"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.JsonArraySchema = exports.JsonObjectSchema = exports.dropdownOptionsBooleanSchema = exports.dropdownOptionsBoolean = void 0;
const lodash_1 = require("lodash");
const zod_1 = require("zod");
exports.dropdownOptionsBoolean = [
    { value: 'true', label: 'Yes' },
    { value: 'false', label: 'No' },
];
exports.dropdownOptionsBooleanSchema = zod_1.z
    .enum(['true', 'false'])
    .transform((val) => val === 'true');
exports.JsonObjectSchema = zod_1.z
    .string()
    .optional()
    .transform((str, ctx) => {
    if ((0, lodash_1.isNil)(str) || (0, lodash_1.isEmpty)(str))
        return {};
    try {
        const parsedJson = JSON.parse(str);
        return parsedJson;
    }
    catch (e) {
        ctx.addIssue({
            code: 'custom',
            message: 'Not a valid JSON object',
        });
        return zod_1.z.NEVER;
    }
});
exports.JsonArraySchema = zod_1.z
    .string()
    .optional()
    .transform((str, ctx) => {
    if ((0, lodash_1.isNil)(str) || (0, lodash_1.isEmpty)(str))
        return [];
    try {
        const parsedJson = JSON.parse(str);
        if ((0, lodash_1.isEmpty)(parsedJson)) {
            return [];
        }
        if (!Array.isArray(parsedJson)) {
            ctx.addIssue({
                code: 'custom',
                message: 'pronunciation_guide should be an array',
            });
            return zod_1.z.NEVER;
        }
        return parsedJson;
    }
    catch (e) {
        ctx.addIssue({
            code: 'custom',
            message: 'Invalid pronunciation_guide data',
        });
        return zod_1.z.NEVER;
    }
});
//# sourceMappingURL=sharedActionFields.js.map