mindexec-ai 0.2.385 → 0.2.387
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.
- package/README.md +28 -28
- package/launch-bridge.cjs +2 -2
- package/package.json +1 -1
- package/port-guard.cjs +1 -1
- package/remote-hub.js +1 -1
- package/scripts/remote-fleet-render-smoke.mjs +3 -3
- package/server.js +1 -1
- package/start-bridge.bat +1 -1
- package/start-bridge.sh +1 -1
- package/wwwroot/appsettings.json +1 -1
- package/wwwroot/assets/{AdminDashboardPage-DnuCHywn.js → AdminDashboardPage-_x_oqzWL.js} +1 -1
- package/wwwroot/assets/AppSidebar-sGY6ZVqZ.js +2 -0
- package/wwwroot/assets/AuthPages-Bt5a9jSO.js +1 -0
- package/wwwroot/assets/{CodePage-7kgZlB3O.js → CodePage-C0OcxSo1.js} +1 -1
- package/wwwroot/assets/{CompanyCorePage-CzIZIIU_.js → CompanyCorePage-BhB6Azad.js} +2 -2
- package/wwwroot/assets/{ExecutionModePage-B-etp_mc.js → ExecutionModePage-DQ6L2G6g.js} +1 -1
- package/wwwroot/assets/{MindCanvas-zEDXzaxW.js → MindCanvas-B5hSTh9A.js} +2 -2
- package/wwwroot/assets/{PlanMasterPage-NZ_mPvaE.js → PlanMasterPage-DevUmIeD.js} +1 -1
- package/wwwroot/assets/{PricingPage-Ylrn8l2g.js → PricingPage-3sc6Juig.js} +1 -1
- package/wwwroot/assets/{ToolPages-3M2KqA9k.js → ToolPages-DILzDdzH.js} +1 -1
- package/wwwroot/assets/{YouTubeSearchPage-COv1oAA7.js → YouTubeSearchPage-D5B05Qdb.js} +1 -1
- package/wwwroot/assets/{canvas-runtime-BbicBcOj.js → canvas-runtime-F1OftOhQ.js} +3 -3
- package/wwwroot/assets/{index-CQMKCp-t.js → index-CmaOkjme.js} +2 -2
- package/wwwroot/assets/{storage-TM3YrWaj.js → storage-k24X2WPI.js} +1 -1
- package/wwwroot/assets/{supabaseAuthAdapter-DA43DeSY.js → supabaseAuthAdapter-BcLkoGvY.js} +10 -10
- package/wwwroot/index.html +1 -1
- package/wwwroot/assets/AppSidebar-DU2OgSiv.js +0 -2
- package/wwwroot/assets/AuthPages-Dgezl7Vj.js +0 -1
package/README.md
CHANGED
|
@@ -10,9 +10,9 @@ npx mindexec-ai
|
|
|
10
10
|
|
|
11
11
|
The npm CLI now starts both pieces of the local product:
|
|
12
12
|
|
|
13
|
-
- MindCanvas app: `http://localhost:
|
|
14
|
-
- LocalBridge API: `http://127.0.0.1:
|
|
15
|
-
- Workspace assets: `http://127.0.0.1:
|
|
13
|
+
- MindCanvas app: `http://localhost:5167/mindcanvas`
|
|
14
|
+
- LocalBridge API: `http://127.0.0.1:5167/api/status`
|
|
15
|
+
- Workspace assets: `http://127.0.0.1:5167/assets/...`
|
|
16
16
|
|
|
17
17
|
By default the CLI opens the MindCanvas app in your default browser after the
|
|
18
18
|
bridge is ready. Use `mindexec --no-open` or `MINDEXEC_NO_OPEN=1` when you only
|
|
@@ -33,7 +33,7 @@ packaged app bundle after code changes:
|
|
|
33
33
|
.\scripts\publish-mindexec-cli.ps1 -AppOnly
|
|
34
34
|
```
|
|
35
35
|
|
|
36
|
-
Then hard-refresh `http://localhost:
|
|
36
|
+
Then hard-refresh `http://localhost:5167/mindcanvas` in the browser.
|
|
37
37
|
|
|
38
38
|
The app and bridge are packaged together. Run `scripts/publish-mindexec-cli.ps1`
|
|
39
39
|
from the repository root before publishing so the latest
|
|
@@ -52,20 +52,20 @@ experiments. By default it binds to loopback only:
|
|
|
52
52
|
|
|
53
53
|
```bash
|
|
54
54
|
npx mindexec-ai
|
|
55
|
-
npx @mindexec/remote connect --manager 127.0.0.1:
|
|
55
|
+
npx @mindexec/remote connect --manager 127.0.0.1:5199 --pair <pair-token>
|
|
56
56
|
```
|
|
57
57
|
|
|
58
58
|
Read the pair token from the protected local endpoint:
|
|
59
59
|
|
|
60
60
|
```bash
|
|
61
|
-
curl -H "X-Bridge-Token: <bridge-token>" http://127.0.0.1:
|
|
61
|
+
curl -H "X-Bridge-Token: <bridge-token>" http://127.0.0.1:5167/api/remote/status
|
|
62
62
|
```
|
|
63
63
|
|
|
64
64
|
LAN/direct mode must be enabled explicitly by changing the RemoteHub bind host:
|
|
65
65
|
|
|
66
66
|
```powershell
|
|
67
67
|
$env:REMOTE_HUB_HOST="0.0.0.0"
|
|
68
|
-
$env:REMOTE_HUB_PORT="
|
|
68
|
+
$env:REMOTE_HUB_PORT="5199"
|
|
69
69
|
$env:REMOTE_HUB_PAIR_TOKEN="<strong-token>"
|
|
70
70
|
npx mindexec-ai
|
|
71
71
|
```
|
|
@@ -73,14 +73,14 @@ npx mindexec-ai
|
|
|
73
73
|
Device inventory is intentionally not paginated:
|
|
74
74
|
|
|
75
75
|
```bash
|
|
76
|
-
curl -H "X-Bridge-Token: <bridge-token>" http://127.0.0.1:
|
|
76
|
+
curl -H "X-Bridge-Token: <bridge-token>" http://127.0.0.1:5167/api/remote/devices
|
|
77
77
|
```
|
|
78
78
|
|
|
79
79
|
Request and read the latest view-only thumbnail for a connected device:
|
|
80
80
|
|
|
81
81
|
```bash
|
|
82
|
-
curl -X POST -H "X-Bridge-Token: <bridge-token>" http://127.0.0.1:
|
|
83
|
-
curl -H "X-Bridge-Token: <bridge-token>" http://127.0.0.1:
|
|
82
|
+
curl -X POST -H "X-Bridge-Token: <bridge-token>" http://127.0.0.1:5167/api/remote/devices/<device-id>/thumbnail/request
|
|
83
|
+
curl -H "X-Bridge-Token: <bridge-token>" http://127.0.0.1:5167/api/remote/devices/<device-id>/thumbnail
|
|
84
84
|
```
|
|
85
85
|
|
|
86
86
|
Start, read, and stop the focused view-only RemoteFast live stream:
|
|
@@ -88,11 +88,11 @@ Start, read, and stop the focused view-only RemoteFast live stream:
|
|
|
88
88
|
```bash
|
|
89
89
|
curl -X POST -H "X-Bridge-Token: <bridge-token>" -H "Content-Type: application/json" \
|
|
90
90
|
-d "{\"fps\":12,\"maxWidth\":960,\"maxHeight\":540,\"quality\":60}" \
|
|
91
|
-
http://127.0.0.1:
|
|
91
|
+
http://127.0.0.1:5167/api/remote/devices/<device-id>/live/start
|
|
92
92
|
|
|
93
|
-
curl -H "X-Bridge-Token: <bridge-token>" http://127.0.0.1:
|
|
93
|
+
curl -H "X-Bridge-Token: <bridge-token>" http://127.0.0.1:5167/api/remote/devices/<device-id>/live/frame
|
|
94
94
|
|
|
95
|
-
curl -X POST -H "X-Bridge-Token: <bridge-token>" http://127.0.0.1:
|
|
95
|
+
curl -X POST -H "X-Bridge-Token: <bridge-token>" http://127.0.0.1:5167/api/remote/devices/<device-id>/live/stop
|
|
96
96
|
```
|
|
97
97
|
|
|
98
98
|
Queue a safe task-only instruction for one device or all connected devices:
|
|
@@ -100,11 +100,11 @@ Queue a safe task-only instruction for one device or all connected devices:
|
|
|
100
100
|
```bash
|
|
101
101
|
curl -X POST -H "X-Bridge-Token: <bridge-token>" -H "Content-Type: application/json" \
|
|
102
102
|
-d "{\"instruction\":\"Check the desktop and report status.\"}" \
|
|
103
|
-
http://127.0.0.1:
|
|
103
|
+
http://127.0.0.1:5167/api/remote/devices/<device-id>/tasks
|
|
104
104
|
|
|
105
105
|
curl -X POST -H "X-Bridge-Token: <bridge-token>" -H "Content-Type: application/json" \
|
|
106
106
|
-d "{\"instruction\":\"Prepare a short status report.\",\"allConnected\":true}" \
|
|
107
|
-
http://127.0.0.1:
|
|
107
|
+
http://127.0.0.1:5167/api/remote/tasks
|
|
108
108
|
```
|
|
109
109
|
|
|
110
110
|
Queue an opt-in text-only AI assist task for agents started with `--ai`:
|
|
@@ -112,7 +112,7 @@ Queue an opt-in text-only AI assist task for agents started with `--ai`:
|
|
|
112
112
|
```bash
|
|
113
113
|
curl -X POST -H "X-Bridge-Token: <bridge-token>" -H "Content-Type: application/json" \
|
|
114
114
|
-d "{\"instruction\":\"Summarize what this computer should do next.\",\"allConnected\":true,\"approvalLevel\":\"ai-assist\"}" \
|
|
115
|
-
http://127.0.0.1:
|
|
115
|
+
http://127.0.0.1:5167/api/remote/tasks
|
|
116
116
|
```
|
|
117
117
|
|
|
118
118
|
?먮뒗 ?꾩뿭 ?ㅼ튂 ???ㅽ뻾?⑸땲??
|
|
@@ -122,7 +122,7 @@ npm install -g mindexec-ai
|
|
|
122
122
|
mindexec
|
|
123
123
|
```
|
|
124
124
|
|
|
125
|
-
湲곕낯 ?ㅽ뻾 二쇱냼??`http://127.0.0.1:
|
|
125
|
+
湲곕낯 ?ㅽ뻾 二쇱냼??`http://127.0.0.1:5167`?낅땲?? `WORKSPACE_PATH`媛 鍮꾩뼱 ?덉쑝硫??ㅼ튂???⑦궎吏??遺紐??대뜑瑜?湲곕낯 ?묒뾽 怨듦컙?쇰줈 ?ъ슜?⑸땲??
|
|
126
126
|
|
|
127
127
|
```bash
|
|
128
128
|
mindexec --workspace /custom/path
|
|
@@ -162,7 +162,7 @@ chmod +x start-bridge.sh
|
|
|
162
162
|
|
|
163
163
|
`start-bridge.sh`???ㅼ쓬???먮룞?쇰줈 泥섎━?⑸땲??
|
|
164
164
|
- `WORKSPACE_PATH`媛 ?놁쑝硫???μ냼 猷⑦듃瑜??묒뾽 怨듦컙?쇰줈 ?ъ슜
|
|
165
|
-
- `BRIDGE_PORT`媛 ?놁쑝硫?`
|
|
165
|
+
- `BRIDGE_PORT`媛 ?놁쑝硫?`5167` ?ъ슜
|
|
166
166
|
- 媛숈? ?ы듃???대? 釉뚮━吏媛 ???덉쑝硫?以묐났 ?ㅽ뻾 諛⑹?
|
|
167
167
|
- ?ㅻⅨ OS?먯꽌 蹂듭궗????`node_modules`媛 媛먯??섎㈃ ?꾩옱 ?뚮옯?쇱슜?쇰줈 ?ㅼ떆 `npm install`
|
|
168
168
|
|
|
@@ -175,7 +175,7 @@ npm run dev
|
|
|
175
175
|
|
|
176
176
|
| 蹂??| ?ㅻ챸 | 湲곕낯媛?|
|
|
177
177
|
|------|------|--------|
|
|
178
|
-
| `BRIDGE_PORT` | ?쒕쾭 ?ы듃 |
|
|
178
|
+
| `BRIDGE_PORT` | ?쒕쾭 ?ы듃 | 5167 |
|
|
179
179
|
| `WORKSPACE_PATH` | ?묒뾽 怨듦컙 寃쎈줈 | `LocalBridge` ?먮뒗 ?ㅼ튂 ?⑦궎吏??遺紐??대뜑 (?놁쑝硫?`~/Documents/MindExecution`) |
|
|
180
180
|
| `BRIDGE_TOKEN` | ?꾪뿕 REST API???ъ슜??怨좎젙 ?좏겙. 鍮꾩슦硫??ㅽ뻾 ???쒕뜡 ?앹꽦 | ?쒕뜡 |
|
|
181
181
|
| `BRIDGE_REQUIRE_TOKEN` | `false`/`0`/`off`濡??ㅼ젙?섎㈃ REST ?좏겙 寃??鍮꾪솢?깊솕 | true |
|
|
@@ -252,7 +252,7 @@ The `start-bridge.bat` and `start-bridge.sh` wrappers always delegate startup to
|
|
|
252
252
|
- `GET /api/company-core/companies` -> `CompanyCore /api/companies`
|
|
253
253
|
- `POST /api/company-core/companies/create-and-run` -> `CompanyCore /api/companies/create-and-run`
|
|
254
254
|
|
|
255
|
-
MindExec Web? CompanyCore ?ы듃瑜?吏곸젒 ???꾩슂 ?놁씠 LocalBridge `
|
|
255
|
+
MindExec Web? CompanyCore ?ы듃瑜?吏곸젒 ???꾩슂 ?놁씠 LocalBridge `5167`留??몄텧?섎㈃ ?⑸땲?? ???꾨줉?쒕룄 Bridge Token 蹂댄샇瑜?諛쏆뒿?덈떎.
|
|
256
256
|
|
|
257
257
|
## 蹂댁븞 二쇱쓽?ы빆
|
|
258
258
|
|
|
@@ -266,7 +266,7 @@ MindExec Web? CompanyCore ?ы듃瑜?吏곸젒 ???꾩슂 ?놁씠 LocalBridge `5
|
|
|
266
266
|
|
|
267
267
|
### ?뚯씪 ?쎄린
|
|
268
268
|
```javascript
|
|
269
|
-
const response = await fetch('http://127.0.0.1:
|
|
269
|
+
const response = await fetch('http://127.0.0.1:5167/api/file/read', {
|
|
270
270
|
method: 'POST',
|
|
271
271
|
headers: { 'Content-Type': 'application/json' },
|
|
272
272
|
body: JSON.stringify({ path: 'test.txt' })
|
|
@@ -277,9 +277,9 @@ console.log(data.content);
|
|
|
277
277
|
|
|
278
278
|
### ?뚯씪 ?곌린
|
|
279
279
|
```javascript
|
|
280
|
-
const status = await fetch('http://127.0.0.1:
|
|
280
|
+
const status = await fetch('http://127.0.0.1:5167/api/status').then(r => r.json());
|
|
281
281
|
|
|
282
|
-
await fetch('http://127.0.0.1:
|
|
282
|
+
await fetch('http://127.0.0.1:5167/api/file/write', {
|
|
283
283
|
method: 'POST',
|
|
284
284
|
headers: {
|
|
285
285
|
'Content-Type': 'application/json',
|
|
@@ -294,9 +294,9 @@ await fetch('http://127.0.0.1:5147/api/file/write', {
|
|
|
294
294
|
|
|
295
295
|
### ??紐낅졊 ?ㅽ뻾
|
|
296
296
|
```javascript
|
|
297
|
-
const status = await fetch('http://127.0.0.1:
|
|
297
|
+
const status = await fetch('http://127.0.0.1:5167/api/status').then(r => r.json());
|
|
298
298
|
|
|
299
|
-
const response = await fetch('http://127.0.0.1:
|
|
299
|
+
const response = await fetch('http://127.0.0.1:5167/api/shell/execute', {
|
|
300
300
|
method: 'POST',
|
|
301
301
|
headers: {
|
|
302
302
|
'Content-Type': 'application/json',
|
|
@@ -313,8 +313,8 @@ console.log(result.stdout);
|
|
|
313
313
|
|
|
314
314
|
### ??job ?ㅽ듃由щ컢
|
|
315
315
|
```javascript
|
|
316
|
-
const status = await fetch('http://127.0.0.1:
|
|
317
|
-
const ws = new WebSocket(`ws://127.0.0.1:
|
|
316
|
+
const status = await fetch('http://127.0.0.1:5167/api/status').then(r => r.json());
|
|
317
|
+
const ws = new WebSocket(`ws://127.0.0.1:5167/events?token=${encodeURIComponent(status.wsToken)}`);
|
|
318
318
|
|
|
319
319
|
ws.onmessage = (message) => {
|
|
320
320
|
const event = JSON.parse(message.data);
|
|
@@ -322,7 +322,7 @@ ws.onmessage = (message) => {
|
|
|
322
322
|
if (event.type === 'ShellCompleted') console.log('done', event.payload.jobId);
|
|
323
323
|
};
|
|
324
324
|
|
|
325
|
-
await fetch('http://127.0.0.1:
|
|
325
|
+
await fetch('http://127.0.0.1:5167/api/shell/jobs', {
|
|
326
326
|
method: 'POST',
|
|
327
327
|
headers: {
|
|
328
328
|
'Content-Type': 'application/json',
|
package/launch-bridge.cjs
CHANGED
|
@@ -87,7 +87,7 @@ Usage:
|
|
|
87
87
|
mindexec [start] [options] [node-options]
|
|
88
88
|
npx mindexec-ai [options]
|
|
89
89
|
|
|
90
|
-
Runs the MindExec local app and bridge on http://localhost:
|
|
90
|
+
Runs the MindExec local app and bridge on http://localhost:5167/mindcanvas by default.
|
|
91
91
|
|
|
92
92
|
Options:
|
|
93
93
|
--workspace <path>
|
|
@@ -95,7 +95,7 @@ Options:
|
|
|
95
95
|
--no-open Do not open the local app in the default browser
|
|
96
96
|
|
|
97
97
|
Environment:
|
|
98
|
-
BRIDGE_PORT Local bridge port. Default:
|
|
98
|
+
BRIDGE_PORT Local bridge port. Default: 5167
|
|
99
99
|
WORKSPACE_PATH Workspace root. Overridden by --workspace when both are set
|
|
100
100
|
BRIDGE_TOKEN Fixed token for protected REST APIs
|
|
101
101
|
MINDEXEC_WEB_ROOT Published MindCanvas wwwroot override. Default: package wwwroot
|
package/package.json
CHANGED
package/port-guard.cjs
CHANGED
|
@@ -5,7 +5,7 @@ const { promisify } = require('util');
|
|
|
5
5
|
const execFileAsync = promisify(execFile);
|
|
6
6
|
const DEFAULT_WAIT_MS = 3500;
|
|
7
7
|
|
|
8
|
-
function normalizePort(value, fallback =
|
|
8
|
+
function normalizePort(value, fallback = 5167) {
|
|
9
9
|
const parsed = Number.parseInt(String(value || '').trim(), 10);
|
|
10
10
|
return Number.isInteger(parsed) && parsed > 0 && parsed <= 65535
|
|
11
11
|
? parsed
|
package/remote-hub.js
CHANGED
|
@@ -2,7 +2,7 @@ import net from 'net';
|
|
|
2
2
|
import os from 'os';
|
|
3
3
|
import crypto from 'crypto';
|
|
4
4
|
|
|
5
|
-
const DEFAULT_REMOTE_HUB_PORT =
|
|
5
|
+
const DEFAULT_REMOTE_HUB_PORT = 5199;
|
|
6
6
|
const DEFAULT_REMOTE_HUB_HOST = '0.0.0.0';
|
|
7
7
|
const DEFAULT_HEARTBEAT_MS = 5000;
|
|
8
8
|
const DEFAULT_AGENT_TASK_TIMEOUT_MS = 120000;
|
|
@@ -491,7 +491,7 @@ async function loadCss3DManager() {
|
|
|
491
491
|
console,
|
|
492
492
|
document,
|
|
493
493
|
location: {
|
|
494
|
-
origin: 'http://localhost:
|
|
494
|
+
origin: 'http://localhost:5167'
|
|
495
495
|
},
|
|
496
496
|
navigator: {
|
|
497
497
|
clipboard: {
|
|
@@ -598,7 +598,7 @@ function encodeRemoteBinaryFrame(metadata, payload = new Uint8Array([0xff, 0xd8,
|
|
|
598
598
|
|
|
599
599
|
function buildMonitorNode(devices, hubStatus, latestTaskBatch = null, recentTaskBatches = [], lastError = '', nodeId = 'remote-fleet-render-smoke') {
|
|
600
600
|
const connected = devices.filter(device => device.Connected).length;
|
|
601
|
-
const endpoint = hubStatus.agentEndpoint || '127.0.0.1:
|
|
601
|
+
const endpoint = hubStatus.agentEndpoint || '127.0.0.1:5199';
|
|
602
602
|
const pairToken = hubStatus.pairToken || 'render-smoke-token';
|
|
603
603
|
const hostTargetState = hubStatus.hostTargetActive
|
|
604
604
|
? (hubStatus.hostTargetNodeId === nodeId ? 'hosting' : 'other-monitor')
|
|
@@ -665,7 +665,7 @@ function createRemoteFleetTemplateShell(document, focusDeviceId = '', nodeId = '
|
|
|
665
665
|
}
|
|
666
666
|
|
|
667
667
|
function buildDeviceNode(device, hubStatus) {
|
|
668
|
-
const endpoint = hubStatus.agentEndpoint || '127.0.0.1:
|
|
668
|
+
const endpoint = hubStatus.agentEndpoint || '127.0.0.1:5199';
|
|
669
669
|
return {
|
|
670
670
|
id: 'remote-device-render-smoke',
|
|
671
671
|
contentType: 'memo',
|
package/server.js
CHANGED
|
@@ -2049,7 +2049,7 @@ async function trySendPackagedWebAppAsset(req, res, mountPath) {
|
|
|
2049
2049
|
}
|
|
2050
2050
|
|
|
2051
2051
|
// Static file serving for assets (direct image loading - bypasses base64 encoding)
|
|
2052
|
-
// This allows browsers to directly fetch images via http://127.0.0.1:
|
|
2052
|
+
// This allows browsers to directly fetch images via http://127.0.0.1:5167/assets/filename.png
|
|
2053
2053
|
app.use('/assets', async (req, res, next) => {
|
|
2054
2054
|
const originalUrl = String(req.originalUrl || '').toLowerCase();
|
|
2055
2055
|
if (originalUrl.includes('/assets/thumbs/')) {
|
package/start-bridge.bat
CHANGED
package/start-bridge.sh
CHANGED
|
@@ -30,7 +30,7 @@ normalize_dir_path() {
|
|
|
30
30
|
|
|
31
31
|
WORKSPACE_PATH="${WORKSPACE_PATH:-$(cd "$SCRIPT_DIR/.." && pwd -P)}"
|
|
32
32
|
WORKSPACE_PATH="$(normalize_dir_path "$WORKSPACE_PATH")"
|
|
33
|
-
BRIDGE_PORT="${BRIDGE_PORT:-
|
|
33
|
+
BRIDGE_PORT="${BRIDGE_PORT:-5167}"
|
|
34
34
|
RUNTIME_MARKER_FILE=".bridge-runtime"
|
|
35
35
|
CURRENT_RUNTIME="$(node -p "process.platform + '-' + process.arch")"
|
|
36
36
|
|
package/wwwroot/appsettings.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as E,j as e}from"./vendor-react-BXzpOyCS.js";import{a as U}from"./index-CQMKCp-t.js";import{r as te}from"./productionAdapterConfig-C5jfk6oG.js";import{R as d}from"./app-runtime-xD2Z3NdN.js";import{getSupabaseBrowserClient as re}from"./supabaseAuthAdapter-DA43DeSY.js";import{an as _e,R as ge,D as Ee,b0 as Se,aQ as De,b1 as ye,P as we,aH as xe,b2 as Ae,j as Ce,q as Ie,W as Ne,b3 as Re,c as je,b4 as ke,e as Oe,aA as Pe}from"./vendor-icons-DE3gIReG.js";import"./canvas-runtime-BbicBcOj.js";const Le=!1,Me="hold-release",Te=[{id:"cloud-auth-billing",label:"Secure cloud/auth/billing adapter closure",uiLabel:"Cloud/auth/billing adapter",state:"blocked-live-proof",requiredProof:["Dodo checkout live smoke with fresh Supabase session","Supabase provider read-only smoke with fresh session","Supabase provider write/admin mutation smoke with explicit admin values","Original launch proof supabaseLeakedPasswordProtection remains required as artifact-backed security proof","Original launch proof bolaIdorNegativeGate remains required as artifact-backed 20-user authorization proof","Original launch proof activeEditorHttpGate remains required as artifact-backed active editor load proof","Original launch proof dodoSignedSmoke remains required as signed webhook proof","Original launch proof dodoCheckoutDisabled remains required as fail-closed checkout proof","Original launch proof dodoSandboxWebhook remains required as real sandbox webhook proof","Original launch proof deploymentHardening.webCaptureWorkerSsrfRedirectGuard remains required as capture hardening proof","Original launch proof deploymentHardening.uploadFileSizeValidation remains required as upload hardening proof","Original launch proof deploymentHardening.dodoWebhookReplayGuard remains required as webhook replay hardening proof"],uiProof:"Dodo checkout, Supabase read-only, cloud write, and admin mutation proof need fresh provider inputs.",requiredInputs:["VITE_MINDEXEC_SUPABASE_URL","VITE_MINDEXEC_SUPABASE_PUBLISHABLE_KEY","VITE_MINDEXEC_DODO_CHECKOUT_FUNCTION_URL","MINDEXEC_SUPABASE_PROVIDER_SESSION_JSON","MINDEXEC_DODO_CHECKOUT_LIVE_CONFIRM","MINDEXEC_SUPABASE_PROVIDER_LIVE_CONFIRM","MINDEXEC_SUPABASE_PROVIDER_WRITE_CONFIRM","MINDEXEC_SUPABASE_PROVIDER_ADMIN_MUTATION_CONFIRM","MINDEXEC_SUPABASE_PROVIDER_ADMIN_PRICE_STAGE","MINDEXEC_SUPABASE_PROVIDER_ADMIN_LTD_LIMIT","MINDEXEC_ORIGINAL_LAUNCH_PROOF_JSON"],uiCommand:"npm run verify:release-blocker-preflight",proofCommands:[{label:"Dodo checkout live smoke",command:"npm run verify:dodo-checkout-live-smoke",mode:"opt-in-live-proof",liveCall:!0,hostAffecting:!1,defaultGate:!1,requiredInputs:["VITE_MINDEXEC_SUPABASE_URL","VITE_MINDEXEC_SUPABASE_PUBLISHABLE_KEY","VITE_MINDEXEC_DODO_CHECKOUT_FUNCTION_URL","MINDEXEC_SUPABASE_PROVIDER_SESSION_JSON","MINDEXEC_DODO_CHECKOUT_LIVE_CONFIRM"]},{label:"Supabase provider read-only smoke",command:"npm run verify:supabase-provider-live-smoke",mode:"opt-in-live-proof",liveCall:!0,hostAffecting:!1,defaultGate:!1,requiredInputs:["VITE_MINDEXEC_SUPABASE_URL","VITE_MINDEXEC_SUPABASE_PUBLISHABLE_KEY","MINDEXEC_SUPABASE_PROVIDER_SESSION_JSON","MINDEXEC_SUPABASE_PROVIDER_LIVE_CONFIRM"]},{label:"Supabase provider write/admin mutation smoke",command:"npm run verify:supabase-provider-write-smoke",mode:"opt-in-live-proof",liveCall:!0,hostAffecting:!1,defaultGate:!1,requiredInputs:["VITE_MINDEXEC_SUPABASE_URL","VITE_MINDEXEC_SUPABASE_PUBLISHABLE_KEY","MINDEXEC_SUPABASE_PROVIDER_SESSION_JSON","MINDEXEC_SUPABASE_PROVIDER_WRITE_CONFIRM","MINDEXEC_SUPABASE_PROVIDER_ADMIN_MUTATION_CONFIRM","MINDEXEC_SUPABASE_PROVIDER_ADMIN_PRICE_STAGE","MINDEXEC_SUPABASE_PROVIDER_ADMIN_LTD_LIMIT"]},{label:"Original launch proof artifacts",command:"npm run verify:original-launch-proof-artifacts",mode:"opt-in-proof-file",liveCall:!1,hostAffecting:!1,defaultGate:!1,requiredInputs:["MINDEXEC_ORIGINAL_LAUNCH_PROOF_JSON"]}]},{id:"agent-webresearch-codemaster",label:"Agent execution and WebResearch adapter closure",uiLabel:"Agent and CodeMaster provider depth",state:"blocked-provider-depth",requiredProof:["Real provider-backed diff/apply proof stays bounded to disposable workspace evidence","Cloud execution adapter proof avoids deploy, publish, billing, and unsafe file mutations","Concept embedding live proof keeps the provider API key server-side and opt-in only"],uiProof:"Live provider diff/apply and cloud execution proof remain opt-in and bounded.",requiredInputs:["MINDEXEC_CODEX_LIVE_READONLY_CONFIRM","MINDEXEC_CODEX_LIVE_TEMP_WRITE_CONFIRM","MINDEXEC_CODEX_LIVE_PROJECT_WRITE_CONFIRM","MINDEXEC_CODEMASTER_CLOUD_EXECUTION_PROOF_JSON","MINDEXEC_CONCEPT_EMBED_LIVE_CONFIRM","MINDEXEC_CONCEPT_EMBED_API_KEY"],uiCommand:"npm run verify:codemaster-codex-live-project-write-smoke",proofCommands:[{label:"Codex live read-only provider smoke",command:"npm run verify:codemaster-codex-live-readonly-smoke",mode:"opt-in-live-proof",liveCall:!0,hostAffecting:!1,defaultGate:!1,requiredInputs:["MINDEXEC_CODEX_LIVE_READONLY_CONFIRM"]},{label:"Codex live temp-write provider smoke",command:"npm run verify:codemaster-codex-live-temp-write-smoke",mode:"opt-in-live-proof",liveCall:!0,hostAffecting:!1,defaultGate:!1,requiredInputs:["MINDEXEC_CODEX_LIVE_TEMP_WRITE_CONFIRM"]},{label:"Codex live project-write provider smoke",command:"npm run verify:codemaster-codex-live-project-write-smoke",mode:"opt-in-live-proof",liveCall:!0,hostAffecting:!1,defaultGate:!1,requiredInputs:["MINDEXEC_CODEX_LIVE_PROJECT_WRITE_CONFIRM"]},{label:"CodeMaster cloud execution adapter proof",command:"npm run verify:codemaster-cloud-execution-adapter-proof",mode:"opt-in-proof-file",liveCall:!1,hostAffecting:!1,defaultGate:!1,requiredInputs:["MINDEXEC_CODEMASTER_CLOUD_EXECUTION_PROOF_JSON"]},{label:"Concept embedding live provider smoke",command:"npm run verify:concept-embedding-live-smoke",mode:"opt-in-live-proof",liveCall:!0,hostAffecting:!1,defaultGate:!1,requiredInputs:["MINDEXEC_CONCEPT_EMBED_LIVE_CONFIRM","MINDEXEC_CONCEPT_EMBED_API_KEY"]}]},{id:"mindcanvas-ai-media-provider",label:"MindCanvas AI media provider closure",uiLabel:"MindCanvas AI media provider",state:"blocked-provider-proof",requiredProof:["Provider-backed image generation proof from the MindCanvas node workflow","Provider-backed video generation proof from the MindCanvas node workflow","No raw provider secrets appear in browser storage, docs, logs, or release artifacts"],uiProof:"Image and video generation need sanitized provider proof from the node workflow.",requiredInputs:["MINDEXEC_MEDIA_PROVIDER_LIVE_CONFIRM","MINDEXEC_MEDIA_PROVIDER_PROOF_JSON"],uiCommand:"npm run verify:mindcanvas-media-provider-proof",proofCommands:[{label:"MindCanvas AI media provider proof",command:"npm run verify:mindcanvas-media-provider-proof",mode:"opt-in-proof-file",liveCall:!1,hostAffecting:!1,defaultGate:!1,requiredInputs:["MINDEXEC_MEDIA_PROVIDER_LIVE_CONFIRM","MINDEXEC_MEDIA_PROVIDER_PROOF_JSON"]}]},{id:"remote-fast-os-input",label:"RemoteFast opt-in OS-input smoke",uiLabel:"RemoteFast host OS input",state:"blocked-operator-confirmation",requiredProof:["Bounded pointer/key smoke against the host with cursor restore evidence"],uiProof:"Pointer/key smoke affects the host and must stay explicitly confirmed.",requiredInputs:["MINDEXEC_REMOTE_FAST_OS_INPUT_CONFIRM"],uiCommand:"npm run verify:remote-monitor-remote-fast-os-input-smoke",proofCommands:[{label:"RemoteFast bounded host OS-input smoke",command:"npm run verify:remote-monitor-remote-fast-os-input-smoke",mode:"opt-in-host-proof",liveCall:!1,hostAffecting:!0,defaultGate:!1,requiredInputs:["MINDEXEC_REMOTE_FAST_OS_INPUT_CONFIRM"]}]},{id:"release-approval",label:"Cloudflare/npm release approval",uiLabel:"Cloudflare/npm approval",state:"hold-release",requiredProof:["Green local gates after live proofs","Reviewed release notes","Explicit user approval before Cloudflare deploy or npm publish","Original `ref/~MindExec` launch proof manifest parity reviewed before release approval"],uiProof:"Deploy and npm publish require a reviewed proof packet and explicit user approval.",requiredInputs:["manual user approval"],uiCommand:"npm run verify:release-proof-packet",proofCommands:[{label:"Cloudflare Pages release pass",command:"manual-release-pass:cloudflare-pages",mode:"manual-release-approval",liveCall:!0,hostAffecting:!1,defaultGate:!1,requiredInputs:["manual user approval"]},{label:"npm package release pass",command:"manual-release-pass:npm-package",mode:"manual-release-approval",liveCall:!0,hostAffecting:!1,defaultGate:!1,requiredInputs:["manual user approval"]}]}],H={releaseReady:Le,releasePosture:Me,blockers:Te},ne="admin-dashboard-data";function v(t){return t&&typeof t=="object"&&!Array.isArray(t)?t:{}}function D(t){return Array.isArray(t)?t:[]}function f(t,a=""){return typeof t=="string"&&t.trim()?t.trim():a}function F(t,a=0){const r=typeof t=="number"?t:Number(t);return Number.isFinite(r)?r:a}function T(t,a=0){return Math.round(F(t,a))}function u(t){return T(t).toLocaleString()}function j(t){return`$${F(t).toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2})}`}function L(t){return`${F(t).toFixed(1)}%`}function V(t){return`${u(t)}P`}function se(t){const a=f(t);if(!a)return"--/--";const r=new Date(a);return Number.isNaN(r.getTime())?a.slice(0,5):`${String(r.getUTCMonth()+1).padStart(2,"0")}/${String(r.getUTCDate()).padStart(2,"0")}`}function Ue(t){const a=f(t).toLowerCase();if(/(failed|error|suspended|revoked|high|danger|blocked)/.test(a))return"danger";if(/(pending|review|grace|warn|manual|locked)/.test(a))return"warn";if(/(active|ok|processed|healthy|paid|closed|enforced)/.test(a))return"ok"}function _(t,a,r="-"){for(const n of a){const s=t[n];if(s!=null&&String(s).trim())return String(s)}return r}function Y(t,a){return t.map(r=>{const n=v(r),s=a.find(c=>n[c]!==void 0)??a[0];return{label:se(n.date??n.day??n.created_at),value:Math.max(0,F(n[s]))}})}function Fe(t){const a=v(t),r=v(a.launch_overview),n=v(a.billing_control),s=v(a.credit_totals),c=v(a.refund_rate),h=Y(D(a.daily_signups),["count","signup_count"]),l=Y(D(a.daily_revenue),["revenue","amount"]),y=D(a.referrers).map(b=>{const i=v(b);return[_(i,["referrer"],"direct"),u(i.visit_count??i.count)]}),O=D(a.countries).map(b=>{const i=v(b);return[_(i,["country"],"--"),u(i.visit_count??i.count),u(i.unique_users)]}),A=D(a.heavy_users).map(b=>{const i=v(b);return[_(i,["email","user_email","display_name"],"unknown"),`${u(i.boards_count??i.board_count)} boards`]}),C=D(a.entitlements).map(b=>{const i=v(b);return[_(i,["email","user_email"],"unknown"),_(i,["plan_key","plan","normalized_plan_key"],"free"),_(i,["status","entitlement_status"],"active"),_(i,["ends_at","current_period_end","renews_at"],"-")]}),I=D(a.refunds).map(b=>{const i=v(b);return[_(i,["email","user_email"],"unknown"),j(i.amount),_(i,["risk","revocation_status"],"review"),_(i,["review_status","status"],"open")]}),P=D(a.credit_ledger).map(b=>{const i=v(b);return[se(i.created_at),_(i,["email","user_email","reason"],"unknown"),V(i.delta??i.amount??i.credit_delta),_(i,["reason","event_type","source"],"-")]}),N=D(a.feature_limits).map(b=>{const i=v(b);return[_(i,["feature","feature_key"],"Feature"),_(i,["free_limit","free"],"-"),_(i,["pro_limit","pro","limit_value"],"-"),_(i,["status","entitlement_status"],"enforced")]}),R=D(a.user_funnel).map(b=>{const i=v(b);return{label:_(i,["stage","label"],"Stage"),count:T(i.count??i.user_count),rate:F(i.rate??i.conversion_rate)}});return{source:"supabase-admin-dashboard-data",fetchedAt:f(a.fetched_at,new Date().toISOString()),billingMode:f(r.billing_mode??n.billing_mode,"DODO_LIVE"),currency:f(r.currency_code??n.currency_code,"USD"),usdPerPoint:f(r.usd_per_point,"0.0002"),overviewKpis:[{label:"DAU",value:u(r.dau),tone:"ok"},{label:"WAU",value:u(r.wau),tone:"ok"},{label:"Activation",value:L(r.activation_rate),tone:"ok"},{label:"AI usage",value:L(r.ai_usage_rate),tone:"ok"},{label:"Paid conversion",value:L(r.paid_conversion_rate),tone:"warn"},{label:"D1 retention",value:L(r.d1_retention_rate),tone:"warn"},{label:"D7 retention",value:L(r.d7_retention_rate),tone:"warn"},{label:"Avg points / user",value:V(r.avg_points_spent_per_user)},{label:"AI cost estimate",value:j(r.ai_cost_estimate_usd)},{label:"Gross margin estimate",value:j(r.gross_margin_estimate_usd),tone:"ok"}],billingKpis:[{label:"Billing mode",value:f(n.billing_mode??r.billing_mode,"DODO_LIVE"),tone:"ok"},{label:"Webhook received 24h",value:u(n.webhook_received_24h??r.webhook_received_24h),tone:"ok"},{label:"Webhook failed 24h",value:u(n.webhook_failures_24h??r.webhook_failures_24h),tone:"warn"},{label:"Pending events",value:u(n.pending_events),tone:"warn"},{label:"Active Pro users",value:u(n.pro_active_users??n.active_entitlements),tone:"ok"},{label:"Manual reviews",value:u(n.manual_reviews),tone:"warn"},{label:"Locked boards",value:u(n.locked_boards),tone:"warn"},{label:"Create blocked today",value:u(n.create_blocked_today)}],operatingHealth:[{label:"Signups today",value:u(r.signups_today),tone:"ok"},{label:"Active users today",value:u(r.active_users_today),tone:"ok"},{label:"Points spent users",value:u(r.points_spent_users)},{label:"AI failures 24h",value:u(r.ai_failures_24h),tone:Ue(r.ai_failures_24h)??"warn"},{label:"Save failures 24h",value:u(r.save_failures_24h),tone:"ok"},{label:"Webhook failures 24h",value:u(r.webhook_failures_24h),tone:"warn"}],revenueBand:[{label:"Revenue today",value:j(r.revenue_today),tone:"ok"},{label:"7 day revenue",value:j(r.revenue_7_days),tone:"ok"},{label:"30 day revenue",value:j(r.revenue_30_days)},{label:"Total revenue",value:j(r.total_revenue)},{label:"Paid users",value:u(r.paid_users)},{label:"Wallet liability",value:V(r.total_credit_balance??s.total_credit_balance),tone:"warn"}],signupTrend:h,revenueTrend:l,referrerRows:y,countryRows:O,heavyUserRows:A,entitlementRows:C,webhookRows:[["24h received","payment/provider","processed",u(n.webhook_received_24h??r.webhook_received_24h)],["24h failed","payment/provider","manual-review",u(n.webhook_failures_24h??r.webhook_failures_24h)],["Refund rate","refunds","watch",L(c.refund_rate??c.rate)]],refundRows:I,creditRows:P,featureLimitRows:N,funnelRows:R,auditRows:[]}}async function W(t){var y,O,A,C;const a=te(t);if(!a.adminData.canAttempt)throw d.emit("adminDashboard.provider.skipped",{mode:a.adminData.mode}),new Error(`Secure admin data adapter is not ready: ${a.adminData.mode}`);const r=re(t);if(!r)throw d.emit("adminDashboard.provider.skipped",{mode:"config-missing"}),new Error("Supabase browser client is not available for admin data.");const{data:n,error:s}=await r.auth.getSession();if(s||!((y=n.session)!=null&&y.access_token))throw d.emit("adminDashboard.provider.sessionMissing",{message:(s==null?void 0:s.message)??"missing-session"}),new Error("Secure admin data requires a Supabase-authenticated session.");const{data:c,error:h}=await r.auth.getUser(),l=(O=c.user)==null?void 0:O.id;if(h||!l)throw d.emit("adminDashboard.provider.sessionMissing",{message:(h==null?void 0:h.message)??"missing-user"}),new Error("Secure admin data requires a verified Supabase user.");return{config:a,accessToken:n.session.access_token,userId:l,email:((C=(A=c.user)==null?void 0:A.email)==null?void 0:C.toLowerCase())??""}}async function X(t,a){await W(t);const r=re(t);if(!r)throw new Error("Supabase browser client is not available for admin data.");const{data:n,error:s}=await r.functions.invoke(ne,{body:a});if(s)throw d.emit("adminDashboard.provider.failed",{operation:f(a.action,"summary"),message:s.message}),s;if(n!=null&&n.error){const c=f(n.message??n.error,"admin-dashboard-data failed");throw d.emit("adminDashboard.provider.failed",{operation:f(a.action,"summary"),message:c}),new Error(c)}return n??{}}async function Be(t){d.emit("adminDashboard.provider.summary.requested",{functionName:ne});const a=await X(t,{action:"summary"}),r=Fe(a.summary);return d.emit("adminDashboard.provider.summary.loaded",{source:r.source,overviewMetrics:r.overviewKpis.length,signupPoints:r.signupTrend.length}),r}async function Xe(t,a){if(d.emit("adminDashboard.provider.userSearch.requested",{hasQuery:!!a.trim()}),!a.trim())return null;const r=await X(t,{action:"user-search",query:a}),n=v(r.user);if(!Object.keys(n).length)return d.emit("adminDashboard.provider.userSearch.loaded",{found:!1}),null;const s=v(n.profile),c=v(n.board_stats),h=v(n.activity),l=D(n.timeline),y={email:f(s.email,"unknown"),plan:f(s.plan_type,"Free"),boards:T(c.boards_count??c.board_count),points:T(s.credits_balance??h.credit_balance??h.points_balance),country:f(s.country,"--"),lastSeen:f(s.last_seen_at,f(s.created_at,"unknown")),timelineCount:l.length};return d.emit("adminDashboard.provider.userSearch.loaded",{found:!0,boards:y.boards}),y}async function Ve(t,a,r){const n=await W(t);d.emit("adminDashboard.provider.settings.requested",{priceStage:a,ltdLimit:r});const s=await X(t,{action:"save-settings",price_stage:a,ltd_limit:r}),c={mode:n.config.adminData.mode,canAttempt:!0,priceStage:f(s.price_stage,a),ltdLimit:T(s.ltd_limit,r),updatedAt:f(s.updated_at,new Date().toISOString())};return d.emit("adminDashboard.provider.settings.saved",{priceStage:c.priceStage,ltdLimit:c.ltdLimit}),c}async function qe(t,a){const r=await W(t);d.emit("adminDashboard.provider.emergencyClose.requested",{ltdLimit:a});const n=await X(t,{action:"emergency-close",price_stage:"CLOSED",ltd_limit:a}),s={mode:r.config.adminData.mode,canAttempt:!0,priceStage:f(n.price_stage,"CLOSED"),ltdLimit:T(n.ltd_limit,a),updatedAt:f(n.updated_at,new Date().toISOString())};return d.emit("adminDashboard.provider.emergencyClose.staged",{priceStage:s.priceStage,ltdLimit:s.ltdLimit}),s}const K="mindexec.react.admin.dashboard.v1",$e=["STANDARD","EARLY","LTD","CLOSED"],k={priceStage:"EARLY",ltdLimit:100,lastAction:"Admin dashboard restored as a local React shell.",updatedAtUtc:""};function Ge(){return te(U())}const He=[{key:"overview",label:"Overview",icon:Se},{key:"billing",label:"Billing Control",icon:De},{key:"entitlements",label:"Entitlements",icon:ye},{key:"dodo",label:"Dodo Events",icon:we},{key:"refunds",label:"Refunds",icon:xe},{key:"credits",label:"Credits",icon:Ae},{key:"limits",label:"Feature Limits",icon:Ce},{key:"funnel",label:"User Funnel",icon:Ie},{key:"explorer",label:"User Explorer",icon:Ne},{key:"release",label:"Release Readiness",icon:Re},{key:"audit",label:"Audit Log",icon:je}],We=[{label:"06/08",value:2},{label:"06/09",value:4},{label:"06/10",value:5},{label:"06/11",value:8},{label:"06/12",value:7},{label:"06/13",value:13},{label:"06/14",value:11},{label:"06/15",value:16},{label:"06/16",value:19},{label:"06/17",value:18},{label:"06/18",value:23},{label:"06/19",value:26},{label:"06/20",value:31},{label:"06/21",value:34}],Ke=[{label:"06/08",value:0},{label:"06/09",value:12},{label:"06/10",value:18},{label:"06/11",value:12},{label:"06/12",value:29},{label:"06/13",value:41},{label:"06/14",value:38},{label:"06/15",value:49},{label:"06/16",value:64},{label:"06/17",value:72},{label:"06/18",value:81},{label:"06/19",value:94},{label:"06/20",value:108},{label:"06/21",value:124}],G=[{email:"maya@buildloop.ai",plan:"Pro",boards:18,points:1240,country:"US",lastSeen:"today"},{email:"kenji@solo-studio.jp",plan:"Early",boards:9,points:640,country:"JP",lastSeen:"today"},{email:"linh@vietlaunch.dev",plan:"Free",boards:5,points:120,country:"VN",lastSeen:"yesterday"},{email:"alex@indieops.co",plan:"LTD",boards:32,points:2840,country:"SG",lastSeen:"2d ago"}],Je=[{label:"DAU",value:"128",tone:"ok"},{label:"WAU",value:"614",tone:"ok"},{label:"Activation",value:"41.8%",tone:"ok"},{label:"AI usage",value:"63.2%",tone:"ok"},{label:"Paid conversion",value:"4.6%",tone:"warn"},{label:"D1 retention",value:"38.1%",tone:"warn"},{label:"D7 retention",value:"22.7%",tone:"warn"},{label:"Avg points / user",value:"318P"},{label:"AI cost estimate",value:"$74.82"},{label:"Gross margin estimate",value:"$418.10",tone:"ok"}],ze=[{label:"Billing mode",value:"DODO_LIVE_GATED",tone:"warn"},{label:"Webhook received 24h",value:"19",tone:"ok"},{label:"Webhook failed 24h",value:"1",tone:"warn"},{label:"Pending events",value:"3",tone:"warn"},{label:"Active Pro users",value:"28",tone:"ok"},{label:"Manual reviews",value:"2",tone:"warn"},{label:"Locked boards",value:"6",tone:"warn"},{label:"Create blocked today",value:"14"}],ie=[["06/21 18:41","admin@mindexec.local","Changed price stage draft to EARLY"],["06/21 16:10","system","Dodo webhook replay queued"],["06/20 23:55","admin@mindexec.local","Raised LTD capacity review flag"],["06/20 19:20","system","Credit ledger reconciliation completed"]],Ye=[["evt_4912","payment.succeeded","processed","$12.00 USD"],["evt_4911","subscription.created","processed","Pro monthly"],["evt_4910","payment.failed","manual-review","$12.00 USD"],["evt_4909","refund.requested","pending","$24.00 USD"]],Qe=[{label:"Visitor",count:1280,rate:100},{label:"Signup",count:214,rate:16.7},{label:"First board",count:132,rate:61.7},{label:"AI run",count:83,rate:62.8},{label:"Pricing visit",count:44,rate:53},{label:"Paid",count:11,rate:25}],Q=String(H.releaseReady),q=H.releasePosture,Ze=H.blockers.map(t=>{var a;return{id:t.id,label:t.uiLabel||t.label,state:t.state,proof:t.uiProof||t.requiredProof.join(" "),command:t.uiCommand||((a=t.proofCommands[0])==null?void 0:a.command)||"npm run verify:release-blocker-preflight",proofCommands:t.proofCommands.map(r=>({label:r.label,command:r.command,mode:r.mode,liveCall:r.liveCall,hostAffecting:r.hostAffecting,defaultGate:r.defaultGate,requiredInputs:r.requiredInputs}))}}),ea={source:"local",fetchedAt:"",billingMode:"DODO_LIVE_GATED",currency:"USD",usdPerPoint:"0.0002",overviewKpis:Je,billingKpis:ze,operatingHealth:[{label:"Signups today",value:"34",tone:"ok"},{label:"Active users today",value:"128",tone:"ok"},{label:"Points spent users",value:"77"},{label:"AI failures 24h",value:"2",tone:"warn"},{label:"Save failures 24h",value:"0",tone:"ok"},{label:"Webhook failures 24h",value:"1",tone:"warn"}],revenueBand:[{label:"Revenue today",value:"$124.00",tone:"ok"},{label:"7 day revenue",value:"$530.00",tone:"ok"},{label:"30 day revenue",value:"$1,870.00"},{label:"Total revenue",value:"$4,418.00"},{label:"Paid users",value:"28"},{label:"Wallet liability",value:"184,200P",tone:"warn"}],signupTrend:We,revenueTrend:Ke,referrerRows:[["direct","312"],["x.com","128"],["reddit","84"],["youtube","62"]],countryRows:[["US","41%"],["JP","18%"],["SG","11%"],["VN","8%"]],heavyUserRows:G.slice(0,4).map(t=>[t.email.split("@")[0],`${t.boards} boards`]),entitlementRows:G.map(t=>[t.email,t.plan,t.plan==="Free"?"free":"active",t.plan==="Free"?"-":"2026-07-21"]),webhookRows:Ye,refundRows:[["maya@buildloop.ai","$12.00","low","closed"],["alex@indieops.co","$24.00","medium","open"],["unknown@blocked.test","$12.00","high","manual review"]],creditRows:[["18:41","maya@buildloop.ai","+1000P","monthly grant"],["18:20","kenji@solo-studio.jp","-120P","AI task"],["17:52","alex@indieops.co","-280P","image generation"]],featureLimitRows:[["Cloud boards","3","Unlimited","enforced"],["AI runs / month","20","1000","enforced"],["Image uploads","100MB","10GB","watching"],["Private boards","0","Unlimited","enforced"]],funnelRows:Qe,auditRows:ie};function aa(t,a){const r=Math.max(...a.map(n=>n.value),1);return Math.max(8,Math.round(t/r*100))}function ta(t){return t?`admin-kpi-card--${t}`:""}function $(t){return t.map(a=>({label:a[0]??"-",value:a[1]??"-"}))}function ra(t){return"timelineCount"in t?t.timelineCount:9}function oe(t){const a=typeof t=="number"?t:Number(t);return Number.isFinite(a)?Math.max(0,Math.min(1e4,Math.round(a))):k.ltdLimit}function le(t){if(!t||typeof t!="object")return k;const a=t,r=$e.includes(a.priceStage)?String(a.priceStage):k.priceStage,n=typeof a.lastAction=="string"&&a.lastAction.trim()?a.lastAction.slice(0,240):k.lastAction,s=typeof a.updatedAtUtc=="string"?a.updatedAtUtc:"";return{priceStage:r,ltdLimit:oe(a.ltdLimit),lastAction:n,updatedAtUtc:s}}function na(){if(typeof window>"u")return k;try{const t=window.localStorage.getItem(K),a=t?le(JSON.parse(t)):k;return d.emit("adminDashboard.localDraft.loaded",{source:t?"stored":"default",priceStage:a.priceStage,ltdLimit:a.ltdLimit}),a}catch(t){return d.emit("adminDashboard.localDraft.failed",{operation:"load",message:t instanceof Error?t.message:String(t)}),k}}function Z(t,a){const r=le({...t,updatedAtUtc:new Date().toISOString()});if(typeof window>"u")return r;try{window.localStorage.setItem(K,JSON.stringify(r)),d.emit("adminDashboard.localDraft.saved",{source:a,priceStage:r.priceStage,ltdLimit:r.ltdLimit})}catch(n){d.emit("adminDashboard.localDraft.failed",{operation:"save",source:a,message:n instanceof Error?n.message:String(n)})}return r}function ha(){const[t]=E.useState(na),[a,r]=E.useState("overview"),[n,s]=E.useState(!1),c=E.useMemo(()=>Ge(),[]),h=c.adminData.canAttempt,[l,y]=E.useState(ea),[O,A]=E.useState(null),[C,I]=E.useState(t.priceStage),[P,N]=E.useState(t.ltdLimit),[R,b]=E.useState(""),[i,de]=E.useState(""),[ce,g]=E.useState(t.lastAction),[ue,J]=E.useState(()=>new Date),me=E.useMemo(()=>{if(!i.trim())return null;const o=i.trim().toLowerCase();return G.find(m=>m.email.toLowerCase().includes(o))||null},[i]),w=l.source==="supabase-admin-dashboard-data"?O:me,pe=o=>{r(o),d.emit("adminDashboard.tab",{key:o})},fe=async()=>{if(s(!0),d.emit("adminDashboard.refresh"),h){try{const o=await Be(U());y(o),J(new Date(o.fetchedAt)),g("Secure Supabase admin snapshot refreshed.")}catch(o){const m=o instanceof Error?o.message:String(o);d.emit("adminDashboard.provider.refreshFailed",{message:m}),g(`Secure admin snapshot failed: ${m}. Local snapshot remains visible.`)}finally{s(!1)}return}window.setTimeout(()=>{J(new Date),g("Local admin snapshot refreshed. Wire Supabase read adapters before treating it as live production data."),s(!1)},260)},he=async o=>{o.preventDefault();const m=`Saved local settings draft: ${C}, LTD ${P}.`,p=Z({priceStage:C,ltdLimit:P,lastAction:m},"settings.form");if(d.emit("adminDashboard.settings.saved",{priceStage:p.priceStage,ltdLimit:p.ltdLimit}),I(p.priceStage),N(p.ltdLimit),g(p.lastAction),!!h)try{const S=await Ve(U(),p.priceStage,p.ltdLimit);I(S.priceStage),N(S.ltdLimit),g(`Secure admin settings saved: ${S.priceStage}, LTD ${S.ltdLimit}.`)}catch(S){const z=S instanceof Error?S.message:String(S);d.emit("adminDashboard.provider.settingsFailed",{message:z}),g(`Local settings draft saved, but secure provider save failed: ${z}`)}},ve=async()=>{const m=Z({priceStage:"CLOSED",ltdLimit:P,lastAction:"Emergency close staged locally. Real billing closure requires a secure admin adapter."},"emergency.close");if(d.emit("adminDashboard.emergency.closed",{priceStage:m.priceStage,ltdLimit:m.ltdLimit}),I(m.priceStage),N(m.ltdLimit),g(m.lastAction),!!h)try{const p=await qe(U(),m.ltdLimit);I(p.priceStage),N(p.ltdLimit),g(`Secure emergency close staged through admin provider: ${p.priceStage}, LTD ${p.ltdLimit}.`)}catch(p){const S=p instanceof Error?p.message:String(p);d.emit("adminDashboard.provider.emergencyFailed",{message:S}),g(`Emergency close staged locally, but secure provider close failed: ${S}`)}},be=async o=>{if(o.preventDefault(),de(R),d.emit("adminDashboard.user.search",{hasQuery:!!R.trim()}),!R.trim()){A(null),g("User explorer query cleared.");return}if(!h){g("User explorer searched local sample data.");return}try{const m=await Xe(U(),R);A(m),g(m?"User explorer loaded secure provider data.":"No secure provider user matched that query.")}catch(m){const p=m instanceof Error?m.message:String(m);d.emit("adminDashboard.provider.userSearchFailed",{message:p}),A(null),g(`Secure user explorer failed: ${p}`)}};return e.jsxs("div",{className:"page admin-dashboard-page","data-testid":"admin-dashboard-shell","data-admin-storage-key":K,"data-production-adapter-state":c.overallState,"data-admin-provider-mode":c.adminData.mode,"data-admin-provider-ready":c.adminData.canAttempt?"true":"false","data-client-secret-blocked":c.forbiddenClientSecretKeys.length>0?"true":"false",children:[e.jsxs("section",{className:"admin-hero",children:[e.jsxs("div",{children:[e.jsx("div",{className:"eyebrow",children:"Operations Console"}),e.jsx("h1",{children:"MindExec Admin Dashboard"}),e.jsx("p",{children:"React port of the original admin plugin: revenue, billing control, credits, limits, funnel, user explorer, and audit surfaces without loading the Blazor plugin runtime."})]}),e.jsxs("div",{className:"admin-hero-actions",children:[e.jsx("span",{className:"admin-badge","data-testid":"admin-dashboard-mode",children:h?"supabase-admin-provider":"local-admin-shell"}),e.jsxs("button",{className:"btn btn-secondary",type:"button",onClick:fe,disabled:n,"data-testid":"admin-refresh",children:[n?e.jsx(_e,{size:16,className:"spin-icon"}):e.jsx(ge,{size:16}),"Refresh"]})]})]}),e.jsxs("section",{className:"admin-status-strip","data-testid":"admin-status-strip",children:[e.jsx(B,{label:"Billing mode",value:l.billingMode}),e.jsx(B,{label:"Currency",value:l.currency}),e.jsx(B,{label:"USD / point",value:l.usdPerPoint}),e.jsx(B,{label:"Updated",value:ue.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})})]}),e.jsxs("section",{className:"admin-alert admin-alert--warning",children:[e.jsx(Ee,{size:18}),e.jsxs("div",{children:[e.jsx("strong",{children:h?"Secure admin provider ready":"Local React shell only"}),e.jsx("span",{"data-testid":"admin-last-action",children:ce})]})]}),e.jsx("nav",{className:"admin-tabs","aria-label":"Admin dashboard tabs","data-testid":"admin-tabs",children:He.map(o=>{const m=o.icon;return e.jsxs("button",{className:a===o.key?"is-active":"",type:"button",onClick:()=>pe(o.key),"data-testid":`admin-tab-${o.key}`,"data-admin-tab":o.key,children:[e.jsx(m,{size:16}),e.jsx("span",{children:o.label})]},o.key)})}),a==="overview"&&e.jsxs(e.Fragment,{children:[e.jsx(ee,{metrics:l.overviewKpis}),e.jsxs("section",{className:"admin-panel-grid admin-panel-grid--two",children:[e.jsx(x,{title:"Operating Health",metrics:l.operatingHealth}),e.jsx(x,{title:"Revenue Band",metrics:l.revenueBand})]}),e.jsxs("section",{className:"admin-panel-grid admin-panel-grid--two",children:[e.jsx(ae,{title:"Daily Signups",points:l.signupTrend}),e.jsx(ae,{title:"Daily Revenue",points:l.revenueTrend,money:!0})]}),e.jsxs("section",{className:"admin-panel-grid admin-panel-grid--three",children:[e.jsx(x,{title:"Top Referrers",metrics:$(l.referrerRows),compact:!0}),e.jsx(x,{title:"Countries",metrics:$(l.countryRows),compact:!0}),e.jsx(x,{title:"Heavy Users",metrics:$(l.heavyUserRows),compact:!0})]})]}),a==="billing"&&e.jsxs(e.Fragment,{children:[e.jsx(ee,{metrics:l.billingKpis}),e.jsxs("section",{className:"admin-panel-grid admin-panel-grid--three",children:[e.jsx(x,{title:"Webhook Status",metrics:[{label:"24h received",value:"19",tone:"ok"},{label:"24h failed",value:"1",tone:"warn"},{label:"Pending",value:"3",tone:"warn"},{label:"Last success",value:"18:41"}]}),e.jsx(x,{title:"Entitlement State",metrics:[{label:"Active",value:"28",tone:"ok"},{label:"Grace",value:"3",tone:"warn"},{label:"Suspended",value:"2",tone:"danger"},{label:"Revoked",value:"1"}]}),e.jsxs("form",{className:"admin-panel admin-settings-panel",onSubmit:he,"data-testid":"admin-settings-form",children:[e.jsxs("div",{className:"admin-panel-head",children:[e.jsx("h2",{children:"Price Controls"}),e.jsxs("button",{className:"btn btn-primary",type:"submit","data-testid":"admin-save-settings",children:[e.jsx(ke,{size:15}),"Save draft"]})]}),e.jsxs("label",{children:["Price stage",e.jsxs("select",{value:C,onChange:o=>I(o.target.value),"data-testid":"admin-price-stage",children:[e.jsx("option",{value:"STANDARD",children:"STANDARD"}),e.jsx("option",{value:"EARLY",children:"EARLY"}),e.jsx("option",{value:"LTD",children:"LTD"}),e.jsx("option",{value:"CLOSED",children:"CLOSED"})]})]}),e.jsxs("label",{children:["LTD limit",e.jsx("input",{type:"number",min:"0",value:P,onChange:o=>N(oe(o.target.value)),"data-testid":"admin-ltd-limit"})]}),e.jsxs("button",{className:"btn btn-secondary admin-danger-button",type:"button",onClick:ve,"data-testid":"admin-emergency-close",children:[e.jsx(Oe,{size:15}),"Stage emergency close"]})]})]})]}),a==="entitlements"&&e.jsx(M,{title:"Entitlements",columns:["User","Plan","Status","Renews"],rows:l.entitlementRows}),a==="dodo"&&e.jsx(M,{title:"Dodo Webhook Events",columns:["Event","Type","Status","Amount"],rows:l.webhookRows}),a==="refunds"&&e.jsx(M,{title:"Refund Reviews",columns:["User","Amount","Risk","Status"],rows:[...l.refundRows]}),a==="credits"&&e.jsx(M,{title:"Credit Ledger",columns:["Time","User","Delta","Reason"],rows:l.creditRows}),a==="limits"&&e.jsx(M,{title:"Feature Limits",columns:["Feature","Free","Pro","Status"],rows:l.featureLimitRows}),a==="funnel"&&e.jsx(ia,{rows:l.funnelRows}),a==="explorer"&&e.jsxs("section",{className:"admin-panel",children:[e.jsxs("div",{className:"admin-panel-head",children:[e.jsx("h2",{children:"User Explorer"}),e.jsx("span",{className:"admin-note",children:h?"Secure provider data":"Local sample data"})]}),e.jsxs("form",{className:"admin-search-row",onSubmit:be,"data-testid":"admin-user-search-form",children:[e.jsx("input",{"aria-label":"Search user",value:R,onChange:o=>b(o.target.value),placeholder:"email, domain, or segment","data-testid":"admin-user-query"}),e.jsxs("button",{className:"btn btn-primary",type:"submit","data-testid":"admin-user-search",children:[e.jsx(Pe,{size:15}),"Search"]})]}),i&&!w&&e.jsx("div",{className:"admin-empty","data-testid":"admin-user-empty",children:h?"No secure provider user matched that query.":"No local sample user matched that query."}),w&&e.jsxs("div",{className:"admin-user-card","data-testid":"admin-user-card",children:[e.jsx("strong",{children:w.email}),e.jsxs("span",{children:[w.plan," / ",w.country," / last seen ",w.lastSeen]}),e.jsx(x,{title:"User Snapshot",compact:!0,metrics:[{label:"Boards",value:String(w.boards)},{label:"Points",value:`${w.points}P`},{label:"Timeline",value:`${ra(w)} events`}]})]})]}),a==="release"&&e.jsx(sa,{blockers:Ze}),a==="audit"&&e.jsxs("section",{className:"admin-panel-grid admin-panel-grid--two",children:[e.jsx(oa,{}),e.jsx(M,{title:"Recent Setting Changes",columns:["Time","Admin","Action"],rows:l.auditRows.length?l.auditRows:ie,compact:!0})]})]})}function sa({blockers:t}){return e.jsxs("section",{className:"admin-release-readiness","data-testid":"admin-release-readiness-panel","data-release-ready":Q,"data-release-posture":q,"data-release-blocker-count":t.length,children:[e.jsxs("div",{className:"admin-panel-head",children:[e.jsxs("div",{children:[e.jsx("h2",{children:"Release Readiness"}),e.jsx("p",{className:"admin-release-summary",children:"Local gates are green enough for RC work, but release remains held until live proofs and explicit approval are complete."})]}),e.jsx("span",{className:"admin-badge admin-badge--hold","data-testid":"admin-release-posture",children:q})]}),e.jsxs("div",{className:"admin-release-grid",children:[e.jsx(x,{title:"Local RC State",compact:!0,metrics:[{label:"Release ready",value:Q,tone:"warn"},{label:"Posture",value:q,tone:"warn"},{label:"Blockers",value:String(t.length),tone:"warn"},{label:"Default deploy/publish",value:"blocked",tone:"ok"}]}),e.jsxs("article",{className:"admin-panel admin-panel--compact",children:[e.jsx("div",{className:"admin-panel-head",children:e.jsx("h2",{children:"Proof Packet"})}),e.jsxs("div",{className:"admin-release-command-list",children:[e.jsx("code",{children:"npm run verify:release-blocker-preflight"}),e.jsx("code",{children:"npm run verify:release-proof-packet"}),e.jsx("code",{children:"npm run check"}),e.jsx("code",{children:"npm run build"})]})]})]}),e.jsx("div",{className:"admin-release-blocker-list","data-testid":"admin-release-blocker-list",children:t.map(a=>e.jsxs("article",{className:"admin-release-blocker","data-testid":"admin-release-blocker","data-release-blocker-id":a.id,"data-release-blocker-state":a.state,children:[e.jsxs("div",{children:[e.jsx("strong",{children:a.label}),e.jsx("span",{children:a.proof})]}),e.jsxs("div",{children:[e.jsx("span",{className:"admin-release-state",children:a.state}),e.jsx("code",{children:a.command})]}),e.jsx("div",{className:"admin-release-proof-command-list","data-testid":"admin-release-proof-command-list","data-release-blocker-id":a.id,"data-release-proof-command-count":a.proofCommands.length,children:a.proofCommands.map(r=>e.jsxs("div",{className:"admin-release-proof-command","data-testid":"admin-release-proof-command","data-release-proof-command-mode":r.mode,"data-release-proof-command-live-call":String(r.liveCall),"data-release-proof-command-host-affecting":String(r.hostAffecting),"data-release-proof-command-default-gate":String(r.defaultGate),children:[e.jsx("span",{children:r.label}),e.jsx("code",{children:r.command}),e.jsxs("div",{className:"admin-release-proof-command__badges",children:[e.jsx("span",{children:r.mode}),e.jsx("span",{children:r.liveCall?"live":"local"}),e.jsx("span",{children:r.hostAffecting?"host-affecting":"host-safe"}),e.jsx("span",{children:r.defaultGate?"default-gate":"manual-only"})]})]},`${a.id}:${r.command}`))})]},a.id))})]})}function B({label:t,value:a}){return e.jsxs("div",{className:"admin-status-pill",children:[e.jsx("span",{children:t}),e.jsx("strong",{children:a})]})}function ee({metrics:t}){return e.jsx("section",{className:"admin-kpi-grid",children:t.map(a=>e.jsxs("article",{className:`admin-kpi-card ${ta(a.tone)}`,children:[e.jsx("span",{children:a.label}),e.jsx("strong",{children:a.value})]},a.label))})}function x({title:t,metrics:a,compact:r}){return e.jsxs("article",{className:`admin-panel ${r?"admin-panel--compact":""}`,children:[e.jsx("div",{className:"admin-panel-head",children:e.jsx("h2",{children:t})}),e.jsx("div",{className:"admin-metric-list",children:a.map(n=>e.jsxs("div",{className:`admin-metric-row ${n.tone?`admin-metric-row--${n.tone}`:""}`,children:[e.jsx("span",{children:n.label}),e.jsx("strong",{children:n.value})]},n.label))})]})}function ae({title:t,points:a,money:r}){return e.jsxs("article",{className:"admin-panel",children:[e.jsxs("div",{className:"admin-panel-head",children:[e.jsx("h2",{children:t}),e.jsx("span",{className:"admin-note",children:"Last 14 days"})]}),e.jsx("div",{className:"admin-mini-chart",children:a.map(n=>e.jsxs("div",{className:"admin-bar-item",children:[e.jsx("div",{className:"admin-bar",style:{height:`${aa(n.value,a)}%`}}),e.jsx("span",{children:n.label.slice(3)}),e.jsx("b",{children:r?`$${n.value}`:n.value})]},n.label))})]})}function M({title:t,columns:a,rows:r,compact:n}){return e.jsxs("section",{className:`admin-panel ${n?"admin-panel--compact":""}`,children:[e.jsx("div",{className:"admin-panel-head",children:e.jsx("h2",{children:t})}),e.jsx("div",{className:"admin-table-wrap",children:e.jsxs("table",{className:"admin-table",children:[e.jsx("thead",{children:e.jsx("tr",{children:a.map(s=>e.jsx("th",{children:s},s))})}),e.jsx("tbody",{children:r.map(s=>e.jsx("tr",{children:s.map(c=>e.jsx("td",{children:c},c))},s.join("|")))})]})})]})}function ia({rows:t}){return e.jsxs("section",{className:"admin-panel",children:[e.jsxs("div",{className:"admin-panel-head",children:[e.jsx("h2",{children:"User Funnel"}),e.jsx("span",{className:"admin-note",children:"30 day sample"})]}),e.jsx("div",{className:"admin-funnel-list",children:t.map(a=>e.jsxs("div",{className:"admin-funnel-row",children:[e.jsxs("div",{children:[e.jsx("strong",{children:a.label}),e.jsxs("span",{children:[a.count.toLocaleString()," users / ",a.rate,"%"]})]}),e.jsx("div",{className:"admin-progress-track",children:e.jsx("div",{className:"admin-progress-fill",style:{width:`${Math.min(100,a.rate)}%`}})})]},a.label))})]})}function oa(){const t=[["Paid users",28,100],["D7 retention",22,35],["AI failure rate",2,1]];return e.jsxs("article",{className:"admin-panel",children:[e.jsx("div",{className:"admin-panel-head",children:e.jsx("h2",{children:"Goal Progress"})}),e.jsx("div",{className:"admin-funnel-list",children:t.map(([a,r,n])=>{const s=a==="AI failure rate"?Math.max(8,100-Math.min(100,r/10*100)):Math.min(100,r/n*100);return e.jsxs("div",{className:"admin-funnel-row",children:[e.jsxs("div",{children:[e.jsx("strong",{children:a}),e.jsxs("span",{children:[r," / ",n]})]}),e.jsx("div",{className:"admin-progress-track",children:e.jsx("div",{className:"admin-progress-fill",style:{width:`${s}%`}})})]},a)})})]})}export{ha as AdminDashboardPage};
|
|
1
|
+
import{r as E,j as e}from"./vendor-react-BXzpOyCS.js";import{a as U}from"./index-CmaOkjme.js";import{r as te}from"./productionAdapterConfig-C5jfk6oG.js";import{R as d}from"./app-runtime-xD2Z3NdN.js";import{getSupabaseBrowserClient as re}from"./supabaseAuthAdapter-BcLkoGvY.js";import{an as _e,R as ge,D as Ee,b0 as Se,aQ as De,b1 as ye,P as we,aH as xe,b2 as Ae,j as Ce,q as Ie,W as Ne,b3 as Re,c as je,b4 as ke,e as Oe,aA as Pe}from"./vendor-icons-DE3gIReG.js";import"./canvas-runtime-F1OftOhQ.js";const Le=!1,Me="hold-release",Te=[{id:"cloud-auth-billing",label:"Secure cloud/auth/billing adapter closure",uiLabel:"Cloud/auth/billing adapter",state:"blocked-live-proof",requiredProof:["Dodo checkout live smoke with fresh Supabase session","Supabase provider read-only smoke with fresh session","Supabase provider write/admin mutation smoke with explicit admin values","Original launch proof supabaseLeakedPasswordProtection remains required as artifact-backed security proof","Original launch proof bolaIdorNegativeGate remains required as artifact-backed 20-user authorization proof","Original launch proof activeEditorHttpGate remains required as artifact-backed active editor load proof","Original launch proof dodoSignedSmoke remains required as signed webhook proof","Original launch proof dodoCheckoutDisabled remains required as fail-closed checkout proof","Original launch proof dodoSandboxWebhook remains required as real sandbox webhook proof","Original launch proof deploymentHardening.webCaptureWorkerSsrfRedirectGuard remains required as capture hardening proof","Original launch proof deploymentHardening.uploadFileSizeValidation remains required as upload hardening proof","Original launch proof deploymentHardening.dodoWebhookReplayGuard remains required as webhook replay hardening proof"],uiProof:"Dodo checkout, Supabase read-only, cloud write, and admin mutation proof need fresh provider inputs.",requiredInputs:["VITE_MINDEXEC_SUPABASE_URL","VITE_MINDEXEC_SUPABASE_PUBLISHABLE_KEY","VITE_MINDEXEC_DODO_CHECKOUT_FUNCTION_URL","MINDEXEC_SUPABASE_PROVIDER_SESSION_JSON","MINDEXEC_DODO_CHECKOUT_LIVE_CONFIRM","MINDEXEC_SUPABASE_PROVIDER_LIVE_CONFIRM","MINDEXEC_SUPABASE_PROVIDER_WRITE_CONFIRM","MINDEXEC_SUPABASE_PROVIDER_ADMIN_MUTATION_CONFIRM","MINDEXEC_SUPABASE_PROVIDER_ADMIN_PRICE_STAGE","MINDEXEC_SUPABASE_PROVIDER_ADMIN_LTD_LIMIT","MINDEXEC_ORIGINAL_LAUNCH_PROOF_JSON"],uiCommand:"npm run verify:release-blocker-preflight",proofCommands:[{label:"Dodo checkout live smoke",command:"npm run verify:dodo-checkout-live-smoke",mode:"opt-in-live-proof",liveCall:!0,hostAffecting:!1,defaultGate:!1,requiredInputs:["VITE_MINDEXEC_SUPABASE_URL","VITE_MINDEXEC_SUPABASE_PUBLISHABLE_KEY","VITE_MINDEXEC_DODO_CHECKOUT_FUNCTION_URL","MINDEXEC_SUPABASE_PROVIDER_SESSION_JSON","MINDEXEC_DODO_CHECKOUT_LIVE_CONFIRM"]},{label:"Supabase provider read-only smoke",command:"npm run verify:supabase-provider-live-smoke",mode:"opt-in-live-proof",liveCall:!0,hostAffecting:!1,defaultGate:!1,requiredInputs:["VITE_MINDEXEC_SUPABASE_URL","VITE_MINDEXEC_SUPABASE_PUBLISHABLE_KEY","MINDEXEC_SUPABASE_PROVIDER_SESSION_JSON","MINDEXEC_SUPABASE_PROVIDER_LIVE_CONFIRM"]},{label:"Supabase provider write/admin mutation smoke",command:"npm run verify:supabase-provider-write-smoke",mode:"opt-in-live-proof",liveCall:!0,hostAffecting:!1,defaultGate:!1,requiredInputs:["VITE_MINDEXEC_SUPABASE_URL","VITE_MINDEXEC_SUPABASE_PUBLISHABLE_KEY","MINDEXEC_SUPABASE_PROVIDER_SESSION_JSON","MINDEXEC_SUPABASE_PROVIDER_WRITE_CONFIRM","MINDEXEC_SUPABASE_PROVIDER_ADMIN_MUTATION_CONFIRM","MINDEXEC_SUPABASE_PROVIDER_ADMIN_PRICE_STAGE","MINDEXEC_SUPABASE_PROVIDER_ADMIN_LTD_LIMIT"]},{label:"Original launch proof artifacts",command:"npm run verify:original-launch-proof-artifacts",mode:"opt-in-proof-file",liveCall:!1,hostAffecting:!1,defaultGate:!1,requiredInputs:["MINDEXEC_ORIGINAL_LAUNCH_PROOF_JSON"]}]},{id:"agent-webresearch-codemaster",label:"Agent execution and WebResearch adapter closure",uiLabel:"Agent and CodeMaster provider depth",state:"blocked-provider-depth",requiredProof:["Real provider-backed diff/apply proof stays bounded to disposable workspace evidence","Cloud execution adapter proof avoids deploy, publish, billing, and unsafe file mutations","Concept embedding live proof keeps the provider API key server-side and opt-in only"],uiProof:"Live provider diff/apply and cloud execution proof remain opt-in and bounded.",requiredInputs:["MINDEXEC_CODEX_LIVE_READONLY_CONFIRM","MINDEXEC_CODEX_LIVE_TEMP_WRITE_CONFIRM","MINDEXEC_CODEX_LIVE_PROJECT_WRITE_CONFIRM","MINDEXEC_CODEMASTER_CLOUD_EXECUTION_PROOF_JSON","MINDEXEC_CONCEPT_EMBED_LIVE_CONFIRM","MINDEXEC_CONCEPT_EMBED_API_KEY"],uiCommand:"npm run verify:codemaster-codex-live-project-write-smoke",proofCommands:[{label:"Codex live read-only provider smoke",command:"npm run verify:codemaster-codex-live-readonly-smoke",mode:"opt-in-live-proof",liveCall:!0,hostAffecting:!1,defaultGate:!1,requiredInputs:["MINDEXEC_CODEX_LIVE_READONLY_CONFIRM"]},{label:"Codex live temp-write provider smoke",command:"npm run verify:codemaster-codex-live-temp-write-smoke",mode:"opt-in-live-proof",liveCall:!0,hostAffecting:!1,defaultGate:!1,requiredInputs:["MINDEXEC_CODEX_LIVE_TEMP_WRITE_CONFIRM"]},{label:"Codex live project-write provider smoke",command:"npm run verify:codemaster-codex-live-project-write-smoke",mode:"opt-in-live-proof",liveCall:!0,hostAffecting:!1,defaultGate:!1,requiredInputs:["MINDEXEC_CODEX_LIVE_PROJECT_WRITE_CONFIRM"]},{label:"CodeMaster cloud execution adapter proof",command:"npm run verify:codemaster-cloud-execution-adapter-proof",mode:"opt-in-proof-file",liveCall:!1,hostAffecting:!1,defaultGate:!1,requiredInputs:["MINDEXEC_CODEMASTER_CLOUD_EXECUTION_PROOF_JSON"]},{label:"Concept embedding live provider smoke",command:"npm run verify:concept-embedding-live-smoke",mode:"opt-in-live-proof",liveCall:!0,hostAffecting:!1,defaultGate:!1,requiredInputs:["MINDEXEC_CONCEPT_EMBED_LIVE_CONFIRM","MINDEXEC_CONCEPT_EMBED_API_KEY"]}]},{id:"mindcanvas-ai-media-provider",label:"MindCanvas AI media provider closure",uiLabel:"MindCanvas AI media provider",state:"blocked-provider-proof",requiredProof:["Provider-backed image generation proof from the MindCanvas node workflow","Provider-backed video generation proof from the MindCanvas node workflow","No raw provider secrets appear in browser storage, docs, logs, or release artifacts"],uiProof:"Image and video generation need sanitized provider proof from the node workflow.",requiredInputs:["MINDEXEC_MEDIA_PROVIDER_LIVE_CONFIRM","MINDEXEC_MEDIA_PROVIDER_PROOF_JSON"],uiCommand:"npm run verify:mindcanvas-media-provider-proof",proofCommands:[{label:"MindCanvas AI media provider proof",command:"npm run verify:mindcanvas-media-provider-proof",mode:"opt-in-proof-file",liveCall:!1,hostAffecting:!1,defaultGate:!1,requiredInputs:["MINDEXEC_MEDIA_PROVIDER_LIVE_CONFIRM","MINDEXEC_MEDIA_PROVIDER_PROOF_JSON"]}]},{id:"remote-fast-os-input",label:"RemoteFast opt-in OS-input smoke",uiLabel:"RemoteFast host OS input",state:"blocked-operator-confirmation",requiredProof:["Bounded pointer/key smoke against the host with cursor restore evidence"],uiProof:"Pointer/key smoke affects the host and must stay explicitly confirmed.",requiredInputs:["MINDEXEC_REMOTE_FAST_OS_INPUT_CONFIRM"],uiCommand:"npm run verify:remote-monitor-remote-fast-os-input-smoke",proofCommands:[{label:"RemoteFast bounded host OS-input smoke",command:"npm run verify:remote-monitor-remote-fast-os-input-smoke",mode:"opt-in-host-proof",liveCall:!1,hostAffecting:!0,defaultGate:!1,requiredInputs:["MINDEXEC_REMOTE_FAST_OS_INPUT_CONFIRM"]}]},{id:"release-approval",label:"Cloudflare/npm release approval",uiLabel:"Cloudflare/npm approval",state:"hold-release",requiredProof:["Green local gates after live proofs","Reviewed release notes","Explicit user approval before Cloudflare deploy or npm publish","Original `ref/~MindExec` launch proof manifest parity reviewed before release approval"],uiProof:"Deploy and npm publish require a reviewed proof packet and explicit user approval.",requiredInputs:["manual user approval"],uiCommand:"npm run verify:release-proof-packet",proofCommands:[{label:"Cloudflare Pages release pass",command:"manual-release-pass:cloudflare-pages",mode:"manual-release-approval",liveCall:!0,hostAffecting:!1,defaultGate:!1,requiredInputs:["manual user approval"]},{label:"npm package release pass",command:"manual-release-pass:npm-package",mode:"manual-release-approval",liveCall:!0,hostAffecting:!1,defaultGate:!1,requiredInputs:["manual user approval"]}]}],H={releaseReady:Le,releasePosture:Me,blockers:Te},ne="admin-dashboard-data";function v(t){return t&&typeof t=="object"&&!Array.isArray(t)?t:{}}function D(t){return Array.isArray(t)?t:[]}function f(t,a=""){return typeof t=="string"&&t.trim()?t.trim():a}function F(t,a=0){const r=typeof t=="number"?t:Number(t);return Number.isFinite(r)?r:a}function T(t,a=0){return Math.round(F(t,a))}function u(t){return T(t).toLocaleString()}function j(t){return`$${F(t).toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2})}`}function L(t){return`${F(t).toFixed(1)}%`}function V(t){return`${u(t)}P`}function se(t){const a=f(t);if(!a)return"--/--";const r=new Date(a);return Number.isNaN(r.getTime())?a.slice(0,5):`${String(r.getUTCMonth()+1).padStart(2,"0")}/${String(r.getUTCDate()).padStart(2,"0")}`}function Ue(t){const a=f(t).toLowerCase();if(/(failed|error|suspended|revoked|high|danger|blocked)/.test(a))return"danger";if(/(pending|review|grace|warn|manual|locked)/.test(a))return"warn";if(/(active|ok|processed|healthy|paid|closed|enforced)/.test(a))return"ok"}function _(t,a,r="-"){for(const n of a){const s=t[n];if(s!=null&&String(s).trim())return String(s)}return r}function Y(t,a){return t.map(r=>{const n=v(r),s=a.find(c=>n[c]!==void 0)??a[0];return{label:se(n.date??n.day??n.created_at),value:Math.max(0,F(n[s]))}})}function Fe(t){const a=v(t),r=v(a.launch_overview),n=v(a.billing_control),s=v(a.credit_totals),c=v(a.refund_rate),h=Y(D(a.daily_signups),["count","signup_count"]),l=Y(D(a.daily_revenue),["revenue","amount"]),y=D(a.referrers).map(b=>{const i=v(b);return[_(i,["referrer"],"direct"),u(i.visit_count??i.count)]}),O=D(a.countries).map(b=>{const i=v(b);return[_(i,["country"],"--"),u(i.visit_count??i.count),u(i.unique_users)]}),A=D(a.heavy_users).map(b=>{const i=v(b);return[_(i,["email","user_email","display_name"],"unknown"),`${u(i.boards_count??i.board_count)} boards`]}),C=D(a.entitlements).map(b=>{const i=v(b);return[_(i,["email","user_email"],"unknown"),_(i,["plan_key","plan","normalized_plan_key"],"free"),_(i,["status","entitlement_status"],"active"),_(i,["ends_at","current_period_end","renews_at"],"-")]}),I=D(a.refunds).map(b=>{const i=v(b);return[_(i,["email","user_email"],"unknown"),j(i.amount),_(i,["risk","revocation_status"],"review"),_(i,["review_status","status"],"open")]}),P=D(a.credit_ledger).map(b=>{const i=v(b);return[se(i.created_at),_(i,["email","user_email","reason"],"unknown"),V(i.delta??i.amount??i.credit_delta),_(i,["reason","event_type","source"],"-")]}),N=D(a.feature_limits).map(b=>{const i=v(b);return[_(i,["feature","feature_key"],"Feature"),_(i,["free_limit","free"],"-"),_(i,["pro_limit","pro","limit_value"],"-"),_(i,["status","entitlement_status"],"enforced")]}),R=D(a.user_funnel).map(b=>{const i=v(b);return{label:_(i,["stage","label"],"Stage"),count:T(i.count??i.user_count),rate:F(i.rate??i.conversion_rate)}});return{source:"supabase-admin-dashboard-data",fetchedAt:f(a.fetched_at,new Date().toISOString()),billingMode:f(r.billing_mode??n.billing_mode,"DODO_LIVE"),currency:f(r.currency_code??n.currency_code,"USD"),usdPerPoint:f(r.usd_per_point,"0.0002"),overviewKpis:[{label:"DAU",value:u(r.dau),tone:"ok"},{label:"WAU",value:u(r.wau),tone:"ok"},{label:"Activation",value:L(r.activation_rate),tone:"ok"},{label:"AI usage",value:L(r.ai_usage_rate),tone:"ok"},{label:"Paid conversion",value:L(r.paid_conversion_rate),tone:"warn"},{label:"D1 retention",value:L(r.d1_retention_rate),tone:"warn"},{label:"D7 retention",value:L(r.d7_retention_rate),tone:"warn"},{label:"Avg points / user",value:V(r.avg_points_spent_per_user)},{label:"AI cost estimate",value:j(r.ai_cost_estimate_usd)},{label:"Gross margin estimate",value:j(r.gross_margin_estimate_usd),tone:"ok"}],billingKpis:[{label:"Billing mode",value:f(n.billing_mode??r.billing_mode,"DODO_LIVE"),tone:"ok"},{label:"Webhook received 24h",value:u(n.webhook_received_24h??r.webhook_received_24h),tone:"ok"},{label:"Webhook failed 24h",value:u(n.webhook_failures_24h??r.webhook_failures_24h),tone:"warn"},{label:"Pending events",value:u(n.pending_events),tone:"warn"},{label:"Active Pro users",value:u(n.pro_active_users??n.active_entitlements),tone:"ok"},{label:"Manual reviews",value:u(n.manual_reviews),tone:"warn"},{label:"Locked boards",value:u(n.locked_boards),tone:"warn"},{label:"Create blocked today",value:u(n.create_blocked_today)}],operatingHealth:[{label:"Signups today",value:u(r.signups_today),tone:"ok"},{label:"Active users today",value:u(r.active_users_today),tone:"ok"},{label:"Points spent users",value:u(r.points_spent_users)},{label:"AI failures 24h",value:u(r.ai_failures_24h),tone:Ue(r.ai_failures_24h)??"warn"},{label:"Save failures 24h",value:u(r.save_failures_24h),tone:"ok"},{label:"Webhook failures 24h",value:u(r.webhook_failures_24h),tone:"warn"}],revenueBand:[{label:"Revenue today",value:j(r.revenue_today),tone:"ok"},{label:"7 day revenue",value:j(r.revenue_7_days),tone:"ok"},{label:"30 day revenue",value:j(r.revenue_30_days)},{label:"Total revenue",value:j(r.total_revenue)},{label:"Paid users",value:u(r.paid_users)},{label:"Wallet liability",value:V(r.total_credit_balance??s.total_credit_balance),tone:"warn"}],signupTrend:h,revenueTrend:l,referrerRows:y,countryRows:O,heavyUserRows:A,entitlementRows:C,webhookRows:[["24h received","payment/provider","processed",u(n.webhook_received_24h??r.webhook_received_24h)],["24h failed","payment/provider","manual-review",u(n.webhook_failures_24h??r.webhook_failures_24h)],["Refund rate","refunds","watch",L(c.refund_rate??c.rate)]],refundRows:I,creditRows:P,featureLimitRows:N,funnelRows:R,auditRows:[]}}async function W(t){var y,O,A,C;const a=te(t);if(!a.adminData.canAttempt)throw d.emit("adminDashboard.provider.skipped",{mode:a.adminData.mode}),new Error(`Secure admin data adapter is not ready: ${a.adminData.mode}`);const r=re(t);if(!r)throw d.emit("adminDashboard.provider.skipped",{mode:"config-missing"}),new Error("Supabase browser client is not available for admin data.");const{data:n,error:s}=await r.auth.getSession();if(s||!((y=n.session)!=null&&y.access_token))throw d.emit("adminDashboard.provider.sessionMissing",{message:(s==null?void 0:s.message)??"missing-session"}),new Error("Secure admin data requires a Supabase-authenticated session.");const{data:c,error:h}=await r.auth.getUser(),l=(O=c.user)==null?void 0:O.id;if(h||!l)throw d.emit("adminDashboard.provider.sessionMissing",{message:(h==null?void 0:h.message)??"missing-user"}),new Error("Secure admin data requires a verified Supabase user.");return{config:a,accessToken:n.session.access_token,userId:l,email:((C=(A=c.user)==null?void 0:A.email)==null?void 0:C.toLowerCase())??""}}async function X(t,a){await W(t);const r=re(t);if(!r)throw new Error("Supabase browser client is not available for admin data.");const{data:n,error:s}=await r.functions.invoke(ne,{body:a});if(s)throw d.emit("adminDashboard.provider.failed",{operation:f(a.action,"summary"),message:s.message}),s;if(n!=null&&n.error){const c=f(n.message??n.error,"admin-dashboard-data failed");throw d.emit("adminDashboard.provider.failed",{operation:f(a.action,"summary"),message:c}),new Error(c)}return n??{}}async function Be(t){d.emit("adminDashboard.provider.summary.requested",{functionName:ne});const a=await X(t,{action:"summary"}),r=Fe(a.summary);return d.emit("adminDashboard.provider.summary.loaded",{source:r.source,overviewMetrics:r.overviewKpis.length,signupPoints:r.signupTrend.length}),r}async function Xe(t,a){if(d.emit("adminDashboard.provider.userSearch.requested",{hasQuery:!!a.trim()}),!a.trim())return null;const r=await X(t,{action:"user-search",query:a}),n=v(r.user);if(!Object.keys(n).length)return d.emit("adminDashboard.provider.userSearch.loaded",{found:!1}),null;const s=v(n.profile),c=v(n.board_stats),h=v(n.activity),l=D(n.timeline),y={email:f(s.email,"unknown"),plan:f(s.plan_type,"Free"),boards:T(c.boards_count??c.board_count),points:T(s.credits_balance??h.credit_balance??h.points_balance),country:f(s.country,"--"),lastSeen:f(s.last_seen_at,f(s.created_at,"unknown")),timelineCount:l.length};return d.emit("adminDashboard.provider.userSearch.loaded",{found:!0,boards:y.boards}),y}async function Ve(t,a,r){const n=await W(t);d.emit("adminDashboard.provider.settings.requested",{priceStage:a,ltdLimit:r});const s=await X(t,{action:"save-settings",price_stage:a,ltd_limit:r}),c={mode:n.config.adminData.mode,canAttempt:!0,priceStage:f(s.price_stage,a),ltdLimit:T(s.ltd_limit,r),updatedAt:f(s.updated_at,new Date().toISOString())};return d.emit("adminDashboard.provider.settings.saved",{priceStage:c.priceStage,ltdLimit:c.ltdLimit}),c}async function qe(t,a){const r=await W(t);d.emit("adminDashboard.provider.emergencyClose.requested",{ltdLimit:a});const n=await X(t,{action:"emergency-close",price_stage:"CLOSED",ltd_limit:a}),s={mode:r.config.adminData.mode,canAttempt:!0,priceStage:f(n.price_stage,"CLOSED"),ltdLimit:T(n.ltd_limit,a),updatedAt:f(n.updated_at,new Date().toISOString())};return d.emit("adminDashboard.provider.emergencyClose.staged",{priceStage:s.priceStage,ltdLimit:s.ltdLimit}),s}const K="mindexec.react.admin.dashboard.v1",$e=["STANDARD","EARLY","LTD","CLOSED"],k={priceStage:"EARLY",ltdLimit:100,lastAction:"Admin dashboard restored as a local React shell.",updatedAtUtc:""};function Ge(){return te(U())}const He=[{key:"overview",label:"Overview",icon:Se},{key:"billing",label:"Billing Control",icon:De},{key:"entitlements",label:"Entitlements",icon:ye},{key:"dodo",label:"Dodo Events",icon:we},{key:"refunds",label:"Refunds",icon:xe},{key:"credits",label:"Credits",icon:Ae},{key:"limits",label:"Feature Limits",icon:Ce},{key:"funnel",label:"User Funnel",icon:Ie},{key:"explorer",label:"User Explorer",icon:Ne},{key:"release",label:"Release Readiness",icon:Re},{key:"audit",label:"Audit Log",icon:je}],We=[{label:"06/08",value:2},{label:"06/09",value:4},{label:"06/10",value:5},{label:"06/11",value:8},{label:"06/12",value:7},{label:"06/13",value:13},{label:"06/14",value:11},{label:"06/15",value:16},{label:"06/16",value:19},{label:"06/17",value:18},{label:"06/18",value:23},{label:"06/19",value:26},{label:"06/20",value:31},{label:"06/21",value:34}],Ke=[{label:"06/08",value:0},{label:"06/09",value:12},{label:"06/10",value:18},{label:"06/11",value:12},{label:"06/12",value:29},{label:"06/13",value:41},{label:"06/14",value:38},{label:"06/15",value:49},{label:"06/16",value:64},{label:"06/17",value:72},{label:"06/18",value:81},{label:"06/19",value:94},{label:"06/20",value:108},{label:"06/21",value:124}],G=[{email:"maya@buildloop.ai",plan:"Pro",boards:18,points:1240,country:"US",lastSeen:"today"},{email:"kenji@solo-studio.jp",plan:"Early",boards:9,points:640,country:"JP",lastSeen:"today"},{email:"linh@vietlaunch.dev",plan:"Free",boards:5,points:120,country:"VN",lastSeen:"yesterday"},{email:"alex@indieops.co",plan:"LTD",boards:32,points:2840,country:"SG",lastSeen:"2d ago"}],Je=[{label:"DAU",value:"128",tone:"ok"},{label:"WAU",value:"614",tone:"ok"},{label:"Activation",value:"41.8%",tone:"ok"},{label:"AI usage",value:"63.2%",tone:"ok"},{label:"Paid conversion",value:"4.6%",tone:"warn"},{label:"D1 retention",value:"38.1%",tone:"warn"},{label:"D7 retention",value:"22.7%",tone:"warn"},{label:"Avg points / user",value:"318P"},{label:"AI cost estimate",value:"$74.82"},{label:"Gross margin estimate",value:"$418.10",tone:"ok"}],ze=[{label:"Billing mode",value:"DODO_LIVE_GATED",tone:"warn"},{label:"Webhook received 24h",value:"19",tone:"ok"},{label:"Webhook failed 24h",value:"1",tone:"warn"},{label:"Pending events",value:"3",tone:"warn"},{label:"Active Pro users",value:"28",tone:"ok"},{label:"Manual reviews",value:"2",tone:"warn"},{label:"Locked boards",value:"6",tone:"warn"},{label:"Create blocked today",value:"14"}],ie=[["06/21 18:41","admin@mindexec.local","Changed price stage draft to EARLY"],["06/21 16:10","system","Dodo webhook replay queued"],["06/20 23:55","admin@mindexec.local","Raised LTD capacity review flag"],["06/20 19:20","system","Credit ledger reconciliation completed"]],Ye=[["evt_4912","payment.succeeded","processed","$12.00 USD"],["evt_4911","subscription.created","processed","Pro monthly"],["evt_4910","payment.failed","manual-review","$12.00 USD"],["evt_4909","refund.requested","pending","$24.00 USD"]],Qe=[{label:"Visitor",count:1280,rate:100},{label:"Signup",count:214,rate:16.7},{label:"First board",count:132,rate:61.7},{label:"AI run",count:83,rate:62.8},{label:"Pricing visit",count:44,rate:53},{label:"Paid",count:11,rate:25}],Q=String(H.releaseReady),q=H.releasePosture,Ze=H.blockers.map(t=>{var a;return{id:t.id,label:t.uiLabel||t.label,state:t.state,proof:t.uiProof||t.requiredProof.join(" "),command:t.uiCommand||((a=t.proofCommands[0])==null?void 0:a.command)||"npm run verify:release-blocker-preflight",proofCommands:t.proofCommands.map(r=>({label:r.label,command:r.command,mode:r.mode,liveCall:r.liveCall,hostAffecting:r.hostAffecting,defaultGate:r.defaultGate,requiredInputs:r.requiredInputs}))}}),ea={source:"local",fetchedAt:"",billingMode:"DODO_LIVE_GATED",currency:"USD",usdPerPoint:"0.0002",overviewKpis:Je,billingKpis:ze,operatingHealth:[{label:"Signups today",value:"34",tone:"ok"},{label:"Active users today",value:"128",tone:"ok"},{label:"Points spent users",value:"77"},{label:"AI failures 24h",value:"2",tone:"warn"},{label:"Save failures 24h",value:"0",tone:"ok"},{label:"Webhook failures 24h",value:"1",tone:"warn"}],revenueBand:[{label:"Revenue today",value:"$124.00",tone:"ok"},{label:"7 day revenue",value:"$530.00",tone:"ok"},{label:"30 day revenue",value:"$1,870.00"},{label:"Total revenue",value:"$4,418.00"},{label:"Paid users",value:"28"},{label:"Wallet liability",value:"184,200P",tone:"warn"}],signupTrend:We,revenueTrend:Ke,referrerRows:[["direct","312"],["x.com","128"],["reddit","84"],["youtube","62"]],countryRows:[["US","41%"],["JP","18%"],["SG","11%"],["VN","8%"]],heavyUserRows:G.slice(0,4).map(t=>[t.email.split("@")[0],`${t.boards} boards`]),entitlementRows:G.map(t=>[t.email,t.plan,t.plan==="Free"?"free":"active",t.plan==="Free"?"-":"2026-07-21"]),webhookRows:Ye,refundRows:[["maya@buildloop.ai","$12.00","low","closed"],["alex@indieops.co","$24.00","medium","open"],["unknown@blocked.test","$12.00","high","manual review"]],creditRows:[["18:41","maya@buildloop.ai","+1000P","monthly grant"],["18:20","kenji@solo-studio.jp","-120P","AI task"],["17:52","alex@indieops.co","-280P","image generation"]],featureLimitRows:[["Cloud boards","3","Unlimited","enforced"],["AI runs / month","20","1000","enforced"],["Image uploads","100MB","10GB","watching"],["Private boards","0","Unlimited","enforced"]],funnelRows:Qe,auditRows:ie};function aa(t,a){const r=Math.max(...a.map(n=>n.value),1);return Math.max(8,Math.round(t/r*100))}function ta(t){return t?`admin-kpi-card--${t}`:""}function $(t){return t.map(a=>({label:a[0]??"-",value:a[1]??"-"}))}function ra(t){return"timelineCount"in t?t.timelineCount:9}function oe(t){const a=typeof t=="number"?t:Number(t);return Number.isFinite(a)?Math.max(0,Math.min(1e4,Math.round(a))):k.ltdLimit}function le(t){if(!t||typeof t!="object")return k;const a=t,r=$e.includes(a.priceStage)?String(a.priceStage):k.priceStage,n=typeof a.lastAction=="string"&&a.lastAction.trim()?a.lastAction.slice(0,240):k.lastAction,s=typeof a.updatedAtUtc=="string"?a.updatedAtUtc:"";return{priceStage:r,ltdLimit:oe(a.ltdLimit),lastAction:n,updatedAtUtc:s}}function na(){if(typeof window>"u")return k;try{const t=window.localStorage.getItem(K),a=t?le(JSON.parse(t)):k;return d.emit("adminDashboard.localDraft.loaded",{source:t?"stored":"default",priceStage:a.priceStage,ltdLimit:a.ltdLimit}),a}catch(t){return d.emit("adminDashboard.localDraft.failed",{operation:"load",message:t instanceof Error?t.message:String(t)}),k}}function Z(t,a){const r=le({...t,updatedAtUtc:new Date().toISOString()});if(typeof window>"u")return r;try{window.localStorage.setItem(K,JSON.stringify(r)),d.emit("adminDashboard.localDraft.saved",{source:a,priceStage:r.priceStage,ltdLimit:r.ltdLimit})}catch(n){d.emit("adminDashboard.localDraft.failed",{operation:"save",source:a,message:n instanceof Error?n.message:String(n)})}return r}function ha(){const[t]=E.useState(na),[a,r]=E.useState("overview"),[n,s]=E.useState(!1),c=E.useMemo(()=>Ge(),[]),h=c.adminData.canAttempt,[l,y]=E.useState(ea),[O,A]=E.useState(null),[C,I]=E.useState(t.priceStage),[P,N]=E.useState(t.ltdLimit),[R,b]=E.useState(""),[i,de]=E.useState(""),[ce,g]=E.useState(t.lastAction),[ue,J]=E.useState(()=>new Date),me=E.useMemo(()=>{if(!i.trim())return null;const o=i.trim().toLowerCase();return G.find(m=>m.email.toLowerCase().includes(o))||null},[i]),w=l.source==="supabase-admin-dashboard-data"?O:me,pe=o=>{r(o),d.emit("adminDashboard.tab",{key:o})},fe=async()=>{if(s(!0),d.emit("adminDashboard.refresh"),h){try{const o=await Be(U());y(o),J(new Date(o.fetchedAt)),g("Secure Supabase admin snapshot refreshed.")}catch(o){const m=o instanceof Error?o.message:String(o);d.emit("adminDashboard.provider.refreshFailed",{message:m}),g(`Secure admin snapshot failed: ${m}. Local snapshot remains visible.`)}finally{s(!1)}return}window.setTimeout(()=>{J(new Date),g("Local admin snapshot refreshed. Wire Supabase read adapters before treating it as live production data."),s(!1)},260)},he=async o=>{o.preventDefault();const m=`Saved local settings draft: ${C}, LTD ${P}.`,p=Z({priceStage:C,ltdLimit:P,lastAction:m},"settings.form");if(d.emit("adminDashboard.settings.saved",{priceStage:p.priceStage,ltdLimit:p.ltdLimit}),I(p.priceStage),N(p.ltdLimit),g(p.lastAction),!!h)try{const S=await Ve(U(),p.priceStage,p.ltdLimit);I(S.priceStage),N(S.ltdLimit),g(`Secure admin settings saved: ${S.priceStage}, LTD ${S.ltdLimit}.`)}catch(S){const z=S instanceof Error?S.message:String(S);d.emit("adminDashboard.provider.settingsFailed",{message:z}),g(`Local settings draft saved, but secure provider save failed: ${z}`)}},ve=async()=>{const m=Z({priceStage:"CLOSED",ltdLimit:P,lastAction:"Emergency close staged locally. Real billing closure requires a secure admin adapter."},"emergency.close");if(d.emit("adminDashboard.emergency.closed",{priceStage:m.priceStage,ltdLimit:m.ltdLimit}),I(m.priceStage),N(m.ltdLimit),g(m.lastAction),!!h)try{const p=await qe(U(),m.ltdLimit);I(p.priceStage),N(p.ltdLimit),g(`Secure emergency close staged through admin provider: ${p.priceStage}, LTD ${p.ltdLimit}.`)}catch(p){const S=p instanceof Error?p.message:String(p);d.emit("adminDashboard.provider.emergencyFailed",{message:S}),g(`Emergency close staged locally, but secure provider close failed: ${S}`)}},be=async o=>{if(o.preventDefault(),de(R),d.emit("adminDashboard.user.search",{hasQuery:!!R.trim()}),!R.trim()){A(null),g("User explorer query cleared.");return}if(!h){g("User explorer searched local sample data.");return}try{const m=await Xe(U(),R);A(m),g(m?"User explorer loaded secure provider data.":"No secure provider user matched that query.")}catch(m){const p=m instanceof Error?m.message:String(m);d.emit("adminDashboard.provider.userSearchFailed",{message:p}),A(null),g(`Secure user explorer failed: ${p}`)}};return e.jsxs("div",{className:"page admin-dashboard-page","data-testid":"admin-dashboard-shell","data-admin-storage-key":K,"data-production-adapter-state":c.overallState,"data-admin-provider-mode":c.adminData.mode,"data-admin-provider-ready":c.adminData.canAttempt?"true":"false","data-client-secret-blocked":c.forbiddenClientSecretKeys.length>0?"true":"false",children:[e.jsxs("section",{className:"admin-hero",children:[e.jsxs("div",{children:[e.jsx("div",{className:"eyebrow",children:"Operations Console"}),e.jsx("h1",{children:"MindExec Admin Dashboard"}),e.jsx("p",{children:"React port of the original admin plugin: revenue, billing control, credits, limits, funnel, user explorer, and audit surfaces without loading the Blazor plugin runtime."})]}),e.jsxs("div",{className:"admin-hero-actions",children:[e.jsx("span",{className:"admin-badge","data-testid":"admin-dashboard-mode",children:h?"supabase-admin-provider":"local-admin-shell"}),e.jsxs("button",{className:"btn btn-secondary",type:"button",onClick:fe,disabled:n,"data-testid":"admin-refresh",children:[n?e.jsx(_e,{size:16,className:"spin-icon"}):e.jsx(ge,{size:16}),"Refresh"]})]})]}),e.jsxs("section",{className:"admin-status-strip","data-testid":"admin-status-strip",children:[e.jsx(B,{label:"Billing mode",value:l.billingMode}),e.jsx(B,{label:"Currency",value:l.currency}),e.jsx(B,{label:"USD / point",value:l.usdPerPoint}),e.jsx(B,{label:"Updated",value:ue.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})})]}),e.jsxs("section",{className:"admin-alert admin-alert--warning",children:[e.jsx(Ee,{size:18}),e.jsxs("div",{children:[e.jsx("strong",{children:h?"Secure admin provider ready":"Local React shell only"}),e.jsx("span",{"data-testid":"admin-last-action",children:ce})]})]}),e.jsx("nav",{className:"admin-tabs","aria-label":"Admin dashboard tabs","data-testid":"admin-tabs",children:He.map(o=>{const m=o.icon;return e.jsxs("button",{className:a===o.key?"is-active":"",type:"button",onClick:()=>pe(o.key),"data-testid":`admin-tab-${o.key}`,"data-admin-tab":o.key,children:[e.jsx(m,{size:16}),e.jsx("span",{children:o.label})]},o.key)})}),a==="overview"&&e.jsxs(e.Fragment,{children:[e.jsx(ee,{metrics:l.overviewKpis}),e.jsxs("section",{className:"admin-panel-grid admin-panel-grid--two",children:[e.jsx(x,{title:"Operating Health",metrics:l.operatingHealth}),e.jsx(x,{title:"Revenue Band",metrics:l.revenueBand})]}),e.jsxs("section",{className:"admin-panel-grid admin-panel-grid--two",children:[e.jsx(ae,{title:"Daily Signups",points:l.signupTrend}),e.jsx(ae,{title:"Daily Revenue",points:l.revenueTrend,money:!0})]}),e.jsxs("section",{className:"admin-panel-grid admin-panel-grid--three",children:[e.jsx(x,{title:"Top Referrers",metrics:$(l.referrerRows),compact:!0}),e.jsx(x,{title:"Countries",metrics:$(l.countryRows),compact:!0}),e.jsx(x,{title:"Heavy Users",metrics:$(l.heavyUserRows),compact:!0})]})]}),a==="billing"&&e.jsxs(e.Fragment,{children:[e.jsx(ee,{metrics:l.billingKpis}),e.jsxs("section",{className:"admin-panel-grid admin-panel-grid--three",children:[e.jsx(x,{title:"Webhook Status",metrics:[{label:"24h received",value:"19",tone:"ok"},{label:"24h failed",value:"1",tone:"warn"},{label:"Pending",value:"3",tone:"warn"},{label:"Last success",value:"18:41"}]}),e.jsx(x,{title:"Entitlement State",metrics:[{label:"Active",value:"28",tone:"ok"},{label:"Grace",value:"3",tone:"warn"},{label:"Suspended",value:"2",tone:"danger"},{label:"Revoked",value:"1"}]}),e.jsxs("form",{className:"admin-panel admin-settings-panel",onSubmit:he,"data-testid":"admin-settings-form",children:[e.jsxs("div",{className:"admin-panel-head",children:[e.jsx("h2",{children:"Price Controls"}),e.jsxs("button",{className:"btn btn-primary",type:"submit","data-testid":"admin-save-settings",children:[e.jsx(ke,{size:15}),"Save draft"]})]}),e.jsxs("label",{children:["Price stage",e.jsxs("select",{value:C,onChange:o=>I(o.target.value),"data-testid":"admin-price-stage",children:[e.jsx("option",{value:"STANDARD",children:"STANDARD"}),e.jsx("option",{value:"EARLY",children:"EARLY"}),e.jsx("option",{value:"LTD",children:"LTD"}),e.jsx("option",{value:"CLOSED",children:"CLOSED"})]})]}),e.jsxs("label",{children:["LTD limit",e.jsx("input",{type:"number",min:"0",value:P,onChange:o=>N(oe(o.target.value)),"data-testid":"admin-ltd-limit"})]}),e.jsxs("button",{className:"btn btn-secondary admin-danger-button",type:"button",onClick:ve,"data-testid":"admin-emergency-close",children:[e.jsx(Oe,{size:15}),"Stage emergency close"]})]})]})]}),a==="entitlements"&&e.jsx(M,{title:"Entitlements",columns:["User","Plan","Status","Renews"],rows:l.entitlementRows}),a==="dodo"&&e.jsx(M,{title:"Dodo Webhook Events",columns:["Event","Type","Status","Amount"],rows:l.webhookRows}),a==="refunds"&&e.jsx(M,{title:"Refund Reviews",columns:["User","Amount","Risk","Status"],rows:[...l.refundRows]}),a==="credits"&&e.jsx(M,{title:"Credit Ledger",columns:["Time","User","Delta","Reason"],rows:l.creditRows}),a==="limits"&&e.jsx(M,{title:"Feature Limits",columns:["Feature","Free","Pro","Status"],rows:l.featureLimitRows}),a==="funnel"&&e.jsx(ia,{rows:l.funnelRows}),a==="explorer"&&e.jsxs("section",{className:"admin-panel",children:[e.jsxs("div",{className:"admin-panel-head",children:[e.jsx("h2",{children:"User Explorer"}),e.jsx("span",{className:"admin-note",children:h?"Secure provider data":"Local sample data"})]}),e.jsxs("form",{className:"admin-search-row",onSubmit:be,"data-testid":"admin-user-search-form",children:[e.jsx("input",{"aria-label":"Search user",value:R,onChange:o=>b(o.target.value),placeholder:"email, domain, or segment","data-testid":"admin-user-query"}),e.jsxs("button",{className:"btn btn-primary",type:"submit","data-testid":"admin-user-search",children:[e.jsx(Pe,{size:15}),"Search"]})]}),i&&!w&&e.jsx("div",{className:"admin-empty","data-testid":"admin-user-empty",children:h?"No secure provider user matched that query.":"No local sample user matched that query."}),w&&e.jsxs("div",{className:"admin-user-card","data-testid":"admin-user-card",children:[e.jsx("strong",{children:w.email}),e.jsxs("span",{children:[w.plan," / ",w.country," / last seen ",w.lastSeen]}),e.jsx(x,{title:"User Snapshot",compact:!0,metrics:[{label:"Boards",value:String(w.boards)},{label:"Points",value:`${w.points}P`},{label:"Timeline",value:`${ra(w)} events`}]})]})]}),a==="release"&&e.jsx(sa,{blockers:Ze}),a==="audit"&&e.jsxs("section",{className:"admin-panel-grid admin-panel-grid--two",children:[e.jsx(oa,{}),e.jsx(M,{title:"Recent Setting Changes",columns:["Time","Admin","Action"],rows:l.auditRows.length?l.auditRows:ie,compact:!0})]})]})}function sa({blockers:t}){return e.jsxs("section",{className:"admin-release-readiness","data-testid":"admin-release-readiness-panel","data-release-ready":Q,"data-release-posture":q,"data-release-blocker-count":t.length,children:[e.jsxs("div",{className:"admin-panel-head",children:[e.jsxs("div",{children:[e.jsx("h2",{children:"Release Readiness"}),e.jsx("p",{className:"admin-release-summary",children:"Local gates are green enough for RC work, but release remains held until live proofs and explicit approval are complete."})]}),e.jsx("span",{className:"admin-badge admin-badge--hold","data-testid":"admin-release-posture",children:q})]}),e.jsxs("div",{className:"admin-release-grid",children:[e.jsx(x,{title:"Local RC State",compact:!0,metrics:[{label:"Release ready",value:Q,tone:"warn"},{label:"Posture",value:q,tone:"warn"},{label:"Blockers",value:String(t.length),tone:"warn"},{label:"Default deploy/publish",value:"blocked",tone:"ok"}]}),e.jsxs("article",{className:"admin-panel admin-panel--compact",children:[e.jsx("div",{className:"admin-panel-head",children:e.jsx("h2",{children:"Proof Packet"})}),e.jsxs("div",{className:"admin-release-command-list",children:[e.jsx("code",{children:"npm run verify:release-blocker-preflight"}),e.jsx("code",{children:"npm run verify:release-proof-packet"}),e.jsx("code",{children:"npm run check"}),e.jsx("code",{children:"npm run build"})]})]})]}),e.jsx("div",{className:"admin-release-blocker-list","data-testid":"admin-release-blocker-list",children:t.map(a=>e.jsxs("article",{className:"admin-release-blocker","data-testid":"admin-release-blocker","data-release-blocker-id":a.id,"data-release-blocker-state":a.state,children:[e.jsxs("div",{children:[e.jsx("strong",{children:a.label}),e.jsx("span",{children:a.proof})]}),e.jsxs("div",{children:[e.jsx("span",{className:"admin-release-state",children:a.state}),e.jsx("code",{children:a.command})]}),e.jsx("div",{className:"admin-release-proof-command-list","data-testid":"admin-release-proof-command-list","data-release-blocker-id":a.id,"data-release-proof-command-count":a.proofCommands.length,children:a.proofCommands.map(r=>e.jsxs("div",{className:"admin-release-proof-command","data-testid":"admin-release-proof-command","data-release-proof-command-mode":r.mode,"data-release-proof-command-live-call":String(r.liveCall),"data-release-proof-command-host-affecting":String(r.hostAffecting),"data-release-proof-command-default-gate":String(r.defaultGate),children:[e.jsx("span",{children:r.label}),e.jsx("code",{children:r.command}),e.jsxs("div",{className:"admin-release-proof-command__badges",children:[e.jsx("span",{children:r.mode}),e.jsx("span",{children:r.liveCall?"live":"local"}),e.jsx("span",{children:r.hostAffecting?"host-affecting":"host-safe"}),e.jsx("span",{children:r.defaultGate?"default-gate":"manual-only"})]})]},`${a.id}:${r.command}`))})]},a.id))})]})}function B({label:t,value:a}){return e.jsxs("div",{className:"admin-status-pill",children:[e.jsx("span",{children:t}),e.jsx("strong",{children:a})]})}function ee({metrics:t}){return e.jsx("section",{className:"admin-kpi-grid",children:t.map(a=>e.jsxs("article",{className:`admin-kpi-card ${ta(a.tone)}`,children:[e.jsx("span",{children:a.label}),e.jsx("strong",{children:a.value})]},a.label))})}function x({title:t,metrics:a,compact:r}){return e.jsxs("article",{className:`admin-panel ${r?"admin-panel--compact":""}`,children:[e.jsx("div",{className:"admin-panel-head",children:e.jsx("h2",{children:t})}),e.jsx("div",{className:"admin-metric-list",children:a.map(n=>e.jsxs("div",{className:`admin-metric-row ${n.tone?`admin-metric-row--${n.tone}`:""}`,children:[e.jsx("span",{children:n.label}),e.jsx("strong",{children:n.value})]},n.label))})]})}function ae({title:t,points:a,money:r}){return e.jsxs("article",{className:"admin-panel",children:[e.jsxs("div",{className:"admin-panel-head",children:[e.jsx("h2",{children:t}),e.jsx("span",{className:"admin-note",children:"Last 14 days"})]}),e.jsx("div",{className:"admin-mini-chart",children:a.map(n=>e.jsxs("div",{className:"admin-bar-item",children:[e.jsx("div",{className:"admin-bar",style:{height:`${aa(n.value,a)}%`}}),e.jsx("span",{children:n.label.slice(3)}),e.jsx("b",{children:r?`$${n.value}`:n.value})]},n.label))})]})}function M({title:t,columns:a,rows:r,compact:n}){return e.jsxs("section",{className:`admin-panel ${n?"admin-panel--compact":""}`,children:[e.jsx("div",{className:"admin-panel-head",children:e.jsx("h2",{children:t})}),e.jsx("div",{className:"admin-table-wrap",children:e.jsxs("table",{className:"admin-table",children:[e.jsx("thead",{children:e.jsx("tr",{children:a.map(s=>e.jsx("th",{children:s},s))})}),e.jsx("tbody",{children:r.map(s=>e.jsx("tr",{children:s.map(c=>e.jsx("td",{children:c},c))},s.join("|")))})]})})]})}function ia({rows:t}){return e.jsxs("section",{className:"admin-panel",children:[e.jsxs("div",{className:"admin-panel-head",children:[e.jsx("h2",{children:"User Funnel"}),e.jsx("span",{className:"admin-note",children:"30 day sample"})]}),e.jsx("div",{className:"admin-funnel-list",children:t.map(a=>e.jsxs("div",{className:"admin-funnel-row",children:[e.jsxs("div",{children:[e.jsx("strong",{children:a.label}),e.jsxs("span",{children:[a.count.toLocaleString()," users / ",a.rate,"%"]})]}),e.jsx("div",{className:"admin-progress-track",children:e.jsx("div",{className:"admin-progress-fill",style:{width:`${Math.min(100,a.rate)}%`}})})]},a.label))})]})}function oa(){const t=[["Paid users",28,100],["D7 retention",22,35],["AI failure rate",2,1]];return e.jsxs("article",{className:"admin-panel",children:[e.jsx("div",{className:"admin-panel-head",children:e.jsx("h2",{children:"Goal Progress"})}),e.jsx("div",{className:"admin-funnel-list",children:t.map(([a,r,n])=>{const s=a==="AI failure rate"?Math.max(8,100-Math.min(100,r/10*100)):Math.min(100,r/n*100);return e.jsxs("div",{className:"admin-funnel-row",children:[e.jsxs("div",{children:[e.jsx("strong",{children:a}),e.jsxs("span",{children:[r," / ",n]})]}),e.jsx("div",{className:"admin-progress-track",children:e.jsx("div",{className:"admin-progress-fill",style:{width:`${s}%`}})})]},a)})})]})}export{ha as AdminDashboardPage};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/supabaseAuthAdapter-BcLkoGvY.js","assets/productionAdapterConfig-C5jfk6oG.js","assets/canvas-runtime-F1OftOhQ.js","assets/vendor-react-BXzpOyCS.js","assets/app-runtime-xD2Z3NdN.js","assets/vendor-icons-DE3gIReG.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{g as C,A as N,a as b,_ as L,c as P,s as U}from"./index-CmaOkjme.js";import{r as o,j as e,a as V}from"./vendor-react-BXzpOyCS.js";import{r as Y}from"./productionAdapterConfig-C5jfk6oG.js";import{R as d}from"./app-runtime-xD2Z3NdN.js";import{b2 as K,aQ as O,b9 as W,ba as x,ap as Q,aE as J,bb as X,a3 as Z,bc as ee,a_ as se,b8 as ne,b0 as ae,bd as te}from"./vendor-icons-DE3gIReG.js";const ie=[{id:"/",label:"Home",description:"MindExec product surface",icon:J},{id:"/mindcanvas",label:"MindCanvas",description:"AI execution canvas",icon:X},{id:"/planmaster",label:"PlanMaster",description:"Execution planning board",icon:Z},{id:"/tools",label:"Tools",description:"Free browser utilities",icon:ee},{id:"/youtube",label:"YouTube",description:"Video capture to canvas",icon:se},{id:"/code",label:"Code",description:"CodeGraph workspace preview",icon:ne},{id:"/pricing",label:"Pricing",description:"USD paid path",icon:O},{id:"/company-core",label:"Company Core",description:"Business operating view",icon:ae},{id:"/login",label:"Login",description:"Google sign-in shell",icon:x}];function M(a){return typeof a=="number"?`${a.toLocaleString()}P`:"Pending"}function oe(a){var l;const c=(a||"").trim();return c?(l=c[0])==null?void 0:l.toUpperCase():"M"}function re(a){return a==="supabase-provider-session"?"Supabase OAuth":a==="supabase-callback-shell"?"OAuth callback shell":a==="manual-google-shell"?"Local Google shell":"Local shell"}function ce(a){return a?a.source==="manual-google-shell"?{availablePoints:0,reservedPoints:0,mode:"Local/BYOK",description:"Local shell, BYOK, and offline work stay outside managed cloud credits."}:{availablePoints:null,reservedPoints:null,mode:"Cloud wallet",description:"Credit wallet sync is reserved for the hosted paid adapter."}:{availablePoints:null,reservedPoints:null,mode:"Sign in required",description:"Sign in to sync managed AI credits for hosted workflows."}}function ve({route:a,navigate:c,canvasActions:l=[]}){const k=l.length>0,[n,v]=o.useState(()=>C()),[u,p]=o.useState(!1),[f,j]=o.useState(!1),w=o.useRef(null),A=o.useRef(null),m=o.useMemo(()=>ce(n),[n]);o.useEffect(()=>{const s=()=>v(C());return window.addEventListener(N,s),window.addEventListener("storage",s),()=>{window.removeEventListener(N,s),window.removeEventListener("storage",s)}},[]),o.useEffect(()=>{if(!Y(b()).auth.canAttempt)return;let t=!1;return(async()=>{try{const{loadSupabaseAuthSession:r,loadSupabaseAuthSessionFromLocalBridge:g,syncSupabaseAuthSessionToLocalBridge:D}=await L(async()=>{const{loadSupabaseAuthSession:G,loadSupabaseAuthSessionFromLocalBridge:H,syncSupabaseAuthSessionToLocalBridge:q}=await import("./supabaseAuthAdapter-BcLkoGvY.js");return{loadSupabaseAuthSession:G,loadSupabaseAuthSessionFromLocalBridge:H,syncSupabaseAuthSessionToLocalBridge:q}},__vite__mapDeps([0,1,2,3,4,5]));let h=await r(b());if(h.session||(h=await g(b(),"sidebar-local-bridge-session-restore")),t)return;if(!h.session){(n==null?void 0:n.source)==="supabase-provider-session"&&(P(),v(null),d.emit("auth.accountMenu.providerSession.cleared",{reason:"session-missing"}));return}const F=U({...h.session,source:"supabase-provider-session"});v(F),await D(b(),"sidebar-provider-session-restore")}catch(r){d.emit("auth.accountMenu.providerRestore.warning",{message:r instanceof Error?r.message:String(r)})}})(),()=>{t=!0}},[n==null?void 0:n.source]),o.useEffect(()=>{if(!u)return;const s=i=>{var r,g;i.target instanceof Node&&((r=w.current)!=null&&r.contains(i.target)||(g=A.current)!=null&&g.contains(i.target)||p(!1))},t=i=>{i.key==="Escape"&&p(!1)};return window.addEventListener("pointerdown",s,!0),window.addEventListener("keydown",t),()=>{window.removeEventListener("pointerdown",s,!0),window.removeEventListener("keydown",t)}},[u]);const _=n?te:x,S=n?`Account: signed in as ${n.email}`:"Account: sign in with Google",I=a==="/login"||!!n,R=(n==null?void 0:n.email)??"Sign in required",B=n?re(n.source):"Not connected",y=s=>{p(!1),c(s)},T=()=>{p(s=>{const t=!s;return d.emit("auth.accountMenu.toggled",{open:t,signedIn:!!n,source:(n==null?void 0:n.source)??"none"}),t})},$=n?e.jsxs("div",{className:"account-popover-credit","data-testid":"sidebar-account-credits",children:[e.jsxs("div",{className:"account-popover-credit-title",children:[e.jsx(K,{size:15}),e.jsx("span",{children:"AI Credits"})]}),e.jsx("strong",{"data-testid":"sidebar-account-credit-available",children:M(m.availablePoints)}),e.jsx("p",{children:m.description}),e.jsxs("div",{className:"account-popover-credit-grid",children:[e.jsxs("div",{children:[e.jsx("span",{children:"Reserved"}),e.jsx("b",{"data-testid":"sidebar-account-credit-reserved",children:M(m.reservedPoints)})]}),e.jsxs("div",{children:[e.jsx("span",{children:"Mode"}),e.jsx("b",{children:m.mode})]})]})]}):null,z=async()=>{if(!f){j(!0),d.emit("auth.accountMenu.signOut.requested",{source:(n==null?void 0:n.source)??"none"});try{const{signOutSupabaseAuthSession:s}=await L(async()=>{const{signOutSupabaseAuthSession:t}=await import("./supabaseAuthAdapter-BcLkoGvY.js");return{signOutSupabaseAuthSession:t}},__vite__mapDeps([0,1,2,3,4,5]));await s(b(),"sidebar-account-menu")}catch(s){d.emit("auth.accountMenu.signOut.warning",{message:s instanceof Error?s.message:String(s)})}P(),v(null),p(!1),j(!1),d.emit("auth.accountMenu.signOut.completed"),c("/")}},E=u?e.jsxs("div",{className:"sidebar-account-popover",role:"dialog","aria-label":"Account","data-testid":"sidebar-account-menu",ref:A,children:[e.jsxs("div",{className:"account-popover-head",children:[e.jsx("div",{className:"account-popover-avatar","aria-hidden":"true",children:oe(n==null?void 0:n.email)}),e.jsxs("div",{className:"account-popover-title",children:[e.jsx("span",{children:"Account"}),e.jsx("strong",{"data-testid":"sidebar-account-email",children:R}),e.jsx("small",{children:B})]})]}),$,e.jsxs("div",{className:"account-popover-actions",children:[e.jsxs("button",{className:"account-popover-action",type:"button","data-testid":"sidebar-account-pricing",onClick:()=>y("/pricing"),children:[e.jsx(O,{size:16}),e.jsx("span",{children:"Credit plans"})]}),n?e.jsxs("button",{className:"account-popover-action account-popover-action--danger",type:"button","data-testid":"sidebar-account-sign-out",disabled:f,onClick:z,children:[e.jsx(W,{size:16}),e.jsx("span",{children:f?"Signing out ...":"Sign out"})]}):e.jsxs("button",{className:"account-popover-action account-popover-action--primary",type:"button","data-testid":"sidebar-account-sign-in",onClick:()=>y("/login"),children:[e.jsx(x,{size:16}),e.jsx("span",{children:"Continue with Google"})]})]})]}):null;return e.jsxs("aside",{className:"app-sidebar","aria-label":"MindExec navigation",children:[e.jsx("button",{className:"sidebar-brand",type:"button",title:"Open MindCanvas","aria-label":"Open MindCanvas",onClick:()=>c("/mindcanvas"),children:e.jsx(Q,{size:22})}),e.jsx("div",{className:"sidebar-divider"}),e.jsx("nav",{className:"sidebar-nav",children:ie.slice(1,8).map(s=>{const t=s.icon,i=s.id===a||s.id==="/mindcanvas"&&a==="/mindmap"||s.id==="/planmaster"&&a==="/planagent"||s.id==="/tools"&&a.startsWith("/tools/")||s.id==="/"&&a==="/";return e.jsx("button",{type:"button",className:`sidebar-icon ${i?"is-active":""}`,title:`${s.label}: ${s.description}`,"aria-label":s.label,"aria-current":i?"page":void 0,onClick:()=>c(s.id),children:e.jsx(t,{size:21})},s.id)})}),e.jsx("div",{className:"sidebar-spacer"}),k&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"sidebar-divider sidebar-divider--context"}),e.jsx("nav",{className:"sidebar-nav sidebar-nav--context","aria-label":"MindCanvas quick actions",children:l.map(s=>{const t=s.icon;return e.jsx("button",{type:"button",className:`sidebar-icon sidebar-icon--context ${s.active?"is-active":""}`,title:`${s.label}: ${s.description}`,"aria-label":s.label,"aria-pressed":s.active?"true":void 0,"data-testid":s.testId,onClick:s.onClick,children:e.jsx(t,{size:20})},s.id)})})]}),e.jsxs("div",{className:"sidebar-account-wrap",ref:w,children:[e.jsx("button",{className:`sidebar-icon ${I?"is-active":""}`,type:"button",title:S,"aria-label":S,"aria-haspopup":"dialog","aria-expanded":u,"data-testid":"sidebar-account","data-auth-session-active":n?"true":"false","data-auth-session-source":(n==null?void 0:n.source)??"none",onClick:T,children:e.jsx(_,{size:20})}),u&&(typeof document<"u"?V.createPortal(E,document.body):E)]})]})}export{ve as AppSidebar};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r,j as e}from"./vendor-react-BXzpOyCS.js";import{g as C,a as g,c as k,s as q,b as K,p as F,d as L}from"./index-CmaOkjme.js";import{p as T,P as U}from"./pricingCheckoutShell-O-DnwmbU.js";import{r as O}from"./productionAdapterConfig-C5jfk6oG.js";import{R as f}from"./app-runtime-xD2Z3NdN.js";import{syncSupabaseAuthSessionToLocalBridge as P,loadSupabaseAuthSession as _,loadSupabaseAuthSessionFromLocalBridge as D,buildSupabaseAuthRedirectUrl as I,startSupabaseGoogleOAuth as H,signOutSupabaseAuthSession as Y,requestSupabasePasswordReset as V,updateSupabasePassword as W}from"./supabaseAuthAdapter-BcLkoGvY.js";import{X,ak as J,ab as Q,aR as z,ad as $,f as Z,aS as N,K as B,aT as ee,a7 as te}from"./vendor-icons-DE3gIReG.js";import"./canvas-runtime-F1OftOhQ.js";function se(o){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(o.trim())}function S(){return O(g())}function E(o,a,u=!1){return o.source==="supabase-provider-session"?a?`Google sign-in is active for ${o.email}. Return to pricing to continue checkout.`:`Google sign-in is active for ${o.email}.`:u?a?"A local auth shell exists, but secure Google sign-in is required before checkout can continue.":"A local auth shell exists, but secure Google sign-in is required before MindCanvas can sync remote services.":a?"A local Google auth shell is active. Return to pricing to continue checkout.":"A local Google auth shell is already active for this browser."}function M(o,a){return a?`Local Google auth shell ready for ${o}. Return to pricing to continue the gated checkout.`:`Local Google auth shell ready for ${o}. Secure Supabase OAuth can replace this adapter later.`}function de({navigate:o}){const[a,u]=r.useState(!1),[t,l]=r.useState(()=>C()),[i]=r.useState(()=>T()),d=r.useMemo(()=>S(),[]),[x,c]=r.useState(()=>{const s=C(),n=T();return s?E(s,!!n,S().auth.canAttempt):n?"Sign in to continue MindCanvas Pro checkout. Payment remains gated until the secure adapter is connected.":"Use your Google account to sync cloud projects. No password to create or remember."});r.useEffect(()=>{if(!d.auth.canAttempt)return;let s=!1;return(async()=>{try{let h=await _(g());if(h.session||(h=await D(g(),"login-local-bridge-session-restore")),s)return;if(!h.session){(t==null?void 0:t.source)==="supabase-provider-session"&&(k(),l(null),c("Google sign-in expired. Choose your account again."),f.emit("auth.supabase.sessionShell.cleared",{source:"login-provider-session-restore",reason:"session-missing"}));return}const G=q({...h.session,source:"supabase-provider-session"});l(G),c(E(G,!!i,d.auth.canAttempt)),await P(g(),"login-provider-session-restore")}catch(h){f.emit("auth.supabase.sessionRestore.uiFailed",{message:h instanceof Error?h.message:String(h)})}})(),()=>{s=!0}},[i,d.auth.canAttempt,t==null?void 0:t.source]),r.useEffect(()=>{(t==null?void 0:t.source)!=="supabase-provider-session"||!d.auth.canAttempt||P(g(),"login-existing-session")},[d.auth.canAttempt,t==null?void 0:t.email,t==null?void 0:t.source]);const m=()=>{const s=C();if(s)return l(s),c(E(s,!!i,d.auth.canAttempt)),s;const n=L();return l(n),c(M(n.email,!!i)),n},b=async()=>{const s=m();s.source==="supabase-provider-session"&&await P(g(),"login-continue");const n={hasCheckoutIntent:!!i,signedIn:!!s,sessionSource:s.source};i?f.emit("auth.returnToPricing",n):f.emit("auth.continueMindCanvas",n),o(i?"/pricing":"/mindcanvas")},w=()=>{const s=L();l(s),c(M(s.email,!!i)),u(!1),window.setTimeout(()=>{b()},240)},p=async()=>{u(!0);const s=await F();if(O(s).auth.canAttempt)try{const h=I("/login",i?"/pricing":"/mindcanvas");c("Opening secure Google sign-in..."),(t==null?void 0:t.source)!=="supabase-provider-session"&&(k(),l(null)),await H(s,h);return}catch(h){c(`Secure Google sign-in failed: ${h instanceof Error?h.message:String(h)}`),u(!1);return}window.setTimeout(()=>{w()},550)},j=!!(t&&(!d.auth.canAttempt||t.source==="supabase-provider-session")),y=j?i?"Continue checkout":"Continue to MindCanvas":a?"Opening Google...":"Continue with Google",v=j?b:p,A=async()=>{u(!0),c("Signing out...");let s="";try{await Y(g(),"login-sign-out")}catch(n){s=n instanceof Error?n.message:String(n),f.emit("auth.signOut.uiFailed",{message:s})}k(),l(null),c(s?`Signed out locally. Provider sign-out warning: ${s}`:i?"Signed out. Choose another Google account to continue checkout.":"Signed out. Choose another Google account to continue."),u(!1)};return e.jsxs(R,{page:"login",children:[e.jsx("button",{className:"auth-close",type:"button",title:"Close",onClick:()=>o("/mindcanvas"),"data-testid":"auth-close",children:e.jsx(X,{size:16})}),e.jsxs("div",{className:"auth-logo",children:[e.jsx(J,{size:24}),e.jsx("strong",{children:"MindExec"})]}),e.jsx("h1",{children:"Sign in with Google"}),e.jsx("p",{"data-testid":"auth-message",children:x}),e.jsxs("button",{className:"google-button",type:"button",disabled:a,onClick:v,"data-testid":"auth-google-shell",children:[e.jsx("span",{className:"google-g",children:"G"}),y]}),e.jsxs("div",{className:"auth-action-strip",children:[t&&i&&e.jsx("button",{type:"button",onClick:()=>void b(),"data-testid":"auth-return-pricing",children:"Return to pricing"}),t&&e.jsx("button",{type:"button",disabled:a,onClick:()=>void A(),"data-testid":"auth-sign-out",children:"Sign out"}),e.jsx("button",{type:"button",onClick:()=>o("/forgot-password"),"data-testid":"auth-forgot-password",children:"Forgot password"}),e.jsx("button",{type:"button",onClick:()=>o("/pricing"),"data-testid":"auth-view-pricing",children:"View pricing"})]}),e.jsx("p",{className:"auth-note",children:d.auth.canAttempt?"Secure Supabase OAuth is connected for this browser build.":"The React port keeps this as a local auth shell until the secure Supabase OAuth adapter is connected."})]})}function he({navigate:o}){const[a,u]=r.useState(""),[t,l]=r.useState(!1),[i,d]=r.useState(""),[x,c]=r.useState(!1),m=r.useMemo(()=>S(),[]),b=async w=>{if(w.preventDefault(),!se(a)){d("Enter a valid email address.");return}if(l(!0),d(""),m.passwordReset.canAttempt){try{const p=I("/reset-password","/login");await V(g(),a,p),c(!0),l(!1),f.emit("auth.reset.requested",{emailDomain:a.split("@")[1]||"",provider:"supabase"})}catch(p){d(p instanceof Error?p.message:String(p)),l(!1)}return}window.setTimeout(()=>{c(!0),l(!1),f.emit("auth.reset.requested",{emailDomain:a.split("@")[1]||""})},450)};return e.jsxs(R,{page:"forgot-password",children:[e.jsxs("button",{className:"auth-back",type:"button",onClick:()=>o("/login"),"data-testid":"forgot-back-login",children:[e.jsx(Q,{size:16}),"Sign in"]}),e.jsx("div",{className:"auth-mark auth-mark--amber",children:e.jsx(z,{size:28})}),e.jsx("h1",{children:"Forgot password?"}),e.jsx("p",{children:"No worries. Enter your email and the React auth shell will walk through the reset flow."}),i&&e.jsx("div",{className:"auth-inline-error","data-testid":"forgot-error",children:i}),x?e.jsxs("div",{className:"auth-success-panel","data-testid":"forgot-success",children:[e.jsx($,{size:32}),e.jsx("strong",{children:"Check your email"}),e.jsxs("span",{children:["Reset instructions were prepared for ",a,"."]}),e.jsx("button",{className:"btn btn-primary",type:"button",onClick:()=>o("/reset-password"),"data-testid":"forgot-continue-reset",children:"Continue to reset"})]}):e.jsxs("form",{className:"auth-form",onSubmit:b,"data-testid":"forgot-password-form",children:[e.jsxs("label",{children:[e.jsx("span",{children:"Email Address"}),e.jsxs("div",{className:"auth-input-wrap",children:[e.jsx(z,{size:18}),e.jsx("input",{value:a,onChange:w=>u(w.target.value),type:"email",placeholder:"you@example.com","data-testid":"forgot-email"})]})]}),e.jsxs("button",{className:"btn btn-primary auth-submit",type:"submit",disabled:t,"data-testid":"forgot-submit",children:[e.jsx(Z,{size:16}),t?"Sending...":"Send Reset Link"]})]})]})}function pe({navigate:o}){const[a,u]=r.useState(""),[t,l]=r.useState(""),[i,d]=r.useState(!1),[x,c]=r.useState(!1),[m,b]=r.useState(!1),[w,p]=r.useState(""),j=r.useMemo(()=>S(),[]),y=r.useMemo(()=>a.length>=6&&a===t,[t,a]),v=t.length>0&&t!==a,A=async s=>{if(s.preventDefault(),a.length<6){p("Password must be at least 6 characters.");return}if(a!==t){p("Passwords do not match.");return}if(c(!0),p(""),j.passwordReset.canAttempt){try{await W(g(),a),b(!0),c(!1),f.emit("auth.password.updated",{provider:"supabase"})}catch(n){p(n instanceof Error?n.message:String(n)),c(!1)}return}window.setTimeout(()=>{b(!0),c(!1),f.emit("auth.password.updated",{localShell:!0})},520)};return e.jsxs(R,{page:"reset-password",children:[e.jsx("div",{className:`auth-mark ${m?"auth-mark--success":""}`,children:m?e.jsx($,{size:30}):e.jsx(N,{size:30})}),e.jsx("h1",{children:m?"Password reset!":"Reset password"}),e.jsx("p",{"data-testid":"reset-message",children:m?"Your local auth shell accepted the new password state.":"Enter a new password and confirm it below."}),w&&e.jsx("div",{className:"auth-inline-error","data-testid":"reset-error",children:w}),m?e.jsxs("button",{className:"btn btn-primary auth-submit",type:"button",onClick:()=>o("/login"),"data-testid":"reset-login",children:[e.jsx(B,{size:16}),"Sign In"]}):e.jsxs("form",{className:"auth-form",onSubmit:A,"data-testid":"reset-password-form",children:[e.jsxs("label",{children:[e.jsx("span",{children:"New Password"}),e.jsxs("div",{className:"auth-input-wrap",children:[e.jsx(N,{size:18}),e.jsx("input",{value:a,onChange:s=>u(s.target.value),type:i?"text":"password",placeholder:"Enter new password","data-testid":"reset-password-input"}),e.jsx("button",{type:"button",className:"auth-icon-button",title:"Toggle password visibility",onClick:()=>d(s=>!s),"data-testid":"reset-toggle-visibility",children:i?e.jsx(ee,{size:17}):e.jsx(te,{size:17})})]}),e.jsx("span",{className:`auth-requirement ${a.length>=6?"is-met":""}`,children:"At least 6 characters"})]}),e.jsxs("label",{children:[e.jsx("span",{children:"Confirm Password"}),e.jsxs("div",{className:"auth-input-wrap",children:[e.jsx(N,{size:18}),e.jsx("input",{value:t,onChange:s=>l(s.target.value),type:"password",placeholder:"Confirm new password","data-testid":"reset-confirm-input"})]}),t&&e.jsx("span",{className:`auth-requirement ${v?"is-error":"is-met"}`,children:v?"Passwords do not match":"Passwords match"})]}),e.jsxs("button",{className:"btn btn-primary auth-submit",type:"submit",disabled:!y||x,"data-testid":"reset-submit",children:[e.jsx(B,{size:16}),x?"Updating...":"Update Password"]})]})]})}function R({children:o,page:a}){const u=S();return e.jsxs("div",{className:"auth-page","data-testid":"auth-shell","data-auth-page":a,"data-auth-storage-key":K,"data-pricing-checkout-intent-key":U,"data-production-adapter-state":u.overallState,"data-auth-provider-mode":u.auth.mode,"data-auth-provider-ready":u.auth.canAttempt?"true":"false","data-client-secret-blocked":u.forbiddenClientSecretKeys.length>0?"true":"false",children:[e.jsx("div",{className:"auth-scrim"}),e.jsx("section",{className:"auth-card",children:o})]})}export{he as ForgotPasswordPage,de as LoginPage,pe as ResetPasswordPage};
|