import j from "react";
import { __require as q } from "../utils.js";
import { __require as D } from "../patterns.js";
var l, d;
function E() {
  if (d) return l;
  d = 1;
  var _ = Object.create, o = Object.defineProperty, m = Object.getOwnPropertyDescriptor, y = Object.getOwnPropertyNames, f = Object.getPrototypeOf, P = Object.prototype.hasOwnProperty, v = (t, e, r) => e in t ? o(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r, b = (t, e) => {
    for (var r in e)
      o(t, r, { get: e[r], enumerable: !0 });
  }, u = (t, e, r, i) => {
    if (e && typeof e == "object" || typeof e == "function")
      for (let s of y(e))
        !P.call(t, s) && s !== r && o(t, s, { get: () => e[s], enumerable: !(i = m(e, s)) || i.enumerable });
    return t;
  }, g = (t, e, r) => (r = t != null ? _(f(t)) : {}, u(
    // 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 ? o(r, "default", { value: t, enumerable: !0 }) : r,
    t
  )), O = (t) => u(o({}, "__esModule", { value: !0 }), t), a = (t, e, r) => (v(t, typeof e != "symbol" ? e + "" : e, r), r), p = {};
  b(p, {
    default: () => n
  }), l = O(p);
  var c = g(j), h = /* @__PURE__ */ q(), w = /* @__PURE__ */ D();
  const L = "https://cdn.embed.ly/player-0.1.0.min.js", K = "playerjs";
  class n extends c.Component {
    constructor() {
      super(...arguments), a(this, "callPlayer", h.callPlayer), a(this, "duration", null), a(this, "currentTime", null), a(this, "secondsLoaded", null), a(this, "mute", () => {
        this.callPlayer("mute");
      }), a(this, "unmute", () => {
        this.callPlayer("unmute");
      }), a(this, "ref", (e) => {
        this.iframe = e;
      });
    }
    componentDidMount() {
      this.props.onMount && this.props.onMount(this);
    }
    load(e) {
      (0, h.getSDK)(L, K).then((r) => {
        this.iframe && (this.player = new r.Player(this.iframe), this.player.on("ready", () => {
          setTimeout(() => {
            this.player.isReady = !0, this.player.setLoop(this.props.loop), this.props.muted && this.player.mute(), this.addListeners(this.player, this.props), this.props.onReady();
          }, 500);
        }));
      }, this.props.onError);
    }
    addListeners(e, r) {
      e.on("play", r.onPlay), e.on("pause", r.onPause), e.on("ended", r.onEnded), e.on("error", r.onError), e.on("timeupdate", ({ duration: i, seconds: s }) => {
        this.duration = i, this.currentTime = s;
      });
    }
    play() {
      this.callPlayer("play");
    }
    pause() {
      this.callPlayer("pause");
    }
    stop() {
    }
    seekTo(e, r = !0) {
      this.callPlayer("setCurrentTime", e), r || this.pause();
    }
    setVolume(e) {
      this.callPlayer("setVolume", e);
    }
    setLoop(e) {
      this.callPlayer("setLoop", e);
    }
    getDuration() {
      return this.duration;
    }
    getCurrentTime() {
      return this.currentTime;
    }
    getSecondsLoaded() {
      return this.secondsLoaded;
    }
    render() {
      const e = {
        width: "100%",
        height: "100%"
      };
      return /* @__PURE__ */ c.default.createElement(
        "iframe",
        {
          ref: this.ref,
          src: this.props.url,
          frameBorder: "0",
          scrolling: "no",
          style: e,
          allow: "encrypted-media; autoplay; fullscreen;",
          referrerPolicy: "no-referrer-when-downgrade"
        }
      );
    }
  }
  return a(n, "displayName", "Kaltura"), a(n, "canPlay", w.canPlay.kaltura), l;
}
export {
  E as __require
};
//# sourceMappingURL=Kaltura.js.map
