/*
 * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
 */
import * as z from "zod";
import * as components from "../components/index.js";
import { S2Error } from "./s2error.js";
export class TailResponse extends S2Error {
    constructor(err, httpMeta) {
        const message = "message" in err && typeof err.message === "string"
            ? err.message
            : `API error occurred: ${JSON.stringify(err)}`;
        super(message, httpMeta);
        this.data$ = err;
        this.tail = err.tail;
        this.name = "TailResponse";
    }
}
/** @internal */
export const TailResponse$inboundSchema = z.object({
    tail: components.StreamPosition$inboundSchema,
    request$: z.instanceof(Request),
    response$: z.instanceof(Response),
    body$: z.string(),
})
    .transform((v) => {
    return new TailResponse(v, {
        request: v.request$,
        response: v.response$,
        body: v.body$,
    });
});
/** @internal */
export const TailResponse$outboundSchema = z.instanceof(TailResponse)
    .transform(v => v.data$)
    .pipe(z.object({
    tail: components.StreamPosition$outboundSchema,
}));
/**
 * @internal
 * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
 */
export var TailResponse$;
(function (TailResponse$) {
    /** @deprecated use `TailResponse$inboundSchema` instead. */
    TailResponse$.inboundSchema = TailResponse$inboundSchema;
    /** @deprecated use `TailResponse$outboundSchema` instead. */
    TailResponse$.outboundSchema = TailResponse$outboundSchema;
})(TailResponse$ || (TailResponse$ = {}));
//# sourceMappingURL=tailresponse.js.map