{"version":3,"sources":["webpack://@flarum/pusher/webpack/bootstrap","webpack://@flarum/pusher/external \"flarum.core.compat['app']\"","webpack://@flarum/pusher/external \"flarum.core.compat['extend']\"","webpack://@flarum/pusher/external \"flarum.core.compat['components/DiscussionList']\"","webpack://@flarum/pusher/external \"flarum.core.compat['components/IndexPage']\"","webpack://@flarum/pusher/external \"flarum.core.compat['components/DiscussionPage']\"","webpack://@flarum/pusher/external \"flarum.core.compat['components/Button']\"","webpack://@flarum/pusher/./src/forum/index.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","flarum","core","compat","app","initializers","add","loadPusher","Promise","resolve","$","getScript","socket","Pusher","forum","attribute","authEndpoint","cluster","auth","headers","session","csrfToken","channels","main","subscribe","user","id","pusher","pushedUpdates","extend","DiscussionList","then","binding","data","params","discussions","getParams","q","sort","filter","tags","tag","store","getBy","tagIds","indexOf","String","discussionId","current","push","matches","IndexPage","setTitleCount","length","redraw","unbind","vdom","count","children","unshift","Button","component","className","onclick","attrs","state","refresh","loadingUpdated","loading","this","translator","trans","returned","discussion","index","splice","DiscussionPage","stream","oldCount","commentCount","find","update","document","hasFocus","Math","max","window","one","items","remove","pushAttributes","unreadNotificationCount","newNotificationCount","notifications","clear"],"mappings":"2BACE,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,QA0Df,OArDAF,EAAoBQ,EAAIF,EAGxBN,EAAoBS,EAAIV,EAGxBC,EAAoBU,EAAI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IAAIgD,cAAcgC,KAAKC,IAAI,EAAG,EAAKZ,WAAWM,eAAiBD,IAE/DpE,EAAE4E,QAAQC,IAAI,SAAS,kBAAMnF,IAAIgD,cAAc,oBAQ3DvB,iBAAO+C,IAAe/E,UAAW,YAAY,WAC3CO,IAAIuB,OAAOI,MAAK,SAAAC,GACdA,EAAQL,OAAO4B,OAAO,iBAI1B1B,iBAAOsB,IAAUtD,UAAW,eAAe,SAAA2F,GACzCA,EAAMC,OAAO,cAGfrF,IAAIuB,OAAOI,MAAK,SAAAC,GACd,IAAMV,EAAWU,EAAQV,SAErBA,EAASG,MACXH,EAASG,KAAKhC,KAAK,gBAAgB,WACjCW,IAAIgB,QAAQK,KAAKiE,eAAe,CAC9BC,wBAAyBvF,IAAIgB,QAAQK,KAAKkE,0BAA4B,EACtEC,qBAAsBxF,IAAIgB,QAAQK,KAAKmE,uBAAyB,IAElExF,IAAIyF,cAAcC,QAClBzH,EAAEiF","file":"forum.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 = 6);\n","module.exports = flarum.core.compat['app'];","module.exports = flarum.core.compat['extend'];","module.exports = flarum.core.compat['components/DiscussionList'];","module.exports = flarum.core.compat['components/IndexPage'];","module.exports = flarum.core.compat['components/DiscussionPage'];","module.exports = flarum.core.compat['components/Button'];","/*global Pusher*/\n\nimport { extend } from 'flarum/extend';\nimport app from 'flarum/app';\nimport DiscussionList from 'flarum/components/DiscussionList';\nimport DiscussionPage from 'flarum/components/DiscussionPage';\nimport IndexPage from 'flarum/components/IndexPage';\nimport Button from 'flarum/components/Button';\n\napp.initializers.add('flarum-pusher', () => {\n const loadPusher = new Promise((resolve) => {\n $.getScript('//cdn.jsdelivr.net/npm/pusher-js@7.0.3/dist/web/pusher.min.js', () => {\n const socket = new Pusher(app.forum.attribute('pusherKey'), {\n authEndpoint: app.forum.attribute('apiUrl') + '/pusher/auth',\n cluster: app.forum.attribute('pusherCluster'),\n auth: {\n headers: {\n 'X-CSRF-Token': app.session.csrfToken\n }\n }\n });\n\n return resolve({\n channels: {\n main: socket.subscribe('public'),\n user: app.session.user ? socket.subscribe('private-user' + app.session.user.id()) : null\n },\n pusher: socket\n });\n });\n });\n\n app.pusher = loadPusher;\n app.pushedUpdates = [];\n\n extend(DiscussionList.prototype, 'oncreate', function() {\n app.pusher.then(binding => {\n const pusher = binding.pusher;\n\n pusher.bind('newPost', data => {\n const params = app.discussions.getParams();\n\n if (!params.q && !params.sort && !params.filter) {\n if (params.tags) {\n const tag = app.store.getBy('tags', 'slug', params.tags);\n\n if (data.tagIds.indexOf(tag.id()) === -1) return;\n }\n\n const id = String(data.discussionId);\n\n if ((!app.current.get('discussion') || id !== app.current.get('discussion').id()) && app.pushedUpdates.indexOf(id) === -1) {\n app.pushedUpdates.push(id);\n\n if (app.current.matches(IndexPage)) {\n app.setTitleCount(app.pushedUpdates.length);\n }\n\n m.redraw();\n }\n }\n });\n });\n });\n\n extend(DiscussionList.prototype, 'onremove', function () {\n app.pusher.then(binding => {\n binding.pusher.unbind('newPost');\n });\n });\n\n extend(DiscussionList.prototype, 'view', function(vdom) {\n if (app.pushedUpdates) {\n const count = app.pushedUpdates.length;\n\n if (count) {\n vdom.children.unshift(\n Button.component({\n className: 'Button Button--block DiscussionList-update',\n onclick: () => {\n this.attrs.state.refresh(false).then(() => {\n this.loadingUpdated = false;\n app.pushedUpdates = [];\n app.setTitleCount(0);\n m.redraw();\n });\n this.loadingUpdated = true;\n },\n loading: this.loadingUpdated\n }, app.translator.trans('flarum-pusher.forum.discussion_list.show_updates_text', { count }))\n );\n }\n }\n });\n\n // Prevent any newly-created discussions from triggering the discussion list\n // update button showing.\n // TODO: Might be better pause the response to the push updates while the\n // composer is loading? idk\n extend(DiscussionList.prototype, 'addDiscussion', function(returned, discussion) {\n const index = app.pushedUpdates.indexOf(discussion.id());\n\n if (index !== -1) {\n app.pushedUpdates.splice(index, 1);\n }\n\n if (app.current.matches(IndexPage)) {\n app.setTitleCount(app.pushedUpdates.length);\n }\n\n m.redraw();\n });\n\n extend(DiscussionPage.prototype, 'oncreate', function() {\n app.pusher.then(binding => {\n const pusher = binding.pusher;\n\n pusher.bind('newPost', data => {\n const id = String(data.discussionId);\n\n if (this.discussion && this.discussion.id() === id && this.stream) {\n const oldCount = this.discussion.commentCount();\n\n app.store.find('discussions', this.discussion.id()).then(() => {\n this.stream.update().then(m.redraw);\n\n if (!document.hasFocus()) {\n app.setTitleCount(Math.max(0, this.discussion.commentCount() - oldCount));\n\n $(window).one('focus', () => app.setTitleCount(0));\n }\n });\n }\n });\n });\n });\n\n extend(DiscussionPage.prototype, 'onremove', function () {\n app.pusher.then(binding => {\n binding.pusher.unbind('newPost');\n });\n });\n\n extend(IndexPage.prototype, 'actionItems', items => {\n items.remove('refresh');\n });\n\n app.pusher.then(binding => {\n const channels = binding.channels;\n\n if (channels.user) {\n channels.user.bind('notification', () => {\n app.session.user.pushAttributes({\n unreadNotificationCount: app.session.user.unreadNotificationCount() + 1,\n newNotificationCount: app.session.user.newNotificationCount() + 1\n });\n app.notifications.clear();\n m.redraw();\n });\n }\n });\n});\n"],"sourceRoot":""}