import react, { useMemo } from "react";
import { useApp } from "../../hooks/index.mjs";
import { SchemaSettingsWrapper } from "../components/index.mjs";
import { defaultSettingItems } from "../SchemaSettingsDefaults.mjs";
function useSchemaSettingsRender(name, options) {
    const app = useApp();
    const schemaSetting = useMemo(()=>app.schemaSettingsManager.get(name), [
        app.schemaSettingsManager,
        name
    ]);
    if (!name) return {
        exists: false,
        render: ()=>null
    };
    if (!schemaSetting) {
        console.error('[tachybase]: SchemaSettings "'.concat(name, '" not found'));
        return {
            exists: false,
            render: ()=>null
        };
    }
    return {
        exists: true,
        render: function() {
            let options2 = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {};
            const newItems = [
                ...defaultSettingItems,
                ...schemaSetting.options.items
            ];
            const newOptions = {
                ...schemaSetting.options,
                items: newItems
            };
            return /*#__PURE__*/ react.createElement(SchemaSettingsWrapper, {
                ...newOptions,
                ...options,
                ...options2
            });
        }
    };
}
export { useSchemaSettingsRender };
