pi-mega-compact 0.20.74 → 0.20.76

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/dist/config/vector-cortex-enc2c.js +9 -6
  2. package/dist/extensions/dashboard-server/api-contracts/setup-cortex-native-ort.js +5 -3
  3. package/dist/extensions/dashboard-server/routes-rag-settings-vector-cortex.js +1 -1
  4. package/dist/extensions/dashboard-server/setup-cortex-actions-native-ort.js +176 -49
  5. package/dist/src/config/vector-cortex-enc2c.js +9 -6
  6. package/dist/src/vector-cortex/encoder/native-qualify-retest.js +9 -5
  7. package/dist/src/vector-cortex/setup-cortex-blockers-compute.js +5 -3
  8. package/dist/vector-cortex/encoder/native-qualify-retest.js +9 -5
  9. package/dist/vector-cortex/setup-cortex-blockers-compute.js +5 -3
  10. package/extensions/dashboard-client/dist/assets/{AdminTab-CqhIxrlT.js → AdminTab-B8JqsA41.js} +2 -2
  11. package/extensions/dashboard-client/dist/assets/{AdminTab-CqhIxrlT.js.map → AdminTab-B8JqsA41.js.map} +1 -1
  12. package/extensions/dashboard-client/dist/assets/{AreaChart-D4EY7yiY.js → AreaChart-CeaexvWO.js} +2 -2
  13. package/extensions/dashboard-client/dist/assets/{AreaChart-D4EY7yiY.js.map → AreaChart-CeaexvWO.js.map} +1 -1
  14. package/extensions/dashboard-client/dist/assets/{BarChart-r_BFpd7a.js → BarChart-Bhyviy7_.js} +2 -2
  15. package/extensions/dashboard-client/dist/assets/{BarChart-r_BFpd7a.js.map → BarChart-Bhyviy7_.js.map} +1 -1
  16. package/extensions/dashboard-client/dist/assets/{CacheTab-Bf5rwce6.js → CacheTab-C6bFdEHq.js} +2 -2
  17. package/extensions/dashboard-client/dist/assets/{CacheTab-Bf5rwce6.js.map → CacheTab-C6bFdEHq.js.map} +1 -1
  18. package/extensions/dashboard-client/dist/assets/{ConfigTab-RFUXAUIP.js → ConfigTab-CbsdI5yj.js} +2 -2
  19. package/extensions/dashboard-client/dist/assets/{ConfigTab-RFUXAUIP.js.map → ConfigTab-CbsdI5yj.js.map} +1 -1
  20. package/extensions/dashboard-client/dist/assets/{EventsTab-DEqHbSHf.js → EventsTab-kvB5Znx2.js} +2 -2
  21. package/extensions/dashboard-client/dist/assets/{EventsTab-DEqHbSHf.js.map → EventsTab-kvB5Znx2.js.map} +1 -1
  22. package/extensions/dashboard-client/dist/assets/{HealthTab-WGEwtqmO.js → HealthTab-DqEUk5LW.js} +2 -2
  23. package/extensions/dashboard-client/dist/assets/{HealthTab-WGEwtqmO.js.map → HealthTab-DqEUk5LW.js.map} +1 -1
  24. package/extensions/dashboard-client/dist/assets/{MaintenanceTab-ClT1D4P9.js → MaintenanceTab-CS5HqDkY.js} +2 -2
  25. package/extensions/dashboard-client/dist/assets/{MaintenanceTab-ClT1D4P9.js.map → MaintenanceTab-CS5HqDkY.js.map} +1 -1
  26. package/extensions/dashboard-client/dist/assets/{MemoryMapTab-DaAxLJ5x.js → MemoryMapTab-Oq-iqvUq.js} +2 -2
  27. package/extensions/dashboard-client/dist/assets/{MemoryMapTab-DaAxLJ5x.js.map → MemoryMapTab-Oq-iqvUq.js.map} +1 -1
  28. package/extensions/dashboard-client/dist/assets/{MetricsCards-CprVx2Yq.js → MetricsCards-36RVmtPj.js} +2 -2
  29. package/extensions/dashboard-client/dist/assets/{MetricsCards-CprVx2Yq.js.map → MetricsCards-36RVmtPj.js.map} +1 -1
  30. package/extensions/dashboard-client/dist/assets/MetricsTab-Clkcniuo.js +2 -0
  31. package/extensions/dashboard-client/dist/assets/{MetricsTab-8WBHRpRp.js.map → MetricsTab-Clkcniuo.js.map} +1 -1
  32. package/extensions/dashboard-client/dist/assets/{OverviewTab-C5ClXheK.js → OverviewTab-Cl2Zx7r1.js} +2 -2
  33. package/extensions/dashboard-client/dist/assets/{OverviewTab-C5ClXheK.js.map → OverviewTab-Cl2Zx7r1.js.map} +1 -1
  34. package/extensions/dashboard-client/dist/assets/{ReposTab-BOX5sOBg.js → ReposTab-DUoDgjk-.js} +2 -2
  35. package/extensions/dashboard-client/dist/assets/{ReposTab-BOX5sOBg.js.map → ReposTab-DUoDgjk-.js.map} +1 -1
  36. package/extensions/dashboard-client/dist/assets/{SessionsTab-DKUO5gCp.js → SessionsTab-hEQ_OAfB.js} +2 -2
  37. package/extensions/dashboard-client/dist/assets/{SessionsTab-DKUO5gCp.js.map → SessionsTab-hEQ_OAfB.js.map} +1 -1
  38. package/extensions/dashboard-client/dist/assets/{SetupTab-CeeRk5Rd.js → SetupTab-Bqibg0cD.js} +3 -3
  39. package/extensions/dashboard-client/dist/assets/SetupTab-Bqibg0cD.js.map +1 -0
  40. package/extensions/dashboard-client/dist/assets/{TimeSavedCard-Dlhljae9.js → TimeSavedCard-9QMQUc7L.js} +2 -2
  41. package/extensions/dashboard-client/dist/assets/{TimeSavedCard-Dlhljae9.js.map → TimeSavedCard-9QMQUc7L.js.map} +1 -1
  42. package/extensions/dashboard-client/dist/assets/{TurnMemoryView-B8fWymMP.js → TurnMemoryView-DAfqhJqd.js} +2 -2
  43. package/extensions/dashboard-client/dist/assets/{TurnMemoryView-B8fWymMP.js.map → TurnMemoryView-DAfqhJqd.js.map} +1 -1
  44. package/extensions/dashboard-client/dist/assets/TurnsTab-C-uZNH2F.js +2 -0
  45. package/extensions/dashboard-client/dist/assets/{TurnsTab-kJ4sfWSd.js.map → TurnsTab-C-uZNH2F.js.map} +1 -1
  46. package/extensions/dashboard-client/dist/assets/{VcStatusBadge-FJZlkrD7.js → VcStatusBadge-DyOagOVb.js} +2 -2
  47. package/extensions/dashboard-client/dist/assets/{VcStatusBadge-FJZlkrD7.js.map → VcStatusBadge-DyOagOVb.js.map} +1 -1
  48. package/extensions/dashboard-client/dist/assets/{VectorCortexTab-C1iE6z4c.js → VectorCortexTab-BxsbSUGv.js} +2 -2
  49. package/extensions/dashboard-client/dist/assets/{VectorCortexTab-C1iE6z4c.js.map → VectorCortexTab-BxsbSUGv.js.map} +1 -1
  50. package/extensions/dashboard-client/dist/assets/{WikiTab-BXqRiTbt.js → WikiTab-CjefloQb.js} +2 -2
  51. package/extensions/dashboard-client/dist/assets/{WikiTab-BXqRiTbt.js.map → WikiTab-CjefloQb.js.map} +1 -1
  52. package/extensions/dashboard-client/dist/assets/{button-CUeN3VyF.js → button-D-9nb4Bw.js} +2 -2
  53. package/extensions/dashboard-client/dist/assets/{button-CUeN3VyF.js.map → button-D-9nb4Bw.js.map} +1 -1
  54. package/extensions/dashboard-client/dist/assets/{card-DtOD33bZ.js → card-Dvl16_R5.js} +2 -2
  55. package/extensions/dashboard-client/dist/assets/{card-DtOD33bZ.js.map → card-Dvl16_R5.js.map} +1 -1
  56. package/extensions/dashboard-client/dist/assets/{client-extra-_tIKSPZ3.js → client-extra-BShDrG99.js} +2 -2
  57. package/extensions/dashboard-client/dist/assets/{client-extra-_tIKSPZ3.js.map → client-extra-BShDrG99.js.map} +1 -1
  58. package/extensions/dashboard-client/dist/assets/{generateCategoricalChart-8AyWGIrK.js → generateCategoricalChart-Q_V4fqVi.js} +2 -2
  59. package/extensions/dashboard-client/dist/assets/{generateCategoricalChart-8AyWGIrK.js.map → generateCategoricalChart-Q_V4fqVi.js.map} +1 -1
  60. package/extensions/dashboard-client/dist/assets/{index-BBJ8LglL.js → index-CL6Af_JZ.js} +3 -3
  61. package/extensions/dashboard-client/dist/assets/{index-BBJ8LglL.js.map → index-CL6Af_JZ.js.map} +1 -1
  62. package/extensions/dashboard-client/dist/assets/{switch-Drm0yRgr.js → switch-0MNUTR9I.js} +2 -2
  63. package/extensions/dashboard-client/dist/assets/{switch-Drm0yRgr.js.map → switch-0MNUTR9I.js.map} +1 -1
  64. package/extensions/dashboard-client/dist/assets/{toggle-DnRtZDPW.js → toggle-DHbWo-CW.js} +2 -2
  65. package/extensions/dashboard-client/dist/assets/{toggle-DnRtZDPW.js.map → toggle-DHbWo-CW.js.map} +1 -1
  66. package/extensions/dashboard-client/dist/assets/{useSSE-l_bpRt_v.js → useSSE-DcBpzKtI.js} +2 -2
  67. package/extensions/dashboard-client/dist/assets/{useSSE-l_bpRt_v.js.map → useSSE-DcBpzKtI.js.map} +1 -1
  68. package/extensions/dashboard-client/dist/index.html +1 -1
  69. package/extensions/dashboard-client/src/tabs/SetupTab/CortexActionsCard.tsx +15 -7
  70. package/extensions/dashboard-client/src/tabs/SetupTab/CortexRetestCard.tsx +11 -1
  71. package/extensions/dashboard-client/src/tabs/SetupTab/CortexRuntimeCard.tsx +1 -1
  72. package/extensions/dashboard-server/api-contracts/setup-cortex-native-ort.ts +5 -3
  73. package/extensions/dashboard-server/routes-rag-settings-vector-cortex.ts +1 -1
  74. package/extensions/dashboard-server/setup-cortex-actions-native-ort.ts +203 -51
  75. package/package.json +1 -1
  76. package/src/config/vector-cortex-enc2c.ts +9 -6
  77. package/src/vector-cortex/encoder/native-qualify-retest.ts +9 -5
  78. package/src/vector-cortex/setup-cortex-blockers-compute.ts +5 -3
  79. package/extensions/dashboard-client/dist/assets/MetricsTab-8WBHRpRp.js +0 -2
  80. package/extensions/dashboard-client/dist/assets/SetupTab-CeeRk5Rd.js.map +0 -1
  81. package/extensions/dashboard-client/dist/assets/TurnsTab-kJ4sfWSd.js +0 -2
