{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./resources/assets/js/alert.js"],"names":["installedModules","__webpack_require__","moduleId","exports","module","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","ctx","audioContextSupported","audioLocked","alertNotification","window","AudioContext","webkitAudioContext","notifications","requestDesktopNotificationPermission","Notification","permission","requestPermission","sendDesktopNotification","id","title","text","cb","notification","icon","body","onclose","this","$","document","on","e","url","$is_mobile","price","html","trim","$hsymbol","close","buzz","getAudioContext","context","Promise","resolve","reject","state","unlock","resume","then","removeEventListener","reason","addEventListener","unlocked","console","log","all","play","error","bell","checkCtxState","css","setTimeout","fixAlertSounds","links","getElementsByClassName","z","length","addLinksCallback"],"mappings":"aACE,IAAIA,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUC,QAGnC,IAAIC,EAASJ,EAAiBE,GAAY,CACzCG,EAAGH,EACHI,GAAG,EACHH,QAAS,IAUV,OANAI,EAAQL,GAAUM,KAAKJ,EAAOD,QAASC,EAAQA,EAAOD,QAASF,GAG/DG,EAAOE,GAAI,EAGJF,EAAOD,QAKfF,EAAoBQ,EAAIF,EAGxBN,EAAoBS,EAAIV,EAGxBC,EAAoBU,EAAI,SAASR,EAASS,EAAMC,GAC3CZ,EAAoBa,EAAEX,EAASS,IAClCG,OAAOC,eAAeb,EAASS,EAAM,CAAEK,YAAY,EAAMC,IAAKL,KAKhEZ,EAAoBkB,EAAI,SAAShB,GACX,oBAAXiB,QAA0BA,OAAOC,aAC1CN,OAAOC,eAAeb,EAASiB,OAAOC,YAAa,CAAEC,MAAO,WAE7DP,OAAOC,eAAeb,EAAS,aAAc,CAAEmB,OAAO,KAQvDrB,EAAoBsB,EAAI,SAASD,EAAOE,GAEvC,GADU,EAAPA,IAAUF,EAAQrB,EAAoBqB,IAC/B,E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QAAS,OAElBC,WAAWF,EAAe,MAE1BD,EAAKE,IAAI,QAAS,KAK9BD,GAqCAG,IAxGJ,WAGI,IAFA,IAAMC,EAAQlC,SAASmC,uBAAuB,cAEtCC,EAAI,EAAGA,EAAIF,EAAMG,OAAQD,IAChBF,EAAME,GAEdd,iBAAiB,SAAS,WAC3B1C,EAAkBK,0CACnB,GAuGXqD","file":"/js/alert.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"/\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 2);\n","(function() {\n    const audioContextSupported = (window.AudioContext || window.webkitAudioContext);\n\n    let ctx, audioLocked = true;\n\n    const alertNotification = {\n        notifications: {},\n\n        requestDesktopNotificationPermission: function() {\n            if(Notification && Notification.permission === 'default') {\n                Notification.requestPermission(function (permission) {\n                    if(!('permission' in Notification)) {\n                        Notification.permission = permission;\n                    }\n                });\n            }\n        },\n\n        sendDesktopNotification: function(id, title, text, cb) {\n            const notification = new Notification(title, {\n                icon: 'https://bitcoinwisdom.io/apple-touch-icon-152x152.png',\n                body: text\n            });\n\n            notification.onclose = function() {\n                if(cb && typeof cb === \"function\") {\n                    cb();\n                }\n            };\n\n            this.notifications[id] = notification;\n\n    //    setTimeout(notification.close.bind(notification), 5000);\n        }\n    };\n\n    function addLinksCallback() {\n        const links = document.getElementsByClassName(\"link_alarm\");\n\n        for(let z = 0; z < links.length; z++) {\n            const elem = links[z];\n\n            elem.addEventListener('click', function() {\n                alertNotification.requestDesktopNotificationPermission();\n            }, false);\n        }\n    }\n\n    function webAudioTouchUnlock(context) {\n        return new Promise(function (resolve, reject) {\n            if (context.state === 'suspended') {\n                const unlock = function () {\n                    context.resume().then(function () {\n                            window.removeEventListener('keydown', unlock);\n                            document.body.removeEventListener('touchstart', unlock);\n                            document.body.removeEventListener('touchend', unlock);\n                            document.body.removeEventListener('touchmove', unlock);\n                            document.body.removeEventListener('mouseup', unlock);\n\n                            resolve(true);\n                        },\n                        function (reason) {\n                            reject(reason);\n                        });\n                };\n\n                window.addEventListener('keydown', unlock, false);\n                document.body.addEventListener('touchstart', unlock, false);\n                document.body.addEventListener('touchend', unlock, false);\n                document.body.addEventListener('touchmove', unlock, false);\n                document.body.addEventListener('mouseup', unlock, false);\n            } else {\n                // meaning it never was locked\n                resolve(false);\n            }\n        });\n    }\n\n    function fixAlertSounds() {\n        webAudioTouchUnlock(ctx).then(function (unlocked) {\n            audioLocked = false;\n\n            console.log(\"unlocked AudioContext\", unlocked);\n\n            window.buzz.all().play();\n        }, function(reason) {\n            console.error(reason);\n        });\n\n        const bell = $(\".link_alarm .icon-bell\");\n\n        function checkCtxState() {\n            if(ctx) {\n                if(audioLocked) {\n                    bell.css(\"color\", \"red\");\n\n                    setTimeout(checkCtxState, 500);\n                } else {\n                    bell.css(\"color\", \"\");\n                }\n            }\n        }\n\n        checkCtxState();\n    }\n\n    $(document).on( \"buzz.js.play\", {}, function(e, url) {\n        if(window.$is_mobile) {\n            // Failed to construct 'Notification': Illegal constructor. Use ServiceWorkerRegistration.showNotification() instead.\n            return;\n        }\n\n        if (Notification && Notification.permission === 'granted') {\n            var title, text;\n            var price = $(\"#price\").html().trim();\n\n            if(url === \"/assets/high\") {\n                title = window.$hsymbol + \" reached \" + price;\n            } else if(url === \"/assets/low\") {\n                title = window.$hsymbol + \" dropped to \" + price;\n            }\n\n            text = 'Price: ' + price;\n\n            alertNotification.sendDesktopNotification(url, title, text, function() {\n                // todo: stop sound\n            });\n        }\n    });\n\n    $(document).on( \"buzz.js.stop\", {}, function(url) {\n        if(alertNotification.notifications[url]) {\n            alertNotification.notifications[url].close();\n        }\n    });\n\n    if(audioContextSupported) {\n        // this line leads to sound freeze on FF... sometimes\n        ctx = window.buzz.getAudioContext();\n\n        fixAlertSounds();\n    }\n\n    //if(!ctx && audioContextSupported) {\n    //    ctx = new (window.AudioContext || window.webkitAudioContext)();\n    //}\n\n    addLinksCallback();\n\n    //$(document).ready(function() {});\n})();"],"sourceRoot":""}