import { jsx, Fragment } from 'react/jsx-runtime';
import { useCallback, Profiler } from 'react';

const DevProfiler = ({ id, threshold, children }) => {
  const onRenderCallback = useCallback(
    (profilerId, phase, actualDuration) => {
      if (actualDuration > threshold) {
        console.log(
          `%cProfiler [${profilerId}] Phase: ${phase} - actual duration: ${actualDuration.toFixed(2)}ms exceeds threshold of ${threshold}ms`,
          "color: red"
        );
      }
    },
    [threshold]
  );
  if (process.env.NODE_ENV === "production") {
    return /* @__PURE__ */ jsx(Fragment, { children });
  }
  return /* @__PURE__ */ jsx(Profiler, { id, onRender: onRenderCallback, children });
};

export { DevProfiler };
