import { queryParams, type RouteQueryOptions, type RouteDefinition, type RouteFormDefinition, applyUrlDefaults } from './../../../wayfinder'
/**
* @see \App\Http\Controllers\Api\V1\DispatchController::move
* @see app/Http/Controllers/Api/V1/DispatchController.php:408
* @route '/dispatch/cards/{type}/{id}/status'
*/
export const move = (args: { type: string | number, id: string | number } | [type: string | number, id: string | number ], options?: RouteQueryOptions): RouteDefinition<'patch'> => ({
    url: move.url(args, options),
    method: 'patch',
})

move.definition = {
    methods: ["patch"],
    url: '/dispatch/cards/{type}/{id}/status',
} satisfies RouteDefinition<["patch"]>

/**
* @see \App\Http\Controllers\Api\V1\DispatchController::move
* @see app/Http/Controllers/Api/V1/DispatchController.php:408
* @route '/dispatch/cards/{type}/{id}/status'
*/
move.url = (args: { type: string | number, id: string | number } | [type: string | number, id: string | number ], options?: RouteQueryOptions) => {
    if (Array.isArray(args)) {
        args = {
            type: args[0],
            id: args[1],
        }
    }

    args = applyUrlDefaults(args)

    const parsedArgs = {
        type: args.type,
        id: args.id,
    }

    return move.definition.url
            .replace('{type}', parsedArgs.type.toString())
            .replace('{id}', parsedArgs.id.toString())
            .replace(/\/+$/, '') + queryParams(options)
}

/**
* @see \App\Http\Controllers\Api\V1\DispatchController::move
* @see app/Http/Controllers/Api/V1/DispatchController.php:408
* @route '/dispatch/cards/{type}/{id}/status'
*/
move.patch = (args: { type: string | number, id: string | number } | [type: string | number, id: string | number ], options?: RouteQueryOptions): RouteDefinition<'patch'> => ({
    url: move.url(args, options),
    method: 'patch',
})

/**
* @see \App\Http\Controllers\Api\V1\DispatchController::move
* @see app/Http/Controllers/Api/V1/DispatchController.php:408
* @route '/dispatch/cards/{type}/{id}/status'
*/
const moveForm = (args: { type: string | number, id: string | number } | [type: string | number, id: string | number ], options?: RouteQueryOptions): RouteFormDefinition<'post'> => ({
    action: move.url(args, {
        [options?.mergeQuery ? 'mergeQuery' : 'query']: {
            _method: 'PATCH',
            ...(options?.query ?? options?.mergeQuery ?? {}),
        }
    }),
    method: 'post',
})

/**
* @see \App\Http\Controllers\Api\V1\DispatchController::move
* @see app/Http/Controllers/Api/V1/DispatchController.php:408
* @route '/dispatch/cards/{type}/{id}/status'
*/
moveForm.patch = (args: { type: string | number, id: string | number } | [type: string | number, id: string | number ], options?: RouteQueryOptions): RouteFormDefinition<'post'> => ({
    action: move.url(args, {
        [options?.mergeQuery ? 'mergeQuery' : 'query']: {
            _method: 'PATCH',
            ...(options?.query ?? options?.mergeQuery ?? {}),
        }
    }),
    method: 'post',
})

move.form = moveForm

/**
* @see \App\Http\Controllers\Api\V1\DispatchController::reschedule
* @see app/Http/Controllers/Api/V1/DispatchController.php:455
* @route '/dispatch/cards/{type}/{id}/schedule'
*/
export const reschedule = (args: { type: string | number, id: string | number } | [type: string | number, id: string | number ], options?: RouteQueryOptions): RouteDefinition<'patch'> => ({
    url: reschedule.url(args, options),
    method: 'patch',
})

reschedule.definition = {
    methods: ["patch"],
    url: '/dispatch/cards/{type}/{id}/schedule',
} satisfies RouteDefinition<["patch"]>

/**
* @see \App\Http\Controllers\Api\V1\DispatchController::reschedule
* @see app/Http/Controllers/Api/V1/DispatchController.php:455
* @route '/dispatch/cards/{type}/{id}/schedule'
*/
reschedule.url = (args: { type: string | number, id: string | number } | [type: string | number, id: string | number ], options?: RouteQueryOptions) => {
    if (Array.isArray(args)) {
        args = {
            type: args[0],
            id: args[1],
        }
    }

    args = applyUrlDefaults(args)

    const parsedArgs = {
        type: args.type,
        id: args.id,
    }

    return reschedule.definition.url
            .replace('{type}', parsedArgs.type.toString())
            .replace('{id}', parsedArgs.id.toString())
            .replace(/\/+$/, '') + queryParams(options)
}

/**
* @see \App\Http\Controllers\Api\V1\DispatchController::reschedule
* @see app/Http/Controllers/Api/V1/DispatchController.php:455
* @route '/dispatch/cards/{type}/{id}/schedule'
*/
reschedule.patch = (args: { type: string | number, id: string | number } | [type: string | number, id: string | number ], options?: RouteQueryOptions): RouteDefinition<'patch'> => ({
    url: reschedule.url(args, options),
    method: 'patch',
})

/**
* @see \App\Http\Controllers\Api\V1\DispatchController::reschedule
* @see app/Http/Controllers/Api/V1/DispatchController.php:455
* @route '/dispatch/cards/{type}/{id}/schedule'
*/
const rescheduleForm = (args: { type: string | number, id: string | number } | [type: string | number, id: string | number ], options?: RouteQueryOptions): RouteFormDefinition<'post'> => ({
    action: reschedule.url(args, {
        [options?.mergeQuery ? 'mergeQuery' : 'query']: {
            _method: 'PATCH',
            ...(options?.query ?? options?.mergeQuery ?? {}),
        }
    }),
    method: 'post',
})

/**
* @see \App\Http\Controllers\Api\V1\DispatchController::reschedule
* @see app/Http/Controllers/Api/V1/DispatchController.php:455
* @route '/dispatch/cards/{type}/{id}/schedule'
*/
rescheduleForm.patch = (args: { type: string | number, id: string | number } | [type: string | number, id: string | number ], options?: RouteQueryOptions): RouteFormDefinition<'post'> => ({
    action: reschedule.url(args, {
        [options?.mergeQuery ? 'mergeQuery' : 'query']: {
            _method: 'PATCH',
            ...(options?.query ?? options?.mergeQuery ?? {}),
        }
    }),
    method: 'post',
})

reschedule.form = rescheduleForm

const cards = {
    move: Object.assign(move, move),
    reschedule: Object.assign(reschedule, reschedule),
}

export default cards