"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("lodash/set"),t=require("lodash/get"),r=require("lodash/unset"),a=require("moment");function l(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var i=l(e),o=l(t),n=l(r),u=l(a),s=function(e){return e.expiry?e.value:e};function f(e){if("string"==typeof e)localStorage.removeItem(e);else if(Array.isArray(e)&&e.length){var t=JSON.parse(localStorage.getItem(e[0]));n.default(t,e.slice(1)),localStorage.setItem(e[0],JSON.stringify(t))}}function g(e,t){var r,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,l=arguments.length>3?arguments[3]:void 0,o=a&&a.length?{value:t,expiry:u.default().add(a[0],a[1])}:t;if("string"==typeof e?(r=o,localStorage.setItem(e,JSON.stringify(r))):Array.isArray(e)&&e.length&&(r=JSON.parse(localStorage.getItem(e[0]))||{},i.default(r,e.slice(1),o),localStorage.setItem(e[0],JSON.stringify(r))),r&&"function"==typeof l){var n=s(r);l(n)}}var c=function(e,t){var r=e;return Array.isArray(e)?(g(t,r=e.filter((function(e){return!e.expiry||u.default().diff(e.expiry)<0}))),r.map((function(e){return e.value}))):(e&&e.expiry&&u.default().diff(e.expiry)>0&&(f(t),r=void 0),r)};exports.deleteValue=f,exports.getValue=function(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if("string"==typeof e)t=JSON.parse(localStorage.getItem(e));else if(Array.isArray(e)&&e.length){var a=JSON.parse(localStorage.getItem(e[0]));t=o.default(a,e.slice(1))}var l=c(t,e);return void 0!==l?l:r},exports.pushValue=function(e,t){var r,a,l=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,n=arguments.length>3?arguments[3]:void 0,f=l&&l.length?{value:t,expiry:u.default().add(l[0],l[1])}:t;if("string"==typeof e?((a=JSON.parse(localStorage.getItem(e))||[]).push(f),localStorage.setItem(e,a)):Array.isArray(e)&&e.length&&(r=JSON.parse(localStorage.getItem(e[0]))||{},(a=o.default(r,e.slice(1),[])).push(f),i.default(r,e.slice(1),a),localStorage.setItem(e[0],JSON.stringify(r))),a&&"function"==typeof n){var g=a.map((function(e){return s(e)}));n(g)}},exports.setValue=g;
