import { JourneyDefinition, JourneyId } from './journey.models';

const supplierJourney: JourneyDefinition = {
  id: 'supplier',
  title: 'Supplier Portal',
  persona: 'External supplier user',
  moduleGroup: 'Supplier',
  accent: 'var(--procurement)',
  description: 'External-first onboarding, sourcing, order collaboration, and financing for suppliers.',
  migrationGoal: 'Support supplier onboarding, sourcing, purchase-order collaboration, and financing in one external business journey.',
  currentPhase: 'Release 1',
  journeyMetrics: [
    { label: 'Primary channel', value: 'External supplier portal' },
    { label: 'Experience mode', value: 'Role-based bilingual workspace' },
    { label: 'Primary systems', value: 'ERP + Islamic Finance' }
  ],
  steps: [
    {
      id: 'supplier-access',
      title: 'Access & Identity',
      subtitle: 'Set the supplier journey context',
      description: 'Confirm who is signing in, which company is being represented, and what the supplier needs to complete now.',
      internalLane: 'Portal access and identity governance',
      output: 'A clean supplier context with the correct organization and role assumptions.',
      linkedApis: ['GET /api/v1/demo/bootstrap', 'POST /api/v1/auth/login'],
      checkpoints: [
        'Supplier sees a portal-first welcome state',
        'Open actions are visible before any raw operational lists',
        'Identity and company context are explicit'
      ],
      fields: [
        { key: 'workspaceName', label: 'Representing company', type: 'text', defaultValue: 'Shatta Supplies Co.', helperText: 'Confirm the supplier company name shown for this business session.' },
        {
          key: 'supplierPersona',
          label: 'Primary persona',
          type: 'select',
          defaultValue: 'bid-manager',
          helperText: 'Choose the business role acting on behalf of the supplier.',
          options: [
            { label: 'Bid manager', value: 'bid-manager' },
            { label: 'Commercial lead', value: 'commercial-lead' },
            { label: 'Finance contact', value: 'finance-contact' }
          ]
        }
      ]
    },
    {
      id: 'supplier-profile',
      title: 'New Onboarding & KYC',
      subtitle: 'Multi-step supplier onboarding',
      description: 'Capture organization, compliance, bank, and tax details in one clear supplier onboarding flow.',
      internalLane: 'Supplier onboarding review and bank verification',
      output: 'A submitted or returned supplier profile package with visible next actions.',
      linkedApis: [
        'POST /api/v1/external/parties/{partyId}/supplier-profile',
        'POST /api/v1/external/parties/{partyId}/supplier-profile/submit',
        'POST /api/v1/external/parties/{partyId}/compliance-documents/upload',
        'POST /api/v1/public/onboarding/suppliers/evaluate',
        'GET /api/v1/onboarding/policies/suppliers'
      ],
      checkpoints: [
        'Profile information is captured in clear business steps',
        'Compliance evidence is uploaded in context',
        'KYC completeness is visible before submission',
        'Returned items are visible as action tasks'
      ],
      fields: [
        { key: 'supplierName', label: 'Supplier legal name', type: 'text', defaultValue: 'Shatta Supplies Co.', helperText: 'Enter the legal name that should appear on supplier records and documents.' },
        { key: 'firmNationalId', label: 'Firm national ID (Egypt)', type: 'text', defaultValue: '', helperText: 'Optional for MVP. Enter الرقم القومي للمنشأة when available. Duplicates are rejected across the system.' },
        {
          key: 'supplierCategory',
          label: 'Supplier category',
          type: 'select',
          defaultValue: 'core',
          helperText: 'Map the onboarding lane before the supplier reaches procurement collaboration.',
          options: [
            { label: 'Core supplier', value: 'core' },
            { label: 'Service supplier', value: 'service' },
            { label: 'Project supplier', value: 'project' }
          ]
        },
        {
          key: 'supplierDocumentType',
          label: 'KYC document type',
          type: 'select',
          defaultValue: 'commercial_register',
          helperText: 'Choose the supplier KYC document being uploaded into the onboarding case.',
          options: [
            { label: 'Commercial register', value: 'commercial_register' },
            { label: 'Tax card', value: 'tax_card' },
            { label: 'Bank letter', value: 'bank_letter' }
          ]
        },
        { key: 'supplierKycFile', label: 'KYC file', type: 'file', helperText: 'Attach a PDF or image file for the supplier onboarding case.' },
        { key: 'bankReady', label: 'Bank package notes', type: 'textarea', defaultValue: 'Verified account evidence, signed bank letter, and settlement instructions.', helperText: 'Keep bank validation as an internal control while letting the supplier complete the package externally.' }
      ]
    },
    {
      id: 'supplier-procurement',
      title: 'Sourcing & Quotation',
      subtitle: 'Respond to commercial demand',
      description: 'Guide the supplier through RFQ review, clarifications, quotation submission, and award visibility as a coherent sourcing journey.',
      internalLane: 'Procurement evaluation and award governance',
      output: 'A supplier quotation package that flows cleanly into internal review.',
      linkedApis: [
        'GET /api/v1/external/parties/{partyId}/rfq-invitations',
        'POST /api/v1/external/parties/{partyId}/quotations',
        'POST /api/v1/external/parties/{partyId}/quotations/{quotationId}/submit'
      ],
      checkpoints: [
        'RFQ actions lead the screen',
        'Clarifications and commercial notes are first-class tasks',
        'Award outcome uses supplier-facing language'
      ],
      fields: [
        { key: 'rfqReference', label: 'RFQ reference', type: 'text', defaultValue: 'RFQ-2026-014', helperText: 'Work against a specific sourcing case with a clear commercial reference.' },
        { key: 'quotationValue', label: 'Quotation value', type: 'number', defaultValue: '95000', helperText: 'Enter the commercial value being proposed by the supplier.' }
      ]
    },
    {
      id: 'supplier-orders',
      title: 'Purchase Order Collaboration',
      subtitle: 'Manage acknowledgment and issues',
      description: 'Let suppliers acknowledge purchase orders, raise issues, and confirm delivery commitments in one transaction flow.',
      internalLane: 'Commercial follow-up and order exception management',
      output: 'A supplier-confirmed purchase order or a tracked issue requiring internal action.',
      linkedApis: [
        'POST /api/v1/external/parties/{partyId}/purchase-orders/{orderId}/acknowledge',
        'POST /api/v1/external/parties/{partyId}/purchase-order-issues'
      ],
      checkpoints: [
        'PO decisions can start directly from the supplier side',
        'Issue workflows stay visible to the supplier',
        'The next internal action is explicit'
      ],
      fields: [
        { key: 'poReference', label: 'Purchase order reference', type: 'text', defaultValue: 'PO-2026-1021', helperText: 'Use the purchase order reference to confirm the exact order being handled.' },
        {
          key: 'issueIntent',
          label: 'Issue scenario',
          type: 'select',
          defaultValue: 'delivery-window',
          helperText: 'Expose issue types that matter to suppliers.',
          options: [
            { label: 'Delivery window conflict', value: 'delivery-window' },
            { label: 'Price clarification', value: 'price-clarification' },
            { label: 'Quantity variance', value: 'quantity-variance' }
          ]
        }
      ]
    },
    {
      id: 'supplier-payments',
      title: 'Payments & Settlement',
      subtitle: 'Track supplier-facing payment visibility',
      description: 'Present supplier payment visibility, payout readiness, settlement posture, and future provider-channel readiness inside the supplier package even while external providers remain on hold.',
      internalLane: 'Supplier payment visibility and settlement readiness',
      output: 'A supplier-facing payments section aligned to go-live UX and ready for later provider activation.',
      linkedApis: [],
      checkpoints: [
        'Supplier users see a dedicated payments section in their own frontend package',
        'Settlement posture is visible without exposing internal-only finance controls',
        'Provider readiness is shown as governed UI scope while external activation remains held'
      ],
      fields: [
        {
          key: 'supplierPaymentView',
          label: 'Payments view mode',
          type: 'select',
          defaultValue: 'status',
          helperText: 'Keep the supplier payment section present in the go-live UX while provider integrations remain on hold.',
          options: [
            { label: 'Settlement status', value: 'status' },
            { label: 'Upcoming payouts', value: 'payouts' },
            { label: 'Provider readiness', value: 'provider-readiness' }
          ]
        },
        {
          key: 'supplierPaymentChannel',
          label: 'Visible payment channel',
          type: 'select',
          defaultValue: 'paymob',
          helperText: 'Show the planned provider channels as UI-ready scope without requiring live activation yet.',
          options: [
            { label: 'Paymob', value: 'paymob' },
            { label: 'Fawry', value: 'fawry' }
          ]
        }
      ]
    },
    {
      id: 'supplier-reports',
      title: 'Reports & Statements',
      subtitle: 'Review supplier-facing statements and account outputs',
      description: 'Give suppliers a practical reporting space for statement visibility, delivery follow-up, export, and print actions without exposing internal finance workbenches.',
      internalLane: 'Supplier-facing reports, statements, and export controls',
      output: 'A supplier reports space with account visibility, statement review, and controlled export or print actions.',
      linkedApis: [
        'GET /api/v1/external/parties/{partyId}/reports-statements/summary',
        'GET /api/v1/external/parties/{partyId}/reports-statements',
        'GET /api/v1/external/parties/{partyId}/reports-statements/{statementId}',
        'GET /api/v1/external/parties/{partyId}/reports-statements/{statementId}/delivery-logs'
      ],
      checkpoints: [
        'Supplier users see only supplier-relevant reports and statements',
        'Statement detail is reachable from the same signed-in package',
        'Export and print actions are available from the report workspace'
      ],
      fields: [
        {
          key: 'supplierReportFocus',
          label: 'Report focus',
          type: 'select',
          defaultValue: 'statements',
          helperText: 'Keep the supplier report workspace centered on statements and account-facing outputs.',
          options: [
            { label: 'Statements', value: 'statements' },
            { label: 'Delivery logs', value: 'delivery-logs' },
            { label: 'Account summary', value: 'summary' }
          ]
        },
        {
          key: 'supplierStatementId',
          label: 'Selected statement ID',
          type: 'text',
          defaultValue: '',
          helperText: 'Optional. Leave blank to use the first available supplier statement.'
        }
      ]
    },
    {
      id: 'supplier-finance',
      title: 'Islamic Finance & Offers',
      subtitle: 'Apply, compare, and accept',
      description: 'Let suppliers launch financing applications from the portal, compare lender offers, and track execution without falling back to internal-only screens.',
      internalLane: 'Islamic Finance officer workbench and partner routing',
      output: 'A supplier-originated financing case with offer comparison and acceptance support.',
      linkedApis: [
        'GET /api/v1/external/parties/{partyId}/financing/products',
        'POST /api/v1/external/parties/{partyId}/financing/requests',
        'GET /api/v1/external/parties/{partyId}/financing/requests/{financingRequestId}/offers',
        'POST /api/v1/external/parties/{partyId}/financing/requests/{financingRequestId}/accept-offer'
      ],
      checkpoints: [
        'Financing starts from the supplier portal',
        'Offers are compared in business language',
        'Execution and settlement tracking remain visible after selection'
      ],
      fields: [
        {
          key: 'supplierProduct',
          label: 'Requested product family',
          type: 'select',
          defaultValue: 'murabaha',
          helperText: 'Keep the product family ready for broader Islamic Finance expansion.',
          options: [
            { label: 'Murabaha', value: 'murabaha' },
            { label: 'Receivables finance', value: 'receivables' },
            { label: 'Tawarruq-ready', value: 'tawarruq' }
          ]
        },
        { key: 'supplierAmount', label: 'Requested amount', type: 'number', defaultValue: '120000', helperText: 'This is the external application amount, not an internal follow-up field.' }
      ]
    },
    {
      id: 'supplier-accounting-office',
      title: 'Accounting Office Notices',
      subtitle: 'Send compliance or ETA-ready notices',
      description: 'Let suppliers send governed accounting notices or ETA-support evidence to the assigned Accounting Office for follow-up and submission readiness.',
      internalLane: 'Delegated accounting-office intake for suppliers',
      output: 'A governed accounting-office request visible to the assigned office user.',
      linkedApis: [
        'GET /api/v1/external/parties/{partyId}/accounting-office/requests',
        'POST /api/v1/external/parties/{partyId}/accounting-office/requests',
        'POST /api/v1/external/parties/{partyId}/accounting-office/requests/{requestId}/documents/upload'
      ],
      checkpoints: [
        'The supplier can raise an accounting notice without internal access',
        'Evidence is attached in the same step',
        'The request becomes visible to the assigned accounting office workspace'
      ],
      fields: [
        {
          key: 'aoRequestType',
          label: 'Request type',
          type: 'select',
          defaultValue: 'ACCOUNTING_NOTICE',
          helperText: 'Use a controlled type so the accounting office can route correctly.',
          options: [
            { label: 'Accounting office notice', value: 'ACCOUNTING_NOTICE' },
            { label: 'ETA submission notice', value: 'ETA_NOTICE' },
            { label: 'Statement preparation', value: 'STATEMENT_PREP' },
            { label: 'Compliance update', value: 'COMPLIANCE_UPDATE' }
          ]
        },
        { key: 'aoRequestSubject', label: 'Notice subject', type: 'text', defaultValue: 'ETA readiness pack needs review', helperText: 'Short headline used by the accounting office inbox.' },
        { key: 'aoRequestDetails', label: 'Notice details', type: 'textarea', defaultValue: 'Supplier attached an accounting notice and evidence that must be submitted to ETA under CashLine governance.', helperText: 'Business-readable description of the notice.' },
        { key: 'aoRequestSubjectType', label: 'Evidence category', type: 'text', defaultValue: 'ACCOUNTING_NOTICE', helperText: 'Optional upload scope label (helps keep storage organized).' },
        { key: 'aoRequestDocumentType', label: 'Evidence document type', type: 'text', defaultValue: 'ACCOUNTING_NOTICE', helperText: 'Document type stored against the notice attachment.' },
        { key: 'aoRequestFile', label: 'Evidence file', type: 'file', helperText: 'Attach a PDF or image file for the accounting notice.' }
      ]
    }
  ]
};

