"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _vueDemi = require("vue-demi");
function createContext(defaultValue) {
  const contextKey = Symbol('contextKey');
  const useProvide = (props, newProps) => {
    const mergedProps = (0, _vueDemi.reactive)({});
    (0, _vueDemi.provide)(contextKey, mergedProps);
    (0, _vueDemi.watchEffect)(() => {
      (0, _extends2.default)(mergedProps, props, newProps || {});
    });
    return mergedProps;
  };
  const useInject = () => {
    return (0, _vueDemi.inject)(contextKey, defaultValue) || {};
  };
  return {
    useProvide,
    useInject
  };
}
var _default = exports.default = createContext;