import { useMemo } from "react";
import { useCollection } from "../../data-source/index.mjs";
import { useBlockCollection } from "../../schema-settings/VariableInput/hooks/useBlockCollection.mjs";
import { useDatetimeVariable } from "../../schema-settings/VariableInput/hooks/useDateVariable.mjs";
import { useCurrentFormVariable } from "../../schema-settings/VariableInput/hooks/useFormVariable.mjs";
import { useCurrentObjectVariable } from "../../schema-settings/VariableInput/hooks/useIterationVariable.mjs";
import { useCurrentParentRecordVariable } from "../../schema-settings/VariableInput/hooks/useParentRecordVariable.mjs";
import { usePopupVariable } from "../../schema-settings/VariableInput/hooks/usePopupVariable.mjs";
import { useCurrentRecordVariable } from "../../schema-settings/VariableInput/hooks/useRecordVariable.mjs";
const useLocalVariables_useLocalVariables = (props)=>{
    const { currentObjectCtx, shouldDisplayCurrentObject } = useCurrentObjectVariable();
    const { currentRecordCtx, collectionName: collectionNameOfRecord } = useCurrentRecordVariable();
    const { popupRecordCtx, collectionName: collectionNameOfPopupRecord } = usePopupVariable();
    const { currentParentRecordCtx, collectionName: collectionNameOfParentRecord } = useCurrentParentRecordVariable();
    const { datetimeCtx } = useDatetimeVariable();
    const { currentFormCtx } = useCurrentFormVariable({
        form: null == props ? void 0 : props.currentForm
    });
    const collection = useCollection();
    let { name } = useBlockCollection();
    if (null == props ? void 0 : props.collectionName) name = props.collectionName;
    return useMemo(()=>[
            {
                name: '$nRecord',
                ctx: currentRecordCtx,
                collectionName: collectionNameOfRecord
            },
            {
                name: '$nParentRecord',
                ctx: currentParentRecordCtx,
                collectionName: collectionNameOfParentRecord
            },
            {
                name: '$nPopupRecord',
                ctx: popupRecordCtx,
                collectionName: collectionNameOfPopupRecord
            },
            {
                name: '$nForm',
                ctx: currentFormCtx,
                collectionName: name
            },
            {
                name: '$nDate',
                ctx: datetimeCtx
            },
            shouldDisplayCurrentObject && {
                name: '$iteration',
                ctx: currentObjectCtx,
                collectionName: null == collection ? void 0 : collection.name
            }
        ].filter(Boolean), [
        currentRecordCtx,
        collectionNameOfRecord,
        name,
        currentFormCtx,
        currentParentRecordCtx,
        collectionNameOfParentRecord,
        popupRecordCtx,
        collectionNameOfPopupRecord,
        datetimeCtx,
        shouldDisplayCurrentObject,
        currentObjectCtx,
        null == collection ? void 0 : collection.name
    ]);
};
const useLocalVariables = useLocalVariables_useLocalVariables;
export { useLocalVariables as default };