const customerJourney: JourneyDefinition = {
  id: 'customer',
  title: 'Customer Portal',
  persona: 'External customer user',
  moduleGroup: 'Customer',
  accent: 'var(--sales-ar)',
  description: 'Customer onboarding, commercial requests, service resolution, payments, and financing as an external journey.',
  migrationGoal: 'Support customer onboarding, service, payment, order, and financing flows in one external business journey.',
  currentPhase: 'Release 1',
  journeyMetrics: [
    { label: 'Primary channel', value: 'External customer portal' },
    { label: 'Experience mode', value: 'Role-based bilingual workspace' },
    { label: 'Primary systems', value: 'ERP + Finance + Islamic Finance' }
  ],
  steps: [
    {
      id: 'customer-context',
      title: 'Welcome & Context',
      subtitle: 'Start from the customer action center',
      description: 'Replace operational status tables as the first impression with a clear action center for customer tasks, dues, and requests.',
      internalLane: 'Customer relationship and portal governance',
      output: 'A customer-ready portal centered on actions instead of follow-up screens.',
      linkedApis: ['GET /api/v1/demo/bootstrap', 'POST /api/v1/auth/login'],
      checkpoints: [
        'Customer sees action cards first',
        'Open invoices, deliveries, and disputes feel customer-owned',
        'The portal does not resemble an internal queue'
      ],
      fields: [
        { key: 'customerWorkspace', label: 'Customer-facing banner', type: 'text', defaultValue: 'Customer Service Hub', helperText: 'Use customer-facing wording that matches the business relationship.' },
        {
          key: 'customerPersona',
          label: 'Primary persona',
          type: 'select',
          defaultValue: 'finance-contact',
          helperText: 'Choose the main customer role using this business journey.',
          options: [
            { label: 'Finance contact', value: 'finance-contact' },
            { label: 'Commercial coordinator', value: 'commercial-coordinator' },
            { label: 'Operations buyer', value: 'operations-buyer' }
          ]
        }
      ]
    },
    {
      id: 'customer-profile',
      title: 'New Onboarding & KYC',
      subtitle: 'Multi-step customer onboarding',
      description: 'Guide the customer through profile, billing, classification, and document steps so the portal supports the real onboarding process.',
      internalLane: 'Customer onboarding review and activation',
      output: 'A customer profile package with visible approval status and next actions.',
      linkedApis: [
        'POST /api/v1/external/parties/{partyId}/customer-profile',
        'POST /api/v1/external/parties/{partyId}/customer-profile/submit',
        'POST /api/v1/external/parties/{partyId}/compliance-documents/upload',
        'POST /api/v1/public/onboarding/customers/evaluate',
        'GET /api/v1/onboarding/policies/customers'
      ],
      checkpoints: [
        'Billing preferences live in the onboarding flow',
        'Returned documents are visible as follow-up tasks',
        'KYC completeness is visible before submission',
        'Status wording is customer-facing'
      ],
      fields: [
        { key: 'customerName', label: 'Customer legal name', type: 'text', defaultValue: 'CashLine Trading Customer', helperText: 'Enter the legal customer name used for billing and contract records.' },
        { key: 'firmNationalId', label: 'Firm national ID (Egypt)', type: 'text', defaultValue: '', helperText: 'Optional for MVP. Enter الرقم القومي للمنشأة when available. Duplicates are rejected across the system.' },
        {
          key: 'customerSegment',
          label: 'Customer segment',
          type: 'select',
          defaultValue: 'b2b',
          helperText: 'Use the segment to branch the later order and finance flows.',
          options: [
            { label: 'B2B', value: 'b2b' },
            { label: 'Strategic', value: 'strategic' },
            { label: 'Project-based', value: 'project' }
          ]
        },
        {
          key: 'billingMode',
          label: 'Billing preference',
          type: 'select',
          defaultValue: 'statement',
          helperText: 'Customers should maintain commercial and billing choices directly.',
          options: [
            { label: 'Statement billing', value: 'statement' },
            { label: 'Invoice billing', value: 'invoice' },
            { label: 'Milestone billing', value: 'milestone' }
          ]
        },
        {
          key: 'customerDocumentType',
          label: 'KYC document type',
          type: 'select',
          defaultValue: 'vat_certificate',
          helperText: 'Choose the customer KYC document being uploaded into the onboarding case.',
          options: [
            { label: 'VAT certificate', value: 'vat_certificate' },
            { label: 'Commercial register', value: 'commercial_register' },
            { label: 'Billing instruction', value: 'billing_instruction' }
          ]
        },
        { key: 'customerKycFile', label: 'KYC file', type: 'file', helperText: 'Attach a PDF or image file for the customer onboarding case.' }
      ]
    },
    {
      id: 'customer-orders',
      title: 'Commercial Request & Orders',
      subtitle: 'Customer-driven request capture',
      description: 'Let customers create requests and orders directly from the portal instead of waiting for internal data entry.',
      internalLane: 'Sales operations and order review',
      output: 'A customer-initiated commercial request that feeds internal review cleanly.',
      linkedApis: [
        'POST /api/v1/external/parties/{partyId}/orders',
        'POST /api/v1/external/parties/{partyId}/orders/{orderId}/submit'
      ],
      checkpoints: [
        'Commercial initiation begins in the customer portal',
        'Order review states are business-friendly',
        'Next actions are visible before internal escalation'
      ],
      fields: [
        {
          key: 'requestType',
          label: 'Request type',
          type: 'select',
          defaultValue: 'sales-order',
          helperText: 'This is the main customer action flow replacing back-office dependence.',
          options: [
            { label: 'Sales order', value: 'sales-order' },
            { label: 'Fulfillment request', value: 'fulfillment' },
            { label: 'Billing adjustment', value: 'billing-adjustment' }
          ]
        },
        { key: 'requestValue', label: 'Requested value', type: 'number', defaultValue: '145000', helperText: 'Guide the customer through the commercial ask instead of hiding it in internal queues.' }
      ]
    },
    {
      id: 'customer-service',
      title: 'Disputes & Service',
      subtitle: 'Resolve customer issues visibly',
      description: 'Turn disputes, escalations, and service responses into a genuine customer workflow with clear states and owned next steps.',
      internalLane: 'Commercial support and exception management',
      output: 'A customer service request with clear acknowledgment or escalation.',
      linkedApis: [
        'POST /api/v1/external/parties/{partyId}/service-requests',
        'POST /api/v1/external/parties/{partyId}/service-requests/{serviceRequestId}/submit',
        'POST /api/v1/external/parties/{partyId}/service-requests/{serviceRequestId}/escalate'
      ],
      checkpoints: [
        'Customers can raise issues directly',
        'Back-office responses return into the same journey',
        'Escalation is explicit and controlled'
      ],
      fields: [
        { key: 'serviceSubject', label: 'Issue subject', type: 'text', defaultValue: 'Delivery delay requires revised commitment', helperText: 'Customer issues should live in the journey rather than in generic administrative follow-up.' },
        {
          key: 'serviceImpact',
          label: 'Commercial impact',
          type: 'select',
          defaultValue: 'medium',
          helperText: 'Set the severity in plain business terms.',
          options: [
            { label: 'Low impact', value: 'low' },
            { label: 'Medium impact', value: 'medium' },
            { label: 'High impact', value: 'high' }
          ]
        }
      ]
    },
    {
      id: 'customer-payments',
      title: 'Payments & Finance',
      subtitle: 'Customer collections and financing',
      description: 'Bring dues, payment initiation, refund status, and Islamic Finance applications together in one customer-owned business flow.',
      internalLane: 'Finance collections, refunds, and Islamic Finance review',
      output: 'A customer flow that covers payment to CashLine and financing requests without switching mental models.',
      linkedApis: [
        'POST /api/v1/external/parties/{partyId}/payments',
        'GET /api/v1/external/parties/{partyId}/payments/{paymentId}/status',
        'POST /api/v1/external/parties/{partyId}/financing/requests',
        'GET /api/v1/external/parties/{partyId}/financing/requests/{financingRequestId}/offers'
      ],
      checkpoints: [
        'Collections and financing both begin in the customer portal',
        'Customers can compare offers in business language',
        'Refund visibility remains in the same payment journey'
      ],
      fields: [
        {
          key: 'paymentChannel',
          label: 'Preferred payment channel',
          type: 'select',
          defaultValue: 'paymob',
          helperText: 'Prepare the customer-facing gateway journey while keeping backend APIs intact.',
          options: [
            { label: 'Paymob', value: 'paymob' },
            { label: 'Fawry', value: 'fawry' }
          ]
        },
        {
          key: 'financeProduct',
          label: 'Financing product family',
          type: 'select',
          defaultValue: 'murabaha',
          helperText: 'The same portal should let customers apply for Islamic Finance directly.',
          options: [
            { label: 'Murabaha', value: 'murabaha' },
            { label: 'Receivables finance', value: 'receivables' },
            { label: 'Tawarruq-ready', value: 'tawarruq' }
          ]
        }
      ]
    },
    {
      id: 'customer-reports',
      title: 'Reports & Statements',
      subtitle: 'Review customer-facing statements and account outputs',
      description: 'Give customers a practical reporting space for statements, billing visibility, delivery follow-up, export, and print actions inside their own package.',
      internalLane: 'Customer-facing reports, statements, and export controls',
      output: 'A customer reports space with statement review, account visibility, and controlled export or print actions.',
      linkedApis: [
        'GET /api/v1/external/parties/{partyId}/reports-statements/summary',
        'GET /api/v1/external/parties/{partyId}/reports-statements',
        'GET /api/v1/external/parties/{partyId}/reports-statements/{statementId}',
        'GET /api/v1/external/parties/{partyId}/reports-statements/{statementId}/delivery-logs'
      ],
      checkpoints: [
        'Customer users see only customer-relevant reports and statements',
        'Statement detail is reachable from the same signed-in package',
        'Export and print actions are available from the report workspace'
      ],
      fields: [
        {
          key: 'customerReportFocus',
          label: 'Report focus',
          type: 'select',
          defaultValue: 'statements',
          helperText: 'Keep the customer report workspace centered on statements and account-facing outputs.',
          options: [
            { label: 'Statements', value: 'statements' },
            { label: 'Delivery logs', value: 'delivery-logs' },
            { label: 'Account summary', value: 'summary' }
          ]
        },
        {
          key: 'customerStatementId',
          label: 'Selected statement ID',
          type: 'text',
          defaultValue: '',
          helperText: 'Optional. Leave blank to use the first available customer statement.'
        }
      ]
    },
    {
      id: 'customer-accounting-office',
      title: 'Accounting Office Notices',
      subtitle: 'Send compliance or ETA-ready notices',
      description: 'Let customers send governed accounting notices or ETA-support evidence to the assigned Accounting Office for follow-up and submission readiness.',
      internalLane: 'Delegated accounting-office intake for customers',
      output: 'A governed accounting-office request visible to the assigned office user.',
      linkedApis: [
        'GET /api/v1/external/parties/{partyId}/accounting-office/requests',
        'POST /api/v1/external/parties/{partyId}/accounting-office/requests',
        'POST /api/v1/external/parties/{partyId}/accounting-office/requests/{requestId}/documents/upload'
      ],
      checkpoints: [
        'The customer can raise an accounting notice without internal access',
        'Evidence is attached in the same step',
        'The request becomes visible to the assigned accounting office workspace'
      ],
      fields: [
        {
          key: 'aoRequestType',
          label: 'Request type',
          type: 'select',
          defaultValue: 'ACCOUNTING_NOTICE',
          helperText: 'Use a controlled type so the accounting office can route correctly.',
          options: [
            { label: 'Accounting office notice', value: 'ACCOUNTING_NOTICE' },
            { label: 'ETA submission notice', value: 'ETA_NOTICE' },
            { label: 'Statement preparation', value: 'STATEMENT_PREP' },
            { label: 'Compliance update', value: 'COMPLIANCE_UPDATE' }
          ]
        },
        { key: 'aoRequestSubject', label: 'Notice subject', type: 'text', defaultValue: 'Statement pack needs accountant review', helperText: 'Short headline used by the accounting office inbox.' },
        { key: 'aoRequestDetails', label: 'Notice details', type: 'textarea', defaultValue: 'Customer attached an accounting notice and evidence that must be prepared for ETA submission under CashLine governance.', helperText: 'Business-readable description of the notice.' },
        { key: 'aoRequestSubjectType', label: 'Evidence category', type: 'text', defaultValue: 'ACCOUNTING_NOTICE', helperText: 'Optional upload scope label (helps keep storage organized).' },
        { key: 'aoRequestDocumentType', label: 'Evidence document type', type: 'text', defaultValue: 'ACCOUNTING_NOTICE', helperText: 'Document type stored against the notice attachment.' },
        { key: 'aoRequestFile', label: 'Evidence file', type: 'file', helperText: 'Attach a PDF or image file for the accounting notice.' }
      ]
    }
  ]
};

