@smartmemory/compose 0.2.55-beta → 0.2.57-beta

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 (73) hide show
  1. package/dist/assets/{App-gyObi7Fh.js → App-BmhlHOXF.js} +240 -240
  2. package/dist/assets/{abnfDiagram-VRR7QNED-DJ5dPOe-.js → abnfDiagram-VRR7QNED-CMOTYAnt.js} +1 -1
  3. package/dist/assets/{arc-CEbBvAxi.js → arc-BJAv_6dL.js} +1 -1
  4. package/dist/assets/{architectureDiagram-ZJ3FMSHR-D7Dutd2o.js → architectureDiagram-ZJ3FMSHR-xa4DLUcp.js} +1 -1
  5. package/dist/assets/{blockDiagram-677ZJIJ3-B-FqnKY3.js → blockDiagram-677ZJIJ3-BdkDqeQF.js} +1 -1
  6. package/dist/assets/{browser-Cr0recrN.js → browser-CvETNQNv.js} +1 -1
  7. package/dist/assets/{c4Diagram-LMCZKHZV-DKyTJh_m.js → c4Diagram-LMCZKHZV-DiNrLIuL.js} +1 -1
  8. package/dist/assets/channel-CYErfopw.js +1 -0
  9. package/dist/assets/{chunk-2Q5K7J3B-oUMIjqtr.js → chunk-2Q5K7J3B-BsjtgrSL.js} +1 -1
  10. package/dist/assets/{chunk-32BRIVSS-BX5Uyghd.js → chunk-32BRIVSS-DpImULWy.js} +1 -1
  11. package/dist/assets/{chunk-5VM5RSS4-DZGXdHnG.js → chunk-5VM5RSS4-DTdG5JnR.js} +1 -1
  12. package/dist/assets/{chunk-EX3LRPZG-iz_V2kb-.js → chunk-EX3LRPZG-Cj1jNuKY.js} +1 -1
  13. package/dist/assets/{chunk-JWPE2WC7-cneY4s8q.js → chunk-JWPE2WC7-DwQ0wwWn.js} +1 -1
  14. package/dist/assets/{chunk-MOJQB5TN-NGLTNiNf.js → chunk-MOJQB5TN-DZZa7unc.js} +1 -1
  15. package/dist/assets/{chunk-RYQCIY6F-BjW2x61e.js → chunk-RYQCIY6F-CgdjqYQj.js} +1 -1
  16. package/dist/assets/{chunk-V7JOEXUC-CU7ID8uE.js → chunk-V7JOEXUC-DrPIj6XI.js} +1 -1
  17. package/dist/assets/{chunk-VR4S4FIN-CxmSp2Q2.js → chunk-VR4S4FIN-BBUOVC5W.js} +1 -1
  18. package/dist/assets/{chunk-XXDRQBXY-DHczIQQU.js → chunk-XXDRQBXY-BEIiZ6gS.js} +1 -1
  19. package/dist/assets/classDiagram-OUVF2IWQ-qCC_hnXu.js +1 -0
  20. package/dist/assets/classDiagram-v2-EOCWNBFH-qCC_hnXu.js +1 -0
  21. package/dist/assets/{cose-bilkent-JH36ORCC-DV1msdt2.js → cose-bilkent-JH36ORCC-ClFTQEyD.js} +1 -1
  22. package/dist/assets/{cynefin-VYW2F7L2-B-thkCgc.js → cynefin-VYW2F7L2-5Bp7xFO0.js} +1 -1
  23. package/dist/assets/{cynefinDiagram-TSTJHNR4-B9sLmzW7.js → cynefinDiagram-TSTJHNR4-C-0QlSda.js} +1 -1
  24. package/dist/assets/{dagre-VKFMJZFB-CzVd8ZeS.js → dagre-VKFMJZFB-DLkqsfBy.js} +1 -1
  25. package/dist/assets/{diagram-FQU43EPY-C2kUlpSd.js → diagram-FQU43EPY-Cwh_tJ_r.js} +1 -1
  26. package/dist/assets/{diagram-G47NLZAW-Bpk-Et_a.js → diagram-G47NLZAW-CvvAjulf.js} +1 -1
  27. package/dist/assets/{diagram-NH7WQ7WH-DOICKw5r.js → diagram-NH7WQ7WH-CCoyx8_e.js} +1 -1
  28. package/dist/assets/{diagram-OA4YK3LP-CUV9PnRC.js → diagram-OA4YK3LP-DfjhKYCp.js} +1 -1
  29. package/dist/assets/{diagram-WEI45ONY-BmhIXYmr.js → diagram-WEI45ONY-Vjz0ygfB.js} +1 -1
  30. package/dist/assets/{ebnfDiagram-CCIWWBDH-BO_0Mcjb.js → ebnfDiagram-CCIWWBDH-GsA8c6g2.js} +1 -1
  31. package/dist/assets/{erDiagram-Q63AITRT-Bd5yIkwb.js → erDiagram-Q63AITRT-Cc0lJ9sQ.js} +1 -1
  32. package/dist/assets/{flowDiagram-23GEKE2U-BC1lVLbe.js → flowDiagram-23GEKE2U-C_sotK-k.js} +1 -1
  33. package/dist/assets/{ganttDiagram-NO4QXBWP-CbHS2Md0.js → ganttDiagram-NO4QXBWP-BBtu_WUe.js} +1 -1
  34. package/dist/assets/{gitGraphDiagram-IHSO6WYX-DZtA0qeo.js → gitGraphDiagram-IHSO6WYX-BV_aSB8-.js} +1 -1
  35. package/dist/assets/{graph-xkel59g2.js → graph--wGAvskB.js} +1 -1
  36. package/dist/assets/{index-C00QpUdP.js → index-CKfOVv2N.js} +3 -3
  37. package/dist/assets/{infoDiagram-FWYZ7A6U-Caji6WpL.js → infoDiagram-FWYZ7A6U-DMAvNGtX.js} +1 -1
  38. package/dist/assets/{ishikawaDiagram-FXEZZL3T-CNhNIQOK.js → ishikawaDiagram-FXEZZL3T-DfQB91MZ.js} +1 -1
  39. package/dist/assets/{journeyDiagram-5HDEW3XC-Dnso1Q2f.js → journeyDiagram-5HDEW3XC-Bq4Llm9o.js} +1 -1
  40. package/dist/assets/{kanban-definition-HUTT4EX6-CnpPLKHm.js → kanban-definition-HUTT4EX6-DTXHiDiE.js} +1 -1
  41. package/dist/assets/{linear-COgkPG4Y.js → linear-BQSYZcVg.js} +1 -1
  42. package/dist/assets/{mindmap-definition-LN4V7U3C-CBH5P268.js → mindmap-definition-LN4V7U3C-KuH2NIj0.js} +1 -1
  43. package/dist/assets/mobile-PV1zQVwv.js +17 -0
  44. package/dist/assets/{pegDiagram-2B236MQR-C4FswqnY.js → pegDiagram-2B236MQR-BKoNGQFr.js} +1 -1
  45. package/dist/assets/{pieDiagram-ENE6RG2P-DU_WHHdv.js → pieDiagram-ENE6RG2P-EpYv162Y.js} +1 -1
  46. package/dist/assets/{quadrantDiagram-ABIIQ3AL-CDzGdzG9.js → quadrantDiagram-ABIIQ3AL-C9deUjQ2.js} +1 -1
  47. package/dist/assets/{railroadDiagram-RFXS5EU6-DlRKrGUE.js → railroadDiagram-RFXS5EU6-Csqw2hK9.js} +1 -1
  48. package/dist/assets/{requirementDiagram-TGXJPOKE-DBLVKLPS.js → requirementDiagram-TGXJPOKE-DCuz3emr.js} +1 -1
  49. package/dist/assets/{sankeyDiagram-HTMAVEWB-Be0dIvmC.js → sankeyDiagram-HTMAVEWB-BTeTL24f.js} +1 -1
  50. package/dist/assets/{sequenceDiagram-DBY2YBRQ-BCpYBQ8F.js → sequenceDiagram-DBY2YBRQ-Cf1ZkTwO.js} +1 -1
  51. package/dist/assets/{sizeCapture-X5ZJPWSS-BZnyrxa6.js → sizeCapture-X5ZJPWSS-D3Lbewzg.js} +1 -1
  52. package/dist/assets/{stateDiagram-2N3HPSRC-DMroM4ld.js → stateDiagram-2N3HPSRC-O8l37yJI.js} +1 -1
  53. package/dist/assets/stateDiagram-v2-6OUMAXLB-BWqk_9py.js +1 -0
  54. package/dist/assets/{swimlanes-5IMT3BWC-Dx9Lc7jS.js → swimlanes-5IMT3BWC-BikmTh8b.js} +2 -2
  55. package/dist/assets/swimlanesDiagram-G3AALYLV-C60ICdks.js +8 -0
  56. package/dist/assets/{timeline-definition-FHXFAJF6-SlkJLwrF.js → timeline-definition-FHXFAJF6-BOxSosG0.js} +1 -1
  57. package/dist/assets/{vennDiagram-L72KCM5P-DH7Ad5bs.js → vennDiagram-L72KCM5P-BSClOErZ.js} +1 -1
  58. package/dist/assets/{wardleyDiagram-EHGQE667-yUzFRzyF.js → wardleyDiagram-EHGQE667-DHFRjOK0.js} +1 -1
  59. package/dist/assets/{xychartDiagram-FW5EYKEG-B-MsI0CO.js → xychartDiagram-FW5EYKEG-Dh1v4x-O.js} +1 -1
  60. package/dist/index.html +2 -2
  61. package/lib/feature-writer.js +24 -5
  62. package/package.json +1 -1
  63. package/server/index.js +27 -5
  64. package/server/settings-routes.js +11 -4
  65. package/server/settings-store.js +53 -5
  66. package/server/stratum-api.js +1 -0
  67. package/server/stratum-client.js +98 -32
  68. package/dist/assets/channel-CmuM_CaB.js +0 -1
  69. package/dist/assets/classDiagram-OUVF2IWQ-D0HUdgLP.js +0 -1
  70. package/dist/assets/classDiagram-v2-EOCWNBFH-D0HUdgLP.js +0 -1
  71. package/dist/assets/mobile-CNLMhdFP.js +0 -17
  72. package/dist/assets/stateDiagram-v2-6OUMAXLB-cykL6dtf.js +0 -1
  73. package/dist/assets/swimlanesDiagram-G3AALYLV-CJMK8pFj.js +0 -8
@@ -15,6 +15,7 @@
15
15
  */
16
16
 
17
17
  import { execFile as _execFileDefault } from 'node:child_process';
18
+ import { loadProjectConfig } from './project-root.js';
18
19
 
19
20
  const STRATUM_BIN = 'stratum-mcp';
20
21
 
@@ -24,57 +25,118 @@ export function _testOnly_setExecFile(fn) { _execFile = fn; }
24
25
  const QUERY_TIMEOUT_MS = 5_000;
25
26
  const MUTATION_TIMEOUT_MS = 10_000;
26
27
 
28
+ // ---------------------------------------------------------------------------
29
+ // Engine selection (COMP-STRATUM-TS)
30
+ //
31
+ // The flow/gate seam is engine-selectable: Python `stratum-mcp` (default) or
32
+ // the TS engine's `stratum` CLI, which emits the same JSON projections and
33
+ // exit codes. Guard calls are PINNED to Python — STRAT-GUARD is not part of
34
+ // the TS port. Resolution order: COMPOSE_STRATUM_ENGINE env override, then
35
+ // capabilities.stratumEngine in .compose/compose.json, then "python".
36
+ // Unknown values fail loudly; never a silent fallback.
37
+ // ---------------------------------------------------------------------------
38
+
39
+ /** @returns {'python'|'ts'} */
40
+ export function resolveStratumEngine() {
41
+ let value = process.env.COMPOSE_STRATUM_ENGINE;
42
+ if (value === undefined || value === '') {
43
+ try { value = loadProjectConfig()?.capabilities?.stratumEngine; } catch { value = undefined; }
44
+ }
45
+ if (value === undefined || value === '') return 'python';
46
+ if (value !== 'python' && value !== 'ts') {
47
+ throw new Error(`stratumEngine must be "python" or "ts", got ${JSON.stringify(value)}`);
48
+ }
49
+ return value;
50
+ }
51
+
52
+ /** Binary for flow/gate query+mutation calls under the selected engine. */
53
+ function flowGateBin() {
54
+ if (resolveStratumEngine() === 'ts') return process.env.COMPOSE_STRATUM_TS_BIN || 'stratum';
55
+ return STRATUM_BIN;
56
+ }
57
+
27
58
  // ---------------------------------------------------------------------------
28
59
  // Core subprocess runner
29
60
  // ---------------------------------------------------------------------------
30
61
 
31
62
  /**
32
- * Spawn stratum-mcp with args. Returns a Promise resolving to { stdout, code }.
63
+ * Spawn a stratum binary with args. Returns a Promise resolving to { stdout, code }.
33
64
  * Rejects only on spawn failure (binary not found).
34
65
  *
35
66
  * @param {string[]} args
36
67
  * @param {number} timeoutMs
68
+ * @param {string} [bin] — defaults to the Python stratum-mcp binary
37
69
  * @returns {Promise<{ stdout: string, stderr: string, code: number }>}
38
70
  */
