import { g as e } from "./alasql-f59e855e.js";
import t from "react";
import { u as r, p as a } from "./index-037d59a7.js";
function o(e2, t2) {
  for (var r2 = 0; r2 < t2.length; r2++) {
    const a2 = t2[r2];
    if ("string" != typeof a2 && !Array.isArray(a2)) {
      for (const t3 in a2)
        if ("default" !== t3 && !(t3 in e2)) {
          const r3 = Object.getOwnPropertyDescriptor(a2, t3);
          r3 && Object.defineProperty(e2, t3, r3.get ? r3 : { enumerable: true, get: () => a2[t3] });
        }
    }
  }
  return Object.freeze(Object.defineProperty(e2, Symbol.toStringTag, { value: "Module" }));
}
var s = Object.create, l = Object.defineProperty, n = Object.getOwnPropertyDescriptor, i = Object.getOwnPropertyNames, p = Object.getPrototypeOf, y = Object.prototype.hasOwnProperty, u = (e2, t2, r2, a2) => {
  if (t2 && "object" == typeof t2 || "function" == typeof t2)
    for (let o2 of i(t2))
      y.call(e2, o2) || o2 === r2 || l(e2, o2, { get: () => t2[o2], enumerable: !(a2 = n(t2, o2)) || a2.enumerable });
  return e2;
}, d = (e2, t2, r2) => (((e3, t3, r3) => {
  t3 in e3 ? l(e3, t3, { enumerable: true, configurable: true, writable: true, value: r3 }) : e3[t3] = r3;
})(e2, "symbol" != typeof t2 ? t2 + "" : t2, r2), r2), c = {};
((e2, t2) => {
  for (var r2 in t2)
    l(e2, r2, { get: t2[r2], enumerable: true });
})(c, { default: () => g });
var h, m = (h = c, u(l({}, "__esModule", { value: true }), h)), f = ((e2, t2, r2) => (r2 = null != e2 ? s(p(e2)) : {}, u(!t2 && e2 && e2.__esModule ? r2 : l(r2, "default", { value: e2, enumerable: true }), e2)))(t), P = r, b = a;
class g extends f.Component {
  constructor() {
    super(...arguments), d(this, "callPlayer", P.callPlayer), d(this, "mute", () => {
      this.setVolume(0);
    }), d(this, "unmute", () => {
      null !== this.props.volume && this.setVolume(this.props.volume);
    }), d(this, "ref", (e2) => {
      this.container = e2;
    });
  }
  componentDidMount() {
    this.props.onMount && this.props.onMount(this);
  }
  load(e2) {
    const { playing: t2, config: r2, onError: a2, onDuration: o2 } = this.props, s2 = e2 && e2.match(b.MATCH_URL_VIDYARD)[1];
    this.player && this.stop(), (0, P.getSDK)("https://play.vidyard.com/embed/v4.js", "VidyardV4", "onVidyardAPI").then((e3) => {
      this.container && (e3.api.addReadyListener((e4, t3) => {
        this.player || (this.player = t3, this.player.on("ready", this.props.onReady), this.player.on("play", this.props.onPlay), this.player.on("pause", this.props.onPause), this.player.on("seek", this.props.onSeek), this.player.on("playerComplete", this.props.onEnded));
      }, s2), e3.api.renderPlayer({ uuid: s2, container: this.container, autoplay: t2 ? 1 : 0, ...r2.options }), e3.api.getPlayerMetadata(s2).then((e4) => {
        this.duration = e4.length_in_seconds, o2(e4.length_in_seconds);
      }));
    }, a2);
  }
  play() {
    this.callPlayer("play");
  }
  pause() {
    this.callPlayer("pause");
  }
  stop() {
    window.VidyardV4.api.destroyPlayer(this.player);
  }
  seekTo(e2, t2 = true) {
    this.callPlayer("seek", e2), t2 || this.pause();
  }
  setVolume(e2) {
    this.callPlayer("setVolume", e2);
  }
  setPlaybackRate(e2) {
    this.callPlayer("setPlaybackSpeed", e2);
  }
  getDuration() {
    return this.duration;
  }
  getCurrentTime() {
    return this.callPlayer("currentTime");
  }
  getSecondsLoaded() {
    return null;
  }
  render() {
    const { display: e2 } = this.props, t2 = { width: "100%", height: "100%", display: e2 };
    return f.default.createElement("div", { style: t2 }, f.default.createElement("div", { ref: this.ref }));
  }
}
d(g, "displayName", "Vidyard"), d(g, "canPlay", b.canPlay.vidyard);
const v = o({ __proto__: null, default: e(m) }, [m]);
export {
  v as V
};