const islamicFinanceJourney: JourneyDefinition = {
  id: 'islamic-finance',
  title: 'Islamic Finance',
  persona: 'Supplier and customer applicants plus the officer lane',
  moduleGroup: 'Islamic Finance',
  accent: 'var(--islamic)',
  description: 'A shared application and offer-comparison journey bridging external users with the internal Islamic Finance workbench.',
  migrationGoal: 'Support Islamic Finance applications, offers, workbench review, and execution oversight through one connected journey.',
  currentPhase: 'Release 1',
  journeyMetrics: [
    { label: 'External users', value: 'Supplier + Customer' },
    { label: 'Internal users', value: 'Islamic Finance Officer' },
    { label: 'Design approach', value: 'Offer-led business flow' }
  ],
  steps: [
    {
      id: 'if-product',
      title: 'Product Family',
      subtitle: 'Choose the financing lane',
      description: 'Start with product understanding and business fit instead of raw internal product codes.',
      internalLane: 'Product governance and policy control',
      output: 'A clear product-family selection ready for the application flow.',
      linkedApis: ['GET /api/v1/external/parties/{partyId}/financing/products'],
      checkpoints: [
        'Product families are expressed in business language',
        'Future CashLine Microfinance can slot into the same model',
        'The portal explains the path before data entry starts'
      ],
      fields: [
        {
          key: 'applicantType',
          label: 'Applicant type',
          type: 'select',
          defaultValue: 'customer',
          helperText: 'The product selection should support both customers and suppliers from the start.',
          options: [
            { label: 'Customer applicant', value: 'customer' },
            { label: 'Supplier applicant', value: 'supplier' }
          ]
        },
        {
          key: 'productFamily',
          label: 'Product family',
          type: 'select',
          defaultValue: 'murabaha',
          helperText: 'Keep the structure ready for broader financing products.',
          options: [
            { label: 'Murabaha', value: 'murabaha' },
            { label: 'Receivables finance', value: 'receivables' },
            { label: 'Tawarruq-ready', value: 'tawarruq' },
            { label: 'CashLine Microfinance-ready', value: 'microfinance-ready' }
          ]
        }
      ]
    },
    {
      id: 'if-application',
      title: 'Application',
      subtitle: 'Submit supporting data and amounts',
      description: 'Capture the business use case, source documents, requested amount, and supporting evidence through an application flow.',
      internalLane: 'Islamic Finance intake and completeness review',
      output: 'An externally initiated application case ready for internal review.',
      linkedApis: [
        'POST /api/v1/external/parties/{partyId}/financing/requests',
        'POST /api/v1/external/parties/{partyId}/financing/requests/{financingRequestId}/submit'
      ],
      checkpoints: [
        'Applicants can launch financing directly from the portal',
        'Supporting documents are in-context',
        'Officer review starts from a portal-originated case'
      ],
      fields: [
        {
          key: 'sourceDocument',
          label: 'Source document type',
          type: 'select',
          defaultValue: 'sales-order',
          helperText: 'Tie the application to the external business event that triggered it.',
          options: [
            { label: 'Sales order', value: 'sales-order' },
            { label: 'Purchase order', value: 'purchase-order' },
            { label: 'Statement balance', value: 'statement-balance' }
          ]
        },
        { key: 'requestedAmount', label: 'Requested amount', type: 'number', defaultValue: '180000', helperText: 'Keep the amount inside the application flow rather than a back-office-only form.' }
      ]
    },
    {
      id: 'if-offers',
      title: 'Offer Comparison',
      subtitle: 'Compare and choose lender offers',
      description: 'Show side-by-side offer terms so suppliers and customers can make a real financing decision in the portal.',
      internalLane: 'Partner-lender orchestration and decision publication',
      output: 'A selected financing offer linked to the internal decision flow.',
      linkedApis: [
        'GET /api/v1/external/parties/{partyId}/financing/requests/{financingRequestId}/offers',
        'POST /api/v1/external/parties/{partyId}/financing/requests/{financingRequestId}/accept-offer'
      ],
      checkpoints: [
        'Offers are visible with business comparison points',
        'The user can accept from the same journey',
        'Internal partner routing is still governed behind the scenes'
      ],
      fields: [
        {
          key: 'decisionFocus',
          label: 'Comparison focus',
          type: 'select',
          defaultValue: 'tenor',
          helperText: 'Wizard copy should help the user compare real terms.',
          options: [
            { label: 'Tenor and installments', value: 'tenor' },
            { label: 'Profit and fees', value: 'fees' },
            { label: 'Collateral and conditions', value: 'conditions' }
          ]
        }
      ]
    },
    {
      id: 'if-execution',
      title: 'Execution & Settlement',
      subtitle: 'Track disbursement and completion',
      description: 'Keep the applicant informed through approval, disbursement, settlement, and ongoing tasks using one financing journey summary.',
      internalLane: 'Execution workbench and settlement control',
      output: 'A live financing execution view that still feels external-user friendly.',
      linkedApis: [
        'GET /api/v1/external/parties/{partyId}/financing/requests/{financingRequestId}/journey-summary',
        'GET /api/v1/islamic-finance/execution-workbench'
      ],
      checkpoints: [
        'Disbursement and settlement are visible',
        'Tasks and notifications sit inside the same journey',
        'Internal workbench and external portal remain aligned'
      ],
      fields: [
        {
          key: 'notificationPreference',
          label: 'Primary notification mode',
          type: 'select',
          defaultValue: 'portal',
          helperText: 'Phase 4 keeps notifications and tasks in the same financing experience.',
          options: [
            { label: 'Portal inbox', value: 'portal' },
            { label: 'Email summary', value: 'email' },
            { label: 'Both portal and email', value: 'both' }
          ]
        }
      ]
    }
  ]
};

