import assert from "node:assert/strict";
import { readFileSync } from "node:fs";
import { dirname, resolve } from "node:path";
import { fileURLToPath } from "node:url";

import {
  INI_PANEL_ENTRIES,
  createControlPageBrowserApiManifest,
  createControlPageBrowserApiSchema,
  createIniPanelLaunchApiManifest,
  createIniPanelLaunchApiSchema,
  createIniPanelLauncherLinkViewModel,
  createIniPanelShellIntegrationManifest,
  createIniPanelShellIntegrationReadiness,
  createIniPanelShellIntegrationSchema,
  createIniPanelShellIntegrationWorkflowPlan,
  createIniPanelShellSessionHandoffActionPlan,
  createIniPanelShellSessionHandoffChecklist,
  createIniPanelShellSessionHandoffCompatibilityReport,
  createIniPanelShellSessionHandoffDisplayViewModel,
  createIniPanelShellSessionHandoffPackage,
  createIniPanelShellSessionHandoffPackageDisplayViewModel,
  createIniPanelShellSessionHandoffPackageMountDisplayViewModel,
  createIniPanelShellSessionHandoffPackageMountRenderState,
  createIniPanelShellSessionHandoffPackageMountState,
  createIniPanelShellSessionHandoffMountDomContract,
  createIniPanelShellSessionHandoffMountDomReadiness,
  mountIniPanelShellSessionHandoff,
  mountIniPanelShellSessionHandoffFromControlPage,
  readIniPanelShellSessionHandoffStatusFromControlPage,
  createIniPanelShellSessionHandoffWorkflowSummary,
  createIniPanelShellSessionReadinessWorkflowReport,
  createIniPanelShellSessionHandoffWorkflowDisplayViewModel,
  createIniPanelShellSessionHandoffWorkflowRenderState,
  createIniPanelShellSessionHandoffWorkflowDomContract,
  createIniPanelShellSessionHandoffWorkflowDomReadiness,
  createIniPanelShellWorkflowOverviewContract,
  createIniPanelShellWorkflowOverviewReadiness,
  createIniPanelShellWorkflowOverviewEmbeddingReport,
  createIniPanelShellWorkflowOverviewEmbeddingDisplayViewModel,
  createIniPanelShellWorkflowOverviewEmbeddingRenderState,
  createIniPanelShellWorkflowOverviewEmbeddingDomContract,
  createIniPanelShellWorkflowOverviewEmbeddingDomReadiness,
  mountIniPanelShellWorkflowOverviewEmbedding,
  renderIniPanelShellWorkflowOverviewEmbeddingState,
  mountIniPanelShellWorkflowOverviewEmbeddingState,
  createIniPanelShellWorkflowOverviewEmbeddingMountDisplayViewModel,
  createIniPanelShellWorkflowOverviewEmbeddingMountRenderState,
  createIniPanelShellWorkflowOverviewEmbeddingMountDomContract,
  createIniPanelShellWorkflowOverviewEmbeddingMountDomReadiness,
  renderIniPanelShellWorkflowOverviewEmbeddingMountState,
  mountIniPanelShellWorkflowOverviewEmbeddingMountState,
  renderIniPanelShellSessionHandoffWorkflowState,
  mountIniPanelShellSessionHandoffWorkflow,
  createIniPanelShellSessionHandoffPackageReport,
  createIniPanelShellSessionHandoffPackageRenderState,
  createIniPanelShellSessionHandoffPackageSchema,
  createIniPanelShellSessionHandoffRenderState,
  createIniPanelShellSessionHandoffSnapshot,
  createIniPanelShellSessionHandoffSummary,
  createIniPanelShellSessionHandoffSummarySchema,
  createControlPageSessionLoadState,
  getVisibleIniPanelEntries,
  isSupportedIniPanelShellIntegrationManifest,
  isSupportedIniPanelShellSessionHandoffPackage,
  isSupportedIniPanelShellSessionHandoffSummary,
} from "../../../runtime/ui/ini-panel/ui-shell.js";

const __dirname = dirname(fileURLToPath(import.meta.url));
const root = resolve(__dirname, "../../..");
const shellText = readFileSync(resolve(root, "runtime/ui/ini-panel/ui-shell.js"), "utf8");
const launchText = readFileSync(resolve(root, "runtime/ui/ini-panel/launch.html"), "utf8");
const docText = readFileSync(resolve(root, "docs/panel-entry.md"), "utf8");

const schema = createIniPanelShellIntegrationSchema();
const manifest = createIniPanelShellIntegrationManifest();
const readiness = createIniPanelShellIntegrationReadiness(manifest);
const workflowPlan = createIniPanelShellIntegrationWorkflowPlan({ manifest, readiness });
const handoffSummary = createIniPanelShellSessionHandoffSummary({ manifest, readiness, workflowPlan });
const handoffSummarySchema = createIniPanelShellSessionHandoffSummarySchema();
const handoffCompatibilityReport = createIniPanelShellSessionHandoffCompatibilityReport(handoffSummary);
const handoffDisplayViewModel = createIniPanelShellSessionHandoffDisplayViewModel(handoffCompatibilityReport);
const handoffSnapshot = createIniPanelShellSessionHandoffSnapshot({
  readiness,
  summary: handoffSummary,
  compatibilityReport: handoffCompatibilityReport,
  displayViewModel: handoffDisplayViewModel,
});
const handoffRenderState = createIniPanelShellSessionHandoffRenderState(handoffSnapshot);
const handoffActionPlan = createIniPanelShellSessionHandoffActionPlan({
  snapshot: handoffSnapshot,
  renderState: handoffRenderState,
});
const handoffChecklist = createIniPanelShellSessionHandoffChecklist({
  actionPlan: handoffActionPlan,
  renderState: handoffRenderState,
});
const handoffPackage = createIniPanelShellSessionHandoffPackage({
  shellIntegrationManifest: manifest,
  launchApiManifest: manifest.launchApiManifest,
  controlPageApiManifest: manifest.controlPageApiManifest,
  snapshot: handoffSnapshot,
  renderState: handoffRenderState,
  actionPlan: handoffActionPlan,
  checklist: handoffChecklist,
});
const handoffPackageSchema = createIniPanelShellSessionHandoffPackageSchema();
const handoffPackageReport = createIniPanelShellSessionHandoffPackageReport(handoffPackage);
const handoffPackageDisplayViewModel = createIniPanelShellSessionHandoffPackageDisplayViewModel(
  handoffPackageReport,
);
const handoffPackageRenderState = createIniPanelShellSessionHandoffPackageRenderState(
  handoffPackageDisplayViewModel,
);
const handoffPackageMountState = createIniPanelShellSessionHandoffPackageMountState({
  handoffPackage,
  packageRenderState: handoffPackageRenderState,
});
const handoffPackageMountDisplayViewModel = createIniPanelShellSessionHandoffPackageMountDisplayViewModel(
  handoffPackageMountState,
);
const handoffPackageMountRenderState = createIniPanelShellSessionHandoffPackageMountRenderState(
  handoffPackageMountDisplayViewModel,
);
const handoffMountDomContract = createIniPanelShellSessionHandoffMountDomContract();

