(function(n){typeof define=="function"&&define.amd?define(["jquery"],n):typeof exports=="object"?n(require("jquery")):n(jQuery)})(function(n){function i(t){var s=arguments.length,e=window[t],u=arguments,f=u[1],o,i,c,r,h;if(s<2)throw new Error("Minimum 2 arguments must be given");else{if(n.isArray(f)){i={};for(r in f){o=f[r];try{i[o]=JSON.parse(e.getItem(o))}catch(l){i[o]=e.getItem(o)}}return i}if(s==2)try{return JSON.parse(e.getItem(f))}catch(l){return e.getItem(f)}else{try{i=JSON.parse(e.getItem(f))}catch(l){throw new ReferenceError(f+" is not defined in this storage");}for(r=2;r1?i.apply(this,e):h,r&&r._cookie)for(f in n.cookie())f!=""&&u.push(f.replace(r._prefix,""));else for(o in r)u.push(o);return u}function a(t){if(!t||typeof t!="string")throw new Error("First parameter must be a string");e?(window.localStorage.getItem(t)||window.localStorage.setItem(t,"{}"),window.sessionStorage.getItem(t)||window.sessionStorage.setItem(t,"{}")):(window.localCookieStorage.getItem(t)||window.localCookieStorage.setItem(t,"{}"),window.sessionCookieStorage.getItem(t)||window.sessionCookieStorage.setItem(t,"{}"));var i={localStorage:n.extend({},n.localStorage,{_ns:t}),sessionStorage:n.extend({},n.sessionStorage,{_ns:t})};return n.cookie&&(window.cookieStorage.getItem(t)||window.cookieStorage.setItem(t,"{}"),i.cookieStorage=n.extend({},n.cookieStorage,{_ns:t})),n.namespaceStorages[t]=i,i}function y(n){var t="jsapi";try{return window[n]?(window[n].setItem(t,t),window[n].removeItem(t),!0):!1}catch(i){return!1}}var o="ls_",s="ss_",e=y("localStorage"),t={_type:"",_ns:"",_callMethod:function(n,t){var i=[this._type],t=Array.prototype.slice.call(t),r=t[0];return this._ns&&i.push(this._ns),typeof r=="string"&&r.indexOf(".")!==-1&&(t.shift(),[].unshift.apply(t,r.split("."))),[].push.apply(i,t),n.apply(this,i)},get:function(){return this._callMethod(i,arguments)},set:function(){var f=arguments.length,e=arguments,t=e[0],i,r;if(f<1||!n.isPlainObject(t)&&f<2)throw new Error("Minimum 2 arguments must be given or first parameter must be an object");if(n.isPlainObject(t)&&this._ns){for(i in t)u(this._type,this._ns,i,t[i]);return t}return r=this._callMethod(u,e),this._ns?r[t.split(".")[0]]:r},remove:function(){if(arguments.length<1)throw new Error("Minimum 1 argument must be given");return this._callMethod(h,arguments)},removeAll:function(n){return this._ns?(u(this._type,this._ns,{}),!0):v(this._type,n)},isEmpty:function(){return this._callMethod(c,arguments)},isSet:function(){if(arguments.length<1)throw new Error("Minimum 1 argument must be given");return this._callMethod(l,arguments)},keys:function(){return this._callMethod(f,arguments)}},r;n.cookie&&(window.name||(window.name=Math.floor(Math.random()*1e8)),r={_cookie:!0,_prefix:"",_expires:null,_path:null,_domain:null,setItem:function(t,i){n.cookie(this._prefix+t,i,{expires:this._expires,path:this._path,domain:this._domain})},getItem:function(t){return n.cookie(this._prefix+t)},removeItem:function(t){return n.removeCookie(this._prefix+t)},clear:function(){for(var t in n.cookie())t!=""&&(!this._prefix&&t.indexOf(o)===-1&&t.indexOf(s)===-1||this._prefix&&t.indexOf(this._prefix)===0)&&n.removeCookie(t)},setExpires:function(n){return this._expires=n,this},setPath:function(n){return this._path=n,this},setDomain:function(n){return this._domain=n,this},setConf:function(n){return n.path&&(this._path=n.path),n.domain&&(this._domain=n.domain),n.expires&&(this._expires=n.expires),this},setDefaultConf:function(){this._path=this._domain=this._expires=null}},e||(window.localCookieStorage=n.extend({},r,{_prefix:o,_expires:3650}),window.sessionCookieStorage=n.extend({},r,{_prefix:s+window.name+"_"})),window.cookieStorage=n.extend({},r),n.cookieStorage=n.extend({},t,{_type:"cookieStorage",setExpires:function(n){return window.cookieStorage.setExpires(n),this},setPath:function(n){return window.cookieStorage.setPath(n),this},setDomain:function(n){return window.cookieStorage.setDomain(n),this},setConf:function(n){return window.cookieStorage.setConf(n),this},setDefaultConf:function(){return window.cookieStorage.setDefaultConf(),this}}));n.initNamespaceStorage=function(n){return a(n)};e?(n.localStorage=n.extend({},t,{_type:"localStorage"}),n.sessionStorage=n.extend({},t,{_type:"sessionStorage"})):(n.localStorage=n.extend({},t,{_type:"localCookieStorage"}),n.sessionStorage=n.extend({},t,{_type:"sessionCookieStorage"}));n.namespaceStorages={};n.removeAllStorages=function(t){n.localStorage.removeAll(t);n.sessionStorage.removeAll(t);n.cookieStorage&&n.cookieStorage.removeAll(t);t||(n.namespaceStorages={})}})