const financeApprovalsJourney: JourneyDefinition = {
  id: 'finance-approvals',
  title: 'Finance Approvals',
  persona: 'Finance maker, checker, and controlled approvers',
  moduleGroup: 'Finance',
  accent: 'var(--finance)',
  description: 'Controlled finance approvals presented as business decision flows rather than queue-first technical views.',
  migrationGoal: 'Support finance approvals, controls, and decision-making through a business workbench.',
  currentPhase: 'Release 1',
  journeyMetrics: [
    { label: 'Target users', value: 'Finance Maker + Checker' },
    { label: 'Core scope', value: 'Approvals, postings, exceptions, gateway controls' },
    { label: 'Experience mode', value: 'Role-based bilingual workspace' }
  ],
  steps: [
    {
      id: 'fa-intake',
      title: 'Approval Intake',
      subtitle: 'Clarify what needs decision',
      description: 'Start approval work from summarized business context, impact, and required authority rather than a raw approvals queue alone.',
      internalLane: 'Controlled finance approvals',
      output: 'A finance decision context ready for maker or checker action.',
      linkedApis: ['GET /api/v1/internal/work-queues/approvals?moduleCode=FINANCE'],
      checkpoints: [
        'Decision context is visible before document detail',
        'Authority and risk are explicit',
        'Users know whether they are acting as maker or checker'
      ],
      fields: [
        {
          key: 'approvalType',
          label: 'Approval type',
          type: 'select',
          defaultValue: 'posting',
          helperText: 'Wizard paths can branch by approval pattern without changing backend rules.',
          options: [
            { label: 'Posting approval', value: 'posting' },
            { label: 'Refund approval', value: 'refund' },
            { label: 'Gateway execution approval', value: 'gateway' }
          ]
        }
      ]
    },
    {
      id: 'fa-review',
      title: 'Review & Exceptions',
      subtitle: 'Focus on what matters',
      description: 'Guide the reviewer through validations, exceptions, and linked evidence before approval or return.',
      internalLane: 'Finance exception management',
      output: 'A reviewed approval case with clear rationale.',
      linkedApis: ['GET /api/v1/internal/workflow-monitoring?itemLimit=3'],
      checkpoints: [
        'Exceptions are visible within the approval journey',
        'Supporting evidence is grouped per decision',
        'The reviewer can return or reject with clarity'
      ],
      fields: [
        {
          key: 'exceptionPolicy',
          label: 'Exception policy',
          type: 'select',
          defaultValue: 'return',
          helperText: 'Keep control decisions visible and easy to act on.',
          options: [
            { label: 'Return for correction', value: 'return' },
            { label: 'Escalate to checker', value: 'escalate' },
            { label: 'Reject', value: 'reject' }
          ]
        }
      ]
    },
    {
      id: 'fa-gateway',
      title: 'Gateway Controls',
      subtitle: 'Collections, refunds, and payouts',
      description: 'Treat payment gateway approvals as a finance workflow, especially for customer collections, refunds, and supplier payouts.',
      internalLane: 'Finance gateway control and reconciliation',
      output: 'A controlled gateway decision flow that stays aligned with business finance work.',
      linkedApis: [
        'POST /api/v1/finance/customer-payments/{id}/queue-provider-execution',
        'GET /api/v1/finance/customer-refunds/{id}/orchestration',
        'POST /api/v1/finance/ap-payments/{id}/queue-provider-execution',
        'GET /api/v1/finance/payment-executions/{id}/provider-status-contract',
        'GET /api/v1/finance/payment-executions/{id}/provider-cancel-contract'
      ],
      checkpoints: [
        'Gateway work is modeled as finance action, not integration noise',
        'Refund and payout controls sit in the same approval pattern',
        'Provider execution posture is visible before release'
      ],
      fields: [
        {
          key: 'providerChannel',
          label: 'Primary gateway channel',
          type: 'select',
          defaultValue: 'paymob',
          helperText: 'Phase the finance approval UI around the same gateway model used in the backend.',
          options: [
            { label: 'Paymob', value: 'paymob' },
            { label: 'Fawry', value: 'fawry' }
          ]
        }
      ]
    },
    {
      id: 'fa-eta',
      title: 'ETA Notifications',
      subtitle: 'Work the authority exception queue',
      description: 'Let finance users review unresolved ETA notifications, process pending authority messages, and manually re-run notification reconciliation from the finance workspace.',
      internalLane: 'ETA exception handling and statutory finance monitoring',
      output: 'A finance-facing ETA notification queue with direct operational actions and authority-status visibility.',
      linkedApis: [
        'GET /api/v1/finance/eta-notifications',
        'GET /api/v1/finance/eta-notifications/monitoring',
        'POST /api/v1/finance/eta-notifications/process-batch',
        'POST /api/v1/finance/eta-notifications/{id}/reprocess'
      ],
      checkpoints: [
        'ETA authority notifications are visible as finance work, not hidden integration detail',
        'Users can process the queue and re-run a specific unresolved item from the same workspace',
        'Monitoring keeps exception pressure visible for finance operations'
      ],
      fields: [
        {
          key: 'etaNotificationStatus',
          label: 'Queue filter',
          type: 'select',
          defaultValue: 'RECEIVED',
          helperText: 'Switch between pending, retry, failed, and dead-letter ETA notifications without leaving the finance workspace.',
          options: [
            { label: 'Received', value: 'RECEIVED' },
            { label: 'Retry', value: 'RETRY' },
            { label: 'Failed', value: 'FAILED' },
            { label: 'Dead letter', value: 'DEAD_LETTER' }
          ]
        },
        {
          key: 'etaBatchSize',
          label: 'Processing batch size',
          type: 'select',
          defaultValue: '10',
          helperText: 'Use a controlled batch size when processing pending authority notifications from the finance shell.',
          options: [
            { label: '5 items', value: '5' },
            { label: '10 items', value: '10' },
            { label: '20 items', value: '20' }
          ]
        },
        {
          key: 'etaRetryDelaySeconds',
          label: 'Retry delay (seconds)',
          type: 'select',
          defaultValue: '0',
          helperText: 'Manual reprocess can retry immediately or with a short delay when the authority state is still incomplete.',
          options: [
            { label: 'Immediate', value: '0' },
            { label: '5 minutes', value: '300' },
            { label: '15 minutes', value: '900' }
          ]
        }
      ]
    },
    {
      id: 'fa-posting',
      title: 'Posting & Sign-off',
      subtitle: 'Finish controlled execution',
      description: 'Close the flow with approval outcome, posting state, monitoring trace, and next-stage governance visibility.',
      internalLane: 'Posting, monitoring, and audit',
      output: 'A controlled approval decision with traceable follow-through.',
      linkedApis: [
        'GET /api/v1/islamic-finance/execution-workbench',
        'GET /api/v1/internal/workflow-monitoring?itemLimit=10'
      ],
      checkpoints: [
        'Posting readiness is explicit',
        'Monitoring stays tied to the decision',
        'Audit history is naturally connected to the flow'
      ],
      fields: [
        {
          key: 'signoffMode',
          label: 'Sign-off pattern',
          type: 'select',
          defaultValue: 'checker',
          helperText: 'Keep the authority matrix visible as the last step of the flow.',
          options: [
            { label: 'Checker sign-off', value: 'checker' },
            { label: 'Escalated sign-off', value: 'escalated' },
            { label: 'Deferred sign-off', value: 'deferred' }
          ]
        }
      ]
    }
  ]
};