@@ -9,12 +9,15 @@
9
9
  *
10
10
  * ENC-2c turns ENC-2a's operator run-script assist into a dashboard action: the
11
11
  * Setup Cortex sub-tab gains an "Install Native ORT" button that, when confirmed
12
- * by the operator, runs the committed `scripts/encoder/install-native-ort.mjs`
13
- * subprocess locally (npm-delegated, sha256-verified) and then re-qualifies the
14
- * binding via the ENC-2b retest path. This is a PREVENT-PI-004 opt-in exemption:
15
- * it is confirm-gated (never automatic), delegated to a local subprocess of a
16
- * committed repo script, and carries NO URL literals in src/ or extensions/
17
- * (the registry URL + sha256 live only in the artifacts-module constants).
12
+ * by the operator, performs the pinned-tarball fetch + sha256 verify + npm
13
+ * install in-process (a TypeScript port of
14
+ * `scripts/encoder/install-native-ort.mjs` the npm package ships
15
+ * src/dist/extensions but NOT scripts/, so an installed device has no checkout
16
+ * script to spawn), then re-qualifies the binding via the ENC-2b retest path.
17
+ * This is a PREVENT-PI-004 opt-in exemption: it is confirm-gated (never
18
+ * automatic), delegated to the operator's npm as a local subprocess, and carries
19
+ * NO URL literals in src/ or extensions/ (the registry URL + sha256 live only
20
+ * in the artifacts-module constants).
18
21
  *
19
22
  * `MEGACOMPACT_ENC_2C=0` disables: no install action branch, no UI button, no
20
23
  * install-related result fields — byte-identical to the ENC-2b predecessor. The
@@ -3,9 +3,11 @@
3
3
  * lazy-download INSTALL action contract types.
4
4
  *
5
5
  * Sibling additive types for the VC9B action driver: POST /api/setup-cortex-action
6
- * gains the `install-native-ort` action that, when confirmed, runs the committed
7
- * scripts/encoder/install-native-ort.mjs subprocess locally (npm-delegated,
8
- * sha256-verified) and then re-qualifies the binding via the ENC-2b retest path.
6
+ * gains the `install-native-ort` action that, when confirmed, performs the
7
+ * pinned-tarball fetch + sha256 verify + npm install in-process (a TypeScript
8
+ * port of scripts/encoder/install-native-ort.mjs the npm package ships
9
+ * src/dist/extensions but NOT scripts/, so an installed device has no checkout
10
+ * script to spawn), then re-qualifies the binding via the ENC-2b retest path.
9
11
  *
10
12
  * The retest result shape mirrors `RetestResult` from
