import { H as T } from "./use-page-data.BYLN5MSa.js";
import N from "react";
import { r as x, a as A } from "./video.Ctm1aA2_.js";
function q(l, s) {
  for (var p = 0; p < s.length; p++) {
    const i = s[p];
    if (typeof i != "string" && !Array.isArray(i)) {
      for (const n in i)
        if (n !== "default" && !(n in l)) {
          const d = Object.getOwnPropertyDescriptor(i, n);
          d && Object.defineProperty(l, n, d.get ? d : {
            enumerable: !0,
            get: () => i[n]
          });
        }
    }
  }
  return Object.freeze(Object.defineProperty(l, Symbol.toStringTag, { value: "Module" }));
}
var f, g;
function U() {
  if (g) return f;
  g = 1;
  var l = Object.create, s = Object.defineProperty, p = Object.getOwnPropertyDescriptor, i = Object.getOwnPropertyNames, n = Object.getPrototypeOf, d = Object.prototype.hasOwnProperty, v = (t, e, r) => e in t ? s(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r, O = (t, e) => {
    for (var r in e)
      s(t, r, { get: e[r], enumerable: !0 });
  }, _ = (t, e, r, c) => {
    if (e && typeof e == "object" || typeof e == "function")
      for (let a of i(e))
        !d.call(t, a) && a !== r && s(t, a, { get: () => e[a], enumerable: !(c = p(e, a)) || c.enumerable });
    return t;
  }, S = (t, e, r) => (r = t != null ? l(n(t)) : {}, _(
    // 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
  )), C = (t) => _(s({}, "__esModule", { value: !0 }), t), o = (t, e, r) => (v(t, typeof e != "symbol" ? e + "" : e, r), r), m = {};
  O(m, {
    default: () => h
  }), f = C(m);
  var y = S(N), P = /* @__PURE__ */ x(), w = /* @__PURE__ */ A();
  const j = "https://w.soundcloud.com/player/api.js", E = "SC";
  class h extends y.Component {
    constructor() {
      super(...arguments), o(this, "callPlayer", P.callPlayer), o(this, "duration", null), o(this, "currentTime", null), o(this, "fractionLoaded", null), o(this, "mute", () => {
        this.setVolume(0);
      }), o(this, "unmute", () => {
        this.props.volume !== null && this.setVolume(this.props.volume);
      }), o(this, "ref", (e) => {
        this.iframe = e;
      });
    }
    componentDidMount() {
      this.props.onMount && this.props.onMount(this);
    }
    load(e, r) {
      (0, P.getSDK)(j, E).then((c) => {
        if (!this.iframe)
          return;
        const { PLAY: a, PLAY_PROGRESS: D, PAUSE: R, FINISH: L, ERROR: M } = c.Widget.Events;
        r || (this.player = c.Widget(this.iframe), this.player.bind(a, this.props.onPlay), this.player.bind(R, () => {
          this.duration - this.currentTime < 0.05 || this.props.onPause();
        }), this.player.bind(D, (u) => {
          this.currentTime = u.currentPosition / 1e3, this.fractionLoaded = u.loadedProgress;
        }), this.player.bind(L, () => this.props.onEnded()), this.player.bind(M, (u) => this.props.onError(u))), this.player.load(e, {
          ...this.props.config.options,
          callback: () => {
            this.player.getDuration((u) => {
              this.duration = u / 1e3, this.props.onReady();
            });
          }
        });
      });
    }
    play() {
      this.callPlayer("play");
    }
    pause() {
      this.callPlayer("pause");
    }
    stop() {
    }
    seekTo(e, r = !0) {
      this.callPlayer("seekTo", e * 1e3), r || this.pause();
    }
    setVolume(e) {
      this.callPlayer("setVolume", e * 100);
    }
    getDuration() {
      return this.duration;
    }
    getCurrentTime() {
      return this.currentTime;
    }
    getSecondsLoaded() {
      return this.fractionLoaded * this.duration;
    }
    render() {
      const { display: e } = this.props, r = {
        width: "100%",
        height: "100%",
        display: e
      };
      return /* @__PURE__ */ y.default.createElement(
        "iframe",
        {
          ref: this.ref,
          src: `https://w.soundcloud.com/player/?url=${encodeURIComponent(this.props.url)}`,
          style: r,
          frameBorder: 0,
          allow: "autoplay"
        }
      );
    }
  }
  return o(h, "displayName", "SoundCloud"), o(h, "canPlay", w.canPlay.soundcloud), o(h, "loopOnEnded", !0), f;
}
var b = /* @__PURE__ */ U();
const V = /* @__PURE__ */ T(b), B = /* @__PURE__ */ q({
  __proto__: null,
  default: V
}, [b]);
export {
  B as S
};
