import { evaluate } from "@qorebase/app-runtime/src/hooks/useExpression";
import React from "react";
import dot from "dot-object";
export function useHidden(hideOn, values) {
    if (!hideOn || !values)
        return { isHidden: false };
    const flatValues = React.useMemo(() => dot.dot(values), [values]);
    const evaluateResult = evaluate(hideOn.expression, flatValues);
    const getValueByType = React.useCallback((value) => {
        switch (hideOn.type) {
            case "shownOn":
                return !value;
            default:
                return value;
        }
    }, [hideOn]);
    const isHidden = React.useMemo(() => {
        if (evaluateResult === "#Error!")
            return false;
        return getValueByType(!!evaluateResult);
    }, [evaluateResult]);
    return { isHidden };
}
//# sourceMappingURL=useHidden.js.map