const operationsControlJourney: JourneyDefinition = {
  id: 'operations-control',
  title: 'Operations Control',
  persona: 'Operations maker, inventory controller, and sales operations',
  moduleGroup: 'Operations',
  accent: 'var(--operations)',
  description: 'An internal operations shell for workflow command, execution visibility, and operational evidence.',
  migrationGoal: 'Support workflow command, execution visibility, and operational evidence through a control-room workspace.',
  currentPhase: 'Release 2',
  journeyMetrics: [
    { label: 'Target users', value: 'Operations + Inventory + Sales Ops' },
    { label: 'Core scope', value: 'Workflow queues, execution posture, operational reporting' },
    { label: 'Experience mode', value: 'Role-based bilingual workspace' }
  ],
  steps: [
    {
      id: 'ops-command',
      title: 'Command Center',
      subtitle: 'Start from live operational posture',
      description: 'Give internal operations users a command-center view of active work, queue posture, and current execution attention before they dive into detail.',
      internalLane: 'Workflow control and daily operations command',
      output: 'A live operational picture with the right queue and monitoring context.',
      linkedApis: [
        'GET /api/v1/workflow/queue',
        'GET /api/v1/internal/workflow-monitoring?itemLimit=8'
      ],
      checkpoints: [
        'Operational attention items are visible first',
        'Queue and monitoring data are aligned',
        'The page reads like a control room, not a raw queue dump'
      ],
      fields: [
        { key: 'opsCommandName', label: 'Workspace heading', type: 'text', defaultValue: 'Operations Command Center', helperText: 'Keep the approved look while moving the page toward an intentional control-room experience.' },
        {
          key: 'opsMissingNationalIdPartyId',
          label: 'Client party (missing firm national ID)',
          type: 'select',
          defaultValue: '',
          helperText: 'Optional. Select a client that was onboarded without الرقم القومي للمنشأة so Operations can record it after follow-up.',
          options: [{ label: 'Loading clients missing firm national ID...', value: '' }]
        },
        { key: 'opsFirmNationalId', label: 'Firm national ID (Egypt)', type: 'text', defaultValue: '', helperText: 'Enter الرقم القومي للمنشأة for the selected client. Uniqueness is enforced globally across the system.' }
      ]
    },
    {
      id: 'ops-onboarding',
      title: 'Onboarding Cases & KYC Review',
      subtitle: 'Work supplier and customer onboarding cases',
      description: 'Give operations a dedicated onboarding queue with case status, KYC completeness, and current reviewer findings before approval or return.',
      internalLane: 'Supplier and customer onboarding review',
      output: 'A live onboarding review view across supplier and customer cases.',
      linkedApis: [
        'GET /api/v1/internal/onboarding/leads',
        'GET /api/v1/internal/onboarding/cases',
        'GET /api/v1/internal/onboarding/cases/{subjectTypeCode}/{subjectProfileId}'
      ],
      checkpoints: [
        'Supplier and customer leads are visible before full onboarding cases',
        'Supplier and customer onboarding are visible in one governed queue',
        'Review blockers are visible before approval',
        'Operations can see the current case posture without leaving the shell'
      ],
      fields: [
        {
          key: 'onboardingSubjectType',
          label: 'Case filter',
          type: 'select',
          defaultValue: 'SUPPLIER',
          helperText: 'Focus the onboarding queue on supplier or customer cases.',
          options: [
            { label: 'Supplier cases', value: 'SUPPLIER' },
            { label: 'Customer cases', value: 'CUSTOMER' }
          ]
        },
        { key: 'onboardingCaseProfileId', label: 'Selected case profile ID', type: 'text', defaultValue: '', helperText: 'Used for operations review actions. If left blank, the first visible case is used.' },
        { key: 'onboardingReviewNotes', label: 'Review notes', type: 'textarea', defaultValue: 'Operations reviewed the onboarding package and recorded the decision.', helperText: 'Used for return or reject actions and general follow-up notes.' },
        { key: 'onboardingHoldReason', label: 'Hold reason', type: 'textarea', defaultValue: 'Waiting for additional applicant clarification and supporting evidence.', helperText: 'Used when Operations needs to pause the onboarding case for follow-up.' },
        { key: 'onboardingReopenReason', label: 'Reopen reason', type: 'textarea', defaultValue: 'Applicant supplied additional information and the case is ready for review again.', helperText: 'Used when Operations reopens a previously held or returned onboarding case.' },
        { key: 'opsLeadCompanyName', label: 'New company name', type: 'text', defaultValue: 'Operations Intake Counterparty', helperText: 'Used when Operations opens a new onboarding case manually.' },
        { key: 'opsLeadEmail', label: 'Lead email', type: 'text', defaultValue: 'onboarding.intake@cashline.test', helperText: 'Primary communication route for the new supplier or customer.' },
        { key: 'opsLeadMobile', label: 'Lead mobile number', type: 'text', defaultValue: '+201000000123', helperText: 'Optional direct contact used by Operations during follow-up.' }
      ]
    },
    {
      id: 'ops-execution',
      title: 'Execution & Throughput',
      subtitle: 'See what is moving and what is stuck',
      description: 'Show operational reporting and exceptions together so execution teams understand throughput, bottlenecks, and workload posture in one view.',
      internalLane: 'Operational execution and exception handling',
      output: 'An operational execution picture connected to current queues and exceptions.',
      linkedApis: [
        'GET /api/v1/reports/core-operations',
        'GET /api/v1/internal/work-queues/exceptions'
      ],
      checkpoints: [
        'Operations reporting is tied to live exceptions',
        'The user can spot throughput issues quickly',
        'Operational detail remains business-readable'
      ],
      fields: [
        {
          key: 'opsFocus',
          label: 'Operational focus',
          type: 'select',
          defaultValue: 'throughput',
          helperText: 'Shape the workspace around the current operational concern.',
          options: [
            { label: 'Throughput', value: 'throughput' },
            { label: 'Exceptions', value: 'exceptions' },
            { label: 'SLA attention', value: 'sla' }
          ]
        }
      ]
    }
  ]
};

