import { queryParams, type RouteQueryOptions, type RouteDefinition, type RouteFormDefinition, applyUrlDefaults } from './../../../../wayfinder'
/**
* @see \App\Http\Controllers\Admin\InPersonAuctionController::store
* @see app/Http/Controllers/Admin/InPersonAuctionController.php:155
* @route '/in-person-auctions/{auction}/messages'
*/
export const store = (args: { auction: number | { id: number } } | [auction: number | { id: number } ] | number | { id: number }, options?: RouteQueryOptions): RouteDefinition<'post'> => ({
    url: store.url(args, options),
    method: 'post',
})

store.definition = {
    methods: ["post"],
    url: '/in-person-auctions/{auction}/messages',
} satisfies RouteDefinition<["post"]>

/**
* @see \App\Http\Controllers\Admin\InPersonAuctionController::store
* @see app/Http/Controllers/Admin/InPersonAuctionController.php:155
* @route '/in-person-auctions/{auction}/messages'
*/
store.url = (args: { auction: number | { id: number } } | [auction: number | { id: number } ] | number | { id: number }, options?: RouteQueryOptions) => {
    if (typeof args === 'string' || typeof args === 'number') {
        args = { auction: args }
    }

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

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

    args = applyUrlDefaults(args)

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

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

/**
* @see \App\Http\Controllers\Admin\InPersonAuctionController::store
* @see app/Http/Controllers/Admin/InPersonAuctionController.php:155
* @route '/in-person-auctions/{auction}/messages'
*/
store.post = (args: { auction: number | { id: number } } | [auction: number | { id: number } ] | number | { id: number }, options?: RouteQueryOptions): RouteDefinition<'post'> => ({
    url: store.url(args, options),
    method: 'post',
})

/**
* @see \App\Http\Controllers\Admin\InPersonAuctionController::store
* @see app/Http/Controllers/Admin/InPersonAuctionController.php:155
* @route '/in-person-auctions/{auction}/messages'
*/
const storeForm = (args: { auction: number | { id: number } } | [auction: number | { id: number } ] | number | { id: number }, options?: RouteQueryOptions): RouteFormDefinition<'post'> => ({
    action: store.url(args, options),
    method: 'post',
})

/**
* @see \App\Http\Controllers\Admin\InPersonAuctionController::store
* @see app/Http/Controllers/Admin/InPersonAuctionController.php:155
* @route '/in-person-auctions/{auction}/messages'
*/
storeForm.post = (args: { auction: number | { id: number } } | [auction: number | { id: number } ] | number | { id: number }, options?: RouteQueryOptions): RouteFormDefinition<'post'> => ({
    action: store.url(args, options),
    method: 'post',
})

store.form = storeForm

const messages = {
    store: Object.assign(store, store),
}

export default messages