export const workflowEntrainmentConfiguration = {
  workflowId: 'WF_ENTRAINMENT_V2',
  workflowName: 'Entrainment Program Registration Workflow',
  programType: 'PT_ENTRAINMENT',
  workflowVersion: '2.0.0',
  lifecycleStatus: 'ACTIVE',
  description:
    'Entrainment program registration workflow with 3 stages (Basic Details, Payment, Travel) - No edit after submission',
  lastUpdated: '2026-02-19T00:00:00Z',
  registrationRules: {
    criteria: [
      { field: 'basicDetailsFilled', operator: 'EQUALS', value: 'completed' },
      {
        field: 'paymentStatus',
        operator: 'IN',
        value: ['online_completed', 'offline_completed', 'completed'],
      },
      { field: 'travelInfoStatus', operator: 'EQUALS', value: 'completed' },
      { field: 'travelPlanStatus', operator: 'EQUALS', value: 'completed' },
    ],
    message: 'Registration is completed when all criteria are fulfilled.',
  },
  initialStage: {
    stageKey: 'REGISTRATION',
    stageName: 'Basic Details',
    isOptional: true,
    description: 'Save progress and resume later',
  },
  stages: [
    {
      stageId: 'registration',
      stageKey: 'REGISTRATION',
      stageName: 'Basic Details',
      stageOrder: 1,
      stageCategory: 'FORM',
      description: 'Seeker fills and submits basic registration details',
      prerequisiteRulesConfig: {
        requiresAuth: true,
        requiredStages: [],
        conditions: [
          {
            roles: ['ROLE_VIEWER', 'ROLE_ADMIN', 'ROLE_SHOBA', 'ROLE_RELATIONAL_MANAGER'],
            condition: null,
            message: 'Login required to register',
          },
        ],
      },
      executionRulesConfig: {
        sections: [
          {
            sectionKey: 'FS_BASICDETAILS',
            permissions: {
              create: [{ roles: ['ROLE_VIEWER'], condition: null }],
              read: [{ roles: ['ALL'], condition: null }],
              update: [
                {
                  roles: ['ROLE_VIEWER'],
                  condition: {
                    operator: 'AND',
                    conditions: [
                      { field: 'basicDetailsFilled', operator: 'NOT_EQUALS', value: 'completed' },
                      { field: 'registrationStatus', operator: 'NOT_IN', value: ['waitlisted'] },
                    ],
                  },
                },
                {
                  roles: ['ROLE_ADMIN', 'ROLE_SHOBA', 'ROLE_RELATIONAL_MANAGER'],
                  condition: null,
                },
              ],
              delete: [{ roles: [], condition: null }],
            },
          },
        ],
      },
      actionButtons: [
        {
          actionKey: 'CANCEL',
          label: 'Cancel',
          type: 'secondary',
          icon: 'close',
          apiKey: null,
          permissions: [
            {
              roles: ['ROLE_ADMIN', 'ROLE_SHOBA', 'ROLE_RELATIONAL_MANAGER', 'ROLE_VIEWER'],
              condition: null,
            },
          ],
          onSuccess: [
            {
              roles: ['ROLE_ADMIN', 'ROLE_SHOBA', 'ROLE_RELATIONAL_MANAGER', 'ROLE_VIEWER'],
              showToast: false,
              showSuccessScreen: false,
            },
          ],
        },
        {
          actionKey: 'SUBMIT_REGISTRATION',
          label: 'Submit',
          type: 'primary',
          icon: 'send',
          apiKey: 'SUBMIT_REGISTRATION',
          permissions: [
            {
              roles: ['ROLE_VIEWER'],
              condition: {
                field: 'basicDetailsFilled',
                operator: 'NOT_EQUALS',
                value: 'completed',
              },
            },
          ],
          onSuccess: [
            {
              roles: ['ROLE_VIEWER'],
              showToast: true,
              toast: {
                message: 'Registration submitted successfully!',
                type: 'success',
              },
              showSuccessScreen: true,
              successScreen: {
                title: 'Registration Submitted!',
                message:
                  'Your registration has been submitted successfully. Please proceed with payment if you are not waitlisted.',
                icon: 'check_circle',
                actions: [
                  {
                    actionKey: 'HOME',
                    label: 'Go to Home',
                    type: 'primary',
                    icon: 'home',
                    apiKey: null,
                    condition: null,
                  },
                ],
              },
            },
          ],
        },
      ],
      nextPossibleStages: [],
      completionActionsConfig: {
        conditional: true,
        conditions: [
          {
            when: {
              field: 'basicDetailsFilled',
              operator: 'EQUALS',
              value: 'completed',
            },
            then: {
              stageStatus: 'completed',
              markStageComplete: true,
            },
          },
        ],
      },
    },
    {
      stageId: 'payment',
      stageKey: 'PAYMENT',
      stageName: 'Payment',
      stageOrder: 2,
      stageCategory: 'FORM',
      description: 'Process payment (online/offline)',
      prerequisiteRulesConfig: {
        requiresAuth: true,
        requiredStages: ['BASICDETAILS'],
        conditions: [
          {
            roles: ['ROLE_VIEWER', 'ROLE_ADMIN', 'ROLE_RELATIONAL_MANAGER'],
            condition: {
              operator: 'AND',
              conditions: [
                { field: 'basicDetailsFilled', operator: 'EQUALS', value: 'completed' },
                { field: 'isWaitlisted', operator: 'EQUALS', value: false },
                { field: 'registrationStatus', operator: 'NOT_IN', value: ['waitlisted'] },
              ],
            },
            message: 'Basic details must be completed and not waitlisted',
          },
        ],
      },
      executionRulesConfig: {
        sections: [
          {
            sectionKey: 'FS_PAYMENTINVOICE',
            permissions: {
              create: [
                {
                  roles: ['ROLE_VIEWER'],
                  condition: {
                    operator: 'AND',
                    conditions: [
                      { field: 'basicDetailsFilled', operator: 'EQUALS', value: 'completed' },
                      { field: 'isWaitlisted', operator: 'EQUALS', value: false },
                      { field: 'registrationStatus', operator: 'NOT_IN', value: ['waitlisted'] },
                    ],
                  },
                },
              ],
              read: [{ roles: ['ALL'], condition: null }],
              update: [
                {
                  roles: ['ROLE_ADMIN', 'ROLE_RELATIONAL_MANAGER'],
                  condition: null,
                },
              ],
              delete: [{ roles: [], condition: null }],
            },
          },
        ],
      },
      actionButtons: [
        {
          actionKey: 'CANCEL',
          label: 'Cancel',
          type: 'secondary',
          icon: 'close',
          apiKey: null,
          permissions: [
            {
              roles: ['ROLE_ADMIN', 'ROLE_RELATIONAL_MANAGER', 'ROLE_VIEWER'],
              condition: null,
            },
          ],
          onSuccess: [
            {
              roles: ['ROLE_ADMIN', 'ROLE_RELATIONAL_MANAGER', 'ROLE_VIEWER'],
              showToast: false,
              showSuccessScreen: false,
            },
          ],
        },
        {
          actionKey: 'SUBMIT_PAYMENT',
          label: 'submit',
          type: 'primary',
          icon: 'payment',
          apiKey: 'SUBMIT_PAYMENT',
          permissions: [
            {
              roles: ['ROLE_VIEWER'],
              condition: {
                operator: 'AND',
                conditions: [
                  { field: 'basicDetailsFilled', operator: 'EQUALS', value: 'completed' },
                  { field: 'isWaitlisted', operator: 'EQUALS', value: false },
                  { field: 'registrationStatus', operator: 'NOT_IN', value: ['waitlisted'] },
                ],
              },
            },
          ],
          onSuccess: [
            {
              roles: ['ROLE_VIEWER'],
              showToast: true,
              toast: {
                message: 'Payment submitted successfully!',
                type: 'success',
              },
              showSuccessScreen: true,
              successScreen: {
                title: 'Payment Completed!',
                message:
                  'Your payment has been completed successfully. You can proceed with travel details once approved.',
                icon: 'check_circle',
                actions: [
                  {
                    actionKey: 'HOME',
                    label: 'home',
                    type: 'secondary',
                    icon: 'home',
                    apiKey: null,
                    condition: null,
                  },
                ],
              },
            },
          ],
        },
      ],
      nextPossibleStages: [],
      completionActionsConfig: {
        conditional: true,
        conditions: [
          {
            when: {
              field: 'paymentStatus',
              operator: 'IN',
              value: ['online_completed', 'offline_completed', 'completed'],
            },
            then: {
              stageStatus: 'completed',
              markStageComplete: true,
            },
          },
        ],
      },
    },
    {
      stageId: 'travel',
      stageKey: 'TRAVEL',
      stageName: 'Travel',
      stageOrder: 3,
      stageCategory: 'FORM',
      description: 'Submit travel information and plan',
      prerequisiteRulesConfig: {
        requiresAuth: true,
        requiredStages: ['BASICDETAILS', 'PAYMENT'],
        conditions: [
          {
            roles: ['ROLE_VIEWER', 'ROLE_ADMIN', 'ROLE_RELATIONAL_MANAGER'],
            condition: {
              operator: 'AND',
              conditions: [
                {
                  field: 'paymentStatus',
                  operator: 'IN',
                  value: ['online_completed', 'offline_completed', 'completed'],
                },
                { field: 'isWaitlisted', operator: 'EQUALS', value: false },
                { field: 'registrationStatus', operator: 'NOT_IN', value: ['waitlisted'] },
                { field: 'approvalStatus', operator: 'EQUALS', value: 'approved' },
              ],
            },
            message: 'Payment must be completed, not waitlisted, and approval status must be approved',
          },
        ],
      },
      executionRulesConfig: {
        sections: [
          {
            sectionKey: 'FS_TRAVELPLAN',
            permissions: {
              create: [
                {
                  roles: ['ROLE_VIEWER'],
                  condition: {
                    operator: 'AND',
                    conditions: [
                      {
                        field: 'paymentStatus',
                        operator: 'IN',
                        value: ['online_completed', 'offline_completed', 'completed'],
                      },
                      { field: 'isWaitlisted', operator: 'EQUALS', value: false },
                      { field: 'approvalStatus', operator: 'EQUALS', value: 'approved' },
                      { field: 'registrationStatus', operator: 'NOT_IN', value: ['waitlisted'] },
                    ],
                  },
                },
              ],
              read: [{ roles: ['ALL'], condition: null }],
              update: [
                {
                  roles: ['ROLE_ADMIN', 'ROLE_RELATIONAL_MANAGER'],
                  condition: null,
                },
              ],
              delete: [{ roles: [], condition: null }],
            },
          }
        ],
      },
      actionButtons: [
        {
          actionKey: 'CANCEL',
          label: 'Cancel',
          type: 'secondary',
          icon: 'close',
          apiKey: null,
          permissions: [
            {
              roles: ['ROLE_ADMIN', 'ROLE_RELATIONAL_MANAGER', 'ROLE_VIEWER'],
              condition: null,
            },
          ],
          onSuccess: [
            {
              roles: ['ROLE_ADMIN', 'ROLE_RELATIONAL_MANAGER', 'ROLE_VIEWER'],
              showToast: false,
              showSuccessScreen: false,
            },
          ],
        },
        {
          actionKey: 'SUBMIT_TRAVEL',
          label: 'submit',
          type: 'primary',
          icon: 'send',
          apiKey: 'SUBMIT_TRAVEL',
          permissions: [
            {
              roles: ['ROLE_VIEWER'],
              condition: {
                operator: 'AND',
                conditions: [
                  {
                    field: 'paymentStatus',
                    operator: 'IN',
                    value: ['online_completed', 'offline_completed', 'completed'],
                  },
                  { field: 'isWaitlisted', operator: 'EQUALS', value: false },
                  { field: 'registrationStatus', operator: 'NOT_IN', value: ['waitlisted'] },
                  { field: 'approvalStatus', operator: 'EQUALS', value: 'approved' },
                ],
              },
            },
          ],
          onSuccess: [
            {
              roles: ['ROLE_VIEWER'],
              showToast: true,
              toast: {
                message: 'Travel details submitted successfully!',
                type: 'success',
              },
              showSuccessScreen: true,
              successScreen: {
                title: 'Registration Complete!',
                message:
                  'Your registration for the Entrainment Program is now complete. We look forward to seeing you!',
                icon: 'check_circle',
                actions: [
                  {
                    actionKey: 'HOME',
                    label: 'home',
                    type: 'primary',
                    icon: 'home',
                    apiKey: null,
                    condition: null,
                  },
                ],
              },
            },
          ],
        },
      ],
      nextPossibleStages: [],
      completionActionsConfig: {
        conditional: true,
        conditions: [
          {
            when: {
              operator: 'AND',
              conditions: [
                { field: 'travelInfoStatus', operator: 'EQUALS', value: 'completed' },
                { field: 'travelPlanStatus', operator: 'EQUALS', value: 'completed' },
              ],
            },
            then: {
              stageStatus: 'completed',
              markStageComplete: true,
            },
          },
        ],
      },
    },
  ],
  independentActions: {},
};
