import * as __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__ from "react/jsx-runtime";
import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react";
import * as __WEBPACK_EXTERNAL_MODULE__collection_manager_index_mjs__ from "../collection-manager/index.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__data_source_index_mjs__ from "../data-source/index.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__user_index_mjs__ from "../user/index.mjs";
const RecordContext_deprecated = /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react__.createContext)({});
RecordContext_deprecated.displayName = 'RecordContext_deprecated';
const RecordIndexContext = /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react__.createContext)(null);
RecordIndexContext.displayName = 'RecordIndexContext';
const RecordProvider = (props)=>{
    const { record, children, parent, isNew } = props;
    const { name: __collectionName } = (0, __WEBPACK_EXTERNAL_MODULE__collection_manager_index_mjs__.useCollection_deprecated)();
    const value = {
        ...record
    };
    value['__parent'] = parent;
    value['__collectionName'] = __collectionName;
    return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(RecordContext_deprecated.Provider, {
        value: value,
        children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__data_source_index_mjs__.CollectionRecordProvider, {
            isNew: isNew,
            record: record,
            parentRecord: parent,
            children: children
        })
    });
};
const RecordSimpleProvider = (props)=>/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(RecordContext_deprecated.Provider, {
        ...props
    });
const RecordIndexProvider = (props)=>{
    const { index, children } = props;
    return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(RecordIndexContext.Provider, {
        value: index,
        children: children
    });
};
function useRecord() {
    return (0, __WEBPACK_EXTERNAL_MODULE_react__.useContext)(RecordContext_deprecated);
}
function useRecordIndex() {
    return (0, __WEBPACK_EXTERNAL_MODULE_react__.useContext)(RecordIndexContext);
}
const useRecordIsOwn = ()=>{
    var _ctx_data_data, _ctx_data;
    const record = useRecord();
    const ctx = (0, __WEBPACK_EXTERNAL_MODULE__user_index_mjs__.useCurrentUserContext)();
    if (!(null == record ? void 0 : record.createdById)) return false;
    return (null == record ? void 0 : record.createdById) === (null == ctx ? void 0 : null === (_ctx_data = ctx.data) || void 0 === _ctx_data ? void 0 : null === (_ctx_data_data = _ctx_data.data) || void 0 === _ctx_data_data ? void 0 : _ctx_data_data.id);
};
export { RecordContext_deprecated, RecordIndexContext, RecordIndexProvider, RecordProvider, RecordSimpleProvider, useRecord, useRecordIndex, useRecordIsOwn };
