@splidejs/splide-extension-video
Version:
The Splide extension for embedding videos.
21 lines (20 loc) • 33 kB
JavaScript
function St(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function qt(t,n){t.prototype=Object.create(n.prototype),e(t.prototype.constructor=t,n)}function e(t,n){return(e=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,n){return t.__proto__=n,t})(t,n)}
/*!
* Splide.js
* Version : 0.8.0
* License : MIT
* Copyright: 2022 Naotoshi Fujita
*/
var t;t=function(){"use strict";function n(t,n,e){return Array.prototype.slice.call(t,n,e)}function r(t){return t.bind.apply(t,[null].concat(n(arguments,1)))}function t(t,n){return typeof n===t}var q=Array.isArray;function o(t){return q(t)?t:[t]}function V(t,n){o(t).forEach(n)}r(t,"function"),r(t,"string"),r(t,"undefined");var N=Object.keys;function z(s){return n(arguments,1).forEach(function(e){var t=e,n=function(t,n){s[n]=e[n]},i=void 0;if(t)for(var r=N(t),r=i?r.reverse():r,o=0;o<r.length;o++){var u=r[o];if("__proto__"!==u&&!1===n(t[u],u))break}}),s}function W(){var s=[];function e(t,e,i){V(t,function(n){n&&V(e,function(t){t.split(" ").forEach(function(t){t=t.split(".");i(n,t[0],t[1])})})})}return{bind:function(t,n,o,u){e(t,n,function(t,n,e){var i="addEventListener"in t,r=i?t.removeEventListener.bind(t,n,o,u):t.removeListener.bind(t,o);i?t.addEventListener(n,o,u):t.addListener(o),s.push([t,n,e,o,r])})},unbind:function(t,n,r){e(t,n,function(n,e,i){s=s.filter(function(t){return!!(t[0]!==n||t[1]!==e||t[2]!==i||r&&t[3]!==r)||(t[4](),!1)})})},dispatch:function(t,n,e){var i;return"function"==typeof CustomEvent?i=new CustomEvent(n,{bubbles:!0,detail:e}):(i=document.createEvent("CustomEvent")).initCustomEvent(n,!0,!1,e),t.dispatchEvent(i),i},destroy:function(){s.forEach(function(t){t[4]()}),s.length=0}}}var i="dragging",L="destroy";function u(t){var e=t?t.event.bus:document.createDocumentFragment(),i=W();return t&&t.event.on(L,i.destroy),z(i,{bus:e,on:function(t,n){i.bind(e,o(t).join(" "),function(t){n.apply(n,q(t.detail)?t.detail:[])})},off:r(i.unbind,e),emit:function(t){i.dispatch(e,t,n(arguments,1))}})}function Y(t){var e=t;return{set:function(t){e=t},is:function(t){return t=o(t),n=e,-1<t.indexOf(n);var n}}}var s="splide__slide",e=s+"__container";function c(t,n,e){return Array.prototype.slice.call(t,n,e)}function a(t){return t.bind.apply(t,[null].concat(c(arguments,1)))}function f(t,n){return typeof n===t}function h(t){return!l(t)&&f("object",t)}var Q=Array.isArray,U=a(f,"function"),B=a(f,"string"),D=a(f,"undefined");function l(t){return null===t}function d(t,n){(Q(t=t)?t:[t]).forEach(n)}function v(n,t,e){n&&d(t,function(t){t&&n.classList[e?"add":"remove"](t)})}function y(t,n){v(t,B(n)?n.split(" "):n,!0)}function H(t,n){return t instanceof HTMLElement&&(t.msMatchesSelector||t.matches).call(t,n)}function J(t,n){return n?(e=n,n=(n=t)?c(n.children):[],(e?n.filter(function(t){return H(t,e)}):n)[0]):t.firstElementChild;var e}var X=Object.keys;function p(t,n,e){if(t)for(var i=X(t),i=e?i.reverse():i,r=0;r<i.length;r++){var o=i[r];if("__proto__"!==o&&!1===n(t[o],o))break}}function $(i){return c(arguments,1).forEach(function(e){p(e,function(t,n){i[n]=e[n]})}),i}function G(e){return c(arguments,1).forEach(function(t){p(t,function(t,n){Q(t)?e[n]=t.slice():h(t)?e[n]=G({},h(e[n])?e[n]:{},t):e[n]=t})}),e}function K(e,n,i){h(n)?p(n,function(t,n){K(e,n,t)}):d(e,function(t){var e;l(i)||""===i?(e=n,d(t,function(n){d(e,function(t){n&&n.removeAttribute(t)})})):t.setAttribute(n,String(i))})}function w(t,n,e){t=document.createElement(t);return n&&(B(n)?y:K)(t,n),e&&d(t,e.appendChild.bind(e)),t}function Z(t,n){var e="display";D(n)?getComputedStyle(t)[e]:l(n)||(t.style[e]=""+n)}function tt(t,n){v(t,n,!1)}var nt=Math.min,et=Math.max;Math.floor,Math.ceil,Math.abs;function it(t,n,e){var i=nt(n,e),n=et(n,e);return nt(et(i,t),n)}var rt="splide__video",m="--has-video",ot={hideControls:!1,loop:!1,mute:!1,volume:.2},ut="video:click",st=function(){function t(t,n,e){this.state=Y(1),this.event=u(),this.target=t,this.videoId=n,this.options=e||{},this.onPlay=this.onPlay.bind(this),this.onPause=this.onPause.bind(this),this.onEnded=this.onEnded.bind(this),this.onPlayerReady=this.onPlayerReady.bind(this),this.onError=this.onError.bind(this)}var n=t.prototype;return n.on=function(t,n){this.event.on(t,n)},n.play=function(){var t=this.state;if(!t.is(9))return this.event.emit("play"),t.is(2)?t.set(4):t.is(3)?(this.player=this.createPlayer(this.videoId),t.set(4)):void(t.is([4,8])||t.is(5)&&(t.set(6),this.playVideo()));console.error("[splide] Can not play this video.")},n.pause=function(){var t=this.state;if(!t.is(9))return this.event.emit("pause"),t.is(4)?t.set(2):t.is(6)?t.set(7):void(t.is(8)&&(this.pauseVideo(),this.state.set(5)))},n.isPaused=function(){return!this.state.is(8)},n.destroy=function(){this.event.destroy()},n.onPlayerReady=function(){var t=this.state,n=t.is(4);t.set(5),n&&this.play()},n.onPlay=function(){var t=this.state,n=t.is(7);t.set(8),n?this.pause():this.event.emit("played")},n.onPause=function(){this.state.set(5),this.event.emit("paused")},n.onEnded=function(){this.state.set(5),this.event.emit("ended")},n.onError=function(){this.state.set(9),this.event.emit("error")},t}(),ct=function(i){function t(t,n,e){return(t=i.call(this,t,n,e=void 0===e?{}:e)||this).state.set(3),t}qt(t,i);var n=t.prototype;return n.createPlayer=function(t){var n=this.options,e=this.options.playerOptions,e=void 0===e?{}:e,t=w("video",{src:t},this.target),i=t.addEventListener.bind(t);return $(t,{controls:!n.hideControls,loop:n.loop,volume:it(n.volume,0,1),muted:n.mute},e.htmlVideo||{}),i("play",this.onPlay),i("pause",this.onPause),i("ended",this.onEnded),i("loadeddata",this.onPlayerReady),i("error",this.onError),t},n.playVideo=function(){var t=this.player.play();t&&t.catch(this.onError.bind(this))},n.pauseVideo=function(){this.player.pause()},n.onError=function(){this.state.is(7)?this.state.set(5):i.prototype.onError.call(this)},n.destroy=function(){i.prototype.destroy.call(this);var t=this.player,t=t.addEventListener.bind(t);t("play",this.onPlay),t("pause",this.onPause),t("ended",this.onEnded),t("loadeddata",this.onPlayerReady)},t}(st);function at(t,n){for(var e=0;e<n.length;e++){var i=n[e];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}var ft="undefined"!=typeof global&&"[object global]"==={}.toString.call(global);function ht(t,n){return 0===t.indexOf(n.toLowerCase())?t:"".concat(n.toLowerCase()).concat(t.substr(0,1).toUpperCase()).concat(t.substr(1))}function b(t){return/^(https?:)?\/\/((player|www)\.)?vimeo\.com(?=$|\/)/.test(t)}function lt(t){var n,t=0<arguments.length&&void 0!==t?t:{},e=t.id,t=t.url,t=e||t;if(!t)throw new Error("An id or url must be passed, either in an options object or as a data-vimeo-id or data-vimeo-url attribute.");if(n=t,!isNaN(parseFloat(n))&&isFinite(n)&&Math.floor(n)==n)return"https://vimeo.com/".concat(t);if(b(t))return t.replace("http:","https:");if(e)throw new TypeError("“".concat(e,"” is not a valid video id."));throw new TypeError("“".concat(t,"” is not a vimeo.com url."))}var k=void 0!==Array.prototype.indexOf,g="undefined"!=typeof window&&void 0!==window.postMessage;if(!(ft||k&&g))throw new Error("Sorry, the Vimeo Player API is not available in this browser.");var dt,vt,E,yt="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function T(){if(void 0===this)throw new TypeError("Constructor WeakMap requires 'new'");if(E(this,"_id","_WeakMap_"+pt()+"."+pt()),0<arguments.length)throw new TypeError("WeakMap iterable is not supported")}function P(t,n){if(!F(t)||!dt.call(t,"_id"))throw new TypeError(n+" method called on incompatible receiver "+typeof t)}function pt(){return Math.random().toString().substring(2)}function F(t){return Object(t)===t}(
/*!
* weakmap-polyfill v2.0.4 - ECMAScript6 WeakMap polyfill
* https://github.com/polygonplanet/weakmap-polyfill
* Copyright (c) 2015-2021 polygonplanet <polygon.planet.aqua@gmail.com>
* @license MIT
*/
k="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:yt).WeakMap||(dt=Object.prototype.hasOwnProperty,vt=Object.defineProperty&&function(){try{return 1===Object.defineProperty({},"x",{value:1}).x}catch(t){}}(),k.WeakMap=((E=function(t,n,e){vt?Object.defineProperty(t,n,{configurable:!0,writable:!0,value:e}):t[n]=e})(T.prototype,"delete",function(t){var n;return P(this,"delete"),!!F(t)&&(!(!(n=t[this.t])||n[0]!==t)&&(delete t[this.t],!0))}),E(T.prototype,"get",function(t){var n;return P(this,"get"),F(t)&&(n=t[this.t])&&n[0]===t?n[1]:void 0}),E(T.prototype,"has",function(t){var n;return P(this,"has"),!!F(t)&&!(!(n=t[this.t])||n[0]!==t)}),E(T.prototype,"set",function(t,n){var e;if(P(this,"set"),F(t))return(e=t[this.t])&&e[0]===t?e[1]=n:E(t,this.t,[t,n]),this;throw new TypeError("Invalid value used as weak map key")}),E(T,"_polyfill",!0),T));(function(t){
/*! Native Promise Only
v0.8.1 (c) Kyle Simpson
MIT License: http://getify.mit-license.org
*/
var n,e,i;i=function(){var n,e,i,r,o,t=Object.prototype.toString,u="undefined"!=typeof setImmediate?function(t){return setImmediate(t)}:setTimeout;try{Object.defineProperty({},"x",{}),n=function(t,n,e,i){return Object.defineProperty(t,n,{value:e,writable:!0,configurable:!1!==i})}}catch(t){n=function(t,n,e){return t[n]=e,t}}function s(t,n){this.fn=t,this.self=n,this.next=void 0}function c(t,n){w.add(t,n),e=e||u(w.drain)}function a(t){var n,e=typeof t;return"function"==typeof(n=null==t||"object"!=e&&"function"!=e?n:t.then)&&n}function f(){for(var t=0;t<this.chain.length;t++){e=n=o=r=i=void 0;var n,e,i=this,r=1===this.state?this.chain[t].success:this.chain[t].failure,o=this.chain[t];try{!1===r?o.reject(i.msg):(n=!0===r?i.msg:r.call(void 0,i.msg))===o.promise?o.reject(TypeError("Promise-chain cycle")):(e=a(n))?e.call(n,o.resolve,o.reject):o.resolve(n)}catch(t){o.reject(t)}}this.chain.length=0}function h(t){var e,i=this;if(!i.triggered){i.triggered=!0,i.def&&(i=i.def);try{(e=a(t))?c(function(){var n=new v(i);try{e.call(t,function(){h.apply(n,arguments)},function(){l.apply(n,arguments)})}catch(t){l.call(n,t)}}):(i.msg=t,i.state=1,0<i.chain.length&&c(f,i))}catch(t){l.call(new v(i),t)}}}function l(t){var n=this;n.triggered||(n.triggered=!0,(n=n.def?n.def:n).msg=t,n.state=2,0<n.chain.length&&c(f,n))}function d(t,e,i,r){for(var n=0;n<e.length;n++)!function(n){t.resolve(e[n]).then(function(t){i(n,t)},r)}(n)}function v(t){this.def=t,this.triggered=!1}function y(t){this.promise=t,this.state=0,this.triggered=!1,this.chain=[],this.msg=void 0}function p(t){if("function"!=typeof t)throw TypeError("Not a function");if(0!==this.n)throw TypeError("Not a promise");this.n=1;var i=new y(this);this.then=function(t,n){var e={success:"function"!=typeof t||t,failure:"function"==typeof n&&n};return e.promise=new this.constructor(function(t,n){if("function"!=typeof t||"function"!=typeof n)throw TypeError("Not a function");e.resolve=t,e.reject=n}),i.chain.push(e),0!==i.state&&c(f,i),e.promise},this.catch=function(t){return this.then(void 0,t)};try{t.call(void 0,function(t){h.call(i,t)},function(t){l.call(i,t)})}catch(t){l.call(i,t)}}var w={add:function(t,n){o=new s(t,n),r?r.next=o:i=o,r=o,o=void 0},drain:function(){var t=i;for(i=r=e=void 0;t;)t.fn.call(t.self),t=t.next}},m=n({},"constructor",p,!1);return n(p.prototype=m,"__NPO__",0,!1),n(p,"resolve",function(e){return e&&"object"==typeof e&&1===e.n?e:new this(function(t,n){if("function"!=typeof t||"function"!=typeof n)throw TypeError("Not a function");t(e)})}),n(p,"reject",function(e){return new this(function(t,n){if("function"!=typeof t||"function"!=typeof n)throw TypeError("Not a function");n(e)})}),n(p,"all",function(n){var u=this;return"[object Array]"!=t.call(n)?u.reject(TypeError("Not an array")):0===n.length?u.resolve([]):new u(function(e,t){if("function"!=typeof e||"function"!=typeof t)throw TypeError("Not a function");var i=n.length,r=Array(i),o=0;d(u,n,function(t,n){r[t]=n,++o===i&&e(r)},t)})}),n(p,"race",function(n){var i=this;return"[object Array]"!=t.call(n)?i.reject(TypeError("Not an array")):new i(function(e,t){if("function"!=typeof e||"function"!=typeof t)throw TypeError("Not a function");d(i,n,function(t,n){e(n)},t)})}),p},(e=yt)[n="Promise"]=e[n]||i(),t.exports&&(t.exports=e[n])})(g={exports:{}});var _=g.exports,C=new WeakMap;function j(t,n,e){var i=C.get(t.element)||{};n in i||(i[n]=[]),i[n].push(e),C.set(t.element,i)}function M(t,n){return(C.get(t.element)||{})[n]||[]}function x(t,n,e){var i=C.get(t.element)||{};return!i[n]||(e?(-1!==(e=i[n].indexOf(e))&&i[n].splice(e,1),C.set(t.element,i),i[n]&&0===i[n].length):(i[n]=[],C.set(t.element,i),!0))}function wt(t){if("string"==typeof t)try{t=JSON.parse(t)}catch(t){return console.warn(t),{}}return t}function I(t,n,e){t.element.contentWindow&&t.element.contentWindow.postMessage&&(n={method:n},void 0!==e&&(n.value=e),8<=(e=parseFloat(navigator.userAgent.toLowerCase().replace(/^.*msie (\d+).*$/,"$1")))&&e<10&&(n=JSON.stringify(n)),t.element.contentWindow.postMessage(n,t.origin))}function mt(e,i){var n,t,r,o,u=[];(i=wt(i)).event?("error"===i.event&&M(e,i.data.method).forEach(function(t){var n=new Error(i.data.message);n.name=i.data.name,t.reject(n),x(e,i.data.method,t)}),u=M(e,"event:".concat(i.event)),n=i.data):i.method&&(t=e,r=i.method,(r=!((o=M(t,r)).length<1)&&(x(t,r,t=o.shift()),t))&&(u.push(r),n=i.value)),u.forEach(function(t){try{"function"==typeof t?t.call(e,n):t.resolve(n)}catch(t){}})}var bt=["autopause","autoplay","background","byline","color","controls","dnt","height","id","interactive_params","keyboard","loop","maxheight","maxwidth","muted","playsinline","portrait","responsive","speed","texttrack","title","transparent","url","width"];function kt(i,t){return bt.reduce(function(t,n){var e=i.getAttribute("data-vimeo-".concat(n));return!e&&""!==e||(t[n]=""===e?1:e),t},1<arguments.length&&void 0!==t?t:{})}function gt(t,n){var e,t=t.html;if(n)return null===n.getAttribute("data-vimeo-initialized")&&((e=document.createElement("div")).innerHTML=t,n.appendChild(e.firstChild),n.setAttribute("data-vimeo-initialized","true")),n.querySelector("iframe");throw new TypeError("An element must be provided")}function Et(o,t,n){var u=1<arguments.length&&void 0!==t?t:{},s=2<arguments.length?n:void 0;return new Promise(function(n,e){if(!b(o))throw new TypeError("“".concat(o,"” is not a vimeo.com url."));var t,i="https://vimeo.com/api/oembed.json?url=".concat(encodeURIComponent(o));for(t in u)u.hasOwnProperty(t)&&(i+="&".concat(t,"=").concat(encodeURIComponent(u[t])));var r=new("XDomainRequest"in window?XDomainRequest:XMLHttpRequest);r.open("GET",i,!0),r.onload=function(){if(404===r.status)e(new Error("“".concat(o,"” was not found.")));else if(403===r.status)e(new Error("“".concat(o,"” is not embeddable.")));else try{var t=JSON.parse(r.responseText);403===t.domain_status_code?(gt(t,s),e(new Error("“".concat(o,"” is not embeddable.")))):n(t)}catch(t){e(t)}},r.onerror=function(){var t=r.status?" (".concat(r.status,")"):"";e(new Error("There was an error fetching the embed code from Vimeo".concat(t,".")))},r.send()})}function Tt(t){function e(t){"console"in window&&console.error&&console.error("There was an error creating an embed: ".concat(t))}t=0<arguments.length&&void 0!==t?t:document,t=[].slice.call(t.querySelectorAll("[data-vimeo-id], [data-vimeo-url]"));t.forEach(function(n){try{var t;null===n.getAttribute("data-vimeo-defer")&&Et(lt(t=kt(n)),t,n).then(function(t){return gt(t,n)}).catch(e)}catch(t){e(t)}})}function Pt(t){var s=0<arguments.length&&void 0!==t?t:document;window.VimeoSeoMetadataAppended||(window.VimeoSeoMetadataAppended=!0,window.addEventListener("message",function(t){if(b(t.origin)){var n=wt(t.data);if(n&&"ready"===n.event)for(var e,i=s.querySelectorAll("iframe"),r=0;r<i.length;r++){var o=i[r],u=o.contentWindow===t.source;e=o.src,/^https:\/\/player\.vimeo\.com\/video\/\d+/.test(e)&&u&&new Ct(o).callMethod("appendVideoMetadata",window.location.href)}}}))}var R,Ft,A,O=new WeakMap,_t=new WeakMap,S={},Ct=function(){function r(o){var u=this,n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},t=this,e=r;if(!(t instanceof e))throw new TypeError("Cannot call a class as a function");if(window.jQuery&&o instanceof jQuery&&(1<o.length&&window.console&&console.warn&&console.warn("A jQuery object with multiple elements was passed, using the first element."),o=o[0]),"undefined"!=typeof document&&"string"==typeof o&&(o=document.getElementById(o)),t=o,!Boolean(t&&1===t.nodeType&&"nodeName"in t&&t.ownerDocument&&t.ownerDocument.defaultView))throw new TypeError("You must pass either a valid element or a valid id.");if("IFRAME"===o.nodeName||(e=o.querySelector("iframe"))&&(o=e),"IFRAME"===o.nodeName&&!b(o.getAttribute("src")||""))throw new Error("The player element passed isn’t a Vimeo embed.");if(O.has(o))return O.get(o);this.e=o.ownerDocument.defaultView,this.element=o,this.origin="*";var i,t=new _(function(i,r){var t;u.i=function(t){var n,e;b(t.origin)&&u.element.contentWindow===t.source&&("*"===u.origin&&(u.origin=t.origin),(t=wt(t.data))&&"error"===t.event&&t.data&&"ready"===t.data.method?((n=new Error(t.data.message)).name=t.data.name,r(n)):(n=t&&"ready"===t.event,e=t&&"ping"===t.method,n||e?(u.element.setAttribute("data-ready","true"),i()):mt(u,t)))},u.e.addEventListener("message",u.i),"IFRAME"!==u.element.nodeName&&Et(lt(t=kt(o,n)),t,o).then(function(t){var n,e,i=gt(t,o);return u.element=i,u.r=o,n=o,i=i,e=C.get(n),C.set(i,e),C.delete(n),O.set(u.element,u),t}).catch(r)});return _t.set(this,t),O.set(this.element,this),"IFRAME"===this.element.nodeName&&I(this,"ping"),S.isEnabled&&(i=function(){return S.exit()},this.fullscreenchangeHandler=function(){(S.isFullscreen?j:x)(u,"event:exitFullscreen",i),u.ready().then(function(){I(u,"fullscreenchange",S.isFullscreen)})},S.on("fullscreenchange",this.fullscreenchangeHandler)),this}var t,n,e;return t=r,(n=[{key:"callMethod",value:function(e){var i=this,r=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};return new _(function(t,n){return i.ready().then(function(){j(i,e,{resolve:t,reject:n}),I(i,e,r)}).catch(n)})}},{key:"get",value:function(e){var i=this;return new _(function(t,n){return e=ht(e,"get"),i.ready().then(function(){j(i,e,{resolve:t,reject:n}),I(i,e)}).catch(n)})}},{key:"set",value:function(e,i){var r=this;return new _(function(t,n){if(e=ht(e,"set"),null==i)throw new TypeError("There must be a value to set.");return r.ready().then(function(){j(r,e,{resolve:t,reject:n}),I(r,e,i)}).catch(n)})}},{key:"on",value:function(t,n){if(!t)throw new TypeError("You must pass an event name.");if(!n)throw new TypeError("You must pass a callback function.");if("function"!=typeof n)throw new TypeError("The callback must be a function.");0===M(this,"event:".concat(t)).length&&this.callMethod("addEventListener",t).catch(function(){}),j(this,"event:".concat(t),n)}},{key:"off",value:function(t,n){if(!t)throw new TypeError("You must pass an event name.");if(n&&"function"!=typeof n)throw new TypeError("The callback must be a function.");x(this,"event:".concat(t),n)&&this.callMethod("removeEventListener",t).catch(function(t){})}},{key:"loadVideo",value:function(t){return this.callMethod("loadVideo",t)}},{key:"ready",value:function(){var t=_t.get(this)||new _(function(t,n){n(new Error("Unknown player. Probably unloaded."))});return _.resolve(t)}},{key:"addCuePoint",value:function(t){return this.callMethod("addCuePoint",{time:t,data:1<arguments.length&&void 0!==arguments[1]?arguments[1]:{}})}},{key:"removeCuePoint",value:function(t){return this.callMethod("removeCuePoint",t)}},{key:"enableTextTrack",value:function(t,n){if(t)return this.callMethod("enableTextTrack",{language:t,kind:n});throw new TypeError("You must pass a language.")}},{key:"disableTextTrack",value:function(){return this.callMethod("disableTextTrack")}},{key:"pause",value:function(){return this.callMethod("pause")}},{key:"play",value:function(){return this.callMethod("play")}},{key:"requestFullscreen",value:function(){return S.isEnabled?S.request(this.element):this.callMethod("requestFullscreen")}},{key:"exitFullscreen",value:function(){return S.isEnabled?S.exit():this.callMethod("exitFullscreen")}},{key:"getFullscreen",value:function(){return S.isEnabled?_.resolve(S.isFullscreen):this.get("fullscreen")}},{key:"requestPictureInPicture",value:function(){return this.callMethod("requestPictureInPicture")}},{key:"exitPictureInPicture",value:function(){return this.callMethod("exitPictureInPicture")}},{key:"getPictureInPicture",value:function(){return this.get("pictureInPicture")}},{key:"unload",value:function(){return this.callMethod("unload")}},{key:"destroy",value:function(){var e=this;return new _(function(t){var n;_t.delete(e),O.delete(e.element),e.r&&(O.delete(e.r),e.r.removeAttribute("data-vimeo-initialized")),e.element&&"IFRAME"===e.element.nodeName&&e.element.parentNode&&(e.element.parentNode.parentNode&&e.r&&e.r!==e.element.parentNode?e.element.parentNode.parentNode.removeChild(e.element.parentNode):e.element.parentNode.removeChild(e.element)),e.element&&"DIV"===e.element.nodeName&&e.element.parentNode&&(e.element.removeAttribute("data-vimeo-initialized"),(n=e.element.querySelector("iframe"))&&n.parentNode&&(n.parentNode.parentNode&&e.r&&e.r!==n.parentNode?n.parentNode.parentNode.removeChild(n.parentNode):n.parentNode.removeChild(n))),e.e.removeEventListener("message",e.i),S.isEnabled&&S.off("fullscreenchange",e.fullscreenchangeHandler),t()})}},{key:"getAutopause",value:function(){return this.get("autopause")}},{key:"setAutopause",value:function(t){return this.set("autopause",t)}},{key:"getBuffered",value:function(){return this.get("buffered")}},{key:"getCameraProps",value:function(){return this.get("cameraProps")}},{key:"setCameraProps",value:function(t){return this.set("cameraProps",t)}},{key:"getChapters",value:function(){return this.get("chapters")}},{key:"getCurrentChapter",value:function(){return this.get("currentChapter")}},{key:"getColor",value:function(){return this.get("color")}},{key:"setColor",value:function(t){return this.set("color",t)}},{key:"getCuePoints",value:function(){return this.get("cuePoints")}},{key:"getCurrentTime",value:function(){return this.get("currentTime")}},{key:"setCurrentTime",value:function(t){return this.set("currentTime",t)}},{key:"getDuration",value:function(){return this.get("duration")}},{key:"getEnded",value:function(){return this.get("ended")}},{key:"getLoop",value:function(){return this.get("loop")}},{key:"setLoop",value:function(t){return this.set("loop",t)}},{key:"setMuted",value:function(t){return this.set("muted",t)}},{key:"getMuted",value:function(){return this.get("muted")}},{key:"getPaused",value:function(){return this.get("paused")}},{key:"getPlaybackRate",value:function(){return this.get("playbackRate")}},{key:"setPlaybackRate",value:function(t){return this.set("playbackRate",t)}},{key:"getPlayed",value:function(){return this.get("played")}},{key:"getQualities",value:function(){return this.get("qualities")}},{key:"getQuality",value:function(){return this.get("quality")}},{key:"setQuality",value:function(t){return this.set("quality",t)}},{key:"getSeekable",value:function(){return this.get("seekable")}},{key:"getSeeking",value:function(){return this.get("seeking")}},{key:"getTextTracks",value:function(){return this.get("textTracks")}},{key:"getVideoEmbedCode",value:function(){return this.get("videoEmbedCode")}},{key:"getVideoId",value:function(){return this.get("videoId")}},{key:"getVideoTitle",value:function(){return this.get("videoTitle")}},{key:"getVideoWidth",value:function(){return this.get("videoWidth")}},{key:"getVideoHeight",value:function(){return this.get("videoHeight")}},{key:"getVideoUrl",value:function(){return this.get("videoUrl")}},{key:"getVolume",value:function(){return this.get("volume")}},{key:"setVolume",value:function(t){return this.set("volume",t)}}])&&at(t.prototype,n),e&&at(t,e),r}(),k=(ft||(R=function(){for(var t,n=[["requestFullscreen","exitFullscreen","fullscreenElement","fullscreenEnabled","fullscreenchange","fullscreenerror"],["webkitRequestFullscreen","webkitExitFullscreen","webkitFullscreenElement","webkitFullscreenEnabled","webkitfullscreenchange","webkitfullscreenerror"],["webkitRequestFullScreen","webkitCancelFullScreen","webkitCurrentFullScreenElement","webkitCancelFullScreen","webkitfullscreenchange","webkitfullscreenerror"],["mozRequestFullScreen","mozCancelFullScreen","mozFullScreenElement","mozFullScreenEnabled","mozfullscreenchange","mozfullscreenerror"],["msRequestFullscreen","msExitFullscreen","msFullscreenElement","msFullscreenEnabled","MSFullscreenChange","MSFullscreenError"]],e=0,i=n.length,r={};e<i;e++)if((t=n[e])&&t[1]in document){for(e=0;e<t.length;e++)r[n[0][e]]=t[e];return r}return!1}(),Ft={fullscreenchange:R.fullscreenchange,fullscreenerror:R.fullscreenerror},A={request:function(r){return new Promise(function(t,n){function e(){A.off("fullscreenchange",e),t()}A.on("fullscreenchange",e);var i=(r=r||document.documentElement)[R.requestFullscreen]();i instanceof Promise&&i.then(e).catch(n)})},exit:function(){return new Promise(function(n,t){var e,i;A.isFullscreen?(A.on("fullscreenchange",e=function t(){A.off("fullscreenchange",t),n()}),(i=document[R.exitFullscreen]())instanceof Promise&&i.then(e).catch(t)):n()})},on:function(t,n){t=Ft[t];t&&document.addEventListener(t,n)},off:function(t,n){t=Ft[t];t&&document.removeEventListener(t,n)}},Object.defineProperties(A,{isFullscreen:{get:function(){return Boolean(document[R.fullscreenElement])}},element:{enumerable:!0,get:function(){return document[R.fullscreenElement]}},isEnabled:{enumerable:!0,get:function(){return Boolean(document[R.fullscreenEnabled])}}}),S=A,Tt(),function(t){var i=0<arguments.length&&void 0!==t?t:document;window.VimeoPlayerResizeEmbeds_||(window.VimeoPlayerResizeEmbeds_=!0,window.addEventListener("message",function(t){if(b(t.origin)&&t.data&&"spacechange"===t.data.event)for(var n=i.querySelectorAll("iframe"),e=0;e<n.length;e++)if(n[e].contentWindow===t.source){n[e].parentElement.style.paddingBottom="".concat(t.data.data[0].bottom,"px");break}}))}(),Pt()),function(i){function t(t,n,e){return(t=i.call(this,t,n,e=void 0===e?{}:e)||this).state.set(3),t}qt(t,i);var n=t.prototype;return n.createPlayer=function(t){var n=this.options,e=this.options.playerOptions,e=void 0===e?{}:e,t=0===t.indexOf("http")?{url:t}:{id:+t},t=new Ct(this.target,$(t,{controls:!n.hideControls,loop:n.loop,muted:n.mute},e.vimeo||{}));return t.on("play",this.onPlay),t.on("pause",this.onPause),t.on("ended",this.onEnded),t.ready().then(this.onPlayerReady,this.onError),t.getMuted()||t.setVolume(it(n.volume,0,1)),t},n.playVideo=function(){var t=this;this.player.play().catch(function(){t.state.is(7)&&t.state.set(5)})},n.pauseVideo=function(){this.player.pause()},t}(st)),jt="//www.youtube.com/player_api",Mt=function(){function t(){}var n=t.prototype;return n.load=function(t){if(window.YT&&U(window.YT.Player))return t();this.attachCallback(t),this.shouldLoad()&&w("script",{src:location.protocol+jt},document.head)},n.shouldLoad=function(){return t=document,!((n="script")?c(t.querySelectorAll(n)):[]).some(function(t){return t.src.replace(/^https?:/,"")===jt});var t,n},n.attachCallback=function(t){var n;D(window.onYouTubeIframeAPIReady)||(n=window.onYouTubeIframeAPIReady),window.onYouTubeIframeAPIReady=function(){n&&n(),t()}},t}(),g=function(i){function t(t,n,e){return(t=i.call(this,t,n,e=void 0===e?{}:e)||this).videoId=t.parseVideoId(n),t.videoId&&(t.state.set(2),(new Mt).load(t.onAPIReady.bind(St(t)))),t}qt(t,i);var n=t.prototype;return n.onAPIReady=function(){var t=this.state,n=t.is(4);t.set(3),n&&this.play()},n.createPlayer=function(t){var n=this.options,e=this.options.playerOptions;return new YT.Player(this.target,{videoId:t,host:n.host,playerVars:$({controls:n.hideControls?0:1,iv_load_policy:3,loop:n.loop?1:0,playlist:n.loop?t:void 0,rel:0,autoplay:0,mute:n.mute?1:0},(void 0===e?{}:e).youtube||{}),events:{onReady:this.onPlayerReady.bind(this),onStateChange:this.onPlayerStateChange.bind(this),onError:this.onError.bind(this)}})},n.onPlayerReady=function(){i.prototype.onPlayerReady.call(this),this.player.setVolume(100*it(this.options.volume,0,1))},n.onPlayerStateChange=function(t){var n=YT.PlayerState,e=n.PLAYING,i=n.PAUSED,n=n.ENDED;switch(!0){case t.data===e:this.onPlay();break;case t.data===i:this.onPause();break;case t.data===n:this.onEnded()}},n.playVideo=function(){this.player.playVideo()},n.pauseVideo=function(){this.player.pauseVideo()},n.parseVideoId=function(t){return 0===t.indexOf("http")?this.parseUrl(t):t},n.parseUrl=function(t){var n,t=t.split(/[#?]/)[1],t=(t=t.split("&"),n=function(t){return 0===t.indexOf("v=")},c(t).filter(n)[0]);return t&&t.replace("v=","")},t}(st),xt="Play Video",It=function(){function t(t,n){this.event=u(),this.Splide=t,this.slide=n,this.container=J(this.slide,"."+e),this.parent=this.container||this.slide,this.init(),this.create(),this.show(),this.listen()}var n=t.prototype;return n.init=function(){y(this.slide,s+m),y(this.container,e+m)},n.create=function(){this.video=w("div",rt,this.parent),this.playButton=w("button",{class:"splide__video__play",type:"button","aria-label":this.Splide.options.i18n.playVideo||xt},this.video),this.wrapper=w("div","splide__video__wrapper",this.video),this.placeholder=w("div",null,this.wrapper)},n.listen=function(){var t=this;this.parent.addEventListener("click",function(){t.event.emit("click")})},n.toggleButton=function(t){Z(this.playButton,t?"":"none")},n.toggleWrapper=function(t){Z(this.wrapper,t?"":"none")},n.getPlaceholder=function(){return this.placeholder},n.hide=function(){this.toggleButton(!1),this.toggleWrapper(!0)},n.show=function(){this.disabled||this.toggleButton(!0),this.toggleWrapper(!1)},n.disable=function(t){(this.disabled=t)&&this.toggleButton(!1)},n.on=function(t,n){this.event.on(t,n)},n.destroy=function(){tt(this.slide,s+m),tt(this.container,e+m),d(this.video,function(t){t&&t.parentNode&&t.parentNode.removeChild(t)}),this.event.destroy()},t}(),Rt=[["data-splide-youtube",g],["data-splide-vimeo",k],["data-splide-html-video",ct]],At=function(){function t(t,n){this.Splide=t,this.slide=n,this.event=u(t),this.options=G(G({},ot),this.Splide.options.video),this.createPlayer(n),this.player&&this.listen()}var n=t.prototype;return n.createPlayer=function(e){var i=this;Rt.forEach(function(t){var n=t[0],t=t[1],n=e.getAttribute(n);n&&(i.ui=new It(i.Splide,e),i.player=new t(i.ui.getPlaceholder(),n,i.options),i.ui.disable(i.options.disableOverlayUI))})},n.listen=function(){var t=this,n=this.player,e=this.event;this.ui.on("click",this.onClick.bind(this)),n.on("play",this.onPlay.bind(this)),n.on("played",this.onPlayed.bind(this)),n.on("pause",this.onPause.bind(this)),n.on("paused",this.onPaused.bind(this)),n.on("ended",this.onEnded.bind(this)),n.on("error",this.onError.bind(this)),e.on(["move","scroll"],this.pause.bind(this)),e.on(ut,this.onVideoClick.bind(this)),e.on("drag",function(){e.off(i),e.on(i,function(){t.pause(),e.off(i)})}),this.options.autoplay&&e.on(["mounted","moved","scrolled"],this.onAutoplayRequested.bind(this))},n.onClick=function(){this.isPaused()?this.play():this.pause(),this.event.emit(ut,this)},n.onVideoClick=function(t){this!==t&&this.pause()},n.onPlay=function(){this.ui.hide()},n.onPlayed=function(){this.ui.hide(),this.togglePlaying(!0),this.event.emit("video:play",this)},n.onPause=function(){this.ui.show()},n.onPaused=function(){this.togglePlaying(!1),this.event.emit("video:pause",this)},n.onEnded=function(){this.togglePlaying(!1),this.event.emit("video:ended",this)},n.onError=function(){y(this.slide,"is-error"),this.ui.show(),this.event.emit("video:error",this)},n.onAutoplayRequested=function(){this.Splide.Components.Slides.getAt(this.Splide.index).slide===this.slide&&this.play()},n.togglePlaying=function(t){v(this.Splide.root,"is-playing",t)},n.play=function(){this.player&&!this.disabled&&this.player.play()},n.pause=function(){this.player&&!this.disabled&&this.player.pause()},n.destroy=function(){this.player&&(this.ui.destroy(),this.player.destroy()),this.disable(!1)},n.disable=function(t){this.disabled=t,v(this.Splide.root,"is-video-disabled",t)},n.isPaused=function(){return this.player.isPaused()},t}();function Ot(r,t){var n=u(r).on,e=t.Slides,o={};function i(){e.forEach(function(t){var n,e,i=t.slide;e=s+m,(n=i)&&n.classList.contains(e)||(o[t.index]=new At(r,i))}),e.update()}return{mount:function(){i(),n("refresh",i)},destroy:function(){p(o,function(t){t.destroy()})},play:function(t){void 0===t&&(t=r.index),(t=o[t])&&t.play()},pause:function(){p(o,function(t){t.pause()})},disable:function(n){p(o,function(t){t.disable(n)})}}}"undefined"!=typeof window&&(window.splide=window.splide||{},window.splide.Extensions=window.splide.Extensions||{},window.splide.Extensions.Video=Ot)},"function"==typeof define&&define.amd?define(t):t();