function $AdfInputSearchScoreUtils$$() {
}
$goog$exportSymbol$$("AdfInputSearchScoreUtils", $AdfInputSearchScoreUtils$$);
$AdfObject$$.$createSubclass$($AdfInputSearchScoreUtils$$);
$AdfInputSearchScoreUtils$$.$InitClass$ = function $$AdfInputSearchScoreUtils$$$$InitClass$$() {
  this.$_MAX_SCORE$ = 250;
  this.$_NEW_ITEM_SCORE$ = 20;
  this.$_STATE_SAME_SESSION$ = 1;
  this.$_STATE_PREVIOUS_SESSION$ = 2;
  this.$_STATE_OLD_SESSION$ = 3;
  this.$_SCORE_INCREMENTOR_MAP$ = {};
  this.$_SCORE_INCREMENTOR_MAP$[this.$_STATE_SAME_SESSION$] = 20;
  this.$_SCORE_INCREMENTOR_MAP$[this.$_STATE_PREVIOUS_SESSION$] = 40;
  this.$_SCORE_INCREMENTOR_MAP$[this.$_STATE_OLD_SESSION$] = 20;
  this.$_DECAY_SCORE_MAP$ = {};
  this.$_DECAY_SCORE_MAP$[this.$_STATE_SAME_SESSION$] = 4;
  this.$_DECAY_SCORE_MAP$[this.$_STATE_PREVIOUS_SESSION$] = 4;
  this.$_DECAY_SCORE_MAP$[this.$_STATE_OLD_SESSION$] = 8;
};
$goog$exportSymbol$$("AdfInputSearchScoreUtils.InitClass", $AdfInputSearchScoreUtils$$.$InitClass$);
$AdfInputSearchScoreUtils$$.$getMinScoredSuggestionKey$ = function $$AdfInputSearchScoreUtils$$$$getMinScoredSuggestionKey$$($scoreMap$$) {
  for (var $minScoredSuggestionKey$$, $minScore$$ = Number.MAX_SAFE_INTEGER, $suggestionKeys$$ = Object.keys($scoreMap$$), $i$$142$$ = 0, $length$$38$$ = $suggestionKeys$$.length;$i$$142$$ < $length$$38$$;$i$$142$$++) {
    var $currenItemKey$$ = $suggestionKeys$$[$i$$142$$], $currentItemScore$$ = $scoreMap$$[$currenItemKey$$].value;
    $currentItemScore$$ < $minScore$$ && ($minScore$$ = $currentItemScore$$, $minScoredSuggestionKey$$ = $currenItemKey$$);
  }
  return $minScoredSuggestionKey$$;
};
$goog$exportSymbol$$("AdfInputSearchScoreUtils.getMinScoredSuggestionKey", $AdfInputSearchScoreUtils$$.$getMinScoredSuggestionKey$);
$AdfInputSearchScoreUtils$$.$sortPerScore$ = function $$AdfInputSearchScoreUtils$$$$sortPerScore$$($suggestionsList$$, $scoreMap$$1$$) {
  return $suggestionsList$$.sort(function($suggestionsList$$, $suggestionB$$) {
    return $scoreMap$$1$$[$suggestionB$$.key].value - $scoreMap$$1$$[$suggestionsList$$.key].value;
  });
};
$goog$exportSymbol$$("AdfInputSearchScoreUtils.sortPerScore", $AdfInputSearchScoreUtils$$.$sortPerScore$);
$AdfInputSearchScoreUtils$$.$updateScores$ = function $$AdfInputSearchScoreUtils$$$$updateScores$$($sessionTimeStamps_storageKey$$, $preferredSuggestions_scoreMap$$2$$, $currentValue$$) {
  $sessionTimeStamps_storageKey$$ = $AdfInputSearchScoreUtils$$.$_updateSessionState$($sessionTimeStamps_storageKey$$, $preferredSuggestions_scoreMap$$2$$);
  $preferredSuggestions_scoreMap$$2$$ = $preferredSuggestions_scoreMap$$2$$.$score$;
  $AdfInputSearchScoreUtils$$.$_decrementScores$($preferredSuggestions_scoreMap$$2$$, $sessionTimeStamps_storageKey$$);
  var $currentItemScore$$1$$ = $preferredSuggestions_scoreMap$$2$$[$currentValue$$];
  $currentItemScore$$1$$ ? ($AdfInputSearchScoreUtils$$.$_incrementScore$($currentItemScore$$1$$, $sessionTimeStamps_storageKey$$), $currentItemScore$$1$$.time = Date.now()) : ($currentItemScore$$1$$ = {}, $currentItemScore$$1$$.time = Date.now(), $currentItemScore$$1$$.value = $AdfInputSearchScoreUtils$$.$_NEW_ITEM_SCORE$, $preferredSuggestions_scoreMap$$2$$[$currentValue$$] = $currentItemScore$$1$$);
};
$goog$exportSymbol$$("AdfInputSearchScoreUtils.updateScores", $AdfInputSearchScoreUtils$$.$updateScores$);
$AdfInputSearchScoreUtils$$.$_decrementScores$ = function $$AdfInputSearchScoreUtils$$$$_decrementScores$$($scoreMap$$3$$, $sessionTimeStamps$$1$$) {
  for (var $suggestionKeys$$1$$ = Object.keys($scoreMap$$3$$), $i$$143$$ = 0, $length$$39$$ = $suggestionKeys$$1$$.length;$i$$143$$ < $length$$39$$;$i$$143$$++) {
    var $score$$ = $scoreMap$$3$$[$suggestionKeys$$1$$[$i$$143$$]], $sessionState$$ = $AdfInputSearchScoreUtils$$.$_getSessionState$($score$$.time, $sessionTimeStamps$$1$$);
    $score$$.value -= $AdfInputSearchScoreUtils$$.$_DECAY_SCORE_MAP$[$sessionState$$];
  }
};
$AdfInputSearchScoreUtils$$.$_incrementScore$ = function $$AdfInputSearchScoreUtils$$$$_incrementScore$$($currentItemScore$$2$$, $sessionTimeStamps$$2$$) {
  var $sessionState$$1$$ = $AdfInputSearchScoreUtils$$.$_getSessionState$($currentItemScore$$2$$.time, $sessionTimeStamps$$2$$);
  0 > $currentItemScore$$2$$.value && ($currentItemScore$$2$$.value = 0);
  $currentItemScore$$2$$.value += $AdfInputSearchScoreUtils$$.$_SCORE_INCREMENTOR_MAP$[$sessionState$$1$$];
  $currentItemScore$$2$$.value > $AdfInputSearchScoreUtils$$.$_MAX_SCORE$ && ($currentItemScore$$2$$.value = $AdfInputSearchScoreUtils$$.$_MAX_SCORE$);
};
$AdfInputSearchScoreUtils$$.$_getSessionState$ = function $$AdfInputSearchScoreUtils$$$$_getSessionState$$($itemTimeStamp$$, $sessionTimeStamps$$3$$) {
  if ($itemTimeStamp$$ >= $sessionTimeStamps$$3$$.current) {
    return $AdfInputSearchScoreUtils$$.$_STATE_SAME_SESSION$;
  }
  if ($itemTimeStamp$$ >= $sessionTimeStamps$$3$$.$previous$) {
    return $AdfInputSearchScoreUtils$$.$_STATE_PREVIOUS_SESSION$;
  }
  $AdfInputSearchScoreUtils$$.$_STATE_OLD_SESSION$;
};
$AdfInputSearchScoreUtils$$.$_updateSessionState$ = function $$AdfInputSearchScoreUtils$$$$_updateSessionState$$($storageKey$$1$$, $preferredSuggestions$$1$$) {
  var $sessionStartTime$$ = $preferredSuggestions$$1$$.$sessionStartTime$ ? $preferredSuggestions$$1$$.$sessionStartTime$ : Date.now(), $sessionTimeStamps$$4$$ = sessionStorage.getItem($storageKey$$1$$);
  return $sessionTimeStamps$$4$$ ? JSON.parse($sessionTimeStamps$$4$$) : ($sessionTimeStamps$$4$$ = {}, $sessionTimeStamps$$4$$.current = Date.now(), $sessionTimeStamps$$4$$.$previous$ = $sessionStartTime$$, sessionStorage.setItem($storageKey$$1$$, JSON.stringify($sessionTimeStamps$$4$$)), $preferredSuggestions$$1$$.$sessionStartTime$ = $sessionTimeStamps$$4$$.current, $sessionTimeStamps$$4$$);
};