11
13
  * extensions/dashboard-server/api-contracts/setup.ts (and
@@ -72,7 +72,7 @@ export const VECTOR_CORTEX_SETTINGS = {
72
72
  boolDirect("MEGACOMPACT_ENC_2BUDGET", "ENC-2a operator-configurable native install-budget knob", "ENC-2a exposes the runtime operator knob MEGACOMPACT_NATIVE_ORT_BUDGET_MIB (default 300 MiB, clamp 8192) as a dashboard Settings field. The knob gates budgetOk in the encoder runtime decision (decision.ts installBudgetMib + runtime-select.ts selectRuntimeBackend). Persisted to the per-repo .mega-compact.env via the setup-configure writer branch; the GET status route surfaces the persisted value AND the effective integer installBudgetMib() resolves to (so the dashboard shows the runtime's actual operand). OFF = no new GET fields, no writer branch, no new Settings rows (byte-identical ENC-1b predecessor).", true),
73
73
  boolDirect("MEGACOMPACT_ENC_2A", "ENC-2a native onnxruntime install GUIDE (detect + copy-paste)", "ENC-2a surfaces the platform-matched native onnxruntime install-guide (three copy-paste steps + script path) on the Setup Cortex sub-tab when the operator opted into the native backend but the effective runtime is still wasm (onnxruntime-node absent). Pure guidance — the extension NEVER executes or fetches (PREVENT-PI-004 unchanged); the committed operator script scripts/encoder/install-native-ort.mjs runs in the USER's shell. OFF = no guide GET fields, no guide-request POST branch, no install card (byte-identical ENC-1b predecessor).", true),
74
74
  boolDirect("MEGACOMPACT_ENC_2B", "ENC-2b native ONNX runtime qualification retest (detect + re-qualify)", "ENC-2b re-probes and re-qualifies the installed native onnxruntime binding (onnxruntime-node in ~/.pi/mega-compact/native-ort/, operator-installed via the ENC-2a guide): loads the LOCAL on-disk binding, runs a bounded warmup + p95 probe, measures RSS, and computes a fresh qualification verdict against the ENC-0f p95 budget + the operator install-budget. Never downloads or trains (PREVENT-PI-004 / HG-1 unchanged); surfaces nativeOrtRetestResult + nativeOrtBackendEffective on the GET /api/setup-status. OFF = no retest GET fields, no retest POST branch, no retest card (byte-identical ENC-2a predecessor).", true),
75
- boolDirect("MEGACOMPACT_ENC_2C", "ENC-2c native ONNX runtime lazy-download INSTALL action (dashboard-triggered)", "ENC-2c turns ENC-2a's operator run-script assist into a confirm-gated dashboard action: the Setup Cortex sub-tab gains an Install Native ORT button that, when the operator confirms, runs the committed scripts/encoder/install-native-ort.mjs subprocess locally (npm-delegated, sha256-verified) and then re-qualifies the binding via the ENC-2b retest path, exposing nativeOrtRetestResult / nativeOrtBackendEffective on the completion. PREVENT-PI-004 opt-in exemption: confirm-gated, npm-delegated, no URL literals (registry URL + sha256 live only in native-install-artifacts.ts). OFF = no install action POST branch, no UI button, no install result fields (byte-identical ENC-2b predecessor).", true),
75
+ boolDirect("MEGACOMPACT_ENC_2C", "ENC-2c native ONNX runtime lazy-download INSTALL action (dashboard-triggered)", "ENC-2c turns ENC-2a's operator run-script assist into a confirm-gated dashboard action: the Setup Cortex sub-tab gains an Install Native ORT button that, when the operator confirms, performs the pinned-tarball fetch + sha256 verify + npm install in-process (TypeScript port of scripts/encoder/install-native-ort.mjs the npm package doesn't ship scripts/, so installed devices have no checkout script to spawn) and then re-qualifies the binding via the ENC-2b retest path, exposing nativeOrtRetestResult / nativeOrtBackendEffective on the completion. PREVENT-PI-004 opt-in exemption: confirm-gated, npm-delegated, no URL literals (registry URL + sha256 live only in native-install-artifacts.ts). OFF = no install action POST branch, no UI button, no install result fields (byte-identical ENC-2b predecessor).", true),
76
76
  boolDirect("MEGACOMPACT_COSINE_FP_BENCH", "COS-FP-A Synthetic FP Bench", "Synthetic FP harness + L2 cosine threshold calibration (COS-FP-A): drives the deterministic synthetic-corpus grid sweep (scripts/cosine-fp/bench.mjs) that measures L2 cosine false-positive rates and emits a recommended default, and serves the reader-only GET /api/cosine-fp-report. Synthetic-corpus-only — never reads real session/ledger bytes. OFF = bench inert, endpoint 404s, no report write, L2_COSINE plain MEGACOMPACT_L2_THRESHOLD (byte-identical predecessor).", true),
77
77
  boolDirect("MEGACOMPACT_COSINE_FP_REAL", "COS-FP-R Real-Corpus Validation", "Real-corpus L2 cosine FP validation (COS-FP-R): runs the real-corpus grid sweep (scripts/cosine-fp/real-bench.mjs) against donated, consent-approved sessions only (SECURITY_PRIVACY Lifecycle/Consent), scoring FP/FN with Wilson intervals + session-grouped bootstrap, and appends CI-backed per-content-type recommendations to the cosine-threshold report. Runs only when a valid consented corpus exists; absent corpus = no_corpus (normative pre-donation state, nothing written). OFF = script inert, nothing executes, no writes (byte-identical predecessor).", true),
78
78
  boolDirect("MEGACOMPACT_REPO_CORPUS", "Cross-Repo Corpus (REPO-A)", "Cross-repo corpus preparation (REPO-A): the governed, consent-gated reader-only path that builds a pseudonymous corpus manifest from per-repo events.log slices and serves GET /api/repo-corpus answering which pseudonymous repos/sessions are in the corpus, what cross-repo overlap exists, and whether consent is active for each — counts + IDs + status only, never payload content. Consent is append-only (consent.mjs, CLI/ops-only); revocation freezes the builder + route. OFF = builder refuses to run, reader route 404s, single-repo recall untouched (byte-identical predecessor).", true),
@@ -5,30 +5,99 @@
5
5
  * Sibling of setup-cortex-actions.ts (which stays under the 300-line source soft
6
6
  * cap). Implements the mechanics behind the VC9B `install-native-ort` action:
7
7
  *
8
- * 1. locate the committed scripts/encoder/install-native-ort.mjs by walking up
9
- * to the repo root (mirroring setup-cortex-actions.ts vc2ScriptDir);
10
- * 2. spawn `node <script>` locally with a 60s timeout (npm-delegated,
11
- * sha256-verified install the registry URL + sha256 live ONLY in
12
- * src/vector-cortex/encoder/native-install-artifacts.ts, never here);
13
- * 3. capture output to <stateDir>/logs/vc9b/install-native-ort-<ts>.log;
14
- * 4. REGARDLESS of the install exit code, re-qualify the binding via the ENC-2b
15
- * retest path (`runNativeRetest`) and surface the fresh result +
16
- * effective backend.
8
+ * 1. compute the install root (`MEGACOMPACT_NATIVE_ORT_ROOT` override, else
9
+ * default ~/.pi/mega-compact/native-ort);
10
+ * 2. detect the host platform and reject non-installable hosts (ENC-0e);
11
+ * 3. fetch the pinned onnxruntime-node tarball via the operator's npm and
12
+ * verify its sha256 BEFORE install (the tarball never lands in the final
13
+ * prefix until the pinned sha matches);
14
+ * 4. `npm install --prefix <root> <tarball>` from the VERIFIED local tarball;
15
+ * 5. write a small `.enc2a-marker.json` marker ({platform, version, sha256})
16
+ * the ENC-2a version probe reads;
17
+ * 6. REGARDLESS of install exit code, re-qualify the binding via the ENC-2b
18
+ * retest path (`runNativeRetest`) and surface the fresh result + effective
19
+ * backend.
17
20
  *
18
21
  * PREVENT-PI-004 banner: this is an OPT-IN, confirm-gated, npm-delegated local
19
22
  * subprocess of a committed repo script. It performs no network I/O in this
20
23
  * module and carries NO URL literals (the codebase-wide no-URL-literal scan
21
24
  * covers src/ + extensions/).
22
25
  *
23
- * Guardrails: PREVENT-011 (no `any`); the subprocess is a committed local script,
24
- * never fetched (PREVENT-PI-004, guardrails-allow below).
26
+ * In-process port of scripts/encoder/install-native-ort.mjs: the npm package
27
+ * ships src/ + dist/ + extensions/ but NOT scripts/, so the dashboard button on
28
+ * an installed device has no checkout script to spawn — porting the install
29
+ * logic here keeps the action working independent of the checkout layout.
30
+ *
31
+ * Guardrails: PREVENT-011 (no `any`); PREVENT-PI-004 (npm-delegated local
32
+ * subprocess; guardrails-allow below).
25
33
  */
26
- import { spawnSync } from "node:child_process"; // guardrails-allow PREVENT-PI-004: opt-in, confirm-gated, npm-delegated install subprocess (local spawn of committed repo script; no URL literals)
27
- import { mkdirSync, writeFileSync, existsSync } from "node:fs";
34
+ import { spawnSync } from "node:child_process"; // guardrails-allow PREVENT-PI-004: opt-in, confirm-gated, npm-delegated install subprocess (local spawn of committed npm tooling; no URL literals)
35
+ import { createHash } from "node:crypto";
36
+ import { mkdirSync, writeFileSync, existsSync, rmSync, readFileSync } from "node:fs";
28
37
  import { join, dirname } from "node:path";
29
38
  import { fileURLToPath } from "node:url";
30
39
  import { runNativeRetest } from "../../src/vector-cortex/encoder/native-qualify-retest.js";
31
- /** Locate scripts/encoder/install-native-ort.mjs by walking up to the repo root. */
40
+ import { NATIVE_ORT_PACKAGE, NATIVE_ORT_TARBALL_SHA256, NATIVE_ORT_VERSION, NATIVE_ORT_INSTALLABLE_PLATFORMS, } from "../../src/vector-cortex/encoder/native-install-artifacts.js";
41
+ /** Candidate install roots: `MEGACOMPACT_NATIVE_ORT_ROOT` override first
42
+ * (ENC-2a parity + test isolation), else the default `~/.pi/mega-compact/
43
+ * native-ort/`. */
44
+ function nativeOrtDir() {
45
+ const override = process.env.MEGACOMPACT_NATIVE_ORT_ROOT;
46
+ if (override !== undefined && override.length > 0)
47
+ return override;
48
+ return join(process.env.HOME ?? "", ".pi", "mega-compact", "native-ort");
49
+ }
50
+ /** Resolve the host to an installable EncoderPlatform string. darwin-x64 is
51
+ * UNSUPPORTED (no native binding upstream — arm64-only since 1.17) and
52
+ * unknown platforms also fail → the caller surfaces a clear failure. */
53
+ function hostPlatform() {
54
+ const plat = process.platform === "win32"
55
+ ? "win32"
56
+ : process.platform === "darwin"
57
+ ? "darwin"
58
+ : process.platform === "linux"
59
+ ? "linux"
60
+ : "";
61
+ const arch = process.arch === "x64" ? "x64" : process.arch === "arm64" ? "arm64" : "";
62
+ const candidate = `${plat}-${arch}`;
63
+ if (candidate === "darwin-x64")
64
+ return null; // no native binding upstream
65
+ if (!NATIVE_ORT_INSTALLABLE_PLATFORMS.includes(candidate))
66
+ return null;
67
+ return candidate;
68
+ }
69
+ /** sha256 digest of a file on disk. Local FS read (loopback). */
70
+ function sha256File(path) {
71
+ // guardrails-allow PREVENT-PI-004: local file hash (loopback)
72
+ return createHash("sha256").update(readFileSync(path)).digest("hex");
73
+ }
74
+ /** Write the small `.enc2a-marker.json` marker the ENC-2a version probe reads. */
75
+ function writeMarker(root, platform) {
76
+ const marker = {
77
+ platform,
78
+ version: NATIVE_ORT_VERSION,
79
+ installedAt: new Date().toISOString(),
80
+ sha256: NATIVE_ORT_TARBALL_SHA256,
81
+ };
82
+ // guardrails-allow PREVENT-PI-004: local marker write (loopback)
83
+ writeFileSync(join(root, ".enc2a-marker.json"), JSON.stringify(marker, null, 2) + "\n", "utf8");
84
+ }
85
+ /** Ensure the vc9b log dir exists (mirrors setup-cortex-actions.ts). */
86
+ function ensureLogDir(stateDir) {
87
+ const dir = join(stateDir, "logs", "vc9b");
88
+ // guardrails-allow PREVENT-PI-004: local state-dir filesystem write (loopback)
89
+ mkdirSync(dir, { recursive: true });
90
+ return dir;
91
+ }
92
+ function writeLog(logPath, body) {
93
+ // guardrails-allow PREVENT-PI-004: local state-dir filesystem write (loopback)
94
+ writeFileSync(logPath, body, "utf8");
95
+ }
96
+ /** The original committed-install-script path lookup, kept for the unit test
97
+ * that proves the committed scripts/encoder/install-native-ort.mjs lives on
98
+ * disk in a checkout. The install action itself no longer spawns that script
99
+ * (in-process port), but the suite would otherwise need to lose that
100
+ * verification. */
32
101
  export function installScriptPath() {
33
102
  let dir = dirname(fileURLToPath(import.meta.url));
34
103
  const rel = join("scripts", "encoder", "install-native-ort.mjs");
@@ -44,60 +113,118 @@ export function installScriptPath() {
44
113
  }
45
114
  return null;
46
115
  }
47
- /** Ensure the vc9b log dir exists (mirrors setup-cortex-actions.ts). */
48
- function ensureLogDir(stateDir) {
49
- const dir = join(stateDir, "logs", "vc9b");
50
- // guardrails-allow PREVENT-PI-004: local state-dir filesystem write (loopback)
51
- mkdirSync(dir, { recursive: true });
52
- return dir;
53
- }
54
- function writeLog(logPath, body) {
55
- // guardrails-allow PREVENT-PI-004: local state-dir filesystem write (loopback)
56
- writeFileSync(logPath, body, "utf8");
57
- }
58
116
  /**
59
- * Run the ENC-2c lazy-download native onnxruntime INSTALL action. Locates and
60
- * spawns the committed install script (npm-delegated, sha256-verified), logs the
61
- * captured output, then ALWAYS runs the ENC-2b retest to re-qualify the binding
62
- * (regardless of install exit code) and surfaces the fresh result.
117
+ * Run the ENC-2c lazy-download native onnxruntime INSTALL action. Fetches the
118
+ * pinned tarball via the operator's npm, verifies its sha256, installs into
119
+ * `nativeOrtDir()`, then ALWAYS runs the ENC-2b retest to re-qualify the
120
+ * binding and surfacing the fresh result.
63
121
  *
64
- * Never throws: a missing script or non-zero exit is surfaced as ok=false on the
65
- * result; the retest runs even on install failure so the operator sees the
66
- * post-install qualification state. Returns a combined SetupCortexActionResult
67
- * with the ENC-2c additive fields (present only for pendant actions).
122
+ * Never throws: every failure (host platform, npm failure, hash mismatch)
123
+ * surfaces as ok=false on the result; the retest runs even on install failure
124
+ * so the operator sees the post-install qualification state. Returns a
125
+ * combined SetupCortexActionResult with the ENC-2c additive fields (present
126
+ * only for pendant actions).
68
127
  */
69
- // guardrails-allow PREVENT-PI-004: opt-in, confirm-gated, npm-delegated install action (subprocess of committed repo script; no URL literals)
128
+ // guardrails-allow PREVENT-PI-004: opt-in, confirm-gated, npm-delegated install action (subprocess of committed npm tooling; no URL literals)
70
129
  export async function runInstallNativeOrt(stateDir) {
71
130
  const ts = Date.now();
72
131
  const logName = `install-native-ort-${ts}.log`;
73
132
  const logPath = join(ensureLogDir(stateDir), logName);
74
- const scriptPath = installScriptPath();
75
- if (scriptPath === null) {
76
- writeLog(logPath, "install-native-ort.mjs not found in this checkout\n");
133
+ const root = nativeOrtDir();
134
+ const platform = hostPlatform();
135
+ if (platform === null) {
136
+ writeLog(logPath, "install-native-ort: host platform has no native binding\n");
77
137
  return {
78
138
  action: "install-native-ort",
79
139
  ok: false,
80
140
  exitCode: null,
81
141
  logPath,
82
142
  logName,
143
+ spawned: false,
144
+ };
145
+ }
146
+ // Step 1: derive the tarball URL + fetch the tarball via the operator's npm.
147
+ // (The tarball never lands in the final prefix until the pinned sha matches.)
148
+ mkdirSync(root, { recursive: true });
149
+ const packedName = `${NATIVE_ORT_PACKAGE}-${NATIVE_ORT_VERSION}.tgz`;
150
+ const packedPath = join(root, packedName);
151
+ let out = "";
152
+ const run = (argv) => {
153
+ const res = spawnSync("npm", argv, { encoding: "utf8", timeout: 60_000 });
154
+ out += [res.stdout, res.stderr].filter(Boolean).join("\n") + "\n";
155
+ return { code: res.status ?? 1, stdio: out };
156
+ };
157
+ // npm pack <pkg>@<ver> --pack-destination <root>
158
+ // guardrails-allow PREVENT-PI-004: npm-delegated tarball fetch (opt-in
159
+ // confirm-gated install action; package@version come from the committed
160
+ // artifacts module, never a literal URL).
161
+ const pack = run([
162
+ "pack",
163
+ `${NATIVE_ORT_PACKAGE}@${NATIVE_ORT_VERSION}`,
164
+ "--pack-destination",
165
+ root,
166
+ ]);
167
+ if (pack.code !== 0 || !existsSync(packedPath)) {
168
+ writeLog(logPath, `${out}npm pack failed — could not download tarball\n`);
169
+ const retest = await runNativeRetest(stateDir);
170
+ return {
171
+ action: "install-native-ort",
172
+ ok: false,
173
+ exitCode: pack.code,
174
+ logPath,
175
+ logName,
176
+ spawned: true,
177
+ nativeOrtRetestResult: retest,
178
+ nativeOrtBackendEffective: retest !== null && retest.verdict === "qualified" ? "native" : "wasm",
179
+ };
180
+ }
181
+ // Step 2: verify sha256 BEFORE install.
182
+ const actual = sha256File(packedPath);
183
+ if (actual !== NATIVE_ORT_TARBALL_SHA256) {
184
+ writeLog(logPath, `${out}sha256 mismatch — expected ${NATIVE_ORT_TARBALL_SHA256}, got ${actual}\n`);
185
+ // guardrails-allow PREVENT-PI-004: removing a tarball we just wrote (local FS)
186
+ rmSync(packedPath, { force: true });
187
+ const retest = await runNativeRetest(stateDir);
188
+ return {
189
+ action: "install-native-ort",
190
+ ok: false,
191
+ exitCode: 1,
192
+ logPath,
193
+ logName,
194
+ spawned: true,
195
+ nativeOrtRetestResult: retest,
196
+ nativeOrtBackendEffective: retest !== null && retest.verdict === "qualified" ? "native" : "wasm",
197
+ };
198
+ }
199
+ // Step 3: install from the VERIFIED local tarball (npm install --prefix).
200
+ // guardrails-allow PREVENT-PI-004: npm-delegated install from a local tarball
201
+ // (opt-in confirm-gated install action).
202
+ const install = run(["install", "--prefix", root, packedPath]);
203
+ // guardrails-allow PREVENT-PI-004: removing the local tarball after install
204
+ rmSync(packedPath, { force: true });
205
+ const installedPkg = join(root, "node_modules", NATIVE_ORT_PACKAGE, "package.json");
206
+ if (install.code !== 0 || !existsSync(installedPkg)) {
207
+ writeLog(logPath, `${out}npm install from verified tarball failed\n`);
208
+ const retest = await runNativeRetest(stateDir);
209
+ return {
210
+ action: "install-native-ort",
211
+ ok: false,
212
+ exitCode: install.code,
213
+ logPath,
214
+ logName,
83
215
  spawned: true,
216
+ nativeOrtRetestResult: retest,
217
+ nativeOrtBackendEffective: retest !== null && retest.verdict === "qualified" ? "native" : "wasm",
84
218
  };
85
219
  }
86
- // guardrails-allow PREVENT-PI-004: opt-in, confirm-gated, npm-delegated
87
- // install subprocess (local spawn of committed repo script; no URL literals)
88
- const result = spawnSync(process.execPath, [scriptPath], {
89
- encoding: "utf8",
90
- timeout: 60_000,
91
- });
92
- const out = `${result.stdout ?? ""}${result.stderr ?? ""}`;
93
- writeLog(logPath, out || "(no output)\n");
94
- // Re-qualify AFTER install regardless of exit code (the retest is the source of
95
- // truth for whether the binding is actually usable).
220
+ // Step 4: success — write the marker, log, then retest.
221
+ writeMarker(root, platform);
222
+ writeLog(logPath, `${out}installed ${NATIVE_ORT_PACKAGE}@${NATIVE_ORT_VERSION} (${platform}); sha256 verified + marker written.\n`);
96
223
  const retest = await runNativeRetest(stateDir);
97
224
  return {
98
225
  action: "install-native-ort",
99
- ok: result.status === 0,
100
- exitCode: result.status === null ? null : result.status,
226
+ ok: true,
227
+ exitCode: install.code,
101
228
  logPath,
102
229
  logName,
103
230
  spawned: true,
@@ -9,12 +9,15 @@
9
9
  *
10
10
  * ENC-2c turns ENC-2a's operator run-script assist into a dashboard action: the
11
11
  * Setup Cortex sub-tab gains an "Install Native ORT" button that, when confirmed
12
- * by the operator, runs the committed `scripts/encoder/install-native-ort.mjs`
13
- * subprocess locally (npm-delegated, sha256-verified) and then re-qualifies the
14
- * binding via the ENC-2b retest path. This is a PREVENT-PI-004 opt-in exemption:
15
- * it is confirm-gated (never automatic), delegated to a local subprocess of a
16
- * committed repo script, and carries NO URL literals in src/ or extensions/
17
- * (the registry URL + sha256 live only in the artifacts-module constants).
12
+ * by the operator, performs the pinned-tarball fetch + sha256 verify + npm
13
+ * install in-process (a TypeScript port of
14
+ * `scripts/encoder/install-native-ort.mjs` the npm package ships
15
+ * src/dist/extensions but NOT scripts/, so an installed device has no checkout
16
+ * script to spawn), then re-qualifies the binding via the ENC-2b retest path.
17
+ * This is a PREVENT-PI-004 opt-in exemption: it is confirm-gated (never
18
+ * automatic), delegated to the operator's npm as a local subprocess, and carries
19
+ * NO URL literals in src/ or extensions/ (the registry URL + sha256 live only
20
+ * in the artifacts-module constants).
18
21
  *
19
22
  * `MEGACOMPACT_ENC_2C=0` disables: no install action branch, no UI button, no
20
23
  * install-related result fields — byte-identical to the ENC-2b predecessor. The
@@ -37,12 +37,16 @@ import { detectPlatform } from "./asset.js";
37
37
  import { NATIVE_ORT_PACKAGE } from "./native-install-artifacts.js";
38
38
  /** Candidate ONNX runtime native-ort prefixes. The ENC-2a guide installs to
39
39
  * the global `~/.pi/mega-compact/native-ort/`; `stateDir` (per-repo) is a
40
- * secondary probe root so the retest resolves either install location. */
40
+ * secondary probe root so the retest resolves either install location.
41
+ * `MEGACOMPACT_NATIVE_ORT_ROOT` overrides the global root (ENC-2a parity +
42
+ * test isolation — honors the same override the enc2a probe and the ENC-2c
43
+ * in-process installer honor). */
41
44
  function nativeOrtRootCandidates(stateDir) {
42
- return [
43
- join(process.env.HOME ?? "", ".pi", "mega-compact", "native-ort"),
44
- join(stateDir, "native-ort"),
45
- ];
45
+ const override = process.env.MEGACOMPACT_NATIVE_ORT_ROOT;
46
+ const global = override !== undefined && override.length > 0
47
+ ? override
48
+ : join(process.env.HOME ?? "", ".pi", "mega-compact", "native-ort");
49
+ return [global, join(stateDir, "native-ort")];
46
50
  }
47
51
  /** A single bounded inference pass on the fixed 512-token synthetic input;
48
52
  * returns latency ms, or null when the session cannot run (caller reports
@@ -200,9 +200,11 @@ const ACTION_GATE_CANDIDATES = {
200
200
  // behavior change. HG-7 is training work (no action in this set).
201
201
  bench: ["HG-1", "HG-3", "HG-6"],
202
202
  "verify-asset": [],
203
- // ENC-2c: installing the lazy-download native binding is gated by HG-3 (the
204
- // open install-budget hard gate) a closed HG-3 no longer blocks the install.
205
- "install-native-ort": ["HG-3"],
203
+ // install-native-ort is NEVER gated by HG-3: the action's entire purpose is
204
+ // to install the binding that closes HG-3. Gating it would deadlock — you
205
+ // can't install the binding that closes the gate because the gate blocks the
206
+ // install. HG-3 closes when the install succeeds (the probe detects it).
207
+ "install-native-ort": [],
206
208
  };
207
209
  /**
208
210
  * Re-derived VC9B action gating from the LIVE computed blockers. An action is
@@ -37,12 +37,16 @@ import { detectPlatform } from "./asset.js";
37
37
  import { NATIVE_ORT_PACKAGE } from "./native-install-artifacts.js";
38
38
  /** Candidate ONNX runtime native-ort prefixes. The ENC-2a guide installs to
39
39
  * the global `~/.pi/mega-compact/native-ort/`; `stateDir` (per-repo) is a
40
- * secondary probe root so the retest resolves either install location. */
40
+ * secondary probe root so the retest resolves either install location.
41
+ * `MEGACOMPACT_NATIVE_ORT_ROOT` overrides the global root (ENC-2a parity +
42
+ * test isolation — honors the same override the enc2a probe and the ENC-2c
43
+ * in-process installer honor). */
41
44
  function nativeOrtRootCandidates(stateDir) {
42
- return [
43
- join(process.env.HOME ?? "", ".pi", "mega-compact", "native-ort"),
44
- join(stateDir, "native-ort"),
45
- ];
45
+ const override = process.env.MEGACOMPACT_NATIVE_ORT_ROOT;
46
+ const global = override !== undefined && override.length > 0
47
+ ? override
48
+ : join(process.env.HOME ?? "", ".pi", "mega-compact", "native-ort");
49
+ return [global, join(stateDir, "native-ort")];
46
50
  }
47
51
  /** A single bounded inference pass on the fixed 512-token synthetic input;
48
52
  * returns latency ms, or null when the session cannot run (caller reports
@@ -200,9 +200,11 @@ const ACTION_GATE_CANDIDATES = {
200
200
  // behavior change. HG-7 is training work (no action in this set).
201
201
  bench: ["HG-1", "HG-3", "HG-6"],
202
202
  "verify-asset": [],
203
- // ENC-2c: installing the lazy-download native binding is gated by HG-3 (the
204
- // open install-budget hard gate) a closed HG-3 no longer blocks the install.
205
- "install-native-ort": ["HG-3"],
203
+ // install-native-ort is NEVER gated by HG-3: the action's entire purpose is
204
+ // to install the binding that closes HG-3. Gating it would deadlock — you
205
+ // can't install the binding that closes the gate because the gate blocks the
206
+ // install. HG-3 closes when the install succeeds (the probe detects it).
207
+ "install-native-ort": [],
206
208
  };
207
209
  /**
208
210
  * Re-derived VC9B action gating from the LIVE computed blockers. An action is
@@ -1,2 +1,2 @@
1
- import{r as s,u as o,e as c,j as e}from"./index-BBJ8LglL.js";import{T as i}from"./toggle-DnRtZDPW.js";import r from"./MaintenanceTab-ClT1D4P9.js";import{C as l}from"./ConfigTab-RFUXAUIP.js";import"./card-DtOD33bZ.js";import"./button-CUeN3VyF.js";import"./switch-Drm0yRgr.js";const f="MEGACOMPACT_DASH_0C";function m(n){if(!n)return!1;for(const t of n.categories)for(const a of t.settings)if(a.key===f&&a.type==="boolean")return a.value===!0;return!1}function h(){const[n,t]=s.useState("maintenance"),{data:a}=o(s.useCallback(()=>c(),[]),{pollInterval:0,maxRetries:0});return m(a)?e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2",role:"tablist","aria-label":"Admin views",children:[e.jsx(i,{pressed:n==="maintenance",onClick:()=>t("maintenance"),children:"Maintenance"}),e.jsx(i,{pressed:n==="config",onClick:()=>t("config"),children:"Config"})]}),n==="maintenance"?e.jsx(r,{}):e.jsx(l,{})]}):e.jsx(r,{})}export{h as default};
2
- //# sourceMappingURL=AdminTab-CqhIxrlT.js.map
1
+ import{r as s,u as o,e as c,j as e}from"./index-CL6Af_JZ.js";import{T as i}from"./toggle-DHbWo-CW.js";import r from"./MaintenanceTab-CS5HqDkY.js";import{C as l}from"./ConfigTab-CbsdI5yj.js";import"./card-Dvl16_R5.js";import"./button-D-9nb4Bw.js";import"./switch-0MNUTR9I.js";const f="MEGACOMPACT_DASH_0C";function m(n){if(!n)return!1;for(const t of n.categories)for(const a of t.settings)if(a.key===f&&a.type==="boolean")return a.value===!0;return!1}function h(){const[n,t]=s.useState("maintenance"),{data:a}=o(s.useCallback(()=>c(),[]),{pollInterval:0,maxRetries:0});return m(a)?e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2",role:"tablist","aria-label":"Admin views",children:[e.jsx(i,{pressed:n==="maintenance",onClick:()=>t("maintenance"),children:"Maintenance"}),e.jsx(i,{pressed:n==="config",onClick:()=>t("config"),children:"Config"})]}),n==="maintenance"?e.jsx(r,{}):e.jsx(l,{})]}):e.jsx(r,{})}export{h as default};
2
+ //# sourceMappingURL=AdminTab-B8JqsA41.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"AdminTab-CqhIxrlT.js","sources":["../../src/tabs/AdminTab.tsx"],"sourcesContent":["/**\n * dashboard-client/src/tabs/AdminTab.tsx — Admin tab (DASH-0c delegate-shell).\n *\n * DASH-0c: the Admin surface combines the maintenance actions with the config\n * editor. A `AdminViews` toggle (\"maintenance\" / \"config\") switches between\n * `MaintenanceTab` (the maintenance shell over MaintenanceTab/*) and `ConfigTab`\n * (the config editor). Both bodies are UNCHANGED — only their hosting changes to\n * this new delegate-shell. `MaintenanceTab.tsx` and `ConfigTab.tsx` stay importable\n * from their original hosts (`ConfigTab` also stays wired into SetupTab per the\n * dual-host note). Flag-ON renders the toggle + both views; flag-OFF renders only\n * the maintenance view (the predecessor's `admin → MaintenanceTab` mapping),\n * and App.tsx keeps its current TabId routing this sprint (DASH-0d rewires).\n *\n * Flag: `MEGACOMPACT_DASH_0C` default ON. The dashboard client is a browser\n * bundle with NO `process` global, so the positive sprint flag cannot be read\n * server-side-style (`process.env`) inside the client. Instead the flag is read\n * from the server-authoritative `/api/rag-settings` state: the server resolves\n * `process.env[\"MEGACOMPACT_DASH_0C\"] ?? default` into the `SettingState.value`\n * boolean.\n */\n\nimport type React from \"react\";\nimport { useCallback, useState } from \"react\";\nimport type { SettingsResponse } from \"@contracts\";\nimport { useApi } from \"../hooks/useApi\";\nimport { fetchSettings } from \"../api/client\";\nimport { Toggle } from \"../components/ui/toggle\";\nimport MaintenanceTab from \"./MaintenanceTab\";\nimport ConfigTab from \"./ConfigTab\";\n\nconst DASH_0C_KEY = \"MEGACOMPACT_DASH_0C\";\n\n/** Resolve the DASH-0c consolidation flag from the server settings state.\n * Absent/not-yet-loaded => false (flag-off posture), so flag-off users never\n * see the toggle flash; the toggle appears only once settings confirm it is ON. */\nfunction dash0cEnabled(settings: SettingsResponse | null): boolean {\n\tif (!settings) return false;\n\tfor (const cat of settings.categories) {\n\t\tfor (const s of cat.settings) {\n\t\t\tif (s.key === DASH_0C_KEY && s.type === \"boolean\") return s.value === true;\n\t\t}\n\t}\n\treturn false;\n}\n\ntype AdminViews = \"maintenance\" | \"config\";\n\nexport default function AdminTab(): React.ReactElement {\n\tconst [view, setView] = useState<AdminViews>(\"maintenance\");\n\n\tconst { data: settingsData } = useApi<SettingsResponse>(\n\t\tuseCallback(() => fetchSettings(), []),\n\t\t{ pollInterval: 0, maxRetries: 0 },\n\t);\n\tconst dash0cOn = dash0cEnabled(settingsData);\n\n\tif (!dash0cOn) {\n\t\treturn <MaintenanceTab />;\n\t}\n\n\treturn (\n\t\t<div className=\"flex flex-col gap-4\">\n\t\t\t<div\n\t\t\t\tclassName=\"flex items-center gap-2\"\n\t\t\t\trole=\"tablist\"\n\t\t\t\taria-label=\"Admin views\"\n\t\t\t>\n\t\t\t\t<Toggle\n\t\t\t\t\tpressed={view === \"maintenance\"}\n\t\t\t\t\tonClick={() => setView(\"maintenance\")}\n\t\t\t\t>\n\t\t\t\t\tMaintenance\n\t\t\t\t</Toggle>\n\t\t\t\t<Toggle pressed={view === \"config\"} onClick={() => setView(\"config\")}>\n\t\t\t\t\tConfig\n\t\t\t\t</Toggle>\n\t\t\t</div>\n\t\t\t{view === \"maintenance\" ? <MaintenanceTab /> : <ConfigTab />}\n\t\t</div>\n\t);\n}\n"],"names":["DASH_0C_KEY","dash0cEnabled","settings","cat","s","AdminTab","view","setView","useState","settingsData","useApi","useCallback","fetchSettings","jsxs","jsx","Toggle","MaintenanceTab","ConfigTab"],"mappings":"mRA8BA,MAAMA,EAAc,sBAKpB,SAASC,EAAcC,EAA4C,CAClE,GAAI,CAACA,EAAU,MAAO,GACtB,UAAWC,KAAOD,EAAS,WAC1B,UAAWE,KAAKD,EAAI,SACnB,GAAIC,EAAE,MAAQJ,GAAeI,EAAE,OAAS,UAAW,OAAOA,EAAE,QAAU,GAGxE,MAAO,EACR,CAIA,SAAwBC,GAA+B,CACtD,KAAM,CAACC,EAAMC,CAAO,EAAIC,EAAAA,SAAqB,aAAa,EAEpD,CAAE,KAAMC,CAAA,EAAiBC,EAC9BC,cAAY,IAAMC,EAAA,EAAiB,EAAE,EACrC,CAAE,aAAc,EAAG,WAAY,CAAA,CAAE,EAIlC,OAFiBX,EAAcQ,CAAY,EAO1CI,EAAAA,KAAC,MAAA,CAAI,UAAU,sBACd,SAAA,CAAAA,EAAAA,KAAC,MAAA,CACA,UAAU,0BACV,KAAK,UACL,aAAW,cAEX,SAAA,CAAAC,EAAAA,IAACC,EAAA,CACA,QAAST,IAAS,cAClB,QAAS,IAAMC,EAAQ,aAAa,EACpC,SAAA,aAAA,CAAA,EAGDO,EAAAA,IAACC,EAAA,CAAO,QAAST,IAAS,SAAU,QAAS,IAAMC,EAAQ,QAAQ,EAAG,SAAA,QAAA,CAEtE,CAAA,CAAA,CAAA,EAEAD,IAAS,cAAgBQ,MAACE,EAAA,CAAA,CAAe,QAAMC,EAAA,CAAA,CAAU,CAAA,EAC3D,QArBQD,EAAA,EAAe,CAuBzB"}
1
+ {"version":3,"file":"AdminTab-B8JqsA41.js","sources":["../../src/tabs/AdminTab.tsx"],"sourcesContent":["/**\n * dashboard-client/src/tabs/AdminTab.tsx — Admin tab (DASH-0c delegate-shell).\n *\n * DASH-0c: the Admin surface combines the maintenance actions with the config\n * editor. A `AdminViews` toggle (\"maintenance\" / \"config\") switches between\n * `MaintenanceTab` (the maintenance shell over MaintenanceTab/*) and `ConfigTab`\n * (the config editor). Both bodies are UNCHANGED — only their hosting changes to\n * this new delegate-shell. `MaintenanceTab.tsx` and `ConfigTab.tsx` stay importable\n * from their original hosts (`ConfigTab` also stays wired into SetupTab per the\n * dual-host note). Flag-ON renders the toggle + both views; flag-OFF renders only\n * the maintenance view (the predecessor's `admin → MaintenanceTab` mapping),\n * and App.tsx keeps its current TabId routing this sprint (DASH-0d rewires).\n *\n * Flag: `MEGACOMPACT_DASH_0C` default ON. The dashboard client is a browser\n * bundle with NO `process` global, so the positive sprint flag cannot be read\n * server-side-style (`process.env`) inside the client. Instead the flag is read\n * from the server-authoritative `/api/rag-settings` state: the server resolves\n * `process.env[\"MEGACOMPACT_DASH_0C\"] ?? default` into the `SettingState.value`\n * boolean.\n */\n\nimport type React from \"react\";\nimport { useCallback, useState } from \"react\";\nimport type { SettingsResponse } from \"@contracts\";\nimport { useApi } from \"../hooks/useApi\";\nimport { fetchSettings } from \"../api/client\";\nimport { Toggle } from \"../components/ui/toggle\";\nimport MaintenanceTab from \"./MaintenanceTab\";\nimport ConfigTab from \"./ConfigTab\";\n\nconst DASH_0C_KEY = \"MEGACOMPACT_DASH_0C\";\n\n/** Resolve the DASH-0c consolidation flag from the server settings state.\n * Absent/not-yet-loaded => false (flag-off posture), so flag-off users never\n * see the toggle flash; the toggle appears only once settings confirm it is ON. */\nfunction dash0cEnabled(settings: SettingsResponse | null): boolean {\n\tif (!settings) return false;\n\tfor (const cat of settings.categories) {\n\t\tfor (const s of cat.settings) {\n\t\t\tif (s.key === DASH_0C_KEY && s.type === \"boolean\") return s.value === true;\n\t\t}\n\t}\n\treturn false;\n}\n\ntype AdminViews = \"maintenance\" | \"config\";\n\nexport default function AdminTab(): React.ReactElement {\n\tconst [view, setView] = useState<AdminViews>(\"maintenance\");\n\n\tconst { data: settingsData } = useApi<SettingsResponse>(\n\t\tuseCallback(() => fetchSettings(), []),\n\t\t{ pollInterval: 0, maxRetries: 0 },\n\t);\n\tconst dash0cOn = dash0cEnabled(settingsData);\n\n\tif (!dash0cOn) {\n\t\treturn <MaintenanceTab />;\n\t}\n\n\treturn (\n\t\t<div className=\"flex flex-col gap-4\">\n\t\t\t<div\n\t\t\t\tclassName=\"flex items-center gap-2\"\n\t\t\t\trole=\"tablist\"\n\t\t\t\taria-label=\"Admin views\"\n\t\t\t>\n\t\t\t\t<Toggle\n\t\t\t\t\tpressed={view === \"maintenance\"}\n\t\t\t\t\tonClick={() => setView(\"maintenance\")}\n\t\t\t\t>\n\t\t\t\t\tMaintenance\n\t\t\t\t</Toggle>\n\t\t\t\t<Toggle pressed={view === \"config\"} onClick={() => setView(\"config\")}>\n\t\t\t\t\tConfig\n\t\t\t\t</Toggle>\n\t\t\t</div>\n\t\t\t{view === \"maintenance\" ? <MaintenanceTab /> : <ConfigTab />}\n\t\t</div>\n\t);\n}\n"],"names":["DASH_0C_KEY","dash0cEnabled","settings","cat","s","AdminTab","view","setView","useState","settingsData","useApi","useCallback","fetchSettings","jsxs","jsx","Toggle","MaintenanceTab","ConfigTab"],"mappings":"mRA8BA,MAAMA,EAAc,sBAKpB,SAASC,EAAcC,EAA4C,CAClE,GAAI,CAACA,EAAU,MAAO,GACtB,UAAWC,KAAOD,EAAS,WAC1B,UAAWE,KAAKD,EAAI,SACnB,GAAIC,EAAE,MAAQJ,GAAeI,EAAE,OAAS,UAAW,OAAOA,EAAE,QAAU,GAGxE,MAAO,EACR,CAIA,SAAwBC,GAA+B,CACtD,KAAM,CAACC,EAAMC,CAAO,EAAIC,EAAAA,SAAqB,aAAa,EAEpD,CAAE,KAAMC,CAAA,EAAiBC,EAC9BC,cAAY,IAAMC,EAAA,EAAiB,EAAE,EACrC,CAAE,aAAc,EAAG,WAAY,CAAA,CAAE,EAIlC,OAFiBX,EAAcQ,CAAY,EAO1CI,EAAAA,KAAC,MAAA,CAAI,UAAU,sBACd,SAAA,CAAAA,EAAAA,KAAC,MAAA,CACA,UAAU,0BACV,KAAK,UACL,aAAW,cAEX,SAAA,CAAAC,EAAAA,IAACC,EAAA,CACA,QAAST,IAAS,cAClB,QAAS,IAAMC,EAAQ,aAAa,EACpC,SAAA,aAAA,CAAA,EAGDO,EAAAA,IAACC,EAAA,CAAO,QAAST,IAAS,SAAU,QAAS,IAAMC,EAAQ,QAAQ,EAAG,SAAA,QAAA,CAEtE,CAAA,CAAA,CAAA,EAEAD,IAAS,cAAgBQ,MAACE,EAAA,CAAA,CAAe,QAAMC,EAAA,CAAA,CAAU,CAAA,EAC3D,QArBQD,EAAA,EAAe,CAuBzB"}
@@ -1,2 +1,2 @@
1
- import{b as R,c as W,m as T,i as C,d as F,A as ie,e as B,h as q,j as oe,k as G,l as se,n as le,u as ue,o as K,G as ce,p as J,q as Q,D as fe,g as pe,X as he,Y as de,f as me}from"./generateCategoricalChart-8AyWGIrK.js";import{R as p,J as ee,r as ve}from"./index-BBJ8LglL.js";var ye=["layout","type","stroke","connectNulls","isRange","ref"],be=["key"],te;function M(e){"@babel/helpers - typeof";return M=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},M(e)}function ae(e,t){if(e==null)return{};var r=Ae(e,t),a,n;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)a=i[n],!(t.indexOf(a)>=0)&&Object.prototype.propertyIsEnumerable.call(e,a)&&(r[a]=e[a])}return r}function Ae(e,t){if(e==null)return{};var r={};for(var a in e)if(Object.prototype.hasOwnProperty.call(e,a)){if(t.indexOf(a)>=0)continue;r[a]=e[a]}return r}function D(){return D=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var a in r)Object.prototype.hasOwnProperty.call(r,a)&&(e[a]=r[a])}return e},D.apply(this,arguments)}function U(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),r.push.apply(r,a)}return r}function S(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?U(Object(r),!0).forEach(function(a){E(e,a,r[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):U(Object(r)).forEach(function(a){Object.defineProperty(e,a,Object.getOwnPropertyDescriptor(r,a))})}return e}function ge(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Z(e,t){for(var r=0;r<t.length;r++){var a=t[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,ne(a.key),a)}}function xe(e,t,r){return t&&Z(e.prototype,t),r&&Z(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function Pe(e,t,r){return t=$(t),Oe(e,re()?Reflect.construct(t,r||[],$(e).constructor):t.apply(e,r))}function Oe(e,t){if(t&&(M(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Ee(e)}function Ee(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function re(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(re=function(){return!!e})()}function $(e){return $=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},$(e)}function we(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&X(e,t)}function X(e,t){return X=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(a,n){return a.__proto__=n,a},X(e,t)}function E(e,t,r){return t=ne(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function ne(e){var t=_e(e,"string");return M(t)=="symbol"?t:t+""}function _e(e,t){if(M(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var a=r.call(e,t);if(M(a)!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}var L=function(e){function t(){var r;ge(this,t);for(var a=arguments.length,n=new Array(a),i=0;i<a;i++)n[i]=arguments[i];return r=Pe(this,t,[].concat(n)),E(r,"state",{isAnimationFinished:!0}),E(r,"id",ue("recharts-area-")),E(r,"handleAnimationEnd",function(){var o=r.props.onAnimationEnd;r.setState({isAnimationFinished:!0}),K(o)&&o()}),E(r,"handleAnimationStart",function(){var o=r.props.onAnimationStart;r.setState({isAnimationFinished:!1}),K(o)&&o()}),r}return we(t,e),xe(t,[{key:"renderDots",value:function(a,n,i){var o=this.props.isAnimationActive,s=this.state.isAnimationFinished;if(o&&!s)return null;var u=this.props,l=u.dot,f=u.points,c=u.dataKey,h=R(this.props,!1),A=R(l,!0),g=f.map(function(v,O){var y=S(S(S({key:"dot-".concat(O),r:3},h),A),{},{index:O,cx:v.x,cy:v.y,dataKey:c,value:v.value,payload:v.payload,points:f});return t.renderDotItem(l,y)}),x={clipPath:a?"url(#clipPath-".concat(n?"":"dots-").concat(i,")"):null};return p.createElement(W,D({className:"recharts-area-dots"},x),g)}},{key:"renderHorizontalRect",value:function(a){var n=this.props,i=n.baseLine,o=n.points,s=n.strokeWidth,u=o[0].x,l=o[o.length-1].x,f=a*Math.abs(u-l),c=T(o.map(function(h){return h.y||0}));return C(i)&&typeof i=="number"?c=Math.max(i,c):i&&Array.isArray(i)&&i.length&&(c=Math.max(T(i.map(function(h){return h.y||0})),c)),C(c)?p.createElement("rect",{x:u<l?u:u-f,y:0,width:f,height:Math.floor(c+(s?parseInt("".concat(s),10):1))}):null}},{key:"renderVerticalRect",value:function(a){var n=this.props,i=n.baseLine,o=n.points,s=n.strokeWidth,u=o[0].y,l=o[o.length-1].y,f=a*Math.abs(u-l),c=T(o.map(function(h){return h.x||0}));return C(i)&&typeof i=="number"?c=Math.max(i,c):i&&Array.isArray(i)&&i.length&&(c=Math.max(T(i.map(function(h){return h.x||0})),c)),C(c)?p.createElement("rect",{x:0,y:u<l?u:u-f,width:c+(s?parseInt("".concat(s),10):1),height:Math.floor(f)}):null}},{key:"renderClipRect",value:function(a){var n=this.props.layout;return n==="vertical"?this.renderVerticalRect(a):this.renderHorizontalRect(a)}},{key:"renderAreaStatically",value:function(a,n,i,o){var s=this.props,u=s.layout,l=s.type,f=s.stroke,c=s.connectNulls,h=s.isRange;s.ref;var A=ae(s,ye);return p.createElement(W,{clipPath:i?"url(#clipPath-".concat(o,")"):null},p.createElement(F,D({},R(A,!0),{points:a,connectNulls:c,type:l,baseLine:n,layout:u,stroke:"none",className:"recharts-area-area"})),f!=="none"&&p.createElement(F,D({},R(this.props,!1),{className:"recharts-area-curve",layout:u,type:l,connectNulls:c,fill:"none",points:a})),f!=="none"&&h&&p.createElement(F,D({},R(this.props,!1),{className:"recharts-area-curve",layout:u,type:l,connectNulls:c,fill:"none",points:n})))}},{key:"renderAreaWithAnimation",value:function(a,n){var i=this,o=this.props,s=o.points,u=o.baseLine,l=o.isAnimationActive,f=o.animationBegin,c=o.animationDuration,h=o.animationEasing,A=o.animationId,g=this.state,x=g.prevPoints,v=g.prevBaseLine;return p.createElement(ie,{begin:f,duration:c,isActive:l,easing:h,from:{t:0},to:{t:1},key:"area-".concat(A),onAnimationEnd:this.handleAnimationEnd,onAnimationStart:this.handleAnimationStart},function(O){var y=O.t;if(x){var _=x.length/s.length,d=s.map(function(P,N){var k=Math.floor(N*_);if(x[k]){var j=x[k],I=B(j.x,P.x),V=B(j.y,P.y);return S(S({},P),{},{x:I(y),y:V(y)})}return P}),m;if(C(u)&&typeof u=="number"){var b=B(v,u);m=b(y)}else if(q(u)||oe(u)){var w=B(v,0);m=w(y)}else m=u.map(function(P,N){var k=Math.floor(N*_);if(v[k]){var j=v[k],I=B(j.x,P.x),V=B(j.y,P.y);return S(S({},P),{},{x:I(y),y:V(y)})}return P});return i.renderAreaStatically(d,m,a,n)}return p.createElement(W,null,p.createElement("defs",null,p.createElement("clipPath",{id:"animationClipPath-".concat(n)},i.renderClipRect(y))),p.createElement(W,{clipPath:"url(#animationClipPath-".concat(n,")")},i.renderAreaStatically(s,u,a,n)))})}},{key:"renderArea",value:function(a,n){var i=this.props,o=i.points,s=i.baseLine,u=i.isAnimationActive,l=this.state,f=l.prevPoints,c=l.prevBaseLine,h=l.totalLength;return u&&o&&o.length&&(!f&&h>0||!G(f,o)||!G(c,s))?this.renderAreaWithAnimation(a,n):this.renderAreaStatically(o,s,a,n)}},{key:"render",value:function(){var a,n=this.props,i=n.hide,o=n.dot,s=n.points,u=n.className,l=n.top,f=n.left,c=n.xAxis,h=n.yAxis,A=n.width,g=n.height,x=n.isAnimationActive,v=n.id;if(i||!s||!s.length)return null;var O=this.state.isAnimationFinished,y=s.length===1,_=ee("recharts-area",u),d=c&&c.allowDataOverflow,m=h&&h.allowDataOverflow,b=d||m,w=q(v)?this.id:v,P=(a=R(o,!1))!==null&&a!==void 0?a:{r:3,strokeWidth:2},N=P.r,k=N===void 0?3:N,j=P.strokeWidth,I=j===void 0?2:j,V=se(o)?o:{},Y=V.clipDot,H=Y===void 0?!0:Y,z=k*2+I;return p.createElement(W,{className:_},d||m?p.createElement("defs",null,p.createElement("clipPath",{id:"clipPath-".concat(w)},p.createElement("rect",{x:d?f:f-A/2,y:m?l:l-g/2,width:d?A:A*2,height:m?g:g*2})),!H&&p.createElement("clipPath",{id:"clipPath-dots-".concat(w)},p.createElement("rect",{x:f-z/2,y:l-z/2,width:A+z,height:g+z}))):null,y?null:this.renderArea(b,w),(o||y)&&this.renderDots(b,H,w),(!x||O)&&le.renderCallByParent(this.props,s))}}],[{key:"getDerivedStateFromProps",value:function(a,n){return a.animationId!==n.prevAnimationId?{prevAnimationId:a.animationId,curPoints:a.points,curBaseLine:a.baseLine,prevPoints:n.curPoints,prevBaseLine:n.curBaseLine}:a.points!==n.curPoints||a.baseLine!==n.curBaseLine?{curPoints:a.points,curBaseLine:a.baseLine}:null}}])}(ve.PureComponent);te=L;E(L,"displayName","Area");E(L,"defaultProps",{stroke:"#3182bd",fill:"#3182bd",fillOpacity:.6,xAxisId:0,yAxisId:0,legendType:"line",connectNulls:!1,points:[],dot:!1,activeDot:!0,hide:!1,isAnimationActive:!ce.isSsr,animationBegin:0,animationDuration:1500,animationEasing:"ease"});E(L,"getBaseValue",function(e,t,r,a){var n=e.layout,i=e.baseValue,o=t.props.baseValue,s=o??i;if(C(s)&&typeof s=="number")return s;var u=n==="horizontal"?a:r,l=u.scale.domain();if(u.type==="number"){var f=Math.max(l[0],l[1]),c=Math.min(l[0],l[1]);return s==="dataMin"?c:s==="dataMax"||f<0?f:Math.max(Math.min(l[0],l[1]),0)}return s==="dataMin"?l[0]:s==="dataMax"?l[1]:l[0]});E(L,"getComposedData",function(e){var t=e.props,r=e.item,a=e.xAxis,n=e.yAxis,i=e.xAxisTicks,o=e.yAxisTicks,s=e.bandSize,u=e.dataKey,l=e.stackedData,f=e.dataStartIndex,c=e.displayedData,h=e.offset,A=t.layout,g=l&&l.length,x=te.getBaseValue(t,r,a,n),v=A==="horizontal",O=!1,y=c.map(function(d,m){var b;g?b=l[f+m]:(b=J(d,u),Array.isArray(b)?O=!0:b=[x,b]);var w=b[1]==null||g&&J(d,u)==null;return v?{x:Q({axis:a,ticks:i,bandSize:s,entry:d,index:m}),y:w?null:n.scale(b[1]),value:b,payload:d}:{x:w?null:a.scale(b[1]),y:Q({axis:n,ticks:o,bandSize:s,entry:d,index:m}),value:b,payload:d}}),_;return g||O?_=y.map(function(d){var m=Array.isArray(d.value)?d.value[0]:null;return v?{x:d.x,y:m!=null&&d.y!=null?n.scale(m):null}:{x:m!=null?a.scale(m):null,y:d.y}}):_=v?n.scale(x):a.scale(x),S({points:y,baseLine:_,layout:A,isRange:O},h)});E(L,"renderDotItem",function(e,t){var r;if(p.isValidElement(e))r=p.cloneElement(e,t);else if(K(e))r=e(t);else{var a=ee("recharts-area-dot",typeof e!="boolean"?e.className:""),n=t.key,i=ae(t,be);r=p.createElement(fe,D({},i,{key:n,className:a}))}return r});var ke=pe({chartName:"AreaChart",GraphicalChild:L,axisComponents:[{axisType:"xAxis",AxisComp:he},{axisType:"yAxis",AxisComp:de}],formatAxisMap:me});export{ke as A,L as a};
2
- //# sourceMappingURL=AreaChart-D4EY7yiY.js.map
1
+ import{b as R,c as W,m as T,i as C,d as F,A as ie,e as B,h as q,j as oe,k as G,l as se,n as le,u as ue,o as K,G as ce,p as J,q as Q,D as fe,g as pe,X as he,Y as de,f as me}from"./generateCategoricalChart-Q_V4fqVi.js";import{R as p,J as ee,r as ve}from"./index-CL6Af_JZ.js";var ye=["layout","type","stroke","connectNulls","isRange","ref"],be=["key"],te;function M(e){"@babel/helpers - typeof";return M=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},M(e)}function ae(e,t){if(e==null)return{};var r=Ae(e,t),a,n;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)a=i[n],!(t.indexOf(a)>=0)&&Object.prototype.propertyIsEnumerable.call(e,a)&&(r[a]=e[a])}return r}function Ae(e,t){if(e==null)return{};var r={};for(var a in e)if(Object.prototype.hasOwnProperty.call(e,a)){if(t.indexOf(a)>=0)continue;r[a]=e[a]}return r}function D(){return D=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var a in r)Object.prototype.hasOwnProperty.call(r,a)&&(e[a]=r[a])}return e},D.apply(this,arguments)}function U(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),r.push.apply(r,a)}return r}function S(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?U(Object(r),!0).forEach(function(a){E(e,a,r[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):U(Object(r)).forEach(function(a){Object.defineProperty(e,a,Object.getOwnPropertyDescriptor(r,a))})}return e}function ge(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Z(e,t){for(var r=0;r<t.length;r++){var a=t[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,ne(a.key),a)}}function xe(e,t,r){return t&&Z(e.prototype,t),r&&Z(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function Pe(e,t,r){return t=$(t),Oe(e,re()?Reflect.construct(t,r||[],$(e).constructor):t.apply(e,r))}function Oe(e,t){if(t&&(M(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Ee(e)}function Ee(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function re(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(re=function(){return!!e})()}function $(e){return $=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},$(e)}function we(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&X(e,t)}function X(e,t){return X=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(a,n){return a.__proto__=n,a},X(e,t)}function E(e,t,r){return t=ne(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function ne(e){var t=_e(e,"string");return M(t)=="symbol"?t:t+""}function _e(e,t){if(M(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var a=r.call(e,t);if(M(a)!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}var L=function(e){function t(){var r;ge(this,t);for(var a=arguments.length,n=new Array(a),i=0;i<a;i++)n[i]=arguments[i];return r=Pe(this,t,[].concat(n)),E(r,"state",{isAnimationFinished:!0}),E(r,"id",ue("recharts-area-")),E(r,"handleAnimationEnd",function(){var o=r.props.onAnimationEnd;r.setState({isAnimationFinished:!0}),K(o)&&o()}),E(r,"handleAnimationStart",function(){var o=r.props.onAnimationStart;r.setState({isAnimationFinished:!1}),K(o)&&o()}),r}return we(t,e),xe(t,[{key:"renderDots",value:function(a,n,i){var o=this.props.isAnimationActive,s=this.state.isAnimationFinished;if(o&&!s)return null;var u=this.props,l=u.dot,f=u.points,c=u.dataKey,h=R(this.props,!1),A=R(l,!0),g=f.map(function(v,O){var y=S(S(S({key:"dot-".concat(O),r:3},h),A),{},{index:O,cx:v.x,cy:v.y,dataKey:c,value:v.value,payload:v.payload,points:f});return t.renderDotItem(l,y)}),x={clipPath:a?"url(#clipPath-".concat(n?"":"dots-").concat(i,")"):null};return p.createElement(W,D({className:"recharts-area-dots"},x),g)}},{key:"renderHorizontalRect",value:function(a){var n=this.props,i=n.baseLine,o=n.points,s=n.strokeWidth,u=o[0].x,l=o[o.length-1].x,f=a*Math.abs(u-l),c=T(o.map(function(h){return h.y||0}));return C(i)&&typeof i=="number"?c=Math.max(i,c):i&&Array.isArray(i)&&i.length&&(c=Math.max(T(i.map(function(h){return h.y||0})),c)),C(c)?p.createElement("rect",{x:u<l?u:u-f,y:0,width:f,height:Math.floor(c+(s?parseInt("".concat(s),10):1))}):null}},{key:"renderVerticalRect",value:function(a){var n=this.props,i=n.baseLine,o=n.points,s=n.strokeWidth,u=o[0].y,l=o[o.length-1].y,f=a*Math.abs(u-l),c=T(o.map(function(h){return h.x||0}));return C(i)&&typeof i=="number"?c=Math.max(i,c):i&&Array.isArray(i)&&i.length&&(c=Math.max(T(i.map(function(h){return h.x||0})),c)),C(c)?p.createElement("rect",{x:0,y:u<l?u:u-f,width:c+(s?parseInt("".concat(s),10):1),height:Math.floor(f)}):null}},{key:"renderClipRect",value:function(a){var n=this.props.layout;return n==="vertical"?this.renderVerticalRect(a):this.renderHorizontalRect(a)}},{key:"renderAreaStatically",value:function(a,n,i,o){var s=this.props,u=s.layout,l=s.type,f=s.stroke,c=s.connectNulls,h=s.isRange;s.ref;var A=ae(s,ye);return p.createElement(W,{clipPath:i?"url(#clipPath-".concat(o,")"):null},p.createElement(F,D({},R(A,!0),{points:a,connectNulls:c,type:l,baseLine:n,layout:u,stroke:"none",className:"recharts-area-area"})),f!=="none"&&p.createElement(F,D({},R(this.props,!1),{className:"recharts-area-curve",layout:u,type:l,connectNulls:c,fill:"none",points:a})),f!=="none"&&h&&p.createElement(F,D({},R(this.props,!1),{className:"recharts-area-curve",layout:u,type:l,connectNulls:c,fill:"none",points:n})))}},{key:"renderAreaWithAnimation",value:function(a,n){var i=this,o=this.props,s=o.points,u=o.baseLine,l=o.isAnimationActive,f=o.animationBegin,c=o.animationDuration,h=o.animationEasing,A=o.animationId,g=this.state,x=g.prevPoints,v=g.prevBaseLine;return p.createElement(ie,{begin:f,duration:c,isActive:l,easing:h,from:{t:0},to:{t:1},key:"area-".concat(A),onAnimationEnd:this.handleAnimationEnd,onAnimationStart:this.handleAnimationStart},function(O){var y=O.t;if(x){var _=x.length/s.length,d=s.map(function(P,N){var k=Math.floor(N*_);if(x[k]){var j=x[k],I=B(j.x,P.x),V=B(j.y,P.y);return S(S({},P),{},{x:I(y),y:V(y)})}return P}),m;if(C(u)&&typeof u=="number"){var b=B(v,u);m=b(y)}else if(q(u)||oe(u)){var w=B(v,0);m=w(y)}else m=u.map(function(P,N){var k=Math.floor(N*_);if(v[k]){var j=v[k],I=B(j.x,P.x),V=B(j.y,P.y);return S(S({},P),{},{x:I(y),y:V(y)})}return P});return i.renderAreaStatically(d,m,a,n)}return p.createElement(W,null,p.createElement("defs",null,p.createElement("clipPath",{id:"animationClipPath-".concat(n)},i.renderClipRect(y))),p.createElement(W,{clipPath:"url(#animationClipPath-".concat(n,")")},i.renderAreaStatically(s,u,a,n)))})}},{key:"renderArea",value:function(a,n){var i=this.props,o=i.points,s=i.baseLine,u=i.isAnimationActive,l=this.state,f=l.prevPoints,c=l.prevBaseLine,h=l.totalLength;return u&&o&&o.length&&(!f&&h>0||!G(f,o)||!G(c,s))?this.renderAreaWithAnimation(a,n):this.renderAreaStatically(o,s,a,n)}},{key:"render",value:function(){var a,n=this.props,i=n.hide,o=n.dot,s=n.points,u=n.className,l=n.top,f=n.left,c=n.xAxis,h=n.yAxis,A=n.width,g=n.height,x=n.isAnimationActive,v=n.id;if(i||!s||!s.length)return null;var O=this.state.isAnimationFinished,y=s.length===1,_=ee("recharts-area",u),d=c&&c.allowDataOverflow,m=h&&h.allowDataOverflow,b=d||m,w=q(v)?this.id:v,P=(a=R(o,!1))!==null&&a!==void 0?a:{r:3,strokeWidth:2},N=P.r,k=N===void 0?3:N,j=P.strokeWidth,I=j===void 0?2:j,V=se(o)?o:{},Y=V.clipDot,H=Y===void 0?!0:Y,z=k*2+I;return p.createElement(W,{className:_},d||m?p.createElement("defs",null,p.createElement("clipPath",{id:"clipPath-".concat(w)},p.createElement("rect",{x:d?f:f-A/2,y:m?l:l-g/2,width:d?A:A*2,height:m?g:g*2})),!H&&p.createElement("clipPath",{id:"clipPath-dots-".concat(w)},p.createElement("rect",{x:f-z/2,y:l-z/2,width:A+z,height:g+z}))):null,y?null:this.renderArea(b,w),(o||y)&&this.renderDots(b,H,w),(!x||O)&&le.renderCallByParent(this.props,s))}}],[{key:"getDerivedStateFromProps",value:function(a,n){return a.animationId!==n.prevAnimationId?{prevAnimationId:a.animationId,curPoints:a.points,curBaseLine:a.baseLine,prevPoints:n.curPoints,prevBaseLine:n.curBaseLine}:a.points!==n.curPoints||a.baseLine!==n.curBaseLine?{curPoints:a.points,curBaseLine:a.baseLine}:null}}])}(ve.PureComponent);te=L;E(L,"displayName","Area");E(L,"defaultProps",{stroke:"#3182bd",fill:"#3182bd",fillOpacity:.6,xAxisId:0,yAxisId:0,legendType:"line",connectNulls:!1,points:[],dot:!1,activeDot:!0,hide:!1,isAnimationActive:!ce.isSsr,animationBegin:0,animationDuration:1500,animationEasing:"ease"});E(L,"getBaseValue",function(e,t,r,a){var n=e.layout,i=e.baseValue,o=t.props.baseValue,s=o??i;if(C(s)&&typeof s=="number")return s;var u=n==="horizontal"?a:r,l=u.scale.domain();if(u.type==="number"){var f=Math.max(l[0],l[1]),c=Math.min(l[0],l[1]);return s==="dataMin"?c:s==="dataMax"||f<0?f:Math.max(Math.min(l[0],l[1]),0)}return s==="dataMin"?l[0]:s==="dataMax"?l[1]:l[0]});E(L,"getComposedData",function(e){var t=e.props,r=e.item,a=e.xAxis,n=e.yAxis,i=e.xAxisTicks,o=e.yAxisTicks,s=e.bandSize,u=e.dataKey,l=e.stackedData,f=e.dataStartIndex,c=e.displayedData,h=e.offset,A=t.layout,g=l&&l.length,x=te.getBaseValue(t,r,a,n),v=A==="horizontal",O=!1,y=c.map(function(d,m){var b;g?b=l[f+m]:(b=J(d,u),Array.isArray(b)?O=!0:b=[x,b]);var w=b[1]==null||g&&J(d,u)==null;return v?{x:Q({axis:a,ticks:i,bandSize:s,entry:d,index:m}),y:w?null:n.scale(b[1]),value:b,payload:d}:{x:w?null:a.scale(b[1]),y:Q({axis:n,ticks:o,bandSize:s,entry:d,index:m}),value:b,payload:d}}),_;return g||O?_=y.map(function(d){var m=Array.isArray(d.value)?d.value[0]:null;return v?{x:d.x,y:m!=null&&d.y!=null?n.scale(m):null}:{x:m!=null?a.scale(m):null,y:d.y}}):_=v?n.scale(x):a.scale(x),S({points:y,baseLine:_,layout:A,isRange:O},h)});E(L,"renderDotItem",function(e,t){var r;if(p.isValidElement(e))r=p.cloneElement(e,t);else if(K(e))r=e(t);else{var a=ee("recharts-area-dot",typeof e!="boolean"?e.className:""),n=t.key,i=ae(t,be);r=p.createElement(fe,D({},i,{key:n,className:a}))}return r});var ke=pe({chartName:"AreaChart",GraphicalChild:L,axisComponents:[{axisType:"xAxis",AxisComp:he},{axisType:"yAxis",AxisComp:de}],formatAxisMap:me});export{ke as A,L as a};
2
+ //# sourceMappingURL=AreaChart-CeaexvWO.js.map