import { g as e } from "./alasql-f60045ee.js";
import t from "react";
import { u as r, p as s } from "./index-abe53b6f.js";
function o(e2, t2) {
  for (var r2 = 0; r2 < t2.length; r2++) {
    const s2 = t2[r2];
    if ("string" != typeof s2 && !Array.isArray(s2)) {
      for (const t3 in s2)
        if ("default" !== t3 && !(t3 in e2)) {
          const r3 = Object.getOwnPropertyDescriptor(s2, t3);
          r3 && Object.defineProperty(e2, t3, r3.get ? r3 : { enumerable: true, get: () => s2[t3] });
        }
    }
  }
  return Object.freeze(Object.defineProperty(e2, Symbol.toStringTag, { value: "Module" }));
}
var a = Object.create, i = Object.defineProperty, n = Object.getOwnPropertyDescriptor, l = Object.getOwnPropertyNames, p = Object.getPrototypeOf, h = Object.prototype.hasOwnProperty, u = (e2, t2, r2, s2) => {
  if (t2 && "object" == typeof t2 || "function" == typeof t2)
    for (let o2 of l(t2))
      h.call(e2, o2) || o2 === r2 || i(e2, o2, { get: () => t2[o2], enumerable: !(s2 = n(t2, o2)) || s2.enumerable });
  return e2;
}, c = (e2, t2, r2) => (((e3, t3, r3) => {
  t3 in e3 ? i(e3, t3, { enumerable: true, configurable: true, writable: true, value: r3 }) : e3[t3] = r3;
})(e2, "symbol" != typeof t2 ? t2 + "" : t2, r2), r2), y = {};
((e2, t2) => {
  for (var r2 in t2)
    i(e2, r2, { get: t2[r2], enumerable: true });
})(y, { default: () => O });
var d, f = (d = y, u(i({}, "__esModule", { value: true }), d)), m = ((e2, t2, r2) => (r2 = null != e2 ? a(p(e2)) : {}, u(!t2 && e2 && e2.__esModule ? r2 : i(r2, "default", { value: e2, enumerable: true }), e2)))(t), b = r, g = s;
const P = (e2) => e2.replace("/manage/videos", "");
class O extends m.Component {
  constructor() {
    super(...arguments), c(this, "callPlayer", b.callPlayer), c(this, "duration", null), c(this, "currentTime", null), c(this, "secondsLoaded", null), c(this, "mute", () => {
      this.setMuted(true);
    }), c(this, "unmute", () => {
      this.setMuted(false);
    }), c(this, "ref", (e2) => {
      this.container = e2;
    });
  }
  componentDidMount() {
    this.props.onMount && this.props.onMount(this);
  }
  load(e2) {
    this.duration = null, (0, b.getSDK)("https://player.vimeo.com/api/player.js", "Vimeo").then((t2) => {
      if (!this.container)
        return;
      const { playerOptions: r2, title: s2 } = this.props.config;
      this.player = new t2.Player(this.container, { url: P(e2), autoplay: this.props.playing, muted: this.props.muted, loop: this.props.loop, playsinline: this.props.playsinline, controls: this.props.controls, ...r2 }), this.player.ready().then(() => {
        const e3 = this.container.querySelector("iframe");
        e3.style.width = "100%", e3.style.height = "100%", s2 && (e3.title = s2);
      }).catch(this.props.onError), this.player.on("loaded", () => {
        this.props.onReady(), this.refreshDuration();
      }), this.player.on("play", () => {
        this.props.onPlay(), this.refreshDuration();
      }), this.player.on("pause", this.props.onPause), this.player.on("seeked", (e3) => this.props.onSeek(e3.seconds)), this.player.on("ended", this.props.onEnded), this.player.on("error", this.props.onError), this.player.on("timeupdate", ({ seconds: e3 }) => {
        this.currentTime = e3;
      }), this.player.on("progress", ({ seconds: e3 }) => {
        this.secondsLoaded = e3;
      }), this.player.on("bufferstart", this.props.onBuffer), this.player.on("bufferend", this.props.onBufferEnd), this.player.on("playbackratechange", (e3) => this.props.onPlaybackRateChange(e3.playbackRate));
    }, this.props.onError);
  }
  refreshDuration() {
    this.player.getDuration().then((e2) => {
      this.duration = e2;
    });
  }
  play() {
    const e2 = this.callPlayer("play");
    e2 && e2.catch(this.props.onError);
  }
  pause() {
    this.callPlayer("pause");
  }
  stop() {
    this.callPlayer("unload");
  }
  seekTo(e2, t2 = true) {
    this.callPlayer("setCurrentTime", e2), t2 || this.pause();
  }
  setVolume(e2) {
    this.callPlayer("setVolume", e2);
  }
  setMuted(e2) {
    this.callPlayer("setMuted", e2);
  }
  setLoop(e2) {
    this.callPlayer("setLoop", e2);
  }
  setPlaybackRate(e2) {
    this.callPlayer("setPlaybackRate", e2);
  }
  getDuration() {
    return this.duration;
  }
  getCurrentTime() {
    return this.currentTime;
  }
  getSecondsLoaded() {
    return this.secondsLoaded;
  }
  render() {
    const { display: e2 } = this.props, t2 = { width: "100%", height: "100%", overflow: "hidden", display: e2 };
    return m.default.createElement("div", { key: this.props.url, ref: this.ref, style: t2 });
  }
}
c(O, "displayName", "Vimeo"), c(O, "canPlay", g.canPlay.vimeo), c(O, "forceLoad", true);
const j = o({ __proto__: null, default: e(f) }, [f]);
export {
  j as V
};
