import { queryParams, type RouteQueryOptions, type RouteDefinition, type RouteFormDefinition, applyUrlDefaults } from './../../../wayfinder'
/**
* @see \App\Http\Controllers\StandPhotoController::store
* @see app/Http/Controllers/StandPhotoController.php:15
* @route '/stands/{stand}/photos'
*/
export const store = (args: { stand: number | { id: number } } | [stand: number | { id: number } ] | number | { id: number }, options?: RouteQueryOptions): RouteDefinition<'post'> => ({
    url: store.url(args, options),
    method: 'post',
})

store.definition = {
    methods: ["post"],
    url: '/stands/{stand}/photos',
} satisfies RouteDefinition<["post"]>

/**
* @see \App\Http\Controllers\StandPhotoController::store
* @see app/Http/Controllers/StandPhotoController.php:15
* @route '/stands/{stand}/photos'
*/
store.url = (args: { stand: number | { id: number } } | [stand: number | { id: number } ] | number | { id: number }, options?: RouteQueryOptions) => {
    if (typeof args === 'string' || typeof args === 'number') {
        args = { stand: args }
    }

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

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

    args = applyUrlDefaults(args)

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

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

/**
* @see \App\Http\Controllers\StandPhotoController::store
* @see app/Http/Controllers/StandPhotoController.php:15
* @route '/stands/{stand}/photos'
*/
store.post = (args: { stand: number | { id: number } } | [stand: number | { id: number } ] | number | { id: number }, options?: RouteQueryOptions): RouteDefinition<'post'> => ({
    url: store.url(args, options),
    method: 'post',
})

/**
* @see \App\Http\Controllers\StandPhotoController::store
* @see app/Http/Controllers/StandPhotoController.php:15
* @route '/stands/{stand}/photos'
*/
const storeForm = (args: { stand: number | { id: number } } | [stand: number | { id: number } ] | number | { id: number }, options?: RouteQueryOptions): RouteFormDefinition<'post'> => ({
    action: store.url(args, options),
    method: 'post',
})

/**
* @see \App\Http\Controllers\StandPhotoController::store
* @see app/Http/Controllers/StandPhotoController.php:15
* @route '/stands/{stand}/photos'
*/
storeForm.post = (args: { stand: number | { id: number } } | [stand: number | { id: number } ] | number | { id: number }, options?: RouteQueryOptions): RouteFormDefinition<'post'> => ({
    action: store.url(args, options),
    method: 'post',
})

store.form = storeForm

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

export default photos