"use strict";
/*
 * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
 */
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.linkedAccountFromJSON = exports.linkedAccountToJSON = exports.LinkedAccount$ = exports.LinkedAccount$outboundSchema = exports.LinkedAccount$inboundSchema = exports.LinkedAccountStatus$ = exports.LinkedAccountStatus$outboundSchema = exports.LinkedAccountStatus$inboundSchema = exports.setupInformationFromJSON = exports.setupInformationToJSON = exports.SetupInformation$ = exports.SetupInformation$outboundSchema = exports.SetupInformation$inboundSchema = exports.credentialsFromJSON = exports.credentialsToJSON = exports.Credentials$ = exports.Credentials$outboundSchema = exports.Credentials$inboundSchema = exports.LinkedAccountStatus = void 0;
const z = __importStar(require("zod"));
const primitives_js_1 = require("../../../lib/primitives.js");
const schemas_js_1 = require("../../../lib/schemas.js");
const enums_js_1 = require("../../types/enums.js");
const statusreason_js_1 = require("./statusreason.js");
var LinkedAccountStatus;
(function (LinkedAccountStatus) {
    LinkedAccountStatus["Active"] = "active";
    LinkedAccountStatus["Inactive"] = "inactive";
    LinkedAccountStatus["Error"] = "error";
})(LinkedAccountStatus || (exports.LinkedAccountStatus = LinkedAccountStatus = {}));
/** @internal */
exports.Credentials$inboundSchema = z.object({});
/** @internal */
exports.Credentials$outboundSchema = z.object({});
/**
 * @internal
 * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
 */
