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I,KAAKsE,MAAMb,GAAG4E,MAAS,QAAOrI,KAAKsE,MAAMvB,gBAAgB/C,KAAKsE,MAAMG,kBAAkBzE,KAAKsE,MAAMI,oBAAoB1E,KAAKsE,MAAMtB,WACpI,EAKG,SAASsF,EAAWC,GACvBA,EAASC,SAASC,IAEQ,IAAlBA,EAAK5G,UACL,IAAI0B,EAAekF,EACvB,GAER,C","sources":["webpack://Chaos Karts/./node_modules/debounce/index.js","webpack://Chaos Karts/../src/throttle.js","webpack://Chaos Karts/../src/index.js","webpack://Chaos Karts/./wwwroot/app/src/js/hero-video-vimeo.js"],"sourcesContent":["/**\n * Returns a function, that, as long as it continues to be invoked, will not\n * be triggered. The function will be called after it stops being called for\n * N milliseconds. If `immediate` is passed, trigger the function on the\n * leading edge, instead of the trailing. The function also has a property 'clear' \n * that is a function which will clear the timer to prevent previously scheduled executions. \n *\n * @source underscore.js\n * @see http://unscriptable.com/2009/03/20/debouncing-javascript-methods/\n * @param {Function} function to wrap\n * @param {Number} timeout in ms (`100`)\n * @param {Boolean} whether to execute at the beginning (`false`)\n * @api public\n */\nfunction debounce(func, wait, immediate){\n var timeout, args, context, timestamp, result;\n if (null == wait) wait = 100;\n\n function later() {\n var last = Date.now() - timestamp;\n\n if (last < wait && last >= 0) {\n timeout = setTimeout(later, wait - last);\n } else {\n timeout = null;\n if (!immediate) {\n result = func.apply(context, args);\n context = args = null;\n }\n }\n };\n\n var debounced = function(){\n context = this;\n args = arguments;\n timestamp = Date.now();\n var callNow = immediate && !timeout;\n if (!timeout) timeout = setTimeout(later, wait);\n if (callNow) {\n result = func.apply(context, args);\n context = args = null;\n }\n\n return result;\n };\n\n debounced.clear = function() {\n if (timeout) {\n clearTimeout(timeout);\n timeout = null;\n }\n };\n \n debounced.flush = function() {\n if (timeout) {\n result = func.apply(context, args);\n context = args = null;\n \n clearTimeout(timeout);\n timeout = null;\n }\n };\n\n return debounced;\n};\n\n// Adds compatibility for ES modules\ndebounce.debounce = debounce;\n\nmodule.exports = debounce;\n","const DEFAULT_THROTTLE_INTERVAL = 100\n\n/**\n * Throttles method execution to prevent some performance bottlenecks\n * @param {Function} fn method to throttle\n * @param {Number} interval milliseconds for the method to be delayed\n */\nfunction throttle(fn, interval = DEFAULT_THROTTLE_INTERVAL) {\n let inThrottle\n let lastFunc\n let lastRan\n\n return function() {\n if (inThrottle === true) {\n clearTimeout(lastFunc)\n lastFunc = setTimeout(function() {\n if (Date.now() - lastRan >= interval) {\n fn.apply(this, arguments)\n lastRan = Date.now()\n }\n }, interval - (Date.now() - lastRan))\n } else {\n fn.apply(this, arguments)\n lastRan = Date.now()\n inThrottle = true\n }\n }\n}\n\nexport default throttle\n","import noop from './noop'\nimport throttle from './throttle'\n\n/**\n * Constructor for element that should be hunted\n * @constructor Hunted\n * @param {Node} element\n * @param {Object} config\n */\nclass Hunted {\n constructor(element, config) {\n this.element = element\n\n // instantiate element as not visible\n this.visible = false\n\n // extend properties from config or fallback to prototype values\n for (var prop in config) {\n if (Object.hasOwnProperty.call(config, prop)) {\n this[prop] = config[prop]\n }\n }\n\n // replace options with dataset if present\n if (typeof element.dataset !== 'undefined') {\n if (typeof element.dataset.huntPersist !== 'undefined') {\n try {\n this.persist = JSON.parse(element.dataset.huntPersist)\n } catch (e) {}\n }\n if (typeof element.dataset.huntOffset !== 'undefined') {\n try {\n this.offset = JSON.parse(element.dataset.huntOffset)\n } catch (e) {}\n }\n }\n }\n}\n\n// protoype values\nHunted.prototype.offset = 0\nHunted.prototype.persist = false\nHunted.prototype.enter = noop\nHunted.prototype.leave = noop\n\n/**\n * Creates and initializes observer\n * @constructor Hunt\n * @param {Node|NodeList|Array} target\n * @param {Object} options\n */\nclass Hunt {\n constructor(target, options) {\n // sanity check for first argument\n const isValidTarget =\n (target && target.nodeType === 1) || typeof target.length === 'number'\n if (!isValidTarget) {\n throw new TypeError(\n 'hunt: observer first argument should be a node or a list of nodes'\n )\n }\n // sanity check for second argument\n if (typeof options !== 'object') {\n throw new TypeError('hunt: observer second argument should be an object')\n }\n\n // turn target to array\n if (target.nodeType === 1) {\n this.__huntedElements__ = [new Hunted(target, options)]\n } else {\n const targetArray = [].slice.call(target)\n this.__huntedElements__ = targetArray.map((t) => new Hunted(t, options))\n }\n\n // hoist viewport metrics\n this.__viewportHeight__ = window.innerHeight\n\n // connect observer and pass in throttle interval\n this.__connect__(options.throttleInterval)\n }\n\n /**\n * Assign throttled actions and add listeners\n * @param {Number} throttleInterval\n * @method __connect__\n * @memberof Hunt\n */\n __connect__(throttleInterval) {\n // throttle actions\n this.__throttledHuntElements__ = throttle(\n this.__huntElements__.bind(this),\n throttleInterval\n )\n this.__throttledUpdateMetrics__ = throttle(\n this.__updateMetrics__.bind(this),\n throttleInterval\n )\n\n // add listeners\n window.addEventListener('scroll', this.__throttledHuntElements__)\n window.addEventListener('resize', this.__throttledUpdateMetrics__)\n\n // run first check\n this.__huntElements__()\n }\n\n /**\n * Checks if hunted elements are visible and apply callbacks\n * @method __huntElements__\n * @memberof Hunt\n */\n __huntElements__() {\n let position = this.__huntedElements__.length\n\n while (position) {\n --position\n const hunted = this.__huntedElements__[position]\n const rect = hunted.element.getBoundingClientRect()\n const isOnViewport =\n rect.top - hunted.offset < this.__viewportHeight__ &&\n rect.top >= -(rect.height + hunted.offset)\n\n /*\n * trigger (enter) event if element comes from a non visible state and the scrolled\n * viewport has reached the visible range of the element without exceeding it\n */\n if (hunted.visible === false && isOnViewport === true) {\n hunted.enter.call(null, hunted.element)\n hunted.visible = true\n // when the leave callback method is not set and hunting should not persist remove element\n if (hunted.leave === noop && hunted.persist !== true) {\n this.__huntedElements__.splice(position, 1)\n\n // end observer activity when there are no more elements\n if (this.__huntedElements__.length === 0) {\n this.disconnect()\n }\n }\n }\n\n /*\n * trigger (leave) event if element comes from a visible state\n * and it's out of the visible range its bottom or top limit\n */\n if (hunted.visible === true && isOnViewport === false) {\n hunted.leave.call(null, hunted.element)\n hunted.visible = false\n // when hunting should not persist remove element\n if (hunted.persist !== true) {\n this.__huntedElements__.splice(position, 1)\n\n // end observer activity when there are no more elements\n if (this.__huntedElements__.length === 0) {\n this.disconnect()\n }\n }\n }\n }\n }\n\n /**\n * Update viewport tracked height and runs a check\n * @method __updateMetrics__\n * @memberof Hunt\n */\n __updateMetrics__() {\n this.__viewportHeight__ = window.innerHeight\n this.__huntElements__()\n }\n\n /**\n * Remove listeners and stops observing elements\n * @method disconnect\n * @memberof Hunt\n */\n disconnect() {\n // remove listeners\n window.removeEventListener('scroll', this.__throttledHuntElements__)\n window.removeEventListener('resize', this.__throttledUpdateMetrics__)\n }\n\n /**\n * __huntElements__ public alias\n * @method trigger\n * @memberof Hunt\n */\n trigger() {\n this.__huntElements__()\n }\n}\n\nexport default Hunt\n","import { debounce } from 'debounce';\r\nimport hunt from 'huntjs';\r\nimport { ResizeObserver as Polyfill } from '@juggle/resize-observer';\r\nconst ResizeObserver = window.ResizeObserver || Polyfill;\r\n\r\nconst defaultPosterVideoInitDelay = 5000; // the delay, once the poster image has loaded, before we load the video iframe\r\n\r\nclass HeroVideoVimeo {\r\n\r\n constructor(el) {\r\n this.wrapper = el;\r\n this.controls = this.wrapper.querySelector('.hero--video--control');\r\n this.loadingSprite = this.wrapper.querySelector('.hero--video-loading-sprite');\r\n this.playButton = this.controls.querySelector('button.play');\r\n this.soundButton = this.controls.querySelector('button.sound');\r\n this.started = false;\r\n this.userPaused = false;\r\n this.muted = true;\r\n this.hasPoster = false;\r\n this.crossfadePoster = false;\r\n this.videoInitDelay = defaultPosterVideoInitDelay;\r\n this.inner = {\r\n poster : this.wrapper.querySelector('.hero--poster-image'),\r\n posterImg : this.wrapper.querySelector('.hero--poster-image img'),\r\n el : this.wrapper.querySelector('.hero--video-inner:first-child'),\r\n top : 0,\r\n left : 0,\r\n width : 0,\r\n height : 0\r\n }\r\n // are we dealing with a poster image?\r\n if(this.inner.posterImg != null) {\r\n this.hasPoster = true;\r\n this.inner.el.classList.add('has-poster');\r\n // crossfade?\r\n this.crossfadePoster = this.inner.poster.dataset.crossfade == 'true';\r\n if(this.crossfadePoster) this.inner.el.classList.add('crossfade-poster');\r\n // custom init delay value?\r\n let delay = parseInt(this.inner.poster.dataset.delay);\r\n if(delay > 0) this.videoInitDelay = delay;\r\n }\r\n this.ratioHeightByWidth = 9 / 16;\r\n this.ratioWidthByHeight = 16 / 9;\r\n // find video id in data attribute\r\n this.videoId = this.wrapper.dataset.heroVideoId;\r\n // add resize observer to hero element\r\n this.ro = new ResizeObserver(entries => {\r\n for (let entry of entries) {\r\n const cr = entry.contentRect;\r\n debounce(this.resize(Math.ceil(cr.width), Math.ceil(cr.height)), 200);\r\n }\r\n });\r\n this.ro.observe(this.wrapper);\r\n // init video based on poster image\r\n if(this.videoId != null) {\r\n if(this.hasPoster) {\r\n if (this.inner.posterImg.complete) {\r\n setTimeout(() => {\r\n this.loadPlayer();\r\n }, this.videoInitDelay);\r\n } else {\r\n let _this = this;\r\n this.inner.posterImg.addEventListener('load', () => {\r\n setTimeout(() => {\r\n _this.loadPlayer();\r\n }, _this.videoInitDelay);\r\n }, {once: true});\r\n }\r\n } else {\r\n this.loadPlayer();\r\n }\r\n }\r\n }\r\n\r\n async loadPlayer() {\r\n let script = document.createElement('script');\r\n script.type = 'text/javascript';\r\n script.src = 'https://player.vimeo.com/api/player.js'; \r\n script.async = true;\r\n document.head.appendChild(script);\r\n script.onload = () => {\r\n this.initVideo();\r\n };\r\n }\r\n\r\n initVideo() {\r\n // add video\r\n this.video = new Vimeo.Player(this.inner.el, {\r\n id: this.videoId,\r\n loop: true,\r\n background: true\r\n });\r\n let thisInstance = this;\r\n // hook up control button?\r\n if(this.playButton !== null) {\r\n this.playButton_play = this.playButton.querySelector('.hero--video--control--play');\r\n this.playButton_pause = this.playButton.querySelector('.hero--video--control--pause');\r\n this.playButton_pause.removeAttribute('hidden');\r\n // add behaviours\r\n this.video.on('play', ()=> {\r\n this.playButton_play.setAttribute('aria-hidden', true);\r\n this.playButton_pause.removeAttribute('aria-hidden');\r\n // fade video in when it starts playback for the first time\r\n if(!this.started) {\r\n this.inner.el.classList.add('reveal');\r\n this.controls.classList.add('reveal');\r\n if(this.loadingSprite != null) this.loadingSprite.classList.add('hidden');\r\n this.started = true;\r\n }\r\n });\r\n this.video.on('pause', ()=> {\r\n this.playButton_play.removeAttribute('aria-hidden');\r\n this.playButton_pause.setAttribute('aria-hidden', true);\r\n });\r\n this.playButton.onclick = () => {\r\n thisInstance.video.getPaused().then(function(paused) {\r\n if(!paused) {\r\n thisInstance.video.pause();\r\n thisInstance.userPaused = true;\r\n } else {\r\n thisInstance.video.play();\r\n thisInstance.userPaused = false;\r\n }\r\n });\r\n };\r\n }\r\n // hook up optional sound control button?\r\n if(this.soundButton !== null) {\r\n this.soundButton_on = this.soundButton.querySelector('.hero--video--control--sound-on');\r\n this.soundButton_off = this.soundButton.querySelector('.hero--video--control--sound-off');\r\n this.soundButton_off.removeAttribute('hidden');\r\n this.soundButton.onclick = () => {\r\n if(thisInstance.muted) {\r\n thisInstance.video.setMuted(false).then(() => {\r\n thisInstance.soundButton_on.setAttribute('aria-hidden', true);\r\n thisInstance.soundButton_off.removeAttribute('aria-hidden');\r\n thisInstance.muted = false;\r\n });\r\n } else {\r\n thisInstance.video.setMuted(true).then(() => {\r\n thisInstance.soundButton_on.removeAttribute('aria-hidden');\r\n thisInstance.soundButton_off.setAttribute('aria-hidden', true);\r\n thisInstance.muted = true;\r\n });\r\n }\r\n }\r\n }\r\n // add hunt to pause video if scrolled offscreen\r\n let fixedWrapper = document.querySelector('.hero--fixed-visual--wrapper');\r\n this.hunt = new hunt(fixedWrapper != null ? fixedWrapper : this.wrapper, {\r\n leave: function () {\r\n thisInstance.video.getPaused().then(function(paused) {\r\n if(!paused) thisInstance.video.pause();\r\n });\r\n },\r\n enter: function () {\r\n thisInstance.video.getPaused().then(function(paused) {\r\n if(paused && !thisInstance.userPaused) thisInstance.video.play();\r\n });\r\n },\r\n persist: true\r\n });\r\n }\r\n\r\n resize(getWidth, getHeight) {\r\n let ratio = getHeight/getWidth;\r\n if(ratio < this.ratioHeightByWidth) {\r\n // use full width\r\n this.inner.width = getWidth;\r\n this.inner.height = Math.ceil(getWidth * this.ratioHeightByWidth);\r\n this.inner.top = ((getHeight - this.inner.height) / 2).toFixed(1);\r\n this.inner.left = 0;\r\n } else {\r\n // use full height\r\n this.inner.height = getHeight;\r\n this.inner.width = Math.ceil(getHeight * this.ratioWidthByHeight);\r\n this.inner.top = 0;\r\n this.inner.left = ((getWidth - this.inner.width) / 2).toFixed(1);\r\n }\r\n this.inner.el.style = `top: ${this.inner.top}px; left: ${this.inner.left}px; width: ${this.inner.width}px; height: ${this.inner.height}px;`;\r\n }\r\n\r\n}\r\n\r\n// export the default function to create\r\nexport function createFrom(wrappers) {\r\n wrappers.forEach((node) => {\r\n // if node is an element\r\n if (node.nodeType === 1) {\r\n new HeroVideoVimeo(node);\r\n }\r\n });\r\n}"],"names":["debounce","func","wait","immediate","timeout","args","context","timestamp","result","later","last","Date","now","setTimeout","apply","debounced","this","arguments","callNow","clear","clearTimeout","flush","module","exports","e","n","t","i","s","o","element","visible","Object","hasOwnProperty","call","dataset","huntPersist","persist","JSON","parse","huntOffset","offset","prototype","enter","leave","nodeType","length","TypeError","__huntedElements__","slice","map","__viewportHeight__","window","innerHeight","__connect__","throttleInterval","__throttledHuntElements__","__huntElements__","bind","__throttledUpdateMetrics__","__updateMetrics__","addEventListener","getBoundingClientRect","top","height","splice","disconnect","removeEventListener","trigger","ResizeObserver","Polyfill","HeroVideoVimeo","constructor","el","wrapper","controls","querySelector","loadingSprite","playButton","soundButton","started","userPaused","muted","hasPoster","crossfadePoster","videoInitDelay","inner","poster","posterImg","left","width","classList","add","crossfade","delay","parseInt","ratioHeightByWidth","ratioWidthByHeight","videoId","heroVideoId","ro","entries","entry","cr","contentRect","resize","Math","ceil","observe","complete","loadPlayer","_this","once","async","script","document","createElement","type","src","head","appendChild","onload","initVideo","video","Vimeo","Player","id","loop","background","thisInstance","playButton_play","playButton_pause","removeAttribute","on","setAttribute","onclick","getPaused","then","paused","play","pause","soundButton_on","soundButton_off","setMuted","fixedWrapper","hunt","getWidth","getHeight","toFixed","style","createFrom","wrappers","forEach","node"],"sourceRoot":""}