limn-review 0.1.123

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 (474) hide show
  1. package/LICENSE +110 -0
  2. package/README.md +133 -0
  3. package/dist/ai/runtime.js +535 -0
  4. package/dist/api/plugins/auth.js +169 -0
  5. package/dist/api/plugins/error-handler.js +114 -0
  6. package/dist/api/plugins/rate-limit.js +855 -0
  7. package/dist/api/plugins/security.js +321 -0
  8. package/dist/api/routes/activity.js +103 -0
  9. package/dist/api/routes/ai-runtime.js +67 -0
  10. package/dist/api/routes/auth.js +194 -0
  11. package/dist/api/routes/billing.js +209 -0
  12. package/dist/api/routes/bot-triage.js +1289 -0
  13. package/dist/api/routes/conflicts.js +730 -0
  14. package/dist/api/routes/contact.js +318 -0
  15. package/dist/api/routes/daily-brief.js +58 -0
  16. package/dist/api/routes/flow.js +71 -0
  17. package/dist/api/routes/health.js +7 -0
  18. package/dist/api/routes/insights.js +200 -0
  19. package/dist/api/routes/me.js +458 -0
  20. package/dist/api/routes/mentions.js +22 -0
  21. package/dist/api/routes/mergers.js +8 -0
  22. package/dist/api/routes/ml-labels.js +109 -0
  23. package/dist/api/routes/open-prs.js +35 -0
  24. package/dist/api/routes/prs.js +1633 -0
  25. package/dist/api/routes/reactions.js +217 -0
  26. package/dist/api/routes/repos.js +563 -0
  27. package/dist/api/routes/search.js +41 -0
  28. package/dist/api/routes/threads.js +118 -0
  29. package/dist/api/routes/timeline.js +150 -0
  30. package/dist/api/routes/users.js +67 -0
  31. package/dist/api/routes/webhooks.js +181 -0
  32. package/dist/api/routes/workspaces.js +322 -0
  33. package/dist/app.js +274 -0
  34. package/dist/ascii.js +19 -0
  35. package/dist/auth/account.js +482 -0
  36. package/dist/auth/crypto.js +46 -0
  37. package/dist/bot-triage/resolve.js +59 -0
  38. package/dist/cli.js +388 -0
  39. package/dist/coding/activity.js +80 -0
  40. package/dist/coding/agent.js +288 -0
  41. package/dist/coding/ai-fix/auto-fix.js +212 -0
  42. package/dist/coding/ai-fix/manager.js +370 -0
  43. package/dist/coding/ai-fix/persist.js +213 -0
  44. package/dist/coding/ai-fix/pr-context.js +58 -0
  45. package/dist/coding/ai-fix/prompts.js +138 -0
  46. package/dist/coding/ai-fix/review-seed.js +357 -0
  47. package/dist/coding/ai-fix/routes.js +425 -0
  48. package/dist/coding/git-ops.js +321 -0
  49. package/dist/coding/git.js +184 -0
  50. package/dist/coding/merge.js +262 -0
  51. package/dist/coding/safe-path.js +75 -0
  52. package/dist/coding/schema.js +43 -0
  53. package/dist/config.js +648 -0
  54. package/dist/conflict/diff.js +304 -0
  55. package/dist/conflict/git.js +118 -0
  56. package/dist/conflict/hash.js +73 -0
  57. package/dist/conflict/janitor.js +218 -0
  58. package/dist/conflict/land.js +675 -0
  59. package/dist/conflict/model-types.js +2 -0
  60. package/dist/conflict/model.js +1081 -0
  61. package/dist/conflict/parse.js +142 -0
  62. package/dist/conflict/seam.js +136 -0
  63. package/dist/conflict/session.js +532 -0
  64. package/dist/conflict/suggestion.js +398 -0
  65. package/dist/conflict/tokens.js +72 -0
  66. package/dist/data-dir.js +112 -0
  67. package/dist/db/actor-lanes.js +213 -0
  68. package/dist/db/automation-ids.js +97 -0
  69. package/dist/db/automation-output.js +349 -0
  70. package/dist/db/blast-radius-query.js +36 -0
  71. package/dist/db/blast-radius.js +226 -0
  72. package/dist/db/bot-dormancy.js +115 -0
  73. package/dist/db/bot-overlap.js +579 -0
  74. package/dist/db/bot-volume.js +722 -0
  75. package/dist/db/bot-window.js +35 -0
  76. package/dist/db/branch-queries.js +310 -0
  77. package/dist/db/change-shape.js +243 -0
  78. package/dist/db/changepoint.js +75 -0
  79. package/dist/db/cleanup.js +36 -0
  80. package/dist/db/client.js +102 -0
  81. package/dist/db/code-loc.js +388 -0
  82. package/dist/db/credits.js +79 -0
  83. package/dist/db/daily-brief.js +406 -0
  84. package/dist/db/dependency-cards.js +145 -0
  85. package/dist/db/erase-account.js +255 -0
  86. package/dist/db/export-account.js +189 -0
  87. package/dist/db/failing-checks.js +124 -0
  88. package/dist/db/file-coupling.js +197 -0
  89. package/dist/db/flow-detail.js +661 -0
  90. package/dist/db/flow-pointers.js +197 -0
  91. package/dist/db/flow-settings.js +67 -0
  92. package/dist/db/forecast.js +114 -0
  93. package/dist/db/line-overlap.js +81 -0
  94. package/dist/db/merge-queue.js +189 -0
  95. package/dist/db/migrate.js +17 -0
  96. package/dist/db/migrations/0000_purple_ben_grimm.sql +155 -0
  97. package/dist/db/migrations/0001_colorful_ozymandias.sql +31 -0
  98. package/dist/db/migrations/0002_famous_sersi.sql +9 -0
  99. package/dist/db/migrations/0003_clever_shinobi_shaw.sql +3 -0
  100. package/dist/db/migrations/0004_pale_scalphunter.sql +1 -0
  101. package/dist/db/migrations/0005_daffy_guardian.sql +2 -0
  102. package/dist/db/migrations/0006_cute_violations.sql +45 -0
  103. package/dist/db/migrations/0007_dark_anthem.sql +2 -0
  104. package/dist/db/migrations/0008_multitenant_accounts.sql +44 -0
  105. package/dist/db/migrations/0009_lean_bodies.sql +13 -0
  106. package/dist/db/migrations/0010_lean_bodies_nullable.sql +56 -0
  107. package/dist/db/migrations/0011_pr_diff_size.sql +10 -0
  108. package/dist/db/migrations/0012_findings_included_default.sql +7 -0
  109. package/dist/db/migrations/0013_review_routing.sql +9 -0
  110. package/dist/db/migrations/0014_account_last_active.sql +6 -0
  111. package/dist/db/migrations/0015_repos_inbox_watch.sql +9 -0
  112. package/dist/db/migrations/0016_repo_viewer_permission.sql +7 -0
  113. package/dist/db/migrations/0017_account_display_name.sql +7 -0
  114. package/dist/db/migrations/0018_finding_comment_kind.sql +7 -0
  115. package/dist/db/migrations/0019_finding_file_in_diff.sql +7 -0
  116. package/dist/db/migrations/0020_claude_review_cost_telemetry.sql +11 -0
  117. package/dist/db/migrations/0021_account_feed_last_seen.sql +7 -0
  118. package/dist/db/migrations/0022_ci_status_events.sql +21 -0
  119. package/dist/db/migrations/0023_ai_usage.sql +21 -0
  120. package/dist/db/migrations/0024_pr_head_ref_name.sql +6 -0
  121. package/dist/db/migrations/0025_account_billing.sql +7 -0
  122. package/dist/db/migrations/0026_ai_credit_allowance.sql +5 -0
  123. package/dist/db/migrations/0027_user_github_type.sql +6 -0
  124. package/dist/db/migrations/0028_bot_review_classification.sql +21 -0
  125. package/dist/db/migrations/0029_bot_mute_rules.sql +19 -0
  126. package/dist/db/migrations/0030_teams.sql +32 -0
  127. package/dist/db/migrations/0031_events_pr_idx.sql +7 -0
  128. package/dist/db/migrations/0032_benchmark_contributions.sql +29 -0
  129. package/dist/db/migrations/0033_thread_addressed_confidence.sql +9 -0
  130. package/dist/db/migrations/0034_thread_resolved_at.sql +6 -0
  131. package/dist/db/migrations/0035_pr_first_review_requested_at.sql +5 -0
  132. package/dist/db/migrations/0036_search_index.sql +25 -0
  133. package/dist/db/migrations/0037_author_indexes.sql +15 -0
  134. package/dist/db/migrations/0038_auto_merge_requests.sql +37 -0
  135. package/dist/db/migrations/0039_branch_status.sql +44 -0
  136. package/dist/db/migrations/0040_pr_review_decision.sql +10 -0
  137. package/dist/db/migrations/0041_branch_commit_detail.sql +38 -0
  138. package/dist/db/migrations/0042_repo_reviewers.sql +176 -0
  139. package/dist/db/migrations/0043_account_reviewers.sql +131 -0
  140. package/dist/db/migrations/0044_workspaces.sql +138 -0
  141. package/dist/db/migrations/0045_workspace_reviewers.sql +180 -0
  142. package/dist/db/migrations/0046_drop_inbox_watch.sql +25 -0
  143. package/dist/db/migrations/0047_ml_comment_labels.sql +40 -0
  144. package/dist/db/migrations/0048_ml_vendor_severity.sql +31 -0
  145. package/dist/db/migrations/0049_seat_pricing_repo_description.sql +21 -0
  146. package/dist/db/migrations/0050_users_app_slug.sql +12 -0
  147. package/dist/db/migrations/0051_auto_merge_queue.sql +17 -0
  148. package/dist/db/migrations/0052_trunk_ci_status_events.sql +43 -0
  149. package/dist/db/migrations/0053_automation_roles.sql +79 -0
  150. package/dist/db/migrations/0054_automation_vendor_kinds.sql +514 -0
  151. package/dist/db/migrations/0055_auto_merge_phase.sql +12 -0
  152. package/dist/db/migrations/0056_pr_mentions.sql +22 -0
  153. package/dist/db/migrations/0057_large_pr_threshold.sql +14 -0
  154. package/dist/db/migrations/0058_pending_mute.sql +53 -0
  155. package/dist/db/migrations/0059_merge_queue_state.sql +33 -0
  156. package/dist/db/migrations/0060_drop_my_turn_dismissals.sql +33 -0
  157. package/dist/db/migrations/0061_auto_merge_durable_anchors.sql +27 -0
  158. package/dist/db/migrations/0062_blast_radius_config.sql +21 -0
  159. package/dist/db/migrations/0063_repo_file_coupling.sql +33 -0
  160. package/dist/db/migrations/0064_pr_content_kind.sql +21 -0
  161. package/dist/db/migrations/0065_workspace_flow_settings.sql +13 -0
  162. package/dist/db/migrations/0066_review_request_events.sql +31 -0
  163. package/dist/db/migrations/0067_pr_security_signals.sql +86 -0
  164. package/dist/db/migrations/0068_my_turn_settings.sql +18 -0
  165. package/dist/db/migrations/0069_my_turn_dismissals.sql +41 -0
  166. package/dist/db/migrations/0070_claude_review_follow_up_ticket.sql +22 -0
  167. package/dist/db/migrations/0071_claude_review_trigger.sql +11 -0
  168. package/dist/db/migrations/0072_commit_message_headline.sql +13 -0
  169. package/dist/db/migrations/0073_claude_review_chat.sql +31 -0
  170. package/dist/db/migrations/0074_adopt_agentic_tables.sql +98 -0
  171. package/dist/db/migrations/0075_review_lens_drop_learnings.sql +15 -0
  172. package/dist/db/migrations/0076_claude_review_threads.sql +17 -0
  173. package/dist/db/migrations/0077_claude_review_ci_failures.sql +10 -0
  174. package/dist/db/migrations/0078_ai_fix_change_report.sql +17 -0
  175. package/dist/db/migrations/0079_claude_finding_story.sql +16 -0
  176. package/dist/db/migrations/meta/0000_snapshot.json +1116 -0
  177. package/dist/db/migrations/meta/0001_snapshot.json +1321 -0
  178. package/dist/db/migrations/meta/0002_snapshot.json +1375 -0
  179. package/dist/db/migrations/meta/0003_snapshot.json +1396 -0
  180. package/dist/db/migrations/meta/0004_snapshot.json +1416 -0
  181. package/dist/db/migrations/meta/0005_snapshot.json +1430 -0
  182. package/dist/db/migrations/meta/0006_snapshot.json +1745 -0
  183. package/dist/db/migrations/meta/0007_snapshot.json +1759 -0
  184. package/dist/db/migrations/meta/_journal.json +566 -0
  185. package/dist/db/migrations-pg/0000_tired_alex_power.sql +268 -0
  186. package/dist/db/migrations-pg/0001_dizzy_mockingbird.sql +3 -0
  187. package/dist/db/migrations-pg/0002_glorious_ikaris.sql +4 -0
  188. package/dist/db/migrations-pg/0003_melted_secret_warriors.sql +2 -0
  189. package/dist/db/migrations-pg/0004_numerous_triton.sql +1 -0
  190. package/dist/db/migrations-pg/0005_thick_blockbuster.sql +2 -0
  191. package/dist/db/migrations-pg/0006_majestic_dracula.sql +1 -0
  192. package/dist/db/migrations-pg/0007_same_human_torch.sql +2 -0
  193. package/dist/db/migrations-pg/0008_slimy_toxin.sql +1 -0
  194. package/dist/db/migrations-pg/0009_fuzzy_jubilee.sql +4 -0
  195. package/dist/db/migrations-pg/0010_late_hammerhead.sql +1 -0
  196. package/dist/db/migrations-pg/0011_happy_leech.sql +16 -0
  197. package/dist/db/migrations-pg/0012_woozy_captain_midlands.sql +16 -0
  198. package/dist/db/migrations-pg/0013_yielding_nicolaos.sql +1 -0
  199. package/dist/db/migrations-pg/0014_wakeful_bill_hollister.sql +2 -0
  200. package/dist/db/migrations-pg/0015_aspiring_black_tom.sql +1 -0
  201. package/dist/db/migrations-pg/0016_cute_ghost_rider.sql +30 -0
  202. package/dist/db/migrations-pg/0017_far_changeling.sql +24 -0
  203. package/dist/db/migrations-pg/0018_fancy_miss_america.sql +1 -0
  204. package/dist/db/migrations-pg/0019_benchmark_contributions.sql +22 -0
  205. package/dist/db/migrations-pg/0020_majestic_edwin_jarvis.sql +3 -0
  206. package/dist/db/migrations-pg/0021_green_salo.sql +1 -0
  207. package/dist/db/migrations-pg/0022_wise_baron_strucker.sql +1 -0
  208. package/dist/db/migrations-pg/0023_search_index.sql +19 -0
  209. package/dist/db/migrations-pg/0024_author_indexes.sql +9 -0
  210. package/dist/db/migrations-pg/0025_auto_merge_requests.sql +26 -0
  211. package/dist/db/migrations-pg/0026_branch_status.sql +32 -0
  212. package/dist/db/migrations-pg/0027_pr_review_decision.sql +5 -0
  213. package/dist/db/migrations-pg/0028_branch_commit_detail.sql +9 -0
  214. package/dist/db/migrations-pg/0029_repo_reviewers.sql +127 -0
  215. package/dist/db/migrations-pg/0030_account_reviewers.sql +77 -0
  216. package/dist/db/migrations-pg/0031_workspaces.sql +131 -0
  217. package/dist/db/migrations-pg/0032_workspace_reviewers.sql +165 -0
  218. package/dist/db/migrations-pg/0033_drop_inbox_watch.sql +14 -0
  219. package/dist/db/migrations-pg/0034_ml_comment_labels.sql +33 -0
  220. package/dist/db/migrations-pg/0035_ml_vendor_severity.sql +16 -0
  221. package/dist/db/migrations-pg/0036_seat_pricing_repo_description.sql +12 -0
  222. package/dist/db/migrations-pg/0037_users_app_slug.sql +9 -0
  223. package/dist/db/migrations-pg/0038_auto_merge_queue.sql +10 -0
  224. package/dist/db/migrations-pg/0039_trunk_ci_status_events.sql +27 -0
  225. package/dist/db/migrations-pg/0040_automation_roles.sql +63 -0
  226. package/dist/db/migrations-pg/0041_automation_vendor_kinds.sql +488 -0
  227. package/dist/db/migrations-pg/0042_auto_merge_phase.sql +8 -0
  228. package/dist/db/migrations-pg/0043_pr_mentions.sql +19 -0
  229. package/dist/db/migrations-pg/0044_large_pr_threshold.sql +6 -0
  230. package/dist/db/migrations-pg/0045_pending_mute.sql +26 -0
  231. package/dist/db/migrations-pg/0046_merge_queue_state.sql +18 -0
  232. package/dist/db/migrations-pg/0047_drop_my_turn_dismissals.sql +21 -0
  233. package/dist/db/migrations-pg/0048_auto_merge_durable_anchors.sql +27 -0
  234. package/dist/db/migrations-pg/0049_blast_radius_config.sql +8 -0
  235. package/dist/db/migrations-pg/0050_repo_file_coupling.sql +13 -0
  236. package/dist/db/migrations-pg/0051_pr_content_kind.sql +6 -0
  237. package/dist/db/migrations-pg/0052_workspace_flow_settings.sql +4 -0
  238. package/dist/db/migrations-pg/0053_review_request_events.sql +18 -0
  239. package/dist/db/migrations-pg/0054_pr_security_signals.sql +59 -0
  240. package/dist/db/migrations-pg/0055_my_turn_settings.sql +6 -0
  241. package/dist/db/migrations-pg/0056_my_turn_dismissals.sql +21 -0
  242. package/dist/db/migrations-pg/0057_claude_review_follow_up_ticket.sql +8 -0
  243. package/dist/db/migrations-pg/0058_claude_review_trigger.sql +4 -0
  244. package/dist/db/migrations-pg/0059_commit_message_headline.sql +3 -0
  245. package/dist/db/migrations-pg/0060_claude_review_chat.sql +24 -0
  246. package/dist/db/migrations-pg/0061_adopt_agentic_tables.sql +79 -0
  247. package/dist/db/migrations-pg/0062_review_lens_drop_learnings.sql +5 -0
  248. package/dist/db/migrations-pg/0063_claude_review_threads.sql +7 -0
  249. package/dist/db/migrations-pg/0064_claude_review_ci_failures.sql +4 -0
  250. package/dist/db/migrations-pg/0065_ai_fix_change_report.sql +9 -0
  251. package/dist/db/migrations-pg/0066_claude_finding_story.sql +7 -0
  252. package/dist/db/migrations-pg/meta/0000_snapshot.json +2137 -0
  253. package/dist/db/migrations-pg/meta/0001_snapshot.json +2143 -0
  254. package/dist/db/migrations-pg/meta/0002_snapshot.json +2170 -0
  255. package/dist/db/migrations-pg/meta/0003_snapshot.json +2182 -0
  256. package/dist/db/migrations-pg/meta/0004_snapshot.json +2188 -0
  257. package/dist/db/migrations-pg/meta/0005_snapshot.json +2201 -0
  258. package/dist/db/migrations-pg/meta/0006_snapshot.json +2207 -0
  259. package/dist/db/migrations-pg/meta/0007_snapshot.json +2219 -0
  260. package/dist/db/migrations-pg/meta/0008_snapshot.json +2226 -0
  261. package/dist/db/migrations-pg/meta/0009_snapshot.json +2250 -0
  262. package/dist/db/migrations-pg/meta/0010_snapshot.json +2256 -0
  263. package/dist/db/migrations-pg/meta/0011_snapshot.json +2412 -0
  264. package/dist/db/migrations-pg/meta/0012_snapshot.json +2528 -0
  265. package/dist/db/migrations-pg/meta/0013_snapshot.json +2534 -0
  266. package/dist/db/migrations-pg/meta/0014_snapshot.json +2547 -0
  267. package/dist/db/migrations-pg/meta/0015_snapshot.json +2553 -0
  268. package/dist/db/migrations-pg/meta/0016_snapshot.json +2774 -0
  269. package/dist/db/migrations-pg/meta/0017_snapshot.json +2999 -0
  270. package/dist/db/migrations-pg/meta/0018_snapshot.json +3020 -0
  271. package/dist/db/migrations-pg/meta/0020_snapshot.json +3228 -0
  272. package/dist/db/migrations-pg/meta/0021_snapshot.json +3234 -0
  273. package/dist/db/migrations-pg/meta/0022_snapshot.json +3240 -0
  274. package/dist/db/migrations-pg/meta/_journal.json +475 -0
  275. package/dist/db/ml-labels.js +1666 -0
  276. package/dist/db/my-turn-dismissals.js +343 -0
  277. package/dist/db/my-turn-settings.js +34 -0
  278. package/dist/db/pending-classify.js +46 -0
  279. package/dist/db/pending-mute.js +171 -0
  280. package/dist/db/pending-tabs.js +238 -0
  281. package/dist/db/period-metrics.js +820 -0
  282. package/dist/db/person-period.js +763 -0
  283. package/dist/db/pr-intervals.js +930 -0
  284. package/dist/db/pr-liveness.js +240 -0
  285. package/dist/db/pr-mentions.js +279 -0
  286. package/dist/db/pr-merge-queue-stamp.js +91 -0
  287. package/dist/db/queries.js +14631 -0
  288. package/dist/db/reaction-targets.js +94 -0
  289. package/dist/db/repo-activity.js +171 -0
  290. package/dist/db/retention.js +138 -0
  291. package/dist/db/review-threads-for-review.js +240 -0
  292. package/dist/db/run-migrations.js +24 -0
  293. package/dist/db/schema.pg.js +1220 -0
  294. package/dist/db/schema.sqlite.js +1801 -0
  295. package/dist/db/search.js +317 -0
  296. package/dist/db/security-alerts.js +218 -0
  297. package/dist/db/synthesis-input.js +565 -0
  298. package/dist/db/triage.js +320 -0
  299. package/dist/db/usage.js +63 -0
  300. package/dist/db/work-plan.js +1086 -0
  301. package/dist/db/working-hours.js +161 -0
  302. package/dist/feed/my-turn.js +122 -0
  303. package/dist/github/actions-logs.js +397 -0
  304. package/dist/github/auth.js +86 -0
  305. package/dist/github/branch-queries.js +229 -0
  306. package/dist/github/client.js +454 -0
  307. package/dist/github/codeowners.js +221 -0
  308. package/dist/github/commit-checks.js +105 -0
  309. package/dist/github/compare.js +110 -0
  310. package/dist/github/diff-anchor.js +227 -0
  311. package/dist/github/mutations.js +706 -0
  312. package/dist/github/pr-file-content.js +254 -0
  313. package/dist/github/pr-liveness.js +161 -0
  314. package/dist/github/queries.js +875 -0
  315. package/dist/github/rate-budget.js +129 -0
  316. package/dist/github/reactions.js +161 -0
  317. package/dist/github/reviewer-suggest.js +104 -0
  318. package/dist/github/team-reviewers.js +96 -0
  319. package/dist/index.js +184 -0
  320. package/dist/merge/auto-merge-runner.js +960 -0
  321. package/dist/ml/severity-client.js +218 -0
  322. package/dist/pr/detail-enricher.js +26 -0
  323. package/dist/pro/bind.js +302 -0
  324. package/dist/pro/contract.js +37 -0
  325. package/dist/pro/migrate.js +64 -0
  326. package/dist/review/agent-context.js +127 -0
  327. package/dist/review/agent.js +385 -0
  328. package/dist/review/agentic.js +59 -0
  329. package/dist/review/auth.js +94 -0
  330. package/dist/review/chat-agent.js +179 -0
  331. package/dist/review/claude-review/ai-ready.js +16 -0
  332. package/dist/review/claude-review/auto-settings.js +139 -0
  333. package/dist/review/claude-review/auto.js +244 -0
  334. package/dist/review/claude-review/chat.js +489 -0
  335. package/dist/review/claude-review/ci-failures.js +350 -0
  336. package/dist/review/claude-review/follow-up.js +310 -0
  337. package/dist/review/claude-review/manager.js +686 -0
  338. package/dist/review/claude-review/persist.js +996 -0
  339. package/dist/review/claude-review/prompts.js +357 -0
  340. package/dist/review/claude-review/routes.js +518 -0
  341. package/dist/review/claude-review/routing.js +61 -0
  342. package/dist/review/claude-review/specialists.js +190 -0
  343. package/dist/review/claude-review/threads.js +265 -0
  344. package/dist/review/claude-review/ticket.js +282 -0
  345. package/dist/review/clone-hygiene.js +380 -0
  346. package/dist/review/clone-manager.js +367 -0
  347. package/dist/review/llm.js +113 -0
  348. package/dist/review/model-options.js +48 -0
  349. package/dist/review/plugin-providers.js +12 -0
  350. package/dist/review/post-review.js +216 -0
  351. package/dist/review/post-seam.js +161 -0
  352. package/dist/review/prepare.js +168 -0
  353. package/dist/review/pricing.js +17 -0
  354. package/dist/review/schema.js +156 -0
  355. package/dist/review/submit-map.js +41 -0
  356. package/dist/review/usage.js +90 -0
  357. package/dist/shared/claude-review.js +335 -0
  358. package/dist/shared/conflict-fold.js +151 -0
  359. package/dist/shared/conflicts.js +30 -0
  360. package/dist/shared/flow-settings.js +191 -0
  361. package/dist/shared/index.js +8 -0
  362. package/dist/shared/my-turn-settings.js +238 -0
  363. package/dist/shared/pending-rules.js +281 -0
  364. package/dist/shared/product.js +54 -0
  365. package/dist/shared/types.js +896 -0
  366. package/dist/status.js +386 -0
  367. package/dist/sync/adaptive.js +185 -0
  368. package/dist/sync/app-attribution.js +66 -0
  369. package/dist/sync/auth-notices.js +36 -0
  370. package/dist/sync/backfill-ci-history.js +315 -0
  371. package/dist/sync/backfill-commit-headlines.js +136 -0
  372. package/dist/sync/backfill-pr-security.js +175 -0
  373. package/dist/sync/backfill-review-requests.js +97 -0
  374. package/dist/sync/benchmark-rollup.js +50 -0
  375. package/dist/sync/bot-detection.js +309 -0
  376. package/dist/sync/bot-resolution-markers.js +30 -0
  377. package/dist/sync/branch-status.js +634 -0
  378. package/dist/sync/classify-change-shape.js +150 -0
  379. package/dist/sync/commit-files.js +74 -0
  380. package/dist/sync/derive-thread-state.js +99 -0
  381. package/dist/sync/drain-review-threads.js +212 -0
  382. package/dist/sync/hydrate-detail.js +482 -0
  383. package/dist/sync/mention-scan.js +89 -0
  384. package/dist/sync/ml-enrichment.js +478 -0
  385. package/dist/sync/pr-change-signal.js +96 -0
  386. package/dist/sync/pr-liveness-sweep.js +139 -0
  387. package/dist/sync/pr-settle.js +381 -0
  388. package/dist/sync/refresh-pr.js +163 -0
  389. package/dist/sync/reparse-vendor-badges.js +495 -0
  390. package/dist/sync/resync-after-write.js +280 -0
  391. package/dist/sync/review-fingerprint.js +117 -0
  392. package/dist/sync/reviewer-behavior.js +103 -0
  393. package/dist/sync/reviewer-classify.js +503 -0
  394. package/dist/sync/routing-files.js +97 -0
  395. package/dist/sync/scheduled-jobs.js +12 -0
  396. package/dist/sync/scheduler.js +159 -0
  397. package/dist/sync/security-detect.js +521 -0
  398. package/dist/sync/sync-manager.js +750 -0
  399. package/dist/sync/sync-one-pr.js +205 -0
  400. package/dist/sync/sync-repo.js +400 -0
  401. package/dist/sync/unsettled-prs.js +506 -0
  402. package/dist/sync/upsert.js +1190 -0
  403. package/package.json +56 -0
  404. package/public/apple-touch-icon.png +0 -0
  405. package/public/assets/AiFixTab-CQP6PT5u.js +2 -0
  406. package/public/assets/ClaudeReviewTab-DQJ-58ZA.js +8 -0
  407. package/public/assets/PrBotBehaviourTab-CCnFrWbC.js +1 -0
  408. package/public/assets/archivo-latin-600-BN-JkNrl.woff2 +0 -0
  409. package/public/assets/highlight-BEHUn5zE.css +10 -0
  410. package/public/assets/highlight-CIIZLa6Z.js +12 -0
  411. package/public/assets/index-BDnYs6zg.js +73 -0
  412. package/public/assets/index-mCuI--RC.css +1 -0
  413. package/public/assets/markdown-I_JLLVAZ.js +32 -0
  414. package/public/assets/perfProbe-Da13EhTE.js +1 -0
  415. package/public/assets/tanstack-5qsxxaLe.js +17 -0
  416. package/public/assets/vis-C3BCkP5U.js +1280 -0
  417. package/public/assets/vis-ziCVehMy.css +1 -0
  418. package/public/favicon-16.png +0 -0
  419. package/public/favicon-32.png +0 -0
  420. package/public/favicon-48.png +0 -0
  421. package/public/favicon.svg +5 -0
  422. package/public/index.html +41 -0
  423. package/public-landing/apple-touch-icon.png +0 -0
  424. package/public-landing/assets/archivo-latin-500-BWmvx2Mg.woff2 +0 -0
  425. package/public-landing/assets/archivo-latin-600-BN-JkNrl.woff2 +0 -0
  426. package/public-landing/assets/index-CA3eEGXO.js +40 -0
  427. package/public-landing/assets/index-naQrQ6Fe.css +1 -0
  428. package/public-landing/assets/jetbrains-mono-latin-400-RruCX7RW.woff2 +0 -0
  429. package/public-landing/assets/newsreader-latin-400-DExrRRrN.woff2 +0 -0
  430. package/public-landing/assets/newsreader-latin-400-italic-b0I-AwbV.woff2 +0 -0
  431. package/public-landing/bots/index.html +156 -0
  432. package/public-landing/contact/index.html +156 -0
  433. package/public-landing/cookies/index.html +156 -0
  434. package/public-landing/demo/limn-walkthrough-poster.jpg +0 -0
  435. package/public-landing/demo/limn-walkthrough.cues.json +44 -0
  436. package/public-landing/demo/limn-walkthrough.mp4 +0 -0
  437. package/public-landing/favicon-16.png +0 -0
  438. package/public-landing/favicon-32.png +0 -0
  439. package/public-landing/favicon-48.png +0 -0
  440. package/public-landing/favicon.svg +5 -0
  441. package/public-landing/features/index.html +156 -0
  442. package/public-landing/for-developers/index.html +156 -0
  443. package/public-landing/for-managers/index.html +156 -0
  444. package/public-landing/how-it-works/index.html +156 -0
  445. package/public-landing/how-we-measure/index.html +156 -0
  446. package/public-landing/icon-192.png +0 -0
  447. package/public-landing/icon-512.png +0 -0
  448. package/public-landing/index.html +156 -0
  449. package/public-landing/insights/index.html +156 -0
  450. package/public-landing/og-image.png +0 -0
  451. package/public-landing/pricing/index.html +156 -0
  452. package/public-landing/privacy/index.html +156 -0
  453. package/public-landing/pro/index.html +156 -0
  454. package/public-landing/reviews/index.html +156 -0
  455. package/public-landing/robots.txt +8 -0
  456. package/public-landing/shots/benchmark.png +0 -0
  457. package/public-landing/shots/bot-roi.png +0 -0
  458. package/public-landing/shots/bot-settings.png +0 -0
  459. package/public-landing/shots/chronology.png +0 -0
  460. package/public-landing/shots/feed.png +0 -0
  461. package/public-landing/shots/flow-metrics.png +0 -0
  462. package/public-landing/shots/free-reports.png +0 -0
  463. package/public-landing/shots/pending-board.png +0 -0
  464. package/public-landing/shots/pending-card.png +0 -0
  465. package/public-landing/shots/period-report.png +0 -0
  466. package/public-landing/shots/pr-detail.png +0 -0
  467. package/public-landing/shots/pr-threads.png +0 -0
  468. package/public-landing/shots/reach.png +0 -0
  469. package/public-landing/shots/repo-rows.png +0 -0
  470. package/public-landing/shots/severity-findings.png +0 -0
  471. package/public-landing/shots/severity-strip.png +0 -0
  472. package/public-landing/site.webmanifest +14 -0
  473. package/public-landing/sitemap.xml +51 -0
  474. package/public-landing/terms/index.html +156 -0
@@ -0,0 +1,73 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ClaudeReviewTab-DQJ-58ZA.js","assets/tanstack-5qsxxaLe.js","assets/markdown-I_JLLVAZ.js","assets/highlight-CIIZLa6Z.js","assets/highlight-BEHUn5zE.css","assets/vis-C3BCkP5U.js","assets/vis-ziCVehMy.css","assets/AiFixTab-CQP6PT5u.js","assets/PrBotBehaviourTab-CCnFrWbC.js"])))=>i.map(i=>d[i]);
2
+ import{b as XT,R as Pu,i as Oe,j as t,r as f,l as He,e as tt,s as Ct,d as Or,u as rc,f as ZT,n as JT,a as qN,h as Xv,k as e$,c as t$,Q as n$,P as r$}from"./tanstack-5qsxxaLe.js";import{d as $g,M as s$,r as a$,a as o$,b as i$}from"./markdown-I_JLLVAZ.js";import{r as l$,H as vh}from"./highlight-CIIZLa6Z.js";import{D as Zv,T as c$}from"./vis-C3BCkP5U.js";(function(){const n=document.createElement("link").relList;if(n&&n.supports&&n.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))s(a);new MutationObserver(a=>{for(const i of a)if(i.type==="childList")for(const c of i.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&s(c)}).observe(document,{childList:!0,subtree:!0});function r(a){const i={};return a.integrity&&(i.integrity=a.integrity),a.referrerPolicy&&(i.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?i.credentials="include":a.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function s(a){if(a.ep)return;a.ep=!0;const i=r(a);fetch(a.href,i)}})();const d$="modulepreload",u$=function(e){return"/app/"+e},Jv={},up=function(n,r,s){let a=Promise.resolve();if(r&&r.length>0){let c=function(m){return Promise.all(m.map(h=>Promise.resolve(h).then(g=>({status:"fulfilled",value:g}),g=>({status:"rejected",reason:g}))))};document.getElementsByTagName("link");const d=document.querySelector("meta[property=csp-nonce]"),u=(d==null?void 0:d.nonce)||(d==null?void 0:d.getAttribute("nonce"));a=c(r.map(m=>{if(m=u$(m),m in Jv)return;Jv[m]=!0;const h=m.endsWith(".css"),g=h?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${m}"]${g}`))return;const x=document.createElement("link");if(x.rel=h?"stylesheet":d$,h||(x.as="script"),x.crossOrigin="",x.href=m,u&&x.setAttribute("nonce",u),document.head.appendChild(x),h)return new Promise((y,b)=>{x.addEventListener("load",y),x.addEventListener("error",()=>b(new Error(`Unable to preload CSS for ${m}`)))})}))}function i(c){const d=new Event("vite:preloadError",{cancelable:!0});if(d.payload=c,window.dispatchEvent(d),!d.defaultPrevented)throw c}return a.then(c=>{for(const d of c||[])d.status==="rejected"&&i(d.reason);return n().catch(i)})};var Eu={},_g={exports:{}},Kr={},Pg={exports:{}},Eg={};/**
3
+ * @license React
4
+ * scheduler.production.min.js
5
+ *
6
+ * Copyright (c) Facebook, Inc. and its affiliates.
7
+ *
8
+ * This source code is licensed under the MIT license found in the
9
+ * LICENSE file in the root directory of this source tree.
10
+ */var ek;function h$(){return ek||(ek=1,(function(e){function n(B,O){var E=B.length;B.push(O);e:for(;0<E;){var ee=E-1>>>1,K=B[ee];if(0<a(K,O))B[ee]=O,B[E]=K,E=ee;else break e}}function r(B){return B.length===0?null:B[0]}function s(B){if(B.length===0)return null;var O=B[0],E=B.pop();if(E!==O){B[0]=E;e:for(var ee=0,K=B.length,U=K>>>1;ee<U;){var Q=2*(ee+1)-1,J=B[Q],ne=Q+1,ae=B[ne];if(0>a(J,E))ne<K&&0>a(ae,J)?(B[ee]=ae,B[ne]=E,ee=ne):(B[ee]=J,B[Q]=E,ee=Q);else if(ne<K&&0>a(ae,E))B[ee]=ae,B[ne]=E,ee=ne;else break e}}return O}function a(B,O){var E=B.sortIndex-O.sortIndex;return E!==0?E:B.id-O.id}if(typeof performance=="object"&&typeof performance.now=="function"){var i=performance;e.unstable_now=function(){return i.now()}}else{var c=Date,d=c.now();e.unstable_now=function(){return c.now()-d}}var u=[],m=[],h=1,g=null,x=3,y=!1,b=!1,w=!1,k=typeof setTimeout=="function"?setTimeout:null,j=typeof clearTimeout=="function"?clearTimeout:null,N=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function I(B){for(var O=r(m);O!==null;){if(O.callback===null)s(m);else if(O.startTime<=B)s(m),O.sortIndex=O.expirationTime,n(u,O);else break;O=r(m)}}function S(B){if(w=!1,I(B),!b)if(r(u)!==null)b=!0,te(T);else{var O=r(m);O!==null&&H(S,O.startTime-B)}}function T(B,O){b=!1,w&&(w=!1,j(C),C=-1),y=!0;var E=x;try{for(I(O),g=r(u);g!==null&&(!(g.expirationTime>O)||B&&!M());){var ee=g.callback;if(typeof ee=="function"){g.callback=null,x=g.priorityLevel;var K=ee(g.expirationTime<=O);O=e.unstable_now(),typeof K=="function"?g.callback=K:g===r(u)&&s(u),I(O)}else s(u);g=r(u)}if(g!==null)var U=!0;else{var Q=r(m);Q!==null&&H(S,Q.startTime-O),U=!1}return U}finally{g=null,x=E,y=!1}}var $=!1,P=null,C=-1,L=5,F=-1;function M(){return!(e.unstable_now()-F<L)}function D(){if(P!==null){var B=e.unstable_now();F=B;var O=!0;try{O=P(!0,B)}finally{O?A():($=!1,P=null)}}else $=!1}var A;if(typeof N=="function")A=function(){N(D)};else if(typeof MessageChannel<"u"){var W=new MessageChannel,z=W.port2;W.port1.onmessage=D,A=function(){z.postMessage(null)}}else A=function(){k(D,0)};function te(B){P=B,$||($=!0,A())}function H(B,O){C=k(function(){B(e.unstable_now())},O)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(B){B.callback=null},e.unstable_continueExecution=function(){b||y||(b=!0,te(T))},e.unstable_forceFrameRate=function(B){0>B||125<B?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):L=0<B?Math.floor(1e3/B):5},e.unstable_getCurrentPriorityLevel=function(){return x},e.unstable_getFirstCallbackNode=function(){return r(u)},e.unstable_next=function(B){switch(x){case 1:case 2:case 3:var O=3;break;default:O=x}var E=x;x=O;try{return B()}finally{x=E}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(B,O){switch(B){case 1:case 2:case 3:case 4:case 5:break;default:B=3}var E=x;x=B;try{return O()}finally{x=E}},e.unstable_scheduleCallback=function(B,O,E){var ee=e.unstable_now();switch(typeof E=="object"&&E!==null?(E=E.delay,E=typeof E=="number"&&0<E?ee+E:ee):E=ee,B){case 1:var K=-1;break;case 2:K=250;break;case 5:K=1073741823;break;case 4:K=1e4;break;default:K=5e3}return K=E+K,B={id:h++,callback:O,priorityLevel:B,startTime:E,expirationTime:K,sortIndex:-1},E>ee?(B.sortIndex=E,n(m,B),r(u)===null&&B===r(m)&&(w?(j(C),C=-1):w=!0,H(S,E-ee))):(B.sortIndex=K,n(u,B),b||y||(b=!0,te(T))),B},e.unstable_shouldYield=M,e.unstable_wrapCallback=function(B){var O=x;return function(){var E=x;x=O;try{return B.apply(this,arguments)}finally{x=E}}}})(Eg)),Eg}var tk;function p$(){return tk||(tk=1,Pg.exports=h$()),Pg.exports}/**
11
+ * @license React
12
+ * react-dom.production.min.js
13
+ *
14
+ * Copyright (c) Facebook, Inc. and its affiliates.
15
+ *
16
+ * This source code is licensed under the MIT license found in the
17
+ * LICENSE file in the root directory of this source tree.
18
+ */var nk;function m$(){if(nk)return Kr;nk=1;var e=XT(),n=p$();function r(o){for(var l="https://reactjs.org/docs/error-decoder.html?invariant="+o,p=1;p<arguments.length;p++)l+="&args[]="+encodeURIComponent(arguments[p]);return"Minified React error #"+o+"; visit "+l+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var s=new Set,a={};function i(o,l){c(o,l),c(o+"Capture",l)}function c(o,l){for(a[o]=l,o=0;o<l.length;o++)s.add(l[o])}var d=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),u=Object.prototype.hasOwnProperty,m=/^[: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]*$/,h={},g={};function x(o){return u.call(g,o)?!0:u.call(h,o)?!1:m.test(o)?g[o]=!0:(h[o]=!0,!1)}function y(o,l,p,v){if(p!==null&&p.type===0)return!1;switch(typeof l){case"function":case"symbol":return!0;case"boolean":return v?!1:p!==null?!p.acceptsBooleans:(o=o.toLowerCase().slice(0,5),o!=="data-"&&o!=="aria-");default:return!1}}function b(o,l,p,v){if(l===null||typeof l>"u"||y(o,l,p,v))return!0;if(v)return!1;if(p!==null)switch(p.type){case 3:return!l;case 4:return l===!1;case 5:return isNaN(l);case 6:return isNaN(l)||1>l}return!1}function w(o,l,p,v,R,_,q){this.acceptsBooleans=l===2||l===3||l===4,this.attributeName=v,this.attributeNamespace=R,this.mustUseProperty=p,this.propertyName=o,this.type=l,this.sanitizeURL=_,this.removeEmptyString=q}var k={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(o){k[o]=new w(o,0,!1,o,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(o){var l=o[0];k[l]=new w(l,1,!1,o[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(o){k[o]=new w(o,2,!1,o.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(o){k[o]=new w(o,2,!1,o,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(o){k[o]=new w(o,3,!1,o.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(o){k[o]=new w(o,3,!0,o,null,!1,!1)}),["capture","download"].forEach(function(o){k[o]=new w(o,4,!1,o,null,!1,!1)}),["cols","rows","size","span"].forEach(function(o){k[o]=new w(o,6,!1,o,null,!1,!1)}),["rowSpan","start"].forEach(function(o){k[o]=new w(o,5,!1,o.toLowerCase(),null,!1,!1)});var j=/[\-:]([a-z])/g;function N(o){return o[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(o){var l=o.replace(j,N);k[l]=new w(l,1,!1,o,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(o){var l=o.replace(j,N);k[l]=new w(l,1,!1,o,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(o){var l=o.replace(j,N);k[l]=new w(l,1,!1,o,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(o){k[o]=new w(o,1,!1,o.toLowerCase(),null,!1,!1)}),k.xlinkHref=new w("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(o){k[o]=new w(o,1,!1,o.toLowerCase(),null,!0,!0)});function I(o,l,p,v){var R=k.hasOwnProperty(l)?k[l]:null;(R!==null?R.type!==0:v||!(2<l.length)||l[0]!=="o"&&l[0]!=="O"||l[1]!=="n"&&l[1]!=="N")&&(b(l,p,R,v)&&(p=null),v||R===null?x(l)&&(p===null?o.removeAttribute(l):o.setAttribute(l,""+p)):R.mustUseProperty?o[R.propertyName]=p===null?R.type===3?!1:"":p:(l=R.attributeName,v=R.attributeNamespace,p===null?o.removeAttribute(l):(R=R.type,p=R===3||R===4&&p===!0?"":""+p,v?o.setAttributeNS(v,l,p):o.setAttribute(l,p))))}var S=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,T=Symbol.for("react.element"),$=Symbol.for("react.portal"),P=Symbol.for("react.fragment"),C=Symbol.for("react.strict_mode"),L=Symbol.for("react.profiler"),F=Symbol.for("react.provider"),M=Symbol.for("react.context"),D=Symbol.for("react.forward_ref"),A=Symbol.for("react.suspense"),W=Symbol.for("react.suspense_list"),z=Symbol.for("react.memo"),te=Symbol.for("react.lazy"),H=Symbol.for("react.offscreen"),B=Symbol.iterator;function O(o){return o===null||typeof o!="object"?null:(o=B&&o[B]||o["@@iterator"],typeof o=="function"?o:null)}var E=Object.assign,ee;function K(o){if(ee===void 0)try{throw Error()}catch(p){var l=p.stack.trim().match(/\n( *(at )?)/);ee=l&&l[1]||""}return`
19
+ `+ee+o}var U=!1;function Q(o,l){if(!o||U)return"";U=!0;var p=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(l)if(l=function(){throw Error()},Object.defineProperty(l.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(l,[])}catch(ve){var v=ve}Reflect.construct(o,[],l)}else{try{l.call()}catch(ve){v=ve}o.call(l.prototype)}else{try{throw Error()}catch(ve){v=ve}o()}}catch(ve){if(ve&&v&&typeof ve.stack=="string"){for(var R=ve.stack.split(`
20
+ `),_=v.stack.split(`
21
+ `),q=R.length-1,Z=_.length-1;1<=q&&0<=Z&&R[q]!==_[Z];)Z--;for(;1<=q&&0<=Z;q--,Z--)if(R[q]!==_[Z]){if(q!==1||Z!==1)do if(q--,Z--,0>Z||R[q]!==_[Z]){var ie=`
22
+ `+R[q].replace(" at new "," at ");return o.displayName&&ie.includes("<anonymous>")&&(ie=ie.replace("<anonymous>",o.displayName)),ie}while(1<=q&&0<=Z);break}}}finally{U=!1,Error.prepareStackTrace=p}return(o=o?o.displayName||o.name:"")?K(o):""}function J(o){switch(o.tag){case 5:return K(o.type);case 16:return K("Lazy");case 13:return K("Suspense");case 19:return K("SuspenseList");case 0:case 2:case 15:return o=Q(o.type,!1),o;case 11:return o=Q(o.type.render,!1),o;case 1:return o=Q(o.type,!0),o;default:return""}}function ne(o){if(o==null)return null;if(typeof o=="function")return o.displayName||o.name||null;if(typeof o=="string")return o;switch(o){case P:return"Fragment";case $:return"Portal";case L:return"Profiler";case C:return"StrictMode";case A:return"Suspense";case W:return"SuspenseList"}if(typeof o=="object")switch(o.$$typeof){case M:return(o.displayName||"Context")+".Consumer";case F:return(o._context.displayName||"Context")+".Provider";case D:var l=o.render;return o=o.displayName,o||(o=l.displayName||l.name||"",o=o!==""?"ForwardRef("+o+")":"ForwardRef"),o;case z:return l=o.displayName||null,l!==null?l:ne(o.type)||"Memo";case te:l=o._payload,o=o._init;try{return ne(o(l))}catch{}}return null}function ae(o){var l=o.type;switch(o.tag){case 24:return"Cache";case 9:return(l.displayName||"Context")+".Consumer";case 10:return(l._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return o=l.render,o=o.displayName||o.name||"",l.displayName||(o!==""?"ForwardRef("+o+")":"ForwardRef");case 7:return"Fragment";case 5:return l;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return ne(l);case 8:return l===C?"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 l=="function")return l.displayName||l.name||null;if(typeof l=="string")return l}return null}function we(o){switch(typeof o){case"boolean":case"number":case"string":case"undefined":return o;case"object":return o;default:return""}}function $e(o){var l=o.type;return(o=o.nodeName)&&o.toLowerCase()==="input"&&(l==="checkbox"||l==="radio")}function Fe(o){var l=$e(o)?"checked":"value",p=Object.getOwnPropertyDescriptor(o.constructor.prototype,l),v=""+o[l];if(!o.hasOwnProperty(l)&&typeof p<"u"&&typeof p.get=="function"&&typeof p.set=="function"){var R=p.get,_=p.set;return Object.defineProperty(o,l,{configurable:!0,get:function(){return R.call(this)},set:function(q){v=""+q,_.call(this,q)}}),Object.defineProperty(o,l,{enumerable:p.enumerable}),{getValue:function(){return v},setValue:function(q){v=""+q},stopTracking:function(){o._valueTracker=null,delete o[l]}}}}function oe(o){o._valueTracker||(o._valueTracker=Fe(o))}function re(o){if(!o)return!1;var l=o._valueTracker;if(!l)return!0;var p=l.getValue(),v="";return o&&(v=$e(o)?o.checked?"true":"false":o.value),o=v,o!==p?(l.setValue(o),!0):!1}function X(o){if(o=o||(typeof document<"u"?document:void 0),typeof o>"u")return null;try{return o.activeElement||o.body}catch{return o.body}}function le(o,l){var p=l.checked;return E({},l,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:p??o._wrapperState.initialChecked})}function Ne(o,l){var p=l.defaultValue==null?"":l.defaultValue,v=l.checked!=null?l.checked:l.defaultChecked;p=we(l.value!=null?l.value:p),o._wrapperState={initialChecked:v,initialValue:p,controlled:l.type==="checkbox"||l.type==="radio"?l.checked!=null:l.value!=null}}function Ve(o,l){l=l.checked,l!=null&&I(o,"checked",l,!1)}function me(o,l){Ve(o,l);var p=we(l.value),v=l.type;if(p!=null)v==="number"?(p===0&&o.value===""||o.value!=p)&&(o.value=""+p):o.value!==""+p&&(o.value=""+p);else if(v==="submit"||v==="reset"){o.removeAttribute("value");return}l.hasOwnProperty("value")?at(o,l.type,p):l.hasOwnProperty("defaultValue")&&at(o,l.type,we(l.defaultValue)),l.checked==null&&l.defaultChecked!=null&&(o.defaultChecked=!!l.defaultChecked)}function be(o,l,p){if(l.hasOwnProperty("value")||l.hasOwnProperty("defaultValue")){var v=l.type;if(!(v!=="submit"&&v!=="reset"||l.value!==void 0&&l.value!==null))return;l=""+o._wrapperState.initialValue,p||l===o.value||(o.value=l),o.defaultValue=l}p=o.name,p!==""&&(o.name=""),o.defaultChecked=!!o._wrapperState.initialChecked,p!==""&&(o.name=p)}function at(o,l,p){(l!=="number"||X(o.ownerDocument)!==o)&&(p==null?o.defaultValue=""+o._wrapperState.initialValue:o.defaultValue!==""+p&&(o.defaultValue=""+p))}var ft=Array.isArray;function mt(o,l,p,v){if(o=o.options,l){l={};for(var R=0;R<p.length;R++)l["$"+p[R]]=!0;for(p=0;p<o.length;p++)R=l.hasOwnProperty("$"+o[p].value),o[p].selected!==R&&(o[p].selected=R),R&&v&&(o[p].defaultSelected=!0)}else{for(p=""+we(p),l=null,R=0;R<o.length;R++){if(o[R].value===p){o[R].selected=!0,v&&(o[R].defaultSelected=!0);return}l!==null||o[R].disabled||(l=o[R])}l!==null&&(l.selected=!0)}}function se(o,l){if(l.dangerouslySetInnerHTML!=null)throw Error(r(91));return E({},l,{value:void 0,defaultValue:void 0,children:""+o._wrapperState.initialValue})}function Ce(o,l){var p=l.value;if(p==null){if(p=l.children,l=l.defaultValue,p!=null){if(l!=null)throw Error(r(92));if(ft(p)){if(1<p.length)throw Error(r(93));p=p[0]}l=p}l==null&&(l=""),p=l}o._wrapperState={initialValue:we(p)}}function _e(o,l){var p=we(l.value),v=we(l.defaultValue);p!=null&&(p=""+p,p!==o.value&&(o.value=p),l.defaultValue==null&&o.defaultValue!==p&&(o.defaultValue=p)),v!=null&&(o.defaultValue=""+v)}function pe(o){var l=o.textContent;l===o._wrapperState.initialValue&&l!==""&&l!==null&&(o.value=l)}function Qe(o){switch(o){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 ct(o,l){return o==null||o==="http://www.w3.org/1999/xhtml"?Qe(l):o==="http://www.w3.org/2000/svg"&&l==="foreignObject"?"http://www.w3.org/1999/xhtml":o}var Bt,Je=(function(o){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(l,p,v,R){MSApp.execUnsafeLocalFunction(function(){return o(l,p,v,R)})}:o})(function(o,l){if(o.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in o)o.innerHTML=l;else{for(Bt=Bt||document.createElement("div"),Bt.innerHTML="<svg>"+l.valueOf().toString()+"</svg>",l=Bt.firstChild;o.firstChild;)o.removeChild(o.firstChild);for(;l.firstChild;)o.appendChild(l.firstChild)}});function Qt(o,l){if(l){var p=o.firstChild;if(p&&p===o.lastChild&&p.nodeType===3){p.nodeValue=l;return}}o.textContent=l}var Ft={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},fe=["Webkit","ms","Moz","O"];Object.keys(Ft).forEach(function(o){fe.forEach(function(l){l=l+o.charAt(0).toUpperCase()+o.substring(1),Ft[l]=Ft[o]})});function rt(o,l,p){return l==null||typeof l=="boolean"||l===""?"":p||typeof l!="number"||l===0||Ft.hasOwnProperty(o)&&Ft[o]?(""+l).trim():l+"px"}function et(o,l){o=o.style;for(var p in l)if(l.hasOwnProperty(p)){var v=p.indexOf("--")===0,R=rt(p,l[p],v);p==="float"&&(p="cssFloat"),v?o.setProperty(p,R):o[p]=R}}var It=E({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 Wt(o,l){if(l){if(It[o]&&(l.children!=null||l.dangerouslySetInnerHTML!=null))throw Error(r(137,o));if(l.dangerouslySetInnerHTML!=null){if(l.children!=null)throw Error(r(60));if(typeof l.dangerouslySetInnerHTML!="object"||!("__html"in l.dangerouslySetInnerHTML))throw Error(r(61))}if(l.style!=null&&typeof l.style!="object")throw Error(r(62))}}function St(o,l){if(o.indexOf("-")===-1)return typeof l.is=="string";switch(o){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 je=null;function Rt(o){return o=o.target||o.srcElement||window,o.correspondingUseElement&&(o=o.correspondingUseElement),o.nodeType===3?o.parentNode:o}var Pt=null,qt=null,Wn=null;function fr(o){if(o=Rc(o)){if(typeof Pt!="function")throw Error(r(280));var l=o.stateNode;l&&(l=Gd(l),Pt(o.stateNode,o.type,l))}}function Na(o){qt?Wn?Wn.push(o):Wn=[o]:qt=o}function uo(){if(qt){var o=qt,l=Wn;if(Wn=qt=null,fr(o),l)for(o=0;o<l.length;o++)fr(l[o])}}function xr(o,l){return o(l)}function hs(){}var ps=!1;function Zs(o,l,p){if(ps)return o(l,p);ps=!0;try{return xr(o,l,p)}finally{ps=!1,(qt!==null||Wn!==null)&&(hs(),uo())}}function As(o,l){var p=o.stateNode;if(p===null)return null;var v=Gd(p);if(v===null)return null;p=v[l];e:switch(l){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(v=!v.disabled)||(o=o.type,v=!(o==="button"||o==="input"||o==="select"||o==="textarea")),o=!v;break e;default:o=!1}if(o)return null;if(p&&typeof p!="function")throw Error(r(231,l,typeof p));return p}var ho=!1;if(d)try{var Yn={};Object.defineProperty(Yn,"passive",{get:function(){ho=!0}}),window.addEventListener("test",Yn,Yn),window.removeEventListener("test",Yn,Yn)}catch{ho=!1}function ai(o,l,p,v,R,_,q,Z,ie){var ve=Array.prototype.slice.call(arguments,3);try{l.apply(p,ve)}catch(Ee){this.onError(Ee)}}var Sa=!1,ms=null,Ca=!1,Ir=null,Ra={onError:function(o){Sa=!0,ms=o}};function Tr(o,l,p,v,R,_,q,Z,ie){Sa=!1,ms=null,ai.apply(Ra,arguments)}function Xr(o,l,p,v,R,_,q,Z,ie){if(Tr.apply(this,arguments),Sa){if(Sa){var ve=ms;Sa=!1,ms=null}else throw Error(r(198));Ca||(Ca=!0,Ir=ve)}}function yn(o){var l=o,p=o;if(o.alternate)for(;l.return;)l=l.return;else{o=l;do l=o,(l.flags&4098)!==0&&(p=l.return),o=l.return;while(o)}return l.tag===3?p:null}function Ms(o){if(o.tag===13){var l=o.memoizedState;if(l===null&&(o=o.alternate,o!==null&&(l=o.memoizedState)),l!==null)return l.dehydrated}return null}function po(o){if(yn(o)!==o)throw Error(r(188))}function Br(o){var l=o.alternate;if(!l){if(l=yn(o),l===null)throw Error(r(188));return l!==o?null:o}for(var p=o,v=l;;){var R=p.return;if(R===null)break;var _=R.alternate;if(_===null){if(v=R.return,v!==null){p=v;continue}break}if(R.child===_.child){for(_=R.child;_;){if(_===p)return po(R),o;if(_===v)return po(R),l;_=_.sibling}throw Error(r(188))}if(p.return!==v.return)p=R,v=_;else{for(var q=!1,Z=R.child;Z;){if(Z===p){q=!0,p=R,v=_;break}if(Z===v){q=!0,v=R,p=_;break}Z=Z.sibling}if(!q){for(Z=_.child;Z;){if(Z===p){q=!0,p=_,v=R;break}if(Z===v){q=!0,v=_,p=R;break}Z=Z.sibling}if(!q)throw Error(r(189))}}if(p.alternate!==v)throw Error(r(190))}if(p.tag!==3)throw Error(r(188));return p.stateNode.current===p?o:l}function Zr(o){return o=Br(o),o!==null?Tn(o):null}function Tn(o){if(o.tag===5||o.tag===6)return o;for(o=o.child;o!==null;){var l=Tn(o);if(l!==null)return l;o=o.sibling}return null}var mo=n.unstable_scheduleCallback,Jr=n.unstable_cancelCallback,Ls=n.unstable_shouldYield,gs=n.unstable_requestPaint,Ot=n.unstable_now,oi=n.unstable_getCurrentPriorityLevel,en=n.unstable_ImmediatePriority,Ia=n.unstable_UserBlockingPriority,$r=n.unstable_NormalPriority,Ta=n.unstable_LowPriority,Js=n.unstable_IdlePriority,_r=null,tn=null;function $a(o){if(tn&&typeof tn.onCommitFiberRoot=="function")try{tn.onCommitFiberRoot(_r,o,void 0,(o.current.flags&128)===128)}catch{}}var Gt=Math.clz32?Math.clz32:Pa,_a=Math.log,ea=Math.LN2;function Pa(o){return o>>>=0,o===0?32:31-(_a(o)/ea|0)|0}var Mn=64,Ea=4194304;function fs(o){switch(o&-o){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 o&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return o&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return o}}function xs(o,l){var p=o.pendingLanes;if(p===0)return 0;var v=0,R=o.suspendedLanes,_=o.pingedLanes,q=p&268435455;if(q!==0){var Z=q&~R;Z!==0?v=fs(Z):(_&=q,_!==0&&(v=fs(_)))}else q=p&~R,q!==0?v=fs(q):_!==0&&(v=fs(_));if(v===0)return 0;if(l!==0&&l!==v&&(l&R)===0&&(R=v&-v,_=l&-l,R>=_||R===16&&(_&4194240)!==0))return l;if((v&4)!==0&&(v|=p&16),l=o.entangledLanes,l!==0)for(o=o.entanglements,l&=v;0<l;)p=31-Gt(l),R=1<<p,v|=o[p],l&=~R;return v}function Gi(o,l){switch(o){case 1:case 2:case 4:return l+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 l+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 go(o,l){for(var p=o.suspendedLanes,v=o.pingedLanes,R=o.expirationTimes,_=o.pendingLanes;0<_;){var q=31-Gt(_),Z=1<<q,ie=R[q];ie===-1?((Z&p)===0||(Z&v)!==0)&&(R[q]=Gi(Z,l)):ie<=l&&(o.expiredLanes|=Z),_&=~Z}}function fo(o){return o=o.pendingLanes&-1073741825,o!==0?o:o&1073741824?1073741824:0}function Aa(){var o=Mn;return Mn<<=1,(Mn&4194240)===0&&(Mn=64),o}function xo(o){for(var l=[],p=0;31>p;p++)l.push(o);return l}function ta(o,l,p){o.pendingLanes|=l,l!==536870912&&(o.suspendedLanes=0,o.pingedLanes=0),o=o.eventTimes,l=31-Gt(l),o[l]=p}function Vi(o,l){var p=o.pendingLanes&~l;o.pendingLanes=l,o.suspendedLanes=0,o.pingedLanes=0,o.expiredLanes&=l,o.mutableReadLanes&=l,o.entangledLanes&=l,l=o.entanglements;var v=o.eventTimes;for(o=o.expirationTimes;0<p;){var R=31-Gt(p),_=1<<R;l[R]=0,v[R]=-1,o[R]=-1,p&=~_}}function Y(o,l){var p=o.entangledLanes|=l;for(o=o.entanglements;p;){var v=31-Gt(p),R=1<<v;R&l|o[v]&l&&(o[v]|=l),p&=~R}}var de=0;function ke(o){return o&=-o,1<o?4<o?(o&268435455)!==0?16:536870912:4:1}var Re,Te,Ie,Xe,Ke,ze=!1,st=[],Le=null,V=null,xe=null,ue=new Map,Se=new Map,Ye=[],Ze="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 Et(o,l){switch(o){case"focusin":case"focusout":Le=null;break;case"dragenter":case"dragleave":V=null;break;case"mouseover":case"mouseout":xe=null;break;case"pointerover":case"pointerout":ue.delete(l.pointerId);break;case"gotpointercapture":case"lostpointercapture":Se.delete(l.pointerId)}}function At(o,l,p,v,R,_){return o===null||o.nativeEvent!==_?(o={blockedOn:l,domEventName:p,eventSystemFlags:v,nativeEvent:_,targetContainers:[R]},l!==null&&(l=Rc(l),l!==null&&Te(l)),o):(o.eventSystemFlags|=v,l=o.targetContainers,R!==null&&l.indexOf(R)===-1&&l.push(R),o)}function rn(o,l,p,v,R){switch(l){case"focusin":return Le=At(Le,o,l,p,v,R),!0;case"dragenter":return V=At(V,o,l,p,v,R),!0;case"mouseover":return xe=At(xe,o,l,p,v,R),!0;case"pointerover":var _=R.pointerId;return ue.set(_,At(ue.get(_)||null,o,l,p,v,R)),!0;case"gotpointercapture":return _=R.pointerId,Se.set(_,At(Se.get(_)||null,o,l,p,v,R)),!0}return!1}function Xn(o){var l=ii(o.target);if(l!==null){var p=yn(l);if(p!==null){if(l=p.tag,l===13){if(l=Ms(p),l!==null){o.blockedOn=l,Ke(o.priority,function(){Ie(p)});return}}else if(l===3&&p.stateNode.current.memoizedState.isDehydrated){o.blockedOn=p.tag===3?p.stateNode.containerInfo:null;return}}}o.blockedOn=null}function $n(o){if(o.blockedOn!==null)return!1;for(var l=o.targetContainers;0<l.length;){var p=ut(o.domEventName,o.eventSystemFlags,l[0],o.nativeEvent);if(p===null){p=o.nativeEvent;var v=new p.constructor(p.type,p);je=v,p.target.dispatchEvent(v),je=null}else return l=Rc(p),l!==null&&Te(l),o.blockedOn=p,!1;l.shift()}return!0}function Fs(o,l,p){$n(o)&&p.delete(l)}function yo(){ze=!1,Le!==null&&$n(Le)&&(Le=null),V!==null&&$n(V)&&(V=null),xe!==null&&$n(xe)&&(xe=null),ue.forEach(Fs),Se.forEach(Fs)}function es(o,l){o.blockedOn===l&&(o.blockedOn=null,ze||(ze=!0,n.unstable_scheduleCallback(n.unstable_NormalPriority,yo)))}function sr(o){function l(R){return es(R,o)}if(0<st.length){es(st[0],o);for(var p=1;p<st.length;p++){var v=st[p];v.blockedOn===o&&(v.blockedOn=null)}}for(Le!==null&&es(Le,o),V!==null&&es(V,o),xe!==null&&es(xe,o),ue.forEach(l),Se.forEach(l),p=0;p<Ye.length;p++)v=Ye[p],v.blockedOn===o&&(v.blockedOn=null);for(;0<Ye.length&&(p=Ye[0],p.blockedOn===null);)Xn(p),p.blockedOn===null&&Ye.shift()}var Ln=S.ReactCurrentBatchConfig,ar=!0;function ts(o,l,p,v){var R=de,_=Ln.transition;Ln.transition=null;try{de=1,na(o,l,p,v)}finally{de=R,Ln.transition=_}}function Ma(o,l,p,v){var R=de,_=Ln.transition;Ln.transition=null;try{de=4,na(o,l,p,v)}finally{de=R,Ln.transition=_}}function na(o,l,p,v){if(ar){var R=ut(o,l,p,v);if(R===null)vm(o,l,v,qe,p),Et(o,v);else if(rn(R,o,l,p,v))v.stopPropagation();else if(Et(o,v),l&4&&-1<Ze.indexOf(o)){for(;R!==null;){var _=Rc(R);if(_!==null&&Re(_),_=ut(o,l,p,v),_===null&&vm(o,l,v,qe,p),_===R)break;R=_}R!==null&&v.stopPropagation()}else vm(o,l,v,null,p)}}var qe=null;function ut(o,l,p,v){if(qe=null,o=Rt(v),o=ii(o),o!==null)if(l=yn(o),l===null)o=null;else if(p=l.tag,p===13){if(o=Ms(l),o!==null)return o;o=null}else if(p===3){if(l.stateNode.current.memoizedState.isDehydrated)return l.tag===3?l.stateNode.containerInfo:null;o=null}else l!==o&&(o=null);return qe=o,null}function or(o){switch(o){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(oi()){case en:return 1;case Ia:return 4;case $r:case Ta:return 16;case Js:return 536870912;default:return 16}default:return 16}}var Fn=null,ra=null,sa=null;function Qi(){if(sa)return sa;var o,l=ra,p=l.length,v,R="value"in Fn?Fn.value:Fn.textContent,_=R.length;for(o=0;o<p&&l[o]===R[o];o++);var q=p-o;for(v=1;v<=q&&l[p-v]===R[_-v];v++);return sa=R.slice(o,1<v?1-v:void 0)}function Yi(o){var l=o.keyCode;return"charCode"in o?(o=o.charCode,o===0&&l===13&&(o=13)):o=l,o===10&&(o=13),32<=o||o===13?o:0}function Xi(){return!0}function qn(){return!1}function Pr(o){function l(p,v,R,_,q){this._reactName=p,this._targetInst=R,this.type=v,this.nativeEvent=_,this.target=q,this.currentTarget=null;for(var Z in o)o.hasOwnProperty(Z)&&(p=o[Z],this[Z]=p?p(_):_[Z]);return this.isDefaultPrevented=(_.defaultPrevented!=null?_.defaultPrevented:_.returnValue===!1)?Xi:qn,this.isPropagationStopped=qn,this}return E(l.prototype,{preventDefault:function(){this.defaultPrevented=!0;var p=this.nativeEvent;p&&(p.preventDefault?p.preventDefault():typeof p.returnValue!="unknown"&&(p.returnValue=!1),this.isDefaultPrevented=Xi)},stopPropagation:function(){var p=this.nativeEvent;p&&(p.stopPropagation?p.stopPropagation():typeof p.cancelBubble!="unknown"&&(p.cancelBubble=!0),this.isPropagationStopped=Xi)},persist:function(){},isPersistent:Xi}),l}var ys={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(o){return o.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Zi=Pr(ys),fc=E({},ys,{view:0,detail:0}),NI=Pr(fc),om,im,xc,Dd=E({},fc,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:cm,button:0,buttons:0,relatedTarget:function(o){return o.relatedTarget===void 0?o.fromElement===o.srcElement?o.toElement:o.fromElement:o.relatedTarget},movementX:function(o){return"movementX"in o?o.movementX:(o!==xc&&(xc&&o.type==="mousemove"?(om=o.screenX-xc.screenX,im=o.screenY-xc.screenY):im=om=0,xc=o),om)},movementY:function(o){return"movementY"in o?o.movementY:im}}),By=Pr(Dd),SI=E({},Dd,{dataTransfer:0}),CI=Pr(SI),RI=E({},fc,{relatedTarget:0}),lm=Pr(RI),II=E({},ys,{animationName:0,elapsedTime:0,pseudoElement:0}),TI=Pr(II),$I=E({},ys,{clipboardData:function(o){return"clipboardData"in o?o.clipboardData:window.clipboardData}}),_I=Pr($I),PI=E({},ys,{data:0}),Wy=Pr(PI),EI={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},AI={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"},MI={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function LI(o){var l=this.nativeEvent;return l.getModifierState?l.getModifierState(o):(o=MI[o])?!!l[o]:!1}function cm(){return LI}var FI=E({},fc,{key:function(o){if(o.key){var l=EI[o.key]||o.key;if(l!=="Unidentified")return l}return o.type==="keypress"?(o=Yi(o),o===13?"Enter":String.fromCharCode(o)):o.type==="keydown"||o.type==="keyup"?AI[o.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:cm,charCode:function(o){return o.type==="keypress"?Yi(o):0},keyCode:function(o){return o.type==="keydown"||o.type==="keyup"?o.keyCode:0},which:function(o){return o.type==="keypress"?Yi(o):o.type==="keydown"||o.type==="keyup"?o.keyCode:0}}),OI=Pr(FI),DI=E({},Dd,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),qy=Pr(DI),BI=E({},fc,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:cm}),WI=Pr(BI),qI=E({},ys,{propertyName:0,elapsedTime:0,pseudoElement:0}),UI=Pr(qI),HI=E({},Dd,{deltaX:function(o){return"deltaX"in o?o.deltaX:"wheelDeltaX"in o?-o.wheelDeltaX:0},deltaY:function(o){return"deltaY"in o?o.deltaY:"wheelDeltaY"in o?-o.wheelDeltaY:"wheelDelta"in o?-o.wheelDelta:0},deltaZ:0,deltaMode:0}),zI=Pr(HI),KI=[9,13,27,32],dm=d&&"CompositionEvent"in window,yc=null;d&&"documentMode"in document&&(yc=document.documentMode);var GI=d&&"TextEvent"in window&&!yc,Uy=d&&(!dm||yc&&8<yc&&11>=yc),Hy=" ",zy=!1;function Ky(o,l){switch(o){case"keyup":return KI.indexOf(l.keyCode)!==-1;case"keydown":return l.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Gy(o){return o=o.detail,typeof o=="object"&&"data"in o?o.data:null}var Ji=!1;function VI(o,l){switch(o){case"compositionend":return Gy(l);case"keypress":return l.which!==32?null:(zy=!0,Hy);case"textInput":return o=l.data,o===Hy&&zy?null:o;default:return null}}function QI(o,l){if(Ji)return o==="compositionend"||!dm&&Ky(o,l)?(o=Qi(),sa=ra=Fn=null,Ji=!1,o):null;switch(o){case"paste":return null;case"keypress":if(!(l.ctrlKey||l.altKey||l.metaKey)||l.ctrlKey&&l.altKey){if(l.char&&1<l.char.length)return l.char;if(l.which)return String.fromCharCode(l.which)}return null;case"compositionend":return Uy&&l.locale!=="ko"?null:l.data;default:return null}}var YI={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 Vy(o){var l=o&&o.nodeName&&o.nodeName.toLowerCase();return l==="input"?!!YI[o.type]:l==="textarea"}function Qy(o,l,p,v){Na(v),l=Hd(l,"onChange"),0<l.length&&(p=new Zi("onChange","change",null,p,v),o.push({event:p,listeners:l}))}var bc=null,vc=null;function XI(o){pb(o,0)}function Bd(o){var l=sl(o);if(re(l))return o}function ZI(o,l){if(o==="change")return l}var Yy=!1;if(d){var um;if(d){var hm="oninput"in document;if(!hm){var Xy=document.createElement("div");Xy.setAttribute("oninput","return;"),hm=typeof Xy.oninput=="function"}um=hm}else um=!1;Yy=um&&(!document.documentMode||9<document.documentMode)}function Zy(){bc&&(bc.detachEvent("onpropertychange",Jy),vc=bc=null)}function Jy(o){if(o.propertyName==="value"&&Bd(vc)){var l=[];Qy(l,vc,o,Rt(o)),Zs(XI,l)}}function JI(o,l,p){o==="focusin"?(Zy(),bc=l,vc=p,bc.attachEvent("onpropertychange",Jy)):o==="focusout"&&Zy()}function eT(o){if(o==="selectionchange"||o==="keyup"||o==="keydown")return Bd(vc)}function tT(o,l){if(o==="click")return Bd(l)}function nT(o,l){if(o==="input"||o==="change")return Bd(l)}function rT(o,l){return o===l&&(o!==0||1/o===1/l)||o!==o&&l!==l}var Os=typeof Object.is=="function"?Object.is:rT;function kc(o,l){if(Os(o,l))return!0;if(typeof o!="object"||o===null||typeof l!="object"||l===null)return!1;var p=Object.keys(o),v=Object.keys(l);if(p.length!==v.length)return!1;for(v=0;v<p.length;v++){var R=p[v];if(!u.call(l,R)||!Os(o[R],l[R]))return!1}return!0}function eb(o){for(;o&&o.firstChild;)o=o.firstChild;return o}function tb(o,l){var p=eb(o);o=0;for(var v;p;){if(p.nodeType===3){if(v=o+p.textContent.length,o<=l&&v>=l)return{node:p,offset:l-o};o=v}e:{for(;p;){if(p.nextSibling){p=p.nextSibling;break e}p=p.parentNode}p=void 0}p=eb(p)}}function nb(o,l){return o&&l?o===l?!0:o&&o.nodeType===3?!1:l&&l.nodeType===3?nb(o,l.parentNode):"contains"in o?o.contains(l):o.compareDocumentPosition?!!(o.compareDocumentPosition(l)&16):!1:!1}function rb(){for(var o=window,l=X();l instanceof o.HTMLIFrameElement;){try{var p=typeof l.contentWindow.location.href=="string"}catch{p=!1}if(p)o=l.contentWindow;else break;l=X(o.document)}return l}function pm(o){var l=o&&o.nodeName&&o.nodeName.toLowerCase();return l&&(l==="input"&&(o.type==="text"||o.type==="search"||o.type==="tel"||o.type==="url"||o.type==="password")||l==="textarea"||o.contentEditable==="true")}function sT(o){var l=rb(),p=o.focusedElem,v=o.selectionRange;if(l!==p&&p&&p.ownerDocument&&nb(p.ownerDocument.documentElement,p)){if(v!==null&&pm(p)){if(l=v.start,o=v.end,o===void 0&&(o=l),"selectionStart"in p)p.selectionStart=l,p.selectionEnd=Math.min(o,p.value.length);else if(o=(l=p.ownerDocument||document)&&l.defaultView||window,o.getSelection){o=o.getSelection();var R=p.textContent.length,_=Math.min(v.start,R);v=v.end===void 0?_:Math.min(v.end,R),!o.extend&&_>v&&(R=v,v=_,_=R),R=tb(p,_);var q=tb(p,v);R&&q&&(o.rangeCount!==1||o.anchorNode!==R.node||o.anchorOffset!==R.offset||o.focusNode!==q.node||o.focusOffset!==q.offset)&&(l=l.createRange(),l.setStart(R.node,R.offset),o.removeAllRanges(),_>v?(o.addRange(l),o.extend(q.node,q.offset)):(l.setEnd(q.node,q.offset),o.addRange(l)))}}for(l=[],o=p;o=o.parentNode;)o.nodeType===1&&l.push({element:o,left:o.scrollLeft,top:o.scrollTop});for(typeof p.focus=="function"&&p.focus(),p=0;p<l.length;p++)o=l[p],o.element.scrollLeft=o.left,o.element.scrollTop=o.top}}var aT=d&&"documentMode"in document&&11>=document.documentMode,el=null,mm=null,wc=null,gm=!1;function sb(o,l,p){var v=p.window===p?p.document:p.nodeType===9?p:p.ownerDocument;gm||el==null||el!==X(v)||(v=el,"selectionStart"in v&&pm(v)?v={start:v.selectionStart,end:v.selectionEnd}:(v=(v.ownerDocument&&v.ownerDocument.defaultView||window).getSelection(),v={anchorNode:v.anchorNode,anchorOffset:v.anchorOffset,focusNode:v.focusNode,focusOffset:v.focusOffset}),wc&&kc(wc,v)||(wc=v,v=Hd(mm,"onSelect"),0<v.length&&(l=new Zi("onSelect","select",null,l,p),o.push({event:l,listeners:v}),l.target=el)))}function Wd(o,l){var p={};return p[o.toLowerCase()]=l.toLowerCase(),p["Webkit"+o]="webkit"+l,p["Moz"+o]="moz"+l,p}var tl={animationend:Wd("Animation","AnimationEnd"),animationiteration:Wd("Animation","AnimationIteration"),animationstart:Wd("Animation","AnimationStart"),transitionend:Wd("Transition","TransitionEnd")},fm={},ab={};d&&(ab=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 qd(o){if(fm[o])return fm[o];if(!tl[o])return o;var l=tl[o],p;for(p in l)if(l.hasOwnProperty(p)&&p in ab)return fm[o]=l[p];return o}var ob=qd("animationend"),ib=qd("animationiteration"),lb=qd("animationstart"),cb=qd("transitionend"),db=new Map,ub="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 bo(o,l){db.set(o,l),i(l,[o])}for(var xm=0;xm<ub.length;xm++){var ym=ub[xm],oT=ym.toLowerCase(),iT=ym[0].toUpperCase()+ym.slice(1);bo(oT,"on"+iT)}bo(ob,"onAnimationEnd"),bo(ib,"onAnimationIteration"),bo(lb,"onAnimationStart"),bo("dblclick","onDoubleClick"),bo("focusin","onFocus"),bo("focusout","onBlur"),bo(cb,"onTransitionEnd"),c("onMouseEnter",["mouseout","mouseover"]),c("onMouseLeave",["mouseout","mouseover"]),c("onPointerEnter",["pointerout","pointerover"]),c("onPointerLeave",["pointerout","pointerover"]),i("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),i("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),i("onBeforeInput",["compositionend","keypress","textInput","paste"]),i("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),i("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),i("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(" "),lT=new Set("cancel close invalid load scroll toggle".split(" ").concat(jc));function hb(o,l,p){var v=o.type||"unknown-event";o.currentTarget=p,Xr(v,l,void 0,o),o.currentTarget=null}function pb(o,l){l=(l&4)!==0;for(var p=0;p<o.length;p++){var v=o[p],R=v.event;v=v.listeners;e:{var _=void 0;if(l)for(var q=v.length-1;0<=q;q--){var Z=v[q],ie=Z.instance,ve=Z.currentTarget;if(Z=Z.listener,ie!==_&&R.isPropagationStopped())break e;hb(R,Z,ve),_=ie}else for(q=0;q<v.length;q++){if(Z=v[q],ie=Z.instance,ve=Z.currentTarget,Z=Z.listener,ie!==_&&R.isPropagationStopped())break e;hb(R,Z,ve),_=ie}}}if(Ca)throw o=Ir,Ca=!1,Ir=null,o}function sn(o,l){var p=l[Cm];p===void 0&&(p=l[Cm]=new Set);var v=o+"__bubble";p.has(v)||(mb(l,o,2,!1),p.add(v))}function bm(o,l,p){var v=0;l&&(v|=4),mb(p,o,v,l)}var Ud="_reactListening"+Math.random().toString(36).slice(2);function Nc(o){if(!o[Ud]){o[Ud]=!0,s.forEach(function(p){p!=="selectionchange"&&(lT.has(p)||bm(p,!1,o),bm(p,!0,o))});var l=o.nodeType===9?o:o.ownerDocument;l===null||l[Ud]||(l[Ud]=!0,bm("selectionchange",!1,l))}}function mb(o,l,p,v){switch(or(l)){case 1:var R=ts;break;case 4:R=Ma;break;default:R=na}p=R.bind(null,l,p,o),R=void 0,!ho||l!=="touchstart"&&l!=="touchmove"&&l!=="wheel"||(R=!0),v?R!==void 0?o.addEventListener(l,p,{capture:!0,passive:R}):o.addEventListener(l,p,!0):R!==void 0?o.addEventListener(l,p,{passive:R}):o.addEventListener(l,p,!1)}function vm(o,l,p,v,R){var _=v;if((l&1)===0&&(l&2)===0&&v!==null)e:for(;;){if(v===null)return;var q=v.tag;if(q===3||q===4){var Z=v.stateNode.containerInfo;if(Z===R||Z.nodeType===8&&Z.parentNode===R)break;if(q===4)for(q=v.return;q!==null;){var ie=q.tag;if((ie===3||ie===4)&&(ie=q.stateNode.containerInfo,ie===R||ie.nodeType===8&&ie.parentNode===R))return;q=q.return}for(;Z!==null;){if(q=ii(Z),q===null)return;if(ie=q.tag,ie===5||ie===6){v=_=q;continue e}Z=Z.parentNode}}v=v.return}Zs(function(){var ve=_,Ee=Rt(p),Ae=[];e:{var Pe=db.get(o);if(Pe!==void 0){var nt=Zi,it=o;switch(o){case"keypress":if(Yi(p)===0)break e;case"keydown":case"keyup":nt=OI;break;case"focusin":it="focus",nt=lm;break;case"focusout":it="blur",nt=lm;break;case"beforeblur":case"afterblur":nt=lm;break;case"click":if(p.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":nt=By;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":nt=CI;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":nt=WI;break;case ob:case ib:case lb:nt=TI;break;case cb:nt=UI;break;case"scroll":nt=NI;break;case"wheel":nt=zI;break;case"copy":case"cut":case"paste":nt=_I;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":nt=qy}var ht=(l&4)!==0,_n=!ht&&o==="scroll",ge=ht?Pe!==null?Pe+"Capture":null:Pe;ht=[];for(var ce=ve,ye;ce!==null;){ye=ce;var Be=ye.stateNode;if(ye.tag===5&&Be!==null&&(ye=Be,ge!==null&&(Be=As(ce,ge),Be!=null&&ht.push(Sc(ce,Be,ye)))),_n)break;ce=ce.return}0<ht.length&&(Pe=new nt(Pe,it,null,p,Ee),Ae.push({event:Pe,listeners:ht}))}}if((l&7)===0){e:{if(Pe=o==="mouseover"||o==="pointerover",nt=o==="mouseout"||o==="pointerout",Pe&&p!==je&&(it=p.relatedTarget||p.fromElement)&&(ii(it)||it[La]))break e;if((nt||Pe)&&(Pe=Ee.window===Ee?Ee:(Pe=Ee.ownerDocument)?Pe.defaultView||Pe.parentWindow:window,nt?(it=p.relatedTarget||p.toElement,nt=ve,it=it?ii(it):null,it!==null&&(_n=yn(it),it!==_n||it.tag!==5&&it.tag!==6)&&(it=null)):(nt=null,it=ve),nt!==it)){if(ht=By,Be="onMouseLeave",ge="onMouseEnter",ce="mouse",(o==="pointerout"||o==="pointerover")&&(ht=qy,Be="onPointerLeave",ge="onPointerEnter",ce="pointer"),_n=nt==null?Pe:sl(nt),ye=it==null?Pe:sl(it),Pe=new ht(Be,ce+"leave",nt,p,Ee),Pe.target=_n,Pe.relatedTarget=ye,Be=null,ii(Ee)===ve&&(ht=new ht(ge,ce+"enter",it,p,Ee),ht.target=ye,ht.relatedTarget=_n,Be=ht),_n=Be,nt&&it)t:{for(ht=nt,ge=it,ce=0,ye=ht;ye;ye=nl(ye))ce++;for(ye=0,Be=ge;Be;Be=nl(Be))ye++;for(;0<ce-ye;)ht=nl(ht),ce--;for(;0<ye-ce;)ge=nl(ge),ye--;for(;ce--;){if(ht===ge||ge!==null&&ht===ge.alternate)break t;ht=nl(ht),ge=nl(ge)}ht=null}else ht=null;nt!==null&&gb(Ae,Pe,nt,ht,!1),it!==null&&_n!==null&&gb(Ae,_n,it,ht,!0)}}e:{if(Pe=ve?sl(ve):window,nt=Pe.nodeName&&Pe.nodeName.toLowerCase(),nt==="select"||nt==="input"&&Pe.type==="file")var gt=ZI;else if(Vy(Pe))if(Yy)gt=nT;else{gt=eT;var yt=JI}else(nt=Pe.nodeName)&&nt.toLowerCase()==="input"&&(Pe.type==="checkbox"||Pe.type==="radio")&&(gt=tT);if(gt&&(gt=gt(o,ve))){Qy(Ae,gt,p,Ee);break e}yt&&yt(o,Pe,ve),o==="focusout"&&(yt=Pe._wrapperState)&&yt.controlled&&Pe.type==="number"&&at(Pe,"number",Pe.value)}switch(yt=ve?sl(ve):window,o){case"focusin":(Vy(yt)||yt.contentEditable==="true")&&(el=yt,mm=ve,wc=null);break;case"focusout":wc=mm=el=null;break;case"mousedown":gm=!0;break;case"contextmenu":case"mouseup":case"dragend":gm=!1,sb(Ae,p,Ee);break;case"selectionchange":if(aT)break;case"keydown":case"keyup":sb(Ae,p,Ee)}var bt;if(dm)e:{switch(o){case"compositionstart":var wt="onCompositionStart";break e;case"compositionend":wt="onCompositionEnd";break e;case"compositionupdate":wt="onCompositionUpdate";break e}wt=void 0}else Ji?Ky(o,p)&&(wt="onCompositionEnd"):o==="keydown"&&p.keyCode===229&&(wt="onCompositionStart");wt&&(Uy&&p.locale!=="ko"&&(Ji||wt!=="onCompositionStart"?wt==="onCompositionEnd"&&Ji&&(bt=Qi()):(Fn=Ee,ra="value"in Fn?Fn.value:Fn.textContent,Ji=!0)),yt=Hd(ve,wt),0<yt.length&&(wt=new Wy(wt,o,null,p,Ee),Ae.push({event:wt,listeners:yt}),bt?wt.data=bt:(bt=Gy(p),bt!==null&&(wt.data=bt)))),(bt=GI?VI(o,p):QI(o,p))&&(ve=Hd(ve,"onBeforeInput"),0<ve.length&&(Ee=new Wy("onBeforeInput","beforeinput",null,p,Ee),Ae.push({event:Ee,listeners:ve}),Ee.data=bt))}pb(Ae,l)})}function Sc(o,l,p){return{instance:o,listener:l,currentTarget:p}}function Hd(o,l){for(var p=l+"Capture",v=[];o!==null;){var R=o,_=R.stateNode;R.tag===5&&_!==null&&(R=_,_=As(o,p),_!=null&&v.unshift(Sc(o,_,R)),_=As(o,l),_!=null&&v.push(Sc(o,_,R))),o=o.return}return v}function nl(o){if(o===null)return null;do o=o.return;while(o&&o.tag!==5);return o||null}function gb(o,l,p,v,R){for(var _=l._reactName,q=[];p!==null&&p!==v;){var Z=p,ie=Z.alternate,ve=Z.stateNode;if(ie!==null&&ie===v)break;Z.tag===5&&ve!==null&&(Z=ve,R?(ie=As(p,_),ie!=null&&q.unshift(Sc(p,ie,Z))):R||(ie=As(p,_),ie!=null&&q.push(Sc(p,ie,Z)))),p=p.return}q.length!==0&&o.push({event:l,listeners:q})}var cT=/\r\n?/g,dT=/\u0000|\uFFFD/g;function fb(o){return(typeof o=="string"?o:""+o).replace(cT,`
23
+ `).replace(dT,"")}function zd(o,l,p){if(l=fb(l),fb(o)!==l&&p)throw Error(r(425))}function Kd(){}var km=null,wm=null;function jm(o,l){return o==="textarea"||o==="noscript"||typeof l.children=="string"||typeof l.children=="number"||typeof l.dangerouslySetInnerHTML=="object"&&l.dangerouslySetInnerHTML!==null&&l.dangerouslySetInnerHTML.__html!=null}var Nm=typeof setTimeout=="function"?setTimeout:void 0,uT=typeof clearTimeout=="function"?clearTimeout:void 0,xb=typeof Promise=="function"?Promise:void 0,hT=typeof queueMicrotask=="function"?queueMicrotask:typeof xb<"u"?function(o){return xb.resolve(null).then(o).catch(pT)}:Nm;function pT(o){setTimeout(function(){throw o})}function Sm(o,l){var p=l,v=0;do{var R=p.nextSibling;if(o.removeChild(p),R&&R.nodeType===8)if(p=R.data,p==="/$"){if(v===0){o.removeChild(R),sr(l);return}v--}else p!=="$"&&p!=="$?"&&p!=="$!"||v++;p=R}while(p);sr(l)}function vo(o){for(;o!=null;o=o.nextSibling){var l=o.nodeType;if(l===1||l===3)break;if(l===8){if(l=o.data,l==="$"||l==="$!"||l==="$?")break;if(l==="/$")return null}}return o}function yb(o){o=o.previousSibling;for(var l=0;o;){if(o.nodeType===8){var p=o.data;if(p==="$"||p==="$!"||p==="$?"){if(l===0)return o;l--}else p==="/$"&&l++}o=o.previousSibling}return null}var rl=Math.random().toString(36).slice(2),aa="__reactFiber$"+rl,Cc="__reactProps$"+rl,La="__reactContainer$"+rl,Cm="__reactEvents$"+rl,mT="__reactListeners$"+rl,gT="__reactHandles$"+rl;function ii(o){var l=o[aa];if(l)return l;for(var p=o.parentNode;p;){if(l=p[La]||p[aa]){if(p=l.alternate,l.child!==null||p!==null&&p.child!==null)for(o=yb(o);o!==null;){if(p=o[aa])return p;o=yb(o)}return l}o=p,p=o.parentNode}return null}function Rc(o){return o=o[aa]||o[La],!o||o.tag!==5&&o.tag!==6&&o.tag!==13&&o.tag!==3?null:o}function sl(o){if(o.tag===5||o.tag===6)return o.stateNode;throw Error(r(33))}function Gd(o){return o[Cc]||null}var Rm=[],al=-1;function ko(o){return{current:o}}function an(o){0>al||(o.current=Rm[al],Rm[al]=null,al--)}function nn(o,l){al++,Rm[al]=o.current,o.current=l}var wo={},yr=ko(wo),Wr=ko(!1),li=wo;function ol(o,l){var p=o.type.contextTypes;if(!p)return wo;var v=o.stateNode;if(v&&v.__reactInternalMemoizedUnmaskedChildContext===l)return v.__reactInternalMemoizedMaskedChildContext;var R={},_;for(_ in p)R[_]=l[_];return v&&(o=o.stateNode,o.__reactInternalMemoizedUnmaskedChildContext=l,o.__reactInternalMemoizedMaskedChildContext=R),R}function qr(o){return o=o.childContextTypes,o!=null}function Vd(){an(Wr),an(yr)}function bb(o,l,p){if(yr.current!==wo)throw Error(r(168));nn(yr,l),nn(Wr,p)}function vb(o,l,p){var v=o.stateNode;if(l=l.childContextTypes,typeof v.getChildContext!="function")return p;v=v.getChildContext();for(var R in v)if(!(R in l))throw Error(r(108,ae(o)||"Unknown",R));return E({},p,v)}function Qd(o){return o=(o=o.stateNode)&&o.__reactInternalMemoizedMergedChildContext||wo,li=yr.current,nn(yr,o),nn(Wr,Wr.current),!0}function kb(o,l,p){var v=o.stateNode;if(!v)throw Error(r(169));p?(o=vb(o,l,li),v.__reactInternalMemoizedMergedChildContext=o,an(Wr),an(yr),nn(yr,o)):an(Wr),nn(Wr,p)}var Fa=null,Yd=!1,Im=!1;function wb(o){Fa===null?Fa=[o]:Fa.push(o)}function fT(o){Yd=!0,wb(o)}function jo(){if(!Im&&Fa!==null){Im=!0;var o=0,l=de;try{var p=Fa;for(de=1;o<p.length;o++){var v=p[o];do v=v(!0);while(v!==null)}Fa=null,Yd=!1}catch(R){throw Fa!==null&&(Fa=Fa.slice(o+1)),mo(en,jo),R}finally{de=l,Im=!1}}return null}var il=[],ll=0,Xd=null,Zd=0,bs=[],vs=0,ci=null,Oa=1,Da="";function di(o,l){il[ll++]=Zd,il[ll++]=Xd,Xd=o,Zd=l}function jb(o,l,p){bs[vs++]=Oa,bs[vs++]=Da,bs[vs++]=ci,ci=o;var v=Oa;o=Da;var R=32-Gt(v)-1;v&=~(1<<R),p+=1;var _=32-Gt(l)+R;if(30<_){var q=R-R%5;_=(v&(1<<q)-1).toString(32),v>>=q,R-=q,Oa=1<<32-Gt(l)+R|p<<R|v,Da=_+o}else Oa=1<<_|p<<R|v,Da=o}function Tm(o){o.return!==null&&(di(o,1),jb(o,1,0))}function $m(o){for(;o===Xd;)Xd=il[--ll],il[ll]=null,Zd=il[--ll],il[ll]=null;for(;o===ci;)ci=bs[--vs],bs[vs]=null,Da=bs[--vs],bs[vs]=null,Oa=bs[--vs],bs[vs]=null}var ns=null,rs=null,un=!1,Ds=null;function Nb(o,l){var p=Ns(5,null,null,0);p.elementType="DELETED",p.stateNode=l,p.return=o,l=o.deletions,l===null?(o.deletions=[p],o.flags|=16):l.push(p)}function Sb(o,l){switch(o.tag){case 5:var p=o.type;return l=l.nodeType!==1||p.toLowerCase()!==l.nodeName.toLowerCase()?null:l,l!==null?(o.stateNode=l,ns=o,rs=vo(l.firstChild),!0):!1;case 6:return l=o.pendingProps===""||l.nodeType!==3?null:l,l!==null?(o.stateNode=l,ns=o,rs=null,!0):!1;case 13:return l=l.nodeType!==8?null:l,l!==null?(p=ci!==null?{id:Oa,overflow:Da}:null,o.memoizedState={dehydrated:l,treeContext:p,retryLane:1073741824},p=Ns(18,null,null,0),p.stateNode=l,p.return=o,o.child=p,ns=o,rs=null,!0):!1;default:return!1}}function _m(o){return(o.mode&1)!==0&&(o.flags&128)===0}function Pm(o){if(un){var l=rs;if(l){var p=l;if(!Sb(o,l)){if(_m(o))throw Error(r(418));l=vo(p.nextSibling);var v=ns;l&&Sb(o,l)?Nb(v,p):(o.flags=o.flags&-4097|2,un=!1,ns=o)}}else{if(_m(o))throw Error(r(418));o.flags=o.flags&-4097|2,un=!1,ns=o}}}function Cb(o){for(o=o.return;o!==null&&o.tag!==5&&o.tag!==3&&o.tag!==13;)o=o.return;ns=o}function Jd(o){if(o!==ns)return!1;if(!un)return Cb(o),un=!0,!1;var l;if((l=o.tag!==3)&&!(l=o.tag!==5)&&(l=o.type,l=l!=="head"&&l!=="body"&&!jm(o.type,o.memoizedProps)),l&&(l=rs)){if(_m(o))throw Rb(),Error(r(418));for(;l;)Nb(o,l),l=vo(l.nextSibling)}if(Cb(o),o.tag===13){if(o=o.memoizedState,o=o!==null?o.dehydrated:null,!o)throw Error(r(317));e:{for(o=o.nextSibling,l=0;o;){if(o.nodeType===8){var p=o.data;if(p==="/$"){if(l===0){rs=vo(o.nextSibling);break e}l--}else p!=="$"&&p!=="$!"&&p!=="$?"||l++}o=o.nextSibling}rs=null}}else rs=ns?vo(o.stateNode.nextSibling):null;return!0}function Rb(){for(var o=rs;o;)o=vo(o.nextSibling)}function cl(){rs=ns=null,un=!1}function Em(o){Ds===null?Ds=[o]:Ds.push(o)}var xT=S.ReactCurrentBatchConfig;function Ic(o,l,p){if(o=p.ref,o!==null&&typeof o!="function"&&typeof o!="object"){if(p._owner){if(p=p._owner,p){if(p.tag!==1)throw Error(r(309));var v=p.stateNode}if(!v)throw Error(r(147,o));var R=v,_=""+o;return l!==null&&l.ref!==null&&typeof l.ref=="function"&&l.ref._stringRef===_?l.ref:(l=function(q){var Z=R.refs;q===null?delete Z[_]:Z[_]=q},l._stringRef=_,l)}if(typeof o!="string")throw Error(r(284));if(!p._owner)throw Error(r(290,o))}return o}function eu(o,l){throw o=Object.prototype.toString.call(l),Error(r(31,o==="[object Object]"?"object with keys {"+Object.keys(l).join(", ")+"}":o))}function Ib(o){var l=o._init;return l(o._payload)}function Tb(o){function l(ge,ce){if(o){var ye=ge.deletions;ye===null?(ge.deletions=[ce],ge.flags|=16):ye.push(ce)}}function p(ge,ce){if(!o)return null;for(;ce!==null;)l(ge,ce),ce=ce.sibling;return null}function v(ge,ce){for(ge=new Map;ce!==null;)ce.key!==null?ge.set(ce.key,ce):ge.set(ce.index,ce),ce=ce.sibling;return ge}function R(ge,ce){return ge=_o(ge,ce),ge.index=0,ge.sibling=null,ge}function _(ge,ce,ye){return ge.index=ye,o?(ye=ge.alternate,ye!==null?(ye=ye.index,ye<ce?(ge.flags|=2,ce):ye):(ge.flags|=2,ce)):(ge.flags|=1048576,ce)}function q(ge){return o&&ge.alternate===null&&(ge.flags|=2),ge}function Z(ge,ce,ye,Be){return ce===null||ce.tag!==6?(ce=Ng(ye,ge.mode,Be),ce.return=ge,ce):(ce=R(ce,ye),ce.return=ge,ce)}function ie(ge,ce,ye,Be){var gt=ye.type;return gt===P?Ee(ge,ce,ye.props.children,Be,ye.key):ce!==null&&(ce.elementType===gt||typeof gt=="object"&&gt!==null&&gt.$$typeof===te&&Ib(gt)===ce.type)?(Be=R(ce,ye.props),Be.ref=Ic(ge,ce,ye),Be.return=ge,Be):(Be=Nu(ye.type,ye.key,ye.props,null,ge.mode,Be),Be.ref=Ic(ge,ce,ye),Be.return=ge,Be)}function ve(ge,ce,ye,Be){return ce===null||ce.tag!==4||ce.stateNode.containerInfo!==ye.containerInfo||ce.stateNode.implementation!==ye.implementation?(ce=Sg(ye,ge.mode,Be),ce.return=ge,ce):(ce=R(ce,ye.children||[]),ce.return=ge,ce)}function Ee(ge,ce,ye,Be,gt){return ce===null||ce.tag!==7?(ce=yi(ye,ge.mode,Be,gt),ce.return=ge,ce):(ce=R(ce,ye),ce.return=ge,ce)}function Ae(ge,ce,ye){if(typeof ce=="string"&&ce!==""||typeof ce=="number")return ce=Ng(""+ce,ge.mode,ye),ce.return=ge,ce;if(typeof ce=="object"&&ce!==null){switch(ce.$$typeof){case T:return ye=Nu(ce.type,ce.key,ce.props,null,ge.mode,ye),ye.ref=Ic(ge,null,ce),ye.return=ge,ye;case $:return ce=Sg(ce,ge.mode,ye),ce.return=ge,ce;case te:var Be=ce._init;return Ae(ge,Be(ce._payload),ye)}if(ft(ce)||O(ce))return ce=yi(ce,ge.mode,ye,null),ce.return=ge,ce;eu(ge,ce)}return null}function Pe(ge,ce,ye,Be){var gt=ce!==null?ce.key:null;if(typeof ye=="string"&&ye!==""||typeof ye=="number")return gt!==null?null:Z(ge,ce,""+ye,Be);if(typeof ye=="object"&&ye!==null){switch(ye.$$typeof){case T:return ye.key===gt?ie(ge,ce,ye,Be):null;case $:return ye.key===gt?ve(ge,ce,ye,Be):null;case te:return gt=ye._init,Pe(ge,ce,gt(ye._payload),Be)}if(ft(ye)||O(ye))return gt!==null?null:Ee(ge,ce,ye,Be,null);eu(ge,ye)}return null}function nt(ge,ce,ye,Be,gt){if(typeof Be=="string"&&Be!==""||typeof Be=="number")return ge=ge.get(ye)||null,Z(ce,ge,""+Be,gt);if(typeof Be=="object"&&Be!==null){switch(Be.$$typeof){case T:return ge=ge.get(Be.key===null?ye:Be.key)||null,ie(ce,ge,Be,gt);case $:return ge=ge.get(Be.key===null?ye:Be.key)||null,ve(ce,ge,Be,gt);case te:var yt=Be._init;return nt(ge,ce,ye,yt(Be._payload),gt)}if(ft(Be)||O(Be))return ge=ge.get(ye)||null,Ee(ce,ge,Be,gt,null);eu(ce,Be)}return null}function it(ge,ce,ye,Be){for(var gt=null,yt=null,bt=ce,wt=ce=0,er=null;bt!==null&&wt<ye.length;wt++){bt.index>wt?(er=bt,bt=null):er=bt.sibling;var Kt=Pe(ge,bt,ye[wt],Be);if(Kt===null){bt===null&&(bt=er);break}o&&bt&&Kt.alternate===null&&l(ge,bt),ce=_(Kt,ce,wt),yt===null?gt=Kt:yt.sibling=Kt,yt=Kt,bt=er}if(wt===ye.length)return p(ge,bt),un&&di(ge,wt),gt;if(bt===null){for(;wt<ye.length;wt++)bt=Ae(ge,ye[wt],Be),bt!==null&&(ce=_(bt,ce,wt),yt===null?gt=bt:yt.sibling=bt,yt=bt);return un&&di(ge,wt),gt}for(bt=v(ge,bt);wt<ye.length;wt++)er=nt(bt,ge,wt,ye[wt],Be),er!==null&&(o&&er.alternate!==null&&bt.delete(er.key===null?wt:er.key),ce=_(er,ce,wt),yt===null?gt=er:yt.sibling=er,yt=er);return o&&bt.forEach(function(Po){return l(ge,Po)}),un&&di(ge,wt),gt}function ht(ge,ce,ye,Be){var gt=O(ye);if(typeof gt!="function")throw Error(r(150));if(ye=gt.call(ye),ye==null)throw Error(r(151));for(var yt=gt=null,bt=ce,wt=ce=0,er=null,Kt=ye.next();bt!==null&&!Kt.done;wt++,Kt=ye.next()){bt.index>wt?(er=bt,bt=null):er=bt.sibling;var Po=Pe(ge,bt,Kt.value,Be);if(Po===null){bt===null&&(bt=er);break}o&&bt&&Po.alternate===null&&l(ge,bt),ce=_(Po,ce,wt),yt===null?gt=Po:yt.sibling=Po,yt=Po,bt=er}if(Kt.done)return p(ge,bt),un&&di(ge,wt),gt;if(bt===null){for(;!Kt.done;wt++,Kt=ye.next())Kt=Ae(ge,Kt.value,Be),Kt!==null&&(ce=_(Kt,ce,wt),yt===null?gt=Kt:yt.sibling=Kt,yt=Kt);return un&&di(ge,wt),gt}for(bt=v(ge,bt);!Kt.done;wt++,Kt=ye.next())Kt=nt(bt,ge,wt,Kt.value,Be),Kt!==null&&(o&&Kt.alternate!==null&&bt.delete(Kt.key===null?wt:Kt.key),ce=_(Kt,ce,wt),yt===null?gt=Kt:yt.sibling=Kt,yt=Kt);return o&&bt.forEach(function(YT){return l(ge,YT)}),un&&di(ge,wt),gt}function _n(ge,ce,ye,Be){if(typeof ye=="object"&&ye!==null&&ye.type===P&&ye.key===null&&(ye=ye.props.children),typeof ye=="object"&&ye!==null){switch(ye.$$typeof){case T:e:{for(var gt=ye.key,yt=ce;yt!==null;){if(yt.key===gt){if(gt=ye.type,gt===P){if(yt.tag===7){p(ge,yt.sibling),ce=R(yt,ye.props.children),ce.return=ge,ge=ce;break e}}else if(yt.elementType===gt||typeof gt=="object"&&gt!==null&&gt.$$typeof===te&&Ib(gt)===yt.type){p(ge,yt.sibling),ce=R(yt,ye.props),ce.ref=Ic(ge,yt,ye),ce.return=ge,ge=ce;break e}p(ge,yt);break}else l(ge,yt);yt=yt.sibling}ye.type===P?(ce=yi(ye.props.children,ge.mode,Be,ye.key),ce.return=ge,ge=ce):(Be=Nu(ye.type,ye.key,ye.props,null,ge.mode,Be),Be.ref=Ic(ge,ce,ye),Be.return=ge,ge=Be)}return q(ge);case $:e:{for(yt=ye.key;ce!==null;){if(ce.key===yt)if(ce.tag===4&&ce.stateNode.containerInfo===ye.containerInfo&&ce.stateNode.implementation===ye.implementation){p(ge,ce.sibling),ce=R(ce,ye.children||[]),ce.return=ge,ge=ce;break e}else{p(ge,ce);break}else l(ge,ce);ce=ce.sibling}ce=Sg(ye,ge.mode,Be),ce.return=ge,ge=ce}return q(ge);case te:return yt=ye._init,_n(ge,ce,yt(ye._payload),Be)}if(ft(ye))return it(ge,ce,ye,Be);if(O(ye))return ht(ge,ce,ye,Be);eu(ge,ye)}return typeof ye=="string"&&ye!==""||typeof ye=="number"?(ye=""+ye,ce!==null&&ce.tag===6?(p(ge,ce.sibling),ce=R(ce,ye),ce.return=ge,ge=ce):(p(ge,ce),ce=Ng(ye,ge.mode,Be),ce.return=ge,ge=ce),q(ge)):p(ge,ce)}return _n}var dl=Tb(!0),$b=Tb(!1),tu=ko(null),nu=null,ul=null,Am=null;function Mm(){Am=ul=nu=null}function Lm(o){var l=tu.current;an(tu),o._currentValue=l}function Fm(o,l,p){for(;o!==null;){var v=o.alternate;if((o.childLanes&l)!==l?(o.childLanes|=l,v!==null&&(v.childLanes|=l)):v!==null&&(v.childLanes&l)!==l&&(v.childLanes|=l),o===p)break;o=o.return}}function hl(o,l){nu=o,Am=ul=null,o=o.dependencies,o!==null&&o.firstContext!==null&&((o.lanes&l)!==0&&(Ur=!0),o.firstContext=null)}function ks(o){var l=o._currentValue;if(Am!==o)if(o={context:o,memoizedValue:l,next:null},ul===null){if(nu===null)throw Error(r(308));ul=o,nu.dependencies={lanes:0,firstContext:o}}else ul=ul.next=o;return l}var ui=null;function Om(o){ui===null?ui=[o]:ui.push(o)}function _b(o,l,p,v){var R=l.interleaved;return R===null?(p.next=p,Om(l)):(p.next=R.next,R.next=p),l.interleaved=p,Ba(o,v)}function Ba(o,l){o.lanes|=l;var p=o.alternate;for(p!==null&&(p.lanes|=l),p=o,o=o.return;o!==null;)o.childLanes|=l,p=o.alternate,p!==null&&(p.childLanes|=l),p=o,o=o.return;return p.tag===3?p.stateNode:null}var No=!1;function Dm(o){o.updateQueue={baseState:o.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Pb(o,l){o=o.updateQueue,l.updateQueue===o&&(l.updateQueue={baseState:o.baseState,firstBaseUpdate:o.firstBaseUpdate,lastBaseUpdate:o.lastBaseUpdate,shared:o.shared,effects:o.effects})}function Wa(o,l){return{eventTime:o,lane:l,tag:0,payload:null,callback:null,next:null}}function So(o,l,p){var v=o.updateQueue;if(v===null)return null;if(v=v.shared,(Ut&2)!==0){var R=v.pending;return R===null?l.next=l:(l.next=R.next,R.next=l),v.pending=l,Ba(o,p)}return R=v.interleaved,R===null?(l.next=l,Om(v)):(l.next=R.next,R.next=l),v.interleaved=l,Ba(o,p)}function ru(o,l,p){if(l=l.updateQueue,l!==null&&(l=l.shared,(p&4194240)!==0)){var v=l.lanes;v&=o.pendingLanes,p|=v,l.lanes=p,Y(o,p)}}function Eb(o,l){var p=o.updateQueue,v=o.alternate;if(v!==null&&(v=v.updateQueue,p===v)){var R=null,_=null;if(p=p.firstBaseUpdate,p!==null){do{var q={eventTime:p.eventTime,lane:p.lane,tag:p.tag,payload:p.payload,callback:p.callback,next:null};_===null?R=_=q:_=_.next=q,p=p.next}while(p!==null);_===null?R=_=l:_=_.next=l}else R=_=l;p={baseState:v.baseState,firstBaseUpdate:R,lastBaseUpdate:_,shared:v.shared,effects:v.effects},o.updateQueue=p;return}o=p.lastBaseUpdate,o===null?p.firstBaseUpdate=l:o.next=l,p.lastBaseUpdate=l}function su(o,l,p,v){var R=o.updateQueue;No=!1;var _=R.firstBaseUpdate,q=R.lastBaseUpdate,Z=R.shared.pending;if(Z!==null){R.shared.pending=null;var ie=Z,ve=ie.next;ie.next=null,q===null?_=ve:q.next=ve,q=ie;var Ee=o.alternate;Ee!==null&&(Ee=Ee.updateQueue,Z=Ee.lastBaseUpdate,Z!==q&&(Z===null?Ee.firstBaseUpdate=ve:Z.next=ve,Ee.lastBaseUpdate=ie))}if(_!==null){var Ae=R.baseState;q=0,Ee=ve=ie=null,Z=_;do{var Pe=Z.lane,nt=Z.eventTime;if((v&Pe)===Pe){Ee!==null&&(Ee=Ee.next={eventTime:nt,lane:0,tag:Z.tag,payload:Z.payload,callback:Z.callback,next:null});e:{var it=o,ht=Z;switch(Pe=l,nt=p,ht.tag){case 1:if(it=ht.payload,typeof it=="function"){Ae=it.call(nt,Ae,Pe);break e}Ae=it;break e;case 3:it.flags=it.flags&-65537|128;case 0:if(it=ht.payload,Pe=typeof it=="function"?it.call(nt,Ae,Pe):it,Pe==null)break e;Ae=E({},Ae,Pe);break e;case 2:No=!0}}Z.callback!==null&&Z.lane!==0&&(o.flags|=64,Pe=R.effects,Pe===null?R.effects=[Z]:Pe.push(Z))}else nt={eventTime:nt,lane:Pe,tag:Z.tag,payload:Z.payload,callback:Z.callback,next:null},Ee===null?(ve=Ee=nt,ie=Ae):Ee=Ee.next=nt,q|=Pe;if(Z=Z.next,Z===null){if(Z=R.shared.pending,Z===null)break;Pe=Z,Z=Pe.next,Pe.next=null,R.lastBaseUpdate=Pe,R.shared.pending=null}}while(!0);if(Ee===null&&(ie=Ae),R.baseState=ie,R.firstBaseUpdate=ve,R.lastBaseUpdate=Ee,l=R.shared.interleaved,l!==null){R=l;do q|=R.lane,R=R.next;while(R!==l)}else _===null&&(R.shared.lanes=0);mi|=q,o.lanes=q,o.memoizedState=Ae}}function Ab(o,l,p){if(o=l.effects,l.effects=null,o!==null)for(l=0;l<o.length;l++){var v=o[l],R=v.callback;if(R!==null){if(v.callback=null,v=p,typeof R!="function")throw Error(r(191,R));R.call(v)}}}var Tc={},oa=ko(Tc),$c=ko(Tc),_c=ko(Tc);function hi(o){if(o===Tc)throw Error(r(174));return o}function Bm(o,l){switch(nn(_c,l),nn($c,o),nn(oa,Tc),o=l.nodeType,o){case 9:case 11:l=(l=l.documentElement)?l.namespaceURI:ct(null,"");break;default:o=o===8?l.parentNode:l,l=o.namespaceURI||null,o=o.tagName,l=ct(l,o)}an(oa),nn(oa,l)}function pl(){an(oa),an($c),an(_c)}function Mb(o){hi(_c.current);var l=hi(oa.current),p=ct(l,o.type);l!==p&&(nn($c,o),nn(oa,p))}function Wm(o){$c.current===o&&(an(oa),an($c))}var bn=ko(0);function au(o){for(var l=o;l!==null;){if(l.tag===13){var p=l.memoizedState;if(p!==null&&(p=p.dehydrated,p===null||p.data==="$?"||p.data==="$!"))return l}else if(l.tag===19&&l.memoizedProps.revealOrder!==void 0){if((l.flags&128)!==0)return l}else if(l.child!==null){l.child.return=l,l=l.child;continue}if(l===o)break;for(;l.sibling===null;){if(l.return===null||l.return===o)return null;l=l.return}l.sibling.return=l.return,l=l.sibling}return null}var qm=[];function Um(){for(var o=0;o<qm.length;o++)qm[o]._workInProgressVersionPrimary=null;qm.length=0}var ou=S.ReactCurrentDispatcher,Hm=S.ReactCurrentBatchConfig,pi=0,vn=null,Un=null,Zn=null,iu=!1,Pc=!1,Ec=0,yT=0;function br(){throw Error(r(321))}function zm(o,l){if(l===null)return!1;for(var p=0;p<l.length&&p<o.length;p++)if(!Os(o[p],l[p]))return!1;return!0}function Km(o,l,p,v,R,_){if(pi=_,vn=l,l.memoizedState=null,l.updateQueue=null,l.lanes=0,ou.current=o===null||o.memoizedState===null?wT:jT,o=p(v,R),Pc){_=0;do{if(Pc=!1,Ec=0,25<=_)throw Error(r(301));_+=1,Zn=Un=null,l.updateQueue=null,ou.current=NT,o=p(v,R)}while(Pc)}if(ou.current=du,l=Un!==null&&Un.next!==null,pi=0,Zn=Un=vn=null,iu=!1,l)throw Error(r(300));return o}function Gm(){var o=Ec!==0;return Ec=0,o}function ia(){var o={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Zn===null?vn.memoizedState=Zn=o:Zn=Zn.next=o,Zn}function ws(){if(Un===null){var o=vn.alternate;o=o!==null?o.memoizedState:null}else o=Un.next;var l=Zn===null?vn.memoizedState:Zn.next;if(l!==null)Zn=l,Un=o;else{if(o===null)throw Error(r(310));Un=o,o={memoizedState:Un.memoizedState,baseState:Un.baseState,baseQueue:Un.baseQueue,queue:Un.queue,next:null},Zn===null?vn.memoizedState=Zn=o:Zn=Zn.next=o}return Zn}function Ac(o,l){return typeof l=="function"?l(o):l}function Vm(o){var l=ws(),p=l.queue;if(p===null)throw Error(r(311));p.lastRenderedReducer=o;var v=Un,R=v.baseQueue,_=p.pending;if(_!==null){if(R!==null){var q=R.next;R.next=_.next,_.next=q}v.baseQueue=R=_,p.pending=null}if(R!==null){_=R.next,v=v.baseState;var Z=q=null,ie=null,ve=_;do{var Ee=ve.lane;if((pi&Ee)===Ee)ie!==null&&(ie=ie.next={lane:0,action:ve.action,hasEagerState:ve.hasEagerState,eagerState:ve.eagerState,next:null}),v=ve.hasEagerState?ve.eagerState:o(v,ve.action);else{var Ae={lane:Ee,action:ve.action,hasEagerState:ve.hasEagerState,eagerState:ve.eagerState,next:null};ie===null?(Z=ie=Ae,q=v):ie=ie.next=Ae,vn.lanes|=Ee,mi|=Ee}ve=ve.next}while(ve!==null&&ve!==_);ie===null?q=v:ie.next=Z,Os(v,l.memoizedState)||(Ur=!0),l.memoizedState=v,l.baseState=q,l.baseQueue=ie,p.lastRenderedState=v}if(o=p.interleaved,o!==null){R=o;do _=R.lane,vn.lanes|=_,mi|=_,R=R.next;while(R!==o)}else R===null&&(p.lanes=0);return[l.memoizedState,p.dispatch]}function Qm(o){var l=ws(),p=l.queue;if(p===null)throw Error(r(311));p.lastRenderedReducer=o;var v=p.dispatch,R=p.pending,_=l.memoizedState;if(R!==null){p.pending=null;var q=R=R.next;do _=o(_,q.action),q=q.next;while(q!==R);Os(_,l.memoizedState)||(Ur=!0),l.memoizedState=_,l.baseQueue===null&&(l.baseState=_),p.lastRenderedState=_}return[_,v]}function Lb(){}function Fb(o,l){var p=vn,v=ws(),R=l(),_=!Os(v.memoizedState,R);if(_&&(v.memoizedState=R,Ur=!0),v=v.queue,Ym(Bb.bind(null,p,v,o),[o]),v.getSnapshot!==l||_||Zn!==null&&Zn.memoizedState.tag&1){if(p.flags|=2048,Mc(9,Db.bind(null,p,v,R,l),void 0,null),Jn===null)throw Error(r(349));(pi&30)!==0||Ob(p,l,R)}return R}function Ob(o,l,p){o.flags|=16384,o={getSnapshot:l,value:p},l=vn.updateQueue,l===null?(l={lastEffect:null,stores:null},vn.updateQueue=l,l.stores=[o]):(p=l.stores,p===null?l.stores=[o]:p.push(o))}function Db(o,l,p,v){l.value=p,l.getSnapshot=v,Wb(l)&&qb(o)}function Bb(o,l,p){return p(function(){Wb(l)&&qb(o)})}function Wb(o){var l=o.getSnapshot;o=o.value;try{var p=l();return!Os(o,p)}catch{return!0}}function qb(o){var l=Ba(o,1);l!==null&&Us(l,o,1,-1)}function Ub(o){var l=ia();return typeof o=="function"&&(o=o()),l.memoizedState=l.baseState=o,o={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Ac,lastRenderedState:o},l.queue=o,o=o.dispatch=kT.bind(null,vn,o),[l.memoizedState,o]}function Mc(o,l,p,v){return o={tag:o,create:l,destroy:p,deps:v,next:null},l=vn.updateQueue,l===null?(l={lastEffect:null,stores:null},vn.updateQueue=l,l.lastEffect=o.next=o):(p=l.lastEffect,p===null?l.lastEffect=o.next=o:(v=p.next,p.next=o,o.next=v,l.lastEffect=o)),o}function Hb(){return ws().memoizedState}function lu(o,l,p,v){var R=ia();vn.flags|=o,R.memoizedState=Mc(1|l,p,void 0,v===void 0?null:v)}function cu(o,l,p,v){var R=ws();v=v===void 0?null:v;var _=void 0;if(Un!==null){var q=Un.memoizedState;if(_=q.destroy,v!==null&&zm(v,q.deps)){R.memoizedState=Mc(l,p,_,v);return}}vn.flags|=o,R.memoizedState=Mc(1|l,p,_,v)}function zb(o,l){return lu(8390656,8,o,l)}function Ym(o,l){return cu(2048,8,o,l)}function Kb(o,l){return cu(4,2,o,l)}function Gb(o,l){return cu(4,4,o,l)}function Vb(o,l){if(typeof l=="function")return o=o(),l(o),function(){l(null)};if(l!=null)return o=o(),l.current=o,function(){l.current=null}}function Qb(o,l,p){return p=p!=null?p.concat([o]):null,cu(4,4,Vb.bind(null,l,o),p)}function Xm(){}function Yb(o,l){var p=ws();l=l===void 0?null:l;var v=p.memoizedState;return v!==null&&l!==null&&zm(l,v[1])?v[0]:(p.memoizedState=[o,l],o)}function Xb(o,l){var p=ws();l=l===void 0?null:l;var v=p.memoizedState;return v!==null&&l!==null&&zm(l,v[1])?v[0]:(o=o(),p.memoizedState=[o,l],o)}function Zb(o,l,p){return(pi&21)===0?(o.baseState&&(o.baseState=!1,Ur=!0),o.memoizedState=p):(Os(p,l)||(p=Aa(),vn.lanes|=p,mi|=p,o.baseState=!0),l)}function bT(o,l){var p=de;de=p!==0&&4>p?p:4,o(!0);var v=Hm.transition;Hm.transition={};try{o(!1),l()}finally{de=p,Hm.transition=v}}function Jb(){return ws().memoizedState}function vT(o,l,p){var v=To(o);if(p={lane:v,action:p,hasEagerState:!1,eagerState:null,next:null},ev(o))tv(l,p);else if(p=_b(o,l,p,v),p!==null){var R=Ar();Us(p,o,v,R),nv(p,l,v)}}function kT(o,l,p){var v=To(o),R={lane:v,action:p,hasEagerState:!1,eagerState:null,next:null};if(ev(o))tv(l,R);else{var _=o.alternate;if(o.lanes===0&&(_===null||_.lanes===0)&&(_=l.lastRenderedReducer,_!==null))try{var q=l.lastRenderedState,Z=_(q,p);if(R.hasEagerState=!0,R.eagerState=Z,Os(Z,q)){var ie=l.interleaved;ie===null?(R.next=R,Om(l)):(R.next=ie.next,ie.next=R),l.interleaved=R;return}}catch{}finally{}p=_b(o,l,R,v),p!==null&&(R=Ar(),Us(p,o,v,R),nv(p,l,v))}}function ev(o){var l=o.alternate;return o===vn||l!==null&&l===vn}function tv(o,l){Pc=iu=!0;var p=o.pending;p===null?l.next=l:(l.next=p.next,p.next=l),o.pending=l}function nv(o,l,p){if((p&4194240)!==0){var v=l.lanes;v&=o.pendingLanes,p|=v,l.lanes=p,Y(o,p)}}var du={readContext:ks,useCallback:br,useContext:br,useEffect:br,useImperativeHandle:br,useInsertionEffect:br,useLayoutEffect:br,useMemo:br,useReducer:br,useRef:br,useState:br,useDebugValue:br,useDeferredValue:br,useTransition:br,useMutableSource:br,useSyncExternalStore:br,useId:br,unstable_isNewReconciler:!1},wT={readContext:ks,useCallback:function(o,l){return ia().memoizedState=[o,l===void 0?null:l],o},useContext:ks,useEffect:zb,useImperativeHandle:function(o,l,p){return p=p!=null?p.concat([o]):null,lu(4194308,4,Vb.bind(null,l,o),p)},useLayoutEffect:function(o,l){return lu(4194308,4,o,l)},useInsertionEffect:function(o,l){return lu(4,2,o,l)},useMemo:function(o,l){var p=ia();return l=l===void 0?null:l,o=o(),p.memoizedState=[o,l],o},useReducer:function(o,l,p){var v=ia();return l=p!==void 0?p(l):l,v.memoizedState=v.baseState=l,o={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:o,lastRenderedState:l},v.queue=o,o=o.dispatch=vT.bind(null,vn,o),[v.memoizedState,o]},useRef:function(o){var l=ia();return o={current:o},l.memoizedState=o},useState:Ub,useDebugValue:Xm,useDeferredValue:function(o){return ia().memoizedState=o},useTransition:function(){var o=Ub(!1),l=o[0];return o=bT.bind(null,o[1]),ia().memoizedState=o,[l,o]},useMutableSource:function(){},useSyncExternalStore:function(o,l,p){var v=vn,R=ia();if(un){if(p===void 0)throw Error(r(407));p=p()}else{if(p=l(),Jn===null)throw Error(r(349));(pi&30)!==0||Ob(v,l,p)}R.memoizedState=p;var _={value:p,getSnapshot:l};return R.queue=_,zb(Bb.bind(null,v,_,o),[o]),v.flags|=2048,Mc(9,Db.bind(null,v,_,p,l),void 0,null),p},useId:function(){var o=ia(),l=Jn.identifierPrefix;if(un){var p=Da,v=Oa;p=(v&~(1<<32-Gt(v)-1)).toString(32)+p,l=":"+l+"R"+p,p=Ec++,0<p&&(l+="H"+p.toString(32)),l+=":"}else p=yT++,l=":"+l+"r"+p.toString(32)+":";return o.memoizedState=l},unstable_isNewReconciler:!1},jT={readContext:ks,useCallback:Yb,useContext:ks,useEffect:Ym,useImperativeHandle:Qb,useInsertionEffect:Kb,useLayoutEffect:Gb,useMemo:Xb,useReducer:Vm,useRef:Hb,useState:function(){return Vm(Ac)},useDebugValue:Xm,useDeferredValue:function(o){var l=ws();return Zb(l,Un.memoizedState,o)},useTransition:function(){var o=Vm(Ac)[0],l=ws().memoizedState;return[o,l]},useMutableSource:Lb,useSyncExternalStore:Fb,useId:Jb,unstable_isNewReconciler:!1},NT={readContext:ks,useCallback:Yb,useContext:ks,useEffect:Ym,useImperativeHandle:Qb,useInsertionEffect:Kb,useLayoutEffect:Gb,useMemo:Xb,useReducer:Qm,useRef:Hb,useState:function(){return Qm(Ac)},useDebugValue:Xm,useDeferredValue:function(o){var l=ws();return Un===null?l.memoizedState=o:Zb(l,Un.memoizedState,o)},useTransition:function(){var o=Qm(Ac)[0],l=ws().memoizedState;return[o,l]},useMutableSource:Lb,useSyncExternalStore:Fb,useId:Jb,unstable_isNewReconciler:!1};function Bs(o,l){if(o&&o.defaultProps){l=E({},l),o=o.defaultProps;for(var p in o)l[p]===void 0&&(l[p]=o[p]);return l}return l}function Zm(o,l,p,v){l=o.memoizedState,p=p(v,l),p=p==null?l:E({},l,p),o.memoizedState=p,o.lanes===0&&(o.updateQueue.baseState=p)}var uu={isMounted:function(o){return(o=o._reactInternals)?yn(o)===o:!1},enqueueSetState:function(o,l,p){o=o._reactInternals;var v=Ar(),R=To(o),_=Wa(v,R);_.payload=l,p!=null&&(_.callback=p),l=So(o,_,R),l!==null&&(Us(l,o,R,v),ru(l,o,R))},enqueueReplaceState:function(o,l,p){o=o._reactInternals;var v=Ar(),R=To(o),_=Wa(v,R);_.tag=1,_.payload=l,p!=null&&(_.callback=p),l=So(o,_,R),l!==null&&(Us(l,o,R,v),ru(l,o,R))},enqueueForceUpdate:function(o,l){o=o._reactInternals;var p=Ar(),v=To(o),R=Wa(p,v);R.tag=2,l!=null&&(R.callback=l),l=So(o,R,v),l!==null&&(Us(l,o,v,p),ru(l,o,v))}};function rv(o,l,p,v,R,_,q){return o=o.stateNode,typeof o.shouldComponentUpdate=="function"?o.shouldComponentUpdate(v,_,q):l.prototype&&l.prototype.isPureReactComponent?!kc(p,v)||!kc(R,_):!0}function sv(o,l,p){var v=!1,R=wo,_=l.contextType;return typeof _=="object"&&_!==null?_=ks(_):(R=qr(l)?li:yr.current,v=l.contextTypes,_=(v=v!=null)?ol(o,R):wo),l=new l(p,_),o.memoizedState=l.state!==null&&l.state!==void 0?l.state:null,l.updater=uu,o.stateNode=l,l._reactInternals=o,v&&(o=o.stateNode,o.__reactInternalMemoizedUnmaskedChildContext=R,o.__reactInternalMemoizedMaskedChildContext=_),l}function av(o,l,p,v){o=l.state,typeof l.componentWillReceiveProps=="function"&&l.componentWillReceiveProps(p,v),typeof l.UNSAFE_componentWillReceiveProps=="function"&&l.UNSAFE_componentWillReceiveProps(p,v),l.state!==o&&uu.enqueueReplaceState(l,l.state,null)}function Jm(o,l,p,v){var R=o.stateNode;R.props=p,R.state=o.memoizedState,R.refs={},Dm(o);var _=l.contextType;typeof _=="object"&&_!==null?R.context=ks(_):(_=qr(l)?li:yr.current,R.context=ol(o,_)),R.state=o.memoizedState,_=l.getDerivedStateFromProps,typeof _=="function"&&(Zm(o,l,_,p),R.state=o.memoizedState),typeof l.getDerivedStateFromProps=="function"||typeof R.getSnapshotBeforeUpdate=="function"||typeof R.UNSAFE_componentWillMount!="function"&&typeof R.componentWillMount!="function"||(l=R.state,typeof R.componentWillMount=="function"&&R.componentWillMount(),typeof R.UNSAFE_componentWillMount=="function"&&R.UNSAFE_componentWillMount(),l!==R.state&&uu.enqueueReplaceState(R,R.state,null),su(o,p,R,v),R.state=o.memoizedState),typeof R.componentDidMount=="function"&&(o.flags|=4194308)}function ml(o,l){try{var p="",v=l;do p+=J(v),v=v.return;while(v);var R=p}catch(_){R=`
24
+ Error generating stack: `+_.message+`
25
+ `+_.stack}return{value:o,source:l,stack:R,digest:null}}function eg(o,l,p){return{value:o,source:null,stack:p??null,digest:l??null}}function tg(o,l){try{console.error(l.value)}catch(p){setTimeout(function(){throw p})}}var ST=typeof WeakMap=="function"?WeakMap:Map;function ov(o,l,p){p=Wa(-1,p),p.tag=3,p.payload={element:null};var v=l.value;return p.callback=function(){yu||(yu=!0,fg=v),tg(o,l)},p}function iv(o,l,p){p=Wa(-1,p),p.tag=3;var v=o.type.getDerivedStateFromError;if(typeof v=="function"){var R=l.value;p.payload=function(){return v(R)},p.callback=function(){tg(o,l)}}var _=o.stateNode;return _!==null&&typeof _.componentDidCatch=="function"&&(p.callback=function(){tg(o,l),typeof v!="function"&&(Ro===null?Ro=new Set([this]):Ro.add(this));var q=l.stack;this.componentDidCatch(l.value,{componentStack:q!==null?q:""})}),p}function lv(o,l,p){var v=o.pingCache;if(v===null){v=o.pingCache=new ST;var R=new Set;v.set(l,R)}else R=v.get(l),R===void 0&&(R=new Set,v.set(l,R));R.has(p)||(R.add(p),o=DT.bind(null,o,l,p),l.then(o,o))}function cv(o){do{var l;if((l=o.tag===13)&&(l=o.memoizedState,l=l!==null?l.dehydrated!==null:!0),l)return o;o=o.return}while(o!==null);return null}function dv(o,l,p,v,R){return(o.mode&1)===0?(o===l?o.flags|=65536:(o.flags|=128,p.flags|=131072,p.flags&=-52805,p.tag===1&&(p.alternate===null?p.tag=17:(l=Wa(-1,1),l.tag=2,So(p,l,1))),p.lanes|=1),o):(o.flags|=65536,o.lanes=R,o)}var CT=S.ReactCurrentOwner,Ur=!1;function Er(o,l,p,v){l.child=o===null?$b(l,null,p,v):dl(l,o.child,p,v)}function uv(o,l,p,v,R){p=p.render;var _=l.ref;return hl(l,R),v=Km(o,l,p,v,_,R),p=Gm(),o!==null&&!Ur?(l.updateQueue=o.updateQueue,l.flags&=-2053,o.lanes&=~R,qa(o,l,R)):(un&&p&&Tm(l),l.flags|=1,Er(o,l,v,R),l.child)}function hv(o,l,p,v,R){if(o===null){var _=p.type;return typeof _=="function"&&!jg(_)&&_.defaultProps===void 0&&p.compare===null&&p.defaultProps===void 0?(l.tag=15,l.type=_,pv(o,l,_,v,R)):(o=Nu(p.type,null,v,l,l.mode,R),o.ref=l.ref,o.return=l,l.child=o)}if(_=o.child,(o.lanes&R)===0){var q=_.memoizedProps;if(p=p.compare,p=p!==null?p:kc,p(q,v)&&o.ref===l.ref)return qa(o,l,R)}return l.flags|=1,o=_o(_,v),o.ref=l.ref,o.return=l,l.child=o}function pv(o,l,p,v,R){if(o!==null){var _=o.memoizedProps;if(kc(_,v)&&o.ref===l.ref)if(Ur=!1,l.pendingProps=v=_,(o.lanes&R)!==0)(o.flags&131072)!==0&&(Ur=!0);else return l.lanes=o.lanes,qa(o,l,R)}return ng(o,l,p,v,R)}function mv(o,l,p){var v=l.pendingProps,R=v.children,_=o!==null?o.memoizedState:null;if(v.mode==="hidden")if((l.mode&1)===0)l.memoizedState={baseLanes:0,cachePool:null,transitions:null},nn(fl,ss),ss|=p;else{if((p&1073741824)===0)return o=_!==null?_.baseLanes|p:p,l.lanes=l.childLanes=1073741824,l.memoizedState={baseLanes:o,cachePool:null,transitions:null},l.updateQueue=null,nn(fl,ss),ss|=o,null;l.memoizedState={baseLanes:0,cachePool:null,transitions:null},v=_!==null?_.baseLanes:p,nn(fl,ss),ss|=v}else _!==null?(v=_.baseLanes|p,l.memoizedState=null):v=p,nn(fl,ss),ss|=v;return Er(o,l,R,p),l.child}function gv(o,l){var p=l.ref;(o===null&&p!==null||o!==null&&o.ref!==p)&&(l.flags|=512,l.flags|=2097152)}function ng(o,l,p,v,R){var _=qr(p)?li:yr.current;return _=ol(l,_),hl(l,R),p=Km(o,l,p,v,_,R),v=Gm(),o!==null&&!Ur?(l.updateQueue=o.updateQueue,l.flags&=-2053,o.lanes&=~R,qa(o,l,R)):(un&&v&&Tm(l),l.flags|=1,Er(o,l,p,R),l.child)}function fv(o,l,p,v,R){if(qr(p)){var _=!0;Qd(l)}else _=!1;if(hl(l,R),l.stateNode===null)pu(o,l),sv(l,p,v),Jm(l,p,v,R),v=!0;else if(o===null){var q=l.stateNode,Z=l.memoizedProps;q.props=Z;var ie=q.context,ve=p.contextType;typeof ve=="object"&&ve!==null?ve=ks(ve):(ve=qr(p)?li:yr.current,ve=ol(l,ve));var Ee=p.getDerivedStateFromProps,Ae=typeof Ee=="function"||typeof q.getSnapshotBeforeUpdate=="function";Ae||typeof q.UNSAFE_componentWillReceiveProps!="function"&&typeof q.componentWillReceiveProps!="function"||(Z!==v||ie!==ve)&&av(l,q,v,ve),No=!1;var Pe=l.memoizedState;q.state=Pe,su(l,v,q,R),ie=l.memoizedState,Z!==v||Pe!==ie||Wr.current||No?(typeof Ee=="function"&&(Zm(l,p,Ee,v),ie=l.memoizedState),(Z=No||rv(l,p,Z,v,Pe,ie,ve))?(Ae||typeof q.UNSAFE_componentWillMount!="function"&&typeof q.componentWillMount!="function"||(typeof q.componentWillMount=="function"&&q.componentWillMount(),typeof q.UNSAFE_componentWillMount=="function"&&q.UNSAFE_componentWillMount()),typeof q.componentDidMount=="function"&&(l.flags|=4194308)):(typeof q.componentDidMount=="function"&&(l.flags|=4194308),l.memoizedProps=v,l.memoizedState=ie),q.props=v,q.state=ie,q.context=ve,v=Z):(typeof q.componentDidMount=="function"&&(l.flags|=4194308),v=!1)}else{q=l.stateNode,Pb(o,l),Z=l.memoizedProps,ve=l.type===l.elementType?Z:Bs(l.type,Z),q.props=ve,Ae=l.pendingProps,Pe=q.context,ie=p.contextType,typeof ie=="object"&&ie!==null?ie=ks(ie):(ie=qr(p)?li:yr.current,ie=ol(l,ie));var nt=p.getDerivedStateFromProps;(Ee=typeof nt=="function"||typeof q.getSnapshotBeforeUpdate=="function")||typeof q.UNSAFE_componentWillReceiveProps!="function"&&typeof q.componentWillReceiveProps!="function"||(Z!==Ae||Pe!==ie)&&av(l,q,v,ie),No=!1,Pe=l.memoizedState,q.state=Pe,su(l,v,q,R);var it=l.memoizedState;Z!==Ae||Pe!==it||Wr.current||No?(typeof nt=="function"&&(Zm(l,p,nt,v),it=l.memoizedState),(ve=No||rv(l,p,ve,v,Pe,it,ie)||!1)?(Ee||typeof q.UNSAFE_componentWillUpdate!="function"&&typeof q.componentWillUpdate!="function"||(typeof q.componentWillUpdate=="function"&&q.componentWillUpdate(v,it,ie),typeof q.UNSAFE_componentWillUpdate=="function"&&q.UNSAFE_componentWillUpdate(v,it,ie)),typeof q.componentDidUpdate=="function"&&(l.flags|=4),typeof q.getSnapshotBeforeUpdate=="function"&&(l.flags|=1024)):(typeof q.componentDidUpdate!="function"||Z===o.memoizedProps&&Pe===o.memoizedState||(l.flags|=4),typeof q.getSnapshotBeforeUpdate!="function"||Z===o.memoizedProps&&Pe===o.memoizedState||(l.flags|=1024),l.memoizedProps=v,l.memoizedState=it),q.props=v,q.state=it,q.context=ie,v=ve):(typeof q.componentDidUpdate!="function"||Z===o.memoizedProps&&Pe===o.memoizedState||(l.flags|=4),typeof q.getSnapshotBeforeUpdate!="function"||Z===o.memoizedProps&&Pe===o.memoizedState||(l.flags|=1024),v=!1)}return rg(o,l,p,v,_,R)}function rg(o,l,p,v,R,_){gv(o,l);var q=(l.flags&128)!==0;if(!v&&!q)return R&&kb(l,p,!1),qa(o,l,_);v=l.stateNode,CT.current=l;var Z=q&&typeof p.getDerivedStateFromError!="function"?null:v.render();return l.flags|=1,o!==null&&q?(l.child=dl(l,o.child,null,_),l.child=dl(l,null,Z,_)):Er(o,l,Z,_),l.memoizedState=v.state,R&&kb(l,p,!0),l.child}function xv(o){var l=o.stateNode;l.pendingContext?bb(o,l.pendingContext,l.pendingContext!==l.context):l.context&&bb(o,l.context,!1),Bm(o,l.containerInfo)}function yv(o,l,p,v,R){return cl(),Em(R),l.flags|=256,Er(o,l,p,v),l.child}var sg={dehydrated:null,treeContext:null,retryLane:0};function ag(o){return{baseLanes:o,cachePool:null,transitions:null}}function bv(o,l,p){var v=l.pendingProps,R=bn.current,_=!1,q=(l.flags&128)!==0,Z;if((Z=q)||(Z=o!==null&&o.memoizedState===null?!1:(R&2)!==0),Z?(_=!0,l.flags&=-129):(o===null||o.memoizedState!==null)&&(R|=1),nn(bn,R&1),o===null)return Pm(l),o=l.memoizedState,o!==null&&(o=o.dehydrated,o!==null)?((l.mode&1)===0?l.lanes=1:o.data==="$!"?l.lanes=8:l.lanes=1073741824,null):(q=v.children,o=v.fallback,_?(v=l.mode,_=l.child,q={mode:"hidden",children:q},(v&1)===0&&_!==null?(_.childLanes=0,_.pendingProps=q):_=Su(q,v,0,null),o=yi(o,v,p,null),_.return=l,o.return=l,_.sibling=o,l.child=_,l.child.memoizedState=ag(p),l.memoizedState=sg,o):og(l,q));if(R=o.memoizedState,R!==null&&(Z=R.dehydrated,Z!==null))return RT(o,l,q,v,Z,R,p);if(_){_=v.fallback,q=l.mode,R=o.child,Z=R.sibling;var ie={mode:"hidden",children:v.children};return(q&1)===0&&l.child!==R?(v=l.child,v.childLanes=0,v.pendingProps=ie,l.deletions=null):(v=_o(R,ie),v.subtreeFlags=R.subtreeFlags&14680064),Z!==null?_=_o(Z,_):(_=yi(_,q,p,null),_.flags|=2),_.return=l,v.return=l,v.sibling=_,l.child=v,v=_,_=l.child,q=o.child.memoizedState,q=q===null?ag(p):{baseLanes:q.baseLanes|p,cachePool:null,transitions:q.transitions},_.memoizedState=q,_.childLanes=o.childLanes&~p,l.memoizedState=sg,v}return _=o.child,o=_.sibling,v=_o(_,{mode:"visible",children:v.children}),(l.mode&1)===0&&(v.lanes=p),v.return=l,v.sibling=null,o!==null&&(p=l.deletions,p===null?(l.deletions=[o],l.flags|=16):p.push(o)),l.child=v,l.memoizedState=null,v}function og(o,l){return l=Su({mode:"visible",children:l},o.mode,0,null),l.return=o,o.child=l}function hu(o,l,p,v){return v!==null&&Em(v),dl(l,o.child,null,p),o=og(l,l.pendingProps.children),o.flags|=2,l.memoizedState=null,o}function RT(o,l,p,v,R,_,q){if(p)return l.flags&256?(l.flags&=-257,v=eg(Error(r(422))),hu(o,l,q,v)):l.memoizedState!==null?(l.child=o.child,l.flags|=128,null):(_=v.fallback,R=l.mode,v=Su({mode:"visible",children:v.children},R,0,null),_=yi(_,R,q,null),_.flags|=2,v.return=l,_.return=l,v.sibling=_,l.child=v,(l.mode&1)!==0&&dl(l,o.child,null,q),l.child.memoizedState=ag(q),l.memoizedState=sg,_);if((l.mode&1)===0)return hu(o,l,q,null);if(R.data==="$!"){if(v=R.nextSibling&&R.nextSibling.dataset,v)var Z=v.dgst;return v=Z,_=Error(r(419)),v=eg(_,v,void 0),hu(o,l,q,v)}if(Z=(q&o.childLanes)!==0,Ur||Z){if(v=Jn,v!==null){switch(q&-q){case 4:R=2;break;case 16:R=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:R=32;break;case 536870912:R=268435456;break;default:R=0}R=(R&(v.suspendedLanes|q))!==0?0:R,R!==0&&R!==_.retryLane&&(_.retryLane=R,Ba(o,R),Us(v,o,R,-1))}return wg(),v=eg(Error(r(421))),hu(o,l,q,v)}return R.data==="$?"?(l.flags|=128,l.child=o.child,l=BT.bind(null,o),R._reactRetry=l,null):(o=_.treeContext,rs=vo(R.nextSibling),ns=l,un=!0,Ds=null,o!==null&&(bs[vs++]=Oa,bs[vs++]=Da,bs[vs++]=ci,Oa=o.id,Da=o.overflow,ci=l),l=og(l,v.children),l.flags|=4096,l)}function vv(o,l,p){o.lanes|=l;var v=o.alternate;v!==null&&(v.lanes|=l),Fm(o.return,l,p)}function ig(o,l,p,v,R){var _=o.memoizedState;_===null?o.memoizedState={isBackwards:l,rendering:null,renderingStartTime:0,last:v,tail:p,tailMode:R}:(_.isBackwards=l,_.rendering=null,_.renderingStartTime=0,_.last=v,_.tail=p,_.tailMode=R)}function kv(o,l,p){var v=l.pendingProps,R=v.revealOrder,_=v.tail;if(Er(o,l,v.children,p),v=bn.current,(v&2)!==0)v=v&1|2,l.flags|=128;else{if(o!==null&&(o.flags&128)!==0)e:for(o=l.child;o!==null;){if(o.tag===13)o.memoizedState!==null&&vv(o,p,l);else if(o.tag===19)vv(o,p,l);else if(o.child!==null){o.child.return=o,o=o.child;continue}if(o===l)break e;for(;o.sibling===null;){if(o.return===null||o.return===l)break e;o=o.return}o.sibling.return=o.return,o=o.sibling}v&=1}if(nn(bn,v),(l.mode&1)===0)l.memoizedState=null;else switch(R){case"forwards":for(p=l.child,R=null;p!==null;)o=p.alternate,o!==null&&au(o)===null&&(R=p),p=p.sibling;p=R,p===null?(R=l.child,l.child=null):(R=p.sibling,p.sibling=null),ig(l,!1,R,p,_);break;case"backwards":for(p=null,R=l.child,l.child=null;R!==null;){if(o=R.alternate,o!==null&&au(o)===null){l.child=R;break}o=R.sibling,R.sibling=p,p=R,R=o}ig(l,!0,p,null,_);break;case"together":ig(l,!1,null,null,void 0);break;default:l.memoizedState=null}return l.child}function pu(o,l){(l.mode&1)===0&&o!==null&&(o.alternate=null,l.alternate=null,l.flags|=2)}function qa(o,l,p){if(o!==null&&(l.dependencies=o.dependencies),mi|=l.lanes,(p&l.childLanes)===0)return null;if(o!==null&&l.child!==o.child)throw Error(r(153));if(l.child!==null){for(o=l.child,p=_o(o,o.pendingProps),l.child=p,p.return=l;o.sibling!==null;)o=o.sibling,p=p.sibling=_o(o,o.pendingProps),p.return=l;p.sibling=null}return l.child}function IT(o,l,p){switch(l.tag){case 3:xv(l),cl();break;case 5:Mb(l);break;case 1:qr(l.type)&&Qd(l);break;case 4:Bm(l,l.stateNode.containerInfo);break;case 10:var v=l.type._context,R=l.memoizedProps.value;nn(tu,v._currentValue),v._currentValue=R;break;case 13:if(v=l.memoizedState,v!==null)return v.dehydrated!==null?(nn(bn,bn.current&1),l.flags|=128,null):(p&l.child.childLanes)!==0?bv(o,l,p):(nn(bn,bn.current&1),o=qa(o,l,p),o!==null?o.sibling:null);nn(bn,bn.current&1);break;case 19:if(v=(p&l.childLanes)!==0,(o.flags&128)!==0){if(v)return kv(o,l,p);l.flags|=128}if(R=l.memoizedState,R!==null&&(R.rendering=null,R.tail=null,R.lastEffect=null),nn(bn,bn.current),v)break;return null;case 22:case 23:return l.lanes=0,mv(o,l,p)}return qa(o,l,p)}var wv,lg,jv,Nv;wv=function(o,l){for(var p=l.child;p!==null;){if(p.tag===5||p.tag===6)o.appendChild(p.stateNode);else if(p.tag!==4&&p.child!==null){p.child.return=p,p=p.child;continue}if(p===l)break;for(;p.sibling===null;){if(p.return===null||p.return===l)return;p=p.return}p.sibling.return=p.return,p=p.sibling}},lg=function(){},jv=function(o,l,p,v){var R=o.memoizedProps;if(R!==v){o=l.stateNode,hi(oa.current);var _=null;switch(p){case"input":R=le(o,R),v=le(o,v),_=[];break;case"select":R=E({},R,{value:void 0}),v=E({},v,{value:void 0}),_=[];break;case"textarea":R=se(o,R),v=se(o,v),_=[];break;default:typeof R.onClick!="function"&&typeof v.onClick=="function"&&(o.onclick=Kd)}Wt(p,v);var q;p=null;for(ve in R)if(!v.hasOwnProperty(ve)&&R.hasOwnProperty(ve)&&R[ve]!=null)if(ve==="style"){var Z=R[ve];for(q in Z)Z.hasOwnProperty(q)&&(p||(p={}),p[q]="")}else ve!=="dangerouslySetInnerHTML"&&ve!=="children"&&ve!=="suppressContentEditableWarning"&&ve!=="suppressHydrationWarning"&&ve!=="autoFocus"&&(a.hasOwnProperty(ve)?_||(_=[]):(_=_||[]).push(ve,null));for(ve in v){var ie=v[ve];if(Z=R!=null?R[ve]:void 0,v.hasOwnProperty(ve)&&ie!==Z&&(ie!=null||Z!=null))if(ve==="style")if(Z){for(q in Z)!Z.hasOwnProperty(q)||ie&&ie.hasOwnProperty(q)||(p||(p={}),p[q]="");for(q in ie)ie.hasOwnProperty(q)&&Z[q]!==ie[q]&&(p||(p={}),p[q]=ie[q])}else p||(_||(_=[]),_.push(ve,p)),p=ie;else ve==="dangerouslySetInnerHTML"?(ie=ie?ie.__html:void 0,Z=Z?Z.__html:void 0,ie!=null&&Z!==ie&&(_=_||[]).push(ve,ie)):ve==="children"?typeof ie!="string"&&typeof ie!="number"||(_=_||[]).push(ve,""+ie):ve!=="suppressContentEditableWarning"&&ve!=="suppressHydrationWarning"&&(a.hasOwnProperty(ve)?(ie!=null&&ve==="onScroll"&&sn("scroll",o),_||Z===ie||(_=[])):(_=_||[]).push(ve,ie))}p&&(_=_||[]).push("style",p);var ve=_;(l.updateQueue=ve)&&(l.flags|=4)}},Nv=function(o,l,p,v){p!==v&&(l.flags|=4)};function Lc(o,l){if(!un)switch(o.tailMode){case"hidden":l=o.tail;for(var p=null;l!==null;)l.alternate!==null&&(p=l),l=l.sibling;p===null?o.tail=null:p.sibling=null;break;case"collapsed":p=o.tail;for(var v=null;p!==null;)p.alternate!==null&&(v=p),p=p.sibling;v===null?l||o.tail===null?o.tail=null:o.tail.sibling=null:v.sibling=null}}function vr(o){var l=o.alternate!==null&&o.alternate.child===o.child,p=0,v=0;if(l)for(var R=o.child;R!==null;)p|=R.lanes|R.childLanes,v|=R.subtreeFlags&14680064,v|=R.flags&14680064,R.return=o,R=R.sibling;else for(R=o.child;R!==null;)p|=R.lanes|R.childLanes,v|=R.subtreeFlags,v|=R.flags,R.return=o,R=R.sibling;return o.subtreeFlags|=v,o.childLanes=p,l}function TT(o,l,p){var v=l.pendingProps;switch($m(l),l.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return vr(l),null;case 1:return qr(l.type)&&Vd(),vr(l),null;case 3:return v=l.stateNode,pl(),an(Wr),an(yr),Um(),v.pendingContext&&(v.context=v.pendingContext,v.pendingContext=null),(o===null||o.child===null)&&(Jd(l)?l.flags|=4:o===null||o.memoizedState.isDehydrated&&(l.flags&256)===0||(l.flags|=1024,Ds!==null&&(bg(Ds),Ds=null))),lg(o,l),vr(l),null;case 5:Wm(l);var R=hi(_c.current);if(p=l.type,o!==null&&l.stateNode!=null)jv(o,l,p,v,R),o.ref!==l.ref&&(l.flags|=512,l.flags|=2097152);else{if(!v){if(l.stateNode===null)throw Error(r(166));return vr(l),null}if(o=hi(oa.current),Jd(l)){v=l.stateNode,p=l.type;var _=l.memoizedProps;switch(v[aa]=l,v[Cc]=_,o=(l.mode&1)!==0,p){case"dialog":sn("cancel",v),sn("close",v);break;case"iframe":case"object":case"embed":sn("load",v);break;case"video":case"audio":for(R=0;R<jc.length;R++)sn(jc[R],v);break;case"source":sn("error",v);break;case"img":case"image":case"link":sn("error",v),sn("load",v);break;case"details":sn("toggle",v);break;case"input":Ne(v,_),sn("invalid",v);break;case"select":v._wrapperState={wasMultiple:!!_.multiple},sn("invalid",v);break;case"textarea":Ce(v,_),sn("invalid",v)}Wt(p,_),R=null;for(var q in _)if(_.hasOwnProperty(q)){var Z=_[q];q==="children"?typeof Z=="string"?v.textContent!==Z&&(_.suppressHydrationWarning!==!0&&zd(v.textContent,Z,o),R=["children",Z]):typeof Z=="number"&&v.textContent!==""+Z&&(_.suppressHydrationWarning!==!0&&zd(v.textContent,Z,o),R=["children",""+Z]):a.hasOwnProperty(q)&&Z!=null&&q==="onScroll"&&sn("scroll",v)}switch(p){case"input":oe(v),be(v,_,!0);break;case"textarea":oe(v),pe(v);break;case"select":case"option":break;default:typeof _.onClick=="function"&&(v.onclick=Kd)}v=R,l.updateQueue=v,v!==null&&(l.flags|=4)}else{q=R.nodeType===9?R:R.ownerDocument,o==="http://www.w3.org/1999/xhtml"&&(o=Qe(p)),o==="http://www.w3.org/1999/xhtml"?p==="script"?(o=q.createElement("div"),o.innerHTML="<script><\/script>",o=o.removeChild(o.firstChild)):typeof v.is=="string"?o=q.createElement(p,{is:v.is}):(o=q.createElement(p),p==="select"&&(q=o,v.multiple?q.multiple=!0:v.size&&(q.size=v.size))):o=q.createElementNS(o,p),o[aa]=l,o[Cc]=v,wv(o,l,!1,!1),l.stateNode=o;e:{switch(q=St(p,v),p){case"dialog":sn("cancel",o),sn("close",o),R=v;break;case"iframe":case"object":case"embed":sn("load",o),R=v;break;case"video":case"audio":for(R=0;R<jc.length;R++)sn(jc[R],o);R=v;break;case"source":sn("error",o),R=v;break;case"img":case"image":case"link":sn("error",o),sn("load",o),R=v;break;case"details":sn("toggle",o),R=v;break;case"input":Ne(o,v),R=le(o,v),sn("invalid",o);break;case"option":R=v;break;case"select":o._wrapperState={wasMultiple:!!v.multiple},R=E({},v,{value:void 0}),sn("invalid",o);break;case"textarea":Ce(o,v),R=se(o,v),sn("invalid",o);break;default:R=v}Wt(p,R),Z=R;for(_ in Z)if(Z.hasOwnProperty(_)){var ie=Z[_];_==="style"?et(o,ie):_==="dangerouslySetInnerHTML"?(ie=ie?ie.__html:void 0,ie!=null&&Je(o,ie)):_==="children"?typeof ie=="string"?(p!=="textarea"||ie!=="")&&Qt(o,ie):typeof ie=="number"&&Qt(o,""+ie):_!=="suppressContentEditableWarning"&&_!=="suppressHydrationWarning"&&_!=="autoFocus"&&(a.hasOwnProperty(_)?ie!=null&&_==="onScroll"&&sn("scroll",o):ie!=null&&I(o,_,ie,q))}switch(p){case"input":oe(o),be(o,v,!1);break;case"textarea":oe(o),pe(o);break;case"option":v.value!=null&&o.setAttribute("value",""+we(v.value));break;case"select":o.multiple=!!v.multiple,_=v.value,_!=null?mt(o,!!v.multiple,_,!1):v.defaultValue!=null&&mt(o,!!v.multiple,v.defaultValue,!0);break;default:typeof R.onClick=="function"&&(o.onclick=Kd)}switch(p){case"button":case"input":case"select":case"textarea":v=!!v.autoFocus;break e;case"img":v=!0;break e;default:v=!1}}v&&(l.flags|=4)}l.ref!==null&&(l.flags|=512,l.flags|=2097152)}return vr(l),null;case 6:if(o&&l.stateNode!=null)Nv(o,l,o.memoizedProps,v);else{if(typeof v!="string"&&l.stateNode===null)throw Error(r(166));if(p=hi(_c.current),hi(oa.current),Jd(l)){if(v=l.stateNode,p=l.memoizedProps,v[aa]=l,(_=v.nodeValue!==p)&&(o=ns,o!==null))switch(o.tag){case 3:zd(v.nodeValue,p,(o.mode&1)!==0);break;case 5:o.memoizedProps.suppressHydrationWarning!==!0&&zd(v.nodeValue,p,(o.mode&1)!==0)}_&&(l.flags|=4)}else v=(p.nodeType===9?p:p.ownerDocument).createTextNode(v),v[aa]=l,l.stateNode=v}return vr(l),null;case 13:if(an(bn),v=l.memoizedState,o===null||o.memoizedState!==null&&o.memoizedState.dehydrated!==null){if(un&&rs!==null&&(l.mode&1)!==0&&(l.flags&128)===0)Rb(),cl(),l.flags|=98560,_=!1;else if(_=Jd(l),v!==null&&v.dehydrated!==null){if(o===null){if(!_)throw Error(r(318));if(_=l.memoizedState,_=_!==null?_.dehydrated:null,!_)throw Error(r(317));_[aa]=l}else cl(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;vr(l),_=!1}else Ds!==null&&(bg(Ds),Ds=null),_=!0;if(!_)return l.flags&65536?l:null}return(l.flags&128)!==0?(l.lanes=p,l):(v=v!==null,v!==(o!==null&&o.memoizedState!==null)&&v&&(l.child.flags|=8192,(l.mode&1)!==0&&(o===null||(bn.current&1)!==0?Hn===0&&(Hn=3):wg())),l.updateQueue!==null&&(l.flags|=4),vr(l),null);case 4:return pl(),lg(o,l),o===null&&Nc(l.stateNode.containerInfo),vr(l),null;case 10:return Lm(l.type._context),vr(l),null;case 17:return qr(l.type)&&Vd(),vr(l),null;case 19:if(an(bn),_=l.memoizedState,_===null)return vr(l),null;if(v=(l.flags&128)!==0,q=_.rendering,q===null)if(v)Lc(_,!1);else{if(Hn!==0||o!==null&&(o.flags&128)!==0)for(o=l.child;o!==null;){if(q=au(o),q!==null){for(l.flags|=128,Lc(_,!1),v=q.updateQueue,v!==null&&(l.updateQueue=v,l.flags|=4),l.subtreeFlags=0,v=p,p=l.child;p!==null;)_=p,o=v,_.flags&=14680066,q=_.alternate,q===null?(_.childLanes=0,_.lanes=o,_.child=null,_.subtreeFlags=0,_.memoizedProps=null,_.memoizedState=null,_.updateQueue=null,_.dependencies=null,_.stateNode=null):(_.childLanes=q.childLanes,_.lanes=q.lanes,_.child=q.child,_.subtreeFlags=0,_.deletions=null,_.memoizedProps=q.memoizedProps,_.memoizedState=q.memoizedState,_.updateQueue=q.updateQueue,_.type=q.type,o=q.dependencies,_.dependencies=o===null?null:{lanes:o.lanes,firstContext:o.firstContext}),p=p.sibling;return nn(bn,bn.current&1|2),l.child}o=o.sibling}_.tail!==null&&Ot()>xl&&(l.flags|=128,v=!0,Lc(_,!1),l.lanes=4194304)}else{if(!v)if(o=au(q),o!==null){if(l.flags|=128,v=!0,p=o.updateQueue,p!==null&&(l.updateQueue=p,l.flags|=4),Lc(_,!0),_.tail===null&&_.tailMode==="hidden"&&!q.alternate&&!un)return vr(l),null}else 2*Ot()-_.renderingStartTime>xl&&p!==1073741824&&(l.flags|=128,v=!0,Lc(_,!1),l.lanes=4194304);_.isBackwards?(q.sibling=l.child,l.child=q):(p=_.last,p!==null?p.sibling=q:l.child=q,_.last=q)}return _.tail!==null?(l=_.tail,_.rendering=l,_.tail=l.sibling,_.renderingStartTime=Ot(),l.sibling=null,p=bn.current,nn(bn,v?p&1|2:p&1),l):(vr(l),null);case 22:case 23:return kg(),v=l.memoizedState!==null,o!==null&&o.memoizedState!==null!==v&&(l.flags|=8192),v&&(l.mode&1)!==0?(ss&1073741824)!==0&&(vr(l),l.subtreeFlags&6&&(l.flags|=8192)):vr(l),null;case 24:return null;case 25:return null}throw Error(r(156,l.tag))}function $T(o,l){switch($m(l),l.tag){case 1:return qr(l.type)&&Vd(),o=l.flags,o&65536?(l.flags=o&-65537|128,l):null;case 3:return pl(),an(Wr),an(yr),Um(),o=l.flags,(o&65536)!==0&&(o&128)===0?(l.flags=o&-65537|128,l):null;case 5:return Wm(l),null;case 13:if(an(bn),o=l.memoizedState,o!==null&&o.dehydrated!==null){if(l.alternate===null)throw Error(r(340));cl()}return o=l.flags,o&65536?(l.flags=o&-65537|128,l):null;case 19:return an(bn),null;case 4:return pl(),null;case 10:return Lm(l.type._context),null;case 22:case 23:return kg(),null;case 24:return null;default:return null}}var mu=!1,kr=!1,_T=typeof WeakSet=="function"?WeakSet:Set,ot=null;function gl(o,l){var p=o.ref;if(p!==null)if(typeof p=="function")try{p(null)}catch(v){jn(o,l,v)}else p.current=null}function cg(o,l,p){try{p()}catch(v){jn(o,l,v)}}var Sv=!1;function PT(o,l){if(km=ar,o=rb(),pm(o)){if("selectionStart"in o)var p={start:o.selectionStart,end:o.selectionEnd};else e:{p=(p=o.ownerDocument)&&p.defaultView||window;var v=p.getSelection&&p.getSelection();if(v&&v.rangeCount!==0){p=v.anchorNode;var R=v.anchorOffset,_=v.focusNode;v=v.focusOffset;try{p.nodeType,_.nodeType}catch{p=null;break e}var q=0,Z=-1,ie=-1,ve=0,Ee=0,Ae=o,Pe=null;t:for(;;){for(var nt;Ae!==p||R!==0&&Ae.nodeType!==3||(Z=q+R),Ae!==_||v!==0&&Ae.nodeType!==3||(ie=q+v),Ae.nodeType===3&&(q+=Ae.nodeValue.length),(nt=Ae.firstChild)!==null;)Pe=Ae,Ae=nt;for(;;){if(Ae===o)break t;if(Pe===p&&++ve===R&&(Z=q),Pe===_&&++Ee===v&&(ie=q),(nt=Ae.nextSibling)!==null)break;Ae=Pe,Pe=Ae.parentNode}Ae=nt}p=Z===-1||ie===-1?null:{start:Z,end:ie}}else p=null}p=p||{start:0,end:0}}else p=null;for(wm={focusedElem:o,selectionRange:p},ar=!1,ot=l;ot!==null;)if(l=ot,o=l.child,(l.subtreeFlags&1028)!==0&&o!==null)o.return=l,ot=o;else for(;ot!==null;){l=ot;try{var it=l.alternate;if((l.flags&1024)!==0)switch(l.tag){case 0:case 11:case 15:break;case 1:if(it!==null){var ht=it.memoizedProps,_n=it.memoizedState,ge=l.stateNode,ce=ge.getSnapshotBeforeUpdate(l.elementType===l.type?ht:Bs(l.type,ht),_n);ge.__reactInternalSnapshotBeforeUpdate=ce}break;case 3:var ye=l.stateNode.containerInfo;ye.nodeType===1?ye.textContent="":ye.nodeType===9&&ye.documentElement&&ye.removeChild(ye.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(r(163))}}catch(Be){jn(l,l.return,Be)}if(o=l.sibling,o!==null){o.return=l.return,ot=o;break}ot=l.return}return it=Sv,Sv=!1,it}function Fc(o,l,p){var v=l.updateQueue;if(v=v!==null?v.lastEffect:null,v!==null){var R=v=v.next;do{if((R.tag&o)===o){var _=R.destroy;R.destroy=void 0,_!==void 0&&cg(l,p,_)}R=R.next}while(R!==v)}}function gu(o,l){if(l=l.updateQueue,l=l!==null?l.lastEffect:null,l!==null){var p=l=l.next;do{if((p.tag&o)===o){var v=p.create;p.destroy=v()}p=p.next}while(p!==l)}}function dg(o){var l=o.ref;if(l!==null){var p=o.stateNode;switch(o.tag){case 5:o=p;break;default:o=p}typeof l=="function"?l(o):l.current=o}}function Cv(o){var l=o.alternate;l!==null&&(o.alternate=null,Cv(l)),o.child=null,o.deletions=null,o.sibling=null,o.tag===5&&(l=o.stateNode,l!==null&&(delete l[aa],delete l[Cc],delete l[Cm],delete l[mT],delete l[gT])),o.stateNode=null,o.return=null,o.dependencies=null,o.memoizedProps=null,o.memoizedState=null,o.pendingProps=null,o.stateNode=null,o.updateQueue=null}function Rv(o){return o.tag===5||o.tag===3||o.tag===4}function Iv(o){e:for(;;){for(;o.sibling===null;){if(o.return===null||Rv(o.return))return null;o=o.return}for(o.sibling.return=o.return,o=o.sibling;o.tag!==5&&o.tag!==6&&o.tag!==18;){if(o.flags&2||o.child===null||o.tag===4)continue e;o.child.return=o,o=o.child}if(!(o.flags&2))return o.stateNode}}function ug(o,l,p){var v=o.tag;if(v===5||v===6)o=o.stateNode,l?p.nodeType===8?p.parentNode.insertBefore(o,l):p.insertBefore(o,l):(p.nodeType===8?(l=p.parentNode,l.insertBefore(o,p)):(l=p,l.appendChild(o)),p=p._reactRootContainer,p!=null||l.onclick!==null||(l.onclick=Kd));else if(v!==4&&(o=o.child,o!==null))for(ug(o,l,p),o=o.sibling;o!==null;)ug(o,l,p),o=o.sibling}function hg(o,l,p){var v=o.tag;if(v===5||v===6)o=o.stateNode,l?p.insertBefore(o,l):p.appendChild(o);else if(v!==4&&(o=o.child,o!==null))for(hg(o,l,p),o=o.sibling;o!==null;)hg(o,l,p),o=o.sibling}var ir=null,Ws=!1;function Co(o,l,p){for(p=p.child;p!==null;)Tv(o,l,p),p=p.sibling}function Tv(o,l,p){if(tn&&typeof tn.onCommitFiberUnmount=="function")try{tn.onCommitFiberUnmount(_r,p)}catch{}switch(p.tag){case 5:kr||gl(p,l);case 6:var v=ir,R=Ws;ir=null,Co(o,l,p),ir=v,Ws=R,ir!==null&&(Ws?(o=ir,p=p.stateNode,o.nodeType===8?o.parentNode.removeChild(p):o.removeChild(p)):ir.removeChild(p.stateNode));break;case 18:ir!==null&&(Ws?(o=ir,p=p.stateNode,o.nodeType===8?Sm(o.parentNode,p):o.nodeType===1&&Sm(o,p),sr(o)):Sm(ir,p.stateNode));break;case 4:v=ir,R=Ws,ir=p.stateNode.containerInfo,Ws=!0,Co(o,l,p),ir=v,Ws=R;break;case 0:case 11:case 14:case 15:if(!kr&&(v=p.updateQueue,v!==null&&(v=v.lastEffect,v!==null))){R=v=v.next;do{var _=R,q=_.destroy;_=_.tag,q!==void 0&&((_&2)!==0||(_&4)!==0)&&cg(p,l,q),R=R.next}while(R!==v)}Co(o,l,p);break;case 1:if(!kr&&(gl(p,l),v=p.stateNode,typeof v.componentWillUnmount=="function"))try{v.props=p.memoizedProps,v.state=p.memoizedState,v.componentWillUnmount()}catch(Z){jn(p,l,Z)}Co(o,l,p);break;case 21:Co(o,l,p);break;case 22:p.mode&1?(kr=(v=kr)||p.memoizedState!==null,Co(o,l,p),kr=v):Co(o,l,p);break;default:Co(o,l,p)}}function $v(o){var l=o.updateQueue;if(l!==null){o.updateQueue=null;var p=o.stateNode;p===null&&(p=o.stateNode=new _T),l.forEach(function(v){var R=WT.bind(null,o,v);p.has(v)||(p.add(v),v.then(R,R))})}}function qs(o,l){var p=l.deletions;if(p!==null)for(var v=0;v<p.length;v++){var R=p[v];try{var _=o,q=l,Z=q;e:for(;Z!==null;){switch(Z.tag){case 5:ir=Z.stateNode,Ws=!1;break e;case 3:ir=Z.stateNode.containerInfo,Ws=!0;break e;case 4:ir=Z.stateNode.containerInfo,Ws=!0;break e}Z=Z.return}if(ir===null)throw Error(r(160));Tv(_,q,R),ir=null,Ws=!1;var ie=R.alternate;ie!==null&&(ie.return=null),R.return=null}catch(ve){jn(R,l,ve)}}if(l.subtreeFlags&12854)for(l=l.child;l!==null;)_v(l,o),l=l.sibling}function _v(o,l){var p=o.alternate,v=o.flags;switch(o.tag){case 0:case 11:case 14:case 15:if(qs(l,o),la(o),v&4){try{Fc(3,o,o.return),gu(3,o)}catch(ht){jn(o,o.return,ht)}try{Fc(5,o,o.return)}catch(ht){jn(o,o.return,ht)}}break;case 1:qs(l,o),la(o),v&512&&p!==null&&gl(p,p.return);break;case 5:if(qs(l,o),la(o),v&512&&p!==null&&gl(p,p.return),o.flags&32){var R=o.stateNode;try{Qt(R,"")}catch(ht){jn(o,o.return,ht)}}if(v&4&&(R=o.stateNode,R!=null)){var _=o.memoizedProps,q=p!==null?p.memoizedProps:_,Z=o.type,ie=o.updateQueue;if(o.updateQueue=null,ie!==null)try{Z==="input"&&_.type==="radio"&&_.name!=null&&Ve(R,_),St(Z,q);var ve=St(Z,_);for(q=0;q<ie.length;q+=2){var Ee=ie[q],Ae=ie[q+1];Ee==="style"?et(R,Ae):Ee==="dangerouslySetInnerHTML"?Je(R,Ae):Ee==="children"?Qt(R,Ae):I(R,Ee,Ae,ve)}switch(Z){case"input":me(R,_);break;case"textarea":_e(R,_);break;case"select":var Pe=R._wrapperState.wasMultiple;R._wrapperState.wasMultiple=!!_.multiple;var nt=_.value;nt!=null?mt(R,!!_.multiple,nt,!1):Pe!==!!_.multiple&&(_.defaultValue!=null?mt(R,!!_.multiple,_.defaultValue,!0):mt(R,!!_.multiple,_.multiple?[]:"",!1))}R[Cc]=_}catch(ht){jn(o,o.return,ht)}}break;case 6:if(qs(l,o),la(o),v&4){if(o.stateNode===null)throw Error(r(162));R=o.stateNode,_=o.memoizedProps;try{R.nodeValue=_}catch(ht){jn(o,o.return,ht)}}break;case 3:if(qs(l,o),la(o),v&4&&p!==null&&p.memoizedState.isDehydrated)try{sr(l.containerInfo)}catch(ht){jn(o,o.return,ht)}break;case 4:qs(l,o),la(o);break;case 13:qs(l,o),la(o),R=o.child,R.flags&8192&&(_=R.memoizedState!==null,R.stateNode.isHidden=_,!_||R.alternate!==null&&R.alternate.memoizedState!==null||(gg=Ot())),v&4&&$v(o);break;case 22:if(Ee=p!==null&&p.memoizedState!==null,o.mode&1?(kr=(ve=kr)||Ee,qs(l,o),kr=ve):qs(l,o),la(o),v&8192){if(ve=o.memoizedState!==null,(o.stateNode.isHidden=ve)&&!Ee&&(o.mode&1)!==0)for(ot=o,Ee=o.child;Ee!==null;){for(Ae=ot=Ee;ot!==null;){switch(Pe=ot,nt=Pe.child,Pe.tag){case 0:case 11:case 14:case 15:Fc(4,Pe,Pe.return);break;case 1:gl(Pe,Pe.return);var it=Pe.stateNode;if(typeof it.componentWillUnmount=="function"){v=Pe,p=Pe.return;try{l=v,it.props=l.memoizedProps,it.state=l.memoizedState,it.componentWillUnmount()}catch(ht){jn(v,p,ht)}}break;case 5:gl(Pe,Pe.return);break;case 22:if(Pe.memoizedState!==null){Av(Ae);continue}}nt!==null?(nt.return=Pe,ot=nt):Av(Ae)}Ee=Ee.sibling}e:for(Ee=null,Ae=o;;){if(Ae.tag===5){if(Ee===null){Ee=Ae;try{R=Ae.stateNode,ve?(_=R.style,typeof _.setProperty=="function"?_.setProperty("display","none","important"):_.display="none"):(Z=Ae.stateNode,ie=Ae.memoizedProps.style,q=ie!=null&&ie.hasOwnProperty("display")?ie.display:null,Z.style.display=rt("display",q))}catch(ht){jn(o,o.return,ht)}}}else if(Ae.tag===6){if(Ee===null)try{Ae.stateNode.nodeValue=ve?"":Ae.memoizedProps}catch(ht){jn(o,o.return,ht)}}else if((Ae.tag!==22&&Ae.tag!==23||Ae.memoizedState===null||Ae===o)&&Ae.child!==null){Ae.child.return=Ae,Ae=Ae.child;continue}if(Ae===o)break e;for(;Ae.sibling===null;){if(Ae.return===null||Ae.return===o)break e;Ee===Ae&&(Ee=null),Ae=Ae.return}Ee===Ae&&(Ee=null),Ae.sibling.return=Ae.return,Ae=Ae.sibling}}break;case 19:qs(l,o),la(o),v&4&&$v(o);break;case 21:break;default:qs(l,o),la(o)}}function la(o){var l=o.flags;if(l&2){try{e:{for(var p=o.return;p!==null;){if(Rv(p)){var v=p;break e}p=p.return}throw Error(r(160))}switch(v.tag){case 5:var R=v.stateNode;v.flags&32&&(Qt(R,""),v.flags&=-33);var _=Iv(o);hg(o,_,R);break;case 3:case 4:var q=v.stateNode.containerInfo,Z=Iv(o);ug(o,Z,q);break;default:throw Error(r(161))}}catch(ie){jn(o,o.return,ie)}o.flags&=-3}l&4096&&(o.flags&=-4097)}function ET(o,l,p){ot=o,Pv(o)}function Pv(o,l,p){for(var v=(o.mode&1)!==0;ot!==null;){var R=ot,_=R.child;if(R.tag===22&&v){var q=R.memoizedState!==null||mu;if(!q){var Z=R.alternate,ie=Z!==null&&Z.memoizedState!==null||kr;Z=mu;var ve=kr;if(mu=q,(kr=ie)&&!ve)for(ot=R;ot!==null;)q=ot,ie=q.child,q.tag===22&&q.memoizedState!==null?Mv(R):ie!==null?(ie.return=q,ot=ie):Mv(R);for(;_!==null;)ot=_,Pv(_),_=_.sibling;ot=R,mu=Z,kr=ve}Ev(o)}else(R.subtreeFlags&8772)!==0&&_!==null?(_.return=R,ot=_):Ev(o)}}function Ev(o){for(;ot!==null;){var l=ot;if((l.flags&8772)!==0){var p=l.alternate;try{if((l.flags&8772)!==0)switch(l.tag){case 0:case 11:case 15:kr||gu(5,l);break;case 1:var v=l.stateNode;if(l.flags&4&&!kr)if(p===null)v.componentDidMount();else{var R=l.elementType===l.type?p.memoizedProps:Bs(l.type,p.memoizedProps);v.componentDidUpdate(R,p.memoizedState,v.__reactInternalSnapshotBeforeUpdate)}var _=l.updateQueue;_!==null&&Ab(l,_,v);break;case 3:var q=l.updateQueue;if(q!==null){if(p=null,l.child!==null)switch(l.child.tag){case 5:p=l.child.stateNode;break;case 1:p=l.child.stateNode}Ab(l,q,p)}break;case 5:var Z=l.stateNode;if(p===null&&l.flags&4){p=Z;var ie=l.memoizedProps;switch(l.type){case"button":case"input":case"select":case"textarea":ie.autoFocus&&p.focus();break;case"img":ie.src&&(p.src=ie.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(l.memoizedState===null){var ve=l.alternate;if(ve!==null){var Ee=ve.memoizedState;if(Ee!==null){var Ae=Ee.dehydrated;Ae!==null&&sr(Ae)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(r(163))}kr||l.flags&512&&dg(l)}catch(Pe){jn(l,l.return,Pe)}}if(l===o){ot=null;break}if(p=l.sibling,p!==null){p.return=l.return,ot=p;break}ot=l.return}}function Av(o){for(;ot!==null;){var l=ot;if(l===o){ot=null;break}var p=l.sibling;if(p!==null){p.return=l.return,ot=p;break}ot=l.return}}function Mv(o){for(;ot!==null;){var l=ot;try{switch(l.tag){case 0:case 11:case 15:var p=l.return;try{gu(4,l)}catch(ie){jn(l,p,ie)}break;case 1:var v=l.stateNode;if(typeof v.componentDidMount=="function"){var R=l.return;try{v.componentDidMount()}catch(ie){jn(l,R,ie)}}var _=l.return;try{dg(l)}catch(ie){jn(l,_,ie)}break;case 5:var q=l.return;try{dg(l)}catch(ie){jn(l,q,ie)}}}catch(ie){jn(l,l.return,ie)}if(l===o){ot=null;break}var Z=l.sibling;if(Z!==null){Z.return=l.return,ot=Z;break}ot=l.return}}var AT=Math.ceil,fu=S.ReactCurrentDispatcher,pg=S.ReactCurrentOwner,js=S.ReactCurrentBatchConfig,Ut=0,Jn=null,On=null,lr=0,ss=0,fl=ko(0),Hn=0,Oc=null,mi=0,xu=0,mg=0,Dc=null,Hr=null,gg=0,xl=1/0,Ua=null,yu=!1,fg=null,Ro=null,bu=!1,Io=null,vu=0,Bc=0,xg=null,ku=-1,wu=0;function Ar(){return(Ut&6)!==0?Ot():ku!==-1?ku:ku=Ot()}function To(o){return(o.mode&1)===0?1:(Ut&2)!==0&&lr!==0?lr&-lr:xT.transition!==null?(wu===0&&(wu=Aa()),wu):(o=de,o!==0||(o=window.event,o=o===void 0?16:or(o.type)),o)}function Us(o,l,p,v){if(50<Bc)throw Bc=0,xg=null,Error(r(185));ta(o,p,v),((Ut&2)===0||o!==Jn)&&(o===Jn&&((Ut&2)===0&&(xu|=p),Hn===4&&$o(o,lr)),zr(o,v),p===1&&Ut===0&&(l.mode&1)===0&&(xl=Ot()+500,Yd&&jo()))}function zr(o,l){var p=o.callbackNode;go(o,l);var v=xs(o,o===Jn?lr:0);if(v===0)p!==null&&Jr(p),o.callbackNode=null,o.callbackPriority=0;else if(l=v&-v,o.callbackPriority!==l){if(p!=null&&Jr(p),l===1)o.tag===0?fT(Fv.bind(null,o)):wb(Fv.bind(null,o)),hT(function(){(Ut&6)===0&&jo()}),p=null;else{switch(ke(v)){case 1:p=en;break;case 4:p=Ia;break;case 16:p=$r;break;case 536870912:p=Js;break;default:p=$r}p=zv(p,Lv.bind(null,o))}o.callbackPriority=l,o.callbackNode=p}}function Lv(o,l){if(ku=-1,wu=0,(Ut&6)!==0)throw Error(r(327));var p=o.callbackNode;if(yl()&&o.callbackNode!==p)return null;var v=xs(o,o===Jn?lr:0);if(v===0)return null;if((v&30)!==0||(v&o.expiredLanes)!==0||l)l=ju(o,v);else{l=v;var R=Ut;Ut|=2;var _=Dv();(Jn!==o||lr!==l)&&(Ua=null,xl=Ot()+500,fi(o,l));do try{FT();break}catch(Z){Ov(o,Z)}while(!0);Mm(),fu.current=_,Ut=R,On!==null?l=0:(Jn=null,lr=0,l=Hn)}if(l!==0){if(l===2&&(R=fo(o),R!==0&&(v=R,l=yg(o,R))),l===1)throw p=Oc,fi(o,0),$o(o,v),zr(o,Ot()),p;if(l===6)$o(o,v);else{if(R=o.current.alternate,(v&30)===0&&!MT(R)&&(l=ju(o,v),l===2&&(_=fo(o),_!==0&&(v=_,l=yg(o,_))),l===1))throw p=Oc,fi(o,0),$o(o,v),zr(o,Ot()),p;switch(o.finishedWork=R,o.finishedLanes=v,l){case 0:case 1:throw Error(r(345));case 2:xi(o,Hr,Ua);break;case 3:if($o(o,v),(v&130023424)===v&&(l=gg+500-Ot(),10<l)){if(xs(o,0)!==0)break;if(R=o.suspendedLanes,(R&v)!==v){Ar(),o.pingedLanes|=o.suspendedLanes&R;break}o.timeoutHandle=Nm(xi.bind(null,o,Hr,Ua),l);break}xi(o,Hr,Ua);break;case 4:if($o(o,v),(v&4194240)===v)break;for(l=o.eventTimes,R=-1;0<v;){var q=31-Gt(v);_=1<<q,q=l[q],q>R&&(R=q),v&=~_}if(v=R,v=Ot()-v,v=(120>v?120:480>v?480:1080>v?1080:1920>v?1920:3e3>v?3e3:4320>v?4320:1960*AT(v/1960))-v,10<v){o.timeoutHandle=Nm(xi.bind(null,o,Hr,Ua),v);break}xi(o,Hr,Ua);break;case 5:xi(o,Hr,Ua);break;default:throw Error(r(329))}}}return zr(o,Ot()),o.callbackNode===p?Lv.bind(null,o):null}function yg(o,l){var p=Dc;return o.current.memoizedState.isDehydrated&&(fi(o,l).flags|=256),o=ju(o,l),o!==2&&(l=Hr,Hr=p,l!==null&&bg(l)),o}function bg(o){Hr===null?Hr=o:Hr.push.apply(Hr,o)}function MT(o){for(var l=o;;){if(l.flags&16384){var p=l.updateQueue;if(p!==null&&(p=p.stores,p!==null))for(var v=0;v<p.length;v++){var R=p[v],_=R.getSnapshot;R=R.value;try{if(!Os(_(),R))return!1}catch{return!1}}}if(p=l.child,l.subtreeFlags&16384&&p!==null)p.return=l,l=p;else{if(l===o)break;for(;l.sibling===null;){if(l.return===null||l.return===o)return!0;l=l.return}l.sibling.return=l.return,l=l.sibling}}return!0}function $o(o,l){for(l&=~mg,l&=~xu,o.suspendedLanes|=l,o.pingedLanes&=~l,o=o.expirationTimes;0<l;){var p=31-Gt(l),v=1<<p;o[p]=-1,l&=~v}}function Fv(o){if((Ut&6)!==0)throw Error(r(327));yl();var l=xs(o,0);if((l&1)===0)return zr(o,Ot()),null;var p=ju(o,l);if(o.tag!==0&&p===2){var v=fo(o);v!==0&&(l=v,p=yg(o,v))}if(p===1)throw p=Oc,fi(o,0),$o(o,l),zr(o,Ot()),p;if(p===6)throw Error(r(345));return o.finishedWork=o.current.alternate,o.finishedLanes=l,xi(o,Hr,Ua),zr(o,Ot()),null}function vg(o,l){var p=Ut;Ut|=1;try{return o(l)}finally{Ut=p,Ut===0&&(xl=Ot()+500,Yd&&jo())}}function gi(o){Io!==null&&Io.tag===0&&(Ut&6)===0&&yl();var l=Ut;Ut|=1;var p=js.transition,v=de;try{if(js.transition=null,de=1,o)return o()}finally{de=v,js.transition=p,Ut=l,(Ut&6)===0&&jo()}}function kg(){ss=fl.current,an(fl)}function fi(o,l){o.finishedWork=null,o.finishedLanes=0;var p=o.timeoutHandle;if(p!==-1&&(o.timeoutHandle=-1,uT(p)),On!==null)for(p=On.return;p!==null;){var v=p;switch($m(v),v.tag){case 1:v=v.type.childContextTypes,v!=null&&Vd();break;case 3:pl(),an(Wr),an(yr),Um();break;case 5:Wm(v);break;case 4:pl();break;case 13:an(bn);break;case 19:an(bn);break;case 10:Lm(v.type._context);break;case 22:case 23:kg()}p=p.return}if(Jn=o,On=o=_o(o.current,null),lr=ss=l,Hn=0,Oc=null,mg=xu=mi=0,Hr=Dc=null,ui!==null){for(l=0;l<ui.length;l++)if(p=ui[l],v=p.interleaved,v!==null){p.interleaved=null;var R=v.next,_=p.pending;if(_!==null){var q=_.next;_.next=R,v.next=q}p.pending=v}ui=null}return o}function Ov(o,l){do{var p=On;try{if(Mm(),ou.current=du,iu){for(var v=vn.memoizedState;v!==null;){var R=v.queue;R!==null&&(R.pending=null),v=v.next}iu=!1}if(pi=0,Zn=Un=vn=null,Pc=!1,Ec=0,pg.current=null,p===null||p.return===null){Hn=1,Oc=l,On=null;break}e:{var _=o,q=p.return,Z=p,ie=l;if(l=lr,Z.flags|=32768,ie!==null&&typeof ie=="object"&&typeof ie.then=="function"){var ve=ie,Ee=Z,Ae=Ee.tag;if((Ee.mode&1)===0&&(Ae===0||Ae===11||Ae===15)){var Pe=Ee.alternate;Pe?(Ee.updateQueue=Pe.updateQueue,Ee.memoizedState=Pe.memoizedState,Ee.lanes=Pe.lanes):(Ee.updateQueue=null,Ee.memoizedState=null)}var nt=cv(q);if(nt!==null){nt.flags&=-257,dv(nt,q,Z,_,l),nt.mode&1&&lv(_,ve,l),l=nt,ie=ve;var it=l.updateQueue;if(it===null){var ht=new Set;ht.add(ie),l.updateQueue=ht}else it.add(ie);break e}else{if((l&1)===0){lv(_,ve,l),wg();break e}ie=Error(r(426))}}else if(un&&Z.mode&1){var _n=cv(q);if(_n!==null){(_n.flags&65536)===0&&(_n.flags|=256),dv(_n,q,Z,_,l),Em(ml(ie,Z));break e}}_=ie=ml(ie,Z),Hn!==4&&(Hn=2),Dc===null?Dc=[_]:Dc.push(_),_=q;do{switch(_.tag){case 3:_.flags|=65536,l&=-l,_.lanes|=l;var ge=ov(_,ie,l);Eb(_,ge);break e;case 1:Z=ie;var ce=_.type,ye=_.stateNode;if((_.flags&128)===0&&(typeof ce.getDerivedStateFromError=="function"||ye!==null&&typeof ye.componentDidCatch=="function"&&(Ro===null||!Ro.has(ye)))){_.flags|=65536,l&=-l,_.lanes|=l;var Be=iv(_,Z,l);Eb(_,Be);break e}}_=_.return}while(_!==null)}Wv(p)}catch(gt){l=gt,On===p&&p!==null&&(On=p=p.return);continue}break}while(!0)}function Dv(){var o=fu.current;return fu.current=du,o===null?du:o}function wg(){(Hn===0||Hn===3||Hn===2)&&(Hn=4),Jn===null||(mi&268435455)===0&&(xu&268435455)===0||$o(Jn,lr)}function ju(o,l){var p=Ut;Ut|=2;var v=Dv();(Jn!==o||lr!==l)&&(Ua=null,fi(o,l));do try{LT();break}catch(R){Ov(o,R)}while(!0);if(Mm(),Ut=p,fu.current=v,On!==null)throw Error(r(261));return Jn=null,lr=0,Hn}function LT(){for(;On!==null;)Bv(On)}function FT(){for(;On!==null&&!Ls();)Bv(On)}function Bv(o){var l=Hv(o.alternate,o,ss);o.memoizedProps=o.pendingProps,l===null?Wv(o):On=l,pg.current=null}function Wv(o){var l=o;do{var p=l.alternate;if(o=l.return,(l.flags&32768)===0){if(p=TT(p,l,ss),p!==null){On=p;return}}else{if(p=$T(p,l),p!==null){p.flags&=32767,On=p;return}if(o!==null)o.flags|=32768,o.subtreeFlags=0,o.deletions=null;else{Hn=6,On=null;return}}if(l=l.sibling,l!==null){On=l;return}On=l=o}while(l!==null);Hn===0&&(Hn=5)}function xi(o,l,p){var v=de,R=js.transition;try{js.transition=null,de=1,OT(o,l,p,v)}finally{js.transition=R,de=v}return null}function OT(o,l,p,v){do yl();while(Io!==null);if((Ut&6)!==0)throw Error(r(327));p=o.finishedWork;var R=o.finishedLanes;if(p===null)return null;if(o.finishedWork=null,o.finishedLanes=0,p===o.current)throw Error(r(177));o.callbackNode=null,o.callbackPriority=0;var _=p.lanes|p.childLanes;if(Vi(o,_),o===Jn&&(On=Jn=null,lr=0),(p.subtreeFlags&2064)===0&&(p.flags&2064)===0||bu||(bu=!0,zv($r,function(){return yl(),null})),_=(p.flags&15990)!==0,(p.subtreeFlags&15990)!==0||_){_=js.transition,js.transition=null;var q=de;de=1;var Z=Ut;Ut|=4,pg.current=null,PT(o,p),_v(p,o),sT(wm),ar=!!km,wm=km=null,o.current=p,ET(p),gs(),Ut=Z,de=q,js.transition=_}else o.current=p;if(bu&&(bu=!1,Io=o,vu=R),_=o.pendingLanes,_===0&&(Ro=null),$a(p.stateNode),zr(o,Ot()),l!==null)for(v=o.onRecoverableError,p=0;p<l.length;p++)R=l[p],v(R.value,{componentStack:R.stack,digest:R.digest});if(yu)throw yu=!1,o=fg,fg=null,o;return(vu&1)!==0&&o.tag!==0&&yl(),_=o.pendingLanes,(_&1)!==0?o===xg?Bc++:(Bc=0,xg=o):Bc=0,jo(),null}function yl(){if(Io!==null){var o=ke(vu),l=js.transition,p=de;try{if(js.transition=null,de=16>o?16:o,Io===null)var v=!1;else{if(o=Io,Io=null,vu=0,(Ut&6)!==0)throw Error(r(331));var R=Ut;for(Ut|=4,ot=o.current;ot!==null;){var _=ot,q=_.child;if((ot.flags&16)!==0){var Z=_.deletions;if(Z!==null){for(var ie=0;ie<Z.length;ie++){var ve=Z[ie];for(ot=ve;ot!==null;){var Ee=ot;switch(Ee.tag){case 0:case 11:case 15:Fc(8,Ee,_)}var Ae=Ee.child;if(Ae!==null)Ae.return=Ee,ot=Ae;else for(;ot!==null;){Ee=ot;var Pe=Ee.sibling,nt=Ee.return;if(Cv(Ee),Ee===ve){ot=null;break}if(Pe!==null){Pe.return=nt,ot=Pe;break}ot=nt}}}var it=_.alternate;if(it!==null){var ht=it.child;if(ht!==null){it.child=null;do{var _n=ht.sibling;ht.sibling=null,ht=_n}while(ht!==null)}}ot=_}}if((_.subtreeFlags&2064)!==0&&q!==null)q.return=_,ot=q;else e:for(;ot!==null;){if(_=ot,(_.flags&2048)!==0)switch(_.tag){case 0:case 11:case 15:Fc(9,_,_.return)}var ge=_.sibling;if(ge!==null){ge.return=_.return,ot=ge;break e}ot=_.return}}var ce=o.current;for(ot=ce;ot!==null;){q=ot;var ye=q.child;if((q.subtreeFlags&2064)!==0&&ye!==null)ye.return=q,ot=ye;else e:for(q=ce;ot!==null;){if(Z=ot,(Z.flags&2048)!==0)try{switch(Z.tag){case 0:case 11:case 15:gu(9,Z)}}catch(gt){jn(Z,Z.return,gt)}if(Z===q){ot=null;break e}var Be=Z.sibling;if(Be!==null){Be.return=Z.return,ot=Be;break e}ot=Z.return}}if(Ut=R,jo(),tn&&typeof tn.onPostCommitFiberRoot=="function")try{tn.onPostCommitFiberRoot(_r,o)}catch{}v=!0}return v}finally{de=p,js.transition=l}}return!1}function qv(o,l,p){l=ml(p,l),l=ov(o,l,1),o=So(o,l,1),l=Ar(),o!==null&&(ta(o,1,l),zr(o,l))}function jn(o,l,p){if(o.tag===3)qv(o,o,p);else for(;l!==null;){if(l.tag===3){qv(l,o,p);break}else if(l.tag===1){var v=l.stateNode;if(typeof l.type.getDerivedStateFromError=="function"||typeof v.componentDidCatch=="function"&&(Ro===null||!Ro.has(v))){o=ml(p,o),o=iv(l,o,1),l=So(l,o,1),o=Ar(),l!==null&&(ta(l,1,o),zr(l,o));break}}l=l.return}}function DT(o,l,p){var v=o.pingCache;v!==null&&v.delete(l),l=Ar(),o.pingedLanes|=o.suspendedLanes&p,Jn===o&&(lr&p)===p&&(Hn===4||Hn===3&&(lr&130023424)===lr&&500>Ot()-gg?fi(o,0):mg|=p),zr(o,l)}function Uv(o,l){l===0&&((o.mode&1)===0?l=1:(l=Ea,Ea<<=1,(Ea&130023424)===0&&(Ea=4194304)));var p=Ar();o=Ba(o,l),o!==null&&(ta(o,l,p),zr(o,p))}function BT(o){var l=o.memoizedState,p=0;l!==null&&(p=l.retryLane),Uv(o,p)}function WT(o,l){var p=0;switch(o.tag){case 13:var v=o.stateNode,R=o.memoizedState;R!==null&&(p=R.retryLane);break;case 19:v=o.stateNode;break;default:throw Error(r(314))}v!==null&&v.delete(l),Uv(o,p)}var Hv;Hv=function(o,l,p){if(o!==null)if(o.memoizedProps!==l.pendingProps||Wr.current)Ur=!0;else{if((o.lanes&p)===0&&(l.flags&128)===0)return Ur=!1,IT(o,l,p);Ur=(o.flags&131072)!==0}else Ur=!1,un&&(l.flags&1048576)!==0&&jb(l,Zd,l.index);switch(l.lanes=0,l.tag){case 2:var v=l.type;pu(o,l),o=l.pendingProps;var R=ol(l,yr.current);hl(l,p),R=Km(null,l,v,o,R,p);var _=Gm();return l.flags|=1,typeof R=="object"&&R!==null&&typeof R.render=="function"&&R.$$typeof===void 0?(l.tag=1,l.memoizedState=null,l.updateQueue=null,qr(v)?(_=!0,Qd(l)):_=!1,l.memoizedState=R.state!==null&&R.state!==void 0?R.state:null,Dm(l),R.updater=uu,l.stateNode=R,R._reactInternals=l,Jm(l,v,o,p),l=rg(null,l,v,!0,_,p)):(l.tag=0,un&&_&&Tm(l),Er(null,l,R,p),l=l.child),l;case 16:v=l.elementType;e:{switch(pu(o,l),o=l.pendingProps,R=v._init,v=R(v._payload),l.type=v,R=l.tag=UT(v),o=Bs(v,o),R){case 0:l=ng(null,l,v,o,p);break e;case 1:l=fv(null,l,v,o,p);break e;case 11:l=uv(null,l,v,o,p);break e;case 14:l=hv(null,l,v,Bs(v.type,o),p);break e}throw Error(r(306,v,""))}return l;case 0:return v=l.type,R=l.pendingProps,R=l.elementType===v?R:Bs(v,R),ng(o,l,v,R,p);case 1:return v=l.type,R=l.pendingProps,R=l.elementType===v?R:Bs(v,R),fv(o,l,v,R,p);case 3:e:{if(xv(l),o===null)throw Error(r(387));v=l.pendingProps,_=l.memoizedState,R=_.element,Pb(o,l),su(l,v,null,p);var q=l.memoizedState;if(v=q.element,_.isDehydrated)if(_={element:v,isDehydrated:!1,cache:q.cache,pendingSuspenseBoundaries:q.pendingSuspenseBoundaries,transitions:q.transitions},l.updateQueue.baseState=_,l.memoizedState=_,l.flags&256){R=ml(Error(r(423)),l),l=yv(o,l,v,p,R);break e}else if(v!==R){R=ml(Error(r(424)),l),l=yv(o,l,v,p,R);break e}else for(rs=vo(l.stateNode.containerInfo.firstChild),ns=l,un=!0,Ds=null,p=$b(l,null,v,p),l.child=p;p;)p.flags=p.flags&-3|4096,p=p.sibling;else{if(cl(),v===R){l=qa(o,l,p);break e}Er(o,l,v,p)}l=l.child}return l;case 5:return Mb(l),o===null&&Pm(l),v=l.type,R=l.pendingProps,_=o!==null?o.memoizedProps:null,q=R.children,jm(v,R)?q=null:_!==null&&jm(v,_)&&(l.flags|=32),gv(o,l),Er(o,l,q,p),l.child;case 6:return o===null&&Pm(l),null;case 13:return bv(o,l,p);case 4:return Bm(l,l.stateNode.containerInfo),v=l.pendingProps,o===null?l.child=dl(l,null,v,p):Er(o,l,v,p),l.child;case 11:return v=l.type,R=l.pendingProps,R=l.elementType===v?R:Bs(v,R),uv(o,l,v,R,p);case 7:return Er(o,l,l.pendingProps,p),l.child;case 8:return Er(o,l,l.pendingProps.children,p),l.child;case 12:return Er(o,l,l.pendingProps.children,p),l.child;case 10:e:{if(v=l.type._context,R=l.pendingProps,_=l.memoizedProps,q=R.value,nn(tu,v._currentValue),v._currentValue=q,_!==null)if(Os(_.value,q)){if(_.children===R.children&&!Wr.current){l=qa(o,l,p);break e}}else for(_=l.child,_!==null&&(_.return=l);_!==null;){var Z=_.dependencies;if(Z!==null){q=_.child;for(var ie=Z.firstContext;ie!==null;){if(ie.context===v){if(_.tag===1){ie=Wa(-1,p&-p),ie.tag=2;var ve=_.updateQueue;if(ve!==null){ve=ve.shared;var Ee=ve.pending;Ee===null?ie.next=ie:(ie.next=Ee.next,Ee.next=ie),ve.pending=ie}}_.lanes|=p,ie=_.alternate,ie!==null&&(ie.lanes|=p),Fm(_.return,p,l),Z.lanes|=p;break}ie=ie.next}}else if(_.tag===10)q=_.type===l.type?null:_.child;else if(_.tag===18){if(q=_.return,q===null)throw Error(r(341));q.lanes|=p,Z=q.alternate,Z!==null&&(Z.lanes|=p),Fm(q,p,l),q=_.sibling}else q=_.child;if(q!==null)q.return=_;else for(q=_;q!==null;){if(q===l){q=null;break}if(_=q.sibling,_!==null){_.return=q.return,q=_;break}q=q.return}_=q}Er(o,l,R.children,p),l=l.child}return l;case 9:return R=l.type,v=l.pendingProps.children,hl(l,p),R=ks(R),v=v(R),l.flags|=1,Er(o,l,v,p),l.child;case 14:return v=l.type,R=Bs(v,l.pendingProps),R=Bs(v.type,R),hv(o,l,v,R,p);case 15:return pv(o,l,l.type,l.pendingProps,p);case 17:return v=l.type,R=l.pendingProps,R=l.elementType===v?R:Bs(v,R),pu(o,l),l.tag=1,qr(v)?(o=!0,Qd(l)):o=!1,hl(l,p),sv(l,v,R),Jm(l,v,R,p),rg(null,l,v,!0,o,p);case 19:return kv(o,l,p);case 22:return mv(o,l,p)}throw Error(r(156,l.tag))};function zv(o,l){return mo(o,l)}function qT(o,l,p,v){this.tag=o,this.key=p,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=l,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=v,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Ns(o,l,p,v){return new qT(o,l,p,v)}function jg(o){return o=o.prototype,!(!o||!o.isReactComponent)}function UT(o){if(typeof o=="function")return jg(o)?1:0;if(o!=null){if(o=o.$$typeof,o===D)return 11;if(o===z)return 14}return 2}function _o(o,l){var p=o.alternate;return p===null?(p=Ns(o.tag,l,o.key,o.mode),p.elementType=o.elementType,p.type=o.type,p.stateNode=o.stateNode,p.alternate=o,o.alternate=p):(p.pendingProps=l,p.type=o.type,p.flags=0,p.subtreeFlags=0,p.deletions=null),p.flags=o.flags&14680064,p.childLanes=o.childLanes,p.lanes=o.lanes,p.child=o.child,p.memoizedProps=o.memoizedProps,p.memoizedState=o.memoizedState,p.updateQueue=o.updateQueue,l=o.dependencies,p.dependencies=l===null?null:{lanes:l.lanes,firstContext:l.firstContext},p.sibling=o.sibling,p.index=o.index,p.ref=o.ref,p}function Nu(o,l,p,v,R,_){var q=2;if(v=o,typeof o=="function")jg(o)&&(q=1);else if(typeof o=="string")q=5;else e:switch(o){case P:return yi(p.children,R,_,l);case C:q=8,R|=8;break;case L:return o=Ns(12,p,l,R|2),o.elementType=L,o.lanes=_,o;case A:return o=Ns(13,p,l,R),o.elementType=A,o.lanes=_,o;case W:return o=Ns(19,p,l,R),o.elementType=W,o.lanes=_,o;case H:return Su(p,R,_,l);default:if(typeof o=="object"&&o!==null)switch(o.$$typeof){case F:q=10;break e;case M:q=9;break e;case D:q=11;break e;case z:q=14;break e;case te:q=16,v=null;break e}throw Error(r(130,o==null?o:typeof o,""))}return l=Ns(q,p,l,R),l.elementType=o,l.type=v,l.lanes=_,l}function yi(o,l,p,v){return o=Ns(7,o,v,l),o.lanes=p,o}function Su(o,l,p,v){return o=Ns(22,o,v,l),o.elementType=H,o.lanes=p,o.stateNode={isHidden:!1},o}function Ng(o,l,p){return o=Ns(6,o,null,l),o.lanes=p,o}function Sg(o,l,p){return l=Ns(4,o.children!==null?o.children:[],o.key,l),l.lanes=p,l.stateNode={containerInfo:o.containerInfo,pendingChildren:null,implementation:o.implementation},l}function HT(o,l,p,v,R){this.tag=l,this.containerInfo=o,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=xo(0),this.expirationTimes=xo(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=xo(0),this.identifierPrefix=v,this.onRecoverableError=R,this.mutableSourceEagerHydrationData=null}function Cg(o,l,p,v,R,_,q,Z,ie){return o=new HT(o,l,p,Z,ie),l===1?(l=1,_===!0&&(l|=8)):l=0,_=Ns(3,null,null,l),o.current=_,_.stateNode=o,_.memoizedState={element:v,isDehydrated:p,cache:null,transitions:null,pendingSuspenseBoundaries:null},Dm(_),o}function zT(o,l,p){var v=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:$,key:v==null?null:""+v,children:o,containerInfo:l,implementation:p}}function Kv(o){if(!o)return wo;o=o._reactInternals;e:{if(yn(o)!==o||o.tag!==1)throw Error(r(170));var l=o;do{switch(l.tag){case 3:l=l.stateNode.context;break e;case 1:if(qr(l.type)){l=l.stateNode.__reactInternalMemoizedMergedChildContext;break e}}l=l.return}while(l!==null);throw Error(r(171))}if(o.tag===1){var p=o.type;if(qr(p))return vb(o,p,l)}return l}function Gv(o,l,p,v,R,_,q,Z,ie){return o=Cg(p,v,!0,o,R,_,q,Z,ie),o.context=Kv(null),p=o.current,v=Ar(),R=To(p),_=Wa(v,R),_.callback=l??null,So(p,_,R),o.current.lanes=R,ta(o,R,v),zr(o,v),o}function Cu(o,l,p,v){var R=l.current,_=Ar(),q=To(R);return p=Kv(p),l.context===null?l.context=p:l.pendingContext=p,l=Wa(_,q),l.payload={element:o},v=v===void 0?null:v,v!==null&&(l.callback=v),o=So(R,l,q),o!==null&&(Us(o,R,q,_),ru(o,R,q)),q}function Ru(o){if(o=o.current,!o.child)return null;switch(o.child.tag){case 5:return o.child.stateNode;default:return o.child.stateNode}}function Vv(o,l){if(o=o.memoizedState,o!==null&&o.dehydrated!==null){var p=o.retryLane;o.retryLane=p!==0&&p<l?p:l}}function Rg(o,l){Vv(o,l),(o=o.alternate)&&Vv(o,l)}function KT(){return null}var Qv=typeof reportError=="function"?reportError:function(o){console.error(o)};function Ig(o){this._internalRoot=o}Iu.prototype.render=Ig.prototype.render=function(o){var l=this._internalRoot;if(l===null)throw Error(r(409));Cu(o,l,null,null)},Iu.prototype.unmount=Ig.prototype.unmount=function(){var o=this._internalRoot;if(o!==null){this._internalRoot=null;var l=o.containerInfo;gi(function(){Cu(null,o,null,null)}),l[La]=null}};function Iu(o){this._internalRoot=o}Iu.prototype.unstable_scheduleHydration=function(o){if(o){var l=Xe();o={blockedOn:null,target:o,priority:l};for(var p=0;p<Ye.length&&l!==0&&l<Ye[p].priority;p++);Ye.splice(p,0,o),p===0&&Xn(o)}};function Tg(o){return!(!o||o.nodeType!==1&&o.nodeType!==9&&o.nodeType!==11)}function Tu(o){return!(!o||o.nodeType!==1&&o.nodeType!==9&&o.nodeType!==11&&(o.nodeType!==8||o.nodeValue!==" react-mount-point-unstable "))}function Yv(){}function GT(o,l,p,v,R){if(R){if(typeof v=="function"){var _=v;v=function(){var ve=Ru(q);_.call(ve)}}var q=Gv(l,v,o,0,null,!1,!1,"",Yv);return o._reactRootContainer=q,o[La]=q.current,Nc(o.nodeType===8?o.parentNode:o),gi(),q}for(;R=o.lastChild;)o.removeChild(R);if(typeof v=="function"){var Z=v;v=function(){var ve=Ru(ie);Z.call(ve)}}var ie=Cg(o,0,!1,null,null,!1,!1,"",Yv);return o._reactRootContainer=ie,o[La]=ie.current,Nc(o.nodeType===8?o.parentNode:o),gi(function(){Cu(l,ie,p,v)}),ie}function $u(o,l,p,v,R){var _=p._reactRootContainer;if(_){var q=_;if(typeof R=="function"){var Z=R;R=function(){var ie=Ru(q);Z.call(ie)}}Cu(l,q,o,R)}else q=GT(p,l,o,R,v);return Ru(q)}Re=function(o){switch(o.tag){case 3:var l=o.stateNode;if(l.current.memoizedState.isDehydrated){var p=fs(l.pendingLanes);p!==0&&(Y(l,p|1),zr(l,Ot()),(Ut&6)===0&&(xl=Ot()+500,jo()))}break;case 13:gi(function(){var v=Ba(o,1);if(v!==null){var R=Ar();Us(v,o,1,R)}}),Rg(o,1)}},Te=function(o){if(o.tag===13){var l=Ba(o,134217728);if(l!==null){var p=Ar();Us(l,o,134217728,p)}Rg(o,134217728)}},Ie=function(o){if(o.tag===13){var l=To(o),p=Ba(o,l);if(p!==null){var v=Ar();Us(p,o,l,v)}Rg(o,l)}},Xe=function(){return de},Ke=function(o,l){var p=de;try{return de=o,l()}finally{de=p}},Pt=function(o,l,p){switch(l){case"input":if(me(o,p),l=p.name,p.type==="radio"&&l!=null){for(p=o;p.parentNode;)p=p.parentNode;for(p=p.querySelectorAll("input[name="+JSON.stringify(""+l)+'][type="radio"]'),l=0;l<p.length;l++){var v=p[l];if(v!==o&&v.form===o.form){var R=Gd(v);if(!R)throw Error(r(90));re(v),me(v,R)}}}break;case"textarea":_e(o,p);break;case"select":l=p.value,l!=null&&mt(o,!!p.multiple,l,!1)}},xr=vg,hs=gi;var VT={usingClientEntryPoint:!1,Events:[Rc,sl,Gd,Na,uo,vg]},Wc={findFiberByHostInstance:ii,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},QT={bundleType:Wc.bundleType,version:Wc.version,rendererPackageName:Wc.rendererPackageName,rendererConfig:Wc.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:S.ReactCurrentDispatcher,findHostInstanceByFiber:function(o){return o=Zr(o),o===null?null:o.stateNode},findFiberByHostInstance:Wc.findFiberByHostInstance||KT,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 _u=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!_u.isDisabled&&_u.supportsFiber)try{_r=_u.inject(QT),tn=_u}catch{}}return Kr.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=VT,Kr.createPortal=function(o,l){var p=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Tg(l))throw Error(r(200));return zT(o,l,null,p)},Kr.createRoot=function(o,l){if(!Tg(o))throw Error(r(299));var p=!1,v="",R=Qv;return l!=null&&(l.unstable_strictMode===!0&&(p=!0),l.identifierPrefix!==void 0&&(v=l.identifierPrefix),l.onRecoverableError!==void 0&&(R=l.onRecoverableError)),l=Cg(o,1,!1,null,null,p,!1,v,R),o[La]=l.current,Nc(o.nodeType===8?o.parentNode:o),new Ig(l)},Kr.findDOMNode=function(o){if(o==null)return null;if(o.nodeType===1)return o;var l=o._reactInternals;if(l===void 0)throw typeof o.render=="function"?Error(r(188)):(o=Object.keys(o).join(","),Error(r(268,o)));return o=Zr(l),o=o===null?null:o.stateNode,o},Kr.flushSync=function(o){return gi(o)},Kr.hydrate=function(o,l,p){if(!Tu(l))throw Error(r(200));return $u(null,o,l,!0,p)},Kr.hydrateRoot=function(o,l,p){if(!Tg(o))throw Error(r(405));var v=p!=null&&p.hydratedSources||null,R=!1,_="",q=Qv;if(p!=null&&(p.unstable_strictMode===!0&&(R=!0),p.identifierPrefix!==void 0&&(_=p.identifierPrefix),p.onRecoverableError!==void 0&&(q=p.onRecoverableError)),l=Gv(l,null,o,1,p??null,R,!1,_,q),o[La]=l.current,Nc(o),v)for(o=0;o<v.length;o++)p=v[o],R=p._getVersion,R=R(p._source),l.mutableSourceEagerHydrationData==null?l.mutableSourceEagerHydrationData=[p,R]:l.mutableSourceEagerHydrationData.push(p,R);return new Iu(l)},Kr.render=function(o,l,p){if(!Tu(l))throw Error(r(200));return $u(null,o,l,!1,p)},Kr.unmountComponentAtNode=function(o){if(!Tu(o))throw Error(r(40));return o._reactRootContainer?(gi(function(){$u(null,null,o,!1,function(){o._reactRootContainer=null,o[La]=null})}),!0):!1},Kr.unstable_batchedUpdates=vg,Kr.unstable_renderSubtreeIntoContainer=function(o,l,p,v){if(!Tu(p))throw Error(r(200));if(o==null||o._reactInternals===void 0)throw Error(r(38));return $u(o,l,p,!1,v)},Kr.version="18.3.1-next-f1338f8080-20240426",Kr}var rk;function UN(){if(rk)return _g.exports;rk=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(n){console.error(n)}}return e(),_g.exports=m$(),_g.exports}var sk;function g$(){if(sk)return Eu;sk=1;var e=UN();return Eu.createRoot=e.createRoot,Eu.hydrateRoot=e.hydrateRoot,Eu}var f$=g$();const wd=["untouched","replied_unresolved","likely_addressed","resolved"],x$=["draft","open","merged","closed"],y$=["approved","changes_requested","commented","dismissed"],ak={pr_opened:"lifecycle",pr_merged:"lifecycle",pr_closed:"lifecycle",pr_reopened:"lifecycle",pr_ready_for_review:"lifecycle",review_submitted:"reviews",review_comment:"review_comments",pr_comment:"pr_comments",commit_pushed:"commits"},HN={coderabbitai:"coderabbit","greptile-apps":"greptile","copilot-pull-request-reviewer":"copilot","qodo-ai":"qodo","qodo-merge":"qodo","qodo-merge-pro":"qodo","qodo-merge-for-open-source":"qodo","codiumai-pr-agent-free":"qodo","sourcery-ai":"sourcery","bito-code-review":"bito","ellipsis-dev":"ellipsis","korbit-ai":"korbit","baz-reviewer":"baz","graphite-app":"graphite",cursor:"cursor","devin-ai-integration":"devin","entelligence-ai-pr-reviews":"entelligence","deepsource-io":"deepsource",deepsourcebot:"deepsource","github-code-quality":"github_code_quality","github-advanced-security":"github_advanced_security","chatgpt-codex-connector":"codex"};function zN(e){if(!e)return null;const n=e.toLowerCase().replace(/\[bot\]$/,"");return HN[n]??null}const KN={dependabot:{kind:"dependabot",role:"dependency"},"dependabot-preview":{kind:"dependabot",role:"dependency"},renovate:{kind:"renovate",role:"dependency"},"renovate-bot":{kind:"renovate",role:"dependency"},"snyk-bot":{kind:"snyk",role:"dependency"},"pyup-bot":{kind:"pyup",role:"dependency"},greenkeeper:{kind:"greenkeeper",role:"dependency"},depfu:{kind:"depfu",role:"dependency"},"snyk-io":{kind:"snyk",role:"dependency"},"aikido-autofix":{kind:"aikido",role:"dependency"},"mend-for-github-com":{kind:"mend",role:"dependency"},sonarqubecloud:{kind:"sonarqube",role:"quality_check"},sonarcloud:{kind:"sonarqube",role:"quality_check"},codecov:{kind:"codecov",role:"quality_check"},codeclimate:{kind:"codeclimate",role:"quality_check"},"codefactor-io":{kind:"codefactor",role:"quality_check"},"houndci-bot":{kind:"hound",role:"quality_check"},coveralls:{kind:"coveralls",role:"quality_check"},"codacy-bot":{kind:"codacy",role:"quality_check"},"github-actions":{kind:"github_actions",role:"quality_check"},"jit-ci":{kind:"jit",role:"quality_check"},"socket-security":{kind:"socket",role:"quality_check"},gitguardian:{kind:"gitguardian",role:"quality_check"},"semgrep-app":{kind:"semgrep",role:"quality_check"},"trunk-io":{kind:"trunk",role:"quality_check"},"endor-labs-pro":{kind:"endor",role:"quality_check"},"devin-ai-integration":{kind:"devin",role:"code_agent"},"sweep-ai":{kind:"sweep",role:"code_agent"},"codegen-sh":{kind:"codegen",role:"code_agent"},"deepsource-autofix":{kind:"deepsource_autofix",role:"code_agent"},"pre-commit-ci":{kind:"pre_commit_ci",role:"code_agent"},"restyled-io":{kind:"restyled",role:"code_agent"},imgbot:{kind:"imgbot",role:"code_agent"},imgbotapp:{kind:"imgbot",role:"code_agent"},"transifex-integration":{kind:"transifex",role:"code_agent"},"crowdin-bot":{kind:"crowdin",role:"code_agent"},mintlify:{kind:"mintlify",role:"code_agent"},allstar:{kind:"allstar",role:"code_agent"},"step-security-bot":{kind:"step_security",role:"code_agent"},orbisai0security:{kind:"orbisai",role:"code_agent"},mergify:{kind:"mergify",role:"release"},kodiak:{kind:"kodiak",role:"release"},kodiakhq:{kind:"kodiak",role:"release"},bulldozer:{kind:"bulldozer",role:"release"},"release-please":{kind:"release_please",role:"release"},releaser:{kind:"release_please",role:"release"},"semantic-release":{kind:"semantic_release",role:"release"},"semantic-release-bot":{kind:"semantic_release",role:"release"},"release-drafter":{kind:"release_drafter",role:"release"},"changeset-bot":{kind:"changesets",role:"release"},changesets:{kind:"changesets",role:"release"},autorelease:{kind:"release_please",role:"release"},"lumberbot-app":{kind:"backport",role:"release"},meeseeksdev:{kind:"backport",role:"release"},backport:{kind:"backport",role:"release"},"cla-bot":{kind:"cla_assistant",role:"housekeeping"},"cla-assistant":{kind:"cla_assistant",role:"housekeeping"},claassistant:{kind:"cla_assistant",role:"housekeeping"},"google-cla":{kind:"google_cla",role:"housekeeping"},googlebot:{kind:"google_cla",role:"housekeeping"},"facebook-github-bot":{kind:"meta_cla",role:"housekeeping"},dco:{kind:"dco",role:"housekeeping"},stale:{kind:"stale_bot",role:"housekeeping"},welcome:{kind:"welcome_bot",role:"housekeeping"},lock:{kind:"lock_bot",role:"housekeeping"},allcontributors:{kind:"allcontributors",role:"housekeeping"},"semantic-pull-request":{kind:"semantic_pr",role:"housekeeping"},sizebot:{kind:"sizebot",role:"housekeeping"},"react-sizebot":{kind:"sizebot",role:"housekeeping"},"diffray-bot":{kind:"sizebot",role:"housekeeping"},"codesandbox-ci":{kind:"codesandbox",role:"housekeeping"},netlify:{kind:"netlify",role:"housekeeping"},vercel:{kind:"vercel",role:"housekeeping"},"gitpod-io":{kind:"gitpod",role:"housekeeping"}},jd=e=>new Set(Object.entries(KN).filter(([,n])=>n.role===e).map(([n])=>n));jd("quality_check");jd("dependency");jd("code_agent");jd("release");jd("housekeeping");const b$=["human","code_agent","dependency","ai_review","quality_gate","release","housekeeping"],v$={human:"people",code_agent:"authors",dependency:"authors",release:"authors",ai_review:"responds",quality_gate:"responds",housekeeping:"responds"},k$=["review","quality_check","dependency","code_agent","release","housekeeping"],GN=new Map([...Object.values(KN).map(e=>[e.kind,e.role]),...Object.values(HN).map(e=>[e,"review"]),["frogbot","dependency"],["checkmarx","dependency"],["pierre","review"],["in_house",null],["vendor",null]]);function Ag(e){return GN.get(e)??null}function w$(e,n){const r=[];for(const[s,a]of GN)(a===e||a===null)&&r.push(s);return n!=null&&!r.includes(n)&&r.push(n),r}const ok={review:"Review bot",quality_check:"Quality check",dependency:"Dependency updates",code_agent:"Code agent",release:"Release automation",housekeeping:"Housekeeping"},j$=[{key:"attention_now",label:"Needs attention",question:"What needs attention now?"},{key:"blocked_threads",label:"Blocked threads",question:"Which review threads are blocked right now?"},{key:"biggest_changes",label:"Biggest changes",question:"What were the biggest changes merged this sprint (largest PRs by LoC)?"},{key:"longest_to_merge",label:"Slowest to merge",question:"Which PRs took the longest to merge?"},{key:"review_bottlenecks",label:"Review bottlenecks",question:"Where are the review bottlenecks — who/what is holding up merges?"},{key:"ship_ready",label:"Ready to ship",question:"Which open PRs look ready to ship?"}],Mg=10,ik=100,hd=1500,lk={cautious:{highCodeLoc:600,highCodeFiles:10,highDirs:4,highSubsystems:2,lowCodeLoc:50,lowCodeFiles:2},balanced:{highCodeLoc:1e3,highCodeFiles:15,highDirs:6,highSubsystems:3,lowCodeLoc:100,lowCodeFiles:3},relaxed:{highCodeLoc:2e3,highCodeFiles:25,highDirs:10,highSubsystems:4,lowCodeLoc:200,lowCodeFiles:5}},ck="balanced",VN=["db_migration","db_schema","sql","public_types","idl","openapi","infra","auth"],CJ=["claude-opus-5-5","claude-sonnet-5"],dk="claude-opus-5-5",RJ={"claude-opus-5-5":"Claude Opus 5.5 (most thorough)","claude-sonnet-5":"Claude Sonnet 5 (best value)"},IJ={design:"Design",tests:"Tests",impact:"Impact",accessibility:"Accessibility",security:"Security",performance:"Performance"},N$=3,S$=1e3,TJ=4e3,$J="claude-opus-5-5",_J={finding:"Finding",thread:"Reviewer thread",story:"User story",ci_failure:"CI failure",earlier_finding:"Earlier finding"},PJ=4e3,C$="Changes requested.",uk=["merges","lead_time","review_latency","merge_ci","ci_recovery","ci_red"],Q0=2,QN=["merged_prs","human_merged_prs","opened_prs","automation_merge_share_pct","median_lead_time_hours","median_time_to_first_human_review_hours","merge_ci_success_pct","median_pr_size_lines","median_human_pr_size_lines","review_threads_opened","threads_replied_within_36h_pct","bot_review_comments","human_review_comments","bot_comments_per_merged_pr","reviewer_concentration_pct"],R$=1250,hp=["critical","major","minor","nit"],I$=["correctness_bug","security","performance","style_readability","maintainability_refactor","testing","documentation","nitpick","praise"],Tl={nit:0,minor:1,major:2,critical:3},Y0=["thumbs_up","thumbs_down","laugh","hooray","confused","heart","rocket","eyes"],hk={thumbs_up:"👍",thumbs_down:"👎",laugh:"😄",hooray:"🎉",confused:"😕",heart:"❤️",rocket:"🚀",eyes:"👀"},T$=["merged_prs_authored","opened_prs_authored","reviews_given","review_comments_written","median_review_response_hours","median_first_human_review_hours_their_prs","review_threads_on_their_prs","their_pr_threads_addressed","awaiting_their_review","open_prs_authored"],$$=["prs_opened","prs_merged","prs_closed_unmerged","merge_rate_pct","median_hours_to_merge","median_pr_size_lines","prs_merged_without_human_review","human_review_comments_received","repos_touched"],YN="Limn",Lg={in_house:"In-house / custom",vendor:"Vendor",pierre:`${YN} · Claude`};function _$(e){switch(e){case"base":return"base";case"ours":return"ours";case"theirs":return"theirs";case"both_ours_first":return"theirs";case"both_theirs_first":return"ours";default:return null}}function P$(e,n){if(n==="edited")return e!=="unchanged";switch(e){case"unchanged":return n==="base";case"ours_only":return n==="ours"||n==="base";case"theirs_only":return n==="theirs"||n==="base";case"both_same":return n==="ours"||n==="base";case"conflict":return!0}}function E$(e,n){const r=[];let s=e.terminators.base;const a=new Set;for(const i of e.regions){if(i.kind==="unchanged"){r.push(...i.base),s=e.terminators.base;continue}const c=n.get(i.id);if(!c)return{ok:!1,reason:"undecided_region",regionId:i.id};if(a.add(i.id),!P$(i.kind,c.decision))return{ok:!1,reason:"disallowed_decision",regionId:i.id};switch(c.decision){case"base":r.push(...i.base);break;case"ours":r.push(...i.ours);break;case"theirs":r.push(...i.theirs);break;case"both_ours_first":r.push(...i.ours,...i.theirs);break;case"both_theirs_first":r.push(...i.theirs,...i.ours);break;case"disjoint_merge":case"suggestion":case"edited":r.push(...c.lines);break}const d=_$(c.decision);s=d===null?c.endsWithNewline:e.terminators[d]}for(const i of n.keys())if(!a.has(i)&&!e.regions.some(c=>c.id===i))return{ok:!1,reason:"unknown_region",regionId:i};return{ok:!0,lines:r,finalNewline:s}}const kh={stalledReviewMinHours:24,untouchedThreadMinHours:24,routingMinAgeHours:4,maxQuietDays:90,reviewerLoadCap:8,boardListCap:50,routingSuggestCap:15},A$="In the merge queue. GitHub merges it from here.",El={stalledReviewHours:{high:72,warn:48},untouchedThreadHours:{high:96,warn:48},reviewerLoadPending:{high:4,warn:2}},M$={review_request:"high",mention:"high",thread:"high",thread_reply:"high",comment_reply:"high",pushed_since:"warn",own_ci_red:"high",own_conflicts:"high",trunk_red:"warn",pr_approved:"warn",own_ready:"warn",your_pr:"warn",own_thread:"warn",claude_review:"warn",watched_repo_pr:"info"},qo={weights:{proximity:.5,stall:.3,relevance:.2},proximity:{merge_approved:.95,merge_unapproved:.45,update_branch:.7,red_trunk:.65,unblock_ci:.6,review:.55,reply:.5,thread:.4,nudge:.25,conflicts:.5,security_alert:.55,waiting:.3},adjustments:{conflicts:-.15,many_untouched_threads:-.1,small_change:.05},manyUntouchedThreadsMin:3,smallChangeMaxFiles:3,stallBuckets:[{minHours:96,risk:1},{minHours:48,risk:.7},{minHours:24,risk:.4}],stallBase:.15,relevanceWeight:{direct:1,maintained:.6,none:.25}},hx={balanced:{proximity:50,stall:30,relevance:20},mine_first:{proximity:30,stall:10,relevance:60},oldest_first:{proximity:20,stall:70,relevance:10},quick_wins:{proximity:80,stall:10,relevance:10}},XN=["balanced","mine_first","oldest_first","quick_wins"],Al=5,Ko=[{key:"my_turn",kinds:["my_turn"],groupByReason:!0},{key:"fixing",kinds:["ci_failing","conflicts"]},{key:"review",kinds:["stalled_review","reviewer_routing","reviewer_load"]},{key:"threads",kinds:["untouched_thread"]},{key:"land",kinds:["merge","update_branch"]},{key:"deps",kinds:["security","dependency_bump"],groupByKind:!0}];function L$(e){for(const n of Ko)if(n.kinds.includes(e))return n.key;return null}function F$(e){return"automation"in e&&e.automation!=null?"automation":"people"}const so=["firstLook","reply","land","lead"],Vs={firstLook:{good:4,ok:8},reply:{good:8,ok:16},land:{good:1,ok:4},lead:{good:8,ok:16}},Fr={budgetMinPrs:5,cutMinPrs:5,contrastMinQuartile:8,separatesRatio:2,weakRatio:1.3,concentrationMinSide:3,slowerRatio:1.25,slowerMinHours:.5,landingRows:10,minRepoPrs:12,dominantShare:.5,slowP75ClockHours:8,unreviewedMinCount:10,unreviewedMinShare:.2},Uo={days:[1,2,3,4,5],startMinute:540,endMinute:1080};function O$(e){return typeof e=="number"&&Number.isFinite(e)&&e>0&&e<=1e3}function D$(e){if(e.length===0||e.length>64)return!1;try{return new Intl.DateTimeFormat("en-GB",{timeZone:e}),!0}catch{return!1}}function B$(e){var s;if(e.timeZone!==void 0&&!D$(e.timeZone))return`“${e.timeZone}” is not a time zone this browser or server recognises.`;if(e.days!==void 0){if(!Array.isArray(e.days)||e.days.length===0)return"Pick at least one working day.";if(!e.days.every(a=>Number.isInteger(a)&&a>=1&&a<=7))return"Working days must be Monday to Sunday."}const n=e.startMinute!==void 0,r=e.endMinute!==void 0;if(n!==r)return"Set both the start and the end of the working day.";if(n&&r){const a=e.startMinute,i=e.endMinute;if(!Number.isInteger(a)||!Number.isInteger(i)||a<0||i>1440)return"The working day must start and end within the same day.";if(a>=i)return"The working day must end after it starts."}for(const a of so){const i=(s=e.budgets)==null?void 0:s[a];if(i!=null){for(const c of["good","ok"])if(i[c]!==void 0&&!O$(i[c]))return"Budgets must be between 0 and 1,000 working hours.";if(i.good!==void 0&&i.ok!==void 0&&i.ok<i.good)return"“Acceptable” cannot be tighter than “good”."}}return null}const sc={firstLook:"First look",reply:"Reply to review",land:"Approved to merged",lead:"Whole pull request"},Oi=["review_request","mention","thread","thread_reply","comment_reply","pushed_since","own_ci_red","own_conflicts","trunk_red","pr_approved","own_ready","your_pr","own_thread","claude_review","watched_repo_pr"],wh=Oi.filter(e=>e!=="trunk_red"),ZN=["off","maintained","all"],X0={review_request:!0,mention:!0,thread:!0,thread_reply:!0,comment_reply:!0,pushed_since:!0,own_ci_red:!1,own_conflicts:!1,pr_approved:!0,own_ready:!1,your_pr:!0,own_thread:!1,claude_review:!0,watched_repo_pr:!1},W$=new Set(["own_ci_red","own_conflicts","own_ready","own_thread","trunk_red"]),Ci={review_request:"Review requests",mention:"@mentions of you",thread:"Replies in threads you started",thread_reply:"Replies to your comments in other threads",comment_reply:"Comments after yours on a PR",pushed_since:"New commits since you reviewed",own_ci_red:"Failing builds on your PRs",own_conflicts:"Merge conflicts on your PRs",trunk_red:"Red default branch",pr_approved:"Your PRs that are approved",own_ready:"Your PRs ready to land",your_pr:"New activity on your PRs",own_thread:"Unanswered threads on your PRs",claude_review:"Finished Claude reviews",watched_repo_pr:"New PRs nobody asked you about"},eh=["proximity","stall","relevance"];function JN(e){for(const n of XN){const r=hx[n];if(eh.every(s=>r[s]===e[s]))return n}return"custom"}function eS(e){const n=jh(e)?e:{},r=jh(n.show)?n.show:{},s={};for(const m of wh){const h=r[m];s[m]=typeof h=="boolean"?h:X0[m]}const a=rS(n.trunkScope)?n.trunkScope:"off",i=H$(n.order),c=n.weights!==void 0&&tS(n.weights)===null?{proximity:n.weights.proximity,stall:n.weights.stall,relevance:n.weights.relevance}:{...hx.balanced},d=JN(c),u=i.filter(m=>m==="trunk_red"?a==="off":!s[m]);return{show:s,trunkScope:a,order:i,off:u,weightsPct:c,weights:{proximity:c.proximity/100,stall:c.stall/100,relevance:c.relevance/100},preset:d,defaults:{show:wh.every(m=>s[m]===X0[m]),trunkScope:a==="off",order:i.every((m,h)=>m===Oi[h]),weights:d==="balanced"},configKey:`${[...u].sort().join(",")}|${a}`}}function q$(e){if(e.show!==void 0){if(!jh(e.show))return"Each card type must be on or off.";for(const[n,r]of Object.entries(e.show)){if(!z$(n))return`“${n}” is not a My Turn card type.`;if(r!==void 0&&typeof r!="boolean")return"Each card type must be on or off."}}if(e.trunkScope!==void 0&&!rS(e.trunkScope))return"Red default branch must be Off, Repos you maintain or Every repo.";if(e.order!==void 0){if(!Array.isArray(e.order))return"The order must be a list of card types.";const n=new Set;for(const r of e.order){if(!nS(r))return`“${String(r)}” is not a My Turn card type.`;if(n.has(r))return"Each card type can appear in the order once.";n.add(r)}}return e.weights!==void 0?tS(e.weights):null}function px(e){const n=eS(e),r={},s={};for(const a of wh)n.show[a]!==X0[a]&&(s[a]=n.show[a]);return Object.keys(s).length>0&&(r.show=s),n.defaults.trunkScope||(r.trunkScope=n.trunkScope),n.defaults.order||(r.order=n.order),n.defaults.weights||(r.weights=n.weightsPct),Object.keys(r).length>0?r:null}function tS(e){return!jh(e)||eh.some(r=>e[r]===void 0)?"Set all three weights.":eh.every(r=>U$(e[r]))?eh.reduce((r,s)=>r+e[s],0)===100?null:"The three weights must add up to 100%.":"Each weight must be 0 to 100%, in steps of 10."}function U$(e){return typeof e=="number"&&Number.isInteger(e)&&e>=0&&e<=100&&e%10===0}function H$(e){const n=[];if(Array.isArray(e))for(const r of e)nS(r)&&!n.includes(r)&&n.push(r);for(const r of Oi)n.includes(r)||n.push(r);return n}function nS(e){return typeof e=="string"&&Oi.includes(e)}function z$(e){return typeof e=="string"&&wh.includes(e)}function rS(e){return typeof e=="string"&&ZN.includes(e)}function jh(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const th={titleChars:300,descriptionChars:8e3,acceptanceCriteriaChars:8e3},pk=5,K$=/^[A-Z][A-Z0-9_]{0,19}-\d{1,9}$/,G$=2e3,V$={title:"Title",description:"Description",acceptanceCriteria:"Acceptance criteria"},Q$=/[\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F]/,Y$=/[\uD800-\uDFFF]/u;function sS(e){const n=th,r={title:n.titleChars,description:n.descriptionChars,acceptanceCriteria:n.acceptanceCriteriaChars},s={title:null,description:null,acceptanceCriteria:null};for(const i of["title","description","acceptanceCriteria"]){const c=e==null?void 0:e[i],d=typeof c=="string"?c.trim():"";if(!d)continue;const u=V$[i];if(Q$.test(d))return{ok:!1,field:i,message:`${u} contains a control character that can't be stored.`};if(Y$.test(d))return{ok:!1,field:i,message:`${u} contains a broken character that can't be stored.`};if(d.length>r[i])return{ok:!1,field:i,message:`${u} is ${d.length} characters; the limit is ${r[i]}.`};s[i]=d}if(s.title==null&&s.description==null&&s.acceptanceCriteria==null)return{ok:!0,ticket:null};const a={title:s.title,description:s.description,acceptanceCriteria:s.acceptanceCriteria};if((e==null?void 0:e.source)==="jira"){a.source="jira";const i=typeof e.key=="string"?e.key.trim():"";a.key=K$.test(i)?i:null;const c=typeof e.url=="string"?e.url.trim():"";a.url=c.length<=G$&&/^https?:\/\/[^\s]+$/i.test(c)?c:null;const d=typeof e.fetchedAt=="string"?Date.parse(e.fetchedAt):Number.NaN;a.fetchedAt=Number.isFinite(d)?new Date(d).toISOString():null}else(e==null?void 0:e.source)==="manual"&&(a.source="manual");return{ok:!0,ticket:a}}function aS(e){const n=[],r=e??[];for(let s=0;s<r.length;s+=1){const a=sS(r[s]);if(!a.ok){const i=r.length>1?`Ticket ${s+1}: ${a.message}`:a.message;return{ok:!1,index:s,field:a.field,message:i}}a.ticket&&n.push(a.ticket)}return n.length>pk?{ok:!1,index:null,field:"tickets",message:`${n.length} tickets; the limit is ${pk}.`}:{ok:!0,tickets:n}}const X$=/^\s*acceptance[\s_-]*criteria\s*$/i;function Z$(e,n){var s;if(n!=null&&e.some(a=>a.id===n))return n;const r=e.filter(a=>a.match==="strong");return((s=r.find(a=>X$.test(a.name))??r[0])==null?void 0:s.id)??""}const EJ={addressed:"Addressed",partly_addressed:"Partly addressed",not_addressed:"Not addressed",no_longer_applies:"No longer applies",not_checked:"Not checked"},J$={met:"Met",partly_met:"Partly met",not_met:"Not met",unclear:"Can't tell from the code",not_checked:"Not checked"},e4={aligned:"Matches the user story",partly_aligned:"Partly matches the user story",not_aligned:"Doesn't match the user story",unclear:"Can't tell",not_checked:"Not checked"},AJ={valid:"Valid",partly_valid:"Partly valid",not_valid:"Not valid",unclear:"Can't tell",not_checked:"Not checked"},MJ={addressed:"Addressed",partly_addressed:"Partly addressed",not_addressed:"Not addressed",unclear:"Can't tell",not_checked:"Not checked"};function mx(e){return(e.validity==="valid"||e.validity==="partly_valid")&&(e.addressed==="not_addressed"||e.addressed==="partly_addressed")}function LJ(e){const n={total:e.length,assessed:0,validUnaddressed:0,notValid:0,addressed:0,notChecked:0};for(const r of e)r.validity!=="not_checked"||r.addressed!=="not_checked"?n.assessed+=1:n.notChecked+=1,mx(r)&&(n.validUnaddressed+=1),r.validity==="not_valid"&&(n.notValid+=1),r.addressed==="addressed"&&(n.addressed+=1);return n}function t4(e){const n={total:e.length,addressed:0,partly:0,notAddressed:0,noLongerApplies:0,notChecked:0};for(const r of e)r.status==="addressed"?n.addressed+=1:r.status==="partly_addressed"?n.partly+=1:r.status==="not_addressed"?n.notAddressed+=1:r.status==="no_longer_applies"?n.noLongerApplies+=1:n.notChecked+=1;return n}function FJ(e){if(!e||e.items.length===0)return null;const n=t4(e.items),r=[`${n.addressed} addressed`];n.partly>0&&r.push(`${n.partly} partly addressed`),n.notAddressed>0&&r.push(`${n.notAddressed} not addressed`),n.noLongerApplies>0&&r.push(`${n.noLongerApplies} no longer ${n.noLongerApplies===1?"applies":"apply"}`),n.notChecked>0&&r.push(`${n.notChecked} not checked`);const s=e.items.filter(d=>d.carried===!0).length,a=n.total-s,i=d=>d===1?"comment":"comments";return`${s===0?`Last review's ${a} ${i(a)}`:a===0?`${s} older ${i(s)}`:`Last review's ${a} ${i(a)} and ${s} older ${s===1?"one":"ones"}`}: ${r.join(", ")}.`}function OJ(e){if(!e||e.criteria.length===0)return null;const n=e.criteria.filter(s=>s.status==="met").length,r=e.criteria.length;return`${n} of ${r} ${r===1?"criterion":"criteria"} met.`}const n4=e=>`M${e+1}`;function r4(e,n){return e.key!=null&&e.key!==""?e.key:`Story ${n+1}`}function oS(e){const{users:n,repos:r,searchTimeline:s,searchOpenPrs:a,mergers:i,inScopeRepoIds:c,repoScoped:d,selectedIds:u,allowedBotIds:m,isBot:h,includeRosterRemainder:g}=e,x=new Map((n??[]).map(M=>[M.id,M])),y=M=>{if(M==null)return null;const D=x.get(M);return D&&!h(D)?D:null},b=M=>{if(M==null)return null;const D=x.get(M);return D&&h(D)?D:null},w=new Map,k=(M,D)=>{if(D==null||!c.has(M))return;let A=w.get(M);A||w.set(M,A=new Set),A.add(D)};for(const M of(s==null?void 0:s.events)??[])k(M.repoId,M.actorId);for(const M of(s==null?void 0:s.prs)??[])k(M.repoId,M.authorId);for(const M of(a==null?void 0:a.prs)??[])k(M.repoId,M.authorId);const j=new Set;for(const M of i??[])if(c.has(M.repoId))for(const D of M.userIds)y(D)&&(j.add(D),k(M.repoId,D));const N=(M,D)=>(M.displayName||M.githubLogin).localeCompare(D.displayName||D.githubLogin),I=(M,D)=>{const A=(j.has(M.id)?0:1)-(j.has(D.id)?0:1);return A!==0?A:N(M,D)},S=[],T=new Set;for(const M of r??[]){if(!c.has(M.id))continue;const D=w.get(M.id);if(!D||D.size===0)continue;const A=[...D].map(y).filter(W=>W!=null).sort(I);if(A.length){S.push({key:`repo:${M.id}`,label:M.name,members:A});for(const W of A)T.add(W.id)}}const P=[...g&&!d?new Set((n??[]).filter(M=>!h(M)).map(M=>M.id)):new Set([...T,...u])].map(y).filter(M=>M!=null).filter(M=>!T.has(M.id)).sort(N);P.length&&S.push({key:"other",label:d||!g?"Other":"No recent activity",members:P});const C=[],L=new Set;for(const M of r??[]){if(!c.has(M.id))continue;const D=w.get(M.id);if(!D)continue;const A=[...D].map(b).filter(W=>W!=null).sort(N);if(A.length){C.push({key:`bot:${M.id}`,label:M.name,members:A});for(const W of A)L.add(W.id)}}const F=m.map(b).filter(M=>M!=null).filter(M=>!L.has(M.id)).sort(N);return F.length&&C.push({key:"bot:other",label:"Other bots",members:F}),{sections:S,botSections:C,maintainerIds:j}}class cn extends Error{constructor(n,r,s=null,a=null){super(r),this.status=n,this.retryAfterSeconds=s,this.code=a,this.name="ApiError"}}async function We(e){if(!e.ok){let n=`${e.status} ${e.statusText}`,r=null;try{const a=await e.json();a.message&&(n=a.message),typeof a.error=="string"&&(r=a.error)}catch{}const s=e.headers.get("retry-after");throw new cn(e.status,n,s&&/^\d+$/.test(s)?Number(s):null,r)}if(e.status!==204)return await e.json()}function Me(e){return fetch(e,{credentials:"same-origin"}).then(n=>We(n))}function Ue(e,n){return n===void 0?{method:e,credentials:"same-origin"}:{method:e,credentials:"same-origin",headers:{"content-type":"application/json"},body:JSON.stringify(n)}}function xt(e){return`workspace=${e}`}function cr(e){return e?`repoIds=${e.join(",")}`:""}function pt(e,...n){const r=n.filter(s=>!!s).join("&");return r?`${e}?${r}`:e}function mk(e){return[`kind=${encodeURIComponent(e.kind)}`,`window=${encodeURIComponent(e.window)}`,xt(e.workspaceId),cr(e.repoIds),e.botUserId!=null?`botUserId=${e.botUserId}`:void 0,e.direction?`direction=${encodeURIComponent(e.direction)}`:void 0,e.select?`select=${encodeURIComponent(e.select)}`:void 0,e.severities&&e.severities.length>0?`severities=${encodeURIComponent(e.severities.join(","))}`:void 0,e.category?`category=${encodeURIComponent(e.category)}`:void 0,e.userId!=null?`userId=${e.userId}`:void 0,e.fromMs!=null?`fromMs=${e.fromMs}`:void 0,e.toMs!=null?`toMs=${e.toMs}`:void 0]}function gk(e){return[xt(e.workspaceId),cr(e.repoIds)]}const he={listRepos:()=>Me("/api/repos"),searchRepos:(e,n)=>Me(`/api/repos/search?q=${encodeURIComponent(e)}${n?`&cursor=${encodeURIComponent(n)}`:""}`),suggestedRepos:()=>Me("/api/repos/suggested"),search:e=>{const n=new URLSearchParams({q:e.q,workspace:String(e.workspaceId)});return e.kinds&&e.kinds.length>0&&n.set("kinds",e.kinds.join(",")),e.limit!=null&&n.set("limit",String(e.limit)),e.offset!=null&&n.set("offset",String(e.offset)),Me(`/api/search?${n.toString()}`)},addRepo:e=>fetch("/api/repos",Ue("POST",e)).then(n=>We(n)),deleteRepo:e=>fetch(`/api/repos/${e}`,Ue("DELETE")).then(n=>We(n)),syncRepo:(e,n=!1)=>fetch(`/api/repos/${e}/sync${n?"?full=true":""}`,Ue("POST")).then(r=>We(r)),cancelSync:e=>fetch(`/api/repos/${e}/cancel`,Ue("POST")).then(n=>We(n)),syncStatus:e=>Me(`/api/repos/${e}/sync-status`),syncActivity:()=>Me("/api/sync-activity"),listWorkspaces:()=>Me("/api/workspaces"),createWorkspace:e=>fetch("/api/workspaces",Ue("POST",{name:e})).then(n=>We(n)),renameWorkspace:(e,n)=>fetch(`/api/workspaces/${e}`,Ue("PATCH",n)).then(r=>We(r)),setWorkspaceRepos:(e,n)=>fetch(`/api/workspaces/${e}`,Ue("PATCH",{repoIds:n})).then(r=>We(r)),deleteWorkspace:e=>fetch(`/api/workspaces/${e}`,Ue("DELETE")).then(n=>We(n)),setWorkspacePendingMute:(e,n)=>fetch(`/api/workspaces/${e}/pending-mute`,Ue("PUT",n)).then(r=>We(r)),workspaceAutoReview:e=>Me(`/api/workspaces/${e}/auto-review`),setWorkspaceAutoReview:(e,n)=>fetch(`/api/workspaces/${e}/auto-review`,Ue("PUT",n)).then(r=>We(r)),setWorkspaceFlowSettings:(e,n)=>fetch(`/api/workspaces/${e}/flow-settings`,Ue("PUT",n)).then(r=>We(r)),assignRepoToWorkspace:(e,n)=>fetch(`/api/workspaces/${e}/repos`,Ue("POST",{repoId:n})).then(r=>We(r)),listUsers:()=>Me("/api/users"),userStats:(e,n,r)=>Me(pt(`/api/users/${e}/stats`,xt(n),cr(r))),mergers:()=>Me("/api/mergers"),timeline:e=>Me(`/api/timeline${e?`?${e}`:""}`),openPrs:e=>Me(`/api/open-prs${e?`?${e}`:""}`),insights:e=>Me(`/api/insights${e?`?${e}`:""}`),repoAnalytics:e=>Me(`/api/insights/${e}/analytics`),pr:e=>Me(`/api/prs/${e}`),refreshPr:(e,n)=>fetch(`/api/prs/${e}/refresh`,Ue("POST",n!=null&&n.wait?{wait:!0}:{})).then(r=>We(r)),suggestedReviewers:e=>Me(`/api/prs/${e}/suggested-reviewers`),thread:e=>Me(`/api/threads/${e}`),mentionCandidates:e=>Me(`/api/prs/${e}/mention-candidates`),scopeMentionCandidates:e=>Me(pt("/api/mention-candidates",xt(e))),prFiles:e=>Me(`/api/prs/${e}/files`),prFilesPage:(e,n)=>Me(`/api/prs/${e}/files?page=${n}`),prFileContent:(e,n,r)=>Me(`/api/prs/${e}/files/content?path=${encodeURIComponent(n)}&side=${r}`),prFileFullDiff:(e,n,r)=>Me(`/api/prs/${e}/files/diff?path=${encodeURIComponent(n)}${r?`&previousPath=${encodeURIComponent(r)}`:""}`),checkLogs:(e,n,r)=>{const s=new URLSearchParams;(r==null?void 0:r.tail)!=null&&s.set("tail",String(r.tail)),(r==null?void 0:r.startByte)!=null&&s.set("startByte",String(r.startByte)),(r==null?void 0:r.endByte)!=null&&s.set("endByte",String(r.endByte));const a=s.toString();return Me(`/api/prs/${e}/checks/${n}/logs${a?`?${a}`:""}`)},rerunCi:(e,n)=>fetch(`/api/prs/${e}/ci/rerun`,Ue("POST",n)).then(r=>We(r)),replyToThread:(e,n)=>fetch(`/api/threads/${e}/reply`,Ue("POST",n)).then(r=>We(r)),resolveThread:(e,n)=>fetch(`/api/threads/${e}/resolve`,Ue("POST",n)).then(r=>We(r)),resolveBotThreads:(e,n)=>fetch(`/api/prs/${e}/resolve-bot-threads`,Ue("POST",n)).then(r=>We(r)),createPrComment:(e,n)=>fetch(`/api/prs/${e}/comment`,Ue("POST",n)).then(r=>We(r)),approvePr:(e,n)=>fetch(`/api/prs/${e}/approve`,Ue("POST",n??{})).then(r=>We(r)),requestChanges:(e,n)=>fetch(`/api/prs/${e}/request-changes`,Ue("POST",n??{})).then(r=>We(r)),mergeOptions:e=>Me(`/api/prs/${e}/merge-options`),mergePr:(e,n)=>fetch(`/api/prs/${e}/merge`,Ue("POST",n)).then(r=>We(r)),closePr:e=>fetch(`/api/prs/${e}/close`,Ue("POST",{})).then(n=>We(n)),reopenPr:e=>fetch(`/api/prs/${e}/reopen`,Ue("POST",{})).then(n=>We(n)),updatePrBranch:(e,n)=>fetch(`/api/prs/${e}/update-branch`,Ue("POST",n??{})).then(r=>We(r)),openConflictSession:(e,n)=>fetch(`/api/prs/${e}/conflicts`,Ue("POST",n??{})).then(r=>We(r)),conflictSession:(e,n)=>Me(`/api/prs/${e}/conflicts?session=${encodeURIComponent(n)}`),conflictFile:(e,n,r)=>Me(`/api/prs/${e}/conflicts/files/${r}?session=${encodeURIComponent(n)}`),editConflictRegion:(e,n)=>fetch(`/api/prs/${e}/conflicts/edit`,Ue("POST",n)).then(r=>We(r)),commitConflictResolution:(e,n)=>fetch(`/api/prs/${e}/conflicts/commit`,Ue("POST",n)).then(r=>We(r)),closeConflictSession:(e,n)=>fetch(`/api/prs/${e}/conflicts?session=${encodeURIComponent(n)}`,Ue("DELETE")).then(r=>We(r)),enqueueMergeQueue:(e,n)=>fetch(`/api/prs/${e}/merge-queue`,Ue("POST",n??{})).then(r=>We(r)),dequeueMergeQueue:e=>fetch(`/api/prs/${e}/merge-queue`,Ue("DELETE")).then(n=>We(n)),armAutoMerge:(e,n)=>fetch(`/api/prs/${e}/auto-merge`,Ue("POST",n)).then(r=>We(r)),disarmAutoMerge:e=>fetch(`/api/prs/${e}/auto-merge`,Ue("DELETE")).then(n=>We(n)),armedMerges:()=>Me("/api/auto-merge"),branchStatus:e=>Me(`/api/branch-status${e?`?${e}`:""}`),branchTrends:e=>Me(`/api/branch-trends?repoId=${e}`),addReviewComment:(e,n)=>fetch(`/api/prs/${e}/review-comment`,Ue("POST",n)).then(r=>We(r)),requestReviewers:(e,n)=>fetch(`/api/prs/${e}/request-reviewers`,Ue("POST",n)).then(r=>We(r)),inbox:e=>Me(`/api/activity${e?`?${e}`:""}`),consolidatedFeed:e=>Me(`/api/activity/feed${e?`?${e}`:""}`),markFeedSeen:()=>fetch("/api/activity/feed/mark-seen",Ue("POST")).then(e=>We(e)),authProviders:()=>Me("/api/auth/providers"),setBenchmarkConsent:e=>fetch("/api/me/benchmark-consent",Ue("POST",{optIn:e})).then(n=>We(n)),setLargePrThreshold:e=>fetch("/api/me/large-pr-threshold",Ue("POST",{threshold:e})).then(n=>We(n)),setBlastRadiusConfig:e=>fetch("/api/me/blast-radius-config",Ue("PUT",{config:e})).then(n=>We(n)),setMyTurnSettings:e=>fetch("/api/me/my-turn-settings",Ue("PUT",{settings:e})).then(n=>We(n)),workspaceInsights:e=>Me(pt("/api/pro/insights",xt(e))),workspaceMetrics:e=>Me(pt("/api/workspace-metrics",xt(e))),attentionCards:e=>Me(pt("/api/attention",xt(e))),attentionLiveness:(e,n)=>fetch(pt("/api/attention/liveness",xt(e)),Ue("POST",n)).then(r=>We(r)),dailyBrief:(e,n)=>Me(pt("/api/daily-brief",xt(e),n?"rollup=1":void 0)),flowFindings:(e,n)=>Me(pt("/api/flow-findings",xt(e),n!=null?`days=${n}`:void 0)),workspaceMetricsDetail:e=>Me(pt("/api/workspace-metrics/detail",xt(e))),repoWorkspaceMetrics:e=>Me(`/api/pro/insights/repo/${e}/metrics`),aiUsage:()=>Me("/api/pro/ai-usage"),repoClaudeReviews:e=>Me(`/api/repos/${e}/claude-reviews`),repoDigests:e=>Me(pt("/api/pro/activity/digests",e)),refreshRepoDigests:e=>fetch(pt("/api/pro/activity/digests/refresh",e),Ue("POST")).then(n=>We(n)),presetPrompt:(e,n)=>Me(pt("/api/pro/preset-prompt",`key=${encodeURIComponent(e)}`,xt(n))),refreshPresetPrompt:(e,n)=>fetch(pt("/api/pro/preset-prompt/refresh",`key=${encodeURIComponent(e)}`,xt(n)),Ue("POST")).then(r=>We(r)),sprintChat:e=>fetch("/api/pro/insights/ask",Ue("POST",e)).then(n=>We(n)),sprintChatHistory:(e,n,r)=>Me(pt("/api/pro/insights/chat-history",`limit=${e}`,`offset=${n}`,xt(r))),pinnedPrompts:e=>Me(pt("/api/pro/insights/pinned",xt(e))),createPinnedPrompt:e=>fetch("/api/pro/insights/pinned",Ue("POST",e)).then(n=>We(n)),deletePinnedPrompt:e=>fetch(`/api/pro/insights/pinned/${e}`,Ue("DELETE")).then(n=>We(n)),periodReports:(e,n="sprint")=>Me(pt("/api/pro/insights/reports",xt(e),n==="sprint"?void 0:`grain=${n}`)),periodMonthToDate:e=>Me(pt("/api/pro/insights/month-to-date",xt(e))),periodReport:(e,n)=>Me(pt(`/api/pro/insights/reports/${encodeURIComponent(n)}`,xt(e))),generatePeriodReport:(e,n,r={})=>fetch(pt(`/api/pro/insights/reports/${encodeURIComponent(n)}/generate`,xt(e)),Ue("POST",r)).then(s=>We(s)),personPeriod:(e,n,r,s)=>Me(pt(`/api/pro/insights/person/${n}`,xt(e),`period=${encodeURIComponent(r)}`,s?"evidence=1":void 0)),repoDigest:e=>Me(`/api/pro/activity/digests/${e}`),prAnnotations:(e,n)=>Me(pt(`/api/pro/prs/${e}/annotations`,n&&n.length>0?`kinds=${n.join(",")}`:"")),runPrAnnotations:(e,n,r)=>fetch(`/api/pro/prs/${e}/annotations/run`,{...Ue("POST",n),...r?{signal:r}:{}}).then(s=>We(s)),prMlLabels:e=>Me(`/api/prs/${e}/ml-labels`),reactionLookup:e=>fetch("/api/reactions/lookup",Ue("POST",e)).then(n=>We(n)),setReaction:e=>fetch("/api/reactions",Ue("POST",e)).then(n=>We(n)),mlStatus:()=>Me("/api/ml-status"),proSettings:()=>Me("/api/pro/settings"),workspaceProSettings:e=>Me(pt("/api/pro/settings/workspace",xt(e))),updateWorkspaceProSettings:(e,n)=>fetch(pt("/api/pro/settings/workspace",xt(e)),Ue("PUT",n)).then(r=>We(r)),jiraFields:e=>Me(pt("/api/pro/jira/fields",xt(e))),jiraTicket:(e,n)=>Me(`/api/pro/prs/${e}/jira-ticket?key=${encodeURIComponent(n)}`),slackTarget:e=>Me(pt("/api/pro/slack/target",xt(e))),updateSlackTarget:(e,n)=>fetch(pt("/api/pro/slack/target",xt(e)),Ue("PUT",n)).then(r=>We(r)),deleteSlackTarget:e=>fetch(pt("/api/pro/slack/target",xt(e)),Ue("DELETE")).then(n=>We(n)),testSlackDigest:e=>fetch(pt("/api/pro/slack/test",xt(e)),Ue("POST")).then(n=>We(n)),me:()=>Me("/api/me"),logout:()=>fetch("/api/auth/logout",{method:"POST",credentials:"same-origin"}),myTurn:()=>Me("/api/my-turn"),dismissMyTurn:e=>fetch(`/api/my-turn/dismissals/${e.kind}/${e.id}`,Ue("PUT")).then(n=>We(n)),restoreMyTurn:e=>fetch(`/api/my-turn/dismissals/${e.kind}/${e.id}`,Ue("DELETE")).then(n=>We(n)),markPrViewed:(e,n)=>fetch(`/api/prs/${e}/mark-viewed`,Ue("POST",n?{sha:n}:{})).then(r=>We(r)),markAllViewed:e=>fetch("/api/prs/mark-all-viewed",Ue("POST",e&&e.length>0?{repoIds:e}:{})).then(n=>We(n)),dismissPr:e=>fetch(`/api/prs/${e}/dismiss`,Ue("POST")).then(n=>We(n)),claudeReview:e=>Me(`/api/prs/${e}/claude-review`),claudeReviewById:e=>Me(`/api/claude-reviews/${e}`),generateClaudeReview:(e,n,r)=>fetch(`/api/prs/${e}/claude-review`,Ue("POST",{model:n,...r!=null&&r.length>0?{tickets:r}:{}})).then(s=>We(s)),claudeReviewStates:e=>fetch("/api/claude-review/states",Ue("POST",{prIds:e})).then(n=>We(n)),claudeReviewStatus:e=>Me(`/api/prs/${e}/claude-review/status`),cancelClaudeReview:e=>fetch(`/api/prs/${e}/claude-review/cancel`,Ue("POST")).then(n=>We(n)),updateClaudeReview:(e,n)=>fetch(`/api/claude-reviews/${e}`,Ue("PATCH",n)).then(r=>We(r)),updateClaudeFinding:(e,n)=>fetch(`/api/claude-findings/${e}`,Ue("PATCH",n)).then(r=>We(r)),postClaudeFinding:e=>fetch(`/api/claude-findings/${e}/post`,Ue("POST")).then(n=>We(n)),activeClaudeReviews:()=>Me("/api/claude-reviews/active"),listAllClaudeReviews:()=>Me("/api/claude-reviews"),postClaudeReview:(e,n,r=!1)=>fetch(`/api/claude-reviews/${e}/post${r?"?dryRun=true":""}`,Ue("POST",{userVerdict:n})).then(s=>We(s)),claudeReviewChat:(e,n)=>Me(`/api/claude-reviews/${e}/chat${n!=null?`?findingId=${n}`:""}`),askClaudeReviewChat:(e,n)=>fetch(`/api/claude-reviews/${e}/chat`,Ue("POST",n)).then(r=>We(r)),aiFixSummary:e=>Me(`/api/pro/prs/${e}/summary`),refreshAiFixSummary:e=>fetch(`/api/pro/prs/${e}/summary/refresh`,Ue("POST")).then(n=>We(n)),aiFix:e=>Me(`/api/pro/prs/${e}/ai-fix`),aiFixStatus:e=>Me(`/api/pro/prs/${e}/ai-fix/status`),startAiFix:(e,n)=>fetch(`/api/pro/prs/${e}/ai-fix`,Ue("POST",n)).then(r=>We(r)),cancelAiFix:e=>fetch(`/api/pro/prs/${e}/ai-fix/cancel`,Ue("POST")).then(n=>We(n)),pushAiFix:(e,n)=>fetch(`/api/pro/ai-fixes/${e}/push`,Ue("POST",n)).then(r=>We(r)),botReviewers:(e,n)=>Me(pt("/api/bot-reviewers",xt(e),cr(n))),setWorkspaceReviewer:(e,n)=>fetch(`/api/bot-reviewers/${e}`,Ue("PATCH",n)).then(r=>We(r)),resetReviewerJudgement:(e,n)=>fetch(`/api/bot-reviewers/${e}/judgement?workspaceId=${n}`,Ue("DELETE")).then(r=>We(r)),resetReviewerIdentity:(e,n)=>fetch(`/api/bot-reviewers/${e}/identity?workspaceId=${n}`,Ue("DELETE")).then(r=>We(r)),setReviewerCost:(e,n)=>fetch(`/api/bot-reviewers/${e}/cost`,Ue("PUT",n)).then(r=>We(r)),botAnalytics:(e,n,r,s)=>Me(pt("/api/bot-analytics",`window=${encodeURIComponent(e)}`,xt(n),cr(r),s?`fromMs=${s.fromMs}`:void 0,s?`toMs=${s.toMs}`:void 0)),botAuthoring:(e,n,r,s,a)=>Me(pt("/api/bot-authoring",`userId=${n}`,`fromMs=${r.fromMs}`,`toMs=${r.toMs}`,xt(e),cr(a),s?"evidence=1":void 0)),advisorFindings:e=>Me(pt("/api/pro/advisor/findings",xt(e))),advisorBrief:(e,n,r)=>Me(pt("/api/pro/advisor/brief",xt(e),n!=null?`botUserId=${n}`:void 0,r&&r.length>0?`keys=${encodeURIComponent(r.join(","))}`:void 0)),advisorDismiss:(e,n)=>fetch(pt(`/api/pro/advisor/recommendations/${encodeURIComponent(n)}/dismiss`,xt(e)),Ue("POST")).then(r=>We(r)),advisorFileIssue:(e,n)=>fetch(pt(`/api/pro/advisor/recommendations/${encodeURIComponent(n)}/issue`,xt(e)),Ue("POST")).then(r=>We(r)),advisorConfigPr:(e,n)=>fetch(pt("/api/pro/advisor/config-pr",xt(e)),Ue("POST",n)).then(r=>We(r)),advisorPreview:(e,n)=>fetch(pt("/api/pro/advisor/preview",xt(e)),Ue("POST",n)).then(r=>We(r)),advisorRefine:(e,n)=>fetch(pt("/api/pro/advisor/refine",xt(e)),Ue("POST",n)).then(r=>We(r)),advisorEffect:(e,n)=>Me(pt(`/api/pro/advisor/bots/${n}/effect`,xt(e))),advisorDiscovery:(e,n,r)=>Me(pt(`/api/pro/advisor/bots/${n}/discovery`,xt(e),`repoId=${r}`)),advisorPutProfile:(e,n)=>fetch(`/api/pro/advisor/bots/${e}/profile`,Ue("PUT",n)).then(r=>We(r)),advisorConfirmManifest:(e,n)=>fetch(`/api/pro/advisor/bots/${e}/manifest`,Ue("POST",n)).then(r=>We(r)),advisorReportConfigEvent:e=>fetch("/api/pro/advisor/config-events",Ue("POST",e)).then(n=>We(n)),botThemes:(e,n,r)=>Me(pt("/api/pro/bot-themes",`window=${encodeURIComponent(e)}`,xt(n),cr(r))),botThemesRefresh:(e,n,r)=>fetch(pt("/api/pro/bot-themes/refresh",`window=${encodeURIComponent(e)}`,xt(n),cr(r)),Ue("POST")).then(s=>We(s)),humanThemes:(e,n)=>Me(pt("/api/pro/human-themes",`window=${encodeURIComponent(e)}`,xt(n))),humanThemesRefresh:(e,n)=>fetch(pt("/api/pro/human-themes/refresh",`window=${encodeURIComponent(e)}`,xt(n)),Ue("POST")).then(r=>We(r)),botBehaviour:(e,n,r,s)=>Me(pt("/api/pro/bot-behaviour",`window=${encodeURIComponent(e)}`,xt(n),cr(r),s!=null?`botUserId=${s}`:void 0)),botBenchmark:e=>Me(pt("/api/pro/bot-benchmark",e&&e.length>0?`cells=${encodeURIComponent(e.map(n=>`${n.vendor}:${n.band}`).join(","))}`:void 0)),botBenchmarkPlacement:(e,n)=>Me(pt("/api/pro/bot-benchmark/placement",`workspace=${e}`,n?`repoIds=${n.join(",")}`:void 0)),synthesis:e=>Me(pt("/api/pro/synthesis",...mk(e))),synthesisGenerate:e=>fetch(pt("/api/pro/synthesis",...mk(e)),Ue("POST")).then(n=>We(n)),workPlan:e=>Me(pt("/api/pro/work-plan",...gk(e))),workPlanGenerate:e=>fetch(pt("/api/pro/work-plan",...gk(e)),Ue("POST")).then(n=>We(n)),flowPointers:(e,n)=>Me(pt("/api/pro/flow-pointers",xt(e),`days=${n}`)),flowPointersGenerate:(e,n)=>fetch(pt("/api/pro/flow-pointers",xt(e),`days=${n}`),Ue("POST")).then(r=>We(r)),botOnlyPrs:(e,n,r)=>Me(pt("/api/bot-analytics/bot-only-prs",`window=${encodeURIComponent(e)}`,xt(n),cr(r))),botVendorPrs:(e,n,r,s)=>Me(pt(`/api/bot-analytics/vendor/${encodeURIComponent(e)}/prs`,`window=${encodeURIComponent(n)}`,xt(r),cr(s))),botVendorComments:(e,n,r,s,a)=>Me(pt(`/api/bot-analytics/vendor/${encodeURIComponent(e)}/comments`,`window=${encodeURIComponent(n)}`,xt(r),cr(s),a?`fromMs=${a.fromMs}`:void 0,a?`toMs=${a.toMs}`:void 0)),botFlagging:e=>{const n=e.selector.kind==="severity"?[`severities=${encodeURIComponent(e.selector.severities.join(","))}`]:e.selector.kind==="category"?[`category=${encodeURIComponent(e.selector.category)}`]:[],r=[e.refine.cell?`cellVendor=${encodeURIComponent(e.refine.cell.vendor)}&cellOurs=${encodeURIComponent(e.refine.cell.ours)}`:"",e.refine.disagree?`disagree=${encodeURIComponent(e.refine.disagree)}`:"",e.refine.authorUserIds!=null?`authorUserIds=${e.refine.authorUserIds.join(",")}`:""];return Me(pt("/api/bot-analytics/flagging",`select=${encodeURIComponent(e.selector.kind)}`,...n,...r,`window=${encodeURIComponent(e.window)}`,xt(e.workspaceId),cr(e.repoIds),`limit=${e.limit}`,e.cursor?`cursor=${encodeURIComponent(e.cursor)}`:""))},botVolume:(e,n,r)=>Me(pt("/api/bot-analytics/volume",`window=${encodeURIComponent(e)}`,xt(n),cr(r))),botVolumePrs:e=>Me(pt("/api/bot-analytics/volume/prs",`window=${encodeURIComponent(e.window)}`,xt(e.workspaceId),cr(e.repoIds),e.authorUserIds!=null?`authorUserIds=${e.authorUserIds.join(",")}`:"",`sort=${encodeURIComponent(e.sort)}`,`limit=${e.limit}`,e.cursor?`cursor=${encodeURIComponent(e.cursor)}`:"")),botVolumeScatter:(e,n,r)=>Me(pt("/api/bot-analytics/volume/scatter",`window=${encodeURIComponent(e)}`,xt(n),cr(r))),prBotDedup:e=>Me(`/api/prs/${e}/bot-dedup`),prBotBehaviour:e=>Me(`/api/prs/${e}/bot-behaviour`),resolvableBotThreads:(e,n)=>Me(pt("/api/bot-threads/resolvable",xt(e),cr(n))),scopeResolveBotThreads:e=>fetch("/api/bot-threads/resolve",Ue("POST",e)).then(n=>We(n))},fk=e=>{let n;const r=new Set,s=(m,h)=>{const g=typeof m=="function"?m(n):m;if(!Object.is(g,n)){const x=n;n=h??(typeof g!="object"||g===null)?g:Object.assign({},n,g),r.forEach(y=>y(n,x))}},a=()=>n,d={setState:s,getState:a,getInitialState:()=>u,subscribe:m=>(r.add(m),()=>r.delete(m))},u=n=e(s,a,d);return d},s4=(e=>e?fk(e):fk),a4=e=>e;function o4(e,n=a4){const r=Pu.useSyncExternalStore(e.subscribe,Pu.useCallback(()=>n(e.getState()),[e,n]),Pu.useCallback(()=>n(e.getInitialState()),[e,n]));return Pu.useDebugValue(r),r}const xk=e=>{const n=s4(e),r=s=>o4(n,s);return Object.assign(r,n),r},Jo=(e=>e?xk(e):xk),i4=["activity","open-prs","timeline"];function Nh(e){return i4.includes(e)}const nh=e=>`pr-detail:${e}`,l4=e=>`pr-focus:${e}`,c4="metrics-detail",d4="bot-prs",u4="bot-only-prs",h4="bot-threads",p4="bot-flagging",m4="bot-volume",g4="theme-threads",f4="search",x4="people-report",y4=e=>`user-activity:${e}`;function pp(e){const n=/^user-activity:(\d+)$/.exec(e);return n?Number(n[1]):null}const b4=e=>`bot-detail:${e}`;function mp(e){const n=/^bot-detail:(\d+)$/.exec(e);return n?Number(n[1]):null}function iS(e,n){if(Nh(e))return null;const r=n.find(s=>s.key===e);return(r==null?void 0:r.kind)==="pr-focus"?{kind:"isolate",prId:r.prId}:null}function Go(e){const n=/^(pr-detail|pr-focus):(\d+)$/.exec(e);return n?{kind:n[1],prId:Number(n[2])}:null}const gx="pierre:tabs",lS="pierre:pinnedTabs";function yk(e){return{id:e.id,number:typeof e.number=="number"?e.number:0,title:typeof e.title=="string"?e.title:"",repoFullName:typeof e.repoFullName=="string"?e.repoFullName:"",authorLogin:typeof e.authorLogin=="string"?e.authorLogin:null,authorDisplayName:typeof e.authorDisplayName=="string"?e.authorDisplayName:null,authorAvatarUrl:typeof e.authorAvatarUrl=="string"?e.authorAvatarUrl:null}}function v4(){try{const e=localStorage.getItem(gx);if(e){const r=JSON.parse(e);if(Array.isArray(r))return r.filter(s=>s!=null&&typeof s=="object"&&typeof s.key=="string").map(s=>{const a=Go(s.key);return a?{key:s.key,kind:a.kind,prId:a.prId,meta:s.meta!=null&&typeof s.meta=="object"?yk(s.meta):null}:null}).filter(s=>s!=null)}const n=localStorage.getItem(lS);if(n){const r=JSON.parse(n);if(Array.isArray(r))return r.filter(s=>s!=null&&typeof s=="object"&&typeof s.id=="number").map(s=>{const a=yk(s);return{key:nh(a.id),kind:"pr-detail",prId:a.id,meta:a}})}}catch{}return[]}function Eo(e){try{localStorage.setItem(gx,JSON.stringify(e.filter(n=>n.kind==="pr-detail"||n.kind==="pr-focus")))}catch{}}function k4(e,n){return e.number===n.number&&e.title===n.title&&e.repoFullName===n.repoFullName&&e.authorLogin===n.authorLogin&&e.authorDisplayName===n.authorDisplayName&&e.authorAvatarUrl===n.authorAvatarUrl}const Ge=Jo((e,n)=>{const r=(s,a)=>{const i=n(),c=(a==null?void 0:a.fromActivity)??i.activeTab==="activity",d=i.tabs.some(m=>m.key===s.key),u=d?i.tabs.map(m=>m.key===s.key&&s.meta!=null?{...m,meta:s.meta}:m):[...i.tabs,s];(!d||s.meta!=null)&&Eo(u),e({tabs:u,activeTab:s.key,activityReturnItemId:c?(a==null?void 0:a.returnItemId)??null:i.activityReturnItemId})};return{tabs:v4(),activeTab:"timeline",activityReturnItemId:null,activityFlashItemId:null,pin:s=>e(a=>{const i=nh(s.id);if(a.tabs.some(d=>d.key===i))return a;const c=[...a.tabs,{key:i,kind:"pr-detail",prId:s.id,meta:s}];return Eo(c),{tabs:c}}),openPrDetailTab:(s,a)=>r({key:nh(s.id),kind:"pr-detail",prId:s.id,meta:s},a),openPrFocusTab:(s,a)=>r({key:l4(s.id),kind:"pr-focus",prId:s.id,meta:s},a),openMetricsTab:s=>r({key:c4,kind:"metrics-detail",prId:0,meta:null},s),openBotPrsTab:s=>r({key:d4,kind:"bot-prs",prId:0,meta:null},s),openBotOnlyPrsTab:s=>r({key:u4,kind:"bot-only-prs",prId:0,meta:null},s),openBotThreadsTab:s=>r({key:h4,kind:"bot-threads",prId:0,meta:null},s),openBotFlaggingTab:s=>r({key:p4,kind:"bot-flagging",prId:0,meta:null},s),openBotVolumeTab:s=>r({key:m4,kind:"bot-volume",prId:0,meta:null},s),openThemeThreadsTab:s=>r({key:g4,kind:"theme-threads",prId:0,meta:null},s),openSearchTab:s=>r({key:f4,kind:"search",prId:0,meta:null},s),openPeopleReportTab:s=>r({key:x4,kind:"people-report",prId:0,meta:null},s),openUserActivityTab:(s,a,i)=>r({key:y4(s),kind:"user-activity",prId:0,meta:null,userMeta:a},i),openBotDetailTab:(s,a,i)=>r({key:b4(s),kind:"bot-detail",prId:0,meta:null,botMeta:a},i),syncMeta:s=>e(a=>{let i=!1;const c=a.tabs.map(d=>d.prId!==s.id||d.meta!=null&&k4(d.meta,s)?d:(i=!0,{...d,meta:s}));return i?(Eo(c),{tabs:c}):a}),closeTab:s=>e(a=>{const i=a.tabs.findIndex(u=>u.key===s);if(i===-1)return a;const c=a.tabs.filter(u=>u.key!==s);if(Eo(c),a.activeTab!==s)return{tabs:c};const d=i-1>=0?a.tabs[i-1].key:c.length>0?c[0].key:"timeline";return{tabs:c,activeTab:d}}),moveTab:(s,a)=>e(i=>{const c=i.tabs.findIndex(h=>h.key===s);if(c===-1)return i;const d=Math.max(0,Math.min(i.tabs.length-1,a));if(d===c)return i;const u=[...i.tabs],[m]=u.splice(c,1);return u.splice(d,0,m),Eo(u),{tabs:u}}),closeOtherTabs:s=>e(a=>{const i=a.tabs.find(u=>u.key===s);if(!i||a.tabs.length<=1)return a;const c=[i];Eo(c);const d=Nh(a.activeTab)||a.activeTab===s?a.activeTab:s;return{tabs:c,activeTab:d}}),closeAllTabs:()=>e(s=>{if(s.tabs.length===0)return s;Eo([]);const a=Nh(s.activeTab)?s.activeTab:"timeline";return{tabs:[],activeTab:a}}),unpin:s=>n().closeTab(nh(s)),setActiveTab:s=>e({activeTab:s}),showTimeline:()=>{n().activeTab!=="timeline"&&e({activeTab:"timeline"})},showBoardFromDetail:()=>{n().activeTab!=="timeline"&&e({activeTab:"timeline"})},showActivity:()=>{n().activeTab!=="activity"&&e({activeTab:"activity"})},showOpenPrs:()=>{n().activeTab!=="open-prs"&&e({activeTab:"open-prs"})},applyUrlTab:(s,a)=>e(i=>{const c=!i.tabs.some(g=>g.key===s),d=Go(s),u=c?d!=null?{key:s,kind:d.kind,prId:d.prId,meta:null}:pp(s)!=null?{key:s,kind:"user-activity",prId:0,meta:null,userMeta:null}:mp(s)!=null?{key:s,kind:"bot-detail",prId:0,meta:null,botMeta:null}:null:null,m=u!=null?[...i.tabs,u]:i.tabs;m!==i.tabs&&Eo(m);const h=(a==null?void 0:a.fromPop)===!0&&s==="activity"&&i.activityReturnItemId!=null;return{tabs:m,activeTab:s,...h?{activityFlashItemId:i.activityReturnItemId,activityReturnItemId:null}:{}}}),clearActivityFlashItem:()=>{n().activityFlashItemId!=null&&e({activityFlashItemId:null})},clear:()=>{try{localStorage.removeItem(gx),localStorage.removeItem(lS)}catch{}e({tabs:[],activeTab:"timeline",activityReturnItemId:null,activityFlashItemId:null})}}}),w4=["overview","bottlenecks"],j4=["roi","themes","advisor","settings","benchmark"],N4=["overview","threads","activity","changes","bot_activity","claude_review","ai_fix"];function S4(e){return`ws:${e}`}const pd=["review_comments","pr_comments","commits"],Sh=pd.filter(e=>e!=="commits"),md=x$,Kl=y$,Ch=[...Kl],Rh=md.filter(e=>e!=="closed"),bk=1440*60*1e3,C4={"7d":7,"14d":14,"30d":30,"90d":90},vk=8;let cS=null;function kk(e){cS=e}function Ih(){return cS}function bi(e,n){return e.includes(n)?e.filter(r=>r!==n):[...e,n]}function gp(){return{repoIds:null,userIds:null,excludeBots:!0,allowedBotIds:[],excludeStale:!0,preset:"14d",customFrom:null,customTo:null,categories:[...Sh],prStatuses:[...Rh],reviewStates:[...Ch],derivedStates:[],feedCiLens:"off"}}function R4(e){return{repoIds:e.repoIds,userIds:e.userIds,excludeBots:e.excludeBots,allowedBotIds:e.allowedBotIds,excludeStale:e.excludeStale,preset:e.preset,customFrom:e.customFrom,customTo:e.customTo,categories:e.categories,prStatuses:e.prStatuses,reviewStates:e.reviewStates,derivedStates:e.derivedStates,feedCiLens:e.feedCiLens}}function I4(e){const n=gp(),r={};for(const s of Object.keys(n))s in e&&e[s]!==void 0&&(r[s]=e[s]);return r.feedCiLens!==void 0&&r.feedCiLens!=="feed"&&r.feedCiLens!=="only"&&r.feedCiLens!=="off"&&delete r.feedCiLens,r}function T4(e){return{workspaceId:e.workspaceId}}function $4(e){if(!e||typeof e!="object")return{};const n=e.workspaceId;return typeof n!="number"||!Number.isInteger(n)||n<=0?{}:{workspaceId:n}}function dS(){return{...gp(),workspaceId:null,feedMyTurnOnly:!1,feedClaudeOnly:!1,feedBotLens:"hide",feedCatComments:!1,feedCatPrEvents:!1,feedPrEventKinds:[],feedNeedsReview:!1,feedShowCommits:!1,feedIsolatedPrId:null,attentionIsolation:null,attentionRelevance:null,attentionAuthorLens:null,attentionTab:null,feedNewCohorts:{scopeKey:null,cohorts:[]},botAnalyticsWindow:"rolling_14",botsInnerTab:"roi",advisorFocus:null,feedInnerTab:"feed",insightsInnerTab:"overview",prDetailTab:null,sprintChatDraft:{question:"",wantChart:!1,wantBots:!1},sprintChatThreads:{},selectedPrId:null,selectedThreadId:null,insightsReportKey:null,insightsReportGrain:"sprint",threadBotFilter:null,threadStateFilter:new Set,threadSeverityFilter:new Set,selectedCommentId:null,activityFocus:null,commentFocus:null,claudeTabFocus:null,aiFixTabFocus:null,metricsFocus:null,botPrsFocusKey:null,botPrsFocusRepoId:null,openPrsRepoFilter:null,botOnlyFocusRepoId:null,botThreadsFocusRepoId:null,themeThreadsSeed:null,searchSeed:null,botFlaggingSeed:null,botVolumeSeed:null,peopleReportSeed:null,activityRepoId:"attention",activityThreadFilter:null,repoConsoleTabs:{},expandedFileGroups:[],collapsedFileGroups:[],expandedDiffHunks:[],timelineFocusPr:null,timelineFocusAt:null,timelineFocusEvent:null,timelineCenterAt:null,rangeResetSignal:0,syncModalSignal:0,syncModalRepoIds:[],syncRound:{open:!1,modal:!1,syncing:!1,cancelling:!1,scopeIds:[]},managerOpen:!1,claudeReviewKickoff:0,aiFixRuns:{}}}function _4(){const e=dS();return{activityRepoId:e.activityRepoId,insightsReportKey:e.insightsReportKey,insightsReportGrain:e.insightsReportGrain,selectedPrId:e.selectedPrId,selectedThreadId:e.selectedThreadId,attentionIsolation:e.attentionIsolation,attentionRelevance:e.attentionRelevance,attentionAuthorLens:e.attentionAuthorLens,attentionTab:e.attentionTab,feedIsolatedPrId:e.feedIsolatedPrId,prDetailTab:e.prDetailTab,feedInnerTab:e.feedInnerTab,botsInnerTab:e.botsInnerTab,insightsInnerTab:e.insightsInnerTab}}const G=Jo((e,n)=>({...dS(),setRepoIds:r=>e({repoIds:r}),setWorkspace:(r,s)=>e({workspaceId:r,repoIds:s,feedIsolatedPrId:null,attentionIsolation:null,attentionRelevance:null,attentionAuthorLens:null}),toggleRepo:r=>e(s=>({repoIds:bi(s.repoIds??[],r)})),showRepo:r=>{const{repoIds:s}=n();s==null||s.includes(r)||e({repoIds:[...s,r]})},setUserIds:r=>e({userIds:r}),setExcludeBots:r=>e({excludeBots:r}),setAllowedBotIds:r=>e({allowedBotIds:r}),toggleAllowedBot:r=>e(s=>({allowedBotIds:bi(s.allowedBotIds,r)})),setExcludeStale:r=>e({excludeStale:r}),setPreset:r=>e(s=>({preset:r,rangeResetSignal:s.rangeResetSignal+1})),setCustomRange:(r,s)=>e({preset:"custom",customFrom:r,customTo:s}),toggleCategory:r=>e(s=>({categories:bi(s.categories,r)})),setCategories:r=>e({categories:r}),togglePrStatus:r=>e(s=>({prStatuses:bi(s.prStatuses,r)})),setPrStatuses:r=>e({prStatuses:r}),toggleReviewState:r=>e(s=>({reviewStates:bi(s.reviewStates,r)})),setReviewStates:r=>e({reviewStates:r}),toggleDerivedState:r=>e(s=>({derivedStates:bi(s.derivedStates,r)})),setDerivedStates:r=>e({derivedStates:r}),toggleFeedMyTurnOnly:()=>e(r=>({feedMyTurnOnly:!r.feedMyTurnOnly,feedClaudeOnly:!1})),setFeedMyTurnOnly:r=>e(r?{feedMyTurnOnly:!0,feedClaudeOnly:!1}:{feedMyTurnOnly:!1}),toggleFeedClaudeOnly:()=>e(r=>({feedClaudeOnly:!r.feedClaudeOnly,feedMyTurnOnly:!1})),setFeedClaudeOnly:r=>e(r?{feedClaudeOnly:!0,feedMyTurnOnly:!1}:{feedClaudeOnly:!1}),cycleFeedBotLens:()=>e(r=>({feedBotLens:r.feedBotLens==="all"?"hide":r.feedBotLens==="hide"?"only":"all"})),setFeedBotLens:r=>e({feedBotLens:r}),toggleFeedCatComments:()=>e(r=>({feedCatComments:!r.feedCatComments})),toggleFeedCatPrEvents:()=>e(r=>({feedCatPrEvents:!r.feedCatPrEvents})),toggleFeedPrEventKind:r=>e(s=>({feedPrEventKinds:s.feedPrEventKinds.includes(r)?s.feedPrEventKinds.filter(a=>a!==r):[...s.feedPrEventKinds,r]})),toggleFeedNeedsReview:()=>e(r=>({feedNeedsReview:!r.feedNeedsReview})),toggleFeedShowCommits:()=>e(r=>({feedShowCommits:!r.feedShowCommits})),cycleFeedCiLens:()=>e(r=>({feedCiLens:r.feedCiLens==="feed"?"only":r.feedCiLens==="only"?"off":"feed"})),setFeedCiLens:r=>e({feedCiLens:r}),setFeedIsolatedPrId:r=>e({feedIsolatedPrId:r}),setAttentionIsolation:r=>e({attentionIsolation:r}),setAttentionRelevance:r=>e({attentionRelevance:r}),setAttentionAuthorLens:r=>e({attentionAuthorLens:r}),setAttentionTab:(r,s=null)=>e({attentionTab:r,attentionIsolation:s}),openMyTurnInWorkspace:r=>{const s=n();s.workspaceId!==r&&s.setWorkspace(r,null),Ge.getState().showActivity(),s.setActivityRepo("attention"),s.setAttentionIsolation("my_turn"),s.setAttentionRelevance("mine"),s.setAttentionAuthorLens(null)},switchWorkspaceToPending:r=>{const s=n();s.setWorkspace(r,null),Ge.getState().showActivity(),s.setActivityRepo("attention"),e({attentionTab:null}),s.clearSelection()},pushFeedNewCohort:(r,s,a)=>e(i=>{if(s.length===0)return{};const d=[...(i.feedNewCohorts.scopeKey===r?i.feedNewCohorts.cohorts:[]).filter(u=>!u.seen),{ids:s,seen:a}];return{feedNewCohorts:{scopeKey:r,cohorts:d.length>vk?d.slice(d.length-vk):d}}}),markFeedNewCohortsSeen:r=>e(s=>{const a=s.feedNewCohorts;return a.scopeKey!==r||a.cohorts.every(i=>i.seen)?{}:{feedNewCohorts:{scopeKey:a.scopeKey,cohorts:a.cohorts.map(i=>i.seen?i:{...i,seen:!0})}}}),setBotAnalyticsWindow:r=>e({botAnalyticsWindow:r}),setBotsInnerTab:r=>e({botsInnerTab:r}),focusAdvisor:(r,s)=>e({advisorFocus:{botKey:r,intent:s},botsInnerTab:"advisor"}),clearAdvisorFocus:()=>e({advisorFocus:null}),setFeedInnerTab:r=>e({feedInnerTab:r}),setInsightsInnerTab:r=>e({insightsInnerTab:r}),setPrDetailTab:(r,s)=>e(a=>{var i;return((i=a.prDetailTab)==null?void 0:i.prId)===r&&a.prDetailTab.tab===s?{}:{prDetailTab:{prId:r,tab:s}}}),setSprintChatDraft:r=>e(s=>({sprintChatDraft:{...s.sprintChatDraft,...r}})),appendSprintChatTurn:(r,s)=>e(a=>({sprintChatThreads:{...a.sprintChatThreads,[r]:[...a.sprintChatThreads[r]??[],s]}})),setSprintChatThread:(r,s)=>e(a=>({sprintChatThreads:{...a.sprintChatThreads,[r]:s}})),setThreadBotFilter:r=>e(s=>({threadBotFilter:s.threadBotFilter===r?null:r})),toggleThreadStateFilter:r=>e(s=>{const a=new Set(s.threadStateFilter);return a.has(r)?a.delete(r):a.add(r),{threadStateFilter:a}}),setThreadStateFilter:r=>e({threadStateFilter:r}),toggleThreadSeverityFilter:r=>e(s=>{const a=new Set(s.threadSeverityFilter);return a.has(r)?a.delete(r):a.add(r),{threadSeverityFilter:a}}),setThreadSeverityFilter:r=>e({threadSeverityFilter:r}),selectPr:r=>e({selectedPrId:r,selectedThreadId:null,selectedCommentId:null,threadBotFilter:null,threadStateFilter:new Set,threadSeverityFilter:new Set}),selectThread:(r,s)=>e(a=>({selectedPrId:r??a.selectedPrId,selectedThreadId:s,selectedCommentId:null,threadStateFilter:s!=null?new Set:a.threadStateFilter,threadSeverityFilter:s!=null?new Set:a.threadSeverityFilter})),clearSelection:()=>e({selectedPrId:null,selectedThreadId:null,selectedCommentId:null,threadBotFilter:null,threadStateFilter:new Set,threadSeverityFilter:new Set}),openPrFocused:(r,s=null,a=null,i=null)=>{Ge.getState().showBoardFromDetail(),e(c=>({selectedPrId:r,selectedThreadId:s,selectedCommentId:null,timelineFocusPr:r,timelineFocusAt:a,timelineFocusEvent:i,threadStateFilter:s!=null?new Set:c.threadStateFilter,threadSeverityFilter:s!=null?new Set:c.threadSeverityFilter}))},showEventOnTimeline:(r,s,a)=>{Ge.getState().showBoardFromDetail(),e({selectedPrId:r,timelineFocusPr:r,timelineFocusAt:s,timelineFocusEvent:a})},focusEventInTab:(r,s,a,i=null)=>e({selectedPrId:r,selectedThreadId:i,selectedCommentId:null,timelineFocusPr:r,timelineFocusAt:s,timelineFocusEvent:a}),consumeTimelineFocus:()=>e({timelineFocusPr:null,timelineFocusAt:null,timelineFocusEvent:null}),centerTimelineNow:()=>{Ge.getState().showTimeline(),e({timelineCenterAt:Date.now()})},consumeTimelineCenter:()=>e({timelineCenterAt:null}),showActivityEntry:(r,s)=>e({selectedPrId:r,selectedThreadId:null,selectedCommentId:null,activityFocus:{prId:r,...s}}),consumeActivityFocus:()=>e({activityFocus:null}),showPrComment:(r,s)=>e({selectedPrId:r,selectedThreadId:null,selectedCommentId:s,commentFocus:{prId:r,commentId:s}}),consumeCommentFocus:()=>e({commentFocus:null}),openClaudeReview:(r,s)=>{Ge.getState().openPrDetailTab(r,s),e({selectedPrId:r.id,selectedThreadId:null,selectedCommentId:null,claudeTabFocus:{prId:r.id}})},consumeClaudeTabFocus:()=>e({claudeTabFocus:null}),openAiFixFromReview:(r,s)=>e({selectedPrId:r,selectedThreadId:null,selectedCommentId:null,aiFixTabFocus:{prId:r,reviewId:s}}),openAiFix:r=>{Ge.getState().openPrDetailTab(r),e({selectedPrId:r.id,selectedThreadId:null,selectedCommentId:null,aiFixTabFocus:{prId:r.id}})},consumeAiFixTabFocus:()=>e({aiFixTabFocus:null}),noteAiFixRun:r=>e(s=>({aiFixRuns:{...s.aiFixRuns,[r.prId]:{...r,startedAt:Date.now(),status:"queued"}}})),setAiFixRunStatus:(r,s)=>e(a=>{const i=a.aiFixRuns[r];return!i||i.status===s?{}:{aiFixRuns:{...a.aiFixRuns,[r]:{...i,status:s}}}}),dismissAiFixRun:r=>e(s=>{if(!(r in s.aiFixRuns))return{};const a={...s.aiFixRuns};return delete a[r],{aiFixRuns:a}}),openMetricsDetail:r=>{e({metricsFocus:r}),Ge.getState().openMetricsTab({fromActivity:!0})},consumeMetricsFocus:()=>e({metricsFocus:null}),openBotPrsDetail:(r,s)=>{e({botPrsFocusKey:r,botPrsFocusRepoId:s??null}),Ge.getState().openBotPrsTab({fromActivity:!0})},consumeBotPrsFocus:()=>e({botPrsFocusKey:null}),openOpenPrsDetail:r=>{e({openPrsRepoFilter:r!=null?{workspaceId:n().workspaceId,repoIds:[r]}:null}),Ge.getState().showOpenPrs()},setOpenPrsRepoFilter:r=>e({openPrsRepoFilter:r!=null?{workspaceId:n().workspaceId,repoIds:r}:null}),openBotOnlyDetail:r=>{e({botOnlyFocusRepoId:r}),Ge.getState().openBotOnlyPrsTab({fromActivity:!0})},openBotThreadsDetail:r=>{e({botThreadsFocusRepoId:r}),Ge.getState().openBotThreadsTab({fromActivity:!0})},openThemeThreadsDetail:(r,s)=>{e({themeThreadsSeed:{theme:r,source:s}}),Ge.getState().openThemeThreadsTab({fromActivity:!0})},openPeopleReport:(r,s,a)=>{e({peopleReportSeed:{workspaceId:r,periodKey:s,selections:a}}),Ge.getState().openPeopleReportTab({fromActivity:!0})},openBotFlaggingDetail:(r,s,a)=>{e({botFlaggingSeed:{selector:r,repoId:s,bots:(a==null?void 0:a.bots)??null,disagree:(a==null?void 0:a.disagree)??null}}),Ge.getState().openBotFlaggingTab({fromActivity:!0})},setBotFlaggingBots:r=>{const s=n().botFlaggingSeed;s&&e({botFlaggingSeed:{...s,bots:r}})},clearBotFlaggingRefine:()=>{const r=n().botFlaggingSeed;r&&e({botFlaggingSeed:{...r,bots:null,disagree:null}})},setBotFlaggingSelector:r=>{const s=n().botFlaggingSeed;s&&e({botFlaggingSeed:{...s,selector:r}})},openBotVolumeDetail:(r,s)=>{e({botVolumeSeed:{repoId:r,bots:s??null}}),Ge.getState().openBotVolumeTab({fromActivity:!0})},setBotVolumeBots:r=>{const s=n().botVolumeSeed;s&&e({botVolumeSeed:{...s,bots:r}})},openSearchDetail:r=>{e({searchSeed:r}),Ge.getState().openSearchTab()},openPrThreadsFiltered:(r,s)=>{Ge.getState().openPrDetailTab(r,{fromActivity:!0}),e({selectedPrId:r.id,selectedThreadId:null,selectedCommentId:null,threadBotFilter:null,threadStateFilter:new Set([s]),threadSeverityFilter:new Set})},requestSyncModal:r=>e(s=>({syncModalSignal:s.syncModalSignal+1,syncModalRepoIds:s.syncModalRepoIds.includes(r)?s.syncModalRepoIds:[...s.syncModalRepoIds,r]})),setSyncRound:r=>e(s=>({syncRound:{...s.syncRound,...r}})),setManagerOpen:r=>e({managerOpen:r}),bumpClaudeReviewKickoff:()=>e(r=>({claudeReviewKickoff:r.claudeReviewKickoff+1})),setActivityRepo:r=>e(s=>s.activityRepoId===r?{}:{activityRepoId:r,activityThreadFilter:null,feedIsolatedPrId:null,attentionIsolation:null,attentionRelevance:null,attentionAuthorLens:null,attentionTab:null}),setActivityThreadFilter:r=>e(s=>({activityThreadFilter:s.activityThreadFilter===r?null:r})),setRepoConsoleTab:(r,s)=>e(a=>({repoConsoleTabs:{...a.repoConsoleTabs,[r]:s}})),setInsightsReportKey:r=>e({insightsReportKey:r}),setInsightsReportGrain:r=>e(s=>s.insightsReportGrain===r?{}:{insightsReportGrain:r,insightsReportKey:null}),toggleFileGroup:(r,s)=>e(a=>{const i=s?!a.collapsedFileGroups.includes(r):a.expandedFileGroups.includes(r);return s?{collapsedFileGroups:i?[...a.collapsedFileGroups,r]:a.collapsedFileGroups.filter(c=>c!==r)}:{expandedFileGroups:i?a.expandedFileGroups.filter(c=>c!==r):[...a.expandedFileGroups,r]}}),toggleDiffHunk:r=>e(s=>({expandedDiffHunks:bi(s.expandedDiffHunks,r)})),resetAllFilters:()=>e(r=>({...gp(),rangeResetSignal:r.rangeResetSignal+1})),hydrate:r=>e(r)}));function rh(e){return P4(e)}function P4(e){if(e.preset==="custom"&&(e.customFrom||e.customTo)){const s=e.customTo?new Date(`${e.customTo}T23:59:59Z`):new Date;return{from:e.customFrom?new Date(`${e.customFrom}T00:00:00Z`):new Date(s.getTime()-14*bk),to:s}}const n=C4[e.preset==="custom"?"14d":e.preset],r=new Date;return{from:new Date(r.getTime()-n*bk),to:r}}function fx(e){const n=new Set(e);return n.add("lifecycle"),n.add("reviews"),Object.keys(ak).filter(r=>n.has(ak[r]))}function wk(e){return new Date(Math.floor(e.getTime()/6e4)*6e4)}function uS(e,n=!0){const r=new URLSearchParams;return e.workspaceId!=null&&r.set("workspace",String(e.workspaceId)),e.repoIds&&r.set("repoIds",e.repoIds.join(",")),n&&e.userIds&&e.userIds.length>0&&r.set("userIds",e.userIds.join(",")),r.toString()}function hS(e,n=!0,r=!0,s=!0,a=!0,i,c=!0,d){if(d&&d.length>0)return`prIds=${d.join(",")}`;const{from:u,to:m}=rh(e),h=i!=null&&i<u.getTime()?new Date(i):u,g=new URLSearchParams;return e.workspaceId!=null&&g.set("workspace",String(e.workspaceId)),g.set("from",wk(h).toISOString()),g.set("to",wk(m).toISOString()),e.repoIds&&g.set("repoIds",e.repoIds.join(",")),n&&e.userIds&&e.userIds.length>0&&g.set("userIds",e.userIds.join(",")),e.categories.length<pd.length&&g.set("types",fx(e.categories).join(",")),r&&e.prStatuses.length<md.length&&g.set("statuses",e.prStatuses.join(",")),a&&e.reviewStates.length<Kl.length&&g.set("reviewStates",e.reviewStates.join(",")),c?(g.set("excludeBots",String(e.excludeBots)),e.excludeBots&&e.allowedBotIds.length>0&&g.set("allowBotIds",e.allowedBotIds.join(","))):g.set("excludeBots","false"),s&&e.excludeStale&&g.set("excludeStale","true"),g.toString()}const ac=["activity","consolidated-feed","feed-head","repo-digests","workspace-insights","sprint-report","branch-status","attention-cards","daily-brief","work-plan"];function dt(e){return e==null?"ws:pending":S4(e)}function E4(e,n,r){const s=new URLSearchParams;return e!=null&&s.set("workspace",String(e)),s.toString()}const fn=1e3*60*45;function A4(e,n,r){const s=E4(e);return Oe({queryKey:["activity",dt(e),s],queryFn:()=>he.inbox(s),enabled:e!=null,staleTime:1/0,gcTime:fn,refetchOnMount:!1,placeholderData:a=>a})}function xn(){return Oe({queryKey:["repos"],queryFn:he.listRepos})}function An(){return Oe({queryKey:["users"],queryFn:he.listUsers})}function fp(){return Oe({queryKey:["mergers"],queryFn:he.mergers})}function pS(e){var a;const n=G(i=>hS(i,!(e!=null&&e.dropMembers),!0,!0,!0,(e==null?void 0:e.fromMs)??null,!0,e==null?void 0:e.prIds)),r=G(i=>i.workspaceId),s=(((a=e==null?void 0:e.prIds)==null?void 0:a.length)??0)>0;return Oe({queryKey:s?["timeline",n]:["timeline",dt(r),n],queryFn:()=>he.timeline(n),enabled:s||r!=null,placeholderData:i=>i})}function mS(e){const n=G(s=>hS(s,!1,!1,!1,!1,null,!1)),r=G(s=>s.workspaceId);return Oe({queryKey:["timeline",dt(r),n],queryFn:()=>he.timeline(n),enabled:r!=null&&((e==null?void 0:e.enabled)??!0),placeholderData:s=>s})}function M4(e,n){const r=new URLSearchParams;return e!=null&&r.set("workspace",String(e)),n!=null&&(r.set("from",new Date(n.fromMs).toISOString()),r.set("to",new Date(n.toMs).toISOString())),r.set("excludeBots","false"),r.toString()}function L4(e){const n=G(s=>s.workspaceId),r=M4(n,e);return Oe({queryKey:["timeline",dt(n),r],queryFn:()=>he.timeline(r),enabled:n!=null&&e!=null,placeholderData:s=>s})}function lt({size:e,className:n,title:r,children:s,strokeWidth:a=2,variant:i="stroke"}){const c=i==="solid";return t.jsxs("svg",{viewBox:"0 0 24 24",width:e,height:e,fill:c?"currentColor":"none",stroke:c?"none":"currentColor",strokeWidth:c?void 0:a,strokeLinecap:"round",strokeLinejoin:"round",className:n,"aria-hidden":r==null?!0:void 0,role:r!=null?"img":void 0,children:[r!=null&&t.jsx("title",{children:r}),s]})}function eo({size:e=14,...n}){return t.jsxs(lt,{size:e,...n,children:[t.jsx("circle",{cx:"11",cy:"11",r:"8"}),t.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]})}function F4({size:e=15,...n}){return t.jsxs(lt,{size:e,...n,children:[t.jsx("line",{x1:"4",y1:"7",x2:"14",y2:"7"}),t.jsx("line",{x1:"9",y1:"12",x2:"20",y2:"12"}),t.jsx("line",{x1:"4",y1:"17",x2:"12",y2:"17"})]})}function O4({size:e=15,...n}){return t.jsx(lt,{size:e,variant:"solid",...n,children:t.jsx("path",{d:"M12 .5C5.37.5 0 5.87 0 12.5c0 5.3 3.44 9.8 8.21 11.39.6.11.82-.26.82-.58 0-.29-.01-1.05-.02-2.06-3.34.73-4.04-1.61-4.04-1.61-.55-1.39-1.34-1.76-1.34-1.76-1.09-.75.08-.73.08-.73 1.21.09 1.85 1.24 1.85 1.24 1.07 1.84 2.81 1.31 3.5 1 .11-.78.42-1.31.76-1.61-2.67-.3-5.47-1.34-5.47-5.95 0-1.31.47-2.39 1.24-3.23-.12-.3-.54-1.53.12-3.18 0 0 1.01-.32 3.3 1.23a11.5 11.5 0 0 1 6 0c2.29-1.55 3.3-1.23 3.3-1.23.66 1.65.24 2.88.12 3.18.77.84 1.24 1.92 1.24 3.23 0 4.62-2.81 5.64-5.49 5.94.43.37.81 1.1.81 2.22 0 1.6-.01 2.9-.01 3.29 0 .32.22.7.83.58A12 12 0 0 0 24 12.5C24 5.87 18.63.5 12 .5z"})})}function _t({size:e=13,...n}){return t.jsxs(lt,{size:e,...n,children:[t.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),t.jsx("polyline",{points:"15 3 21 3 21 9"}),t.jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]})}const D4={up:"6 15 12 9 18 15",down:"6 9 12 15 18 9",left:"15 6 9 12 15 18",right:"9 6 15 12 9 18"};function Mt({dir:e="down",size:n=12,...r}){return t.jsx(lt,{size:n,strokeWidth:2.5,...r,children:t.jsx("polyline",{points:D4[e]})})}const B4={down:"M5 8.5h14L12 17.5z",up:"M5 15.5h14L12 6.5z",right:"M8.5 5v14L17.5 12z",left:"M15.5 5v14L6.5 12z"};function Cr({dir:e="down",size:n=10,...r}){return t.jsx(lt,{size:n,variant:"solid",...r,children:t.jsx("path",{d:B4[e]})})}const W4={up:t.jsxs(t.Fragment,{children:[t.jsx("line",{x1:"12",y1:"20",x2:"12",y2:"5"}),t.jsx("polyline",{points:"5.5 11.5 12 5 18.5 11.5"})]}),down:t.jsxs(t.Fragment,{children:[t.jsx("line",{x1:"12",y1:"4",x2:"12",y2:"19"}),t.jsx("polyline",{points:"5.5 12.5 12 19 18.5 12.5"})]}),left:t.jsxs(t.Fragment,{children:[t.jsx("line",{x1:"20",y1:"12",x2:"5",y2:"12"}),t.jsx("polyline",{points:"11.5 5.5 5 12 11.5 18.5"})]}),right:t.jsxs(t.Fragment,{children:[t.jsx("line",{x1:"4",y1:"12",x2:"19",y2:"12"}),t.jsx("polyline",{points:"12.5 5.5 19 12 12.5 18.5"})]})};function _s({dir:e="right",size:n=12,...r}){return t.jsx(lt,{size:n,...r,children:W4[e]})}function q4({dir:e="down",size:n=14,...r}){return t.jsx(lt,{size:n,...r,children:e==="down"?t.jsxs(t.Fragment,{children:[t.jsx("line",{x1:"3",y1:"4",x2:"21",y2:"4",strokeDasharray:"3 3"}),t.jsx("line",{x1:"12",y1:"9",x2:"12",y2:"21"}),t.jsx("polyline",{points:"7 16 12 21 17 16"})]}):t.jsxs(t.Fragment,{children:[t.jsx("line",{x1:"3",y1:"20",x2:"21",y2:"20",strokeDasharray:"3 3"}),t.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"}),t.jsx("polyline",{points:"7 8 12 3 17 8"})]})})}function U4({size:e=14,...n}){return t.jsxs(lt,{size:e,...n,children:[t.jsx("line",{x1:"3",y1:"12",x2:"21",y2:"12",strokeDasharray:"3 3"}),t.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"2"}),t.jsx("polyline",{points:"8 5 12 1.5 16 5"}),t.jsx("line",{x1:"12",y1:"16",x2:"12",y2:"22"}),t.jsx("polyline",{points:"8 19 12 22.5 16 19"})]})}function Zt({size:e=12,...n}){return t.jsxs(lt,{size:e,strokeWidth:2.2,...n,children:[t.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"}),t.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"})]})}function H4({size:e=13,...n}){return t.jsx(lt,{size:e,...n,children:t.jsx("path",{d:"M3.5 5h17l-6.6 7.7v5.8l-3.8 2.4v-8.2z"})})}function xp({size:e=13,...n}){return t.jsxs(lt,{size:e,strokeWidth:1.8,...n,children:[t.jsx("path",{d:"M12 2.5 21.5 12 12 21.5 2.5 12z"}),t.jsx("path",{d:"M12 8.4 15.6 12 12 15.6 8.4 12z"})]})}function z4({size:e=13,...n}){return t.jsxs(lt,{size:e,strokeWidth:1.8,...n,children:[t.jsx("circle",{cx:"12",cy:"12",r:"3.2"}),t.jsx("path",{d:"M19.1 14.4a1.5 1.5 0 0 0 .3 1.66l.05.05a1.9 1.9 0 1 1-2.68 2.68l-.05-.05a1.5 1.5 0 0 0-2.56 1.06v.15a1.9 1.9 0 1 1-3.8 0v-.08a1.5 1.5 0 0 0-2.6-1.02l-.05.05a1.9 1.9 0 1 1-2.68-2.68l.05-.05A1.5 1.5 0 0 0 4 12.05h-.15a1.9 1.9 0 1 1 0-3.8h.08A1.5 1.5 0 0 0 4.95 5.7l-.05-.05A1.9 1.9 0 1 1 7.58 2.97l.05.05a1.5 1.5 0 0 0 1.66.3h.07A1.5 1.5 0 0 0 10.28 1.9v-.15a1.9 1.9 0 1 1 3.8 0v.08a1.5 1.5 0 0 0 2.56 1.06l.05-.05a1.9 1.9 0 1 1 2.68 2.68l-.05.05a1.5 1.5 0 0 0-.3 1.66v.07a1.5 1.5 0 0 0 1.38.92h.15a1.9 1.9 0 1 1 0 3.8h-.08a1.5 1.5 0 0 0-1.37.92z"})]})}function K4({size:e=13,...n}){return t.jsxs(lt,{size:e,strokeWidth:1.9,...n,children:[t.jsx("circle",{cx:"12",cy:"12",r:"4.2"}),t.jsx("path",{d:"M12 2.4v2.3M12 19.3v2.3M4.6 4.6l1.7 1.7M17.7 17.7l1.7 1.7M2.4 12h2.3M19.3 12h2.3M4.6 19.4l1.7-1.7M17.7 6.3l1.7-1.7"})]})}function G4({size:e=13,...n}){return t.jsx(lt,{size:e,strokeWidth:1.9,...n,children:t.jsx("path",{d:"M20.6 14.4A8.7 8.7 0 0 1 9.6 3.4a8.7 8.7 0 1 0 11 11z"})})}function pr({size:e=13,...n}){return t.jsx(lt,{size:e,strokeWidth:2.5,...n,children:t.jsx("polyline",{points:"20 6 9 17 4 12"})})}function Vo({size:e=13,...n}){return t.jsxs(lt,{size:e,...n,children:[t.jsx("circle",{cx:"12",cy:"12",r:"9"}),t.jsx("polyline",{points:"8.2 12.2 10.9 14.9 15.9 9.4"})]})}function Jt({size:e=13,...n}){return t.jsxs(lt,{size:e,...n,children:[t.jsx("path",{d:"M10.7 3.9 2.4 18.6a1.5 1.5 0 0 0 1.3 2.2h16.6a1.5 1.5 0 0 0 1.3-2.2L13.3 3.9a1.5 1.5 0 0 0-2.6 0z"}),t.jsx("line",{x1:"12",y1:"9.5",x2:"12",y2:"14"}),t.jsx("circle",{cx:"12",cy:"17.3",r:"1.05",fill:"currentColor",stroke:"none"})]})}function oc({size:e=12,...n}){return t.jsxs(lt,{size:e,strokeWidth:1.9,...n,children:[t.jsx("circle",{cx:"12",cy:"12",r:"9"}),t.jsx("line",{x1:"12",y1:"11.2",x2:"12",y2:"16.6"}),t.jsx("circle",{cx:"12",cy:"7.7",r:"1.05",fill:"currentColor",stroke:"none"})]})}function $i({size:e=13,...n}){return t.jsxs(lt,{size:e,strokeWidth:1.9,...n,children:[t.jsx("circle",{cx:"12",cy:"13.6",r:"7.4"}),t.jsx("path",{d:"M12 9.8v3.8l2.4 1.8"}),t.jsx("path",{d:"M9.6 2.6h4.8"}),t.jsx("path",{d:"M18.7 6.5 20.2 5"})]})}function jk({size:e=10,...n}){return t.jsx(lt,{size:e,strokeWidth:2.4,...n,children:t.jsx("circle",{cx:"12",cy:"12",r:"7.5"})})}function gS({size:e=11,...n}){return t.jsxs(lt,{size:e,strokeWidth:1.9,...n,children:[t.jsx("circle",{cx:"12",cy:"12",r:"8.4"}),t.jsx("path",{d:"M12 3.6A8.4 8.4 0 0 1 20.4 12H12z",fill:"currentColor",stroke:"none"})]})}function V4({rings:e=1,size:n=12,...r}){return t.jsxs(lt,{size:n,strokeWidth:1.9,...r,children:[t.jsx("circle",{cx:"12",cy:"12",r:"2.6",fill:"currentColor",stroke:"none"}),e>=2&&t.jsx("circle",{cx:"12",cy:"12",r:"6.4",opacity:"0.75"}),e>=3&&t.jsx("circle",{cx:"12",cy:"12",r:"10.1",opacity:"0.5"})]})}function ic({size:e=10,...n}){return t.jsx(lt,{size:e,strokeWidth:2.2,...n,children:t.jsx("path",{d:"M12 5.5 19.6 18.6H4.4z"})})}function yp({size:e=13,...n}){return t.jsxs(lt,{size:e,strokeWidth:1.8,...n,children:[t.jsx("line",{x1:"12",y1:"4.2",x2:"12",y2:"20.4"}),t.jsx("line",{x1:"7.4",y1:"20.4",x2:"16.6",y2:"20.4"}),t.jsx("line",{x1:"4",y1:"7.4",x2:"20",y2:"7.4"}),t.jsx("path",{d:"M7 7.6 4.2 13.6h5.6z"}),t.jsx("path",{d:"M17 7.6 14.2 13.6h5.6z"})]})}function Q4({size:e=13,...n}){return t.jsxs(lt,{size:e,strokeWidth:1.7,...n,children:[t.jsx("circle",{cx:"12",cy:"12",r:"9"}),t.jsx("path",{d:"M15 9.2c-.55-.95-1.7-1.5-3-1.5-1.75 0-3 .95-3 2.2 0 2.85 6 1.55 6 4.4 0 1.25-1.25 2.2-3 2.2-1.3 0-2.45-.55-3-1.5"}),t.jsx("line",{x1:"12",y1:"5.6",x2:"12",y2:"18.4"})]})}function xx({size:e=8,...n}){return t.jsx(lt,{size:e,variant:"solid",...n,children:t.jsx("circle",{cx:"12",cy:"12",r:"6"})})}function Nd({size:e=13,...n}){return t.jsxs(lt,{size:e,strokeWidth:1.9,...n,children:[t.jsx("circle",{cx:"6.5",cy:"6",r:"2.4"}),t.jsx("circle",{cx:"6.5",cy:"18",r:"2.4"}),t.jsx("line",{x1:"6.5",y1:"8.4",x2:"6.5",y2:"15.6"}),t.jsx("circle",{cx:"17.5",cy:"18",r:"2.4"}),t.jsx("path",{d:"M17.5 15.6V8a2 2 0 0 0-2-2h-2.6"}),t.jsx("polyline",{points:"15.2 3.6 12.7 6 15.2 8.4"})]})}function bp({size:e=13,...n}){return t.jsxs(lt,{size:e,strokeWidth:1.9,...n,children:[t.jsx("circle",{cx:"7",cy:"6",r:"2.4"}),t.jsx("circle",{cx:"7",cy:"18",r:"2.4"}),t.jsx("circle",{cx:"17",cy:"11.5",r:"2.4"}),t.jsx("line",{x1:"7",y1:"8.4",x2:"7",y2:"15.6"}),t.jsx("path",{d:"M14.6 11.5H12A5 5 0 0 1 7 6.5"})]})}function Y4({size:e=13,...n}){return t.jsxs(lt,{size:e,strokeWidth:1.9,...n,children:[t.jsx("circle",{cx:"12",cy:"12",r:"3.4"}),t.jsx("line",{x1:"2.6",y1:"12",x2:"8.6",y2:"12"}),t.jsx("line",{x1:"15.4",y1:"12",x2:"21.4",y2:"12"})]})}function us({size:e=14,...n}){return t.jsxs(lt,{size:e,...n,children:[t.jsx("polyline",{points:"23 4 23 10 17 10"}),t.jsx("polyline",{points:"1 20 1 14 7 14"}),t.jsx("path",{d:"M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15"})]})}function X4({size:e=12,...n}){return t.jsxs(lt,{size:e,...n,children:[t.jsx("polyline",{points:"1 4 1 10 7 10"}),t.jsx("path",{d:"M3.51 15a9 9 0 1 0 2.13-9.36L1 10"})]})}function Lt({size:e=13,...n}){return t.jsxs(lt,{size:e,strokeWidth:1.9,...n,children:[t.jsx("rect",{x:"3.6",y:"8",width:"16.8",height:"12.4",rx:"3"}),t.jsx("path",{d:"M12 8V5.2"}),t.jsx("circle",{cx:"12",cy:"3.6",r:"1.5"}),t.jsx("circle",{cx:"8.8",cy:"13.4",r:"1.3",fill:"currentColor",stroke:"none"}),t.jsx("circle",{cx:"15.2",cy:"13.4",r:"1.3",fill:"currentColor",stroke:"none"}),t.jsx("path",{d:"M9.6 17.2h4.8"})]})}function Nk({size:e=13,...n}){return t.jsx(lt,{size:e,strokeWidth:1.9,...n,children:t.jsx("path",{d:"M12 3.2 19 5.8v5.6c0 4.4-3 7.9-7 9.4-4-1.5-7-5-7-9.4V5.8Z"})})}function yx({size:e=13,...n}){return t.jsxs(lt,{size:e,strokeWidth:1.9,...n,children:[t.jsx("circle",{cx:"12",cy:"8",r:"3.6"}),t.jsx("path",{d:"M4.8 20.4a7.2 7.2 0 0 1 14.4 0"})]})}function Z4({size:e=13,...n}){return t.jsxs(lt,{size:e,strokeWidth:1.8,...n,children:[t.jsx("circle",{cx:"9.4",cy:"8.4",r:"3.3"}),t.jsx("path",{d:"M3.2 20.2a6.2 6.2 0 0 1 12.4 0"}),t.jsx("path",{d:"M16.4 5.5a3.3 3.3 0 0 1 0 5.8"}),t.jsx("path",{d:"M17.4 14.3a6.2 6.2 0 0 1 3.4 5.9"})]})}function Qo({size:e=13,...n}){return t.jsx(lt,{size:e,strokeWidth:1.9,...n,children:t.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H7.5L3 21V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}function bx({size:e=13,...n}){return t.jsxs(lt,{size:e,strokeWidth:1.9,...n,children:[t.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H7.5L3 21V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"}),t.jsx("line",{x1:"7.2",y1:"8.2",x2:"16.8",y2:"8.2"}),t.jsx("line",{x1:"7.2",y1:"12",x2:"13",y2:"12"})]})}function vx({size:e=13,...n}){return t.jsxs(lt,{size:e,strokeWidth:1.9,...n,children:[t.jsx("path",{d:"M21 14.6a2 2 0 0 1-2 2H7.6L3.4 20.6V5.4a2 2 0 0 1 2-2h13.6a2 2 0 0 1 2 2z"}),t.jsx("polyline",{points:"8.4 9.8 10.8 12.2 15.6 7.4"})]})}function J4({size:e=13,...n}){return t.jsxs(lt,{size:e,strokeWidth:1.8,...n,children:[t.jsx("path",{d:"M6.5 3h7.2L19 8.3V20a1 1 0 0 1-1 1H6.5a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1z"}),t.jsx("polyline",{points:"13.4 3.2 13.4 8.4 18.8 8.4"}),t.jsx("polyline",{points:"8.6 14.6 10.6 16.6 14.8 12.2"})]})}function e_({size:e=13,...n}){return t.jsxs(lt,{size:e,strokeWidth:1.9,...n,children:[t.jsx("path",{d:"M2.4 12S6 5.6 12 5.6 21.6 12 21.6 12 18 18.4 12 18.4 2.4 12 2.4 12z"}),t.jsx("circle",{cx:"12",cy:"12",r:"3"})]})}function Ps({size:e=13,...n}){return t.jsxs(lt,{size:e,strokeWidth:1.7,...n,children:[t.jsx("path",{d:"M10.6 3.2 12.3 8.3 17.4 10 12.3 11.7 10.6 16.8 8.9 11.7 3.8 10 8.9 8.3z"}),t.jsx("path",{d:"M17.8 14.2 18.7 16.7 21.2 17.6 18.7 18.5 17.8 21 16.9 18.5 14.4 17.6 16.9 16.7z"})]})}function vp({size:e=13,...n}){return t.jsxs(lt,{size:e,strokeWidth:2.1,...n,children:[t.jsx("line",{x1:"6",y1:"20",x2:"6",y2:"13.5"}),t.jsx("line",{x1:"12",y1:"20",x2:"12",y2:"4.5"}),t.jsx("line",{x1:"18",y1:"20",x2:"18",y2:"9.5"})]})}function t_({size:e=13,...n}){return t.jsxs(lt,{size:e,strokeWidth:1.9,...n,children:[t.jsx("path",{d:"M9.4 3h5.2l-.9 5.6 3.7 3v1.8H6.6v-1.8l3.7-3z"}),t.jsx("line",{x1:"12",y1:"13.4",x2:"12",y2:"21"})]})}function kx({size:e=12,...n}){return t.jsx(lt,{size:e,strokeWidth:1.8,...n,children:t.jsx("path",{d:"M12 3.4 14.7 8.9l6 .9-4.35 4.24 1.03 6-5.38-2.83-5.38 2.83 1.03-6L3.3 9.8l6-.9z"})})}function n_({size:e=13,...n}){return t.jsxs(lt,{size:e,...n,children:[t.jsx("circle",{cx:"12",cy:"12",r:"9"}),t.jsx("path",{d:"M8 14 Q12 17.4 16 14"}),t.jsx("circle",{cx:"9",cy:"9.8",r:"1.15",fill:"currentColor",stroke:"none"}),t.jsx("circle",{cx:"15",cy:"9.8",r:"1.15",fill:"currentColor",stroke:"none"})]})}function r_({size:e=15,...n}){return t.jsxs(lt,{size:e,...n,children:[t.jsx("circle",{cx:"5",cy:"6",r:"1"}),t.jsx("line",{x1:"9",y1:"6",x2:"20",y2:"6"}),t.jsx("circle",{cx:"5",cy:"12",r:"1"}),t.jsx("line",{x1:"9",y1:"12",x2:"20",y2:"12"}),t.jsx("circle",{cx:"5",cy:"18",r:"1"}),t.jsx("line",{x1:"9",y1:"18",x2:"20",y2:"18"})]})}function s_({size:e=13,...n}){return t.jsxs(lt,{size:e,...n,children:[t.jsx("rect",{x:"9",y:"9",width:"12",height:"12",rx:"2"}),t.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})}function kp({size:e=12,...n}){return t.jsx(lt,{size:e,strokeWidth:2.2,...n,children:t.jsx("line",{x1:"6",y1:"12",x2:"18",y2:"12"})})}function a_({size:e=12,...n}){return t.jsxs(lt,{size:e,strokeWidth:1.9,...n,children:[t.jsx("circle",{cx:"12",cy:"12",r:"8.6"}),t.jsx("line",{x1:"6.4",y1:"6.4",x2:"17.6",y2:"17.6"})]})}function o_({size:e=12,...n}){return t.jsxs(lt,{size:e,strokeWidth:1.9,...n,children:[t.jsx("circle",{cx:"12",cy:"12",r:"8.6"}),t.jsx("path",{d:"M9.4 9.6a2.7 2.7 0 1 1 3.5 2.6c-.75.28-1.1.85-1.1 1.6v.5"}),t.jsx("circle",{cx:"11.8",cy:"17",r:"1",fill:"currentColor",stroke:"none"})]})}function fS({size:e=12,...n}){return t.jsxs(lt,{size:e,strokeWidth:1.9,...n,children:[t.jsx("path",{d:"M16.4 3.6a2.3 2.3 0 0 1 3.3 3.3L8.2 18.4l-4.3 1 1-4.3z"}),t.jsx("line",{x1:"14.6",y1:"5.4",x2:"17.9",y2:"8.7"})]})}function i_({size:e=13,...n}){return t.jsxs(lt,{size:e,strokeWidth:1.9,...n,children:[t.jsx("rect",{x:"4.6",y:"10.4",width:"14.8",height:"9.8",rx:"2.1"}),t.jsx("path",{d:"M8.2 10.4V7.6a3.8 3.8 0 0 1 7.6 0v2.8"})]})}function xS({size:e=12,...n}){return t.jsxs(lt,{size:e,strokeWidth:1.9,...n,children:[t.jsx("path",{d:"M6 3.4v5.2c0 1.7 1.4 3.1 3.1 3.1h1.5"}),t.jsx("path",{d:"M18 20.6v-5.2c0-1.7-1.4-3.1-3.1-3.1h-1.5"}),t.jsx("circle",{cx:"6",cy:"3.4",r:"1.9"}),t.jsx("circle",{cx:"18",cy:"20.6",r:"1.9"}),t.jsx("line",{x1:"9.4",y1:"15.2",x2:"14.6",y2:"8.8"})]})}function yS({size:e=14,...n}){return t.jsxs(lt,{size:e,strokeWidth:1.8,...n,children:[t.jsx("line",{x1:"4.2",y1:"19.8",x2:"14.6",y2:"9.4"}),t.jsx("line",{x1:"11.2",y1:"8.4",x2:"15.6",y2:"12.8"}),t.jsx("path",{d:"M17.2 4.4v3.2"}),t.jsx("path",{d:"M20.6 8.6h-3.2"}),t.jsx("path",{d:"M18.6 6.2 16.2 8.6"})]})}function wx({size:e=14,...n}){return t.jsxs(lt,{size:e,strokeWidth:2,...n,children:[t.jsx("line",{x1:"3.4",y1:"4.4",x2:"3.4",y2:"19.6"}),t.jsx("line",{x1:"6.6",y1:"12",x2:"19.4",y2:"12"}),t.jsx("path",{d:"m14.6 7.2 5.2 4.8-5.2 4.8"})]})}function jx({size:e=14,...n}){return t.jsxs(lt,{size:e,strokeWidth:2,...n,children:[t.jsx("line",{x1:"20.6",y1:"4.4",x2:"20.6",y2:"19.6"}),t.jsx("line",{x1:"17.4",y1:"12",x2:"4.6",y2:"12"}),t.jsx("path",{d:"m9.4 7.2-5.2 4.8 5.2 4.8"})]})}function l_({size:e=14,...n}){return t.jsxs(lt,{size:e,strokeWidth:2,...n,children:[t.jsx("line",{x1:"3.6",y1:"7.4",x2:"14.4",y2:"7.4"}),t.jsx("path",{d:"m10.6 4.2 4 3.2-4 3.2"}),t.jsx("line",{x1:"20.4",y1:"16.6",x2:"9.6",y2:"16.6"}),t.jsx("path",{d:"m13.4 13.4-4 3.2 4 3.2"})]})}function c_({size:e=14,...n}){return t.jsxs(lt,{size:e,strokeWidth:1.9,...n,children:[t.jsx("path",{d:"M4.4 8.4h11.4a3.2 3.2 0 0 1 0 6.4H14"}),t.jsx("path",{d:"m7.6 5.2-3.2 3.2 3.2 3.2"}),t.jsx("path",{d:"m16.4 11.6 3.2 3.2-3.2 3.2"})]})}function d_({size:e=14,...n}){return t.jsxs(lt,{size:e,strokeWidth:1.9,...n,children:[t.jsx("circle",{cx:"12",cy:"12",r:"8.4"}),t.jsx("line",{x1:"6.4",y1:"17.6",x2:"17.6",y2:"6.4"})]})}function bS({size:e=14,...n}){return t.jsxs(lt,{size:e,strokeWidth:1.9,...n,children:[t.jsx("path",{d:"M4.4 10.4h10.2a4.8 4.8 0 1 1 0 9.6H8.6"}),t.jsx("path",{d:"m8.2 5.6-3.8 4.8 3.8 4.8"})]})}function u_({size:e=14,...n}){return t.jsxs(lt,{size:e,strokeWidth:1.9,...n,children:[t.jsx("circle",{cx:"12",cy:"19.2",r:"2.4"}),t.jsx("circle",{cx:"5.6",cy:"5.2",r:"2.4"}),t.jsx("circle",{cx:"18.4",cy:"5.2",r:"2.4"}),t.jsx("path",{d:"M12 16.8V13c0-2 -1.6-3.6-3.6-3.6H7.6"}),t.jsx("path",{d:"M12 16.8V13c0-2 1.6-3.6 3.6-3.6h.8"})]})}function h_({size:e=14,...n}){return t.jsxs(lt,{size:e,strokeWidth:1.9,...n,children:[t.jsx("line",{x1:"5.4",y1:"3.6",x2:"5.4",y2:"20.4"}),t.jsx("circle",{cx:"5.4",cy:"16.4",r:"2.2"}),t.jsx("circle",{cx:"18.4",cy:"8",r:"2.2"}),t.jsx("path",{d:"M8 14.4c2.6-3.4 5-5.2 8-6.2"}),t.jsx("path",{d:"m13.4 5.6-.6 2.6 2.6.4"})]})}function Sk({size:e=14,...n}){return t.jsxs(lt,{size:e,strokeWidth:1.9,...n,children:[t.jsx("circle",{cx:"6.4",cy:"4.8",r:"2.3"}),t.jsx("circle",{cx:"6.4",cy:"19.2",r:"2.3"}),t.jsx("circle",{cx:"17.6",cy:"6.8",r:"2.3"}),t.jsx("line",{x1:"6.4",y1:"7.1",x2:"6.4",y2:"16.9"}),t.jsx("path",{d:"M17.6 9.1c0 3.4-2.8 4.6-6.2 5.2-2.6.5-5 1.4-5 2.6"})]})}function p_(e){const n=Math.max(0,e);return n>0&&n<.01?"under US$0.01":`US$${n.toFixed(2)}`}const Xt={untouched:{label:"Untouched",color:"#ef4444",description:"No reply, and no follow-up commit touched the file."},replied_unresolved:{label:"Replied",color:"#f59e0b",description:"Someone replied, but the thread is unresolved and no later commit touched the file."},likely_addressed:{label:"Likely addressed",color:"#3b82f6",description:"A commit touched this file after the last comment. Heuristic — it may be a false positive."},resolved:{label:"Resolved",color:"#22c55e",description:"Marked resolved on GitHub."}},wp={high:{label:"High",color:"#16a34a",description:"Strong deterministic evidence the thread was addressed — GitHub marked the lines outdated AND a later commit touched them, or the bot itself confirmed/resolved it."},medium:{label:"Medium",color:"#d97706",description:"One change signal — a later commit touched the file, or GitHub marked the lines outdated (could be an unrelated edit or a rebase)."},low:{label:"Low",color:"#94a3b8",description:"Only a reply — no follow-up change detected."},none:{label:"None",color:"#94a3b8",description:"No addressed signal."}},m_={addressed:{label:"Addressed",color:"#16a34a"},likely:{label:"Likely addressed",color:"#3b82f6"},partial:{label:"Partially addressed",color:"#d97706"},not_addressed:{label:"Not addressed",color:"#ef4444"},unclear:{label:"Unclear",color:"#94a3b8"}},Ht={critical:{label:"Critical",color:"#dc2626",description:'The model rates this the most serious class of finding. Advisory — CRITICAL is the class it under-recalls, so treat major+critical together as "high".'},major:{label:"Major",color:"#ea580c",description:"A substantive problem the model expects to need a real change."},minor:{label:"Minor",color:"#0284c7",description:"A small but genuine issue."},nit:{label:"Nit",color:"#78716c",description:"Trivial or optional — style, wording, preference."}},Xa={correctness_bug:"Correctness",security:"Security",performance:"Performance",style_readability:"Style",maintainability_refactor:"Maintainability",testing:"Testing",documentation:"Docs",nitpick:"Nitpick",praise:"Praise"},Ck={correctness_bug:"#ef4444",security:"#8957e5",performance:"#f59e0b",style_readability:"#3b82f6",maintainability_refactor:"#6366f1",testing:"#14b8a6",documentation:"#64748b",nitpick:"#9ca3af",praise:"#22c55e"},vS={open:{label:"Open",color:"#3b82f6"},merged:{label:"Merged",color:"#22c55e"},closed:{label:"Closed",color:"#9ca3af"}},kS={pr_opened:{label:"PR opened",color:"#3b82f6",shape:"dot"},pr_merged:{label:"PR merged",color:"#8957e5",shape:"dot"},pr_closed:{label:"PR closed",color:"#9ca3af",shape:"dot"},pr_reopened:{label:"PR reopened",color:"#3b82f6",shape:"dot"},pr_ready_for_review:{label:"Ready for review",color:"#3b82f6",shape:"dot"},review_submitted:{label:"Review",color:"#22c55e",shape:"triangle"},review_comment:{label:"Review comment",color:"#f59e0b",shape:"dot"},pr_comment:{label:"PR comment",color:"#a78bfa",shape:"square"},commit_pushed:{label:"Commit",color:"#6b7280",shape:"diamond"}};function Fg(e){switch(e){case"pr_opened":case"pr_ready_for_review":case"pr_reopened":return"opened";case"review_submitted":return"reviewed";case"pr_merged":return"merged";case"pr_closed":return"closed";default:return null}}const Rk=[{id:"opened",label:"Opened",title:"PRs opened, marked ready for review, or reopened"},{id:"reviewed",label:"Reviewed",title:"Reviews submitted — approvals, comments, changes requested"},{id:"merged",label:"Merged",title:"PRs merged, including any comments folded into them"},{id:"closed",label:"Closed",title:"PRs closed without merging, including any comments folded into them"}],g_={awaiting_your_review:{label:"Awaiting your review",color:"#3b82f6",myTurn:!0},your_pr_new_comments:{label:"Your PR · new comments",color:"#22c55e",myTurn:!0},ci_failing:{label:"CI failing",color:"#ef4444",myTurn:!1},merge_conflicts:{label:"Merge conflicts",color:"#f97316",myTurn:!1},approved_ready:{label:"Approved · ready to merge",color:"#22c55e",myTurn:!1},stalled:{label:"Stalled",color:"#eab308",myTurn:!1},untouched_threads:{label:"Untouched threads",color:"#f59e0b",myTurn:!1},in_progress:{label:"In progress",color:"#9ca3af",myTurn:!1}},Ik={requested:{label:"Review requested",title:"A review was requested from you on this PR"},authored:{label:"You authored",title:"You opened this PR"},merged:{label:"You merged",title:"You merged this PR"},reviewed:{label:"You reviewed",title:"You previously reviewed this PR"},commented:{label:"You commented",title:"You previously commented on this PR"}},Qs={coderabbit:{label:"CodeRabbit",color:"#ff7a45"},greptile:{label:"Greptile",color:"#16a34a"},copilot:{label:"Copilot",color:"#8957e5"},qodo:{label:"Qodo",color:"#7c3aed"},sourcery:{label:"Sourcery",color:"#0d9488"},bito:{label:"Bito",color:"#e11d48"},ellipsis:{label:"Ellipsis",color:"#64748b"},korbit:{label:"Korbit",color:"#2563eb"},baz:{label:"Baz",color:"#db2777"},graphite:{label:"Graphite",color:"#475569"},cursor:{label:"Cursor",color:"#334155"},devin:{label:"Devin",color:"#0891b2"},entelligence:{label:"Entelligence",color:"#ca8a04"},deepsource:{label:"DeepSource",color:"#0ea5e9"},github_code_quality:{label:"GitHub Code Quality",color:"#4338ca"},github_advanced_security:{label:"GitHub Advanced Security",color:"#b91c1c"},codex:{label:"Codex",color:"#10a37f"},sonarqube:{label:"SonarQube",color:"#4e9bcd"},codecov:{label:"Codecov",color:"#f01f7a"},codeclimate:{label:"Code Climate",color:"#5c4d8f"},codefactor:{label:"CodeFactor",color:"#3b7dd8"},hound:{label:"Hound",color:"#4a5568"},coveralls:{label:"Coveralls",color:"#c1503f"},codacy:{label:"Codacy",color:"#397ab8"},github_actions:{label:"GitHub Actions",color:"#2088ff"},jit:{label:"Jit",color:"#5b5bd6"},socket:{label:"Socket",color:"#6d5efc"},gitguardian:{label:"GitGuardian",color:"#1c3f94"},semgrep:{label:"Semgrep",color:"#1aa382"},trunk:{label:"Trunk",color:"#2d6a5a"},endor:{label:"Endor Labs",color:"#1e7f6e"},dependabot:{label:"Dependabot",color:"#0366d6"},renovate:{label:"Renovate",color:"#1a1f6c"},snyk:{label:"Snyk",color:"#4c4a73"},pyup:{label:"PyUp",color:"#3775a9"},greenkeeper:{label:"Greenkeeper",color:"#3aa757"},depfu:{label:"Depfu",color:"#7b5ea7"},aikido:{label:"Aikido",color:"#6551f3"},mend:{label:"Mend",color:"#f05a28"},frogbot:{label:"Frogbot",color:"#40be46"},checkmarx:{label:"Checkmarx",color:"#6b3fa0"},sweep:{label:"Sweep",color:"#e0913a"},codegen:{label:"Codegen",color:"#b45309"},deepsource_autofix:{label:"DeepSource Autofix",color:"#0284c7"},pre_commit_ci:{label:"pre-commit.ci",color:"#f9a825"},restyled:{label:"Restyled",color:"#a16207"},imgbot:{label:"ImgBot",color:"#d97706"},transifex:{label:"Transifex",color:"#0f6fbe"},crowdin:{label:"Crowdin",color:"#2e3340"},mintlify:{label:"Mintlify",color:"#0d9f6e"},allstar:{label:"Allstar",color:"#8d6e2f"},step_security:{label:"StepSecurity",color:"#0e7490"},orbisai:{label:"OrbisAI",color:"#3b5bdb"},mergify:{label:"Mergify",color:"#ee6c4d"},kodiak:{label:"Kodiak",color:"#3f7a8c"},bulldozer:{label:"Bulldozer",color:"#6b7f3a"},release_please:{label:"Release Please",color:"#1f7a8c"},semantic_release:{label:"semantic-release",color:"#c0392b"},release_drafter:{label:"Release Drafter",color:"#5a7d9a"},changesets:{label:"Changesets",color:"#8a5cf6"},backport:{label:"Backport bot",color:"#7e6b8f"},cla_assistant:{label:"CLA Assistant",color:"#78716c"},google_cla:{label:"Google CLA",color:"#4285f4"},meta_cla:{label:"Meta CLA",color:"#0866ff"},dco:{label:"DCO",color:"#57534e"},stale_bot:{label:"Stale bot",color:"#a8a29e"},welcome_bot:{label:"Welcome bot",color:"#a3a3a3"},lock_bot:{label:"Lock bot",color:"#737373"},allcontributors:{label:"All Contributors",color:"#ff8c00"},semantic_pr:{label:"Semantic PR",color:"#8b8b8b"},sizebot:{label:"Size bot",color:"#9ca3af"},codesandbox:{label:"CodeSandbox",color:"#151515"},netlify:{label:"Netlify",color:"#00c7b7"},vercel:{label:"Vercel",color:"#5f5f5f"},gitpod:{label:"Gitpod",color:"#ff8a00"},in_house:{label:Lg.in_house,color:"#6b7280"},vendor:{label:Lg.vendor,color:"#71717a"},pierre:{label:Lg.pierre,color:"#d97757"}},f_="#ffffff",x_="#030712",Tk=4.5;function Th(e){const n=e.replace("#",""),r=n.length===3?n.split("").map(s=>s+s).join(""):n;return[parseInt(r.slice(0,2),16),parseInt(r.slice(2,4),16),parseInt(r.slice(4,6),16)]}function Z0(e){const n=r=>{const s=r/255;return s<=.03928?s/12.92:Math.pow((s+.055)/1.055,2.4)};return .2126*n(e[0])+.7152*n(e[1])+.0722*n(e[2])}function $k(e,n){const r=Z0(Th(e)),s=Z0(Th(n));return(Math.max(r,s)+.05)/(Math.min(r,s)+.05)}function y_([e,n,r]){const s=e/255,a=n/255,i=r/255,c=Math.max(s,a,i),d=Math.min(s,a,i),u=(c+d)/2;if(c===d)return[0,0,u];const m=c-d,h=u>.5?m/(2-c-d):m/(c+d);return[(c===s?(a-i)/m+(a<i?6:0):c===a?(i-s)/m+2:(s-a)/m+4)/6,h,u]}function b_(e,n,r){const s=(u,m,h)=>{let g=h;return g<0&&(g+=1),g>1&&(g-=1),g<.16666666666666666?u+(m-u)*6*g:g<.5?m:g<.6666666666666666?u+(m-u)*(.6666666666666666-g)*6:u};let a,i,c;if(n===0)a=i=c=r;else{const u=r<.5?r*(1+n):r+n-r*n,m=2*r-u;a=s(m,u,e+1/3),i=s(m,u,e),c=s(m,u,e-1/3)}const d=u=>Math.round(u*255).toString(16).padStart(2,"0");return`#${d(a)}${d(i)}${d(c)}`}function _k(e,n){if($k(e,n)>=Tk)return e;const[r,s,a]=y_(Th(e)),i=Z0(Th(n))<.5;for(let c=1;c<=100;c+=1){const d=i?Math.min(1,a+c/100):Math.max(0,a-c/100),u=b_(r,s,d);if($k(u,n)>=Tk)return u;if(d===0||d===1)break}return i?"#ffffff":"#000000"}function pn(e){return{"--ink-light":_k(e,f_),"--ink-dark":_k(e,x_)}}function ds(e){return Qs[e]}function wS(e){const n=zN(e==null?void 0:e.githubLogin);return n?{kind:n,...Qs[n]}:null}const bl=["#ec4899","#84cc16","#06b6d4","#ef4444","#3b82f6","#8b5cf6","#f59e0b","#14b8a6","#22c55e","#f97316"],v_=Qs.in_house.color;function jS(e){return e!=="in_house"&&e!=="vendor"}function k_(e){const n=new Map,r=new Set,s=[...e].sort((i,c)=>i.login.localeCompare(c.login));for(const i of s){if(n.has(i.login)||!jS(i.kind))continue;const c=Qs[i.kind].color;n.set(i.login,c),r.add(c.toLowerCase())}let a=0;for(const i of s){if(n.has(i.login))continue;let c=bl[a%bl.length];for(let d=0;d<bl.length;d++){const u=bl[(a+d)%bl.length];if(!r.has(u.toLowerCase())){c=u,a+=d+1;break}d===bl.length-1&&(a+=1)}n.set(i.login,c),r.add(c.toLowerCase())}return n}function w_(e,n){if(n.login){const r=e.get(n.login);if(r)return r}return jS(n.kind)?Qs[n.kind].color:v_}const j_=new Set(["awaiting_your_review","your_pr_new_comments","ci_failing","merge_conflicts","untouched_threads"]);function N_(e){return e.isStalled||e.threadCounts.untouched>0||j_.has(e.reasonTag)}function Pk(e){const n=e.threadCounts;return n.untouched+n.replied_unresolved+n.likely_addressed+n.resolved}function NS(e,n){return[...e].sort((r,s)=>{const a=n(r)?0:1,i=n(s)?0:1;if(a!==i)return a-i;const c=s.updatedAt.localeCompare(r.updatedAt);if(c!==0)return c;const d=Pk(s)-Pk(r);return d!==0?d:s.number-r.number})}const Rr={success:{label:"CI passing",color:"#22c55e"},failure:{label:"CI failing",color:"#ef4444"},error:{label:"CI error",color:"#ef4444"},pending:{label:"CI running",color:"#eab308"},expected:{label:"CI expected",color:"#9ca3af"},unknown:null};function S_(e,n){if(e!=="open")return null;const r=Rr[n];return{status:n,label:(r==null?void 0:r.label)??"No checks"}}const Nx={success:{label:"passed",color:"#22c55e",icon:pr},failure:{label:"failed",color:"#ef4444",icon:Zt},pending:{label:"running",color:"#eab308",icon:xx},neutral:{label:"neutral",color:"#9ca3af",icon:kp},skipped:{label:"skipped",color:"#9ca3af",icon:a_},error:{label:"error",color:"#ef4444",icon:Jt},unknown:{label:"unknown",color:"#9ca3af",icon:o_}};function qc(e,n,r,s,a){return{label:e,icon:n,ink:s,cls:`${r} ${s}`,title:a}}const $h={approved:qc("Approved",pr,"bg-green-500/10","text-green-700 dark:text-green-400","Approved"),changes_requested:qc("Changes requested",Zt,"bg-red-500/10","text-red-700 dark:text-red-400","Requested changes"),commented:qc("Commented",Qo,"bg-gray-500/10","text-gray-600 dark:text-gray-300","Reviewed with comments — no verdict"),dismissed:qc("Dismissed",kp,"bg-gray-500/10","text-gray-500 dark:text-gray-400","Review dismissed"),pending:qc("Pending",null,"bg-gray-500/10","text-gray-500 dark:text-gray-400","Review pending")},C_="required checks or reviews aren’t satisfied",SS=(e,n,r)=>e===1?n:r;function R_(e){const n=[],{reviewDecision:r,ciStatus:s,requestedReviewers:a}=e,i=e.unresolvedThreads??0,c=Math.min(e.likelyAddressedThreads??0,i);if(r==="changes_requested"?n.push({kind:"changes_requested",certainty:"proven",text:"a reviewer requested changes"}):r==="review_required"&&n.push({kind:"review_required",certainty:"proven",text:"required reviews aren’t in yet",...a!=null&&a>0?{count:a}:{}}),s==="failure"||s==="error"?n.push({kind:"checks_red",certainty:"inferred",text:s==="error"?"a check errored on the head commit":"CI is red on the head commit"}):(s==="pending"||s==="expected")&&n.push({kind:"checks_pending",certainty:"inferred",text:s==="expected"?"a required check hasn’t reported yet":"checks are still running"}),i>0&&n.push({kind:"unresolved_threads",certainty:"inferred",count:i,text:`${i} review ${SS(i,"thread isn’t","threads aren’t")} resolved on GitHub${c>0?` (${c} of them look addressed)`:""}`}),n.length===0){const d=r==="approved";n.push({kind:"unexplained",certainty:"inferred",text:d?"approved, and nothing we can see explains the block":"nothing we can see explains it"})}return n}const I_=["clean","dirty","unstable","blocked","behind","has_hooks","unknown"];function CS(e){const n=(e??"").toLowerCase();return I_.includes(n)?n:"unknown"}function Pi(e){var r;const n=e.mergeStateStatus;if(e.inMergeQueue)return{verdict:"queued",label:"in merge queue",tone:"ok",canMerge:!1,detail:e.queuePosition!=null?`position ${e.queuePosition}`:null};if(n==="dirty"||e.mergeable==="conflicting")return{verdict:"conflicts",label:"conflicts",tone:"bad",canMerge:!1,detail:"resolve the conflicts with the base branch"};if(e.autoMergeArmed)return{verdict:"armed",label:"auto-merge armed",tone:"ok",canMerge:!0,detail:"it lands by itself once the blockers clear"};if(e.isDraft)return{verdict:"draft",label:"draft",tone:"muted",canMerge:!1,detail:"mark it ready for review to merge"};if(n==="blocked"){const s=e.blockFacts?R_(e.blockFacts):null;return{verdict:"blocked",label:"blocked",tone:"bad",canMerge:!1,detail:((r=s==null?void 0:s[0])==null?void 0:r.text)??C_,...s?{blockers:s}:{}}}return n==="behind"?{verdict:"behind",label:"behind base",tone:"warn",canMerge:!1,detail:e.behindBy!=null&&e.behindBy>0?`${e.behindBy} commit${e.behindBy===1?"":"s"} behind — update the branch first`:"update the branch first"}:n==="unstable"?{verdict:"unstable",label:"checks failing",tone:"warn",canMerge:!0,detail:"some non-required checks are failing — GitHub will still merge it"}:n==="clean"||n==="has_hooks"?{verdict:"clean",label:"ready to merge",tone:"ok",canMerge:!0,detail:null}:{verdict:"unknown",label:"mergeability unknown",tone:"muted",canMerge:!1,detail:null}}function RS(e,n){return e==="open"&&n==="conflicts"}function T_(e){return RS(e.state,e.verdict)&&e.viewerCanPush&&e.resolverAvailable}const Sx={ok:"text-green-600 dark:text-green-400",warn:"text-orange-600 dark:text-orange-400",bad:"text-red-600 dark:text-red-400",muted:"text-gray-400 dark:text-gray-500"},IS={ok:"bg-green-500/15 text-green-700 dark:text-green-400",warn:"bg-orange-500/15 text-orange-600 dark:text-orange-400",bad:"bg-red-500/15 text-red-600 dark:text-red-400",muted:"bg-gray-500/10 text-gray-500 dark:text-gray-400"},$_=new Set(["conflicts","blocked","behind","unstable"]),__=new Set(["conflicts","behind"]);function Cx(e){const n=Pi(e);if($_.has(n.verdict))return n;if(n.verdict!=="draft")return null;const r=Pi({...e,isDraft:!1});return __.has(r.verdict)?r:null}function TS(e,n){const r=e.codeLoc;if(r==null||r<n)return null;const s=r.toLocaleString(),a=n.toLocaleString(),i=e.codeLocIsLowerBound===!0;return{codeLoc:r,isLowerBound:i,label:i?`At least ${s} code lines changed — above your ${a} threshold. GitHub truncated the file list, so the real figure is higher.`:`${s} code lines changed — above your ${a} threshold.`,short:i?`${s}+ code lines`:`${s} code lines`}}let $S=hd;function P_(e){$S=e!=null&&Number.isInteger(e)&&e>0?e:hd}function E_(){return $S}function jp(e){const n=(e==null?void 0:e.sensitivity)??ck,r=lk[n]??lk[ck];return{sensitivity:n,surfacesOff:(e==null?void 0:e.surfacesOff)??[],thresholds:{...r,...(e==null?void 0:e.overrides)??{}},showImpactNote:(e==null?void 0:e.showImpactNote)??!0,isDefault:e==null}}const A_={db_migration:"a database migration",db_schema:"a database schema",sql:"SQL",public_types:"published types",idl:"a service contract",openapi:"an API description",infra:"infrastructure",auth:"auth or security code",ci:"CI workflows",deps:"dependencies"};function Ek(e){return e.length<=1?e[0]??"":`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`}const os=(e,n,r)=>`${e} ${SS(e,n,r)}`;function Rx(e,n){const r=e.blast;if(r==null)return null;const s=n.thresholds,a=[],i=new Set(n.surfacesOff),c=r.surfaces.filter(y=>VN.includes(y)&&!i.has(y));if(c.length>0&&a.push({kind:"surface",text:`Touches ${Ek(c.map(y=>A_[y]))}`}),r.hubDegree!=null&&r.hubBar!=null&&r.hubDegree>=r.hubBar){const y=r.hubPath?`\`${r.hubPath}\``:"a file here";a.push({kind:"hub",text:`Touches ${y}, which usually changes alongside ${r.hubDegree} others`})}const d=[];if(r.subsystems>=s.highSubsystems&&d.push(os(r.subsystems,"subsystem","subsystems")),r.dirs>=s.highDirs&&d.push(os(r.dirs,"directory","directories")),r.codeFiles>=s.highCodeFiles&&d.push(os(r.codeFiles,"code file","code files")),d.length>0&&a.push({kind:"spread",text:`Spans ${Ek(d)}`}),e.codeLoc!=null&&e.codeLoc>=s.highCodeLoc&&a.push({kind:"volume",text:`${e.codeLoc.toLocaleString()}${e.codeLocIsLowerBound?"+":""} lines of code changed`}),a.length>0){if(r.contentKind==="comments"||r.contentKind==="formatting"){const b=r.contentKind==="comments"?"Comments only":"Formatting only";return{level:"medium",reasons:[{kind:"contained",text:`${b} — no code behaviour changed`},...a],short:"Medium",label:`${b}, in files that would otherwise read as high reach — ${a.map(w=>w.text).join("; ")}.`,volumeOnly:!1}}return{level:"high",reasons:a,short:"High",label:`Wide reach — ${a.map(b=>b.text).join("; ")}.`,volumeOnly:a.every(b=>b.kind==="volume")}}if(r.truncated)return null;if(r.codeFiles===0){const y=r.testFiles>0&&r.nonCodeFiles===0?"Tests only — no product code changed":r.testFiles>0?"Tests, docs and config only — no product code changed":"Docs, config and dependencies only — no code changed";return{level:"low",reasons:[{kind:"contained",text:y}],short:"Low",label:`${y}.`,volumeOnly:!1}}const u=r.codeFiles>s.lowCodeFiles,m=r.subsystems>1,h=e.codeLoc!=null&&e.codeLoc>s.lowCodeLoc,g=e.codeLoc==null;if(!u&&!m&&!h&&!g){const y=[`${os(r.codeFiles,"code file","code files")} in one area`];r.testFiles>0&&y.push("with tests"),r.allNew&&y.push("all newly added");const b=y.join(", ");return{level:"low",reasons:[{kind:"contained",text:b}],short:"Low",label:`Contained — ${b}.`,volumeOnly:!1}}const x=m?{kind:"spread",text:`Spans ${os(r.subsystems,"subsystem","subsystems")}`}:u?{kind:"spread",text:`${os(r.codeFiles,"code file","code files")} across ${os(r.dirs,"directory","directories")}`}:h?{kind:"volume",text:`${e.codeLoc.toLocaleString()}${e.codeLocIsLowerBound?"+":""} lines across ${os(r.codeFiles,"code file","code files")}`}:{kind:"spread",text:`${os(r.codeFiles,"code file","code files")}, size not measured`};return{level:"medium",reasons:[x],short:"Medium",label:`Moderate reach — ${x.text}.`,volumeOnly:!1}}let _S=jp(null);function M_(e){_S=jp(e??null)}function L_(){return _S}const F_=new Set(["blocked","behind","unknown"]);function O_(e){return!e.allowedByRepo||e.methodCount===0||e.alreadyArmed?!1:F_.has(e.verdict.verdict)?!0:e.verdict.canMerge&&e.behindBy>0}function Dt(e,n){return e?e.displayName||e.githubLogin:n==null?"unknown":`user ${n}`}function Gl(e){return`https://github.com/${encodeURIComponent(e)}`}function mn(e){if(!e)return;const n=e.trim();if(n==="")return;let r;try{r=new URL(n,window.location.origin)}catch{return}if(!(r.protocol!=="http:"&&r.protocol!=="https:"))return n}function PS(e){const n=encodeURIComponent(e);return e.startsWith("CVE-")?`https://nvd.nist.gov/vuln/detail/${n}`:e.startsWith("GHSA-")?`https://github.com/advisories/${n}`:e.startsWith("RUSTSEC-")?`https://rustsec.org/advisories/${n}`:e.startsWith("GO-")?`https://pkg.go.dev/vuln/${n}`:e.startsWith("PYSEC-")||e.startsWith("OSV-")?`https://osv.dev/vulnerability/${n}`:e.startsWith("SNYK-")?`https://security.snyk.io/vuln/${n}`:null}function ES(e,n){const r=n?`@${n} `:"",s=(e??"").trim();return s===""?r:`${s.split(`
26
+ `).map(i=>`> ${i}`).join(`
27
+ `)}
28
+
29
+ ${r}`}function Rn(e){const n=new Map;for(const r of e??[])n.set(r.id,r);return n}function J0(e){return new Date(e).toLocaleDateString(void 0,{day:"2-digit",month:"2-digit",year:"numeric"})}function Nt(e){const n=new Date(e).getTime(),r=Date.now()-n,s=Math.abs(r),a=6e4,i=60*a,c=24*i,d=(u,m)=>`${u} ${m}${u===1?"":"s"} ago`;return s<a?"just now":s<i?d(Math.round(r/a),"min"):s<c?d(Math.round(r/i),"hour"):s<30*c?d(Math.round(r/c),"day"):J0(e)}function Cn(e){return new Date(e).toLocaleString(void 0,{day:"2-digit",month:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit"})}function kn(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function D_(){const e=G(uS),n=G(r=>r.workspaceId);return Oe({queryKey:["open-prs",dt(n),e],queryFn:()=>he.openPrs(e),enabled:n!=null,placeholderData:r=>r})}function AS(){const e=G(r=>uS(r,!1)),n=G(r=>r.workspaceId);return Oe({queryKey:["open-prs",dt(n),e],queryFn:()=>he.openPrs(e),enabled:n!=null,placeholderData:r=>r})}function B_(e){const n=new URLSearchParams;return e!=null&&n.set("workspace",String(e)),n.toString()}function Np(){const e=G(r=>r.workspaceId),n=B_(e);return Oe({queryKey:["open-prs",dt(e),n],queryFn:()=>he.openPrs(n),enabled:e!=null,placeholderData:r=>r})}function W_(e,n){const r=new URLSearchParams;return e!=null&&r.set("workspace",String(e)),r.toString()}function q_(e){const n=G(s=>s.workspaceId),r=W_(n);return Oe({queryKey:["open-prs",dt(n),r],queryFn:()=>he.openPrs(r),enabled:n!=null,placeholderData:s=>s})}function In(){var s,a;const e=Oe({queryKey:["me"],queryFn:he.me,retry:!1}),n=(s=e.data)==null?void 0:s.largePrCodeLocThreshold;f.useEffect(()=>{P_(n)},[n]);const r=(a=e.data)==null?void 0:a.blastRadius;return f.useEffect(()=>{M_(r)},[r]),e}function vt(){var e;return((e=In().data)==null?void 0:e.pro)??{activityDigest:!1,prSummary:!1,workspaceInsights:!1,slackDigest:!1,issueLinks:!1,botTriage:!1,botAdvisor:!1,periodReports:!1,botDepth:!1,workPlan:!1}}function U_(){return Oe({queryKey:["my-turn"],queryFn:he.myTurn})}function H_(e){return Oe({queryKey:["repo-analytics",e],queryFn:()=>he.repoAnalytics(e),enabled:e!=null})}const z_=["workspaces","repos","workspace-metrics","workspace-metrics-detail","period-reports","period-report","timeline","open-prs","my-turn","users","mergers",...ac];function xa(){return Oe({queryKey:["workspaces"],queryFn:()=>he.listWorkspaces().then(e=>e.workspaces)})}function Ix(){const e=He(),n=()=>{for(const m of z_)e.invalidateQueries({queryKey:[m]})},r=tt({mutationFn:m=>he.createWorkspace(m),onSettled:n}),s=tt({mutationFn:m=>he.renameWorkspace(m.id,{name:m.name}),onSettled:n}),a=tt({mutationFn:m=>he.deleteWorkspace(m),onSettled:n}),i=tt({mutationFn:m=>he.assignRepoToWorkspace(m.workspaceId,m.repoId),onSettled:n}),c=tt({mutationFn:m=>he.setWorkspaceRepos(m.id,m.repoIds),onSettled:n}),d=tt({mutationFn:m=>he.setWorkspacePendingMute(m.id,m.patch),onSettled:n}),u=tt({mutationFn:m=>he.setWorkspaceFlowSettings(m.id,m.settings),onSettled:()=>Promise.all([e.invalidateQueries({queryKey:["workspaces"]}),e.invalidateQueries({queryKey:["flow-findings"]})])});return{createWorkspace:r,renameWorkspace:s,deleteWorkspace:a,assignRepoToWorkspace:i,setWorkspaceRepos:c,setWorkspacePendingMute:d,setWorkspaceFlowSettings:u}}function MS(e,n){if(e==null)return[];const r=n.find(s=>s.id===e);return r?[...r.repoIds]:[]}function Yr(e,n,r=!0){const s=f.useRef(n);s.current=n,f.useEffect(()=>{if(!r)return;function a(i){const c=e.current;c&&!c.contains(i.target)&&s.current()}return document.addEventListener("pointerdown",a,!0),()=>document.removeEventListener("pointerdown",a,!0)},[e,r])}const K_={lifecycle:"PR state events",reviews:"Reviews",review_comments:"Review comments",pr_comments:"PR comments",commits:"Commits"},G_={approved:"Approved",changes_requested:"Changes requested",commented:"Commented",dismissed:"Dismissed",pending:"Pending"},V_={approved:"#22c55e",changes_requested:"#f97316",commented:"#9ca3af",dismissed:"#9ca3af",pending:"#9ca3af"};function Ak(e,n){if(e.length!==n.length)return!1;const r=new Set(e);return n.every(s=>r.has(s))}function Q_({categories:e,onToggleCategory:n,onSetCategories:r,reviewStates:s,onToggleReviewState:a,onSetReviewStates:i}){const[c,d]=f.useState(!1),u=f.useRef(null),m=Ak(e,Sh)&&Ak(s,Ch),h=e.length+s.length,g=pd.length+Kl.length,x=()=>{r([...Sh]),i([...Ch])};return Yr(u,()=>d(!1),c),f.useEffect(()=>{if(!c)return;const y=b=>{b.key==="Escape"&&(b.stopPropagation(),d(!1))};return document.addEventListener("keydown",y),()=>document.removeEventListener("keydown",y)},[c]),t.jsxs("div",{ref:u,className:"relative",children:[t.jsxs("span",{className:"inline-flex items-center whitespace-nowrap rounded-full border border-gray-300 text-xs text-gray-600 hover:border-gray-400 dark:border-gray-700 dark:text-gray-300 dark:hover:border-gray-500",children:[t.jsxs("button",{type:"button",onClick:()=>d(y=>!y),"aria-haspopup":"true","aria-expanded":c,className:`inline-flex items-center gap-1 py-0.5 pl-2.5 ${m?"pr-2.5":"pr-1"}`,children:["Events",m?"":` (${h})`,t.jsx(Cr,{dir:"down"})]}),!m&&t.jsx("button",{type:"button",onClick:x,title:"Reset event filters to default","aria-label":"Reset event filters to default",className:"flex items-center self-stretch py-0.5 pl-0.5 pr-2 opacity-60 hover:opacity-100",children:t.jsx(Zt,{size:11})})]}),c&&t.jsxs("div",{role:"dialog","aria-label":"Event types",className:"absolute left-0 top-full z-[60] mt-1 w-60 rounded-lg border border-gray-200 bg-white p-2 shadow-lg dark:border-gray-700 dark:bg-gray-900",children:[t.jsxs("div",{className:"max-h-80 overflow-y-auto",children:[t.jsx("p",{className:"px-1 pb-0.5 pt-1 text-[11px] uppercase tracking-wide text-gray-400",children:"Reviews"}),Kl.map(y=>t.jsxs("label",{className:"flex cursor-pointer items-center gap-2 rounded px-1 py-1 text-xs hover:bg-gray-100 dark:hover:bg-gray-800",children:[t.jsx("input",{type:"checkbox",checked:s.includes(y),onChange:()=>a(y)}),t.jsx("span",{"aria-hidden":!0,className:"h-2.5 w-2.5 shrink-0 rounded-full",style:{backgroundColor:V_[y]}}),t.jsx("span",{className:"text-gray-800 dark:text-gray-100",children:G_[y]})]},y)),t.jsx("div",{className:"my-1 border-t border-gray-200 dark:border-gray-700"}),pd.map(y=>t.jsxs("label",{className:"flex cursor-pointer items-center gap-2 rounded px-1 py-1 text-xs hover:bg-gray-100 dark:hover:bg-gray-800",children:[t.jsx("input",{type:"checkbox",checked:e.includes(y),onChange:()=>n(y)}),t.jsx("span",{className:"text-gray-800 dark:text-gray-100",children:K_[y]})]},y))]}),!m&&t.jsxs("div",{className:"mt-2 flex items-center justify-between border-t border-gray-200 pt-2 dark:border-gray-700",children:[t.jsxs("span",{className:"text-[11px] text-gray-400",children:[h," of ",g," shown"]}),t.jsx("button",{type:"button",onClick:x,className:"text-[11px] text-gray-400 hover:text-gray-600",children:"Reset to default"})]})]})]})}function Y_({repos:e,repoIds:n,onToggle:r,onOnly:s,onShowAll:a}){const[i,c]=f.useState(!1),[d,u]=f.useState(""),m=f.useRef(null),h=e.length,g=k=>n==null||n.includes(k),x=n==null?h:n.length,y=n!=null&&x<h;Yr(m,()=>c(!1),i),f.useEffect(()=>{if(!i)return;const k=j=>{j.key==="Escape"&&(j.stopPropagation(),c(!1))};return document.addEventListener("keydown",k),()=>document.removeEventListener("keydown",k)},[i]);const b=d.trim().toLowerCase(),w=e.filter(k=>!b||k.fullName.toLowerCase().includes(b));return t.jsxs("div",{ref:m,className:"relative",children:[t.jsxs("span",{className:"inline-flex items-center whitespace-nowrap rounded-full border border-gray-300 text-xs text-gray-600 hover:border-gray-400 dark:border-gray-700 dark:text-gray-300 dark:hover:border-gray-500",children:[t.jsxs("button",{type:"button",onClick:()=>c(k=>!k),"aria-haspopup":"true","aria-expanded":i,className:`inline-flex items-center gap-1 py-0.5 pl-2.5 ${y?"pr-1":"pr-2.5"}`,children:["Repos",h>0?` (${y?`${x}/${h}`:h})`:"",t.jsx(Cr,{dir:"down"})]}),y&&t.jsx("button",{type:"button",onClick:()=>a(),title:"Show every repo in this workspace","aria-label":"Show every repo in this workspace",className:"flex items-center self-stretch py-0.5 pl-0.5 pr-2 opacity-60 hover:opacity-100",children:t.jsx(Zt,{size:11})})]}),i&&t.jsxs("div",{role:"dialog","aria-label":"Repositories in this workspace",className:"absolute left-0 top-full z-[60] mt-1 w-[28rem] max-w-[calc(100vw-2rem)] rounded-lg border border-gray-200 bg-white p-2 shadow-lg dark:border-gray-700 dark:bg-gray-900",children:[h>8&&t.jsx("input",{autoFocus:!0,type:"search",value:d,onChange:k=>u(k.target.value),placeholder:"Filter repos…","aria-label":"Filter repos",className:"mb-2 w-full rounded border border-gray-300 bg-transparent px-2 py-0.5 text-xs focus:border-blue-500 focus:outline-none dark:border-gray-700"}),t.jsx("div",{className:"max-h-72 overflow-y-auto",children:h===0?t.jsx("div",{className:"px-1 py-2 text-xs text-gray-500 dark:text-gray-400",children:"No repos in this workspace — move some in from Manage repos & workspaces."}):w.length===0?t.jsx("div",{className:"px-1 py-2 text-xs text-gray-500 dark:text-gray-400",children:"No repos match."}):w.map(k=>{const j=g(k.id)&&x<=1;return t.jsxs("div",{className:"group flex items-center gap-2 rounded px-1 py-1 text-xs hover:bg-gray-100 dark:hover:bg-gray-800",children:[t.jsxs("label",{className:`flex min-w-0 flex-1 items-center gap-2 ${j?"cursor-default":"cursor-pointer"}`,children:[t.jsx("input",{type:"checkbox",checked:g(k.id),disabled:j,onChange:()=>r(k.id),title:j?"At least one repo must stay shown":void 0}),t.jsxs("span",{className:"min-w-0 truncate",title:k.fullName,children:[t.jsxs("span",{className:"text-gray-400",children:[k.owner,"/"]}),t.jsx("span",{className:"font-medium text-gray-800 dark:text-gray-100",children:k.name})]}),k.lastSyncStatus==="error"&&t.jsx("span",{role:"img",className:"flex shrink-0 items-center text-red-500",title:k.lastSyncError??"Last sync failed","aria-label":"Last sync failed",children:t.jsx(Jt,{size:12})})]}),!(g(k.id)&&x===1)&&t.jsx("button",{type:"button",onClick:()=>s(k.id),title:`Show only ${k.fullName}`,"aria-label":`Show only ${k.fullName}`,className:"shrink-0 rounded px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-gray-400 opacity-0 hover:bg-gray-200 hover:text-gray-700 focus:opacity-100 group-hover:opacity-100 dark:hover:bg-gray-700 dark:hover:text-gray-200",children:"only"})]},k.id)})}),y&&t.jsxs("div",{className:"mt-2 flex items-center justify-between border-t border-gray-200 pt-2 dark:border-gray-700",children:[t.jsxs("span",{className:"text-[11px] text-gray-400",children:[x," of ",h," shown"]}),t.jsx("button",{type:"button",onClick:()=>a(),className:"text-[11px] text-gray-400 hover:text-gray-600",children:"Show all"})]})]})]})}const X_={draft:"Draft",open:"Open",merged:"Merged",closed:"Closed"},Mk=!0,Z_="A stale PR is an open PR with no commits, comments or reviews in the selected time range. Unchecked hides them; check to include them.";function J_(e,n){if(e.length!==n.length)return!1;const r=new Set(e);return n.every(s=>r.has(s))}function eP({statuses:e,onToggle:n,onSet:r,excludeStale:s,onExcludeStaleChange:a}){const[i,c]=f.useState(!1),d=f.useRef(null),u=J_(e,Rh)&&s===Mk,m=e.length+(s?0:1),h=md.length+1,g=()=>{r([...Rh]),a(Mk)};return Yr(d,()=>c(!1),i),f.useEffect(()=>{if(!i)return;const x=y=>{y.key==="Escape"&&(y.stopPropagation(),c(!1))};return document.addEventListener("keydown",x),()=>document.removeEventListener("keydown",x)},[i]),t.jsxs("div",{ref:d,className:"relative",children:[t.jsxs("span",{className:"inline-flex items-center whitespace-nowrap rounded-full border border-gray-300 text-xs text-gray-600 hover:border-gray-400 dark:border-gray-700 dark:text-gray-300 dark:hover:border-gray-500",children:[t.jsxs("button",{type:"button",onClick:()=>c(x=>!x),"aria-haspopup":"true","aria-expanded":i,className:`inline-flex items-center gap-1 py-0.5 pl-2.5 ${u?"pr-2.5":"pr-1"}`,children:["Status",u?"":` (${m})`,t.jsx(Cr,{dir:"down"})]}),!u&&t.jsx("button",{type:"button",onClick:g,title:"Reset statuses to default","aria-label":"Reset statuses to default",className:"flex items-center self-stretch py-0.5 pl-0.5 pr-2 opacity-60 hover:opacity-100",children:t.jsx(Zt,{size:11})})]}),i&&t.jsxs("div",{role:"dialog","aria-label":"PR statuses",className:"absolute left-0 top-full z-[60] mt-1 w-60 rounded-lg border border-gray-200 bg-white p-2 shadow-lg dark:border-gray-700 dark:bg-gray-900",children:[t.jsxs("div",{className:"max-h-72 overflow-y-auto",children:[md.map(x=>t.jsxs("label",{className:"flex cursor-pointer items-center gap-2 rounded px-1 py-1 text-xs hover:bg-gray-100 dark:hover:bg-gray-800",children:[t.jsx("input",{type:"checkbox",checked:e.includes(x),onChange:()=>n(x)}),t.jsx("span",{className:"text-gray-800 dark:text-gray-100",children:X_[x]})]},x)),t.jsx("div",{className:"my-1 border-t border-gray-200 dark:border-gray-700"}),t.jsxs("label",{title:Z_,className:"flex cursor-pointer items-center gap-2 rounded px-1 py-1 text-xs hover:bg-gray-100 dark:hover:bg-gray-800",children:[t.jsx("input",{type:"checkbox",checked:!s,onChange:()=>a(!s)}),t.jsx("span",{className:"text-gray-800 dark:text-gray-100",children:"Show stale PRs"})]})]}),!u&&t.jsxs("div",{className:"mt-2 flex items-center justify-between border-t border-gray-200 pt-2 dark:border-gray-700",children:[t.jsxs("span",{className:"text-[11px] text-gray-400",children:[m," of ",h," shown"]}),t.jsx("button",{type:"button",onClick:g,className:"text-[11px] text-gray-400 hover:text-gray-600",children:"Reset to default"})]})]})]})}function tP(e){return Oe({queryKey:["attention-cards",dt(e)],queryFn:e==null?Ct:()=>he.attentionCards(e),refetchInterval:5*6e4,refetchIntervalInBackground:!1,staleTime:6e4,refetchOnWindowFocus:!0})}const nP=6e4,rP=90;function sP(e,n,r){const s=He(),a=n,i=Oe({queryKey:["attention-liveness",dt(e)],queryFn:e==null?Ct:()=>he.attentionLiveness(e,{prIds:a}),enabled:r&&a.length>0,refetchInterval:nP,refetchIntervalInBackground:!1,refetchOnWindowFocus:!0,staleTime:3e4,retry:!1,gcTime:0}),{data:c,dataUpdatedAt:d}=i;f.useEffect(()=>{!c||c.changed<=0||(s.invalidateQueries({queryKey:["attention-cards"]}),s.invalidateQueries({queryKey:["daily-brief"]}),s.invalidateQueries({queryKey:["work-plan"]}))},[c,d,s])}function ei(e){var r;const n=((r=In().data)==null?void 0:r.aiUsage)??void 0;return Oe({queryKey:["ai-usage"],queryFn:()=>he.aiUsage(),enabled:e,staleTime:3e4,placeholderData:n})}function Tx(e){return[dt(e)]}function LS(e){return{workspaceId:e}}function aP(e,n=!0){const{workPlan:r}=vt();return Oe({queryKey:["work-plan",...Tx(e)],queryFn:e==null?Ct:()=>he.workPlan(LS(e)),enabled:n&&r,staleTime:6e4,refetchInterval:5*6e4,refetchOnWindowFocus:!0})}function oP(e){const n=He(),r=Tx(e);return tt({mutationKey:["work-plan-generate",...r],mutationFn:()=>{if(e==null)throw new Error("No workspace selected");return he.workPlanGenerate(LS(e))},onSuccess:s=>{n.setQueryData(["work-plan",...r],a=>s.stale===void 0&&(a==null?void 0:a.stale)!==void 0?{...s,stale:a.stale}:s),n.invalidateQueries({queryKey:["ai-usage"]}),n.invalidateQueries({queryKey:["attention-cards"]})}})}function iP(e){return Or({mutationKey:["work-plan-generate",...Tx(e)]})>0}const Xc=Jo(e=>({open:!1,focus:null,openSettings:n=>e({open:!0,focus:n??null}),closeSettings:()=>e({open:!1,focus:null})})),is={my_turn:"My turn",fixing:"Needs fixing",review:"Waiting on review",threads:"Unanswered threads",land:"Ready to land",deps:"Dependencies"};function lP(e,n){if(e!=null){const r=L$(e);if(r!=null)return r}return n??"my_turn"}function cP(e){return e==="my_turn"}function dP(e,n){return n==null||e.kind!=="my_turn"?!0:n==="mine"?e.personal!==!1:e.relevance==="none"}function Lk(e,n){return n==null||F$(e)===n}function Fk(e,n){return n!=null&&e.authorTotals!=null?e.authorTotals[n]:e.total}function uP(e,n){return n!=null?!0:e!=null&&e.people>0&&e.automation>0}function Ok(e,n,r){var s,a,i;return r!=null?((a=(s=e==null?void 0:e.relevanceAuthorTotals)==null?void 0:s[n])==null?void 0:a[r])??null:((i=e==null?void 0:e.relevanceTotals)==null?void 0:i[n])??null}function FS(e){if((e==null?void 0:e.tabs)!=null)return e.tabs;const n=(e==null?void 0:e.cards)??[];return Ko.map(r=>{const s=r.kinds.filter(c=>c!=="reviewer_load"),a=n.filter(c=>s.includes(c.kind)),i={};for(const c of s)i[c]=a.filter(d=>d.kind===c).length;return{key:r.key,total:a.length,kindTotals:i,cardIds:a.map(c=>c.id),...r.kinds.includes("reviewer_load")?{peopleCardIds:n.filter(c=>c.kind==="reviewer_load").map(c=>c.id)}:{}}})}function hP(e,n,r,s,a){var N,I,S;const i=FS(e),c=i.find(T=>T.key===n)??i[0],d=new Map(((e==null?void 0:e.cards)??[]).map(T=>[T.id,T])),u=c.cardIds.map(T=>d.get(T)).filter(T=>T!=null),m=Object.keys(c.kindTotals),h=r!=null&&m.length>1&&m.includes(r)?r:null,g=n==="my_turn"?s:null,x=u.filter(T=>(h==null||T.kind===h)&&dP(T,g)),y=x.filter(T=>Lk(T,a)).slice(0,kh.boardListCap),b=x.length;let w,k;h!=null?(w=c.kindTotals[h]??b,k=((N=c.kindAuthorTotals)==null?void 0:N[h])??null):g!=null?(w=((I=c.relevanceTotals)==null?void 0:I[g])??b,k=((S=c.relevanceAuthorTotals)==null?void 0:S[g])??null):(w=c.total,k=c.authorTotals??null);const j=a!=null?(k==null?void 0:k[a])??y.length:w;return{tab:c.key,cards:y,doNextCount:Math.min(Al,y.length),shown:y.length,total:Math.max(j,y.length),chips:m.length>1?m.map(T=>{var $,P;return{kind:T,total:a!=null?((P=($=c.kindAuthorTotals)==null?void 0:$[T])==null?void 0:P[a])??u.filter(C=>C.kind===T&&Lk(C,a)).length:c.kindTotals[T]??0}}):null,kind:h,people:(c.peopleCardIds??[]).map(T=>d.get(T)).filter(T=>T!=null),authorSplit:k,allTotal:Math.max(w,Math.min(b,kh.boardListCap))}}function pP(e,n){if(n!=null)return!0;const r=e==null?void 0:e.relevanceTotals;return r!=null&&r.mine>0&&r.others>0}const ao=1e3*60*45;function ya(e){return Oe({queryKey:["pr",e],queryFn:()=>he.pr(e),enabled:e!=null,staleTime:1/0,gcTime:ao})}function Sp(e){return Oe({queryKey:["thread",e],queryFn:()=>he.thread(e),enabled:e!=null,staleTime:1/0,gcTime:ao})}function mP(e){return Oe({queryKey:["mention-candidates",e],queryFn:()=>he.mentionCandidates(e),enabled:e!=null,staleTime:1e3*60*5,gcTime:ao})}function gP(e,n=!0){return Oe({queryKey:["suggested-reviewers",e],queryFn:()=>he.suggestedReviewers(e),enabled:e!=null&&n,staleTime:1e3*60*2,gcTime:ao})}function fP(e){const n=He(),r=Oe({queryKey:["pr-files",e],queryFn:()=>he.prFiles(e),enabled:e!=null,staleTime:1/0,gcTime:ao}),s=ya(e),a=s.dataUpdatedAt,i=e!=null&&r.data!=null&&s.data!=null&&vP({headSha:r.data.headSha,at:r.dataUpdatedAt},{headSha:s.data.headSha,at:a}),c=r.isFetching,d=f.useRef(0);return f.useEffect(()=>{!i||c||e==null||d.current===a||(d.current=a,n.invalidateQueries({queryKey:["pr-files",e],exact:!0}))},[i,c,e,a,n]),r}function xP(e,n){var N;const r=(n==null?void 0:n.nextPage)??null,s=(n==null?void 0:n.headSha)??null,a=`${e}:${s}:${r}`,[i,c]=f.useState(null),d=rc({queryKey:["pr-files-more",e,s,r],queryFn:({pageParam:I})=>he.prFilesPage(e,I),initialPageParam:r??2,getNextPageParam:I=>I.nextPage??void 0,enabled:e!=null&&r!=null&&i===a,staleTime:1/0,gcTime:ao}),{fetchNextPage:u,hasNextPage:m,isFetching:h,refetch:g}=d,x=(((N=d.data)==null?void 0:N.pages.length)??0)>0,y=i===a,b=f.useCallback(()=>{if(!y){c(a);return}h||(x?m&&u():g())},[y,a,x,m,h,u,g]),w=f.useMemo(()=>{var I;return y?((I=d.data)==null?void 0:I.pages)??[]:[]},[y,d.data]),k=f.useMemo(()=>w.flatMap(I=>I.files),[w]),j=w[w.length-1];return{files:k,canLoadMore:r!=null&&(w.length===0||(j==null?void 0:j.nextPage)!=null),ceilingReached:(w.length===0?n==null?void 0:n.ceilingReached:j==null?void 0:j.ceilingReached)===!0,loading:y&&h,error:y&&d.isError,loadMore:b}}function yP(e,n,r,s,a){return Oe({queryKey:["pr-file-content",e,s,r,n],queryFn:()=>he.prFileContent(e,n,r),enabled:e!=null&&a,staleTime:1/0,gcTime:ao,retry:!1})}function bP(e,n,r,s,a){return Oe({queryKey:["pr-file-diff",e,s,n,r],queryFn:()=>he.prFileFullDiff(e,n,r),enabled:e!=null&&a,staleTime:1/0,gcTime:ao,retry:!1})}function vP(e,n){return n.headSha==null||!(n.at>e.at)?!1:(e.headSha??null)!==n.headSha}function OS(e){return e.kind==="team"?`team:${e.teamSlug??e.teamName??""}`:`user:${e.login??`#${e.userId??""}`}`}function kP(e){return e.kind==="team"?e.teamSlug?{teamSlugs:[e.teamSlug]}:null:e.userId!=null?{userIds:[e.userId]}:e.login?{logins:[e.login]}:null}function wP(e,n){var s;if(e.kind==="team"){const a=e.teamName??e.teamSlug;return a?`@${a}`:"this team"}const r=e.login??(e.userId!=null?(s=n==null?void 0:n.get(e.userId))==null?void 0:s.githubLogin:void 0);return r?`@${r}`:"this reviewer"}const jP="Couldn’t request this reviewer.";function NP(e){const n=e[e.length-1];if(n==null)return{status:"idle",error:null};if(n.status!=="error")return{status:n.status,error:null};const r=n.error instanceof Error?n.error.message.trim():"";return{status:"error",error:r!==""?r:jP}}const Cp=["auto-merge"];function ba(){var e;return((e=In().data)==null?void 0:e.mlSeverity)??!1}function Rp(e){return["ml-labels",e]}const gd=(e,n)=>`${e}|${n}`,SP=e=>{const n=new Map;for(const r of e.labels)n.set(gd(r.targetKind,r.targetId),r);return n};function Ip(e,n){return Oe({queryKey:Rp(e),queryFn:()=>he.prMlLabels(e),enabled:e!=null&&n,staleTime:1/0,select:SP}).data}function Tp(e){return e!=null&&e.enabled?e.running?!0:e.serviceHealthy===!1||e.pausedUntil||e.failuresThisRun>0&&e.scoredThisRun===0?!1:e.pending>0:!1}function $x(e){const n=ba();return Oe({queryKey:["ml-status"],queryFn:he.mlStatus,enabled:n,refetchInterval:r=>e||Tp(r.state.data)?4e3:6e4,refetchIntervalInBackground:!1})}const Dk=5e3,CP=6e4;function nd(e){return["pr-refresh",e]}function DS(e,n){const r=He(),s=f.useRef(0),a=Oe({queryKey:nd(e),queryFn:()=>he.refreshPr(e),enabled:n,staleTime:0,gcTime:0,retry:!1,refetchInterval:h=>{var w;const g=h.state.status==="success"&&((w=h.state.data)==null?void 0:w.synced)===!1;if(h.state.status!=="error"&&!g)return Dk;const x=Math.min(Dk*2**s.current,CP),y=h.state.error,b=y instanceof cn&&y.retryAfterSeconds!=null?y.retryAfterSeconds*1e3:0;return Math.max(x,b)},refetchIntervalInBackground:!1}),{data:i,dataUpdatedAt:c,status:d,errorUpdatedAt:u}=a;return f.useEffect(()=>{d==="error"||d==="success"&&(i==null?void 0:i.synced)===!1?s.current+=1:d==="success"&&(s.current=0)},[d,u,c,i]),f.useEffect(()=>{if(!(i!=null&&i.changed))return;const h=r.getQueryData(["pr",e]);r.invalidateQueries({queryKey:["pr",e]});for(const g of(h==null?void 0:h.threads)??[])r.invalidateQueries({queryKey:["thread",g.id]});r.invalidateQueries({queryKey:Rp(e)}),r.invalidateQueries({queryKey:["merge-options",e]}),r.invalidateQueries({queryKey:["timeline"]}),r.invalidateQueries({queryKey:["open-prs"]}),r.invalidateQueries({queryKey:["attention-cards"]}),r.invalidateQueries({queryKey:["daily-brief"]}),r.invalidateQueries({queryKey:["work-plan"]})},[i,c,e,r]),{refreshNow:f.useCallback(()=>{r.cancelQueries({queryKey:nd(e)}).then(()=>r.fetchQuery({queryKey:nd(e),queryFn:()=>he.refreshPr(e,{wait:!0}),staleTime:0})).catch(()=>{})},[e,r]),isRefreshing:a.isFetching,isStale:d==="error"||(i==null?void 0:i.synced)===!1}}const RP=15e4,IP=5e3,BS=5e3;function TP(){return[...ac.map(e=>[e]),["timeline"],["open-prs"],["my-turn"],["me"]]}function $P(e,n){const r=[["pr",n]],s=e.getQueryData(["pr",n]),a=Array.isArray(s==null?void 0:s.threads)?s.threads:[];for(const i of a)typeof(i==null?void 0:i.id)=="number"&&r.push(["thread",i.id]);return r.push(["merge-options",n],Rp(n),["pr-bot-behaviour",n]),r}function _P(e){return e==null?[]:typeof e=="number"?[e]:[...e]}function PP(e,n,r){const s=[];for(const a of n)s.push(...$P(e,a));for(const a of r.threadIds??[])s.push(["thread",a]);return s}function EP(e){const n=[];return e.merged&&n.push(["mergers"],["branch-status"]),e.armed&&n.push([...Cp]),n}function AP(e){const n=new Set,r=[];for(const s of e){const a=JSON.stringify(s);n.has(a)||(n.add(a),r.push(s))}return r}function WS(e,n){return Promise.all(AP(n).map(r=>e.invalidateQueries({queryKey:r}))).then(()=>{})}function dn(e,n,r={}){const s=_P(n);return UP(Date.now(),s),qS(e,{prKeys:PP(e,s,r),prIds:s,extras:EP(r),readRepos:!0})}const ef=new WeakMap;function MP(e){let n=ef.get(e);return n==null&&(n={lastStartAt:0,running:null,pending:null,timer:null,absorbed:null},ef.set(e,n)),n}function LP(e){var n;return((n=ef.get(e))==null?void 0:n.absorbed)??null}function qS(e,n){const r=MP(e);if(r.running==null&&r.pending==null&&Date.now()-r.lastStartAt>=BS)return US(e,r,n);const s=WS(e,n.prKeys);let a=r.pending;if(a==null){let i=()=>{};const c=new Promise(d=>{i=d});a={extras:[],readRepos:!1,done:c,resolve:i},r.pending=a}return a.extras.push(...n.extras),a.readRepos=a.readRepos||n.readRepos,FP(e,r),Promise.all([s,a.done]).then(()=>{})}function FP(e,n){if(n.timer!=null)return;const r=Math.max(0,n.lastStartAt+BS-Date.now());n.timer=setTimeout(()=>{n.timer=null;const s=()=>{const a=n.pending;a!=null&&(n.pending=null,US(e,n,{prKeys:[],prIds:[],extras:a.extras,readRepos:a.readRepos}).then(a.resolve))};n.running!=null?n.running.then(s):s()},r)}function US(e,n,r){n.lastStartAt=Date.now();const s=(async()=>{r.readRepos&&(await e.invalidateQueries({queryKey:["repos"]}),n.absorbed={stamps:KS(e.getQueryData(["repos"])),prIds:new Set(r.prIds)}),await WS(e,[...r.prKeys,...TP(),...r.extras])})().catch(()=>{});return n.running=s,s.then(()=>{n.running===s&&(n.running=null)}),s}function OP(e,n){const r=e.getQueryCache().find({queryKey:nd(n),exact:!0});return(r==null?void 0:r.isActive())===!0}function HS(e,n={}){const{repoIds:r,skipPrIds:s}=n,a=d=>{var m;const u=(m=e.getQueryData(["pr",d]))==null?void 0:m.repoId;return typeof u=="number"?u:null},i=[],c=zS();for(const d of c){if(s!=null&&s.has(d))continue;const u=a(d);r!=null&&u!=null&&!r.has(u)||i.push(e.invalidateQueries({queryKey:["pr",d]}),e.invalidateQueries({queryKey:["merge-options",d]}))}return i.push(e.invalidateQueries({queryKey:["merge-options"],type:"active",predicate:d=>{const u=d.queryKey[1];if(typeof u!="number"||c.has(u)||s!=null&&s.has(u))return!1;const m=a(u);return m==null||r!=null&&!r.has(m)?!1:!OP(e,u)}})),n.workspaceSwept||i.push(n.otherWorkspaceIds!=null?DP(e,n.otherWorkspaceIds):qS(e,{prKeys:[],prIds:[],extras:[],readRepos:!1})),Promise.all(i).then(()=>{})}function DP(e,n){const r=new Set([...n].map(s=>dt(s)));return Promise.all([e.invalidateQueries({predicate:s=>s.queryKey.some(a=>typeof a=="string"&&r.has(a)),refetchType:"none"}),e.invalidateQueries({queryKey:["my-turn"]}),e.invalidateQueries({queryKey:["timeline"],predicate:s=>typeof s.queryKey[1]=="string"&&s.queryKey[1].startsWith("prIds=")})]).then(()=>{})}function BP(e){if(e.prev==null)return null;const n=VP(e.prev,e.next);if(n.size===0)return null;const{absorbed:r}=e,s=r!=null&&[...n].every(i=>{const c=r.stamps.get(i),d=e.next.get(i);return c!=null&&d!=null&&d<=c}),a=WP(n,e.repoWorkspaces??null,e.currentWorkspaceId??null);return{repoIds:n,workspaceSwept:e.walkSwept||s,...s?{skipPrIds:r.prIds}:{},...a!=null?{otherWorkspaceIds:a}:{}}}function WP(e,n,r){if(r==null||n==null)return null;const s=new Set;for(const a of e){const i=n.get(a);if(i==null||i===r)return null;s.add(i)}return s}function qP(e){const n=new Map;if(!Array.isArray(e))return n;for(const r of e){const s=r==null?void 0:r.id,a=r==null?void 0:r.workspaceId;typeof s=="number"&&typeof a=="number"&&n.set(s,a)}return n}let _h=0;const tf=new Map,nf=new Set;function UP(e=Date.now(),n=[]){const r=e+RP;for(const s of n)tf.set(s,r);if(!(r<=_h)){_h=r;for(const s of nf)s()}}function zS(e=Date.now()){const n=new Set;for(const[r,s]of tf)s<=e?tf.delete(r):n.add(r);return n}function HP(e=Date.now()){return e<_h}function zP(){return _h}function KP(e){return nf.add(e),()=>{nf.delete(e)}}function KS(e){const n=new Map;if(!Array.isArray(e))return n;for(const r of e){const s=r==null?void 0:r.lastPrChangeAt,a=r==null?void 0:r.id;if(typeof s!="string"||typeof a!="number")continue;const i=Date.parse(s);Number.isFinite(i)&&n.set(a,i)}return n}function GP(e){return[...e].map(([n,r])=>`${n}:${r}`).join(",")}function VP(e,n){const r=new Set;for(const[s,a]of n){const i=e.get(s);(i==null||a>i)&&r.add(s)}return r}function QP(){const e=He();return tt({mutationFn:n=>he.replyToThread(n.threadId,{body:n.body}),onSuccess:(n,r)=>{dn(e,r.prId,{threadIds:[r.threadId]})}})}function YP(){const e=He();return tt({mutationFn:n=>he.resolveThread(n.threadId,{resolved:n.resolved}),onSuccess:(n,r)=>{dn(e,r.prId,{threadIds:[r.threadId]})}})}function GS(){const e=He();return tt({mutationFn:n=>he.resolveBotThreads(n.prId,{threadIds:n.threadIds}),onSuccess:(n,r)=>{dn(e,r.prId,{threadIds:r.threadIds})}})}function XP(e){const n=He();return tt({mutationFn:r=>he.createPrComment(e,{body:r}),onSuccess:()=>void dn(n,e)})}function ZP(e){const n=He();return tt({mutationFn:r=>he.approvePr(e,r!==void 0?{body:r}:void 0),onSuccess:()=>void dn(n,e)})}function JP(e){const n=He();return tt({mutationFn:r=>he.requestChanges(e,r!==void 0?{body:r}:void 0),onSuccess:()=>void dn(n,e)})}function _x(e,n){return Oe({queryKey:["merge-options",e],queryFn:()=>he.mergeOptions(e),enabled:n,staleTime:3e4})}function VS(e){return["merge-pr",e]}function QS(e){return["update-pr-branch",e]}function eE(e){const n=He();return tt({mutationKey:VS(e),mutationFn:r=>he.mergePr(e,{method:r}),onSuccess:()=>void dn(n,e,{merged:!0})})}function rd(e,n){return n==null?["merge-queue",e]:["merge-queue",e,n]}function tE(e){const n=He();return tt({mutationKey:rd(e,"enqueue"),mutationFn:r=>he.enqueueMergeQueue(e,r?{method:r}:void 0),onSuccess:()=>dn(n,e)})}function nE(e){const n=He();return tt({mutationKey:rd(e,"dequeue"),mutationFn:()=>he.dequeueMergeQueue(e),onSuccess:()=>dn(n,e)})}function rE(e){const n=He();return tt({mutationFn:()=>he.closePr(e),onSuccess:()=>void dn(n,e)})}function sE(e){const n=He();return tt({mutationFn:()=>he.reopenPr(e),onSuccess:()=>void dn(n,e)})}function aE(e){const n=He();return tt({mutationKey:QS(e),mutationFn:r=>he.updatePrBranch(e,r),onSuccess:()=>void dn(n,e)})}function oE(e){const n=He();return tt({mutationFn:r=>he.addReviewComment(e,r),onSuccess:()=>void dn(n,e)})}function rf(e,n){return n==null?["request-reviewers",e]:["request-reviewers",e,n]}function iE(e,n,r){return{mutationKey:rf(n,r),mutationFn:s=>he.requestReviewers(n,s),onSuccess:()=>{if(e.invalidateQueries({queryKey:["suggested-reviewers",n]}),e.isMutating({mutationKey:rf(n)})>1){e.invalidateQueries({queryKey:["pr",n]});return}dn(e,n)}}}function YS(e,n){const r=He();return tt(iE(r,e,n))}function lE(e,n){const r=ZT({filters:{mutationKey:rf(e,n)},select:s=>({status:s.state.status,error:s.state.error})});return NP(r)}function XS(e){const n=He(),r=f.useCallback(s=>n.getQueryCache().subscribe(JT.batchCalls(s)),[n]);return f.useSyncExternalStore(r,()=>{var s;return((s=n.getQueryState(e))==null?void 0:s.dataUpdatedAt)??0})}const vl=new Map,cE=200;function ZS(e,n,r,s,a){const i=He(),c=n!==void 0&&s!=null&&a>r&&s.inQueue!==(n===!0);f.useEffect(()=>{if(!(!c||vl.get(e)===a)){if(vl.delete(e),vl.set(e,a),vl.size>cE){const d=vl.keys().next().value;d!==void 0&&vl.delete(d)}i.invalidateQueries({queryKey:["pr",e]}),HS(i,{repoIds:new Set,skipPrIds:new Set([e,...zS()])})}},[c,a,e,i])}const dE=45e3,uE=8e3;function Px(e=!0){return Oe({queryKey:Cp,queryFn:()=>he.armedMerges(),enabled:e,refetchInterval:n=>{var r,s;return(s=(r=n.state.data)==null?void 0:r.requests)!=null&&s.some(a=>a.state==="armed")?uE:dE},refetchIntervalInBackground:!1,staleTime:5e3})}function Di(e){const{data:n}=Px();return e==null?null:(n==null?void 0:n.requests.find(r=>r.prId===e&&r.state==="armed"))??null}function JS(e){const{data:n}=Px();if(e==null)return null;const r=(n==null?void 0:n.requests.filter(s=>s.prId===e))??[];return r.some(s=>s.state==="armed")?null:r.find(s=>s.state!=="armed"&&s.state!=="merged")??null}function hE(e,n){switch(n.type){case"ask":return e==="idle"?"asked":e;case"confirm":return"confirming";case"cancel":return e==="confirming"?"asked":e;case"settled":return"idle"}}function pE(e){return e.intentArmed?"armed":e.posting?"arming":e.draft}const sf=new Map,af=new Set;function mE(e){return af.add(e),()=>{af.delete(e)}}function e5(e){return sf.get(e)??"idle"}function gE(e){return f.useSyncExternalStore(mE,()=>e5(e))}function Ml(e,n){const r=e5(e),s=hE(r,n);if(s!==r){s==="idle"?sf.delete(e):sf.set(e,s);for(const a of af)a()}}function t5(e){return["arm-auto-merge",e]}function fE(e){const n=He();return tt({mutationKey:t5(e),mutationFn:r=>he.armAutoMerge(e,r),onSuccess:r=>{n.setQueryData(Cp,s=>s==null?{requests:[r]}:{requests:[r,...s.requests.filter(a=>a.prId!==r.prId)]}),dn(n,e,{armed:!0}),Ml(e,{type:"settled"})},onError:r=>{!(r instanceof cn)||r.status!==409||dn(n,e).then(()=>{var s,a;((a=(s=n.getQueryData(["merge-options",e]))==null?void 0:s.mergeQueue)==null?void 0:a.inQueue)===!0&&Ml(e,{type:"settled"})})}})}function Ex(e){const n=He();return tt({mutationFn:()=>he.disarmAutoMerge(e),onSuccess:()=>{n.setQueryData(Cp,r=>r==null?r:{requests:r.requests.filter(s=>s.prId!==e)}),dn(n,e,{armed:!0}),Ml(e,{type:"settled"})}})}async function of(e){await Promise.all([e.invalidateQueries({queryKey:["my-turn"]}),e.invalidateQueries({queryKey:["attention-cards"]}),e.invalidateQueries({queryKey:["daily-brief"]}),e.invalidateQueries({queryKey:["work-plan"]})])}const Ph=Jo(e=>({last:null,show:n=>e({last:n}),clear:()=>e({last:null})}));let lf=!1;function xE(){const e=lf;return lf=!1,e}const yE=e=>["my-turn-dismiss",e.kind,e.id];function bE(e,n){const r=He(),s=Ph(a=>a.show);return tt({mutationKey:yE(e),mutationFn:()=>he.dismissMyTurn(e),onSuccess:async()=>{await of(r),s({target:e,label:n})}})}function n5(){const e=He(),n=Ph(r=>r.clear);return tt({mutationKey:["my-turn-restore"],mutationFn:r=>he.restoreMyTurn(r),onSuccess:async()=>{lf=!0,n(),await of(e)},onError:async()=>{n(),await of(e)}})}const vE=new Set(["charOff","compact","hSpace","isMap","longDesc","noHref","noShade","noWrap","vAlign"]);function kE(e){return Object.fromEntries(Object.entries(e).map(([n,r])=>[n,r.filter(s=>{const a=Array.isArray(s)?s[0]:s;return typeof a!="string"||!vE.has(a)})]))}const wE={...$g,tagNames:[...$g.tagNames??[],"img"],attributes:kE({...$g.attributes,img:["src","alt","title","width","height"]})};function jE(e,n){const r=i=>{const c=typeof i=="number"?i:typeof i=="string"?Number(i.trim()):NaN;return Number.isFinite(c)&&c>0?`${c}px`:null},s=r(e),a=r(n);if(!(!s&&!a))return{...s?{"--md-img-w":s}:{},...a?{"--md-img-h":a}:{}}}const gr=f.memo(function({children:n}){return t.jsx("div",{className:"md-body",children:t.jsx(s$,{remarkPlugins:[i$],rehypePlugins:[a$,[o$,wE],[l$,{detect:!0,ignoreMissing:!0}]],components:{a:({node:r,...s})=>t.jsx("a",{...s,target:"_blank",rel:"noreferrer noopener"}),img:({node:r,...s})=>t.jsx("img",{...s,style:jE(s.width,s.height),loading:"lazy",referrerPolicy:"no-referrer"})},children:n})})});function Ax(){const{data:e}=fp();return f.useMemo(()=>{const n=new Map;for(const r of e??[])n.set(r.repoId,new Set(r.userIds));return n},[e])}function $p({className:e,title:n="Has merge rights — has merged a PR in this repo"}){return t.jsxs("svg",{viewBox:"0 0 16 16",width:"11",height:"11","aria-hidden":"true",className:["inline-block shrink-0",e].filter(Boolean).join(" "),children:[t.jsx("title",{children:n}),t.jsx("path",{fill:"#8957e5",d:"M8 .8 2.2 2.9v4.2c0 3.3 2.5 6.4 5.8 7.3 3.3-.9 5.8-4 5.8-7.3V2.9L8 .8Z"}),t.jsx("path",{d:"M5.2 8 7.1 9.9 10.9 6",fill:"none",stroke:"#fff",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round"})]})}function _p(){return typeof window<"u"}function ti(e){return Mx(e)?(e.nodeName||"").toLowerCase():"#document"}function Gr(e){var n;return(e==null||(n=e.ownerDocument)==null?void 0:n.defaultView)||window}function va(e){var n;return(n=(Mx(e)?e.ownerDocument:e.document)||window.document)==null?void 0:n.documentElement}function Mx(e){return _p()?e instanceof Node||e instanceof Gr(e).Node:!1}function on(e){return _p()?e instanceof Element||e instanceof Gr(e).Element:!1}function tr(e){return _p()?e instanceof HTMLElement||e instanceof Gr(e).HTMLElement:!1}function Eh(e){return!_p()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Gr(e).ShadowRoot}function Sd(e){const{overflow:n,overflowX:r,overflowY:s,display:a}=Es(e);return/auto|scroll|overlay|hidden|clip/.test(n+s+r)&&a!=="inline"&&a!=="contents"}function NE(e){return/^(table|td|th)$/.test(ti(e))}function Pp(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const SE=/transform|translate|scale|rotate|perspective|filter/,CE=/paint|layout|strict|content/,vi=e=>!!e&&e!=="none";let Og;function Lx(e){const n=on(e)?Es(e):e;return vi(n.transform)||vi(n.translate)||vi(n.scale)||vi(n.rotate)||vi(n.perspective)||!Ep()&&(vi(n.backdropFilter)||vi(n.filter))||SE.test(n.willChange||"")||CE.test(n.contain||"")}function RE(e){let n=no(e);for(;tr(n)&&!to(n);){if(Lx(n))return n;if(Pp(n))return null;n=no(n)}return null}function Ep(){return Og==null&&(Og=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Og}function to(e){return/^(html|body|#document)$/.test(ti(e))}function Es(e){return Gr(e).getComputedStyle(e)}function Ap(e){return on(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function no(e){if(ti(e)==="html")return e;const n=e.assignedSlot||e.parentNode||Eh(e)&&e.host||va(e);return Eh(n)?n.host:n}function r5(e){const n=no(e);return to(n)?e.ownerDocument?e.ownerDocument.body:e.body:tr(n)&&Sd(n)?n:r5(n)}function Ho(e,n,r){var s;n===void 0&&(n=[]),r===void 0&&(r=!0);const a=r5(e),i=a===((s=e.ownerDocument)==null?void 0:s.body),c=Gr(a);if(i){const d=cf(c);return n.concat(c,c.visualViewport||[],Sd(a)?a:[],d&&r?Ho(d):[])}else return n.concat(a,Ho(a,[],r))}function cf(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}const Vl=Math.min,ls=Math.max,Ah=Math.round,$l=Math.floor,ga=e=>({x:e,y:e}),IE={left:"right",right:"left",bottom:"top",top:"bottom"};function Bk(e,n,r){return ls(e,Vl(n,r))}function Cd(e,n){return typeof e=="function"?e(n):e}function Yo(e){return e.split("-")[0]}function Rd(e){return e.split("-")[1]}function s5(e){return e==="x"?"y":"x"}function a5(e){return e==="y"?"height":"width"}function Za(e){const n=e[0];return n==="t"||n==="b"?"y":"x"}function o5(e){return s5(Za(e))}function TE(e,n,r){r===void 0&&(r=!1);const s=Rd(e),a=o5(e),i=a5(a);let c=a==="x"?s===(r?"end":"start")?"right":"left":s==="start"?"bottom":"top";return n.reference[i]>n.floating[i]&&(c=Mh(c)),[c,Mh(c)]}function $E(e){const n=Mh(e);return[df(e),n,df(n)]}function df(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const Wk=["left","right"],qk=["right","left"],_E=["top","bottom"],PE=["bottom","top"];function EE(e,n,r){switch(e){case"top":case"bottom":return r?n?qk:Wk:n?Wk:qk;case"left":case"right":return n?_E:PE;default:return[]}}function AE(e,n,r,s){const a=Rd(e);let i=EE(Yo(e),r==="start",s);return a&&(i=i.map(c=>c+"-"+a),n&&(i=i.concat(i.map(df)))),i}function Mh(e){const n=Yo(e);return IE[n]+e.slice(n.length)}function ME(e){return{top:0,right:0,bottom:0,left:0,...e}}function LE(e){return typeof e!="number"?ME(e):{top:e,right:e,bottom:e,left:e}}function Lh(e){const{x:n,y:r,width:s,height:a}=e;return{width:s,height:a,top:r,left:n,right:n+s,bottom:r+a,x:n,y:r}}/*!
30
+ * tabbable 6.4.0
31
+ * @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE
32
+ */var FE=["input:not([inert]):not([inert] *)","select:not([inert]):not([inert] *)","textarea:not([inert]):not([inert] *)","a[href]:not([inert]):not([inert] *)","button:not([inert]):not([inert] *)","[tabindex]:not(slot):not([inert]):not([inert] *)","audio[controls]:not([inert]):not([inert] *)","video[controls]:not([inert]):not([inert] *)",'[contenteditable]:not([contenteditable="false"]):not([inert]):not([inert] *)',"details>summary:first-of-type:not([inert]):not([inert] *)","details:not([inert]):not([inert] *)"],Fh=FE.join(","),i5=typeof Element>"u",Ql=i5?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,Oh=!i5&&Element.prototype.getRootNode?function(e){var n;return e==null||(n=e.getRootNode)===null||n===void 0?void 0:n.call(e)}:function(e){return e==null?void 0:e.ownerDocument},Dh=function(n,r){var s;r===void 0&&(r=!0);var a=n==null||(s=n.getAttribute)===null||s===void 0?void 0:s.call(n,"inert"),i=a===""||a==="true",c=i||r&&n&&(typeof n.closest=="function"?n.closest("[inert]"):Dh(n.parentNode));return c},OE=function(n){var r,s=n==null||(r=n.getAttribute)===null||r===void 0?void 0:r.call(n,"contenteditable");return s===""||s==="true"},l5=function(n,r,s){if(Dh(n))return[];var a=Array.prototype.slice.apply(n.querySelectorAll(Fh));return r&&Ql.call(n,Fh)&&a.unshift(n),a=a.filter(s),a},Bh=function(n,r,s){for(var a=[],i=Array.from(n);i.length;){var c=i.shift();if(!Dh(c,!1))if(c.tagName==="SLOT"){var d=c.assignedElements(),u=d.length?d:c.children,m=Bh(u,!0,s);s.flatten?a.push.apply(a,m):a.push({scopeParent:c,candidates:m})}else{var h=Ql.call(c,Fh);h&&s.filter(c)&&(r||!n.includes(c))&&a.push(c);var g=c.shadowRoot||typeof s.getShadowRoot=="function"&&s.getShadowRoot(c),x=!Dh(g,!1)&&(!s.shadowRootFilter||s.shadowRootFilter(c));if(g&&x){var y=Bh(g===!0?c.children:g.children,!0,s);s.flatten?a.push.apply(a,y):a.push({scopeParent:c,candidates:y})}else i.unshift.apply(i,c.children)}}return a},c5=function(n){return!isNaN(parseInt(n.getAttribute("tabindex"),10))},d5=function(n){if(!n)throw new Error("No node provided");return n.tabIndex<0&&(/^(AUDIO|VIDEO|DETAILS)$/.test(n.tagName)||OE(n))&&!c5(n)?0:n.tabIndex},DE=function(n,r){var s=d5(n);return s<0&&r&&!c5(n)?0:s},BE=function(n,r){return n.tabIndex===r.tabIndex?n.documentOrder-r.documentOrder:n.tabIndex-r.tabIndex},u5=function(n){return n.tagName==="INPUT"},WE=function(n){return u5(n)&&n.type==="hidden"},qE=function(n){var r=n.tagName==="DETAILS"&&Array.prototype.slice.apply(n.children).some(function(s){return s.tagName==="SUMMARY"});return r},UE=function(n,r){for(var s=0;s<n.length;s++)if(n[s].checked&&n[s].form===r)return n[s]},HE=function(n){if(!n.name)return!0;var r=n.form||Oh(n),s=function(d){return r.querySelectorAll('input[type="radio"][name="'+d+'"]')},a;if(typeof window<"u"&&typeof window.CSS<"u"&&typeof window.CSS.escape=="function")a=s(window.CSS.escape(n.name));else try{a=s(n.name)}catch(c){return console.error("Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s",c.message),!1}var i=UE(a,n.form);return!i||i===n},zE=function(n){return u5(n)&&n.type==="radio"},KE=function(n){return zE(n)&&!HE(n)},GE=function(n){var r,s=n&&Oh(n),a=(r=s)===null||r===void 0?void 0:r.host,i=!1;if(s&&s!==n){var c,d,u;for(i=!!((c=a)!==null&&c!==void 0&&(d=c.ownerDocument)!==null&&d!==void 0&&d.contains(a)||n!=null&&(u=n.ownerDocument)!==null&&u!==void 0&&u.contains(n));!i&&a;){var m,h,g;s=Oh(a),a=(m=s)===null||m===void 0?void 0:m.host,i=!!((h=a)!==null&&h!==void 0&&(g=h.ownerDocument)!==null&&g!==void 0&&g.contains(a))}}return i},Uk=function(n){var r=n.getBoundingClientRect(),s=r.width,a=r.height;return s===0&&a===0},VE=function(n,r){var s=r.displayCheck,a=r.getShadowRoot;if(s==="full-native"&&"checkVisibility"in n){var i=n.checkVisibility({checkOpacity:!1,opacityProperty:!1,contentVisibilityAuto:!0,visibilityProperty:!0,checkVisibilityCSS:!0});return!i}if(getComputedStyle(n).visibility==="hidden")return!0;var c=Ql.call(n,"details>summary:first-of-type"),d=c?n.parentElement:n;if(Ql.call(d,"details:not([open]) *"))return!0;if(!s||s==="full"||s==="full-native"||s==="legacy-full"){if(typeof a=="function"){for(var u=n;n;){var m=n.parentElement,h=Oh(n);if(m&&!m.shadowRoot&&a(m)===!0)return Uk(n);n.assignedSlot?n=n.assignedSlot:!m&&h!==n.ownerDocument?n=h.host:n=m}n=u}if(GE(n))return!n.getClientRects().length;if(s!=="legacy-full")return!0}else if(s==="non-zero-area")return Uk(n);return!1},QE=function(n){if(/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(n.tagName))for(var r=n.parentElement;r;){if(r.tagName==="FIELDSET"&&r.disabled){for(var s=0;s<r.children.length;s++){var a=r.children.item(s);if(a.tagName==="LEGEND")return Ql.call(r,"fieldset[disabled] *")?!0:!a.contains(n)}return!0}r=r.parentElement}return!1},uf=function(n,r){return!(r.disabled||WE(r)||VE(r,n)||qE(r)||QE(r))},hf=function(n,r){return!(KE(r)||d5(r)<0||!uf(n,r))},YE=function(n){var r=parseInt(n.getAttribute("tabindex"),10);return!!(isNaN(r)||r>=0)},h5=function(n){var r=[],s=[];return n.forEach(function(a,i){var c=!!a.scopeParent,d=c?a.scopeParent:a,u=DE(d,c),m=c?h5(a.candidates):d;u===0?c?r.push.apply(r,m):r.push(d):s.push({documentOrder:i,tabIndex:u,item:a,isScope:c,content:m})}),s.sort(BE).reduce(function(a,i){return i.isScope?a.push.apply(a,i.content):a.push(i.content),a},[]).concat(r)},Mp=function(n,r){r=r||{};var s;return r.getShadowRoot?s=Bh([n],r.includeContainer,{filter:hf.bind(null,r),flatten:!1,getShadowRoot:r.getShadowRoot,shadowRootFilter:YE}):s=l5(n,r.includeContainer,hf.bind(null,r)),h5(s)},XE=function(n,r){r=r||{};var s;return r.getShadowRoot?s=Bh([n],r.includeContainer,{filter:uf.bind(null,r),flatten:!0,getShadowRoot:r.getShadowRoot}):s=l5(n,r.includeContainer,uf.bind(null,r)),s},p5=function(n,r){if(r=r||{},!n)throw new Error("No node provided");return Ql.call(n,Fh)===!1?!1:hf(r,n)};function m5(){const e=navigator.userAgentData;return e!=null&&e.platform?e.platform:navigator.platform}function g5(){const e=navigator.userAgentData;return e&&Array.isArray(e.brands)?e.brands.map(n=>{let{brand:r,version:s}=n;return r+"/"+s}).join(" "):navigator.userAgent}function f5(){return/apple/i.test(navigator.vendor)}function pf(){const e=/android/i;return e.test(m5())||e.test(g5())}function ZE(){return m5().toLowerCase().startsWith("mac")&&!navigator.maxTouchPoints}function x5(){return g5().includes("jsdom/")}const Hk="data-floating-ui-focusable",JE="input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])",Dg="ArrowLeft",Bg="ArrowRight",eA="ArrowUp",tA="ArrowDown";function pa(e){let n=e.activeElement;for(;((r=n)==null||(r=r.shadowRoot)==null?void 0:r.activeElement)!=null;){var r;n=n.shadowRoot.activeElement}return n}function dr(e,n){if(!e||!n)return!1;const r=n.getRootNode==null?void 0:n.getRootNode();if(e.contains(n))return!0;if(r&&Eh(r)){let s=n;for(;s;){if(e===s)return!0;s=s.parentNode||s.host}}return!1}function Qa(e){return"composedPath"in e?e.composedPath()[0]:e.target}function Wg(e,n){if(n==null)return!1;if("composedPath"in e)return e.composedPath().includes(n);const r=e;return r.target!=null&&n.contains(r.target)}function nA(e){return e.matches("html,body")}function ur(e){return(e==null?void 0:e.ownerDocument)||document}function y5(e){return tr(e)&&e.matches(JE)}function mf(e){return e?e.getAttribute("role")==="combobox"&&y5(e):!1}function rA(e){if(!e||x5())return!0;try{return e.matches(":focus-visible")}catch{return!0}}function Wh(e){return e?e.hasAttribute(Hk)?e:e.querySelector("["+Hk+"]")||e:null}function _i(e,n,r){return r===void 0&&(r=!0),e.filter(a=>{var i;return a.parentId===n&&(!r||((i=a.context)==null?void 0:i.open))}).flatMap(a=>[a,..._i(e,a.id,r)])}function sA(e,n){let r,s=-1;function a(i,c){c>s&&(r=i,s=c),_i(e,i).forEach(u=>{a(u.id,c+1)})}return a(n,0),e.find(i=>i.id===r)}function zk(e,n){var r;let s=[],a=(r=e.find(i=>i.id===n))==null?void 0:r.parentId;for(;a;){const i=e.find(c=>c.id===a);a=i==null?void 0:i.parentId,i&&(s=s.concat(i))}return s}function Mr(e){e.preventDefault(),e.stopPropagation()}function aA(e){return"nativeEvent"in e}function b5(e){return e.mozInputSource===0&&e.isTrusted?!0:pf()&&e.pointerType?e.type==="click"&&e.buttons===1:e.detail===0&&!e.pointerType}function v5(e){return x5()?!1:!pf()&&e.width===0&&e.height===0||pf()&&e.width===1&&e.height===1&&e.pressure===0&&e.detail===0&&e.pointerType==="mouse"||e.width<1&&e.height<1&&e.pressure===0&&e.detail===0&&e.pointerType==="touch"}function gf(e,n){const r=["mouse","pen"];return r.push("",void 0),r.includes(e)}var oA=typeof document<"u",iA=function(){},En=oA?f.useLayoutEffect:iA;const lA={...qN};function Rs(e){const n=f.useRef(e);return En(()=>{n.current=e}),n}const cA=lA.useInsertionEffect,dA=cA||(e=>e());function hr(e){const n=f.useRef(()=>{});return dA(()=>{n.current=e}),f.useCallback(function(){for(var r=arguments.length,s=new Array(r),a=0;a<r;a++)s[a]=arguments[a];return n.current==null?void 0:n.current(...s)},[])}function Au(e,n,r){return Math.floor(e/n)!==r}function sd(e,n){return n<0||n>=e.current.length}function qg(e,n){return jr(e,{disabledIndices:n})}function Kk(e,n){return jr(e,{decrement:!0,startingIndex:e.current.length,disabledIndices:n})}function jr(e,n){let{startingIndex:r=-1,decrement:s=!1,disabledIndices:a,amount:i=1}=n===void 0?{}:n,c=r;do c+=s?-i:i;while(c>=0&&c<=e.current.length-1&&sh(e,c,a));return c}function uA(e,n){let{event:r,orientation:s,loop:a,rtl:i,cols:c,disabledIndices:d,minIndex:u,maxIndex:m,prevIndex:h,stopEvent:g=!1}=n,x=h;if(r.key===eA){if(g&&Mr(r),h===-1)x=m;else if(x=jr(e,{startingIndex:x,amount:c,decrement:!0,disabledIndices:d}),a&&(h-c<u||x<0)){const y=h%c,b=m%c,w=m-(b-y);b===y?x=m:x=b>y?w:w-c}sd(e,x)&&(x=h)}if(r.key===tA&&(g&&Mr(r),h===-1?x=u:(x=jr(e,{startingIndex:h,amount:c,disabledIndices:d}),a&&h+c>m&&(x=jr(e,{startingIndex:h%c-c,amount:c,disabledIndices:d}))),sd(e,x)&&(x=h)),s==="both"){const y=$l(h/c);r.key===(i?Dg:Bg)&&(g&&Mr(r),h%c!==c-1?(x=jr(e,{startingIndex:h,disabledIndices:d}),a&&Au(x,c,y)&&(x=jr(e,{startingIndex:h-h%c-1,disabledIndices:d}))):a&&(x=jr(e,{startingIndex:h-h%c-1,disabledIndices:d})),Au(x,c,y)&&(x=h)),r.key===(i?Bg:Dg)&&(g&&Mr(r),h%c!==0?(x=jr(e,{startingIndex:h,decrement:!0,disabledIndices:d}),a&&Au(x,c,y)&&(x=jr(e,{startingIndex:h+(c-h%c),decrement:!0,disabledIndices:d}))):a&&(x=jr(e,{startingIndex:h+(c-h%c),decrement:!0,disabledIndices:d})),Au(x,c,y)&&(x=h));const b=$l(m/c)===y;sd(e,x)&&(a&&b?x=r.key===(i?Bg:Dg)?m:jr(e,{startingIndex:h-h%c-1,disabledIndices:d}):x=h)}return x}function hA(e,n,r){const s=[];let a=0;return e.forEach((i,c)=>{let{width:d,height:u}=i,m=!1;for(r&&(a=0);!m;){const h=[];for(let g=0;g<d;g++)for(let x=0;x<u;x++)h.push(a+g+x*n);a%n+d<=n&&h.every(g=>s[g]==null)?(h.forEach(g=>{s[g]=c}),m=!0):a++}}),[...s]}function pA(e,n,r,s,a){if(e===-1)return-1;const i=r.indexOf(e),c=n[e];switch(a){case"tl":return i;case"tr":return c?i+c.width-1:i;case"bl":return c?i+(c.height-1)*s:i;case"br":return r.lastIndexOf(e)}}function mA(e,n){return n.flatMap((r,s)=>e.includes(r)?[s]:[])}function sh(e,n,r){if(typeof r=="function")return r(n);if(r)return r.includes(n);const s=e.current[n];return s==null||s.hasAttribute("disabled")||s.getAttribute("aria-disabled")==="true"}const Id=()=>({getShadowRoot:!0,displayCheck:typeof ResizeObserver=="function"&&ResizeObserver.toString().includes("[native code]")?"full":"none"});function k5(e,n){const r=Mp(e,Id()),s=r.length;if(s===0)return;const a=pa(ur(e)),i=r.indexOf(a),c=i===-1?n===1?0:s-1:i+n;return r[c]}function w5(e){return k5(ur(e).body,1)||e}function j5(e){return k5(ur(e).body,-1)||e}function ad(e,n){const r=n||e.currentTarget,s=e.relatedTarget;return!s||!dr(r,s)}function gA(e){Mp(e,Id()).forEach(r=>{r.dataset.tabindex=r.getAttribute("tabindex")||"",r.setAttribute("tabindex","-1")})}function Gk(e){e.querySelectorAll("[data-tabindex]").forEach(r=>{const s=r.dataset.tabindex;delete r.dataset.tabindex,s?r.setAttribute("tabindex",s):r.removeAttribute("tabindex")})}var N5=UN();function Vk(e,n,r){let{reference:s,floating:a}=e;const i=Za(n),c=o5(n),d=a5(c),u=Yo(n),m=i==="y",h=s.x+s.width/2-a.width/2,g=s.y+s.height/2-a.height/2,x=s[d]/2-a[d]/2;let y;switch(u){case"top":y={x:h,y:s.y-a.height};break;case"bottom":y={x:h,y:s.y+s.height};break;case"right":y={x:s.x+s.width,y:g};break;case"left":y={x:s.x-a.width,y:g};break;default:y={x:s.x,y:s.y}}switch(Rd(n)){case"start":y[c]-=x*(r&&m?-1:1);break;case"end":y[c]+=x*(r&&m?-1:1);break}return y}async function fA(e,n){var r;n===void 0&&(n={});const{x:s,y:a,platform:i,rects:c,elements:d,strategy:u}=e,{boundary:m="clippingAncestors",rootBoundary:h="viewport",elementContext:g="floating",altBoundary:x=!1,padding:y=0}=Cd(n,e),b=LE(y),k=d[x?g==="floating"?"reference":"floating":g],j=Lh(await i.getClippingRect({element:(r=await(i.isElement==null?void 0:i.isElement(k)))==null||r?k:k.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(d.floating)),boundary:m,rootBoundary:h,strategy:u})),N=g==="floating"?{x:s,y:a,width:c.floating.width,height:c.floating.height}:c.reference,I=await(i.getOffsetParent==null?void 0:i.getOffsetParent(d.floating)),S=await(i.isElement==null?void 0:i.isElement(I))?await(i.getScale==null?void 0:i.getScale(I))||{x:1,y:1}:{x:1,y:1},T=Lh(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:d,rect:N,offsetParent:I,strategy:u}):N);return{top:(j.top-T.top+b.top)/S.y,bottom:(T.bottom-j.bottom+b.bottom)/S.y,left:(j.left-T.left+b.left)/S.x,right:(T.right-j.right+b.right)/S.x}}const xA=50,yA=async(e,n,r)=>{const{placement:s="bottom",strategy:a="absolute",middleware:i=[],platform:c}=r,d=c.detectOverflow?c:{...c,detectOverflow:fA},u=await(c.isRTL==null?void 0:c.isRTL(n));let m=await c.getElementRects({reference:e,floating:n,strategy:a}),{x:h,y:g}=Vk(m,s,u),x=s,y=0;const b={};for(let w=0;w<i.length;w++){const k=i[w];if(!k)continue;const{name:j,fn:N}=k,{x:I,y:S,data:T,reset:$}=await N({x:h,y:g,initialPlacement:s,placement:x,strategy:a,middlewareData:b,rects:m,platform:d,elements:{reference:e,floating:n}});h=I??h,g=S??g,b[j]={...b[j],...T},$&&y<xA&&(y++,typeof $=="object"&&($.placement&&(x=$.placement),$.rects&&(m=$.rects===!0?await c.getElementRects({reference:e,floating:n,strategy:a}):$.rects),{x:h,y:g}=Vk(m,x,u)),w=-1)}return{x:h,y:g,placement:x,strategy:a,middlewareData:b}},bA=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(n){var r,s;const{placement:a,middlewareData:i,rects:c,initialPlacement:d,platform:u,elements:m}=n,{mainAxis:h=!0,crossAxis:g=!0,fallbackPlacements:x,fallbackStrategy:y="bestFit",fallbackAxisSideDirection:b="none",flipAlignment:w=!0,...k}=Cd(e,n);if((r=i.arrow)!=null&&r.alignmentOffset)return{};const j=Yo(a),N=Za(d),I=Yo(d)===d,S=await(u.isRTL==null?void 0:u.isRTL(m.floating)),T=x||(I||!w?[Mh(d)]:$E(d)),$=b!=="none";!x&&$&&T.push(...AE(d,w,b,S));const P=[d,...T],C=await u.detectOverflow(n,k),L=[];let F=((s=i.flip)==null?void 0:s.overflows)||[];if(h&&L.push(C[j]),g){const W=TE(a,c,S);L.push(C[W[0]],C[W[1]])}if(F=[...F,{placement:a,overflows:L}],!L.every(W=>W<=0)){var M,D;const W=(((M=i.flip)==null?void 0:M.index)||0)+1,z=P[W];if(z&&(!(g==="alignment"?N!==Za(z):!1)||F.every(B=>Za(B.placement)===N?B.overflows[0]>0:!0)))return{data:{index:W,overflows:F},reset:{placement:z}};let te=(D=F.filter(H=>H.overflows[0]<=0).sort((H,B)=>H.overflows[1]-B.overflows[1])[0])==null?void 0:D.placement;if(!te)switch(y){case"bestFit":{var A;const H=(A=F.filter(B=>{if($){const O=Za(B.placement);return O===N||O==="y"}return!0}).map(B=>[B.placement,B.overflows.filter(O=>O>0).reduce((O,E)=>O+E,0)]).sort((B,O)=>B[1]-O[1])[0])==null?void 0:A[0];H&&(te=H);break}case"initialPlacement":te=d;break}if(a!==te)return{reset:{placement:te}}}return{}}}},vA=new Set(["left","top"]);async function kA(e,n){const{placement:r,platform:s,elements:a}=e,i=await(s.isRTL==null?void 0:s.isRTL(a.floating)),c=Yo(r),d=Rd(r),u=Za(r)==="y",m=vA.has(c)?-1:1,h=i&&u?-1:1,g=Cd(n,e);let{mainAxis:x,crossAxis:y,alignmentAxis:b}=typeof g=="number"?{mainAxis:g,crossAxis:0,alignmentAxis:null}:{mainAxis:g.mainAxis||0,crossAxis:g.crossAxis||0,alignmentAxis:g.alignmentAxis};return d&&typeof b=="number"&&(y=d==="end"?b*-1:b),u?{x:y*h,y:x*m}:{x:x*m,y:y*h}}const wA=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(n){var r,s;const{x:a,y:i,placement:c,middlewareData:d}=n,u=await kA(n,e);return c===((r=d.offset)==null?void 0:r.placement)&&(s=d.arrow)!=null&&s.alignmentOffset?{}:{x:a+u.x,y:i+u.y,data:{...u,placement:c}}}}},jA=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(n){const{x:r,y:s,placement:a,platform:i}=n,{mainAxis:c=!0,crossAxis:d=!1,limiter:u={fn:j=>{let{x:N,y:I}=j;return{x:N,y:I}}},...m}=Cd(e,n),h={x:r,y:s},g=await i.detectOverflow(n,m),x=Za(Yo(a)),y=s5(x);let b=h[y],w=h[x];if(c){const j=y==="y"?"top":"left",N=y==="y"?"bottom":"right",I=b+g[j],S=b-g[N];b=Bk(I,b,S)}if(d){const j=x==="y"?"top":"left",N=x==="y"?"bottom":"right",I=w+g[j],S=w-g[N];w=Bk(I,w,S)}const k=u.fn({...n,[y]:b,[x]:w});return{...k,data:{x:k.x-r,y:k.y-s,enabled:{[y]:c,[x]:d}}}}}},NA=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(n){var r,s;const{placement:a,rects:i,platform:c,elements:d}=n,{apply:u=()=>{},...m}=Cd(e,n),h=await c.detectOverflow(n,m),g=Yo(a),x=Rd(a),y=Za(a)==="y",{width:b,height:w}=i.floating;let k,j;g==="top"||g==="bottom"?(k=g,j=x===(await(c.isRTL==null?void 0:c.isRTL(d.floating))?"start":"end")?"left":"right"):(j=g,k=x==="end"?"top":"bottom");const N=w-h.top-h.bottom,I=b-h.left-h.right,S=Vl(w-h[k],N),T=Vl(b-h[j],I),$=!n.middlewareData.shift;let P=S,C=T;if((r=n.middlewareData.shift)!=null&&r.enabled.x&&(C=I),(s=n.middlewareData.shift)!=null&&s.enabled.y&&(P=N),$&&!x){const F=ls(h.left,0),M=ls(h.right,0),D=ls(h.top,0),A=ls(h.bottom,0);y?C=b-2*(F!==0||M!==0?F+M:ls(h.left,h.right)):P=w-2*(D!==0||A!==0?D+A:ls(h.top,h.bottom))}await u({...n,availableWidth:C,availableHeight:P});const L=await c.getDimensions(d.floating);return b!==L.width||w!==L.height?{reset:{rects:!0}}:{}}}};function S5(e){const n=Es(e);let r=parseFloat(n.width)||0,s=parseFloat(n.height)||0;const a=tr(e),i=a?e.offsetWidth:r,c=a?e.offsetHeight:s,d=Ah(r)!==i||Ah(s)!==c;return d&&(r=i,s=c),{width:r,height:s,$:d}}function Fx(e){return on(e)?e:e.contextElement}function Ll(e){const n=Fx(e);if(!tr(n))return ga(1);const r=n.getBoundingClientRect(),{width:s,height:a,$:i}=S5(n);let c=(i?Ah(r.width):r.width)/s,d=(i?Ah(r.height):r.height)/a;return(!c||!Number.isFinite(c))&&(c=1),(!d||!Number.isFinite(d))&&(d=1),{x:c,y:d}}const SA=ga(0);function C5(e){const n=Gr(e);return!Ep()||!n.visualViewport?SA:{x:n.visualViewport.offsetLeft,y:n.visualViewport.offsetTop}}function CA(e,n,r){return n===void 0&&(n=!1),!r||n&&r!==Gr(e)?!1:n}function Ei(e,n,r,s){n===void 0&&(n=!1),r===void 0&&(r=!1);const a=e.getBoundingClientRect(),i=Fx(e);let c=ga(1);n&&(s?on(s)&&(c=Ll(s)):c=Ll(e));const d=CA(i,r,s)?C5(i):ga(0);let u=(a.left+d.x)/c.x,m=(a.top+d.y)/c.y,h=a.width/c.x,g=a.height/c.y;if(i){const x=Gr(i),y=s&&on(s)?Gr(s):s;let b=x,w=cf(b);for(;w&&s&&y!==b;){const k=Ll(w),j=w.getBoundingClientRect(),N=Es(w),I=j.left+(w.clientLeft+parseFloat(N.paddingLeft))*k.x,S=j.top+(w.clientTop+parseFloat(N.paddingTop))*k.y;u*=k.x,m*=k.y,h*=k.x,g*=k.y,u+=I,m+=S,b=Gr(w),w=cf(b)}}return Lh({width:h,height:g,x:u,y:m})}function Lp(e,n){const r=Ap(e).scrollLeft;return n?n.left+r:Ei(va(e)).left+r}function R5(e,n){const r=e.getBoundingClientRect(),s=r.left+n.scrollLeft-Lp(e,r),a=r.top+n.scrollTop;return{x:s,y:a}}function RA(e){let{elements:n,rect:r,offsetParent:s,strategy:a}=e;const i=a==="fixed",c=va(s),d=n?Pp(n.floating):!1;if(s===c||d&&i)return r;let u={scrollLeft:0,scrollTop:0},m=ga(1);const h=ga(0),g=tr(s);if((g||!g&&!i)&&((ti(s)!=="body"||Sd(c))&&(u=Ap(s)),g)){const y=Ei(s);m=Ll(s),h.x=y.x+s.clientLeft,h.y=y.y+s.clientTop}const x=c&&!g&&!i?R5(c,u):ga(0);return{width:r.width*m.x,height:r.height*m.y,x:r.x*m.x-u.scrollLeft*m.x+h.x+x.x,y:r.y*m.y-u.scrollTop*m.y+h.y+x.y}}function IA(e){return Array.from(e.getClientRects())}function TA(e){const n=va(e),r=Ap(e),s=e.ownerDocument.body,a=ls(n.scrollWidth,n.clientWidth,s.scrollWidth,s.clientWidth),i=ls(n.scrollHeight,n.clientHeight,s.scrollHeight,s.clientHeight);let c=-r.scrollLeft+Lp(e);const d=-r.scrollTop;return Es(s).direction==="rtl"&&(c+=ls(n.clientWidth,s.clientWidth)-a),{width:a,height:i,x:c,y:d}}const Qk=25;function $A(e,n){const r=Gr(e),s=va(e),a=r.visualViewport;let i=s.clientWidth,c=s.clientHeight,d=0,u=0;if(a){i=a.width,c=a.height;const h=Ep();(!h||h&&n==="fixed")&&(d=a.offsetLeft,u=a.offsetTop)}const m=Lp(s);if(m<=0){const h=s.ownerDocument,g=h.body,x=getComputedStyle(g),y=h.compatMode==="CSS1Compat"&&parseFloat(x.marginLeft)+parseFloat(x.marginRight)||0,b=Math.abs(s.clientWidth-g.clientWidth-y);b<=Qk&&(i-=b)}else m<=Qk&&(i+=m);return{width:i,height:c,x:d,y:u}}function _A(e,n){const r=Ei(e,!0,n==="fixed"),s=r.top+e.clientTop,a=r.left+e.clientLeft,i=tr(e)?Ll(e):ga(1),c=e.clientWidth*i.x,d=e.clientHeight*i.y,u=a*i.x,m=s*i.y;return{width:c,height:d,x:u,y:m}}function Yk(e,n,r){let s;if(n==="viewport")s=$A(e,r);else if(n==="document")s=TA(va(e));else if(on(n))s=_A(n,r);else{const a=C5(e);s={x:n.x-a.x,y:n.y-a.y,width:n.width,height:n.height}}return Lh(s)}function I5(e,n){const r=no(e);return r===n||!on(r)||to(r)?!1:Es(r).position==="fixed"||I5(r,n)}function PA(e,n){const r=n.get(e);if(r)return r;let s=Ho(e,[],!1).filter(d=>on(d)&&ti(d)!=="body"),a=null;const i=Es(e).position==="fixed";let c=i?no(e):e;for(;on(c)&&!to(c);){const d=Es(c),u=Lx(c);!u&&d.position==="fixed"&&(a=null),(i?!u&&!a:!u&&d.position==="static"&&!!a&&(a.position==="absolute"||a.position==="fixed")||Sd(c)&&!u&&I5(e,c))?s=s.filter(h=>h!==c):a=d,c=no(c)}return n.set(e,s),s}function EA(e){let{element:n,boundary:r,rootBoundary:s,strategy:a}=e;const c=[...r==="clippingAncestors"?Pp(n)?[]:PA(n,this._c):[].concat(r),s],d=Yk(n,c[0],a);let u=d.top,m=d.right,h=d.bottom,g=d.left;for(let x=1;x<c.length;x++){const y=Yk(n,c[x],a);u=ls(y.top,u),m=Vl(y.right,m),h=Vl(y.bottom,h),g=ls(y.left,g)}return{width:m-g,height:h-u,x:g,y:u}}function AA(e){const{width:n,height:r}=S5(e);return{width:n,height:r}}function MA(e,n,r){const s=tr(n),a=va(n),i=r==="fixed",c=Ei(e,!0,i,n);let d={scrollLeft:0,scrollTop:0};const u=ga(0);function m(){u.x=Lp(a)}if(s||!s&&!i)if((ti(n)!=="body"||Sd(a))&&(d=Ap(n)),s){const y=Ei(n,!0,i,n);u.x=y.x+n.clientLeft,u.y=y.y+n.clientTop}else a&&m();i&&!s&&a&&m();const h=a&&!s&&!i?R5(a,d):ga(0),g=c.left+d.scrollLeft-u.x-h.x,x=c.top+d.scrollTop-u.y-h.y;return{x:g,y:x,width:c.width,height:c.height}}function Ug(e){return Es(e).position==="static"}function Xk(e,n){if(!tr(e)||Es(e).position==="fixed")return null;if(n)return n(e);let r=e.offsetParent;return va(e)===r&&(r=r.ownerDocument.body),r}function T5(e,n){const r=Gr(e);if(Pp(e))return r;if(!tr(e)){let a=no(e);for(;a&&!to(a);){if(on(a)&&!Ug(a))return a;a=no(a)}return r}let s=Xk(e,n);for(;s&&NE(s)&&Ug(s);)s=Xk(s,n);return s&&to(s)&&Ug(s)&&!Lx(s)?r:s||RE(e)||r}const LA=async function(e){const n=this.getOffsetParent||T5,r=this.getDimensions,s=await r(e.floating);return{reference:MA(e.reference,await n(e.floating),e.strategy),floating:{x:0,y:0,width:s.width,height:s.height}}};function FA(e){return Es(e).direction==="rtl"}const OA={convertOffsetParentRelativeRectToViewportRelativeRect:RA,getDocumentElement:va,getClippingRect:EA,getOffsetParent:T5,getElementRects:LA,getClientRects:IA,getDimensions:AA,getScale:Ll,isElement:on,isRTL:FA};function $5(e,n){return e.x===n.x&&e.y===n.y&&e.width===n.width&&e.height===n.height}function DA(e,n){let r=null,s;const a=va(e);function i(){var d;clearTimeout(s),(d=r)==null||d.disconnect(),r=null}function c(d,u){d===void 0&&(d=!1),u===void 0&&(u=1),i();const m=e.getBoundingClientRect(),{left:h,top:g,width:x,height:y}=m;if(d||n(),!x||!y)return;const b=$l(g),w=$l(a.clientWidth-(h+x)),k=$l(a.clientHeight-(g+y)),j=$l(h),I={rootMargin:-b+"px "+-w+"px "+-k+"px "+-j+"px",threshold:ls(0,Vl(1,u))||1};let S=!0;function T($){const P=$[0].intersectionRatio;if(P!==u){if(!S)return c();P?c(!1,P):s=setTimeout(()=>{c(!1,1e-7)},1e3)}P===1&&!$5(m,e.getBoundingClientRect())&&c(),S=!1}try{r=new IntersectionObserver(T,{...I,root:a.ownerDocument})}catch{r=new IntersectionObserver(T,I)}r.observe(e)}return c(!0),i}function ni(e,n,r,s){s===void 0&&(s={});const{ancestorScroll:a=!0,ancestorResize:i=!0,elementResize:c=typeof ResizeObserver=="function",layoutShift:d=typeof IntersectionObserver=="function",animationFrame:u=!1}=s,m=Fx(e),h=a||i?[...m?Ho(m):[],...n?Ho(n):[]]:[];h.forEach(j=>{a&&j.addEventListener("scroll",r,{passive:!0}),i&&j.addEventListener("resize",r)});const g=m&&d?DA(m,r):null;let x=-1,y=null;c&&(y=new ResizeObserver(j=>{let[N]=j;N&&N.target===m&&y&&n&&(y.unobserve(n),cancelAnimationFrame(x),x=requestAnimationFrame(()=>{var I;(I=y)==null||I.observe(n)})),r()}),m&&!u&&y.observe(m),n&&y.observe(n));let b,w=u?Ei(e):null;u&&k();function k(){const j=Ei(e);w&&!$5(w,j)&&r(),w=j,b=requestAnimationFrame(k)}return r(),()=>{var j;h.forEach(N=>{a&&N.removeEventListener("scroll",r),i&&N.removeEventListener("resize",r)}),g==null||g(),(j=y)==null||j.disconnect(),y=null,u&&cancelAnimationFrame(b)}}const BA=wA,WA=jA,qA=bA,UA=NA,HA=(e,n,r)=>{const s=new Map,a={platform:OA,...r},i={...a.platform,_c:s};return yA(e,n,{...a,platform:i})};var zA=typeof document<"u",KA=function(){},ah=zA?f.useLayoutEffect:KA;function qh(e,n){if(e===n)return!0;if(typeof e!=typeof n)return!1;if(typeof e=="function"&&e.toString()===n.toString())return!0;let r,s,a;if(e&&n&&typeof e=="object"){if(Array.isArray(e)){if(r=e.length,r!==n.length)return!1;for(s=r;s--!==0;)if(!qh(e[s],n[s]))return!1;return!0}if(a=Object.keys(e),r=a.length,r!==Object.keys(n).length)return!1;for(s=r;s--!==0;)if(!{}.hasOwnProperty.call(n,a[s]))return!1;for(s=r;s--!==0;){const i=a[s];if(!(i==="_owner"&&e.$$typeof)&&!qh(e[i],n[i]))return!1}return!0}return e!==e&&n!==n}function _5(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Zk(e,n){const r=_5(e);return Math.round(n*r)/r}function Hg(e){const n=f.useRef(e);return ah(()=>{n.current=e}),n}function GA(e){e===void 0&&(e={});const{placement:n="bottom",strategy:r="absolute",middleware:s=[],platform:a,elements:{reference:i,floating:c}={},transform:d=!0,whileElementsMounted:u,open:m}=e,[h,g]=f.useState({x:0,y:0,strategy:r,placement:n,middlewareData:{},isPositioned:!1}),[x,y]=f.useState(s);qh(x,s)||y(s);const[b,w]=f.useState(null),[k,j]=f.useState(null),N=f.useCallback(B=>{B!==$.current&&($.current=B,w(B))},[]),I=f.useCallback(B=>{B!==P.current&&(P.current=B,j(B))},[]),S=i||b,T=c||k,$=f.useRef(null),P=f.useRef(null),C=f.useRef(h),L=u!=null,F=Hg(u),M=Hg(a),D=Hg(m),A=f.useCallback(()=>{if(!$.current||!P.current)return;const B={placement:n,strategy:r,middleware:x};M.current&&(B.platform=M.current),HA($.current,P.current,B).then(O=>{const E={...O,isPositioned:D.current!==!1};W.current&&!qh(C.current,E)&&(C.current=E,N5.flushSync(()=>{g(E)}))})},[x,n,r,M,D]);ah(()=>{m===!1&&C.current.isPositioned&&(C.current.isPositioned=!1,g(B=>({...B,isPositioned:!1})))},[m]);const W=f.useRef(!1);ah(()=>(W.current=!0,()=>{W.current=!1}),[]),ah(()=>{if(S&&($.current=S),T&&(P.current=T),S&&T){if(F.current)return F.current(S,T,A);A()}},[S,T,A,F,L]);const z=f.useMemo(()=>({reference:$,floating:P,setReference:N,setFloating:I}),[N,I]),te=f.useMemo(()=>({reference:S,floating:T}),[S,T]),H=f.useMemo(()=>{const B={position:r,left:0,top:0};if(!te.floating)return B;const O=Zk(te.floating,h.x),E=Zk(te.floating,h.y);return d?{...B,transform:"translate("+O+"px, "+E+"px)",..._5(te.floating)>=1.5&&{willChange:"transform"}}:{position:r,left:O,top:E}},[r,d,te.floating,h.x,h.y]);return f.useMemo(()=>({...h,update:A,refs:z,elements:te,floatingStyles:H}),[h,A,z,te,H])}const oo=(e,n)=>{const r=BA(e);return{name:r.name,fn:r.fn,options:[e,n]}},ri=(e,n)=>{const r=WA(e);return{name:r.name,fn:r.fn,options:[e,n]}},io=(e,n)=>{const r=qA(e);return{name:r.name,fn:r.fn,options:[e,n]}},VA=(e,n)=>{const r=UA(e);return{name:r.name,fn:r.fn,options:[e,n]}};function QA(e){const n=f.useRef(void 0),r=f.useCallback(s=>{const a=e.map(i=>{if(i!=null){if(typeof i=="function"){const c=i,d=c(s);return typeof d=="function"?d:()=>{c(null)}}return i.current=s,()=>{i.current=null}}});return()=>{a.forEach(i=>i==null?void 0:i())}},e);return f.useMemo(()=>e.every(s=>s==null)?null:s=>{n.current&&(n.current(),n.current=void 0),s!=null&&(n.current=r(s))},e)}const YA="data-floating-ui-focusable",Jk="active",ew="selected",Td="ArrowLeft",$d="ArrowRight",P5="ArrowUp",Fp="ArrowDown",XA={...qN};let tw=!1,ZA=0;const nw=()=>"floating-ui-"+Math.random().toString(36).slice(2,6)+ZA++;function JA(){const[e,n]=f.useState(()=>tw?nw():void 0);return En(()=>{e==null&&n(nw())},[]),f.useEffect(()=>{tw=!0},[]),e}const eM=XA.useId,Ox=eM||JA;function tM(){const e=new Map;return{emit(n,r){var s;(s=e.get(n))==null||s.forEach(a=>a(r))},on(n,r){e.has(n)||e.set(n,new Set),e.get(n).add(r)},off(n,r){var s;(s=e.get(n))==null||s.delete(r)}}}const nM=f.createContext(null),rM=f.createContext(null),Op=()=>{var e;return((e=f.useContext(nM))==null?void 0:e.id)||null},_d=()=>f.useContext(rM);function Ai(e){return"data-floating-ui-"+e}function as(e){e.current!==-1&&(clearTimeout(e.current),e.current=-1)}const rw=Ai("safe-polygon");function zg(e,n,r){if(r&&!gf(r))return 0;if(typeof e=="number")return e;if(typeof e=="function"){const s=e();return typeof s=="number"?s:s==null?void 0:s[n]}return e==null?void 0:e[n]}function Kg(e){return typeof e=="function"?e():e}function sM(e,n){n===void 0&&(n={});const{open:r,onOpenChange:s,dataRef:a,events:i,elements:c}=e,{enabled:d=!0,delay:u=0,handleClose:m=null,mouseOnly:h=!1,restMs:g=0,move:x=!0}=n,y=_d(),b=Op(),w=Rs(m),k=Rs(u),j=Rs(r),N=Rs(g),I=f.useRef(),S=f.useRef(-1),T=f.useRef(),$=f.useRef(-1),P=f.useRef(!0),C=f.useRef(!1),L=f.useRef(()=>{}),F=f.useRef(!1),M=hr(()=>{var H;const B=(H=a.current.openEvent)==null?void 0:H.type;return(B==null?void 0:B.includes("mouse"))&&B!=="mousedown"});f.useEffect(()=>{if(!d)return;function H(B){let{open:O}=B;O||(as(S),as($),P.current=!0,F.current=!1)}return i.on("openchange",H),()=>{i.off("openchange",H)}},[d,i]),f.useEffect(()=>{if(!d||!w.current||!r)return;function H(O){M()&&s(!1,O,"hover")}const B=ur(c.floating).documentElement;return B.addEventListener("mouseleave",H),()=>{B.removeEventListener("mouseleave",H)}},[c.floating,r,s,d,w,M]);const D=f.useCallback(function(H,B,O){B===void 0&&(B=!0),O===void 0&&(O="hover");const E=zg(k.current,"close",I.current);E&&!T.current?(as(S),S.current=window.setTimeout(()=>s(!1,H,O),E)):B&&(as(S),s(!1,H,O))},[k,s]),A=hr(()=>{L.current(),T.current=void 0}),W=hr(()=>{if(C.current){const H=ur(c.floating).body;H.style.pointerEvents="",H.removeAttribute(rw),C.current=!1}}),z=hr(()=>a.current.openEvent?["click","mousedown"].includes(a.current.openEvent.type):!1);f.useEffect(()=>{if(!d)return;function H(K){if(as(S),P.current=!1,h&&!gf(I.current)||Kg(N.current)>0&&!zg(k.current,"open"))return;const U=zg(k.current,"open",I.current);U?S.current=window.setTimeout(()=>{j.current||s(!0,K,"hover")},U):r||s(!0,K,"hover")}function B(K){if(z()){W();return}L.current();const U=ur(c.floating);if(as($),F.current=!1,w.current&&a.current.floatingContext){r||as(S),T.current=w.current({...a.current.floatingContext,tree:y,x:K.clientX,y:K.clientY,onClose(){W(),A(),z()||D(K,!0,"safe-polygon")}});const J=T.current;U.addEventListener("mousemove",J),L.current=()=>{U.removeEventListener("mousemove",J)};return}(I.current==="touch"?!dr(c.floating,K.relatedTarget):!0)&&D(K)}function O(K){z()||a.current.floatingContext&&(w.current==null||w.current({...a.current.floatingContext,tree:y,x:K.clientX,y:K.clientY,onClose(){W(),A(),z()||D(K)}})(K))}function E(){as(S)}function ee(K){z()||D(K,!1)}if(on(c.domReference)){const K=c.domReference,U=c.floating;return r&&K.addEventListener("mouseleave",O),x&&K.addEventListener("mousemove",H,{once:!0}),K.addEventListener("mouseenter",H),K.addEventListener("mouseleave",B),U&&(U.addEventListener("mouseleave",O),U.addEventListener("mouseenter",E),U.addEventListener("mouseleave",ee)),()=>{r&&K.removeEventListener("mouseleave",O),x&&K.removeEventListener("mousemove",H),K.removeEventListener("mouseenter",H),K.removeEventListener("mouseleave",B),U&&(U.removeEventListener("mouseleave",O),U.removeEventListener("mouseenter",E),U.removeEventListener("mouseleave",ee))}}},[c,d,e,h,x,D,A,W,s,r,j,y,k,w,a,z,N]),En(()=>{var H;if(d&&r&&(H=w.current)!=null&&(H=H.__options)!=null&&H.blockPointerEvents&&M()){C.current=!0;const O=c.floating;if(on(c.domReference)&&O){var B;const E=ur(c.floating).body;E.setAttribute(rw,"");const ee=c.domReference,K=y==null||(B=y.nodesRef.current.find(U=>U.id===b))==null||(B=B.context)==null?void 0:B.elements.floating;return K&&(K.style.pointerEvents=""),E.style.pointerEvents="none",ee.style.pointerEvents="auto",O.style.pointerEvents="auto",()=>{E.style.pointerEvents="",ee.style.pointerEvents="",O.style.pointerEvents=""}}}},[d,r,b,c,y,w,M]),En(()=>{r||(I.current=void 0,F.current=!1,A(),W())},[r,A,W]),f.useEffect(()=>()=>{A(),as(S),as($),W()},[d,c.domReference,A,W]);const te=f.useMemo(()=>{function H(B){I.current=B.pointerType}return{onPointerDown:H,onPointerEnter:H,onMouseMove(B){const{nativeEvent:O}=B;function E(){!P.current&&!j.current&&s(!0,O,"hover")}h&&!gf(I.current)||r||Kg(N.current)===0||F.current&&B.movementX**2+B.movementY**2<2||(as($),I.current==="touch"?E():(F.current=!0,$.current=window.setTimeout(E,Kg(N.current))))}}},[h,s,r,j,N]);return f.useMemo(()=>d?{reference:te}:{},[d,te])}let sw=0;function Ri(e,n){n===void 0&&(n={});const{preventScroll:r=!1,cancelPrevious:s=!0,sync:a=!1}=n;s&&cancelAnimationFrame(sw);const i=()=>e==null?void 0:e.focus({preventScroll:r});a?i():sw=requestAnimationFrame(i)}function aM(e){return(e==null?void 0:e.ownerDocument)||document}const Fl={inert:new WeakMap,"aria-hidden":new WeakMap,none:new WeakMap};function aw(e){return e==="inert"?Fl.inert:e==="aria-hidden"?Fl["aria-hidden"]:Fl.none}let Mu=new WeakSet,Lu={},Gg=0;const oM=()=>typeof HTMLElement<"u"&&"inert"in HTMLElement.prototype;function E5(e){return e?Eh(e)?e.host:E5(e.parentNode):null}const iM=(e,n)=>n.map(r=>{if(e.contains(r))return r;const s=E5(r);return e.contains(s)?s:null}).filter(r=>r!=null);function lM(e,n,r,s){const a="data-floating-ui-inert",i=s?"inert":r?"aria-hidden":null,c=iM(n,e),d=new Set,u=new Set(c),m=[];Lu[a]||(Lu[a]=new WeakMap);const h=Lu[a];c.forEach(g),x(n),d.clear();function g(y){!y||d.has(y)||(d.add(y),y.parentNode&&g(y.parentNode))}function x(y){!y||u.has(y)||[].forEach.call(y.children,b=>{if(ti(b)!=="script")if(d.has(b))x(b);else{const w=i?b.getAttribute(i):null,k=w!==null&&w!=="false",j=aw(i),N=(j.get(b)||0)+1,I=(h.get(b)||0)+1;j.set(b,N),h.set(b,I),m.push(b),N===1&&k&&Mu.add(b),I===1&&b.setAttribute(a,""),!k&&i&&b.setAttribute(i,i==="inert"?"":"true")}})}return Gg++,()=>{m.forEach(y=>{const b=aw(i),k=(b.get(y)||0)-1,j=(h.get(y)||0)-1;b.set(y,k),h.set(y,j),k||(!Mu.has(y)&&i&&y.removeAttribute(i),Mu.delete(y)),j||y.removeAttribute(a)}),Gg--,Gg||(Fl.inert=new WeakMap,Fl["aria-hidden"]=new WeakMap,Fl.none=new WeakMap,Mu=new WeakSet,Lu={})}}function ow(e,n,r){n===void 0&&(n=!1),r===void 0&&(r=!1);const s=aM(e[0]).body;return lM(e.concat(Array.from(s.querySelectorAll('[aria-live],[role="status"],output'))),s,n,r)}const Dx={border:0,clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:0,position:"fixed",whiteSpace:"nowrap",width:"1px",top:0,left:0},Uh=f.forwardRef(function(n,r){const[s,a]=f.useState();En(()=>{f5()&&a("button")},[]);const i={ref:r,tabIndex:0,role:s,"aria-hidden":s?void 0:!0,[Ai("focus-guard")]:"",style:Dx};return t.jsx("span",{...n,...i})}),cM={clipPath:"inset(50%)",position:"fixed",top:0,left:0},A5=f.createContext(null),iw=Ai("portal");function dM(e){e===void 0&&(e={});const{id:n,root:r}=e,s=Ox(),a=M5(),[i,c]=f.useState(null),d=f.useRef(null);return En(()=>()=>{i==null||i.remove(),queueMicrotask(()=>{d.current=null})},[i]),En(()=>{if(!s||d.current)return;const u=n?document.getElementById(n):null;if(!u)return;const m=document.createElement("div");m.id=s,m.setAttribute(iw,""),u.appendChild(m),d.current=m,c(m)},[n,s]),En(()=>{if(r===null||!s||d.current)return;let u=r||(a==null?void 0:a.portalNode);u&&!Mx(u)&&(u=u.current),u=u||document.body;let m=null;n&&(m=document.createElement("div"),m.id=n,u.appendChild(m));const h=document.createElement("div");h.id=s,h.setAttribute(iw,""),u=m||u,u.appendChild(h),d.current=h,c(h)},[n,r,s,a]),i}function ka(e){const{children:n,id:r,root:s,preserveTabOrder:a=!0}=e,i=dM({id:r,root:s}),[c,d]=f.useState(null),u=f.useRef(null),m=f.useRef(null),h=f.useRef(null),g=f.useRef(null),x=c==null?void 0:c.modal,y=c==null?void 0:c.open,b=!!c&&!c.modal&&c.open&&a&&!!(s||i);return f.useEffect(()=>{if(!i||!a||x)return;function w(k){i&&ad(k)&&(k.type==="focusin"?Gk:gA)(i)}return i.addEventListener("focusin",w,!0),i.addEventListener("focusout",w,!0),()=>{i.removeEventListener("focusin",w,!0),i.removeEventListener("focusout",w,!0)}},[i,a,x]),f.useEffect(()=>{i&&(y||Gk(i))},[y,i]),t.jsxs(A5.Provider,{value:f.useMemo(()=>({preserveTabOrder:a,beforeOutsideRef:u,afterOutsideRef:m,beforeInsideRef:h,afterInsideRef:g,portalNode:i,setFocusManagerState:d}),[a,i]),children:[b&&i&&t.jsx(Uh,{"data-type":"outside",ref:u,onFocus:w=>{if(ad(w,i)){var k;(k=h.current)==null||k.focus()}else{const j=c?c.domReference:null,N=j5(j);N==null||N.focus()}}}),b&&i&&t.jsx("span",{"aria-owns":i.id,style:cM}),i&&N5.createPortal(n,i),b&&i&&t.jsx(Uh,{"data-type":"outside",ref:m,onFocus:w=>{if(ad(w,i)){var k;(k=g.current)==null||k.focus()}else{const j=c?c.domReference:null,N=w5(j);N==null||N.focus(),c!=null&&c.closeOnFocusOut&&(c==null||c.onOpenChange(!1,w.nativeEvent,"focus-out"))}}})]})}const M5=()=>f.useContext(A5);function lw(e){return f.useMemo(()=>n=>{e.forEach(r=>{r&&(r.current=n)})},e)}const cw=20;let Do=[];function Bx(){Do=Do.filter(e=>{var n;return(n=e.deref())==null?void 0:n.isConnected})}function uM(e){Bx(),e&&ti(e)!=="body"&&(Do.push(new WeakRef(e)),Do.length>cw&&(Do=Do.slice(-cw)))}function dw(){Bx();const e=Do[Do.length-1];return e==null?void 0:e.deref()}function hM(e){const n=Id();return p5(e,n)?e:Mp(e,n)[0]||e}function uw(e,n){var r;if(!n.current.includes("floating")&&!((r=e.getAttribute("role"))!=null&&r.includes("dialog")))return;const s=Id(),i=XE(e,s).filter(d=>{const u=d.getAttribute("data-tabindex")||"";return p5(d,s)||d.hasAttribute("data-tabindex")&&!u.startsWith("-")}),c=e.getAttribute("tabindex");n.current.includes("floating")||i.length===0?c!=="0"&&e.setAttribute("tabindex","0"):(c!=="-1"||e.hasAttribute("data-tabindex")&&e.getAttribute("data-tabindex")!=="-1")&&(e.setAttribute("tabindex","-1"),e.setAttribute("data-tabindex","-1"))}const pM=f.forwardRef(function(n,r){return t.jsx("button",{...n,type:"button",ref:r,tabIndex:-1,style:Dx})});function mM(e){const{context:n,children:r,disabled:s=!1,order:a=["content"],guards:i=!0,initialFocus:c=0,returnFocus:d=!0,restoreFocus:u=!1,modal:m=!0,visuallyHiddenDismiss:h=!1,closeOnFocusOut:g=!0,outsideElementsInert:x=!1,getInsideElements:y=()=>[]}=e,{open:b,onOpenChange:w,events:k,dataRef:j,elements:{domReference:N,floating:I}}=n,S=hr(()=>{var re;return(re=j.current.floatingContext)==null?void 0:re.nodeId}),T=hr(y),$=typeof c=="number"&&c<0,P=mf(N)&&$,C=oM(),L=C?i:!0,F=!L||C&&x,M=Rs(a),D=Rs(c),A=Rs(d),W=_d(),z=M5(),te=f.useRef(null),H=f.useRef(null),B=f.useRef(!1),O=f.useRef(!1),E=f.useRef(-1),ee=f.useRef(-1),K=z!=null,U=Wh(I),Q=hr(function(re){return re===void 0&&(re=U),re?Mp(re,Id()):[]}),J=hr(re=>{const X=Q(re);return M.current.map(le=>N&&le==="reference"?N:U&&le==="floating"?U:X).filter(Boolean).flat()});f.useEffect(()=>{if(s||!m)return;function re(le){if(le.key==="Tab"){dr(U,pa(ur(U)))&&Q().length===0&&!P&&Mr(le);const Ne=J(),Ve=Qa(le);M.current[0]==="reference"&&Ve===N&&(Mr(le),le.shiftKey?Ri(Ne[Ne.length-1]):Ri(Ne[1])),M.current[1]==="floating"&&Ve===U&&le.shiftKey&&(Mr(le),Ri(Ne[0]))}}const X=ur(U);return X.addEventListener("keydown",re),()=>{X.removeEventListener("keydown",re)}},[s,N,U,m,M,P,Q,J]),f.useEffect(()=>{if(s||!I)return;function re(X){const le=Qa(X),Ve=Q().indexOf(le);Ve!==-1&&(E.current=Ve)}return I.addEventListener("focusin",re),()=>{I.removeEventListener("focusin",re)}},[s,I,Q]),f.useEffect(()=>{if(s||!g)return;function re(){O.current=!0,setTimeout(()=>{O.current=!1})}function X(Ve){const me=Ve.relatedTarget,be=Ve.currentTarget,at=Qa(Ve);queueMicrotask(()=>{const ft=S(),mt=!(dr(N,me)||dr(I,me)||dr(me,I)||dr(z==null?void 0:z.portalNode,me)||me!=null&&me.hasAttribute(Ai("focus-guard"))||W&&(_i(W.nodesRef.current,ft).find(se=>{var Ce,_e;return dr((Ce=se.context)==null?void 0:Ce.elements.floating,me)||dr((_e=se.context)==null?void 0:_e.elements.domReference,me)})||zk(W.nodesRef.current,ft).find(se=>{var Ce,_e,pe;return[(Ce=se.context)==null?void 0:Ce.elements.floating,Wh((_e=se.context)==null?void 0:_e.elements.floating)].includes(me)||((pe=se.context)==null?void 0:pe.elements.domReference)===me})));if(be===N&&U&&uw(U,M),u&&be!==N&&!(at!=null&&at.isConnected)&&pa(ur(U))===ur(U).body){tr(U)&&U.focus();const se=E.current,Ce=Q(),_e=Ce[se]||Ce[Ce.length-1]||U;tr(_e)&&_e.focus()}if(j.current.insideReactTree){j.current.insideReactTree=!1;return}(P||!m)&&me&&mt&&!O.current&&me!==dw()&&(B.current=!0,w(!1,Ve,"focus-out"))})}const le=!!(!W&&z);function Ne(){as(ee),j.current.insideReactTree=!0,ee.current=window.setTimeout(()=>{j.current.insideReactTree=!1})}if(I&&tr(N))return N.addEventListener("focusout",X),N.addEventListener("pointerdown",re),I.addEventListener("focusout",X),le&&I.addEventListener("focusout",Ne,!0),()=>{N.removeEventListener("focusout",X),N.removeEventListener("pointerdown",re),I.removeEventListener("focusout",X),le&&I.removeEventListener("focusout",Ne,!0)}},[s,N,I,U,m,W,z,w,g,u,Q,P,S,M,j]);const ne=f.useRef(null),ae=f.useRef(null),we=lw([ne,z==null?void 0:z.beforeInsideRef]),$e=lw([ae,z==null?void 0:z.afterInsideRef]);f.useEffect(()=>{var re,X;if(s||!I)return;const le=Array.from((z==null||(re=z.portalNode)==null?void 0:re.querySelectorAll("["+Ai("portal")+"]"))||[]),Ve=(X=(W?zk(W.nodesRef.current,S()):[]).find(at=>{var ft;return mf(((ft=at.context)==null?void 0:ft.elements.domReference)||null)}))==null||(X=X.context)==null?void 0:X.elements.domReference,me=[I,Ve,...le,...T(),te.current,H.current,ne.current,ae.current,z==null?void 0:z.beforeOutsideRef.current,z==null?void 0:z.afterOutsideRef.current,M.current.includes("reference")||P?N:null].filter(at=>at!=null),be=m||P?ow(me,!F,F):ow(me);return()=>{be()}},[s,N,I,m,M,z,P,L,F,W,S,T]),En(()=>{if(s||!tr(U))return;const re=ur(U),X=pa(re);queueMicrotask(()=>{const le=J(U),Ne=D.current,Ve=(typeof Ne=="number"?le[Ne]:Ne.current)||U,me=dr(U,X);!$&&!me&&b&&Ri(Ve,{preventScroll:Ve===U})})},[s,b,U,$,J,D]),En(()=>{if(s||!U)return;const re=ur(U),X=pa(re);uM(X);function le(me){let{reason:be,event:at,nested:ft}=me;if(["hover","safe-polygon"].includes(be)&&at.type==="mouseleave"&&(B.current=!0),be==="outside-press")if(ft)B.current=!1;else if(b5(at)||v5(at))B.current=!1;else{let mt=!1;document.createElement("div").focus({get preventScroll(){return mt=!0,!1}}),mt?B.current=!1:B.current=!0}}k.on("openchange",le);const Ne=re.createElement("span");Ne.setAttribute("tabindex","-1"),Ne.setAttribute("aria-hidden","true"),Object.assign(Ne.style,Dx),K&&N&&N.insertAdjacentElement("afterend",Ne);function Ve(){if(typeof A.current=="boolean"){const me=N||dw();return me&&me.isConnected?me:Ne}return A.current.current||Ne}return()=>{k.off("openchange",le);const me=pa(re),be=dr(I,me)||W&&_i(W.nodesRef.current,S(),!1).some(ft=>{var mt;return dr((mt=ft.context)==null?void 0:mt.elements.floating,me)}),at=Ve();queueMicrotask(()=>{const ft=hM(at);A.current&&!B.current&&tr(ft)&&(!(ft!==me&&me!==re.body)||be)&&ft.focus({preventScroll:!0}),Ne.remove()})}},[s,I,U,A,j,k,W,K,N,S]),f.useEffect(()=>(queueMicrotask(()=>{B.current=!1}),()=>{queueMicrotask(Bx)}),[s]),En(()=>{if(!s&&z)return z.setFocusManagerState({modal:m,closeOnFocusOut:g,open:b,onOpenChange:w,domReference:N}),()=>{z.setFocusManagerState(null)}},[s,z,m,b,w,g,N]),En(()=>{s||U&&uw(U,M)},[s,U,M]);function Fe(re){return s||!h||!m?null:t.jsx(pM,{ref:re==="start"?te:H,onClick:X=>w(!1,X.nativeEvent),children:typeof h=="string"?h:"Dismiss"})}const oe=!s&&L&&(m?!P:!0)&&(K||m);return t.jsxs(t.Fragment,{children:[oe&&t.jsx(Uh,{"data-type":"inside",ref:we,onFocus:re=>{if(m){const le=J();Ri(a[0]==="reference"?le[0]:le[le.length-1])}else if(z!=null&&z.preserveTabOrder&&z.portalNode)if(B.current=!1,ad(re,z.portalNode)){const le=w5(N);le==null||le.focus()}else{var X;(X=z.beforeOutsideRef.current)==null||X.focus()}}}),!P&&Fe("start"),r,Fe("end"),oe&&t.jsx(Uh,{"data-type":"inside",ref:$e,onFocus:re=>{if(m)Ri(J()[0]);else if(z!=null&&z.preserveTabOrder&&z.portalNode)if(g&&(B.current=!0),ad(re,z.portalNode)){const le=j5(N);le==null||le.focus()}else{var X;(X=z.afterOutsideRef.current)==null||X.focus()}}})]})}const gM={pointerdown:"onPointerDown",mousedown:"onMouseDown",click:"onClick"},fM={pointerdown:"onPointerDownCapture",mousedown:"onMouseDownCapture",click:"onClickCapture"},hw=e=>{var n,r;return{escapeKey:typeof e=="boolean"?e:(n=e==null?void 0:e.escapeKey)!=null?n:!1,outsidePress:typeof e=="boolean"?e:(r=e==null?void 0:e.outsidePress)!=null?r:!0}};function si(e,n){n===void 0&&(n={});const{open:r,onOpenChange:s,elements:a,dataRef:i}=e,{enabled:c=!0,escapeKey:d=!0,outsidePress:u=!0,outsidePressEvent:m="pointerdown",referencePress:h=!1,referencePressEvent:g="pointerdown",ancestorScroll:x=!1,bubbles:y,capture:b}=n,w=_d(),k=hr(typeof u=="function"?u:()=>!1),j=typeof u=="function"?k:u,N=f.useRef(!1),{escapeKey:I,outsidePress:S}=hw(y),{escapeKey:T,outsidePress:$}=hw(b),P=f.useRef(!1),C=hr(W=>{var z;if(!r||!c||!d||W.key!=="Escape"||P.current)return;const te=(z=i.current.floatingContext)==null?void 0:z.nodeId,H=w?_i(w.nodesRef.current,te):[];if(!I&&(W.stopPropagation(),H.length>0)){let B=!0;if(H.forEach(O=>{var E;if((E=O.context)!=null&&E.open&&!O.context.dataRef.current.__escapeKeyBubbles){B=!1;return}}),!B)return}s(!1,aA(W)?W.nativeEvent:W,"escape-key")}),L=hr(W=>{var z;const te=()=>{var H;C(W),(H=Qa(W))==null||H.removeEventListener("keydown",te)};(z=Qa(W))==null||z.addEventListener("keydown",te)}),F=hr(W=>{var z;const te=i.current.insideReactTree;i.current.insideReactTree=!1;const H=N.current;if(N.current=!1,m==="click"&&H||te||typeof j=="function"&&!j(W))return;const B=Qa(W),O="["+Ai("inert")+"]",E=ur(a.floating).querySelectorAll(O);let ee=on(B)?B:null;for(;ee&&!to(ee);){const J=no(ee);if(to(J)||!on(J))break;ee=J}if(E.length&&on(B)&&!nA(B)&&!dr(B,a.floating)&&Array.from(E).every(J=>!dr(ee,J)))return;if(tr(B)&&A){const J=to(B),ne=Es(B),ae=/auto|scroll/,we=J||ae.test(ne.overflowX),$e=J||ae.test(ne.overflowY),Fe=we&&B.clientWidth>0&&B.scrollWidth>B.clientWidth,oe=$e&&B.clientHeight>0&&B.scrollHeight>B.clientHeight,re=ne.direction==="rtl",X=oe&&(re?W.offsetX<=B.offsetWidth-B.clientWidth:W.offsetX>B.clientWidth),le=Fe&&W.offsetY>B.clientHeight;if(X||le)return}const K=(z=i.current.floatingContext)==null?void 0:z.nodeId,U=w&&_i(w.nodesRef.current,K).some(J=>{var ne;return Wg(W,(ne=J.context)==null?void 0:ne.elements.floating)});if(Wg(W,a.floating)||Wg(W,a.domReference)||U)return;const Q=w?_i(w.nodesRef.current,K):[];if(Q.length>0){let J=!0;if(Q.forEach(ne=>{var ae;if((ae=ne.context)!=null&&ae.open&&!ne.context.dataRef.current.__outsidePressBubbles){J=!1;return}}),!J)return}s(!1,W,"outside-press")}),M=hr(W=>{var z;const te=()=>{var H;F(W),(H=Qa(W))==null||H.removeEventListener(m,te)};(z=Qa(W))==null||z.addEventListener(m,te)});f.useEffect(()=>{if(!r||!c)return;i.current.__escapeKeyBubbles=I,i.current.__outsidePressBubbles=S;let W=-1;function z(E){s(!1,E,"ancestor-scroll")}function te(){window.clearTimeout(W),P.current=!0}function H(){W=window.setTimeout(()=>{P.current=!1},Ep()?5:0)}const B=ur(a.floating);d&&(B.addEventListener("keydown",T?L:C,T),B.addEventListener("compositionstart",te),B.addEventListener("compositionend",H)),j&&B.addEventListener(m,$?M:F,$);let O=[];return x&&(on(a.domReference)&&(O=Ho(a.domReference)),on(a.floating)&&(O=O.concat(Ho(a.floating))),!on(a.reference)&&a.reference&&a.reference.contextElement&&(O=O.concat(Ho(a.reference.contextElement)))),O=O.filter(E=>{var ee;return E!==((ee=B.defaultView)==null?void 0:ee.visualViewport)}),O.forEach(E=>{E.addEventListener("scroll",z,{passive:!0})}),()=>{d&&(B.removeEventListener("keydown",T?L:C,T),B.removeEventListener("compositionstart",te),B.removeEventListener("compositionend",H)),j&&B.removeEventListener(m,$?M:F,$),O.forEach(E=>{E.removeEventListener("scroll",z)}),window.clearTimeout(W)}},[i,a,d,j,m,r,s,x,c,I,S,C,T,L,F,$,M]),f.useEffect(()=>{i.current.insideReactTree=!1},[i,j,m]);const D=f.useMemo(()=>({onKeyDown:C,...h&&{[gM[g]]:W=>{s(!1,W.nativeEvent,"reference-press")},...g!=="click"&&{onClick(W){s(!1,W.nativeEvent,"reference-press")}}}}),[C,s,h,g]),A=f.useMemo(()=>{function W(z){z.button===0&&(N.current=!0)}return{onKeyDown:C,onMouseDown:W,onMouseUp:W,[fM[m]]:()=>{i.current.insideReactTree=!0}}},[C,m,i]);return f.useMemo(()=>c?{reference:D,floating:A}:{},[c,D,A])}function xM(e){const{open:n=!1,onOpenChange:r,elements:s}=e,a=Ox(),i=f.useRef({}),[c]=f.useState(()=>tM()),d=Op()!=null,[u,m]=f.useState(s.reference),h=hr((y,b,w)=>{i.current.openEvent=y?b:void 0,c.emit("openchange",{open:y,event:b,reason:w,nested:d}),r==null||r(y,b,w)}),g=f.useMemo(()=>({setPositionReference:m}),[]),x=f.useMemo(()=>({reference:u||s.reference||null,floating:s.floating||null,domReference:s.reference}),[u,s.reference,s.floating]);return f.useMemo(()=>({dataRef:i,open:n,onOpenChange:h,elements:x,events:c,floatingId:a,refs:g}),[n,h,x,c,a,g])}function wa(e){e===void 0&&(e={});const{nodeId:n}=e,r=xM({...e,elements:{reference:null,floating:null,...e.elements}}),s=e.rootContext||r,a=s.elements,[i,c]=f.useState(null),[d,u]=f.useState(null),h=(a==null?void 0:a.domReference)||i,g=f.useRef(null),x=_d();En(()=>{h&&(g.current=h)},[h]);const y=GA({...e,elements:{...a,...d&&{reference:d}}}),b=f.useCallback(I=>{const S=on(I)?{getBoundingClientRect:()=>I.getBoundingClientRect(),getClientRects:()=>I.getClientRects(),contextElement:I}:I;u(S),y.refs.setReference(S)},[y.refs]),w=f.useCallback(I=>{(on(I)||I===null)&&(g.current=I,c(I)),(on(y.refs.reference.current)||y.refs.reference.current===null||I!==null&&!on(I))&&y.refs.setReference(I)},[y.refs]),k=f.useMemo(()=>({...y.refs,setReference:w,setPositionReference:b,domReference:g}),[y.refs,w,b]),j=f.useMemo(()=>({...y.elements,domReference:h}),[y.elements,h]),N=f.useMemo(()=>({...y,...s,refs:k,elements:j,nodeId:n}),[y,k,j,n,s]);return En(()=>{s.dataRef.current.floatingContext=N;const I=x==null?void 0:x.nodesRef.current.find(S=>S.id===n);I&&(I.context=N)}),f.useMemo(()=>({...y,context:N,refs:k,elements:j}),[y,k,j,N])}function Vg(){return ZE()&&f5()}function yM(e,n){n===void 0&&(n={});const{open:r,onOpenChange:s,events:a,dataRef:i,elements:c}=e,{enabled:d=!0,visibleOnly:u=!0}=n,m=f.useRef(!1),h=f.useRef(-1),g=f.useRef(!0);f.useEffect(()=>{if(!d)return;const y=Gr(c.domReference);function b(){!r&&tr(c.domReference)&&c.domReference===pa(ur(c.domReference))&&(m.current=!0)}function w(){g.current=!0}function k(){g.current=!1}return y.addEventListener("blur",b),Vg()&&(y.addEventListener("keydown",w,!0),y.addEventListener("pointerdown",k,!0)),()=>{y.removeEventListener("blur",b),Vg()&&(y.removeEventListener("keydown",w,!0),y.removeEventListener("pointerdown",k,!0))}},[c.domReference,r,d]),f.useEffect(()=>{if(!d)return;function y(b){let{reason:w}=b;(w==="reference-press"||w==="escape-key")&&(m.current=!0)}return a.on("openchange",y),()=>{a.off("openchange",y)}},[a,d]),f.useEffect(()=>()=>{as(h)},[]);const x=f.useMemo(()=>({onMouseLeave(){m.current=!1},onFocus(y){if(m.current)return;const b=Qa(y.nativeEvent);if(u&&on(b)){if(Vg()&&!y.relatedTarget){if(!g.current&&!y5(b))return}else if(!rA(b))return}s(!0,y.nativeEvent,"focus")},onBlur(y){m.current=!1;const b=y.relatedTarget,w=y.nativeEvent,k=on(b)&&b.hasAttribute(Ai("focus-guard"))&&b.getAttribute("data-type")==="outside";h.current=window.setTimeout(()=>{var j;const N=pa(c.domReference?c.domReference.ownerDocument:document);!b&&N===c.domReference||dr((j=i.current.floatingContext)==null?void 0:j.refs.floating.current,N)||dr(c.domReference,N)||k||s(!1,w,"focus")})}}),[i,c.domReference,s,u]);return f.useMemo(()=>d?{reference:x}:{},[d,x])}function Qg(e,n,r){const s=new Map,a=r==="item";let i=e;if(a&&e){const{[Jk]:c,[ew]:d,...u}=e;i=u}return{...r==="floating"&&{tabIndex:-1,[YA]:""},...i,...n.map(c=>{const d=c?c[r]:null;return typeof d=="function"?e?d(e):null:d}).concat(e).reduce((c,d)=>(d&&Object.entries(d).forEach(u=>{let[m,h]=u;if(!(a&&[Jk,ew].includes(m)))if(m.indexOf("on")===0){if(s.has(m)||s.set(m,[]),typeof h=="function"){var g;(g=s.get(m))==null||g.push(h),c[m]=function(){for(var x,y=arguments.length,b=new Array(y),w=0;w<y;w++)b[w]=arguments[w];return(x=s.get(m))==null?void 0:x.map(k=>k(...b)).find(k=>k!==void 0)}}}else c[m]=h}),c),{})}}function lo(e){e===void 0&&(e=[]);const n=e.map(d=>d==null?void 0:d.reference),r=e.map(d=>d==null?void 0:d.floating),s=e.map(d=>d==null?void 0:d.item),a=f.useCallback(d=>Qg(d,e,"reference"),n),i=f.useCallback(d=>Qg(d,e,"floating"),r),c=f.useCallback(d=>Qg(d,e,"item"),s);return f.useMemo(()=>({getReferenceProps:a,getFloatingProps:i,getItemProps:c}),[a,i,c])}const bM="Escape";function Dp(e,n,r){switch(e){case"vertical":return n;case"horizontal":return r;default:return n||r}}function Fu(e,n){return Dp(n,e===P5||e===Fp,e===Td||e===$d)}function Yg(e,n,r){return Dp(n,e===Fp,r?e===Td:e===$d)||e==="Enter"||e===" "||e===""}function pw(e,n,r){return Dp(n,r?e===Td:e===$d,e===Fp)}function mw(e,n,r,s){const a=r?e===$d:e===Td,i=e===P5;return n==="both"||n==="horizontal"&&s&&s>1?e===bM:Dp(n,a,i)}function vM(e,n){const{open:r,onOpenChange:s,elements:a,floatingId:i}=e,{listRef:c,activeIndex:d,onNavigate:u=()=>{},enabled:m=!0,selectedIndex:h=null,allowEscape:g=!1,loop:x=!1,nested:y=!1,rtl:b=!1,virtual:w=!1,focusItemOnOpen:k="auto",focusItemOnHover:j=!0,openOnArrowKeyDown:N=!0,disabledIndices:I=void 0,orientation:S="vertical",parentOrientation:T,cols:$=1,scrollItemIntoView:P=!0,virtualItemRef:C,itemSizes:L,dense:F=!1}=n,M=Wh(a.floating),D=Rs(M),A=Op(),W=_d();En(()=>{e.dataRef.current.orientation=S},[e,S]);const z=hr(()=>{u(B.current===-1?null:B.current)}),te=mf(a.domReference),H=f.useRef(k),B=f.useRef(h??-1),O=f.useRef(null),E=f.useRef(!0),ee=f.useRef(z),K=f.useRef(!!a.floating),U=f.useRef(r),Q=f.useRef(!1),J=f.useRef(!1),ne=Rs(I),ae=Rs(r),we=Rs(P),$e=Rs(h),[Fe,oe]=f.useState(),[re,X]=f.useState(),le=hr(()=>{function se(Qe){if(w){var ct;(ct=Qe.id)!=null&&ct.endsWith("-fui-option")&&(Qe.id=i+"-"+Math.random().toString(16).slice(2,10)),oe(Qe.id),W==null||W.events.emit("virtualfocus",Qe),C&&(C.current=Qe)}else Ri(Qe,{sync:Q.current,preventScroll:!0})}const Ce=c.current[B.current],_e=J.current;Ce&&se(Ce),(Q.current?Qe=>Qe():requestAnimationFrame)(()=>{const Qe=c.current[B.current]||Ce;if(!Qe)return;Ce||se(Qe);const ct=we.current;ct&&Ve&&(_e||!E.current)&&(Qe.scrollIntoView==null||Qe.scrollIntoView(typeof ct=="boolean"?{block:"nearest",inline:"nearest"}:ct))})});En(()=>{m&&(r&&a.floating?H.current&&h!=null&&(J.current=!0,B.current=h,z()):K.current&&(B.current=-1,ee.current()))},[m,r,a.floating,h,z]),En(()=>{if(m&&r&&a.floating)if(d==null){if(Q.current=!1,$e.current!=null)return;if(K.current&&(B.current=-1,le()),(!U.current||!K.current)&&H.current&&(O.current!=null||H.current===!0&&O.current==null)){let se=0;const Ce=()=>{c.current[0]==null?(se<2&&(se?requestAnimationFrame:queueMicrotask)(Ce),se++):(B.current=O.current==null||Yg(O.current,S,b)||y?qg(c,ne.current):Kk(c,ne.current),O.current=null,z())};Ce()}}else sd(c,d)||(B.current=d,le(),J.current=!1)},[m,r,a.floating,d,$e,y,c,S,b,z,le,ne]),En(()=>{var se;if(!m||a.floating||!W||w||!K.current)return;const Ce=W.nodesRef.current,_e=(se=Ce.find(ct=>ct.id===A))==null||(se=se.context)==null?void 0:se.elements.floating,pe=pa(ur(a.floating)),Qe=Ce.some(ct=>ct.context&&dr(ct.context.elements.floating,pe));_e&&!Qe&&E.current&&_e.focus({preventScroll:!0})},[m,a.floating,W,A,w]),En(()=>{if(!m||!W||!w||A)return;function se(Ce){X(Ce.id),C&&(C.current=Ce)}return W.events.on("virtualfocus",se),()=>{W.events.off("virtualfocus",se)}},[m,W,w,A,C]),En(()=>{ee.current=z,U.current=r,K.current=!!a.floating}),En(()=>{r||(O.current=null,H.current=k)},[r,k]);const Ne=d!=null,Ve=f.useMemo(()=>{function se(_e){if(!ae.current)return;const pe=c.current.indexOf(_e);pe!==-1&&B.current!==pe&&(B.current=pe,z())}return{onFocus(_e){let{currentTarget:pe}=_e;Q.current=!0,se(pe)},onClick:_e=>{let{currentTarget:pe}=_e;return pe.focus({preventScroll:!0})},onMouseMove(_e){let{currentTarget:pe}=_e;Q.current=!0,J.current=!1,j&&se(pe)},onPointerLeave(_e){let{pointerType:pe}=_e;if(!(!E.current||pe==="touch")&&(Q.current=!0,!!j&&(B.current=-1,z(),!w))){var Qe;(Qe=D.current)==null||Qe.focus({preventScroll:!0})}}}},[ae,D,j,c,z,w]),me=f.useCallback(()=>{var se;return T??(W==null||(se=W.nodesRef.current.find(Ce=>Ce.id===A))==null||(se=se.context)==null||(se=se.dataRef)==null?void 0:se.current.orientation)},[A,W,T]),be=hr(se=>{if(E.current=!1,Q.current=!0,se.which===229||!ae.current&&se.currentTarget===D.current)return;if(y&&mw(se.key,S,b,$)){Fu(se.key,me())||Mr(se),s(!1,se.nativeEvent,"list-navigation"),tr(a.domReference)&&(w?W==null||W.events.emit("virtualfocus",a.domReference):a.domReference.focus());return}const Ce=B.current,_e=qg(c,I),pe=Kk(c,I);if(te||(se.key==="Home"&&(Mr(se),B.current=_e,z()),se.key==="End"&&(Mr(se),B.current=pe,z())),$>1){const Qe=L||Array.from({length:c.current.length},()=>({width:1,height:1})),ct=hA(Qe,$,F),Bt=ct.findIndex(Ft=>Ft!=null&&!sh(c,Ft,I)),Je=ct.reduce((Ft,fe,rt)=>fe!=null&&!sh(c,fe,I)?rt:Ft,-1),Qt=ct[uA({current:ct.map(Ft=>Ft!=null?c.current[Ft]:null)},{event:se,orientation:S,loop:x,rtl:b,cols:$,disabledIndices:mA([...(typeof I!="function"?I:null)||c.current.map((Ft,fe)=>sh(c,fe,I)?fe:void 0),void 0],ct),minIndex:Bt,maxIndex:Je,prevIndex:pA(B.current>pe?_e:B.current,Qe,ct,$,se.key===Fp?"bl":se.key===(b?Td:$d)?"tr":"tl"),stopEvent:!0})];if(Qt!=null&&(B.current=Qt,z()),S==="both")return}if(Fu(se.key,S)){if(Mr(se),r&&!w&&pa(se.currentTarget.ownerDocument)===se.currentTarget){B.current=Yg(se.key,S,b)?_e:pe,z();return}Yg(se.key,S,b)?x?B.current=Ce>=pe?g&&Ce!==c.current.length?-1:_e:jr(c,{startingIndex:Ce,disabledIndices:I}):B.current=Math.min(pe,jr(c,{startingIndex:Ce,disabledIndices:I})):x?B.current=Ce<=_e?g&&Ce!==-1?c.current.length:pe:jr(c,{startingIndex:Ce,decrement:!0,disabledIndices:I}):B.current=Math.max(_e,jr(c,{startingIndex:Ce,decrement:!0,disabledIndices:I})),sd(c,B.current)&&(B.current=-1),z()}}),at=f.useMemo(()=>w&&r&&Ne&&{"aria-activedescendant":re||Fe},[w,r,Ne,re,Fe]),ft=f.useMemo(()=>({"aria-orientation":S==="both"?void 0:S,...te?{}:at,onKeyDown:be,onPointerMove(){E.current=!0}}),[at,be,S,te]),mt=f.useMemo(()=>{function se(_e){k==="auto"&&b5(_e.nativeEvent)&&(H.current=!0)}function Ce(_e){H.current=k,k==="auto"&&v5(_e.nativeEvent)&&(H.current=!0)}return{...at,onKeyDown(_e){E.current=!1;const pe=_e.key.startsWith("Arrow"),Qe=["Home","End"].includes(_e.key),ct=pe||Qe,Bt=pw(_e.key,S,b),Je=mw(_e.key,S,b,$),Qt=pw(_e.key,me(),b),Ft=Fu(_e.key,S),fe=(y?Qt:Ft)||_e.key==="Enter"||_e.key.trim()==="";if(w&&r){const Wt=W==null?void 0:W.nodesRef.current.find(je=>je.parentId==null),St=W&&Wt?sA(W.nodesRef.current,Wt.id):null;if(ct&&St&&C){const je=new KeyboardEvent("keydown",{key:_e.key,bubbles:!0});if(Bt||Je){var rt,et;const Rt=((rt=St.context)==null?void 0:rt.elements.domReference)===_e.currentTarget,Pt=Je&&!Rt?(et=St.context)==null?void 0:et.elements.domReference:Bt?c.current.find(qt=>(qt==null?void 0:qt.id)===Fe):null;Pt&&(Mr(_e),Pt.dispatchEvent(je),X(void 0))}if((Ft||Qe)&&St.context&&St.context.open&&St.parentId&&_e.currentTarget!==St.context.elements.domReference){var It;Mr(_e),(It=St.context.elements.domReference)==null||It.dispatchEvent(je);return}}return be(_e)}if(!(!r&&!N&&pe)){if(fe){const Wt=Fu(_e.key,me());O.current=y&&Wt?null:_e.key}if(y){Qt&&(Mr(_e),r?(B.current=qg(c,ne.current),z()):s(!0,_e.nativeEvent,"list-navigation"));return}Ft&&(h!=null&&(B.current=h),Mr(_e),!r&&N?s(!0,_e.nativeEvent,"list-navigation"):be(_e),r&&z())}},onFocus(){r&&!w&&(B.current=-1,z())},onPointerDown:Ce,onPointerEnter:Ce,onMouseDown:se,onClick:se}},[Fe,at,$,be,ne,k,c,y,z,s,r,N,S,me,b,h,W,w,C]);return f.useMemo(()=>m?{reference:mt,floating:ft,item:Ve}:{},[m,mt,ft,Ve])}const kM=new Map([["select","listbox"],["combobox","listbox"],["label",!1]]);function wM(e,n){var r,s;n===void 0&&(n={});const{open:a,elements:i,floatingId:c}=e,{enabled:d=!0,role:u="dialog"}=n,m=Ox(),h=((r=i.domReference)==null?void 0:r.id)||m,g=f.useMemo(()=>{var N;return((N=Wh(i.floating))==null?void 0:N.id)||c},[i.floating,c]),x=(s=kM.get(u))!=null?s:u,b=Op()!=null,w=f.useMemo(()=>x==="tooltip"||u==="label"?{["aria-"+(u==="label"?"labelledby":"describedby")]:a?g:void 0}:{"aria-expanded":a?"true":"false","aria-haspopup":x==="alertdialog"?"dialog":x,"aria-controls":a?g:void 0,...x==="listbox"&&{role:"combobox"},...x==="menu"&&{id:h},...x==="menu"&&b&&{role:"menuitem"},...u==="select"&&{"aria-autocomplete":"none"},...u==="combobox"&&{"aria-autocomplete":"list"}},[x,g,b,a,h,u]),k=f.useMemo(()=>{const N={id:g,...x&&{role:x}};return x==="tooltip"||u==="label"?N:{...N,...x==="menu"&&{"aria-labelledby":h}}},[x,g,h,u]),j=f.useCallback(N=>{let{active:I,selected:S}=N;const T={role:"option",...I&&{id:g+"-fui-option"}};switch(u){case"select":case"combobox":return{...T,"aria-selected":S}}return{}},[g,u]);return f.useMemo(()=>d?{reference:w,floating:k,item:j}:{},[d,w,k,j])}function jM(e,n,r){const s=r&&r.length>0?[...r].sort((a,i)=>a-i).join(","):"all";return Oe({queryKey:["user-stats",e,dt(n),s],queryFn:()=>he.userStats(e,n,r),enabled:e!=null&&n!=null,staleTime:1e3*60*5,gcTime:fn})}function L5({user:e,userId:n,repoId:r,anchor:s,onDismiss:a}){const i=G(F=>F.workspaceId),c=Ge(F=>F.openUserActivityTab),{periodReports:d}=vt(),{data:u}=xn(),m=f.useMemo(()=>r!=null?[r]:null,[r]),h=f.useMemo(()=>{var F;return r==null?i:((F=(u??[]).find(M=>M.id===r))==null?void 0:F.workspaceId)??null},[r,u,i]),g=f.useMemo(()=>{if(r!=null){const F=(u??[]).find(M=>M.id===r);return F?`in ${F.fullName}`:"in this repo"}return"across this workspace"},[r,u]),{data:x,isLoading:y,isError:b}=jM(n,h,m),{refs:w,floatingStyles:k,context:j,isPositioned:N}=wa({open:!0,onOpenChange:F=>{F||a()},strategy:"fixed",placement:"bottom-start",middleware:[oo(6),io({fallbackPlacements:["top-start","right-start","left-start"]}),ri({padding:8})],whileElementsMounted:(F,M,D)=>ni(F,M,D,{animationFrame:s.kind==="selector"})}),I=si(j,{outsidePress:F=>{var D,A;const M=F.target;return!((D=M==null?void 0:M.closest)!=null&&D.call(M,"[data-user-handle]"))&&!((A=M==null?void 0:M.closest)!=null&&A.call(M,"[data-user-gid]"))}}),{getFloatingProps:S}=lo([I]),T=f.useRef(null),$=s.kind==="selector"?s.selector:"element";f.useEffect(()=>{T.current=null},[$]),f.useEffect(()=>{if(s.kind==="element"){w.setReference(s.el);return}const{selector:F,x:M,y:D}=s,A=()=>({x:M,y:D,top:D,left:M,right:M,bottom:D,width:0,height:0});w.setReference({getBoundingClientRect:()=>{const W=document.querySelector(F);if(W){const z=W.getBoundingClientRect();return T.current=z,z}return T.current??A()}})},[w,s.kind,$,s.kind==="selector"?s.x:0,s.kind==="selector"?s.y:0]);const P=Dt(e,n),C=(e==null?void 0:e.githubLogin)??null,L=x?[{label:"PRs merged",value:x.prsMerged,dot:"#8957e5"},{label:"PRs open",value:x.prsOpen,dot:"#3b82f6"},{label:"PRs draft",value:x.prsDraft,dot:"#9ca3af"},{label:"PRs closed",value:x.prsClosed,dot:"#ef4444"},{label:"Reviews given",value:x.reviewsGiven},{label:"Comments",value:x.comments}]:[];return t.jsx(ka,{children:t.jsxs("div",{ref:w.setFloating,style:{...k,visibility:N?"visible":"hidden"},...S(),"data-testid":"user-profile-popover",className:"z-50 w-64 rounded-lg border border-gray-200 bg-white p-3 shadow-xl dark:border-gray-700 dark:bg-gray-900",children:[t.jsxs("div",{className:"flex items-center gap-2.5",children:[e!=null&&e.avatarUrl?t.jsx("img",{src:e.avatarUrl,width:44,height:44,alt:"",loading:"lazy",referrerPolicy:"no-referrer",className:"h-11 w-11 shrink-0 rounded-full bg-gray-100 dark:bg-gray-800"}):t.jsx("span",{className:"flex h-11 w-11 shrink-0 items-center justify-center rounded-full bg-gray-200 text-base font-semibold text-gray-500 dark:bg-gray-800 dark:text-gray-400",children:(P[0]??"?").toUpperCase()}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"truncate text-sm font-semibold text-gray-800 dark:text-gray-100",title:P,children:P}),C&&t.jsxs("div",{className:"truncate text-xs text-gray-500 dark:text-gray-400",title:`@${C}`,children:["@",C]})]})]}),t.jsxs("div",{className:"mt-2.5 text-[10px] uppercase tracking-wide text-gray-400",title:g,children:["All time · ",g]}),y&&t.jsx("div",{className:"py-3 text-xs text-gray-400 dark:text-gray-500",children:"Loading activity…"}),b&&t.jsx("div",{className:"py-3 text-xs text-red-500 dark:text-red-400",children:"Couldn't load stats."}),x&&t.jsx("table",{className:"mt-1 w-full text-xs",children:t.jsx("tbody",{children:L.map(F=>t.jsxs("tr",{className:"border-t border-gray-100 first:border-0 dark:border-gray-800",children:[t.jsx("td",{className:"py-1 pr-2 text-gray-500 dark:text-gray-400",children:t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[F.dot&&t.jsx("span",{className:"inline-block h-2 w-2 rounded-full",style:{backgroundColor:F.dot}}),F.label]})}),t.jsx("td",{className:"py-1 text-right font-medium tabular-nums text-gray-800 dark:text-gray-100",children:F.value})]},F.label))})}),t.jsxs("div",{className:"mt-2.5 flex items-center justify-between gap-2 border-t border-gray-100 pt-2 dark:border-gray-800",children:[t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("button",{type:"button",onClick:()=>{c(n,{id:n,login:(e==null?void 0:e.githubLogin)??null,displayName:(e==null?void 0:e.displayName)??null,avatarUrl:(e==null?void 0:e.avatarUrl)??null}),a()},className:"rounded px-1.5 py-1 text-xs font-medium text-sky-600 hover:bg-sky-50 dark:text-sky-400 dark:hover:bg-sky-950/40",title:`Open ${P}'s recent activity in a tab`,children:"View activity →"}),d&&t.jsx("button",{type:"button",onClick:()=>{c(n,{id:n,login:(e==null?void 0:e.githubLogin)??null,displayName:(e==null?void 0:e.displayName)??null,avatarUrl:(e==null?void 0:e.avatarUrl)??null}),a()},className:"rounded px-1.5 py-1 text-xs font-medium text-ai-signal hover:bg-ai-signal/10",title:`Prep for a 1:1 with ${P} — their period figures, not a scorecard`,children:"1:1 prep →"})]}),C&&t.jsxs("a",{href:Gl(C),target:"_blank",rel:"noreferrer noopener",onClick:F=>F.stopPropagation(),className:"inline-flex items-center gap-1 rounded px-1.5 py-1 text-xs text-gray-500 hover:bg-gray-100 hover:text-gray-700 dark:text-gray-400 dark:hover:bg-gray-800 dark:hover:text-gray-200",title:`@${C} on GitHub`,children:["GitHub",t.jsx(_t,{size:11})]})]})]})})}function mr({user:e,fallbackId:n,repoId:r,className:s}){var k;const a=Ax(),[i,c]=f.useState(!1),[d,u]=f.useState(null),h=r!=null&&e!=null&&(((k=a.get(r))==null?void 0:k.has(e.id))??!1)?t.jsx($p,{}):null,g=Dt(e,n),x=(e==null?void 0:e.id)??null,y=(e==null?void 0:e.githubLogin)??null,b=x==null?t.jsx("span",{className:s,children:g}):t.jsx("a",{ref:u,href:y?Gl(y):void 0,target:y?"_blank":void 0,rel:y?"noreferrer noopener":void 0,"data-user-handle":x,onClick:j=>{j.stopPropagation(),!(j.metaKey||j.ctrlKey||j.shiftKey||j.altKey)&&(j.preventDefault(),c(N=>!N))},title:y?`@${y} — activity & stats`:"Activity & stats",className:[s,"cursor-pointer hover:underline"].filter(Boolean).join(" "),children:g}),w=i&&x!=null&&d!=null?t.jsx(L5,{user:e,userId:x,repoId:r??null,anchor:{kind:"element",el:d},onDismiss:()=>c(!1)}):null;return h?t.jsxs("span",{className:"inline-flex items-center gap-1",children:[b,h,w]}):t.jsxs(t.Fragment,{children:[b,w]})}function gn({user:e,size:n=24}){const r=Dt(e,null);return e!=null&&e.avatarUrl?t.jsx("img",{src:e.avatarUrl,alt:r,width:n,height:n,className:"shrink-0 rounded-full",style:{width:n,height:n}}):t.jsx("span",{className:"flex shrink-0 items-center justify-center rounded-full bg-gray-300 text-[10px] font-semibold text-gray-700 dark:bg-gray-700 dark:text-gray-200",style:{width:n,height:n},children:r.slice(0,2).toUpperCase()})}function NM({comment:e,usersById:n,repoId:r}){const s=e.authorId!=null?n.get(e.authorId):void 0;return t.jsxs("div",{className:"flex gap-2",children:[t.jsx(gn,{user:s}),t.jsxs("div",{className:"min-w-0 flex-1 rounded-md border border-gray-200 dark:border-gray-800",children:[t.jsxs("div",{className:"flex items-center gap-2 border-b border-gray-100 px-3 py-1 text-xs dark:border-gray-800",children:[t.jsx(mr,{user:s,fallbackId:e.authorId,repoId:r,className:"font-semibold"}),t.jsx("span",{className:"text-gray-400",children:Nt(e.createdAt)})]}),t.jsx("div",{className:"px-3 py-2",children:t.jsx(gr,{children:e.body})})]})]})}async function Pd(e,n){const r=await fetch(e,{method:n.method??"GET",credentials:"same-origin",headers:{Accept:"text/event-stream",...n.body!==void 0?{"content-type":"application/json"}:{}},body:n.body!==void 0?JSON.stringify(n.body):void 0,signal:n.signal});if(!r.ok){let d=`${r.status} ${r.statusText}`;try{const u=await r.json();u.message&&(d=u.message)}catch{}throw new cn(r.status,d)}if(!r.body)throw new cn(r.status,"stream has no body");const s=r.body.getReader(),a=new TextDecoder;let i="";const c=d=>{const u=[];for(const m of d.split(`
33
+ `))m.startsWith("data:")&&u.push(m.slice(5).replace(/^ /,""));if(u.length!==0)try{n.onEvent(JSON.parse(u.join(`
34
+ `)))}catch{}};try{for(;;){const{done:d,value:u}=await s.read();if(d)break;i+=a.decode(u,{stream:!0}).replace(/\r\n/g,`
35
+ `);let m;for(;(m=i.indexOf(`
36
+
37
+ `))!==-1;)c(i.slice(0,m)),i=i.slice(m+2)}i.trim()&&c(i)}finally{try{s.releaseLock()}catch{}}}function DJ(e,n){return Oe({queryKey:["ai-fix",e],queryFn:()=>he.aiFix(e),enabled:e!=null&&n})}function SM(e,n){return Oe({queryKey:["ai-fix-summary",e],queryFn:()=>he.aiFixSummary(e),enabled:e!=null&&n})}function CM(e){const n=He();return tt({mutationFn:()=>he.refreshAiFixSummary(e),onSuccess:r=>n.setQueryData(["ai-fix-summary",e],r)})}function F5(e){return["ai-fix-start",e]}function BJ(e){const n=He();return tt({mutationKey:F5(e),mutationFn:r=>he.startAiFix(e,r),onSuccess:()=>void n.invalidateQueries({queryKey:["ai-fix",e]})})}function WJ(e){const n=He();return tt({mutationFn:()=>he.cancelAiFix(e),onSuccess:()=>void n.invalidateQueries({queryKey:["ai-fix",e]})})}function qJ(e){const n=He();return tt({mutationFn:r=>he.pushAiFix(r.fixId,r.body),onSuccess:()=>{n.invalidateQueries({queryKey:["ai-fix",e]}),dn(n,e)}})}function RM(e,n){const r=He(),[s,a]=f.useState(null);return f.useEffect(()=>{if(e==null||!n){a(null);return}const i=new AbortController;let c=!1;const d=()=>{c||(c=!0,r.invalidateQueries({queryKey:["ai-fix",e]}))};return Pd(`/api/pro/prs/${e}/ai-fix/stream`,{signal:i.signal,onEvent:u=>{u.type==="done"?(d(),a({status:u.status,fixId:u.fixId,progress:null})):a({status:u.status,fixId:u.fixId,progress:u.progress})}}).catch(()=>{}),()=>i.abort()},[e,n,r]),{status:s}}function O5({pr:e}){const{prSummary:n}=vt(),{data:r}=SM(e.id,n),s=CM(e.id),a=(r==null?void 0:r.headSha)!=null&&r.headSha!==e.headSha,i=(r==null?void 0:r.creditsExhausted)===!0;return n?t.jsxs("div",{children:[t.jsx("div",{className:"px-4 pb-1 pt-2 text-xs font-semibold uppercase tracking-wide text-gray-400",children:"AI summary"}),t.jsxs("div",{className:"px-4 pb-3",children:[r!=null&&r.summary?t.jsx("div",{className:"prose prose-sm max-w-none dark:prose-invert",children:t.jsx(gr,{children:r.summary})}):t.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Generate a plain-language overview of what this PR does."}),t.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[t.jsx("button",{type:"button",className:"whitespace-nowrap rounded border border-blue-400 px-2.5 py-1 text-xs text-blue-600 hover:bg-blue-50 disabled:opacity-50 dark:border-blue-600 dark:text-blue-400 dark:hover:bg-blue-900/30",disabled:s.isPending||i,onClick:()=>s.mutate(),children:s.isPending?"Generating…":r!=null&&r.summary?"Regenerate":"Generate summary"}),i&&t.jsx("span",{className:"text-[11px] text-amber-600 dark:text-amber-400",children:"Out of AI credits this month"}),a&&t.jsx("span",{className:"text-[11px] text-amber-600 dark:text-amber-400",children:"PR has changed since this was generated"}),s.isError&&t.jsx("span",{className:"text-[11px] text-red-500",children:s.error instanceof cn||s.error instanceof Error?s.error.message:"Something went wrong"})]})]})]}):null}function Wx({state:e,count:n}){const r=Xt[e];return t.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-xs font-medium",style:{backgroundColor:`${r.color}22`,...pn(r.color)},title:r.description,children:[t.jsx("span",{className:"inline-block h-2 w-2 rounded-full",style:{backgroundColor:r.color}}),r.label,n!==void 0&&t.jsxs("span",{className:"opacity-70",children:["· ",n]})]})}function IM({confidence:e,reason:n}){if(e==="none")return null;const r=wp[e],s=n?`${r.description}
38
+ Signal: ${n}`:r.description;return t.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full px-1.5 py-0.5 text-[10px] font-semibold",style:{backgroundColor:`${r.color}1a`,...pn(r.color)},title:s,children:[t.jsx("span",{className:"inline-block h-1.5 w-1.5 rounded-full",style:{backgroundColor:r.color}}),r.label," confidence"]})}const qx=400,gw=2e3,TM={ts:"typescript",tsx:"typescript",mts:"typescript",cts:"typescript",js:"javascript",jsx:"javascript",mjs:"javascript",cjs:"javascript",json:"json",py:"python",rb:"ruby",go:"go",rs:"rust",java:"java",kt:"kotlin",swift:"swift",c:"c",h:"c",cc:"cpp",cpp:"cpp",hpp:"cpp",cs:"csharp",php:"php",sh:"bash",bash:"bash",zsh:"bash",sql:"sql",css:"css",scss:"scss",less:"less",html:"xml",xml:"xml",svg:"xml",yml:"yaml",yaml:"yaml",toml:"ini",ini:"ini",md:"markdown",markdown:"markdown",dockerfile:"dockerfile"};function Yl(e){const n=e.slice(e.lastIndexOf("/")+1).toLowerCase();if(n==="dockerfile")return"dockerfile";if(n==="makefile")return"makefile";const r=n.lastIndexOf(".");return r<=0?null:TM[n.slice(r+1)]??null}function $M(e){const n=[],r=[];let s="",a=0;for(;a<e.length;){const i=e.slice(a).search(/[<\n]/);if(i===-1){s+=e.slice(a);break}if(s+=e.slice(a,a+i),a+=i,e[a]===`
39
+ `){for(let u=r.length-1;u>=0;u-=1)s+="</span>";n.push(s),s=r.join(""),a+=1;continue}const c=e.indexOf(">",a);if(c===-1){s+=e.slice(a);break}const d=e.slice(a,c+1);d.startsWith("</")?r.pop():d.endsWith("/>")||r.push(d),s+=d,a=c+1}for(let i=r.length-1;i>=0;i-=1)s+="</span>";return n.push(s),n}function Mi(e,n,r=qx){if(n==null||e.length===0||e.length>r||vh.getLanguage(n)==null)return null;let s;try{s=vh.highlight(e.join(`
40
+ `),{language:n,ignoreIllegals:!0}).value}catch{return null}const a=$M(s);return a.length!==e.length?null:a}function _M(e,n){if(n==null||e===""||e.split(`
41
+ `).length>qx||vh.getLanguage(n)==null)return null;try{return vh.highlight(e,{language:n,ignoreIllegals:!0}).value}catch{return null}}function D5(e){const n=/^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@ ?(.*)$/.exec(e);return n?{oldStart:Number(n[1]),oldCount:n[2]==null?1:Number(n[2]),newStart:Number(n[3]),newCount:n[4]==null?1:Number(n[4]),context:(n[5]??"").trim()}:null}function Bp(e){if(!e)return[];const n=[];let r=0,s=0,a=1,i=1;for(const c of e.replace(/\n$/,"").split(`
42
+ `)){const d=D5(c);if(d){const m=d.newCount>0?d.newStart-i:d.oldCount>0?d.oldStart-a:0;n.push({kind:"hunk",text:c,gap:{count:Math.max(0,m),oldFrom:a,newFrom:i,context:d.context}}),r=d.oldStart,s=d.newStart,a=d.oldCount===0?d.oldStart+1:d.oldStart,i=d.newCount===0?d.newStart+1:d.newStart;continue}const u=c[0];u==="+"?(n.push({kind:"add",text:c,newLine:s}),s+=1,i=s):u==="-"?(n.push({kind:"del",text:c,oldLine:r}),r+=1,a=r):u==="\\"?n.push({kind:"context",text:c}):(n.push({kind:"context",text:c,oldLine:r,newLine:s}),r+=1,s+=1,a=r,i=s)}return n}function PM(e){let n=1,r=1;for(const s of e){if(s.kind==="hunk"){const a=D5(s.text);a&&(n=a.oldCount===0?a.oldStart+1:a.oldStart,r=a.newCount===0?a.newStart+1:a.newStart);continue}s.oldLine!=null&&(n=s.oldLine+1),s.newLine!=null&&(r=s.newLine+1)}return{oldNext:n,newNext:r}}const ff=20,Hh={top:0,bottom:0};function EM(e,n){var r;for(let s=n-1;s>=0;s-=1)if(((r=e[s])==null?void 0:r.kind)==="hunk")return"between";return"first"}function B5(e,n){if(e==null)return Hh;const r=Math.min(Math.max(0,n.top),e),s=Math.min(Math.max(0,n.bottom),e-r);return{top:r,bottom:s}}function W5(e,n){if(e==null)return null;const r=B5(e,n);return e-r.top-r.bottom}function AM(e,n){return n!=null&&n<=0?[]:e==="first"?["up"]:e==="trailing"?["down"]:n!=null&&n<=ff?["all"]:["down","up"]}function q5(e,n){return n==null?ff:e==="all"?n:Math.min(ff,n)}function MM(e,n,r){const s=q5(n,W5(r,e));return n==="up"?{top:e.top,bottom:e.bottom+s}:{top:e.top+s,bottom:e.bottom}}function LM(e,n){const r=q5(e,n),s=r===1?"line":"lines";return e==="all"?`Expand all ${r.toLocaleString()} ${s}`:`Expand ${r.toLocaleString()} ${s} ${e}`}function FM(e,n){const r=[];return e!=null&&r.push(`${e.toLocaleString()} hidden ${e===1?"line":"lines"}`),n!==""&&r.push(n),r.join(" · ")}function fw(e,n,r){return{count:r,oldFrom:e.oldFrom+n,newFrom:e.newFrom+n,context:e.context}}const OM=3;function DM(e){if(e.length===0)return!0;let n=0;for(let r=e.length-1;r>=0;r-=1){const s=e[r];if(s!=null){if(lc(s))return!0;if(s.kind==="context"){n+=1;continue}break}}return n<OM}function U5(e){const n=Bp(e);for(let r=n.length-1;r>=0;r-=1){const s=n[r];if(!(s==null||s.kind==="hunk")){if(s.kind==="del"){if(s.oldLine!=null&&s.oldLine>0)return{line:s.oldLine,side:"LEFT"};continue}if(s.newLine!=null&&s.newLine>0)return{line:s.newLine,side:"RIGHT"};if(s.oldLine!=null&&s.oldLine>0)return{line:s.oldLine,side:"LEFT"}}}return null}function BM(e,n,r){for(const s of e){if(s.kind==="hunk"||lc(s)||r==="head"&&s.kind==="del"||r==="base"&&s.kind==="add")continue;const a=r==="head"?s.newLine:s.oldLine;if(a==null)continue;const i=Ed(s).body.replace(/\r$/,"");if(n[a-1]!==i)return!1}return!0}function lc(e){return e.kind==="context"&&e.text.startsWith("\\")}function Ed(e){return e.kind==="hunk"||lc(e)?{marker:"",body:e.text}:e.kind==="add"||e.kind==="del"?{marker:e.text.slice(0,1),body:e.text.slice(1)}:e.text.startsWith(" ")?{marker:" ",body:e.text.slice(1)}:{marker:"",body:e.text}}function Ux(e,n,r=qx){if(n==null||e.length===0)return null;let s=0,a=0;for(const m of e)m.kind==="hunk"||lc(m)||(m.kind!=="add"&&(s+=1),m.kind!=="del"&&(a+=1));if(s>r||a>r)return null;const i=e.map(()=>null);let c=!1,d=0;const u=m=>{if(m>d){const h=WM(e,d,m,n,r);if(h!=null){c=!0;for(let g=d;g<m;g+=1)i[g]=h[g-d]??null}}};return e.forEach((m,h)=>{m.kind==="hunk"&&(u(h),d=h+1)}),u(e.length),c?i:null}function WM(e,n,r,s,a){const i=[],c=[],d=[],u=[];for(let g=n;g<r;g+=1){const x=e[g];if(x.kind==="hunk"||lc(x)){d.push(null),u.push(null);continue}const{body:y}=Ed(x);x.kind==="add"?d.push(null):(d.push(i.length),i.push(y)),x.kind==="del"?u.push(null):(u.push(c.length),c.push(y))}if(i.length===0&&c.length===0)return null;const m=i.length===0?[]:Mi(i,s,a),h=c.length===0?[]:Mi(c,s,a);return m==null||h==null?null:d.map((g,x)=>{const y=u[x];if(y!=null)return h[y]??null;const b=d[x];return b!=null?m[b]??null:null})}function qM(e){return e?e.replace(/\n$/,"").split(`
43
+ `).length:0}function H5(e,n,r){let s=null;for(let a=0;a<e.length;a++){const i=e[a];i!=null&&(r==="RIGHT"?(i.kind==="add"||i.kind==="context")&&i.newLine===n&&(s=a):(i.kind==="del"||i.kind==="context")&&i.oldLine===n&&(s=a))}return s}function z5(e){return e.kind==="add"&&e.newLine!=null?{line:e.newLine,side:"RIGHT"}:e.kind==="context"&&e.newLine!=null?{line:e.newLine,side:"RIGHT"}:e.kind==="del"&&e.oldLine!=null?{line:e.oldLine,side:"LEFT"}:null}function UM(e,n){if(n==null)return null;let r=null,s=null;return e.forEach((a,i)=>{const c=z5(a);!c||c.line!==n||(c.side==="RIGHT"?r=i:s=i)}),r??s}function HM(e,n){var a;if(n.line!=null){const i=UM(e,n.line);return i==null?null:{index:i,approximate:!1}}const r=U5((a=n.comments[0])==null?void 0:a.diffHunk);if(r==null)return null;const s=H5(e,r.line,r.side);return s==null?null:{index:s,approximate:!0}}function zM(e,n){const r=new Set,s=new Map;for(const i of n)r.add(i.path),i.previousPath!=null&&i.previousPath!==""&&!s.has(i.previousPath)&&s.set(i.previousPath,i.path);const a=new Map;for(const i of e){const c=r.has(i.path)?i.path:s.get(i.path);if(c==null)continue;const d=a.get(c)??[];d.push(i),a.set(c,d)}return a}function KM(e,n){return(n==null?void 0:n.get(e.id))??e.derivedState!=="resolved"}function GM(e,n,r){if(n!=null)return!1;const s=e.threadId;return s==null||!r.some(a=>a.id===s)}function K5(){return{untouched:0,replied_unresolved:0,likely_addressed:0,resolved:0}}function VM(e,n){e.untouched+=n.untouched,e.replied_unresolved+=n.replied_unresolved,e.likely_addressed+=n.likely_addressed,e.resolved+=n.resolved}function xw(){return{dirs:new Map,files:new Map}}function yw(e,n){return e<n?-1:e>n?1:0}function G5(e,n){const r=[];for(const s of[...e.dirs.keys()].sort(yw)){const a=e.dirs.get(s);a&&r.push(QM(s,a,n))}for(const s of[...e.files.keys()].sort(yw)){const a=e.files.get(s);a&&r.push({kind:"file",name:s,path:a.path,children:[],fileCount:1,additions:a.additions,deletions:a.deletions,threadCounts:a.threadCounts??K5(),entry:a})}return r}function QM(e,n,r){let s=e,a=r===""?e:`${r}/${e}`,i=n;for(;i.files.size===0&&i.dirs.size===1;){const g=[...i.dirs.keys()][0],x=g==null?void 0:i.dirs.get(g);if(g==null||x==null)break;s=`${s}/${g}`,a=`${a}/${g}`,i=x}const c=G5(i,a);let d=0,u=0,m=0;const h=K5();for(const g of c)d+=g.fileCount,u+=g.additions,m+=g.deletions,VM(h,g.threadCounts);return{kind:"dir",name:s,path:a,children:c,fileCount:d,additions:u,deletions:m,threadCounts:h,entry:null}}function YM(e){const n=xw();for(const r of e){const s=r.path.split("/").filter(c=>c!==""),a=s.pop();if(a==null)continue;let i=n;for(const c of s){let d=i.dirs.get(c);d||(d=xw(),i.dirs.set(c,d)),i=d}i.files.set(a,r)}return G5(n,"")}const XM=new Set(["pnpm-lock.yaml","package-lock.json","npm-shrinkwrap.json","yarn.lock","bun.lockb","bun.lock","Cargo.lock","poetry.lock","uv.lock","Pipfile.lock","Gemfile.lock","composer.lock","go.sum","flake.lock","Package.resolved","gradle.lockfile","mix.lock","pubspec.lock","packages.lock.json"]);function Hx(e){const n=e.replace(/\\/g,"/"),r=n.slice(n.lastIndexOf("/")+1);return XM.has(r)||r.endsWith(".lockfile")}function bw(e){let n=e.trim();return n==="/dev/null"?null:(n.startsWith('"')&&n.endsWith('"')&&(n=n.slice(1,-1)),(n.startsWith("a/")||n.startsWith("b/"))&&(n=n.slice(2)),n)}function ZM(e){const n=/^diff --git a\/(.+) b\/(.+)$/.exec(e);return n?{oldPath:n[1]??null,newPath:n[2]??null}:{oldPath:null,newPath:null}}function UJ(e){if(!e)return[];const n=e.replace(/\n$/,"").split(`
44
+ `),r=n.length,s=[];let a=0;for(;a<r&&!(n[a]??"").startsWith("diff --git ");)a++;for(;a<r;){const i=ZM(n[a]??"");a++;let c="modified",d=null,u=null,m=null,h=null,g=!1;const x=[];let y=!1;for(;a<r;a++){const N=n[a]??"";if(N.startsWith("diff --git "))break;if(y){x.push(N);continue}N.startsWith("@@")?(y=!0,x.push(N)):N.startsWith("new file mode")?c="added":N.startsWith("deleted file mode")?c="removed":N.startsWith("rename from ")?(c="renamed",m=N.slice(12)):N.startsWith("rename to ")?(c="renamed",h=N.slice(10)):N.startsWith("copy from ")?(c="copied",m=N.slice(10)):N.startsWith("copy to ")?(c="copied",h=N.slice(8)):N.startsWith("Binary files ")||N.startsWith("GIT binary patch")?g=!0:N.startsWith("--- ")?d=bw(N.slice(4)):N.startsWith("+++ ")&&(u=bw(N.slice(4)))}const b=u||h||i.newPath||i.oldPath||d||"(unknown)",w=c==="renamed"||c==="copied"?m||d||i.oldPath:null;let k=0,j=0;for(const N of x)N.startsWith("+")&&!N.startsWith("+++")?k++:N.startsWith("-")&&!N.startsWith("---")&&j++;s.push({path:b,previousPath:w,status:c,additions:k,deletions:j,patch:g?null:x.join(`
45
+ `)})}return s}function JM(e){return e==null?null:e.creditsExhausted?e.generated>0?`AI credits exhausted — only ${e.generated} of the checks ran.`:"AI credits exhausted this month.":e.noAuth?"No AI credential is configured on the server.":e.requested-e.cached-e.skipped>0&&e.generated===0&&e.failed===0?"Nothing was produced — the server may have no AI credential configured.":e.failed>0?e.generated>0?`${e.generated} checked · ${e.failed} failed.`:`${e.failed} check${e.failed===1?"":"s"} failed.`:e.generated>0?null:e.cached>0?"Already up to date.":"Nothing here to check."}function V5(e){return["pr-annotations",e]}const zo=(e,n,r)=>`${e}|${n}|${r}`,e3=e=>{const n=new Map;for(const r of e.annotations)n.set(zo(r.kind,r.targetKind,r.targetId),r);return n};function Wp(e,n){return Oe({queryKey:V5(e),queryFn:()=>he.prAnnotations(e),enabled:e!=null&&n,staleTime:1/0,select:e3}).data}const oh=new Map,xf=new Set;function t3(e){return xf.add(e),()=>{xf.delete(e)}}function Q5(e,n){return`${e}|${n.targetKind}|${n.targetId}`}function vw(e,n){if(e.length!==0){for(const r of e){const s=(oh.get(r)??0)+n;s>0?oh.set(r,s):oh.delete(r)}for(const r of xf)r()}}function Y5(e,n){const r=e!=null&&n!=null?Q5(e,n):null;return f.useSyncExternalStore(t3,()=>r!=null&&oh.has(r))}const Xg={running:!1,result:null,error:null};function X5(e){const n=He(),[r,s]=f.useState(Xg),a=f.useRef(null);f.useEffect(()=>()=>{var c;return(c=a.current)==null?void 0:c.abort()},[]);const i=f.useCallback((c,d)=>{var h;(h=a.current)==null||h.abort();const u=new AbortController;a.current=u,s({...Xg,running:!0});const m=((d==null?void 0:d.targets)??[]).map(g=>Q5(e,g));vw(m,1),(async()=>{try{const g=await he.runPrAnnotations(e,{kind:c,...d},u.signal);s({running:!1,result:g,error:null})}catch(g){if((g==null?void 0:g.name)==="AbortError"){s(Xg);return}s({running:!1,result:null,error:(g==null?void 0:g.message)??"Failed"})}finally{n.invalidateQueries({queryKey:V5(e)}),vw(m,-1)}})()},[e,n]);return{state:r,run:i}}const n3={valid:{label:"Holds up",color:"#059669"},partly:{label:"Partly valid",color:"#d97706"},weak:{label:"Shaky",color:"#e11d48"},unclear:{label:"Unclear",color:"#94a3b8"}},r3={simplify:{label:"Simplified",title:"A shorter, faithful rewrite of this comment — the original is below, unchanged."},validity:{label:"Comment check",title:"A critical second opinion on whether this comment’s point holds up."},addressed:{label:"Addressed check",title:"Whether later changes actually dealt with this concern, and what is still open."},impact:{label:"Impact",title:"What this pull request could break, and what to look at first."}};function s3(e){if(e.verdict==null)return null;if(e.kind==="validity")return n3[e.verdict]??null;if(e.kind==="addressed"){const n=m_[e.verdict];return n==null?null:{label:e.confidence!=null?`${n.label} · ${e.confidence}%`:n.label,color:n.color}}return null}const a3={file_level:"this comment has no code anchor (it is file-level or PR-level)",not_in_snapshot:"GitHub returned only the first 50 review threads for this PR and this one fell outside them",lean_storage:"the anchored code was not stored and could not be re-fetched",rate_limited:"GitHub’s rate limit was hit before the anchored code could be fetched",saml_sso:"this token is not SSO-authorized for the repository’s organisation",unavailable:"the anchored code could not be fetched"};function o3(e){if(e==null||e.trim()==="")return null;try{const n=JSON.parse(e),r=d=>typeof n[d]=="string"?n[d]:null,s=r("baseSha"),a=r("headSha");if(s==null||a==null)return null;const i=n.outcome==="changed"||n.outcome==="untouched"?n.outcome:"unavailable",c=n.anchor;return{baseSha:s,headSha:a,path:r("path")??"",outcome:i,patch:r("patch"),previousPath:r("previousPath"),note:r("note"),anchor:c!=null&&typeof c.available=="boolean"?{available:c.available,reason:typeof c.reason=="string"?c.reason:null}:null}}catch{return null}}const kw=e=>e.slice(0,7);function i3(e,n=!1){return e.startsWith("@@")?"text-sky-700 dark:text-sky-400":e.startsWith("+")?n?"bg-emerald-50 dark:bg-emerald-950/40":"bg-emerald-50 text-emerald-800 dark:bg-emerald-950/40 dark:text-emerald-300":e.startsWith("-")?n?"bg-rose-50 dark:bg-rose-950/40":"bg-rose-50 text-rose-800 dark:bg-rose-950/40 dark:text-rose-300":"text-gray-600 dark:text-gray-400"}function l3({evidence:e}){var h;const n=e.outcome==="changed",r=e.anchor!=null&&!e.anchor.available,[s,a]=f.useState(!n||r),i=f.useMemo(()=>Bp(e.patch),[e.patch]),c=f.useMemo(()=>Ux(i,Yl(e.path)),[i,e.path]),u=e.baseSha!==""&&e.headSha!==""?`${kw(e.baseSha)}..${kw(e.headSha)}`:null,m=n?`· diff of ${u??"the change"}`:e.outcome==="untouched"?`· file unchanged in ${u??"that range"}`:"· no diff available";return t.jsxs("div",{className:"mt-2 border-t border-ai-hairline pt-1.5",children:[t.jsxs("button",{type:"button",onClick:g=>{g.stopPropagation(),a(x=>!x)},"aria-expanded":s,className:"flex items-center gap-1 text-[10px] font-medium text-ai-signal hover:underline",title:"The exact change this verdict was judged against, and the two commits it was taken between.",children:[t.jsx(Mt,{dir:s?"down":"right",size:10}),"Evidence",t.jsx("span",{className:"font-normal text-gray-400 dark:text-gray-500",children:m}),r&&t.jsx("span",{className:"font-normal text-amber-600 dark:text-amber-400",children:"· no anchored code"})]}),s&&t.jsxs("div",{className:"mt-1.5",children:[t.jsxs("div",{className:"text-[10px] text-gray-500 dark:text-gray-400",children:[e.path!==""&&t.jsx("span",{className:"font-mono",children:e.path}),e.previousPath!=null&&t.jsxs("span",{children:[" (renamed from ",t.jsx("span",{className:"font-mono",children:e.previousPath}),")"]})]}),e.outcome==="changed"&&e.patch!=null?t.jsx("div",{className:"mt-1 max-h-72 overflow-auto rounded border border-gray-200 bg-white dark:border-gray-700 dark:bg-gray-900",children:t.jsx("pre",{className:"w-max min-w-full text-[11px] leading-[1.35]",children:i.map((g,x)=>{const y=(c==null?void 0:c[x])??null;return t.jsx("div",{className:`px-2 font-mono whitespace-pre ${i3(g.text,y!=null)}`,children:y!=null?t.jsxs(t.Fragment,{children:[Ed(g).marker,t.jsx("span",{className:"code-hl",dangerouslySetInnerHTML:{__html:y}})]}):g.text===""?" ":g.text},x)})})}):t.jsxs("div",{className:"mt-1 text-[11px] text-gray-600 dark:text-gray-300",children:[e.outcome==="untouched"?"The file was not modified between those two commits.":"No diff could be fetched for this range, so the verdict above rests on the deterministic signals alone.",e.note!=null&&t.jsxs("span",{className:"text-gray-400 dark:text-gray-500",children:[" (",e.note,")"]})]}),e.outcome==="changed"&&e.note!=null&&t.jsx("div",{className:"mt-1 text-[10px] text-gray-400 dark:text-gray-500",children:e.note}),r&&t.jsxs("div",{className:"mt-1 text-[11px] text-amber-700 dark:text-amber-400",children:["The code this comment was written against wasn’t available to the check —"," ",(((h=e.anchor)==null?void 0:h.reason)!=null?a3[e.anchor.reason]:null)??"it could not be fetched",". The verdict rests on the thread’s own wording and the signals above."]})]})]})}function c3(){return t.jsx("div",{className:"mt-1.5 space-y-1.5 py-0.5","aria-hidden":"true",children:["88%","72%","54%"].map((e,n)=>t.jsx("div",{className:"digest-skeleton-line h-2.5",style:{width:e}},n))})}function d3(){return t.jsx("span",{className:"rounded-full border border-amber-300 px-1.5 py-0.5 text-[10px] font-medium text-amber-700 dark:border-amber-700 dark:text-amber-300",title:"This comment (or the code around it) changed after the check ran, so the result may no longer hold. Press “Check review” on this thread or comment again to refresh it.",children:"may be out of date"})}function ih({annotation:e,defaultOpen:n,sublabel:r,metaOverride:s,busy:a=!1}){const[i,c]=f.useState(n),d=s??r3[e.kind],u=s3(e),m=e.kind==="addressed"?o3(e.evidence):null;return t.jsxs("div",{className:"mt-2 rounded-md border border-ai-border bg-ai-surface px-2.5 py-1.5","aria-busy":a,children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsxs("button",{type:"button",onClick:h=>{h.stopPropagation(),c(g=>!g)},"aria-expanded":i,className:"flex items-center gap-1 text-[11px] font-semibold text-ai-signal hover:underline",title:d.title,children:[t.jsx(Mt,{dir:i?"down":"right",size:10}),t.jsx(Ps,{size:11}),d.label]}),!a&&u!=null&&t.jsx("span",{className:"rounded-full px-1.5 py-0.5 text-[10px] font-semibold",style:{backgroundColor:`${u.color}1a`,color:u.color},children:u.label}),!a&&e.stale&&t.jsx(d3,{}),r!=null&&t.jsx("span",{className:"text-[10px] text-ai-muted",children:r})]}),i&&(a?t.jsx(c3,{}):t.jsxs("div",{className:"prose-thread mt-1.5 text-[12px] text-gray-700 dark:text-gray-200",children:[t.jsx(gr,{children:e.body}),m!=null&&t.jsx(l3,{evidence:m}),t.jsxs("div",{className:"mt-1 text-[10px] text-gray-400",children:[e.kind==="simplify"?"AI rewrite — the original comment is shown below, unchanged.":"AI judgement — a critical read, your call."," ",new Date(e.createdAt).toLocaleString()]})]}))]})}function Z5({prId:e,targetKind:n,targetId:r,kinds:s}){const a=vt().prSummary,i=Wp(e,a),c=Y5(e,{targetKind:n,targetId:r});if(!a||i==null)return null;const u=(s??["simplify","validity","addressed"]).map(m=>i.get(zo(m,n,r))).filter(m=>m!=null);return u.length===0?null:t.jsx(t.Fragment,{children:u.map(m=>t.jsx(ih,{annotation:m,busy:c,defaultOpen:!0},m.kind))})}function u3({thread:e,usersById:n}){const r=vt().prSummary,s=Wp(e.prId,r),a=Y5(e.prId,{targetKind:"thread",targetId:e.id});if(!r||s==null)return null;const i=e.comments[0],c=e.comments.flatMap((m,h)=>{const g=s.get(zo("simplify","review_comment",m.id));if(g==null)return[];const x=m.authorId!=null?n==null?void 0:n.get(m.authorId):void 0,y=h===0?"opening comment":`reply ${h}`,b=x!=null?`${Dt(x,m.authorId)}’s ${y}`:y;return[{annotation:g,sublabel:b}]}),d=i!=null?s.get(zo("validity","review_comment",i.id))??null:null,u=s.get(zo("addressed","thread",e.id))??null;return c.length===0&&d==null&&u==null?null:t.jsxs(t.Fragment,{children:[c.map(m=>t.jsx(ih,{annotation:m.annotation,sublabel:m.sublabel,defaultOpen:!0,busy:a},`simplify:${m.annotation.targetId}`)),d!=null&&t.jsx(ih,{annotation:d,defaultOpen:!0,busy:a}),u!=null&&t.jsx(ih,{annotation:u,defaultOpen:!0,busy:a,metaOverride:e.isResolved?{label:"Resolution check",title:"This thread is resolved. Whether the code actually backs that up — and what, if anything, is still open."}:void 0})]})}const h3="One AI pass over this thread or comment: rewrite the wall of bot text, sanity-check the point, and judge what has actually been addressed (Pro)";function zx({prId:e,target:n,className:r=""}){const s=vt().prSummary,{state:a,run:i}=X5(e);if(!s)return null;const c=a.error??JM(a.result);return t.jsxs("span",{className:`inline-flex items-center gap-1 ${r}`,children:[t.jsx("button",{type:"button",onClick:d=>{d.stopPropagation(),i("review",{targets:[n]})},disabled:a.running,className:"rounded px-1 py-0.5 text-[10px] font-medium text-ai-signal hover:bg-ai-signal/10 disabled:opacity-50",title:h3,children:a.running?"Checking…":t.jsxs(t.Fragment,{children:[t.jsx(Ps,{size:10,className:"inline-block align-[-0.1em]"})," Check review"]})}),c!=null&&t.jsx("span",{className:"text-[10px] text-amber-600 dark:text-amber-400",children:c})]})}function p3(e){const n=e.vendorSeverity;return n==null||n===e.severity?null:Tl[n]>Tl[e.severity]?"over":"under"}function m3(e,n,r){var s;return((s=e.cells.find(a=>a.vendor===n&&a.ours===r))==null?void 0:s.count)??0}function Ya(e){return e.label?e.label:e.userIds.length===1?"1 bot":`${e.userIds.length} bots`}function Kx(e,n){const r=g3(e);if(!n)return r;const s=n.label?`${n.label}’s own comments`:n.userIds.length===1?"this bot’s comments":`these ${n.userIds.length} bots’ comments`;return{title:`${r.title} — ${Ya(n)}`,subtitle:`${r.subtitle} Narrowed to ${s} — the grid above still describes every bot.`}}function g3(e){switch(e.kind){case"findings":return{title:"Findings",subtitle:"Scored bot comments that raise something — walkthroughs and praise excluded."};case"summaries":return{title:"Walkthroughs & summaries",subtitle:"The PR-level summaries bots post. Scored, but never counted as findings — a walkthrough rated major must not outrank real ones."};case"severity":{const n=new Set(e.severities),r=n.size===2&&n.has("major")&&n.has("critical"),s=n.size===1&&n.has("nit"),a=hp.filter(i=>n.has(i)).map(i=>Ht[i].label).join(" or ");return r?{title:"High severity",subtitle:"Findings the model rated major or critical. The two are read together — CRITICAL alone is the class it under-recalls."}:s?{title:"Nits",subtitle:"Findings the model rated trivial or optional."}:{title:a||"Severity",subtitle:a?`Findings the model rated ${a}.`:"Findings by severity."}}case"category":return{title:Xa[e.category]??e.category,subtitle:`Findings the model tagged ${Xa[e.category]??e.category}. Categories are multi-label, so a finding can appear under more than one.`};case"overlap":return{title:"Same-line overlap",subtitle:"Line areas two or more review bots both flagged (within ±3 lines of each other in the same file). Measured from the threads themselves — not model-scored."}}}function f3(e){return[...new Set(e)].sort()}function x3(e){switch(e.kind){case"findings":return"findings";case"summaries":return"summaries";case"severity":return`severity:${f3(e.severities).join(",")}`;case"category":return`category:${e.category}`;case"overlap":return"overlap"}}function y3(e){const n=e.cell?`${e.cell.vendor}>${e.cell.ours}`:"-",r=e.authorUserIds?`[${[...e.authorUserIds].sort((s,a)=>s-a).join(",")}]`:"-";return`cell:${n}|dis:${e.disagree??"-"}|bot:${r}`}const ww=["high","critical","major","minor","nit","praise"];function jw(e){return e==="high"?{kind:"severity",severities:["major","critical"]}:e==="praise"?{kind:"category",category:"praise"}:{kind:"severity",severities:[e]}}function J5(e){if(e.kind==="category")return e.category==="praise"?"praise":null;if(e.kind!=="severity")return null;const n=new Set(e.severities);return n.size===2&&n.has("major")&&n.has("critical")?"high":n.size===1?[...n][0]??null:null}function b3(e){return J5(e)!==null}function v3(e){return e.kind==="category"&&e.category!=="praise"}const Nw=I$.filter(e=>e!=="praise"),k3=.25,w3=.5;function cc({label:e,compact:n,vendorClaim:r}){if(!e)return null;const s=Ht[e.severity],i=e.categories.slice(0,2).map(k=>Xa[k]??k).join(" · "),c=Math.round(e.severityProb*100),d=e.backend.includes("modernbert-onnx"),u=d?"":`
46
+ Heuristic fallback — the ML model was not loaded on the server.`,m=d&&e.severityProb<k3,h=e.severityProb<w3,g=!n&&e.vendorSeverity&&e.vendorSeverity!==e.severity?Ht[e.vendorSeverity]:null,x=g?p3(e):null,y=r&&!n&&!g?e.vendorSeverity==null?{text:"bot declared nothing",title:"This bot posted no severity badge of its own, so there is nothing here to agree or disagree with — the matrix’s ‘none’ column. Silence is not agreement, which is why the two are counted apart."}:{text:"bot agreed",title:`The bot badged this ${s.label} itself — the matrix’s diagonal. Said out loud here because on this screen agreement is a finding of its own; on an ordinary comment the badge stays quiet about it.`}:null,b=e.vendorSeverityConfidence&&e.vendorSeverityConfidence!=="high"?` (a ${e.vendorSeverityConfidence}-confidence read of its own markup)`:"",w=`${s.label}: ${s.description}
47
+ Confidence ${c}%. Category: ${e.categories.map(k=>Xa[k]??k).join(", ")||"none"}.`+(m?`
48
+ The model did not pick this label — a four-class score is never under 25%, so ${c}% means the serving-side calibration overrode the model's own choice.`:h?`
49
+ Dimmed: under 50% confidence, where this label is materially less reliable.`:"")+(g?`
50
+ The bot badged this ${g.label} itself${b}. Ours is the more accurate rating — 70% agreement with human adjudication on a held-out sample, against the bot's 47%.`:"")+(e.isSummary?`
51
+ This is a PR walkthrough/summary, not a specific finding.`:"")+u;return t.jsxs("span",{className:"inline-flex items-center gap-1",title:w,children:[t.jsxs("span",{className:`inline-flex items-center gap-1 rounded-full px-1.5 py-0.5 text-[10px] font-semibold${h?" opacity-70":""}`,style:{backgroundColor:`${s.color}1a`,...pn(s.color)},children:[t.jsx("span",{className:"inline-block h-1.5 w-1.5 rounded-full",style:m?{boxShadow:`inset 0 0 0 1px ${s.color}`}:{backgroundColor:s.color}}),s.label]}),g&&t.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] font-medium text-gray-400 dark:text-gray-500",title:r&&x!=null?`The bot badged this ${g.label}; our model rated it ${s.label}. The direction is the two severity ordinals — not anyone's confidence. Ours is the more accurate rating (70% agreement with human adjudication against the bot's 47%), so this is a disagreement to look at, not one to resolve.`:void 0,children:[r&&x!=null&&t.jsx(_s,{dir:x==="over"?"up":"down",size:10}),t.jsx("span",{children:"bot said"}),t.jsx("span",{className:"font-semibold",style:pn(g.color),children:g.label}),r&&x!=null&&t.jsxs("span",{className:"opacity-80",children:["· ",x==="over"?"worse":"milder"]})]}),y&&t.jsx("span",{className:"text-[10px] text-gray-400 dark:text-gray-500",title:y.title,children:y.text}),!n&&i&&t.jsx("span",{className:"rounded bg-gray-100 px-1 py-0.5 text-[10px] font-medium uppercase tracking-wide text-gray-500 dark:bg-gray-800 dark:text-gray-400",children:i}),!n&&e.isSummary&&t.jsx("span",{className:"text-[10px] font-medium text-gray-400 dark:text-gray-500",title:"A PR walkthrough/summary comment rather than a specific finding.",children:"summary"})]})}function j3(e){let n;for(const r of e)r.isSummary||(!n||r.severityOrd>n.severityOrd)&&(n=r);return n}const N3=["critical","major","minor","nit"];function S3({counts:e,total:n}){return n===0?t.jsx("div",{className:"h-2 w-full rounded-full bg-gray-100 dark:bg-gray-800"}):t.jsx("div",{className:"flex h-2 w-full overflow-hidden rounded-full bg-gray-100 dark:bg-gray-800",children:N3.map(r=>{const s=e[r];if(s===0)return null;const a=Ht[r];return t.jsx("div",{style:{width:`${s/n*100}%`,backgroundColor:a.color},title:`${a.label}: ${s}`},r)})})}const e2=f.createContext(null);function zh({prId:e,at:n,event:r,title:s="Show this on the timeline",label:a,className:i=""}){const c=G(g=>g.showEventOnTimeline),d=G(g=>g.focusEventInTab),u=Ge(g=>g.openPrFocusTab),m=f.useContext(e2),h=()=>{if(m!=null&&m.id===e){const g=r.type==="review_comment"?r.refId:null;u(m),d(e,n,r,g)}else c(e,n,r)};return a!=null?t.jsx("button",{type:"button",onClick:h,className:`shrink-0 text-blue-500 hover:underline ${i}`,title:s,children:a}):t.jsx("button",{type:"button",onClick:h,className:`shrink-0 rounded p-0.5 text-blue-500 hover:text-blue-600 ${i}`,title:s,"aria-label":s,children:t.jsx(eo,{size:13})})}const C3=1600;async function R3(e){var n;try{if((n=navigator.clipboard)!=null&&n.writeText)return await navigator.clipboard.writeText(e),!0}catch{}try{const r=document.createElement("textarea");r.value=e,r.setAttribute("readonly",""),r.style.position="fixed",r.style.top="-1000px",r.style.opacity="0",document.body.appendChild(r),r.select();const s=document.execCommand("copy");return document.body.removeChild(r),s}catch{return!1}}function Bi({text:e,what:n="comment",title:r,className:s=""}){const[a,i]=f.useState("idle"),c=f.useRef(null);f.useEffect(()=>()=>{c.current&&clearTimeout(c.current)},[]);const d=f.useCallback(m=>{m.preventDefault(),m.stopPropagation(),R3(e).then(h=>{i(h?"copied":"failed"),c.current&&clearTimeout(c.current),c.current=setTimeout(()=>i("idle"),C3)})},[e]);if(e.trim()==="")return null;const u=a==="copied"?"Copied":a==="failed"?"Copy failed":`Copy ${n}`;return t.jsxs("button",{type:"button",onClick:d,title:a==="idle"?r??`Copy this ${n}'s text to the clipboard, exactly as written`:u,"aria-label":u,className:`inline-flex shrink-0 items-center gap-1 rounded px-1 py-0.5 text-[11px] font-medium transition-colors ${a==="copied"?"text-emerald-600 dark:text-emerald-400":a==="failed"?"text-amber-600 dark:text-amber-400":"text-gray-400 hover:bg-gray-100 hover:text-gray-600 dark:hover:bg-gray-800 dark:hover:text-gray-200"} ${s}`,children:[a==="copied"?t.jsx(pr,{}):t.jsx(s_,{}),a!=="idle"&&t.jsx("span",{children:u})]})}function t2(e,n){return["reactions",e,n]}function n2(e,n){return["reaction-toggle",e,n]}const yf=(e,n)=>`${e}:${n}`,bf=60,I3=5*6e4,T3=3e4,Ol=new Map;let vf=!1;async function $3(e){try{const n=await he.reactionLookup({targets:e.map(s=>s.target)}),r=new Map;for(const s of n.results)r.set(yf(s.kind,s.id),s);for(const s of e){const a=r.get(yf(s.target.kind,s.target.id))??null;for(const i of s.waiters)i.resolve(a)}}catch(n){for(const r of e)for(const s of r.waiters)s.reject(n)}}function Sw(){if(vf=!1,Ol.size===0)return;const e=[...Ol.values()];Ol.clear();for(let n=0;n<e.length;n+=bf)$3(e.slice(n,n+bf))}function _3(e){return new Promise((n,r)=>{const s=yf(e.kind,e.id),a=Ol.get(s);if(a){a.waiters.push({resolve:n,reject:r});return}if(Ol.set(s,{target:e,waiters:[{resolve:n,reject:r}]}),Ol.size>=bf){Sw();return}vf||(vf=!0,queueMicrotask(Sw))})}function P3(e,n){return Oe({queryKey:t2(e,n),queryFn:()=>_3({kind:e,id:n}),staleTime:s=>s.state.data==null?T3:I3,retry:!1}).data??void 0}function E3(e,n){return Or({mutationKey:n2(e,n)})>0}function A3(e,n,r){const s=e.groups.filter(i=>i.content!==n),a=e.groups.find(i=>i.content===n);if(r){const i=(a==null?void 0:a.viewerHasReacted)===!0;s.push({content:n,count:((a==null?void 0:a.count)??0)+(i?0:1),viewerHasReacted:!0})}else if(a){const i=a.viewerHasReacted?a.count-1:a.count;i>0&&s.push({content:n,count:i,viewerHasReacted:!1})}return s.sort((i,c)=>Y0.indexOf(i.content)-Y0.indexOf(c.content)),{...e,groups:s}}function M3(e,n){const r=He(),s=t2(e,n);return tt({mutationKey:n2(e,n),mutationFn:a=>he.setReaction({kind:e,id:n,content:a.content,add:a.add}),onMutate:async a=>{await r.cancelQueries({queryKey:s});const i=r.getQueryData(s);return i&&r.setQueryData(s,A3(i,a.content,a.add)),{prev:i}},onError:(a,i,c)=>{c&&r.setQueryData(s,c.prev??null),r.invalidateQueries({queryKey:s})},onSuccess:a=>{r.setQueryData(s,a)}})}const Zg={thumbs_up:"Thumbs up",thumbs_down:"Thumbs down",laugh:"Laugh",hooray:"Hooray",confused:"Confused",heart:"Heart",rocket:"Rocket",eyes:"Eyes"};function r2({kind:e,id:n,className:r}){const s=P3(e,n),a=E3(e,n),i=M3(e,n),c=f.useRef(null),[d,u]=f.useState(!1);if(Yr(c,()=>u(!1),d),!s)return null;const m=s.groups;if(m.length===0&&!s.viewerCanReact)return null;const h=(g,x)=>{u(!1),i.mutate({content:g,add:x})};return t.jsxs("div",{ref:c,className:`relative flex flex-wrap items-center gap-1${r?` ${r}`:""}`,"data-noactivate":!0,children:[m.map(g=>{const x=Zg[g.content];return t.jsxs("button",{type:"button",disabled:a||!s.viewerCanReact,"aria-pressed":g.viewerHasReacted,title:s.viewerCanReact?`${x} · ${g.count}${g.viewerHasReacted?" — click to remove yours":""}`:`${x} · ${g.count}`,onClick:y=>{y.stopPropagation(),h(g.content,!g.viewerHasReacted)},className:`inline-flex items-center gap-1 rounded-full border px-1.5 py-0.5 text-[11px] leading-none transition-colors disabled:opacity-60 ${g.viewerHasReacted?"border-blue-400 bg-blue-50 text-blue-700 dark:border-blue-500 dark:bg-blue-950/40 dark:text-blue-300":"border-gray-200 text-gray-500 hover:border-gray-300 dark:border-gray-800 dark:text-gray-400 dark:hover:border-gray-700"}`,children:[t.jsx("span",{"aria-hidden":!0,children:hk[g.content]}),t.jsx("span",{className:"tabular-nums",children:g.count})]},g.content)}),s.viewerCanReact&&t.jsxs("button",{type:"button",disabled:a,"aria-haspopup":"menu","aria-expanded":d,title:"Add a reaction",onClick:g=>{g.stopPropagation(),u(x=>!x)},className:`inline-flex items-center gap-0.5 rounded-full border border-dashed px-1.5 py-1 text-[11px] leading-none transition-opacity disabled:opacity-40 ${m.length===0?"opacity-40 hover:opacity-100":""} border-gray-300 text-gray-400 hover:text-gray-600 dark:border-gray-700 dark:text-gray-500 dark:hover:text-gray-200`,children:[t.jsx(n_,{}),t.jsx("span",{"aria-hidden":!0,children:"+"})]}),d&&t.jsx("div",{role:"menu",onKeyDown:g=>{g.key==="Escape"&&(g.stopPropagation(),u(!1))},className:"absolute bottom-full left-0 z-30 mb-1 flex gap-0.5 rounded-md border border-gray-200 bg-white p-1 shadow-lg dark:border-gray-700 dark:bg-gray-900",children:Y0.map(g=>{var y;const x=((y=m.find(b=>b.content===g))==null?void 0:y.viewerHasReacted)===!0;return t.jsx("button",{type:"button",role:"menuitem",title:x?`Remove ${Zg[g]}`:Zg[g],onClick:b=>{b.stopPropagation(),h(g,!x)},className:`rounded px-1 py-0.5 text-sm leading-none hover:bg-gray-100 dark:hover:bg-gray-800 ${x?"bg-blue-50 dark:bg-blue-950/40":""}`,children:t.jsx("span",{"aria-hidden":!0,children:hk[g]})},g)})})]})}function s2(){return t.jsx("span",{className:"rounded bg-sky-500/20 px-1 text-[10px] font-semibold uppercase text-sky-500",children:"new"})}function a2(e,n){return n?Date.parse(e)>Date.parse(n):!1}function L3({comment:e,usersById:n,repoId:r,isNew:s,anchor:a,showLink:i,mlLabel:c}){const d=e.authorId!=null?n.get(e.authorId):void 0;return t.jsxs("div",{className:`pl-2 ${s?"comment-new":""}`,children:[t.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[i&&t.jsxs(t.Fragment,{children:[i,t.jsx("span",{className:"decorative-mark text-gray-300 dark:text-gray-600",children:"·"})]}),t.jsx(gn,{user:d,size:18}),t.jsx(mr,{user:d,fallbackId:e.authorId,repoId:r,className:"font-semibold"}),t.jsx("span",{className:"text-gray-400",children:Nt(e.createdAt)}),s&&t.jsx(s2,{}),t.jsx(cc,{label:c}),t.jsx(Bi,{text:e.body,className:"ml-auto"})]}),a&&t.jsx("div",{className:"mt-1.5",children:a}),t.jsx("div",{className:"mt-1 text-sm",children:t.jsx(gr,{children:e.body})}),t.jsx(r2,{kind:"review_comment",id:e.id,className:"mt-1.5"})]})}function kf(e){return e.startsWith("@@")?"meta":e.startsWith("+")?"add":e.startsWith("-")?"del":"ctx"}const F3={add:"add",del:"del",meta:"hunk",ctx:"context"},O3={add:"bg-green-500/10 dark:bg-green-500/15",del:"bg-red-500/10 dark:bg-red-500/15",meta:"bg-sky-500/5 dark:bg-transparent",ctx:""},D3={add:"text-green-700 dark:text-green-300",del:"text-red-700 dark:text-red-300",meta:"text-sky-600 dark:text-sky-400",ctx:"text-gray-600 dark:text-gray-400"};function Cw(e,n){const r=n&&(e==="add"||e==="del")?"":D3[e];return`${O3[e]} ${r}`}function Gx(e,n){return f.useMemo(()=>{if(!e||n==null||n==="")return null;const r=e.replace(/\n$/,"").split(`
52
+ `).length,s=Ux(Bp(e),Yl(n));return s!=null&&s.length===r?s:null},[e,n])}function Vx(e){return Ed({kind:F3[kf(e)],text:e}).marker}function B3({hunk:e,path:n,onCollapse:r}){const s=Gx(e,n);if(!e)return null;const a=e.replace(/\n$/,"").split(`
53
+ `),i=r!=null&&kf(a[0]??"")==="meta"?r:null;return t.jsx("pre",{className:"overflow-x-auto rounded-md border border-gray-200 bg-gray-50 text-[12px] leading-[1.45] dark:border-gray-800 dark:bg-gray-900",children:t.jsx("code",{className:"block w-max min-w-full font-mono",children:a.map((c,d)=>{const u=kf(c),m=(s==null?void 0:s[d])??null;return d===0&&i!=null?t.jsx("button",{type:"button",onClick:()=>{var h;((h=window.getSelection())==null?void 0:h.isCollapsed)!==!1&&i()},"aria-expanded":!0,"aria-label":"Hide code context",title:"Hide code context",className:`block w-full whitespace-pre px-3 text-left hover:bg-sky-500/15 dark:hover:bg-sky-500/10 ${Cw(u,!1)}`,children:c||" "},d):t.jsx("span",{className:`block whitespace-pre px-3 ${Cw(u,m!=null)}`,children:m!=null?t.jsxs(t.Fragment,{children:[Vx(c),t.jsx("span",{className:"code-hl",dangerouslySetInnerHTML:{__html:m}})]}):c||" "},d)})})})}function W3(e){return e.startsWith("+")?"add":e.startsWith("-")?"del":"ctx"}const Rw={add:"border-green-500",del:"border-red-500",ctx:"border-gray-400"},q3={add:"text-green-600 dark:text-green-300",del:"text-red-600 dark:text-red-300",ctx:"text-gray-600 dark:text-gray-300"};function U3({diffHunk:e,path:n,threadId:r}){const s=G(x=>x.expandedDiffHunks.includes(r)),a=G(x=>x.toggleDiffHunk),i=Gx(e,n);if(!e)return null;const c=e.replace(/\n$/,"").split(`
54
+ `),d=c.at(-1)??"",u=W3(d),m=(i==null?void 0:i.at(-1))??null;if(s)return t.jsxs("div",{className:"space-y-1",children:[t.jsx(B3,{hunk:e,path:n,onCollapse:()=>a(r)}),t.jsxs("button",{type:"button",onClick:()=>a(r),"aria-expanded":!0,className:"inline-flex items-center gap-1 text-[11px] text-gray-400 hover:text-gray-600 dark:hover:text-gray-300",children:[t.jsx(Mt,{dir:"up",size:11}),"Hide code context"]})]});const h=m!=null?t.jsxs(t.Fragment,{children:[Vx(d),t.jsx("span",{className:"code-hl",dangerouslySetInnerHTML:{__html:m}})]}):d||" ",g=m!=null&&u!=="ctx"?"":q3[u];return c.length<=1?t.jsx("pre",{className:`overflow-x-auto border-l-2 bg-gray-50 py-0.5 pl-2 font-mono text-[12px] leading-snug dark:bg-gray-900/60 ${Rw[u]} ${g}`,children:h}):t.jsxs("button",{type:"button",onClick:()=>a(r),"aria-expanded":!1,title:"Show the full code context",className:`flex w-full items-center gap-2 overflow-hidden rounded-r border-l-2 bg-gray-50 py-0.5 pl-2 pr-2 text-left font-mono text-[12px] leading-snug hover:bg-gray-100 dark:bg-gray-900/60 dark:hover:bg-gray-800/60 ${Rw[u]} ${g}`,children:[t.jsx("span",{className:"min-w-0 flex-1 truncate",children:h}),t.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 font-sans text-[10px] text-gray-400",children:[t.jsx(Mt,{dir:"down",size:10}),c.length," lines"]})]})}function H3({prId:e,threadId:n,isResolved:r}){const s=YP(),a=s.error instanceof cn?s.error.message:s.error?"Failed to update the thread.":null;return t.jsxs("span",{className:"flex items-center gap-1.5",children:[a&&t.jsx("span",{className:"text-[10px] text-red-500",children:a}),t.jsx("button",{type:"button",onClick:()=>s.mutate({prId:e,threadId:n,resolved:!r}),disabled:s.isPending,title:r?"Reopen this thread on GitHub":"Mark this thread resolved on GitHub",className:"rounded border border-gray-300 px-1.5 py-0.5 text-[10px] font-semibold text-gray-600 hover:border-gray-400 disabled:opacity-50 dark:border-gray-700 dark:text-gray-300 dark:hover:border-gray-500",children:r?"Unresolve":"Resolve"})]})}const z3=8;function Iw(e,n){let r=n-1;for(;r>=0;){const s=e[r];if(s==="@"){const a=r>0?e[r-1]:"";if(r===0||/[\s(]/.test(a)){const i=e.slice(r+1,n);if(/^[A-Za-z0-9-]*$/.test(i))return{query:i,start:r}}return null}if(/\s/.test(s))return null;r-=1}return null}function K3(e,n){var s;if(n==="")return!0;const r=n.toLowerCase();return e.githubLogin.toLowerCase().includes(r)||(((s=e.displayName)==null?void 0:s.toLowerCase().includes(r))??!1)}function G3(e,n,r=z3){const s=e.filter(c=>K3(c,n)),a=s.filter(c=>c.isMaintainer),i=s.filter(c=>!c.isMaintainer);return[...a,...i].slice(0,r)}const V3=new Set(["ArrowDown","ArrowUp","Enter","Tab","Escape"]);function Ad({prId:e,candidates:n,value:r,onChange:s,rows:a=3,placeholder:i,autoFocus:c,disabled:d,className:u,ariaLabel:m,onKeyDown:h,onBlur:g}){const x=f.useRef(null),{data:y}=mP(e??null),b=n??y,[w,k]=f.useState(0),[j,N]=f.useState(!1),[I,S]=f.useState(0),T=f.useRef(null);f.useLayoutEffect(()=>{if(T.current!=null&&x.current){const D=T.current;x.current.setSelectionRange(D,D),T.current=null}});const $=j?Iw(r,w):null,P=f.useMemo(()=>$==null||!b?[]:G3(b,$.query),[$,b]);f.useEffect(()=>{S(D=>D>=P.length?0:D)},[P.length]);const C=j&&$!=null&&P.length>0,L=()=>{const D=x.current;D&&k(D.selectionStart??0)},F=D=>{const A=Iw(r,w);if(!A)return;let W=w;for(;W<r.length&&/[A-Za-z0-9-]/.test(r[W]);)W+=1;const z=r.slice(0,A.start),te=r.slice(W),H=`@${D.githubLogin} `;T.current=z.length+H.length,k(z.length+H.length),N(!1),s(z+H+te)},M=D=>{if(C&&V3.has(D.key)){if(D.key==="ArrowDown")D.preventDefault(),S(A=>(A+1)%P.length);else if(D.key==="ArrowUp")D.preventDefault(),S(A=>(A-1+P.length)%P.length);else if(D.key==="Enter"||D.key==="Tab"){D.preventDefault();const A=P[I]??P[0];A&&F(A)}else D.key==="Escape"&&(D.preventDefault(),N(!1));return}h==null||h(D)};return t.jsxs("div",{className:"relative",children:[t.jsx("textarea",{ref:x,value:r,rows:a,placeholder:i,autoFocus:c,disabled:d,"aria-label":m,className:u,onChange:D=>{s(D.target.value),k(D.target.selectionStart??D.target.value.length),N(!0)},onKeyDown:M,onKeyUp:L,onClick:()=>{L(),N(!0)},onBlur:D=>{window.setTimeout(()=>N(!1),120),g==null||g(D)}}),C&&t.jsx("ul",{role:"listbox",className:"absolute left-0 right-0 z-30 mt-0.5 max-h-56 overflow-auto rounded-md border border-gray-200 bg-white py-1 shadow-lg dark:border-gray-700 dark:bg-gray-900",children:P.map((D,A)=>t.jsx("li",{children:t.jsxs("button",{type:"button",role:"option","aria-selected":A===I,onMouseDown:W=>{W.preventDefault(),F(D)},onMouseEnter:()=>S(A),className:`flex w-full items-center gap-2 px-2 py-1 text-left text-xs ${A===I?"bg-sky-50 dark:bg-sky-950/40":"hover:bg-gray-50 dark:hover:bg-gray-800/60"}`,children:[t.jsx(gn,{user:D,size:18}),t.jsxs("span",{className:"font-medium text-gray-800 dark:text-gray-100",children:["@",D.githubLogin]}),D.isMaintainer&&t.jsx($p,{title:"Maintainer — has merged a PR here"}),D.displayName&&t.jsx("span",{className:"truncate text-gray-400",children:D.displayName})]})},D.id))})]})}function Q3({prId:e,threadId:n}){const[r,s]=f.useState(!1),[a,i]=f.useState(""),c=QP(),d=c.error instanceof cn?c.error.message:c.error?"Failed to post the reply.":null,u=()=>{const m=a.trim();!m||c.isPending||c.mutate({prId:e,threadId:n,body:m},{onSuccess:()=>{i(""),s(!1)}})};return r?t.jsxs("div",{className:"space-y-1",children:[t.jsx(Ad,{prId:e,value:a,onChange:i,rows:3,autoFocus:!0,placeholder:"Reply to this thread (markdown, @ to mention)…",className:"w-full rounded border border-gray-300 bg-white px-2 py-1.5 text-xs dark:border-gray-700 dark:bg-gray-900"}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("button",{type:"button",onClick:u,disabled:c.isPending||a.trim().length===0,className:"whitespace-nowrap rounded border border-blue-400 px-2 py-0.5 text-xs text-blue-600 hover:bg-blue-50 disabled:opacity-50 dark:border-blue-600 dark:text-blue-400 dark:hover:bg-blue-900/30",children:c.isPending?"Sending…":"Send"}),t.jsx("button",{type:"button",onClick:()=>{s(!1),i(""),c.reset()},disabled:c.isPending,className:"whitespace-nowrap rounded border border-gray-300 px-2 py-0.5 text-xs hover:border-gray-400 disabled:opacity-50 dark:border-gray-700 dark:hover:border-gray-500",children:"Cancel"}),d&&t.jsx("span",{className:"text-[10px] text-red-500",children:d})]})]}):t.jsx("button",{type:"button",onClick:()=>s(!0),className:"text-blue-500 hover:underline",children:"Reply"})}function Li({thread:e,usersById:n,prUrl:r,repoId:s,selected:a,viewedSince:i,highlightCommentId:c,onOpenInPr:d,openInChanges:u,onOpenInThreads:m}){var w;const h=((w=e.comments[0])==null?void 0:w.diffHunk)??null,g=e.line!=null?`line ${e.line}`:"file-level",x=ba(),y=Ip(e.prId,x),b=y&&e.comments.length>1?j3(e.comments.map(k=>y.get(gd("review_comment",k.id))).filter(k=>k!=null)):void 0;return t.jsxs("div",{className:`rounded-md border px-2.5 py-2 ${a?"border-amber-400 bg-amber-400/5":"border-gray-200 dark:border-gray-800"}`,children:[t.jsxs("div",{className:`mb-2 flex items-center gap-2 text-[11px] text-gray-400${d?" -mx-1 cursor-pointer rounded px-1 hover:bg-sky-50 dark:hover:bg-sky-950/20":""}`,role:d?"button":void 0,tabIndex:d?0:void 0,title:d?"Open this thread in its PR":void 0,onClick:d?k=>{k.target.closest("a,button,input,textarea,[data-noactivate]")||d()}:void 0,onKeyDown:d?k=>{k.target===k.currentTarget&&(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),d())}:void 0,children:[t.jsx(Wx,{state:e.derivedState}),e.derivedState==="likely_addressed"&&t.jsx(IM,{confidence:e.addressedConfidence,reason:e.addressedReason}),t.jsx(cc,{label:b,compact:!0}),t.jsx(zh,{prId:e.prId,at:e.createdAt,event:{type:"review_comment",refId:e.id},title:"Show this thread on the timeline"}),t.jsx("span",{className:"decorative-mark text-gray-300 dark:text-gray-600",children:"·"}),t.jsx("span",{className:d?"font-medium text-gray-500 underline decoration-dotted underline-offset-2 dark:text-gray-400":void 0,children:g}),e.isOutdated&&t.jsx("span",{children:"· outdated"}),u!=null&&t.jsxs("button",{type:"button",onClick:k=>{k.stopPropagation(),u.run()},className:"shrink-0 rounded px-1 py-0.5 text-[10px] font-medium text-blue-500 hover:bg-blue-50 hover:text-blue-600 dark:hover:bg-blue-950/40",title:u.line==null?"Show this file in the Changes tab — this thread’s line is no longer in the diff":u.approximate?`Show line ~${u.line} in the Changes tab (approximate: this thread’s anchor is outdated, so the line is reconstructed from the code it was written against)`:`Show line ${u.line} in the Changes tab`,children:[t.jsx(_s,{size:10,className:"mr-0.5 inline-block align-[-0.1em]"}),u.line==null?"File in Changes":u.approximate?"In Changes ~":"In Changes"]}),m!=null&&t.jsxs("button",{type:"button",onClick:k=>{k.stopPropagation(),m()},className:"shrink-0 rounded px-1 py-0.5 text-[10px] font-medium text-blue-500 hover:bg-blue-50 hover:text-blue-600 dark:hover:bg-blue-950/40",title:"Open this thread in the Threads tab",children:[t.jsx(_s,{size:10,className:"mr-0.5 inline-block align-[-0.1em]"}),"In Threads"]}),t.jsx(zx,{prId:e.prId,target:{targetKind:"thread",targetId:e.id}}),t.jsx("span",{className:"ml-auto flex items-center",children:t.jsx(H3,{prId:e.prId,threadId:e.id,isResolved:e.isResolved})})]}),t.jsx("div",{className:"space-y-3",children:e.comments.map((k,j)=>t.jsx(L3,{comment:k,usersById:n,repoId:s,mlLabel:y==null?void 0:y.get(gd("review_comment",k.id)),isNew:c!=null?k.id===c:a2(k.createdAt,i),anchor:j===0?t.jsx(U3,{diffHunk:h,path:e.path,threadId:e.id}):void 0,showLink:j>0?t.jsx(zh,{prId:e.prId,at:k.createdAt,event:{type:"review_comment",refId:e.id},title:"Show this reply on the timeline"}):void 0},k.id))}),t.jsx(u3,{thread:e,usersById:n}),t.jsxs("div",{className:"mt-2 space-y-1.5 pl-2 text-[11px]",children:[t.jsx(Q3,{prId:e.prId,threadId:e.id}),t.jsx("div",{children:t.jsxs("a",{href:mn(e.url)??`${r}/files`,target:"_blank",rel:"noreferrer noopener",className:"text-blue-500 hover:underline",children:[t.jsx(_t,{size:11,className:"inline-block align-[-0.1em]"})," ",e.url?"View thread on GitHub":"Reply on GitHub"]})})]})]})}const Tw=4,o2={pending_first_check:"Armed — waiting for the first check",waiting_conflicts:"Waiting — conflicts with the base branch",waiting_behind:"Waiting — behind the base branch",updating_rebase:"Rebasing onto the base branch…",updating_merge:"Merging the base branch in…",awaiting_checks:"Checks running…",awaiting_review:"Waiting for required reviews",blocked_protection:"Waiting — branch protection not satisfied",enqueuing:"Adding to the merge queue…",queued:"In the merge queue",queued_local:"Waiting its turn on this repo",merging:"Merging…",retrying:"Retrying after a GitHub error"};function Y3(e){return e.yieldedForFailedChecks?"Waiting — checks failed, letting the next PR through":e.queuePosition!=null&&e.queueDepth!=null&&e.queuePosition>1?`Waiting its turn — ${e.queuePosition} of ${e.queueDepth} on this repo`:e.queuePosition===1?"Next up on this repo":o2.queued_local}function Qx(e){return e.phase==="queued_local"?Y3(e):e.phase!=null?o2[e.phase]:"Waiting…"}const X3=new Set(["updating_rebase","updating_merge","enqueuing","merging"]),Z3=new Set(["waiting_conflicts","waiting_behind","blocked_protection","retrying"]),qp={merged:"Merged automatically",disarmed_head_moved:"Auto-merge disarmed — the branch moved",disarmed_blocked:"Auto-merge stopped",expired:"Auto-merge expired",failed:"Auto-merge failed"},i2="limn.autoMerge.seenStates.v1";function J3(){try{const e=localStorage.getItem(i2);if(e==null)return null;const n=JSON.parse(e);if(n==null||typeof n!="object"||Array.isArray(n))return null;const r=new Map;for(const[s,a]of Object.entries(n)){const i=Number(s);Number.isFinite(i)&&a==="armed"&&r.set(i,"armed")}return r.size>0?r:null}catch{return null}}function $w(e){try{const n={};for(const[r,s]of e)s==="armed"&&(n[String(r)]=s);localStorage.setItem(i2,JSON.stringify(n))}catch{}}let eL=0;const tL=()=>`o${++eL}`;function nL(e,n){const r=[],s=new Set;let a=!1;for(const i of n)e.get(i.prId)==="armed"&&i.state!=="armed"&&qp[i.state]&&(r.push({id:tL(),prId:i.prId,state:i.state,repoFullName:`${i.repoOwner}/${i.repoName}`,prNumber:i.prNumber,prTitle:i.prTitle,reason:i.lastReason}),i.state==="merged"&&(a=!0)),i.state==="armed"&&s.add(i.prId);for(const i of r)s.add(i.prId);return{fresh:r,superseded:s,landed:a}}function l2(e){return{id:e.prId,number:e.prNumber,title:e.prTitle,repoFullName:e.repoFullName,authorLogin:null,authorDisplayName:null,authorAvatarUrl:null}}function rL({tone:e}){if(e==="working")return t.jsx("span",{className:"inline-block h-2.5 w-2.5 shrink-0 animate-spin rounded-full border-2 border-gray-300 border-t-blue-500"});const n=e==="good"?"bg-green-500":e==="bad"?"bg-red-500":e==="stalled"?"bg-amber-500":"bg-sky-500 animate-pulse";return t.jsx("span",{className:`inline-block h-2 w-2 shrink-0 rounded-full ${n}`})}function c2({repoFullName:e,prNumber:n,prTitle:r,tone:s,onOpen:a}){return t.jsxs("button",{type:"button",onClick:a,className:"block w-full text-left",title:"Open this PR",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx(rL,{tone:s}),t.jsxs("span",{className:"truncate font-medium text-blue-600 hover:underline dark:text-blue-400",children:[e," #",n]})]}),t.jsx("div",{className:"mt-0.5 truncate text-gray-500 dark:text-gray-400",children:r})]})}function sL({row:e}){const n=Ge(d=>d.openPrDetailTab),r=Ex(e.prId),s=`${e.repoOwner}/${e.repoName}`,a=e.phase,i=a==null?"waiting":X3.has(a)?"working":Z3.has(a)||a==="queued_local"&&e.yieldedForFailedChecks?"stalled":"waiting",c=Qx(e);return t.jsxs("li",{className:"px-3 py-2 text-xs",children:[t.jsx(c2,{repoFullName:s,prNumber:e.prNumber,prTitle:e.prTitle,tone:i,onOpen:()=>n(l2({prId:e.prId,prNumber:e.prNumber,prTitle:e.prTitle,repoFullName:s}))}),t.jsxs("div",{className:"mt-0.5 flex items-start justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"text-gray-500 dark:text-gray-400",children:c}),e.lastReason&&!(e.phase==="queued_local"&&e.queuePosition!=null)&&t.jsx("div",{className:"mt-0.5 text-[11px] leading-snug text-gray-400",children:e.lastReason})]}),t.jsx("button",{type:"button",onClick:()=>r.mutate(),disabled:r.isPending,className:"shrink-0 text-[11px] text-gray-400 hover:text-red-600 disabled:opacity-50 dark:hover:text-red-400",children:r.isPending?"Cancelling…":"Cancel"})]})]})}function aL({outcome:e,onDismiss:n}){const r=Ge(a=>a.openPrDetailTab),s=e.state==="merged";return t.jsxs("li",{className:"px-3 py-2 text-xs",children:[t.jsx(c2,{repoFullName:e.repoFullName,prNumber:e.prNumber,prTitle:e.prTitle,tone:s?"good":"bad",onOpen:()=>r(l2(e))}),t.jsxs("div",{className:"mt-0.5 flex items-start justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:s?"text-green-600 dark:text-green-400":"text-gray-500 dark:text-gray-400",children:[s?t.jsx(pr,{size:11,className:"mr-1 inline-block align-[-0.1em]"}):t.jsx(Jt,{size:11,className:"mr-1 inline-block align-[-0.1em]"}),qp[e.state]??"Auto-merge finished"]}),e.reason&&t.jsx("div",{className:"mt-0.5 text-[11px] leading-snug text-gray-400",children:e.reason})]}),t.jsx("button",{type:"button",onClick:n,className:"shrink-0 text-[11px] text-gray-400 hover:text-gray-600 dark:hover:text-gray-200",children:"dismiss"})]})]})}function oL(){const{data:e}=Px(),n=He(),r=f.useRef(J3()),[s,a]=f.useState([]),[i,c]=f.useState({}),d=e==null?void 0:e.requests;f.useEffect(()=>{if(!d)return;const w=r.current,k=new Map;for(const S of d)k.set(S.prId,S.state);if(w==null){r.current=k,$w(k);return}const{fresh:j,superseded:N,landed:I}=nL(w,d);if(r.current=k,$w(k),a(S=>{const T=S.filter($=>!N.has($.prId));return j.length===0&&T.length===S.length?S:[...j,...T].slice(0,5)}),I){const S=j.filter(T=>T.state==="merged").map(T=>T.prId);dn(n,S,{merged:!0})}},[d,n]);const u=(d??[]).filter(w=>w.state==="armed").sort((w,k)=>k.armedAt.localeCompare(w.armedAt)),m=s.filter(w=>!i[w.id]),h=m.length+u.length;if(h===0)return null;const g=m.slice(0,Tw),x=u.slice(0,Math.max(0,Tw-g.length)),y=h-g.length-x.length,b=()=>c(w=>{const k={...w};for(const j of m)k[j.id]=!0;return k});return t.jsxs("div",{role:"status","aria-label":"Auto-merge progress",className:"pointer-events-auto rounded-lg border border-gray-200 bg-white/95 shadow-lg backdrop-blur dark:border-gray-700 dark:bg-gray-900/95",children:[t.jsxs("div",{className:"flex items-center justify-between border-b border-gray-100 px-3 py-1.5 dark:border-gray-800",children:[t.jsxs("span",{className:"text-xs font-semibold",children:["Merge when ready",u.length>0&&t.jsxs("span",{className:"ml-1 font-normal text-gray-400",children:["· ",u.length," armed"]})]}),m.length>0&&t.jsx("button",{type:"button",onClick:b,className:"text-xs text-gray-400 hover:text-gray-600 dark:hover:text-gray-200",children:"Dismiss all"})]}),t.jsxs("ul",{className:"max-h-72 divide-y divide-gray-100 overflow-auto dark:divide-gray-800",children:[g.map(w=>t.jsx(aL,{outcome:w,onDismiss:()=>c(k=>({...k,[w.id]:!0}))},w.id)),x.map(w=>t.jsx(sL,{row:w},w.prId))]}),y>0&&t.jsxs("div",{className:"border-t border-gray-100 px-3 py-1 text-[11px] text-gray-400 dark:border-gray-800",children:["+",y," more"]}),t.jsx("div",{className:"border-t border-gray-100 px-3 py-1 text-[11px] text-gray-400 dark:border-gray-800",children:"Auto-merge only runs while Limn is running."})]})}const Pn={my_turn:"Review or reply",ci_failing:"CI failing",bot_signal:"Review-bot signal",bot_only_review:"Only a bot reviewed",stalled_review:"Stalled review",untouched_thread:"Untouched thread",reviewer_load:"Review load",reviewer_routing:"Needs a reviewer",merge:"Ready to merge",update_branch:"Behind trunk",conflicts:"Merge conflicts",security:"Security",dependency_bump:"Bumps"};function iL(e){var n;if(e.kind==="my_turn"){if(e.relevance==="direct")return"Your turn";if(e.relevance==="maintained")return"In your repos";switch(e.reason){case"trunk_red":return"Trunk CI failing";case"own_ci_red":return"CI failing on your PR";case"own_conflicts":return Pn.conflicts;case"own_ready":return((n=e.own)==null?void 0:n.kind)==="ready"?Pn[e.own.forward]:Pn.merge;case"own_thread":return Pn.untouched_thread;default:return Pn.my_turn}}return e.kind==="ci_failing"?e.arm==="your_pr"?"CI failing on your PR":"Trunk CI failing":e.kind==="security"?e.fix==="proven"?"Security fix":e.fix==="inferred"?"Likely security fix":"Security alert":e.kind==="dependency_bump"?"Dependency update":Pn[e.kind]}const wf={dependency:"Dependency bot",code_agent:"Coding agent",release:"Release bot",housekeeping:"Housekeeping bot",quality_check:"CI bot",review:"Review bot"},lL={ready:"Ready to merge",behind:"Behind trunk",conflicts:null,ci_red:null,needs_review:null,blocked:"Blocked",unknown:null};function cL(e){if(e.depState==="ci_red")return null;const n=e.kind==="security"?e.stateDetail:e.detail;return n==null||n===""?null:Nf({detail:n,inMergeQueue:e.inMergeQueue})}function dL(e){return e.depState==null||e.inMergeQueue===!0?null:lL[e.depState]}const uL={socket:"Socket",dependency_review:"Dependency Review",endor:"Endor Labs",semgrep:"Semgrep",code_scanning:"Code scanning",snyk:"Snyk",frogbot:"Frogbot",checkmarx:"Checkmarx"},d2="Auto review",od={review_request:"Review requested",mention:"Mentioned",thread:"Reply needed",thread_reply:"Reply to you",comment_reply:"Comment after yours",pushed_since:"Pushed since",own_ci_red:"Build failed",own_conflicts:"Merge conflicts",trunk_red:"Trunk red",pr_approved:"Approved",own_ready:"Ready to land",your_pr:"Your PR",own_thread:"Unanswered thread",claude_review:"Claude review",watched_repo_pr:"New PR"};function u2(e){var n;return e.reason==="own_ready"&&((n=e.own)==null?void 0:n.kind)==="ready"?Pn[e.own.forward]:e.reason==="claude_review"&&e.trigger==="auto"?d2:od[e.reason]}function hL(e){return e.reason==="own_ready"&&e.inMergeQueue===!0?null:u2(e)}const h2={queued:null,awaiting_checks:"running checks",mergeable:"lands next",locked:"held",unmergeable:null};function jf(e){return e==="unmergeable"?"Leaving the merge queue":"In the merge queue"}function Rl(e){const n=e!=null?h2[e]:null;return n!=null?`${jf(e)} · ${n}`:jf(e)}const pL={queued:Rl("queued"),awaiting_checks:Rl("awaiting_checks"),mergeable:Rl("mergeable"),locked:Rl("locked"),unmergeable:Rl("unmergeable")},p2={queued:"This pull request is waiting its turn in GitHub’s merge queue.",awaiting_checks:"It is at the front of GitHub’s merge queue, running the queue’s checks against the merged result.",mergeable:"The queue’s checks passed. GitHub lands this pull request next.",locked:"GitHub is holding this entry while an earlier one in the same batch settles.",unmergeable:"GitHub is taking this pull request out of the merge queue — the queued merge failed its checks, or it no longer applies. Fix it and queue it again."},m2="This pull request is in GitHub’s merge queue.";function g2(e){if(e.inMergeQueue!==!0)return null;const n=e.mergeQueueEntryState??null;return n==null?{label:Rl(null),title:m2,tone:"ok"}:{label:pL[n],title:p2[n],tone:n==="unmergeable"?"bad":"ok"}}function Yx(e,n,r={}){var k,j,N;const s=r.withPosition??!0,a=e.inMergeQueue??null,i=n.info!=null?n.info.inQueue:null;let c;if(i!=null&&a!=null)c=n.observedAt>=e.observedAt?"live":"synced";else if(i!=null)c="live";else if(a!=null)c="synced";else return null;if((c==="live"?i:a)!==!0)return null;const u=i===!0&&n.info!=null,m=a===!0?e.mergeQueueEntryState??null:null,h=u?((k=n.info)==null?void 0:k.entryState)??null:null,g=c==="live"?h??m:m??h,x=u&&s?((j=n.info)==null?void 0:j.position)??null:null,y=u&&s?((N=n.info)==null?void 0:N.estimatedTimeToMergeMs)??null:null,b=g!=null?h2[g]:null;let w=jf(g);return x!=null&&(w+=` · position ${x}`),b!=null&&(w+=` · ${b}`),y!=null&&(w+=` · ~${Math.max(1,Math.round(y/6e4))} min`),{line:w,title:g!=null?p2[g]:m2,tone:g==="unmergeable"?"bad":"ok",entryState:g,position:x,source:c}}function Nf(e){return e.detail===""||e.inMergeQueue===!0&&e.detail===A$?null:e.detail}function mL(e,n){return(e==null?void 0:e.status)==="done"||n.isPending?!0:(e==null?void 0:e.status)!=="failed"&&((e==null?void 0:e.status)==="running"||n.isSuccess)}function gL(e,n){return e?"committed":n}const fL=4;function xL(e,n,r,s){return`${e}:${n}:${r}:${s}`}function Dn(e,n){return`${e}:${n}`}function yL(e,n){const r=e.slice(0,fL),s={};for(const a of r){const i=n[a];i&&(s[a]=i)}return{order:r,sessions:s}}function Jg(e,n){return[n,...e.filter(r=>r!==n)]}function e0(e){return Object.keys(e).length}function bL(e){const n={};for(const[r,s]of Object.entries(e.decisions))s!=="suggestion"&&s!=="edited"&&(n[r]=s);return{decisions:n,suggestionIds:{},editIds:{}}}const Is=Jo(e=>({target:null,sessions:{},order:[],lastClosed:null,confirming:!1,openConflictResolver:n=>e({target:n,confirming:!1,lastClosed:null}),closeConflictResolver:({reason:n})=>e(r=>{if(r.target==null)return{confirming:!1};const s=r.order[0],a=s!=null?r.sessions[s]:void 0,i=a&&a.key.startsWith(`${r.target.prId}:`)?a.decidedCount:0;return{target:null,confirming:!1,lastClosed:n==="committed"||i===0?null:{target:r.target,reason:n,decidedCount:i}}}),setConfirming:n=>e({confirming:n}),dismissClosedResolver:()=>e({lastClosed:null}),seedSession:({key:n,sessionId:r,conflictCount:s,defaults:a})=>e(i=>{const c=i.sessions[n],d=c==null?null:c.sessionId===r?{decisions:c.decisions,suggestionIds:c.suggestionIds,editIds:c.editIds}:bL(c),u=(d==null?void 0:d.decisions)??{...a??{}},m={key:n,sessionId:r,decisions:u,suggestionIds:(d==null?void 0:d.suggestionIds)??{},editIds:(d==null?void 0:d.editIds)??{},decidedCount:e0(u),conflictCount:s};return yL(Jg(i.order,n),{...i.sessions,[n]:m})}),decideRegion:({key:n,fileIndex:r,regionId:s,decision:a,suggestionId:i,editId:c})=>e(d=>{const u=d.sessions[n];if(u==null)return{};const m=Dn(r,s),h={...u.decisions},g={...u.suggestionIds},x={...u.editIds};a==null?(delete h[m],delete g[m],delete x[m]):(h[m]=a,a==="suggestion"&&i!=null?g[m]=i:delete g[m],a==="edited"&&c!=null?x[m]=c:delete x[m]);const y={...u,decisions:h,suggestionIds:g,editIds:x,decidedCount:e0(h)};return{sessions:{...d.sessions,[n]:y},order:Jg(d.order,n)}}),decideRegions:({key:n,decisions:r})=>e(s=>{const a=s.sessions[n];if(a==null)return{};const i={...a.decisions},c={...a.suggestionIds},d={...a.editIds};for(const m of r){const h=Dn(m.fileIndex,m.regionId);i[h]=m.decision,m.decision==="suggestion"&&m.suggestionId!=null?c[h]=m.suggestionId:delete c[h],m.decision==="edited"&&m.editId!=null?d[h]=m.editId:delete d[h]}const u={...a,decisions:i,suggestionIds:c,editIds:d,decidedCount:e0(i)};return{sessions:{...s.sessions,[n]:u},order:Jg(s.order,n)}})}));function vL(){return Is(e=>e.target)}function Xx(e){return Is(n=>e==null?null:n.sessions[e]??null)}function kL(e){Is.getState().openConflictResolver(e)}function f2(e){const{data:n}=In();return T_({...e,resolverAvailable:(n==null?void 0:n.conflictResolver)??!1})}function Zx({state:e,verdict:n,viewerCanPush:r,target:s,className:a}){return f2({state:e,verdict:n,viewerCanPush:r})?t.jsxs("button",{type:"button",onClick:()=>kL(s),className:`inline-flex items-center gap-1 rounded border border-gray-300 px-1.5 py-0.5 text-xs font-medium text-gray-700 hover:border-gray-400 hover:bg-gray-50 dark:border-gray-700 dark:text-gray-200 dark:hover:border-gray-600 dark:hover:bg-gray-800 ${a??""}`,title:`Resolve the conflicts in ${s.repoFullName} #${s.prNumber}`,children:[t.jsx(xS,{size:12}),"Resolve conflicts"]}):null}const wL={merge:"Create a merge commit",squash:"Squash and merge",rebase:"Rebase and merge"},_w={merge:"Merge",squash:"Squash and merge",rebase:"Rebase and merge"};function x2({prId:e,githubUrl:n,label:r="Merge",blockFacts:s,resolverTarget:a,inMergeQueue:i,mergeQueueEntryState:c,syncedAt:d,showQueuePosition:u=!0}){const[m,h]=f.useState(!1),{data:g,isLoading:x,isError:y,dataUpdatedAt:b}=_x(e,m),w=eE(e),k=aE(e),j=tE(e),N=nE(e),I=Ex(e),S=Or({mutationKey:rd(e)})>0,T=Or({mutationKey:rd(e,"dequeue")})>0,$=Or({mutationKey:rd(e,"enqueue")})>0,P=Yx({inMergeQueue:i,mergeQueueEntryState:c,observedAt:d??0},{info:g==null?void 0:g.mergeQueue,observedAt:b},{withPosition:u});ZS(e,i,d??0,g==null?void 0:g.mergeQueue,b);const[C,L]=f.useState(null),[F,M]=f.useState("rebase"),D=C&&(g!=null&&g.allowedMethods.includes(C))?C:(g==null?void 0:g.defaultMethod)??"merge",A=(ae,we)=>ae instanceof cn?ae.message:ae?we:null,W=A(w.error,"Failed to merge the PR."),z=A(k.error,"Failed to update the branch."),te=A(j.error??N.error,"Merge-queue action failed."),H=A(I.error,"Failed to change auto-merge."),B=f.useMemo(()=>{if(g==null||!g.behind)return null;const ae=g.behindBy;return`${ae>0?ae:"Some"} commit${ae===1?"":"s"} behind ${g.baseRef}`},[g]),O=P!=null;if(P!=null)return t.jsx(jL,{status:P,busy:S,removing:T,error:te,onRemove:()=>N.mutate()});if(!m)return t.jsxs("button",{type:"button",onClick:()=>h(!0),className:"inline-flex items-center gap-1 rounded border border-violet-500 px-2 py-0.5 text-sm font-medium text-violet-700 hover:bg-violet-50 dark:border-violet-600 dark:text-violet-300 dark:hover:bg-violet-900/30",children:[t.jsx(bp,{}),r,t.jsx(Cr,{})]});if(x)return t.jsx("div",{className:"text-xs text-gray-400",children:"Checking merge status…"});if(y||g==null)return t.jsxs("div",{className:"flex items-center gap-2 text-xs text-red-500",children:["Couldn’t load merge status.",t.jsx("button",{type:"button",onClick:()=>h(!1),className:"rounded border border-gray-300 px-1.5 py-0.5 text-gray-600 hover:border-gray-400 dark:border-gray-700 dark:text-gray-300",children:"Close"})]});const E=g.mergeQueue,ee=g.autoMerge.armed,K=(ee==null?void 0:ee.state)==="armed",U=Pi({mergeable:g.conflicts?"conflicting":g.mergeable===!0?"mergeable":"unknown",mergeStateStatus:CS(g.mergeStateStatus),inMergeQueue:O,queuePosition:(E==null?void 0:E.position)??null,behindBy:g.behindBy,...s||g.reviewDecision!=null?{blockFacts:{...s,...g.reviewDecision!==void 0?{reviewDecision:g.reviewDecision}:{}}}:{}}),Q=g.allowedMethods.length>0,J=U.canMerge&&Q,ne=w.isPending||S;return t.jsxs("div",{className:"w-full space-y-2",children:[t.jsxs("div",{className:`text-xs font-medium ${Sx[U.tone]}`,children:[(U.tone==="bad"||U.tone==="warn")&&t.jsx(Jt,{size:12,className:"mr-1 inline-block align-[-0.1em]"}),U.label,U.detail&&t.jsxs("span",{className:"ml-1 font-normal text-gray-500 dark:text-gray-400",children:["— ",U.detail]})]}),g.conflicts&&t.jsxs("div",{className:"rounded border border-amber-300 bg-amber-50/60 px-2 py-1.5 text-xs text-amber-800 dark:border-amber-800/60 dark:bg-amber-950/20 dark:text-amber-200",children:[t.jsx(Jt,{size:12,className:"mr-1 inline-block align-[-0.1em]"}),"This PR conflicts with ",t.jsx("span",{className:"font-mono",children:g.baseRef}),".",t.jsxs("div",{className:"mt-1.5 flex flex-wrap items-center gap-2",children:[a!=null&&t.jsx(Zx,{state:"open",verdict:U.verdict,viewerCanPush:!0,target:a}),t.jsxs("a",{href:n,target:"_blank",rel:"noreferrer noopener",className:"font-medium underline",children:["Resolve on GitHub ",t.jsx(_t,{size:11,className:"inline-block align-[-0.1em]"})]})]})]}),g.canUpdateBranch&&t.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:[t.jsxs("span",{className:"text-gray-500 dark:text-gray-400",children:[B,"."]}),g.canRebaseUpdate&&t.jsxs("select",{value:F,onChange:ae=>M(ae.target.value),disabled:k.isPending,className:"rounded border border-gray-300 bg-white px-1 py-0.5 text-xs dark:border-gray-700 dark:bg-gray-900",title:"How to bring in the base branch",children:[t.jsxs("option",{value:"rebase",children:["Rebase onto ",g.baseRef]}),t.jsxs("option",{value:"merge",children:["Merge ",g.baseRef," in"]})]}),t.jsx("button",{type:"button",onClick:()=>k.mutate(g.canRebaseUpdate?{strategy:F}:{strategy:"merge"}),disabled:k.isPending,className:"rounded border border-sky-500 px-2 py-0.5 font-medium text-sky-700 hover:bg-sky-50 disabled:opacity-50 dark:border-sky-600 dark:text-sky-300 dark:hover:bg-sky-900/30",title:"Bring in the latest base-branch changes before merging",children:k.isPending?"Updating…":"Update branch"}),z&&t.jsx("span",{className:"text-red-500",children:z})]}),K&&ee!=null&&t.jsxs("div",{className:"rounded border border-violet-300 bg-violet-50/60 px-2 py-1.5 text-xs text-violet-900 dark:border-violet-800/60 dark:bg-violet-950/20 dark:text-violet-200",children:[t.jsxs("div",{className:"font-medium",children:["Auto-merge armed · ",ee.viaMergeQueue?"via the merge queue":_w[ee.mergeMethod]," · armed"," ",Nt(ee.armedAt)]}),t.jsx("div",{className:"mt-0.5 text-violet-700/90 dark:text-violet-300/90",children:ee.lastReason??"Waiting for the blockers to clear."}),t.jsxs("div",{className:"mt-0.5 text-[11px] text-violet-700/70 dark:text-violet-300/70",children:[ee.viaMergeQueue?"Limn adds it to the merge queue while the app is running; GitHub lands it from there.":"Limn merges it while the app is running."," ","A new commit on the branch disarms it — you re-arm to merge the new code. Expires"," ",Cn(ee.expiresAt),"."]}),t.jsx("button",{type:"button",onClick:()=>I.mutate(),disabled:I.isPending,className:"mt-1 rounded border border-violet-400 px-1.5 py-0.5 font-medium hover:bg-violet-100 disabled:opacity-50 dark:border-violet-700 dark:hover:bg-violet-900/40",children:I.isPending?"Cancelling…":"Cancel auto-merge"})]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[E!=null&&E.enabled?t.jsx("button",{type:"button",onClick:()=>j.mutate(D),disabled:ne,className:"whitespace-nowrap rounded border border-violet-500 px-2 py-0.5 text-sm font-medium text-violet-700 hover:bg-violet-50 disabled:opacity-50 dark:border-violet-600 dark:text-violet-300 dark:hover:bg-violet-900/30",title:"This branch uses a merge queue — GitHub merges it in turn",children:$?"Queueing…":"Add to merge queue"}):t.jsxs(t.Fragment,{children:[g.allowedMethods.length>1&&t.jsx("select",{value:D,onChange:ae=>L(ae.target.value),disabled:ne||!J,className:"rounded border border-gray-300 bg-white px-1.5 py-0.5 text-sm dark:border-gray-700 dark:bg-gray-900",children:g.allowedMethods.map(ae=>t.jsx("option",{value:ae,children:wL[ae]},ae))}),t.jsx("button",{type:"button",onClick:()=>w.mutate(D),disabled:!J||ne,className:"whitespace-nowrap rounded border border-violet-500 px-2 py-0.5 text-sm font-medium text-violet-700 hover:bg-violet-50 disabled:opacity-50 dark:border-violet-600 dark:text-violet-300 dark:hover:bg-violet-900/30",title:J?"Merge this PR":U.detail??"This PR can’t be merged right now",children:w.isPending?"Merging…":_w[D]})]}),t.jsx("button",{type:"button",onClick:()=>{h(!1),w.reset(),k.reset(),j.reset(),N.reset(),I.reset()},disabled:ne,className:"whitespace-nowrap rounded border border-gray-300 px-2 py-0.5 text-sm hover:border-gray-400 disabled:opacity-50 dark:border-gray-700 dark:hover:border-gray-500",children:"Cancel"}),W&&t.jsx("span",{className:"text-xs text-red-500",children:W}),te&&t.jsx("span",{className:"text-xs text-red-500",children:te}),H&&t.jsx("span",{className:"text-xs text-red-500",children:H})]})]})}function jL({status:e,busy:n,removing:r,error:s,onRemove:a}){return t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsxs("span",{className:`text-xs ${e.tone==="bad"?"text-red-700 dark:text-red-300":"text-gray-600 dark:text-gray-300"}`,title:e.title,children:[e.tone==="bad"&&t.jsx(Jt,{size:12,className:"mr-1 inline-block align-[-0.1em]"}),e.line]}),t.jsx("button",{type:"button",onClick:a,disabled:n,className:"whitespace-nowrap rounded border border-gray-300 px-2 py-0.5 text-sm hover:border-gray-400 disabled:opacity-50 dark:border-gray-700 dark:hover:border-gray-500",children:r?"Removing…":"Remove from queue"}),s&&t.jsx("span",{className:"text-xs text-red-500",children:s})]})}function Jx({prId:e,eager:n=!0,blockFacts:r,inMergeQueue:s,mergeQueueEntryState:a,syncedAt:i}){var P,C;const c=gE(e),{data:d,dataUpdatedAt:u}=_x(e,n||c!=="idle"),m=Yx({inMergeQueue:s,mergeQueueEntryState:a,observedAt:i??0},{info:d==null?void 0:d.mergeQueue,observedAt:u})!=null;ZS(e,s,i??0,d==null?void 0:d.mergeQueue,u);const h=Di(e),g=fE(e),x=Ex(e),y=Or({mutationKey:t5(e)})>0,b=(L,F)=>L instanceof cn?L.message:L?F:null,w=b(g.error,"Failed to arm auto-merge."),k=b(x.error,"Failed to cancel auto-merge."),j=h??(((P=d==null?void 0:d.autoMerge.armed)==null?void 0:P.state)==="armed"?d.autoMerge.armed:null),N=pE({draft:c,intentArmed:j!=null,posting:y});if(j!=null){const L=j.enqueuedAt!=null;return t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsxs("span",{className:"inline-flex items-center gap-1 rounded border border-violet-300 bg-violet-50/60 px-2 py-0.5 text-sm font-medium text-violet-700 dark:border-violet-800/60 dark:bg-violet-950/20 dark:text-violet-300",title:L?"Limn added this PR to the merge queue — GitHub lands it from here. Cancelling also removes it from the queue.":j.viaMergeQueue?"Limn updates it from trunk if needed and adds it to the merge queue when required reviews are in — while the app is running. A new commit on the branch disarms it.":"Limn updates it from trunk if needed and merges when checks pass — while the app is running. A new commit on the branch disarms it.",children:[t.jsx($i,{}),L?"In the merge queue":j.viaMergeQueue?"Armed — queueing when ready":"Armed — merging when ready"]}),t.jsx("button",{type:"button",onClick:()=>x.mutate(),disabled:x.isPending,className:"whitespace-nowrap rounded border border-gray-300 px-2 py-0.5 text-sm hover:border-gray-400 disabled:opacity-50 dark:border-gray-700 dark:hover:border-gray-500",children:x.isPending?"Cancelling…":L?"Cancel & dequeue":"Cancel auto-merge"}),k&&t.jsx("span",{className:"text-xs text-red-500",children:k})]})}if(d==null)return n||m?null:c==="idle"?t.jsxs("button",{type:"button",onClick:()=>Ml(e,{type:"ask"}),className:"inline-flex items-center gap-1 rounded border border-violet-400 px-2 py-0.5 text-[11px] font-medium text-violet-600 hover:bg-violet-50 dark:border-violet-700 dark:text-violet-300 dark:hover:bg-violet-900/30",title:"Check whether Limn's watcher can land this for you — it asks GitHub for the live merge state",children:[t.jsx($i,{size:11}),"Merge when ready"]}):t.jsx("span",{className:"text-[11px] text-gray-400",children:"Checking merge state…"});const I=d.mergeQueue,S=Pi({mergeable:d.conflicts?"conflicting":d.mergeable===!0?"mergeable":"unknown",mergeStateStatus:CS(d.mergeStateStatus),inMergeQueue:m,queuePosition:(I==null?void 0:I.position)??null,behindBy:d.behindBy,...r||d.reviewDecision!=null?{blockFacts:{...r,...d.reviewDecision!==void 0?{reviewDecision:d.reviewDecision}:{}}}:{}}),T=(I==null?void 0:I.enabled)??!1;return O_({allowedByRepo:d.autoMerge.allowedByRepo,methodCount:d.allowedMethods.length,alreadyArmed:!1,verdict:S,behindBy:d.behindBy})?N==="confirming"||N==="arming"?t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:T?"Updates from trunk if needed and adds it to the merge queue when required reviews are in — while Limn is running.":"Updates from trunk if needed and merges when checks pass — while Limn is running."}),t.jsx("button",{type:"button",onClick:()=>g.mutate({mergeMethod:d.defaultMethod,updateStrategy:d.canRebaseUpdate?"rebase":"merge"}),disabled:N==="arming",className:"whitespace-nowrap rounded border border-violet-500 px-2 py-0.5 text-sm font-medium text-violet-700 hover:bg-violet-50 disabled:opacity-50 dark:border-violet-600 dark:text-violet-300 dark:hover:bg-violet-900/30",children:N==="arming"?"Arming…":"Arm auto-merge"}),t.jsx("button",{type:"button",onClick:()=>{Ml(e,{type:"cancel"}),g.reset()},disabled:N==="arming",className:"whitespace-nowrap rounded border border-gray-300 px-2 py-0.5 text-sm hover:border-gray-400 disabled:opacity-50 dark:border-gray-700 dark:hover:border-gray-500",children:"Cancel"}),w&&t.jsx("span",{className:"text-xs text-red-500",children:w})]}):t.jsxs("button",{type:"button",onClick:()=>Ml(e,{type:"confirm"}),className:"inline-flex items-center gap-1 rounded border border-violet-400 px-2 py-0.5 text-sm font-medium text-violet-600 hover:bg-violet-50 dark:border-violet-700 dark:text-violet-300 dark:hover:bg-violet-900/30",title:(T?"Arm Limn's watcher: it updates from trunk if needed and adds the PR to the merge queue when required reviews are in — while the app is running":"Arm Limn's watcher: it updates from trunk if needed and merges when checks pass — while the app is running")+((C=S.blockers)!=null&&C[0]?`. Right now: ${S.blockers[0].text}`:""),children:[t.jsx($i,{}),T?"Queue when ready":"Merge when ready"]}):n||c==="idle"?null:t.jsx("span",{className:"text-[11px] text-gray-400",title:"Arming only helps while something is blocking the merge. There is nothing here for the watcher to wait out — or this repo won’t let this account merge.",children:"Nothing to arm."})}function NL(){var e;return((e=In().data)==null?void 0:e.largePrCodeLocThreshold)??hd}function SL(){const e=He();return tt({mutationFn:n=>he.setLargePrThreshold(n),onSuccess:()=>{e.invalidateQueries({queryKey:["me"]})}})}const Pw={};function CL(e){const n=He(),r=f.useCallback(()=>{if(e==null)return Pw;const i=c=>{for(const d of c??[])if(d.id===e&&d.codeLoc!=null)return{codeLoc:d.codeLoc,codeLocIsLowerBound:d.codeLocIsLowerBound};return null};for(const[,c]of n.getQueriesData({queryKey:["timeline"]})){const d=i(c==null?void 0:c.prs);if(d)return d}for(const[,c]of n.getQueriesData({queryKey:["open-prs"]})){const d=i(c==null?void 0:c.prs);if(d)return d}return Pw},[n,e]),[s,a]=f.useState(r);return f.useEffect(()=>{const i=()=>{const c=r();a(d=>d.codeLoc===c.codeLoc&&d.codeLocIsLowerBound===c.codeLocIsLowerBound?d:c)};return i(),n.getQueryCache().subscribe(c=>{const d=c.query.queryKey[0];(d==="timeline"||d==="open-prs")&&i()})},[n,r]),s}function Up({pr:e,className:n="",iconOnly:r=!1}){const s=NL(),a=TS(e,s);return a==null?null:t.jsxs("span",{className:`inline-flex shrink-0 items-center gap-1 text-[11px] text-amber-600/90 dark:text-amber-500/80 ${n}`,title:a.label,children:[t.jsx(Jt,{size:11,className:"inline-block align-[-0.1em]"}),t.jsx("span",{className:"sr-only",children:a.label}),!r&&t.jsx("span",{"aria-hidden":"true",children:a.short})]})}function ey(){var e;return jp(((e=In().data)==null?void 0:e.blastRadius)??null)}function RL(){const e=He();return tt({mutationFn:n=>he.setBlastRadiusConfig(n),onSuccess:()=>{e.invalidateQueries({queryKey:["me"]})}})}const Ew={blast:null};function IL(e){const n=He(),r=f.useCallback(()=>{if(e==null)return Ew;const i=c=>{for(const d of c??[])if(d.id===e&&d.blast!=null)return{blast:d.blast};return null};for(const[,c]of n.getQueriesData({queryKey:["timeline"]})){const d=i(c==null?void 0:c.prs);if(d)return d}for(const[,c]of n.getQueriesData({queryKey:["open-prs"]})){const d=i(c==null?void 0:c.prs);if(d)return d}return Ew},[n,e]),[s,a]=f.useState(r);return f.useEffect(()=>{const i=()=>{const c=r();a(d=>d.blast===c.blast?d:c)};return i(),n.getQueryCache().subscribe(c=>{const d=c.query.queryKey[0];(d==="timeline"||d==="open-prs")&&i()})},[n,r]),s}const Aw=12;function TL(){var i;const{data:e}=Np(),{data:n}=xn(),r=G(c=>c.workspaceId),s=((i=In().data)==null?void 0:i.blastRadius)??null,a=f.useMemo(()=>jp(s),[s]);return f.useMemo(()=>{const c=e==null?void 0:e.prs;if(c==null||n==null||r==null)return null;const d=new Map(n.map(y=>[y.id,y.fullName])),u=new Map;for(const y of c){let b=u.get(y.repoId);b==null&&(b={repoId:y.repoId,repoFullName:d.get(y.repoId)??`Repository ${y.repoId}`,low:0,medium:0,high:0,read:0,unread:0,drafts:0,openPrs:0},u.set(y.repoId,b)),b.openPrs+=1,y.isDraft&&(b.drafts+=1);const w=Rx(y,a);if(w==null){b.unread+=1;continue}b.read+=1,w.level==="low"?b.low+=1:w.level==="medium"?b.medium+=1:b.high+=1}const m=[...u.values()].sort((y,b)=>b.openPrs-y.openPrs||y.repoFullName.localeCompare(b.repoFullName));if(m.reduce((y,b)=>y+b.read,0)===0)return null;const h=m.slice(0,Aw),g=m.slice(Aw),x=(y,b)=>y.reduce((w,k)=>w+b(k),0);return{repos:h,repoCount:m.length,workspaceRepos:n.reduce((y,b)=>y+(b.workspaceId===r?1:0),0),openPrs:x(h,y=>y.openPrs),read:x(h,y=>y.read),unread:x(h,y=>y.unread),drafts:x(h,y=>y.drafts),omitted:{repos:g.length,openPrs:x(g,y=>y.openPrs),high:x(g,y=>y.high)}}},[e,n,a,r])}const $L={low:{rings:1,className:"text-emerald-700 dark:text-emerald-400",word:"Low"},medium:{rings:2,className:"text-gray-500 dark:text-gray-400",word:"Medium"},high:{rings:3,className:"text-amber-600 dark:text-amber-500",word:"High"}};function _L({pr:e}){const n=e.blast;if(n==null)return null;const r=[os(n.codeFiles,"code file","code files"),os(n.testFiles,"test file","test files"),`${n.nonCodeFiles} docs/config`],s=`${os(n.dirs,"directory","directories")} · ${os(n.subsystems,"top-level area","top-level areas")}`;return t.jsxs("div",{className:"border-t border-gray-200 pt-1 text-gray-500 dark:border-gray-700 dark:text-gray-400",children:[t.jsx("div",{children:r.join(", ")}),t.jsx("div",{children:s}),e.codeLoc!=null&&t.jsxs("div",{children:[e.codeLoc.toLocaleString(),e.codeLocIsLowerBound?"+":""," code lines",n.truncated?" · GitHub truncated the file list, so these are minimums":""]}),n.contentKind!=null&&t.jsx("div",{children:n.contentKind==="comments"?"Read from the diff: comments only":n.contentKind==="formatting"?"Read from the diff: formatting only":"Read from the diff: real code changes"})]})}function Md({pr:e,className:n="",iconOnly:r=!1,expandable:s=!1}){const a=ey(),[i,c]=f.useState(!1),d=Rx(e,a);if(d==null)return null;const u=$L[d.level],m=d.volumeOnly?u.word:`${u.word} · ${d.reasons[0].text.replace(/^Touches /,"").replace(/^Spans /,"")}`,h=t.jsxs(t.Fragment,{children:[t.jsx(V4,{rings:u.rings,size:12,className:"inline-block align-[-0.1em]"}),t.jsx("span",{className:"sr-only",children:`Blast radius: ${d.label}`}),!r&&t.jsx("span",{"aria-hidden":"true",children:m})]}),g=`inline-flex shrink-0 items-center gap-1 text-[11px] ${u.className} ${n}`;return s?t.jsxs("span",{className:"inline-flex flex-col items-start gap-0.5 self-start",children:[t.jsx("button",{type:"button",onClick:()=>c(x=>!x),className:`${g} rounded hover:underline`,"aria-expanded":i,title:d.label,children:h}),i&&t.jsxs("div",{className:"ml-4 flex flex-col gap-1 text-[11px] text-gray-600 dark:text-gray-300",children:[t.jsx("ul",{className:"list-disc space-y-0.5",children:d.reasons.map(x=>t.jsx("li",{children:x.text},`${x.kind}:${x.text}`))}),t.jsx(_L,{pr:e})]})]}):t.jsx("span",{className:g,title:d.label,children:h})}let ha=null;function y2(e){return ha!==e&&(ha==null||ha()),ha=e,()=>{ha===e&&(ha=null)}}function Hp(){ha==null||ha()}const ty=["proximity","stall","relevance"],$s={proximity:"How close to done",stall:"How long it has waited",relevance:"How much it is about you"};function Dl(e){return $s[e].charAt(0).toLowerCase()+$s[e].slice(1)}const b2={balanced:"Balanced",mine_first:"Mine first",oldest_first:"Oldest first",quick_wins:"Quick wins"},PL={balanced:"The default.",mine_first:`Most weight on “${$s.relevance}”.`,oldest_first:`Most weight on “${$s.stall}”.`,quick_wins:`Most weight on “${$s.proximity}”.`},EL=[{reason:"review_request",hint:"Someone asked you to review."},{reason:"mention",hint:"Someone mentioned you on an open PR."},{reason:"thread",hint:"A reply, or a new commit, on your review thread."},{reason:"thread_reply",hint:"Someone answered your comment in a review thread."},{reason:"comment_reply",hint:"Someone commented after your last comment on a PR."},{reason:"pushed_since",hint:"Someone pushed after your review or comment."},{reason:"pr_approved",hint:"Your PR has an approval and no “changes requested”."},{reason:"your_pr",hint:"Since you last opened them here."},{reason:"claude_review",hint:"Findings you have not posted."},{reason:"watched_repo_pr",hint:"Open PRs in your repos you have not touched."}],AL=["own_ci_red","own_conflicts","own_ready","own_thread"],ML={off:"Off",maintained:"Repos you maintain",all:"Every repo in the workspace"};function Mw(e){const n=eS(e);return{show:{...n.show},trunkScope:n.trunkScope,order:[...n.order],weights:{...n.weightsPct}}}function v2(e){return px({show:e.show,trunkScope:e.trunkScope,order:e.order,weights:e.weights})}function LL(e,n){return JSON.stringify(v2(e))!==JSON.stringify(px(n))}function FL(e){return q$({show:e.show,trunkScope:e.trunkScope,order:e.order,weights:e.weights})}function OL(e,n){return n==="trunk_red"?e.trunkScope==="off":!e.show[n]}function DL(e,n,r,s=new Set){const a=[...e],i=a.indexOf(n);if(i<0)return a;let c=i+r;for(;c>=0&&c<a.length&&s.has(a[c]);)c+=r;return c<0||c>=a.length||(a[i]=a[c],a[c]=n),a}function BL(e,n,r){const s=Math.min(100,Math.max(0,Math.round(r/10)*10)),[a,i]=ty.filter(h=>h!==n),c=100-s,d=e[a]+e[i],u=d===0?Math.round(c/20)*10:Math.round(c*e[a]/d/10)*10,m=Math.min(c,Math.max(0,u));return{...e,[n]:s,[a]:m,[i]:c-m}}function WL(e,n,r,s){const i=e!=null&&e.key===r&&ty.every(c=>e.to[c]===n[c])?e.from:n;return{key:r,from:i,to:BL(i,r,s)}}function qL(e,n,r,s=new Set){const a=e.filter(i=>!s.has(i));return`“${r}” moved to ${a.indexOf(n)+1} of ${a.length}.`}function k2(e){return{...hx[e]}}function UL(e){return{...e,order:[...Oi],weights:k2("balanced")}}const w2={high:"Red",warn:"Amber",info:"Blue"};function HL(e){const n=e%100;if(n>=11&&n<=13)return`${e}th`;switch(e%10){case 1:return`${e}st`;case 2:return`${e}nd`;case 3:return`${e}rd`;default:return`${e}th`}}function ua(e){if(e%24===0){const n=e/24;return`${n} day${n===1?"":"s"}`}return`${e} hour${e===1?"":"s"}`}function lh(e){if(e<1)return"under an hour";const n=Math.round(e);return n<48?`${n} hour${n===1?"":"s"}`:`${Math.round(n/24)} days`}function ma(e){return Math.round(e*1e3)/10}const zL=e=>e>=0?`+${ma(e)}`:`−${ma(-e)}`,j2={merge_approved:"approved and ready to merge",merge_unapproved:"ready to merge, not yet approved",update_branch:"needs a branch update",red_trunk:"failing trunk",unblock_ci:"failing build",review:"needs your review or action",reply:"needs your reply",thread:"unanswered review thread",nudge:"waiting on a reviewer",conflicts:"has merge conflicts",waiting:"blocked, or still being checked",security_alert:"flagged by a security tool"};function N2(e){const n=zL(qo.adjustments[e]);switch(e){case"conflicts":return`has conflicts ${n}`;case"many_untouched_threads":return`${qo.manyUntouchedThreadsMin}+ untouched threads ${n}`;case"small_change":return`${qo.smallChangeMaxFiles} files or fewer ${n}`}}const KL={opened:"since it was opened",requested:"since you were asked",last_commit:"since the last commit",thread_created:"since the thread started",observed:"since this came up"},S2={direct:"names you",maintained:"a repo you maintain",none:"shared work"};function C2(e){return e==="custom"?"your own":b2[e]}function GL(e){const n=Date.parse(e);return Number.isFinite(n)?Math.max(0,Date.now()-n)/36e5:0}function VL(e,n){const r=qo.proximity[e.proximityBase],s=[`${j2[e.proximityBase]} ${ma(r)}`,...e.adjustments.map(N2)].join(", "),a=e.clock==null?"":e.proximityBase==="red_trunk"&&e.clock==="observed"?"since we last checked the branch":KL[e.clock],i=e.ageHours==null?"no start time to measure from":`${lh(e.ageHours)} ${a}`.trim(),c=qo.relevanceWeight[e.relevance],d=(u,m,h,g,x)=>({key:u,label:m,value:ma(h),weight:Math.round(g*100),points:ma(h*g),note:x});return{total:ma(e.score),rows:[d("proximity",$s.proximity,e.proximity,n.proximity,s),d("stall",$s.stall,e.stallRisk,n.stall,i),d("relevance",$s.relevance,c,n.relevance,S2[e.relevance])]}}function QL(e){var n;switch(e.kind){case"my_turn":switch(e.reason){case"review_request":return"Someone asked you to review this PR. It goes away when you submit a review.";case"mention":return"Someone @-mentioned you on this PR. Any review, comment or push from you clears it.";case"thread":return"Someone replied in a review thread you started, or the code under it changed. Replying usually clears it; resolving the thread always does.";case"thread_reply":return"Someone replied after your comment in a review thread. Replying there clears it; resolving the thread always does.";case"comment_reply":return"Someone commented on this PR after your last comment. Any review, comment or push from you clears it.";case"pushed_since":return"Someone pushed new commits after your last review or comment. It goes away when you review, comment or push.";case"own_ci_red":return"The latest build on your open PR failed. It goes away when the build passes.";case"own_conflicts":return"Your PR conflicts with its base branch. It goes away when the conflict is resolved.";case"trunk_red":return e.maintained?"The default branch is failing CI in a repo you maintain. Every open PR there builds on it.":"The default branch is failing CI. Every open PR there builds on it.";case"pr_approved":return"Your PR is approved. It goes away when it is merged or closed.";case"own_ready":return((n=e.own)==null?void 0:n.kind)==="ready"&&e.own.forward==="update_branch"?"GitHub will not merge your PR until its branch is updated.":"GitHub will merge your PR now.";case"your_pr":return"Your PR has new commits, comments or reviews since you last opened it here. Opening it clears this.";case"own_thread":return`A review comment on your PR has had no reply and no later commit for ${lh(GL(e.since))}.`;case"claude_review":return"A Claude review finished with findings you have not posted. It goes away when you post them or act on the PR.";case"watched_repo_pr":return"A new PR you have not reviewed, commented on or pushed to. It goes away when you do one of those.";default:return e}case"ci_failing":return e.arm==="your_pr"?"The latest build on your open PR failed.":"The default branch is failing CI in a repo you maintain. Every open PR there builds on it.";case"conflicts":return"This PR conflicts with its base branch, and you can push to the repo.";case"stalled_review":return`The PR has been open ${lh(e.ageHours)} and a requested review has not arrived.`;case"untouched_thread":return`A review comment has had no reply and no follow-up commit for ${lh(e.ageHours)}.`;case"reviewer_load":return`This reviewer has ${e.pendingCount} requested review${e.pendingCount===1?"":"s"} they have not done yet.`;case"reviewer_routing":return"Nobody has been asked to review this PR, and nobody has reviewed it.";case"merge":return"GitHub will merge this PR now.";case"update_branch":return"GitHub will not merge this PR until its branch is updated.";case"security":return e.dependencyUpdate?e.fix==="proven"?"A dependency bot opened this PR to fix a known security advisory. It goes away when the PR is merged or closed.":e.fix==="inferred"?"Dependabot grouped this update the way it groups security updates, and GitHub cut off the line that would confirm it. It goes away when the PR is merged or closed.":"A security tool flagged a known advisory on this dependency update. It goes away when the PR is merged or closed, or the tool clears it.":"A security tool flagged a known advisory on this PR. It goes away when the tool clears it or the review thread is resolved.";case"dependency_bump":return"A dependency bot opened this PR. It goes away when the PR is merged or closed.";default:return Pn[e.kind]}}function YL(e){return e.kind==="my_turn"?e.muted===!0?"Its repo is muted for Pending, so it does not claim your turn or notify you.":W$.has(e.reason)?"You added this type to My Turn in Settings.":e.relevance==="direct"?null:e.relevance==="maintained"?"It counts as “In your repos”: you can push to this repo, or have merged a PR into it.":"Nobody has named you on it, and you do not maintain the repo.":e.kind==="security"&&!e.dependencyUpdate?null:e.kind==="merge"||e.kind==="update_branch"||e.kind==="security"||e.kind==="dependency_bump"?e.relevance==="direct"?"It is your PR.":e.relevance==="maintained"?"It is in a repo you maintain.":"It is not your PR, and you do not maintain the repo.":e.kind==="conflicts"?e.relevance==="direct"?"It is your PR.":"It is someone else’s PR.":null}function XL(e){const n=ua;switch(e.kind){case"my_turn":switch(e.reason){case"review_request":return"someone is waiting on your review";case"thread":case"mention":case"thread_reply":case"comment_reply":return"someone is waiting on your reply";case"pushed_since":return"new code since your review";case"own_ci_red":return"your build is failing";case"own_conflicts":return"your PR cannot merge";case"trunk_red":return e.viewerMerged?"you merged the PR that landed this commit":"the default branch is failing";case"pr_approved":case"your_pr":case"own_ready":case"own_thread":return"it is your own PR";case"claude_review":return"findings are waiting to be posted";case"watched_repo_pr":return"nobody asked you directly";default:return e}case"ci_failing":return e.arm==="your_pr"?"your build is failing":e.viewerMerged?"you merged the PR that landed this commit":"trunk is failing in a repo you maintain";case"conflicts":return e.relevance==="direct"?"it is your PR":"it is someone else’s PR";case"stalled_review":{const r=El.stalledReviewHours;return e.severity==="high"?`open ${n(r.high)} or more`:e.severity==="warn"?`open ${n(r.warn)} to ${n(r.high)}`:`open under ${n(r.warn)}`}case"untouched_thread":{const r=El.untouchedThreadHours;return e.severity==="high"?`unanswered ${n(r.high)} or more`:e.severity==="warn"?`unanswered ${n(r.warn)} to ${n(r.high)}`:`unanswered under ${n(r.warn)}`}case"reviewer_load":{const r=El.reviewerLoadPending;return e.severity==="high"?`${r.high} or more reviews waiting`:e.severity==="warn"?`${r.warn} to ${r.high-1} reviews waiting`:`fewer than ${r.warn} reviews waiting`}case"reviewer_routing":return"a suggestion, never urgent";case"merge":case"update_branch":return e.relevance==="direct"?"it is your PR":"it is not your PR";case"security":return e.severity==="high"?"it names a known security advisory":"it is probably a security update";case"dependency_bump":return"an ordinary update, never urgent";default:return""}}function ZL(e,n,r){var s;return e==="my_turn"&&n&&r!=null?`Grouped by type in your order, then by Do next score. The top ${Al} are Do next.`:n?((s=Ko.find(a=>a.key===e))==null?void 0:s.groupByKind)===!0?`Security first, then bumps. Each is listed by Do next score, highest first. The top ${Al} are Do next.`:`Listed by Do next score, highest first. The top ${Al} are Do next.`:"Listed in the order the server sent."}function JL(e,n,r,s,a){const i=Ko.find(d=>d.key===e);return n==null&&((i==null?void 0:i.groupByKind)===!0||(i==null?void 0:i.groupByReason)===!0&&a!=null)?`Showing the first ${r} of ${s}.`:`Showing the top ${r} of ${s}. The rest score lower.`}function eF(e,n){var i,c;const r=n.indexById.get(e.id)??0,s={why:QL(e),whose:YL(e),colour:{severity:e.severity,word:w2[e.severity],reason:XL(e)}};if(r<0)return{...s,place:"In “Reviews waiting on people”, above the ranked list",order:"People are listed by how many reviews they owe, most first. They are not scored.",score:null};const a=(i=n.scores)==null?void 0:i[e.id];return{...s,place:`${HL(r+1)} of ${n.total} in ${n.viewName}`+(r<n.doNextCount?" · Do next":""),order:ZL(n.tab,a!=null,n.rules),score:a!=null?VL(a,((c=n.rules)==null?void 0:c.weights)??qo.weights):null}}const R2={high:"bg-red-500",warn:"bg-amber-500",info:"bg-sky-500"};function I2({label:e,children:n,width:r="w-[24rem]",align:s="end"}){const[a,i]=f.useState(!1),{refs:c,floatingStyles:d,context:u}=wa({open:a,onOpenChange:i,strategy:"fixed",placement:`bottom-${s}`,middleware:[oo(6),io({fallbackPlacements:[`top-${s}`]}),ri({padding:8})],whileElementsMounted:ni}),m=si(u,{escapeKey:!1}),{getReferenceProps:h,getFloatingProps:g}=lo([m]);return f.useEffect(()=>{if(a)return y2(()=>i(!1))},[a]),f.useEffect(()=>{if(!a)return;const x=y=>{y.key==="Escape"&&(y.stopImmediatePropagation(),i(!1))};return window.addEventListener("keydown",x,!0),()=>window.removeEventListener("keydown",x,!0)},[a]),t.jsxs(t.Fragment,{children:[t.jsx("button",{ref:c.setReference,...h(),type:"button",onClick:()=>i(x=>!x),"aria-expanded":a,"aria-label":e,className:`inline-flex shrink-0 items-center justify-center rounded-full p-0.5 transition-colors ${a?"text-gray-800 dark:text-gray-100":"text-gray-500 hover:text-gray-800 dark:text-gray-400 dark:hover:text-gray-100"}`,children:t.jsx(oc,{size:13})}),a&&t.jsx(ka,{children:t.jsx("div",{ref:c.setFloating,style:d,...g(),role:"dialog","aria-label":e,"data-noactivate":!0,className:`z-[60] ${r} max-w-[92vw] cursor-default rounded-lg border border-gray-200 bg-white p-3 text-[12px] leading-relaxed text-gray-700 shadow-lg dark:border-gray-700 dark:bg-gray-900 dark:text-gray-200`,children:n(()=>i(!1))})})]})}function T2({onClick:e}){return t.jsx("button",{type:"button",onClick:e,className:"mt-2.5 text-[12px] font-medium text-sky-700 hover:underline dark:text-sky-400",children:"How Pending works"})}function tF({onOpenGuide:e,rules:n}){const r=(n==null?void 0:n.weights)??qo.weights;return t.jsx(I2,{label:"How Pending is ordered",align:"start",children:s=>t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"font-semibold text-gray-900 dark:text-gray-50",children:"How Pending is ordered"}),t.jsxs("p",{className:"mt-1",children:["Everything waiting on you or your workspace, in ",Ko.length," tabs. The number on a tab is everything in it. Dependency updates and security alerts have their own tab, security first."]}),t.jsxs("p",{className:"mt-1.5",children:["Each tab lists its cards by score, highest first. The score weighs"," ",Dl("proximity")," (",Math.round(r.proximity*100),"%), ",Dl("stall")," (",Math.round(r.stall*100),"%) and ",Dl("relevance")," (",Math.round(r.relevance*100),"%). The top"," ",Al," are ",t.jsx("span",{className:"font-semibold",children:"Do next"}),".",n!=null&&n.preset!=="balanced"&&` Weights: ${C2(n.preset)}.`]}),n!=null&&t.jsx("p",{className:"mt-1.5",children:"My turn groups its cards by type first, in the order set in Settings."}),t.jsxs("p",{className:"mt-1.5",children:["The"," ",t.jsx(oc,{size:12,title:"info",className:"inline-block align-[-0.15em]"})," button on a card says why it sits where it does."]}),t.jsx(T2,{onClick:()=>{s(),e()}})]})})}const ny=f.createContext(null);function nF({card:e}){const n=f.useContext(ny);return n==null?null:t.jsx(I2,{label:"Why this card is here",children:r=>t.jsx(rF,{card:e,board:n,onOpenGuide:()=>{r(),n.onOpenGuide()}})})}function rF({card:e,board:n,onOpenGuide:r}){const s=f.useMemo(()=>eF(e,n),[e,n]);return t.jsxs("div",{className:"space-y-2",children:[t.jsxs("section",{children:[t.jsx("h3",{className:"text-[11px] font-semibold uppercase tracking-wide text-gray-500 dark:text-gray-400",children:"Why it is here"}),t.jsx("p",{className:"mt-0.5",children:s.why}),s.whose!=null&&t.jsx("p",{className:"mt-1",children:s.whose}),t.jsxs("p",{className:"mt-1 flex items-baseline gap-1.5",children:[t.jsx("span",{className:`inline-block h-2 w-2 shrink-0 translate-y-[-1px] rounded-full ${R2[s.colour.severity]}`,"aria-hidden":!0}),t.jsxs("span",{children:[t.jsx("span",{className:"font-medium",children:s.colour.word}),s.colour.reason!==""?`: ${s.colour.reason}.`:"."]})]})]}),t.jsxs("section",{children:[t.jsx("h3",{className:"text-[11px] font-semibold uppercase tracking-wide text-gray-500 dark:text-gray-400",children:"Where it sits"}),t.jsx("p",{className:"mt-0.5 font-medium text-gray-900 dark:text-gray-50",children:s.place}),t.jsx("p",{className:"mt-0.5",children:s.order})]}),s.score!=null&&t.jsxs("section",{children:[t.jsxs("h3",{className:"text-[11px] font-semibold uppercase tracking-wide text-gray-500 dark:text-gray-400",children:["Do next score: ",s.score.total," of 100"]}),t.jsx("table",{className:"mt-1 w-full border-collapse text-[12px]",children:t.jsx("tbody",{children:s.score.rows.map(a=>t.jsxs("tr",{className:"border-t border-gray-100 align-top first:border-t-0 dark:border-gray-800",children:[t.jsxs("td",{className:"py-1 pr-2",children:[t.jsx("div",{className:"font-medium",children:a.label}),t.jsx("div",{className:"text-[11px] text-gray-500 dark:text-gray-400",children:a.note})]}),t.jsxs("td",{className:"whitespace-nowrap py-1 text-right tabular-nums text-gray-600 dark:text-gray-300",children:[a.value," × ",a.weight,"%"]}),t.jsx("td",{className:"whitespace-nowrap py-1 pl-2 text-right font-medium tabular-nums",children:a.points})]},a.key))})})]}),t.jsx(T2,{onClick:r})]})}function kl({title:e,children:n}){return t.jsxs("section",{className:"space-y-2",children:[t.jsx("h3",{className:"text-base font-semibold text-gray-900 dark:text-gray-50",children:e}),n]})}const Ss="border-b border-gray-200 py-1.5 pr-3 text-left text-[13px] font-semibold text-gray-600 dark:border-gray-700 dark:text-gray-300",kt="border-b border-gray-100 py-1.5 pr-3 align-top dark:border-gray-800";function hn({severity:e}){return t.jsxs("span",{className:"inline-flex items-center gap-1.5 whitespace-nowrap",children:[t.jsx("span",{className:`inline-block h-2 w-2 rounded-full ${R2[e]}`,"aria-hidden":!0}),w2[e]]})}const sF={my_turn:"Things you owe an action on — see “When it is your turn” below.",fixing:"Failing builds you are on the hook for, and PRs with merge conflicts in repos you can push to.",review:"PRs whose requested review has not come, and PRs nobody has been asked to review. People with reviews waiting are listed above them.",threads:"Review comments with no reply and no later commit to their file.",land:"PRs GitHub will merge now, and PRs that need a branch update first.",deps:"PRs opened by dependency bots, security fixes first, and PRs a security tool flagged for a known advisory."},Lw={review_request:{appears:"Someone asks you to review a PR.",goes:"You submit a review."},mention:{appears:"Someone @-mentions you on an open PR.",goes:"You review, comment or push on it."},thread:{appears:"Someone replies in a review thread you started, or the code under it changes.",goes:"You reply (usually), or resolve the thread (always)."},thread_reply:{appears:"Someone replies after your comment in a thread someone else started.",goes:"You reply, or the thread is resolved."},comment_reply:{appears:"Someone comments on a PR after your last comment there.",goes:"You review, comment or push on it."},pushed_since:{appears:"Someone pushes to a PR after your last review or comment.",goes:"You review, comment or push."},own_ci_red:{appears:"The latest build on your open PR failed. Only if added in Settings.",goes:"The build passes."},own_conflicts:{appears:"Your PR conflicts with its base. Only if added in Settings.",goes:"The conflict is resolved."},trunk_red:{appears:"A default branch is failing. Only if added in Settings.",goes:"The branch goes green."},pr_approved:{appears:"Your PR has an approval and no “changes requested”.",goes:"It is merged or closed."},own_ready:{appears:"GitHub will merge your PR, or wants the branch updated. Only if added in Settings.",goes:"It merges, or stops being ready."},your_pr:{appears:"Your PR has new commits, comments or reviews since you last opened it here.",goes:"You open it."},own_thread:{appears:`A review comment on your PR has had no reply for ${ua(kh.untouchedThreadMinHours)}. Only if added in Settings.`,goes:"Someone replies or pushes to its file."},claude_review:{appears:"A Claude review finished with findings you have not posted. Local installs only.",goes:"You post them."},watched_repo_pr:{appears:"Someone else’s PR you have not touched, opened since the repo was added. Off unless turned on.",goes:"You review, comment or push."}};function aF({onClose:e,rules:n}){f.useEffect(()=>{Hp()},[]),f.useEffect(()=>{const b=w=>{w.key==="Escape"&&(w.stopImmediatePropagation(),e())};return window.addEventListener("keydown",b,!0),()=>window.removeEventListener("keydown",b,!0)},[e]);const r=qo,s=(n==null?void 0:n.weights)??r.weights,a=(n==null?void 0:n.myTurnOrder)??Oi,i=(n==null?void 0:n.myTurnOff)??[],c=b=>`${Math.round(b*100)}%`,d=Object.keys(r.proximity).slice().sort((b,w)=>r.proximity[w]-r.proximity[b]),u=[...r.stallBuckets.map(b=>`${ua(b.minHours)} or more: ${ma(b.risk)}`),`less: ${ma(r.stallBase)}`],m=["direct","maintained","none"].map(b=>`${S2[b]}: ${ma(r.relevanceWeight[b])}`),h=El.stalledReviewHours,g=El.untouchedThreadHours,x=El.reviewerLoadPending,y=kh;return t.jsx("div",{className:"fixed inset-0 z-[60] flex items-center justify-center bg-black/50 p-4",onClick:e,role:"presentation",children:t.jsxs("div",{className:"flex max-h-[85vh] w-[46rem] max-w-[94vw] flex-col rounded-lg border border-gray-200 bg-white shadow-xl dark:border-gray-700 dark:bg-gray-900",onClick:b=>b.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":"How Pending works",children:[t.jsxs("div",{className:"flex items-center justify-between border-b border-gray-200 px-5 py-3 dark:border-gray-800",children:[t.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-gray-50",children:"How Pending works"}),t.jsx("button",{type:"button",onClick:e,className:"flex items-center self-stretch text-gray-500 hover:text-gray-800 dark:text-gray-400 dark:hover:text-gray-100","aria-label":"Close (Esc)",children:t.jsx(Zt,{size:16})})]}),t.jsxs("div",{className:"min-h-0 flex-1 space-y-6 overflow-auto px-5 py-4 text-[15px] leading-relaxed text-gray-700 dark:text-gray-200",children:[t.jsxs("p",{children:["Pending is everything waiting on you or your workspace, in ",Ko.length," tabs. It is worked out fresh every time it loads. Nothing is stored and nothing can be dismissed: a card leaves when the work it describes is done."]}),t.jsxs(kl,{title:"The tabs",children:[t.jsxs("table",{className:"w-full border-collapse text-sm",children:[t.jsx("thead",{children:t.jsxs("tr",{children:[t.jsx("th",{className:Ss,children:"Tab"}),t.jsx("th",{className:Ss,children:"What is in it"})]})}),t.jsx("tbody",{children:Ko.map(b=>t.jsxs("tr",{children:[t.jsx("td",{className:`${kt} whitespace-nowrap font-medium`,children:is[b.key]}),t.jsx("td",{className:kt,children:sF[b.key]})]},b.key))})]}),t.jsxs("p",{children:["The number on a tab is everything in it. A tab lists up to ",y.boardListCap," of each kind of card and says when it holds more. Where a tab holds two kinds, the chips above the list narrow it to one."]}),t.jsxs("p",{children:[is.my_turn," also shows every default branch in the workspace above its cards, and an ",t.jsx("strong",{children:"Open PRs"})," button that lists every open PR. Neither is scored or counted in a tab."]})]}),t.jsxs(kl,{title:"Inside a tab",children:[t.jsxs("p",{children:["Cards are listed by score, highest first, except in two tabs that list in groups first. The top ",Al," are ",t.jsx("strong",{children:"Do next"}),"; the rest are"," ",t.jsx("strong",{children:"Everything else"}),"."]}),t.jsxs("p",{children:[is.my_turn," groups its cards by type, in the order set in Settings → My Turn."," ",is.deps," puts every security item before every bump. Inside each group, cards are listed by score. A PR a dependency bot opened is listed only in ",is.deps,", unless it is also your turn on it in ",is.my_turn,"."]}),t.jsxs("p",{children:["A card is only compared with the cards in its own tab. So a PR with two jobs appears twice, once in each job’s tab — a PR you were asked to review is in ",is.my_turn," ","(“",od.review_request,"”) and, if a thread on it is unanswered, in"," ",is.threads,". A type added under Settings → My Turn → Add to My Turn moves into"," ",is.my_turn," instead, so it is listed once."]})]}),t.jsxs(kl,{title:"The score",children:[t.jsx("p",{children:"Each card gets a score out of 100, made of three parts."}),t.jsxs("table",{className:"w-full border-collapse text-sm",children:[t.jsx("thead",{children:t.jsxs("tr",{children:[t.jsx("th",{className:Ss,children:"Part"}),t.jsx("th",{className:Ss,children:"Counts"}),t.jsx("th",{className:Ss,children:"How it is measured"})]})}),t.jsxs("tbody",{children:[t.jsxs("tr",{children:[t.jsx("td",{className:`${kt} font-medium`,children:$s.proximity}),t.jsx("td",{className:kt,children:c(s.proximity)}),t.jsxs("td",{className:kt,children:["The next step: ",d.map(b=>`${j2[b]} ${ma(r.proximity[b])}`).join(" · "),". Then: ",["conflicts","many_untouched_threads","small_change"].map(N2).join(", "),"."]})]}),t.jsxs("tr",{children:[t.jsx("td",{className:`${kt} font-medium`,children:$s.stall}),t.jsx("td",{className:kt,children:c(s.stall)}),t.jsxs("td",{className:kt,children:[u.join(" · "),". Measured from the moment that matters for the card: when you were asked, the last commit, or when the thread started."]})]}),t.jsxs("tr",{children:[t.jsx("td",{className:`${kt} font-medium`,children:$s.relevance}),t.jsx("td",{className:kt,children:c(s.relevance)}),t.jsxs("td",{className:kt,children:[m.join(" · "),"."]})]})]})]}),n!=null&&n.preset!=="balanced"&&t.jsxs("p",{children:[n.preset==="custom"?"These are your own weights.":`These are your weights (${C2(n.preset)}).`," ","Change them in Settings → My Turn."]}),t.jsx("p",{children:"Cards in one tab usually share their next step, so the order mostly comes down to how long each has waited and how small the change is."})]}),t.jsxs(kl,{title:"Colours",children:[t.jsx("p",{children:"The coloured edge on a card shows how urgent it is. It does not change the order."}),t.jsxs("table",{className:"w-full border-collapse text-sm",children:[t.jsx("thead",{children:t.jsxs("tr",{children:[t.jsx("th",{className:Ss,children:"Card"}),t.jsx("th",{className:Ss,children:"It appears when"}),t.jsx("th",{className:Ss,children:"Colour"})]})}),t.jsxs("tbody",{children:[t.jsxs("tr",{children:[t.jsx("td",{className:`${kt} font-medium`,children:"My turn"}),t.jsx("td",{className:kt,children:"You owe an action on a PR (next section)."}),t.jsx("td",{className:kt,children:"By type"})]}),t.jsxs("tr",{children:[t.jsx("td",{className:`${kt} font-medium`,children:Pn.ci_failing}),t.jsx("td",{className:kt,children:"The latest build on your open PR failed, or the default branch is failing in a repo you maintain."}),t.jsxs("td",{className:kt,children:[t.jsx(hn,{severity:"high"})," for your PR. For the branch, ",t.jsx(hn,{severity:"warn"}),", or"," ",t.jsx(hn,{severity:"high"})," if you merged the PR that landed the failing commit."]})]}),t.jsxs("tr",{children:[t.jsx("td",{className:`${kt} font-medium`,children:Pn.conflicts}),t.jsx("td",{className:kt,children:"A PR conflicts with its base, in a repo you can push to."}),t.jsxs("td",{className:kt,children:[t.jsx(hn,{severity:"high"})," if yours, otherwise ",t.jsx(hn,{severity:"warn"})]})]}),t.jsxs("tr",{children:[t.jsx("td",{className:`${kt} font-medium`,children:Pn.stalled_review}),t.jsxs("td",{className:kt,children:["A requested review has not arrived and the PR has been open more than"," ",ua(y.stalledReviewMinHours),"."]}),t.jsxs("td",{className:kt,children:[t.jsx(hn,{severity:"high"})," from ",ua(h.high),", ",t.jsx(hn,{severity:"warn"})," from"," ",ua(h.warn),", otherwise ",t.jsx(hn,{severity:"info"})]})]}),t.jsxs("tr",{children:[t.jsx("td",{className:`${kt} font-medium`,children:Pn.reviewer_routing}),t.jsxs("td",{className:kt,children:["Nobody has been asked and nobody has reviewed, and the PR is older than"," ",ua(y.routingMinAgeHours),". Reviewers are suggested for the top"," ",y.routingSuggestCap,"."]}),t.jsx("td",{className:kt,children:t.jsx(hn,{severity:"info"})})]}),t.jsxs("tr",{children:[t.jsx("td",{className:`${kt} font-medium`,children:Pn.reviewer_load}),t.jsxs("td",{className:kt,children:["Someone has requested reviews they have not done (the top ",y.reviewerLoadCap," ","people). Shown above the list in Waiting on review, and not scored."]}),t.jsxs("td",{className:kt,children:[t.jsx(hn,{severity:"high"})," from ",x.high,", ",t.jsx(hn,{severity:"warn"})," from ",x.warn,", otherwise ",t.jsx(hn,{severity:"info"})]})]}),t.jsxs("tr",{children:[t.jsx("td",{className:`${kt} font-medium`,children:Pn.untouched_thread}),t.jsxs("td",{className:kt,children:["A review comment has no reply and no later commit to its file, and is older than"," ",ua(y.untouchedThreadMinHours),"."]}),t.jsxs("td",{className:kt,children:[t.jsx(hn,{severity:"high"})," from ",ua(g.high),", ",t.jsx(hn,{severity:"warn"})," from"," ",ua(g.warn),", otherwise ",t.jsx(hn,{severity:"info"})]})]}),t.jsxs("tr",{children:[t.jsx("td",{className:`${kt} font-medium`,children:Pn.merge}),t.jsx("td",{className:kt,children:"GitHub will merge it now."}),t.jsxs("td",{className:kt,children:[t.jsx(hn,{severity:"warn"})," if yours, otherwise ",t.jsx(hn,{severity:"info"})]})]}),t.jsxs("tr",{children:[t.jsx("td",{className:`${kt} font-medium`,children:Pn.update_branch}),t.jsx("td",{className:kt,children:"GitHub will not merge it until the branch is updated."}),t.jsxs("td",{className:kt,children:[t.jsx(hn,{severity:"warn"})," if yours, otherwise ",t.jsx(hn,{severity:"info"})]})]}),t.jsxs("tr",{children:[t.jsx("td",{className:`${kt} font-medium`,children:Pn.security}),t.jsx("td",{className:kt,children:"A dependency bot’s PR fixes a known advisory, or a security tool flagged one on a PR."}),t.jsxs("td",{className:kt,children:[t.jsx(hn,{severity:"high"})," (",t.jsx(hn,{severity:"warn"})," when we could only infer it)"]})]}),t.jsxs("tr",{children:[t.jsx("td",{className:`${kt} font-medium`,children:Pn.dependency_bump}),t.jsx("td",{className:kt,children:"Any other PR a dependency bot opened."}),t.jsx("td",{className:kt,children:t.jsx(hn,{severity:"info"})})]})]})]}),t.jsxs("p",{children:["Most cards cover open, non-draft PRs with activity in the last ",y.maxQuietDays," days."]})]}),t.jsx(kl,{title:"Who opened it",children:t.jsxs("p",{children:["Every card names who opened the PR. A person shows with their picture and name. Automation shows as a chip: the tool’s name when we know it, otherwise what it does, such as ",wf.dependency," or ",wf.code_agent,". Some tools open PRs with a person’s account; those show the tool, then “via” the person. People and Automation above a tab narrow it to one or the other. Coding agents count as automation."]})}),t.jsxs(kl,{title:"When it is your turn",children:[t.jsx("p",{children:"A My turn card means you owe an action. These put one on the board, in the order My turn groups them:"}),t.jsxs("table",{className:"w-full border-collapse text-sm",children:[t.jsx("thead",{children:t.jsxs("tr",{children:[t.jsx("th",{className:Ss,children:"Card"}),t.jsx("th",{className:Ss,children:"It appears when"}),t.jsx("th",{className:Ss,children:"It goes away when"}),t.jsx("th",{className:Ss,children:"Colour"})]})}),t.jsx("tbody",{children:a.map(b=>t.jsxs("tr",{children:[t.jsx("td",{className:`${kt} font-medium`,children:od[b]}),t.jsx("td",{className:kt,children:Lw[b].appears}),t.jsx("td",{className:kt,children:Lw[b].goes}),t.jsxs("td",{className:kt,children:[t.jsx(hn,{severity:M$[b]}),b==="trunk_red"&&t.jsxs(t.Fragment,{children:[", or ",t.jsx(hn,{severity:"high"})," if you merged the PR that landed it"]})]})]},b))})]}),i.length>0&&t.jsxs("p",{children:["Switched off in Settings:"," ",i.map(b=>Ci[b]).join(", "),"."]}),t.jsxs("p",{children:["Only real actions count: a review, a comment or a commit. Viewing a PR does not, except for “",od.your_pr,"”. Bot comments and bot pushes never make it your turn again."]}),t.jsxs("p",{children:["The label on a card says how it relates to you. ",t.jsx("strong",{children:"Your turn"}),": it names you — you were asked, mentioned or answered, it is your PR or thread, or you added its type in Settings. ",t.jsx("strong",{children:"In your repos"}),": a new PR in a repo you can push to or have merged a PR into. ",t.jsx("strong",{children:"Review or reply"}),": neither. Muting a repo in Settings keeps its cards on the board but stops them claiming your turn."]})]})]})]})})}const oF={high:{border:"border-l-red-400 dark:border-l-red-500",dot:"bg-red-500"},warn:{border:"border-l-amber-400 dark:border-l-amber-500",dot:"bg-amber-500"},info:{border:"border-l-sky-400 dark:border-l-sky-500",dot:"bg-sky-500"}},$2={clean:"clean",dirty:"conflicts",unstable:"unstable",blocked:"blocked",behind:"behind trunk",has_hooks:"has hooks",unknown:null};function iF(e){return e.mergeStateStatus==null||e.mergeStateStatus==="dirty"?null:$2[e.mergeStateStatus]}function lF(e){return e.inMergeQueue===!0?null:$2[e.mergeStateStatus]}function cF(e){return e.kind!=="my_turn"?!1:e.relevance==="direct"||e.relevance==="maintained"}function Sf(e){return e<48?`${e}h`:`${Math.round(e/24)}d`}function dF(e){const n=Cf(e);return n==null?null:`opened ${n}`}function Cf(e){const n=ry(e);return n==null?null:Sf(Math.round(n/36e5))}function uF(e,n){const r=hF(e);if(r==null)return!1;const s=pF(n);if(s==null)return!0;const a=!(r.unit===s.unit&&r.value===s.value),i=Cf(e)!==Cf(n);return a&&i}function hF(e){const n=ry(e);if(n==null)return null;const r=6e4,s=60*r,a=24*s;return n<r?null:n<s?{unit:"min",value:Math.round(n/r)}:n<a?{unit:"hour",value:Math.round(n/s)}:n<30*a?{unit:"day",value:Math.round(n/a)}:null}function pF(e){const n=ry(e);if(n==null)return null;const r=Math.round(n/36e5);return r<48?{unit:"hour",value:r}:{unit:"day",value:Math.round(r/24)}}function ry(e){if(e==null)return null;const n=Date.parse(e);return Number.isFinite(n)?Math.max(0,Date.now()-n):null}function Kn(e,n){const r=e.authorId!=null?n.get(e.authorId):void 0;return{id:e.prId,number:e.prNumber,title:e.prTitle,repoFullName:e.repoFullName,authorLogin:(r==null?void 0:r.githubLogin)??null,authorDisplayName:(r==null?void 0:r.displayName)??null,authorAvatarUrl:(r==null?void 0:r.avatarUrl)??null}}function id({id:e,usersById:n}){const r=n.get(e);return t.jsxs("span",{className:"inline-flex items-center gap-1 rounded bg-gray-500/10 px-1.5 py-0.5 text-[11px]",children:[t.jsx(gn,{user:r,size:13}),t.jsx(mr,{user:r,fallbackId:e})]})}function Rf({kind:e,title:n}){const r=e!=null?ds(e):null;return t.jsxs("span",{className:`inline-flex items-center gap-1 rounded px-1.5 py-0.5 font-medium${r==null?" bg-gray-500/10 text-gray-600 dark:text-gray-300":""}`,style:r!=null?{...pn(r.color),background:`${r.color}1a`}:void 0,title:n??"This thread was opened by an automated reviewer",children:[t.jsx(Lt,{size:12}),sy(e)]})}function sy(e){return e!=null?ds(e).label:"Bot"}function mF(e){return e.authorIsBot!==!0?null:sy(e.authorBotKind??null)}const gF=new Set(["in_house","vendor","pierre"]);function _2(e){return e!=null&&!gF.has(e)?ds(e).label:null}function fF(e,n){const r=e.authorId!=null?n.get(e.authorId):void 0,s=e.authorId==null?"Deleted account":Dt(r,e.authorId),a=e.automation??null;if(a==null)return{mode:"person",chip:null,chipKind:null,name:s,avatarUserId:e.authorId};const i=_2(a.kind),c=i??wf[a.role],d=i!=null?a.kind:null;return a.source==="marker"?{mode:"via",chip:c,chipKind:d,name:s,avatarUserId:e.authorId}:{mode:"automation",chip:c,chipKind:d,name:i!=null?null:(r==null?void 0:r.githubLogin)??Dt(r,e.authorId),avatarUserId:r!=null&&r.avatarUrl?e.authorId:null}}function xF(e){const n=e.avatarUserId!=null?["avatar"]:[],r=e.chip!=null?["chip"]:[],s=e.name!=null?["name"]:[];return e.mode==="via"?[...r,"via",...n,...s]:[...n,...r,...s]}function P2({pr:e,usersById:n,repoId:r}){const s=fF(e,n),a=s.avatarUserId!=null?n.get(s.avatarUserId):void 0,i=s.chipKind!=null?ds(s.chipKind):null,c=d=>{switch(d){case"avatar":return t.jsx(gn,{user:a,size:13},d);case"chip":return t.jsxs("span",{className:`inline-flex items-center gap-1 rounded px-1.5 py-0.5 font-medium${i==null?" bg-gray-500/10 text-gray-600 dark:text-gray-300":""}`,style:i!=null?{...pn(i.color),background:`${i.color}1a`}:void 0,children:[t.jsx(Lt,{size:12}),s.chip]},d);case"via":return t.jsx("span",{children:"via"},d);case"name":return s.avatarUserId!=null?t.jsx(mr,{user:a,fallbackId:s.avatarUserId,repoId:r},d):t.jsx("span",{children:s.name},d)}};return t.jsx("span",{className:"inline-flex min-w-0 flex-wrap items-center gap-1 text-[11px] text-gray-600 dark:text-gray-300",children:xF(s).map(c)})}function E2(e){return e==="failure"||e==="error"}function A2(e,n){const r=(e??[]).filter(a=>a.length>0);if(r.length===0)return null;const s=Math.max(0,(n??r.length)-r.length);return{names:r.join(", "),more:s>0?`and ${s} more`:null}}function M2({parts:e}){return t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"min-w-0 truncate",title:e.names,children:e.names}),e.more!=null&&t.jsxs(t.Fragment,{children:[" ",t.jsx("span",{className:"shrink-0",children:e.more})]})]})}function yF({pr:e}){const n=e.ciStatus?Rr[e.ciStatus]:null,r=E2(e.ciStatus)?A2(e.failingChecks,e.failingCheckTotal):null;return t.jsxs("span",{className:"inline-flex min-w-0 max-w-full items-center gap-1",title:(n==null?void 0:n.label)??"no checks",children:[t.jsx("span",{className:"inline-block h-2 w-2 shrink-0 rounded-full",style:n?{background:n.color}:{boxShadow:"inset 0 0 0 1px #9ca3af"},"aria-hidden":!0}),t.jsxs("span",{className:"shrink-0",children:[(n==null?void 0:n.label)??"no checks",r!=null&&":"]}),r!=null&&t.jsxs(t.Fragment,{children:[" ",t.jsx(M2,{parts:r})]})]})}function bF({card:e}){const n=E2(e.ciStatus)?A2(e.failingChecks,e.failingCheckTotal):null;if(n==null)return null;const r=Nx.failure.icon;return t.jsxs("div",{className:"mt-1 flex min-w-0 items-center gap-1 text-xs text-red-600 dark:text-red-400",children:[t.jsx(r,{size:12,className:"shrink-0"}),t.jsx("span",{className:"sr-only",children:"Failing checks: "}),t.jsx(M2,{parts:n})]})}function Fo({pr:e,usersById:n}){const r=n!=null&&"automation"in e;return t.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px] text-gray-500 dark:text-gray-400",children:[r&&t.jsx(P2,{pr:{authorId:e.authorId??null,automation:e.automation},usersById:n}),t.jsx(yF,{pr:e}),t.jsxs("span",{children:[e.changedFiles," file",e.changedFiles===1?"":"s"]}),t.jsxs("span",{className:"font-mono",children:[t.jsxs("span",{className:"text-green-600 dark:text-green-400",children:["+",e.additions]})," ",t.jsxs("span",{className:"text-red-500 dark:text-red-400",children:["−",e.deletions]})]}),t.jsx(Up,{pr:e}),t.jsx(Md,{pr:e}),!r&&mF(e)!=null&&t.jsx(Rf,{kind:e.authorBotKind??null,title:e.authorBotKind!=null?"This pull request was opened by an automated author":"This pull request was opened by automation whose vendor we don’t recognise"})]})}function vF(e){const n=e.reviewChangesRequested===!0,r=e.reviewApprovals??0,s=e.reviewerCount??0,a=e.reviewDecision??null;if(!n&&r===0&&s===0&&a==null)return null;const i=`${r} approval${r===1?"":"s"}`;let c,d;n?(d="changes_requested",c=r>0?`Changes requested · ${i}`:"Changes requested"):r>0?(d="approved",c=i):s>0?(d="commented",c="No approval yet"):(d=null,c="No reviews yet");let u=null;return a==="review_required"?u="GitHub: review required":a==="approved"&&r===0?u="GitHub: approved":a==="changes_requested"&&!n?u="GitHub: changes requested":a==null&&!n&&r===0&&(u="GitHub: no review required"),{ours:c,standing:d,github:u}}const Fw={changes_requested:0,approved:1,commented:2,dismissed:3};function Ow(e){return e==="approved"?"approved":e==="changes_requested"?"requested changes":e==="commented"?"commented":"review dismissed"}function kF(e){const n=e.reviewers??[],r=e.reviewerCount??n.length,s=n.filter(c=>!c.isBot),a=n.filter(c=>c.isBot);let i=null;if(a.length>0){const c=a.reduce((h,g)=>Fw[g.standing]<Fw[h]?g.standing:h,a[0].standing),d=a.every(h=>h.standing===c),u=a.length,m=u===1?"":"s";i={count:u,label:d?c==="dismissed"?`${u} bot review${m} dismissed`:`${u} bot${m} ${Ow(c)}`:`${u} bots reviewed`,title:a.map(h=>`${sy(h.botKind)} ${Ow(h.standing)}`).join(" · "),standing:c}}return{humans:s,bots:i,total:r,moreCount:Math.max(0,r-n.length),complete:n.length===r}}function wF({reviewer:e,usersById:n}){const r=$h[e.standing],s=r.icon,a=n.get(e.userId);return t.jsxs("span",{className:`inline-flex items-center gap-1 rounded px-1.5 py-0.5 ${r.cls}`,title:`${r.title} · ${Nt(e.standingAt)}`,children:[s!=null&&t.jsx(s,{size:11}),t.jsx(gn,{user:a,size:13}),t.jsx(mr,{user:a,fallbackId:e.userId})]})}function jF({reply:e,openLabel:n,onOpen:r}){const[s,a]=f.useState(!1),[i,c]=f.useState(!1),d=f.useRef(null);return f.useLayoutEffect(()=>{const u=d.current;u&&!s&&c(u.scrollHeight>u.clientHeight+1)},[e.body,s]),t.jsxs("div",{className:"mt-1.5 border-l-2 border-gray-300 pl-2 dark:border-gray-600","data-noactivate":!0,children:[t.jsx("div",{ref:d,className:`text-[12px] text-gray-700 dark:text-gray-300 ${s?"":"max-h-[4.6rem] overflow-hidden [&_img]:hidden"}`,children:t.jsx(gr,{children:e.body})}),(i||s||e.truncated)&&t.jsxs("div",{className:"mt-0.5 flex gap-3 text-[11px]",children:[(i||s)&&t.jsx("button",{type:"button",className:"text-gray-600 hover:underline dark:text-gray-300",onClick:()=>a(u=>!u),children:s?"Show less":"Show more"}),e.truncated&&(s||!i)&&t.jsx("button",{type:"button",className:"text-gray-600 hover:underline dark:text-gray-300",onClick:r,children:n})]})]})}function NF({ball:e,usersById:n}){const r=e.commits??[];if(r.length===0)return null;const a=new Set(r.map(c=>c.authorId)).size>1,i=Math.max(0,(e.humanCommitsAfter??r.length)-r.length);return t.jsxs("ul",{className:"mt-1.5 space-y-0.5 text-[12px] text-gray-700 dark:text-gray-300",children:[r.map(c=>{var u;const d=c.authorId!=null?(u=n.get(c.authorId))==null?void 0:u.githubLogin:void 0;return t.jsxs("li",{className:"flex min-w-0 items-baseline gap-2",children:[t.jsx("span",{className:"shrink-0 font-mono text-[11px] text-gray-500 dark:text-gray-400",children:c.sha.slice(0,7)}),c.headline!=null?t.jsx("span",{className:"min-w-0 truncate",children:c.headline}):t.jsx("span",{className:"min-w-0 truncate text-gray-500 dark:text-gray-400",children:"Message not synced yet"}),a&&d!=null&&t.jsxs("span",{className:"shrink-0 text-[11px] text-gray-500 dark:text-gray-400",children:["@",d]})]},c.sha)}),i>0&&t.jsxs("li",{className:"text-[11px] text-gray-500 dark:text-gray-400",children:["and ",i," more"]})]})}function ki({pr:e,usersById:n}){const r=vF(e),s=kF(e),a=!s.complete&&s.moreCount>0,i=s.humans.length>0||s.bots!=null||a;if(r==null&&!i)return null;const c=(r==null?void 0:r.standing)!=null?$h[r.standing]:null,d=(c==null?void 0:c.icon)??null;return t.jsxs(t.Fragment,{children:[r!=null&&t.jsxs("div",{className:"mt-1.5 flex flex-wrap items-center gap-x-2 gap-y-1 text-[11px]",children:[t.jsxs("span",{className:`inline-flex items-center gap-1 font-medium ${(c==null?void 0:c.ink)??"text-gray-500 dark:text-gray-400"}`,children:[d!=null&&t.jsx(d,{size:11}),r.ours]}),r.github!=null&&t.jsx("span",{className:"text-gray-500 dark:text-gray-400",title:"GitHub’s own review decision — what this repository’s rules say about the merge, which is a different question from who has reviewed.",children:r.github})]}),i&&t.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-1.5 text-[11px]",children:[s.humans.map(u=>t.jsx(wF,{reviewer:u,usersById:n},u.userId)),s.bots!=null&&t.jsxs("span",{className:`inline-flex items-center gap-1 rounded px-1.5 py-0.5 font-medium ${$h[s.bots.standing].cls}`,title:s.bots.title,children:[t.jsx(Lt,{size:11}),s.bots.label]}),a&&t.jsx("span",{className:"text-gray-500 dark:text-gray-400",title:`${s.total} reviewers have a standing on this pull request. The other ${s.moreCount} are past the cap, or have no GitHub account left to name.`,children:s.humans.length>0||s.bots!=null?`+${s.moreCount} more`:`${s.moreCount} reviewer${s.moreCount===1?"":"s"}`})]})]})}function ch({prId:e}){const[n,r]=f.useState(!1);return t.jsxs("div",{className:"mt-2",children:[t.jsxs("button",{type:"button",onClick:()=>r(s=>!s),className:"text-[11px] font-medium text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200",children:[t.jsx(Mt,{dir:n?"down":"right",size:10,className:"inline-block align-[-0.1em]"})," ","PR summary"]}),n&&t.jsx(SF,{prId:e})]})}function SF({prId:e}){const{data:n,isLoading:r}=ya(e);if(r)return t.jsx("div",{className:"mt-1 text-[11px] text-gray-400",children:"Loading…"});if(!n)return t.jsx("div",{className:"mt-1 text-[11px] text-gray-400",children:"Couldn’t load this PR."});const s=n.body!=null&&n.body.trim()!=="";return t.jsxs("div",{className:"mt-1 space-y-2 rounded border border-gray-200 bg-gray-50 p-2 dark:border-gray-800 dark:bg-gray-900/40",children:[s?t.jsx("div",{className:"max-h-64 overflow-auto text-sm",children:t.jsx(gr,{children:n.body})}):t.jsx("div",{className:"text-[11px] italic text-gray-400",children:"No PR description."}),t.jsx(O5,{pr:n})]})}function CF({card:e}){const{data:n,isLoading:r}=Sp(e.threadId),{data:s}=An(),a=f.useMemo(()=>Rn(s),[s]),i=`https://github.com/${e.repoFullName}/pull/${e.prNumber}`;return r?t.jsx("div",{className:"px-1 py-2 text-xs text-gray-400",children:"Loading conversation…"}):n?t.jsx(Li,{thread:n,usersById:a,prUrl:i,repoId:e.repoId}):t.jsx("div",{className:"px-1 py-2 text-xs text-gray-400",children:"Couldn’t load this conversation."})}function RF({card:e,usersById:n}){const r=e.suggestedReviewers;return r.length===0?null:t.jsxs("div",{className:"mt-1.5 space-y-1","data-noactivate":!0,children:[t.jsx("div",{className:"text-[11px] font-medium text-gray-500 dark:text-gray-400",children:"Suggested reviewers"}),t.jsx("ul",{className:"space-y-1",children:r.map(s=>t.jsx(IF,{prId:e.prId,suggestion:s,viewerCanPush:e.viewerCanPush,usersById:n},OS(s)))})]})}function IF({prId:e,suggestion:n,viewerCanPush:r,usersById:s}){const a=OS(n),i=r?kP(n):null,c=YS(e,a),d=lE(e,a),u=wP(n,s);return t.jsxs("li",{"data-testid":"suggested-reviewer",className:"flex flex-wrap items-center gap-1.5 text-[11px] text-gray-500 dark:text-gray-400",children:[n.kind==="team"?t.jsxs("span",{className:"inline-flex items-center gap-1 rounded bg-gray-500/10 px-1.5 py-0.5 text-[11px] font-medium",children:["@",n.teamName]}):n.userId!=null?t.jsx(id,{id:n.userId,usersById:s}):t.jsxs("span",{className:"inline-flex items-center gap-1 rounded bg-gray-500/10 px-1.5 py-0.5 text-[11px]",children:["@",n.login]}),t.jsx("span",{children:n.reason}),i!=null&&(d.status==="success"?t.jsxs("span",{role:"status",className:"inline-flex items-center gap-1 font-medium text-green-700 dark:text-green-400",children:[t.jsx(pr,{size:11,className:"inline-block align-[-0.1em]"})," Requested"]}):t.jsx("button",{type:"button",onClick:()=>c.mutate(i),disabled:d.status==="pending","aria-label":d.status==="pending"?`Assigning ${u}`:`Assign ${u}`,title:`Ask ${u} to review this PR on GitHub`,className:"rounded border border-violet-300 px-1.5 py-0.5 font-medium text-violet-700 hover:bg-violet-50 disabled:opacity-50 dark:border-violet-700 dark:text-violet-300 dark:hover:bg-violet-900/20",children:d.status==="pending"?"Assigning…":"Assign"})),i!=null&&d.status==="error"&&t.jsx("span",{role:"alert",className:"basis-full text-[12px] text-red-600 dark:text-red-400",children:d.error})]})}function Dw({card:e}){const n=e.reason==="trunk_red"?{kind:"repo",id:e.repoId}:{kind:"pr",id:e.prId},r=e.reason==="trunk_red"?e.repoFullName:`${e.repoFullName} #${e.prNumber}`,s=bE(n,r);return t.jsxs("div",{className:"mt-2 flex flex-wrap items-baseline gap-2",children:[e.reason==="your_pr"&&t.jsx("span",{className:"text-[11px] italic text-gray-500 dark:text-gray-400",children:"Opening the PR marks it seen — this card clears as soon as you come back."}),t.jsx("button",{type:"button",onClick:()=>s.mutate(),disabled:s.isPending,title:"Take this off My turn until something new happens on it",className:"ml-auto rounded px-1.5 py-0.5 text-[12px] text-gray-500 hover:bg-gray-100 hover:text-gray-800 disabled:opacity-60 dark:text-gray-400 dark:hover:bg-gray-800 dark:hover:text-gray-100",children:s.isPending?"Dismissing…":"Dismiss"}),s.isError&&t.jsx("span",{className:"text-[12px] text-red-600 dark:text-red-400",children:"Couldn’t dismiss it."})]})}function If(e){const n=e.inMergeQueue===!0,r=Pi({mergeable:e.mergeable??"unknown",mergeStateStatus:e.mergeStateStatus??"unknown",inMergeQueue:n}),s=e.kind==="security"||e.kind==="dependency_bump",a=!s;return e.viewerCanPush?e.kind==="security"&&!e.dependencyUpdate?{show:!1,action:null,verdict:r,verdictLine:a,queued:n}:s?{show:!0,action:r.verdict==="behind"?"update_branch":r.canMerge?"merge":null,verdict:r,verdictLine:a,queued:n}:{show:!0,action:e.kind==="update_branch"?r.verdict==="behind"?"update_branch":null:r.canMerge?"merge":null,verdict:r,verdictLine:a,queued:n}:{show:!1,action:null,verdict:r,verdictLine:a,queued:n}}function TF(e){var n;switch(e.kind){case"merge":case"update_branch":return e;case"security":case"dependency_bump":return e.kind==="security"&&!e.dependencyUpdate||e.depState==="conflicts"?null:e;case"my_turn":return e.reason==="trunk_red"?null:((n=e.own)==null?void 0:n.kind)==="ready"?O2(e,e.own):null;default:return null}}function L2(e){const n=G(c=>c.workspaceId),r=XS(["attention-cards",dt(n)]),{data:s,dataUpdatedAt:a}=_x(e.prId,!1);return{queued:Yx({inMergeQueue:e.inMergeQueue,mergeQueueEntryState:e.mergeQueueEntryState,observedAt:r},{info:s==null?void 0:s.mergeQueue,observedAt:a})!=null,cardsAt:r}}function $F(e){const n=If(e),r=Di(e.prId),{queued:s}=L2(e);return n.show&&r==null&&s}function F2({queue:e}){return t.jsxs("span",{className:`inline-flex items-center gap-1 rounded px-1.5 py-0.5 font-medium normal-case tracking-normal ${e.tone==="bad"?"bg-red-500/10 text-red-700 dark:text-red-300":"bg-gray-500/10 text-gray-600 dark:text-gray-300"}`,title:e.title,children:[e.tone==="bad"?t.jsx(Jt,{size:11}):t.jsx(bp,{size:11}),e.label]})}function _F({card:e}){const n="inMergeQueue"in e?g2(e):null;if(n==null)return null;const r=TF(e);return r==null?t.jsx(F2,{queue:n}):t.jsx(PF,{card:r,queue:n})}function PF({card:e,queue:n}){return $F(e)?null:t.jsx(F2,{queue:n})}function Tf({card:e}){const n=If(e),r=Di(e.prId),s=JS(e.prId),a=Or({mutationKey:VS(e.prId)})>0,i=Or({mutationKey:QS(e.prId)})>0,c=a?"Merging…":i?"Updating the branch…":null,{queued:d,cardsAt:u}=L2(e),m=d===n.queued?n:If({...e,inMergeQueue:d});return n.show?t.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2","data-noactivate":!0,children:[c!=null?t.jsx("span",{className:"text-[11px] font-medium text-gray-600 dark:text-gray-300",children:c}):r!=null?r.phase==="queued"&&r.enqueuedAt!=null?null:t.jsx("span",{className:"text-[11px] text-gray-500 dark:text-gray-400",children:Qx(r)}):s!=null?t.jsxs("span",{className:"text-[11px] text-gray-500 dark:text-gray-400",children:[t.jsx(Jt,{size:11,className:"mr-1 inline-block align-[-0.1em]"}),qp[s.state]??"Auto-merge stopped",s.lastReason!=null&&t.jsxs("span",{className:"ml-1",children:["— ",s.lastReason]})]}):d?null:m.action==null&&m.verdictLine?t.jsxs("span",{className:`text-[11px] font-medium ${Sx[m.verdict.tone]}`,children:[m.verdict.label,m.verdict.detail!=null&&t.jsxs("span",{className:"ml-1 font-normal text-gray-500 dark:text-gray-400",children:["— ",m.verdict.detail]})]}):null,r==null&&(m.action!=null||d)&&t.jsx(x2,{prId:e.prId,githubUrl:e.githubUrl,label:m.action==="update_branch"?"Update branch":"Merge",inMergeQueue:e.inMergeQueue,mergeQueueEntryState:e.mergeQueueEntryState,syncedAt:u,showQueuePosition:!1}),(!d||r!=null)&&t.jsx(Jx,{prId:e.prId,eager:!1,inMergeQueue:e.inMergeQueue,mergeQueueEntryState:e.mergeQueueEntryState,syncedAt:u})]}):null}function $f({card:e}){const n=Di(e.prId),r=e.kind==="conflicts"?!0:e.viewerCanPush;return!f2({state:"open",verdict:"conflicts",viewerCanPush:r})&&n==null?null:t.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2","data-noactivate":!0,children:[t.jsx(Zx,{state:"open",verdict:"conflicts",viewerCanPush:r,target:{prId:e.prId,repoId:e.repoId,repoFullName:e.repoFullName,prNumber:e.prNumber,prTitle:e.prTitle,githubUrl:e.githubUrl}}),n!=null&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"text-[11px] text-gray-500 dark:text-gray-400",children:Qx(n)}),t.jsx(Jx,{prId:e.prId,eager:!1})]})]})}function EF({card:e}){return e.kind==="security"&&!e.dependencyUpdate?null:e.depState==="conflicts"?t.jsx($f,{card:e}):t.jsx(Tf,{card:e})}const AF=/[A-Za-z0-9_-]/,Bw=e=>e==null||!AF.test(e);function Ww(e,n){const r=[...n].sort((c,d)=>d.length-c.length),s=[];let a="",i=0;for(;i<e.length;){const c=Bw(e[i-1])?r.find(d=>e.startsWith(d,i)&&Bw(e[i+d.length])):void 0;if(c==null){a+=e[i],i+=1;continue}a!==""&&s.push({text:a}),a="",s.push({id:c,href:mn(PS(c))}),i+=c.length}return a!==""&&s.push({text:a}),s}function MF(e,n=new Set){const r=e.filter(a=>!n.has(a)),s=r.slice(0,3);return{chips:s.map(a=>({id:a,href:mn(PS(a))})),more:r.length-s.length}}function LF(e,n){var c;const r=e.source==="reviewer"?_2(e.vendorKind)??((c=n.get(e.authorId))==null?void 0:c.githubLogin)??Dt(void 0,e.authorId):uL[e.source],[s,...a]=e.advisoryIds,i=s==null?"a known advisory":a.length>0?`${s} and ${a.length} more`:s;return{lead:`${r} flagged ${i}`,where:e.surface==="thread"?"in a review thread":null}}function FF({card:e,usersById:n,onOpenThread:r}){const s=e.fix==="inferred"&&e.alertCount===0,a=s?"bg-amber-500/10 text-amber-700 dark:text-amber-400":"bg-red-500/10 text-red-700 dark:text-red-300",i=s?"text-amber-600 dark:text-amber-400":"text-red-600 dark:text-red-400",c=e.advisoryIds,d=e.detail!==""?Ww(e.detail,c):[],u=e.alerts.map(w=>{const k=LF(w,n);return{alert:w,where:k.where,parts:Ww(k.lead,c)}}),m=new Set([...d,...u.flatMap(w=>w.parts)].flatMap(w=>"id"in w?[w.id]:[])),{chips:h,more:g}=MF(c,m),x=e.alertCount-e.alerts.length,y=(w,k)=>w.href!=null?t.jsxs("a",{href:w.href,target:"_blank",rel:"noreferrer noopener",onClick:j=>j.stopPropagation(),className:`inline-flex items-center gap-1 rounded px-1.5 py-px font-mono text-[11px] hover:underline ${a}`,title:"Open the advisory",children:[w.id,t.jsx(_t,{size:10})]},k):t.jsx("span",{className:`rounded px-1.5 py-px font-mono text-[11px] ${a}`,children:w.id},k),b=w=>w.map((k,j)=>"id"in k?y(k,`${j}`):t.jsx("span",{children:k.text},j));return t.jsxs("div",{className:"mt-1.5 space-y-1 text-[12px] text-gray-600 dark:text-gray-300",children:[d.length>0&&t.jsxs("p",{className:"flex items-start gap-1.5",children:[t.jsx(Nk,{size:12,className:`mt-0.5 shrink-0 ${i}`}),t.jsx("span",{className:"min-w-0",children:b(d)})]}),u.map(({alert:w,where:k,parts:j},N)=>t.jsxs("p",{className:"flex items-start gap-1.5",children:[t.jsx(Nk,{size:12,className:`mt-0.5 shrink-0 ${i}`}),t.jsxs("span",{className:"min-w-0",children:[b(j),k!=null&&(w.threadId!=null?t.jsxs(t.Fragment,{children:[" ",t.jsx("button",{type:"button",onClick:()=>r(w.threadId),className:"text-left underline decoration-dotted underline-offset-2 hover:decoration-solid",title:"Open this review thread",children:k})]}):` ${k}`)]})]},`${w.source}:${w.at}:${N}`)),(h.length>0||g>0)&&t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 pl-[18px] text-[11px]",children:[h.map(w=>y(w,w.id)),g>0&&t.jsxs("span",{className:"text-gray-500 dark:text-gray-400",children:["+",g," more"]})]}),x>0&&t.jsxs("p",{className:"pl-[18px] text-gray-500 dark:text-gray-400",children:["+",x," more ",x===1?"alert":"alerts"]})]})}function ca({card:e,right:n,openedAt:r,clockAt:s,onActivate:a,children:i,innerRef:c,flash:d=!1,why:u}){var k;const m=oF[e.severity],h=cF(e),g=f.useContext(ny),x=u??((k=g==null?void 0:g.whyById)==null?void 0:k.get(e.id)),y=dF(r),b=y==null||s===void 0||uF(s,r),w=a?j=>{j.target.closest("a,button,textarea,input,[data-noactivate]")||a()}:void 0;return t.jsxs("li",{ref:c,onClick:w,className:`rounded-lg border border-l-4 border-gray-200 bg-white p-3 dark:border-gray-800 dark:bg-gray-900/40 ${m.border}${d?" ring-2 ring-sky-400/70":""}${a?" cursor-pointer hover:bg-gray-50/70 dark:hover:bg-gray-900/60":""}`,children:[t.jsxs("div",{className:"mb-1.5 flex flex-wrap items-center gap-2 text-[11px]",children:[t.jsx("span",{className:`inline-block h-1.5 w-1.5 rounded-full ${m.dot}`,"aria-hidden":!0}),t.jsx("span",{className:`uppercase tracking-wide ${h?"font-bold text-gray-700 dark:text-gray-200":"font-semibold text-gray-500 dark:text-gray-400"}`,children:iL(e)}),t.jsx(_F,{card:e}),e.kind==="my_turn"&&e.muted===!0&&t.jsx("span",{className:"rounded bg-gray-500/10 px-1.5 py-0.5 font-medium normal-case tracking-normal text-gray-500 dark:text-gray-400",title:"Pending items from this repository are muted — they still appear here, but they don’t claim your turn and don’t notify you. Change it in Settings → Workspace.",children:"muted"}),t.jsxs("span",{className:"ml-auto flex items-baseline gap-1.5 text-gray-400",children:[b&&n,y!=null&&t.jsxs(t.Fragment,{children:[b&&n!=null&&t.jsx("span",{"aria-hidden":!0,className:"decorative-mark text-gray-300 dark:text-gray-600",children:"·"}),t.jsx("span",{className:"whitespace-nowrap",title:r!=null?`Opened ${Cn(r)}`:void 0,children:y})]})]}),t.jsx(nF,{card:e})]}),i,x!=null&&x.trim()!==""&&t.jsxs("p",{className:"mt-1.5 flex items-start gap-1 text-[11px] italic text-ai-ink",children:[t.jsx(Ps,{size:11,className:"mt-0.5 shrink-0 not-italic text-ai-signal"}),t.jsx("span",{className:"min-w-0",children:x})]})]})}function wi({card:e,onOpen:n}){return t.jsxs("div",{className:"flex min-w-0 items-baseline gap-1.5 text-sm",children:[t.jsxs("button",{type:"button",onClick:n,className:"min-w-0 truncate text-left font-medium text-gray-800 hover:underline dark:text-gray-100",title:"Open this PR on its Overview tab",children:[t.jsxs("span",{className:"text-gray-400",children:[e.repoFullName," #",e.prNumber]})," ",e.prTitle]}),t.jsx("a",{href:e.githubUrl,target:"_blank",rel:"noreferrer noopener",onClick:r=>r.stopPropagation(),className:"shrink-0 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300",title:"Open on GitHub",children:t.jsx(_t,{})})]})}function OF(e){return e.arm!=="trunk"||e.prId==null?null:{authorId:e.authorId,automation:e.automation}}function qw({card:e,usersById:n,onOpenPr:r,chip:s}){const a=Rr[e.ciStatus]??null,i=mn(e.githubUrl),c=e.prId!=null&&e.prNumber!=null&&e.prTitle!=null,d=OF(e);return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex min-w-0 items-baseline gap-1.5 text-sm",children:[t.jsxs("span",{className:"min-w-0 truncate font-medium text-gray-800 dark:text-gray-100",children:[t.jsx("span",{className:"text-gray-400",children:e.repoFullName})," ",e.arm==="trunk"?"trunk is red":"your PR is red"]}),i!=null&&t.jsx("a",{href:i,target:"_blank",rel:"noreferrer noopener",onClick:u=>u.stopPropagation(),className:"shrink-0 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300",title:e.arm==="trunk"?"Open the commit on GitHub":"Open the PR on GitHub",children:t.jsx(_t,{})})]}),t.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px] text-gray-500 dark:text-gray-400",children:[t.jsxs("span",{className:"inline-flex items-center gap-1",title:(a==null?void 0:a.label)??e.ciStatus,children:[t.jsx("span",{className:"inline-block h-2 w-2 rounded-full",style:a?{background:a.color}:{boxShadow:"inset 0 0 0 1px #9ca3af"},"aria-hidden":!0}),(a==null?void 0:a.label)??e.ciStatus]}),e.headSha!=null&&t.jsx("span",{className:"font-mono",children:e.headSha.slice(0,7)})]}),t.jsx(bF,{card:e}),c&&t.jsxs("div",{className:"mt-1 flex min-w-0 flex-wrap items-baseline gap-1.5 text-[11px] text-gray-500 dark:text-gray-400",children:[e.arm==="your_pr"&&t.jsx("span",{children:"PR"}),t.jsxs("button",{type:"button",onClick:()=>r(Kn({prId:e.prId,prNumber:e.prNumber,prTitle:e.prTitle,repoFullName:e.repoFullName},n),e.id),className:"min-w-0 truncate text-left hover:underline",title:"Open this PR on its Overview tab",children:[t.jsxs("span",{className:"text-gray-400",children:["#",e.prNumber]})," ",e.prTitle]}),d!=null&&t.jsx(P2,{pr:d,usersById:n,repoId:e.repoId}),e.arm==="trunk"&&e.mergedById!=null&&t.jsxs(t.Fragment,{children:[t.jsx("span",{children:"landed by"}),t.jsx(id,{id:e.mergedById,usersById:n})]})]}),t.jsxs("div",{className:"mt-1.5 flex flex-wrap items-baseline gap-1.5 text-[11px] text-gray-500 dark:text-gray-400",children:[t.jsx("span",{className:"rounded bg-gray-500/10 px-1.5 py-0.5 font-medium text-gray-600 dark:text-gray-300",children:s??(e.arm==="your_pr"?"Your PR":"Your repo")}),t.jsx("span",{className:"min-w-0",children:e.detail})]}),e.arm==="trunk"&&t.jsx("div",{className:"mt-1 text-[11px] italic text-gray-400",children:"Trunk is red at this commit — not necessarily because of it."})]})}function O2(e,n){const r={...e,mergeable:n.mergeable,lastCommitAt:n.lastCommitAt,viewerCanPush:n.viewerCanPush,relevance:e.relevance??"direct",detail:e.detail};return n.forward==="update_branch"?{...r,kind:"update_branch",mergeStateStatus:"behind"}:{...r,kind:"merge",mergeStateStatus:n.mergeStateStatus}}function DF(e,n){return{...e,kind:"conflicts",mergeStateStatus:n.mergeStateStatus,mergeable:n.mergeable,relevance:e.relevance??"direct"}}function BF(e){return{id:e.id,kind:"ci_failing",severity:e.severity,arm:"trunk",repoId:e.repoId,repoFullName:e.repoFullName,ciStatus:e.ciStatus,prId:e.prId,prNumber:e.prNumber,prTitle:e.prTitle,headSha:e.headSha,mergedById:e.mergedById,viewerMerged:e.viewerMerged,detail:e.detail,observedAt:e.observedAt,githubUrl:e.githubUrl,authorId:e.authorId,authorIsBot:e.authorIsBot,authorBotKind:e.authorBotKind,automation:e.automation,failingChecks:e.failingChecks,failingCheckTotal:e.failingCheckTotal}}function Uw(e,n){return e.prId==null||e.prNumber==null||e.prTitle==null?null:Kn({prId:e.prId,prNumber:e.prNumber,prTitle:e.prTitle,repoFullName:e.repoFullName},n)}function WF(e,n){return e!=null&&e>0&&e<n}function qF({cards:e,users:n,doNextCount:r,people:s,explain:a}){const i=Ge(C=>C.openPrDetailTab),c=G(C=>C.selectThread),d=f.useMemo(()=>Rn(n),[n]),u=Ge(C=>C.activityFlashItemId),m=Ge(C=>C.clearActivityFlashItem),h=f.useRef(new Map),[g,x]=f.useState(null);f.useEffect(()=>{if(u==null)return;const C=u,L=requestAnimationFrame(()=>{const F=h.current.get(C);F&&(F.scrollIntoView({block:"center",behavior:"smooth"}),x(C),window.setTimeout(()=>x(M=>M===C?null:M),1800)),m()});return()=>cancelAnimationFrame(L)},[u,m]);const y=(C,L)=>{L?h.current.set(C,L):h.current.delete(C)},b=(C,L)=>i(C,{fromActivity:!0,returnItemId:L}),w=(C,L)=>{i(Kn(C,d),{fromActivity:!0,returnItemId:C.id}),c(C.prId,L)},k=C=>w(C,C.threadId),j=C=>{const L=C.own,F=hL(C),M=Nf(C),D=(L==null?void 0:L.kind)==="thread"&&L.botKind!=null?L.botKind:null;return t.jsxs(ca,{card:C,innerRef:A=>y(C.id,A),flash:g===C.id,right:t.jsx("span",{title:Cn(C.since),children:Nt(C.since)}),openedAt:C.openedAt,clockAt:C.since,onActivate:()=>C.threadId!=null&&(C.reason==="thread"||C.reason==="thread_reply"||C.reason==="own_thread")?w(C,C.threadId):b(Kn(C,d),C.id),children:[t.jsx(wi,{card:C,onOpen:()=>b(Kn(C,d),C.id)}),t.jsx(Fo,{pr:C,usersById:d}),t.jsx(ki,{pr:C,usersById:d}),(F!=null||M!=null||D!=null)&&t.jsxs("div",{className:"mt-1.5 flex flex-wrap items-baseline gap-1.5 text-[11px] text-gray-500 dark:text-gray-400",children:[F!=null&&t.jsx("span",{className:"rounded bg-gray-500/10 px-1.5 py-0.5 font-medium text-gray-600 dark:text-gray-300",children:F}),M!=null&&t.jsx("span",{className:"min-w-0",children:M}),D!=null&&t.jsx(Rf,{kind:D})]}),C.reply!=null&&t.jsx(jF,{reply:C.reply,openLabel:C.threadId!=null?"Open thread":"Open PR",onOpen:()=>C.threadId!=null?w(C,C.threadId):b(Kn(C,d),C.id)}),C.reason==="pushed_since"&&C.ball!=null&&t.jsx(NF,{ball:C.ball,usersById:d}),(L==null?void 0:L.kind)==="ready"&&t.jsx(Tf,{card:O2(C,L)}),(L==null?void 0:L.kind)==="conflicts"&&t.jsx($f,{card:DF(C,L)}),t.jsx(Dw,{card:C})]},C.id)},N=C=>{const L=Uw(C,d);return t.jsxs(ca,{card:C,innerRef:F=>y(C.id,F),flash:g===C.id,right:C.observedAt!=null?t.jsx("span",{title:Cn(C.observedAt),children:Nt(C.observedAt)}):void 0,onActivate:L!=null?()=>b(L,C.id):void 0,children:[t.jsx(qw,{card:BF(C),usersById:d,onOpenPr:b,chip:u2(C)}),t.jsx(Dw,{card:C})]},C.id)},I=C=>{switch(C.kind){case"my_turn":switch(C.reason){case"trunk_red":return N(C);case"review_request":case"mention":case"thread":case"thread_reply":case"comment_reply":case"pushed_since":case"own_ci_red":case"own_conflicts":case"pr_approved":case"own_ready":case"your_pr":case"own_thread":case"claude_review":case"watched_repo_pr":return j(C);default:return null}case"ci_failing":{const L=Uw(C,d);return t.jsx(ca,{card:C,innerRef:F=>y(C.id,F),flash:g===C.id,right:C.observedAt!=null?t.jsx("span",{title:Cn(C.observedAt),children:Nt(C.observedAt)}):void 0,onActivate:L!=null?()=>b(L,C.id):void 0,children:t.jsx(qw,{card:C,usersById:d,onOpenPr:b})},C.id)}case"stalled_review":return t.jsxs(ca,{card:C,innerRef:L=>y(C.id,L),flash:g===C.id,right:`waiting ${Sf(C.ageHours)}`,onActivate:()=>b(Kn(C,d),C.id),children:[t.jsx(wi,{card:C,onOpen:()=>b(Kn(C,d),C.id)}),t.jsx(Fo,{pr:C,usersById:d}),t.jsx(ki,{pr:C,usersById:d}),t.jsxs("div",{className:"mt-1.5 flex flex-wrap items-center gap-1.5 text-[11px] text-gray-500 dark:text-gray-400",children:[t.jsx("span",{children:"waiting on"}),C.requestedReviewerIds.length>0||C.requestedTeamNames.length>0?t.jsxs(t.Fragment,{children:[C.requestedReviewerIds.map(L=>t.jsx(id,{id:L,usersById:d},L)),C.requestedTeamNames.map(L=>t.jsxs("span",{className:"inline-flex items-center gap-1 rounded bg-gray-500/10 px-1.5 py-0.5 text-[11px] font-medium",children:["@",L]},`team:${L}`))]}):t.jsx("span",{className:"italic",children:"no reviewer requested"})]}),t.jsx(ch,{prId:C.prId})]},C.id);case"untouched_thread":return t.jsxs(ca,{card:C,innerRef:L=>y(C.id,L),flash:g===C.id,right:`${Sf(C.ageHours)} old`,children:[t.jsxs("div",{className:"-m-1 cursor-pointer rounded p-1 hover:bg-gray-50/70 dark:hover:bg-gray-900/60",onClick:L=>{L.target.closest("a,button")||k(C)},children:[t.jsx(wi,{card:C,onOpen:()=>b(Kn(C,d),C.id)}),t.jsx(Fo,{pr:C,usersById:d}),t.jsx(ki,{pr:C,usersById:d}),t.jsxs("div",{className:"mt-1.5 flex flex-wrap items-center gap-1.5 text-[11px] text-gray-500 dark:text-gray-400",children:[t.jsx("span",{className:"rounded bg-gray-500/10 px-1.5 py-0.5 font-mono",children:C.path}),t.jsx("span",{children:"· no reply since"}),C.originalCommenterId!=null&&t.jsx(id,{id:C.originalCommenterId,usersById:d}),C.botKind!=null&&t.jsx(Rf,{kind:C.botKind})]})]}),t.jsx("div",{className:"mt-2",children:t.jsx(CF,{card:C})}),t.jsx(ch,{prId:C.prId})]},C.id);case"reviewer_routing":return t.jsxs(ca,{card:C,innerRef:L=>y(C.id,L),flash:g===C.id,right:"unassigned",openedAt:C.openedAt,onActivate:()=>b(Kn(C,d),C.id),children:[t.jsx(wi,{card:C,onOpen:()=>b(Kn(C,d),C.id)}),t.jsx(Fo,{pr:C,usersById:d}),t.jsx(ki,{pr:C,usersById:d}),C.topPaths.length>0&&t.jsxs("div",{className:"mt-1 truncate text-[11px] text-gray-400",children:["touches ",t.jsx("span",{className:"font-mono",children:C.topPaths.slice(0,3).join(", ")})]}),t.jsx(RF,{card:C,usersById:d}),t.jsx(ch,{prId:C.prId})]},C.id);case"merge":case"update_branch":{const L=lF(C),F=Nf(C);return t.jsxs(ca,{card:C,innerRef:M=>y(C.id,M),flash:g===C.id,right:C.lastCommitAt!=null?t.jsx("span",{title:Cn(C.lastCommitAt),children:Nt(C.lastCommitAt)}):void 0,openedAt:C.openedAt,clockAt:C.lastCommitAt,onActivate:()=>b(Kn(C,d),C.id),children:[t.jsx(wi,{card:C,onOpen:()=>b(Kn(C,d),C.id)}),t.jsx(Fo,{pr:C,usersById:d}),t.jsx(ki,{pr:C,usersById:d}),(L!=null||F!=null)&&t.jsxs("div",{className:"mt-1.5 flex flex-wrap items-baseline gap-1.5 text-[11px] text-gray-500 dark:text-gray-400",children:[L!=null&&t.jsx("span",{className:"rounded bg-gray-500/10 px-1.5 py-0.5 font-medium text-gray-600 dark:text-gray-300",children:L}),F!=null&&t.jsx("span",{className:"min-w-0",children:F})]}),t.jsx(Tf,{card:C})]},C.id)}case"conflicts":{const L=iF(C);return t.jsxs(ca,{card:C,innerRef:F=>y(C.id,F),flash:g===C.id,openedAt:C.openedAt,onActivate:()=>b(Kn(C,d),C.id),children:[t.jsx(wi,{card:C,onOpen:()=>b(Kn(C,d),C.id)}),t.jsx(Fo,{pr:C,usersById:d}),t.jsx(ki,{pr:C,usersById:d}),t.jsxs("div",{className:"mt-1.5 flex flex-wrap items-baseline gap-1.5 text-[11px] text-gray-500 dark:text-gray-400",children:[L!=null&&t.jsx("span",{className:"rounded bg-gray-500/10 px-1.5 py-0.5 font-medium text-gray-600 dark:text-gray-300",children:L}),t.jsx("span",{className:"min-w-0",children:C.detail})]}),t.jsx($f,{card:C})]},C.id)}case"security":case"dependency_bump":{const L=dL(C),F=cL(C);return t.jsxs(ca,{card:C,innerRef:M=>y(C.id,M),flash:g===C.id,right:C.lastCommitAt!=null?t.jsx("span",{title:Cn(C.lastCommitAt),children:Nt(C.lastCommitAt)}):void 0,openedAt:C.openedAt,clockAt:C.lastCommitAt,onActivate:()=>b(Kn(C,d),C.id),children:[t.jsx(wi,{card:C,onOpen:()=>b(Kn(C,d),C.id)}),t.jsx(Fo,{pr:C,usersById:d}),t.jsx(ki,{pr:C,usersById:d}),(L!=null||F!=null)&&t.jsxs("div",{className:"mt-1.5 flex flex-wrap items-baseline gap-1.5 text-[12px] text-gray-600 dark:text-gray-300",children:[L!=null&&t.jsx("span",{className:"rounded bg-gray-500/10 px-1.5 py-0.5 text-[11px] font-medium text-gray-600 dark:text-gray-300",children:L}),F!=null&&t.jsx("span",{className:"min-w-0",children:F})]}),C.kind==="security"&&t.jsx(FF,{card:C,usersById:d,onOpenThread:M=>w(C,M)}),t.jsx(EF,{card:C})]},C.id)}case"reviewer_load":return t.jsxs(ca,{card:C,innerRef:L=>y(C.id,L),flash:g===C.id,right:`${C.reviewsThisSprint} review${C.reviewsThisSprint===1?"":"s"} this sprint`,children:[t.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[t.jsx(id,{id:C.reviewerId,usersById:d}),t.jsxs("span",{className:"font-semibold text-gray-800 dark:text-gray-100",children:[C.pendingCount," pending review",C.pendingCount===1?"":"s"]})]}),C.pendingPrs.length>0&&t.jsx("ul",{className:"mt-1.5 space-y-0.5",children:C.pendingPrs.map(L=>t.jsx("li",{className:"truncate text-[11px]",children:t.jsxs("button",{type:"button",onClick:()=>b({id:L.prId,number:L.prNumber,title:L.prTitle,repoFullName:L.repoFullName,authorLogin:null,authorDisplayName:null,authorAvatarUrl:null},C.id),className:"text-left text-gray-500 hover:underline dark:text-gray-400",children:[t.jsxs("span",{className:"text-gray-400",children:[L.repoFullName," #",L.prNumber]})," ",L.prTitle]})},L.prId))})]},C.id);default:return null}},S=r??0,T=WF(S,e.length),$=f.useMemo(()=>{if(a==null)return null;const C=new Map(e.map((L,F)=>[L.id,F]));for(const L of s??[])C.set(L.id,-1);return{...a,indexById:C,doNextCount:S}},[a,e,s,S]),P=(C,L,F)=>t.jsxs("li",{className:"flex items-baseline gap-2 pt-1 first:pt-0",children:[t.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wide text-gray-500 dark:text-gray-400",children:L}),F!=null&&t.jsx("span",{className:"text-[11px] text-gray-500 dark:text-gray-400",children:F}),t.jsx("span",{className:"h-px flex-1 bg-gray-200 dark:bg-gray-800","aria-hidden":!0})]},C);return t.jsx(ny.Provider,{value:$,children:t.jsxs("ul",{className:"space-y-2",children:[s!=null&&s.length>0&&[P("__people","Reviews waiting on people","not ranked"),...s.map(C=>I(C))],S>0&&P("__do-next","Do next"),e.flatMap((C,L)=>T&&L===S?[P("__everything-else","Everything else"),I(C)]:[I(C)])]})})}function UF({items:e}){const[n,r]=f.useState(!1),s=n5(),a=i=>{var c;return s.isPending&&((c=s.variables)==null?void 0:c.kind)===i.target.kind&&s.variables.id===i.target.id};return t.jsxs("section",{className:"rounded-lg border border-gray-200 dark:border-gray-800",children:[t.jsxs("button",{type:"button",onClick:()=>r(i=>!i),"aria-expanded":n,className:"flex w-full items-center gap-1.5 px-3 py-2 text-left text-[12px] font-medium text-gray-700 hover:bg-gray-50 dark:text-gray-200 dark:hover:bg-gray-900/60",children:[t.jsx(Mt,{dir:n?"down":"right",size:11,className:"text-gray-500 dark:text-gray-400"}),"Dismissed ",t.jsx("span",{className:"tabular-nums text-gray-500 dark:text-gray-400",children:e.length})]}),n&&t.jsxs("div",{className:"border-t border-gray-200 px-3 py-2 dark:border-gray-800",children:[t.jsx("p",{className:"mb-2 text-[12px] text-gray-500 dark:text-gray-400",children:"Each comes back by itself when something new happens on it."}),t.jsx("ul",{className:"space-y-1.5",children:e.map(i=>{const c=mn(i.githubUrl),d=i.prNumber!=null?`${i.repoFullName} #${i.prNumber}`:i.repoFullName;return t.jsxs("li",{className:"flex flex-wrap items-baseline gap-x-2 gap-y-0.5 text-[12px]",children:[t.jsxs("span",{className:"min-w-0 text-gray-800 dark:text-gray-100",children:[t.jsx("span",{className:"text-gray-500 dark:text-gray-400",children:d}),i.title!=null&&t.jsxs(t.Fragment,{children:[" ",i.title]})]}),c!==void 0&&t.jsx("a",{href:c,target:"_blank",rel:"noreferrer noopener",title:"Open on GitHub","aria-label":`Open ${d} on GitHub`,className:"text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200",children:t.jsx(_t,{size:11})}),t.jsx("span",{className:"rounded bg-gray-500/10 px-1.5 py-0.5 text-[11px] text-gray-600 dark:text-gray-300",children:od[i.reason]}),t.jsxs("span",{className:"text-gray-500 dark:text-gray-400",title:Cn(i.dismissedAt),children:["dismissed ",Nt(i.dismissedAt)]}),t.jsx("button",{type:"button",onClick:()=>s.mutate(i.target),disabled:a(i),className:"ml-auto rounded border border-gray-300 px-2 py-0.5 text-[12px] text-gray-800 hover:border-gray-400 disabled:opacity-50 dark:border-gray-700 dark:text-gray-100 dark:hover:border-gray-600",children:a(i)?"Bringing it back…":"Bring back"})]},`${i.target.kind}:${i.target.id}`)})})]})]})}function HF(e,n){const r=new URLSearchParams;return e!=null&&r.set("workspace",String(e)),n&&r.set("repoIds",[...n].sort((s,a)=>s-a).join(",")),r.toString()}function ay(e){const n=G(s=>s.workspaceId),r=HF(n,e??null);return Oe({queryKey:["branch-status",dt(n),r],queryFn:()=>he.branchStatus(r),enabled:n!=null,staleTime:6e4,gcTime:fn,placeholderData:s=>s})}function zF(e,n){return Oe({queryKey:["branch-trends",e],queryFn:()=>he.branchTrends(e??-1),enabled:n&&e!=null,staleTime:6e4})}const Hw="…";function KF(e,n){if(n==null)return e;const r=` (#${n})`;if(e.endsWith(r))return e.slice(0,-r.length);if(!e.endsWith(Hw))return e;const s=e.slice(0,-Hw.length),a=" (#",i=s.lastIndexOf(a);if(i<0)return e;const c=s.slice(i+a.length);return c.length===0||!String(n).startsWith(c)?e:s.slice(0,i)}function Xs(){const e=f.useRef(null),[n,r]=f.useState(0);return f.useEffect(()=>{const s=e.current;if(!s)return;const a=new ResizeObserver(i=>{var d;const c=(d=i[0])==null?void 0:d.contentRect.width;c!=null&&r(c)});return a.observe(s),r(s.clientWidth),()=>a.disconnect()},[]),[e,n]}const De={blue:"#3b82f6",green:"#22c55e",gray:"#9ca3af",orange:"#f97316",amber:"#f59e0b",purple:"#8957e5",indigo:"#6366f1",red:"#ef4444",teal:"#14b8a6",pink:"#ec4899",slate:"#64748b",violet:"#a78bfa"},Zc=De.red,Xl=[De.blue,De.green,De.amber,De.purple,De.teal,De.pink,De.slate];function wn(e){if(e<=0)return"0h";if(e<1)return`${Math.round(e*60)}m`;if(e<48)return`${e%1===0?e:e.toFixed(1)}h`;const n=e/24;return`${n<10?n.toFixed(1):Math.round(n)}d`}function Bo(e){return new Date(e).toLocaleDateString(void 0,{month:"short",day:"numeric"})}function Sn(e){return Math.abs(e)>=1e3?`${(e/1e3).toFixed(e%1e3===0?0:1)}k`:`${Math.round(e)}`}function zp(e){if(e<=0)return 1;const n=Math.floor(Math.log10(e)),r=Math.pow(10,n),s=e/r;return(s<=1?1:s<=2?2:s<=5?5:10)*r}function Ld({series:e}){return t.jsx("div",{className:"mt-1 flex flex-wrap gap-x-3 gap-y-0.5",children:e.map(n=>t.jsxs("span",{className:"flex items-center gap-1 text-[10px] text-gray-500 dark:text-gray-400",children:[t.jsx("span",{className:"inline-block h-2 w-2 rounded-[2px]",style:{background:n.color}}),n.label]},n.label))})}function Wi({x:e,y:n,width:r,children:s,centered:a=!1}){const i=a?r/2:Math.max(58,Math.min(e,Math.max(58,r-58)));return t.jsx("div",{className:`pointer-events-none absolute z-20 -translate-x-1/2 ${a?"":"-translate-y-full"} whitespace-nowrap rounded-md border border-gray-200 bg-white/95 px-2 py-1 text-[10px] leading-tight text-gray-700 shadow-md dark:border-gray-700 dark:bg-gray-900/95 dark:text-gray-200`,style:{left:i,top:a?2:Math.max(n-6,0)},children:s})}function jt({title:e,note:n,className:r,testId:s,children:a}){return t.jsxs("div",{"data-testid":s,className:`rounded-lg border border-gray-200 p-3 dark:border-gray-800${r?` ${r}`:""}`,children:[t.jsxs("div",{className:"mb-1 flex items-baseline justify-between gap-2",children:[t.jsx("h4",{className:"text-xs font-semibold text-gray-700 dark:text-gray-200",children:e}),n&&t.jsx("span",{className:"text-[10px] text-gray-400",children:n})]}),a]})}function Tt({label:e="No data in this window"}){return t.jsx("div",{className:"flex h-[120px] items-center justify-center rounded-md border border-dashed border-gray-200 text-[10px] text-gray-400 dark:border-gray-800",children:e})}const GF="#64748b";function D2({daily:e,startDate:n,silentRuns:r,color:s,height:a,opened:i,noun:c="action",openedVerb:d="opened",dailyGood:u,goodColor:m,goodNoun:h="passing commit"}){const g=s??De.blue,[x,y]=Xs(),[b,w]=f.useState(null),k=i!=null&&i.length>0,j=k?14:0,N=2,I=16,S=5,T=N+j,$=a??T+I+S+12,P=Math.max(1,e.length),L=Math.max(y-2,1)/P,F=u!=null&&u.length>0,M=m??De.green,D=F?e.map((E,ee)=>E+(u[ee]??0)):e,A=Math.max(1,...D),W=k?Math.max(1,...i):1,z=Date.parse(n),te=864e5,H=E=>new Date(z+E*te).toISOString().slice(0,10),B=k?i.map((E,ee)=>{const K=N+(j-2)*(1-E/W);return`${ee*L+L/2},${K.toFixed(1)}`}).join(" "):"",O=E=>{const ee=Math.floor(E.nativeEvent.offsetX/L);w(ee<0||ee>=P?null:ee)};return t.jsx("div",{children:t.jsxs("div",{ref:x,className:"relative",style:{height:$},children:[y>0&&t.jsxs("svg",{width:y,height:$,className:"block",children:[e.map((E,ee)=>{const K=b===ee,U=D[ee]??0,Q=Math.max(L-1,1);if(!F||U===0){const ae=F?U>0:E>0;return t.jsx("rect",{x:ee*L,y:T,width:Q,height:I,rx:1.5,fill:ae?g:"currentColor",className:ae?"":"decorative-mark text-gray-100 dark:text-gray-800",fillOpacity:ae?.2+.8*(E/A):1,stroke:K?g:"none",strokeWidth:K?1.5:0},ee)}const J=Math.round(I*(E/U)),ne=.25+.75*(U/A);return t.jsxs("g",{children:[J>0&&t.jsx("rect",{x:ee*L,y:T,width:Q,height:J,rx:1.5,fill:g,fillOpacity:ne}),I-J>0&&t.jsx("rect",{x:ee*L,y:T+J,width:Q,height:I-J,rx:1.5,fill:M,fillOpacity:ne}),K&&t.jsx("rect",{x:ee*L,y:T,width:Q,height:I,rx:1.5,fill:"none",stroke:E>0?g:M,strokeWidth:1.5})]},ee)}),k&&t.jsx("polyline",{points:B,fill:"none",stroke:GF,strokeWidth:1.25,strokeLinejoin:"round",strokeLinecap:"round",opacity:.9}),r.map(E=>t.jsx("rect",{x:E.startDay*L,y:T+I+1,width:Math.max(E.days*L-1,1),height:2.5,rx:1,fill:Zc},`gap-${E.startDay}`)),t.jsx("text",{x:0,y:$-2,className:"fill-gray-500 dark:fill-gray-400 text-[8px]",children:H(0)}),t.jsx("text",{x:y,y:$-2,textAnchor:"end",className:"fill-gray-500 dark:fill-gray-400 text-[8px]",children:H(P-1)}),t.jsx("rect",{x:0,y:0,width:y,height:$,fill:"transparent",onMouseMove:O,onMouseLeave:()=>w(null)})]}),b!=null&&y>0&&t.jsxs(Wi,{x:b*L+L/2,y:N,width:y,children:[H(b)," · ",e[b]??0," ",c,e[b]===1?"":"s",F?` · ${u[b]??0} ${h}${u[b]===1?"":"s"}`:"",k?` · ${i[b]??0} PR${i[b]===1?"":"s"} ${d}`:""]})]})})}function Kp({status:e,size:n=6,title:r,className:s=""}){const a=Rr[e],i=r??(a==null?void 0:a.label)??"No CI reported";return t.jsx("span",{"aria-hidden":"true",title:i,className:`inline-block shrink-0 rounded-full ${s}`,style:a?{width:n,height:n,background:a.color}:{width:n,height:n,border:"1px solid #9ca3af",background:"transparent"}})}function VF({status:e,className:n=""}){if(e==null||e.branchName==null)return null;const r=Rr[e.ciStatus];return t.jsxs("span",{className:`flex min-w-0 items-center gap-1 text-[10px] text-gray-400 ${n}`,title:`${e.branchName}: ${(r==null?void 0:r.label)??"no CI reported"}${e.lastCommitAt!=null?` · last commit ${Nt(e.lastCommitAt)}`:""}`,children:[t.jsx(Kp,{status:e.ciStatus,size:5}),t.jsx("span",{className:"min-w-0 truncate font-mono",children:e.branchName}),e.lastCommitAt!=null&&t.jsx("span",{className:"shrink-0 tabular-nums",children:Nt(e.lastCommitAt)})]})}function QF(e,n){if(!e)return;const[r,s]=e.split("/");if(!(!r||!s))return mn(`https://github.com/${encodeURIComponent(r)}/${encodeURIComponent(s)}/pull/${n}`)}function YF(e,n,r,s){return{id:e,number:n,title:s??`#${n}`,repoFullName:r,authorLogin:null,authorDisplayName:null,authorAvatarUrl:null}}function B2(e){return e.workflowName!=null?`${e.workflowName} / ${e.name}`:e.name}function XF({check:e}){const n=Nx[e.state],r=mn(e.url),s=B2(e),a=t.jsxs("span",{className:"flex min-w-0 items-center gap-1",children:[t.jsx("span",{"aria-hidden":"true",style:pn(n.color),className:"flex shrink-0 items-center",children:t.jsx(n.icon,{size:11})}),t.jsx("span",{className:"min-w-0 truncate",title:s,children:s})]});return r!=null?t.jsx("a",{href:r,target:"_blank",rel:"noreferrer noopener",className:"min-w-0 text-red-600 hover:underline dark:text-red-400",children:a}):t.jsx("span",{className:"min-w-0 text-red-600 dark:text-red-400",children:a})}function ZF({checks:e}){const[n,...r]=e;return n==null?null:t.jsxs("span",{className:"flex min-w-0 shrink items-center gap-1 text-[11px]",children:[t.jsx("span",{"aria-hidden":"true",className:"shrink-0 decorative-mark text-gray-300 dark:text-gray-600",children:"·"}),t.jsx(XF,{check:n}),r.length>0&&t.jsxs("span",{className:"shrink-0 text-gray-400",title:r.map(B2).join(`
55
+ `),children:["+",r.length]})]})}const t0=20;function JF({pr:e,fullName:n}){var m;const r=Ge(h=>h.openPrDetailTab),s=mn(e.authorAvatarUrl),a=e.prId,i=QF(n,e.prNumber),c=e.title??((m=e.commits[0])==null?void 0:m.messageHeadline)??`#${e.prNumber}`,d=e.commits.slice(0,t0).map(h=>`${h.sha.slice(0,7)} ${h.messageHeadline}`);e.commits.length>t0&&d.push(`… +${e.commits.length-t0} more`);const u=d.join(`
56
+ `);return t.jsx("li",{className:"text-[11px]",children:t.jsxs("div",{className:"flex items-center gap-2 py-0.5",title:u,children:[t.jsx(Kp,{status:e.ciStatus,size:5}),a!=null?t.jsxs("button",{type:"button",onClick:()=>r(YF(a,e.prNumber,n??"",e.title),{fromActivity:!0}),title:`Open #${e.prNumber} in this app`,className:"shrink-0 rounded bg-sky-500/10 px-1 font-mono text-[10px] text-sky-700 hover:bg-sky-500/20 dark:text-sky-300",children:["#",e.prNumber]}):i!=null?t.jsxs("a",{href:i,target:"_blank",rel:"noreferrer noopener",title:`#${e.prNumber} on GitHub — not synced here`,className:"shrink-0 rounded bg-gray-500/10 px-1 font-mono text-[10px] text-gray-500 hover:text-sky-600 dark:text-gray-400 dark:hover:text-sky-400",children:["#",e.prNumber]}):t.jsxs("span",{className:"shrink-0 font-mono text-[10px] text-gray-400",children:["#",e.prNumber]}),t.jsx("span",{className:"min-w-0 flex-1 truncate text-gray-700 dark:text-gray-200",children:KF(c,e.prNumber)}),t.jsxs("span",{className:"shrink-0 text-gray-400",children:[e.commits.length," commit",e.commits.length===1?"":"s"]}),(s!=null||e.authorLogin!=null)&&t.jsxs("span",{className:"flex shrink-0 items-center gap-1 text-gray-400",children:[s!=null&&t.jsx("img",{src:s,alt:"",className:"h-3.5 w-3.5 rounded-full",loading:"lazy"}),e.authorLogin!=null&&t.jsx("span",{className:"max-w-[10rem] truncate",children:e.authorLogin})]}),t.jsx("span",{className:"shrink-0 tabular-nums text-gray-400",title:new Date(e.mergedAt).toLocaleString(),children:Nt(e.mergedAt)})]})})}function eO({data:e,isLoading:n,isError:r,full:s}){var h;const a=(e==null?void 0:e.daily)??[],i=a.length>0,c=g=>t.jsx("div",{className:"flex h-full items-center justify-center text-[10px] text-gray-400",children:g}),d="Couldn’t load trends",u=49,m=n?c("Loading trends…"):r?c(d):i?t.jsx(D2,{daily:a.map(g=>g.failed),dailyGood:a.map(g=>g.passed),startDate:((h=a[0])==null?void 0:h.day)??"",silentRuns:[],color:De.red,goodColor:De.green,opened:a.map(g=>g.merged),noun:"failing commit",goodNoun:"passing commit",openedVerb:"merged"}):c("No trunk history yet");return s?t.jsx("div",{className:"mb-2",children:t.jsx(jt,{title:"Trunk health & throughput",note:"one cell / day · red = failing, green = passing commits · line = PRs merged · retained window (UTC)",children:t.jsx("div",{style:{height:u},children:m})})}):t.jsxs("div",{className:"mb-1 border-b border-gray-100 pb-1 dark:border-gray-800/60",children:[t.jsx("div",{className:"text-[10px] text-gray-400",children:"Trunk CI · red = failing, green = passing · line = PRs merged · retained window"}),t.jsx("div",{style:{height:u},children:m})]})}function tO({status:e,fullName:n,showRepoName:r,fullTrends:s}){const[a,i]=f.useState(!1),c=Rr[e.ciStatus],d=e.lastCommitAt!=null,u=zF(e.repoId,a);return t.jsxs("li",{className:"border-b border-gray-100 last:border-b-0 dark:border-gray-800/60",children:[t.jsxs("div",{className:"flex items-center gap-2 px-2 py-1 text-xs hover:bg-gray-50 dark:hover:bg-gray-800/40",children:[t.jsxs("button",{type:"button",onClick:()=>i(m=>!m),"aria-expanded":a,disabled:!d,className:"flex min-w-0 flex-1 items-center gap-2 text-left disabled:cursor-default",children:[t.jsx("span",{"aria-hidden":"true",className:`w-2 shrink-0 text-[9px] text-gray-400 ${d?"":"opacity-0"}`,children:t.jsx(Mt,{dir:a?"down":"right",size:10})}),t.jsx(Kp,{status:e.ciStatus}),r&&t.jsx("span",{className:"min-w-0 max-w-[14rem] truncate font-medium text-gray-700 dark:text-gray-200",children:n??`repo ${e.repoId}`}),t.jsx("span",{className:"min-w-0 truncate font-mono text-[11px] text-gray-500 dark:text-gray-400",children:e.branchName??"—"}),t.jsx("span",{className:"shrink-0 text-[11px] text-gray-400",children:(c==null?void 0:c.label)??"no CI reported"})]}),t.jsx(ZF,{checks:e.failingChecks}),t.jsx("span",{className:"shrink-0 text-[11px] tabular-nums text-gray-400",children:e.lastCommitAt!=null?Nt(e.lastCommitAt):"never synced"})]}),a&&d&&t.jsxs("div",{className:"border-t border-gray-100 px-2 py-1 pl-6 dark:border-gray-800/60",children:[t.jsx(eO,{data:u.data,isLoading:u.isLoading,isError:u.isError,full:s}),e.mergedPrs.length>0?t.jsx("ul",{children:e.mergedPrs.map(m=>t.jsx(JF,{pr:m,fullName:n},m.prNumber))}):t.jsx("div",{className:"py-0.5 text-[11px] text-gray-400",children:"No merged PRs in the retained window — direct pushes only."})]})]})}function W2(e){return e.some(n=>n.branchName!=null)}function q2({repoIds:e,compact:n=!1}){const{data:r,isLoading:s}=ay(e),{data:a}=xn(),i=new Map((a??[]).map(j=>[j.id,j.fullName])),[c,d]=f.useState(null);if(s&&r==null)return null;const u=(r==null?void 0:r.repos)??[];if(!W2(u))return null;const h=u.filter(j=>j.ciStatus==="failure"||j.ciStatus==="error").length,g=u.every(j=>j.ciStatus==="success"),x=!n,y=!x||(c??h>0),b=u.filter(j=>j.ciStatus==="success").length,w=u.filter(j=>j.ciStatus==="pending"||j.ciStatus==="expected").length,k=t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wide text-gray-500 dark:text-gray-400",children:"Default branches"}),b>0&&t.jsx("span",{className:"rounded bg-green-500/15 px-1 text-[11px] font-semibold text-green-700 dark:text-green-400",title:"Default branches whose latest CI passed",children:g&&b>1?`all ${b} green`:`${b} green`}),h>0&&t.jsxs("span",{className:"rounded bg-red-500/15 px-1 text-[11px] font-semibold text-red-600 dark:text-red-400",title:"Default branches whose latest CI is failing",children:[h," failing"]}),w>0&&t.jsxs("span",{className:"rounded bg-amber-500/15 px-1 text-[11px] font-semibold text-amber-700 dark:text-amber-400",title:"Default branches whose latest CI is still running",children:[w," running"]}),t.jsxs("span",{className:"ml-auto text-[11px] text-gray-500 dark:text-gray-400",children:[u.length," repo",u.length===1?"":"s"]})]});return t.jsxs("section",{className:"rounded-lg border border-gray-200 dark:border-gray-800","data-testid":"branch-status-panel",children:[x?t.jsxs("button",{type:"button",onClick:()=>d(!y),"aria-expanded":y,className:`flex w-full items-center gap-2 px-2 py-1 text-left hover:bg-gray-50 dark:hover:bg-gray-800/40 ${y?"border-b border-gray-100 dark:border-gray-800/60":""}`,children:[t.jsx(Mt,{dir:y?"down":"right",size:10,className:"shrink-0 text-gray-400"}),k]}):t.jsx("div",{className:`flex items-center gap-2 px-2 py-1 ${y?"border-b border-gray-100 dark:border-gray-800/60":""}`,children:k}),t.jsx("ul",{className:`${n?"":"max-h-64 overflow-y-auto"}${y?"":" hidden"}`,children:u.map(j=>t.jsx(tO,{status:j,fullName:i.get(j.repoId),showRepoName:!n,fullTrends:n},j.repoId))})]})}const nO="h-9 animate-pulse rounded-lg border border-gray-200 bg-gray-50 dark:border-gray-800 dark:bg-gray-900/40",rO="text-[12px] text-gray-500 dark:text-gray-400",sO="text-[12px] text-red-600 dark:text-red-400";function aO(){var r;const e=ay(),n=e.isSuccess&&!e.isPlaceholderData&&!W2(((r=e.data)==null?void 0:r.repos)??[]);return e.data===void 0&&!e.isError?t.jsx("div",{className:nO}):e.isError&&e.data===void 0?t.jsx("p",{className:sO,children:"Couldn’t load the default branches."}):n?t.jsx("p",{className:rO,children:"No default branch has synced yet."}):t.jsx(q2,{})}function oO(e,n){return n==null?null:U2(e,n.myTurn,n.myTurnTotal,(r,s)=>`${r} items are on your plate in this Workspace. The My turn tab lists the ${s} with the highest scores.`)}function iO(e,n){return n==null?null:n.myTurnPersonal==null?oO(e,n):U2(e,n.myTurnPersonal,n.myTurnPersonalTotal,(r,s)=>`${r} items on your plate in this Workspace personally involve you. The My turn tab lists the ${s} with the highest scores.`)}function U2(e,n,r,s){return r==null||e<=0||e!==n||r<=n?null:{shown:e,total:r,title:s(r,e)}}function H2(e){return e.myTurnPersonal??e.myTurn}const z2={mine:{empty:"personally involves you",hidden:"in repos you don’t maintain",withKind:"that personally involves you",bare:"what personally involves you"},others:{empty:"is waiting on someone other than you",hidden:"tied to you directly",withKind:"that isn’t tied to you",bare:"what isn’t tied to you"}},lO={my_turn:"Nothing is your turn right now.",fixing:"No failing builds or merge conflicts are yours to fix.",review:"No reviews are waiting.",threads:"No review threads are waiting for an answer.",land:"Nothing is ready to land.",deps:"No dependency updates or security alerts are waiting."};function cO(e){if(e.cards>0)return null;const n=e.authorLens!=null&&e.allTotal>0?e.authorLens:null,r=n!=null||e.kind!=null||e.relevance!=null;if(e.people>0&&!r)return null;const s=e.kind!=null?`under ${Pn[e.kind]}`:`in ${is[e.tab]}`;return{sentence:n!=null?`Nothing from ${n} ${s} right now.`:e.kind!=null?`Nothing ${s} right now.`:e.relevance!=null?`Nothing on My turn ${z2[e.relevance].empty} right now.`:lO[e.tab],placement:e.people>0?"above":"alone",emptiedBy:n}}function dO(){var J,ne,ae,we,$e,Fe,oe,re,X,le,Ne,Ve,me;const e=G(be=>be.workspaceId),n=G(be=>be.attentionIsolation),r=G(be=>be.attentionTab),s=G(be=>be.setAttentionTab),a=G(be=>be.attentionRelevance),i=G(be=>be.setAttentionRelevance),c=G(be=>be.attentionAuthorLens),d=G(be=>be.setAttentionAuthorLens),{data:u,isLoading:m,isError:h}=tP(e),g=m||e==null,x=lP(n,r),y=f.useMemo(()=>FS(u),[u]),b=f.useMemo(()=>hP(u,x,n,a,c),[u,x,n,a,c]),w=y.find(be=>be.key===x),k=x==="my_turn"?a:null,j=f.useMemo(()=>{const be=Ce=>"prId"in Ce&&typeof Ce.prId=="number"?Ce.prId:null,at=new Set(b.cards.map(Ce=>Ce.id)),ft=Ce=>Ce.kind==="merge"||Ce.kind==="update_branch"||Ce.kind==="conflicts"||Ce.kind==="dependency_bump"||Ce.kind==="security"&&Ce.dependencyUpdate||Ce.kind==="my_turn"&&(Ce.reason==="own_ready"||Ce.reason==="own_conflicts")?0:at.has(Ce.id)?1:2,mt=new Set,se=[];for(const Ce of[...(u==null?void 0:u.cards)??[]].sort((_e,pe)=>ft(_e)-ft(pe))){const _e=be(Ce);if(!(_e==null||mt.has(_e))&&(mt.add(_e),se.push(_e),se.length>=rP))break}return se},[u==null?void 0:u.cards,b.cards]);sP(e,j,!g&&!h);const{workPlan:N}=vt(),I=((J=In().data)==null?void 0:J.deploymentMode)==="cloud",S=aP(e,N),T=oP(e),$=iP(e),P=ei(N),C=((ne=P.data)==null?void 0:ne.summaryTurnLimit)!=null&&(P.data.summaryTurnsRemaining??0)<=0,L=(ae=S.data)!=null&&ae.enabled?S.data.plan??null:null,F=f.useMemo(()=>{var ft,mt;const be=new Map;if(L==null)return be;const at=new Map((((mt=(ft=S.data)==null?void 0:ft.evidence)==null?void 0:mt.items)??[]).flatMap(se=>se.cardId!=null?[[se.id,se.cardId]]:[]));for(const se of L.steps){const Ce=at.get(se.id);Ce!=null&&be.set(Ce,se.why)}return be},[L,($e=(we=S.data)==null?void 0:we.evidence)==null?void 0:$e.items]),M=(Fe=T.data)!=null&&Fe.throttled?"A plan is already being written — the latest shows here shortly.":(oe=T.data)!=null&&oe.creditsExhausted?"Out of AI credits this month — the plan below is the last one written.":(re=T.data)!=null&&re.empty?"Nothing needs doing in this workspace right now.":null,[D,A]=f.useState(!1),W=f.useCallback(()=>A(!0),[]),z=f.useCallback(()=>A(!1),[]),te=(b.kind!=null?`${Pn[b.kind]} (${is[b.tab]})`:k==="mine"?"My turn, only yours":k==="others"?"My turn, not tied to you":is[b.tab])+(c==="people"?", people only":c==="automation"?", automation only":""),H=f.useMemo(()=>({tab:b.tab,rules:u==null?void 0:u.rules,scores:u==null?void 0:u.scores,viewName:te,total:b.total,whyById:F,onOpenGuide:W}),[b.tab,u==null?void 0:u.rules,u==null?void 0:u.scores,te,b.total,F,W]),B=Xc(be=>be.openSettings),O=uP(b.authorSplit,c),E=x==="my_turn"&&pP(w,a),ee=!g&&!h&&(b.chips!=null||E||O||x==="my_turn"),K=cO({tab:x,kind:b.kind,relevance:k,authorLens:c,allTotal:b.allTotal,cards:b.cards.length,people:b.people.length}),U=K!=null&&t.jsxs("div",{className:"rounded-lg border border-dashed border-gray-300 p-6 text-center text-sm text-gray-500 dark:border-gray-700 dark:text-gray-400",children:[t.jsx(Vo,{className:"mr-1.5 inline-block align-[-0.15em] decorative-mark text-gray-300 dark:text-gray-600"}),K.sentence,K.emptiedBy!=null&&t.jsx("div",{className:"mt-2",children:t.jsx("button",{type:"button",onClick:()=>d(null),className:"rounded border border-gray-300 px-2 py-0.5 text-[11px] font-medium text-gray-600 hover:bg-gray-50 dark:border-gray-700 dark:text-gray-300 dark:hover:bg-gray-900/60",children:"Show all"})}),K.emptiedBy==null&&k!=null&&t.jsx("div",{className:"mt-2",children:t.jsx("button",{type:"button",onClick:()=>i(null),className:"rounded border border-gray-300 px-2 py-0.5 text-[11px] font-medium text-gray-600 hover:bg-gray-50 dark:border-gray-700 dark:text-gray-300 dark:hover:bg-gray-900/60",children:"Show everyone’s"})})]}),Q=be=>`shrink-0 rounded-full border px-2 py-0.5 text-[11px] font-medium transition-colors ${be?"border-gray-400 bg-gray-100 text-gray-800 dark:border-gray-500 dark:bg-gray-800 dark:text-gray-100":"border-gray-300 text-gray-500 hover:border-gray-400 dark:border-gray-700 dark:text-gray-400"}`;return t.jsxs("div",{className:"space-y-3","data-testid":"attention-view",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("h2",{className:"text-sm font-semibold text-gray-700 dark:text-gray-200",children:"Pending"}),t.jsx(tF,{onOpenGuide:W,rules:u==null?void 0:u.rules}),N&&!g&&!h&&((u==null?void 0:u.cards.length)??0)>0&&t.jsxs("div",{className:"ml-auto flex items-center gap-1.5",children:[L!=null&&((X=S.data)==null?void 0:X.stale)===!0&&t.jsx("span",{className:"shrink-0 rounded bg-amber-500/10 px-1.5 py-0.5 text-[11px] font-medium text-amber-700 dark:text-amber-400",title:"The list has moved on since this plan was written — the rows are current, the italic lines describe the list as it stood.",children:"stale"}),L!=null&&t.jsxs("span",{className:"shrink-0 text-[11px] text-gray-500 dark:text-gray-400",title:L.model,children:["written ",Nt(L.generatedAt)]}),t.jsx("button",{type:"button",onClick:()=>T.mutate(),disabled:$||C,className:"rounded bg-ai-signal px-2.5 py-0.5 text-[11px] font-semibold text-white hover:opacity-90 disabled:opacity-50 dark:text-gray-950",title:C?"Out of AI credits — resets next month":"Have the model say why some items are worth doing now. The tabs, figures and order are computed either way.",children:$?"Planning…":L!=null?t.jsxs("span",{className:"inline-flex items-center gap-1",children:[t.jsx(us,{size:11}),"Re-plan my day"]}):"Plan my day"})]}),!N&&I&&!g&&!h&&((u==null?void 0:u.cards.length)??0)>0&&t.jsxs("span",{className:"ml-auto text-[11px] text-gray-500 dark:text-gray-400",children:[t.jsx("span",{className:"mr-1 rounded bg-ai-signal/15 px-1 text-[11px] font-semibold text-ai-signal",children:"Pro"}),"Have the model say why some of these come first."]})]}),N&&T.isError&&t.jsx("div",{className:"text-[12px] text-red-600 dark:text-red-400",children:((le=T.error)==null?void 0:le.message)??"Couldn’t write the plan."}),N&&!T.isError&&M!=null&&t.jsx("div",{className:"text-[12px] text-gray-500 dark:text-gray-400",children:M}),L!=null&&L.headline.trim()!==""&&t.jsxs("p",{className:"digest-fade-in flex items-start gap-1.5 text-[12px] italic text-ai-ink",children:[t.jsx(Ps,{size:12,className:"mt-0.5 shrink-0 text-ai-signal"}),t.jsx("span",{children:L.headline})]},L.generatedAt),L!=null&&L.parked!=null&&L.parked.trim()!==""&&t.jsxs("p",{className:"flex items-start gap-1.5 text-[12px] italic text-ai-ink",children:[t.jsx(Ps,{size:12,className:"mt-0.5 shrink-0 text-ai-signal"}),t.jsx("span",{children:L.parked})]}),L!=null&&L.droppedIds>0&&t.jsxs("p",{className:"text-[11px] text-amber-700 dark:text-amber-400",children:[L.droppedIds," reference",L.droppedIds===1?"":"s"," the model named"," ",L.droppedIds===1?"was":"were"," not on this board and"," ",L.droppedIds===1?"was":"were"," discarded."]}),t.jsx("div",{role:"tablist","aria-label":"Pending",className:"flex flex-wrap gap-1 border-b border-gray-200 dark:border-gray-800",children:y.map(be=>{const at=be.key===x,ft=Fk(be,c);return t.jsxs("button",{type:"button",role:"tab","aria-selected":at,"aria-controls":"pending-tabpanel",onClick:()=>s(be.key),className:`-mb-px flex items-center gap-1.5 rounded-t-md border border-b-0 px-3 py-1.5 text-xs font-medium ${at?"border-gray-300 bg-white text-gray-800 dark:border-gray-700 dark:bg-gray-950 dark:text-gray-100":"border-transparent text-gray-600 hover:bg-gray-100 dark:text-gray-400 dark:hover:bg-gray-900/60"}`,children:[is[be.key],t.jsx("span",{className:`rounded-full px-1.5 text-[11px] tabular-nums ${ft===0?"text-gray-500 dark:text-gray-500":at?"bg-gray-800 text-white dark:bg-gray-200 dark:text-gray-900":"bg-gray-500/15 text-gray-700 dark:text-gray-300"}`,children:g?"…":ft})]},be.key)})}),t.jsxs("div",{id:"pending-tabpanel",role:"tabpanel",className:"space-y-3",children:[cP(x)&&t.jsx(aO,{}),ee&&t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[b.chips!=null&&t.jsxs(t.Fragment,{children:[t.jsxs("button",{type:"button",onClick:()=>s(x),"aria-pressed":b.kind==null,className:Q(b.kind==null),children:["All"," ",t.jsx("span",{className:"tabular-nums",children:w!=null?Fk(w,c):0})]}),b.chips.map(be=>t.jsxs("button",{type:"button",onClick:()=>s(x,be.kind),"aria-pressed":b.kind===be.kind,className:Q(b.kind===be.kind),children:[Pn[be.kind]," ",t.jsx("span",{className:"tabular-nums",children:be.total})]},be.kind))]}),E&&t.jsxs("button",{type:"button",onClick:()=>i(a==="mine"?null:"mine"),"aria-pressed":a==="mine",className:Q(a==="mine"),title:`Show only ${z2.mine.bare} — the items you’re named on, and the ones in repos you maintain.`,children:["Only yours"," ",t.jsx("span",{className:"tabular-nums",children:Ok(w,"mine",c)??""})]}),x==="my_turn"&&a==="others"&&t.jsxs("button",{type:"button",onClick:()=>i(null),"aria-pressed":!0,className:Q(!0),children:["Not tied to you"," ",t.jsx("span",{className:"tabular-nums",children:Ok(w,"others",c)??""})]}),(O||x==="my_turn")&&t.jsxs("div",{className:"ml-auto flex flex-wrap items-center gap-3",children:[O&&t.jsxs("div",{role:"group","aria-label":"Who opened it",className:"flex flex-wrap items-center gap-1.5",children:[t.jsxs("button",{type:"button",onClick:()=>d(null),"aria-pressed":c==null,className:Q(c==null),children:["Anyone ",t.jsx("span",{className:"tabular-nums",children:b.allTotal})]}),t.jsxs("button",{type:"button",onClick:()=>d("people"),"aria-pressed":c==="people",className:Q(c==="people"),children:["People ",t.jsx("span",{className:"tabular-nums",children:((Ne=b.authorSplit)==null?void 0:Ne.people)??""})]}),t.jsxs("button",{type:"button",onClick:()=>d("automation"),"aria-pressed":c==="automation",className:Q(c==="automation"),children:["Automation ",t.jsx("span",{className:"tabular-nums",children:((Ve=b.authorSplit)==null?void 0:Ve.automation)??""})]})]}),x==="my_turn"&&t.jsx("button",{type:"button","aria-haspopup":"dialog",className:"text-[12px] font-medium text-sky-700 hover:underline dark:text-sky-400",onClick:()=>B("my-turn"),children:"Customise"})]})]}),g?t.jsx("div",{className:"space-y-3",children:[0,1,2].map(be=>t.jsx("div",{className:"h-20 animate-pulse rounded-lg border border-gray-200 bg-gray-50 dark:border-gray-800 dark:bg-gray-900/40"},be))}):h?t.jsx("div",{className:"text-sm text-red-600 dark:text-red-400",children:"Couldn’t load what needs attention."}):(K==null?void 0:K.placement)==="alone"?U:t.jsxs(t.Fragment,{children:[(K==null?void 0:K.placement)==="above"&&U,t.jsx(qF,{cards:b.cards,users:u==null?void 0:u.users,doNextCount:(u==null?void 0:u.tabs)!=null?b.doNextCount:0,people:b.people,explain:H}),b.shown<b.total&&t.jsx("p",{className:"text-[12px] text-gray-500 dark:text-gray-400",children:JL(b.tab,b.kind,b.shown,b.total,u==null?void 0:u.rules)})]}),x==="my_turn"&&!g&&!h&&(((me=u==null?void 0:u.myTurnDismissed)==null?void 0:me.length)??0)>0&&t.jsx(UF,{items:u.myTurnDismissed})]}),D&&t.jsx(aF,{onClose:z,rules:u==null?void 0:u.rules})]})}function uO(e){return Oe({queryKey:["daily-brief",dt(e)],queryFn:e==null?Ct:()=>he.dailyBrief(e,!0),refetchInterval:5*6e4,refetchIntervalInBackground:!1,staleTime:6e4,refetchOnWindowFocus:!0})}const hO="in this Workspace";function pO(e,n,r){const s=iO(H2(e),e);return s==null||n?s:{...s,title:s.title.replace(hO,`in ${r}`)}}function mO(e){const{myTurnDirect:n,myTurnMaintained:r}=e;return n==null||r==null?null:{direct:n,maintained:r}}function gO(e){if(e.length===0)return null;let n=0,r=0;for(const s of e){if(s.split==null)return null;n+=s.split.direct,r+=s.split.maintained}return{direct:n,maintained:r}}function fO(e){var n;return e==null||e.count<=0?null:{count:e.count,cappedTotal:((n=e.cap)==null?void 0:n.total)??null}}const xO={byWorkspace:new Map,active:null,lines:[],total:0,totalSplit:null,elsewhereCount:0,anyCapped:!1,elsewhereCapped:!1,uncounted:[]};function K2(){const e=G(s=>s.workspaceId),{data:n}=xa(),{data:r}=uO(e);return f.useMemo(()=>{if(r==null)return xO;const s=n??[],a=new Map(s.map(w=>[w.id,w.name])),i=new Map,c=r.workspaceId,d=(w,k,j,N)=>{const I=w===c,S=a.get(w)??N;i.set(w,{workspaceId:w,name:S,isActive:I,count:H2(k),cap:pO(k,I,S),split:mO(k),fresh:j})};d(c,r.counts,!0,"This Workspace");for(const w of r.rollup??[])d(w.workspaceId,w.counts,!1,w.name);const u=[...i.values()].filter(w=>w.count>0).sort((w,k)=>w.isActive!==k.isActive?w.isActive?-1:1:w.name.localeCompare(k.name));let m=0,h=0,g=!1,x=!1;for(const w of u)m+=w.count,w.cap!=null&&(g=!0),!w.isActive&&(h+=w.count,w.cap!=null&&(x=!0));const y=gO(u),b=s.filter(w=>!i.has(w.id)).map(w=>({id:w.id,name:w.name}));return{byWorkspace:i,active:i.get(c)??null,lines:u,total:m,totalSplit:y,elsewhereCount:h,anyCapped:g,elsewhereCapped:x,uncounted:b}},[r,n])}const yO=["7d","14d","30d","90d","custom"],bO=["my_turn","ci_failing","stalled_review","untouched_thread","reviewer_load","reviewer_routing","merge","update_branch","conflicts","security","dependency_bump","bot_signal","bot_only_review"],vO=["view","workspace","activityRepo","attn","attnRel","attnTab","attnPersonal","attnBy","feedPr","feedTab","botsTab","insightsTab","prTab"];function n0(e,n){if(e.length!==n.length)return!1;const r=new Set(e);return n.every(s=>r.has(s))}function r0(e){if(!e)return null;const n=e.split(",").map(r=>Number.parseInt(r,10)).filter(Number.isFinite);return n.length?n:null}function zw(e){if(e==null||!/^[0-9]+$/.test(e))return null;const n=Number.parseInt(e,10);return Number.isFinite(n)&&n>0?n:null}function kO(e){const n=e.get("workspace");return n!=null?zw(n):zw(e.get("team"))}function Kw(e,n){const r=e.get(n);return!!r&&Number.isFinite(Number.parseInt(r,10))}function G2(e){const n=new URLSearchParams(e),r=n.get("view");return r==="timeline"?"timeline":r==="activity"?"activity":r==="open-prs"?"open-prs":r!=null&&(Go(r)!=null||pp(r)!=null||mp(r)!=null)?r:Kw(n,"pr")||Kw(n,"thread")?"timeline":"activity"}function V2(){const e=new URLSearchParams(window.location.search),n={},r=e.get("preset");r&&yO.includes(r)&&(n.preset=r);const s=kO(e);s!=null&&(n.workspaceId=s),n.repoIds=s!=null?r0(e.get("repos")):null,n.userIds=r0(e.get("users")),e.get("bots")!==null&&(n.excludeBots=e.get("bots")==="1");const a=r0(e.get("allowBots"));a&&(n.allowedBotIds=a);const i=e.get("stale");i==="0"?n.excludeStale=!1:i==="1"&&(n.excludeStale=!0);const c=e.get("ci");c==="only"?n.feedCiLens="only":c==="0"?n.feedCiLens="off":c!==null&&(n.feedCiLens="feed"),n.customFrom=e.get("from"),n.customTo=e.get("to");const d=e.get("cats");if(d){const C=new Set(pd);n.categories=d.split(",").filter(L=>C.has(L))}const u=e.get("status");if(u!==null){const C=new Set(md);n.prStatuses=u.split(",").filter(L=>C.has(L))}const m=e.get("reviews");if(m!==null){const C=new Set(Kl);n.reviewStates=m.split(",").filter(L=>C.has(L))}const h=e.get("states");if(h){const C=new Set(wd);n.derivedStates=h.split(",").filter(L=>C.has(L))}const g=e.get("pr");g&&(n.selectedPrId=Number.parseInt(g,10));const x=e.get("thread");x&&(n.selectedThreadId=Number.parseInt(x,10));const y=e.get("activityRepo");if(y)if(y==="bots")n.activityRepoId="bots";else if(y==="attention")n.activityRepoId="attention";else if(y==="feed")n.activityRepoId="feed";else if(y==="insights")n.activityRepoId="insights";else{const C=Number.parseInt(y,10);Number.isFinite(C)&&(n.activityRepoId=C)}const b=e.get("attn");b&&bO.includes(b)&&(n.attentionIsolation=b);const w=e.get("attnTab");Ko.some(C=>C.key===w)&&(n.attentionTab=w);const k=e.get("attnRel");k==="mine"||k==="others"?n.attentionRelevance=k:e.get("attnPersonal")==="1"&&(n.attentionRelevance="mine");const j=e.get("attnBy");(j==="people"||j==="automation")&&(n.attentionAuthorLens=j);const N=e.get("feedPr");if(N){const C=Number.parseInt(N,10);Number.isFinite(C)&&(n.feedIsolatedPrId=C)}const I=e.get("feedTab");(I==="themes"||I==="feed")&&(n.feedInnerTab=I);const S=e.get("botsTab");j4.includes(S??"")&&(n.botsInnerTab=S);const T=e.get("insightsTab");w4.includes(T??"")&&(n.insightsInnerTab=T);const $=e.get("prTab");if($&&N4.includes($)){const C=Go(e.get("view")??"");(C==null?void 0:C.kind)==="pr-detail"&&(n.prDetailTab={prId:C.prId,tab:$})}e.get("reportGrain")==="month"&&(n.insightsReportGrain="month");const P=e.get("report");return P&&(n.insightsReportKey=P),n}let _f=!1,Pf=!1,Ef=null;function wO(e){return Ef!==e?!1:(Ef=null,!0)}function Gp(){_f=!0}let s0=!1;function Gw(){Pf||s0||(s0=!0,queueMicrotask(()=>{s0=!1,oy(G.getState())}))}function oy(e){var u,m;const n=new URLSearchParams;e.preset!=="14d"&&n.set("preset",e.preset),(u=e.repoIds)!=null&&u.length&&n.set("repos",e.repoIds.join(",")),e.workspaceId!=null&&n.set("workspace",String(e.workspaceId)),(m=e.userIds)!=null&&m.length&&n.set("users",e.userIds.join(",")),e.excludeBots||n.set("bots","0"),e.allowedBotIds.length&&n.set("allowBots",e.allowedBotIds.join(",")),e.excludeStale||n.set("stale","0"),e.feedCiLens==="only"?n.set("ci","only"):e.feedCiLens==="feed"&&n.set("ci","1"),e.preset==="custom"&&e.customFrom&&n.set("from",e.customFrom),e.preset==="custom"&&e.customTo&&n.set("to",e.customTo),n0(e.categories,Sh)||n.set("cats",e.categories.join(",")),n0(e.prStatuses,Rh)||n.set("status",e.prStatuses.join(",")),n0(e.reviewStates,Ch)||n.set("reviews",e.reviewStates.join(",")),e.derivedStates.length&&n.set("states",e.derivedStates.join(",")),e.selectedPrId&&n.set("pr",String(e.selectedPrId)),e.selectedThreadId&&n.set("thread",String(e.selectedThreadId));const r=Ge.getState().activeTab;if(r==="timeline")n.set("view","timeline");else if(r==="open-prs")n.set("view","open-prs");else if(r==="activity")n.set("view","activity"),e.activityRepoId==="attention"&&e.attentionIsolation&&n.set("attn",e.attentionIsolation),e.activityRepoId==="attention"&&e.attentionTab!=null&&n.set("attnTab",e.attentionTab),e.activityRepoId==="attention"&&e.attentionRelevance!=null&&n.set("attnRel",e.attentionRelevance),e.activityRepoId==="attention"&&e.attentionAuthorLens!=null&&n.set("attnBy",e.attentionAuthorLens),e.feedIsolatedPrId!=null&&(e.activityRepoId==="feed"||typeof e.activityRepoId=="number")&&n.set("feedPr",String(e.feedIsolatedPrId)),e.activityRepoId==="feed"&&e.feedInnerTab!=="feed"&&n.set("feedTab",e.feedInnerTab),e.activityRepoId==="bots"&&e.botsInnerTab!=="roi"&&n.set("botsTab",e.botsInnerTab),typeof e.activityRepoId=="number"?n.set("activityRepo",String(e.activityRepoId)):e.activityRepoId==="feed"?n.set("activityRepo","feed"):e.activityRepoId==="bots"?n.set("activityRepo","bots"):e.activityRepoId==="insights"&&(n.set("activityRepo","insights"),e.insightsInnerTab!=="overview"&&n.set("insightsTab",e.insightsInnerTab),e.insightsReportGrain!=="sprint"&&n.set("reportGrain",e.insightsReportGrain),e.insightsReportKey&&n.set("report",e.insightsReportKey));else if(Go(r)!=null||pp(r)!=null||mp(r)!=null){n.set("view",r);const h=Go(r);(h==null?void 0:h.kind)==="pr-detail"&&e.prDetailTab!=null&&e.prDetailTab.prId===h.prId&&e.prDetailTab.tab!=="overview"&&n.set("prTab",e.prDetailTab.tab)}const s=n.toString(),a=`${window.location.pathname}${s?`?${s}`:""}`,i=_f;if(_f=!1,a===window.location.pathname+window.location.search)return;const c=new URLSearchParams(window.location.search);if(vO.some(h=>c.get(h)!==n.get(h))&&!i)try{window.history.pushState(null,"",a);return}catch{}window.history.replaceState(null,"",a)}const Af="pierre:filterBarState",Q2=4;function jO(e){let n=e;if(n.v===2){const{excludeBots:r,allowedBotIds:s,...a}=n;n={...a,v:3}}if(n.v===3){const{feedCiLens:r,...s}=n;n={...s,v:4}}return n}const Mf="pierre:workspaceScope",Y2=1;function NO(){try{const e=localStorage.getItem(Af);if(!e)return null;const n=JSON.parse(e);if(!n||typeof n!="object")return null;const r=jO(n);return r.v!==Q2?(localStorage.removeItem(Af),null):I4(r)}catch{return null}}function SO(e){try{localStorage.setItem(Af,JSON.stringify({v:Q2,...R4(e)}))}catch{}}function CO(){try{const e=localStorage.getItem(Mf);if(!e)return null;const n=JSON.parse(e);return!n||typeof n!="object"?null:n.v!==Y2?(localStorage.removeItem(Mf),null):$4(n).workspaceId??null}catch{return null}}function RO(e){if(e.workspaceId!=null)try{localStorage.setItem(Mf,JSON.stringify({v:Y2,...T4(e)}))}catch{}}function IO(e){Pf=!0;try{const n=V2(),r=G.getState().workspaceId;Ef=n.workspaceId!=null&&n.repoIds!=null?n.workspaceId:null,G.getState().hydrate({...gp(),..._4(),...n.workspaceId==null&&r!=null?{workspaceId:r}:{},...n}),Ge.getState().applyUrlTab(G2(window.location.search),e),Gp(),oy(G.getState())}finally{Pf=!1}}function TO(){const e=f.useRef(!1);f.useEffect(()=>{if(!e.current){if(window.location.search.length>1)G.getState().hydrate(V2());else{const i=NO();i&&G.getState().hydrate(i);const c=CO();c!=null&&G.getState().hydrate({workspaceId:c})}Ge.getState().applyUrlTab(G2(window.location.search)),Gp(),oy(G.getState()),e.current=!0}const n=G.subscribe(a=>{Gw(),SO(a),RO(a)}),r=Ge.subscribe(()=>{Gw()}),s=()=>IO({fromPop:!0});return window.addEventListener("popstate",s),()=>{n(),r(),window.removeEventListener("popstate",s)}},[])}function iy(e,n=300){const[r,s]=f.useState(e);return f.useEffect(()=>{const a=setTimeout(()=>s(e),n);return()=>clearTimeout(a)},[e,n]),r}const $O=[{owner:"mrdoob",name:"three.js",category:"Graphics",why:"The de-facto JavaScript 3D library (WebGL/WebGPU) behind most browser 3D and creative coding."},{owner:"bevyengine",name:"bevy",category:"Game engines",why:"A refreshingly simple, data-driven game engine in Rust with one of open source’s most active engine communities."},{owner:"obsproject",name:"obs-studio",category:"Media",why:"The industry-standard open-source live-streaming and screen-recording suite."},{owner:"huggingface",name:"transformers",category:"Machine learning",why:"The model-definition framework behind state-of-the-art NLP/vision/audio models; hub of the open ML ecosystem."},{owner:"pytorch",name:"pytorch",category:"Machine learning",why:"Meta’s deep-learning framework that dominates research and increasingly production training."},{owner:"ollama",name:"ollama",category:"Machine learning",why:"The easiest way to run open LLMs locally; explosive recent adoption."},{owner:"ggml-org",name:"llama.cpp",category:"Machine learning",why:"Highly optimized C/C++ LLM inference that made local, quantized model serving mainstream."},{owner:"numpy",name:"numpy",category:"Scientific computing",why:"The foundational N-dimensional array library underpinning essentially all of Python’s scientific stack."},{owner:"pola-rs",name:"polars",category:"Data science",why:"A blazing-fast multi-threaded DataFrame query engine in Rust; the modern challenger to pandas."},{owner:"jupyter",name:"notebook",category:"Data science",why:"The interactive notebook that became the lingua franca of data science and research computing."},{owner:"rust-lang",name:"rust",category:"Languages",why:"The Rust language and compiler; a memory-safe systems language topping developer-love surveys."},{owner:"golang",name:"go",category:"Languages",why:"Google’s Go language and toolchain; the backbone of modern cloud and infrastructure software."},{owner:"duckdb",name:"duckdb",category:"Databases",why:"An in-process analytical SQL database — the “SQLite for analytics” — surging across data tooling."},{owner:"redis",name:"redis",category:"Databases",why:"The ubiquitous in-memory data store used for caching, queues, and real-time data."},{owner:"cockroachdb",name:"cockroach",category:"Databases",why:"A distributed, PostgreSQL-compatible SQL database built for resilience and horizontal scale."},{owner:"sveltejs",name:"svelte",category:"Web frameworks",why:"A compiler-first UI framework producing tiny, fast apps; consistently top-rated for satisfaction."},{owner:"denoland",name:"deno",category:"Runtimes",why:"A secure, TypeScript-first JavaScript runtime from Node’s original creator."},{owner:"neovim",name:"neovim",category:"Dev tools",why:"The hyperextensible, Lua-scriptable Vim fork that became the modern terminal editor of choice."},{owner:"openssl",name:"openssl",category:"Security",why:"The cryptography and TLS library securing a huge fraction of the internet’s traffic."},{owner:"tldraw",name:"tldraw",category:"Visualization",why:"An infinite-canvas drawing SDK and whiteboard; a slick showcase of modern web UI and real-time collab."}],_O=[{owner:"InsForge",name:"InsForge",category:"Bot monitoring",why:"CodeRabbit, cubic, Greptile and Copilot all review here — the densest bot mix we found."},{owner:"opentibiabr",name:"canary",category:"Bot monitoring",why:"Five review bots on one C++ codebase: CodeRabbit, SonarCloud, Gemini, Copilot, Greptile."},{owner:"BerriAI",name:"litellm",category:"Bot monitoring",why:"Greptile, Cursor Bugbot and Devin on a very high-velocity AI library."},{owner:"twentyhq",name:"twenty",category:"Bot monitoring",why:"cubic, Greptile and Copilot review a busy TypeScript CRM."},{owner:"obot-platform",name:"obot",category:"Bot monitoring",why:"Copilot reviewer and CodeRabbit side by side on every PR."},{owner:"pingdotgg",name:"t3code",category:"Bot monitoring",why:"Macroscope, Cursor Bugbot and CodeRabbit on a fast-moving young codebase."},{owner:"ai-dynamo",name:"dynamo",category:"Bot monitoring",why:"CodeRabbit, Devin and an in-house review agent on NVIDIA’s inference stack."},{owner:"redis",name:"go-redis",category:"Bot monitoring",why:"Codex, Copilot reviewer and Cursor Bugbot on a mainstream Go client."}],a0=2,PO=["repos","timeline","open-prs","users","my-turn","me","workspaces",...ac];function Vw(e){return e>=1e6?`${(e/1e6).toFixed(1)}m`:e>=1e3?`${(e/1e3).toFixed(e>=1e4?0:1)}k`:String(e)}function Qw({login:e,src:n}){return n?t.jsx("img",{src:n,alt:e,width:20,height:20,className:"mt-0.5 h-5 w-5 shrink-0 rounded-full"}):t.jsx("span",{className:"mt-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-gray-300 text-[9px] font-semibold text-gray-700 dark:bg-gray-700 dark:text-gray-200",children:e.slice(0,2).toUpperCase()})}function Yw(){return t.jsx("span",{className:"inline-block h-3 w-3 shrink-0 animate-spin rounded-full border-2 border-gray-300 border-t-blue-500 dark:border-gray-600 dark:border-t-blue-400"})}function Lf({onAdded:e,placeholder:n="Search repos to add…",autoFocus:r=!1}={}){var $e,Fe;const s=He(),a=G(oe=>oe.requestSyncModal),i=G(oe=>oe.showRepo),c=f.useRef(null),d=f.useRef(null),u=f.useId(),[m,h]=f.useState(""),[g,x]=f.useState(!1),[y,b]=f.useState(0),[w,k]=f.useState(new Set),j=oe=>`${oe.owner}/${oe.name}`.toLowerCase(),[N,I]=f.useState([null]),[S,T]=f.useState(0),$=m.trim(),P=iy($,300),C=g&&P.length>=a0,L=g&&P.length<a0,F=C||L,M=N[S]??null,{data:D}=xn(),A=((D==null?void 0:D.length)??0)>=ik,W=f.useMemo(()=>new Set((D??[]).map(oe=>`${oe.owner}/${oe.name}`.toLowerCase())),[D]),z=f.useMemo(()=>$O.filter(oe=>!W.has(`${oe.owner}/${oe.name}`.toLowerCase())&&!w.has(`${oe.owner}/${oe.name}`.toLowerCase())),[W,w]),te=f.useMemo(()=>_O.filter(oe=>!W.has(`${oe.owner}/${oe.name}`.toLowerCase())&&!w.has(`${oe.owner}/${oe.name}`.toLowerCase())),[W,w]);f.useEffect(()=>{I([null]),T(0),b(0)},[P]);const H=Oe({queryKey:["repo-search",P,M],queryFn:()=>he.searchRepos(P,M??void 0),enabled:C,placeholderData:oe=>oe,staleTime:6e4}),B=tt({mutationFn:oe=>he.addRepo({owner:oe.owner,name:oe.name}),onMutate:oe=>{k(re=>new Set(re).add(j(oe)))},onSuccess:oe=>{for(const re of PO)s.invalidateQueries({queryKey:[re]});s.invalidateQueries({queryKey:["repo-search"]}),a(oe.id),i(oe.id),e==null||e(oe)}}),O=((($e=H.data)==null?void 0:$e.results)??[]).filter(oe=>!w.has(`${oe.owner}/${oe.name}`.toLowerCase())),E=((Fe=H.data)==null?void 0:Fe.hasNextPage)??!1,ee=$.length>=a0&&$!==P,K=C&&(ee||H.isFetching||H.isPlaceholderData),U=f.useMemo(()=>[...te,...z],[te,z]),Q=L?U:O;f.useEffect(()=>{b(oe=>Q.length?Math.min(oe,Q.length-1):0)},[Q]),Yr(c,()=>x(!1),g),f.useEffect(()=>{var oe,re;(re=(oe=d.current)==null?void 0:oe.querySelector(`[data-idx="${y}"]`))==null||re.scrollIntoView({block:"nearest"})},[y,Q]);function J(){var re;const oe=(re=H.data)==null?void 0:re.cursor;!E||oe==null||(I(X=>[...X.slice(0,S+1),oe]),T(X=>X+1),b(0))}function ne(){S!==0&&(T(oe=>oe-1),b(0))}function ae(oe){if(oe.key==="Escape"){x(!1);return}if(F){if(oe.key==="ArrowDown")oe.preventDefault(),b(re=>Math.min(re+1,Math.max(Q.length-1,0)));else if(oe.key==="ArrowUp")oe.preventDefault(),b(re=>Math.max(re-1,0));else if(oe.key==="Enter"){oe.preventDefault();const re=Q[y];re&&!B.isPending&&!A&&B.mutate({owner:re.owner,name:re.name})}}}function we(oe,re){var le,Ne;const X=B.isPending&&((le=B.variables)==null?void 0:le.owner)===oe.owner&&((Ne=B.variables)==null?void 0:Ne.name)===oe.name;return t.jsxs("div",{className:`flex items-stretch ${re===y?"bg-gray-100 dark:bg-gray-800":""} hover:bg-gray-100 dark:hover:bg-gray-800`,children:[t.jsxs("button",{id:`${u}-opt-${re}`,"data-idx":re,type:"button",role:"option","aria-selected":re===y,disabled:B.isPending||A,onMouseEnter:()=>b(re),onClick:()=>B.mutate({owner:oe.owner,name:oe.name}),className:"flex min-w-0 flex-1 items-start gap-2 px-3 py-2 text-left disabled:opacity-60",children:[t.jsx(Qw,{login:oe.owner,src:null}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsxs("span",{className:"flex items-center gap-1.5",children:[t.jsxs("span",{className:"truncate text-xs font-medium text-gray-800 dark:text-gray-100",title:`${oe.owner}/${oe.name}`,children:[oe.owner,"/",oe.name]}),t.jsx("span",{className:"shrink-0 rounded bg-gray-100 px-1 text-[9px] uppercase tracking-wide text-gray-500 dark:bg-gray-800 dark:text-gray-400",children:oe.category})]}),t.jsx("span",{className:"mt-0.5 line-clamp-2 text-[11px] text-gray-500 dark:text-gray-400",children:oe.why})]}),t.jsx("span",{className:"mt-0.5 shrink-0 rounded bg-blue-600 px-1.5 py-0.5 text-[10px] text-white",children:X?"Adding…":"Add"})]}),t.jsx("a",{href:`https://github.com/${oe.owner}/${oe.name}`,target:"_blank",rel:"noopener noreferrer",onClick:Ve=>Ve.stopPropagation(),title:"Open on GitHub","aria-label":`Open ${oe.owner}/${oe.name} on GitHub`,className:"flex shrink-0 items-center px-2 text-[10px] text-gray-400 hover:text-gray-700 dark:hover:text-gray-200",children:t.jsx(_t,{size:12})})]},`${oe.owner}/${oe.name}`)}return t.jsxs("div",{ref:c,className:"relative",children:[t.jsx("input",{id:"add-repo-input",type:"search",value:m,onChange:oe=>{h(oe.target.value),x(!0)},onFocus:()=>x(!0),onKeyDown:ae,autoFocus:r,placeholder:n,role:"combobox","aria-expanded":F,"aria-controls":u,"aria-autocomplete":"list","aria-activedescendant":F&&Q[y]?`${u}-opt-${y}`:void 0,className:"w-44 rounded border border-gray-300 bg-transparent px-2 py-0.5 text-xs focus:border-blue-500 focus:outline-none dark:border-gray-700"}),F&&t.jsxs("div",{id:u,role:"listbox","aria-label":"Repository search results",className:"absolute left-0 top-full z-[60] mt-1 max-h-96 w-96 overflow-y-auto rounded-lg border border-gray-200 bg-white shadow-lg dark:border-gray-700 dark:bg-gray-900",children:[A&&t.jsxs("div",{className:"sticky top-0 z-20 border-b border-amber-300 bg-amber-50 px-3 py-1.5 text-[11px] text-amber-700 dark:border-amber-800 dark:bg-amber-950/40 dark:text-amber-300",children:["You’ve added the maximum of ",ik," repos. Remove one to add another."]}),L?t.jsx("div",{ref:d,children:te.length===0&&z.length===0?t.jsxs("div",{children:[t.jsx("div",{className:"sticky top-0 z-10 border-b border-gray-200 bg-white px-3 py-1.5 text-[10px] font-semibold uppercase tracking-wide text-gray-400 dark:border-gray-700 dark:bg-gray-900",children:"Suggested repos"}),t.jsx("div",{className:"px-3 py-2 text-xs text-gray-500 dark:text-gray-400",children:"You’ve already added all the suggestions."})]}):t.jsxs(t.Fragment,{children:[te.length>0&&t.jsxs("div",{children:[t.jsxs("div",{className:"sticky top-0 z-10 border-b border-gray-200 bg-white px-3 py-1.5 dark:border-gray-700 dark:bg-gray-900",children:[t.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-wide text-gray-400",children:"Bot monitoring demos"}),t.jsx("div",{className:"mt-0.5 text-[10px] leading-snug text-gray-400 dark:text-gray-500",children:"Several AI review bots are active in these — good for exploring the Bots tab. First sync can take a few minutes."})]}),te.map((oe,re)=>we(oe,re))]}),z.length>0&&t.jsxs("div",{children:[t.jsx("div",{className:"sticky top-0 z-10 border-b border-gray-200 bg-white px-3 py-1.5 text-[10px] font-semibold uppercase tracking-wide text-gray-400 dark:border-gray-700 dark:bg-gray-900",children:"Suggested repos"}),z.map((oe,re)=>we(oe,te.length+re))]})]})}):H.isError?t.jsx("div",{className:"px-3 py-2 text-xs text-red-500",children:H.error instanceof cn?H.error.message:"Search failed"}):K&&O.length===0?t.jsxs("div",{className:"flex items-center justify-center gap-2 px-3 py-6 text-xs text-gray-500 dark:text-gray-400",children:[t.jsx(Yw,{}),t.jsx("span",{children:"Searching…"})]}):O.length===0?t.jsx("div",{className:"px-3 py-2 text-xs text-gray-500 dark:text-gray-400",children:"No matching repositories."}):t.jsxs("div",{ref:d,children:[K&&t.jsxs("div",{className:"sticky top-0 z-10 flex items-center gap-2 border-b border-gray-200 bg-white/95 px-3 py-1.5 text-[11px] text-gray-500 backdrop-blur dark:border-gray-700 dark:bg-gray-900/95 dark:text-gray-400",children:[t.jsx(Yw,{}),t.jsx("span",{children:"Searching…"})]}),O.map((oe,re)=>{var le,Ne;const X=B.isPending&&((le=B.variables)==null?void 0:le.owner)===oe.owner&&((Ne=B.variables)==null?void 0:Ne.name)===oe.name;return t.jsxs("div",{className:`flex items-stretch ${re===y?"bg-gray-100 dark:bg-gray-800":""} hover:bg-gray-100 dark:hover:bg-gray-800`,children:[t.jsxs("button",{id:`${u}-opt-${re}`,"data-idx":re,type:"button",role:"option","aria-selected":re===y,disabled:B.isPending,onMouseEnter:()=>b(re),onClick:()=>B.mutate({owner:oe.owner,name:oe.name}),className:"flex min-w-0 flex-1 items-start gap-2 px-3 py-2 text-left disabled:opacity-60",children:[t.jsx(Qw,{login:oe.owner,src:oe.ownerAvatarUrl}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsxs("span",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:"truncate text-xs font-medium text-gray-800 dark:text-gray-100",title:oe.fullName,children:oe.fullName}),oe.isPrivate&&t.jsx("span",{className:"shrink-0 rounded bg-gray-200 px-1 text-[9px] uppercase tracking-wide text-gray-500 dark:bg-gray-700 dark:text-gray-300",children:"private"}),oe.isOwnedOrMember&&t.jsx("span",{className:"shrink-0 rounded bg-sky-100 px-1 text-[9px] uppercase tracking-wide text-sky-700 dark:bg-sky-900/50 dark:text-sky-300",children:"yours"})]}),oe.description&&t.jsx("span",{className:"mt-0.5 line-clamp-2 text-[11px] text-gray-500 dark:text-gray-400",children:oe.description}),t.jsxs("span",{className:"mt-0.5 flex items-center gap-2 text-[10px] text-gray-400",children:[t.jsxs("span",{className:"flex items-center gap-1",title:`${oe.stargazerCount} stars`,children:[t.jsx(kx,{size:10}),Vw(oe.stargazerCount)]}),t.jsx("span",{"aria-hidden":!0,children:"·"}),t.jsxs("span",{title:`${oe.openPrCount} open pull requests`,children:[Vw(oe.openPrCount)," open PR",oe.openPrCount===1?"":"s"]})]})]}),t.jsx("span",{className:"mt-0.5 shrink-0 rounded bg-blue-600 px-1.5 py-0.5 text-[10px] text-white",children:X?"Adding…":"Add"})]}),t.jsx("a",{href:mn(oe.url)??`https://github.com/${oe.owner}/${oe.name}`,target:"_blank",rel:"noopener noreferrer",onClick:Ve=>Ve.stopPropagation(),title:"Open on GitHub","aria-label":`Open ${oe.fullName} on GitHub`,className:"flex shrink-0 items-center px-2 text-[10px] text-gray-400 hover:text-gray-700 dark:hover:text-gray-200",children:t.jsx(_t,{size:12})})]},oe.githubNodeId)})]}),!L&&(S>0||E)&&t.jsxs("div",{className:"sticky bottom-0 flex items-center justify-between border-t border-gray-200 bg-white px-3 py-1.5 text-[11px] dark:border-gray-700 dark:bg-gray-900",children:[t.jsxs("button",{type:"button",onClick:ne,disabled:S===0,className:"flex items-center gap-1 text-gray-500 hover:text-gray-800 disabled:opacity-30 dark:text-gray-400 dark:hover:text-gray-100",children:[t.jsx(Mt,{dir:"left",size:11}),"Prev"]}),t.jsxs("span",{className:"text-gray-400",children:["Page ",S+1]}),t.jsxs("button",{type:"button",onClick:J,disabled:!E,className:"flex items-center gap-1 text-gray-500 hover:text-gray-800 disabled:opacity-30 dark:text-gray-400 dark:hover:text-gray-100",children:["Next",t.jsx(Mt,{dir:"right",size:11})]})]}),B.error&&t.jsx("div",{className:"border-t border-gray-200 px-3 py-1.5 text-[11px] text-red-500 dark:border-gray-700",children:B.error instanceof cn?B.error.message:"Failed to add repo"})]})]})}function Xw({size:e=14}){return t.jsxs("svg",{viewBox:"0 0 24 24",width:e,height:e,fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[t.jsx("path",{d:"M12 3v12"}),t.jsx("polyline",{points:"7 10 12 15 17 10"}),t.jsx("line",{x1:"5",y1:"21",x2:"19",y2:"21"})]})}function EO(e){if(!e)return"resuming shortly";const n=new Date(e);return Number.isNaN(n.getTime())?"resuming shortly":`resuming ~${n.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}`}function X2({repos:e,statuses:n,ml:r,cancelling:s,onCancel:a,onDismiss:i}){const c=k=>n==null?void 0:n.find(j=>j.repoId===k),d=k=>{if(n===void 0)return!0;const j=c(k);return j===void 0||j.status==="running"},u=e.filter(k=>!d(k.id)).length,m=e.length>0&&u===e.length,h=Tp(r),g=f.useRef(0);r&&r.pending>g.current&&(g.current=r.pending);const x=g.current,y=Math.max(0,x-((r==null?void 0:r.pending)??0)),b=x>0?Math.min(100,Math.round(y/x*100)):h?0:100,w=!!(r!=null&&r.enabled)&&(h||y>0);return t.jsxs("div",{children:[t.jsx("div",{className:"mb-3 flex items-center justify-between",children:t.jsx("h2",{className:"text-sm font-semibold",children:s?"Cancelling…":e.length===0?"Starting sync…":m?h?"Scoring bot comments…":"Sync complete":`Syncing ${e.length} repo${e.length===1?"":"s"}`})}),t.jsx("ul",{className:"space-y-3",children:e.map(k=>{var P,C,L;const j=c(k.id),N=d(k.id),I=(j==null?void 0:j.status)==="error",S=(j==null?void 0:j.status)==="running"?(P=j.progress)==null?void 0:P.paused:void 0,T=((C=j==null?void 0:j.progress)==null?void 0:C.prsProcessed)??0,$=N?Math.round((((L=j==null?void 0:j.progress)==null?void 0:L.percent)??0)*100):100;return t.jsxs("li",{children:[t.jsxs("div",{className:"mb-1 flex items-baseline justify-between gap-2 text-xs",children:[t.jsx("span",{className:"truncate font-medium",title:k.fullName,children:k.fullName}),t.jsx("span",{className:"shrink-0 text-gray-500 dark:text-gray-400",children:I?t.jsx("span",{className:"text-red-500",children:"error"}):(S==null?void 0:S.reason)==="rate_limit"?t.jsxs("span",{className:"text-amber-600 dark:text-amber-400",children:["Paused — GitHub rate limit, ",EO(S.resumeAt)]}):(S==null?void 0:S.reason)==="queued"?t.jsx("span",{children:"Waiting for another sync…"}):N?`${$}%${T>0?` · ${T} PRs`:""}`:t.jsxs("span",{className:"inline-flex items-center gap-1 text-green-600 dark:text-green-400",children:[t.jsx(pr,{size:12}),"done",T>0?` · ${T} PRs`:""]})})]}),t.jsx("div",{className:"h-2 w-full overflow-hidden rounded bg-gray-200 dark:bg-gray-800",children:t.jsx("div",{className:`h-2 rounded transition-all duration-500 ${I?"bg-red-500":(S==null?void 0:S.reason)==="rate_limit"?"bg-amber-500":(S==null?void 0:S.reason)==="queued"?"bg-gray-400 dark:bg-gray-600":N?"bg-blue-500":"bg-green-500"}`,style:{width:`${I?100:$}%`}})})]},k.id)})}),w&&t.jsxs("div",{className:"mt-3 border-t border-gray-100 pt-3 dark:border-gray-800",children:[t.jsxs("div",{className:"mb-1 flex items-baseline justify-between gap-2 text-xs",children:[t.jsx("span",{className:"truncate font-medium",title:"Local severity model — nothing billed",children:"Scoring bot comments"}),t.jsx("span",{className:"shrink-0 text-gray-500 dark:text-gray-400",children:h?`${b}%${r&&r.pending>0?` · ${r.pending.toLocaleString()} to go`:""}`:t.jsxs("span",{className:"inline-flex items-center gap-1 text-green-600 dark:text-green-400",children:[t.jsx(pr,{size:12}),"scored",y>0?` · ${y.toLocaleString()}`:""]})})]}),t.jsx("div",{className:"h-2 w-full overflow-hidden rounded bg-gray-200 dark:bg-gray-800",children:t.jsx("div",{className:`h-2 rounded transition-all duration-500 ${h?"bg-ai-signal-fill":"bg-green-500"}`,style:{width:`${b}%`}})}),t.jsxs("p",{className:"mt-1 text-[11px] leading-snug text-gray-500 dark:text-gray-400",children:[r!=null&&r.markerFallback?"Severity model unavailable — labelling from markers only.":"Severity + category labels for the bot comments this sync brought in.",r&&r.unscorable>0?` ${r.unscorable.toLocaleString()} unscorable (no stored text).`:null]})]}),t.jsxs("div",{className:"mt-4 flex items-center justify-between gap-3 text-xs text-gray-500 dark:text-gray-400",children:[t.jsxs("span",{children:[u," of ",e.length," repo",e.length===1?"":"s"," complete"]}),m&&!s?t.jsx("button",{type:"button",onClick:i,title:h?"Close this. Scoring keeps running in the background.":"Close",className:"rounded border border-gray-300 px-3 py-1 text-gray-600 hover:border-gray-400 hover:bg-gray-50 dark:border-gray-700 dark:text-gray-300 dark:hover:bg-gray-800",children:h?"Continue in background":"Close"}):t.jsx("button",{type:"button",onClick:a,disabled:s,title:"Stop the sync and remove any repos still loading for the first time",className:"rounded border border-red-300 px-3 py-1 text-red-600 hover:border-red-400 hover:bg-red-50 disabled:opacity-50 dark:border-red-900 dark:text-red-400 dark:hover:bg-red-950",children:s?"Cancelling…":"Cancel"})]})]})}function AO(){const e=G(m=>m.syncRound),{data:n}=Oe({queryKey:["repos"],queryFn:he.listRepos}),r=(n??[]).map(m=>m.id).join(","),{data:s}=Oe({queryKey:["sync-status",r],enabled:e.syncing&&!!n&&n.length>0,queryFn:()=>Promise.all((n??[]).map(m=>he.syncStatus(m.id))),refetchInterval:1500}),{data:a}=$x(e.open||e.syncing);if(!e.open)return null;const i=new Set(e.scopeIds),c=i.size===0?n??[]:(n??[]).filter(m=>i.has(m.id)),d=new Set(c.map(m=>m.id)),u=s==null?void 0:s.filter(m=>d.has(m.repoId));return t.jsx(X2,{repos:c,statuses:u,ml:a,cancelling:e.cancelling,onCancel:()=>{var m;return(m=Ih())==null?void 0:m.cancel()},onDismiss:()=>{var m;return(m=Ih())==null?void 0:m.dismiss()}})}function MO({onClose:e}){const n=He(),{data:r}=xa(),{data:s}=xn(),a=G(ne=>ne.workspaceId),i=G(ne=>ne.setWorkspace),{createWorkspace:c,renameWorkspace:d,deleteWorkspace:u,assignRepoToWorkspace:m}=Ix(),h=G(ne=>ne.syncRound),g=G(ne=>ne.setManagerOpen);f.useEffect(()=>(g(!0),()=>g(!1)),[g]);const x=f.useRef(null);Yr(x,e,!0),f.useEffect(()=>{const ne=ae=>{ae.key==="Escape"&&(ae.stopPropagation(),e())};return document.addEventListener("keydown",ne),()=>document.removeEventListener("keydown",ne)},[e]);const[y,b]=f.useState(null),w=f.useRef(null);f.useEffect(()=>()=>{w.current!=null&&clearTimeout(w.current)},[]);const k=(ne,ae)=>{w.current!=null&&clearTimeout(w.current),b({repoId:ne,kind:ae}),w.current=setTimeout(()=>{b(null),w.current=null},6e3)},j=()=>{var ne;window.confirm("Deep re-sync re-fetches the full backfill window for every repo. Slower, but catches CI/thread changes the incremental sync can lag. Continue?")&&((ne=Ih())==null||ne.syncAllDeep())},N=ne=>{window.confirm(`Deep re-sync ${ne.fullName}? Re-fetches its full backfill window — slower, and uses more GitHub quota than the regular sync. Continue?`)&&(async()=>{var we;const ae=await((we=Ih())==null?void 0:we.syncOneDeep(ne.id))??"error";ae!=="started"&&k(ne.id,ae)})()},[I,S]=f.useState(""),[T,$]=f.useState(null),[P,C]=f.useState(null),[L,F]=f.useState(""),M=f.useMemo(()=>r??[],[r]),D=f.useMemo(()=>M.find(ne=>ne.isDefault)??null,[M]),A=f.useMemo(()=>M.find(ne=>ne.id===T)??M.find(ne=>ne.id===a)??D??M[0]??null,[M,T,a,D]),W=f.useMemo(()=>{const ne=new Set(M.map(we=>we.id)),ae=(D==null?void 0:D.id)??null;return we=>ne.has(we.workspaceId)?we.workspaceId:ae},[M,D]),z=f.useMemo(()=>[...s??[]].sort((ne,ae)=>ne.fullName.localeCompare(ae.fullName)),[s]),te=s!=null&&s.length===0,H=f.useMemo(()=>A?z.filter(ne=>W(ne)===A.id):[],[z,A,W]),B=f.useMemo(()=>A?z.filter(ne=>W(ne)!==A.id):z,[z,A,W]),O=tt({mutationFn:ne=>he.deleteRepo(ne),onSettled:()=>{for(const ne of["repos","timeline","open-prs","users","my-turn","me","workspaces","workspace-metrics","workspace-metrics-detail","period-reports","period-report",...ac])n.invalidateQueries({queryKey:[ne]})}}),E=()=>{const ne=I.trim();ne&&c.mutate(ne,{onSuccess:ae=>{S(""),$(ae.workspace.id)}})},ee=ne=>{const ae=L.trim();ae&&d.mutate({id:ne,name:ae}),C(null)},K=(ne,ae)=>{m.mutate({workspaceId:ae,repoId:ne})},U=ne=>{window.confirm(`Remove ${ne.fullName}? This deletes all of its locally-synced data.`)&&O.mutate(ne.id)},Q=ne=>{const ae=(D==null?void 0:D.name)??"Default";window.confirm(`Delete workspace “${ne.name}”? Its repos move to “${ae}”, along with its bot settings — any verdict or price already set in “${ae}” is kept.`)&&(u.mutate(ne.id),T===ne.id&&$(null))},J=ne=>{const ae=W(ne),we=(y==null?void 0:y.repoId)===ne.id?y:null;return t.jsxs("li",{className:"group rounded px-1 py-1 text-xs hover:bg-gray-100 dark:hover:bg-gray-800",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("span",{className:"min-w-0 flex-1 truncate",title:ne.fullName,children:[t.jsxs("span",{className:"text-gray-400",children:[ne.owner,"/"]}),t.jsx("span",{className:"font-medium text-gray-800 dark:text-gray-100",children:ne.name})]}),t.jsx("select",{value:ae??"",disabled:ae==null||m.isPending,"aria-label":`Workspace for ${ne.fullName}`,title:`Move ${ne.fullName} to another workspace (it leaves the one it's in now)`,onChange:$e=>{const Fe=Number($e.target.value);Number.isFinite(Fe)&&Fe!==ae&&K(ne.id,Fe)},className:"max-w-[9rem] shrink-0 truncate rounded border border-gray-300 bg-transparent px-1 py-0.5 text-[11px] focus:border-blue-500 focus:outline-none disabled:opacity-40 dark:border-gray-700",children:M.map($e=>t.jsx("option",{value:$e.id,children:$e.name},$e.id))}),t.jsx("button",{type:"button",onClick:()=>N(ne),title:`Deep re-sync ${ne.fullName} — re-fetches its full backfill window`,"aria-label":`Deep re-sync ${ne.fullName}`,className:"shrink-0 px-1 text-gray-400 opacity-0 hover:text-blue-500 focus:opacity-100 group-hover:opacity-100",children:t.jsx(Xw,{size:12})}),t.jsx("button",{type:"button",onClick:()=>U(ne),disabled:O.isPending,title:`Remove ${ne.fullName}`,"aria-label":`Remove ${ne.fullName}`,className:"shrink-0 px-1 text-gray-400 opacity-0 hover:text-red-500 focus:opacity-100 group-hover:opacity-100 disabled:opacity-30",children:t.jsx(Zt,{})})]}),we&&t.jsx("div",{className:"pl-1 pt-0.5 text-[10px] text-amber-600 dark:text-amber-500",children:we.kind==="cooldown"?"recently synced — try again in a moment":"couldn’t start the sync — check the header sync button for details"})]},ne.id)};return t.jsx("div",{className:"fixed inset-0 z-[80] flex items-start justify-center bg-black/40 p-4 pt-16",children:t.jsxs("div",{ref:x,role:"dialog","aria-modal":"true","aria-label":"Manage repos and workspaces",className:`flex max-h-[80vh] w-full ${h.open?"max-w-5xl":"max-w-2xl"} flex-col rounded-lg border border-gray-200 bg-white shadow-xl dark:border-gray-700 dark:bg-gray-900`,children:[t.jsxs("div",{className:"flex items-center justify-between border-b border-gray-200 px-4 py-2.5 dark:border-gray-800",children:[t.jsx("span",{className:"text-sm font-semibold text-gray-800 dark:text-gray-100",children:"Repos & workspaces"}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("button",{type:"button",onClick:j,disabled:h.syncing,title:"Force a full backfill for all repos",className:"flex items-center gap-1.5 rounded border border-gray-300 px-2 py-1 text-[11px] text-gray-600 hover:border-gray-400 hover:bg-gray-50 disabled:opacity-50 dark:border-gray-700 dark:text-gray-300 dark:hover:bg-gray-800",children:[t.jsx(Xw,{size:12}),"Deep re-sync all"]}),t.jsx("button",{type:"button",onClick:e,"aria-label":"Close",className:"rounded p-1 text-gray-400 hover:bg-gray-100 hover:text-gray-700 dark:hover:bg-gray-800 dark:hover:text-gray-200",children:t.jsx(Zt,{size:14})})]})]}),te&&t.jsxs("div",{className:"border-b border-gray-200 bg-sky-50/60 px-4 py-3 dark:border-gray-800 dark:bg-sky-950/20",children:[t.jsx("div",{className:"text-sm font-semibold text-gray-800 dark:text-gray-100",children:"Add a repo to get started"}),t.jsx("p",{className:"mt-0.5 text-xs text-gray-600 dark:text-gray-300",children:"Search GitHub for a repo by name, or pick one of the suggested public repos to try Limn out."})]}),t.jsxs("div",{className:"relative z-20 flex items-center gap-2 border-b border-gray-200 px-3 py-2 dark:border-gray-800",children:[A?t.jsx(Lf,{autoFocus:te,placeholder:`Add a repo to ${A.name}…`,onAdded:ne=>{const ae=A.id;m.mutate({workspaceId:ae,repoId:ne.id},{onSuccess:()=>{G.getState().workspaceId!==ae?i(ae,null):G.getState().showRepo(ne.id)}})}}):t.jsx(Lf,{autoFocus:te}),t.jsx("span",{className:"min-w-0 truncate text-[11px] text-gray-400",children:A?`New repos join “${A.name}”`:""})]}),t.jsxs("div",{className:`grid min-h-0 flex-1 grid-cols-1 gap-0 overflow-hidden rounded-b-lg ${h.open?"md:grid-cols-[1fr_1fr_20rem]":"md:grid-cols-2"}`,children:[t.jsxs("div",{className:"flex min-h-0 flex-col border-b border-gray-200 md:border-b-0 md:border-r dark:border-gray-800",children:[t.jsxs("div",{className:"border-b border-gray-100 px-3 py-2 dark:border-gray-800",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("input",{type:"text",value:I,onChange:ne=>S(ne.target.value),onKeyDown:ne=>{ne.key==="Enter"&&(ne.preventDefault(),E())},placeholder:"New workspace name…",className:"min-w-0 flex-1 rounded border border-gray-300 bg-transparent px-2 py-1 text-xs focus:border-blue-500 focus:outline-none dark:border-gray-700"}),t.jsx("button",{type:"button",onClick:E,disabled:!I.trim()||c.isPending,className:"shrink-0 rounded bg-blue-600 px-2 py-1 text-xs font-medium text-white disabled:opacity-40",children:"Create"})]}),c.error&&t.jsx("div",{className:"mt-1 text-[11px] text-red-500",children:c.error instanceof cn?c.error.message:"Failed to create workspace"})]}),t.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto p-2",children:[r==null&&t.jsx("div",{className:"px-1 py-3 text-xs text-gray-500 dark:text-gray-400",children:"Loading workspaces…"}),M.map(ne=>{const ae=(A==null?void 0:A.id)===ne.id;return t.jsxs("div",{className:`group flex items-center gap-1.5 rounded px-2 py-1 text-xs ${ae?"bg-sky-50 dark:bg-sky-950/30":"hover:bg-gray-100 dark:hover:bg-gray-800"}`,children:[P===ne.id?t.jsx("input",{autoFocus:!0,value:L,onChange:we=>F(we.target.value),onKeyDown:we=>{we.key==="Enter"?(we.preventDefault(),ee(ne.id)):we.key==="Escape"&&(we.stopPropagation(),C(null))},onBlur:()=>ee(ne.id),className:"min-w-0 flex-1 rounded border border-gray-300 bg-transparent px-1.5 py-0.5 text-xs focus:border-blue-500 focus:outline-none dark:border-gray-700"}):t.jsxs("button",{type:"button",onClick:()=>$(ne.id),className:"flex min-w-0 flex-1 items-center gap-1.5 text-left",children:[t.jsx("span",{className:`truncate ${ae?"font-semibold text-sky-700 dark:text-sky-300":"text-gray-700 dark:text-gray-200"}`,children:ne.name}),ne.isDefault&&t.jsx("span",{className:"shrink-0 rounded bg-gray-100 px-1 text-[9px] uppercase tracking-wide text-gray-500 dark:bg-gray-800 dark:text-gray-400",title:"New repos land here, and a deleted workspace's repos come back here.",children:"default"}),t.jsx("span",{className:"shrink-0 tabular-nums text-[10px] text-gray-400",children:ne.repoCount})]}),t.jsx("button",{type:"button",onClick:()=>{C(ne.id),F(ne.name)},title:"Rename","aria-label":`Rename ${ne.name}`,className:"shrink-0 rounded px-1 text-gray-400 opacity-0 hover:text-gray-700 focus:opacity-100 group-hover:opacity-100 dark:hover:text-gray-200",children:t.jsx(fS,{})}),ne.isDefault?t.jsx("button",{type:"button",disabled:!0,title:"The default workspace can’t be deleted — new repos land here, and a deleted workspace’s repos and bot settings come back here. You can rename it.","aria-label":`${ne.name} is the default workspace and can’t be deleted`,className:"shrink-0 cursor-not-allowed rounded px-1 decorative-mark text-gray-300 opacity-0 focus:opacity-100 group-hover:opacity-100 dark:text-gray-600",children:t.jsx(Zt,{})}):t.jsx("button",{type:"button",onClick:()=>Q(ne),title:"Delete workspace","aria-label":`Delete ${ne.name}`,className:"shrink-0 rounded px-1 text-gray-400 opacity-0 hover:text-red-500 focus:opacity-100 group-hover:opacity-100",children:t.jsx(Zt,{})})]},ne.id)})]})]}),t.jsxs("div",{className:"flex min-h-0 flex-col",children:[t.jsxs("div",{className:"border-b border-gray-100 px-3 py-2 dark:border-gray-800",children:[t.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wide text-gray-400",children:"Repos"}),t.jsx("div",{className:"text-[11px] text-gray-500 dark:text-gray-400",children:"Every repo lives in exactly one workspace. Changing a repo’s workspace MOVES it — it leaves the one it’s in now."})]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto p-2",children:z.length===0?t.jsx("div",{className:"px-1 py-3 text-xs text-gray-500 dark:text-gray-400",children:"No repos yet — search to add one above."}):t.jsxs(t.Fragment,{children:[A&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"px-1 pb-1 pt-0.5 text-[10px] font-semibold uppercase tracking-wide text-gray-400",children:["In “",A.name,"” · ",H.length]}),H.length===0?t.jsx("div",{className:"px-1 pb-2 text-xs text-gray-500 dark:text-gray-400",children:"No repos in this workspace yet — move one in below, or add one above."}):t.jsx("ul",{className:"space-y-0.5 pb-2",children:H.map(J)})]}),B.length>0&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"border-t border-gray-100 px-1 pb-1 pt-2 text-[10px] font-semibold uppercase tracking-wide text-gray-400 dark:border-gray-800",children:["In other workspaces · ",B.length]}),t.jsx("ul",{className:"space-y-0.5",children:B.map(J)})]})]})})]}),h.open&&t.jsx("div",{className:"flex min-h-0 flex-col border-t border-gray-200 md:border-l md:border-t-0 dark:border-gray-800",children:t.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto p-3",children:t.jsx(AO,{})})})]})]})})}let Zw=!1;const Jw="shrink-0 rounded-full border border-amber-500/60 px-1 text-center text-[11px] font-medium leading-[16px] tabular-nums text-amber-600 dark:border-amber-400/50 dark:text-amber-400";function LO(){const e=G(i=>i.workspaceId),n=G(i=>i.setWorkspace),r=G(i=>i.setRepoIds),{data:s}=xa(),a=f.useRef(null);f.useEffect(()=>{FO({workspaces:s,workspaceId:e,prevWorkspaceRef:a,setWorkspace:n,setRepoIds:r})},[e,s,n,r])}function FO(e){const{workspaces:n,workspaceId:r,prevWorkspaceRef:s,setWorkspace:a,setRepoIds:i}=e;if(n==null||n.length===0)return;const c=r==null?void 0:n.find(g=>g.id===r);if(c==null){const g=n.find(x=>x.isDefault)??n[0];if(g==null)return;s.current=g.id,Gp(),a(g.id,null);return}const d=s.current!=null&&s.current!==c.id;if(s.current=c.id,d&&!wO(c.id)){G.getState().repoIds!=null&&a(c.id,null);return}const u=G.getState().repoIds;if(u==null)return;if(u.length===0){i(null);return}const m=new Set(c.repoIds),h=u.filter(g=>m.has(g));h.length!==u.length&&i(h.length>0?h:null)}function OO(e){return[...e].sort((n,r)=>n.isDefault!==r.isDefault?n.isDefault?-1:1:n.name.localeCompare(r.name))}function DO(){var S;const e=G(T=>T.workspaceId),n=G(T=>T.switchWorkspaceToPending),{data:r}=xa(),[s,a]=f.useState(!1),[i,c]=f.useState(!1),d=f.useRef(null),{data:u}=xn();f.useEffect(()=>{Zw||u==null||r==null||u.length>0||(Zw=!0,c(!0))},[u,r]),LO(),Yr(d,()=>a(!1),s);const m=f.useMemo(()=>OO(r??[]),[r]),h=e==null?void 0:m.find(T=>T.id===e),{active:g,byWorkspace:x,elsewhereCount:y,elsewhereCapped:b,uncounted:w}=K2(),k=fO(g),j=T=>{n(T),a(!1)},N=(h==null?void 0:h.name)??"Workspace",I=T=>`flex w-full items-center justify-between gap-2 rounded px-2 py-1 text-left text-xs ${T?"bg-sky-50 font-medium text-sky-700 dark:bg-sky-950/40 dark:text-sky-300":"text-gray-700 hover:bg-gray-100 dark:text-gray-200 dark:hover:bg-gray-800"}`;return t.jsxs("div",{ref:d,className:"relative",children:[t.jsxs("button",{type:"button",onClick:()=>a(T=>!T),"aria-haspopup":"true","aria-expanded":s,title:["The active Workspace — the one scope every view is read through",y>0?`${y}${b?" or more":""} item${y===1&&!b?"":"s"} need you in other Workspaces — open this menu to see where`:null].filter(T=>T!=null).join(". "),className:"inline-flex max-w-[12rem] items-center gap-1 whitespace-nowrap rounded-full border border-gray-300 py-0.5 pl-2.5 pr-2 text-xs text-gray-600 hover:border-gray-400 dark:border-gray-700 dark:text-gray-300 dark:hover:border-gray-500",children:[t.jsx(xp,{className:"shrink-0 text-sky-500"}),t.jsx("span",{className:"truncate",children:N}),k!=null&&t.jsxs("span",{title:((S=g==null?void 0:g.cap)==null?void 0:S.title)??(k.count===1?`1 item needs you in ${N} — it is on the Pending board`:`${k.count} items need you in ${N} — they are on the Pending board`),className:`${Jw} min-w-[1.35rem]`,children:[k.count,k.cappedTotal!=null&&t.jsxs(t.Fragment,{children:[t.jsx("span",{"aria-hidden":!0,children:"+"}),t.jsxs("span",{className:"sr-only",children:[" of ",k.cappedTotal]})]})]}),t.jsx(Cr,{dir:"down",className:"shrink-0"})]}),s&&t.jsxs("div",{role:"menu","aria-label":"Workspace",className:"absolute left-0 top-full z-[60] mt-1 max-h-80 w-56 overflow-y-auto rounded-lg border border-gray-200 bg-white p-1 shadow-lg dark:border-gray-700 dark:bg-gray-900",children:[m.length===0?t.jsx("div",{className:"px-2 py-1.5 text-xs text-gray-500 dark:text-gray-400",children:"Loading workspaces…"}):m.map(T=>{var C;const $=T.id===e,P=x.get(T.id)??null;return t.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":$,onClick:()=>j(T.id),className:I($),children:[t.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[t.jsx("span",{"aria-hidden":!0,className:`inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center rounded-full border text-[9px] leading-none ${$?"border-sky-500 bg-sky-500 text-white":"border-gray-300 dark:border-gray-600"}`,children:$&&t.jsx(xx,{size:5})}),t.jsx("span",{className:"truncate",children:T.name}),T.isDefault&&t.jsx("span",{className:"shrink-0 rounded bg-gray-100 px-1 text-[9px] uppercase tracking-wide text-gray-500 dark:bg-gray-800 dark:text-gray-400",children:"Default"})]}),t.jsxs("span",{className:"flex shrink-0 items-center gap-1.5",children:[P!=null&&P.count>0&&t.jsxs("span",{title:((C=P.cap)==null?void 0:C.title)??(P.split!=null?`${P.split.direct} tied to you, ${P.split.maintained} in repos you maintain — in ${T.name}`:P.count===1?`1 item needs you in ${T.name}`:`${P.count} items need you in ${T.name}`),className:`${Jw} min-w-[1.35rem]`,children:[P.count,P.cap!=null&&t.jsxs(t.Fragment,{children:[t.jsx("span",{"aria-hidden":!0,children:"+"}),t.jsxs("span",{className:"sr-only",children:[" of ",P.cap.total]})]})]}),P==null&&w.length>0&&t.jsx("span",{title:"Not counted here — the cross-workspace roll-up covers only the first few Workspaces. Switch to it to see its own count.",className:"text-[10px] decorative-mark text-gray-300 dark:text-gray-600",children:"—"}),t.jsxs("span",{className:"tabular-nums text-[11px] text-gray-400",children:[T.repoCount," repo",T.repoCount===1?"":"s"]})]})]},T.id)}),w.length>0&&t.jsxs("div",{className:"px-2 pb-0.5 pt-1 text-[10px] leading-tight text-gray-400",children:[w.length," Workspace",w.length===1?"":"s"," beyond the cross-workspace roll-up",w.length===1?" is":" are"," not counted here."]}),t.jsx("div",{className:"my-1 border-t border-gray-100 dark:border-gray-800"}),t.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{a(!1),c(!0)},title:"Add or remove repos, create Workspaces, and move repos between them",className:"flex w-full items-center gap-1.5 rounded px-2 py-1 text-left text-xs text-gray-600 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-800",children:[t.jsx(z4,{className:"shrink-0"}),t.jsx("span",{className:"truncate",children:"Manage repos & workspaces"}),m.length>0&&t.jsx("span",{className:"ml-auto shrink-0 tabular-nums text-[10px] text-gray-400",children:m.length})]})]}),i&&t.jsx(MO,{onClose:()=>c(!1)})]})}const BO=8,WO=25;function qO(e){const n=G(i=>i.workspaceId),r=e.trim(),s=r.length>=2&&n!=null,a=Oe({queryKey:["search-dropdown",dt(n),r],queryFn:n==null?Ct:()=>he.search({q:r,workspaceId:n,limit:BO}),enabled:s,placeholderData:i=>i,staleTime:3e4});return{data:s?a.data:void 0,isFetching:s&&a.isFetching}}function UO(e,n){var u,m,h,g;const r=G(x=>x.workspaceId),s=e.trim(),a=s.length>=1&&r!=null,i=[...n].sort().join(","),c=rc({queryKey:["search-results",dt(r),s,i],initialPageParam:0,queryFn:r==null?Ct:({pageParam:x})=>he.search({q:s,workspaceId:r,kinds:n,limit:WO,offset:x}),getNextPageParam:(x,y)=>{var k;const b=y.reduce((j,N)=>j+N.hits.length,0),w=((k=y[0])==null?void 0:k.total)??0;return b<w?b:void 0},enabled:a,staleTime:3e4,placeholderData:x=>x});return{hits:f.useMemo(()=>{var x;return a?(((x=c.data)==null?void 0:x.pages)??[]).flatMap(y=>y.hits):[]},[c.data,a]),people:a?((m=(u=c.data)==null?void 0:u.pages[0])==null?void 0:m.people)??[]:[],total:a?((g=(h=c.data)==null?void 0:h.pages[0])==null?void 0:g.total)??0:0,isLoading:a&&c.isLoading,isFetching:a&&c.isFetching,hasMore:a&&c.hasNextPage,fetchMore:()=>void c.fetchNextPage(),isFetchingMore:c.isFetchingNextPage}}function Z2(e){return{id:e.prId,number:e.prNumber,title:e.prTitle,repoFullName:e.repoFullName,authorLogin:e.authorLogin,authorDisplayName:null,authorAvatarUrl:e.authorAvatarUrl}}function ly(e){Ge.getState().openPrDetailTab(Z2(e)),e.kind==="review_comment"&&e.threadId!=null?G.getState().selectThread(e.prId,e.threadId):G.getState().selectPr(e.prId)}function e1(e){Ge.getState().openPrDetailTab(Z2(e)),G.getState().selectPr(e.prId)}const J2={pr:"PR",review:"Review",review_comment:"Thread",pr_comment:"Comment"},eC={pr:Nd,review:J4,review_comment:bx,pr_comment:Qo};function HO(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function fd(e,n){const r=n.trim().split(/\s+/).filter(Boolean);if(r.length===0||e==="")return e;const s=new RegExp(`(${r.map(HO).join("|")})`,"gi"),a=e.split(s);return a.length===1?e:a.map((i,c)=>c%2===1?t.jsx("mark",{className:"rounded bg-yellow-200 px-0.5 text-gray-900 dark:bg-yellow-400/30 dark:text-yellow-100",children:i},c):i)}function zO(){const[e,n]=f.useState(""),[r,s]=f.useState(!1),a=f.useRef(null),i=G(k=>k.openSearchDetail),c=iy(e.trim(),300),{data:d,isFetching:u}=qO(c),m=r&&e.trim().length>=2;Yr(a,()=>s(!1),m);const h=(d==null?void 0:d.hits)??[],g=(d==null?void 0:d.people)??[],x=(d==null?void 0:d.total)??0,y=e.trim()!==c||u,b=()=>{const k=e.trim();k.length!==0&&(i(k),s(!1))},w=k=>{k.key==="Escape"?(s(!1),k.target.blur()):k.key==="Enter"&&(k.preventDefault(),b())};return t.jsxs("div",{ref:a,className:"relative",children:[t.jsx("div",{className:"pointer-events-none absolute left-2 top-1/2 -translate-y-1/2 text-gray-400",children:t.jsx(eo,{size:13})}),t.jsx("input",{id:"global-search-input",type:"search",value:e,placeholder:"Search PRs, threads, people…",onChange:k=>{n(k.target.value),s(!0)},onFocus:()=>s(!0),onKeyDown:w,"aria-label":"Search PRs, reviews, threads, comments and people across this workspace's repos",className:"w-64 rounded border border-gray-300 bg-transparent py-0.5 pl-7 pr-2 text-xs focus:border-blue-500 focus:outline-none dark:border-gray-700"}),m&&t.jsxs("div",{className:"absolute left-0 top-full z-[60] mt-1 max-h-[70vh] w-96 max-w-[calc(100vw-2rem)] overflow-y-auto rounded-lg border border-gray-200 bg-white shadow-lg dark:border-gray-700 dark:bg-gray-900",children:[h.length===0&&g.length===0?t.jsx("div",{className:"px-3 py-2 text-xs text-gray-500 dark:text-gray-400",children:y?"Searching…":"No matches."}):t.jsxs(t.Fragment,{children:[g.length>0&&t.jsxs("div",{className:"border-b border-gray-100 py-1 dark:border-gray-800",children:[t.jsx("div",{className:"px-3 pb-0.5 pt-1 text-[10px] font-semibold uppercase tracking-wide text-gray-400",children:"People"}),g.map(k=>t.jsxs("button",{type:"button",onClick:()=>{i(k.login),s(!1)},className:"flex w-full items-center gap-2 px-3 py-1 text-left hover:bg-gray-100 dark:hover:bg-gray-800",children:[k.avatarUrl!=null?t.jsx("img",{src:k.avatarUrl,alt:"",className:"h-4 w-4 shrink-0 rounded-full"}):t.jsx("span",{className:"h-4 w-4 shrink-0 rounded-full bg-gray-300 dark:bg-gray-700"}),t.jsxs("span",{className:"truncate text-xs",children:[k.login,k.displayName?t.jsxs("span",{className:"text-gray-400",children:[" · ",k.displayName]}):null]}),t.jsx("span",{className:"ml-auto shrink-0 text-[10px] text-gray-400",children:k.matchCount})]},k.id))]}),h.map(k=>{const j=eC[k.kind];return t.jsxs("button",{type:"button",onClick:()=>{ly(k),s(!1)},className:"flex w-full flex-col gap-0.5 px-3 py-1.5 text-left hover:bg-gray-100 dark:hover:bg-gray-800",children:[t.jsxs("span",{className:"flex items-center gap-1 text-[10px] text-gray-400",children:[t.jsx(j,{size:11}),t.jsx("span",{className:"font-medium text-gray-500 dark:text-gray-400",children:J2[k.kind]}),t.jsx("span",{"aria-hidden":!0,children:"·"}),t.jsxs("span",{className:"truncate",children:[k.repoFullName," #",k.prNumber]})]}),t.jsx("span",{className:"truncate text-xs font-medium",children:fd(k.prTitle,c)}),k.snippet&&k.kind!=="pr"?t.jsx("span",{className:"line-clamp-1 text-[11px] text-gray-500 dark:text-gray-400",children:fd(k.snippet,c)}):null]},`${k.kind}:${k.refId}`)})]}),t.jsxs("button",{type:"button",onClick:b,className:"sticky bottom-0 flex w-full items-center justify-center gap-1 border-t border-gray-200 bg-gray-50 px-3 py-1.5 text-xs font-medium text-sky-600 hover:bg-gray-100 dark:border-gray-700 dark:bg-gray-900 dark:text-sky-400 dark:hover:bg-gray-800",children:["See all results",x>0?` (${x})`:""," for “",e.trim(),"”"]})]})]})}function KO({derivedStates:e,onToggle:n,onClear:r}){const[s,a]=f.useState(!1),i=f.useRef(null),c=e.length>0,d=e.length;return Yr(i,()=>a(!1),s),f.useEffect(()=>{if(!s)return;const u=m=>{m.key==="Escape"&&(m.stopPropagation(),a(!1))};return document.addEventListener("keydown",u),()=>document.removeEventListener("keydown",u)},[s]),t.jsxs("div",{ref:i,className:"relative",children:[t.jsxs("span",{className:"inline-flex items-center whitespace-nowrap rounded-full border border-gray-300 text-xs text-gray-600 hover:border-gray-400 dark:border-gray-700 dark:text-gray-300 dark:hover:border-gray-500",children:[t.jsxs("button",{type:"button",onClick:()=>a(u=>!u),"aria-haspopup":"true","aria-expanded":s,className:`inline-flex items-center gap-1 py-0.5 pl-2.5 ${c?"pr-1":"pr-2.5"}`,children:["Threads",c?` (${d})`:"",t.jsx(Cr,{dir:"down"})]}),c&&t.jsx("button",{type:"button",onClick:r,title:"Clear the thread-state filter","aria-label":"Clear the thread-state filter",className:"flex items-center self-stretch py-0.5 pl-0.5 pr-2 opacity-60 hover:opacity-100",children:t.jsx(Zt,{size:11})})]}),s&&t.jsxs("div",{role:"dialog","aria-label":"Thread states",className:"absolute left-0 top-full z-[60] mt-1 w-64 rounded-lg border border-gray-200 bg-white p-2 shadow-lg dark:border-gray-700 dark:bg-gray-900",children:[t.jsx("p",{className:"px-1 pb-1.5 text-[11px] leading-snug text-gray-400",children:"Show only PRs with a review thread that is:"}),t.jsx("div",{className:"max-h-72 overflow-y-auto",children:wd.map(u=>{const m=Xt[u];return t.jsxs("label",{title:m.description,className:"flex cursor-pointer items-center gap-2 rounded px-1 py-1 text-xs hover:bg-gray-100 dark:hover:bg-gray-800",children:[t.jsx("input",{type:"checkbox",checked:e.includes(u),onChange:()=>n(u)}),t.jsx("span",{"aria-hidden":!0,className:"h-2.5 w-2.5 shrink-0 rounded-full",style:{backgroundColor:m.color}}),t.jsx("span",{className:"text-gray-800 dark:text-gray-100",children:m.label})]},u)})}),c&&t.jsxs("div",{className:"mt-2 flex items-center justify-between border-t border-gray-200 pt-2 dark:border-gray-700",children:[t.jsxs("span",{className:"text-[11px] text-gray-400",children:[d," selected"]}),t.jsx("button",{type:"button",onClick:r,className:"text-[11px] text-gray-400 hover:text-gray-600",children:"Clear"})]})]})]})}function tC(e,n){return!n||e.githubLogin.toLowerCase().includes(n)||(e.displayName??"").toLowerCase().includes(n)}function Kh(){return t.jsx("span",{className:"flex-none",title:"Maintainer — has merged a PR in the selected repo(s)",children:t.jsxs("svg",{viewBox:"0 0 16 16",width:"11",height:"11","aria-hidden":"true",children:[t.jsx("path",{fill:"#8957e5",d:"M8 .8 2.2 2.9v4.2c0 3.3 2.5 6.4 5.8 7.3 3.3-.9 5.8-4 5.8-7.3V2.9L8 .8Z"}),t.jsx("path",{d:"M5.2 8 7.1 9.9 10.9 6",fill:"none",stroke:"#fff",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round"})]})})}function nC({sections:e,filter:n,staged:r,onToggle:s,onToggleMany:a,maintainerIds:i,shownOthers:c,setShownOthers:d}){const u=n.trim().toLowerCase(),m=e.map(x=>({...x,members:x.members.filter(y=>tC(y,u))})).filter(x=>x.members.length>0),h=e.reduce((x,y)=>x+y.members.length,0),g=(x,y)=>t.jsxs("label",{className:"flex cursor-pointer items-center gap-2 rounded px-1 py-1 text-xs hover:bg-gray-100 dark:hover:bg-gray-800",children:[t.jsx("input",{type:"checkbox",checked:r.has(y.id),onChange:()=>s(y.id)}),t.jsx(gn,{user:y,size:16}),t.jsx("span",{className:"min-w-0 truncate",title:y.githubLogin,children:Dt(y,y.id)}),i.has(y.id)&&t.jsx(Kh,{})]},`${x.key}:${y.id}`);return t.jsx(t.Fragment,{children:h===0?t.jsx("div",{className:"px-1 py-2 text-xs text-gray-500 dark:text-gray-400",children:"No members in range."}):m.length===0?t.jsx("div",{className:"px-1 py-2 text-xs text-gray-500 dark:text-gray-400",children:"No members match."}):m.map(x=>{const y=x.members.map(T=>T.id),b=y.every(T=>r.has(T)),w=u.length>0,k=w?[]:x.members.filter(T=>i.has(T.id)),j=w?x.members:x.members.filter(T=>!i.has(T.id)),N=c[x.key]??0,I=w?j:j.slice(0,N),S=j.length-I.length;return t.jsxs("div",{className:"mb-1 last:mb-0",children:[t.jsxs("div",{className:"sticky top-0 z-10 flex items-center justify-between border-b border-gray-100 bg-white px-1 pb-0.5 pt-1 dark:border-gray-800 dark:bg-gray-900",children:[t.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wide text-gray-400",children:x.label}),t.jsx("button",{type:"button",onClick:()=>a(y,!b),title:"Select / clear every member in this repo (including any collapsed below)",className:"text-[10px] text-gray-400 hover:text-gray-600 dark:hover:text-gray-200",children:b?"none":"all"})]}),k.map(T=>g(x,T)),I.map(T=>g(x,T)),!w&&j.length>0&&t.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-0.5 px-1 py-0.5 text-[10px]",children:[S>0&&t.jsx("button",{type:"button",onClick:()=>d(T=>({...T,[x.key]:(T[x.key]??0)+10})),className:"font-medium text-blue-600 hover:underline dark:text-blue-400",children:S<=10?`Show ${S} more`:`Show 10 more · ${S} hidden`}),N>0&&t.jsx("button",{type:"button",onClick:()=>d(T=>({...T,[x.key]:0})),className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300",children:"Show fewer"})]})]},x.key)})})}function GO({sections:e,botSections:n,userIds:r,maintainerIds:s,onApply:a,excludeBots:i,onExcludeBotsChange:c,allowedBotIds:d,onToggleAllowedBot:u}){const[m,h]=f.useState(!1),[g,x]=f.useState(new Set),[y,b]=f.useState(""),[w,k]=f.useState({}),j=f.useRef(null),N=(r==null?void 0:r.length)??0,I=()=>{x(new Set(r??[])),b(""),k({}),h(!0)},S=y.trim().toLowerCase(),T=new Set(d),$=n.map(M=>({...M,members:M.members.filter(D=>tC(D,S))})).filter(M=>M.members.length>0);Yr(j,()=>h(!1),m),f.useEffect(()=>{if(!m)return;const M=D=>{D.key==="Escape"&&(D.stopPropagation(),h(!1))};return document.addEventListener("keydown",M),()=>document.removeEventListener("keydown",M)},[m]);const P=M=>x(D=>{const A=new Set(D);return A.has(M)?A.delete(M):A.add(M),A}),C=(M,D)=>x(A=>{const W=new Set(A);for(const z of M)D?W.add(z):W.delete(z);return W}),L=()=>{const M=[...g];a(M.length?M:null),h(!1)},F=()=>x(new Set);return t.jsxs("div",{ref:j,className:"relative",children:[t.jsxs("span",{className:"inline-flex items-center whitespace-nowrap rounded-full border border-gray-300 text-xs text-gray-600 hover:border-gray-400 dark:border-gray-700 dark:text-gray-300 dark:hover:border-gray-500",children:[t.jsxs("button",{type:"button",onClick:()=>m?h(!1):I(),"aria-haspopup":"true","aria-expanded":m,className:`inline-flex items-center gap-1 py-0.5 pl-2.5 ${N>0?"pr-1":"pr-2.5"}`,children:["Members",N>0?` (${N})`:"",t.jsx(Cr,{dir:"down"})]}),N>0&&t.jsx("button",{type:"button",onClick:()=>{a(null),h(!1)},title:"Clear members filter","aria-label":"Clear members filter",className:"flex items-center self-stretch py-0.5 pl-0.5 pr-2 opacity-60 hover:opacity-100",children:t.jsx(Zt,{size:11})})]}),m&&t.jsxs("div",{role:"dialog","aria-label":"Select members",className:"absolute left-0 top-full z-[60] mt-1 w-80 rounded-lg border border-gray-200 bg-white p-2 shadow-lg dark:border-gray-700 dark:bg-gray-900",children:[t.jsx("input",{autoFocus:!0,type:"search",value:y,onChange:M=>b(M.target.value),placeholder:"Filter members…","aria-label":"Filter members",className:"mb-2 w-full rounded border border-gray-300 bg-transparent px-2 py-0.5 text-xs focus:border-blue-500 focus:outline-none dark:border-gray-700"}),s.size>0&&(()=>{const M=[...s],D=M.every(A=>g.has(A));return t.jsxs("button",{type:"button",onClick:()=>C(M,!D),title:"Select every maintainer in the current filter",className:`mb-2 flex w-full items-center gap-2 rounded px-2 py-1 text-xs transition ${D?"bg-[#8957e5]/15 text-[#8957e5]":"text-gray-600 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-800"}`,children:[t.jsx(Kh,{}),t.jsx("span",{className:"font-medium",children:"Maintainers"}),t.jsxs("span",{className:"text-gray-400",children:["(",M.length,")"]}),t.jsx("span",{className:"ml-auto text-[10px] text-gray-400",children:D?"clear":"select all"})]})})(),t.jsx("div",{className:"max-h-72 overflow-y-auto",children:t.jsx(nC,{sections:e,filter:y,staged:g,onToggle:P,onToggleMany:C,maintainerIds:s,shownOthers:w,setShownOthers:k})}),t.jsxs("label",{className:"mt-2 flex cursor-pointer items-center gap-2 border-t border-gray-200 pt-2 text-xs text-gray-600 dark:border-gray-700 dark:text-gray-300",children:[t.jsx("input",{type:"checkbox",checked:i,onChange:M=>c(M.target.checked)}),"Exclude bots"]}),$.length>0&&t.jsxs("div",{className:"mt-2 border-t border-gray-200 pt-2 dark:border-gray-700",children:[t.jsxs("div",{className:"mb-1 flex items-center gap-1.5 px-1",children:[t.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wide text-gray-400",children:"Bots"}),t.jsx("span",{className:"text-[10px] text-gray-400",children:i?"· ticked stay visible":"· all shown (bots not excluded)"})]}),t.jsx("div",{className:"max-h-40 overflow-y-auto",children:$.map(M=>t.jsxs("div",{className:"mb-1 last:mb-0",children:[t.jsx("div",{className:"sticky top-0 z-10 border-b border-gray-100 bg-white px-1 pb-0.5 pt-1 text-[10px] font-semibold uppercase tracking-wide text-gray-400 dark:border-gray-800 dark:bg-gray-900",children:M.label}),M.members.map(D=>t.jsxs("label",{className:`flex items-center gap-2 rounded px-1 py-1 text-xs hover:bg-gray-100 dark:hover:bg-gray-800 ${i?"cursor-pointer":"cursor-pointer opacity-60"}`,title:i?"Keep this bot visible even though bots are excluded":'Bots are currently shown; enable "Exclude bots" for this to take effect',children:[t.jsx("input",{type:"checkbox",checked:T.has(D.id),onChange:()=>u(D.id)}),t.jsx(gn,{user:D,size:16}),t.jsx("span",{className:"min-w-0 truncate",title:D.githubLogin,children:Dt(D,D.id)})]},`${M.key}:${D.id}`))]},M.key))})]}),t.jsxs("div",{className:"mt-2 flex items-center justify-between",children:[t.jsx("button",{type:"button",onClick:F,className:"text-[11px] text-gray-400 hover:text-gray-600",children:"Clear all"}),t.jsx("button",{type:"button",onClick:L,className:"rounded bg-blue-600 px-2.5 py-0.5 text-xs text-white",children:"Apply"})]})]})]})}const VO=["7d","14d","30d","90d"];function QO({active:e,onClick:n,children:r,color:s,title:a,onRemove:i,removeTitle:c,removeDisabled:d}){const u=`whitespace-nowrap rounded-full border text-xs transition ${e?"border-transparent bg-blue-600 text-white":"border-gray-300 text-gray-600 hover:border-gray-400 dark:border-gray-700 dark:text-gray-300 dark:hover:border-gray-500"}`,m=e&&s?{backgroundColor:s}:void 0;return i?t.jsxs("span",{className:`inline-flex items-center ${u}`,style:m,children:[t.jsx("button",{type:"button",onClick:n,title:a,className:"py-0.5 pl-2.5 pr-1",children:r}),t.jsx("button",{type:"button",onClick:i,disabled:d,title:c,"aria-label":c,className:"flex items-center self-stretch py-0.5 pl-0.5 pr-2 opacity-50 hover:opacity-100 disabled:opacity-30",children:t.jsx(Zt,{size:11})})]}):t.jsx("button",{type:"button",onClick:n,title:a,className:`${u} px-2.5 py-0.5`,style:m,children:r})}function Ha({label:e,children:n}){return t.jsxs("div",{className:"flex items-center gap-1.5",children:[e!=null&&t.jsx("span",{className:"text-[11px] uppercase tracking-wide text-gray-400",children:e}),n]})}function YO(){var I;const{data:e}=xn(),{data:n}=xa(),{data:r}=An(),s=Ge(S=>S.activeTab),a=Ge(S=>S.tabs),i=s==="timeline",c=iS(s,a)!=null,d=i||c,{data:u}=mS({enabled:!c}),{data:m}=AS(),{data:h}=fp(),g=G(),x=((I=g.allowedBotIds)==null?void 0:I.length)??0,y=f.useMemo(()=>{if(n==null||g.workspaceId==null)return[];const S=new Set(MS(g.workspaceId,n));return(e??[]).filter(T=>S.has(T.id))},[e,n,g.workspaceId]),b=S=>{const T=y.map(P=>P.id),$=new Set(G.getState().repoIds??T);$.has(S)?$.delete(S):$.add(S),g.setRepoIds($.size===0||$.size===T.length?null:T.filter(P=>$.has(P)))},w=S=>{g.setRepoIds(y.length<=1?null:[S])},{sections:k,botSections:j,maintainerIds:N}=f.useMemo(()=>{const S=g.repoIds!=null&&g.repoIds.length>0,T=new Set(y.map(C=>C.id)),$=g.repoIds,P=$!=null&&$.length>0?new Set($.filter(C=>T.has(C))):T;return oS({users:r,repos:e,searchTimeline:u,searchOpenPrs:m,mergers:h,inScopeRepoIds:P,repoScoped:S,selectedIds:g.userIds??[],allowedBotIds:g.allowedBotIds??[],isBot:C=>C.isBot,includeRosterRemainder:!0})},[r,u,m,h,e,y,g.repoIds,g.userIds,g.allowedBotIds]);return t.jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-2 border-b border-gray-200 bg-gray-50 px-4 py-2 dark:border-gray-800 dark:bg-gray-900",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-2",children:[t.jsx(Ha,{children:t.jsx(DO,{})}),t.jsx(Ha,{children:t.jsx(zO,{})}),i&&t.jsx(Ha,{children:t.jsx(Y_,{repos:y,repoIds:g.repoIds,onToggle:b,onOnly:w,onShowAll:()=>g.setRepoIds(null)})}),i&&t.jsx(Ha,{children:t.jsx(GO,{sections:k,botSections:j,userIds:g.userIds,maintainerIds:N,onApply:S=>g.setUserIds(S),excludeBots:g.excludeBots,onExcludeBotsChange:g.setExcludeBots,allowedBotIds:g.allowedBotIds,onToggleAllowedBot:g.toggleAllowedBot})}),i&&t.jsx(Ha,{children:t.jsx(eP,{statuses:g.prStatuses,onToggle:g.togglePrStatus,onSet:g.setPrStatuses,excludeStale:g.excludeStale,onExcludeStaleChange:g.setExcludeStale})}),d&&t.jsx(Ha,{children:t.jsx(Q_,{categories:g.categories,onToggleCategory:S=>g.toggleCategory(S),onSetCategories:S=>g.setCategories(S),reviewStates:g.reviewStates,onToggleReviewState:S=>g.toggleReviewState(S),onSetReviewStates:S=>g.setReviewStates(S)})}),c&&t.jsx(Ha,{children:t.jsxs("button",{type:"button","aria-pressed":g.excludeBots,onClick:()=>g.setExcludeBots(!g.excludeBots),title:g.excludeBots?x>0?`Bot activity is hidden, except ${x} ${x===1?"bot":"bots"} you chose to keep`:"Bot activity is hidden":"Bot activity is shown",className:`inline-flex items-center gap-1 whitespace-nowrap rounded-full border px-2.5 py-0.5 text-xs transition ${g.excludeBots?"border-transparent bg-blue-600 text-white":"border-gray-300 text-gray-600 hover:border-gray-400 dark:border-gray-700 dark:text-gray-300 dark:hover:border-gray-500"}`,children:[t.jsx(Lt,{size:12}),g.excludeBots&&x>0?`Hide bots (except ${x})`:"Hide bots"]})}),i&&t.jsx(Ha,{children:t.jsx(KO,{derivedStates:g.derivedStates,onToggle:S=>g.toggleDerivedState(S),onClear:()=>g.setDerivedStates([])})}),i&&t.jsxs(Ha,{label:"Range",children:[VO.map(S=>t.jsx(QO,{active:g.preset===S,onClick:()=>g.setPreset(S),children:S},S)),t.jsx("button",{type:"button",onClick:()=>g.centerTimelineNow(),title:"Recenter the timeline on the current time (keeps the zoom)",className:"whitespace-nowrap rounded-full border border-sky-300 px-2.5 py-0.5 text-xs text-sky-600 transition hover:border-sky-400 hover:bg-sky-50 dark:border-sky-700 dark:text-sky-400 dark:hover:bg-sky-900/30",children:"Now"})]})]}),i&&t.jsx("div",{className:"ml-auto flex items-center gap-2",children:t.jsx("button",{type:"button",onClick:()=>g.resetAllFilters(),title:"Reset all filters to their defaults",className:"whitespace-nowrap rounded border border-gray-300 px-2 py-0.5 text-xs text-gray-600 transition hover:border-gray-400 hover:text-gray-800 dark:border-gray-700 dark:text-gray-300 dark:hover:border-gray-500 dark:hover:text-gray-100",children:"Clear filters"})})]})}function rC(e,n="sprint"){return["period-reports",dt(e),n]}function sC(e,n){return["period-report",dt(e),n??"none"]}function Fd(e,n,r="sprint"){return Oe({queryKey:rC(n,r),queryFn:n==null?Ct:()=>he.periodReports(n,r),enabled:e,staleTime:6e4,gcTime:fn})}function XO(e){return["period-month-to-date",dt(e)]}function ZO(e,n){return Oe({queryKey:XO(n),queryFn:n==null?Ct:()=>he.periodMonthToDate(n),enabled:e,staleTime:3e4,gcTime:fn})}function JO(e,n,r){return Oe({queryKey:sC(n,r),queryFn:n==null||r==null?Ct:()=>he.periodReport(n,r),enabled:e&&r!=null,staleTime:6e4,gcTime:fn})}function aC(e,n){return["period-report-generate",dt(e),n??"none"]}function eD(e,n){const r=He();return tt({mutationKey:aC(e,n),mutationFn:s=>e==null||n==null?Promise.reject(new Error("No period selected")):he.generatePeriodReport(e,n,s??{}),onSuccess:s=>{r.setQueryData(sC(e,n),a=>({enabled:s.enabled,workspaceId:s.workspaceId,report:s.report,...(a==null?void 0:a.byWorkspace)!=null?{byWorkspace:a.byWorkspace}:{},...(a==null?void 0:a.modelInfo)!=null?{modelInfo:a.modelInfo}:{}})),r.invalidateQueries({queryKey:["period-reports",dt(e)]}),r.invalidateQueries({queryKey:["ai-usage"]})}})}const Ff={"claude-haiku-4-5":{label:"Haiku",hint:"fast · cheapest"},"claude-sonnet-5":{label:"Sonnet",hint:"more considered prose"}};function oC(e){var n;return((n=Ff[e])==null?void 0:n.label)??e}function tD(e){return((e==null?void 0:e.estimates)??[]).map(n=>{var r,s;return{id:n.model,label:((r=Ff[n.model])==null?void 0:r.label)??n.model,hint:((s=Ff[n.model])==null?void 0:s.hint)??"",estimate:n}})}function nD(e,n){return e==null||n?null:(e.prs??[]).reduce((r,s)=>r+(s.isDraft?0:1),0)}function rD(e){return e==null?"Open PRs":`Open PRs · ${e}`}const wl=e=>String(Math.round(e)),Ja=e=>`${Math.round(e)}%`,t1=e=>`${Math.round(e)}`,n1=e=>`${Math.round(e)} lines`,sD=e=>Number.isInteger(e)?String(e):e.toFixed(2),Ou=e=>`${Math.round(e)} pts`;function Gh(e){return e.standaloneLabel??e.label}const aD=e=>Number.isInteger(e)?String(e):e.toFixed(2);function Vh(e){return dy[e]??{label:e.replace(/_/g," "),format:aD}}function Vp(e){return e.changeFormat??e.format}function cy(e){return e.standaloneFormat??Vp(e)}const dy={merged_prs:{label:"Merged PRs",format:wl,note:"everything that landed"},human_merged_prs:{label:"…by people",standaloneLabel:"Merged PRs by people",format:wl,note:"excludes bumps, agents, release bots"},opened_prs:{label:"Opened PRs",format:wl},automation_merge_share_pct:{label:"Automation share of merges",format:Ja,changeFormat:Ou,note:"no arrow — more automation is not self-evidently better or worse"},median_lead_time_hours:{label:"Lead time",format:wn,note:"median open → merge"},median_time_to_first_human_review_hours:{label:"Time to first review by a person",format:wn,note:"median, counted on the review — not the open. Bot approvals are excluded"},merge_ci_success_pct:{label:"Merge CI success",format:Ja,changeFormat:Ou,note:"% green at merge"},median_pr_size_lines:{label:"PR size",format:t1,standaloneFormat:n1,note:"median lines added + deleted"},median_human_pr_size_lines:{label:"…by people",standaloneLabel:"PR size, people only",format:t1,standaloneFormat:n1,note:"the blended figure above understated this by 2.1× on the workspace this was built for"},review_threads_opened:{label:"Review threads opened",format:wl},threads_replied_within_36h_pct:{label:"Threads replied within 36h",format:Ja,changeFormat:Ou,note:"same 36h grace the bot verdict uses"},bot_review_comments:{label:"Bot review comments",format:wl,note:"inline only — see Effort vs automation"},human_review_comments:{label:"Human review comments",format:wl,note:"inline only — see Effort vs automation"},bot_comments_per_merged_pr:{label:"Bot comments per merged PR",format:sD},reviewer_concentration_pct:{label:"Reviewer concentration",format:Ja,changeFormat:Ou,note:"share taken by the busiest human reviewer"}},Qh={no_prior_period:"No earlier period is stored, so there is nothing to compare against.",cadence_changed:"The sprint cadence changed between these two periods. Periods of different lengths are not comparable, so the difference is not shown rather than being quietly subtracted.",partial_coverage:"No repo in this workspace was being tracked across both periods, so there is no like-for-like subset to compare.",insufficient_history:"Not enough complete periods yet — a trend needs several periods where every repo in the subset was already being tracked.",too_volatile:"Too volatile to forecast: the uncertainty band came out wider than the estimate itself.",uneven_periods:"Calendar months are 28–31 days long, so a trend fitted across them would read their own uneven lengths as a change in the work. No forecast is offered at this grain — the sprint grain, whose periods are all the same length, still forecasts."},o0={day:"numeric",month:"short",timeZone:"UTC"},oD={month:"long",year:"numeric",timeZone:"UTC"};function ro(e,n,r="sprint"){const s=new Date(e),a=new Date(n);if(r==="month")return s.toLocaleDateString(void 0,oD);const i=s.getUTCFullYear()===a.getUTCFullYear(),c=new Date().getUTCFullYear(),d={...o0,year:"numeric"};if(!i)return`${s.toLocaleDateString(void 0,d)} – ${a.toLocaleDateString(void 0,d)}`;const u=s.getUTCFullYear()===c?a.toLocaleDateString(void 0,o0):a.toLocaleDateString(void 0,d);return`${s.toLocaleDateString(void 0,o0)} – ${u}`}function cs(e,n){return`${e>0?"+":e<0?"−":""}${n(Math.abs(e))}`}function iC(e,n,r){return{value:n?n.value:(e==null?void 0:e.value)??null,prior:(n==null?void 0:n.prior)??null,headline:r&&n?(e==null?void 0:e.value)??null:null,lowSample:(n?n.lowSample:e==null?void 0:e.lowSample)??!1}}function lC(e){return e.comparison.deltas.length===0&&e.comparison.refusal==null&&e.comparison.priorPeriodKey==null&&e.forecasts.length===0}function iD(e,n,r){const s=Vp(n);if(e.prior==null)return r?"no prior figure":"no prior period";if(e.value==null||e.absoluteChange==null)return"—";if(e.absoluteChange===0)return"no change";if(!e.significant)return`${cs(e.absoluteChange,s)} · not significant`;const a=e.absoluteChange>0?"▲":"▼",i=e.percentChange!=null?` (${cs(e.percentChange,Ja)})`:" (from 0)";return`${a} ${cs(e.absoluteChange,s)}${i}`}function lD(e,n){return n?"not compared":e?"no prior figure":"no prior period"}function cD(e,n,r){return r?"not forecast":e==null?"—":e.available?`≈ ${n.format(e.point)} (${n.format(e.low)}–${n.format(e.high)})`:`not forecast · ${e.reason.replace(/_/g," ")}`}function dD(e){const n=e.coverage;return n.complete?`All ${n.totalRepos} repos in this workspace were already being tracked when this period started.`:`**Partial coverage.** ${n.trackedRepos} of ${n.totalRepos} repos in this workspace were being tracked when this period started. The headline figures below cover the whole workspace as it is today, so they under-count this period relative to a later one — which is why the comparison is computed over the repos present in both.`}function uD(e,n){const r=[],s=lC(e),a=e.comparison.priorPeriodKey!=null;r.push(`# ${ro(e.periodStart,e.periodEnd,e.grain)}`),r.push("");const i=[e.grain==="month"?`Calendar month · ${e.cadenceDays} days`:`Sprint · ${e.cadenceDays} days`];e.inProgress&&i.push(`IN PROGRESS — ${e.elapsedDays??0} day${e.elapsedDays===1?"":"s"} elapsed, not written up`),e.model&&i.push(`written up with ${e.model}`),i.push(`generated ${e.generatedAt}`),e.stale&&i.push("STALE — the underlying data changed after this report was written"),r.push(i.join(" · ")),r.push(""),r.push(dD(e)),r.push(""),e.metricsSchemaVersion!==n&&(r.push(`Written under metric schema v${e.metricsSchemaVersion} (current is v${n}) — any metric added since is blank here, not zero.`),r.push("")),s&&(r.push("**Figures only.** This period was filled in automatically to give the forecast some history — no comparison, forecast or write-up was computed for it."),r.push(""));const c=new Map(e.metrics.map(y=>[y.key,y])),d=new Map(e.comparison.deltas.map(y=>[y.key,y])),u=new Map(e.forecasts.map(y=>[y.key,y])),m=e.comparison.subsetRepoIds.length,h=m>0&&m!==e.coverage.totalRepos;r.push("| Metric | This period | Prior | Change | Next period |"),r.push("| --- | ---: | ---: | --- | --- |");let g=!1;for(const y of QN){const b=dy[y],w=c.get(y),k=d.get(y),j=u.get(y),{value:N,prior:I,headline:S,lowSample:T}=iC(w,k,h);T&&N!=null&&(g=!0);let $=N==null?"—":b.format(N);T&&N!=null&&($+=" ▵"),S!=null&&($+=` (all repos: ${b.format(S)})`);const P=I==null?"—":b.format(I),C=k?iD(k,b,a):lD(a,s),L=b.note?`${b.label} — ${b.note}`:b.label;r.push(`| ${L} | ${$} | ${P} | ${C} | ${cD(j,b,s)} |`)}if(r.push(""),g&&(r.push("▵ thin sample — the figure is real but rests on few items and moves easily."),r.push("")),h&&(r.push(`Rows with a Change show the coverage-stable subset (${m} of ${e.coverage.totalRepos} repos); "all repos" beside a figure is the full-workspace headline. The two populations are never mixed in one subtraction.`),r.push("")),s||(e.comparison.refusal!=null?r.push(`**No comparison.** ${Qh[e.comparison.refusal]}`):e.comparison.subsetDisclosure&&r.push(`Comparison ${e.comparison.subsetDisclosure}${e.comparison.priorPeriodKey?` · vs ${e.comparison.priorPeriodKey}`:""}`),r.push("")),!s){e.forecastDisclosure&&(r.push(`Forecast ${e.forecastDisclosure}`),r.push(""));const y=e.forecasts.filter(b=>!b.available);if(y.length>0){r.push("Not forecast:");for(const b of y)r.push(`- ${Gh(Vh(b.key))} — ${b.reason.replace(/_/g," ")}: ${Qh[b.reason]}`);r.push("")}}const x=(e.movements??[]).slice(0,5);if(x.length>0){const y=x.map(b=>{const w=Vh(b.key),k=b.percentChange!=null?` (${cs(b.percentChange,Ja)})`:"";return`${Gh(w)} ${b.absoluteChange>0?"▲":"▼"} ${cs(b.absoluteChange,cy(w))}${k}`});r.push(`**Biggest movers:** ${y.join(" · ")}`),r.push("")}return e.narrative?(r.push("## Write-up"),r.push(""),r.push(e.narrative.trim()),r.push("")):(r.push("Figures only — this period has not been written up. The numbers above are already final."),r.push("")),r.join(`
57
+ `)}const hD=t.jsxs("svg",{viewBox:"0 0 24 24",width:"14",height:"14",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("line",{x1:"4",y1:"20",x2:"4",y2:"12"}),t.jsx("line",{x1:"10",y1:"20",x2:"10",y2:"6"}),t.jsx("line",{x1:"16",y1:"20",x2:"16",y2:"14"}),t.jsx("line",{x1:"20",y1:"20",x2:"20",y2:"9"})]}),pD={violet:"text-violet-600 dark:text-violet-400",sky:"text-sky-600 dark:text-sky-400",amber:"text-amber-600 dark:text-amber-400",ai:"text-ai-signal"};function Hs(e,n){return`min-w-0 flex-1 truncate text-xs font-medium ${e?pD[n]:"text-gray-600 dark:text-gray-300"}`}function mD({tabKey:e,active:n,isDragged:r,width:s,buttonClass:a,title:i,closeAria:c,body:d,onActivate:u,drag:m,onOpenMenu:h}){const g=Ge(x=>x.closeTab);return t.jsxs("div",{role:"presentation","data-tabkey":e,onContextMenu:x=>h(x,e),...m,className:`group flex ${s??"w-52"} shrink-0 touch-none select-none items-center gap-1 rounded-t-md border border-b-0 pl-2 pr-1 ${r?"cursor-grabbing opacity-50 ":""}${n?"border-gray-300 bg-white dark:border-gray-700 dark:bg-gray-950":"border-transparent bg-transparent hover:bg-gray-200/60 dark:hover:bg-gray-800/60"}`,children:[t.jsx("button",{type:"button",role:"tab","aria-selected":n,onClick:()=>u(e),className:a??"flex min-w-0 flex-1 items-center gap-1.5 py-1.5 text-left",title:i,children:d}),t.jsx("button",{type:"button","data-tab-close":!0,onClick:()=>g(e),className:"flex shrink-0 items-center self-center rounded px-1 py-0.5 text-xs leading-none text-gray-400 hover:bg-gray-200 hover:text-gray-700 dark:hover:bg-gray-700 dark:hover:text-gray-200",title:"Close this tab","aria-label":c,children:t.jsx(Zt,{})})]})}function gD({tab:e,isDragged:n,drag:r,onActivate:s,onOpenMenu:a}){var I,S,T,$,P,C;const i=Ge(L=>L.activeTab===e.key),c=G(L=>L.botOnlyFocusRepoId),d=G(L=>L.botThreadsFocusRepoId),u=G(L=>L.themeThreadsSeed),m=G(L=>L.searchSeed),h=G(L=>L.botFlaggingSeed),g=G(L=>L.botVolumeSeed),x=G(L=>L.peopleReportSeed),y=G(L=>L.workspaceId),{periodReports:b}=vt(),w=Fd(b&&e.kind==="people-report"&&x!=null,y),{data:k}=xn(),j=L=>{var F;return L!=null?((F=(k??[]).find(M=>M.id===L))==null?void 0:F.fullName)??`repo ${L}`:null};let N;if(e.kind==="metrics-detail")N={title:"Flow metrics — drill-down",closeAria:"Close flow-metrics tab",body:t.jsxs(t.Fragment,{children:[t.jsx("span",{"aria-hidden":"true",className:"shrink-0 text-violet-500",children:hD}),t.jsx("span",{className:Hs(i,"violet"),children:"Flow metrics"})]})};else if(e.kind==="bot-prs")N={title:"Bot Drill-Down — what a review bot said, and the PRs it touched",closeAria:"Close bot drill-down tab",body:t.jsxs(t.Fragment,{children:[t.jsx("span",{"aria-hidden":"true",className:"shrink-0",children:t.jsx(Lt,{})}),t.jsx("span",{className:Hs(i,"ai"),children:"Bot Drill-Down"})]})};else if(e.kind==="bot-only-prs"){const L=j(c);N={title:`Bot-only PRs — only a bot reviewed these${L?` · ${L}`:""}`,closeAria:"Close bot-only-PRs tab",body:t.jsxs(t.Fragment,{children:[t.jsx("span",{"aria-hidden":"true",className:"shrink-0",children:t.jsx(Lt,{})}),t.jsxs("span",{className:Hs(i,"amber"),children:["Bot-only PRs",L?` · ${L}`:""]})]})}}else if(e.kind==="user-activity"){const L=((I=e.userMeta)==null?void 0:I.login)??((S=e.userMeta)==null?void 0:S.displayName)??"contributor";N={title:`${L} — recent activity`,closeAria:"Close contributor activity tab",body:t.jsxs(t.Fragment,{children:[(T=e.userMeta)!=null&&T.avatarUrl?t.jsx("img",{src:e.userMeta.avatarUrl,width:14,height:14,alt:"",loading:"lazy",referrerPolicy:"no-referrer",draggable:!1,className:"h-3.5 w-3.5 shrink-0 rounded-full bg-gray-200 dark:bg-gray-800"}):t.jsx("span",{"aria-hidden":"true",className:"shrink-0",children:t.jsx(yx,{})}),t.jsx("span",{className:Hs(i,"sky"),children:L})]})}}else if(e.kind==="bot-detail"){const L=(($=e.botMeta)==null?void 0:$.label)??((P=e.botMeta)==null?void 0:P.login)??"bot";N={title:`${L} — bot depth`,closeAria:"Close bot depth tab",body:t.jsxs(t.Fragment,{children:[t.jsx("span",{"aria-hidden":"true",className:"shrink-0",children:t.jsx(Lt,{})}),t.jsxs("span",{className:Hs(i,"sky"),children:[L," · depth"]})]})}}else if(e.kind==="bot-threads"){const L=j(d);N={title:`Bot threads — review & resolve the likely-addressed backlog${L?` · ${L}`:""}`,closeAria:"Close bot-threads tab",body:t.jsxs(t.Fragment,{children:[t.jsx("span",{"aria-hidden":"true",className:"shrink-0",children:t.jsx(vx,{})}),t.jsxs("span",{className:Hs(i,"sky"),children:["Bot threads",L?` · ${L}`:""]})]})}}else if(e.kind==="theme-threads"){const L=(u==null?void 0:u.theme.title)??"Theme threads";N={title:`Theme threads — ${L}`,closeAria:"Close theme-threads tab",body:t.jsxs(t.Fragment,{children:[t.jsx("span",{"aria-hidden":"true",className:"shrink-0",children:t.jsx(bx,{})}),t.jsx("span",{className:Hs(i,"sky"),children:L})]})}}else if(e.kind==="bot-flagging"){const L=h?Kx(h.selector,h.bots).title:null,F=j((h==null?void 0:h.repoId)??null);N={title:`What the bots are flagging${L?` — ${L}`:""}${F?` · ${F}`:""}`,closeAria:"Close bot-flagging tab",body:t.jsxs(t.Fragment,{children:[t.jsx("span",{"aria-hidden":"true",className:"shrink-0",children:t.jsx(eo,{size:13})}),t.jsxs("span",{className:Hs(i,"sky"),children:["Flagged",L?` · ${L}`:""]})]})}}else if(e.kind==="bot-volume"){const L=g!=null&&g.bots?Ya(g.bots):null,F=j((g==null?void 0:g.repoId)??null);N={title:`Bot comments per merged PR${L?` — ${L}`:""}${F?` · ${F}`:""}`,closeAria:"Close bot-volume tab",body:t.jsxs(t.Fragment,{children:[t.jsx("span",{"aria-hidden":"true",className:"shrink-0",children:t.jsx(Qo,{})}),t.jsxs("span",{className:Hs(i,"sky"),children:["Comments/PR",L?` · ${L}`:""]})]})}}else if(e.kind==="people-report"){const L=x?(((C=w.data)==null?void 0:C.periods)??[]).find(M=>M.periodKey===x.periodKey)??null:null,F=L?ro(L.periodStart,L.periodEnd):(x==null?void 0:x.periodKey)??null;N={title:`People report${F?` — ${F}`:""} · one section per person or bot, alphabetical`,closeAria:"Close people-report tab",body:t.jsxs(t.Fragment,{children:[t.jsx("span",{"aria-hidden":"true",className:"shrink-0",children:t.jsx(Z4,{})}),t.jsxs("span",{className:Hs(i,"ai"),children:["People report",F?` · ${F}`:""]})]})}}else if(e.kind==="search"){const L=m??"";N={title:L?`Search — “${L}”`:"Search",closeAria:"Close search tab",body:t.jsxs(t.Fragment,{children:[t.jsx("span",{"aria-hidden":"true",className:"shrink-0 text-gray-500 dark:text-gray-400",children:t.jsx(eo,{size:13})}),t.jsx("span",{className:Hs(i,"sky"),children:L?`“${L}”`:"Search"})]})}}else{const L=e.kind==="pr-focus",F=e.meta,M=(F==null?void 0:F.authorDisplayName)??(F==null?void 0:F.authorLogin)??"unknown";N={buttonClass:"flex min-w-0 flex-1 items-center gap-1.5 py-1 text-left",title:`${(F==null?void 0:F.repoFullName)??""} #${(F==null?void 0:F.number)??""} · ${(F==null?void 0:F.title)??""}${L?" (focus)":""}`,closeAria:`Close ${L?"focus":"detail"} tab for PR #${(F==null?void 0:F.number)??""}`,body:t.jsxs(t.Fragment,{children:[L?t.jsx("span",{"aria-hidden":"true",className:"shrink-0 text-sky-500",children:t.jsx(eo,{size:14})}):(F==null?void 0:F.authorAvatarUrl)!=null?t.jsx("img",{src:F.authorAvatarUrl,alt:M,width:16,height:16,draggable:!1,className:"shrink-0 rounded-full",style:{width:16,height:16}}):t.jsx("span",{className:"flex shrink-0 items-center justify-center rounded-full bg-gray-300 text-[8px] font-semibold text-gray-700 dark:bg-gray-700 dark:text-gray-200",style:{width:16,height:16},children:M.slice(0,2).toUpperCase()}),t.jsxs("span",{className:"flex min-w-0 flex-col leading-tight",children:[t.jsxs("span",{className:`truncate text-xs font-medium ${i?"text-blue-600 dark:text-blue-400":"text-gray-600 dark:text-gray-300"}`,children:[t.jsxs("span",{className:"text-gray-400",children:["#",F==null?void 0:F.number]})," ",F==null?void 0:F.title]}),t.jsx("span",{className:"truncate text-[10px] text-gray-500 dark:text-gray-400",children:L?"PR focus":M})]})]})}}return t.jsx(mD,{tabKey:e.key,active:i,isDragged:n,width:N.width,buttonClass:N.buttonClass,title:N.title,closeAria:N.closeAria,body:N.body,onActivate:s,drag:r,onOpenMenu:a})}function i0({active:e,onClick:n,onContextMenu:r,icon:s,label:a,title:i}){return t.jsxs("button",{type:"button",role:"tab","aria-selected":e,onClick:n,onContextMenu:r,title:i,className:`flex shrink-0 items-center gap-1.5 rounded-t-md border border-b-0 px-3 py-1.5 text-xs font-semibold ${e?"border-gray-300 bg-white text-blue-600 dark:border-gray-700 dark:bg-gray-950 dark:text-blue-400":"border-transparent bg-transparent text-gray-600 hover:bg-gray-200/60 dark:text-gray-300 dark:hover:bg-gray-800/60"}`,children:[t.jsx("span",{"aria-hidden":"true",className:"shrink-0",children:s}),a]})}const fD=t.jsxs("svg",{viewBox:"0 0 24 24",width:"13",height:"13",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("polyline",{points:"22 12 16 12 14 15 10 15 8 12 2 12"}),t.jsx("path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z"})]}),xD=t.jsxs("svg",{viewBox:"0 0 24 24",width:"13",height:"13",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("line",{x1:"4",y1:"7",x2:"20",y2:"7"}),t.jsx("line",{x1:"4",y1:"12",x2:"14",y2:"12"}),t.jsx("line",{x1:"4",y1:"17",x2:"18",y2:"17"})]});function yD({x:e,y:n,tabKey:r,tabCount:s,onClose:a}){const i=Ge(w=>w.closeTab),c=Ge(w=>w.closeOtherTabs),d=Ge(w=>w.closeAllTabs),{refs:u,floatingStyles:m,context:h,isPositioned:g}=wa({open:!0,onOpenChange:w=>{w||a()},strategy:"fixed",placement:"bottom-start",middleware:[oo(2),io({fallbackPlacements:["top-start"]}),ri({padding:8})]}),x=si(h,{escapeKey:!1}),{getFloatingProps:y}=lo([x]);f.useEffect(()=>{u.setReference({getBoundingClientRect:()=>({x:e,y:n,top:n,left:e,right:e,bottom:n,width:0,height:0})})},[u,e,n]),f.useEffect(()=>{const w=k=>{k.key==="Escape"&&(k.stopPropagation(),a())};return document.addEventListener("keydown",w,!0),()=>document.removeEventListener("keydown",w,!0)},[a]);const b="flex w-full items-center gap-2 px-3 py-1.5 text-left text-xs text-gray-700 enabled:hover:bg-gray-100 disabled:opacity-40 dark:text-gray-200 dark:enabled:hover:bg-gray-800";return t.jsx(ka,{children:t.jsxs("div",{ref:u.setFloating,style:{...m,visibility:g?"visible":"hidden"},...y(),role:"menu","aria-label":"Tab actions",className:"z-[60] w-44 rounded-lg border border-gray-200 bg-white py-1 shadow-lg dark:border-gray-700 dark:bg-gray-900",children:[r!=null&&t.jsx("button",{role:"menuitem",type:"button",onClick:()=>{a(),i(r)},className:b,children:"Close this tab"}),r!=null&&t.jsx("button",{role:"menuitem",type:"button",disabled:s<=1,onClick:()=>{a(),c(r)},className:b,children:"Close other tabs"}),t.jsx("button",{role:"menuitem",type:"button",onClick:()=>{a(),d()},disabled:s===0,className:b,children:"Close all tabs"})]})})}function bD(){const e=Ge(A=>A.tabs),n=Ge(A=>A.activeTab),r=Ge(A=>A.setActiveTab),s=Ge(A=>A.showTimeline),a=G(A=>A.openOpenPrsDetail),i=Np(),c=nD(i.data,i.isPlaceholderData),d=Ge(A=>A.moveTab),u=f.useRef(null),m=f.useRef(null),h=f.useRef(!1),[g,x]=f.useState(null),y=f.useRef(null),[b,w]=f.useState(null),k=f.useRef(null),j=f.useRef(0),[N,I]=f.useState(null),S=f.useCallback(A=>{const W=m.current,z=u.current;if(!W||!z)return;const te=Array.from(z.querySelectorAll("[data-tabkey]")).filter(O=>O.dataset.tabkey!==W.key);let H=0;for(const O of te){const E=O.getBoundingClientRect();A>E.left+E.width/2&&H++}const B=te.map(O=>O.dataset.tabkey);B.splice(H,0,W.key),y.current=B,x(O=>O!=null&&O.length===B.length&&O.every((E,ee)=>E===B[ee])?O:B)},[]),T=f.useCallback(()=>{k.current!=null&&cancelAnimationFrame(k.current),k.current=null,j.current=0},[]);f.useEffect(()=>T,[T]);const $=f.useCallback(()=>{const A=u.current,W=m.current;if(!A||!W||j.current===0){k.current=null;return}A.scrollLeft+=j.current*8,S(W.lastX),k.current=requestAnimationFrame($)},[S]),P=f.useCallback(A=>{const W=m.current;if(m.current=null,T(),W!=null&&W.dragging){try{W.el.releasePointerCapture(W.pointerId)}catch{}const z=y.current;if(A&&z!=null){const te=z.indexOf(W.key);te!==-1&&d(W.key,te)}}y.current=null,x(null),w(null),h.current&&setTimeout(()=>{h.current=!1},0)},[d,T]),C=f.useRef(null);f.useEffect(()=>{var H,B;const A=C.current;if(A==null)return;if(b==null){A.replaceChildren();return}const W=(H=m.current)==null?void 0:H.el;if(W==null)return;const z=W.cloneNode(!0);z.removeAttribute("data-tabkey"),(B=z.querySelector("[data-tab-close]"))==null||B.remove(),z.classList.remove("opacity-50"),A.replaceChildren(z);const te=m.current;te!=null&&(A.style.transform=`translate3d(${te.lastX-te.grabDx}px, ${te.top}px, 0)`)},[b]),f.useEffect(()=>{if(b==null)return;const A=W=>{W.key==="Escape"&&(W.stopPropagation(),P(!1))};return document.addEventListener("keydown",A,!0),()=>document.removeEventListener("keydown",A,!0)},[b,P]),f.useEffect(()=>{if(b==null)return;const A=te=>{const H=m.current;if(!H||te.pointerId!==H.pointerId||!H.dragging)return;if((te.buttons&1)===0){P(!0);return}H.lastX=te.clientX;const B=C.current;B!=null&&(B.style.transform=`translate3d(${te.clientX-H.grabDx}px, ${H.top}px, 0)`),S(te.clientX);const O=u.current;if(O!=null){const E=O.getBoundingClientRect();j.current=te.clientX<E.left+40?-1:te.clientX>E.right-40?1:0,j.current!==0&&k.current==null&&(k.current=requestAnimationFrame($))}},W=te=>{const H=m.current;!H||te.pointerId!==H.pointerId||P(!0)},z=te=>{const H=m.current;!H||te.pointerId!==H.pointerId||P(!1)};return window.addEventListener("pointermove",A),window.addEventListener("pointerup",W),window.addEventListener("pointercancel",z),()=>{window.removeEventListener("pointermove",A),window.removeEventListener("pointerup",W),window.removeEventListener("pointercancel",z)}},[b,P,S,$]);const L=f.useMemo(()=>({onPointerDown:A=>{var te;if((te=m.current)!=null&&te.dragging||A.button!==0||A.target.closest("[data-tab-close]")!=null)return;const W=A.currentTarget.dataset.tabkey;if(W==null)return;h.current=!1;const z=A.currentTarget.getBoundingClientRect();m.current={key:W,pointerId:A.pointerId,startX:A.clientX,lastX:A.clientX,el:A.currentTarget,dragging:!1,grabDx:A.clientX-z.left,top:z.top}},onPointerMove:A=>{const W=m.current;if(!(!W||A.pointerId!==W.pointerId||W.dragging)){if((A.buttons&1)===0){m.current=null;return}if(W.lastX=A.clientX,!(Math.abs(A.clientX-W.startX)<=4)){W.dragging=!0,h.current=!0;try{W.el.setPointerCapture(W.pointerId)}catch{}w(W.key),S(A.clientX)}}},onPointerUp:A=>{const W=m.current;!W||A.pointerId!==W.pointerId||P(!0)},onPointerCancel:A=>{const W=m.current;!W||A.pointerId!==W.pointerId||P(!1)}}),[P,S]),F=f.useCallback(A=>{h.current||r(A)},[r]),M=f.useCallback((A,W)=>{A.preventDefault(),I({x:A.clientX,y:A.clientY,tabKey:W})},[]),D=f.useMemo(()=>{if(g==null)return e;const A=new Map(e.map(z=>[z.key,z])),W=g.map(z=>A.get(z)).filter(z=>z!=null);for(const z of e)g.includes(z.key)||W.push(z);return W},[e,g]);return t.jsxs(t.Fragment,{children:[t.jsxs("div",{ref:u,"data-testid":"pinned-tabs",role:"tablist","aria-label":"Views",className:"tab-scrollbar flex min-h-[42px] shrink-0 items-stretch gap-1 overflow-x-auto bg-gray-100 px-2 pt-1 dark:bg-gray-900",children:[t.jsx(i0,{active:n==="activity",onClick:()=>r("activity"),onContextMenu:A=>M(A,null),icon:fD,label:"Activity",title:"Activity — per-repo triage console"}),t.jsx(i0,{active:n==="open-prs",onClick:()=>a(),onContextMenu:A=>M(A,null),icon:t.jsx(Nd,{}),label:rD(c),title:"Open PRs — every open pull request in this Workspace"}),t.jsx(i0,{active:n==="timeline",onClick:s,onContextMenu:A=>M(A,null),icon:xD,label:"Timeline",title:"Timeline — the activity board"}),D.map((A,W)=>{var z;return t.jsxs(f.Fragment,{children:[W>0&&((z=D[W-1])==null?void 0:z.key)!==n&&A.key!==n&&t.jsx("span",{"aria-hidden":"true",className:"pointer-events-none -mx-px h-4 w-px shrink-0 self-center bg-gray-300 dark:bg-gray-700"}),t.jsx(gD,{tab:A,isDragged:b===A.key,drag:L,onActivate:F,onOpenMenu:M})]},A.key)}),N!=null&&t.jsx(yD,{x:N.x,y:N.y,tabKey:N.tabKey,tabCount:e.length,onClose:()=>I(null)})]}),t.jsx("div",{ref:C,"aria-hidden":"true",className:`pointer-events-none fixed left-0 top-0 z-[70] flex items-stretch rounded-t-md shadow-lg ring-1 ring-black/10 dark:ring-white/10 ${b==null?"hidden":""}`,style:{transform:"translate3d(-9999px, -9999px, 0)"}})]})}const vD="Review and fix run on your machine: npx limn-review",kD="Sign in to Claude Code or set ANTHROPIC_API_KEY",wD="Set up AI (one-time ~110 MB download)";function jD(e){const n=e==null?void 0:e.ai,r=(n==null?void 0:n.enabled)===!0,s=(n==null?void 0:n.runtime)??"absent",a=(n==null?void 0:n.auth)??"none";return{enabled:r,cloud:(e==null?void 0:e.deploymentMode)==="cloud",runtime:s,runtimeMessage:(n==null?void 0:n.runtimeMessage)??null,auth:a,authMessage:(n==null?void 0:n.authMessage)??null,ready:r&&s==="ready"&&a==="ok"}}function Dr(){return jD(In().data)}let Of={phase:"idle",message:null};const Df=new Set;function Du(e){Of=e;for(const n of Df)n()}function ND(e){return Df.add(e),()=>Df.delete(e)}function SD(){const e=He();return{state:f.useSyncExternalStore(ND,()=>Of),start:()=>{if(Of.phase==="running")return;Du({phase:"running",message:null});let s=null;Pd("/api/ai/runtime/install",{method:"POST",onEvent:a=>{a.type==="error"?s=a.message||"The download failed.":a.type==="progress"&&a.message.trim()!==""&&Du({phase:"running",message:a.message.trim()})}}).then(()=>{Du(s!=null?{phase:"failed",message:s}:{phase:"idle",message:null})}).catch(a=>{Du({phase:"failed",message:a instanceof Error?a.message:"The download failed."})}).finally(()=>{e.invalidateQueries({queryKey:["me"]})})}}}function CD(e){Oe({queryKey:["me"],queryFn:he.me,retry:!1,refetchInterval:e?2e3:!1})}function HJ({children:e,auth:n}){const r=Dr();return r.enabled?r.runtime!=="ready"?t.jsx(dC,{}):r.auth==="none"||n==="none"?t.jsx(cC,{}):t.jsx(t.Fragment,{children:e}):null}function cC(){return t.jsx("span",{className:"text-xs text-gray-600 dark:text-gray-300",children:kD})}function dC(){const e=Dr(),{state:n,start:r}=SD(),s=e.runtime==="installing"&&n.phase!=="running";if(CD(s),!e.enabled||e.runtime==="ready")return null;if(n.phase==="running"||e.runtime==="installing")return t.jsxs("span",{className:"text-xs text-gray-600 dark:text-gray-300",role:"status",children:["Setting up AI…",n.message!=null?` ${n.message}`:""]});const a=n.phase==="failed"?n.message??"The download failed.":e.runtime==="failed"?e.runtimeMessage??"The download failed.":null;return t.jsxs("span",{className:"inline-flex flex-wrap items-center gap-2",children:[a!=null&&t.jsx("span",{className:"text-xs text-red-600 dark:text-red-400",children:a}),t.jsx("button",{type:"button",onClick:r,className:"rounded border border-gray-300 px-2 py-1 text-xs hover:border-gray-400 dark:border-gray-700 dark:hover:border-gray-500",children:a!=null?"Retry":wD})]})}function RD({className:e=""}){const n=Dr();return n.enabled||!n.cloud?null:t.jsx("span",{className:`text-xs text-gray-600 dark:text-gray-300 ${e}`,children:vD})}const r1=25;function Vr(e){return e&&e.length>0?[...e].sort((n,r)=>n-r).join(","):"all"}function Qp(e,n,r=!0,s){return Oe({queryKey:["bot-analytics",n,dt(e),Vr(s)],queryFn:e==null?Ct:()=>he.botAnalytics(n,e,s),enabled:r,refetchInterval:5*6e4,refetchIntervalInBackground:!1,staleTime:6e4,gcTime:fn})}function uC(e,n,r=!0,s,a){const{botDepth:i}=vt();return Oe({queryKey:["bot-behaviour",n,dt(e),Vr(s),a!=null?`bot:${a}`:"bot:all"],queryFn:e==null?Ct:()=>he.botBehaviour(n,e,s,a),enabled:r&&i,refetchInterval:5*6e4,refetchIntervalInBackground:!1,staleTime:6e4,gcTime:fn})}function ID(e,n,r=!0,s){return Oe({queryKey:["bot-only-prs",n,dt(e),Vr(s)],queryFn:e==null?Ct:()=>he.botOnlyPrs(n,e,s),enabled:r,refetchInterval:5*6e4,refetchIntervalInBackground:!1,staleTime:6e4,gcTime:fn})}function TD(e,n){return["bot-reviewers",dt(e),Vr(n)]}function qi(e,n,r=!0){return Oe({queryKey:TD(e,n),queryFn:e==null?Ct:()=>he.botReviewers(e,n),enabled:r,staleTime:6e4,gcTime:fn})}const $D=["bot-reviewers","bot-analytics","bot-behaviour","bot-only-prs","bot-resolvable","bot-vendor-prs","bot-vendor-comments","bot-flagging","bot-dedup","pr-bot-behaviour","activity","consolidated-feed","pr"];function Yp(e){for(const n of $D)e.invalidateQueries({queryKey:[n]})}function hC(){const e=He();return tt({mutationFn:({userId:n,body:r})=>he.setWorkspaceReviewer(n,r),onSuccess:()=>Yp(e)})}function _D(){const e=He();return tt({mutationFn:({userId:n,body:r})=>he.setReviewerCost(n,r),onSuccess:()=>Yp(e)})}function PD(){const e=He();return tt({mutationFn:({userId:n,workspaceId:r})=>he.resetReviewerJudgement(n,r),onSuccess:()=>Yp(e)})}function ED(){const e=He();return tt({mutationFn:({userId:n,workspaceId:r})=>he.resetReviewerIdentity(n,r),onSuccess:()=>Yp(e)})}function AD(e,n=!0){return Oe({queryKey:["bot-dedup",e],queryFn:()=>he.prBotDedup(e),enabled:n&&e!=null,staleTime:6e4,gcTime:fn})}function pC(e,n=!0){return Oe({queryKey:["pr-bot-behaviour",e],queryFn:()=>he.prBotBehaviour(e),enabled:n&&e!=null,staleTime:6e4,gcTime:fn})}function mC(e,n=!0,r){return Oe({queryKey:["bot-resolvable",dt(e),Vr(r)],queryFn:e==null?Ct:()=>he.resolvableBotThreads(e,r),enabled:n,staleTime:6e4,gcTime:fn})}function MD(){const e=He();return tt({mutationFn:async({threadIds:n,workspaceId:r,onProgress:s,shouldStop:a})=>{const i=n.length;let c=0,d=0,u=0,m=!1;for(let h=0;h<n.length;h+=r1){if(a!=null&&a()){m=!0;break}const g=n.slice(h,h+r1),x=await he.scopeResolveBotThreads({threadIds:g,workspaceId:r});c+=x.resolved,d+=x.failed,u+=g.length,s==null||s(u,i,c,d)}return{resolved:c,failed:d,stopped:m}},onSettled:(n,r,s)=>{e.invalidateQueries({queryKey:["bot-resolvable"]}),e.invalidateQueries({queryKey:["bot-analytics"]}),e.invalidateQueries({queryKey:["bot-only-prs"]}),e.invalidateQueries({queryKey:["bot-vendor-prs"]}),e.invalidateQueries({queryKey:["bot-vendor-comments"]}),e.invalidateQueries({queryKey:["bot-flagging"]}),dn(e,s.prIds??null,{threadIds:s.threadIds})}})}function gC(e,n){var s;const r=Yh(e);return r==null?null:zN((s=n.get(r))==null?void 0:s.githubLogin)}function Yh(e){var n;return e.originalCommenterId??((n=e.comments[0])==null?void 0:n.authorId)??null}function fC(e,n,r,s){const a=[];for(const i of e){if(i.isResolved||i.derivedState!=="likely_addressed")continue;const c=gC(i,n);if(c==null||r!=null&&c!==r)continue;const d=Yh(i),u=d!=null?s==null?void 0:s.get(d):void 0;u!=null&&(!u.automated||u.role!=="review")||a.push(i.id)}return a}const LD=["untouched","replied_unresolved","likely_addressed","resolved"];function Zl(e){const n={untouched:0,replied_unresolved:0,likely_addressed:0,resolved:0};for(const r of e)n[r.derivedState]+=1;return n}function xC(e,n){const r=new Set;if(!n)return r;for(const s of e.comments){const a=n.get(gd("review_comment",s.id));a&&!a.isSummary&&r.add(a.severity)}return r}function Jl({counts:e,compact:n=!1}){const r=LD.filter(s=>e[s]>0);return r.length===0?null:t.jsx("span",{className:`inline-flex items-center ${n?"gap-1":"gap-1.5"}`,children:r.map(s=>{const a=Xt[s];return n?t.jsx("span",{className:`inline-block h-2 w-2 rounded-full ${s==="resolved"?"opacity-40":""}`,style:{backgroundColor:a.color},title:`${a.label}: ${e[s]}`},s):t.jsxs("span",{className:"inline-flex items-center gap-0.5 text-[10px] font-semibold",style:pn(a.color),title:`${a.label}: ${e[s]}`,children:[t.jsx("span",{className:"inline-block h-2 w-2 rounded-full",style:{backgroundColor:a.color}}),e[s]]},s)})})}function FD(e){return[...e].sort((n,r)=>r.createdAt.localeCompare(n.createdAt))}function OD({path:e,threads:n,usersById:r,prUrl:s,repoId:a,selectedThreadId:i,viewedSince:c,registerRef:d,openInChangesFor:u}){const m=Zl(n),h=n.some(T=>T.derivedState!=="resolved"),g=i!=null&&n.some(T=>T.id===i),x=h,y=G(T=>T.expandedFileGroups),b=G(T=>T.collapsedFileGroups),w=G(T=>T.toggleFileGroup),k=x?!b.includes(e):y.includes(e),j=g||k,N=e.split("/"),I=N.at(-1),S=N.slice(0,-1).join("/");return t.jsxs("div",{className:"border-b border-gray-100 dark:border-gray-800",children:[t.jsxs("button",{type:"button",onClick:()=>w(e,x),className:"flex w-full items-center gap-2 px-3 py-2 text-left hover:bg-gray-50 dark:hover:bg-gray-900",children:[t.jsx(Mt,{dir:j?"down":"right",className:"shrink-0 text-gray-400"}),t.jsxs("code",{className:"min-w-0 flex-1 truncate font-mono text-xs",title:e,children:[S&&t.jsxs("span",{className:"text-gray-400",children:[S,"/"]}),t.jsx("span",{className:"font-semibold",children:I})]}),t.jsx(Jl,{counts:m})]}),j&&t.jsx("div",{className:"space-y-2 px-3 pb-3",children:FD(n).map(T=>t.jsx("div",{ref:$=>d(T.id,$),children:t.jsx(Li,{thread:T,usersById:r,prUrl:s,repoId:a,selected:T.id===i,viewedSince:c,openInChanges:(u==null?void 0:u(T))??null})},T.id))})]})}const DD=new Set,BD=new Set;function WD(e){const n=new Map;for(const s of e){const a=n.get(s.path)??[];a.push(s),n.set(s.path,a)}const r=[...n.entries()].map(([s,a])=>({path:s,threads:a,newest:a.reduce((i,c)=>c.createdAt>i?c.createdAt:i,"")}));return r.sort((s,a)=>a.newest.localeCompare(s.newest)||s.path.localeCompare(a.path)),r}function qD({threads:e,usersById:n,prUrl:r,prId:s,repoId:a,selectedThreadId:i,viewedSince:c,botFilter:d=null,stateFilter:u,severityFilter:m,openInChangesFor:h}){const g=f.useRef(new Map),x=G(J=>J.setThreadBotFilter),y=G(J=>J.toggleThreadStateFilter),b=G(J=>J.setThreadStateFilter),w=u??DD,k=m??BD,j=G(J=>J.toggleThreadSeverityFilter),N=G(J=>J.setThreadSeverityFilter),I=ba(),S=Ip(s??null,I),T=f.useCallback(J=>xC(J,S),[S]),$=GS(),[P,C]=f.useState(!1),{data:L}=AD(s??null),F=(L==null?void 0:L.clusters)??[],M=J=>{var ne;(ne=g.current.get(J))==null||ne.scrollIntoView({behavior:"smooth",block:"center"})},D=f.useRef(new Map),A=(J,ne,ae)=>{const we=ae.filter(oe=>g.current.has(oe));if(we.length===0)return;const $e=`${J}:${ne}`,Fe=D.current.get($e)??0;M(we[Fe%we.length]),D.current.set($e,Fe+1)},W=f.useMemo(()=>e.filter(J=>(d?gC(J,n)===d:!0)&&(w.size===0||w.has(J.derivedState))&&(k.size===0||[...T(J)].some(ne=>k.has(ne)))),[e,d,n,w,k,T]),z=f.useMemo(()=>Zl(e),[e]),te=f.useMemo(()=>{const J={critical:0,major:0,minor:0,nit:0};for(const ne of e)for(const ae of T(ne))J[ae]+=1;return J},[e,T]),{data:H}=xn(),B=f.useMemo(()=>{var J;return a==null?null:((J=(H??[]).find(ne=>ne.id===a))==null?void 0:J.workspaceId)??null},[H,a]),{data:O}=qi(B,null,d!=null),E=f.useMemo(()=>{if(O==null)return null;const J=new Map;for(const ne of O.reviewers)J.set(ne.userId,{automated:ne.automated,role:ne.role});return J},[O]),ee=f.useMemo(()=>fC(e,n,d,E),[e,n,d,E]);f.useEffect(()=>{if(i==null)return;const J=g.current.get(i);J&&J.scrollIntoView({behavior:"smooth",block:"nearest"})},[i]),f.useEffect(()=>{ee.length===0&&C(!1)},[ee.length]);const K=f.useMemo(()=>WD(W),[W]),U=d?Qs[d]:null,Q=()=>{s==null||ee.length===0||$.mutate({prId:s,threadIds:ee},{onSettled:()=>C(!1)})};return t.jsxs("div",{children:[e.length>0&&t.jsxs("div",{className:"sticky top-0 z-10 space-y-2 border-b border-gray-100 bg-white/95 px-3 py-2 backdrop-blur dark:border-gray-800 dark:bg-gray-900/95",style:U?{boxShadow:`inset 3px 0 0 ${U.color}`}:void 0,children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[t.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wide text-gray-400",children:"State"}),wd.map(J=>{const ne=Xt[J],ae=w.has(J),we=z[J];return t.jsxs("button",{type:"button",onClick:()=>y(J),"aria-pressed":ae,className:`flex items-center gap-1 rounded-full border px-2 py-0.5 text-[11px] font-medium transition-colors ${ae?"border-sky-400 bg-sky-50 text-sky-700 dark:border-sky-500/60 dark:bg-sky-950/30 dark:text-sky-300":"border-gray-300 text-gray-500 hover:border-gray-400 dark:border-gray-700 dark:text-gray-400"}`,title:ne.description,children:[t.jsx("span",{"aria-hidden":"true",className:"inline-block h-2 w-2 rounded-full",style:{background:ne.color}}),ne.label,we>0&&t.jsx("span",{className:"tabular-nums opacity-70",children:we})]},J)}),w.size>0&&t.jsx("button",{type:"button",onClick:()=>b(new Set),className:"rounded px-1.5 py-0.5 text-[11px] text-gray-500 dark:text-gray-400 underline-offset-2 hover:underline",children:"Clear"})]}),S!=null&&S.size>0&&t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[t.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wide text-gray-400",children:"Severity"}),hp.map(J=>{const ne=Ht[J],ae=k.has(J),we=te[J]??0;return t.jsxs("button",{type:"button",onClick:()=>j(J),"aria-pressed":ae,disabled:we===0&&!ae,className:`flex items-center gap-1 rounded-full border px-2 py-0.5 text-[11px] font-medium transition-colors disabled:opacity-40 ${ae?"border-sky-400 bg-sky-50 text-sky-700 dark:border-sky-500/60 dark:bg-sky-950/30 dark:text-sky-300":"border-gray-300 text-gray-500 hover:border-gray-400 dark:border-gray-700 dark:text-gray-400"}`,title:ne.description,children:[t.jsx("span",{"aria-hidden":"true",className:"inline-block h-2 w-2 rounded-full",style:{background:ne.color}}),ne.label,we>0&&t.jsx("span",{className:"tabular-nums opacity-70",children:we})]},J)}),k.size>0&&t.jsx("button",{type:"button",onClick:()=>N(new Set),className:"rounded px-1.5 py-0.5 text-[11px] text-gray-500 dark:text-gray-400 underline-offset-2 hover:underline",children:"Clear"})]}),U&&t.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:[t.jsxs("span",{className:"inline-flex items-center gap-1 font-medium",style:pn(U.color),children:[t.jsx(Lt,{size:12}),U.label]}),t.jsxs("span",{className:"text-gray-500 dark:text-gray-400",children:[W.length," thread",W.length===1?"":"s"]}),t.jsx("button",{type:"button",onClick:()=>x(null),className:"rounded px-1.5 py-0.5 text-gray-500 dark:text-gray-400 underline-offset-2 hover:underline",children:"Show all threads"}),ee.length>0&&t.jsx("span",{className:"ml-auto flex items-center gap-2",children:P?t.jsxs(t.Fragment,{children:[t.jsxs("span",{className:"text-gray-500 dark:text-gray-400",children:["Resolve ",ee.length," likely-addressed thread",ee.length===1?"":"s"," on GitHub?"]}),t.jsx("button",{type:"button",disabled:$.isPending,onClick:Q,className:"rounded bg-green-600 px-2 py-0.5 font-medium text-white hover:bg-green-700 disabled:opacity-60",children:$.isPending?"Resolving…":"Yes, resolve"}),t.jsx("button",{type:"button",disabled:$.isPending,onClick:()=>C(!1),className:"rounded px-2 py-0.5 text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300",children:"Cancel"})]}):t.jsxs("button",{type:"button",onClick:()=>C(!0),className:"rounded border px-2 py-0.5 font-medium hover:opacity-80",style:{borderColor:U.color,...pn(U.color)},title:"A later commit touched the file these threads flag — resolve them in one click (you approve each batch).",children:["Resolve ",ee.length," addressed"]})})]})]}),$.data&&($.data.resolved>0||$.data.failed>0)&&t.jsxs("div",{className:"px-3 py-1.5 text-xs text-gray-500 dark:text-gray-400",children:["Resolved ",$.data.resolved,$.data.failed>0&&` · ${$.data.failed} failed`,"."]}),F.length>0&&t.jsxs("div",{"data-testid":"bot-dedup",className:"mx-3 my-2 rounded-md border border-sky-200 bg-sky-50/60 px-3 py-2 text-xs dark:border-sky-800 dark:bg-sky-950/30",children:[t.jsxs("div",{className:"mb-1.5 flex items-center gap-1.5 font-medium text-sky-800 dark:text-sky-200",children:[t.jsx(Lt,{}),"Multiple bots flagged the same ",F.length===1?"line":"lines"]}),t.jsx("ul",{className:"space-y-1.5",children:F.map((J,ne)=>{const ae=J.path.split("/").pop()??J.path,we=`${J.path}:${J.line??"x"}:${ne}`,Fe=new Set(J.members.map(oe=>oe.userId)).size===2?"both flagged":"all flagged";return t.jsxs("li",{className:"flex flex-wrap items-center gap-x-1.5 gap-y-1",children:[J.members.map((oe,re)=>{const X=ds(oe.kind),le=oe.threadIds&&oe.threadIds.length>0?oe.threadIds:[oe.threadId];return t.jsxs(f.Fragment,{children:[re>0&&t.jsx("span",{className:"text-gray-400",children:"+"}),t.jsxs("button",{type:"button",onClick:()=>A(we,oe.userId,le),className:"inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] font-medium hover:opacity-80",style:{...pn(X.color),background:`${X.color}1a`},title:le.length>1?`${oe.label} left ${le.length} threads here — click to cycle through them`:`Jump to ${oe.label}'s thread`,children:[oe.label,le.length>1&&t.jsxs("span",{className:"opacity-70",children:["×",le.length]})]})]},oe.threadId)}),t.jsxs("span",{className:"text-gray-600 dark:text-gray-300",children:[Fe," ",t.jsx("code",{className:"font-mono",children:ae}),J.line!=null?`:${J.line}`:""]}),J.conflict?t.jsx("span",{className:"rounded bg-amber-100 px-1.5 py-0.5 text-[10px] font-semibold text-amber-700 dark:bg-amber-900/40 dark:text-amber-300",title:"The bots disagree on severity/verdict here — worth a human look.",children:"bots disagree here"}):J.consensus?t.jsx("span",{className:"rounded bg-green-100 px-1.5 py-0.5 text-[10px] font-semibold text-green-700 dark:bg-green-900/40 dark:text-green-300",title:"The bots agree here — one fix likely clears both.",children:"consensus"}):null]},we)})})]}),W.length===0?t.jsx("div",{className:"px-3 py-6 text-center text-sm text-gray-500 dark:text-gray-400",children:w.size>0?"No threads in the selected state(s).":d?"No threads from this bot on this PR.":"No review threads on this PR."}):K.map(J=>t.jsx(OD,{path:J.path,threads:J.threads,usersById:n,prUrl:r,repoId:a,selectedThreadId:i,viewedSince:c,registerRef:(ne,ae)=>{ae?g.current.set(ne,ae):g.current.delete(ne)},openInChangesFor:h},J.path))]})}const s1=5;function a1(e,n,r){var a;const s=n.get(e);if(s!=null){if(s.automated)return!0;if(s.isManualOverride)return!1}return((a=r.get(e))==null?void 0:a.isBot)??!1}function Bu({color:e}){return t.jsx("span",{"aria-hidden":"true",className:"inline-block h-2 w-2 rounded-full",style:{background:e}})}function o1({pr:e,usersById:n,variant:r,onOpenThreads:s}){const[a,i]=f.useState(!1),c=GS(),u=f.useMemo(()=>e.threads.reduce((z,te)=>z+te.comments.length,0),[e.threads])>=s1,{data:m}=xn(),h=f.useMemo(()=>{var z;return((z=(m??[]).find(te=>te.id===e.repoId))==null?void 0:z.workspaceId)??null},[m,e.repoId]),{data:g}=qi(h,null,u),x=f.useMemo(()=>{const z=new Map;for(const te of(g==null?void 0:g.reviewers)??[])z.set(te.userId,te);return z},[g]),y=f.useMemo(()=>e.threads.filter(z=>{const te=Yh(z);return te!=null&&a1(te,x,n)}),[e.threads,x,n]),b=f.useMemo(()=>{let z=0;for(const te of e.threads)for(const H of te.comments)H.authorId!=null&&a1(H.authorId,x,n)&&(z+=1);return z},[e.threads,x,n]),w=u&&g!=null&&y.length>0&&b>=s1,k=ba(),j=Ip(e.id,k&&w),N=vt().prSummary,I=Wp(e.id,N&&w),S=f.useMemo(()=>Zl(y),[y]),T=f.useMemo(()=>y.filter(z=>xC(z,j).has("nit")).length,[y,j]),$=f.useMemo(()=>{if(I==null)return null;let z=0,te=0;for(const H of y){const B=H.comments[0];if(B==null)continue;const O=I.get(zo("validity","review_comment",B.id));if((O==null?void 0:O.verdict)==null)continue;z+=1;const E=I.get(zo("addressed","thread",H.id)),ee=H.isResolved||(E==null?void 0:E.verdict)==="addressed"||(E==null?void 0:E.verdict)==="likely";O.verdict==="valid"&&!ee&&(te+=1)}return{judged:z,real:te,unjudged:y.length-z}},[I,y]),P=f.useMemo(()=>{if(g==null)return null;const z=new Map;for(const te of g.reviewers)z.set(te.userId,{automated:te.automated,role:te.role});return z},[g]),C=f.useMemo(()=>fC(e.threads,n,null,P),[e.threads,n,P]),L=f.useMemo(()=>{const z=new Set(C);return e.threads.filter(te=>z.has(te.id))},[e.threads,C]);if(!w)return null;const F=S.untouched+S.replied_unresolved,M=S.likely_addressed,D=$!=null&&$.judged>0,A=[];D?A.push(t.jsxs("span",{className:"inline-flex items-center gap-1 font-medium text-red-600 dark:text-red-400",children:[t.jsx(Bu,{color:"#e11d48"}),$.real," real issue",$.real===1?"":"s"]},"real")):F>0&&A.push(t.jsxs("span",{className:"inline-flex items-center gap-1",children:[t.jsx(Bu,{color:Xt.untouched.color}),F," awaiting a look"]},"open")),M>0&&A.push(t.jsxs("span",{className:"inline-flex items-center gap-1",children:[t.jsx(Bu,{color:Xt.likely_addressed.color}),M," likely addressed"]},"addr")),T>0&&A.push(t.jsxs("span",{className:"inline-flex items-center gap-1",children:[t.jsx(Bu,{color:Ht.nit.color}),T," nit-flagged"]},"nits"));const W=t.jsxs("span",{className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[t.jsxs("span",{className:"inline-flex items-center gap-1 font-medium text-gray-700 dark:text-gray-200",children:[t.jsx(Lt,{size:12}),b," bot comments"]}),A.map((z,te)=>t.jsxs("span",{className:"inline-flex items-center gap-2",children:[te===0?t.jsx("span",{className:"text-gray-400",children:":"}):t.jsx("span",{className:"text-gray-400",children:"·"}),z]},te))]});return r==="compact"?t.jsxs("div",{"data-testid":"bot-triage-card",className:"mx-4 mt-2 flex flex-wrap items-center gap-x-3 gap-y-1 rounded-md border border-gray-200 bg-gray-50/60 px-3 py-1.5 text-xs text-gray-600 dark:border-gray-800 dark:bg-gray-900/40 dark:text-gray-300",children:[W,s&&t.jsx("button",{type:"button",onClick:s,className:"ml-auto rounded px-1.5 py-0.5 font-medium text-sky-600 underline-offset-2 hover:underline dark:text-sky-400",title:C.length>0?"Open the Threads tab — the likely-addressed threads can be resolved from there.":"Open the Threads tab.",children:C.length>0?`Resolve the ${C.length} addressed →`:D&&$.unjudged>0?"Judge the rest →":"View threads →"})]}):t.jsxs("div",{"data-testid":"bot-triage-card",className:"mx-3 mt-2 rounded-md border border-gray-200 bg-gray-50/60 px-3 py-2 text-xs text-gray-600 dark:border-gray-800 dark:bg-gray-900/40 dark:text-gray-300",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:[W,D&&$.unjudged>0&&t.jsxs("span",{className:"text-gray-400",title:"Judge the rest with the “Check review” button on each thread below — one judgement per click, nothing runs automatically.",children:[$.unjudged," unjudged"]}),C.length>0&&!a&&t.jsxs("button",{type:"button",onClick:()=>i(!0),disabled:c.isPending,className:"ml-auto rounded border border-green-600 px-2 py-0.5 font-medium text-green-700 hover:bg-green-50 disabled:opacity-60 dark:text-green-400 dark:hover:bg-green-950/30",title:"A later commit touched the file each of these threads flags — review the exact list, then resolve them on GitHub in one click.",children:["Resolve the ",C.length," addressed"]})]}),a&&t.jsxs("div",{className:"mt-2 rounded border border-green-200 bg-white/60 p-2 dark:border-green-900 dark:bg-gray-950/40",children:[t.jsxs("div",{className:"mb-1 font-medium text-gray-700 dark:text-gray-200",children:["Resolve ",L.length," likely-addressed bot thread",L.length===1?"":"s"," on GitHub?"]}),t.jsx("ul",{className:"mb-2 max-h-48 space-y-1 overflow-y-auto",children:L.map(z=>{var O,E;const te=Yh(z),H=te!=null?n.get(te):void 0,B=(((O=z.comments[0])==null?void 0:O.body)??"").replace(/\s+/g," ").slice(0,90);return t.jsxs("li",{className:"flex items-baseline gap-1.5",children:[t.jsxs("code",{className:"shrink-0 font-mono text-[10px] text-gray-500 dark:text-gray-400",children:[z.path.split("/").pop()??z.path,z.line!=null?`:${z.line}`:""]}),t.jsxs("span",{className:"truncate text-gray-500 dark:text-gray-400",title:((E=z.comments[0])==null?void 0:E.body)??"",children:[Dt(H,te),": ",B]})]},z.id)})}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{type:"button",disabled:c.isPending,onClick:()=>c.mutate({prId:e.id,threadIds:C},{onSettled:()=>i(!1)}),className:"rounded bg-green-600 px-2 py-0.5 font-medium text-white hover:bg-green-700 disabled:opacity-60",children:c.isPending?"Resolving…":"Yes, resolve"}),t.jsx("button",{type:"button",disabled:c.isPending,onClick:()=>i(!1),className:"rounded px-2 py-0.5 text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300",children:"Cancel"})]})]}),c.data&&(c.data.resolved>0||c.data.failed>0)&&t.jsxs("div",{className:"mt-1 text-gray-500 dark:text-gray-400",children:["Resolved ",c.data.resolved,c.data.failed>0&&` · ${c.data.failed} failed`,"."]})]})}const Bf="limn.blastImpactNote.collapsed.v1";function UD(){try{return localStorage.getItem(Bf)==="1"}catch{return!1}}function HD(e){try{e?localStorage.setItem(Bf,"1"):localStorage.removeItem(Bf)}catch{}}function zD(e,n){const r=Wp(e,n);return r==null?void 0:r.get(zo("impact","pull_request",e))}function KD({prId:e,hasBlast:n}){var g;const r=vt().prSummary,s=ey().showImpactNote,[a,i]=f.useState(UD),c=f.useCallback(()=>{i(x=>!x),HD(!a)},[a]),d=zD(e,r&&n&&s),{state:u,run:m}=X5(e);if(!r||!n||!s)return null;const h=(d==null?void 0:d.verdict)==="concern";return t.jsxs("div",{className:"mt-1.5 flex flex-col items-start gap-1",children:[d==null&&t.jsxs("button",{type:"button",onClick:()=>m("impact"),disabled:u.running,className:"inline-flex items-center gap-1 rounded text-[11px] text-gray-500 hover:text-gray-700 disabled:opacity-60 dark:text-gray-400 dark:hover:text-gray-200",children:[t.jsx(Ps,{size:11}),u.running?"Reading the change…":"What could this break?"]}),d!=null&&a&&t.jsxs("button",{type:"button",onClick:c,className:"inline-flex items-center gap-1 text-[11px] text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200","aria-expanded":!1,children:[t.jsx(Mt,{size:11,dir:"right"}),"Impact note",h&&t.jsx("span",{className:"text-amber-600 dark:text-amber-500",children:"· flagged"})]}),d!=null&&!a&&t.jsxs("div",{className:"flex flex-col items-start gap-0.5",children:[t.jsxs("button",{type:"button",onClick:c,className:"inline-flex items-center gap-1 text-[11px] text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200","aria-expanded":!0,children:[t.jsx(Mt,{size:11,dir:"down"}),"Impact note"]}),h&&t.jsxs("span",{className:"inline-flex items-center gap-1 text-[11px] text-amber-600 dark:text-amber-500",children:[t.jsx(Jt,{size:11,className:"inline-block align-[-0.1em]"}),"Flagged on a closer read"]}),t.jsx("p",{className:"max-w-prose text-[12px] leading-snug text-gray-600 dark:text-gray-300",children:d.body}),t.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-gray-400 dark:text-gray-500",children:[t.jsxs("span",{children:["Written by ",d.model]}),d.stale&&t.jsx("button",{type:"button",onClick:()=>m("impact"),disabled:u.running,className:"underline hover:text-gray-600 disabled:opacity-60 dark:hover:text-gray-300",children:u.running?"Re-reading…":"Out of date — read again"})]})]}),u.error!=null&&t.jsx("span",{className:"text-[11px] text-red-500",children:u.error}),((g=u.result)==null?void 0:g.creditsExhausted)===!0&&t.jsx("span",{className:"text-[11px] text-gray-500 dark:text-gray-400",children:"Out of AI credits for this month."})]})}const l0="inline-flex items-center gap-1 whitespace-nowrap rounded border border-green-500 px-2 py-0.5 text-sm font-medium text-green-700 hover:bg-green-50 disabled:opacity-50 dark:border-green-600 dark:text-green-400 dark:hover:bg-green-900/30",i1="inline-flex items-center gap-1 whitespace-nowrap rounded border border-amber-500 px-2 py-0.5 text-sm font-medium text-amber-700 hover:bg-amber-50 disabled:opacity-50 dark:border-amber-600 dark:text-amber-400 dark:hover:bg-amber-900/30",GD="whitespace-nowrap rounded border border-gray-300 px-2 py-0.5 text-sm hover:border-gray-400 disabled:opacity-50 dark:border-gray-700 dark:hover:border-gray-500";function VD({prId:e,standing:n}){const[r,s]=f.useState(null),[a,i]=f.useState(""),[c,d]=f.useState(null),u=ZP(e),m=JP(e);f.useEffect(()=>{c!=null&&c===n&&d(null)},[c,n]);const h=c??n,g=u.isPending||m.isPending,x=u.error??m.error,y=x instanceof cn?x.message:x?"GitHub did not accept the review.":null,b=()=>{s(null),i(""),u.reset(),m.reset()},w=I=>{u.reset(),m.reset(),i(""),s(I)},k=I=>{g||(m.reset(),u.mutate(I,{onSuccess:()=>{d("approved"),s(null),i("")}}))},j=()=>{if(g)return;u.reset();const I=a.trim();m.mutate(I||void 0,{onSuccess:()=>{d("changes_requested"),s(null),i("")}})},N=y&&t.jsx("span",{className:"text-xs text-red-500",children:y});if(r!=null){const I=r==="approve-comment",S=I?a.trim()!=="":!0;return t.jsxs("div",{className:"w-full space-y-1.5",children:[t.jsx(Ad,{prId:e,value:a,onChange:i,rows:3,autoFocus:!0,placeholder:I?"Comment to post with your approval (markdown)…":`Optional. Left blank, this posts "${C$}"`,className:"w-full rounded border border-gray-300 bg-white px-2 py-1.5 text-sm dark:border-gray-700 dark:bg-gray-900"}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[I?t.jsxs("button",{type:"button",onClick:()=>k(a.trim()),disabled:g||!S,className:l0,children:[t.jsx(pr,{})," ",u.isPending?"Approving…":"Approve"]}):t.jsxs("button",{type:"button",onClick:j,disabled:g,className:i1,children:[t.jsx(Jt,{})," ",m.isPending?"Sending…":"Request changes"]}),t.jsx("button",{type:"button",onClick:b,disabled:g,className:GD,children:"Cancel"}),N]})]})}return t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[h==="approved"?t.jsxs("button",{type:"button",disabled:!0,title:"Your approval stands",className:"inline-flex cursor-default items-center gap-1 rounded border border-green-500/40 px-2 py-0.5 text-sm font-medium text-green-700/70 dark:border-green-700/50 dark:text-green-400/70",children:[t.jsx(pr,{})," Approved"]}):t.jsxs(t.Fragment,{children:[h==="changes_requested"&&t.jsxs("span",{className:"inline-flex items-center gap-1 rounded bg-amber-500/10 px-2 py-0.5 text-sm font-medium text-amber-700 dark:text-amber-400",children:[t.jsx(Jt,{})," Changes requested"]}),t.jsxs("button",{type:"button",onClick:()=>k(void 0),disabled:g,className:l0,children:[t.jsx(pr,{})," ",u.isPending?"Approving…":"Approve"]}),t.jsxs("button",{type:"button",onClick:()=>w("approve-comment"),disabled:g,className:l0,children:[t.jsx(Qo,{})," Approve with comment"]})]}),t.jsxs("button",{type:"button",onClick:()=>w("request-changes"),disabled:g,className:i1,children:[t.jsx(Jt,{})," Request changes"]}),N]})}function QD({prId:e}){const[n,r]=f.useState(!1),s=rE(e),a=s.error instanceof cn?s.error.message:s.error?"Failed to close the PR.":null;return n?t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Close without merging?"}),t.jsx("button",{type:"button",onClick:()=>s.mutate(void 0,{onSuccess:()=>r(!1)}),disabled:s.isPending,className:"whitespace-nowrap rounded border border-red-400 px-2 py-0.5 text-sm font-medium text-red-600 hover:bg-red-50 disabled:opacity-50 dark:border-red-600 dark:text-red-400 dark:hover:bg-red-900/30",children:s.isPending?"Closing…":"Close PR"}),t.jsx("button",{type:"button",onClick:()=>{r(!1),s.reset()},disabled:s.isPending,className:"whitespace-nowrap rounded border border-gray-300 px-2 py-0.5 text-sm hover:border-gray-400 disabled:opacity-50 dark:border-gray-700 dark:hover:border-gray-500",children:"Cancel"}),a&&t.jsx("span",{className:"text-xs text-red-500",children:a})]}):t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsxs("button",{type:"button",onClick:()=>r(!0),className:"inline-flex items-center gap-1 rounded border border-gray-400 px-2 py-0.5 text-sm font-medium text-gray-600 hover:bg-gray-100 dark:border-gray-600 dark:text-gray-300 dark:hover:bg-gray-800",title:"Close this PR without merging (reversible on GitHub)",children:[t.jsx(Zt,{})," Close"]}),a&&t.jsx("span",{className:"text-xs text-red-500",children:a})]})}function YD({prId:e}){const n=sE(e),r=n.error instanceof cn?n.error.message:n.error?"Couldn’t reopen the PR.":null;return t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsxs("button",{type:"button",onClick:()=>n.mutate(),disabled:n.isPending,className:"inline-flex items-center gap-1 rounded border border-gray-400 px-2 py-0.5 text-sm font-medium text-gray-600 hover:bg-gray-100 disabled:opacity-50 dark:border-gray-600 dark:text-gray-300 dark:hover:bg-gray-800",title:"Reopen this PR on GitHub",children:[t.jsx(X4,{})," ",n.isPending?"Reopening…":"Reopen"]}),r&&t.jsx("span",{className:"text-xs text-red-500",children:r})]})}function XD(e){const n=He();return tt({mutationFn:async({runIds:r,mode:s})=>{const a=await Promise.allSettled(r.map(d=>he.rerunCi(e,{runId:d,mode:s}))),i=a.filter(d=>d.status==="fulfilled").length,c=a.length-i;if(i===0){const d=a.find(u=>u.status==="rejected");throw(d==null?void 0:d.reason)instanceof Error?d.reason:new Error("Re-run failed")}return{mode:s,queued:i,failed:c}},onSuccess:()=>void dn(n,e)})}const ZD=128*1024;function JD(e,n,r){return rc({queryKey:["check-logs",e,n],initialPageParam:null,queryFn:({pageParam:s})=>he.checkLogs(e,n,s??void 0),getNextPageParam:s=>{if(!s.available||!s.hasMore)return null;const a=s.startByte??0;return a<=0?null:{startByte:Math.max(0,a-ZD),endByte:a}},enabled:r&&n!=null,staleTime:1/0,gcTime:5*6e4})}function e6(e){if(!e||e.length===0)return null;const n=e[0];if(!n.available)return{available:!1,reason:n.reason,text:"",startByte:null,endByte:null,totalBytes:null,loadedBytes:null,lines:0,partial:!1};const r=e[e.length-1],s=[...e].reverse().map(u=>u.text).filter(u=>u.length>0).join(`
58
+ `),a=r.startByte,i=n.endByte,c=n.totalBytes,d=a!=null&&i!=null?Math.max(0,i-a):null;return{available:!0,text:s,startByte:a,endByte:i,totalBytes:c,loadedBytes:d,lines:s===""?0:s.split(`
59
+ `).length,partial:(a??0)>0||c!=null&&i!=null&&i<c}}function l1(e){return e<1024?`${e} B`:e<1024*1024?`${Math.round(e/1024)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}const t6=/\/actions\/runs\/\d+\/job\/(\d+)/,n6=/\/actions\/runs\/(\d+)/;function r6(e){if(e.jobId!=null)return e.jobId;const n=e.url?t6.exec(e.url):null;return n?Number(n[1]):null}function s6(e){if(e.runId!=null)return e.runId;const n=e.url?n6.exec(e.url):null;return n?Number(n[1]):null}function a6(e,n){const r=mn(e.url);return r?{href:r,own:!0}:{href:`${n}/checks`,own:!1}}function o6({prId:e,prGithubUrl:n,check:r}){var C,L;const s=Nx[r.state],a=a6(r,n),i=r6(r),c=i!=null,[d,u]=f.useState(!1),m=JD(e,i,d&&c),h=e6((C=m.data)==null?void 0:C.pages),g=f.useRef(null),x=f.useRef(null),y=f.useRef(!1),b=((L=m.data)==null?void 0:L.pages.length)??0,w=(h==null?void 0:h.text)??"";f.useLayoutEffect(()=>{const F=g.current;if(!F||!d)return;const M=x.current;if(M){x.current=null,F.scrollTop=F.scrollHeight-M.height+M.top;return}!y.current&&w&&(y.current=!0,F.scrollTop=F.scrollHeight)},[d,b,w]);const k=m.hasNextPage&&!m.isFetchingNextPage,j=m.fetchNextPage,N=f.useCallback(()=>{const F=g.current;F&&(x.current={height:F.scrollHeight,top:F.scrollTop}),j()},[j]),I=f.useCallback(()=>{const F=g.current;!F||!k||F.scrollTop<=80&&N()},[k,N]),S=()=>{u(F=>(F&&(y.current=!1),!F))},T=t.jsx("span",{className:"inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-full text-[10px] font-bold text-white",style:{backgroundColor:s.color},title:s.label,children:t.jsx(s.icon,{size:10})}),$=a.own?r.name:`${r.name} — this check reports no link of its own; opens the PR's Checks tab on GitHub`,P=t.jsxs("a",{href:a.href,target:"_blank",rel:"noreferrer noopener",onClick:F=>F.stopPropagation(),className:"text-blue-500 hover:underline",title:$,children:["Open on GitHub ",t.jsx(_t,{size:11,className:"inline-block align-[-0.1em]"})]});return c?t.jsxs("li",{className:"text-xs",children:[t.jsxs("div",{className:"flex items-center gap-2 rounded px-1 py-0.5 hover:bg-gray-100 dark:hover:bg-gray-800",children:[T,t.jsx("a",{href:a.href,target:"_blank",rel:"noreferrer noopener",onClick:F=>F.stopPropagation(),title:$,className:"min-w-0 truncate hover:underline",children:r.name}),t.jsxs("button",{type:"button",onClick:S,"aria-expanded":d,title:d?"Hide the job log":"Show the job log",className:"flex flex-1 items-center justify-end gap-1.5 text-gray-400",children:[t.jsx("span",{className:"text-xs",children:s.label}),t.jsxs("span",{className:"inline-flex items-center gap-0.5 text-[10px] font-medium text-blue-500",children:[t.jsx(Mt,{dir:d?"down":"right",size:10}),d?"hide logs":"logs"]})]})]}),d&&t.jsx("div",{className:"mb-1 mt-1",children:m.isLoading?t.jsx("div",{className:"px-1 py-2 text-gray-400",children:"Loading logs…"}):h!=null&&h.available?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"mb-1 flex items-center justify-between gap-2 px-1 text-[10px] text-gray-400",children:[t.jsx("span",{children:h.partial&&h.loadedBytes!=null?`${h.lines} lines · ${l1(h.loadedBytes)}${h.totalBytes!=null?` of ${l1(h.totalBytes)}`:""}`:`${h.lines} line${h.lines===1?"":"s"}`}),t.jsxs("span",{className:"flex items-center gap-2",children:[(m.hasNextPage||m.isFetchingNextPage)&&t.jsx("button",{type:"button",className:"rounded border border-gray-300 px-1.5 py-0.5 text-[10px] hover:border-gray-400 disabled:opacity-50 dark:border-gray-700 dark:hover:border-gray-500",disabled:!k,onClick:N,title:"Load the previous chunk of this log (or just scroll up)",children:m.isFetchingNextPage?"Loading earlier…":t.jsxs(t.Fragment,{children:[t.jsx(_s,{dir:"up",size:10,className:"inline-block align-[-0.1em]"})," ","Load earlier"]})}),P]})]}),t.jsx("pre",{ref:g,onScroll:I,className:"max-h-[40rem] overflow-auto whitespace-pre rounded bg-gray-900 p-2 font-mono text-[11px] leading-[1.45] text-gray-100",children:h.text||"(empty log)"})]}):t.jsxs("div",{className:"px-1 py-2 text-gray-400",children:[(h==null?void 0:h.reason)??"Couldn't load logs."," ",P]})})]}):t.jsx("li",{className:"text-xs",children:t.jsxs("a",{href:a.href,target:"_blank",rel:"noreferrer noopener",title:$,className:"flex items-center gap-2 rounded px-1 py-0.5 hover:bg-gray-100 dark:hover:bg-gray-800",children:[T,t.jsx("span",{className:"min-w-0 truncate",children:r.name}),t.jsx("span",{className:"ml-auto shrink-0 text-xs text-gray-400",children:s.label})]})})}function i6({prId:e,prGithubUrl:n,checks:r}){return t.jsx("ul",{className:"space-y-1",children:r.map((s,a)=>t.jsx(o6,{prId:e,prGithubUrl:n,check:s},`${s.name}-${a}`))})}function c1(e,n){const r=new Set;for(const s of e){if(n&&s.state!=="failure"&&s.state!=="error")continue;const a=s6(s);a!=null&&r.add(a)}return[...r]}function l6({prId:e,checks:n,viewerCanPush:r}){const s=XD(e),[a,i]=f.useState(null),c=c1(n,!1),d=c1(n,!0);if(!r||c.length===0)return null;const u=(m,h)=>{h.length!==0&&(i(null),s.mutate({runIds:h,mode:m},{onSuccess:g=>i(g)}))};return t.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:[t.jsx("button",{type:"button",className:"whitespace-nowrap rounded border border-blue-400 px-2.5 py-1 text-xs text-blue-600 hover:bg-blue-50 disabled:opacity-50 dark:border-blue-600 dark:text-blue-400 dark:hover:bg-blue-900/30",disabled:s.isPending||d.length===0,onClick:()=>u("failed",d),title:"Re-run only the failed jobs of the failing workflow run(s)",children:s.isPending?"Requesting…":"Re-run failed jobs"}),t.jsx("button",{type:"button",className:"whitespace-nowrap rounded border border-gray-300 px-2.5 py-1 text-xs hover:border-gray-400 disabled:opacity-50 dark:border-gray-700 dark:hover:border-gray-500",disabled:s.isPending,onClick:()=>u("all",c),title:"Re-run the entire workflow run(s) from scratch",children:"Re-run all jobs"}),a&&!s.isPending&&t.jsxs("span",{className:"text-[11px] text-gray-500 dark:text-gray-400",children:["Re-run requested — CI updates on the next sync.",a.failed>0&&` (${a.failed} run${a.failed===1?"":"s"} couldn't be re-run.)`]}),s.isError&&t.jsx("span",{className:"text-[11px] text-red-500",children:s.error instanceof Error?s.error.message:"Re-run failed"})]})}function wr({label:e,children:n}){return t.jsxs("div",{className:"flex gap-3 px-4 py-1.5 text-sm",children:[t.jsx("span",{className:"w-28 shrink-0 text-xs uppercase tracking-wide text-gray-400",children:e}),t.jsx("div",{className:"min-w-0 flex-1",children:n})]})}function c6({headRefName:e,baseRefName:n}){return t.jsxs("div",{className:"flex items-start gap-1.5",children:[t.jsxs("span",{className:"min-w-0 break-all","data-testid":"pr-branch",children:[t.jsx("span",{className:"font-mono text-xs text-gray-900 dark:text-gray-100",children:e}),n!=null&&t.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:[" → ",n]})]}),t.jsx(Bi,{text:e,what:"branch name"})]})}function d6({kind:e,provenance:n}){const r=ds(e),s=e==="pierre"&&n?n==="ai_verbatim"?" · verbatim":" · curated":"";return t.jsxs("span",{"data-testid":"reviewer-provenance",className:"inline-flex items-center gap-0.5 rounded px-1 py-0.5 text-[10px] font-medium",style:{...pn(r.color),background:`${r.color}1a`},title:`Automated reviewer — ${r.label}${s}`,children:[t.jsx(Lt,{size:10}),r.label,s]})}const Il=new Map;function u6(e,n){if(Il.delete(e),Il.set(e,n),Il.size>50){const r=Il.keys().next().value;r!==void 0&&Il.delete(r)}}function h6({pr:e,suggestions:n,usersById:r}){var w;const s=YS(e.id),[a,i]=f.useState(new Set),[c,d]=f.useState(null),u=k=>k.kind==="team"?`team:${k.teamSlug}`:`user:${k.login}`,m=new Set(e.requestedReviewers.flatMap(k=>k.userId!=null?[k.userId]:[])),h=new Set(e.requestedReviewers.flatMap(k=>k.teamName!=null?[k.teamName.toLowerCase()]:[])),g=e.repoFullName.split("/")[0]??"",x=k=>{var j;return k.kind==="team"?[k.teamSlug,(j=k.teamName)==null?void 0:j.replace(/^@/,""),k.teamSlug&&`${g}/${k.teamSlug}`].some(N=>N!=null&&N!==""&&h.has(N.toLowerCase())):k.userId!=null&&m.has(k.userId)},y=n.filter(k=>!x(k));if(y.length===0)return null;const b=k=>{const j=k.kind==="team"?{teamSlugs:k.teamSlug?[k.teamSlug]:[]}:k.userId!=null?{userIds:[k.userId]}:{logins:k.login?[k.login]:[]},N=u(k);d(N),s.mutate(j,{onSuccess:()=>i(I=>new Set(I).add(N)),onSettled:()=>d(null)})};return t.jsxs(wr,{label:"Suggested",children:[t.jsx("div",{className:"flex flex-col gap-1.5 text-xs",children:y.map(k=>{const j=u(k),N=a.has(j),I=k.userId!=null?r.get(k.userId):void 0;return t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[t.jsx("span",{className:"inline-flex items-center gap-1 rounded bg-gray-500/10 px-1.5 py-0.5",children:k.kind==="team"?t.jsxs("span",{className:"font-medium",children:["@",k.teamName]}):I?t.jsxs(t.Fragment,{children:[t.jsx(gn,{user:I,size:14}),t.jsx(mr,{user:I,fallbackId:k.userId,repoId:e.repoId})]}):t.jsxs("span",{children:["@",k.login]})}),t.jsx("span",{className:"text-gray-400",children:k.reason}),e.viewerCanPush&&t.jsx("button",{type:"button",onClick:()=>b(k),disabled:c!==null||N,className:"rounded border border-violet-300 px-1.5 py-0.5 font-medium text-violet-700 hover:bg-violet-50 disabled:opacity-50 dark:border-violet-700 dark:text-violet-300 dark:hover:bg-violet-900/20",title:"Request this reviewer on GitHub",children:N?t.jsxs(t.Fragment,{children:[t.jsx(pr,{size:11,className:"inline-block align-[-0.1em]"})," Requested"]}):c===j?"Assigning…":"Assign"})]},j)})}),s.isError&&t.jsx("div",{className:"mt-1 text-[11px] text-red-500",children:((w=s.error)==null?void 0:w.message)??"Couldn’t request the reviewer."})]})}function p6({body:e}){const[n,r]=f.useState(!1),[s,a]=f.useState(!1),[i,c]=f.useState(!1),d=f.useRef(null);return f.useEffect(()=>{const u=d.current;if(!u)return;const m=160,h=384,g=()=>{const k=u.clientWidth,j=Array.from(u.querySelectorAll("img"));let N=!1,I=k>0;for(const S of j){if(!(S.naturalWidth>0&&S.naturalHeight>0)){S.complete||(I=!1);continue}const $=Number(S.getAttribute("width")),P=Number.isFinite($)&&$>0?Math.min(S.naturalWidth,$):S.naturalWidth,C=k?Math.min(P,k):P,L=Math.min(S.naturalHeight*C/S.naturalWidth,h),F=k>0&&L>m;S.classList.toggle("pr-summary-tall-img",F),F&&(N=!0)}return c(N),I},x=new MutationObserver(()=>g());x.observe(u,{childList:!0,subtree:!0});let y=0,b=0;const w=()=>{!g()&&y++<240&&(b=requestAnimationFrame(w))};return w(),()=>{x.disconnect(),cancelAnimationFrame(b)}},[e]),f.useLayoutEffect(()=>{if(n)return;const u=d.current;u&&a(u.scrollHeight-u.clientHeight>1)},[e,n]),f.useEffect(()=>{if(n)return;const u=d.current;if(!u)return;const m=new ResizeObserver(()=>{a(u.scrollHeight-u.clientHeight>1)});return m.observe(u),()=>m.disconnect()},[e,n]),t.jsxs("div",{children:[t.jsx("div",{className:"px-4 pb-1 pt-2 text-xs font-semibold uppercase tracking-wide text-gray-400",children:"Summary"}),t.jsxs("div",{className:"px-4 pb-3 text-sm",children:[t.jsx("div",{ref:d,className:`overflow-hidden${n?"":" pr-summary-collapsed"}`,style:n?void 0:{display:"-webkit-box",WebkitLineClamp:3,WebkitBoxOrient:"vertical"},children:t.jsx(gr,{children:e})}),(s||i||n)&&t.jsx("button",{type:"button",onClick:()=>r(u=>!u),className:"mt-1 text-xs font-medium text-blue-500 hover:underline",children:n?"Show less":"Show more"})]})]})}function m6({pr:e,usersById:n,onShowBotActivity:r,onOpenThreads:s,statusFocus:a,onStatusFocusConsumed:i}){var B,O;const c=f.useRef(null);f.useEffect(()=>{if(a==null)return;const E=c.current;E==null||E.scrollIntoView({block:"nearest"}),E==null||E.focus({preventScroll:!0}),i==null||i()},[a]);const{data:d}=gP(e.id),u=XS(["pr",e.id]),{data:m}=pC(e.id,r!=null),h=((m==null?void 0:m.bots)??[]).filter(E=>E.ttfrAnomaly!=null),g=Di(e.id),x=JS(e.id),y=d!=null&&d.suggestedReviewers.length>0?d:void 0;y&&u6(e.id,y);const b=y??(e.state==="open"&&!e.isDraft?Il.get(e.id):void 0),w=(b==null?void 0:b.suggestedReviewers)??[],k=(((B=b==null?void 0:b.users)==null?void 0:B.length)??0)>0?new Map([...n,...b.users.map(E=>[E.id,E])]):n,j=Rr[e.ciStatus],N=e.threads.filter(E=>!E.isResolved).length,I=e.threads.filter(E=>!E.isResolved&&E.derivedState==="likely_addressed").length,S={reviewDecision:e.reviewDecision,ciStatus:e.ciStatus,unresolvedThreads:N,likelyAddressedThreads:I,requestedReviewers:e.requestedReviewers.length},T=Pi({mergeable:e.mergeable,mergeStateStatus:e.mergeStateStatus,isDraft:e.isDraft,inMergeQueue:e.inMergeQueue===!0,blockFacts:S}),$=e.state==="open",P=$?T.blockers??[]:[],C=$?g2(e):null,L=e.checkRuns,F=L.reduce((E,ee)=>(E[ee.state]=(E[ee.state]??0)+1,E),{}),M=e.reviewStandings.map(E=>E.userId),D=e.reviewerCount-e.reviewStandings.length,A=new Map,W=new Set;for(const E of e.reviews)E.authorId==null||E.state==="pending"||(E.automatedKind!=null?A.set(E.authorId,{kind:E.automatedKind,provenance:E.provenance??null}):W.add(E.authorId));const z=M.length>0&&M.every(E=>A.has(E)&&!W.has(E)),te=G(E=>E.setThreadBotFilter),H=(()=>{var ee;const E=new Map;for(const K of e.threads){const U=K.originalCommenterId??((ee=K.comments[0])==null?void 0:ee.authorId)??null;if(U==null)continue;const Q=wS(n.get(U));if(!Q)continue;const J=E.get(Q.kind)??{threads:0,unresolved:0};J.threads+=1,(K.derivedState==="untouched"||K.derivedState==="replied_unresolved")&&(J.unresolved+=1),E.set(Q.kind,J)}return[...E.entries()].map(([K,U])=>({kind:K,...Qs[K],...U})).sort((K,U)=>U.threads-K.threads)})();return t.jsxs(t.Fragment,{children:[((O=e.authNotice)==null?void 0:O.kind)==="saml_sso"&&t.jsxs("div",{className:"mx-4 mt-2 rounded-md border border-amber-400/50 bg-amber-400/10 px-3 py-2 text-xs leading-relaxed text-amber-800 dark:text-amber-200",children:[t.jsxs("strong",{className:"font-semibold",children:["Some data from ",e.authNotice.org," is hidden."]})," ","Your GitHub sign-in isn’t authorized for ",e.authNotice.org,"’s SAML SSO, so the description, CI jobs and comment bodies couldn’t be loaded. Fix:"," ",t.jsxs("a",{className:"underline underline-offset-2",href:`https://github.com/orgs/${e.authNotice.org}/sso`,target:"_blank",rel:"noreferrer",children:["start an SSO session for ",e.authNotice.org]}),", then revoke the app at"," ",t.jsx("a",{className:"underline underline-offset-2",href:"https://github.com/settings/applications",target:"_blank",rel:"noreferrer",children:"Authorized OAuth Apps"})," ","and sign in again. (If GitHub only offers “Request”, an org owner must approve the app.)"]}),t.jsxs("div",{className:"divide-y divide-gray-100 py-1 dark:divide-gray-800",children:[t.jsx("div",{ref:c,tabIndex:-1,className:"outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-sky-500",children:t.jsx(wr,{label:"Status",children:t.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[j?t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx("span",{className:"inline-block h-2.5 w-2.5 rounded-full",style:{backgroundColor:j.color}}),t.jsxs("a",{href:`${e.githubUrl}/checks`,target:"_blank",rel:"noreferrer noopener",title:"Open this pull request's Checks tab on GitHub",className:"inline-flex items-center gap-1 hover:underline",children:[j.label,t.jsx(_t,{size:11,className:"inline-block align-[-0.1em] text-gray-400"})]}),L.length>0&&t.jsxs("span",{className:"text-xs text-gray-400",children:["·"," ",[F.success?`${F.success} passed`:null,F.failure?`${F.failure} failed`:null,F.pending?`${F.pending} running`:null].filter(Boolean).join(" · ")]})]}):t.jsx("span",{className:"text-gray-400",children:"no checks"}),$&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"decorative-mark text-gray-300 dark:text-gray-600","aria-hidden":!0,children:"|"}),C!=null?t.jsxs(t.Fragment,{children:[t.jsxs("span",{className:`font-medium ${C.tone==="bad"?"text-red-700 dark:text-red-300":"text-gray-700 dark:text-gray-200"}`,title:C.title,children:[C.tone==="bad"?t.jsx(Jt,{size:12,className:"mr-1 inline-block align-[-0.1em]"}):t.jsx(bp,{size:12,className:"mr-1 inline-block align-[-0.1em]"}),C.label]}),C.tone==="bad"&&t.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:["· ",C.title]})]}):t.jsxs(t.Fragment,{children:[t.jsxs("span",{className:`font-medium ${Sx[T.tone]}`,title:T.detail??void 0,children:[(T.tone==="bad"||T.tone==="warn")&&t.jsx(Jt,{size:12,className:"mr-1 inline-block align-[-0.1em]"}),T.label]}),T.detail&&T.verdict!=="conflicts"&&t.jsxs("span",{className:"text-xs text-gray-400",children:["· ",T.detail]})]})]})]})})}),RS(e.state,T.verdict)&&t.jsx(wr,{label:"Conflicts",children:t.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs font-medium leading-relaxed text-gray-700 dark:text-gray-200",children:[t.jsx(Zx,{state:e.state,verdict:T.verdict,viewerCanPush:e.viewerCanPush,target:{prId:e.id,repoId:e.repoId,repoFullName:e.repoFullName,prNumber:e.number,prTitle:e.title,githubUrl:e.githubUrl}}),t.jsxs("a",{href:e.githubUrl,target:"_blank",rel:"noreferrer noopener",className:"underline underline-offset-2",title:"Open this pull request on GitHub",children:["Resolve on GitHub",t.jsx(_t,{size:11,className:"ml-0.5 inline-block align-[-0.1em]"})]})]})}),x!=null&&e.state==="open"&&t.jsx(wr,{label:"Auto-merge",children:t.jsxs("div",{className:"text-xs leading-relaxed",children:[t.jsxs("span",{className:"font-medium text-gray-700 dark:text-gray-200",children:[t.jsx(Jt,{size:12,className:"mr-1 inline-block align-[-0.1em]"}),qp[x.state]??"Auto-merge stopped"]}),x.lastReason&&t.jsxs("span",{className:"ml-1 text-gray-500 dark:text-gray-400",children:["— ",x.lastReason]}),t.jsxs("span",{className:"ml-1 text-gray-400",children:["· armed ",Nt(x.armedAt)]})]})}),P.length>0&&t.jsx(wr,{label:"Blocked",children:t.jsx("ul",{className:"space-y-1",children:P.map(E=>{const ee=E.kind==="unresolved_threads"&&s!=null;return t.jsx("li",{className:"text-xs leading-relaxed",children:ee?t.jsx("button",{type:"button",onClick:s,className:"font-medium text-gray-700 first-letter:uppercase hover:underline dark:text-gray-200",children:E.text}):t.jsx("span",{className:"font-medium text-gray-700 first-letter:uppercase dark:text-gray-200",children:E.text})},E.kind)})})}),(e.reviewStandings.length>0||D>0)&&t.jsx(wr,{label:"Reviews",children:t.jsxs("div",{className:"flex flex-wrap gap-2 text-xs",children:[e.reviewStandings.map(E=>{const ee=n.get(E.userId),K=$h[E.standing],U=A.get(E.userId);return t.jsxs("span",{className:`inline-flex items-center gap-1 rounded px-1.5 py-0.5 ${K.cls}`,title:`${K.title} · ${Cn(E.standingAt)}`,children:[K.icon&&t.jsx(K.icon,{size:12}),t.jsx(gn,{user:ee,size:14}),t.jsx(mr,{user:ee,fallbackId:E.userId,repoId:e.repoId}),U&&t.jsx(d6,{kind:U.kind,provenance:U.provenance})]},E.userId)}),D>0&&t.jsx("span",{className:"inline-flex items-center rounded bg-gray-500/10 px-1.5 py-0.5 text-gray-500 dark:text-gray-400",title:"GitHub no longer has an account for these reviews, so they cannot be named here.",children:D===1?"1 review from a deleted account":`${D} reviews from deleted accounts`}),z&&t.jsxs("span",{"data-testid":"only-bots-reviewed",className:"inline-flex items-center gap-1 rounded bg-amber-400/10 px-1.5 py-0.5 font-medium text-amber-700 dark:text-amber-300",title:"Every review on this PR came from an automated reviewer — no human has reviewed it yet.",children:[t.jsx(Lt,{size:12}),"only bots reviewed"]})]})}),H.length>0&&t.jsx(wr,{label:"Bots",children:t.jsx("div",{className:"flex flex-wrap gap-2 text-xs",children:H.map(E=>t.jsxs("button",{type:"button",onClick:()=>te(E.kind),className:"inline-flex items-center gap-1 rounded px-1.5 py-0.5 font-medium transition-opacity hover:opacity-80",style:{color:E.color,background:`${E.color}1a`},title:`${E.label} opened ${E.threads} review thread${E.threads===1?"":"s"} on this PR${E.unresolved>0?` · ${E.unresolved} still need a look (no reply and no follow-up commit, or replied but still open). Threads that LOOK addressed are excluded here — the Blocked row counts those, because GitHub still wants the resolve click`:" · all acted on"} — click to filter the Threads tab`,children:[t.jsx(Lt,{size:12}),E.label,t.jsxs("span",{className:"tabular-nums opacity-70",children:["· ",E.threads]}),E.unresolved>0&&t.jsxs("span",{className:"tabular-nums font-semibold",children:["· ",E.unresolved," need a look"]})]},E.kind))})}),h.length>0&&r&&t.jsx(wr,{label:"Bot activity",children:t.jsxs("button",{type:"button",onClick:r,className:"inline-flex items-center gap-1 rounded bg-red-500/10 px-1.5 py-0.5 text-xs font-medium text-red-600 transition-opacity hover:opacity-80 dark:text-red-400",title:h.map(E=>`${E.label}: slower than its typical on this PR`).join(" · "),children:[t.jsx(Jt,{size:12}),h.length===1?`${h[0].label} slower than typical`:`${h.length} bots slower than typical`,t.jsx("span",{className:"opacity-70",children:"— view"})]})}),(e.viewerCanApprove||e.viewerCanPush&&e.state==="open"&&!e.isDraft||e.viewerCanClose&&e.state==="open"&&g==null||e.viewerCanReopen&&e.state==="closed")&&t.jsx(wr,{label:"Actions",children:t.jsxs("div",{className:"flex flex-wrap items-start gap-x-3 gap-y-2",children:[e.viewerCanApprove&&t.jsx(VD,{prId:e.id,standing:e.viewerReviewStanding}),e.viewerCanPush&&e.state==="open"&&!e.isDraft&&t.jsxs(t.Fragment,{children:[t.jsx(x2,{prId:e.id,githubUrl:e.githubUrl,blockFacts:S,inMergeQueue:e.inMergeQueue,mergeQueueEntryState:e.mergeQueueEntryState,syncedAt:u,resolverTarget:{prId:e.id,repoId:e.repoId,repoFullName:e.repoFullName,prNumber:e.number,prTitle:e.title,githubUrl:e.githubUrl}}),t.jsx(Jx,{prId:e.id,blockFacts:S,inMergeQueue:e.inMergeQueue,mergeQueueEntryState:e.mergeQueueEntryState,syncedAt:u})]}),e.viewerCanClose&&e.state==="open"&&g==null&&t.jsx(QD,{prId:e.id}),e.viewerCanReopen&&e.state==="closed"&&t.jsx(YD,{prId:e.id})]})}),e.mergedById!=null&&t.jsx(wr,{label:"Merged by",children:t.jsxs("div",{className:"text-xs",children:[t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx(gn,{user:n.get(e.mergedById),size:14}),t.jsx(mr,{user:n.get(e.mergedById),fallbackId:e.mergedById,repoId:e.repoId})]}),e.mergedAt!=null&&t.jsx("div",{className:"mt-0.5 text-gray-400",title:Cn(e.mergedAt),children:Cn(e.mergedAt)})]})}),e.headRefName!=null&&t.jsx(wr,{label:"Branch",children:t.jsx(c6,{headRefName:e.headRefName,baseRefName:e.baseRefName})}),e.tickets!=null&&t.jsx(wr,{label:"Ticket",children:e.tickets.length===0?t.jsx("span",{className:"text-xs text-gray-400",children:"No ticket found"}):t.jsx("div",{className:"flex flex-wrap gap-1.5",children:e.tickets.map(E=>t.jsx("a",{href:mn(E.url),target:"_blank",rel:"noreferrer noopener",className:"inline-flex items-center rounded border border-sky-200 bg-sky-50 px-1.5 py-0.5 text-xs font-medium text-sky-700 hover:bg-sky-100 dark:border-sky-900 dark:bg-sky-950 dark:text-sky-300",title:`Open ${E.key} in ${E.provider==="jira"?"Jira":"Linear"}`,children:E.key},E.key))})}),e.body!=null&&e.body.trim()!==""&&t.jsx(p6,{body:e.body}),t.jsx(O5,{pr:e}),L.length>0&&t.jsxs(wr,{label:"Checks",children:[t.jsx(i6,{prId:e.id,prGithubUrl:e.githubUrl,checks:L}),t.jsx(l6,{prId:e.id,checks:L,viewerCanPush:e.viewerCanPush})]}),e.labels.length>0&&t.jsx(wr,{label:"Labels",children:t.jsx("div",{className:"flex flex-wrap gap-1",children:e.labels.map(E=>t.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-xs",style:{borderColor:`#${E.color}`},children:[t.jsx("span",{className:"inline-block h-2 w-2 rounded-full",style:{backgroundColor:`#${E.color}`}}),E.name]},E.name))})}),e.requestedReviewers.length>0&&t.jsx(wr,{label:"Requested",children:t.jsx("div",{className:"flex flex-wrap gap-2 text-xs",children:e.requestedReviewers.map((E,ee)=>t.jsx("span",{className:"rounded bg-gray-500/10 px-1.5 py-0.5",children:E.teamName?`@${E.teamName}`:t.jsx(mr,{user:E.userId!=null?n.get(E.userId):void 0,fallbackId:E.userId,repoId:e.repoId})},ee))})}),w.length>0&&t.jsx(h6,{pr:e,suggestions:w,usersById:k}),t.jsx(wr,{label:"Meta",children:t.jsxs("div",{className:"space-y-0.5 text-xs text-gray-500 dark:text-gray-400",children:[t.jsx("div",{children:e.repoFullName}),t.jsxs("div",{children:["opened ",Nt(e.openedAt)]}),t.jsxs("div",{children:["updated ",Nt(e.updatedAt)]})]})})]})]})}function uy(e,n){const[r,s]=f.useState(()=>{try{const a=localStorage.getItem(e);return a!=null?JSON.parse(a):n}catch{return n}});return f.useEffect(()=>{try{localStorage.setItem(e,JSON.stringify(r))}catch{}},[e,r]),[r,s]}function g6(e,n,r,s){const a=Math.max(n,r),i=Number.isFinite(e)?e:s;return Math.min(Math.max(Math.round(i),n),a)}function f6(e){const{storageKey:n,defaultWidth:r,minWidth:s,maxWidth:a,label:i,keyStep:c=16}=e,[d,u]=uy(n,r),m=f.useRef(null),h=f.useRef(null),g=Math.max(s,a),x=f.useCallback(I=>g6(I,s,a,r),[s,a,r]),y=x(d),b=f.useCallback(I=>{m.current!=null&&(I.preventDefault(),h.current={startX:I.clientX,startW:m.current.offsetWidth},I.currentTarget.setPointerCapture(I.pointerId))},[]),w=f.useCallback(I=>{const S=h.current,T=m.current;S==null||T==null||(T.style.width=`${x(S.startW+(I.clientX-S.startX))}px`)},[x]),k=f.useCallback(I=>{const S=m.current;h.current==null||S==null||(h.current=null,I.currentTarget.releasePointerCapture(I.pointerId),u(x(S.offsetWidth)))},[x,u]),j=f.useCallback(I=>{const S=I.shiftKey?c*4:c;let T=null;I.key==="ArrowLeft"?T=y-S:I.key==="ArrowRight"?T=y+S:I.key==="Home"?T=s:I.key==="End"?T=g:(I.key==="Enter"||I.key===" ")&&(T=r),T!=null&&(I.preventDefault(),u(x(T)))},[y,c,s,g,r,x,u]),N=f.useCallback(()=>{u(x(r))},[x,r,u]);return{width:y,paneRef:m,separatorProps:{role:"separator","aria-orientation":"vertical","aria-label":i,"aria-valuenow":y,"aria-valuemin":s,"aria-valuemax":g,tabIndex:0,title:"Drag to resize — double-click to reset",onPointerDown:b,onPointerMove:w,onPointerUp:k,onKeyDown:j,onDoubleClick:N}}}const yC="pierre:diffWrap";function x6(){try{const e=localStorage.getItem(yC);return e==null?!0:e!=="false"}catch{return!0}}let dh=null;const Wf=new Set;function y6(){return dh==null&&(dh=x6()),dh}function b6(e){return Wf.add(e),()=>Wf.delete(e)}function v6(e){dh=e;try{localStorage.setItem(yC,String(e))}catch{}for(const n of Wf)n()}function bC(){return[f.useSyncExternalStore(b6,y6,()=>!0),v6]}const vC={added:{icon:"A",label:"added",cls:"text-green-600 dark:text-green-400"},removed:{icon:"D",label:"removed",cls:"text-red-500 dark:text-red-400"},modified:{icon:"M",label:"modified",cls:"text-amber-600 dark:text-amber-400"},renamed:{icon:"R",label:"renamed",cls:"text-sky-600 dark:text-sky-400"},copied:{icon:"C",label:"copied",cls:"text-sky-600 dark:text-sky-400"},changed:{icon:"M",label:"changed",cls:"text-amber-600 dark:text-amber-400"},unchanged:{icon:"·",label:"unchanged",cls:"text-gray-400"}},kC="border-sky-500",wC="border-transparent",k6=6e3,jC=4e3,w6=250,j6=400;function N6(e){return!!(Hx(e.path)||e.patch==null||qM(e.patch)>w6||e.additions+e.deletions>j6)}const S6={hunk:"bg-sky-500/5 text-sky-600 dark:text-sky-400 select-none",add:"bg-green-500/10",del:"bg-red-500/10",context:""};function d1(e){return e==null?"":String(e)}function C6({row:e,html:n,filePath:r,fileUrl:s,commenting:a,onPosted:i,open:c,onOpen:d,onClose:u,focused:m,focusNonce:h,wrap:g}){const x=a?z5(e):null,y=Ed(e).body||" ",b=f.useRef(null),[w,k]=f.useState(!1);return f.useEffect(()=>{var N;if(!m){k(!1);return}(N=b.current)==null||N.scrollIntoView({block:"center",behavior:"smooth"}),k(!0);const j=setTimeout(()=>k(!1),jC);return()=>clearTimeout(j)},[m,h]),t.jsxs(t.Fragment,{children:[t.jsxs("tr",{ref:b,className:`group transition-colors ${w?"bg-amber-300/40 dark:bg-amber-400/25":S6[e.kind]}`,children:[t.jsx("td",{className:"select-none border-r border-gray-200 px-1 text-right align-top text-gray-400 dark:border-gray-800",children:d1(e.oldLine)}),t.jsx("td",{className:"select-none border-r border-gray-200 px-1 text-right align-top text-gray-400 dark:border-gray-800",children:d1(e.newLine)}),t.jsx("td",{className:"select-none px-1 align-top",children:t.jsx("div",{className:"flex w-4 justify-center",children:a&&x&&!c&&t.jsx("button",{type:"button",onClick:d,title:"Comment on this line",className:"rounded bg-blue-500 px-1 text-[10px] font-bold leading-tight text-white opacity-0 transition-opacity hover:bg-blue-600 group-hover:opacity-100",children:"+"})})}),t.jsxs("td",{className:`px-2 align-top ${g?"whitespace-pre-wrap [overflow-wrap:anywhere]":"whitespace-pre"}`,children:[e.kind==="add"&&t.jsx("span",{className:"sr-only",children:"added "}),e.kind==="del"&&t.jsx("span",{className:"sr-only",children:"removed "}),n!=null?t.jsx("span",{className:"code-hl",dangerouslySetInnerHTML:{__html:n}}):y]})]}),c&&a&&x&&t.jsx("tr",{children:t.jsx("td",{colSpan:4,className:"px-2 py-1.5",children:t.jsx(SC,{wrap:g,children:t.jsx($6,{prId:a.prId,filePath:r,fileUrl:s,line:x.line,side:x.side,onPosted:i,onClose:u})})})})]})}function NC({thread:e,ctx:n,approximate:r=!1,fileChip:s=!1,focusNonce:a=null,consumedFocus:i}){var T;const c=f.useRef(null),d=n.focusThreadId!=null&&n.focusThreadId===e.id,u=n.openMemory,[m,h]=f.useState(()=>KM(e,u)),g=f.useCallback($=>{h($),u.set(e.id,$)},[u,e.id]),[x,y]=f.useState(!1);f.useEffect(()=>{var $,P;d&&(g(!0),($=c.current)==null||$.scrollIntoView({block:"center",behavior:"smooth"}),(P=n.onThreadShown)==null||P.call(n))},[d]),f.useEffect(()=>{var P;if(a==null){y(!1);return}if((i==null?void 0:i.current)===a)return;i!=null&&(i.current=a),g(!0),(P=c.current)==null||P.scrollIntoView({block:"center",behavior:"smooth"}),y(!0);const $=setTimeout(()=>y(!1),jC);return()=>clearTimeout($)},[a,i]);const b=Xt[e.derivedState],w=e.derivedState==="resolved",k=e.comments[0],j=Dt((k==null?void 0:k.authorId)!=null?n.usersById.get(k.authorId):void 0,(k==null?void 0:k.authorId)??null),N=e.comments.length-1,I=(T=((k==null?void 0:k.body)??"").split(`
60
+ `).find($=>$.trim()!==""))==null?void 0:T.slice(0,120),S=d||x;return t.jsxs("div",{className:`rounded font-sans ${S?"ring-2 ring-amber-400/70":""}`,children:[t.jsxs("button",{ref:c,type:"button",onClick:()=>g(!m),"aria-expanded":m,title:`${b.label} — ${b.description}`,style:{borderLeftColor:w?"transparent":b.color},className:`flex w-full items-center gap-1.5 rounded border border-l-2 border-gray-200 bg-white px-2 py-1 text-left text-[11px] hover:bg-gray-50 dark:border-gray-700 dark:bg-gray-900 dark:hover:bg-gray-800 ${w?"text-gray-400 opacity-70 dark:text-gray-500":"text-gray-600 dark:text-gray-300"}`,children:[w?t.jsx(pr,{size:11,className:"shrink-0 text-emerald-600 dark:text-emerald-400"}):t.jsx("span",{className:"inline-block h-2 w-2 shrink-0 rounded-full",style:{backgroundColor:b.color}}),s&&!(m&&e.isOutdated)&&t.jsxs("span",{className:"shrink-0 text-gray-400 dark:text-gray-500",children:[e.isOutdated?"outdated":"line not in this diff"," ·"]}),!m&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"shrink-0 font-medium",children:j}),t.jsxs("span",{className:"shrink-0 text-gray-400 dark:text-gray-500",children:["· ",Nt(e.createdAt)]})]}),r&&t.jsx("span",{className:"shrink-0 text-gray-400 dark:text-gray-500",title:"Reconstructed from the code it was written against — may be a few lines off",children:"~"}),!m&&N>0&&t.jsxs("span",{className:"shrink-0 text-gray-400 dark:text-gray-500",children:["· ",N," repl",N===1?"y":"ies"]}),!m&&I&&t.jsxs("span",{className:"min-w-0 flex-1 truncate text-gray-400 dark:text-gray-500",children:["· ",I]}),m&&t.jsx("span",{className:"min-w-0 flex-1 truncate text-gray-400 dark:text-gray-500",children:"Hide thread"}),t.jsx(Mt,{dir:m?"up":"down",size:11,className:"ml-auto shrink-0 text-gray-400"})]}),m&&t.jsx("div",{className:"mt-1",children:t.jsx(Li,{thread:e,usersById:n.usersById,prUrl:n.prUrl,selected:S,onOpenInThreads:n.onOpenThread!=null?()=>{var $;return($=n.onOpenThread)==null?void 0:$.call(n,e.id)}:void 0})})]})}function u1({thread:e,ctx:n,approximate:r,fileChip:s,focusNonce:a,consumedFocus:i,wrap:c}){return t.jsx("tr",{children:t.jsx("td",{colSpan:4,className:"bg-gray-50 px-2 py-1 dark:bg-gray-900/40",children:t.jsx(SC,{wrap:c,children:t.jsx(NC,{thread:e,ctx:n,approximate:r,fileChip:s,focusNonce:a,consumedFocus:i})})})})}function SC({wrap:e,children:n}){return e?t.jsx(t.Fragment,{children:n}):t.jsx("div",{className:"sticky left-2",style:{width:"calc(100cqw - 1rem)"},children:n})}function R6(e){let n=0;for(const s of e)s.oldLine!=null&&s.oldLine>n&&(n=s.oldLine),s.newLine!=null&&s.newLine>n&&(n=s.newLine);return`calc(${Math.max(4,String(n).length)}ch + 0.5rem + 1px)`}function I6({rows:e,wrap:n,children:r}){const s=R6(e),a=t.jsxs("table",{className:`border-collapse font-mono text-[12px] leading-[1.45] ${n?"w-full table-fixed":"w-max min-w-full"}`,children:[t.jsxs("colgroup",{children:[t.jsx("col",{style:{width:s}}),t.jsx("col",{style:{width:s}}),t.jsx("col",{style:{width:"1.5rem"}}),t.jsx("col",{})]}),t.jsx("tbody",{children:r})]});return n?a:t.jsx("div",{className:"overflow-x-auto",style:{containerType:"inline-size"},children:a})}function T6(){const[e,n]=bC();return t.jsxs("label",{className:"inline-flex cursor-pointer select-none items-center gap-1.5 text-[12px] text-gray-600 dark:text-gray-300",children:[t.jsx("input",{type:"checkbox",checked:e,onChange:r=>n(r.target.checked),className:"h-3.5 w-3.5 rounded border-gray-300 dark:border-gray-600"}),"Wrap lines"]})}function $6({prId:e,filePath:n,fileUrl:r,line:s,side:a,onPosted:i,onClose:c}){const[d,u]=f.useState(""),[m,h]=f.useState(null),[g,x]=f.useState(!1),y=oE(e),b=He(),w=y.error instanceof cn?y.error.message:y.error?"Failed to post the comment.":null,k=y.isPending||g,j=async I=>{if(I.commentId===null){h({text:"Couldn't place this comment in the diff — open it on GitHub instead.",url:r,posted:!1});return}if(u(""),I.visible){x(!0);try{await b.refetchQueries({queryKey:["pr",e],exact:!0},{cancelRefetch:!1})}finally{x(!1)}if(i==null||i(I.threadId),I.anchored===!1){h({text:`Posted on the nearest changed line (${I.side==="LEFT"?"old":"new"} line ${I.line}) — shown below.`,url:I.url,posted:!0});return}c();return}h({text:I.anchored===!1?`Posted on GitHub on the nearest changed line (${I.side==="LEFT"?"old":"new"} line ${I.line}). It couldn’t be loaded back just now — it’ll show up here shortly.`:"Posted on GitHub. It couldn’t be loaded back just now — it’ll show up here shortly.",url:I.url,posted:!0})},N=()=>{const I=d.trim();!I||k||(h(null),y.mutate({path:n,line:s,side:a,body:I},{onSuccess:S=>void j(S)}))};return t.jsxs("div",{className:"space-y-1 rounded border border-gray-300 bg-white p-2 font-sans dark:border-gray-700 dark:bg-gray-900",children:[t.jsxs("div",{className:"text-[10px] text-gray-400",children:["Commenting on ",a==="LEFT"?"old":"new"," line ",s]}),t.jsx(Ad,{prId:e,value:d,onChange:u,rows:3,autoFocus:!0,placeholder:"Add an inline review comment (markdown)…",className:"w-full rounded border border-gray-300 bg-white px-2 py-1.5 text-xs dark:border-gray-700 dark:bg-gray-950"}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("button",{type:"button",onClick:N,disabled:k||d.trim().length===0,className:"whitespace-nowrap rounded border border-blue-400 px-2 py-0.5 text-xs text-blue-600 hover:bg-blue-50 disabled:opacity-50 dark:border-blue-600 dark:text-blue-400 dark:hover:bg-blue-900/30",children:g?"Loading it…":y.isPending?"Posting…":"Send"}),t.jsx("button",{type:"button",onClick:()=>{u(""),h(null),y.reset(),c()},disabled:k,className:"whitespace-nowrap rounded border border-gray-300 px-2 py-0.5 text-xs hover:border-gray-400 disabled:opacity-50 dark:border-gray-700 dark:hover:border-gray-500",children:m!=null&&m.posted?"Close":"Cancel"}),w&&t.jsx("span",{className:"text-[10px] text-red-500",children:w})]}),m&&t.jsxs("div",{className:"text-[10px] text-amber-600 dark:text-amber-400",children:[m.text,m.url&&t.jsxs(t.Fragment,{children:[" ",t.jsxs("a",{href:mn(m.url),target:"_blank",rel:"noreferrer noopener",className:"text-blue-500 hover:underline",children:["Open on GitHub",t.jsx(_t,{size:10,className:"ml-0.5 inline-block align-[-0.1em]"})]})]})]})]})}function _6({status:e,onLoad:n,githubUrl:r}){const s=e==="too_large"?"This file is over 1 MB — too large to diff here.":e==="binary"?"Binary file — no text diff.":e==="missing"?"This file isn’t on GitHub at either commit.":e==="error"?"Couldn’t load the full diff.":"GitHub didn’t send this diff. It is too large, or a binary file.";return t.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-x-3 gap-y-1",children:[t.jsx("span",{children:s}),(e==="idle"||e==="loading")&&t.jsx("button",{type:"button",onClick:n,disabled:e==="loading",className:"rounded border border-blue-400 px-2 py-0.5 text-blue-600 hover:bg-blue-50 disabled:opacity-60 dark:border-blue-600 dark:text-blue-400 dark:hover:bg-blue-900/30",children:e==="loading"?"Loading full diff…":"Load full diff"}),r&&t.jsxs("a",{href:r,target:"_blank",rel:"noreferrer noopener",className:"text-blue-500 hover:underline",children:["View on GitHub",t.jsx(_t,{size:10,className:"ml-0.5 inline-block align-[-0.1em]"})]})]})}function P6({gap:e,place:n,remaining:r,expandable:s,status:a,onExpand:i,wrap:c}){const d=s&&a==="idle"?AM(n,r):[],u=a==="idle"?FM(r,e.context):[E6[a]??"",e.context].filter(m=>m!=="").join(" · ");return t.jsxs("tr",{className:"bg-sky-500/10",children:[t.jsx("td",{colSpan:2,className:"border-r border-gray-200 p-0 align-middle dark:border-gray-800",children:d.length>0&&t.jsx("div",{className:"flex flex-col",children:d.map(m=>{const h=LM(m,r);return t.jsx("button",{type:"button",onClick:()=>i(m),"aria-label":h,title:h,className:"flex h-5 w-full items-center justify-center text-gray-500 hover:bg-blue-500 hover:text-white focus-visible:bg-blue-500 focus-visible:text-white focus-visible:outline-none dark:text-gray-400 dark:hover:bg-blue-600 dark:focus-visible:bg-blue-600",children:m==="all"?t.jsx(U4,{size:16}):t.jsx(q4,{dir:m,size:16})},m)})})}),t.jsx("td",{colSpan:2,className:`px-2 py-0.5 align-middle text-gray-500 dark:text-gray-400 ${c?"whitespace-pre-wrap [overflow-wrap:anywhere]":"whitespace-pre"}`,children:u||" "})]})}const E6={loading:"Loading…",error:"Couldn’t load these lines.",too_large:"This file is too large to show here.",binary:"Binary file.",missing:"This file isn’t on GitHub at this commit.",moved:"This file has changed since the diff was loaded."};function h1({gap:e,lines:n,html:r,side:s,wrap:a}){const i=[];for(let c=0;c<e.count;c+=1){const d=e.oldFrom+c,u=e.newFrom+c,m=(s==="head"?u:d)-1,h=n[m]??"",g=(r==null?void 0:r[m])??null;i.push(t.jsxs("tr",{children:[t.jsx("td",{className:"select-none border-r border-gray-200 px-1 text-right align-top text-gray-400 dark:border-gray-800",children:d}),t.jsx("td",{className:"select-none border-r border-gray-200 px-1 text-right align-top text-gray-400 dark:border-gray-800",children:u}),t.jsx("td",{className:"select-none px-1 align-top"}),t.jsx("td",{className:`px-2 align-top ${a?"whitespace-pre-wrap [overflow-wrap:anywhere]":"whitespace-pre"}`,children:g!=null?t.jsx("span",{className:"code-hl",dangerouslySetInnerHTML:{__html:g}}):h||" "})]},c))}return t.jsx(t.Fragment,{children:i})}function p1({gap:e,place:n,reveal:r,lines:s,html:a,side:i,expandable:c,status:d,onExpand:u,wrap:m}){const h=e.count,g=s!=null?B5(h,r??Hh):Hh,x=W5(h,g),y={...e,count:h??0};return t.jsxs(t.Fragment,{children:[s!=null&&g.top>0&&t.jsx(h1,{gap:fw(y,0,g.top),lines:s,html:a,side:i,wrap:m}),x!==0&&t.jsx(P6,{gap:y,place:n,remaining:x,expandable:c,status:d,onExpand:b=>u(b,h),wrap:m}),s!=null&&h!=null&&g.bottom>0&&t.jsx(h1,{gap:fw(y,h-g.bottom,g.bottom),lines:s,html:a,side:i,wrap:m})]})}function A6({file:e,commenting:n,onPosted:r,threads:s,threadCtx:a,focus:i,wrap:c,fileSource:d}){var ae,we,$e,Fe;const[u,m]=f.useState(!1),h=bP((d==null?void 0:d.prId)??null,e.path,e.previousPath??null,(d==null?void 0:d.headSha)??null,u&&e.patch==null&&d!=null),g=e.patch??((ae=h.data)==null?void 0:ae.patch)??null,x=f.useMemo(()=>Bp(g),[g]),y=e.status==="removed"?"base":"head",b=y==="base"?e.previousPath??e.path:e.path,[w,k]=f.useState(!1),j=yP((d==null?void 0:d.prId)??null,b,y,(d==null?void 0:d.headSha)??null,w&&d!=null),[N,I]=f.useState(()=>new Map),S=((we=j.data)==null?void 0:we.lines)??null,T=f.useMemo(()=>S!=null?BM(x,S,y):!1,[S,x,y]),$=w?j.isLoading?"loading":j.isError?"error":(($e=j.data)==null?void 0:$e.refused)!=null?j.data.refused:S!=null&&!T?"moved":"idle":"idle",P=$==="idle"&&T?S:null,C=f.useMemo(()=>{if(x.length===0)return null;const oe=PM(x);if(P==null)return d==null||DM(x)?null:{count:null,oldFrom:oe.oldNext,newFrom:oe.newNext,context:""};const re=y==="head"?oe.newNext:oe.oldNext,X=P.length-(re-1);return X>0?{count:X,oldFrom:oe.oldNext,newFrom:oe.newNext,context:""}:null},[P,x,y,d]),L=(oe,re,X)=>{k(!0),I(le=>{const Ne=new Map(le);return Ne.set(oe,MM(le.get(oe)??Hh,re,X)),Ne})},F=f.useMemo(()=>P!=null&&N.size>0?Mi([...P],Yl(e.path),gw):null,[P,N.size,e.path]),{byRow:M,unanchored:D}=f.useMemo(()=>{const oe=new Map,re=[];for(const X of s){const le=HM(x,X);if(le==null)re.push(X);else{const Ne=oe.get(le.index)??[];Ne.push({thread:X,approximate:le.approximate}),oe.set(le.index,Ne)}}return{byRow:oe,unanchored:re}},[x,s]),A=s.filter(oe=>!oe.isResolved).length,W=(a==null?void 0:a.focusThreadId)!=null&&s.some(oe=>oe.id===a.focusThreadId),[z,te]=f.useState(()=>!Hx(e.path)&&(!N6(e)||A>0));f.useEffect(()=>{W&&te(!0)},[W]);const H=f.useMemo(()=>z?Ux(x,Yl(e.path),gw):null,[z,x,e.path]),B=f.useMemo(()=>i==null||i.line==null?null:H5(x,i.line,i.side??"RIGHT"),[x,i]),O=f.useRef(null);f.useEffect(()=>{var oe;i!=null&&(te(!0),GM(i,B,a!=null?s:[])&&((oe=O.current)==null||oe.scrollIntoView({block:"start",behavior:"smooth"})))},[i]);const[E,ee]=f.useState(null),K=f.useRef(null),U=vC[e.status],Q=e.previousPath?`${e.previousPath} → ${e.path}`:e.path,J=e.githubUrl??null,ne=a&&s.length>0?t.jsx("div",{className:"mt-2 space-y-1 text-left",children:s.map(oe=>t.jsx(NC,{thread:oe,ctx:a,fileChip:!0,focusNonce:i!=null&&i.threadId===oe.id?i.nonce:null,consumedFocus:K},oe.id))}):null;return t.jsxs("div",{ref:O,className:`border-l-2 ${i!=null?kC:wC}`,children:[t.jsxs("div",{className:"sticky top-0 z-10 flex items-center gap-2 border-b border-gray-100 bg-white px-3 py-1.5 text-xs hover:bg-gray-50 dark:border-gray-800 dark:bg-gray-950 dark:hover:bg-gray-900",children:[t.jsxs("button",{type:"button",onClick:()=>te(oe=>!oe),className:"flex min-w-0 flex-1 items-center gap-2 text-left",title:z?"Collapse this file":"Expand this file",children:[t.jsx("span",{className:"flex w-3 shrink-0 select-none items-center text-gray-400",children:t.jsx(Mt,{dir:z?"down":"right"})}),t.jsx("span",{className:`w-3 shrink-0 select-none text-center font-mono font-bold ${U.cls}`,title:U.label,children:U.icon}),t.jsx("code",{className:"min-w-0 flex-1 truncate font-mono",children:Q})]}),t.jsx(Bi,{text:e.path,what:"file path",title:"Copy file path"}),s.length>0&&t.jsx("span",{className:"shrink-0",children:t.jsx(Jl,{counts:Zl(s)})}),t.jsxs("span",{className:"shrink-0 font-mono tabular-nums",children:[t.jsxs("span",{className:"text-green-600 dark:text-green-400",children:["+",e.additions]})," ",t.jsxs("span",{className:"text-red-500 dark:text-red-400",children:["−",e.deletions]})]}),J&&t.jsx("a",{href:J,target:"_blank",rel:"noreferrer noopener",className:"inline-flex shrink-0 items-center text-blue-500 hover:underline",title:"View this file's diff on GitHub",children:t.jsx(_t,{size:12})})]}),z&&t.jsx("div",{className:"border-b border-gray-100 dark:border-gray-800",children:g==null?t.jsxs("div",{className:"px-3 py-3 text-center text-xs text-gray-500 dark:text-gray-400",children:[d!=null?t.jsx(_6,{status:u?h.isLoading?"loading":h.isError?"error":((Fe=h.data)==null?void 0:Fe.refused)??"idle":"idle",onLoad:()=>m(!0),githubUrl:J}):J?t.jsxs(t.Fragment,{children:["Diff is too large or binary —"," ",t.jsxs("a",{href:J,target:"_blank",rel:"noreferrer noopener",className:"text-blue-500 hover:underline",children:["view on GitHub",t.jsx(_t,{size:10,className:"ml-0.5 inline-block align-[-0.1em]"})]})]}):"Binary file — no textual diff.",ne]}):x.length===0?t.jsxs("div",{className:"px-3 py-3 text-center text-xs text-gray-500 dark:text-gray-400",children:["No textual diff for this file.",ne]}):t.jsxs(I6,{rows:x,wrap:c,children:[a&&D.map(oe=>t.jsx(u1,{thread:oe,ctx:a,fileChip:!0,focusNonce:i!=null&&i.threadId===oe.id?i.nonce:null,consumedFocus:K,wrap:c},`u-${oe.id}`)),x.map((oe,re)=>{var X;return t.jsxs(f.Fragment,{children:[oe.kind==="hunk"?oe.gap!=null&&oe.gap.count>0?t.jsx(p1,{gap:oe.gap,place:EM(x,re),reveal:N.get(re),lines:P,html:F,side:y,expandable:d!=null,status:N.has(re)?$:"idle",onExpand:(le,Ne)=>L(re,le,Ne),wrap:c}):null:lc(oe)?null:t.jsx(C6,{row:oe,html:(H==null?void 0:H[re])??null,filePath:e.path,fileUrl:J,commenting:n,onPosted:r,open:E===re,onOpen:()=>ee(re),onClose:()=>ee(null),focused:B===re,focusNonce:(i==null?void 0:i.nonce)??null,wrap:c}),a&&((X=M.get(re))==null?void 0:X.map(le=>t.jsx(u1,{thread:le.thread,ctx:a,approximate:le.approximate,focusNonce:i!=null&&i.threadId===le.thread.id?i.nonce:null,consumedFocus:K,wrap:c},le.thread.id)))]},re)}),C!=null&&t.jsx(p1,{gap:C,place:"trailing",reveal:N.get(-1),lines:P,html:F,side:y,expandable:d!=null,status:N.has(-1)?$:"idle",onExpand:(oe,re)=>L(-1,oe,re),wrap:c})]})})]})}const M6=f.memo(function({files:n,commenting:r,threadCtx:s,focus:a,fileSource:i}){const[c,d]=f.useState(null),[u]=bC(),m=f.useRef(null);f.useEffect(()=>()=>{m.current&&clearTimeout(m.current)},[]);const h=b=>{b!=null&&(d(b),m.current&&clearTimeout(m.current),m.current=setTimeout(()=>{m.current=null,d(w=>w===b?null:w)},k6))},g=s?{...s,focusThreadId:s.focusThreadId??c,onThreadShown:s.focusThreadId!=null?s.onThreadShown:void 0}:null,x=(a==null?void 0:a.path)??null,y=f.useMemo(()=>{if(x==null)return null;const b=n.find(k=>k.path===x);if(b)return b.path;const w=n.find(k=>k.previousPath===x);return(w==null?void 0:w.path)??null},[n,x]);return t.jsx("div",{className:"relative",children:n.map(b=>t.jsx(A6,{file:b,commenting:r??null,onPosted:h,threads:(s==null?void 0:s.threadsByPath.get(b.path))??[],threadCtx:g,focus:a!=null&&b.path===y?a:null,wrap:u,fileSource:i??null},b.path))})}),L6=10,F6=6,m1=12;function O6(e){for(let n=e.parentElement;n!=null;n=n.parentElement){const r=getComputedStyle(n).overflowY;if((r==="auto"||r==="scroll")&&n.scrollHeight>n.clientHeight)return n}return null}function g1({additions:e,deletions:n,muted:r=!1}){return r?t.jsxs("span",{className:"shrink-0 font-mono text-[10px] tabular-nums text-gray-400 dark:text-gray-500",children:["+",e," −",n]}):t.jsxs("span",{className:"shrink-0 font-mono text-[10px] tabular-nums",children:[t.jsxs("span",{className:"text-green-600 dark:text-green-400",children:["+",e]})," ",t.jsxs("span",{className:"text-red-500 dark:text-red-400",children:["−",n]})]})}function CC({node:e,depth:n,collapsed:r,onToggleDir:s,selectedPath:a,onSelectFile:i,selectedRef:c}){var x,y;const d={paddingLeft:F6+n*L6};if(e.kind==="dir"){const b=!r.has(e.path);return t.jsxs(t.Fragment,{children:[t.jsxs("button",{type:"button",onClick:()=>s(e.path),"aria-expanded":b,style:d,className:"flex w-full items-center gap-1.5 rounded border-l-2 border-transparent py-0.5 pr-2 text-left text-xs hover:bg-gray-50 dark:hover:bg-gray-800/50",title:`${e.path} — ${e.fileCount} file${e.fileCount===1?"":"s"}`,children:[t.jsx("span",{className:"flex w-3 shrink-0 select-none justify-center text-gray-400",children:t.jsx(Mt,{dir:b?"down":"right"})}),t.jsxs("span",{className:"min-w-0 flex-1 truncate font-mono text-gray-500 dark:text-gray-400",children:[e.name,"/"]}),t.jsxs("span",{className:"ml-auto flex shrink-0 items-center gap-1.5",children:[t.jsx(Jl,{counts:e.threadCounts,compact:!0}),t.jsx(g1,{additions:e.additions,deletions:e.deletions,muted:!0})]})]}),b&&e.children.map(w=>t.jsx(CC,{node:w,depth:n+1,collapsed:r,onToggleDir:s,selectedPath:a,onSelectFile:i,selectedRef:c},w.path))]})}const u=a===e.path,m=(x=e.entry)==null?void 0:x.status,h=m?vC[m]:null,g=Hx(e.path);return t.jsxs("button",{type:"button",ref:u?c:void 0,onClick:()=>i(e.path),"aria-pressed":u,style:d,className:`flex w-full items-center gap-1.5 rounded border-l-2 py-0.5 pr-2 text-left text-xs ${u?`${kC} bg-sky-50 dark:bg-sky-950/30`:`${wC} hover:bg-gray-50 dark:hover:bg-gray-800/50`} ${g&&!u?"opacity-60":""}`,title:(y=e.entry)!=null&&y.previousPath?`${e.entry.previousPath} → ${e.path}`:e.path,children:[t.jsx("span",{className:`w-3 shrink-0 select-none text-center font-mono font-bold ${h?h.cls:"text-gray-400"}`,title:h==null?void 0:h.label,children:h?h.icon:"·"}),t.jsx("span",{className:"min-w-0 flex-1 truncate font-mono",children:e.name}),t.jsxs("span",{className:"ml-auto flex shrink-0 items-center gap-1.5",children:[t.jsx(Jl,{counts:e.threadCounts,compact:!0}),t.jsx(g1,{additions:e.additions,deletions:e.deletions})]})]})}function D6({nodes:e,selectedPath:n,onSelectFile:r,note:s,revealNonce:a,railHeight:i}){const[c,d]=f.useState(()=>new Set),u=y=>{d(b=>{const w=new Set(b);return w.has(y)?w.delete(y):w.add(y),w})},m=f.useMemo(()=>{const y=[],b=w=>{for(const k of w)k.kind==="dir"&&(y.push(k.path),b(k.children))};return b(e),y},[e]),h=f.useMemo(()=>e.reduce((y,b)=>y+b.fileCount,0),[e]),g=m.some(y=>!c.has(y)),x=f.useRef(null);return f.useEffect(()=>{n!=null&&d(y=>{const b=[...y].filter(k=>n.startsWith(`${k}/`));if(b.length===0)return y;const w=new Set(y);for(const k of b)w.delete(k);return w})},[n,a]),f.useLayoutEffect(()=>{const y=x.current;if(n==null||y==null)return;const b=O6(y);if(b==null)return;const w=y.getBoundingClientRect(),k=b.getBoundingClientRect(),j=Math.max(k.top,0),N=Math.min(k.bottom,window.innerHeight),I=N-j;I<=0||w.top>=j+m1&&w.bottom<=N-m1||(b.scrollTop+=w.top-j-I*.3)},[n,a,c,i]),t.jsxs("nav",{"aria-label":"Changed files",className:"py-1",children:[t.jsxs("div",{className:"sticky top-0 z-10 flex items-center gap-2 bg-white px-2 pb-0.5 pt-1 text-[10px] text-gray-400 dark:bg-gray-950 dark:text-gray-500",children:[t.jsxs("span",{children:[h," file",h===1?"":"s"]}),m.length>0&&t.jsx("button",{type:"button",onClick:()=>d(g?new Set(m):new Set),className:"ml-auto hover:text-gray-600 hover:underline dark:hover:text-gray-300",children:g?"Collapse all":"Expand all"})]}),s,e.map(y=>t.jsx(CC,{node:y,depth:0,collapsed:c,onToggleDir:u,selectedPath:n,onSelectFile:r,selectedRef:x},y.path))]})}const B6=160,W6="pierre:changesRailWidth",q6=224,U6=140,f1=720,H6=320;function z6({file:e}){const n=e.path.split("/"),r=n.at(-1),s=n.slice(0,-1).join("/");return t.jsxs("div",{className:"flex items-center pr-3 hover:bg-gray-50 dark:hover:bg-gray-900",children:[t.jsxs("a",{href:e.githubUrl,target:"_blank",rel:"noreferrer noopener",className:"group flex min-w-0 flex-1 items-center gap-3 px-4 py-1.5 text-sm",title:`${e.path} — view this file's diff on GitHub`,children:[t.jsxs("code",{className:"min-w-0 flex-1 truncate font-mono text-xs",children:[s&&t.jsxs("span",{className:"text-gray-400",children:[s,"/"]}),t.jsx("span",{className:"font-semibold",children:r})]}),t.jsxs("span",{className:"shrink-0 font-mono text-xs tabular-nums",children:[t.jsxs("span",{className:"text-green-600 dark:text-green-400",children:["+",e.additions]})," ",t.jsxs("span",{className:"text-red-500 dark:text-red-400",children:["−",e.deletions]})]}),t.jsx("span",{className:"shrink-0 decorative-mark text-gray-300 group-hover:text-blue-500 dark:text-gray-600",children:t.jsx(_t,{size:12})})]}),t.jsx(Bi,{text:e.path,what:"file path",title:"Copy file path"})]})}function x1({shown:e,total:n,canLoadMore:r,ceilingReached:s,loading:a,error:i,onLoadMore:c,githubUrl:d,compact:u=!1}){const m=`${e.toLocaleString()} of ${Math.max(n,e).toLocaleString()} shown`;return t.jsxs("div",{className:u?"space-y-0.5 px-2 pb-1 pt-0.5 text-[11px] leading-snug text-amber-700 dark:text-amber-400":"flex flex-wrap items-center gap-x-3 gap-y-1 px-4 py-2 text-xs text-gray-500 dark:text-gray-400",children:[r?t.jsx("button",{type:"button",onClick:c,disabled:a,className:"rounded border border-blue-400 px-2 py-0.5 text-blue-600 hover:bg-blue-50 disabled:opacity-60 dark:border-blue-600 dark:text-blue-400 dark:hover:bg-blue-900/30",children:a?"Loading files…":`Load next 100 files (${m})`}):t.jsxs("span",{children:[m,"."]}),i&&t.jsx("span",{className:"text-amber-700 dark:text-amber-400",children:"Couldn’t load more files."}),s&&t.jsx("span",{children:"GitHub lists at most 3,000 files."}),t.jsxs("a",{href:`${d}/files`,target:"_blank",rel:"noreferrer noopener",className:`text-blue-500 hover:underline ${u?"block":""}`,children:["All on GitHub ",t.jsx(_t,{size:11,className:"inline-block align-[-0.1em]"})]})]})}function c0({pr:e,extra:n,wrapToggle:r=!1}){return t.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 border-b border-gray-200 px-4 py-2 text-xs dark:border-gray-800",children:[t.jsxs("span",{className:"font-semibold text-gray-600 dark:text-gray-300",children:[e.changedFilesCount," file",e.changedFilesCount===1?"":"s"," changed"]}),t.jsxs("span",{className:"text-green-600 dark:text-green-400",children:["+",e.additions.toLocaleString()]}),t.jsxs("span",{className:"text-red-500 dark:text-red-400",children:["−",e.deletions.toLocaleString()]}),n,t.jsxs("span",{className:"ml-auto flex items-center gap-3",children:[r&&t.jsx(T6,{}),t.jsxs("a",{href:`${e.githubUrl}/files`,target:"_blank",rel:"noreferrer noopener",className:"text-blue-500 hover:underline",children:["Files changed ",t.jsx(_t,{size:11,className:"inline-block align-[-0.1em]"})]})]})]})}function K6({pr:e,focus:n,onOpenThread:r,threadOpenMemory:s}){var B;const{data:a,isLoading:i,isError:c}=fP(e.id),d=xP(e.id,a),u=f.useMemo(()=>{const O=(a==null?void 0:a.files)??[];if(d.files.length===0)return O;const E=new Set(O.map(ee=>ee.path));return[...O,...d.files.filter(ee=>!E.has(ee.path))]},[a==null?void 0:a.files,d.files]),m=d.canLoadMore||d.ceilingReached||(a==null?void 0:a.truncated)===!0&&a.nextPage===void 0,{data:h}=An(),g=f.useMemo(()=>Rn(h),[h]),x=f.useMemo(()=>zM(e.threads,u),[e.threads,u]),y=f.useRef(r);f.useLayoutEffect(()=>{y.current=r},[r]);const b=r!=null,w=f.useCallback(O=>{var E;return(E=y.current)==null?void 0:E.call(y,O)},[]),k=f.useMemo(()=>({threadsByPath:x,usersById:g,prUrl:e.githubUrl,onOpenThread:b?w:void 0,openMemory:s}),[x,g,e.githubUrl,b,w,s]),j=f.useMemo(()=>({prId:e.id}),[e.id]),N=f.useMemo(()=>({prId:e.id,headSha:(a==null?void 0:a.headSha)??null}),[e.id,a==null?void 0:a.headSha]),[I,S]=f.useState(n??null);f.useEffect(()=>{n!=null&&S(n)},[n]);const T=f.useRef(null),[$,P]=f.useState(null);f.useLayoutEffect(()=>{const O=T.current;if(O==null)return;const E=()=>P(O.clientWidth);E();const ee=new ResizeObserver(E);return ee.observe(O),()=>ee.disconnect()},[a]);const{width:C,paneRef:L,separatorProps:F}=f6({storageKey:W6,defaultWidth:q6,minWidth:U6,maxWidth:$!=null&&$>0?Math.min(f1,$-H6):f1,label:"Resize the changed-files list"}),[M,D]=f.useState(null);f.useLayoutEffect(()=>{const O=L.current;if(O==null)return;let E=O.parentElement;for(;E!=null;){const U=getComputedStyle(E).overflowY;if(U==="auto"||U==="scroll")break;E=E.parentElement}const ee=()=>{D(Math.max(B6,E!=null?E.clientHeight:window.innerHeight))};ee();const K=new ResizeObserver(ee);return E!=null&&K.observe(E),window.addEventListener("resize",ee),()=>{K.disconnect(),window.removeEventListener("resize",ee)}},[a]);const A=u,W=f.useMemo(()=>YM(A.map(O=>({path:O.path,additions:O.additions,deletions:O.deletions,status:O.status,previousPath:O.previousPath??null,threadCounts:Zl(x.get(O.path)??[])}))),[u,x]);if(e.files.length===0&&e.changedFilesCount===0&&!i)return t.jsx("div",{className:"px-3 py-6 text-center text-sm text-gray-500 dark:text-gray-400",children:"No file changes on this PR."});if(i)return t.jsxs("div",{children:[t.jsx(c0,{pr:e}),t.jsx("div",{className:"px-3 py-6 text-center text-sm text-gray-500 dark:text-gray-400",children:"Loading diff…"})]});const z=!c&&A.length>0,te=I!=null&&!A.some(O=>O.path===I.path||O.previousPath===I.path),H=I==null?null:((B=A.find(O=>O.previousPath===I.path&&O.path!==I.path))==null?void 0:B.path)??I.path;return z?t.jsxs("div",{children:[t.jsx(c0,{pr:e,wrapToggle:!0,extra:e.threads.length>0?t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsxs("span",{className:"rounded bg-gray-500/10 px-1.5 py-0.5 text-[11px] font-medium text-gray-600 dark:text-gray-300",children:[e.threads.length," thread",e.threads.length===1?"":"s"]}),t.jsx(Jl,{counts:Zl(e.threads)})]}):void 0}),t.jsxs("div",{ref:T,className:"flex items-start",children:[t.jsxs("div",{className:"sticky top-0 z-20 hidden shrink-0 self-start md:flex",children:[t.jsx("div",{ref:L,style:{width:C,...M!=null?{maxHeight:M}:null},className:"max-h-[70vh] min-w-0 shrink-0 overflow-y-auto overscroll-contain border-r border-gray-200 bg-white dark:border-gray-800 dark:bg-gray-950",children:t.jsx(D6,{nodes:W,selectedPath:H,revealNonce:I==null?void 0:I.nonce,railHeight:M,onSelectFile:O=>S({path:O,nonce:Date.now()}),note:m?t.jsx(x1,{compact:!0,shown:A.length,total:e.changedFilesCount,canLoadMore:d.canLoadMore,ceilingReached:d.ceilingReached,loading:d.loading,error:d.error,onLoadMore:d.loadMore,githubUrl:e.githubUrl}):null})}),t.jsx("div",{...F,className:"w-1.5 shrink-0 cursor-col-resize touch-none bg-gray-200 transition-colors hover:bg-blue-400 focus-visible:bg-blue-500 focus-visible:outline-none dark:bg-gray-800 dark:hover:bg-blue-500"})]}),t.jsxs("div",{className:"min-w-0 flex-1",children:[te&&I!=null&&t.jsxs("div",{className:"border-b border-amber-500/30 bg-amber-500/10 px-4 py-1.5 text-xs text-amber-700 dark:text-amber-300",children:[t.jsx("code",{className:"font-mono",children:I.path})," isn’t in the diff shown here.",m?" It may be in the files not loaded yet.":" It may be outside this PR’s changed files."," ",t.jsxs("a",{href:`${e.githubUrl}/files`,target:"_blank",rel:"noreferrer noopener",className:"text-blue-500 hover:underline",children:["View on GitHub ",t.jsx(_t,{size:11,className:"inline-block align-[-0.1em]"})]})]}),t.jsx(M6,{files:A,commenting:j,threadCtx:k,focus:I,fileSource:N})]})]}),m&&t.jsx(x1,{shown:A.length,total:e.changedFilesCount,canLoadMore:d.canLoadMore,ceilingReached:d.ceilingReached,loading:d.loading,error:d.error,onLoadMore:d.loadMore,githubUrl:e.githubUrl})]}):t.jsxs("div",{children:[t.jsx(c0,{pr:e}),t.jsxs("div",{className:"px-4 py-2 text-xs text-gray-400",children:[c?"The full diff couldn’t be loaded — showing the changed-file list.":"Inline diffs aren’t available for this PR — showing the changed-file list."," ",t.jsxs("a",{href:`${e.githubUrl}/files`,target:"_blank",rel:"noreferrer noopener",className:"text-blue-500 hover:underline",children:["View on GitHub ",t.jsx(_t,{size:11,className:"inline-block align-[-0.1em]"})]})]}),e.files.length>0&&t.jsx("div",{className:"divide-y divide-gray-100 dark:divide-gray-800",children:e.files.map(O=>t.jsx(z6,{file:O},O.path))})]})}function hy({prId:e,initialBody:n,autoFocus:r,onCancel:s,onDone:a}){const[i,c]=f.useState(n??""),d=XP(e),u=d.error instanceof cn?d.error.message:d.error?"Failed to post the comment.":null,m=()=>{const h=i.trim();!h||d.isPending||d.mutate(h,{onSuccess:()=>{c(""),a==null||a()}})};return t.jsxs("div",{className:"space-y-1.5 px-3 pb-3",children:[t.jsx(Ad,{prId:e,value:i,onChange:c,rows:3,autoFocus:r,placeholder:"Add a comment to this PR (markdown, @ to mention)…",className:"w-full rounded border border-gray-300 bg-white px-2 py-1.5 text-sm dark:border-gray-700 dark:bg-gray-900"}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("button",{type:"button",onClick:m,disabled:d.isPending||i.trim().length===0,className:"whitespace-nowrap rounded border border-blue-400 px-2 py-0.5 text-sm text-blue-600 hover:bg-blue-50 disabled:opacity-50 dark:border-blue-600 dark:text-blue-400 dark:hover:bg-blue-900/30",children:d.isPending?"Commenting…":s?"Reply":"Comment"}),s&&t.jsx("button",{type:"button",onClick:()=>{d.reset(),s()},disabled:d.isPending,className:"whitespace-nowrap rounded border border-gray-300 px-2 py-0.5 text-sm hover:border-gray-400 disabled:opacity-50 dark:border-gray-700 dark:hover:border-gray-500",children:"Cancel"}),u&&t.jsx("span",{className:"text-xs text-red-500",children:u})]})]})}const G6="animate-pulse rounded-lg border border-gray-200 bg-gray-50 dark:border-gray-800 dark:bg-gray-900/40";function Bl({className:e="",style:n}){return t.jsx("div",{className:`${G6} ${e}`,style:n,"aria-hidden":"true"})}function Va({className:e="h-3 w-full",style:n}){return t.jsx("div",{className:`animate-pulse rounded bg-gray-200 dark:bg-gray-800 ${e}`,style:n,"aria-hidden":"true"})}const V6=f.lazy(()=>up(()=>import("./ClaudeReviewTab-DQJ-58ZA.js"),__vite__mapDeps([0,1,2,3,4,5,6])).then(e=>({default:e.ClaudeReviewTab}))),Q6=f.lazy(()=>up(()=>import("./AiFixTab-CQP6PT5u.js"),__vite__mapDeps([7,1,2,3,4,5,6])).then(e=>({default:e.AiFixTab}))),Y6=f.lazy(()=>up(()=>import("./PrBotBehaviourTab-CCnFrWbC.js"),__vite__mapDeps([8,1,2,3,4,5,6])).then(e=>({default:e.PrBotBehaviourTab})));function X6(e){if(!e)return null;const n=[];return e.comments>0&&n.push(`${e.comments} new comment${e.comments===1?"":"s"}`),e.reviews>0&&n.push(`${e.reviews} new review${e.reviews===1?"":"s"}`),e.commits>0&&n.push(`${e.commits} new commit${e.commits===1?"":"s"}`),n.length?n.join(" · "):null}function Uc(e,n){const r=e.authorId!=null?n.get(e.authorId):void 0;return{id:e.id,number:e.number,title:e.title,repoFullName:e.repoFullName,authorLogin:(r==null?void 0:r.githubLogin)??null,authorDisplayName:(r==null?void 0:r.displayName)??null,authorAvatarUrl:(r==null?void 0:r.avatarUrl)??null}}const Z6={overview:"Overview",threads:"Threads",activity:"Activity",changes:"Changes",bot_activity:"Bot activity",claude_review:"Claude Review",ai_fix:"AI Analysis and Fix"};function J6(e){var r;const n=[];n.push({key:"opened",time:e.openedAt,label:"opened this PR",actorId:e.authorId,href:e.githubUrl,event:{type:"pr_opened",refId:null}});for(const s of e.commits)n.push({key:`commit:${s.id}`,time:s.committedAt,label:"pushed a commit",actorId:s.authorId??s.committerId,detail:(r=s.message)==null?void 0:r.split(`
61
+ `)[0],href:`${e.githubUrl}/commits/${s.sha}`,sha:s.sha,event:{type:"commit_pushed",refId:s.id}});for(const s of e.reviews)n.push({key:`review:${s.id}`,time:s.submittedAt,label:`reviewed (${s.state.replace("_"," ")})`,actorId:s.authorId,detail:s.body??void 0,href:s.url??e.githubUrl,event:{type:"review_submitted",refId:s.id}});for(const s of e.comments)n.push({key:`comment:${s.id}`,time:s.createdAt,label:"commented",actorId:s.authorId,detail:s.body,href:s.url??e.githubUrl,event:{type:"pr_comment",refId:s.id}});return e.mergedAt?n.push({key:"merged",time:e.mergedAt,label:"merged this PR",actorId:e.authorId,href:e.githubUrl,event:{type:"pr_merged",refId:null}}):e.closedAt&&n.push({key:"closed",time:e.closedAt,label:"closed this PR",actorId:e.authorId,href:e.githubUrl,event:{type:"pr_closed",refId:null}}),n.sort((s,a)=>a.time.localeCompare(s.time))}function e8({pr:e,usersById:n,since:r,onClearSince:s,focusEvent:a,onConsumed:i}){const c=f.useMemo(()=>J6(e),[e]),d=r?c.filter(g=>g.time>r):c,u=f.useRef(new Map),[m,h]=f.useState(null);return f.useEffect(()=>{var x;if(!a)return;const g=c.find(y=>y.event.type===a.type&&y.event.refId===a.refId);i(),g&&((x=u.current.get(g.key))==null||x.scrollIntoView({behavior:"smooth",block:"center"}),h(g.key))},[a,c,i]),f.useEffect(()=>{if(m==null)return;const g=setTimeout(()=>h(null),1800);return()=>clearTimeout(g)},[m]),t.jsxs("ul",{className:"divide-y divide-gray-100 dark:divide-gray-800",children:[r&&t.jsxs("li",{className:"flex items-center gap-2 bg-sky-500/5 px-3 py-1.5 text-xs text-sky-600 dark:text-sky-400",children:[t.jsxs("span",{children:["Showing ",d.length," since you last looked"]}),t.jsx("button",{type:"button",onClick:s,className:"ml-auto text-gray-400 hover:text-gray-600",children:"show all"})]}),d.map(g=>{const x=g.actorId!=null?n.get(g.actorId):void 0;return t.jsxs("li",{ref:y=>{y?u.current.set(g.key,y):u.current.delete(g.key)},className:`flex items-start gap-2 px-3 py-2 text-sm ${g.key===m?"activity-flash":""}`,children:[t.jsx(gn,{user:x,size:20}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-2 gap-y-0.5",children:[t.jsx(mr,{user:x,fallbackId:g.actorId,repoId:e.repoId,className:"font-medium"}),t.jsx("span",{className:"text-gray-500 dark:text-gray-400",children:g.label}),g.sha&&t.jsxs("span",{className:"inline-flex items-center gap-0.5",children:[t.jsx("a",{href:mn(g.href??`${e.githubUrl}/commits/${g.sha}`),target:"_blank",rel:"noreferrer noopener",className:"font-mono text-xs text-gray-500 hover:text-blue-500 dark:text-gray-400","aria-label":`Commit ${g.sha.slice(0,7)} on GitHub`,children:g.sha.slice(0,7)}),t.jsx(Bi,{text:g.sha,what:"commit hash",title:"Copy commit hash"})]}),t.jsxs("span",{className:"text-xs text-gray-400",title:Cn(g.time),children:["· ",Nt(g.time)]})]}),g.detail&&t.jsx("div",{className:"mt-0.5 truncate text-xs text-gray-500 dark:text-gray-400",title:g.detail,children:g.detail.split(`
62
+ `)[0]}),t.jsxs("div",{className:"mt-1 flex items-center gap-3 text-xs",children:[t.jsx(zh,{prId:e.id,at:g.time,event:g.event,label:"Timeline view",title:"Timeline view — open this PR's own timeline tab, centred on this event"}),g.href&&t.jsxs("a",{href:mn(g.href),target:"_blank",rel:"noreferrer noopener",className:"text-gray-400 hover:text-blue-500",children:["Open on GitHub"," ",t.jsx(_t,{size:11,className:"inline-block align-[-0.1em]"})]})]})]})]},g.key)})]})}const y1=e=>e.reviews.filter(n=>n.body!=null&&n.body.trim()!=="").length,t8={approved:{label:"approved",cls:"bg-green-500/10 text-green-700 dark:text-green-400"},changes_requested:{label:"changes requested",cls:"bg-amber-500/10 text-amber-700 dark:text-amber-400"},commented:{label:"review",cls:"bg-sky-500/10 text-sky-700 dark:text-sky-400"},dismissed:{label:"dismissed",cls:"bg-gray-500/10 text-gray-500 dark:text-gray-400"},pending:{label:"pending",cls:"bg-gray-500/10 text-gray-500 dark:text-gray-400"}};function n8({state:e}){const n=t8[e];return t.jsx("span",{className:`rounded px-1.5 py-0.5 text-[10px] font-medium ${n.cls}`,title:`Review: ${e.replace("_"," ")}`,children:n.label})}function r8({pr:e,usersById:n,viewedSince:r,focusCommentId:s,selectedCommentId:a,onFocusConsumed:i}){const c=f.useRef(new Map),[d,u]=f.useState(null),[m,h]=f.useState(null);f.useEffect(()=>{if(s==null)return;i();const b=c.current.get(s);b&&(b.scrollIntoView({behavior:"smooth",block:"center"}),u(s))},[s,i]),f.useEffect(()=>{if(d==null)return;const b=setTimeout(()=>u(null),1800);return()=>clearTimeout(b)},[d]);const g=ba(),x=Ip(e.id,g),y=[...e.comments.map(b=>({kind:"comment",id:b.id,authorId:b.authorId,body:b.body,at:b.createdAt,url:b.url})),...e.reviews.filter(b=>b.body!=null&&b.body.trim()!=="").map(b=>({kind:"review",id:b.id,authorId:b.authorId,body:b.body,at:b.submittedAt,url:b.url,state:b.state}))].sort((b,w)=>b.at.localeCompare(w.at));return y.length===0?t.jsx("div",{className:"px-3 py-6 text-center text-sm text-gray-500 dark:text-gray-400",children:"No PR comments on this PR."}):t.jsx("div",{className:"space-y-2 px-3 pb-3",children:y.map(b=>{var T;const w=b.authorId!=null?n.get(b.authorId):void 0,k=a2(b.at,r),j=b.kind==="comment",N=`${b.kind}:${b.id}`,I=j&&b.id===a,S=j&&b.id===d;return t.jsxs("div",{ref:j?$=>{$?c.current.set(b.id,$):c.current.delete(b.id)}:void 0,className:`rounded-md border px-2.5 py-2 ${I?"border-amber-400 bg-amber-400/5":"border-gray-200 dark:border-gray-800"} ${k?"comment-new":""} ${S?"activity-flash":""}`,children:[t.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[t.jsx(zh,{prId:e.id,at:b.at,event:j?{type:"pr_comment",refId:b.id}:{type:"review_submitted",refId:b.id},title:j?"Show this comment on the timeline":"Show this review on the timeline"}),t.jsx("span",{className:"decorative-mark text-gray-300 dark:text-gray-600",children:"·"}),t.jsx(gn,{user:w,size:18}),t.jsx(mr,{user:w,fallbackId:b.authorId,repoId:e.repoId,className:"font-semibold"}),b.kind==="review"&&b.state!=null&&t.jsx(n8,{state:b.state}),t.jsx("span",{className:"text-gray-400",title:Cn(b.at),children:Nt(b.at)}),k&&t.jsx(s2,{}),t.jsx(cc,{label:x==null?void 0:x.get(gd(j?"pr_comment":"review",b.id))}),t.jsx(Bi,{text:b.body,what:j?"comment":"review",className:"ml-auto"})]}),t.jsx("div",{className:"mt-1 text-sm",children:t.jsx(gr,{children:b.body})}),t.jsx(r2,{kind:j?"pr_comment":"review",id:b.id,className:"mt-1.5 pl-2"}),t.jsxs("div",{className:"mt-2 flex items-center gap-3 pl-2 text-[11px]",children:[m!==N&&t.jsx("button",{type:"button",onClick:()=>h(N),className:"text-blue-500 hover:underline",children:"Reply"}),b.url&&t.jsxs("a",{href:mn(b.url),target:"_blank",rel:"noreferrer noopener",className:"text-blue-500 hover:underline",children:[t.jsx(_t,{size:11,className:"inline-block align-[-0.1em]"})," ",j?"View comment on GitHub":"View review on GitHub"]}),j&&t.jsx(zx,{prId:e.id,target:{targetKind:"pr_comment",targetId:b.id}})]}),j&&t.jsx(Z5,{prId:e.id,targetKind:"pr_comment",targetId:b.id}),m===N&&t.jsx("div",{className:"mt-2",children:t.jsx(hy,{prId:e.id,initialBody:ES(b.body,((T=n.get(b.authorId??-1))==null?void 0:T.githubLogin)??null),autoFocus:!0,onCancel:()=>h(null),onDone:()=>h(null)})})]},N)})})}function s8(){return t.jsxs("div",{className:"flex h-full flex-col","aria-hidden":"true",children:[t.jsxs("div",{className:"border-b border-gray-200 px-4 py-2 dark:border-gray-800",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Va,{className:"h-4 w-12"}),t.jsx(Va,{className:"h-3.5 w-20"}),t.jsx(Va,{className:"h-4 w-2/5"})]}),t.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[t.jsx(Va,{className:"h-3 w-24"}),t.jsx(Va,{className:"h-3 w-32"}),t.jsx(Va,{className:"h-3 w-20"})]})]}),t.jsx("div",{className:"flex gap-3 border-b border-gray-200 px-3 py-2 dark:border-gray-800",children:[16,14,14,14].map((e,n)=>t.jsx(Va,{className:"h-3.5",style:{width:`${e*4}px`}},n))}),t.jsxs("div",{className:"flex flex-1 flex-col gap-3 p-4",children:[t.jsx(Bl,{className:"h-20"}),t.jsx(Bl,{className:"h-16"}),t.jsx(Bl,{className:"h-16"})]})]})}const a8=new Set,o8=new Set,jl="shrink-0 rounded p-0.5 text-gray-900 hover:bg-gray-100 dark:text-gray-100 dark:hover:bg-gray-800";function RC({prId:e,selectedThreadId:n,placement:r}){const{data:s,isLoading:a,error:i}=ya(e),c=CL(e),d=IL(e),{data:u}=xn(),m=Dr().enabled,h=m,g=m,x=G(je=>je.prDetailTab),y=G(je=>je.setPrDetailTab),b=(x==null?void 0:x.prId)===e?x.tab:"overview",[w,k]=f.useState(null),[j]=f.useState(()=>new Map),[N,I]=f.useState(null),S=f.useCallback(je=>{k(null),y(e,je)},[e,y]),T=f.useCallback(je=>{Gp(),S(je)},[S]),$=(je,Rt,Pt,qt)=>{y(e,"changes"),k({path:je,line:Rt,side:Pt,threadId:qt??null,nonce:Date.now()})},[P,C]=f.useState(null),L=He(),F=f.useMemo(()=>{const je=new Set;for(const Pt of(s==null?void 0:s.files)??[])je.add(Pt.path);const Rt=L.getQueryData(["pr-files",s==null?void 0:s.id]);for(const Pt of(Rt==null?void 0:Rt.files)??[])je.add(Pt.path),Pt.previousPath&&je.add(Pt.previousPath);return je},[s==null?void 0:s.files,s==null?void 0:s.id,L]),M=f.useCallback(je=>{var Wn;if(F.size>0&&!F.has(je.path))return null;const Rt=je.line==null?U5((Wn=je.comments[0])==null?void 0:Wn.diffHunk):null,Pt=je.line??(Rt==null?void 0:Rt.line)??null,qt=je.line!=null?"RIGHT":(Rt==null?void 0:Rt.side)??"RIGHT";return{line:Pt,approximate:je.line==null&&Rt!=null,run:()=>$(je.path,Pt,qt,je.id)}},[F,$]),D=f.useCallback(je=>{G.getState().selectThread(e,je),S("threads")},[e,S]),A=G(je=>je.openPrFocused),W=Ge(je=>je.openPrFocusTab),z=Ge(je=>je.openPrDetailTab),te=G(je=>je.workspaceId),H=G(je=>je.setWorkspace),B=G(je=>je.setActivityRepo),O=G(je=>je.setRepoConsoleTab),E=G(je=>je.setFeedIsolatedPrId),ee=Ge(je=>je.showActivity),K=G(je=>je.activityFocus),U=G(je=>je.consumeActivityFocus),Q=f.useMemo(()=>K&&s&&K.prId===s.id?{type:K.type,refId:K.refId}:null,[K,s]),J=G(je=>je.commentFocus),ne=G(je=>je.consumeCommentFocus),ae=G(je=>je.selectedCommentId),we=G(je=>je.claudeTabFocus),$e=G(je=>je.consumeClaudeTabFocus),Fe=G(je=>je.aiFixTabFocus),oe=J&&s&&J.prId===s.id?J.commentId:null,re=Ge(je=>je.syncMeta);f.useEffect(()=>{n!=null&&T("threads")},[n,T]);const X=G(je=>je.threadBotFilter);f.useEffect(()=>{X!=null&&T("threads")},[X,T]);const le=G(je=>je.selectedPrId),Ne=G(je=>je.threadStateFilter),Ve=le===e?Ne:a8,me=G(je=>je.threadSeverityFilter),be=le===e?me:o8;f.useEffect(()=>{Ve.size>0&&T("threads")},[Ve,T]),f.useEffect(()=>{Q&&(T("activity"),C(null))},[Q,T]),f.useEffect(()=>{h&&we&&s&&we.prId===s.id&&(T("claude_review"),$e())},[we,s,h,$e,T]),f.useEffect(()=>{g&&Fe&&s&&Fe.prId===s.id&&T("ai_fix")},[Fe,s,g,T]),f.useEffect(()=>{oe!=null&&T("overview")},[oe,T]);const at=tt({mutationFn:je=>he.markPrViewed(je),onSuccess:()=>{L.invalidateQueries({queryKey:["open-prs"]}),L.invalidateQueries({queryKey:["timeline"]}),L.invalidateQueries({queryKey:["my-turn"]}),L.invalidateQueries({queryKey:["me"]}),L.invalidateQueries({queryKey:["attention-cards"]}),L.invalidateQueries({queryKey:["daily-brief"]}),L.invalidateQueries({queryKey:["work-plan"]})}}),ft=f.useRef(null);f.useEffect(()=>{s&&ft.current!==s.id&&(ft.current=s.id,at.mutate(s.id))},[s,at]);const mt=f.useMemo(()=>Rn(s==null?void 0:s.users),[s]),se=f.useMemo(()=>s?!!(s.reviews.some(je=>je.automatedKind!=null)||s.threads.some(je=>{var Rt;return je.originalCommenterId!=null&&((Rt=mt.get(je.originalCommenterId))==null?void 0:Rt.isBot)})||s.comments.some(je=>{var Rt;return je.authorId!=null&&((Rt=mt.get(je.authorId))==null?void 0:Rt.isBot)})):!1,[s,mt]),{data:Ce}=pC((s==null?void 0:s.id)??null,se),_e=((Ce==null?void 0:Ce.bots.length)??0)>0,pe=((Ce==null?void 0:Ce.bots)??[]).filter(je=>je.ttfrAnomaly!=null).length,Qe=s!=null&&(!se||Ce!==void 0),ct=b==="bot_activity"&&Qe&&!_e?"overview":b;f.useEffect(()=>{s!=null&&re(Uc(s,mt))},[s,mt,re]);const Bt=Ge(je=>je.activeTab),Je=Go(Bt),Qt=(Je==null?void 0:Je.kind)==="pr-detail"?Je.prId===e:Bt==="timeline"||(Je==null?void 0:Je.kind)==="pr-focus",{refreshNow:Ft,isRefreshing:fe,isStale:rt}=DS(e,Qt&&(s==null?void 0:s.state)==="open"),et=Di(e);if(a)return t.jsx(s8,{});if(i||!s)return t.jsx("div",{className:"p-4 text-sm text-red-500",children:i?String(i):"PR not found"});const It=vS[s.state],Wt=S_(s.state,s.ciStatus),St=s.authorId!=null?mt.get(s.authorId):void 0;return t.jsx(e2.Provider,{value:Uc(s,mt),children:t.jsxs("div",{className:"flex h-full flex-col",children:[t.jsxs("div",{className:`border-b border-gray-200 px-4 py-2 dark:border-gray-800 ${r==="pane"?"pr-28":""}`,children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"rounded px-1.5 py-0.5 text-xs font-semibold text-white",style:{backgroundColor:It.color},children:s.isDraft?"Draft":It.label}),Wt!=null&&t.jsxs("button",{type:"button","data-testid":"pr-header-ci",onClick:()=>{S("overview"),I(je=>(je??0)+1)},className:"inline-flex shrink-0 items-center gap-1.5 rounded px-1 py-0.5 text-xs font-medium text-gray-700 hover:bg-gray-100 dark:text-gray-200 dark:hover:bg-gray-800",title:"Show CI status in Overview","aria-label":`${Wt.label} — show CI status`,children:[t.jsx(Kp,{status:Wt.status,size:12,title:"Show CI status in Overview",className:Wt.status==="unknown"?"":"ring-1 ring-black/15 dark:ring-white/20"}),Wt.label]}),r==="pane"?t.jsxs(t.Fragment,{children:[t.jsxs("button",{type:"button",onClick:()=>z(Uc(s,mt)),className:"min-w-0 truncate text-left text-sm font-semibold hover:underline",title:"Open full-screen in its own tab",children:[t.jsxs("span",{className:"text-gray-400",children:["#",s.number]})," ",s.title]}),t.jsx("button",{type:"button",onClick:()=>z(Uc(s,mt)),className:jl,title:"Open full-screen — this PR in its own tab","aria-label":"Open this PR full-screen in its own tab",children:t.jsx(_t,{size:13})})]}):t.jsxs("h2",{className:"min-w-0 truncate text-sm font-semibold",title:s.title,children:[t.jsxs("span",{className:"text-gray-400",children:["#",s.number]})," ",s.title]}),t.jsx("button",{type:"button",onClick:()=>A(s.id),className:jl,title:"Show this PR on the timeline","aria-label":"Show this PR on the timeline",children:t.jsx(F4,{size:15})}),t.jsx("button",{type:"button",onClick:()=>W(Uc(s,mt)),className:jl,title:"Focus — open this PR in its own isolated timeline tab (the close button on the tab closes it)","aria-label":"Focus this PR in its own timeline tab",children:t.jsx(eo,{size:15})}),t.jsx("button",{type:"button",onClick:()=>{var Rt;const je=((Rt=u==null?void 0:u.find(Pt=>Pt.id===s.repoId))==null?void 0:Rt.workspaceId)??null;je!=null&&je!==te&&H(je,null),O(s.repoId,"activity"),B(s.repoId),E(s.id),ee()},className:jl,title:"Show this PR in its repo's Activity feed (filtered to this PR)","aria-label":"Show this PR in the Activity feed",children:t.jsx(r_,{size:15})}),t.jsx("button",{type:"button",onClick:Ft,disabled:fe,className:rt?"shrink-0 rounded p-0.5 text-amber-500 hover:text-amber-600 disabled:opacity-60":`${jl} disabled:opacity-60`,title:rt?"Couldn't refresh from GitHub — showing the last synced state. Click to retry.":"Refresh — re-check GitHub for new activity on this PR","aria-label":"Refresh this PR from GitHub",children:t.jsx(us,{size:14,className:fe?"animate-spin":void 0})}),t.jsx("a",{href:s.githubUrl,target:"_blank",rel:"noreferrer noopener",className:jl,title:"Open this PR on GitHub","aria-label":"Open this PR on GitHub",children:t.jsx(O4,{size:15})}),s.isStalled&&t.jsx("span",{className:"rounded bg-orange-500/15 px-1.5 py-0.5 text-xs font-medium text-orange-500",title:"Open, no recent commits, and has open threads",children:"Stalled"}),et!=null&&s.state==="open"&&t.jsxs("span",{className:"shrink-0 rounded bg-violet-500/15 px-1.5 py-0.5 text-xs font-medium text-violet-600 dark:text-violet-300",title:"Auto-merge is armed — Limn updates it from trunk if needed and merges when checks pass, while the app is running. Cancel from Overview → Actions.",children:[t.jsx($i,{size:12,className:"mr-1 inline-block align-[-0.1em]"}),"Auto-merge armed"]}),(()=>{const je=X6(s.newSinceLastViewed);return je?t.jsxs("button",{type:"button",onClick:()=>{S("activity"),C(s.lastViewedAt)},className:"ml-auto shrink-0 rounded bg-sky-500/15 px-1.5 py-0.5 text-xs font-medium text-sky-500 hover:bg-sky-500/25",title:"Filter activity to what's new since you last looked",children:[t.jsx(e_,{size:12,className:"inline-block align-[-0.1em]"})," ",je]}):null})()]}),t.jsxs("div",{className:"mt-1 flex items-center gap-2 text-xs text-gray-500 dark:text-gray-400",children:[t.jsx(gn,{user:St,size:16}),t.jsx(mr,{user:St,fallbackId:s.authorId,repoId:s.repoId}),t.jsx("span",{children:"·"}),t.jsx("span",{children:s.repoFullName}),t.jsx("span",{children:"·"}),t.jsxs("span",{children:["opened ",Nt(s.openedAt)]}),s.changedFilesCount>0&&t.jsxs(t.Fragment,{children:[t.jsx("span",{children:"·"}),t.jsxs("button",{type:"button",onClick:()=>S("changes"),className:"inline-flex shrink-0 items-center gap-1 font-medium",title:"View the files changed by this PR",children:[t.jsxs("span",{className:"text-gray-500 dark:text-gray-400",children:[s.changedFilesCount," file",s.changedFilesCount===1?"":"s"]}),t.jsxs("span",{className:"text-green-600 dark:text-green-400",children:["+",s.additions.toLocaleString()]}),t.jsxs("span",{className:"text-red-500 dark:text-red-400",children:["−",s.deletions.toLocaleString()]})]})]}),t.jsx(Up,{pr:c,className:"ml-0.5"}),t.jsx(Md,{pr:{...d,...c},className:"ml-0.5",expandable:!0})]}),t.jsx(KD,{prId:e,hasBlast:d.blast!=null})]}),t.jsxs("div",{className:"flex gap-1 border-b border-gray-200 px-3 dark:border-gray-800",children:[["overview","threads","activity","changes",..._e||ct==="bot_activity"?["bot_activity"]:[],...h?["claude_review"]:[],...g?["ai_fix"]:[]].map(je=>{const Rt=s.checkRuns.filter(Pt=>Pt.state==="failure"||Pt.state==="error").length;return t.jsxs("button",{type:"button",onClick:()=>S(je),className:`-mb-px border-b-2 px-3 py-1.5 text-xs ${ct===je?"border-blue-500 text-blue-500":"border-transparent text-gray-500 dark:text-gray-400 hover:text-gray-700"}`,children:[Z6[je],je==="overview"&&Rt>0&&t.jsx("span",{className:"ml-1 text-red-500",title:`${Rt} failing`,children:t.jsx(xx,{size:7,className:"inline-block align-middle"})}),je==="threads"&&s.threads.length>0&&t.jsx("span",{className:"ml-1 opacity-60",title:`${s.threads.length} threads`,children:s.threads.length}),je==="changes"&&s.changedFilesCount>0&&t.jsx("span",{className:"ml-1 opacity-60",title:`${s.changedFilesCount} files changed`,children:s.changedFilesCount}),je==="bot_activity"&&pe>0&&t.jsx("span",{className:"ml-1 text-red-500",title:`${pe} bot slower than its typical on this PR`,children:t.jsx(Jt,{size:11,className:"inline-block align-[-0.1em]"})})]},je)}),t.jsx(RD,{className:"ml-auto self-center"})]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:t.jsx(f.Suspense,{fallback:t.jsx("div",{className:"px-4 py-6 text-sm text-gray-400",children:"Loading…"}),children:ct==="overview"?t.jsxs("div",{children:[t.jsx(o1,{pr:s,usersById:mt,variant:"compact",onOpenThreads:()=>S("threads")}),t.jsx(m6,{pr:s,usersById:mt,onShowBotActivity:_e?()=>S("bot_activity"):void 0,onOpenThreads:()=>S("threads"),statusFocus:N,onStatusFocusConsumed:()=>I(null)}),t.jsxs("div",{className:"border-t border-gray-200 dark:border-gray-800",children:[t.jsx("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 px-4 pb-1 pt-2",children:t.jsxs("span",{className:"text-xs font-semibold uppercase tracking-wide text-gray-400",children:["PR comments",s.comments.length+y1(s)>0&&t.jsxs("span",{className:"ml-1 font-normal opacity-70",children:["· ",s.comments.length+y1(s)]})]})}),t.jsx(r8,{pr:s,usersById:mt,viewedSince:s.lastViewedAt,focusCommentId:oe,selectedCommentId:ae,onFocusConsumed:ne}),t.jsx(hy,{prId:s.id})]})]}):ct==="threads"?t.jsxs(t.Fragment,{children:[t.jsx(o1,{pr:s,usersById:mt,variant:"full"}),t.jsx(qD,{threads:s.threads,usersById:mt,prUrl:s.githubUrl,prId:s.id,repoId:s.repoId,selectedThreadId:n,viewedSince:s.lastViewedAt,botFilter:X,stateFilter:Ve,severityFilter:be,openInChangesFor:M})]}):ct==="activity"?t.jsx(e8,{pr:s,usersById:mt,since:P,onClearSince:()=>C(null),focusEvent:Q,onConsumed:U}):ct==="changes"?t.jsx(K6,{pr:s,focus:w,onOpenThread:D,threadOpenMemory:j}):ct==="bot_activity"?t.jsx(Y6,{pr:s}):ct==="ai_fix"?t.jsx(Q6,{pr:s}):t.jsx(V6,{pr:s,usersById:mt,onOpenInChanges:$,onOpenThread:D})})})]})})}function i8(e,n){const r=new Map;for(const s of e??[])r.set(s.userId,s);return s=>{var i;const a=r.get(s);if(a!=null){if(a.automated)return!0;if(a.isManualOverride)return!1}return((i=n.get(s))==null?void 0:i.isBot)??!1}}function l8(e,n,r){const{data:s}=qi(e,null,r&&e!=null),a=r?s==null?void 0:s.reviewers:void 0;return f.useMemo(()=>i8(a,n),[a,n])}const c8=["untouched","replied_unresolved","likely_addressed","resolved"],d8={open:"Open",merged:"Merged",closed:"Closed"},u8=e=>'<svg viewBox="0 0 24 24" width="12" height="12" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="2.6" fill="currentColor" stroke="none"/>'+(e>=2?'<circle cx="12" cy="12" r="6.4" opacity="0.75"/>':"")+(e>=3?'<circle cx="12" cy="12" r="10.1" opacity="0.5"/>':"")+"</svg>",b1='<svg viewBox="0 0 24 24" width="12" height="12" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M10.7 3.9 2.4 18.6a1.5 1.5 0 0 0 1.3 2.2h16.6a1.5 1.5 0 0 0 1.3-2.2L13.3 3.9a1.5 1.5 0 0 0-2.6 0z"/><line x1="12" y1="9.5" x2="12" y2="14"/><circle cx="12" cy="17.3" r="1.05" fill="currentColor" stroke="none"/></svg>';function h8(e){const n=Rr[e.ciStatus];return n?`<span class="pr-ci pr-ci-lead" style="background:${n.color}" title="${n.label}"></span>`:""}function p8(e){return e?`${e.avatarUrl?`<img class="pr-avatar" src="${kn(e.avatarUrl)}" width="14" height="14" loading="lazy" alt="" />`:""}<span class="pr-author">${kn(e.label)}</span>`:""}function m8(e,n={}){const{author:r}=n,s=e.isDraft?'<span class="pr-draft-tag">draft</span>':"";return'<div class="pr-bar-inner">'+(e.state==="open"?h8(e):"")+`<span class="pr-num">#${e.number}</span>`+p8(r)+`${s}<span class="pr-title">${kn(e.title)}</span></div>`}function v1(e,n,r=""){return`<div class="pr-tt-row ${r}"><span class="pr-tt-dot" style="background:${e}"></span><span>${n}</span></div>`}function g8(e,n={}){const{author:r,hasComments:s=!1}=n,a=[];a.push(`<div class="pr-tt-title">#${e.number} ${kn(e.title)}</div>`);const i=[];r!=null&&r.label&&i.push(kn(r.label)),i.push(d8[e.state]),e.isDraft&&i.push("draft"),e.isStalled&&i.push("stalled"),a.push(`<div class="pr-tt-meta">${i.join(" · ")}</div>`);const c=Rr[e.ciStatus];c&&a.push(v1(c.color,c.label));const d=Cx({mergeable:e.mergeable,mergeStateStatus:e.mergeStateStatus,isDraft:e.isDraft});if(d){const g=d.detail?` — ${d.detail}`:"";a.push(`<div class="pr-tt-row pr-tt-warn">${b1}<span>merge: ${kn(d.label)}${kn(g)}</span></div>`)}const u=TS(e,E_());u&&a.push(`<div class="pr-tt-row pr-tt-warn">${b1}<span>${kn(u.label)}</span></div>`);const m=Rx(e,L_());if(m){const g=m.level==="high"?"pr-tt-warn":"pr-tt-quiet",x=m.level==="low"?1:m.level==="medium"?2:3;a.push(`<div class="pr-tt-row ${g}">${u8(x)}<span>${kn(`Blast radius ${m.short.toLowerCase()} — ${m.label}`)}</span></div>`)}const h=c8.filter(g=>e.threadCounts[g]>0);if(h.length>0){a.push('<div class="pr-tt-section">Review threads</div>');for(const g of h){const x=Xt[g];a.push(v1(x.color,`${x.label}: ${e.threadCounts[g]}`))}}else s&&a.push('<div class="pr-tt-row pr-tt-quiet">Has comments</div>');return`<div class="pr-tt">${a.join("")}</div>`}function f8(e,n=!1){const r=["pr-bar",`pr-${e.state}`];return e.state==="open"?r.push("pr-emph"):r.push("pr-muted"),e.isDraft&&r.push("pr-draft"),e.isStalled&&r.push("pr-stalled"),e.reviewRequestedFromMe&&r.push("pr-myturn"),e.state==="open"&&(e.isChangesRequested?r.push("pr-changes-requested"):e.isApproved?r.push("pr-approved"):n&&r.push("pr-commented")),r.join(" ")}const x8='<svg viewBox="0 0 16 16" width="11" height="11" aria-hidden="true"><path fill="#8957e5" d="M8 .8 2.2 2.9v4.2c0 3.3 2.5 6.4 5.8 7.3 3.3-.9 5.8-4 5.8-7.3V2.9L8 .8Z"/><path d="M5.2 8 7.1 9.9 10.9 6" fill="none" stroke="#fff" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/></svg>';function IC(e){return`<svg viewBox="0 0 24 24" width="12" height="12" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="${e}"/></svg>`}const TC=IC("9 6 15 12 9 18"),$C=IC("6 9 12 15 18 9");function y8(e,n,r=!1,s,a=!1){const i=Dt(e,n),c=e!=null&&e.avatarUrl?`<img class="tl-user-avatar" src="${kn(e.avatarUrl)}" width="18" height="18" loading="lazy" referrerpolicy="no-referrer" alt="" />`:`<span class="tl-user-avatar tl-user-avatar-fallback">${kn((i[0]??"?").toUpperCase())}</span>`,d=e!=null&&e.githubLogin&&s?`<a class="tl-user-name tl-user-name-link" data-user-gid="${kn(s)}" href="${kn(Gl(e.githubLogin))}" target="_blank" rel="noreferrer noopener" title="${kn(`@${e.githubLogin} — activity & stats`)}">${kn(i)}</a>`:e!=null&&e.githubLogin?`<a class="tl-user-name tl-user-name-link" href="${kn(Gl(e.githubLogin))}" target="_blank" rel="noreferrer noopener" title="${kn(`@${e.githubLogin} on GitHub`)}">${kn(i)}</a>`:`<span class="tl-user-name">${kn(i)}</span>`,u=r?`<span class="tl-merger" title="Has merge rights — has merged a PR in this repo">${x8}</span>`:"",m=a?"Expand row":"Collapse row";return'<div class="tl-user">'+(s?`<button type="button" class="tl-collapse-caret" data-collapse-gid="${kn(s)}" title="${kn(m)}" aria-label="${kn(m)}">${a?TC:$C}</button>`:"")+c+`<span class="tl-user-main"><span class="tl-user-name-line">${d}${u}</span></span></div>`}const zn={reviewComment:"#f59e0b",prComment:"#9ca3af",approved:"#22c55e",changes:"#f97316",commented:"#9ca3af",dismissed:"#9ca3af",commit:"#6b7280",lifecycle:"#3b82f6"};function Ui(e){return`<svg viewBox="0 0 16 16" width="16" height="16" aria-hidden="true">${e}</svg>`}const k1=e=>Ui(`<circle cx="8" cy="8" r="5" fill="${e}"/>`),b8=e=>Ui(`<circle cx="8" cy="8" r="4.5" fill="none" stroke="${e}" stroke-width="2"/>`),v8=e=>Ui(`<circle cx="8" cy="8" r="4.5" fill="none" stroke="${e}" stroke-width="1.6" stroke-dasharray="2.2 2"/>`),k8=e=>Ui(`<rect x="3.5" y="3.5" width="9" height="9" rx="1.5" fill="${e}"/>`),w8=e=>Ui(`<circle cx="8" cy="8" r="7" fill="${e}"/><path d="M4.5 8.3 L7 10.8 L11.5 5.5" fill="none" stroke="#fff" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/>`),j8=e=>Ui(`<circle cx="8" cy="8" r="7" fill="${e}"/><path d="M4.5 6.5 L8 10 L11.5 6.5" fill="none" stroke="#fff" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/>`),N8=e=>Ui(`<path d="M2.5 4.5 a1.5 1.5 0 0 1 1.5-1.5 h8 a1.5 1.5 0 0 1 1.5 1.5 v4 a1.5 1.5 0 0 1 -1.5 1.5 h-5 l-2.5 2.2 v-2.2 h-0 a1.5 1.5 0 0 1 -1.5 -1.5 z" fill="none" stroke="${e}" stroke-width="1.5"/>`);function _C(e){switch(e.type){case"review_comment":return{svg:k1(zn.reviewComment),color:zn.reviewComment,label:"Review comment",round:!0};case"pr_comment":return{svg:b8(zn.prComment),color:zn.prComment,label:"PR comment",round:!0};case"commit_pushed":return{svg:k8(zn.commit),color:zn.commit,label:"Commit pushed"};case"review_submitted":switch(e.reviewState){case"approved":return{svg:w8(zn.approved),color:zn.approved,label:"Approved"};case"changes_requested":return{svg:j8(zn.changes),color:zn.changes,label:"Changes requested"};case"dismissed":return{svg:v8(zn.dismissed),color:zn.dismissed,label:"Review dismissed",round:!0};default:return{svg:N8(zn.commented),color:zn.commented,label:"Review comment"}}default:return{svg:k1(zn.lifecycle),color:zn.lifecycle,label:"Event",round:!0}}}function S8(e){const n=_C(e);return`<div class="ev-marker-inner${n.round?" ev-round":""}">${n.svg}</div>`}function d0(e){return`<svg viewBox="0 0 16 16" width="11" height="11" aria-hidden="true">${e}</svg>`}const C8={commit:{color:zn.commit,glyph:d0('<rect x="3.5" y="3.5" width="9" height="9" rx="1.5" fill="#fff"/>'),label:"commits"},comment:{color:zn.reviewComment,glyph:d0('<circle cx="8" cy="8" r="5" fill="#fff"/>'),label:"comments"},review:{color:zn.approved,glyph:d0('<path d="M4.5 8.3 L7 10.8 L11.5 5.5" fill="none" stroke="#fff" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>'),label:"reviews"}};function R8(e,n){const r=C8[n];return`<div class="ev-cluster-inner" style="background:${r.color}" title="${e} ${r.label}">${r.glyph}+${e}</div>`}function I8(e,n){const r=kS[e.type],s=Dt(e.actorId!=null?n.get(e.actorId):void 0,e.actorId);return`${r.label} · ${s} · ${Nt(e.occurredAt)}`}const w1=Number.MAX_SAFE_INTEGER,T8="2000-01-01T00:00:00Z",$8="2100-01-01T00:00:00Z";function _8(e){if(!e||e.end<=e.start)return{start:T8,end:$8};const n=e.end-e.start;return{start:new Date(e.start-n*3).toISOString(),end:new Date(e.end+n*3).toISOString()}}const P8=new Set(["review_comment","pr_comment","review_submitted","commit_pushed"]);function E8(e){return P8.has(e.type)}function A8(e){return e.type==="commit_pushed"?"commit":e.type==="review_submitted"?"review":"comment"}const PC=9,M8=3;function L8(e){return(23+(1+String(e).length)*6.5)/2}function F8(e,n,r,s,a,i,c=8,d){const u=Math.max(1,c*i),m=[],h=new Map,g=new Map,x=new Set,y=new Map;for(const w of e){if(!E8(w))continue;const k=n(w),j=A8(w),N=w.prId,I=N!=null?s.get(N):void 0,S=w.actorId!=null&&(I==null?void 0:I.authorId)!=null&&w.actorId===I.authorId,T=S?`${k}::${j}::own::${N}`:`${k}::${j}::cross::${N??"none"}`,$=y.get(T);if($){$.events.push(w);continue}S||x.add(k);const P=S?a.get(N)??0:0;y.set(T,{group:k,kind:j,ownWork:S,subgroup:S?`ev:${P}`:"cross",sortKey:S?P*2+1:w1,events:[w]})}for(const{group:w,kind:k,ownWork:j,subgroup:N,sortKey:I,events:S}of y.values()){const T=F=>`${F} ${j?"ev-own":"ev-cross"}`,$=[...S].sort((F,M)=>Date.parse(F.occurredAt)-Date.parse(M.occurredAt));let P=[],C=-1/0;const L=()=>{if(P.length!==0){if(P.length===1){const F=P[0],M=`ev:${F.id}`;m.push({id:M,group:w,subgroup:N,sortKey:I,type:"point",start:F.occurredAt,content:S8(F),className:`${T("ev-marker")} ev-key-${F.id}`,title:I8(F,r),selectable:!1}),g.set(M,PC)}else{const F=P.reduce((D,A)=>D+Date.parse(A.occurredAt),0)/P.length,M=`cl:${w}:${k}:${P[0].id}`;h.set(M,P.map(D=>D.id)),m.push({id:M,group:w,subgroup:N,sortKey:I,type:"point",start:new Date(F).toISOString(),content:R8(P.length,k),className:`${T("ev-cluster")} ${P.map(D=>`ev-key-${D.id}`).join(" ")}`,title:`${P.length} ${k}s`,selectable:!1}),g.set(M,L8(P.length))}P=[]}};for(const F of $){const M=Date.parse(F.occurredAt);P.length>0&&M-C>u&&L(),P.push(F),C=M}L()}O8(m,i,g);const b=_8(d);for(const w of x)m.push({id:`xsep:${w}`,group:w,subgroup:"cross",sortKey:w1,type:"background",start:b.start,end:b.end,content:"",className:"cross-sep"});return{items:m,clusterMembers:h}}function O8(e,n,r){if(n<=0)return;const s=new Map;for(const a of e){if(a.type!=="point")continue;const i=`${String(a.group)}\0${String(a.subgroup??"")}`,c=s.get(i);c?c.push(a):s.set(i,[a])}for(const a of s.values()){if(a.length<2)continue;a.sort((d,u)=>u0(d)-u0(u));let i=-1/0,c=0;for(const d of a){const u=r.get(String(d.id))??PC;let m=u0(d);const h=(c+u+M8)*n;m-i<h&&(m=i+h,d.start=new Date(m).toISOString()),i=m,c=u}}}function u0(e){const n=e.start;return n instanceof Date?n.valueOf():typeof n=="number"?n:Date.parse(String(n))}function Oo(e){return e.authorId!=null?`repo:${e.repoId}:user:${e.authorId}`:`repo:${e.repoId}`}function h0(e){return Date.parse(e.openedAt)}function j1(e,n){const r=e.mergedAt??e.closedAt;return r?Date.parse(r):n}function D8(e,n=()=>0,r=Date.now()){const s=new Map;for(const i of e){const c=Oo(i),d=s.get(c);d?d.push(i):s.set(c,[i])}const a=new Map;for(const i of s.values()){const c=[...i].sort((m,h)=>h0(m)-h0(h)),d=[],u=[];for(const m of c){const h=h0(m),g=n(m);let x=d.findIndex((y,b)=>y<=h&&u[b]===g);x===-1?(x=d.length,d.push(j1(m,r)),u.push(g)):d[x]=j1(m,r),a.set(m.id,x)}}return a}function B8(e,n,r){const s=new Set(fx(e.categories)),a=e.reviewStates.length<Kl.length,i=new Set(e.reviewStates),c=new Set(e.allowedBotIds);return d=>r!=null&&d.id===r?!0:!(!s.has(d.type)||a&&d.type==="review_submitted"&&(d.reviewState==null||!i.has(d.reviewState))||e.excludeBots&&d.actorId!=null&&!c.has(d.actorId)&&n(d.actorId))}function W8(e,n,r,s,a){const i=B8(r,s,a);return(e??[]).filter(c=>c.prId===n&&i(c))}function N1(e,n){const r=[Oo(e)],s=new Set(r);for(const a of n){if(a.prId!==e.id||a.actorId==null)continue;const i=`repo:${e.repoId}:user:${a.actorId}`;s.has(i)||(s.add(i),r.push(i))}return r}function S1(e,n,r,s){const a=(e??[]).filter(i=>i.prId===n&&i.type===r.type&&(r.refId==null||i.refId===r.refId));return(s!=null?a.find(i=>i.occurredAt===s):void 0)??a[0]}function q8(e){return e?e.replace(/\n$/,"").split(`
63
+ `).at(-1)??null:null}function U8({ev:e,pr:n,usersById:r,onOpen:s}){const a=n.authorId!=null?r.get(n.authorId):void 0,i=e.actorId!=null&&n.authorId!=null&&e.actorId!==n.authorId;return t.jsxs("div",{className:"flex items-baseline gap-1 text-[11px] text-gray-500 dark:text-gray-400",children:[t.jsx("span",{children:"on"}),i&&t.jsxs("span",{className:"font-medium text-gray-600 dark:text-gray-300",children:[Dt(a,n.authorId),"’s"]}),t.jsxs("button",{type:"button",onClick:s,className:"font-medium text-blue-500 hover:underline",children:["#",n.number]}),t.jsx("span",{className:"truncate text-gray-400",title:n.title,children:n.title})]})}function C1({ev:e,usersById:n,prsById:r,onNavigate:s}){var M,D;const a=G(A=>A.selectThread),i=G(A=>A.selectPr),c=G(A=>A.showActivityEntry),d=G(A=>A.showPrComment),u=_C(e),m=e.actorId!=null?n.get(e.actorId):void 0,h=Dt(m,e.actorId),g=e.type==="review_comment"&&e.threadId!=null,{data:x}=Sp(g?e.threadId:null),y=Date.parse(e.occurredAt),b=(x==null?void 0:x.comments.find(A=>Date.parse(A.createdAt)===y&&A.authorId===e.actorId))??(x==null?void 0:x.comments[0]),w=x?(b==null?void 0:b.diffHunk)??((M=x.comments[0])==null?void 0:M.diffHunk)??null:null,k=q8(w),j=((D=Gx(w,(x==null?void 0:x.path)??null))==null?void 0:D.at(-1))??null,N=e.type==="commit_pushed",I=e.type==="pr_comment",S=e.type==="review_submitted",{data:T}=ya((N||I)&&e.prId!=null?e.prId:null),$=N&&T?T.commits.find(A=>A.id===e.refId):void 0,P=I&&T?T.comments.find(A=>A.id===e.refId):void 0,C=e.prId!=null?r.get(e.prId):void 0,L=()=>{e.threadId!=null?a(e.prId,e.threadId):I&&e.prId!=null&&e.refId!=null?d(e.prId,e.refId):S&&e.prId!=null&&e.refId!=null?c(e.prId,{type:e.type,refId:e.refId}):e.prId!=null&&i(e.prId),s()},F=()=>{e.prId!=null&&(c(e.prId,{type:e.type,refId:e.refId}),s())};return t.jsxs("div",{className:"space-y-1.5",children:[t.jsxs("div",{className:"flex items-center gap-1.5 text-[11px]",children:[t.jsx("span",{className:"inline-block h-3 w-3",dangerouslySetInnerHTML:{__html:u.svg}}),t.jsx("span",{className:"font-semibold",children:h}),t.jsxs("span",{className:"text-gray-500 dark:text-gray-400",children:["· ",u.label]}),t.jsx("span",{className:"ml-auto text-gray-400",children:Nt(e.occurredAt)})]}),C&&t.jsx(U8,{ev:e,pr:C,usersById:n,onOpen:L}),N&&t.jsx("div",{className:"text-[11px]",children:$?t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("code",{className:"rounded bg-gray-100 px-1 font-mono text-gray-600 dark:bg-gray-800 dark:text-gray-300",children:$.sha.slice(0,7)}),$.message&&t.jsx("span",{className:"truncate text-gray-600 dark:text-gray-300",children:$.message.split(`
64
+ `)[0]})]}):t.jsx("span",{className:"text-gray-400",children:"loading commit…"})}),x&&t.jsxs("div",{className:"flex items-center gap-1.5 text-[11px]",children:[t.jsxs("code",{className:"truncate font-mono text-gray-600 dark:text-gray-300",children:[x.path,x.line!=null?`:${x.line}`:""]}),t.jsx("span",{className:"ml-auto shrink-0",children:t.jsx(Wx,{state:x.derivedState})})]}),k&&t.jsx("pre",{className:"overflow-x-auto rounded border border-gray-200 bg-gray-50 px-2 py-1 font-mono text-[11px] leading-snug text-gray-600 dark:border-gray-800 dark:bg-gray-900 dark:text-gray-300",children:j!=null?t.jsxs(t.Fragment,{children:[Vx(k),t.jsx("span",{className:"code-hl",dangerouslySetInnerHTML:{__html:j}})]}):k}),b&&t.jsxs("div",{className:"text-xs",children:[t.jsx(gr,{children:b.body}),x&&x.comments.length>1&&t.jsxs("div",{className:"mt-1 text-[11px] text-gray-400",children:["+",x.comments.length-1," more in thread"]})]}),I&&t.jsx("div",{className:"text-xs",children:P?t.jsx(gr,{children:P.body}):t.jsx("span",{className:"text-gray-400",children:"loading comment…"})}),t.jsxs("div",{className:"flex items-center gap-3 pt-0.5 text-[11px]",children:[!N&&t.jsx("button",{type:"button",onClick:L,className:"text-blue-500 hover:underline",children:"Open in detail pane"}),N&&e.prId!=null&&t.jsx("button",{type:"button",onClick:F,className:"text-blue-500 hover:underline",title:"Show this commit in the PR's Activity tab",children:"View in Activity"}),N&&$&&T&&t.jsxs("a",{href:`${T.githubUrl}/commits/${$.sha}`,target:"_blank",rel:"noreferrer noopener",className:"text-blue-500 hover:underline",children:["Open commit on GitHub ",t.jsx(_t,{size:11,className:"inline-block align-[-0.1em]"})]}),I&&P&&T&&t.jsxs("a",{href:mn(P.url)??T.githubUrl,target:"_blank",rel:"noreferrer noopener",className:"text-blue-500 hover:underline",children:["Open on GitHub ",t.jsx(_t,{size:11,className:"inline-block align-[-0.1em]"})]})]})]})}function H8({state:e,eventsById:n,usersById:r,prsById:s,focusPrId:a,onContextFocus:i,onDismiss:c,onNavigate:d}){var F;const[u,m]=uy("pierre:popoverSize",null),{refs:h,floatingStyles:g,context:x,isPositioned:y}=wa({open:!0,onOpenChange:M=>{M||c()},strategy:"fixed",placement:"right-start",middleware:[oo(24),io({fallbackPlacements:["left-start","bottom"]}),ri({padding:8})],whileElementsMounted:(M,D,A)=>ni(M,D,A,{animationFrame:!0})}),b=si(x,{outsidePress:!1}),{getFloatingProps:w}=lo([b]),k=e.eventIds[0]??null,j=f.useRef(null);f.useEffect(()=>{j.current=null},[k]),f.useEffect(()=>{const M=()=>({x:e.x,y:e.y,top:e.y,left:e.x,right:e.x,bottom:e.y,width:0,height:0});h.setReference({getBoundingClientRect:()=>{if(k!=null){const D=document.querySelector(`.ev-key-${k}`),A=(D==null?void 0:D.querySelector(".ev-marker-inner, .ev-cluster-inner"))??D;if(A){const W=A.getBoundingClientRect();return j.current=W,W}}return j.current??M()}})},[h,k,e.x,e.y]);const N=e.eventIds.map(M=>n.get(M)).filter(M=>M!=null).filter(M=>a==null||M.prId===a),I=((F=N[0])==null?void 0:F.prId)??null;f.useEffect(()=>{i({groupIds:null,prId:I,eventId:null})},[I,i]);const S=M=>{const D=M.currentTarget;m({width:D.offsetWidth,height:D.offsetHeight})},[T,$]=f.useState({x:0,y:0}),P=f.useRef(null);f.useEffect(()=>{const M=A=>{const W=P.current;W&&$({x:W.ox+(A.clientX-W.sx),y:W.oy+(A.clientY-W.sy)})},D=()=>{P.current=null};return window.addEventListener("pointermove",M),window.addEventListener("pointerup",D),()=>{window.removeEventListener("pointermove",M),window.removeEventListener("pointerup",D)}},[]);const C=M=>{M.button===0&&(M.preventDefault(),P.current={sx:M.clientX,sy:M.clientY,ox:T.x,oy:T.y})},L=`${g.transform??""} translate(${T.x}px, ${T.y}px)`.trim();return t.jsx(ka,{children:t.jsxs("div",{ref:h.setFloating,style:{...g,transform:L,visibility:y?"visible":"hidden",width:(u==null?void 0:u.width)??420,height:(u==null?void 0:u.height)??340,minWidth:240,minHeight:120,maxWidth:"92vw",maxHeight:"80vh",resize:"both",overflow:"hidden"},...w(),onPointerUp:S,"data-testid":"marker-popover",className:"z-50 flex flex-col rounded-lg border border-gray-200 bg-white shadow-xl dark:border-gray-700 dark:bg-gray-900",children:[t.jsxs("div",{className:"tl-modal-header",onPointerDown:C,children:[t.jsx("svg",{className:"tl-grip",width:"10",height:"10",viewBox:"0 0 10 10","aria-hidden":"true",children:t.jsxs("g",{fill:"currentColor",children:[t.jsx("circle",{cx:"2",cy:"2",r:"1"}),t.jsx("circle",{cx:"8",cy:"2",r:"1"}),t.jsx("circle",{cx:"2",cy:"5",r:"1"}),t.jsx("circle",{cx:"8",cy:"5",r:"1"}),t.jsx("circle",{cx:"2",cy:"8",r:"1"}),t.jsx("circle",{cx:"8",cy:"8",r:"1"})]})}),t.jsx("span",{className:"tl-modal-title",children:N.length>1?`${N.length} events`:"Activity"}),t.jsx("button",{type:"button",className:"tl-modal-close",onPointerDown:M=>M.stopPropagation(),onClick:c,"aria-label":"Close",title:"Close",children:t.jsx(Zt,{})})]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-auto p-2",children:N.length===1?t.jsx(C1,{ev:N[0],usersById:r,prsById:s,onNavigate:d}):t.jsx("div",{className:"divide-y divide-gray-200 dark:divide-gray-800",children:N.map(M=>t.jsx("div",{className:"py-2 first:pt-0 last:pb-0",children:t.jsx(C1,{ev:M,usersById:r,prsById:s,onNavigate:d})},M.id))})})]})})}const z8=1e3*60*60,K8=1e4,G8=5e3,V8={stack:!1,stackSubgroups:!0,groupHeightMode:"fixed",orientation:{axis:"top",item:"top"},zoomMin:z8,zoomMax:1e3*60*60*24*365*2,margin:{item:4,axis:8},tooltip:{followMouse:!0,overflowMethod:"flip",delay:150},verticalScroll:!0,horizontalScroll:!0,selectable:!0,multiselect:!1,maxHeight:"100%",xss:{disabled:!0}},Q8=12,Y8=2;function R1(e){return[...new Set(e)]}function I1(e,n){var a,i;if(!e)return 0;const r=e.body,s=n==null?void 0:n.querySelector(".vis-panel.vis-center");return((i=(a=r==null?void 0:r.domProps)==null?void 0:a.center)==null?void 0:i.width)||(s==null?void 0:s.clientWidth)||(n==null?void 0:n.clientWidth)||0}function Jc(e){return Date.parse(String(e.start))}function X8(e){return e.end!=null?Date.parse(String(e.end)):Jc(e)}function Z8(e,n){if(n<=0)return;const r=Q8*n,s=new Map;for(const a of e){const i=`${String(a.group)}|${String(a.subgroup??"")}`,c=s.get(i);c?c.push(a):s.set(i,[a])}for(const a of s.values())if(a.length!==0){a.sort((i,c)=>Jc(i)-Jc(c));for(let i=0;i<a.length;i++){const c=a[i],d=Jc(c),u=X8(c),m=i+1<a.length?Jc(a[i+1]):Number.POSITIVE_INFINITY,h=Math.min(Math.max(u,d+r),m);h!==u&&(c.end=new Date(h).toISOString())}}}function T1(e,n){const r=n.getTime()-e.getTime(),s=Math.max(r*.06,14400*1e3),a=Math.max(r*.03,7200*1e3);return{start:new Date(e.getTime()-a),end:new Date(n.getTime()+s)}}function J8(e){const n=document.createElement("div");return n.innerHTML=e,n.firstElementChild??n}function eB(){const e=typeof navigator<"u"?navigator.platform||navigator.userAgent:"";return/Mac|iP(hone|ad|od)/.test(e)?"metaKey":"ctrlKey"}function tB(e){return e.actorId!=null?`repo:${e.repoId}:user:${e.actorId}`:`repo:${e.repoId}`}const nB=/^repo:\d+:user:\d+$/;function Nl(e){return`tlg-${e.replace(/:/g,"-")}`}function rB(e){return new Date(e.mergedAt??e.closedAt??new Date().toISOString()).getTime()}const $1=[[{o:4,w:46},{o:24,w:34}],[{o:10,w:58},{o:40,w:28}],[{o:6,w:40},{o:30,w:50}]];function sB(){return t.jsxs("div",{className:"absolute inset-0 flex gap-4 overflow-hidden p-4","aria-hidden":"true",children:[t.jsx("div",{className:"flex w-44 shrink-0 flex-col gap-4",children:$1.map((e,n)=>t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx(Va,{className:"h-3.5 w-28"}),e.map((r,s)=>t.jsx(Va,{className:"ml-4 h-3 w-24"},s))]},n))}),t.jsx("div",{className:"flex min-w-0 flex-1 flex-col gap-4",children:$1.map((e,n)=>t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx("div",{className:"h-3.5"}),e.map((r,s)=>t.jsx(Bl,{className:"h-3",style:{marginLeft:`${r.o}%`,width:`${r.w}%`}},s))]},n))})]})}function _1({mode:e}={}){var xo,ta,Vi;const n=(e==null?void 0:e.kind)==="isolate"?e.prId:null,r=f.useRef(null),s=f.useRef(null),a=f.useRef(new Zv),i=f.useRef(new Zv),c=f.useRef(new Map),d=f.useRef(new Map),u=f.useRef(new Map),m=f.useRef([]),h=f.useRef(null),g=f.useRef(new Map),x=f.useRef(new Map),y=f.useRef(new Map),b=f.useRef({active:!1,states:[]}),w=f.useRef([]),k=f.useRef(null),j=f.useRef(null),N=f.useRef(null),I=f.useRef(new Set),S=f.useRef(new Set),T=f.useRef(!1);if(!T.current){T.current=!0;try{const Y=localStorage.getItem("pierre:collapsedRows");if(Y){const de=JSON.parse(Y);Array.isArray(de)&&(S.current=new Set(de.map(String)))}}catch{}}const $=f.useRef(new Map),P=f.useRef(null),C=f.useRef(null),L=f.useRef(null),F=f.useRef(null),M=f.useRef(null),D=f.useRef(null),A=f.useRef(null),W=f.useRef(null),z=f.useRef(null),te=f.useRef(0),H=f.useRef(!1),B=f.useRef(null),O=f.useRef(null),E=f.useRef(null),ee=f.useRef(null),K=f.useRef(null),U=f.useRef(null),Q=f.useRef(null),[J,ne]=f.useState(null),ae=f.useRef(null);ae.current=J;const[we,$e]=f.useState(null),[Fe,oe]=f.useState(!1),{data:re,isLoading:X,error:le}=pS(n!=null?{prIds:[n]}:void 0),{data:Ne}=D_(),{data:Ve,isPending:me}=mS({enabled:n==null}),{data:be}=AS(),{data:at}=xn(),{data:ft}=An(),{data:mt}=fp(),se=He(),Ce=G(Y=>Y.derivedStates),_e=G(Y=>Y.categories),pe=G(Y=>Y.reviewStates),Qe=G(Y=>Y.excludeBots),ct=G(Y=>Y.allowedBotIds),Bt=G(Y=>Y.userIds),Je=G(Y=>Y.selectPr),Qt=G(Y=>Y.selectedPrId),Ft=f.useRef(Qt),[fe,rt]=f.useState(0),[et,It]=f.useState(0),Wt=G(Y=>Y.preset),St=G(Y=>Y.customFrom),je=G(Y=>Y.customTo),Rt=G(Y=>Y.rangeResetSignal),Pt=f.useMemo(()=>{const Y=new Map;for(const de of at??[])Y.set(de.id,de);return Y},[at]),qt=f.useRef(Pt);qt.current=Pt;const Wn=f.useMemo(()=>{const Y=new Map;for(const de of mt??[])Y.set(de.repoId,new Set(de.userIds));return Y},[mt]),fr=f.useMemo(()=>Rn(ft),[ft]);g.current=fr;const Na=f.useRef(!1);f.useEffect(()=>{if(!re)return;let Y=!1;for(const de of re.events)if(de.actorId!=null&&!fr.has(de.actorId)){Y=!0;break}if(!Y){for(const de of re.prs)if(de.authorId!=null&&!fr.has(de.authorId)){Y=!0;break}}if(!Y){Na.current=!1;return}Na.current||(Na.current=!0,se.invalidateQueries({queryKey:["users"]}))},[re,fr,se]);const uo=f.useMemo(()=>{const Y=new Map;for(const de of(re==null?void 0:re.prs)??[])Y.set(de.id,de);return Y},[re]);x.current=uo;const xr=G(Y=>Y.timelineFocusPr),hs=G(Y=>Y.timelineFocusAt),ps=G(Y=>Y.timelineFocusEvent),Zs=n!=null&&re!=null&&xr===n&&ps!=null?((xo=S1(re.events,n,ps,hs))==null?void 0:xo.id)??null:null,[As,ho]=f.useState(null);Zs!=null&&Zs!==As&&ho(Zs);const Yn=Zs??As,ai=n!=null?((ta=uo.get(n))==null?void 0:ta.repoId)??null:null,Sa=ai!=null?((Vi=Pt.get(ai))==null?void 0:Vi.workspaceId)??null:null,ms=l8(Sa,fr,n!=null),Ca=f.useRef(null),Ir=f.useMemo(()=>{if(n==null||!re)return null;const Y=W8(re.events,n,{categories:_e,reviewStates:pe,excludeBots:Qe,allowedBotIds:ct},ms,Yn),de=Ca.current;return de!=null&&de.length===Y.length&&de.every((ke,Re)=>ke===Y[Re])?de:Y},[n,re,_e,pe,Qe,ct,ms,Yn]);Ca.current=Ir,k.current=Ir;const Ra=f.useCallback(Y=>{const de=a.current,ke=j.current;if(ke!=null&&ke!==Y){const Re=de.get(`pr:${ke}`);Re&&typeof Re.className=="string"&&de.update({id:`pr:${ke}`,className:Re.className.replace(/\s*pr-cross-linked/g,"")})}if(Y!=null){const Re=de.get(`pr:${Y}`);Re&&typeof Re.className=="string"&&!Re.className.includes("pr-cross-linked")&&de.update({id:`pr:${Y}`,className:`${Re.className} pr-cross-linked`})}j.current=Y},[]),Tr=f.useCallback(Y=>{const de=a.current,ke=C.current;if(ke!=null){const Ie=de.get(ke);Ie&&typeof Ie.className=="string"&&Ie.className.includes("ev-cross-linked")&&de.update({id:ke,className:Ie.className.replace(/\s*ev-cross-linked/g,"")}),C.current=null}if(P.current=Y,Y==null)return;const Re=de.get(`ev:${Y}`)?`ev:${Y}`:u.current.get(Y)??null;if(Re==null)return;const Te=de.get(Re);Te&&typeof Te.className=="string"&&!Te.className.includes("ev-cross-linked")&&(de.update({id:Re,className:`${Te.className} ev-cross-linked`}),C.current=Re)},[]),Xr=f.useCallback(Y=>{const de=a.current;for(const Te of de.getIds()){const Ie=de.get(Te);Ie&&typeof Ie.className=="string"&&Ie.className.includes("ev-exit-glow")&&de.update({id:Te,className:Ie.className.replace(/\s*ev-exit-glow/g,"")})}if(F.current=null,L.current=Y,Y==null)return;const ke=de.get(`ev:${Y}`)?`ev:${Y}`:u.current.get(Y)??null;if(ke==null)return;const Re=de.get(ke);Re&&typeof Re.className=="string"&&!Re.className.includes("ev-exit-glow")&&(de.update({id:ke,className:`${Re.className} ev-exit-glow`}),F.current=ke)},[]),yn=f.useCallback(Y=>{const de=a.current;for(const Te of de.getIds()){const Ie=de.get(Te);Ie&&typeof Ie.className=="string"&&Ie.className.includes("ev-selected")&&de.update({id:Te,className:Ie.className.replace(/\s*ev-selected/g,"")})}if(Q.current=null,U.current=Y,Y==null)return;const ke=de.get(`ev:${Y}`)?`ev:${Y}`:u.current.get(Y)??null;if(ke==null)return;const Re=de.get(ke);Re&&typeof Re.className=="string"&&!Re.className.includes("ev-selected")&&(de.update({id:ke,className:`${Re.className} ev-selected`}),Q.current=ke)},[]),Ms=f.useCallback(()=>{const Y=a.current,de=I.current,ke=[],Re=[],Te=N.current!=null;for(const Ie of m.current){const Xe=String(Ie.id),Ke=de.has(String(Ie.group))||!Te&&S.current.has(String(Ie.group)),ze=Y.get(Xe)!=null;Ke&&ze?ke.push(Xe):!Ke&&!ze&&Re.push(Ie)}ke.length&&Y.remove(ke),Re.length&&Y.add(Re)},[]),po=f.useCallback(()=>{try{localStorage.setItem("pierre:collapsedRows",JSON.stringify([...S.current]))}catch{}},[]),Br=f.useCallback((Y,de)=>{var ze,st;const ke=i.current;if(!ke.get(Y))return;const Re=a.current.get(),Te=new Set;for(const Le of Re)Le.group===Y&&typeof Le.subgroup=="string"&&Te.add(Le.subgroup);const Ie={};for(const Le of Te)Ie[Le]=!de;const Xe=ke.get(Y);Xe&&(ke.remove(Y),ke.add({...Xe,subgroupVisibility:Ie,heightMode:de?"auto":"fixed"})),de?S.current.add(Y):S.current.delete(Y),po(),Ms();const Ke=s.current;(st=(ze=Ke==null?void 0:Ke.itemSet)==null?void 0:ze.markDirty)==null||st.call(ze,{restackGroups:!0}),Ke==null||Ke.redraw()},[po,Ms]),Zr=f.useCallback(Y=>{const de=i.current.getIds().map(String).filter(Te=>nB.test(Te)),ke=Y&&Y.length?new Set(Y):null,Re=[];for(const Te of de){const Ie=ke!=null&&!ke.has(Te);Ie?I.current.add(Te):I.current.delete(Te),Re.push({id:Te,visible:!Ie})}Re.length&&i.current.update(Re),N.current=ke?Y:null,Ms()},[Ms]),Tn=f.useCallback(()=>{const Y=s.current,de=r.current,ke=h.current;if(!Y||!de||!ke)return;const Re=Y.getWindow(),Te=Re.end.valueOf()-Re.start.valueOf();W.current=Te;const Ie=de.clientWidth||1e3,Xe=Te/Ie;let Ke;const ze=k.current;if(ze!=null)Ke=ze;else if(Ke=ke.events,b.current.active){const{states:ue}=b.current;Ke=Ke.filter(Se=>Se.type==="review_comment"&&Se.prId!=null&&Se.derivedState!=null&&ue.includes(Se.derivedState))}if(ze==null){const ue=new Set(fx(w.current));Ke=Ke.filter(Se=>ue.has(Se.type))}const{items:st,clusterMembers:Le}=F8(Ke,tB,g.current,x.current,y.current,Xe,8,{start:Re.start.valueOf(),end:Re.end.valueOf()});d.current=Le;const V=new Map;for(const[ue,Se]of Le)for(const Ye of Se)V.set(Ye,ue);u.current=V;const xe=a.current.getIds().filter(ue=>{const Se=String(ue);return Se.startsWith("ev:")||Se.startsWith("cl:")||Se.startsWith("xsep:")});if(a.current.remove(xe),a.current.add(st),m.current=st.filter(ue=>String(ue.id).startsWith("xsep:")),Ms(),P.current!=null){const ue=P.current;C.current=null,P.current=null,Tr(ue)}if(L.current!=null){const ue=L.current;F.current=null,L.current=null,Xr(ue)}if(U.current!=null){const ue=U.current;Q.current=null,U.current=null,yn(ue)}},[Tr,Xr,yn,Ms]),mo=f.useCallback(()=>{const Y=O.current;if(!Y)return;const de=()=>{Y.childElementCount&&Y.replaceChildren(),Y.style.display="none"},ke=r.current,Re=B.current;if(!H.current||Re==null||!ke){de();return}const Te=ke.querySelector(".vis-panel.vis-center"),Ie=x.current.get(Re);if(!Te||!Ie){de();return}const Xe=Nl(Oo(Ie)),Ke=ke.querySelector(`.vis-foreground .vis-group.${Xe} .vis-item.pr-bar.vis-selected`)??ke.querySelector(`.vis-foreground .vis-group.${Xe} .vis-item.pr-bar:not(.pr-focus-hidden)`);if(!Ke||Ke.offsetHeight===0){de();return}const st=(Y.parentElement??ke).getBoundingClientRect(),Le=Te.getBoundingClientRect();Y.style.display="block",Y.style.left=`${Le.left-st.left}px`,Y.style.top=`${Le.top-st.top}px`,Y.style.width=`${Le.width}px`,Y.style.height=`${Le.height}px`;const V=Ke.getBoundingClientRect(),xe=V.top-Le.top,ue=V.bottom-Le.top,Se=V.left-Le.left,Ye=V.right-Le.left,Ze="http://www.w3.org/2000/svg",Et=document.createDocumentFragment(),At=ke.querySelectorAll(".vis-foreground .vis-item.ev-cross");for(const rn of At){if(rn.offsetHeight===0)continue;const $n=(rn.querySelector(".ev-marker-inner, .ev-cluster-inner")??rn).getBoundingClientRect(),Fs=$n.left+$n.width/2-Le.left,yo=$n.top-Le.top,es=$n.bottom-Le.top,sr=Math.max(Se,Math.min(Fs,Ye));let Ln,ar;if(yo>=ue)Ln=yo,ar=ue;else if(es<=xe)Ln=es,ar=xe;else continue;const ts=document.createElementNS(Ze,"path");ts.setAttribute("d",`M ${Fs.toFixed(1)} ${Ln.toFixed(1)} L ${sr.toFixed(1)} ${ar.toFixed(1)}`),Et.appendChild(ts)}Y.replaceChildren(Et)},[]),Jr=f.useCallback(()=>{var ke;const Y=H.current&&B.current!=null,de=(((ke=O.current)==null?void 0:ke.childElementCount)??0)>0;!Y&&!de||E.current==null&&(E.current=requestAnimationFrame(()=>{E.current=null,mo()}))},[mo]),Ls=f.useCallback((Y,de)=>{const ke=i.current;for(const[ze,st]of $.current){if(!ke.get(ze))continue;const Le={};for(const V of st)Le[V]=!0;ke.update({id:ze,subgroupVisibility:Le})}if($.current.clear(),!Y||Y.length===0||de==null)return;const Re=y.current.get(de),Te=x.current.get(de),Ie=a.current.get(`pr:${de}`),Xe=Te?Oo(Te):Ie&&typeof Ie.group=="string"?Ie.group:null,Ke=a.current.get();for(const ze of Y){const st=new Set(["cross"]);ze===Xe&&Re!=null&&(st.add(`bar:${Re}`),st.add(`ev:${Re}`));const Le=new Set;for(const ue of Ke)ue.group===ze&&typeof ue.subgroup=="string"&&Le.add(ue.subgroup);const V=[...Le].filter(ue=>!st.has(ue)),xe={};for(const ue of V)xe[ue]=!1;for(const ue of Le)st.has(ue)&&(xe[ue]=!0);Object.keys(xe).length!==0&&(ke.update({id:ze,subgroupVisibility:xe}),V.length&&$.current.set(ze,V))}},[]),gs=f.useCallback(Y=>{const de=a.current,ke=[];for(const Re of de.getIds()){const Te=String(Re);if(!Te.startsWith("pr:"))continue;const Ie=de.get(Re);if(!Ie||typeof Ie.className!="string")continue;const Xe=Number.parseInt(Te.slice(3),10),Ke=Ie.className.includes("pr-focus-hidden"),ze=Y!=null&&Xe!==Y;ze&&!Ke?ke.push({id:Re,className:`${Ie.className} pr-focus-hidden`}):!ze&&Ke&&ke.push({id:Re,className:Ie.className.replace(/\s*pr-focus-hidden/g,"")})}ke.length&&de.update(ke)},[]),Ot=f.useCallback(Y=>{Xr(null);const de=H.current;Ls((Y==null?void 0:Y.groupIds)??null,(Y==null?void 0:Y.prId)??null),Zr((Y==null?void 0:Y.groupIds)??null),Ra((Y==null?void 0:Y.prId)??null),Tr((Y==null?void 0:Y.eventId)??null);const ke=!!(Y!=null&&Y.groupIds&&Y.groupIds.length>0);if(oe(ke),ke||(H.current=!1,B.current=null),ke&&(Y==null?void 0:Y.prId)!=null){const Re=G.getState();Re.selectedPrId!==Y.prId&&Re.selectPr(Y.prId)}if(!ke&&de&&(gs(null),Tn()),!ke&&S.current.size>0)for(const Re of S.current)Br(Re,!0)},[Ls,Zr,Ra,Tr,Xr,gs,Tn,Br]),oi=f.useCallback(Y=>{H.current||Ot(Y)},[Ot]),en=f.useCallback(()=>{const Y=r.current;return Y?Y.querySelector(".vis-panel.vis-left.vis-vertical-scroll")??Y.querySelector(".vis-panel.vis-right.vis-vertical-scroll"):null},[]),Ia=f.useCallback(()=>{const Y=ee.current,de=r.current;if(!Y||!de)return;const ke=()=>{Y.style.display!=="none"&&(Y.style.display="none")},Re=en();if(!Re){ke();return}const Ie=(Y.parentElement??de).getBoundingClientRect(),Xe=Re.getBoundingClientRect(),Ke=Xe.top,ze=1;let st=null;for(const Se of de.querySelectorAll(".vis-labelset .vis-label.tl-repo-header")){const Ye=Se.getBoundingClientRect();Ye.height<1||Ye.top<=Ke+ze&&(st=Se)}if(!st){ke();return}if(st.getBoundingClientRect().top>=Ke-ze){ke();return}const xe=((st.querySelector(".vis-inner")??st).textContent??"").trim();if(!xe){ke();return}const ue=[...st.classList].find(Se=>Se.startsWith("tl-repo-tint-"))??"";Y.dataset.repo!==xe&&(Y.textContent=xe,Y.dataset.repo=xe),Y.dataset.tint!==ue&&(Y.className=`tl-repo-sticky${ue?` ${ue}`:""}`,Y.dataset.tint=ue),Y.style.left=`${Xe.left-Ie.left}px`,Y.style.top=`${Xe.top-Ie.top}px`,Y.style.width=`${Xe.width}px`,Y.style.display!=="block"&&(Y.style.display="block")},[en]),$r=f.useCallback(()=>{K.current==null&&(K.current=requestAnimationFrame(()=>{K.current=null,Ia()}))},[Ia]),Ta=f.useCallback(()=>{const Y=en(),de=r.current;if(!Y||!de)return null;const ke=Y.getBoundingClientRect().top;let Re=null,Te=0,Ie=1/0;for(const Xe of de.querySelectorAll(".vis-labelset .vis-label")){const Ke=Xe.getBoundingClientRect();if(Ke.height<4||Ke.bottom<=ke+1)continue;const ze=[...Xe.classList].find(Le=>Le.startsWith("tlg-"));if(!ze)continue;const st=Math.abs(Ke.top-ke);st<Ie&&(Ie=st,Re=ze,Te=Ke.top-ke)}return{token:Re,offset:Te,scrollTop:Y.scrollTop}},[en]),Js=f.useCallback((Y,de)=>{const ke=s.current,Re=h.current;if(!ke||!Re)return;const Te=(de==null?void 0:de.pr)??x.current.get(Y);if(!Te)return;ne(null);let Ie=1/0,Xe=-1/0;const Ke=st=>{st<Ie&&(Ie=st),st>Xe&&(Xe=st)};Ke(new Date(Te.openedAt).getTime()),Ke(rB(Te));for(const st of Re.events)st.prId===Y&&Ke(new Date(st.occurredAt).getTime());const ze=N1(Te,k.current??[]);if((de==null?void 0:de.fitWindow)!==!1&&Number.isFinite(Ie)&&Number.isFinite(Xe)){const st=Math.max((Xe-Ie)*.08,G8);ke.setWindow(Ie-st,Xe+st,{animation:!1}),It(Le=>Le+1)}H.current=!0,B.current=Y,Ot({groupIds:ze.length?ze:null,prId:Y,eventId:(de==null?void 0:de.anchorEventId)??null}),Tn(),gs(Y),ke.setSelection([`pr:${Y}`]),(de==null?void 0:de.anchorEventId)!=null&&Tr(de.anchorEventId)},[Ot,Tn,gs,Tr]),_r=f.useCallback(Y=>{const de=en();if(!de||s.current==null||!de.isConnected)return;const ke=Math.max(0,de.scrollHeight-de.clientHeight);de.scrollTop=Math.max(0,Math.min(ke,Y)),de.dispatchEvent(new Event("scroll"))},[en]),tn=f.useRef(!1),$a=f.useRef(0),Gt=f.useCallback((Y,de,ke=".ev-cross-linked",Re=".pr-cross-linked")=>{const Te=r.current,Ie=en(),Xe=Te==null?void 0:Te.querySelector(".vis-panel.vis-center");if(!Te||!Ie||!Xe)return;const Ke=`.vis-labelset .vis-label.${Y}`;let ze;const st=Ze=>{const Et=Xe.getBoundingClientRect(),At=Ze.getBoundingClientRect();return At.top+At.height/2-Et.top-Et.height/2},Le=()=>{const Ze=rn=>[...Te.querySelectorAll(rn)].filter(Xn=>Xn.offsetHeight>0).sort((Xn,$n)=>$n.offsetHeight-Xn.offsetHeight)[0];if(de){const rn=Ze(ke);if(rn)return{delta:st(rn),settleable:!0};const Xn=Te.querySelector(`.vis-foreground .vis-group.${Y}`);if(Xn){const $n=Xe.getBoundingClientRect();return{delta:Xn.getBoundingClientRect().bottom-12-($n.top+$n.height/2),settleable:!1}}return null}if(ze&&ze.isConnected&&ze.offsetHeight>0)return{delta:st(ze),settleable:!0};const Et=Ze(Re);if(Et)return ze=Et,{delta:st(Et),settleable:!0};const At=Te.querySelector(Ke);return At?{delta:st(At),settleable:!0}:null},V=Te.querySelector(Ke);V&&_r(V.offsetTop-8);let xe=0,ue=0;const Se=++$a.current;tn.current=!0,window.setTimeout(()=>{$a.current===Se&&(tn.current=!1)},2500);const Ye=()=>{if($a.current!==Se)return;const Ze=Le();Ze!=null&&(Math.abs(Ze.delta)>6?(_r(Ie.scrollTop+Ze.delta),ue=0):Ze.settleable?ue+=1:ue=0),ue<6&&xe++<90?requestAnimationFrame(Ye):tn.current=!1};requestAnimationFrame(()=>requestAnimationFrame(Ye))},[en,_r]),_a=f.useCallback(Y=>{const de=r.current,ke=()=>{var Ke;const Xe=en();if(!Xe||!de)return!0;if(Y.token){const ze=de.querySelector(`.vis-labelset .vis-label.${Y.token}`);if(ze&&ze.offsetHeight>0){const Le=ze.getBoundingClientRect().top-Xe.getBoundingClientRect().top-Y.offset;return Math.abs(Le)>1?(_r(Xe.scrollTop+Le),!1):!0}}return _r(Y.scrollTop),Math.abs((((Ke=en())==null?void 0:Ke.scrollTop)??Y.scrollTop)-Y.scrollTop)<=2};ke();let Re=0,Te=0;const Ie=()=>{ke()?Te+=1:Te=0,Te<3&&Re++<30&&requestAnimationFrame(Ie)};requestAnimationFrame(Ie)},[en,_r]),ea=f.useCallback((Y,de,ke)=>{ke.length!==0&&(N.current||Ot(null),$e(null),ne({x:Y,y:de,eventIds:ke}))},[Ot]),Pa=f.useCallback(()=>{ne(null),N.current||Ot(null)},[Ot]),Mn=f.useCallback(()=>{ae.current?Pa():N.current||(Ft.current!=null?G.getState().clearSelection():L.current!=null&&Xr(null))},[Pa,Xr]),Ea=f.useCallback(()=>{ne(null)},[]);f.useEffect(()=>{yn(J&&!Fe?J.eventIds[0]??null:null)},[J,Fe,yn]);const fs=(J==null?void 0:J.eventIds[0])??null;f.useEffect(()=>{if(fs==null)return;const Y=c.current.get(fs);(Y==null?void 0:Y.prId)!=null&&G.getState().selectPr(Y.prId)},[fs]);const xs=f.useCallback(Y=>{const de=qt.current.get(Y.repoId),ke=Y.authorId!=null?g.current.get(Y.authorId):void 0;return{id:Y.id,number:Y.number,title:Y.title,repoFullName:(de==null?void 0:de.fullName)??`repo ${Y.repoId}`,authorLogin:(ke==null?void 0:ke.githubLogin)??null,authorDisplayName:(ke==null?void 0:ke.displayName)??null,authorAvatarUrl:(ke==null?void 0:ke.avatarUrl)??null}},[]);f.useEffect(()=>{if(!r.current)return;const{from:Y,to:de}=rh(G.getState()),{start:ke,end:Re}=T1(Y,de),Te=new c$(r.current,a.current,i.current,{...V8,start:ke,end:Re,zoomKey:eB(),...n!=null?{zoomMin:K8}:{}});Te.on("click",ze=>{var Ye,Ze,Et;const st=ze.item,Le=((Ye=ze.event)==null?void 0:Ye.srcEvent)??ze.event,V=(Le==null?void 0:Le.clientX)??ze.pageX??0,xe=(Le==null?void 0:Le.clientY)??ze.pageY??0,ue=(Le==null?void 0:Le.target)??null;if((Ze=ue==null?void 0:ue.closest)!=null&&Ze.call(ue,"[data-collapse-gid]")||(Et=ue==null?void 0:ue.closest)!=null&&Et.call(ue,"[data-user-gid]"))return;if(st==null){if(((Le==null?void 0:Le.detail)??0)>=2)return;Mn();return}const Se=String(st);if(Se.startsWith("pr:"))ae.current&&!H.current&&!N.current&&Pa(),Je(Number.parseInt(Se.slice(3),10));else if(Se.startsWith("ev:")){const At=Number.parseInt(Se.slice(3),10);if(H.current){Tr(At),ea(V,xe,[At]);return}ea(V,xe,[At])}else if(Se.startsWith("cl:")){const At=d.current.get(Se)??[];if(At.length===0)return;const rn=At[0];if(H.current){Tr(rn),ea(V,xe,At);return}ea(V,xe,At)}}),Te.on("doubleClick",ze=>{const st=ze.item;if(st==null||H.current)return;const Le=String(st);if(Le.startsWith("pr:")){const V=Number.parseInt(Le.slice(3),10),xe=x.current.get(V);xe&&Ge.getState().openPrFocusTab(xs(xe));return}if(Le.startsWith("ev:")||Le.startsWith("cl:")){const xe=(Le.startsWith("ev:")?[Number.parseInt(Le.slice(3),10)]:d.current.get(Le)??[])[0]??null;if(xe==null)return;const ue=c.current.get(xe);if((ue==null?void 0:ue.prId)==null)return;const Se=x.current.get(ue.prId);Se&&Ge.getState().openPrFocusTab(xs(Se))}});let Ie=null,Xe=null;Te.on("rangechanged",()=>{const ze=Te.getWindow(),st=ze.end.valueOf()-ze.start.valueOf(),Le=W.current;if(Le==null||Math.abs(st-Le)/Le>.02){Ie&&clearTimeout(Ie);const Ye=()=>{if(tn.current){Ie=setTimeout(Ye,120);return}Ie=null;const Ze=Ta();Tn(),Te.redraw(),Ze&&_a(Ze)};Ie=setTimeout(Ye,120)}const xe=A.current;if(xe==null||H.current||N.current)return;const ue=Te.getWindow(),Se=ue.end.valueOf()-ue.start.valueOf();Math.abs(Se-xe)/xe<=.02||(Xe&&clearTimeout(Xe),Xe=setTimeout(()=>It(Ye=>Ye+1),160))}),Te.on("changed",Jr);const Ke=en();return Ke==null||Ke.addEventListener("scroll",Jr,{passive:!0}),Te.on("changed",$r),Ke==null||Ke.addEventListener("scroll",$r,{passive:!0}),window.addEventListener("resize",$r,{passive:!0}),$r(),s.current=Te,()=>{$a.current+=1,tn.current=!1,Ie&&clearTimeout(Ie),Xe&&clearTimeout(Xe),Ke==null||Ke.removeEventListener("scroll",Jr),Ke==null||Ke.removeEventListener("scroll",$r),window.removeEventListener("resize",$r),E.current!=null&&(cancelAnimationFrame(E.current),E.current=null),K.current!=null&&(cancelAnimationFrame(K.current),K.current=null),Te.destroy(),s.current=null}},[Je,Tn,ea,Mn,Pa,Tr,xs,Ta,_a,Jr,$r,en,n]),f.useEffect(()=>{const Y=r.current;if(!Y)return;const de=ke=>{var ze;const Re=ke.target,Te=(ze=Re==null?void 0:Re.closest)==null?void 0:ze.call(Re,"[data-collapse-gid]");if(!Te)return;const Ie=Te.getAttribute("data-collapse-gid");if(!Ie||(ke.stopPropagation(),ke.preventDefault(),H.current||N.current))return;const Xe=!S.current.has(Ie);Br(Ie,Xe),Te.innerHTML=Xe?TC:$C;const Ke=Xe?"Expand row":"Collapse row";Te.setAttribute("title",Ke),Te.setAttribute("aria-label",Ke)};return Y.addEventListener("click",de,!0),()=>Y.removeEventListener("click",de,!0)},[Br]),f.useEffect(()=>{const Y=r.current;if(!Y)return;const de=ke=>{var st;if(ke.button!==0||ke.metaKey||ke.ctrlKey||ke.shiftKey||ke.altKey)return;const Re=ke.target,Te=(st=Re==null?void 0:Re.closest)==null?void 0:st.call(Re,"[data-user-gid]");if(!Te)return;const Ie=Te.getAttribute("data-user-gid");if(!Ie)return;const Xe=/^repo:(\d+):user:(\d+)$/.exec(Ie);if(!Xe)return;const Ke=Number(Xe[1]),ze=Number(Xe[2]);!Number.isFinite(ze)||!Number.isFinite(Ke)||(ke.stopPropagation(),ke.preventDefault(),ne(null),$e(Le=>Le&&Le.gid===Ie?null:{gid:Ie,uid:ze,repoId:Ke,x:ke.clientX,y:ke.clientY}))};return Y.addEventListener("click",de,!0),()=>Y.removeEventListener("click",de,!0)},[]),f.useEffect(()=>{const Y=r.current;if(!Y)return;const de=ke=>{const Re=ke.target;!Re||!Re.isConnected||Re.closest(".vis-timeline")||Mn()};return Y.addEventListener("click",de),()=>Y.removeEventListener("click",de)},[Mn]);const Gi=f.useCallback((Y,de)=>{z.current!=null&&(cancelAnimationFrame(z.current),z.current=null);const ke=ze=>{const st=s.current;if(!st||ze<=0)return;const Le=st.getWindow();Z8(Y,(Le.end.valueOf()-Le.start.valueOf())/ze),a.current.update(Y),te.current=ze,de==null||de()},Re=I1(s.current,r.current);if(Re>0&&Math.abs(Re-te.current)<1){ke(Re);return}let Te=-1,Ie=0,Xe=0;const Ke=()=>{const ze=I1(s.current,r.current);if(ze>0&&ze===Te?Ie+=1:(Ie=0,Te=ze),ze>0&&Ie>=2||Xe++>40){z.current=null,ke(ze);return}z.current=requestAnimationFrame(Ke)};z.current=requestAnimationFrame(Ke)},[]);f.useEffect(()=>()=>{z.current!=null&&cancelAnimationFrame(z.current)},[]),f.useEffect(()=>{let Y=null;const de=()=>{Y&&clearTimeout(Y),Y=setTimeout(()=>It(ke=>ke+1),200)};return window.addEventListener("resize",de),()=>{window.removeEventListener("resize",de),Y&&clearTimeout(Y)}},[]);const go=f.useRef(!1);f.useEffect(()=>{const Y=()=>{!document.hidden&&go.current&&(go.current=!1,It(de=>de+1))};return document.addEventListener("visibilitychange",Y),()=>document.removeEventListener("visibilitychange",Y)},[]),f.useEffect(()=>{var na;if(!re)return;if(h.current=re,document.hidden){go.current=!0;return}go.current=!1;const Y=M.current,de=Y&&!re.prs.some(qe=>qe.id===Y.id)?[...re.prs,Y]:re.prs,ke=Bt&&Bt.length>0?new Set(Bt):null,Re=qe=>!ke||qe.authorId!=null&&ke.has(qe.authorId),Te=Ce.length>0,Ie=new Set;if(Te){const qe=new Set(Ce);for(const ut of re.events)ut.type==="review_comment"&&ut.prId!=null&&ut.derivedState!=null&&qe.has(ut.derivedState)&&Ie.add(ut.prId)}const Xe=qe=>!Te||Ie.has(qe.id),Ke=de.filter(qe=>qe.id===n||qe.id===Ft.current||qe.id===(Y==null?void 0:Y.id)||Re(qe)&&Xe(qe));b.current={active:Te,states:Ce},w.current=_e;const ze=new Map;for(const qe of re.events)ze.set(qe.id,qe);c.current=ze;const st=new Set;for(const qe of Ir??re.events)qe.prId!=null&&(qe.type==="review_comment"||qe.type==="pr_comment")&&st.add(qe.prId);const Le=(na=s.current)==null?void 0:na.getWindow();A.current=Le?Le.end.valueOf()-Le.start.valueOf():null;const V=D8(de);y.current=V;let xe=re.events;if(Ir!=null)xe=Ir;else if(n==null&&!H.current&&Te){const qe=new Set(Ce);xe=re.events.filter(ut=>ut.type==="review_comment"&&ut.prId!=null&&ut.derivedState!=null&&qe.has(ut.derivedState))}const ue=R1([...Ke.map(qe=>qe.repoId),...xe.map(qe=>qe.repoId)]).sort((qe,ut)=>{const or=Pt.get(qe),Fn=Pt.get(ut);return!or||!Fn?(or?0:1)-(Fn?0:1)||qe-ut:or.owner.localeCompare(Fn.owner)||or.name.localeCompare(Fn.name)||qe-ut}),Se=[],Ye=0,Ze=1e6;ue.forEach((qe,ut)=>{const or=R1([...xe.filter(qn=>qn.repoId===qe&&qn.actorId!=null).map(qn=>qn.actorId),...Ke.filter(qn=>qn.repoId===qe&&qn.authorId!=null).map(qn=>qn.authorId)]),Fn=Wn.get(qe),ra=or.map(qn=>`repo:${qe}:user:${qn}`),sa=`tl-repo-tint-${ut%Y8}`,Qi=Pt.get(qe),Yi=(Qi==null?void 0:Qi.fullName)??`repo ${qe}`,Xi=kn(Yi);Se.push({id:`repo:${qe}`,content:Xi,nestedGroups:ra.length?ra:void 0,treeLevel:1,order:ut,subgroupOrder:"sortKey",className:`tl-repo-header ${sa}`}),or.forEach((qn,Pr)=>{const ys=`repo:${qe}:user:${qn}`,Zi=(Fn==null?void 0:Fn.has(qn))??!1;Se.push({id:ys,content:J8(y8(fr.get(qn),qn,Zi,ys,S.current.has(ys))),treeLevel:2,order:(Zi?Ye:Ze)+Pr,subgroupOrder:"sortKey",heightMode:S.current.has(ys)?"auto":"fixed",className:`tl-user-row ${Nl(ys)} ${sa}`})})});const Et=H.current?B.current:null,At=Ke.map(qe=>{const ut=qe.authorId!=null?fr.get(qe.authorId):void 0,or=Oo(qe),Fn=V.get(qe.id)??0,ra={author:{label:Dt(ut,qe.authorId),avatarUrl:(ut==null?void 0:ut.avatarUrl)??null},hasComments:st.has(qe.id)};return{id:`pr:${qe.id}`,group:or,subgroup:`bar:${Fn}`,sortKey:Fn*2,type:"range",start:qe.openedAt,end:qe.mergedAt??qe.closedAt??new Date().toISOString(),content:m8(qe,ra),className:(()=>{const sa=f8(qe,ra.hasComments);return Et!=null&&qe.id!==Et?`${sa} pr-focus-hidden`:sa})(),title:g8(qe,ra)}}),rn=s.current,Xn=rn==null?void 0:rn.getWindow(),$n=Y?null:Ta(),Fs=tn.current,yo=new Set(Se.map(qe=>String(qe.id)));i.current.update(Se);const es=i.current.getIds().map(String).filter(qe=>!yo.has(qe));es.length&&i.current.remove(es);const sr=new Set(At.map(qe=>String(qe.id))),Ln=a.current.getIds().map(String).filter(qe=>qe.startsWith("pr:")&&!sr.has(qe));if(a.current.update(At),Ln.length&&a.current.remove(Ln),Gi(At,()=>{$n&&!tn.current&&!Fs&&_a($n)}),Tn(),rn&&Xn){const qe=rn.getWindow();(qe.start.valueOf()!==Xn.start.valueOf()||qe.end.valueOf()!==Xn.end.valueOf())&&rn.setWindow(Xn.start,Xn.end,{animation:!1})}const ar=Ft.current;if(ar!=null&&rn&&a.current.get(`pr:${ar}`)&&!rn.getSelection().map(String).includes(`pr:${ar}`)&&rn.setSelection([`pr:${ar}`]),j.current!=null){const qe=j.current;j.current=null,Ra(qe)}const ts=n!=null&&Ir!=null&&H.current&&B.current===n?re.prs.find(qe=>qe.id===n)??null:null;if(ts!=null&&Ir!=null){const qe=N1(ts,Ir);Ls(qe,ts.id),Zr(qe)}else N.current&&Zr(N.current);if(H.current&&B.current!=null&&gs(B.current),!N.current&&!H.current&&S.current.size>0)for(const qe of S.current)Br(qe,!0);const Ma=M.current;(!Ma||re.prs.some(qe=>qe.id===Ma.id)||Ft.current!==Ma.id&&B.current!==Ma.id)&&(M.current=null),$n&&!tn.current&&_a($n)},[re,Ce,Ne,Bt,Pt,fr,Wn,fe,et,Ir,Tn,Ra,Ls,Zr,gs,Br,Ta,_a,Gi]),f.useEffect(()=>{w.current=_e,n==null&&s.current&&h.current&&Tn()},[_e,Tn,n]),f.useEffect(()=>{Ft.current=Qt;const Y=s.current;if(!Y)return;if(Qt!=null&&!a.current.get(`pr:${Qt}`)){rt(Te=>Te+1);return}const de=Qt!=null?[`pr:${Qt}`]:[],ke=Y.getSelection().map(String);ke.length===de.length&&de.every(Te=>ke.includes(Te))||Y.setSelection(de)},[Qt]);const fo=f.useRef(!1);f.useEffect(()=>{if(n==null||fo.current||!s.current||!h.current)return;G.getState().selectedPrId!==n&&G.getState().selectPr(n);const de=x.current.get(n)??(re==null?void 0:re.prs.find(Xe=>Xe.id===n))??(Ne==null?void 0:Ne.prs.find(Xe=>Xe.id===n))??(be==null?void 0:be.prs.find(Xe=>Xe.id===n));if(!de)return;fo.current=!0,Js(n,{fitWindow:!0,pr:de});const ke=Nl(Oo(de)),Re=G.getState(),Ie=Re.timelineFocusPr===n&&Re.timelineFocusEvent!=null?null:window.setTimeout(()=>Gt(ke,!1),320);return()=>{Ie!=null&&window.clearTimeout(Ie)}},[n,re,Ne,be,Js,Gt]),f.useEffect(()=>{const Y=s.current;if(!Y||n!=null)return;const{from:de,to:ke}=rh(G.getState()),{start:Re,end:Te}=T1(de,ke);Y.setWindow(Re,Te,{animation:!1})},[Wt,St,je,Rt,n]);const Aa=G(Y=>Y.timelineCenterAt);return f.useEffect(()=>{if(Aa==null)return;const Y=s.current;if(!Y)return;const de=Y.getWindow(),ke=de.end.valueOf()-de.start.valueOf();Y.setWindow(Aa-ke/2,Aa+ke/2,{animation:!0}),G.getState().consumeTimelineCenter()},[Aa]),f.useEffect(()=>{if(xr==null)return;const Y=s.current;if(!Y||re==null)return;const de=re==null?void 0:re.prs.find(Ie=>Ie.id===xr);if(de){const Ie=G.getState().timelineFocusEvent;if(Ie&&re){const Le=S1(re.events,xr,Ie,hs),V=(Le==null?void 0:Le.actorId)??de.authorId,xe=Le!=null&&(a.current.get(`ev:${Le.id}`)!=null||u.current.get(Le.id)!=null);if(hs){const ue=Date.parse(hs),Se=Y.getWindow(),Ye=Se.end.valueOf()-Se.start.valueOf();n!=null&&Number.isFinite(ue)&&ue>=Se.start.valueOf()&&ue<=Se.end.valueOf()||Y.setWindow(ue-Ye/2,ue+Ye/2,{animation:!0})}if(Y.setSelection([`pr:${xr}`]),Le!=null&&Tr(Le.id),V!=null){const ue=Nl(`repo:${de.repoId}:user:${V}`);window.setTimeout(()=>Gt(ue,xe),120)}G.getState().consumeTimelineFocus();return}const Xe=Y.getWindow(),Ke=Xe.end.valueOf()-Xe.start.valueOf();let ze;if(hs)ze=Date.parse(hs);else{const Le=new Date(de.openedAt).getTime(),V=new Date(de.mergedAt??de.closedAt??new Date().toISOString()).getTime();ze=(Le+V)/2}Y.setWindow(ze-Ke/2,ze+Ke/2,{animation:!0}),Y.setSelection([`pr:${xr}`]);const st=Nl(Oo(de));window.setTimeout(()=>{Gt(st,!1,".ev-cross-linked",".pr-bar.vis-selected")},120),G.getState().consumeTimelineFocus();return}const ke=Ie=>{M.current=Ie,rt(Ke=>Ke+1);const Xe=Nl(Oo(Ie));D.current!=null&&window.clearTimeout(D.current),D.current=window.setTimeout(()=>{D.current=null,Y.setSelection([`pr:${Ie.id}`]),Gt(Xe,!1,".ev-cross-linked",".pr-bar.vis-selected")},360),G.getState().consumeTimelineFocus()};if(n==null&&Ve==null&&me)return;const Re=re&&!re.prs.some(Ie=>Ie.id===xr)?Ve==null?void 0:Ve.prs.find(Ie=>Ie.id===xr):void 0;if(Re){ke(Re);return}const Te=(Ne==null?void 0:Ne.prs.find(Ie=>Ie.id===xr))??(be==null?void 0:be.prs.find(Ie=>Ie.id===xr));if(Te){const{from:Ie}=rh(G.getState()),Xe=new Date(Te.openedAt).getTime();if(Xe<Ie.getTime()){const Ke=new Date(Xe-864e5).toISOString().slice(0,10),ze=new Date().toISOString().slice(0,10);G.getState().setCustomRange(Ke,ze);return}if(re&&!re.prs.some(Ke=>Ke.id===Te.id)){ke(Te);return}}G.getState().consumeTimelineFocus()},[xr,hs,re,Ne,Ve,me,be,Gt,Tr,n]),t.jsxs("div",{className:`relative h-full w-full${Fe?" tl-focus-active":""}`,children:[X&&!re&&t.jsx(sB,{}),le&&t.jsx("div",{className:"absolute inset-0 flex items-center justify-center text-sm text-red-500",children:String(le)}),re&&re.prs.length===0&&re.events.length===0&&t.jsx("div",{className:"absolute inset-0 flex items-center justify-center text-sm text-gray-500 dark:text-gray-400",children:"No activity in this window. Add a repo or widen the date range."}),t.jsx("div",{ref:r,className:"h-full w-full"}),t.jsx("svg",{ref:O,className:"tl-cross-connectors","aria-hidden":"true",style:{display:"none"}}),t.jsx("div",{ref:ee,className:"tl-repo-sticky","aria-hidden":"true",style:{display:"none"}}),J&&t.jsx(H8,{state:J,eventsById:c.current,usersById:fr,prsById:uo,focusPrId:Fe?B.current:null,onContextFocus:oi,onDismiss:Pa,onNavigate:Ea}),we&&t.jsx(L5,{userId:we.uid,user:fr.get(we.uid),repoId:we.repoId,anchor:{kind:"selector",selector:`[data-user-gid="${we.gid}"]`,x:we.x,y:we.y},onDismiss:()=>$e(null)})]})}const uh=wd;function aB(e){return uh.reduce((n,r)=>n+e[r],0)}function Xp({counts:e,compact:n=!1,activeState:r=null,onSegmentClick:s,className:a=""}){const i=aB(e);return n?t.jsx("span",{className:`inline-flex h-1.5 w-16 overflow-hidden rounded-full bg-gray-200 dark:bg-gray-700 ${a}`,"aria-hidden":"true",children:i>0&&uh.map(c=>e[c]>0?t.jsx("span",{style:{width:`${e[c]/i*100}%`,background:Xt[c].color}},c):null)}):t.jsxs("div",{className:a,children:[t.jsx("div",{className:"flex h-2.5 w-full overflow-hidden rounded-full bg-gray-200 dark:bg-gray-700",children:i===0?null:uh.map(c=>{if(e[c]===0)return null;const d=Xt[c],u=t.jsx("span",{title:`${d.label}: ${e[c]}`,style:{width:`${e[c]/i*100}%`,background:d.color,opacity:r==null||r===c?1:.35},className:"block h-full"},c);return s?t.jsx("button",{type:"button",onClick:()=>s(c),title:`${d.label}: ${e[c]} — click to filter`,style:{width:`${e[c]/i*100}%`,background:d.color,opacity:r==null||r===c?1:.35},className:"block h-full transition-opacity hover:opacity-100","aria-pressed":r===c},c):u})}),t.jsxs("div",{className:"mt-1 flex flex-wrap gap-x-3 gap-y-0.5",children:[uh.map(c=>{const d=Xt[c],u=r===c,m=r!=null&&!u,h=t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"inline-block h-2 w-2 rounded-full",style:{background:d.color}}),t.jsx("span",{className:"tabular-nums",children:e[c]}),t.jsx("span",{children:d.label.toLowerCase()})]}),g=`flex items-center gap-1 text-[10px] ${m?"text-gray-400 opacity-60":"text-gray-600 dark:text-gray-300"}`;return s?t.jsx("button",{type:"button",onClick:()=>s(c),className:`${g} hover:underline`,"aria-pressed":u,title:d.description,children:h},c):t.jsx("span",{className:g,title:d.description,children:h},c)}),t.jsx("span",{className:"ml-auto text-[10px] tabular-nums text-gray-400",children:i})]})]})}function oB(e,n){return Oe({queryKey:["repo-digest",e],queryFn:()=>he.repoDigest(e),enabled:n&&e!=null,staleTime:1/0})}function iB(e,n){e.setQueriesData({queryKey:["repo-digests"]},r=>{if(!r)return r;const s=r.digests.findIndex(i=>i.repoId===n.repoId);if(s===-1)return r;const a=r.digests.slice();return a[s]=n,{...r,digests:a}})}const lB=5e3;function cB(e){return!e||e.total<=0?{value:null}:{value:e.completed/e.total*100,sub:`${e.completed}/${e.total}`}}function dB(){const e=He(),[n,r]=f.useState(!1),[s,a]=f.useState(()=>new Set),[i,c]=f.useState(null),[d,u]=f.useState(null),m=f.useRef(null);return f.useEffect(()=>()=>{var g;return(g=m.current)==null?void 0:g.abort()},[]),f.useEffect(()=>{if(d==null)return;const g=window.setTimeout(()=>u(null),lB);return()=>window.clearTimeout(g)},[d]),{mutate:f.useCallback(g=>{var T;(T=m.current)==null||T.abort();const x=new AbortController;m.current=x,r(!0),u(null),a(new Set),c(null);const y=$=>a(P=>{if(!P.has($))return P;const C=new Set(P);return C.delete($),C}),b=g==null?void 0:Array.isArray(g)?g.length>0?`repoIds=${g.join(",")}`:void 0:`repoIds=${g}`,w=`/api/pro/activity/digests/refresh/stream${b?`?${b}`:""}`;let k=!1,j=!1,N=[],I=0,S=0;Pd(w,{method:"POST",signal:x.signal,onEvent:$=>{switch($.type){case"start":$.throttled&&(k=!0),$.creditsExhausted&&(j=!0);break;case"plan":N=$.toRegenerate,I=N.length,a(new Set(N)),c({completed:0,total:I});break;case"repo":S+=1,c({completed:S,total:I}),e.setQueryData(["repo-digest",$.digest.repoId],$.digest),iB(e,$.digest),y($.digest.repoId);break;case"error":S+=1,c({completed:S,total:I}),y($.repoId);break}}}).catch(()=>{}).finally(()=>{if(m.current===x){m.current=null,r(!1),a(new Set),c(null),u(j?"Out of AI credits this month — summaries resume on the 1st.":k?"Refreshed moments ago — showing the latest. Try again shortly.":I===0?"Already up to date — no new activity since the last digest.":null),e.invalidateQueries({queryKey:["ai-usage"]});for(const $ of N)e.invalidateQueries({queryKey:["repo-digest",$]});N.length>0&&e.invalidateQueries({queryKey:["repo-digests"]})}})},[e]),isPending:n,refreshingRepoIds:s,progress:i,notice:d}}function uB(e){return{id:e.prId,number:e.prNumber,title:e.title??`#${e.prNumber}`,repoFullName:e.repoFullName,authorLogin:null,authorDisplayName:null,authorAvatarUrl:null}}function hB(){const e=Ge(n=>n.openPrDetailTab);return n=>{n.prId!=null&&e(uB(n),{fromActivity:!0})}}const EC="pierre:collapsedDigests";function pB(){try{const e=localStorage.getItem(EC),n=e?JSON.parse(e):[];return new Set(Array.isArray(n)?n.filter(r=>typeof r=="number"):[])}catch{return new Set}}function mB(e){try{localStorage.setItem(EC,JSON.stringify([...e]))}catch{}}const P1=Jo((e,n)=>({collapsed:pB(),toggle:r=>{const s=new Set(n().collapsed);s.has(r)?s.delete(r):s.add(r),mB(s),e({collapsed:s})}})),AC="pierre:insightsDigestsExpanded";function gB(){try{const e=localStorage.getItem(AC),n=e?JSON.parse(e):[];return new Set(Array.isArray(n)?n.filter(r=>typeof r=="number"):[])}catch{return new Set}}Jo((e,n)=>({expanded:gB(),toggle:r=>{const s=new Set(n().expanded);s.has(r)?s.delete(r):s.add(r);try{localStorage.setItem(AC,JSON.stringify([...s]))}catch{}e({expanded:s})}}));const MC="pierre:repoOpenPrsPanel";function fB(){try{const e=localStorage.getItem(MC);return e==null?!0:JSON.parse(e)===!0}catch{return!0}}const E1=Jo((e,n)=>{const r=s=>{try{localStorage.setItem(MC,JSON.stringify(s))}catch{}};return{collapsed:fB(),setCollapsed:s=>{e({collapsed:s}),r(s)},toggle:()=>{const s=!n().collapsed;e({collapsed:s}),r(s)}}});function py(e){const n=new Map,r=new Map;for(const s of e)s.prId!=null&&(n.set(`${s.repoFullName}#${s.prNumber}`,s),r.has(s.prNumber)||r.set(s.prNumber,s));return{byKey:n,byNumber:r}}const my=/([A-Za-z0-9][\w.-]*\/[A-Za-z0-9][\w.-]*)#(\d+)|#(\d+)/.source;function LC(e,n){const r=e[1]!=null,s=Number(r?e[2]:e[3]);return r?n.byKey.get(`${e[1]}#${s}`):n.byNumber.get(s)}function A1(e,n,r,s=""){const a=[];let i=0,c=0;const d=new RegExp(my,"g");let u;for(;(u=d.exec(e))!=null;){u.index>i&&a.push(e.slice(i,u.index));const m=u[1]!=null,h=Number(m?u[2]:u[3]),g=m?n.byKey.get(`${u[1]}#${h}`):n.byNumber.get(h);if(g!=null){const x=`${g.repoFullName}#${g.prNumber}`;a.push(t.jsx("button",{type:"button",onClick:()=>r(g),className:"font-semibold text-sky-600 hover:underline dark:text-sky-400",title:g.title??x,children:x},`${s}r${c++}`))}else a.push(u[0]);i=u.index+u[0].length}return i<e.length&&a.push(e.slice(i)),a}function Ii(e,n,r){return e.split(/(\*\*[^*]+\*\*)/g).flatMap((a,i)=>{const c=/^\*\*([^*]+)\*\*$/.exec(a);return c!=null?[t.jsx("strong",{children:A1(c[1]??"",n,r,`b${i}-`)},`b${i}`)]:A1(a,n,r,`t${i}-`)})}const M1=e=>{const n=e.additions+e.deletions,r=e.openedAt?Math.max(0,(Date.now()-Date.parse(e.openedAt))/36e5):0;return n*r},L1=(e,n)=>M1(n)-M1(e),F1=e=>Number.isFinite(e)&&e>=1e4?`${Math.round(e/1e3)}k`:String(e??0);function Xh(e){return e.replace(/^\|/,"").replace(/\|$/,"").split("|").map(n=>n.trim())}function xB(e){return e.length>0&&e.every(n=>/^:?-{2,}:?$/.test(n))}function yB(e,n){const r=e[n],s=e[n+1];if(r==null||s==null||!r.startsWith("|")||!s.startsWith("|"))return!1;const a=Xh(r),i=Xh(s);return a.length>=2&&xB(i)&&i.length===a.length}function bB(e,n){const r=[],s=new Set,a=new RegExp(my,"g");let i;for(;(i=a.exec(e))!=null;){const c=LC(i,n);if((c==null?void 0:c.prId)!=null){const d=`${c.repoFullName}#${c.prNumber}`;s.has(d)||(s.add(d),r.push(c))}}return r}function vB(e,n){const r=e.replace(new RegExp(my,"g"),(s,...a)=>{const i=a.slice(0,3),c=LC([s,...i],n);return(c==null?void 0:c.prId)!=null?"":s}).replace(/\s{2,}/g," ").replace(/\s*[,;](?:\s*[,;])+\s*/g,", ").replace(/,\s*(?:and|or)\s*,/gi,",").replace(/(^|[:,])\s*(?:and|or)\b\s*/gi,"$1 ").replace(/\s+(?:and|or)\s*([,.;:])/gi,"$1").replace(/:\s*,/g,":").replace(/\s+([,.;:])/g,"$1").replace(/,(?:\s*,)+/g,",").replace(/[\s,;:]+([.!?])/g,"$1").replace(/\s{2,}/g," ").replace(/^[\s:,.\-–—·•]+/,"").replace(/[\s,;:]+$/,"").trim();return/^[a-z]/.test(r)?r[0].toUpperCase()+r.slice(1):r}function kB(e,n){const r=e.split(`
65
+ `).map(d=>d.replace(/`/g,"").trim()).filter(d=>d!==""&&!/^[-–—*_]{3,}$/.test(d)),s=[];let a=[],i=!1;const c=()=>{a.length!==0&&(a.sort((d,u)=>L1(d.prs[0],u.prs[0])),s.push({kind:"prtable",groups:a}),a=[])};for(let d=0;d<r.length;d++){const u=r[d],m=/^#{1,6}\s+(.*)$/.exec(u),h=u.replace(/^[-*]\s+/,"");if(!i){i=!0,s.push({kind:"headline",text:m?m[1]??"":h});continue}if(yB(r,d)){const y=Xh(u),b=[];let w=d+2;for(;w<r.length&&r[w].startsWith("|");w++)b.push(Xh(r[w]));c(),s.push({kind:"mdtable",table:{header:y,rows:b}}),d=w-1;continue}const g=bB(u,n);if(g.length>0){g.sort(L1),a.push({prs:g,summary:vB(h,n)});continue}const x=/^\*\*(.+)\*\*$/.exec(h);c(),m?s.push({kind:"header",text:m[1]}):x?s.push({kind:"subhead",text:x[1]}):s.push({kind:"prose",text:h})}return c(),s}function gy({groups:e,onOpenPr:n,usersById:r,index:s}){return t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"w-full min-w-[852px] table-fixed border-collapse text-[12px]",children:[t.jsxs("colgroup",{children:[t.jsx("col",{style:{width:"320px"}}),t.jsx("col",{style:{width:"24px"}}),t.jsx("col",{style:{width:"84px"}}),t.jsx("col",{style:{width:"110px"}}),t.jsx("col",{style:{width:"104px"}}),t.jsx("col",{})]}),t.jsx("thead",{children:t.jsxs("tr",{className:"text-left text-[9px] font-semibold uppercase tracking-wide text-gray-400",children:[t.jsx("th",{className:"pb-1 pr-2 font-semibold",children:"Pull request"}),t.jsx("th",{className:"pb-1 pr-2 font-semibold",children:"CI"}),t.jsx("th",{className:"pb-1 pr-2 font-semibold",children:"Age"}),t.jsx("th",{className:"pb-1 pr-2 font-semibold",children:"Author"}),t.jsx("th",{className:"pb-1 pr-2 font-semibold",children:"Diff"}),t.jsx("th",{className:"pb-1 font-semibold",children:"Summary"})]})}),t.jsx("tbody",{children:e.map((a,i)=>a.prs.map((c,d)=>{const u=c.ciStatus?Rr[c.ciStatus]:null,m=c.authorId!=null?r.get(c.authorId):void 0;return t.jsxs("tr",{className:"border-t border-gray-100 align-top dark:border-gray-800/60",children:[t.jsx("td",{className:"py-1 pr-2",children:t.jsxs("button",{type:"button",onClick:()=>n(c),className:"block text-left leading-snug hover:underline",title:`${c.repoFullName}#${c.prNumber}${c.title?` — ${c.title}`:""}`,children:[t.jsxs("span",{className:"font-semibold text-sky-600 dark:text-sky-400",children:["#",c.prNumber]})," ",t.jsx("span",{className:"text-gray-700 dark:text-gray-200",children:c.title??""})]})}),t.jsx("td",{className:"py-1 pr-2",children:t.jsx("span",{className:"inline-flex items-center gap-1 text-[11px] text-gray-500 dark:text-gray-400",title:(u==null?void 0:u.label)??"no checks",children:t.jsx("span",{className:"inline-block h-2 w-2 rounded-full",style:u?{background:u.color}:{boxShadow:"inset 0 0 0 1px #9ca3af"},"aria-hidden":!0})})}),t.jsx("td",{className:"whitespace-nowrap py-1 pr-2 text-[11px] text-gray-500 dark:text-gray-400",children:c.openedAt?Nt(c.openedAt):"—"}),t.jsx("td",{className:"overflow-hidden py-1 pr-2",children:t.jsxs("span",{className:"flex min-w-0 items-center gap-1 text-[11px] text-gray-600 dark:text-gray-300",children:[t.jsx("span",{className:"shrink-0",children:t.jsx(gn,{user:m,size:13})}),t.jsx("span",{className:"min-w-0 truncate",children:m?t.jsx(mr,{user:m,fallbackId:c.authorId??0}):c.authorLogin??"—"})]})}),t.jsxs("td",{className:"whitespace-nowrap py-1 pr-2 text-[11px]",children:[t.jsxs("span",{className:"font-mono text-green-600 dark:text-green-400",children:["+",F1(c.additions)]})," ",t.jsxs("span",{className:"font-mono text-red-500 dark:text-red-400",children:["−",F1(c.deletions)]})]}),d===0&&t.jsx("td",{rowSpan:a.prs.length,className:"py-1 align-top text-[12px] leading-relaxed text-gray-700 dark:text-gray-200",children:a.summary?Ii(a.summary,s,n):null})]},`${i}-${c.prId}`)}))})]})})}function wB({table:e,onOpenPr:n,index:r}){return t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"w-full min-w-[480px] border-collapse text-[12px]",children:[t.jsx("thead",{children:t.jsx("tr",{className:"text-left text-[9px] font-semibold uppercase tracking-wide text-gray-400",children:e.header.map((s,a)=>t.jsx("th",{className:"pb-1 pr-2 font-semibold",children:Ii(s,r,n)},a))})}),t.jsx("tbody",{children:e.rows.map((s,a)=>t.jsx("tr",{className:"border-t border-gray-100 align-top dark:border-gray-800/60",children:e.header.map((i,c)=>t.jsx("td",{className:"py-1 pr-2 text-[12px] leading-relaxed text-gray-700 dark:text-gray-200",children:Ii(s[c]??"",r,n)},c))},a))})]})})}function Zp({markdown:e,prRefs:n,onOpenPr:r}){const{data:s}=An(),a=f.useMemo(()=>Rn(s),[s]),i=f.useMemo(()=>py(n),[n]),c=f.useMemo(()=>kB(e,i),[e,i]),d=u=>u;return t.jsx("div",{className:"space-y-1.5",children:c.map((u,m)=>u.kind==="prtable"?t.jsx(gy,{groups:u.groups,onOpenPr:r,usersById:a,index:i},m):u.kind==="mdtable"?t.jsx(wB,{table:u.table,onOpenPr:r,index:i},m):u.kind==="headline"?t.jsx("div",{className:"border-l-2 border-ai-signal-fill pl-2 text-[13px] font-semibold leading-relaxed text-gray-800 dark:text-gray-100",children:d(Ii(u.text??"",i,r))},m):u.kind==="header"?t.jsx("div",{className:"pt-1 text-xs font-semibold uppercase tracking-wide text-gray-500 dark:text-gray-400",children:d(Ii(u.text??"",i,r))},m):u.kind==="subhead"?t.jsx("div",{className:"pt-1.5 text-[12px] font-semibold text-gray-700 dark:text-gray-200",children:d(Ii(u.text??"",i,r))},m):t.jsxs("div",{className:"flex gap-1.5 text-[13px] leading-relaxed text-gray-700 dark:text-gray-200",children:[t.jsx("span",{"aria-hidden":"true",className:"select-none text-gray-400",children:"•"}),t.jsx("span",{className:"min-w-0",children:d(Ii(u.text??"",i,r))})]},m))})}function jB({markdown:e,prRefs:n,onOpenPr:r}){return t.jsx(Zp,{markdown:e,prRefs:n,onOpenPr:r})}function NB(e){if(!e)return"Haiku";const n=e.toLowerCase();return n.includes("haiku")?"Haiku":n.includes("sonnet")?"Sonnet":n.includes("opus")?"Opus":e}function SB({digest:e,isLoading:n,title:r,collapsed:s,onToggle:a,onRegenerate:i,regenerating:c=!1,onOpenPr:d,showProBadge:u=!0,outOfCredits:m=!1}){return t.jsxs("div",{className:"rounded-md border border-ai-border bg-ai-surface px-3 py-2",children:[t.jsxs("div",{onClick:a,className:"-mx-1 flex cursor-pointer select-none items-center gap-2 rounded px-1 hover:bg-ai-signal/5",children:[t.jsxs("button",{type:"button",onClick:h=>{h.stopPropagation(),a()},"aria-expanded":!s,className:"flex min-w-0 items-center gap-1 text-[11px] font-semibold uppercase tracking-wide text-ai-ink hover:text-ai-signal",title:s?"Expand digest":"Collapse digest",children:[t.jsx(Mt,{dir:s?"right":"down",size:10}),t.jsx(Ps,{size:12}),t.jsx("span",{className:"truncate normal-case",children:r})]}),u&&t.jsx("span",{className:"shrink-0 rounded bg-ai-signal/15 px-1 text-[10px] font-semibold text-ai-signal",children:"Pro"}),t.jsxs("span",{className:"ml-auto flex items-center gap-2 text-[10px] text-gray-400",children:[e!=null&&t.jsxs("span",{title:e.model,children:[NB(e.model)," · ",Nt(e.generatedAt),e.stale?" · stale":""]}),i!=null&&t.jsxs("button",{type:"button",onClick:h=>{h.stopPropagation(),i==null||i()},disabled:c||m,className:"flex items-center gap-0.5 rounded border border-ai-border px-1.5 py-0.5 font-medium text-ai-signal hover:border-ai-signal/60 hover:bg-ai-surface-2 disabled:opacity-50",title:m?"Out of AI credits — resets next month":e==null?"Generate this repo's digest (runs the cheap-tier model)":"Regenerate this repo's digest (runs the cheap-tier model)",children:[t.jsx(us,{size:11}),m?"Out of credits":c?e==null?"Generating…":"Regenerating…":e==null?"Generate":"Regenerate"]})]})]}),!s&&t.jsx("div",{className:"mt-1",children:c?t.jsx(CB,{}):n?t.jsx("div",{className:"h-3 w-2/3 animate-pulse rounded bg-ai-surface-2"}):e!=null&&e.summary.trim()!==""?t.jsx("div",{className:"digest-fade-in",children:t.jsx(jB,{markdown:e.summary,prRefs:e.prRefs,onOpenPr:d})},e.generatedAt):t.jsx("p",{className:"text-xs text-gray-400",children:"No digest yet — click Generate to summarise this repo's recent activity."})})]})}function CB(){return t.jsx("div",{className:"space-y-1.5 py-0.5","aria-hidden":"true",children:["92%","80%","66%","74%"].map((e,n)=>t.jsx("div",{className:"digest-skeleton-line h-3",style:{width:e}},n))})}function FC({active:e,label:n="Regenerating digests",timeConstantSec:r=5,value:s,sub:a}){const[i,c]=f.useState(null),d=s!=null;if(f.useEffect(()=>{if(e){if(d){c(Math.max(0,Math.min(100,s)));return}const h=performance.now();c(8);const g=window.setInterval(()=>{const x=(performance.now()-h)/1e3;c(Math.min(92,8+84*(1-Math.exp(-x/r))))},200);return()=>window.clearInterval(g)}c(h=>h==null?null:100);const m=window.setTimeout(()=>c(null),500);return()=>window.clearTimeout(m)},[e,d,s,r]),i==null)return null;const u=Math.round(i);return t.jsxs("div",{className:"flex items-center gap-2 px-0.5","aria-live":"polite",children:[t.jsx("div",{className:"h-1 flex-1 overflow-hidden rounded-full bg-ai-signal-fill/15",role:"progressbar","aria-valuenow":u,"aria-valuemin":0,"aria-valuemax":100,"aria-label":n,children:t.jsx("div",{className:"h-full rounded-full bg-ai-signal-fill transition-[width] duration-200 ease-out",style:{width:`${i}%`}})}),t.jsx("span",{className:"shrink-0 whitespace-nowrap text-right text-[10px] tabular-nums text-ai-signal",children:a??`${u}%`})]})}function RB({repoId:e}){var g,x;const{activityDigest:n}=vt(),{data:r,isLoading:s}=oB(e,n),a=dB(),i=hB(),c=ei(n),d=((g=c.data)==null?void 0:g.summaryTurnLimit)!=null&&(c.data.summaryTurnsRemaining??0)<=0,u=P1(y=>y.collapsed.has(e)),m=P1(y=>y.toggle),h=a.refreshingRepoIds.has(e);return n?t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(SB,{digest:r,isLoading:s,title:"Digest",collapsed:u,onToggle:()=>m(e),onRegenerate:r==null||r.stale?()=>a.mutate(e):void 0,regenerating:h,onOpenPr:i,outOfCredits:d}),t.jsx(FC,{active:a.isPending&&(((x=a.progress)==null?void 0:x.total)??0)>0,label:"Regenerating digest",...cB(a.progress)}),a.notice!=null&&t.jsx("p",{className:"px-0.5 text-[11px] text-gray-400","aria-live":"polite",children:a.notice})]}):null}function IB({stats:e}){return t.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-gray-500 dark:text-gray-400",children:[t.jsxs("span",{children:[t.jsx("span",{className:"font-semibold text-gray-700 dark:text-gray-200 tabular-nums",children:e.openPrs})," ","open"]}),t.jsxs("span",{children:[t.jsx("span",{className:"tabular-nums",children:e.draftPrs})," draft"]}),e.stalledPrs>0&&t.jsxs("span",{className:"text-amber-500",children:[t.jsx("span",{className:"tabular-nums",children:e.stalledPrs})," stalled"," ",t.jsx($i,{size:12,className:"inline-block align-[-0.1em]"})]}),e.medianHoursToFirstReview!=null&&t.jsxs("span",{title:"Median hours to first review",children:["TTFR"," ",t.jsx("span",{className:"tabular-nums",children:e.medianHoursToFirstReview<1?`${Math.round(e.medianHoursToFirstReview*60)}m`:`${Math.round(e.medianHoursToFirstReview)}h`})]}),e.oldestUnreviewed!=null&&t.jsxs("a",{href:e.oldestUnreviewed.githubUrl,target:"_blank",rel:"noreferrer noopener",className:"hover:underline",title:e.oldestUnreviewed.title,children:["oldest unreviewed #",e.oldestUnreviewed.number," ·"," ",Nt(e.oldestUnreviewed.openedAt)]}),e.botThreads>0&&t.jsxs("span",{className:"text-sky-600 dark:text-sky-400",title:"Review-bot threads on open PRs, and the share a later commit has likely addressed (resolved or likely_addressed). An approximate signal — likely_addressed is a heuristic.",children:[t.jsx(Lt,{size:12,className:"inline-block align-[-0.1em]"})," ",t.jsx("span",{className:"tabular-nums",children:e.botThreads})," bot thread",e.botThreads===1?"":"s"," ·"," ",t.jsxs("span",{className:"tabular-nums",children:[Math.round(e.botThreadsActedOn/e.botThreads*100),"%"]})," ","acted on"]})]})}function TB({repo:e}){const n=e.maintainerIds.length;return t.jsxs("div",{className:"space-y-2 rounded-lg border border-gray-200 p-3 dark:border-gray-800",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"min-w-0 truncate text-base font-semibold text-gray-800 dark:text-gray-100",children:e.repoFullName}),n>0&&t.jsxs("span",{className:"flex shrink-0 items-center gap-0.5 text-[11px] text-gray-400",title:`${n} maintainer${n===1?"":"s"} (have merged here)`,children:[t.jsx($p,{}),n]}),e.attentionCount>0&&t.jsxs("span",{className:"flex shrink-0 items-center gap-0.5 rounded bg-amber-500/15 px-1 text-[10px] font-semibold text-amber-600 dark:text-amber-400",title:"PRs needing attention (review or reply · stalled · untouched threads)",children:[t.jsx(Jt,{size:10}),e.attentionCount]}),t.jsx("span",{className:"ml-auto shrink-0 text-[11px] tabular-nums text-gray-400",children:e.stats.openPrs>0?`[${e.stats.openPrs}]`:"[—]"})]}),t.jsx(IB,{stats:e.stats}),t.jsx(Xp,{counts:e.threadTotals}),t.jsx(q2,{repoIds:[e.repoId],compact:!0}),t.jsx(RB,{repoId:e.repoId})]})}function $B(e,n=!0){return Oe({queryKey:["repo-workspace-metrics",e],queryFn:()=>he.repoWorkspaceMetrics(e),enabled:n,refetchInterval:5*6e4,refetchIntervalInBackground:!1,staleTime:6e4})}function Gn({labels:e,series:n,area:r=!1,curved:s=!1,formatY:a=Sn,height:i=132,logY:c=!1,yDomain:d,centerTip:u=!1,tipBelow:m=!1,hideLegend:h=!1,noteTone:g="anomaly"}){const[x,y]=Xs(),[b,w]=f.useState(null),k=30,j=8,N=8,I=16,S=e.length,T=Math.max(y-k-j,1),$=i-N-I,P=K=>k+(S<=1?T/2:K/(S-1)*T),C=N+$,L=n.flatMap(K=>K.values).filter(K=>K!=null&&K>0),F=c&&L.length>0;let M,D;if(!F&&d){const K=Math.max(d.max-d.min,1e-9);M=U=>{const Q=Math.min(d.max,Math.max(d.min,U));return N+$*(1-(Q-d.min)/K)},D=d.ticks}else if(F){const K=Math.ceil(Math.log10(Math.max(...L))-1e-9);let U=Math.floor(Math.log10(Math.min(...L))+1e-9);U>=K&&(U=K-1);const Q=K-U,J=Math.pow(10,U);M=ne=>{const ae=ne<=J?J:ne;return N+$*(1-(Math.log10(ae)-U)/Q)},D=[];for(let ne=U;ne<=K;ne++)D.push(Math.pow(10,ne))}else{const K=zp(Math.max(1,...n.flatMap(U=>U.values.map(Q=>Q??0))));M=U=>N+$*(1-U/K),D=[0,K]}const A=K=>K.values.map((U,Q)=>U==null?null:`${P(Q)},${M(U)}`).reduce((U,Q)=>Q==null?{d:U.d,pen:!1}:{d:`${U.d}${U.pen?" L":" M"} ${Q}`,pen:!0},{d:"",pen:!1}).d,W=K=>{const U=K.values.map((Q,J)=>Q==null?null:[P(J),M(Q)]).filter(Q=>Q!=null);return U.length<2?"":`M ${U[0][0]} ${C} `+U.map(([Q,J])=>`L ${Q} ${J}`).join(" ")+` L ${U[U.length-1][0]} ${C} Z`},z=K=>{let U="";for(let Q=0;Q<K.length-1;Q++){const J=K[Q-1]??K[Q],ne=K[Q],ae=K[Q+1],we=K[Q+2]??ae,$e=ne[0]+(ae[0]-J[0])/6,Fe=ne[1]+(ae[1]-J[1])/6,oe=ae[0]-(we[0]-ne[0])/6,re=ae[1]-(we[1]-ne[1])/6;U+=` C ${$e} ${Fe} ${oe} ${re} ${ae[0]} ${ae[1]}`}return U},te=K=>{const U=[];let Q=[];return K.values.forEach((J,ne)=>{J==null?(Q.length&&U.push(Q),Q=[]):Q.push([P(ne),M(J)])}),Q.length&&U.push(Q),U.map(J=>{const ne=`M ${J[0][0]} ${J[0][1]}`;return J.length<2?ne:ne+z(J)}).join(" ")},H=K=>{const U=K.values.map((ne,ae)=>ne==null?null:[P(ae),M(ne)]).filter(ne=>ne!=null);if(U.length<2)return"";const Q=U[0],J=U[U.length-1];return`M ${Q[0]} ${C} L ${Q[0]} ${Q[1]}`+z(U)+` L ${J[0]} ${C} Z`},B=s?te:A,O=s?H:W,E=K=>t.jsx("path",{d:B(K),fill:"none",stroke:K.color,strokeWidth:K.dashed?2.75:1.5,strokeDasharray:K.dashed?"6 4":void 0,strokeLinejoin:"round",strokeLinecap:"round"},K.key),ee=K=>{const U=K.nativeEvent.offsetX,Q=S<=1?0:Math.round((U-k)/T*(S-1));w(Math.max(0,Math.min(S-1,Q)))};return t.jsxs("div",{children:[t.jsxs("div",{ref:x,className:"relative",style:{height:i},children:[y>0&&t.jsxs("svg",{width:y,height:i,className:"block",children:[D.map(K=>t.jsxs("g",{children:[t.jsx("line",{x1:k,y1:M(K),x2:y-j,y2:M(K),className:"decorative-mark text-gray-200 dark:text-gray-700",stroke:"currentColor",strokeWidth:1}),t.jsx("text",{x:k-4,y:M(K)+3,textAnchor:"end",className:"fill-gray-500 dark:fill-gray-400 text-[8px]",children:a(K)})]},K)),r&&n[0]&&O(n[0])&&t.jsx("path",{d:O(n[0]),fill:n[0].color,opacity:.12}),b!=null&&t.jsx("line",{x1:P(b),y1:N,x2:P(b),y2:C,className:"decorative-mark text-gray-300 dark:text-gray-600",stroke:"currentColor",strokeWidth:1}),n.filter(K=>!K.dashed).map(E),n.map(K=>K.dashed?null:K.values.map((U,Q)=>{var ne;if(U==null)return null;const J=((ne=K.pointFlags)==null?void 0:ne[Q])===!0;return t.jsxs("g",{children:[J&&t.jsx("circle",{cx:P(Q),cy:M(U),r:4.5,fill:"none",stroke:Zc,strokeWidth:1.5}),t.jsx("circle",{cx:P(Q),cy:M(U),r:b===Q?3:J?2.4:1.8,fill:J?Zc:K.color})]},`${K.key}-${Q}`)})),n.filter(K=>K.dashed).map(E),t.jsx("text",{x:k,y:i-4,className:"fill-gray-500 dark:fill-gray-400 text-[8px]",children:e[0]?Bo(e[0]):""}),t.jsx("text",{x:y-j,y:i-4,textAnchor:"end",className:"fill-gray-500 dark:fill-gray-400 text-[8px]",children:e[S-1]?Bo(e[S-1]):""}),t.jsx("rect",{x:0,y:0,width:y,height:i,fill:"transparent",onMouseMove:ee,onMouseLeave:()=>w(null)})]}),!m&&b!=null&&y>0&&t.jsxs(Wi,{x:P(b),y:N,width:y,centered:u,children:[t.jsx("div",{className:"font-medium",children:e[b]?Bo(e[b]):""}),n.filter(K=>!K.dashed).map(K=>{var Q;const U=((Q=K.pointNotes)==null?void 0:Q[b])??null;return t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("span",{className:"inline-block h-1.5 w-1.5 rounded-[1px]",style:{background:K.color}}),K.label,": ",K.values[b]==null?"—":a(K.values[b])]}),U&&t.jsxs("div",{className:`ml-2.5 mt-0.5 flex max-w-[220px] items-start gap-1 whitespace-normal ${g==="muted"?"text-gray-500 dark:text-gray-400":""}`,style:g==="muted"?void 0:{color:Zc},children:[t.jsx("span",{className:"mt-px flex shrink-0 items-center",children:g==="muted"?"·":t.jsx(jk,{size:9})}),t.jsx("span",{children:U})]})]},K.key)})]})]}),m&&t.jsx("div",{className:"mt-1 flex min-h-[1.75rem] flex-wrap items-baseline justify-end gap-x-3 gap-y-0.5 text-[10px] leading-tight",children:b==null?t.jsx("span",{className:"text-gray-400",children:"hover a week for its point-in-time breakdown"}):t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"font-medium text-gray-600 dark:text-gray-300",children:e[b]?Bo(e[b]):""}),n.filter(K=>!K.dashed).map(K=>{var J;const U=K.values[b],Q=((J=K.pointNotes)==null?void 0:J[b])??null;return t.jsxs("span",{className:"flex items-baseline gap-1",children:[t.jsx("span",{className:"inline-block h-1.5 w-1.5 translate-y-px rounded-[1px]",style:{background:K.color}}),t.jsxs("span",{className:"text-gray-600 dark:text-gray-300",children:[K.label,": ",U==null?"—":a(U)]}),Q&&(g==="muted"?t.jsxs("span",{className:"text-gray-500 dark:text-gray-400",children:["· ",Q]}):t.jsxs("span",{className:"inline-flex items-center gap-1",style:{color:Zc},children:[t.jsx(jk,{size:9}),Q]}))]},K.key)})]})}),!h&&n.length>1&&t.jsx(Ld,{series:n})]})}function Lr({labels:e,series:n,mode:r="grouped",formatY:s=Sn,formatValue:a=s,height:i=132,rotateLabels:c=!1,maxBarWidth:d,onSelectBar:u,barAriaLabel:m}){const[h,g]=Xs(),[x,y]=f.useState(null),b=30,w=8,k=8,j=c?40:16,N=e.length,I=Math.max(g-b-w,1),S=i-k-j,T=/^\d{4}-\d{2}-\d{2}T/.test(e[0]??""),$=B=>n.reduce((O,E)=>O+(E.values[B]??0),0),P=zp(r==="stacked"?Math.max(1,...e.map((B,O)=>$(O))):Math.max(1,...n.flatMap(B=>B.values.map(O=>O??0)))),C=I/Math.max(N,1),L=Math.min(C*.7,d??Number.POSITIVE_INFINITY),F=B=>b+B*C+(C-L)/2,M=B=>k+S*(1-B/P),D=k+S,A=B=>{const O=Math.floor((B.nativeEvent.offsetX-b)/C);y(Math.max(0,Math.min(N-1,O)))},W=B=>{const O=e[B]??"";return T?Bo(O):O},z=!T||N<=8,te=()=>{var B;return n.length===1?((B=n[0])==null?void 0:B.key)??null:null},H=B=>m?m(B):`${W(B)}: ${n.map(O=>`${O.label} ${a(O.values[B]??0)}`).join(", ")}`;return t.jsxs("div",{children:[t.jsxs("div",{ref:h,className:"relative",style:{height:i},children:[g>0&&t.jsxs("svg",{width:g,height:i,className:"block",children:[[0,P].map(B=>t.jsxs("g",{children:[t.jsx("line",{x1:b,y1:M(B),x2:g-w,y2:M(B),className:"decorative-mark text-gray-200 dark:text-gray-700",stroke:"currentColor",strokeWidth:1}),t.jsx("text",{x:b-4,y:M(B)+3,textAnchor:"end",className:"fill-gray-500 dark:fill-gray-400 text-[8px]",children:s(B)})]},B)),x!=null&&t.jsx("rect",{x:b+x*C,y:k,width:C,height:S,className:"text-gray-400/10 dark:text-gray-300/10",fill:"currentColor"}),e.map((B,O)=>{if(r==="stacked"){let ee=0;return n.map(K=>{var ne;const U=K.values[O]??0;if(U<=0)return null;const Q=M(ee+U),J=M(ee)-Q;return ee+=U,t.jsx("rect",{x:F(O),y:Q,width:L,height:Math.max(J,0),fill:((ne=K.colors)==null?void 0:ne[O])??K.color},`${O}-${K.key}`)})}const E=L/Math.max(n.length,1);return n.map((ee,K)=>{var Q;const U=ee.values[O]??0;return U<=0?null:t.jsx("rect",{x:F(O)+K*E,y:M(U),width:Math.max(E-.5,.5),height:D-M(U),fill:((Q=ee.colors)==null?void 0:Q[O])??ee.color},`${O}-${ee.key}`)})}),e.map((B,O)=>{if(!(z||O===0||O===N-1))return null;const E=b+O*C+C/2;if(c){const ee=D+9;return t.jsx("text",{x:E,y:ee,textAnchor:"end",transform:`rotate(-35 ${E} ${ee})`,className:"fill-gray-500 dark:fill-gray-400 text-[8px]",children:W(O)},`lbl-${O}`)}return t.jsx("text",{x:E,y:i-4,textAnchor:"middle",className:"fill-gray-500 dark:fill-gray-400 text-[8px]",children:W(O)},`lbl-${O}`)}),t.jsx("rect",{x:0,y:0,width:g,height:i,fill:"transparent",onMouseMove:A,onMouseLeave:()=>y(null)})]}),u&&g>0&&t.jsx("div",{className:"pointer-events-none absolute inset-0",children:e.map((B,O)=>t.jsx("button",{type:"button",className:"pointer-events-auto absolute cursor-pointer rounded-sm bg-transparent focus:outline-none focus-visible:ring-2 focus-visible:ring-sky-500",style:{left:b+O*C,top:k,width:C,height:S},onMouseEnter:()=>y(O),onMouseLeave:()=>y(null),onFocus:()=>y(O),onBlur:()=>y(null),onClick:()=>u(te(),O),"aria-label":H(O)},`hit-${O}`))}),x!=null&&g>0&&t.jsxs(Wi,{x:b+x*C+C/2,y:k,width:g,children:[t.jsx("div",{className:"font-medium",children:W(x)}),n.map(B=>{var O;return t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("span",{className:"inline-block h-1.5 w-1.5 rounded-[1px]",style:{background:((O=B.colors)==null?void 0:O[x])??B.color}}),B.label,": ",a(B.values[x]??0)]},B.key)}),r==="stacked"&&n.length>1&&t.jsxs("div",{className:"mt-0.5 border-t border-gray-200 pt-0.5 dark:border-gray-700",children:["total: ",a($(x))]})]})]}),n.length>1&&t.jsx(Ld,{series:n})]})}function O1({labels:e,series:n,formatValue:r=Sn,height:s=132}){const[a,i]=Xs(),[c,d]=f.useState(null),u=30,m=8,h=8,g=16,x=e.length,y=Math.max(i-u-m,1),b=s-h-g,w=(C,L)=>C.values[L]??0,k=C=>n.reduce((L,F)=>L+w(F,C),0),j=zp(Math.max(1,...e.map((C,L)=>k(L)))),N=C=>u+(x<=1?y/2:C/(x-1)*y),I=C=>h+b*(1-C/j),S=h+b,T=[];{const C=e.map(()=>0);for(const L of n)T.push([...C]),e.forEach((F,M)=>C[M]=(C[M]??0)+w(L,M))}const $=(C,L)=>{const F=T[L],M=e.map((A,W)=>[N(W),I(F[W]+w(C,W))]),D=e.map((A,W)=>[N(W),I(F[W])]).reverse();return`M ${M.map(([A,W])=>`${A},${W}`).join(" L ")} L ${D.map(([A,W])=>`${A},${W}`).join(" L ")} Z`},P=C=>{const L=x<=1?0:Math.round((C.nativeEvent.offsetX-u)/y*(x-1));d(Math.max(0,Math.min(x-1,L)))};return t.jsxs("div",{children:[t.jsxs("div",{ref:a,className:"relative",style:{height:s},children:[i>0&&t.jsxs("svg",{width:i,height:s,className:"block",children:[[0,j].map(C=>t.jsxs("g",{children:[t.jsx("line",{x1:u,y1:I(C),x2:i-m,y2:I(C),className:"decorative-mark text-gray-200 dark:text-gray-700",stroke:"currentColor",strokeWidth:1}),t.jsx("text",{x:u-4,y:I(C)+3,textAnchor:"end",className:"fill-gray-500 dark:fill-gray-400 text-[8px]",children:Sn(C)})]},C)),n.map((C,L)=>t.jsx("path",{d:$(C,L),fill:C.color,opacity:.85},C.key)),c!=null&&t.jsx("line",{x1:N(c),y1:h,x2:N(c),y2:S,className:"text-gray-400 dark:text-gray-300",stroke:"currentColor",strokeWidth:1}),t.jsx("text",{x:u,y:s-4,className:"fill-gray-500 dark:fill-gray-400 text-[8px]",children:e[0]?Bo(e[0]):""}),t.jsx("text",{x:i-m,y:s-4,textAnchor:"end",className:"fill-gray-500 dark:fill-gray-400 text-[8px]",children:e[x-1]?Bo(e[x-1]):""}),t.jsx("rect",{x:0,y:0,width:i,height:s,fill:"transparent",onMouseMove:P,onMouseLeave:()=>d(null)})]}),c!=null&&i>0&&t.jsxs(Wi,{x:N(c),y:h,width:i,children:[t.jsx("div",{className:"font-medium",children:e[c]?Bo(e[c]):""}),n.map(C=>t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("span",{className:"inline-block h-1.5 w-1.5 rounded-[1px]",style:{background:C.color}}),C.label,": ",r(w(C,c))]},C.key)),t.jsxs("div",{className:"mt-0.5 border-t border-gray-200 pt-0.5 dark:border-gray-700",children:["total: ",r(k(c))]})]})]}),n.length>1&&t.jsx(Ld,{series:n})]})}function _B({points:e,xLabel:n,yLabel:r,formatX:s=Sn,formatY:a=Sn,fit:i=!1,height:c=150}){const[d,u]=Xs(),[m,h]=f.useState(null),g=32,x=8,y=8,b=18,w=Math.max(u-g-x,1),k=c-y-b,j=F=>Math.log10(1+Math.max(0,F)),N=j(Math.max(1,...e.map(F=>F.x))),I=j(Math.max(1,...e.map(F=>F.y))),S=F=>g+j(F)/(N||1)*w,T=F=>y+k*(1-j(F)/(I||1)),$=F=>[0,1,10,100,1e3,1e4].filter(M=>j(M)<=F+.01),P=(()=>{if(!i)return null;const F=e.filter(Q=>Q.x>0&&Q.y>0);if(F.length<4)return null;const M=F.map(Q=>Math.log10(Q.x)),D=F.map(Q=>Math.log10(Q.y)),A=F.length,W=M.reduce((Q,J)=>Q+J,0)/A,z=D.reduce((Q,J)=>Q+J,0)/A;let te=0,H=0;for(let Q=0;Q<A;Q++)te+=(M[Q]-W)**2,H+=(M[Q]-W)*(D[Q]-z);if(te===0)return null;const B=H/te,O=z-B*W,E=Math.min(...M),ee=Math.max(...M);if(ee<=E)return null;const K=24;let U="";for(let Q=0;Q<=K;Q++){const J=E+Q/K*(ee-E),ne=10**J,ae=10**(O+B*J);U+=`${Q===0?"M":" L"} ${S(ne).toFixed(1)} ${T(ae).toFixed(1)}`}return{d:U,slope:B}})(),C=F=>{const M=F.nativeEvent.offsetX,D=F.nativeEvent.offsetY;let A=-1,W=196;e.forEach((z,te)=>{const H=S(z.x)-M,B=T(z.y)-D,O=H*H+B*B;O<W&&(W=O,A=te)}),h(A>=0?A:null)},L=m!=null?e[m]:null;return t.jsxs("div",{children:[t.jsxs("div",{ref:d,className:"relative",style:{height:c},children:[u>0&&t.jsxs("svg",{width:u,height:c,className:"block",children:[$(I).map(F=>t.jsxs("g",{children:[t.jsx("line",{x1:g,y1:T(F),x2:u-x,y2:T(F),className:"decorative-mark text-gray-200 dark:text-gray-700",stroke:"currentColor",strokeWidth:1}),t.jsx("text",{x:g-4,y:T(F)+3,textAnchor:"end",className:"fill-gray-500 dark:fill-gray-400 text-[8px]",children:a(F)})]},`y${F}`)),$(N).map(F=>t.jsx("text",{x:S(F),y:c-8,textAnchor:"middle",className:"fill-gray-500 dark:fill-gray-400 text-[8px]",children:s(F)},`x${F}`)),e.map((F,M)=>t.jsx("circle",{cx:S(F.x),cy:T(F.y),r:m===M?4:2.2,fill:F.merged?De.green:De.gray,opacity:m==null||m===M?.75:.3},M)),P&&t.jsx("path",{d:P.d,fill:"none",stroke:De.amber,strokeWidth:1.5,strokeDasharray:"4 3",opacity:.95}),P&&t.jsxs("text",{x:g+5,y:y+9,fill:De.amber,className:"text-[8px] font-semibold",children:["≈ ",r," ∝ ",n,"^",P.slope.toFixed(1)]}),t.jsxs("text",{x:g,y:c-1,className:"fill-gray-500 dark:fill-gray-400 text-[8px]",children:[n," →"]}),t.jsx("rect",{x:0,y:0,width:u,height:c,fill:"transparent",onMouseMove:C,onMouseLeave:()=>h(null)})]}),L&&u>0&&t.jsxs(Wi,{x:S(L.x),y:T(L.y),width:u,children:[t.jsx("div",{className:"font-medium",children:L.label}),t.jsxs("div",{children:[n,": ",s(L.x)]}),t.jsxs("div",{children:[r,": ",a(L.y)]})]})]}),t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("span",{className:"text-[9px] text-gray-400",children:[r," (log) ↑"]}),t.jsx(Ld,{series:[{label:"merged",color:De.green},{label:"closed",color:De.gray}]})]})]})}const p0=[1,2,3,4,5,6,0],PB=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],EB=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function OC({cells:e,height:n,color:r}){const s=r??De.blue,[a,i]=Xs(),[c,d]=f.useState(null),u=26,m=2,h=14,x=Math.max(i-u-2,1)/24,y=n??m+7*h+14,b=Math.max(1,...e),w=j=>{const N=Math.floor((j.nativeEvent.offsetX-u)/x),I=Math.floor((j.nativeEvent.offsetY-m)/h);if(N<0||N>23||I<0||I>6){d(null);return}d({row:I,col:N})},k=(j,N)=>e[p0[j]*24+N]??0;return t.jsx("div",{children:t.jsxs("div",{ref:a,className:"relative",style:{height:y},children:[i>0&&t.jsxs("svg",{width:i,height:y,className:"block",children:[PB.map((j,N)=>t.jsx("text",{x:u-4,y:m+N*h+h-4,textAnchor:"end",className:"fill-gray-500 dark:fill-gray-400 text-[8px]",children:j},j)),p0.map((j,N)=>Array.from({length:24},(I,S)=>{const T=k(N,S),$=(c==null?void 0:c.row)===N&&(c==null?void 0:c.col)===S;return t.jsx("rect",{x:u+S*x,y:m+N*h,width:Math.max(x-1,1),height:h-1,rx:1.5,fill:T>0?s:"currentColor",className:T>0?"":"decorative-mark text-gray-100 dark:text-gray-800",fillOpacity:T>0?.15+.85*(T/b):1,stroke:$?s:"none",strokeWidth:$?1.5:0},`${N}-${S}`)})),[0,6,12,18].map(j=>t.jsxs("text",{x:u+j*x,y:y-3,className:"fill-gray-500 dark:fill-gray-400 text-[8px]",children:[j,":00"]},j)),t.jsx("rect",{x:0,y:0,width:i,height:y,fill:"transparent",onMouseMove:w,onMouseLeave:()=>d(null)})]}),c&&i>0&&t.jsxs(Wi,{x:u+c.col*x+x/2,y:m+c.row*h,width:i,children:[EB[p0[c.row]]," ",String(c.col).padStart(2,"0"),":00 ·"," ",k(c.row,c.col)," events"]})]})})}const za=e=>e.reduce((n,r)=>n+r,0);function Sl({title:e,children:n}){return t.jsxs("div",{children:[t.jsx("h3",{className:"mb-1.5 text-[11px] font-semibold uppercase tracking-wide text-gray-400",children:e}),t.jsx("div",{className:"grid grid-cols-1 gap-3 lg:grid-cols-2",children:n})]})}function D1({data:e,collapsible:n=!1,omitPrimaries:r=!1}){const[s,a]=f.useState(!1),{data:i}=An(),c=Rn(i),d=e.weekBuckets,u=`${e.windowDays/7}-wk · weekly`,m=[{key:"opened",label:"Opened",color:De.blue,values:e.throughput.opened},{key:"merged",label:"Merged",color:De.green,values:e.throughput.merged},{key:"closed",label:"Closed",color:De.gray,values:e.throughput.closed}],h=[{key:"open",label:"Open",color:De.blue,values:e.backlog.open},{key:"stalled",label:"Stalled",color:De.orange,values:e.backlog.stalled}],g=[{key:"median",label:"Median to 1st review",color:De.blue,values:e.reviewLatencyTrend.medianHours}],x=[{key:"ttfr",label:"Open → 1st review",color:De.amber,values:e.cycleBreakdown.toFirstReview},{key:"rtm",label:"1st review → close",color:De.blue,values:e.cycleBreakdown.reviewToMerge}],y=[{key:"count",label:"PRs",color:De.blue,values:e.reviewLatencyDist.map(O=>O.count)}],b=e.reviewLatencyDist.map(O=>O.label),w=[{key:"untouched",label:Xt.untouched.label,color:Xt.untouched.color,values:e.threadMix.untouched},{key:"replied",label:Xt.replied_unresolved.label,color:Xt.replied_unresolved.color,values:e.threadMix.replied_unresolved},{key:"likely",label:Xt.likely_addressed.label,color:Xt.likely_addressed.color,values:e.threadMix.likely_addressed},{key:"resolved",label:Xt.resolved.label,color:Xt.resolved.color,values:e.threadMix.resolved}],k=[{key:"approved",label:"Approved",color:De.green,values:e.reviewVerdicts.approved},{key:"changes",label:"Changes requested",color:De.orange,values:e.reviewVerdicts.changes_requested},{key:"commented",label:"Commented",color:De.gray,values:e.reviewVerdicts.commented},{key:"dismissed",label:"Dismissed",color:De.slate,values:e.reviewVerdicts.dismissed}],j=e.reviewerLoad.map((O,E)=>({key:String(O.userId),label:O.userId===-1?"Others":Dt(c.get(O.userId),O.userId),color:Xl[E%Xl.length],values:O.weekly})),N=[{key:"count",label:"PRs",color:De.purple,values:e.sizeDist.map(O=>O.count)}],I=e.sizeDist.map(O=>O.label),S=e.sizeVsCycle.map(O=>({x:O.loc,y:O.hoursOpen,label:`#${O.prNumber}`,merged:O.merged})),T=e.sizeCycleByBucket.map(O=>O.label),$=[{key:"median",label:"Median time open",color:De.teal,values:e.sizeCycleByBucket.map(O=>O.medianHours??0)}],P=e.ciRecovery,C=P.length===0||P.every(O=>O.medianHours==null),L=za(P.map(O=>O.incidents)),F=P.map(O=>O.weekStart),M=[{key:"recovery",label:"Median recovery",color:De.red,values:P.map(O=>O.medianHours)}],D=e.ciFailuresByStage,A=D.map(O=>O.stage),W=[{key:"failures",label:"Failures",color:De.orange,values:D.map(O=>O.count)}],z=t.jsx(jt,{title:"PR throughput",note:u,children:za(m.flatMap(O=>O.values))===0?t.jsx(Tt,{}):t.jsx(Gn,{labels:d,series:m,curved:!0})}),te=t.jsx(jt,{title:"CI recovery time",note:C?"weekly median":`${L} recoveries · weekly median`,children:C?t.jsx(Tt,{label:"No CI failures recorded"}):t.jsx(Gn,{labels:F,series:M,area:!0,curved:!0,formatY:wn})}),H=t.jsx(jt,{title:"CI failures by stage",note:"by check name",children:D.length===0?t.jsx(Tt,{label:"No CI failures recorded"}):t.jsx(Lr,{labels:A,series:W,rotateLabels:!0})}),B=(O,E=O)=>t.jsxs("div",{className:"space-y-4",children:[t.jsxs(Sl,{title:"Flow & throughput",children:[O&&z,t.jsx(jt,{title:"Open backlog & stalled",note:"weekly snapshot",children:Math.max(0,...e.backlog.open)===0?t.jsx(Tt,{}):t.jsx(Gn,{labels:d,series:h,curved:!0})})]}),t.jsxs(Sl,{title:"Speed & latency",children:[t.jsx(jt,{title:"Time to first review",note:"weekly median",children:e.reviewLatencyTrend.medianHours.every(ee=>ee==null)?t.jsx(Tt,{}):t.jsx(Gn,{labels:d,series:g,area:!0,formatY:wn,curved:!0})}),t.jsx(jt,{title:"Cycle-time breakdown",note:"by close week",children:za(e.cycleBreakdown.count)===0?t.jsx(Tt,{}):t.jsx(Lr,{labels:d,series:x,mode:"stacked",formatY:wn})}),t.jsx(jt,{title:"Review-latency distribution",note:"open → 1st review",children:za(y[0].values)===0?t.jsx(Tt,{}):t.jsx(Lr,{labels:b,series:y})})]}),(O||E)&&t.jsxs(Sl,{title:"CI health",children:[O&&te,E&&H]}),t.jsxs(Sl,{title:"Review health",children:[t.jsx(jt,{title:"Thread-resolution mix",note:"by thread created week",children:za(w.flatMap(ee=>ee.values))===0?t.jsx(Tt,{}):t.jsx(O1,{labels:d,series:w})}),t.jsx(jt,{title:"Review verdicts",note:u,children:za(k.flatMap(ee=>ee.values))===0?t.jsx(Tt,{}):t.jsx(Lr,{labels:d,series:k,mode:"stacked"})}),t.jsx(jt,{title:"Reviews by reviewer",note:u,children:j.length===0?t.jsx(Tt,{}):t.jsx(O1,{labels:d,series:j})})]}),t.jsxs(Sl,{title:"Size & risk",children:[t.jsx(jt,{title:"PR size distribution",note:"opened, by LOC",children:za(N[0].values)===0?t.jsx(Tt,{}):t.jsx(Lr,{labels:I,series:N})}),t.jsx(jt,{title:"Median time open by size",note:"PRs closed in window",children:za(e.sizeCycleByBucket.map(ee=>ee.count))===0?t.jsx(Tt,{}):t.jsx(Lr,{labels:T,series:$,formatY:wn,formatValue:wn})}),t.jsx(jt,{title:"Size vs. time open",note:"log–log · power-law fit",children:S.length===0?t.jsx(Tt,{}):t.jsx(_B,{points:S,xLabel:"LOC",yLabel:"time open",formatX:Sn,formatY:wn,fit:!0})})]}),t.jsx(Sl,{title:"Cadence",children:t.jsx(jt,{title:"Activity heatmap",note:"by weekday × hour (UTC)",children:za(e.activityHeatmap)===0?t.jsx(Tt,{}):t.jsx(OC,{cells:e.activityHeatmap})})})]});return n?t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"grid grid-cols-1 gap-3 lg:grid-cols-2",children:[z,te]}),t.jsxs("div",{children:[t.jsxs("button",{type:"button",onClick:()=>a(O=>!O),className:"flex items-center gap-1 text-[11px] font-medium text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200",children:[t.jsx(Mt,{dir:s?"down":"right",size:11}),"More charts"]}),s&&t.jsx("div",{className:"mt-3",children:B(!1,!0)})]})]}):B(!r)}const Wu=e=>`${Math.round(e)}%`,B1=e=>String(Math.round(e)),AB=e=>Number.isInteger(e)?String(e):e.toFixed(1);function Hc({label:e,stat:n,format:r,betterWhen:s,sub:a,onActivate:i}){const{value:c,previous:d,lowConfidence:u}=n,m=c!=null&&d!=null?c-d:null,h=m!=null&&m!==0&&m>0==(s==="up"),g=m!=null&&m!==0&&!u;return t.jsxs(qf,{onActivate:i,children:[t.jsx("div",{className:"text-[10px] font-medium uppercase tracking-wide text-gray-400",children:e}),t.jsx("div",{className:"text-lg font-semibold text-gray-800 dark:text-gray-100",children:c==null?"—":r(c)}),g?t.jsxs("div",{className:`text-[11px] ${h?"text-green-600 dark:text-green-400":"text-red-500 dark:text-red-400"}`,children:[t.jsx(Cr,{dir:m>0?"up":"down",className:"inline-block align-[-0.1em]"})," ",r(Math.abs(m))," ",t.jsx("span",{className:"text-gray-400",children:"vs last"})]}):u?t.jsx("div",{className:"text-[11px] text-gray-400",title:"Too few data points to read a trend yet (small sample)",children:d==null?"building baseline":`was ${r(d)}`}):t.jsx("div",{className:"text-[11px] text-gray-400",children:d==null?a:"no change"}),t.jsx("div",{className:"mt-0.5 text-[10px] text-gray-400",children:a})]})}function qf({onActivate:e,children:n}){const r="block w-full rounded-lg border border-gray-200 bg-white p-2 text-left dark:border-gray-800 dark:bg-gray-900/40";return e?t.jsx("button",{type:"button",onClick:e,title:"Inspect the PRs behind this metric",className:`${r} cursor-pointer transition hover:border-gray-300 hover:bg-gray-50/70 focus:outline-none focus-visible:ring-2 focus-visible:ring-sky-400 dark:hover:border-gray-600 dark:hover:bg-gray-900/60`,children:n}):t.jsx("div",{className:r,children:n})}function DC({metrics:e,onOpenMetric:n,onOpenOpenPrs:r,openPrsSubtitle:s="across this workspace",moreChartsSlot:a}){const[i,c]=f.useState(!1),d=e.weekBuckets,u=e.comparisonMode??"rolling_14",m=Math.max(1,Math.min(e.sprintDays,Math.ceil(e.elapsedDays??e.sprintDays))),h=u==="sprint"?`day ${m} of ${e.sprintDays} · vs same point last sprint`:`rolling ${e.sprintDays} days · vs prior ${e.sprintDays} days`,g=E=>E.reduce((ee,K)=>ee+K,0),x=E=>n?()=>n(E):void 0,y=[{key:"opened",label:"Opened",color:De.blue,values:e.throughput.opened},{key:"merged",label:"Merged",color:De.green,values:e.throughput.merged}],b=[{key:"lead",label:"Lead time",color:De.purple,values:e.leadTimeTrend}],w=[{key:"ci",label:"Merge CI success",color:De.green,values:e.ciSuccessTrend}],k=[{key:"recovery",label:"CI recovery",color:De.orange,values:e.ciRecoveryTrend}],j=[{key:"failures",label:"Failures",color:De.red,values:e.ciFailureReasons.map(E=>E.count)}],N=e.ciFailureReasons.map(E=>E.stage),I=e.reviewLoad,S=I?[{key:"human",label:"Human",color:De.blue,values:I.human},{key:"bot",label:"Bot",color:De.orange,values:I.bot}]:[],T=I==null||I.human.every(E=>E==null)&&I.bot.every(E=>E==null),$=e.changesRequestedTrend,P=e.reworkTrend,C=e.reviewCoverage,L=$?[{key:"cr",label:"Changes requested",color:De.orange,values:$}]:[],F=P?[{key:"rework",label:"Rework",color:De.purple,values:P}]:[],M=C?[{key:"human",label:"Human-reviewed",color:De.green,values:C.human},{key:"botOnly",label:"Bot-only",color:De.orange,values:C.botOnly},{key:"unreviewed",label:"Unreviewed",color:De.red,values:C.unreviewed}]:[],D=E=>E==null||E.every(ee=>ee==null),A=C==null||C.human.every(E=>E===0)&&C.botOnly.every(E=>E===0)&&C.unreviewed.every(E=>E===0),W=e.resolutionLatencyTrend,z=W?[{key:"human",label:"Human-resolved",color:De.blue,values:W.human},{key:"bot",label:"Bot self-resolved",color:De.orange,values:W.bot}]:[],te=W==null||D(W.human)&&D(W.bot),H=e.reviewPickupTrend,B=H?[{key:"pickup",label:"Pickup",color:De.blue,values:H}]:[],O=t.jsx(jt,{title:"CI failures by stage",note:"which checks fail · window",children:N.length===0?t.jsx(Tt,{label:"No CI failures recorded yet"}):t.jsx(Lr,{labels:N,series:j,rotateLabels:!0})});return t.jsxs("div",{className:"space-y-3 rounded-lg border border-gray-200 bg-gray-50/50 p-3 dark:border-gray-800 dark:bg-gray-900/20","data-testid":"flow-metrics",children:[t.jsxs("div",{className:"flex flex-wrap items-baseline gap-2",children:[t.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-gray-500 dark:text-gray-300",children:"Flow metrics"}),t.jsxs("span",{className:"text-[11px] text-gray-400",children:["DORA-ish · ",h,n?" · tap a tile to drill in":""]})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-2 sm:grid-cols-3 lg:grid-cols-7",children:[t.jsxs(qf,{onActivate:r,children:[t.jsx("div",{className:"text-[10px] font-medium uppercase tracking-wide text-gray-400",children:"Open PRs"}),t.jsx("div",{className:"text-lg font-semibold text-gray-800 dark:text-gray-100",children:e.openPrs}),t.jsx("div",{className:"text-[11px] text-gray-400",children:s}),t.jsx("div",{className:"mt-0.5 text-[10px] text-gray-400",children:"currently open"})]}),t.jsx(Hc,{label:"Merges",stat:e.merges,format:B1,betterWhen:"up",sub:"deploy frequency",onActivate:x("merges")}),t.jsx(Hc,{label:"Lead time",stat:e.leadTimeHours,format:wn,betterWhen:"down",sub:"open → merge",onActivate:x("lead_time")}),t.jsx(Hc,{label:"Review latency",stat:e.timeToFirstReviewHours,format:wn,betterWhen:"down",sub:"to first review",onActivate:x("review_latency")}),t.jsx(Hc,{label:"Merge CI",stat:e.mergeCiSuccessPct,format:Wu,betterWhen:"up",sub:"green at merge",onActivate:x("merge_ci")}),t.jsx(Hc,{label:"CI recovery",stat:e.ciRecoveryHours,format:wn,betterWhen:"down",sub:"red → green",onActivate:x("ci_recovery")}),t.jsxs(qf,{onActivate:x("ci_red"),children:[t.jsx("div",{className:"text-[10px] font-medium uppercase tracking-wide text-gray-400",children:"CI red now"}),t.jsx("div",{className:`text-lg font-semibold ${e.ciFailingNow>0?"text-red-500 dark:text-red-400":"text-gray-800 dark:text-gray-100"}`,children:e.ciFailingNow}),t.jsx("div",{className:"text-[11px] text-gray-400",children:e.ciFailingNow>0&&e.ciFailingMedianAgeHours!=null?`~${wn(e.ciFailingMedianAgeHours)} unresolved`:"all green"}),t.jsx("div",{className:"mt-0.5 text-[10px] text-gray-400",children:"recovery pressure"})]})]}),t.jsx("h4",{className:"pt-1 text-[11px] font-semibold uppercase tracking-wide text-gray-500 dark:text-gray-400",children:"12-week trend"}),t.jsxs("div",{className:"grid grid-cols-1 gap-3 lg:grid-cols-3",children:[t.jsx(jt,{title:"Review load per PR",note:"human vs bot touches per shipped PR · weekly",children:T?t.jsx(Tt,{label:"No merged-PR review activity yet"}):t.jsx(Gn,{labels:d,series:S,area:!0,curved:!0,formatY:AB})}),t.jsx(jt,{title:"Throughput",note:"opened vs merged · weekly",children:g(e.throughput.opened)+g(e.throughput.merged)===0?t.jsx(Tt,{}):t.jsx(Gn,{labels:d,series:y,area:!0,curved:!0})}),t.jsx(jt,{title:"CI recovery time",note:"median red→green · weekly",children:e.ciRecoveryTrend.every(E=>E==null)?t.jsx(Tt,{label:"No CI recoveries yet — accrues from sync"}):t.jsx(Gn,{labels:d,series:k,area:!0,curved:!0,formatY:wn})})]}),t.jsxs("div",{children:[t.jsxs("button",{type:"button",onClick:()=>c(E=>!E),className:"text-[11px] font-medium text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200",children:[t.jsx(Mt,{dir:i?"down":"right",className:"inline-block align-[-0.1em]"})," ","More charts",a==null?" — lead time · CI · review depth":""]}),i&&(a!=null?t.jsxs("div",{className:"mt-2 space-y-3",children:[t.jsx("div",{className:"grid grid-cols-1 gap-3 lg:grid-cols-2",children:O}),a]}):t.jsxs("div",{className:"mt-2 grid grid-cols-1 gap-3 lg:grid-cols-2",children:[O,t.jsx(jt,{title:"Lead time for changes",note:"median open→merge · weekly",children:e.leadTimeTrend.every(E=>E==null)?t.jsx(Tt,{}):t.jsx(Gn,{labels:d,series:b,area:!0,curved:!0,formatY:wn})}),t.jsx(jt,{title:"Merge CI success",note:"% green at merge · weekly",children:e.ciSuccessTrend.every(E=>E==null)?t.jsx(Tt,{}):t.jsx(Gn,{labels:d,series:w,curved:!0,formatY:Wu})}),t.jsx(jt,{title:"Changes-requested rate",note:"% merged PRs sent back · weekly · lower = cleaner drafts",children:D($)?t.jsx(Tt,{}):t.jsx(Gn,{labels:d,series:L,curved:!0,formatY:Wu})}),t.jsx(jt,{title:"Review coverage",note:"merged PRs by who reviewed · weekly",children:A?t.jsx(Tt,{label:"No merged PRs yet"}):t.jsx(Lr,{labels:d,series:M,mode:"stacked",formatY:B1})}),t.jsx(jt,{title:"Rework after review",note:"median % of commits pushed after first review · weekly",children:D(P)?t.jsx(Tt,{label:"No reviewed merges yet"}):t.jsx(Gn,{labels:d,series:F,area:!0,curved:!0,formatY:Wu})}),t.jsx(jt,{title:"Time to resolve threads",note:"median open→resolved · human vs bot self-resolve · weekly",children:te?t.jsx(Tt,{label:"No resolutions observed yet — accrues from sync"}):t.jsx(Gn,{labels:d,series:z,curved:!0,formatY:wn})}),t.jsx(jt,{title:"Review pickup time",note:"median requested→first review · weekly",children:D(H)?t.jsx(Tt,{label:"No review requests recorded yet — accrues from sync"}):t.jsx(Gn,{labels:d,series:B,area:!0,curved:!0,formatY:wn})})]}))]})]})}function MB({repoId:e}){const{workspaceInsights:n}=vt(),{data:r,isLoading:s}=$B(e,n),{data:a,isLoading:i}=H_(e),c=a?t.jsx(D1,{data:a,omitPrimaries:!0}):null;return r!=null&&r.metrics?t.jsx(DC,{metrics:r.metrics,openPrsSubtitle:"in this repo",moreChartsSlot:c}):s&&r==null?t.jsx("div",{className:"h-44 animate-pulse rounded-lg border border-gray-200 bg-gray-50 dark:border-gray-800 dark:bg-gray-900/40"}):a?t.jsx("div",{className:"rounded-lg border border-gray-200 bg-gray-50/50 p-3 dark:border-gray-800 dark:bg-gray-900/20",children:t.jsx(D1,{data:a,collapsible:!0})}):i?t.jsx("div",{className:"h-44 animate-pulse rounded-lg border border-gray-200 bg-gray-50 dark:border-gray-800 dark:bg-gray-900/40"}):t.jsx(t.Fragment,{})}const LB=10;function FB({pr:e,author:n,onClick:r}){const s=Rr[e.ciStatus],a=g_[e.reasonTag],i=Cx({mergeable:e.mergeable,mergeStateStatus:e.mergeStateStatus,isDraft:e.isDraft}),c=e.isApproved?{label:"approved",color:"#22c55e"}:e.isChangesRequested?{label:"changes",color:"#ef4444"}:null;return t.jsx("li",{className:"flex items-stretch hover:bg-gray-50 dark:hover:bg-gray-800/40",children:t.jsxs("button",{type:"button",onClick:r,title:`Open #${e.number} — ${e.title}`,className:"flex min-w-0 flex-1 items-center gap-2 px-3 py-1.5 text-left text-xs",children:[t.jsx("span",{"aria-hidden":"true",title:(s==null?void 0:s.label)??"no checks",className:"inline-block h-2 w-2 shrink-0 rounded-full",style:s!=null?{background:s.color}:{boxShadow:"inset 0 0 0 1px #9ca3af"}}),N_(e)&&t.jsx("span",{"aria-hidden":"true",title:"Needs attention (review or reply · stalled · untouched threads · CI / conflicts)",className:"flex shrink-0 items-center text-amber-500 dark:text-amber-400",children:t.jsx(Jt,{size:12})}),t.jsxs("span",{className:"min-w-0 flex-1 truncate",children:[t.jsxs("span",{className:"text-gray-400",children:["#",e.number]})," ",t.jsx("span",{className:"font-medium text-gray-700 dark:text-gray-200",children:e.title})]}),t.jsxs("span",{className:"hidden w-36 shrink-0 items-center gap-1.5 overflow-hidden sm:flex",children:[t.jsx(gn,{user:n,size:16}),t.jsx("span",{className:"truncate text-gray-500 dark:text-gray-400",title:Dt(n,e.authorId),children:Dt(n,e.authorId)})]}),t.jsxs("span",{className:"flex min-w-28 shrink-0 items-center justify-end gap-1 whitespace-nowrap",children:[e.isDraft&&t.jsx("span",{className:"shrink-0 rounded bg-gray-500/15 px-1 text-[10px] font-medium text-gray-500 dark:text-gray-400",children:"draft"}),c!=null&&t.jsx("span",{className:"shrink-0 rounded px-1 text-[10px] font-semibold",style:{color:c.color,background:c.color+"1a"},children:c.label}),i!=null&&t.jsx("span",{className:`shrink-0 rounded px-1 text-[10px] font-medium ${IS[i.tone]}`,title:i.detail??i.label,children:i.label})]}),t.jsx(Xp,{counts:e.threadCounts,compact:!0}),t.jsx("span",{className:"hidden w-20 shrink-0 justify-end text-right sm:flex",children:a.myTurn?t.jsx("span",{className:"truncate rounded px-1 text-[10px] font-medium",style:{color:a.color,background:a.color+"1a"},title:Dt(n,e.authorId),children:a.label}):t.jsx("span",{className:"truncate text-[10px] text-gray-400",children:Nt(e.updatedAt)})})]})})}function OB({prs:e,usersById:n,keyPrefix:r="",onShowAll:s}){const{data:a}=xn(),i=Ge(h=>h.openPrDetailTab),c=f.useMemo(()=>{const h=new Map;for(const g of a??[])h.set(g.id,g);return h},[a]),d=f.useCallback((h,g)=>{var y;const x={id:h.id,number:h.number,title:h.title,repoFullName:((y=c.get(h.repoId))==null?void 0:y.fullName)??"",authorLogin:(g==null?void 0:g.githubLogin)??null,authorDisplayName:(g==null?void 0:g.displayName)??null,authorAvatarUrl:(g==null?void 0:g.avatarUrl)??null};i(x,{fromActivity:!0})},[c,i]),u=e.slice(0,LB),m=e.length-u.length;return t.jsxs(t.Fragment,{children:[t.jsx("ul",{className:"divide-y divide-gray-100 dark:divide-gray-800/70",children:u.map(h=>{const g=h.authorId!=null?n.get(h.authorId):void 0;return t.jsx(FB,{pr:h,author:g,onClick:()=>d(h,g)},`${r}${h.id}`)})}),m>0&&t.jsxs("button",{type:"button",onClick:s,className:"flex w-full items-center justify-center gap-1 border-t border-gray-100 px-3 py-1.5 text-[11px] font-medium text-sky-600 hover:bg-gray-50 dark:border-gray-800/70 dark:text-sky-400 dark:hover:bg-gray-800/40",children:["Show all ",e.length," open PRs",t.jsx("span",{className:"text-gray-400",children:"· sortable"})]})]})}function DB({repoId:e,prs:n}){const{data:r}=An(),s=Ax(),a=E1(g=>g.collapsed),i=E1(g=>g.toggle),c=G(g=>g.openOpenPrsDetail),d=f.useMemo(()=>Rn(r),[r]),u=f.useMemo(()=>NS(n,g=>{const x=s.get(g.repoId);return g.authorId!=null&&x!=null&&x.has(g.authorId)}),[n,s]);if(n.length===0)return null;const m=n.reduce((g,x)=>g+(x.isDraft?1:0),0),h=n.length-m;return t.jsxs("div",{className:"rounded-lg border border-gray-200 dark:border-gray-800",children:[t.jsxs("button",{type:"button",onClick:i,"aria-expanded":!a,className:"flex w-full items-center gap-1.5 px-3 py-1.5 text-left text-[11px] font-semibold uppercase tracking-wide text-gray-500 hover:bg-gray-50 dark:text-gray-400 dark:hover:bg-gray-800/40",children:[t.jsx(Mt,{dir:a?"right":"down",className:"shrink-0 text-gray-400"}),"Open PRs · ",h,m>0&&t.jsxs("span",{className:"font-normal normal-case text-gray-400",children:["· ",m," draft",m===1?"":"s"]}),t.jsx("span",{className:"ml-auto font-normal normal-case text-gray-400",children:"click a PR to open it"})]}),!a&&t.jsx("div",{className:"border-t border-gray-200 dark:border-gray-800",children:t.jsx(OB,{prs:u,usersById:d,onShowAll:()=>c(e)})})]})}function BB(){const e=He();return tt({mutationFn:()=>he.markFeedSeen(),onSuccess:()=>void e.invalidateQueries({queryKey:["me"]})})}const BC=50;function WC(e,n,r,s,a,i,c,d,u,m){const h=new URLSearchParams;return e!=null&&h.set("workspace",String(e)),n&&h.set("repoIds",n.join(",")),r&&r.length>0&&h.set("userIds",r.join(",")),i!=null&&h.set("prId",String(i)),s&&(h.set("excludeBots","true"),a.length>0&&h.set("allowBotIds",a.join(","))),c&&h.set("botsOnly","true"),c&&d!=null&&h.set("botWindowDays",String(d)),u&&h.set("includeAllCommits","true"),m&&h.set("includeCiFailures","true"),h.toString()}function WB(e){var i,c,d,u,m,h,g,x;const n=WC(e.workspaceId,e.repoIds,e.userIds,e.excludeBots??!1,e.allowedBotIds??[],e.prId??null,e.botsOnly??!1,e.botWindowDays??null,e.includeAllCommits??!1,e.includeCiFailures??!1),r=rc({queryKey:["consolidated-feed",dt(e.workspaceId),n],initialPageParam:0,queryFn:({pageParam:y})=>{const b=new URLSearchParams(n);return b.set("limit",String(BC)),b.set("offset",String(y)),he.consolidatedFeed(b.toString())},getNextPageParam:(y,b)=>{var j;const w=b.reduce((N,I)=>N+I.items.length,0),k=((j=b[0])==null?void 0:j.total)??0;return w<k?w:void 0},enabled:(e.enabled??!0)&&e.workspaceId!=null,staleTime:1/0,gcTime:fn,refetchOnMount:!1,placeholderData:y=>y}),{items:s,users:a}=f.useMemo(()=>{var j;const y=((j=r.data)==null?void 0:j.pages)??[],b=new Set,w=[];for(const N of y)for(const I of N.items)b.has(I.id)||(b.add(I.id),w.push(I));const k=new Map;for(const N of y)for(const I of N.users)k.set(I.id,I);return{items:w,users:[...k.values()]}},[r.data]);return{items:s,users:a,total:((c=(i=r.data)==null?void 0:i.pages[0])==null?void 0:c.total)??0,uncappedTotal:(u=(d=r.data)==null?void 0:d.pages[0])==null?void 0:u.uncappedTotal,counts:(h=(m=r.data)==null?void 0:m.pages[0])==null?void 0:h.counts,generatedAt:((x=(g=r.data)==null?void 0:g.pages[0])==null?void 0:x.generatedAt)??null,hasMore:r.hasNextPage,loadMore:r.fetchNextPage,isFetchingMore:r.isFetchingNextPage,isLoading:r.isLoading,isFetching:r.isFetching,isPlaceholderData:r.isPlaceholderData}}function qB(e,n){if(n.size===0)return{verdict:"none",insert:[]};const r=e.findIndex(s=>n.has(s));return r<0?{verdict:"gap",insert:[]}:r===0?{verdict:"none",insert:[]}:{verdict:"insert",insert:e.slice(0,r)}}function UB(e,n,r){var i;const s=(i=e[0])==null?void 0:i.id;if(s==null||n.length===0)return 0;const a=n.findIndex(c=>c.id===s);return a<=0?0:r(n.slice(0,a)).length}function HB(e){const n=He(),r=WC(e.workspaceId,e.repoIds,e.userIds,e.excludeBots??!1,e.allowedBotIds??[],e.prId??null,e.botsOnly??!1,e.botWindowDays??null,e.includeAllCommits??!1,e.includeCiFailures??!1),s=dt(e.workspaceId),a=(e.enabled??!0)&&e.workspaceId!=null,i=Oe({queryKey:["feed-head",s,r],queryFn:()=>{const u=new URLSearchParams(r);return u.set("limit",String(BC)),u.set("offset","0"),he.consolidatedFeed(u.toString())},enabled:a,refetchInterval:6e4,refetchIntervalInBackground:!1,staleTime:3e4}),c=f.useRef(e.onBeforeInsert);c.current=e.onBeforeInsert;const d=i.data;return f.useEffect(()=>{if(!a||d==null)return;const u=["consolidated-feed",s,r],m=n.getQueryData(u);if(m==null||m.pages.length===0)return;const h=new Set;for(const y of m.pages)for(const b of y.items)h.add(b.id);const g=qB(d.items.map(y=>y.id),h);if(g.verdict==="none")return;if(g.verdict==="gap"){n.invalidateQueries({queryKey:u});return}const x=d.items.slice(0,g.insert.length);c.current(),n.setQueryData(u,y=>{if(y==null||y.pages.length===0)return y;const[b,...w]=y.pages,k=new Set,j=[...d.users,...b.users].filter(N=>k.has(N.id)?!1:(k.add(N.id),!0));return{...y,pages:[{...b,items:[...x,...b.items],users:j,total:d.total,uncappedTotal:d.uncappedTotal,counts:d.counts,generatedAt:d.generatedAt},...w]}})},[d,a,n,s,r]),{scopeKey:`${s}|${r}`}}function co(e){const{data:n}=qi(e),r=f.useMemo(()=>k_(((n==null?void 0:n.reviewers)??[]).filter(s=>s.kind!=null).map(s=>({login:s.login,kind:s.kind}))),[n==null?void 0:n.reviewers]);return f.useMemo(()=>s=>w_(r,s),[r])}function Uf(e){for(let n=(e==null?void 0:e.parentElement)??null;n;n=n.parentElement){const r=getComputedStyle(n).overflowY;if((r==="auto"||r==="scroll"||r==="overlay")&&n.scrollHeight>n.clientHeight)return n}return null}function zB(e){return Oe({queryKey:["sync-activity"],queryFn:he.syncActivity,refetchInterval:n=>{var r,s,a,i;return(((s=(r=n.state.data)==null?void 0:r.backfills)==null?void 0:s.length)??0)+(((i=(a=n.state.data)==null?void 0:a.catchups)==null?void 0:i.length)??0)>0||e?4e3:2e4},refetchIntervalInBackground:!1})}const W1=.3,KB=3,Ao=()=>({ewma:null,positiveSamples:0,last:null}),GB=90;function q1(e,n,r){if(e.last==null)return{...e,last:{value:n,at:r}};if(n>e.last.value)return{...e,last:{value:n,at:r}};const s=(r-e.last.at)/1e3;if(n===e.last.value||s<=0)return s>GB&&e.ewma!=null?{...e,ewma:null,positiveSamples:0}:e;const a=(e.last.value-n)/s;return{ewma:e.ewma==null?a:W1*a+(1-W1)*e.ewma,positiveSamples:e.positiveSamples+1,last:{value:n,at:r}}}function VB(e,n,r){return{...e,last:{value:n,at:r}}}function U1(e,n){return n<=0?0:e.ewma==null||e.ewma<=0||e.positiveSamples<KB?null:n/e.ewma}function QB(e){const n=e[0];if(n==null)return 0;if(e.length===1)return n.percent;const r=e.reduce((a,i)=>a+i.percent,0)/e.length;if(e.some(a=>a.etaSeconds==null))return r;const s=e.reduce((a,i)=>a+i.etaSeconds,0);return s<=0?r:e.reduce((a,i)=>a+i.percent*(i.etaSeconds/s),0)}function YB(e){const n=e.map(r=>r.etaSeconds).filter(r=>r!=null);return n.length>0?Math.max(...n):null}function XB(e){return e<60?`~${Math.max(5,Math.round(e/5)*5)} sec left`:e<5400?`~${Math.max(1,Math.round(e/60))} min left`:`~${Math.round(e/3600)} hr left`}function qC(e){const n=Math.max(1,Math.round(e/36e5));if(n<48)return`${n} hour${n===1?"":"s"}`;const r=Math.round(n/24);return`${r} day${r===1?"":"s"}`}function ZB(e,n){if(e.length===0)return null;const r=e.filter(d=>d.paused==null),s=e.length-r.length,a=s>0?` · ${s} waiting`:"";if(r.length===0)return`Catch-up queued · ${s} waiting`;const i=qC(n-Math.min(...r.map(d=>d.sinceMs)));return`Catching up · ${r.length>1?`${r.length} repos · oldest `:""}${i} behind${a}`}function H1(e){return e.length===0?0:e.reduce((r,s)=>r+Math.min(1,Math.max(0,s.percent)),0)/e.length*100}function JB(e){return e.reduce((n,r)=>n+(1-Math.min(1,Math.max(0,r.percent))),0)}function e7(e){if(!e)return"resuming shortly";const n=new Date(e);return Number.isNaN(n.getTime())?"resuming shortly":`resuming ~${n.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}`}function t7(){var O,E,ee;const e=f.useRef(!1),n=$x(e.current),r=n.data,s=Tp(r),a=zB(s),i=((O=a.data)==null?void 0:O.backfills)??[],c=((E=a.data)==null?void 0:E.catchups)??[],d=[...i,...c],u=i.length>0,m=d.length>0;e.current=m;const h=m||s,g=f.useRef(Ao()),x=f.useRef(Ao()),y=f.useRef(0),b=f.useRef(0),w=f.useRef(""),k=f.useRef(new Map),j=f.useRef(!1);h&&!j.current&&(g.current=Ao(),x.current=Ao(),y.current=0,b.current=0,w.current="",k.current=new Map),j.current=h;const N=m&&d.every(K=>K.paused!=null),I=JB(d),S=m&&I<=.01,T=[];let $=0,P=0;if(h){const K=`${m?"b":""}${s?"m":""}`;let U=!1;K!==w.current&&(w.current=K,U=!0);const Q=k.current,J=new Map;for(const ae of d){const we=Math.min(1,Math.max(0,ae.percent)),$e=Q.get(ae.repoId);($e==null||we<$e-.02)&&(U=!0),J.set(ae.repoId,we)}J.size<Q.size&&(U=!0),k.current=J,m?(g.current=N?VB(g.current,I,a.dataUpdatedAt):q1(g.current,I,a.dataUpdatedAt),T.push({percent:H1(d),etaSeconds:N||S?null:U1(g.current,I)})):g.current=Ao(),s&&r?(y.current=Math.max(y.current,r.pending+r.scoredThisRun),x.current=q1(x.current,r.pending,n.dataUpdatedAt),P=y.current,$=Math.max(0,P-r.pending),T.push({percent:P>0?$/P*100:0,etaSeconds:U1(x.current,r.pending)})):(y.current=0,x.current=Ao());const ne=QB(T);b.current=U?ne:Math.max(b.current,ne)}const[C,L]=f.useState(!1);if(f.useEffect(()=>{if(h){L(!0);return}if(!C)return;const K=window.setTimeout(()=>{L(!1),g.current=Ao(),x.current=Ao(),y.current=0,b.current=0,w.current="",k.current=new Map},1e3);return()=>window.clearTimeout(K)},[h,C]),!h&&!C)return null;const F=Math.min(100,Math.round(b.current)),M=YB(T),D=h&&!s&&N,A=d.find(K=>{var U;return((U=K.paused)==null?void 0:U.reason)==="rate_limit"}),W=i.filter(K=>{var U;return((U=K.paused)==null?void 0:U.reason)==="queued"}).length,z=i.length-W,te=Math.round(H1(i)),H=ZB(c,Date.now()),B=m&&!s&&!!(r!=null&&r.enabled)&&((r==null?void 0:r.pending)??0)>0;return t.jsxs("div",{role:"status","aria-label":"Background loading",className:`pointer-events-none rounded-lg border border-gray-200 bg-white/95 p-3 shadow-lg backdrop-blur transition-opacity duration-500 dark:border-gray-700 dark:bg-gray-900/95 ${h?"opacity-100":"opacity-0"}`,children:[t.jsxs("div",{className:"mb-1 flex items-baseline justify-between gap-2",children:[t.jsx("span",{className:"text-xs font-semibold text-gray-800 dark:text-gray-100",children:"Loading data"}),t.jsxs("span",{className:"text-xs font-semibold tabular-nums text-yellow-600 dark:text-yellow-400",children:[F,"%"]})]}),t.jsx("div",{role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":F,className:"h-1.5 w-full overflow-hidden rounded bg-gray-200 dark:bg-gray-800",children:t.jsx("div",{className:"h-1.5 rounded bg-yellow-500 transition-all duration-500 dark:bg-yellow-400",style:{width:`${F}%`}})}),t.jsx("div",{className:"mt-1 text-[11px] leading-snug text-gray-500 dark:text-gray-400",children:h?D?t.jsx("span",{className:"text-amber-600 dark:text-amber-400",children:A?`Paused — GitHub rate limit, ${e7((ee=A.paused)==null?void 0:ee.resumeAt)}`:"Paused — waiting for another sync"}):M!=null?XB(M):S&&!s?"finishing up…":"estimating…":"Done"}),u&&t.jsx("div",{className:"mt-0.5 text-[11px] leading-snug text-gray-500 dark:text-gray-400",children:z>0?`Backfilling ${z} repo${z===1?"":"s"} · ${te}%${W>0?` · ${W} waiting`:""}`:`Backfill queued · ${W} waiting`}),H!=null&&t.jsx("div",{className:"mt-0.5 text-[11px] leading-snug text-gray-500 dark:text-gray-400",children:H}),s&&r&&t.jsx("div",{className:"mt-0.5 text-[11px] leading-snug text-gray-500 dark:text-gray-400",children:`Classifying bot comments · ${$.toLocaleString()} of ${P.toLocaleString()} · ${P>0?Math.round($/P*100):0}%`}),B&&t.jsx("div",{className:"mt-0.5 text-[11px] leading-snug text-gray-400 dark:text-gray-500",children:"Classification waiting…"})]})}function hh(e){return e==="ci_failed"||e==="trunk_ci_failed"}const n7=[];function r7(e){if(e.kind==="claude_review")return{color:"",label:"Claude Review",className:"bg-ai-signal/10 text-ai-signal"};if(e.kind==="ci_failed")return{color:"#ef4444",label:"CI failed"};if(e.kind==="trunk_ci_failed")return{color:"#ef4444",label:"Trunk CI failed"};if(e.kind==="review_submitted"&&e.reviewState!=null)return{color:s7[e.reviewState].color,label:`Review: ${a7[e.reviewState]}`};const n=kS[e.kind];return{color:(n==null?void 0:n.color)??"#6b7280",label:(n==null?void 0:n.label)??e.kind}}const s7={approved:{label:"approved",color:"#22c55e"},changes_requested:{label:"requested changes",color:"#ef4444"},commented:{label:"commented",color:"#9ca3af"},dismissed:{label:"dismissed",color:"#9ca3af"},pending:{label:"pending",color:"#eab308"}},a7={approved:"Approved",changes_requested:"Request Changes",commented:"Comment",dismissed:"Dismissed",pending:"Pending"},o7={APPROVE:{label:"approve",color:"#22c55e"},REQUEST_CHANGES:{label:"request changes",color:"#ef4444"},COMMENT:{label:"comment",color:"#9ca3af"}};function UC(e,n,r){const s=wS(e);if(s)return{userId:(e==null?void 0:e.id)??null,kind:s.kind,label:s.label,color:r({login:e==null?void 0:e.githubLogin,kind:s.kind})};if(e){const a=n.get(e.id);if(a&&a.kind!=null)return{userId:e.id,kind:a.kind,label:a.label,color:r({login:e.githubLogin,kind:a.kind})}}return null}function m0(e,n){return{id:n,number:e.prNumber??0,title:e.prTitle??`#${e.prNumber??""}`,repoFullName:e.repoFullName,authorLogin:null,authorDisplayName:null,authorAvatarUrl:null}}const z1=800,K1=160,g0=80;function f0(e){return e===document.documentElement||e===document.body?window.scrollY:e.scrollTop}function i7(e,n){e===document.documentElement||e===document.body?window.scrollBy(0,n):e.scrollTop+=n}const l7=["untouched","replied_unresolved","likely_addressed","resolved"],c7=1440*60*1e3,d7=14;function xd({repoId:e,botsMode:n=!1,userIds:r=null}){var Le;const s=G(V=>V.workspaceId),a=G(V=>V.feedMyTurnOnly),i=G(V=>V.toggleFeedMyTurnOnly),c=G(V=>V.feedClaudeOnly),d=G(V=>V.toggleFeedClaudeOnly),u=G(V=>V.feedBotLens),m=G(V=>V.cycleFeedBotLens),h=G(V=>V.feedCatComments),g=G(V=>V.feedCatPrEvents),x=G(V=>V.toggleFeedCatComments),y=G(V=>V.toggleFeedCatPrEvents),b=G(V=>V.feedPrEventKinds),w=G(V=>V.toggleFeedPrEventKind),k=G(V=>V.feedNeedsReview),j=G(V=>V.toggleFeedNeedsReview),N=G(V=>V.feedShowCommits),I=G(V=>V.toggleFeedShowCommits),S=G(V=>V.feedCiLens),T=G(V=>V.cycleFeedCiLens),$=G(V=>V.feedIsolatedPrId),P=G(V=>V.feedNewCohorts),C=G(V=>V.pushFeedNewCohort),L=G(V=>V.markFeedNewCohortsSeen),F=G(V=>V.selectThread),M=G(V=>V.selectPr),D=G(V=>V.showPrComment),A=G(V=>V.openClaudeReview),W=G(V=>V.focusEventInTab),z=Ge(V=>V.openPrDetailTab),te=Ge(V=>V.openPrFocusTab),H=Dr().enabled,{data:B}=qi(s),O=co(s),E=hC(),{mutate:ee}=E,K=f.useMemo(()=>{const V=new Map;for(const xe of(B==null?void 0:B.reviewers)??[])xe.kind!=null&&V.set(xe.userId,xe);return V},[B]),U=f.useMemo(()=>{const V=new Map;for(const xe of(B==null?void 0:B.reviewers)??[])V.set(xe.userId,xe);return V},[B]),Q=f.useCallback((V,xe)=>{const ue=U.get(V);if(ue!=null){if(ue.automated)return!0;if(ue.isManualOverride)return!1}return(xe==null?void 0:xe.isBot)??!1},[U]),J=E.isPending?((Le=E.variables)==null?void 0:Le.userId)??null:null,ne=f.useCallback((V,xe)=>{s==null||!window.confirm(`Stop treating ${xe} as an automated reviewer in this Workspace?
66
+
67
+ This applies to every repo in the Workspace — not just this PR’s repo. It keeps the vendor name, and you can undo it from Bots › Settings.`)||ee({userId:V,body:{workspaceId:s,automated:!1}})},[ee,s]),ae=Ge(V=>V.activityFlashItemId),we=Ge(V=>V.clearActivityFlashItem),$e=e!=null?[e]:null,{data:Fe}=xn(),oe=f.useMemo(()=>{if(!Fe||s==null)return null;let V=null;for(const xe of Fe){if((e!=null?xe.id!==e:xe.workspaceId!==s)||!xe.lastIncrementalSyncAt)continue;const ue=new Date(xe.lastIncrementalSyncAt).getTime();Number.isNaN(ue)||(V==null||ue>V)&&(V=ue)}return V},[Fe,s,e]),re=G(V=>V.botAnalyticsWindow),X=n?re==="rolling_7"?7:re==="rolling_30"?30:14:null,le=X??d7,Ne=oe!=null?Date.now()-oe:null,Ve=$==null&&Ne!=null&&Ne>c7?`${n?`No bot activity in the last ${le} days`:`Nothing in the last ${le} days`}. Last synced ${qC(Ne)} ago.`:null,me=$,be=e==null&&!n&&r==null,at=BB(),ft=f.useRef(!1);f.useEffect(()=>{be&&!ft.current&&(ft.current=!0,at.mutate())},[be,at]);const{data:mt}=An(),se=f.useMemo(()=>Rn(mt??[]),[mt]),Ce=f.useMemo(()=>r!=null&&r.length>0&&r.every(V=>Q(V,se.get(V))),[r,Q,se]),_e=Ce?"all":u,{items:pe,users:Qe,total:ct,uncappedTotal:Bt,counts:Je,isLoading:Qt,isPlaceholderData:Ft,hasMore:fe,loadMore:rt,isFetchingMore:et}=WB({workspaceId:s,repoIds:$e,userIds:r,prId:me,excludeBots:!n&&_e==="hide",botsOnly:n,botWindowDays:X,includeAllCommits:!n&&N,includeCiFailures:!n&&S!=="off"}),It=f.useRef(null),Wt=f.useMemo(()=>Rn(Qe),[Qe]),St=f.useCallback(V=>V.actorId!=null&&Q(V.actorId,Wt.get(V.actorId)),[Q,Wt]),je=f.useMemo(()=>(Je==null?void 0:Je.myTurn)??pe.filter(V=>V.isMyTurn).length,[Je,pe]),Rt=f.useMemo(()=>(Je==null?void 0:Je.claude)??pe.filter(V=>V.kind==="claude_review").length,[Je,pe]),Pt=f.useMemo(()=>(Je==null?void 0:Je.bots)??pe.filter(St).length,[Je,pe,St]),qt=g?b:n7,Wn=f.useCallback(V=>{if(!h&&!g)return!0;const xe=V.kind==="review_comment"||V.kind==="pr_comment",ue=Fg(V.kind),Se=ue!=null&&(qt.length===0||qt.includes(ue));return h&&xe||g&&Se},[h,g,qt]),fr=f.useMemo(()=>(Je==null?void 0:Je.comments)??pe.filter(V=>V.kind==="review_comment"||V.kind==="pr_comment").length,[Je,pe]),Na=f.useMemo(()=>(Je==null?void 0:Je.prEvents)??pe.filter(V=>Fg(V.kind)!=null).length,[Je,pe]),uo=f.useMemo(()=>{const V=new Map;if(Je!=null&&Je.byEventType){for(const[xe,ue]of Object.entries(Je.byEventType))V.set(xe,ue);return V}for(const xe of pe){const ue=Fg(xe.kind);ue!=null&&V.set(ue,(V.get(ue)??0)+1)}return V},[Je,pe]),xr=f.useMemo(()=>{const V=Rk.filter(ue=>qt.includes(ue.id)).map(ue=>ue.label),xe=V.pop();return xe===void 0?"":V.length===0?xe:`${V.join(", ")} or ${xe}`},[qt]),hs=qt.length>0&&S!=="only"&&!c&&!a&&_e!=="only",ps=f.useCallback(V=>(V.kind==="pr_opened"||V.kind==="pr_ready_for_review")&&V.prAwaitingReview===!0,[]),Zs=f.useMemo(()=>(Je==null?void 0:Je.awaitingReview)??new Set(pe.filter(ps).map(V=>V.prId)).size,[Je,pe,ps]),As=f.useMemo(()=>(Je==null?void 0:Je.commits)??pe.filter(V=>V.kind==="commit_pushed").length,[Je,pe]),ho=f.useMemo(()=>(Je==null?void 0:Je.ciFailures)??pe.filter(V=>hh(V.kind)).length,[Je,pe]),[Yn,ai]=f.useState(()=>new Set),Sa=f.useCallback(V=>{ai(xe=>{const ue=new Set(xe);return ue.has(V)?ue.delete(V):ue.add(V),ue}),k&&j()},[k,j]),[ms,Ca]=f.useState(()=>new Set),Ir=f.useCallback(V=>{Ca(xe=>{const ue=new Set(xe);return ue.has(V)?ue.delete(V):ue.add(V),ue})},[]),Ra=f.useMemo(()=>{if(!n)return[];const V=(ue,Se)=>{var At;const Ye=Wt.get(ue),Ze=UC(Ye,K,O),Et=(At=Ze==null?void 0:Ze.label)!=null&&At.trim()?Ze.label:Dt(Ye,ue);return{actorId:ue,label:Et,color:(Ze==null?void 0:Ze.color)??"#6b7280",count:Se}};if(Je!=null&&Je.byBotActor){const ue=[];for(const[Se,Ye]of Object.entries(Je.byBotActor)){const Ze=Number(Se);Wt.has(Ze)&&ue.push(V(Ze,Ye))}return ue.sort((Se,Ye)=>Ye.count-Se.count)}const xe=new Map;for(const ue of pe){const Se=ue.actorId;if(Se==null)continue;const Ye=xe.get(Se);if(Ye){Ye.count+=1;continue}xe.set(Se,V(Se,1))}return[...xe.values()].sort((ue,Se)=>Se.count-ue.count)},[n,Je,pe,Wt,K,O]),Tr=f.useMemo(()=>{const V=new Map;if(Je!=null&&Je.byThreadState){for(const[xe,ue]of Object.entries(Je.byThreadState))V.set(xe,ue);return V}for(const xe of pe)xe.derivedState!=null&&V.set(xe.derivedState,(V.get(xe.derivedState)??0)+1);return V},[Je,pe]),Xr=f.useCallback(V=>{if(n){let Ze=V;return ms.size>0&&(Ze=Ze.filter(Et=>Et.actorId!=null&&ms.has(Et.actorId))),Yn.size>0&&(Ze=Ze.filter(Et=>Et.derivedState!=null&&Yn.has(Et.derivedState))),k&&(Ze=Ze.filter(ps)),Ze}const xe=a?V.filter(Ze=>Ze.isMyTurn):c?V.filter(Ze=>Ze.kind==="claude_review"):S==="only"?V.filter(Ze=>hh(Ze.kind)):V,ue=(h||g)&&S!=="only"?xe.filter(Wn):xe,Se=_e==="hide"?ue.filter(Ze=>!St(Ze)):_e==="only"?ue.filter(St):ue,Ye=Yn.size>0?Se.filter(Ze=>Ze.derivedState!=null&&Yn.has(Ze.derivedState)):Se;return k?Ye.filter(ps):Ye},[n,Yn,ms,a,c,S,_e,h,g,b,Wn,St,k,ps]),yn=f.useMemo(()=>Xr(pe),[Xr,pe]),Ms=f.useMemo(()=>{const V=yn.length!==pe.length?`${yn.length} shown · ${pe.length} loaded of ${ct}`:`${pe.length} of ${ct} loaded`,xe=Bt!=null&&Bt>ct?` · ${ct} most recent of ${Bt} in window`:"";return V+xe},[yn.length,pe.length,ct,Bt]),po=f.useRef(null),Br=f.useRef(null),Zr=f.useRef(new Map),Tn=f.useRef(new Map),mo=f.useRef(new Map),Jr=f.useRef(new Map),Ls=f.useRef(null),gs=f.useRef(null),Ot=f.useRef(null),oi=f.useRef(yn);oi.current=yn;const[en,Ia]=f.useState({start:0,end:12,top:0,bottom:0}),$r=f.useRef(en);$r.current=en;const Ta=f.useRef(()=>{}),Js=f.useRef(null),_r=f.useRef(null),tn=f.useCallback(()=>{const V=Br.current;if(!V||f0(V)<=g0){Js.current=null;return}const xe=oi.current,ue=$r.current;for(let Se=Math.max(0,ue.start);Se<Math.min(ue.end,xe.length);Se++){const Ye=Tn.current.get(xe[Se].id);if(Ye){Js.current={id:xe[Se].id,top:Ye.getBoundingClientRect().top,scrollHeight:V.scrollHeight};return}}Js.current=null},[]),$a=f.useCallback(()=>{Ot.current=null;const V=Br.current,xe=po.current;if(!V||!xe)return;tn();const ue=oi.current,Se=ue.length;if(Se===0){Ia(ut=>ut.start===0&&ut.end===0&&ut.top===0&&ut.bottom===0?ut:{start:0,end:0,top:0,bottom:0});return}const Ye=Zr.current;let Ze=0;for(const ut of Ye.values())Ze+=ut;const Et=Ye.size>0?Ze/Ye.size:K1,At=ut=>Ye.get(ue[ut].id)??Et,rn=V===document.scrollingElement||V===document.documentElement||V===document.body,Xn=rn?0:V.getBoundingClientRect().top,$n=rn?window.innerHeight:V.clientHeight,Fs=Xn-xe.getBoundingClientRect().top,yo=Fs-z1,es=Fs+$n+z1;let sr=0,Ln=Se,ar=0,ts=!1;for(let ut=0;ut<Se;ut++){const or=At(ut);if(!ts&&ar+or>=yo&&(sr=ut,ts=!0),ts&&ar>es){Ln=ut;break}ar+=or}ts||(sr=Se);const Ma=gs.current;if(Ma!=null){const ut=ue.findIndex(or=>or.id===Ma);ut>=0&&(ut<sr&&(sr=ut),ut>=Ln&&(Ln=ut+1))}let na=0,qe=0;for(let ut=0;ut<sr;ut++)na+=At(ut);for(let ut=Ln;ut<Se;ut++)qe+=At(ut);Ia(ut=>ut.start===sr&&ut.end===Ln&&ut.top===na&&ut.bottom===qe?ut:{start:sr,end:Ln,top:na,bottom:qe})},[tn]),Gt=f.useCallback(()=>{Ot.current==null&&(Ot.current=requestAnimationFrame($a))},[$a]);f.useEffect(()=>{const V=new ResizeObserver(xe=>{let ue=!1;for(const Se of xe){const Ye=Jr.current.get(Se.target);if(Ye==null)continue;const Ze=Se.target.offsetHeight,Et=Zr.current.get(Ye);(Et==null||Math.abs(Et-Ze)>.5)&&(Zr.current.set(Ye,Ze),ue=!0)}ue&&Gt()});Ls.current=V;for(const[xe,ue]of Tn.current)Jr.current.set(ue,xe),V.observe(ue);return()=>{V.disconnect(),Ls.current=null,Jr.current.clear()}},[Gt]);const _a=yn.length>0;f.useEffect(()=>{const V=Uf(It.current)??document.scrollingElement??document.documentElement;Br.current=V;const xe=V===document.scrollingElement||V===document.documentElement||V===document.body,ue=()=>{f0(V)<=g0&&Ta.current(),tn(),Gt()},Se=xe?window:V;Se.addEventListener("scroll",ue,{passive:!0}),window.addEventListener("resize",ue);const Ye=new ResizeObserver(ue);return Ye.observe(V),Gt(),()=>{Se.removeEventListener("scroll",ue),window.removeEventListener("resize",ue),Ye.disconnect()}},[Gt,tn,_a]),f.useEffect(()=>{Gt()},[yn,Gt]);const ea=f.useCallback(()=>{const V=Zr.current;if(V.size===0)return K1;let xe=0;for(const ue of V.values())xe+=ue;return xe/V.size},[]),Pa=f.useCallback(()=>{tn()},[tn]),{scopeKey:Mn}=HB({workspaceId:s,repoIds:$e,userIds:r,prId:me,excludeBots:!n&&_e==="hide",botsOnly:n,botWindowDays:X,includeAllCommits:!n&&N,includeCiFailures:!n&&S!=="off",enabled:be,onBeforeInsert:Pa});Ta.current=()=>{be&&L(Mn)};const Ea=f.useRef(null);f.useEffect(()=>{if(!be||pe.length===0||Ft)return;const V=Ea.current;if(V==null||V.scopeKey!==Mn){Ea.current={scopeKey:Mn,ids:new Set(pe.map(Ye=>Ye.id))};return}const xe=pe.findIndex(Ye=>V.ids.has(Ye.id)),ue=xe>0?pe.slice(0,xe).map(Ye=>Ye.id):[];for(const Ye of pe)V.ids.add(Ye.id);if(ue.length===0)return;const Se=Br.current;C(Mn,ue,Se==null||f0(Se)<=g0)},[pe,be,Mn,C,Ft]);const fs=f.useRef(null);f.useLayoutEffect(()=>{const V=_r.current;if(V!=null){_r.current=null;const Ze=Br.current;if(Ze){const Et=Tn.current.get(V.anchorId),At=Et?Et.getBoundingClientRect().top-V.anchorTop:Ze.scrollHeight-V.scrollHeight;Math.abs(At)>.5&&i7(Ze,At),Gt()}}const xe=fs.current;if(fs.current={scopeKey:Mn,items:pe,placeholder:Ft},!be||xe==null||xe.items===pe||xe.scopeKey!==Mn||xe.placeholder||Ft)return;const ue=UB(xe.items,pe,Xr);if(ue===0)return;const Se=Js.current;if(Se==null)return;_r.current={anchorId:Se.id,anchorTop:Se.top,scrollHeight:Se.scrollHeight};const Ye=ea();Ia(Ze=>({start:Ze.start+ue,end:Ze.end+ue,top:Ze.top+ue*Ye,bottom:Ze.bottom}))},[pe,en,Mn,be,Ft,Xr,ea,Gt]);const xs=f.useMemo(()=>{if(!be||P.scopeKey!==Mn)return null;const V=new Set;for(const xe of P.cohorts)for(const ue of xe.ids)V.add(ue);return V.size>0?V:null},[be,P,Mn]),Gi=f.useCallback(V=>{let xe=mo.current.get(V);return xe||(xe=ue=>{var Ye,Ze;const Se=Tn.current.get(V);Se&&Se!==ue&&((Ye=Ls.current)==null||Ye.unobserve(Se),Jr.current.delete(Se)),ue?(Tn.current.set(V,ue),Jr.current.set(ue,V),(Ze=Ls.current)==null||Ze.observe(ue)):Tn.current.delete(V)},mo.current.set(V,xe)),xe},[]),[go,fo]=f.useState(()=>new Set),[Aa,xo]=f.useState(()=>new Set),ta=f.useCallback(V=>{fo(xe=>{const ue=new Set(xe);return ue.has(V)?ue.delete(V):ue.add(V),ue})},[]),Vi=f.useCallback((V,xe)=>{xo(ue=>{if(xe===ue.has(V))return ue;const Se=new Set(ue);return xe?Se.add(V):Se.delete(V),Se})},[]),[Y,de]=f.useState(null);f.useEffect(()=>{if(ae==null)return;const V=ae;gs.current=V,Gt();let xe=0,ue=0;const Se=()=>{gs.current=null,Gt()},Ye=()=>{const Ze=Tn.current.get(V);Ze?(Ze.scrollIntoView({block:"center",behavior:"smooth"}),de(V),window.setTimeout(()=>{de(Et=>Et===V?null:Et),Se()},1800),we()):xe<12?(xe+=1,ue=requestAnimationFrame(Ye)):(Se(),we())};return ue=requestAnimationFrame(Ye),()=>cancelAnimationFrame(ue)},[ae,we,Gt]);const ke=f.useRef(null),Re=f.useRef(!1),Te=f.useRef(()=>{});Te.current=()=>{fe&&!et&&pe.length>0&&rt()};const Ie=fe&&pe.length>0;f.useEffect(()=>{const V=ke.current;if(!V)return;const xe=new IntersectionObserver(ue=>{var Se;Re.current=((Se=ue[0])==null?void 0:Se.isIntersecting)??!1,Re.current&&Te.current()},{root:Uf(V),rootMargin:"0px 0px 600px 0px"});return xe.observe(V),()=>xe.disconnect()},[Ie]),f.useEffect(()=>{!et&&Re.current&&Te.current()},[et,pe.length,fe]);const Xe=f.useCallback(V=>{const xe=V.prId;if(xe==null)return;const ue=m0(V,xe),Se={fromActivity:!0,returnItemId:V.id};if(V.kind==="claude_review"){A(ue,Se);return}z(ue,Se),V.threadId!=null?F(xe,V.threadId):V.commentId!=null?D(xe,V.commentId):M(xe)},[A,z,F,D,M]),Ke=f.useCallback((V,xe)=>{const ue=V.prId;ue!=null&&(z(m0(V,ue),{fromActivity:!0,returnItemId:V.id}),F(ue,xe))},[z,F]),ze=f.useCallback(V=>{const xe=V.prId;if(xe!=null&&(te(m0(V,xe),{fromActivity:!0,returnItemId:V.id}),V.kind!=="claude_review"&&!hh(V.kind))){const ue=V.threadId??V.commentId??null,Se=V.kind==="review_comment"?V.threadId:null;W(xe,V.occurredAt,{type:V.kind,refId:ue},Se)}},[te,W]),st=yn.slice(en.start,en.end);return t.jsxs("div",{className:"space-y-3","data-testid":"feed-view",ref:It,children:[t.jsxs("div",{className:"space-y-2 px-0.5",children:[n?Ra.length>0&&t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("span",{className:"text-[11px] font-semibold text-gray-500 dark:text-gray-400",children:"Vendor"}),Ra.map(V=>{const xe=ms.has(V.actorId);return t.jsxs("button",{type:"button",onClick:()=>Ir(V.actorId),"aria-pressed":xe,className:`flex items-center gap-1.5 rounded-full border px-2.5 py-1 text-xs font-medium transition-colors ${xe?"border-sky-400 bg-sky-50 text-sky-700 dark:border-sky-500/60 dark:bg-sky-950/30 dark:text-sky-300":"border-gray-300 text-gray-500 hover:border-gray-400 dark:border-gray-700 dark:text-gray-400"}`,title:`Show only ${V.label}`,children:[t.jsx(Lt,{}),t.jsx("span",{"aria-hidden":"true",className:"inline-block h-2 w-2 rounded-full",style:{background:V.color}}),V.label,t.jsx("span",{className:"tabular-nums opacity-70",children:V.count})]},V.actorId)})]}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsxs("button",{type:"button",onClick:i,"aria-pressed":a,className:`flex items-center gap-1 rounded-full border px-2.5 py-1 text-xs font-medium transition-colors ${a?"border-yellow-400 bg-yellow-50 text-yellow-700 dark:border-yellow-500/60 dark:bg-yellow-950/30 dark:text-yellow-300":"border-gray-300 text-gray-500 hover:border-gray-400 dark:border-gray-700 dark:text-gray-400"}`,title:"Show only items that concern you (My Turn)",children:[t.jsx(kx,{})," My Turn",je>0&&t.jsx("span",{className:"tabular-nums opacity-70",children:je})]}),H&&t.jsxs("button",{type:"button",onClick:d,"aria-pressed":c,className:`flex items-center gap-1 rounded-full border px-2.5 py-1 text-xs font-medium transition-colors ${c?"border-ai-signal/50 bg-ai-signal/10 text-ai-signal hover:border-ai-signal":"border-gray-300 text-gray-500 hover:border-gray-400 dark:border-gray-700 dark:text-gray-400"}`,title:"Show only Claude Reviews",children:[t.jsx(Ps,{})," Claude Reviews",Rt>0&&t.jsx("span",{className:"tabular-nums opacity-70",children:Rt})]}),t.jsxs("button",{type:"button",onClick:x,"aria-pressed":h,className:`flex items-center gap-1 rounded-full border px-2.5 py-1 text-xs font-medium transition-colors ${h?"border-teal-400 bg-teal-50 text-teal-700 dark:border-teal-500/60 dark:bg-teal-950/30 dark:text-teal-300":"border-gray-300 text-gray-500 hover:border-gray-400 dark:border-gray-700 dark:text-gray-400"}`,title:"Show comment activity (review threads + PR comments)",children:[t.jsx(Qo,{})," Comments",fr>0&&t.jsx("span",{className:"tabular-nums opacity-70",children:fr})]}),t.jsxs("button",{type:"button",onClick:y,"aria-pressed":g,className:`flex items-center gap-1 rounded-full border px-2.5 py-1 text-xs font-medium transition-colors ${g?"border-indigo-400 bg-indigo-50 text-indigo-700 dark:border-indigo-500/60 dark:bg-indigo-950/30 dark:text-indigo-300":"border-gray-300 text-gray-500 hover:border-gray-400 dark:border-gray-700 dark:text-gray-400"}`,title:"Show PR events (opens, merges, closes, reopens, ready-for-review, reviews)",children:[t.jsx(Nd,{})," PR events",Na>0&&t.jsx("span",{className:"tabular-nums opacity-70",children:Na})]}),t.jsxs("button",{type:"button",onClick:I,"aria-pressed":N,className:`flex items-center gap-1 rounded-full border px-2.5 py-1 text-xs font-medium transition-colors ${N?"border-amber-400 bg-amber-50 text-amber-700 dark:border-amber-500/60 dark:bg-amber-950/30 dark:text-amber-300":"border-gray-300 text-gray-500 hover:border-gray-400 dark:border-gray-700 dark:text-gray-400"}`,title:"Show individual commit pushes in the feed (off by default) — on surfaces every push run, off keeps only pushes that addressed a review thread",children:[t.jsx(Y4,{})," Commits",As>0&&t.jsx("span",{className:"tabular-nums opacity-70",children:As})]}),t.jsxs("button",{type:"button",onClick:T,"aria-pressed":S!=="off",className:`flex items-center gap-1 rounded-full border px-2.5 py-1 text-xs font-medium transition-colors ${S==="only"?"border-red-500 bg-red-500 text-white dark:border-red-500 dark:bg-red-600 dark:text-white":S==="feed"?"border-red-400 bg-red-50 text-red-700 dark:border-red-500/60 dark:bg-red-950/30 dark:text-red-300":"border-gray-300 text-gray-500 hover:border-gray-400 dark:border-gray-700 dark:text-gray-400"}`,title:S==="feed"?"CI failures are shown in the feed — click to show ONLY CI failures. One card per failed check run, on pull-request heads and on the default branch. Times are when Limn DETECTED the failure, which can lag the build.":S==="only"?"Showing ONLY CI failures — click to hide them again":"CI failures are hidden — click to show them in the feed, then again for CI failures only. One card per failed check run, on pull-request heads and on the default branch.",children:[t.jsx(Jt,{}),S==="only"?"CI failures only":"CI failures",ho>0&&S!=="off"&&t.jsx("span",{className:"tabular-nums opacity-70",children:ho})]}),!Ce&&(Pt>0||u!=="all")&&t.jsxs("button",{type:"button",onClick:m,"aria-pressed":u!=="all",className:`flex items-center gap-1 rounded-full border px-2.5 py-1 text-xs font-medium transition-colors ${u!=="all"?"border-sky-400 bg-sky-50 text-sky-700 dark:border-sky-500/60 dark:bg-sky-950/30 dark:text-sky-300":"border-gray-300 text-gray-500 hover:border-gray-400 dark:border-gray-700 dark:text-gray-400"}`,title:"Tame the bot firehose: click to cycle all activity → hide bot noise → bot activity only",children:[t.jsx(Lt,{}),u==="hide"?"Bots hidden":u==="only"?"Bots only":"Bots",u==="all"&&t.jsx("span",{className:"tabular-nums opacity-70",children:Pt})]})]}),g&&t.jsxs("div",{className:"flex flex-wrap items-center gap-2 pl-3",children:[t.jsx("span",{className:"text-[11px] font-semibold text-gray-500 dark:text-gray-400",children:"Kind"}),Rk.map(V=>{const xe=qt.includes(V.id),ue=uo.get(V.id)??0;return t.jsxs("button",{type:"button",onClick:()=>w(V.id),"aria-pressed":xe,className:`flex items-center gap-1 rounded-full border px-2.5 py-1 text-xs font-medium transition-colors ${xe?"border-indigo-400 bg-indigo-50 text-indigo-700 dark:border-indigo-500/60 dark:bg-indigo-950/30 dark:text-indigo-300":"border-gray-300 text-gray-500 hover:border-gray-400 dark:border-gray-700 dark:text-gray-400"}`,title:V.title,children:[V.label,ue>0&&t.jsx("span",{className:"tabular-nums opacity-70",children:ue})]},V.id)})]})]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("span",{className:"text-[11px] font-semibold text-gray-500 dark:text-gray-400",children:"State"}),l7.map(V=>{const xe=Xt[V],ue=Yn.has(V),Se=Tr.get(V)??0;return t.jsxs("button",{type:"button",onClick:()=>Sa(V),"aria-pressed":ue,className:`flex items-center gap-1.5 rounded-full border px-2.5 py-1 text-xs font-medium transition-colors ${ue?"border-sky-400 bg-sky-50 text-sky-700 dark:border-sky-500/60 dark:bg-sky-950/30 dark:text-sky-300":"border-gray-300 text-gray-500 hover:border-gray-400 dark:border-gray-700 dark:text-gray-400"}`,title:xe.description,children:[t.jsx("span",{"aria-hidden":"true",className:"inline-block h-2 w-2 rounded-full",style:{background:xe.color}}),xe.label,Se>0&&t.jsx("span",{className:"tabular-nums opacity-70",children:Se})]},V)}),t.jsx("span",{className:"ml-1 text-[11px] font-semibold text-gray-500 dark:text-gray-400",children:"PR"}),t.jsxs("button",{type:"button",onClick:()=>{!k&&Yn.size>0&&ai(new Set),j()},"aria-pressed":k,className:`flex items-center gap-1 rounded-full border px-2.5 py-1 text-xs font-medium transition-colors ${k?"border-indigo-400 bg-indigo-50 text-indigo-700 dark:border-indigo-500/60 dark:bg-indigo-950/30 dark:text-indigo-300":"border-gray-300 text-gray-500 hover:border-gray-400 dark:border-gray-700 dark:text-gray-400"}`,title:"PRs still awaiting a first review — shows their opened / marked-ready cards · last 14 days",children:["Needs review",Zs>0&&t.jsx("span",{className:"tabular-nums opacity-70",children:Zs})]}),pe.length>0&&t.jsx("span",{className:"text-[11px] text-gray-400",children:Ms})]})]}),pe.length===0?s==null||Qt?t.jsxs("div",{role:"status","aria-label":"Loading activity",className:"flex h-32 flex-col justify-center gap-2 px-1",children:[t.jsx("div",{className:"h-3 w-1/3 animate-pulse rounded bg-gray-100 dark:bg-gray-900/40"}),t.jsx("div",{className:"h-3 w-2/3 animate-pulse rounded bg-gray-100 dark:bg-gray-900/40"}),t.jsx("div",{className:"h-3 w-1/2 animate-pulse rounded bg-gray-100 dark:bg-gray-900/40"})]}):t.jsx("div",{className:"flex h-32 items-center justify-center px-4 text-center text-sm text-gray-400",children:Ve??(n?"No bot activity yet — automated-reviewer activity across your repos will appear here.":"Nothing to show yet — activity across your repos will appear here.")}):yn.length===0&&Ft?t.jsx("div",{className:"flex h-32 items-center justify-center text-sm text-gray-400",children:"Loading…"}):yn.length===0?t.jsx("div",{className:"flex h-32 items-center justify-center text-sm text-gray-400",children:n?k?"No PRs awaiting a first review in this window.":Yn.size>0?"No bot activity matches these state filters.":"No bot activity in this window.":k?"No PRs awaiting a first review in this window.":Yn.size>0?"Nothing matches these state filters.":hs?`No ${xr} PR events in this window.`:c?"No Claude Reviews in this window.":a?"Nothing needs your attention right now.":_e==="only"?"No bot activity in this window.":_e==="hide"?"Only bot activity here — nothing from humans in this window.":"Nothing needs your attention right now."}):t.jsxs("ul",{ref:po,children:[en.top>0&&t.jsx("li",{"aria-hidden":!0,style:{height:en.top}}),st.map(V=>t.jsx(b7,{item:V,usersById:Wt,identityByUserId:K,botColor:O,overridePendingUserId:J,onNotBot:ne,isNew:(xs==null?void 0:xs.has(V.id))??!1,flash:Y===V.id,expanded:go.has(V.id),onToggleExpanded:ta,replyOpen:Aa.has(V.id),onSetReplyOpen:Vi,innerRef:Gi(V.id),onOpen:Xe,onOpenThread:Ke,onFocus:ze},V.id)),en.bottom>0&&t.jsx("li",{"aria-hidden":!0,style:{height:en.bottom}})]}),Ie&&t.jsx("div",{ref:ke,className:"flex justify-center pt-1",children:et?t.jsxs("span",{className:"flex items-center gap-2 py-1.5 text-xs text-gray-400",children:[t.jsx("span",{className:"h-3 w-3 animate-spin rounded-full border-2 border-gray-300 border-t-transparent dark:border-gray-600 dark:border-t-transparent"}),"Loading more…"]}):t.jsx("button",{type:"button",onClick:()=>void rt(),className:"rounded-full border border-gray-300 px-4 py-1.5 text-xs font-medium text-gray-600 hover:border-gray-400 hover:bg-gray-50 dark:border-gray-700 dark:text-gray-300 dark:hover:border-gray-500 dark:hover:bg-gray-800/50",children:"Load more"})})]})}function u7({item:e}){const{data:n,isLoading:r}=Sp(e.threadId),{data:s}=An(),a=f.useMemo(()=>Rn(s),[s]),[i,c]=f.useState(!1),d=f.useMemo(()=>{if(!n||e.actorId==null)return null;const m=new Date(e.occurredAt).getTime();let h=null;for(const g of n.comments){if(g.authorId!==e.actorId)continue;const x=Math.abs(new Date(g.createdAt).getTime()-m);(h==null||x<h.dist)&&(h={id:g.id,dist:x})}return(h==null?void 0:h.id)??null},[n,e.actorId,e.occurredAt]),u=e.prNumber!=null?`https://github.com/${e.repoFullName}/pull/${e.prNumber}`:"";if(r)return t.jsx("div",{className:"px-1 py-2 text-xs text-gray-400",children:"Loading conversation…"});if(!n)return t.jsx("div",{className:"px-1 py-2 text-xs text-gray-400",children:"Couldn’t load this conversation."});if(n.derivedState==="resolved"){const m=n.path.split("/").pop()??n.path,h=n.comments.length;return t.jsxs("div",{children:[t.jsxs("button",{type:"button",onClick:()=>c(g=>!g),"aria-expanded":i,className:"group/rt flex w-full cursor-pointer items-center gap-1.5 rounded border border-gray-200 bg-white/60 px-2 py-1 text-left text-[11px] hover:border-sky-300 dark:border-gray-800 dark:bg-gray-900/40 dark:hover:border-sky-700",children:[!i&&t.jsx("span",{className:"shrink-0",children:t.jsx(Wx,{state:n.derivedState})}),t.jsxs("code",{className:"truncate font-mono text-gray-600 group-hover/rt:text-sky-600 dark:text-gray-300",children:[m,!i&&n.line!=null?`:${n.line}`:""]}),!i&&t.jsx("span",{className:"shrink-0 text-gray-400",children:h===1?"1 comment":`${h} comments`}),t.jsx("span",{className:`ml-auto shrink-0 text-sky-600 dark:text-sky-400 ${i?"":"opacity-0 group-hover/rt:opacity-100"}`,children:i?"Hide":"Show"})]}),i&&t.jsx("div",{className:"mt-1.5 cursor-default",children:t.jsx(Li,{thread:n,usersById:a,prUrl:u,repoId:e.repoId,highlightCommentId:d})})]})}return t.jsx(Li,{thread:n,usersById:a,prUrl:u,repoId:e.repoId,highlightCommentId:d})}function h7({prId:e}){var a;const{data:n,isLoading:r}=ya(e);if(r)return t.jsx("div",{className:"mt-1 px-1 text-xs text-gray-400",children:"Loading summary…"});const s=(a=n==null?void 0:n.body)==null?void 0:a.trim();return s?t.jsx("div",{className:"mt-1 max-h-72 overflow-auto rounded bg-gray-50 px-2 py-1.5 text-sm dark:bg-gray-900/50",children:t.jsx(gr,{children:s})}):t.jsx("div",{className:"mt-1 px-1 text-xs text-gray-400",children:"No description."})}function p7({prId:e,commentId:n}){var i,c;const{data:r,isLoading:s}=ya(e);if(s)return t.jsx("span",{className:"text-xs text-gray-400",children:"Loading comment…"});const a=(c=(i=r==null?void 0:r.comments.find(d=>d.id===n))==null?void 0:i.body)==null?void 0:c.trim();return a?t.jsx(gr,{children:a}):t.jsx("span",{className:"text-xs italic text-gray-400",children:"Comment body unavailable — open the PR to view."})}function m7({item:e}){const[n,r]=f.useState(!1),s=e.ciStatus!=null&&e.ciStatus!=="unknown"?Rr[e.ciStatus]:null,a=e.changedFilesCount,i=e.prId;return t.jsxs("div",{className:"mt-1.5 space-y-1.5",children:[(s!=null||a!=null)&&t.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px] text-gray-500 dark:text-gray-400",children:[s!=null&&t.jsxs("span",{className:"inline-flex items-center gap-1 font-medium",style:{color:s.color},children:[t.jsx("span",{"aria-hidden":"true",className:"inline-block h-2 w-2 rounded-full",style:{background:s.color}}),s.label]}),a!=null&&t.jsxs("span",{children:[a," ",a===1?"file":"files"," changed"]}),t.jsx(Md,{pr:e})]}),i!=null&&t.jsxs("div",{onClick:c=>c.stopPropagation(),children:[t.jsx("button",{type:"button",onClick:()=>r(c=>!c),className:"text-[11px] font-medium text-sky-600 hover:underline dark:text-sky-400",children:n?"Hide summary":"Show summary"}),n&&t.jsx(h7,{prId:i})]})]})}function g7({thread:e,author:n,onOpen:r}){const s=Xt[e.derivedState],a=e.path.split("/").pop()??e.path;return t.jsx("li",{children:t.jsxs("button",{type:"button",onClick:r,className:"group/th block w-full rounded border border-gray-200 bg-white/60 px-2 py-1 text-left hover:border-sky-300 dark:border-gray-800 dark:bg-gray-900/40 dark:hover:border-sky-700",children:[t.jsxs("span",{className:"flex items-center gap-1.5 text-[11px]",children:[t.jsx("span",{"aria-hidden":"true",className:"inline-block h-2 w-2 shrink-0 rounded-full",style:{background:s.color}}),t.jsxs("code",{className:"truncate font-mono text-gray-600 group-hover/th:text-sky-600 dark:text-gray-300",children:[a,e.line!=null?`:${e.line}`:""]}),t.jsx("span",{className:"shrink-0 text-gray-400",children:s.label.toLowerCase()})]}),e.excerpt.trim()!==""&&t.jsxs("span",{className:"mt-0.5 block truncate text-xs italic text-gray-500 dark:text-gray-400",children:[n!=null?`${Dt(n,e.authorId)}: `:"","“",e.excerpt,"”"]})]})})}function f7({affected:e,usersById:n,onOpenThread:r}){const[s,a]=f.useState(!1),i=e.filter(u=>u.derivedState!=="resolved"),c=e.filter(u=>u.derivedState==="resolved"),d=u=>t.jsx(g7,{thread:u,author:u.authorId!=null?n.get(u.authorId):void 0,onOpen:()=>r(u.threadId)},u.threadId);return t.jsxs("ul",{className:"space-y-1.5",children:[i.map(d),c.length>0&&t.jsx("li",{children:t.jsxs("button",{type:"button",onClick:u=>{u.stopPropagation(),a(m=>!m)},className:"text-[11px] text-gray-400 hover:text-gray-600 dark:hover:text-gray-200",children:[s?"Hide":"Show"," ",c.length," resolved"," ",c.length===1?"thread":"threads"]})}),s&&c.map(d)]})}const x7=160;function y7({item:e,usersById:n,identityByUserId:r,botColor:s,overridePendingUserId:a,onNotBot:i,isNew:c,flash:d,expanded:u,onToggleExpanded:m,replyOpen:h,onSetReplyOpen:g,innerRef:x,onOpen:y,onOpenThread:b,onFocus:w}){const k=r7(e),j=e.actorId!=null?n.get(e.actorId):void 0,N=f.useMemo(()=>UC(j,r,s),[j,r,s]),I=(N==null?void 0:N.userId)!=null&&a===N.userId,S=e.mergedById!=null?n.get(e.mergedById):void 0,T=S!=null||e.mergedById!=null?Dt(S,e.mergedById):null,$=f.useMemo(()=>(e.reviewers??[]).map($e=>Dt(n.get($e.userId),$e.userId)),[e.reviewers,n]),P=e.isMyTurn,C=e.kind==="claude_review",L=e.kind==="pr_merged",F=C?"Claude":e.actorId==null&&e.kind==="commit_pushed"?"A contributor":hh(e.kind)?"CI":Dt(j,e.actorId),M=e.prNumber!=null?`#${e.prNumber}${e.prTitle!=null?` ${e.prTitle}`:""}`:"",D=e.claudeVerdict!=null?o7[e.claudeVerdict]:null,A=e.affectedThreads??[],W=e.myTurnReasons[0],z=e.kind==="review_comment"&&e.threadId!=null,te=e.kind==="pr_comment"&&e.prId!=null,H=e.kind==="pr_opened",B=e.kind==="trunk_ci_failed",O=B?mn(e.githubUrl):void 0,E=B&&e.prId==null,ee=L&&T!=null&&e.mergedById!==e.actorId,K=L&&$.length>0,U=f.useRef(null),Q=f.useRef(null),[J,ne]=f.useState(!1),ae=e.content!=null&&e.content.trim()!=="";f.useEffect(()=>{const $e=U.current,Fe=Q.current;if(!$e||!Fe)return;const oe=()=>{u||ne($e.scrollHeight>$e.clientHeight+4)};oe();const re=new ResizeObserver(oe);return re.observe(Fe),()=>re.disconnect()},[e.content,u]);const we=$e=>{$e.target.closest("a,button")||E||y(e)};return t.jsx("li",{ref:x,className:"pb-2",children:t.jsxs("article",{onClick:we,className:`${E?"cursor-default":"cursor-pointer"} rounded-md border p-2.5 text-sm transition-colors ${d?"border-sky-400 ring-2 ring-sky-400/60 dark:border-sky-500":P?"border-yellow-400 bg-yellow-50/40 dark:border-yellow-500/50 dark:bg-yellow-950/15":C?"border-ai-border bg-ai-surface":"border-gray-200 hover:border-sky-300 dark:border-gray-800 dark:hover:border-sky-700"}`,children:[t.jsxs("div",{className:"flex items-center gap-2",children:[e.prId!=null&&t.jsx("button",{type:"button",onClick:$e=>{$e.stopPropagation(),w(e)},className:"shrink-0 rounded p-0.5 text-blue-500 hover:text-blue-600",title:"Focus — open this PR in its own isolated timeline tab","aria-label":"Focus this PR in its own timeline tab",children:t.jsx(eo,{size:13})}),c&&t.jsx("span",{className:"shrink-0 rounded-full bg-sky-500/15 px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-sky-600 dark:text-sky-300",title:"Arrived since you last looked at the top of the feed",children:"New"}),t.jsx("span",{className:"shrink-0 text-[11px] text-gray-400",title:Cn(e.occurredAt),children:Nt(e.occurredAt)}),t.jsx(gn,{user:j,size:20}),j!=null&&!C?t.jsx("span",{className:"truncate font-medium text-gray-800 dark:text-gray-100",children:t.jsx(mr,{user:j,fallbackId:e.actorId,repoId:e.repoId??void 0})}):t.jsx("span",{className:"truncate font-medium text-gray-800 dark:text-gray-100",children:F}),N&&t.jsxs("span",{className:"group/bot inline-flex shrink-0 items-center gap-1",children:[t.jsxs("span",{className:"inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] font-medium",style:{color:N.color,background:`${N.color}1a`},title:`${N.label} — an automated reviewer Limn triages`,children:[t.jsx(Lt,{size:11}),N.label]}),N.userId!=null&&t.jsx("button",{type:"button",onClick:$e=>{$e.stopPropagation(),N.userId!=null&&i(N.userId,N.label)},disabled:I,className:"text-[9px] text-gray-400 underline underline-offset-2 opacity-0 transition-opacity hover:text-gray-600 disabled:opacity-40 group-hover/bot:opacity-100 dark:hover:text-gray-200",title:"Not a bot? Stop treating this reviewer as automated ACROSS THIS WHOLE WORKSPACE — every repo in it, not just this PR's. It keeps its vendor name, other Workspaces are unaffected, and you'll be asked to confirm.",children:I?"saving…":"not a bot?"})]}),t.jsx("span",{className:`inline-flex shrink-0 items-center gap-1 rounded px-1.5 py-0.5 text-[11px] font-medium ${k.className??""}`,style:k.className?void 0:{color:k.color,background:k.color+"1a"},children:k.label}),D!=null&&t.jsx("span",{className:"shrink-0 rounded px-1.5 py-0.5 text-[10px] font-medium",style:{color:D.color,background:D.color+"1a"},children:D.label}),P&&t.jsx("span",{className:"shrink-0 rounded bg-yellow-400/20 px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-yellow-700 dark:text-yellow-300",children:"My Turn"}),P&&W!=null&&t.jsx("span",{className:"shrink-0 rounded border border-yellow-300 px-1.5 py-0.5 text-[10px] font-medium text-yellow-700 dark:border-yellow-600/50 dark:text-yellow-300",title:e.myTurnReasons.map($e=>Ik[$e].title).join(" · "),children:Ik[W].label})]}),t.jsxs("div",{className:"mt-1 flex items-baseline gap-1.5 text-xs",children:[t.jsx("span",{className:"shrink-0 text-gray-400",children:e.repoFullName}),B&&M!==""&&t.jsxs("span",{className:"shrink-0 text-gray-400",children:["· ",e.prState==="merged"?"landed by":"from"]}),M!==""&&t.jsx("button",{type:"button",onClick:()=>y(e),className:"min-w-0 truncate font-medium text-gray-700 hover:text-sky-600 hover:underline dark:text-gray-200",children:M}),t.jsx(Up,{pr:e,iconOnly:!0,className:"self-center"}),!H&&t.jsx(Md,{pr:e,iconOnly:!0,className:"self-center"}),e.path!=null&&t.jsxs("span",{className:"shrink-0 text-gray-400",children:["· ",e.path.split("/").pop()]}),O!=null&&t.jsxs("a",{href:O,target:"_blank",rel:"noreferrer noopener",onClick:$e=>$e.stopPropagation(),className:"shrink-0 font-medium text-sky-600 hover:underline dark:text-sky-400",children:["commit ",(e.ciHeadSha??"").slice(0,7)," ",t.jsx(_t,{size:11,className:"inline-block align-[-0.1em]"})]})]}),H&&t.jsx(m7,{item:e}),ae&&!z&&t.jsxs("div",{className:"mt-1.5 rounded bg-gray-50 px-2 py-1.5 text-sm dark:bg-gray-900/50",children:[t.jsx("div",{ref:U,className:u?"":"overflow-hidden",style:u?void 0:{maxHeight:x7},children:t.jsx("div",{ref:Q,children:t.jsx(gr,{children:e.content})})}),(J||u)&&t.jsx("button",{type:"button",onClick:()=>m(e.id),className:"mt-1 text-[11px] font-medium text-sky-600 hover:underline dark:text-sky-400",children:u?"Show less":"Show more"})]}),te&&!ae&&e.commentId!=null&&e.prId!=null&&t.jsx("div",{className:"mt-1.5 rounded bg-gray-50 px-2 py-1.5 text-sm dark:bg-gray-900/50",children:t.jsx(p7,{prId:e.prId,commentId:e.commentId})}),e.mergedComments.length>0&&t.jsx("div",{className:"mt-1.5 space-y-1.5",children:e.mergedComments.map($e=>t.jsxs("div",{className:"rounded bg-gray-50 px-2 py-1.5 text-sm dark:bg-gray-900/50",children:[t.jsx("div",{className:"mb-0.5 text-[10px] font-semibold uppercase tracking-wide text-gray-400",children:"Also commented"}),t.jsx("div",{className:"max-h-72 overflow-auto",children:t.jsx(gr,{children:$e.content})})]},$e.commentId))}),(e.changeSummary!=null||A.length>0)&&t.jsxs("div",{className:"mt-1.5 space-y-1.5",children:[e.changeSummary!=null&&t.jsx("div",{className:"text-[11px] font-medium text-gray-500 dark:text-gray-400",children:e.changeSummary}),A.length>0&&t.jsx(f7,{affected:A,usersById:n,onOpenThread:$e=>b(e,$e)})]}),(ee||K)&&t.jsxs("div",{className:"mt-1.5 flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px] text-gray-500 dark:text-gray-400",children:[ee&&t.jsxs("span",{children:["Merged by ",t.jsx("span",{className:"font-medium",children:T})]}),K&&t.jsxs("span",{children:["Reviewed by ",t.jsx("span",{className:"font-medium",children:$.join(", ")})]})]}),z&&t.jsx("div",{className:"mt-1.5 cursor-default",onClick:$e=>$e.stopPropagation(),children:t.jsx(u7,{item:e})}),te&&e.prId!=null&&t.jsxs("div",{className:"mt-1.5",children:[h?t.jsx("div",{onClick:$e=>$e.stopPropagation(),children:t.jsx(hy,{prId:e.prId,initialBody:ES(e.content,(j==null?void 0:j.githubLogin)??null),autoFocus:!0,onCancel:()=>g(e.id,!1),onDone:()=>g(e.id,!1)})}):t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("button",{type:"button",onClick:$e=>{$e.stopPropagation(),g(e.id,!0)},className:"text-[11px] font-medium text-sky-600 hover:underline dark:text-sky-400",children:"Reply"}),e.commentId!=null&&t.jsx(zx,{prId:e.prId,target:{targetKind:"pr_comment",targetId:e.commentId}})]}),e.commentId!=null&&t.jsx("div",{className:"cursor-default",onClick:$e=>$e.stopPropagation(),children:t.jsx(Z5,{prId:e.prId,targetKind:"pr_comment",targetId:e.commentId})})]})]})})}const b7=f.memo(y7,(e,n)=>e.item===n.item&&e.isNew===n.isNew&&e.flash===n.flash&&e.expanded===n.expanded&&e.replyOpen===n.replyOpen&&e.overridePendingUserId===n.overridePendingUserId&&e.usersById===n.usersById&&e.identityByUserId===n.identityByUserId&&e.botColor===n.botColor&&e.onOpen===n.onOpen&&e.onOpenThread===n.onOpenThread&&e.onFocus===n.onFocus&&e.onNotBot===n.onNotBot&&e.onToggleExpanded===n.onToggleExpanded&&e.onSetReplyOpen===n.onSetReplyOpen&&e.innerRef===n.innerRef);function fy(){const e=G(a=>a.feedIsolatedPrId),n=G(a=>a.setFeedIsolatedPrId),{data:r}=Np();if(e==null)return null;const s=(r==null?void 0:r.prs.find(a=>a.id===e))??null;return t.jsxs("div",{className:"flex items-center gap-2 rounded-md border border-sky-300 bg-sky-50 px-3 py-1.5 text-xs text-sky-800 shadow-sm dark:border-sky-500/50 dark:bg-sky-950/60 dark:text-sky-200",children:[t.jsx(H4,{className:"shrink-0"}),t.jsxs("span",{className:"min-w-0 flex-1 truncate",children:["Showing only"," ",s!=null?t.jsxs(t.Fragment,{children:[t.jsxs("span",{className:"font-mono",children:["#",s.number]})," ",s.title]}):"the selected PR"]}),t.jsx("button",{type:"button",onClick:()=>n(null),className:"shrink-0 rounded border border-sky-400 px-2 py-0.5 font-medium hover:bg-sky-100 dark:border-sky-500/60 dark:hover:bg-sky-900/40",children:"Clear"})]})}function v7(e,n,r){return Oe({queryKey:["human-themes",e,dt(r)],queryFn:r==null?Ct:()=>he.humanThemes(e,r),enabled:n,staleTime:6e4})}const k7=5e3;function w7(e,n){const r=He(),[s,a]=f.useState(null);f.useEffect(()=>{if(s==null)return;const c=globalThis.setTimeout(()=>a(null),k7);return()=>globalThis.clearTimeout(c)},[s]);const i=tt({mutationFn:()=>{if(n==null)throw new Error("No workspace selected");return he.humanThemesRefresh(e,n)},onSuccess:c=>{r.setQueryData(["human-themes",e,dt(n)],c),r.invalidateQueries({queryKey:["ai-usage"]}),a(c.creditsExhausted?"Out of AI credits this month — the summary resumes on the 1st.":c.empty?"No human review comments in this workspace / window yet.":c.throttled?"A summary is already generating — showing the latest shortly.":null)}});return Object.assign(i,{notice:s})}const Hf={critical:{label:"Critical",cls:"bg-red-100 text-red-700 dark:bg-red-950/50 dark:text-red-300"},major:{label:"Major",cls:"bg-amber-100 text-amber-700 dark:bg-amber-950/50 dark:text-amber-300"},minor:{label:"Minor",cls:"bg-sky-100 text-sky-700 dark:bg-sky-950/50 dark:text-sky-300"},nit:{label:"Nit",cls:"bg-gray-100 text-gray-500 dark:bg-gray-800 dark:text-gray-400"}},j7={correctness:"Correctness",security:"Security",performance:"Performance",error_handling:"Error handling",testing:"Testing",style:"Style",docs:"Docs",maintainability:"Maintainability",other:"Other"};function HC({severity:e}){const n=Hf[e];return t.jsx("span",{className:`shrink-0 rounded px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide ${n.cls}`,children:n.label})}function N7({theme:e,ActorIcon:n,onOpenPr:r,onOpenTheme:s}){const a=e.threads.length>0;return t.jsx("li",{className:`rounded-md border border-gray-200 bg-white/70 p-3 dark:border-gray-800 dark:bg-gray-900/40 ${a?"cursor-pointer transition-colors hover:border-ai-signal/40 hover:bg-ai-surface-2":""}`,...a?{role:"button",tabIndex:0,onClick:()=>s(e),onKeyDown:i=>{(i.key==="Enter"||i.key===" ")&&(i.preventDefault(),s(e))}}:{},children:t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(HC,{severity:e.severity}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex items-baseline gap-2",children:[t.jsx("span",{className:"text-[13px] font-semibold text-gray-800 dark:text-gray-100",children:e.title}),t.jsx("span",{className:"shrink-0 rounded bg-gray-100 px-1 text-[9px] font-medium uppercase tracking-wide text-gray-500 dark:bg-gray-800 dark:text-gray-400",children:j7[e.category]}),e.commentCount!=null?t.jsxs("span",{className:"ml-auto shrink-0 text-[11px] font-semibold tabular-nums text-gray-600 dark:text-gray-300",title:"Comments across this theme's member clusters — computed from the clusters, not the model",children:[e.commentCount," comment",e.commentCount===1?"":"s"]}):e.occurrences>0?t.jsxs("span",{className:"ml-auto shrink-0 text-[10px] tabular-nums text-gray-400",title:"Approximate number of comments this theme covers",children:["≈",e.occurrences]}):null]}),e.summary&&t.jsx("p",{className:"mt-0.5 text-[12px] leading-relaxed text-gray-600 dark:text-gray-300",children:e.summary}),t.jsxs("div",{className:"mt-1.5 flex flex-wrap items-center gap-x-3 gap-y-1 text-[10px] text-gray-400",children:[e.bots.length>0&&t.jsxs("span",{children:[t.jsx(n,{size:11,className:"mr-1 inline-block align-[-0.1em] text-gray-400"}),e.bots.join(", ")]}),e.areas.length>0&&t.jsx("span",{className:"font-mono text-gray-500 dark:text-gray-400",children:e.areas.join(" · ")}),e.prs.length>0&&t.jsx("span",{className:"flex flex-wrap items-center gap-1",children:e.prs.map(i=>t.jsxs("button",{type:"button",onClick:c=>{c.stopPropagation(),r(i)},title:`${i.repoFullName}#${i.prNumber}${i.title?` — ${i.title}`:""} — open PR`,className:"rounded px-1 tabular-nums text-sky-600 hover:bg-sky-100 hover:underline dark:text-sky-400 dark:hover:bg-sky-950/50",children:["#",i.prNumber]},i.prId))}),a&&t.jsxs("span",{className:"ml-auto shrink-0 font-medium text-ai-signal",children:[e.threads.length," thread",e.threads.length===1?"":"s"," →"]})]})]})]})})}function S7({bySeverity:e}){return e.length===0?null:t.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",children:e.map(n=>t.jsxs("span",{className:`rounded px-1.5 py-0.5 text-[10px] font-semibold ${Hf[n.severity].cls}`,title:"Aggregated from the themes’ approximate occurrence estimates — the model’s read, not an exact count",children:[Hf[n.severity].label," · ",n.count]},n.severity))})}function C7({byArea:e}){if(e.length===0)return null;const n=e.reduce((r,s)=>r+s.count,0);return n===0?null:t.jsxs("div",{className:"mt-3",children:[t.jsx("div",{className:"mb-1 text-[11px] font-semibold uppercase tracking-wide text-gray-500 dark:text-gray-400",children:"Where"}),t.jsx("div",{className:"flex flex-wrap gap-1",children:e.map(r=>t.jsxs("span",{className:"rounded bg-gray-100 px-1.5 py-0.5 text-[10px] text-gray-600 dark:bg-gray-800 dark:text-gray-300",title:`${r.count} of ${n} comments`,children:[t.jsx("span",{className:"font-mono",children:r.area})," ",t.jsxs("span",{className:"tabular-nums text-gray-400",children:[Math.round(r.count/n*100),"%"]})]},r.area))})]})}function zC(){return t.jsx("div",{className:"mt-3 space-y-2","aria-hidden":"true",children:[0,1,2].map(e=>t.jsxs("div",{className:"rounded-md border border-gray-200 p-3 dark:border-gray-800",children:[t.jsx("div",{className:"digest-skeleton-line h-3.5",style:{width:"40%"}}),t.jsx("div",{className:"digest-skeleton-line mt-1.5 h-3",style:{width:"88%"}})]},e))})}function KC({narrative:e,themes:n,bySeverity:r,byArea:s,ActorIcon:a,emptyThemesLabel:i,reviewerSection:c,coverageLine:d,onOpenPr:u,onOpenTheme:m}){return t.jsxs("div",{className:"mt-3",children:[e&&t.jsx("div",{className:"rounded-md border border-ai-hairline bg-white/60 p-3 dark:bg-gray-900/40",children:t.jsx(Zp,{markdown:e,prRefs:[],onOpenPr:()=>{}})}),t.jsx(S7,{bySeverity:r}),n.length>0?t.jsx("ul",{className:"mt-3 space-y-2",children:n.map((h,g)=>t.jsx(N7,{theme:h,ActorIcon:a,onOpenPr:u,onOpenTheme:m},g))}):t.jsx("div",{className:"mt-3 text-[12px] text-gray-500 dark:text-gray-400",children:i}),c,t.jsx(C7,{byArea:s}),d]})}function Fi({meta:e,prefix:n,count:r}){return t.jsxs("span",{className:"shrink-0 rounded px-1 py-px text-[10px] font-medium tabular-nums",style:{...pn(e.color),background:`${e.color}1a`},title:e.description,children:[n,e.label,r!==void 0&&` · ${r}`]})}const R7=12;function fa(e){return{id:e.prId,number:e.prNumber,title:e.title??`#${e.prNumber}`,repoFullName:e.repoFullName,authorLogin:e.authorLogin??null,authorDisplayName:null,authorAvatarUrl:null}}function I7({prId:e,prNumber:n,repoFullName:r,refs:s}){var w;const{data:a,isLoading:i}=ya(e),c=Ge(k=>k.openPrDetailTab),d=f.useMemo(()=>Rn(a==null?void 0:a.users),[a]),u=(a==null?void 0:a.authorId)!=null?((w=d.get(a.authorId))==null?void 0:w.githubLogin)??null:null,m=()=>c(fa({prId:e,prNumber:n,repoFullName:r,title:a==null?void 0:a.title,authorLogin:u}),{fromActivity:!0}),h=k=>{m(),G.getState().selectThread(e,k)},g=new Set,x=new Set;for(const k of s)k.source==="review"&&k.threadId!=null?g.add(k.threadId):k.source==="issue"&&k.commentId!=null&&x.add(k.commentId);const y=((a==null?void 0:a.threads)??[]).filter(k=>g.has(k.id)),b=((a==null?void 0:a.comments)??[]).filter(k=>x.has(k.id));return t.jsxs("div",{className:"rounded-lg border border-gray-200 dark:border-gray-800",children:[t.jsxs("div",{className:"flex items-center gap-2 border-b border-gray-200 bg-gray-50 px-3 py-2 dark:border-gray-800 dark:bg-gray-900/50",children:[t.jsxs("span",{role:"button",tabIndex:0,onClick:m,onKeyDown:k=>{(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),m())},className:"min-w-0 flex-1 cursor-pointer truncate text-sm hover:underline",title:"Open this PR in its own detail tab",children:[t.jsx("span",{className:"font-mono text-gray-500 dark:text-gray-400",children:r})," ",t.jsxs("span",{className:"font-semibold text-gray-800 dark:text-gray-100",children:["#",n]}),a!=null&&a.title?t.jsxs("span",{className:"text-gray-600 dark:text-gray-300",children:[" — ",a.title]}):null]}),t.jsx("button",{type:"button",onClick:m,className:"shrink-0 rounded border border-sky-300 px-2 py-0.5 text-[11px] font-medium text-sky-600 hover:bg-sky-50 dark:border-sky-800 dark:text-sky-300 dark:hover:bg-sky-950/40",children:"Open PR →"})]}),t.jsx("div",{className:"space-y-2 p-3",children:i&&!a?t.jsx("div",{className:"h-16 animate-pulse rounded bg-gray-100 dark:bg-gray-900"}):t.jsxs(t.Fragment,{children:[y.map(k=>t.jsx(Li,{thread:k,usersById:d,prUrl:a.githubUrl,repoId:a.repoId,onOpenInPr:()=>h(k.id)},`t${k.id}`)),b.map(k=>t.jsx(NM,{comment:k,usersById:d,repoId:a==null?void 0:a.repoId},`c${k.id}`)),y.length===0&&b.length===0&&t.jsxs("div",{className:"text-[12px] text-gray-400",children:[s.length," comment",s.length===1?"":"s"," in this PR — not currently loaded (the thread may be outdated or still hydrating)."]})]})})]})}function T7(e,n,r,s){var b,w,k;let a=0,i=0;const c=new Set,d=new Set;for(const j of e)j.source==="review"?a+=1:i+=1,c.add(j.prId),d.add(j.repoFullName);const u={untouched:0,replied_unresolved:0,likely_addressed:0,resolved:0},m={high:0,minor:0,nit:0,labelled:0};let h=0,g=0;const x=new Set,y=new Set;for(const j of n){const N=r.get(j.prId);if(N==null)continue;h+=1;const I=new Map;for(const $ of N.threads??[])I.set($.id,$);const S=new Map;for(const $ of((b=s.get(j.prId))==null?void 0:b.labels)??[])S.set(`${$.targetKind}|${$.targetId}`,$.severity);const T=($,P)=>{const C=`${$}|${P}`;if(y.has(C))return;y.add(C);const L=S.get(C);L!=null&&(m.labelled+=1,L==="major"||L==="critical"?m.high+=1:L==="minor"?m.minor+=1:m.nit+=1)};for(const $ of j.refs)if($.source==="review"&&$.threadId!=null){const P=I.get($.threadId);if(P==null)continue;!x.has(P.id)&&P.derivedState in u&&(x.add(P.id),u[P.derivedState]+=1,g+=1);const C=(k=(w=P.comments)==null?void 0:w[0])==null?void 0:k.id;C!=null&&T("review_comment",C)}else $.source==="issue"&&$.commentId!=null&&T("pr_comment",$.commentId)}return{memberCount:e.length,reviewMembers:a,issueMembers:i,prCount:c.size,repoCount:d.size,shownPrCount:n.length,loadedPrCount:h,states:u,matchedThreads:g,ml:m}}function x0({label:e,color:n,count:r}){return t.jsxs("span",{className:"rounded px-1.5 py-0.5 text-[10px] font-medium tabular-nums",style:{...pn(n),background:`${n}1a`},children:[e," · ",r]})}function $7({members:e,shown:n}){const r=ba(),s=Xv({queries:n.map(u=>({queryKey:["pr",u.prId],queryFn:()=>he.pr(u.prId),staleTime:1/0,gcTime:ao}))}),a=Xv({queries:r?n.map(u=>({queryKey:Rp(u.prId),queryFn:()=>he.prMlLabels(u.prId),staleTime:1/0})):[]}),i=new Map,c=new Map;n.forEach((u,m)=>{var h,g;i.set(u.prId,(h=s[m])==null?void 0:h.data),c.set(u.prId,(g=a[m])==null?void 0:g.data)});const d=T7(e,n,i,c);return t.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1.5 rounded-md border border-gray-200 bg-gray-50 px-3 py-2 text-[11px] text-gray-500 dark:border-gray-800 dark:bg-gray-900/40 dark:text-gray-400","data-testid":"theme-metrics-strip",children:[t.jsxs("span",{title:"The theme's linked members — the resolved (capped) member set, not necessarily every comment the theme covers",children:[d.memberCount," linked member",d.memberCount===1?"":"s",d.reviewMembers>0&&d.issueMembers>0?` (${d.reviewMembers} in threads · ${d.issueMembers} PR-level)`:""]}),t.jsxs("span",{children:[d.prCount," PR",d.prCount===1?"":"s"," · ",d.repoCount," repo",d.repoCount===1?"":"s"]}),_7(d),d.ml.labelled>0&&t.jsxs("span",{className:"flex items-center gap-1",title:"ML severity of the linked findings (major+critical bucketed as high). Counts the LABELLED ones only — an unlabelled comment is silence, not agreement.",children:[d.ml.high>0&&t.jsx(x0,{label:"High",color:Ht.major.color,count:d.ml.high}),d.ml.minor>0&&t.jsx(x0,{label:"Minor",color:Ht.minor.color,count:d.ml.minor}),d.ml.nit>0&&t.jsx(x0,{label:"Nit",color:Ht.nit.color,count:d.ml.nit})]}),d.loadedPrCount<d.shownPrCount&&t.jsxs("span",{className:"text-gray-400 dark:text-gray-500",children:["· ",d.loadedPrCount," of ",d.shownPrCount," PRs loaded"]})]})}function _7(e){return e.matchedThreads===0?null:t.jsx("span",{className:"flex items-center gap-1",children:wd.map(n=>e.states[n]>0?t.jsx(Fi,{meta:Xt[n],count:e.states[n]},n):null)})}function P7(){const e=G(u=>u.themeThreadsSeed),n=Ge(u=>u.openPrDetailTab);if(!e)return t.jsx("div",{className:"p-6 text-sm text-gray-400",children:"No theme selected."});const{theme:r,source:s}=e,a=[],i=new Map;for(const u of r.threads){let m=i.get(u.prId);m||(m={prId:u.prId,prNumber:u.prNumber,repoFullName:u.repoFullName,refs:[]},i.set(u.prId,m),a.push(m)),m.refs.push(u)}const c=a.slice(0,R7),d=a.length-c.length;return t.jsxs("div",{className:"mx-auto max-w-[100rem] space-y-4 p-4",children:[t.jsxs("div",{children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx(HC,{severity:r.severity}),t.jsx("h2",{className:"text-base font-semibold text-gray-800 dark:text-gray-100",children:r.title}),t.jsx("span",{className:"rounded bg-gray-100 px-1.5 text-[10px] font-medium uppercase tracking-wide text-gray-500 dark:bg-gray-800 dark:text-gray-400",children:s==="bot"?"Bot theme":"Discussion theme"})]}),r.summary&&t.jsx("p",{className:"mt-1 text-sm text-gray-600 dark:text-gray-300",children:r.summary}),t.jsx("div",{className:"mt-2 flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px] text-gray-400",children:r.prs.length>0&&t.jsx("span",{className:"flex flex-wrap items-center gap-1",children:r.prs.map(u=>t.jsxs("button",{type:"button",onClick:()=>n(fa(u),{fromActivity:!0}),className:"rounded px-1 tabular-nums text-sky-600 hover:bg-sky-100 hover:underline dark:text-sky-400 dark:hover:bg-sky-950/50",title:`${u.repoFullName}#${u.prNumber} — open PR`,children:["#",u.prNumber]},u.prId))})})]}),r.threads.length===0?t.jsx("div",{className:"text-sm text-gray-400",children:"This theme has no linked threads."}):t.jsxs(t.Fragment,{children:[t.jsx($7,{members:r.threads,shown:c}),t.jsxs("div",{className:"space-y-3",children:[c.map(u=>t.jsx(I7,{prId:u.prId,prNumber:u.prNumber,repoFullName:u.repoFullName,refs:u.refs},u.prId)),d>0&&t.jsxs("div",{className:"text-[12px] text-gray-400",children:["+ ",d," more PR",d===1?"":"s"," not shown."]})]})]})]})}function E7({result:e}){return e.participants.length===0?null:t.jsxs("div",{className:"mt-3",children:[t.jsx("div",{className:"mb-1 text-[11px] font-semibold uppercase tracking-wide text-gray-500 dark:text-gray-400",children:"Most active"}),t.jsx("div",{className:"space-y-1",children:e.participants.map(n=>t.jsxs("div",{className:"flex items-center gap-2 text-[11px]",children:[t.jsx("span",{className:"min-w-0 flex-1 truncate text-gray-700 dark:text-gray-200",children:n.displayName||n.login||`#${n.userId}`}),t.jsxs("span",{className:"shrink-0 tabular-nums text-gray-500 dark:text-gray-400",children:[n.comments," comment",n.comments===1?"":"s"]})]},n.userId))})]})}function A7({result:e}){const n=e.coverage;return t.jsxs("div",{className:"mt-3 border-t border-ai-hairline pt-2 text-[10px] text-gray-400",children:["Summarised the top ",n.analyzed.toLocaleString()," of ",n.totalComments.toLocaleString()," review comment",n.totalComments===1?"":"s"," (prioritised by PR-level comments, then active threads, then recency)",n.truncated?" · older comments beyond the cap were excluded":"",". Generated ",new Date(e.generatedAt).toLocaleString(),"."]})}function M7(){var g,x,y;const{activityDigest:e}=vt(),n=G(b=>b.botAnalyticsWindow),r=G(b=>b.workspaceId),s=Ge(b=>b.openPrDetailTab),a=G(b=>b.openThemeThreadsDetail),i=v7(n,e,r),c=w7(n,r),d=ei(e),u=((g=d.data)==null?void 0:g.summaryTurnLimit)!=null&&(d.data.summaryTurnsRemaining??0)<=0;if(!e)return null;const m=((x=i.data)==null?void 0:x.result)??null,h=c.isPending;return t.jsxs("div",{className:"rounded-lg border border-ai-border bg-ai-surface p-4","data-testid":"human-themes-panel",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsxs("span",{className:"text-base font-semibold text-gray-800 dark:text-gray-100",children:[t.jsx(Qo,{size:15,className:"inline-block align-[-0.1em]"})," What people are discussing"]}),t.jsx("span",{className:"shrink-0 rounded bg-ai-signal/10 px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-ai-signal",children:"Pro"}),t.jsx("button",{type:"button",onClick:()=>{r!=null&&c.mutate()},disabled:h||u||r==null,className:"ml-auto rounded bg-ai-signal px-3 py-1 text-[11px] font-semibold text-white hover:opacity-90 disabled:opacity-50 dark:text-gray-950",title:u?"Out of AI credits — resets next month":"Summarise what people are raising in review across this Workspace (runs the Haiku model)",children:h?"Summarising…":m?t.jsxs(t.Fragment,{children:[t.jsx(us,{size:11,className:"mr-1 inline-block align-[-0.1em]"}),"Regenerate"]}):"Generate"})]}),t.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:"A read of what your reviewers keep raising — recurring concerns, debates, decisions, and questions across this Workspace’s human review comments (including replies on bot threads). Themes are an AI read (approximate); the volumes and “where” are exact."}),c.isError&&t.jsx("div",{className:"mt-2 text-[11px] text-red-500",children:((y=c.error)==null?void 0:y.message)??"Couldn’t generate the summary."}),!c.isError&&c.notice&&t.jsx("div",{className:"mt-2 text-[11px] text-gray-400",children:c.notice}),u&&t.jsx("div",{className:"mt-2 text-[11px] text-amber-600 dark:text-amber-400",children:"Out of AI credits this month — the summary resumes on the 1st. Any existing summary still shows."}),h&&!m?t.jsx(zC,{}):i.isLoading?t.jsx("div",{className:"mt-3 h-24 animate-pulse rounded bg-ai-surface-2"}):m?t.jsx("div",{className:"digest-fade-in",children:t.jsx(KC,{narrative:m.narrative,themes:m.themes,bySeverity:m.bySeverity,byArea:m.byArea,ActorIcon:Qo,emptyThemesLabel:"No distinct discussion themes surfaced in this window.",reviewerSection:t.jsx(E7,{result:m}),coverageLine:t.jsx(A7,{result:m}),onOpenPr:b=>s(fa(b),{fromActivity:!0}),onOpenTheme:b=>a(b,"human")})},m.generatedAt):t.jsx("div",{className:"mt-3 flex items-center justify-between gap-2 rounded-md border border-dashed border-ai-border p-3 text-[12px] text-gray-500 dark:text-gray-400",children:t.jsx("span",{children:"No summary yet — generate one to see what people are discussing in review."})})]})}function GC(e){const n=e;return Oe({queryKey:["workspace-metrics",n],queryFn:n==null?Ct:()=>he.workspaceMetrics(n),refetchInterval:5*6e4,refetchIntervalInBackground:!1,staleTime:6e4})}const L7="https://pierre-review.com/pricing",F7="/pricing",O7={inline:"rounded bg-ai-signal/15 px-1 text-[10px] font-semibold text-ai-signal",tab:"rounded bg-ai-signal/10 px-1 text-[9px] font-semibold uppercase tracking-wide text-ai-signal",heading:"rounded bg-ai-signal/10 px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-ai-signal"};function ec({variant:e="inline",className:n,title:r,srLabel:s="Pro feature"}){return t.jsxs("span",{className:`${O7[e]}${n?` ${n}`:""}`,title:r,children:[t.jsx("span",{"aria-hidden":"true",children:e==="inline"?"Pro":"pro"}),t.jsx("span",{className:"sr-only",children:s})]})}function dc({heading:e,children:n,testId:r,className:s}){var c;const i=((c=In().data)==null?void 0:c.deploymentMode)==="cloud"?F7:L7;return t.jsxs("div",{"data-testid":r,className:`rounded-lg border border-dashed border-ai-signal/25 bg-ai-signal/5 p-6 text-center${s?` ${s}`:""}`,children:[t.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-sm font-semibold text-gray-700 dark:text-gray-200",children:[t.jsx(i_,{size:13,className:"shrink-0 text-ai-signal"}),e]}),t.jsx("div",{className:"mx-auto mt-1.5 max-w-md text-[11px] leading-relaxed text-gray-500 dark:text-gray-400",children:n}),t.jsx("div",{className:"mt-3",children:t.jsxs("a",{href:i,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1.5 rounded border border-ai-signal/40 bg-ai-signal/10 px-2.5 py-1 text-[11px] font-medium text-ai-signal hover:bg-ai-signal/20",children:["See what Pro includes",t.jsx(_t,{size:11})]})})]})}function uc(e){const n=In();return e?"entitled":n.data==null?"pending":"locked"}function D7(e,n){return["flow-findings",dt(e),n]}function B7(e,n){const{periodReports:r}=vt();return Oe({queryKey:D7(e,n),queryFn:e==null?Ct:()=>he.flowFindings(e,n),enabled:r,refetchInterval:5*6e4,refetchIntervalInBackground:!1,staleTime:6e4})}const W7={md:"w-[34rem]",lg:"w-[44rem]"};function q7({title:e,onClose:n,children:r,width:s="md"}){const a=f.useId(),i=f.useRef(null),{refs:c,context:d}=wa({open:!0,onOpenChange:u=>{u||n()}});return f.useEffect(()=>{Hp()},[]),f.useEffect(()=>{const u=m=>{m.key==="Escape"&&(m.stopImmediatePropagation(),n())};return window.addEventListener("keydown",u,!0),()=>window.removeEventListener("keydown",u,!0)},[n]),t.jsx(ka,{children:t.jsx("div",{className:"fixed inset-0 z-[60] flex items-center justify-center bg-black/50 p-4",role:"presentation",onClick:u=>{u.target===u.currentTarget&&n()},children:t.jsx(mM,{context:d,modal:!0,initialFocus:i,returnFocus:!0,children:t.jsxs("div",{ref:c.setFloating,role:"dialog","aria-modal":"true","aria-labelledby":a,tabIndex:-1,className:`flex max-h-[85vh] max-w-[94vw] flex-col rounded-lg border border-gray-200 bg-white shadow-xl focus:outline-none dark:border-gray-700 dark:bg-gray-900 ${W7[s]}`,children:[t.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-gray-200 px-5 py-3 dark:border-gray-800",children:[t.jsx("h2",{id:a,className:"text-base font-semibold text-gray-900 dark:text-gray-50",children:e}),t.jsx("button",{type:"button",onClick:n,"aria-label":"Close (Esc)",className:"rounded p-0.5 text-gray-500 hover:text-gray-800 focus:outline-none focus-visible:ring-2 focus-visible:ring-sky-500 dark:text-gray-400 dark:hover:text-gray-100",children:t.jsx(Zt,{size:16})})]}),t.jsx("div",{ref:i,tabIndex:0,className:"min-h-0 flex-1 space-y-3 overflow-auto rounded-b-lg px-5 py-4 text-sm leading-relaxed text-gray-700 focus:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-sky-500 dark:text-gray-200",children:r})]})})})})}function xy({title:e,children:n,width:r,className:s}){const[a,i]=f.useState(!1),c=f.useCallback(()=>i(!1),[]),d=s??"text-gray-500 hover:text-gray-800 dark:text-gray-400 dark:hover:text-gray-100";return t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:()=>i(!0),"aria-haspopup":"dialog","aria-expanded":a,"aria-label":`About “${e}”`,className:`inline-flex shrink-0 items-center justify-center rounded-full p-0.5 focus:outline-none focus-visible:ring-2 focus-visible:ring-sky-500 ${d}`,children:t.jsx(oc,{size:13})}),a&&t.jsx(q7,{title:e,width:r,onClose:c,children:n})]})}function yy(e,n){return[dt(e),n]}function U7(e,n){const{periodReports:r}=vt();return Oe({queryKey:["flow-pointers",...yy(e,n)],queryFn:e==null?Ct:()=>he.flowPointers(e,n),enabled:r,staleTime:6e4,refetchInterval:5*6e4,refetchIntervalInBackground:!1})}function H7(e,n){const r=He(),s=yy(e,n);return tt({mutationKey:["flow-pointers-generate",...s],mutationFn:()=>{if(e==null)throw new Error("No workspace selected");return he.flowPointersGenerate(e,n)},onSuccess:a=>{r.setQueryData(["flow-pointers",...s],i=>a.stale===void 0&&(i==null?void 0:i.stale)!==void 0?{...a,stale:i.stale}:a),r.invalidateQueries({queryKey:["ai-usage"]})}})}function z7(e,n){return Or({mutationKey:["flow-pointers-generate",...yy(e,n)]})>0}const VC=[30,60,90];function K7(e){return VC.includes(e??-1)?e:30}const G7=["","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],V7=["","Mon","Tue","Wed","Thu","Fri","Sat","Sun"];function Q7(e){return V7[e]??""}function ph(e){return G7[e]??""}function Zh(e){const n=Math.floor(e/60),r=e%60;return`${String(n).padStart(2,"0")}:${String(r).padStart(2,"0")}`}function QC(e){const n=[...new Set(e)].filter(r=>r>=1&&r<=7).sort((r,s)=>r-s);if(n.length===7)return"every day";if(n.length===0)return"no days";if(n.length===1)return`${ph(n[0])}s`;for(const r of n){let s=!0;for(let a=0;a<n.length;a+=1){const i=(r-1+a)%7+1;if(!n.includes(i)){s=!1;break}}if(s){const a=(r-1+n.length-1)%7+1;return`${ph(r)} to ${ph(a)}`}}return n.map(r=>Q7(r)).join(", ")}function Y7(e){return`Working hours: ${QC(e.days)}, ${Zh(e.startMinute)}–${Zh(e.endMinute)}, ${e.timeZone}.`}function X7(e){return e.toFixed(1).replace(/\.0$/,"")}function Vt(e){return!Number.isFinite(e)||e<=0?"0h":e<1?`${Math.max(1,Math.round(e*60))}m`:e<10?`${X7(e)}h`:`${Math.round(e)}h`}function ln(e){return e.toLocaleString("en-GB")}function hc(e){return`${Math.round(e*100)}%`}const YC={good:"Within budget",ok:"Acceptable",slow:"Slow"},XC={firstLook:"Opened to the first human review or comment",reply:"The slowest reply on each pull request that went back to its author",land:"Approved to merged, for pull requests that were approved",lead:"Opened to merged"};function Z7(e,n){const r=Math.max(n,...e.map(c=>c.ok*1.5)),s=r<=12?2:r<=30?4:r<=60?8:16,a=Math.ceil(r/s)*s,i=[];for(let c=0;c<=a;c+=s)i.push(c);return{max:a,ticks:i}}function ZC(e,n){return e.prs===0?"none":e.p75>n?"bar":e.p90>n?"tail":"none"}function J7(e){const n=[];return e.prs>0&&n.push(["Pull requests",ln(e.prs)],["Median",Vt(e.p50)],["Three in four within",Vt(e.p75)],["Nine in ten within",Vt(e.p90)]),n.push(["Budget",Vt(e.good)],["Acceptable up to",Vt(e.ok)]),{note:e.verdict==null&&e.sentence!==""?e.sentence:null,figures:n}}function eW(e){const n=sc[e.measure],r=`Budget ${Vt(e.good)}, acceptable up to ${Vt(e.ok)}.`;if(e.prs===0)return`${n}: No pull requests. ${r}`;const s=e.verdict==null?"Too few to judge":YC[e.verdict];return`${n}: ${s}. ${ln(e.prs)} pull ${e.prs===1?"request":"requests"}; median ${Vt(e.p50)}, three in four within ${Vt(e.p75)}, nine in ten within ${Vt(e.p90)}. ${r}`}const JC=.1;function tW(e){const n=Math.max(8,...e.map(s=>s.leadWorkHours)),r=[16,40,80,160,400,800,1600].find(s=>s>=n*1.1)??n*1.2;return{min:JC,max:r}}function nW(e){return[.1,.5,1,4,16,40,80,160,400,800,1600].filter(r=>r<=e).map(r=>({hours:r,label:r<1?`${Math.round(r*60)}m`:`${r}h`}))}function G1(e){return e==null||e<=0?3:Math.min(10,3+Math.sqrt(e)/8)}function rW(e,n){return[...e].sort((r,s)=>s.leadWorkHours-r.leadWorkHours||r.prId-s.prId).slice(0,n)}function sW(e){const n=[...e].map(i=>i.leadWorkHours).sort((i,c)=>c-i),r=Math.ceil(n.length/10),s=n.reduce((i,c)=>i+c,0),a=n.slice(0,r).reduce((i,c)=>i+c,0);return{count:r,share:s>0?a/s:0}}const aW=.05;function oW(e){const n=e.reviewer+e.author+e.landing;return n>=aW?{reviewer:e.reviewer/n,author:e.author/n,landing:e.landing/n}:null}function iW(e){return e.filter(n=>n.rounds===0).length}function lW(e){if(e.prFigures!=null)return e.prFigures;if(e.prsCapped||e.prs==null||e.settings==null)return null;const n=(e.settings.endMinute-e.settings.startMinute)/60,r=sW(e.prs);return{overWorkingDay:e.prs.filter(s=>s.leadWorkHours>n).length,slowestTenthCount:r.count,slowestTenthShare:r.share,neverWentBack:iW(e.prs)}}function cW(e){return e.known>=e.measured?null:`Who was asked is known for ${ln(e.known)} of ${ln(e.measured)} pull requests so far.`}function dW(e){const n=e.lookedBeforeAsked;return n<=0?null:`${ln(n)} had a first look before anyone was asked and ${n===1?"is":"are"} left out of the request figures.`}function uW(e){return(e==null?void 0:e.settings)!=null&&Array.isArray(e.budgets)}function hW({children:e}){return t.jsx("h3",{className:"text-sm font-semibold text-gray-900 dark:text-gray-50",children:e})}function pW({settings:e}){const n=e==null?"":`: ${QC(e.days)}, ${Zh(e.startMinute)}–${Zh(e.endMinute)}, ${e.timeZone}`;return t.jsxs(t.Fragment,{children:[t.jsx("p",{children:"Every hour a pull request is open, somebody is holding it: a reviewer who has not looked yet, an author who owes a reply, or nobody, because it is approved and waiting to merge. Chronology adds up those hours."}),t.jsx("p",{children:"It measures pull requests a person wrote and a person reviewed or commented on. Pull requests opened by automation are measured on the Bots rail."}),t.jsxs("p",{children:["The charts count working hours only",n,". Nights, weekends and days off do not count. Change them in Settings → Workspace."]}),t.jsx("p",{children:"“By repository” counts clock hours, nights and weekends included, because the rule that calls a repository out was set on clock hours."}),t.jsx("p",{children:"No person is named on this page."})]})}function mW(){return t.jsxs(t.Fragment,{children:[t.jsx("p",{children:"How all the working hours were split between waiting for a reviewer, waiting for the author, and waiting to merge after approval."}),t.jsx("p",{children:"An even split is not the goal. A pull request approved on its first review never waits for its author, and that is the best case."}),t.jsx("p",{children:"The next chart holds each wait against its budget."})]})}function gW(){return t.jsxs(t.Fragment,{children:[t.jsx("p",{children:"Four waits, in working hours:"}),t.jsx("dl",{className:"space-y-1.5",children:so.map(e=>t.jsxs("div",{children:[t.jsx("dt",{className:"font-medium text-gray-900 dark:text-gray-50",children:sc[e]}),t.jsxs("dd",{children:[XC[e],"."]})]},e))}),t.jsx("p",{children:"Each bar ends where three in four pull requests had finished that wait. The dot is the median, and the thin line runs on to nine in ten. The dashed line is the budget."}),t.jsxs("p",{children:["Within budget: three in four finished inside the budget. Acceptable: inside the acceptable limit. Slow: past it. Too few: fewer than ",Fr.budgetMinPrs," pull requests, so no verdict."]}),t.jsx("p",{children:"An arrow at the right edge means the figure runs past the scale. Point at, focus or tap a bar to see its figures."}),t.jsx("p",{children:"Budgets are set per workspace in Settings."})]})}function fW(){return t.jsxs(t.Fragment,{children:[t.jsx("p",{children:"One dot per merged pull request: the day it merged, and how many working hours it was open, on a log scale."}),t.jsx("p",{children:"Colour shows which wait took most of its working time. Bigger dots changed more lines."}),t.jsx("p",{children:"Point at a dot for its breakdown, and click to open it. The table of the slowest lists the same pull requests for keyboard and screen readers."})]})}function xW(){return t.jsxs(t.Fragment,{children:[t.jsxs("p",{children:["Pull requests are ranked by working-hour lead time and split into quarters. The table compares the slowest quarter with the fastest, and needs ",Fr.contrastMinQuartile," in each."]}),t.jsxs("p",{children:["“Separates” means the slow quarter’s figure is at least ",Fr.separatesRatio," times the fast one’s. “Weakly” means at least ",Fr.weakRatio," times. A very small gap counts as “No”."]}),t.jsx("p",{children:"By size: median working hours from opened to merged, by lines added plus removed."}),t.jsx("p",{children:"By the day it opened: the grey bar is clock time and the dark bar is working hours. The gap between them is time outside working hours."}),t.jsxs("p",{children:["A size band or day with fewer than ",Fr.cutMinPrs," pull requests shows no median."]})]})}function yW({dayHours:e}){return t.jsxs(t.Fragment,{children:[t.jsxs("p",{children:["Pull requests that sat approved for more than one working day (",Vt(e),") before they merged. The ",Fr.landingRows," slowest are listed."]}),t.jsx("p",{children:"“Merged alongside” lists pull requests in other repositories with the same ticket key that merged while this one waited. It may have been held for them."})]})}function bW(){return t.jsxs(t.Fragment,{children:[t.jsx("p",{children:"For each repository: how many people gave first reviews, and how much of it the busiest one did. Nobody is named."}),t.jsx("p",{children:"A high share is a cover risk for when that person is away."}),t.jsxs("p",{children:["“Slower” means the busiest reviewer’s first looks take at least"," ",Math.round((Fr.slowerRatio-1)*100),"% longer than everyone else’s, and at least"," ",Math.round(Fr.slowerMinHours*60)," minutes longer."]}),t.jsxs("p",{children:["Medians are in working hours. “—” means fewer than ",Fr.concentrationMinSide," to go on."]})]})}function vW(){return t.jsxs(t.Fragment,{children:[t.jsx("p",{children:"Who was asked to review first: a named person, a team, or nobody. This comes from each pull request’s history on GitHub. Nobody is named here."}),t.jsx("p",{children:"“Request to first look” starts at that first request. “Opened to first look” starts when the pull request opened, so it compares all three rows."}),t.jsxs("p",{children:["Medians are in working hours. “—” means none, or fewer than ",Fr.cutMinPrs," to go on."]})]})}function kW(){return t.jsxs(t.Fragment,{children:[t.jsx("p",{children:"Written by a model from the pull requests on this page: patterns, examples worth copying, and things to try."}),t.jsx("p",{children:"It names no one and writes no figures; every figure on this page is measured. Each pointer links the pull requests it is based on, and a pointer that cites none is dropped."}),t.jsx("p",{children:"Writing pointers uses AI credits. Nothing is written until you press the button."})]})}function wW(){return t.jsxs(t.Fragment,{children:[t.jsx("p",{children:"Each pull request is placed by how its working time split: waiting for a reviewer (top), for its author (bottom left) and to merge after approval (bottom right). The ringed dot is the workspace as a whole."}),t.jsx("p",{children:"This is context, not a target. A pull request approved on its first review never goes back to its author, so it sits on the right-hand edge. That is the best case, and it is far from the middle."})]})}function jW({sections:e}){return t.jsxs(t.Fragment,{children:[t.jsx("p",{children:"Clock hours: nights and weekends count."}),t.jsxs("p",{children:["A repository needs ",Fr.minRepoPrs," merged pull requests to be measured. It is called out only when one wait holds at least ",hc(Fr.dominantShare)," of its time and its slowest quarter took ",Fr.slowP75ClockHours," clock hours or more. The rest are under “Nothing stands out”."]}),e.filter(n=>n.directive!=="").map(n=>t.jsxs("div",{className:"space-y-1",children:[t.jsx(hW,{children:n.label}),t.jsx("p",{children:n.directive})]},n.court))]})}function NW(){return t.jsxs(t.Fragment,{children:[t.jsx("p",{children:"These merged with no review, comment or approval from a person. That is a branch protection setting, not a habit."}),t.jsx("p",{children:"Only pull requests a person wrote are counted, so automation’s own pull requests do not inflate it."}),t.jsxs("p",{children:["A repository is listed from ",Fr.unreviewedMinCount," such merges and"," ",hc(Fr.unreviewedMinShare)," of its merges."]})]})}const Wo=["reviewer","author","landing"],zf={reviewer:"Waiting for a reviewer",author:"Waiting for the author",landing:"Approved, waiting to land"},Wl={reviewer:"Reviewer",author:"Author",landing:"Landing"};function SW(e){return e==="bottlenecks"?"bottlenecks":"overview"}function V1(e){return e.toFixed(1).replace(/\.0$/,"")}function ql(e){return!Number.isFinite(e)||e<=0?"0h":e<1?`${Math.max(1,Math.round(e*60))}m`:e<10?`${V1(e)}h`:e<48?`${Math.round(e)}h`:`${V1(e/24)}d`}function mh(e){return`${Math.round(e*100)}%`}function CW(e){return`${Math.max(0,Math.min(100,e*100)).toFixed(2)}%`}function RW(e){var a,i;if(e==null)return null;const n=new Map(e.directives.map(c=>[c.court,c])),r=[];for(const c of Wo){const d=e.repos.filter(u=>u.dominant===c);d.length!==0&&r.push({court:c,label:zf[c],summary:((a=n.get(c))==null?void 0:a.summary)??"",directive:((i=n.get(c))==null?void 0:i.directive)??"",repos:d})}const s=e.repos.filter(c=>c.dominant==null);return{windowDays:e.windowDays,measuredPrs:e.measuredPrs,courts:e.courts,sections:r,quiet:s,unreviewed:e.unreviewed,refusals:e.refusals.filter(c=>!(c.kind==="courts"&&c.basis==="measured_clean"&&s.length>0)),coverage:e.coverage,nothingMeasured:e.measuredPrs===0}}function IW(e,n){const r=`${e.reposWithData} of ${e.reposInWorkspace} ${e.reposInWorkspace===1?"repository":"repositories"}`,s=`${e.prsScanned} merged pull ${e.prsScanned===1?"request":"requests"}`;return`Measured ${r} · ${s} · last ${n} days.`}function TW(e){const n=[];return e.excludedBotAuthored>0&&n.push(`${e.excludedBotAuthored} opened by automation`),e.excludedNoHumanTouch>0&&n.push(`${e.excludedNoHumanTouch} no person reviewed or commented on`),n.length===0?null:`Set aside: ${n.join(", and ")}.`}function $W(e){return e.truncated?"A scan reached its cap, so these figures come from part of the window only.":null}function _W({label:e,content:n,children:r,anchorX:s,testId:a}){const[i,c]=f.useState(!1),[d,u]=f.useState(!1),m=i||d,{refs:h,floatingStyles:g,context:x}=wa({open:m,onOpenChange:($,P,C)=>{if(C==="hover"||C==="focus"||C==="focus-out"||C==="safe-polygon"){u($);return}$||(c(!1),u(!1))},strategy:"fixed",placement:"top",middleware:[oo(8),io({fallbackPlacements:["bottom"]}),ri({padding:8})],whileElementsMounted:ni}),y=sM(x,{mouseOnly:!0,delay:{open:60,close:80}}),b=yM(x,{visibleOnly:!0}),w=si(x,{escapeKey:!1}),k=wM(x,{role:"tooltip"}),{getReferenceProps:j,getFloatingProps:N}=lo([y,b,w,k]),I=f.useRef(null),S=QA([I,h.setReference]),T=f.useRef(s);return T.current=s,f.useLayoutEffect(()=>{const $=I.current;$!=null&&h.setPositionReference({getBoundingClientRect(){const P=$.getBoundingClientRect(),C=P.left+(T.current??P.width/2);return{x:C,y:P.top,left:C,right:C,top:P.top,bottom:P.bottom,width:0,height:P.height}},contextElement:$})},[h]),f.useEffect(()=>{if(m)return y2(()=>{c(!1),u(!1)})},[m]),f.useEffect(()=>{if(!m)return;const $=P=>{P.key==="Escape"&&(P.stopImmediatePropagation(),c(!1),u(!1))};return window.addEventListener("keydown",$,!0),()=>window.removeEventListener("keydown",$,!0)},[m]),t.jsxs(t.Fragment,{children:[t.jsx("button",{ref:S,type:"button","data-testid":a,"aria-label":e,"aria-expanded":m,className:"block w-full cursor-pointer rounded text-left focus:outline-none focus-visible:ring-2 focus-visible:ring-sky-500",...j({onClick:()=>{i&&u(!1),c(!i)}}),children:r}),m&&t.jsx(ka,{children:t.jsx("div",{ref:h.setFloating,style:g,...N(),className:"z-[60] w-64 max-w-[92vw] rounded-md border border-gray-200 bg-white px-3 py-2 text-xs leading-snug text-gray-700 shadow-lg dark:border-gray-700 dark:bg-gray-900 dark:text-gray-200",children:n})})]})}const eR={reviewer:"fill-amber-500 dark:fill-amber-600",author:"fill-teal-600 dark:fill-teal-600",landing:"fill-indigo-500 dark:fill-indigo-500"},Jp={reviewer:"bg-amber-500 dark:bg-amber-600",author:"bg-teal-600 dark:bg-teal-600",landing:"bg-indigo-500 dark:bg-indigo-500"},Kf={reviewer:"text-amber-700 dark:text-amber-400",author:"text-teal-700 dark:text-teal-400",landing:"text-indigo-600 dark:text-indigo-400"},Ul="fill-gray-500 dark:fill-gray-400 text-[11px]",PW=new Map;function by(){const e=Ge(n=>n.openPrDetailTab);return n=>e(Kn({prId:n.prId,prNumber:n.prNumber,prTitle:n.prTitle,repoFullName:n.repoFullName},PW),{fromActivity:!0})}function Ti({value:e,label:n}){return t.jsxs("div",{children:[t.jsx("div",{className:"text-lg font-semibold tabular-nums text-gray-900 dark:text-gray-50",children:e}),t.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:n})]})}function gh({courts:e,size:n="lg"}){const r=new Map(e.map(c=>[c.court,c.share])),s=c=>r.get(c)??0,a=n==="bar",i=t.jsx("div",{className:`flex w-full overflow-hidden rounded-sm bg-gray-200 dark:bg-gray-800 ${n==="lg"?"h-2.5":"h-2"}`,...a?{role:"img","aria-label":Wo.map(c=>`${zf[c]} ${mh(s(c))}`).join(", ")}:{"aria-hidden":!0},children:Wo.map(c=>t.jsx("div",{className:Jp[c],style:{width:CW(s(c))}},c))});return a?i:n==="sm"?t.jsxs("div",{children:[i,t.jsx("div",{className:"mt-1 text-xs tabular-nums text-gray-600 dark:text-gray-300",children:Wo.map((c,d)=>t.jsxs(f.Fragment,{children:[d>0&&t.jsx("span",{className:"decorative-mark text-gray-400 dark:text-gray-500",children:" · "}),Wl[c]," ",t.jsx("strong",{className:`font-semibold ${Kf[c]}`,children:mh(s(c))})]},c))})]}):t.jsxs("div",{children:[i,t.jsx("div",{className:"mt-2 flex flex-wrap items-baseline gap-x-6 gap-y-1",children:Wo.map(c=>t.jsxs("span",{className:"inline-flex items-baseline gap-1.5",children:[t.jsx("span",{className:`text-2xl font-semibold tabular-nums ${Kf[c]}`,children:mh(s(c))}),t.jsx("span",{className:"text-xs text-gray-600 dark:text-gray-300",children:zf[c].toLowerCase()})]},c))})]})}function vy({prefix:e=""}){return t.jsx("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1",children:Wo.map(n=>t.jsxs("span",{className:"inline-flex items-center gap-1.5 text-[11px] text-gray-500 dark:text-gray-400",children:[t.jsx("span",{className:`h-2.5 w-2.5 rounded-full ${Jp[n]}`}),e,Wl[n].toLowerCase()]},n))})}const EW={good:"text-emerald-700 dark:text-emerald-400",ok:"text-amber-700 dark:text-amber-400",slow:"text-rose-700 dark:text-rose-400"},Q1="inline-flex items-center gap-1 text-xs font-medium text-gray-600 dark:text-gray-300";function AW({row:e}){const n=e.verdict;if(n==null)return e.prs>0?t.jsxs("span",{className:Q1,children:[t.jsx(ic,{size:11}),"Too few"]}):t.jsxs("span",{className:Q1,children:[t.jsx(kp,{size:11}),"None"]});const r=n==="good"?Vo:n==="ok"?$i:Jt;return t.jsxs("span",{"data-testid":`verdict-${e.measure}`,className:`inline-flex items-center gap-1 text-xs font-medium ${EW[n]}`,children:[t.jsx(r,{size:12}),YC[n]]})}function MW({row:e}){const{note:n,figures:r}=J7(e);return t.jsxs("div",{children:[t.jsx("div",{className:"font-semibold text-gray-900 dark:text-gray-50",children:sc[e.measure]}),t.jsx("div",{className:"text-gray-600 dark:text-gray-300",children:XC[e.measure]}),n!=null&&t.jsx("p",{className:"mt-1.5",children:n}),t.jsx("dl",{className:"mt-1.5 grid grid-cols-[1fr_auto] gap-x-4 gap-y-0.5",children:r.map(([s,a])=>t.jsxs(f.Fragment,{children:[t.jsx("dt",{className:"text-gray-600 dark:text-gray-300",children:s}),t.jsx("dd",{className:"text-right font-medium tabular-nums text-gray-900 dark:text-gray-50",children:a})]},s))})]})}function LW({row:e,max:n,ticks:r}){const[s,a]=Xs(),i=46,c=6,d=Math.max(c+1,a-16),u=h=>c+Math.min(Math.max(h,0),n)/n*(d-c),m=ZC(e,n);return t.jsx(_W,{label:eW(e),content:t.jsx(MW,{row:e}),anchorX:u(Math.min(e.prs>0?e.p75:e.good,n)),testId:`budget-trigger-${e.measure}`,children:t.jsx("div",{ref:s,className:"h-[46px] w-full",children:a>0&&t.jsxs("svg",{width:a,height:i,"aria-hidden":"true",className:"block",children:[t.jsx("rect",{x:u(0),y:4,width:u(e.good)-u(0),height:22,className:"fill-emerald-500/15 dark:fill-emerald-400/15"}),t.jsx("rect",{x:u(e.good),y:4,width:Math.max(0,u(e.ok)-u(e.good)),height:22,className:"fill-amber-400/20 dark:fill-amber-400/15"}),t.jsx("rect",{x:u(e.ok),y:4,width:Math.max(0,u(n)-u(e.ok)),height:22,className:"fill-rose-500/10 dark:fill-rose-400/10"}),e.prs>0&&t.jsxs(t.Fragment,{children:[t.jsx("line",{x1:u(e.p75),x2:u(e.p90),y1:15,y2:15,className:"stroke-gray-500 dark:stroke-gray-400",strokeWidth:1.5}),m==="tail"&&t.jsx("path",{"data-clipped":"tail",d:`M ${u(n)-6} 11 L ${u(n)} 15 L ${u(n)-6} 19`,fill:"none",className:"stroke-gray-500 dark:stroke-gray-400",strokeWidth:1.5}),t.jsx("rect",{x:u(0),y:10,width:Math.max(2,u(e.p75)-u(0)),height:10,rx:2,className:"fill-gray-800 dark:fill-gray-100"}),t.jsx("circle",{cx:u(e.p50),cy:15,r:5,className:"fill-white stroke-gray-800 dark:fill-gray-950 dark:stroke-gray-100",strokeWidth:2}),m==="bar"&&t.jsx("path",{"data-clipped":"bar",d:`M ${d+6} 9 L ${d+14} 15 L ${d+6} 21 Z`,className:"fill-gray-800 dark:fill-gray-100"})]}),t.jsx("line",{x1:u(e.good),x2:u(e.good),y1:0,y2:30,className:"stroke-gray-800 dark:stroke-gray-100",strokeWidth:1.5,strokeDasharray:"4 3"}),r.map((h,g)=>t.jsx("text",{x:u(h),y:43,textAnchor:g===0?"start":g===r.length-1?"end":"middle",className:Ul,children:g===r.length-1?`${h}h+`:`${h}h`},h))]})})})}function FW({rows:e,dayHours:n}){const{max:r,ticks:s}=Z7(e,n),a=e.some(i=>ZC(i,r)==="bar");return t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1 text-[11px] text-gray-500 dark:text-gray-400",children:[t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx("span",{className:"h-2.5 w-4 rounded-sm bg-emerald-500/25 dark:bg-emerald-400/25"}),"within budget"]}),t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx("span",{className:"h-2.5 w-4 rounded-sm bg-amber-400/30 dark:bg-amber-400/25"}),"acceptable"]}),t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx("span",{className:"h-2.5 w-4 rounded-sm bg-rose-500/15 dark:bg-rose-400/20"}),"slow"]}),t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx("span",{className:"h-0 w-4 border-t-[1.5px] border-dashed border-gray-800 dark:border-gray-100"}),"budget"]}),t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx("span",{className:"h-2 w-4 rounded-sm bg-gray-800 dark:bg-gray-100"}),"three in four"]}),t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx("span",{className:"h-0 w-4 border-t-[1.5px] border-gray-500 dark:border-gray-400"}),"to nine in ten"]}),t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx("span",{className:"h-2.5 w-2.5 rounded-full border-2 border-gray-800 dark:border-gray-100"}),"median"]}),a&&t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx("svg",{width:10,height:10,viewBox:"0 0 10 10","aria-hidden":"true",className:"shrink-0",children:t.jsx("path",{d:"M 1 0 L 9 5 L 1 10 Z",className:"fill-gray-800 dark:fill-gray-100"})}),"runs past the scale"]})]}),e.map(i=>t.jsxs("div",{"data-testid":`budget-${i.measure}`,children:[t.jsxs("div",{className:"flex items-baseline justify-between gap-3",children:[t.jsx("span",{className:"text-sm font-medium text-gray-800 dark:text-gray-100",children:sc[i.measure]}),t.jsx(AW,{row:i})]}),t.jsx("div",{className:"mt-1",children:t.jsx(LW,{row:i,max:r,ticks:s})})]},i.measure))]})}function tR(e,n,r,s=14){let a=null,i=s*s;for(const c of e){const d=(c.x-n)**2+(c.y-r)**2;d<i&&(i=d,a=c)}return a}function nR({p:e,width:n}){const r=e.pr,s=r.workHours.reviewer+r.workHours.author+r.workHours.landing,a=Math.max(8,Math.min(e.x+14,n-268));return t.jsxs("div",{className:"pointer-events-none absolute z-20 w-64 rounded-md border border-gray-200 bg-white px-2.5 py-2 text-[11px] leading-snug text-gray-700 shadow-lg dark:border-gray-700 dark:bg-gray-900 dark:text-gray-200",style:{left:a,top:Math.max(0,e.y-20)},children:[t.jsx("div",{className:"font-medium text-gray-900 dark:text-gray-50",children:r.prTitle}),t.jsxs("div",{className:"text-gray-500 dark:text-gray-400",children:[r.repoFullName," #",r.prNumber]}),t.jsx("div",{className:"mt-1.5 flex h-1.5 w-full overflow-hidden rounded-sm bg-gray-200 dark:bg-gray-800",children:s>0&&Wo.map(i=>t.jsx("div",{className:Jp[i],style:{width:`${r.workHours[i]/s*100}%`}},i))}),t.jsxs("div",{className:"mt-1 grid grid-cols-2 gap-x-3 tabular-nums",children:[t.jsxs("span",{children:[t.jsx("span",{className:"font-semibold",children:Vt(r.leadWorkHours)})," working"]}),t.jsxs("span",{className:"text-gray-500 dark:text-gray-400",children:[Vt(r.leadHours)," on the clock"]}),Wo.map(i=>t.jsxs("span",{children:[Wl[i]," ",Vt(r.workHours[i])]},i)),t.jsxs("span",{children:["First look ",r.firstLookWorkHours==null?"—":Vt(r.firstLookWorkHours)]}),t.jsxs("span",{children:[r.rounds," ",r.rounds===1?"round":"rounds"," back"]}),t.jsx("span",{children:r.lines==null?"Size unknown":`${ln(r.lines)} lines`}),r.ciRedHours>0&&t.jsxs("span",{children:["Checks red ",Vt(r.ciRedHours)," (clock)"]})]}),r.reachAreas.length>0&&t.jsxs("div",{className:"mt-1 text-gray-500 dark:text-gray-400",children:["Touches ",r.reachAreas.join(", ").replace(/_/g," ")]}),t.jsx("div",{className:"mt-1 text-gray-500 dark:text-gray-400",children:"Click to open"})]})}function OW(e,n){const r=n-e,s=864e5,a=r<=35*s?7:r<=70*s?14:21,i=[],c=new Date(e);c.setUTCHours(0,0,0,0);const d=(c.getUTCDay()+6)%7;let u=c.getTime()+(7-d)*s;for(u-7*s>=e&&(u-=7*s);u<=n;u+=a*s)i.push(u);return i}function DW({prs:e,budgetHours:n,p75Hours:r}){const[s,a]=Xs(),[i,c]=f.useState(null),d=by(),u=300,m=44,h=12,g=12,x=28,y=f.useMemo(()=>{if(a<=0||e.length===0)return null;const w=e.map(L=>Date.parse(L.mergedAt)),k=Math.min(...w),j=Math.max(...w),{min:N,max:I}=tW(e),S=Math.log10(N),T=Math.log10(I),$=L=>j>k?m+(L-k)/(j-k)*(a-m-h):(m+a-h)/2,P=L=>g+(1-(Math.log10(Math.max(JC,L))-S)/(T-S))*(u-g-x),C=[...e].sort((L,F)=>(F.lines??0)-(L.lines??0)).map(L=>({pr:L,x:$(Date.parse(L.mergedAt)),y:P(L.leadWorkHours)}));return{X:$,Y:P,placed:C,yTicks:nW(I),xTicks:OW(k,j)}},[e,a]),b=(y==null?void 0:y.placed)??[];return t.jsxs("div",{children:[t.jsxs("div",{className:"mb-1.5 flex flex-wrap items-center gap-x-4 gap-y-1",children:[t.jsx(vy,{prefix:"mostly "}),t.jsxs("span",{className:"inline-flex items-center gap-1.5 text-[11px] text-gray-500 dark:text-gray-400",children:[t.jsx("span",{className:"h-0 w-4 border-t-[1.5px] border-dashed border-gray-800 dark:border-gray-100"}),"whole-PR budget"]}),t.jsxs("span",{className:"inline-flex items-center gap-1.5 text-[11px] text-gray-500 dark:text-gray-400",children:[t.jsx("span",{className:"h-0 w-4 border-t border-dotted border-gray-500 dark:border-gray-400"}),"three in four"]}),t.jsx("span",{className:"text-[11px] text-gray-500 dark:text-gray-400",children:"size = lines changed"})]}),t.jsxs("div",{ref:s,className:"relative",style:{height:u},children:[y!=null&&t.jsxs("svg",{width:a,height:u,className:"block",role:"img","aria-label":`Every merged pull request by the day it merged and its working-hour lead time, on a log scale. ${e.length} pull requests; the table below lists the slowest.`,children:[y.yTicks.map(w=>t.jsxs("g",{children:[t.jsx("line",{x1:m,x2:a-h,y1:y.Y(w.hours),y2:y.Y(w.hours),className:"decorative-mark stroke-gray-200 dark:stroke-gray-800",strokeWidth:1}),t.jsx("text",{x:m-6,y:y.Y(w.hours)+4,textAnchor:"end",className:Ul,children:w.label})]},w.hours)),y.xTicks.map(w=>t.jsx("text",{x:y.X(w),y:u-8,textAnchor:"middle",className:Ul,children:new Date(w).toLocaleDateString("en-GB",{day:"numeric",month:"short",timeZone:"UTC"})},w)),t.jsx("line",{x1:m,x2:a-h,y1:y.Y(r),y2:y.Y(r),className:"stroke-gray-500 dark:stroke-gray-400",strokeWidth:1,strokeDasharray:"2 3"}),t.jsx("line",{x1:m,x2:a-h,y1:y.Y(n),y2:y.Y(n),className:"stroke-gray-800 dark:stroke-gray-100",strokeWidth:1.5,strokeDasharray:"4 3"}),b.map(w=>t.jsx("circle",{cx:w.x,cy:w.y,r:G1(w.pr.lines),className:`${eR[w.pr.dominant]} stroke-white dark:stroke-gray-950`,strokeWidth:1.5,fillOpacity:i==null||i.pr.prId===w.pr.prId?.85:.35},w.pr.prId)),i!=null&&t.jsx("circle",{cx:i.x,cy:i.y,r:G1(i.pr.lines)+2.5,fill:"none",className:"stroke-gray-900 dark:stroke-gray-50",strokeWidth:1.5}),t.jsx("rect",{x:0,y:0,width:a,height:u,fill:"transparent",style:{cursor:i?"pointer":"default"},onMouseMove:w=>c(tR(b,w.nativeEvent.offsetX,w.nativeEvent.offsetY)),onMouseLeave:()=>c(null),onClick:()=>{i&&d(i.pr)}})]}),i!=null&&a>0&&t.jsx(nR,{p:i,width:a})]}),t.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Lead time in working hours, log scale · by the day it merged"})]})}function BW({prs:e,overall:n}){const[r,s]=Xs(),[a,i]=f.useState(null),c=by(),d=300,u=Math.min(s-40,(d-60)/.866),m=s/2,h={x:m,y:24},g={x:m-u/2,y:24+u*.866},x={x:m+u/2,y:24+u*.866},y=(I,S,T)=>{const $=I+S+T||1;return{x:(I*h.x+S*g.x+T*x.x)/$,y:(I*h.y+S*g.y+T*x.y)/$}},b=f.useMemo(()=>{if(s<=0)return[];const I=[];for(const S of e){const T=oW(S.workHours);if(T==null)continue;const $=S.prId*37%11-5,P=S.prId*53%9-4,C=y(T.reviewer,T.author,T.landing);I.push({pr:S,x:C.x+$*.8,y:C.y+P*.8})}return I},[e,s]),w=new Map(n.map(I=>[I.court,I.share])),k=y(w.get("reviewer")??0,w.get("author")??0,w.get("landing")??0),j=y(1,1,1),N=[.25,.5,.75];return t.jsxs("div",{children:[t.jsxs("div",{className:"mb-1.5 flex flex-wrap items-center gap-x-4 gap-y-1",children:[t.jsx(vy,{prefix:"mostly "}),t.jsxs("span",{className:"inline-flex items-center gap-1.5 text-[11px] text-gray-500 dark:text-gray-400",children:[t.jsx("span",{className:"h-3 w-3 rounded-full border-2 border-gray-800 bg-white dark:border-gray-100 dark:bg-gray-950"}),"the workspace as a whole"]}),t.jsxs("span",{className:"inline-flex items-center gap-1.5 text-[11px] text-gray-500 dark:text-gray-400",children:[t.jsx("span",{className:"h-3 w-3 rounded-full border-[1.5px] border-dashed border-gray-500 dark:border-gray-400"}),"equal thirds"]})]}),t.jsxs("div",{ref:r,className:"relative",style:{height:d},children:[s>0&&u>40&&t.jsxs("svg",{width:s,height:d,className:"block",role:"img","aria-label":"Each pull request placed by its share of working time waiting for a reviewer (top), for its author (bottom left) and to land (bottom right).",children:[N.map(I=>[[y(I,1-I,0),y(I,0,1-I)],[y(0,I,1-I),y(1-I,I,0)],[y(0,1-I,I),y(1-I,0,I)]].map(([T,$],P)=>t.jsx("line",{x1:T.x,y1:T.y,x2:$.x,y2:$.y,className:"decorative-mark stroke-gray-200 dark:stroke-gray-800",strokeWidth:1},`${I}-${P}`))),t.jsx("path",{d:`M${h.x},${h.y} L${g.x},${g.y} L${x.x},${x.y} Z`,fill:"none",className:"stroke-gray-300 dark:stroke-gray-700",strokeWidth:1.2}),t.jsx("text",{x:h.x,y:h.y-10,textAnchor:"middle",className:Ul,children:"All waiting for a reviewer"}),t.jsx("text",{x:g.x,y:g.y+18,textAnchor:"start",className:Ul,children:"All with the author"}),t.jsx("text",{x:x.x,y:x.y+18,textAnchor:"end",className:Ul,children:"All waiting to land"}),b.map(I=>t.jsx("circle",{cx:I.x,cy:I.y,r:3.5,className:`${eR[I.pr.dominant]} stroke-white dark:stroke-gray-950`,strokeWidth:1,fillOpacity:a==null||a.pr.prId===I.pr.prId?.8:.3},I.pr.prId)),t.jsx("circle",{cx:j.x,cy:j.y,r:12,fill:"none",className:"stroke-gray-500 dark:stroke-gray-400",strokeWidth:1.5,strokeDasharray:"3 3"}),t.jsx("circle",{cx:k.x,cy:k.y,r:7,className:"fill-white stroke-gray-800 dark:fill-gray-950 dark:stroke-gray-100",strokeWidth:2.2}),t.jsx("rect",{x:0,y:0,width:s,height:d,fill:"transparent",style:{cursor:a?"pointer":"default"},onMouseMove:I=>i(tR(b,I.nativeEvent.offsetX,I.nativeEvent.offsetY,10)),onMouseLeave:()=>i(null),onClick:()=>{a&&c(a.pr)}})]}),a!=null&&s>0&&t.jsx(nR,{p:a,width:s})]})]})}const Vn="px-2 py-1.5 text-left text-[11px] font-medium text-gray-500 dark:text-gray-400",Jh="mt-1 text-xs text-gray-500 dark:text-gray-400",Qn="px-2 py-1.5 text-xs text-gray-700 dark:text-gray-200",Yt="text-right tabular-nums";function ep({pr:e}){const n=by(),r=mn(e.githubUrl);return t.jsxs("span",{className:"inline-flex min-w-0 items-baseline gap-1",children:[t.jsxs("button",{type:"button",onClick:()=>n(e),title:e.prTitle,className:"inline-flex min-w-0 items-baseline gap-1 text-left font-medium text-sky-700 hover:underline dark:text-sky-400",children:[t.jsx(Nd,{size:11,className:"shrink-0 self-center"}),t.jsxs("span",{className:"shrink-0 whitespace-nowrap",children:[e.repoFullName.split("/").pop()," #",e.prNumber]}),t.jsx("span",{className:"truncate font-normal text-gray-600 dark:text-gray-300",children:e.prTitle})]}),r!=null&&t.jsx("a",{href:r,target:"_blank",rel:"noopener noreferrer",title:"Open on GitHub","aria-label":`Open ${e.repoFullName} #${e.prNumber} on GitHub`,className:"shrink-0 self-center text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200",children:t.jsx(_t,{size:11})})]})}function Y1(e,n){return e.unit==="percent"?hc(n):e.unit==="workHours"?Vt(n):ln(Math.round(n))}const WW={separates:"Separates",weak:"Weakly",none:"No"};function qW({contrast:e}){return t.jsxs("div",{children:[t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"w-full min-w-[420px] border-collapse",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"border-b border-gray-200 dark:border-gray-800",children:[t.jsx("th",{className:Vn,children:"Median, or share of pull requests"}),t.jsx("th",{className:`${Vn} ${Yt}`,children:"Fastest quarter"}),t.jsx("th",{className:`${Vn} ${Yt}`,children:"Slowest quarter"}),t.jsx("th",{className:`${Vn} ${Yt}`,children:"Sets them apart?"})]})}),t.jsx("tbody",{children:e.rows.map(n=>t.jsxs("tr",{className:"border-b border-gray-100 last:border-b-0 dark:border-gray-800/70",children:[t.jsx("td",{className:Qn,children:n.label}),t.jsx("td",{className:`${Qn} ${Yt}`,children:Y1(n,n.fast)}),t.jsx("td",{className:`${Qn} ${Yt} font-semibold`,children:Y1(n,n.slow)}),t.jsx("td",{className:`${Qn} ${Yt} ${n.verdict==="separates"?"font-medium text-gray-900 dark:text-gray-50":"text-gray-500 dark:text-gray-400"}`,children:WW[n.verdict]})]},n.signal))})]})}),t.jsxs("p",{className:Jh,children:[ln(e.quartilePrs)," pull requests in each quarter."]})]})}function Gf({value:e,max:n,className:r}){const s=e==null||n<=0?0:Math.max(1.5,Math.min(100,e/n*100));return t.jsx("div",{className:"h-2.5 w-full rounded-sm bg-gray-100 dark:bg-gray-800",children:t.jsx("div",{className:`h-full rounded-sm ${r}`,style:{width:`${s}%`}})})}function UW({bands:e}){const n=Math.max(1,...e.map(r=>r.medianLeadWorkHours??0));return t.jsx("div",{className:"space-y-2",children:e.map(r=>t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-baseline justify-between gap-2 text-xs",children:[t.jsx("span",{className:"text-gray-700 dark:text-gray-200",children:r.label}),t.jsx("span",{className:"tabular-nums text-gray-500 dark:text-gray-400",children:r.medianLeadWorkHours==null?r.prs===0?"none":`${r.prs} — too few for a median`:t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"font-semibold text-gray-800 dark:text-gray-100",children:Vt(r.medianLeadWorkHours)})," ","· first look ",Vt(r.medianFirstLookWorkHours??0)," ·"," ",ln(r.prs)," PRs"]})})]}),t.jsx(Gf,{value:r.medianLeadWorkHours,max:n,className:"bg-gray-700 dark:bg-gray-300"})]},r.label))})}function HW({days:e}){const n=e.filter(s=>s.working||s.prs>0),r=Math.max(1,...n.map(s=>Math.max(s.medianLeadHours??0,s.medianLeadWorkHours??0)));return t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex flex-wrap gap-x-4 text-[11px] text-gray-500 dark:text-gray-400",children:[t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx("span",{className:"h-2.5 w-4 rounded-sm bg-gray-400 dark:bg-gray-500"}),"on the clock"]}),t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx("span",{className:"h-2.5 w-4 rounded-sm bg-gray-800 dark:bg-gray-100"}),"working hours"]})]}),n.map(s=>t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-baseline justify-between gap-2 text-xs",children:[t.jsxs("span",{className:"text-gray-700 dark:text-gray-200",children:[ph(s.weekday),!s.working&&t.jsx("span",{className:"text-gray-500 dark:text-gray-400",children:" (not a working day)"})]}),t.jsx("span",{className:"tabular-nums text-gray-500 dark:text-gray-400",children:s.medianLeadWorkHours==null?s.prs===0?"none":`${s.prs} — too few for a median`:t.jsxs(t.Fragment,{children:[Vt(s.medianLeadHours??0)," ·"," ",t.jsx("span",{className:"font-semibold text-gray-800 dark:text-gray-100",children:Vt(s.medianLeadWorkHours)})," ","· ",ln(s.prs)," PRs"]})})]}),t.jsxs("div",{className:"space-y-0.5",children:[t.jsx(Gf,{value:s.medianLeadHours,max:r,className:"bg-gray-400 dark:bg-gray-500"}),t.jsx(Gf,{value:s.medianLeadWorkHours,max:r,className:"bg-gray-800 dark:bg-gray-100"})]})]},s.weekday))]})}function zW({tail:e}){if(e.prsOver===0)return t.jsx("p",{className:"text-xs text-gray-700 dark:text-gray-300",children:e.sentence});const n=e.siblingsOver??0;return t.jsxs("div",{children:[t.jsxs("div",{className:"flex flex-wrap gap-x-8 gap-y-2",children:[t.jsx(Ti,{value:ln(e.prsOver),label:"sat approved over a working day"}),t.jsx(Ti,{value:hc(e.shareOfLanding),label:"of all time spent approved"}),e.selfMergedOver>0&&t.jsx(Ti,{value:ln(e.selfMergedOver),label:"merged by their own author"}),n>0&&t.jsx(Ti,{value:ln(n),label:"merged alongside a pull request in another repository"})]}),e.rows.length>0&&t.jsx("ul",{className:"mt-3 divide-y divide-gray-100 dark:divide-gray-800/70",children:e.rows.map(r=>t.jsxs("li",{className:"py-1.5 text-xs",children:[t.jsxs("div",{className:"flex items-baseline gap-2",children:[t.jsx(ep,{pr:r}),t.jsxs("span",{className:"ml-auto shrink-0 whitespace-nowrap text-xs tabular-nums text-gray-500 dark:text-gray-400",children:[t.jsx("span",{className:"font-semibold text-gray-800 dark:text-gray-100",children:Vt(r.landWorkHours)})," ","working · ",Vt(r.landHours)," on the clock"]})]}),(r.selfMerged||r.ticketKey!=null)&&t.jsxs("div",{className:"mt-0.5 flex flex-wrap items-center gap-x-3 gap-y-0.5 pl-4 text-[11px] text-gray-500 dark:text-gray-400",children:[r.selfMerged&&t.jsx("span",{children:"Merged by its author"}),r.ticketKey!=null&&t.jsx("span",{className:"font-mono",children:r.ticketKey}),r.siblings.length>0&&t.jsxs("span",{className:"inline-flex flex-wrap items-baseline gap-x-2",children:[t.jsx("span",{children:"merged alongside:"}),r.siblings.map(s=>t.jsx(ep,{pr:{...s,prTitle:""}},s.prId))]})]})]},r.prId))}),e.prsOver>e.rows.length&&t.jsxs("p",{className:Jh,children:["Showing the ",ln(e.rows.length)," slowest of ",ln(e.prsOver),"."]})]})}function KW({rows:e}){return t.jsx("div",{children:t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"w-full min-w-[520px] border-collapse",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"border-b border-gray-200 dark:border-gray-800",children:[t.jsx("th",{className:Vn,children:"Repository"}),t.jsx("th",{className:`${Vn} ${Yt}`,children:"People giving first reviews"}),t.jsx("th",{className:`${Vn} ${Yt}`,children:"Busiest one’s share"}),t.jsx("th",{className:`${Vn} ${Yt}`,children:"Their first look"}),t.jsx("th",{className:`${Vn} ${Yt}`,children:"Everyone else’s"})]})}),t.jsx("tbody",{children:e.map(n=>t.jsxs("tr",{className:"border-b border-gray-100 last:border-b-0 dark:border-gray-800/70",children:[t.jsx("td",{className:`${Qn} font-mono`,children:n.repoFullName}),t.jsx("td",{className:`${Qn} ${Yt}`,children:n.firstReviewers}),t.jsxs("td",{className:`${Qn} ${Yt} font-semibold`,children:[hc(n.topShare),t.jsxs("span",{className:"font-normal text-gray-500 dark:text-gray-400",children:[" of ",n.prs]})]}),t.jsx("td",{className:`${Qn} ${Yt}`,children:t.jsxs("span",{className:"inline-flex items-center justify-end gap-1",children:[n.slower&&t.jsx(Jt,{size:11,className:"text-amber-700 dark:text-amber-400"}),n.topFirstLookWorkHours==null?"—":Vt(n.topFirstLookWorkHours),n.slower&&t.jsx("span",{className:"text-amber-700 dark:text-amber-400",children:"slower"})]})}),t.jsx("td",{className:`${Qn} ${Yt}`,children:n.othersFirstLookWorkHours==null?"—":Vt(n.othersFirstLookWorkHours)})]},n.repoId))})]})})})}function GW({prs:e}){return t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"w-full min-w-[560px] border-collapse",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"border-b border-gray-200 dark:border-gray-800",children:[t.jsx("th",{className:Vn,children:"Pull request"}),t.jsx("th",{className:`${Vn} ${Yt}`,children:"Working"}),t.jsx("th",{className:`${Vn} ${Yt}`,children:Wl.reviewer}),t.jsx("th",{className:`${Vn} ${Yt}`,children:Wl.author}),t.jsx("th",{className:`${Vn} ${Yt}`,children:Wl.landing}),t.jsx("th",{className:`${Vn} ${Yt}`,children:"Lines"})]})}),t.jsx("tbody",{children:e.map(n=>t.jsxs("tr",{className:"border-b border-gray-100 last:border-b-0 dark:border-gray-800/70",children:[t.jsx("td",{className:`${Qn} max-w-[18rem]`,children:t.jsx(ep,{pr:n})}),t.jsx("td",{className:`${Qn} ${Yt} font-semibold`,children:Vt(n.leadWorkHours)}),t.jsx("td",{className:`${Qn} ${Yt}`,children:Vt(n.workHours.reviewer)}),t.jsx("td",{className:`${Qn} ${Yt}`,children:Vt(n.workHours.author)}),t.jsx("td",{className:`${Qn} ${Yt}`,children:Vt(n.workHours.landing)}),t.jsx("td",{className:`${Qn} ${Yt}`,children:n.lines==null?"—":ln(n.lines)})]},n.prId))})]})})}const VW={person:"A named person",team:"A team",none:"Nobody"};function QW({stats:e}){const n=cW(e),r=dW(e);return t.jsxs("div",{children:[t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"w-full min-w-[440px] border-collapse",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"border-b border-gray-200 dark:border-gray-800",children:[t.jsx("th",{className:Vn,children:"Asked first"}),t.jsx("th",{className:`${Vn} ${Yt}`,children:"Pull requests"}),t.jsx("th",{className:`${Vn} ${Yt}`,children:"Request to first look"}),t.jsx("th",{className:`${Vn} ${Yt}`,children:"Opened to first look"})]})}),t.jsx("tbody",{children:e.rows.map(s=>t.jsxs("tr",{className:"border-b border-gray-100 last:border-b-0 dark:border-gray-800/70",children:[t.jsx("td",{className:Qn,children:VW[s.kind]}),t.jsx("td",{className:`${Qn} ${Yt}`,children:ln(s.prs)}),t.jsx("td",{className:`${Qn} ${Yt} font-semibold`,children:s.kind==="none"||s.medianRequestToLookWorkHours==null?"—":Vt(s.medianRequestToLookWorkHours)}),t.jsx("td",{className:`${Qn} ${Yt}`,children:s.medianFirstLookWorkHours==null?"—":Vt(s.medianFirstLookWorkHours)})]},s.kind))})]})}),n!=null&&t.jsx("p",{className:Jh,children:n}),r!=null&&t.jsx("p",{className:Jh,children:r})]})}const YW={pattern:"Pattern",example:"Worth copying",try:"Try"};function XW(e){const n=new Date(e);return Number.isNaN(n.getTime())?"":n.toLocaleString("en-GB",{day:"numeric",month:"short",hour:"2-digit",minute:"2-digit"})}function ZW({workspaceId:e,days:n}){var m;const r=U7(e,n),s=H7(e,n),a=z7(e,n),i=r.data;if(i==null||!i.enabled)return null;const c=new Map(i.links.map(h=>[h.prId,h])),d=i.result,u=s.data;return t.jsxs("section",{"data-testid":"chronology-pointers",className:"rounded-lg border border-ai-border bg-ai-surface p-4",children:[t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Ps,{size:14,className:"text-ai-signal"}),t.jsxs("span",{className:"flex items-center gap-1",children:[t.jsx("h4",{className:"text-sm font-semibold text-ai-ink",children:"Pointers"}),t.jsx(xy,{title:"Pointers",className:"text-ai-ink",children:t.jsx(kW,{})})]}),d!=null&&i.stale&&t.jsx("span",{className:"rounded border border-ai-hairline px-1.5 text-[11px] text-ai-ink",children:"Out of date"})]}),!i.empty&&t.jsx("button",{type:"button",disabled:a,onClick:()=>s.mutate(),className:"rounded border border-ai-border px-2.5 py-1 text-xs font-medium text-ai-ink hover:bg-ai-surface-2 disabled:opacity-50",children:a?"Writing…":d==null?"Write pointers":"Rewrite"})]}),t.jsx("p",{className:"mt-0.5 text-xs text-ai-ink",children:"Written by AI from the pull requests on this page."}),i.empty?t.jsx("p",{className:"mt-3 text-xs text-ai-ink",children:"Nothing merged in this window to write about."}):d==null?t.jsx("p",{className:"mt-3 text-xs text-ai-ink",children:r.isLoading?"Loading…":"No pointers for this window yet. Writing them uses AI credits."}):t.jsx("ul",{className:"mt-3 space-y-3",children:d.pointers.map((h,g)=>t.jsxs("li",{className:"border-l-2 border-ai-signal/50 pl-3",children:[t.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wide text-ai-signal",children:YW[h.kind]??h.kind}),t.jsx("p",{className:"text-sm leading-relaxed text-ai-ink",children:h.text}),t.jsx("div",{className:"mt-1 flex flex-col gap-0.5 text-xs",children:h.cites.map(x=>{const y=c.get(x);return y?t.jsx(ep,{pr:y},x):null})})]},g))}),d!=null&&t.jsxs("p",{className:"mt-3 text-xs text-ai-ink",children:["Written ",XW(d.generatedAt)," over ",d.prCount," pull requests.",d.droppedPointers>0&&` ${d.droppedPointers} ${d.droppedPointers===1?"pointer was":"pointers were"} dropped for citing nothing real or breaking a rule.`,d.droppedIds>0&&` ${d.droppedIds} ${d.droppedIds===1?"citation":"citations"} to pull requests outside the evidence ${d.droppedIds===1?"was":"were"} removed.`]}),(u==null?void 0:u.throttled)&&t.jsx("p",{className:"mt-1 text-xs text-ai-ink",children:"Written moments ago — try again in a minute."}),(u==null?void 0:u.creditsExhausted)&&t.jsx("p",{className:"mt-1 text-xs text-ai-ink",children:"Out of AI credits for this month."}),s.isError&&t.jsx("p",{className:"mt-1 text-xs text-rose-700 dark:text-rose-400",children:((m=s.error)==null?void 0:m.message)??"Could not write pointers."})]})}const JW=new Map,ed="text-xs text-gray-500 dark:text-gray-400";function rR({pr:e,court:n}){const r=Ge(i=>i.openPrDetailTab),s=mn(e.githubUrl),a=Kn({prId:e.prId,prNumber:e.prNumber,prTitle:e.prTitle,repoFullName:e.repoFullName},JW);return t.jsxs("li",{className:"flex items-baseline gap-2 py-1 text-xs",children:[t.jsxs("button",{type:"button",onClick:()=>r(a,{fromActivity:!0}),title:e.prTitle,className:"inline-flex min-w-0 items-center gap-1 font-medium text-sky-600 hover:underline dark:text-sky-400",children:[t.jsx(Nd,{size:11,className:"shrink-0"}),t.jsxs("span",{className:"shrink-0",children:["#",e.prNumber]}),t.jsx("span",{className:"truncate text-gray-600 dark:text-gray-300",children:e.prTitle})]}),e.authorIsBot&&t.jsxs("span",{className:"inline-flex shrink-0 items-center gap-0.5 rounded bg-gray-100 px-1 text-[11px] text-gray-600 dark:bg-gray-800 dark:text-gray-300",title:"Opened by automation",children:[t.jsx(Lt,{size:10}),"bot"]}),t.jsx("span",{className:"ml-auto shrink-0 whitespace-nowrap tabular-nums text-gray-500 dark:text-gray-400",children:n!=null?t.jsxs(t.Fragment,{children:[t.jsx("span",{className:`font-semibold ${Kf[n]}`,children:ql(e.hoursInCourt)})," of ",ql(e.leadHours)]}):t.jsxs(t.Fragment,{children:["merged in ",ql(e.leadHours)]})}),s!=null&&t.jsx("a",{href:s,target:"_blank",rel:"noopener noreferrer",title:"Open on GitHub","aria-label":`Open ${e.repoFullName} #${e.prNumber} on GitHub`,className:"shrink-0 text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200",children:t.jsx(_t,{size:10})})]})}function eq({repo:e}){const n=e.dominant;return t.jsxs("li",{className:"rounded-lg border border-gray-200 p-3 dark:border-gray-800",children:[t.jsxs("div",{className:"flex flex-wrap items-baseline justify-between gap-x-3 gap-y-1",children:[t.jsx("span",{className:"font-mono text-xs font-semibold text-gray-800 dark:text-gray-100",children:e.repoFullName}),t.jsxs("span",{className:"whitespace-nowrap text-xs tabular-nums text-gray-500 dark:text-gray-400",children:[ln(e.prs)," PRs · median ",ql(e.medianLeadHours)," · three in four"," ",t.jsx("span",{className:"font-semibold text-gray-700 dark:text-gray-200",children:ql(e.p75LeadHours)})]})]}),t.jsx("div",{className:"mt-2",children:t.jsx(gh,{courts:e.courts,size:"sm"})}),e.evidence.length>0&&n!=null&&t.jsxs("div",{className:"mt-2 border-t border-gray-100 pt-1.5 dark:border-gray-800/70",children:[t.jsx("div",{className:"text-[11px] font-medium text-gray-500 dark:text-gray-400",children:"Longest in this court"}),t.jsx("ul",{children:e.evidence.map(r=>t.jsx(rR,{pr:r,court:n},r.prId))})]})]})}let X1=30;function tq({value:e,onChange:n}){return t.jsx("div",{role:"group","aria-label":"Window",className:"inline-flex rounded-md border border-gray-200 p-0.5 dark:border-gray-700",children:VC.map(r=>t.jsxs("button",{type:"button","aria-pressed":e===r,onClick:()=>n(r),className:`rounded px-2 py-0.5 text-xs ${e===r?"bg-gray-800 font-medium text-white dark:bg-gray-100 dark:text-gray-900":"text-gray-600 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-800"}`,children:[r," days"]},r))})}function zs({title:e,info:n,infoWidth:r,children:s,testId:a}){return t.jsxs("section",{"data-testid":a,className:"rounded-lg border border-gray-200 p-4 dark:border-gray-800",children:[t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("h4",{className:"text-sm font-semibold text-gray-800 dark:text-gray-100",children:e}),n!=null&&t.jsx(xy,{title:e,width:r,children:n})]}),t.jsx("div",{className:"mt-3",children:s})]})}function Z1({shown:e,measured:n}){return t.jsxs("p",{className:`mt-1 ${ed}`,children:["Showing ",ln(e)," of ",ln(n),": every slow pull request, and an even sample of the rest."]})}function J1({label:e,count:n,swatch:r}){return t.jsxs("div",{className:"flex items-center gap-2",children:[r!=null&&t.jsx("span",{className:`h-2.5 w-2.5 rounded-sm ${r}`}),t.jsx("h5",{className:"text-xs font-semibold text-gray-700 dark:text-gray-200",children:e}),t.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:[n," ",n===1?"repository":"repositories"]})]})}const nq=20;function rq(){var k,j;const e=G(N=>N.workspaceId),[n,r]=f.useState(()=>K7(X1)),s=N=>{X1=N,r(N)},[a,i]=f.useState(!1),c=B7(e,n),d=f.useMemo(()=>RW(c.data),[c.data]),u=c.data,m=uW(u),h=f.useMemo(()=>rW((u==null?void 0:u.prs)??[],nq),[u==null?void 0:u.prs]);if(d==null||u==null)return t.jsx("div",{className:"rounded-lg border border-dashed border-gray-300 p-6 text-center text-sm text-gray-500 dark:border-gray-700 dark:text-gray-400",children:c.isError?"Could not load this workspace’s flow.":"Measuring…"});const g=TW(d.coverage),x=$W(d.coverage),y=lW(u),b=u.settings==null?0:(u.settings.endMinute-u.settings.startMinute)/60,w=u.prs??[];return t.jsxs("div",{className:"space-y-4","data-testid":"bottlenecks-panel",children:[t.jsxs("div",{children:[t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("h3",{className:"text-sm font-semibold text-gray-700 dark:text-gray-200",children:"Chronology"}),t.jsx(xy,{title:"How Chronology works",children:t.jsx(pW,{settings:u.settings??null})})]}),t.jsx(tq,{value:n,onChange:s})]}),t.jsxs("div",{className:"mt-1 space-y-0.5",children:[u.settings!=null&&t.jsxs("p",{className:ed,children:[Y7(u.settings)," Set per workspace in Settings."]}),t.jsx("p",{className:ed,children:IW(d.coverage,d.windowDays)}),g!=null&&t.jsx("p",{className:ed,children:g}),x!=null&&t.jsxs("p",{className:"flex items-start gap-1.5 text-xs text-amber-700 dark:text-amber-400",children:[t.jsx(Jt,{size:12,className:"mt-0.5 shrink-0"}),t.jsx("span",{children:x})]})]})]}),d.nothingMeasured?t.jsxs("div",{className:"rounded-lg border border-dashed border-gray-300 p-6 text-center text-sm text-gray-500 dark:border-gray-700 dark:text-gray-400",children:["Nothing to measure in this workspace yet.",t.jsx("p",{className:"mt-1 text-xs",children:"A pull request has to merge, and a person has to have reviewed or commented on it, before its waiting time can be counted."})]}):t.jsxs(t.Fragment,{children:[m&&u.settings!=null?t.jsxs(t.Fragment,{children:[t.jsx(zs,{title:"Who was holding it, in working hours",info:t.jsx(mW,{}),testId:"chronology-split",children:t.jsx(gh,{courts:u.courtsWork??[],size:"lg"})}),t.jsx(zs,{title:"Each wait against its budget",info:t.jsx(gW,{}),testId:"chronology-budgets",children:t.jsx(FW,{rows:u.budgets??[],dayHours:b})}),w.length>0&&t.jsxs(zs,{title:"Every pull request",info:t.jsx(fW,{}),testId:"chronology-scatter",children:[y!=null&&t.jsxs("div",{className:"mb-3 flex flex-wrap gap-x-8 gap-y-2",children:[t.jsx(Ti,{value:ln(y.overWorkingDay),label:"took more than a working day"}),t.jsx(Ti,{value:hc(y.slowestTenthShare),label:`of all working-hour waiting sits in the slowest ${ln(y.slowestTenthCount)}`})]}),t.jsx(DW,{prs:w,budgetHours:u.settings.budgets.lead.good,p75Hours:u.p75LeadWorkHours??0}),u.prsCapped&&t.jsx(Z1,{shown:w.length,measured:d.measuredPrs}),t.jsxs("button",{type:"button",onClick:()=>i(N=>!N),"aria-expanded":a,className:"mt-2 text-xs font-medium text-sky-700 hover:underline dark:text-sky-400",children:[a?"Hide":"Show"," the ",h.length," slowest as a table"]}),a&&t.jsx("div",{className:"mt-2",children:t.jsx(GW,{prs:h})})]}),(u.contrast!=null||(((k=u.sizeBands)==null?void 0:k.length)??0)>0)&&t.jsx(zs,{title:"What the slow ones have in common",info:t.jsx(xW,{}),testId:"chronology-contrast",children:t.jsxs("div",{className:"space-y-5",children:[u.contrast!=null?t.jsx(qW,{contrast:u.contrast}):t.jsx("p",{className:ed,children:"Too few pull requests to compare the fastest quarter with the slowest."}),t.jsxs("div",{className:"grid gap-5 md:grid-cols-2",children:[t.jsxs("div",{children:[t.jsx("h5",{className:"mb-2 text-xs font-medium text-gray-700 dark:text-gray-200",children:"By size"}),t.jsx(UW,{bands:u.sizeBands??[]})]}),t.jsxs("div",{children:[t.jsx("h5",{className:"mb-2 text-xs font-medium text-gray-700 dark:text-gray-200",children:"By the day it opened"}),t.jsx(HW,{days:u.weekdays??[]})]})]})]})}),u.landingTail!=null&&t.jsx(zs,{title:"Approved and waiting",info:t.jsx(yW,{dayHours:b}),testId:"chronology-landing",children:t.jsx(zW,{tail:u.landingTail})}),(((j=u.concentration)==null?void 0:j.length)??0)>0&&t.jsx(zs,{title:"Who gives the first review",info:t.jsx(bW,{}),testId:"chronology-concentration",children:t.jsx(KW,{rows:u.concentration??[]})}),u.requests!=null&&t.jsx(zs,{title:"Asking for a review",info:t.jsx(vW,{}),testId:"chronology-requests",children:t.jsx(QW,{stats:u.requests})}),t.jsx(ZW,{workspaceId:e,days:n}),w.length>0&&t.jsxs(zs,{title:"Where each pull request sits",info:t.jsx(wW,{}),testId:"chronology-triangle",children:[y!=null&&t.jsx("div",{className:"mb-2",children:t.jsx(Ti,{value:`${ln(y.neverWentBack)} of ${ln(d.measuredPrs)}`,label:"never went back to their author"})}),t.jsx(BW,{prs:w,overall:u.courtsWork??[]}),u.prsCapped&&t.jsx(Z1,{shown:w.length,measured:d.measuredPrs})]})]}):t.jsx(zs,{title:"Who was holding it, in clock hours",testId:"chronology-split",children:t.jsx(gh,{courts:d.courts,size:"lg"})}),(d.sections.length>0||d.quiet.length>0)&&t.jsx(zs,{title:"By repository, in clock hours",info:t.jsx(jW,{sections:d.sections}),infoWidth:"lg",testId:"chronology-repos",children:t.jsxs("div",{className:"space-y-5",children:[t.jsx(vy,{}),d.sections.map(N=>t.jsxs("section",{className:"space-y-2",children:[t.jsx(J1,{label:N.label,count:N.repos.length,swatch:Jp[N.court]}),N.summary!==""&&t.jsx("p",{className:"text-xs text-gray-700 dark:text-gray-300",children:N.summary}),t.jsx("ul",{className:"space-y-2",children:N.repos.map(I=>t.jsx(eq,{repo:I},I.repoId))})]},N.court)),d.quiet.length>0&&t.jsxs("section",{className:"space-y-2",children:[t.jsx(J1,{label:"Nothing stands out",count:d.quiet.length}),t.jsx("ul",{className:"space-y-1.5",children:d.quiet.map(N=>t.jsxs("li",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 rounded-lg border border-dashed border-gray-200 px-3 py-2 dark:border-gray-800",children:[t.jsx(Vo,{size:12,className:"shrink-0 text-gray-500 dark:text-gray-400"}),t.jsx("span",{className:"font-mono text-xs text-gray-600 dark:text-gray-300",children:N.repoFullName}),t.jsx("span",{className:"w-24 shrink-0",children:t.jsx(gh,{courts:N.courts,size:"bar"})}),t.jsxs("span",{className:"ml-auto text-xs tabular-nums text-gray-500 dark:text-gray-400",children:[ln(N.prs)," PRs · three in four ",ql(N.p75LeadHours)]})]},N.repoId))})]})]})}),d.unreviewed.length>0&&t.jsx(zs,{title:"Merged without a human review",info:t.jsx(NW,{}),testId:"chronology-unreviewed",children:t.jsx("ul",{className:"space-y-2",children:d.unreviewed.map(N=>t.jsxs("li",{className:"rounded-lg border border-gray-200 p-3 dark:border-gray-800",children:[t.jsxs("div",{className:"flex flex-wrap items-baseline justify-between gap-x-3",children:[t.jsx("span",{className:"font-mono text-xs font-semibold text-gray-800 dark:text-gray-100",children:N.repoFullName}),t.jsxs("span",{className:"text-xs tabular-nums text-gray-500 dark:text-gray-400",children:[t.jsx("span",{className:"font-semibold text-amber-700 dark:text-amber-400",children:mh(N.share)})," ","— ",N.withoutHumanReview," of ",N.merged," merges"]})]}),t.jsx("ul",{className:"mt-1.5 border-t border-gray-100 pt-1 dark:border-gray-800/70",children:N.evidence.map(I=>t.jsx(rR,{pr:I,court:null},I.prId))})]},N.repoId))})}),d.refusals.map(N=>t.jsxs("p",{"data-testid":"bottleneck-refusal",className:"flex items-start gap-1.5 rounded-lg border border-dashed border-gray-300 px-3 py-2 text-xs text-gray-500 dark:border-gray-700 dark:text-gray-400",children:[N.basis==="measured_clean"?t.jsx(Vo,{size:12,className:"mt-0.5 shrink-0"}):t.jsx(oc,{size:12,className:"mt-0.5 shrink-0"}),t.jsxs("span",{children:[N.basis==="insufficient_data"&&t.jsx("strong",{className:"font-medium",children:"Not enough data to say. "}),N.reason]})]},N.kind))]})]})}const sq={sprint:"Sprint to date","7d":"7d","14d":"14d","30d":"30d","90d":"90d",period:"Period"},ej={sprint:"Sprint to date","7d":"Last 7 days","14d":"Last 14 days","30d":"Last 30 days","90d":"Last 90 days",period:"Report period"};function sR(e){if(e==null)return null;const n=`${J0(e.from)} – ${J0(e.to)}`;return e.requested==="sprint"&&e.kind!=="sprint"?`${ej[e.kind]} · ${n} — no sprint cadence configured`:`${ej[e.kind]} · ${n}`}const tp=10;function aq(e){return e.flatMap(n=>n.response.answer!=null?[{question:n.question,answer:n.response.answer}]:[]).slice(-9)}function oq(e,n){const r=He();return tt({mutationFn:s=>{const a=G.getState().sprintChatThreads[dt(e)]??[],i=aq(a);return he.sprintChat({...s,...i.length>0?{history:i}:{},...e!=null?{scope:String(e)}:{},...n!=null?{window:{fromMs:n.fromMs,toMs:n.toMs}}:{}})},onMutate:()=>({scopeKey:dt(e)}),onSuccess:(s,a,i)=>{s.answer!=null&&i!=null&&(G.getState().appendSprintChatTurn(i.scopeKey,{question:a.question,response:s}),G.getState().sprintChatDraft.question.trim()===a.question&&G.getState().setSprintChatDraft({question:""})),r.invalidateQueries({queryKey:["ai-usage"]}),r.invalidateQueries({queryKey:["sprint-chat-history"]})}})}function iq(e,n,r){return Oe({queryKey:["sprint-chat-history",dt(n),e],queryFn:n==null?Ct:()=>he.sprintChatHistory(tp,e*tp,n),enabled:r,staleTime:3e4,placeholderData:e$})}function lq(e,n){return Oe({queryKey:["scope-mention-candidates",dt(e)],queryFn:e==null?Ct:()=>he.scopeMentionCandidates(e),enabled:n,staleTime:3e5})}function cq(e,n){return Oe({queryKey:["pinned-prompts",dt(e)],queryFn:e==null?Ct:()=>he.pinnedPrompts(e),enabled:n,staleTime:6e4})}function dq(e){const n=He();return tt({mutationFn:r=>he.createPinnedPrompt({...r,...e!=null?{scope:String(e)}:{}}),onSuccess:()=>{n.invalidateQueries({queryKey:["pinned-prompts",dt(e)]})}})}function uq(e){const n=He();return tt({mutationFn:r=>he.deletePinnedPrompt(r),onSuccess:()=>{n.invalidateQueries({queryKey:["pinned-prompts",dt(e)]})}})}const hq=/^\d{4}-\d{2}-\d{2}/;function pq(e){return e==="percent"?n=>`${Math.round(n*10)/10}%`:e==="hours"?wn:Sn}function mq({spec:e}){if(e.series.length===0||e.labels.length===0)return null;const n=e.series.map((i,c)=>({key:`s${c}`,label:i.label||`Series ${c+1}`,color:Xl[c%Xl.length],values:i.values})),r=pq(e.unit),s=e.labels.every(i=>hq.test(i)&&!Number.isNaN(Date.parse(i))),a=(e.type==="line"||e.type==="area")&&s;return t.jsx(jt,{title:e.title||"Chart",children:a?t.jsx(Gn,{labels:e.labels,series:n,area:e.type==="area",curved:!0,formatY:r}):t.jsx(Lr,{labels:e.labels,series:n,formatY:r,rotateLabels:e.labels.length>6})})}const gq="Give me a sprint status report: overall flow health, what needs attention now, the biggest changes shipped this sprint, and any blockers.",fq="Give me a retrospective of this sprint: start with a short narrative summary (2-3 sentences), then ONE GitHub-flavoured markdown pipe table of the retro items with columns Item | Category | PRs | Note. Category is one of: shipped, went well, dragged, CI. Put PR references in the PRs column as plain owner/name#N.",xq="What does this workspace do, and what are its latest priorities? Using the repo descriptions and recent PR activity in the JSON, give one line per repository on its purpose, then a short list of the current priorities and themes across the workspace.",yq=[{label:"Sprint report",question:gq},{label:"Retro",question:fq},{label:"About this Workspace",question:xq},...j$.map(e=>({label:e.label,question:e.question}))];function bq(e){const n=[];return e!=null&&e.length>0&&n.push({key:"report",title:"From this report",pills:e}),n.push({key:"builtin",title:"Quick questions",pills:yq}),n}const vq=[];function kq(e){return{id:e.prId,number:e.prNumber,title:e.title??`#${e.prNumber}`,repoFullName:e.repoFullName,authorLogin:e.authorLogin,authorDisplayName:null,authorAvatarUrl:null}}function wq(){return t.jsxs("div",{className:"space-y-1.5 py-0.5","aria-hidden":"true",children:[t.jsx("div",{className:"digest-skeleton-line h-3.5",style:{width:"42%"}}),["94%","88%","72%"].map((e,n)=>t.jsx("div",{className:"digest-skeleton-line h-3",style:{width:e}},n))]})}function tj({checked:e,onChange:n,label:r,title:s}){return t.jsxs("label",{className:"inline-flex cursor-pointer items-center gap-1.5 text-[11px] text-gray-600 dark:text-gray-300",title:s,children:[t.jsx("input",{type:"checkbox",checked:e,onChange:a=>n(a.target.checked),className:"h-3.5 w-3.5 rounded border-gray-300 text-ai-signal focus:ring-ai-signal dark:border-gray-600"}),r]})}function aR({text:e}){return t.jsx("div",{className:"flex justify-end",children:t.jsx("div",{className:"max-w-[85%] truncate rounded-md bg-ai-surface-2 px-2.5 py-1 text-xs text-ai-ink",title:e,children:e})})}function jq({turn:e,onOpenPr:n}){const r=e.response,a=[sR(r.window),r.generatedAt?`Generated ${new Date(r.generatedAt).toLocaleString()}`:null,r.model!=null?oC(r.model):null].filter(c=>c!=null).join(" · "),i=r.trimmedTurns??0;return t.jsxs("div",{children:[t.jsx(aR,{text:e.question}),t.jsxs("div",{className:"digest-fade-in mt-1.5 rounded-md border border-ai-hairline bg-white/60 p-3 dark:bg-gray-900/40",children:[t.jsx(Zp,{markdown:r.answer??"",prRefs:r.prRefs??[],onOpenPr:n}),r.chart&&t.jsx("div",{className:"mt-3",children:t.jsx(mq,{spec:r.chart})}),a!==""&&t.jsx("div",{className:"mt-1.5 text-[10px] text-gray-400",children:a}),i>0&&t.jsxs("div",{className:"mt-0.5 text-[10px] italic text-gray-400",children:["The model couldn't see the ",i," earliest turn",i===1?"":"s"," for this answer."]})]})]})}function Nq({item:e,selected:n,onSelect:r,onReuse:s}){return t.jsxs("li",{className:`flex items-stretch overflow-hidden rounded border ${n?"border-sky-400 bg-sky-50 ring-1 ring-sky-400 dark:border-sky-500 dark:bg-sky-950/30 dark:ring-sky-500":"border-gray-200 dark:border-gray-800"}`,children:[t.jsxs("button",{type:"button",onClick:r,className:"flex min-w-0 flex-1 items-start gap-2 px-2 py-1.5 text-left text-xs hover:bg-gray-50 dark:hover:bg-gray-900/40","aria-current":n,children:[t.jsxs("span",{className:"min-w-0 flex-1 truncate font-medium text-gray-700 dark:text-gray-200",children:[e.wantChart&&t.jsx(vp,{size:12,className:"mr-1 inline-block align-[-0.1em]"}),e.wantBots&&t.jsx(Lt,{size:12,className:"mr-1 inline-block align-[-0.1em]"}),e.question]}),e.window&&t.jsx("span",{className:"shrink-0 rounded bg-gray-100 px-1 text-[10px] text-gray-500 dark:bg-gray-800 dark:text-gray-400",title:sR(e.window)??void 0,children:sq[e.window.kind]}),t.jsx("span",{className:"shrink-0 text-[10px] text-gray-400",title:new Date(e.createdAt).toLocaleString(),children:new Date(e.createdAt).toLocaleDateString()})]}),t.jsxs("button",{type:"button",onClick:a=>{a.stopPropagation(),s()},className:"shrink-0 border-l border-gray-200 px-2 text-[10px] font-medium text-ai-signal hover:bg-ai-signal/10 hover:underline dark:border-gray-800",title:"Load this question back into the box to edit or re-ask",children:[t.jsx(us,{size:10,className:"mr-1 inline-block align-[-0.1em]"}),"Reuse"]})]})}function Sq({periodWindow:e,periodLabel:n,suggestedQuestions:r}={}){var le,Ne,Ve,me,be,at,ft,mt;const{activityDigest:s}=vt(),a=G(se=>se.workspaceId),i=dt(a),c=Ge(se=>se.openPrDetailTab),d=G(se=>se.sprintChatDraft),u=G(se=>se.setSprintChatDraft),m=G(se=>se.sprintChatThreads[i])??vq,h=G(se=>se.setSprintChatThread),{question:g,wantChart:x,wantBots:y}=d,[b,w]=f.useState(!1),[k,j]=f.useState(!1),[N,I]=f.useState(0),[S,T]=f.useState(null),$=f.useRef(null),P=f.useRef(!0),C=oq(a,e),{data:L}=lq(a,s),F=cq(a,s),M=dq(a),D=uq(a),A=iq(N,a,s&&b);f.useEffect(()=>{I(0),C.reset(),T(null)},[i]);const W=ei(s),z=((le=W.data)==null?void 0:le.summaryTurnLimit)!=null&&(W.data.summaryTurnsRemaining??0)<=0;if(f.useEffect(()=>{const se=$.current;se&&P.current&&(se.scrollTop=se.scrollHeight)},[m.length,C.isPending]),f.useEffect(()=>{var se;S!=null&&((se=$.current)==null||se.scrollIntoView({behavior:"smooth",block:"nearest"}))},[S]),!s)return null;const te=g.trim(),H=m.length>=Mg,B=te!==""&&a!=null&&!C.isPending&&!z&&!H,O=(se,Ce,_e)=>{const pe=se.trim();pe===""||a==null||C.isPending||z||H||(T(null),P.current=!0,C.mutate({question:pe,wantChart:Ce,wantBots:_e}))},E=se=>{const Ce={enabled:!0,answer:se.answer,prRefs:se.prRefs,chart:se.chart,window:se.window,model:se.model??void 0,generatedAt:se.createdAt};C.reset(),h(i,[{question:se.question,response:Ce}]),T(se.id)},ee=()=>{C.reset(),h(i,[]),u({question:""}),T(null)},K=se=>{u({question:se.text,wantChart:se.wantChart,wantBots:se.wantBots}),O(se.text,se.wantChart,se.wantBots)},U=se=>{u({question:se.question}),O(se.question,x,y)},Q=m[m.length-1],J=te!==""?te:(Q==null?void 0:Q.question.trim())??"",ne=()=>{J!==""&&M.mutate({text:J,wantChart:x,wantBots:y})},ae=((Ne=F.data)==null?void 0:Ne.prompts)??[],we=J!==""&&ae.some(se=>se.text===J),$e=(Q==null?void 0:Q.response.followUps)??[],Fe=C.isPending||z||H,oe=((Ve=A.data)==null?void 0:Ve.items)??[],re=((me=A.data)==null?void 0:me.total)??0,X=Math.max(1,Math.ceil(re/tp));return t.jsxs("div",{className:"rounded-lg border border-ai-border bg-ai-surface p-4","data-testid":"adhoc-chat-panel",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("span",{className:"text-base font-semibold text-gray-800 dark:text-gray-100",children:[t.jsx(Qo,{size:15,className:"inline-block align-[-0.1em]"})," ",n!=null?"Ask about this period":"Ask about the sprint"]}),t.jsx("span",{className:"shrink-0 rounded bg-ai-signal/10 px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-ai-signal",children:"Pro"}),m.length>0&&t.jsx("button",{type:"button",onClick:ee,className:"ml-auto shrink-0 text-[11px] font-medium text-gray-500 hover:text-gray-700 hover:underline dark:text-gray-400 dark:hover:text-gray-200",title:"Clear this conversation and start over (your questions stay in History)",children:"New conversation"})]}),t.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:n!=null?t.jsxs(t.Fragment,{children:["Pick a question below or type your own — answered from this Workspace's data over"," ",t.jsx("span",{className:"font-medium",children:n}),", the period shown above (runs your configured report model). Follow-ups continue the conversation. Type"," ",t.jsx("span",{className:"font-mono",children:"@"})," to mention someone."]}):t.jsxs(t.Fragment,{children:["Pick a question below or type your own — answered from this Workspace's sprint data (runs your configured report model). Follow-ups continue the conversation. Type"," ",t.jsx("span",{className:"font-mono",children:"@"})," to mention someone."]})}),(m.length>0||C.isPending)&&t.jsxs("div",{ref:$,onScroll:se=>{const Ce=se.currentTarget;P.current=Ce.scrollHeight-Ce.scrollTop-Ce.clientHeight<40},className:"mt-3 max-h-[28rem] space-y-3 overflow-y-auto pr-0.5","data-testid":"chat-transcript",children:[m.map((se,Ce)=>t.jsx(jq,{turn:se,onOpenPr:_e=>c(kq(_e),{fromActivity:!0})},`${Ce}:${se.response.generatedAt??""}`)),C.isPending&&t.jsxs("div",{children:[((be=C.variables)==null?void 0:be.question)!=null&&t.jsx(aR,{text:C.variables.question}),t.jsx("div",{className:"mt-1.5 rounded-md border border-ai-hairline bg-white/60 p-3 dark:bg-gray-900/40",children:t.jsx(wq,{})})]}),!C.isPending&&$e.length>0&&t.jsxs("div",{"data-testid":"chat-follow-ups",children:[t.jsx("div",{className:"mb-1 text-[10px] font-semibold uppercase tracking-wide text-gray-400",children:"Follow up"}),t.jsx("div",{className:"flex flex-wrap gap-1.5",children:$e.map(se=>t.jsx("button",{type:"button",onClick:()=>U({question:se}),disabled:Fe,className:"rounded-full bg-ai-signal px-2.5 py-0.5 text-left text-[11px] font-medium text-white hover:opacity-90 disabled:opacity-50 dark:text-gray-950",title:se,children:se},se))})]})]}),bq(r).map(se=>{const Ce=se.key==="builtin"&&m.length>0,_e=!Ce||k;return t.jsxs("div",{className:"mt-2","data-testid":se.key==="report"?"chat-report-questions":"chat-quick-questions",children:[Ce?t.jsxs("button",{type:"button",onClick:()=>j(pe=>!pe),className:"mb-1 flex items-center gap-1 text-[10px] font-semibold uppercase tracking-wide text-gray-400 hover:text-gray-600 dark:hover:text-gray-300","aria-expanded":_e,children:[t.jsx(Mt,{dir:_e?"down":"right",size:10}),se.title]}):t.jsx("div",{className:"mb-1 text-[10px] font-semibold uppercase tracking-wide text-gray-400",children:se.title}),_e&&t.jsx("div",{className:"flex flex-wrap gap-1.5",children:se.pills.map(pe=>t.jsx("button",{type:"button",onClick:()=>U(pe),disabled:Fe,className:se.key==="report"?"rounded-full border border-sky-300 bg-sky-50/80 px-2.5 py-0.5 text-[11px] font-medium text-sky-700 hover:bg-sky-100 disabled:opacity-50 dark:border-sky-800 dark:bg-sky-950/30 dark:text-sky-200 dark:hover:bg-sky-950/50":"rounded-full border border-ai-border bg-white/70 px-2.5 py-0.5 text-[11px] font-medium text-ai-signal hover:bg-ai-surface-2 disabled:opacity-50 dark:bg-gray-900/50",title:pe.question,children:pe.label},pe.label))})]},se.key)}),C.isError&&t.jsx("div",{className:"mt-2 text-[11px] text-red-500",children:((at=C.error)==null?void 0:at.message)??"Couldn’t answer that — try again."}),((ft=C.data)==null?void 0:ft.throttled)&&t.jsx("div",{className:"mt-2 text-[11px] text-gray-400",children:"A question is already running — try again in a moment."}),(((mt=C.data)==null?void 0:mt.creditsExhausted)||z)&&t.jsx("div",{className:"mt-2 text-[11px] text-amber-600 dark:text-amber-400",children:"Out of AI credits this month — questions resume on the 1st."}),H&&t.jsxs("div",{className:"mt-3 flex flex-wrap items-center justify-between gap-2 rounded-md border border-amber-300 bg-amber-50/60 px-2.5 py-1.5 text-[11px] text-amber-700 dark:border-amber-800 dark:bg-amber-950/20 dark:text-amber-300",children:[t.jsxs("span",{children:["This conversation is at its ",Mg,"-question limit."]}),t.jsx("button",{type:"button",onClick:ee,className:"rounded border border-amber-400 px-2 py-0.5 font-semibold hover:bg-amber-100 dark:border-amber-700 dark:hover:bg-amber-950/40",children:"Start a new conversation"})]}),t.jsx("div",{className:"mt-3",children:t.jsx(Ad,{candidates:L,value:g,onChange:se=>u({question:se}),rows:3,disabled:H,ariaLabel:"Ask a question about the sprint",placeholder:"e.g. What did @alex ship this sprint? Which reviews are stuck?",className:"w-full resize-y rounded-md border border-gray-300 bg-white px-2.5 py-2 text-sm text-gray-800 placeholder-gray-400 focus:border-ai-signal focus:outline-none focus:ring-1 focus:ring-ai-signal disabled:opacity-50 dark:border-gray-700 dark:bg-gray-900 dark:text-gray-100",onKeyDown:se=>{(se.metaKey||se.ctrlKey)&&se.key==="Enter"&&B&&(se.preventDefault(),O(g,x,y))}})}),t.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-x-4 gap-y-2",children:[t.jsx(tj,{checked:x,onChange:se=>u({wantChart:se}),label:"Add a chart",title:"Also generate a chart for the answer when one fits (a second Haiku pass)"}),t.jsx(tj,{checked:y,onChange:se=>u({wantBots:se}),label:"Include bot performance",title:"Append Limn's review-bot performance data (volume, acted-on %, noise, verdict) to the question"}),t.jsxs("div",{className:"ml-auto flex items-center gap-1.5",children:[t.jsxs("button",{type:"button",onClick:ne,disabled:J===""||M.isPending||we,className:"rounded border border-gray-300 px-2 py-1 text-[11px] font-medium text-gray-600 hover:border-gray-400 disabled:opacity-50 dark:border-gray-700 dark:text-gray-300 dark:hover:border-gray-500",title:we?"Already pinned":te===""&&J!==""?"Pin the last question to re-run later":"Pin this prompt to re-run later",children:[t.jsx(t_,{size:11,className:"mr-1 inline-block align-[-0.1em]"}),we?"Pinned":"Pin"]}),t.jsx("button",{type:"button",onClick:()=>O(g,x,y),disabled:!B,className:"rounded bg-ai-signal px-3 py-1 text-[11px] font-semibold text-white hover:opacity-90 disabled:opacity-50 dark:text-gray-950",title:H?`This conversation is at its ${Mg}-question limit — start a new one`:z?"Out of AI credits — resets next month":"Ask (runs your configured report model)",children:C.isPending?"Asking…":"Ask"})]})]}),ae.length>0&&t.jsxs("div",{className:"mt-3",children:[t.jsx("div",{className:"mb-1 text-[10px] font-semibold uppercase tracking-wide text-gray-400",children:"Pinned"}),t.jsx("div",{className:"flex flex-wrap gap-1.5",children:ae.map(se=>t.jsxs("span",{className:"inline-flex max-w-full items-center gap-1 rounded-full border border-ai-border bg-white/70 py-0.5 pl-2 pr-1 text-[11px] text-ai-ink dark:bg-gray-900/50",children:[t.jsxs("button",{type:"button",onClick:()=>K(se),disabled:Fe,className:"max-w-[22rem] truncate text-left hover:underline disabled:opacity-50",title:`Re-run: ${se.text}`,children:[se.wantChart&&t.jsx(vp,{size:11,className:"mr-1 inline-block align-[-0.1em]"}),se.wantBots&&t.jsx(Lt,{size:11,className:"mr-1 inline-block align-[-0.1em]"}),se.text]}),t.jsx("button",{type:"button",onClick:()=>D.mutate(se.id),className:"rounded-full px-1 text-gray-400 hover:text-red-500",title:"Remove this pinned prompt","aria-label":"Remove pinned prompt",children:t.jsx(Zt,{})})]},se.id))})]}),t.jsxs("div",{className:"mt-4 border-t border-ai-hairline pt-3",children:[t.jsxs("button",{type:"button",onClick:()=>w(se=>!se),className:"flex items-center gap-1.5 text-[11px] font-semibold uppercase tracking-wide text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200","aria-expanded":b,children:[t.jsx(Mt,{dir:b?"down":"right"}),"History",re>0&&t.jsxs("span",{className:"text-gray-400",children:["· ",re]})]}),b&&t.jsxs("div",{className:"mt-2",children:[A.isLoading?t.jsx("div",{className:"py-1 text-[11px] text-gray-400",children:"Loading…"}):oe.length===0?t.jsx("div",{className:"py-1 text-[11px] text-gray-400",children:"No past questions yet."}):t.jsx("ul",{className:"space-y-1",children:oe.map(se=>t.jsx(Nq,{item:se,selected:S===se.id,onSelect:()=>E(se),onReuse:()=>u({question:se.question,wantChart:se.wantChart,wantBots:se.wantBots})},se.id))}),re>tp&&t.jsxs("div",{className:"mt-2 flex items-center justify-between text-[11px] text-gray-500 dark:text-gray-400",children:[t.jsxs("button",{type:"button",onClick:()=>I(se=>Math.max(0,se-1)),disabled:N===0,className:"rounded border border-gray-300 px-2 py-0.5 font-medium hover:border-gray-400 disabled:opacity-40 dark:border-gray-700 dark:hover:border-gray-500",children:[t.jsx(Mt,{dir:"left",size:11,className:"mr-1 inline-block align-[-0.1em]"}),"Newer"]}),t.jsxs("span",{className:"tabular-nums",children:["Page ",N+1," of ",X]}),t.jsxs("button",{type:"button",onClick:()=>I(se=>Math.min(X-1,se+1)),disabled:N+1>=X,className:"rounded border border-gray-300 px-2 py-0.5 font-medium hover:border-gray-400 disabled:opacity-40 dark:border-gray-700 dark:hover:border-gray-500",children:["Older",t.jsx(Mt,{dir:"right",size:11,className:"ml-1 inline-block align-[-0.1em]"})]})]})]})]})]})}function oR(e){return[...e].sort((n,r)=>n.label.localeCompare(r.label)||n.userId-r.userId)}function Cq(e){return T$.flatMap(n=>{const r=e[n];return r&&r.rows.length>0?[{key:n,rows:r.rows,more:r.more}]:[]})}function Rq(e){const n=e.reportKey!=null&&e.periodKeys.includes(e.reportKey);return e.chipCount>=1&&n?null:e.chipCount===0?"Pick at least one person or bot first":e.listLoading?"Waiting for the period list to load":e.periodKeys.length===0?"No completed periods yet — the report covers one completed sprint period":"Waiting for the Reports period selection to resolve"}function Iq(e){const n=e.split("/");return n.length>2?`${n[0]}/${n[1]}/**`:e}function Tq(e,n=5){const r=new Map,s=new Map;for(const i of e)if(r.set(i.repoFullName,(r.get(i.repoFullName)??0)+1),i.path!=null&&i.path!==""){const c=Iq(i.path);s.set(c,(s.get(c)??0)+1)}const a=i=>[...i.entries()].sort((c,d)=>d[1]-c[1]||c[0].localeCompare(d[0])).slice(0,n);return{repos:a(r),areas:a(s),sampleSize:e.length}}const $q={queue:[],current:null};function _q(e,n){switch(n.type){case"request":return e.current===n.userId||e.queue.includes(n.userId)?e:e.current==null?{queue:e.queue,current:n.userId}:{queue:[...e.queue,n.userId],current:e.current};case"release":{if(e.current===n.userId){const[r,...s]=e.queue;return{queue:s,current:r??null}}return e.queue.includes(n.userId)?{queue:e.queue.filter(r=>r!==n.userId),current:e.current}:e}}}function Pq(e){let n=/^pm\d+:([a-z_]+):/.exec(e);return n?`metric:${n[1]}`:(n=/^pe\d+:(pr|rc|pc|th):(\d+)$/.exec(e),n?`${n[1]}:${n[2]}`:(n=/^pe\d+:area:(.+):\d+$/.exec(e),n?`area:${n[1]}`:null))}const Eq={review:"reviewer",quality_check:"quality check",dependency:"dependency bot",code_agent:"code agent",release:"release automation",housekeeping:"housekeeping"},Aq=10,nj=8,Mq=180;function Lq(e){return{login:e.login,kind:e.kind??"in_house"}}function Fq(){var re;const{periodReports:e}=vt(),n=G(X=>X.workspaceId),r=G(X=>X.insightsReportKey),s=G(X=>X.insightsReportGrain),a=G(X=>X.openPeopleReport),{data:i}=An(),{data:c}=xn(),{data:d}=xa(),{data:u}=fp(),{data:m}=qi(n),h=co(n),g=Fd(e,n,s),x=((re=g.data)==null?void 0:re.periods)??[],y=f.useMemo(()=>{var me;const X=((me=g.data)==null?void 0:me.periods)??[],le=X.find(be=>be.periodKey===r)??X[0]??null;if(le==null)return null;const Ne=Date.parse(le.periodStart),Ve=le.inProgress?Math.min(Date.parse(le.periodEnd),Date.now()):Date.parse(le.periodEnd);return Number.isFinite(Ne)&&Number.isFinite(Ve)?{fromMs:Ne,toMs:Ve}:null},[g.data,r]),{data:b}=L4(y),{data:w}=Np(),[k,j]=f.useState([]),[N,I]=f.useState(""),[S,T]=f.useState(!1),[$,P]=f.useState({}),C=f.useRef(null),L=f.useRef(null),[F,M]=f.useState({dir:"up",max:0});Yr(C,()=>T(!1),S),f.useEffect(()=>{if(!S)return;const X=()=>{const le=L.current;if(le==null)return;const Ne=le.getBoundingClientRect();let Ve=le.parentElement,me=0,be=window.innerHeight;for(;Ve!=null&&Ve!==document.body;){if(/(auto|scroll)/.test(getComputedStyle(Ve).overflowY)){const se=Ve.getBoundingClientRect();me=Math.max(me,se.top),be=Math.min(be,se.bottom);break}Ve=Ve.parentElement}const at=Ne.top-me-nj,ft=be-Ne.bottom-nj,mt=at>=ft?"up":"down";M({dir:mt,max:Math.max(Mq,Math.floor(mt==="up"?at:ft))})};return X(),window.addEventListener("resize",X),window.addEventListener("scroll",X,!0),()=>{window.removeEventListener("resize",X),window.removeEventListener("scroll",X,!0)}},[S]),f.useEffect(()=>{if(!S)return;const X=le=>{le.key==="Escape"&&(le.stopPropagation(),T(!1))};return document.addEventListener("keydown",X),()=>document.removeEventListener("keydown",X)},[S]);const D=f.useMemo(()=>{const X=new Map(((m==null?void 0:m.reviewers)??[]).map(le=>[le.userId,le]));return le=>{const Ne=X.get(le.id);if(Ne!=null){if(Ne.automated)return!0;if(Ne.isManualOverride)return!1}return le.isBot}},[m]),A=f.useMemo(()=>new Set(k.map(X=>X.userId)),[k]),W=f.useMemo(()=>new Set(MS(n,d??[])),[n,d]),{sections:z,maintainerIds:te}=f.useMemo(()=>oS({users:i,repos:c,searchTimeline:b,searchOpenPrs:w,mergers:u,inScopeRepoIds:W,repoScoped:!1,selectedIds:[...A],allowedBotIds:[],isBot:D,includeRosterRemainder:!1}),[i,c,b,w,u,W,A,D]),H=f.useMemo(()=>((m==null?void 0:m.reviewers)??[]).filter(X=>X.automated).sort((X,le)=>X.label.localeCompare(le.label)||X.userId-le.userId),[m]),B=f.useMemo(()=>new Map((i??[]).map(X=>[X.id,X])),[i]),O=f.useMemo(()=>{if(te.size===0)return[];const X=new Map;for(const le of u??[])if(W.has(le.repoId))for(const Ne of le.userIds)te.has(Ne)&&X.set(Ne,(X.get(Ne)??0)+1);return[...te].map(le=>B.get(le)).filter(le=>le!=null).map(le=>({user:le,label:Dt(le,le.id),breadth:X.get(le.id)??0})).sort((le,Ne)=>Ne.breadth-le.breadth||le.label.localeCompare(Ne.label)||le.user.id-Ne.user.id).slice(0,Aq).sort((le,Ne)=>le.label.localeCompare(Ne.label)||le.user.id-Ne.user.id)},[te,u,W,B]);if(n==null||!e)return null;const E=X=>({kind:"human",userId:X.id,login:X.githubLogin,label:Dt(X,X.id),avatarUrl:X.avatarUrl}),ee=X=>({kind:"bot",userId:X.userId,login:X.login,label:X.label,avatarUrl:X.avatarUrl}),K=X=>j(le=>le.filter(Ne=>Ne.userId!==X)),U=X=>j(le=>le.some(Ne=>Ne.userId===X.userId)?le:[...le,X]),Q=X=>{if(A.has(X)){K(X);return}const le=B.get(X);le&&U(E(le))},J=(X,le)=>{if(!le){j(Ne=>Ne.filter(Ve=>!X.includes(Ve.userId)));return}j(Ne=>{const Ve=new Set(Ne.map(be=>be.userId)),me=X.filter(be=>!Ve.has(be)).map(be=>B.get(be)).filter(be=>be!=null).map(E);return me.length?[...Ne,...me]:Ne})},ne=N.trim().toLowerCase(),ae=H.filter(X=>!ne||X.label.toLowerCase().includes(ne)||X.login.toLowerCase().includes(ne)),we=Rq({chipCount:k.length,reportKey:r,periodKeys:x.filter(X=>!X.inProgress).map(X=>X.periodKey),listLoading:g.isLoading}),$e=we==null,Fe=we??"Open the People report for the period selected above — one section per person or bot, alphabetical",oe=oR(k);return t.jsxs("section",{"aria-label":"People","data-testid":"people-picker",className:"print:hidden",ref:C,children:[t.jsxs("div",{className:"mb-1 flex flex-wrap items-baseline gap-2",children:[t.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wide text-gray-400",children:"People"}),t.jsx("span",{className:"text-[11px] text-gray-400",children:"prep for 1:1s, not a scorecard — sections alphabetical, no rankings"})]}),oe.length>0&&t.jsx("div",{className:"mb-1.5 flex flex-wrap gap-1.5",children:oe.map(X=>t.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-full border border-gray-300 py-0.5 pl-1.5 pr-1 text-[11px] text-gray-700 dark:border-gray-700 dark:text-gray-200",children:[X.kind==="bot"?t.jsx("span",{"aria-hidden":"true",className:"inline-block h-2.5 w-2.5 shrink-0 rounded-full",style:{background:h({login:X.login,kind:"in_house"})}}):X.avatarUrl!=null?t.jsx("img",{src:X.avatarUrl,width:14,height:14,alt:"",loading:"lazy",referrerPolicy:"no-referrer",className:"h-3.5 w-3.5 shrink-0 rounded-full bg-gray-200 dark:bg-gray-800"}):t.jsx(yx,{size:14,className:"shrink-0"}),t.jsx("span",{className:"max-w-[12rem] truncate",title:X.login??X.label,children:X.label}),t.jsx("button",{type:"button",onClick:()=>K(X.userId),"aria-label":`Remove ${X.label} from the report`,className:"rounded px-0.5 opacity-60 hover:opacity-100",children:t.jsx(Zt,{})})]},X.userId))}),O.length>0&&t.jsx("div",{className:"mb-1.5 flex flex-wrap gap-1.5",children:O.map(({user:X,label:le})=>{const Ne=A.has(X.id);return t.jsxs("label",{title:Ne?`Remove ${le} from the report`:`Add ${le} to the report`,className:`inline-flex cursor-pointer items-center gap-1.5 rounded-full border py-0.5 pl-1.5 pr-2 text-[11px] transition ${Ne?"border-[#8957e5]/50 bg-[#8957e5]/15 text-[#8957e5]":"border-gray-300 text-gray-600 hover:bg-gray-100 dark:border-gray-700 dark:text-gray-300 dark:hover:bg-gray-800"}`,children:[t.jsx("input",{type:"checkbox",checked:Ne,onChange:()=>Q(X.id),className:"h-3 w-3"}),t.jsx(Kh,{}),t.jsx("span",{className:"max-w-[10rem] truncate",children:le})]},X.id)})}),t.jsxs("div",{className:"relative",children:[t.jsxs("div",{ref:L,className:"flex max-w-md items-center gap-2",children:[t.jsx("input",{type:"search",value:N,onChange:X=>{I(X.target.value),T(!0)},onFocus:()=>T(!0),placeholder:"Add people or bots…","aria-label":"Add people or bots to the report",className:"flex-1 rounded border border-gray-300 bg-transparent px-2 py-1 text-xs focus:border-ai-signal/60 focus:outline-none dark:border-gray-700"}),t.jsxs("button",{type:"button",disabled:!$e,onClick:()=>{r!=null&&a(n,r,k)},title:Fe,className:"shrink-0 rounded border border-ai-border px-2.5 py-1 text-[11px] font-medium text-ai-signal hover:border-ai-signal/60 hover:bg-ai-surface-2 disabled:cursor-not-allowed disabled:opacity-50",children:["Begin report",k.length>0?` (${k.length})`:""]})]}),S&&t.jsxs("div",{style:{maxHeight:F.max},className:`absolute left-0 z-30 flex w-full max-w-md flex-col rounded border border-gray-200 bg-white p-1.5 shadow-lg dark:border-gray-800 dark:bg-gray-900 ${F.dir==="up"?"bottom-full mb-1":"top-full mt-1"}`,children:[te.size>0&&(()=>{const X=[...te],le=X.every(Ne=>A.has(Ne));return t.jsxs("button",{type:"button",onClick:()=>J(X,!le),title:"Add every maintainer in this workspace to the report",className:`mb-1 flex w-full shrink-0 items-center gap-2 rounded px-2 py-1 text-xs transition ${le?"bg-[#8957e5]/15 text-[#8957e5]":"text-gray-600 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-800"}`,children:[t.jsx(Kh,{}),t.jsx("span",{className:"font-medium",children:"Maintainers"}),t.jsxs("span",{className:"text-gray-400",children:["(",X.length,")"]}),t.jsx("span",{className:"ml-auto text-[10px] text-gray-400",children:le?"clear":"select all"})]})})(),t.jsxs("div",{className:"max-h-72 min-h-0 flex-1 overflow-y-auto",children:[t.jsx(nC,{sections:z,filter:N,staged:A,onToggle:Q,onToggleMany:J,maintainerIds:te,shownOthers:$,setShownOthers:P}),ae.length>0&&t.jsxs("div",{className:"mt-1 border-t border-gray-200 pt-1 dark:border-gray-700",children:[t.jsx("div",{className:"sticky top-0 z-10 border-b border-gray-100 bg-white px-1 pb-0.5 pt-1 text-[10px] font-semibold uppercase tracking-wide text-gray-400 dark:border-gray-800 dark:bg-gray-900",children:"Bots"}),ae.map(X=>{const le=X.kind!=null?ds(X.kind):null,Ne=[le==null?void 0:le.label,Eq[X.role]].filter(Ve=>Ve!=null&&Ve!=="").join(" · ");return t.jsxs("label",{className:"flex cursor-pointer items-center gap-2 rounded px-1 py-1 text-xs hover:bg-gray-100 dark:hover:bg-gray-800",children:[t.jsx("input",{type:"checkbox",checked:A.has(X.userId),onChange:()=>A.has(X.userId)?K(X.userId):U(ee(X))}),t.jsx("span",{"aria-hidden":"true",className:"inline-block h-2.5 w-2.5 shrink-0 rounded-full",style:{background:h(Lq(X))}}),t.jsx("span",{className:"min-w-0 truncate",title:X.login,children:X.label}),Ne&&t.jsx("span",{className:"ml-auto shrink-0 text-[10px] text-gray-400",children:Ne})]},X.userId)})]})]})]})]})]})}const qu=104,zc=30,rj=7,sj=5;function Oq({prior:e,value:n,forecast:r,format:s,favourableColor:a}){if(n==null)return null;const i=[];e!=null&&i.push({x:0,v:e}),i.push({x:0,v:n}),r&&i.push({x:0,v:r.point});const c=i.length,d=qu-rj*2;i.forEach((N,I)=>{N.x=rj+(c<=1?d/2:I/(c-1)*d)});const u=i.map(N=>N.v).filter(N=>N!=null);r&&u.push(r.low,r.high);let m=Math.min(...u),h=Math.max(...u);if(h-m<1e-9){const N=Math.max(Math.abs(h)*.1,1);m-=N,h+=N}const g=zc-sj*2,x=N=>sj+g*(1-(N-m)/(h-m)),y=i.slice(0,e!=null?2:1),b=y[y.length-1],w=r?i[i.length-1].x:null,k=r?x(r.high):0,j=r?x(r.low):0;return t.jsxs("svg",{width:qu,height:zc,viewBox:`0 0 ${qu} ${zc}`,role:"img",className:"overflow-visible decorative-mark text-gray-300 dark:text-gray-700","aria-label":`this period ${s(n)}`+(e!=null?`, prior ${s(e)}`:", no prior period")+(r?`, next ≈ ${s(r.point)} (${s(r.low)}–${s(r.high)})`:""),children:[t.jsx("line",{x1:0,y1:zc-1,x2:qu,y2:zc-1,stroke:"currentColor",strokeWidth:1}),r&&w!=null&&t.jsxs(t.Fragment,{children:[t.jsx("path",{d:`M ${b.x} ${x(b.v)} L ${w} ${k} L ${w} ${j} Z`,className:"fill-ai-signal-fill",fillOpacity:.18}),t.jsx("line",{x1:b.x,y1:x(b.v),x2:w,y2:x(r.point),className:"stroke-ai-signal-fill",strokeWidth:1.5,strokeDasharray:"3 2"}),t.jsx("circle",{cx:w,cy:x(r.point),r:2.5,className:"fill-ai-signal-fill"})]}),y.length>1&&t.jsx("line",{x1:y[0].x,y1:x(y[0].v),x2:y[1].x,y2:x(y[1].v),stroke:a,strokeWidth:1.5}),y.map((N,I)=>t.jsx("circle",{cx:N.x,cy:x(N.v),r:2.5,fill:I===y.length-1?a:"transparent",stroke:a,strokeWidth:1.5},I))]})}function aj(e){const n=ro(e.periodStart,e.periodEnd,e.grain??"sprint");return e.inProgress?`${n} · to date`:n}function Dq(e,n){return e==="month"?`calendar month · ${n} days`:`sprint · ${n} days`}const Bq="text-green-600 dark:text-green-400",Wq="text-red-500 dark:text-red-400",nr="text-gray-400";function iR(e){return e.absoluteChange==null||e.absoluteChange===0||e.direction==="neutral"?null:e.absoluteChange>0==(e.direction==="up_good")}function qq(e){return e==null?nr:e?Bq:Wq}function Uq(e){return e==null?De.gray:e?De.green:De.red}function lR({hasPriorPeriod:e,notComputed:n}){return n?t.jsx("span",{className:`text-[11px] ${nr}`,title:"This period was backfilled for the forecast series; no comparison was run for it",children:"not compared"}):e?t.jsx("span",{className:`text-[11px] ${nr}`,title:"The previous period exists but has no figure for this metric, so there is nothing to subtract",children:"no prior figure"}):t.jsx("span",{className:`text-[11px] ${nr}`,title:"Nothing is stored for the period before this one",children:"no prior period"})}function Hq({delta:e,format:n,hasPriorPeriod:r}){if(e.prior==null)return t.jsx(lR,{hasPriorPeriod:r,notComputed:!1});if(e.value==null||e.absoluteChange==null)return t.jsx("span",{className:`text-[11px] ${nr}`,title:"No data for this metric in this period",children:"—"});if(e.absoluteChange===0)return t.jsx("span",{className:`text-[11px] ${nr}`,children:"no change"});if(!e.significant)return t.jsxs("span",{className:`text-[11px] ${nr}`,title:"Below the sample or size floor for this metric — the figures are real, but the change is not distinguishable from noise, so no percentage is quoted",children:[cs(e.absoluteChange,n),t.jsx("span",{className:"ml-1 text-[10px]",children:"· not significant"})]});const s=iR(e);return t.jsxs("span",{className:`text-[11px] font-medium ${qq(s)}`,children:[t.jsx(Cr,{dir:e.absoluteChange>0?"up":"down",className:"inline-block align-[-0.1em]"})," ",cs(e.absoluteChange,n),e.percentChange!=null?t.jsxs("span",{className:"ml-1 font-normal",children:["(",cs(e.percentChange,Ja),")"]}):t.jsx("span",{className:`ml-1 font-normal ${nr}`,title:"The prior period was 0, so a percentage change is undefined",children:"(from 0)"})]})}function zq({forecast:e,format:n}){return e==null?t.jsx("span",{className:`text-[11px] ${nr}`,children:"—"}):e.available?t.jsxs("span",{className:"text-[11px] text-ai-signal",title:`${e.basis} · ${e.periodsUsed} periods`,children:["≈ ",n(e.point),t.jsxs("span",{className:`ml-1 ${nr}`,children:["(",n(e.low),"–",n(e.high),")"]})]}):t.jsxs("span",{className:`text-[11px] ${nr}`,title:Qh[e.reason],children:["not forecast · ",e.reason.replace(/_/g," ")]})}const ld={human:{label:"People",note:"authored and reviewed by humans",hex:De.green},code_agent:{label:"Code agents",note:"Devin, autofix, codegen, translation sync — writes real changes",hex:De.teal},dependency:{label:"Dependency bots",note:"Dependabot, Renovate — version bumps, never reviews",hex:De.gray},ai_review:{label:"AI review",note:"CodeRabbit, Copilot, Greptile…",hex:De.violet},quality_gate:{label:"Quality gates & CI",note:"SonarQube, scanners, Actions — posts verdicts, not findings",hex:De.blue},release:{label:"Release automation",note:"merge queues, release trains, backports — moves code",hex:De.indigo},housekeeping:{label:"Housekeeping",note:"CLA, triage, labels, stale, size reports — noise in every review metric",hex:De.slate}},Kq={people:"People",authors:"Automation that writes code",responds:"Automation that responds"};function Gq({parts:e,total:n}){return n<=0?t.jsx("div",{className:"h-2 w-full rounded-sm bg-gray-100 dark:bg-gray-900",title:"nothing in this period"}):t.jsx("div",{className:"flex h-2 w-full overflow-hidden rounded-sm",children:e.filter(r=>r.n>0).map(r=>t.jsx("div",{style:{width:`${r.n/n*100}%`,backgroundColor:ld[r.lane].hex},title:`${ld[r.lane].label}: ${r.n} of ${n} (${Math.round(r.n/n*100)}%)`},r.lane))})}function Vq({lanes:e}){const n=new Map(e.lanes.map(h=>[h.lane,h])),r=b$,s=[{key:"authored",label:"PRs merged",pick:h=>h.mergedPrs},{key:"comments",label:"Review comments",pick:h=>h.comments},{key:"approvals",label:"Approvals",pick:h=>h.approvals}];if(!s.some(h=>e.lanes.reduce((g,x)=>g+h.pick(x),0)>0))return null;const i=n.get("human"),c=n.get("ai_review"),d=r.filter(h=>{const g=n.get(h);return g!=null&&s.some(x=>x.pick(g)>0)}),u=e.lanes.reduce((h,g)=>h+g.mergedPrs,0),m=h=>e.lanes.reduce((g,x)=>v$[x.lane]===h?g+x.mergedPrs:g,0);return t.jsxs("div",{className:"space-y-2 rounded-md border border-gray-200 px-3 py-2.5 dark:border-gray-800",children:[t.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-2",children:[t.jsx("span",{className:"text-[12px] font-medium text-gray-700 dark:text-gray-200",children:"Effort vs automation"}),e.automationMergeSharePct!=null&&t.jsxs("span",{className:"text-[11px] text-gray-500 dark:text-gray-400",children:[e.automationMergeSharePct,"% of merges were automated"]})]}),s.map(h=>{const g=e.lanes.reduce((x,y)=>x+h.pick(y),0);return t.jsxs("div",{className:"grid grid-cols-[7.5rem_1fr_3rem] items-center gap-2",children:[t.jsx("span",{className:"text-[11px] text-gray-500 dark:text-gray-400",children:h.label}),t.jsx(Gq,{parts:r.map(x=>({lane:x,n:h.pick(n.get(x)??{})||0})),total:g}),t.jsx("span",{className:"text-right text-[11px] tabular-nums text-gray-400",children:g})]},h.key)}),u>0&&t.jsx("div",{className:"flex flex-wrap gap-x-3 gap-y-0.5 pt-0.5 text-[10px] text-gray-500 dark:text-gray-400",children:["people","authors","responds"].map(h=>{const g=m(h);return g===0?null:t.jsxs("span",{children:[t.jsxs("span",{className:"font-medium text-gray-600 dark:text-gray-300",children:[Math.round(g/u*100),"%"]})," ",Kq[h].toLowerCase()]},h)})}),t.jsx("div",{className:"flex flex-wrap gap-x-3 gap-y-1 pt-0.5",children:d.map(h=>t.jsxs("span",{title:ld[h].note,className:"flex items-center gap-1 text-[10px] text-gray-500 dark:text-gray-400",children:[t.jsx("span",{className:"h-2 w-2 rounded-sm",style:{backgroundColor:ld[h].hex}}),ld[h].label]},h))}),c!=null&&c.comments===0&&e.silentAutomation.length>0&&t.jsx("div",{className:"text-[10px] text-amber-600 dark:text-amber-400",children:"No AI-review activity this period, though automation is configured — worth checking it is still running."}),i!=null&&(i.medianPrSizeLines!=null||i.medianLeadTimeHours!=null)&&t.jsxs("div",{className:"text-[10px] text-gray-400",children:["Human PRs",i.medianPrSizeLines!=null&&` ran ${i.medianPrSizeLines} lines at the median`,i.medianLeadTimeHours!=null&&`${i.medianPrSizeLines!=null?" and":""} merged in ${wn(i.medianLeadTimeHours)}`,"."]}),e.medianTimeToFirstHumanReviewHours!=null&&t.jsxs("div",{className:"text-[10px] text-gray-400",children:["First review by a person: ",wn(e.medianTimeToFirstHumanReviewHours)," at the median — the same measurement as the row above, which counts people only and excludes bot approvals."]})]})}function Qq({axis:e,metricKey:n,meta:r}){if(e.refusal!=null){const c=e.refusalWorkspaces??[];return t.jsxs("div",{className:`text-[11px] ${nr}`,children:["No like-for-like comparison: these workspaces do not all run the same sprint length, and one window measured over two cadences is not one figure.",c.length>0&&t.jsxs(t.Fragment,{children:[" ",t.jsxs("span",{className:"text-gray-500 dark:text-gray-400",children:[c.map(d=>d.cadenceDays==null?`${d.name} (no cadence set)`:`${d.name} (${d.cadenceDays} days)`).join(", "),"."]})]})," ","Set a matching cadence in Settings to compare them."]})}const s=e.prior==null?null:new Map(e.prior.map(c=>[c.workspaceId,c])),a=c=>c==null?void 0:c.metrics.find(d=>d.key===n),i=Vp(r);return t.jsxs("div",{className:"space-y-0.5",children:[t.jsxs("div",{className:"grid grid-cols-[minmax(8rem,16rem)_5.5rem_5.5rem_1fr] items-baseline gap-2 text-[9px] uppercase tracking-wide text-gray-400",children:[t.jsx("span",{children:"Workspace"}),t.jsx("span",{className:"text-right",children:"This period"}),t.jsx("span",{className:"text-right",children:"Prior"}),t.jsx("span",{children:"Change"})]}),e.current.map(c=>{const d=a(c),u=s==null?void 0:s.get(c.workspaceId),m=s==null?void 0:a(u),h=(d==null?void 0:d.value)??null,g=(m==null?void 0:m.value)??null,x=h!=null&&g!=null?h-g:null,y=!c.coverage.complete,b=u==null?void 0:u.coverage,w=b!=null&&!b.complete,k=y||w,j=y&&w?`Partial coverage in both windows: ${c.coverage.trackedRepos} of ${c.coverage.totalRepos} repos in this workspace were tracked when this period started, and ${b.trackedRepos} when the prior one did — both figures under-count, and the change mixes two different memberships.`:w?`Partial prior coverage: the prior period started before ${b.totalRepos-b.trackedRepos} of ${b.totalRepos} repos in this workspace were tracked, so the prior figure under-counts and the change over-states growth.`:`Partial coverage: ${c.coverage.trackedRepos} of ${c.coverage.totalRepos} repos in this workspace were being tracked when this period started, so its figures under-count the period.`;return t.jsxs("div",{className:"grid grid-cols-[minmax(8rem,16rem)_5.5rem_5.5rem_1fr] items-baseline gap-2 text-[11px]",children:[t.jsxs("span",{className:"flex min-w-0 items-baseline gap-1",children:[t.jsx("span",{className:"truncate text-gray-600 dark:text-gray-300",children:c.name}),c.isDefault&&t.jsx("span",{className:"shrink-0 text-[9px] text-gray-400",children:"default"}),k&&t.jsx("span",{className:"shrink-0 text-amber-600 dark:text-amber-400",title:j,children:t.jsx(gS,{})})]}),t.jsxs("span",{className:"text-right tabular-nums text-gray-700 dark:text-gray-200",children:[h==null?"—":r.format(h),(d==null?void 0:d.lowSample)&&h!=null&&t.jsx("span",{className:"ml-0.5 align-super text-[9px] text-amber-600 dark:text-amber-400",title:`Thin sample — ${d.sampleSize} item${d.sampleSize===1?"":"s"} behind this figure.`,"aria-label":"thin sample",children:t.jsx(ic,{})})]}),t.jsx("span",{className:"text-right tabular-nums text-gray-400",children:g==null?"—":r.format(g)}),e.prior==null?t.jsx("span",{className:`text-[10px] ${nr}`,title:"Nothing exists for the period before this one on the cadence grid",children:"no prior period"}):g==null||h==null?t.jsx("span",{className:`text-[10px] ${nr}`,title:"One side has no figure for this metric in this workspace, so there is nothing to subtract",children:h==null&&g==null?"—":"no prior figure"}):x===0?t.jsx("span",{className:`text-[10px] ${nr}`,children:"no change"}):t.jsx("span",{className:`text-[10px] ${nr}`,title:k?"Raw change — coverage-biased: one window was only partially tracked (see the amber partial-coverage marker beside the workspace name), so this difference mixes memberships. No significance test is run at workspace grain, so no percentage and no verdict colour.":"Raw change over this workspace's full membership — no significance test is run at workspace grain, so no percentage and no verdict colour",children:cs(x,i)})]},c.workspaceId)})]})}function Yq({report:e,byWorkspace:n}){const[r,s]=f.useState(new Set),a=x=>{s(y=>{const b=new Set(y);return b.has(x)?b.delete(x):b.add(x),b})},i=new Map(e.metrics.map(x=>[x.key,x])),c=new Map(e.comparison.deltas.map(x=>[x.key,x])),d=new Map(e.forecasts.map(x=>[x.key,x])),u=e.comparison.priorPeriodKey!=null,m=lC(e),h=e.comparison.subsetRepoIds.length,g=h>0&&h!==e.coverage.totalRepos;return t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"w-full min-w-[46rem] text-left text-xs",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"border-b border-gray-200 text-[10px] uppercase tracking-wide text-gray-400 dark:border-gray-800",children:[t.jsx("th",{className:"py-1 pr-3 font-medium",children:"Metric"}),t.jsx("th",{className:"py-1 pr-3 text-right font-medium",children:"This period"}),t.jsx("th",{className:"py-1 pr-3 text-right font-medium",children:"Prior"}),t.jsx("th",{className:"py-1 pr-3 font-medium",children:"Change"}),t.jsx("th",{className:"py-1 pr-3 font-medium",children:"Next period"}),t.jsx("th",{className:"py-1 font-medium","aria-label":"Trend"})]})}),t.jsx("tbody",{children:QN.map(x=>{const y=dy[x],b=i.get(x),w=c.get(x),k=d.get(x),{value:j,prior:N,headline:I,lowSample:S}=iC(b,w,g),T=w?iR(w):null,$=w!=null&&w.significant?Uq(T):De.gray,P=n!=null&&r.has(x);return t.jsxs(f.Fragment,{children:[t.jsxs("tr",{className:"border-b border-gray-100 last:border-0 dark:border-gray-900",children:[t.jsxs("td",{className:"py-1.5 pr-3 align-top",children:[t.jsx("div",{className:"font-medium text-gray-700 dark:text-gray-200",children:y.label}),y.note&&t.jsx("div",{className:"text-[10px] text-gray-400",children:y.note}),n!=null&&t.jsxs("button",{type:"button",onClick:()=>a(x),"aria-expanded":P,className:"mt-0.5 text-[10px] text-sky-600 hover:underline dark:text-sky-400",title:"This metric, per workspace, for this period and the prior one",children:[t.jsx(Mt,{dir:P?"down":"right",size:10,className:"mr-1 inline-block align-[-0.1em]"}),"By workspace"]})]}),t.jsxs("td",{className:"py-1.5 pr-3 text-right align-top",children:[t.jsx("span",{className:"text-[13px] font-semibold text-gray-800 dark:text-gray-100",title:b&&!w?`${b.sampleSize} item${b.sampleSize===1?"":"s"} behind this figure`:void 0,children:j==null?"—":y.format(j)}),S&&j!=null&&t.jsx("span",{className:"ml-1 align-super text-[9px] font-normal text-amber-600 dark:text-amber-400",title:b?`Thin sample — ${b.sampleSize} item${b.sampleSize===1?"":"s"} behind this figure. It is what was observed, but it moves easily.`:"Thin sample — this figure rests on very few items and moves easily.","aria-label":"thin sample",children:t.jsx(ic,{})}),I!=null&&t.jsxs("div",{className:"text-[10px] text-gray-400",title:`The comparison covers the ${h} repo${h===1?"":"s"} tracked across both periods. This is the figure for all ${e.coverage.totalRepos}.`,children:["all repos: ",y.format(I)]})]}),t.jsx("td",{className:"py-1.5 pr-3 text-right align-top text-[12px] text-gray-500 dark:text-gray-400",children:N==null?"—":y.format(N)}),t.jsx("td",{className:"py-1.5 pr-3 align-top",children:w?t.jsx(Hq,{delta:w,format:Vp(y),hasPriorPeriod:u}):t.jsx(lR,{hasPriorPeriod:u,notComputed:m})}),t.jsx("td",{className:"py-1.5 pr-3 align-top",children:m?t.jsx("span",{className:`text-[11px] ${nr}`,title:"No forecast was computed for a backfilled period",children:"not forecast"}):t.jsx(zq,{forecast:k,format:y.format})}),t.jsx("td",{className:"py-1.5 align-top",children:t.jsx(Oq,{prior:N,value:j,forecast:k!=null&&k.available?k:null,format:y.format,favourableColor:$})})]}),P&&n!=null&&t.jsx("tr",{className:"border-b border-gray-100 last:border-0 dark:border-gray-900",children:t.jsx("td",{colSpan:6,className:"bg-gray-50/60 py-1.5 pl-4 pr-3 dark:bg-gray-900/30",children:t.jsx(Qq,{axis:n,metricKey:x,meta:y})})})]},x)})})]})})}const Xq="border-gray-300 text-gray-500 dark:border-gray-700 dark:text-gray-400",Zq="border-green-300 text-green-700 dark:border-green-800 dark:text-green-300",Jq="border-red-300 text-red-600 dark:border-red-900 dark:text-red-300";function e9({movements:e,deltas:n}){const r=(e??[]).slice(0,5);if(r.length===0)return null;const s=new Map(n.map(a=>[a.key,a.direction]));return t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[t.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wide text-gray-400",children:"Biggest movers"}),r.map(a=>{const i=Vh(a.key),c=(s.get(a.key)??"neutral")==="neutral";return t.jsxs("span",{className:`rounded border px-1.5 py-0.5 text-[11px] ${c?Xq:a.favourable?Zq:Jq}`,title:c?"This metric has no good direction — it moved, and that is all this says.":a.favourable?"Moved in this metric’s good direction":"Moved against this metric’s good direction",children:[Gh(i)," ",t.jsx(Cr,{dir:a.absoluteChange>0?"up":"down",className:"inline-block align-[-0.1em]"})," ",cs(a.absoluteChange,cy(i)),a.percentChange!=null&&` (${cs(a.percentChange,Ja)})`]},a.key)})]})}function t9({report:e}){const{activityDigest:n}=vt(),[r,s]=f.useState(!0);if(!n)return null;const a=Date.parse(e.periodStart),i=e.inProgress?Date.parse(e.generatedAt):Date.parse(e.periodEnd);return!Number.isFinite(a)||!Number.isFinite(i)?null:t.jsxs("div",{className:"border-t border-gray-200 pt-2 dark:border-gray-800 print:hidden",children:[t.jsxs("button",{type:"button",onClick:()=>s(c=>!c),"aria-expanded":r,className:"flex items-center gap-1.5 text-[11px] font-semibold uppercase tracking-wide text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200",title:"Ask free-form questions grounded in this period's data (Pro, runs your configured report model)",children:[t.jsx(Mt,{dir:r?"down":"right"}),"Ask about this period"]}),r&&t.jsx("div",{className:"mt-2",children:t.jsx(Sq,{periodWindow:{fromMs:a,toMs:i},periodLabel:`${ro(e.periodStart,e.periodEnd,e.grain)}${e.inProgress?" · to date":""}`,suggestedQuestions:n9(e)})})]})}function n9(e){return(e.movements??[]).slice(0,4).map(n=>{const r=Vh(n.key),s=n.absoluteChange>0?"rise":"fall",a=cs(n.absoluteChange,cy(r)),i=n.percentChange!=null?` (${cs(n.percentChange,Ja)})`:"",c=Gh(r);return{label:`Why did ${c} ${s} ${a}${i}?`,question:`Why did ${c} ${s} ${a}${i} over this period? Point to the PRs, repos or people in the data that explain the movement.`}})}function r9({report:e,byWorkspace:n}){const r=e.comparison,s=r.deltas.length===0&&r.refusal==null&&r.priorPeriodKey==null&&e.forecasts.length===0;return t.jsxs("div",{className:"space-y-3",children:[t.jsx("div",{className:`rounded-md border px-2 py-1.5 text-[11px] ${e.coverage.complete?"border-gray-200 text-gray-500 dark:border-gray-800 dark:text-gray-400":"border-amber-300 bg-amber-50/50 text-amber-700 dark:border-amber-800 dark:bg-amber-950/20 dark:text-amber-300"}`,children:e.coverage.complete?t.jsxs(t.Fragment,{children:["All ",e.coverage.totalRepos," repos in this workspace were already being tracked when this period started."]}):t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"font-medium",children:"Partial coverage."})," ",e.coverage.trackedRepos," of ",e.coverage.totalRepos," repos in this workspace were being tracked when this period started. The headline figures below cover the whole workspace as it is today, so they under-count this period relative to a later one — which is why the comparison is computed over the repos present in both."]})}),e.metricsSchemaVersion!==Q0&&t.jsxs("div",{className:"text-[11px] text-gray-400",children:["Written under metric schema v",e.metricsSchemaVersion," (current is v",Q0,") — any metric added since is blank here, not zero."]}),e.lanes&&t.jsx(Vq,{lanes:e.lanes}),t.jsx(e9,{movements:e.movements,deltas:r.deltas}),s&&t.jsxs("div",{className:"rounded-md border border-gray-200 px-2 py-1.5 text-[11px] text-gray-500 dark:border-gray-800 dark:text-gray-400",children:[t.jsx("span",{className:"font-medium",children:"Figures only."})," This period was filled in automatically to give the forecast some history — no comparison, forecast or write-up was computed for it. Generate it to compare it with the period before."]}),!s&&e.forecastDisclosure&&t.jsxs("div",{className:"text-[11px] text-gray-500 dark:text-gray-400",children:["Forecast ",e.forecastDisclosure]}),s?null:r.refusal?t.jsxs("div",{className:"rounded-md border border-gray-200 px-2 py-1.5 text-[11px] text-gray-500 dark:border-gray-800 dark:text-gray-400",children:[t.jsx("span",{className:"font-medium",children:"No comparison."})," ",Qh[r.refusal]]}):r.subsetDisclosure&&t.jsxs("div",{className:"text-[11px] text-gray-500 dark:text-gray-400",children:["Comparison ",r.subsetDisclosure,r.priorPeriodKey&&t.jsxs("span",{className:nr,children:[" · vs ",r.priorPeriodKey]})]}),t.jsx(Yq,{report:e,byWorkspace:n}),e.narrative?t.jsx("div",{className:"rounded-md border border-ai-hairline bg-white/60 p-3 dark:bg-gray-900/40",children:t.jsx(Zp,{markdown:e.narrative,prRefs:[],onOpenPr:()=>{}})}):t.jsx("div",{className:"rounded-md border border-dashed border-gray-200 px-2 py-1.5 text-[11px] text-gray-400 dark:border-gray-800",children:"Figures only — this period has not been written up. Generating a report adds the narrative; the numbers above are already final."}),t.jsx(t9,{report:e})]})}function s9({workspaceId:e,periodKey:n,hasReport:r,stale:s,reportLoading:a,modelInfo:i}){var N,I,S,T,$;const c=f.useMemo(()=>tD(i),[i]),[d,u]=f.useState(null),m=d??(i==null?void 0:i.model)??null,h=((N=c.find(P=>P.id===m))==null?void 0:N.estimate)??null,g=c.length>1,x=eD(e,n),y=Or({mutationKey:aC(e,n)})>0,b=ei(!0),w=((I=b.data)==null?void 0:I.summaryTurnLimit)!=null&&(b.data.summaryTurnsRemaining??0)<=0,k=e==null||n==null||w||y||a,j=x.data;return t.jsxs("div",{className:"space-y-1.5",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[g&&t.jsxs("label",{className:"flex items-center gap-1 text-[11px] text-gray-500 dark:text-gray-400",children:["Model",t.jsx("select",{value:m??"",onChange:P=>u(P.target.value),disabled:y,className:"rounded border border-gray-300 bg-white px-1 py-0.5 text-[11px] dark:border-gray-700 dark:bg-gray-950",children:c.map(P=>t.jsx("option",{value:P.id,children:P.hint?`${P.label} — ${P.hint}`:P.label},P.id))})]}),h&&t.jsxs("span",{className:"text-[11px] text-gray-400",title:`Estimated cost of one generation with ${oC(h.model)}, priced by the server`,children:["≈ ",h.estimatedCredits," credits"]}),t.jsx("button",{type:"button",onClick:()=>x.mutate(d!=null?{model:d}:{}),disabled:k,className:"rounded border border-ai-border px-2 py-0.5 text-[11px] font-medium text-ai-signal hover:border-ai-signal/60 hover:bg-ai-surface-2 disabled:opacity-50",title:w?"Out of AI credits — resets next month":r?"Write this period up again. The stored figures are immutable; regenerating replaces the narrative for this model.":"Compute this period and write it up. The first generation also backfills earlier periods (figures only, no AI, no credits) so the forecast has a series.",children:y?r?"Regenerating…":"Generating…":a?"Loading…":r?s?t.jsxs("span",{className:"inline-flex items-center gap-1",children:[t.jsx(us,{size:11}),"Regenerate"]}):"Regenerate":"Generate"})]}),x.isError&&t.jsx("div",{className:"text-[11px] text-red-500",children:((S=x.error)==null?void 0:S.message)??"Couldn’t generate the report."}),(j==null?void 0:j.cadenceMissing)&&t.jsx("div",{className:"text-[11px] text-amber-600 dark:text-amber-400",children:"No sprint cadence is configured, so there is no period to report on."}),(j==null?void 0:j.creditsExhausted)&&t.jsx("div",{className:"text-[11px] text-amber-600 dark:text-amber-400",children:"Out of AI credits this month — the figures were computed and stored, but the write-up was skipped. Narration resumes on the 1st."}),j!=null&&!x.isError&&!j.creditsExhausted&&!j.cadenceMissing&&t.jsx("div",{className:"text-[11px] text-gray-400",children:j.generated===!1?"Already had this one — served from cache, nothing spent.":j.spend?`Generated with ${j.spend.model} · ${j.spend.credits} credits${((T=b.data)==null?void 0:T.summaryTurnLimit)!=null?" · 1 monthly summary turn":""}.`:`Generated with ${(($=j.report)==null?void 0:$.model)??m??"the default model"}.`})]})}function a9(){return t.jsxs("div",{className:"rounded-lg border border-dashed border-gray-300 p-4 text-xs text-gray-500 dark:border-gray-700 dark:text-gray-400",children:[t.jsx("div",{className:"mb-1 font-medium text-gray-700 dark:text-gray-200",children:"Set a sprint cadence first"}),"Reports are cut on your sprint boundary, so there is nothing to report until one is set. Open the header menu → ",t.jsx("span",{className:"font-medium",children:"Settings"})," and give this workspace a sprint length and a start date — either under"," ",t.jsx("span",{className:"font-medium",children:"Sprint cadence"})," for this workspace alone, or under"," ",t.jsx("span",{className:"font-medium",children:"Sprint (account default)"})," for every workspace that has not set its own.",t.jsx("div",{className:"mt-1.5 text-[11px] text-gray-400",children:"There is deliberately no fallback to a rolling two weeks: a period you did not choose is not an artifact you would forward to anyone."})]})}function y0(){return t.jsxs("div",{className:"space-y-1.5 py-1","aria-hidden":"true",children:[t.jsx("div",{className:"digest-skeleton-line h-3.5",style:{width:"42%"}}),["96%","90%","84%","90%","76%"].map((e,n)=>t.jsx("div",{className:"digest-skeleton-line h-3",style:{width:e}},n))]})}function o9(){var T,$,P,C,L,F,M,D;const{periodReports:e}=vt(),n=uc(e),r=G(A=>A.workspaceId),s=G(A=>A.insightsReportGrain),a=G(A=>A.setInsightsReportGrain),i=Fd(e,r,s),c=f.useMemo(()=>{var A;return((A=i.data)==null?void 0:A.periods)??[]},[i.data]),d=f.useMemo(()=>{var A;return((A=i.data)==null?void 0:A.archived)??[]},[i.data]),u=G(A=>A.insightsReportKey),m=G(A=>A.setInsightsReportKey);f.useEffect(()=>{if(i.data==null)return;if(c.length===0){u!=null&&m(null);return}const A=c.some(W=>W.periodKey===u)||d.some(W=>W.archivedKey===u);(u==null||!A)&&m(c[0].periodKey)},[i.data,c,d,u,m]);const h=c.find(A=>A.periodKey===u)??null,g=(h==null?void 0:h.inProgress)===!0,x=JO(e&&!g,r,u),y=ZO(e&&g,r),b=g?y:x,w=f.useMemo(()=>{var W;const A=(W=b.data)==null?void 0:W.report;try{return A?uD(A,Q0):""}catch(z){return console.error("period report markdown failed",z),""}},[b.data]);if(n==="pending")return t.jsx(y0,{});if(n==="locked")return t.jsx(dc,{heading:"Period reports",testId:"period-reports-locked",children:"A stored report for each completed period: what moved since the one before it, which of those movements the history can actually stand behind, and a forecast that refuses rather than guessing when the data is too thin."});if(((T=i.data)==null?void 0:T.enabled)===!1)return null;const k=i.isLoading||i.isPlaceholderData,j=b.isLoading||b.isPlaceholderData||u==null,N=d.find(A=>A.archivedKey===u)??null,I=h??N,S=(($=b.data)==null?void 0:$.report)??null;return t.jsxs("div",{className:"space-y-3","data-testid":"period-reports","data-print-report":!0,children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 print:hidden",children:[t.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wide text-gray-400",children:"Grain"}),[["sprint","Sprint","Periods of the length this workspace runs its sprints at"],["month","Month","Real calendar months, aligned to the 1st (UTC). Needs no cadence setting — and month-to-date is live"]].map(([A,W,z])=>t.jsx("button",{type:"button",onClick:()=>a(A),"aria-pressed":s===A,title:z,className:`rounded border px-1.5 py-0.5 text-[11px] ${s===A?"border-ai-signal/50 bg-ai-signal/10 text-ai-signal":"border-gray-300 text-gray-500 hover:border-gray-400 dark:border-gray-700 dark:text-gray-400"}`,children:W},A))]}),r==null||k?t.jsx(y0,{}):((P=i.data)==null?void 0:P.cadenceConfigured)===!1?t.jsx(a9,{}):c.length===0?t.jsx("div",{className:"rounded-lg border border-dashed border-gray-300 p-4 text-xs text-gray-500 dark:border-gray-700 dark:text-gray-400",children:s==="month"?"No months yet. A report covers one completed calendar month — the first one appears once a month has ended with activity behind it.":"No periods yet. A report covers one completed sprint — the first one appears once a sprint boundary has passed with activity behind it."}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 print:hidden",children:[t.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wide text-gray-400",children:"Period"}),c.slice(0,8).map(A=>{const W=A.periodKey===u;return t.jsxs("button",{type:"button",onClick:()=>m(A.periodKey),"aria-pressed":W,className:`inline-flex h-[22px] items-center gap-1 rounded border px-1.5 text-[11px] leading-none ${W?"border-ai-signal/50 bg-ai-signal/10 text-ai-signal":"border-gray-300 text-gray-500 hover:border-gray-400 dark:border-gray-700 dark:text-gray-400"}`,title:A.hasNarrative?`${A.periodKey} · written up${A.model?` with ${A.model}`:""}`:`${A.periodKey} · figures only, not written up`,children:[t.jsx("span",{className:"truncate",children:aj(A)}),!A.coverageComplete&&t.jsx("span",{className:"flex shrink-0 items-center text-amber-600 dark:text-amber-400",title:"Partial repo coverage",children:t.jsx(gS,{})})]},A.periodKey)}),c.length>8&&t.jsxs("select",{value:c.slice(0,8).some(A=>A.periodKey===u)?"":u??"",onChange:A=>A.target.value&&m(A.target.value),className:"h-[22px] rounded border border-gray-300 bg-white px-1 text-[11px] leading-none dark:border-gray-700 dark:bg-gray-950",children:[t.jsx("option",{value:"",children:"Earlier…"}),c.slice(8).map(A=>t.jsx("option",{value:A.periodKey,children:aj(A)},A.periodKey))]})]}),I&&t.jsxs("div",{className:"flex flex-wrap items-baseline gap-2",children:[t.jsx("h3",{className:"text-sm font-semibold text-gray-800 dark:text-gray-100",children:ro(I.periodStart,I.periodEnd,I.grain??(S==null?void 0:S.grain)??"sprint")}),t.jsxs("span",{className:"text-[11px] text-gray-400",title:(I.grain??(S==null?void 0:S.grain)??"sprint")==="month"?"A real calendar month, aligned to the 1st (UTC). Months are 28–31 days long, so their lengths are not comparable — which is why no forecast is offered at this grain.":((C=i.data)==null?void 0:C.cadenceSource)==="workspace"?"This workspace runs its own sprint length":"This workspace follows the account-default sprint length",children:[Dq(I.grain??(S==null?void 0:S.grain)??"sprint",I.cadenceDays),(I.grain??(S==null?void 0:S.grain)??"sprint")==="sprint"&&((L=i.data)==null?void 0:L.cadenceSource)==="workspace"&&!(S!=null&&S.archived)&&t.jsx("span",{className:"ml-1",children:"· this workspace"})]}),S&&!S.inProgress&&t.jsxs("span",{className:"text-[10px] text-gray-400",title:S.periodKey,children:[S.model?`${S.model} · `:"","generated ",new Date(S.generatedAt).toLocaleString()]}),(S==null?void 0:S.inProgress)&&t.jsxs("span",{className:"rounded bg-ai-signal/10 px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-ai-signal",title:"This month is still running. The figures are recomputed live on every read — nothing is stored, nothing is written up, and there is nothing to regenerate. The comparison is against the SAME stretch of the previous month, not against the whole of it.",children:["in progress · ",S.elapsedDays??0," day",S.elapsedDays===1?"":"s"," so far"]}),(S==null?void 0:S.archived)&&t.jsxs("span",{className:"rounded bg-gray-500/10 px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-gray-600 dark:text-gray-300",title:"Generated under a sprint cadence this workspace no longer runs. It is kept exactly as it was written and cannot be regenerated — its window is not on the current period grid.",children:["archived · ",S.cadenceDays,"-day cadence"]}),(S==null?void 0:S.stale)&&t.jsx("span",{className:"rounded bg-amber-500/10 px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-amber-700 dark:text-amber-300",title:"The underlying data changed after this report was written. It is kept exactly as generated — a copy someone has already forwarded has to stay comparable — so regenerate if you want the newer figures.",children:"stale"}),t.jsx(Bi,{text:w,what:"report as Markdown",className:"print:hidden"})]}),(S==null?void 0:S.archived)!==!0&&!g&&(S==null?void 0:S.inProgress)!==!0&&t.jsx("div",{className:"print:hidden",children:t.jsx(s9,{workspaceId:r,periodKey:u,hasReport:S!=null,stale:(S==null?void 0:S.stale)===!0,reportLoading:j,modelInfo:(F=i.data)==null?void 0:F.modelInfo})}),j?t.jsx(y0,{}):b.isError?t.jsx("div",{className:"text-[11px] text-red-500",children:((M=b.error)==null?void 0:M.message)??"Couldn’t load this report."}):S?t.jsx("div",{children:t.jsx(r9,{report:S,byWorkspace:((D=b.data)==null?void 0:D.byWorkspace)??null})},S.periodKey):t.jsx("div",{className:"rounded-lg border border-dashed border-gray-300 p-4 text-xs text-gray-500 dark:border-gray-700 dark:text-gray-400",children:g?"Month-to-date figures could not be read just now. This view is computed live — nothing is stored for an open month — so retrying is the whole recovery.":s==="month"?"This month has not been generated yet. Use Generate above — the first run also backfills earlier months with figures only.":"This period has not been generated yet. Use Generate above — the first run also backfills earlier periods with figures only, so the forecast has something to fit."}),t.jsx(Fq,{}),d.length>0&&t.jsxs("details",{className:"print:hidden",children:[t.jsxs("summary",{className:"cursor-pointer text-[11px] text-gray-400 hover:text-gray-600 dark:hover:text-gray-300",children:["Earlier cadences (",d.length,")"]}),t.jsxs("div",{className:"mt-1.5 space-y-1 border-l border-gray-200 pl-2 dark:border-gray-800",children:[t.jsx("p",{className:"text-[10px] text-gray-400",children:"Generated under a sprint length this workspace no longer runs, or older than the grid reaches. Kept exactly as written — they cannot be regenerated, because their windows are not on the current grid."}),d.map(A=>t.jsxs("button",{type:"button",onClick:()=>m(A.archivedKey),"aria-pressed":A.archivedKey===u,className:`block text-left text-[11px] hover:underline ${A.archivedKey===u?"text-ai-signal":"text-gray-500 dark:text-gray-400"}`,title:A.reason==="cadence_changed"?`Measured over a ${A.cadenceDays}-day sprint, which this workspace no longer runs`:"Older than the period grid reaches back",children:[ro(A.periodStart,A.periodEnd,A.grain??"sprint"),t.jsxs("span",{className:"ml-1.5 text-gray-400",children:[A.cadenceDays,"-day",A.hasNarrative?" · written up":" · figures only"]})]},A.archivedKey))]})]})]})]})}function oj(e){const n=new Date(e);return new Date(Date.UTC(n.getUTCFullYear(),n.getUTCMonth()+1,1)).toLocaleDateString(void 0,{month:"short",day:"numeric"})}function ij({label:e,hint:n,used:r,limit:s,remaining:a,unit:i,resetOn:c,format:d}){const u=s!=null,m=u&&(a??0)<=0,h=u&&s>0?Math.min(100,Math.round(r/s*100)):0;return t.jsxs("div",{className:"py-1.5",children:[t.jsxs("div",{className:"flex items-baseline justify-between gap-3",children:[t.jsxs("div",{children:[t.jsx("div",{className:"text-[12px] font-medium text-gray-700 dark:text-gray-200",children:e}),t.jsx("div",{className:"text-[10px] text-gray-400",children:n})]}),t.jsx("div",{className:"whitespace-nowrap text-sm font-semibold tabular-nums text-gray-800 dark:text-gray-100",children:d?d(r):t.jsxs(t.Fragment,{children:[r.toLocaleString(),u&&t.jsxs("span",{className:"text-gray-400",children:[" / ",s.toLocaleString()]})," ",t.jsx("span",{className:"text-[10px] font-normal text-gray-400",children:i})]})})]}),u&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"mt-1 h-1.5 w-full overflow-hidden rounded-full bg-gray-200 dark:bg-gray-700",children:t.jsx("div",{className:`h-full rounded-full ${m?"bg-amber-500":"bg-ai-signal-fill"}`,style:{width:`${h}%`}})}),t.jsx("div",{className:`mt-1 text-[10px] tabular-nums ${m?"font-medium text-amber-600 dark:text-amber-400":"text-gray-400"}`,children:m?`None left — resets ${c}.`:`${(a??0).toLocaleString()} ${i} left · resets ${c}`})]})]})}function i9(){const{data:e,isLoading:n,isError:r}=ei(!0),s=Dr().enabled,a=e?new Date(e.monthStart).toLocaleDateString(void 0,{month:"long"}):"";return t.jsxs("div",{className:"rounded-lg border border-gray-200 bg-white p-3 dark:border-gray-800 dark:bg-gray-900/40",children:[t.jsxs("div",{className:"mb-1 flex items-baseline gap-2",children:[t.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-gray-500 dark:text-gray-300",children:"AI usage"}),t.jsx("span",{className:"text-[11px] text-gray-400",children:a?`${a} to date`:"month to date"})]}),n?t.jsx("div",{className:"h-20 animate-pulse rounded bg-gray-100 dark:bg-gray-900/40"}):r||!e?t.jsx("div",{className:"text-[11px] text-gray-400",children:"Usage isn’t available."}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"divide-y divide-gray-100 dark:divide-gray-800/60",children:[t.jsx(ij,{label:"Summaries",hint:"digests · sprint · chat · analyses",used:e.summaryTurnsUsed,limit:e.summaryTurnLimit,remaining:e.summaryTurnsRemaining,unit:"summaries",resetOn:oj(e.monthStart)}),s&&t.jsx(ij,{label:"Claude Review and AI Fix",hint:"on your own Claude Code or Anthropic API key",used:e.agentCreditsUsed,limit:null,remaining:null,unit:"",resetOn:oj(e.monthStart),format:i=>p_(i/R$)})]}),t.jsxs("div",{className:"mt-1.5 text-[11px] text-gray-500 dark:text-gray-400",children:["Summaries are counted per month and reset on the 1st.",s&&" Limn charges nothing for Claude Review or AI Fix."]})]})]})}function lj(e){return e.reduce((n,r)=>n+r,0)}function cj(e){return e.valueMode==="segments"?e.segments.length:1}const Uu="pb-1 text-[11px] font-semibold text-gray-500 dark:text-gray-400",Hu="py-[3px] text-[11px]";function cR({labels:e,columns:n,nameHeader:r="Repository",nameWidthPct:s=30,noteFor:a}){const i=n.map(d=>d.values.reduce((u,m)=>m==null?u:Math.max(u,lj(m)),0)),c=n.flatMap(d=>d.segments.map(u=>({label:u.label,color:u.color})));return t.jsxs("div",{children:[t.jsxs("table",{className:"w-full table-fixed border-collapse",children:[t.jsxs("colgroup",{children:[t.jsx("col",{style:{width:`${s}%`}}),n.map(d=>t.jsxs(f.Fragment,{children:[t.jsx("col",{style:{width:`${d.barWidthPct}%`}}),Array.from({length:cj(d)},(u,m)=>t.jsx("col",{style:{width:`${d.valueWidthPct}%`}},m))]},d.key))]}),t.jsx("thead",{children:t.jsxs("tr",{children:[t.jsx("th",{scope:"col",className:`${Uu} pr-2 text-left`,children:r}),n.map(d=>d.valueMode==="total"?t.jsx("th",{scope:"col",colSpan:2,className:`${Uu} pr-2 text-left`,children:d.header},d.key):t.jsxs(f.Fragment,{children:[t.jsx("th",{scope:"col",className:`${Uu} pr-2 text-left`,children:d.header}),d.segments.map(u=>t.jsx("th",{scope:"col",className:`${Uu} pr-2 text-right`,children:u.label},u.key))]},d.key))]})}),t.jsx("tbody",{children:e.map((d,u)=>{const m=(a==null?void 0:a(u))??null;return t.jsxs("tr",{children:[t.jsxs("th",{scope:"row",className:`${Hu} pr-2 text-left align-middle font-normal`,children:[t.jsx("span",{className:"break-words text-gray-700 dark:text-gray-200",children:d}),m!=null&&t.jsx("span",{className:"block text-gray-500 dark:text-gray-400",children:m})]}),n.map((h,g)=>{const x=h.values[u]??null,y=i[g]??0,b=[t.jsx("td",{className:`${Hu} pr-2 align-middle`,children:x==null?t.jsx("span",{className:"text-gray-500 dark:text-gray-400",children:h.unknownLabel}):t.jsx("span",{"aria-hidden":"true",className:"flex h-2 w-full overflow-hidden rounded-[2px] bg-gray-100 dark:bg-gray-800",children:h.segments.map((w,k)=>{const j=x[k]??0;return j<=0||y<=0?null:t.jsx("span",{style:{width:`${j/y*100}%`,minWidth:"1px",background:w.color}},w.key)})})},`${h.key}-bar`)];if(h.valueMode==="total")b.push(t.jsxs("td",{className:`${Hu} pr-2 text-right align-middle tabular-nums text-gray-700 dark:text-gray-200`,children:[x==null?null:h.format(lj(x)),x!=null&&h.segments.length>1&&t.jsx("span",{className:"sr-only",children:` (${h.segments.map((w,k)=>`${h.format(x[k]??0)} ${w.label}`).join(", ")})`})]},`${h.key}-total`));else for(const[w,k]of h.segments.entries())b.push(t.jsx("td",{className:`${Hu} pr-2 text-right align-middle tabular-nums text-gray-700 dark:text-gray-200`,children:x==null?null:h.format(x[w]??0)},`${h.key}-${k.key}`));return t.jsx(f.Fragment,{children:b},h.key)})]},d)})}),t.jsx("tfoot",{children:t.jsxs("tr",{children:[t.jsx("td",{}),n.map((d,u)=>t.jsxs(f.Fragment,{children:[t.jsx("td",{className:"border-t border-gray-200 pr-2 pt-1 dark:border-gray-800",children:t.jsxs("span",{className:"flex items-baseline justify-between text-[11px] text-gray-500 dark:text-gray-400",children:[t.jsx("span",{children:"0"}),t.jsx("span",{className:"tabular-nums",children:d.format(i[u]??0)})]})}),Array.from({length:cj(d)},(m,h)=>t.jsx("td",{},h))]},d.key))]})})]}),t.jsx(Ld,{series:c})]})}const l9="#0072B2",c9="#CC79A7",d9="#D55E00";function Cs(e,n,r){return e===1?n:r}function Ka(e){return e.toLocaleString()}function dj(e){return e>0?" shown here":""}function u9({reach:e,neighbourWindowDays:n}){const r=e.repos.length,s=e.omitted.repos>0?`top ${r} of ${e.repoCount} repositories`:`${r} ${Cs(r,"repository","repositories")}`,a=[{key:"reach",header:"Open pull requests",segments:[{key:"low",label:"Low",color:l9},{key:"medium",label:"Medium",color:c9},{key:"high",label:"High",color:d9}],values:e.repos.map(i=>i.read===0?null:[i.low,i.medium,i.high]),unknownLabel:"no reading",format:Sn,valueMode:"segments",barWidthPct:24,valueWidthPct:14}];return t.jsxs(jt,{title:"Reach by repository",note:`open now · ${s}`,className:"h-full",testId:"workspace-reach",children:[t.jsx(cR,{labels:e.repos.map(i=>i.repoFullName),columns:a,nameWidthPct:34,noteFor:i=>{const c=e.repos[i];return c!=null&&c.unread>0?`${Sn(c.unread)} with no reading`:null}}),t.jsxs("div",{className:"mt-2 space-y-1 text-[12px] text-gray-500 dark:text-gray-400",children:[t.jsxs("p",{children:["Every pull request open right now, by how far it could reach — a snapshot, not a window.",n!=null&&t.jsxs(t.Fragment,{children:[" Activity by repository covers the last ",n," days."]})]}),e.unread>0&&t.jsxs("p",{children:[Ka(e.unread)," of the ",Ka(e.openPrs)," open"," ",Cs(e.openPrs,"pull request","pull requests"),dj(e.omitted.repos)," ",Cs(e.unread,"has","have")," no reading and"," ",Cs(e.unread,"is","are")," not drawn."]}),e.drafts>0&&t.jsxs("p",{children:[Ka(e.drafts)," of the ",Ka(e.openPrs)," open"," ",Cs(e.openPrs,"pull request","pull requests"),dj(e.omitted.repos)," ",Cs(e.drafts,"is a draft","are drafts"),"."]}),e.omitted.repos>0&&t.jsxs("p",{children:[Ka(e.omitted.repos)," more"," ",Cs(e.omitted.repos,"repository","repositories")," ",Cs(e.omitted.repos,"holds","hold")," ",Ka(e.omitted.openPrs)," open"," ",Cs(e.omitted.openPrs,"pull request","pull requests"),","," ",e.omitted.high===0?"none":Ka(e.omitted.high)," of them high reach, and"," ",Cs(e.omitted.repos,"is","are")," not shown."]}),e.workspaceRepos>e.repoCount&&t.jsxs("p",{children:[Ka(e.workspaceRepos-e.repoCount)," of the ",Ka(e.workspaceRepos)," ",Cs(e.workspaceRepos,"repository","repositories")," in this workspace"," ",Cs(e.workspaceRepos-e.repoCount,"has","have")," nothing open right now."]})]})]})}const h9=De.blue,p9=De.orange,m9=De.teal;function Mo(e,n,r){return e===1?n:r}function g9({activity:e}){const n=TL(),r=e.repos,s=e.workspaceRepos>1&&r.length>0;if(!s&&n==null)return null;const a=r.map(h=>h.repoFullName),i=[{key:"prs",header:"PRs opened",segments:[{key:"human",label:"People",color:h9},{key:"automation",label:"Automation",color:p9}],values:r.map(h=>[h.prsOpenedHuman,h.prsOpenedAutomation]),unknownLabel:"not counted",format:Sn,valueMode:"total",barWidthPct:20,valueWidthPct:10},{key:"lines",header:"Lines changed",segments:[{key:"lines",label:"Lines changed",color:m9}],values:r.map(h=>h.linesChanged==null?null:[h.linesChanged]),unknownLabel:"size unknown",format:Sn,valueMode:"total",barWidthPct:20,valueWidthPct:12}],c=r.length,d=e.omitted.repos>0?`top ${c} of ${e.activeRepos} repositories`:`${c} ${Mo(c,"repository","repositories")}`,u=r.reduce((h,g)=>h+g.unsizedPrs,0),m=r.filter(h=>h.addedDuringWindow);return t.jsxs("div",{className:"space-y-2","data-testid":"repo-activity-charts",children:[t.jsx("h4",{className:"pt-1 text-[11px] font-semibold uppercase tracking-wide text-gray-500 dark:text-gray-400",children:"Where the work is happening"}),t.jsxs("div",{className:"grid grid-cols-1 items-stretch gap-3 lg:grid-cols-2",children:[s&&t.jsxs(jt,{title:"Activity by repository",note:`${e.windowDays} days · ${d}`,className:"h-full",children:[t.jsx(cR,{labels:a,columns:i,nameWidthPct:38,noteFor:h=>{const g=r[h];return g==null||g.unsizedPrs===0||g.linesChanged==null?null:`lines cover ${Sn(g.sizedPrs)} of ${Sn(g.sizedPrs+g.unsizedPrs)} PRs`}}),t.jsx("p",{className:"mt-1 text-[12px] text-gray-500 dark:text-gray-400",children:"Each column has its own scale, so a bar compares repositories within its column and never across the two."}),t.jsxs("div",{className:"mt-2 space-y-1 text-[12px] text-gray-500 dark:text-gray-400",children:[t.jsxs("p",{children:["Pull requests opened in the last ",e.windowDays," days, by repository — the same window as the tiles above, with no prior-period comparison."]}),e.omitted.repos>0&&t.jsxs("p",{children:[e.omitted.repos," more"," ",Mo(e.omitted.repos,"repository","repositories")," saw"," ",Sn(e.omitted.prsOpened)," ",Mo(e.omitted.prsOpened,"pull request","pull requests"),e.omitted.linesChanged!=null&&t.jsxs(t.Fragment,{children:[" and ",Sn(e.omitted.linesChanged)," lines changed"]})," ","in this window and are not shown."]}),e.workspaceRepos>e.activeRepos&&t.jsxs("p",{children:[e.workspaceRepos-e.activeRepos," of the ",e.workspaceRepos," ",Mo(e.workspaceRepos,"repository","repositories")," in this workspace saw no pull request opened in this window."]}),u>0&&t.jsxs("p",{children:[Sn(u)," ",Mo(u,"pull request has","pull requests have")," no recorded size and ",Mo(u,"is","are")," counted in PRs opened but not in lines changed."]}),m.length>0&&t.jsxs("p",{children:[m.map(h=>h.repoFullName).join(", ")," ",Mo(m.length,"was","were")," added to this workspace during the window, so ",Mo(m.length,"its bars cover","their bars cover")," less than"," ",e.windowDays," days."]})]})]}),n!=null&&t.jsx(u9,{reach:n,neighbourWindowDays:s?e.windowDays:null})]})]})}function f9(){const e=G(a=>a.workspaceId),n=G(a=>a.openMetricsDetail),r=G(a=>a.openOpenPrsDetail),{data:s}=GC(e);return s!=null&&s.metrics?t.jsxs("div",{className:"space-y-3","data-testid":"workspace-flow-metrics",children:[t.jsx(DC,{metrics:s.metrics,onOpenMetric:n,onOpenOpenPrs:()=>r()}),s.repoActivity&&t.jsx(g9,{activity:s.repoActivity})]}):null}function x9(){const{periodReports:e}=vt(),n=uc(e);return n==="pending"?null:n==="locked"?t.jsx(dc,{heading:"Chronology",testId:"chronology-locked",children:"Every hour a pull request is open, someone is holding it — a reviewer who hasn’t looked, an author who owes a reply, or nobody, approved and waiting to land. Chronology splits that time into the three courts and names the one that is both lopsided and slow."}):t.jsx(rq,{})}function y9(){const[e,n]=f.useState(!1),{activityDigest:r,periodReports:s}=vt(),a=G(h=>h.workspaceId),i=G(h=>h.insightsInnerTab),c=G(h=>h.setInsightsInnerTab),d=SW(i),u=GC(a),m=!s&&u.data!=null&&u.data.metrics==null;return t.jsxs("div",{className:"space-y-4","data-testid":"insights-view",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("h2",{className:"text-sm font-semibold text-gray-700 dark:text-gray-200",children:"Reports"}),t.jsx("div",{className:"ml-auto flex items-center gap-1.5",children:r&&t.jsxs("button",{type:"button",onClick:()=>n(h=>!h),"aria-expanded":e,className:`inline-flex items-center gap-1 rounded border px-1.5 py-0.5 text-[11px] font-medium ${e?"border-ai-signal/50 bg-ai-signal/10 text-ai-signal":"border-gray-300 hover:border-gray-400 dark:border-gray-700 dark:hover:border-gray-500"}`,title:"Show your month-to-date AI usage (in credits)",children:[t.jsx(Mt,{dir:e?"down":"right",size:10}),"Track usage"]})})]}),e&&r&&t.jsx(i9,{}),t.jsx("div",{role:"tablist",className:"flex gap-1 border-b border-gray-200 dark:border-gray-800",children:[{key:"overview",label:"Overview",proTitle:null},{key:"bottlenecks",label:"Chronology",proTitle:"Chronology is part of Pro."}].map(h=>{const g=d===h.key;return t.jsxs("button",{type:"button",role:"tab","aria-selected":g,onClick:()=>c(h.key),className:`-mb-px flex items-center gap-1 rounded-t-md border border-b-0 px-3 py-1.5 text-xs font-medium ${g?"border-gray-300 bg-white text-sky-600 dark:border-gray-700 dark:bg-gray-950 dark:text-sky-300":"border-transparent text-gray-500 hover:bg-gray-100 dark:text-gray-400 dark:hover:bg-gray-900/60"}`,children:[h.label,h.proTitle!=null&&t.jsx(ec,{variant:"tab",className:"shrink-0",title:h.proTitle})]},h.key)})}),d==="bottlenecks"?t.jsx(x9,{}):t.jsxs(t.Fragment,{children:[m?t.jsxs("div",{className:"rounded-lg border border-dashed border-gray-300 p-6 text-center text-sm text-gray-400 dark:border-gray-700",children:["Nothing to measure in this Workspace yet.",t.jsx("div",{className:"mt-1 text-[11px]",children:"Flow metrics appear once this workspace has merged pull requests to measure."})]}):t.jsxs("section",{className:"space-y-2",children:[t.jsx("h3",{className:"text-[11px] font-semibold uppercase tracking-wide text-gray-400",children:"Flow metrics"}),t.jsx(f9,{})]}),t.jsxs("section",{className:"space-y-2",children:[t.jsxs("h3",{className:"flex items-center gap-1.5 text-[11px] font-semibold uppercase tracking-wide text-gray-400",children:["Period reports",t.jsx(ec,{variant:"heading",title:"Period reports are part of Pro."})]}),t.jsx(o9,{})]})]})]})}function b9(){const e=vt();return e.workspaceInsights||e.slackDigest||e.issueLinks||e.botTriage}function v9(){const e=vt();return e.workspaceInsights||e.slackDigest||e.issueLinks}function dR(e){return Oe({queryKey:["pro-settings"],queryFn:he.proSettings,enabled:e,staleTime:6e4})}function k9(e){return e.costMonthlyUsd==null?"none":"set"}const w9=2147483647e-2;function j9(e){const n=e.trim();if(n==="")return{ok:!0,value:null};const r=Number(n);return Number.isFinite(r)?r<0?{ok:!1,error:"A monthly cost can’t be negative."}:r>w9?{ok:!1,error:"That’s larger than the maximum storable price."}:{ok:!0,value:Math.round(r*100)/100}:{ok:!1,error:"Enter a number, or clear the box for no price."}}function Hl(e){return e==null?"":Number.isInteger(e)?String(e):e.toFixed(2)}function N9(e,n,r="flat",s="flat"){return n==null?e==null?{kind:"no-cost",dirty:!1}:{kind:"clear",dirty:!0}:e===n&&r===s?{kind:"unchanged",dirty:!1}:{kind:"set",dirty:!0}}function b0(e,n,r){return n==null?{workspaceId:e,monthlyUsd:null}:r==null?{workspaceId:e,monthlyUsd:n}:{workspaceId:e,monthlyUsd:n,costModel:r}}function S9(e,n){return Math.round(e*n*100)/100}function C9(e,n){return e.costMonthlyUsd!=null?{costMonthlyUsd:e.costMonthlyUsd,costPerActedOnUsd:e.costPerActedOnUsd,legacyOnlyUsd:null}:{costMonthlyUsd:null,costPerActedOnUsd:null,legacyOnlyUsd:e.login!=null?n.get(e.login)??null:null}}function R9(e){return new Map((e??[]).map(n=>[n.key,n]))}function uj(e){return e==null?"—":e===0?"0":e>0&&e<.05?"<0.1":e.toFixed(1)}function I9(e,n){return e==null?n==="low_expectation"?"too quiet":"no baseline":`${e.toFixed(1)}×`}const T9=3;function $9(e){return e==null?"—":e.toLocaleString()}function _9(e,n){switch(e){case"bucket":return`vs PRs this size in this repo (${n.toLocaleString()} merged)`;case"repo":return`vs this repo's overall average across ${n.toLocaleString()} merged PRs — NOT matched on size, because too few comparable PRs merged in this window`;case"low_expectation":return`Too quiet to compare: PRs this size in this repo average under ${T9} bot comments (${n.toLocaleString()} merged). A multiplier off an expectation that small reports chance, not a finding.`;case"none":return"No baseline: this PR’s size was never observed, or the repo has too few merged PRs in this window."}}function P9(e){return e.expected==null?null:`expected ${e.expected.toFixed(1)} over ${e.baselinePrs.toLocaleString()} PRs`}function E9(e){return e==null?"text-gray-400":e>=3?"text-red-600 dark:text-red-400":e>=1.5?"text-amber-600 dark:text-amber-400":"text-gray-500 dark:text-gray-400"}const v0=[{key:"comments",label:"Most comments",help:"The raw number of bot comments on the PR. Mostly ranks by size — big PRs draw more comments."},{key:"ratio",label:"Most vs expected",help:"How far above this repo’s usual for a PR of this size. Surfaces the small PR a bot tore apart, which the raw count buries."}],A9=20;function M9(e,n,r=!0,s){const{botDepth:a}=vt();return Oe({queryKey:["bot-volume",n,dt(e),Vr(s)],queryFn:e==null?Ct:()=>he.botVolume(n,e,s),enabled:r&&a,staleTime:6e4,gcTime:fn,placeholderData:i=>i})}function L9(e,n,r=!0,s){const{botDepth:a}=vt();return Oe({queryKey:["bot-volume-scatter",n,dt(e),Vr(s)],queryFn:e==null?Ct:()=>he.botVolumeScatter(n,e,s),enabled:r&&a,staleTime:6e4,gcTime:fn,placeholderData:i=>i})}function F9(e){var b;const{workspaceId:n,repoIds:r,window:s,sort:a,authorUserIds:i,enabled:c}=e,{botDepth:d}=vt(),u=He(),m=f.useMemo(()=>["bot-volume-prs",s,dt(n),Vr(r),a,i?`bots:[${[...i].sort((w,k)=>w-k).join(",")}]`:"bots:-"],[s,n,r,a,i]);f.useState(()=>{u.setQueryData(m,w=>w&&w.pages.length>1?{pages:w.pages.slice(0,1),pageParams:w.pageParams.slice(0,1)}:w)});const h=rc({queryKey:m,initialPageParam:null,queryFn:n==null?Ct:({pageParam:w})=>he.botVolumePrs({window:s,workspaceId:n,repoIds:r,authorUserIds:i,sort:a,limit:A9,cursor:w}),getNextPageParam:w=>w.nextCursor??void 0,enabled:c&&d,staleTime:6e4,gcTime:fn,refetchOnMount:!0,placeholderData:w=>w}),g=(b=h.data)==null?void 0:b.pages,x=g==null?void 0:g[0];return{items:f.useMemo(()=>(g??[]).flatMap(w=>w.items),[g]),total:x==null?void 0:x.total,filteredTotal:x==null?void 0:x.filteredTotal,truncated:(x==null?void 0:x.truncated)??!1,isLoading:h.isLoading||h.isPlaceholderData,hasMore:h.hasNextPage,fetchMore:()=>void h.fetchNextPage(),isFetchingMore:h.isFetchingNextPage}}const Vf=De.amber,Qf=De.violet,hj=e=>new Date(e.weekStartMs).toISOString();function O9(e){var c;const n=new Set;for(const d of e)for(const u of((c=d.mlInflation)==null?void 0:c.weekly)??[])n.add(hj(u));const r=Array.from(n).sort().slice(-12),s=[],a=[],i=[];for(const d of e){const u=d.mlInflation;if(u==null)continue;if(u.badged===0){a.push(d.label);continue}const m=u.weekly;if(m==null||m.length===0){i.push(d.label);continue}const h=new Map(m.map(g=>[hj(g),g]));s.push({key:d.key,label:d.label,over:r.map(g=>{var x;return((x=h.get(g))==null?void 0:x.overCall)??null}),under:r.map(g=>{var x;return((x=h.get(g))==null?void 0:x.underCall)??null}),overTotal:m.reduce((g,x)=>g+x.overCall,0),underTotal:m.reduce((g,x)=>g+x.underCall,0)})}return s.sort((d,u)=>u.overTotal+u.underTotal-(d.overTotal+d.underTotal)||d.label.localeCompare(u.label)),{labels:r,panels:s,unbadged:a,quiet:i}}function D9(){return t.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-0.5 text-[10px]",children:[t.jsxs("span",{className:"flex items-center gap-1",style:{color:Vf},children:[t.jsx(_s,{dir:"up",size:10}),"Bot graded it worse (inflation)"]}),t.jsxs("span",{className:"flex items-center gap-1",style:{color:Qf},children:[t.jsx(_s,{dir:"down",size:10}),"We graded it worse"]})]})}function B9({panel:e,labels:n,color:r}){const s=[{key:"over",label:"Bot worse",color:Vf,values:e.over},{key:"under",label:"We worse",color:Qf,values:e.under}];return t.jsxs("div",{children:[t.jsxs("div",{className:"mb-0.5 flex items-baseline justify-between gap-2",children:[t.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 text-[11px] font-medium text-gray-700 dark:text-gray-200",children:[t.jsx("span",{className:"inline-block h-2 w-2 shrink-0 rounded-full",style:{background:r}}),t.jsx("span",{className:"truncate",children:e.label})]}),t.jsxs("span",{className:"shrink-0 tabular-nums text-[10px] text-gray-400",children:[t.jsx("span",{style:{color:Vf},children:e.overTotal})," · ",t.jsx("span",{style:{color:Qf},children:e.underTotal})]})]}),t.jsx(Gn,{labels:n,series:s,height:110,curved:!0,hideLegend:!0,centerTip:!0})]})}function W9({vendors:e,botColor:n,windowLabel:r}){const{labels:s,panels:a,unbadged:i,quiet:c}=f.useMemo(()=>O9(e),[e]),d=f.useMemo(()=>{const u=new Map(e.map(m=>[m.key,n({login:m.login,kind:m.kind})]));return m=>u.get(m)??De.slate},[e,n]);return a.length===0&&i.length===0&&c.length===0?null:t.jsxs(jt,{title:"Severity inflation",note:"weekly counts · last 12 weeks",className:"lg:col-span-3",children:[t.jsx(D9,{}),t.jsxs("div",{className:"mt-1 text-[10px] leading-snug text-gray-400",children:["A fixed 12 weeks (84 days), whatever window is selected above — the table's Inflation counts are the ",r," window, so the two are different spans and are never subtracted. Each bot has its own y-scale, as its sparkline did: read a line's height against itself, never against another bot's."]}),a.length===0?t.jsx("div",{className:"mt-2",children:t.jsx(Tt,{label:"No badge disagreements in the last 12 weeks"})}):t.jsx("div",{className:"mt-2 grid grid-cols-1 gap-x-4 gap-y-3 sm:grid-cols-2 xl:grid-cols-3",children:a.map(u=>t.jsx(B9,{panel:u,labels:s,color:d(u.key)},u.key))}),(i.length>0||c.length>0)&&t.jsxs("div",{className:"mt-2 space-y-0.5 text-[10px] leading-snug text-gray-400",children:[i.length>0&&t.jsxs("div",{children:["Not charted: ",i.join(", ")," — ",i.length===1?"it badges":"they badge"," ","nothing, and no badge is silence, not agreement. A flat zero would read “never inflates”, which is the opposite of what we know."]}),c.length>0&&t.jsxs("div",{children:["No disagreement in these 12 weeks: ",c.join(", ")," —"," ",c.length===1?"it badged":"they badged"," findings and our model agreed with every one."]})]})]})}const pj=["nit","minor","major","critical"],mj=[{key:"rolling_7",label:"7d"},{key:"rolling_14",label:"14d"},{key:"rolling_30",label:"30d"},{key:"sprint",label:"Sprint"}],q9={keep:{label:"Keep",className:"bg-green-500/10 text-green-700 dark:text-green-300 border border-green-500/30",title:"Healthy signal-to-noise — worth keeping on."},tune:{label:"Tune",className:"bg-amber-500/10 text-amber-700 dark:text-amber-300 border border-amber-500/30",title:"Either a lot of comments go unaddressed, or nearly everything it flags scores as a nit — consider tuning the noisy paths/severities on the bot."},noisy:{label:"Noisy",className:"bg-red-500/10 text-red-700 dark:text-red-300 border border-red-500/30",title:"High volume, low acted-on, and many threads left unaddressed past your normal response window — probably not paying for itself."}};function fh(e){return e==null?"—":`${Math.round(e)}%`}const gj=e=>`${Math.round(e)}%`,U9=e=>e.threads,fj={keep:De.green,tune:De.amber,noisy:De.red};function H9(e){return e==null?"—":`$${e.toFixed(2)}`}function z9(e){if(e==null)return"—";const n=e/6e4;if(n<60)return`${Math.max(1,Math.round(n))}m`;const r=n/60;if(r<24)return`${Math.round(r)}h`;const s=r/24;return`${s<10?s.toFixed(1):Math.round(s)}d`}function K9(e,n){return e.map(r=>({...r,...C9(r,n)}))}function G9({vendors:e,value:n,botColor:r,formatY:s,height:a=140}){const{labels:i,series:c}=f.useMemo(()=>{const d=new Set;for(const h of e)for(const g of h.trend)d.add(g.weekStart);const u=Array.from(d).sort().slice(-12),m=e.filter(h=>h.trend.length>0).map(h=>{const g=new Map(h.trend.map(x=>[x.weekStart,n(x)]));return{key:h.key,label:h.label,color:r({login:h.login,kind:h.kind}),values:u.map(x=>g.get(x)??null)}});return{labels:u,series:m}},[e,n,r]);return i.length<2||c.length===0?t.jsx(Tt,{label:"Not enough weekly history yet"}):t.jsx(Gn,{labels:i,series:c,height:a,curved:!0,formatY:s})}function V9({vendors:e}){const n=e.map(s=>s.label),r=[{key:"acted",label:"Acted on",color:De.green,values:e.map(s=>s.actedOn)},{key:"untouched",label:"Untouched",color:De.amber,values:e.map(s=>s.untouched)}];return n.length===0||e.every(s=>s.actedOn+s.untouched===0)?t.jsx(Tt,{}):t.jsx(Lr,{labels:n,series:r,mode:"stacked",rotateLabels:!0,height:160})}function Q9({vendors:e}){const n=e.filter(s=>s.actedOnPct!=null);if(n.length===0)return t.jsx(Tt,{label:"No acted-on data yet"});const r=[{key:"acted",label:"Acted-on %",color:De.slate,values:n.map(s=>s.actedOnPct??0),colors:n.map(s=>fj[s.verdict])}];return t.jsxs("div",{children:[t.jsx(Lr,{labels:n.map(s=>s.label),series:r,formatY:gj,formatValue:gj,rotateLabels:!0,height:160}),t.jsx("div",{className:"mt-1 flex flex-wrap gap-x-3 gap-y-0.5",children:["keep","tune","noisy"].map(s=>t.jsxs("span",{className:"flex items-center gap-1 text-[10px] capitalize text-gray-500 dark:text-gray-400",children:[t.jsx("span",{className:"inline-block h-2 w-2 rounded-[2px]",style:{background:fj[s]}}),s]},s))})]})}function Y9({suggestions:e}){return e.length===0?null:t.jsxs("div",{className:"rounded-lg border border-amber-300/50 bg-amber-50/50 p-3 dark:border-amber-500/30 dark:bg-amber-950/20",children:[t.jsx("div",{className:"mb-1.5 text-[11px] font-semibold uppercase tracking-wide text-amber-700 dark:text-amber-300",children:"Tuning suggestions"}),t.jsx("ul",{className:"space-y-1.5",children:e.map((n,r)=>{const s=ds(n.vendorKind);return t.jsxs("li",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 text-[11px]",children:[t.jsxs("span",{className:"inline-flex items-center gap-1 rounded px-1.5 py-0.5 font-medium",style:{...pn(s.color),background:`${s.color}1a`},children:[t.jsx(Lt,{size:11}),s.label]}),t.jsx("span",{className:"text-gray-600 dark:text-gray-300",children:n.rationale})]},`${n.vendorKind}:${n.pathGlob??"*"}:${n.severity??"*"}:${r}`)})})]})}const np="rounded border border-gray-200 px-2 py-1.5 dark:border-gray-800",X9="block w-full text-left transition hover:border-sky-300 focus:outline-none focus-visible:ring-1 focus-visible:ring-sky-400 dark:hover:border-sky-700";function zu({title:e,openLabel:n,onClick:r,children:s}){return r?t.jsx("button",{type:"button",onClick:r,title:e??n,className:`${np} ${X9}`,children:s}):t.jsx("div",{className:np,title:e,children:s})}function Z9({ml:e,overlapClusters:n,onOpen:r}){if(e.labelled===0&&e.pending===0)return null;const s=g=>r?()=>r(g):void 0,a=r?`${np} transition hover:border-sky-300 focus-within:border-sky-300 dark:hover:border-sky-700`:np,i=e.labelled+e.pending>0?e.labelled/(e.labelled+e.pending):0,c=e.bySeverity.major+e.bySeverity.critical,d=e.findings>0?c/e.findings:0,u=e.findings>0?e.bySeverity.nit/e.findings:0,m=e.backends.length>0&&e.backends.every(g=>!g.includes("modernbert-onnx")),h=e.byCategory[0];return t.jsxs("div",{className:"rounded-lg border border-gray-200 p-3 dark:border-gray-800",children:[t.jsxs("div",{className:"mb-2 flex flex-wrap items-baseline gap-2",children:[t.jsx("h3",{className:"text-sm font-semibold",children:"What the bots are flagging"}),t.jsx("span",{className:"text-[11px] text-gray-400",title:"Severity and category are predicted by a small local model, not an LLM. Advisory — treat major+critical together as 'high' rather than trusting critical alone.",children:"model-scored · advisory · over the selected window"}),e.pending>0&&t.jsxs("span",{className:"ml-auto text-[11px] text-gray-400 tabular-nums",children:[e.labelled.toLocaleString()," of ",(e.labelled+e.pending).toLocaleString()," bot comments in this window scored (",Math.round(i*100),"%) — the rest are still being processed"]}),e.unscorable>0&&t.jsxs("span",{className:`text-[11px] text-gray-400 tabular-nums${e.pending>0?"":" ml-auto"}`,title:"Comments synced during an old lean-storage window whose text GitHub no longer has (deleted-and-reposted bot comments). They can never be scored and are excluded from every coverage figure.",children:[e.unscorable.toLocaleString()," older comment",e.unscorable===1?"":"s"," can’t be scored"]})]}),e.truncated&&t.jsxs("div",{className:"mb-2 rounded border border-gray-300 px-2 py-1 text-[11px] text-gray-500 dark:border-gray-700 dark:text-gray-400",children:["This window has more labelled bot comments than one read covers — the numbers below cover the most recent ",e.labelled.toLocaleString(),"."]}),m&&t.jsx("div",{className:"mb-2 rounded border border-amber-300 bg-amber-50 px-2 py-1 text-[11px] text-amber-700 dark:border-amber-800 dark:bg-amber-950/30 dark:text-amber-300",children:"The scoring service is running its heuristic fallback, not the trained model — these severities are low quality. See docs/ML-SEVERITY.md."}),t.jsxs("div",{className:"grid grid-cols-2 gap-2 sm:grid-cols-3 xl:grid-cols-5",children:[t.jsxs("div",{className:a,children:[r?t.jsxs("button",{type:"button",onClick:()=>r({kind:"findings"}),title:"Show the findings behind this number",className:"block w-full text-left focus:outline-none focus-visible:ring-1 focus-visible:ring-sky-400",children:[t.jsx("div",{className:"text-[10px] uppercase tracking-wide text-gray-400",children:"Findings"}),t.jsx("div",{className:"text-lg font-semibold tabular-nums",children:e.findings.toLocaleString()})]}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"text-[10px] uppercase tracking-wide text-gray-400",children:"Findings"}),t.jsx("div",{className:"text-lg font-semibold tabular-nums",children:e.findings.toLocaleString()})]}),r?t.jsxs("button",{type:"button",onClick:()=>r({kind:"summaries"}),title:"Show the walkthroughs and summaries — a separate population, not counted as findings",className:"block w-full text-left text-[10px] text-gray-400 hover:text-gray-600 focus:outline-none focus-visible:ring-1 focus-visible:ring-sky-400 dark:hover:text-gray-200",children:["+ ",e.summaries.toLocaleString()," walkthrough/summary"]}):t.jsxs("div",{className:"text-[10px] text-gray-400",children:["+ ",e.summaries.toLocaleString()," walkthrough/summary"]})]}),t.jsxs(zu,{openLabel:"Show the major and critical findings behind this share",onClick:s({kind:"severity",severities:["major","critical"]}),children:[t.jsx("div",{className:"text-[10px] uppercase tracking-wide text-gray-400",children:"High severity"}),t.jsxs("div",{className:"text-lg font-semibold tabular-nums",style:{color:Ht.major.color},children:[Math.round(d*100),"%"]}),t.jsxs("div",{className:"text-[10px] text-gray-400",children:[c.toLocaleString()," major or critical"]})]}),t.jsxs(zu,{openLabel:"Show the findings scored as nits",onClick:s({kind:"severity",severities:["nit"]}),children:[t.jsx("div",{className:"text-[10px] uppercase tracking-wide text-gray-400",children:"Nits"}),t.jsxs("div",{className:"text-lg font-semibold tabular-nums",style:{color:Ht.nit.color},children:[Math.round(u*100),"%"]}),t.jsxs("div",{className:"text-[10px] text-gray-400",children:[e.bySeverity.nit.toLocaleString()," trivial or optional"]})]}),t.jsxs(zu,{openLabel:"Show the findings in this topic",onClick:h?s({kind:"category",category:h.category}):void 0,children:[t.jsx("div",{className:"text-[10px] uppercase tracking-wide text-gray-400",children:"Top topic"}),t.jsx("div",{className:"truncate text-lg font-semibold",children:h?Xa[h.category]??h.category:"—"}),t.jsx("div",{className:"text-[10px] text-gray-400",children:h?`${h.count.toLocaleString()} findings`:"no categorised findings yet"})]}),t.jsxs(zu,{title:"Distinct line areas two or more review bots both flagged in this window. Threads within ±3 lines of each other in the same file count as one area (two bots reviewing different revisions of a diff rarely land on the exact same line). Quality checks and outdated/file-level threads are excluded. Measured from the threads' own line data — not model-scored.",openLabel:"Show the line areas more than one bot flagged",onClick:s({kind:"overlap"}),children:[t.jsx("div",{className:"text-[10px] uppercase tracking-wide text-gray-400",children:"Same-line overlap"}),t.jsx("div",{className:"text-lg font-semibold tabular-nums",children:n.toLocaleString()}),t.jsxs("div",{className:"text-[10px] text-gray-400",children:["line area",n===1?"":"s"," flagged by >1 bot · window"]})]})]}),t.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2 text-[10px] text-gray-400",children:[e.byCategory.slice(0,5).map(g=>r?t.jsxs("button",{type:"button",onClick:()=>r({kind:"category",category:g.category}),title:`Show the findings categorised as ${Xa[g.category]??g.category}`,className:"rounded bg-gray-100 px-1 py-0.5 font-medium text-gray-500 hover:bg-gray-200 focus:outline-none focus-visible:ring-1 focus-visible:ring-sky-400 dark:bg-gray-800 dark:text-gray-400 dark:hover:bg-gray-700",children:[Xa[g.category]??g.category," ",g.count]},g.category):t.jsxs("span",{className:"rounded bg-gray-100 px-1 py-0.5 font-medium text-gray-500 dark:bg-gray-800 dark:text-gray-400",children:[Xa[g.category]??g.category," ",g.count]},g.category)),t.jsxs("span",{className:"ml-auto inline-flex flex-wrap items-center gap-2",children:[hp.map(g=>t.jsxs("span",{className:"inline-flex items-center gap-1",children:[t.jsx("span",{className:"inline-block h-2 w-2 rounded-full",style:{backgroundColor:Ht[g].color}}),Ht[g].label]},g)),t.jsx("span",{children:"Summaries and praise are excluded from severity shares."})]})]})]})}function xj({rows:e,botColor:n}){return e.length===0?null:t.jsxs("details",{className:"rounded-lg border border-gray-200 dark:border-gray-800",children:[t.jsxs("summary",{className:"cursor-pointer select-none px-3 py-2 text-[11px] font-semibold uppercase tracking-wide text-gray-500 dark:text-gray-400",children:["Quality checks (",e.length,")"," ",t.jsx("span",{className:"font-normal normal-case tracking-normal text-gray-400",children:"— excluded from ROI"})]}),t.jsxs("div",{className:"border-t border-gray-200 px-3 py-2 dark:border-gray-800",children:[t.jsxs("div",{className:"mb-2 text-[11px] text-gray-500 dark:text-gray-400",children:["Coverage and quality gates, not code reviewers. Their volume and untouched threads are left out of the verdicts and totals above — an unread coverage report is the norm, not noise. Re-role one in ",t.jsx("span",{className:"font-medium",children:"Settings"})," if it belongs in the ROI table."]}),t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"w-full min-w-[380px] border-collapse text-[11px]",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"text-left text-gray-500 dark:text-gray-400",children:[t.jsx("th",{className:"py-1 pr-3 font-medium",children:"Check"}),t.jsx("th",{className:"py-1 pr-3 text-right font-medium",children:"Threads"}),t.jsx("th",{className:"py-1 pr-3 text-right font-medium",children:"Comments"}),t.jsx("th",{className:"py-1 text-right font-medium",children:"Last active"})]})}),t.jsx("tbody",{children:e.map(r=>t.jsxs("tr",{className:"border-t border-gray-100 dark:border-gray-800/60",children:[t.jsx("td",{className:"py-1 pr-3",children:t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx("span",{className:"inline-block h-2 w-2 shrink-0 rounded-full",style:{background:n({login:r.login,kind:r.kind})}}),t.jsx("span",{className:"text-gray-700 dark:text-gray-200",children:r.label}),r.dormant&&t.jsx("span",{className:"rounded bg-gray-500/10 px-1 py-px text-[10px] text-gray-500 dark:text-gray-400",children:"dormant"})]})}),t.jsx("td",{className:"py-1 pr-3 text-right tabular-nums",children:r.threads}),t.jsx("td",{className:"py-1 pr-3 text-right tabular-nums",children:r.comments}),t.jsx("td",{className:"py-1 text-right text-gray-500 dark:text-gray-400",children:r.lastActiveAt!=null?Nt(r.lastActiveAt):"—"})]},r.key))})]})})]})]})}function J9({bot:e,loading:n,mergedPrs:r,onOpen:s}){if(n)return t.jsx("span",{className:"inline-block h-3 w-8 animate-pulse rounded bg-gray-100 align-middle dark:bg-gray-800",title:"Counting the bot comments on this window’s merged PRs…"});if(!e)return t.jsx("span",{className:"text-gray-500 dark:text-gray-400",title:"This bot commented on nothing that merged inside the window. (The thread columns can still be non-zero — they count threads OPENED in the window, on PRs that may not have merged yet.)",children:"—"});const a=uj(e.avgCommentsPerCommentedPr),i=`${e.comments.toLocaleString()} comment${e.comments===1?"":"s"} across ${e.prsCommentedOn.toLocaleString()} of the ${r.toLocaleString()} PRs merged in this window (most on one PR: ${e.maxCommentsOnOnePr.toLocaleString()}). Averaged over EVERY merged PR in scope instead — counting the ones it ignored — it is ${uj(e.avgCommentsPerScopePr)}.`;return s?t.jsx("button",{type:"button",onClick:()=>s({userId:e.authorUserId,label:e.label}),title:`${i} Click for the PRs behind it.`,className:"rounded px-1 underline decoration-dotted underline-offset-2 hover:bg-gray-100 hover:text-gray-900 dark:hover:bg-gray-800 dark:hover:text-gray-100",children:a}):t.jsx("span",{title:i,children:a})}function uR(e){const n=/^u(\d+)$/.exec(e);return n?Number(n[1]):null}function eU({weekly:e}){if(e.length<2)return null;const s=Math.max(1,...e.map(i=>Math.max(i.overCall,i.underCall))),a=i=>e.map((c,d)=>{const u=d/(e.length-1)*50+1,m=13-i(c)/s*11;return`${Math.round(u*10)/10},${Math.round(m*10)/10}`}).join(" ");return t.jsxs("svg",{width:52,height:14,className:"ml-1 inline-block align-middle","aria-hidden":"true",children:[t.jsx("polyline",{points:a(i=>i.overCall),fill:"none",stroke:De.amber,strokeWidth:1.25}),t.jsx("polyline",{points:a(i=>i.underCall),fill:"none",stroke:De.violet,strokeWidth:1.25})]})}function tU({vendor:e,onOpen:n}){const r=e.mlInflation,s=uR(e.key);if(r==null||r.badged===0)return t.jsx("span",{className:"text-gray-500 dark:text-gray-400",title:"badges nothing — no badge is silence, not agreement",children:"—"});const a=n!=null&&s!=null,i=c=>{const d=c==="over"?r.overCall:r.underCall,u=t.jsxs(t.Fragment,{children:[t.jsx(_s,{dir:c==="over"?"up":"down",size:10,className:"inline-block align-[-0.1em]"}),d]}),m=c==="over"?`${d} of ${r.badged} badged findings the bot graded WORSE than our model did (inflation).${a?" Click for the comments behind it.":""}`:`${d} of ${r.badged} badged findings our model graded worse than the bot's own badge — what a nit-filter set to the bot's grades would drop.${a?" Click for the comments behind it.":""}`,h=c==="over"?De.amber:De.violet;return a?t.jsx("button",{type:"button",onClick:()=>n(c,{userIds:[s],label:e.label}),title:m,style:d>0?{color:h}:void 0,className:`rounded px-0.5 underline decoration-dotted underline-offset-2 hover:bg-gray-100 dark:hover:bg-gray-800 ${d>0?"":"text-gray-400"}`,children:u}):t.jsx("span",{title:m,style:d>0?{color:h}:void 0,className:d>0?"":"text-gray-400",children:u})};return t.jsxs("span",{className:"inline-flex items-center gap-1 tabular-nums",children:[i("over"),i("under"),r.weekly!=null&&t.jsx(eU,{weekly:r.weekly})]})}function nU({vendors:e,botColor:n,onOpenVendor:r,overdueGraceMs:s,showMl:a,showCost:i,volume:c,volumeLoading:d,onOpenVolume:u,onOpenInflation:m,onOpenDepth:h,onTune:g,onDrop:x}){const y=a?2:1,b=!!(g??x),w=f.useMemo(()=>R9(c==null?void 0:c.bots),[c==null?void 0:c.bots]),k=(c==null?void 0:c.totals.prs)??0;return t.jsx("div",{className:"overflow-x-auto rounded-lg border border-gray-200 dark:border-gray-800",children:t.jsxs("table",{className:`w-full border-collapse text-[11px] ${b?a?"min-w-[1680px]":"min-w-[1200px]":a?"min-w-[1560px]":"min-w-[1080px]"}`,children:[t.jsxs("thead",{children:[t.jsxs("tr",{className:`text-left text-gray-500 dark:text-gray-400${a?"":" border-b border-gray-200 dark:border-gray-800"}`,children:[t.jsx("th",{rowSpan:y,className:"px-2 py-1.5 font-medium",children:"Vendor"}),t.jsx("th",{rowSpan:y,className:"px-2 py-1.5 text-right font-medium",children:"Threads"}),t.jsx("th",{rowSpan:y,className:"px-2 py-1.5 text-right font-medium",title:"Inline review comments this bot left in the window, counted by the comment's own date, across PRs in any state (open, merged or closed). Deliberately NOT the numerator of Comments/PR — that column also counts PR comments and review bodies, and only over PRs merged inside the window.",children:"Comments"}),t.jsx("th",{rowSpan:y,className:"px-2 py-1.5 text-right font-medium",title:"How much this bot says when it shows up: its comments averaged over the PRs IT COMMENTED ON — not over every PR. Counts inline review comments, PR comments and review bodies, on PRs MERGED inside the window (open PRs are excluded, unlike the thread columns to the left). Click a figure for the PRs behind it.",children:"Comments/PR"}),t.jsx("th",{rowSpan:y,className:"px-2 py-1.5 text-right font-medium",title:"A later commit likely addressed the thread, it was resolved, or a human replied/resolved after the bot",children:"Acted on"}),t.jsx("th",{rowSpan:y,className:"px-2 py-1.5 text-right font-medium",title:"Threads with no reply and no follow-up commit — the total not-addressed",children:"Not addressed"}),t.jsx("th",{rowSpan:y,className:"px-2 py-1.5 text-right font-medium",title:`Not-addressed threads older than the ${Math.round(s/36e5)}h grace window — the genuinely-ignored ones that drive the 'noisy' verdict`,children:"Overdue"}),t.jsx("th",{rowSpan:y,className:"px-2 py-1.5 text-right font-medium",title:"PRs merged inside the window that still carried at least one not-addressed thread by this bot at merge — the team's final answer was to ship anyway. The threads themselves may be older than the window.",children:"Merged past"}),t.jsx("th",{rowSpan:y,className:"px-2 py-1.5 text-right font-medium",title:"This bot's median time from opening a thread to it being addressed — a human reply, a resolve, or an addressing commit",children:"Time to address"}),t.jsx("th",{rowSpan:y,className:"px-2 py-1.5 text-right font-medium",title:"Not-addressed threads' oldest age",children:"Oldest"}),t.jsx("th",{rowSpan:y,className:"px-2 py-1.5 text-right font-medium",title:"Low-value / untouched share — the noise floor",children:"Noise"}),t.jsx("th",{rowSpan:y,className:"px-2 py-1.5 text-right font-medium",title:"Share of this bot's threads landing within ±3 lines of another bot's thread in the same file — redundant coverage. Advisory only; hover a cell for the top partner. Outdated/file-level threads (no line) never count.",children:"Overlap"}),a&&t.jsxs(t.Fragment,{children:[t.jsx("th",{rowSpan:y,className:"w-28 px-2 py-1.5 font-medium",title:"This bot's scored findings by predicted severity, over the selected window — model-scored, advisory. Summaries and praise are excluded.",children:"Severity mix"}),t.jsx("th",{rowSpan:y,className:"px-2 py-1.5 text-right font-medium",title:"Major + critical as a share of this bot's scored findings in the window.",children:"High"}),t.jsx("th",{rowSpan:y,className:"px-2 py-1.5 text-right font-medium",title:"Nits as a share of this bot's scored findings in the window — a persistently high share suggests raising the bot's severity floor.",children:"Nits"}),t.jsx("th",{colSpan:4,className:"border-l border-gray-200 px-2 pb-0 pt-1.5 text-center font-medium dark:border-gray-800",title:"This bot's not-addressed threads, split by the predicted severity of the finding that opened each one. Model-scored and advisory: threads whose opening comment was never scored aren't counted, so these need not add up to the Not addressed column.",children:"Not addressed by severity"}),t.jsx("th",{rowSpan:y,className:"border-l border-gray-200 px-2 py-1.5 text-right font-medium dark:border-gray-800",title:"How often this bot's OWN severity badge contradicted our label, over its badged findings in the window: the up-arrow count = the bot graded a finding worse than we did (inflation), the down-arrow count = we graded it worse than the bot (what a nit-filter on its own grades would drop). Counts, never shares. A bot that badges nothing shows a dash — no badge is silence, not agreement. Click a count for the comments behind it.",children:"Inflation"})]}),i&&t.jsx("th",{rowSpan:y,className:"px-2 py-1.5 text-right font-medium",title:"Monthly cost ÷ acted-on threads a month, both over this whole Workspace — the acted-on count is scaled from the selected window to a month, so the price and the work are on the same time base. Bots → Benchmark measures the same fraction over each reviewer's whole observed span instead, so the two answer different questions and need not match. The price is this bot's price FOR THIS WORKSPACE — set it on the bot's card in Bots → Settings. Another Workspace may hold a different figure for the same bot; the two are never added together.",children:"$/acted-on"}),t.jsx("th",{rowSpan:y,className:"px-2 py-1.5 text-center font-medium",children:"Verdict"}),h!=null&&t.jsx("th",{rowSpan:y,className:"px-2 py-1.5 text-center font-medium",title:"Open this bot's depth tab — its latency, cadence, coverage and consistency charts, plus its severity-over-time and category mix",children:"Depth"}),b&&t.jsx("th",{rowSpan:y,className:"px-2 py-1.5 text-center font-medium",title:"Open the Bot Tuning Advisor focused on this bot — Tune shows its evidence-backed configuration changes; Drop assembles the case for removing it.",children:"Actions"})]}),a&&t.jsx("tr",{className:"border-b border-gray-200 text-left text-gray-500 dark:border-gray-800 dark:text-gray-400",children:pj.map((j,N)=>t.jsx("th",{className:`px-1.5 pb-1.5 text-right text-[10px] font-medium${N===0?" border-l border-gray-200 dark:border-gray-800":""}`,style:{color:Ht[j].color},title:`Not-addressed threads whose opening finding scored ${Ht[j].label.toLowerCase()}`,children:j==="critical"?"Crit":Ht[j].label},j))})]}),t.jsx("tbody",{children:e.map(j=>{const N=n({login:j.login,kind:j.kind}),I=q9[j.verdict],S=t.jsx("span",{className:"text-gray-500 dark:text-gray-400",children:"—"});return t.jsxs("tr",{className:"border-b border-gray-100 last:border-0 dark:border-gray-800/60",children:[t.jsxs("td",{className:"px-2 py-1.5",children:[t.jsxs("button",{type:"button",onClick:()=>r(j.key),title:"Open the bot drill-down — its comments (default) and the PRs it touched",className:"inline-flex cursor-pointer items-center gap-1 rounded px-1.5 py-0.5 font-medium hover:underline",style:{...pn(N),background:`${N}1a`},children:[t.jsx(Lt,{size:11}),j.label]}),j.reviewers>1&&t.jsxs("span",{className:"ml-1 text-gray-400",children:["×",j.reviewers]}),j.dormant&&t.jsxs("span",{className:"ml-1.5 inline-block rounded border border-gray-300 px-1 py-px text-[10px] text-gray-500 dark:border-gray-700 dark:text-gray-400",title:"No activity in the selected window — the trend below still shows its earlier threads. Widen the window to see them counted.",children:["dormant",j.lastActiveAt!=null&&` · last active ${Nt(j.lastActiveAt)}`]})]}),t.jsx("td",{className:"px-2 py-1.5 text-right tabular-nums",children:j.dormant?S:j.threads}),t.jsx("td",{className:"px-2 py-1.5 text-right tabular-nums text-gray-500 dark:text-gray-400",children:j.dormant?S:j.comments}),t.jsx("td",{className:"px-2 py-1.5 text-right tabular-nums",children:t.jsx(J9,{bot:w.get(j.key),loading:d,mergedPrs:k,onOpen:u})}),t.jsx("td",{className:"px-2 py-1.5 text-right tabular-nums",children:j.dormant?S:t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"text-gray-700 dark:text-gray-200",children:j.actedOn}),t.jsx("span",{className:"ml-1 text-gray-400",children:fh(j.actedOnPct)})]})}),t.jsx("td",{className:"px-2 py-1.5 text-right tabular-nums",children:j.dormant?S:t.jsx("span",{className:j.untouched>0?"text-amber-600 dark:text-amber-400":"text-gray-400",children:j.untouched})}),t.jsx("td",{className:"px-2 py-1.5 text-right tabular-nums",children:j.dormant?S:t.jsx("span",{className:j.overdueUntouched>0?"text-red-600 dark:text-red-400":"text-gray-400",title:j.untouched>0?`${j.overdueUntouched} of ${j.untouched} not-addressed threads are past the normal response window`:void 0,children:j.overdueUntouched})}),t.jsx("td",{className:"px-2 py-1.5 text-right tabular-nums",title:(j.mergedPastPrs??0)>0?`${j.mergedPastPrs} PR${j.mergedPastPrs===1?"":"s"} merged this window still carrying ${j.mergedPastThreads} not-addressed thread${j.mergedPastThreads===1?"":"s"} by this bot`:"No PR merged this window carried a not-addressed thread by this bot",children:(j.mergedPastPrs??null)==null?S:t.jsx("span",{className:j.mergedPastPrs>0?"text-amber-600 dark:text-amber-400":"text-gray-400",children:j.mergedPastPrs})}),t.jsx("td",{className:"px-2 py-1.5 text-right tabular-nums text-gray-500 dark:text-gray-400",children:j.dormant?S:z9(j.medianAddressedMs)}),t.jsx("td",{className:"px-2 py-1.5 text-right tabular-nums text-gray-500 dark:text-gray-400",children:j.oldestUntouchedDays!=null?`${j.oldestUntouchedDays}d`:"—"}),t.jsx("td",{className:"px-2 py-1.5 text-right tabular-nums text-gray-500 dark:text-gray-400",children:j.dormant?S:fh(j.noiseRatioPct)}),t.jsx("td",{className:"px-2 py-1.5 text-right tabular-nums text-gray-500 dark:text-gray-400",title:j.topOverlapPartner?`${j.overlapThreads} thread${j.overlapThreads===1?"":"s"} land on lines ${j.topOverlapPartner.label} also flagged (${j.topOverlapPartner.clusters} shared spot${j.topOverlapPartner.clusters===1?"":"s"})`:"No threads landing on lines another bot also flagged in this window",children:j.dormant?S:fh(j.overlapPct??null)}),a&&t.jsxs(t.Fragment,{children:[t.jsx("td",{className:"w-28 px-2 py-1.5",title:j.mlFindings!=null?`${j.mlFindings} scored finding${j.mlFindings===1?"":"s"} in the window`:"No scored comments for this bot in the window",children:j.mlBySeverity&&j.mlFindings!=null&&j.mlFindings>0?t.jsx(S3,{counts:j.mlBySeverity,total:j.mlFindings}):S}),t.jsx("td",{className:"px-2 py-1.5 text-right font-semibold tabular-nums",style:j.mlHighPct!=null?{color:Ht.major.color}:void 0,children:j.mlHighPct!=null?`${j.mlHighPct}%`:S}),t.jsx("td",{className:"px-2 py-1.5 text-right tabular-nums",style:j.mlNitPct!=null?{color:Ht.nit.color}:void 0,children:j.mlNitPct!=null?`${j.mlNitPct}%`:S}),pj.map((T,$)=>{var C;const P=((C=j.notAddressedBySeverity)==null?void 0:C[T])??0;return t.jsx("td",{className:`px-1.5 py-1.5 text-right tabular-nums${$===0?" border-l border-gray-200 dark:border-gray-800":""}`,style:P>0?{color:Ht[T].color}:void 0,title:P>0?`${P} not-addressed thread${P===1?"":"s"} opened by a ${Ht[T].label.toLowerCase()} finding`:void 0,children:P>0?P:S},T)}),t.jsx("td",{className:"border-l border-gray-200 px-2 py-1.5 text-right dark:border-gray-800",children:t.jsx(tU,{vendor:j,onOpen:m})})]}),i&&t.jsx("td",{className:"px-2 py-1.5 text-right tabular-nums text-gray-500 dark:text-gray-400",title:j.costMonthlyUsd==null?j.legacyOnlyUsd!=null?`No price set for this bot in this Workspace. The old account-wide list still has $${Hl(j.legacyOnlyUsd)}/mo for it — re-enter it in Bots → Settings to use it.`:"No price set for this bot in this Workspace — set one in Bots → Settings.":`$${Hl(j.costMonthlyUsd)}/mo for this bot in this Workspace${j.costModel==="per_seat"&&j.costUnitMonthlyUsd!=null?` — $${Hl(j.costUnitMonthlyUsd)}/seat at ${j.costSeatCount} seat${j.costSeatCount===1?"":"s"}`:""}. Another Workspace may hold a different figure; the two are never added together.`,children:j.dormant?S:t.jsx(t.Fragment,{children:H9(j.costPerActedOnUsd)})}),t.jsx("td",{className:"px-2 py-1.5 text-center",children:j.dormant?S:t.jsx("span",{className:`inline-block rounded px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide ${I.className}`,title:I.title,children:I.label})}),h!=null&&t.jsx("td",{className:"px-2 py-1.5 text-center",children:(()=>{const T=uR(j.key);return T==null?S:t.jsx("button",{type:"button",onClick:()=>h({userId:T,label:j.label,login:j.login,kind:j.kind}),title:"Open this bot's depth tab — latency, cadence, coverage and consistency, plus its severity-over-time and category mix",className:"rounded border border-sky-400 px-1.5 py-0.5 text-[10px] font-medium text-sky-700 hover:bg-sky-50 dark:border-sky-600/70 dark:text-sky-300 dark:hover:bg-sky-950/40",children:"Depth →"})})()}),b&&t.jsx("td",{className:"px-2 py-1.5 text-center",children:t.jsxs("span",{className:"inline-flex gap-1",children:[g&&t.jsx("button",{type:"button",onClick:()=>g(j.key),title:"Open the Advisor on this bot's tuning findings — evidence-backed config changes, retro-checked before any PR",className:"rounded border border-amber-400 px-1.5 py-0.5 text-[10px] font-medium text-amber-700 hover:bg-amber-50 dark:border-amber-600/70 dark:text-amber-300 dark:hover:bg-amber-950/40",children:"Tune"}),x&&t.jsx("button",{type:"button",onClick:()=>x(j.key),title:"Open the Advisor with the case for dropping this bot — its acted-on rate, overlap and suppression evidence in one brief",className:"rounded border border-red-400 px-1.5 py-0.5 text-[10px] font-medium text-red-700 hover:bg-red-50 dark:border-red-600/70 dark:text-red-300 dark:hover:bg-red-950/40",children:"Drop"})]})})]},j.key)})})]})})}function rU({workspaceId:e,repoIds:n}){const{data:r}=mC(e,!0,n),s=G(i=>i.openBotThreadsDetail),a=(r==null?void 0:r.totalThreads)??0;return a===0?null:t.jsxs("button",{type:"button",onClick:()=>s((n==null?void 0:n[0])??null),"data-testid":"resolve-backlog-caption",title:"Review & resolve the likely-addressed bot threads",className:"flex w-full items-start gap-1.5 rounded-lg border border-sky-300 bg-sky-50 px-3 py-2 text-left text-[11px] text-sky-700 hover:bg-sky-100 dark:border-sky-800 dark:bg-sky-950/30 dark:text-sky-300 dark:hover:bg-sky-900/40",children:[t.jsxs("span",{className:"flex-1",children:[t.jsx(vx,{className:"mr-1 inline-block align-[-0.1em]"}),t.jsx("span",{className:"font-semibold tabular-nums",children:a})," likely-addressed bot thread",a===1?"":"s"," look resolved by later commits — review before resolving on GitHub."]}),t.jsx("span",{className:"shrink-0 self-center rounded border border-sky-400 px-1.5 py-0.5 text-[10px] font-medium text-sky-700 dark:border-sky-600/70 dark:text-sky-300",children:"Show list →"})]})}function sU({repoId:e}={}){var O;const n=G(E=>E.botAnalyticsWindow),r=G(E=>E.setBotAnalyticsWindow),s=G(E=>E.openBotPrsDetail),a=G(E=>E.openBotOnlyDetail),i=G(E=>E.openBotFlaggingDetail),c=G(E=>E.focusAdvisor),{botAdvisor:d,botDepth:u}=vt(),m=uc(u),h=m==="entitled",g=d&&e==null,x=u&&e==null,y=G(E=>E.workspaceId),b=f.useMemo(()=>e!=null?[e]:null,[e]),{data:w,isLoading:k,isError:j}=Qp(y,n,h,b),{data:N,isLoading:I,isPlaceholderData:S}=M9(y,n,h,b),T=I||S,$=G(E=>E.openBotVolumeDetail),P=Ge(E=>E.openBotDetailTab),C=co(y),L=ba(),F=w==null?void 0:w.ml,M=L&&F!=null,D=L&&((F==null?void 0:F.labelled)??0)>0,{data:A}=dR(b9()),W=f.useMemo(()=>new Map(((A==null?void 0:A.bots.cost)??[]).map(E=>[E.login,E.monthlyUsd])),[A==null?void 0:A.bots.cost]),z=f.useMemo(()=>w?K9(w.vendors,W):[],[w,W]),te=(w==null?void 0:w.qualityChecks)??[];if(m==="pending")return null;if(m==="locked")return t.jsxs(dc,{heading:"Bot ROI",testId:"bot-roi-locked",children:["What each review bot actually produced this window: threads raised, how many were acted on, how long they sat, how much repeated another bot",x?t.jsx(t.Fragment,{children:" — and what that works out to per acted-on comment against the price of the seat."}):t.jsx(t.Fragment,{children:"."})]});const H=t.jsx("div",{className:"flex flex-wrap items-center gap-2",children:t.jsx("div",{className:"ml-auto inline-flex overflow-hidden rounded border border-gray-300 dark:border-gray-700",children:mj.map(E=>t.jsx("button",{type:"button",onClick:()=>r(E.key),className:`px-2 py-0.5 text-[11px] font-medium ${n===E.key?"bg-ai-signal/15 text-ai-signal":"text-gray-500 hover:bg-gray-100 dark:text-gray-400 dark:hover:bg-gray-800"}`,children:E.label},E.key))})});let B;if(k)B=t.jsx("div",{className:"h-28 animate-pulse rounded-lg border border-gray-200 bg-gray-50 dark:border-gray-800 dark:bg-gray-900/40"});else if(j)B=t.jsx("div",{className:"text-sm text-red-500",children:"Couldn’t load bot analytics."});else if(!w||z.length===0)B=t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"rounded-lg border border-dashed border-gray-300 p-6 text-center text-sm text-gray-400 dark:border-gray-700",children:["No review-bot activity in this window.",t.jsxs("div",{className:"mt-1 text-[11px]",children:["When review bots (CodeRabbit, Copilot, in-house AI…) comment on your PRs, their signal-to-noise lands here. A bot that was active earlier may just be quiet — try widening the window above.",te.length>0&&" Quality checks are listed separately below."]})]}),t.jsx(xj,{rows:te,botColor:C})]});else{const E=w.totals,ee=((O=mj.find(K=>K.key===n))==null?void 0:O.label)??"selected";B=t.jsxs("div",{className:"space-y-3",children:[M&&F&&t.jsx(Z9,{ml:F,overlapClusters:E.overlapClusters??0,onOpen:K=>i(K,e??null)}),t.jsxs("div",{className:"text-[11px] text-gray-500 dark:text-gray-400",children:[t.jsx("span",{className:"font-semibold tabular-nums text-gray-700 dark:text-gray-200",children:E.threads})," ","bot thread",E.threads===1?"":"s"," · ",E.comments," comment",E.comments===1?"":"s"," ·"," ",t.jsx("span",{className:"tabular-nums",children:fh(E.actedOnPct)})," acted on ·"," ",t.jsx("span",{className:"tabular-nums text-amber-600 dark:text-amber-400",children:E.untouched})," ","not addressed"," · ",t.jsxs("span",{className:"tabular-nums",title:"Not-addressed threads count as overdue (and feed the 'noisy' verdict) once they're older than this fixed grace window.",children:["overdue after ",Math.round(E.overdueGraceMs/36e5),"h"]})," · ",t.jsxs("button",{type:"button",onClick:()=>a(e??null),title:"Show the OPEN PRs only a bot reviewed — no human review or comment since they opened",className:"rounded underline decoration-dotted underline-offset-2 hover:text-gray-700 dark:hover:text-gray-200",children:[t.jsx("b",{className:"tabular-nums text-gray-700 dark:text-gray-200",children:E.botOnlyPrs})," ","bot-only open PR",E.botOnlyPrs===1?"":"s"]})]}),t.jsx(nU,{vendors:z,botColor:C,onOpenVendor:K=>s(K,e??null),overdueGraceMs:E.overdueGraceMs,showMl:D,showCost:x,volume:N,volumeLoading:T,onOpenVolume:K=>$(e??null,{userIds:[K.userId],label:K.label}),onOpenInflation:(K,U)=>i({kind:"findings"},e??null,{bots:U,disagree:K}),onOpenDepth:u?K=>{const U={id:K.userId,login:K.login,label:K.label,kind:K.kind,repoId:e??null};P(K.userId,U)}:null,onTune:g?K=>c(K,"tune"):null,onDrop:g?K=>c(K,"drop"):null}),t.jsxs("div",{className:"grid grid-cols-1 gap-3 lg:grid-cols-3",children:[t.jsx(jt,{title:"Thread volume",note:"weekly · last 12",children:t.jsx(G9,{vendors:z,value:U9,botColor:C})}),t.jsx(jt,{title:"Bot effectiveness",note:"acted-on % · keep / tune / noisy",children:t.jsx(Q9,{vendors:z})}),t.jsx(jt,{title:"Acted-on vs untouched",note:"by bot · current window",children:t.jsx(V9,{vendors:z})}),D&&t.jsx(W9,{vendors:z,botColor:C,windowLabel:ee})]}),t.jsx(xj,{rows:te,botColor:C}),t.jsxs("div",{className:"text-[11px] text-gray-400",children:["“Acted on” = a later commit likely addressed the thread, it was resolved, or a human replied/resolved after the bot (approximate). Noise ratio = the untouched share of a bot's threads."," ",x?t.jsxs(t.Fragment,{children:["Set a bot's monthly price in ",t.jsx("span",{className:"font-medium",children:"Bots → Settings"})," to see $/acted-on — the price is per ",t.jsx("span",{className:"font-medium",children:"Workspace"}),", so another Workspace may hold a different figure for the same bot and the two are never added together."]}):t.jsxs(t.Fragment,{children:["Cost is not shown per repository: a bot's price is per"," ",t.jsx("span",{className:"font-medium",children:"Workspace"}),", so dividing a whole month of it by one repo's work would read as spend and could not be added up across repos. The $/acted-on figures are on the cross-repo"," ",t.jsx("span",{className:"font-medium",children:"Bots"})," rail."]})]})]})}return t.jsxs("div",{className:"space-y-2","data-testid":"bot-roi-panel",children:[H,B]})}const Ku={nit:1,minor:2,major:3,critical:4},aU=["nit","minor","major","critical"];function hR(e){return e.nit+e.minor+e.major+e.critical}function oU(e){const n=hR(e);return n===0?null:(e.nit*Ku.nit+e.minor*Ku.minor+e.major*Ku.major+e.critical*Ku.critical)/n}function iU(e){const n=new Set;for(const r of e)for(const s of r.weekly)n.add(s.weekStart);return[...n].sort().slice(-12)}function lU(e,n){const r=new Map(e.weekly.map(s=>[s.weekStart,s.bySeverity]));return n.map(s=>{const a=r.get(s);return a?oU(a):null})}function cU(e){const n=hR(e);if(n===0)return null;const r=aU.filter(s=>e[s]>0).map(s=>`${e[s]} ${s}`);return`${n} finding${n===1?"":"s"} · ${r.join(" / ")}`}function dU(e){const n=[...e].sort((i,c)=>i.minLoc-c.minLoc),r=[],s=[];let a=!1;for(const i of n){if(i.prs<=0){s.push(i.label);continue}i.comments>0&&(a=!0),r.push({label:i.label,prs:i.prs,avg:i.avgComments,density:i.commentsPer100Loc})}return{rows:r,emptyLabels:s,hasComments:a}}function uU(e){return e==null?"—":e===0?"0":e>0&&e<.05?"<0.1":e.toFixed(1)}function hU(e){return e==null?"—":e===0?"0":e>0&&e<.01?"<0.01":e<1?e.toFixed(2):e<10?e.toFixed(1):String(Math.round(e))}function pU(e){return`${e.toLocaleString()} PR${e===1?"":"s"}`}function mU(e,n){if(n<=0)return null;const r=e+n;return`${n.toLocaleString()} of ${r.toLocaleString()} merged PRs had no recorded size and are excluded from every bucket.`}const Yf=[{key:"rolling_7",label:"7d"},{key:"rolling_14",label:"14d"},{key:"rolling_30",label:"30d"},{key:"sprint",label:"Sprint"}],Xf=e=>e>=10?String(Math.round(e)):String(Math.round(e*10)/10);function _l({label:e,value:n,sub:r}){return t.jsxs("div",{className:"rounded-lg border border-gray-200 bg-white p-2 dark:border-gray-800 dark:bg-gray-900/40",children:[t.jsx("div",{className:"text-[9px] font-semibold uppercase tracking-wide text-gray-400",children:e}),t.jsx("div",{className:"text-base font-semibold text-gray-800 dark:text-gray-100",children:n}),r&&t.jsx("div",{className:"text-[10px] text-gray-400",children:r})]})}function Zf({bins:e,color:n}){if(e.every(s=>s.count===0))return t.jsx(Tt,{label:"No data in this window"});const r=[{key:"count",label:"PRs",color:n,values:e.map(s=>s.count)}];return t.jsx(Lr,{labels:e.map(s=>s.label),series:r,height:130})}function pR(e){const[n,r]=f.useState(null);return f.useMemo(()=>({selected:n,isOn:s=>n==null||n.has(s),toggle:s=>r(a=>{if(a==null)return new Set([s]);const i=new Set(a);return i.has(s)?i.delete(s):i.add(s),i.size===0||i.size===e.length?null:i}),reset:()=>r(null)}),[n,e])}function mR({bots:e,subset:n,botColor:r}){return e.length<=1?null:t.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[e.map(s=>{const a=n.isOn(s.key),i=r({login:s.login,kind:s.kind});return t.jsxs("button",{type:"button",onClick:()=>n.toggle(s.key),className:`flex items-center gap-1 text-[10px] ${a?"text-gray-600 dark:text-gray-300":"text-gray-400 line-through opacity-60"}`,children:[t.jsx("span",{className:"inline-block h-2 w-2 rounded-[2px]",style:{background:a?i:"transparent",boxShadow:`inset 0 0 0 1.5px ${i}`}}),s.label]},s.key)}),n.selected!=null&&t.jsx("button",{type:"button",onClick:n.reset,className:"text-[10px] text-sky-600 hover:underline dark:text-sky-400",children:"all"})]})}function gU(e){const n=e.length;if(n<2)return null;let r=0,s=0,a=0,i=0;for(const u of e)r+=u.x,s+=u.y,a+=u.x*u.x,i+=u.x*u.y;const c=n*a-r*r;if(c===0)return null;const d=(n*i-r*s)/c;return{m:d,b:(s-d*r)/n}}function fU({bots:e,botColor:n}){const[r,s]=f.useState("kloc"),[a,i]=f.useState(!0),c=f.useMemo(()=>e.filter(k=>k.trend.some(j=>j.findingsPerKloc!=null||j.findingsPerPr!=null)),[e]),d=f.useMemo(()=>c.map(k=>k.key),[c]),u=pR(d),{selected:m,isOn:h}=u,{labels:g,series:x,trendPct:y}=f.useMemo(()=>{const k=P=>r==="kloc"?P.findingsPerKloc:P.findingsPerPr,j=new Set;for(const P of c)for(const C of P.trend)j.add(C.weekStart);const N=Array.from(j).sort().slice(-12),I=c.filter(P=>m==null||m.has(P.key)),S=new Map,T=I.filter(P=>P.trend.some(C=>k(C)!=null)).map(P=>{const C=new Map(P.trend.map(D=>[D.weekStart,k(D)]));S.set(P.key,C);const L=new Map(P.trend.map(D=>[D.weekStart,D.densityAnomaly])),F=new Map(P.trend.map(D=>[D.weekStart,D.prsInWeek])),M=new Map;for(const D of P.anomalies){if(D.metric!=="density"||D.weekStart==null)continue;const A=D.direction==="high"?"higher than usual":"lower than usual",W=F.get(D.weekStart),z=W!=null?` · over ${W} PR${W===1?"":"s"}`:"",te=D.z!=null?` · robust-z ${D.z}`:"";M.set(D.weekStart,`${A} — ${D.observed} vs ${D.typical}/KLoC typical${te}${z}`)}return{key:P.key,label:P.label,color:n({login:P.login,kind:P.kind}),values:N.map(D=>C.get(D)??null),pointFlags:N.map(D=>L.get(D)??!1),pointNotes:N.map(D=>M.get(D)??null)}});let $=null;if(a&&T.length>0){const P=[];N.forEach((L,F)=>{var A;const M=[];for(const W of I){const z=(A=S.get(W.key))==null?void 0:A.get(L);z!=null&&M.push(z)}if(M.length===0)return;const D=M.reduce((W,z)=>W+z,0)/M.length;D>0&&P.push({x:F,y:Math.log10(D)})});const C=gU(P);if(C){const L=D=>Math.pow(10,C.m*D+C.b);T.push({key:"__trend__",label:"Overall trend",color:De.amber,values:N.map((D,A)=>L(A)),dashed:!0});const F=L(0),M=L(N.length-1);F>0&&($=Math.round((M/F-1)*100))}}return{labels:N,series:T,trendPct:$}},[c,n,r,m,a]),b=(()=>{if(y==null)return null;const k=y<=-10?"↘":y>=10?"↗":"→",j=y<=-10?"text-green-600 dark:text-green-400":y>=10?"text-amber-600 dark:text-amber-400":"text-gray-500 dark:text-gray-400";return{text:`${k} ${y>0?"+":""}${y}% over 12 wks`,cls:j}})(),w=d.length>0&&d.every(k=>!h(k));return t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[t.jsxs("div",{className:"flex items-center gap-2 text-[10px]",children:[t.jsxs("button",{type:"button",onClick:()=>i(k=>!k),className:`inline-flex items-center gap-1 rounded border px-2 py-0.5 font-medium ${a?"border-amber-400 bg-amber-500/10 text-amber-700 dark:text-amber-300":"border-gray-300 text-gray-500 hover:bg-gray-100 dark:border-gray-700 dark:text-gray-400 dark:hover:bg-gray-800"}`,children:[t.jsx("span",{className:"inline-block h-0 w-3 border-t-2 border-dashed",style:{borderColor:De.amber}}),"Trend line"]}),a&&b&&t.jsx("span",{className:`font-medium ${b.cls}`,children:b.text})]}),t.jsx("div",{className:"inline-flex overflow-hidden rounded border border-gray-300 text-[10px] dark:border-gray-700",children:[["kloc","per KLoC"],["pr","per PR"]].map(([k,j])=>t.jsx("button",{type:"button",onClick:()=>s(k),className:`px-2 py-0.5 font-medium ${r===k?"bg-sky-500/15 text-sky-700 dark:text-sky-300":"text-gray-500 hover:bg-gray-100 dark:text-gray-400 dark:hover:bg-gray-800"}`,children:j},k))})]}),t.jsx(mR,{bots:c,subset:u,botColor:n}),w?t.jsx(Tt,{label:"Select at least one bot"}):g.length<2||x.length===0?t.jsx(Tt,{label:"Not enough weekly history yet"}):t.jsx(Gn,{labels:g,series:x,height:150,curved:!0,logY:!0,tipBelow:!0,hideLegend:!0,formatY:Xf})]})}const xU={1:"Nit",2:"Minor",3:"Major",4:"Critical"},yU=e=>xU[e]??e.toFixed(1);function bU({views:e,subset:n,botColor:r}){const s=f.useMemo(()=>iU(e.map(c=>c.ml)),[e]),a=f.useMemo(()=>{const c=[];for(const d of e){if(!n.isOn(d.key))continue;const u=lU(d.ml,s);if(u.every(h=>h==null))continue;const m=new Map(d.ml.weekly.map(h=>[h.weekStart,h.bySeverity]));c.push({key:d.key,label:d.label,color:r({login:d.login,kind:d.kind}),values:u,pointNotes:s.map(h=>{const g=m.get(h);return g?cU(g):null})})}return c},[e,n,s,r]),i=e.length>0&&e.every(c=>!n.isOn(c.key));return t.jsxs("div",{className:"space-y-2",children:[t.jsx(mR,{bots:e,subset:n,botColor:r}),i?t.jsx(Tt,{label:"Select at least one bot"}):s.length<2||a.length===0?t.jsx(Tt,{label:"Not enough weekly history yet"}):t.jsx(Gn,{labels:s,series:a,height:160,curved:!0,hideLegend:!0,noteTone:"muted",formatY:yU,yDomain:{min:1,max:4,ticks:[1,2,3,4]}})]})}function vU({overlap:e,color:n}){const{reviewedPrs:r,multiReviewedPrs:s,distribution:a,pairs:i,lineOverlapClusters:c,lineOverlapPrs:d}=e;if(r===0)return null;const u=Math.round(s/r*100),m=Math.max(1,...i.map(h=>h.prs));return t.jsxs("div",{className:"space-y-2 rounded-lg border border-gray-200 p-3 dark:border-gray-800",children:[t.jsxs("div",{className:"flex flex-wrap items-baseline gap-2",children:[t.jsx("span",{className:"text-sm font-semibold text-gray-800 dark:text-gray-100",children:"Bot overlap"}),t.jsx("span",{className:"text-[11px] text-gray-400",children:"where more than one bot reviews the same PR or line — distinct bot accounts, this window"})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-2 sm:grid-cols-4",children:[t.jsx(_l,{label:"PRs with ≥2 bots",value:String(s),sub:`${u}% of ${r} reviewed`}),t.jsx(_l,{label:"Same-line overlaps",value:String(c),sub:c>0?`across ${d} PR${d===1?"":"s"}`:"no collisions"})]}),t.jsxs("div",{className:"grid grid-cols-1 gap-3 lg:grid-cols-2",children:[t.jsx(jt,{title:"PRs by bot count",note:"how many bots touched each reviewed PR",children:t.jsx(Zf,{bins:a,color:n})}),t.jsx(jt,{title:"Most-overlapping bot pairs",note:"PRs both bots reviewed",children:i.length===0?t.jsx(Tt,{label:"No PR was reviewed by two bots"}):t.jsx("ul",{className:"space-y-1 py-1",children:i.slice(0,8).map(h=>t.jsxs("li",{className:"flex items-center gap-2 text-[11px]",children:[t.jsxs("span",{className:"w-40 shrink-0 truncate text-gray-600 dark:text-gray-300",title:`${h.aLabel} ↔ ${h.bLabel}`,children:[h.aLabel," ",t.jsx("span",{className:"text-gray-400",children:"↔"})," ",h.bLabel]}),t.jsx("span",{className:"h-2 rounded-full bg-sky-400/70",style:{width:`${h.prs/m*100}%`,minWidth:4}}),t.jsx("span",{className:"ml-auto shrink-0 tabular-nums text-gray-400",children:h.prs})]},`${h.aKey}-${h.bKey}`))})})]})]})}function yj(e){return e==="."?"(root)":e==="other"?"other":e}function kU({data:e,botColor:n}){const[r,s]=Xs(),[a,i]=f.useState(null),c=f.useMemo(()=>{const H=e.filter(ae=>ae.repos.some(we=>we.totalThreads>0)).slice(0,6);if(H.length===0)return null;const B=new Map;for(const ae of H)for(const we of ae.repos)for(const $e of we.dirs)$e.dir!=="other"&&B.set($e.dir,(B.get($e.dir)??0)+$e.count);const O=[...B.entries()].sort((ae,we)=>we[1]-ae[1]).slice(0,8).map(([ae])=>ae),E=new Map(O.map((ae,we)=>[ae,we])),ee=ae=>ae==="other"?De.gray:Xl[(E.get(ae)??0)%Xl.length],K=[],U=[];let Q=!1;for(const ae of H){const we=n({login:ae.login,kind:ae.kind}),$e=K.length;for(const Fe of ae.repos.slice(0,5)){const oe=new Map;let re=0;for(const le of Fe.dirs)E.has(le.dir)?oe.set(le.dir,(oe.get(le.dir)??0)+le.count):re+=le.count;const X=O.filter(le=>oe.has(le)).map(le=>({dir:le,count:oe.get(le),color:ee(le)}));re>0&&(X.push({dir:"other",count:re,color:De.gray}),Q=!0),K.push({botLabel:ae.label,botColor:we,repoName:Fe.repoName.split("/").pop()??Fe.repoName,repoFull:Fe.repoName,segments:X,total:Fe.totalThreads})}U.push({label:ae.label,color:we,start:$e,count:K.length-$e})}if(K.length===0)return null;const J=new Set(K.map(ae=>ae.repoFull)).size<=1,ne=[...O.map(ae=>({dir:ae,color:ee(ae)})),...Q?[{dir:"other",color:De.gray}]:[]];return{columns:K,groups:U,singleRepo:J,legend:ne}},[e,n]);if(!c)return null;const{columns:d,groups:u,singleRepo:m,legend:h}=c,g=210,x=30,y=8,b=8,w=m?42:56,k=Math.max(s-x-y,1),j=g-b-w,N=b+j,I=zp(Math.max(1,...d.map(H=>H.total))),S=H=>b+j*(1-H/I),T=.8,$=.14,P=new Set(u.map(H=>H.start)),C=d.map((H,B)=>B===0?0:m||P.has(B)?T:$),L=d.length+C.reduce((H,B)=>H+B,0),F=k/Math.max(L,1),M=[];let D=x;d.forEach((H,B)=>{D+=C[B]*F,M.push(D),D+=F});const A=Math.max(F*.82,1),W=H=>M[H]+(F-A)/2,z=H=>M[H]+F/2,te=H=>{const B=H.nativeEvent.offsetX;let O=0,E=1/0;d.forEach((ee,K)=>{const U=Math.abs(z(K)-B);U<E&&(E=U,O=K)}),i(O)};return t.jsxs(jt,{title:"Where bots work",note:m?"per bot: inline threads by codebase area":"per bot: inline threads by repo, split by codebase area",children:[t.jsxs("div",{ref:r,className:"relative",style:{height:g},children:[s>0&&t.jsxs("svg",{width:s,height:g,className:"block",children:[[0,I].map(H=>t.jsxs("g",{children:[t.jsx("line",{x1:x,y1:S(H),x2:s-y,y2:S(H),className:"decorative-mark text-gray-200 dark:text-gray-700",stroke:"currentColor",strokeWidth:1}),t.jsx("text",{x:x-4,y:S(H)+3,textAnchor:"end",className:"fill-gray-500 dark:fill-gray-400 text-[8px]",children:Sn(H)})]},H)),a!=null&&t.jsx("rect",{x:M[a],y:b,width:F,height:j,className:"text-gray-400/10 dark:text-gray-300/10",fill:"currentColor"}),d.map((H,B)=>{let O=0;return H.segments.map(E=>{const ee=S(O+E.count),K=S(O)-ee;return O+=E.count,t.jsx("rect",{x:W(B),y:ee,width:A,height:Math.max(K,0),fill:E.color},`${B}-${E.dir}`)})}),d.map((H,B)=>{const O=z(B),E=N+9;return t.jsx("text",{x:O,y:E,textAnchor:"end",transform:`rotate(-35 ${O} ${E})`,className:"fill-gray-500 dark:fill-gray-400 text-[8px]",children:m?H.botLabel:H.repoName},`lbl-${B}`)}),!m&&u.map(H=>{const B=W(H.start),O=W(H.start+H.count-1)+A,E=N+40;return t.jsxs("g",{children:[t.jsx("line",{x1:B,y1:E,x2:O,y2:E,stroke:H.color,strokeWidth:2}),t.jsx("text",{x:(B+O)/2,y:E+10,textAnchor:"middle",className:"text-[8px] font-medium",fill:H.color,children:H.label})]},`grp-${H.start}`)}),t.jsx("rect",{x:0,y:0,width:s,height:g,fill:"transparent",onMouseMove:te,onMouseLeave:()=>i(null)})]}),a!=null&&s>0&&(()=>{const H=d[a];return t.jsxs(Wi,{x:z(a),y:b,width:s,children:[t.jsxs("div",{className:"font-medium",children:[H.botLabel,!m&&t.jsxs("span",{className:"text-gray-400",children:[" · ",H.repoFull]})]}),H.segments.map(B=>t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("span",{className:"inline-block h-1.5 w-1.5 rounded-[1px]",style:{background:B.color}}),yj(B.dir),": ",Sn(B.count)]},B.dir)),t.jsxs("div",{className:"mt-0.5 border-t border-gray-200 pt-0.5 dark:border-gray-700",children:["total: ",Sn(H.total)]})]})})()]}),t.jsx("div",{className:"mt-1 flex flex-wrap gap-x-2 gap-y-0.5",children:h.map(H=>t.jsxs("span",{className:"flex items-center gap-1 text-[9px] text-gray-500 dark:text-gray-400",children:[t.jsx("span",{className:"inline-block h-2 w-2 rounded-[2px]",style:{background:H.color}}),yj(H.dir)]},H.dir))})]})}function wU({workspaceId:e,window:n,repoScope:r,windowLabel:s}){const{data:a,isLoading:i,isPlaceholderData:c,isError:d}=L9(e,n,!0,r),u=i||c,m=f.useMemo(()=>dU((a==null?void 0:a.buckets)??[]),[a==null?void 0:a.buckets]),h=f.useMemo(()=>[{key:"avg",label:"Bot comments per merged PR",color:De.blue,values:m.rows.map(w=>w.avg)}],[m.rows]),g=f.useMemo(()=>[{key:"density",label:"Bot comments per 100 lines",color:De.purple,values:m.rows.map(w=>w.density)}],[m.rows]);if(d)return null;if(u)return t.jsx("div",{className:"h-40 animate-pulse rounded-lg border border-gray-200 bg-gray-50 dark:border-gray-800 dark:bg-gray-900/40"});if(m.rows.length===0)return null;const x=m.rows.map(w=>w.label),y=mU((a==null?void 0:a.sizedPrs)??0,(a==null?void 0:a.unsizedPrs)??0),b=a!=null&&a.scanTruncated?" · newest PRs only (scan capped)":"";return t.jsxs(jt,{title:"PR size vs bot comment volume",note:`merged PRs only · ${s} · by lines changed (added + deleted)${b}`,children:[m.hasComments?t.jsxs("div",{className:"grid grid-cols-1 gap-3 lg:grid-cols-2",children:[t.jsxs("div",{children:[t.jsxs("div",{className:"mb-0.5 text-[10px] font-medium text-gray-600 dark:text-gray-300",children:["Per merged PR ",t.jsx("span",{className:"font-normal text-gray-400",children:"— rises with size"})]}),t.jsx(Lr,{labels:x,series:h,height:140,formatY:Xf,formatValue:uU})]}),t.jsxs("div",{children:[t.jsxs("div",{className:"mb-0.5 text-[10px] font-medium text-gray-600 dark:text-gray-300",children:["Per 100 lines"," ",t.jsx("span",{className:"font-normal text-gray-400",children:"— falls, usually by a lot"})]}),t.jsx(Lr,{labels:x,series:g,height:140,formatY:Xf,formatValue:hU})]})]}):t.jsx(Tt,{label:"No bot comments on the PRs that merged in this window"}),t.jsxs("div",{className:"mt-2 flex flex-wrap gap-x-4 gap-y-0.5 text-[10px] text-gray-500 dark:text-gray-400",children:[t.jsx("span",{className:"text-gray-400",children:"Merged PRs behind each bar:"}),m.rows.map(w=>t.jsxs("span",{children:[w.label," · ",t.jsx("span",{className:"font-medium",children:pU(w.prs)})]},w.label))]}),m.emptyLabels.length>0&&t.jsxs("div",{className:"mt-1 text-[10px] text-gray-400",children:["No merged PR of this size in this window: ",m.emptyLabels.join(", ")," — those bands are left off the axis rather than drawn as a zero."]}),y&&t.jsx("div",{className:"mt-1 text-[10px] text-gray-400",children:y}),t.jsxs("div",{className:"mt-1 text-[10px] text-gray-400",children:[t.jsxs("span",{className:"font-medium text-amber-600 dark:text-amber-400",children:[t.jsx(Jt,{size:10,className:"mr-0.5 inline-block align-[-0.1em]"}),"A correlation, not a rule — and it is repo-dependent."]})," ","Across the five repos we measured this on, log-LOC against bot-comment count ran 0.62 and 0.54 on two heavily-configured repos, then 0.15, 0.13 and 0.03 on three others: where a bot is lightly configured it says roughly the same amount whatever the diff size, and size predicts nothing at all. Read this as the shape of ",t.jsx("em",{children:"this"})," scope in"," ",t.jsx("em",{children:"this"})," window — several repos and every bot in the workspace are pooled here, so a workspace whose repos are configured differently blends them into one curve. Counts every review comment, PR comment and review body an automated reviewer wrote (a wider definition than the ROI table’s “Comments”), on PRs that ",t.jsx("em",{children:"merged"})," in the window."]})]})}function jU({repoId:e}={}){var y;const[n,r]=f.useState(!1),s=G(b=>b.botAnalyticsWindow),a=G(b=>b.workspaceId),i=f.useMemo(()=>e!=null?[e]:null,[e]),c=co(a),{botDepth:d}=vt(),{data:u,isLoading:m,isError:h}=uC(a,s,n,i),g=(u==null?void 0:u.bots)??[],x=((y=Yf.find(b=>b.key===s))==null?void 0:y.label)??"";return d?t.jsxs("div",{className:"space-y-3","data-testid":"workspace-bot-charts",children:[t.jsxs("button",{type:"button",onClick:()=>r(b=>!b),"aria-expanded":n,className:"inline-flex items-center gap-1 text-[11px] font-medium text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200",children:[t.jsx(Mt,{dir:n?"down":"right",size:11}),"Workspace charts — cross-bot trends, overlap and coverage"]}),n&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"text-[11px] text-gray-400",children:["How your review bots behave over time — deterministic, no AI. Red rings & underlines mark where a bot diverged from its ",t.jsx("span",{className:"font-medium",children:"own"})," typical (a self-baseline). Times are UTC; activity gaps are inferred (not a direct rate-limit signal). Per-bot depth lives on each bot’s own tab — the “Depth →” pill on the ROI table. Window: the ROI picker’s (",x,")."]}),m?t.jsx("div",{className:"h-40 animate-pulse rounded-lg border border-gray-200 bg-gray-50 dark:border-gray-800 dark:bg-gray-900/40"}):h?t.jsx("div",{className:"text-sm text-red-500",children:"Couldn’t load bot behaviour analytics."}):g.length===0?t.jsxs("div",{className:"rounded-lg border border-dashed border-gray-300 p-6 text-center text-sm text-gray-400 dark:border-gray-700",children:["No automated-reviewer activity in this window.",t.jsx("div",{className:"mt-1 text-[11px]",children:"When review bots (CodeRabbit, Copilot, in-house AI…) review your PRs, their latency and cadence land here. A bot that was active earlier may just be quiet — try widening the window above."})]}):t.jsxs(t.Fragment,{children:[t.jsx(jt,{title:"Findings density",note:"threads a bot opens per PR / KLoC · weekly · log scale · lower = cleaner · hover a ring for why",children:t.jsx(fU,{bots:g,botColor:c})}),t.jsx(wU,{workspaceId:a,window:s,repoScope:i,windowLabel:x}),(u==null?void 0:u.overlap)!=null&&t.jsx(vU,{overlap:u.overlap,color:c({login:null,kind:"in_house"})}),(u==null?void 0:u.repoBotDirs)!=null&&u.repoBotDirs.length>0&&t.jsx(kU,{data:u.repoBotDirs,botColor:c})]})]})]}):null}function NU(e,n,r,s){return Oe({queryKey:["bot-themes",e,dt(r),Vr(s)],queryFn:r==null?Ct:()=>he.botThemes(e,r,s),enabled:n,staleTime:6e4})}const SU=5e3;function CU(e,n,r){const s=He(),[a,i]=f.useState(null);f.useEffect(()=>{if(a==null)return;const m=globalThis.setTimeout(()=>i(null),SU);return()=>globalThis.clearTimeout(m)},[a]);const c=["bot-themes-refresh",e,dt(n),Vr(r)],d=tt({mutationKey:c,mutationFn:()=>{if(n==null)throw new Error("No workspace selected");return he.botThemesRefresh(e,n,r)},onSuccess:m=>{s.setQueryData(["bot-themes",e,dt(n),Vr(r)],m),s.invalidateQueries({queryKey:["ai-usage"]}),i(m.creditsExhausted?"Out of AI credits this month — the summary resumes on the 1st.":m.empty?m.result!=null?"No bot comments in this scope / window any more — showing the last report.":"No review-bot comments in this scope / window yet.":m.throttled?"A summary is already generating — showing the latest shortly.":null)}}),u=Or({mutationKey:c})>0;return Object.assign(d,{notice:a,busy:u})}function RU({result:e}){return e.bots.length===0?null:t.jsxs("div",{className:"mt-3",children:[t.jsx("div",{className:"mb-1 text-[11px] font-semibold uppercase tracking-wide text-gray-500 dark:text-gray-400",children:"By reviewer"}),t.jsx("div",{className:"space-y-1",children:e.bots.map(n=>t.jsxs("div",{className:"flex items-center gap-2 text-[11px]",children:[t.jsx("span",{className:"min-w-0 flex-1 truncate text-gray-700 dark:text-gray-200",children:n.label}),t.jsxs("span",{className:"shrink-0 tabular-nums text-gray-500 dark:text-gray-400",children:[n.comments," comment",n.comments===1?"":"s"]}),t.jsx("span",{className:"w-16 shrink-0 text-right tabular-nums text-gray-400",title:"Share of this reviewer's threads later resolved or likely-addressed (approximate)",children:n.actedOnPct!=null?`${n.actedOnPct}% acted`:"—"})]},n.key))})]})}function IU({result:e}){const n=e.coverage;return t.jsxs("div",{className:"mt-3 border-t border-ai-hairline pt-2 text-[10px] text-gray-400",children:["Summarised ",n.deduped.toLocaleString()," distinct ",n.deduped===1?"point":"points"," from"," ",n.totalComments.toLocaleString()," bot comment",n.totalComments===1?"":"s",n.analyzed<n.deduped?` (top ${n.analyzed.toLocaleString()} analysed)`:"",n.truncated?" · older comments beyond the cap were excluded":"",". Generated"," ",new Date(e.generatedAt).toLocaleString(),"."]})}function TU({repoIds:e}){var y,b;const{activityDigest:n}=vt(),r=G(w=>w.botAnalyticsWindow),s=G(w=>w.workspaceId),a=Ge(w=>w.openPrDetailTab),i=G(w=>w.openThemeThreadsDetail),c=NU(r,n,s,e),d=CU(r,s,e),u=ei(n),m=((y=u.data)==null?void 0:y.summaryTurnLimit)!=null&&(u.data.summaryTurnsRemaining??0)<=0;if(!n)return null;const h=c.data;if(c.isError||h!=null&&!h.enabled)return null;const g=(h==null?void 0:h.result)??null,x=d.busy;return t.jsxs("div",{className:"rounded-lg border border-ai-border bg-ai-surface p-4","data-testid":"bot-themes-panel",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsxs("span",{className:"text-base font-semibold text-gray-800 dark:text-gray-100",children:[t.jsx(eo,{size:15,className:"inline-block align-[-0.1em]"})," What they’re flagging"]}),t.jsx("span",{className:"shrink-0 rounded bg-ai-signal/10 px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-ai-signal",children:"Pro"}),t.jsx("button",{type:"button",onClick:()=>d.mutate(),disabled:x||m||s==null,className:"ml-auto rounded bg-ai-signal px-3 py-1 text-[11px] font-semibold text-white hover:opacity-90 disabled:opacity-50 dark:text-gray-950",title:m?"Out of AI credits — resets next month":"Summarise what the review bots are flagging in this scope (runs the Haiku model; unchanged comments cost nothing)",children:x?"Summarising…":g?t.jsxs(t.Fragment,{children:[t.jsx(us,{size:11,className:"mr-1 inline-block align-[-0.1em]"}),"Regenerate"]}):"Generate"})]}),t.jsx("p",{className:"mt-1 text-xs text-gray-500 dark:text-gray-400",children:"A qualitative read of what your automated reviewers keep flagging — the recurring themes, how critical they are, and where they cluster. Themes are an AI read (approximate); the volumes, per-theme comment counts and “where” are exact."}),d.isError&&t.jsx("div",{className:"mt-2 text-[11px] text-red-500",children:((b=d.error)==null?void 0:b.message)??"Couldn’t generate the summary."}),!d.isError&&d.notice&&t.jsx("div",{className:"mt-2 text-[11px] text-gray-400",children:d.notice}),m&&t.jsx("div",{className:"mt-2 text-[11px] text-amber-600 dark:text-amber-400",children:"Out of AI credits this month — the summary resumes on the 1st. Any existing summary still shows."}),x&&!g?t.jsx(zC,{}):c.isLoading?t.jsx("div",{className:"mt-3 h-24 animate-pulse rounded bg-ai-surface-2"}):g?t.jsx("div",{className:"digest-fade-in",children:t.jsx(KC,{narrative:g.narrative,themes:g.themes,bySeverity:g.bySeverity,byArea:g.byArea,ActorIcon:Lt,emptyThemesLabel:"No distinct themes surfaced from the bot comments in this window.",reviewerSection:t.jsx(RU,{result:g}),coverageLine:t.jsx(IU,{result:g}),onOpenPr:w=>a(fa(w),{fromActivity:!0}),onOpenTheme:w=>i(w,"bot")})},g.generatedAt):t.jsx("div",{className:"mt-3 flex items-center justify-between gap-2 rounded-md border border-dashed border-ai-border p-3 text-[12px] text-gray-500 dark:text-gray-400",children:t.jsx("span",{children:"No summary yet — generate one to see what your review bots are flagging."})})]})}function $U(e){return["advisor-findings",dt(e)]}function _U(e,n=!0){return Oe({queryKey:$U(e),queryFn:e==null?Ct:()=>he.advisorFindings(e),enabled:n,staleTime:6e4,gcTime:fn})}function PU(e,n,r=!0){return Oe({queryKey:["advisor-effect",dt(e),n??"none"],queryFn:e==null||n==null?Ct:()=>he.advisorEffect(e,n),enabled:r&&n!=null,staleTime:5*6e4,gcTime:fn})}function EU(e,n,r,s){return Oe({queryKey:["advisor-brief",dt(e),n??"all",[...r].sort().join(",")],queryFn:e==null?Ct:()=>he.advisorBrief(e,n??void 0,r),enabled:s,staleTime:6e4})}function em(e){e.invalidateQueries({queryKey:["advisor-findings"]}),e.invalidateQueries({queryKey:["advisor-effect"]})}function AU(e){const n=He();return tt({mutationFn:r=>e==null?Promise.reject(new Error("no workspace")):he.advisorDismiss(e,r),onSuccess:()=>em(n)})}function MU(e){const n=He();return tt({mutationFn:r=>e==null?Promise.reject(new Error("no workspace")):he.advisorFileIssue(e,r),onSuccess:()=>em(n)})}function gR(e){return["advisor-config-pr",e]}function LU(e,n){const r=He();return tt({mutationKey:gR(n),mutationFn:s=>e==null?Promise.reject(new Error("no workspace")):he.advisorConfigPr(e,s),onSuccess:()=>em(r)})}function FU(e,n){return tt({mutationKey:["advisor-preview",n],mutationFn:r=>e==null?Promise.reject(new Error("no workspace")):he.advisorPreview(e,r)})}function OU(){const e=He();return tt({mutationFn:n=>he.advisorPutProfile(n.botUserId,n.body),onSuccess:()=>em(e)})}const fR={SUPPRESS_PATH:"Suppress path",QUIET_PATH_NITS:"Quiet nits on path",SUPPRESS_CATEGORY:"Suppress category",LOWER_VERBOSITY:"Raise severity floor",SCOPE_OFF:"Narrow overlap",AMPLIFY_PATH:"Amplify path",ESCALATE:"Escalate category",PROMOTE_TO_LINT:"Promote to lint",BOOTSTRAP_CONFIG:"Bootstrap config"},DU={dismissed:{label:"Dismissed",className:"bg-gray-500/10 text-gray-500 dark:text-gray-400 border border-gray-400/40"},pr_opened:{label:"PR open",className:"bg-sky-500/10 text-sky-700 dark:text-sky-300 border border-sky-500/30"},pr_merged:{label:"PR merged",className:"bg-green-500/10 text-green-700 dark:text-green-300 border border-green-500/30"},issue_filed:{label:"Issue filed",className:"bg-ai-signal/10 text-ai-signal border border-ai-signal/30"},superseded:{label:"Superseded",className:"bg-gray-500/10 text-gray-500 dark:text-gray-400 border border-gray-400/40"}};function BU({intent:e,rec:n,checked:r,onToggle:s,onDismiss:a}){const i=e.evidence,c=n?DU[n.status]:null;return t.jsxs("div",{className:"rounded-lg border border-gray-200 p-2.5 dark:border-gray-800",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("input",{type:"checkbox",checked:r,onChange:s,disabled:(n==null?void 0:n.status)==="dismissed",title:"Include this recommendation in the output"}),t.jsx("span",{className:"inline-block rounded bg-amber-500/10 px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-amber-700 dark:text-amber-300",children:fR[e.kind]??e.kind}),t.jsx("code",{className:"text-[11px] text-gray-600 dark:text-gray-300",children:e.targetKey}),c&&t.jsx("span",{className:`inline-block rounded px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide ${c.className}`,children:c.label}),(n==null?void 0:n.prUrl)&&t.jsxs("a",{href:n.prUrl,target:"_blank",rel:"noreferrer",className:"text-[11px] text-sky-600 hover:underline dark:text-sky-300",children:["PR #",n.prNumber]}),(n==null?void 0:n.issueUrl)&&t.jsx("a",{href:n.issueUrl,target:"_blank",rel:"noreferrer",className:"text-[11px] text-ai-signal hover:underline",children:"issue"}),t.jsx("button",{type:"button",onClick:a,className:"ml-auto rounded border border-gray-300 px-1.5 py-0.5 text-[10px] text-gray-500 hover:bg-gray-100 dark:border-gray-700 dark:text-gray-400 dark:hover:bg-gray-900/60",title:"Record a dismissal — the recommendation stops resurfacing as new",children:"Dismiss"})]}),t.jsx("div",{className:"mt-1.5 text-[11px] text-gray-600 dark:text-gray-300",children:e.rationale}),t.jsxs("div",{className:"mt-1 text-[11px] text-gray-500 dark:text-gray-400",children:["Evidence: ",i.volume," ",e.kind==="SUPPRESS_CATEGORY"||e.kind==="ESCALATE"?"findings":"threads"," ·"," ",i.actedOn," acted on",i.threadLinked!=null?` (of ${i.threadLinked} thread-linked)`:""," · ",i.untouched," untouched",(i.mergedUntouched??0)>0?` (${i.mergedUntouched} merged past)`:""," ·"," ",i.overdueUntouched," overdue",i.dissent>0?` · ${i.dissent} pushback`:""]}),e.retro.applicable&&t.jsx("div",{className:`mt-1 text-[11px] ${e.retro.computable?"text-gray-500 dark:text-gray-400":"text-amber-700 dark:text-amber-300"}`,title:e.retro.disclosure,children:e.retro.computable?`Retro-check: would also hide ${e.retro.wouldHideActedOn} acted-on (${e.retro.wouldHideActedOnHigh} high-severity) of ${e.retro.wouldHideTotal}.`:"Retro-check not computable — config PR blocked; use the brief."})]})}function WU({botUserId:e}){const n=G(d=>d.workspaceId),{data:r,isLoading:s}=PU(n,e);if(s)return t.jsx("div",{className:"text-[11px] text-gray-400",children:"Loading effect panel…"});if(!r)return t.jsx("div",{className:"text-[11px] text-gray-400",children:"No effect data."});const{panel:a,anchors:i}=r,c=d=>d==null?"—":String(d);return t.jsxs("div",{className:"space-y-1.5 text-[11px] text-gray-600 dark:text-gray-300",children:[a.anchor&&a.before&&a.after?t.jsxs("table",{className:"border-collapse",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"text-left text-[10px] uppercase tracking-wide text-gray-400",children:[t.jsx("th",{className:"pr-3"}),t.jsx("th",{className:"pr-3",children:"Before"}),t.jsx("th",{children:"After"})]})}),t.jsxs("tbody",{children:[t.jsxs("tr",{children:[t.jsx("td",{className:"pr-3",children:"Volume / week"}),t.jsx("td",{className:"pr-3",children:c(a.before.volumePerWeek)}),t.jsx("td",{children:c(a.after.volumePerWeek)})]}),t.jsxs("tr",{children:[t.jsx("td",{className:"pr-3",children:"Nit share %"}),t.jsx("td",{className:"pr-3",children:c(a.before.nitSharePct)}),t.jsx("td",{children:c(a.after.nitSharePct)})]}),t.jsxs("tr",{children:[t.jsx("td",{className:"pr-3",children:"Acted-on %"}),t.jsx("td",{className:"pr-3",children:c(a.before.actedOnPct)}),t.jsx("td",{children:c(a.after.actedOnPct)})]}),t.jsxs("tr",{children:[t.jsx("td",{className:"pr-3",children:"High-sev median (h)"}),t.jsx("td",{className:"pr-3",children:c(a.before.highSeverityMedianHours)}),t.jsx("td",{children:c(a.after.highSeverityMedianHours)})]})]})]}):a.changepoints.length>0?t.jsx("ul",{className:"list-disc pl-4",children:a.changepoints.map(d=>{var u;return t.jsxs("li",{children:[d.series,": ",d.beforeMedian," → ",d.afterMedian," around"," ",(u=a.weekStarts[d.weekIndex])==null?void 0:u.slice(0,10)," (",d.direction,", unattributed — no recorded config change)"]},`${d.series}-${d.weekIndex}`)})}):t.jsx("div",{children:"No anchor and no detected change — record a config change (or open a tuning PR) and this panel splits before/after around it."}),i.length>0&&t.jsxs("div",{className:"text-[10px] text-gray-400",children:["Anchors: ",i.map(d=>`${new Date(d.ms).toISOString().slice(0,10)} (${d.source})`).join(" · ")]})]})}function qU({bot:e,overlay:n}){const r=G(g=>g.workspaceId),s=OU(),a=(n==null?void 0:n.profile)??null,[i,c]=f.useState((a==null?void 0:a.configPath)??""),[d,u]=f.useState((a==null?void 0:a.ownerRepo)??""),[m,h]=f.useState((a==null?void 0:a.notes)??"");return r==null?t.jsx("div",{}):t.jsxs("div",{className:"space-y-1.5 text-[11px]",children:[t.jsxs("div",{className:"text-gray-500 dark:text-gray-400",children:["Asked once, kept forever: where ",e.label," is configured and who owns it. The config path unlocks prose tuning for bots with no known adapter; the owner repo is where “File issue” sends the brief."]}),t.jsxs("label",{className:"block",children:[t.jsx("span",{className:"text-gray-500 dark:text-gray-400",children:"Config file path (in your repo)"}),t.jsx("input",{value:i,onChange:g=>c(g.target.value),placeholder:".github/my-bot-prompt.md",className:"mt-0.5 w-full rounded border border-gray-300 bg-white px-2 py-1 text-[11px] dark:border-gray-700 dark:bg-gray-950"})]}),t.jsxs("label",{className:"block",children:[t.jsx("span",{className:"text-gray-500 dark:text-gray-400",children:"Bot's own repo (owner/name — the issue target)"}),t.jsx("input",{value:d,onChange:g=>u(g.target.value),placeholder:"acme/review-bot",className:"mt-0.5 w-full rounded border border-gray-300 bg-white px-2 py-1 text-[11px] dark:border-gray-700 dark:bg-gray-950"})]}),t.jsxs("label",{className:"block",children:[t.jsx("span",{className:"text-gray-500 dark:text-gray-400",children:"Notes"}),t.jsx("input",{value:m,onChange:g=>h(g.target.value),className:"mt-0.5 w-full rounded border border-gray-300 bg-white px-2 py-1 text-[11px] dark:border-gray-700 dark:bg-gray-950"})]}),t.jsx("button",{type:"button",disabled:s.isPending,onClick:()=>s.mutate({botUserId:e.botUserId,body:{workspaceId:r,configPath:i.trim()||null,ownerRepo:d.trim()||null,notes:m.trim()||null}}),className:"rounded border border-sky-400 px-2 py-0.5 text-[11px] font-medium text-sky-700 hover:bg-sky-50 dark:border-sky-600/70 dark:text-sky-300 dark:hover:bg-sky-950/40",children:s.isPending?"Saving…":"Save profile"}),s.isError&&t.jsx("div",{className:"text-red-600 dark:text-red-400",children:s.error.message})]})}function UU({path:e,text:n}){const r=f.useMemo(()=>_M(n,Yl(e)),[n,e]),s="max-h-72 overflow-auto whitespace-pre-wrap rounded border border-gray-200 bg-gray-50 p-2 text-[11px] text-gray-700 dark:border-gray-800 dark:bg-gray-900/40 dark:text-gray-300";return r!=null?t.jsx("pre",{className:`code-hl ${s}`,dangerouslySetInnerHTML:{__html:r}}):t.jsx("pre",{className:s,children:n})}function HU({bot:e,overlay:n,intents:r,recsByKey:s,repos:a,firstPrMerged:i}){var z,te;const c=G(H=>H.workspaceId),d=ds(e.kind),[u,m]=f.useState(new Set),[h,g]=f.useState(i?"pr":"brief"),[x,y]=f.useState(((z=a[0])==null?void 0:z.id)??null),[b,w]=f.useState(!1),k=AU(c),j=MU(c),N=LU(c,e.botUserId),I=FU(c,e.botUserId),S=Or({mutationKey:gR(e.botUserId)})>0,T=r.filter(H=>{var B;return((B=s.get(H.dedupeKey))==null?void 0:B.status)!=="dismissed"}),$=T.filter(H=>!u.has(H.dedupeKey)).map(H=>H.dedupeKey),P=`${x??""}|${[...$].sort().join(",")}`,C=f.useRef(P),L=I.reset;f.useEffect(()=>{C.current!==P&&(C.current=P,L())},[P,L]);const F=EU(c,e.botUserId,$,b&&$.length>0),M=(n==null?void 0:n.adapterKey)!=null,D=((te=n==null?void 0:n.profile)==null?void 0:te.ownerRepo)??null,A=T.some(H=>$.includes(H.dedupeKey)&&H.retro.applicable&&!H.retro.computable),W=N.data??null;return t.jsxs("div",{className:"space-y-2 rounded-lg border border-gray-200 p-3 dark:border-gray-800",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsxs("span",{className:"inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[12px] font-medium",style:{...pn(d.color),background:`${d.color}1a`},children:[t.jsx(Lt,{size:11}),e.label]}),t.jsx("span",{className:"text-[11px] text-gray-500 dark:text-gray-400",children:M?`${n.adapterName} · ${n.configTargets.map(H=>H.path).join(", ")}`:"no config surface known — the brief is the output"}),e.pathCoveragePct!=null&&t.jsxs("span",{className:"text-[10px] text-gray-400",title:"Only review-comment labels can carry a file path; path-keyed findings describe only this share of the bot's scored output.",children:["path coverage ",e.pathCoveragePct,"%"]})]}),t.jsx("div",{className:"space-y-1.5",children:r.map(H=>t.jsx(BU,{intent:H,rec:s.get(H.dedupeKey),checked:$.includes(H.dedupeKey),onToggle:()=>m(B=>{const O=new Set(B);return O.has(H.dedupeKey)?O.delete(H.dedupeKey):O.add(H.dedupeKey),O}),onDismiss:()=>k.mutate(H.dedupeKey)},H.dedupeKey))}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2 border-t border-gray-100 pt-2 dark:border-gray-800/60",children:[t.jsx("div",{role:"tablist",className:"flex gap-1",children:[{key:"brief",label:"Brief"},...M?[{key:"pr",label:"Config PR"}]:[],{key:"issue",label:"File issue"}].map(H=>t.jsx("button",{type:"button",onClick:()=>{g(H.key),H.key==="brief"&&w(!0)},title:H.key==="brief"?"Render the selected recommendations as a markdown brief (nothing is stored or posted)":void 0,className:`rounded border px-2 py-0.5 text-[11px] font-medium ${h===H.key?"border-sky-400 text-sky-700 dark:border-sky-600/70 dark:text-sky-300":"border-gray-300 text-gray-500 hover:bg-gray-100 dark:border-gray-700 dark:text-gray-400 dark:hover:bg-gray-900/60"}`,children:H.label},H.key))}),h==="brief"&&b&&$.length===0&&t.jsx("span",{className:"text-[11px] text-gray-400",children:"Select at least one recommendation to render."}),h==="brief"&&b&&F.isFetching&&t.jsx("span",{className:"text-[11px] text-gray-400",children:"Rendering…"}),h==="pr"&&M&&t.jsxs(t.Fragment,{children:[a.length>1&&t.jsx("select",{value:x??"",onChange:H=>y(Number(H.target.value)),className:"rounded border border-gray-300 bg-white px-1.5 py-0.5 text-[11px] dark:border-gray-700 dark:bg-gray-950",title:"The repo whose config the PR edits",children:a.map(H=>t.jsx("option",{value:H.id,children:H.fullName},H.id))}),t.jsx("button",{type:"button",disabled:I.isPending||$.length===0||x==null||A,title:A?"A selected suppression has no computable retro-check — the config PR (and its preview) is blocked; use the brief.":"Dry-run: show the exact config file(s) the PR would commit, without writing anything",onClick:()=>{x!=null&&I.mutate({repoId:x,botUserId:e.botUserId,dedupeKeys:$})},className:"rounded border border-gray-300 px-2 py-0.5 text-[11px] font-medium text-gray-600 disabled:opacity-50 hover:bg-gray-100 dark:border-gray-700 dark:text-gray-300 dark:hover:bg-gray-900/60",children:I.isPending?"Previewing…":"Preview changes"}),t.jsx("button",{type:"button",disabled:S||$.length===0||x==null||A,title:A?"A selected suppression has no computable retro-check — the config PR is blocked; use the brief.":"Open a PR with the additive config change (reviewed before merge — nothing auto-applies)",onClick:()=>{x!=null&&N.mutate({repoId:x,botUserId:e.botUserId,dedupeKeys:$})},className:"rounded border border-sky-400 px-2 py-0.5 text-[11px] font-medium text-sky-700 disabled:opacity-50 dark:border-sky-600/70 dark:text-sky-300",children:S?"Opening PR…":"Open config PR"})]}),h==="issue"&&t.jsx("button",{type:"button",disabled:j.isPending||$.length===0||!D,title:D?`Files the brief as an issue on ${D}`:"Set the bot's own repo in its profile first",onClick:()=>{const H=$[0];H&&j.mutate(H)},className:"rounded border border-ai-border px-2 py-0.5 text-[11px] font-medium text-ai-signal hover:border-ai-signal/60 hover:bg-ai-surface-2 disabled:opacity-50",children:j.isPending?"Filing…":`File issue${D?` → ${D}`:""}`})]}),W&&t.jsxs("div",{className:"rounded border border-green-500/30 bg-green-500/5 px-2 py-1.5 text-[11px] text-green-700 dark:text-green-300",children:["Opened"," ",t.jsxs("a",{href:W.url,target:"_blank",rel:"noreferrer",className:"underline",children:["PR #",W.prNumber]}),W.visible?".":" — it'll show up here shortly."]}),N.isError&&t.jsx("div",{className:"text-[11px] text-red-600 dark:text-red-400",children:N.error.message}),h==="pr"&&I.isError&&t.jsxs("div",{className:"text-[11px] text-red-600 dark:text-red-400",children:["Preview failed: ",I.error.message]}),h==="pr"&&I.data&&t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"text-[11px] text-gray-500 dark:text-gray-400",children:["Would open ",t.jsx("span",{className:"font-medium",children:I.data.title})," on branch"," ",t.jsx("code",{children:I.data.branch})," — nothing has been written yet."]}),t.jsx("div",{className:"flex flex-wrap gap-1.5",children:I.data.applied.map((H,B)=>t.jsxs("span",{title:H.note,className:`inline-block rounded px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide ${H.status==="applied"?"bg-green-500/10 text-green-700 dark:text-green-300":H.status==="degraded"?"bg-amber-500/10 text-amber-700 dark:text-amber-300":"bg-gray-500/10 text-gray-500 dark:text-gray-400"}`,children:[fR[H.intentKind]??H.intentKind," · ",H.status]},`${H.intentKind}-${H.targetKey}-${B}`))}),I.data.files.map(H=>t.jsxs("div",{className:"space-y-1",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("code",{className:"text-[11px] font-medium text-gray-700 dark:text-gray-200",children:H.path}),t.jsx("span",{className:"text-[10px] text-gray-400",children:H.before==null?"new file":"edits the existing file — additive; nothing outside our entries changes"}),t.jsx("button",{type:"button",onClick:()=>void navigator.clipboard.writeText(H.after),title:"Copy the generated file content",className:"rounded border border-gray-300 px-1.5 py-0.5 text-[10px] text-gray-500 hover:bg-gray-100 dark:border-gray-700 dark:text-gray-400 dark:hover:bg-gray-900/60",children:"Copy"})]}),t.jsx(UU,{path:H.path,text:H.after})]},H.path))]}),j.isError&&t.jsx("div",{className:"text-[11px] text-red-600 dark:text-red-400",children:j.error.message}),j.data&&t.jsxs("div",{className:"text-[11px] text-ai-signal",children:["Filed"," ",t.jsx("a",{href:j.data.issueUrl,target:"_blank",rel:"noreferrer",className:"underline",children:j.data.issueUrl})]}),h==="brief"&&b&&F.isError&&t.jsxs("div",{className:"text-[11px] text-red-600 dark:text-red-400",children:["Brief failed: ",F.error.message]}),h==="brief"&&b&&F.data&&t.jsxs("div",{className:"space-y-1",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wide text-gray-400",children:"Brief (markdown)"}),t.jsx("button",{type:"button",onClick:()=>{var H;return void navigator.clipboard.writeText(((H=F.data)==null?void 0:H.markdown)??"")},title:"Copy the markdown — paste it into a doc, a Slack thread, or the bot vendor's support form",className:"rounded border border-gray-300 px-1.5 py-0.5 text-[10px] text-gray-500 hover:bg-gray-100 dark:border-gray-700 dark:text-gray-400 dark:hover:bg-gray-900/60",children:"Copy"})]}),t.jsx("pre",{className:"max-h-96 overflow-auto whitespace-pre-wrap rounded border border-gray-200 bg-gray-50 p-2 text-[11px] text-gray-700 dark:border-gray-800 dark:bg-gray-900/40 dark:text-gray-300",children:F.data.markdown})]}),t.jsxs("details",{children:[t.jsx("summary",{className:"cursor-pointer text-[11px] text-gray-500 dark:text-gray-400",children:"Effect panel (before/after a config change)"}),t.jsx("div",{className:"mt-1.5",children:t.jsx(WU,{botUserId:e.botUserId})})]}),t.jsxs("details",{children:[t.jsxs("summary",{className:"cursor-pointer text-[11px] text-gray-500 dark:text-gray-400",children:["Profile",n!=null&&n.profile?"":" (unanswered)"]}),t.jsx("div",{className:"mt-1.5",children:t.jsx(qU,{bot:e,overlay:n})})]})]})}function zU(){const e=G(I=>I.workspaceId),n=G(I=>I.advisorFocus),r=G(I=>I.clearAdvisorFocus),{botAdvisor:s}=vt(),{data:a,isLoading:i,error:c}=_U(e,s),{data:d}=xn(),u=f.useMemo(()=>(d??[]).filter(I=>I.workspaceId===e),[d,e]),[m,h]=f.useState(null),g=(n==null?void 0:n.botKey)??m;if(!s)return t.jsx("div",{});if(i)return t.jsx("div",{className:"p-3 text-xs text-gray-400",children:"Computing advisor findings…"});if(c||!a)return t.jsxs("div",{className:"p-3 text-xs text-red-600 dark:text-red-400",children:["Advisor findings unavailable",c?`: ${c.message}`:"","."]});const x=new Map;for(const I of a.intents){const S=x.get(I.botUserId)??[];S.push(I),x.set(I.botUserId,S)}const y=new Map(a.recommendations.map(I=>[I.dedupeKey,I])),b=new Map(a.overlays.map(I=>[I.botUserId,I])),w=a.payload.bots.filter(I=>x.has(I.botUserId)),k=a.recommendations.some(I=>I.status==="pr_merged"),j=g?w.filter(I=>I.key===g):w,N=n?a.payload.bots.find(I=>I.key===n.botKey):null;return t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsxs("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:["Evidence-backed configuration changes per bot — deterministic findings over"," ",a.payload.window.kind==="rolling_30"?"the trailing 30 days":"the window",". Nothing auto-applies."]}),t.jsxs("div",{className:"ml-auto flex flex-wrap gap-1",children:[t.jsx("button",{type:"button",onClick:()=>{h(null),r()},className:`rounded border px-2 py-0.5 text-[11px] ${g==null?"border-sky-400 text-sky-700 dark:border-sky-600/70 dark:text-sky-300":"border-gray-300 text-gray-500 dark:border-gray-700 dark:text-gray-400"}`,children:"All bots"}),w.map(I=>{var S;return t.jsxs("button",{type:"button",onClick:()=>{h(I.key),r()},className:`rounded border px-2 py-0.5 text-[11px] ${g===I.key?"border-sky-400 text-sky-700 dark:border-sky-600/70 dark:text-sky-300":"border-gray-300 text-gray-500 dark:border-gray-700 dark:text-gray-400"}`,children:[I.label," · ",((S=x.get(I.botUserId))==null?void 0:S.length)??0]},I.key)})]})]}),(n==null?void 0:n.intent)==="drop"&&N&&t.jsxs("div",{className:"rounded-lg border border-red-300/60 bg-red-50/50 p-2.5 text-[11px] text-red-800 dark:border-red-800/60 dark:bg-red-950/20 dark:text-red-300",children:["Considering dropping ",N.label,"? Over this window: ",N.threads," threads,"," ",N.actedOn," acted on, ",N.untouched," untouched (",N.overdueUntouched," overdue). The suppress and overlap findings below are the evidence — the brief is the deliverable to bring to that discussion."]}),j.length===0&&t.jsx("div",{className:"rounded-lg border border-gray-200 p-3 text-xs text-gray-500 dark:border-gray-800 dark:text-gray-400",children:g?"No advisor findings for this bot in the current window — its evidence is under the cell floors.":"No advisor findings in the current window. Findings appear once a bot crosses the evidence floors (5 threads per path cell, 20 scored findings per category cell)."}),j.map(I=>t.jsx(HU,{bot:I,overlay:b.get(I.botUserId),intents:x.get(I.botUserId)??[],recsByKey:y,repos:u,firstPrMerged:k},I.key))]})}function KU(e){return e.automated||e.isManualOverride||e.identitySource==="manual"}function GU(e){const n={reviewBots:[],qualityChecks:[],markedNotBots:[]};for(const r of e){if(!r.automated){(r.isManualOverride||r.identitySource==="manual")&&n.markedNotBots.push(r);continue}r.role==="review"?n.reviewBots.push(r):n.qualityChecks.push(r)}return n}function VU(e,n){return e.filter(r=>r.repoFootprints.some(s=>s.repoId===n))}function QU(e){const n=new Set;let r=0,s=0,a=0;for(const i of e)if(i.automated&&!n.has(i.userId)){if(n.add(i.userId),i.effectiveMonthlyUsd==null){a+=1;continue}s+=1,r+=i.effectiveMonthlyUsd}return{totalUsd:s===0?null:Math.round(r*100)/100,pricedActors:s,unpricedActors:a}}function YU(e,n,r){const s=n.trim().toLowerCase();if(s==="")return[];const a=[];for(const i of e)if(!(i.automated||!`${i.login} ${i.displayName??""}`.toLowerCase().includes(s))&&(a.push(i),a.length>=r))break;return a}function XU(e,n){return n.length===0?"no-repos":e.some(KU)?null:"no-reviewers"}function ZU(e,n){return e==="no-repos"?"No repos in this Workspace — move some in from Manage repos & workspaces, and their automated reviewers appear here.":`No automated reviewers seen yet in this Workspace’s ${n} repo${n===1?"":"s"} — they appear here once one has reviewed or commented on a PR we’ve synced.`}function Qr({title:e,desc:n,children:r}){return t.jsxs("section",{className:"border-b border-gray-100 pb-4 last:border-b-0 dark:border-gray-800",children:[t.jsx("h3",{className:"text-sm font-semibold text-gray-800 dark:text-gray-100",children:e}),n!=null&&t.jsx("p",{className:"mt-0.5 text-xs text-gray-500 dark:text-gray-400",children:n}),t.jsx("div",{className:"mt-2.5 space-y-2.5",children:r})]})}function rr({label:e,htmlFor:n,hint:r,children:s}){return t.jsxs("label",{htmlFor:n,className:"flex flex-col gap-1 text-xs",children:[t.jsx("span",{className:"font-medium text-gray-600 dark:text-gray-300",children:e}),s,r!=null&&t.jsx("span",{className:"text-[11px] text-gray-400",children:r})]})}const Bn="w-full rounded border border-gray-300 bg-white px-2 py-1 text-xs text-gray-800 outline-none focus:border-sky-400 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-100";function ja({dirty:e,saving:n,onClick:r}){return t.jsx("button",{type:"button",onClick:r,disabled:!e||n,className:"self-start rounded bg-sky-600 px-3 py-1 text-xs font-medium text-white hover:bg-sky-700 disabled:cursor-not-allowed disabled:opacity-40",children:n?"Saving…":"Save"})}const JU=8,eH=8,bj="rounded border border-gray-300 bg-white px-2 py-1 text-xs text-gray-800 outline-none focus:border-sky-400 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-100",vj={review:"A real AI code reviewer. The only role counted in the ROI, behaviour and dedup metrics; its comments read as review substance.",quality_check:"Static analysis, coverage, scanners, CI. Posts verdicts rather than findings — visible in the feed, excluded from the review-bot metrics.",dependency:"Version bumps (Dependabot, Renovate). Authors PRs and never reviews, so its merges are reported as overhead rather than as team throughput.",code_agent:"Writes code that is not a bump — agents, autofix, generated-content sync. Its merged PRs are reported as delivered work that no person typed.",release:"Merge queues, release trains, changelogs, backports. Moves code without writing or judging any; its approvals are governance, not review.",housekeeping:"CLA/DCO, triage, labels, stale-closers, size and preview reports. Its volume is noise in every review metric."};function tH({workspaceId:e,repoId:n}){var F;const r=qi(e),{data:s}=xn(),a=co(e),{botDepth:i}=vt(),c=hC(),d=_D(),u=PD(),m=ED(),h=c.isPending||d.isPending||u.isPending||m.isPending,[g,x]=f.useState(""),y=f.useMemo(()=>{var M;return((M=r.data)==null?void 0:M.reviewers)??[]},[r.data]),b=f.useMemo(()=>{var M;return((M=r.data)==null?void 0:M.repoIds)??[]},[r.data]),w=((F=r.data)==null?void 0:F.workspaceSeatCount)??0,k=f.useMemo(()=>n==null?y:VU(y,n),[y,n]),j=f.useMemo(()=>GU(k),[k]),N=f.useMemo(()=>QU(y),[y]),I=f.useMemo(()=>{const M=new Map;for(const D of s??[])M.set(D.id,D.fullName);return M},[s]),S=f.useMemo(()=>YU(y,g,JU),[y,g]),T=XU(y,b),$=c.error??d.error??u.error??m.error,P="Review bots",C=i?"Who counts as an automated reviewer in this Workspace, who each bot is, and what it costs here. Every setting below applies to the whole Workspace.":"Who counts as an automated reviewer in this Workspace and who each bot is. Every setting below applies to the whole Workspace.";if(e==null)return t.jsx(Qr,{title:P,desc:C,children:t.jsx("p",{className:"py-3 text-center text-[11px] text-gray-400",children:"Loading…"})});const L=(M,D)=>{c.mutate({userId:M,body:{workspaceId:e,...D}})};return t.jsxs(Qr,{title:P,desc:C,children:[r.isLoading?t.jsx("p",{className:"py-3 text-center text-[11px] text-gray-400",children:"Loading…"}):r.isError?t.jsx("p",{className:"py-3 text-center text-[11px] text-red-500",children:r.error.message}):T!=null?t.jsx("p",{className:"py-3 text-center text-[11px] text-gray-400",children:ZU(T,b.length)}):t.jsxs(t.Fragment,{children:[t.jsxs("p",{className:"rounded border border-amber-300 bg-amber-50 px-2 py-1 text-[10px] text-amber-700 dark:border-amber-800 dark:bg-amber-950/30 dark:text-amber-300",children:["Everything here applies to"," ",t.jsx("span",{className:"font-semibold",children:"this Workspace"})," — all ",b.length," of its repo",b.length===1?"":"s",", including any not listed on a card. It does not reach your other Workspaces: the same bot can be classified, named and priced differently in each."]}),n!=null&&t.jsxs("p",{className:"text-[10px] text-gray-400",children:["Filtered to the bots active in"," ",t.jsx("span",{className:"font-medium text-gray-500 dark:text-gray-300",children:I.get(n)??`repo #${n}`}),". The repo chips on each card are the real reach of an edit."]}),t.jsx(k0,{heading:"Review bots",note:"Counted in the ROI, behaviour and dedup metrics.",reviewers:j.reviewBots,workspaceSeatCount:w,showCost:i,repoName:I,botColor:a,busy:h,onPatch:L,onCost:(M,D,A)=>d.mutate({userId:M,body:b0(e,D,A)}),onResetJudgement:M=>u.mutate({userId:M,workspaceId:e}),onResetIdentity:M=>m.mutate({userId:M,workspaceId:e})}),t.jsx(k0,{heading:"Other automation",note:"Quality gates, dependency bots, code agents, release and housekeeping automation — still visible in the feed, excluded from the review-bot metrics.",reviewers:j.qualityChecks,workspaceSeatCount:w,showCost:i,repoName:I,botColor:a,busy:h,onPatch:L,onCost:(M,D,A)=>d.mutate({userId:M,body:b0(e,D,A)}),onResetJudgement:M=>u.mutate({userId:M,workspaceId:e}),onResetIdentity:M=>m.mutate({userId:M,workspaceId:e})}),t.jsx(k0,{heading:"Marked “not a bot” by you",note:"Detection leaves these alone until you reset them.",reviewers:j.markedNotBots,workspaceSeatCount:w,showCost:i,repoName:I,botColor:a,busy:h,onPatch:L,onCost:(M,D,A)=>d.mutate({userId:M,body:b0(e,D,A)}),onResetJudgement:M=>u.mutate({userId:M,workspaceId:e}),onResetIdentity:M=>m.mutate({userId:M,workspaceId:e})}),n!=null&&k.length===0&&t.jsx("p",{className:"py-3 text-center text-[11px] text-gray-400",children:"No automated reviewer has touched this repo yet. This Workspace's other bots are still configured — clear the repo filter to see them."}),i?t.jsx("p",{className:"text-[10px] text-gray-400",children:N.totalUsd==null?t.jsx(t.Fragment,{children:"No monthly prices set yet — add one per bot above to get $/acted-on in the ROI table."}):t.jsxs(t.Fragment,{children:[t.jsxs("span",{className:"font-medium tabular-nums text-gray-600 dark:text-gray-300",children:["$",Hl(N.totalUsd),"/mo"]})," ","across ",N.pricedActors," bot",N.pricedActors===1?"":"s"," in this Workspace",N.unpricedActors>0&&t.jsxs(t.Fragment,{children:[" · ",N.unpricedActors," with no price set"]}),"."," ",t.jsx("span",{className:"text-gray-400",children:"Prices are per Workspace and are never added across Workspaces."})]})}):t.jsxs("p",{className:"text-[10px] text-gray-400",children:[t.jsx(ec,{className:"mr-1",title:"Per-bot pricing is part of Pro."}),"Per-bot pricing and the ROI table it feeds are part of Pro: put a monthly cost against each bot in this Workspace and read what each acted-on comment cost, beside what every bot actually produced. Classifying bots here is free."]}),t.jsxs("div",{className:"mt-3 space-y-1.5 border-t border-gray-200 pt-3 dark:border-gray-800",children:[t.jsxs("label",{className:"flex flex-col gap-1 text-xs",children:[t.jsx("span",{className:"font-medium text-gray-600 dark:text-gray-300",children:"Add a review bot"}),t.jsx("input",{className:Bn,value:g,placeholder:"Search reviewers by name or login…",onChange:M=>x(M.target.value),"aria-label":"Search reviewers to mark as a review bot"})]}),g.trim()===""?t.jsxs("p",{className:"text-[10px] text-gray-400",children:["Type a reviewer's name to treat them as an automated reviewer in this Workspace. They join the ",t.jsx("span",{className:"font-medium",children:"Review bots"})," list above, where you set the vendor and the price."]}):S.length===0?t.jsx("p",{className:"text-[10px] text-gray-400",children:"No matching reviewers this Workspace currently treats as human."}):t.jsx("ul",{className:"divide-y divide-gray-100 rounded border border-gray-200 dark:divide-gray-800 dark:border-gray-700",children:S.map(M=>t.jsxs("li",{className:"flex flex-wrap items-center gap-2 px-2.5 py-1.5",children:[M.avatarUrl!=null&&t.jsx("img",{src:M.avatarUrl,alt:"",className:"h-5 w-5 shrink-0 rounded-full"}),t.jsxs("span",{className:"truncate text-xs font-medium text-gray-800 dark:text-gray-100",children:[M.login,M.displayName!=null&&M.displayName!==M.login&&t.jsx("span",{className:"ml-1 font-normal text-gray-400",children:M.displayName})]}),t.jsx("button",{type:"button",disabled:h,onClick:()=>{L(M.userId,{automated:!0}),x("")},className:"ml-auto rounded bg-sky-600 px-2 py-0.5 text-[11px] font-medium text-white hover:bg-sky-700 disabled:opacity-40",children:"Treat as a review bot in this Workspace"})]},M.userId))})]})]}),$!=null&&t.jsx("p",{className:"text-[11px] text-red-500",children:$.message})]})}function k0({heading:e,note:n,reviewers:r,workspaceSeatCount:s,showCost:a,repoName:i,botColor:c,busy:d,onPatch:u,onCost:m,onResetJudgement:h,onResetIdentity:g}){return r.length===0?null:t.jsxs("section",{className:"space-y-1.5",children:[t.jsxs("div",{className:"flex flex-wrap items-baseline gap-1.5",children:[t.jsxs("h4",{className:"text-xs font-semibold text-gray-700 dark:text-gray-200",children:[e," (",r.length,")"]}),t.jsx("span",{className:"text-[10px] text-gray-400",children:n})]}),t.jsx("ul",{className:"divide-y divide-gray-100 rounded border border-gray-200 dark:divide-gray-800 dark:border-gray-700",children:r.map(x=>t.jsx(nH,{reviewer:x,workspaceSeatCount:s,showCost:a,repoName:i,botColor:c,busy:d,onPatch:u,onCost:m,onResetJudgement:h,onResetIdentity:g},x.userId))})]})}function nH({reviewer:e,workspaceSeatCount:n,showCost:r,repoName:s,botColor:a,busy:i,onPatch:c,onCost:d,onResetJudgement:u,onResetIdentity:m}){const h=e,g=h.kind??"in_house",[x,y]=f.useState(g),[b,w]=f.useState(h.label),k="",[j,N]=f.useState(h.role),[I,S]=f.useState(`${g}${k}${h.label}${k}${h.role}`),T=`${g}${k}${h.label}${k}${h.role}`;I!==T&&(S(T),y(g),w(h.label),N(h.role));const $=a({login:h.login,kind:g}),P=x!==g||b!==h.label,C=h.footprint,L=h.repoFootprints,F=L.slice(0,eH),M=L.length-F.length,D=L.map(A=>s.get(A.repoId)??`repo #${A.repoId}`).join(", ");return t.jsxs("li",{className:"flex flex-col gap-1.5 px-2.5 py-2",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[h.avatarUrl!=null&&t.jsx("img",{src:h.avatarUrl,alt:"",className:"h-5 w-5 shrink-0 rounded-full"}),t.jsxs("span",{className:"truncate text-xs font-medium text-gray-800 dark:text-gray-100",title:h.sampleReviewBody??void 0,children:[h.login,h.displayName!=null&&h.displayName!==h.login&&t.jsx("span",{className:"ml-1 font-normal text-gray-400",children:h.displayName})]}),t.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 rounded-full px-1.5 py-0.5 text-[10px] font-medium",style:{...pn($),backgroundColor:`${$}1a`},children:[t.jsx("span",{className:"h-1.5 w-1.5 rounded-full",style:{backgroundColor:$}}),ds(g).label]}),h.identitySource==="manual"&&t.jsx("span",{className:"shrink-0 rounded bg-sky-50 px-1 py-0.5 text-[9px] font-medium uppercase tracking-wide text-sky-600 dark:bg-sky-950 dark:text-sky-300",children:"named by you"}),h.isManualOverride?t.jsx("span",{className:"shrink-0 rounded bg-sky-50 px-1 py-0.5 text-[9px] font-medium uppercase tracking-wide text-sky-600 dark:bg-sky-950 dark:text-sky-300",children:"set by you"}):t.jsx("span",{className:"shrink-0 text-[9px] uppercase tracking-wide text-gray-500 dark:text-gray-400",title:h.reasons.join(" · "),children:h.source.replace(/_/g," ")}),h.automated&&h.confidence!=="high"&&!h.isManualOverride&&t.jsxs("span",{className:"shrink-0 text-[10px] text-amber-500",title:h.reasons.join(" · "),children:["likely (",h.confidence,")"]}),t.jsxs("span",{className:"ml-auto shrink-0 text-[10px] text-gray-400",title:"Reviews / inline threads / PR comments across this Workspace over the last 90 days",children:[C.reviews,"r · ",C.threads,"t · ",C.comments,"c",t.jsx("span",{className:"ml-1 text-gray-500 dark:text-gray-400",children:"90d"})]})]}),L.length>0&&t.jsxs("div",{className:"flex flex-wrap items-center gap-1",title:D,children:[t.jsx("span",{className:"text-[9px] uppercase tracking-wide text-gray-400",children:"Active in"}),F.map(A=>t.jsx("span",{className:"rounded bg-gray-100 px-1.5 py-0.5 text-[10px] text-gray-600 dark:bg-gray-800 dark:text-gray-300",title:`${A.reviews}r · ${A.threads}t · ${A.comments}c here over the last 90 days`,children:s.get(A.repoId)??`repo #${A.repoId}`},A.repoId)),M>0&&t.jsxs("span",{className:"text-[10px] text-gray-400",children:["+",M," more"]})]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[h.automated?t.jsxs(t.Fragment,{children:[t.jsxs("label",{className:"flex items-center gap-1 text-[11px] text-gray-500 dark:text-gray-400",children:[t.jsx("span",{className:"sr-only",children:"Role in this Workspace"}),t.jsx("select",{disabled:i,value:j,onChange:A=>N(A.target.value),title:vj[j],className:"rounded border border-gray-300 bg-transparent px-1.5 py-0.5 text-[11px] font-medium text-gray-600 disabled:opacity-40 dark:border-gray-700 dark:text-gray-300",children:k$.map(A=>t.jsx("option",{value:A,children:ok[A]},A))})]}),j!==h.role&&t.jsx("button",{type:"button",disabled:i,onClick:()=>c(h.userId,{automated:!0,role:j}),title:vj[j],className:"rounded bg-sky-600 px-2 py-0.5 text-[11px] font-medium text-white hover:bg-sky-700 disabled:opacity-40",children:"Apply role"}),t.jsx("button",{type:"button",disabled:i,onClick:()=>c(h.userId,{automated:!1}),title:"Stop treating this reviewer as automated in this Workspace — every repo in it. Its vendor name and price are kept, and your other Workspaces are unaffected.",className:"rounded border border-gray-300 px-2 py-0.5 text-[11px] font-medium text-gray-600 hover:bg-gray-100 disabled:opacity-40 dark:border-gray-700 dark:text-gray-300 dark:hover:bg-gray-800",children:"Not a bot in this Workspace"})]}):t.jsx("button",{type:"button",disabled:i,onClick:()=>c(h.userId,{automated:!0}),title:"Treat this reviewer as automated again in this Workspace — every repo in it. Your other Workspaces are unaffected.",className:"rounded border border-gray-300 px-2 py-0.5 text-[11px] font-medium text-gray-600 hover:bg-gray-100 disabled:opacity-40 dark:border-gray-700 dark:text-gray-300 dark:hover:bg-gray-800",children:"Treat as a review bot"}),h.isManualOverride&&t.jsx("button",{type:"button",disabled:i,onClick:()=>u(h.userId),title:"Forget your bot / not-a-bot and review / quality-check judgement for this Workspace and let detection decide again. The vendor name and the price are untouched.",className:"rounded border border-dashed border-gray-300 px-2 py-0.5 text-[11px] font-medium text-gray-500 hover:bg-gray-100 disabled:opacity-40 dark:border-gray-700 dark:text-gray-400 dark:hover:bg-gray-800",children:"Reset classification"})]}),h.isManualOverride&&t.jsxs("p",{className:"text-[10px] text-gray-400",children:["Set by you — detection will not change it in this Workspace until you reset. Resetting keeps the bot's"," ",t.jsx("span",{className:"font-medium text-gray-500 dark:text-gray-300",children:"name and price"}),"."]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[t.jsx("select",{className:`${bj} w-auto py-0.5`,value:x,onChange:A=>y(A.target.value),"aria-label":`Vendor for ${h.login} in this Workspace`,children:w$(j,x).map(A=>t.jsxs("option",{value:A,children:[ds(A).label,Ag(A)!=null&&Ag(A)!==j?` (${ok[Ag(A)].toLowerCase()})`:""]},A))}),t.jsx("input",{className:`${bj} w-40 py-0.5`,value:b,placeholder:"Label",onChange:A=>w(A.target.value),"aria-label":`Display label for ${h.login} in this Workspace`}),t.jsx("button",{type:"button",disabled:i||!P,onClick:()=>c(h.userId,{kind:x,label:b.trim()===""?null:b}),title:"Name this bot for this Workspace. It does not change whether it counts as a bot, and it does not reach your other Workspaces.",className:"rounded bg-sky-600 px-2 py-0.5 text-[11px] font-medium text-white hover:bg-sky-700 disabled:opacity-40",children:"Save name"}),h.identitySource==="manual"&&t.jsx("button",{type:"button",disabled:i,onClick:()=>m(h.userId),title:"Forget the vendor and label you set and let detection name this bot again in this Workspace. The monthly price is kept, and the bot / not-a-bot verdict is unchanged.",className:"rounded border border-gray-300 px-2 py-0.5 text-[11px] font-medium text-gray-600 hover:bg-gray-100 disabled:opacity-40 dark:border-gray-700 dark:text-gray-300 dark:hover:bg-gray-800",children:"Reset name"})]}),h.identitySource==="manual"&&t.jsxs("p",{className:"text-[10px] text-gray-400",children:["Reset hands the vendor and label back to detection for this Workspace —"," ",t.jsx("span",{className:"font-medium text-gray-500 dark:text-gray-300",children:"the price is kept"}),", and the bot / not-a-bot verdict does not change."]}),r&&t.jsx(sH,{login:h.login,costMonthlyUsd:h.costMonthlyUsd,costModel:h.costModel,workspaceSeatCount:n,busy:i,onApply:(A,W)=>d(h.userId,A,W)},h.userId)]})}const rH={set:"border-ai-signal/60 text-gray-800 dark:text-gray-100",none:"border-gray-300 text-gray-800 dark:border-gray-700 dark:text-gray-100"};function sH({login:e,costMonthlyUsd:n,costModel:r,workspaceSeatCount:s,busy:a,onApply:i}){const c=k9({costMonthlyUsd:n}),d=Hl(n),[u,m]=f.useState(d),[h,g]=f.useState(r),y=`${d}${r}`,[b,w]=f.useState(y);b!==y&&(w(y),m(d),g(r));const k=j9(u),j=k.ok?N9(n,k.value,r,h):null;let N;if(!k.ok)N=k.error;else if(j==null)N="";else switch(j.kind){case"set":N=h==="per_seat"?"Sets a per-seat price for this Workspace — the monthly figure is the price × this Workspace’s seats. Other Workspaces are unaffected.":"Sets this bot’s price for this Workspace. Other Workspaces are unaffected.";break;case"clear":N="Clears the price for this Workspace. $/acted-on stops showing for this bot.";break;case"unchanged":N="Unchanged.";break;case"no-cost":N="No price set. Type a number to add one (0 means “free”).";break}const I=S=>`px-1.5 py-0.5 text-[10px] font-medium ${S?"bg-sky-600 text-white":"bg-white text-gray-500 hover:bg-gray-100 dark:bg-gray-800 dark:text-gray-400 dark:hover:bg-gray-700"}`;return t.jsxs("div",{className:"flex flex-wrap items-center gap-x-1.5 gap-y-1",children:[t.jsx("span",{className:"text-[10px] uppercase tracking-wide text-gray-400",children:"Price for this Workspace"}),t.jsx("span",{className:"text-[11px] text-gray-400",children:"$"}),t.jsx("input",{type:"text",inputMode:"decimal",className:`w-20 rounded border bg-white px-1.5 py-0.5 text-[11px] tabular-nums outline-none focus:border-sky-400 dark:bg-gray-800 ${rH[c]}`,value:u,placeholder:"—",onChange:S=>m(S.target.value),onKeyDown:S=>{S.key==="Enter"&&k.ok&&(j==null?void 0:j.dirty)===!0&&!a&&i(k.value,h)},"aria-label":`Monthly cost in US dollars for ${e} in this Workspace`}),t.jsx("span",{className:"text-[11px] text-gray-400",children:h==="per_seat"?"/seat/mo":"/mo"}),t.jsxs("span",{role:"group","aria-label":`Pricing model for ${e} in this Workspace`,className:"inline-flex overflow-hidden rounded border border-gray-300 dark:border-gray-700",children:[t.jsx("button",{type:"button",disabled:a,onClick:()=>g("flat"),className:I(h==="flat"),children:"flat"}),t.jsx("button",{type:"button",disabled:a,onClick:()=>g("per_seat"),className:I(h==="per_seat"),title:"Meter this bot per seat — a seat is a distinct human who opened a PR in this Workspace’s repos over the last 30 days.",children:"per seat"})]}),h==="per_seat"&&k.ok&&k.value!=null&&t.jsxs("span",{className:"text-[10px] tabular-nums text-gray-400",title:"Seats are the distinct humans who opened a PR in this Workspace’s repos over the last 30 days. The monthly figure is derived at read time and moves with the team.",children:["× ",s," seat",s===1?"":"s"," ≈ $",Hl(S9(k.value,s)),"/mo"]}),t.jsx("button",{type:"button",disabled:a||!k.ok||(j==null?void 0:j.dirty)!==!0,onClick:()=>{k.ok&&(j==null?void 0:j.dirty)===!0&&i(k.value,h)},title:N,className:"rounded border border-gray-300 px-2 py-0.5 text-[11px] font-medium text-gray-600 hover:bg-gray-100 disabled:opacity-40 dark:border-gray-700 dark:text-gray-300 dark:hover:bg-gray-800",children:(j==null?void 0:j.kind)==="clear"?"Clear":"Save price"}),t.jsx("span",{className:`text-[10px] ${k.ok?"text-gray-400":"text-red-500"}`,children:N})]})}function aH({repoId:e}={}){const n=G(r=>r.workspaceId);return t.jsxs("div",{className:"space-y-3","data-testid":"bot-settings-panel",children:[t.jsxs("div",{className:"flex flex-wrap items-baseline gap-2",children:[t.jsx("h3",{className:"text-sm font-semibold text-gray-700 dark:text-gray-200",children:"Who counts as a review bot in this Workspace"}),t.jsx("span",{className:"text-[11px] text-gray-400",children:e!=null?"This Workspace’s bots, filtered to the ones active in this repo — edits still apply Workspace-wide.":"One card per bot — its verdict, its name and its price in this Workspace."})]}),t.jsx(tH,{workspaceId:n,repoId:e}),t.jsxs("p",{className:"border-t border-gray-200 pt-2.5 text-[11px] text-gray-400 dark:border-gray-800",children:["Bot ",t.jsx("span",{className:"font-medium",children:"detection"})," needs no configuration, and Limn stamps its own review marker unconditionally. To put a review-bot summary into a Slack digest, turn it on for that workspace's delivery in"," ",t.jsx("span",{className:"font-medium",children:"Settings → Workspace → Slack digest"}),"."]})]})}function oH(e,n){return["bot-benchmark-placement",dt(e),Vr(n)]}function iH(e,n){const{botDepth:r}=vt();return Oe({queryKey:oH(e,n),queryFn:e==null?Ct:()=>he.botBenchmarkPlacement(e,n??void 0),enabled:r,staleTime:5*6e4})}function lH(e){const{botDepth:n}=vt();return Oe({queryKey:["bot-benchmark-manifest"],queryFn:()=>he.botBenchmark(),enabled:n&&e,staleTime:1/0})}function cH(e,n){return e==="advisor"&&!n.showAdvisor||e==="themes"&&!n.showThemes?"roi":e}function dH(e){return e==="pending"?"blank":e==="locked"?"locked":"panel"}const uH={artifact_missing:"This build has no comparison data",artifact_unreadable:"The comparison data could not be read",fit_version_unsupported:"The comparison data is newer than this build understands"},tm={vendor_not_in_corpus_vocabulary:"We have never measured this bot",vendor_unfittable:"We cannot tell which product this bot is",vendor_unstratifiable:"Too few teams run this bot to compare against",cell_not_in_corpus:"No team we measured runs this bot on a repo this size",repo_window_incomplete:"This repo is too new to compare",repo_inactive_in_window:"Nothing merged here recently"},kj={repo_not_walked:"This repo has not been read yet",no_prs_in_window:"No pull requests in this period",vendor_silent:"Said nothing here",vendor_absent_from_population:"It said nothing on the PRs this counts",denominator_empty:"Nothing to measure against",below_min_units:"Too little here to be worth a number",body_unobserved:"A comment was never stored"},hH={volume:"Comments far more than it does for other teams",engagement:"Your team uses far less of it than other teams do",latency:"Someone gets to it far later than on similar repos",overlap:"Repeats another bot on the same lines"},wj=["volume","engagement","latency","overlap"],pH={fresh:"Comparison data is current",aging:"Comparison data is getting old",stale:"Comparison data is out of date",expired:"Comparison data has expired"},mH={acted_on_rate:"Acted on",acted_on_rate_with_outdated:"Acted on (counting outdated)",thread_resolved_rate:"Resolved",thread_outdated_rate:"Went outdated",human_reply_rate:"A person replied",human_followed_last_bot_rate:"A person had the last word",median_hours_to_first_human_reply:"Time to a first human reply",overdue_untouched_rate_72h:"Untouched after 72h",overdue_untouched_rate_168h:"Untouched after a week",findings_per_merged_pr:"Findings per merged PR",threads_per_merged_pr:"Threads per merged PR",pr_comment_coverage:"Merged PRs it commented on",cross_bot_overlap_rate:"Overlaps another reviewer",high_severity_share:"Share flagged high severity",nit_share:"Share flagged as nits",distinct_category_count:"Distinct categories used"},jj=["acted_on_rate","thread_resolved_rate","human_reply_rate","human_followed_last_bot_rate","median_hours_to_first_human_reply","overdue_untouched_rate_72h","overdue_untouched_rate_168h","thread_outdated_rate","acted_on_rate_with_outdated","findings_per_merged_pr","threads_per_merged_pr","pr_comment_coverage","cross_bot_overlap_rate"];function nm(e){return mH[e]??e}const xR={code:"Counted",model:"Model-derived"};function zl(e){return e.includes(".")?e.replace(/0+$/,"").replace(/\.$/,""):e}function Nr(e,n){if(n==="rate"){const r=e*100;return`${zl(r.toFixed(r>=10?0:1))}%`}return n==="hours"?gH(e):zl(e.toFixed(2))}function gH(e){return Number.isFinite(e)?e<1?`${Math.round(e*60)}m`:e<48?`${zl(e.toFixed(1))}h`:`${zl((e/24).toFixed(1))}d`:"—"}function $t(e){return e.toLocaleString("en-US")}function fH(e){const n=Math.round(e),r=n%100;if(r>=11&&r<=13)return`${n}th`;const s={1:"st",2:"nd",3:"rd"}[n%10]??"th";return`${n}${s}`}function yR(e){const n=e.bandLabel===""?"":` of similar size (group ${e.bandLabel})`;return`Higher than ${Math.round(e.percentile)}% of the ${$t(e.nRepos)} teams we measured`+n}const xH=["p10","p25","p50","p75","p90"];function yH(e){return e<0?0:e>1?1:e}function bH(e,n,r){const s={};for(const x of xH){const y=e[x];if(typeof y!="number"||!Number.isFinite(y))return null;s[x]=y}if(!Number.isFinite(n))return null;const i=r!=null&&Number.isFinite(r[0])&&Number.isFinite(r[1])?r:null,c=[s.p10,n,...i?[i[0]]:[]],d=[s.p90,n,...i?[i[1]]:[]];let u=Math.min(...c),m=Math.max(...d);if(!(m>u))return{domain:[u,m],p10:.5,p25:.5,p50:.5,p75:.5,p90:.5,value:.5,ci:i?[.5,.5]:null};const h=(m-u)*.04;u-=h,m+=h;const g=x=>yH((x-u)/(m-u));return{domain:[u,m],p10:g(s.p10),p25:g(s.p25),p50:g(s.p50),p75:g(s.p75),p90:g(s.p90),value:g(n),ci:i?[g(i[0]),g(i[1])]:null}}function tc(e){return`${e.repoOwner}/${e.repoName}`}function Xo(e){if(e!=null&&Object.hasOwn(Qs,e)){const n=Qs[e];if(n!=null)return n.label}return"Bot"}function bR(e){if(e!=null&&Object.hasOwn(Qs,e)){const n=Qs[e];if(n!=null)return n.color}return null}function vH(e){const n=new Set(jj),r=Object.keys(e.metrics).filter(i=>!n.has(i)).sort(),s=[...jj,...r],a=[];for(const i of s){const c=e.metrics[i];c!=null&&a.push({name:i,label:nm(i),metric:c})}return a}function kH(e){if(e.aboveTopBandBy!=null)return null;const[n,r]=e.bandRange;return e.activity<n?`Your ${$t(e.activity)} is below the ${$t(n)}–${$t(r)} these peers drew — this is the quietest band there is, and it is open at the bottom.`:e.activity>r?`Your ${$t(e.activity)} is above the ${$t(n)}–${$t(r)} these peers drew; the band is a rank cut, not a bucket you have to fall inside.`:null}function wH(e){var r;if(e.length===0)return null;const n=(r=e[0])==null?void 0:r.metric;if(n==null||n.status!=="excluded")return null;for(const s of e)if(s.metric.status!=="excluded"||s.metric.reason!==n.reason)return null;return n.reason}function jH(e){const n=[];for(const s of e)for(const a of s.anomalies){const i=s.metrics[a.metric];n.push({key:`${s.repoId}:${a.metric}:${a.kind}`,unit:s,anomaly:a,headline:hH[a.kind],metricLabel:nm(a.metric),rankRepos:i!=null&&i.status==="compared"?i.cohort.nRepos:null})}const r=s=>{const a=wj.indexOf(s);return a===-1?wj.length:a};return n.sort((s,a)=>{const i=r(s.anomaly.kind)-r(a.anomaly.kind);return i!==0?i:tc(s.unit).localeCompare(tc(a.unit))||s.key.localeCompare(a.key)})}const Nj={nothing_comparable:"Nothing could be compared yet",nothing_stands_out:"Nothing stands out"};function NH(e){return e.compared===0?"nothing_comparable":"nothing_stands_out"}function SH(e){let n=0,r=0,s=0;for(const a of e){a.placement.status==="placed"&&(n+=1);for(const i of Object.values(a.metrics))i.status==="compared"&&(r+=1);s+=a.anomalies.length}return{units:e.length,placed:n,refused:e.length-n,compared:r,anomalies:s}}function CH(e){return[...e].sort((n,r)=>{const s=n.placement.status==="placed"?0:1,a=r.placement.status==="placed"?0:1;return s!==a?s-a:tc(n).localeCompare(tc(r))||Xo(n.botKind).localeCompare(Xo(r.botKind))})}const RH={stored:"Price you entered",counted:"From your own data",fitted:"Typical team"},vR={repo_window_incomplete:tm.repo_window_incomplete,no_merges_in_window:"Nothing merged here recently",span_unobserved:"No timestamps to work out a rate from",own_rate_withheld:"Too little of your own data to use",nothing_acted_on:"Your team acted on none of it",window_underpopulated:"Too few comments used this month to price",price_is_zero:"Recorded as free",price_unresolved:"Price entered, but the seat count is missing",cohort_rate_unfitted:"No typical team to compare this bot with here",cohort_rate_zero:"Other teams act on none of it either",workspace_truncated:"Too many repos here to price the whole Workspace"};function Gs(e){if(!Number.isFinite(e))return"—";const n=Math.abs(e),r=e<0?"-":"";return n>0&&n<.005?`${r}<US$0.01`:`${r}US$${n.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}`}function IH(e){return`per ${$t(e)} days`}function kR(e){if(!Number.isFinite(e))return"—";const n=Math.abs(e);return n>0&&n<.05?"<0.1":zl(e.toFixed(n<10?1:0))}function TH(e){if(e.monthlyUsd==null||e.windowUsd==null)return"No monthly figure — every price recorded here is per seat, and the seat count could not be multiplied out";const n=`${Gs(e.monthlyUsd)} a month · ${Gs(e.windowUsd)} ${IH(e.windowDays)}`;return e.costModel!=="per_seat"||e.unitMonthlyUsd==null||e.seats==null?n:`${n} — ${Gs(e.unitMonthlyUsd)} per seat × ${$t(e.seats)} seat${e.seats===1?"":"s"}`}function $H(e){return e.pricedReviewers<=1?null:`Summed over ${$t(e.pricedReviewers)} priced accounts the Workspace classifies as this one reviewer.`}function _H(e){return e.seatPriceUnresolved<=0?null:`${$t(e.seatPriceUnresolved)} per-seat price${e.seatPriceUnresolved===1?" is":"s are"} left out of this figure: this build could not read the Workspace's seat count, and a per-developer unit price is not a monthly one.`}function PH(e){return e.seatCountZero<=0?null:`${$t(e.seatCountZero)} per-seat price${e.seatCountZero===1?" is":"s are"} left out of this figure: this Workspace has no human pull-request authors in the last 30 days, so there are no seats to multiply by. A price you entered is not a price of nothing.`}function EH(e){return(e??[]).map(n=>({...n,label:nm(n.name)}))}function Ys(e,n,r){return`${$t(e)} ${e===1?n:r}`}function AH(e){return e.length<=1?e[0]??"":`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`}const w0={single_repo:"Runs in one repo — nothing to spread across",no_placed_repos:"No repo here could be compared",no_fitted_cohort_rate:"No typical team to compare these repos with",no_settled_threads:"No finished comment threads to measure",vendor_not_in_corpus:tm.vendor_not_in_corpus_vocabulary};function wR(e){const n=Ys(e.reposConsidered,"repository","repositories");return`live in ${$t(e.liveInRepos)} of ${n}`}function MH(e){return`${Xo(e.botKind)} — ${wR(e)}`}function LH(e){if(e.status!=="value")return null;const n=[];return e.below>0&&n.push(`below it in ${$t(e.below)}`),e.at>0&&n.push(`level with it in ${$t(e.at)}`),e.above>0&&n.push(`above it in ${$t(e.above)}`),n.length===0?null:`Of the ${Ys(e.placed,"repository","repositories")} placed with a comparable acted-on rate, this reviewer sits ${AH(n)}.`}function FH(e){if(e.status!=="value")return null;const r=`In the ${Ys(e.fittedRepos,"repository","repositories")} we can compare, your team uses ${Nr(e.yoursRateOnFitted,"rate")} of what this bot says, where teams with repos like these use ${Nr(e.expectedRate,"rate")}.`;if(e.excludedRepos<=0)return r;const s=Ys(e.excludedRepos,"repository","repositories"),a=e.excludedRepos===1?"has no team to compare it with and is":"have no teams to compare them with and are";return`${r} The other ${s} this bot runs in ${a} outside both figures — the rate above covers every one of them and is a different number.`}function OH(e,n){return e.status!=="refused"||n.status!=="refused"||e.reason!==n.reason?null:{reason:e.reason,message:e.message}}function DH(e){return TH(e)}function Sj(e){const n=e.costWindowDays;return n==null||!Number.isFinite(n)||n<=0?"Per comment your team used":`Per comment your team used (last ${$t(Math.round(n))} days)`}function BH(e,n){const r=e.coveredRepos>1?` across ${Ys(e.coveredRepos,"repository","repositories")}`:"",s=e.monthlyUsd==null?"":` · ${Gs(e.monthlyUsd)} a month`;return`${kR(n.actedThreads)} of ${$t(n.settledThreads)} comments used${r}${s}`}function WH(e){return"The same subscription may cover repositories outside this Workspace, which this app cannot see; in that direction the figure is an upper bound."}function qH(e){return e.spanUnobservedRepos<=0?null:`${Ys(e.spanUnobservedRepos,"repository","repositories")} carries no readable observation period: this reviewer's own earliest-to-latest comment stretch could not be read there. Nothing on this card divides by it — the money is a fixed window at both ends — and every thread it settled still counts.`}function UH(e){const n=e.costWindowIncompleteRepos??0;if(n<=0)return null;const r=Ys(n,"repository","repositories"),s=n===1?"has":"have",a=e.costWindowDays==null?null:$t(Math.round(e.costWindowDays));return`${r} ${s} been tracked for less than ${a==null?"the cost window":`${a} days`}, so the month of work the price would be divided by is incomplete while the price is whole. The per-acted-on figure is withheld rather than reported too high; every other number here still includes it.`}function HH(e){return e.partialWindowRepos<=0?null:`${Ys(e.partialWindowRepos,"repository","repositories")} left out of the cost per merged pull request: this build has held ${e.partialWindowRepos===1?"it":"them"} for less than ${Ys(e.windowDays,"day","days")}, so the merge count there is a partial-window undercount and would divide the price by too little work. Everything else on this card still includes it.`}function zH(e){const n=[e.perMergedPr,e.unacted,e.yours],r=n[0];if(r==null||r.status!=="refused")return null;for(const s of n)if(s.status!=="refused"||s.reason!==r.reason)return null;return r.reason}function KH(e,n){const r=e.unacted;if(r.status!=="value"||e.monthlyUsd==null)return null;const s=Ys(e.coveredRepos,"repository","repositories"),a=e.coveredRepos===1?"":`across the ${s} it is live in `,i=`Your team used ${Nr(r.actedOnRate,"rate")} of the ${$t(r.settledThreads)} comments this bot finished ${a}— so ${Gs(r.unactedUsd)} of its ${Gs(e.monthlyUsd)} a month is paying for comments nobody used.`;if(n.status!=="value"||n.conversionGapUsd==null)return{tone:"measured",spend:i,comparison:null};const c=n.conversionGapUsd,u=`In the ${Ys(n.fittedRepos,"repository","repositories")} we can compare, your team used ${Nr(n.yoursRateOnFitted,"rate")} of what it said, where teams with similar repos used ${Nr(n.expectedRate,"rate")}`;return c>0?{tone:"behind",spend:i,comparison:`${u}. Using it as much as they do would put another ${Gs(c)} a month of the price you already pay to work.`}:c<0?{tone:"ahead",spend:i,comparison:`${u}. That puts ${Gs(-c)} a month more of the price to work than a team with similar repos would.`}:{tone:"even",spend:i,comparison:`${u} — the same. Using it more or less would not change what the price buys.`}}const GH=new Set(["vendor_not_in_corpus_vocabulary","vendor_unfittable","vendor_unstratifiable"]);function VH(e){return e.map(n=>({key:String(n.repoId),repo:`${n.repoOwner}/${n.repoName}`,band:n.band!=null?`Band ${n.band.bandLabel}`:n.placementRefusal!=null?tm[n.placementRefusal]:"—",bandRefused:n.band==null,mergedPrs:$t(n.mergedPrsLast14d),actedOn:n.actedOnRate==null?"—":Nr(n.actedOnRate,"rate"),percentile:n.percentile==null?"—":fH(n.percentile),refusalIsVendorWide:n.placementRefusal!=null&&GH.has(n.placementRefusal)}))}function QH(e){return[...e].sort((n,r)=>{const s=n.spread.status==="value"?0:1,a=r.spread.status==="value"?0:1;return s!==a?s-a:Xo(n.botKind).localeCompare(Xo(r.botKind))||n.key.localeCompare(r.key)})}function YH(e){return QH(e).map(n=>({key:n.key,rollup:n,title:MH(n),label:Xo(n.botKind),color:bR(n.botKind),coverage:wR(n)}))}const Cj=18;function XH({geom:e,width:n,flagged:r}){const s=i=>i*n,a=Cj/2;return t.jsxs("svg",{width:n,height:Cj,className:"decorative-mark text-gray-300 dark:text-gray-600","aria-hidden":"true",children:[t.jsx("rect",{x:s(e.p10),y:a-4,width:Math.max(1,s(e.p90)-s(e.p10)),height:8,fill:De.slate,opacity:.16,rx:2}),t.jsx("rect",{x:s(e.p25),y:a-4,width:Math.max(1,s(e.p75)-s(e.p25)),height:8,fill:De.slate,opacity:.32,rx:2}),t.jsx("line",{x1:s(e.p50),x2:s(e.p50),y1:a-6,y2:a+6,stroke:De.slate,strokeWidth:1.5}),e.ci!=null&&t.jsx("line",{x1:s(e.ci[0]),x2:s(e.ci[1]),y1:a-7.5,y2:a-7.5,stroke:De.slate,strokeWidth:2,opacity:.45,strokeLinecap:"round"}),t.jsx("circle",{cx:s(e.value),cy:a,r:4,fill:r?De.red:De.blue,stroke:"currentColor",strokeWidth:1})]})}const jR={higher_is_better:"higher is better",lower_is_better:"lower is better",neutral:"neither better nor worse"},ZH={acted_on_rate:"rate",acted_on_rate_with_outdated:"rate",thread_resolved_rate:"rate",thread_outdated_rate:"rate",human_reply_rate:"rate",human_followed_last_bot_rate:"rate",median_hours_to_first_human_reply:"hours",overdue_untouched_rate_72h:"rate",overdue_untouched_rate_168h:"rate",findings_per_merged_pr:"count_per_pr",threads_per_merged_pr:"count_per_pr",pr_comment_coverage:"rate",cross_bot_overlap_rate:"rate"};function rm({children:e,className:n=""}){return t.jsx("div",{className:`rounded-lg border border-gray-200 bg-white p-3 dark:border-gray-800 dark:bg-gray-950 ${n}`,children:e})}function Ts({headline:e,message:n,observed:r,required:s,testId:a}){const i=r!=null&&s!=null?Object.keys(s).map(c=>{const d=r[c],u=s[c];return d==null||u==null?null:`${c.replace(/_/g," ")}: ${d} of ${u}`}).filter(c=>c!=null):[];return t.jsx("div",{"data-testid":a,className:"rounded border border-dashed border-gray-300 bg-gray-50 px-2.5 py-2 text-[11px] dark:border-gray-700 dark:bg-gray-900/40",children:t.jsxs("div",{className:"flex items-start gap-1.5",children:[t.jsx(oc,{className:"mt-0.5 shrink-0 text-gray-400"}),t.jsxs("div",{children:[t.jsx("div",{className:"font-medium text-gray-700 dark:text-gray-200",children:e}),t.jsx("p",{className:"mt-0.5 leading-relaxed text-gray-500 dark:text-gray-400",children:n}),i.length>0&&t.jsx("p",{className:"mt-1 tabular-nums text-gray-400 dark:text-gray-500",children:i.join(" · ")})]})]})})}function NR({basis:e}){return t.jsx("span",{className:"rounded bg-gray-500/10 px-1 text-[10px] font-semibold uppercase tracking-wide text-gray-600 dark:text-gray-300","data-testid":`benchmark-cost-basis-${e}`,children:RH[e]})}function Jf({label:e,refusal:n}){return t.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-2 py-1",children:[t.jsx("span",{className:"w-44 shrink-0 text-[11px] text-gray-500 dark:text-gray-400",children:e}),t.jsxs("span",{className:"text-[11px] font-medium text-gray-400",title:n.message,"data-testid":`benchmark-cost-refused-${n.reason}`,children:[t.jsx(ic,{className:"mr-1 inline-block align-[-0.05em]"}),vR[n.reason]]})]})}function ex({label:e,figure:n,detail:r,basis:s,testId:a}){return t.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-2 py-1","data-testid":a,children:[t.jsx("span",{className:"w-44 shrink-0 text-[11px] text-gray-600 dark:text-gray-300",children:e}),t.jsx("span",{className:"shrink-0 text-[11px] font-semibold tabular-nums text-gray-800 dark:text-gray-100",children:n}),t.jsx("span",{className:"text-[10px] tabular-nums text-gray-400",children:r}),t.jsx(NR,{basis:s})]})}function JH({units:e,tally:n}){const r=f.useMemo(()=>jH(e),[e]);return r.length===0?NH(n)==="nothing_comparable"?t.jsx(Ts,{testId:"benchmark-nothing-comparable",headline:Nj.nothing_comparable,message:`None of your ${$t(n.units)} reviewer${n.units===1?"":"s"} produced a single metric this corpus could rank — every one was withheld, and the reason is on each row below. That is a refusal, not a clean result: nothing here says your reviewers are behaving normally, only that there was not enough to compare.`}):t.jsx(rm,{className:"border-gray-200 dark:border-gray-800",children:t.jsxs("div",{className:"flex items-start gap-2 text-[11px]",children:[t.jsx(yp,{className:"mt-0.5 shrink-0 text-gray-400"}),t.jsxs("div",{children:[t.jsx("div",{className:"text-sm font-semibold text-gray-700 dark:text-gray-200",children:Nj.nothing_stands_out}),t.jsxs("p",{className:"mt-0.5 leading-relaxed text-gray-500 dark:text-gray-400",children:[$t(n.compared)," comparison",n.compared===1?"":"s"," across ",$t(n.placed)," placed reviewer",n.placed===1?"":"s"," — none of them far enough from its peer cohort, in both rank and real units, to be worth acting on. The distributions are below."]})]})]})}):t.jsx("div",{className:"space-y-2","data-testid":"benchmark-findings",children:r.map(s=>{const{anomaly:a}=s,i=s.rankRepos??a.cohortRepos;return t.jsxs("div",{className:"rounded-lg border border-amber-300 bg-amber-50 p-3 dark:border-amber-800 dark:bg-amber-950/30",children:[t.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-2 gap-y-1",children:[t.jsx(Jt,{className:"shrink-0 text-amber-600 dark:text-amber-400"}),t.jsx("span",{className:"text-sm font-semibold text-amber-800 dark:text-amber-200",children:s.headline}),t.jsxs("span",{className:"text-[11px] text-amber-700/80 dark:text-amber-300/80",children:[Xo(s.unit.botKind)," in ",tc(s.unit)]})]}),t.jsx("p",{className:"mt-1 text-[12px] leading-relaxed text-amber-800 dark:text-amber-200",children:a.action}),t.jsxs("dl",{className:"mt-2 grid grid-cols-1 gap-x-4 gap-y-1 text-[11px] sm:grid-cols-2",children:[t.jsxs("div",{className:"flex gap-1.5",children:[t.jsx("dt",{className:"text-amber-700/80 dark:text-amber-300/90",children:"Rank"}),t.jsx("dd",{className:"tabular-nums text-amber-900 dark:text-amber-100",children:yR({percentile:a.share.percentile,nRepos:i,bandLabel:a.bandLabel})})]}),t.jsxs("div",{className:"flex gap-1.5",children:[t.jsx("dt",{className:"text-amber-700/80 dark:text-amber-300/90",children:"Gap"}),t.jsxs("dd",{className:"tabular-nums text-amber-900 dark:text-amber-100",children:[s.metricLabel,": yours ",Nr(a.magnitude.value,a.magnitude.unit),","," ","a typical team"," ",Nr(a.magnitude.cohortMedian,a.magnitude.unit)," ","(measured over ",$t(a.units),a.unitsNoun!=null?` of your ${a.unitsNoun}`:" of yours",")"]})]})]})]},s.key)})})}function ez({unit:e,width:n}){var u;const r=f.useMemo(()=>vH(e),[e]),s=f.useMemo(()=>new Set(e.anomalies.map(m=>m.metric)),[e.anomalies]),a=bR(e.botKind),i=e.placement,c=i.status==="placed"?kH({activity:e.activity.mergedPrsLast14d,bandRange:i.bandRange,aboveTopBandBy:i.aboveTopBandBy}):null,d=f.useMemo(()=>wH(r),[r]);return t.jsxs(rm,{children:[t.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-2 gap-y-1",children:[t.jsxs("span",{className:"inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[11px] font-medium",style:a!=null?{color:a,background:`${a}1a`}:void 0,children:[t.jsx(Lt,{size:12}),Xo(e.botKind)]}),t.jsx("span",{className:"text-xs font-medium text-gray-700 dark:text-gray-200",children:tc(e)}),e.reviewers.length>0&&t.jsx("span",{className:"text-[11px] text-gray-500 dark:text-gray-400",children:e.reviewers.map(m=>m.login).join(", ")})]}),i.status==="placed"?t.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-x-3 gap-y-0.5 text-[11px] text-gray-500 dark:text-gray-400",children:[t.jsxs("span",{className:"tabular-nums",children:["Size group ",i.bandLabel," (",$t(i.bandRange[0]),"–",$t(i.bandRange[1])," merged PRs a fortnight)"]}),t.jsxs("span",{className:"tabular-nums",children:["Compared with ",$t(i.cohortRepos)," other teams’ repos this size"]}),t.jsxs("span",{className:"tabular-nums",children:["You: ",$t(e.activity.mergedPrsLast14d)," merged in 14 days"]}),t.jsxs("span",{className:"tabular-nums",title:"The corpus walk capped each repository the same way; folding your whole history instead would measure older threads than any cohort describes.",children:[$t(e.activity.prsConsidered)," of its most recent PRs read"]}),i.aboveTopBandBy!=null&&t.jsxs("span",{className:"text-amber-600 dark:text-amber-400",children:["Busier than the top band’s own edge by ",$t(i.aboveTopBandBy)," — the outermost band is open in the direction it faces."]}),c!=null&&t.jsx("span",{className:"text-gray-400",children:c})]}):t.jsx("div",{className:"mt-2",children:t.jsx(Ts,{testId:`benchmark-placement-refusal-${i.reason}`,headline:tm[i.reason],message:i.message,observed:i.observed,required:i.required})}),d!=null?t.jsx("div",{className:"mt-2",children:t.jsx(Ts,{testId:`benchmark-metric-collapsed-${d}`,headline:`${kj[d]} — all ${$t(r.length)} metrics`,message:(((u=r[0])==null?void 0:u.metric.status)==="excluded"?r[0].metric.message:"")+" Every metric this corpus measures is withheld for the same reason, so this is one refusal, not "+$t(r.length)+" measurements that each came back empty."})}):t.jsx("div",{className:"mt-2 divide-y divide-gray-100 dark:divide-gray-800/70",children:r.map(m=>{const h=m.metric;if(h.status==="excluded")return t.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-2 py-1.5",children:[t.jsx("span",{className:"w-52 shrink-0 text-[11px] text-gray-500 dark:text-gray-400",children:m.label}),t.jsxs("span",{className:"text-[11px] font-medium text-gray-400",title:h.message,"data-testid":`benchmark-metric-excluded-${h.reason}`,children:[t.jsx(ic,{className:"mr-1 inline-block align-[-0.05em]"}),kj[h.reason]]})]},m.name);const g=h.status==="compared"?h.cohort.unit:ZH[m.name]??"";if(h.status==="uncompared")return t.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-2 py-1.5",children:[t.jsx("span",{className:"w-52 shrink-0 text-[11px] text-gray-500 dark:text-gray-400",children:m.label}),t.jsx("span",{className:"w-16 shrink-0 text-right text-[11px] font-semibold tabular-nums text-gray-700 dark:text-gray-200",children:Nr(h.value,g)}),t.jsx("span",{className:"text-[11px] text-gray-400",title:h.cohortRefusal.message,"data-testid":"benchmark-metric-uncompared",children:"No peer distribution for this metric in this cohort"})]},m.name);const x=bH(h.cohort.quantiles,h.value,h.cohort.ciMedian95),y=s.has(m.name);return t.jsxs("div",{className:"py-1.5",children:[t.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-2",children:[t.jsxs("span",{className:"w-52 shrink-0 text-[11px] text-gray-600 dark:text-gray-300",children:[m.label,t.jsx("span",{className:"ml-1 text-[11px] text-gray-500 dark:text-gray-400",children:jR[h.cohort.direction]})]}),t.jsx("span",{className:"w-16 shrink-0 text-right text-[11px] font-semibold tabular-nums text-gray-800 dark:text-gray-100",children:Nr(h.value,h.cohort.unit)}),t.jsx("span",{className:"text-[11px] tabular-nums text-gray-500 dark:text-gray-400",children:yR({percentile:h.percentile,nRepos:h.cohort.nRepos,bandLabel:i.status==="placed"?i.bandLabel:""})}),t.jsxs("span",{className:"text-[10px] tabular-nums text-gray-400",children:["over ",$t(h.units)," of yours"]})]}),t.jsxs("div",{className:"mt-1 flex items-center gap-2",children:[t.jsxs("span",{className:"w-52 shrink-0 text-[10px] tabular-nums text-gray-400",children:["peer median ",Nr(h.cohort.quantiles.p50??0,h.cohort.unit),h.cohort.ciMedian95!=null&&t.jsxs(t.Fragment,{children:[" ","(95% CI ",Nr(h.cohort.ciMedian95[0],h.cohort.unit),"–",Nr(h.cohort.ciMedian95[1],h.cohort.unit),")"]})]}),x!=null&&n>0?t.jsx("span",{title:`Cohort p10 ${Nr(h.cohort.quantiles.p10??0,h.cohort.unit)} to p90 ${Nr(h.cohort.quantiles.p90??0,h.cohort.unit)}; your value ${Nr(h.value,h.cohort.unit)}`,children:t.jsx(XH,{geom:x,width:Math.max(80,n-240),flagged:y})}):t.jsx("span",{className:"text-[11px] text-gray-500 dark:text-gray-400",children:x==null?"No readable distribution to draw":""})]})]},m.name)})})]})}function tz({cost:e,expectation:n}){const r=KH(e,n),s=zH(e),a=WH(),i=$H(e),c=_H(e),d=PH(e),u=qH(e),m=HH(e),h=UH(e);return t.jsxs("div",{className:"mt-2 rounded border border-gray-200 bg-gray-50/60 px-2.5 py-2 dark:border-gray-800 dark:bg-gray-900/30","data-testid":"benchmark-workspace-cost",children:[t.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-2 gap-y-1",children:[t.jsxs("span",{className:"inline-flex items-center gap-1 text-[11px] font-semibold text-gray-700 dark:text-gray-200",children:[t.jsx(Q4,{size:12,className:"text-gray-400"}),"Cost"]}),t.jsx("span",{className:"text-[11px] tabular-nums text-gray-600 dark:text-gray-300",children:DH(e)}),t.jsx(NR,{basis:"stored"})]}),e.monthlyUsd!=null&&t.jsx("p",{className:"mt-1 text-[10px] leading-relaxed text-gray-500 dark:text-gray-400","data-testid":"benchmark-workspace-cost-coverage",children:a}),i!=null&&t.jsx("p",{className:"mt-0.5 text-[10px] leading-relaxed text-gray-400",children:i}),c!=null&&t.jsx("p",{className:"mt-0.5 text-[10px] leading-relaxed text-amber-700 dark:text-amber-400","data-testid":"benchmark-cost-seat-unresolved",children:c}),d!=null&&t.jsx("p",{className:"mt-0.5 text-[10px] leading-relaxed text-amber-700 dark:text-amber-400","data-testid":"benchmark-cost-seat-zero",children:d}),s!=null?t.jsx("div",{className:"mt-1.5",children:t.jsx(Ts,{testId:`benchmark-workspace-cost-collapsed-${s}`,headline:vR[s],message:(e.perMergedPr.status==="refused"?e.perMergedPr.message:"")+" Every figure this price would produce is withheld for the same reason, so this is one refusal rather than three measurements that each came back empty."})}):t.jsxs("div",{className:"mt-1 divide-y divide-gray-200/70 dark:divide-gray-800/70",children:[e.perMergedPr.status==="value"?t.jsx(ex,{testId:"benchmark-workspace-cost-per-merged-pr",label:"Per merged PR",figure:Gs(e.perMergedPr.value),detail:`over ${$t(e.perMergedPr.mergedPrs)} merged across the estate in the last ${$t(e.windowDays)} days`,basis:"counted"}):t.jsx(Jf,{label:"Per merged PR",refusal:e.perMergedPr}),e.yours.status==="value"?t.jsx(ex,{testId:"benchmark-workspace-cost-per-acted-on",label:Sj(e),figure:Gs(e.yours.perActedOnUsd),detail:BH(e,e.yours),basis:"counted"}):t.jsx(Jf,{label:Sj(e),refusal:e.yours}),t.jsx(nz,{expectation:n})]}),r!=null&&t.jsxs("div",{className:"mt-1.5 space-y-1 border-t border-gray-200 pt-1.5 text-[12px] leading-relaxed text-gray-700 dark:border-gray-800 dark:text-gray-200","data-testid":`benchmark-workspace-cost-headline-${r.tone}`,children:[t.jsx("p",{"data-testid":"benchmark-workspace-cost-headline-spend",children:r.spend}),r.comparison!=null&&t.jsx("p",{className:"text-gray-500 dark:text-gray-400","data-testid":"benchmark-workspace-cost-headline-comparison",children:r.comparison})]}),s==null&&t.jsx("p",{className:"mt-1 text-[10px] leading-relaxed text-gray-400",children:e.basisNote}),u!=null&&t.jsx("p",{className:"mt-0.5 text-[10px] leading-relaxed text-gray-400","data-testid":"benchmark-workspace-cost-span-unobserved",children:u}),m!=null&&t.jsx("p",{className:"mt-0.5 text-[10px] leading-relaxed text-gray-400","data-testid":"benchmark-workspace-cost-partial-window",children:m}),h!=null&&t.jsx("p",{className:"mt-0.5 text-[10px] leading-relaxed text-amber-700 dark:text-amber-400","data-testid":"benchmark-workspace-cost-window-incomplete",children:h})]})}function nz({expectation:e}){const n="If your team used it as much";return e.status!=="value"?null:e.perActedOnUsd!=null&&e.actedPerMonthAtPeer!=null?t.jsx(ex,{testId:"benchmark-workspace-cost-counterfactual",label:n,figure:Gs(e.perActedOnUsd),detail:`your price, divided by the roughly ${kR(e.actedPerMonthAtPeer)} comments a month your team would have used if it used this bot as much as teams with similar repos do`,basis:"fitted"}):e.moneyRefusal!=null?t.jsx(Jf,{label:n,refusal:e.moneyRefusal}):null}const rz=["volume","outcome","overdueEligible","overdueUntouched","repository"],sz={volume:{label:"Volume",population:"merged PRs only"},outcome:{label:"Thread outcomes",population:"merged or not"},overdueEligible:{label:"Eligible to go overdue",population:"by grace"},overdueUntouched:{label:"Still untouched past grace",population:"by grace"},repository:{label:"Repository disclosure",population:"what was read"}},az={outcome:/^threads(?=[A-Z])/};function oz(e,n){if(/^\d+$/.test(e))return`${e} h`;const r=n!=null?az[n]:void 0,s=r!=null?e.replace(r,""):e,i=(s.length>0?s:e).replace(/([a-z0-9])([A-Z])/g,"$1 $2").toLowerCase().trim();return(i.charAt(0).toUpperCase()+i.slice(1)).replace(/\bPrs\b/g,"PRs")}function iz({counters:e}){const[n,r]=f.useState(!1);return t.jsxs("div",{className:"mt-2","data-testid":"benchmark-rollup-counters",children:[t.jsxs("button",{type:"button",onClick:()=>r(s=>!s),"aria-expanded":n,"data-testid":"benchmark-rollup-counters-toggle",className:"flex items-center gap-1.5 text-[11px] font-semibold text-gray-700 hover:text-gray-900 dark:text-gray-200 dark:hover:text-gray-50",children:[t.jsx(Mt,{dir:n?"down":"right"}),t.jsx(bx,{size:12,className:"text-gray-400"}),"The raw counts behind every figure on this card"]}),n?t.jsx("div",{className:"mt-1 flex flex-col gap-1.5",children:rz.map(s=>{const a=Object.entries(e[s]);if(a.length===0)return null;const i=sz[s];return t.jsxs("div",{children:[t.jsxs("div",{className:"text-[10px] font-semibold uppercase tracking-wide text-gray-400",children:[i.label," ",t.jsxs("span",{className:"font-normal normal-case tracking-normal text-gray-400/80",children:["· ",i.population]})]}),t.jsx("dl",{className:"mt-0.5 flex flex-wrap items-baseline gap-x-3 gap-y-0.5",children:a.map(([c,d])=>t.jsxs("div",{className:"flex items-baseline gap-1",children:[t.jsx("dt",{className:"text-[10px] text-gray-500 dark:text-gray-400",children:oz(c,s)}),t.jsx("dd",{className:"text-[10px] font-semibold tabular-nums text-gray-700 dark:text-gray-200",children:$t(d)})]},c))})]},s)})}):null]})}function lz({rows:e,statedRefusal:n}){return t.jsxs("div",{className:"mt-2","data-testid":"benchmark-rollup-evidence",children:[t.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] font-semibold text-gray-700 dark:text-gray-200",children:[t.jsx(xp,{size:12,className:"text-gray-400"}),"Where these numbers come from"]}),t.jsx("div",{className:"mt-1 overflow-x-auto",children:t.jsxs("table",{className:"w-full min-w-[32rem] border-collapse text-[11px]",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"border-b border-gray-200 text-left text-[10px] uppercase tracking-wide text-gray-400 dark:border-gray-800",children:[t.jsx("th",{scope:"col",className:"py-1 pr-3 font-semibold",children:"Repository"}),t.jsx("th",{scope:"col",className:"py-1 pr-3 font-semibold",children:"Size group"}),t.jsx("th",{scope:"col",className:"py-1 pr-3 text-right font-semibold",children:"Merged PRs, 14 days"}),t.jsx("th",{scope:"col",className:"py-1 pr-3 text-right font-semibold",children:"Acted on"}),t.jsx("th",{scope:"col",className:"py-1 text-right font-semibold",children:"Rank in its group"})]})}),t.jsx("tbody",{className:"divide-y divide-gray-100 dark:divide-gray-800/70",children:e.map(r=>t.jsxs("tr",{children:[t.jsx("td",{className:"py-1 pr-3 text-gray-700 dark:text-gray-200",children:r.repo}),t.jsx("td",{className:"py-1 pr-3 text-gray-500 dark:text-gray-400",children:r.bandRefused?n!=null&&r.refusalIsVendorWide?t.jsx("span",{className:"text-gray-400",children:"—"}):t.jsxs("span",{className:"text-gray-400",children:[t.jsx(ic,{className:"mr-1 inline-block align-[-0.05em]"}),r.band]}):t.jsx("span",{className:"tabular-nums",children:r.band})}),t.jsx("td",{className:"py-1 pr-3 text-right tabular-nums text-gray-600 dark:text-gray-300",children:r.mergedPrs}),t.jsx("td",{className:"py-1 pr-3 text-right tabular-nums text-gray-600 dark:text-gray-300",children:r.actedOn}),t.jsx("td",{className:"py-1 text-right tabular-nums text-gray-600 dark:text-gray-300",children:r.percentile})]},r.key))})]})}),t.jsx("p",{className:"mt-1 text-[10px] leading-relaxed text-gray-400",children:"A dash means this repo had too little to measure — never that the answer was zero. Its counts are still included in the totals above. Each rank is against other repos of that repo’s own size, so the ranks in this column are not comparable with each other."})]})}function cz({row:e}){const{rollup:n}=e,r=f.useMemo(()=>VH(n.contributions),[n.contributions]),s=LH(n.spread),a=FH(n.expectation),i=OH(n.spread,n.expectation);return t.jsxs(rm,{children:[t.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-2 gap-y-1",title:e.title,children:[t.jsxs("span",{className:"inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[11px] font-medium",style:e.color!=null?{color:e.color,background:`${e.color}1a`}:void 0,children:[t.jsx(Lt,{size:12}),e.label]}),t.jsx("span",{className:"text-xs font-medium text-gray-700 dark:text-gray-200",children:e.coverage}),n.reviewers.length>0&&t.jsx("span",{className:"text-[11px] text-gray-500 dark:text-gray-400",children:n.reviewers.map(c=>c.login).join(", ")})]}),n.cost!=null&&t.jsx(tz,{cost:n.cost,expectation:n.expectation}),s!=null&&t.jsxs("div",{className:"mt-2 flex items-start gap-1.5 text-[12px] leading-relaxed text-gray-600 dark:text-gray-300","data-testid":"benchmark-rollup-spread",children:[t.jsx(yp,{className:"mt-0.5 shrink-0 text-gray-400"}),t.jsx("p",{children:s})]}),i!=null?t.jsx("div",{className:"mt-2",children:t.jsx(Ts,{testId:`benchmark-rollup-comparisons-refused-${i.reason}`,headline:w0[i.reason],message:i.message})}):n.spread.status==="refused"&&t.jsx("div",{className:"mt-2",children:t.jsx(Ts,{testId:`benchmark-rollup-spread-refused-${n.spread.reason}`,headline:w0[n.spread.reason],message:n.spread.message})}),a!=null&&t.jsxs("div",{className:"mt-2 flex items-start gap-1.5 text-[12px] leading-relaxed text-gray-600 dark:text-gray-300","data-testid":"benchmark-rollup-expectation",children:[t.jsx(vp,{size:13,className:"mt-0.5 shrink-0 text-gray-400"}),t.jsx("p",{children:a})]}),i==null&&n.expectation.status==="refused"&&t.jsx("div",{className:"mt-2",children:t.jsx(Ts,{testId:`benchmark-rollup-expectation-refused-${n.expectation.reason}`,headline:w0[n.expectation.reason],message:n.expectation.message})}),t.jsx(lz,{rows:r,statedRefusal:(i==null?void 0:i.reason)??null}),t.jsx(iz,{counters:n.counters})]})}function dz(){var c,d;const[e,n]=f.useState(!1),{data:r,isLoading:s}=lH(e),a=((c=r==null?void 0:r.manifest)==null?void 0:c.metricSpecs)??[],i=((d=r==null?void 0:r.manifest)==null?void 0:d.populations)??{};return t.jsxs("div",{className:"rounded-lg border border-gray-200 dark:border-gray-800",children:[t.jsxs("button",{type:"button",onClick:()=>n(u=>!u),"aria-expanded":e,"data-testid":"benchmark-specs-toggle",className:"flex w-full items-center gap-1.5 px-3 py-2 text-left text-[11px] font-medium text-gray-600 hover:bg-gray-50 dark:text-gray-300 dark:hover:bg-gray-900/60",children:[t.jsx(Mt,{dir:e?"down":"right"}),"How these are measured",t.jsx("span",{className:"font-normal text-gray-400",children:"— the peer corpus counts these differently from this app’s own bot columns"})]}),e&&t.jsxs("div",{className:"border-t border-gray-200 px-3 py-2 dark:border-gray-800",children:[s&&t.jsx(Bl,{className:"h-16"}),!s&&a.length===0&&t.jsx("p",{className:"text-[11px] text-gray-400",children:"No metric definitions are available in this build."}),a.length>0&&t.jsx("dl",{className:"space-y-2",children:a.map(u=>t.jsxs("div",{children:[t.jsxs("dt",{className:"text-[11px] font-medium text-gray-700 dark:text-gray-200",children:[nm(u.name)," ",t.jsxs("span",{className:"font-normal text-gray-400",children:[xR[u.derivation]," · ",jR[u.direction]," · needs at least ",$t(u.minUnits)]})]}),t.jsxs("dd",{className:"text-[12px] leading-relaxed text-gray-500 dark:text-gray-400",children:[u.definition,t.jsx("br",{}),t.jsxs("span",{className:"text-gray-400",children:[u.numerator," ÷ ",u.denominator," · over ",i[u.population]??u.population]})]})]},u.name))})]})]})}function uz({repoId:e}={}){const n=G(u=>u.workspaceId),r=f.useMemo(()=>e!=null?[e]:null,[e]),{data:s,isLoading:a,isError:i}=iH(n,r),[c,d]=Xs();return t.jsx("div",{className:"space-y-3",ref:c,"data-testid":"benchmark-panel",children:t.jsx(hz,{data:s,isLoading:a,isError:i,width:d,isRail:e==null})})}function hz({data:e,isLoading:n,isError:r,width:s,isRail:a}){const i=f.useMemo(()=>CH((e==null?void 0:e.units)??[]),[e==null?void 0:e.units]),c=f.useMemo(()=>SH(i),[i]),d=f.useMemo(()=>EH(e==null?void 0:e.absentMetrics),[e==null?void 0:e.absentMetrics]),u=f.useMemo(()=>YH((e==null?void 0:e.rollup)??[]),[e==null?void 0:e.rollup]);return n?t.jsx(Bl,{className:"h-40"}):r||e==null?t.jsx(rm,{children:t.jsx("p",{className:"text-[11px] text-gray-500 dark:text-gray-400",children:"Could not load the peer benchmark for this Workspace."})}):e.available?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px] text-gray-600 dark:text-gray-300",children:[t.jsxs("span",{className:"inline-flex items-center gap-1",children:[t.jsx(vp,{size:12}),"Every bot here is compared with the same bot running in other teams’ repos of a similar size."]}),e.staleness!=null&&t.jsxs("span",{title:`The newest measurement in the comparison data is ${Math.round(e.staleness.corpusAgeDays)} days old.`,children:[pH[e.staleness.state]," ·"," ",Math.round(e.staleness.corpusAgeDays)," days old"]}),e.fitKey!=null&&e.fitKey!==""&&t.jsx("span",{className:"font-mono",children:e.fitKey})]}),e.truncated===!0&&t.jsx(Ts,{testId:"benchmark-truncated",headline:"More repositories than one request folds",message:"This Workspace holds more (repository × reviewer) pairs than one request may measure, so only the first are shown. The rest are not “no data”"+(a?": every card below sums a partial estate, so its counters and its spread still read as sums over the repositories named on it, while its money is withheld — a whole subscription over part of the work is not an approximation of the answer. Open a repository’s own Bots tab to place it on its own.":".")}),i.length===0?t.jsx(Ts,{testId:"benchmark-no-units",headline:"No automated reviewer to place",message:"Nothing in this Workspace is classified as an automated reviewer with activity to measure. Bots → Settings is where a reviewer is classified; a bot classified there appears here once it has commented."}):t.jsxs(t.Fragment,{children:[t.jsx(JH,{units:i,tally:c}),a?u.length>0?t.jsx("div",{className:"space-y-2",children:u.map(m=>t.jsx(cz,{row:m},m.key))}):e.rollup==null?t.jsx(Ts,{testId:"benchmark-no-rollup",headline:"No Workspace rollup is being served",message:"This build served the per-repository placements but no per-vendor rollup, which is what this view is made of. A repository’s own Bots tab still shows its placements, and nothing here is a statement about your reviewers."}):t.jsx(Ts,{testId:"benchmark-no-live-reviewers",headline:"No reviewer commented on the pull requests we read",message:"The rollup ran and found no automated reviewer that has commented in the pull requests read here, so there is nothing to place, pool or price — every card would be a column of zeros about a reviewer that has not been given the chance to do anything. That is a statement about this sample, not about your reviewers: the walk is capped at each repository’s most recently updated pull requests, so a reviewer that is busy outside that window is absent here and still working. A reviewer classified in Bots → Settings appears once it has commented on a pull request in range; each repository’s own Bots tab says the same thing per repository."}):t.jsx("div",{className:"space-y-2",children:i.map(m=>t.jsx(ez,{unit:m,width:s},`${m.repoId}:${m.vendor??m.botKind??"bot"}`))})]}),d.length>0&&t.jsxs("div",{className:"rounded-lg border border-dashed border-gray-300 px-3 py-2 dark:border-gray-700","data-testid":"benchmark-absent-metrics",children:[t.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] font-medium text-gray-600 dark:text-gray-300",children:[t.jsx(oc,{className:"text-gray-400"}),"Not in this corpus yet",t.jsx("span",{className:"rounded bg-gray-500/10 px-1 text-[10px] font-semibold uppercase tracking-wide text-gray-600 dark:text-gray-300",children:xR.model})]}),t.jsx("ul",{className:"mt-1 space-y-1",children:d.map(m=>t.jsxs("li",{className:"text-[12px] leading-relaxed text-gray-500 dark:text-gray-400",children:[t.jsx("span",{className:"font-medium text-gray-600 dark:text-gray-300",children:m.label})," —"," ",m.note,Object.entries(m.requires).length>0&&t.jsxs("span",{className:"text-gray-400",children:[" ","(",Object.entries(m.requires).map(([h,g])=>`${h.replace(/_/g," ")}: ${g}`).join("; "),")"]})]},m.name))})]}),t.jsx(dz,{}),e.disclosures!=null&&e.disclosures.length>0&&t.jsx("ul",{className:"space-y-1 text-[10px] leading-relaxed text-gray-400",children:e.disclosures.map(m=>t.jsxs("li",{children:["· ",m]},m))})]}):t.jsx(Ts,{testId:"benchmark-unavailable",headline:e.reason!=null?uH[e.reason]:"No comparison data is available",message:e.message??"This tab compares each of your review bots against the same bot running in other teams’ repositories of a similar size. That comparison data is not available in this build."})}function SR({repoId:e}={}){const n=G(b=>b.workspaceId),r=G(b=>b.botAnalyticsWindow),s=f.useMemo(()=>e!=null?[e]:null,[e]),{data:a}=Qp(n,r,!0,s),i=(a==null?void 0:a.totals.botOnlyPrs)??0,c=G(b=>b.openBotOnlyDetail),d=G(b=>b.botsInnerTab),u=G(b=>b.setBotsInnerTab),{botAdvisor:m,activityDigest:h}=vt(),g=e==null&&m,x=h,y=cH(d,{showAdvisor:g,showThemes:x});return t.jsxs("div",{className:"space-y-3","data-testid":"bots-view",children:[t.jsxs("div",{className:"flex flex-wrap items-baseline gap-2",children:[t.jsx("h2",{className:"text-sm font-semibold text-gray-700 dark:text-gray-200",children:"Review bots"}),t.jsx("span",{className:"text-[11px] text-gray-400",children:e!=null?"The calm layer above your review bots — this Workspace’s bots, measured on this repo.":"The calm layer above your review bots — detect, measure, and triage the automated reviewers in this Workspace."})]}),t.jsx("div",{role:"tablist",className:"flex gap-1 border-b border-gray-200 dark:border-gray-800",children:[{key:"roi",label:"ROI"},...x?[{key:"themes",label:"Themes"}]:[],...g?[{key:"advisor",label:"Advisor"}]:[],{key:"benchmark",label:"Benchmark"},{key:"settings",label:"Settings"}].map(b=>{const w=y===b.key;return t.jsxs("button",{type:"button",role:"tab","aria-selected":w,onClick:()=>u(b.key),className:`-mb-px flex items-center gap-1 rounded-t-md border border-b-0 px-3 py-1.5 text-xs font-medium ${w?"border-gray-300 bg-white text-sky-600 dark:border-gray-700 dark:bg-gray-950 dark:text-sky-300":"border-transparent text-gray-500 hover:bg-gray-100 dark:text-gray-400 dark:hover:bg-gray-900/60"}`,children:[b.label,(b.key==="advisor"||b.key==="themes"||b.key==="roi"||b.key==="benchmark")&&t.jsx(ec,{variant:"tab",title:b.key==="roi"?"The ROI table is part of Pro.":b.key==="benchmark"?"The peer benchmark is part of Pro.":b.key==="themes"?"The themes summary is part of Pro.":"The Bot Tuning Advisor is part of Pro."})]},b.key)})}),t.jsx(fy,{}),y==="advisor"?t.jsx(zU,{}):y==="themes"?t.jsx(TU,{repoIds:s}):y==="benchmark"?t.jsx(pz,{repoId:e}):y==="settings"?t.jsx(aH,{repoId:e}):t.jsxs(t.Fragment,{children:[i>0&&t.jsxs("button",{type:"button",onClick:()=>c(e??null),"data-testid":"bot-only-caption",title:"Show the open PRs only a bot reviewed",className:"flex w-full items-start gap-1.5 rounded-lg border border-amber-300 bg-amber-50 px-3 py-2 text-left text-[11px] text-amber-700 hover:bg-amber-100 dark:border-amber-800 dark:bg-amber-950/30 dark:text-amber-300 dark:hover:bg-amber-900/40",children:[t.jsxs("span",{className:"flex-1",children:[t.jsx(Lt,{className:"mr-1 inline-block align-[-0.1em]"}),"Only a bot reviewed"," ",t.jsx("span",{className:"font-semibold tabular-nums",children:i})," ","open PR",i===1?"":"s"," — no human review yet. Consider a human pass before they merge."," ",t.jsx("span",{className:"text-amber-600/80 dark:text-amber-400/70",children:"Open PRs only, any age."})]}),t.jsx("span",{className:"shrink-0 self-center rounded border border-amber-400 px-1.5 py-0.5 text-[10px] font-medium text-amber-700 dark:border-amber-600/70 dark:text-amber-300",children:"Show list →"})]}),t.jsx(rU,{workspaceId:n,repoIds:s}),t.jsx(Y9,{suggestions:(a==null?void 0:a.suggestions)??[]}),t.jsx(sU,{repoId:e}),t.jsx(jU,{repoId:e}),t.jsx("div",{className:"border-t border-gray-200 pt-3 dark:border-gray-800",children:t.jsx(xd,{repoId:e,botsMode:!0})})]})]})}function pz({repoId:e}){const{botDepth:n}=vt(),r=dH(uc(n));return r==="blank"?null:r==="locked"?t.jsx(dc,{heading:"Peer benchmark",testId:"benchmark-locked",children:"Is this reviewer normal? Benchmark places each of your bots against the same product running in repositories of comparable activity — how much it writes, how much of it your team acts on, how long a person takes to reach it — and names the ones that are far enough from their peers, in both rank and real terms, to be worth acting on."}):t.jsx(uz,{repoId:e})}const mz=5,gz=["repos","timeline","open-prs","users","my-turn","me",...ac,"repo-search","repo-suggested"];function Rj(e){return e>=1e6?`${(e/1e6).toFixed(1)}m`:e>=1e3?`${(e/1e3).toFixed(e>=1e4?0:1)}k`:String(e)}function fz({login:e,src:n}){return n?t.jsx("img",{src:n,alt:e,width:20,height:20,className:"mt-0.5 h-5 w-5 shrink-0 rounded-full"}):t.jsx("span",{className:"mt-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-gray-300 text-[9px] font-semibold text-gray-700 dark:bg-gray-700 dark:text-gray-200",children:e.slice(0,2).toUpperCase()})}function xz(){const e=He(),n=G($=>$.requestSyncModal),{data:r,isLoading:s,isError:a}=Oe({queryKey:["repo-suggested"],queryFn:()=>he.suggestedRepos(),staleTime:5*6e4}),i=f.useMemo(()=>(r==null?void 0:r.results)??[],[r]),[c,d]=f.useState(new Set),[u,m]=f.useState(!1);f.useEffect(()=>{!u&&i.length>0&&(d(new Set(i.slice(0,mz).map($=>$.githubNodeId))),m(!0))},[u,i]);const[h,g]=f.useState(!1),[x,y]=f.useState(null),[b,w]=f.useState([]),[k,j]=f.useState([]),N=i.filter($=>c.has($.githubNodeId));function I($){h||d(P=>{const C=new Set(P);return C.has($)?C.delete($):C.add($),C})}function S($){for(const P of $)n(P);for(const P of gz)e.invalidateQueries({queryKey:[P]});j([])}async function T(){if(h||N.length===0)return;g(!0),w([]);const $=[],P=[];let C=0;for(const L of N){y({done:C,total:N.length,current:L.fullName});try{const F=await he.addRepo({owner:L.owner,name:L.name});P.push(F.id)}catch(F){$.push({fullName:L.fullName,message:F instanceof cn?F.message:"Failed to add"})}C++}y(null),w($),g(!1),$.length===0?S(P):j(P)}return t.jsxs("div",{className:"mx-auto max-w-2xl space-y-5 py-6",children:[t.jsxs("header",{children:[t.jsx("h2",{className:"text-lg font-semibold text-gray-800 dark:text-gray-100",children:"Add the repos you work on"}),t.jsx("p",{className:"mt-1 text-sm text-gray-500 dark:text-gray-400",children:"Limn tracks the repos you care about — here’s what you’ve been working on."})]}),s?t.jsx("div",{className:"space-y-2",children:[0,1,2,3].map($=>t.jsx("div",{className:"h-14 animate-pulse rounded-lg border border-gray-200 bg-gray-50 dark:border-gray-800 dark:bg-gray-900/40"},$))}):a?t.jsx("p",{className:"text-xs text-gray-400",children:"Couldn’t detect your recent repos — add one below to get started."}):i.length===0?t.jsx("p",{className:"text-xs text-gray-400",children:"No recent activity found — add any repo below to get started."}):t.jsxs("div",{className:"space-y-3",children:[t.jsx("div",{className:"overflow-hidden rounded-lg border border-gray-200 dark:border-gray-800",children:i.map($=>{const P=c.has($.githubNodeId);return t.jsxs("label",{className:`flex cursor-pointer items-start gap-2.5 border-b border-gray-100 px-3 py-2 last:border-b-0 dark:border-gray-800/70 ${P?"bg-sky-50/60 dark:bg-sky-950/20":"hover:bg-gray-50 dark:hover:bg-gray-800/40"} ${h?"cursor-default opacity-70":""}`,children:[t.jsx("input",{type:"checkbox",checked:P,disabled:h,onChange:()=>I($.githubNodeId),className:"mt-1 h-3.5 w-3.5 shrink-0 accent-sky-500"}),t.jsx(fz,{login:$.owner,src:$.ownerAvatarUrl}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsxs("span",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:"truncate text-xs font-medium text-gray-800 dark:text-gray-100",title:$.fullName,children:$.fullName}),$.isPrivate&&t.jsx("span",{className:"shrink-0 rounded bg-gray-200 px-1 text-[9px] uppercase tracking-wide text-gray-500 dark:bg-gray-700 dark:text-gray-300",children:"private"}),$.isOwnedOrMember&&t.jsx("span",{className:"shrink-0 rounded bg-sky-100 px-1 text-[9px] uppercase tracking-wide text-sky-700 dark:bg-sky-900/50 dark:text-sky-300",children:"yours"})]}),$.description&&t.jsx("span",{className:"mt-0.5 line-clamp-2 text-[11px] text-gray-500 dark:text-gray-400",children:$.description}),t.jsxs("span",{className:"mt-0.5 flex items-center gap-2 text-[10px] text-gray-400",children:[t.jsxs("span",{className:"flex items-center gap-1",title:`${$.stargazerCount} stars`,children:[t.jsx(kx,{size:10}),Rj($.stargazerCount)]}),t.jsx("span",{"aria-hidden":!0,children:"·"}),t.jsxs("span",{title:`${$.openPrCount} open pull requests`,children:[Rj($.openPrCount)," open PR",$.openPrCount===1?"":"s"]})]})]})]},$.githubNodeId)})}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("button",{type:"button",onClick:T,disabled:h||N.length===0,className:"rounded bg-sky-600 px-3 py-1.5 text-xs font-medium text-white hover:bg-sky-700 disabled:cursor-not-allowed disabled:opacity-50",children:h?x?`Adding ${x.done+1}/${x.total} — ${x.current}…`:"Adding…":`Add ${N.length} selected`}),!h&&t.jsxs("span",{className:"text-[11px] text-gray-400",children:[N.length," of ",i.length," selected"]})]}),b.length>0&&t.jsxs("div",{className:"rounded border border-amber-300 bg-amber-50 px-3 py-2 text-[11px] text-amber-700 dark:border-amber-800 dark:bg-amber-950/40 dark:text-amber-300",children:[t.jsxs("div",{className:"font-semibold",children:["Couldn’t add ",b.length," repo",b.length===1?"":"s",":"]}),t.jsx("ul",{className:"mt-1 space-y-0.5",children:b.map($=>t.jsxs("li",{children:[t.jsx("span",{className:"font-medium",children:$.fullName})," — ",$.message]},$.fullName))}),k.length>0&&t.jsxs("button",{type:"button",onClick:()=>S(k),className:"mt-2 rounded bg-sky-600 px-2.5 py-1 text-[11px] font-medium text-white hover:bg-sky-700",children:["Continue with the ",k.length," added repo",k.length===1?"":"s"]})]})]}),t.jsxs("div",{className:"border-t border-gray-200 pt-4 dark:border-gray-800",children:[t.jsx("p",{className:"mb-2 text-xs text-gray-500 dark:text-gray-400",children:"or add any repo by name"}),t.jsx(Lf,{placeholder:"Search repos to add…"})]})]})}function yz(e){return[...e].sort((n,r)=>r.attentionCount!==n.attentionCount?r.attentionCount-n.attentionCount:n.hasUnread!==r.hasUnread?n.hasUnread?-1:1:n.repoFullName.localeCompare(r.repoFullName))}function bz(){const[,e]=f.useState(0);f.useEffect(()=>{const n=window.setInterval(()=>e(r=>r+1),3e4);return()=>window.clearInterval(n)},[])}function vz({fullName:e,maintainerCount:n,hasUnread:r,attentionCount:s,openPrs:a,threadTotals:i,branch:c,selected:d,onSelect:u}){const m=i!=null||r||s>0||a!=null;return t.jsxs("button",{type:"button",onClick:u,"aria-pressed":d,className:`flex w-56 shrink-0 flex-col gap-0.5 rounded border-l-2 px-2 py-1.5 text-left text-xs md:w-full ${d?"border-sky-500 bg-sky-50 dark:bg-sky-950/30":"border-transparent hover:bg-gray-50 dark:hover:bg-gray-800/50"}`,children:[t.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[t.jsx("span",{className:"min-w-0 flex-1 truncate font-medium text-gray-700 dark:text-gray-200",children:e}),n>0&&t.jsx($p,{})]}),m&&t.jsxs("span",{className:"flex items-center gap-1.5 pl-0.5",children:[r&&t.jsx("span",{"aria-hidden":"true",title:"New activity",className:"inline-block h-1.5 w-1.5 shrink-0 rounded-full bg-sky-500"}),i!=null&&t.jsx(Xp,{counts:i,compact:!0}),s>0&&t.jsxs("span",{className:"shrink-0 rounded bg-amber-500/15 px-1 text-[10px] font-semibold text-amber-600 dark:text-amber-400",title:"PRs needing attention",children:[t.jsx(Jt,{size:10,className:"mr-0.5 inline-block align-[-0.1em]"}),s]}),t.jsx("span",{className:"ml-auto shrink-0 tabular-nums text-gray-400",children:a==null?"":a>0?`[${a}]`:"[—]"})]}),t.jsx(VF,{status:c,className:"pl-0.5"})]})}function kz({repo:e}){const n=G(a=>a.repoConsoleTabs[e.repoId]??"activity"),r=G(a=>a.setRepoConsoleTab),s=G(a=>a.feedIsolatedPrId!=null);return t.jsxs("div",{className:"space-y-3","data-testid":"repo-console",children:[t.jsx("div",{role:"tablist",className:"flex gap-1 border-b border-gray-200 dark:border-gray-800",children:["activity","bots"].map(a=>{const i=n===a;return t.jsxs("button",{type:"button",role:"tab","aria-selected":i,onClick:()=>r(e.repoId,a),className:`-mb-px flex items-center gap-1 rounded-t-md border border-b-0 px-3 py-1.5 text-xs font-medium ${i?"border-gray-300 bg-white text-gray-700 dark:border-gray-700 dark:bg-gray-950 dark:text-gray-200":"border-transparent text-gray-500 hover:bg-gray-100 dark:text-gray-400 dark:hover:bg-gray-900/60"}`,children:[a==="bots"&&t.jsx(Lt,{}),a==="activity"?"Activity":"Bots"]},a)})}),n==="activity"?t.jsxs(t.Fragment,{children:[t.jsx(TB,{repo:e}),t.jsx(fy,{}),!s&&t.jsxs(t.Fragment,{children:[t.jsx(MB,{repoId:e.repoId,repoFullName:e.repoFullName}),t.jsx(DB,{repoId:e.repoId,prs:e.prs})]}),t.jsx(xd,{repoId:e.repoId})]}):t.jsx(SR,{repoId:e.repoId})]})}function wz(){bz();const e=G(A=>A.workspaceId),n=G(A=>A.activityRepoId),r=G(A=>A.setActivityRepo),{workspaceInsights:s,activityDigest:a}=vt(),i=G(A=>A.feedInnerTab),c=G(A=>A.setFeedInnerTab),{data:d,isFetching:u,isLoading:m}=A4(e),{data:h}=ay(),g=f.useMemo(()=>new Map(((h==null?void 0:h.repos)??[]).map(A=>[A.repoId,A])),[h]),{data:x}=xn(),y=f.useMemo(()=>yz((d==null?void 0:d.repos)??[]),[d==null?void 0:d.repos]),b=typeof n=="number"?y.find(A=>A.repoId===n)??null:null,w=n==="feed",k=n==="attention"||n==null,j=n==="insights",N=n==="bots",I=f.useMemo(()=>{const A=[{key:"feed",label:"Feed"}];return a&&A.push({key:"themes",label:"Themes"}),A},[a]),S=I.some(A=>A.key===i)?i:"feed",T=(d==null?void 0:d.generatedAt)??null,$=e==null?[]:(x??[]).filter(A=>A.workspaceId===e),P=d!=null?y.map(A=>({repoId:A.repoId,fullName:A.repoFullName,maintainerCount:A.maintainerIds.length,hasUnread:A.hasUnread,attentionCount:A.attentionCount,openPrs:A.stats.openPrs,threadTotals:A.threadTotals})):$.map(A=>({repoId:A.id,fullName:A.fullName,maintainerCount:0,hasUnread:!1,attentionCount:0,openPrs:null,threadTotals:null})),C=A=>t.jsx(vz,{fullName:A.fullName,maintainerCount:A.maintainerCount,hasUnread:A.hasUnread,attentionCount:A.attentionCount,openPrs:A.openPrs,threadTotals:A.threadTotals,branch:g.get(A.repoId)??null,selected:n===A.repoId,onSelect:()=>r(A.repoId)},String(A.repoId)),L=d!=null&&y.length===0,F=(x??[]).length>0,D=x!=null&&!F;return t.jsxs("div",{className:"flex h-full min-h-0 flex-col md:flex-row",children:[t.jsxs("div",{className:"flex flex-col border-b border-gray-200 md:w-72 md:shrink-0 md:border-b-0 md:border-r dark:border-gray-800",children:[T!=null&&t.jsx("div",{className:"px-3 py-1 text-[10px] text-gray-400",title:new Date(T).toLocaleString(),children:Nt(T)}),u&&d!=null&&t.jsx("div",{className:"h-0.5 w-full overflow-hidden bg-sky-100 dark:bg-sky-950",children:t.jsx("div",{className:"h-full w-1/3 animate-pulse bg-sky-500"})}),t.jsxs("div",{className:`flex gap-1 overflow-x-auto p-2 md:min-h-0 md:flex-1 md:flex-col md:overflow-x-visible md:overflow-y-auto ${u&&d!=null?"opacity-60 transition-opacity":""}`,children:[t.jsxs("button",{type:"button",onClick:()=>r("attention"),"aria-pressed":k,className:`flex w-56 shrink-0 items-center gap-1.5 rounded border-l-2 px-2 py-1.5 text-left text-xs md:w-full ${k?"border-sky-500 bg-sky-50 dark:bg-sky-950/30":"border-transparent hover:bg-gray-50 dark:hover:bg-gray-800/50"}`,title:"Everything waiting on you or your workspace, ranked most actionable first (free)",children:[t.jsx("span",{className:"shrink-0 text-amber-500",children:t.jsx($i,{})}),t.jsx("span",{className:"min-w-0 flex-1 truncate font-semibold text-gray-700 dark:text-gray-200",children:"Pending"})]}),t.jsxs("button",{type:"button",onClick:()=>r("feed"),"aria-pressed":w,className:`flex w-56 shrink-0 items-center gap-1.5 rounded border-l-2 px-2 py-1.5 text-left text-xs md:w-full ${w?"border-sky-500 bg-sky-50 dark:bg-sky-950/30":"border-transparent hover:bg-gray-50 dark:hover:bg-gray-800/50"}`,title:"One chronological stream across every repo in this workspace",children:[t.jsx("span",{className:"shrink-0 text-sky-500",children:t.jsx(Ps,{})}),t.jsx("span",{className:"min-w-0 flex-1 truncate font-semibold text-gray-700 dark:text-gray-200",children:"Feed"})]}),t.jsxs("button",{type:"button",onClick:()=>r("bots"),"aria-pressed":N,className:`flex w-56 shrink-0 items-center gap-1.5 rounded border-l-2 px-2 py-1.5 text-left text-xs md:w-full ${N?"border-sky-500 bg-sky-50 dark:bg-sky-950/30":"border-transparent hover:bg-gray-50 dark:hover:bg-gray-800/50"}`,title:"Detect, measure and triage this workspace's automated review bots — classification and triage are free; the ROI table is Pro",children:[t.jsx("span",{className:"shrink-0",children:t.jsx(Lt,{})}),t.jsx("span",{className:"min-w-0 flex-1 truncate font-semibold text-gray-700 dark:text-gray-200",children:"Bots"})]}),t.jsxs("button",{type:"button",onClick:()=>r("insights"),"aria-pressed":j,className:`flex w-56 shrink-0 items-center gap-1.5 rounded border-l-2 px-2 py-1.5 text-left text-xs md:w-full ${j?"border-sky-500 bg-sky-50 dark:bg-sky-950/30":"border-transparent hover:bg-gray-50 dark:hover:bg-gray-800/50"}`,title:"Flow metrics for this workspace, and period-over-period reports (Pro)",children:[t.jsx("span",{className:"shrink-0 text-ai-signal",children:t.jsx(xp,{})}),t.jsx("span",{className:"min-w-0 flex-1 truncate font-semibold text-gray-700 dark:text-gray-200",children:"Reports"})]}),P.map(A=>C(A)),t.jsx("div",{className:"mt-auto hidden flex-wrap gap-x-3 gap-y-0.5 px-1 pt-3 md:flex",children:["untouched","replied_unresolved","likely_addressed","resolved"].map(A=>t.jsxs("span",{className:"flex items-center gap-1 text-[10px] text-gray-400",title:Xt[A].description,children:[t.jsx("span",{className:"inline-block h-2 w-2 rounded-full",style:{background:Xt[A].color}}),Xt[A].label.toLowerCase()]},A))})]})]}),t.jsx("div",{className:"relative min-h-0 flex-1 overflow-y-auto p-3",children:D?t.jsx(xz,{}):N?t.jsx(SR,{}):k&&!L?t.jsx(dO,{}):j?t.jsx(y9,{}):L?t.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center text-sm text-gray-400",children:F?'No repos in this workspace yet. Open "Manage repos & workspaces" in the header to move some in.':"Detecting the repos you work on…"}):w?t.jsxs("div",{className:"space-y-3",children:[I.length>1&&t.jsx("div",{role:"tablist",className:"flex gap-1 border-b border-gray-200 dark:border-gray-800",children:I.map(A=>{const W=S===A.key;return t.jsxs("button",{type:"button",role:"tab","aria-selected":W,onClick:()=>c(A.key),className:`-mb-px flex items-center gap-1 rounded-t-md border border-b-0 px-3 py-1.5 text-xs font-medium ${W?"border-gray-300 bg-white text-sky-600 dark:border-gray-700 dark:bg-gray-950 dark:text-sky-300":"border-transparent text-gray-500 hover:bg-gray-100 dark:text-gray-400 dark:hover:bg-gray-900/60"}`,children:[A.label,A.key==="themes"&&t.jsx("span",{className:"rounded bg-ai-signal/10 px-1 text-[9px] font-semibold uppercase text-ai-signal",children:"pro"})]},A.key)})}),S==="themes"?t.jsx(M7,{}):t.jsx(xd,{})]}):m&&d==null?t.jsx("div",{className:"space-y-3",children:[0,1,2].map(A=>t.jsx("div",{className:"h-24 animate-pulse rounded-lg border border-gray-200 bg-gray-50 dark:border-gray-800 dark:bg-gray-900/40"},A))}):b!=null?t.jsx(kz,{repo:b},b.repoId):t.jsxs("div",{className:"space-y-3",children:[t.jsx(fy,{}),t.jsx(xd,{})]})})]})}function jz(e,n){const r=n;return Oe({queryKey:["workspace-metrics-detail",r],queryFn:r==null?Ct:()=>he.workspaceMetricsDetail(r),enabled:e,refetchInterval:5*6e4,refetchIntervalInBackground:!1,staleTime:6e4})}function CR({repos:e,selected:n,onChange:r}){const[s,a]=f.useState(!1),i=f.useRef(null);Yr(i,()=>a(!1),s),f.useEffect(()=>{if(!s)return;const x=y=>{y.key==="Escape"&&(y.stopPropagation(),a(!1))};return document.addEventListener("keydown",x),()=>document.removeEventListener("keydown",x)},[s]);const c=e.map(x=>x.id),d=c.length,u=n==null,m=x=>u||n.includes(x),h=x=>{const y=u?c:n,b=y.includes(x)?y.filter(w=>w!==x):[...y,x];r(b.length===d?null:b)},g=u?d:n.length;return t.jsxs("div",{ref:i,className:"relative",children:[t.jsxs("span",{className:"inline-flex items-center whitespace-nowrap rounded-full border border-gray-300 text-xs text-gray-600 hover:border-gray-400 dark:border-gray-700 dark:text-gray-300 dark:hover:border-gray-500",children:[t.jsxs("button",{type:"button",onClick:()=>a(x=>!x),"aria-haspopup":"true","aria-expanded":s,className:`inline-flex items-center gap-1 py-0.5 pl-2.5 ${u?"pr-2.5":"pr-1"}`,children:[u?"All Workspace repos":`Repos (${g}/${d})`,t.jsx(Cr,{dir:"down"})]}),!u&&t.jsx("button",{type:"button",onClick:()=>r(null),title:"Show all Workspace repos","aria-label":"Show all Workspace repos",className:"flex items-center self-stretch py-0.5 pl-0.5 pr-2 opacity-60 hover:opacity-100",children:t.jsx(Zt,{size:11})})]}),s&&t.jsxs("div",{role:"dialog","aria-label":"Filter by repo",className:"absolute right-0 top-full z-[60] mt-1 w-64 rounded-lg border border-gray-200 bg-white p-2 shadow-lg dark:border-gray-700 dark:bg-gray-900",children:[t.jsxs("label",{className:"flex cursor-pointer items-center gap-2 rounded px-1 py-1 text-xs font-medium hover:bg-gray-100 dark:hover:bg-gray-800",children:[t.jsx("input",{type:"checkbox",checked:u,onChange:()=>r(null)}),t.jsx("span",{className:"text-gray-800 dark:text-gray-100",children:"All Workspace repos"})]}),t.jsx("div",{className:"my-1 border-t border-gray-200 dark:border-gray-700"}),t.jsx("div",{className:"max-h-72 overflow-y-auto",children:d===0?t.jsx("div",{className:"px-1 py-2 text-xs text-gray-500 dark:text-gray-400",children:"No repos with data."}):e.map(x=>{const y=n!=null&&n.length===1&&n[0]===x.id;return t.jsxs("div",{className:"group flex items-center gap-2 rounded px-1 py-1 text-xs hover:bg-gray-100 dark:hover:bg-gray-800",children:[t.jsxs("label",{className:"flex min-w-0 flex-1 cursor-pointer items-center gap-2",children:[t.jsx("input",{type:"checkbox",checked:m(x.id),onChange:()=>h(x.id)}),t.jsx("span",{className:"min-w-0 truncate text-gray-800 dark:text-gray-100",title:x.fullName,children:x.fullName})]}),d>1&&!y&&t.jsx("button",{type:"button",onClick:()=>r([x.id]),title:`Show only ${x.fullName}`,"aria-label":`Show only ${x.fullName}`,className:"shrink-0 rounded px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-gray-400 opacity-0 hover:bg-gray-200 hover:text-gray-700 focus:opacity-100 group-hover:opacity-100 dark:hover:bg-gray-700 dark:hover:text-gray-200",children:"only"})]},x.id)})})]})]})}function ky(e,n){return typeof e=="string"&&typeof n=="string"?e.localeCompare(n):e-n}function wy(e,n,r){return(e==null?void 0:e.col)===n?{col:n,dir:e.dir==="asc"?"desc":"asc"}:{col:n,dir:r[n]}}function Nn({col:e,label:n,sort:r,onSort:s,title:a,className:i="pb-1 pr-3 font-semibold"}){const c=r!=null&&r.col===e?r.dir:null;return t.jsx("th",{className:i,"aria-sort":c!=null?c==="asc"?"ascending":"descending":void 0,children:t.jsxs("button",{type:"button",onClick:()=>s(e),title:a,className:`inline-flex items-center gap-0.5 uppercase tracking-wide hover:text-gray-600 dark:hover:text-gray-300 ${c!=null?"text-gray-600 dark:text-gray-300":""}`,children:[n,t.jsx("span",{"aria-hidden":!0,className:c!=null?"":"invisible",children:t.jsx(Cr,{dir:c==="asc"?"up":"down"})})]})})}const Ij={merges:{label:"Merges",blurb:"Merged this sprint · most-recently-updated first"},lead_time:{label:"Lead time",blurb:"Open → merge (merged + open) · longest first"},review_latency:{label:"Review latency",blurb:"Open → first review · longest first"},merge_ci:{label:"Merge CI",blurb:"Merged PRs · CI-failed-at-merge first"},ci_recovery:{label:"CI recovery",blurb:"Red → green · slowest first"},ci_red:{label:"CI red now",blurb:"Currently-failing branches · longest red first"}},Nz={pr:"desc",value:"desc",ci:"asc",diff:"desc",author:"asc",last:"desc",updated:"desc"},Sz={merges:{col:"updated",dir:"desc"},lead_time:{col:"value",dir:"desc"},review_latency:{col:"value",dir:"desc"},merge_ci:{col:"value",dir:"desc"},ci_recovery:{col:"value",dir:"desc"},ci_red:{col:"value",dir:"desc"}},Cz={failure:0,error:0,pending:1,success:2,expected:3,unknown:4};function Rz(e){return e==null?5:Cz[e]??4}function Iz(e,n){switch(e){case"merges":case"lead_time":return n.leadTimeHours??-1;case"review_latency":return n.reviewLatencyHours??-1;case"ci_recovery":return n.recoveryHours??-1;case"ci_red":return n.redAgeHours??-1;case"merge_ci":return n.ciStatus==="failure"||n.ciStatus==="error"?2:n.ciStatus==="pending"?1:0}}function Tz(e,n,r){if(e==="review_latency")return n.reviewerIds.length;if(e==="merges"||e==="merge_ci"){const s=n.mergedById!=null?r.get(n.mergedById):void 0;return((s==null?void 0:s.githubLogin)??String(n.mergedById??"")).toLowerCase()}return n.openedAt}function Tj(e,n,r,s){switch(r){case"pr":return e.prNumber;case"value":return Iz(n,e);case"ci":return Rz(e.ciStatus);case"diff":return e.additions+e.deletions;case"author":{const a=e.authorId!=null?s.get(e.authorId):void 0;return((a==null?void 0:a.githubLogin)??String(e.authorId??"")).toLowerCase()}case"updated":return e.updatedAt;case"last":return Tz(n,e,s)}}function j0(e,n){if(!e)return[];switch(n){case"merges":return e.merges;case"lead_time":return e.leadTime;case"review_latency":return e.reviewLatency;case"merge_ci":return e.mergeCi;case"ci_recovery":return e.ciRecovery;case"ci_red":return e.ciRed}}function $z({ci:e}){const n=e?Rr[e]:null;return t.jsxs("span",{className:"inline-flex items-center gap-1 text-[11px] text-gray-500 dark:text-gray-400",children:[t.jsx("span",{className:"inline-block h-2 w-2 rounded-full",style:n?{background:n.color}:{boxShadow:"inset 0 0 0 1px #9ca3af"},"aria-hidden":!0}),(n==null?void 0:n.label)??"no checks"]})}function _z({pr:e}){return t.jsxs("span",{className:"whitespace-nowrap text-[11px]",children:[t.jsxs("span",{className:"text-gray-400",children:[e.changedFiles,"f"]})," ",t.jsxs("span",{className:"font-mono text-green-600 dark:text-green-400",children:["+",e.additions]})," ",t.jsxs("span",{className:"font-mono text-red-500 dark:text-red-400",children:["−",e.deletions]})]})}function $j({id:e,usersById:n}){const r=e!=null?n.get(e):void 0;return t.jsxs("span",{className:"inline-flex items-center gap-1 text-[11px] text-gray-600 dark:text-gray-300",children:[t.jsx(gn,{user:r,size:14}),t.jsx(mr,{user:r,fallbackId:e??0})]})}function Pz({ids:e,usersById:n}){return e.length===0?t.jsx("span",{className:"text-[11px] italic text-gray-400",children:"none"}):t.jsx("span",{className:"flex flex-wrap gap-1",children:e.map(r=>{const s=n.get(r);return t.jsxs("span",{className:"inline-flex items-center gap-1 rounded bg-gray-500/10 px-1 py-0.5 text-[10px]",children:[t.jsx(gn,{user:s,size:11}),t.jsx(mr,{user:s,fallbackId:r})]},r)})})}function Ez(e){switch(e){case"merges":case"lead_time":return"Lead time";case"review_latency":return"Latency";case"merge_ci":return"CI @ merge";case"ci_recovery":return"Recovery";case"ci_red":return"Red for"}}function Az({m:e,pr:n}){const r=s=>s==null?"—":wn(s);switch(e){case"merges":case"lead_time":return t.jsx("span",{className:"font-medium",children:r(n.leadTimeHours)});case"review_latency":return t.jsx("span",{className:"font-medium",children:r(n.reviewLatencyHours)});case"ci_recovery":return t.jsx("span",{className:"font-medium text-orange-600 dark:text-orange-400",children:r(n.recoveryHours)});case"ci_red":return t.jsx("span",{className:"font-medium text-red-500 dark:text-red-400",children:r(n.redAgeHours)});case"merge_ci":{const s=n.ciStatus==="failure"||n.ciStatus==="error";return t.jsx("span",{className:`font-medium ${s?"text-red-500 dark:text-red-400":"text-gray-500 dark:text-gray-400"}`,children:n.ciStatus??"—"})}}}function Mz({m:e,pr:n,usersById:r,onOpen:s}){const a=e==="review_latency",i=e==="merges"||e==="merge_ci";return t.jsxs("tr",{className:"border-t border-gray-100 align-top hover:bg-gray-50/70 dark:border-gray-800/60 dark:hover:bg-gray-900/40",children:[t.jsx("td",{className:"py-1.5 pr-3",children:t.jsxs("button",{type:"button",onClick:()=>s(n),className:"block max-w-md text-left hover:underline",title:`${n.repoFullName} #${n.prNumber} — ${n.prTitle}`,children:[t.jsxs("span",{className:"block truncate font-mono text-[11px] text-gray-400",children:[n.repoFullName," #",n.prNumber]}),t.jsx("span",{className:"block truncate text-sm font-medium text-gray-800 dark:text-gray-100",children:n.prTitle})]})}),t.jsx("td",{className:"py-1.5 pr-3",children:t.jsx(Az,{m:e,pr:n})}),t.jsx("td",{className:"py-1.5 pr-3",children:t.jsx($z,{ci:n.ciStatus})}),t.jsx("td",{className:"py-1.5 pr-3",children:t.jsx(_z,{pr:n})}),t.jsx("td",{className:"py-1.5 pr-3",children:t.jsx($j,{id:n.authorId,usersById:r})}),t.jsx("td",{className:"py-1.5 pr-3 text-[11px] text-gray-500 dark:text-gray-400",children:a?t.jsx(Pz,{ids:n.reviewerIds,usersById:r}):i?t.jsx($j,{id:n.mergedById,usersById:r}):Nt(n.openedAt)}),t.jsx("td",{className:"py-1.5 pr-3 text-[11px] text-gray-500 dark:text-gray-400",children:Nt(n.updatedAt)})]})}function Lz({m:e,rows:n,usersById:r,onOpen:s,sort:a,onSort:i}){const c=e==="review_latency"?"Reviewers":e==="merges"||e==="merge_ci"?"Merged by":"Opened";return t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"w-full min-w-[760px] border-collapse text-sm",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"text-left text-[10px] font-semibold uppercase tracking-wide text-gray-400",children:[t.jsx(Nn,{col:"pr",label:"Pull request",sort:a,onSort:i}),t.jsx(Nn,{col:"value",label:Ez(e),sort:a,onSort:i}),t.jsx(Nn,{col:"ci",label:"CI",sort:a,onSort:i}),t.jsx(Nn,{col:"diff",label:"Diff",sort:a,onSort:i,title:"Diff size (added + deleted lines)"}),t.jsx(Nn,{col:"author",label:"Author",sort:a,onSort:i}),t.jsx(Nn,{col:"last",label:c,sort:a,onSort:i}),t.jsx(Nn,{col:"updated",label:"Updated",sort:a,onSort:i,title:"GitHub last-activity time"})]})}),t.jsx("tbody",{children:n.map(d=>t.jsx(Mz,{m:e,pr:d,usersById:r,onOpen:s},d.prId))})]})})}function Fz(){const e=G(F=>F.metricsFocus),n=G(F=>F.consumeMetricsFocus),r=Ge(F=>F.openPrDetailTab),s=G(F=>F.workspaceId),{data:a,isLoading:i,isError:c,refetch:d,isFetching:u}=jz(!0,s),{data:m}=An(),h=f.useMemo(()=>Rn(m),[m]),[g,x]=f.useState(e??"merges");f.useEffect(()=>{e&&(x(e),n())},[e,n]);const[y,b]=f.useState(()=>({...Sz})),w=y[g],k=F=>b(M=>({...M,[g]:wy(M[g],F,Nz)})),j=(a==null?void 0:a.detail)??null,[N,I]=f.useState({}),S=N[g]??null,T=F=>I(M=>({...M,[g]:F})),$=f.useMemo(()=>{const F=new Map;if(j)for(const M of uk)for(const D of j0(j,M))F.set(D.repoId,D.repoFullName);return[...F.entries()].map(([M,D])=>({id:M,fullName:D})).sort((M,D)=>M.fullName.localeCompare(D.fullName))},[j]),P=j0(j,g),C=f.useMemo(()=>{const F=S==null?P:P.filter(D=>S.includes(D.repoId));if(w==null)return F;const M=w.dir==="asc"?1:-1;return[...F].sort((D,A)=>M*ky(Tj(D,g,w.col,h),Tj(A,g,w.col,h))||A.prNumber-D.prNumber)},[P,S,w,g,h]),L=F=>{const M=F.authorId!=null?h.get(F.authorId):void 0,D={id:F.prId,number:F.prNumber,title:F.prTitle,repoFullName:F.repoFullName,authorLogin:(M==null?void 0:M.githubLogin)??null,authorDisplayName:(M==null?void 0:M.displayName)??null,authorAvatarUrl:(M==null?void 0:M.avatarUrl)??null};r(D)};return t.jsxs("div",{className:"mx-auto max-w-[100rem] space-y-4 p-4",children:[t.jsxs("div",{className:"flex flex-wrap items-baseline gap-2",children:[t.jsx("h2",{className:"text-base font-semibold text-gray-800 dark:text-gray-100",children:"Flow metrics"}),j&&t.jsx("span",{className:"text-[11px] text-gray-400",children:"sprint: last 2 weeks · where issues cluster"}),t.jsxs("button",{type:"button",onClick:()=>void d(),disabled:u,className:"ml-auto rounded border border-gray-300 px-1.5 py-0.5 text-[11px] font-medium hover:border-gray-400 disabled:opacity-50 dark:border-gray-700 dark:hover:border-gray-500",children:[t.jsx(us,{size:11,className:`inline-block align-[-0.1em] ${u?"animate-spin":""}`})," ","Refresh"]})]}),t.jsx("div",{role:"tablist",className:"flex flex-wrap gap-1 border-b border-gray-200 dark:border-gray-800",children:uk.map(F=>{const M=F===g,D=j0(j,F).length;return t.jsxs("button",{type:"button",role:"tab","aria-selected":M,onClick:()=>x(F),className:`-mb-px rounded-t-md border border-b-0 px-3 py-1.5 text-xs font-medium ${M?"border-gray-300 bg-white text-violet-600 dark:border-gray-700 dark:bg-gray-950 dark:text-violet-300":"border-transparent text-gray-500 hover:bg-gray-100 dark:text-gray-400 dark:hover:bg-gray-900/60"}`,children:[Ij[F].label,j?t.jsx("span",{className:"ml-1 text-gray-400",children:D}):null]},F)})}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsxs("div",{className:"text-[11px] text-gray-400",children:[Ij[g].blurb," · click a column to sort"]}),C.length!==P.length&&t.jsxs("span",{className:"text-[11px] text-gray-400",children:["· ",C.length," of ",P.length]}),t.jsx("div",{className:"ml-auto",children:t.jsx(CR,{repos:$,selected:S,onChange:T})})]}),i?t.jsx("div",{className:"space-y-2",children:[0,1,2,3].map(F=>t.jsx("div",{className:"h-8 animate-pulse rounded bg-gray-100 dark:bg-gray-900/40"},F))}):c?t.jsx("div",{className:"text-sm text-red-500",children:"Couldn’t load the metric detail."}):C.length===0?t.jsx("div",{className:"rounded-lg border border-dashed border-gray-300 p-6 text-center text-sm text-gray-400 dark:border-gray-700",children:P.length===0?t.jsxs(t.Fragment,{children:[t.jsx(Vo,{className:"mr-1.5 inline-block align-[-0.15em] decorative-mark text-gray-300 dark:text-gray-600"}),"Nothing to show for this metric in the current sprint."]}):"No PRs for the selected repos — adjust the repo filter."}):t.jsx(Lz,{m:g,rows:C,usersById:h,onOpen:L,sort:w,onSort:k})]})}function Oz(e,n,r,s=!0,a){const{botDepth:i}=vt(),c=a&&a.length>0?[...a].sort((d,u)=>d-u).join(","):"all";return Oe({queryKey:["bot-vendor-prs",n,r,dt(e),c],queryFn:n==null||e==null?Ct:()=>he.botVendorPrs(n,r,e,a),enabled:s&&i,refetchInterval:5*6e4,refetchIntervalInBackground:!1,staleTime:6e4})}function Dz(e,n,r,s=!0,a){const{botDepth:i,periodReports:c}=vt(),d=a&&a.length>0?[...a].sort((u,m)=>u-m).join(","):"all";return Oe({queryKey:["bot-vendor-comments",n,r,dt(e),d],queryFn:n==null||e==null?Ct:()=>he.botVendorComments(n,r,e,a),enabled:s&&(i||c),refetchInterval:5*6e4,refetchIntervalInBackground:!1,staleTime:6e4})}const Bz=["critical","major","minor","nit","praise"];function RR(e){const n=e.mlLabel;return n?n.categories.includes("praise")?"praise":n.isSummary?null:n.severity:null}function IR(e){const n=e.mlLabel;return n!=null&&n.vendorSeverity!=null&&n.vendorSeverity!==n.severity}const Wz=()=>({critical:0,major:0,minor:0,nit:0,praise:0});function qz(e){const n=Wz();let r=0,s=0;for(const a of e){a.mlLabel&&(s+=1);const i=RR(a);i&&(n[i]+=1),IR(a)&&(r+=1)}return{counts:n,disagreements:r,labelled:s}}function Uz(e,n){const{severities:r,disagreesOnly:s}=n;return r.size===0&&!s?[...e]:e.filter(a=>{if(r.size>0){const i=RR(a);if(i==null||!r.has(i))return!1}return s?IR(a):!0})}const _j=(e,n)=>e.createdAt<n.createdAt?-1:e.createdAt>n.createdAt?1:0;function Hz(e,n){if(n==="newest")return[...e];if(n==="oldest")return[...e].sort(_j);const r=s=>s.mlLabel&&!s.mlLabel.isSummary?s.mlLabel.severityOrd:-1;return[...e].sort((s,a)=>r(a)-r(s)||-_j(s,a))}function zz(e,n,r){return Hz(Uz(e,n),r)}const Kz=[{key:"rolling_7",label:"7d"},{key:"rolling_14",label:"14d"},{key:"rolling_30",label:"30d"},{key:"sprint",label:"Sprint"}],Gz=[],Pj=50,Vz=150,Qz={review_comment:"inline comment",pr_comment:"PR comment",review:"review summary"},Yz={...Ht,praise:{label:"Praise",color:"#16a34a",description:"Not a finding — the bot acknowledging a fix, confirming a resolution, withdrawing a concern or saying thanks. Excluded from every severity share."}},N0=new Set;function Xz({c:e,showSeverity:n,onOpen:r}){const s=e.derivedState?Xt[e.derivedState]:null;return t.jsxs("tr",{className:"border-t border-gray-100 align-top dark:border-gray-800/60",children:[n&&t.jsx("td",{className:"py-2 pr-3",children:e.mlLabel?t.jsx(cc,{label:e.mlLabel}):t.jsx("span",{className:"text-[11px] text-gray-500 dark:text-gray-400",title:"Not scored yet",children:"—"})}),t.jsxs("td",{className:"max-w-2xl py-2 pr-3",children:[t.jsxs("div",{className:"mb-1 flex flex-wrap items-center gap-1.5 text-[10px] text-gray-400",children:[t.jsx("span",{className:"uppercase tracking-wide",children:Qz[e.targetKind]}),e.path&&t.jsx("span",{className:"truncate font-mono",children:e.path}),s&&t.jsx(Fi,{meta:s})]}),t.jsx("div",{className:"text-xs",children:t.jsx(gr,{children:e.body??""})})]}),t.jsx("td",{className:"py-2 pr-3",children:t.jsxs("button",{type:"button",onClick:()=>r(e),className:"block max-w-56 text-left hover:underline",title:`${e.repoFullName} #${e.prNumber} — ${e.prTitle}`,children:[t.jsxs("span",{className:"block truncate font-mono text-[11px] text-gray-400",children:[e.repoFullName," #",e.prNumber]}),t.jsx("span",{className:"block truncate text-[11px] text-gray-700 dark:text-gray-200",children:e.prTitle})]})}),t.jsx("td",{className:"whitespace-nowrap py-2 text-[11px] text-gray-500 dark:text-gray-400",children:Nt(e.createdAt)})]})}function Zz({ci:e}){const n=e?Rr[e]:null;return t.jsxs("span",{className:"inline-flex items-center gap-1 text-[11px] text-gray-500 dark:text-gray-400",children:[t.jsx("span",{className:"inline-block h-2 w-2 rounded-full",style:n?{background:n.color}:{boxShadow:"inset 0 0 0 1px #9ca3af"},"aria-hidden":!0}),(n==null?void 0:n.label)??"no checks"]})}function Jz({pr:e}){return t.jsxs("span",{className:"whitespace-nowrap text-[11px]",children:[t.jsxs("span",{className:"text-gray-400",children:[e.changedFiles,"f"]})," ",t.jsxs("span",{className:"font-mono text-green-600 dark:text-green-400",children:["+",e.additions]})," ",t.jsxs("span",{className:"font-mono text-red-500 dark:text-red-400",children:["−",e.deletions]})]})}function eK({id:e,usersById:n}){const r=e!=null?n.get(e):void 0;return t.jsxs("span",{className:"inline-flex items-center gap-1 text-[11px] text-gray-600 dark:text-gray-300",children:[t.jsx(gn,{user:r,size:14}),t.jsx(mr,{user:r,fallbackId:e??0})]})}function tK({pr:e}){return t.jsxs("span",{className:"whitespace-nowrap text-[11px] tabular-nums",children:[t.jsx("span",{className:"text-gray-700 dark:text-gray-200",children:e.botThreads}),e.botUntouched>0&&t.jsxs("span",{className:"ml-1 text-amber-600 dark:text-amber-400",title:`${e.botUntouched} still untouched — no reply, no follow-up commit`,children:[e.botUntouched," untouched"]})]})}function nK({pr:e}){const n=e.botThreads>0?Math.round(e.botActedOn/e.botThreads*100):null;return t.jsxs("span",{className:"whitespace-nowrap text-[11px] tabular-nums",children:[t.jsx("span",{className:"text-gray-700 dark:text-gray-200",children:e.botActedOn}),n!=null&&t.jsxs("span",{className:"ml-1 text-gray-400",children:[n,"%"]})]})}function rK({pr:e,usersById:n,onOpen:r}){return t.jsxs("tr",{className:"border-t border-gray-100 align-top hover:bg-gray-50/70 dark:border-gray-800/60 dark:hover:bg-gray-900/40",children:[t.jsx("td",{className:"py-1.5 pr-3",children:t.jsxs("button",{type:"button",onClick:()=>r(e),className:"block max-w-md text-left hover:underline",title:`${e.repoFullName} #${e.prNumber} — ${e.prTitle}`,children:[t.jsxs("span",{className:"block truncate font-mono text-[11px] text-gray-400",children:[e.repoFullName," #",e.prNumber]}),t.jsxs("span",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:"min-w-0 truncate text-sm font-medium text-gray-800 dark:text-gray-100",children:e.prTitle}),e.botOnly&&t.jsx("span",{className:"shrink-0 rounded bg-amber-500/10 px-1 py-0.5 text-[9px] font-semibold uppercase tracking-wide text-amber-700 dark:text-amber-300",title:"Only bots touched this PR — no human review or comment",children:"bot-only"})]})]})}),t.jsx("td",{className:"py-1.5 pr-3",children:t.jsx(tK,{pr:e})}),t.jsx("td",{className:"py-1.5 pr-3",children:t.jsx(nK,{pr:e})}),t.jsx("td",{className:"py-1.5 pr-3",children:t.jsx(Zz,{ci:e.ciStatus})}),t.jsx("td",{className:"py-1.5 pr-3",children:t.jsx(Jz,{pr:e})}),t.jsx("td",{className:"py-1.5 pr-3",children:t.jsx(eK,{id:e.authorId,usersById:n})}),t.jsx("td",{className:"py-1.5 pr-3 text-[11px] text-gray-500 dark:text-gray-400",children:e.lastBotActivityAt?Nt(e.lastBotActivityAt):"—"})]})}function sK({rows:e,usersById:n,onOpen:r}){return t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"w-full min-w-[720px] border-collapse text-sm",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"text-left text-[10px] font-semibold uppercase tracking-wide text-gray-400",children:[t.jsx("th",{className:"pb-1 pr-3 font-semibold",children:"Pull request"}),t.jsx("th",{className:"pb-1 pr-3 font-semibold",children:"Bot threads"}),t.jsx("th",{className:"pb-1 pr-3 font-semibold",children:"Acted on"}),t.jsx("th",{className:"pb-1 pr-3 font-semibold",children:"CI"}),t.jsx("th",{className:"pb-1 pr-3 font-semibold",children:"Diff"}),t.jsx("th",{className:"pb-1 pr-3 font-semibold",children:"Author"}),t.jsx("th",{className:"pb-1 pr-3 font-semibold",children:"Last activity"})]})}),t.jsx("tbody",{children:e.map(s=>t.jsx(rK,{pr:s,usersById:n,onOpen:r},s.prId))})]})})}function aK(){var Fe,oe,re,X,le,Ne,Ve;const e=G(me=>me.botPrsFocusKey),n=G(me=>me.consumeBotPrsFocus),r=G(me=>me.botAnalyticsWindow),s=G(me=>me.setBotAnalyticsWindow),a=G(me=>me.workspaceId),i=G(me=>me.botPrsFocusRepoId),c=f.useMemo(()=>i!=null?[i]:null,[i]),d=Ge(me=>me.openPrDetailTab),{data:u}=An(),m=f.useMemo(()=>Rn(u),[u]),h=co(a),g=Qp(a,r,!0,c),x=((Fe=g.data)==null?void 0:Fe.vendors)??Gz,[y,b]=f.useState(e);f.useEffect(()=>{e&&(b(e),n())},[e,n]),f.useEffect(()=>{x.length!==0&&b(me=>me!=null&&x.some(be=>be.key===me)?me:x[0].key)},[x]);const[w,k]=f.useState("comments"),j=y==="pierre"?"prs":w,N=ba(),[I,S]=f.useState("newest"),[T,$]=f.useState(N0),[P,C]=f.useState(!1),[L,F]=f.useState(Pj),M=me=>$(be=>{const at=new Set(be);return at.delete(me)||at.add(me),at}),D=()=>{$(N0),C(!1)},A=Oz(a,y,r,j==="prs",c),W=((oe=A.data)==null?void 0:oe.prs)??[],z=Dz(a,y,r,j==="comments",c),te=f.useMemo(()=>{var me;return((me=z.data)==null?void 0:me.comments)??[]},[z.data]),H=f.useMemo(()=>qz(te),[te]),B=N&&H.labelled>0,O=B?T:N0,E=B&&P,ee=!N&&I==="severity"?"newest":I;f.useEffect(()=>{F(Pj)},[y,ee,O,E,r,a,c]);const K=f.useMemo(()=>zz(te,{severities:O,disagreesOnly:E},ee),[te,O,E,ee]),U=K.length!==te.length,Q=((re=A.data)==null?void 0:re.label)??((X=z.data)==null?void 0:X.label)??((le=x.find(me=>me.key===y))==null?void 0:le.label)??null,J=((Ne=g.data)==null?void 0:Ne.totals.botOnlyPrs)??0,ne=me=>{const be=me.authorId!=null?m.get(me.authorId):void 0,at={id:me.prId,number:me.prNumber,title:me.prTitle,repoFullName:me.repoFullName,authorLogin:(be==null?void 0:be.githubLogin)??null,authorDisplayName:(be==null?void 0:be.displayName)??null,authorAvatarUrl:(be==null?void 0:be.avatarUrl)??null};d(at)},ae=me=>{const be=me.prAuthorId!=null?m.get(me.prAuthorId):void 0,at={id:me.prId,number:me.prNumber,title:me.prTitle,repoFullName:me.repoFullName,authorLogin:(be==null?void 0:be.githubLogin)??null,authorDisplayName:(be==null?void 0:be.displayName)??null,authorAvatarUrl:(be==null?void 0:be.avatarUrl)??null};d(at)},we=g.isFetching||A.isFetching||z.isFetching,$e=()=>{g.refetch(),j==="comments"?z.refetch():A.refetch()};return t.jsxs("div",{className:"mx-auto max-w-[100rem] space-y-4 p-4",children:[t.jsxs("div",{className:"flex flex-wrap items-baseline gap-2",children:[t.jsx("h2",{className:"text-base font-semibold text-gray-800 dark:text-gray-100",children:"Bot Drill-Down"}),t.jsxs("span",{className:"text-[11px] text-gray-400",children:[j==="comments"?`What ${Q??"an automated reviewer"} said in the window`:`PRs ${Q??"an automated reviewer"} touched · most-recent activity first`,J>0&&t.jsxs(t.Fragment,{children:[" · ",t.jsxs("span",{className:"text-amber-600 dark:text-amber-400",children:[J," bot-only open"]})]})]}),t.jsx("div",{className:"ml-auto inline-flex overflow-hidden rounded border border-gray-300 dark:border-gray-700",children:Kz.map(me=>t.jsx("button",{type:"button",onClick:()=>s(me.key),className:`px-2 py-0.5 text-[11px] font-medium ${r===me.key?"bg-ai-signal/15 text-ai-signal":"text-gray-500 hover:bg-gray-100 dark:text-gray-400 dark:hover:bg-gray-800"}`,children:me.label},me.key))}),t.jsxs("button",{type:"button",onClick:$e,disabled:we,className:"rounded border border-gray-300 px-1.5 py-0.5 text-[11px] font-medium hover:border-gray-400 disabled:opacity-50 dark:border-gray-700 dark:hover:border-gray-500",children:[t.jsx(us,{size:11,className:`inline-block align-[-0.1em] ${we?"animate-spin":""}`})," ","Refresh"]})]}),g.isLoading?t.jsx("div",{className:"space-y-2",children:[0,1,2,3].map(me=>t.jsx("div",{className:"h-8 animate-pulse rounded bg-gray-100 dark:bg-gray-900/40"},me))}):g.isError?t.jsx("div",{className:"text-sm text-red-500",children:"Couldn’t load bot analytics."}):x.length===0?t.jsxs("div",{className:"rounded-lg border border-dashed border-gray-300 p-6 text-center text-sm text-gray-400 dark:border-gray-700",children:["No automated-reviewer activity in this window.",t.jsx("div",{className:"mt-1 text-[11px]",children:"When review bots (CodeRabbit, Copilot, in-house AI…) comment on your PRs, the PRs they touched land here."})]}):t.jsxs(t.Fragment,{children:[t.jsx("div",{role:"tablist",className:"flex flex-wrap gap-1 border-b border-gray-200 dark:border-gray-800",children:x.map(me=>{const be=me.key===y,at=h({login:me.login,kind:me.kind});return t.jsxs("button",{type:"button",role:"tab","aria-selected":be,onClick:()=>b(me.key),className:`-mb-px flex items-center gap-1 rounded-t-md border border-b-0 px-3 py-1.5 text-xs font-medium ${be?"border-gray-300 bg-white dark:border-gray-700 dark:bg-gray-950":"border-transparent text-gray-500 hover:bg-gray-100 dark:text-gray-400 dark:hover:bg-gray-900/60"}`,style:be?{color:at}:void 0,children:[t.jsx(Lt,{size:12}),me.label,t.jsx("span",{className:"ml-1 text-gray-400",children:me.threads})]},me.key)})}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("div",{className:"inline-flex overflow-hidden rounded border border-gray-300 dark:border-gray-700",children:[{key:"comments",label:"Comments"},{key:"prs",label:"PRs"}].map(me=>{const be=me.key==="comments"&&y==="pierre";return t.jsx("button",{type:"button",onClick:()=>k(me.key),disabled:be,title:be?`${YN}’s verbatim reviews are posted with the human’s token — there are no per-comment rows to list.`:me.key==="comments"?"Everything this bot said in the window — inline comments, PR comments and review summaries":"The PRs this bot touched in the window",className:`px-2 py-0.5 text-[11px] font-medium disabled:cursor-not-allowed disabled:opacity-40 ${j===me.key?"bg-ai-signal/15 text-ai-signal":"text-gray-500 hover:bg-gray-100 dark:text-gray-400 dark:hover:bg-gray-800"}`,children:me.label},me.key)})}),j==="comments"&&t.jsx("div",{className:"ml-auto inline-flex overflow-hidden rounded border border-gray-300 dark:border-gray-700",children:[{key:"newest",label:"Newest",title:"Most recent first"},{key:"oldest",label:"Oldest",title:"Earliest first"},{key:"severity",label:"Severity",title:"Worst predicted severity first — summaries and unscored comments sink to the bottom"}].filter(me=>me.key!=="severity"||N).map(me=>t.jsx("button",{type:"button",onClick:()=>S(me.key),title:me.title,className:`px-2 py-0.5 text-[11px] font-medium ${ee===me.key?"bg-ai-signal/15 text-ai-signal":"text-gray-500 hover:bg-gray-100 dark:text-gray-400 dark:hover:bg-gray-800"}`,children:me.label},me.key))})]}),j==="comments"&&B&&t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[t.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wide text-gray-400",children:"Severity"}),Bz.map(me=>{const be=Yz[me],at=O.has(me),ft=H.counts[me];return t.jsxs("button",{type:"button",onClick:()=>M(me),"aria-pressed":at,disabled:ft===0&&!at,className:`flex items-center gap-1 rounded-full border px-2 py-0.5 text-[11px] font-medium transition-colors disabled:opacity-40 ${at?"border-sky-400 bg-sky-50 text-sky-700 dark:border-sky-500/60 dark:bg-sky-950/30 dark:text-sky-300":"border-gray-300 text-gray-500 hover:border-gray-400 dark:border-gray-700 dark:text-gray-400"}`,title:be.description,children:[t.jsx("span",{"aria-hidden":"true",className:"inline-block h-2 w-2 rounded-full",style:{background:be.color}}),be.label,ft>0&&t.jsx("span",{className:"tabular-nums opacity-70",children:ft})]},me)}),t.jsxs("button",{type:"button",onClick:()=>C(me=>!me),"aria-pressed":E,disabled:H.disagreements===0&&!E,className:`ml-1 flex items-center gap-1 rounded-full border px-2 py-0.5 text-[11px] font-medium transition-colors disabled:opacity-40 ${E?"border-amber-400 bg-amber-50 text-amber-700 dark:border-amber-500/60 dark:bg-amber-950/30 dark:text-amber-300":"border-gray-300 text-gray-500 hover:border-gray-400 dark:border-gray-700 dark:text-gray-400"}`,title:"Only comments where the bot's OWN declared severity badge differs from Limn's. This is a SEVERITY disagreement and nothing else: vendors declare no machine-readable category, so category disagreement is not derivable and is never claimed here.",children:[t.jsx(yp,{size:11}),"Bot disagrees",H.disagreements>0&&t.jsx("span",{className:"tabular-nums opacity-70",children:H.disagreements})]}),(O.size>0||E)&&t.jsx("button",{type:"button",onClick:D,className:"rounded px-1.5 py-0.5 text-[11px] text-gray-500 dark:text-gray-400 underline-offset-2 hover:underline",children:"Clear"})]}),j==="comments"?z.isLoading?t.jsx("div",{className:"space-y-2",children:[0,1,2,3].map(me=>t.jsx("div",{className:"h-8 animate-pulse rounded bg-gray-100 dark:bg-gray-900/40"},me))}):z.isError?t.jsx("div",{className:"text-sm text-red-500",children:"Couldn’t load the comment list."}):K.length===0?t.jsx("div",{className:"rounded-lg border border-dashed border-gray-300 p-6 text-center text-sm text-gray-400 dark:border-gray-700",children:U?t.jsxs(t.Fragment,{children:["None of this bot’s ",te.length.toLocaleString()," comments match these filters.",t.jsx("div",{className:"mt-2",children:t.jsx("button",{type:"button",onClick:D,className:"rounded border border-gray-300 px-2 py-0.5 text-[11px] font-medium text-gray-500 hover:border-gray-400 dark:border-gray-700 dark:text-gray-400 dark:hover:border-gray-500",children:"Clear filters"})})]}):"No comments from this bot in the window."}):t.jsxs(t.Fragment,{children:[((Ve=z.data)==null?void 0:Ve.truncated)&&t.jsxs("div",{className:"rounded border border-gray-300 px-2 py-1 text-[11px] text-gray-500 dark:border-gray-700 dark:text-gray-400",children:["This bot said more in the window than one read covers — showing the most recent ",te.length.toLocaleString(),"."]}),t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"w-full min-w-[720px] border-collapse text-sm",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"text-left text-[10px] font-semibold uppercase tracking-wide text-gray-400",children:[N&&t.jsx("th",{className:"pb-1 pr-3 font-semibold",children:"Severity"}),t.jsx("th",{className:"pb-1 pr-3 font-semibold",children:"Comment"}),t.jsx("th",{className:"pb-1 pr-3 font-semibold",children:"Pull request"}),t.jsx("th",{className:"pb-1 font-semibold",children:"Posted"})]})}),t.jsx("tbody",{children:K.slice(0,L).map(me=>t.jsx(Xz,{c:me,showSeverity:N,onOpen:ae},`${me.targetKind}:${me.targetId}`))})]})}),K.length>L&&t.jsxs("button",{type:"button",onClick:()=>F(me=>me+Vz),className:"w-full rounded border border-gray-300 px-2 py-1 text-[11px] font-medium text-gray-500 hover:border-gray-400 dark:border-gray-700 dark:text-gray-400 dark:hover:border-gray-500",children:["Show more (",(K.length-L).toLocaleString()," remaining)"]}),t.jsx("div",{className:"text-[11px] text-gray-400",children:U?`${K.length.toLocaleString()} of ${te.length.toLocaleString()} comments match`:`${te.length.toLocaleString()} comments`})]}):A.isLoading?t.jsx("div",{className:"space-y-2",children:[0,1,2,3].map(me=>t.jsx("div",{className:"h-8 animate-pulse rounded bg-gray-100 dark:bg-gray-900/40"},me))}):A.isError?t.jsx("div",{className:"text-sm text-red-500",children:"Couldn’t load the PR list."}):W.length===0?t.jsx("div",{className:"rounded-lg border border-dashed border-gray-300 p-6 text-center text-sm text-gray-400 dark:border-gray-700",children:"No PRs for this bot in the window."}):t.jsx(sK,{rows:W,usersById:m,onOpen:ne})]})]})}const Ej={blocker:0,warning:1,nit:2,question:3,praise:4},Aj={blocker:"bg-red-500/10 text-red-700 dark:text-red-400",warning:"bg-orange-500/10 text-orange-700 dark:text-orange-400",nit:"bg-yellow-500/10 text-yellow-700 dark:text-yellow-500",question:"bg-blue-500/10 text-blue-700 dark:text-blue-400",praise:"bg-green-500/10 text-green-700 dark:text-green-400"};function zJ(e){return e.map((n,r)=>({f:n,i:r})).sort((n,r)=>{const s=Ej[n.f.severity]-Ej[r.f.severity];if(s!==0)return s;const a=n.f.priorFindingId!=null?0:1,i=r.f.priorFindingId!=null?0:1;return a!==i?a-i:n.i-r.i}).map(n=>n.f)}const Hi="bg-red-500/10 text-red-700 dark:text-red-400",Zo="bg-orange-500/10 text-orange-700 dark:text-orange-400",zi="bg-green-500/10 text-green-700 dark:text-green-400",Sr="bg-gray-500/10 text-gray-600 dark:text-gray-300",Mj={not_addressed:Hi,partly_addressed:Zo,not_checked:Sr,addressed:zi,no_longer_applies:Sr},KJ={met:zi,partly_met:Zo,not_met:Hi,unclear:Sr,not_checked:Sr},tx=zi,nx=Zo,oK={APPROVE:zi,REQUEST_CHANGES:Hi,COMMENT:Sr},iK={aligned:zi,partly_aligned:Zo,not_aligned:Hi,unclear:Sr,not_checked:Sr},S0={not_addressed:0,partly_addressed:1,not_checked:2};function GJ(e){const n=[],r=[];return e.forEach((s,a)=>{S0[s.status]!=null?n.push({it:s,i:a}):r.push(s)}),n.sort((s,a)=>(S0[s.it.status]??9)-(S0[a.it.status]??9)||s.i-a.i),{open:n.map(s=>s.it),closed:r}}function TR(e,n){return e.headMoved??n}function VJ(e,n,r,s){const a=e.reraisedFindingId!=null?n.get(e.reraisedFindingId):void 0;return a?{path:a.path,line:a.line,side:a.side,inChangeset:s.size>0?s.has(a.path):a.fileInDiff}:{path:e.path,line:TR(e,r)?null:e.line,side:e.side,inChangeset:s.has(e.path)}}function QJ(e,n){return n!=null?`${e}:${n}`:e}function YJ(e){return e.sent?"Claude didn't report on this one.":"Not sent to Claude: too many earlier comments."}const XJ={valid:Zo,partly_valid:Zo,not_valid:Sr,unclear:Sr,not_checked:Sr},lK={not_addressed:Hi,partly_addressed:Zo,addressed:zi,unclear:Sr,not_checked:Sr};function ZJ(e){return e.validity==="not_valid"?Sr:lK[e.addressed]}function cK(e){return!mx(e)&&(e.addressed==="addressed"||e.validity==="not_valid")}function JJ(e){const n=a=>mx(a)?0:a.validity==="not_checked"&&a.addressed==="not_checked"?2:1,r=[],s=[];return e.forEach((a,i)=>{cK(a)?s.push(a):r.push({t:a,i})}),r.sort((a,i)=>n(a.t)-n(i.t)||a.i-i.i),{shown:r.map(a=>a.t),more:s}}function eee(e){const n=[{key:"toFix",label:`${e.validUnaddressed} still to fix`,cls:Hi},{key:"addressed",label:`${e.addressed} addressed`,cls:zi},{key:"notValid",label:`${e.notValid} not valid`,cls:Sr},{key:"notChecked",label:`${e.notChecked} not checked`,cls:Sr}],r={toFix:e.validUnaddressed,addressed:e.addressed,notValid:e.notValid,notChecked:e.notChecked};return n.filter(s=>r[s.key]>0)}function tee(e){return e.sent?"Claude didn't report on this one.":"Not sent to Claude: too many open threads."}function nee(e){var a;const n=new Map,r=((a=e.followUp)==null?void 0:a.items)??[];if(r.length===0)return n;const s=new Map;for(const i of r)s.set(i.priorFindingId,i.status);for(const i of e.findings){if(i.priorFindingId==null)continue;const c=s.get(i.priorFindingId);(c==="not_addressed"||c==="partly_addressed")&&n.set(i.id,c)}return n}const ree={not_addressed:{label:"Not addressed since last review",cls:Hi},partly_addressed:{label:"Partly addressed since last review",cls:Zo}};function see(e){const n=new Set,r=e.followUp;if(!r||r.items.length===0)return n;const s=new Set;for(const a of r.items)a.priorPosted===!0&&!TR(a,r.headMoved)&&s.add(a.priorFindingId);for(const a of e.findings)a.priorFindingId!=null&&s.has(a.priorFindingId)&&n.add(a.id);return n}const aee={label:"Already posted",title:"This comment is already on the pull request, on this same commit, so it starts ignored.",cls:Sr},$R={title:"",description:"",acceptanceCriteria:""};function jy(e){if(!e)return $R;const n={title:e.title??"",description:e.description??"",acceptanceCriteria:e.acceptanceCriteria??""};return e.source==="jira"&&(n.source="jira",e.key!=null&&(n.key=e.key),e.url!=null&&(n.url=e.url),e.fetchedAt!=null&&(n.fetchedAt=e.fetchedAt)),n}function dK(e){return e==null?[]:(e.tickets!=null?e.tickets.map(r=>r.ticket):e.ticket?[e.ticket]:[]).map(jy).filter(Ny)}function oee(e){return e.source==="jira"}function Ny(e){return e.title.trim()!==""||e.description.trim()!==""||e.acceptanceCriteria.trim()!==""}function Lj(e){return sS(e)}function Fj(e){if(!e.ok||e.ticket==null)return;const n=e.ticket;return _R(n)}function _R(e){const n={};return e.title!=null&&(n.title=e.title),e.description!=null&&(n.description=e.description),e.acceptanceCriteria!=null&&(n.acceptanceCriteria=e.acceptanceCriteria),e.source!=null&&(n.source=e.source),e.key!=null&&(n.key=e.key),e.url!=null&&(n.url=e.url),e.fetchedAt!=null&&(n.fetchedAt=e.fetchedAt),n}function iee(e){return aS(e)}function uK(e){if(!(!e.ok||e.tickets.length===0))return e.tickets.map(_R)}function lee(e,n){const r=e.filter(Ny).length;return r===0?"":n.ok?` · ${r} added`:" · needs a fix"}function cee(e,n){return e??dK(n)}const hK={title:th.titleChars,description:th.descriptionChars,acceptanceCriteria:th.acceptanceCriteriaChars};function dee(e,n){const r=hK[e],s=n.trim().length;return s<=r*.8?null:{text:`${s} / ${r} characters`,over:s>r}}const pK=50;function uee(e=pK){const n=new Map;return{get:r=>n.get(r),has:r=>n.has(r),set:(r,s)=>{for(n.delete(r),n.set(r,s);n.size>e;){const a=n.keys().next().value;if(a===void 0)break;n.delete(a)}}}}const PR=(e,n)=>`${e}:${n}`;function mK(e){const n=new Map;for(const r of e){if(r.story==null)continue;const s=PR(r.story.index,r.story.ref);n.has(s)||n.set(s,r.id)}return n}function Oj(e,n,r){const s="ref"in r?r.ref:n4(r.missingIndex);return e.get(PR(n,s))??null}function hee(e,n){const r=(n??[]).find(a=>a.index===e.index);return`${r?r4(r.ticket,r.index):"Story"} · ${/^M\d+$/.test(e.ref)?"Not done":e.ref}`}function pee(e,n){const r=mK(e),s=new Map(e.map(i=>[i.id,i])),a=new Set;for(const i of n??[]){const c=i.assessment;if(c!=null){for(const d of c.criteria){if(d.status!=="not_met"&&d.status!=="partly_met")continue;const u=Oj(r,i.index,{ref:d.ref});u!=null&&a.add(u)}c.missing.forEach((d,u)=>{const m=Oj(r,i.index,{missingIndex:u});m!=null&&a.add(m)})}}return{byId:s,ids:r,placed:a}}function mee(e,n){return n==null?"Not done":`${e} · ${J$[n]}`}function gK(e){return e?e.filter(n=>n.provider==="jira"&&n.canFetchDetails===!0):[]}function gee(e){return e?e.filter(n=>n.provider==="jira"&&n.canFetchDetails!==!0):[]}function fK(e,n){return{...e,title:n.title,description:n.description}}function xK(e,n=new Date){return{source:"jira",key:e.key,url:e.url,fetchedAt:n.toISOString()}}function yK(e,n,r){if(r==="")return e;const s=n.find(a=>a.id===r);return s?{...e,acceptanceCriteria:s.text}:e}function bK(){try{return typeof window<"u"&&window.localStorage?window.localStorage:null}catch{return null}}function vK(e){try{return new URL(e).host.toLowerCase()||null}catch{return null}}const rx=(e,n)=>`limn:jira-ac-field:v1:${e}:${n}`;function kK(e,n,r){if(e==null||n==null||r==null)return null;try{const s=e.getItem(rx(n,r));return s!=null&&s!==""?s:null}catch{return null}}function fee(e,n,r,s){if(!(e==null||n==null||r==null))try{s===""?e.removeItem(rx(n,r)):e.setItem(rx(n,r),s)}catch{}}function wK(e,n,r){const s=Z$(n.candidates,r);return{draft:yK(fK(e,n),n.candidates,s),chosen:s}}const Dj=60,jK="★";function xee(e){const n=e.text.replace(/\s+/g," ").trim(),r=n.length>Dj?`${n.slice(0,Dj).trimEnd()}…`:n;return`${e.match==="strong"?`${jK} `:""}${e.name} (${e.id}) — ${r}`}function yee(e,n){return e.candidates.length===0?`${e.key} has no other fields with text, so the acceptance criteria were left as they were.`:n===""?"Pick the field that holds the acceptance criteria. The box is unchanged until you do.":null}const NK={COMMENT:"Comment",REQUEST_CHANGES:"Request changes",APPROVE:"Approve"};function ER(e,n){if(e==null)return n?{kind:"starting"}:{kind:"start"};const r=e.trigger==="auto"?{auto:!0}:{};if(r.auto&&(e.status==="queued"||e.status==="running"))return{kind:e.status,...r};if(n)return{kind:"starting"};switch(e.status){case"queued":return{kind:"queued"};case"running":return{kind:"running"};case"succeeded":return{kind:"done",reviewId:e.reviewId,...e.verdict!=null?{verdict:e.verdict}:{},verdictLabel:e.verdict!=null?NK[e.verdict]:"Reviewed",headMoved:e.headMoved,...r};case"failed":return{kind:"start",failed:!0};case"cancelled":return{kind:"start"}}}function SK(e){switch(e.kind){case"start":return 0;case"done":return e.headMoved?1:4;case"starting":case"queued":return 2;case"running":return 3}}const CK=["blocker","warning","nit","question"],RK={blocker:["blocker","blockers"],warning:["warning","warnings"],nit:["nit","nits"],question:["question","questions"],praise:["praise","praise"]};function IK(e){return CK.filter(n=>(e.findings[n]??0)>0).map(n=>{const r=e.findings[n];return{severity:n,count:r,label:`${r} ${RK[n][r===1?0:1]}`}})}function TK(e){return Object.values(e.findings).reduce((n,r)=>n+r,0)}function $K(e){const n=e.reviewedHeadSha,r=e.currentHeadSha;if(!n||!r)return null;const s=r.slice(0,7);if(n===r)return{tone:"current",label:"On latest commit",sha:s,className:tx,title:`Reviewed ${s}, the PR's latest commit`};const a=e.commitsSince;return{tone:"behind",label:a==null||a<=0?"Branch changed":`${a} newer commit${a===1?"":"s"}`,sha:s,className:nx,title:`Reviewed ${n.slice(0,7)}; the PR is now at ${s}`}}const _K={aligned:"Matches",partly_aligned:"Partly",not_aligned:"Doesn't match",unclear:"Can't tell",not_checked:"Not checked"};function PK(e){if(e==null)return null;const n=e.addressed,r=e.not_addressed+e.partly_addressed;return n===0&&r===0?null:{fixed:n,open:r}}function EK(e){switch(e.kind){case"start":return e.failed?"bad":"none";case"starting":case"queued":case"running":return"active";case"done":return e.verdict==="REQUEST_CHANGES"?"bad":e.verdict==="APPROVE"?"ok":"neutral"}}function AK(e){if(e==null||e.failing<=0)return null;const n=`CI failure${e.failing===1?"":"s"}`;return e.diagnosed>=e.failing?`${e.failing} ${n} explained`:`${e.failing} ${n}, ${e.diagnosed===0?"none":e.diagnosed} explained`}function MK(e){var r;const n=((r=e.threadAssessments)==null?void 0:r.validUnaddressed)??0;return n>0?`${n} thread${n===1?"":"s"} to fix`:null}function LK(e){var r;const n=(r=e==null?void 0:e.summary)==null?void 0:r.findings;return n==null?-1:n.blocker*1e6+n.warning*1e3+n.nit+n.question}function FK(e){return(e==null?void 0:e.trigger)==="auto"&&(e.status==="queued"||e.status==="running")}function OK(e){return(e??[]).some(n=>n.status==="queued"||n.status==="running")}const C0="Started without a user story.";async function DK(e){var m;const n=jy(e.previous);if(Ny(n)){const h=Lj(n);return h.ok?{ticket:Fj(h),note:null}:{ticket:void 0,note:`Started without the user story: ${h.message}`}}let r;try{r=await e.loadTickets()}catch{return{ticket:void 0,note:C0}}const s=gK(r)[0];if(s==null)return{ticket:void 0,note:C0};let a;try{a=await e.loadDetails(s.key)}catch{return{ticket:void 0,note:`Started without a user story: ${s.key} could not be read.`}}const i=kK(e.memory,vK(s.url),(m=a.issueType)==null?void 0:m.id),c={...wK($R,a,i).draft,...xK(s)},d=Lj(c);if(!d.ok)return{ticket:void 0,note:`Started without ${s.key}: ${d.message}`};const u=Fj(d);return u!=null?{ticket:u,note:null}:{ticket:void 0,note:C0}}const bee={ci:"Auto review waiting for CI",comments:"Auto review waiting for comments to settle",commits:"Auto review waiting for pushes to settle"},BK={nothing_to_fix:"the review found nothing to fix",cap:`${N$} auto fixes already ran on this PR in the last 24 hours`,fix_in_progress:"a fix for this PR is already running",fix_waiting:"a finished fix is waiting to be pushed",already_tried:"the last auto fix could not address these items",head_moved:"the PR has new commits since this review",not_started:"the fixer could not start"};function vee(e){return e==null?null:e.status==="started"?"Auto fix started. See the AI Fix tab.":`No auto fix: ${BK[e.reason]??"skipped"}.`}function WK(e){return e==="running"?"Fixing…":e==="ready"?"Fix ready":null}function qK(e){return(e??[]).some(n=>n.fix==="running")}function kee(e){return Oe({queryKey:["claude-review",e],queryFn:()=>he.claudeReview(e),enabled:e!=null,refetchInterval:n=>{var r,s;return((r=n.state.data)==null?void 0:r.autoReview)==="queued"?5e3:((s=n.state.data)==null?void 0:s.autoReviewWaiting)!=null?3e4:!1}})}function wee(e){return Oe({queryKey:["claude-review-by-id",e],queryFn:()=>he.claudeReviewById(e),enabled:e!=null})}function jee(e,n){const r=He(),[s,a]=f.useState(null);return f.useEffect(()=>{if(e==null||!n){a(null);return}const i=new AbortController;let c=!1;const d=()=>{c||(c=!0,r.invalidateQueries({queryKey:["claude-review",e]}),r.invalidateQueries({queryKey:Od}))};return Pd(`/api/prs/${e}/claude-review/stream`,{signal:i.signal,onEvent:u=>{u.type==="done"?(d(),a({status:u.status,reviewId:u.reviewId,progress:null})):a({status:u.status,reviewId:u.reviewId,progress:u.progress})}}).catch(()=>{}),()=>i.abort()},[e,n,r]),{status:s}}const Sy=e=>["claude-review-start",e],Od=["claude-review-states"];function UK(e){return Or({mutationKey:Sy(e)})>0}function AR(e,n){return G.getState().bumpClaudeReviewKickoff(),Promise.all([e.invalidateQueries({queryKey:["claude-review",n]}),e.invalidateQueries({queryKey:["claude-review-status",n]}),e.invalidateQueries({queryKey:Od})])}function Nee(e){const n=He();return tt({mutationKey:Sy(e),mutationFn:r=>he.generateClaudeReview(e,r.model,r.tickets),onSuccess:()=>AR(n,e),onError:r=>Cy(r)?Promise.all([n.invalidateQueries({queryKey:["claude-review",e]}),n.invalidateQueries({queryKey:Od})]):void 0})}function HK(e,n){const r=[...new Set(e)].sort((s,a)=>s-a).slice(0,S$);return Oe({queryKey:[...Od,r.join(",")],queryFn:()=>he.claudeReviewStates(r),enabled:n&&r.length>0,refetchInterval:s=>{var a,i;return OK((a=s.state.data)==null?void 0:a.states)||qK((i=s.state.data)==null?void 0:i.states)?5e3:!1}})}function zK(e){const n=He();return tt({mutationKey:Sy(e),mutationFn:async({previous:r})=>{const s=(r==null?void 0:r.tickets)??[];if(s.length>1){const i=aS(s.map(jy)),c=uK(i);if(c!=null)return await he.generateClaudeReview(e,dk,c),{ticket:c[0],note:null}}const a=await DK({previous:(r==null?void 0:r.ticket)??null,loadTickets:async()=>(await n.fetchQuery({queryKey:["pr",e],queryFn:()=>he.pr(e),staleTime:1/0})).tickets,loadDetails:i=>he.jiraTicket(e,i),memory:bK()});return await he.generateClaudeReview(e,dk,a.ticket!=null?[a.ticket]:void 0),a},onSuccess:()=>AR(n,e),onError:r=>Cy(r)?Promise.all([n.invalidateQueries({queryKey:Od}),n.invalidateQueries({queryKey:["claude-review",e]})]):void 0})}function Cy(e){return e instanceof cn&&e.status===409&&e.code==="AutoReviewInProgress"}function See(e){const n=He();return tt({mutationFn:r=>he.postClaudeFinding(r.findingId),onSuccess:()=>{n.invalidateQueries({queryKey:["claude-review",e]}),dn(n,e)}})}function Cee(e){const n=He();return tt({mutationFn:()=>he.cancelClaudeReview(e),onSuccess:()=>void n.invalidateQueries({queryKey:["claude-review",e]})})}function Ree(e){const n=He();return tt({mutationFn:r=>he.updateClaudeReview(r.reviewId,{userBody:r.userBody,userVerdict:r.userVerdict}),onSuccess:()=>void n.invalidateQueries({queryKey:["claude-review",e]})})}function Iee(e){const n=He();return tt({mutationFn:r=>he.updateClaudeFinding(r.findingId,{included:r.included,editedBody:r.editedBody}),onSuccess:()=>void n.invalidateQueries({queryKey:["claude-review",e]})})}function KK(e){return Oe({queryKey:["claude-reviews-active"],queryFn:he.activeClaudeReviews,enabled:e,refetchInterval:2500})}function Tee(e){const n=He();return tt({mutationFn:r=>he.postClaudeReview(r.reviewId,r.userVerdict,r.dryRun??!1),onSuccess:(r,s)=>{s.dryRun||(n.invalidateQueries({queryKey:["claude-review",e]}),dn(n,e))}})}const MR=[{key:"updated",name:"Updated",natural:"desc",words:{desc:"latest first",asc:"earliest first"}},{key:"age",name:"Opened",natural:"asc",words:{asc:"oldest first",desc:"newest first"}},{key:"loc",name:"Size",natural:"desc",words:{desc:"largest first",asc:"smallest first"}},{key:"threads",name:"Untouched threads",natural:"desc",words:{desc:"most first",asc:"fewest first"}},{key:"ci",name:"CI",natural:"asc",words:{asc:"failing first",desc:"failing last"}},{key:"approval",name:"Approval",natural:"asc",words:{asc:"changes requested first",desc:"approved first"}},{key:"claude",name:"Claude review",natural:"asc",words:{asc:"not reviewed first",desc:"reviewed first"},claude:!0},{key:"findings",name:"Claude findings",natural:"desc",words:{desc:"most severe first",asc:"least severe first"},claude:!0},{key:"repo",name:"Repo",natural:"asc",words:{asc:"A to Z",desc:"Z to A"}},{key:"author",name:"Author",natural:"asc",words:{asc:"A to Z",desc:"Z to A"}},{key:"pr",name:"PR number",natural:"desc",words:{desc:"highest first",asc:"lowest first"}}],GK="Recent activity";function Ry(e){return MR.find(n=>n.key===e)}function VK(e){return MR.filter(n=>e||n.claude!==!0)}function QK(e){if(e==null)return GK;const n=Ry(e.key);return`${n.name}, ${n.words[e.dir]}`}function YK(e){return{key:e,dir:Ry(e).natural}}function XK(e){return{key:e.key,dir:e.dir==="asc"?"desc":"asc"}}function LR(e,n){return e==null||!n&&Ry(e.key).claude===!0?null:e}const ZK={failure:0,error:0,pending:1,success:2,expected:3,unknown:4};function JK(e){return e.isChangesRequested?0:e.isApproved?2:1}function Bj(e,n,r){switch(n){case"pr":return e.number;case"repo":return r.repoNameById.get(e.repoId)??"";case"author":{const s=e.authorId!=null?r.usersById.get(e.authorId):void 0;return Dt(s,e.authorId).toLowerCase()}case"age":return e.openedAt;case"updated":return e.updatedAt;case"loc":return e.additions+e.deletions;case"threads":return e.threadCounts.untouched;case"ci":return ZK[e.ciStatus];case"approval":return JK(e);case"claude":return SK(ER(r.claudeStates.get(e.id),!1));case"findings":return LK(r.claudeStates.get(e.id))}}function eG(e,n){return typeof e=="string"&&typeof n=="string"?e.localeCompare(n):e-n}function tG(e,n,r){const s=n.dir==="asc"?1:-1;return[...e].sort((a,i)=>s*eG(Bj(a,n.key,r),Bj(i,n.key,r))||i.number-a.number)}const nG="pierre:reviewSoundMuted";let Gu=null;function FR(){try{if(Gu!=null)return Gu;const e=window,n=window.AudioContext??e.webkitAudioContext;return n==null?null:(Gu=new n,Gu)}catch{return null}}function rG(){try{return localStorage.getItem(nG)==="true"}catch{return!1}}function sG(){try{const e=FR();e!=null&&e.state==="suspended"&&e.resume()}catch{}}function Wj(e,n,r,s){const a=e.createOscillator(),i=e.createGain();a.type="sine",a.frequency.value=n;const c=.12;i.gain.setValueAtTime(1e-4,r),i.gain.exponentialRampToValueAtTime(c,r+.02),i.gain.exponentialRampToValueAtTime(1e-4,r+s),a.connect(i),i.connect(e.destination),a.start(r),a.stop(r+s+.02)}function aG(){try{if(rG())return;const e=FR();if(e==null)return;e.state==="suspended"&&e.resume();const n=e.currentTime+.01;Wj(e,660,n,.15),Wj(e,990,n+.13,.18)}catch{}}const da="inline-flex items-center gap-1 whitespace-nowrap rounded px-1.5 py-px text-[11px] font-medium",qj=`${da} bg-gray-500/10 text-gray-600 dark:text-gray-300`,Kc="inline-flex items-center gap-1 whitespace-nowrap rounded px-2 py-0.5 text-xs font-semibold",xh="text-[11px] text-ai-muted",Uj="whitespace-nowrap rounded border border-ai-border bg-white/70 px-2 py-0.5 text-[11px] font-medium text-ai-signal hover:border-ai-signal/60 hover:bg-ai-surface-2 disabled:cursor-default disabled:opacity-60 dark:bg-gray-900/50",oG="whitespace-nowrap rounded border border-ai-border bg-white/70 px-2 py-0.5 text-[11px] font-medium text-gray-700 hover:border-gray-400 dark:bg-gray-900/50 dark:text-gray-200 dark:hover:border-gray-500",iG=6e3,lG={none:"border-l-ai-border",active:"border-l-sky-400 dark:border-l-sky-500",bad:"border-l-red-500",ok:"border-l-green-500",neutral:"border-l-gray-400 dark:border-l-gray-500"};function R0(){return t.jsx("span",{className:xh,children:d2})}function Hj(){return t.jsx("span",{"aria-hidden":!0,className:"h-3.5 w-px shrink-0 bg-ai-border"})}function Vu({children:e}){return t.jsx("span",{className:"inline-flex min-w-0 flex-wrap items-center gap-1",children:e})}function cG({prId:e,state:n,onOpenReview:r,onOpenFix:s}){const a=zK(e),i=UK(e),c=ER(n,i),d=FK(n),u=a.isError&&!i&&(d||!Cy(a.error)),[m,h]=f.useState(null);f.useEffect(()=>{if(m==null)return;const D=setTimeout(()=>h(null),iG);return()=>clearTimeout(D)},[m]);const g=Dr().ready,x=D=>{if(D.stopPropagation(),!g){r();return}sG(),h(null),a.mutate({previous:n},{onSuccess:A=>h(A.note)})},y=D=>D.stopPropagation(),b=D=>{D.stopPropagation(),r()},w="cursor-pointer hover:brightness-95 hover:underline focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 dark:hover:brightness-125";let k,j=null;switch(c.kind){case"start":k=c.failed?t.jsx("button",{type:"button",onClick:b,className:`${Kc} ${Aj.blocker} ${w}`,children:"Review failed"}):t.jsx("span",{className:"text-xs text-ai-muted",children:"Not reviewed"}),j=t.jsx("button",{type:"button",onClick:x,className:Uj,children:"Review"});break;case"starting":k=t.jsx("span",{className:`${Kc} bg-gray-500/10 text-gray-600 dark:text-gray-300`,children:"Starting…"});break;case"queued":k=t.jsxs(t.Fragment,{children:[t.jsx("span",{className:`${Kc} bg-gray-500/10 text-gray-600 dark:text-gray-300`,children:"Queued"}),c.auto&&t.jsx(R0,{})]});break;case"running":k=t.jsxs(t.Fragment,{children:[t.jsxs("button",{type:"button",onClick:b,className:`${Kc} bg-ai-signal/10 text-ai-signal ${w}`,children:[t.jsx("span",{"aria-hidden":!0,className:"h-1.5 w-1.5 animate-pulse rounded-full bg-ai-signal-fill"}),"Reviewing…"]}),c.auto&&t.jsx(R0,{})]});break;case"done":{const D=n!=null?$K({reviewedHeadSha:n.reviewedHeadSha,currentHeadSha:n.currentHeadSha,commitsSince:n.commitsSince}):null;k=t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:b,title:"Open the review",className:`${Kc} ${c.verdict!=null?oK[c.verdict]:"bg-gray-500/10 text-gray-600 dark:text-gray-300"} ${w}`,children:c.verdictLabel}),c.auto&&t.jsx(R0,{}),D!=null&&t.jsx("span",{className:`${da} ${D.className}`,title:D.title,children:D.label})]}),j=c.headMoved?t.jsx("button",{type:"button",onClick:x,className:Uj,children:"Re-review"}):t.jsx("button",{type:"button",onClick:A=>{A.stopPropagation(),r()},className:oG,children:"Open review"});break}}const N=c.kind==="done"?n==null?void 0:n.summary:void 0,I=N!=null?IK(N):[],S=N!=null?TK(N):0,T=(N==null?void 0:N.lenses.design)??0,$=N!=null?PK(N.followUp):null,P=N!=null?AK(N.ci):null,C=N!=null?MK(N):null,L=((N==null?void 0:N.tickets)??[]).filter(D=>D.alignment!=null),F=N==null?null:N.postedFindings>0?`${N.postedFindings} of ${S} posted`:N.reviewPosted?"Posted":S>0?"Not posted":null,M=WK(n==null?void 0:n.fix);return t.jsxs("div",{className:`mt-1.5 flex cursor-default flex-wrap items-center gap-x-2.5 gap-y-1.5 rounded-md border border-l-[3px] border-ai-border bg-ai-surface px-2.5 py-1.5 ${lG[EK(c)]}`,onClick:y,role:"group","aria-label":"Claude review",children:[t.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 text-[11px] font-semibold text-ai-ink",children:[t.jsx(Ps,{size:12,className:"text-ai-signal"}),"Claude"]}),t.jsx(Vu,{children:k}),N!=null&&t.jsxs(t.Fragment,{children:[t.jsx(Hj,{}),t.jsxs(Vu,{children:[I.length>0?I.map(D=>t.jsx("span",{className:`${da} ${Aj[D.severity]}`,children:D.label},D.severity)):t.jsxs("span",{className:`${da} ${tx}`,children:[t.jsx(pr,{size:11}),"No issues"]}),P!=null&&t.jsx("span",{className:`${da} ${nx}`,title:"Failing checks on the reviewed commit",children:P}),C!=null&&t.jsx("span",{className:`${da} ${nx}`,title:"Other reviewers' threads Claude judged right and not yet dealt with",children:C})]})]}),(L.length>0||$!=null)&&t.jsxs(t.Fragment,{children:[t.jsx(Hj,{}),t.jsxs(Vu,{children:[L.map((D,A)=>t.jsxs("span",{className:`${da} ${iK[D.alignment]}`,title:`${D.title??"User story"}: ${e4[D.alignment]}`,children:[D.key??(L.length>1?`Story ${A+1}`:"Story")," · ",_K[D.alignment]]},A)),$!=null&&t.jsxs("span",{className:"inline-flex items-center gap-1",title:"Findings from the previous review",children:[t.jsx("span",{className:xh,children:"Earlier:"}),$.fixed>0&&t.jsxs("span",{className:`${da} ${Mj.addressed}`,children:[$.fixed," fixed"]}),$.open>0&&t.jsxs("span",{className:`${da} ${Mj.not_addressed}`,children:[$.open," still open"]})]})]})]}),(F!=null||T>0)&&t.jsxs(Vu,{children:[F!=null&&t.jsx("span",{className:xh,title:"Findings posted to GitHub",children:F}),T>0&&t.jsxs("span",{className:qj,title:"Findings about the design, from a deep review",children:[T," design"]})]}),u&&t.jsx("span",{className:"text-[11px] text-red-600 dark:text-red-400",children:a.error.message||"Could not start the review."}),m!=null&&!a.isError&&t.jsx("span",{className:xh,children:m}),t.jsxs("span",{className:"ml-auto inline-flex shrink-0 items-center gap-1.5",children:[M!=null&&t.jsxs("button",{type:"button",onClick:D=>{D.stopPropagation(),s()},className:`${(n==null?void 0:n.fix)==="ready"?`${da} ${tx}`:qj} hover:underline`,title:(n==null?void 0:n.fix)==="ready"?"Review and push the fix in the AI Fix tab":"Open the AI Fix tab",children:[(n==null?void 0:n.fix)==="running"&&t.jsx("span",{"aria-hidden":!0,className:"h-1.5 w-1.5 animate-pulse rounded-full bg-ai-signal-fill"}),M]}),j]})]})}const OR="inline-flex items-center gap-1 whitespace-nowrap rounded-full border px-2 py-px text-[11px] font-medium",DR=`${OR} border-gray-200 text-gray-600 dark:border-gray-700 dark:text-gray-300`,yd=`${OR} border-transparent`;function Gc(){return t.jsx("span",{"aria-hidden":!0,className:"decorative-mark text-gray-300 dark:text-gray-600",children:"·"})}function dG({ci:e}){const n=Rr[e];if(n==null)return null;const r=e==="failure"||e==="error";return t.jsxs("span",{className:r?`${yd} bg-red-500/10 text-red-700 dark:text-red-400`:DR,children:[t.jsx("span",{"aria-hidden":!0,className:"inline-block h-2 w-2 rounded-full",style:{background:n.color}}),n.label]})}function uG({pr:e}){return e.isChangesRequested?t.jsx("span",{className:`${yd} bg-red-500/10 text-red-700 dark:text-red-400`,children:"Changes requested"}):e.isApproved?t.jsxs("span",{className:`${yd} bg-green-500/10 text-green-700 dark:text-green-400`,children:[t.jsx(pr,{size:11}),"Approved"]}):null}function hG(e){const n=e.untouched+e.replied_unresolved+e.likely_addressed+e.resolved;if(n===0)return null;if(e.untouched>0)return{text:`${e.untouched} untouched`,warn:!0};const r=n-e.resolved;return r>0?{text:`${r} open thread${r===1?"":"s"}`,warn:!1}:{text:`${n} resolved`,warn:!1}}function pG({pr:e}){const n=hG(e.threadCounts);return n==null?null:t.jsxs("span",{className:n.warn?`${yd} bg-amber-500/10 text-amber-700 dark:text-amber-400`:DR,title:"Review threads: untouched · replied · likely addressed · resolved",children:[t.jsx(Xp,{counts:e.threadCounts,compact:!0,className:"!w-8"}),n.text]})}function mG({pr:e}){const n={mergeable:e.mergeable,mergeStateStatus:e.mergeStateStatus,isDraft:e.isDraft},r=e.isDraft?Cx(n):Pi(n);return r==null||r.verdict==="unknown"||r.verdict==="draft"?null:t.jsx("span",{className:`${yd} ${IS[r.tone]}`,title:r.detail??void 0,children:r.label})}function gG({sort:e,onChange:n}){const r=Dr().enabled,s=LR(e,r),[a,i]=f.useState(!1),c=f.useRef(null),d=f.useId();Yr(c,()=>i(!1),a),f.useEffect(()=>{if(!a)return;const h=g=>{g.key==="Escape"&&(g.stopPropagation(),i(!1))};return document.addEventListener("keydown",h),()=>document.removeEventListener("keydown",h)},[a]),f.useEffect(()=>{var h,g;a&&((g=(h=c.current)==null?void 0:h.querySelector('[role="menuitemradio"][aria-checked="true"]'))==null||g.focus())},[a]);const u=h=>{if(h.key!=="ArrowDown"&&h.key!=="ArrowUp")return;h.preventDefault();const g=[...h.currentTarget.querySelectorAll('[role="menuitemradio"]')],x=g.indexOf(document.activeElement),y=g[(x+(h.key==="ArrowDown"?1:-1)+g.length)%g.length];y==null||y.focus()},m=(h,g,x,y)=>t.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":x,onClick:()=>{y(),i(!1)},className:"flex w-full items-center gap-2 rounded px-2 py-1 text-left text-xs text-gray-800 hover:bg-gray-100 focus:bg-gray-100 focus:outline-none dark:text-gray-100 dark:hover:bg-gray-800 dark:focus:bg-gray-800",children:[t.jsx("span",{className:"inline-flex w-3 shrink-0 justify-center",children:x&&t.jsx(pr,{size:11})}),g]},h);return t.jsxs("div",{ref:c,className:"relative inline-flex items-center gap-1",children:[t.jsxs("button",{type:"button",onClick:()=>i(h=>!h),"aria-haspopup":"menu","aria-expanded":a,"aria-controls":a?d:void 0,className:"inline-flex items-center gap-1 whitespace-nowrap rounded-full border border-gray-300 py-0.5 pl-2.5 pr-2 text-xs text-gray-600 hover:border-gray-400 dark:border-gray-700 dark:text-gray-300 dark:hover:border-gray-500",children:[t.jsx("span",{className:"text-gray-500 dark:text-gray-400",children:"Sort:"}),t.jsx("span",{className:"font-medium text-gray-800 dark:text-gray-100",children:QK(s)}),t.jsx(Cr,{dir:"down"})]}),s!=null&&t.jsx("button",{type:"button",onClick:()=>n(XK(s)),"aria-label":"Reverse the order",title:"Reverse the order",className:"inline-flex h-6 w-6 items-center justify-center rounded-full border border-gray-300 text-gray-600 hover:border-gray-400 dark:border-gray-700 dark:text-gray-300 dark:hover:border-gray-500",children:t.jsx(_s,{dir:s.dir==="asc"?"up":"down",size:11})}),a&&t.jsxs("div",{id:d,role:"menu","aria-label":"Sort open PRs",onKeyDown:u,className:"absolute right-0 top-full z-[60] mt-1 w-56 rounded-lg border border-gray-200 bg-white p-1 shadow-lg dark:border-gray-700 dark:bg-gray-900",children:[m("default","Recent activity",s==null,()=>n(null)),t.jsx("div",{className:"my-1 border-t border-gray-200 dark:border-gray-700"}),VK(r).map(h=>m(h.key,h.name,(s==null?void 0:s.key)===h.key,()=>n(YK(h.key))))]})]})}function fG({prs:e,isLoading:n,isError:r,sort:s,onOpenPr:a,emptyLabel:i=t.jsxs(t.Fragment,{children:[t.jsx(Vo,{className:"mr-1.5 inline-block align-[-0.15em] decorative-mark text-gray-300 dark:text-gray-600"}),"No open PRs here."]})}){const{data:c}=An(),{data:d}=xn(),u=Ax(),m=f.useMemo(()=>Rn(c),[c]),h=f.useMemo(()=>new Map((d??[]).map(S=>[S.id,S.fullName])),[d]),g=Dr().enabled,x=f.useMemo(()=>e.map(S=>S.id),[e]),{data:y}=HK(x,g),b=f.useMemo(()=>new Map(((y==null?void 0:y.states)??[]).map(S=>[S.prId,S])),[y]),w=G(S=>S.openClaudeReview),k=G(S=>S.openAiFix),j=S=>{const T=S.authorId!=null?m.get(S.authorId):void 0;return{id:S.id,number:S.number,title:S.title,repoFullName:h.get(S.repoId)??"",authorLogin:(T==null?void 0:T.githubLogin)??null,authorDisplayName:(T==null?void 0:T.displayName)??null,authorAvatarUrl:(T==null?void 0:T.avatarUrl)??null}},N=LR(s,g),I=f.useMemo(()=>N==null?NS(e,S=>{const T=u.get(S.repoId);return S.authorId!=null&&T!=null&&T.has(S.authorId)}):tG(e,N,{usersById:m,repoNameById:h,claudeStates:b}),[e,N,u,m,h,b]);return n?t.jsx("div",{className:"space-y-2",children:[0,1,2,3].map(S=>t.jsx("div",{className:"h-24 animate-pulse rounded-lg bg-gray-100 dark:bg-gray-900/40"},S))}):r?t.jsx("div",{className:"text-sm text-red-500",children:"Couldn’t load the open PRs."}):I.length===0?t.jsx("div",{className:"rounded-lg border border-dashed border-gray-300 p-6 text-center text-sm text-gray-500 dark:border-gray-700 dark:text-gray-400",children:i}):t.jsx("ul",{"aria-label":"Open pull requests",className:"space-y-2",children:I.map(S=>t.jsx(xG,{pr:S,author:S.authorId!=null?m.get(S.authorId):void 0,repoName:h.get(S.repoId)??`repo ${S.repoId}`,onOpen:()=>a(S),claude:g?t.jsx(cG,{prId:S.id,state:b.get(S.id),onOpenReview:()=>w(j(S),{fromActivity:!0}),onOpenFix:()=>k(j(S))}):null},S.id))})}function xG({pr:e,author:n,repoName:r,onOpen:s,claude:a}){const i=f.useId(),c=u=>{u.target===u.currentTarget&&(u.key==="Enter"||u.key===" ")&&(u.preventDefault(),s())},d=u=>{u.target.closest("a,button,[data-noactivate]")||s()};return t.jsxs("li",{tabIndex:0,"aria-labelledby":i,onClick:d,onKeyDown:c,className:"cursor-pointer rounded-lg border border-gray-200 bg-white px-3.5 py-2 transition-colors hover:border-gray-300 hover:bg-gray-50/60 focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 dark:border-gray-800 dark:bg-gray-900/40 dark:hover:border-gray-700 dark:hover:bg-gray-900/70",children:[t.jsxs("h3",{id:i,className:"flex min-w-0 items-center gap-2",children:[t.jsx("span",{className:"min-w-0 truncate text-sm font-semibold text-gray-900 dark:text-gray-50",title:e.title,children:e.title}),e.isDraft&&t.jsx("span",{className:"shrink-0 rounded border border-gray-300 px-1.5 text-[11px] font-medium text-gray-600 dark:border-gray-600 dark:text-gray-300",children:"Draft"})]}),t.jsxs("div",{className:"mt-1.5 flex flex-wrap items-center gap-1.5 empty:hidden",children:[t.jsx(dG,{ci:e.ciStatus}),t.jsx(uG,{pr:e}),t.jsx(pG,{pr:e}),t.jsx(mG,{pr:e})]}),t.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-x-1.5 gap-y-1 text-[11px] text-gray-500 dark:text-gray-400",children:[t.jsxs("span",{className:"font-mono",children:["#",e.number]}),t.jsx(Gc,{}),t.jsx("span",{className:"max-w-[18rem] truncate",title:r,children:r}),t.jsx(Gc,{}),t.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1 text-gray-600 dark:text-gray-300",children:[t.jsx(gn,{user:n,size:14}),t.jsx("span",{className:"truncate",children:Dt(n,e.authorId)})]}),t.jsx(Gc,{}),t.jsxs("span",{title:`Opened ${Cn(e.openedAt)}`,children:["opened ",Nt(e.openedAt)]}),e.updatedAt!==e.openedAt&&t.jsxs(t.Fragment,{children:[t.jsx(Gc,{}),t.jsxs("span",{title:`Updated ${Cn(e.updatedAt)}`,children:["updated ",Nt(e.updatedAt)]})]}),t.jsx(Gc,{}),t.jsxs("span",{children:[e.changedFiles," file",e.changedFiles===1?"":"s"]}),t.jsxs("span",{className:"font-mono",children:[t.jsxs("span",{className:"text-green-600 dark:text-green-400",children:["+",e.additions]})," ",t.jsxs("span",{className:"text-red-500 dark:text-red-400",children:["−",e.deletions]})]}),t.jsx(Up,{pr:e}),t.jsx(Md,{pr:e})]}),a]})}function yG(){const{data:e,isLoading:n,isError:r,refetch:s,isFetching:a}=q_(),{data:i}=An(),{data:c}=xn(),d=f.useMemo(()=>Rn(i),[i]),u=f.useMemo(()=>new Map((c??[]).map($=>[$.id,$.fullName])),[c]),m=Ge($=>$.openPrDetailTab),h=f.useMemo(()=>(e==null?void 0:e.prs)??[],[e]),[g,x]=f.useState(null),y=G($=>$.workspaceId),b=G($=>$.openPrsRepoFilter),w=G($=>$.setOpenPrsRepoFilter),k=b!=null&&b.workspaceId===y?b.repoIds:null,j=f.useMemo(()=>{const $=new Map;for(const P of h)$.set(P.repoId,u.get(P.repoId)??`repo ${P.repoId}`);for(const P of k??[])$.has(P)||$.set(P,u.get(P)??`repo ${P}`);return[...$.entries()].map(([P,C])=>({id:P,fullName:C})).sort((P,C)=>P.fullName.localeCompare(C.fullName))},[h,u,k]),N=k!=null?h.filter($=>k.includes($.repoId)):h,I=$=>{const P=$.authorId!=null?d.get($.authorId):void 0,C={id:$.id,number:$.number,title:$.title,repoFullName:u.get($.repoId)??"",authorLogin:(P==null?void 0:P.githubLogin)??null,authorDisplayName:(P==null?void 0:P.displayName)??null,authorAvatarUrl:(P==null?void 0:P.avatarUrl)??null};m(C,{fromActivity:!0})},S=k==null?"every repo in this Workspace":k.length===1?u.get(k[0])??`repo ${k[0]}`:`${k.length} repos`,T=N.reduce(($,P)=>$+(P.isDraft?1:0),0);return t.jsxs("div",{className:"mx-auto max-w-[100rem] space-y-4 p-4",children:[t.jsxs("div",{className:"flex flex-wrap items-baseline gap-2",children:[t.jsx("h2",{className:"text-base font-semibold text-gray-800 dark:text-gray-100",children:"Open PRs"}),t.jsxs("span",{className:"text-[11px] text-gray-400",children:[S," · ",N.length-T," open",T>0&&` · ${T} draft${T===1?"":"s"}`]}),t.jsxs("div",{className:"ml-auto flex flex-wrap items-center gap-2",children:[t.jsx(gG,{sort:g,onChange:x}),t.jsx(CR,{repos:j,selected:k,onChange:w}),t.jsxs("button",{type:"button",onClick:()=>void s(),disabled:a,className:"rounded border border-gray-300 px-1.5 py-0.5 text-[11px] font-medium hover:border-gray-400 disabled:opacity-50 dark:border-gray-700 dark:hover:border-gray-500",children:[t.jsx(us,{size:11,className:`inline-block align-[-0.1em] ${a?"animate-spin":""}`})," ","Refresh"]})]})]}),t.jsx(fG,{prs:N,isLoading:n,isError:r,sort:g,onOpenPr:I,emptyLabel:k!=null&&h.length>0?"No open PRs for the selected repos — adjust the repo filter.":void 0})]})}const bG=[{key:"rolling_7",label:"7d"},{key:"rolling_14",label:"14d"},{key:"rolling_30",label:"30d"},{key:"sprint",label:"Sprint"}],vG={pr:"desc",repo:"asc",bot:"asc",state:"asc",author:"asc",age:"asc",updated:"desc"};function zj(e,n,r){switch(n){case"pr":return e.number;case"repo":return e.repoFullName.toLowerCase();case"bot":return e.botLabel.toLowerCase();case"state":return e.state;case"author":{const s=e.authorId!=null?r.get(e.authorId):void 0;return((s==null?void 0:s.githubLogin)??Dt(s,e.authorId)).toLowerCase()}case"age":return e.openedAt;case"updated":return e.updatedAt}}function kG({pr:e,usersById:n,showRepo:r,onOpen:s,onShowInFeed:a,isolated:i}){const c=e.authorId!=null?n.get(e.authorId):void 0;return t.jsxs("tr",{onClick:()=>s(e),title:`Open #${e.number} in its own tab`,className:"cursor-pointer border-t border-gray-100 align-top hover:bg-gray-50/70 dark:border-gray-800/60 dark:hover:bg-gray-900/40",children:[t.jsx("td",{className:"max-w-md py-1.5 pr-3",children:t.jsxs("span",{className:"flex items-center gap-1.5",children:[t.jsxs("span",{className:"font-mono text-[11px] text-gray-400",children:["#",e.number]}),t.jsx("span",{className:"min-w-0 truncate text-sm font-medium text-gray-800 dark:text-gray-100",children:e.title})]})}),r&&t.jsx("td",{className:"py-1.5 pr-3 text-[11px] text-gray-500 dark:text-gray-400",children:t.jsx("span",{className:"block max-w-[12rem] truncate font-mono",children:e.repoFullName})}),t.jsx("td",{className:"py-1.5 pr-3",children:t.jsxs("span",{className:"inline-flex items-center gap-1 rounded border border-amber-300 bg-amber-100/70 px-1.5 py-px text-[10px] font-medium text-amber-700 dark:border-amber-700/60 dark:bg-amber-900/30 dark:text-amber-300",children:[t.jsx(Lt,{size:10}),e.botLabel]})}),t.jsx("td",{className:"py-1.5 pr-3 text-[10px] uppercase tracking-wide text-gray-500 dark:text-gray-400",children:e.state}),t.jsx("td",{className:"py-1.5 pr-3",children:t.jsxs("span",{className:"inline-flex items-center gap-1 text-[11px] text-gray-600 dark:text-gray-300",children:[t.jsx(gn,{user:c,size:14}),t.jsx("span",{className:"max-w-[8rem] truncate",children:Dt(c,e.authorId)})]})}),t.jsx("td",{className:"py-1.5 pr-3 text-[11px] text-gray-500 dark:text-gray-400",children:Nt(e.openedAt)}),t.jsx("td",{className:"py-1.5 pr-3 text-[11px] text-gray-500 dark:text-gray-400",children:Nt(e.updatedAt)}),t.jsx("td",{className:"py-1.5 pr-3",children:t.jsxs("a",{href:e.githubUrl,target:"_blank",rel:"noreferrer noopener",onClick:d=>d.stopPropagation(),className:"inline-flex items-center gap-0.5 text-[11px] text-gray-500 hover:underline dark:text-gray-400",title:"Open on GitHub",children:["GitHub",t.jsx(_t,{size:10})]})}),t.jsx("td",{className:"py-1.5",onClick:d=>d.stopPropagation(),children:e.viaPierreOnly?t.jsx("span",{className:"cursor-help rounded border border-amber-300/60 px-1.5 py-0.5 text-[10px] text-amber-500 dark:border-amber-700/50 dark:text-amber-400/70",title:"This review was posted via Limn with your token, so it has no bot activity to show in the bot feed — open it on GitHub instead.",children:"via Limn"}):t.jsx("button",{type:"button",onClick:()=>a(e),"aria-pressed":i,className:"rounded border border-amber-400 px-1.5 py-0.5 text-[10px] font-medium text-amber-700 hover:bg-amber-100 dark:border-amber-600/70 dark:text-amber-300 dark:hover:bg-amber-900/30",title:"Return to the Bots console with this PR isolated in the bot feed (bypasses the feed window)",children:"Show in feed"})})]})}function wG(){const e=G(E=>E.botAnalyticsWindow),n=G(E=>E.setBotAnalyticsWindow),r=G(E=>E.workspaceId),s=G(E=>E.botOnlyFocusRepoId),a=f.useMemo(()=>s!=null?[s]:null,[s]),{data:i,isLoading:c,isError:d,refetch:u,isFetching:m}=ID(r,e,!0,a),h=f.useMemo(()=>(i==null?void 0:i.prs)??[],[i]),{data:g}=An(),x=f.useMemo(()=>Rn(g),[g]),y=Ge(E=>E.openPrDetailTab),b=Ge(E=>E.showActivity),w=G(E=>E.setRepoConsoleTab),k=G(E=>E.setActivityRepo),j=G(E=>E.setFeedIsolatedPrId),N=G(E=>E.feedIsolatedPrId),I=s==null,S=f.useMemo(()=>{const E=new Map;for(const ee of h)E.has(ee.repoId)||E.set(ee.repoId,ee.repoFullName);return[...E.entries()].sort((ee,K)=>ee[1].localeCompare(K[1]))},[h]),[T,$]=f.useState("all"),P=T!=="all"&&S.some(([E])=>E===T)?T:"all",C=I&&P==="all",[L,F]=f.useState({col:"updated",dir:"desc"}),M=E=>F(ee=>wy(ee,E,vG)),[D,A]=f.useState(!1),W=f.useMemo(()=>P==="all"?h:h.filter(E=>E.repoId===P),[h,P]),z=f.useMemo(()=>W.filter(E=>E.state==="open").length,[W]),te=f.useMemo(()=>W.filter(E=>E.state==="merged").length,[W]),H=f.useMemo(()=>{const E=D?W:W.filter(K=>K.state==="open");if(L==null)return E;const ee=L.dir==="asc"?1:-1;return[...E].sort((K,U)=>ee*ky(zj(K,L.col,x),zj(U,L.col,x))||U.number-K.number)},[W,D,L,x]),B=E=>{const ee=E.authorId!=null?x.get(E.authorId):void 0,K={id:E.prId,number:E.number,title:E.title,repoFullName:E.repoFullName,authorLogin:(ee==null?void 0:ee.githubLogin)??null,authorDisplayName:(ee==null?void 0:ee.displayName)??null,authorAvatarUrl:(ee==null?void 0:ee.avatarUrl)??null};y(K,{fromActivity:!0})},O=E=>{s!=null?(w(s,"bots"),k(s)):k("bots"),j(E.prId),b()};return t.jsxs("div",{className:"mx-auto max-w-[100rem] space-y-4 p-4",children:[t.jsxs("div",{className:"flex flex-wrap items-baseline gap-2",children:[t.jsx("h2",{className:"text-base font-semibold text-gray-800 dark:text-gray-100",children:"Bot-only PRs"}),t.jsxs("span",{className:"text-[11px] text-gray-400",children:["only a bot reviewed these — no human review or comment."," ",t.jsx("span",{className:"text-amber-600 dark:text-amber-400",children:D?`${z} open · ${te} merged`:`${z} open`})," ","· click a column to sort · click a row to open it"]}),I&&S.length>1&&t.jsxs("select",{value:P,onChange:E=>$(E.target.value==="all"?"all":Number(E.target.value)),className:"rounded border border-gray-300 bg-white px-1.5 py-0.5 text-[11px] dark:border-gray-700 dark:bg-gray-900",title:"Filter by repo",children:[t.jsxs("option",{value:"all",children:["All repos (",S.length,")"]}),S.map(([E,ee])=>t.jsx("option",{value:E,children:ee},E))]}),t.jsxs("label",{className:"flex items-center gap-1 text-[11px] text-gray-500 dark:text-gray-400",title:"Also show bot-only PRs that already merged in this window — open PRs are the actionable set",children:[t.jsx("input",{type:"checkbox",checked:D,onChange:E=>A(E.target.checked),className:"h-3.5 w-3.5 cursor-pointer accent-ai-signal"}),"Show merged",te>0?` (${te})`:""]}),t.jsx("div",{className:"ml-auto inline-flex overflow-hidden rounded border border-gray-300 dark:border-gray-700",children:bG.map(E=>t.jsx("button",{type:"button",onClick:()=>n(E.key),className:`px-2 py-0.5 text-[11px] font-medium ${e===E.key?"bg-ai-signal/15 text-ai-signal":"text-gray-500 hover:bg-gray-100 dark:text-gray-400 dark:hover:bg-gray-800"}`,children:E.label},E.key))}),t.jsxs("button",{type:"button",onClick:()=>void u(),disabled:m,className:"rounded border border-gray-300 px-1.5 py-0.5 text-[11px] font-medium hover:border-gray-400 disabled:opacity-50 dark:border-gray-700 dark:hover:border-gray-500",children:[t.jsx(us,{size:11,className:`inline-block align-[-0.1em] ${m?"animate-spin":""}`})," ","Refresh"]})]}),c?t.jsx("div",{className:"space-y-2",children:[0,1,2,3].map(E=>t.jsx("div",{className:"h-8 animate-pulse rounded bg-gray-100 dark:bg-gray-900/40"},E))}):d?t.jsx("div",{className:"text-sm text-red-500",children:"Couldn’t load the PR list."}):H.length===0?t.jsx("div",{className:"rounded-lg border border-dashed border-gray-300 p-6 text-center text-sm text-gray-400 dark:border-gray-700",children:!D&&te>0?`No open bot-only PRs — ${te} merged in this window. Tick “Show merged” to see them.`:t.jsxs(t.Fragment,{children:[t.jsx(Vo,{className:"mr-1.5 inline-block align-[-0.1em] opacity-70"}),"No bot-only PRs in this window."]})}):t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"w-full min-w-[760px] border-collapse text-sm",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"text-left text-[10px] font-semibold uppercase tracking-wide text-gray-400",children:[t.jsx(Nn,{col:"pr",label:"Pull request",sort:L,onSort:M}),C&&t.jsx(Nn,{col:"repo",label:"Repo",sort:L,onSort:M}),t.jsx(Nn,{col:"bot",label:"Bot",sort:L,onSort:M}),t.jsx(Nn,{col:"state",label:"State",sort:L,onSort:M}),t.jsx(Nn,{col:"author",label:"Author",sort:L,onSort:M}),t.jsx(Nn,{col:"age",label:"Age",sort:L,onSort:M,title:"Time since the PR opened"}),t.jsx(Nn,{col:"updated",label:"Updated",sort:L,onSort:M}),t.jsx("th",{className:"pb-1 pr-3 font-semibold",children:"Link"}),t.jsx("th",{className:"pb-1 font-semibold","aria-label":"Feed action"})]})}),t.jsx("tbody",{children:H.map(E=>t.jsx(kG,{pr:E,usersById:x,showRepo:C,onOpen:B,onShowInFeed:O,isolated:N===E.prId},E.prId))})]})})]})}function pc(e,n){const r=n.kind==="bot-flagging",s=n.kind==="person"||n.kind==="person_report",a=r?n.select??"findings":null,i=n.kind==="bot-threads"||n.kind==="brief"||n.kind==="rollup"||s,c=n.kind==="brief"||n.kind==="rollup"||s;return[n.kind,i?"w:-":`w:${n.window}`,dt(e),c?"r:-":Vr(n.repoIds??null),n.botUserId!=null&&(r||n.kind==="bot-volume")?`bot:${n.botUserId}`:"bot:-",`dir:${(r?n.direction:null)??"-"}`,`sel:${a??"-"}`,`sev:${a==="severity"&&n.severities?[...n.severities].sort().join(","):"-"}`,`cat:${(a==="category"?n.category:null)??"-"}`,`u:${(s?n.userId:null)??"-"}`,`pw:${s&&n.fromMs!=null&&n.toMs!=null?`${n.fromMs}-${n.toMs}`:"-"}`]}function BR(e,n){return{kind:n.kind,window:n.window,workspaceId:e,repoIds:n.repoIds??null,botUserId:n.botUserId??null,direction:n.direction??null,select:n.select??null,severities:n.severities??null,category:n.category??null,userId:n.userId??null,fromMs:n.fromMs??null,toMs:n.toMs??null}}function mc(e,n,r=!0){const{activityDigest:s}=vt();return Oe({queryKey:["synthesis",...pc(e,n)],queryFn:e==null?Ct:()=>he.synthesis(BR(e,n)),enabled:r&&s,staleTime:6e4})}function Iy(e,n){const r=He(),s=pc(e,n);return tt({mutationKey:["synthesis-generate",...s],mutationFn:()=>{if(e==null)throw new Error("No workspace selected");return he.synthesisGenerate(BR(e,n))},onSuccess:a=>{r.setQueryData(["synthesis",...s],a),r.invalidateQueries({queryKey:["ai-usage"]})}})}function Ty(e,n){return Or({mutationKey:["synthesis-generate",...pc(e,n)]})>0}function jG(e,n,r){var h;const{activityDigest:s}=vt(),a=r&&s,{data:i}=mc(e,n,a),c=Iy(e,n),d=Ty(e,n),u=f.useRef(null),m=a&&(i==null?void 0:i.enabled)===!0&&(i.synthesis==null||i.stale===!0);return f.useEffect(()=>{var x;if(!m||d||e==null)return;const g=`${e}|${n.kind}|${n.userId??"-"}|${n.fromMs??"-"}|${n.toMs??"-"}|${((x=i==null?void 0:i.synthesis)==null?void 0:x.generatedAt)??"-"}`;u.current!==g&&(u.current=g,c.mutate())},[m,d,e,n.kind,n.userId,n.fromMs,n.toMs,(h=i==null?void 0:i.synthesis)==null?void 0:h.generatedAt]),(i==null?void 0:i.synthesis)??null}function NG({synthesis:e}){return t.jsxs("div",{className:"mt-2 space-y-1",children:[e.clusters.map((n,r)=>t.jsxs("div",{className:"flex items-baseline gap-2 text-[12px]",children:[t.jsx("span",{className:"shrink-0 tabular-nums font-semibold text-gray-800 dark:text-gray-100",children:n.count.toLocaleString()}),t.jsx("span",{className:"min-w-0 flex-1 text-gray-700 dark:text-gray-200",children:n.label}),n.configFixable&&t.jsx("span",{className:"shrink-0 rounded bg-amber-500/10 px-1 py-0.5 text-[10px] font-medium text-amber-600 dark:text-amber-400",title:"This whole cluster looks addressable from the bot's own configuration — see the Advisor for an evidence-backed change. A hint, never an action.",children:"config-fixable"})]},`${r}-${n.label}`)),e.remainderCount>0&&t.jsxs("div",{className:"flex items-baseline gap-2 text-[12px] text-gray-400",children:[t.jsx("span",{className:"shrink-0 tabular-nums",children:e.remainderCount.toLocaleString()}),t.jsx("span",{children:"more without a recurring pattern"})]})]})}function SG({synthesis:e}){return t.jsxs("div",{className:"mt-2 border-t border-ai-hairline pt-1.5 text-[10px] text-gray-400",children:["Summarised ",e.analyzedCount.toLocaleString()," of"," ",e.totalCount.toLocaleString()," item",e.totalCount===1?"":"s",e.truncated?" (the newest — items beyond the cap were not analysed)":"",". Generated ",new Date(e.generatedAt).toLocaleString(),"."]})}function $y({workspaceId:e,descriptor:n,title:r="What this adds up to",className:s,children:a}){var w,k,j,N,I,S;const{activityDigest:i}=vt(),c=((w=In().data)==null?void 0:w.deploymentMode)==="cloud",d=mc(e,n,i),u=Iy(e,n),m=Ty(e,n),h=ei(i),g=((k=h.data)==null?void 0:k.summaryTurnLimit)!=null&&(h.data.summaryTurnsRemaining??0)<=0;if(!i)return c?t.jsxs(t.Fragment,{children:[t.jsxs("p",{className:"mb-2 text-[10px] text-gray-400",children:[t.jsx("span",{className:"mr-1 rounded bg-ai-signal/15 px-1 text-[10px] font-semibold text-ai-signal",children:"Pro"}),"Summaries of what this list adds up to are part of Pro — upgrade to get a clustered verdict above the receipts."]}),a]}):a==null?null:t.jsx(t.Fragment,{children:a});const x=d.data,y=x!=null&&x.enabled?x.synthesis??null:null;if(d.isError||x!=null&&!x.enabled)return a==null?null:t.jsx(t.Fragment,{children:a});const b=(j=u.data)!=null&&j.throttled?"A summary is already generating — showing the latest shortly.":(N=u.data)!=null&&N.creditsExhausted?"Out of AI credits this month — the summary resumes on the 1st.":(I=u.data)!=null&&I.empty?"Nothing to summarise in this scope yet.":null;return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:`rounded-lg border border-ai-border bg-ai-surface p-3 ${s??""}`,"data-testid":"synthesis-card",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("span",{className:"text-sm font-semibold text-gray-800 dark:text-gray-100",children:r}),t.jsx("span",{className:"shrink-0 rounded bg-ai-signal/10 px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-ai-signal",children:"Pro"}),y&&(x==null?void 0:x.stale)&&t.jsx("span",{className:"shrink-0 rounded bg-amber-500/10 px-1.5 py-0.5 text-[10px] font-medium text-amber-600 dark:text-amber-400",title:"The items below have changed since this summary was generated — the counts still describe the set it was computed over.",children:"stale"}),t.jsx("button",{type:"button",onClick:()=>u.mutate(),disabled:m||g||e==null,className:"ml-auto rounded bg-ai-signal px-2.5 py-0.5 text-[11px] font-semibold text-white hover:opacity-90 disabled:opacity-50 dark:text-gray-950",title:g?"Out of AI credits — resets next month":"Group this list into recurring clusters (runs the Haiku model; unchanged items cost nothing)",children:m?"Summarising…":y?t.jsxs("span",{className:"inline-flex items-center gap-1",children:[t.jsx(us,{size:11}),"Regenerate"]}):"Summarise"})]}),u.isError&&t.jsx("div",{className:"mt-1.5 text-[11px] text-red-500",children:((S=u.error)==null?void 0:S.message)??"Couldn’t generate the summary."}),!u.isError&&b&&t.jsx("div",{className:"mt-1.5 text-[11px] text-gray-400",children:b}),g&&t.jsx("div",{className:"mt-1.5 text-[11px] text-amber-600 dark:text-amber-400",children:"Out of AI credits this month — any existing summary still shows."}),y?t.jsxs("div",{className:"digest-fade-in",children:[t.jsx(NG,{synthesis:y}),t.jsx(SG,{synthesis:y})]},y.generatedAt):m?t.jsx("div",{className:"mt-2 h-12 animate-pulse rounded bg-ai-surface-2"}):t.jsx("p",{className:"mt-1 text-[11px] text-gray-400",children:"No summary yet — Summarise groups this list into recurring clusters, with every count computed from the items themselves."})]}),a]})}const Qu=50,CG={kind:"bot-threads",window:"rolling_30"},RG={pr:"desc",repo:"asc",author:"asc",age:"asc",updated:"desc",ci:"asc",resolvable:"desc",confidence:"desc"};function IG(e){return e.high*3+e.medium*2+e.low}function TG({counts:e}){const r=["high","medium","low"].filter(s=>e[s]>0);return r.length===0?t.jsx("span",{className:"text-[11px] text-gray-400",children:"—"}):t.jsx("span",{className:"inline-flex items-center gap-1",children:r.map(s=>{const a=wp[s];return t.jsxs("span",{title:`${e[s]} ${a.label}-confidence thread${e[s]===1?"":"s"} — ${a.description}`,className:"inline-flex items-center gap-0.5 rounded px-1.5 py-px text-[10px] font-semibold tabular-nums",style:{...pn(a.color),background:`${a.color}1f`},children:[e[s],t.jsx("span",{className:"tracking-wide",children:a.label[0]})]},s)})})}const $G={failure:0,error:0,pending:1,success:2,expected:3,unknown:4};function Kj(e,n,r){switch(n){case"pr":return e.prNumber;case"repo":return e.repoFullName.toLowerCase();case"author":{const s=e.authorId!=null?r.get(e.authorId):void 0;return((s==null?void 0:s.githubLogin)??Dt(s,e.authorId)).toLowerCase()}case"age":return e.openedAt;case"updated":return e.updatedAt;case"ci":return $G[e.ciStatus];case"resolvable":return e.resolvableCount;case"confidence":return IG(e.confidenceCounts)}}function _G(){var Ce,_e;const e=G(pe=>pe.workspaceId),n=G(pe=>pe.botThreadsFocusRepoId),r=f.useMemo(()=>n!=null?[n]:null,[n]),{data:s,isLoading:a,isError:i,refetch:c,isFetching:d}=mC(e,!0,r),u=MD(),m=G(pe=>pe.openPrThreadsFiltered),{data:h}=An(),g=f.useMemo(()=>Rn(h),[h]),x=f.useMemo(()=>(s==null?void 0:s.prs)??[],[s]),y=(s==null?void 0:s.totalThreads)??0,[b,w]=f.useState(!1),[k,j]=f.useState(!1),[N,I]=f.useState(new Set),[S,T]=f.useState(null),$=f.useRef(!1),P=n==null,C=f.useMemo(()=>{const pe=new Map;for(const Qe of x)pe.has(Qe.repoId)||pe.set(Qe.repoId,Qe.repoFullName);return[...pe.entries()].sort((Qe,ct)=>Qe[1].localeCompare(ct[1]))},[x]),[L,F]=f.useState("all"),M=L!=="all"&&C.some(([pe])=>pe===L)?L:"all",D=P&&M==="all",A=f.useMemo(()=>M!=="all"||k?null:{kind:"bot-threads",window:"rolling_30",repoIds:r},[M,k,r]),W=mc(e,A??CG,A!=null),z=A!=null&&((Ce=W.data)==null?void 0:Ce.enabled)===!0&&W.data.synthesis!=null,[te,H]=f.useState(!1),B=A==null?null:pc(e,A).join("|");f.useEffect(()=>{H(!1)},[B]);const O=z&&!te,[E,ee]=f.useState({col:"updated",dir:"desc"}),K=pe=>ee(Qe=>wy(Qe,pe,RG)),[U,Q]=f.useState(0),J=f.useMemo(()=>{const pe=M==="all"?x:x.filter(Qe=>Qe.repoId===M);return k?pe.filter(Qe=>Qe.highConfidenceThreadIds.length>0):pe},[x,M,k]),ne=f.useMemo(()=>{if(E==null)return J;const pe=E.dir==="asc"?1:-1;return[...J].sort((Qe,ct)=>pe*ky(Kj(Qe,E.col,g),Kj(ct,E.col,g))||ct.prNumber-Qe.prNumber)},[J,E,g]),ae=Math.max(1,Math.ceil(ne.length/Qu)),we=Math.min(U,ae-1),$e=ne.slice(we*Qu,we*Qu+Qu),Fe=f.useMemo(()=>J.filter(pe=>N.has(pe.prId)),[J,N]),oe=f.useMemo(()=>Fe.flatMap(pe=>k?pe.highConfidenceThreadIds:pe.threadIds),[Fe,k]),re=f.useMemo(()=>Fe.map(pe=>pe.prId),[Fe]),X=f.useMemo(()=>J.reduce((pe,Qe)=>pe+Qe.highConfidenceThreadIds.length,0),[J]),le=k?X:y,Ne=pe=>I(Qe=>{const ct=new Set(Qe);return ct.has(pe)?ct.delete(pe):ct.add(pe),ct}),Ve=()=>I(new Set(J.map(pe=>pe.prId))),me=()=>I(new Set),be=J.length>0&&J.every(pe=>N.has(pe.prId)),at=pe=>{const Qe=pe.authorId!=null?g.get(pe.authorId):void 0,ct={id:pe.prId,number:pe.prNumber,title:pe.prTitle,repoFullName:pe.repoFullName,authorLogin:(Qe==null?void 0:Qe.githubLogin)??null,authorDisplayName:(Qe==null?void 0:Qe.displayName)??null,authorAvatarUrl:(Qe==null?void 0:Qe.avatarUrl)??null};m(ct,"likely_addressed")},ft=()=>{oe.length!==0&&e!=null&&($.current=!1,T({done:0,total:oe.length,resolved:0,failed:0}),u.mutate({threadIds:oe,workspaceId:e,prIds:re,onProgress:(pe,Qe,ct,Bt)=>T({done:pe,total:Qe,resolved:ct,failed:Bt}),shouldStop:()=>$.current},{onSettled:()=>w(!1)}))},mt=t.jsxs("div",{className:"flex flex-wrap items-baseline gap-2",children:[t.jsxs("h2",{className:"text-base font-semibold text-gray-800 dark:text-gray-100",children:[t.jsx(vx,{size:15,className:"inline-block align-[-0.1em]"})," Resolve bot threads"]}),t.jsx("span",{className:"text-[11px] text-gray-400",children:"PRs with likely-addressed automated-reviewer threads — a later commit touched their file, so they only LOOK resolved. Review, then resolve on GitHub. Click a PR to inspect."}),P&&C.length>1&&t.jsxs("select",{value:M,onChange:pe=>{F(pe.target.value==="all"?"all":Number(pe.target.value)),Q(0)},className:"rounded border border-gray-300 bg-white px-1.5 py-0.5 text-[11px] dark:border-gray-700 dark:bg-gray-900",title:"Filter by repo",children:[t.jsxs("option",{value:"all",children:["All repos (",C.length,")"]}),C.map(([pe,Qe])=>t.jsx("option",{value:pe,children:Qe},pe))]}),t.jsxs("button",{type:"button",onClick:()=>void c(),disabled:d,className:"ml-auto rounded border border-gray-300 px-1.5 py-0.5 text-[11px] font-medium hover:border-gray-400 disabled:opacity-50 dark:border-gray-700 dark:hover:border-gray-500",children:[t.jsx(us,{size:11,className:`inline-block align-[-0.1em] ${d?"animate-spin":""}`})," ","Refresh"]})]}),se=t.jsx(t.Fragment,{children:a?t.jsx("div",{className:"space-y-2",children:[0,1,2,3].map(pe=>t.jsx("div",{className:"h-8 animate-pulse rounded bg-gray-100 dark:bg-gray-900/40"},pe))}):i?t.jsx("div",{className:"text-sm text-red-500",children:"Couldn’t load the resolvable threads."}):x.length===0?t.jsxs("div",{className:"rounded-lg border border-dashed border-gray-300 p-6 text-center text-sm text-gray-400 dark:border-gray-700",children:[t.jsx(Vo,{className:"mr-1.5 inline-block align-[-0.1em] opacity-70"}),"No likely-addressed bot threads to review."]}):O?t.jsxs("button",{type:"button",onClick:()=>H(!0),className:"w-full rounded-lg border border-dashed border-gray-300 px-3 py-2 text-center text-[12px] font-medium text-gray-500 hover:border-gray-400 hover:text-gray-700 dark:border-gray-700 dark:text-gray-400 dark:hover:border-gray-500 dark:hover:text-gray-200",children:["Show the ",y.toLocaleString()," thread",y===1?"":"s"," across"," ",x.length.toLocaleString()," PR",x.length===1?"":"s"," this summary was computed from"]}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-2 rounded-lg border border-gray-200 bg-gray-50/60 px-3 py-2 dark:border-gray-800 dark:bg-gray-900/40",children:[u.isPending&&S?t.jsxs(t.Fragment,{children:[t.jsxs("span",{className:"text-[12px] text-gray-500 dark:text-gray-400 tabular-nums",children:["Resolving… ",S.done,"/",S.total," (",S.resolved," resolved",S.failed>0?`, ${S.failed} failed`:"",")"]}),t.jsx("button",{type:"button",onClick:()=>{$.current=!0},className:"rounded border border-amber-400 px-2 py-1 text-[12px] font-medium text-amber-700 hover:bg-amber-100 dark:border-amber-600 dark:text-amber-300 dark:hover:bg-amber-900/30",title:"Stop after the current batch finishes",children:"Stop"})]}):b?t.jsxs(t.Fragment,{children:[t.jsxs("span",{className:"text-[12px] text-gray-600 dark:text-gray-300",children:["Resolve ",oe.length," likely-addressed thread",oe.length===1?"":"s"," across ",re.length," PR",re.length===1?"":"s"," on GitHub?"]}),t.jsx("button",{type:"button",disabled:u.isPending||oe.length===0,onClick:ft,className:"rounded bg-green-600 px-2.5 py-1 text-[12px] font-medium text-white hover:bg-green-700 disabled:opacity-60",children:"Yes, resolve"}),t.jsx("button",{type:"button",disabled:u.isPending,onClick:()=>w(!1),className:"rounded px-2 py-1 text-[12px] text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300",children:"Cancel"})]}):t.jsxs(t.Fragment,{children:[t.jsxs("button",{type:"button",disabled:oe.length===0,onClick:()=>w(!0),className:"rounded border border-sky-400 px-2.5 py-1 text-[12px] font-medium text-sky-700 hover:bg-sky-100 disabled:opacity-50 dark:border-sky-600 dark:text-sky-200 dark:hover:bg-sky-900/30",title:"These threads only LOOK addressed (a later commit touched their file) — you approve the batch before it resolves on GitHub.",children:["Resolve ",oe.length," thread",oe.length===1?"":"s"," across ",re.length," PR",re.length===1?"":"s"]}),t.jsxs("button",{type:"button",onClick:Ve,disabled:be||J.length===0,className:"rounded border border-gray-300 px-2 py-1 text-[12px] font-medium text-gray-600 hover:border-gray-400 disabled:opacity-50 dark:border-gray-700 dark:text-gray-300",title:"Select every PR in the list (across all pages)",children:["Select all",M==="all"?"":" (repo)"]}),t.jsx("button",{type:"button",onClick:me,disabled:re.length===0,className:"rounded px-2 py-1 text-[12px] text-gray-500 dark:text-gray-400 hover:text-gray-700 disabled:opacity-40 dark:hover:text-gray-300",children:"Clear"}),t.jsxs("label",{className:"flex items-center gap-1 text-[11px] text-gray-500 dark:text-gray-400",title:"Show only PRs with a HIGH-confidence resolvable thread, and resolve just those — GitHub marked the lines outdated AND a later commit touched them, or the bot itself confirmed/resolved it. The safest subset.",children:[t.jsx("input",{type:"checkbox",checked:k,onChange:pe=>j(pe.target.checked),className:"h-3.5 w-3.5 cursor-pointer accent-green-600"}),"High-confidence only",X>0?` (${X})`:""]})]}),t.jsxs("span",{className:"text-[11px] text-gray-400 tabular-nums",children:[re.length," of ",J.length," PR",J.length===1?"":"s"," ","selected · ",le," ",k?"high-confidence ":"","thread",le===1?"":"s"," in backlog"]}),!u.isPending&&u.data&&(u.data.resolved>0||u.data.failed>0||u.data.stopped)&&t.jsxs("span",{className:"text-[11px] text-gray-500 dark:text-gray-400",children:["Resolved ",u.data.resolved,u.data.failed>0&&` · ${u.data.failed} failed`,u.data.stopped&&" · stopped","."]}),u.isError&&t.jsx("span",{className:"text-[11px] text-red-500",children:((_e=u.error)==null?void 0:_e.message)??"Couldn’t resolve."})]}),J.length===0&&t.jsx("div",{className:"rounded-lg border border-dashed border-gray-300 p-6 text-center text-sm text-gray-400 dark:border-gray-700",children:k?"No high-confidence threads here — uncheck “High-confidence only” to see the rest of the backlog.":"No PRs match this filter."}),J.length>0&&t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"w-full min-w-[940px] border-collapse text-sm",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"text-left text-[10px] font-semibold uppercase tracking-wide text-gray-400",children:[t.jsx("th",{className:"pb-1 pr-2",children:t.jsx("input",{type:"checkbox",checked:be,onChange:()=>be?me():Ve(),title:be?"Deselect all":"Select all (across pages)",className:"h-3.5 w-3.5 cursor-pointer accent-sky-500"})}),t.jsx(Nn,{col:"pr",label:"Pull request",sort:E,onSort:K}),D&&t.jsx(Nn,{col:"repo",label:"Repo",sort:E,onSort:K}),t.jsx(Nn,{col:"author",label:"Author",sort:E,onSort:K}),t.jsx(Nn,{col:"age",label:"Age",sort:E,onSort:K,title:"Time since the PR opened"}),t.jsx(Nn,{col:"updated",label:"Updated",sort:E,onSort:K}),t.jsx(Nn,{col:"ci",label:"CI",sort:E,onSort:K}),t.jsx(Nn,{col:"resolvable",label:"Resolvable",sort:E,onSort:K,title:"Likely-addressed bot threads this row resolves"}),t.jsx(Nn,{col:"confidence",label:"Confidence",sort:E,onSort:K,title:"Deterministic addressed-confidence of this PR's resolvable threads (High / Medium / Low)"}),t.jsx("th",{className:"pb-1 font-semibold",children:"Bot threads"})]})}),t.jsx("tbody",{children:$e.map(pe=>{const Qe=N.has(pe.prId),ct=pe.authorId!=null?g.get(pe.authorId):void 0,Bt=Rr[pe.ciStatus];return t.jsxs("tr",{onClick:()=>at(pe),title:"Open this PR's Threads tab (likely-addressed threads)",className:`cursor-pointer border-t border-gray-100 align-top hover:bg-gray-50/70 dark:border-gray-800/60 dark:hover:bg-gray-900/40 ${Qe?"bg-sky-50/60 dark:bg-sky-950/20":""}`,children:[t.jsx("td",{className:"py-1.5 pr-2",onClick:Je=>Je.stopPropagation(),children:t.jsx("input",{type:"checkbox",checked:Qe,onChange:()=>Ne(pe.prId),title:Qe?"Exclude this PR":"Include this PR",className:"h-3.5 w-3.5 cursor-pointer accent-sky-500"})}),t.jsx("td",{className:"max-w-md py-1.5 pr-3",children:t.jsxs("span",{className:"flex items-center gap-1.5",children:[t.jsxs("span",{className:"font-mono text-[11px] text-gray-400",children:["#",pe.prNumber]}),t.jsx("span",{className:"min-w-0 truncate text-sm font-medium text-gray-800 dark:text-gray-100",children:pe.prTitle})]})}),D&&t.jsx("td",{className:"py-1.5 pr-3 text-[11px] text-gray-500 dark:text-gray-400",children:t.jsx("span",{className:"block max-w-[12rem] truncate font-mono",children:pe.repoFullName})}),t.jsx("td",{className:"py-1.5 pr-3",children:t.jsxs("span",{className:"inline-flex items-center gap-1 text-[11px] text-gray-600 dark:text-gray-300",children:[t.jsx(gn,{user:ct,size:14}),t.jsx("span",{className:"max-w-[8rem] truncate",children:Dt(ct,pe.authorId)})]})}),t.jsx("td",{className:"py-1.5 pr-3 text-[11px] text-gray-500 dark:text-gray-400",children:Nt(pe.openedAt)}),t.jsx("td",{className:"py-1.5 pr-3 text-[11px] text-gray-500 dark:text-gray-400",children:Nt(pe.updatedAt)}),t.jsx("td",{className:"py-1.5 pr-3",children:t.jsxs("span",{className:"inline-flex items-center gap-1 whitespace-nowrap text-[11px] text-gray-500 dark:text-gray-400",children:[t.jsx("span",{className:"inline-block h-2 w-2 rounded-full",style:Bt?{background:Bt.color}:{boxShadow:"inset 0 0 0 1px #9ca3af"},"aria-hidden":!0}),(Bt==null?void 0:Bt.label)??"no checks"]})}),t.jsx("td",{className:"py-1.5 pr-3",children:t.jsx("span",{className:"rounded bg-sky-100 px-1.5 py-px text-[11px] font-semibold tabular-nums text-sky-700 dark:bg-sky-900/40 dark:text-sky-300",children:pe.resolvableCount})}),t.jsx("td",{className:"py-1.5 pr-3",children:t.jsx(TG,{counts:pe.confidenceCounts})}),t.jsx("td",{className:"py-1.5",children:t.jsx(Jl,{counts:pe.botThreadCounts})})]},pe.prId)})})]})}),ae>1&&t.jsxs("div",{className:"flex items-center justify-center gap-3 text-[11px] text-gray-500 dark:text-gray-400",children:[t.jsxs("button",{type:"button",onClick:()=>Q(Math.max(0,we-1)),disabled:we===0,className:"inline-flex items-center gap-0.5 rounded border border-gray-300 px-2 py-0.5 font-medium hover:border-gray-400 disabled:opacity-40 dark:border-gray-700",children:[t.jsx(Mt,{dir:"left",size:11}),"Prev"]}),t.jsxs("span",{className:"tabular-nums",children:["Page ",we+1," of ",ae," · ",ne.length," PRs"]}),t.jsxs("button",{type:"button",onClick:()=>Q(Math.min(ae-1,we+1)),disabled:we>=ae-1,className:"inline-flex items-center gap-0.5 rounded border border-gray-300 px-2 py-0.5 font-medium hover:border-gray-400 disabled:opacity-40 dark:border-gray-700",children:["Next",t.jsx(Mt,{dir:"right",size:11})]})]})]})});return t.jsxs("div",{className:"mx-auto max-w-[100rem] space-y-4 p-4",children:[mt,A!=null?t.jsx($y,{workspaceId:e,descriptor:A,children:se}):se]})}function WR(e){const{hasMore:n,isFetchingMore:r,itemCount:s,loadMore:a}=e,i=f.useRef(null),c=f.useRef(!1),d=f.useRef(()=>{});d.current=()=>{n&&!r&&s>0&&a()};const u=n&&s>0;return f.useEffect(()=>{const m=i.current;if(!m)return;const h=new IntersectionObserver(g=>{var x;c.current=((x=g[0])==null?void 0:x.isIntersecting)??!1,c.current&&d.current()},{root:Uf(m),rootMargin:"0px 0px 600px 0px"});return h.observe(m),()=>h.disconnect()},[u]),f.useEffect(()=>{!r&&c.current&&d.current()},[r,s,n]),{sentinelRef:i,showSentinel:u}}const PG=10,EG=20;function AG(e){var w;const{workspaceId:n,repoIds:r,window:s,selector:a,refine:i,enabled:c}=e,{botDepth:d}=vt(),u=a.kind==="overlap"?PG:EG,m=He(),h=f.useMemo(()=>["bot-flagging",x3(a),s,dt(n),Vr(r),y3(i)],[a,s,n,r,i]);f.useState(()=>{m.setQueryData(h,k=>k&&k.pages.length>1?{pages:k.pages.slice(0,1),pageParams:k.pageParams.slice(0,1)}:k)});const g=rc({queryKey:h,initialPageParam:null,queryFn:n==null?Ct:({pageParam:k})=>he.botFlagging({selector:a,refine:i,window:s,workspaceId:n,repoIds:r,limit:u,cursor:k}),getNextPageParam:k=>k.nextCursor??void 0,enabled:c&&d,staleTime:6e4,gcTime:fn,refetchOnMount:!0,placeholderData:k=>k}),x=(w=g.data)==null?void 0:w.pages,y=x==null?void 0:x[0];return{items:f.useMemo(()=>{var j;return!x||x.length===0?a.kind==="overlap"?{kind:"clusters",items:[]}:{kind:"comments",items:[]}:((j=x[0])==null?void 0:j.kind)==="clusters"?{kind:"clusters",items:x.flatMap(N=>N.kind==="clusters"?N.items:[])}:{kind:"comments",items:x.flatMap(N=>N.kind==="comments"?N.items:[])}},[x,a.kind]),total:y==null?void 0:y.total,filteredTotal:y==null?void 0:y.filteredTotal,matrix:y==null?void 0:y.matrix,truncated:(y==null?void 0:y.truncated)??!1,isLoading:g.isLoading,isFetching:g.isFetching,hasMore:g.hasNextPage,fetchMore:()=>void g.fetchNextPage(),isFetchingMore:g.isFetchingNextPage}}function MG(e){return`${e.targetKind}:${e.targetId}`}const LG={review_comment:"inline comment",pr_comment:"PR comment",review:"review summary"},FG=220;function OG({body:e}){const n=f.useRef(null),r=f.useRef(null),[s,a]=f.useState(!1),[i,c]=f.useState(!1);return f.useEffect(()=>{const d=n.current,u=r.current;if(!d||!u)return;const m=()=>{s||c(d.scrollHeight>d.clientHeight+4)};m();const h=new ResizeObserver(m);return h.observe(u),()=>h.disconnect()},[e,s]),t.jsxs("div",{className:"mt-1.5 rounded bg-gray-50 px-2 py-1.5 text-sm dark:bg-gray-900/50",children:[t.jsx("div",{ref:n,className:s?"":"overflow-hidden",style:s?void 0:{maxHeight:FG},children:t.jsx("div",{ref:r,children:t.jsx(gr,{children:e})})}),(i||s)&&t.jsx("button",{type:"button",onClick:()=>a(d=>!d),className:"mt-1 text-[11px] font-medium text-sky-600 hover:underline dark:text-sky-400",children:s?"Show less":"Show more"})]})}function DG({c:e,usersById:n,botColor:r,onOpenPr:s,onOpenThread:a,member:i}){const c=n.get(e.authorUserId),d=r({login:e.authorLogin,kind:e.authorKind}),u=i?Xt[i.derivedState]:e.derivedState?Xt[e.derivedState]:null,m=(i==null?void 0:i.threadIds.length)??0,h=i&&i.addressedConfidence!=="none"?wp[i.addressedConfidence]:null,g=e.threadId??(i==null?void 0:i.threadId)??null,x=mn(e.prUrl),y=i==null,b=y||e.line!=null||u!=null||h!=null;return t.jsxs("article",{className:"rounded-md border border-gray-200 bg-white p-2.5 text-sm dark:border-gray-800 dark:bg-gray-950",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx(gn,{user:c,size:18}),t.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 rounded px-1.5 py-0.5 text-[10px] font-medium",style:{...pn(d),background:`${d}1a`},title:`${e.authorLabel} — an automated reviewer Limn triages`,children:[t.jsx(Lt,{size:10}),e.authorLabel]}),t.jsx("span",{className:"shrink-0 text-[10px] uppercase tracking-wide text-gray-400",children:LG[e.targetKind]}),m>1&&t.jsxs("span",{className:"shrink-0 rounded bg-gray-100 px-1 py-px text-[10px] font-medium text-gray-500 dark:bg-gray-800 dark:text-gray-400",title:`This bot left ${m} separate threads in the same line area — collapsed to one row here, exactly as the overlap count treats them.`,children:["×",m]}),t.jsx("span",{className:"ml-auto shrink-0 text-[11px] text-gray-400",title:Cn(e.createdAt),children:Nt(e.createdAt)})]}),t.jsx("div",{className:"mt-1 flex flex-wrap items-center gap-2",children:e.mlLabel?t.jsx(cc,{label:e.mlLabel,vendorClaim:!0}):t.jsx("span",{className:"text-[10px] text-gray-400 dark:text-gray-500",title:"Not scored yet — the enrichment worker labels bot text on its own pass, which always FOLLOWS the sync that stored it.",children:"not scored"})}),b&&t.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-x-2 gap-y-1 text-[11px]",children:[y&&t.jsxs("button",{type:"button",onClick:()=>s(e),className:"shrink-0 font-medium text-gray-700 hover:text-sky-600 hover:underline dark:text-gray-200",title:`${e.repoFullName} #${e.prNumber} — ${e.prTitle}`,children:[e.repoFullName," #",e.prNumber]}),y&&e.path!=null&&t.jsxs("span",{className:"min-w-0 truncate font-mono text-gray-400",title:e.path,children:[e.path,e.line!=null?`:${e.line}`:""]}),!y&&e.line!=null&&t.jsxs("span",{className:"shrink-0 font-mono text-gray-400",children:["L",e.line]}),u&&t.jsx(Fi,{meta:u}),h&&t.jsx(Fi,{meta:h,prefix:"addressed: "})]}),e.body!=null&&e.body.trim()!==""?t.jsx(OG,{body:e.body}):t.jsx("div",{className:"mt-1 rounded border border-dashed border-gray-300 px-2 py-1.5 text-[11px] text-gray-400 dark:border-gray-700",children:"GitHub no longer returns this comment’s text, so only its scored severity survives. It still counts toward the number above."}),t.jsxs("div",{className:"mt-1.5 flex flex-wrap items-center gap-3 text-[11px]",children:[g!=null&&t.jsx("button",{type:"button",onClick:()=>a(e,g),className:"font-medium text-sky-600 hover:underline dark:text-sky-400",children:"Open thread"}),x!=null&&t.jsxs("a",{href:x,target:"_blank",rel:"noreferrer noopener",className:"inline-flex items-center gap-0.5 font-medium text-sky-600 hover:underline dark:text-sky-400",title:`${e.repoFullName} #${e.prNumber} on GitHub. There is deliberately no per-comment permalink — the comment's REST id isn't stored, so an anchor would 404.`,children:[t.jsx(_t,{size:11}),"PR"]})]})]})}const qR=f.memo(DG,(e,n)=>e.c===n.c&&e.member===n.member&&e.usersById===n.usersById&&e.botColor===n.botColor&&e.onOpenPr===n.onOpenPr&&e.onOpenThread===n.onOpenThread);function BG({member:e,cluster:n,onOpenThread:r}){const s=Xt[e.derivedState],a=e.addressedConfidence!=="none"?wp[e.addressedConfidence]:null;return t.jsx("div",{className:"rounded-md border border-dashed border-gray-200 p-2 text-[11px] dark:border-gray-800",children:t.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[t.jsx("span",{className:"text-gray-400",title:"This thread has no stored comment by its own bot, so there is no body and no author to name here — it still counts toward the overlap.",children:"another bot thread here — no stored comment"}),e.line!=null&&t.jsxs("span",{className:"shrink-0 font-mono text-gray-400",children:["L",e.line]}),e.threadIds.length>1&&t.jsxs("span",{className:"shrink-0 rounded bg-gray-100 px-1 py-px font-medium text-gray-500 dark:bg-gray-800 dark:text-gray-400",children:["×",e.threadIds.length]}),t.jsx(Fi,{meta:s}),a&&t.jsx(Fi,{meta:a,prefix:"addressed: "}),t.jsx("button",{type:"button",onClick:()=>r(n,e.threadId),className:"font-medium text-sky-600 hover:underline dark:text-sky-400",children:"Open thread"})]})})}function WG({cluster:e,usersById:n,botColor:r,onOpenPr:s,onOpenThread:a}){const i=e.path.split("/").pop()??e.path,c=e.lineEnd>e.lineStart?`L${e.lineStart}–${e.lineEnd}`:`L${e.lineStart}`,d=mn(e.prUrl),u=e.members.map(h=>{var g,x;return((x=(g=h.comment)==null?void 0:g.mlLabel)==null?void 0:x.severity)??null}).filter(h=>h!=null),m=new Set(u).size>1;return t.jsxs("section",{className:"rounded-md border border-sky-200 bg-sky-50/60 p-2.5 text-sm dark:border-sky-800 dark:bg-sky-950/30",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 text-xs",children:[t.jsx(Lt,{size:12}),t.jsxs("span",{className:"font-medium text-sky-800 dark:text-sky-200",children:[e.members.length," bots flagged the same lines"]}),t.jsxs("button",{type:"button",onClick:()=>s(e),className:"shrink-0 font-medium text-gray-700 hover:text-sky-600 hover:underline dark:text-gray-200",title:`${e.repoFullName} #${e.prNumber} — ${e.prTitle}`,children:[e.repoFullName," #",e.prNumber]}),t.jsx("span",{className:"min-w-0 truncate font-mono text-gray-500 dark:text-gray-400",title:e.path,children:i}),t.jsx("span",{className:"shrink-0 font-mono text-gray-500 dark:text-gray-400",children:c}),e.threadCount>e.members.length&&t.jsxs("span",{className:"shrink-0 text-gray-400",title:"Threads in this line area across all its bots — more than one bot left several, and each bot is collapsed to a single row below.",children:[e.threadCount," threads"]}),d!=null&&t.jsxs("a",{href:d,target:"_blank",rel:"noreferrer noopener",className:"ml-auto inline-flex shrink-0 items-center gap-0.5 font-medium text-sky-600 hover:underline dark:text-sky-400",children:[t.jsx(_t,{size:11}),"PR"]})]}),t.jsxs("div",{className:"mt-1.5 flex flex-wrap items-center gap-x-2 gap-y-1 text-[11px]",children:[e.members.map((h,g)=>{const x=h.comment,y=x?r({login:x.authorLogin,kind:x.authorKind}):"#94a3b8",b=x!=null&&x.mlLabel?Ht[x.mlLabel.severity]:null;return t.jsxs(f.Fragment,{children:[g>0&&t.jsx("span",{className:"text-gray-400",children:"vs"}),t.jsx("span",{className:"inline-flex items-center gap-1 rounded px-1.5 py-0.5 font-medium",style:{...pn(y),background:`${y}1a`},children:(x==null?void 0:x.authorLabel)??"a bot"}),b?t.jsx("span",{className:"font-semibold",style:{color:b.color},title:b.description,children:b.label}):t.jsx("span",{className:"text-gray-400",title:"Not scored yet.",children:"—"})]},h.threadId)}),m&&t.jsx("span",{className:"rounded bg-amber-100 px-1.5 py-0.5 font-semibold text-amber-700 dark:bg-amber-900/40 dark:text-amber-300",title:"Our model rated these bots' comments at different severities — the same lines read as trivial to one reviewer and substantive to another. This compares OUR ratings of what each bot said, not the bots' own badges (those are on each card below).",children:"rated differently"})]}),t.jsx("div",{className:"mt-2 space-y-2",children:e.members.map(h=>h.comment?t.jsx(qR,{c:h.comment,member:h,usersById:n,botColor:r,onOpenPr:s,onOpenThread:a},h.threadId):t.jsx(BG,{member:h,cluster:e,onOpenThread:a},h.threadId))})]})}const qG=f.memo(WG,(e,n)=>e.cluster===n.cluster&&e.usersById===n.usersById&&e.botColor===n.botColor&&e.onOpenPr===n.onOpenPr&&e.onOpenThread===n.onOpenThread),UG=["critical","major","minor","nit","none"],Gj=hp,Vj="#94a3b8";function Qj(e,n){const r=Math.round(Math.max(0,Math.min(1,n))*255).toString(16).padStart(2,"0");return`${e}${r}`}function HG(e,n,r){return e!=null&&e.vendor===n&&e.ours===r}function zG({matrix:e,cell:n,onSelectCell:r}){if(!e||e.total===0)return null;if(e.declared===0)return t.jsxs("div",{className:"rounded-lg border border-gray-200 p-3 text-xs text-gray-500 dark:border-gray-800 dark:text-gray-400",children:["None of the ",e.total.toLocaleString()," scored comments here carry a severity badge from the bot itself, so there is nothing to compare our ratings against."," ",t.jsx("span",{className:"font-semibold",children:"Severity only."})," Vendors declare no machine-readable category, so category is our model’s alone and cannot be compared."]});let s=0,a=null;for(const c of e.cells)c.vendor!=="none"&&(c.count>s&&(s=c.count),!(c.vendor===c.ours||c.count===0)&&(!a||c.count>a.count)&&(a={vendor:c.vendor,ours:c.ours,count:c.count}));const i=c=>`${Math.round(c/e.declared*100)}%`;return t.jsxs("div",{className:"rounded-lg border border-gray-200 p-3 dark:border-gray-800",children:[t.jsxs("div",{className:"mb-2 flex flex-wrap items-baseline gap-2",children:[t.jsx("h3",{className:"text-sm font-semibold",children:"Our severity vs the bot’s own badge"}),t.jsx("span",{className:"text-[11px] text-gray-400",title:"A comparison, not a correction. Our rating agrees with human adjudication on 70% of a held-out sample against the bot badge's 47% — nothing here changes our severity, and there is no disagreement to 'resolve'.",children:"click a cell to narrow the list · advisory"})]}),t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"min-w-[26rem] border-collapse",children:[t.jsx("thead",{children:t.jsxs("tr",{children:[t.jsxs("th",{className:"px-2 py-1 text-left align-bottom text-[10px] font-medium leading-tight text-gray-400",children:[t.jsx("div",{children:"we scored →"}),t.jsx("div",{children:"bot badged ↓"})]}),Gj.map(c=>{const d=Ht[c];return t.jsx("th",{scope:"col",className:"px-3 py-1 text-center text-[11px] font-semibold",style:pn(d.color),title:`We scored these ${d.label}. ${d.description}`,children:d.label},c)})]})}),t.jsx("tbody",{children:UG.map(c=>{const d=c==="none",u=d?null:Ht[c];return t.jsxs("tr",{className:"border-t border-gray-100 dark:border-gray-900",children:[t.jsx("th",{scope:"row",className:`px-2 py-1 text-left text-[11px] font-semibold${d?" text-gray-400":""}`,style:u?pn(u.color):void 0,title:u?`The bot badged these ${u.label} itself.`:"The bot posted no severity badge of its own on these — the common case, and not a disagreement.",children:u?u.label:"no badge"}),Gj.map(m=>{const h=m3(e,c,m),g=HG(n,c,m),x=c===m,y=!d&&!x&&Tl[c]>Tl[m],b=d||x?null:Ht[Tl[c]>=Tl[m]?c:m].color,w=s>0?h/s:0,k=d?Qj(Vj,.06):Qj(b??Vj,.08+.42*w),j=h===0?`Nothing here: no comment we scored ${Ht[m].label} ${d?"is missing a badge from the bot":`carries a ${u==null?void 0:u.label} badge from the bot`}.`:(d?`The bot declared no severity of its own on ${h.toLocaleString()} comment${h===1?"":"s"} we scored ${Ht[m].label}. Not a disagreement — most bots badge nothing.`:x?`The bot and our model both rated ${h.toLocaleString()} comment${h===1?"":"s"} ${Ht[m].label}. Agreement is not a score — it doesn’t make either rating right.`:`The bot badged ${h.toLocaleString()} comment${h===1?"":"s"} ${u==null?void 0:u.label} where we scored ${Ht[m].label} — the bot called ${h===1?"this":"these"} ${y?"worse":"milder"} than we did. ${i(h)} of the badged rows here.`)+(g?" Click again to clear the filter.":" Click to show only these.");return t.jsx("td",{className:"p-0.5",children:t.jsx("button",{type:"button",onClick:()=>r(g?null:{vendor:c,ours:m}),"aria-pressed":g,disabled:h===0&&!g,title:j,className:`w-full rounded px-3 py-2 text-center text-[13px] tabular-nums transition-colors disabled:cursor-default ${g?"ring-2 ring-sky-500 ring-offset-1 ring-offset-white dark:ring-offset-gray-950":h>0?"hover:ring-1 hover:ring-gray-400":""} ${h===0?"text-gray-500 dark:text-gray-400":"font-medium text-gray-800 dark:text-gray-100"}`,style:h===0?void 0:{backgroundColor:k,fontWeight:s>0&&h===s?700:void 0},children:h===0?"—":h.toLocaleString()})},m)})]},c)})})]})}),t.jsxs("div",{className:"mt-2 text-[11px] text-gray-500 dark:text-gray-400",children:["Upper right: the bot called it ",t.jsx("span",{className:"font-medium",children:"worse"})," than we did. Lower left: ",t.jsx("span",{className:"font-medium",children:"milder"}),". The diagonal is agreement."]}),t.jsxs("div",{className:"mt-1 text-[11px] text-gray-500 tabular-nums dark:text-gray-400",children:["Of the ",e.declared.toLocaleString()," badged: ",e.agree.toLocaleString()," agree ·"," ",e.overCall.toLocaleString()," the bot called worse ·"," ",e.underCall.toLocaleString()," milder"]}),a&&t.jsxs("div",{className:"mt-1 text-[11px] text-gray-500 dark:text-gray-400",children:["Most common disagreement: the bot badged"," ",t.jsx("span",{className:"font-semibold tabular-nums",children:a.count.toLocaleString()})," ","of these"," ",t.jsx("span",{className:"font-semibold",style:{color:Ht[a.vendor].color},children:Ht[a.vendor].label})," ","where we scored them"," ",t.jsx("span",{className:"font-semibold",style:{color:Ht[a.ours].color},children:Ht[a.ours].label})," ","(",i(a.count)," of the badged rows)."]}),t.jsxs("div",{className:"mt-1 text-[11px] text-gray-400 tabular-nums",children:[e.declared.toLocaleString()," of ",e.total.toLocaleString()," rows carry a badge from the bot; the rest (",e.undeclared.toLocaleString(),") declared nothing."]}),t.jsxs("div",{className:"mt-1 text-[11px] text-gray-400",children:[t.jsx("span",{className:"font-semibold",children:"Severity only."})," Vendors declare no machine-readable category, so category is our model’s alone and cannot be compared."]})]})}const KG=[{key:"rolling_7",label:"7d"},{key:"rolling_14",label:"14d"},{key:"rolling_30",label:"30d"},{key:"sprint",label:"Sprint"}],GG={kind:"findings"},VG={kind:"bot-flagging",window:"rolling_30"},I0=[null,"any","over","under"],Yj={any:{label:"Disagreements only",title:"Only rows where the bot’s OWN severity badge differs from ours, in either direction. A row the bot left unbadged is NOT a disagreement — silence is not a claim — so those are excluded."},over:{label:"Bot called it worse",title:"Only rows the bot badged MORE severe than our model rated them (the grid’s upper-right triangle) — the shape of an over-eager reviewer."},under:{label:"Bot called it milder",title:"Only rows the bot badged LESS severe than our model rated them (the grid’s lower-left triangle) — the ones a nit-filter would silently drop."}};function QG(){return t.jsx("div",{className:"space-y-2",children:[0,1,2,3].map(e=>t.jsx("div",{className:"h-16 animate-pulse rounded bg-gray-100 dark:bg-gray-900/40"},e))})}function YG({workspaceId:e,repoIds:n,window:r,selector:s,onPick:a}){const i=b3(s)?"severity":v3(s)?"topic":null,{data:c}=Qp(e,r,i!=null,n),d=c==null?void 0:c.ml,u=f.useMemo(()=>{const h=(b,w)=>{const{title:k}=Kx(b);return w==null?k:`${k} · ${w.toLocaleString()}`},g=new Map(((d==null?void 0:d.byCategory)??[]).map(b=>[b.category,b.count])),x=ww.map(b=>{const w=jw(b),k=d==null?null:b==="high"?d.bySeverity.major+d.bySeverity.critical:b==="praise"?d.praise:d.bySeverity[b];return{value:b,label:h(w,k)}}),y=Nw.map(b=>({value:b,label:h({kind:"category",category:b},d==null?null:g.get(b)??0)}));return{severity:x,topic:y}},[d]);if(i===null)return null;const m="rounded border border-gray-300 bg-white px-1.5 py-0.5 text-[11px] dark:border-gray-700 dark:bg-gray-900";if(i==="severity"){const h=J5(s);return t.jsx("select",{value:h??"",onChange:g=>{const x=ww.find(y=>y===g.target.value);x&&a(jw(x))},className:m,"aria-label":"Severity",title:"Show a different severity over the same window and scope. The counts are the strip’s own numbers.",children:u.severity.map(g=>t.jsx("option",{value:g.value,children:g.label},g.value))})}return t.jsx("select",{value:s.kind==="category"?s.category:"",onChange:h=>{const g=Nw.find(x=>x===h.target.value);g&&a({kind:"category",category:g})},className:m,"aria-label":"Topic",title:"Show a different topic over the same window and scope. Categories are multi-label, so these counts overlap.",children:u.topic.map(h=>t.jsx("option",{value:h.value,children:h.label},h.value))})}function XG(){var mt;const e=G(se=>se.botFlaggingSeed),n=G(se=>se.workspaceId),r=G(se=>se.botAnalyticsWindow),s=G(se=>se.setBotAnalyticsWindow),a=(e==null?void 0:e.repoId)??null,i=f.useMemo(()=>a!=null?[a]:null,[a]),c=(e==null?void 0:e.selector)??GG,d=G(se=>se.setBotFlaggingSelector),u=(e==null?void 0:e.bots)??null,m=G(se=>se.setBotFlaggingBots),h=G(se=>se.clearBotFlaggingRefine),g=(e==null?void 0:e.disagree)??null,[x,y]=f.useState(null),[b,w]=f.useState(g),k=f.useMemo(()=>({cell:x,disagree:b,authorUserIds:(u==null?void 0:u.userIds)??null}),[x,b,u]),j=f.useMemo(()=>e==null||c.kind==="overlap"||x!=null||u!=null&&u.userIds.length!==1?null:{kind:"bot-flagging",window:r,repoIds:i,botUserId:(u==null?void 0:u.userIds[0])??null,direction:b,select:c.kind,severities:c.kind==="severity"?c.severities:null,category:c.kind==="category"?c.category:null},[e,c,x,u,b,r,i]),N=mc(n,j??VG,j!=null),I=j!=null&&((mt=N.data)==null?void 0:mt.enabled)===!0&&N.data.synthesis!=null,[S,T]=f.useState(!1),$=j==null?null:pc(n,j).join("|");f.useEffect(()=>{T(!1)},[$]);const P=I&&!S;f.useEffect(()=>{y(null),w(g)},[e,g,r,n,i]);const{data:C}=An(),L=f.useMemo(()=>Rn(C),[C]),{data:F}=xn(),M=f.useMemo(()=>{var se;return a==null?null:((se=(F??[]).find(Ce=>Ce.id===a))==null?void 0:se.fullName)??`repo ${a}`},[F,a]),D=co(n),{items:A,total:W,filteredTotal:z,matrix:te,truncated:H,isLoading:B,hasMore:O,fetchMore:E,isFetchingMore:ee}=AG({workspaceId:n,repoIds:i,window:r,selector:c,refine:k,enabled:e!=null}),U=te!=null&&te.declared>0||b!=null,Q=x!=null||b!=null||u!=null,J=f.useCallback(()=>{y(null),w(null),h()},[h]),ne=f.useCallback(()=>{w(se=>I0[(I0.indexOf(se)+1)%I0.length]??null)},[]),ae=f.useCallback(se=>{y(null),w(g),d(se)},[d,g]),we=Ge(se=>se.openPrDetailTab),$e=G(se=>se.selectThread),Fe=f.useCallback(se=>{const Ce=se.prAuthorId!=null?L.get(se.prAuthorId):void 0;return{id:se.prId,number:se.prNumber,title:se.prTitle,repoFullName:se.repoFullName,authorLogin:(Ce==null?void 0:Ce.githubLogin)??null,authorDisplayName:(Ce==null?void 0:Ce.displayName)??null,authorAvatarUrl:(Ce==null?void 0:Ce.avatarUrl)??null}},[L]),oe=f.useCallback(se=>{we(Fe(se),{fromActivity:!0})},[Fe,we]),re=f.useCallback((se,Ce)=>{we(Fe(se),{fromActivity:!0}),$e(se.prId,Ce)},[Fe,we,$e]),X=A.items.length,{sentinelRef:le}=WR({hasMore:O,isFetchingMore:ee,itemCount:X,loadMore:E}),{title:Ne,subtitle:Ve}=Kx(c,u),me=A.kind==="clusters",be=me?"line areas":"comments",at=t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex flex-wrap items-baseline gap-2",children:[t.jsx("h2",{className:"text-base font-semibold text-gray-800 dark:text-gray-100",children:Ne}),t.jsx("span",{className:"text-[11px] text-gray-400",children:"What the bots are flagging"}),M&&t.jsx("span",{className:"rounded bg-gray-100 px-1.5 py-0.5 font-mono text-[10px] text-gray-500 dark:bg-gray-800 dark:text-gray-400",title:"This drill-down was opened from a single repo’s Bots tab, so it measures that repo — the same narrowing the tile you clicked was computed at.",children:M}),t.jsxs("div",{className:"ml-auto flex flex-wrap items-center gap-2",children:[t.jsx(YG,{workspaceId:n,repoIds:i,window:r,selector:c,onPick:ae}),t.jsx("div",{className:"inline-flex overflow-hidden rounded border border-gray-300 dark:border-gray-700",children:KG.map(se=>t.jsx("button",{type:"button",onClick:()=>{y(null),w(g),s(se.key)},className:`px-2 py-0.5 text-[11px] font-medium ${r===se.key?"bg-ai-signal/15 text-ai-signal":"text-gray-500 hover:bg-gray-100 dark:text-gray-400 dark:hover:bg-gray-800"}`,children:se.label},se.key))})]})]}),t.jsx("p",{className:"max-w-4xl text-[11px] text-gray-500 dark:text-gray-400",children:Ve})]}),ft=e==null?t.jsx("div",{className:"rounded-lg border border-dashed border-gray-300 p-6 text-center text-sm text-gray-400 dark:border-gray-700",children:"Open this from a tile on the Bots rail to see what it counted."}):n==null||B?t.jsx(QG,{}):W==null||z==null?t.jsx("div",{className:"rounded-lg border border-dashed border-gray-300 p-6 text-center text-sm text-gray-400 dark:border-gray-700",children:"Couldn’t load what the bots flagged in this window."}):t.jsxs(t.Fragment,{children:[t.jsx(zG,{matrix:te,cell:x,onSelectCell:y}),me&&te!=null&&te.total>0&&t.jsx("p",{className:"text-[11px] text-gray-400",children:"Those counts are the bot comments inside these line areas, not the areas themselves — one overlap contributes a row per bot."}),(U||Q)&&t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[U&&t.jsxs("button",{type:"button",onClick:ne,"aria-pressed":b!=null,title:b?`${Yj[b].title} Click to step to the next direction.`:"Narrow to rows where the bot’s own severity badge contradicts ours. Click again to step through over-calls and under-calls.",className:`flex items-center gap-1 rounded-full border px-2 py-0.5 text-[11px] font-medium transition-colors ${b!=null?"border-amber-400 bg-amber-50 text-amber-700 dark:border-amber-500/60 dark:bg-amber-950/30 dark:text-amber-300":"border-gray-300 text-gray-500 hover:border-gray-400 dark:border-gray-700 dark:text-gray-400"}`,children:[t.jsx(yp,{size:11}),b?Yj[b].label:"Disagreements only"]}),x&&t.jsxs("span",{className:"rounded-full border border-sky-400 bg-sky-50 px-2 py-0.5 text-[11px] font-medium text-sky-700 dark:border-sky-500/60 dark:bg-sky-950/30 dark:text-sky-300",title:"One cell of the grid above. Click that cell again to clear it.",children:["bot said ",x.vendor==="none"?"nothing":x.vendor," · we scored"," ",x.ours]}),u&&t.jsxs("button",{type:"button",onClick:()=>m(null),title:`Only ${Ya(u)}${u.label?"’s":"’"} comments — opened from the Behaviour tab’s inflation index. Click to widen back to every bot, keeping this window, scope and direction.`,className:"flex items-center gap-1 rounded-full border border-ai-signal/50 bg-ai-signal/10 px-2 py-0.5 text-[11px] font-medium text-ai-signal hover:border-ai-signal",children:[t.jsx(Lt,{size:11}),Ya(u)," only",t.jsx("span",{className:"text-ai-signal/70",children:t.jsx(Zt,{size:10})})]}),Q&&t.jsx("button",{type:"button",onClick:J,className:"rounded px-1.5 py-0.5 text-[11px] text-gray-500 dark:text-gray-400 underline-offset-2 hover:underline",children:"Clear"})]}),H&&t.jsx("div",{className:"rounded border border-gray-300 px-2 py-1 text-[11px] text-gray-500 dark:border-gray-700 dark:text-gray-400",children:"More matched this window than one read covers — the counts and the grid above describe the most recent sample, not the whole window."}),z===0?t.jsx("div",{className:"rounded-lg border border-dashed border-gray-300 p-6 text-center text-sm text-gray-400 dark:border-gray-700",children:Q?t.jsxs(t.Fragment,{children:["None of these ",W.toLocaleString()," ",be," match the filters you’ve applied.",t.jsx("div",{className:"mt-2",children:t.jsx("button",{type:"button",onClick:J,className:"rounded border border-gray-300 px-2 py-0.5 text-[11px] font-medium text-gray-500 hover:border-gray-400 dark:border-gray-700 dark:text-gray-400 dark:hover:border-gray-500",children:"Clear filters"})})]}):t.jsxs(t.Fragment,{children:["Nothing was flagged here in this window.",t.jsx("div",{className:"mt-1 text-[11px]",children:me?"No two review bots landed within a few lines of each other — either only one bot is reviewing, or they’re looking at different things.":"Either the bots said nothing that fits, or their comments haven’t been scored yet — the enrichment pass always FOLLOWS the sync that stored them."})]})}):P?t.jsxs("button",{type:"button",onClick:()=>T(!0),className:"w-full rounded-lg border border-dashed border-gray-300 px-3 py-2 text-center text-[12px] font-medium text-gray-500 hover:border-gray-400 hover:text-gray-700 dark:border-gray-700 dark:text-gray-400 dark:hover:border-gray-500 dark:hover:text-gray-200",children:["Show the ",z.toLocaleString()," ",be," this summary was computed from"]}):t.jsxs(t.Fragment,{children:[A.kind==="clusters"?t.jsx("div",{className:"space-y-3",children:A.items.map(se=>t.jsx(qG,{cluster:se,usersById:L,botColor:D,onOpenPr:oe,onOpenThread:re},se.clusterId))}):t.jsx("div",{className:"space-y-2",children:A.items.map(se=>t.jsx(qR,{c:se,usersById:L,botColor:D,onOpenPr:oe,onOpenThread:re},MG(se)))}),t.jsxs("div",{className:"text-[11px] tabular-nums text-gray-400",title:`The ${W.toLocaleString()} figure is the tile you clicked, recomputed from the same windowed scan and the same fold — not a separate query.`,children:["Showing ",X.toLocaleString()," of ",z.toLocaleString()," ",be,Q&&t.jsxs(t.Fragment,{children:[" · ",z.toLocaleString()," of ",W.toLocaleString()," match these filters"]})]}),O&&t.jsx("div",{ref:le,className:"flex justify-center pt-1",children:ee?t.jsxs("span",{className:"flex items-center gap-2 py-1.5 text-xs text-gray-400",children:[t.jsx("span",{className:"h-3 w-3 animate-spin rounded-full border-2 border-gray-300 border-t-transparent dark:border-gray-600 dark:border-t-transparent"}),"Loading more…"]}):t.jsx("button",{type:"button",onClick:E,className:"rounded-full border border-gray-300 px-4 py-1.5 text-xs font-medium text-gray-600 hover:border-gray-400 hover:bg-gray-50 dark:border-gray-700 dark:text-gray-300 dark:hover:border-gray-500 dark:hover:bg-gray-800/50",children:"Load more"})})]})]});return t.jsxs("div",{className:"mx-auto max-w-[100rem] space-y-4 p-4",children:[at,j!=null?t.jsx($y,{workspaceId:n,descriptor:j,children:ft}):ft]})}const ZG=[{key:"rolling_7",label:"7d"},{key:"rolling_14",label:"14d"},{key:"rolling_30",label:"30d"},{key:"sprint",label:"Sprint"}],JG={kind:"bot-volume",window:"rolling_30"};function eV(){return t.jsx("div",{className:"space-y-2",children:[0,1,2,3].map(e=>t.jsx("div",{className:"h-9 animate-pulse rounded bg-gray-100 dark:bg-gray-900/40"},e))})}function tV({row:e,onOpenPr:n}){const r=mn(e.prUrl),s=P9(e);return t.jsxs("tr",{className:"border-b border-gray-100 last:border-0 dark:border-gray-800/60",children:[t.jsxs("td",{className:"px-2 py-1.5",children:[t.jsxs("div",{className:"flex flex-wrap items-baseline gap-1.5",children:[t.jsx("span",{className:"font-mono text-[10px] text-gray-400",children:e.repoFullName}),r?t.jsxs("a",{href:r,target:"_blank",rel:"noopener noreferrer",className:"font-mono text-[10px] text-gray-500 hover:underline dark:text-gray-400",title:"Open on GitHub",children:["#",e.prNumber]}):t.jsxs("span",{className:"font-mono text-[10px] text-gray-500 dark:text-gray-400",children:["#",e.prNumber]}),t.jsx("button",{type:"button",onClick:()=>n(e),title:"Open this PR",className:"max-w-[46rem] truncate text-left text-gray-700 hover:underline dark:text-gray-200",children:e.prTitle})]}),e.byBot.length>1&&t.jsx("div",{className:"mt-0.5 flex flex-wrap gap-1",children:e.byBot.map(a=>t.jsxs("span",{className:"rounded bg-gray-100 px-1 py-px text-[10px] text-gray-500 dark:bg-gray-800 dark:text-gray-400",children:[a.label," ",t.jsx("span",{className:"tabular-nums",children:a.comments})]},a.key))})]}),t.jsx("td",{className:"px-2 py-1.5 text-right font-semibold tabular-nums text-gray-700 dark:text-gray-200",children:e.botComments.toLocaleString()}),t.jsx("td",{className:"px-2 py-1.5 text-right tabular-nums text-gray-500 dark:text-gray-400",title:e.loc==null?"This PR’s size was never observed — under lean storage that is indistinguishable from an empty PR, so it is left blank rather than shown as 0.":`+${e.additions.toLocaleString()} / −${e.deletions.toLocaleString()}`,children:$9(e.loc)}),t.jsx("td",{className:"px-2 py-1.5 text-right tabular-nums text-gray-500 dark:text-gray-400",children:e.changedFiles==null?"—":e.changedFiles.toLocaleString()}),t.jsxs("td",{className:"px-2 py-1.5 text-right",title:_9(e.baseline,e.baselinePrs),children:[t.jsx("span",{className:`font-medium tabular-nums ${E9(e.ratio)}`,children:I9(e.ratio,e.baseline)}),s&&t.jsxs("div",{className:"text-[10px] tabular-nums text-gray-400",children:[s,e.baseline==="repo"&&" · repo avg, not size-matched",e.baseline==="low_expectation"&&" · too few expected to compare"]})]})]})}function nV(){var B;const e=G(O=>O.botVolumeSeed),n=G(O=>O.workspaceId),r=G(O=>O.botAnalyticsWindow),s=G(O=>O.setBotAnalyticsWindow),a=(e==null?void 0:e.repoId)??null,i=f.useMemo(()=>a!=null?[a]:null,[a]),c=(e==null?void 0:e.bots)??null,d=G(O=>O.setBotVolumeBots),[u,m]=f.useState("comments"),h=f.useMemo(()=>e==null||c!=null&&c.userIds.length!==1?null:{kind:"bot-volume",window:r,repoIds:i,botUserId:(c==null?void 0:c.userIds[0])??null},[e,c,r,i]),g=mc(n,h??JG,h!=null),x=h!=null&&((B=g.data)==null?void 0:B.enabled)===!0&&g.data.synthesis!=null,[y,b]=f.useState(!1),w=h==null?null:pc(n,h).join("|");f.useEffect(()=>{b(!1)},[w]);const k=x&&!y,{data:j}=xn(),N=f.useMemo(()=>{var O;return a==null?null:((O=(j??[]).find(E=>E.id===a))==null?void 0:O.fullName)??`repo ${a}`},[j,a]),{items:I,total:S,filteredTotal:T,truncated:$,isLoading:P,hasMore:C,fetchMore:L,isFetchingMore:F}=F9({workspaceId:n,repoIds:i,window:r,sort:u,authorUserIds:(c==null?void 0:c.userIds)??null,enabled:e!=null}),M=Ge(O=>O.openPrDetailTab),D=f.useCallback(O=>{const E={id:O.prId,number:O.prNumber,title:O.prTitle,repoFullName:O.repoFullName,authorLogin:null,authorDisplayName:null,authorAvatarUrl:null};M(E,{fromActivity:!0})},[M]),A=I.length,{sentinelRef:W}=WR({hasMore:C,isFetchingMore:F,itemCount:A,loadMore:L}),z=v0.find(O=>O.key===u)??v0[0],te=t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex flex-wrap items-baseline gap-2",children:[t.jsx("h2",{className:"text-base font-semibold text-gray-800 dark:text-gray-100",children:"Bot comments per merged PR"}),t.jsx("span",{className:"text-[11px] text-gray-400",children:c?`${Ya(c)}’s comments`:"every bot in this workspace"}),N&&t.jsx("span",{className:"rounded bg-gray-100 px-1.5 py-0.5 font-mono text-[10px] text-gray-500 dark:bg-gray-800 dark:text-gray-400",title:"This drill-down was opened from a single repo’s Bots tab, so it measures that repo — the same narrowing the column you clicked was computed at.",children:N}),t.jsx("div",{className:"ml-auto flex flex-wrap items-center gap-2",children:t.jsx("div",{className:"inline-flex overflow-hidden rounded border border-gray-300 dark:border-gray-700",children:ZG.map(O=>t.jsx("button",{type:"button",onClick:()=>s(O.key),className:`px-2 py-0.5 text-[11px] font-medium ${r===O.key?"bg-ai-signal/15 text-ai-signal":"text-gray-500 hover:bg-gray-100 dark:text-gray-400 dark:hover:bg-gray-800"}`,children:O.label},O.key))})})]}),t.jsxs("p",{className:"max-w-4xl text-[11px] text-gray-500 dark:text-gray-400",children:["Every PR ",t.jsx("span",{className:"font-medium",children:"merged"})," in this window that drew at least one bot comment — inline review comments, PR comments and review bodies alike. Open PRs are not counted."]})]}),H=e==null?t.jsx("div",{className:"rounded-lg border border-dashed border-gray-300 p-6 text-center text-sm text-gray-400 dark:border-gray-700",children:"Open this from the Comments/PR column on the Bots rail to see the PRs behind it."}):n==null||P?t.jsx(eV,{}):S==null||T==null?t.jsx("div",{className:"rounded-lg border border-dashed border-gray-300 p-6 text-center text-sm text-gray-400 dark:border-gray-700",children:"Couldn’t load the merged PRs for this window."}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("div",{className:"inline-flex overflow-hidden rounded border border-gray-300 dark:border-gray-700",children:v0.map(O=>t.jsx("button",{type:"button",onClick:()=>m(O.key),"aria-pressed":u===O.key,title:O.help,className:`px-2 py-0.5 text-[11px] font-medium ${u===O.key?"bg-sky-500/15 text-sky-700 dark:text-sky-300":"text-gray-500 hover:bg-gray-100 dark:text-gray-400 dark:hover:bg-gray-800"}`,children:O.label},O.key))}),c&&t.jsxs("button",{type:"button",onClick:()=>d(null),title:`Only ${Ya(c)}${c.label?"’s":"’"} comments — opened from that bot's cell in the Bots table. Click to widen to every bot, keeping this window and scope.`,className:"flex items-center gap-1 rounded-full border border-ai-signal/50 bg-ai-signal/10 px-2 py-0.5 text-[11px] font-medium text-ai-signal hover:border-ai-signal",children:[t.jsx(Lt,{size:11}),Ya(c)," only",t.jsx("span",{className:"flex items-center text-ai-signal/70",children:t.jsx(Zt,{size:11})})]})]}),t.jsx("p",{className:"max-w-4xl text-[11px] text-gray-500 dark:text-gray-400",children:z==null?void 0:z.help}),$&&t.jsx("div",{className:"rounded border border-gray-300 px-2 py-1 text-[11px] text-gray-500 dark:border-gray-700 dark:text-gray-400",children:"More PRs merged in this window than one read covers — this list and its counts describe the most recent sample, not the whole window."}),T===0?t.jsx("div",{className:"rounded-lg border border-dashed border-gray-300 p-6 text-center text-sm text-gray-400 dark:border-gray-700",children:c?t.jsxs(t.Fragment,{children:[Ya(c)," commented on none of the ",S.toLocaleString()," PR",S===1?"":"s"," merged in this window.",t.jsx("div",{className:"mt-2",children:t.jsx("button",{type:"button",onClick:()=>d(null),className:"rounded border border-gray-300 px-2 py-0.5 text-[11px] font-medium text-gray-500 hover:border-gray-400 dark:border-gray-700 dark:text-gray-400 dark:hover:border-gray-500",children:"Show every bot"})})]}):t.jsxs(t.Fragment,{children:[S===0?"Nothing merged in this window.":`No bot commented on any of the ${S.toLocaleString()} PRs merged in this window.`,t.jsx("div",{className:"mt-1 text-[11px]",children:"Bot comments are counted against the PR they landed on and the window is keyed on the merge, so a quiet window here can simply mean little shipped — try widening it above."})]})}):k?t.jsxs("button",{type:"button",onClick:()=>b(!0),className:"w-full rounded-lg border border-dashed border-gray-300 px-3 py-2 text-center text-[12px] font-medium text-gray-500 hover:border-gray-400 hover:text-gray-700 dark:border-gray-700 dark:text-gray-400 dark:hover:border-gray-500 dark:hover:text-gray-200",children:["Show the ",T.toLocaleString()," merged PR",T===1?"":"s"," ","this summary was computed from"]}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"overflow-x-auto rounded-lg border border-gray-200 dark:border-gray-800",children:t.jsxs("table",{className:"w-full min-w-[720px] border-collapse text-[11px]",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"border-b border-gray-200 text-left text-gray-500 dark:border-gray-800 dark:text-gray-400",children:[t.jsx("th",{className:"px-2 py-1.5 font-medium",children:"PR"}),t.jsx("th",{className:"px-2 py-1.5 text-right font-medium",title:"Every comment the bots left on this PR — inline review comments, PR-level comments and review bodies.",children:"Bot comments"}),t.jsx("th",{className:"px-2 py-1.5 text-right font-medium",title:"Additions + deletions. Blank when the PR's size was never observed — under lean storage that is indistinguishable from an empty PR, so it is never shown as 0.",children:"LOC"}),t.jsx("th",{className:"px-2 py-1.5 text-right font-medium",children:"Files"}),t.jsx("th",{className:"px-2 py-1.5 text-right font-medium",title:"Bot comments divided by what a PR this size usually draws in this repo. Hover a cell for what it was compared against; 'no baseline' means there were too few comparable merged PRs to say.",children:"vs expected"})]})}),t.jsx("tbody",{children:I.map(O=>t.jsx(tV,{row:O,onOpenPr:D},O.prId))})]})}),t.jsxs("div",{className:"text-[11px] tabular-nums text-gray-400",title:"Both totals are the server's, folded from the same scan the Comments/PR column was — not a separate query.",children:["Showing ",A.toLocaleString()," of ",T.toLocaleString()," merged PR",T===1?"":"s"," that drew"," ",c?`${Ya(c)} comments`:"bot comments"," · ",T.toLocaleString()," of ",S.toLocaleString()," merged in this window"]}),C&&t.jsx("div",{ref:W,className:"flex justify-center pt-1",children:F?t.jsxs("span",{className:"flex items-center gap-2 py-1.5 text-xs text-gray-400",children:[t.jsx("span",{className:"h-3 w-3 animate-spin rounded-full border-2 border-gray-300 border-t-transparent dark:border-gray-600 dark:border-t-transparent"}),"Loading more…"]}):t.jsx("button",{type:"button",onClick:L,className:"rounded-full border border-gray-300 px-4 py-1.5 text-xs font-medium text-gray-600 hover:border-gray-400 hover:bg-gray-50 dark:border-gray-700 dark:text-gray-300 dark:hover:border-gray-500 dark:hover:bg-gray-800/50",children:"Load more"})})]})]});return t.jsxs("div",{className:"mx-auto max-w-[100rem] space-y-4 p-4",children:[te,h!=null?t.jsx($y,{workspaceId:n,descriptor:h,children:H}):H]})}function rV(e,n,r,s=!1){return["person-period",dt(e),`u:${n}`,r??"none",`ev:${s?1:0}`]}function UR(e,n,r,s,a=!1){return Oe({queryKey:rV(n,r,s,a),queryFn:n==null||s==null?Ct:()=>he.personPeriod(n,r,s,a),enabled:e&&s!=null,staleTime:6e4,gcTime:fn})}const ji="text-gray-400",sx={merged_prs_authored:"PRs merged (authored)",opened_prs_authored:"PRs opened",reviews_given:"Reviews given",review_comments_written:"Review comments written",median_review_response_hours:"Median review response",median_first_human_review_hours_their_prs:"Their PRs’ wait for a human review",review_threads_on_their_prs:"Threads opened on their PRs",their_pr_threads_addressed:"…of those, addressed",awaiting_their_review:"Waiting on their review",open_prs_authored:"Open PRs (WIP)"},HR={median_review_response_hours:"First review request on a PR → their first review of it, over PRs they first reviewed in this period (only PRs with a recorded request)",median_first_human_review_hours_their_prs:"How long their PRs waited for a first review by a person — the same fold the period report uses, narrowed to their PRs",their_pr_threads_addressed:"Resolved or likely-addressed AS OF NOW — the threads are the period’s, the state is today’s"};function _y(e){return e.value==null?"—":e.key==="median_review_response_hours"||e.key==="median_first_human_review_hours_their_prs"?`${e.value}h`:e.key==="their_pr_threads_addressed"?`${e.value} of ${e.sampleSize}`:String(e.value)}function sV(e){const n=e.split(":");return n.length>=2?n[1]??null:null}function aV({synth:e,person:n}){const r=f.useMemo(()=>{const a=new Map;for(const i of n.metrics)a.set(i.key,i);return a},[n]),s=(e==null?void 0:e.ordering)??[];return s.length===0?null:t.jsx("ul",{className:"mb-2 flex flex-col gap-0.5",children:s.slice(0,4).map(a=>{const i=sV(a.ref),c=i!=null?r.get(i):void 0;return t.jsxs("li",{className:"flex items-baseline gap-2 text-xs",children:[c!=null&&t.jsx("span",{className:"shrink-0 font-semibold tabular-nums text-gray-800 dark:text-gray-100",children:_y(c)}),t.jsx("span",{className:"min-w-0 text-gray-600 dark:text-gray-300",children:a.phrase})]},a.ref)})})}function oV({userId:e}){var j,N,I,S;const{periodReports:n}=vt(),r=uc(n),s=G(T=>T.workspaceId),a=G(T=>T.insightsReportKey),i=Fd(n,s),c=f.useMemo(()=>{var T;return((T=i.data)==null?void 0:T.periods)??[]},[i.data]),[d,u]=f.useState(null),m=f.useMemo(()=>{var $;const T=P=>P!=null&&c.some(C=>C.periodKey===P);return T(d)?d:T(a)?a:(($=c[0])==null?void 0:$.periodKey)??null},[d,a,c]),h=UR(n,s,e,m),g=((j=h.data)==null?void 0:j.person)??null,x=((N=h.data)==null?void 0:N.periodStart)!=null?Date.parse(h.data.periodStart):null,y=((I=h.data)==null?void 0:I.periodEnd)!=null?Date.parse(h.data.periodEnd):null,b=f.useMemo(()=>({kind:"person",window:"rolling_14",userId:e,fromMs:x,toMs:y}),[e,x,y]),w=jG(s,b,g!=null&&x!=null&&y!=null);if(s==null||r==="pending")return null;if(r==="locked")return t.jsx(dc,{heading:"1:1 prep",testId:"person-period-locked",children:"What one person did over a completed period — what they reviewed, what they authored, and how long others waited on them — in the shape of notes for a one-to-one. No rankings, and nobody is compared to anybody. Reports → People builds the same thing for several people or bots at once."});if(((S=i.data)==null?void 0:S.enabled)===!1)return null;const k=c.find(T=>T.periodKey===m)??null;return t.jsxs("section",{"aria-label":"1:1 prep",className:"rounded-lg border border-gray-200 bg-white p-3 text-xs dark:border-gray-800 dark:bg-gray-950",children:[t.jsxs("div",{className:"mb-1.5 flex flex-wrap items-baseline gap-2",children:[t.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wide text-ai-ink",children:"1:1 prep"}),t.jsx(ec,{variant:"heading",title:"The People report is part of Pro."}),t.jsx("span",{className:`text-[11px] ${ji}`,children:"prep for a 1:1, not a scorecard — one person, no rankings"}),c.length>0&&t.jsx("select",{value:m??"",onChange:T=>u(T.target.value||null),className:"ml-auto rounded border border-gray-300 bg-white px-1 py-0.5 text-[11px] dark:border-gray-700 dark:bg-gray-950",title:"The sprint period this vector covers (same cadence as Reports)",children:c.map(T=>t.jsx("option",{value:T.periodKey,children:ro(T.periodStart,T.periodEnd)},T.periodKey))})]}),i.data!=null&&i.data.cadenceConfigured===!1?t.jsx("div",{className:`text-[11px] ${ji}`,children:"1:1 prep covers one sprint period — set a sprint cadence under Reports to unlock it."}):i.isLoading||h.isLoading?t.jsx("div",{className:`py-1 text-[11px] ${ji}`,children:"Loading period figures…"}):c.length===0?t.jsx("div",{className:`text-[11px] ${ji}`,children:"No completed periods yet — the first appears once a sprint boundary has passed."}):g==null?t.jsxs("div",{className:`text-[11px] ${ji}`,children:["Nothing to prep — no activity from them in this Workspace",k?" ":"",k?`(period ${ro(k.periodStart,k.periodEnd)})`:"","."]}):t.jsxs(t.Fragment,{children:[!g.coverage.complete&&t.jsxs("div",{className:"mb-1.5 rounded-md border border-amber-300 bg-amber-50/50 px-2 py-1 text-[11px] text-amber-700 dark:border-amber-800 dark:bg-amber-950/20 dark:text-amber-300",children:["Partial coverage: ",g.coverage.trackedRepos," of ",g.coverage.totalRepos," ","repos in this workspace were being tracked when this period started — these figures under-count it."]}),g.firstObservedMidWindow&&g.firstSeenAt!=null&&t.jsxs("div",{className:"mb-1.5 rounded-md border border-amber-300 bg-amber-50/50 px-2 py-1 text-[11px] text-amber-700 dark:border-amber-800 dark:bg-amber-950/20 dark:text-amber-300",children:["First observed here ",new Date(g.firstSeenAt).toLocaleDateString()," — after this period began, so the period figures under-count them."]}),t.jsx(aV,{synth:w,person:g}),t.jsx("table",{className:"w-full text-xs",children:t.jsx("tbody",{children:g.metrics.map(T=>t.jsxs("tr",{className:"border-t border-gray-100 first:border-0 dark:border-gray-800",children:[t.jsxs("td",{className:"py-1 pr-2 text-gray-500 dark:text-gray-400",title:HR[T.key],children:[sx[T.key],T.basis==="live"&&t.jsx("span",{className:`ml-1.5 rounded border border-gray-300 px-1 text-[9px] uppercase tracking-wide ${ji} dark:border-gray-700`,title:"A live reading — today’s state, not a period figure; it keeps moving after the period closes",children:"now"})]}),t.jsxs("td",{className:"py-1 text-right font-medium tabular-nums text-gray-800 dark:text-gray-100",children:[_y(T),T.lowSample&&T.value!=null&&t.jsx("span",{className:`ml-1 text-[10px] font-normal ${ji}`,title:"Below this metric’s sample floor — the figure is real, but thin",children:"· thin"})]})]},T.key))})})]})]})}function iV(){var m,h,g,x;const e=Ge(y=>y.activeTab),n=Ge(y=>y.tabs),{data:r}=An(),s=pp(e),a=n.find(y=>y.key===e)??null,i=f.useMemo(()=>s!=null?(r??[]).find(y=>y.id===s):void 0,[r,s]),c=(i==null?void 0:i.githubLogin)??((m=a==null?void 0:a.userMeta)==null?void 0:m.login)??null,d=(i==null?void 0:i.avatarUrl)??((h=a==null?void 0:a.userMeta)==null?void 0:h.avatarUrl)??null,u=i?Dt(i,s??0):((g=a==null?void 0:a.userMeta)==null?void 0:g.displayName)??((x=a==null?void 0:a.userMeta)==null?void 0:x.login)??`user ${s??"?"}`;return s==null?t.jsx("div",{className:"mx-auto max-w-[100rem] p-4 text-sm text-gray-500 dark:text-gray-400",children:"No contributor selected."}):t.jsxs("div",{className:"mx-auto max-w-[100rem] space-y-3 p-4",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2.5",children:[d?t.jsx("img",{src:d,width:32,height:32,alt:"",loading:"lazy",referrerPolicy:"no-referrer",className:"h-8 w-8 shrink-0 rounded-full bg-gray-100 dark:bg-gray-800"}):t.jsx("span",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-gray-200 text-xs font-semibold text-gray-500 dark:bg-gray-800 dark:text-gray-400",children:(u[0]??"?").toUpperCase()}),t.jsxs("h2",{className:"text-base font-semibold text-gray-800 dark:text-gray-100",children:[u,t.jsx("span",{className:"font-normal text-gray-400",children:" · activity"})]}),t.jsx("span",{className:"text-[11px] text-gray-400",children:"last 14 days · across this Workspace · merge/close rows are PRs they authored"}),c&&t.jsxs("a",{href:Gl(c),target:"_blank",rel:"noreferrer noopener",className:"ml-auto inline-flex items-center gap-0.5 rounded border border-gray-300 px-1.5 py-0.5 text-[11px] font-medium text-gray-600 hover:border-gray-400 dark:border-gray-700 dark:text-gray-300 dark:hover:border-gray-500",title:`@${c} on GitHub`,children:["GitHub",t.jsx(_t,{size:10})]})]}),t.jsx(oV,{userId:s}),t.jsx(lV,{userId:s})]})}function lV({userId:e}){const n=f.useMemo(()=>[e],[e]);return t.jsx(xd,{userIds:n})}const cV=e=>wn(e),dV=e=>String(Math.round(e)),uV=e=>`${Math.round(e)}%`;function T0(e){return e==null?"—":wn(e)}function Xj(e,n){return e==="ttfr"?wn(n):e==="followup"?`${Math.round(n)}%`:e==="silence"?`${n}d`:String(Math.round(n))}function $0(e,n){const r=e.filter(d=>d.metric===n);if(r.length===0)return;const s=r[0],a=Xj(n,s.observed),i=Xj(n,s.typical),c=s.direction==="high"?"higher":"lower";return`${r.length} exception${r.length===1?"":"s"} · latest ${c}: ${a} vs ${i} typical`}function hV(e){if(e.silentRuns.length===0)return;const n=Math.max(...e.silentRuns.map(r=>r.days));return`${e.silentRuns.length} gap${e.silentRuns.length===1?"":"s"} · longest ${n}d silent`}function _0({title:e,bot:n,value:r,flag:s,color:a,formatY:i,note:c}){const d=n.trend.map(g=>g.weekStart),u=n.trend.map(r),m=n.trend.map(s),h=u.some(g=>g!=null);return t.jsx(jt,{title:e,note:c,children:h?t.jsx(Gn,{labels:d,series:[{key:e,label:e,color:a,values:u,pointFlags:m}],height:120,curved:!0,formatY:i}):t.jsx(Tt,{label:"Not enough history yet"})})}function pV({bot:e,color:n,prsOpenedPerDay:r}){const s=ds(e.kind);return t.jsxs("div",{className:"space-y-2 rounded-lg border border-gray-200 p-3 dark:border-gray-800",children:[t.jsxs("div",{className:"flex flex-wrap items-baseline gap-2",children:[t.jsxs("span",{className:"inline-flex items-center gap-1.5 text-sm font-semibold text-gray-800 dark:text-gray-100",children:[t.jsx("span",{className:"inline-block h-2.5 w-2.5 rounded-full",style:{background:n},"aria-hidden":!0}),e.label]}),t.jsx("span",{className:"rounded px-1.5 py-0.5 text-[10px] font-medium",style:{...pn(s.color),background:`${s.color}1a`},children:s.label}),t.jsxs("span",{className:"text-[11px] text-gray-400",children:[e.prsReviewed," PR",e.prsReviewed===1?"":"s"," first-reviewed · ",e.totalActivity," ","action",e.totalActivity===1?"":"s"," in window"]})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-2 sm:grid-cols-4",children:[t.jsx(_l,{label:"Time to first review",value:T0(e.ttfrMedianHours),sub:e.ttfrP90Hours!=null?`p90 ${T0(e.ttfrP90Hours)}${e.ttfrBaseline?` · from ${e.ttfrBaseline==="mixed"?"ready/opened":e.ttfrBaseline}`:""}`:e.ttfrBaseline?`from ${e.ttfrBaseline==="mixed"?"ready/opened":e.ttfrBaseline}`:void 0}),t.jsx(_l,{label:"LoC per comment",value:e.medianLocPerComment==null?"—":String(Math.round(e.medianLocPerComment)),sub:`${e.totalComments} comment${e.totalComments===1?"":"s"}`}),t.jsx(_l,{label:"Follow-up rate",value:e.followupRatePct==null?"—":`${e.followupRatePct}%`,sub:e.avgFollowups==null?void 0:`avg ${e.avgFollowups} extra`}),t.jsx(_l,{label:"Follow-up latency",value:T0(e.followupLatencyMedianHours),sub:"median gap"})]}),t.jsxs("div",{className:"grid grid-cols-1 gap-3 lg:grid-cols-3",children:[t.jsx(_0,{title:"Time to first review",bot:e,value:a=>a.medianTtfrHours,flag:a=>a.ttfrAnomaly,color:n,formatY:cV,note:$0(e.anomalies,"ttfr")??"weekly · vs own typical"}),t.jsx(_0,{title:"Review volume",bot:e,value:a=>a.volume,flag:a=>a.volumeAnomaly,color:n,formatY:dV,note:$0(e.anomalies,"volume")??"touches / week"}),t.jsx(_0,{title:"Follow-up rate",bot:e,value:a=>a.followupRatePct,flag:a=>a.followupAnomaly,color:n,formatY:uV,note:$0(e.anomalies,"followup")??"weekly · vs own typical"})]}),t.jsx(jt,{title:"Daily coverage",note:hV(e)??(r!=null?"one cell / day · line = PRs opened · last 12 weeks (UTC)":"one cell / day · last 12 weeks (UTC)"),children:t.jsx(D2,{daily:e.dailyActivity,startDate:e.daySpanStart,silentRuns:e.silentRuns,color:n,opened:r})}),t.jsxs("div",{className:"grid grid-cols-1 gap-3 lg:grid-cols-3",children:[t.jsx(jt,{title:"Time to first review",note:"distribution",children:t.jsx(Zf,{bins:e.ttfrDist,color:n})}),t.jsx(jt,{title:"Activity by hour",note:"week × hour (UTC) · inferred coverage",children:e.totalActivity>0?t.jsx(OC,{cells:e.activityHeatmap,color:n}):t.jsx(Tt,{label:"No activity in this window"})}),t.jsx(jt,{title:"Follow-ups after first review",note:"extra touches / PR",children:t.jsx(Zf,{bins:e.followupDist,color:n})})]})]})}function mV({ml:e}){const n=f.useMemo(()=>{var r;return[{key:"count",label:"Mentions",color:Ck[((r=e.byCategory[0])==null?void 0:r.category)??"nitpick"],values:e.byCategory.map(s=>s.count),colors:e.byCategory.map(s=>Ck[s.category])}]},[e.byCategory]);return e.byCategory.length===0?t.jsx(Tt,{label:"No categorised bot comments in this window"}):t.jsx(Lr,{labels:e.byCategory.map(r=>Xa[r.category]),series:n,height:150,rotateLabels:!0})}function gV(){var $,P;const e=Ge(C=>C.activeTab),n=Ge(C=>C.tabs),r=mp(e),s=n.find(C=>C.key===e)??null,a=(s==null?void 0:s.botMeta)??null,i=G(C=>C.botAnalyticsWindow),c=G(C=>C.setBotAnalyticsWindow),d=G(C=>C.workspaceId),{botDepth:u}=vt(),m=co(d),h=ba(),g=f.useMemo(()=>(a==null?void 0:a.repoId)!=null?[a.repoId]:null,[a==null?void 0:a.repoId]),{data:x,isLoading:y,isError:b}=uC(d,i,r!=null,g,r),w=f.useMemo(()=>r!=null?((x==null?void 0:x.bots)??[]).find(C=>C.userId===r)??null:null,[x==null?void 0:x.bots,r]),k=f.useMemo(()=>{if(w==null||(x==null?void 0:x.ml)==null)return[];const C=x.ml.perBot.find(L=>L.key===w.key);return C?[{key:w.key,userId:w.userId,label:w.label,login:w.login,kind:w.kind,ml:C}]:[]},[w,x==null?void 0:x.ml]),j=f.useMemo(()=>k.map(C=>C.key),[k]),N=pR(j),I=(w==null?void 0:w.label)??(a==null?void 0:a.label)??(a==null?void 0:a.login)??`bot ${r??"?"}`,S=(($=Yf.find(C=>C.key===i))==null?void 0:$.label)??"";let T;if(r==null)T=t.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:"No bot selected."});else if(!u)T=t.jsx("div",{className:"rounded-lg border border-dashed border-gray-300 p-6 text-center text-sm text-gray-400 dark:border-gray-700",children:"Per-bot depth isn’t available on this plan."});else if(y)T=t.jsx("div",{className:"h-40 animate-pulse rounded-lg border border-gray-200 bg-gray-50 dark:border-gray-800 dark:bg-gray-900/40"});else if(b)T=t.jsx("div",{className:"text-sm text-red-500",children:"Couldn’t load bot behaviour analytics."});else if(w==null)T=t.jsxs("div",{className:"rounded-lg border border-dashed border-gray-300 p-6 text-center text-sm text-gray-400 dark:border-gray-700",children:["No activity for this bot in this window.",t.jsx("div",{className:"mt-1 text-[11px]",children:"A bot that was active earlier may just be quiet — try widening the window above."})]});else{const C=m({login:w.login,kind:w.kind}),L=((P=k[0])==null?void 0:P.ml)??null;T=t.jsxs("div",{className:"space-y-3",children:[t.jsx(pV,{bot:w,color:C,prsOpenedPerDay:x==null?void 0:x.prsOpenedPerDay}),h&&L!=null&&t.jsxs("div",{className:"grid grid-cols-1 gap-3 lg:grid-cols-2",children:[t.jsx(jt,{title:"Severity over time",note:"weekly mean severity · findings only · hover for the week’s counts",children:t.jsx(bU,{views:k,subset:N,botColor:m})}),t.jsxs(jt,{title:"Category mix",note:`what this bot talks about · ${S}`,children:[t.jsx(mV,{ml:L}),t.jsxs("div",{className:"mt-1 text-[10px] text-gray-400",children:["Multi-label: one comment can count under several categories, so the category total (",Sn(L.byCategory.reduce((F,M)=>F+M.count,0)),") exceeds the finding count (",Sn(L.findings),") — bars are mentions, not findings. Walkthrough summaries are excluded (their categories are a read of the template, not of a finding); acknowledgments appear as “Praise”."]})]})]})]})}return t.jsxs("div",{className:"mx-auto max-w-[100rem] space-y-3 p-4",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsxs("h2",{className:"inline-flex items-center gap-1.5 text-base font-semibold text-gray-800 dark:text-gray-100",children:[t.jsx(Lt,{size:15}),I,t.jsx("span",{className:"font-normal text-gray-400",children:" · depth"})]}),t.jsxs("span",{className:"text-[11px] text-gray-400",children:["Deterministic, no AI. Red rings & underlines mark where this bot diverged from its"," ",t.jsx("span",{className:"font-medium",children:"own"})," typical (a self-baseline). Times are UTC; activity gaps are inferred (not a direct rate-limit signal).",(a==null?void 0:a.repoId)!=null&&" Measured on the repo the pill was opened from."]}),t.jsx("div",{className:"ml-auto inline-flex overflow-hidden rounded border border-gray-300 dark:border-gray-700",children:Yf.map(C=>t.jsx("button",{type:"button",onClick:()=>c(C.key),className:`px-2 py-0.5 text-[11px] font-medium ${i===C.key?"bg-sky-500/15 text-sky-700 dark:text-sky-300":"text-gray-500 hover:bg-gray-100 dark:text-gray-400 dark:hover:bg-gray-800"}`,children:C.label},C.key))})]}),T]})}const zt="text-gray-400",fV=8,xV=16e3,yV={worked_on:"What they worked on",nature_of_changes:"Nature of the changes",collaboration:"Collaboration",waiting_and_risk:"Waiting + risk"},Py=e=>e?`pw:${e.fromMs}-${e.toMs}`:"pw:-";function bV(e,n,r){return Oe({queryKey:["bot-analytics",dt(e),"r:-",Py(n)],queryFn:e==null||n==null?Ct:()=>he.botAnalytics("sprint",e,void 0,n),enabled:r&&n!=null,staleTime:6e4,gcTime:fn})}function vV(e,n,r,s){return Oe({queryKey:["bot-vendor-comments",dt(e),`u${n}`,Py(r)],queryFn:e==null||r==null?Ct:()=>he.botVendorComments(`u${n}`,"sprint",e,void 0,r),enabled:s&&r!=null,staleTime:6e4,gcTime:fn})}function kV(e,n,r,s){return Oe({queryKey:["bot-authoring",dt(e),`u${n}`,Py(r)],queryFn:e==null||r==null?Ct:()=>he.botAuthoring(e,n,r,!0),enabled:s&&r!=null,staleTime:6e4,gcTime:fn})}function zR({state:e}){return t.jsx(Fi,{meta:Xt[e]})}function wV({body:e}){const[n,r]=f.useState(!1),s=e.length>400;return t.jsxs("div",{className:"mt-1 rounded bg-gray-50 px-2 py-1.5 text-sm dark:bg-gray-900/50",children:[t.jsx("div",{className:n||!s?"":"max-h-32 overflow-hidden",children:t.jsx(gr,{children:e})}),s&&t.jsx("button",{type:"button",onClick:()=>r(a=>!a),className:"mt-1 text-[11px] font-medium text-sky-600 hover:underline dark:text-sky-400",children:n?"Show less":"Show more"})]})}const jV={review_comment:"inline comment",pr_comment:"PR comment",review:"review summary"};function KR({c:e,onOpenPr:n,onOpenThread:r}){return t.jsxs("article",{"data-ev-anchor":e.targetKind==="review_comment"?`rc:${e.targetId}`:e.targetKind==="pr_comment"?`pc:${e.targetId}`:void 0,className:"rounded-md border border-gray-200 bg-white p-2 text-sm dark:border-gray-800 dark:bg-gray-950",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 text-[11px]",children:[t.jsx("span",{className:"shrink-0 text-[10px] uppercase tracking-wide text-gray-400",children:jV[e.targetKind]}),t.jsxs("button",{type:"button",onClick:()=>n(e),className:"shrink-0 font-medium text-gray-700 hover:text-sky-600 hover:underline dark:text-gray-200",title:`${e.repoFullName} #${e.prNumber} — ${e.prTitle}`,children:[e.repoFullName," #",e.prNumber]}),e.path!=null&&t.jsx("span",{className:"min-w-0 truncate font-mono text-gray-400",title:e.path,children:e.path}),e.mlLabel&&t.jsx(cc,{label:e.mlLabel}),e.derivedState!=null&&t.jsx(zR,{state:e.derivedState}),e.threadId!=null&&t.jsx("button",{type:"button",onClick:()=>r(e,e.threadId),className:"shrink-0 font-medium text-sky-600 hover:underline dark:text-sky-400",children:"Open thread"}),t.jsx("span",{className:`ml-auto shrink-0 ${zt}`,title:Cn(e.createdAt),children:Nt(e.createdAt)})]}),e.body!=null&&e.body.trim()!==""&&t.jsx(wV,{body:e.body})]})}function NV({t:e,onOpen:n}){return t.jsxs("article",{"data-ev-anchor":`th:${e.threadId}`,className:"rounded-md border border-gray-200 bg-white p-2 text-sm dark:border-gray-800 dark:bg-gray-950",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 text-[11px]",children:[t.jsxs("span",{className:"shrink-0 font-medium text-gray-700 dark:text-gray-200",children:[e.repoFullName," #",e.prNumber]}),e.path!=null&&t.jsx("span",{className:"min-w-0 truncate font-mono text-gray-400",title:e.path,children:e.path}),t.jsx(zR,{state:e.derivedState}),t.jsx("button",{type:"button",onClick:()=>n(e),className:"shrink-0 font-medium text-sky-600 hover:underline dark:text-sky-400",children:"Open thread"}),t.jsx("span",{className:`ml-auto shrink-0 ${zt}`,title:Cn(e.createdAt),children:Nt(e.createdAt)})]}),t.jsx("p",{className:"mt-1 text-[12px] text-gray-600 dark:text-gray-300",children:e.excerpt})]})}function yh({more:e,unit:n}){return e<=0?null:t.jsxs("div",{className:`text-[11px] ${zt}`,children:["and ",e," more ",n]})}function SV({workspaceId:e,userId:n,fromMs:r,toMs:s,wanted:a,granted:i,request:c,release:d,onRefClick:u}){var L,F;const{activityDigest:m}=vt(),h=a&&m&&r!=null&&s!=null,g=f.useMemo(()=>({kind:"person_report",window:"rolling_14",userId:n,fromMs:r,toMs:s}),[n,r,s]),{data:x}=mc(e,g,h),y=Iy(e,g),b=Ty(e,g),[w,k]=f.useState(!1),j=f.useRef(null);f.useEffect(()=>()=>{j.current!=null&&window.clearTimeout(j.current)},[]);const[N,I]=f.useState(!1);f.useEffect(()=>I(!1),[e,n,r,s,(L=x==null?void 0:x.synthesis)==null?void 0:L.generatedAt]);const S=h&&(x==null?void 0:x.enabled)===!0&&(x.synthesis==null||x.stale===!0);f.useEffect(()=>{S&&!b&&!w&&!N?c(n):(!S||N)&&d(n)},[S,b,w,N,c,d,n]),f.useEffect(()=>()=>d(n),[d,n]);const T=f.useRef(null);if(f.useEffect(()=>{var D;if(!i)return;if(!S||b||w||N||e==null){(!S||w||N)&&d(n);return}const M=`${e}|${n}|${r??"-"}|${s??"-"}|${((D=x==null?void 0:x.synthesis)==null?void 0:D.generatedAt)??"-"}`;if(T.current===M){d(n);return}T.current=M,y.mutate(void 0,{onSettled:A=>{A!=null&&A.throttled?(T.current=null,k(!0),j.current=window.setTimeout(()=>k(!1),xV)):A==null&&I(!0),d(n)}})},[i,S,b,w,N,e,n,r,s,(F=x==null?void 0:x.synthesis)==null?void 0:F.generatedAt]),!h||(x==null?void 0:x.enabled)===!1)return null;const $=(x==null?void 0:x.synthesis)??null,P=($==null?void 0:$.sections)??[],C=b||i||S&&!N&&x!=null;return t.jsxs("div",{className:"rounded-lg border border-ai-border bg-ai-surface p-3",children:[t.jsxs("div",{className:"mb-1.5 flex flex-wrap items-baseline gap-2",children:[t.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wide text-ai-ink",children:"Claude’s read"}),t.jsx("span",{className:`text-[11px] ${zt}`,children:"evidence-cited prose — every figure on this page is computed, not written"}),(x==null?void 0:x.stale)===!0&&$!=null&&t.jsx("span",{className:"rounded bg-amber-500/10 px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-amber-700 dark:text-amber-300",children:"stale"}),C&&t.jsx("span",{className:`ml-auto text-[11px] ${zt}`,children:b?"writing…":"queued…"})]}),$==null?t.jsx("div",{className:`text-[11px] ${zt}`,children:C?"Writing this section…":"No narrative yet."}):P.length===0?t.jsx("div",{className:`text-[11px] ${zt}`,children:"No narrative for this period — the figures and evidence above are the surface."}):t.jsx("div",{className:"space-y-2",children:P.map(M=>t.jsxs("div",{children:[t.jsx("div",{className:"text-[11px] font-semibold text-ai-ink",children:yV[M.id]}),t.jsx("p",{className:"text-[12px] leading-relaxed text-gray-700 dark:text-gray-200",children:M.prose}),M.refs.length>0&&t.jsxs("div",{className:"mt-0.5 flex flex-wrap items-center gap-1",children:[t.jsxs("span",{className:`text-[10px] ${zt}`,children:[M.refs.length," citation",M.refs.length===1?"":"s",":"]}),M.refs.map((D,A)=>t.jsx("button",{type:"button",onClick:()=>u(D),title:D,className:"rounded border border-ai-border px-1 text-[10px] tabular-nums text-ai-signal hover:border-ai-signal/60 hover:bg-ai-surface-2",children:A+1},D))]})]},M.id))})]})}function CV({selection:e,workspaceId:n,periodKey:r,granted:s,request:a,release:i}){var P,C,L;const{periodReports:c}=vt(),{data:d}=An(),u=f.useMemo(()=>Rn(d),[d]),m=Ge(F=>F.openPrDetailTab),h=f.useRef(null),g=UR(c,n,e.userId,r,!0),x=((P=g.data)==null?void 0:P.person)??null,y=(x==null?void 0:x.evidence)??null,b=((C=g.data)==null?void 0:C.periodStart)!=null?Date.parse(g.data.periodStart):null,w=((L=g.data)==null?void 0:L.periodEnd)!=null?Date.parse(g.data.periodEnd):null,k=f.useMemo(()=>py([]),[]),j=f.useCallback(F=>{F.prId!=null&&m(fa({prId:F.prId,prNumber:F.prNumber,repoFullName:F.repoFullName,title:F.title,authorLogin:F.authorLogin}),{fromActivity:!0})},[m]),N=f.useCallback(F=>{m(fa({...F,title:F.prTitle}),{fromActivity:!0})},[m]),I=f.useCallback((F,M)=>{m(fa(F),{fromActivity:!0}),G.getState().selectThread(F.prId,M)},[m]),S=f.useRef(null),T=f.useCallback(F=>{const M=Pq(F);if(M==null||h.current==null)return;const D=h.current.querySelector(`[data-ev-anchor="${CSS.escape(M)}"]`);if(D==null)return;D.scrollIntoView({behavior:"smooth",block:"center"});const A=D.closest("[data-ev-anchor-group]")??D,W=["ring-2","ring-ai-signal/60","bg-ai-signal/10"];A.classList.add(...W),S.current!=null&&window.clearTimeout(S.current),S.current=window.setTimeout(()=>A.classList.remove(...W),1600)},[]),$=y?Cq(y.prs):[];return t.jsxs("section",{ref:h,"aria-label":e.label,className:"rounded-lg border border-gray-200 bg-white p-3 text-xs dark:border-gray-800 dark:bg-gray-950",children:[t.jsxs("div",{className:"mb-1.5 flex flex-wrap items-center gap-2",children:[e.avatarUrl!=null?t.jsx("img",{src:e.avatarUrl,width:18,height:18,alt:"",loading:"lazy",referrerPolicy:"no-referrer",className:"h-[18px] w-[18px] shrink-0 rounded-full bg-gray-200 dark:bg-gray-800"}):t.jsx(yx,{size:18,className:"shrink-0"}),t.jsx("span",{className:"text-sm font-semibold text-gray-800 dark:text-gray-100",children:e.label}),e.login!=null&&e.login!==e.label&&t.jsxs("span",{className:`text-[11px] ${zt}`,children:["@",e.login]})]}),g.isLoading?t.jsx("div",{className:`py-1 text-[11px] ${zt}`,children:"Loading period figures…"}):x==null?t.jsx("div",{className:`text-[11px] ${zt}`,children:"Nothing to report — no activity from them in this Workspace this period."}):t.jsxs("div",{className:"space-y-3",children:[!x.coverage.complete&&t.jsxs("div",{className:"rounded-md border border-amber-300 bg-amber-50/50 px-2 py-1 text-[11px] text-amber-700 dark:border-amber-800 dark:bg-amber-950/20 dark:text-amber-300",children:["Partial coverage: ",x.coverage.trackedRepos," of ",x.coverage.totalRepos," ","repos in this workspace were being tracked when this period started — these figures under-count it."]}),x.firstObservedMidWindow&&x.firstSeenAt!=null&&t.jsxs("div",{className:"rounded-md border border-amber-300 bg-amber-50/50 px-2 py-1 text-[11px] text-amber-700 dark:border-amber-800 dark:bg-amber-950/20 dark:text-amber-300",children:["First observed here ",new Date(x.firstSeenAt).toLocaleDateString()," — after this period began, so the period figures under-count them."]}),t.jsx("table",{className:"w-full text-xs",children:t.jsx("tbody",{children:x.metrics.map(F=>t.jsxs("tr",{"data-ev-anchor":`metric:${F.key}`,className:"border-t border-gray-100 first:border-0 dark:border-gray-800",children:[t.jsxs("td",{className:"py-1 pr-2 text-gray-500 dark:text-gray-400",title:HR[F.key],children:[sx[F.key],F.basis==="live"&&t.jsx("span",{className:`ml-1.5 rounded border border-gray-300 px-1 text-[9px] uppercase tracking-wide ${zt} dark:border-gray-700`,title:"A live reading — today’s state, not a period figure; it keeps moving after the period closes",children:"now"})]}),t.jsxs("td",{className:"py-1 text-right font-medium tabular-nums text-gray-800 dark:text-gray-100",children:[_y(F),F.lowSample&&F.value!=null&&t.jsx("span",{className:`ml-1 text-[10px] font-normal ${zt}`,title:"Below this metric’s sample floor — the figure is real, but thin",children:"· thin"})]})]},F.key))})}),t.jsx(SV,{workspaceId:n,userId:e.userId,fromMs:b,toMs:w,wanted:!0,granted:s,request:a,release:i,onRefClick:T}),y!=null&&t.jsxs("div",{className:"space-y-3",children:[$.map(F=>t.jsxs("div",{children:[t.jsx("div",{className:`mb-1 text-[10px] font-semibold uppercase tracking-wide ${zt}`,children:sx[F.key]}),t.jsxs("div",{"data-ev-anchor-group":F.key,children:[t.jsx(RV,{rows:F.rows}),t.jsx(gy,{groups:[{prs:F.rows,summary:""}],onOpenPr:j,usersById:u,index:k})]}),t.jsx(yh,{more:F.more,unit:"PRs"})]},F.key)),y.comments.rows.length>0&&t.jsxs("div",{children:[t.jsxs("div",{className:`mb-1 text-[10px] font-semibold uppercase tracking-wide ${zt}`,children:["Their review comments"," ",t.jsx("span",{className:"font-normal normal-case tracking-normal",children:"(inline + PR comments — wider than the inline-only figure above)"})]}),t.jsx("div",{className:"space-y-1.5",children:y.comments.rows.map(F=>t.jsx(KR,{c:F,onOpenPr:N,onOpenThread:(M,D)=>I({...M,title:M.prTitle},D)},`${F.targetKind}:${F.targetId}`))}),t.jsx(yh,{more:y.comments.more,unit:"comments"})]}),y.threads.rows.length>0&&t.jsxs("div",{children:[t.jsx("div",{className:`mb-1 text-[10px] font-semibold uppercase tracking-wide ${zt}`,children:"Threads opened on their PRs"}),t.jsx("div",{className:"space-y-1.5",children:y.threads.rows.map(F=>t.jsx(NV,{t:F,onOpen:M=>I(M,M.threadId)},F.threadId))}),t.jsx(yh,{more:y.threads.more,unit:"threads"})]}),y.pathAreas.length>0&&t.jsxs("div",{children:[t.jsx("div",{className:`mb-1 text-[10px] font-semibold uppercase tracking-wide ${zt}`,children:"Where they worked"}),t.jsx("div",{className:"flex flex-wrap gap-1.5",children:y.pathAreas.map(F=>t.jsxs("span",{"data-ev-anchor":`area:${F.bucket}`,className:"rounded border border-gray-200 px-1.5 py-0.5 text-[11px] text-gray-600 dark:border-gray-800 dark:text-gray-300",title:`${F.files} files touched across ${F.commits} commits on PRs they authored this period`,children:[t.jsx("span",{className:"font-mono",children:F.bucket}),t.jsxs("span",{className:`ml-1 tabular-nums ${zt}`,children:[F.files," files · ",F.commits," commits"]})]},F.bucket))})]})]})]})]})}function RV({rows:e}){return t.jsx(t.Fragment,{children:e.map(n=>n.prId!=null?t.jsx("span",{"data-ev-anchor":`pr:${n.prId}`},n.prId):null)})}const Zj={keep:{label:"keep",cls:"bg-green-500/10 text-green-700 dark:text-green-300"},tune:{label:"tune",cls:"bg-amber-500/10 text-amber-700 dark:text-amber-300"},noisy:{label:"noisy",cls:"bg-red-500/10 text-red-700 dark:text-red-300"}};function Ks({label:e,value:n,title:r}){return t.jsxs("div",{title:r,children:[t.jsx("div",{className:`text-[10px] uppercase tracking-wide ${zt}`,children:e}),t.jsx("div",{className:"text-sm font-semibold tabular-nums text-gray-800 dark:text-gray-100",children:n})]})}function IV(e){if(e==null)return"—";const n=e/6e4;if(n<60)return`${Math.max(1,Math.round(n))}m`;const r=n/60;if(r<24)return`${Math.round(r)}h`;const s=r/24;return`${s<10?s.toFixed(1):Math.round(s)}d`}const TV={prs_opened:"PRs opened",prs_merged:"PRs merged",prs_closed_unmerged:"Closed unmerged",merge_rate_pct:"Merge rate",median_hours_to_merge:"Median time to merge",median_pr_size_lines:"Median size",prs_merged_without_human_review:"Merged with no human review",human_review_comments_received:"Human review comments",repos_touched:"Repos touched"},$V={prs_opened:"PRs this automation opened inside the period",prs_merged:"PRs this automation authored that were merged inside the period",prs_closed_unmerged:"PRs it authored that were closed inside the period WITHOUT merging — the churn it cost for nothing",merge_rate_pct:"Merged ÷ (merged + closed-unmerged), over PRs RESOLVED in the period — not over PRs opened, since one opened on the last day has not had its chance yet",median_hours_to_merge:"Median open → merged, over the PRs merged inside the period",median_pr_size_lines:"Median added + deleted lines, over the PRs merged inside the period",prs_merged_without_human_review:"Of the PRs merged in the period, how many no human ever reviewed or commented on — the ones that cost nobody any time",human_review_comments_received:"Review comments people left on its PRs inside the period — where it did cost time",repos_touched:"Repos it opened or merged a PR in during the period"};function _V(e){if(e.value==null)return"—";switch(e.key){case"merge_rate_pct":return`${Math.round(e.value)}%`;case"median_hours_to_merge":return e.value<24?`${Math.round(e.value)}h`:`${(e.value/24).toFixed(1)}d`;case"median_pr_size_lines":return`${Math.round(e.value).toLocaleString()} lines`;default:return Math.round(e.value).toLocaleString()}}function PV({output:e,usersById:n,onOpenPr:r}){const s=f.useMemo(()=>py([]),[]),a=e.evidence,i=new Map(e.metrics.map(d=>[d.key,d])),c=[];return a!=null&&(a.merged.length>0&&c.push({label:"Merged",rows:a.merged,more:a.mergedMore,title:"PRs merged inside the period"}),a.closedUnmerged.length>0&&c.push({label:"Closed unmerged",rows:a.closedUnmerged,more:a.closedUnmergedMore,title:"Closed inside the period without merging"}),a.humanReviewed.length>0&&c.push({label:"Drew human review",rows:a.humanReviewed,more:a.humanReviewedMore,title:"Its PRs that a person commented on inside the period"})),t.jsxs("div",{className:"space-y-3 border-t border-gray-200 pt-3 dark:border-gray-800",children:[t.jsxs("div",{className:"flex flex-wrap items-baseline gap-2",children:[t.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wide text-gray-500 dark:text-gray-400",children:"What it authored"}),t.jsx("span",{className:`text-[11px] ${zt}`,children:"PRs this automation wrote — the output its role is actually measured by"})]}),t.jsx("div",{className:"grid grid-cols-3 gap-x-4 gap-y-2 sm:grid-cols-5",children:$$.map(d=>{const u=i.get(d);return u==null?null:t.jsx(Ks,{label:TV[d],value:_V(u),title:$V[d]},d)})}),e.repos.length>0&&t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[t.jsx("span",{className:`text-[10px] uppercase tracking-wide ${zt}`,children:"Where"}),e.repos.map(d=>t.jsxs("span",{className:"rounded bg-gray-100 px-1.5 py-0.5 text-[10px] text-gray-600 dark:bg-gray-900 dark:text-gray-300",children:[d.repoFullName.split("/")[1]??d.repoFullName," · ",d.prs]},d.repoId))]}),c.map(d=>t.jsxs("div",{children:[t.jsx("div",{className:`mb-1 text-[10px] font-semibold uppercase tracking-wide ${zt}`,title:d.title,children:d.label}),t.jsx(gy,{groups:[{prs:d.rows,summary:""}],onOpenPr:r,usersById:n,index:s}),t.jsx(yh,{more:d.more,unit:d.label==="Drew human review"?"more PRs at least":"PRs"})]},d.label))]})}function EV({selection:e,workspaceId:n,bounds:r,row:s,analyticsLoading:a}){var L,F,M;const{botDepth:i,periodReports:c}=vt(),d=Ge(D=>D.openBotDetailTab),u=Ge(D=>D.openPrDetailTab),m=co(n),[h,g]=f.useState(!1),x=vV(n,e.userId,r,c),y=kV(n,e.userId,r,c),b=((L=y.data)==null?void 0:L.output)??null,{data:w}=An(),k=f.useMemo(()=>Rn(w),[w]),j=f.useCallback(D=>{D.prId!=null&&u(fa({prId:D.prId,prNumber:D.prNumber,repoFullName:D.repoFullName,title:D.title,authorLogin:D.authorLogin}),{fromActivity:!0})},[u]),N=((F=x.data)==null?void 0:F.comments)??[],I=h?N:N.slice(0,fV),S=f.useMemo(()=>Tq(N),[N]),T=f.useCallback(D=>{u(fa({...D,title:D.prTitle}),{fromActivity:!0})},[u]),$=f.useCallback((D,A)=>{u(fa({...D,title:D.prTitle}),{fromActivity:!0}),G.getState().selectThread(D.prId,A)},[u]),P=m({login:e.login,kind:(s==null?void 0:s.kind)??"in_house"}),C=s==null?void 0:s.mlInflation;return t.jsxs("section",{"aria-label":e.label,className:"rounded-lg border border-gray-200 bg-white p-3 text-xs dark:border-gray-800 dark:bg-gray-950",children:[t.jsxs("div",{className:"mb-1.5 flex flex-wrap items-center gap-2",children:[t.jsx("span",{"aria-hidden":"true",className:"inline-block h-3 w-3 shrink-0 rounded-full",style:{background:P}}),t.jsx("span",{className:"text-sm font-semibold text-gray-800 dark:text-gray-100",children:e.label}),s!=null&&t.jsx("span",{className:`text-[11px] ${zt}`,children:ds(s.kind).label}),s!=null&&t.jsx("span",{className:`rounded px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide ${Zj[s.verdict].cls}`,title:"The ROI table's keep/tune/noisy verdict over this period's thread math",children:Zj[s.verdict].label}),(s==null?void 0:s.dormant)===!0&&t.jsx("span",{className:`text-[10px] uppercase tracking-wide ${zt}`,children:"dormant"}),t.jsx("span",{className:`ml-auto text-[11px] ${zt}`,children:"deterministic breakdown — no model narrative for bots"}),i&&t.jsx("button",{type:"button",onClick:()=>d(e.userId,{id:e.userId,login:e.login,label:e.label,kind:(s==null?void 0:s.kind)??"in_house",repoId:null}),className:"rounded border border-sky-300 px-2 py-0.5 text-[11px] font-medium text-sky-600 hover:bg-sky-50 dark:border-sky-800 dark:text-sky-300 dark:hover:bg-sky-950/40",title:"Open this bot's paid depth tab — trends, heatmaps, weekly inflation history, per-seat cost",children:"Depth →"})]}),a?t.jsx("div",{className:`py-1 text-[11px] ${zt}`,children:"Loading period figures…"}):s==null&&b==null?t.jsx("div",{className:`text-[11px] ${zt}`,children:y.isPending?"Loading period figures…":"No review output and no authored PRs in this period."}):s==null?t.jsx(PV,{output:b,usersById:k,onOpenPr:j}):t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"grid grid-cols-3 gap-x-4 gap-y-2 sm:grid-cols-5",children:[t.jsx(Ks,{label:"Threads",value:String(s.threads)}),t.jsx(Ks,{label:"Comments",value:String(s.comments)}),t.jsx(Ks,{label:"Acted on",value:`${s.actedOn}${s.actedOnPct!=null?` (${s.actedOnPct}%)`:""}`,title:"Threads a human replied to, resolved, or likely addressed"}),t.jsx(Ks,{label:"Untouched",value:`${s.untouched}${s.overdueUntouched>0?` · ${s.overdueUntouched} overdue`:""}`,title:"Not-addressed threads; 'overdue' = older than the grace window (genuinely ignored)"}),t.jsx(Ks,{label:"Median addressed",value:IV(s.medianAddressedMs),title:"This bot's median time-to-addressed (reply | resolve | addressing commit)"}),t.jsx(Ks,{label:"Merged past",value:`${s.mergedPastPrs} PRs · ${s.mergedPastThreads} threads`,title:"PRs merged this period still carrying ≥1 untouched thread by this bot at merge — the team's final answer was to ship anyway"}),s.mlFindings!=null&&t.jsx(Ks,{label:"Findings (ML)",value:String(s.mlFindings),title:"Labelled findings this period (summaries/praise excluded)"}),s.mlBySeverity!=null&&t.jsx(Ks,{label:"Severity mix",value:`${s.mlBySeverity.critical+s.mlBySeverity.major} high · ${s.mlBySeverity.minor} minor · ${s.mlBySeverity.nit} nit`,title:"Our model's severity of this bot's labelled findings (major+critical bucketed as high)"}),s.notAddressedBySeverity!=null&&t.jsx(Ks,{label:"Ignored, by severity",value:`${s.notAddressedBySeverity.critical+s.notAddressedBySeverity.major} high · ${s.notAddressedBySeverity.minor} minor · ${s.notAddressedBySeverity.nit} nit`,title:"Untouched threads split by the predicted severity of the finding that opened each one (labelled subset only — these need not sum to Untouched)"}),t.jsx(Ks,{label:"Inflation",value:C==null||C.badged===0?"—":t.jsxs(t.Fragment,{children:[t.jsx(_s,{dir:"up",size:11,className:"inline-block align-[-0.1em]"}),C.overCall," ",t.jsx(_s,{dir:"down",size:11,className:"inline-block align-[-0.1em]"}),C.underCall," of ",C.badged]}),title:C==null||C.badged===0?"Badges nothing — no badge is silence, not agreement":`Of ${C.badged} findings carrying the bot's own badge: ${C.overCall} badged worse than our model rated (inflation), ${C.underCall} milder`})]}),N.length>0&&t.jsxs("div",{children:[t.jsxs("div",{className:`mb-1 text-[10px] font-semibold uppercase tracking-wide ${zt}`,children:["Where it works"," ",t.jsxs("span",{className:"font-normal normal-case",children:["— across the ",S.sampleSize," most recent comments below"]})]}),t.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[S.repos.map(([D,A])=>t.jsxs("span",{className:"rounded border border-gray-200 px-1.5 py-0.5 text-[11px] text-gray-600 dark:border-gray-800 dark:text-gray-300",children:[D," ",t.jsxs("span",{className:`tabular-nums ${zt}`,children:["· ",A]})]},`r:${D}`)),S.areas.map(([D,A])=>t.jsxs("span",{className:"rounded border border-gray-200 px-1.5 py-0.5 font-mono text-[11px] text-gray-600 dark:border-gray-800 dark:text-gray-300",children:[D," ",t.jsxs("span",{className:`font-sans tabular-nums ${zt}`,children:["· ",A]})]},`a:${D}`))]})]}),x.isLoading?t.jsx("div",{className:`text-[11px] ${zt}`,children:"Loading comments…"}):N.length>0?t.jsxs("div",{children:[t.jsx("div",{className:`mb-1 text-[10px] font-semibold uppercase tracking-wide ${zt}`,children:"What it said"}),t.jsx("div",{className:"space-y-1.5",children:I.map(D=>t.jsx(KR,{c:D,onOpenPr:T,onOpenThread:$},`${D.targetKind}:${D.targetId}`))}),!h&&N.length>I.length&&t.jsxs("button",{type:"button",onClick:()=>g(!0),className:"mt-1 text-[11px] font-medium text-sky-600 hover:underline dark:text-sky-400",children:["Show all ",N.length," comments"]}),((M=x.data)==null?void 0:M.truncated)===!0&&t.jsx("div",{className:`mt-1 text-[11px] ${zt}`,children:"and more — the period holds more comments than were fetched."})]}):null]})]})}function AV(){var k;const e=G(j=>j.peopleReportSeed),n=G(j=>j.workspaceId),{periodReports:r}=vt(),s=uc(r),[a,i]=f.useReducer(_q,$q),c=f.useCallback(j=>i({type:"request",userId:j}),[]),d=f.useCallback(j=>i({type:"release",userId:j}),[]),u=e!=null&&n!=null&&e.workspaceId===n,m=Fd(r,n),h=u?(((k=m.data)==null?void 0:k.periods)??[]).find(j=>j.periodKey===e.periodKey)??null:null,g=h!=null?{fromMs:Date.parse(h.periodStart),toMs:Date.parse(h.periodEnd)}:null,x=f.useMemo(()=>oR((e==null?void 0:e.selections)??[]),[e]),y=x.some(j=>j.kind==="bot"),b=bV(n,g,y&&r),w=f.useMemo(()=>{var N,I;const j=new Map;for(const S of((N=b.data)==null?void 0:N.vendors)??[])j.set(S.key,S);for(const S of((I=b.data)==null?void 0:I.qualityChecks)??[])j.set(S.key,S);return j},[b.data]);return s==="pending"?t.jsx("div",{className:"p-6 text-sm text-gray-400",children:"Loading…"}):s==="locked"?t.jsx("div",{className:"mx-auto max-w-[100rem] p-4",children:t.jsx(dc,{heading:"The People report",testId:"people-report-locked",children:"One report with a section per person or bot you pick — what they reviewed, what they authored, and how long others waited on them over a completed period. Built for 1:1 prep: sections are alphabetical, and nothing here ranks anyone against anyone."})}):e==null?t.jsx("div",{className:"p-6 text-sm text-gray-400",children:"No report seeded. Open Reports → People, pick people or bots, and Begin report."}):t.jsxs("div",{className:"mx-auto max-w-[100rem] space-y-4 p-4",children:[t.jsxs("div",{className:"flex flex-wrap items-baseline gap-2",children:[t.jsxs("h2",{className:"text-base font-semibold text-gray-800 dark:text-gray-100",children:["People report",h!=null?` · ${ro(h.periodStart,h.periodEnd)}`:""]}),t.jsx(ec,{variant:"heading",title:"The People report is part of Pro."}),t.jsxs("span",{className:"text-[11px] text-gray-400",children:[x.length," section",x.length===1?"":"s"]}),t.jsx("span",{className:"text-[11px] text-gray-400",children:"one section per person or bot, alphabetical — not a leaderboard"})]}),u?m.isLoading?t.jsx("div",{className:"text-sm text-gray-400",children:"Loading the period list…"}):h==null?t.jsx("div",{className:"rounded-lg border border-dashed border-gray-300 p-4 text-xs text-gray-500 dark:border-gray-700 dark:text-gray-400",children:"This period is no longer listed for the current workspace — reopen the report from Reports → People."}):t.jsx("div",{className:"space-y-4",children:x.map(j=>j.kind==="human"?t.jsx(CV,{selection:j,workspaceId:n,periodKey:e.periodKey,granted:a.current===j.userId,request:c,release:d},`human:${j.userId}`):t.jsx(EV,{selection:j,workspaceId:n,bounds:g,row:w.get(`u${j.userId}`)??null,analyticsLoading:b.isLoading},`bot:${j.userId}`))}):t.jsx("div",{className:"rounded-lg border border-dashed border-gray-300 p-4 text-xs text-gray-500 dark:border-gray-700 dark:text-gray-400",children:"This report was begun in another workspace — reopen it from Reports → People in the workspace you want to report on."})]})}const MV=[{key:"pr",label:"PRs"},{key:"review",label:"Reviews"},{key:"review_comment",label:"Threads"},{key:"pr_comment",label:"Comments"}];function LV(){const e=G(N=>N.searchSeed),n=G(N=>N.openSearchDetail),[r,s]=f.useState(e??""),[a,i]=f.useState([]);f.useEffect(()=>{e!=null&&e!==r.trim()&&s(e)},[e]);const c=iy(r.trim(),300);f.useEffect(()=>{c!==(G.getState().searchSeed??"")&&G.setState({searchSeed:c})},[c]);const{hits:d,people:u,total:m,isLoading:h,isFetching:g,hasMore:x,fetchMore:y,isFetchingMore:b}=UO(c,a),{data:w}=An(),k=f.useMemo(()=>Rn(w),[w]),j=N=>i(I=>I.includes(N)?I.filter(S=>S!==N):[...I,N]);return t.jsxs("div",{className:"mx-auto max-w-[100rem] p-4",children:[t.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-3",children:[t.jsx("h2",{className:"text-sm font-semibold text-gray-700 dark:text-gray-200",children:"Search"}),t.jsxs("div",{className:"relative",children:[t.jsx("div",{className:"pointer-events-none absolute left-2 top-1/2 -translate-y-1/2 text-gray-400",children:t.jsx(eo,{size:14})}),t.jsx("input",{type:"search",value:r,autoFocus:!0,placeholder:"Search PRs, reviews, threads, comments, people…",onChange:N=>s(N.target.value),onKeyDown:N=>{N.key==="Enter"&&n(r.trim())},className:"w-96 rounded border border-gray-300 bg-transparent py-1 pl-8 pr-2 text-sm focus:border-blue-500 focus:outline-none dark:border-gray-700"})]}),t.jsxs("div",{className:"flex items-center gap-1",children:[MV.map(N=>{const I=a.includes(N.key);return t.jsx("button",{type:"button",onClick:()=>j(N.key),className:`rounded-full border px-2 py-0.5 text-xs ${I?"border-sky-500 bg-sky-50 text-sky-700 dark:bg-sky-950 dark:text-sky-300":"border-gray-300 text-gray-600 hover:bg-gray-100 dark:border-gray-700 dark:text-gray-300 dark:hover:bg-gray-800"}`,children:N.label},N.key)}),a.length>0&&t.jsx("button",{type:"button",onClick:()=>i([]),className:"px-2 py-0.5 text-xs text-gray-400 hover:text-gray-700 dark:hover:text-gray-200",children:"Clear"})]}),t.jsx("span",{className:"ml-auto text-xs text-gray-400",children:c.length<1?"Type to search":h?"Searching…":`${d.length} of ${m} result${m===1?"":"s"}`})]}),u.length>0&&t.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:[t.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wide text-gray-400",children:"People"}),u.map(N=>t.jsxs("button",{type:"button",onClick:()=>n(N.login),className:"flex items-center gap-1.5 rounded-full border border-gray-200 px-2 py-0.5 text-xs hover:bg-gray-100 dark:border-gray-700 dark:hover:bg-gray-800",children:[N.avatarUrl!=null?t.jsx("img",{src:N.avatarUrl,alt:"",className:"h-4 w-4 rounded-full"}):t.jsx("span",{className:"h-4 w-4 rounded-full bg-gray-300 dark:bg-gray-700"}),t.jsx("span",{children:N.login}),t.jsx("span",{className:"text-gray-400",children:N.matchCount})]},N.id))]}),c.length>=1&&!h&&d.length===0?t.jsxs("div",{className:"rounded-lg border border-dashed border-gray-300 py-10 text-center text-sm text-gray-500 dark:text-gray-400 dark:border-gray-700",children:["No matches for “",c,"”",a.length>0?" with the selected filters":"","."]}):t.jsx("ul",{className:"space-y-3",children:d.map(N=>t.jsx(FV,{hit:N,query:c,usersById:k},`${N.kind}:${N.refId}`))}),x&&t.jsx("div",{className:"mt-3 flex justify-center",children:t.jsx("button",{type:"button",onClick:y,disabled:b,className:"rounded border border-gray-300 px-3 py-1 text-xs text-gray-700 hover:bg-gray-100 disabled:opacity-50 dark:border-gray-700 dark:text-gray-200 dark:hover:bg-gray-800",children:b?"Loading…":`Load more (${m-d.length} more)`})}),g&&!h&&t.jsx("div",{className:"mt-2 text-center text-[11px] text-gray-400",children:"Updating…"})]})}function GR({hit:e}){const n=eC[e.kind];return t.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] text-gray-400",children:[t.jsx(n,{size:12}),t.jsx("span",{className:"font-medium text-gray-500 dark:text-gray-400",children:J2[e.kind]}),t.jsx("span",{"aria-hidden":!0,className:"decorative-mark text-gray-300 dark:text-gray-600",children:"·"}),t.jsxs("span",{role:"button",tabIndex:0,"data-noactivate":!0,onClick:r=>{r.stopPropagation(),e1(e)},onKeyDown:r=>{(r.key==="Enter"||r.key===" ")&&(r.preventDefault(),r.stopPropagation(),e1(e))},title:"Open this PR",className:"truncate rounded font-medium text-sky-600 hover:underline dark:text-sky-400",children:[e.repoFullName," #",e.prNumber]}),e.authorLogin?t.jsxs(t.Fragment,{children:[t.jsx("span",{"aria-hidden":!0,className:"decorative-mark text-gray-300 dark:text-gray-600",children:"·"}),t.jsx("span",{className:"truncate",children:e.authorLogin})]}):null]})}function FV({hit:e,query:n,usersById:r}){return e.kind==="review_comment"&&e.threadId!=null?t.jsx(OV,{hit:e,query:n,usersById:r}):t.jsx(DV,{hit:e,query:n})}function OV({hit:e,query:n,usersById:r}){const{data:s,isLoading:a}=Sp(e.threadId),i=`https://github.com/${e.repoFullName}/pull/${e.prNumber}`;return t.jsxs("li",{className:"rounded-lg border border-gray-200 p-3 dark:border-gray-800",children:[t.jsxs("div",{className:"mb-2",children:[t.jsx(GR,{hit:e}),t.jsx("div",{className:"mt-0.5 truncate text-sm font-medium text-gray-800 dark:text-gray-100",children:fd(e.prTitle,n)})]}),a||!s?t.jsx("div",{className:"h-16 animate-pulse rounded bg-gray-100 dark:bg-gray-900"}):t.jsx(Li,{thread:s,usersById:r,prUrl:i,repoId:e.repoId,onOpenInPr:()=>ly(e)})]})}function DV({hit:e,query:n}){const{data:r}=ya(e.prId),s=vS[e.prState],a=r?{ciStatus:r.ciStatus,changedFiles:r.changedFilesCount,additions:r.additions,deletions:r.deletions}:null,i=()=>ly(e);return t.jsx("li",{children:t.jsxs("div",{role:"button",tabIndex:0,onClick:c=>{c.target.closest("a,button,textarea,input,[data-noactivate]")||i()},onKeyDown:c=>{c.target===c.currentTarget&&(c.key==="Enter"||c.key===" ")&&(c.preventDefault(),i())},className:"cursor-pointer rounded-lg border border-gray-200 p-3 hover:bg-gray-50/70 dark:border-gray-800 dark:hover:bg-gray-900/60",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"shrink-0 rounded px-1.5 py-0.5 text-[10px] font-semibold text-white",style:{backgroundColor:s.color},children:s.label}),t.jsx("div",{className:"min-w-0 flex-1",children:t.jsx(GR,{hit:e})})]}),t.jsx("div",{className:"mt-0.5 text-sm font-medium text-gray-800 dark:text-gray-100",children:fd(e.prTitle,n)}),a&&t.jsx(Fo,{pr:a}),e.snippet&&e.kind!=="pr"?t.jsx("div",{className:"mt-1 line-clamp-3 text-xs text-gray-500 dark:text-gray-400",children:fd(e.snippet,n)}):null,t.jsx(ch,{prId:e.prId})]})})}function BV(){const e=G(m=>m.selectedPrId),n=G(m=>m.selectedThreadId),r=G(m=>m.clearSelection),s=f.useDeferredValue(e),a=e??s,i=Ge(m=>m.activeTab),c=Go(i),d=(c==null?void 0:c.kind)==="pr-detail"?c.prId:null,u=a!=null&&a!==d;return t.jsxs("div",{className:"relative h-full","data-testid":"detail-pane",children:[e!=null&&t.jsx("div",{className:"absolute right-2 top-1.5 z-10 flex items-center gap-2",children:t.jsx("button",{type:"button","data-testid":"detail-clear",onClick:r,className:"flex items-center rounded px-2 py-0.5 text-xs text-gray-900 hover:bg-gray-100 dark:text-gray-100 dark:hover:bg-gray-800","aria-label":"Clear selection (Esc)",title:"Clear selection (Esc)",children:t.jsx(Zt,{})})}),u?t.jsx(RC,{prId:a,selectedThreadId:n,placement:"pane"},a):t.jsx("div",{className:"flex h-full items-center justify-center px-4 text-center text-sm text-gray-400",children:"Select a PR on the timeline to see its details — your relevance-ranked state of play lives in the Activity."})]})}const VR="pierre:notifications",P0="pierre:notif-pref";function Jj(){try{return localStorage.getItem(VR)==="1"}catch{return!1}}function QR(){const[e,n]=f.useState(Jj);f.useEffect(()=>{const s=()=>n(Jj());return window.addEventListener(P0,s),window.addEventListener("storage",s),()=>{window.removeEventListener(P0,s),window.removeEventListener("storage",s)}},[]);const r=f.useCallback(s=>{try{localStorage.setItem(VR,s?"1":"0")}catch{}n(s),window.dispatchEvent(new Event(P0))},[]);return[e,r]}function WV(e){if(e.length===0||typeof Notification>"u"||Notification.permission!=="granted")return;const n=e.length===1?"Claude review ready":`${e.length} Claude reviews ready`,r=e.length===1?`${e[0].repoFullName} #${e[0].prNumber}`:e.slice(0,3).map(a=>`${a.repoFullName} #${a.prNumber}`).join(" · "),s=Cn(new Date().toISOString());try{const a=new Notification(n,{body:`${s}
68
+ ${r}`,tag:"pierre-claude-review"});a.onclick=()=>{window.focus(),a.close()}}catch{}}const qV={cloning:"Cloning",fetching_diff:"Fetching diff",deciding:"Deciding scope",reviewing:"Reviewing",persisting:"Saving findings"};function UV(){const e=Dr().enabled,n=G(T=>T.claudeReviewKickoff),r=G(T=>T.openClaudeReview),[s]=QR(),a=f.useRef(s);a.current=s;const[i,c]=f.useState(!1);f.useEffect(()=>{n>0&&c(!0)},[n]);const{data:d,dataUpdatedAt:u}=KK(e&&i),m=d&&{...d,reviews:d.reviews.filter(T=>T.trigger!=="auto"&&T.reviewId!=null)};f.useEffect(()=>{i&&((m==null?void 0:m.reviews.length)??0)===0&&c(!1)},[u]);const[h,g]=f.useState({}),[x,y]=f.useState({}),b=f.useRef(null),w=((m==null?void 0:m.reviews)??[]).map(T=>`${T.reviewId}:${T.phase??""}`).join(",");f.useEffect(()=>{const T=(m==null?void 0:m.reviews)??[],$=new Set(T.map(C=>C.reviewId)),P=b.current;if(P!=null){const C=[];for(const[L,F]of P)$.has(L)||C.push(F);C.length>0&&(aG(),a.current&&WV(C))}b.current=new Map(T.map(C=>[C.reviewId,{repoFullName:C.repoFullName,prNumber:C.prNumber,prTitle:C.prTitle}])),g(C=>{const L={...C};for(const F of T)L[F.reviewId]={reviewId:F.reviewId,prId:F.prId,repoFullName:F.repoFullName,prNumber:F.prNumber,prTitle:F.prTitle,phase:F.phase,done:!1};for(const F of Object.values(L))!$.has(F.reviewId)&&!F.done&&(L[F.reviewId]={...F,done:!0});return L})},[w]);const k=Object.values(h).filter(T=>!x[T.reviewId]);if(!e||k.length===0)return null;const j=k.filter(T=>!T.done),N=j.length===0,I=()=>{y(T=>{const $={...T};for(const P of k)$[P.reviewId]=!0;return $})},S=T=>y($=>({...$,[T]:!0}));return t.jsx("div",{className:"flex flex-col gap-2",children:t.jsxs("div",{className:"pointer-events-auto rounded-lg border border-gray-200 bg-white shadow-lg dark:border-gray-700 dark:bg-gray-900",children:[t.jsxs("div",{className:"flex items-center justify-between border-b border-gray-100 px-3 py-1.5 dark:border-gray-800",children:[t.jsxs("span",{className:"text-xs font-semibold",children:["Claude reviews",j.length>0&&t.jsxs("span",{className:"ml-1 font-normal text-gray-400",children:["· ",j.length," running"]})]}),N&&t.jsx("button",{type:"button",onClick:I,className:"text-xs text-gray-400 hover:text-gray-600 dark:hover:text-gray-200",children:"Dismiss all"})]}),t.jsx("ul",{className:"max-h-64 divide-y divide-gray-100 overflow-auto dark:divide-gray-800",children:k.map(T=>t.jsxs("li",{className:"px-3 py-2 text-xs",children:[t.jsxs("button",{type:"button",onClick:()=>r({id:T.prId,number:T.prNumber,title:T.prTitle,repoFullName:T.repoFullName,authorLogin:null,authorDisplayName:null,authorAvatarUrl:null}),className:"block w-full text-left",title:"Open this review",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[T.done?t.jsx("span",{className:"inline-block h-2 w-2 shrink-0 rounded-full bg-green-500"}):t.jsx("span",{className:"inline-block h-2.5 w-2.5 shrink-0 animate-spin rounded-full border-2 border-gray-300 border-t-blue-500"}),t.jsxs("span",{className:"truncate font-medium text-blue-600 hover:underline dark:text-blue-400",children:[T.repoFullName," #",T.prNumber]})]}),t.jsx("div",{className:"mt-0.5 truncate text-gray-500 dark:text-gray-400",children:T.prTitle}),t.jsx("div",{className:"mt-0.5 text-gray-400",children:T.done?"Ready — click to view":`${T.phase!=null?qV[T.phase]??T.phase:"Starting"}…`})]}),T.done&&t.jsx("div",{className:"mt-1 text-right",children:t.jsx("button",{type:"button",onClick:()=>S(T.reviewId),className:"text-[11px] text-gray-400 hover:text-gray-600 dark:hover:text-gray-200",children:"dismiss"})})]},T.reviewId))})]})})}const HV={fetching_diff:"Reading the PR",cloning:"Checking out the code",fixing:"Applying the fix",capturing:"Capturing changes",persisting:"Saving"};function zV(e){var r;if(!e||e.status==="idle")return null;if(e.status==="queued")return 6;const n=e.progress;if(!n)return 10;switch(n.phase){case"fetching_diff":return 12;case"cloning":return 28;case"fixing":return Math.min(90,45+(((r=n.recentActivity)==null?void 0:r.length)??0)*3);case"capturing":return 92;case"persisting":return 96;default:return 20}}const KV=4,YR=new Set(["succeeded","failed","cancelled","idle"]);function GV(e){switch(e){case"succeeded":return"Fix ready";case"failed":return"The fix did not finish";case"cancelled":return"Cancelled";case"idle":return"The fix did not start";default:return null}}function VV(){const e=Dr().enabled,n=G(i=>i.aiFixRuns),r=Object.values(n).sort((i,c)=>i.startedAt-c.startedAt);if(!e||r.length===0)return null;const s=r.filter(i=>!YR.has(i.status)),a=new Set(s.slice(0,KV).map(i=>i.prId));return t.jsxs("div",{className:"pointer-events-auto rounded-lg border border-gray-200 bg-white shadow-lg dark:border-gray-700 dark:bg-gray-900",children:[t.jsx("div",{className:"flex items-center justify-between border-b border-gray-100 px-3 py-1.5 dark:border-gray-800",children:t.jsxs("span",{className:"text-xs font-semibold",children:["AI fixes",s.length>0&&t.jsxs("span",{className:"ml-1 font-normal text-gray-400",children:["· ",s.length," running"]})]})}),t.jsx("ul",{className:"max-h-64 divide-y divide-gray-100 overflow-auto dark:divide-gray-800",children:r.map(i=>t.jsx(QV,{run:i,live:a.has(i.prId)},i.prId))})]})}function QV({run:e,live:n}){var h;const r=G(g=>g.openAiFix),s=G(g=>g.setAiFixRunStatus),a=G(g=>g.dismissAiFixRun),i=YR.has(e.status),c=Or({mutationKey:F5(e.prId)})>0,{status:d}=RM(e.prId,n&&!i&&!c),u=(d==null?void 0:d.status)??null;f.useEffect(()=>{u!=null&&s(e.prId,u)},[u,e.prId,s]);const m=GV(e.status);return t.jsxs("li",{className:"px-3 py-2 text-xs",children:[t.jsxs("button",{type:"button",onClick:()=>r({id:e.prId,number:e.prNumber,title:e.prTitle,repoFullName:e.repoFullName,authorLogin:null,authorDisplayName:null,authorAvatarUrl:null}),className:"block w-full text-left",title:"Open the AI Fix tab for this pull request",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[e.status==="succeeded"?t.jsx("span",{className:"inline-block h-2 w-2 shrink-0 rounded-full bg-green-500"}):i?t.jsx("span",{className:"inline-block h-2 w-2 shrink-0 rounded-full bg-gray-400"}):t.jsx("span",{className:"inline-block h-2.5 w-2.5 shrink-0 animate-spin rounded-full border-2 border-gray-300 border-t-blue-500"}),t.jsxs("span",{className:"truncate font-medium text-blue-600 hover:underline dark:text-blue-400",children:[e.repoFullName," #",e.prNumber]})]}),t.jsx("div",{className:"mt-0.5 truncate text-gray-500 dark:text-gray-400",children:e.prTitle})]}),m!=null?t.jsxs("div",{className:"mt-1 flex items-center justify-between gap-2",children:[t.jsx("span",{className:"text-gray-500 dark:text-gray-400",children:m}),t.jsx("button",{type:"button",onClick:()=>a(e.prId),className:"text-[11px] text-gray-400 hover:text-gray-600 dark:hover:text-gray-200",children:"dismiss"})]}):c?t.jsx("div",{className:"mt-1 text-[11px] text-gray-500 dark:text-gray-400",children:"Starting…"}):n?t.jsxs("div",{className:"mt-1",children:[t.jsx(FC,{active:!0,label:"Running AI fix",value:zV(d),timeConstantSec:40}),t.jsx("div",{className:"mt-1 text-[11px] text-gray-500 dark:text-gray-400",children:HV[((h=d==null?void 0:d.progress)==null?void 0:h.phase)??""]??"Working…"})]}):t.jsx("div",{className:"mt-1 text-[11px] text-gray-500 dark:text-gray-400",children:"Running. Progress not shown."})]})}function YV({repos:e,statuses:n,ml:r,cancelling:s,onCancel:a,onDismiss:i}){return t.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",role:"presentation",children:t.jsx("div",{className:"w-[28rem] max-w-[90vw] rounded-lg border border-gray-200 bg-white p-4 shadow-xl dark:border-gray-700 dark:bg-gray-900",role:"dialog","aria-modal":"true","aria-label":"Sync progress",children:t.jsx(X2,{repos:e,statuses:n,ml:r,cancelling:s,onCancel:a,onDismiss:i})})})}function XV({spinning:e=!1,size:n=14}){return t.jsxs("svg",{viewBox:"0 0 24 24",width:n,height:n,fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",className:e?"animate-spin":void 0,children:[t.jsx("polyline",{points:"23 4 23 10 17 10"}),t.jsx("polyline",{points:"1 20 1 14 7 14"}),t.jsx("path",{d:"M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15"})]})}function ZV(e){let n=null;for(const r of e){const s=r.lastIncrementalSyncAt??r.lastFullSyncAt;s&&(!n||s>n)&&(n=s)}return n}const eN=5,tN=e=>e.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});function JV(e){const n=new Date,r=new Date(n);return r.setSeconds(0,0),r.setMinutes(Math.floor(n.getMinutes()/e)*e+e),r}function eQ(e){const n=JV(eN),r=Math.max(1,Math.round((n.getTime()-Date.now())/6e4)),s=e?[`Last synced ${tN(new Date(e))}`]:[];return s.push(`Syncs automatically every ${eN} minutes`),s.push(`Next sync ~${tN(n)} (in ${r} min)`),s.join(`
69
+ `)}function tQ(){const e=He(),n=G(re=>re.syncRound),r=G(re=>re.setSyncRound),s=G(re=>re.managerOpen),[a,i]=f.useState(!1);f.useSyncExternalStore(KP,zP);const{data:c}=Oe({queryKey:["repos"],queryFn:he.listRepos,refetchInterval:()=>n.syncing?3e3:HP()?IP:3e4}),d=(c??[]).map(re=>re.id).join(","),{data:u}=Oe({queryKey:["sync-status",d],enabled:n.syncing&&!!c&&c.length>0,queryFn:()=>Promise.all((c??[]).map(re=>he.syncStatus(re.id))),refetchInterval:1500}),m=new Set(n.scopeIds),h=m.size===0?c??[]:(c??[]).filter(re=>m.has(re.id)),g=new Set(h.map(re=>re.id)),x=u==null?void 0:u.filter(re=>g.has(re.repoId)),y=(x??[]).filter(re=>re.status==="running"),b=y.length,w=y.filter(re=>{var X,le;return((le=(X=re.progress)==null?void 0:X.paused)==null?void 0:le.reason)!=="queued"}),k=w.length>0&&w.every(re=>{var X;return((X=re.progress)==null?void 0:X.foregroundComplete)===!0}),j=ba(),{data:N,isFetched:I}=$x(n.syncing||n.open),S=Tp(N),T=j&&!I,$=ZV(c??[]),P=f.useRef($),C=f.useRef(!1),L=f.useRef(null),F=()=>{L.current!=null&&(clearTimeout(L.current),L.current=null)},M=()=>{i(!1),C.current=!1,F()};f.useEffect(()=>F,[]);const D=()=>{e.invalidateQueries({queryKey:["timeline"]}),e.invalidateQueries({queryKey:["open-prs"]}),e.invalidateQueries({queryKey:["users"]}),e.invalidateQueries({queryKey:["mergers"]}),e.invalidateQueries({queryKey:["my-turn"]}),e.invalidateQueries({queryKey:["me"]});for(const re of ac)e.invalidateQueries({queryKey:[re]})};f.useEffect(()=>{P.current!==$&&(P.current=$,D())},[$]);const A=G(re=>re.workspaceId),W=KS(c),z=GP(W),te=f.useRef(null),H=f.useRef($);f.useEffect(()=>{if(!Array.isArray(c))return;const re=te.current;te.current=W;const X=H.current!==$;H.current=$;const le=BP({prev:re,next:W,walkSwept:X,absorbed:LP(e),repoWorkspaces:qP(c),currentWorkspaceId:A});le!=null&&HS(e,le)},[z,$,c===void 0]),f.useEffect(()=>{!n.syncing||!k||C.current||(C.current=!0,r({open:!1}),D())},[n.syncing,k]),f.useEffect(()=>{b>0&&i(!0)},[b]),f.useEffect(()=>{n.syncing&&a&&u&&b===0&&(r({syncing:!1}),i(!1),D(),e.invalidateQueries({queryKey:["ml-status"]}))},[n.syncing,a,u,b]),f.useEffect(()=>{if(!(!n.open||n.syncing||n.cancelling||S||T))return F(),L.current=setTimeout(()=>{r({open:!1}),L.current=null},1200),F},[n.open,n.syncing,n.cancelling,S,T]);const B=G(re=>re.syncModalSignal),O=f.useRef(B);f.useEffect(()=>{if(B===O.current)return;O.current=B;const re=G.getState().syncModalRepoIds;if(re.length===0)return;G.setState({syncModalRepoIds:[]});const X=G.getState().syncRound;if(X.open){if(X.scopeIds.length>0){const le=re.filter(Ne=>!X.scopeIds.includes(Ne));le.length>0&&r({scopeIds:[...X.scopeIds,...le]})}X.syncing||r({syncing:!0})}else r({open:!0,modal:!G.getState().managerOpen,syncing:!0,cancelling:!1,scopeIds:re}),M();e.invalidateQueries({queryKey:["repos"]}),e.invalidateQueries({queryKey:["sync-status"]})},[B,e]);const E=async re=>{const X=c??[];if(X.length===0||G.getState().syncRound.syncing)return;if(r({open:!0,modal:!1,syncing:!0,cancelling:!1,scopeIds:[]}),M(),(await Promise.allSettled(X.map(Ne=>he.syncRepo(Ne.id,re)))).every(Ne=>Ne.status==="rejected")){r({open:!1,syncing:!1}),i(!1);return}e.invalidateQueries({queryKey:["repos"]}),e.invalidateQueries({queryKey:["sync-status"]})},ee=async re=>{try{await he.syncRepo(re,!0)}catch(le){return le instanceof cn&&le.status===429?"cooldown":"error"}const X=G.getState().syncRound;if(X.open||X.syncing){const le={open:!0,modal:!1};X.scopeIds.length>0&&!X.scopeIds.includes(re)&&(le.scopeIds=[...X.scopeIds,re]),X.syncing||(le.syncing=!0),r(le)}else r({open:!0,modal:!1,syncing:!0,cancelling:!1,scopeIds:[re]}),M();return e.invalidateQueries({queryKey:["repos"]}),e.invalidateQueries({queryKey:["sync-status"]}),"started"},K=async()=>{r({cancelling:!0}),F();const re=(x??[]).filter(le=>le.status==="running").map(le=>le.repoId),X=re.length?re:h.map(le=>le.id);await Promise.allSettled(X.map(le=>he.cancelSync(le))),r({open:!1,syncing:!1,cancelling:!1}),i(!1),e.invalidateQueries({queryKey:["repos"]}),D()},U=()=>{F(),r({open:!1})};if(f.useEffect(()=>{kk({cancel:()=>void K(),syncAllShallow:()=>void E(!1),syncAllDeep:()=>void E(!0),syncOneDeep:ee,dismiss:U})}),f.useEffect(()=>()=>kk(null),[]),!c||c.length===0)return null;const Q=c.filter(re=>re.lastSyncStatus==="error"),J=Q[0],ne=J?`Sync error: ${J.fullName}${J.lastSyncError?` — ${J.lastSyncError}`:""}${Q.length>1?` (and ${Q.length-1} more)`:""}`:null,ae=N&&N.unscorable>0?` · ${N.unscorable.toLocaleString()} unscorable`:"",we=N?`scoring bot comments${N.pending>0?` — ${N.pending.toLocaleString()} to go`:"…"}${ae}`:"scoring bot comments…",$e=k?"loading older history…":b>0?`syncing ${b} repo${b===1?"":"s"}…`:S?we:"syncing…",Fe=n.syncing?$e:S?we:"Click to sync all repos now",oe=[ne,Fe,eQ($)].filter(Boolean).join(`
70
+ `);return t.jsxs(t.Fragment,{children:[n.open&&n.modal&&!s&&t.jsx(YV,{repos:h,statuses:x,ml:N,cancelling:n.cancelling,onCancel:()=>void K(),onDismiss:U}),t.jsxs("button",{type:"button",onClick:()=>void E(!1),"aria-busy":n.syncing||S,title:oe,className:"relative flex items-center gap-1 rounded px-1.5 py-0.5 text-xs font-medium text-gray-600 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-800",children:[t.jsx(XV,{spinning:n.syncing||S}),t.jsx("span",{className:"hidden sm:inline",children:"Sync"}),J&&!n.syncing&&!S&&t.jsx("span",{"aria-hidden":!0,className:"absolute -right-0.5 -top-0.5 h-2 w-2 rounded-full bg-red-500 ring-1 ring-white dark:ring-gray-900"})]})]})}const nN=4;function nQ(){const{data:e}=In(),n=G(w=>w.openMyTurnInWorkspace),{lines:r,total:s,totalSplit:a,anyCapped:i,uncounted:c}=K2(),[d,u]=f.useState(!1);if(d||!(e!=null&&e.user)||r.length===0)return null;const m=s===1&&!i,h=w=>{n(w),u(!0)},g=r.slice(0,nN),x=r.slice(nN),y=[x.length>0?`Also needing you: ${x.map(w=>`${w.name} (${w.count}${w.cap!=null?"+":""})`).join(", ")}.`:null,c.length>0?`Not counted here: ${c.map(w=>w.name).join(", ")}. Switch to one to see its own count.`:null].filter(w=>w!=null).join(" "),b=x.length+c.length;return t.jsxs("div",{className:"flex h-7 shrink-0 items-center gap-2 overflow-hidden whitespace-nowrap border-b border-amber-200 bg-amber-50 px-4 text-xs text-amber-800 dark:border-amber-900/50 dark:bg-amber-900/20 dark:text-amber-200",children:[t.jsx("button",{type:"button",onClick:()=>u(!0),"aria-label":"Dismiss welcome back banner",title:"Dismiss for this session",className:"flex shrink-0 items-center rounded -ml-1 px-1 text-amber-500 hover:text-amber-700 dark:hover:text-amber-300",children:t.jsx(Zt,{})}),t.jsx("span",{className:"shrink-0 font-medium",children:"Welcome back"}),t.jsx("span",{className:"shrink-0 text-amber-700/80 dark:text-amber-300/80",children:a!=null?t.jsxs(t.Fragment,{children:["· ",a.direct,i?"+":""," yours · ",a.maintained,i?"+":""," in your repos"]}):t.jsxs(t.Fragment,{children:["· ",s,i?"+":""," item",m?"":"s"," need",m?"s":""," you"]})}),t.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-1 overflow-hidden",children:[g.map(w=>{var k;return t.jsxs("button",{type:"button",onClick:()=>h(w.workspaceId),title:((k=w.cap)==null?void 0:k.title)??(w.isActive?`Show these in ${w.name}`:`Switch to ${w.name} and show these`),className:"group flex min-w-0 shrink items-center gap-1 rounded px-1 py-0.5 hover:bg-amber-100/70 dark:hover:bg-amber-900/40",children:[t.jsx("span",{"aria-hidden":!0,className:`inline-block h-1.5 w-1.5 shrink-0 rounded-full border ${w.isActive?"border-amber-500 bg-amber-500":"border-amber-400 dark:border-amber-600"}`}),t.jsxs("span",{className:"shrink-0 font-semibold tabular-nums",children:[w.count,w.cap!=null&&t.jsxs(t.Fragment,{children:[t.jsx("sup",{className:"ml-px text-[8px] font-normal opacity-70","aria-hidden":!0,children:"+"}),t.jsxs("span",{className:"sr-only",children:[" of ",w.cap.total]})]})]}),t.jsx("span",{className:`min-w-0 truncate group-hover:underline ${w.isActive?"font-medium":"text-amber-700/90 dark:text-amber-300/90"}`,children:w.name})]},w.workspaceId)}),b>0&&t.jsxs("span",{className:"shrink-0 px-1 text-[10px] text-amber-700/70 dark:text-amber-300/70",title:y,children:["+",b," more"]})]})]})}const rQ="Limn";function sQ(){return t.jsxs("svg",{width:"1.1em",height:"0.9em",viewBox:"0 0 11 9",shapeRendering:"crispEdges",fill:"currentColor","aria-hidden":"true",focusable:"false",className:"inline-block shrink-0",children:[t.jsx("rect",{x:"0",y:"0",width:"6",height:"1"}),t.jsx("rect",{x:"0",y:"1",width:"1",height:"1"}),t.jsx("rect",{x:"2",y:"1",width:"2",height:"1"}),t.jsx("rect",{x:"5",y:"1",width:"1",height:"1"}),t.jsx("rect",{x:"0",y:"2",width:"6",height:"1"}),t.jsx("rect",{x:"1",y:"3",width:"1",height:"1"}),t.jsx("rect",{x:"3",y:"4",width:"7",height:"1"}),t.jsx("rect",{x:"3",y:"5",width:"1",height:"1"}),t.jsx("rect",{x:"9",y:"5",width:"1",height:"1"}),t.jsx("rect",{x:"3",y:"6",width:"1",height:"1"}),t.jsx("rect",{x:"5",y:"6",width:"3",height:"1",className:"fill-[#C13A20] dark:fill-[#F26B4E]"}),t.jsx("rect",{x:"9",y:"6",width:"1",height:"1"}),t.jsx("rect",{x:"3",y:"7",width:"7",height:"1"}),t.jsx("rect",{x:"5",y:"8",width:"1",height:"1"})]})}function rp({className:e=""}){return t.jsxs("span",{className:`brand-title inline-flex items-center gap-[0.35em] ${e}`,children:[t.jsx(sQ,{}),t.jsxs("span",{children:[rQ,t.jsx("span",{className:"text-[#C13A20] dark:text-[#F26B4E]",children:"."})]})]})}function aQ({onClose:e}){return f.useEffect(()=>{Hp()},[]),f.useEffect(()=>{const n=r=>{r.key==="Escape"&&(r.stopImmediatePropagation(),e())};return window.addEventListener("keydown",n,!0),()=>window.removeEventListener("keydown",n,!0)},[e]),t.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4",onClick:e,role:"presentation",children:t.jsxs("div",{className:"flex max-h-[80vh] w-[34rem] max-w-[92vw] flex-col rounded-lg border border-gray-200 bg-white shadow-xl dark:border-gray-700 dark:bg-gray-900",onClick:n=>n.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":"Limn help",children:[t.jsxs("div",{className:"flex items-center justify-between border-b border-gray-200 px-4 py-2 dark:border-gray-800",children:[t.jsx("h2",{children:t.jsx(rp,{})}),t.jsx("button",{type:"button",onClick:e,className:"flex items-center self-stretch text-gray-400 hover:text-gray-600 dark:hover:text-gray-200","aria-label":"Close (Esc)",title:"Close (Esc)",children:t.jsx(Zt,{size:14})})]}),t.jsxs("div",{className:"min-h-0 flex-1 space-y-4 overflow-auto px-4 py-3 text-sm leading-relaxed text-gray-600 dark:text-gray-300",children:[t.jsxs("p",{className:"text-gray-500 dark:text-gray-400",children:["A dashboard for GitHub pull-request activity across a Workspace of repos — built for sprint situational-awareness: who’s doing what, which PRs are stalled, which review threads sit untouched, and what needs ",t.jsx("em",{children:"you"}),". It opens on ",t.jsx("strong",{children:"Pending"}),", in the ",t.jsx("strong",{children:"Activity"})," console; the"," ",t.jsx("strong",{children:"Timeline"})," is a second lens. Runs locally off your ",t.jsx(rN,{children:"gh"})," ","login (or hosted, with GitHub sign-in)."]}),t.jsxs(Ga,{title:"Add repos & scope with Workspaces",children:["Every repo lives in exactly one ",t.jsx("strong",{children:"Workspace"}),", and a Workspace is the only scope there is: the ",t.jsx(xp,{className:"inline-block align-[-0.1em]"})," ","selector top-left picks ",t.jsx("em",{children:"one"}),", and that choice narrows the whole app — Activity, Insights and the Timeline — at once. There is no “all repos” and no “unassigned” bucket. ",t.jsx("strong",{children:"Default"})," is made for you: you can rename it, you can’t delete it, and new repos land there. Add repos, create Workspaces and move repos between them under"," ",t.jsx("strong",{children:"Manage repos & workspaces"})," — assigning a repo elsewhere"," ",t.jsx("em",{children:"moves"})," it, it is never in two places. Inside the selected Workspace, the repo show/hide dropdown narrows further without changing scope."]}),t.jsxs(Ga,{title:"Activity console (the default)",children:["The left rail is your state of play: ",t.jsx("strong",{children:"Pending"}),", where the app opens, then a cross-repo ",t.jsx("strong",{children:"Feed"}),", ",t.jsx("strong",{children:"Bots"})," and"," ",t.jsx("strong",{children:"Reports"}),", then the Workspace’s repos as a flat list. The Feed is one chronological stream of real activity — opens, merges, reviews, comments, and pushes that addressed a thread. Filter it with the pills: ",t.jsx("strong",{children:"My Turn"})," (things that concern you — you authored it, were asked to review, or already chimed in), ",t.jsx("strong",{children:"Comments"})," /"," ",t.jsx("strong",{children:"PR events"})," by category, and the ",t.jsx("strong",{children:"Bots"})," lens (all → hide → only). Click any card to open that PR; ",t.jsx("strong",{children:"Back"})," returns you to the exact card. To compare Workspaces, expand any metric row in ",t.jsx("strong",{children:"Reports"})," — the “By workspace” breakdown shows every Workspace side by side for that period."]}),t.jsxs(Ga,{title:"Review-bot triage",children:["Third-party review bots (CodeRabbit, Greptile, Copilot, …) are a triaged signal, not noise. A PR’s ",t.jsx("strong",{children:"Bots"})," chip filters its threads to that vendor; you can ",t.jsx("strong",{children:"bulk-resolve"})," the ones a later commit likely addressed — always a confirm-gated, one-click action that resolves the threads on GitHub, never automatic. The rail’s ",t.jsx("strong",{children:"Bots"})," console sits directly under the Feed because it is where the Feed’s own bot judgement is made: who counts as a review bot ",t.jsx("em",{children:"in this Workspace"})," (under ",t.jsx("strong",{children:"Settings"}),") is exactly what the Feed and the Timeline hide by default. The rest of the strip measures them: per-vendor keep / tune / noisy verdicts, cost and severity inflation (",t.jsx("strong",{children:"ROI"}),"), what they keep flagging (",t.jsx("strong",{children:"Themes"}),") and how your bots compare with the same vendor elsewhere (",t.jsx("strong",{children:"Benchmark"}),"). A bot is ",t.jsx("em",{children:"one row per Workspace"}),", merged by GitHub handle however many repos it runs in, and everything about it is edited there: whether it’s automated, whether it’s a ",t.jsx("strong",{children:"quality check"})," (SonarCloud, Codecov & co, kept out of the ROI verdicts), its vendor name, and its ",t.jsx("strong",{children:"price"}),". All of those are per Workspace — setting a price in one leaves the others untouched, and prices are never added up across Workspaces. How we detect bots and how Limn attributes its own reviews stay account-wide, in ",t.jsx("strong",{children:"Settings → Review bots"}),"."]}),t.jsxs(Ga,{title:"Pending",children:["Everything waiting on you or your Workspace, in one list: items on your plate, red builds you are on the hook for, stalled reviews, untouched threads, un-assigned PRs, PRs that are simply ready to land, and dependency updates and security alerts — in six tabs, each showing how many it holds. Every tab lists its cards by a score that weighs"," ",Dl("proximity"),", ",Dl("stall")," and ",Dl("relevance")," (My turn groups by type in the order you set, and Dependencies lists security items first); the top five are"," ",t.jsx("strong",{children:"Do next"}),". ",t.jsx("strong",{children:"Settings → My Turn"})," chooses what counts as your turn and how the three are weighed. The"," ",t.jsx("strong",{children:"i"})," beside the title, and on every card, explains the order. The ranking is computed, free, and identical on every plan; Pro adds a sentence per item saying why it is worth doing now."]}),t.jsxs(Ga,{title:"Reports",children:[t.jsx("strong",{children:"Flow metrics"})," for the selected Workspace — throughput, lead time, time-to-first-review, CI success & recovery — are free and sit at the top of this pane. Below them, Pro adds the period-over-period report."," ",t.jsx("strong",{children:"Ask about the sprint"})," answers a question from that Workspace’s own sprint data — pick a quick-question pill (sprint report, retro, bottlenecks, biggest changes, …) or type your own, ",t.jsx(rN,{children:"@"}),"-mention a contributor, and optionally attach a chart. PR mentions in an answer are clickable, and answers can be pinned. ",t.jsx("strong",{children:"Track usage"})," shows your month-to-date AI credits. The attention cards are not here — they are free, and live on"," ",t.jsx("strong",{children:"Pending"}),"."]}),t.jsxs(Ga,{title:"PR detail & threads",children:["Opening a PR shows ",t.jsx("strong",{children:"Overview"})," (checks, reviewers & approvals, summary, comments), ",t.jsx("strong",{children:"Threads"})," (grouped by file, with code anchors), and ",t.jsx("strong",{children:"Activity"}),". Reply or resolve inline. On the Pro tier, each thread offers a ",t.jsx("strong",{children:"Comment check"})," — a critical, retained AI read of whether the comment holds up, with the thread and diff as context, so you can decide what to do."]}),t.jsxs(Ga,{title:"Timeline",children:["Rows are grouped ",t.jsx("strong",{children:"repo → contributor"}),"; each PR is a bar, the markers are events. Scroll to pan, hold the zoom key to zoom. ",t.jsx("strong",{children:"Show"})," ","centres a PR on the shared board; ",t.jsx("strong",{children:"Focus"})," (or double-clicking a bar) opens the PR in its own isolated tab. The tab strip carries"," ",t.jsx("strong",{children:"Activity"})," and ",t.jsx("strong",{children:"Timeline"})," plus any PR tabs you open."]}),t.jsxs(Ga,{title:"Claude Review and AI Fix (free, on your machine)",children:["The ",t.jsx("strong",{children:"Claude Review"})," tab reviews a PR into findings; you pick which to post as one GitHub review. ",t.jsx("strong",{children:"AI Fix"})," edits the branch for you to push. Both run on your own Claude Code or Anthropic API key — Limn stores no key and charges nothing. The reviewer reads code; it cannot edit files, run commands or reach the web. The fixer edits files but has no shell, and builds and tests nothing. Nothing is posted or pushed until you press the button. The hosted app does not run them: use"," ",t.jsx("code",{children:"npx limn-review"}),"."]}),t.jsxs(Ga,{title:"Keyboard",children:[t.jsx(Vc,{children:"/"})," focus search · ",t.jsx(Vc,{children:"j"}),"/",t.jsx(Vc,{children:"k"})," cycle PRs ·"," ",t.jsx(Vc,{children:"i"})," Activity console · ",t.jsx(Vc,{children:"Esc"})," leave a tab/overlay, else clear the selection."]})]})]})})}function Ga({title:e,children:n}){return t.jsxs("section",{children:[t.jsx("h3",{className:"mb-1 font-semibold text-gray-800 dark:text-gray-100",children:e}),t.jsx("p",{children:n})]})}function rN({children:e}){return t.jsx("code",{className:"rounded bg-gray-100 px-1 font-mono text-[12px] text-gray-700 dark:bg-gray-800 dark:text-gray-300",children:e})}function Vc({children:e}){return t.jsx("kbd",{className:"rounded border border-gray-300 bg-gray-100 px-1 text-[11px] font-medium text-gray-600 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-300",children:e})}function XR(e){return["workspace-pro-settings",dt(e)]}function ZR(e,n){return Oe({queryKey:XR(n),queryFn:n==null?Ct:()=>he.workspaceProSettings(n),enabled:e,staleTime:6e4})}function Ey(e){const n=He();return tt({mutationFn:r=>e==null?Promise.reject(new Error("No workspace selected")):he.updateWorkspaceProSettings(e,r),onSuccess:(r,s)=>{n.setQueryData(XR(e),r),s.sprint&&(n.invalidateQueries({queryKey:rC(e)}),n.invalidateQueries({queryKey:["period-report"]})),(s.sprint||s.comparisonMode!=null)&&(n.invalidateQueries({queryKey:["workspace-insights"]}),n.invalidateQueries({queryKey:["workspace-metrics-detail"]})),(s.issue||s.jira)&&(n.invalidateQueries({queryKey:["pr"]}),n.invalidateQueries({queryKey:["thread"]}))}})}function Ki(){var s,a;const e=G(i=>i.workspaceId),n=xa();if(e==null)return{workspaceId:null,name:null};const r=((a=(s=n.data)==null?void 0:s.find(i=>i.id===e))==null?void 0:a.name)??null;return{workspaceId:e,name:r}}function gc({title:e,failed:n=!1}){return t.jsx(Qr,{title:e,children:t.jsx("p",{className:"text-xs text-gray-400",children:n?"Unavailable right now.":"Loading this workspace’s settings…"})})}const oQ=[7,14,21,28],E0="none",sN=[{value:"rolling_14",label:"Rolling 14 days (default)",hint:"Trailing 14 days vs the prior 14 — always a full window, no sprint needed. Best if this workspace doesn’t run fixed sprints."},{value:"rolling_7",label:"Rolling 7 days",hint:"Trailing 7 days vs the prior 7 — a tighter, more responsive momentum read."},{value:"sprint",label:"Sprint position (like-for-like)",hint:"This sprint SO FAR vs the SAME point in the previous sprint (e.g. day 3 vs day 3). Uses the cadence set above; with no cadence it falls back to rolling 14 days."}];function iQ(e){const n={};return e.cadenceDirty&&(n.sprint=e.days!=null?{cadenceDays:e.days,startDate:e.start===""?null:e.start}:{cadenceDays:null,startDate:null}),e.modeDirty&&(n.comparisonMode=e.mode),n}function lQ(){var T,$;const{workspaceId:e}=Ki(),n=ZR(e!=null,e),r=Ey(e),s=n.data,[a,i]=f.useState(null),[c,d]=f.useState(!1),[u,m]=f.useState(""),[h,g]=f.useState("rolling_14"),x=`${e??"none"}:${(s==null?void 0:s.cadenceDays)??"none"}:${(s==null?void 0:s.startDate)??"none"}:${(s==null?void 0:s.comparisonMode)??"none"}`;f.useEffect(()=>{var P;s!=null&&(i(s.cadenceDays),d(s.cadenceDays!=null&&!oQ.includes(s.cadenceDays)),m(((P=s.startDate)==null?void 0:P.slice(0,10))??""),g(s.comparisonMode))},[x]);const y=(T=sN.find(P=>P.value===h))==null?void 0:T.hint;if(e==null||s==null)return t.jsx(gc,{title:"Sprint cadence",failed:n.isError});const b=s.cadenceDays,w=(($=s.startDate)==null?void 0:$.slice(0,10))??"",k=s.comparisonMode,j=a!=null,N=a!==b||j&&u!==w,I=h!==k,S=()=>{r.mutate(iQ({cadenceDirty:N,modeDirty:I,days:a,start:u,mode:h}))};return t.jsxs(Qr,{title:"Sprint cadence and comparison window",desc:"The sprint length that frames this workspace’s Reports periods and its “Sprint to date” range, and how its Insights compare one stretch of time against another. Both apply to this workspace only — every other workspace sets its own.",children:[t.jsx(rr,{label:"Sprint length",hint:j?void 0:"No sprint grid: Reports cannot generate at the sprint grain and the comparison window below falls back to a rolling 14 days.",children:t.jsxs("select",{className:Bn,value:a==null?E0:c?"custom":String(a),onChange:P=>{const C=P.target.value;C===E0?(d(!1),i(null)):C==="custom"?(d(!0),i(a??14)):(d(!1),i(Number(C)))},children:[t.jsx("option",{value:E0,children:"No sprint — this workspace doesn’t run one"}),t.jsx("option",{value:"7",children:"1 week"}),t.jsx("option",{value:"14",children:"2 weeks"}),t.jsx("option",{value:"21",children:"3 weeks"}),t.jsx("option",{value:"28",children:"4 weeks"}),t.jsx("option",{value:"custom",children:"Custom…"})]})}),j&&t.jsxs(t.Fragment,{children:[c&&t.jsx(rr,{label:"Sprint length (days)",children:t.jsx("input",{type:"number",min:1,max:90,className:Bn,value:a,onChange:P=>i(Math.max(1,Math.min(90,Number(P.target.value)||1)))})}),t.jsx(rr,{label:"Start date",hint:"Any day one of this workspace’s sprints began — the cadence rolls forward and backward from here, so it sets where the boundaries fall, not when history starts.",children:t.jsx("input",{type:"date",className:Bn,value:u,onChange:P=>m(P.target.value)})}),u===""&&t.jsx("p",{className:"text-[11px] text-amber-600 dark:text-amber-400",children:"A cadence needs a start date to locate its boundaries. Until one is set, this workspace has no period grid and Reports cannot generate."})]}),t.jsx(rr,{label:"Comparison window",hint:y,children:t.jsx("select",{className:Bn,value:h,onChange:P=>g(P.target.value),children:sN.map(P=>t.jsx("option",{value:P.value,children:P.label},P.value))})}),t.jsx("p",{className:"text-[11px] text-gray-400",children:"How this workspace’s Insights flow-metrics compare over time. Open PRs always count, regardless of the window."}),N&&t.jsxs("p",{className:"rounded border border-amber-300/60 bg-amber-50 px-2 py-1.5 text-[11px] text-amber-800 dark:border-amber-500/30 dark:bg-amber-950/40 dark:text-amber-200",children:["Changing the cadence moves this workspace’s period boundaries. Reports already generated under the old cadence are ",t.jsx("span",{className:"font-medium",children:"kept exactly as they are"})," — nothing is deleted or rewritten — but they stop appearing in the period picker, because they measure a different number of days. They stay readable under"," ",t.jsx("span",{className:"font-medium",children:"Earlier cadences"})," at the bottom of the Reports pane."]}),t.jsx(ja,{dirty:N||I,saving:r.isPending,onClick:S}),r.isError&&t.jsx("p",{className:"text-[11px] text-red-500",children:r.error.message})]})}function Ay(e){return["slack-target",dt(e)]}function cQ(e,n){return Oe({queryKey:Ay(n),queryFn:n==null?Ct:()=>he.slackTarget(n),enabled:e,staleTime:6e4})}function dQ(e){const n=He();return tt({mutationFn:r=>e==null?Promise.reject(new Error("No workspace selected")):he.updateSlackTarget(e,r),onSuccess:r=>{n.setQueryData(Ay(e),r)}})}function uQ(e){const n=He();return tt({mutationFn:()=>e==null?Promise.reject(new Error("No workspace selected")):he.deleteSlackTarget(e),onSuccess:r=>{n.setQueryData(Ay(e),r)}})}const aN=Array.from({length:24},(e,n)=>n),oN=e=>{const n=e<12;return`${e%12===0?12:e%12}:00 ${n?"AM":"PM"}`};function hQ(){const{workspaceId:e,name:n}=Ki(),r=cQ(e!=null,e),s=dQ(e),a=uQ(e),i=r.data,c=(i==null?void 0:i.target)??null,[d,u]=f.useState(""),[m,h]=f.useState("daily"),[g,x]=f.useState(9),[y,b]=f.useState(16),[w,k]=f.useState(!1),[j,N]=f.useState({busy:!1,msg:null,ok:!1}),I=f.useMemo(()=>c==null?`${e??"none"}:none`:`${e??"none"}:${c.cadence}:${c.hour1}:${c.hour2}:${c.botDigest}`,[c,e]);f.useEffect(()=>{if(u(""),N({busy:!1,msg:null,ok:!1}),c==null){h("daily"),x(9),b(16),k(!1);return}h(c.cadence),x(c.hour1),b(c.hour2),k(c.botDigest)},[I]),f.useEffect(()=>{s.isSuccess&&u("")},[s.isSuccess,s.data]);const S=(i==null?void 0:i.workspaceName)??n??"this workspace";if(e==null||i==null)return t.jsx(gc,{title:"Slack digest",failed:r.isError});const T=d.trim(),$=c==null&&T==="",P=c==null&&i.configuredCount>=i.cap,C=T!==""||c!=null&&(m!==c.cadence||g!==c.hour1||y!==c.hour2||w!==c.botDigest),L=()=>{const M={cadence:m,hour1:g,hour2:y,botDigest:w};T!==""&&(M.webhookUrl=T),s.mutate(M)},F=async()=>{N({busy:!0,msg:null,ok:!1});try{const M=await he.testSlackDigest(e);N({busy:!1,ok:M.sent,msg:M.sent?"Sent — check Slack.":M.message??"Not sent."})}catch(M){N({busy:!1,ok:!1,msg:M.message})}};return t.jsxs(Qr,{title:"Slack digest",desc:t.jsxs(t.Fragment,{children:["Posts your Pending board for this workspace to a Slack channel on a schedule: your turn, then each Pending tab, top 5 each, every PR once. A short sprint summary follows. Links open the app."," ",t.jsx("span",{className:"font-medium",children:"Every workspace with a digest writes its own sprint summary on every send"}),", so at most ",i.cap," can have one. A summary costs nothing when the workspace’s activity has not changed."]}),children:[s.isError&&t.jsx("p",{className:"rounded bg-red-50 px-2 py-1 text-xs text-red-600 dark:bg-red-950 dark:text-red-300",children:s.error.message}),a.isError&&t.jsx("p",{className:"rounded bg-red-50 px-2 py-1 text-xs text-red-600 dark:bg-red-950 dark:text-red-300",children:a.error.message}),c==null&&t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:"This workspace receives no digest. Add a webhook below to start."}),t.jsx(rr,{label:"Incoming webhook URL",hint:c!=null?t.jsx("span",{className:"text-emerald-500",children:"A webhook is stored. Enter a new URL to replace it."}):"Create one at api.slack.com/apps → Incoming Webhooks.",children:t.jsx("input",{type:"url",className:Bn,placeholder:c!=null?"•••••••• (unchanged)":"https://hooks.slack.com/services/…",value:d,onChange:M=>u(M.target.value)})}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(rr,{label:"Cadence",children:t.jsxs("select",{className:Bn,value:m,onChange:M=>h(M.target.value),children:[t.jsx("option",{value:"off",children:"Off (paused, channel kept)"}),t.jsx("option",{value:"daily",children:"Daily"}),t.jsx("option",{value:"twice_daily",children:"Twice daily"})]})}),m!=="off"&&t.jsx(rr,{label:"Send at",hint:(c==null?void 0:c.timezone)??"server time",children:t.jsx("select",{className:Bn,value:g,onChange:M=>x(Number(M.target.value)),children:aN.map(M=>t.jsx("option",{value:M,children:oN(M)},M))})}),m==="twice_daily"&&t.jsx(rr,{label:"And at",children:t.jsx("select",{className:Bn,value:y,onChange:M=>b(Number(M.target.value)),children:aN.map(M=>t.jsx("option",{value:M,children:oN(M)},M))})})]}),t.jsxs("label",{className:"flex items-start gap-2 text-xs",children:[t.jsx("input",{type:"checkbox",className:"mt-0.5",checked:w,onChange:M=>k(M.target.checked)}),t.jsxs("span",{children:[t.jsx("span",{className:"font-medium text-gray-700 dark:text-gray-200",children:"Include a review-bot summary"}),t.jsx("span",{className:"block text-[11px] text-gray-400",children:"Adds a deterministic bots block — volume · acted-on · untouched — to this workspace’s digest. Other workspaces’ digests are unaffected; each one decides for itself."})]})]}),t.jsxs("p",{className:`text-[11px] ${P?"text-red-500":"text-gray-500 dark:text-gray-400"}`,children:[i.configuredCount," of ",i.cap," workspaces"," ",i.configuredCount===1?"has":"have"," a digest, each its own report on every send.",P?` At the maximum — stop one from that workspace’s settings before adding ${S}.`:""]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(ja,{dirty:C&&!$&&!P,saving:s.isPending,onClick:L}),$&&C&&t.jsx("span",{className:"text-[11px] text-red-500",children:"A webhook URL is required."})]}),c!=null&&t.jsxs("div",{className:"flex flex-wrap items-center gap-2 border-t border-gray-100 pt-3 dark:border-gray-800",children:[t.jsx("button",{type:"button",onClick:()=>void F(),disabled:j.busy,className:"rounded border border-gray-300 px-3 py-1 text-xs font-medium text-gray-600 hover:bg-gray-100 disabled:opacity-40 dark:border-gray-700 dark:text-gray-300 dark:hover:bg-gray-800",children:j.busy?"Sending…":"Send test"}),j.msg!=null&&t.jsx("span",{className:`text-[11px] ${j.ok?"text-emerald-500":"text-gray-500 dark:text-gray-400"}`,children:j.msg}),c.lastSentAt!=null&&t.jsxs("span",{className:"text-[11px] text-gray-400",children:["Last sent ",new Date(c.lastSentAt).toLocaleString()]}),t.jsx("button",{type:"button",onClick:()=>a.mutate(),disabled:a.isPending,className:"ml-auto text-[11px] text-gray-400 underline hover:text-red-500 disabled:opacity-50",title:"Delete this workspace's channel and stop the digest. Use cadence 'Off' to pause without losing the webhook.",children:a.isPending?"Stopping…":"Stop sending (delete the channel)"})]})]})}const A0="rounded border border-gray-300 px-2 py-0.5 text-xs text-gray-700 hover:border-gray-400 disabled:cursor-not-allowed disabled:opacity-40 dark:border-gray-700 dark:text-gray-200 dark:hover:border-gray-500";function pQ({workspaceId:e,jira:n}){var j;const r=Ey(e),s=tt({mutationFn:()=>he.jiraFields(e)}),a=((j=s.data)==null?void 0:j.workspaceId)===e?s.data.fields:null,i={email:f.useId(),token:f.useId()},[c,d]=f.useState(n.email??""),[u,m]=f.useState(""),[h,g]=f.useState(!1),x=`${e}:${n.email??""}:${n.hasToken}`;f.useEffect(()=>{d(n.email??""),m(""),g(!1)},[x]);const y=u.trim(),b=c.trim()!==(n.email??"")||y!=="",w=!n.hasToken||h,k=()=>r.mutate({jira:{email:c.trim()===""?null:c.trim(),...y!==""?{token:y}:{}}});return t.jsxs("div",{className:"space-y-2.5 rounded border border-gray-200 p-2.5 dark:border-gray-800",children:[t.jsxs("div",{children:[t.jsx("h4",{className:"text-xs font-semibold text-gray-800 dark:text-gray-100",children:"Jira API access (optional)"}),t.jsx("p",{className:"mt-0.5 text-xs text-gray-500 dark:text-gray-400",children:"Lets Claude Review fill in a detected ticket’s title, description and acceptance criteria. You pick the criteria field per ticket there. A saved token is never shown again."})]}),t.jsx(rr,{label:"Email",htmlFor:i.email,hint:"Needed for Jira Cloud. Leave blank for a Data Center personal access token.",children:t.jsx("input",{id:i.email,type:"email",autoComplete:"off",className:Bn,placeholder:"you@example.com",value:c,onChange:N=>d(N.target.value)})}),w?t.jsx(rr,{label:"API token",htmlFor:i.token,hint:n.hasToken?"The new token replaces the saved one when you save.":"A Jira Cloud API token, or a Data Center personal access token.",children:t.jsx("input",{id:i.token,type:"password",autoComplete:"new-password",className:Bn,value:u,onChange:N=>m(N.target.value)})}):t.jsxs("div",{className:"flex flex-col gap-1 text-xs",children:[t.jsx("span",{className:"font-medium text-gray-600 dark:text-gray-300",children:"API token"}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-gray-700 dark:text-gray-200",children:"Saved"}),t.jsx("button",{type:"button",className:A0,onClick:()=>g(!0),children:"Replace"}),t.jsx("button",{type:"button",className:A0,disabled:r.isPending,onClick:()=>r.mutate({jira:{clearToken:!0}}),children:"Remove"})]})]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("button",{type:"button",className:A0,disabled:!n.hasToken||s.isPending,onClick:()=>s.mutate(),children:s.isPending?"Checking…":"Check connection"}),!n.hasToken&&t.jsx("span",{className:"text-[11px] text-gray-500 dark:text-gray-400",children:"Save a token first."}),a!=null&&t.jsx("span",{className:"text-[11px] text-emerald-700 dark:text-emerald-400",children:"Connected. Jira accepted the saved token."})]}),s.isError&&t.jsx("p",{className:"text-xs text-red-600 dark:text-red-400",children:s.error.message}),t.jsx(ja,{dirty:b,saving:r.isPending,onClick:k}),r.isError&&t.jsx("p",{className:"text-xs text-red-600 dark:text-red-400",children:r.error.message})]})}const mQ={jira:"https://your-org.atlassian.net",linear:"https://linear.app/your-workspace"};function gQ(){var N;const{workspaceId:e}=Ki(),n=ZR(e!=null,e),r=Ey(e),s=n.data,a=Dr().enabled,[i,c]=f.useState(""),[d,u]=f.useState(""),[m,h]=f.useState(""),[g,x]=f.useState("title_branch"),y=s?`${e??"none"}:${s.issue.provider??"none"}:${s.issue.baseUrl??"none"}:${s.issue.projectKeys.join(",")}:${s.issue.matchScope}`:`${e??"none"}:pending`;if(f.useEffect(()=>{s!=null&&(c(s.issue.provider??""),u(s.issue.baseUrl??""),h(s.issue.projectKeys.join(", ")),x(s.issue.matchScope))},[y]),e==null||s==null)return t.jsx(gc,{title:"Issue tracker",failed:n.isError});const b=s.issue,w=m.split(/[\s,]+/).map(I=>I.trim().toUpperCase()).filter(I=>I!==""),k=w.length>0,j=(i||null)!==b.provider||d.trim()!==(b.baseUrl??"")||w.join(",")!==b.projectKeys.join(",")||g!==b.matchScope;return t.jsxs(Qr,{title:"Issue tracker",desc:"Link Jira/Linear tickets detected in a PR’s title or branch into the PR details, for this workspace’s repos only. Other workspaces are unaffected — each one points at its own tracker, or none.",children:[t.jsx(rr,{label:"Provider",children:t.jsxs("select",{className:Bn,value:i,onChange:I=>c(I.target.value),children:[t.jsx("option",{value:"",children:"None"}),t.jsx("option",{value:"jira",children:"Jira"}),t.jsx("option",{value:"linear",children:"Linear"})]})}),i!==""&&t.jsxs(t.Fragment,{children:[t.jsx(rr,{label:"Base URL",hint:i==="jira"?`Tickets link to {base}/browse/KEY-123.${(N=s.jira)!=null&&N.hasToken?" Moving to a different Jira site removes the saved API token.":""}`:"Tickets link to {base}/issue/KEY-123.",children:t.jsx("input",{type:"url",className:Bn,placeholder:mQ[i],value:d,onChange:I=>u(I.target.value)})}),t.jsx(rr,{label:"Project keys",hint:"Optional, comma-separated (e.g. ENG, PROJ). When set, a ticket is only detected if its prefix is on this list — the most reliable way to avoid false matches like GPT-4 or node-18. Leave blank to fall back to detecting uppercase keys in the PR title.",children:t.jsx("input",{type:"text",className:Bn,placeholder:"ENG, PROJ",value:m,onChange:I=>h(I.target.value)})}),t.jsx(rr,{label:"Where to look",hint:k?"Detection never reads commit messages — only the PR title and, in the second mode, the head branch name.":"Only has an effect when project keys are set above: without them the branch is never scanned, because a lowercase eng-123 is indistinguishable from node-18 or release-2. Detection never reads commit messages.",children:t.jsxs("select",{className:Bn,value:g,disabled:!k,onChange:I=>x(I.target.value),children:[t.jsx("option",{value:"title",children:"PR title only"}),t.jsx("option",{value:"title_branch",children:"PR title and branch name (default)"})]})})]}),t.jsx(ja,{dirty:j,saving:r.isPending,onClick:()=>r.mutate({issue:{provider:i===""?null:i,baseUrl:d.trim()===""?null:d.trim(),projectKeys:w,matchScope:g}})}),r.isError&&t.jsx("p",{className:"text-[11px] text-red-500",children:r.error.message}),a&&b.provider==="jira"&&i==="jira"&&(b.baseUrl??"")!==""&&s.jira!=null&&t.jsx(pQ,{workspaceId:e,jira:s.jira})]})}function JR(e){return["workspace-auto-review",dt(e)]}function fQ(e,n){return Oe({queryKey:JR(n),queryFn:n!=null?()=>he.workspaceAutoReview(n):Ct,staleTime:6e4})}function xQ(e){const n=He();return tt({mutationFn:r=>{if(e==null)throw new Error("Workspace not resolved yet.");return he.setWorkspaceAutoReview(e,r)},onSuccess:r=>{n.setQueryData(JR(r.workspaceId),r)}})}function yQ(){var h,g;const{workspaceId:e}=Ki(),n=fQ(!0,e),r=xQ(e),s=Dr(),a=s.ready,i=((h=n.data)==null?void 0:h.autoReview)??null,c=(i==null?void 0:i.enabled)===!0,[d,u]=f.useState(c);if(f.useEffect(()=>{u(c)},[e,c]),e==null||n.data==null)return t.jsx(gc,{title:"Auto Claude review",failed:n.isError});const m=(i==null?void 0:i.dailyCap)??20;return t.jsxs(Qr,{title:"Auto Claude review",desc:"Claude reviews each new PR a person opens in this workspace, once, with the same model and budget as the Review button. It runs on your own Claude Code or Anthropic API key.",children:[t.jsxs("label",{className:"flex items-start gap-2 text-xs",children:[t.jsx("input",{type:"checkbox",className:"mt-0.5",checked:d,onChange:x=>u(x.target.checked)}),t.jsxs("span",{children:[t.jsx("span",{className:"font-medium text-gray-700 dark:text-gray-200",children:"Review new PRs automatically"}),t.jsxs("span",{className:"mt-0.5 block text-xs text-gray-500 dark:text-gray-400",children:["Only PRs opened after you turn this on. Drafts wait until they are ready. Bots are skipped. At most ",m," a day (UTC); the rest wait for the next day. Reviews you start yourself always go first."]})]})]}),!a&&t.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs text-gray-600 dark:text-gray-300",children:[t.jsx("span",{children:"Nothing is reviewed until AI is set up."}),s.runtime!=="ready"?t.jsx(dC,{}):t.jsx(cC,{})]}),c&&(i==null?void 0:i.enabledAt)!=null&&t.jsxs("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:["On since ",Cn(i.enabledAt),"."]}),t.jsx(ja,{dirty:d!==c,saving:r.isPending,onClick:()=>r.mutate({enabled:d})}),r.isError&&t.jsx("div",{className:"text-xs text-red-500",children:((g=r.error)==null?void 0:g.message)??"Couldn’t save."})]})}function bQ(){const e=He();return tt({mutationFn:n=>he.setBenchmarkConsent(n),onSuccess:()=>{e.invalidateQueries({queryKey:["me"]})}})}function vQ(){var a;const{data:e}=In(),n=(e==null?void 0:e.benchmarkOptIn)??!1,r=bQ(),s=r.isPending?r.variables??n:n;return t.jsxs(Qr,{title:"Contribute to the bot benchmark",desc:"Opt in to share anonymous, aggregate stats about how your review bots perform, so we can build a neutral cross-organisation benchmark — e.g. “your CodeRabbit is 38% acted-on vs a 45% peer median”. Off by default.",children:[t.jsxs("label",{className:"flex cursor-pointer items-start gap-2",children:[t.jsx("input",{type:"checkbox",className:"mt-0.5 h-4 w-4 shrink-0 accent-sky-600",checked:s,disabled:r.isPending,onChange:i=>r.mutate(i.target.checked)}),t.jsx("span",{className:"text-xs text-gray-600 dark:text-gray-300",children:s?"Contributing anonymous weekly bot stats to the benchmark network.":"Not contributing — turn on to help build the benchmark."})]}),t.jsxs("ul",{className:"mt-1 space-y-1 text-[11px] leading-relaxed text-gray-500 dark:text-gray-400",children:[t.jsxs("li",{children:[t.jsx("span",{className:"font-medium text-gray-600 dark:text-gray-300",children:"What’s shared:"})," ","per-vendor weekly counts only — threads, comments, acted-on, untouched, and your org-size band. Known vendors only (CodeRabbit, Copilot, …)."]}),t.jsxs("li",{children:[t.jsx("span",{className:"font-medium text-gray-600 dark:text-gray-300",children:"What’s never shared:"})," ","no code, comment text, PR titles, logins, or repository names. In-house bots are excluded."]}),t.jsxs("li",{children:[t.jsx("span",{className:"font-medium text-gray-600 dark:text-gray-300",children:"Reversible:"})," turning this off immediately deletes everything you’ve contributed. Aggregates are only ever shown across many organisations (k-anonymised)."]})]}),r.isError&&t.jsx("div",{className:"text-[11px] text-red-500",children:((a=r.error)==null?void 0:a.message)??"Couldn’t update your choice."})]})}function kQ(e){const n=e.trim();if(n==="")return{value:null};if(!/^\d+$/.test(n))return{error:"Enter a whole number of lines, or leave empty."};const r=Number(n);return!Number.isSafeInteger(r)||r<=0?{error:"Enter a number greater than zero."}:{value:r}}function wQ(){var m;const{data:e}=In(),n=SL(),r=e==null||e.largePrCodeLocThresholdIsDefault?null:e.largePrCodeLocThreshold,s=r==null?"":String(r),[a,i]=f.useState(s);f.useEffect(()=>{i(s)},[s]);const c=kQ(a),d="error"in c?c.error:null,u=a.trim()!==s;return t.jsxs(Qr,{title:"Large pull requests",desc:"Flag a pull request once its code churn passes this many lines. Documentation, config, lockfiles and generated or vendored files don’t count — a 4,000-line lockfile bump is not a large PR.",children:[t.jsx(rr,{label:"Threshold (lines of code changed)",htmlFor:"large-pr-threshold",hint:t.jsxs(t.Fragment,{children:["Leave empty to use the default of"," ",hd.toLocaleString()," lines. Applies to every workspace, and takes effect everywhere the moment you save."]}),children:t.jsx("input",{id:"large-pr-threshold",type:"text",inputMode:"numeric",className:`${Bn} max-w-[10rem]`,value:a,placeholder:`Default (${hd.toLocaleString()})`,onChange:h=>i(h.target.value),"aria-invalid":d!=null,"aria-describedby":d!=null?"large-pr-threshold-error":void 0})}),d!=null&&t.jsx("div",{id:"large-pr-threshold-error",className:"text-[11px] text-red-500",children:d}),t.jsx(ja,{dirty:u&&d==null,saving:n.isPending,onClick:()=>{d!=null||!("value"in c)||n.mutate(c.value)}}),n.isError&&t.jsx("div",{className:"text-[11px] text-red-500",children:((m=n.error)==null?void 0:m.message)??"Couldn’t save your threshold."})]})}const jQ=[{value:"cautious",label:"Cautious",desc:"Fewer pull requests count as low. Good when a mistake is expensive to undo."},{value:"balanced",label:"Balanced",desc:"The default. On a typical repository about a third of open pull requests land in each level."},{value:"relaxed",label:"Relaxed",desc:"More pull requests count as low. Good for a fast-moving repository you can roll back easily."}],NQ={db_migration:"Database migrations",db_schema:"Database schemas and models",sql:"SQL files",public_types:"Published type definitions",idl:"Service contracts (protobuf, GraphQL, Thrift)",openapi:"API descriptions (OpenAPI, Swagger)",infra:"Infrastructure (Terraform, Helm, Kubernetes)",auth:"Auth and security code",ci:"CI workflows",deps:"Dependencies"};function SQ(){var b;const{data:e}=In(),n=ey(),r=RL(),s=(e==null?void 0:e.blastRadius)??null,[a,i]=f.useState(n.sensitivity),[c,d]=f.useState(n.surfacesOff),[u,m]=f.useState(n.showImpactNote),h=`${n.sensitivity}|${[...n.surfacesOff].sort().join(",")}|${n.showImpactNote}`;f.useEffect(()=>{i(n.sensitivity),d(n.surfacesOff),m(n.showImpactNote)},[h]);const x=`${a}|${[...c].sort().join(",")}|${u}`!==h,y=w=>d(k=>k.includes(w)?k.filter(j=>j!==w):[...k,w]);return t.jsxs(Qr,{title:"Blast radius",desc:"How far a pull request can reach — shown beside each one as Low, Medium or High, so you can tell at a glance which need a real review and which just need a look. It reads what a change touches, not how big it is: a four-line database migration is high, a 2,000-line documentation update is low.",children:[t.jsx(rr,{label:"Sensitivity",htmlFor:"blast-sensitivity",hint:t.jsxs(t.Fragment,{children:[s==null?"Currently the product default. ":"","Applies to every workspace, and takes effect everywhere the moment you save."]}),children:t.jsx("div",{id:"blast-sensitivity",className:"flex flex-col gap-1.5",children:jQ.map(w=>t.jsxs("label",{className:"flex cursor-pointer items-start gap-2 text-[12px]",children:[t.jsx("input",{type:"radio",name:"blast-sensitivity",className:"mt-0.5",checked:a===w.value,onChange:()=>i(w.value)}),t.jsxs("span",{children:[t.jsx("span",{className:"font-medium text-gray-700 dark:text-gray-200",children:w.label}),t.jsxs("span",{className:"text-gray-500 dark:text-gray-400",children:[" — ",w.desc]})]})]},w.value))})}),t.jsx(rr,{label:"Ignore these when judging reach",htmlFor:"blast-surfaces",hint:t.jsxs(t.Fragment,{children:["Touching one of these normally makes a pull request high, however small it is. Switch one off if it is simply what your repository is made of — a project whose product"," ",t.jsx("em",{children:"is"})," a database schema would otherwise see almost every change called high."]}),children:t.jsx("div",{id:"blast-surfaces",className:"flex flex-col gap-1",children:VN.map(w=>t.jsxs("label",{className:"flex cursor-pointer items-center gap-2 text-[12px]",children:[t.jsx("input",{type:"checkbox",checked:c.includes(w),onChange:()=>y(w)}),t.jsx("span",{className:"text-gray-600 dark:text-gray-300",children:NQ[w]})]},w))})}),t.jsx(rr,{label:"AI impact note",htmlFor:"blast-impact-note",hint:"A short AI-written note on the pull request pane saying what a change could break. It is never generated until you ask for it, and turning this off removes the button too.",children:t.jsxs("label",{className:"flex cursor-pointer items-center gap-2 text-[12px]",children:[t.jsx("input",{id:"blast-impact-note",type:"checkbox",checked:u,onChange:w=>m(w.target.checked)}),t.jsx("span",{className:"text-gray-600 dark:text-gray-300",children:"Offer the impact note on pull requests"})]})}),t.jsx(ja,{dirty:x,saving:r.isPending,onClick:()=>{const w=a==="balanced"&&c.length===0&&u;r.mutate(w?null:{sensitivity:a,surfacesOff:c,...u?{}:{showImpactNote:!1}})}}),r.isError&&t.jsx("div",{className:"text-[11px] text-red-500",children:((b=r.error)==null?void 0:b.message)??"Couldn’t save your blast-radius settings."})]})}const CQ=["my-turn-settings"];function RQ(){const e=He();return tt({mutationKey:CQ,mutationFn:n=>he.setMyTurnSettings(n),onSuccess:n=>{e.setQueryData(["me"],r=>r!=null?{...r,myTurnSettings:n.myTurnSettings}:r),e.invalidateQueries({queryKey:["me"]}),e.invalidateQueries({queryKey:["my-turn"]}),e.invalidateQueries({queryKey:["attention-cards"]}),e.invalidateQueries({queryKey:["daily-brief"]}),e.invalidateQueries({queryKey:["work-plan"]})}})}const IQ="settings-my-turn",ax="settings-my-turn-heading",Yu="text-xs font-medium text-gray-600 dark:text-gray-300",Ni="text-[12px] text-gray-500 dark:text-gray-400",iN=e=>`rounded-full border px-2 py-0.5 text-[12px] font-medium transition-colors ${e?"border-gray-400 bg-gray-100 text-gray-800 dark:border-gray-500 dark:bg-gray-800 dark:text-gray-100":"border-gray-300 text-gray-600 hover:border-gray-400 dark:border-gray-700 dark:text-gray-300"}`;function TQ(){var T;const{data:e}=In(),n=Dr().enabled,r=RQ(),s=(e==null?void 0:e.myTurnSettings)??null,[a,i]=f.useState(()=>Mw(s)),c=JSON.stringify(px(s));f.useEffect(()=>{i(Mw(s))},[c]);const d=f.useMemo(()=>new Set(n?[]:["claude_review"]),[n]),u=EL.filter($=>!d.has($.reason)),m=a.order.filter($=>!d.has($)),h=f.useRef(new Map),g=f.useRef(null),[x,y]=f.useState("");f.useEffect(()=>{var L;const $=g.current;if($==null)return;g.current=null;const P=h.current.get(`${$.reason}:${$.dir}`),C=h.current.get(`${$.reason}:${-$.dir}`);(L=P!=null&&!P.disabled?P:C)==null||L.focus(),y(qL(a.order,$.reason,Ci[$.reason],d))},[a.order,d]);const b=f.useRef(null),w=($,P)=>{g.current={reason:$,dir:P},i(C=>({...C,order:DL(C.order,$,P,d)}))},k=($,P)=>i(C=>({...C,show:{...C.show,[$]:P}})),j=JN(a.weights),N=FL(a),I=LL(a,s),S=j==="balanced"&&a.order.every(($,P)=>$===Oi[P]);return t.jsxs("section",{id:IQ,"aria-labelledby":ax,className:"border-b border-gray-100 pb-4 last:border-b-0 dark:border-gray-800",children:[t.jsx("h3",{id:ax,tabIndex:-1,className:"text-sm font-semibold text-gray-800 outline-none dark:text-gray-100",children:"My Turn"}),t.jsx("p",{className:"mt-0.5 text-xs text-gray-500 dark:text-gray-400",children:"What counts as your turn, and how Pending orders cards. Applies to every workspace."}),t.jsxs("div",{className:"mt-2.5 space-y-4",children:[t.jsxs("fieldset",{className:"space-y-1.5",children:[t.jsx("legend",{className:Yu,children:"Show in My Turn"}),t.jsx("div",{className:"grid gap-x-4 gap-y-1.5 sm:grid-cols-2",children:u.map(({reason:$,hint:P})=>t.jsxs("label",{className:"flex cursor-pointer items-start gap-2",children:[t.jsx("input",{type:"checkbox",className:"mt-0.5",checked:a.show[$],onChange:C=>k($,C.target.checked)}),t.jsxs("span",{className:"min-w-0",children:[t.jsx("span",{className:"block text-[12px] font-medium text-gray-700 dark:text-gray-200",children:Ci[$]}),t.jsx("span",{className:`block ${Ni}`,children:P})]})]},$))}),t.jsx("p",{className:Ni,children:"Switching a type off removes it from My Turn, its counts and its notifications. Review requests and new PRs can still show in Waiting on review."})]}),t.jsxs("fieldset",{className:"space-y-1.5",children:[t.jsx("legend",{className:Yu,children:"Add to My Turn"}),t.jsx("div",{className:"grid gap-x-4 gap-y-1 sm:grid-cols-2",children:AL.map($=>t.jsxs("label",{className:"flex cursor-pointer items-center gap-2 text-[12px]",children:[t.jsx("input",{type:"checkbox",checked:a.show[$],onChange:P=>k($,P.target.checked)}),t.jsx("span",{className:"text-gray-700 dark:text-gray-200",children:Ci[$]})]},$))}),t.jsxs("div",{role:"radiogroup","aria-label":Ci.trunk_red,className:"space-y-1",children:[t.jsx("div",{className:"text-[12px] font-medium text-gray-700 dark:text-gray-200",children:Ci.trunk_red}),t.jsx("div",{className:"flex flex-wrap gap-x-4 gap-y-1",children:ZN.map($=>t.jsxs("label",{className:"flex cursor-pointer items-center gap-1.5 text-[12px]",children:[t.jsx("input",{type:"radio",name:"my-turn-trunk-scope",checked:a.trunkScope===$,onChange:()=>i(P=>({...P,trunkScope:$}))}),t.jsx("span",{className:"text-gray-700 dark:text-gray-200",children:ML[$]})]},$))})]}),t.jsx("p",{className:Ni,children:"These move out of their own tab into My turn, and notify you unless the repo is muted."})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx("h4",{className:Yu,children:"Order of My turn"}),t.jsx("p",{className:Ni,children:"My turn groups cards by type, in this order."}),t.jsx("ol",{className:"space-y-0.5",children:m.map(($,P)=>{const C=Ci[$];return t.jsxs("li",{className:"flex items-center gap-2 rounded px-1 text-[12px] hover:bg-gray-50 dark:hover:bg-gray-800/60",children:[t.jsx("span",{className:"w-5 shrink-0 text-right tabular-nums text-gray-500 dark:text-gray-400",children:P+1}),t.jsxs("span",{className:"min-w-0 flex-1 text-gray-700 dark:text-gray-200",children:[C,OL(a,$)&&t.jsx("span",{className:"ml-1 text-gray-500 dark:text-gray-400",children:"(off)"})]}),[-1,1].map(L=>t.jsx("button",{type:"button",ref:F=>{const M=`${$}:${L}`;F?h.current.set(M,F):h.current.delete(M)},onClick:()=>w($,L),disabled:L===-1?P===0:P===m.length-1,"aria-label":`Move “${C}” ${L===-1?"up":"down"}`,className:"rounded p-1.5 text-gray-600 hover:bg-gray-100 hover:text-gray-900 disabled:cursor-default disabled:opacity-30 disabled:hover:bg-transparent dark:text-gray-300 dark:hover:bg-gray-800 dark:hover:text-gray-50",children:t.jsx(_s,{dir:L===-1?"up":"down",size:12})},L))]},$)})}),t.jsx("p",{"aria-live":"polite",className:"sr-only",children:x})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx("h4",{className:Yu,children:"How Pending ranks cards"}),t.jsx("p",{className:Ni,children:"Every Pending tab ranks its cards by these three. In My turn they rank cards within each type."}),t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[t.jsx("div",{role:"radiogroup","aria-label":"Ranking preset",className:"flex flex-wrap gap-1.5",children:XN.map($=>t.jsxs("label",{className:`${iN(j===$)} relative cursor-pointer has-[:focus-visible]:ring-2 has-[:focus-visible]:ring-sky-500`,children:[t.jsx("input",{type:"radio",name:"my-turn-preset",className:"sr-only",checked:j===$,onChange:()=>i(P=>({...P,weights:k2($)}))}),b2[$]]},$))}),j==="custom"&&t.jsx("span",{className:iN(!0),children:"Custom"})]}),j!=="custom"&&t.jsx("p",{className:Ni,children:PL[j]}),t.jsx("div",{className:"space-y-1",children:ty.map($=>{const P=`my-turn-weight-${$}`,C=a.weights[$];return t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("label",{htmlFor:P,className:"w-36 shrink-0 text-[12px] text-gray-700 sm:w-44 dark:text-gray-200",children:$s[$]}),t.jsx("input",{id:P,type:"range",min:0,max:100,step:10,value:C,"aria-valuetext":`${C} percent`,onChange:L=>{const F=WL(b.current,a.weights,$,Number(L.target.value));b.current=F,i(M=>({...M,weights:F.to}))},className:"budget-range min-w-0 flex-1"}),t.jsxs("output",{htmlFor:P,className:"w-10 shrink-0 text-right text-xs tabular-nums text-gray-800 dark:text-gray-100",children:[C,"%"]})]},$)})}),t.jsx("p",{className:Ni,children:"They always add up to 100%."}),t.jsx("button",{type:"button",onClick:()=>i(UL),disabled:S,className:"rounded border border-gray-300 px-2 py-0.5 text-[12px] font-medium text-gray-600 hover:bg-gray-50 disabled:cursor-default disabled:opacity-40 dark:border-gray-700 dark:text-gray-300 dark:hover:bg-gray-800",children:"Reset"})]}),N!=null&&t.jsx("p",{className:"text-[12px] text-red-600 dark:text-red-400",role:"alert",children:N}),t.jsx(ja,{dirty:I&&N==null,saving:r.isPending,onClick:()=>r.mutate(v2(a))}),r.isError&&t.jsx("p",{className:"text-[12px] text-red-600 dark:text-red-400",role:"alert",children:((T=r.error)==null?void 0:T.message)??"Couldn’t save your My Turn settings."})]})]})}function $Q(e){const n={};return e.workspaceDirty&&(n.muted=e.muted),e.reposDirty&&(n.mutedRepoIds=[...e.repoIds].sort((r,s)=>r-s)),n}function _Q(e,n){return e.length===n.size&&e.every(r=>n.has(r))}function PQ(){var j,N;const{workspaceId:e}=Ki(),n=xa(),r=xn(),{setWorkspacePendingMute:s}=Ix(),a=((j=n.data)==null?void 0:j.find(I=>I.id===e))??null,i=(a==null?void 0:a.pendingMuted)??!1,c=f.useMemo(()=>new Set((a==null?void 0:a.mutedRepoIds)??[]),[a==null?void 0:a.mutedRepoIds]),d=f.useMemo(()=>(r.data??[]).filter(I=>I.workspaceId===e).slice().sort((I,S)=>I.fullName.localeCompare(S.fullName)),[r.data,e]),[u,m]=f.useState(i),[h,g]=f.useState([...c]),x=`${e}|${i}|${[...c].sort((I,S)=>I-S).join(",")}`;if(f.useEffect(()=>{m(i),g([...c])},[x]),e==null||a==null)return t.jsx(gc,{title:"Pending mute",failed:n.isError});const y=u!==i,b=!_Q(h,c),w=y||b,k=I=>g(S=>S.includes(I)?S.filter(T=>T!==I):[...S,I]);return t.jsxs(Qr,{title:"Pending mute",desc:t.jsxs(t.Fragment,{children:["Muted items ",t.jsx("span",{className:"font-medium",children:"stay on the Pending board"})," — they just stop being flagged as your turn. They no longer trigger notifications and no longer count towards “needs your attention”; they move into the broader “review or reply” list. Red builds and stalled PRs in their own tabs are not affected; types you added to My Turn are muted like the rest."]}),children:[t.jsxs("label",{className:"flex items-start gap-2 text-xs",children:[t.jsx("input",{type:"checkbox",className:"mt-0.5",checked:u,onChange:I=>m(I.target.checked)}),t.jsxs("span",{children:[t.jsx("span",{className:"font-medium text-gray-700 dark:text-gray-200",children:"Mute this whole workspace"}),t.jsx("span",{className:"mt-0.5 block text-[11px] text-gray-400",children:"Every repository in it, including ones added later."})]})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx("div",{className:"text-xs font-medium text-gray-600 dark:text-gray-300",children:"Mute individual repositories"}),u&&t.jsx("p",{className:"text-[11px] text-gray-400",children:"The whole workspace is muted, so these are already covered. Their own settings are kept, and come back if you un-mute the workspace."}),r.isLoading?t.jsx("p",{className:"text-[11px] text-gray-400",children:"Loading this workspace’s repositories…"}):d.length===0?t.jsx("p",{className:"text-[11px] text-gray-400",children:"This workspace has no repositories yet."}):t.jsx("div",{className:"max-h-44 space-y-1 overflow-auto rounded border border-gray-200 p-2 dark:border-gray-700",children:d.map(I=>t.jsxs("label",{className:"flex items-center gap-2 text-xs",children:[t.jsx("input",{type:"checkbox",checked:h.includes(I.id),onChange:()=>k(I.id)}),t.jsx("span",{className:"truncate text-gray-700 dark:text-gray-200",children:I.fullName})]},I.id))})]}),t.jsx(ja,{dirty:w,saving:s.isPending,onClick:()=>s.mutate({id:e,patch:$Q({workspaceDirty:y,reposDirty:b,muted:u,repoIds:h})})}),t.jsx("p",{className:"text-[11px] text-gray-400",children:"Applies to this workspace only. Muting a repository follows the repository, so it keeps its setting if you move it to another workspace."}),s.isError&&t.jsx("div",{className:"text-[11px] text-red-500",children:((N=s.error)==null?void 0:N.message)??"Couldn’t save the mute."})]})}function lN(e){return`${String(Math.floor(e/60)).padStart(2,"0")}:${String(e%60).padStart(2,"0")}`}function nc(e){const n=/^(\d{1,2}):(\d{2})$/.exec(e.trim());if(!n)return null;const r=Number(n[1]),s=Number(n[2]);return r>24||s>59||r===24&&s!==0?null:r*60+s}function M0(e){var s;const n=e??{},r={};for(const a of so){const i=(s=n.budgets)==null?void 0:s[a];r[a]={good:(i==null?void 0:i.good)!=null?String(i.good):"",ok:(i==null?void 0:i.ok)!=null?String(i.ok):""}}return{timeZone:n.timeZone??"",days:[...n.days??Uo.days].sort((a,i)=>a-i),start:lN(n.startMinute??Uo.startMinute),end:lN(n.endMinute??Uo.endMinute),budgets:r}}function EQ(e,n){const r=[...new Set(e)].sort((a,i)=>a-i),s=[...new Set(n)].sort((a,i)=>a-i);return r.length===s.length&&r.every((a,i)=>a===s[i])}function bd(e){const n=e.trim();if(n==="")return;const r=Number(n);return Number.isFinite(r)?r:Number.NaN}function ox(e){const n={},r=e.timeZone.trim();r!==""&&(n.timeZone=r),EQ(e.days,Uo.days)||(n.days=[...new Set(e.days)].sort((u,m)=>u-m));const s=nc(e.start),a=nc(e.end),i=s??Number.NaN,c=a??Number.NaN;(i!==Uo.startMinute||c!==Uo.endMinute)&&(n.startMinute=i,n.endMinute=c);const d={};for(const u of so){const m=bd(e.budgets[u].good),h=bd(e.budgets[u].ok),g={};m!==void 0&&m!==Vs[u].good&&(g.good=m),h!==void 0&&h!==Vs[u].ok&&(g.ok=h),(g.good!==void 0||g.ok!==void 0)&&(d[u]=g)}return Object.keys(d).length>0&&(n.budgets=d),n}function AQ(e){if(e.days.length===0)return"Pick at least one working day.";if(nc(e.start)==null||nc(e.end)==null)return"Enter the working day as two times, like 09:00 and 18:00.";const n=ox(e),r=B$(n);if(r!=null)return r;for(const s of so){const a=bd(e.budgets[s].good)??Vs[s].good;if((bd(e.budgets[s].ok)??Vs[s].ok)<a)return"“Acceptable” cannot be tighter than “good”."}return null}function MQ(e,n){const r=s=>JSON.stringify({timeZone:s.timeZone??null,days:s.days?[...s.days].sort((a,i)=>a-i):null,startMinute:s.startMinute??null,endMinute:s.endMinute??null,budgets:so.map(a=>{var i,c,d,u;return[((c=(i=s.budgets)==null?void 0:i[a])==null?void 0:c.good)??null,((u=(d=s.budgets)==null?void 0:d[a])==null?void 0:u.ok)??null]})});return r(e)===r(n)}const LQ=[.5,1,1.5,2,3,4,5,6,7,8],eI=[1,1.5,2,3,4,5];function sm(e){return Math.round(e*2)/2}function FQ(e){const n=nc(e.start),r=nc(e.end);return n!=null&&r!=null&&r>n?(r-n)/60:(Uo.endMinute-Uo.startMinute)/60}function OQ(e){return Math.max(sm(5*e),...so.flatMap(n=>[Vs[n].good,Vs[n].ok]))}function DQ(e,n){var a,i,c,d;const r=OQ(e),s=new Set(LQ.filter(u=>u<e));for(const u of eI)s.add(sm(u*e));for(const u of so){s.add(Vs[u].good),s.add(Vs[u].ok);for(const m of[(i=(a=n==null?void 0:n.budgets)==null?void 0:a[u])==null?void 0:i.good,(d=(c=n==null?void 0:n.budgets)==null?void 0:c[u])==null?void 0:d.ok])typeof m=="number"&&m>=.5&&m<=r&&s.add(m)}return[...s].filter(u=>u>=.5).sort((u,m)=>u-m)}function cN(e,n){const r=e.length-1,s=e.indexOf(n);if(s!==-1)return{index:s,off:null};if(n<(e[0]??0))return{index:0,off:"below"};if(n>(e[r]??0))return{index:r,off:"above"};let a=0;for(let i=1;i<=r;i++)Math.abs((e[i]??0)-n)<Math.abs((e[a]??0)-n)&&(a=i);return{index:a,off:null}}function tI(e,n,r){const s=bd(e.budgets[n][r]);return s!==void 0&&Number.isFinite(s)?s:Vs[n][r]}function BQ(e,n,r,s){const a=tI(e,n,r==="good"?"ok":"good"),i=r==="good"?Math.min(s,a):Math.max(s,a),c=i===Vs[n][r]?"":String(i);return{...e,budgets:{...e.budgets,[n]:{...e.budgets[n],[r]:c}}}}function WQ(e,n){const r=e[e.length-1]??0;return`The mark under each track is the default; a wait left on it follows the default. The scale runs from half an hour to ${r===sm(5*n)?`5 working days (${ix(r)})`:ix(r)}.`}function ix(e){return e<1?`${Math.max(1,Math.round(e*60))}m`:`${Number(e.toFixed(2))}h`}function L0(e,n,r){return`${e} ${e===1?n:r}`}function qQ(e,n,r){const s=e<1?L0(Math.max(1,Math.round(e*60)),"working minute","working minutes"):L0(Number(e.toFixed(2)),"working hour","working hours");if(r!=null)return`${s}, beyond this scale`;for(const a of eI){if(sm(a*n)!==e)continue;const i=L0(a,"working day","working days");return a*n===e?`${s}, ${i}`:`${s}, about ${i}`}return s}const dN=14;function UQ({form:e,setForm:n,stored:r}){const s=FQ(e),a=DQ(s,r);return t.jsxs("div",{className:"text-xs",children:[t.jsx("div",{className:"mb-1 font-medium text-gray-600 dark:text-gray-300",children:"Budgets, in working hours"}),t.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)_minmax(0,1fr)] items-center gap-x-4 gap-y-2 sm:grid-cols-[8.5rem_minmax(0,1fr)_minmax(0,1fr)]",children:[t.jsx("span",{className:"hidden sm:block"}),t.jsx("span",{className:"text-[11px] font-medium text-gray-500 dark:text-gray-400",children:"Good"}),t.jsx("span",{className:"text-[11px] font-medium text-gray-500 dark:text-gray-400",children:"Acceptable"}),so.map(i=>t.jsxs(f.Fragment,{children:[t.jsx("span",{className:"col-span-2 text-xs text-gray-700 sm:col-span-1 dark:text-gray-200",children:sc[i]}),["good","ok"].map(c=>t.jsx(HQ,{m:i,k:c,form:e,setForm:n,steps:a,dayHours:s},c))]},i))]}),t.jsx("p",{className:"mt-1.5 text-xs text-gray-500 dark:text-gray-400",children:WQ(a,s)})]})}function HQ({m:e,k:n,form:r,setForm:s,steps:a,dayHours:i}){const c=f.useId(),d=tI(r,e,n),u=cN(a,d),m=Math.max(1,a.length-1),h=cN(a,Vs[e][n]).index/m;return t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("div",{className:"relative h-[22px] min-w-0 flex-1",children:[t.jsx("input",{id:c,type:"range",min:0,max:a.length-1,step:1,value:u.index,"aria-label":`${sc[e]}, ${n==="good"?"good":"acceptable"}`,"aria-valuetext":qQ(d,i,u.off),onChange:g=>{const x=a[Number(g.target.value)];x!=null&&s(y=>BQ(y,e,n,x))},className:"budget-range absolute inset-x-0 top-0"}),t.jsx("span",{"aria-hidden":!0,className:"absolute top-[15px] h-2 w-0.5 bg-gray-700 dark:bg-gray-300",style:{left:`calc(${h*100}% - ${h*dN}px + ${dN/2-1}px)`}})]}),t.jsxs("output",{htmlFor:c,className:"inline-flex w-12 shrink-0 items-center justify-end gap-0.5 text-xs tabular-nums text-gray-800 dark:text-gray-100",children:[ix(d),u.off!=null&&t.jsx(_s,{dir:u.off==="above"?"right":"left",size:10})]})]})}const nI="data-owns-escape";function zQ(e){const n=e==null?void 0:e.closest;return typeof n!="function"?!1:n.call(e,`[${nI}]`)!=null}const KQ={"Europe/Kiev":"Europe/Kyiv","Asia/Calcutta":"Asia/Kolkata","Asia/Saigon":"Asia/Ho_Chi_Minh","Asia/Katmandu":"Asia/Kathmandu","Asia/Rangoon":"Asia/Yangon","America/Godthab":"America/Nuuk","Pacific/Enderbury":"Pacific/Kanton","Atlantic/Faeroe":"Atlantic/Faroe","America/Buenos_Aires":"America/Argentina/Buenos_Aires","America/Catamarca":"America/Argentina/Catamarca","America/Cordoba":"America/Argentina/Cordoba","America/Jujuy":"America/Argentina/Jujuy","America/Mendoza":"America/Argentina/Mendoza","America/Indianapolis":"America/Indiana/Indianapolis","America/Louisville":"America/Kentucky/Louisville","America/Coral_Harbour":"America/Atikokan","Africa/Asmera":"Africa/Asmara","Pacific/Truk":"Pacific/Chuuk","Pacific/Ponape":"Pacific/Pohnpei"},cd="UTC",rI=["Etc/UTC","GMT"];function sp(e){return e===cd||rI.includes(e)?cd:KQ[e]??e}function GQ(e,n){var r;try{const s=(r=new Intl.DateTimeFormat("en-US",{timeZone:e,timeZoneName:"longOffset"}).formatToParts(n).find(u=>u.type==="timeZoneName"))==null?void 0:r.value;if(s==null)return null;if(s==="GMT")return{minutes:0,label:"UTC+0"};const a=/^GMT([+-])(\d{2}):(\d{2})$/.exec(s);if(a==null)return null;const i=Number(a[2]),c=Number(a[3]),d=(a[1]==="-"?-1:1)*(i*60+c);return{minutes:d,label:VQ(d)}}catch{return null}}function VQ(e){const n=e<0?"-":"+",r=Math.abs(e),s=Math.floor(r/60),a=r%60;return`UTC${n}${s}${a===0?"":`:${String(a).padStart(2,"0")}`}`}function QQ(e,n){const r=new Map([[cd,new Set(rI)]]);for(const a of e){const i=sp(a),c=r.get(i)??new Set;a!==i&&c.add(a),r.set(i,c)}const s=[...r.keys()].filter(a=>a!==cd).sort((a,i)=>a.localeCompare(i));return[cd,...s].map(a=>{const i=GQ(a,n);return{value:a,aliases:[...r.get(a)??[]],offset:(i==null?void 0:i.label)??"",offsetMinutes:(i==null?void 0:i.minutes)??null}})}let Xu=null;function uN(){if(Xu!=null)return Xu;let e=[];try{const n=Intl.supportedValuesOf;e=n?n("timeZone"):[]}catch{e=[]}return Xu=QQ(e,new Date),Xu}function sI(e,n){return e.find(r=>r.value===n||r.aliases.includes(n))??null}function hN(e){return e.toLowerCase().replace(/_/g," ")}const YQ=/^(utc|gmt)?\s*([+-])\s*(\d{1,2})(?::?(\d{2}))?$/;function XQ(e,n){const r=hN(n.trim());if(r==="")return[...e];const s=YQ.exec(r);if(s!=null){const c=(s[2]==="-"?-1:1)*(Number(s[3])*60+Number(s[4]??0));return e.filter(d=>d.offsetMinutes===c).sort((d,u)=>d.value.localeCompare(u.value))}const a=c=>{const d=hN(c);if(!d.includes(r))return null;const u=d.split("/");return(u[u.length-1]??"").startsWith(r)?0:u.some(m=>m.startsWith(r))?1:2},i=[];for(const c of e){let d=null;for(const u of[c.value,...c.aliases]){const m=a(u);m!=null&&(d==null||m<d)&&(d=m)}d!=null&&i.push({o:c,rank:d})}return i.sort((c,d)=>c.rank-d.rank||c.o.value.localeCompare(d.o.value)).map(c=>c.o)}function F0(e,n,r){const s=XQ(e,n).map(d=>({value:d.value,label:d.value,offset:d.offset})),a=n.trim().toLowerCase();if(a!==""&&!"default".startsWith(a))return s;const i=sI(e,r);return[{value:"",label:`Default (${(i==null?void 0:i.value)??sp(r)})`,offset:(i==null?void 0:i.offset)??""},...s]}function ZQ({id:e,value:n,onChange:r,defaultZone:s}){const a=f.useId(),i=f.useRef(null),c=f.useRef([]),[d,u]=f.useState(!1),[m,h]=f.useState(null),[g,x]=f.useState(""),[y,b]=f.useState(""),[w,k]=f.useState(null),[j,N]=f.useState(null),I=n===""?`Default (${sp(s)})`:sp(n),S=f.useMemo(()=>m==null?[]:F0(m,y,s),[m,y,s]);c.current.length=S.length;const T=O=>{var E;return n===""?"":((E=sI(O,n))==null?void 0:E.value)??n},$=m==null?n:T(m),P=()=>{var ee;if(d)return;const O=m??uN();h(O),x(I),b("");const E=F0(O,"",s).findIndex(K=>K.value===T(O));k(E===-1?null:E),N(((ee=i.current)==null?void 0:ee.closest('[role="dialog"]'))??null),u(!0)},C=()=>{u(!1),b(""),k(null)},L=O=>{r(O),C()},{refs:F,floatingStyles:M,context:D,isPositioned:A}=wa({open:d,onOpenChange:O=>O?P():C(),strategy:"fixed",placement:"bottom-start",whileElementsMounted:ni,middleware:[oo(4),io({padding:8}),VA({padding:8,apply({availableHeight:O,rects:E,elements:ee}){Object.assign(ee.floating.style,{maxHeight:`${Math.min(288,O)}px`,width:`${E.reference.width}px`})}})]}),W=vM(D,{listRef:c,activeIndex:w,onNavigate:k,virtual:!0,loop:!0}),{getReferenceProps:z,getFloatingProps:te,getItemProps:H}=lo([W]);f.useLayoutEffect(()=>{var O;!A||w==null||(O=c.current[w])==null||O.scrollIntoView({block:"nearest"})},[A]);const B=O=>{if(O.key==="Escape"&&d){O.preventDefault(),O.stopPropagation(),C();return}if(O.key==="Enter"&&d){O.preventDefault();const E=w==null?void 0:S[w];E!=null&&L(E.value);return}!d&&O.key.length===1&&!O.metaKey&&!O.ctrlKey&&!O.altKey&&(P(),O.currentTarget.select())};return t.jsxs(t.Fragment,{children:[t.jsx("input",{...z({ref:O=>{i.current=O,F.setReference(O)},id:e,role:"combobox",type:"text",autoComplete:"off",spellCheck:!1,"aria-expanded":d,"aria-controls":a,"aria-autocomplete":"list","aria-activedescendant":d&&w!=null?`${a}-opt-${w}`:void 0,[nI]:d?"":void 0,className:Bn,value:d?g:I,onFocus:O=>{P(),O.currentTarget.select()},onClick:O=>{d||P(),y===""&&O.currentTarget.select()},onChange:O=>{const E=O.currentTarget.value;d||P(),x(E),b(E),k(F0(m??uN(),E,s).length>0?0:null)},onBlur:C,onKeyDown:B})}),d&&t.jsx(ka,{root:j??void 0,children:t.jsxs("div",{ref:F.setFloating,style:M,onMouseDown:O=>O.preventDefault(),className:"z-[70] overflow-auto rounded-md border border-gray-200 bg-white py-1 shadow-lg dark:border-gray-700 dark:bg-gray-900",children:[t.jsx("div",{...te({role:"listbox",id:a,"aria-label":"Time zones"}),children:S.map((O,E)=>t.jsxs("div",{...H({onClick:()=>L(O.value)}),ref:ee=>{c.current[E]=ee},role:"option",id:`${a}-opt-${E}`,"aria-selected":E===w,className:`flex cursor-pointer items-center justify-between gap-3 px-2 py-1 text-xs ${E===w?"bg-sky-50 dark:bg-sky-950/40":""}`,children:[t.jsxs("span",{className:"flex min-w-0 items-center gap-1 text-gray-800 dark:text-gray-100",children:[t.jsx("span",{className:"truncate",children:O.label}),O.value===$&&t.jsx(pr,{size:11,className:"shrink-0"})]}),O.offset!==""&&t.jsx("span",{className:"shrink-0 tabular-nums text-gray-500 dark:text-gray-400",children:O.offset})]},O.value===""?"(default)":O.value))}),S.length===0&&t.jsxs("p",{className:"px-2 py-1 text-xs text-gray-500 dark:text-gray-400",children:["No time zone matches “",y.trim(),"”."]})]})})]})}const JQ=[{iso:1,short:"Mon"},{iso:2,short:"Tue"},{iso:3,short:"Wed"},{iso:4,short:"Thu"},{iso:5,short:"Fri"},{iso:6,short:"Sat"},{iso:7,short:"Sun"}];function eY(){var w,k,j;const{workspaceId:e}=Ki(),n=xa(),r=In(),{setWorkspaceFlowSettings:s}=Ix(),a=((w=n.data)==null?void 0:w.find(N=>N.id===e))??null,i=(a==null?void 0:a.flowSettings)??null,c=((k=r.data)==null?void 0:k.workTimeZone)??Intl.DateTimeFormat().resolvedOptions().timeZone??"UTC",[d,u]=f.useState(()=>M0(i)),m=`${e}|${JSON.stringify(i)}`;if(f.useEffect(()=>{u(M0(i))},[m]),e==null||a==null)return t.jsx(gc,{title:"Working hours and budgets",failed:n.isError});const h=AQ(d),g=ox(d),x=ox(M0(i)),y=!MQ(g,x),b=N=>u(I=>({...I,days:I.days.includes(N)?I.days.filter(S=>S!==N):[...I.days,N].sort((S,T)=>S-T)}));return t.jsxs(Qr,{title:"Working hours and budgets",desc:"Chronology counts only the hours your team works, and holds each wait against a budget. Nights, weekends and days off are not counted as waiting.",children:[t.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[t.jsxs("div",{className:"flex flex-col gap-1 text-xs",children:[t.jsx("label",{htmlFor:"flow-tz",className:"font-medium text-gray-600 dark:text-gray-300",children:"Time zone"}),t.jsx(ZQ,{id:"flow-tz",value:d.timeZone,onChange:N=>u(I=>({...I,timeZone:N})),defaultZone:c})]}),t.jsxs("div",{className:"flex flex-col gap-1 text-xs",children:[t.jsx("span",{className:"font-medium text-gray-600 dark:text-gray-300",children:"Working day"}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{type:"time","aria-label":"Start of the working day",className:Bn,value:d.start,onChange:N=>u(I=>({...I,start:N.target.value}))}),t.jsx("span",{className:"text-gray-500 dark:text-gray-400",children:"to"}),t.jsx("input",{type:"time","aria-label":"End of the working day",className:Bn,value:d.end,onChange:N=>u(I=>({...I,end:N.target.value}))})]})]})]}),t.jsxs("div",{className:"text-xs",children:[t.jsx("div",{className:"mb-1 font-medium text-gray-600 dark:text-gray-300",children:"Working days"}),t.jsx("div",{className:"flex flex-wrap gap-1.5",children:JQ.map(N=>{const I=d.days.includes(N.iso);return t.jsx("button",{type:"button","aria-pressed":I,onClick:()=>b(N.iso),className:`rounded border px-2 py-0.5 text-xs ${I?"border-sky-600 bg-sky-600 text-white":"border-gray-300 text-gray-600 hover:bg-gray-100 dark:border-gray-700 dark:text-gray-300 dark:hover:bg-gray-800"}`,children:N.short},N.iso)})})]}),t.jsx(UQ,{form:d,setForm:u,stored:i}),h!=null&&t.jsx("p",{className:"text-xs text-rose-700 dark:text-rose-400",role:"alert",children:h}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(ja,{dirty:y&&h==null,saving:s.isPending,onClick:()=>s.mutate({id:e,settings:g})}),i!=null&&t.jsx("button",{type:"button",disabled:s.isPending,onClick:()=>s.mutate({id:e,settings:{}}),className:"text-xs text-gray-600 hover:underline disabled:opacity-40 dark:text-gray-300",children:"Reset to defaults"})]}),s.isError&&t.jsx("div",{className:"text-xs text-rose-700 dark:text-rose-400",children:((j=s.error)==null?void 0:j.message)??"Couldn’t save the working hours."})]})}function tY(){return Oe({queryKey:["auth-providers"],queryFn:()=>he.authProviders(),staleTime:1/0,gcTime:1/0,refetchOnWindowFocus:!1,retry:!1})}function nY(){const{data:e}=tY();if(!(e!=null&&e.app)||!e.appSlug)return null;const n=`https://github.com/apps/${e.appSlug}/installations/new`,r="inline-flex items-center gap-1 rounded border border-gray-300 px-2 py-1 text-xs font-medium text-gray-700 hover:border-sky-400 hover:text-sky-600 dark:border-gray-700 dark:text-gray-200 dark:hover:text-sky-400";return t.jsxs(Qr,{title:"GitHub App",desc:"Signing in with GitHub doesn’t install the app. Installing it is a separate, one-time step per account or org — and it’s what unlocks private repos and real-time sync.",children:[t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsxs("a",{className:r,href:n,target:"_blank",rel:"noreferrer",children:["Install on an account or org",t.jsx(_t,{size:11})]}),t.jsxs("a",{className:r,href:"https://github.com/settings/installations",target:"_blank",rel:"noreferrer",children:["Manage installations",t.jsx(_t,{size:11})]})]}),t.jsxs("ul",{className:"mt-1 space-y-1 text-[11px] leading-relaxed text-gray-500 dark:text-gray-400",children:[t.jsxs("li",{children:[t.jsx("span",{className:"font-medium text-gray-600 dark:text-gray-300",children:"Private repos:"})," ","only readable in orgs where the app is installed. An org owner may need to approve."]}),t.jsxs("li",{children:[t.jsx("span",{className:"font-medium text-gray-600 dark:text-gray-300",children:"Real-time sync:"})," ","installed repos push changes to Limn as they happen, instead of waiting for the next scheduled poll. Coverage is per ",t.jsx("em",{children:"repo"}),", not per person — one install covers everyone watching that repo."]}),t.jsxs("li",{children:[t.jsx("span",{className:"font-medium text-gray-600 dark:text-gray-300",children:"Not installed?"})," ","Nothing breaks — those repos just stay on the scheduled poll, which keeps running as the backstop either way. Public repos work with no install at all."]})]})]})}const My="pierre:cookie-consent",lx=1,ap="pierre:consent";function rY(){try{const e=window.localStorage.getItem(My);if(!e)return null;const n=JSON.parse(e);return n.choice!=="granted"&&n.choice!=="denied"||n.version!==lx?null:{choice:n.choice,version:lx,at:n.at??""}}catch{return null}}function Ly(){var e;return typeof window>"u"?null:((e=rY())==null?void 0:e.choice)??null}function sY(){return Ly()==="granted"}function pN(e){try{const n={choice:e,version:lx,at:new Date().toISOString()};window.localStorage.setItem(My,JSON.stringify(n))}catch{}e==="denied"&&aI(),window.dispatchEvent(new CustomEvent(ap,{detail:e}))}function aY(){try{window.localStorage.removeItem(My)}catch{}aI(),window.dispatchEvent(new CustomEvent(ap,{detail:null}))}function aI(){var s;if(typeof document>"u")return;const e=window.location.hostname,n=e.split("."),r=new Set([e,`.${e}`]);if(n.length>2){const a=n.slice(-2).join(".");r.add(a),r.add(`.${a}`)}for(const a of document.cookie.split(";")){const i=(s=a.split("=")[0])==null?void 0:s.trim();if(i&&/^_ga(_|$)|^_gid$|^_gat/.test(i)){for(const c of r)document.cookie=`${i}=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/; domain=${c}`;document.cookie=`${i}=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/`}}}function oY(e){const n=r=>{e(r.detail??null)};return window.addEventListener(ap,n),()=>window.removeEventListener(ap,n)}const bh="";function oI(e){return/^G-[A-Z0-9]{6,}$/i.test(e)&&e!=="G-XXXXXXXXXX"}function iI(){return oI(bh)}let cx=!1,op=!1;function lI(){var n;if(typeof window>"u"||!oI(bh)||!sY())return;if(cx){op=!0,(n=window.gtag)==null||n.call(window,"consent","update",{analytics_storage:"granted"});return}cx=!0,op=!0,window.dataLayer=window.dataLayer||[],window.gtag=function(){window.dataLayer.push(arguments)},window.gtag("consent","default",{ad_storage:"denied",ad_user_data:"denied",ad_personalization:"denied",analytics_storage:"denied"}),window.gtag("consent","update",{analytics_storage:"granted"});const e=document.createElement("script");e.async=!0,e.src=`https://www.googletagmanager.com/gtag/js?id=${bh}`,document.head.appendChild(e),window.gtag("js",new Date),window.gtag("config",bh,{send_page_view:!1,allow_google_signals:!1,allow_ad_personalization_signals:!1})}function cI(){op=!1,typeof window<"u"&&window.gtag&&window.gtag("consent","update",{ad_storage:"denied",ad_user_data:"denied",ad_personalization:"denied",analytics_storage:"denied"})}function iY(e=window.location.pathname){!cx||!op||!window.gtag||window.gtag("event","page_view",{page_path:e,page_location:`${window.location.origin}${e}`,page_title:document.title})}function lY(){var N;const{data:e}=In(),n=((N=e==null?void 0:e.user)==null?void 0:N.login)??"",[r,s]=f.useState(!1),[a,i]=f.useState(null),[c,d]=f.useState(!1),[u,m]=f.useState(""),[h,g]=f.useState(!1),[x,y]=f.useState(null),b=f.useCallback(async()=>{s(!0),i(null);try{const I=await fetch("/api/me/export",{credentials:"same-origin"});if(!I.ok)throw new Error(`Export failed (${I.status})`);const S=await I.blob(),T=URL.createObjectURL(S),$=document.createElement("a");$.href=T,$.download=`pierre-export-${n||"account"}-${new Date().toISOString().slice(0,10)}.json`,document.body.appendChild($),$.click(),$.remove(),URL.revokeObjectURL(T)}catch(I){i(I instanceof Error?I.message:"Export failed.")}finally{s(!1)}},[n]),w=f.useCallback(async()=>{g(!0),y(null);try{const I=await fetch("/api/me/account",{method:"DELETE",credentials:"same-origin",headers:{"content-type":"application/json"},body:JSON.stringify({confirmLogin:u.trim()})});if(!I.ok){const S=await I.json().catch(()=>null);throw new Error((S==null?void 0:S.message)??`Deletion failed (${I.status})`)}window.location.assign("/")}catch(I){y(I instanceof Error?I.message:"Deletion failed."),g(!1)}},[u]),k=u.trim().toLowerCase()===n.toLowerCase()&&n!=="",j=Ly();return t.jsxs(Qr,{title:"Your data",desc:"Download everything we hold for your account, change your cookie choice, or delete the account entirely.",children:[t.jsxs("div",{children:[t.jsx("button",{type:"button",onClick:b,disabled:r,className:"rounded border border-gray-300 px-2.5 py-1 text-xs font-medium text-gray-700 hover:border-gray-400 disabled:opacity-50 dark:border-gray-700 dark:text-gray-200 dark:hover:border-gray-500",children:r?"Preparing…":"Download my data (JSON)"}),t.jsx("p",{className:"mt-1 text-[11px] leading-relaxed text-gray-500 dark:text-gray-400",children:"Your account, repositories, workspaces, synced pull-request activity and AI usage. Your stored GitHub token is deliberately excluded — it is a credential, and an export file is not a safe place for one."}),a!=null&&t.jsx("p",{className:"mt-1 text-[11px] text-red-600 dark:text-red-400",children:a})]}),iI()&&t.jsxs("div",{className:"border-t border-gray-100 pt-2.5 dark:border-gray-800",children:[t.jsxs("p",{className:"text-[11px] text-gray-500 dark:text-gray-400",children:["Analytics cookies:"," ",t.jsx("span",{className:"font-medium text-gray-700 dark:text-gray-200",children:j==="granted"?"accepted":j==="denied"?"declined":"not chosen"})]}),t.jsx("button",{type:"button",onClick:()=>{cI(),aY()},className:"mt-1 rounded border border-gray-300 px-2.5 py-1 text-xs font-medium text-gray-700 hover:border-gray-400 dark:border-gray-700 dark:text-gray-200 dark:hover:border-gray-500",children:"Change cookie choice"})]}),t.jsx("div",{className:"border-t border-gray-100 pt-2.5 dark:border-gray-800",children:c?t.jsxs("div",{className:"rounded border border-red-300 bg-red-50 p-2.5 dark:border-red-900 dark:bg-red-950/40",children:[t.jsx("p",{className:"text-xs font-semibold text-red-700 dark:text-red-300",children:"This cannot be undone."}),t.jsx("p",{className:"mt-1 text-[11px] leading-relaxed text-red-700/90 dark:text-red-300/90",children:"Deletes your account, your encrypted GitHub token, every repository you added and all activity synced for them. Nothing is archived. Your repositories on GitHub are, of course, untouched — this only removes Limn's copy."}),t.jsxs("label",{className:"mt-2 block text-[11px] font-medium text-red-700 dark:text-red-300",children:["Type ",t.jsx("span",{className:"font-mono",children:n||"your GitHub username"})," to confirm",t.jsx("input",{type:"text",value:u,onChange:I=>m(I.target.value),autoComplete:"off",spellCheck:!1,className:`${Bn} mt-1`})]}),t.jsxs("div",{className:"mt-2 flex gap-2",children:[t.jsx("button",{type:"button",onClick:w,disabled:!k||h,className:"rounded bg-red-600 px-2.5 py-1 text-xs font-semibold text-white hover:bg-red-700 disabled:opacity-40",children:h?"Deleting…":"Permanently delete"}),t.jsx("button",{type:"button",onClick:()=>{d(!1),m(""),y(null)},disabled:h,className:"rounded border border-gray-300 px-2.5 py-1 text-xs font-medium text-gray-700 hover:border-gray-400 disabled:opacity-50 dark:border-gray-600 dark:text-gray-200",children:"Cancel"})]}),x!=null&&t.jsx("p",{className:"mt-1.5 text-[11px] text-red-700 dark:text-red-300",children:x})]}):t.jsx("button",{type:"button",onClick:()=>d(!0),className:"rounded border border-red-300 px-2.5 py-1 text-xs font-medium text-red-600 hover:border-red-400 hover:bg-red-50 dark:border-red-900 dark:text-red-400 dark:hover:bg-red-950",children:"Delete my account"})})]})}function cY(e,n){const r=e;return r==null||r===n||typeof r.focus!="function"?()=>{}:()=>{var s;r.isConnected===!0&&((s=r.focus)==null||s.call(r,{preventScroll:!0}))}}function dY({focus:e=null,onClose:n}){var g;const r=vt(),s=Dr().enabled,a=((g=In().data)==null?void 0:g.deploymentMode)==="cloud",i=v9(),c=dR(i),{workspaceId:d,name:u}=Ki();f.useEffect(()=>{const x=y=>{y.key==="Escape"&&(zQ(y.target)||(y.stopImmediatePropagation(),n()))};return window.addEventListener("keydown",x,!0),()=>window.removeEventListener("keydown",x,!0)},[n]),f.useEffect(()=>{Hp();const x=cY(document.activeElement,document.body),y=e==="my-turn"?requestAnimationFrame(()=>{const b=document.getElementById(ax);b==null||b.scrollIntoView({block:"start"}),b==null||b.focus({preventScroll:!0})}):null;return()=>{y!=null&&cancelAnimationFrame(y),x()}},[]);const m=c.data!=null,h=d!=null;return t.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4",onClick:n,role:"presentation",children:t.jsxs("div",{className:"flex max-h-[85vh] w-[40rem] max-w-[92vw] flex-col rounded-lg border border-gray-200 bg-white shadow-xl dark:border-gray-700 dark:bg-gray-900",onClick:x=>x.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":"Settings",children:[t.jsxs("div",{className:"flex items-center justify-between border-b border-gray-200 px-4 py-2 dark:border-gray-800",children:[t.jsx("h2",{className:"text-sm font-semibold text-gray-800 dark:text-gray-100",children:"Settings"}),t.jsx("button",{type:"button",onClick:n,className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-200","aria-label":"Close (Esc)",title:"Close (Esc)",children:t.jsx(Zt,{size:14})})]}),t.jsxs("div",{className:"min-h-0 flex-1 space-y-4 overflow-auto px-4 py-3",children:[a&&t.jsx(nY,{}),a&&t.jsx(vQ,{}),t.jsx(wQ,{}),t.jsx(SQ,{}),t.jsx(TQ,{}),a&&t.jsx(lY,{}),t.jsxs("section",{className:"pt-1",children:[t.jsxs("div",{className:"mb-3",children:[t.jsxs("h3",{className:"text-sm font-semibold text-gray-800 dark:text-gray-100",children:["Workspace",u!=null&&t.jsxs(t.Fragment,{children:[" · ",t.jsx("span",{className:"text-sky-600 dark:text-sky-400",children:u})]})]}),t.jsxs("p",{className:"mt-0.5 text-xs text-gray-500 dark:text-gray-400",children:["Everything below applies to"," ",t.jsx("span",{className:"font-medium",children:u??"the selected workspace"})," alone — every other workspace keeps its own. Switch workspace in the rail to configure a different one."]})]}),h?t.jsxs("div",{className:"space-y-4",children:[t.jsx(PQ,{}),t.jsx(eY,{}),i&&!m&&t.jsx("p",{className:"py-2 text-center text-xs text-gray-400",children:c.isError?"Workspace settings unavailable.":"Loading this workspace’s settings…"}),m&&r.workspaceInsights&&t.jsx(lQ,{}),m&&r.slackDigest&&t.jsx(hQ,{}),m&&r.issueLinks&&t.jsx(gQ,{}),s&&t.jsx(yQ,{})]}):t.jsx("p",{className:"py-4 text-center text-xs text-gray-400",children:"Loading this workspace’s settings…"})]})]})]})})}const uY=400,Pl=new Map;function hY(e){const r=Pl.get(e)??{mounts:0,sessionId:null,closeTimer:null};return r.mounts+=1,r.closeTimer!=null&&(clearTimeout(r.closeTimer),r.closeTimer=null),Pl.set(e,r),r}function pY(e){const n=Pl.get(e);n&&(n.mounts-=1,!(n.mounts>0)&&(n.closeTimer=setTimeout(()=>{const r=Pl.get(e);if(!r||r.mounts>0)return;const s=r.sessionId;Pl.delete(e),s!=null&&he.closeConflictSession(e,s).catch(()=>{})},uY),Pl.set(e,n)))}const mN=2e3,gN=8e3,mY=e=>new Promise(n=>setTimeout(n,e));function gY(e){const[n,r]=f.useState(null),[s,a]=f.useState("live"),[i,c]=f.useState(null),[d,u]=f.useState({}),[m,h]=f.useState(()=>new Set),[g,x]=f.useState({}),[y,b]=f.useState(0),w=f.useRef(null),k=f.useRef({});f.useEffect(()=>{if(e==null)return;const S=new AbortController,T=hY(e);return r(null),a("live"),c(null),k.current={},u({}),h(new Set),x({}),w.current=null,(async()=>{var C;let $;try{const L=y>0?{restart:!0,autoApply:!1}:{autoApply:!1};$=await he.openConflictSession(e,L)}catch(L){if(S.signal.aborted)return;c(L instanceof cn?L.message:"Couldn’t start resolving this pull request.");return}if(T.sessionId=$.sessionId,S.signal.aborted||(w.current=$.sessionId,r($),await Pd(`/api/prs/${e}/conflicts/stream?session=${encodeURIComponent($.sessionId)}`,{signal:S.signal,onEvent:L=>{L.type!=="done"&&r(L.session)}}).catch(()=>{}),S.signal.aborted))return;a("polling");let P=mN;for(;!S.signal.aborted;){if(await mY(P),S.signal.aborted)return;try{const L=await he.conflictSession(e,$.sessionId);r(L),P=L.status==="preparing"||((C=L.commit)==null?void 0:C.status)==="running"?mN:gN}catch(L){if(L instanceof cn&&[409,404,403].includes(L.status)){a("lost");return}P=gN}}})(),()=>{S.abort(),pY(e)}},[e,y]);const j=f.useCallback(async S=>{const T=w.current;if(e==null||T==null)return null;const $=k.current[S];if($)return $;h(P=>new Set(P).add(S));try{const P=await he.conflictFile(e,T,S);return k.current={...k.current,[S]:P},u(k.current),x(C=>{if(C[S]==null)return C;const L={...C};return delete L[S],L}),P}catch(P){return x(C=>({...C,[S]:P instanceof cn?P.message:"Couldn’t read this file’s conflicts."})),null}finally{h(P=>{const C=new Set(P);return C.delete(S),C})}},[e]),N=f.useCallback(S=>{x(T=>{if(T[S]==null)return T;const $={...T};return delete $[S],$})},[]),I=f.useCallback(()=>b(S=>S+1),[]);return{session:n,connection:s,openError:i,files:d,loadingFiles:m,fileErrors:g,loadFile:j,retryFile:N,restart:I}}function fY(e){return["conflict-commit",e]}function xY(e,n){dn(e,n,{armed:!0})}function yY(e){return tt({mutationKey:fY(e),mutationFn:n=>he.commitConflictResolution(e,n)})}function bY(e,n){const r=He(),s=f.useRef(!1),a=(n==null?void 0:n.status)??null;f.useEffect(()=>{a!=="done"||s.current||(s.current=!0,xY(r,e))},[a,e,r])}const vY={left:"ours",right:"theirs","both-lr":"both_ours_first","both-rl":"both_theirs_first",ignored:"base",wand:"disjoint_merge",ai:"suggestion",edit:"edited"},kY={ours:"left",theirs:"right",both_ours_first:"both-lr",both_theirs_first:"both-rl",base:"ignored",disjoint_merge:"wand",suggestion:"ai",edited:"edit"};function wY(e){return e.kind==="unapplied"?null:vY[e.kind]}function jY(e,n,r,s){var d,u,m,h;const a=Dn(n,e.id),i=r[a];if(i==null)return{kind:"unapplied"};const c=kY[i];if(c==="wand"){const g=e.mergedLines;return g==null?{kind:"unapplied"}:{kind:"wand",lines:g}}if(c==="ai"){const g=(d=s.suggestionIds)==null?void 0:d[a],x=g!=null?(u=s.suggestionLines)==null?void 0:u[g]:void 0;return g==null||x==null?{kind:"unapplied"}:{kind:"ai",suggestionId:g,lines:x}}if(c==="edit"){const g=(m=s.editIds)==null?void 0:m[a],x=g!=null?(h=s.editLines)==null?void 0:h[g]:void 0;return g==null||x==null?{kind:"unapplied"}:{kind:"edit",editId:g,lines:x}}return{kind:c}}function NY(e,n){return e.kind==="unchanged"?null:n.kind==="unapplied"?e.kind==="conflict"?"conflict":"change":n.kind==="ignored"?"ignored":"applied"}const SY={left:"ours",right:"theirs"};function ip(e,n){return e.allowed.includes(SY[n])}function lp(e,n){switch(e.kind){case"unapplied":return"undecided";case"ignored":return"rejected";case"edit":return"rejected";case"left":return n==="left"?"contributed":"rejected";case"right":return n==="right"?"contributed":"rejected";case"both-lr":case"both-rl":case"wand":case"ai":return"contributed"}}function O0(e,n,r){if(e.kind==="unchanged")return null;if(r==="centre")return n.kind==="unapplied"?null:n.kind==="ignored"?"ignored":"applied";if(!ip(e,r))return null;switch(lp(n,r)){case"contributed":return"applied";case"rejected":return null;case"undecided":return e.kind==="conflict"?"conflict":"change"}}const fN=Object.freeze([]),CY=Object.freeze(["left"]),RY=Object.freeze(["right"]),IY=Object.freeze(["left","right"]);function TY(e,n){if(e.kind==="unchanged")return fN;const r=ip(e,"left")&&lp(n,"left")==="contributed",s=ip(e,"right")&&lp(n,"right")==="contributed";return r&&s?IY:r?CY:s?RY:fN}const Cl=e=>e.text,$Y={wand:"disjoint_merge",ai:"suggestion",edit:"edited"};function _Y(e,n){if(e.kind==="unchanged"||n.kind==="unapplied")return e.base.map(Cl);const r=wY(n);if(r==null)return e.base.map(Cl);const s=n.kind==="wand"||n.kind==="ai"||n.kind==="edit"?{decision:$Y[n.kind],lines:n.lines,endsWithNewline:!0}:{decision:r},a=E$({regions:[{id:e.id,kind:e.kind,base:e.base.map(Cl),ours:e.ours.map(Cl),theirs:e.theirs.map(Cl)}],terminators:{base:!0,ours:!0,theirs:!0}},new Map([[e.id,s]]));return a.ok?a.lines:e.base.map(Cl)}function xN(e,n,r){const s=[];let a=0,i=0,c=0,d=0;for(const u of e){if(u.kind==="unchanged")continue;if(r[Dn(n,u.id)]!=null){d+=1;continue}const h=u.wand;if(h==null){u.kind==="conflict"&&(c+=1);continue}if(u.kind==="conflict"){if(h.reason!=="disjoint_words"||h.decision!=="disjoint_merge"){c+=1;continue}i+=1}else a+=1;s.push({fileIndex:n,regionId:u.id,decision:h.decision,reason:h.reason})}return{moves:s,changesApplied:a,conflictsResolved:i,conflictsLeft:c,alreadyDecided:d}}const D0=(e,n,r)=>`${e} ${e===1?n:r}`;function PY(e){const n=[];return e.changesApplied>0&&n.push(`${D0(e.changesApplied,"change","changes")} applied`),e.conflictsResolved>0&&n.push(`${D0(e.conflictsResolved,"conflict","conflicts")} resolved`),n.length>0?e.conflictsLeft>0?`${n.join(", ")}, ${e.conflictsLeft} left.`:`${n.join(", ")}. Nothing left to decide in this file.`:e.conflictsLeft===0?"Nothing left to decide in this file.":e.alreadyDecided===0?"Every change here needs a decision.":`${D0(e.conflictsLeft,"conflict","conflicts")} left to decide.`}function EY(e,n){return e.kind==="unchanged"?null:e.allowed.includes(n)?n:e.kind==="both_same"&&e.allowed.includes("ours")?"ours":e.allowed.includes("base")?"base":null}function yN(e,n,r,s){const a=[];for(const i of e){const c=EY(i,s);c!=null&&r[Dn(n,i.id)]!==c&&a.push({fileIndex:n,regionId:i.id,decision:c})}return{moves:a}}function dI(e,n,r){let s=0,a=0,i=0,c=0;for(const d of e){if(d.kind==="unchanged")continue;s+=1;const u=r[Dn(n,d.id)]!=null;u&&(a+=1),d.kind==="conflict"&&(i+=1,u&&(c+=1))}return{decidable:s,decided:a,conflicts:i,conflictsDecided:c}}const uI="Can’t be resolved here",vd=e=>`${e} to decide`,cp="Nothing to decide";function bN(e,n){return e.unsupported!=null?{state:"unsupported",label:e.unsupportedLabel??uI}:n==null?e.decidableCount===0?{state:"conflicts",label:cp}:{state:"conflicts",label:vd(e.decidableCount)}:n.decidable===0?{state:"conflicts",label:cp}:n.decided>=n.decidable?{state:"resolved",label:"Resolved"}:n.decided>0?{state:"partial",label:`${n.decided} of ${n.decidable} decided`}:{state:"conflicts",label:vd(n.decidable)}}function AY(e,n,r,s,a={}){const i=[];for(const c of e){if(c.kind==="unchanged")continue;const d=Dn(n,c.id),u=r[d];if(u==null)continue;const m=u==="suggestion"?s[d]:void 0;if(u==="suggestion"&&m==null)continue;const h=u==="edited"?a[d]:void 0;u==="edited"&&h==null||(m!=null?i.push({id:c.id,decision:u,suggestionId:m}):h!=null?i.push({id:c.id,decision:u,editId:h}):i.push({id:c.id,decision:u}))}return i}function MY(e,n,r){const s={index:e.index,path:e.path};if(e.unsupported!=null)return{...s,state:"unsupported",label:e.unsupportedLabel??uI,conflictsDecided:0,decidable:0,decided:0,opened:!1};if(n==null)return{...s,state:"untouched",label:e.decidableCount===0?cp:"Not opened",conflictsDecided:0,decidable:e.decidableCount,decided:0,opened:!1};const a=dI(n.regions,e.index,r),i={conflictsDecided:a.conflictsDecided,decidable:a.decidable,decided:a.decided,opened:!0};return a.decidable===0?{...s,state:"untouched",label:cp,...i}:a.decided>=a.decidable?{...s,state:"resolved",label:"Resolved",...i}:a.decided>0?{...s,state:"partial",label:`${a.decided} of ${a.decidable} decided`,...i}:{...s,state:"untouched",label:"Nothing decided",...i}}function LY(e,n,r){const s=e.files.map(g=>MY(g,n[g.index],r)),a=s.filter(g=>g.state==="resolved"),i=s.filter(g=>g.state!=="unsupported"),c=[];let d=0,u=0;for(const g of i){d+=g.decidable,u+=g.decided;const x=g.decidable-g.decided;x>0&&c.push({index:g.index,path:g.path,remaining:x,opened:g.opened})}const m=new Set(c.map(g=>g.index)),h=s.filter(g=>g.state!=="resolved");return{rows:s,resolved:a,stillConflicted:h,notCarried:h.filter(g=>!m.has(g.index)),conflictsResolved:a.reduce((g,x)=>g+x.conflictsDecided,0),totalFiles:e.files.length,outstanding:c,canCommit:c.length===0&&a.length>0,decidableTotal:d,decidedTotal:u}}const hI="This pull request moved on GitHub while you were here. Committing will be refused — close this and start again.",FY="Nothing here can be committed. These files have to be finished on GitHub.",OY=e=>`${e} change${e===1?"":"s"} left to decide.`;function pI(e,n){return n?hI:e.outstanding.length>0?OY(e.decidableTotal-e.decidedTotal):e.resolved.length===0?FY:null}function DY(e,n){var a;const r=e.filter(i=>i.index!==n);return((a=r.find(i=>i.index>n)??r[0])==null?void 0:a.index)??null}function BY(e,n){const r=e.prBranchPushable;return{offerPrBranch:r,prBranchNote:r?null:e.prBranchUnavailableReason,toNewBranch:n||!r}}function WY(e){const{session:n,plan:r,loaded:s,decisions:a,suggestionIds:i,editIds:c,strategy:d,target:u}=e,m=r.resolved.flatMap(h=>{const g=s[h.index];return g==null?[]:[{index:h.index,decisions:AY(g.regions,h.index,a,i,c??{})}]});return{sessionId:n.sessionId,expectedHeadSha:n.headSha,expectedBaseSha:n.baseSha,modelHash:n.modelHash,strategy:d,target:u,files:m}}function qY(e,n){const r=[],s=new Set;for(const a of[...e.skipped.map(i=>i.path),...n.stillConflicted.map(i=>i.path)])s.has(a)||(s.add(a),r.push(a));return r}let dx=0;function UY(){return dx>0}function Fy(e,n){f.useEffect(()=>{if(!e)return;dx+=1;const r=s=>{s.key==="Escape"&&(s.stopImmediatePropagation(),n())};return window.addEventListener("keydown",r,!0),()=>{dx-=1,window.removeEventListener("keydown",r,!0)}},[e,n])}const mI="Your version",gI="Result",fI=e=>`Changes from ${e}`;function HY(e,n){if(e.kind==="unchanged")return"";switch(n.kind){case"unapplied":return"Needs a decision";case"ignored":return"Ignored";case"wand":return"Merged";case"ai":return"Suggested";case"edit":return"Your text";case"both-lr":case"both-rl":return"Both applied";default:return"Applied"}}const td={change:"mr-ink-change",conflict:"mr-ink-conflict",applied:"mr-ink-applied",ignored:"mr-ink-ignored"},zY={change:"mr-wash-change",conflict:"mr-wash-conflict",applied:"mr-wash-applied",ignored:"mr-wash-ignored"};function B0(e){return e==null?"":zY[e]}const KY="mr-fill-applied",GY={change:"mr-rule-change",conflict:"mr-rule-conflict",applied:"mr-rule-applied",ignored:"mr-rule-ignored"};function xI(e,n,r,s){return`${e.kind==="conflict"?"Conflict":"Change"} ${n} of ${r} in ${s}`}const VY=(e,n,r,s,a)=>`${e} — ${xI(n,r,s,a)}`,yI=e=>({left:"Take your version",right:`Take the change from ${e}`,bothLr:`Take both — yours first, then ${e}`,bothRl:`Take both — ${e} first, then yours`,swap:"Swap which side goes first",ignore:"Ignore this change and keep the ancestor",undo:"Undo this decision",edit:"Edit the result for this change"}),QY="Edit",YY="Your text for this change",XY="Save",ZY="Cancel",JY="Saving…",eX=(e,n,r)=>`Result for change ${n} of ${r} in ${e}`,tX="This replaces the result for this change only.",vN="Previous file in the list",kN="Next file in the list",nX="Next",wN="Next file that needs decisions",jN="What is left to decide",rX="Everything is decided.",sX="Take your file",aX=e=>`Take ${e}’s file`,oX=e=>`Make this whole file your version. ${e}’s changes to it are left out.`,iX=e=>`Make this whole file ${e}’s version. Your changes to it are left out.`,lX="This file is now your version.",cX=e=>`This file is now ${e}’s version.`,dX=(e,n)=>n===0?"This file: nothing to decide":e===0?"This file: all decided":`This file: ${e} of ${n} changes left`,uX=(e,n)=>n===0?"Nothing to decide in this pull request.":e===0?"All files: all decided":`All files: ${e} of ${n} changes left`,hX="Take the obvious ones",pX="Apply every change only one side made, and merge the conflicts whose edits don’t overlap. Never picks a side.",mX="Merge base",W0="Merge base — the last commit both branches shared.",gX="Pick a change first.",fX="Undo",xX=e=>`${e} file${e===1?"":"s"} need resolving on GitHub.`,yX=(e,n)=>`${e} of ${n} files`,bX="Rename detection is off: this pull request changes too many files. A renamed file shows as a delete and an add.",vX=(e,n)=>`Showing ${e} of ${n} conflicting files. The rest need resolving on GitHub.`,kX="The window is too narrow for three columns, so the versions are stacked. Widen it to get them back.",wX=e=>`Show ${e} unchanged line${e===1?"":"s"}`,jX="Hide unchanged lines",NX=(e,n)=>n===0?"Nothing to decide in this pull request.":`${e} of ${n} changes decided`,Oy="Reading the conflicting files…",NN="Back to the panes",SX="What is being committed",CX=(e,n)=>`${e} of ${n} file${n===1?"":"s"} resolved`,bI="Still conflicted:",vI="This pull request stays conflicted until these are resolved too.",RX="Still to decide:",kI=(e,n)=>`Go to ${e}, ${vd(n)}`,IX="This commit keeps the files you resolved. A conflict you ignored is committed as the base branch’s version, so finishing the merge later takes that version without asking.",TX="How to land it",$X="Merge",_X="One merge commit on your branch. Plain push.",PX="One commit with the files you resolved. Not a merge commit — this pull request stays conflicted.",EX="Rebase",SN=e=>`Replays your commit onto ${e}. Force-pushes with --force-with-lease.`,AX="Where to put it",MX=e=>`Push to ${e}`,LX="Commit to a new branch",FX="Branch name",OX="Open a pull request for it",DX=(e,n)=>`Based on ${e.slice(0,7)} and ${n.slice(0,7)}. If either moves, nothing is pushed.`,dp="Commit and push",CN="Rebase and force-push",BX=`${dp} — review what goes in first`,WX=e=>`${e} — pushes to GitHub now`,qX="Review what gets committed, then push",UX="Merge when ready is armed on this pull request. Pushing this commit disarms it — arm it again afterwards.",HX={preparing:"Getting a copy of the repository…",fetching:"Fetching both branches…",merging:"Applying your decisions…",committing:"Making the commit…",pushing:"Pushing…",confirming:"Checking it landed…"};function zX(e){if(e.length===0)return"";if(e.length===1)return e[0]??"";const n=e.slice(0,3),r=e.length-n.length,s=r>0?`${r} more`:n.pop()??"";return`${n.join(", ")} and ${s}`}const KX=(e,n)=>`Pushed to ${e} — ${n.slice(0,7)}.`,GX=(e,n)=>`${e} conflict${e===1?"":"s"} resolved across ${n} file${n===1?"":"s"}.`,VX=e=>`${zX(e)} still conflict${e.length===1?"s":""}; resolve ${e.length===1?"it":"them"} on GitHub.`,QX=e=>`${e} moved while you were resolving. Those commits are in this merge.`,YX="Merge when ready was disarmed. Arm it again if you still want it.",XX="It’ll show up here shortly.",ZX="This session is no longer open.",JX="Your resolution was sent, but this session ended before the result came back. Check the pull request on GitHub.",eZ="Nothing was pushed.",wI="Start again",ux="Close",tZ="Open the compare view",nZ="Your decisions are kept until you reload.",rZ=(e,n)=>`${e} of ${n} changes decided, nothing pushed. Your choices are kept until you reload.`,sZ="Keep working",aZ="Close",oZ=e=>`Conflict resolver closed — ${e} decision${e===1?"":"s"} kept, nothing pushed.`,iZ="Reopen",lZ="The branch moved since you started. Starting again.",cZ="http://www.w3.org/2000/svg",q0=2;function dZ({scrollerRef:e,fileIndex:n,regions:r,slots:s,narrow:a}){const i=f.useRef(null),c=f.useRef(null),d=f.useRef(!0),u=f.useRef(null),m=f.useRef(null),h=f.useRef([]),g=f.useRef(a),x=f.useRef(n),y=f.useMemo(()=>{const I=[];for(const S of r){const T=s.get(S.id);if(T!=null)for(const $ of TY(S,T))I.push({regionId:S.id,side:$})}return I},[r,s]);function b(){const I=i.current;I!=null&&(I.childElementCount>0&&I.replaceChildren(),I.style.display="none")}function w(I,S){if(S-I>=q0)return[I,S];const $=(I+S)/2;return[$-q0/2,$+q0/2]}function k(){const I=e.current,S=h.current;if(u.current=null,d.current=!1,I==null||g.current||S.length===0)return;const T=I.getBoundingClientRect(),$=I.scrollTop,P=I.querySelector("[data-mr-pane-header]"),C=P==null?0:P.getBoundingClientRect().height,L=x.current,F=new Map;for(const D of I.querySelectorAll("[data-mr-cell]")){const A=D.dataset.mrCell;A!=null&&F.set(A,D)}const M=[];for(const D of S){const A=F.get(`${L}:${D.regionId}:${D.side}`),W=F.get(`${L}:${D.regionId}:centre`);if(A==null||W==null)continue;const z=A.getBoundingClientRect(),te=W.getBoundingClientRect(),[H,B]=w(z.top-T.top+$,z.bottom-T.top+$),[O,E]=w(te.top-T.top+$,te.bottom-T.top+$);M.push({srcX:(D.side==="left"?z.right:z.left)-T.left,dstX:(D.side==="left"?te.left:te.right)-T.left,srcTop:H,srcBottom:B,dstTop:O,dstBottom:E})}u.current={headerH:C,items:M}}function j(){const I=i.current,S=e.current,T=u.current;if(I==null||S==null||T==null||T.items.length===0){b();return}const $=S.scrollTop,P=S.clientHeight,C=$+T.headerH,L=$+P,F=document.createDocumentFragment();for(const M of T.items){const D=Math.min(M.srcTop,M.dstTop);if(Math.max(M.srcBottom,M.dstBottom)<=C||D>=L)continue;const W=document.createElementNS(cZ,"path");W.setAttribute("d",uZ(M.srcX,M.srcTop-C,M.srcBottom-C,M.dstX,M.dstTop-C,M.dstBottom-C)),W.setAttribute("class",KY),F.appendChild(W)}if(F.childElementCount===0){b();return}I.style.display="block",I.style.top=`${T.headerH}px`,I.style.height=`${Math.max(0,P-T.headerH)}px`,I.replaceChildren(F)}function N(I){I&&(d.current=!0),c.current==null&&(c.current=requestAnimationFrame(()=>{c.current=null,d.current&&k(),j()}))}return f.useLayoutEffect(()=>{const I=e.current;if(I==null)return;const S=()=>N(!1),T=new ResizeObserver(()=>N(!0));return m.current=T,T.observe(I),I.addEventListener("scroll",S,{passive:!0}),()=>{I.removeEventListener("scroll",S),T.disconnect(),m.current=null,c.current!=null&&cancelAnimationFrame(c.current),c.current=null}},[]),f.useLayoutEffect(()=>{h.current=y,g.current=a,x.current=n;const I=e.current,S=m.current;if(S!=null&&I!=null){S.disconnect(),S.observe(I);const T=I.querySelector("[data-mr-grid]");T!=null&&S.observe(T)}k(),j()},[y,a,n]),t.jsx("svg",{ref:i,className:"mr-ribbons","aria-hidden":"true",style:{display:"none"}})}function uZ(e,n,r,s,a,i){const c=(s-e)*.5,d=u=>u.toFixed(1);return`M ${d(e)} ${d(n)} C ${d(e+c)} ${d(n)} ${d(s-c)} ${d(a)} ${d(s)} ${d(a)} L ${d(s)} ${d(i)} C ${d(s-c)} ${d(i)} ${d(e+c)} ${d(r)} ${d(e)} ${d(r)} Z`}function hZ({region:e,language:n,open:r,onOpenChange:s}){const{refs:a,floatingStyles:i,context:c}=wa({open:r,onOpenChange:s,strategy:"fixed",placement:"bottom-end",middleware:[oo(4),io({fallbackPlacements:["top-end"]}),ri({padding:8})],whileElementsMounted:ni}),d=si(c),{getReferenceProps:u,getFloatingProps:m}=lo([d]),h=f.useCallback(()=>s(!1),[s]);Fy(r,h);const g=(e==null?void 0:e.base.map(y=>y.text))??[],x=Mi(g,n);return t.jsxs(t.Fragment,{children:[t.jsxs("button",{ref:a.setReference,...u(),type:"button",onClick:()=>s(!r),"aria-expanded":r,title:W0,className:"flex items-center gap-1 rounded border border-gray-300 px-2 py-1 text-xs text-gray-700 hover:border-gray-400 dark:border-gray-700 dark:text-gray-200 dark:hover:border-gray-600",children:[t.jsx(u_,{size:13}),mX]}),r&&t.jsx(ka,{children:t.jsxs("div",{ref:a.setFloating,style:i,...m(),role:"dialog","aria-label":W0,className:"z-[70] w-[36rem] max-w-[92vw] overflow-hidden rounded-md border border-gray-200 bg-white shadow-lg dark:border-gray-800 dark:bg-gray-900",children:[t.jsx("div",{className:"border-b border-gray-200 px-2.5 py-1.5 text-[11px] text-gray-600 dark:border-gray-800 dark:text-gray-300",children:W0}),e==null?t.jsx("div",{className:"px-2.5 py-2 text-xs text-gray-600 dark:text-gray-300",children:gX}):t.jsx("div",{className:"code-hl max-h-[50vh] overflow-y-auto px-2.5 py-1.5 font-mono text-[12px] leading-[18px] text-gray-900 dark:text-gray-100",children:g.map((y,b)=>{var w;return t.jsxs("div",{className:"flex",children:[t.jsx("span",{className:"w-9 shrink-0 select-none pr-2 text-right tabular-nums text-gray-500 dark:text-gray-400",children:((w=e.base[b])==null?void 0:w.n)??""}),(x==null?void 0:x[b])!=null?t.jsx("span",{className:"min-h-[18px] min-w-0 flex-1 whitespace-pre-wrap [overflow-wrap:anywhere]",dangerouslySetInnerHTML:{__html:x[b]}}):t.jsx("span",{className:"min-h-[18px] min-w-0 flex-1 whitespace-pre-wrap [overflow-wrap:anywhere]",children:y})]},b)})})]})})]})}function RN(e,n){return e.length<=n?e:`…${e.slice(e.length-(n-1))}`}const IN={resolved:td.applied,partial:td.change,conflicts:td.conflict,unsupported:td.ignored};function pZ({files:e,activeIndex:n,tallies:r,open:s,onOpenChange:a,onSelect:i}){const c=f.useRef(null),{refs:d,floatingStyles:u,context:m}=wa({open:s,onOpenChange:a,strategy:"fixed",placement:"bottom-start",middleware:[oo(4),io({fallbackPlacements:["top-start"]}),ri({padding:8})],whileElementsMounted:ni}),h=si(m),{getReferenceProps:g,getFloatingProps:x}=lo([h]),y=f.useCallback(()=>a(!1),[a]);Fy(s,y),f.useEffect(()=>{var j,N;s&&((N=(j=c.current)==null?void 0:j.querySelector('[data-mr-file-active="true"]'))==null||N.focus())},[s]);const b=e.find(j=>j.index===n)??e[0],w=f.useMemo(()=>e.filter(j=>bN(j,r[j.index]??null).state==="resolved").length,[e,r]),k=e.filter(j=>j.unsupported!=null).length;return t.jsxs(t.Fragment,{children:[t.jsxs("button",{ref:d.setReference,...g(),type:"button",onClick:()=>a(!s),"aria-haspopup":"listbox","aria-expanded":s,className:"flex min-w-0 items-center gap-1.5 rounded border border-gray-300 px-2 py-1 text-xs text-gray-800 hover:border-gray-400 dark:border-gray-700 dark:text-gray-100 dark:hover:border-gray-600",children:[t.jsx("span",{className:"truncate font-mono",title:b==null?void 0:b.path,children:b==null?"No files":RN(b.path,44)}),t.jsx(Cr,{size:11,className:"shrink-0 text-gray-500 dark:text-gray-400"})]}),s&&t.jsx(ka,{children:t.jsxs("div",{ref:d.setFloating,style:u,...x(),className:"z-[70] w-[26rem] max-w-[92vw] overflow-hidden rounded-md border border-gray-200 bg-white shadow-lg dark:border-gray-800 dark:bg-gray-900",children:[t.jsxs("div",{className:"flex items-center justify-between border-b border-gray-200 px-2.5 py-1.5 text-[11px] text-gray-600 dark:border-gray-800 dark:text-gray-300",children:[t.jsx("span",{children:yX(w,e.length)}),k>0&&t.jsx("span",{children:xX(k)})]}),t.jsx("div",{ref:c,role:"listbox",className:"max-h-[50vh] overflow-y-auto py-1",children:e.map(j=>{const N=bN(j,r[j.index]??null),I=N.state==="unsupported",S=j.index===n,T=N.state==="resolved"?pr:N.state==="unsupported"?kp:N.state==="conflicts"?xS:null;return t.jsxs("div",{role:"option","aria-selected":S,"aria-disabled":I||void 0,"data-mr-file-active":S?"true":void 0,tabIndex:I?-1:0,onClick:I?void 0:()=>{i(j.index),a(!1)},onKeyDown:I?void 0:$=>{$.key!=="Enter"&&$.key!==" "||($.preventDefault(),i(j.index),a(!1))},className:`flex items-center gap-2 px-2.5 py-1 text-xs ${I?"cursor-default":"cursor-pointer"} ${I?"text-gray-500 dark:text-gray-400":"text-gray-800 hover:bg-gray-100 dark:text-gray-100 dark:hover:bg-gray-800"} ${S?"bg-gray-100 dark:bg-gray-800":""}`,children:[t.jsx("span",{className:`shrink-0 ${IN[N.state]}`,children:T!=null?t.jsx(T,{size:12}):t.jsx(mZ,{})}),t.jsx("span",{className:"min-w-0 flex-1 truncate font-mono",title:j.path,children:RN(j.path,40)}),t.jsx("span",{className:`shrink-0 text-[11px] ${IN[N.state]}`,children:N.label})]},j.index)})})]})})]})}function mZ(){return t.jsx("span",{className:"inline-block h-3 w-3"})}function gZ({decided:e,total:n,outstanding:r,blockedReason:s,open:a,onOpenChange:i,onJumpToFile:c}){const{refs:d,floatingStyles:u,context:m}=wa({open:a,onOpenChange:i,strategy:"fixed",placement:"bottom-end",middleware:[oo(4),io({fallbackPlacements:["top-end"]}),ri({padding:8})],whileElementsMounted:ni}),h=si(m),{getReferenceProps:g,getFloatingProps:x}=lo([h]),y=f.useRef(null),b=f.useRef(null),w=f.useCallback(()=>i(!1),[i]);return Fy(a,w),f.useEffect(()=>{var j;if(!a)return;const k=y.current;return(j=(k==null?void 0:k.querySelector("button"))??k)==null||j.focus(),()=>{var N;((N=b.current)==null?void 0:N.isConnected)===!0&&b.current.focus()}},[a]),t.jsxs(t.Fragment,{children:[t.jsxs("button",{ref:k=>{d.setReference(k),b.current=k},...g(),type:"button",onClick:()=>i(!a),"aria-haspopup":"dialog","aria-expanded":a,title:jN,className:"flex items-center gap-1 rounded px-1 py-0.5 text-[11px] text-gray-600 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-800",children:[uX(n-e,n),t.jsx(Cr,{size:11,className:"shrink-0 text-gray-500 dark:text-gray-400"})]}),a&&t.jsx(ka,{children:t.jsxs("div",{ref:k=>{d.setFloating(k),y.current=k},style:u,...x(),role:"dialog","aria-label":jN,tabIndex:-1,className:"z-[70] w-[26rem] max-w-[92vw] overflow-hidden rounded-md border border-gray-200 bg-white shadow-lg outline-none dark:border-gray-800 dark:bg-gray-900",children:[t.jsx("p",{className:"border-b border-gray-200 px-2.5 py-1.5 text-[12px] text-gray-800 dark:border-gray-800 dark:text-gray-100",children:s??rX}),r.length>0&&t.jsx("ul",{className:"max-h-[50vh] overflow-y-auto py-1",children:r.map(k=>t.jsx("li",{children:t.jsxs("button",{type:"button",onClick:()=>{c(k.index),i(!1)},"aria-label":kI(k.path,k.remaining),className:"flex w-full flex-wrap items-baseline gap-x-2 px-2.5 py-1 text-left text-[12px] hover:bg-gray-100 dark:hover:bg-gray-800",children:[t.jsx("span",{className:"min-w-0 font-mono text-gray-800 dark:text-gray-100",children:k.path}),t.jsx("span",{className:"text-gray-600 dark:text-gray-300",children:vd(k.remaining)})]})},k.index))})]})})]})}function fZ({files:e,activeIndex:n,tallies:r,fileMenuOpen:s,onFileMenuOpen:a,onSelectFile:i,onStepFile:c,canStepBack:d,canStepForward:u,baseRef:m,onTakeFile:h,takeFileDisabled:g,onWand:x,wandDisabled:y,onUndo:b,undoDepth:w,activeRegion:k,language:j,baseOpen:N,onBaseOpen:I,fileDecided:S,fileDecidable:T,decided:$,total:P,outstanding:C,outstandingOpen:L,onOutstandingOpen:F,onJumpToFile:M,nextOutstanding:D,onNextOutstanding:A,blockedReason:W,onLand:z}){return t.jsxs("div",{className:"flex shrink-0 flex-wrap items-center gap-2 border-b border-gray-200 px-4 py-1.5 dark:border-gray-800",children:[t.jsxs("div",{className:"flex items-center",children:[t.jsx("button",{type:"button",onClick:()=>c(-1),disabled:!d,title:vN,"aria-label":vN,className:"rounded p-1 text-gray-600 hover:bg-gray-100 disabled:opacity-40 dark:text-gray-300 dark:hover:bg-gray-800",children:t.jsx(Mt,{dir:"left",size:13})}),t.jsx("button",{type:"button",onClick:()=>c(1),disabled:!u,title:kN,"aria-label":kN,className:"rounded p-1 text-gray-600 hover:bg-gray-100 disabled:opacity-40 dark:text-gray-300 dark:hover:bg-gray-800",children:t.jsx(Mt,{dir:"right",size:13})})]}),t.jsx(pZ,{files:e,activeIndex:n,tallies:r,open:s,onOpenChange:a,onSelect:i}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsxs("button",{type:"button",onClick:()=>h("ours"),disabled:g.ours,title:oX(m),className:"flex items-center gap-1 rounded border border-gray-300 px-2 py-1 text-xs text-gray-800 hover:border-gray-400 disabled:opacity-40 dark:border-gray-700 dark:text-gray-100 dark:hover:border-gray-600",children:[t.jsx(wx,{size:13}),sX]}),t.jsxs("button",{type:"button",onClick:()=>h("theirs"),disabled:g.theirs,title:iX(m),className:"flex min-w-0 max-w-[16rem] items-center gap-1 rounded border border-gray-300 px-2 py-1 text-xs text-gray-800 hover:border-gray-400 disabled:opacity-40 dark:border-gray-700 dark:text-gray-100 dark:hover:border-gray-600",children:[t.jsx("span",{className:"truncate",children:aX(m)}),t.jsx(jx,{size:13,className:"shrink-0"})]})]}),t.jsxs("button",{type:"button",onClick:x,disabled:y,title:pX,className:"flex items-center gap-1 rounded border border-gray-300 px-2 py-1 text-xs text-gray-800 hover:border-gray-400 disabled:opacity-40 dark:border-gray-700 dark:text-gray-100 dark:hover:border-gray-600",children:[t.jsx(yS,{size:13}),hX]}),t.jsxs("button",{type:"button",onClick:b,disabled:w===0,title:"Undo the last decision",className:"flex items-center gap-1 rounded border border-gray-300 px-2 py-1 text-xs text-gray-800 hover:border-gray-400 disabled:opacity-40 dark:border-gray-700 dark:text-gray-100 dark:hover:border-gray-600",children:[t.jsx(bS,{size:13}),fX]}),t.jsx(hZ,{region:k,language:j,open:N,onOpenChange:I}),t.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[D!=null&&t.jsx("button",{type:"button",onClick:A,title:wN,"aria-label":wN,className:"rounded border border-gray-300 px-2 py-1 text-xs text-gray-800 hover:border-gray-400 dark:border-gray-700 dark:text-gray-100 dark:hover:border-gray-600",children:nX}),T!=null&&S!=null&&t.jsx("span",{className:"text-[11px] text-gray-600 dark:text-gray-300",children:dX(T-S,T)}),t.jsx(gZ,{decided:$,total:P,outstanding:C,blockedReason:W,open:L,onOpenChange:F,onJumpToFile:M}),z!=null&&t.jsxs(t.Fragment,{children:[W!=null&&t.jsx("span",{id:TN,className:"sr-only",children:W}),t.jsx("button",{type:"button",onClick:z,disabled:W!=null,title:W??qX,"aria-label":BX,"aria-describedby":W!=null?TN:void 0,className:"rounded border border-gray-300 px-2 py-1 text-xs font-medium text-gray-900 disabled:opacity-40 hover:border-gray-400 dark:border-gray-600 dark:text-gray-100 dark:hover:border-gray-500",children:dp})]})]})]})}const TN="conflict-toolbar-blocked-reason",dd=f.memo(function({rows:n,paint:r,rule:s,ariaHidden:a,anchor:i}){const c=n.length===0&&r!=null&&r!=="";return t.jsx("div",{className:"mr-filler min-w-0","aria-hidden":a===!0?!0:void 0,children:t.jsx("div",{"data-mr-cell":i,className:`min-w-0 font-mono text-[12px] leading-[18px] text-gray-900 dark:text-gray-100 ${r??""} ${s!=null?`border-l-2 ${s}`:""} ${c?"h-[18px]":""}`,children:n.map((d,u)=>d.kind==="gap"?t.jsx("div",{className:"mr-filler h-[18px]"},`gap-${u}`):t.jsxs("div",{className:"flex",children:[t.jsx("span",{className:"w-9 shrink-0 select-none pr-2 text-right tabular-nums text-gray-500 dark:text-gray-400",children:d.n??""}),d.html!=null?t.jsx("span",{className:"code-hl min-h-[18px] min-w-0 flex-1 whitespace-pre-wrap [overflow-wrap:anywhere]",dangerouslySetInnerHTML:{__html:d.html}}):t.jsx("span",{className:"min-h-[18px] min-w-0 flex-1 whitespace-pre-wrap [overflow-wrap:anywhere]",children:d.text})]},`${d.n??"r"}-${u}`))})})});function xZ({state:e,language:n,onUse:r,onDiscard:s}){const a=e.status==="ready"?e.suggestion:null,i=f.useMemo(()=>{if(a==null)return[];const c=Mi(a.lines,n);return a.lines.map((d,u)=>({kind:"line",n:null,text:d,html:(c==null?void 0:c[u])??null}))},[a,n]);return e.status==="asking"?t.jsx(U0,{children:"Asking Claude…"}):e.status==="refused"?t.jsx(U0,{children:e.message}):a==null?t.jsx(U0,{children:"Asking Claude…"}):t.jsxs("div",{className:"border-l-2 border-ai-signal-fill bg-ai-surface-2",children:[t.jsx("div",{className:"px-2 py-1 text-[11px] text-gray-700 dark:text-gray-200",children:yZ(a)}),t.jsx(dd,{rows:i}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2 px-2 py-1",children:[t.jsx("button",{type:"button",onClick:()=>r(a),className:"rounded border border-gray-500 px-1.5 py-0.5 text-[11px] font-medium text-gray-900 hover:bg-gray-100 dark:border-gray-400 dark:text-gray-50 dark:hover:bg-gray-800",children:"Use this"}),t.jsx("button",{type:"button",onClick:s,className:"rounded border border-gray-300 px-1.5 py-0.5 text-[11px] text-gray-700 hover:border-gray-400 dark:border-gray-700 dark:text-gray-200",children:"Discard"})]})]})}function yZ(e){const n=`${e.lines.length} line${e.lines.length===1?"":"s"}.`;if(e.keptCommonLines===0)return n;const r=e.keptCommonLines===1?"1 line":`${e.keptCommonLines} lines`;return`${n} Keeps ${r} both versions had.`}function U0({children:e}){return t.jsx("div",{className:"border-l-2 border-ai-signal-fill bg-ai-surface-2 px-2 py-1 text-[12px] text-gray-700 dark:text-gray-200",children:e})}function bZ({state:e,seed:n,path:r,ordinal:s,total:a,onDraft:i,onSave:c,onCancel:d}){const[u,m]=f.useState(n),h=f.useRef(null),g=f.useRef(null);f.useEffect(()=>{var w;const y=document.activeElement,b=g.current;return(w=h.current)==null||w.focus(),()=>{const k=document.activeElement;(k==null||k===document.body||(b==null?void 0:b.contains(k))===!0)&&(y==null?void 0:y.isConnected)===!0&&y.focus()}},[]);const x=e.status==="saving";return t.jsxs("div",{ref:g,className:"border-l-2 border-gray-300 bg-gray-50 dark:border-gray-700 dark:bg-gray-900",children:[t.jsx("div",{className:"px-2 py-1 text-[11px] font-medium text-gray-700 dark:text-gray-200",children:YY}),e.status==="refused"&&t.jsx("div",{className:"px-2 pb-1 text-[12px] text-gray-800 dark:text-gray-100",children:e.message}),t.jsx("textarea",{ref:h,value:u,readOnly:x,"aria-busy":x||void 0,onChange:y=>{m(y.target.value),i(y.target.value)},"aria-label":eX(r,s,a),spellCheck:!1,className:"block max-h-[60vh] w-full resize-y border-0 bg-transparent px-2 py-1 font-mono text-[12px] leading-[18px] text-gray-900 outline-none read-only:opacity-60 focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-sky-600 dark:text-gray-100 dark:focus-visible:ring-sky-400",rows:Math.min(24,Math.max(3,u.split(`
71
+ `).length+1))}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2 px-2 py-1",children:[t.jsx("button",{type:"button",disabled:x,onClick:()=>c(u),className:"rounded border border-gray-500 px-1.5 py-0.5 text-[11px] font-medium text-gray-900 hover:bg-gray-100 disabled:opacity-60 dark:border-gray-400 dark:text-gray-50 dark:hover:bg-gray-800",children:x?JY:XY}),t.jsx("button",{type:"button",onClick:d,className:"rounded border border-gray-300 px-1.5 py-0.5 text-[11px] text-gray-700 hover:border-gray-400 dark:border-gray-700 dark:text-gray-200",children:ZY}),t.jsx("span",{className:"text-[12px] text-gray-600 dark:text-gray-300",children:tX})]})]})}const H0="flex items-center gap-1 rounded border px-1 py-0.5 text-[11px] leading-none transition-colors border-gray-300 text-gray-700 hover:border-gray-400 hover:bg-gray-100 dark:border-gray-700 dark:text-gray-200 dark:hover:border-gray-600 dark:hover:bg-gray-800",$N="flex items-center gap-1 rounded border px-1 py-0.5 text-[11px] leading-none border-gray-500 bg-gray-100 text-gray-900 dark:border-gray-400 dark:bg-gray-800 dark:text-gray-50";function vZ({region:e,slot:n,role:r,fileIndex:s,ordinal:a,total:i,path:c,baseRef:d,active:u,sideTakes:m,onAskClaude:h,askInFlight:g,onEdit:x,editOpen:y,onActivate:b,onDecide:w}){var T;const k=yI(d),j=u?0:-1,N=$=>e.allowed.includes($),I=((T=e.wand)==null?void 0:T.reason)==="disjoint_words"&&N("disjoint_merge"),S=($,P,C,L,F,M)=>t.jsxs("button",{type:"button",tabIndex:j,"aria-pressed":P,title:C,"aria-label":C,onClick:()=>{b(),w(F)},className:P?$N:H0,children:[L,M!=null&&t.jsx("span",{children:M})]},$);return t.jsxs("div",{role:"group","aria-label":xI(e,a,i,c),"data-mr-region":`${s}:${e.id}`,onFocus:b,onMouseDown:b,className:`flex flex-wrap items-center gap-1 px-1 py-1 ${u?"bg-gray-100 dark:bg-gray-900":""}`,children:[t.jsx("span",{className:`mr-1 text-[11px] font-medium ${r==null?"":td[r]}`,children:HY(e,n)}),m&&N("ours")&&S("ours",n.kind==="left",k.left,t.jsx(wx,{size:13}),"ours"),m&&N("theirs")&&S("theirs",n.kind==="right",k.right,t.jsx(jx,{size:13}),"theirs"),N("both_ours_first")&&S("both",n.kind==="both-lr"||n.kind==="both-rl",n.kind==="both-rl"?k.bothRl:k.bothLr,t.jsx(l_,{size:13}),n.kind==="both-rl"?"both_theirs_first":"both_ours_first"),(n.kind==="both-lr"||n.kind==="both-rl")&&N("both_theirs_first")&&S("swap",!1,k.swap,t.jsx(c_,{size:13}),n.kind==="both-lr"?"both_theirs_first":"both_ours_first",n.kind==="both-lr"?"Yours first":`${d} first`),I&&S("wand",n.kind==="wand",kZ,t.jsx(yS,{size:13}),"disjoint_merge"),N("base")&&S("ignore",n.kind==="ignored",k.ignore,t.jsx(d_,{size:13}),"base"),h!=null&&e.kind==="conflict"&&t.jsxs("button",{type:"button",tabIndex:j,disabled:g===!0,title:_N,"aria-label":_N,onClick:()=>{b(),h()},className:`${H0} disabled:opacity-60`,children:[t.jsx(Ps,{size:13}),t.jsx("span",{children:g===!0?"Asking…":"Ask Claude"})]}),x!=null&&t.jsxs("button",{type:"button",tabIndex:j,"aria-expanded":y===!0,title:k.edit,"aria-label":k.edit,onClick:()=>{b(),x()},className:y===!0?$N:H0,children:[t.jsx(fS,{size:13}),t.jsx("span",{children:QY})]}),n.kind!=="unapplied"&&S("undo",!1,k.undo,t.jsx(bS,{size:13}),null)]})}const kZ="Merge both edits — they don’t overlap",_N="Ask Claude to merge this change",wZ=8,kd=3;function PN(e,n,r){const s=Mi(e.map(i=>i.text),n),a=e.map((i,c)=>({kind:"line",n:i.n,text:i.text,html:(s==null?void 0:s[c])??null}));return r?[...a.slice(0,kd),{kind:"gap"},...a.slice(a.length-kd)]:a}function jZ(e,n,r){const s=Mi(e,n),a=e.map((i,c)=>({kind:"line",n:null,text:i,html:(s==null?void 0:s[c])??null}));return r?[...a.slice(0,kd),{kind:"gap"},...a.slice(a.length-kd)]:a}function NZ({region:e,slot:n,fileIndex:r,path:s,baseRef:a,ordinal:i,total:c,language:d,narrow:u,active:m,ask:h,onAskClaude:g,onUseSuggestion:x,onDiscardSuggestion:y,edit:b,editDraft:w,onEditDraft:k,onOpenEdit:j,onCancelEdit:N,onSaveEdit:I,onActivate:S,onDecide:T}){const[$,P]=f.useState(!1),C=yI(a),L=NY(e,n),F=L==null?null:GY[L],M=B0(O0(e,n,"left")),D=B0(O0(e,n,"centre")),A=B0(O0(e,n,"right")),W=Fe=>`${r}:${e.id}:${Fe}`,z=e.kind==="unchanged",te=z&&e.base.length>wZ,H=te&&!$,B=H?e.base.length-kd*2:0,O=z?e.base:e.ours,E=z?e.base:e.theirs,ee=f.useMemo(()=>_Y(e,n),[e,n]),K=f.useMemo(()=>PN(O,d,H),[O,d,H]),U=f.useMemo(()=>PN(E,d,H),[E,d,H]),Q=f.useMemo(()=>jZ(ee,d,H),[ee,d,H]),J=te?t.jsxs("button",{type:"button",onClick:()=>P(Fe=>!Fe),className:"flex w-full items-center gap-1 px-1 py-0.5 text-left text-[11px] text-gray-600 hover:text-gray-900 dark:text-gray-400 dark:hover:text-gray-100",children:[t.jsx(Mt,{dir:$?"down":"right",size:11}),$?jX:wX(B)]}):null,ne=Fe=>{const oe=Fe==="left"?"ours":"theirs",re=Fe==="left"?C.left:C.right;return t.jsx("div",{className:"relative z-[1] flex items-start justify-center pt-0.5",children:ip(e,Fe)&&lp(n,Fe)!=="contributed"&&t.jsx("button",{type:"button",tabIndex:m?0:-1,"data-mr-take":`${r}:${e.id}:${Fe}`,title:re,"aria-label":VY(re,e,i,c,s),onFocus:S,onClick:()=>{S(),T(oe)},className:"rounded px-1.5 py-0.5 text-gray-500 transition-colors hover:bg-gray-100 hover:text-gray-900 focus:outline-none focus-visible:bg-gray-100 focus-visible:text-gray-900 focus-visible:ring-1 focus-visible:ring-sky-600 dark:text-gray-400 dark:hover:bg-gray-800 dark:hover:text-gray-100 dark:focus-visible:bg-gray-800 dark:focus-visible:text-gray-100 dark:focus-visible:ring-sky-400",children:Fe==="left"?t.jsx(wx,{size:13}):t.jsx(jx,{size:13})})})},ae=z?null:t.jsx(vZ,{region:e,slot:n,role:L,fileIndex:r,ordinal:i,total:c,path:s,baseRef:a,active:m,sideTakes:u,onAskClaude:g,askInFlight:(h==null?void 0:h.status)==="asking",onEdit:j,editOpen:b!=null,onActivate:S,onDecide:T}),we=h==null||x==null||y==null?null:t.jsx(xZ,{state:h,language:d,onUse:x,onDiscard:y}),$e=b==null||I==null||N==null||k==null?null:t.jsx(bZ,{state:b,seed:w??ee.join(`
72
+ `),path:s,ordinal:i,total:c,onDraft:k,onSave:I,onCancel:N});return t.jsx("div",{className:"contents",children:u?t.jsxs("div",{className:"col-span-full border-t border-gray-200 py-1 dark:border-gray-800",children:[t.jsx(z0,{label:mI,rows:K,paint:M,anchor:W("left")}),ae,t.jsx(z0,{label:gI,rows:Q,paint:D,rule:F,anchor:W("centre")}),we,$e,t.jsx(z0,{label:fI(a),rows:U,paint:A,anchor:W("right")}),J]}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"min-w-0 border-t border-gray-200 dark:border-gray-800",children:[t.jsx(dd,{rows:K,paint:M,anchor:W("left"),ariaHidden:!0}),J]}),t.jsx("div",{className:"border-t border-gray-200 dark:border-gray-800",children:ne("left")}),t.jsxs("div",{className:"min-w-0 border-t border-gray-200 dark:border-gray-800",children:[ae,t.jsx(dd,{rows:Q,paint:D,rule:F,anchor:W("centre")}),we,$e]}),t.jsx("div",{className:"border-t border-gray-200 dark:border-gray-800",children:ne("right")}),t.jsx("div",{className:"min-w-0 border-t border-gray-200 dark:border-gray-800",children:t.jsx(dd,{rows:U,paint:A,anchor:W("right"),ariaHidden:!0})})]})})}function z0({label:e,rows:n,paint:r,rule:s,anchor:a}){return t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"px-1 text-[11px] font-medium text-gray-500 dark:text-gray-400",children:e}),t.jsx(dd,{rows:n,paint:r,rule:s,anchor:a})]})}const SZ="Claude isn’t available here.",CZ="Claude couldn’t answer just now.";async function RZ(e,n){const r=await fetch(`/api/pro/prs/${e}/conflict-hunk/suggest`,{method:"POST",credentials:"same-origin",headers:{"content-type":"application/json"},body:JSON.stringify(n)});return r.ok?await r.json():{enabled:!1}}const Lo=new Map;function IZ(e,n){const{prSummary:r}=vt(),{data:s}=In(),{data:a}=ya(e),[i,c]=f.useState({}),[d,u]=f.useState(()=>{if(n==null)return{};for(const b of[...Lo.keys()])b!==n&&Lo.delete(b);return Lo.get(n)??{}}),m=f.useRef(new Set),h=r&&((s==null?void 0:s.conflictResolver)??!1)&&((a==null?void 0:a.viewerCanPush)??!1),g=f.useCallback((b,w)=>{const k=Dn(b,w);m.current.delete(k),c(j=>{if(j[k]===void 0)return j;const N={...j};return delete N[k],N})},[]);f.useEffect(()=>{if(n!=null){for(const b of[...Lo.keys()])b!==n&&Lo.delete(b);u(Lo.get(n)??{})}},[n]);const x=f.useCallback((b,w,k)=>{if(n!=null){const j=Lo.get(n)??{};j[k.suggestionId]=k.lines,Lo.set(n,j)}u(j=>({...j,[k.suggestionId]:k.lines})),g(b,w)},[g,n]),y=f.useCallback(b=>{if(!h||n==null)return;const w=Dn(b.fileIndex,b.regionId);if(m.current.has(w))return;m.current.add(w),c(j=>({...j,[w]:{status:"asking"}}));const k=j=>{m.current.delete(w),c(N=>N[w]===void 0?N:{...N,[w]:j})};RZ(e,{sessionId:n,...b}).then(j=>{k(j.enabled===!1?{status:"refused",message:SZ}:j.ok?{status:"ready",suggestion:j.suggestion}:{status:"refused",message:j.message})}).catch(()=>k({status:"refused",message:CZ}))},[h,e,n]);return{enabled:h,states:i,acceptedLines:d,ask:y,clear:g,accept:x}}const TZ="That didn’t save. Try again.",ud=new Map;function EN(e){for(const n of[...ud.keys()])n!==e&&ud.delete(n);return ud.get(e)??{}}function $Z(e,n){const[r,s]=f.useState({}),[a,i]=f.useState(()=>n==null?{}:EN(n)),c=f.useRef(new Set),d=f.useRef({});f.useEffect(()=>{n!=null&&i(EN(n))},[n]);const u=f.useCallback((y,b)=>d.current[Dn(y,b)],[]),m=f.useCallback((y,b,w)=>{d.current[Dn(y,b)]=w},[]),h=f.useCallback((y,b)=>{s(w=>({...w,[Dn(y,b)]:{status:"editing"}}))},[]),g=f.useCallback((y,b)=>{const w=Dn(y,b);c.current.delete(w),delete d.current[w],s(k=>{if(k[w]===void 0)return k;const j={...k};return delete j[w],j})},[]),x=f.useCallback(async y=>{if(n==null)return null;const b=Dn(y.fileIndex,y.regionId);if(c.current.has(b))return null;c.current.add(b),s(k=>({...k,[b]:{status:"saving"}}));const w=k=>{c.current.delete(b),s(j=>j[b]===void 0?j:{...j,[b]:k})};try{const k=await he.editConflictRegion(e,{sessionId:n,...y});if(!k.ok)return w({status:"refused",message:k.message}),null;if(!c.current.has(b))return null;const j=ud.get(n)??{};return j[k.edit.editId]=k.edit.lines,ud.set(n,j),i(N=>({...N,[k.edit.editId]:k.edit.lines})),g(y.fileIndex,y.regionId),k.edit}catch(k){return w({status:"refused",message:k instanceof Error&&k.message!==""?k.message:TZ}),null}},[g,e,n]);return{states:r,editLines:a,draftFor:u,noteDraft:m,open:h,close:g,save:x}}const _Z=1100,PZ=8e3;function EZ({session:e,sessionKey:n,files:r,loadingFiles:s,fileErrors:a,loadFile:i,onRetryFile:c,suggestionLines:d,plan:u,landBlockedReason:m,jumpToFile:h,onJumpConsumed:g,onLand:x}){const y=Xx(n),b=IZ(e.prId,e.sessionId),w=$Z(e.prId,e.sessionId),k=Is(fe=>fe.decideRegion),j=(y==null?void 0:y.decisions)??FZ,N=(y==null?void 0:y.suggestionIds)??MN,I=(y==null?void 0:y.editIds)??MN,S=f.useMemo(()=>e.files.filter(fe=>fe.unsupported==null),[e.files]),[T,$]=f.useState(()=>{var fe;return((fe=S[0])==null?void 0:fe.index)??-1}),[P,C]=f.useState(null),[L,F]=f.useState(!1),[M,D]=f.useState(!1),[A,W]=f.useState(!1),[z,te]=f.useState(!1),[H,B]=f.useState(null),[O,E]=f.useState(""),ee=f.useRef([]),[K,U]=f.useState(0),Q=f.useRef(!1),J=f.useRef(null),ne=f.useRef(null),ae=r[T]??null,we=e.files.find(fe=>fe.index===T)??null,$e=we==null?null:Yl(we.path);f.useEffect(()=>{const fe=J.current;if(fe==null)return;const rt=new ResizeObserver(et=>{var Wt;const It=(Wt=et[0])==null?void 0:Wt.contentRect.width;It!=null&&te(It<_Z)});return rt.observe(fe),()=>rt.disconnect()},[]),f.useEffect(()=>{T<0||r[T]!=null||s.has(T)||a[T]==null&&i(T)},[T,r,s,a,i]),f.useEffect(()=>{ee.current=[],U(0)},[n]);const Fe=f.useRef(null);f.useEffect(()=>{h!=null&&(Fe.current=h,Q.current=!0,$(h),C(null),g==null||g())},[h,g]);const oe=f.useMemo(()=>{const fe={};for(const[rt,et]of Object.entries(r))fe[Number(rt)]=dI(et.regions,et.index,j);return fe},[r,j]),re=f.useMemo(()=>ae==null?[]:ae.regions.filter(fe=>fe.kind!=="unchanged"),[ae]),X=f.useMemo(()=>re.find(fe=>fe.id===P)??null,[re,P]),le=f.useMemo(()=>({...d,...b.acceptedLines}),[d,b.acceptedLines]),Ne=f.useMemo(()=>({suggestionIds:N,suggestionLines:le,editIds:I,editLines:w.editLines}),[N,le,I,w.editLines]),Ve=f.useMemo(()=>{const fe=new Map;if(ae==null)return fe;for(const rt of ae.regions)fe.set(rt.id,jY(rt,ae.index,j,Ne));return fe},[ae,j,Ne]),me=f.useCallback(fe=>{if(fe.length===0)return;const rt=fe.map(et=>{const It=Dn(et.fileIndex,et.regionId);return{fileIndex:et.fileIndex,regionId:et.regionId,previous:j[It]??null,previousSuggestionId:N[It]??null,previousEditId:I[It]??null}});ee.current=[...ee.current,rt].slice(-50),U(ee.current.length);for(const et of fe)et.decision!=="suggestion"&&b.clear(et.fileIndex,et.regionId),et.decision!=="edited"&&w.close(et.fileIndex,et.regionId),k({key:n,fileIndex:et.fileIndex,regionId:et.regionId,decision:et.decision,suggestionId:et.suggestionId??null,editId:et.editId??null})},[j,N,I,k,n,b.clear,w.close]),be=f.useCallback(fe=>{X!=null&&(fe!=null&&!X.allowed.includes(fe)||(me([{fileIndex:T,regionId:X.id,decision:fe}]),E(fe==null?"Decision cleared.":`${AN[fe]} on this change.`)))},[X,T,me]),at=f.useCallback(()=>{const fe=ee.current[ee.current.length-1];if(fe!=null){ee.current=ee.current.slice(0,-1),U(ee.current.length);for(const rt of fe)k({key:n,fileIndex:rt.fileIndex,regionId:rt.regionId,decision:rt.previous,suggestionId:rt.previousSuggestionId,editId:rt.previousEditId});E("Undone.")}},[k,n]),ft=f.useCallback(()=>{if(ae==null)return;const fe=xN(ae.regions,ae.index,j);me(fe.moves.map(et=>({...et,suggestionId:null})));const rt=PY(fe);B(rt),E(rt)},[ae,j,me]),mt=f.useCallback(fe=>{if(ae==null)return;const{moves:rt}=yN(ae.regions,ae.index,j,fe);if(rt.length===0)return;me(rt.map(It=>({...It,suggestionId:null,editId:null})));const et=fe==="ours"?lX:cX(e.baseRef);B(et),E(et)},[ae,j,me,e.baseRef]),se=f.useMemo(()=>{if(ae==null)return{ours:!0,theirs:!0};const fe=rt=>yN(ae.regions,ae.index,j,rt).moves.length===0;return{ours:fe("ours"),theirs:fe("theirs")}},[ae,j]);f.useEffect(()=>{if(H==null)return;const fe=window.setTimeout(()=>B(null),PZ);return()=>window.clearTimeout(fe)},[H]);const Ce=f.useCallback((fe,rt)=>j[Dn(rt,fe.id)]==null,[j]),_e=f.useCallback(async(fe,rt)=>{const et=(St,je)=>(rt?St.kind==="conflict":!0)&&Ce(St,je);if(ae!=null){const St=ae.regions.filter(qt=>qt.kind!=="unchanged"),je=St.findIndex(qt=>qt.id===P),Pt=(fe===1?St.slice(je+1):St.slice(0,Math.max(je,0)).reverse()).find(qt=>et(qt,ae.index));if(Pt!=null){Q.current=!0,C(Pt.id);return}}const It=fe===1?S:[...S].reverse(),Wt=It.findIndex(St=>St.index===T);for(const St of It.slice(Wt+1)){const je=r[St.index]??await i(St.index);if(je==null)continue;const Rt=je.regions.filter(Wn=>Wn.kind!=="unchanged"),qt=(fe===1?Rt:[...Rt].reverse()).find(Wn=>et(Wn,St.index));if(qt!=null){Q.current=!0,$(St.index),C(qt.id),E(`Moved to ${St.path}.`);return}}E(rt?"No conflicts left.":"Nothing left to decide.")},[ae,P,T,S,r,i,Ce]),pe=f.useCallback(fe=>{const rt=S.findIndex(It=>It.index===T),et=S[rt+fe];et!=null&&(Q.current=!0,$(et.index),C(null))},[S,T]),Qe=f.useCallback(fe=>{var et,It;if(fe===T){const Wt=(et=r[fe])==null?void 0:et.regions.find(St=>St.kind!=="unchanged"&&j[Dn(fe,St.id)]==null);if(Wt==null)return;Q.current=!0,C(Wt.id);return}Fe.current=fe,Q.current=!0,$(fe),C(null);const rt=(It=e.files.find(Wt=>Wt.index===fe))==null?void 0:It.path;rt!=null&&E(`Moved to ${rt}.`)},[T,r,j,e.files]),ct=DY(u.outstanding,T);f.useEffect(()=>{var fe;P!=null&&re.some(rt=>rt.id===P)||C(((fe=re[0])==null?void 0:fe.id)??null)},[re,P]),f.useEffect(()=>{const fe=Fe.current;if(fe==null||T!==fe)return;if(a[fe]!=null){Fe.current=null;return}const rt=r[fe];if(rt==null)return;Fe.current=null;const et=rt.regions.find(It=>It.kind!=="unchanged"&&j[Dn(fe,It.id)]==null);et!=null&&(Q.current=!0,C(et.id))},[T,r,a,j]),f.useEffect(()=>{var et;if(P==null)return;const fe=ne.current,rt=fe==null?void 0:fe.querySelector(`[data-mr-region="${T}:${P}"]`);rt==null||fe==null||(rt.scrollIntoView({block:"nearest"}),Q.current&&(Q.current=!1,(et=fe.querySelector(`[data-mr-take="${T}:${P}:left"]`)??fe.querySelector(`[data-mr-take="${T}:${P}:right"]`)??rt.querySelector("button"))==null||et.focus()))},[T,P]);const Bt=f.useCallback(fe=>{const rt=fe.target;if((rt==null?void 0:rt.closest('input, textarea, select, [contenteditable="true"]'))==null&&!(fe.key==="Enter"&&(rt==null?void 0:rt.closest('button, a[href], [role="button"]'))!=null)){if((fe.metaKey||fe.ctrlKey)&&fe.key.toLowerCase()==="z"){fe.preventDefault(),at();return}if(!(fe.metaKey||fe.ctrlKey||fe.altKey))switch(fe.key){case"n":fe.preventDefault(),_e(1,!1);return;case"p":fe.preventDefault(),_e(-1,!1);return;case"N":fe.preventDefault(),_e(1,!0);return;case"P":fe.preventDefault(),_e(-1,!0);return;case"ArrowLeft":fe.preventDefault(),be("ours");return;case"ArrowRight":fe.preventDefault(),be("theirs");return;case"b":fe.preventDefault(),be("both_ours_first");return;case"B":fe.preventDefault(),be("both_theirs_first");return;case"x":fe.preventDefault(),be("base");return;case"u":fe.preventDefault(),be(null);return;case"w":fe.preventDefault(),ft();return;case"f":fe.preventDefault(),F(!0);return;case"[":fe.preventDefault(),pe(-1);return;case"]":fe.preventDefault(),pe(1);return;case"Enter":if(x==null)return;if(fe.preventDefault(),m!=null){E(m);return}x();return}}},[be,ft,_e,pe,at,x,m]),Je=S.findIndex(fe=>fe.index===T),Qt=u.rows.find(fe=>fe.index===T&&fe.state!=="unsupported"),Ft=ae==null||xN(ae.regions,ae.index,j).moves.length===0;return t.jsxs("div",{ref:J,className:"flex min-h-0 flex-1 flex-col",children:[t.jsx(fZ,{files:e.files,activeIndex:T,tallies:oe,fileMenuOpen:L,onFileMenuOpen:F,onSelectFile:fe=>{$(fe),C(null)},onStepFile:pe,canStepBack:Je>0,canStepForward:Je>=0&&Je<S.length-1,baseRef:e.baseRef,onTakeFile:mt,takeFileDisabled:se,onWand:ft,wandDisabled:Ft,onUndo:at,undoDepth:K,activeRegion:X,language:$e,baseOpen:M,onBaseOpen:D,fileDecided:(Qt==null?void 0:Qt.decided)??null,fileDecidable:(Qt==null?void 0:Qt.decidable)??null,decided:u.decidedTotal,total:u.decidableTotal,outstanding:u.outstanding,outstandingOpen:A,onOutstandingOpen:W,onJumpToFile:Qe,nextOutstanding:ct,onNextOutstanding:()=>{ct!=null&&Qe(ct)},blockedReason:m,onLand:x}),t.jsx(AZ,{session:e,narrow:z,wandMessage:H}),t.jsxs("div",{className:"relative flex min-h-0 flex-1 flex-col",children:[t.jsx("div",{ref:ne,tabIndex:-1,onKeyDown:Bt,className:"min-h-0 flex-1 overflow-y-auto overflow-x-hidden outline-none",children:ae==null?t.jsx("div",{className:"px-4 py-3 text-xs text-gray-600 dark:text-gray-300",children:we==null?t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx("div",{children:m??"Nothing to resolve here."}),u.notCarried.length>0&&t.jsxs("div",{children:[t.jsx("div",{className:"font-medium text-gray-700 dark:text-gray-200",children:bI}),t.jsx("ul",{className:"mt-0.5",children:u.notCarried.map(fe=>t.jsxs("li",{className:"flex flex-wrap items-baseline gap-x-2",children:[t.jsx("span",{className:"font-mono text-gray-800 dark:text-gray-100",children:fe.path}),t.jsx("span",{children:fe.label})]},fe.index))}),t.jsx("div",{className:"mt-1",children:vI})]})]}):a[T]!=null?t.jsxs("span",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("span",{children:a[T]}),t.jsx("button",{type:"button",onClick:()=>c(T),className:"rounded border border-gray-300 px-2 py-0.5 text-[11px] hover:bg-gray-100 dark:border-gray-600 dark:hover:bg-gray-800",children:"Try again"})]}):`Reading ${we.path}…`}):t.jsxs("div",{"data-mr-grid":!0,className:"grid items-stretch",style:{gridTemplateColumns:z?"minmax(0,1fr)":"minmax(0,1fr) 1.75rem minmax(0,1fr) 1.75rem minmax(0,1fr)"},children:[!z&&t.jsxs("div",{className:"contents",children:[t.jsx(Qc,{children:mI}),t.jsx(Qc,{}),t.jsx(Qc,{children:gI}),t.jsx(Qc,{}),t.jsx(Qc,{children:fI(e.baseRef)})]}),ae.regions.map(fe=>{const rt=re.findIndex(et=>et.id===fe.id)+1;return t.jsx(NZ,{region:fe,slot:Ve.get(fe.id)??MZ,fileIndex:ae.index,path:ae.path,baseRef:e.baseRef,ordinal:rt,total:re.length,language:$e,narrow:z,active:fe.id===P,ask:b.states[Dn(ae.index,fe.id)],onAskClaude:b.enabled?()=>b.ask({fileIndex:ae.index,regionId:fe.id,fingerprint:fe.fingerprint}):void 0,onUseSuggestion:et=>{C(fe.id),b.accept(ae.index,fe.id,et),me([{fileIndex:ae.index,regionId:fe.id,decision:"suggestion",suggestionId:et.suggestionId}]),E("Took Claude’s suggestion.")},onDiscardSuggestion:()=>b.clear(ae.index,fe.id),edit:w.states[Dn(ae.index,fe.id)],editDraft:w.draftFor(ae.index,fe.id),onEditDraft:et=>w.noteDraft(ae.index,fe.id,et),onOpenEdit:fe.kind==="unchanged"?void 0:()=>{C(fe.id),b.clear(ae.index,fe.id),w.open(ae.index,fe.id)},onCancelEdit:()=>w.close(ae.index,fe.id),onSaveEdit:et=>{C(fe.id),w.save({fileIndex:ae.index,regionId:fe.id,fingerprint:fe.fingerprint,text:et}).then(It=>{It!=null&&(me([{fileIndex:ae.index,regionId:fe.id,decision:"edited",editId:It.editId}]),E("Saved your text for this change."))})},onActivate:()=>C(fe.id),onDecide:et=>{C(fe.id),!(et!=null&&!fe.allowed.includes(et))&&(me([{fileIndex:ae.index,regionId:fe.id,decision:et}]),E(et==null?"Decision cleared.":`${AN[et]} on this change.`))}},`${ae.index}:${fe.id}`)})]})}),t.jsx(dZ,{scrollerRef:ne,fileIndex:(ae==null?void 0:ae.index)??-1,regions:(ae==null?void 0:ae.regions)??LZ,slots:Ve,narrow:z})]}),t.jsx("div",{"aria-live":"polite",className:"sr-only",children:O})]})}function Qc({children:e}){return t.jsx("div",{"data-mr-pane-header":!0,className:"sticky top-0 z-10 border-b border-gray-200 bg-white px-2 py-1 text-[11px] font-medium text-gray-600 dark:border-gray-800 dark:bg-gray-950 dark:text-gray-300",children:e})}function AZ({session:e,narrow:n,wandMessage:r}){const s=[];return e.renameDetection==="off"&&s.push(bX),e.truncated&&s.push(vX(e.files.length,e.totalConflictedPaths)),n&&s.push(kX),r!=null&&s.push(r),s.length===0?null:t.jsx("div",{className:"shrink-0 border-b border-gray-200 px-4 py-1.5 dark:border-gray-800",children:s.map(a=>t.jsx("div",{className:"text-[12px] text-gray-700 dark:text-gray-200",children:a},a))})}const AN={ours:"Took your version",theirs:"Took the base branch’s version",both_ours_first:"Took both, yours first",both_theirs_first:"Took both, the base branch first",base:"Ignored",disjoint_merge:"Merged both edits",suggestion:"Took the suggestion",edited:"Used your own text"},MZ=Object.freeze({kind:"unapplied"}),LZ=Object.freeze([]),FZ=Object.freeze({}),MN=Object.freeze({}),OZ=/^[A-Za-z0-9][A-Za-z0-9._/-]*$/;function K0(e,n){return e.toLowerCase()===n.toLowerCase()}function DZ(e,n){const r=e.trim();return r===""?"empty":!OZ.test(r)||r.includes("..")?"malformed":K0(r,n.headRef)?"pr_branch":K0(r,n.baseRef)?"base_branch":n.reserved.some(s=>K0(r,s))?"default_branch":null}function BZ(e,n){switch(e){case"empty":return"Name the branch.";case"malformed":return"Branch names start with a letter or digit and can use letters, digits, . _ / and -.";case"pr_branch":return`That’s this PR’s branch — use “Push to ${n.headRef}” instead.`;case"base_branch":return"That’s this PR’s base branch. Pick another name.";case"default_branch":return"That’s the default branch. Pick another name."}}function WZ({session:e,sessionKey:n,files:r,plan:s,headMoved:a,autoMergeArmed:i,commitError:c,connectionLost:d,onBack:u,onJumpToFile:m,onCommit:h,onRestart:g,onClose:x}){var U;const y=Xx(n),b=(y==null?void 0:y.decisions)??qZ,w=(y==null?void 0:y.suggestionIds)??ON,k=(y==null?void 0:y.editIds)??ON,j=e.strategies.includes("rebase"),[N,I]=f.useState("merge"),[S,T]=f.useState(!1),$=BY(e,S),P=$.toNewBranch,[C,L]=f.useState(""),[F,M]=f.useState(!0),[D,A]=f.useState(!1);f.useEffect(()=>{c!=null&&A(!1)},[c]);const W=e.commit,z=(W==null?void 0:W.status)==="failed"||c!=null,te=!z&&(D||(W==null?void 0:W.status)==="running"),H=P?DZ(C,{headRef:e.headRef,baseRef:e.baseRef,reserved:e.reservedBranchNames}):null,B=H==null?null:BZ(H,{headRef:e.headRef,baseRef:e.baseRef,reserved:e.reservedBranchNames}),O=pI(s,a),E=O!=null||B!=null||te,ee=s.notCarried;function K(){if(E)return;const Q=P?{kind:"new_branch",branch:C.trim(),openPr:F}:{kind:"pr_branch"};A(!0),h(WY({session:e,plan:s,loaded:r,decisions:b,suggestionIds:w,editIds:k,strategy:N,target:Q}))}return t.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-4 py-3",children:t.jsxs("div",{className:"mx-auto flex w-full max-w-2xl flex-col gap-5",children:[a&&t.jsxs("p",{className:"flex items-start gap-1.5 text-[12px] text-gray-800 dark:text-gray-100",children:[t.jsx(Jt,{size:13,className:"mt-px shrink-0"}),t.jsx("span",{children:hI})]}),t.jsxs("section",{children:[t.jsx(G0,{children:SX}),t.jsx("p",{className:"text-[12px] text-gray-800 dark:text-gray-100",children:CX(s.resolved.length,s.totalFiles)}),t.jsx(LN,{rows:s.resolved}),s.outstanding.length>0&&t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"mt-2 text-[12px] text-gray-800 dark:text-gray-100",children:RX}),t.jsx("ul",{className:"mt-0.5",children:s.outstanding.map(Q=>t.jsx("li",{children:t.jsxs("button",{type:"button",onClick:()=>m(Q.index),"aria-label":kI(Q.path,Q.remaining),className:"flex w-full flex-wrap items-baseline gap-x-2 rounded px-1 py-0.5 text-left text-[12px] hover:bg-gray-100 dark:hover:bg-gray-800",children:[t.jsx("span",{className:"font-mono text-gray-800 dark:text-gray-100",children:Q.path}),t.jsx("span",{className:"text-gray-600 dark:text-gray-300",children:vd(Q.remaining)})]})},Q.index))})]}),ee.length>0&&t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"mt-2 text-[12px] text-gray-800 dark:text-gray-100",children:bI}),t.jsx(LN,{rows:ee,withLabel:!0}),t.jsx("p",{className:"mt-1 text-[12px] text-gray-700 dark:text-gray-200",children:vI}),t.jsx("p",{className:"mt-2 text-[12px] text-gray-700 dark:text-gray-200",children:IX})]})]}),t.jsxs("section",{children:[t.jsx(G0,{children:TX}),t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx(Zu,{name:"conflict-strategy",checked:N==="merge",onSelect:()=>I("merge"),icon:t.jsx(bp,{size:13}),title:$X,detail:e.fullyResolvable?_X:PX}),t.jsx(Zu,{name:"conflict-strategy",checked:N==="rebase",onSelect:()=>I("rebase"),disabled:!j,icon:t.jsx(h_,{size:13}),title:EX,detail:j?SN(e.baseRef):e.rebaseUnavailableReason??SN(e.baseRef)})]})]}),t.jsxs("section",{children:[t.jsx(G0,{children:AX}),$.prBranchNote!=null&&t.jsx("p",{className:"mb-1.5 text-[12px] text-gray-800 dark:text-gray-100",children:$.prBranchNote}),t.jsxs("div",{className:"flex flex-col gap-2",children:[$.offerPrBranch&&t.jsx(Zu,{name:"conflict-target",checked:!P,onSelect:()=>T(!1),icon:t.jsx(Sk,{size:13}),title:MX(e.headRef)}),t.jsx(Zu,{name:"conflict-target",checked:P,onSelect:()=>T(!0),icon:t.jsx(Sk,{size:13}),title:LX})]}),P&&t.jsxs("div",{className:"mt-2",children:[t.jsx("label",{htmlFor:"conflict-branch-name",className:"block text-[11px] text-gray-600 dark:text-gray-300",children:FX}),t.jsx("input",{id:"conflict-branch-name",type:"text",value:C,spellCheck:!1,autoComplete:"off",onChange:Q=>L(Q.target.value),className:"mt-0.5 w-full rounded border border-gray-300 px-2 py-1 font-mono text-xs text-gray-900 dark:border-gray-700 dark:bg-gray-900 dark:text-gray-100"}),B!=null&&C.trim()!==""&&t.jsx("p",{className:"mt-1 text-[12px] text-gray-800 dark:text-gray-100",children:B}),t.jsxs("label",{className:"mt-1.5 flex items-center gap-1.5 text-[12px] text-gray-700 dark:text-gray-200",children:[t.jsx("input",{type:"checkbox",checked:F,onChange:Q=>M(Q.target.checked)}),OX]})]})]}),t.jsxs("section",{className:"flex flex-col gap-2 border-t border-gray-200 pt-3 dark:border-gray-800",children:[t.jsx("p",{className:"text-[11px] text-gray-600 dark:text-gray-300",children:DX(e.headSha,e.baseSha)}),i&&t.jsx("p",{className:"text-[12px] text-gray-800 dark:text-gray-100",children:UX}),z?t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsxs("p",{className:"text-[12px] text-gray-800 dark:text-gray-100",children:[eZ," ",((U=W==null?void 0:W.error)==null?void 0:U.message)??c??""]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Yc,{onClick:u,children:NN}),t.jsx(Yc,{onClick:g,children:wI}),t.jsx(Yc,{onClick:()=>x(!1),children:ux})]})]}):te&&d?t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx("p",{className:"text-[12px] text-gray-800 dark:text-gray-100","aria-live":"polite",role:"status",children:JX}),t.jsx("div",{className:"flex items-center gap-2",children:t.jsx(Yc,{onClick:()=>x(!0),children:ux})})]}):te?t.jsx("div",{className:"text-[12px] text-gray-700 dark:text-gray-200","aria-live":"polite",role:"status",children:(W==null?void 0:W.phase)!=null?HX[W.phase]:"Starting…"}):t.jsxs("div",{className:"flex flex-col gap-2",children:[O!=null&&t.jsx("p",{id:FN,className:"text-[12px] text-gray-800 dark:text-gray-100",children:O}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Yc,{onClick:u,children:NN}),t.jsx("button",{type:"button",onClick:K,disabled:E,title:O??void 0,"aria-label":WX(N==="rebase"?CN:dp),"aria-describedby":O!=null?FN:void 0,className:"rounded bg-gray-900 px-3 py-1 text-xs font-medium text-white disabled:opacity-40 dark:bg-gray-100 dark:text-gray-900",children:N==="rebase"?CN:dp})]})]})]})]})})}function G0({children:e}){return t.jsx("h2",{className:"mb-1 text-[11px] font-medium text-gray-600 dark:text-gray-300",children:e})}function LN({rows:e,withLabel:n=!1}){return e.length===0?null:t.jsx("ul",{className:"mt-0.5",children:e.map(r=>t.jsxs("li",{className:"flex flex-wrap items-baseline gap-x-2 text-[12px]",children:[t.jsx("span",{className:"font-mono text-gray-800 dark:text-gray-100",children:r.path}),n&&t.jsx("span",{className:"text-gray-600 dark:text-gray-300",children:r.label})]},r.index))})}function Zu({name:e,checked:n,onSelect:r,disabled:s=!1,icon:a,title:i,detail:c}){return t.jsxs("label",{className:`flex items-start gap-2 rounded border px-2.5 py-1.5 ${n?"border-gray-400 dark:border-gray-500":"border-gray-200 dark:border-gray-800"} ${s?"opacity-50":"cursor-pointer"}`,children:[t.jsx("input",{type:"radio",name:e,checked:n,disabled:s,onChange:r,className:"mt-0.5"}),t.jsxs("span",{className:"min-w-0",children:[t.jsxs("span",{className:"flex items-center gap-1.5 text-xs font-medium text-gray-900 dark:text-gray-100",children:[a,i]}),c!=null&&t.jsx("span",{className:"mt-0.5 block text-[12px] text-gray-600 dark:text-gray-300",children:c})]})]})}function Yc({onClick:e,children:n}){return t.jsx("button",{type:"button",onClick:e,className:"rounded border border-gray-300 px-2.5 py-1 text-xs text-gray-800 hover:border-gray-400 dark:border-gray-700 dark:text-gray-100 dark:hover:border-gray-600",children:n})}const FN="conflict-commit-blocked-reason",qZ=Object.freeze({}),ON=Object.freeze({});function UZ({session:e,result:n,plan:r,onClose:s}){const a=qY(n,r),i=new Set(n.resolvedPaths),c=r.resolved.filter(u=>i.has(u.path)).reduce((u,m)=>u+m.conflictsDecided,0),d=n.compareUrl==null?void 0:mn(n.compareUrl);return t.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-4 py-3",children:t.jsxs("div",{className:"mx-auto flex w-full max-w-2xl flex-col gap-2 text-[12px] text-gray-800 dark:text-gray-100","aria-live":"polite",children:[t.jsxs("p",{children:[KX(n.branch,n.commitSha)," ",GX(c,n.resolvedPaths.length)]}),a.length>0&&t.jsx("p",{children:VX(a)}),n.baseAdvanced&&t.jsx("p",{className:"text-gray-700 dark:text-gray-200",children:QX(e.baseRef)}),n.autoMergeDisarmed&&t.jsx("p",{className:"text-gray-700 dark:text-gray-200",children:YX}),!n.visible&&t.jsx("p",{className:"text-gray-700 dark:text-gray-200",children:XX}),t.jsxs("div",{className:"mt-1 flex items-center gap-2",children:[t.jsx("button",{type:"button",onClick:s,className:"rounded border border-gray-300 px-2.5 py-1 text-xs text-gray-800 hover:border-gray-400 dark:border-gray-700 dark:text-gray-100 dark:hover:border-gray-600",children:ux}),d!==void 0&&t.jsxs("a",{href:d,target:"_blank",rel:"noreferrer noopener",className:"text-xs text-gray-600 underline underline-offset-2 hover:text-gray-800 dark:text-gray-300 dark:hover:text-gray-100",children:[tZ,t.jsx(_t,{size:11,className:"ml-0.5 inline-block align-[-0.1em]"})]})]})]})})}function HZ({decided:e,total:n,onKeep:r,onClose:s}){const a=f.useRef(null);return f.useEffect(()=>{var i;(i=a.current)==null||i.focus()},[]),t.jsxs("div",{role:"alertdialog","aria-label":"Close the conflict resolver?",className:"flex shrink-0 flex-wrap items-center gap-3 border-t border-gray-200 px-4 py-2 dark:border-gray-800",children:[t.jsx("span",{className:"text-[12px] text-gray-800 dark:text-gray-100",children:rZ(e,n)}),t.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[t.jsx("button",{ref:a,type:"button",onClick:r,className:"rounded border border-gray-300 px-2.5 py-1 text-xs font-medium text-gray-900 hover:border-gray-400 dark:border-gray-600 dark:text-gray-100 dark:hover:border-gray-500",children:sZ}),t.jsx("button",{type:"button",onClick:s,className:"rounded border border-gray-200 px-2.5 py-1 text-xs text-gray-600 hover:border-gray-300 dark:border-gray-800 dark:text-gray-300 dark:hover:border-gray-700",children:aZ})]})]})}const zZ={cloning:"Getting a copy of the repository…",fetching:"Fetching both branches…",merging:"Working out what conflicts…",reading:Oy};function KZ(){const e=vL();return e==null?null:t.jsx(GZ,{target:e},e.prId)}function GZ({target:e}){var U;const n=Is(Q=>Q.closeConflictResolver),r=Is(Q=>Q.seedSession),s=Is(Q=>Q.confirming),a=Is(Q=>Q.setConfirming),i=Is(Q=>Q.sessions),{session:c,connection:d,openError:u,files:m,loadingFiles:h,fileErrors:g,loadFile:x,retryFile:y,restart:b}=gY(e.prId),w=d==="lost",[k,j]=f.useState("panes"),[N,I]=f.useState(null),S=c!=null&&c.status==="ready"?xL(e.prId,c.headSha,c.baseSha,c.modelHash):null,T=Xx(S);f.useEffect(()=>{S==null||c==null||r({key:S,sessionId:c.sessionId,conflictCount:c.files.reduce((Q,J)=>Q+J.conflictCount,0)})},[S,c,r]);const $=(T==null?void 0:T.decisions)??ZZ,P=f.useMemo(()=>c==null||c.status!=="ready"?null:LY(c,m,$),[c,m,$]),C=yY(e.prId),L=(c==null?void 0:c.commit)??null;bY(e.prId,L);const F=(L==null?void 0:L.status)==="done"&&L.result!=null,M=mL(L,C),D=f.useRef(!1),A=f.useRef(!1);f.useEffect(()=>{D.current=M,M&&(A.current=!0)},[M]);const W=f.useCallback(Q=>gL(D.current,Q),[]),z=He();f.useEffect(()=>()=>{A.current&&dn(z,e.prId,{armed:!0})},[z,e.prId]);const{data:te}=ya(e.prId),H=YZ((c==null?void 0:c.headSha)??null,te==null?void 0:te.headSha)&&!M,B=QZ(e.prId,te==null||te.state==="open"),O=Di(e.prId)!=null,E=P!=null&&P.decidedTotal>0&&!F;f.useEffect(()=>{const Q=J=>{if(J.key==="Escape"&&!UY()){if(J.stopImmediatePropagation(),s){a(!1);return}if(E){a(!0);return}n({reason:W("user")})}};return window.addEventListener("keydown",Q,!0),()=>window.removeEventListener("keydown",Q,!0)},[n,W,s,a,E]),f.useEffect(()=>{const Q=()=>n({reason:W("navigated")});return window.addEventListener("popstate",Q),()=>window.removeEventListener("popstate",Q)},[n,W]),f.useEffect(()=>{if(!E)return;const Q=J=>{J.preventDefault(),J.returnValue=""};return window.addEventListener("beforeunload",Q),()=>window.removeEventListener("beforeunload",Q)},[E]);const ee=f.useMemo(()=>S==null?!1:Object.values(i).some(Q=>Q.key!==S&&Q.key.startsWith(`${e.prId}:`)&&Q.decidedCount>0),[i,S,e.prId]),K=mn(e.githubUrl);return t.jsxs("div",{className:"fixed inset-0 z-[60] flex flex-col bg-white dark:bg-gray-950",role:"dialog","aria-modal":"true","aria-label":`Resolve conflicts in ${e.repoFullName} #${e.prNumber}`,children:[t.jsxs("header",{className:"flex shrink-0 items-center gap-3 border-b border-gray-200 px-4 py-2 dark:border-gray-800",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"truncate text-sm font-medium text-gray-900 dark:text-gray-100",children:e.prTitle}),t.jsxs("div",{className:"truncate text-[11px] text-gray-500 dark:text-gray-400",children:[e.repoFullName," #",e.prNumber,c!=null&&c.status!=="preparing"&&t.jsxs(t.Fragment,{children:[" · merging ",t.jsx("span",{className:"font-mono",children:c.baseRef})," into ",t.jsx("span",{className:"font-mono",children:c.headRef})]})]})]}),K!==void 0&&t.jsxs("a",{href:K,target:"_blank",rel:"noreferrer noopener",className:"text-xs text-gray-500 underline underline-offset-2 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200",children:["Open on GitHub",t.jsx(_t,{size:11,className:"ml-0.5 inline-block align-[-0.1em]"})]}),t.jsx("button",{type:"button",onClick:()=>n({reason:W("user")}),className:"flex items-center text-gray-400 hover:text-gray-600 dark:hover:text-gray-200",title:"Close","aria-label":"Close",children:t.jsx(Zt,{size:16})})]}),B&&t.jsx(VZ,{prId:e.prId}),ee&&t.jsx("div",{className:"shrink-0 border-b border-gray-200 px-4 py-1.5 text-[12px] text-gray-700 dark:border-gray-800 dark:text-gray-200",children:lZ}),t.jsx("div",{className:"flex min-h-0 flex-1 flex-col",children:t.jsx(XZ,{openError:u,session:c,connectionLost:w,sessionKey:S,files:m,plan:P,loadingFiles:h,fileErrors:g,loadFile:x,onRetryFile:y,onRestart:b,view:k,onView:j,jumpTo:N,onJumpTo:I,headMoved:H,autoMergeArmed:O,commitError:((U=C.error)==null?void 0:U.message)??null,onCommit:Q=>C.mutate(Q),onResetCommit:()=>C.reset(),onClose:Q=>{Q&&(D.current=!0,A.current=!0),n({reason:Q?"committed":"user"})}})}),s&&t.jsx(HZ,{decided:(P==null?void 0:P.decidedTotal)??0,total:(P==null?void 0:P.decidableTotal)??0,onKeep:()=>a(!1),onClose:()=>n({reason:W("user")})}),t.jsxs("footer",{className:"flex shrink-0 flex-wrap items-baseline gap-x-3 border-t border-gray-200 px-4 py-1.5 text-[11px] text-gray-600 dark:border-gray-800 dark:text-gray-300",children:[t.jsx("span",{children:P!=null?NX(P.decidedTotal,P.decidableTotal):Oy}),t.jsx("span",{children:nZ})]})]})}function VZ({prId:e}){return DS(e,!0),null}function QZ(e,n){const s=He().getQueryCache(),a=f.useCallback(h=>s.subscribe(g=>{const x=g.query.queryKey;x[0]==="pr-refresh"&&x[1]===e&&h()}),[s,e]),i=f.useCallback(()=>{const h=s.find({queryKey:nd(e),exact:!0});return(Array.isArray(h==null?void 0:h.observers)?h.observers:[]).filter(x=>x.options.enabled!==!1).length},[s,e]),c=f.useSyncExternalStore(a,i,i),[d,u]=f.useState(!1),m=c-(d?1:0);return f.useEffect(()=>{d&&(!n||m>0)?u(!1):!d&&n&&m<=0&&u(!0)},[d,n,m]),d}function YZ(e,n){const[r,s]=f.useState(null);return f.useEffect(()=>{e==null||n==null||s(a=>a!=null&&a.pin===e?a:{pin:e,head:n})},[e,n]),e==null||n==null||r==null||r.pin!==e?!1:n!==e&&n!==r.head}function XZ({openError:e,session:n,connectionLost:r,sessionKey:s,files:a,plan:i,loadingFiles:c,fileErrors:d,loadFile:u,onRetryFile:m,onRestart:h,view:g,onView:x,jumpTo:y,onJumpTo:b,headMoved:w,autoMergeArmed:k,commitError:j,onCommit:N,onResetCommit:I,onClose:S}){var $,P;if(e!=null)return t.jsx(Si,{text:e,onRetry:h});if(n==null)return t.jsx(Si,{text:"Starting…"});if(n.status==="failed")return t.jsx(Si,{text:(($=n.error)==null?void 0:$.message)??"Couldn’t work out the conflicts in this pull request.",onRetry:h});if(n.status==="preparing")return r?t.jsx(Si,{text:ZX,onRetry:h}):t.jsx(Si,{text:n.phase!=null?zZ[n.phase]:"Starting…"});if(n.status==="clean")return t.jsx(Si,{text:`This pull request no longer conflicts with ${n.baseRef}.`});if(s==null||i==null)return t.jsx(Si,{text:Oy});const T=((P=n.commit)==null?void 0:P.status)==="done"?n.commit.result:null;return T!=null?t.jsx(UZ,{session:n,result:T,plan:i,onClose:()=>S(!0)}):g==="landing"?t.jsx(WZ,{session:n,sessionKey:s,files:a,plan:i,headMoved:w,autoMergeArmed:k,commitError:j,connectionLost:r,onBack:()=>{I(),x("panes")},onJumpToFile:C=>{I(),b(C),x("panes")},onCommit:N,onRestart:()=>{I(),h()},onClose:S}):t.jsx(EZ,{session:n,sessionKey:s,files:a,loadingFiles:c,fileErrors:d,loadFile:u,onRetryFile:m,plan:i,landBlockedReason:pI(i,w),jumpToFile:y,onJumpConsumed:()=>b(null),onLand:()=>x("landing")})}const ZZ=Object.freeze({});function Si({text:e,onRetry:n}){return t.jsxs("div",{className:"flex items-baseline gap-2 px-4 py-3 text-xs text-gray-600 dark:text-gray-300",children:[t.jsx("span",{children:e}),n!=null&&t.jsx("button",{type:"button",onClick:n,className:"rounded border border-gray-300 px-1.5 py-0.5 font-medium text-gray-700 hover:border-gray-400 dark:border-gray-700 dark:text-gray-200",children:wI})]})}const JZ=2e4;function eJ(){const e=Is(s=>s.lastClosed),n=Is(s=>s.dismissClosedResolver),r=Is(s=>s.openConflictResolver);return f.useEffect(()=>{if(e==null)return;const s=setTimeout(n,JZ);return()=>clearTimeout(s)},[e,n]),e==null?null:t.jsx("div",{className:"pointer-events-auto rounded-lg border border-gray-200 bg-white shadow-lg dark:border-gray-700 dark:bg-gray-900",children:t.jsxs("div",{className:"flex items-start gap-2 px-3 py-2",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"truncate text-[11px] text-gray-500 dark:text-gray-400",children:[e.target.repoFullName," #",e.target.prNumber]}),t.jsx("div",{className:"text-[12px] text-gray-800 dark:text-gray-100",children:oZ(e.decidedCount)}),t.jsx("button",{type:"button",onClick:()=>r(e.target),className:"mt-1 rounded border border-gray-300 px-2 py-0.5 text-xs text-gray-800 hover:border-gray-400 dark:border-gray-700 dark:text-gray-100 dark:hover:border-gray-600",children:iZ})]}),t.jsx("button",{type:"button",onClick:n,title:"Dismiss","aria-label":"Dismiss",className:"shrink-0 text-gray-400 hover:text-gray-600 dark:hover:text-gray-200",children:t.jsx(Zt,{size:13})})]})})}const tJ=1e4;function nJ(){const e=Ph(s=>s.last),n=Ph(s=>s.clear),r=n5();return f.useEffect(()=>{if(e==null)return;const s=setTimeout(n,tJ);return()=>clearTimeout(s)},[e,n]),e==null?null:t.jsx("div",{role:"status",className:"pointer-events-auto rounded-lg border border-gray-200 bg-white shadow-lg dark:border-gray-700 dark:bg-gray-900",children:t.jsxs("div",{className:"flex items-start gap-2 px-3 py-2",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"truncate text-[11px] text-gray-500 dark:text-gray-400",children:e.label}),t.jsx("div",{className:"text-[12px] text-gray-800 dark:text-gray-100",children:"Dismissed until something new happens on it."}),t.jsx("button",{type:"button",disabled:r.isPending,onClick:()=>r.mutate(e.target),className:"mt-1 rounded border border-gray-300 px-2 py-0.5 text-xs text-gray-800 hover:border-gray-400 disabled:opacity-50 dark:border-gray-700 dark:text-gray-100 dark:hover:border-gray-600",children:r.isPending?"Bringing it back…":"Undo"})]}),t.jsx("button",{type:"button",onClick:n,title:"Close","aria-label":"Close",className:"shrink-0 text-gray-400 hover:text-gray-600 dark:hover:text-gray-200",children:t.jsx(Zt,{size:13})})]})})}const rJ={expired:"Your sign-in link expired. Please sign in again.",failed:"We couldn’t complete sign-in with GitHub. Please try again.",error:"Something went wrong reaching GitHub. Please try again in a moment.",unavailable:"That sign-in method isn’t enabled on this deployment."},DN=()=>t.jsx("svg",{viewBox:"0 0 16 16",width:"18",height:"18",fill:"currentColor","aria-hidden":"true",children:t.jsx("path",{fillRule:"evenodd",d:"M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0 0 16 8c0-4.42-3.58-8-8-8Z"})});function sJ(){const[e]=f.useState(()=>{const a=new URLSearchParams(window.location.search).get("auth");return a?rJ[a]??"We couldn’t complete sign-in. Please try again.":null});f.useEffect(()=>{if(!e)return;const a=new URL(window.location.href);a.searchParams.delete("auth"),window.history.replaceState({},"",a.pathname+a.search+a.hash)},[e]);const[n,r]=f.useState({oauth:!0,app:!1,appSlug:""});f.useEffect(()=>{let a=!0;return fetch("/api/auth/providers",{credentials:"include"}).then(i=>i.ok?i.json():null).then(i=>{a&&i&&r(i)}).catch(()=>{}),()=>{a=!1}},[]);const s=n.oauth&&n.app;return t.jsx("div",{className:"flex h-full min-h-screen w-full items-center justify-center bg-gray-950 px-4 text-gray-100",children:t.jsxs("div",{className:"flex w-full max-w-sm flex-col items-center rounded-2xl border border-gray-800 bg-gray-900/40 px-8 py-10 text-center shadow-xl",children:[t.jsx(rp,{className:"text-4xl"}),t.jsx("p",{className:"mt-4 text-sm text-gray-400",children:"Sign in to view your GitHub activity across every repo you watch — pull requests, reviews, and what needs your attention."}),e&&t.jsx("div",{role:"alert",className:"mt-6 w-full rounded-lg border border-amber-500/40 bg-amber-500/10 px-3 py-2 text-xs text-amber-200",children:e}),t.jsxs("div",{className:"mt-7 flex w-full flex-col gap-3",children:[n.oauth&&t.jsxs("a",{href:"/api/auth/login/oauth",className:"inline-flex w-full items-center justify-center gap-2 rounded-lg bg-blue-600 px-4 py-2.5 text-sm font-semibold text-white transition-colors hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-sky-400 focus:ring-offset-2 focus:ring-offset-gray-950",children:[t.jsx(DN,{}),"Sign in with GitHub"]}),n.app&&t.jsxs("div",{className:"flex w-full flex-col gap-1",children:[t.jsxs("a",{href:"/api/auth/login/app",className:`inline-flex w-full items-center justify-center gap-2 rounded-lg px-4 py-2.5 text-sm font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-sky-400 focus:ring-offset-2 focus:ring-offset-gray-950 ${s?"border border-gray-700 bg-transparent text-gray-100 hover:bg-gray-800":"bg-blue-600 text-white hover:bg-blue-700"}`,children:[t.jsx(DN,{}),"Sign in with the Limn GitHub App"]}),t.jsx("span",{className:"px-1 text-[11px] leading-snug text-amber-500/80",children:"Scope may be limited: private org repos only appear once an org admin installs the app on your org — until then you’ll see public repos."})]})]}),s&&t.jsxs("p",{className:"mt-4 text-[11px] leading-relaxed text-gray-500 dark:text-gray-400",children:[t.jsx("span",{className:"text-gray-400",children:"GitHub"})," = public repositories, instant, no install. ",t.jsx("span",{className:"text-gray-400",children:"GitHub App"})," = also private repos, but only in orgs that have installed the app."]}),t.jsxs("p",{className:"mt-4 text-xs leading-relaxed text-gray-500 dark:text-gray-400",children:["Public repositories work either way, with no install. To watch"," ",t.jsx("strong",{className:"font-semibold text-gray-400",children:"private"})," org repos, sign in with the GitHub App and"," ",n.app&&n.appSlug?t.jsx("a",{className:"underline decoration-gray-600 underline-offset-2 hover:text-gray-300",href:`https://github.com/apps/${n.appSlug}/installations/new`,target:"_blank",rel:"noreferrer",children:"install it"}):"install it"," ","on that org (an org owner may need to approve). Revoke anytime from your GitHub settings."]}),t.jsxs("p",{className:"mt-4 text-[11px] leading-relaxed text-gray-500 dark:text-gray-400",children:["By signing in you agree to the"," ",t.jsx("a",{className:"underline decoration-gray-600 underline-offset-2 hover:text-gray-300",href:"/terms",target:"_blank",rel:"noreferrer noopener",children:"Terms of Service"})," ","and the"," ",t.jsx("a",{className:"underline decoration-gray-600 underline-offset-2 hover:text-gray-300",href:"/privacy",target:"_blank",rel:"noreferrer noopener",children:"Privacy Policy"}),"."]})]})})}function aJ({notices:e}){if(e.length===0)return null;const n=e.map(r=>r.org).join(", ");return t.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 border-b border-amber-400/50 bg-amber-400/10 px-4 py-2 text-xs text-amber-800 dark:text-amber-200",children:[t.jsxs("span",{className:"min-w-0",children:[t.jsxs("strong",{className:"font-semibold",children:["Your GitHub sign-in is no longer authorized for ",n,"."]})," ","Its pull requests, CI checks and comments can’t be synced until you re-authorize (SAML single sign-on)."]}),t.jsx("a",{href:"/api/auth/reconnect",className:"ml-auto whitespace-nowrap rounded border border-amber-500/60 px-2.5 py-0.5 font-medium hover:bg-amber-400/20",children:"Reconnect GitHub"}),t.jsx("span",{className:"w-full text-[11px] text-amber-700/80 dark:text-amber-300/70",children:"Reconnect signs you in again through SSO. If it doesn’t clear, your org may restrict third-party OAuth apps — an org owner has to approve Limn once."})]})}function oJ({user:e,canSignOut:n,onSignOut:r,onOpenSettings:s}){const[a,i]=f.useState(!1),c=f.useRef(null),d=e.displayName??e.login;Yr(c,()=>i(!1),a),f.useEffect(()=>{if(!a)return;const m=h=>{h.key==="Escape"&&(h.stopPropagation(),i(!1))};return document.addEventListener("keydown",m),()=>document.removeEventListener("keydown",m)},[a]);const u=e.avatarUrl!=null?t.jsx("img",{src:e.avatarUrl,alt:d,width:20,height:20,className:"shrink-0 rounded-full",style:{width:20,height:20}}):t.jsx("span",{className:"flex shrink-0 items-center justify-center rounded-full bg-gray-300 text-[9px] font-semibold text-gray-700 dark:bg-gray-700 dark:text-gray-200",style:{width:20,height:20},children:d.slice(0,2).toUpperCase()});return t.jsxs("div",{ref:c,className:"relative",children:[t.jsxs("button",{type:"button",onClick:()=>i(m=>!m),"aria-haspopup":"menu","aria-expanded":a,className:`flex items-center gap-1.5 rounded px-1.5 py-0.5 text-xs font-medium text-gray-600 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-800 ${a?"bg-gray-100 dark:bg-gray-800":""}`,title:e.displayName!=null?`Signed in as ${e.displayName} (@${e.login})`:`Signed in as ${e.login}`,children:[u,t.jsx("span",{className:"max-w-[10rem] truncate",children:d}),t.jsx(Cr,{dir:"down",className:"shrink-0 text-gray-400"})]}),a&&t.jsxs("div",{role:"menu","aria-label":"Account menu",className:"absolute right-0 top-full z-[60] mt-1 w-52 rounded-lg border border-gray-200 bg-white py-1 shadow-lg dark:border-gray-700 dark:bg-gray-900",children:[s!=null&&t.jsxs("button",{role:"menuitem",type:"button",onClick:()=>{i(!1),s()},className:"flex w-full items-center gap-2 px-3 py-1.5 text-left text-xs text-gray-700 hover:bg-gray-100 dark:text-gray-200 dark:hover:bg-gray-800",children:[t.jsxs("svg",{viewBox:"0 0 24 24",width:"13",height:"13",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[t.jsx("circle",{cx:"12",cy:"12",r:"3"}),t.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"})]}),"Settings"]}),t.jsxs("a",{role:"menuitem",href:Gl(e.login),target:"_blank",rel:"noreferrer noopener",onClick:()=>i(!1),className:"flex items-center gap-2 px-3 py-1.5 text-xs text-gray-700 hover:bg-gray-100 dark:text-gray-200 dark:hover:bg-gray-800",children:[t.jsx(_t,{size:13}),"Open Profile on GitHub"]}),n&&t.jsxs("button",{role:"menuitem",type:"button",onClick:()=>{i(!1),r()},className:"flex w-full items-center gap-2 px-3 py-1.5 text-left text-xs text-gray-700 hover:bg-gray-100 dark:text-gray-200 dark:hover:bg-gray-800",children:[t.jsxs("svg",{viewBox:"0 0 24 24",width:"13",height:"13",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[t.jsx("path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"}),t.jsx("polyline",{points:"16 17 21 12 16 7"}),t.jsx("line",{x1:"21",y1:"12",x2:"9",y2:"12"})]}),"Sign Out"]})]})]})}function BN(e){if(!(e instanceof HTMLElement))return!1;const n=e.tagName;return n==="INPUT"||n==="TEXTAREA"||e.isContentEditable}function iJ(){const{data:e}=pS();f.useEffect(()=>{const n=r=>{const{selectedPrId:s,selectPr:a,clearSelection:i}=G.getState(),c=Ge.getState(),d=c.activeTab==="timeline";if(r.key==="Escape"){BN(r.target)?r.target.blur():d?i():c.showTimeline();return}if(!BN(r.target)){if(r.key==="/"){r.preventDefault();const u=document.getElementById("add-repo-input")??document.getElementById("global-search-input");u==null||u.focus();return}if(r.key==="i"){c.showActivity();return}if(d&&(r.key==="j"||r.key==="k")){const u=[...(e==null?void 0:e.prs)??[]].sort((x,y)=>y.openedAt.localeCompare(x.openedAt));if(u.length===0)return;const m=u.findIndex(x=>x.id===s);let h;m===-1?h=0:h=r.key==="j"?m+1:m-1,h=Math.max(0,Math.min(u.length-1,h));const g=u[h];g&&a(g.id)}}};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[e])}function lJ(){const e=He();f.useEffect(()=>{let n=null;const r=()=>{n||(n=setTimeout(()=>{n=null,cJ(e)},300))};r();const s=e.getQueryCache().subscribe(a=>{const i=a.query.queryKey[0];(i==="timeline"||i==="open-prs")&&r()});return()=>{n&&clearTimeout(n),s()}},[e])}function cJ(e){const n=new Map,r=(a,i)=>{const c=n.get(a);(!c||i>c)&&n.set(a,i)},s=new Map;for(const a of["timeline","open-prs"])for(const i of e.getQueryCache().findAll({queryKey:[a]})){const c=i.state.data,d=i.state.dataUpdatedAt;for(const u of(c==null?void 0:c.prs)??[]){r(u.id,u.updatedAt);const m=s.get(u.id);(!m||d>m.at)&&s.set(u.id,{ciStatus:u.ciStatus,at:d})}}for(const[a,i]of n){const c=e.getQueryData(["pr",a]);if(!c)continue;const d=e.getQueryState(["pr",a]),u=c.updatedAt<i,m=s.get(a),h=m!=null&&dJ(m,c.ciStatus,(d==null?void 0:d.dataUpdatedAt)??0);if(!(!u&&!h)&&!(d&&d.fetchStatus!=="idle")&&(e.invalidateQueries({queryKey:["pr",a]}),!!u))for(const g of c.threads??[])e.invalidateQueries({queryKey:["thread",g.id]})}}function dJ(e,n,r){return e.at>r&&e.ciStatus!==n}function uJ(e){const{data:n}=U_(),{data:r}=xn(),{data:s}=xa(),a=f.useRef(null),i=f.useRef(null),c=f.useMemo(()=>{const u=new Map((s??[]).map(h=>[h.id,h.name])),m=new Map;for(const h of r??[]){const g=u.get(h.workspaceId);g!=null&&m.set(h.fullName,g)}return m},[r,s]),d=f.useRef(c);f.useEffect(()=>{d.current=c},[c]),f.useEffect(()=>{if(!n)return;const u=new Map,m=new Map,h=new Map;for(const U of n.awaitingReview)u.set(`r:${U.prId}`,U.since??U.openedAt),m.set(`r:${U.prId}`,U.repoFullName),h.set(`r:${U.prId}`,U.personal!==!1);for(const U of n.yourPrs)u.set(`p:${U.prId}`,U.since??U.openedAt),m.set(`p:${U.prId}`,U.repoFullName),h.set(`p:${U.prId}`,U.personal!==!1);for(const U of n.approvedPrs??[])u.set(`a:${U.prId}`,U.since??U.openedAt),m.set(`a:${U.prId}`,U.repoFullName),h.set(`a:${U.prId}`,U.personal!==!1);for(const U of n.threadsAwaiting)u.set(`t:${U.threadId}`,U.lastReplyAt),m.set(`t:${U.threadId}`,U.repoFullName),h.set(`t:${U.threadId}`,U.personal!==!1);for(const U of n.watchedRepoPrs)u.set(`w:${U.prId}`,U.since??U.openedAt),m.set(`w:${U.prId}`,U.repoFullName),h.set(`w:${U.prId}`,U.personal!==!1);const g=(U,Q,J,ne)=>{u.set(U,Q),m.set(U,J),h.set(U,ne!==!1)};for(const U of n.mentions??[])g(`mention:${U.prId}`,U.since??U.openedAt,U.repoFullName,U.personal);for(const U of n.threadReplies??[])g(`treply:${U.threadId}`,U.lastReplyAt,U.repoFullName,U.personal);for(const U of n.commentReplies??[])g(`creply:${U.prId}`,U.since??U.openedAt,U.repoFullName,U.personal);for(const U of n.pushedSince??[])g(`push:${U.prId}`,U.since??U.openedAt,U.repoFullName,U.personal);for(const U of n.ownCiRed??[])g(`ci:${U.prId}`,U.since??U.openedAt,U.repoFullName,U.personal);for(const U of n.ownConflicts??[])g(`conflict:${U.prId}`,U.since??U.openedAt,U.repoFullName,U.personal);for(const U of n.ownReady??[])g(`land:${U.prId}`,U.since??U.openedAt,U.repoFullName,U.personal);for(const U of n.ownThreads??[])g(`othread:${U.threadId}`,U.since,U.repoFullName,U.personal);for(const U of n.redTrunks??[])g(`trunk:${U.repoId}:${U.headSha??""}`,U.since,U.repoFullName,U.personal);const x=a.current;if(a.current=new Set(u.keys()),x==null){i.current=n.configKey??null;return}const y=n.configKey??null;if(y!==i.current){i.current=y;return}if(xE()||!e||typeof Notification>"u"||Notification.permission!=="granted")return;const b=[...u.keys()].filter(U=>!x.has(U)&&h.get(U)!==!1);if(b.length===0)return;const w=b.filter(U=>U.startsWith("r:")).length,k=b.filter(U=>U.startsWith("t:")).length,j=b.filter(U=>U.startsWith("p:")).length,N=b.filter(U=>U.startsWith("a:")).length,I=b.filter(U=>U.startsWith("w:")).length,S=U=>b.filter(Q=>Q.startsWith(U)).length,T=U=>U===1?"":"s",$=S("mention:"),P=S("treply:"),C=S("creply:"),L=S("push:"),F=S("ci:"),M=S("conflict:"),D=S("land:"),A=S("othread:"),W=S("trunk:"),z=[];w&&z.push(`${w} review${T(w)} requested`),$&&z.push(`${$} mention${T($)}`),k&&z.push(`${k} thread${T(k)} awaiting you`),P&&z.push(`${P} repl${P===1?"y":"ies"} to your comments`),C&&z.push(`${C} comment${T(C)} after yours`),L&&z.push(`${L} PR${T(L)} pushed since your review`),F&&z.push(`${F} of your builds failed`),M&&z.push(`${M} of your PRs ${M===1?"has":"have"} conflicts`),W&&z.push(`${W} default branch${W===1?"":"es"} red`),j&&z.push(`${j} of your PRs active`),N&&z.push(`${N} of your PRs approved`),D&&z.push(`${D} of your PRs ready to land`),A&&z.push(`${A} unanswered thread${T(A)} on your PRs`),I&&z.push(`${I} new PR${T(I)} in your repos`);let te=null,H=-1/0;for(const U of b){const Q=u.get(U);if(Q==null)continue;const J=Date.parse(Q);!Number.isNaN(J)&&J>H&&(H=J,te=Q)}const B=Cn(te??new Date().toISOString()),O=d.current,E=[];for(const U of b){const Q=m.get(U),J=Q==null?void 0:O.get(Q);J!=null&&!E.includes(J)&&E.push(J)}E.sort((U,Q)=>U.localeCompare(Q));const ee=E.length===1?E[0]:void 0,K=ee!=null?` in ${ee}`:E.length>1?` across ${E.length} Workspaces`:"";try{const U=new Notification(`Limn — ${b.length} new in My Turn${K}`,{body:`${B}
73
+ ${z.join(" · ")}${E.length>1?` — ${E.join(", ")}`:""}`,tag:"pierre-my-turn"});U.onclick=()=>{window.focus(),U.close()}}catch{}},[n,e])}function hJ({enabled:e}){const[n,r]=f.useState(!1);f.useEffect(()=>{if(!(!e||!iI()))return r(Ly()===null),oY(i=>r(i===null))},[e]);const s=f.useCallback(()=>{pN("granted"),lI(),r(!1)},[]),a=f.useCallback(()=>{pN("denied"),cI(),r(!1)},[]);return n?t.jsx("div",{role:"dialog","aria-modal":"false","aria-label":"Cookie choices",className:"fixed inset-x-0 bottom-0 z-[60] border-t border-gray-200 bg-white/95 backdrop-blur dark:border-gray-800 dark:bg-gray-950/95",children:t.jsxs("div",{className:"mx-auto flex max-w-4xl flex-col gap-3 px-4 py-3 sm:flex-row sm:items-center sm:justify-between",children:[t.jsxs("p",{className:"text-sm leading-relaxed text-gray-700 dark:text-gray-300",children:["We'd like to use Google Analytics to count page views. It sets a cookie and shares your IP address with Google. Nothing loads unless you say yes, and Limn works exactly the same either way."," ",t.jsx("a",{href:"/privacy",target:"_blank",rel:"noreferrer noopener",className:"text-blue-600 underline hover:text-blue-500 dark:text-blue-400",children:"Privacy policy"})]}),t.jsxs("div",{className:"flex shrink-0 gap-2",children:[t.jsx("button",{type:"button",onClick:a,className:"flex-1 rounded-md border border-gray-300 bg-white px-3.5 py-1.5 text-sm font-semibold text-gray-700 transition hover:bg-gray-50 dark:border-gray-700 dark:bg-gray-900 dark:text-gray-200 dark:hover:bg-gray-800 sm:flex-none",children:"Decline"}),t.jsx("button",{type:"button",onClick:s,className:"flex-1 rounded-md border border-gray-300 bg-gray-100 px-3.5 py-1.5 text-sm font-semibold text-gray-900 transition hover:bg-gray-200 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-100 dark:hover:bg-gray-700 sm:flex-none",children:"Accept"})]})]})}):null}function pJ(){const[e,n]=f.useState(()=>(localStorage.getItem("theme")??"dark")!=="light");return f.useEffect(()=>{document.documentElement.classList.toggle("dark",e),localStorage.setItem("theme",e?"dark":"light")},[e]),[e,()=>n(r=>!r)]}function mJ(){var Fe,oe,re;const e=In();TO(),iJ(),lJ();const[n,r]=pJ(),[s,a]=f.useState(!1),i=Xc(X=>X.open),c=Xc(X=>X.focus),d=Xc(X=>X.openSettings),u=Xc(X=>X.closeSettings),[m,h]=QR(),g=typeof window<"u"&&"Notification"in window;uJ(m&&g);const x=()=>{if(g){if(m){h(!1);return}Notification.permission==="granted"?h(!0):Notification.permission!=="denied"&&Notification.requestPermission().then(X=>h(X==="granted"))}},y=((Fe=e.data)==null?void 0:Fe.deploymentMode)==="cloud",b=((oe=e.data)==null?void 0:oe.user)??null,w=()=>{Ge.getState().clear(),he.logout().finally(()=>window.location.assign("/"))},k=G(X=>X.selectedPrId),j=G(X=>X.selectedThreadId),N=Ge(X=>X.activeTab),I=Ge(X=>X.tabs),S=Nh(N)?null:I.find(X=>X.key===N)??null,T=N==="activity",$=(S==null?void 0:S.kind)==="pr-detail"?S.prId:null,P=(S==null?void 0:S.kind)==="metrics-detail",C=(S==null?void 0:S.kind)==="bot-prs",L=N==="open-prs",F=(S==null?void 0:S.kind)==="bot-only-prs",M=(S==null?void 0:S.kind)==="bot-threads",D=(S==null?void 0:S.kind)==="bot-flagging",A=(S==null?void 0:S.kind)==="bot-volume",W=(S==null?void 0:S.kind)==="theme-threads",z=(S==null?void 0:S.kind)==="search",te=(S==null?void 0:S.kind)==="user-activity",H=(S==null?void 0:S.kind)==="bot-detail",B=(S==null?void 0:S.kind)==="people-report",O=iS(N,I),E=$!=null||T||P||C||L||F||M||D||A||W||z||te||H||B,ee=k!=null&&!E,[K,U]=uy("pierre:detailPaneHeight",384),Q=f.useRef(null),J=f.useRef(null),ne=f.useRef(null);f.useEffect(()=>{for(const X of[J.current,Q.current])X&&(E?X.setAttribute("inert",""):X.removeAttribute("inert"))},[E]),f.useEffect(()=>{window.dispatchEvent(new Event("resize"))},[ee]);const ae=X=>{var le;ne.current={startY:X.clientY,startH:((le=Q.current)==null?void 0:le.offsetHeight)??K},X.currentTarget.setPointerCapture(X.pointerId)},we=X=>{const le=ne.current;if(!le||!Q.current)return;const Ne=window.innerHeight*.7,Ve=Math.min(Math.max(le.startH+(le.startY-X.clientY),160),Ne);Q.current.style.height=`${Ve}px`,window.dispatchEvent(new Event("resize"))},$e=X=>{!ne.current||!Q.current||(ne.current=null,X.currentTarget.releasePointerCapture(X.pointerId),U(Q.current.offsetHeight))};return f.useEffect(()=>{if(!y)return;const X=()=>{he.me().catch(()=>{})},le=window.setInterval(X,180*1e3);return()=>window.clearInterval(le)},[y]),f.useEffect(()=>{y&&(lI(),iY())},[y]),e.error instanceof cn&&e.error.status===401?t.jsx(sJ,{}):e.isLoading&&!e.data?t.jsx("div",{className:"flex h-full min-h-screen items-center justify-center bg-gray-950",children:t.jsx(rp,{className:"text-4xl text-gray-100"})}):t.jsxs("div",{className:"flex h-full flex-col",children:[t.jsx(aJ,{notices:((re=e.data)==null?void 0:re.authNotices)??[]}),t.jsxs("header",{className:"flex items-center gap-3 border-b border-gray-200 px-4 py-2 dark:border-gray-800",children:[t.jsx("h1",{title:"Limn — to depict, to make clear",children:t.jsx(rp,{})}),t.jsxs("div",{className:"ml-auto flex items-center gap-3",children:[t.jsx(tQ,{}),g&&t.jsx("button",{type:"button",onClick:x,"aria-pressed":m,className:`rounded border px-2 py-0.5 text-xs hover:border-gray-400 dark:hover:border-gray-500 ${m?"border-blue-400 text-blue-600 dark:border-blue-600 dark:text-blue-400":"border-gray-300 dark:border-gray-700"}`,title:m?"Notifications on — alerts when a new item enters your My Turn. Click to turn off.":"Turn on browser notifications for new My Turn items","aria-label":"Toggle My Turn notifications",children:t.jsxs("svg",{viewBox:"0 0 24 24",width:"14",height:"14",fill:m?"currentColor":"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[t.jsx("path",{d:"M18 8a6 6 0 0 0-12 0c0 7-3 9-3 9h18s-3-2-3-9"}),t.jsx("path",{d:"M13.73 21a2 2 0 0 1-3.46 0"})]})}),t.jsx("button",{type:"button",onClick:()=>a(!0),className:"rounded border border-gray-300 px-2 py-0.5 text-xs font-semibold hover:border-gray-400 dark:border-gray-700 dark:hover:border-gray-500",title:"Help — what is Limn and how to use it","aria-label":"Help",children:"?"}),t.jsx("button",{type:"button",onClick:r,className:"rounded border border-gray-300 px-2 py-0.5 text-xs hover:border-gray-400 dark:border-gray-700 dark:hover:border-gray-500",title:"Toggle dark mode",children:n?t.jsx(K4,{className:"inline-block align-[-0.15em]"}):t.jsx(G4,{className:"inline-block align-[-0.15em]"})}),b!=null&&t.jsx(oJ,{user:b,canSignOut:y,onSignOut:w,onOpenSettings:()=>d()})]})]}),s&&t.jsx(aQ,{onClose:()=>a(!1)}),i&&t.jsx(dY,{focus:c,onClose:u}),t.jsx(KZ,{}),t.jsx(nQ,{}),t.jsx(YO,{}),t.jsx(bD,{}),t.jsxs("main",{className:"relative flex min-h-0 flex-1 flex-col",children:[t.jsx("section",{ref:J,className:"min-h-0 flex-1 overflow-hidden",children:O==null?t.jsx(_1,{},"board"):t.jsx(_1,{mode:O},`focus:${O.prId}`)}),ee&&t.jsxs(t.Fragment,{children:[t.jsx("div",{role:"separator","aria-orientation":"horizontal","aria-label":"Resize detail pane",onPointerDown:ae,onPointerMove:we,onPointerUp:$e,title:"Drag to resize",className:"h-1 shrink-0 cursor-row-resize bg-gray-200 transition-colors hover:bg-blue-400 dark:bg-gray-800 dark:hover:bg-blue-500"}),t.jsx("section",{ref:Q,style:{height:K},className:"shrink-0 overflow-auto",children:t.jsx(BV,{})})]}),$!=null&&t.jsx("div",{"data-testid":"pinned-pr-overlay",className:"absolute inset-0 z-20 bg-white dark:bg-gray-950",children:t.jsx(RC,{prId:$,selectedThreadId:k===$?j:null,placement:"fullscreen"},$)}),T&&t.jsx("div",{"data-testid":"activity-overlay",className:"absolute inset-0 z-20 overflow-clip bg-white dark:bg-gray-950",children:t.jsx(wz,{})}),P&&t.jsx("div",{"data-testid":"metrics-overlay",className:"absolute inset-0 z-20 overflow-auto bg-white dark:bg-gray-950",children:t.jsx(Fz,{})}),C&&t.jsx("div",{"data-testid":"bot-prs-overlay",className:"absolute inset-0 z-20 overflow-auto bg-white dark:bg-gray-950",children:t.jsx(aK,{})}),L&&t.jsx("div",{"data-testid":"open-prs-overlay",className:"absolute inset-0 z-20 overflow-auto bg-white dark:bg-gray-950",children:t.jsx(yG,{})}),F&&t.jsx("div",{"data-testid":"bot-only-prs-overlay",className:"absolute inset-0 z-20 overflow-auto bg-white dark:bg-gray-950",children:t.jsx(wG,{})}),M&&t.jsx("div",{"data-testid":"bot-threads-overlay",className:"absolute inset-0 z-20 overflow-auto bg-white dark:bg-gray-950",children:t.jsx(_G,{})}),D&&t.jsx("div",{"data-testid":"bot-flagging-overlay",className:"absolute inset-0 z-20 overflow-auto bg-white dark:bg-gray-950",children:t.jsx(XG,{})}),A&&t.jsx("div",{"data-testid":"bot-volume-overlay",className:"absolute inset-0 z-20 overflow-auto bg-white dark:bg-gray-950",children:t.jsx(nV,{})}),W&&t.jsx("div",{"data-testid":"theme-threads-overlay",className:"absolute inset-0 z-20 overflow-auto bg-white dark:bg-gray-950",children:t.jsx(P7,{})}),B&&t.jsx("div",{"data-testid":"people-report-overlay",className:"absolute inset-0 z-20 overflow-auto bg-white dark:bg-gray-950",children:t.jsx(AV,{})}),te&&t.jsx("div",{"data-testid":"user-activity-overlay",className:"absolute inset-0 z-20 overflow-auto bg-white dark:bg-gray-950",children:t.jsx(iV,{})},N),H&&t.jsx("div",{"data-testid":"bot-detail-overlay",className:"absolute inset-0 z-20 overflow-auto bg-white dark:bg-gray-950",children:t.jsx(gV,{})},N),z&&t.jsx("div",{"data-testid":"search-overlay",className:"absolute inset-0 z-20 overflow-auto bg-white dark:bg-gray-950",children:t.jsx(LV,{})})]}),t.jsxs("div",{className:"pointer-events-none fixed bottom-4 right-4 z-50 flex w-80 max-w-[calc(100vw-2rem)] flex-col gap-2",children:[t.jsx(UV,{}),t.jsx(VV,{}),t.jsx(eJ,{}),t.jsx(nJ,{}),t.jsx(oL,{}),t.jsx(t7,{})]}),t.jsx(hJ,{enabled:y})]})}function am(e){return new Promise((n,r)=>{e.oncomplete=e.onsuccess=()=>n(e.result),e.onabort=e.onerror=()=>r(e.error)})}function gJ(e,n){let r;const s=()=>{if(r)return r;const a=indexedDB.open(e);return a.onupgradeneeded=()=>a.result.createObjectStore(n),r=am(a),r.then(i=>{i.onclose=()=>r=void 0},()=>{}),r};return(a,i)=>s().then(c=>i(c.transaction(n,a).objectStore(n)))}let V0;function Dy(){return V0||(V0=gJ("keyval-store","keyval")),V0}function fJ(e,n=Dy()){return n("readonly",r=>am(r.get(e)))}function xJ(e,n,r=Dy()){return r("readwrite",s=>(s.put(n,e),am(s.transaction)))}function yJ(e,n=Dy()){return n("readwrite",r=>(r.delete(e),am(r.transaction)))}const bJ=t$({storage:{getItem:e=>fJ(e).then(n=>n??null),setItem:(e,n)=>xJ(e,n),removeItem:e=>yJ(e)},key:"pierre-query-cache",throttleTime:1e3}),vJ=new n$({defaultOptions:{queries:{staleTime:3e4,refetchOnWindowFocus:!1,retry:1}}});var Ju,WN;(WN=(Ju=navigator.storage)==null?void 0:Ju.persist)==null||WN.call(Ju);new URLSearchParams(window.location.search).has("perf")&&up(()=>import("./perfProbe-Da13EhTE.js"),[]).then(e=>e.startPerfProbe());const jI=document.getElementById("root");if(!jI)throw new Error("#root not found");const kJ=1e3*60*60*24*7;f$.createRoot(jI).render(t.jsx(f.StrictMode,{children:t.jsx(r$,{client:vJ,persistOptions:{persister:bJ,maxAge:kJ,buster:"pierre-detail-v4",dehydrateOptions:{shouldDehydrateQuery:e=>{const n=e.queryKey[0];return(n==="pr"||n==="thread"||n==="pr-files")&&e.state.status==="success"}}},children:t.jsx(mJ,{})})}));export{he as $,PJ as A,Lt as B,IJ as C,$J as D,$R as E,Mj as F,us as G,FC as H,xy as I,J4 as J,XJ as K,AJ as L,gr as M,iK as N,e4 as O,HV as P,KJ as Q,ree as R,Aj as S,MJ as T,J$ as U,oK as V,Jt as W,xee as X,F5 as Y,see as Z,QJ as _,_J as a,See as a$,yK as a0,vee as a1,ds as a2,bK as a3,iee as a4,uee as a5,Cn as a6,dee as a7,wK as a8,gK as a9,mn as aA,zJ as aB,hee as aC,Oj as aD,mee as aE,ZJ as aF,LJ as aG,eee as aH,tee as aI,OJ as aJ,lee as aK,uK as aL,gee as aM,sG as aN,Dr as aO,DJ as aP,RM as aQ,co as aR,WJ as aS,Cee as aT,kee as aU,wee as aV,UK as aW,jee as aX,G as aY,Nee as aZ,Gx as a_,zV as aa,wn as ab,VJ as ac,FJ as ad,J0 as ae,p_ as af,_M as ag,Vx as ah,Cy as ai,oee as aj,mx as ak,yee as al,xK as am,vK as an,Yl as ao,YJ as ap,UJ as aq,GJ as ar,JJ as as,pee as at,kK as au,Nt as av,fee as aw,nee as ax,cee as ay,$K as az,aee as b,Tee as b0,pC as b1,qJ as b2,xn as b3,BJ as b4,Iee as b5,Ree as b6,xa as b7,pn as b8,R3 as b9,d2 as c,bee as d,RD as e,HJ as f,O5 as g,cn as h,_s as i,TJ as j,pk as k,CJ as l,RJ as m,pr as n,i6 as o,Mt as p,l6 as q,Qo as r,Bi as s,dk as t,T6 as u,_t as v,EJ as w,M6 as x,Ad as y,fS as z};