const accountingOfficeJourney: JourneyDefinition = {
  id: 'accounting-office',
  title: 'Accounting Office',
  persona: 'Accounting office user',
  moduleGroup: 'Delegated accounting-office operations',
  accent: 'var(--shell-accent-strong)',
  description: 'A governed internal-partner workspace for accounting-office users to onboard clients, support approved accounts, and manage ETA or government submission readiness under CashLine control.',
  migrationGoal: 'Reuse the existing internal-user and onboarding foundation while keeping approval authority with CashLine Operations.',
  currentPhase: 'MVP',
  journeyMetrics: [
    { label: 'Target users', value: 'Accounting Office users' },
    { label: 'Core scope', value: 'Client onboarding intake, approved-client servicing, ETA submissions, reporting' },
    { label: 'Governance mode', value: 'System Owner governed, Operations approval required' }
  ],
  steps: [
    {
      id: 'ao-command',
      title: 'Office Command Center',
      subtitle: 'See office posture and governed client workload',
      description: 'Start with a focused accounting-office summary so the user sees current onboarding demand, approved-client servicing attention, and submission posture without entering the broader operations back-office.',
      internalLane: 'Accounting office command and client posture',
      output: 'A restricted accounting-office workspace summary.',
      linkedApis: [
        'GET /api/v1/internal/onboarding/cases',
        'GET /api/v1/accounting-office/clients',
        'GET /api/v1/accounting-office/activity'
      ],
      checkpoints: [
        'The workspace is restricted to accounting-office needs',
        'Operations-only controls remain outside this lane',
        'The user can move into onboarding or reporting from one governed shell'
      ],
      fields: [
        { key: 'aoOfficeName', label: 'Office heading', type: 'text', defaultValue: 'Accounting Office Workspace', helperText: 'Use a clean heading for the governed accounting-office shell.' }
      ]
    },
    {
      id: 'ao-onboarding',
      title: 'Client Onboarding Intake',
      subtitle: 'Open supplier or customer onboarding for client companies',
      description: 'Allow the accounting office to create client onboarding cases using the current CashLine onboarding cycle while keeping approval decisions with CashLine Operations.',
      internalLane: 'Accounting-office client onboarding submission',
      output: 'A submitted onboarding case routed into Operations review.',
      linkedApis: [
        'POST /api/v1/internal/onboarding/suppliers',
        'POST /api/v1/internal/onboarding/customers',
        'GET /api/v1/internal/onboarding/cases'
      ],
      checkpoints: [
        'The office can submit supplier or customer onboarding',
        'Operations review stays mandatory after submission',
        'The accounting office cannot approve its own onboarding cases'
      ],
      fields: [
        {
          key: 'onboardingSubjectType',
          label: 'Client type',
          type: 'select',
          defaultValue: 'SUPPLIER',
          helperText: 'Choose whether the office is submitting a supplier or customer onboarding case.',
          options: [
            { label: 'Supplier client', value: 'SUPPLIER' },
            { label: 'Customer client', value: 'CUSTOMER' }
          ]
        },
        { key: 'onboardingCaseProfileId', label: 'Selected case profile ID', type: 'text', defaultValue: '', helperText: 'Used to review the current case posture after submission.' },
        { key: 'opsLeadCompanyName', label: 'Client company name', type: 'text', defaultValue: 'Accounting Office Managed Client', helperText: 'Name of the client being submitted by the accounting office.' },
        { key: 'opsLeadEmail', label: 'Client email', type: 'text', defaultValue: 'accounting.office.client@cashline.test', helperText: 'Primary client communication route.' },
        { key: 'opsLeadMobile', label: 'Client mobile number', type: 'text', defaultValue: '+201000000234', helperText: 'Optional direct contact used during onboarding follow-up.' }
      ]
    },
    {
      id: 'ao-clients',
      title: 'Approved Client Finance',
      subtitle: 'Work statements, invoices, and client finance follow-up',
      description: 'Prepare the accounting office for approved-client servicing through finance-facing tasks, statement readiness, and invoice follow-up inside a restricted client-service lane.',
      internalLane: 'Approved client finance servicing',
      output: 'A finance-support view for approved client accounts.',
      linkedApis: [
        'GET /api/v1/reports/core-finance',
        'GET /api/v1/reports/finance-stakeholders'
      ],
      checkpoints: [
        'Only approved-client servicing activities are visible',
        'The lane feels useful without exposing internal governance features',
        'Client-facing finance activity can be monitored in one place'
      ],
      fields: [
        {
          key: 'aoClientFocus',
          label: 'Client servicing focus',
          type: 'select',
          defaultValue: 'statements',
          helperText: 'Shape the office view around the current client-service need.',
          options: [
            { label: 'Statements', value: 'statements' },
            { label: 'Invoices', value: 'invoices' },
            { label: 'Collections follow-up', value: 'collections' }
          ]
        },
        {
          key: 'aoSelectedPartyId',
          label: 'Assigned client',
          type: 'select',
          defaultValue: '',
          helperText: 'Select from assigned clients. If left blank, the first assigned client is used for the workspace detail.',
          options: [{ label: 'Loading assigned clients...', value: '' }]
        },
        {
          key: 'aoSelectedClientRequestId',
          label: 'Selected client notice',
          type: 'select',
          defaultValue: '',
          helperText: 'Select from client notices. If left blank, the first visible client request is used for review or completion.',
          options: [{ label: 'Loading client requests...', value: '' }]
        },
        { key: 'aoClientRequestReviewNotes', label: 'Review notes (optional)', type: 'textarea', defaultValue: '', helperText: 'Optional notes captured when the accounting office starts review.' },
        { key: 'aoClientRequestCompletionNotes', label: 'Completion notes', type: 'textarea', defaultValue: 'Completed by Accounting Office under CashLine governance.', helperText: 'Required notes when completing a client request.' },
        { key: 'aoClientRequestRejectionReason', label: 'Rejection reason', type: 'textarea', defaultValue: 'Rejected due to missing evidence or incorrect submission.', helperText: 'Required reason when rejecting a client request.' }
      ]
    },
    {
      id: 'ao-submissions',
      title: 'ETA & Government Submissions',
      subtitle: 'Track submission readiness and filing posture',
      description: 'Keep ETA and other government submissions visible inside the accounting-office workspace so the office can prepare and follow the compliance cycle under the current governed operating model.',
      internalLane: 'Government submission readiness',
      output: 'A monitored submission posture for the office and its approved clients.',
      linkedApis: [
        'GET /api/v1/eta/compliance/readiness',
        'GET /api/v1/internal/workflow-monitoring?itemLimit=5',
        'GET /api/v1/accounting-office/clients/{partyId}/statements',
        'POST /api/v1/accounting-office/clients/{partyId}/statements/generate',
        'POST /api/v1/accounting-office/clients/{partyId}/statements/{statementId}/delivery-logs',
        'POST /api/v1/accounting-office/clients/{partyId}/statements/{statementId}/delivery-logs/{deliveryLogId}/acknowledge',
        'POST /api/v1/accounting-office/clients/{partyId}/statements/{statementId}/delivery-logs/{deliveryLogId}/retry'
      ],
      checkpoints: [
        'Submission readiness is visible without opening the operations shell',
        'The office can monitor ETA-facing work in one place',
        'Governed submission tracing remains intact'
      ],
      fields: [
        {
          key: 'aoSubmissionFocus',
          label: 'Submission focus',
          type: 'select',
          defaultValue: 'eta',
          helperText: 'Keep the submission lane aligned with the current filing workload.',
          options: [
            { label: 'ETA filings', value: 'eta' },
            { label: 'Government reporting', value: 'government' },
            { label: 'Submission exceptions', value: 'exceptions' }
          ]
        },
        { key: 'aoSelectedPartyId', label: 'Assigned client', type: 'select', defaultValue: '', helperText: 'Choose the assigned client whose ETA and government submission posture you want to review.' },
        { key: 'aoSelectedInvoiceId', label: 'Selected client invoice', type: 'select', defaultValue: '', helperText: 'Choose the client invoice used for ETA submission review. If left blank, the first visible invoice is used.' },
        { key: 'aoSelectedStatementId', label: 'Selected client statement', type: 'select', defaultValue: '', helperText: 'Choose the client statement used for delivery-log and acknowledgment work. If left blank, the first visible statement is used.' },
        { key: 'aoStatementDateFrom', label: 'Statement date from', type: 'date', defaultValue: '', helperText: 'Optional. Leave blank to use the system default range.' },
        { key: 'aoStatementDateTo', label: 'Statement date to', type: 'date', defaultValue: '', helperText: 'Optional. Leave blank to use the system default range.' },
        { key: 'aoStatementCurrencyCode', label: 'Statement currency', type: 'text', defaultValue: 'EGP', helperText: 'Optional currency filter used when generating statements.' },
        { key: 'aoEtaPayloadText', label: 'ETA payload note', type: 'textarea', defaultValue: 'Delegated ETA submission triggered by Accounting Office under CashLine governance.', helperText: 'Optional payload note carried with the governed ETA submission.' },
        {
          key: 'aoStatementDeliveryChannel',
          label: 'Statement delivery channel',
          type: 'select',
          defaultValue: 'EMAIL',
          helperText: 'Channel used by the accounting office to deliver a client statement.',
          options: [
            { label: 'Email', value: 'EMAIL' },
            { label: 'Portal', value: 'PORTAL' },
            { label: 'SMS', value: 'SMS' },
            { label: 'WhatsApp', value: 'WHATSAPP' }
          ]
        },
        {
          key: 'aoStatementDeliveryStatus',
          label: 'Statement delivery status',
          type: 'select',
          defaultValue: 'DELIVERED',
          helperText: 'Delivery outcome captured in delegated audit and reporting trail.',
          options: [
            { label: 'Delivered', value: 'DELIVERED' },
            { label: 'Sent', value: 'SENT' },
            { label: 'Failed', value: 'FAILED' }
          ]
        },
        { key: 'aoStatementDeliveryRecipient', label: 'Statement recipient address', type: 'text', defaultValue: 'client.reports@cashline.test', helperText: 'Recipient endpoint used for statement delivery follow-up.' },
        { key: 'aoStatementDeliveryNotes', label: 'Statement delivery note', type: 'textarea', defaultValue: 'Delegated statement delivery logged by Accounting Office under CashLine governance.', helperText: 'Optional trace note captured with the delegated delivery event.' },
        { key: 'aoSelectedDeliveryLogId', label: 'Selected delivery log', type: 'select', defaultValue: '', helperText: 'Choose the statement delivery log to acknowledge or retry. If left blank, the latest visible delivery log is used.' },
        {
          key: 'aoStatementAckStatus',
          label: 'Delivery acknowledgment status',
          type: 'select',
          defaultValue: 'ACKNOWLEDGED',
          helperText: 'Acknowledgment result captured for supplier statement delivery follow-up.',
          options: [
            { label: 'Acknowledged', value: 'ACKNOWLEDGED' },
            { label: 'Rejected', value: 'REJECTED' },
            { label: 'Disputed', value: 'DISPUTED' }
          ]
        },
        { key: 'aoStatementAckNotes', label: 'Delivery acknowledgment note', type: 'textarea', defaultValue: 'Delegated supplier statement delivery acknowledgment recorded by Accounting Office.', helperText: 'Optional acknowledgment note stored with the delegated supplier delivery log.' },
        { key: 'aoStatementRetryNotes', label: 'Delivery retry note', type: 'textarea', defaultValue: 'Delegated statement delivery retry recorded by Accounting Office.', helperText: 'Optional note stored with the retry delivery attempt.' },
        {
          key: 'aoClientComplianceDocumentType',
          label: 'Compliance document type',
          type: 'select',
          defaultValue: 'COMMERCIAL_REGISTER',
          helperText: 'Choose the client compliance document type being submitted by the accounting office.',
          options: [
            { label: 'Commercial register', value: 'COMMERCIAL_REGISTER' },
            { label: 'Tax card', value: 'TAX_CARD' },
            { label: 'VAT certificate', value: 'VAT_CERTIFICATE' },
            { label: 'National ID', value: 'NATIONAL_ID' }
          ]
        },
        { key: 'aoClientComplianceFile', label: 'Client compliance file', type: 'file', defaultValue: '', helperText: 'Upload the client compliance file from the governed accounting-office lane.' }
      ]
    },
    {
      id: 'ao-reports',
      title: 'Office Reporting',
      subtitle: 'Export governed reporting outputs',
      description: 'Allow the accounting office to use the current reporting and export foundations for its governed workspace without exposing broader internal reporting domains.',
      internalLane: 'Accounting-office reporting outputs',
      output: 'A report-ready view for office-facing exports and print actions.',
      linkedApis: [
        'GET /api/v1/reports/core-finance',
        'GET /api/v1/reports/core-operations'
      ],
      checkpoints: [
        'Reporting stays exportable inside the office workspace',
        'The office sees useful outputs without unrelated internal cards',
        'The route remains consistent with the governed reporting model'
      ],
      fields: [
        {
          key: 'aoReportFocus',
          label: 'Report focus',
          type: 'select',
          defaultValue: 'finance',
          helperText: 'Choose which office-facing report perspective to emphasize.',
          options: [
            { label: 'Finance outputs', value: 'finance' },
            { label: 'Operational posture', value: 'operations' }
          ]
        },
        { key: 'aoSelectedPartyId', label: 'Assigned client', type: 'select', defaultValue: '', helperText: 'Choose the assigned client used for reporting detail. If left blank, the first assigned client is used.' }
      ]
    }
  ]
};

