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AYgB,KAAKC,MACjBd,IACA5F,OAAO6G,SAAWP,GAAAA,CAASM,EAAgB,M,eC3C7C5G,OAAO8G,eAAiB,CAACvE,EAAG,EAAG8B,EAAG,GAClCrE,OAAO+G,SAAW,KAElB,IAAMC,EAAO,SAAC3G,GACRL,OAAOiH,cACT5G,EAAE6G,iBACF7G,EAAE8G,YAAc,WAET9G,EAAC,aAIZpB,SAASC,iBAAiB,oBAAqB8H,GAO/C9H,iBAAiB,eAAgB8H,GACjC9H,iBAAiB,4BAPW,WAC1B,IAAIC,EAAQF,SAASmI,YAAY,UACjCjI,EAAMkI,UAAU,qBAAqB,GAAM,GAC3CpI,SAASqI,cAAcnI,MAMzBF,SAASC,iBAAiB,2BAA2B,WACnDc,OAAO8G,eAAiB,CAACvE,EAAGvC,OAAOuH,QAASlD,EAAGrE,OAAOwH,SACtDxH,OAAO+G,SAAW/G,OAAO8B,SAASC,QACjC,GAGH9C,SAASC,iBAAiB,mBAAmB,WAEvCc,OAAO8G,gBAAmBW,KAAK3F,SAASC,MAAQ/B,OAAO+G,UAEzD/G,OAAO0H,SAAS1H,OAAO8G,eAAevE,EAAGvC,OAAO8G,eAAezC,MAEhE,GAEHrE,OAAO2H,WAAa,WAClB1I,SAAS+F,KAAKC,UAAUC,IAAI,iB","sources":["webpack://daff2/./app/packs/entrypoints/guest.js","webpack://daff2/./app/packs/lib/discussion.js","webpack://daff2/./app/packs/lib/esc.js","webpack://daff2/./app/packs/lib/is_visible.js","webpack://daff2/./app/packs/lib/popup.js","webpack://daff2/./app/packs/lib/reads.js","webpack://daff2/./app/packs/lib/setup.js"],"sourcesContent":["/* eslint no-console:0 */\n// This file is automatically compiled by Webpack, along with any other files\n// present in this directory. You're encouraged to place your actual application logic in\n// a relevant structure within app/packs and only use these pack files to reference\n// that code so it'll be compiled.\n//\n// To reference this file, add <%= javascript_pack_tag 'application' %> to the appropriate\n// layout file, like app/views/layouts/application.html.erb\n\n// Uncomment to copy all static images under ../images to the output folder and reference\n// them with the image_pack_tag helper in views (e.g <%= image_pack_tag 'rails.png' %>)\n// or the `imagePath` JavaScript helper below.\n//\n// const images = require.context('../images', true)\n// const imagePath = (name) => images(name, true)\n\n// import 'core-js/stable'\n// import 'regenerator-runtime/runtime'\nconst Rails = require(\"@rails/ujs\")\nRails.start();\nrequire(\"turbolinks\").start()\n// require(\"@rails/activestorage\").start()\n// import Pusher from 'pusher-js';\n// import { setupDiscussionSeen } from './ununseen.js';\n// import * as ActiveStorage from \"@rails/activestorage\"\n// ActiveStorage.start()\nimport { setupReads } from '../lib/reads.js';\n// import { setupEditor } from './editor.js';\nimport '../lib/esc.js';\nimport '../lib/popup.js';\n// import debounce from 'debounce'\nimport { setupDiscussion } from '../lib/discussion.js'\n\nimport '../lib/setup.js'\nconst setup = (event) => {\n // setupDiscussion();\n // setupDiscussionSeen();\n setupReads();\n // setupEditor();\n}\ndocument.addEventListener(\"turbolinks:load\", setup); \n","const Rails = require(\"@rails/ujs\")\nimport ClipboardJS from 'clipboard';\n\nlet channel;\nlet userChannel;\nlet subscribedDiscussionRoom;\nconst racs = ['group_chats#show','chats#show', 'posts#show', 'papers#show', 'challenges#show'];\nconst pracs = ['posts#show', 'papers#show', 'challenges#show']\nfunction pusherNotificationsBoardSetup() {\n if (!window.pusherClient) return false;\n let st;\n const nb = document.querySelector('.notifications_board');\n const uc = document.getElementById('unseen_count');\n if (!userChannel) {\n userChannel = window.pusherClient.subscribe('user-' + window.currentUserId);\n // console.log('userChannel', userChannel);\n userChannel.bind('unseenCount', function(m) {\n uc.innerHTML = m.count;\n uc.style.display = 'block';\n // if (nb.innerHTML !== '') uc.click();\n // if (document.querySelector(`[data-message-id=\"${m.id}\"]`)) return false;\n // console.log('fetching');\n // fetch(`/users/${m.id}/notifications`).then(function (response) {\n // // The API call was successful!\n // return response.text();\n // }).then(function (html) {\n // nb.innerHTML = html;\n // nb.style.display = 'flex';\n // }).catch(function (err) {\n // // There was an error\n // console.warn('Something went wrong.', err);\n // });\n });\n }\n\n}\nconst scrollDownDiscussion = function() {\n const dmo = document.querySelector('.discussion_messages');\n if (dmo) dmo.scrollTop = dmo.scrollHeight;\n}\nwindow.scrollDownDiscussion = scrollDownDiscussion;\n\nfunction pusherDiscussionsSetup() {\n if (!window.pusherClient) return false;\n let st;\n if (!racs.includes(window.rac)) return;\n if (channel && subscribedDiscussionRoom) st = true;\n if (st) channel.unsubscribe(subscribedDiscussionRoom);\n subscribedDiscussionRoom = window.discussionId+'';\n channel = window.pusherClient.subscribe(subscribedDiscussionRoom);\n // console.log('listen11');\n if (!st) {\n channel.bind('newMsg', function(m) {\n console.log('newMsg', m);\n if (document.querySelector(`[data-message-id=\"${m.id}\"]`)) return false;\n console.log('fetching');\n fetch(location.href).then(function (response) {\n // The API call was successful!\n return response.text();\n }).then(function (html) {\n\n // Convert the HTML string into a document object\n \n const parser = new DOMParser();\n const doc = parser.parseFromString(html, 'text/html');\n const x = (pracs.includes(window.rac)) ? '.post_comments' : '.discussion_messages';\n const dm = doc.querySelector(x);\n const dmo = document.querySelector(x);\n dmo.innerHTML = dm.innerHTML;\n scrollDownDiscussion();\n }).catch(function (err) {\n // There was an error\n console.warn('Something went wrong.', err);\n });\n });\n }\n}\n\n\nconst setupCommentForm = () => {\n const cf = document.querySelector('#message_content');\n cf.focus();\n cf.addEventListener('keyup', (e) => {\n if (e.keyCode == 13) {\n // if (e.shiftKey === true)\n if (e.shiftKey) // thruthy\n {\n // new line\n }\n else\n {\n e.stopPropagation(); \n Rails.fire(e.target.form, 'submit');\n // run your function\n }\n return false;\n }\n });\n}\nconst setupPusher = () => {\n if (window.currentUserId && !window.pusherClient) {\n window.pusherClient = new Pusher(window.pusherKey, {\n cluster: 'eu',\n forceTLS: true\n });\n }\n}\n\nconst setupDiscussion = () => {\n new ClipboardJS('.link_to_add_users');\n new ClipboardJS('.link_to_add_users_btn');\n const dmo = document.querySelector('.discussion_messages');\n if (dmo) dmo.scrollTop = dmo.scrollHeight;\n if (dmo) setupCommentForm();\n setupPusher();\n pusherDiscussionsSetup();\n pusherNotificationsBoardSetup();\n\n // document.querySelector('.group-chat-token').addEventListener('click', (e) => { copy(e.value) });\n}\nexport { setupDiscussion }\n","document.onkeydown = function(evt) {\n evt = evt || window.event;\n var isEscape = false;\n if (\"key\" in evt) {\n isEscape = (evt.key === \"Escape\" || evt.key === \"Esc\");\n } else {\n isEscape = (evt.keyCode === 27);\n }\n if (isEscape) {\n window.removePopoup();\n }\n};\n","function isVisible(elem) {\n if (!(elem instanceof Element)) throw Error('DomUtil: elem is not an element.');\n const style = getComputedStyle(elem);\n if (style.display === 'none') return false;\n if (style.visibility !== 'visible') return false;\n if (style.opacity < 0.1) return false;\n if (elem.offsetWidth + elem.offsetHeight + elem.getBoundingClientRect().height +\n elem.getBoundingClientRect().width === 0) {\n return false;\n }\n const elemCenter = {\n x: elem.getBoundingClientRect().left + elem.offsetWidth / 2,\n y: elem.getBoundingClientRect().top + elem.offsetHeight / 2\n };\n if (elemCenter.x < 0) return false;\n if (elemCenter.x > (document.documentElement.clientWidth || window.innerWidth)) return false;\n if (elemCenter.y < 0) return false;\n if (elemCenter.y > (document.documentElement.clientHeight || window.innerHeight)) return false;\n let pointContainer = document.elementFromPoint(elemCenter.x, elemCenter.y);\n do {\n if (pointContainer === elem) return true;\n } while (pointContainer = pointContainer.parentNode);\n return false;\n}\n\n\nexports.isVisible = isVisible;\n","window.withPopoup = () => {\n document.body.classList.add('with_popup');\n document.querySelector('.wrappy').addEventListener('click', window.removePopoup);\n}\nwindow.removePopoup = () => {\n document.body.classList.remove('with_popup')\n document.querySelector('.wrappy').removeEventListener('click', window.removePopoup);\n};\nwindow.randomlyShowPopup = () => { \n if (Math.random() < 0.10) {\n setTimeout(window.withPopoup, 1000);\n }\n}\n","import debounce from 'debounce'\nimport { isVisible } from './is_visible.js'\n\nlet startTime;\nlet writerProfile;\nlet sendReadDone;\nlet sendRead = function(status) {\n fetch(`/reads`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({...{ read: window.readPms}, ...{status: status}})\n });\n}\nconst allowAction = ['papers#show', 'blog_posts#show']; //, 'challenges#show']\nlet radingy = function() {\n if (sendReadDone) return console.log('dondon');\n \n if (!allowAction.includes(window.rac)) return;\n // let offset = d.scrollTop + window.innerHeight;\n\n let mri_ = window.mri * 0.2; // allow speed reading\n let time_since_page_load = (Date.now() - startTime) / 60000;\n if (time_since_page_load < mri_) return;\n if (!isVisible(writerProfile)) return;\n sendRead('done');\n sendReadDone = true;\n};\n\nlet debouncedRadingy = debounce(radingy, 200);\n\nfunction scrollFunction() {\n debouncedRadingy();\n // if (!bottomNav) return;\n // if (document.body.scrollTop > 130 || document.documentElement.scrollTop > 130) {\n // bottomNav.className = 'main_nav topi';\n // } else {\n // bottomNav.className = 'main_nav';\n // }\n}\nconst setupReads = () => { \n sendReadDone = false;\n writerProfile = document.querySelector('.writer_profile')\n startTime = Date.now()\n sendRead();\n window.onscroll = debounce(scrollFunction, 30)\n}\nexport { setupReads };\n","// Turbolinks.scroll = {};\n\n// Obviously doesn't need to be on window\nwindow.scrollPosition = {x: 0, y: 0} // Our 'old' scroll position\nwindow.lastHref = null // Our 'old' page href\n\nconst koko = (e) => {\n if (window.didntSaveYet) {\n e.preventDefault();\n e.returnValue = '';\n } else {\n delete e['returnValue'];\n }\n}\n\ndocument.addEventListener('turbolinks:unload', koko);\nconst dispatchUnloadEvent = function() {\n let event = document.createEvent(\"Events\")\n event.initEvent(\"turbolinks:unload\", true, false)\n document.dispatchEvent(event)\n}\n\naddEventListener(\"beforeunload\", koko);\naddEventListener(\"turbolinks:before-render\", dispatchUnloadEvent)\n//i Before visit, simply store scroll position & url/href\ndocument.addEventListener('turbolinks:before-visit', function () {\n window.scrollPosition = {x: window.scrollX, y: window.scrollY}\n window.lastHref = window.location.href\n}, false)\n\n// After load\ndocument.addEventListener('turbolinks:load', function () {\n // If we have a scroll position AND we're on the same page\n if (window.scrollPosition && (this.location.href == window.lastHref)) {\n // Scroll to our previous position\n window.scrollTo(window.scrollPosition.x, window.scrollPosition.y)\n }\n}, false)\n\nwindow.firstLogin = () => {\n document.body.classList.add('with_popup');\n}\n// document.addEventListener(\"DOMContentLoaded\", setup); \n\n\n"],"names":["require","start","document","addEventListener","event","setupReads","channel","userChannel","subscribedDiscussionRoom","Rails","racs","pracs","scrollDownDiscussion","dmo","querySelector","scrollTop","scrollHeight","window","setupDiscussion","ClipboardJS","cf","focus","e","keyCode","shiftKey","stopPropagation","fire","target","form","currentUserId","pusherClient","Pusher","pusherKey","cluster","forceTLS","st","includes","rac","unsubscribe","discussionId","subscribe","bind","m","console","log","id","fetch","location","href","then","response","text","html","doc","DOMParser","parseFromString","x","dm","innerHTML","err","warn","pusherDiscussionsSetup","uc","getElementById","count","style","display","pusherNotificationsBoardSetup","onkeydown","evt","key","removePopoup","exports","elem","Element","Error","getComputedStyle","visibility","opacity","offsetWidth","offsetHeight","getBoundingClientRect","height","width","elemCenter","left","y","top","documentElement","clientWidth","innerWidth","clientHeight","innerHeight","pointContainer","elementFromPoint","parentNode","withPopoup","body","classList","add","remove","removeEventListener","randomlyShowPopup","Math","random","setTimeout","startTime","writerProfile","sendReadDone","sendRead","status","method","headers","JSON","stringify","read","readPms","allowAction","debouncedRadingy","debounce","mri_","mri","Date","now","isVisible","scrollFunction","onscroll","scrollPosition","lastHref","koko","didntSaveYet","preventDefault","returnValue","createEvent","initEvent","dispatchEvent","scrollX","scrollY","this","scrollTo","firstLogin"],"sourceRoot":""}