"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.ReferenceEditWrapper = ReferenceEditWrapper;
var _react = _interopRequireDefault(require("react"));
var _useOpenCollectionOverlay = require("../../useOpenCollectionOverlay");
var _openCollectionContext = require("./openCollectionContext");
var _jsxFileName = "/home/builduser/work/843658b9f44192f0/packages/cairo/dist/cjs/components/EditableTable/cellTypes/reference/ReferenceEditWrapper.tsx";
/**
 * Stable owner (mounted by EditableCell around the cell content, kept mounted
 * across the edit↔view swap) for the reference cell's "open collection" flow.
 * Opening the referenced collection navigates away as an overlay, which commits
 * and unmounts the inline editor — owning the navigation + return-to-foreground
 * subscription here lets it survive that unmount. The editor supplies the
 * refresh to run on return (over its own dropdown collection) via the opener
 * provided through context.
 */
function ReferenceEditWrapper({
  typeConfig,
  children
}) {
  var _refSchema;
  const collectionId = typeConfig == null || (_refSchema = typeConfig.refSchema) == null ? void 0 : _refSchema.collectionId;
  const openReferencedCollection = (0, _useOpenCollectionOverlay.useOpenCollectionOverlay)({
    collectionId
  });
  return /*#__PURE__*/_react.default.createElement(_openCollectionContext.OpenReferencedCollectionContext.Provider, {
    value: openReferencedCollection,
    __self: this,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 25,
      columnNumber: 5
    }
  }, children);
}
//# sourceMappingURL=ReferenceEditWrapper.js.map