/*
 * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
 */
import * as z from "zod/v3";
import { safeParse } from "../../lib/schemas.js";
import { InkeepAnalyticsError } from "./inkeepanalyticserror.js";
/**
 * A short code indicating the error code returned.
 */
export const NotFoundCode = {
    NotFound: "not_found",
};
/**
 * A short code indicating the error code returned.
 */
export const NotFoundErrorCode = {
    NotFound: "not_found",
};
export class NotFound extends InkeepAnalyticsError {
    constructor(err, httpMeta) {
        const message = err.error?.message
            || `API error occurred: ${JSON.stringify(err)}`;
        super(message, httpMeta);
        this.data$ = err;
        this.title = err.title;
        this.status = err.status;
        this.detail = err.detail;
        if (err.instance != null)
            this.instance = err.instance;
        if (err.requestId != null)
            this.requestId = err.requestId;
        this.code = err.code;
        this.error = err.error;
        this.name = "NotFound";
    }
}
/** @internal */
export const NotFoundCode$inboundSchema = z.nativeEnum(NotFoundCode);
/** @internal */
export const NotFoundCode$outboundSchema = NotFoundCode$inboundSchema;
/** @internal */
export const NotFoundErrorCode$inboundSchema = z.nativeEnum(NotFoundErrorCode);
/** @internal */
export const NotFoundErrorCode$outboundSchema = NotFoundErrorCode$inboundSchema;
/** @internal */
export const NotFoundError$inboundSchema = z.object({
    code: NotFoundErrorCode$inboundSchema,
    message: z.string(),
});
/** @internal */
export const NotFoundError$outboundSchema = z.object({
    code: NotFoundErrorCode$outboundSchema,
    message: z.string(),
});
export function notFoundErrorToJSON(notFoundError) {
    return JSON.stringify(NotFoundError$outboundSchema.parse(notFoundError));
}
export function notFoundErrorFromJSON(jsonString) {
    return safeParse(jsonString, (x) => NotFoundError$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'NotFoundError' from JSON`);
}
/** @internal */
export const NotFound$inboundSchema = z.object({
    title: z.string(),
    status: z.number(),
    detail: z.string(),
    instance: z.string().optional(),
    requestId: z.string().optional(),
    code: NotFoundCode$inboundSchema,
    error: z.lazy(() => NotFoundError$inboundSchema),
    request$: z.instanceof(Request),
    response$: z.instanceof(Response),
    body$: z.string(),
})
    .transform((v) => {
    return new NotFound(v, {
        request: v.request$,
        response: v.response$,
        body: v.body$,
    });
});
/** @internal */
export const NotFound$outboundSchema = z.instanceof(NotFound)
    .transform(v => v.data$)
    .pipe(z.object({
    title: z.string(),
    status: z.number(),
    detail: z.string(),
    instance: z.string().optional(),
    requestId: z.string().optional(),
    code: NotFoundCode$outboundSchema,
    error: z.lazy(() => NotFoundError$outboundSchema),
}));
//# sourceMappingURL=notfound.js.map