{"version":3,"file":"ScrollToTop-f84a4b35.js","names":["define","Moduler","create","defaults","template","topThreshold","offsetBottom","init","self","this","scroller","utils","bind","onScroll","window","addEventListener","requestAnimationFrame","setTimeout","scrollY","options","ensureExists","document","querySelector","exists","isShown","body","insertAdjacentHTML","e","preventDefault","scrollTo","top","behavior","scrollButton","innerWidth","notice","offsetWidth","offsetHeight","classList","add","appendChild","elem","length","querySelectorAll","forEach","o","getBoundingClientRect","height","style","bottom","remove"],"sources":["ScrollToTop.js"],"mappings":"AAAAA,OAAO,CAAC,YAAY,SAAUC,GAC7B,aAEA,OAAOA,EAAQC,OAAO,CACrBC,SAAU,CACTC,SAAU,iEACVC,aAAc,IACdC,aAAc,wBAGfC,KAAM,WACL,IAAIC,EAAOC,KACPC,EAAWT,EAAQU,MAAMC,KAAKJ,EAAKK,SAAUL,GACjDM,OAAOC,iBAAiB,UAAU,WAChCD,OAAOE,uBAAyBA,sBAAsBN,IAAcO,WAAWP,EAAU,IAAO,GAClG,IAEII,OAAOI,SAAWV,EAAKW,QAAQd,eACjCS,OAAOE,uBAAyBA,sBAAsBN,IAAcO,WAAWP,EAAU,IAAO,IAEnG,EAEAU,aAAc,WACb,IAAIZ,EAAOC,KACNY,SAASC,cAAc,kBAC3Bd,EAAKe,QAAS,EACdf,EAAKgB,SAAU,GAEXhB,EAAKe,SACTF,SAASI,KAAKC,mBAAmB,YAAalB,EAAKW,QAAQf,UAE3DiB,SAASC,cAAc,gBAAgBP,iBAAiB,SAAS,SAAUY,GAC1EA,EAAEC,iBACFd,OAAOe,SAAS,CACfC,IAAK,EACLC,SAAU,UAEZ,IAEAvB,EAAKe,QAAS,EAEhB,EAEAV,SAAU,WACT,IAAIL,EAAOC,KAEXD,EAAKY,eACL,IAAIY,EAAeX,SAASC,cAAc,gBAC1C,GAAKU,EAIL,GAAIlB,OAAOI,SAAWV,EAAKW,QAAQd,aAAc,CAChD,GAAIS,OAAOmB,WAAa,IAAK,CAC5B,IAAIC,EAASb,SAASC,cAAc,0BAChCY,IAAWA,EAAOC,YAAc,GAAKD,EAAOE,aAAe,KAC9DJ,EAAaK,UAAUC,IAAI,6BAC3BJ,EAAOK,YAAYP,GAErB,CACA,IAAKxB,EAAKgB,QAAS,CAClBhB,EAAKY,eACL,IAAIoB,EAAOnB,SAASC,cAAc,gBAElC,GAAId,EAAKW,QAAQb,cAAcmC,OAAS,EAAG,CAC1C,IAAInC,EAAe,EACnBe,SAASqB,iBAAiBlC,EAAKW,QAAQb,cAAcqC,SAAQC,IAC5DtC,GAAgBsC,EAAEC,wBAAwBC,MAAM,IAEjDN,EAAKO,MAAMC,OAAS1C,EAAe,IACpC,CAEAkC,EAAKH,UAAUC,IAAI,YACnB9B,EAAKgB,SAAU,CAChB,CACD,MACKhB,EAAKgB,UACJV,OAAOmB,WAAa,MACvBD,EAAaK,UAAUY,OAAO,6BAC9B5B,SAASI,KAAKc,YAAYP,IAE3BX,SAASC,cAAc,gBAAgBe,UAAUY,OAAO,YACxDzC,EAAKgB,SAAU,EAGlB,GAEF","sourcesContent":["define(['moduler'], function (Moduler) {\r\n\t'use strict';\r\n\r\n\treturn Moduler.create({\r\n\t\tdefaults: {\r\n\t\t\ttemplate: '',\r\n\t\t\ttopThreshold: 150, // how far from top to display the button\r\n\t\t\toffsetBottom: '.Status--fixedBottom' // use a selector to offset the reference from the bottom by the height of the elements\r\n\t\t},\r\n\r\n\t\tinit: function () {\r\n\t\t\tvar self = this;\r\n\t\t\tvar scroller = Moduler.utils.bind(self.onScroll, self);\r\n\t\t\twindow.addEventListener('scroll', function () {\r\n\t\t\t\t(window.requestAnimationFrame && requestAnimationFrame(scroller)) || setTimeout(scroller, 1000 / 60);\r\n\t\t\t});\r\n\r\n\t\t\tif (window.scrollY >= self.options.topThreshold) {\r\n\t\t\t\t(window.requestAnimationFrame && requestAnimationFrame(scroller)) || setTimeout(scroller, 1000 / 60);\r\n\t\t\t}\r\n\t\t},\r\n\r\n\t\tensureExists: function () {\r\n\t\t\tvar self = this;\r\n\t\t\tif (!document.querySelector('.ScrollToTop')) {\r\n\t\t\t\tself.exists = false;\r\n\t\t\t\tself.isShown = false;\r\n\t\t\t}\r\n\t\t\tif (!self.exists) {\r\n\t\t\t\tdocument.body.insertAdjacentHTML(\"beforeend\", self.options.template);\r\n\r\n\t\t\t\tdocument.querySelector('.ScrollToTop').addEventListener('click', function (e) {\r\n\t\t\t\t\te.preventDefault();\r\n\t\t\t\t\twindow.scrollTo({\r\n\t\t\t\t\t\ttop: 0,\r\n\t\t\t\t\t\tbehavior: \"smooth\"\r\n\t\t\t\t\t});\r\n\t\t\t\t});\r\n\r\n\t\t\t\tself.exists = true;\r\n\t\t\t}\r\n\t\t},\r\n\r\n\t\tonScroll: function () {\r\n\t\t\tvar self = this;\r\n\r\n\t\t\tself.ensureExists();\r\n\t\t\tvar scrollButton = document.querySelector('.ScrollToTop');\r\n\t\t\tif (!scrollButton) {\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\r\n\t\t\tif (window.scrollY >= self.options.topThreshold) {\r\n\t\t\t\tif (window.innerWidth < 768) {\r\n\t\t\t\t\tvar notice = document.querySelector('.Status--visitorNotice');\r\n\t\t\t\t\tif (notice && (notice.offsetWidth > 0 || notice.offsetHeight > 0)) {\r\n\t\t\t\t\t\tscrollButton.classList.add('ScrollToTop--withinNotice');\r\n\t\t\t\t\t\tnotice.appendChild(scrollButton);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tif (!self.isShown) {\r\n\t\t\t\t\tself.ensureExists();\r\n\t\t\t\t\tlet elem = document.querySelector('.ScrollToTop');\r\n\r\n\t\t\t\t\tif (self.options.offsetBottom?.length > 0) {\r\n\t\t\t\t\t\tlet offsetBottom = 0;\r\n\t\t\t\t\t\tdocument.querySelectorAll(self.options.offsetBottom).forEach(o => {\r\n\t\t\t\t\t\t\toffsetBottom += o.getBoundingClientRect().height;\r\n\t\t\t\t\t\t});\r\n\t\t\t\t\t\telem.style.bottom = offsetBottom + 'px';\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\telem.classList.add('is-shown');\r\n\t\t\t\t\tself.isShown = true;\r\n\t\t\t\t}\r\n\t\t\t} else {\r\n\t\t\t\tif (self.isShown) {\r\n\t\t\t\t\tif (window.innerWidth < 768) {\r\n\t\t\t\t\t\tscrollButton.classList.remove('ScrollToTop--withinNotice');\r\n\t\t\t\t\t\tdocument.body.appendChild(scrollButton);\r\n\t\t\t\t\t}\r\n\t\t\t\t\tdocument.querySelector('.ScrollToTop').classList.remove('is-shown');\r\n\t\t\t\t\tself.isShown = false;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t});\r\n});"]}