{"version":3,"file":"autoplayfallback.component.bundle.js","sources":["../../../../node_modules/lozad/dist/lozad.es.js","../../../../Frontend/utils/videoSourceInit.util.ts","../../../../Frontend/js/components/autoplayfallback.component.ts"],"sourcesContent":["/*! lozad.js - v1.16.0 - 2020-09-06\n* https://github.com/ApoorvSaxena/lozad.js\n* Copyright (c) 2020 Apoorv Saxena; Licensed MIT */\n\n\n/**\n * Detect IE browser\n * @const {boolean}\n * @private\n */\nconst isIE = typeof document !== 'undefined' && document.documentMode;\n\nconst defaultConfig = {\n rootMargin: '0px',\n threshold: 0,\n load(element) {\n if (element.nodeName.toLowerCase() === 'picture') {\n let img = element.querySelector('img');\n let append = false;\n\n if (img === null) {\n img = document.createElement('img');\n append = true;\n }\n\n if (isIE && element.getAttribute('data-iesrc')) {\n img.src = element.getAttribute('data-iesrc');\n }\n\n if (element.getAttribute('data-alt')) {\n img.alt = element.getAttribute('data-alt');\n }\n\n if (append) {\n element.append(img);\n }\n }\n\n if (element.nodeName.toLowerCase() === 'video' && !element.getAttribute('data-src')) {\n if (element.children) {\n const childs = element.children;\n let childSrc;\n for (let i = 0; i <= childs.length - 1; i++) {\n childSrc = childs[i].getAttribute('data-src');\n if (childSrc) {\n childs[i].src = childSrc;\n }\n }\n\n element.load();\n }\n }\n\n if (element.getAttribute('data-poster')) {\n element.poster = element.getAttribute('data-poster');\n }\n\n if (element.getAttribute('data-src')) {\n element.src = element.getAttribute('data-src');\n }\n\n if (element.getAttribute('data-srcset')) {\n element.setAttribute('srcset', element.getAttribute('data-srcset'));\n }\n\n let backgroundImageDelimiter = ',';\n if (element.getAttribute('data-background-delimiter')) {\n backgroundImageDelimiter = element.getAttribute('data-background-delimiter');\n }\n\n if (element.getAttribute('data-background-image')) {\n element.style.backgroundImage = `url('${element.getAttribute('data-background-image').split(backgroundImageDelimiter).join('\\'),url(\\'')}')`;\n } else if (element.getAttribute('data-background-image-set')) {\n const imageSetLinks = element.getAttribute('data-background-image-set').split(backgroundImageDelimiter);\n let firstUrlLink = (imageSetLinks[0].substr(0, imageSetLinks[0].indexOf(' ')) || imageSetLinks[0]); // Substring before ... 1x\n firstUrlLink = firstUrlLink.indexOf('url(') === -1 ? `url(${firstUrlLink})` : firstUrlLink;\n if (imageSetLinks.length === 1) {\n element.style.backgroundImage = firstUrlLink;\n } else {\n element.setAttribute('style', (element.getAttribute('style') || '') + `background-image: ${firstUrlLink}; background-image: -webkit-image-set(${imageSetLinks}); background-image: image-set(${imageSetLinks})`);\n }\n }\n\n if (element.getAttribute('data-toggle-class')) {\n element.classList.toggle(element.getAttribute('data-toggle-class'));\n }\n },\n loaded() {}\n};\n\nfunction markAsLoaded(element) {\n element.setAttribute('data-loaded', true);\n}\n\nfunction preLoad(element) {\n if (element.getAttribute('data-placeholder-background')) {\n element.style.background = element.getAttribute('data-placeholder-background');\n }\n}\n\nconst isLoaded = element => element.getAttribute('data-loaded') === 'true';\n\nconst onIntersection = (load, loaded) => (entries, observer) => {\n entries.forEach(entry => {\n if (entry.intersectionRatio > 0 || entry.isIntersecting) {\n observer.unobserve(entry.target);\n\n if (!isLoaded(entry.target)) {\n load(entry.target);\n markAsLoaded(entry.target);\n loaded(entry.target);\n }\n }\n });\n};\n\nconst getElements = (selector, root = document) => {\n if (selector instanceof Element) {\n return [selector]\n }\n\n if (selector instanceof NodeList) {\n return selector\n }\n\n return root.querySelectorAll(selector)\n};\n\nfunction lozad (selector = '.lozad', options = {}) {\n const {root, rootMargin, threshold, load, loaded} = Object.assign({}, defaultConfig, options);\n let observer;\n\n if (typeof window !== 'undefined' && window.IntersectionObserver) {\n observer = new IntersectionObserver(onIntersection(load, loaded), {\n root,\n rootMargin,\n threshold\n });\n }\n\n const elements = getElements(selector, root);\n for (let i = 0; i < elements.length; i++) {\n preLoad(elements[i]);\n }\n\n return {\n observe() {\n const elements = getElements(selector, root);\n\n for (let i = 0; i < elements.length; i++) {\n if (isLoaded(elements[i])) {\n continue\n }\n\n if (observer) {\n observer.observe(elements[i]);\n continue\n }\n\n load(elements[i]);\n markAsLoaded(elements[i]);\n loaded(elements[i]);\n }\n },\n triggerLoad(element) {\n if (isLoaded(element)) {\n return\n }\n\n load(element);\n markAsLoaded(element);\n loaded(element);\n },\n observer\n }\n}\n\nexport default lozad;\n","export function videoSourceInit(source: HTMLIFrameElement) {\r\n const src = new URL(source.src)\r\n // checks for source (youtube needs different attributes)\r\n if (\r\n src.hostname.includes(\"youtube.com\") ||\r\n src.hostname.includes(\"youtu.be\") ||\r\n src.hostname.includes(\"youtube-nocookie.com\")\r\n ) {\r\n src.searchParams.set(\"autoplay\", \"1\")\r\n src.searchParams.set(\"modestbranding\", \"1\")\r\n src.searchParams.set(\"mute\", \"1\")\r\n src.searchParams.set(\"controls\", \"0\")\r\n src.searchParams.set(\"showinfo\", \"0\")\r\n src.searchParams.set(\"loop\", \"1\")\r\n src.searchParams.set(\"enablejsapi\", \"1\")\r\n const videoId = src.pathname.split(\"/\").pop()\r\n if (videoId) {\r\n src.searchParams.set(\"playlist\", videoId)\r\n }\r\n } else if (src.hostname.includes(\"vimeo.com\")) {\r\n src.searchParams.set(\"autoplay\", \"1\")\r\n src.searchParams.set(\"muted\", \"1\")\r\n src.searchParams.set(\"controls\", \"0\")\r\n src.searchParams.set(\"loop\", \"1\")\r\n src.searchParams.set(\"dnt\", \"1\")\r\n }\r\n\r\n source.src = src.toString()\r\n}\r\n","import lozad from \"lozad\"\r\nimport { videoSourceInit } from \"../../utils/videoSourceInit.util\"\r\n\r\n// TODO er worden momenteel veel calls gemaakt in youtube later stadium bekijken\r\nexport const autoPlay = (): void => {\r\n const video = document.getElementById(\"backgroundVideo\") as HTMLIFrameElement\r\n const thumbnail = document.querySelector(\"#thumbnail\") as HTMLPictureElement\r\n\r\n if (video) {\r\n const playPauseButton = document.getElementById(\"playPauseButton\")\r\n const observer = lozad(\".lozad\", {\r\n loaded: function () {\r\n if (thumbnail) {\r\n setTimeout(() => {\r\n thumbnail.classList.add(\"lg:hidden\")\r\n }, 300)\r\n }\r\n },\r\n })\r\n observer.observe()\r\n observer.triggerLoad(video)\r\n\r\n if (video.getAttribute(\"data-initialized\") === \"true\") return\r\n\r\n video.setAttribute(\"data-initialized\", \"true\") // Set initialized flag so it runs only once\r\n\r\n videoSourceInit(video)\r\n\r\n // Attempt to play the video manually if autoplay fails\r\n video.addEventListener(\"load\", () => {\r\n const videoWindow = video.contentWindow\r\n if (videoWindow) {\r\n playPauseButton?.classList.remove(\"play\", \"hidden\")\r\n playPauseButton?.classList.add(\"pause\")\r\n\r\n if (video.src.includes(\"vimeo.com\")) {\r\n videoWindow.postMessage('{\"method\":\"play\"}', \"https://vimeo.com\")\r\n } else if (video.src.includes(\"youtube\")) {\r\n videoWindow.postMessage('{\"event\":\"command\",\"func\":\"playVideo\",\"args\":\"\"}', \"https://youtube.com\")\r\n }\r\n }\r\n })\r\n }\r\n}\r\n"],"names":["isIE","defaultConfig","element","img","append","childs","childSrc","backgroundImageDelimiter","imageSetLinks","firstUrlLink","markAsLoaded","preLoad","isLoaded","onIntersection","load","loaded","entries","observer","entry","getElements","selector","root","lozad","options","rootMargin","threshold","elements","i","videoSourceInit","source","src","videoId","autoPlay","video","thumbnail","playPauseButton","videoWindow"],"mappings":"AAAA;AAAA;AAAA,mDAUA,MAAMA,EAAO,OAAO,SAAa,KAAe,SAAS,aAEnDC,EAAgB,CACpB,WAAY,MACZ,UAAW,EACX,KAAKC,EAAS,CACZ,GAAIA,EAAQ,SAAS,YAAW,IAAO,UAAW,CAChD,IAAIC,EAAMD,EAAQ,cAAc,KAAK,EACjCE,EAAS,GAETD,IAAQ,OACVA,EAAM,SAAS,cAAc,KAAK,EAClCC,EAAS,IAGPJ,GAAQE,EAAQ,aAAa,YAAY,IAC3CC,EAAI,IAAMD,EAAQ,aAAa,YAAY,GAGzCA,EAAQ,aAAa,UAAU,IACjCC,EAAI,IAAMD,EAAQ,aAAa,UAAU,GAGvCE,GACFF,EAAQ,OAAOC,CAAG,CAE1B,CAEI,GAAID,EAAQ,SAAS,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