import { queryParams, type RouteQueryOptions, type RouteDefinition, type RouteFormDefinition, applyUrlDefaults, validateParameters } from './../../../../wayfinder'
/**
* @see \App\Http\Controllers\QueriesController::publicForm
* @see app/Http/Controllers/QueriesController.php:19
* @route '/submit-query/{company?}'
*/
export const publicForm = (args?: { company?: string | number | { id: string | number } } | [company: string | number | { id: string | number } ] | string | number | { id: string | number }, options?: RouteQueryOptions): RouteDefinition<'get'> => ({
    url: publicForm.url(args, options),
    method: 'get',
})

publicForm.definition = {
    methods: ["get","head"],
    url: '/submit-query/{company?}',
} satisfies RouteDefinition<["get","head"]>

/**
* @see \App\Http\Controllers\QueriesController::publicForm
* @see app/Http/Controllers/QueriesController.php:19
* @route '/submit-query/{company?}'
*/
publicForm.url = (args?: { company?: string | number | { id: string | number } } | [company: string | number | { id: string | number } ] | string | number | { id: string | number }, options?: RouteQueryOptions) => {
    if (typeof args === 'string' || typeof args === 'number') {
        args = { company: args }
    }

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

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

    args = applyUrlDefaults(args)

    validateParameters(args, [
        "company",
    ])

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

    return publicForm.definition.url
            .replace('{company?}', parsedArgs.company?.toString() ?? '')
            .replace(/\/+$/, '') + queryParams(options)
}

/**
* @see \App\Http\Controllers\QueriesController::publicForm
* @see app/Http/Controllers/QueriesController.php:19
* @route '/submit-query/{company?}'
*/
publicForm.get = (args?: { company?: string | number | { id: string | number } } | [company: string | number | { id: string | number } ] | string | number | { id: string | number }, options?: RouteQueryOptions): RouteDefinition<'get'> => ({
    url: publicForm.url(args, options),
    method: 'get',
})

/**
* @see \App\Http\Controllers\QueriesController::publicForm
* @see app/Http/Controllers/QueriesController.php:19
* @route '/submit-query/{company?}'
*/
publicForm.head = (args?: { company?: string | number | { id: string | number } } | [company: string | number | { id: string | number } ] | string | number | { id: string | number }, options?: RouteQueryOptions): RouteDefinition<'head'> => ({
    url: publicForm.url(args, options),
    method: 'head',
})

/**
* @see \App\Http\Controllers\QueriesController::publicForm
* @see app/Http/Controllers/QueriesController.php:19
* @route '/submit-query/{company?}'
*/
const publicFormForm = (args?: { company?: string | number | { id: string | number } } | [company: string | number | { id: string | number } ] | string | number | { id: string | number }, options?: RouteQueryOptions): RouteFormDefinition<'get'> => ({
    action: publicForm.url(args, options),
    method: 'get',
})

/**
* @see \App\Http\Controllers\QueriesController::publicForm
* @see app/Http/Controllers/QueriesController.php:19
* @route '/submit-query/{company?}'
*/
publicFormForm.get = (args?: { company?: string | number | { id: string | number } } | [company: string | number | { id: string | number } ] | string | number | { id: string | number }, options?: RouteQueryOptions): RouteFormDefinition<'get'> => ({
    action: publicForm.url(args, options),
    method: 'get',
})

/**
* @see \App\Http\Controllers\QueriesController::publicForm
* @see app/Http/Controllers/QueriesController.php:19
* @route '/submit-query/{company?}'
*/
publicFormForm.head = (args?: { company?: string | number | { id: string | number } } | [company: string | number | { id: string | number } ] | string | number | { id: string | number }, options?: RouteQueryOptions): RouteFormDefinition<'get'> => ({
    action: publicForm.url(args, {
        [options?.mergeQuery ? 'mergeQuery' : 'query']: {
            _method: 'HEAD',
            ...(options?.query ?? options?.mergeQuery ?? {}),
        }
    }),
    method: 'get',
})

