"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.objectKeys = objectKeys;
exports.objectAssign = objectAssign;
exports.objectEntries = objectEntries;
exports.extractValues = extractValues;
exports.extractUpdates = extractUpdates;
exports.patchObject = patchObject;
exports.extractKV = extractKV;
const __ΩPartial = ['T', 'Partial', 'l+e#!e"!fRb!Pde"!gN#"w"y'];
const __ΩPick = ['T', 'K', 'Pick', 'l+e#!e"!fRb!b"Pde""N#!w#y'];
function __assignType(fn, args) {
    fn.__type = args;
    return fn;
}
const lodash_1 = require("lodash");
function objectKeys(object) {
    // eslint-disable-next-line @typescript-eslint/no-explicit-any
    return Object.keys(object);
}
objectKeys.__type = ['object', 'objectKeys', 'P"2!"gF/"'];
function objectAssign(object, ...values) {
    return Object.assign(object, ...values);
}
objectAssign.__type = ['object', () => __ΩPartial, 'values', 'objectAssign', 'P"2!"o""@2#"/$'];
const __ΩEntries = ['T', 'Entries', 'l0Pe#!e$!e#!fGRb!Pde"!gN#!e!!gfFw"y'];
function objectEntries(object) {
    // eslint-disable-next-line @typescript-eslint/no-explicit-any
    return Object.entries(object);
}
objectEntries.__type = ['object', () => __ΩEntries, 'objectEntries', 'P"2!"o""/#'];
function extractValues(state, fields) {
    // eslint-disable-next-line @typescript-eslint/no-explicit-any
    const result = {};
    for (const key of fields) {
        if (state[key] !== undefined) {
            result[key] = state[key];
        }
    }
    return result;
}
extractValues.__type = ['state', 'fields', () => __ΩPick, 'extractValues', 'P"2!"2"""\'fo##/$'];
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function doesMatch(original, updated, method) {
    if (method === 'matches' && typeof original === 'object' && typeof updated === 'object') {
        return (0, lodash_1.isMatch)(original, updated);
    }
    return (0, lodash_1.isEqual)(original, updated);
}
doesMatch.__type = ['original', 'updated', "equals", "matches", 'method', 'doesMatch', 'P"2!"2"P.#.$J2%8)/&'];
function extractUpdates(state, updates, fields, method) {
    const result = {};
    const updateFields = fields ?? objectKeys(updates);
    for (const key of updateFields) {
        if (updates[key] !== undefined && !doesMatch(state[key], updates[key], method)) {
            result[key] = updates[key];
        }
    }
    return result;
}
extractUpdates.__type = ['state', () => __ΩPartial, 'updates', 'fields', "equals", "matches", 'method', () => __ΩPartial, 'extractUpdates', 'P"2!"o""2#"gF2$8P.%.&J2\'8"o("/)'];
function patchObject(state, updates, fields, method) {
    const effectiveUpdates = extractUpdates(state, updates, fields, method);
    objectAssign(state, effectiveUpdates);
    return state;
}
patchObject.__type = ['state', () => __ΩPartial, 'updates', 'fields', "equals", "matches", 'method', 'patchObject', 'P"2!"o""2#"gF2$8P.%.&J2\'8"/('];
function extractKV(arr, keyCol, valCol) {
    return arr.reduce(__assignType((acc, cur) => {
        acc[cur[keyCol]] = cur[valCol];
        return acc;
    }, ['acc', 'cur', '', 'P"2!"2""/#']), {});
}
extractKV.__type = ['arr', 'keyCol', 'valCol', 'extractKV', 'P"F2!"2""2#"/$'];
//# sourceMappingURL=objects.js.map