// Synthetic SimVSM fixtures — FIXTURE-DATEN-REGEL (see app/wertstrom/[id]/
// __tests__/page.test.ts, P5): every name/number below is FREE INVENTION,
// hand-built to match the REAL SimVSM JSON *shape* (verified structurally
// against the confidential corpus, never against its content — see
// lib/simvsm-import/README.md "Confidentiality"). No supplier/plant/product
// name, number, or path from the real corpus appears anywhere in this file.

export function buildSyntheticSimVsmFile(overrides: { alternatives?: unknown[] } = {}): unknown {
  return {
    name: 'Werk Nord Testmodell',
    description: 'Synthetische Testdatei für Unit-Tests',
    createdWithVersion: '3.36.0',
    mainVersion: '3.20.0',
    settings: {
      products: [{ referenceId: 'prod-a', name: 'Testteil A' }],
      shiftCalendars: [{ id: 1, name: 'Frühschicht' }],
      modelling: {},
      simulation: {},
    },
    alternatives: overrides.alternatives ?? [buildIstAlternative(), buildAlternativeA()],
  }
}

export function buildIstAlternative(): unknown {
  return {
    name: 'Ist-Zustand',
    isMain: false,
    modificationTime: '2026-01-01T00:00:00.000Z',
    lastOpenDate: '2026-01-01T00:00:00.000Z',
    resultData: [],
    extensions: { simvsm: {} },
    model: {
      nodeDataArray: [
        { key: 1, category: 'item', class: 'supplier', nodeName: 'Lieferant Nord', loc: '-200 0', parameters: [{ class: 'comment', type: 'string', value: '' }] },
        {
          key: 2,
          category: 'item',
          class: 'singleProcess',
          nodeName: 'Stanzen',
          loc: '0 0',
          parameters: [
            { class: 'ProductTable', type: 'tableGrid', value: { rows: [{ PlannedCycleTime: { durationInSec: 45 }, ScrapRate: 2, ReworkRate: 0, Product: 'prod-a' }] } },
            { class: 'Availability', type: 'number', value: 95 },
            { class: 'NumberOfWorkers', type: 'number', value: 2 },
            { class: 'isValueAdding', type: 'boolean', value: true },
            { class: 'MTTR', type: 'time', value: { durationInSec: 600 } },
            { class: 'comment', type: 'string', value: 'Testkommentar' },
          ],
        },
        { key: 3, category: 'item', class: 'fifoStore', nodeName: 'FIFO Puffer', loc: '200 0', parameters: [{ class: 'Capacity', type: 'integer', value: 20 }] },
        {
          key: 4,
          category: 'item',
          class: 'customer',
          nodeName: 'Kunde Nord',
          loc: '400 0',
          parameters: [{ class: 'Produkte', type: 'tableGrid', value: { rows: [{ Quantity: 100, Product: 'prod-a' }] } }, { class: 'OrderIndex', type: 'enum', value: 'Bedarf nach Kundentakt' }],
        },
        { key: 5, category: 'item', class: 'productionControl', nodeName: 'PPS', loc: '100 -200', parameters: [{ class: 'dispositionInterval', type: 'time', value: { durationInSec: 86400 } }] },
        { key: 6, category: 'text', class: 'noteVSM', loc: '0 -100', text: 'Kaizen-Idee: Rüstzeit senken' },
        { key: 7, category: 'item', class: 'foreignOrders', nodeName: 'Fremdauftrag', loc: '600 0', parameters: [{ class: 'minOrderQuantity', type: 'integer', value: 5 }] },
      ],
      linkDataArray: [
        { key: -1, category: 'item', class: 'materialFlow', from: 1, to: 2, fromPort: 'R', toPort: 'L' },
        { key: -2, category: 'item', class: 'materialFlow', from: 2, to: 3, fromPort: 'R', toPort: 'L' },
        { key: -3, category: 'item', class: 'materialFlow', from: 3, to: 4, fromPort: 'R', toPort: 'L' },
        { key: -4, category: 'item', class: 'informationFlow', from: 5, to: 2, fromPort: 'B', toPort: 'T', text: 'täglich' },
        { key: -5, category: 'item', class: 'informationFlow', from: 6, to: 2, fromPort: 'B', toPort: 'T' },
      ],
    },
  }
}

export function buildAlternativeA(): unknown {
  return {
    name: 'Alternative A',
    isMain: false,
    resultData: [],
    model: {
      nodeDataArray: [
        { key: 1, category: 'item', class: 'supplier', nodeName: 'Lieferant Nord', loc: '-200 0', parameters: [] },
        {
          key: 2,
          category: 'item',
          class: 'multiProcess',
          nodeName: 'Stanzen (parallel)',
          loc: '0 0',
          parameters: [
            { class: 'ProductTable', type: 'tableGrid', value: { rows: [{ PlannedCycleTime: { durationInSec: 30 }, Product: 'prod-a' }] } },
            { class: 'Capacity', type: 'integer', value: 2 },
          ],
        },
        { key: 4, category: 'item', class: 'customer', nodeName: 'Kunde Nord', loc: '400 0', parameters: [{ class: 'Produkte', type: 'tableGrid', value: { rows: [{ Quantity: 120, Product: 'prod-a' }] } }] },
      ],
      linkDataArray: [
        { key: -1, category: 'item', class: 'materialFlow', from: 1, to: 2 },
        { key: -2, category: 'item', class: 'materialFlow', from: 2, to: 4 },
      ],
    },
  }
}
