{{#not queryParams.dontRenderScriptTags}}<script>{{/not}}
var superPersonalisation = window.superPersonalisation || {}
superPersonalisation.helper = (function (win, doc) {
  var getLocalStorageValue = function(key) {
    var tuiPersonalisation = localStorage.getItem('tuiPersonalisation')
    if (tuiPersonalisation) {
      var parsedData = JSON.parse(tuiPersonalisation)
      return parsedData[key]
    }
  }

  var setLocalStorageValue = function (key, value) {
    var tuiPersonalisation = localStorage.getItem('tuiPersonalisation')
    if (tuiPersonalisation) {
      var personalisationObject = JSON.parse(tuiPersonalisation)
      personalisationObject[key] = value
    } else {
      var personalisationObject = {}
      personalisationObject[key] = value
    }
    localStorage.setItem('tuiPersonalisation', JSON.stringify(personalisationObject))
  }

  var getSessionStorageValue = function(key) {
    return sessionStorage.getItem(key)
  }

  var setSessionStorageValue = function (key, value) {
    sessionStorage.setItem(key, value)
  }

  return {
    getLocalStorageValue: function(key) {
      return getLocalStorageValue(key)
    },
    setLocalStorageValue: function(key, value) {
      return setLocalStorageValue(key, value)
    },
    getSessionStorageValue: function (key) {
      return getSessionStorageValue(key)
    },
    setSessionStorageValue: function (key, value) {
      return setSessionStorageValue(key, value)
    }
  }
})(window, document)
{{#not queryParams.dontRenderScriptTags}}</script>{{/not}}
