{"version":3,"file":"Main.js","sources":["../../Private/Assets/Helper/MediaInit.js","../../Private/Assets/Helper/triggerEvent.js","../../Private/Assets/Audio/Embed.js","../../Private/Assets/Helper/addEvent.js","../../Private/Assets/Helper/getAriaLabel.js","../../Private/Assets/Video/Embed.js","../../Private/Assets/Helper/Lightbox.js","../../Private/Assets/Video/Lightbox.js","../../Private/Assets/Helper/iFrame.js","../../Private/Assets/Youtube/Preview.js","../../Private/Assets/Vimeo/Embed.js","../../Private/Assets/Vimeo/Lightbox.js","../../Private/Assets/Youtube/Embed.js","../../Private/Assets/Youtube/Lightbox.js"],"sourcesContent":["const BASE = 'jonnitto-prettyembed';\nconst INIT_CLASS = `${BASE}--init`;\nconst SLIM_CLASS = `${BASE}--slim`;\nconst PLAY_CLASS = `${BASE}--play`;\n\nconst VIDEOS = Array.from(document.querySelectorAll(`.${BASE}--video video:not([autoplay])`));\nconst AUDIOS = Array.from(document.querySelectorAll(`.${BASE}--audio audio:not([autoplay])`));\nconst ELEMENTS = [].concat(VIDEOS, AUDIOS);\n\nfunction init(element, autoplay = true, callback) {\n const CLASS_LIST = element.parentNode.classList;\n if (CLASS_LIST.contains(INIT_CLASS)) {\n return;\n }\n\n if (typeof callback == 'function') {\n callback();\n }\n\n if (element.hasAttribute('data-controls')) {\n element.setAttribute('controls', true);\n }\n\n if (!element.hasAttribute('controls')) {\n CLASS_LIST.add(SLIM_CLASS);\n element.addEventListener('click', () => {\n const play = !CLASS_LIST.contains(PLAY_CLASS);\n CLASS_LIST[play ? 'add' : 'remove'](PLAY_CLASS);\n if (play) {\n element.play();\n } else {\n element.pause();\n }\n });\n }\n\n if (element.hasAttribute('data-streaming')) {\n const SRC = element.getAttribute('data-streaming');\n if (element.canPlayType('application/vnd.apple.mpegurl')) {\n element.src = SRC;\n addClassAndPlay(element, autoplay, CLASS_LIST);\n } else {\n if (typeof Hls === 'undefined') {\n const HLS_SCRIPT = document.createElement('script');\n HLS_SCRIPT.src = '/_Resources/Static/Packages/Jonnitto.PrettyEmbedHelper/Scripts/Hls.js?v=1';\n document.head.appendChild(HLS_SCRIPT);\n HLS_SCRIPT.addEventListener('load', () => {\n setTimeout(() => {\n loadHls(element, SRC);\n addClassAndPlay(element, autoplay, CLASS_LIST);\n }, 100);\n });\n } else {\n loadHls(element, SRC);\n addClassAndPlay(element, autoplay, CLASS_LIST);\n }\n }\n } else {\n addClassAndPlay(element, autoplay, CLASS_LIST);\n }\n}\n\nfunction addClassAndPlay(element, autoplay, classList) {\n classList.add(INIT_CLASS);\n if (autoplay) {\n classList.add(PLAY_CLASS);\n setTimeout(() => {\n element.play();\n }, 0);\n }\n}\n\nfunction pause(elements = ELEMENTS, current = null) {\n elements.forEach((element) => {\n if (element != current) {\n if (!element.hasAttribute('controls')) {\n element.parentNode.classList.remove(PLAY_CLASS);\n }\n element.pause();\n }\n });\n}\n\nfunction loadHls(element, src) {\n if (Hls.isSupported()) {\n const HLS = new Hls();\n HLS.loadSource(src);\n HLS.attachMedia(element);\n }\n}\n\nELEMENTS.forEach((element) => {\n element.addEventListener('play', (event) => {\n pause(ELEMENTS, event.target);\n });\n});\n\nexport { init, pause };\n","export default function (options) {\n let event;\n if (!options) {\n options = {};\n }\n if (window.CustomEvent) {\n event = new CustomEvent('prettyembed', { detail: options });\n } else {\n event = document.createEvent('CustomEvent');\n event.initCustomEvent('prettyembed', true, true, options);\n }\n document.dispatchEvent(event);\n}\n","import { init } from '../Helper/MediaInit';\nimport triggerEvent from '../Helper/triggerEvent';\n\nconst elements = document.querySelectorAll('.jonnitto-prettyembed--audio audio');\nArray.from(elements).forEach((element) => {\n init(element, false);\n triggerEvent({\n type: 'audio',\n style: 'inline',\n src: (() => {\n const SOURCE = element.querySelector('source');\n return SOURCE ? SOURCE.src : null;\n })(),\n });\n});\n","function matches(element, selector) {\n return (\n element.matches ||\n element.matchesSelector ||\n element.msMatchesSelector ||\n element.mozMatchesSelector ||\n element.webkitMatchesSelector ||\n element.oMatchesSelector\n ).call(element, selector);\n}\n\nfunction closest(element, selector) {\n let ancestor = element;\n\n do {\n if (matches(ancestor, selector)) {\n return ancestor;\n }\n ancestor = ancestor.parentElement || ancestor.parentNode;\n } while (ancestor !== null && ancestor.nodeType === 1);\n return null;\n}\n\nexport default function (selector, callback) {\n document.documentElement.addEventListener('click', (event) => {\n const ELEMENT = closest(event.target, selector);\n if (!ELEMENT || typeof callback != 'function') {\n return;\n }\n callback.call(ELEMENT, event);\n });\n}\n","export default function (node) {\n return node.getAttribute('aria-label');\n}\n","import { init } from '../Helper/MediaInit';\nimport addEvent from '../Helper/addEvent';\nimport triggerEvent from '../Helper/triggerEvent';\nimport getAriaLabel from '../Helper/getAriaLabel';\n\nconst SELECTOR = '.jonnitto-prettyembed--video.jonnitto-prettyembed--inline video';\n\naddEvent(SELECTOR, function (event) {\n event.preventDefault();\n init(this, true, () => {\n triggerEvent({\n type: 'video',\n style: 'inline',\n title: getAriaLabel(this),\n src: (() => {\n const SOURCE = this.querySelector('source');\n return SOURCE ? SOURCE.src : null;\n })(),\n });\n });\n});\n","import addEvent from './addEvent';\n\nconst HTML_ELEMENT = document.documentElement;\nconst BODY_ELEMENT = document.body;\nconst BASE_CLASS = 'jonnitto-prettyembed';\nconst LIGHTBOX_CLASS = `${BASE_CLASS}__lightbox`;\nconst ID = LIGHTBOX_CLASS;\nconst VISIBLE_CLASS = `-${LIGHTBOX_CLASS}`;\nconst VISIBLE_CLASS_LIST = HTML_ELEMENT.classList;\nconst INNER_CLASS = `${BASE_CLASS}__inner`;\nconst CLOSE_CLASS = `${BASE_CLASS}__close`;\nconst CONTENT_CLASS = `${BASE_CLASS}__content`;\nconst LIGHTBOX = document.createElement('div');\n\nLIGHTBOX.className = LIGHTBOX_CLASS;\nLIGHTBOX.innerHTML = `\n