/**
 * Request Flow Registry
 * 
 * Central registry for all request flow types.
 * This provides a single import point for flow-specific components.
 * 
 * LOCATION: src/flows.ts
 * 
 * This file imports from flow folders at src/ level:
 * - src/custom/
 * - src/dealer-claim/
 * - src/shared/
 */

import { RequestFlowType } from '@/utils/requestTypeUtils';
import { UserFilterType } from '@/utils/userFilterUtils';

// Import flow modules from src/ level
import * as CustomFlow from './custom';
import * as DealerClaimFlow from './dealer-claim';
import * as SharedComponents from './shared/components';

/**
 * Flow registry mapping
 * Maps RequestFlowType to their respective flow modules
 */
export const FlowRegistry = {
  CUSTOM: CustomFlow,
  DEALER_CLAIM: DealerClaimFlow,
} as const;

/**
 * Get flow module for a given flow type
 */
export function getFlowModule(flowType: RequestFlowType) {
  return FlowRegistry[flowType];
}

/**
 * Get overview tab component for a flow type
 */
export function getOverviewTab(flowType: RequestFlowType) {
  switch (flowType) {
    case 'DEALER_CLAIM':
      return DealerClaimFlow.DealerClaimOverviewTab;
    case 'CUSTOM':
    default:
      return CustomFlow.CustomOverviewTab;
  }
}

/**
 * Get workflow tab component for a flow type
 */
export function getWorkflowTab(flowType: RequestFlowType) {
  switch (flowType) {
    case 'DEALER_CLAIM':
      return DealerClaimFlow.DealerClaimWorkflowTab;
    case 'CUSTOM':
    default:
      return CustomFlow.CustomWorkflowTab;
  }
}

/**
 * Get create request component for a flow type
 */
export function getCreateRequestComponent(flowType: RequestFlowType) {
  switch (flowType) {
    case 'DEALER_CLAIM':
      return DealerClaimFlow.ClaimManagementWizard;
    case 'CUSTOM':
    default:
      return CustomFlow.CustomCreateRequest;
  }
}

/**
 * Get RequestDetail screen component for a flow type
 * Each flow has its own complete RequestDetail screen
 */
export function getRequestDetailScreen(flowType: RequestFlowType) {
  switch (flowType) {
    case 'DEALER_CLAIM':
      return DealerClaimFlow.DealerClaimRequestDetail;
    case 'CUSTOM':
    default:
      return CustomFlow.CustomRequestDetail;
  }
}

/**
 * Get Requests Filters component for a user filter type
 * Each user type can have its own filter component
 * 
 * This allows for plug-and-play filter components:
 * - DEALER: Simplified filters (search + sort only)
 * - STANDARD: Full filters (search + status + priority + template + sort)
 * 
 * To add a new user filter type:
 * 1. Add the user filter type to UserFilterType in userFilterUtils.ts
 * 2. Create a filter component in the appropriate flow folder
 * 3. Export it from the flow's index.ts
 * 4. Add a case here to return it
 */
export function getRequestsFilters(userFilterType: UserFilterType) {
  switch (userFilterType) {
    case 'DEALER':
      return DealerClaimFlow.DealerRequestsFilters;
    case 'STANDARD':
    default:
      return CustomFlow.StandardRequestsFilters;
  }
}

/**
 * Get Closed Requests Filters component for a user filter type
 * Each user type can have its own filter component for closed requests
 * 
 * This allows for plug-and-play filter components:
 * - DEALER: Simplified filters (search + status + sort only, no priority or template)
 * - STANDARD: Full filters (search + priority + status + template + sort)
 * 
 * To add a new user filter type:
 * 1. Add the user filter type to UserFilterType in userFilterUtils.ts
 * 2. Create a closed requests filter component in the appropriate flow folder
 * 3. Export it from the flow's index.ts
 * 4. Add a case here to return it
 */
export function getClosedRequestsFilters(userFilterType: UserFilterType) {
  switch (userFilterType) {
    case 'DEALER':
      return DealerClaimFlow.DealerClosedRequestsFilters;
    case 'STANDARD':
    default:
      return CustomFlow.StandardClosedRequestsFilters;
  }
}

/**
 * Get User All Requests Filters component for a user filter type
 * Each user type can have its own filter component for user all requests
 * 
 * This allows for plug-and-play filter components:
 * - DEALER: Simplified filters (search + status + initiator + approver + date range, no priority/template/department/sla)
 * - STANDARD: Full filters (all filters including priority, template, department, and SLA compliance)
 * 
 * To add a new user filter type:
 * 1. Add the user filter type to UserFilterType in userFilterUtils.ts
 * 2. Create a user all requests filter component in the appropriate flow folder
 * 3. Export it from the flow's index.ts
 * 4. Add a case here to return it
 */
export function getUserAllRequestsFilters(userFilterType: UserFilterType) {
  switch (userFilterType) {
    case 'DEALER':
      return DealerClaimFlow.DealerUserAllRequestsFilters;
    case 'STANDARD':
    default:
      return CustomFlow.StandardUserAllRequestsFilters;
  }
}

// Re-export flow modules for direct access
export { CustomFlow, DealerClaimFlow, SharedComponents };
export type { RequestFlowType } from '@/utils/requestTypeUtils';
export type { UserFilterType } from '@/utils/userFilterUtils';
