import React from "react";
import { DevContext } from "./../../ricos-context/index.js";
const DevContextProvider = ({ children }) => {
  const existingValue = React.useContext(DevContext);
  const [connectionState, setConnectionState] = React.useState({
    type: "NO_MODIFICATION"
  });
  const currentValue = React.useMemo(() => {
    const renderCountChangeListeners = /* @__PURE__ */ new Set();
    const testingProviderValue = {
      renderCounts: /* @__PURE__ */ new Map(),
      trackRender: (componentName) => {
        testingProviderValue.renderCounts?.set(
          componentName,
          (testingProviderValue.renderCounts?.get(componentName) || 0) + 1
        );
        renderCountChangeListeners.forEach((listener) => {
          if (testingProviderValue.renderCounts) {
            listener(testingProviderValue.renderCounts);
          }
        });
      },
      onRenderCountChange: (listener) => {
        renderCountChangeListeners.add(listener);
        return () => {
          renderCountChangeListeners.delete(listener);
        };
      },
      resetRenderCounts: () => {
        testingProviderValue.renderCounts?.forEach((_, key) => {
          testingProviderValue.renderCounts?.set(key, 0);
        });
        renderCountChangeListeners.forEach((listener) => {
          if (testingProviderValue.renderCounts) {
            listener(testingProviderValue.renderCounts);
          }
        });
      },
      connectionState,
      setConnectionState
    };
    return { ...testingProviderValue, ...existingValue };
  }, [existingValue, connectionState]);
  return /* @__PURE__ */ React.createElement(DevContext.Provider, { value: currentValue }, children);
};
export {
  DevContextProvider
};
//# sourceMappingURL=dev-contenxt-provider.js.map