assert.deepEqual(schema, {
  apiName: "ini-panel-shell-integration",
  manifestVersion: 1,
  fields: [
    "apiName",
    "manifestVersion",
    "pages",
    "launcherLinks",
    "launchApiSchema",
    "launchApiManifest",
    "controlPageApiSchema",
    "controlPageApiManifest",
    "compatibility",
    "persistenceCapabilities",
  ],
});

assert.deepEqual(manifest, {
  apiName: "ini-panel-shell-integration",
  manifestVersion: 1,
  pages: getVisibleIniPanelEntries(),
  launcherLinks: createIniPanelLauncherLinkViewModel(),
  launchApiSchema: createIniPanelLaunchApiSchema(),
  launchApiManifest: createIniPanelLaunchApiManifest(),
  controlPageApiSchema: createControlPageBrowserApiSchema(),
  controlPageApiManifest: createControlPageBrowserApiManifest(),
  compatibility: {
    launchApiManifest: true,
    controlPageApiManifest: true,
  },
  persistenceCapabilities: createIniPanelLaunchApiManifest().persistenceCapabilities,
});

assert.equal(isSupportedIniPanelShellIntegrationManifest(manifest), true);
assert.equal(isSupportedIniPanelShellIntegrationManifest({ ...manifest, manifestVersion: 2 }), false);
assert.equal(isSupportedIniPanelShellIntegrationManifest({ ...manifest, apiName: "other" }), false);
const missingControlPageManifest = { ...manifest };
delete missingControlPageManifest.controlPageApiManifest;
assert.equal(isSupportedIniPanelShellIntegrationManifest(missingControlPageManifest), false);
assert.equal(isSupportedIniPanelShellIntegrationManifest(null), false);
assert.deepEqual(readiness, {
  phase: "ready",
  ready: true,
  checks: {
    integrationManifestSupported: true,
    launchApiManifestSupported: true,
    controlPageApiManifestSupported: true,
    launchCompatibility: true,
    controlPageCompatibility: true,
  },
  missing: [],
  counts: {
    pages: 3,
    launcherLinks: 3,
    launchMethods: 56,
    controlPageMethods: 11,
    persistenceCapabilities: 3,
  },
  apiNames: {
    integration: "ini-panel-shell-integration",
    launch: "ini-panel-launch",
    controlPage: "ini-panel-control-page",
  },
});
assert.deepEqual(workflowPlan, {
  phase: "ready",
  ready: true,
  controlEntryId: "control-view",
  targetPage: {
    entryId: "control-view",
    href: "./control-page.html",
  },
  readiness,
  requiredLaunchApiMethods: [
    "getShellIntegrationManifest",
    "getShellIntegrationReadiness",
  ],
  requiredControlPageApiMethods: [
    "getControlPageApiManifest",
    "loadControlPageSessionState",
    "readControlPageStatus",
  ],
  missingLaunchApiMethods: [],
  missingControlPageApiMethods: [],
  missing: [],
  readonlyStatusHandoff: {
    loadSessionStateMethod: "loadControlPageSessionState",
    readStatusMethod: "readControlPageStatus",
    expectedStatusFields: [
      "stateBundle",
      "workflowStatus",
      "overview",
      "controlView",
      "report",
      "sessionReadiness",
      "runReadiness",
      "run",
      "session",
      "status",
    ],
  },
});
assert.deepEqual(handoffSummary, {
  apiName: "ini-panel-shell-session-handoff-summary",
  summaryVersion: 1,
  phase: "ready",
  ready: true,
  targetPage: {
    entryId: "control-view",
    href: "./control-page.html",
  },
  readiness: {
    phase: "ready",
    missing: [],
    counts: {
      pages: 3,
      launcherLinks: 3,
      launchMethods: 56,
      controlPageMethods: 11,
      persistenceCapabilities: 3,
    },
    apiNames: {
      integration: "ini-panel-shell-integration",
      launch: "ini-panel-launch",
      controlPage: "ini-panel-control-page",
    },
  },
  persistenceCapabilities: [
    {
      id: "machine-files",
      label: "Machine text files",
      scope: "opfs",
    },
    {
      id: "session-snapshot",
      label: "Machine session snapshot",
      scope: "opfs",
    },
    {
      id: "readonly-status",
      label: "Read-only machine session status",
      scope: "control-page",
    },
  ],
  readonlyStatusFields: [
    "stateBundle",
    "workflowStatus",
    "overview",
    "controlView",
    "report",
    "sessionReadiness",
    "runReadiness",
    "run",
    "session",
    "status",
  ],
  handoffMethods: {
    loadSessionState: "loadControlPageSessionState",
    readStatus: "readControlPageStatus",
  },
  blockingReasons: [],
});
assert.deepEqual(handoffSummarySchema, {
  apiName: "ini-panel-shell-session-handoff-summary",
  summaryVersion: 1,
  fields: [
    "apiName",
    "summaryVersion",
    "phase",
    "ready",
    "targetPage",
    "readiness",
    "persistenceCapabilities",
    "readonlyStatusFields",
    "handoffMethods",
    "blockingReasons",
  ],
});
assert.equal(isSupportedIniPanelShellSessionHandoffSummary(handoffSummary), true);
assert.equal(
  isSupportedIniPanelShellSessionHandoffSummary({ ...handoffSummary, summaryVersion: 2 }),
  false,
);
assert.equal(
  isSupportedIniPanelShellSessionHandoffSummary({ ...handoffSummary, apiName: "other" }),
  false,
);
const missingSummaryField = { ...handoffSummary };
delete missingSummaryField.readonlyStatusFields;
assert.equal(isSupportedIniPanelShellSessionHandoffSummary(missingSummaryField), false);
assert.equal(isSupportedIniPanelShellSessionHandoffSummary(null), false);
assert.deepEqual(handoffCompatibilityReport, {
  apiName: "ini-panel-shell-session-handoff-compatibility-report",
  reportVersion: 1,
  phase: "ready",
  compatible: true,
  summarySupported: true,
  handoffReady: true,
  schema: {
    apiName: "ini-panel-shell-session-handoff-summary",
    summaryVersion: 1,
    fields: [
      "apiName",
      "summaryVersion",
      "phase",
      "ready",
      "targetPage",
      "readiness",
      "persistenceCapabilities",
      "readonlyStatusFields",
      "handoffMethods",
      "blockingReasons",
    ],
  },
  summary: {
    apiName: "ini-panel-shell-session-handoff-summary",
    summaryVersion: 1,
    phase: "ready",
    ready: true,
  },
  missingFields: [],
  mismatchFields: [],
  blockingReasons: [],
});
assert.deepEqual(handoffDisplayViewModel, {
  phase: "ready",
  title: "Shell handoff compatibility",
  statusText: "Ready",
  detailText: "No blocking reasons",
  rows: [
    {
      id: "summary-supported",
      label: "Summary schema",
      value: "supported",
    },
    {
      id: "handoff-ready",
      label: "Handoff readiness",
      value: "ready",
    },
    {
      id: "missing-fields",
      label: "Missing fields",
      value: "none",
    },
    {
      id: "mismatch-fields",
      label: "Mismatched fields",
      value: "none",
    },
    {
      id: "blocking-reasons",
      label: "Blocking reasons",
      value: "none",
    },
  ],
});
assert.deepEqual(handoffSnapshot, {
  apiName: "ini-panel-shell-session-handoff-snapshot",
  snapshotVersion: 1,
  phase: "ready",
  ready: true,
  readiness,
  summary: handoffSummary,
  compatibilityReport: handoffCompatibilityReport,
  displayViewModel: handoffDisplayViewModel,
});
assert.deepEqual(handoffRenderState, {
  apiName: "ini-panel-shell-session-handoff-render-state",
  renderStateVersion: 1,
  phase: "ready",
  ready: true,
  title: "Shell handoff compatibility",
  statusText: "Ready",
  detailText: "No blocking reasons",
  statusLine: "Ready: No blocking reasons",
  rows: handoffDisplayViewModel.rows,
  dataset: {
    handoffPhase: "ready",
    handoffReady: "true",
  },
});
assert.deepEqual(handoffActionPlan, {
  apiName: "ini-panel-shell-session-handoff-action-plan",
  planVersion: 1,
  phase: "ready",
  ready: true,
  statusLine: "Ready: No blocking reasons",
  targetPage: {
    entryId: "control-view",
    href: "./control-page.html",
  },
  requiredMethods: {
    loadSessionState: "loadControlPageSessionState",
    readStatus: "readControlPageStatus",
  },
  blockingReasons: [],
  displayRows: handoffRenderState.rows,
  nextSteps: [
    {
      id: "open-control-page",
      label: "Open control page target",
      targetPage: {
        entryId: "control-view",
        href: "./control-page.html",
      },
    },
    {
      id: "read-readonly-status",
      label: "Read readonly status",
      methods: {
        loadSessionState: "loadControlPageSessionState",
        readStatus: "readControlPageStatus",
      },
    },
  ],
});
assert.deepEqual(handoffChecklist, {
  apiName: "ini-panel-shell-session-handoff-checklist",
  checklistVersion: 1,
  phase: "ready",
  ready: true,
  statusLine: "Ready: No blocking reasons",
  checks: [
    {
      id: "render-state",
      label: "Render state",
      status: "pass",
      value: "Ready: No blocking reasons",
    },
    {
      id: "target-page",
      label: "Control target",
      status: "pass",
      value: "./control-page.html",
    },
    {
      id: "load-session-method",
      label: "Load session method",
      status: "pass",
      value: "loadControlPageSessionState",
    },
    {
      id: "read-status-method",
      label: "Read status method",
      status: "pass",
      value: "readControlPageStatus",
    },
    {
      id: "blocking-reasons",
      label: "Blocking reasons",
      status: "pass",
      value: "none",
    },
  ],
  displayRows: handoffActionPlan.displayRows,
  nextStepIds: ["open-control-page", "read-readonly-status"],
  blockingReasons: [],
});
assert.deepEqual(handoffPackage, {
  apiName: "ini-panel-shell-session-handoff-package",
  packageVersion: 1,
  phase: "ready",
  ready: true,
  statusLine: "Ready: No blocking reasons",
  manifests: {
    shellIntegration: manifest,
    launchApi: manifest.launchApiManifest,
    controlPageApi: manifest.controlPageApiManifest,
    launchMethods: manifest.launchApiManifest.methods,
    controlPageMethods: manifest.controlPageApiManifest.methods,
  },
  snapshot: handoffSnapshot,
  renderState: handoffRenderState,
  actionPlan: handoffActionPlan,
  checklist: handoffChecklist,
});
assert.deepEqual(handoffPackageSchema, {
  apiName: "ini-panel-shell-session-handoff-package",
  packageVersion: 1,
  fields: [
    "apiName",
    "packageVersion",
    "phase",
    "ready",
    "statusLine",
    "manifests",
    "snapshot",
    "renderState",
    "actionPlan",
    "checklist",
  ],
  manifestFields: [
    "shellIntegration",
    "launchApi",
    "controlPageApi",
    "launchMethods",
    "controlPageMethods",
  ],
});
assert.deepEqual(handoffPackageReport, {
  apiName: "ini-panel-shell-session-handoff-package-report",
  reportVersion: 1,
  phase: "ready",
  ready: true,
  packageSupported: true,
  packageReady: true,
  statusLine: "Ready: No blocking reasons",
  schema: {
    apiName: "ini-panel-shell-session-handoff-package",
    packageVersion: 1,
    fields: [
      "apiName",
      "packageVersion",
      "phase",
      "ready",
      "statusLine",
      "manifests",
      "snapshot",
      "renderState",
      "actionPlan",
      "checklist",
    ],
    manifestFields: [
      "shellIntegration",
      "launchApi",
      "controlPageApi",
      "launchMethods",
      "controlPageMethods",
    ],
  },
  package: {
    apiName: "ini-panel-shell-session-handoff-package",
    packageVersion: 1,
    phase: "ready",
    ready: true,
  },
  missingPackageFields: [],
  missingManifestFields: [],
  mismatchFields: [],
  blockingReasons: [],
  rows: [
    {
      id: "package-supported",
      label: "Package schema",
      value: "supported",
    },
    {
      id: "package-ready",
      label: "Package readiness",
      value: "ready",
    },
    {
      id: "missing-package-fields",
      label: "Missing package fields",
      value: "none",
    },
    {
      id: "missing-manifest-fields",
      label: "Missing manifest fields",
      value: "none",
    },
    {
      id: "mismatch-fields",
      label: "Mismatched fields",
      value: "none",
    },
    {
      id: "blocking-reasons",
      label: "Blocking reasons",
      value: "none",
    },
  ],
});
assert.deepEqual(handoffPackageDisplayViewModel, {
  phase: "ready",
  title: "Shell handoff package",
  statusText: "Ready",
  detailText: "No blocking reasons",
  rows: handoffPackageReport.rows,
});
assert.deepEqual(handoffPackageRenderState, {
  apiName: "ini-panel-shell-session-handoff-package-render-state",
  renderStateVersion: 1,
  phase: "ready",
  ready: true,
  title: "Shell handoff package",
  statusText: "Ready",
  detailText: "No blocking reasons",
  statusLine: "Ready: No blocking reasons",
  rows: handoffPackageDisplayViewModel.rows,
  dataset: {
    handoffPhase: "ready",
    handoffReady: "true",
    handoffScope: "package",
  },
});
assert.deepEqual(handoffPackageMountState, {
  apiName: "ini-panel-shell-session-handoff-package-mount-state",
  mountStateVersion: 1,
  phase: "blocked",
  ready: false,
  packageReady: true,
  targetReady: true,
  methodsReady: true,
  sessionReady: false,
  statusLine: "Blocked: waiting-panel",
  packageRenderState: handoffPackageRenderState,
  targetPage: {
    entryId: "control-view",
    href: "./control-page.html",
  },
  requiredMethods: {
    loadSessionState: "loadControlPageSessionState",
    readStatus: "readControlPageStatus",
  },
  sessionLoadState: createControlPageSessionLoadState({ phase: "waiting-panel" }),
  blockingReasons: [],
  checks: [
    {
      id: "package-render-state",
      label: "Package render state",
      status: "pass",
      value: "Ready: No blocking reasons",
    },
    {
      id: "target-page",
      label: "Control target",
      status: "pass",
      value: "./control-page.html",
    },
    {
      id: "required-methods",
      label: "Readonly methods",
      status: "pass",
      value: "loadControlPageSessionState, readControlPageStatus",
    },
    {
      id: "session-load-state",
      label: "Session load state",
      status: "blocked",
      value: "waiting-panel",
    },
    {
      id: "blocking-reasons",
      label: "Blocking reasons",
      status: "pass",
      value: "none",
    },
  ],
});
assert.deepEqual(handoffPackageMountDisplayViewModel, {
  phase: "blocked",
  title: "Shell handoff mount",
  statusText: "Blocked",
  detailText: "session-load-state",
  rows: handoffPackageMountState.checks,
});
assert.deepEqual(handoffPackageMountRenderState, {
  apiName: "ini-panel-shell-session-handoff-package-mount-render-state",
  renderStateVersion: 1,
  phase: "blocked",
  ready: false,
  title: "Shell handoff mount",
  statusText: "Blocked",
  detailText: "session-load-state",
  statusLine: "Blocked: session-load-state",
  rows: handoffPackageMountDisplayViewModel.rows,
  dataset: {
    handoffPhase: "blocked",
    handoffReady: "false",
    handoffScope: "mount",
  },
});
assert.deepEqual(handoffMountDomContract, {
  apiName: "ini-panel-shell-session-handoff-mount-dom-contract",
  contractVersion: 1,
  requiredNodeIds: ["mount", "status", "rows"],
  selectors: {
    mount: "[data-handoff-mount]",
    status: "[data-handoff-mount-status]",
    rows: "[data-handoff-mount-rows]",
  },
  mountDatasetKeys: ["handoffPhase", "handoffReady", "handoffScope"],
  rowDatasetPrefix: "handoffMount",
  rowDatasetKeys: {
    term: ["handoffMountRow", "handoffMountStatus"],
    detail: ["handoffMountValue", "handoffMountStatus"],
  },
  renderResultFields: ["rendered", "statusLine", "rowCount", "rowIds", "dataset"],
});
assert.deepEqual(createIniPanelShellSessionHandoffMountDomReadiness({ documentRef: null }), {
  apiName: "ini-panel-shell-session-handoff-mount-dom-readiness",
  readinessVersion: 1,
  phase: "blocked",
  ready: false,
  missing: ["document", "mount", "status", "rows"],
  checks: {
    document: false,
    mount: false,
    status: false,
    rows: false,
    rowDatasetPrefix: true,
  },
  contract: handoffMountDomContract,
});
assert.equal(
  mountIniPanelShellSessionHandoff({ documentRef: null }).statusLine,
  "Blocked: document, mount, status, rows",
);
assert.equal(
  mountIniPanelShellSessionHandoffFromControlPage({ documentRef: null }).sessionLoadState.phase,
  "waiting-api",
);
assert.equal(
  readIniPanelShellSessionHandoffStatusFromControlPage().readError,
  "Missing readControlPageStatus",
);
assert.equal(
  createIniPanelShellSessionHandoffWorkflowSummary().phase,
  "blocked",
);
assert.equal(createIniPanelShellSessionReadinessWorkflowReport().phase, "blocked");
assert.equal(
  createIniPanelShellSessionHandoffWorkflowDisplayViewModel().phase,
  "blocked",
);
assert.equal(
  createIniPanelShellSessionHandoffWorkflowRenderState().phase,
  "blocked",
);
assert.equal(
  createIniPanelShellSessionHandoffWorkflowDomContract().selectors.mount,
  "[data-handoff-workflow]",
);
assert.equal(
  createIniPanelShellSessionHandoffWorkflowDomReadiness().phase,
  "blocked",
);
assert.equal(
  mountIniPanelShellSessionHandoffWorkflow().phase,
  "blocked",
);
assert.deepEqual(createIniPanelShellWorkflowOverviewContract(), {
  pageHref: "./workflow-overview.html",
  entryId: "workflow-overview",
  apiName: "linuxCncIniPanelWorkflowOverviewApi",
  methodNames: [
    "getWorkflowOverviewRenderState",
    "getWorkflowOverviewDisplayViewModel",
    "getWorkflowOverviewSummary",
    "getWorkflowOverviewSessionReadinessReport",
    "getWorkflowOverviewDomContract",
    "getWorkflowOverviewDomReadiness",
    "renderWorkflowOverview",
    "mountWorkflowOverview",
    "createWorkflowOverviewRenderState",
  ],
});
assert.equal(createIniPanelShellWorkflowOverviewReadiness().ready, false);
assert.equal(createIniPanelShellWorkflowOverviewEmbeddingReport().ready, false);
assert.equal(createIniPanelShellWorkflowOverviewEmbeddingReport().rows.length, 6);
assert.equal(
  createIniPanelShellWorkflowOverviewEmbeddingDisplayViewModel(
    createIniPanelShellWorkflowOverviewEmbeddingReport(),
  ).title,
  "Workflow overview embedding",
);
assert.equal(
  createIniPanelShellWorkflowOverviewEmbeddingRenderState(
    createIniPanelShellWorkflowOverviewEmbeddingDisplayViewModel(
      createIniPanelShellWorkflowOverviewEmbeddingReport(),
    ),
  ).dataset.handoffScope,
  "workflow-overview-embedding",
);
assert.equal(
  createIniPanelShellWorkflowOverviewEmbeddingDomContract().selectors.mount,
  "[data-workflow-overview-embedding]",
);
assert.equal(createIniPanelShellWorkflowOverviewEmbeddingDomReadiness().ready, false);
assert.equal(typeof renderIniPanelShellWorkflowOverviewEmbeddingState, "function");
assert.equal(typeof mountIniPanelShellWorkflowOverviewEmbeddingState, "function");
assert.equal(typeof createIniPanelShellWorkflowOverviewEmbeddingMountDisplayViewModel, "function");
assert.equal(typeof createIniPanelShellWorkflowOverviewEmbeddingMountRenderState, "function");
assert.equal(typeof createIniPanelShellWorkflowOverviewEmbeddingMountDomContract, "function");
assert.equal(typeof createIniPanelShellWorkflowOverviewEmbeddingMountDomReadiness, "function");
assert.equal(typeof renderIniPanelShellWorkflowOverviewEmbeddingMountState, "function");
assert.equal(typeof mountIniPanelShellWorkflowOverviewEmbeddingMountState, "function");
assert.deepEqual(
  createIniPanelShellWorkflowOverviewReadiness({
    overviewApi: {
      getWorkflowOverviewRenderState: () => handoffPackageRenderState,
      getWorkflowOverviewSessionReadinessReport: () => createIniPanelShellSessionReadinessWorkflowReport(),
    },
  }).missing,
  [
    "getWorkflowOverviewDisplayViewModel",
    "getWorkflowOverviewSummary",
    "getWorkflowOverviewDomContract",
    "getWorkflowOverviewDomReadiness",
    "renderWorkflowOverview",
    "mountWorkflowOverview",
    "createWorkflowOverviewRenderState",
  ],
);
assert.equal(mountIniPanelShellWorkflowOverviewEmbedding().phase, "blocked");
assert.deepEqual(
  createIniPanelShellSessionHandoffPackageMountState({
    handoffPackage,
    packageRenderState: handoffPackageRenderState,
    sessionLoadState: createControlPageSessionLoadState({
      phase: "ready",
      panelReady: true,
      apiReady: true,
      controlViewReady: true,
      controlView: { status: { runStatus: "not-run" } },
    }),
  }).checks.map(({ id, status, value }) => ({ id, status, value })),
  [
    {
      id: "package-render-state",
      status: "pass",
      value: "Ready: No blocking reasons",
    },
    {
      id: "target-page",
      status: "pass",
      value: "./control-page.html",
    },
    {
      id: "required-methods",
      status: "pass",
      value: "loadControlPageSessionState, readControlPageStatus",
    },
    {
      id: "session-load-state",
      status: "pass",
      value: "ready",
    },
    {
      id: "blocking-reasons",
      status: "pass",
      value: "none",
    },
  ],
);
const readyMountState = createIniPanelShellSessionHandoffPackageMountState({
  handoffPackage,
  packageRenderState: handoffPackageRenderState,
  sessionLoadState: createControlPageSessionLoadState({
    phase: "ready",
    panelReady: true,
    apiReady: true,
    controlViewReady: true,
    controlView: { status: { runStatus: "not-run" } },
  }),
});
assert.deepEqual(
  createIniPanelShellSessionHandoffPackageMountRenderState(
    createIniPanelShellSessionHandoffPackageMountDisplayViewModel(readyMountState),
  ),
  {
    apiName: "ini-panel-shell-session-handoff-package-mount-render-state",
    renderStateVersion: 1,
    phase: "ready",
    ready: true,
    title: "Shell handoff mount",
    statusText: "Ready",
    detailText: "No blocking reasons",
    statusLine: "Ready: No blocking reasons",
    rows: readyMountState.checks,
    dataset: {
      handoffPhase: "ready",
      handoffReady: "true",
      handoffScope: "mount",
    },
  },
);
assert.equal(isSupportedIniPanelShellSessionHandoffPackage(handoffPackage), true);
assert.equal(
  isSupportedIniPanelShellSessionHandoffPackage({ ...handoffPackage, packageVersion: 2 }),
  false,
);
assert.equal(
  isSupportedIniPanelShellSessionHandoffPackage({ ...handoffPackage, apiName: "other" }),
  false,
);
const missingPackageField = { ...handoffPackage };
delete missingPackageField.checklist;
assert.equal(isSupportedIniPanelShellSessionHandoffPackage(missingPackageField), false);
assert.equal(isSupportedIniPanelShellSessionHandoffPackage({
  ...handoffPackage,
  manifests: {
    ...handoffPackage.manifests,
    controlPageMethods: undefined,
  },
}), true);
const missingManifestField = {
  ...handoffPackage,
  manifests: { ...handoffPackage.manifests },
};
delete missingManifestField.manifests.controlPageMethods;
assert.equal(isSupportedIniPanelShellSessionHandoffPackage(missingManifestField), false);
assert.equal(isSupportedIniPanelShellSessionHandoffPackage(null), false);
assert.deepEqual(
  createIniPanelShellSessionHandoffPackageReport({ ...handoffPackage, packageVersion: 2 }).mismatchFields,
  ["packageVersion"],
);
assert.deepEqual(
  createIniPanelShellSessionHandoffPackageDisplayViewModel(
    createIniPanelShellSessionHandoffPackageReport({ ...handoffPackage, packageVersion: 2 }),
  ).rows.find((row) => row.id === "mismatch-fields"),
  {
    id: "mismatch-fields",
    label: "Mismatched fields",
    value: "packageVersion",
  },
);
assert.equal(
  createIniPanelShellSessionHandoffPackageDisplayViewModel(
    createIniPanelShellSessionHandoffPackageReport({ ...handoffPackage, packageVersion: 2 }),
  ).statusText,
  "Blocked",
);
assert.deepEqual(
  createIniPanelShellSessionHandoffPackageRenderState(createIniPanelShellSessionHandoffPackageDisplayViewModel(
    createIniPanelShellSessionHandoffPackageReport({ ...handoffPackage, packageVersion: 2 }),
  )),
  {
    apiName: "ini-panel-shell-session-handoff-package-render-state",
    renderStateVersion: 1,
    phase: "blocked",
    ready: false,
    title: "Shell handoff package",
    statusText: "Blocked",
    detailText: "packageVersion",
    statusLine: "Blocked: packageVersion",
    rows: [
      {
        id: "package-supported",
        label: "Package schema",
        value: "blocked",
      },
      {
        id: "package-ready",
        label: "Package readiness",
        value: "blocked",
      },
      {
        id: "missing-package-fields",
        label: "Missing package fields",
        value: "none",
      },
      {
        id: "missing-manifest-fields",
        label: "Missing manifest fields",
        value: "none",
      },
      {
        id: "mismatch-fields",
        label: "Mismatched fields",
        value: "packageVersion",
      },
      {
        id: "blocking-reasons",
        label: "Blocking reasons",
        value: "none",
      },
    ],
    dataset: {
      handoffPhase: "blocked",
      handoffReady: "false",
      handoffScope: "package",
    },
  },
);
assert.deepEqual(
  createIniPanelShellSessionHandoffPackageMountState({
    handoffPackage: { ...handoffPackage, ready: false },
    packageRenderState: createIniPanelShellSessionHandoffPackageRenderState(createIniPanelShellSessionHandoffPackageDisplayViewModel(
      createIniPanelShellSessionHandoffPackageReport({ ...handoffPackage, packageVersion: 2 }),
    )),
    sessionLoadState: createControlPageSessionLoadState({ phase: "error", error: "boom" }),
  }).blockingReasons,
  ["controlPageSessionError"],
);
assert.deepEqual(
  createIniPanelShellSessionHandoffPackageReport(missingManifestField).missingManifestFields,
  ["controlPageMethods"],
);
assert.deepEqual(
  createIniPanelShellSessionHandoffPackageReport(null).missingPackageFields,
  handoffPackageSchema.fields,
);
assert.equal(createIniPanelShellSessionHandoffSnapshot().displayViewModel.rows.length, 5);
assert.equal(createIniPanelShellSessionHandoffRenderState().statusLine, "Ready: No blocking reasons");
assert.equal(createIniPanelShellSessionHandoffActionPlan().nextSteps.length, 2);
assert.equal(createIniPanelShellSessionHandoffChecklist().checks.length, 5);
assert.equal(createIniPanelShellSessionHandoffPackage().manifests.launchMethods.includes("getShellSessionHandoffPackage"), true);
assert.equal(isSupportedIniPanelShellSessionHandoffPackage(createIniPanelShellSessionHandoffPackage()), true);
assert.equal(createIniPanelShellSessionHandoffPackageReport().rows.length, 6);
assert.deepEqual(
  createIniPanelShellSessionHandoffDisplayViewModel(
    createIniPanelShellSessionHandoffCompatibilityReport({ ...handoffSummary, summaryVersion: 2 }),
  ).rows.find((row) => row.id === "mismatch-fields"),
  {
    id: "mismatch-fields",
    label: "Mismatched fields",
    value: "summaryVersion",
  },
);
assert.deepEqual(
  createIniPanelShellSessionHandoffCompatibilityReport({ ...handoffSummary, summaryVersion: 2 }),
  {
    ...handoffCompatibilityReport,
    phase: "blocked",
    compatible: false,
    summarySupported: false,
    handoffReady: false,
    summary: {
      apiName: "ini-panel-shell-session-handoff-summary",
      summaryVersion: 2,
      phase: "ready",
      ready: true,
    },
    mismatchFields: ["summaryVersion"],
  },
);
const missingFieldReportInput = { ...handoffSummary };
delete missingFieldReportInput.readonlyStatusFields;
assert.deepEqual(
  createIniPanelShellSessionHandoffCompatibilityReport(missingFieldReportInput).missingFields,
  ["readonlyStatusFields"],
);
assert.deepEqual(
  createIniPanelShellSessionHandoffCompatibilityReport(null).missingFields,
  handoffSummarySchema.fields,
);
assert.deepEqual(
  createIniPanelShellSessionHandoffRenderState(createIniPanelShellSessionHandoffSnapshot({
    compatibilityReport: createIniPanelShellSessionHandoffCompatibilityReport({
      ...handoffSummary,
      summaryVersion: 2,
    }),
  })),
  {
    apiName: "ini-panel-shell-session-handoff-render-state",
    renderStateVersion: 1,
    phase: "blocked",
    ready: false,
    title: "Shell handoff compatibility",
    statusText: "Blocked",
    detailText: "summaryVersion",
    statusLine: "Blocked: summaryVersion",
    rows: [
      {
        id: "summary-supported",
        label: "Summary schema",
        value: "blocked",
      },
      {
        id: "handoff-ready",
        label: "Handoff readiness",
        value: "blocked",
      },
      {
        id: "missing-fields",
        label: "Missing fields",
        value: "none",
      },
      {
        id: "mismatch-fields",
        label: "Mismatched fields",
        value: "summaryVersion",
      },
      {
        id: "blocking-reasons",
        label: "Blocking reasons",
        value: "none",
      },
    ],
    dataset: {
      handoffPhase: "blocked",
      handoffReady: "false",
    },
  },
);
assert.deepEqual(
  createIniPanelShellSessionHandoffActionPlan({
    snapshot: createIniPanelShellSessionHandoffSnapshot({
      summary: {
        ...handoffSummary,
        summaryVersion: 2,
      },
      compatibilityReport: createIniPanelShellSessionHandoffCompatibilityReport({
        ...handoffSummary,
        summaryVersion: 2,
      }),
    }),
    renderState: createIniPanelShellSessionHandoffRenderState(createIniPanelShellSessionHandoffSnapshot({
      compatibilityReport: createIniPanelShellSessionHandoffCompatibilityReport({
        ...handoffSummary,
        summaryVersion: 2,
      }),
    })),
  }).nextSteps,
  [
    {
      id: "resolve-blockers",
      label: "Resolve handoff blockers",
      blockingReasons: [],
      displayRows: [
        {
          id: "summary-supported",
          label: "Summary schema",
          value: "blocked",
        },
        {
          id: "handoff-ready",
          label: "Handoff readiness",
          value: "blocked",
        },
        {
          id: "missing-fields",
          label: "Missing fields",
          value: "none",
        },
        {
          id: "mismatch-fields",
          label: "Mismatched fields",
          value: "summaryVersion",
        },
        {
          id: "blocking-reasons",
          label: "Blocking reasons",
          value: "none",
        },
      ],
    },
  ],
);
assert.deepEqual(
  createIniPanelShellSessionHandoffChecklist({
    actionPlan: createIniPanelShellSessionHandoffActionPlan({
      snapshot: createIniPanelShellSessionHandoffSnapshot({
        summary: {
          ...handoffSummary,
          summaryVersion: 2,
        },
        compatibilityReport: createIniPanelShellSessionHandoffCompatibilityReport({
          ...handoffSummary,
          summaryVersion: 2,
        }),
      }),
      renderState: createIniPanelShellSessionHandoffRenderState(createIniPanelShellSessionHandoffSnapshot({
        compatibilityReport: createIniPanelShellSessionHandoffCompatibilityReport({
          ...handoffSummary,
          summaryVersion: 2,
        }),
      })),
    }),
    renderState: createIniPanelShellSessionHandoffRenderState(createIniPanelShellSessionHandoffSnapshot({
      compatibilityReport: createIniPanelShellSessionHandoffCompatibilityReport({
        ...handoffSummary,
        summaryVersion: 2,
      }),
    })),
  }).checks.map(({ id, status, value }) => ({ id, status, value })),
  [
    {
      id: "render-state",
      status: "blocked",
      value: "Blocked: summaryVersion",
    },
    {
      id: "target-page",
      status: "pass",
      value: "./control-page.html",
    },
    {
      id: "load-session-method",
      status: "pass",
      value: "loadControlPageSessionState",
    },
    {
      id: "read-status-method",
      status: "pass",
      value: "readControlPageStatus",
    },
    {
      id: "blocking-reasons",
      status: "pass",
      value: "none",
    },
  ],
);
const blockedManifest = {
  ...createIniPanelShellIntegrationManifest(),
  compatibility: {
    launchApiManifest: false,
    controlPageApiManifest: true,
  },
};
assert.deepEqual(createIniPanelShellIntegrationReadiness(blockedManifest), {
  phase: "blocked",
  ready: false,
  checks: {
    integrationManifestSupported: true,
    launchApiManifestSupported: true,
    controlPageApiManifestSupported: true,
    launchCompatibility: false,
    controlPageCompatibility: true,
  },
  missing: ["launchCompatibility"],
  counts: {
    pages: 3,
    launcherLinks: 3,
    launchMethods: 56,
    controlPageMethods: 11,
    persistenceCapabilities: 3,
  },
  apiNames: {
    integration: "ini-panel-shell-integration",
    launch: "ini-panel-launch",
    controlPage: "ini-panel-control-page",
  },
});
assert.deepEqual(
  createIniPanelShellIntegrationWorkflowPlan({
    manifest: blockedManifest,
    readiness: createIniPanelShellIntegrationReadiness(blockedManifest),
  }).missing,
  ["launchCompatibility"],
);
const blockedWorkflowPlan = createIniPanelShellIntegrationWorkflowPlan({
  manifest: blockedManifest,
  readiness: createIniPanelShellIntegrationReadiness(blockedManifest),
});
assert.deepEqual(
  createIniPanelShellSessionHandoffSummary({
    manifest: blockedManifest,
    readiness: createIniPanelShellIntegrationReadiness(blockedManifest),
    workflowPlan: blockedWorkflowPlan,
  }).blockingReasons,
  ["launchCompatibility"],
);
assert.deepEqual(
  createIniPanelShellSessionHandoffCompatibilityReport(createIniPanelShellSessionHandoffSummary({
    manifest: blockedManifest,
    readiness: createIniPanelShellIntegrationReadiness(blockedManifest),
    workflowPlan: blockedWorkflowPlan,
  })).blockingReasons,
  ["launchCompatibility"],
);
assert.equal(
  createIniPanelShellSessionHandoffCompatibilityReport(createIniPanelShellSessionHandoffSummary({
    manifest: blockedManifest,
    readiness: createIniPanelShellIntegrationReadiness(blockedManifest),
    workflowPlan: blockedWorkflowPlan,
  })).compatible,
  false,
);
assert.deepEqual(
  createIniPanelShellSessionHandoffActionPlan({
    snapshot: createIniPanelShellSessionHandoffSnapshot({
      summary: createIniPanelShellSessionHandoffSummary({
        manifest: blockedManifest,
        readiness: createIniPanelShellIntegrationReadiness(blockedManifest),
        workflowPlan: blockedWorkflowPlan,
      }),
      compatibilityReport: createIniPanelShellSessionHandoffCompatibilityReport(createIniPanelShellSessionHandoffSummary({
        manifest: blockedManifest,
        readiness: createIniPanelShellIntegrationReadiness(blockedManifest),
        workflowPlan: blockedWorkflowPlan,
      })),
    }),
  }).blockingReasons,
  ["launchCompatibility"],
);
const missingTargetPlan = createIniPanelShellIntegrationWorkflowPlan({
  manifest,
  controlEntryId: "missing-entry",
});
assert.equal(missingTargetPlan.ready, false);
assert.deepEqual(missingTargetPlan.missing, ["controlTargetPage"]);
assert.equal(missingTargetPlan.targetPage, null);
const missingControlMethodManifest = {
  ...createIniPanelShellIntegrationManifest(),
  controlPageApiManifest: {
    ...createControlPageBrowserApiManifest(),
    methods: ["getControlPageApiManifest", "readControlPageStatus"],
  },
};
const missingControlMethodPlan = createIniPanelShellIntegrationWorkflowPlan({
  manifest: missingControlMethodManifest,
});
assert.equal(missingControlMethodPlan.ready, false);
assert.deepEqual(missingControlMethodPlan.missing, [
  "controlPageApi.loadControlPageSessionState",
]);
handoffSummary.persistenceCapabilities[0].label = "changed";
handoffSummary.readonlyStatusFields.push("changedField");
assert.equal(createIniPanelShellSessionHandoffSummary().persistenceCapabilities[0].label, "Machine text files");
assert.equal(createIniPanelShellSessionHandoffSummary().readonlyStatusFields.includes("changedField"), false);
const malformedReadiness = createIniPanelShellIntegrationReadiness({
  apiName: "other",
});
assert.equal(malformedReadiness.phase, "blocked");
assert.equal(malformedReadiness.ready, false);
assert.deepEqual(malformedReadiness.missing, [
  "integrationManifestSupported",
  "launchApiManifestSupported",
  "controlPageApiManifestSupported",
  "launchCompatibility",
  "controlPageCompatibility",
]);
assert.deepEqual(malformedReadiness.counts, {
  pages: 0,
  launcherLinks: 0,
  launchMethods: 0,
  controlPageMethods: 0,
  persistenceCapabilities: 0,
});

