/*
 * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
 */
import * as z from "zod";
import { safeParse } from "../../lib/schemas.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 Error {
    constructor(err) {
        const message = "message" in err && typeof err.message === "string"
            ? err.message
            : `API error occurred: ${JSON.stringify(err)}`;
        super(message);
        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
 * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
 */
export var NotFoundCode$;
(function (NotFoundCode$) {
    /** @deprecated use `NotFoundCode$inboundSchema` instead. */
    NotFoundCode$.inboundSchema = NotFoundCode$inboundSchema;
    /** @deprecated use `NotFoundCode$outboundSchema` instead. */
    NotFoundCode$.outboundSchema = NotFoundCode$outboundSchema;
})(NotFoundCode$ || (NotFoundCode$ = {}));
/** @internal */
export const NotFoundErrorCode$inboundSchema = z.nativeEnum(NotFoundErrorCode);
/** @internal */
export const NotFoundErrorCode$outboundSchema = NotFoundErrorCode$inboundSchema;
/**
 * @internal
 * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
 */
export var NotFoundErrorCode$;
(function (NotFoundErrorCode$) {
    /** @deprecated use `NotFoundErrorCode$inboundSchema` instead. */
    NotFoundErrorCode$.inboundSchema = NotFoundErrorCode$inboundSchema;
    /** @deprecated use `NotFoundErrorCode$outboundSchema` instead. */
    NotFoundErrorCode$.outboundSchema = NotFoundErrorCode$outboundSchema;
})(NotFoundErrorCode$ || (NotFoundErrorCode$ = {}));
/** @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(),
});
/**
 * @internal
 * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
 */
export var NotFoundError$;
(function (NotFoundError$) {
    /** @deprecated use `NotFoundError$inboundSchema` instead. */
    NotFoundError$.inboundSchema = NotFoundError$inboundSchema;
    /** @deprecated use `NotFoundError$outboundSchema` instead. */
    NotFoundError$.outboundSchema = NotFoundError$outboundSchema;
})(NotFoundError$ || (NotFoundError$ = {}));
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),
})
    .transform((v) => {
    return new NotFound(v);
});
/** @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),
}));
/**
 * @internal
 * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
 */
export var NotFound$;
(function (NotFound$) {
    /** @deprecated use `NotFound$inboundSchema` instead. */
    NotFound$.inboundSchema = NotFound$inboundSchema;
    /** @deprecated use `NotFound$outboundSchema` instead. */
    NotFound$.outboundSchema = NotFound$outboundSchema;
})(NotFound$ || (NotFound$ = {}));
//# sourceMappingURL=notfound.js.map