import { queryParams, type RouteQueryOptions, type RouteDefinition, type RouteFormDefinition, applyUrlDefaults } from './../../../wayfinder'
/**
* @see \App\Http\Controllers\Booking\AdminBookingController::store
* @see app/Http/Controllers/Booking/AdminBookingController.php:661
* @route '/admin/location-types'
*/
export const store = (options?: RouteQueryOptions): RouteDefinition<'post'> => ({
    url: store.url(options),
    method: 'post',
})

store.definition = {
    methods: ["post"],
    url: '/admin/location-types',
} satisfies RouteDefinition<["post"]>

/**
* @see \App\Http\Controllers\Booking\AdminBookingController::store
* @see app/Http/Controllers/Booking/AdminBookingController.php:661
* @route '/admin/location-types'
*/
store.url = (options?: RouteQueryOptions) => {
    return store.definition.url + queryParams(options)
}

/**
* @see \App\Http\Controllers\Booking\AdminBookingController::store
* @see app/Http/Controllers/Booking/AdminBookingController.php:661
* @route '/admin/location-types'
*/
store.post = (options?: RouteQueryOptions): RouteDefinition<'post'> => ({
    url: store.url(options),
    method: 'post',
})

/**
* @see \App\Http\Controllers\Booking\AdminBookingController::store
* @see app/Http/Controllers/Booking/AdminBookingController.php:661
* @route '/admin/location-types'
*/
const storeForm = (options?: RouteQueryOptions): RouteFormDefinition<'post'> => ({
    action: store.url(options),
    method: 'post',
})

/**
* @see \App\Http\Controllers\Booking\AdminBookingController::store
* @see app/Http/Controllers/Booking/AdminBookingController.php:661
* @route '/admin/location-types'
*/
storeForm.post = (options?: RouteQueryOptions): RouteFormDefinition<'post'> => ({
    action: store.url(options),
    method: 'post',
})

store.form = storeForm

/**
* @see \App\Http\Controllers\Booking\AdminBookingController::update
* @see app/Http/Controllers/Booking/AdminBookingController.php:683
* @route '/admin/location-types/{locationType}'
*/
export const update = (args: { locationType: number | { id: number } } | [locationType: number | { id: number } ] | number | { id: number }, options?: RouteQueryOptions): RouteDefinition<'patch'> => ({
    url: update.url(args, options),
    method: 'patch',
})

update.definition = {
    methods: ["patch"],
    url: '/admin/location-types/{locationType}',
} satisfies RouteDefinition<["patch"]>

/**
* @see \App\Http\Controllers\Booking\AdminBookingController::update
* @see app/Http/Controllers/Booking/AdminBookingController.php:683
* @route '/admin/location-types/{locationType}'
*/
update.url = (args: { locationType: number | { id: number } } | [locationType: number | { id: number } ] | number | { id: number }, options?: RouteQueryOptions) => {
    if (typeof args === 'string' || typeof args === 'number') {
        args = { locationType: args }
    }

    if (typeof args === 'object' && !Array.isArray(args) && 'id' in args) {
        args = { locationType: args.id }
    }

    if (Array.isArray(args)) {
        args = {
            locationType: args[0],
        }
    }

    args = applyUrlDefaults(args)

    const parsedArgs = {
        locationType: typeof args.locationType === 'object'
        ? args.locationType.id
        : args.locationType,
    }

    return update.definition.url
            .replace('{locationType}', parsedArgs.locationType.toString())
            .replace(/\/+$/, '') + queryParams(options)
}

/**
* @see \App\Http\Controllers\Booking\AdminBookingController::update
* @see app/Http/Controllers/Booking/AdminBookingController.php:683
* @route '/admin/location-types/{locationType}'
*/
update.patch = (args: { locationType: number | { id: number } } | [locationType: number | { id: number } ] | number | { id: number }, options?: RouteQueryOptions): RouteDefinition<'patch'> => ({
    url: update.url(args, options),
    method: 'patch',
})

/**
* @see \App\Http\Controllers\Booking\AdminBookingController::update
* @see app/Http/Controllers/Booking/AdminBookingController.php:683
* @route '/admin/location-types/{locationType}'
*/
const updateForm = (args: { locationType: number | { id: number } } | [locationType: number | { id: number } ] | number | { id: number }, options?: RouteQueryOptions): RouteFormDefinition<'post'> => ({
    action: update.url(args, {
        [options?.mergeQuery ? 'mergeQuery' : 'query']: {
            _method: 'PATCH',
            ...(options?.query ?? options?.mergeQuery ?? {}),
        }
    }),
    method: 'post',
})

