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