manifest.pages[0].title = "changed";
manifest.launcherLinks[0].label = "changed";
manifest.launchApiManifest.visibleEntries[0].title = "changed";
manifest.controlPageApiManifest.methods.push("changedMethod");
manifest.persistenceCapabilities[0].label = "changed";
assert.equal(INI_PANEL_ENTRIES[0].title, "Open edit and run panel");
assert.equal(createIniPanelShellIntegrationManifest().pages[0].title, "Open edit and run panel");
assert.equal(createIniPanelShellIntegrationManifest().launcherLinks[0].label, "Open edit and run panel");
assert.equal(
  createIniPanelShellIntegrationManifest().launchApiManifest.visibleEntries[0].title,
  "Open edit and run panel",
);
assert.equal(
  createIniPanelShellIntegrationManifest().controlPageApiManifest.methods.includes("changedMethod"),
  false,
);
assert.equal(
  createIniPanelShellIntegrationManifest().persistenceCapabilities[0].label,
  "Machine text files",
);

const customManifest = createIniPanelShellIntegrationManifest([
  {
    id: "custom",
    href: "./custom.html",
    title: "Custom entry",
  },
]);
assert.deepEqual(customManifest.pages, [
  {
    id: "custom",
    href: "./custom.html",
    title: "Custom entry",
  },
]);
assert.deepEqual(customManifest.launcherLinks, [
  {
    entryId: "custom",
    href: "./custom.html",
    label: "Custom entry",
  },
]);
assert.deepEqual(customManifest.launchApiManifest.targetPages, [
  {
    entryId: "custom",
    href: "./custom.html",
  },
]);

