UNPKG

@wistia/wistia-player-react

Version:

An embeddable wistia-player web component and React wrapper to add responsive, lightweight, and SEO-friendly videos to your site.

1,046 lines (1,040 loc) 752 kB
var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __esm = (fn, res) => function __init() { return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res; }; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // ../../node_modules/@wistia/type-guards/dist/index.mjs var FALSY_VALUES, isNull, isUndefined, isNil2, isNotNil, isString, isNumber2, isFunction, isBoolean; var init_dist = __esm({ "../../node_modules/@wistia/type-guards/dist/index.mjs"() { FALSY_VALUES = [false, 0, -0, 0n, "", null, void 0, Number.NaN]; isNull = (value) => value === null; isUndefined = (value) => value === void 0; isNil2 = (value) => isNull(value) || isUndefined(value); isNotNil = (value) => !isNil2(value); isString = (value) => typeof value === "string"; isNumber2 = (value) => typeof value === "number"; isFunction = (value) => isNotNil(value) && typeof value === "function"; isBoolean = (value) => isNotNil(value) && typeof value === "boolean"; } }); // src/utils/getMergedEmbedOption.ts var isValidEmbedOption, getMergedEmbedOption; var init_getMergedEmbedOption = __esm({ "src/utils/getMergedEmbedOption.ts"() { init_dist(); isValidEmbedOption = (value) => { return isNumber2(value) || isString(value) || isBoolean(value); }; getMergedEmbedOption = (mediaId, optionKey, optionValue) => { let finalEmbedOption = optionValue; if (typeof window === "undefined") { return finalEmbedOption; } if (isNotNil(window.wistiaOptions?._all) && isNotNil(window.wistiaOptions._all[optionKey]) && isValidEmbedOption(window.wistiaOptions._all[optionKey])) { finalEmbedOption = window.wistiaOptions._all[optionKey]; } if (isNotNil(window.wistiaOptions?.[mediaId]) && isNotNil(window.wistiaOptions[mediaId]) && isValidEmbedOption(window.wistiaOptions[mediaId][optionKey])) { finalEmbedOption = window.wistiaOptions[mediaId][optionKey]; } return finalEmbedOption; }; } }); // src/utils/camelCaseToKebabCase.ts var camelCaseToKebabCase; var init_camelCaseToKebabCase = __esm({ "src/utils/camelCaseToKebabCase.ts"() { camelCaseToKebabCase = (str) => { return str.replace( /[A-Z]+(?![a-z])|[A-Z]/g, (letter, idx) => (idx !== 0 ? "-" : "") + letter.toLowerCase() ); }; } }); // src/utils/swatch.ts var getSwatchMetaData, swatchUrl, getSwatchAspectRatio, wistiaPlayerStyleBlock; var init_swatch = __esm({ "src/utils/swatch.ts"() { init_camelCaseToKebabCase(); getSwatchMetaData = async (url) => { const swatch = new Image(); swatch.src = url; await swatch.decode(); return swatch; }; swatchUrl = (mediaId, embedHost) => `https://${embedHost}/embed/medias/${mediaId}/swatch`; getSwatchAspectRatio = async (mediaId, embedHost = "fast.wistia.com") => { const swatchImg = await getSwatchMetaData(swatchUrl(mediaId, embedHost)); const { naturalHeight, naturalWidth } = swatchImg; return naturalWidth / naturalHeight; }; wistiaPlayerStyleBlock = ({ mediaId, embedHost = "fast.wistia.com", aspect = 1.7, shouldLoadSwatch = true, roundedPlayer = 0 }) => { const CSSProperties = { background: shouldLoadSwatch ? `center / contain no-repeat url(${swatchUrl(mediaId, embedHost)})` : void 0, borderRadius: `${roundedPlayer}px`, display: "block", filter: "blur(5px)", paddingTop: `${100 / aspect}%` }; return ` wistia-player[media-id='${mediaId}']:not(:defined) { ${Object.entries(CSSProperties).map(([key, value]) => `${camelCaseToKebabCase(key)}: ${value};`).join("\r\n")} } wistia-player[media-id='${mediaId}']:state(--initializing) { ${Object.entries(CSSProperties).map(([key, value]) => `${camelCaseToKebabCase(key)}: ${value};`).join("\r\n")} } `; }; } }); // ../wistia-player/dist/wistia-player.js var wistia_player_exports = {}; __export(wistia_player_exports, { WistiaPlayer: () => __webpack_exports__WistiaPlayer, wistiaSwatchElement: () => __webpack_exports__wistiaSwatchElement }); function __webpack_require__2(moduleId) { var cachedModule = __webpack_module_cache__[moduleId]; if (cachedModule !== void 0) { return cachedModule.exports; } var module2 = __webpack_module_cache__[moduleId] = { /******/ id: moduleId, /******/ loaded: false, /******/ exports: {} /******/ }; __webpack_modules__[moduleId](module2, module2.exports, __webpack_require__2); module2.loaded = true; return module2.exports; } function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); } function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } } function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; } function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i2, u, a = [], f = true, o = false; try { if (i2 = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = false; } else for (; !(f = (e = i2.call(t)).done) && (a.push(e.value), a.length !== l); f = true) ; } catch (r2) { o = true, n = r2; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } } function _arrayWithHoles(r) { if (Array.isArray(r)) return r; } function _regenerator() { var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i2(r2, n2, o2, i3) { var c2 = n2 && n2.prototype instanceof Generator ? n2 : Generator, u2 = Object.create(c2.prototype); return _regeneratorDefine2(u2, "_invoke", (function(r3, n3, o3) { var i4, c3, u3, f2 = 0, p = o3 || [], y = false, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d2(t2, r4) { return i4 = t2, c3 = 0, u3 = e, G.n = r4, a; } }; function d(r4, n4) { for (c3 = r4, u3 = n4, t = 0; !y && f2 && !o4 && t < p.length; t++) { var o4, i5 = p[t], d2 = G.p, l = i5[2]; r4 > 3 ? (o4 = l === n4) && (u3 = i5[(c3 = i5[4]) ? 5 : (c3 = 3, 3)], i5[4] = i5[5] = e) : i5[0] <= d2 && ((o4 = r4 < 2 && d2 < i5[1]) ? (c3 = 0, G.v = n4, G.n = i5[1]) : d2 < l && (o4 = r4 < 3 || i5[0] > n4 || n4 > l) && (i5[4] = r4, i5[5] = n4, G.n = l, c3 = 0)); } if (o4 || r4 > 1) return a; throw y = true, n4; } return function(o4, p2, l) { if (f2 > 1) throw TypeError("Generator is already running"); for (y && 1 === p2 && d(p2, l), c3 = p2, u3 = l; (t = c3 < 2 ? e : u3) || !y; ) { i4 || (c3 ? c3 < 3 ? (c3 > 1 && (G.n = -1), d(c3, u3)) : G.n = u3 : G.v = u3); try { if (f2 = 2, i4) { if (c3 || (o4 = "next"), t = i4[o4]) { if (!(t = t.call(i4, u3))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u3 = t.value, c3 < 2 && (c3 = 0); } else 1 === c3 && (t = i4.return) && t.call(i4), c3 < 2 && (u3 = TypeError("The iterator does not provide a '" + o4 + "' method"), c3 = 1); i4 = e; } else if ((t = (y = G.n < 0) ? u3 : r3.call(n3, G)) !== a) break; } catch (t2) { i4 = e, c3 = 1, u3 = t2; } finally { f2 = 1; } } return { value: t, done: y }; }; })(r2, o2, i3), true), u2; } var a = {}; function Generator() { } function GeneratorFunction() { } function GeneratorFunctionPrototype() { } t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function() { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e2) { return Object.setPrototypeOf ? Object.setPrototypeOf(e2, GeneratorFunctionPrototype) : (e2.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e2, o, "GeneratorFunction")), e2.prototype = Object.create(u), e2; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function() { return this; }), _regeneratorDefine2(u, "toString", function() { return "[object Generator]"; }), (_regenerator = function _regenerator2() { return { w: i2, m: f }; })(); } function _regeneratorDefine2(e, r, n, t) { var i2 = Object.defineProperty; try { i2({}, "", {}); } catch (e2) { i2 = 0; } _regeneratorDefine2 = function _regeneratorDefine(e2, r2, n2, t2) { if (r2) i2 ? i2(e2, r2, { value: n2, enumerable: !t2, configurable: !t2, writable: !t2 }) : e2[r2] = n2; else { var o = function o2(r3, n3) { _regeneratorDefine2(e2, r3, function(e3) { return this._invoke(r3, n3, e3); }); }; o("next", 0), o("throw", 1), o("return", 2); } }, _regeneratorDefine2(e, r, n, t); } function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i2 = n[a](c), u = i2.value; } catch (n2) { return void e(n2); } i2.done ? t(u) : Promise.resolve(u).then(r, o); } function _asyncToGenerator(n) { return function() { var t = this, e = arguments; return new Promise(function(r, o) { var a = n.apply(t, e); function _next(n2) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n2); } function _throw(n2) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n2); } _next(void 0); }); }; } function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function(r2) { return Object.getOwnPropertyDescriptor(e, r2).enumerable; })), t.push.apply(t, o); } return t; } function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), true).forEach(function(r2) { _defineProperty(e, r2, t[r2]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r2) { Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2)); }); } return e; } function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e; } function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); } function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || false, o.configurable = true, "value" in o && (o.writable = true), Object.defineProperty(e, _toPropertyKey(o.key), o); } } function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: false }), e; } function _toPropertyKey(t) { var i2 = _toPrimitive(t, "string"); return "symbol" == typeof i2 ? i2 : i2 + ""; } function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i2 = e.call(t, r || "default"); if ("object" != typeof i2) return i2; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); } function _possibleConstructorReturn(t, e) { if (e && ("object" == typeof e || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); } function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; } function _superPropGet(t, o, e, r) { var p = _get(_getPrototypeOf(1 & r ? t.prototype : t), o, e); return 2 & r && "function" == typeof p ? function(t2) { return p.apply(e, t2); } : p; } function _get() { return _get = "undefined" != typeof Reflect && Reflect.get ? Reflect.get.bind() : function(e, t, r) { var p = _superPropBase(e, t); if (p) { var n = Object.getOwnPropertyDescriptor(p, t); return n.get ? n.get.call(arguments.length < 3 ? e : r) : n.value; } }, _get.apply(null, arguments); } function _superPropBase(t, o) { for (; !{}.hasOwnProperty.call(t, o) && null !== (t = _getPrototypeOf(t)); ) ; return t; } function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: true, configurable: true } }), Object.defineProperty(t, "prototype", { writable: false }), e && _setPrototypeOf(t, e); } function _wrapNativeSuper(t) { var r = "function" == typeof Map ? /* @__PURE__ */ new Map() : void 0; return _wrapNativeSuper = function _wrapNativeSuper2(t2) { if (null === t2 || !_isNativeFunction(t2)) return t2; if ("function" != typeof t2) throw new TypeError("Super expression must either be null or a function"); if (void 0 !== r) { if (r.has(t2)) return r.get(t2); r.set(t2, Wrapper); } function Wrapper() { return _construct(t2, arguments, _getPrototypeOf(this).constructor); } return Wrapper.prototype = Object.create(t2.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }), _setPrototypeOf(Wrapper, t2); }, _wrapNativeSuper(t); } function _construct(t, e, r) { if (_isNativeReflectConstruct()) return Reflect.construct.apply(null, arguments); var o = [null]; o.push.apply(o, e); var p = new (t.bind.apply(t, o))(); return r && _setPrototypeOf(p, r.prototype), p; } function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() { })); } catch (t2) { } return (_isNativeReflectConstruct = function _isNativeReflectConstruct2() { return !!t; })(); } function _isNativeFunction(t) { try { return -1 !== Function.toString.call(t).indexOf("[native code]"); } catch (n) { return "function" == typeof t; } } function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(t2, e2) { return t2.__proto__ = e2, t2; }, _setPrototypeOf(t, e); } function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function(t2) { return t2.__proto__ || Object.getPrototypeOf(t2); }, _getPrototypeOf(t); } function _classPrivateMethodInitSpec(e, a) { _checkPrivateRedeclaration(e, a), a.add(e); } function _classPrivateFieldInitSpec(e, t, a) { _checkPrivateRedeclaration(e, t), t.set(e, a); } function _checkPrivateRedeclaration(e, t) { if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object"); } function _classPrivateGetter(s, r, a) { return a(_assertClassBrand(s, r)); } function _classPrivateFieldGet(s, a) { return s.get(_assertClassBrand(s, a)); } function _classPrivateFieldSet(s, a, r) { return s.set(_assertClassBrand(s, a), r), r; } function _assertClassBrand(e, t, n) { if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n; throw new TypeError("Private element is not present on this object"); } function _get_pageUrl(_this) { var _this$getAttribute3; return (_this$getAttribute3 = _this.getAttribute("page-url")) !== null && _this$getAttribute3 !== void 0 ? _this$getAttribute3 : (0, _utilities_inferPageUrl_ts__WEBPACK_IMPORTED_MODULE_18__.H)(); } function _defaultLocalization() { return { alpha3Bibliographic: "eng", alpha3Terminologic: "eng", duration: 0, genericName: "English", genericNativeName: "English", hashedId: this.mediaId, ietfLanguageTag: "eng", isLocalization: true, iso6392LanguageCode: "eng", name: "English", nativeName: "English", sourceLanguage: true, timeMappings: [] }; } function _deferMediaDataFetchingToCarouselEmbed() { return !!document.querySelector('wistia-channel-carousel[player-dom-id="'.concat(this.id, '"]:not([is-inside-playlist-embed="true"][channel-id])')); } function _findLocalizationByLanguage(language) { var _classPrivateFieldGet108; if (language == null) { return void 0; } return (_classPrivateFieldGet108 = _classPrivateFieldGet(_playerData, this).mediaData.localizations) === null || _classPrivateFieldGet108 === void 0 ? void 0 : _classPrivateFieldGet108.find(function(localization) { return localization.ietfLanguageTag === language || localization.iso6392LanguageCode === language; }); } function _generateUniqueId(mediaId) { var prefix = "wistia-".concat(mediaId, "-"); return (0, _utilities_seqid_js__WEBPACK_IMPORTED_MODULE_22__.h)(prefix); } function _getSyncedEmbedOption(key) { var _ref18, _ref19; if (_classPrivateFieldGet(_impl, this) && key in _classPrivateFieldGet(_impl, this)._attrs) { return _classPrivateFieldGet(_impl, this)._attrs[key]; } return (_ref18 = (_ref19 = this.embedOptions[key]) !== null && _ref19 !== void 0 ? _ref19 : _assertClassBrand(_WistiaPlayer_brand, this, _getValueFromAttribute).call(this, (0, _utilities_camelCaseToKebabCase_ts__WEBPACK_IMPORTED_MODULE_35__.$)(key))) !== null && _ref18 !== void 0 ? _ref18 : defaultEmbedOptions[key]; } function _getValueFromAttribute(name) { if (!this.hasAttribute(name)) { return null; } switch (this.getAttribute(name)) { case "true": return true; case "false": return false; case "": return true; case null: default: return this.getAttribute(name); } } function _initPlayerEmbed(_ref20) { var container = _ref20.container, mediaData = _ref20.mediaData; if (!_classPrivateFieldGet(_hasElementConnectedToDOM, this)) { return; } _classPrivateFieldGet(_playerData, this).updateEmbedOptionOverrides({ videoFoam: true }); if (mediaData && !(0, _utilities_mediaDataError_ts__WEBPACK_IMPORTED_MODULE_33__.V)(mediaData)) { _classPrivateFieldSet(_playerType, this, (0, _utilities_judy_js__WEBPACK_IMPORTED_MODULE_19__.$F)(_classPrivateFieldGet(_judyContext, this), _classPrivateFieldGet(_playerData, this).mediaData, _classPrivateFieldGet(_playerData, this).embedOptions)); _assertClassBrand(_WistiaPlayer_brand, this, _renderPreloadThumbnail).call(this); _assertClassBrand(_WistiaPlayer_brand, this, _maybeInjectJsonLd).call(this); } if ("attachInternals" in HTMLElement.prototype && "states" in ElementInternals.prototype) { var _classPrivateFieldGet109; (_classPrivateFieldGet109 = _classPrivateFieldGet(_internals, this)) === null || _classPrivateFieldGet109 === void 0 ? void 0 : _classPrivateFieldGet109.states.delete("--initializing"); } void _assertClassBrand(_WistiaPlayer_brand, this, _initPublicApi).call(this, this.mediaId, { container, mediaData }); } function _initPublicApi(_x21, _x22) { return _initPublicApi2.apply(this, arguments); } function _initPublicApi2() { _initPublicApi2 = _asyncToGenerator(/* @__PURE__ */ _regenerator().m(function _callee26(mediaId, options) { var _this19 = this; var embeddedCallback; return _regenerator().w(function(_context26) { while (1) switch (_context26.n) { case 0: _context26.n = 1; return _classPrivateFieldGet(_publicApiScript, this); case 1: if (_wistia_namespace_ts__WEBPACK_IMPORTED_MODULE_3__.s.PublicApi) { _context26.n = 2; break; } (0, _utilities_simpleMetrics_js__WEBPACK_IMPORTED_MODULE_24__.WO)("player/failure/init-failed"); throw new Error("Wistia.PublicApi is not defined"); case 2: embeddedCallback = function embeddedCallback2() { var _classPrivateFieldGet116; void _assertClassBrand(_WistiaPlayer_brand, _this19, _maybeInitializeMux).call(_this19); _assertClassBrand(_WistiaPlayer_brand, _this19, _renderEmbedTemplate).call(_this19); (_classPrivateFieldGet116 = _classPrivateFieldGet(_resizeObserver, _this19)) === null || _classPrivateFieldGet116 === void 0 ? void 0 : _classPrivateFieldGet116.disconnect(); _classPrivateFieldSet(_resizeObserver, _this19, null); if (_classPrivateFieldGet(_playPending, _this19)) { void _this19.play(); } }; this.addEventListener("embedded", embeddedCallback); _classPrivateFieldGet(_removeEventListeners, this).push(function() { _this19.removeEventListener("embedded", embeddedCallback); }); _classPrivateFieldSet(_api, this, new _wistia_namespace_ts__WEBPACK_IMPORTED_MODULE_3__.s.PublicApi(mediaId, options)); this.addEventListener(_utilities_eventConstants_ts__WEBPACK_IMPORTED_MODULE_15__.kY, _classPrivateFieldGet(_handleBeforeReplace, this)); this.addEventListener(_utilities_eventConstants_ts__WEBPACK_IMPORTED_MODULE_15__.$1, _classPrivateFieldGet(_handleAfterReplace, this)); _classPrivateFieldGet(_removeEventListeners, this).push(function() { _this19.removeEventListener(_utilities_eventConstants_ts__WEBPACK_IMPORTED_MODULE_15__.kY, _classPrivateFieldGet(_handleBeforeReplace, _this19)); _this19.removeEventListener(_utilities_eventConstants_ts__WEBPACK_IMPORTED_MODULE_15__.$1, _classPrivateFieldGet(_handleAfterReplace, _this19)); }); _classPrivateFieldGet(_api, this).ready(function() { var _classPrivateFieldGet117; (_classPrivateFieldGet117 = _classPrivateFieldGet(_preloadThumbnailRoot, _this19)) === null || _classPrivateFieldGet117 === void 0 ? void 0 : _classPrivateFieldGet117.remove(); _this19.removeEventListener("click", _classPrivateFieldGet(_handlePreloadThumbnailClick, _this19)); _this19.dispatchEvent(new CustomEvent(_utilities_eventConstants_ts__WEBPACK_IMPORTED_MODULE_15__.c5, { detail: { mediaId } })); _this19.dispatchEvent(new CustomEvent(_utilities_eventConstants_ts__WEBPACK_IMPORTED_MODULE_15__.iP, { detail: { mediaId, api: _classPrivateFieldGet(_api, _this19) } })); if (_classPrivateFieldGet(_impl, _this19)) { Object.entries(_classPrivateFieldGet(_impl, _this19)._attrs).forEach(function(_ref25) { var _ref26 = _slicedToArray(_ref25, 2), key = _ref26[0], value = _ref26[1]; _classPrivateFieldGet(_playerData, _this19).updateEmbedOptionOverrides(_defineProperty({}, key, value)); }); } _assertClassBrand(_WistiaPlayer_brand, _this19, _renderPreloadThumbnail).call(_this19); }); case 3: return _context26.a(2); } }, _callee26, this); })); return _initPublicApi2.apply(this, arguments); } function _isPopoverWithThumbnail() { return this.wistiaPopover && ((0, _wistia_type_guards__WEBPACK_IMPORTED_MODULE_1__.gD)(this.popoverContent) || (0, _wistia_type_guards__WEBPACK_IMPORTED_MODULE_1__.jw)(this.popoverContent) || this.popoverContent === "thumbnail"); } function _maybeInitializeMux() { return _maybeInitializeMux2.apply(this, arguments); } function _maybeInitializeMux2() { _maybeInitializeMux2 = _asyncToGenerator(/* @__PURE__ */ _regenerator().m(function _callee27() { var _this20 = this; var shouldRandomEnableMux, shouldEnableMuxForPlayer, embedType, mux; return _regenerator().w(function(_context27) { while (1) switch (_context27.n) { case 0: if (_classPrivateFieldGet(_api, this)) { _context27.n = 1; break; } return _context27.a(2); case 1: shouldRandomEnableMux = (0, _utilities_coinFlip_ts__WEBPACK_IMPORTED_MODULE_10__.k)(_utilities_shouldEnableMux_ts__WEBPACK_IMPORTED_MODULE_23__._); shouldEnableMuxForPlayer = (0, _utilities_shouldEnableMux_ts__WEBPACK_IMPORTED_MODULE_23__.J)(_classPrivateFieldGet(_api, this), shouldRandomEnableMux) && (0, _utilities_trackingConsentApi_js__WEBPACK_IMPORTED_MODULE_25__.D5)(); embedType = this.useWebComponent ? "translated-web-component" : "web-component"; if (!shouldEnableMuxForPlayer) { _context27.n = 3; break; } _context27.n = 2; return (0, _utilities_dynamicImport_ts__WEBPACK_IMPORTED_MODULE_12__.$)("assets/external/wistia-mux.js"); case 2: mux = _context27.v; mux.init(_classPrivateFieldGet(_api, this), { embedType }); this.addEventListener("visitor-tracking-change", function(event) { var isTrackingEnabled = event.detail.isTrackingEnabled; if (!isTrackingEnabled) { var _classPrivateFieldGet119, _classPrivateFieldGet120; (_classPrivateFieldGet119 = _classPrivateFieldGet(_api, _this20)) === null || _classPrivateFieldGet119 === void 0 ? void 0 : (_classPrivateFieldGet120 = _classPrivateFieldGet119.mux) === null || _classPrivateFieldGet120 === void 0 ? void 0 : _classPrivateFieldGet120.destroy(); } }); case 3: return _context27.a(2); } }, _callee27, this); })); return _maybeInitializeMux2.apply(this, arguments); } function _maybeInjectJsonLd() { if (this.seo && _classPrivateFieldGet(_playerType, this) !== "notplayable" && _classPrivateFieldGet(_playerType, this) !== "passwordprotected" && _classPrivateFieldGet(_playerType, this) !== "carouselHardWall") { _classPrivateFieldSet(_jsonLdId, this, "w-json-ld-".concat(this.uniqueId)); (0, _utilities_injectJsonLd_js__WEBPACK_IMPORTED_MODULE_31__.Z)(_classPrivateFieldGet(_jsonLdId, this)); (0, _utilities_injectJsonLd_js__WEBPACK_IMPORTED_MODULE_31__.g)(_classPrivateFieldGet(_jsonLdId, this), _classPrivateFieldGet(_playerData, this).mediaData, { embedOptions: _classPrivateFieldGet(_playerData, this).embedOptions, videoHeight: this.offsetHeight, videoWidth: this.offsetWidth }); } } function _maybeSetupEmbedOptionsFromIframe() { if (!window._inWistiaIframe) { return; } var searchParams = new URLSearchParams(window.location.search); var iframeEmbedOptions = Object.fromEntries(searchParams.entries()); iframeEmbedOptions.pageTitle = document.title; iframeEmbedOptions._inIframe = true; _classPrivateFieldGet(_playerData, this).setIframeEmbedOptionSource(iframeEmbedOptions); } function _renderEmbedTemplate() { var _this$embedHost2, _this13 = this; if (!_classPrivateFieldGet(_preactRoot, this)) { return; } var mediaType = _classPrivateFieldGet(_playerData, this).mediaData.mediaType; var swatchUrl2 = getSwatchUrl(this.mediaId, (_this$embedHost2 = this.embedHost) !== null && _this$embedHost2 !== void 0 ? _this$embedHost2 : ""); var swatchHeight = "100%"; if (parseFloat(_classPrivateFieldGet(_paddingTop, this)) !== 0 && _classPrivateFieldGet(_paddingTop, this) !== "") { swatchHeight = "".concat(parseFloat(_classPrivateFieldGet(_paddingTop, this)), "px"); } var playerBorderRadius = (0, _utilities_roundedPlayerDefaults_ts__WEBPACK_IMPORTED_MODULE_20__.JA)({ playerBorderRadius: this.playerBorderRadius, roundedPlayer: this.roundedPlayer }); (0, preact__WEBPACK_IMPORTED_MODULE_0__.XX)((0, preact__WEBPACK_IMPORTED_MODULE_0__.h)(preact__WEBPACK_IMPORTED_MODULE_0__.FK, null, (0, preact__WEBPACK_IMPORTED_MODULE_0__.h)("style", null, ":host {\n display: flex;\n position: relative;\n width: 100%;\n ".concat(mediaType === "Audio" ? "min-height: 45px;" : "", "\n }")), _assertClassBrand(_WistiaPlayer_brand, this, _shouldDisplaySwatch).call(this) && (0, preact__WEBPACK_IMPORTED_MODULE_0__.h)("div", { style: { height: swatchHeight, left: 0, position: "absolute", top: 0, width: "100%" }, class: "wistia_swatch" }, (0, preact__WEBPACK_IMPORTED_MODULE_0__.h)("div", { style: { height: "100%", position: "relative", width: "100%" } }, (0, preact__WEBPACK_IMPORTED_MODULE_0__.h)("div", { style: { height: "100%", left: 0, overflow: "hidden", position: "absolute", top: 0, width: "100%", borderRadius: "".concat(playerBorderRadius, "px") } }, (0, preact__WEBPACK_IMPORTED_MODULE_0__.h)("img", { src: swatchUrl2, style: { filter: "blur(5px)", height: "100%", objectFit: "contain", width: "100%" }, alt: "", "aria-hidden": "true" })))), (0, preact__WEBPACK_IMPORTED_MODULE_0__.h)("div", { ref: function ref(_ref21) { _classPrivateFieldSet(_preloadThumbnailRoot, _this13, _ref21); } })), _classPrivateFieldGet(_preactRoot, this)); } function _renderPreloadThumbnail() { var _this$playerForce; if (!_classPrivateFieldGet(_preloadThumbnailRoot, this)) { return; } var _classPrivateFieldGet110 = _classPrivateFieldGet(_playerData, this).mediaData, assets = _classPrivateFieldGet110.assets, mediaType = _classPrivateFieldGet110.mediaType, carouselHardWall = _classPrivateFieldGet110.carouselHardWall; var _classPrivateFieldGet111 = _classPrivateFieldGet(_playerData, this).embedOptions, autoPlay = _classPrivateFieldGet111.autoPlay, plugin = _classPrivateFieldGet111.plugin; if (carouselHardWall) { return; } var thumbnailAssets = (0, _utilities_assets_js__WEBPACK_IMPORTED_MODULE_9__.Q0)(assets, {}); var willAutoplay = this.autoplay || autoPlay; var hasVideoThumbnail = (plugin === null || plugin === void 0 ? void 0 : plugin.videoThumbnail) !== void 0; var shouldRenderThumbnail = (!this.wistiaPopover || _assertClassBrand(_WistiaPlayer_brand, this, _isPopoverWithThumbnail).call(this)) && mediaType !== "Audio" && thumbnailAssets.length > 0 && !willAutoplay && !hasVideoThumbnail; if (!shouldRenderThumbnail) { return; } (0, preact__WEBPACK_IMPORTED_MODULE_0__.XX)((0, preact__WEBPACK_IMPORTED_MODULE_0__.h)(_hooks_usePlayerData_tsx__WEBPACK_IMPORTED_MODULE_5__.z, { embedOptions: _classPrivateFieldGet(_playerData, this).embedOptions, mediaData: _classPrivateFieldGet(_playerData, this).mediaData }, (0, preact__WEBPACK_IMPORTED_MODULE_0__.h)(_components_PreloadThumbnail_tsx__WEBPACK_IMPORTED_MODULE_4__.u, { mediaId: this.mediaId, playerType: (_this$playerForce = this.playerForce) !== null && _this$playerForce !== void 0 ? _this$playerForce : _classPrivateFieldGet(_playerType, this), playerWidth: this.offsetWidth, isPlayPending: _classPrivateFieldGet(_playPending, this) })), _classPrivateFieldGet(_preloadThumbnailRoot, this)); } function _runMethodsFromAttributes() { var _this14 = this; if (_assertClassBrand(_WistiaPlayer_brand, this, _getValueFromAttribute).call(this, "current-time") !== null) { this.whenApiReady().then(function() { var _ref22, _classPrivateFieldGet112, _classPrivateFieldGet113; var newTime = Number(_assertClassBrand(_WistiaPlayer_brand, _this14, _getValueFromAttribute).call(_this14, "current-time")); var isClosedPopover = (_ref22 = ((_classPrivateFieldGet112 = _classPrivateFieldGet(_api, _this14)) === null || _classPrivateFieldGet112 === void 0 ? void 0 : _classPrivateFieldGet112.popover) && !_classPrivateFieldGet(_api, _this14).popover.isVisible()) !== null && _ref22 !== void 0 ? _ref22 : false; var isMobile = (0, _utilities_detect_js__WEBPACK_IMPORTED_MODULE_11__.GS)(); var shouldDelayUntilPlay = _this14.state !== "playing" && (isMobile || isClosedPopover); void ((_classPrivateFieldGet113 = _classPrivateFieldGet(_impl, _this14)) === null || _classPrivateFieldGet113 === void 0 ? void 0 : _classPrivateFieldGet113.time(newTime, { lazy: shouldDelayUntilPlay })); _assertClassBrand(_WistiaPlayer_brand, _this14, _setSyncedEmbedOption).call(_this14, "currentTime", newTime); }).catch(function(_error) { }); } if (_assertClassBrand(_WistiaPlayer_brand, this, _getValueFromAttribute).call(this, "email") !== null) { _assertClassBrand(_WistiaPlayer_brand, this, _updateEmail).call(this, _assertClassBrand(_WistiaPlayer_brand, this, _getValueFromAttribute).call(this, "email")); } if (_assertClassBrand(_WistiaPlayer_brand, this, _getValueFromAttribute).call(this, "video-quality") !== null) { this.whenApiReady().then(function() { var _classPrivateFieldGet114; var newQuality = _assertClassBrand(_WistiaPlayer_brand, _this14, _getValueFromAttribute).call(_this14, "video-quality"); (_classPrivateFieldGet114 = _classPrivateFieldGet(_impl, _this14)) === null || _classPrivateFieldGet114 === void 0 ? void 0 : _classPrivateFieldGet114.setVideoQuality(newQuality); _assertClassBrand(_WistiaPlayer_brand, _this14, _setSyncedEmbedOption).call(_this14, "videoQuality", newQuality); }).catch(function(_error) { }); } } function _saveInitialAttributesFromDomOptions() { var _this15 = this; var domOptions = Object.fromEntries(Object.entries(this.attributes).map(function(_ref23) { var _ref24 = _slicedToArray(_ref23, 2), value = _ref24[1]; return [(0, _utilities_camelCaseToKebabCase_ts__WEBPACK_IMPORTED_MODULE_35__.b)(value.name), _assertClassBrand(_WistiaPlayer_brand, _this15, _getValueFromAttribute).call(_this15, value.name)]; })); _classPrivateFieldGet(_playerData, this).setDomEmbedOptionSource(domOptions); (0, _utilities_embedOptionStore_ts__WEBPACK_IMPORTED_MODULE_13__.gY)("__".concat(this.uniqueId, "_dom_options__"), _classPrivateFieldGet(_playerData, this).embedOptions); } function _setMultipleSyncedEmbedOptions(options) { var _this16 = this; Object.entries(options).forEach(function(entry) { var _Object$getOwnPropert; var _entry = _slicedToArray(entry, 2), key = _entry[0], value = _entry[1]; if (value == null) { return; } if ((_Object$getOwnPropert = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(_this16), key)) !== null && _Object$getOwnPropert !== void 0 && _Object$getOwnPropert.set) { _this16[key] = value; } else { _assertClassBrand(_WistiaPlayer_brand, _this16, _setSyncedEmbedOption).call(_this16, key, value); } }); } function _setSyncedEmbedOption(key, value) { _classPrivateFieldGet(_logger, this).info("set ".concat(key), value.toString()); if (_classPrivateFieldGet(_impl, this)) { _classPrivateFieldGet(_impl, this)._attrs[key] = value; } _classPrivateFieldGet(_playerData, this).updateEmbedOptionOverrides(_defineProperty({}, key, value)); _assertClassBrand(_WistiaPlayer_brand, this, _renderPreloadThumbnail).call(this); } function _setupEventListeners() { var _this17 = this; var loadedMediaDataCallback = function loadedMediaDataCallback2(event) { _assertClassBrand(_WistiaPlayer_brand, _this17, _updateMediaData).call(_this17, event.detail.mediaData); }; var implCreatedCallback = function implCreatedCallback2(event) { _classPrivateFieldSet(_impl, _this17, event.detail.impl); }; this.addEventListener(_utilities_eventConstants_ts__WEBPACK_IMPORTED_MODULE_15__.rO, loadedMediaDataCallback); this.addEventListener(_utilities_eventConstants_ts__WEBPACK_IMPORTED_MODULE_15__.dp, implCreatedCallback); _classPrivateFieldGet(_removeEventListeners, this).push(function() { _this17.removeEventListener(_utilities_eventConstants_ts__WEBPACK_IMPORTED_MODULE_15__.rO, loadedMediaDataCallback); }, function() { _this17.removeEventListener(_utilities_eventConstants_ts__WEBPACK_IMPORTED_MODULE_15__.dp, implCreatedCallback); }); this.addEventListener("click", _classPrivateFieldGet(_handlePreloadThumbnailClick, this), { once: true }); } function _shouldDisplaySwatch() { return this.swatch !== false && (!this.wistiaPopover || _assertClassBrand(_WistiaPlayer_brand, this, _isPopoverWithThumbnail).call(this)); } function _updateEmail(email) { var _this18 = this; (0, _utilities_wistiaLocalStorage_js__WEBPACK_IMPORTED_MODULE_27__.$B)(function(localStorage2) { localStorage2[_classPrivateGetter(_WistiaPlayer_brand, _this18, _get_pageUrl)] = _objectSpread(_objectSpread({}, localStorage2[_classPrivateGetter(_WistiaPlayer_brand, _this18, _get_pageUrl)]), {}, { trackEmail: email }); }); this.dispatchEvent(new CustomEvent("emailchange", { detail: { email } })); } function _updateMediaData(mediaData) { if ((0, _utilities_mediaDataError_ts__WEBPACK_IMPORTED_MODULE_33__.V)(mediaData)) { return; } _classPrivateFieldGet(_playerData, this).setMediaDataSource(mediaData); _classPrivateFieldSet(_playerType, this, (0, _utilities_judy_js__WEBPACK_IMPORTED_MODULE_19__.$F)(_classPrivateFieldGet(_judyContext, this), _classPrivateFieldGet(_playerData, this).mediaData, _classPrivateFieldGet(_playerData, this).embedOptions)); _assertClassBrand(_WistiaPlayer_brand, this, _renderPreloadThumbnail).call(this); } var __webpack_modules__, __webpack_module_cache__, __webpack_exports__2, preact__WEBPACK_IMPORTED_MODULE_0__, _wistia_type_guards__WEBPACK_IMPORTED_MODULE_1__, _utilities_gradients_ts__WEBPACK_IMPORTED_MODULE_2__, _wistia_namespace_ts__WEBPACK_IMPORTED_MODULE_3__, _components_PreloadThumbnail_tsx__WEBPACK_IMPORTED_MODULE_4__, _hooks_usePlayerData_tsx__WEBPACK_IMPORTED_MODULE_5__, _utilities_constants_ts__WEBPACK_IMPORTED_MODULE_6__, _utilities_PlayerDataHandler_ts__WEBPACK_IMPORTED_MODULE_7__, _appHostname_js__WEBPACK_IMPORTED_MODULE_8__, _utilities_assets_js__WEBPACK_IMPORTED_MODULE_9__, _utilities_coinFlip_ts__WEBPACK_IMPORTED_MODULE_10__, _utilities_detect_js__WEBPACK_IMPORTED_MODULE_11__, _utilities_dynamicImport_ts__WEBPACK_IMPORTED_MODULE_12__, _utilities_embedOptionStore_ts__WEBPACK_IMPORTED_MODULE_13__, _utilities_elem_js__WEBPACK_IMPORTED_MODULE_14__, _utilities_eventConstants_ts__WEBPACK_IMPORTED_MODULE_15__, _utilities_extractEmailFromParams_ts__WEBPACK_IMPORTED_MODULE_16__, _utilities_hosts_js__WEBPACK_IMPORTED_MODULE_17__, _utilities_inferPageUrl_ts__WEBPACK_IMPORTED_MODULE_18__, _utilities_judy_js__WEBPACK_IMPORTED_MODULE_19__, _utilities_roundedPlayerDefaults_ts__WEBPACK_IMPORTED_MODULE_20__, _utilities_runScript_js__WEBPACK_IMPORTED_MODULE_21__, _utilities_seqid_js__WEBPACK_IMPORTED_MODULE_22__, _utilities_shouldEnableMux_ts__WEBPACK_IMPORTED_MODULE_23__, _utilities_simpleMetrics_js__WEBPACK_IMPORTED_MODULE_24__, _utilities_trackingConsentApi_js__WEBPACK_IMPORTED_MODULE_25__, _utilities_url_js__WEBPACK_IMPORTED_MODULE_26__, _utilities_wistiaLocalStorage_js__WEBPACK_IMPORTED_MODULE_27__, _utilities_wistiaOptions_ts__WEBPACK_IMPORTED_MODULE_28__, _utilities_wistiaQueue_ts__WEBPACK_IMPORTED_MODULE_29__, _utilities_wlog_js__WEBPACK_IMPORTED_MODULE_30__, _utilities_injectJsonLd_js__WEBPACK_IMPORTED_MODULE_31__, _utilities_getInitialMediaData_ts__WEBPACK_IMPORTED_MODULE_32__, _utilities_mediaDataError_ts__WEBPACK_IMPORTED_MODULE_33__, _utilities_remote_data_cache_ts__WEBPACK_IMPORTED_MODULE_34__, _utilities_camelCaseToKebabCase_ts__WEBPACK_IMPORTED_MODULE_35__, _types_gradient_ts__WEBPACK_IMPORTED_MODULE_36__, _WistiaPlayer, requiredAttributes, optionalPublicAttributes, optionalPrivateAttributes, defaultEmbedOptions, getSwatchUrl, _api, _eventListeners, _fullscreenState, _impl, _internals, _jsonLdId, _judyContext, _logger, _oldEngine, _playerData, _playerType, _removeEventListeners, _cachedRemapTime, _hasElementConnectedToDOM, _paddingTop, _playPending, _preactRoot, _preloadThumbnailRoot, _publicApiScript, _resizeObserver, _WistiaPlayer_brand, _handleAfterReplace, _handleBeforeReplace, _handlePreloadThumbnailClick, WistiaPlayer, getSwatchMetaData2, wistiaSwatchElement, __webpack_exports__WistiaPlayer, __webpack_exports__wistiaSwatchElement; var init_wistia_player = __esm({ "../wistia-player/dist/wistia-player.js"() { __webpack_modules__ = { /***/ 159: ( /***/ ((__unused_webpack___webpack_module__2, __webpack_exports__3, __webpack_require__3) => { __webpack_require__3.d(__webpack_exports__3, { /* harmony export */ Rb: () => ( /* binding */ findScriptInDomBySrc ) /* harmony export */ }); var utilities_wlog_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__3(6637); var utilities_obj_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__3(731); var utilities_runScript_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__3(1248); function ownKeys2(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function(r2) { return Object.getOwnPropertyDescriptor(e, r2).enumerable; })), t.push.apply(t, o); } return t; } function _objectSpread2(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys2(Object(t), true).forEach(function(r2) { _defineProperty2(e, r2, t[r2]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys2(Object(t)).forEach(function(r2) { Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2)); }); } return e; } function _defineProperty2(e, r, t) { return (r = _toPropertyKey2(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e; } function _toPropertyKey2(t) { var i2 = _toPrimitive2(t, "string"); return "symbol" == typeof i2 ? i2 : i2 + ""; } function _toPrimitive2(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i2 = e.call(t, r || "default"); if ("object" != typeof i2) return i2; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } var findScriptInDomBySrc = function findScriptInDomBySrc2(targetSrc) { var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}; var scriptTags2 = document.getElementsByTagName("script"); for (var i2 = 0; i2 < scriptTags2.length; i2++) { var s = scriptTags2[i2]; var src2 = s.getAttribute("src") || ""; if (options.ignoreQueryParams) { var matches2 = src2.split("?"); var urlWithoutParams = matches2[0]; src2 = urlWithoutParams; } if (!options.scriptRegex && options.ignoreProtocol) { src2 = src2.replace(/^https?:/, ""); targetSrc = targetSrc.replace(/^https?:/, ""); } if (options.scriptRegex && options.scriptRegex.test(src2)) { return s; } if (options.testStartsWith && src2.indexOf(targetSrc) === 0) { return s; } if (src2 === targetSrc) { return s; } } return null; }; var removeScriptsBySrc2 = function removeScriptsBySrc3(targetSrc) { var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}; var s; var _loop2 = function _loop3() { if (s) { s.onload = s.onreadystatechange = s.onerror = null; if (s.parentNode && typeof s.parentNode.removeChild) { try { s.parentNode.removeChild(s); } catch (e) { setTimeout(function() { throw e; }, 0); } } } }; while (s = findScriptInDomBySrc(targetSrc, options)) { _loop2(); } }; var runScript = function runScript2(src2) { var timeout = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 8e3; var options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}; if (timeout == null) { timeout = 8e3; } if (options == null) { options = {}; } var s; var alreadyExists; return new Promise(function(resolve) { if (options.once === true && (s = findScriptInDomBySrc(src2))) { alreadyExists = true; } if (options.once && alreadyExists) { if (!s.readyState || /loaded|complete/.test(s.readyState)) { setTimeout(function() { resolve(); }, 1); } } else { runScriptWithPromise(src2, timeout).then(resolve).catch(function(msg) { resolve(msg); setTimeout(function() { console.error(msg); }, 1); }); } }); }; var runScripts2 = function runScripts3() { var scripts; for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } if (args[0] instanceof Array) { scripts = args[0]; } else { scripts = args; } scripts = scriptInputsToHash(scripts); var asyncScripts = []; var syncScripts = []; var scriptPromises = []; scripts.forEach(function(s) { var script = _objectSpread2({}, s); var p = new Promise(function(resolve) { script.resolve = resolve; }); script.promise = p; scriptPromises.push(script.promise); if (s.async) { asyncScripts.push(script); } else { syncScripts.push(script); } }); syncScripts.reduce(function(prev, script) { if (script.fn) { try { script.fn(); } catch (e) { wlog.error(e); } finally { script.resolve(); } } else if (script.src) { runScript(script.src, null, script).then(script.resolve); } return prev.then(script.promise); }, Promise.resolve()); setTimeout(function() { asyncScripts.forEach(function(script) { if (script.fn) { try { script.fn(); } catch (e) { wlog.error(e); } finally { script.resolve(); } } else if (script.src) { runScript(script.src, null, script).then(script.resolve); } }); }, 1); return Promise.all(scriptPromises); }; var scriptInputsToHash = function scriptInputsToHash2(scripts)