39
- function spawnStratum(args, timeoutMs) {
40
- return new Promise((resolve, reject) => {
41
- let stdout = '';
42
- let stderr = '';
43
-
44
- const proc = _execFile(STRATUM_BIN, args, { timeout: timeoutMs }, (err, out, err2) => {
45
- stdout = out || '';
46
- stderr = err2 || '';
47
- const code = err?.code === 'ETIMEDOUT' ? -1
48
- : (typeof err?.code === 'number' ? err.code : 0);
49
- resolve({ stdout, stderr, code });
71
+ function spawnStratum(args, timeoutMs, bin = STRATUM_BIN) {
72
+ return new Promise((resolve) => {
73
+ const proc = _execFile(bin, args, { timeout: timeoutMs }, (err, out, err2) => {
74
+ resolve(_spawnResult(bin, err, out, err2));
50
75
  });
51
-
76
+ // Node delivers spawn failures through BOTH the callback and the child
77
+ // 'error' event, in racy order. Both paths settle through the same
78
+ // mapping — the promise keeps whichever fires first, never an unhandled
79
+ // rejection, and only genuine spawn codes become SPAWN.
52
80
  proc.on('error', (err) => {
53
- if (err.code === 'ENOENT') {
54
- reject(new Error(`stratum-mcp not found. Install with: pip install stratum-mcp`));
55
- } else {
56
- reject(err);
57
- }
81
+ resolve(_spawnResult(bin, err ?? new Error('child process error'), '', ''));
58
82
  });
59
83
  });
60
84
  }
61
85
 
86
+ // Genuine spawn-level failures; other string codes (e.g. maxbuffer overruns)
87
+ // are execution failures and must not be reported as "install stratum".
88
+ const _SPAWN_CODES = new Set(['ENOENT', 'EACCES', 'EPERM', 'ENOTDIR']);
89
+
90
+ /** Map an execFile callback settle into the { stdout, stderr, code } contract. */
91
+ function _spawnResult(bin, err, out, err2) {
92
+ const stdout = out || '';
93
+ let stderr = err2 || '';
94
+ let code;
95
+ if (err?.code === 'ETIMEDOUT') code = -1;
96
+ else if (typeof err?.code === 'number') code = err.code;
97
+ else if (typeof err?.code === 'string' && _SPAWN_CODES.has(err.code)) {
98
+ code = -2;
99
+ stderr = _spawnRemedy(bin, err.code);
100
+ } else if (err) {
101
+ // Non-spawn string codes (ERR_CHILD_PROCESS_STDIO_MAXBUFFER, ...) and
102
+ // codeless errors: a generic failure with the real message preserved.
103
+ code = 1;
104
+ stderr = stderr || err.message || String(err);
105
+ } else {
106
+ code = 0;
107
+ }
108
+ return { stdout, stderr, code };
109
+ }
110
+
111
+ /** Binary-specific spawn-failure message with the install/path remedy. */
112
+ function _spawnRemedy(bin, code) {
113
+ return bin === STRATUM_BIN
114
+ ? `stratum-mcp failed to spawn (${code}). Install with: pip install stratum-mcp`
115
+ : `${bin} (TS stratum engine) failed to spawn (${code}). Install @smartmemory/stratum or set COMPOSE_STRATUM_TS_BIN`;
116
+ }
117
+
62
118
  /**
63
119
  * Run a query command (read-only). Retries once on timeout.
64
120
  *
65
121
  * @returns {Promise<any>} parsed JSON result, or throws StratumError
66
122
  */
67
123
  async function runQuery(args) {
68
- let result = await spawnStratum(args, QUERY_TIMEOUT_MS);
124
+ const bin = flowGateBin();
125
+ let result = await spawnStratum(args, QUERY_TIMEOUT_MS, bin);
69
126
 
70
127
  if (result.code === -1) {
71
128
  // Retry once on timeout
72
- result = await spawnStratum(args, QUERY_TIMEOUT_MS);
129
+ result = await spawnStratum(args, QUERY_TIMEOUT_MS, bin);
73
130
  if (result.code === -1) {
74
131
  return { error: { code: 'TIMEOUT', message: 'stratum-mcp query timed out', detail: '' } };
75
132
  }
76
133
  }
77
134
 
135
+ if (result.code === -2) {
136
+ console.error('[stratum-client] query spawn failure:', result.stderr);
137
+ return { error: { code: 'SPAWN', message: result.stderr, detail: '' } };
138
+ }
139
+
78
140
  if (result.code !== 0) {
79
141
  console.error('[stratum-client] query error stderr:', result.stderr);
80
142
  try {
@@ -97,12 +159,17 @@ async function runQuery(args) {
97
159
  * @returns {Promise<any>} parsed JSON result, or { conflict }, or { error }
98
160
  */
99
161
  async function runMutation(args) {
100
- const result = await spawnStratum(args, MUTATION_TIMEOUT_MS);
162
+ const result = await spawnStratum(args, MUTATION_TIMEOUT_MS, flowGateBin());
101
163
 
102
164
  if (result.code === -1) {
103
165
  return { error: { code: 'TIMEOUT', message: 'stratum-mcp gate timed out', detail: '' } };
104
166
  }
105
167
 
168
+ if (result.code === -2) {
169
+ console.error('[stratum-client] mutation spawn failure:', result.stderr);
170
+ return { error: { code: 'SPAWN', message: result.stderr, detail: '' } };
171
+ }
172
+
106
173
  if (result.code === 2) {
107
174
  try {
108
175
  return JSON.parse(result.stdout); // { conflict: true, ... }
@@ -130,7 +197,8 @@ async function runMutation(args) {
130
197
  /**
131
198
  * Spawn stratum-mcp with args and pipe `inputJson` (a string) on stdin.
132
199
  * Used by the STRAT-GUARD adapter, whose CLI reads one JSON kwargs object from
133
- * stdin. Same resolve contract as spawnStratum.
200
+ * stdin. Same resolve contract as spawnStratum. PINNED to the Python binary —
201
+ * STRAT-GUARD is not part of the TS port and ignores the engine flag.
134
202
  *
135
203
  * @param {string[]} args
136
204
  * @param {string} inputJson
@@ -138,19 +206,13 @@ async function runMutation(args) {
138
206
  * @returns {Promise<{ stdout: string, stderr: string, code: number }>}
139
207
  */
140
208
  function spawnStratumStdin(args, inputJson, timeoutMs) {
141
- return new Promise((resolve, reject) => {
209
+ return new Promise((resolve) => {
142
210
  const proc = _execFile(STRATUM_BIN, args, { timeout: timeoutMs }, (err, out, err2) => {
143
- const code = err?.code === 'ETIMEDOUT' ? -1
144
- : (typeof err?.code === 'number' ? err.code : 0);
145
- resolve({ stdout: out || '', stderr: err2 || '', code });
211
+ resolve(_spawnResult(STRATUM_BIN, err, out, err2));
146
212
  });
147
-
213
+ // Same both-paths-settle-identically contract as spawnStratum.
148
214
  proc.on('error', (err) => {
149
- if (err.code === 'ENOENT') {
150
- reject(new Error(`stratum-mcp not found. Install with: pip install stratum-mcp`));
151
- } else {
152
- reject(err);
153
- }
215
+ resolve(_spawnResult(STRATUM_BIN, err ?? new Error('child process error'), '', ''));
154
216
  });
155
217
 
156
218
  // Feed the JSON kwargs on stdin. The test mock supplies a fake stdin; a
@@ -177,6 +239,10 @@ async function runGuard(action, kwargs, timeoutMs = MUTATION_TIMEOUT_MS) {
177
239
  if (result.code === -1) {
178
240
  return { error: { code: 'TIMEOUT', message: 'stratum-mcp guard timed out', detail: '' } };
179
241
  }
242
+ if (result.code === -2) {
243
+ console.error('[stratum-client] guard spawn failure:', result.stderr);
244
+ return { error: { code: 'SPAWN', message: result.stderr, detail: '' } };
245
+ }
180
246
  if (result.code !== 0) {
181
247
  console.error('[stratum-client] guard error stderr:', result.stderr);
182
248
  try {
@@ -1 +0,0 @@
1
- import{ag as o,ah as n}from"./App-gyObi7Fh.js";const t=(a,r)=>o.lang.round(n.parse(a)[r]);export{t as c};
@@ -1 +0,0 @@
1
- import{s as a,c as s,a as e,C as t}from"./chunk-V7JOEXUC-CU7ID8uE.js";import{_ as i}from"./App-gyObi7Fh.js";import"./chunk-5VM5RSS4-DZGXdHnG.js";import"./chunk-XXDRQBXY-DHczIQQU.js";import"./chunk-VR4S4FIN-CxmSp2Q2.js";import"./chunk-32BRIVSS-BX5Uyghd.js";import"./mobile-CNLMhdFP.js";import"./index-C00QpUdP.js";import"./graph-xkel59g2.js";var b={parser:e,get db(){return new t},renderer:s,styles:a,init:i(r=>{r.class||(r.class={}),r.class.arrowMarkerAbsolute=r.arrowMarkerAbsolute},"init")};export{b as diagram};
@@ -1 +0,0 @@
1
- import{s as a,c as s,a as e,C as t}from"./chunk-V7JOEXUC-CU7ID8uE.js";import{_ as i}from"./App-gyObi7Fh.js";import"./chunk-5VM5RSS4-DZGXdHnG.js";import"./chunk-XXDRQBXY-DHczIQQU.js";import"./chunk-VR4S4FIN-CxmSp2Q2.js";import"./chunk-32BRIVSS-BX5Uyghd.js";import"./mobile-CNLMhdFP.js";import"./index-C00QpUdP.js";import"./graph-xkel59g2.js";var b={parser:e,get db(){return new t},renderer:s,styles:a,init:i(r=>{r.class||(r.class={}),r.class.arrowMarkerAbsolute=r.arrowMarkerAbsolute},"init")};export{b as diagram};
@@ -1,17 +0,0 @@
1
- function tt(e,a){for(var s=0;s<a.length;s++){const n=a[s];if(typeof n!="string"&&!Array.isArray(n)){for(const i in n)if(i!=="default"&&!(i in e)){const u=Object.getOwnPropertyDescriptor(n,i);u&&Object.defineProperty(e,i,u.get?u:{enumerable:!0,get:()=>n[i]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}var Xs=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function st(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var je={exports:{}},re={};/**
2
- * @license React
3
- * react-jsx-runtime.production.js
4
- *
5
- * Copyright (c) Meta Platforms, Inc. and affiliates.
6
- *
7
- * This source code is licensed under the MIT license found in the
8
- * LICENSE file in the root directory of this source tree.
9
- */var Ae;function at(){if(Ae)return re;Ae=1;var e=Symbol.for("react.transitional.element"),a=Symbol.for("react.fragment");function s(n,i,u){var o=null;if(u!==void 0&&(o=""+u),i.key!==void 0&&(o=""+i.key),"key"in i){u={};for(var l in i)l!=="key"&&(u[l]=i[l])}else u=i;return i=u.ref,{$$typeof:e,type:n,key:o,ref:i!==void 0?i:null,props:u}}return re.Fragment=a,re.jsx=s,re.jsxs=s,re}var Re;function nt(){return Re||(Re=1,je.exports=at()),je.exports}var t=nt(),ve={exports:{}},I={};/**
10
- * @license React
11
- * react.production.js
12
- *
13
- * Copyright (c) Meta Platforms, Inc. and affiliates.
14
- *
15
- * This source code is licensed under the MIT license found in the
16
- * LICENSE file in the root directory of this source tree.
17
- */var _e;function rt(){if(_e)return I;_e=1;var e=Symbol.for("react.transitional.element"),a=Symbol.for("react.portal"),s=Symbol.for("react.fragment"),n=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),u=Symbol.for("react.consumer"),o=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),d=Symbol.for("react.suspense"),g=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),f=Symbol.for("react.activity"),p=Symbol.iterator;function h(c){return c===null||typeof c!="object"?null:(c=p&&c[p]||c["@@iterator"],typeof c=="function"?c:null)}var N={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},C=Object.assign,w={};function E(c,k,_){this.props=c,this.context=k,this.refs=w,this.updater=_||N}E.prototype.isReactComponent={},E.prototype.setState=function(c,k){if(typeof c!="object"&&typeof c!="function"&&c!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,c,k,"setState")},E.prototype.forceUpdate=function(c){this.updater.enqueueForceUpdate(this,c,"forceUpdate")};function v(){}v.prototype=E.prototype;function T(c,k,_){this.props=c,this.context=k,this.refs=w,this.updater=_||N}var x=T.prototype=new v;x.constructor=T,C(x,E.prototype),x.isPureReactComponent=!0;var j=Array.isArray;function b(){}var y={H:null,A:null,T:null,S:null},S=Object.prototype.hasOwnProperty;function A(c,k,_){var $=_.ref;return{$$typeof:e,type:c,key:k,ref:$!==void 0?$:null,props:_}}function M(c,k){return A(c.type,k,c.props)}function P(c){return typeof c=="object"&&c!==null&&c.$$typeof===e}function O(c){var k={"=":"=0",":":"=2"};return"$"+c.replace(/[=:]/g,function(_){return k[_]})}var L=/\/+/g;function F(c,k){return typeof c=="object"&&c!==null&&c.key!=null?O(""+c.key):k.toString(36)}function Y(c){switch(c.status){case"fulfilled":return c.value;case"rejected":throw c.reason;default:switch(typeof c.status=="string"?c.then(b,b):(c.status="pending",c.then(function(k){c.status==="pending"&&(c.status="fulfilled",c.value=k)},function(k){c.status==="pending"&&(c.status="rejected",c.reason=k)})),c.status){case"fulfilled":return c.value;case"rejected":throw c.reason}}throw c}function q(c,k,_,$,D){var U=typeof c;(U==="undefined"||U==="boolean")&&(c=null);var G=!1;if(c===null)G=!0;else switch(U){case"bigint":case"string":case"number":G=!0;break;case"object":switch(c.$$typeof){case e:case a:G=!0;break;case m:return G=c._init,q(G(c._payload),k,_,$,D)}}if(G)return D=D(c),G=$===""?"."+F(c,0):$,j(D)?(_="",G!=null&&(_=G.replace(L,"$&/")+"/"),q(D,k,_,"",function(R){return R})):D!=null&&(P(D)&&(D=M(D,_+(D.key==null||c&&c.key===D.key?"":(""+D.key).replace(L,"$&/")+"/")+G)),k.push(D)),1;G=0;var W=$===""?".":$+":";if(j(c))for(var J=0;J<c.length;J++)$=c[J],U=W+F($,J),G+=q($,k,_,U,D);else if(J=h(c),typeof J=="function")for(c=J.call(c),J=0;!($=c.next()).done;)$=$.value,U=W+F($,J++),G+=q($,k,_,U,D);else if(U==="object"){if(typeof c.then=="function")return q(Y(c),k,_,$,D);throw k=String(c),Error("Objects are not valid as a React child (found: "+(k==="[object Object]"?"object with keys {"+Object.keys(c).join(", ")+"}":k)+"). If you meant to render a collection of children, use an array instead.")}return G}function z(c,k,_){if(c==null)return c;var $=[],D=0;return q(c,$,"","",function(U){return k.call(_,U,D++)}),$}function ae(c){if(c._status===-1){var k=c._result;k=k(),k.then(function(_){(c._status===0||c._status===-1)&&(c._status=1,c._result=_)},function(_){(c._status===0||c._status===-1)&&(c._status=2,c._result=_)}),c._status===-1&&(c._status=0,c._result=k)}if(c._status===1)return c._result.default;throw c._result}var Q=typeof reportError=="function"?reportError:function(c){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var k=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof c=="object"&&c!==null&&typeof c.message=="string"?String(c.message):String(c),error:c});if(!window.dispatchEvent(k))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",c);return}console.error(c)},K={map:z,forEach:function(c,k,_){z(c,function(){k.apply(this,arguments)},_)},count:function(c){var k=0;return z(c,function(){k++}),k},toArray:function(c){return z(c,function(k){return k})||[]},only:function(c){if(!P(c))throw Error("React.Children.only expected to receive a single React element child.");return c}};return I.Activity=f,I.Children=K,I.Component=E,I.Fragment=s,I.Profiler=i,I.PureComponent=T,I.StrictMode=n,I.Suspense=d,I.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=y,I.__COMPILER_RUNTIME={__proto__:null,c:function(c){return y.H.useMemoCache(c)}},I.cache=function(c){return function(){return c.apply(null,arguments)}},I.cacheSignal=function(){return null},I.cloneElement=function(c,k,_){if(c==null)throw Error("The argument must be a React element, but you passed "+c+".");var $=C({},c.props),D=c.key;if(k!=null)for(U in k.key!==void 0&&(D=""+k.key),k)!S.call(k,U)||U==="key"||U==="__self"||U==="__source"||U==="ref"&&k.ref===void 0||($[U]=k[U]);var U=arguments.length-2;if(U===1)$.children=_;else if(1<U){for(var G=Array(U),W=0;W<U;W++)G[W]=arguments[W+2];$.children=G}return A(c.type,D,$)},I.createContext=function(c){return c={$$typeof:o,_currentValue:c,_currentValue2:c,_threadCount:0,Provider:null,Consumer:null},c.Provider=c,c.Consumer={$$typeof:u,_context:c},c},I.createElement=function(c,k,_){var $,D={},U=null;if(k!=null)for($ in k.key!==void 0&&(U=""+k.key),k)S.call(k,$)&&$!=="key"&&$!=="__self"&&$!=="__source"&&(D[$]=k[$]);var G=arguments.length-2;if(G===1)D.children=_;else if(1<G){for(var W=Array(G),J=0;J<G;J++)W[J]=arguments[J+2];D.children=W}if(c&&c.defaultProps)for($ in G=c.defaultProps,G)D[$]===void 0&&(D[$]=G[$]);return A(c,U,D)},I.createRef=function(){return{current:null}},I.forwardRef=function(c){return{$$typeof:l,render:c}},I.isValidElement=P,I.lazy=function(c){return{$$typeof:m,_payload:{_status:-1,_result:c},_init:ae}},I.memo=function(c,k){return{$$typeof:g,type:c,compare:k===void 0?null:k}},I.startTransition=function(c){var k=y.T,_={};y.T=_;try{var $=c(),D=y.S;D!==null&&D(_,$),typeof $=="object"&&$!==null&&typeof $.then=="function"&&$.then(b,Q)}catch(U){Q(U)}finally{k!==null&&_.types!==null&&(k.types=_.types),y.T=k}},I.unstable_useCacheRefresh=function(){return y.H.useCacheRefresh()},I.use=function(c){return y.H.use(c)},I.useActionState=function(c,k,_){return y.H.useActionState(c,k,_)},I.useCallback=function(c,k){return y.H.useCallback(c,k)},I.useContext=function(c){return y.H.useContext(c)},I.useDebugValue=function(){},I.useDeferredValue=function(c,k){return y.H.useDeferredValue(c,k)},I.useEffect=function(c,k){return y.H.useEffect(c,k)},I.useEffectEvent=function(c){return y.H.useEffectEvent(c)},I.useId=function(){return y.H.useId()},I.useImperativeHandle=function(c,k,_){return y.H.useImperativeHandle(c,k,_)},I.useInsertionEffect=function(c,k){return y.H.useInsertionEffect(c,k)},I.useLayoutEffect=function(c,k){return y.H.useLayoutEffect(c,k)},I.useMemo=function(c,k){return y.H.useMemo(c,k)},I.useOptimistic=function(c,k){return y.H.useOptimistic(c,k)},I.useReducer=function(c,k,_){return y.H.useReducer(c,k,_)},I.useRef=function(c){return y.H.useRef(c)},I.useState=function(c){return y.H.useState(c)},I.useSyncExternalStore=function(c,k,_){return y.H.useSyncExternalStore(c,k,_)},I.useTransition=function(){return y.H.useTransition()},I.version="19.2.7",I}var $e;function it(){return $e||($e=1,ve.exports=rt()),ve.exports}var r=it();const lt=st(r),Vs=tt({__proto__:null,default:lt},[r]),Ne={},ot=(Ne==null?void 0:Ne.VITE_COMPOSE_API_TOKEN)||"";let He=null;function se(e){He=e||null}function ce(){return He||ot||""}function V(e={}){const a=ce();return a?{...e,"x-compose-token":a}:e}const de="compose:mobile:accessToken",oe="compose:mobile:refreshToken",ye="compose:mobile:accessExpiry";let ie=null,pe=null;function ct(e){pe=e}async function dt(){const e=localStorage.getItem(de),a=parseInt(localStorage.getItem(ye)||"0",10);return e&&a>Date.now()+3e4?(ce()!==e&&se(e),e):Be()}async function Be(){if(ie)return ie;const e=localStorage.getItem(oe);if(!e)throw new Error("NoRefreshToken");return ie=fetch("/api/auth/refresh",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refresh_token:e})}).then(async a=>{if(!a.ok)throw localStorage.removeItem(de),localStorage.removeItem(oe),localStorage.removeItem(ye),se(localStorage.getItem("compose:mobile:sensitiveToken")||null),pe==null||pe("cockpit"),new Error("RefreshFailed");const s=await a.json();return localStorage.setItem(de,s.access_token),localStorage.setItem(oe,s.refresh_token),localStorage.setItem(ye,String(Date.now()+s.expires_in*1e3)),se(s.access_token),s.access_token}).finally(()=>{ie=null}),ie}let ke=null,ue="cockpit";ct(e=>{ue=e});function Qs(e){ke=e??null}function Je(e){ue=e}function Ce(){return ue}async function B(e,a={}){if(ue==="mobile-paired")try{await dt()}catch{}const s={...a.headers||{}};ke&&(s["X-Compose-Workspace-Id"]=ke);const n=ce();n&&(ue==="mobile-paired"?s.Authorization=`Bearer ${n}`:s["x-compose-token"]=n);let i=await fetch(e,{...a,headers:s});if(i.status===401){if((await i.clone().json().catch(()=>({}))).code==="TokenExpired"){try{await Be()}catch{throw window.location.href="/m/pair",new Error("NeedsPairing")}i=await fetch(e,{...a,headers:{...s,Authorization:`Bearer ${ce()}`}})}if(i.status===401){const o=await i.clone().json().catch(()=>({}));if(o.code==="TokenExpired"||o.code==="TokenInvalid")throw window.location.href="/m/pair",new Error("NeedsPairing")}}return i}let Te=!1;function Ye(e){Te=!0}function Zs(){return Te}function ut(){if(Ce()==="mobile-paired"){try{const e=localStorage.getItem(de);if(e)return e}catch{}return null}if(Te){const e=ce();if(e)return e}return null}function Ee(e){const a=ut();return a?`${e}?token=${encodeURIComponent(a)}`:e}function qe(e){return`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}${e}`}function fe(){return Ee(qe("/ws/vision"))}function ea(){return Ee(qe("/ws/files"))}function mt(e){return Ee(e)}function ft(e){return e?/iPad|iPhone|iPod/.test(e)?"iOS":/Android/.test(e)?"Android":/Mac/.test(e)?"macOS":/Win/.test(e)?"Windows":/Linux/.test(e)?"Linux":"Unknown":"Unknown"}function ht(e){return e?/Edg/.test(e)?"Edge":/CriOS|Chrome/.test(e)?"Chrome":/FxiOS|Firefox/.test(e)?"Firefox":/Safari/.test(e)?"Safari":"Browser":"Browser"}function pt(e){const a=String(e).indexOf("?");if(a===-1)return null;try{return new URLSearchParams(String(e).slice(a+1)).get("code")||null}catch{return null}}function bt(){const[e,a]=r.useState(()=>{try{return new URLSearchParams(window.location.search||"").get("code")||null}catch{return null}}),[s,n]=r.useState(()=>{const p=typeof navigator<"u"&&navigator.userAgent||"";return`${ft(p)} (${ht(p)})`}),[i,u]=r.useState(!1),[o,l]=r.useState(null),[d,g]=r.useState(""),m=r.useCallback(p=>{const h=p.target.value;g(h);const N=pt(h);N&&(a(N),l(null))},[]),f=r.useCallback(async p=>{if(p==null||p.preventDefault(),!!e){u(!0),l(null);try{const h=await fetch("/api/auth/pair/complete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:e,device_name:s})}),N=await h.json().catch(()=>({}));if(!h.ok){const C=(N==null?void 0:N.error)||`HTTP ${h.status}`;l(`Pairing failed: ${C}. On your desktop, run \`compose remote pair\` to generate a new code.`);return}localStorage.setItem(de,N.access_token),localStorage.setItem(oe,N.refresh_token),localStorage.setItem(ye,String(Date.now()+N.expires_in*1e3)),se(N.access_token),Je("mobile-paired"),Ye(!0),window.location.href="/m/agents"}catch(h){l(`Pairing failed: ${h.message}. On your desktop, run \`compose remote pair\` to generate a new code.`)}finally{u(!1)}}},[e,s]);return e?t.jsxs("div",{className:"m-root","data-testid":"mobile-pair-code-screen",children:[t.jsx("header",{className:"m-header",children:t.jsx("div",{className:"m-header-title",children:"Complete pairing"})}),t.jsxs("main",{className:"m-main m-pair-page",children:[t.jsx("p",{className:"m-pair-instructions",children:"Give this device a name so you can recognize it in the paired devices list."}),t.jsxs("form",{onSubmit:f,className:"m-pair-form",children:[t.jsxs("div",{className:"m-pair-field",children:[t.jsx("label",{htmlFor:"m-pair-device-name",className:"m-pair-label",children:"Device name"}),t.jsx("input",{id:"m-pair-device-name","data-testid":"mobile-pair-device-name-input",className:"m-pair-input",type:"text",value:s,onChange:p=>n(p.target.value),disabled:i,required:!0})]}),o&&t.jsx("p",{"data-testid":"mobile-pair-error",className:"m-pair-error",children:o}),t.jsx("button",{type:"submit","data-testid":"mobile-pair-submit-btn",className:"m-pair-btn",disabled:i||!s.trim(),children:i?"Pairing…":"Pair this device"})]})]})]}):t.jsxs("div",{className:"m-root","data-testid":"mobile-pair-codeless-screen",children:[t.jsx("header",{className:"m-header",children:t.jsx("div",{className:"m-header-title",children:"Pair this device"})}),t.jsxs("main",{className:"m-main m-pair-page",children:[t.jsxs("p",{"data-testid":"mobile-pair-codeless-instructions",className:"m-pair-instructions",children:["This device is no longer paired (or pairing has expired). On your desktop, run ",t.jsx("code",{children:"compose remote pair"})," or open Cockpit → Pair mobile, then scan the new QR code. If your camera is unavailable, paste the pairing URL below:"]}),t.jsxs("div",{className:"m-pair-field",children:[t.jsx("label",{htmlFor:"m-pair-url-input",className:"m-pair-label",children:"Pairing URL"}),t.jsx("input",{id:"m-pair-url-input","data-testid":"mobile-pair-url-input",className:"m-pair-input",type:"text",placeholder:"https://your-host/m/pair?code=...",value:d,onChange:m,autoComplete:"off"})]}),o&&t.jsx("p",{"data-testid":"mobile-pair-error",className:"m-pair-error",children:o})]})]})}const yt=[{id:"explore_design",name:"Explore Design",agent:"claude",phase:"design",hasGate:!1},{id:"design_review",name:"Design Review",agent:"codex",phase:"design",hasGate:!1},{id:"design_gate",name:"Design Gate",agent:"human",phase:"design",hasGate:!0},{id:"prd",name:"PRD",agent:"claude",phase:"design",hasGate:!1},{id:"prd_review",name:"PRD Review",agent:"codex",phase:"design",hasGate:!1},{id:"prd_gate",name:"PRD Gate",agent:"human",phase:"design",hasGate:!0},{id:"architecture",name:"Architecture",agent:"claude",phase:"design",hasGate:!1},{id:"architecture_review",name:"Arch Review",agent:"codex",phase:"design",hasGate:!1},{id:"architecture_gate",name:"Arch Gate",agent:"human",phase:"design",hasGate:!0},{id:"blueprint",name:"Blueprint",agent:"claude",phase:"blueprint",hasGate:!1},{id:"verification",name:"Verification",agent:"claude",phase:"blueprint",hasGate:!1},{id:"blueprint_review",name:"BP Review",agent:"codex",phase:"blueprint",hasGate:!1},{id:"plan",name:"Plan",agent:"claude",phase:"implementation",hasGate:!1},{id:"plan_review",name:"Plan Review",agent:"codex",phase:"implementation",hasGate:!1},{id:"plan_gate",name:"Plan Gate",agent:"human",phase:"implementation",hasGate:!0},{id:"execute",name:"Execute",agent:"claude",phase:"implementation",hasGate:!1},{id:"review",name:"Review Loop",agent:"codex",phase:"implementation",hasGate:!1},{id:"coverage",name:"Coverage Sweep",agent:"claude",phase:"implementation",hasGate:!1},{id:"report",name:"Report",agent:"claude",phase:"ship",hasGate:!1},{id:"report_review",name:"Report Review",agent:"codex",phase:"ship",hasGate:!1},{id:"report_gate",name:"Report Gate",agent:"human",phase:"ship",hasGate:!0},{id:"docs",name:"Docs",agent:"claude",phase:"ship",hasGate:!1},{id:"ship",name:"Ship",agent:"claude",phase:"ship",hasGate:!1},{id:"ship_gate",name:"Ship Gate",agent:"human",phase:"ship",hasGate:!0}],gt=new Set(["complete","completed","aborted","failed","killed","done"]);function me(e){return gt.has(e)}function xt(e,a,s){const n=Array.isArray(a)?Object.fromEntries(a.map(o=>[o.id,o.status])):{},i=Array.isArray(a)?Object.fromEntries(a.map(o=>[o.id,o])):{},u=e.map(o=>{const l=i[o.id],d=l?{...o,...l}:{...o};return d.id===s&&!n[d.id]&&(d.status="active"),d});if(Array.isArray(a))for(const o of a)e.find(l=>l.id===o.id)||u.push({id:o.id,name:o.id.replace(/_/g," "),agent:"claude",phase:"implementation",...o});return u}function jt(e,a,s){if(!e)return!1;const{featureCode:n,status:i,currentStepId:u}=e;if(i!=="running"||!u||!u.endsWith("_gate"))return!1;const o=Array.isArray(s)?s:[],l=o.find(d=>d.featureCode===n)||o.find(d=>d.title===n)||o.find(d=>d.title&&d.title.startsWith(n+":"));return l?(Array.isArray(a)?a:[]).some(d=>d.itemId===l.id&&!d.resolvedAt):!1}const vt=[{id:"agents",label:"Agents",icon:"◇"},{id:"roadmap",label:"Roadmap",icon:"⚡"},{id:"builds",label:"Builds",icon:"⏵"},{id:"ideas",label:"Ideas",icon:"✦"}];function Nt({active:e,onSelect:a,badges:s}){return t.jsx("nav",{className:"m-bottom-nav",role:"tablist","aria-label":"Mobile navigation",children:vt.map(n=>{const i=s==null?void 0:s[n.id];return t.jsxs("button",{type:"button",className:"m-nav-btn",role:"tab","aria-pressed":e===n.id?"true":"false","aria-label":n.label,"data-tab":n.id,"data-testid":`mobile-nav-${n.id}`,onClick:()=>a(n.id),children:[t.jsxs("span",{className:"m-nav-icon-wrap",children:[t.jsx("span",{className:"m-nav-icon","aria-hidden":"true",children:n.icon}),i&&t.jsx("span",{className:`m-nav-badge m-nav-badge-${i.level||"info"}`,"data-testid":`mobile-nav-badge-${n.id}`,"aria-hidden":"true",children:i.count!=null?String(i.count):""})]}),t.jsx("span",{className:"m-nav-label",children:n.label})]},n.id)})})}function he({url:e,onMessage:a,onOpen:s,onClose:n,onError:i,maxBackoffMs:u=3e4}){let o=null,l=0,d=!1,g=null;function m(h){return typeof h=="function"?h():h}function f(){if(!d){try{o=new WebSocket(m(e))}catch(h){i==null||i(h),p();return}o.onopen=()=>{l=0,s==null||s(o)},o.onmessage=h=>a==null?void 0:a(h),o.onclose=()=>{n==null||n(),p()},o.onerror=h=>{i==null||i(h)}}}function p(){if(d||g)return;const h=Math.min(u,1e3*Math.pow(2,l++));g=setTimeout(()=>{g=null,f()},h)}return f(),{get socket(){return o},isOpen(){return(o==null?void 0:o.readyState)===1},send(h){(o==null?void 0:o.readyState)===1&&o.send(h)},close(){if(d=!0,g&&(clearTimeout(g),g=null),o){try{o.onclose=null,o.onerror=null,o.close()}catch{}o=null}}}}async function wt(e,a={}){const s=await B(e,a);let n=null;try{n=await s.json()}catch{}if(!s.ok){const i=n&&n.error||`HTTP ${s.status}`;throw new Error(i)}return n}function St(){const[e,a]=r.useState([]),[s,n]=r.useState(!0),[i,u]=r.useState(null),o=r.useRef(!0),l=r.useCallback(async()=>{try{const d=await wt("/api/agents/tree");if(!o.current)return;a(Array.isArray(d==null?void 0:d.agents)?d.agents:[]),u(null)}catch(d){if(!o.current)return;u(d.message)}finally{o.current&&n(!1)}},[]);return r.useEffect(()=>(o.current=!0,l(),()=>{o.current=!1}),[l]),r.useEffect(()=>{if(typeof window>"u"||typeof WebSocket>"u")return;const d=he({url:()=>fe(),onMessage:g=>{try{const m=JSON.parse(g.data);if(!m||!m.type)return;(m.type==="agentSpawned"||m.type==="agentStopped"||m.type==="agentStatusChanged"||m.type==="agentTreeUpdated")&&l()}catch{}}});return()=>{try{d.close()}catch{}}},[l]),{agents:e,loading:s,error:i,refetch:l}}const we={};function Ke(e){if(typeof window>"u"||!window.location)return e;const a=typeof import.meta<"u"&&(we==null?void 0:we.VITE_AGENT_PORT)||"4002";return`${window.location.protocol}//${window.location.hostname}:${a}${e}`}const kt=5e3,Ct={"/api/agent/session":"/api/agent/proxy/session","/api/agent/message":"/api/agent/proxy/message","/api/agent/interrupt":"/api/agent/proxy/interrupt","/api/agent/session/status":"/api/agent/proxy/session/status"};function We(e){return Ce()==="mobile-paired"?Ct[e]||e:Ke(e)}async function Pe(e,a){const s=await B(We(e),{method:"POST",headers:V({"Content-Type":"application/json"}),body:JSON.stringify(a||{})});let n=null;try{n=await s.json()}catch{}if(!s.ok){const i=n&&n.error||`HTTP ${s.status}`;throw new Error(i)}return n}function Tt(){const[e,a]=r.useState(!1),[s,n]=r.useState(null),[i,u]=r.useState(!0),[o,l]=r.useState(null),[d,g]=r.useState(!1),m=r.useRef(!0),f=r.useCallback(async()=>{try{const C=await(await B(We("/api/agent/session/status"))).json().catch(()=>({}));if(!m.current)return;a(!!C.active),n(C.sessionId||null),l(null)}catch(N){if(!m.current)return;l(N.message)}finally{m.current&&u(!1)}},[]);r.useEffect(()=>{m.current=!0,f();const N=setInterval(f,kt);return()=>{m.current=!1,clearInterval(N)}},[f]);const p=r.useCallback(async N=>{const C=(N||"").trim();if(!C)throw new Error("message is empty");g(!0);try{const E=await Pe(s?"/api/agent/message":"/api/agent/session",{prompt:C});return f(),E}finally{g(!1)}},[s,f]),h=r.useCallback(async()=>Pe("/api/agent/interrupt",{}),[]);return{active:e,sessionId:s,loading:i,error:o,sending:d,sendMessage:p,interrupt:h,refresh:f}}function Et(e){if(!e)return"";const a=typeof e=="string"?Date.parse(e):Number(e);if(!a||Number.isNaN(a))return"";const s=Date.now()-a;return s<5e3?"just now":s<6e4?`${Math.floor(s/1e3)}s ago`:s<36e5?`${Math.floor(s/6e4)}m ago`:`${Math.floor(s/36e5)}h ago`}function At({agent:e,onOpen:a,onAfterKill:s}){const[n,i]=r.useState(!1),[u,o]=r.useState(null),l=e.agentId||e.id,d=e.status||"unknown",g=e.lastActivityAt||e.lastEventAt||e.startedAt||null,m=r.useCallback(async p=>{if(p==null||p.stopPropagation(),!!l){i(!0),o(null);try{const h=await B(`/api/agent/${encodeURIComponent(l)}/stop`,{method:"POST",headers:V({"Content-Type":"application/json"}),body:JSON.stringify({})});if(!h.ok){let N=null;try{N=await h.json()}catch{}throw new Error(N&&N.error||`HTTP ${h.status}`)}s==null||s(l)}catch(h){o(h.message)}finally{i(!1)}}},[l,s]),f=r.useCallback(()=>a==null?void 0:a(e),[a,e]);return t.jsxs("div",{className:"m-agent-card","data-testid":`mobile-agent-card-${l}`,role:"button",tabIndex:0,onClick:f,onKeyDown:p=>{p.key==="Enter"&&f()},children:[t.jsxs("div",{className:"m-agent-card-row",children:[t.jsx("div",{className:"m-agent-card-id",title:l,children:l||"(no id)"}),t.jsx("span",{className:"m-status-pill","data-status":d,children:d})]}),t.jsxs("div",{className:"m-agent-card-meta",children:[t.jsx("span",{className:"m-agent-card-time",children:Et(g)}),t.jsx("button",{type:"button",className:"m-btn m-btn-danger m-btn-sm","data-testid":`mobile-agent-kill-${l}`,disabled:n||d!=="running",onClick:m,children:n?"Killing…":"Kill"})]}),u&&t.jsx("div",{className:"m-agent-card-error",children:u})]})}const Rt=3e4,_t=5,$t=3e4;function Pt({url:e,onEvent:a,onOpen:s,onClose:n,onError:i,onRetry:u,onStall:o,onExhausted:l,namedEvents:d=["hydrate"],maxBackoffMs:g=Rt,maxRetries:m=_t,stallTimeoutMs:f=$t}){if(!e)throw new Error("createAgentStream: url is required");if(typeof EventSource>"u")return{close(){}};let p=null,h=!1,N=0,C=null,w=null;function E(){w&&clearTimeout(w),!h&&(w=setTimeout(()=>{o==null||o({elapsedMs:f})},f))}function v(){w&&(clearTimeout(w),w=null)}function T(b,y){if(E(),!!a)try{const S=JSON.parse(y);a(S,b)}catch{}}function x(){if(v(),h||C)return;if(N>=m){const y=new Error(`agent-stream: failed after ${m} retries`);i==null||i(y),h=!0;try{p==null||p.close()}catch{}p=null,n==null||n(),l==null||l();return}const b=Math.min(g,1e3*Math.pow(2,N));N+=1,u==null||u({attempt:N,maxRetries:m,nextBackoffMs:b}),C=setTimeout(()=>{C=null,j()},b)}function j(){if(!h){try{p=new EventSource(e)}catch(b){i==null||i(b),x();return}p.onopen=()=>{N=0,v(),s==null||s()},p.onmessage=b=>T("message",b.data);for(const b of d)p.addEventListener(b,y=>T(b,y.data));p.onerror=b=>{i==null||i(b instanceof Error?b:new Error("agent-stream error"));try{p==null||p.close()}catch{}p=null,n==null||n(),x()}}}return j(),{close(){h=!0,v(),C&&(clearTimeout(C),C=null);try{p==null||p.close()}catch{}p=null},reconnect(){h=!1,N=0,v(),C&&(clearTimeout(C),C=null);try{p==null||p.close()}catch{}p=null,j()}}}function It(){return typeof window>"u"||!window.location?"":Ce()==="mobile-paired"?mt("/api/agent/proxy/stream"):Ke("/api/agent/stream")}function Lt(e){return!e||typeof e!="object"?null:e.agentId||e.agent_id||e.id||null}function ze({url:e,agentId:a,max:s=500,enabled:n=!0}={}){const[i,u]=r.useState([]),[o,l]=r.useState(!1),d=r.useRef(null),g=r.useMemo(()=>e||It(),[e]);return r.useEffect(()=>{if(!n||!g)return;const f=Pt({url:g,onOpen:()=>l(!0),onClose:()=>l(!1),onEvent:p=>{u(h=>{const N=h.length>=s?h.slice(h.length-s+1):h.slice();return N.push(p),N})}});return d.current=f,()=>{try{f.close()}catch{}}},[g,n,s]),{events:r.useMemo(()=>a?i.filter(f=>Lt(f)===a):i,[i,a]),allEvents:i,connected:o}}function Ot(e,a){if(typeof e=="string")return e;if(e!=null&&e.type&&(e!=null&&e.message))return`[${e.type}] ${typeof e.message=="string"?e.message:JSON.stringify(e.message)}`;if(e!=null&&e.type)return`[${e.type}] ${JSON.stringify(e).slice(0,240)}`;try{return JSON.stringify(e)}catch{return`(unserializable #${a})`}}function Mt({agent:e,onClose:a}){const s=(e==null?void 0:e.agentId)||(e==null?void 0:e.id),{events:n}=ze({agentId:s}),i=r.useRef(null),[u,o]=r.useState(!1),[l,d]=r.useState(null);r.useEffect(()=>{var m;(m=i.current)==null||m.scrollIntoView({behavior:"smooth"})},[n.length]);const g=r.useCallback(async()=>{if(s){o(!0),d(null);try{const m=await B(`/api/agent/${encodeURIComponent(s)}/stop`,{method:"POST",headers:V({"Content-Type":"application/json"}),body:JSON.stringify({})});if(!m.ok){let f=null;try{f=await m.json()}catch{}throw new Error(f&&f.error||`HTTP ${m.status}`)}}catch(m){d(m.message)}finally{o(!1)}}},[s]);return e?t.jsxs("div",{className:"m-overlay","data-testid":"mobile-agent-detail",role:"dialog","aria-modal":"true",children:[t.jsxs("header",{className:"m-overlay-header",children:[t.jsxs("div",{className:"m-overlay-header-inner",children:[t.jsx("div",{className:"m-overlay-title",title:s,children:s}),t.jsx("span",{className:"m-status-pill","data-status":e.status,children:e.status||"unknown"})]}),t.jsxs("div",{className:"m-overlay-actions",children:[t.jsx("button",{type:"button",className:"m-btn m-btn-danger m-btn-sm",disabled:u,onClick:g,"data-testid":"mobile-agent-detail-kill",children:u?"Killing…":"Kill"}),t.jsx("button",{type:"button",className:"m-btn m-btn-sm",onClick:a,"data-testid":"mobile-agent-detail-close",children:"Close"})]})]}),t.jsxs("div",{className:"m-overlay-body m-agent-log",children:[n.length===0?t.jsx("div",{className:"m-empty",children:"No live events for this agent yet."}):n.map((m,f)=>t.jsx("div",{className:"m-agent-log-line",children:Ot(m,f)},f)),t.jsx("div",{ref:i})]}),l&&t.jsx("div",{className:"m-agent-card-error",children:l})]}):null}function Dt({session:e}){const{active:a,sessionId:s,sending:n,sendMessage:i}=e,[u,o]=r.useState(""),[l,d]=r.useState(null),g=r.useCallback(async m=>{if(m==null||m.preventDefault(),!!u.trim()){d(null);try{await i(u),o("")}catch(f){d(f.message)}}},[u,i]);return t.jsxs("div",{className:"m-session-card","data-testid":"mobile-interactive-session",children:[t.jsxs("div",{className:"m-session-card-row",children:[t.jsx("div",{className:"m-session-card-title",children:"Interactive session"}),t.jsx("span",{className:"m-status-pill","data-status":a?"in_progress":"planned",children:a?"active":"ready"})]}),t.jsx("div",{className:"m-session-card-id",children:s?`id: ${s}`:"No active session"}),t.jsxs("form",{className:"m-session-card-form",onSubmit:g,children:[t.jsx("input",{type:"text",className:"m-input",placeholder:a?"Message Claude…":"Start a new session…",value:u,onChange:m=>o(m.target.value),"data-testid":"mobile-interactive-session-input",disabled:n}),t.jsx("button",{type:"submit",className:"m-btn m-btn-primary m-btn-sm",disabled:n||!u.trim(),"data-testid":"mobile-interactive-session-send",children:n?"Sending…":"Send"})]}),l&&t.jsx("div",{className:"m-agent-card-error",children:l})]})}function Ut({gate:e,onOpen:a}){const s=e.id,n=e.flowId||e.flow||"",i=e.stepId||e.step||"",u=e.summary||e.comment||"",o=e.toPhase||e.fromPhase||"";return t.jsxs("div",{className:"m-gate-card","data-testid":`mobile-gate-card-${s}`,role:"button",tabIndex:0,onClick:()=>a==null?void 0:a(e),onKeyDown:l=>{l.key==="Enter"&&(a==null||a(e))},children:[t.jsxs("div",{className:"m-gate-card-row",children:[t.jsx("div",{className:"m-gate-card-title",children:n||s}),o&&t.jsx("span",{className:"m-status-pill","data-status":"in_progress",children:o})]}),t.jsx("div",{className:"m-gate-card-step",children:i}),u&&t.jsx("div",{className:"m-gate-card-summary",children:u})]})}const Ft=[{id:"approve",label:"Approve",kind:"primary"},{id:"revise",label:"Revise",kind:"warn"},{id:"kill",label:"Kill",kind:"danger"}];function Gt({gate:e,onResolve:a,onClose:s}){const[n,i]=r.useState(null),[u,o]=r.useState(""),[l,d]=r.useState(""),[g,m]=r.useState(!1),[f,p]=r.useState(null),h=r.useCallback(async N=>{if(N==null||N.preventDefault(),!n){p("Pick an outcome");return}if(n==="kill"&&!u.trim()){p("Reason is required when killing a gate");return}m(!0),p(null);try{await a(e.id,{outcome:n,reason:u.trim(),summary:l.trim()}),s==null||s()}catch(C){p(C.message)}finally{m(!1)}},[e,n,u,l,a,s]);return t.jsx("div",{className:"m-sheet-backdrop","data-testid":"mobile-gate-sheet",onClick:s,children:t.jsxs("div",{className:"m-sheet",role:"dialog","aria-modal":"true",onClick:N=>N.stopPropagation(),children:[t.jsxs("div",{className:"m-sheet-header",children:[t.jsx("div",{className:"m-sheet-title",children:"Resolve gate"}),t.jsxs("div",{className:"m-sheet-subtitle",children:[e.flowId,":",e.stepId]})]}),t.jsxs("form",{onSubmit:h,className:"m-sheet-body",children:[t.jsx("div",{className:"m-sheet-outcomes",role:"radiogroup","aria-label":"Outcome",children:Ft.map(N=>t.jsx("button",{type:"button",role:"radio","aria-checked":n===N.id,className:`m-btn m-btn-${N.kind} ${n===N.id?"m-btn-active":""}`,"data-testid":`mobile-gate-outcome-${N.id}`,onClick:()=>i(N.id),children:N.label},N.id))}),t.jsxs("label",{className:"m-field",children:[t.jsxs("span",{className:"m-field-label",children:["Reason ",n==="kill"?"(required)":"(optional)"]}),t.jsx("textarea",{className:"m-textarea","data-testid":"mobile-gate-reason",value:u,onChange:N=>o(N.target.value),rows:2})]}),t.jsxs("label",{className:"m-field",children:[t.jsx("span",{className:"m-field-label",children:"Summary (optional)"}),t.jsx("textarea",{className:"m-textarea","data-testid":"mobile-gate-summary",value:l,onChange:N=>d(N.target.value),rows:2})]}),f&&t.jsx("div",{className:"m-agent-card-error",children:f}),t.jsxs("div",{className:"m-sheet-actions",children:[t.jsx("button",{type:"button",className:"m-btn m-btn-sm",onClick:s,disabled:g,children:"Cancel"}),t.jsx("button",{type:"submit",className:"m-btn m-btn-primary m-btn-sm",disabled:g||!n,"data-testid":"mobile-gate-submit",children:g?"Submitting…":"Submit"})]})]})]})})}function Ht({gates:e=[],gatesLoading:a=!1,resolveGate:s}){const{agents:n,loading:i,refetch:u}=St(),o=Tt(),[l,d]=r.useState(null),[g,m]=r.useState(null),f=r.useCallback(()=>{u(),d(null)},[u]);return t.jsxs("section",{"data-testid":"mobile-tab-agents",className:"m-agents-tab",children:[t.jsxs("div",{className:"m-section","data-testid":"mobile-section-spawned",children:[t.jsx("h2",{className:"m-section-title",children:"Spawned agents"}),i?t.jsx("div",{className:"m-empty",children:"Loading agents…"}):n.length===0?t.jsx("div",{className:"m-empty",children:"No spawned agents."}):t.jsx("div",{className:"m-stack",children:n.map(p=>t.jsx(At,{agent:p,onOpen:d,onAfterKill:f},p.agentId||p.id))})]}),t.jsxs("div",{className:"m-section","data-testid":"mobile-section-session",children:[t.jsx("h2",{className:"m-section-title",children:"Interactive session"}),t.jsx(Dt,{session:o})]}),t.jsxs("div",{className:"m-section","data-testid":"mobile-section-gates",children:[t.jsx("h2",{className:"m-section-title",children:"Pending gates"}),a?t.jsx("div",{className:"m-empty",children:"Loading gates…"}):e.length===0?t.jsx("div",{className:"m-empty",children:"No pending gates."}):t.jsx("div",{className:"m-stack",children:e.map(p=>t.jsx(Ut,{gate:p,onOpen:m},p.id))})]}),l&&t.jsx(Mt,{agent:l,onClose:()=>d(null)}),g&&t.jsx(Gt,{gate:g,onResolve:s,onClose:()=>m(null)})]})}const Bt=[{value:"planned",label:"planned"},{value:"in_progress",label:"in progress"},{value:"blocked",label:"blocked"},{value:"complete",label:"complete"},{value:"parked",label:"parked"},{value:"killed",label:"killed"}];function Jt({statuses:e=[],onToggleStatus:a,group:s="",groupOptions:n=[],onChangeGroup:i,keyword:u="",onChangeKeyword:o}){return t.jsxs("div",{className:"m-filter-bar","data-testid":"mobile-filter-bar",children:[t.jsx("div",{className:"m-filter-chips",role:"group","aria-label":"Status filter",children:Bt.map(l=>{const d=e.includes(l.value);return t.jsx("button",{type:"button",className:"m-filter-chip","aria-pressed":d,"data-testid":`mobile-filter-status-${l.value}`,onClick:()=>a==null?void 0:a(l.value),children:l.label},l.value)})}),t.jsxs("div",{className:"m-filter-row",children:[t.jsxs("select",{className:"m-filter-select","data-testid":"mobile-filter-group",value:s,onChange:l=>i==null?void 0:i(l.target.value),"aria-label":"Group filter",children:[t.jsx("option",{value:"",children:"All groups"}),n.map(l=>t.jsx("option",{value:l,children:l},l))]}),t.jsx("input",{type:"search",className:"m-filter-keyword","data-testid":"mobile-filter-keyword",placeholder:"Search title or description",value:u,onChange:l=>o==null?void 0:o(l.target.value),"aria-label":"Keyword filter"})]})]})}const Yt=new Set(["planned","in_progress","blocked","complete","partial","superseded","parked"]);function Xe({status:e,children:a}){const s=typeof e=="string"?e.toLowerCase():"",n=Yt.has(s)?s:"unknown",i=a??e??"unknown";return t.jsx("span",{className:"m-status-pill","data-status":n,children:i})}function qt(e,a=140){if(typeof e!="string")return"";const s=e.trim();return s.length<=a?s:s.slice(0,a-1).trimEnd()+"…"}function Kt({item:e,onSelect:a}){if(!e)return null;const s=e.title||e.id||"Untitled",n=e.status||"unknown",i=e.group||"",u=qt(e.description||"");return t.jsxs("button",{type:"button",className:"m-item-card","data-testid":`mobile-item-card-${e.id}`,onClick:()=>a==null?void 0:a(e),children:[t.jsxs("div",{className:"m-item-card-row",children:[t.jsx("div",{className:"m-item-card-title",children:s}),t.jsx(Xe,{status:n})]}),t.jsxs("div",{className:"m-item-card-meta",children:[i?t.jsx("span",{className:"m-item-card-group","data-testid":"mobile-item-group",children:i}):null,e.id?t.jsx("span",{className:"m-item-card-id",children:e.id}):null]}),u?t.jsx("div",{className:"m-item-card-desc",children:u}):null]})}const Wt=["planned","ready","in_progress","review","complete","blocked","parked","killed","superseded"],zt=["informs","blocks","supports","contradicts","implements"];function Xt({item:e,onClose:a,onSave:s,onDelete:n,allItems:i=[],addConnection:u,removeConnection:o,fetchItemDetail:l}){const d=r.useMemo(()=>({status:(e==null?void 0:e.status)||"planned",group:(e==null?void 0:e.group)||"",confidence:(e==null?void 0:e.confidence)??""}),[e]),[g,m]=r.useState(d.status),[f,p]=r.useState(d.group),[h,N]=r.useState(d.confidence),[C,w]=r.useState(!1),[E,v]=r.useState(!1),[T,x]=r.useState(!1),j=r.useRef(null),[b,y]=r.useState([]),[S,A]=r.useState(!1),[M,P]=r.useState(!1),[O,L]=r.useState(""),[F,Y]=r.useState("informs"),[q,z]=r.useState(!1),[ae,Q]=r.useState(null),K=r.useRef(null);if(r.useEffect(()=>{m(d.status),p(d.group),N(d.confidence),v(!1),y([]),P(!1),L(""),Y("informs"),Q(null),j.current&&clearTimeout(j.current),K.current&&clearTimeout(K.current)},[e==null?void 0:e.id,d.status,d.group,d.confidence]),r.useEffect(()=>{!(e!=null&&e.id)||!l||(A(!0),l(e.id).then(R=>{var H;R!=null&&R.ok&&Array.isArray((H=R.item)==null?void 0:H.connections)&&y(R.item.connections)}).finally(()=>A(!1)))},[e==null?void 0:e.id,l]),r.useEffect(()=>()=>{j.current&&clearTimeout(j.current),K.current&&clearTimeout(K.current)},[]),!e)return null;const c=g!==d.status||f!==d.group||String(h)!==String(d.confidence);function k(){v(!1),j.current&&clearTimeout(j.current)}function _(){E&&k(),ae!==null&&(Q(null),K.current&&clearTimeout(K.current))}const $=async()=>{if(!c||C)return;const R={};if(g!==d.status&&(R.status=g),f!==d.group&&(R.group=f),String(h)!==String(d.confidence)){const H=h===""?null:Number(h);H!==null&&Number.isFinite(H)?R.confidence=H:h===""&&(R.confidence=null)}w(!0);try{await(s==null?void 0:s(e.id,R))}finally{w(!1)}},D=async()=>{if(!E)v(!0),j.current=setTimeout(()=>{v(!1)},3e3);else{j.current&&clearTimeout(j.current),v(!1),x(!0);try{await(n==null?void 0:n(e.id))}finally{x(!1)}}},U=r.useMemo(()=>{const R=O.toLowerCase();return i.filter(H=>H.id===e.id?!1:R?H.id.toLowerCase().includes(R)||(H.title||"").toLowerCase().includes(R):!0)},[i,e==null?void 0:e.id,O]),G=async R=>{z(!0);const H=await(u==null?void 0:u({fromId:e.id,toId:R.id,type:F}));if(H!=null&&H.ok){const X=H.connection||{id:`local-${Date.now()}`,fromId:e.id,toId:R.id,type:F};y(ne=>[...ne,X]),P(!1),L(""),Y("informs")}z(!1)},W=async(R,H)=>{if(ae!==H)K.current&&clearTimeout(K.current),Q(H),K.current=setTimeout(()=>{Q(null)},3e3);else{K.current&&clearTimeout(K.current),Q(null);const X=await(o==null?void 0:o(R.id));X!=null&&X.ok&&y(ne=>ne.filter(ge=>ge.id!==R.id))}};function J(R){const H=i.find(X=>X.id===R);return(H==null?void 0:H.title)||R}return t.jsx("div",{className:"m-sheet-overlay",role:"dialog","aria-modal":"true","data-testid":"mobile-item-sheet",children:t.jsxs("div",{className:"m-sheet",children:[t.jsxs("header",{className:"m-sheet-header",children:[t.jsx("button",{type:"button",className:"m-sheet-close",onClick:a,"data-testid":"mobile-item-sheet-close","aria-label":"Close",children:"×"}),t.jsxs("div",{className:"m-sheet-title-row",children:[t.jsx("div",{className:"m-sheet-title",children:e.title||e.id}),t.jsx(Xe,{status:g})]})]}),t.jsxs("div",{className:"m-sheet-body",children:[e.description?t.jsxs("section",{className:"m-sheet-section",children:[t.jsx("div",{className:"m-sheet-label",children:"Description"}),t.jsx("p",{className:"m-sheet-desc",children:e.description})]}):null,t.jsxs("section",{className:"m-sheet-section",children:[t.jsx("label",{className:"m-sheet-label",htmlFor:"m-sheet-status",children:"Status"}),t.jsx("select",{id:"m-sheet-status",className:"m-sheet-input","data-testid":"mobile-item-sheet-status",value:g,onChange:R=>{_(),m(R.target.value)},children:Wt.map(R=>t.jsx("option",{value:R,children:R},R))})]}),t.jsxs("section",{className:"m-sheet-section",children:[t.jsx("label",{className:"m-sheet-label",htmlFor:"m-sheet-group",children:"Group"}),t.jsx("input",{id:"m-sheet-group",type:"text",className:"m-sheet-input","data-testid":"mobile-item-sheet-group",value:f,onChange:R=>{_(),p(R.target.value)}})]}),t.jsxs("section",{className:"m-sheet-section",children:[t.jsx("label",{className:"m-sheet-label",htmlFor:"m-sheet-confidence",children:"Confidence (0–4)"}),t.jsx("input",{id:"m-sheet-confidence",type:"number",min:"0",max:"4",step:"1",className:"m-sheet-input","data-testid":"mobile-item-sheet-confidence",value:h,onChange:R=>{_(),N(R.target.value)}})]}),t.jsxs("section",{className:"m-sheet-section m-sheet-connections",children:[t.jsxs("div",{className:"m-sheet-connections-header",children:[t.jsx("span",{className:"m-sheet-label",children:"Connections"}),!M&&t.jsx("button",{type:"button",className:"m-conn-add-btn","data-testid":"mobile-item-conn-add",onClick:()=>{_(),P(!0)},children:"+ Add"})]}),S?t.jsx("div",{className:"m-conn-loading",children:"Loading…"}):b.length===0&&!M?t.jsx("div",{className:"m-conn-empty",children:"No connections"}):t.jsx("ul",{className:"m-conn-list",children:b.map((R,H)=>{const X=R.fromId===e.id,ne=X?R.toId:R.fromId,ge=J(ne),xe=ae===H;return t.jsxs("li",{className:"m-conn-row",children:[t.jsx("span",{className:"m-conn-dir",children:X?"→":"←"}),t.jsx("span",{className:"m-conn-title",children:ge}),t.jsx("span",{className:"m-conn-type",children:R.type}),t.jsx("button",{type:"button",className:`m-conn-remove${xe?" m-conn-remove--armed":""}`,"data-testid":`mobile-item-conn-remove-${H}`,"aria-label":xe?"Confirm remove connection":"Remove connection",onClick:()=>{_(),W(R,H)},children:xe?"✓":"×"})]},R.id)})}),M&&t.jsxs("div",{className:"m-conn-picker",children:[t.jsxs("div",{className:"m-conn-picker-row",children:[t.jsx("input",{type:"text",className:"m-sheet-input m-conn-search",placeholder:"Search items…",value:O,onChange:R=>L(R.target.value),"data-testid":"mobile-item-conn-search",autoFocus:!0}),t.jsx("select",{className:"m-sheet-input m-conn-type-select",value:F,onChange:R=>Y(R.target.value),"data-testid":"mobile-item-conn-type",children:zt.map(R=>t.jsx("option",{value:R,children:R},R))})]}),t.jsxs("ul",{className:"m-conn-picker-list",children:[U.map(R=>t.jsx("li",{children:t.jsxs("button",{type:"button",className:"m-conn-picker-item",disabled:q,onClick:()=>G(R),"data-testid":`mobile-item-conn-pick-${R.id}`,children:[t.jsx("span",{className:"m-conn-picker-title",children:R.title||R.id}),t.jsx("span",{className:"m-conn-picker-id",children:R.id})]})},R.id)),U.length===0&&t.jsx("li",{className:"m-conn-picker-empty",children:"No items found"})]}),t.jsx("button",{type:"button",className:"m-sheet-btn m-sheet-btn-secondary",onClick:()=>{P(!1),L(""),Y("informs")},children:"Cancel"})]})]})]}),t.jsxs("footer",{className:"m-sheet-footer",children:[t.jsx("button",{type:"button",className:`m-sheet-btn m-sheet-btn-danger${E?" m-sheet-btn-danger--armed":""}`,onClick:D,disabled:T,"data-testid":"mobile-item-sheet-delete",children:T?"Deleting…":E?"Confirm delete":"Delete"}),t.jsxs("div",{className:"m-sheet-footer-right",children:[t.jsx("button",{type:"button",className:"m-sheet-btn m-sheet-btn-secondary",onClick:a,"data-testid":"mobile-item-sheet-cancel",children:"Cancel"}),t.jsx("button",{type:"button",className:"m-sheet-btn m-sheet-btn-primary",onClick:$,disabled:!c||C,"data-testid":"mobile-item-sheet-save",children:C?"Saving…":"Save"})]})]})]})})}const Vt=["planned","ready","in_progress","review","complete","blocked","parked","killed","superseded"];function Qt({open:e,onClose:a,onCreate:s,groupOptions:n=[]}){const[i,u]=r.useState(""),[o,l]=r.useState(""),[d,g]=r.useState(""),[m,f]=r.useState("planned"),[p,h]=r.useState(""),[N,C]=r.useState(!1),[w,E]=r.useState(null),v=r.useId();if(!e)return null;function T(){u(""),l(""),g(""),f("planned"),h(""),E(null),C(!1)}function x(){T(),a==null||a()}async function j(b){if(b.preventDefault(),!i.trim()){E("Title is required");return}C(!0),E(null);try{const y={title:i.trim()};if(o.trim()&&(y.description=o.trim()),d.trim()&&(y.group=d.trim()),m&&(y.status=m),p!==""){const S=Number(p);Number.isFinite(S)&&(y.confidence=S)}await(s==null?void 0:s(y)),x()}catch(y){E(y.message||"Failed to create item"),C(!1)}}return t.jsx("div",{className:"m-sheet-overlay","data-testid":"mobile-create-sheet",role:"dialog","aria-modal":"true","aria-label":"Create roadmap item",onClick:b=>{b.target===b.currentTarget&&x()},children:t.jsxs("div",{className:"m-sheet",children:[t.jsxs("header",{className:"m-sheet-header",children:[t.jsx("button",{type:"button",className:"m-sheet-close","aria-label":"Close",onClick:x,disabled:N,children:"×"}),t.jsx("div",{className:"m-sheet-title-row",children:t.jsx("div",{className:"m-sheet-title",children:"New roadmap item"})})]}),t.jsxs("form",{className:"m-sheet-body",onSubmit:j,children:[t.jsxs("div",{className:"m-sheet-section",children:[t.jsx("label",{className:"m-sheet-label",htmlFor:"m-create-title",children:"Title"}),t.jsx("input",{id:"m-create-title",type:"text",className:"m-sheet-input",value:i,onChange:b=>u(b.target.value),placeholder:"Feature title","data-testid":"mobile-create-title",autoFocus:!0,required:!0})]}),t.jsxs("div",{className:"m-sheet-section",children:[t.jsx("label",{className:"m-sheet-label",htmlFor:"m-create-desc",children:"Description (optional)"}),t.jsx("textarea",{id:"m-create-desc",className:"m-sheet-input m-textarea",value:o,onChange:b=>l(b.target.value),rows:3,"data-testid":"mobile-create-desc"})]}),t.jsxs("div",{className:"m-sheet-section",children:[t.jsx("label",{className:"m-sheet-label",htmlFor:"m-create-group",children:"Group (optional)"}),t.jsx("input",{id:"m-create-group",type:"text",className:"m-sheet-input",value:d,onChange:b=>g(b.target.value),list:v,placeholder:"e.g. core, infra","data-testid":"mobile-create-group"}),t.jsx("datalist",{id:v,children:n.map(b=>t.jsx("option",{value:b},b))})]}),t.jsxs("div",{className:"m-sheet-section",children:[t.jsx("label",{className:"m-sheet-label",htmlFor:"m-create-status",children:"Status"}),t.jsx("select",{id:"m-create-status",className:"m-sheet-input",value:m,onChange:b=>f(b.target.value),"data-testid":"mobile-create-status",children:Vt.map(b=>t.jsx("option",{value:b,children:b},b))})]}),t.jsxs("div",{className:"m-sheet-section",children:[t.jsx("label",{className:"m-sheet-label",htmlFor:"m-create-confidence",children:"Confidence (0–4, optional)"}),t.jsx("input",{id:"m-create-confidence",type:"number",min:"0",max:"4",step:"1",className:"m-sheet-input",value:p,onChange:b=>h(b.target.value),"data-testid":"mobile-create-confidence"})]}),w?t.jsx("div",{className:"m-form-error",role:"alert","data-testid":"mobile-create-error",children:w}):null]}),t.jsxs("footer",{className:"m-sheet-footer",children:[t.jsx("button",{type:"button",className:"m-sheet-btn m-sheet-btn-secondary",onClick:x,disabled:N,"data-testid":"mobile-create-cancel",children:"Cancel"}),t.jsx("div",{className:"m-sheet-footer-right",children:t.jsx("button",{type:"button",className:"m-sheet-btn m-sheet-btn-primary",disabled:N||!i.trim(),"data-testid":"mobile-create-submit",onClick:j,children:N?"Creating…":"Create"})})]})]})})}function Ve({message:e,kind:a="error",durationMs:s=3e3,onDismiss:n}){return r.useEffect(()=>{if(!e)return;const i=setTimeout(()=>n==null?void 0:n(),s);return()=>clearTimeout(i)},[e,s,n]),e?t.jsx("div",{className:"m-toast",role:"status","data-kind":a,"data-testid":"mobile-toast",children:e}):null}function Zt(e){const a=new Set;for(const s of e){const n=((s==null?void 0:s.group)||"").trim();n&&a.add(n)}return Array.from(a).sort()}function es(e,a){if(!a)return!0;const s=a.toLowerCase(),n=(e.title||"").toLowerCase(),i=(e.description||"").toLowerCase();return n.includes(s)||i.includes(s)}function ts({items:e=[],loading:a=!1,error:s=null,applyOptimisticEdit:n,createItem:i,deleteItem:u,addConnection:o,removeConnection:l,fetchItemDetail:d}){const[g,m]=r.useState([]),[f,p]=r.useState(""),[h,N]=r.useState(""),[C,w]=r.useState(null),[E,v]=r.useState(!1),[T,x]=r.useState(null),j=r.useMemo(()=>Zt(e),[e]),b=r.useMemo(()=>e.filter(O=>!(g.length&&!g.includes(O.status)||f&&O.group!==f||!es(O,h))),[e,g,f,h]),y=r.useMemo(()=>e.find(O=>O.id===C)||null,[e,C]),S=O=>{m(L=>L.includes(O)?L.filter(F=>F!==O):[...L,O])},A=async(O,L)=>{const F=await n(O,L);F!=null&&F.ok?w(null):x((F==null?void 0:F.error)||"Save failed")},M=async O=>{const L=await(i==null?void 0:i(O));if(!(L!=null&&L.ok))throw new Error((L==null?void 0:L.error)||"Create failed")},P=async O=>{const L=await(u==null?void 0:u(O));L!=null&&L.ok?w(null):x((L==null?void 0:L.error)||"Delete failed")};return t.jsxs("section",{className:"m-roadmap","data-testid":"mobile-tab-roadmap",children:[t.jsx(Jt,{statuses:g,onToggleStatus:S,group:f,groupOptions:j,onChangeGroup:p,keyword:h,onChangeKeyword:N}),s?t.jsx("div",{className:"m-roadmap-error","data-testid":"mobile-roadmap-error",children:s}):null,a?t.jsx("div",{className:"m-roadmap-skeleton","data-testid":"mobile-roadmap-loading",children:Array.from({length:4}).map((O,L)=>t.jsx("div",{className:"m-skel-card"},L))}):b.length===0?t.jsx("div",{className:"m-roadmap-empty","data-testid":"mobile-roadmap-empty",children:e.length===0?"No roadmap items yet.":"No items match the current filters."}):t.jsx("ul",{className:"m-roadmap-list","data-testid":"mobile-roadmap-list",children:b.map(O=>t.jsx("li",{children:t.jsx(Kt,{item:O,onSelect:L=>w(L.id)})},O.id))}),y?t.jsx(Xt,{item:y,onClose:()=>w(null),onSave:A,onDelete:P,allItems:e,addConnection:o,removeConnection:l,fetchItemDetail:d}):null,t.jsx(Qt,{open:E,onClose:()=>v(!1),onCreate:M,groupOptions:j}),t.jsx("button",{type:"button",className:"m-fab","data-testid":"mobile-roadmap-fab","aria-label":"Create new roadmap item",onClick:()=>v(!0),children:"+"}),t.jsx(Ve,{message:T,onDismiss:()=>x(null)})]})}const Z="—";async function le(e,a={}){const s=await B(e,a);let n=null;try{n=await s.json()}catch{}if(!s.ok){const i=n&&n.error||`HTTP ${s.status}`;throw new Error(i)}return n}function ss(){const[e,a]=r.useState([]),[s,n]=r.useState([]),[i,u]=r.useState(!0),[o,l]=r.useState(null),[d,g]=r.useState([]),m=r.useRef(e);m.current=e;const f=r.useCallback((v,T)=>{const x=`t_${Date.now()}_${Math.random().toString(36).slice(2,6)}`;g(j=>[...j,{id:x,kind:v,message:T}]),setTimeout(()=>{g(j=>j.filter(b=>b.id!==x))},3500)},[]),p=r.useCallback(v=>{g(T=>T.filter(x=>x.id!==v))},[]),h=r.useCallback(async()=>{try{const v=await le("/api/ideabox");a(Array.isArray(v==null?void 0:v.ideas)?v.ideas:[]),n(Array.isArray(v==null?void 0:v.killed)?v.killed:[]),l(null)}catch(v){l(v.message),f("error",`Failed to load ideas: ${v.message}`)}finally{u(!1)}},[f]);r.useEffect(()=>{let v=!0;return(async()=>v&&await h())(),()=>{v=!1}},[h]),r.useEffect(()=>{if(typeof window>"u"||typeof WebSocket>"u")return;const v=he({url:()=>fe(),onMessage:T=>{try{const x=JSON.parse(T.data);x&&x.type==="ideaboxUpdated"&&h()}catch{}}});return()=>{try{v.close()}catch{}}},[h]);const N=r.useCallback(async({title:v,description:T,source:x,tags:j,cluster:b})=>{if(!v||!v.trim()){const A=new Error("title is required");throw f("error",A.message),A}const y=`tmp_${Date.now()}`,S={id:y,num:0,title:v.trim(),description:T||"",source:x||"",tags:Array.isArray(j)?j:[],cluster:b||null,status:"NEW",priority:Z,_pending:!0};a(A=>[S,...A]);try{const A=await le("/api/ideabox/ideas",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:v.trim(),description:T,source:x,tags:j,cluster:b})});return a(M=>M.map(P=>P.id===y?{...A}:P)),f("ok","Idea captured"),A}catch(A){throw a(M=>M.filter(P=>P.id!==y)),f("error",`Capture failed: ${A.message}`),A}},[f]),C=r.useCallback(async(v,{featureCode:T}={})=>{const x=m.current;a(j=>j.map(b=>b.id===v?{...b,_promoting:!0}:b));try{const j=await le(`/api/ideabox/ideas/${encodeURIComponent(v)}/promote`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({featureCode:T||""})});return f("ok",`Promoted${j!=null&&j.featureCode?` → ${j.featureCode}`:""}`),h(),j}catch(j){throw a(x),f("error",`Promote failed: ${j.message}`),j}},[f,h]),w=r.useCallback(async(v,{reason:T}={})=>{const x=m.current,j=x.find(b=>b.id===v);a(b=>b.filter(y=>y.id!==v)),j&&n(b=>[{...j,status:"KILLED",reason:T||""},...b]);try{const b=await le(`/api/ideabox/ideas/${encodeURIComponent(v)}/kill`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({reason:T||""})});return f("ok","Idea killed"),h(),b}catch(b){throw a(x),n(y=>y.filter(S=>S.id!==v||S.status!=="KILLED")),f("error",`Kill failed: ${b.message}`),b}},[f,h]),E=r.useCallback(async(v,T)=>{if(!["P0","P1","P2",Z].includes(T)){const b=new Error(`Invalid priority: ${T}`);throw f("error",b.message),b}const j=m.current;a(b=>b.map(y=>y.id===v?{...y,priority:T}:y));try{const b=await le(`/api/ideabox/ideas/${encodeURIComponent(v)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({priority:T})});return f("ok",`Priority → ${T===Z?"Untriaged":T}`),b}catch(b){throw a(j),f("error",`Set priority failed: ${b.message}`),b}},[f]);return{ideas:e,killed:s,loading:i,error:o,toasts:d,dismissToast:p,refetch:h,createIdea:N,promote:C,kill:w,setPriority:E}}function as(e,a={}){const{onSwipeLeft:s,onSwipeRight:n,onDrag:i,onDragEnd:u,threshold:o=80,axis:l="x"}=a,d=r.useRef({onSwipeLeft:s,onSwipeRight:n,onDrag:i,onDragEnd:u});d.current={onSwipeLeft:s,onSwipeRight:n,onDrag:i,onDragEnd:u},r.useEffect(()=>{const g=e&&e.current;if(!g)return;let m=0,f=0,p=null,h=!1,N=0;function C(v){if(!(v.button!==void 0&&v.button!==0)){p=v.pointerId,m=v.clientX,f=v.clientY,h=!0,N=0;try{g.setPointerCapture(v.pointerId)}catch{}}}function w(v){var j,b,y,S;if(!h||v.pointerId!==p)return;const T=v.clientX-m,x=v.clientY-f;if(l==="x"&&Math.abs(x)>Math.abs(T)&&Math.abs(x)>12){h=!1,(b=(j=d.current).onDragEnd)==null||b.call(j,0,!1);return}N=T,(S=(y=d.current).onDrag)==null||S.call(y,T)}function E(v){var j,b,y,S,A,M;if(!h||v&&v.pointerId!==p)return;const T=N;h=!1;try{g.releasePointerCapture(p)}catch{}p=null;let x=!1;T<=-o?((b=(j=d.current).onSwipeLeft)==null||b.call(j),x=!0):T>=o&&((S=(y=d.current).onSwipeRight)==null||S.call(y),x=!0),(M=(A=d.current).onDragEnd)==null||M.call(A,T,x)}return g.addEventListener("pointerdown",C),g.addEventListener("pointermove",w),g.addEventListener("pointerup",E),g.addEventListener("pointercancel",E),()=>{g.removeEventListener("pointerdown",C),g.removeEventListener("pointermove",w),g.removeEventListener("pointerup",E),g.removeEventListener("pointercancel",E)}},[e,o,l])}function ns(e){return e==="P0"||e==="P1"||e==="P2"?e.toLowerCase():"untriaged"}function rs(e){return e==="P0"||e==="P1"||e==="P2"?e:"Untriaged"}function is({idea:e,onTap:a,onSwipeLeft:s,onSwipeRight:n}){const i=r.useRef(null),[u,o]=r.useState(0),[l,d]=r.useState(null),g=r.useCallback(h=>{o(h),h<=-40?d("kill"):h>=40?d("promote"):d(null)},[]),m=r.useCallback(()=>{o(0),d(null)},[]);as(i,{onSwipeLeft:()=>s==null?void 0:s(e),onSwipeRight:()=>n==null?void 0:n(e),onDrag:g,onDragEnd:m,threshold:80});const f=ns(e.priority),p=Array.isArray(e.tags)?e.tags:[];return t.jsxs("div",{className:"m-idea-row","data-testid":`idea-row-${e.id}`,children:[t.jsx("div",{className:"m-idea-action m-idea-action-left","aria-hidden":"true",children:"Promote"}),t.jsx("div",{className:"m-idea-action m-idea-action-right","aria-hidden":"true",children:"Kill"}),t.jsxs("article",{ref:i,className:`m-idea-card${l?` is-intent-${l}`:""}`,"data-testid":"idea-card","data-idea-id":e.id,"data-priority":f,style:{transform:`translateX(${u}px)`},role:"button",tabIndex:0,onClick:()=>{Math.abs(u)<4&&(a==null||a(e))},onKeyDown:h=>{(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),a==null||a(e))},children:[t.jsxs("div",{className:"m-idea-head",children:[t.jsx("span",{className:"m-priority-badge","data-priority":f,"data-testid":`priority-badge-${e.id}`,children:rs(e.priority)}),e.cluster?t.jsx("span",{className:"m-idea-cluster",title:e.cluster,children:e.cluster}):null]}),t.jsx("h3",{className:"m-idea-title","data-testid":`idea-title-${e.id}`,children:e.title}),p.length>0?t.jsx("div",{className:"m-idea-tags",children:p.map(h=>t.jsx("span",{className:"m-idea-tag",children:h},h))}):null]})]})}function ls({open:e,onClose:a,onSubmit:s,existingClusters:n=[]}){const[i,u]=r.useState(""),[o,l]=r.useState(""),[d,g]=r.useState(""),[m,f]=r.useState([]),[p,h]=r.useState(""),[N,C]=r.useState(!1),[w,E]=r.useState(null),v=r.useId(),T=r.useMemo(()=>{const S=new Set;for(const A of n)A&&typeof A=="string"&&S.add(A);return[...S].sort()},[n]);if(!e)return null;function x(){u(""),l(""),g(""),f([]),h(""),E(null),C(!1)}function j(){x(),a==null||a()}function b(){const S=d.trim();S&&(m.includes(S)||f([...m,S]),g(""))}async function y(S){if(S.preventDefault(),!i.trim()){E("Title is required");return}C(!0),E(null);try{await(s==null?void 0:s({title:i.trim(),description:o.trim()||void 0,tags:m.length?m:void 0,cluster:p.trim()||void 0})),j()}catch(A){E(A.message||"Failed to capture"),C(!1)}}return t.jsx("div",{className:"m-sheet-overlay","data-testid":"capture-sheet",role:"dialog","aria-modal":"true","aria-label":"Capture idea",onClick:S=>{S.target===S.currentTarget&&j()},children:t.jsxs("div",{className:"m-sheet",children:[t.jsxs("header",{className:"m-sheet-header",children:[t.jsx("button",{type:"button",className:"m-sheet-close","aria-label":"Close capture",onClick:j,disabled:N,children:"×"}),t.jsx("div",{className:"m-sheet-title-row",children:t.jsx("div",{className:"m-sheet-title",children:"Capture idea"})})]}),t.jsxs("form",{className:"m-sheet-body",onSubmit:y,children:[t.jsxs("div",{className:"m-sheet-section",children:[t.jsx("label",{className:"m-sheet-label",htmlFor:"m-capture-title",children:"Title"}),t.jsx("input",{id:"m-capture-title",type:"text",className:"m-sheet-input",value:i,onChange:S=>u(S.target.value),placeholder:"What's the idea?","data-testid":"capture-title",autoFocus:!0,required:!0})]}),t.jsxs("div",{className:"m-sheet-section",children:[t.jsx("label",{className:"m-sheet-label",htmlFor:"m-capture-desc",children:"Description (optional)"}),t.jsx("textarea",{id:"m-capture-desc",className:"m-sheet-input m-textarea",value:o,onChange:S=>l(S.target.value),rows:4,"data-testid":"capture-description"})]}),t.jsxs("div",{className:"m-sheet-section",children:[t.jsx("label",{className:"m-sheet-label",htmlFor:"m-capture-tag",children:"Tags (optional)"}),t.jsxs("div",{className:"m-tag-input-row",children:[t.jsx("input",{id:"m-capture-tag",type:"text",className:"m-sheet-input",value:d,onChange:S=>g(S.target.value),onKeyDown:S=>{(S.key==="Enter"||S.key===",")&&(S.preventDefault(),b())},placeholder:"Add tag and press Enter","data-testid":"capture-tag-input"}),t.jsx("button",{type:"button",className:"m-sheet-btn m-sheet-btn-secondary m-tag-add",onClick:b,children:"Add"})]}),m.length>0?t.jsx("div",{className:"m-idea-tags","data-testid":"capture-tags",children:m.map(S=>t.jsxs("span",{className:"m-idea-tag",children:[S,t.jsx("button",{type:"button",className:"m-tag-remove","aria-label":`Remove tag ${S}`,onClick:()=>f(m.filter(A=>A!==S)),children:"×"})]},S))}):null]}),t.jsxs("div",{className:"m-sheet-section",children:[t.jsx("label",{className:"m-sheet-label",htmlFor:"m-capture-cluster",children:"Cluster (optional)"}),t.jsx("input",{id:"m-capture-cluster",type:"text",className:"m-sheet-input",value:p,onChange:S=>h(S.target.value),list:v,placeholder:"Group into a theme","data-testid":"capture-cluster"}),t.jsx("datalist",{id:v,children:T.map(S=>t.jsx("option",{value:S},S))})]}),w?t.jsx("div",{className:"m-form-error",role:"alert",children:w}):null]}),t.jsxs("footer",{className:"m-sheet-footer",children:[t.jsx("button",{type:"button",className:"m-sheet-btn m-sheet-btn-secondary",onClick:j,disabled:N,"data-testid":"capture-cancel",children:"Cancel"}),t.jsx("button",{type:"button",className:"m-sheet-btn m-sheet-btn-primary",disabled:N||!i.trim(),"data-testid":"capture-submit",onClick:y,children:N?"Saving…":"Capture"})]})]})})}const os=[{value:"P0",label:"P0"},{value:"P1",label:"P1"},{value:"P2",label:"P2"},{value:Z,label:"Untriaged"}];function cs({value:e,onChange:a,disabled:s=!1}){return t.jsx("div",{className:"m-priority-selector",role:"radiogroup","aria-label":"Priority",children:os.map(n=>{const i=e===n.value,u=`m-priority-chip${i?" is-selected":""}`;return t.jsx("button",{type:"button",role:"radio","aria-checked":i?"true":"false",className:u,"data-priority":n.value===Z?"untriaged":n.value.toLowerCase(),"data-testid":`priority-chip-${n.value===Z?"untriaged":n.value.toLowerCase()}`,disabled:s,onClick:()=>a(n.value),children:n.label},n.value)})})}function ds({idea:e,open:a,onClose:s,onPromote:n,onKill:i,onSetPriority:u}){const[o,l]=r.useState(!1);if(!a||!e)return null;const d=Array.isArray(e.tags)?e.tags:[],g=e.priority||Z;async function m(f,p=!0){l(!0);try{await f(),p&&(s==null||s())}catch{}finally{l(!1)}}return t.jsx("div",{className:"m-sheet-overlay","data-testid":"idea-detail-sheet",role:"dialog","aria-modal":"true","aria-label":`Idea ${e.id}`,onClick:f=>{f.target===f.currentTarget&&(s==null||s())},children:t.jsxs("div",{className:"m-sheet",children:[t.jsxs("header",{className:"m-sheet-header",children:[t.jsx("button",{type:"button",className:"m-sheet-close","aria-label":"Close detail",onClick:s,disabled:o,children:"×"}),t.jsx("div",{className:"m-sheet-title-row",children:t.jsx("div",{className:"m-sheet-title",children:e.title})}),t.jsxs("div",{className:"m-detail-meta",children:[t.jsx("span",{className:"m-detail-meta-id",children:e.id}),t.jsx("span",{className:"m-detail-meta-status",children:e.status||"NEW"}),e.cluster?t.jsx("span",{className:"m-detail-meta-cluster",children:e.cluster}):null]})]}),t.jsxs("div",{className:"m-sheet-body",children:[e.description?t.jsxs("div",{className:"m-sheet-section",children:[t.jsx("div",{className:"m-sheet-label",children:"Description"}),t.jsx("p",{className:"m-sheet-desc",children:e.description})]}):null,e.source?t.jsxs("div",{className:"m-sheet-section",children:[t.jsx("div",{className:"m-sheet-label",children:"Source"}),t.jsx("p",{className:"m-sheet-desc",children:e.source})]}):null,d.length>0?t.jsxs("div",{className:"m-sheet-section",children:[t.jsx("div",{className:"m-sheet-label",children:"Tags"}),t.jsx("div",{className:"m-idea-tags",children:d.map(f=>t.jsx("span",{className:"m-idea-tag",children:f},f))})]}):null,t.jsxs("div",{className:"m-sheet-section",children:[t.jsx("div",{className:"m-sheet-label",children:"Priority"}),t.jsx(cs,{value:g,disabled:o,onChange:f=>m(()=>u==null?void 0:u(e.id,f),!1)})]})]}),t.jsxs("footer",{className:"m-sheet-footer",children:[t.jsx("button",{type:"button",className:"m-sheet-btn m-sheet-btn-secondary","data-testid":"detail-kill",disabled:o,onClick:()=>m(()=>i==null?void 0:i(e.id)),children:"Kill"}),t.jsx("button",{type:"button",className:"m-sheet-btn m-sheet-btn-primary","data-testid":"detail-promote",disabled:o,onClick:()=>m(()=>n==null?void 0:n(e.id)),children:"Promote"})]})]})})}const us=[{id:"all",label:"All"},{id:"P0",label:"P0"},{id:"P1",label:"P1"},{id:"P2",label:"P2"},{id:"untriaged",label:"Untriaged"}],Ie={P0:3,P1:2,P2:1};function ms(e){return[...e].sort((a,s)=>{const n=Ie[a.priority]||0,i=Ie[s.priority]||0;if(n!==i)return i-n;const u=typeof a.num=="number"?a.num:0;return(typeof s.num=="number"?s.num:0)-u})}function fs(){const{ideas:e,loading:a,toasts:s,dismissToast:n,createIdea:i,promote:u,kill:o,setPriority:l}=ss(),[d,g]=r.useState("all"),[m,f]=r.useState(!1),[p,h]=r.useState(null),N=r.useMemo(()=>{let w=e;return d==="untriaged"?w=w.filter(E=>!E.priority||E.priority===Z||E.priority===""):d!=="all"&&(w=w.filter(E=>E.priority===d)),ms(w)},[e,d]),C=r.useMemo(()=>{const w=new Set;for(const E of e)E.cluster&&w.add(E.cluster);return[...w]},[e]);return t.jsxs("section",{className:"m-ideas-tab","data-testid":"mobile-tab-ideas",children:[t.jsxs("div",{className:"m-ideas-toolbar",children:[t.jsx("button",{type:"button",className:"m-sheet-btn m-sheet-btn-primary m-capture-btn",onClick:()=>f(!0),"data-testid":"open-capture","aria-label":"Capture new idea",children:"+ Capture"}),t.jsx("div",{className:"m-filter-chips",role:"tablist","aria-label":"Priority filter",children:us.map(w=>t.jsx("button",{type:"button",role:"tab","aria-pressed":d===w.id?"true":"false","aria-selected":d===w.id?"true":"false",className:"m-filter-chip",onClick:()=>g(w.id),"data-testid":`filter-${w.id}`,children:w.label},w.id))})]}),a?t.jsx("div",{className:"m-ideas-list","data-testid":"ideas-loading",children:[0,1,2].map(w=>t.jsx("div",{className:"m-idea-skeleton","aria-hidden":"true"},w))}):N.length===0?t.jsxs("div",{className:"m-empty-state","data-testid":"ideas-empty",children:[t.jsx("div",{className:"m-empty-title",children:e.length===0?"No ideas yet":"Nothing matches this filter"}),t.jsx("div",{className:"m-empty-body",children:e.length===0?"Tap Capture to add your first idea.":"Try All to see everything."})]}):t.jsx("div",{className:"m-ideas-list","data-testid":"ideas-list",children:N.map(w=>t.jsx(is,{idea:w,onTap:E=>h(E),onSwipeLeft:E=>o(E.id),onSwipeRight:E=>u(E.id)},w.id))}),t.jsx(ls,{open:m,onClose:()=>f(!1),onSubmit:i,existingClusters:C}),t.jsx(ds,{idea:p,open:!!p,onClose:()=>h(null),onPromote:w=>u(w),onKill:w=>o(w),onSetPriority:(w,E)=>l(w,E)}),t.jsx("div",{className:"m-toast-stack","aria-live":"polite","data-testid":"toasts",children:s.map(w=>t.jsx("div",{className:"m-toast","data-kind":w.kind==="error"?"error":"ok",role:w.kind==="error"?"alert":"status",onClick:()=>n(w.id),children:w.message},w.id))})]})}function hs(e){if(!e)return"";const a=typeof e=="string"?Date.parse(e):Number(e);if(!a||Number.isNaN(a))return"";const s=Date.now()-a;return s<5e3?"just now":s<6e4?`${Math.floor(s/1e3)}s ago`:s<36e5?`${Math.floor(s/6e4)}m ago`:`${Math.floor(s/36e5)}h ago`}function ps(e,a=3){return e?Array.isArray(e.logTail)?e.logTail.slice(-a):Array.isArray(e.recentLogs)?e.recentLogs.slice(-a):Array.isArray(e.steps)?e.steps.slice(-a).map(s=>`${s.id||s.name||""}: ${s.status||""}`.trim()):[]:[]}function bs({active:e,onOpen:a,onAbort:s,aborting:n}){const[i,u]=r.useState(null),o=(e==null?void 0:e.featureCode)||"(unknown)",l=(e==null?void 0:e.mode)||"feature",d=(e==null?void 0:e.status)||"unknown",g=(e==null?void 0:e.startedAt)||(e==null?void 0:e.started_at)||null,m=ps(e),f=r.useCallback(async h=>{if(h==null||h.stopPropagation(),!!(e!=null&&e.featureCode)){u(null);try{await(s==null?void 0:s({featureCode:e.featureCode}))}catch(N){u(N.message||"Failed to abort")}}},[e,s]),p=r.useCallback(()=>a==null?void 0:a(e),[a,e]);return t.jsxs("div",{className:"m-build-card","data-testid":"mobile-build-card","data-feature":o,role:"button",tabIndex:0,onClick:p,onKeyDown:h=>{h.key==="Enter"&&p()},children:[t.jsxs("div",{className:"m-build-card-row",children:[t.jsx("div",{className:"m-build-card-feature",title:o,children:o}),t.jsx("span",{className:"m-status-pill","data-status":d,children:d})]}),t.jsxs("div",{className:"m-build-card-meta",children:[t.jsx("span",{className:"m-build-card-mode","data-mode":l,children:l}),t.jsx("span",{className:"m-build-card-time",children:hs(g)})]}),m.length>0&&t.jsx("div",{className:"m-build-card-tail",children:m.map((h,N)=>t.jsx("div",{className:"m-build-card-tail-line",children:String(h).slice(0,200)},N))}),t.jsx("div",{className:"m-build-card-actions",children:t.jsx("button",{type:"button",className:"m-btn m-btn-danger m-btn-sm","data-testid":"mobile-build-abort",disabled:n||me(d),onClick:f,children:n?"Aborting…":"Abort"})}),i&&t.jsx("div",{className:"m-agent-card-error",children:i})]})}const ys={design:"Design",blueprint:"Blueprint",implementation:"Implementation",ship:"Ship"},gs=["design","blueprint","implementation","ship"];function xs(e){return e==="active"?"◉":e==="done"||e==="complete"||e==="completed"?"●":e==="failed"||e==="error"?"✕":"○"}function Le(e){return e==="done"||e==="complete"||e==="completed"}function js(e){return e==="failed"||e==="error"}function vs(e){return e||null}function Ns(e){const a=[];let s=0;for(;s<e.length;){const n=e[s];if(!Le(n.status)){a.push({type:"step",step:n}),s++;continue}let i=s;for(;i<e.length&&Le(e[i].status);)i++;const u=i-s;if(u>=3)a.push({type:"collapsed",steps:e.slice(s,i),count:u});else for(let o=s;o<i;o++)a.push({type:"step",step:e[o]});s=i}return a}function Qe({step:e}){const a=xs(e.status),s=js(e.status),n=e.status==="active";return t.jsxs("div",{className:["m-step-row",n?"m-step-row--active":"",s?"m-step-row--failed":""].filter(Boolean).join(" "),"data-testid":`mobile-build-step-${e.id}`,"data-status":e.status||"pending",children:[t.jsx("span",{className:`m-step-glyph${n?" m-step-glyph--pulse":""}`,"aria-hidden":"true",children:a}),t.jsx("span",{className:"m-step-name",children:e.name||e.id}),vs(e.agent)&&t.jsx("span",{className:"m-step-agent-chip",children:e.agent}),s&&e.summary&&t.jsx("div",{className:"m-step-summary",children:e.summary})]})}function ws({segment:e,expandedKey:a,onToggle:s}){const n=a===e.steps[0].id;return t.jsx("div",{className:"m-step-collapsed-row","data-testid":"mobile-build-steps-collapsed",role:"button",tabIndex:0,"aria-expanded":n,onClick:()=>s(e.steps[0].id),onKeyDown:i=>{(i.key==="Enter"||i.key===" ")&&s(e.steps[0].id)},children:n?e.steps.map(i=>t.jsx(Qe,{step:i},i.id)):t.jsxs("span",{className:"m-step-collapsed-label",children:[e.count," done ✓"]})})}function Ss({active:e}){const[a,s]=r.useState(null),n=xt(yt,(e==null?void 0:e.steps)??null,(e==null?void 0:e.currentStepId)??null),i={};for(const l of n){const d=l.phase||"implementation";i[d]||(i[d]=[]),i[d].push(l)}const u=gs.filter(l=>{var d;return((d=i[l])==null?void 0:d.length)>0});function o(l){s(d=>d===l?null:l)}return t.jsx("div",{className:"m-build-steps-list","data-testid":"mobile-build-steps",children:u.map(l=>{const d=i[l],g=Ns(d);return t.jsxs("div",{className:"m-build-steps-phase",children:[t.jsx("div",{className:"m-build-steps-phase-header",children:ys[l]||l}),t.jsx("div",{className:"m-build-steps-phase-rows",children:g.map((m,f)=>m.type==="collapsed"?t.jsx(ws,{segment:m,expandedKey:a,onToggle:o},`collapsed-${f}`):t.jsx(Qe,{step:m.step},m.step.id))})]},l)})})}function ks(e,a){if(typeof e=="string")return e;if(e!=null&&e.type&&(e!=null&&e.message))return`[${e.type}] ${typeof e.message=="string"?e.message:JSON.stringify(e.message)}`;if(e!=null&&e.type)return`[${e.type}] ${JSON.stringify(e).slice(0,240)}`;try{return JSON.stringify(e)}catch{return`(unserializable #${a})`}}function Cs({active:e,onClose:a,onAbort:s}){const n=e==null?void 0:e.featureCode,{events:i}=ze({agentId:(e==null?void 0:e.flowId)||null}),u=r.useRef(null),[o,l]=r.useState(!1),[d,g]=r.useState(null),[m,f]=r.useState("steps");r.useEffect(()=>{var C;(C=u.current)==null||C.scrollIntoView({behavior:"smooth"})},[i.length]);const p=r.useCallback(async()=>{if(n){l(!0),g(null);try{await(s==null?void 0:s({featureCode:n}))}catch(C){g(C.message||"Failed to abort")}finally{l(!1)}}},[n,s]);if(!e)return null;const h=e.status||"unknown",N=e.mode||"feature";return t.jsxs("div",{className:"m-overlay","data-testid":"mobile-build-detail",role:"dialog","aria-modal":"true",children:[t.jsxs("header",{className:"m-overlay-header",children:[t.jsxs("div",{className:"m-overlay-header-inner",children:[t.jsx("div",{className:"m-overlay-title",title:n,children:n}),t.jsx("span",{className:"m-status-pill","data-status":h,children:h}),t.jsx("span",{className:"m-build-card-mode","data-mode":N,children:N})]}),t.jsxs("div",{className:"m-overlay-actions",children:[t.jsx("button",{type:"button",className:"m-btn m-btn-danger m-btn-sm",disabled:o||me(h),onClick:p,"data-testid":"mobile-build-detail-abort",children:o?"Aborting…":"Abort"}),t.jsx("button",{type:"button",className:"m-btn m-btn-sm",onClick:a,"data-testid":"mobile-build-detail-close",children:"Close"})]})]}),t.jsxs("div",{className:"m-build-detail-tabs",children:[t.jsx("button",{type:"button",className:`m-build-detail-tab${m==="steps"?" is-active":""}`,"data-testid":"mobile-build-detail-tab-steps","aria-pressed":m==="steps",onClick:()=>f("steps"),children:"Steps"}),t.jsx("button",{type:"button",className:`m-build-detail-tab${m==="log"?" is-active":""}`,"data-testid":"mobile-build-detail-tab-log","aria-pressed":m==="log",onClick:()=>f("log"),children:"Log"})]}),m==="steps"?t.jsx("div",{className:"m-overlay-body",children:t.jsx(Ss,{active:e})}):t.jsxs("div",{className:"m-overlay-body m-agent-log",children:[i.length===0?t.jsx("div",{className:"m-empty",children:"No live events yet."}):i.map((C,w)=>t.jsx("div",{className:"m-agent-log-line",children:ks(C,w)},w)),t.jsx("div",{ref:u})]}),d&&t.jsx("div",{className:"m-agent-card-error",children:d})]})}function Ts(e){if(!e)return"";const a=typeof e=="string"?Date.parse(e):Number(e);if(!a||Number.isNaN(a))return"";const s=Date.now()-a;return s<5e3?"just now":s<6e4?`${Math.floor(s/1e3)}s ago`:s<36e5?`${Math.floor(s/6e4)}m ago`:s<864e5?`${Math.floor(s/36e5)}h ago`:`${Math.floor(s/864e5)}d ago`}function Es(e){if(!e||typeof e!="number")return"—";if(e<1e3)return`${e}ms`;if(e<6e4)return`${Math.floor(e/1e3)}s`;if(e<36e5){const n=Math.floor(e/6e4),i=Math.floor(e%6e4/1e3);return i>0?`${n}m ${i}s`:`${n}m`}const a=Math.floor(e/36e5),s=Math.floor(e%36e5/6e4);return s>0?`${a}h ${s}m`:`${a}h`}const Oe=80,As={done:"●",failed:"✕",revised:"↻",killed:"✕"};function Rs(e){if(!e)return"";const a=e.toLowerCase();return a==="complete"||a==="completed"?"ok":a==="failed"||a==="error"?"error":a==="aborted"||a==="killed"?"warn":""}function _s({build:e,index:a}){const[s,n]=r.useState(!1),i=Ts(e.completedAt),u=e.failureReason?e.failureReason.slice(0,Oe)+(e.failureReason.length>Oe?"…":""):null,o=Rs(e.status);return t.jsxs("div",{className:`m-build-history-row${s?" is-expanded":""}`,"data-testid":`mobile-build-history-${a}`,"data-status":e.status||"unknown",role:"button",tabIndex:0,"aria-expanded":s,onClick:()=>n(l=>!l),onKeyDown:l=>{(l.key==="Enter"||l.key===" ")&&n(d=>!d)},children:[t.jsxs("div",{className:"m-build-history-summary",children:[t.jsx("span",{className:"m-build-history-code",children:e.featureCode||"(unknown)"}),t.jsx("span",{className:`m-status-pill${o?" m-status-pill--"+o:""}`,"data-status":e.status,children:e.status||"unknown"}),i&&t.jsx("span",{className:"m-build-history-rel",children:i}),!s&&u&&t.jsx("span",{className:"m-build-history-reason-trunc",children:u})]}),s&&t.jsxs("div",{className:"m-build-history-detail",children:[e.mode!=null&&t.jsxs("div",{className:"m-build-history-field",children:[t.jsx("span",{className:"m-build-history-field-label",children:"Mode"}),t.jsx("span",{className:"m-build-history-field-value",children:e.mode})]}),e.durationMs!=null&&t.jsxs("div",{className:"m-build-history-field",children:[t.jsx("span",{className:"m-build-history-field-label",children:"Duration"}),t.jsx("span",{className:"m-build-history-field-value",children:Es(e.durationMs)})]}),e.stepCount!=null&&t.jsxs("div",{className:"m-build-history-field",children:[t.jsx("span",{className:"m-build-history-field-label",children:"Steps"}),t.jsx("span",{className:"m-build-history-field-value",children:e.stepCount})]}),Array.isArray(e.steps)&&e.steps.length>0&&t.jsx("div",{className:"m-build-history-steps","data-testid":`mobile-build-history-steps-${a}`,children:e.steps.map((l,d)=>t.jsxs("div",{className:`m-build-history-step${l.status==="failed"?" is-failed":""}`,"data-status":l.status,children:[t.jsx("span",{className:"m-build-history-step-glyph",children:As[l.status]||"○"}),t.jsx("span",{className:"m-build-history-step-id",children:(l.id||"").replace(/_/g," ")}),l.agent&&t.jsx("span",{className:"m-build-history-step-agent",children:l.agent}),l.status==="failed"&&l.summary&&t.jsx("span",{className:"m-build-history-step-summary",children:l.summary})]},`${l.id||d}`))}),e.failureReason&&t.jsxs("div",{className:"m-build-history-field m-build-history-field--block",children:[t.jsx("span",{className:"m-build-history-field-label",children:"Failure reason"}),t.jsx("span",{className:"m-build-history-field-value m-build-history-failure",children:e.failureReason})]}),e.startedAt&&t.jsxs("div",{className:"m-build-history-field",children:[t.jsx("span",{className:"m-build-history-field-label",children:"Started"}),t.jsx("span",{className:"m-build-history-field-value",children:new Date(e.startedAt).toLocaleString()})]}),e.completedAt&&t.jsxs("div",{className:"m-build-history-field",children:[t.jsx("span",{className:"m-build-history-field-label",children:"Completed"}),t.jsx("span",{className:"m-build-history-field-value",children:new Date(e.completedAt).toLocaleString()})]})]})]})}function $s({builds:e,loading:a,error:s}){return a?t.jsx("div",{className:"m-build-history","data-testid":"mobile-build-history",children:t.jsx("div",{className:"m-empty",children:"Loading history…"})}):s?t.jsx("div",{className:"m-build-history","data-testid":"mobile-build-history",children:t.jsxs("div",{className:"m-empty",children:["Error: ",s]})}):t.jsx("div",{className:"m-build-history","data-testid":"mobile-build-history",children:!e||e.length===0?t.jsx("div",{className:"m-empty",children:"No past builds."}):e.map((n,i)=>t.jsx(_s,{build:n,index:i},n.flowId||i))})}async function Ps(){var e;try{const a=await B("/api/vision/items");if(!a.ok)return[];const s=await a.json(),n=Array.isArray(s==null?void 0:s.items)?s.items:Array.isArray(s)?s:[],i=new Set;for(const u of n){const o=((e=u==null?void 0:u.lifecycle)==null?void 0:e.featureCode)||(u==null?void 0:u.featureCode)||(u==null?void 0:u.id);o&&typeof o=="string"&&i.add(o)}return[...i].sort()}catch{return[]}}function Is({open:e,onClose:a,onSubmit:s}){const[n,i]=r.useState(""),[u,o]=r.useState("feature"),[l,d]=r.useState(""),[g,m]=r.useState(!1),[f,p]=r.useState(null),[h,N]=r.useState([]),C=r.useId();r.useEffect(()=>{if(!e)return;let x=!0;return Ps().then(j=>{x&&N(j)}),()=>{x=!1}},[e]);const w=r.useMemo(()=>h,[h]);if(!e)return null;function E(){i(""),o("feature"),d(""),p(null),m(!1)}function v(){E(),a==null||a()}async function T(x){if(x==null||x.preventDefault(),!n.trim()){p("Feature code is required");return}m(!0),p(null);try{await(s==null?void 0:s({featureCode:n.trim(),mode:u,description:l.trim()})),v()}catch(j){p(j.message||"Failed to start build"),m(!1)}}return t.jsx("div",{className:"m-sheet-overlay","data-testid":"mobile-start-build-sheet",role:"dialog","aria-modal":"true","aria-label":"Start build",onClick:x=>{x.target===x.currentTarget&&v()},children:t.jsxs("div",{className:"m-sheet",children:[t.jsxs("header",{className:"m-sheet-header",children:[t.jsx("button",{type:"button",className:"m-sheet-close","aria-label":"Close start build",onClick:v,disabled:g,children:"×"}),t.jsx("div",{className:"m-sheet-title-row",children:t.jsx("div",{className:"m-sheet-title",children:"Start build"})})]}),t.jsxs("form",{className:"m-sheet-body",onSubmit:T,children:[t.jsxs("div",{className:"m-sheet-section",children:[t.jsx("label",{className:"m-sheet-label",htmlFor:"m-build-feature",children:"Feature code"}),t.jsx("input",{id:"m-build-feature",type:"text",className:"m-sheet-input",value:n,onChange:x=>i(x.target.value),placeholder:"e.g. COMP-MOBILE","data-testid":"mobile-build-feature-input",list:C,autoFocus:!0,required:!0}),t.jsx("datalist",{id:C,children:w.map(x=>t.jsx("option",{value:x},x))})]}),t.jsxs("div",{className:"m-sheet-section",children:[t.jsx("div",{className:"m-sheet-label",children:"Mode"}),t.jsxs("div",{className:"m-build-mode-row",role:"radiogroup","aria-label":"Build mode",children:[t.jsx("button",{type:"button",role:"radio","aria-checked":u==="feature",className:`m-priority-chip${u==="feature"?" is-selected":""}`,"data-testid":"mobile-build-mode-feature",onClick:()=>o("feature"),children:"Feature"}),t.jsx("button",{type:"button",role:"radio","aria-checked":u==="bug",className:`m-priority-chip${u==="bug"?" is-selected":""}`,"data-testid":"mobile-build-mode-bug",onClick:()=>o("bug"),children:"Bug"})]})]}),t.jsxs("div",{className:"m-sheet-section",children:[t.jsx("label",{className:"m-sheet-label",htmlFor:"m-build-desc",children:"Description (optional)"}),t.jsx("textarea",{id:"m-build-desc",className:"m-sheet-input m-textarea",value:l,onChange:x=>d(x.target.value),rows:4,"data-testid":"mobile-build-description"})]}),f?t.jsx("div",{className:"m-form-error",role:"alert",children:f}):null]}),t.jsxs("footer",{className:"m-sheet-footer",children:[t.jsx("button",{type:"button",className:"m-sheet-btn m-sheet-btn-secondary",onClick:v,disabled:g,"data-testid":"mobile-build-cancel",children:"Cancel"}),t.jsx("button",{type:"button",className:"m-sheet-btn m-sheet-btn-primary",disabled:g||!n.trim(),"data-testid":"mobile-build-submit",onClick:T,children:g?"Starting…":"Start"})]})]})})}const Ze=4e3,Me={info:{color:"hsl(var(--foreground))",bg:"hsl(var(--muted))"},warn:{color:"hsl(var(--warning, 32 95% 52%))",bg:"hsl(var(--muted))"},error:{color:"hsl(var(--destructive))",bg:"hsl(var(--destructive) / 0.08)"}};function ta(){const[e,a]=r.useState(null),s=r.useRef(null);if(r.useEffect(()=>{function i(u){const{message:o,level:l="info",ttl:d=Ze}=u.detail??{};o&&(clearTimeout(s.current),a({message:o,level:l}),d>0&&(s.current=setTimeout(()=>a(null),d)))}return window.addEventListener("compose:notify",i),()=>{window.removeEventListener("compose:notify",i),clearTimeout(s.current)}},[]),!e)return null;const n=Me[e.level]??Me.info;return t.jsxs("div",{className:"h-6 flex items-center justify-between px-3 gap-2 shrink-0 text-[11px] font-mono",style:{background:n.bg,color:n.color,borderTop:"1px solid hsl(var(--border))"},role:"status","aria-live":"polite",children:[t.jsx("span",{className:"flex-1 min-w-0 truncate",children:e.message}),t.jsx("button",{className:"shrink-0 opacity-60 hover:opacity-100 text-[10px]",onClick:()=>{clearTimeout(s.current),a(null)},"aria-label":"Dismiss notification",children:"✕"})]})}function be(e,a="info",s=Ze){try{window.dispatchEvent(new CustomEvent("compose:notify",{detail:{message:e,level:a,ttl:s}}))}catch{}}async function De(e,a={}){const s=await B(e,a);let n=null;try{n=await s.json()}catch{}if(!s.ok){const i=n&&n.error||`HTTP ${s.status}`;throw new Error(i)}return n}const Ls=new Set(["complete","completed"]);function Os({active:e,limit:a=20}={}){const[s,n]=r.useState([]),[i,u]=r.useState(!0),[o,l]=r.useState(null),d=r.useRef(new Map),g=r.useRef(new Map),m=r.useRef(!0),f=r.useRef(null),p=r.useCallback(C=>{n(C),l(null);for(const w of C){const E=w.flowId;if(!E)continue;const v=d.current.get(E);if(v&&Ls.has(v)&&w.status==="failed"&&g.current.get(E)!==w.status){g.current.set(E,w.status);try{be(`Build failed post-checks: ${w.featureCode}`,"error",0)}catch{}}}},[]),h=r.useCallback(async({pendingFlowId:C}={})=>{try{const w=await De(`/api/builds?limit=${a}`);if(!m.current)return;const E=Array.isArray(w==null?void 0:w.builds)?w.builds:[];p(E),C&&(E.some(T=>T.flowId===C)||(f.current&&clearTimeout(f.current),f.current=setTimeout(async()=>{if(m.current)try{const T=await De(`/api/builds?limit=${a}`);if(!m.current)return;const x=Array.isArray(T==null?void 0:T.builds)?T.builds:[];p(x)}catch(T){m.current&&l(T.message)}},2500)))}catch(w){if(!m.current)return;l(w.message)}finally{m.current&&u(!1)}},[a,p]);r.useEffect(()=>(m.current=!0,h(),()=>{m.current=!1,f.current&&clearTimeout(f.current)}),[h]);const N=r.useRef(null);return r.useEffect(()=>{if(!e)return;N.current,N.current=e;const C=e.flowId;if(!(!C||!me(e.status))){if(d.current.has(C)){d.current.get(C)!==e.status&&d.current.set(C,e.status);return}d.current.set(C,e.status),h({pendingFlowId:C})}},[e,h]),{builds:s,loading:i,error:o,refetch:h}}function Ms({active:e,loading:a,error:s,startBuild:n,abortBuild:i}){const[u,o]=r.useState(!1),[l,d]=r.useState(!1),[g,m]=r.useState(!1),[f,p]=r.useState(null),{builds:h,loading:N,error:C}=Os({active:e}),w=!!(e&&e.featureCode&&!me(e.status)),E=r.useCallback(async({featureCode:T,mode:x,description:j})=>{try{await n({featureCode:T,mode:x,description:j}),p({kind:"ok",message:`Build started for ${T}`})}catch(b){const y=(b==null?void 0:b.status)===409?`A build for ${T} is already active`:(b==null?void 0:b.message)||"Failed to start build";throw p({kind:"error",message:y}),b}},[n]),v=r.useCallback(async({featureCode:T})=>{m(!0);try{await i({featureCode:T}),p({kind:"ok",message:`Aborted ${T}`}),d(!1)}catch(x){throw p({kind:"error",message:(x==null?void 0:x.message)||"Failed to abort"}),x}finally{m(!1)}},[i]);return t.jsxs("section",{"data-testid":"mobile-tab-builds",className:"m-builds-tab",children:[t.jsxs("div",{className:"m-section",children:[t.jsx("h2",{className:"m-section-title",children:"Current build"}),a?t.jsx("div",{className:"m-empty","data-testid":"mobile-build-loading",children:"Loading…"}):w?t.jsx(bs,{active:e,onOpen:()=>d(!0),onAbort:v,aborting:g}):t.jsxs("div",{className:"m-empty-state","data-testid":"mobile-build-empty",children:[t.jsx("div",{className:"m-empty-title",children:"No active build"}),t.jsx("div",{className:"m-empty-body",children:e&&me(e.status)?`Last build: ${e.featureCode} (${e.status})`:"Start a build to track progress here."}),t.jsx("button",{type:"button",className:"m-btn m-btn-primary","data-testid":"mobile-build-start",onClick:()=>o(!0),children:"Start build"})]}),s&&t.jsxs("div",{className:"m-empty","data-testid":"mobile-build-error",children:["Error: ",s]})]}),w&&t.jsx("div",{className:"m-section",children:t.jsx("button",{type:"button",className:"m-btn m-btn-sm","data-testid":"mobile-build-start-secondary",onClick:()=>o(!0),children:"Start another build"})}),t.jsxs("div",{className:"m-section","data-testid":"mobile-build-history-section",children:[t.jsx("h2",{className:"m-section-title",children:"History"}),t.jsx($s,{builds:h,loading:N,error:C})]}),t.jsx(Is,{open:u,onClose:()=>o(!1),onSubmit:E}),l&&e&&t.jsx(Cs,{active:e,onClose:()=>d(!1),onAbort:v}),t.jsx(Ve,{message:f==null?void 0:f.message,kind:f==null?void 0:f.kind,onDismiss:()=>p(null)})]})}const Ds=3;function Us({onNavigate:e}){const[a,s]=r.useState([]),n=r.useRef(new Map),i=r.useRef(0),u=r.useCallback(l=>{clearTimeout(n.current.get(l)),n.current.delete(l),s(d=>d.filter(g=>g.id!==l))},[]);if(r.useEffect(()=>{function l(d){const{message:g,level:m="info",ttl:f}=d.detail??{};if(!g)return;const p=++i.current;s(N=>{const C=[...N,{id:p,message:g,level:m}];if(C.length>Ds){const w=C.shift();clearTimeout(n.current.get(w.id)),n.current.delete(w.id)}return C});const h=typeof f=="number"&&f>0&&isFinite(f)?f:0;if(h>0){const N=setTimeout(()=>{s(C=>C.filter(w=>w.id!==p)),n.current.delete(p)},h);n.current.set(p,N)}}return window.addEventListener("compose:notify",l),()=>{window.removeEventListener("compose:notify",l);for(const d of n.current.values())clearTimeout(d);n.current.clear()}},[]),a.length===0)return null;function o(l){return l==="warn"?"agents":"builds"}return t.jsx("div",{className:"m-alert-bar","data-testid":"mobile-alert-bar","aria-live":"polite",children:a.map(l=>t.jsxs("div",{className:`m-alert m-alert-${l.level}`,"data-testid":`mobile-alert-${l.level}`,role:"status",onClick:()=>{e==null||e(o(l.level)),u(l.id)},children:[t.jsx("span",{className:"m-alert-msg",children:l.message}),t.jsx("button",{type:"button",className:"m-alert-dismiss","aria-label":"Dismiss",onClick:d=>{d.stopPropagation(),u(l.id)},children:"✕"})]},l.id))})}const Fs={ok:"var(--m-ok)",warn:"var(--m-warn)",error:"var(--m-danger)"},te="var(--m-text-dim)",Gs={"installed-current":"var(--m-ok)",absent:"var(--m-text-dim)",foreign:"var(--m-danger)","installed-stale":"var(--m-warn)","workspace-unverified":"var(--m-warn)",unavailable:"var(--m-text-dim)"};function ee({color:e}){return t.jsx("span",{className:"m-env-dot","aria-hidden":"true",style:{background:e}})}function Hs(...e){return e.reduce((a,s)=>!s||s.unavailable?a:a+(s.missing||[]).length,0)}function Bs(){var C,w,E;const[e,a]=r.useState(null),[s,n]=r.useState(null),[i,u]=r.useState(!1),[o,l]=r.useState(!1),d=r.useRef(null),g=r.useCallback(async()=>{u(!0);try{const T=await(await B("/api/environment-health")).json();a(T),n(null)}catch(v){a(null),n((v==null?void 0:v.message)||"unavailable")}finally{u(!1)}},[]);r.useEffect(()=>{g()},[g]),r.useEffect(()=>{if(!o)return;const v=x=>{var j;(j=d.current)!=null&&j.contains(x.target)||l(!1)},T=x=>{x.key==="Escape"&&l(!1)};return window.addEventListener("mousedown",v),window.addEventListener("keydown",T),()=>{window.removeEventListener("mousedown",v),window.removeEventListener("keydown",T)}},[o]);const m=e==null?void 0:e.summary,f=m&&Fs[m]||te,p=e?Hs(e.dependencies,e.binaries):0,h=!!(e&&((C=e.dependencies)!=null&&C.unavailable||(w=e.binaries)!=null&&w.unavailable)),N=e!=null&&e.hooks&&!e.hooks.unavailable?Object.entries(e.hooks).filter(([v])=>v!=="unavailable"):[];return t.jsxs("div",{ref:d,className:"m-env-health",children:[t.jsx("button",{type:"button",className:"m-env-btn","data-testid":"mobile-env-health-dot",onClick:()=>l(v=>!v),title:`Environment health: ${m||(i?"checking…":"unknown")}`,"aria-label":"Environment health","aria-haspopup":"dialog","aria-expanded":o,children:t.jsx(ee,{color:f})}),o&&t.jsxs("div",{className:"m-env-detail","data-testid":"mobile-env-health-detail",role:"dialog","aria-label":"Environment health",children:[t.jsx("div",{className:"m-env-detail-head",children:"Environment Health"}),s&&t.jsxs("div",{className:"m-env-row m-env-unavailable",children:["Unavailable: ",s]}),!e&&!s&&t.jsx("div",{className:"m-env-row m-env-dim",children:i?"Checking…":"No data"}),e&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"m-env-row","data-testid":"mobile-env-health-deps",children:[t.jsx(ee,{color:h?te:p>0?"var(--m-warn)":"var(--m-ok)"}),t.jsx("span",{className:h?"m-env-dim":void 0,children:h?"dependencies unavailable":p>0?`${p} dependenc${p===1?"y":"ies"} missing`:"All dependencies present"})]}),t.jsx("div",{className:"m-env-row","data-testid":"mobile-env-health-version",children:e.version?e.version.behind?t.jsxs(t.Fragment,{children:[t.jsx(ee,{color:"var(--m-warn)"}),t.jsxs("span",{children:[e.version.current," → ",e.version.latest," (behind)"]})]}):t.jsxs(t.Fragment,{children:[t.jsx(ee,{color:"var(--m-ok)"}),t.jsxs("span",{children:[e.version.current," (up to date)"]})]}):t.jsxs(t.Fragment,{children:[t.jsx(ee,{color:te}),t.jsx("span",{className:"m-env-dim",children:"version check unavailable"})]})}),N.map(([v,T])=>t.jsxs("div",{className:"m-env-row","data-testid":`mobile-env-health-hook-${v}`,children:[t.jsx(ee,{color:Gs[T.state]||te}),t.jsx("span",{className:"m-env-mono",children:v}),t.jsx("span",{className:"m-env-dim",children:T.state})]},v)),((E=e.hooks)==null?void 0:E.unavailable)&&t.jsxs("div",{className:"m-env-row",children:[t.jsx(ee,{color:te}),t.jsx("span",{className:"m-env-dim",children:"hook status unavailable"})]})]})]})]})}async function Ue(e,a={}){const s=await B(e,a);let n=null;try{n=await s.json()}catch{}if(!s.ok){const i=n&&n.error||`HTTP ${s.status}`;throw new Error(i)}return n}function Js(){const[e,a]=r.useState([]),[s,n]=r.useState(!0),[i,u]=r.useState(null),o=r.useRef(!0),l=r.useCallback(async()=>{try{const g=await Ue("/api/vision/gates");if(!o.current)return;a(Array.isArray(g==null?void 0:g.gates)?g.gates:[]),u(null)}catch(g){if(!o.current)return;u(g.message)}finally{o.current&&n(!1)}},[]);r.useEffect(()=>(o.current=!0,l(),()=>{o.current=!1}),[l]),r.useEffect(()=>{if(typeof window>"u"||typeof WebSocket>"u")return;const g=he({url:()=>fe(),onMessage:m=>{try{const f=JSON.parse(m.data);if(!f||!f.type)return;(f.type==="gateCreated"||f.type==="gateResolved"||f.type==="gateUpdated")&&l()}catch{}}});return()=>{try{g.close()}catch{}}},[l]);const d=r.useCallback(async(g,{outcome:m,reason:f,summary:p}={})=>{if(!["approve","revise","kill"].includes(m))throw new Error(`outcome must be approve|revise|kill (got ${m})`);const h=[];f&&h.push(f),p&&h.push(p);const N=h.join(" — ")||void 0,C={outcome:m};N&&(C.comment=N);const w=await Ue(`/api/vision/gates/${encodeURIComponent(g)}/resolve`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(C)});return l(),w},[l]);return{gates:e,loading:s,error:i,refetch:l,resolve:d}}async function Se(e,a={}){const s=await B(e,a);let n=null;try{n=await s.json()}catch{}if(!s.ok){const i=n&&n.error||`HTTP ${s.status}`,u=new Error(i);throw u.status=s.status,u.data=n,u}return n}function Ys(){const[e,a]=r.useState(null),[s,n]=r.useState(!0),[i,u]=r.useState(null),o=r.useRef(!0),l=r.useCallback(async()=>{try{const m=await Se("/api/build/state");if(!o.current)return;a((m==null?void 0:m.state)??null),u(null)}catch(m){if(!o.current)return;u(m.message)}finally{o.current&&n(!1)}},[]);r.useEffect(()=>(o.current=!0,l(),()=>{o.current=!1}),[l]),r.useEffect(()=>{if(typeof window>"u"||typeof WebSocket>"u")return;const m=he({url:()=>fe(),onMessage:f=>{try{const p=JSON.parse(f.data);if(!p||!p.type)return;p.type==="buildState"&&l()}catch{}}});return()=>{try{m.close()}catch{}}},[l]);const d=r.useCallback(async({featureCode:m,mode:f="feature",description:p=""}={})=>{if(!m)throw new Error("featureCode required");const h=await Se("/api/build/start",{method:"POST",headers:V({"Content-Type":"application/json"}),body:JSON.stringify({featureCode:m,mode:f,description:p})});return l(),h},[l]),g=r.useCallback(async({featureCode:m}={})=>{if(!m)throw new Error("featureCode required");const f=await Se("/api/build/abort",{method:"POST",headers:V({"Content-Type":"application/json"}),body:JSON.stringify({featureCode:m})});return l(),f},[l]);return{active:e,loading:s,error:i,refetch:l,startBuild:d,abortBuild:g}}function qs(){const[e,a]=r.useState([]),[s,n]=r.useState(!0),[i,u]=r.useState(null),[o,l]=r.useState(!1),d=r.useRef(e);d.current=e;const g=r.useRef(new Map),m=r.useRef(new Map),f=r.useRef(new Set),p=r.useRef(0),h=r.useCallback(async()=>{try{const j=await(await B("/api/vision/items")).json(),b=Array.isArray(j==null?void 0:j.items)?j.items:Array.isArray(j)?j:[];a(b),u(null)}catch(x){u((x==null?void 0:x.message)||"Failed to load items")}finally{n(!1)}},[]);r.useEffect(()=>{let x=!1;h();const j=he({url:()=>fe(),onOpen:()=>{x||l(!0)},onClose:()=>{x||l(!1)},onMessage:b=>{var A,M;if(x)return;let y;try{y=JSON.parse(b.data)}catch{return}if(!y||typeof y!="object")return;const S=y.type;(S==="visionState"||S==="hydrate")&&Array.isArray(y.items)?a(()=>{const P=g.current,O=m.current,L=f.current;let F=y.items;if(P.size>0&&(F=F.map(Y=>{const q=P.get(Y.id);return q?{...Y,...q}:Y})),L.size>0&&(F=F.filter(Y=>!L.has(Y.id))),O.size>0){const Y=new Set(F.map(z=>z.id)),q=[...O.values()].filter(z=>!Y.has(z.id));q.length>0&&(F=[...q,...F])}return F}):S==="itemUpdated"&&((A=y.item)!=null&&A.id)?a(P=>{const O=P.findIndex(F=>F.id===y.item.id);if(O===-1)return[...P,y.item];const L=P.slice();return L[O]={...L[O],...y.item},L}):S==="itemCreated"&&((M=y.item)!=null&&M.id)?a(P=>P.some(O=>O.id===y.item.id)?P:[...P,y.item]):S==="itemDeleted"&&y.id?a(P=>P.filter(O=>O.id!==y.id)):S==="state"&&Array.isArray(y.items)?a(y.items):(S==="visionUpdated"||S==="roadmapUpdated")&&h()}});return()=>{x=!0;try{j.close()}catch{}}},[h]);const N=r.useCallback(async(x,j)=>{if(!x||!j||typeof j!="object")return{ok:!1,error:"invalid patch"};const b=d.current;if(!b.find(A=>A.id===x))return{ok:!1,error:"item not found"};g.current.set(x,j);const S=b.map(A=>A.id===x?{...A,...j}:A);a(S);try{const A=await B(`/api/vision/items/${x}`,{method:"PATCH",headers:V({"Content-Type":"application/json"}),body:JSON.stringify(j)}),M=await A.json().catch(()=>({}));if(!A.ok)return g.current.delete(x),a(b),{ok:!1,error:(M==null?void 0:M.error)||`HTTP ${A.status}`};g.current.delete(x);const P=(M==null?void 0:M.item)||(M==null?void 0:M.updated)||null;return P&&P.id===x&&a(O=>O.map(L=>L.id===x?{...L,...P}:L)),{ok:!0,item:P||S.find(O=>O.id===x)}}catch(A){return g.current.delete(x),a(b),{ok:!1,error:(A==null?void 0:A.message)||"Network error"}}},[]),C=r.useCallback(async x=>{if(!x||typeof x!="object")return{ok:!1,error:"invalid fields"};const j=`tmp-${++p.current}`,b={...x,type:"feature",id:j};m.current.set(j,b),a(y=>[b,...y]);try{const y=await B("/api/vision/items",{method:"POST",headers:V({"Content-Type":"application/json"}),body:JSON.stringify({...x,type:"feature"})}),S=await y.json().catch(()=>({}));if(!y.ok)return m.current.delete(j),a(M=>M.filter(P=>P.id!==j)),{ok:!1,error:(S==null?void 0:S.error)||`HTTP ${y.status}`};const A=(S==null?void 0:S.item)||(S!=null&&S.id?S:null);return m.current.delete(j),a(M=>A&&M.some(P=>P.id===A.id)?M.filter(P=>P.id!==j):M.map(P=>P.id===j&&A?{...P,...A}:P)),{ok:!0,item:A}}catch(y){return m.current.delete(j),a(S=>S.filter(A=>A.id!==j)),{ok:!1,error:(y==null?void 0:y.message)||"Network error"}}},[]),w=r.useCallback(async x=>{if(!x)return{ok:!1,error:"id required"};const j=d.current;f.current.add(x),a(b=>b.filter(y=>y.id!==x));try{const b=await B(`/api/vision/items/${x}`,{method:"DELETE",headers:V({"Content-Type":"application/json"})}),y=await b.json().catch(()=>({}));return b.ok?(f.current.delete(x),{ok:!0}):(f.current.delete(x),a(j),{ok:!1,error:(y==null?void 0:y.error)||`HTTP ${b.status}`})}catch(b){return f.current.delete(x),a(j),{ok:!1,error:(b==null?void 0:b.message)||"Network error"}}},[]),E=r.useCallback(async({fromId:x,toId:j,type:b})=>{try{const y=await B("/api/vision/connections",{method:"POST",headers:V({"Content-Type":"application/json"}),body:JSON.stringify({fromId:x,toId:j,type:b})}),S=await y.json().catch(()=>({}));return y.ok?{ok:!0,connection:(S==null?void 0:S.connection)||S}:{ok:!1,error:(S==null?void 0:S.error)||`HTTP ${y.status}`}}catch(y){return{ok:!1,error:(y==null?void 0:y.message)||"Network error"}}},[]),v=r.useCallback(async x=>{try{const j=await B(`/api/vision/connections/${x}`,{method:"DELETE",headers:V({"Content-Type":"application/json"})}),b=await j.json().catch(()=>({}));return j.ok?{ok:!0}:{ok:!1,error:(b==null?void 0:b.error)||`HTTP ${j.status}`}}catch(j){return{ok:!1,error:(j==null?void 0:j.message)||"Network error"}}},[]),T=r.useCallback(async x=>{try{const j=await B(`/api/vision/items/${x}`),b=await j.json().catch(()=>({}));return j.ok?{ok:!0,item:b}:{ok:!1,error:(b==null?void 0:b.error)||`HTTP ${j.status}`}}catch(j){return{ok:!1,error:(j==null?void 0:j.message)||"Network error"}}},[]);return{items:e,loading:s,error:i,connected:o,refetch:h,applyOptimisticEdit:N,createItem:C,deleteItem:w,addConnection:E,removeConnection:v,fetchItemDetail:T}}function Ks({active:e,gates:a,items:s}){const n=r.useRef(null),i=r.useRef(new Map);r.useEffect(()=>{if(Array.isArray(a)){if(n.current===null){n.current=new Set(a.map(u=>u.id));return}for(const u of a)if(!n.current.has(u.id)){n.current.add(u.id);const o=(Array.isArray(s)?s:[]).find(d=>d.id===u.itemId),l=(o==null?void 0:o.title)||"Gate pending";be(`Gate pending: ${l}`,"warn",0)}}},[a,s]),r.useEffect(()=>{if(!e||!e.flowId)return;const u=i.current.get(e.flowId),o=e.status;u!==void 0&&u!==o&&(o==="failed"?be(`Build failed: ${e.featureCode||e.flowId}`,"error",0):(o==="complete"||o==="completed")&&be(`Build complete: ${e.featureCode||e.flowId}`,"info",4e3)),i.current.set(e.flowId,o)},[e])}const et=["agents","roadmap","builds","ideas"],Fe="agents",Ge="compose:mobile:sensitiveToken";function Ws(e){const a=e.match(/^\/m(?:\/([^/?#]+))?\/?$/);if(!a)return Fe;const s=a[1];return s&&et.includes(s)?s:Fe}function zs(){const e=window.location.pathname==="/m/pair",[a,s]=r.useState(()=>Ws(window.location.pathname));r.useEffect(()=>{try{localStorage.getItem(oe)&&(Je("mobile-paired"),Ye(!0))}catch{}},[]),r.useEffect(()=>{try{const y=new URL(window.location.href),S=y.searchParams.get("token");if(S){try{localStorage.setItem(Ge,S)}catch{}se(S),y.searchParams.delete("token"),window.history.replaceState({},"",y.pathname+(y.search?y.search:"")+y.hash)}else{let A=null;try{A=localStorage.getItem(Ge)}catch{}A&&se(A)}}catch{}},[]),r.useEffect(()=>{if(!(typeof navigator>"u")&&"serviceWorker"in navigator)try{navigator.serviceWorker.register("/m-sw.js").catch(y=>{console.warn("[compose-mobile] SW registration failed:",y)})}catch(y){console.warn("[compose-mobile] SW registration threw:",y)}},[]);const n=r.useCallback(y=>{if(et.includes(y)){s(y);try{const S=new URL(window.location.href);S.pathname=`/m/${y}`,window.history.replaceState({},"",S.pathname+S.search+S.hash)}catch{}}},[]),{gates:i,loading:u,resolve:o}=Js(),{active:l,loading:d,error:g,startBuild:m,abortBuild:f}=Ys(),{items:p,loading:h,error:N,applyOptimisticEdit:C,createItem:w,deleteItem:E,addConnection:v,removeConnection:T,fetchItemDetail:x}=qs();Ks({active:l,gates:i,items:p});const j={};if(i.length>0&&(j.agents={count:i.length,level:"warn"}),(l==null?void 0:l.status)==="failed"?j.builds={level:"error"}:jt(l,i,p)&&(j.builds={level:"warn"}),e)return t.jsx(bt,{});let b=null;return a==="agents"?b=t.jsx(Ht,{gates:i,gatesLoading:u,resolveGate:o}):a==="roadmap"?b=t.jsx(ts,{items:p,loading:h,error:N,applyOptimisticEdit:C,createItem:w,deleteItem:E,addConnection:v,removeConnection:T,fetchItemDetail:x}):a==="ideas"?b=t.jsx(fs,{}):a==="builds"&&(b=t.jsx(Ms,{active:l,loading:d,error:g,startBuild:m,abortBuild:f})),t.jsxs("div",{className:"m-root","data-testid":"mobile-root",children:[t.jsx("header",{className:"m-header",children:t.jsxs("div",{className:"m-header-bar",children:[t.jsx("div",{className:"m-header-title",children:"Compose"}),t.jsx(Bs,{})]})}),t.jsx(Us,{onNavigate:n}),t.jsx("main",{className:"m-main","data-testid":"mobile-main","data-tab":a,children:b}),t.jsx(Nt,{active:a,onSelect:n,badges:j})]})}const sa=Object.freeze(Object.defineProperty({__proto__:null,default:zs},Symbol.toStringTag,{value:"Module"}));export{sa as M,ta as N,yt as P,Vs as R,r as a,Ye as b,Xs as c,lt as d,mt as e,Pt as f,st as g,he as h,Zs as i,t as j,V as k,Ke as l,xt as m,be as n,ea as o,it as r,Qs as s,fe as v,B as w};
@@ -1 +0,0 @@
1
- import{s as r,b as e,a,S as s}from"./chunk-EX3LRPZG-iz_V2kb-.js";import{_ as i}from"./App-gyObi7Fh.js";import"./chunk-XXDRQBXY-DHczIQQU.js";import"./chunk-VR4S4FIN-CxmSp2Q2.js";import"./chunk-32BRIVSS-BX5Uyghd.js";import"./mobile-CNLMhdFP.js";import"./index-C00QpUdP.js";import"./graph-xkel59g2.js";var b={parser:a,get db(){return new s(2)},renderer:e,styles:r,init:i(t=>{t.state||(t.state={}),t.state.arrowMarkerAbsolute=t.arrowMarkerAbsolute},"init")};export{b as diagram};
@@ -1,8 +0,0 @@
1
- import{c as r,s as e}from"./flowDiagram-23GEKE2U-BC1lVLbe.js";import{_ as a}from"./App-gyObi7Fh.js";import"./chunk-5VM5RSS4-DZGXdHnG.js";import"./chunk-XXDRQBXY-DHczIQQU.js";import"./chunk-VR4S4FIN-CxmSp2Q2.js";import"./chunk-32BRIVSS-BX5Uyghd.js";import"./channel-CmuM_CaB.js";import"./mobile-CNLMhdFP.js";import"./index-C00QpUdP.js";import"./graph-xkel59g2.js";var o=a(t=>`${e(t)}
2
- .swimlane.cluster rect {
3
- stroke: ${t.clusterBorder} !important;
4
- }
5
- [data-look="neo"].cluster rect {
6
- filter: none;
7
- }
8
- `,"getStyles"),m=o,_=r({defaultLayout:"swimlane",styles:m});export{_ as diagram};