assert.match(shellText, /\bexport function createIniPanelShellIntegrationSchema\b/);
assert.match(shellText, /\bexport function createIniPanelShellIntegrationManifest\b/);
assert.match(shellText, /\bexport function createIniPanelShellIntegrationReadiness\b/);
assert.match(shellText, /\bexport function createIniPanelShellIntegrationWorkflowPlan\b/);
assert.match(shellText, /\bexport function createIniPanelShellSessionHandoffActionPlan\b/);
assert.match(shellText, /\bexport function createIniPanelShellSessionHandoffChecklist\b/);
assert.match(shellText, /\bexport function createIniPanelShellSessionHandoffCompatibilityReport\b/);
assert.match(shellText, /\bexport function createIniPanelShellSessionHandoffDisplayViewModel\b/);
assert.match(shellText, /\bexport function createIniPanelShellSessionHandoffPackage\b/);
assert.match(shellText, /\bexport function createIniPanelShellSessionHandoffPackageDisplayViewModel\b/);
assert.match(shellText, /\bexport function createIniPanelShellSessionHandoffPackageMountDisplayViewModel\b/);
assert.match(shellText, /\bexport function createIniPanelShellSessionHandoffPackageMountRenderState\b/);
assert.match(shellText, /\bexport function createIniPanelShellSessionHandoffPackageMountState\b/);
assert.match(shellText, /\bexport function createIniPanelShellSessionHandoffMountDomContract\b/);
assert.match(shellText, /\bexport function createIniPanelShellSessionHandoffMountDomReadiness\b/);
assert.match(shellText, /\bexport function mountIniPanelShellSessionHandoff\b/);
assert.match(shellText, /\bexport function mountIniPanelShellSessionHandoffFromControlPage\b/);
assert.match(shellText, /\bexport function readIniPanelShellSessionHandoffStatusFromControlPage\b/);
assert.match(shellText, /\bexport function createIniPanelShellSessionHandoffWorkflowSummary\b/);
assert.match(shellText, /\bexport function createIniPanelShellSessionReadinessWorkflowReport\b/);
assert.match(shellText, /\bexport function createIniPanelShellSessionHandoffWorkflowDisplayViewModel\b/);
assert.match(shellText, /\bexport function createIniPanelShellSessionHandoffWorkflowRenderState\b/);
assert.match(shellText, /\bexport function createIniPanelShellSessionHandoffWorkflowDomContract\b/);
assert.match(shellText, /\bexport function createIniPanelShellSessionHandoffWorkflowDomReadiness\b/);
assert.match(shellText, /\bexport function renderIniPanelShellSessionHandoffWorkflowState\b/);
assert.match(shellText, /\bexport function mountIniPanelShellSessionHandoffWorkflow\b/);
assert.match(shellText, /\bexport function createIniPanelShellSessionHandoffPackageReport\b/);
assert.match(shellText, /\bexport function createIniPanelShellWorkflowOverviewEmbeddingReport\b/);
assert.match(shellText, /\bexport function createIniPanelShellWorkflowOverviewEmbeddingDisplayViewModel\b/);
assert.match(shellText, /\bexport function createIniPanelShellWorkflowOverviewEmbeddingRenderState\b/);
assert.match(shellText, /\bexport function createIniPanelShellWorkflowOverviewEmbeddingDomContract\b/);
assert.match(shellText, /\bexport function createIniPanelShellWorkflowOverviewEmbeddingDomReadiness\b/);
assert.match(shellText, /\bexport function renderIniPanelShellWorkflowOverviewEmbeddingState\b/);
assert.match(shellText, /\bexport function mountIniPanelShellWorkflowOverviewEmbeddingState\b/);
assert.match(shellText, /\bexport function createIniPanelShellWorkflowOverviewEmbeddingMountDisplayViewModel\b/);
assert.match(shellText, /\bexport function createIniPanelShellWorkflowOverviewEmbeddingMountRenderState\b/);
assert.match(shellText, /\bexport function createIniPanelShellWorkflowOverviewEmbeddingMountDomContract\b/);
assert.match(shellText, /\bexport function createIniPanelShellWorkflowOverviewEmbeddingMountDomReadiness\b/);
assert.match(shellText, /\bexport function renderIniPanelShellWorkflowOverviewEmbeddingMountState\b/);
assert.match(shellText, /\bexport function mountIniPanelShellWorkflowOverviewEmbeddingMountState\b/);
assert.match(shellText, /\bexport function createIniPanelShellSessionHandoffPackageRenderState\b/);
assert.match(shellText, /\bexport function createIniPanelShellSessionHandoffPackageSchema\b/);
assert.match(shellText, /\bexport function createIniPanelShellSessionHandoffRenderState\b/);
assert.match(shellText, /\bexport function createIniPanelShellSessionHandoffSnapshot\b/);
assert.match(shellText, /\bexport function createIniPanelShellSessionHandoffSummary\b/);
assert.match(shellText, /\bexport function createIniPanelShellSessionHandoffSummarySchema\b/);
assert.match(shellText, /\bexport function isSupportedIniPanelShellSessionHandoffSummary\b/);
assert.match(shellText, /\bexport function isSupportedIniPanelShellSessionHandoffPackage\b/);
assert.match(shellText, /\bexport function isSupportedIniPanelShellIntegrationManifest\b/);
assert.match(launchText, /\bgetShellIntegrationSchema\b/);
assert.match(launchText, /\bgetShellIntegrationManifest\b/);
assert.match(launchText, /\bgetShellIntegrationReadiness\b/);
assert.match(docText, /\bcreateIniPanelShellIntegrationManifest\b/);
assert.match(docText, /\bcreateIniPanelShellIntegrationReadiness\b/);
assert.match(docText, /\bcreateIniPanelShellIntegrationWorkflowPlan\b/);
assert.match(docText, /\bcreateIniPanelShellSessionHandoffActionPlan\b/);
assert.match(docText, /\bcreateIniPanelShellSessionHandoffChecklist\b/);
assert.match(docText, /\bcreateIniPanelShellSessionHandoffCompatibilityReport\b/);
assert.match(docText, /\bcreateIniPanelShellSessionHandoffDisplayViewModel\b/);
assert.match(docText, /\bcreateIniPanelShellSessionHandoffPackage\b/);
assert.match(docText, /\bcreateIniPanelShellSessionHandoffPackageDisplayViewModel\b/);
assert.match(docText, /\bcreateIniPanelShellSessionHandoffPackageMountDisplayViewModel\b/);
assert.match(docText, /\bcreateIniPanelShellSessionHandoffPackageMountRenderState\b/);
assert.match(docText, /\bcreateIniPanelShellSessionHandoffPackageMountState\b/);
assert.match(docText, /\bcreateIniPanelShellSessionHandoffMountDomContract\b/);
assert.match(docText, /\bcreateIniPanelShellSessionHandoffMountDomReadiness\b/);
assert.match(docText, /\bmountIniPanelShellSessionHandoff\b/);
assert.match(docText, /\bmountIniPanelShellSessionHandoffFromControlPage\b/);
assert.match(docText, /\breadIniPanelShellSessionHandoffStatusFromControlPage\b/);
assert.match(docText, /\bcreateIniPanelShellSessionHandoffWorkflowSummary\b/);
assert.match(docText, /\bcreateIniPanelShellSessionHandoffWorkflowDisplayViewModel\b/);
assert.match(docText, /\bcreateIniPanelShellSessionHandoffWorkflowRenderState\b/);
assert.match(docText, /\bcreateIniPanelShellSessionHandoffWorkflowDomContract\b/);
assert.match(docText, /\bcreateIniPanelShellSessionHandoffWorkflowDomReadiness\b/);
assert.match(docText, /\brenderIniPanelShellSessionHandoffWorkflowState\b/);
assert.match(docText, /\bmountIniPanelShellSessionHandoffWorkflow\b/);
assert.match(docText, /\bcreateIniPanelShellSessionHandoffPackageReport\b/);
assert.match(docText, /\bcreateIniPanelShellWorkflowOverviewEmbeddingReport\b/);
assert.match(docText, /\bcreateIniPanelShellWorkflowOverviewEmbeddingDisplayViewModel\b/);
assert.match(docText, /\bcreateIniPanelShellWorkflowOverviewEmbeddingRenderState\b/);
assert.match(docText, /\bcreateIniPanelShellWorkflowOverviewEmbeddingDomContract\b/);
assert.match(docText, /\bcreateIniPanelShellWorkflowOverviewEmbeddingDomReadiness\b/);
assert.match(docText, /\brenderIniPanelShellWorkflowOverviewEmbeddingState\b/);
assert.match(docText, /\bmountIniPanelShellWorkflowOverviewEmbeddingState\b/);
assert.match(docText, /\bcreateIniPanelShellWorkflowOverviewEmbeddingMountDisplayViewModel\b/);
assert.match(docText, /\bcreateIniPanelShellWorkflowOverviewEmbeddingMountRenderState\b/);
assert.match(docText, /\bcreateIniPanelShellWorkflowOverviewEmbeddingMountDomContract\b/);
assert.match(docText, /\bcreateIniPanelShellWorkflowOverviewEmbeddingMountDomReadiness\b/);
assert.match(docText, /\brenderIniPanelShellWorkflowOverviewEmbeddingMountState\b/);
assert.match(docText, /\bmountIniPanelShellWorkflowOverviewEmbeddingMountState\b/);
assert.match(docText, /\bcreateIniPanelShellSessionHandoffPackageRenderState\b/);
assert.match(docText, /\bcreateIniPanelShellSessionHandoffPackageSchema\b/);
assert.match(docText, /\bcreateIniPanelShellSessionHandoffRenderState\b/);
assert.match(docText, /\bcreateIniPanelShellSessionHandoffSnapshot\b/);
assert.match(docText, /\bcreateIniPanelShellSessionHandoffSummary\b/);
assert.match(docText, /\bcreateIniPanelShellSessionHandoffSummarySchema\b/);
assert.match(docText, /\bisSupportedIniPanelShellSessionHandoffSummary\b/);
assert.match(docText, /\bisSupportedIniPanelShellSessionHandoffPackage\b/);
assert.match(docText, /\bisSupportedIniPanelShellIntegrationManifest\b/);
assert.doesNotMatch(shellText, /\bparseGcode\b|\bcanonicalEvents\b|\btoolTable\b|\bplanner\b/);

console.log("ini_panel_shell_integration_manifest_node_smoke=ok");
