copilot-operator 0.1.38 → 0.1.40

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 (55) hide show
  1. package/dist/src/api/operator.controller.js +128 -2
  2. package/dist/src/api/operator.service.js +473 -39
  3. package/dist/src/api/server.js +7 -0
  4. package/dist/src/log/terminal.js +145 -0
  5. package/dist/src/orchestrator/contract.js +77 -6
  6. package/dist/src/plan/brief.js +1375 -1369
  7. package/dist/src/plan/schema.js +5 -0
  8. package/dist/src/plan/systemGuide.js +218 -20
  9. package/dist/src/session/exports.js +1 -0
  10. package/dist/src/session/startFailure.js +91 -0
  11. package/dist/src/vcs/prepareFromRemote.js +7 -20
  12. package/dist/src/vcs/remoteAuth.js +26 -1
  13. package/dist/src/vcs/runPreflight.js +31 -14
  14. package/dist/src/vcs/snapshot.js +3 -1
  15. package/dist/src/vcs/startChoice.js +295 -0
  16. package/dist/src/vcs/taskVcs.js +61 -5
  17. package/dist/web/404.html +2 -2
  18. package/dist/web/_next/static/chunks/499-28e118e33ce07935.js +1 -0
  19. package/dist/web/_next/static/chunks/{549-7e35e4fdefadb05d.js → 549-f295c8429e83b25b.js} +1 -1
  20. package/dist/web/_next/static/chunks/584-578be94a0786334b.js +1 -0
  21. package/dist/web/_next/static/chunks/867-8dc5bbb092ca2c5c.js +1 -0
  22. package/dist/web/_next/static/chunks/app/history/page-9f69ccde726c9be2.js +1 -0
  23. package/dist/web/_next/static/chunks/app/layout-73f28bc065a46ed3.js +1 -0
  24. package/dist/web/_next/static/chunks/app/page-e557d58476ae6383.js +1 -0
  25. package/dist/web/_next/static/chunks/app/sessions/view/page-0485ee7f781156ec.js +1 -0
  26. package/dist/web/_next/static/chunks/app/system/{page-5ae1f8054208e6eb.js → page-227a259e383ca2a0.js} +1 -1
  27. package/dist/web/_next/static/css/cea7913ba416dbb7.css +1 -0
  28. package/dist/web/appearance.html +2 -2
  29. package/dist/web/appearance.txt +28 -26
  30. package/dist/web/defaults.html +2 -2
  31. package/dist/web/defaults.txt +28 -26
  32. package/dist/web/history.html +2 -2
  33. package/dist/web/history.txt +28 -26
  34. package/dist/web/import.html +2 -2
  35. package/dist/web/import.txt +28 -26
  36. package/dist/web/index.html +2 -2
  37. package/dist/web/index.txt +28 -26
  38. package/dist/web/level1.html +2 -2
  39. package/dist/web/level1.txt +28 -26
  40. package/dist/web/presets.html +2 -2
  41. package/dist/web/presets.txt +28 -26
  42. package/dist/web/sessions/view.html +2 -2
  43. package/dist/web/sessions/view.txt +28 -26
  44. package/dist/web/system.html +2 -2
  45. package/dist/web/system.txt +28 -26
  46. package/package.json +158 -156
  47. package/dist/web/_next/static/chunks/36-94660f1cde2da529.js +0 -1
  48. package/dist/web/_next/static/chunks/867-d4f5bd8c5805bffb.js +0 -1
  49. package/dist/web/_next/static/chunks/app/history/page-a0bd59986f7c8beb.js +0 -1
  50. package/dist/web/_next/static/chunks/app/layout-630b663626cebe4a.js +0 -1
  51. package/dist/web/_next/static/chunks/app/page-4defcfd1eb482644.js +0 -1
  52. package/dist/web/_next/static/chunks/app/sessions/view/page-ce99494b1997ee25.js +0 -1
  53. package/dist/web/_next/static/css/c37978b44194c37b.css +0 -1
  54. /package/dist/web/_next/static/{8C2D7RnTerPO3g_WyLEC3 → Y9tuV5LV-O0XyCREkeGc5}/_buildManifest.js +0 -0
  55. /package/dist/web/_next/static/{8C2D7RnTerPO3g_WyLEC3 → Y9tuV5LV-O0XyCREkeGc5}/_ssgManifest.js +0 -0