const reportingCenterJourney: JourneyDefinition = {
  id: 'reporting-center',
  title: 'Reports',
  persona: 'Finance, Operations, and Murabaha-first internal reporting users',
  moduleGroup: 'Reporting',
  accent: 'var(--finance)',
  description: 'A governed reporting workspace for finance, accounting, operations, and Islamic Finance users with practical report navigation, export, and print controls.',
  migrationGoal: 'Support go-live reporting through role-based report visibility, guided navigation, and production-style export and print operations.',
  currentPhase: 'Release 1',
  journeyMetrics: [
    { label: 'Target users', value: 'Finance + Operations + Islamic Finance + Management review' },
    { label: 'Core scope', value: 'Finance, accounting, operations, aging, statements, snapshots' },
    { label: 'Experience mode', value: 'Role-based bilingual workspace' }
  ],
  steps: [
    {
      id: 'reports-summary',
      title: 'Finance Reports Package',
      subtitle: 'Use the assigned finance and shared reports',
      description: 'Present the assigned finance report package from the new workbook, linked to live backend finance, settlement, statement, and transaction data.',
      internalLane: 'Finance reporting access and commercial performance review',
      output: 'A finance reporting workspace with assigned financial and shared reports tied to live business data.',
      linkedApis: [
        'GET /api/v1/reports/core-finance',
        'GET /api/v1/reports/finance-stakeholders',
        'GET /api/v1/finance/customer-statements',
        'GET /api/v1/finance/supplier-statements',
        'GET /api/v1/finance/collections/queue',
        'GET /api/v1/finance/supplier-account-reconciliations',
        'GET /api/v1/finance/payment-settlement-batches',
        'GET /api/v1/workflow/instances',
        'GET /api/v1/sales/orders'
      ],
      checkpoints: [
        'Finance users can see only the assigned finance and shared report package',
        'Each finance report is linked to live backend finance or transaction data',
        'Export and print can begin from the reporting workspace'
      ],
      fields: [
        {
          key: 'financeReportFocus',
          label: 'Primary finance report',
          type: 'select',
          defaultValue: 'gained-profit-per-customer',
          helperText: 'Choose the finance or shared report to foreground from the assigned workbook package.',
          options: [
            { label: 'Gained-profit per customer reprot', value: 'gained-profit-per-customer' },
            { label: 'Currencies margin profit per customer report', value: 'currencies-margin-profit-per-customer' },
            { label: 'Currencies margin profile per user reprot', value: 'currencies-margin-profile-per-user' },
            { label: 'Sales by currencies report (EGP / USD)', value: 'sales-by-currencies' },
            { label: 'Currency performance report (Sales volume)', value: 'currency-performance-sales-volume' },
            { label: 'Settlement report per customer / supplier', value: 'settlement-per-customer-supplier' },
            { label: 'AR report per customer', value: 'ar-per-customer' },
            { label: 'AP report per supplier', value: 'ap-per-supplier' },
            { label: 'Statement of account For (CashLine / Supplier / Customer)', value: 'statement-of-account' },
            { label: 'Rejected transactions report - detailed', value: 'rejected-transactions-detailed' },
            { label: 'Successful transactions report - detailed', value: 'successful-transactions-detailed' }
          ]
        },
        {
          key: 'reportingWindow',
          label: 'Review window',
          type: 'select',
          defaultValue: 'current',
          helperText: 'Use the review window to frame the finance reporting conversation.',
          options: [
            { label: 'Current position', value: 'current' },
            { label: 'Month to date', value: 'mtd' },
            { label: 'Quarter to date', value: 'qtd' }
          ]
        }
      ]
    },
    {
      id: 'reports-financial-statements',
      title: 'Financial Statements',
      subtitle: 'Use go-live finance and accounting outputs',
      description: 'Provide the finance reporting outputs required for go-live, including financial statements, trial balance, and end-of-day accounting entries with controlled export formats.',
      internalLane: 'Finance and accounting report execution',
      output: 'A finance-report lane where users can view, export, and print core accounting outputs.',
      linkedApis: [
        'GET /api/v1/reports/finance-statements/{statementCode}',
        'GET /api/v1/reports/finance-statements/{statementCode}/export'
      ],
      checkpoints: [
        'Financial statements are available in the same post-login workspace',
        'Trial balance and end-of-day entries are handled as controlled report outputs',
        'Export and print actions are part of the workflow, not technical side paths'
      ],
      fields: [
        {
          key: 'financialStatementCode',
          label: 'Financial report',
          type: 'select',
          defaultValue: 'BALANCE_SHEET',
          helperText: 'Choose the finance or accounting report to view and export.',
          options: [
            { label: 'Balance Sheet', value: 'BALANCE_SHEET' },
            { label: 'Income Statement', value: 'INCOME_STATEMENT' },
            { label: 'Cash Flow Statement', value: 'CASH_FLOW' },
            { label: 'Trial Balance', value: 'TRIAL_BALANCE' },
            { label: 'End-of-Day Entries', value: 'ACCOUNTING_ENTRIES' }
          ]
        },
        {
          key: 'financialStatementFormat',
          label: 'Export format',
          type: 'select',
          defaultValue: 'PDF',
          helperText: 'Use PDF for print-ready output, CSV for analysis, and Excel where needed.',
          options: [
            { label: 'PDF', value: 'PDF' },
            { label: 'CSV', value: 'CSV' },
            { label: 'Excel', value: 'EXCEL' }
          ]
        },
        {
          key: 'financialAsOfDate',
          label: 'As-of date',
          type: 'date',
          helperText: 'Used for balance sheet, trial balance, and end-of-day style reporting.'
        },
        {
          key: 'financialDateFrom',
          label: 'Date from',
          type: 'date',
          helperText: 'Used for date-range reports such as income statement, cash flow, and accounting entries.'
        },
        {
          key: 'financialDateTo',
          label: 'Date to',
          type: 'date',
          helperText: 'Used for date-range reports such as income statement, cash flow, and accounting entries.'
        }
      ]
    },
    {
      id: 'reports-operations',
      title: 'Operations Reports',
      subtitle: 'Review governed operational reports by business responsibility',
      description: 'Present the assigned Operations report list in one governed reporting lane covering onboarding review, user visibility, and procurement, inventory, sales, and activity oversight.',
      internalLane: 'Operations reporting, onboarding review, and business-activity oversight',
      output: 'A practical Operations reporting workspace with the exact assigned report set for go-live use.',
      linkedApis: [
        'GET /api/v1/demo/bootstrap',
        'GET /api/v1/internal/onboarding/cases',
        'GET /api/v1/internal/workflow-monitoring',
        'GET /api/v1/workflow/instances',
        'GET /api/v1/procurement/purchase-requisitions',
        'GET /api/v1/procurement/purchase-orders',
        'GET /api/v1/inventory/movements',
        'GET /api/v1/inventory/adjustments',
        'GET /api/v1/sales/orders',
        'GET /api/v1/sales/returns',
        'GET /api/v1/reports/finance-stakeholders',
        'GET /api/v1/finance/payment-settlement-batches',
        'GET /api/v1/finance/customer-statements',
        'GET /api/v1/finance/supplier-statements'
      ],
      checkpoints: [
        'Operations users can reach the exact assigned operations and shared report list after login',
        'Each operations report is linked to live backend workflow, onboarding, finance, or transaction data',
        'CSV, PDF, and print actions remain available from the report workspace'
      ],
      fields: [
        {
          key: 'operationsAsOfDate',
          label: 'As-of date',
          type: 'date',
          helperText: 'Used for onboarding and activity reports that need a point-in-time posture.'
        },
        {
          key: 'operationsDateFrom',
          label: 'Date from',
          type: 'date',
          helperText: 'Used for operational activity reports and workflow review windows.'
        },
        {
          key: 'operationsDateTo',
          label: 'Date to',
          type: 'date',
          helperText: 'Used for operational activity reports and workflow review windows.'
        },
        {
          key: 'operationsReportFocus',
          label: 'Primary report focus',
          type: 'select',
          defaultValue: 'currencies-margin-profit-per-customer',
          helperText: 'Choose the Operations or shared report you want to foreground first from the assigned workbook package.',
          options: [
            { label: 'Currencies margin profit per customer report', value: 'currencies-margin-profit-per-customer' },
            { label: 'Currencies margin profile per user reprot', value: 'currencies-margin-profile-per-user' },
            { label: 'Settlement report per customer / supplier', value: 'settlement-per-customer-supplier' },
            { label: 'Statement of account For (CashLine / Supplier / Customer)', value: 'statement-of-account' },
            { label: 'Complaints reprot - detailed', value: 'complaints-detailed' },
            { label: 'User log report', value: 'user-log-report' },
            { label: 'Users number per customer', value: 'users-number-per-customer' },
            { label: 'Users number per supplier', value: 'users-number-per-supplier' },
            { label: 'Users number for CashLine per department', value: 'users-number-for-cashline-per-department' },
            { label: 'Rejected transactions report - detailed', value: 'rejected-transactions-detailed' },
            { label: 'Successful transactions report - detailed', value: 'successful-transactions-detailed' },
            { label: 'Analytical report', value: 'analytical-report' }
          ]
        }
      ]
    },
    {
      id: 'reports-snapshots',
      title: 'Snapshot Library',
      subtitle: 'Generate and review management evidence',
      description: 'Bring report snapshots into the same reporting journey so users can create and review evidence without falling back to raw technical endpoints.',
      internalLane: 'Reporting evidence and governance',
      output: 'A reusable reporting snapshot library tied to the live reporting center.',
      linkedApis: [
        'GET /api/v1/reports/snapshots',
        'POST /api/v1/reports/snapshots'
      ],
      checkpoints: [
        'Snapshots are generated from the same reporting experience',
        'Users can review existing reporting evidence quickly',
        'The snapshot library supports management and governance review'
      ],
      fields: [
        {
          key: 'snapshotReportCode',
          label: 'Snapshot report',
          type: 'select',
          defaultValue: 'CORE_FINANCE',
          helperText: 'Choose which report should be snapshotted from this center.',
          options: [
            { label: 'Core finance', value: 'CORE_FINANCE' },
            { label: 'Core operations', value: 'CORE_OPERATIONS' },
            { label: 'Aging AR', value: 'AGING_AR' },
            { label: 'Aging AP', value: 'AGING_AP' }
          ]
        }
      ]
    }
  ]
};

