import { useFieldSchema } from "@tachybase/schema";
import lodash from "lodash";
import { useColumnSchema } from "../../schema-component/index.mjs";
function getNewSchema(options) {
    const { fieldSchema, schemaKey, parentSchemaKey, value, valueKeys } = options;
    if (schemaKey) lodash.set(fieldSchema, schemaKey, value);
    else if (parentSchemaKey) {
        if (void 0 === value) return fieldSchema;
        if ('object' == typeof value) Object.keys(value).forEach((key)=>{
            if (valueKeys && !valueKeys.includes(key)) return;
            lodash.set(fieldSchema, "".concat(parentSchemaKey, ".").concat(key), value[key]);
        });
        else console.error('value must be object');
    }
    return fieldSchema;
}
const useHookDefault = (defaultValues)=>defaultValues;
const useSchemaByType = function() {
    let type = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : 'common';
    const schema = useFieldSchema();
    const { fieldSchema: tableColumnSchema } = useColumnSchema() || {};
    return 'field' === type ? tableColumnSchema || schema : schema;
};
export { getNewSchema, useHookDefault, useSchemaByType };
