import { useMemo } from "react";
import { useBlockCollection } from "./useBlockCollection.mjs";
import { useDatetimeVariable } from "./useDateVariable.mjs";
import { useFilterVariable } from "./useFilterVariable.mjs";
import { useCurrentFormVariable } from "./useFormVariable.mjs";
import { useCurrentObjectVariable } from "./useIterationVariable.mjs";
import { useCurrentParentRecordVariable } from "./useParentRecordVariable.mjs";
import { usePopupVariable } from "./usePopupVariable.mjs";
import { useCurrentRecordVariable } from "./useRecordVariable.mjs";
import { useCurrentRoleVariable } from "./useRoleVariable.mjs";
import { useCurrentUserVariable } from "./useUserVariable.mjs";
const useVariableOptions = (param)=>{
    let { collectionField, form, uiSchema, operator, noDisabled, targetFieldSchema, record } = param;
    var _record___parent;
    const { name: blockCollectionName = null == record ? void 0 : record.__collectionName } = useBlockCollection();
    const blockParentCollectionName = null == record ? void 0 : null == (_record___parent = record.__parent) ? void 0 : _record___parent.__collectionName;
    const { currentUserSettings } = useCurrentUserVariable({
        maxDepth: 3,
        uiSchema: uiSchema,
        collectionField,
        noDisabled,
        targetFieldSchema
    });
    const { currentRoleSettings } = useCurrentRoleVariable({
        uiSchema: uiSchema,
        collectionField,
        noDisabled,
        targetFieldSchema
    });
    const { datetimeSettings } = useDatetimeVariable({
        operator,
        schema: uiSchema,
        noDisabled
    });
    const { currentFormSettings, shouldDisplayCurrentForm } = useCurrentFormVariable({
        schema: uiSchema,
        collectionField,
        noDisabled,
        targetFieldSchema,
        form
    });
    const { currentObjectSettings, shouldDisplayCurrentObject } = useCurrentObjectVariable({
        collectionField,
        schema: uiSchema,
        noDisabled,
        targetFieldSchema
    });
    const { currentRecordSettings, shouldDisplayCurrentRecord } = useCurrentRecordVariable({
        schema: uiSchema,
        collectionField,
        noDisabled,
        targetFieldSchema
    });
    const { settings: popupRecordSettings, shouldDisplayPopupRecord } = usePopupVariable({
        schema: uiSchema,
        collectionField,
        noDisabled,
        targetFieldSchema
    });
    const { currentParentRecordSettings, shouldDisplayCurrentParentRecord } = useCurrentParentRecordVariable({
        schema: uiSchema,
        collectionName: blockParentCollectionName,
        collectionField,
        noDisabled,
        targetFieldSchema
    });
    const { currentCustomFilterSetting, shouldDisplayCustomFilter } = useFilterVariable({
        schema: uiSchema,
        form,
        collectionName: blockParentCollectionName,
        collectionField,
        targetFieldSchema
    });
    return useMemo(()=>[
            currentUserSettings,
            currentRoleSettings,
            datetimeSettings,
            shouldDisplayCurrentForm && currentFormSettings,
            shouldDisplayCurrentObject && currentObjectSettings,
            shouldDisplayCurrentRecord && currentRecordSettings,
            shouldDisplayCurrentParentRecord && currentParentRecordSettings,
            shouldDisplayPopupRecord && popupRecordSettings,
            shouldDisplayCustomFilter && currentCustomFilterSetting
        ].filter(Boolean), [
        currentUserSettings,
        currentRoleSettings,
        datetimeSettings,
        shouldDisplayCurrentForm,
        currentFormSettings,
        shouldDisplayCurrentObject,
        currentObjectSettings,
        shouldDisplayCurrentRecord,
        currentRecordSettings,
        shouldDisplayCurrentParentRecord,
        currentParentRecordSettings,
        shouldDisplayPopupRecord,
        popupRecordSettings,
        currentCustomFilterSetting,
        shouldDisplayCustomFilter
    ]);
};
export { useVariableOptions };