package/package.json CHANGED
@@ -1,156 +1,158 @@
1
- {
2
- "name": "copilot-operator",
3
- "version": "0.1.38",
4
- "private": false,
5
- "type": "module",
6
- "description": "Automates a Microsoft 365 Copilot chat: sends prompts, extracts commands, runs them, reports back.",
7
- "license": "MIT",
8
- "engines": {
9
- "node": ">=20"
10
- },
11
- "scripts": {
12
- "build": "tsc -p tsconfig.json",
13
- "build:package": "node scripts/build-package.mjs",
14
- "prepack": "node scripts/build-package.mjs",
15
- "check:pacing": "tsx test/pacing.check.ts",
16
- "check:runner": "tsx test/runner.check.ts",
17
- "check:chat": "tsx test/chat.check.ts",
18
- "cop": "tsx src/cli.ts",
19
- "check:parser": "tsx test/parser.check.ts",
20
- "check:report": "tsx test/report.check.ts",
21
- "check": "npm run check:parser && npm run check:damage && npm run check:session && npm run check:report && npm run check:runner && npm run check:vcs && npm run check:plan && npm run check:checks && npm run check:workdir && npm run check:processes && npm run check:environment && npm run check:clock && npm run check:crash && npm run check:clipboard && npm run check:restart && npm run check:review && npm run check:chat && npm run check:pacing && npm run check:shells && npm run check:save && npm run check:guide && npm run check:bundle && npm run check:runname && npm run check:dangerous && npm run check:programs && npm run check:manifest && npm run check:lock && npm run check:isolation && npm run check:security && npm run check:update && npm run check:persona && npm run check:script && npm run check:batch && npm run check:confinement && npm run check:network && npm run check:hardening && npm run check:package && npm run check:models && npm run check:continue && npm run check:startfrom && npm run check:diff && npm run check:integrity && npm run check:scope && npm run check:progress && npm run check:metrics && npm run check:modelpicker && npm run check:formatrepair && npm run check:intent && npm run check:sync && npm run check:e2e-run && npm run check:e2e-continue && npm run check:e2e-interrupt && npm run check:e2e-vcs && npm run check:noattach && npm run check:guard && npm run check:gate && npm run check:e2e-batch && npm run check:e2e-review && npm run check:e2e-branches && npm run check:e2e-loop && npm run check:transport && npm run check:e2e-plan && npm run check:exec && npm run check:pins && npm run check:login && npm run check:order && npm run check:snapshot && npm run check:inputs && npm run check:e2e-inputs && npm run check:attempts && npm run check:finding-ids && npm run check:e2e-commit && npm run check:e2e-retry-inputs && npm run check:e2e-run-vcs && npm run check:prepare && npm run check:live-fixes",
22
- "probe": "tsx scripts/probe-locators.ts",
23
- "check:damage": "tsx test/damage.check.ts",
24
- "api": "npm run build && node dist/src/api/main.js",
25
- "api:start": "node dist/src/api/main.js",
26
- "web": "npm run dev --workspace web",
27
- "web:build": "npm run build --workspace web",
28
- "check:session": "tsx test/session.check.ts",
29
- "start": "node scripts/dev.mjs",
30
- "dev": "node scripts/dev.mjs --open",
31
- "check:vcs": "tsx test/vcs.check.ts",
32
- "check:plan": "tsx test/plan.check.ts",
33
- "check:checks": "tsx test/checks.check.ts",
34
- "check:workdir": "tsx test/workdir.check.ts",
35
- "check:processes": "tsx test/processes.check.ts",
36
- "check:environment": "tsx test/environment.check.ts",
37
- "check:clock": "tsx test/clock.check.ts",
38
- "check:crash": "tsx test/crash.check.ts",
39
- "check:clipboard": "tsx test/clipboard.check.ts",
40
- "check:restart": "tsx test/restart.check.ts",
41
- "check:review": "tsx test/review.check.ts",
42
- "check:review-evidence": "tsx test/review-evidence.check.ts",
43
- "check:settings-precedence": "tsx test/settings-precedence.check.ts",
44
- "check:model-help": "tsx test/model-help.check.ts",
45
- "check:shells": "tsx test/shells.check.ts",
46
- "check:save": "tsx test/save.check.ts",
47
- "check:guide": "tsx test/guide.check.ts",
48
- "typecheck": "tsc -p tsconfig.json --noEmit && tsc -p tsconfig.test.json && npm run typecheck --workspace web",
49
- "check:bundle": "tsx test/bundle.check.ts",
50
- "check:runname": "tsx test/runname.check.ts",
51
- "update": "node scripts/update.mjs",
52
- "check:dangerous": "tsx test/dangerous.check.ts",
53
- "check:programs": "tsx test/programs.check.ts",
54
- "check:manifest": "tsx test/manifest.check.ts",
55
- "check:lock": "tsx test/lock.check.ts",
56
- "check:isolation": "tsx test/isolation.check.ts",
57
- "check:security": "tsx test/security.check.ts",
58
- "check:update": "tsx test/update.check.ts",
59
- "check:persona": "tsx test/persona.check.ts",
60
- "check:script": "tsx test/script.check.ts",
61
- "check:batch": "tsx test/batch.check.ts",
62
- "check:confinement": "tsx test/confinement.check.ts",
63
- "check:network": "tsx test/network.check.ts",
64
- "check:hardening": "tsx test/hardening.check.ts",
65
- "check:package": "tsx test/package.check.ts",
66
- "check:models": "tsx test/models.check.ts",
67
- "check:continue": "tsx test/continue.check.ts",
68
- "check:startfrom": "tsx test/startfrom.check.ts",
69
- "check:diff": "tsx test/diff.check.ts",
70
- "check:integrity": "tsx test/integrity.check.ts",
71
- "check:scope": "tsx test/scope.check.ts",
72
- "check:progress": "tsx test/progress.check.ts",
73
- "check:metrics": "tsx test/metrics.check.ts",
74
- "check:modelpicker": "tsx test/modelpicker.check.ts",
75
- "check:formatrepair": "tsx test/formatrepair.check.ts",
76
- "check:intent": "tsx test/intent.check.ts",
77
- "check:sync": "tsx test/sync.check.ts",
78
- "check:prepare": "tsx test/prepare.check.ts",
79
- "check:live-fixes": "tsx test/live-fixes.check.ts",
80
- "check:live-models": "tsx test/live-models.check.ts",
81
- "check:live-chat": "tsx test/live-chatname.check.ts",
82
- "check:e2e-run": "tsx test/e2e-run.check.ts",
83
- "check:e2e-continue": "tsx test/e2e-continue.check.ts",
84
- "check:e2e-interrupt": "tsx test/e2e-interrupt.check.ts",
85
- "check:ui": "node scripts/build-package.mjs && tsx test/ui.check.ts && tsx test/ui-flows.check.ts",
86
- "check:all": "npm run check && npm run check:ui && npm run check:release",
87
- "check:e2e-vcs": "tsx test/e2e-vcs.check.ts",
88
- "check:noattach": "tsx test/noattach.check.ts",
89
- "check:guard": "tsx test/guard.check.ts",
90
- "check:gate": "tsx test/gate.check.ts",
91
- "check:e2e-batch": "tsx test/e2e-batch.check.ts",
92
- "check:e2e-review": "tsx test/e2e-review.check.ts",
93
- "check:e2e-branches": "tsx test/e2e-branches.check.ts",
94
- "check:e2e-loop": "tsx test/e2e-loop.check.ts",
95
- "check:transport": "tsx test/transport.check.ts",
96
- "check:e2e-plan": "tsx test/e2e-plan.check.ts",
97
- "check:exec": "tsx test/exec.check.ts",
98
- "check:pins": "tsx test/pins.check.ts",
99
- "check:release": "tsx test/release.check.ts",
100
- "check:ui-flows": "tsx test/ui-flows.check.ts",
101
- "check:login": "tsx test/login.check.ts",
102
- "check:order": "tsx test/order.check.ts",
103
- "check:snapshot": "tsx test/snapshot.check.ts",
104
- "check:inputs": "tsx test/inputs.check.ts",
105
- "check:e2e-inputs": "tsx test/e2e-inputs.check.ts",
106
- "check:attempts": "tsx test/attempts.check.ts",
107
- "check:finding-ids": "tsx test/finding-ids.check.ts",
108
- "check:e2e-commit": "tsx test/e2e-commit.check.ts",
109
- "check:e2e-retry-inputs": "tsx test/e2e-retry-inputs.check.ts",
110
- "check:e2e-run-vcs": "tsx test/e2e-run-vcs.check.ts"
111
- },
112
- "dependencies": {
113
- "@nestjs/common": "^12.0.3",
114
- "@nestjs/core": "^12.0.3",
115
- "@nestjs/platform-express": "^12.0.3",
116
- "commander": "^15.0.0",
117
- "playwright": "^1.63.0",
118
- "reflect-metadata": "^0.2.2",
119
- "rxjs": "^7.8.2",
120
- "yaml": "^2.9.1",
121
- "zod": "^4.6.5"
122
- },
123
- "devDependencies": {
124
- "@types/express": "^5.0.6",
125
- "@types/node": "^22.10.2",
126
- "tsx": "^4.19.2",
127
- "typescript": "5.9"
128
- },
129
- "repository": {
130
- "type": "git",
131
- "url": "git+https://github.com/ivan-markov-666/copilot-operator.git"
132
- },
133
- "bin": {
134
- "cop": "dist/src/cli.js"
135
- },
136
- "files": [
137
- "dist/src",
138
- "dist/web",
139
- "prompts",
140
- "README.md",
141
- "LICENSE"
142
- ],
143
- "os": [
144
- "win32"
145
- ],
146
- "keywords": [
147
- "copilot",
148
- "microsoft-365",
149
- "automation",
150
- "playwright",
151
- "agent"
152
- ],
153
- "workspaces": [
154
- "web"
155
- ]
156
- }
1
+ {
2
+ "name": "copilot-operator",
3
+ "version": "0.1.40",
4
+ "private": false,
5
+ "type": "module",
6
+ "description": "Automates a Microsoft 365 Copilot chat: sends prompts, extracts commands, runs them, reports back.",
7
+ "license": "MIT",
8
+ "engines": {
9
+ "node": ">=20"
10
+ },
11
+ "scripts": {
12
+ "build": "tsc -p tsconfig.json",
13
+ "build:package": "node scripts/build-package.mjs",
14
+ "prepack": "node scripts/build-package.mjs",
15
+ "check:pacing": "tsx test/pacing.check.ts",
16
+ "check:runner": "tsx test/runner.check.ts",
17
+ "check:chat": "tsx test/chat.check.ts",
18
+ "cop": "tsx src/cli.ts",
19
+ "check:parser": "tsx test/parser.check.ts",
20
+ "check:report": "tsx test/report.check.ts",
21
+ "check": "npm run check:suite && npm run check:parser && npm run check:damage && npm run check:session && npm run check:report && npm run check:runner && npm run check:vcs && npm run check:plan && npm run check:checks && npm run check:workdir && npm run check:processes && npm run check:environment && npm run check:clock && npm run check:crash && npm run check:clipboard && npm run check:restart && npm run check:review && npm run check:chat && npm run check:pacing && npm run check:shells && npm run check:save && npm run check:guide && npm run check:bundle && npm run check:runname && npm run check:dangerous && npm run check:programs && npm run check:manifest && npm run check:lock && npm run check:isolation && npm run check:security && npm run check:update && npm run check:persona && npm run check:script && npm run check:batch && npm run check:confinement && npm run check:network && npm run check:hardening && npm run check:package && npm run check:models && npm run check:settings-precedence && npm run check:review-evidence && npm run check:model-help && npm run check:continue && npm run check:startfrom && npm run check:startbranch && npm run check:diff && npm run check:integrity && npm run check:scope && npm run check:progress && npm run check:metrics && npm run check:modelpicker && npm run check:formatrepair && npm run check:intent && npm run check:sync && npm run check:e2e-run && npm run check:e2e-continue && npm run check:e2e-interrupt && npm run check:e2e-vcs && npm run check:noattach && npm run check:guard && npm run check:gate && npm run check:e2e-batch && npm run check:e2e-review && npm run check:e2e-branches && npm run check:e2e-loop && npm run check:transport && npm run check:e2e-plan && npm run check:exec && npm run check:pins && npm run check:login && npm run check:order && npm run check:snapshot && npm run check:inputs && npm run check:e2e-inputs && npm run check:attempts && npm run check:finding-ids && npm run check:e2e-commit && npm run check:e2e-retry-inputs && npm run check:e2e-run-vcs && npm run check:prepare && npm run check:live-fixes",
22
+ "probe": "tsx scripts/probe-locators.ts",
23
+ "check:damage": "tsx test/damage.check.ts",
24
+ "api": "npm run build && node dist/src/api/main.js",
25
+ "api:start": "node dist/src/api/main.js",
26
+ "web": "npm run dev --workspace web",
27
+ "web:build": "npm run build --workspace web",
28
+ "check:session": "tsx test/session.check.ts",
29
+ "start": "node scripts/dev.mjs",
30
+ "dev": "node scripts/dev.mjs --open",
31
+ "check:vcs": "tsx test/vcs.check.ts",
32
+ "check:plan": "tsx test/plan.check.ts",
33
+ "check:checks": "tsx test/checks.check.ts",
34
+ "check:workdir": "tsx test/workdir.check.ts",
35
+ "check:processes": "tsx test/processes.check.ts",
36
+ "check:environment": "tsx test/environment.check.ts",
37
+ "check:clock": "tsx test/clock.check.ts",
38
+ "check:crash": "tsx test/crash.check.ts",
39
+ "check:clipboard": "tsx test/clipboard.check.ts",
40
+ "check:restart": "tsx test/restart.check.ts",
41
+ "check:review": "tsx test/review.check.ts",
42
+ "check:review-evidence": "tsx test/review-evidence.check.ts",
43
+ "check:settings-precedence": "tsx test/settings-precedence.check.ts",
44
+ "check:suite": "tsx test/suite.check.ts",
45
+ "check:model-help": "tsx test/model-help.check.ts",
46
+ "check:shells": "tsx test/shells.check.ts",
47
+ "check:save": "tsx test/save.check.ts",
48
+ "check:guide": "tsx test/guide.check.ts",
49
+ "typecheck": "tsc -p tsconfig.json --noEmit && tsc -p tsconfig.test.json && npm run typecheck --workspace web",
50
+ "check:bundle": "tsx test/bundle.check.ts",
51
+ "check:runname": "tsx test/runname.check.ts",
52
+ "update": "node scripts/update.mjs",
53
+ "check:dangerous": "tsx test/dangerous.check.ts",
54
+ "check:programs": "tsx test/programs.check.ts",
55
+ "check:manifest": "tsx test/manifest.check.ts",
56
+ "check:lock": "tsx test/lock.check.ts",
57
+ "check:isolation": "tsx test/isolation.check.ts",
58
+ "check:security": "tsx test/security.check.ts",
59
+ "check:update": "tsx test/update.check.ts",
60
+ "check:persona": "tsx test/persona.check.ts",
61
+ "check:script": "tsx test/script.check.ts",
62
+ "check:batch": "tsx test/batch.check.ts",
63
+ "check:confinement": "tsx test/confinement.check.ts",
64
+ "check:network": "tsx test/network.check.ts",
65
+ "check:hardening": "tsx test/hardening.check.ts",
66
+ "check:package": "tsx test/package.check.ts",
67
+ "check:models": "tsx test/models.check.ts",
68
+ "check:continue": "tsx test/continue.check.ts",
69
+ "check:startfrom": "tsx test/startfrom.check.ts",
70
+ "check:diff": "tsx test/diff.check.ts",
71
+ "check:integrity": "tsx test/integrity.check.ts",
72
+ "check:scope": "tsx test/scope.check.ts",
73
+ "check:progress": "tsx test/progress.check.ts",
74
+ "check:metrics": "tsx test/metrics.check.ts",
75
+ "check:modelpicker": "tsx test/modelpicker.check.ts",
76
+ "check:formatrepair": "tsx test/formatrepair.check.ts",
77
+ "check:intent": "tsx test/intent.check.ts",
78
+ "check:sync": "tsx test/sync.check.ts",
79
+ "check:prepare": "tsx test/prepare.check.ts",
80
+ "check:live-fixes": "tsx test/live-fixes.check.ts",
81
+ "check:live-models": "tsx test/live-models.check.ts",
82
+ "check:live-chat": "tsx test/live-chatname.check.ts",
83
+ "check:e2e-run": "tsx test/e2e-run.check.ts",
84
+ "check:e2e-continue": "tsx test/e2e-continue.check.ts",
85
+ "check:e2e-interrupt": "tsx test/e2e-interrupt.check.ts",
86
+ "check:ui": "node scripts/build-package.mjs && tsx test/ui.check.ts && tsx test/ui-flows.check.ts",
87
+ "check:all": "npm run check && npm run check:ui && npm run check:release",
88
+ "check:e2e-vcs": "tsx test/e2e-vcs.check.ts",
89
+ "check:noattach": "tsx test/noattach.check.ts",
90
+ "check:guard": "tsx test/guard.check.ts",
91
+ "check:gate": "tsx test/gate.check.ts",
92
+ "check:e2e-batch": "tsx test/e2e-batch.check.ts",
93
+ "check:e2e-review": "tsx test/e2e-review.check.ts",
94
+ "check:e2e-branches": "tsx test/e2e-branches.check.ts",
95
+ "check:e2e-loop": "tsx test/e2e-loop.check.ts",
96
+ "check:transport": "tsx test/transport.check.ts",
97
+ "check:e2e-plan": "tsx test/e2e-plan.check.ts",
98
+ "check:exec": "tsx test/exec.check.ts",
99
+ "check:pins": "tsx test/pins.check.ts",
100
+ "check:release": "tsx test/release.check.ts",
101
+ "check:ui-flows": "tsx test/ui-flows.check.ts",
102
+ "check:login": "tsx test/login.check.ts",
103
+ "check:order": "tsx test/order.check.ts",
104
+ "check:snapshot": "tsx test/snapshot.check.ts",
105
+ "check:inputs": "tsx test/inputs.check.ts",
106
+ "check:e2e-inputs": "tsx test/e2e-inputs.check.ts",
107
+ "check:attempts": "tsx test/attempts.check.ts",
108
+ "check:finding-ids": "tsx test/finding-ids.check.ts",
109
+ "check:e2e-commit": "tsx test/e2e-commit.check.ts",
110
+ "check:e2e-retry-inputs": "tsx test/e2e-retry-inputs.check.ts",
111
+ "check:e2e-run-vcs": "tsx test/e2e-run-vcs.check.ts",
112
+ "check:startbranch": "tsx test/startbranch.check.ts"
113
+ },
114
+ "dependencies": {
115
+ "@nestjs/common": "^12.0.3",
116
+ "@nestjs/core": "^12.0.3",
117
+ "@nestjs/platform-express": "^12.0.3",
118
+ "commander": "^15.0.0",
119
+ "playwright": "^1.63.0",
120
+ "reflect-metadata": "^0.2.2",
121
+ "rxjs": "^7.8.2",
122
+ "yaml": "^2.9.1",
123
+ "zod": "^4.6.5"
124
+ },
125
+ "devDependencies": {
126
+ "@types/express": "^5.0.6",
127
+ "@types/node": "^22.10.2",
128
+ "tsx": "^4.19.2",
129
+ "typescript": "5.9"
130
+ },
131
+ "repository": {
132
+ "type": "git",
133
+ "url": "git+https://github.com/ivan-markov-666/copilot-operator.git"
134
+ },
135
+ "bin": {
136
+ "cop": "dist/src/cli.js"
137
+ },
138
+ "files": [
139
+ "dist/src",
140
+ "dist/web",
141
+ "prompts",
142
+ "README.md",
143
+ "LICENSE"
144
+ ],
145
+ "os": [
146
+ "win32"
147
+ ],
148
+ "keywords": [
149
+ "copilot",
150
+ "microsoft-365",
151
+ "automation",
152
+ "playwright",
153
+ "agent"
154
+ ],
155
+ "workspaces": [
156
+ "web"
157
+ ]
158
+ }
@@ -1 +0,0 @@
1
- "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[36],{1035:(e,t,n)=>{n.d(t,{DialogHost:()=>c,Z:()=>d});var s=n(3365),l=n(1521),a=n(867),r=n(4969);let i=null,o=[];function d(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise(n=>{var s;return s={kind:"confirm",message:e,...t,resolve:n},void(i?i(s):o.push(s))})}function c(e){var t,n;let{children:d}=e,{t:c}=(0,a.kj)(),[u,h]=(0,l.useState)([]),m=(0,l.useRef)(null),f=(0,l.useRef)(null);(0,l.useEffect)(()=>{if(i=e=>h(t=>[...t,e]),o.length>0){let e=o.splice(0,o.length);h(t=>[...t,...e])}return()=>{i=null}},[]);let p=u[0],x=(0,l.useCallback)(e=>{p&&(p.resolve(e),h(e=>e.slice(1)))},[p]);return(0,r.V)(f,!!p,m),(0,l.useEffect)(()=>{if(!p)return;let e=e=>{"Escape"===e.key&&(e.preventDefault(),x(!1))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[p,x]),(0,s.jsxs)(s.Fragment,{children:[d,p&&(0,s.jsx)("div",{className:"modal-backdrop",onClick:()=>x(!1),role:"presentation",children:(0,s.jsxs)("div",{ref:f,className:"modal".concat(p.danger?" danger":""),role:"confirm"===p.kind?"alertdialog":"dialog","aria-modal":"true","aria-labelledby":"modal-title","aria-describedby":"modal-body",onClick:e=>e.stopPropagation(),children:[(0,s.jsx)("h2",{id:"modal-title",children:null!=(t=p.title)?t:c("confirm"===p.kind?"dialog.confirmTitle":"dialog.noticeTitle")}),(0,s.jsx)("div",{id:"modal-body",className:"modal-body",children:p.message}),(0,s.jsxs)("div",{className:"row modal-actions",children:["confirm"===p.kind&&(0,s.jsx)("button",{type:"button",className:"quiet",onClick:()=>x(!1),children:c("dialog.cancel")}),(0,s.jsx)("button",{ref:m,type:"button",className:p.danger?"danger":"primary",onClick:()=>x(!0),children:null!=(n=p.okLabel)?n:c("dialog.ok")})]})]})})]})}},1366:(e,t,n)=>{n.d(t,{w:()=>i,y:()=>r});var s=n(3365),l=n(1521),a=n(867);function r(e){let{readOnly:t,scope:n,onReadOnly:r,onScope:i}=e,{t:o}=(0,a.kj)(),d=(0,l.useId)();return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"option",style:{marginTop:10},children:[(0,s.jsxs)("label",{children:[(0,s.jsx)("input",{type:"checkbox",checked:t,onChange:e=>r(e.target.checked)}),(0,s.jsx)("span",{children:o("task.readOnlyEdit")})]}),(0,s.jsx)("p",{className:"why",children:o("task.readOnlyEditWhy")})]}),(0,s.jsx)("label",{htmlFor:"".concat(d,"-scope"),children:o("task.scopeEdit")}),(0,s.jsx)("textarea",{id:"".concat(d,"-scope"),value:n,onChange:e=>i(e.target.value),placeholder:"tests/e2e/\nsrc/**/*.ts",style:{minHeight:60},disabled:t}),(0,s.jsx)("p",{className:"why",children:o("task.scopeEditWhy")})]})}function i(e){return e.split(/\r?\n/).map(e=>e.trim()).filter(Boolean)}},1910:(e,t,n)=>{n.d(t,{H:()=>o,u:()=>i});var s=n(3365),l=n(1521),a=n(867),r=n(5549);function i(e){let{label:t,save:n}=e,{t:r}=(0,a.kj)(),[i,o]=(0,l.useState)(!1),[d,c]=(0,l.useState)(""),[u,h]=(0,l.useState)(!1),m=async()=>{o(!0),c("");try{var e;let t=await n();h(!1),c(t.revealed?r("save.done",{path:t.path}):r("save.savedOnly",{path:t.path,note:null!=(e=t.note)?e:""}))}catch(e){h(!0),c(r("save.failed",{problem:e.message}))}finally{o(!1)}};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("button",{type:"button",className:"linkish",disabled:i,title:r("save.why"),onClick:()=>void m(),children:i?r("save.saving"):t}),d&&(0,s.jsx)("span",{className:u?"err small":"muted small",children:d})]})}function o(e){let{sessionId:t,taskId:n,attempt:i}=e,{t:o}=(0,a.kj)(),[d,c]=(0,l.useState)(!1),[u,h]=(0,l.useState)(""),[m,f]=(0,l.useState)(!1),p=async()=>{c(!0),h("");try{let e=await r.FH.downloadBundle([{sessionId:t,taskId:n,attempt:i}]);f(!1),h(o("reg.bundleSaved",{name:e}))}catch(e){f(!0),h(o("save.failed",{problem:e.message}))}finally{c(!1)}};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("button",{type:"button",className:"linkish",disabled:d,title:o("save.attemptRecordWhy"),onClick:()=>void p(),children:d?o("save.saving"):o("save.attemptRecord")}),u&&(0,s.jsx)("span",{className:m?"err small":"muted small",children:u})]})}},2876:(e,t,n)=>{n.d(t,{P:()=>c});var s=n(3365),l=n(1521),a=n(5549),r=n(867);function i(e,t){let[n,s]=(0,l.useState)(null),a=(0,l.useRef)(!0),[r,i]=(0,l.useState)(!0),o=(0,l.useCallback)(e=>s(e),[]);return(0,l.useLayoutEffect)(()=>{if(!n)return;let e=()=>{let e=n.scrollHeight-n.scrollTop-n.clientHeight<=24;a.current=e,i(e)};return n.addEventListener("scroll",e,{passive:!0}),()=>n.removeEventListener("scroll",e)},[n]),(0,l.useLayoutEffect)(()=>{n&&e&&a.current&&(n.scrollTop=n.scrollHeight)},[n,e,t]),{ref:o,following:r,follow:(0,l.useCallback)(()=>{a.current=!0,i(!0),n&&(n.scrollTop=n.scrollHeight)},[n])}}var o=n(5132);function d(e){let{text:t,follow:n}=e,{ref:l}=i(n,t);return(0,s.jsx)("pre",{ref:l,className:"story-out".concat(n?" terminal":""),children:t})}function c(e){let{sessionId:t,taskId:n,runId:c,live:h}=e,{t:m}=(0,r.kj)(),[f,p]=(0,l.useState)(null),[x,g]=(0,l.useState)(""),[v,y]=(0,l.useState)(!0),[j,k]=(0,l.useState)(!0),[b,N]=(0,l.useState)(new Set),[w,S]=(0,l.useState)(new Set),[C,E]=(0,l.useState)(new Set),I=!!(null==f?void 0:f.live),F=(0,l.useRef)(0);F.current+=1;let D=i(I,F.current),M=(0,l.useRef)(null),L=(0,l.useRef)(!1);if((0,l.useEffect)(()=>{if(!f)return;let e=[],t=(n,s)=>n.forEach((n,l)=>{let a="".concat(s).concat(l);"review"===n.kind?t(n.entries,"".concat(a,"-")):"step"!==n.kind||n.outcome||e.push(a)});t(f.entries,"e"),e.some(e=>!w.has(e))&&S(t=>new Set([...t,...e])),f.live&&!L.current&&M.current&&(L.current=!0,M.current.scrollIntoView({block:"nearest",behavior:"smooth"}))},[f,w]),(0,l.useEffect)(()=>{let e,s=!0,l=async()=>{try{let r=await a.FH.taskStory(t,n,c);if(!s)return;p(r),g(""),(r.live||h)&&(e=setTimeout(l,2e3))}catch(t){if(!s)return;g(t.message),h&&(e=setTimeout(l,2e3))}};return l(),()=>{s=!1,e&&clearTimeout(e)}},[t,n,c,h]),x&&!f)return(0,s.jsx)("div",{className:"err small",children:x});if(!f)return(0,s.jsx)("div",{className:"muted small",children:m("story.loading")});let T=e=>b.has(e)||w.has(e)&&!C.has(e),H=e=>{let t=T(e);N(n=>{let s=new Set(n);return t?s.delete(e):s.add(e),s}),E(n=>{let s=new Set(n);return t?s.add(e):s.delete(e),s})},R=(e,t)=>{if(!("review"===e.kind?v||j:"step"===e.kind?j:v))return null;if("review"===e.kind)return(0,s.jsxs)("li",{className:"story-review",children:[(0,s.jsxs)("div",{className:"story-head",children:[(0,s.jsx)(u,{at:e.at}),(0,s.jsx)("span",{className:"chip",children:m("story.review",{n:e.round})})]}),(0,s.jsx)("ol",{className:"story",children:e.entries.map((e,n)=>R(e,"".concat(t,"-").concat(n)))})]},t);if("step"===e.kind){let n=T(t),l=!e.outcome&&f.live;return(0,s.jsxs)("li",{className:"story-step".concat(e.failed?" failed":""),children:[(0,s.jsxs)("div",{className:"story-head",children:[(0,s.jsx)(u,{at:e.at}),(0,s.jsx)("span",{className:"chip",children:m("story.step",{it:e.iteration,id:e.id})}),e.outcome&&(0,s.jsxs)("span",{className:"badge ".concat(e.failed?"failed":"done"),children:[e.outcome,void 0!==e.exitCode?" \xb7 exit ".concat(e.exitCode):"",void 0!==e.durationMs?" \xb7 ".concat((0,a.c5)(e.durationMs)):""]}),!e.outcome&&(0,s.jsx)("span",{className:"badge running",children:m("story.running")}),e.failed&&(0,s.jsx)("span",{className:"badge failed",children:m("story.failedHere")})]}),(0,s.jsx)("pre",{className:"story-cmd",children:e.command}),e.output&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("button",{type:"button",className:"linkish small",onClick:()=>H(t),children:n?m("story.hideOutput"):m("story.showOutput",{n:e.output.length})}),n&&(0,s.jsx)(d,{text:e.output,follow:l})]})]},t)}let n=b.has(t),l="sent"===e.kind?m("story.bot"):m("story.chat"),r="reply"===e.kind&&("blocked"===e.status||"failed"===e.status);return(0,s.jsxs)("li",{className:"story-msg ".concat(e.kind).concat(r?" failed":""),children:[(0,s.jsxs)("div",{className:"story-head",children:[(0,s.jsx)(u,{at:e.at}),(0,s.jsx)("strong",{children:l}),(0,s.jsx)("span",{className:"muted small",children:e.label}),"reply"===e.kind&&e.status&&(0,s.jsx)("span",{className:"badge ".concat(r?"failed":"done"===e.status?"done":""),children:e.status})]}),"reply"===e.kind&&e.notes&&(0,s.jsx)("p",{className:"story-notes",children:e.notes}),(0,s.jsx)("button",{type:"button",className:"linkish small",onClick:()=>H(t),children:n?m("story.hideText"):m("story.showText",{n:e.text.length})}),n&&(0,s.jsx)("pre",{className:"story-out",children:e.text})]},t)},q=f.close,B=q&&"done"!==q.status;return(0,s.jsxs)("div",{className:"story-box",ref:M,children:[(0,s.jsxs)("div",{className:"row small",style:{marginBottom:6},children:[(0,s.jsxs)("label",{className:"option-inline",children:[(0,s.jsx)("input",{type:"checkbox",checked:v,onChange:e=>y(e.target.checked)})," ",m("story.showChat")]}),(0,s.jsxs)("label",{className:"option-inline",children:[(0,s.jsx)("input",{type:"checkbox",checked:j,onChange:e=>k(e.target.checked)})," ",m("story.showCommands")]}),f.live&&(0,s.jsxs)("span",{className:"live",children:[(0,s.jsx)("span",{className:"dot","aria-hidden":"true"})," ",m("story.live")]}),f.live&&!D.following&&(0,s.jsx)("button",{type:"button",className:"quiet small",onClick:D.follow,title:m("story.followWhy"),children:m("story.follow")}),x&&(0,s.jsx)("span",{className:"err",children:x})]}),(0,s.jsxs)("div",{className:"story-fixed",children:[(0,s.jsx)("strong",{children:m("story.prompt")}),(0,s.jsx)("pre",{className:"story-out always",children:f.prompt})]}),(0,s.jsx)("div",{ref:D.ref,className:"story-scroll".concat(f.live?" live":""),children:(0,s.jsx)("ol",{className:"story",children:f.entries.map((e,t)=>R(e,"e".concat(t)))})}),q?(0,s.jsxs)("div",{className:"story-fixed close".concat(B?" failed":""),children:[(0,s.jsx)("strong",{children:B?m("story.endedBadly",{status:q.status}):m("story.ended")}),q.reason&&(0,s.jsx)("p",{className:"err small",children:q.reason}),q.summary&&(0,s.jsx)(o.s,{text:q.summary,className:"what"}),q.checks&&q.checks.length>0&&(0,s.jsx)("ul",{className:"small",style:{margin:"6px 0 0",paddingLeft:18},children:q.checks.map((e,t)=>(0,s.jsxs)("li",{className:e.passed?"":"err",children:[e.passed?"✓":"✗"," ",e.name,!e.passed&&e.detail?" — ".concat(e.detail):""]},t))})]}):(0,s.jsx)("div",{className:"story-fixed muted small",children:m("story.notEnded")})]})}function u(e){let{at:t}=e,n=(0,r.W3)(),{locale:l}=(0,r.kj)();if(!t)return null;let a=new Date(t),i="bg"===l?"bg-BG":void 0,o=a.toLocaleTimeString(i,{hour12:!1}),d=new Date().toDateString()===a.toDateString();return(0,s.jsx)("time",{className:"story-when",dateTime:t,title:n(t),children:d?o:"".concat(a.toLocaleDateString(i)," ").concat(o)})}},3041:(e,t,n)=>{n.d(t,{e:()=>i});var s=n(1521),l=n(5549),a=n(1035),r=n(867);function i(e){let{t}=(0,r.kj)(),[n,i]=(0,s.useState)(""),[o,d]=(0,s.useState)({taskId:"",text:""}),c=(e,t)=>d({taskId:e,text:t}),u=(0,s.useCallback)(async n=>{i("restore"),c(n.taskId,"");try{var s,r,o,d,u,h,m,f,p,x,g,v,y,j;let i=await l.FH.restorePreview(n.sessionId,n.taskId);if(!i.ok)return void c(n.taskId,t("restore.cannot",{problem:null!=(o=i.problem)?o:""}));let k={repo:i.repoDir,title:n.title,branch:null!=(d=i.branchName)?d:"",commit:(null!=(u=i.baseCommit)?u:"").slice(0,8)},b=i.leftBehind.length>0?t("restore.confirmLosing",{...k,n:i.leftBehind.length,kept:null!=(h=i.keptOn)?h:"",list:i.leftBehind.slice(0,10).join("\n")}):t("restore.confirm",k);if(!await (0,a.Z)(b))return;let N=await l.FH.restore(n.sessionId,n.taskId);if(!N.ok)return void c(n.taskId,t("restore.failed",{problem:null!=(m=N.problem)?m:""}));c(n.taskId,(null!=(f=null==(s=N.leftBehind)?void 0:s.length)?f:0)>0?t("restore.done",{branch:null!=(p=N.branch)?p:"",commit:(null!=(x=N.commit)?x:"").slice(0,8),n:null!=(g=null==(r=N.leftBehind)?void 0:r.length)?g:0,kept:null!=(v=N.keptOn)?v:""}):t("restore.doneNothing",{branch:null!=(y=N.branch)?y:"",commit:(null!=(j=N.commit)?j:"").slice(0,8)})),e()}catch(e){c(n.taskId,e.message)}finally{i("")}},[t,e]),h=(0,s.useCallback)(async n=>{i("restart"),c(n.taskId,"");try{var s,r,o;let i=await l.FH.restartPlan(n.sessionId,n.taskId);if(!i.ok)return void c(n.taskId,t("restart.cannot",{problem:null!=(s=i.problem)?s:""}));let d=i.restores.filter(e=>!e.ok);if(d.length>0)return void c(n.taskId,t("restart.cannot",{problem:d.map(e=>{var t;return"".concat(e.repoDir,": ").concat(null!=(t=e.problem)?t:"")}).join(" | ")}));let u=i.restores.map(e=>{var n,s,l;return t("restart.repoLine",{repo:e.repoDir,commit:(null!=(n=e.baseCommit)?n:"").slice(0,8),branch:null!=(s=e.branchName)?s:"",n:e.leftBehind.length,kept:null!=(l=e.keptOn)?l:""})}).join("\n"),h=i.tasks.map(e=>" ".concat(e.sessionName," / ").concat(e.title).concat(e.alreadyQueued?t("restart.alreadyQueued"):"")).join("\n"),m="unattended"===i.mode&&!!i.unattendedRefused,f=t("restart.confirm",{title:i.from.title,tasks:i.tasks.length,sessions:i.sessions.length,list:h,repos:u||t("restart.noRepo"),mode:t("unattended"!==i.mode||m?"run.confirm":"run.unattended")})+(m?t("restart.stepByStep",{reason:null!=(r=i.unattendedRefused)?r:""}):"");if(!await (0,a.Z)(f))return;let p=await l.FH.restartFrom(n.sessionId,n.taskId,m?{mode:"confirm"}:{});if(!p.started){c(n.taskId,t("restart.failed",{problem:null!=(o=p.reason)?o:""})),e();return}c(n.taskId,t("restart.started",{requeued:p.requeued,repos:p.restored.length})),e()}catch(e){c(n.taskId,e.message)}finally{i("")}},[t,e]);return{busy:n,message:o.text,messageTask:o.taskId,clearMessage:()=>c("",""),restore:u,restartFrom:h}}},3374:(e,t,n)=>{n.d(t,{c:()=>l});var s=n(1521);function l(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e3,[n,l]=(0,s.useState)(()=>Date.now());return(0,s.useEffect)(()=>{if(!e)return;l(Date.now());let n=window.setInterval(()=>l(Date.now()),t);return()=>window.clearInterval(n)},[e,t]),n}},3523:(e,t,n)=>{function s(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Date.now();if(!e)return;let s=Date.parse(e);if(Number.isNaN(s))return;let l=t?Date.parse(t):n;return Number.isNaN(l)?void 0:Math.max(0,l-s)}function l(e){return!!e.startedAt&&!e.finishedAt&&"queued"!==e.status}function a(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Date.now(),s=t.some(e=>l(e)),a=t.map(e=>e.finishedAt?Date.parse(e.finishedAt):NaN).filter(e=>!Number.isNaN(e)),r=Date.parse(e.startedAt),i=s||0===a.length?n:Math.max(...a);return{ms:Number.isNaN(r)?0:Math.max(0,i-r),live:s,tasks:t.length}}function r(e){var t,n;let s=new Map;for(let n of e){if(!n.runGroup)continue;let e=null!=(t=s.get(n.runGroup.id))?t:{run:n.runGroup,tasks:[]};e.tasks.push(n),s.set(n.runGroup.id,e)}return null!=(n=[...s.values()].sort((e,t)=>Date.parse(t.run.startedAt)-Date.parse(e.run.startedAt))[0])?n:null}n.d(t,{DG:()=>l,d5:()=>s,eZ:()=>a,hH:()=>r})},4811:(e,t,n)=>{n.d(t,{p:()=>a});var s=n(1521),l=n(5549);function a(){let[e,t]=(0,s.useState)(!1);return(0,s.useEffect)(()=>{let e=!0;return l.FH.settings().then(n=>{var s;let l=null!=(s=n.raw.execution)?s:{};e&&t("unattended"===l.mode)}).catch(()=>void 0),()=>{e=!1}},[]),e}},4969:(e,t,n)=>{n.d(t,{V:()=>a});var s=n(1521);let l='a[href], button:not([disabled]), textarea:not([disabled]), input:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])';function a(e,t,n){(0,s.useEffect)(()=>{var s,a;if(!t)return;let r=document.activeElement instanceof HTMLElement?document.activeElement:null,i=e.current,o=null!=(a=null!=(s=null==n?void 0:n.current)?s:null==i?void 0:i.querySelector(l))?a:null;null==o||o.focus();let d=e=>{if("Tab"!==e.key||!i)return;let t=Array.from(i.querySelectorAll(l)).filter(e=>null!==e.offsetParent);if(0===t.length)return;let n=t[0],s=t[t.length-1],a=i.contains(document.activeElement);e.shiftKey&&(document.activeElement===n||!a)?(e.preventDefault(),s.focus()):e.shiftKey||document.activeElement!==s&&a||(e.preventDefault(),n.focus())};return document.addEventListener("keydown",d),()=>{document.removeEventListener("keydown",d),r&&document.contains(r)&&r.focus()}},[e,t,n])}},5132:(e,t,n)=>{n.d(t,{s:()=>i});var s=n(3365),l=n(1521);function a(e,t){let n,l=[],a=/(`[^`\n]+`)|(\*\*[^*\n]+\*\*)|(\*[^*\n]+\*)/g,r=0,i=0;for(;null!==(n=a.exec(e));){n.index>r&&l.push(e.slice(r,n.index));let a=n[0],o="".concat(t,"-i").concat(i+=1);a.startsWith("`")?l.push((0,s.jsx)("code",{children:a.slice(1,-1)},o)):a.startsWith("**")?l.push((0,s.jsx)("strong",{children:a.slice(2,-2)},o)):l.push((0,s.jsx)("em",{children:a.slice(1,-1)},o)),r=n.index+a.length}return r<e.length&&l.push(e.slice(r)),l}function r(e){let t=/^\s*[-*•]\s+(.*)$/.exec(e);if(t)return t[1];let n=/^\s*\d+[.)]\s+(.*)$/.exec(e);return n?n[1]:null}function i(e){let{text:t,className:n}=e,i=[],o=t.replace(/\r\n/g,"\n").split("\n"),d=0,c=0;for(;d<o.length;){let e=o[d];if(e.trim().startsWith("```")){let e=[];for(d+=1;d<o.length&&!o[d].trim().startsWith("```");)e.push(o[d++]);d+=1,e.length>0&&i.push((0,s.jsx)("pre",{children:e.join("\n")},"b".concat(c+=1)));continue}if(null!==r(e)){let e=[];for(;d<o.length&&null!==r(o[d]);)e.push(r(o[d++]));i.push((0,s.jsx)("ul",{children:e.map((e,t)=>(0,s.jsx)("li",{children:a(e,"b".concat(c,"-").concat(t))},t))},"b".concat(c+=1)));continue}if(""===e.trim()){d+=1;continue}let t=[];for(;d<o.length&&""!==o[d].trim()&&null===r(o[d])&&!o[d].trim().startsWith("```");)t.push(o[d++]);let n=c+=1;i.push((0,s.jsx)("p",{children:t.map((e,t)=>(0,s.jsxs)(l.Fragment,{children:[t>0&&(0,s.jsx)("br",{}),a(e,"b".concat(n,"-").concat(t))]},t))},"b".concat(n)))}return(0,s.jsx)("div",{className:"rich ".concat(null!=n?n:""),children:i})}},7527:(e,t,n)=>{n.d(t,{z:()=>l});var s=n(1521);function l(e,t){let n=!(arguments.length>2)||void 0===arguments[2]||arguments[2],l=(0,s.useRef)(e);l.current=e,(0,s.useEffect)(()=>{let e;if(!n)return;let s=!1,a=async()=>{try{await l.current()}catch(e){}finally{s||(e=setTimeout(()=>void a(),t))}};return a(),()=>{s=!0,e&&clearTimeout(e)}},[t,n])}},8934:(e,t,n)=>{n.d(t,{C:()=>d});var s=n(3365),l=n(1521),a=n(5549),r=n(4969),i=n(867);function o(e){if(null===e||""===e)return[];let t=e.split(/\r?\n/);return""===t[t.length-1]&&t.pop(),t}function d(e){let{sessionId:t,taskId:n,runId:a,title:r,files:o}=e,{t:d}=(0,i.kj)(),[u,h]=(0,l.useState)(!1);return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("button",{type:"button",className:"linkish",onClick:()=>h(!0),title:d("diff.openWhy"),children:d("diff.open",{n:o})}),u&&(0,s.jsx)(c,{sessionId:t,taskId:n,runId:a,title:r,onClose:()=>h(!1)})]})}function c(e){var t,n,d,c,h,m,f;let{sessionId:p,taskId:x,runId:g,title:v,onClose:y}=e,{t:j}=(0,i.kj)(),[k,b]=(0,l.useState)(null),[N,w]=(0,l.useState)(""),[S,C]=(0,l.useState)(0),[E,I]=(0,l.useState)(new Map),[F,D]=(0,l.useState)(!1),[M,L]=(0,l.useState)(!0),[T,H]=(0,l.useState)(new Map),[R,q]=(0,l.useState)(-1),B=(0,l.useRef)(null),A=(0,l.useRef)(null),W=(0,l.useRef)(null);(0,r.V)(A,!0,W),(0,l.useEffect)(()=>{a.FH.taskChanges(p,x,g).then(b).catch(e=>w(e.message))},[p,x,g]);let P=null!=(d=null==k?void 0:k.files)?d:[],O=P[S];(0,l.useEffect)(()=>{!O||E.has(O.path)||a.FH.taskChangeFile(p,x,O.path,g).then(e=>I(t=>new Map(t).set(O.path,e))).catch(e=>I(t=>new Map(t).set(O.path,e.message)))},[O,E,p,x,g]);let G=O?E.get(O.path):void 0,K=(0,l.useMemo)(()=>!G||"string"==typeof G||G.binary||G.tooLarge?[]:function(e,t){let n=function(e,t){let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];)n+=1;let s=e.length,l=t.length;for(;s>n&&l>n&&e[s-1]===t[l-1];)s-=1,l-=1;let a=[];for(let e=0;e<n;e+=1)a.push({kind:"same",a:e,b:e});for(let r of function(e,t){let n=e.length,s=t.length;if(0===n)return t.map((e,t)=>({kind:"add",b:t}));if(0===s)return e.map((e,t)=>({kind:"del",a:t}));let l=n+s,a=l+1,r=new Int32Array(2*l+3),i=[];for(let o=0;o<=Math.min(l,2e3);o+=1){i.push(r.slice(a-o-1,a+o+2));for(let l=-o;l<=o;l+=2){let d=l===-o||l!==o&&r[a+l-1]<r[a+l+1]?r[a+l+1]:r[a+l-1]+1,c=d-l;for(;d<n&&c<s&&e[d]===t[c];)d+=1,c+=1;if(r[a+l]=d,d>=n&&c>=s)return function(e,t,n,s){let l=[],a=t.length,r=n.length;for(let t=s;t>0;t-=1){let n=e[t],s=e=>n[e+t+1],i=a-r,o=i===-t||i!==t&&s(i-1)<s(i+1)?i+1:i-1,d=s(o),c=d-o;for(;a>d&&r>c;)a-=1,r-=1,l.push({kind:"same",a:a,b:r});a===d?l.push({kind:"add",b:c}):l.push({kind:"del",a:d}),a=d,r=c}for(;a>0&&r>0;)a-=1,r-=1,l.push({kind:"same",a:a,b:r});return l.reverse()}(i,e,t,o)}}return[...e.map((e,t)=>({kind:"del",a:t})),...t.map((e,t)=>({kind:"add",b:t}))]}(e.slice(n,s),t.slice(n,l)))a.push({kind:r.kind,...void 0!==r.a?{a:r.a+n}:{},...void 0!==r.b?{b:r.b+n}:{}});for(let t=0;s+t<e.length;t+=1)a.push({kind:"same",a:s+t,b:l+t});return a}(e,t),s=[];for(let l=0;l<n.length;){let a=n[l];if("same"===a.kind){s.push({kind:"same",left:{no:a.a+1,text:e[a.a]},right:{no:a.b+1,text:t[a.b]}}),l+=1;continue}let r=[],i=[];for(;l<n.length&&"same"!==n[l].kind;){let e=n[l];"del"===e.kind?r.push(e.a):i.push(e.b),l+=1}let o=Math.max(r.length,i.length);for(let n=0;n<o;n+=1){let l=r[n],a=i[n];s.push({kind:void 0!==l&&void 0!==a?"change":void 0!==l?"del":"add",...void 0!==l?{left:{no:l+1,text:e[l]}}:{},...void 0!==a?{right:{no:a+1,text:t[a]}}:{}})}}return s}(o(G.before),o(G.after)),[G]),V=O&&T.get(O.path)||new Set,Z=(0,l.useMemo)(()=>(function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new Set,s=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if(s)return e.map((e,t)=>({type:"row",row:e,index:t}));let l=[];for(let s=0;s<e.length;){if("same"!==e[s].kind){l.push({type:"row",row:e[s],index:s}),s+=1;continue}let a=s;for(;a<e.length&&"same"===e[a].kind;)a+=1;let r=0===s?0:t,i=a===e.length?0:t,o=a-s-r-i;if(o>1&&!n.has(s+r)){for(let t=s;t<s+r;t+=1)l.push({type:"row",row:e[t],index:t});l.push({type:"gap",from:s+r,count:o});for(let t=a-i;t<a;t+=1)l.push({type:"row",row:e[t],index:t})}else for(let t=s;t<a;t+=1)l.push({type:"row",row:e[t],index:t});s=a}return l})(K,3,V,F),[K,V,F]),_=(0,l.useMemo)(()=>K.flatMap((e,t)=>"same"!==e.kind&&(0===t||"same"===K[t-1].kind)?[t]:[]),[K]);(0,l.useEffect)(()=>{q(-1),B.current&&(B.current.scrollTop=0)},[S]);let Q=(0,l.useCallback)(e=>{var t;if(0===_.length)return;let n=R<0?1===e?0:_.length-1:Math.min(_.length-1,Math.max(0,R+e));q(n);let s=null==(t=B.current)?void 0:t.querySelector('[data-row="'.concat(_[n],'"]'));null==s||s.scrollIntoView({block:"center"})},[R,_]),$=(0,l.useCallback)(e=>C(t=>Math.min(Math.max(0,t+e),Math.max(0,P.length-1))),[P.length]);(0,l.useEffect)(()=>{let e=e=>{if(!e.ctrlKey&&!e.metaKey&&!e.altKey){if("Escape"===e.key)y();else if("n"===e.key)Q(1);else if("p"===e.key)Q(-1);else if("]"===e.key)$(1);else{if("["!==e.key)return;$(-1)}e.preventDefault()}};window.addEventListener("keydown",e);let t=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{window.removeEventListener("keydown",e),document.body.style.overflow=t}},[Q,$,y]);let z=P.reduce((e,t)=>({added:e.added+Math.max(0,t.added),removed:e.removed+Math.max(0,t.removed)}),{added:0,removed:0});return(0,s.jsxs)("div",{ref:A,className:"diff-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"diff-title",children:[(0,s.jsxs)("div",{className:"diff-head",children:[(0,s.jsx)("h2",{id:"diff-title",children:j("diff.title",{title:v})}),(null==k?void 0:k.ok)&&(0,s.jsxs)("span",{className:"muted small",children:[k.branch?"".concat(k.branch," \xb7 "):"",null==(t=k.base)?void 0:t.slice(0,8)," → ",null==(n=k.commit)?void 0:n.slice(0,8)," \xb7 ",j("diff.summary",{n:P.length,a:z.added,r:z.removed})]}),(0,s.jsx)("span",{className:"grow"}),(0,s.jsx)("span",{className:"muted small",children:j("diff.keys")}),(0,s.jsx)("button",{ref:W,type:"button",onClick:y,children:j("diff.close")})]}),N&&(0,s.jsx)("div",{className:"err",style:{padding:12},children:N}),!k&&!N&&(0,s.jsx)("div",{className:"muted",style:{padding:12},children:j("diff.loading")}),k&&!k.ok&&(0,s.jsx)("div",{className:"notice caution",style:{margin:12},children:k.problem}),(null==k?void 0:k.ok)&&0===P.length&&(0,s.jsx)("div",{className:"notice",style:{margin:12},children:j("diff.nothing")}),(null==k?void 0:k.ok)&&P.length>0&&(0,s.jsxs)("div",{className:"diff-body",children:[(0,s.jsx)("nav",{className:"diff-files","aria-label":j("diff.files"),children:P.map((e,t)=>{let n=e.path.lastIndexOf("/");return(0,s.jsxs)("button",{type:"button",className:"diff-file".concat(t===S?" on":""),onClick:()=>C(t),title:e.oldPath?"".concat(e.oldPath," → ").concat(e.path):e.path,children:[(0,s.jsx)("span",{className:"diff-status s-".concat(e.status),children:e.status}),(0,s.jsxs)("span",{className:"diff-path",children:[n>=0&&(0,s.jsx)("span",{className:"muted",children:e.path.slice(0,n+1)}),(0,s.jsx)("strong",{children:e.path.slice(n+1)})]}),(0,s.jsx)("span",{className:"diff-counts",children:e.added<0?j("diff.binaryShort"):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("span",{className:"plus",children:["+",e.added]})," ",(0,s.jsxs)("span",{className:"minus",children:["−",e.removed]})]})})]},e.path)})}),(0,s.jsxs)("div",{className:"diff-main",children:[O&&(0,s.jsxs)("div",{className:"diff-toolbar",children:[(0,s.jsx)("strong",{className:"diff-name",children:O.oldPath?"".concat(O.oldPath," → ").concat(O.path):O.path}),(0,s.jsx)("span",{className:"muted small",children:"A"===O.status?j("diff.added"):"D"===O.status?j("diff.deleted"):"R"===O.status?j("diff.renamed"):""}),(0,s.jsx)("span",{className:"grow"}),(0,s.jsx)("button",{type:"button",className:"quiet",onClick:()=>Q(-1),disabled:0===_.length,children:j("diff.prevChange")}),(0,s.jsx)("button",{type:"button",className:"quiet",onClick:()=>Q(1),disabled:0===_.length,children:j("diff.nextChange")}),(0,s.jsx)("span",{className:"muted small",children:_.length>0?j("diff.changeN",{i:R<0?"–":R+1,n:_.length}):""}),(0,s.jsx)("button",{type:"button",className:"quiet",onClick:()=>$(-1),disabled:0===S,children:j("diff.prevFile")}),(0,s.jsx)("button",{type:"button",className:"quiet",onClick:()=>$(1),disabled:S>=P.length-1,children:j("diff.nextFile")}),(0,s.jsxs)("label",{className:"option-inline",children:[(0,s.jsx)("input",{type:"checkbox",checked:F,onChange:e=>D(e.target.checked)})," ",j("diff.whole")]}),(0,s.jsxs)("label",{className:"option-inline",children:[(0,s.jsx)("input",{type:"checkbox",checked:M,onChange:e=>L(e.target.checked)})," ",j("diff.wrap")]})]}),(0,s.jsxs)("div",{className:"diff-scroll",ref:B,children:[void 0===G&&(0,s.jsx)("div",{className:"muted",style:{padding:12},children:j("diff.loading")}),"string"==typeof G&&(0,s.jsx)("div",{className:"err",style:{padding:12},children:G}),G&&"string"!=typeof G&&G.binary&&(0,s.jsx)("div",{className:"notice",style:{margin:12},children:j("diff.binary")}),G&&"string"!=typeof G&&G.tooLarge&&(0,s.jsx)("div",{className:"notice",style:{margin:12},children:j("diff.tooLarge")}),G&&"string"!=typeof G&&!G.binary&&!G.tooLarge&&(0,s.jsxs)(s.Fragment,{children:[(null!=(c=G.before)?c:"").includes("\r\n")!==(null!=(h=G.after)?h:"").includes("\r\n")&&null!==G.before&&null!==G.after&&(0,s.jsx)("div",{className:"notice small",style:{margin:8},children:j("diff.eol",{from:(null!=(m=G.before)?m:"").includes("\r\n")?"CRLF":"LF",to:(null!=(f=G.after)?f:"").includes("\r\n")?"CRLF":"LF"})}),K.length>0&&0===_.length&&(0,s.jsx)("div",{className:"notice small",style:{margin:8},children:j("diff.sameText")}),(0,s.jsxs)("table",{className:"diff-table".concat(M?"":" nowrap"),children:[(0,s.jsxs)("colgroup",{children:[(0,s.jsx)("col",{className:"num"}),(0,s.jsx)("col",{}),(0,s.jsx)("col",{className:"num"}),(0,s.jsx)("col",{})]}),(0,s.jsx)("thead",{children:(0,s.jsxs)("tr",{children:[(0,s.jsx)("th",{colSpan:2,children:j("diff.before")}),(0,s.jsx)("th",{colSpan:2,children:j("diff.after")})]})}),(0,s.jsx)("tbody",{children:Z.map(e=>"gap"===e.type?(0,s.jsx)("tr",{className:"diff-gap",children:(0,s.jsx)("td",{colSpan:4,children:(0,s.jsx)("button",{type:"button",className:"linkish small",onClick:()=>{var t;return t=e.from,void(O&&H(e=>{var n;return new Map(e).set(O.path,new Set([...null!=(n=e.get(O.path))?n:[],t]))}))},children:j("diff.gap",{n:e.count})})})},"g".concat(e.from)):(0,s.jsx)(u,{row:e.row,index:e.index,current:R>=0&&_[R]===e.index},e.index))})]})]})]})]})]})]})}function u(e){var t,n,a,r;let{row:i,index:o,current:d}=e,c="change"===i.kind?function(e,t){let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];)n+=1;let s=e.length,l=t.length;for(;s>n&&l>n&&e[s-1]===t[l-1];)s-=1,l-=1;return{start:n,leftEnd:s,rightEnd:l}}(i.left.text,i.right.text):null,u=e=>{let t=i[e];if(!t)return null;if(!c)return t.text;let n="left"===e?c.leftEnd:c.rightEnd;return(0,s.jsxs)(l.Fragment,{children:[t.text.slice(0,c.start),(0,s.jsx)("mark",{children:t.text.slice(c.start,n)}),t.text.slice(n)]})};return(0,s.jsxs)("tr",{className:"diff-row ".concat(i.kind).concat(d?" current":""),"data-row":o,children:[(0,s.jsx)("td",{className:"num",children:null!=(a=null==(t=i.left)?void 0:t.no)?a:""}),(0,s.jsx)("td",{className:"code l".concat(i.left?"":" empty"),children:u("left")}),(0,s.jsx)("td",{className:"num",children:null!=(r=null==(n=i.right)?void 0:n.no)?r:""}),(0,s.jsx)("td",{className:"code r".concat(i.right?"":" empty"),children:u("right")})]})}}}]);