import A from "react";
import { __require as E } from "../utils.js";
import { __require as C } from "../patterns.js";
var y, f;
function T() {
  if (f) return y;
  f = 1;
  var m = Object.create, s = Object.defineProperty, v = Object.getOwnPropertyDescriptor, g = Object.getOwnPropertyNames, b = Object.getPrototypeOf, O = Object.prototype.hasOwnProperty, V = (t, e, r) => e in t ? s(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r, D = (t, e) => {
    for (var r in e)
      s(t, r, { get: e[r], enumerable: !0 });
  }, c = (t, e, r, o) => {
    if (e && typeof e == "object" || typeof e == "function")
      for (let a of g(e))
        !O.call(t, a) && a !== r && s(t, a, { get: () => e[a], enumerable: !(o = v(e, a)) || o.enumerable });
    return t;
  }, w = (t, e, r) => (r = t != null ? m(b(t)) : {}, c(
    // If the importer is in node compatibility mode or this is not an ESM
    // file that has been converted to a CommonJS file using a Babel-
    // compatible transform (i.e. "__esModule" has not been set), then set
    // "default" to the CommonJS "module.exports" for node compatibility.
    !t || !t.__esModule ? s(r, "default", { value: t, enumerable: !0 }) : r,
    t
  )), M = (t) => c(s({}, "__esModule", { value: !0 }), t), i = (t, e, r) => (V(t, typeof e != "symbol" ? e + "" : e, r), r), h = {};
  D(h, {
    default: () => l
  }), y = M(h);
  var n = w(A), _ = /* @__PURE__ */ E(), P = /* @__PURE__ */ C();
  const R = "https://play.vidyard.com/embed/v4.js", S = "VidyardV4", L = "onVidyardAPI";
  class l extends n.Component {
    constructor() {
      super(...arguments), i(this, "callPlayer", _.callPlayer), i(this, "mute", () => {
        this.setVolume(0);
      }), i(this, "unmute", () => {
        this.props.volume !== null && this.setVolume(this.props.volume);
      }), i(this, "ref", (e) => {
        this.container = e;
      });
    }
    componentDidMount() {
      this.props.onMount && this.props.onMount(this);
    }
    load(e) {
      const { playing: r, config: o, onError: a, onDuration: q } = this.props, p = e && e.match(P.MATCH_URL_VIDYARD)[1];
      this.player && this.stop(), (0, _.getSDK)(R, S, L).then((u) => {
        this.container && (u.api.addReadyListener((d, j) => {
          this.player || (this.player = j, 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));
        }, p), u.api.renderPlayer({
          uuid: p,
          container: this.container,
          autoplay: r ? 1 : 0,
          ...o.options
        }), u.api.getPlayerMetadata(p).then((d) => {
          this.duration = d.length_in_seconds, q(d.length_in_seconds);
        }));
      }, a);
    }
    play() {
      this.callPlayer("play");
    }
    pause() {
      this.callPlayer("pause");
    }
    stop() {
      window.VidyardV4.api.destroyPlayer(this.player);
    }
    seekTo(e, r = !0) {
      this.callPlayer("seek", e), r || this.pause();
    }
    setVolume(e) {
      this.callPlayer("setVolume", e);
    }
    setPlaybackRate(e) {
      this.callPlayer("setPlaybackSpeed", e);
    }
    getDuration() {
      return this.duration;
    }
    getCurrentTime() {
      return this.callPlayer("currentTime");
    }
    getSecondsLoaded() {
      return null;
    }
    render() {
      const { display: e } = this.props, r = {
        width: "100%",
        height: "100%",
        display: e
      };
      return /* @__PURE__ */ n.default.createElement("div", { style: r }, /* @__PURE__ */ n.default.createElement("div", { ref: this.ref }));
    }
  }
  return i(l, "displayName", "Vidyard"), i(l, "canPlay", P.canPlay.vidyard), y;
}
export {
  T as __require
};
//# sourceMappingURL=Vidyard.js.map
