{"version":3,"sources":["components/queryManager.js","components/cookieManager.js","components/localManager.js","components/sessionManager.js"],"names":["dmx","Component","initialData","data","attributes","methods","set","key","value","this","setQueryParam","remove","render","node","update","query","window","location","search","substr","hash","indexOf","split","reduce","part","p","replace","decodeURIComponent","clone","useHistory","history","pushState","pathname","buildQuery","Object","keys","qs","encodeURIComponent","name","options","setCookie","expires","document","cookie","pos","test","path","String","escape","Date","now","toUTCString","domain","secure","requestUpdate","localStorage","setItem","JSON","stringify","getData","removeItem","parse","getItem","sessionStorage"],"mappings":";;;;;;AAAAA,IAAAC,UAAA,gBAAA,CAEAC,YAAA,CACAC,KAAA,IAGAC,WAAA,GAEAC,QAAA,CACAC,IAAA,SAAAC,EAAAC,GACAC,KAAAC,cAAAH,EAAAC,IAGAG,OAAA,SAAAJ,GACAE,KAAAC,cAAAH,KAIAK,OAAA,SAAAC,GACAJ,KAAAK,UAGAA,OAAA,WACA,IAAAC,EAAA,GAEAC,OAAAC,SAAAC,OACAH,EAAAC,OAAAC,SAAAC,OAAAC,OAAA,GACAH,OAAAC,SAAAG,KAAAC,QAAA,OACAN,EAAAC,OAAAC,SAAAG,KAAAD,OAAAH,OAAAC,SAAAG,KAAAC,QAAA,KAAA,IACAA,QAAA,OACAN,EAAAA,EAAAI,OAAA,EAAAJ,EAAAM,QAAA,OAIAZ,KAAAH,IAAA,OAAAS,EAAAO,MAAA,KAAAC,OAAA,SAAApB,EAAAqB,GACA,IAAAC,EAAAD,EAAAE,QAAA,MAAA,KAAAJ,MAAA,KAIA,OAHAG,EAAA,KACAtB,EAAAwB,mBAAAF,EAAA,KAAAE,mBAAAF,EAAA,IAAA,KAEAtB,GACA,MAGAO,cAAA,SAAAH,EAAAC,GACA,IAAAL,EAAAH,IAAA4B,MAAAnB,KAAAN,KAAAA,MAEA,MAAAK,SACAL,EAAAI,GAEAJ,EAAAI,GAAAC,EAGAR,IAAA6B,WACAb,OAAAc,QAAAC,UAAA,KAAA,KAAAf,OAAAC,SAAAe,SAA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agement.js","sourcesContent":["dmx.Component('query-manager', {\r\n\r\n initialData: {\r\n data: {}\r\n },\r\n\r\n attributes: {},\r\n\r\n methods: {\r\n set: function(key, value) {\r\n this.setQueryParam(key, value);\r\n },\r\n\r\n remove: function(key) {\r\n this.setQueryParam(key);\r\n }\r\n },\r\n\r\n render: function(node) {\r\n this.update();\r\n },\r\n\r\n update: function() {\r\n var query = '';\r\n\r\n if (window.location.search) {\r\n query = window.location.search.substr(1);\r\n } else if (window.location.hash.indexOf('?')) {\r\n query = window.location.hash.substr(window.location.hash.indexOf('?') + 1);\r\n if (query.indexOf('#')) {\r\n query = query.substr(0, query.indexOf('#'));\r\n }\r\n }\r\n\r\n this.set('data', query.split('&').reduce(function(data, part) {\r\n var p = part.replace(/\\+/g, ' ').split('=');\r\n if (p[0]) {\r\n data[decodeURIComponent(p[0])] = decodeURIComponent(p[1] || '');\r\n }\r\n return data;\r\n }, {}));\r\n },\r\n\r\n setQueryParam: function(key, value) {\r\n var data = dmx.clone(this.data.data);\r\n\r\n if (value == null) {\r\n delete data[key];\r\n } else {\r\n data[key] = value;\r\n }\r\n\r\n if (dmx.useHistory) {\r\n window.history.pushState(null, null, window.location.pathname + '?' + this.buildQuery(data));\r\n } else {\r\n window.location.hash = window.location.hash.substr(1).replace(/(\\?.*)?$/, '?' + this.buildQuery(data));\r\n }\r\n\r\n this.set('data', data);\r\n },\r\n\r\n buildQuery: function(query) {\r\n return Object.keys(query).reduce(function(qs, key) {\r\n if (qs) qs += '&';\r\n qs += encodeURIComponent(key) + '=' + encodeURIComponent(query[key]);\r\n return qs;\r\n }, '');\r\n }\r\n\r\n});\r\n","dmx.Component('cookie-manager', {\r\n\r\n initialData: {\r\n data: {}\r\n },\r\n\r\n attributes: {},\r\n\r\n methods: {\r\n set: function(name, value, options) {\r\n this.setCookie(name, value, options);\r\n },\r\n\r\n remove: function(name, options) {\r\n options = options || {};\r\n options.expires = '1970-01-01T00:00:00Z';\r\n this.setCookie(name, '', options);\r\n }\r\n },\r\n\r\n render: function(node) {\r\n this.update();\r\n },\r\n\r\n update: function() {\r\n this.set('data', document.cookie.split(/;\\s*/).reduce(function(data, cookie) {\r\n var pos = cookie.indexOf('=');\r\n data[decodeURIComponent(cookie.substr(0, pos))] = decodeURIComponent(cookie.substr(pos + 1));\r\n return data;\r\n }, {}));\r\n },\r\n\r\n setCookie: function(name, value, options) {\r\n if (!name || /^(?:expires|max\\-age|path|domain|secure)$/i.test(name)) {\r\n return false;\r\n }\r\n\r\n options = options || {};\r\n options.path = options.path || '/';\r\n\r\n // escaping taken from:\r\n // https://github.com/js-cookie/js-cookie/blob/master/src/js.cookie.js\r\n name = encodeURIComponent(String(name));\r\n\t\tname = name.replace(/%(23|24|26|2B|5E|60|7C)/g, decodeURIComponent);\r\n\t\tname = name.replace(/[\\(\\)]/g, escape);\r\n\r\n value = encodeURIComponent(String(value));\r\n value = value.replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g, decodeURIComponent);\r\n\r\n var cookie = name + '=' + value;\r\n\r\n if (options.expires) {\r\n if (typeof options.expires == 'number') {\r\n options.expires = Date.now() + (options.expires * 86400000);\r\n }\r\n cookie += '; expires=' + (new Date(options.expires)).toUTCString();\r\n }\r\n\r\n if (options.domain) {\r\n cookie += '; domain=' + options.domain;\r\n }\r\n\r\n if (options.path) {\r\n cookie += '; path=' + options.path;\r\n }\r\n\r\n if (options.secure) {\r\n cookie += '; secure';\r\n }\r\n\r\n document.cookie = cookie;\r\n\r\n dmx.requestUpdate();\r\n }\r\n\r\n});\r\n","dmx.Component('local-manager', {\r\n\r\n initialData: {\r\n data: {}\r\n },\r\n\r\n attributes: {},\r\n\r\n methods: {\r\n set: function(key, value) {\r\n window.localStorage.setItem('dmxState-' + key, JSON.stringify(value));\r\n this.getData();\r\n },\r\n\r\n remove: function(key) {\r\n window.localStorage.removeItem('dmxState-' + key);\r\n this.getData();\r\n }\r\n },\r\n\r\n render: function(node) {\r\n this.getData();\r\n },\r\n\r\n getData: function() {\r\n this.set('data', Object.keys(window.localStorage).reduce(function(data, key) {\r\n if (/^dmxState-/.test(key)) {\r\n data[key.substr(9)] = JSON.parse(window.localStorage.getItem(key));\r\n }\r\n\r\n return data;\r\n }, {}));\r\n }\r\n\r\n});\r\n","dmx.Component('session-manager', {\r\n\r\n initialData: {\r\n data: {}\r\n },\r\n\r\n attributes: {},\r\n\r\n methods: {\r\n set: function(key, value) {\r\n window.sessionStorage.setItem('dmxState-' + key, JSON.stringify(value));\r\n this.getData();\r\n },\r\n\r\n remove: function(key) {\r\n window.sessionStorage.removeItem('dmxState-' + key);\r\n this.getData();\r\n }\r\n },\r\n\r\n render: function(node) {\r\n this.getData();\r\n },\r\n\r\n getData: function() {\r\n this.set('data', Object.keys(window.sessionStorage).reduce(function(data, key) {\r\n if (/^dmxState-/.test(key)) {\r\n data[key.substr(9)] = JSON.parse(window.sessionStorage.getItem(key));\r\n }\r\n\r\n return data;\r\n }, {}));\r\n }\r\n\r\n});\r\n"]}