/**
* @see \App\Http\Controllers\Booking\AdminBookingController::update
* @see app/Http/Controllers/Booking/AdminBookingController.php:683
* @route '/admin/location-types/{locationType}'
*/
updateForm.patch = (args: { locationType: number | { id: number } } | [locationType: number | { id: number } ] | number | { id: number }, options?: RouteQueryOptions): RouteFormDefinition<'post'> => ({
    action: update.url(args, {
        [options?.mergeQuery ? 'mergeQuery' : 'query']: {
            _method: 'PATCH',
            ...(options?.query ?? options?.mergeQuery ?? {}),
        }
    }),
    method: 'post',
})

update.form = updateForm

/**
* @see \App\Http\Controllers\Booking\AdminBookingController::destroy
* @see app/Http/Controllers/Booking/AdminBookingController.php:699
* @route '/admin/location-types/{locationType}'
*/
export const destroy = (args: { locationType: number | { id: number } } | [locationType: number | { id: number } ] | number | { id: number }, options?: RouteQueryOptions): RouteDefinition<'delete'> => ({
    url: destroy.url(args, options),
    method: 'delete',
})

destroy.definition = {
    methods: ["delete"],
    url: '/admin/location-types/{locationType}',
} satisfies RouteDefinition<["delete"]>

/**
* @see \App\Http\Controllers\Booking\AdminBookingController::destroy
* @see app/Http/Controllers/Booking/AdminBookingController.php:699
* @route '/admin/location-types/{locationType}'
*/
destroy.url = (args: { locationType: number | { id: number } } | [locationType: number | { id: number } ] | number | { id: number }, options?: RouteQueryOptions) => {
    if (typeof args === 'string' || typeof args === 'number') {
        args = { locationType: args }
    }

    if (typeof args === 'object' && !Array.isArray(args) && 'id' in args) {
        args = { locationType: args.id }
    }

    if (Array.isArray(args)) {
        args = {
            locationType: args[0],
        }
    }

    args = applyUrlDefaults(args)

    const parsedArgs = {
        locationType: typeof args.locationType === 'object'
        ? args.locationType.id
        : args.locationType,
    }

    return destroy.definition.url
            .replace('{locationType}', parsedArgs.locationType.toString())
            .replace(/\/+$/, '') + queryParams(options)
}

/**
* @see \App\Http\Controllers\Booking\AdminBookingController::destroy
* @see app/Http/Controllers/Booking/AdminBookingController.php:699
* @route '/admin/location-types/{locationType}'
*/
destroy.delete = (args: { locationType: number | { id: number } } | [locationType: number | { id: number } ] | number | { id: number }, options?: RouteQueryOptions): RouteDefinition<'delete'> => ({
    url: destroy.url(args, options),
    method: 'delete',
})

/**
* @see \App\Http\Controllers\Booking\AdminBookingController::destroy
* @see app/Http/Controllers/Booking/AdminBookingController.php:699
* @route '/admin/location-types/{locationType}'
*/
const destroyForm = (args: { locationType: number | { id: number } } | [locationType: number | { id: number } ] | number | { id: number }, options?: RouteQueryOptions): RouteFormDefinition<'post'> => ({
    action: destroy.url(args, {
        [options?.mergeQuery ? 'mergeQuery' : 'query']: {
            _method: 'DELETE',
            ...(options?.query ?? options?.mergeQuery ?? {}),
        }
    }),
    method: 'post',
})

/**
* @see \App\Http\Controllers\Booking\AdminBookingController::destroy
* @see app/Http/Controllers/Booking/AdminBookingController.php:699
* @route '/admin/location-types/{locationType}'
*/
destroyForm.delete = (args: { locationType: number | { id: number } } | [locationType: number | { id: number } ] | number | { id: number }, options?: RouteQueryOptions): RouteFormDefinition<'post'> => ({
    action: destroy.url(args, {
        [options?.mergeQuery ? 'mergeQuery' : 'query']: {
            _method: 'DELETE',
            ...(options?.query ?? options?.mergeQuery ?? {}),
        }
    }),
    method: 'post',
})

destroy.form = destroyForm

const locationTypes = {
    store: Object.assign(store, store),
    update: Object.assign(update, update),
    destroy: Object.assign(destroy, destroy),
}

export default locationTypes