"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.uniqueBy = uniqueBy;
/**
 * Creates a superRefine function that validates array elements are unique by a given key.
 *
 * @param keyFn - Function to extract the key from each element
 * @param errorMessage - Function to generate error message for duplicates
 * @returns A superRefine callback for use with z.array().superRefine()
 */
function uniqueBy(keyFn, errorMessage) {
    return (items, ctx) => {
        const seen = new Set();
        for (const [idx, item] of items.entries()) {
            const key = keyFn(item);
            if (seen.has(key)) {
                ctx.addIssue({ code: 'custom', message: errorMessage(key), path: [idx] });
            }
            seen.add(key);
        }
    };
}
//# sourceMappingURL=zod-util.js.map