publicForm.form = publicFormForm

/**
* @see \App\Http\Controllers\QueriesController::publicStore
* @see app/Http/Controllers/QueriesController.php:37
* @route '/submit-query'
*/
export const publicStore = (options?: RouteQueryOptions): RouteDefinition<'post'> => ({
    url: publicStore.url(options),
    method: 'post',
})

publicStore.definition = {
    methods: ["post"],
    url: '/submit-query',
} satisfies RouteDefinition<["post"]>

/**
* @see \App\Http\Controllers\QueriesController::publicStore
* @see app/Http/Controllers/QueriesController.php:37
* @route '/submit-query'
*/
publicStore.url = (options?: RouteQueryOptions) => {
    return publicStore.definition.url + queryParams(options)
}

/**
* @see \App\Http\Controllers\QueriesController::publicStore
* @see app/Http/Controllers/QueriesController.php:37
* @route '/submit-query'
*/
publicStore.post = (options?: RouteQueryOptions): RouteDefinition<'post'> => ({
    url: publicStore.url(options),
    method: 'post',
})

/**
* @see \App\Http\Controllers\QueriesController::publicStore
* @see app/Http/Controllers/QueriesController.php:37
* @route '/submit-query'
*/
const publicStoreForm = (options?: RouteQueryOptions): RouteFormDefinition<'post'> => ({
    action: publicStore.url(options),
    method: 'post',
})

/**
* @see \App\Http\Controllers\QueriesController::publicStore
* @see app/Http/Controllers/QueriesController.php:37
* @route '/submit-query'
*/
publicStoreForm.post = (options?: RouteQueryOptions): RouteFormDefinition<'post'> => ({
    action: publicStore.url(options),
    method: 'post',
})

publicStore.form = publicStoreForm

/**
* @see \App\Http\Controllers\QueriesController::index
* @see app/Http/Controllers/QueriesController.php:83
* @route '/queries'
*/
export const index = (options?: RouteQueryOptions): RouteDefinition<'get'> => ({
    url: index.url(options),
    method: 'get',
})

index.definition = {
    methods: ["get","head"],
    url: '/queries',
} satisfies RouteDefinition<["get","head"]>

/**
* @see \App\Http\Controllers\QueriesController::index
* @see app/Http/Controllers/QueriesController.php:83
* @route '/queries'
*/
index.url = (options?: RouteQueryOptions) => {
    return index.definition.url + queryParams(options)
}

/**
* @see \App\Http\Controllers\QueriesController::index
* @see app/Http/Controllers/QueriesController.php:83
* @route '/queries'
*/
index.get = (options?: RouteQueryOptions): RouteDefinition<'get'> => ({
    url: index.url(options),
    method: 'get',
})

/**
* @see \App\Http\Controllers\QueriesController::index
* @see app/Http/Controllers/QueriesController.php:83
* @route '/queries'
*/
index.head = (options?: RouteQueryOptions): RouteDefinition<'head'> => ({
    url: index.url(options),
    method: 'head',
})

/**
* @see \App\Http\Controllers\QueriesController::index
* @see app/Http/Controllers/QueriesController.php:83
* @route '/queries'
*/
const indexForm = (options?: RouteQueryOptions): RouteFormDefinition<'get'> => ({
    action: index.url(options),
    method: 'get',
})

/**
* @see \App\Http\Controllers\QueriesController::index
* @see app/Http/Controllers/QueriesController.php:83
* @route '/queries'
*/
indexForm.get = (options?: RouteQueryOptions): RouteFormDefinition<'get'> => ({
    action: index.url(options),
    method: 'get',
})