const workflowMonitoringJourney: JourneyDefinition = {
  id: 'workflow-monitoring',
  title: 'Workflow Monitoring',
  persona: 'Operations, finance control, and support monitoring users',
  moduleGroup: 'Monitoring',
  accent: 'var(--external)',
  description: 'A live workflow-monitoring shell for queues, exceptions, notifications, and operational traceability.',
  migrationGoal: 'Support operational monitoring, traceability, and response handling through one monitoring workspace.',
  currentPhase: 'Release 2',
  journeyMetrics: [
    { label: 'Target users', value: 'Operations + Finance control + Support' },
    { label: 'Core scope', value: 'Workflow monitoring, notifications, recovery posture' },
    { label: 'Experience mode', value: 'Role-based bilingual workspace' }
  ],
  steps: [
    {
      id: 'monitor-live',
      title: 'Live Monitoring',
      subtitle: 'Read the current system posture',
      description: 'Start with a live monitoring view of workflow items and operational posture so users see what is happening now.',
      internalLane: 'Workflow monitoring and live control',
      output: 'A live operational trace view with current workflow attention items.',
      linkedApis: [
        'GET /api/v1/internal/workflow-monitoring?itemLimit=10',
        'GET /api/v1/workflow/queue'
      ],
      checkpoints: [
        'Live workflow posture is immediately visible',
        'The page supports real operational traceability',
        'Users can move from posture to detail without changing mental models'
      ],
      fields: [
        {
          key: 'monitorItemLimit',
          label: 'Monitoring depth',
          type: 'select',
          defaultValue: '10',
          helperText: 'Keep the live view intentional rather than overwhelming.',
          options: [
            { label: 'Top 5 items', value: '5' },
            { label: 'Top 10 items', value: '10' },
            { label: 'Top 20 items', value: '20' }
          ]
        }
      ]
    },
    {
      id: 'monitor-exceptions',
      title: 'Exceptions & Recovery',
      subtitle: 'Understand what needs intervention',
      description: 'Bring together work-queue exceptions, collections attention, and reconciliation exceptions so the monitoring lane becomes action-oriented.',
      internalLane: 'Exception and recovery management',
      output: 'A recovery-oriented monitoring picture across system exceptions.',
      linkedApis: [
        'GET /api/v1/internal/work-queues/exceptions',
        'GET /api/v1/finance/collections/queue',
        'GET /api/v1/finance/reconciliations/exception-queue'
      ],
      checkpoints: [
        'Exceptions are grouped around intervention needs',
        'Collections and reconciliation posture are visible',
        'The page supports recovery-oriented operations'
      ],
      fields: [
        {
          key: 'exceptionFocus',
          label: 'Primary intervention lane',
          type: 'select',
          defaultValue: 'workflow',
          helperText: 'Keep the monitoring step tuned to the current recovery lane.',
          options: [
            { label: 'Workflow exceptions', value: 'workflow' },
            { label: 'Collections queue', value: 'collections' },
            { label: 'Reconciliation exceptions', value: 'reconciliation' }
          ]
        }
      ]
    },
    {
      id: 'monitor-notifications',
      title: 'Notifications & Trace',
      subtitle: 'Inspect downstream signal flow',
      description: 'Show notification queue posture beside ETA authority notifications and workflow traceability so support users can work unresolved downstream signals from one monitoring lane.',
      internalLane: 'Notification orchestration, ETA exception handling, and downstream traceability',
      output: 'A trace-friendly monitoring lane that includes notification backlog visibility and ETA exception response.',
      linkedApis: [
        'GET /api/v1/notifications/queue',
        'GET /api/v1/internal/workflow-monitoring?itemLimit=5',
        'GET /api/v1/finance/eta-notifications/monitoring',
        'POST /api/v1/finance/eta-notifications/process-batch',
        'GET /api/v1/finance/payment-executions/{id}/provider-status-contract',
        'GET /api/v1/finance/payment-executions/{id}/provider-cancel-contract'
      ],
      checkpoints: [
        'Notifications are visible as part of the system trace',
        'ETA authority notification pressure is visible to support users',
        'Backlog posture can be reviewed quickly',
        'Monitoring stays tied to real user-facing signal flow'
      ],
      fields: [
        { key: 'traceNote', label: 'Trace note', type: 'textarea', defaultValue: 'Monitoring the end-to-end signal path from workflow event to notification.', helperText: 'Use this step to frame traceability and downstream control review.' },
        {
          key: 'etaNotificationStatus',
          label: 'ETA queue filter',
          type: 'select',
          defaultValue: 'RECEIVED',
          helperText: 'Support users can switch across unresolved ETA notification states from the same monitoring lane.',
          options: [
            { label: 'Received', value: 'RECEIVED' },
            { label: 'Retry', value: 'RETRY' },
            { label: 'Failed', value: 'FAILED' },
            { label: 'Dead letter', value: 'DEAD_LETTER' }
          ]
        },
        {
          key: 'etaBatchSize',
          label: 'ETA processing batch',
          type: 'select',
          defaultValue: '10',
          helperText: 'Choose how many ETA notifications should be processed from the support lane in one run.',
          options: [
            { label: '5 items', value: '5' },
            { label: '10 items', value: '10' },
            { label: '20 items', value: '20' }
          ]
        },
        {
          key: 'etaRetryDelaySeconds',
          label: 'ETA retry delay (seconds)',
          type: 'select',
          defaultValue: '0',
          helperText: 'Manual support reprocess can retry immediately or with a controlled delay.',
          options: [
            { label: 'Immediate', value: '0' },
            { label: '5 minutes', value: '300' },
            { label: '15 minutes', value: '900' }
          ]
        }
      ]
    }
  ]
};

export const JOURNEY_DEFINITIONS: Record<JourneyId, JourneyDefinition> = {
  supplier: supplierJourney,
  customer: customerJourney,
  'accounting-office': accountingOfficeJourney,
  'islamic-finance': islamicFinanceJourney,
  'finance-approvals': financeApprovalsJourney,
  'operations-control': operationsControlJourney,
  'reporting-center': reportingCenterJourney,
  'workflow-monitoring': workflowMonitoringJourney
};

export const JOURNEY_ORDER: JourneyId[] = [
  'supplier',
  'customer',
  'accounting-office',
  'islamic-finance',
  'finance-approvals',
  'operations-control',
  'reporting-center',
  'workflow-monitoring'
];

export function getJourneyDefinition(id: JourneyId): JourneyDefinition {
  return JOURNEY_DEFINITIONS[id];
}

export function getDefaultJourneyStepId(id: JourneyId): string {
  switch (id) {
    case 'supplier':
      return 'supplier-profile';
    case 'customer':
      return 'customer-profile';
    case 'accounting-office':
      return 'ao-onboarding';
    case 'operations-control':
      return 'ops-onboarding';
    default:
      return JOURNEY_DEFINITIONS[id].steps[0]?.id ?? '';
  }
}
