import M from "react";
import { __require as W } from "../utils.js";
import { __require as L } from "../patterns.js";
var h, P;
function A() {
  if (P) return h;
  P = 1;
  var b = Object.create, n = Object.defineProperty, m = Object.getOwnPropertyDescriptor, f = Object.getOwnPropertyNames, v = Object.getPrototypeOf, g = Object.prototype.hasOwnProperty, w = (t, e, a) => e in t ? n(t, e, { enumerable: !0, configurable: !0, writable: !0, value: a }) : t[e] = a, O = (t, e) => {
    for (var a in e)
      n(t, a, { get: e[a], enumerable: !0 });
  }, c = (t, e, a, i) => {
    if (e && typeof e == "object" || typeof e == "function")
      for (let r of f(e))
        !g.call(t, r) && r !== a && n(t, r, { get: () => e[r], enumerable: !(i = m(e, r)) || i.enumerable });
    return t;
  }, C = (t, e, a) => (a = t != null ? b(v(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 ? n(a, "default", { value: t, enumerable: !0 }) : a,
    t
  )), R = (t) => c(n({}, "__esModule", { value: !0 }), t), s = (t, e, a) => (w(t, typeof e != "symbol" ? e + "" : e, a), a), y = {};
  O(y, {
    default: () => o
  }), h = R(y);
  var d = C(M), l = /* @__PURE__ */ W(), _ = /* @__PURE__ */ L();
  const k = "https://fast.wistia.com/assets/external/E-v1.js", D = "Wistia", E = "wistia-player-";
  class o extends d.Component {
    constructor() {
      super(...arguments), s(this, "callPlayer", l.callPlayer), s(this, "playerID", this.props.config.playerId || `${E}${(0, l.randomString)()}`), s(this, "onPlay", (...e) => this.props.onPlay(...e)), s(this, "onPause", (...e) => this.props.onPause(...e)), s(this, "onSeek", (...e) => this.props.onSeek(...e)), s(this, "onEnded", (...e) => this.props.onEnded(...e)), s(this, "onPlaybackRateChange", (...e) => this.props.onPlaybackRateChange(...e)), s(this, "mute", () => {
        this.callPlayer("mute");
      }), s(this, "unmute", () => {
        this.callPlayer("unmute");
      });
    }
    componentDidMount() {
      this.props.onMount && this.props.onMount(this);
    }
    load(e) {
      const { playing: a, muted: i, controls: r, onReady: S, config: p, onError: q } = this.props;
      (0, l.getSDK)(k, D).then((I) => {
        p.customControls && p.customControls.forEach((u) => I.defineControl(u)), window._wq = window._wq || [], window._wq.push({
          id: this.playerID,
          options: {
            autoPlay: a,
            silentAutoPlay: "allow",
            muted: i,
            controlsVisibleOnLoad: r,
            fullscreenButton: r,
            playbar: r,
            playbackRateControl: r,
            qualityControl: r,
            volumeControl: r,
            settingsControl: r,
            smallPlayButton: r,
            ...p.options
          },
          onReady: (u) => {
            this.player = u, this.unbind(), this.player.bind("play", this.onPlay), this.player.bind("pause", this.onPause), this.player.bind("seek", this.onSeek), this.player.bind("end", this.onEnded), this.player.bind("playbackratechange", this.onPlaybackRateChange), S();
          }
        });
      }, q);
    }
    unbind() {
      this.player.unbind("play", this.onPlay), this.player.unbind("pause", this.onPause), this.player.unbind("seek", this.onSeek), this.player.unbind("end", this.onEnded), this.player.unbind("playbackratechange", this.onPlaybackRateChange);
    }
    play() {
      this.callPlayer("play");
    }
    pause() {
      this.callPlayer("pause");
    }
    stop() {
      this.unbind(), this.callPlayer("remove");
    }
    seekTo(e, a = !0) {
      this.callPlayer("time", e), a || this.pause();
    }
    setVolume(e) {
      this.callPlayer("volume", e);
    }
    setPlaybackRate(e) {
      this.callPlayer("playbackRate", e);
    }
    getDuration() {
      return this.callPlayer("duration");
    }
    getCurrentTime() {
      return this.callPlayer("time");
    }
    getSecondsLoaded() {
      return null;
    }
    render() {
      const { url: e } = this.props, a = e && e.match(_.MATCH_URL_WISTIA)[1], i = `wistia_embed wistia_async_${a}`, r = {
        width: "100%",
        height: "100%"
      };
      return /* @__PURE__ */ d.default.createElement("div", { id: this.playerID, key: a, className: i, style: r });
    }
  }
  return s(o, "displayName", "Wistia"), s(o, "canPlay", _.canPlay.wistia), s(o, "loopOnEnded", !0), h;
}
export {
  A as __require
};
//# sourceMappingURL=Wistia.js.map