/**
* @see \App\Http\Controllers\QueriesController::index
* @see app/Http/Controllers/QueriesController.php:83
* @route '/queries'
*/
indexForm.head = (options?: RouteQueryOptions): RouteFormDefinition<'get'> => ({
    action: index.url({
        [options?.mergeQuery ? 'mergeQuery' : 'query']: {
            _method: 'HEAD',
            ...(options?.query ?? options?.mergeQuery ?? {}),
        }
    }),
    method: 'get',
})

index.form = indexForm

/**
* @see \App\Http\Controllers\QueriesController::show
* @see app/Http/Controllers/QueriesController.php:138
* @route '/queries/{query}'
*/
export const show = (args: { query: string | number | { id: string | number } } | [query: string | number | { id: string | number } ] | string | number | { id: string | number }, options?: RouteQueryOptions): RouteDefinition<'get'> => ({
    url: show.url(args, options),
    method: 'get',
})

show.definition = {
    methods: ["get","head"],
    url: '/queries/{query}',
} satisfies RouteDefinition<["get","head"]>

/**
* @see \App\Http\Controllers\QueriesController::show
* @see app/Http/Controllers/QueriesController.php:138
* @route '/queries/{query}'
*/
show.url = (args: { query: string | number | { id: string | number } } | [query: string | number | { id: string | number } ] | string | number | { id: string | number }, options?: RouteQueryOptions) => {
    if (typeof args === 'string' || typeof args === 'number') {
        args = { query: args }
    }

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

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

    args = applyUrlDefaults(args)

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

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

/**
* @see \App\Http\Controllers\QueriesController::show
* @see app/Http/Controllers/QueriesController.php:138
* @route '/queries/{query}'
*/
show.get = (args: { query: string | number | { id: string | number } } | [query: string | number | { id: string | number } ] | string | number | { id: string | number }, options?: RouteQueryOptions): RouteDefinition<'get'> => ({
    url: show.url(args, options),
    method: 'get',
})

/**
* @see \App\Http\Controllers\QueriesController::show
* @see app/Http/Controllers/QueriesController.php:138
* @route '/queries/{query}'
*/
show.head = (args: { query: string | number | { id: string | number } } | [query: string | number | { id: string | number } ] | string | number | { id: string | number }, options?: RouteQueryOptions): RouteDefinition<'head'> => ({
    url: show.url(args, options),
    method: 'head',
})

/**
* @see \App\Http\Controllers\QueriesController::show
* @see app/Http/Controllers/QueriesController.php:138
* @route '/queries/{query}'
*/
const showForm = (args: { query: string | number | { id: string | number } } | [query: string | number | { id: string | number } ] | string | number | { id: string | number }, options?: RouteQueryOptions): RouteFormDefinition<'get'> => ({
    action: show.url(args, options),
    method: 'get',
})

/**
* @see \App\Http\Controllers\QueriesController::show
* @see app/Http/Controllers/QueriesController.php:138
* @route '/queries/{query}'
*/
showForm.get = (args: { query: string | number | { id: string | number } } | [query: string | number | { id: string | number } ] | string | number | { id: string | number }, options?: RouteQueryOptions): RouteFormDefinition<'get'> => ({
    action: show.url(args, options),
    method: 'get',
})

/**
* @see \App\Http\Controllers\QueriesController::show
* @see app/Http/Controllers/QueriesController.php:138
* @route '/queries/{query}'
*/
showForm.head = (args: { query: string | number | { id: string | number } } | [query: string | number | { id: string | number } ] | string | number | { id: string | number }, options?: RouteQueryOptions): RouteFormDefinition<'get'> => ({
    action: show.url(args, {
        [options?.mergeQuery ? 'mergeQuery' : 'query']: {
            _method: 'HEAD',
            ...(options?.query ?? options?.mergeQuery ?? {}),
        }
    }),
    method: 'get',
})

show.form = showForm

/**
* @see \App\Http\Controllers\QueriesController::update
* @see app/Http/Controllers/QueriesController.php:167
* @route '/queries/{query}'
*/
export const update = (args: { query: string | number | { id: string | number } } | [query: string | number | { id: string | number } ] | string | number | { id: string | number }, options?: RouteQueryOptions): RouteDefinition<'patch'> => ({
    url: update.url(args, options),
    method: 'patch',
})

update.definition = {
    methods: ["patch"],
    url: '/queries/{query}',
} satisfies RouteDefinition<["patch"]>

/**
* @see \App\Http\Controllers\QueriesController::update
* @see app/Http/Controllers/QueriesController.php:167
* @route '/queries/{query}'
*/
update.url = (args: { query: string | number | { id: string | number } } | [query: string | number | { id: string | number } ] | string | number | { id: string | number }, options?: RouteQueryOptions) => {
    if (typeof args === 'string' || typeof args === 'number') {
        args = { query: args }
    }

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

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

    args = applyUrlDefaults(args)

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

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

/**
* @see \App\Http\Controllers\QueriesController::update
* @see app/Http/Controllers/QueriesController.php:167
* @route '/queries/{query}'
*/
update.patch = (args: { query: string | number | { id: string | number } } | [query: string | number | { id: string | number } ] | string | number | { id: string | number }, options?: RouteQueryOptions): RouteDefinition<'patch'> => ({
    url: update.url(args, options),
    method: 'patch',
})

/**
* @see \App\Http\Controllers\QueriesController::update
* @see app/Http/Controllers/QueriesController.php:167
* @route '/queries/{query}'
*/
const updateForm = (args: { query: string | number | { id: string | number } } | [query: string | number | { id: string | number } ] | string | number | { id: string | 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\QueriesController::update
* @see app/Http/Controllers/QueriesController.php:167
* @route '/queries/{query}'
*/
updateForm.patch = (args: { query: string | number | { id: string | number } } | [query: string | number | { id: string | number } ] | string | number | { id: string | 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\QueriesController::destroy
* @see app/Http/Controllers/QueriesController.php:183
* @route '/queries/{query}'
*/
export const destroy = (args: { query: string | number | { id: string | number } } | [query: string | number | { id: string | number } ] | string | number | { id: string | number }, options?: RouteQueryOptions): RouteDefinition<'delete'> => ({
    url: destroy.url(args, options),
    method: 'delete',
})

destroy.definition = {
    methods: ["delete"],
    url: '/queries/{query}',
} satisfies RouteDefinition<["delete"]>

/**
* @see \App\Http\Controllers\QueriesController::destroy
* @see app/Http/Controllers/QueriesController.php:183
* @route '/queries/{query}'
*/
destroy.url = (args: { query: string | number | { id: string | number } } | [query: string | number | { id: string | number } ] | string | number | { id: string | number }, options?: RouteQueryOptions) => {
    if (typeof args === 'string' || typeof args === 'number') {
        args = { query: args }
    }

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

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

    args = applyUrlDefaults(args)

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

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

/**
* @see \App\Http\Controllers\QueriesController::destroy
* @see app/Http/Controllers/QueriesController.php:183
* @route '/queries/{query}'
*/
destroy.delete = (args: { query: string | number | { id: string | number } } | [query: string | number | { id: string | number } ] | string | number | { id: string | number }, options?: RouteQueryOptions): RouteDefinition<'delete'> => ({
    url: destroy.url(args, options),
    method: 'delete',
})

/**
* @see \App\Http\Controllers\QueriesController::destroy
* @see app/Http/Controllers/QueriesController.php:183
* @route '/queries/{query}'
*/
const destroyForm = (args: { query: string | number | { id: string | number } } | [query: string | number | { id: string | number } ] | string | number | { id: string | 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\QueriesController::destroy
* @see app/Http/Controllers/QueriesController.php:183
* @route '/queries/{query}'
*/
destroyForm.delete = (args: { query: string | number | { id: string | number } } | [query: string | number | { id: string | number } ] | string | number | { id: string | 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 QueriesController = { publicForm, publicStore, index, show, update, destroy }

export default QueriesController