import React__default from "react";
function* Keygen() {
  const max = 10;
  let key = 0;
  while (true) {
    yield String(key);
    key = (key + 1) % max;
  }
}
function withPropsGuard(Component, guard) {
  class WithPropsGuardComponent extends React__default.Component {
    constructor(props) {
      super(props);
      this.refresh = () => {
        this.setState({ key: this.state.keygen.next().value });
      };
      this.state = {
        keygen: Keygen(),
        oldProps: props,
        key: "1"
      };
    }
    static getDerivedStateFromProps(nextProps, state) {
      if (guard(state.oldProps, nextProps)) {
        return {
          key: state.keygen.next().value,
          oldProps: nextProps
        };
      }
      return null;
    }
    render() {
      return /* @__PURE__ */ React__default.createElement(Component, {
        key: this.state.key,
        propsGuardRefresh: this.refresh,
        ...this.props
      }, this.props.children);
    }
  }
  return WithPropsGuardComponent;
}
export { withPropsGuard as w };
