import { commonjsGlobal as P } from "../../../../../../_virtual/_commonjsHelpers.js";
import F from "react";
import { __require as G } from "../../../../deepmerge@4.3.1/node_modules/deepmerge/dist/cjs.js";
import W from "../../../../../../_virtual/memoize-one.esm.js";
import { __require as $ } from "../../../../react-fast-compare@3.2.2/node_modules/react-fast-compare/index.js";
import { __require as J } from "./props.js";
import { __require as H } from "./utils.js";
import { __require as K } from "./Player.js";
var _, b;
function ae() {
  if (b) return _;
  b = 1;
  var O = Object.create, l = Object.defineProperty, R = Object.getOwnPropertyDescriptor, C = Object.getOwnPropertyNames, S = Object.getPrototypeOf, q = Object.prototype.hasOwnProperty, E = (t, s, a) => s in t ? l(t, s, { enumerable: !0, configurable: !0, writable: !0, value: a }) : t[s] = a, I = (t, s) => {
    for (var a in s)
      l(t, a, { get: s[a], enumerable: !0 });
  }, m = (t, s, a, e) => {
    if (s && typeof s == "object" || typeof s == "function")
      for (let r of C(s))
        !q.call(t, r) && r !== a && l(t, r, { get: () => s[r], enumerable: !(e = R(s, r)) || e.enumerable });
    return t;
  }, p = (t, s, a) => (a = t != null ? O(S(t)) : {}, m(
    // 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 ? l(a, "default", { value: t, enumerable: !0 }) : a,
    t
  )), T = (t) => m(l({}, "__esModule", { value: !0 }), t), i = (t, s, a) => (E(t, typeof s != "symbol" ? s + "" : s, a), a), v = {};
  I(v, {
    createReactPlayer: () => N
  }), _ = T(v);
  var o = p(F), j = p(G()), h = p(W), w = p($()), u = /* @__PURE__ */ J(), g = /* @__PURE__ */ H(), k = p(/* @__PURE__ */ K());
  const A = (0, g.lazy)(() => import(
    /* webpackChunkName: 'reactPlayerPreview' */
    "../../../../../../_virtual/Preview.js"
  ).then((t) => t.P)), D = typeof window < "u" && window.document && typeof document < "u", U = typeof P < "u" && P.window && P.window.document, x = Object.keys(u.propTypes), L = D || U ? o.Suspense : () => null, c = [], N = (t, s) => {
    var a;
    return a = class extends o.Component {
      constructor() {
        super(...arguments), i(this, "state", {
          showPreview: !!this.props.light
        }), i(this, "references", {
          wrapper: (e) => {
            this.wrapper = e;
          },
          player: (e) => {
            this.player = e;
          }
        }), i(this, "handleClickPreview", (e) => {
          this.setState({ showPreview: !1 }), this.props.onClickPreview(e);
        }), i(this, "showPreview", () => {
          this.setState({ showPreview: !0 });
        }), i(this, "getDuration", () => this.player ? this.player.getDuration() : null), i(this, "getCurrentTime", () => this.player ? this.player.getCurrentTime() : null), i(this, "getSecondsLoaded", () => this.player ? this.player.getSecondsLoaded() : null), i(this, "getInternalPlayer", (e = "player") => this.player ? this.player.getInternalPlayer(e) : null), i(this, "seekTo", (e, r, n) => {
          if (!this.player)
            return null;
          this.player.seekTo(e, r, n);
        }), i(this, "handleReady", () => {
          this.props.onReady(this);
        }), i(this, "getActivePlayer", (0, h.default)((e) => {
          for (const r of [...c, ...t])
            if (r.canPlay(e))
              return r;
          return s || null;
        })), i(this, "getConfig", (0, h.default)((e, r) => {
          const { config: n } = this.props;
          return j.default.all([
            u.defaultProps.config,
            u.defaultProps.config[r] || {},
            n,
            n[r] || {}
          ]);
        })), i(this, "getAttributes", (0, h.default)((e) => (0, g.omit)(this.props, x))), i(this, "renderActivePlayer", (e) => {
          if (!e)
            return null;
          const r = this.getActivePlayer(e);
          if (!r)
            return null;
          const n = this.getConfig(e, r.key);
          return /* @__PURE__ */ o.default.createElement(
            k.default,
            {
              ...this.props,
              key: r.key,
              ref: this.references.player,
              config: n,
              activePlayer: r.lazyPlayer || r,
              onReady: this.handleReady
            }
          );
        });
      }
      shouldComponentUpdate(e, r) {
        return !(0, w.default)(this.props, e) || !(0, w.default)(this.state, r);
      }
      componentDidUpdate(e) {
        const { light: r } = this.props;
        !e.light && r && this.setState({ showPreview: !0 }), e.light && !r && this.setState({ showPreview: !1 });
      }
      renderPreview(e) {
        if (!e)
          return null;
        const { light: r, playIcon: n, previewTabIndex: y, oEmbedUrl: d, previewAriaLabel: f } = this.props;
        return /* @__PURE__ */ o.default.createElement(
          A,
          {
            url: e,
            light: r,
            playIcon: n,
            previewTabIndex: y,
            previewAriaLabel: f,
            oEmbedUrl: d,
            onClick: this.handleClickPreview
          }
        );
      }
      render() {
        const { url: e, style: r, width: n, height: y, fallback: d, wrapper: f } = this.props, { showPreview: M } = this.state, z = this.getAttributes(e), B = typeof f == "string" ? this.references.wrapper : void 0;
        return /* @__PURE__ */ o.default.createElement(f, { ref: B, style: { ...r, width: n, height: y }, ...z }, /* @__PURE__ */ o.default.createElement(L, { fallback: d }, M ? this.renderPreview(e) : this.renderActivePlayer(e)));
      }
    }, i(a, "displayName", "ReactPlayer"), i(a, "propTypes", u.propTypes), i(a, "defaultProps", u.defaultProps), i(a, "addCustomPlayer", (e) => {
      c.push(e);
    }), i(a, "removeCustomPlayers", () => {
      c.length = 0;
    }), i(a, "canPlay", (e) => {
      for (const r of [...c, ...t])
        if (r.canPlay(e))
          return !0;
      return !1;
    }), i(a, "canEnablePIP", (e) => {
      for (const r of [...c, ...t])
        if (r.canEnablePIP && r.canEnablePIP(e))
          return !0;
      return !1;
    }), a;
  };
  return _;
}
export {
  ae as __require
};
//# sourceMappingURL=ReactPlayer.js.map