var Credentials$;
(function (Credentials$) {
    /** @deprecated use `Credentials$inboundSchema` instead. */
    Credentials$.inboundSchema = exports.Credentials$inboundSchema;
    /** @deprecated use `Credentials$outboundSchema` instead. */
    Credentials$.outboundSchema = exports.Credentials$outboundSchema;
})(Credentials$ || (exports.Credentials$ = Credentials$ = {}));
function credentialsToJSON(credentials) {
    return JSON.stringify(exports.Credentials$outboundSchema.parse(credentials));
}
exports.credentialsToJSON = credentialsToJSON;
function credentialsFromJSON(jsonString) {
    return (0, schemas_js_1.safeParse)(jsonString, (x) => exports.Credentials$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Credentials' from JSON`);
}
exports.credentialsFromJSON = credentialsFromJSON;
/** @internal */
exports.SetupInformation$inboundSchema = z.object({});
/** @internal */
exports.SetupInformation$outboundSchema = z.object({});
/**
 * @internal
 * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
 */
var SetupInformation$;
(function (SetupInformation$) {
    /** @deprecated use `SetupInformation$inboundSchema` instead. */
    SetupInformation$.inboundSchema = exports.SetupInformation$inboundSchema;
    /** @deprecated use `SetupInformation$outboundSchema` instead. */
    SetupInformation$.outboundSchema = exports.SetupInformation$outboundSchema;
})(SetupInformation$ || (exports.SetupInformation$ = SetupInformation$ = {}));
function setupInformationToJSON(setupInformation) {
    return JSON.stringify(exports.SetupInformation$outboundSchema.parse(setupInformation));
}
exports.setupInformationToJSON = setupInformationToJSON;
function setupInformationFromJSON(jsonString) {
    return (0, schemas_js_1.safeParse)(jsonString, (x) => exports.SetupInformation$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'SetupInformation' from JSON`);
}
exports.setupInformationFromJSON = setupInformationFromJSON;
/** @internal */
exports.LinkedAccountStatus$inboundSchema = z
    .union([
    z.nativeEnum(LinkedAccountStatus),
    z.string().transform(enums_js_1.catchUnrecognizedEnum),
]);
/** @internal */
exports.LinkedAccountStatus$outboundSchema = z.union([
    z.nativeEnum(LinkedAccountStatus),
    z.string().and(z.custom()),
]);
/**
 * @internal
 * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
 */
var LinkedAccountStatus$;
(function (LinkedAccountStatus$) {
    /** @deprecated use `LinkedAccountStatus$inboundSchema` instead. */
    LinkedAccountStatus$.inboundSchema = exports.LinkedAccountStatus$inboundSchema;
    /** @deprecated use `LinkedAccountStatus$outboundSchema` instead. */
    LinkedAccountStatus$.outboundSchema = exports.LinkedAccountStatus$outboundSchema;
})(LinkedAccountStatus$ || (exports.LinkedAccountStatus$ = LinkedAccountStatus$ = {}));
/** @internal */
exports.LinkedAccount$inboundSchema = z.object({
    created_at: z.string().datetime({ offset: true }).transform(v => new Date(v)),
    credentials: z.nullable(z.lazy(() => exports.Credentials$inboundSchema)).optional(),
    id: z.string(),
    label: z.nullable(z.string()).optional(),
    origin_owner_id: z.string(),
    origin_owner_name: z.string(),
    origin_username: z.nullable(z.string()).optional(),
    provider: z.string(),
    provider_name: z.nullable(z.string()).optional(),
    setup_information: z.nullable(z.lazy(() => exports.SetupInformation$inboundSchema))
        .optional(),
    status: exports.LinkedAccountStatus$inboundSchema,
    status_reasons: z.nullable(z.array(statusreason_js_1.StatusReason$inboundSchema)).optional(),
    updated_at: z.string().datetime({ offset: true }).transform(v => new Date(v)),
}).transform((v) => {
    return (0, primitives_js_1.remap)(v, {
        "created_at": "createdAt",
        "origin_owner_id": "originOwnerId",
        "origin_owner_name": "originOwnerName",
        "origin_username": "originUsername",
        "provider_name": "providerName",
        "setup_information": "setupInformation",
        "status_reasons": "statusReasons",
        "updated_at": "updatedAt",
    });
});
/** @internal */
exports.LinkedAccount$outboundSchema = z.object({
    createdAt: z.date().transform(v => v.toISOString()),
    credentials: z.nullable(z.lazy(() => exports.Credentials$outboundSchema)).optional(),
    id: z.string(),
    label: z.nullable(z.string()).optional(),
    originOwnerId: z.string(),
    originOwnerName: z.string(),
    originUsername: z.nullable(z.string()).optional(),
    provider: z.string(),
    providerName: z.nullable(z.string()).optional(),
    setupInformation: z.nullable(z.lazy(() => exports.SetupInformation$outboundSchema))
        .optional(),
    status: exports.LinkedAccountStatus$outboundSchema,
    statusReasons: z.nullable(z.array(statusreason_js_1.StatusReason$outboundSchema)).optional(),
    updatedAt: z.date().transform(v => v.toISOString()),
}).transform((v) => {
    return (0, primitives_js_1.remap)(v, {
        createdAt: "created_at",
        originOwnerId: "origin_owner_id",
        originOwnerName: "origin_owner_name",
        originUsername: "origin_username",
        providerName: "provider_name",
        setupInformation: "setup_information",
        statusReasons: "status_reasons",
        updatedAt: "updated_at",
    });
});
/**
 * @internal
 * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
 */
var LinkedAccount$;
(function (LinkedAccount$) {
    /** @deprecated use `LinkedAccount$inboundSchema` instead. */
    LinkedAccount$.inboundSchema = exports.LinkedAccount$inboundSchema;
    /** @deprecated use `LinkedAccount$outboundSchema` instead. */
    LinkedAccount$.outboundSchema = exports.LinkedAccount$outboundSchema;
})(LinkedAccount$ || (exports.LinkedAccount$ = LinkedAccount$ = {}));
function linkedAccountToJSON(linkedAccount) {
    return JSON.stringify(exports.LinkedAccount$outboundSchema.parse(linkedAccount));
}
exports.linkedAccountToJSON = linkedAccountToJSON;
function linkedAccountFromJSON(jsonString) {
    return (0, schemas_js_1.safeParse)(jsonString, (x) => exports.LinkedAccount$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'LinkedAccount' from JSON`);
}
exports.linkedAccountFromJSON = linkedAccountFromJSON;
//# sourceMappingURL=linkedaccount.js.map