docs: private State calculateNextState(final long timeoutInNanos, final State activeState) {
          long cyclePeriodInNanos = activeState.config.getLimitRefreshPeriodInNanos();
          int permissionsPerCycle = activeState.config.getLimitForPeriod();
  
          long currentNanos = currentNanoTime();
          long currentCycle = currentNanos / cyclePeriodInNanos;
  
          long nextCycle = activeState.activeCycle;
          int nextPermissions = activeState.activePermissions;
          if (nextCycle != currentCycle) {
              long elapsedCycles = currentCycle - nextCycle;
              long accumulatedPermissions = elapsedCycles * permissionsPerCycle;
              nextCycle = currentCycle;
              nextPermissions = (int) min(nextPermissions + accumulatedPermissions, permissionsPerCycle);
          }
          long nextNanosToWait = nanosToWaitForPermission(
                  cyclePeriodInNanos, permissionsPerCycle, nextPermissions, currentNanos, currentCycle
          );
          State nextState = reservePermissions(activeState.config, timeoutInNanos, nextCycle, nextPermissions, nextNanosToWait);
          return nextState;
      }