import { openBlock as T, createElementBlock as S, defineComponent as Z, useTemplateRef as qe, ref as O, toRaw as Ye, watch as ne, nextTick as Le, createCommentVNode as R, shallowRef as De, reactive as ge, normalizeStyle as ce, toDisplayString as ue, normalizeClass as V, createElementVNode as M, unref as pe, computed as A, createVNode as X, createBlock as J, onMounted as $e, onBeforeUnmount as We, createTextVNode as Je } from "vue";
const he = (i, e) => {
  const n = i.__vccOpts || i;
  for (const [t, r] of e)
    n[t] = r;
  return n;
}, Xe = {}, Ke = { class: "cf-player__loader" };
function Qe(i, e) {
  return T(), S("div", Ke);
}
const et = /* @__PURE__ */ he(Xe, [["render", Qe]]), H = /* @__PURE__ */ new WeakMap(), W = /* @__PURE__ */ new WeakMap(), F = /* @__PURE__ */ new WeakMap(), me = /* @__PURE__ */ Symbol("anyProducer"), Ie = Promise.resolve(), ve = /* @__PURE__ */ Symbol("listenerAdded"), ye = /* @__PURE__ */ Symbol("listenerRemoved");
let we = !1, Ce = !1;
const be = (i) => typeof i == "string" || typeof i == "symbol" || typeof i == "number";
function Q(i) {
  if (!be(i))
    throw new TypeError("`eventName` must be a string, symbol, or number");
}
function fe(i) {
  if (typeof i != "function")
    throw new TypeError("listener must be a function");
}
function ee(i, e) {
  const n = W.get(i);
  if (n.has(e))
    return n.get(e);
}
function le(i, e) {
  const n = be(e) ? e : me, t = F.get(i);
  if (t.has(n))
    return t.get(n);
}
function tt(i, e, n) {
  const t = F.get(i);
  if (t.has(e))
    for (const r of t.get(e))
      r.enqueue(n);
  if (t.has(me)) {
    const r = Promise.all([e, n]);
    for (const s of t.get(me))
      s.enqueue(r);
  }
}
function ze(i, e) {
  e = Array.isArray(e) ? e : [e];
  let n = !1, t = () => {
  }, r = [];
  const s = {
    enqueue(o) {
      r.push(o), t();
    },
    finish() {
      n = !0, t();
    }
  };
  for (const o of e) {
    let a = le(i, o);
    a || (a = /* @__PURE__ */ new Set(), F.get(i).set(o, a)), a.add(s);
  }
  return {
    async next() {
      return r ? r.length === 0 ? n ? (r = void 0, this.next()) : (await new Promise((o) => {
        t = o;
      }), this.next()) : {
        done: !1,
        value: await r.shift()
      } : { done: !0 };
    },
    async return(o) {
      r = void 0;
      for (const a of e) {
        const h = le(i, a);
        h && (h.delete(s), h.size === 0 && F.get(i).delete(a));
      }
      return t(), arguments.length > 0 ? { done: !0, value: await o } : { done: !0 };
    },
    [Symbol.asyncIterator]() {
      return this;
    }
  };
}
function Oe(i) {
  if (i === void 0)
    return Me;
  if (!Array.isArray(i))
    throw new TypeError("`methodNames` must be an array of strings");
  for (const e of i)
    if (!Me.includes(e))
      throw typeof e != "string" ? new TypeError("`methodNames` element must be a string") : new Error(`${e} is not Emittery method`);
  return i;
}
const te = (i) => i === ve || i === ye;
function de(i, e, n) {
  if (te(e))
    try {
      we = !0, i.emit(e, n);
    } finally {
      we = !1;
    }
}
class U {
  static mixin(e, n) {
    return n = Oe(n), (t) => {
      if (typeof t != "function")
        throw new TypeError("`target` must be function");
      for (const o of n)
        if (t.prototype[o] !== void 0)
          throw new Error(`The property \`${o}\` already exists on \`target\``);
      function r() {
        return Object.defineProperty(this, e, {
          enumerable: !1,
          value: new U()
        }), this[e];
      }
      Object.defineProperty(t.prototype, e, {
        enumerable: !1,
        get: r
      });
      const s = (o) => function(...a) {
        return this[e][o](...a);
      };
      for (const o of n)
        Object.defineProperty(t.prototype, o, {
          enumerable: !1,
          value: s(o)
        });
      return t;
    };
  }
  static get isDebugEnabled() {
    if (typeof globalThis.process?.env != "object")
      return Ce;
    const { env: e } = globalThis.process ?? { env: {} };
    return e.DEBUG === "emittery" || e.DEBUG === "*" || Ce;
  }
  static set isDebugEnabled(e) {
    Ce = e;
  }
  constructor(e = {}) {
    H.set(this, /* @__PURE__ */ new Set()), W.set(this, /* @__PURE__ */ new Map()), F.set(this, /* @__PURE__ */ new Map()), F.get(this).set(me, /* @__PURE__ */ new Set()), this.debug = e.debug ?? {}, this.debug.enabled === void 0 && (this.debug.enabled = !1), this.debug.logger || (this.debug.logger = (n, t, r, s) => {
      try {
        s = JSON.stringify(s);
      } catch {
        s = `Object with the following keys failed to stringify: ${Object.keys(s).join(",")}`;
      }
      (typeof r == "symbol" || typeof r == "number") && (r = r.toString());
      const o = /* @__PURE__ */ new Date(), a = `${o.getHours()}:${o.getMinutes()}:${o.getSeconds()}.${o.getMilliseconds()}`;
      console.log(`[${a}][emittery:${n}][${t}] Event Name: ${r}
	data: ${s}`);
    });
  }
  logIfDebugEnabled(e, n, t) {
    (U.isDebugEnabled || this.debug.enabled) && this.debug.logger(e, this.debug.name, n, t);
  }
  on(e, n, { signal: t } = {}) {
    fe(n), e = Array.isArray(e) ? e : [e];
    for (const s of e) {
      Q(s);
      let o = ee(this, s);
      o || (o = /* @__PURE__ */ new Set(), W.get(this).set(s, o)), o.add(n), this.logIfDebugEnabled("subscribe", s, void 0), te(s) || de(this, ve, { eventName: s, listener: n });
    }
    const r = () => {
      this.off(e, n), t?.removeEventListener("abort", r);
    };
    return t?.addEventListener("abort", r, { once: !0 }), t?.aborted && r(), r;
  }
  off(e, n) {
    fe(n), e = Array.isArray(e) ? e : [e];
    for (const t of e) {
      Q(t);
      const r = ee(this, t);
      r && (r.delete(n), r.size === 0 && W.get(this).delete(t)), this.logIfDebugEnabled("unsubscribe", t, void 0), te(t) || de(this, ye, { eventName: t, listener: n });
    }
  }
  once(e, n) {
    if (n !== void 0 && typeof n != "function")
      throw new TypeError("predicate must be a function");
    let t;
    const r = new Promise((s) => {
      t = this.on(e, (o) => {
        n && !n(o) || (t(), s(o));
      });
    });
    return r.off = t, r;
  }
  events(e) {
    e = Array.isArray(e) ? e : [e];
    for (const n of e)
      Q(n);
    return ze(this, e);
  }
  async emit(e, n) {
    if (Q(e), te(e) && !we)
      throw new TypeError("`eventName` cannot be meta event `listenerAdded` or `listenerRemoved`");
    this.logIfDebugEnabled("emit", e, n), tt(this, e, n);
    const t = ee(this, e) ?? /* @__PURE__ */ new Set(), r = H.get(this), s = [...t], o = te(e) ? [] : [...r];
    await Ie, await Promise.all([
      ...s.map(async (a) => {
        if (t.has(a))
          return a(n);
      }),
      ...o.map(async (a) => {
        if (r.has(a))
          return a(e, n);
      })
    ]);
  }
  async emitSerial(e, n) {
    if (Q(e), te(e) && !we)
      throw new TypeError("`eventName` cannot be meta event `listenerAdded` or `listenerRemoved`");
    this.logIfDebugEnabled("emitSerial", e, n);
    const t = ee(this, e) ?? /* @__PURE__ */ new Set(), r = H.get(this), s = [...t], o = [...r];
    await Ie;
    for (const a of s)
      t.has(a) && await a(n);
    for (const a of o)
      r.has(a) && await a(e, n);
  }
  onAny(e, { signal: n } = {}) {
    fe(e), this.logIfDebugEnabled("subscribeAny", void 0, void 0), H.get(this).add(e), de(this, ve, { listener: e });
    const t = () => {
      this.offAny(e), n?.removeEventListener("abort", t);
    };
    return n?.addEventListener("abort", t, { once: !0 }), n?.aborted && t(), t;
  }
  anyEvent() {
    return ze(this);
  }
  offAny(e) {
    fe(e), this.logIfDebugEnabled("unsubscribeAny", void 0, void 0), de(this, ye, { listener: e }), H.get(this).delete(e);
  }
  clearListeners(e) {
    e = Array.isArray(e) ? e : [e];
    for (const n of e)
      if (this.logIfDebugEnabled("clear", n, void 0), be(n)) {
        const t = ee(this, n);
        t && t.clear();
        const r = le(this, n);
        if (r) {
          for (const s of r)
            s.finish();
          r.clear();
        }
      } else {
        H.get(this).clear();
        for (const [t, r] of W.get(this).entries())
          r.clear(), W.get(this).delete(t);
        for (const [t, r] of F.get(this).entries()) {
          for (const s of r)
            s.finish();
          r.clear(), F.get(this).delete(t);
        }
      }
  }
  listenerCount(e) {
    e = Array.isArray(e) ? e : [e];
    let n = 0;
    for (const t of e) {
      if (be(t)) {
        n += H.get(this).size + (ee(this, t)?.size ?? 0) + (le(this, t)?.size ?? 0) + (le(this)?.size ?? 0);
        continue;
      }
      t !== void 0 && Q(t), n += H.get(this).size;
      for (const r of W.get(this).values())
        n += r.size;
      for (const r of F.get(this).values())
        n += r.size;
    }
    return n;
  }
  bindMethods(e, n) {
    if (typeof e != "object" || e === null)
      throw new TypeError("`target` must be an object");
    n = Oe(n);
    for (const t of n) {
      if (e[t] !== void 0)
        throw new Error(`The property \`${t}\` already exists on \`target\``);
      Object.defineProperty(e, t, {
        enumerable: !1,
        value: this[t].bind(this)
      });
    }
  }
}
const Me = Object.getOwnPropertyNames(U.prototype).filter((i) => i !== "constructor");
Object.defineProperty(U, "listenerAdded", {
  value: ve,
  writable: !1,
  enumerable: !0,
  configurable: !1
});
Object.defineProperty(U, "listenerRemoved", {
  value: ye,
  writable: !1,
  enumerable: !0,
  configurable: !1
});
function q(i) {
  return q = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(e) {
    return typeof e;
  } : function(e) {
    return e && typeof Symbol == "function" && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e;
  }, q(i);
}
function Fe(i, e) {
  if (!(i instanceof e)) throw new TypeError("Cannot call a class as a function");
}
function nt(i) {
  var e = (function(n, t) {
    if (q(n) != "object" || !n) return n;
    var r = n[Symbol.toPrimitive];
    if (r !== void 0) {
      var s = r.call(n, t);
      if (q(s) != "object") return s;
      throw new TypeError("@@toPrimitive must return a primitive value.");
    }
    return String(n);
  })(i, "string");
  return q(e) == "symbol" ? e : String(e);
}
function rt(i, e) {
  for (var n = 0; n < e.length; n++) {
    var t = e[n];
    t.enumerable = t.enumerable || !1, t.configurable = !0, "value" in t && (t.writable = !0), Object.defineProperty(i, nt(t.key), t);
  }
}
function Ve(i, e, n) {
  return e && rt(i.prototype, e), Object.defineProperty(i, "prototype", { writable: !1 }), i;
}
var it = (function() {
  function i() {
    Fe(this, i), this._listeners = {};
  }
  return Ve(i, [{ key: "on", value: function(e, n) {
    var t = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : 0;
    this._listeners[e] || (this._listeners[e] = []), n._priority = parseInt(t) || 0, this._listeners[e].indexOf(n) === -1 && (this._listeners[e].push(n), this._listeners[e].length > 1 && this._listeners[e].sort(this.listenerSorter));
  } }, { key: "listenerSorter", value: function(e, n) {
    return e._priority - n._priority;
  } }, { key: "off", value: function(e, n) {
    if (this._listeners[e] !== void 0) if (n !== void 0) {
      var t = this._listeners[e].indexOf(n);
      -1 < t && this._listeners[e].splice(t, 1);
    } else delete this._listeners[e];
  } }, { key: "trigger", value: function(e) {
    var n = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
    if (typeof e == "string" && (e = { type: e, data: q(n) === "object" && n !== null ? n : {} }), this._listeners[e.type] !== void 0) for (var t = this._listeners[e.type].length - 1; t >= 0; t--) this._listeners[e.type][t](e);
  } }, { key: "destroy", value: function() {
    this._listeners = {};
  } }]), i;
})();
function Pe() {
  Pe = function() {
    return e;
  };
  var i, e = {}, n = Object.prototype, t = n.hasOwnProperty, r = Object.defineProperty || function(c, l, f) {
    c[l] = f.value;
  }, s = typeof Symbol == "function" ? Symbol : {}, o = s.iterator || "@@iterator", a = s.asyncIterator || "@@asyncIterator", h = s.toStringTag || "@@toStringTag";
  function u(c, l, f) {
    return Object.defineProperty(c, l, { value: f, enumerable: !0, configurable: !0, writable: !0 }), c[l];
  }
  try {
    u({}, "");
  } catch {
    u = function(l, f, C) {
      return l[f] = C;
    };
  }
  function g(c, l, f, C) {
    var b = l && l.prototype instanceof m ? l : m, P = Object.create(b.prototype), L = new G(C || []);
    return r(P, "_invoke", { value: _e(c, f, L) }), P;
  }
  function d(c, l, f) {
    try {
      return { type: "normal", arg: c.call(l, f) };
    } catch (C) {
      return { type: "throw", arg: C };
    }
  }
  e.wrap = g;
  var v = "suspendedStart", x = "suspendedYield", y = "executing", w = "completed", p = {};
  function m() {
  }
  function k() {
  }
  function E() {
  }
  var j = {};
  u(j, o, (function() {
    return this;
  }));
  var $ = Object.getPrototypeOf, D = $ && $($(se([])));
  D && D !== n && t.call(D, o) && (j = D);
  var B = E.prototype = m.prototype = Object.create(j);
  function ie(c) {
    ["next", "throw", "return"].forEach((function(l) {
      u(c, l, (function(f) {
        return this._invoke(l, f);
      }));
    }));
  }
  function K(c, l) {
    function f(b, P, L, I) {
      var _ = d(c[b], c, P);
      if (_.type !== "throw") {
        var z = _.arg, ae = z.value;
        return ae && q(ae) == "object" && t.call(ae, "__await") ? l.resolve(ae.__await).then((function(Y) {
          f("next", Y, L, I);
        }), (function(Y) {
          f("throw", Y, L, I);
        })) : l.resolve(ae).then((function(Y) {
          z.value = Y, L(z);
        }), (function(Y) {
          return f("throw", Y, L, I);
        }));
      }
      I(_.arg);
    }
    var C;
    r(this, "_invoke", { value: function(b, P) {
      function L() {
        return new l((function(I, _) {
          f(b, P, I, _);
        }));
      }
      return C = C ? C.then(L, L) : L();
    } });
  }
  function _e(c, l, f) {
    var C = v;
    return function(b, P) {
      if (C === y) throw new Error("Generator is already running");
      if (C === w) {
        if (b === "throw") throw P;
        return { value: i, done: !0 };
      }
      for (f.method = b, f.arg = P; ; ) {
        var L = f.delegate;
        if (L) {
          var I = oe(L, f);
          if (I) {
            if (I === p) continue;
            return I;
          }
        }
        if (f.method === "next") f.sent = f._sent = f.arg;
        else if (f.method === "throw") {
          if (C === v) throw C = w, f.arg;
          f.dispatchException(f.arg);
        } else f.method === "return" && f.abrupt("return", f.arg);
        C = y;
        var _ = d(c, l, f);
        if (_.type === "normal") {
          if (C = f.done ? w : x, _.arg === p) continue;
          return { value: _.arg, done: f.done };
        }
        _.type === "throw" && (C = w, f.method = "throw", f.arg = _.arg);
      }
    };
  }
  function oe(c, l) {
    var f = l.method, C = c.iterator[f];
    if (C === i) return l.delegate = null, f === "throw" && c.iterator.return && (l.method = "return", l.arg = i, oe(c, l), l.method === "throw") || f !== "return" && (l.method = "throw", l.arg = new TypeError("The iterator does not provide a '" + f + "' method")), p;
    var b = d(C, c.iterator, l.arg);
    if (b.type === "throw") return l.method = "throw", l.arg = b.arg, l.delegate = null, p;
    var P = b.arg;
    return P ? P.done ? (l[c.resultName] = P.value, l.next = c.nextLoc, l.method !== "return" && (l.method = "next", l.arg = i), l.delegate = null, p) : P : (l.method = "throw", l.arg = new TypeError("iterator result is not an object"), l.delegate = null, p);
  }
  function xe(c) {
    var l = { tryLoc: c[0] };
    1 in c && (l.catchLoc = c[1]), 2 in c && (l.finallyLoc = c[2], l.afterLoc = c[3]), this.tryEntries.push(l);
  }
  function N(c) {
    var l = c.completion || {};
    l.type = "normal", delete l.arg, c.completion = l;
  }
  function G(c) {
    this.tryEntries = [{ tryLoc: "root" }], c.forEach(xe, this), this.reset(!0);
  }
  function se(c) {
    if (c || c === "") {
      var l = c[o];
      if (l) return l.call(c);
      if (typeof c.next == "function") return c;
      if (!isNaN(c.length)) {
        var f = -1, C = function b() {
          for (; ++f < c.length; ) if (t.call(c, f)) return b.value = c[f], b.done = !1, b;
          return b.value = i, b.done = !0, b;
        };
        return C.next = C;
      }
    }
    throw new TypeError(q(c) + " is not iterable");
  }
  return k.prototype = E, r(B, "constructor", { value: E, configurable: !0 }), r(E, "constructor", { value: k, configurable: !0 }), k.displayName = u(E, h, "GeneratorFunction"), e.isGeneratorFunction = function(c) {
    var l = typeof c == "function" && c.constructor;
    return !!l && (l === k || (l.displayName || l.name) === "GeneratorFunction");
  }, e.mark = function(c) {
    return Object.setPrototypeOf ? Object.setPrototypeOf(c, E) : (c.__proto__ = E, u(c, h, "GeneratorFunction")), c.prototype = Object.create(B), c;
  }, e.awrap = function(c) {
    return { __await: c };
  }, ie(K.prototype), u(K.prototype, a, (function() {
    return this;
  })), e.AsyncIterator = K, e.async = function(c, l, f, C, b) {
    b === void 0 && (b = Promise);
    var P = new K(g(c, l, f, C), b);
    return e.isGeneratorFunction(l) ? P : P.next().then((function(L) {
      return L.done ? L.value : P.next();
    }));
  }, ie(B), u(B, h, "Generator"), u(B, o, (function() {
    return this;
  })), u(B, "toString", (function() {
    return "[object Generator]";
  })), e.keys = function(c) {
    var l = Object(c), f = [];
    for (var C in l) f.push(C);
    return f.reverse(), function b() {
      for (; f.length; ) {
        var P = f.pop();
        if (P in l) return b.value = P, b.done = !1, b;
      }
      return b.done = !0, b;
    };
  }, e.values = se, G.prototype = { constructor: G, reset: function(c) {
    if (this.prev = 0, this.next = 0, this.sent = this._sent = i, this.done = !1, this.delegate = null, this.method = "next", this.arg = i, this.tryEntries.forEach(N), !c) for (var l in this) l.charAt(0) === "t" && t.call(this, l) && !isNaN(+l.slice(1)) && (this[l] = i);
  }, stop: function() {
    this.done = !0;
    var c = this.tryEntries[0].completion;
    if (c.type === "throw") throw c.arg;
    return this.rval;
  }, dispatchException: function(c) {
    if (this.done) throw c;
    var l = this;
    function f(_, z) {
      return P.type = "throw", P.arg = c, l.next = _, z && (l.method = "next", l.arg = i), !!z;
    }
    for (var C = this.tryEntries.length - 1; C >= 0; --C) {
      var b = this.tryEntries[C], P = b.completion;
      if (b.tryLoc === "root") return f("end");
      if (b.tryLoc <= this.prev) {
        var L = t.call(b, "catchLoc"), I = t.call(b, "finallyLoc");
        if (L && I) {
          if (this.prev < b.catchLoc) return f(b.catchLoc, !0);
          if (this.prev < b.finallyLoc) return f(b.finallyLoc);
        } else if (L) {
          if (this.prev < b.catchLoc) return f(b.catchLoc, !0);
        } else {
          if (!I) throw new Error("try statement without catch or finally");
          if (this.prev < b.finallyLoc) return f(b.finallyLoc);
        }
      }
    }
  }, abrupt: function(c, l) {
    for (var f = this.tryEntries.length - 1; f >= 0; --f) {
      var C = this.tryEntries[f];
      if (C.tryLoc <= this.prev && t.call(C, "finallyLoc") && this.prev < C.finallyLoc) {
        var b = C;
        break;
      }
    }
    b && (c === "break" || c === "continue") && b.tryLoc <= l && l <= b.finallyLoc && (b = null);
    var P = b ? b.completion : {};
    return P.type = c, P.arg = l, b ? (this.method = "next", this.next = b.finallyLoc, p) : this.complete(P);
  }, complete: function(c, l) {
    if (c.type === "throw") throw c.arg;
    return c.type === "break" || c.type === "continue" ? this.next = c.arg : c.type === "return" ? (this.rval = this.arg = c.arg, this.method = "return", this.next = "end") : c.type === "normal" && l && (this.next = l), p;
  }, finish: function(c) {
    for (var l = this.tryEntries.length - 1; l >= 0; --l) {
      var f = this.tryEntries[l];
      if (f.finallyLoc === c) return this.complete(f.completion, f.afterLoc), N(f), p;
    }
  }, catch: function(c) {
    for (var l = this.tryEntries.length - 1; l >= 0; --l) {
      var f = this.tryEntries[l];
      if (f.tryLoc === c) {
        var C = f.completion;
        if (C.type === "throw") {
          var b = C.arg;
          N(f);
        }
        return b;
      }
    }
    throw new Error("illegal catch attempt");
  }, delegateYield: function(c, l, f) {
    return this.delegate = { iterator: se(c), resultName: l, nextLoc: f }, this.method === "next" && (this.arg = i), p;
  } }, e;
}
function Ae(i, e, n, t, r, s, o) {
  try {
    var a = i[s](o), h = a.value;
  } catch (u) {
    return void n(u);
  }
  a.done ? e(h) : Promise.resolve(h).then(t, r);
}
function He(i) {
  if (i === void 0) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
  return i;
}
function re(i) {
  return re = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function(e) {
    return e.__proto__ || Object.getPrototypeOf(e);
  }, re(i);
}
function Te() {
  return Te = typeof Reflect < "u" && Reflect.get ? Reflect.get.bind() : function(i, e, n) {
    var t = (function(s, o) {
      for (; !Object.prototype.hasOwnProperty.call(s, o) && (s = re(s)) !== null; ) ;
      return s;
    })(i, e);
    if (t) {
      var r = Object.getOwnPropertyDescriptor(t, e);
      return r.get ? r.get.call(arguments.length < 3 ? i : n) : r.value;
    }
  }, Te.apply(this, arguments);
}
function ke(i, e) {
  return ke = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(n, t) {
    return n.__proto__ = t, n;
  }, ke(i, e);
}
function ot(i) {
  var e = (function() {
    if (typeof Reflect > "u" || !Reflect.construct || Reflect.construct.sham) return !1;
    if (typeof Proxy == "function") return !0;
    try {
      return Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], (function() {
      }))), !0;
    } catch {
      return !1;
    }
  })();
  return function() {
    var n, t = re(i);
    if (e) {
      var r = re(this).constructor;
      n = Reflect.construct(t, arguments, r);
    } else n = t.apply(this, arguments);
    return (function(s, o) {
      if (o && (q(o) === "object" || typeof o == "function")) return o;
      if (o !== void 0) throw new TypeError("Derived constructors may only return object or undefined");
      return He(s);
    })(this, n);
  };
}
var Ue = (function(i) {
  (function(t, r) {
    if (typeof r != "function" && r !== null) throw new TypeError("Super expression must either be null or a function");
    t.prototype = Object.create(r && r.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), r && ke(t, r);
  })(n, it);
  var e = ot(n);
  function n() {
    var t, r = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 100 * Math.random() | 0;
    return Fe(this, n), (t = e.call(this)).id = "BELLHOP:".concat(r), t.connected = !1, t.isChild = !0, t.connecting = !1, t.debug = !1, t.origin = "*", t._sendLater = [], t.iframe = null, t.receive = t.receive.bind(He(t)), t;
  }
  return Ve(n, [{ key: "receive", value: function(t) {
    if (this.target === t.source) if (this.logDebugMessage(!0, t), t.data === "connected") this.onConnectionReceived(t.data);
    else {
      var r = t.data;
      if (typeof r == "string") try {
        r = JSON.parse(r);
      } catch (s) {
        console.warn("Bellhop error: ", s);
      }
      this.connected && q(r) === "object" && r.type && this.trigger(r);
    }
  } }, { key: "onConnectionReceived", value: function(t) {
    if (this.connecting = !1, this.connected = !0, !this.isChild) {
      if (!this.target) return;
      this.target.postMessage(t, this.origin);
    }
    for (var r = 0; r < this._sendLater.length; r++) {
      var s = this._sendLater[r], o = s.type, a = s.data;
      this.send(o, a);
    }
    this._sendLater.length = 0, this.trigger("connected");
  } }, { key: "connect", value: function(t) {
    var r = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "*";
    this.connecting || (this.disconnect(), this.connecting = !0, t instanceof HTMLIFrameElement && (this.iframe = t), this.isChild = t === void 0, this.supported = !0, this.isChild && (this.supported = window != t), this.origin = r, window.addEventListener("message", this.receive), this.isChild && (window === this.target ? this.trigger("failed") : this.target.postMessage("connected", this.origin)));
  } }, { key: "disconnect", value: function() {
    this.connected = !1, this.connecting = !1, this.origin = null, this.iframe = null, this.isChild = !0, this._sendLater.length = 0, window.removeEventListener("message", this.receive);
  } }, { key: "send", value: function(t) {
    if (typeof t != "string") throw "The event type must be a string";
    var r = { type: t, data: arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {} };
    this.logDebugMessage(!1, r), this.connecting ? this._sendLater.push(r) : this.target.postMessage(JSON.stringify(r), this.origin);
  } }, { key: "fetch", value: function(t, r) {
    var s = this, o = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}, a = arguments.length > 3 && arguments[3] !== void 0 && arguments[3];
    if (!this.connecting && !this.connected) throw "No connection, please call connect() first";
    this.on(t, (function h(u) {
      a && s.off(u.type, h), r(u);
    })), this.send(t, o);
  } }, { key: "respond", value: function(t) {
    var r = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, s = arguments.length > 2 && arguments[2] !== void 0 && arguments[2], o = this, a = (function() {
      var h, u = (h = Pe().mark((function g(d) {
        return Pe().wrap((function(v) {
          for (; ; ) switch (v.prev = v.next) {
            case 0:
              if (s && o.off(d, a), typeof r != "function") {
                v.next = 10;
                break;
              }
              return v.t0 = o, v.t1 = d.type, v.next = 6, r();
            case 6:
              v.t2 = v.sent, v.t0.send.call(v.t0, v.t1, v.t2), v.next = 11;
              break;
            case 10:
              o.send(d.type, r);
            case 11:
            case "end":
              return v.stop();
          }
        }), g);
      })), function() {
        var g = this, d = arguments;
        return new Promise((function(v, x) {
          var y = h.apply(g, d);
          function w(m) {
            Ae(y, v, x, w, p, "next", m);
          }
          function p(m) {
            Ae(y, v, x, w, p, "throw", m);
          }
          w(void 0);
        }));
      });
      return function(g) {
        return u.apply(this, arguments);
      };
    })();
    this.on(t, a);
  } }, { key: "logDebugMessage", value: function() {
    var t = arguments.length > 0 && arguments[0] !== void 0 && arguments[0], r = arguments.length > 1 ? arguments[1] : void 0;
    this.debug && typeof this.debug == "function" ? this.debug({ isChild: this.isChild, received: t, message: r }) : this.debug && console.log("Bellhop Instance (".concat(this.isChild ? "Child" : "Parent", ") ").concat(t ? "Receieved" : "Sent"), r);
  } }, { key: "destroy", value: function() {
    Te(re(n.prototype), "destroy", this).call(this), this.disconnect(), this._sendLater.length = 0;
  } }, { key: "target", get: function() {
    return this.isChild ? window.parent : this.iframe.contentWindow;
  } }]), n;
})();
const st = { ref: "containerEl" }, at = ["src"], lt = /* @__PURE__ */ Z({
  __name: "PPTAnimationEngine",
  props: {
    metas: {},
    defaultPage: { default: 1 },
    defaultStep: { default: 1 },
    engineBaseUrl: {},
    headless: { type: Boolean, default: !1 },
    dev: { type: Boolean, default: !1 }
  },
  emits: ["paginationChange", "loading"],
  setup(i, { expose: e, emit: n }) {
    const t = i, r = n, s = qe("iframe"), o = O(null), a = new Ue();
    return a.on("ready", () => {
      a.send("render", { defaultPage: t.defaultPage, defaultStep: t.defaultStep, metas: Ye(t.metas.animation) });
    }), a.on("pageChange", ({ data: d }) => {
      r("paginationChange", Object.assign({}, d, { total: t.metas.page }));
    }), ne(() => t.metas, async () => {
      o.value = t.dev ? "http://localhost:5174" : `${t.engineBaseUrl ? t.engineBaseUrl : ""}/cf-player/ppt-engine/index.html`, await Le(), a.connect(s.value);
    }, { immediate: !0 }), e({
      prev: () => {
        a.send("prev");
      },
      next: () => {
        a.send("next");
      },
      goto: (d) => {
        d.step = d.step ? d.step : 1, a.send("goto", d);
      }
    }), (d, v) => (T(), S("div", st, [
      o.value ? (T(), S("iframe", {
        key: 0,
        ref: "iframe",
        src: o.value,
        style: { position: "absolute", top: "0", left: "0", width: "100%", height: "100%", border: "0" }
      }, null, 8, at)) : R("", !0)
    ], 512));
  }
});
function ct(i) {
  return i && i.__esModule && Object.prototype.hasOwnProperty.call(i, "default") ? i.default : i;
}
var Ee = { exports: {} }, Be;
function ut() {
  return Be || (Be = 1, (function(i) {
    var e = Object.prototype.hasOwnProperty, n = "~";
    function t() {
    }
    Object.create && (t.prototype = /* @__PURE__ */ Object.create(null), new t().__proto__ || (n = !1));
    function r(h, u, g) {
      this.fn = h, this.context = u, this.once = g || !1;
    }
    function s(h, u, g, d, v) {
      if (typeof g != "function")
        throw new TypeError("The listener must be a function");
      var x = new r(g, d || h, v), y = n ? n + u : u;
      return h._events[y] ? h._events[y].fn ? h._events[y] = [h._events[y], x] : h._events[y].push(x) : (h._events[y] = x, h._eventsCount++), h;
    }
    function o(h, u) {
      --h._eventsCount === 0 ? h._events = new t() : delete h._events[u];
    }
    function a() {
      this._events = new t(), this._eventsCount = 0;
    }
    a.prototype.eventNames = function() {
      var u = [], g, d;
      if (this._eventsCount === 0) return u;
      for (d in g = this._events)
        e.call(g, d) && u.push(n ? d.slice(1) : d);
      return Object.getOwnPropertySymbols ? u.concat(Object.getOwnPropertySymbols(g)) : u;
    }, a.prototype.listeners = function(u) {
      var g = n ? n + u : u, d = this._events[g];
      if (!d) return [];
      if (d.fn) return [d.fn];
      for (var v = 0, x = d.length, y = new Array(x); v < x; v++)
        y[v] = d[v].fn;
      return y;
    }, a.prototype.listenerCount = function(u) {
      var g = n ? n + u : u, d = this._events[g];
      return d ? d.fn ? 1 : d.length : 0;
    }, a.prototype.emit = function(u, g, d, v, x, y) {
      var w = n ? n + u : u;
      if (!this._events[w]) return !1;
      var p = this._events[w], m = arguments.length, k, E;
      if (p.fn) {
        switch (p.once && this.removeListener(u, p.fn, void 0, !0), m) {
          case 1:
            return p.fn.call(p.context), !0;
          case 2:
            return p.fn.call(p.context, g), !0;
          case 3:
            return p.fn.call(p.context, g, d), !0;
          case 4:
            return p.fn.call(p.context, g, d, v), !0;
          case 5:
            return p.fn.call(p.context, g, d, v, x), !0;
          case 6:
            return p.fn.call(p.context, g, d, v, x, y), !0;
        }
        for (E = 1, k = new Array(m - 1); E < m; E++)
          k[E - 1] = arguments[E];
        p.fn.apply(p.context, k);
      } else {
        var j = p.length, $;
        for (E = 0; E < j; E++)
          switch (p[E].once && this.removeListener(u, p[E].fn, void 0, !0), m) {
            case 1:
              p[E].fn.call(p[E].context);
              break;
            case 2:
              p[E].fn.call(p[E].context, g);
              break;
            case 3:
              p[E].fn.call(p[E].context, g, d);
              break;
            case 4:
              p[E].fn.call(p[E].context, g, d, v);
              break;
            default:
              if (!k) for ($ = 1, k = new Array(m - 1); $ < m; $++)
                k[$ - 1] = arguments[$];
              p[E].fn.apply(p[E].context, k);
          }
      }
      return !0;
    }, a.prototype.on = function(u, g, d) {
      return s(this, u, g, d, !1);
    }, a.prototype.once = function(u, g, d) {
      return s(this, u, g, d, !0);
    }, a.prototype.removeListener = function(u, g, d, v) {
      var x = n ? n + u : u;
      if (!this._events[x]) return this;
      if (!g)
        return o(this, x), this;
      var y = this._events[x];
      if (y.fn)
        y.fn === g && (!v || y.once) && (!d || y.context === d) && o(this, x);
      else {
        for (var w = 0, p = [], m = y.length; w < m; w++)
          (y[w].fn !== g || v && !y[w].once || d && y[w].context !== d) && p.push(y[w]);
        p.length ? this._events[x] = p.length === 1 ? p[0] : p : o(this, x);
      }
      return this;
    }, a.prototype.removeAllListeners = function(u) {
      var g;
      return u ? (g = n ? n + u : u, this._events[g] && o(this, g)) : (this._events = new t(), this._eventsCount = 0), this;
    }, a.prototype.off = a.prototype.removeListener, a.prototype.addListener = a.prototype.on, a.prefixed = n, a.EventEmitter = a, i.exports = a;
  })(Ee)), Ee.exports;
}
var ht = ut();
const ft = /* @__PURE__ */ ct(ht);
class Se extends Error {
  name = "TimeoutError";
  constructor(e, n) {
    super(e, n), Error.captureStackTrace?.(this, Se);
  }
}
const Ze = (i) => i.reason ?? new DOMException("This operation was aborted.", "AbortError");
function dt(i, e) {
  const {
    milliseconds: n,
    fallback: t,
    message: r,
    customTimers: s = { setTimeout, clearTimeout },
    signal: o
  } = e;
  let a, h;
  const g = new Promise((d, v) => {
    if (typeof n != "number" || Math.sign(n) !== 1)
      throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${n}\``);
    if (o?.aborted) {
      v(Ze(o));
      return;
    }
    if (o && (h = () => {
      v(Ze(o));
    }, o.addEventListener("abort", h, { once: !0 })), i.then(d, v), n === Number.POSITIVE_INFINITY)
      return;
    const x = new Se();
    a = s.setTimeout.call(void 0, () => {
      if (t) {
        try {
          d(t());
        } catch (y) {
          v(y);
        }
        return;
      }
      typeof i.cancel == "function" && i.cancel(), r === !1 ? d() : r instanceof Error ? v(r) : (x.message = r ?? `Promise timed out after ${n} milliseconds`, v(x));
    }, n);
  }).finally(() => {
    g.clear(), h && o && o.removeEventListener("abort", h);
  });
  return g.clear = () => {
    s.clearTimeout.call(void 0, a), a = void 0;
  }, g;
}
function gt(i, e, n) {
  let t = 0, r = i.length;
  for (; r > 0; ) {
    const s = Math.trunc(r / 2);
    let o = t + s;
    n(i[o], e) <= 0 ? (t = ++o, r -= s + 1) : r = s;
  }
  return t;
}
class pt {
  #n = [];
  enqueue(e, n) {
    const { priority: t = 0, id: r } = n ?? {}, s = {
      priority: t,
      id: r,
      run: e
    };
    if (this.size === 0 || this.#n[this.size - 1].priority >= t) {
      this.#n.push(s);
      return;
    }
    const o = gt(this.#n, s, (a, h) => h.priority - a.priority);
    this.#n.splice(o, 0, s);
  }
  setPriority(e, n) {
    const t = this.#n.findIndex((s) => s.id === e);
    if (t === -1)
      throw new ReferenceError(`No promise function with the id "${e}" exists in the queue.`);
    const [r] = this.#n.splice(t, 1);
    this.enqueue(r.run, { priority: n, id: e });
  }
  dequeue() {
    return this.#n.shift()?.run;
  }
  filter(e) {
    return this.#n.filter((n) => n.priority === e.priority).map((n) => n.run);
  }
  get size() {
    return this.#n.length;
  }
}
class mt extends ft {
  #n;
  #s;
  #a = 0;
  #d;
  #p = !1;
  #y = !1;
  #l;
  #T = 0;
  #w = 0;
  #c;
  #u;
  #o;
  // Circular buffer implementation for better performance
  #i = [];
  #r = 0;
  #e;
  #k;
  #t = 0;
  // The `!` is needed because of https://github.com/microsoft/TypeScript/issues/32194
  #m;
  #h;
  // Use to assign a unique identifier to a promise function, if not explicitly specified
  #z = 1n;
  // Track currently running tasks for debugging
  #v = /* @__PURE__ */ new Map();
  /**
      Get or set the default timeout for all tasks. Can be changed at runtime.
  
      Operations will throw a `TimeoutError` if they don't complete within the specified time.
  
      The timeout begins when the operation is dequeued and starts execution, not while it's waiting in the queue.
  
      @example
      ```
      const queue = new PQueue({timeout: 5000});
  
      // Change timeout for all future tasks
      queue.timeout = 10000;
      ```
      */
  timeout;
  constructor(e) {
    if (super(), e = {
      carryoverIntervalCount: !1,
      intervalCap: Number.POSITIVE_INFINITY,
      interval: 0,
      concurrency: Number.POSITIVE_INFINITY,
      autoStart: !0,
      queueClass: pt,
      strict: !1,
      ...e
    }, !(typeof e.intervalCap == "number" && e.intervalCap >= 1))
      throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${e.intervalCap?.toString() ?? ""}\` (${typeof e.intervalCap})`);
    if (e.interval === void 0 || !(Number.isFinite(e.interval) && e.interval >= 0))
      throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${e.interval?.toString() ?? ""}\` (${typeof e.interval})`);
    if (e.strict && e.interval === 0)
      throw new TypeError("The `strict` option requires a non-zero `interval`");
    if (e.strict && e.intervalCap === Number.POSITIVE_INFINITY)
      throw new TypeError("The `strict` option requires a finite `intervalCap`");
    if (this.#n = e.carryoverIntervalCount ?? e.carryoverConcurrencyCount ?? !1, this.#s = e.intervalCap === Number.POSITIVE_INFINITY || e.interval === 0, this.#d = e.intervalCap, this.#l = e.interval, this.#o = e.strict, this.#e = new e.queueClass(), this.#k = e.queueClass, this.concurrency = e.concurrency, e.timeout !== void 0 && !(Number.isFinite(e.timeout) && e.timeout > 0))
      throw new TypeError(`Expected \`timeout\` to be a positive finite number, got \`${e.timeout}\` (${typeof e.timeout})`);
    this.timeout = e.timeout, this.#h = e.autoStart === !1, this.#q();
  }
  #b(e) {
    for (; this.#r < this.#i.length; ) {
      const t = this.#i[this.#r];
      if (t !== void 0 && e - t >= this.#l)
        this.#r++;
      else
        break;
    }
    (this.#r > 100 && this.#r > this.#i.length / 2 || this.#r === this.#i.length) && (this.#i = this.#i.slice(this.#r), this.#r = 0);
  }
  // Helper methods for interval consumption
  #O(e) {
    this.#o ? this.#i.push(e) : this.#a++;
  }
  #M() {
    this.#o ? this.#i.length > this.#r && this.#i.pop() : this.#a > 0 && this.#a--;
  }
  #_() {
    return this.#i.length - this.#r;
  }
  get #A() {
    return this.#s ? !0 : this.#o ? this.#_() < this.#d : this.#a < this.#d;
  }
  get #B() {
    return this.#t < this.#m;
  }
  #Z() {
    this.#t--, this.#t === 0 && this.emit("pendingZero"), this.#E(), this.emit("next");
  }
  #j() {
    this.#u = void 0, this.#$(), this.#S();
  }
  #R(e) {
    if (this.#o) {
      if (this.#b(e), this.#_() >= this.#d) {
        const t = this.#i[this.#r], r = this.#l - (e - t);
        return this.#x(r), !0;
      }
      return !1;
    }
    if (this.#c === void 0) {
      const n = this.#T - e;
      if (n < 0) {
        if (this.#w > 0) {
          const t = e - this.#w;
          if (t < this.#l)
            return this.#x(this.#l - t), !0;
        }
        this.#a = this.#n ? this.#t : 0;
      } else
        return this.#x(n), !0;
    }
    return !1;
  }
  #x(e) {
    this.#u === void 0 && (this.#u = setTimeout(() => {
      this.#j();
    }, e));
  }
  #C() {
    this.#c && (clearInterval(this.#c), this.#c = void 0);
  }
  #L() {
    this.#u && (clearTimeout(this.#u), this.#u = void 0);
  }
  #E() {
    if (this.#e.size === 0) {
      if (this.#C(), this.emit("empty"), this.#t === 0) {
        if (this.#L(), this.#o && this.#r > 0) {
          const n = Date.now();
          this.#b(n);
        }
        this.emit("idle");
      }
      return !1;
    }
    let e = !1;
    if (!this.#h) {
      const n = Date.now(), t = !this.#R(n);
      if (this.#A && this.#B) {
        const r = this.#e.dequeue();
        this.#s || (this.#O(n), this.#g()), this.emit("active"), r(), t && this.#S(), e = !0;
      }
    }
    return e;
  }
  #S() {
    this.#s || this.#c !== void 0 || this.#o || (this.#c = setInterval(() => {
      this.#$();
    }, this.#l), this.#T = Date.now() + this.#l);
  }
  #$() {
    this.#o || (this.#a === 0 && this.#t === 0 && this.#c && this.#C(), this.#a = this.#n ? this.#t : 0), this.#P(), this.#g();
  }
  /**
  Executes all queued functions until it reaches the limit.
  */
  #P() {
    for (; this.#E(); )
      ;
  }
  get concurrency() {
    return this.#m;
  }
  set concurrency(e) {
    if (!(typeof e == "number" && e >= 1))
      throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${e}\` (${typeof e})`);
    this.#m = e, this.#P();
  }
  /**
      Updates the priority of a promise function by its id, affecting its execution order. Requires a defined concurrency limit to take effect.
  
      For example, this can be used to prioritize a promise function to run earlier.
  
      ```js
      import PQueue from 'p-queue';
  
      const queue = new PQueue({concurrency: 1});
  
      queue.add(async () => '🦄', {priority: 1});
      queue.add(async () => '🦀', {priority: 0, id: '🦀'});
      queue.add(async () => '🦄', {priority: 1});
      queue.add(async () => '🦄', {priority: 1});
  
      queue.setPriority('🦀', 2);
      ```
  
      In this case, the promise function with `id: '🦀'` runs second.
  
      You can also deprioritize a promise function to delay its execution:
  
      ```js
      import PQueue from 'p-queue';
  
      const queue = new PQueue({concurrency: 1});
  
      queue.add(async () => '🦄', {priority: 1});
      queue.add(async () => '🦀', {priority: 1, id: '🦀'});
      queue.add(async () => '🦄');
      queue.add(async () => '🦄', {priority: 0});
  
      queue.setPriority('🦀', -1);
      ```
      Here, the promise function with `id: '🦀'` executes last.
      */
  setPriority(e, n) {
    if (typeof n != "number" || !Number.isFinite(n))
      throw new TypeError(`Expected \`priority\` to be a finite number, got \`${n}\` (${typeof n})`);
    this.#e.setPriority(e, n);
  }
  async add(e, n = {}) {
    return n = {
      timeout: this.timeout,
      ...n,
      // Assign unique ID if not provided
      id: n.id ?? (this.#z++).toString()
    }, new Promise((t, r) => {
      const s = /* @__PURE__ */ Symbol(`task-${n.id}`);
      this.#e.enqueue(async () => {
        this.#t++, this.#v.set(s, {
          id: n.id,
          priority: n.priority ?? 0,
          // Match priority-queue default
          startTime: Date.now(),
          timeout: n.timeout
        });
        let o;
        try {
          try {
            n.signal?.throwIfAborted();
          } catch (u) {
            throw this.#D(), this.#v.delete(s), u;
          }
          this.#w = Date.now();
          let a = e({ signal: n.signal });
          if (n.timeout && (a = dt(Promise.resolve(a), {
            milliseconds: n.timeout,
            message: `Task timed out after ${n.timeout}ms (queue has ${this.#t} running, ${this.#e.size} waiting)`
          })), n.signal) {
            const { signal: u } = n;
            a = Promise.race([a, new Promise((g, d) => {
              o = () => {
                d(u.reason);
              }, u.addEventListener("abort", o, { once: !0 });
            })]);
          }
          const h = await a;
          t(h), this.emit("completed", h);
        } catch (a) {
          r(a), this.emit("error", a);
        } finally {
          o && n.signal?.removeEventListener("abort", o), this.#v.delete(s), queueMicrotask(() => {
            this.#Z();
          });
        }
      }, n), this.emit("add"), this.#E();
    });
  }
  async addAll(e, n) {
    return Promise.all(e.map(async (t) => this.add(t, n)));
  }
  /**
  Start (or resume) executing enqueued tasks within concurrency limit. No need to call this if queue is not paused (via `options.autoStart = false` or by `.pause()` method.)
  */
  start() {
    return this.#h ? (this.#h = !1, this.#P(), this) : this;
  }
  /**
  Put queue execution on hold.
  */
  pause() {
    this.#h = !0;
  }
  /**
  Clear the queue.
  */
  clear() {
    this.#e = new this.#k(), this.#C(), this.#I(), this.emit("empty"), this.#t === 0 && (this.#L(), this.emit("idle")), this.emit("next");
  }
  /**
      Can be called multiple times. Useful if you for example add additional items at a later time.
  
      @returns A promise that settles when the queue becomes empty.
      */
  async onEmpty() {
    this.#e.size !== 0 && await this.#f("empty");
  }
  /**
      @returns A promise that settles when the queue size is less than the given limit: `queue.size < limit`.
  
      If you want to avoid having the queue grow beyond a certain size you can `await queue.onSizeLessThan()` before adding a new item.
  
      Note that this only limits the number of items waiting to start. There could still be up to `concurrency` jobs already running that this call does not include in its calculation.
      */
  async onSizeLessThan(e) {
    this.#e.size < e || await this.#f("next", () => this.#e.size < e);
  }
  /**
      The difference with `.onEmpty` is that `.onIdle` guarantees that all work from the queue has finished. `.onEmpty` merely signals that the queue is empty, but it could mean that some promises haven't completed yet.
  
      @returns A promise that settles when the queue becomes empty, and all promises have completed; `queue.size === 0 && queue.pending === 0`.
      */
  async onIdle() {
    this.#t === 0 && this.#e.size === 0 || await this.#f("idle");
  }
  /**
      The difference with `.onIdle` is that `.onPendingZero` only waits for currently running tasks to finish, ignoring queued tasks.
  
      @returns A promise that settles when all currently running tasks have completed; `queue.pending === 0`.
      */
  async onPendingZero() {
    this.#t !== 0 && await this.#f("pendingZero");
  }
  /**
  @returns A promise that settles when the queue becomes rate-limited due to intervalCap.
  */
  async onRateLimit() {
    this.isRateLimited || await this.#f("rateLimit");
  }
  /**
  @returns A promise that settles when the queue is no longer rate-limited.
  */
  async onRateLimitCleared() {
    this.isRateLimited && await this.#f("rateLimitCleared");
  }
  /**
      @returns A promise that rejects when any task in the queue errors.
  
      Use with `Promise.race([queue.onError(), queue.onIdle()])` to fail fast on the first error while still resolving normally when the queue goes idle.
  
      Important: The promise returned by `add()` still rejects. You must handle each `add()` promise (for example, `.catch(() => {})`) to avoid unhandled rejections.
  
      @example
      ```
      import PQueue from 'p-queue';
  
      const queue = new PQueue({concurrency: 2});
  
      queue.add(() => fetchData(1)).catch(() => {});
      queue.add(() => fetchData(2)).catch(() => {});
      queue.add(() => fetchData(3)).catch(() => {});
  
      // Stop processing on first error
      try {
          await Promise.race([
              queue.onError(),
              queue.onIdle()
          ]);
      } catch (error) {
          queue.pause(); // Stop processing remaining tasks
          console.error('Queue failed:', error);
      }
      ```
      */
  // eslint-disable-next-line @typescript-eslint/promise-function-async
  onError() {
    return new Promise((e, n) => {
      const t = (r) => {
        this.off("error", t), n(r);
      };
      this.on("error", t);
    });
  }
  async #f(e, n) {
    return new Promise((t) => {
      const r = () => {
        n && !n() || (this.off(e, r), t());
      };
      this.on(e, r);
    });
  }
  /**
  Size of the queue, the number of queued items waiting to run.
  */
  get size() {
    return this.#e.size;
  }
  /**
      Size of the queue, filtered by the given options.
  
      For example, this can be used to find the number of items remaining in the queue with a specific priority level.
      */
  sizeBy(e) {
    return this.#e.filter(e).length;
  }
  /**
  Number of running items (no longer in the queue).
  */
  get pending() {
    return this.#t;
  }
  /**
  Whether the queue is currently paused.
  */
  get isPaused() {
    return this.#h;
  }
  #q() {
    this.#s || (this.on("add", () => {
      this.#e.size > 0 && this.#g();
    }), this.on("next", () => {
      this.#g();
    }));
  }
  #g() {
    this.#s || this.#y || (this.#y = !0, queueMicrotask(() => {
      this.#y = !1, this.#I();
    }));
  }
  #D() {
    this.#s || (this.#M(), this.#g());
  }
  #I() {
    const e = this.#p;
    if (this.#s || this.#e.size === 0) {
      e && (this.#p = !1, this.emit("rateLimitCleared"));
      return;
    }
    let n;
    if (this.#o) {
      const r = Date.now();
      this.#b(r), n = this.#_();
    } else
      n = this.#a;
    const t = n >= this.#d;
    t !== e && (this.#p = t, this.emit(t ? "rateLimit" : "rateLimitCleared"));
  }
  /**
  Whether the queue is currently rate-limited due to intervalCap.
  */
  get isRateLimited() {
    return this.#p;
  }
  /**
      Whether the queue is saturated. Returns `true` when:
      - All concurrency slots are occupied and tasks are waiting, OR
      - The queue is rate-limited and tasks are waiting
  
      Useful for detecting backpressure and potential hanging tasks.
  
      ```js
      import PQueue from 'p-queue';
  
      const queue = new PQueue({concurrency: 2});
  
      // Backpressure handling
      if (queue.isSaturated) {
          console.log('Queue is saturated, waiting for capacity...');
          await queue.onSizeLessThan(queue.concurrency);
      }
  
      // Monitoring for stuck tasks
      setInterval(() => {
          if (queue.isSaturated) {
              console.warn(`Queue saturated: ${queue.pending} running, ${queue.size} waiting`);
          }
      }, 60000);
      ```
      */
  get isSaturated() {
    return this.#t === this.#m && this.#e.size > 0 || this.isRateLimited && this.#e.size > 0;
  }
  /**
      The tasks currently being executed. Each task includes its `id`, `priority`, `startTime`, and `timeout` (if set).
  
      Returns an array of task info objects.
  
      ```js
      import PQueue from 'p-queue';
  
      const queue = new PQueue({concurrency: 2});
  
      // Add tasks with IDs for better debugging
      queue.add(() => fetchUser(123), {id: 'user-123'});
      queue.add(() => fetchPosts(456), {id: 'posts-456', priority: 1});
  
      // Check what's running
      console.log(queue.runningTasks);
      // => [{
      //   id: 'user-123',
      //   priority: 0,
      //   startTime: 1759253001716,
      //   timeout: undefined
      // }, {
      //   id: 'posts-456',
      //   priority: 1,
      //   startTime: 1759253001916,
      //   timeout: undefined
      // }]
      ```
      */
  get runningTasks() {
    return [...this.#v.values()].map((e) => ({ ...e }));
  }
}
class vt extends U {
  queue;
  items;
  constructor(e) {
    super(), this.queue = new mt({ concurrency: 2, autoStart: !0 });
    const n = [];
    if (e.page && e.image && e.image.imageUrlPrefix)
      for (let t = 1; t <= e.page; t++)
        n.push({
          src: `${e.image.imageUrlPrefix}${t}`,
          page: t,
          state: "unloaded"
        });
    else if (e.page && e.image && e.image.urls)
      e.image.urls.forEach((t, r) => {
        n.push({
          src: t,
          page: r + 1,
          state: "unloaded"
        });
      });
    else
      throw new Error("File metas invalid.");
    this.items = n;
  }
  getItems() {
    return this.items;
  }
  pre(e) {
    let n = e - 1;
    n = Math.max(0, n), n = Math.min(this.items.length, n);
    const t = this.items[n];
    return t.state !== "unloaded" || (t.state = "queueing", this.queue.add(async () => new Promise(async (r, s) => {
      try {
        t.state = "loading";
        const a = await (await fetch(t.src)).blob(), h = URL.createObjectURL(a), u = new Image();
        t.el = u, u.src = h, u.onload = () => {
          t.state = "loaded", t.width = u.naturalWidth, t.height = u.naturalHeight, this.emit("loaded", t).then(), r();
        }, u.onerror = () => {
          throw new Error("Img error.");
        };
      } catch (o) {
        t.state = "error", this.emit("loaded", t).then(), s(o);
      }
    })).then()), t;
  }
}
const yt = { class: "cf-player__engine cf-player__engine--image-horizontal" }, wt = ["src", "alt"], bt = { key: 1 }, _t = { key: 2 }, xt = /* @__PURE__ */ Z({
  __name: "ImageHorizontalEngine",
  props: {
    metas: {},
    viewportSize: {},
    defaultPage: { default: 1 },
    headless: { type: Boolean, default: !1 },
    dev: { type: Boolean, default: !1 }
  },
  emits: ["paginationChange", "loading"],
  setup(i, { expose: e, emit: n }) {
    const t = i, r = n, s = O(0), o = O(null), a = O(0), h = De(null), u = ge({}), g = () => {
      if (!o.value || !o.value.width || !o.value.height)
        u.top = "0", u.left = "0", u.width = "100%", u.height = "100%";
      else {
        const y = t.viewportSize.width / o.value.width, w = t.viewportSize.height / o.value.height, p = Math.min(y, w), m = Math.floor(o.value.width * p), k = Math.floor(o.value.height * p), E = Math.floor((t.viewportSize.width - m) / 2), j = Math.floor((t.viewportSize.height - k) / 2);
        u.width = `${m}px`, u.height = `${k}px`, u.top = `${j}px`, u.left = `${E}px`;
      }
    }, d = async (y) => {
      console.log("[cf-player] (image-h) goto ", y);
      let w = y.page;
      y.page > s.value && (w = s.value), y.page < 1 && (w = 1), g(), o.value = h.value.pre(w), r("paginationChange", { total: s.value, current: w }), w < s.value && h.value.pre(y.page + 1), w > 1 && h.value.pre(y.page - 1);
    }, v = async () => {
      o.value && await d({ page: o.value.page - 1 });
    }, x = async () => {
      o.value && await d({ page: o.value.page + 1 });
    };
    return ne(() => t.metas, (y) => {
      console.log("[cf-player] (image-h) metas changed, reinitializing..."), s.value = y.page ? y.page : 0, o.value = null, a.value = 0, h.value = new vt(y), h.value.on("loaded", () => {
        a.value || r("loading", !1), g(), a.value = Date.now();
      }), r("loading", !0), d({ page: t.defaultPage });
    }, { deep: !0, immediate: !0 }), e({
      prev: v,
      next: x,
      goto: d
    }), (y, w) => (T(), S("div", yt, [
      o.value && a.value > 0 ? (T(), S("div", {
        key: 0,
        ref: "contentEl",
        class: "cf-player__content",
        style: ce(u)
      }, [
        o.value.state === "loaded" ? (T(), S("img", {
          key: 0,
          src: o.value.el?.currentSrc,
          alt: `第${o.value.page}页`
        }, null, 8, wt)) : ["unloaded", "queueing", "loading"].includes(o.value.state) ? (T(), S("div", bt, " 第" + ue(o.value.page) + "页，正在加载中... ", 1)) : (T(), S("div", _t, " 第" + ue(o.value.page) + "页，加载失败... ", 1))
      ], 4)) : R("", !0)
    ]));
  }
}), Ct = { ref: "containerEl" }, Et = ["src"], Pt = /* @__PURE__ */ Z({
  __name: "DocumentEngine",
  props: {
    metas: {},
    defaultPage: { default: 1 },
    defaultStep: { default: 1 },
    defaultZoom: { default: 1 },
    engineBaseUrl: {},
    headless: { type: Boolean, default: !1 },
    dev: { type: Boolean, default: !1 }
  },
  emits: ["paginationChange", "zoomChange", "loading"],
  setup(i, { expose: e, emit: n }) {
    const t = i, r = qe("iframe"), s = O(null), o = O(0), a = new Ue();
    a.on("ready", () => {
      a.send("render", { defaultPage: t.defaultPage, defaultZoom: t.defaultZoom, metas: t.metas });
    }), a.on("pageChange", ({ data: w }) => {
      o.value != w.current && (o.value = w.current, h("paginationChange", w));
    }), a.on("zoomChange", ({ data: w }) => {
      h("zoomChange", w.zoom);
    });
    const h = n;
    return ne(() => t.metas, async () => {
      s.value = t.dev ? "http://localhost:5175" : `${t.engineBaseUrl ? t.engineBaseUrl : ""}/cf-player/document-engine/index.html`, await Le(), a.connect(r.value);
    }, { immediate: !0 }), e({
      prev: () => {
        a.send("prev");
      },
      next: () => {
        a.send("next");
      },
      goto: (w) => {
        a.send("goto", w);
      },
      zoomIn: () => {
        a.send("zoomIn");
      },
      zoomOut: () => {
        a.send("zoomOut");
      },
      zoomTo: (w) => {
        a.send("zoomTo", { zoom: w });
      }
    }), (w, p) => (T(), S("div", Ct, [
      s.value ? (T(), S("iframe", {
        key: 0,
        ref: "iframe",
        src: s.value,
        style: { position: "absolute", top: "0", left: "0", width: "100%", height: "100%", border: "0" }
      }, null, 8, Et)) : R("", !0)
    ], 512));
  }
}), je = (i) => i === "true" ? !0 : i === "false" ? !1 : i, Tt = (i, e = 3e4) => new Promise((n, t) => {
  const r = `jsonp_${Date.now()}_${Math.random().toString(36).substring(2, 11)}`, s = document.createElement("script");
  let o;
  const a = () => {
    s.parentNode && s.parentNode.removeChild(s), delete window[r], o && clearTimeout(o);
  };
  window[r] = (u) => {
    n(u), a();
  }, s.onerror = () => {
    t(new Error(`JSONP request to ${i} failed`)), a();
  }, e && (o = window.setTimeout(() => {
    t(new Error(`JSONP request to ${i} timed out`)), a();
  }, e));
  const h = i.includes("?") ? "&" : "?";
  s.src = `${i}${h}callback=${r}`, document.head.appendChild(s);
}), kt = async (i) => new Promise(async (e, n) => {
  const t = await Tt(i);
  if (!t) {
    n(new Error(`Failed to fetch file metas from ${i}`));
    return;
  }
  const r = t.args.html;
  r && r.key && (r.url = r.key, delete r.key);
  const s = {
    id: t.args.resource.no,
    name: t.args.resource.name,
    type: t.type,
    page: parseInt(t.args.resource.length),
    thumb: t.args.resource.thumbnail,
    html: r,
    image: t.args.image,
    animation: t.args.animation
  };
  e(s);
}), Lt = "data:image/svg+xml,%3csvg%20width='16'%20height='16'%20viewBox='0%200%2016%2016'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M2.66675%205.03712V3.85193C2.66675%203.5376%202.79162%203.23615%203.01388%203.01388C3.23615%202.79162%203.5376%202.66675%203.85193%202.66675H5.03712M10.963%202.66675H12.1482C12.4626%202.66675%2012.764%202.79162%2012.9863%203.01388C13.2085%203.23615%2013.3334%203.5376%2013.3334%203.85193V5.03712M13.3334%2010.963V12.1482C13.3334%2012.4626%2013.2085%2012.764%2012.9863%2012.9863C12.764%2013.2085%2012.4626%2013.3334%2012.1482%2013.3334H10.963M5.03712%2013.3334H3.85193C3.5376%2013.3334%203.23615%2013.2085%203.01388%2012.9863C2.79162%2012.764%202.66675%2012.4626%202.66675%2012.1482V10.963M5.62971%205.62971H10.3705C10.6977%205.62971%2010.963%205.89502%2010.963%206.2223V9.77786C10.963%2010.1051%2010.6977%2010.3705%2010.3705%2010.3705H5.62971C5.30243%2010.3705%205.03712%2010.1051%205.03712%209.77786V6.2223C5.03712%205.89502%205.30243%205.62971%205.62971%205.62971Z'%20stroke='white'%20stroke-width='1.33'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3c/svg%3e", St = ["src"], $t = /* @__PURE__ */ Z({
  __name: "FullscreenButton",
  props: {
    clientType: { default: "pc" }
  },
  emits: ["click"],
  setup(i, { emit: e }) {
    const n = e, t = () => {
      n("click");
    };
    return (r, s) => (T(), S("button", {
      class: V(["fullscreen-button", `fullscreen-button--${i.clientType}`]),
      onClick: t,
      title: "全屏"
    }, [
      M("img", {
        src: pe(Lt),
        class: "fullscreen-button__icon",
        alt: "全屏"
      }, null, 8, St)
    ], 2));
  }
}), Ne = /* @__PURE__ */ he($t, [["__scopeId", "data-v-93eb2893"]]), It = ["value"], zt = { class: "cf-page-indicator__total" }, Ge = /* @__PURE__ */ Z({
  __name: "PageIndicator",
  props: {
    value: {},
    maxPage: {},
    clientType: { default: "pc" }
  },
  emits: ["change"],
  setup(i, { emit: e }) {
    const n = i, t = e, r = A(() => Math.min(n.value, n.maxPage)), s = A(() => `cf-page-indicator--${n.clientType}`), o = O(r.value.toString()), a = (g) => {
      const d = g.target, x = d.value.replace(/[^\d]/g, "");
      d.value = x, o.value = x;
    }, h = () => {
      let g = parseInt(o.value) || 1;
      g = Math.max(1, Math.min(g, n.maxPage)), o.value = g.toString(), t("change", g);
    }, u = (g) => {
      g.key === "Enter" && g.target.blur();
    };
    return ne(r, (g) => {
      o.value = g.toString();
    }), (g, d) => (T(), S("div", {
      class: V(["cf-page-indicator", s.value])
    }, [
      M("input", {
        class: "cf-page-indicator__current",
        type: "text",
        inputmode: "numeric",
        value: o.value,
        onInput: a,
        onBlur: h,
        onKeydown: u
      }, null, 40, It),
      M("div", zt, ue(`/${i.maxPage}`), 1)
    ], 2));
  }
}), Ot = { class: "cf-zoom-slider__track" }, Mt = /* @__PURE__ */ Z({
  __name: "ZoomSlider",
  props: {
    currentZoom: {},
    minZoom: { default: 0.4 },
    maxZoom: { default: 2 },
    clientType: { default: "pc" },
    themeColor: { default: "#00D98D" }
  },
  emits: ["change"],
  setup(i, { emit: e }) {
    const n = i, t = e, r = O(!1), s = O(null), o = O(n.currentZoom), a = (m) => Math.max(n.minZoom, Math.min(n.maxZoom, m)), h = A(() => `cf-zoom-slider--${n.clientType}`), u = A(() => {
      const m = r.value ? o.value : n.currentZoom;
      return (a(m) - n.minZoom) / (n.maxZoom - n.minZoom) * 100;
    }), g = (m) => {
      if (!s.value) return;
      const k = s.value.querySelector(".cf-zoom-slider__track");
      if (!k) return;
      const E = k.getBoundingClientRect(), j = m - E.left, $ = Math.max(0, Math.min(1, j / E.width)), D = n.minZoom + $ * (n.maxZoom - n.minZoom), B = a(Math.round(D * 100) / 100);
      o.value = B, t("change", B);
    }, d = (m) => {
      r.value && g(m.clientX);
    }, v = () => {
      r.value = !1, document.removeEventListener("mousemove", d), document.removeEventListener("mouseup", v);
    }, x = () => {
      r.value = !0, o.value = n.currentZoom, document.addEventListener("mousemove", d), document.addEventListener("mouseup", v);
    }, y = (m) => {
      r.value && g(m.touches[0].clientX);
    }, w = () => {
      r.value = !1;
    }, p = () => {
      r.value = !0, o.value = n.currentZoom;
    };
    return (m, k) => (T(), S("div", {
      ref_key: "sliderRef",
      ref: s,
      class: V(["cf-zoom-slider", [h.value, { "cf-zoom-slider--dragging": r.value }]]),
      onMousedown: x,
      onTouchstart: p,
      onTouchmove: y,
      onTouchend: w
    }, [
      M("div", Ot, [
        M("div", {
          class: "cf-zoom-slider__progress",
          style: ce({
            width: `${u.value}%`,
            backgroundColor: i.themeColor
          })
        }, null, 4),
        M("div", {
          class: "cf-zoom-slider__thumb",
          style: ce({
            left: `${u.value}%`,
            borderColor: i.themeColor
          })
        }, null, 4)
      ])
    ], 34));
  }
}), At = /* @__PURE__ */ he(Mt, [["__scopeId", "data-v-40a581f4"]]), Bt = { class: "document-controls" }, Zt = { class: "document-controls__right" }, jt = /* @__PURE__ */ Z({
  __name: "DocumentControls",
  props: {
    currentPage: {},
    maxPage: {},
    currentZoom: {},
    clientType: {},
    themeColor: {}
  },
  emits: ["pageChange", "zoomChange", "fullscreen"],
  setup(i, { emit: e }) {
    const n = e, t = (o) => {
      n("pageChange", o);
    }, r = (o) => {
      n("zoomChange", o);
    }, s = () => {
      n("fullscreen");
    };
    return (o, a) => (T(), S("div", Bt, [
      X(Ge, {
        value: i.currentPage,
        "max-page": i.maxPage,
        "client-type": i.clientType,
        onChange: t
      }, null, 8, ["value", "max-page", "client-type"]),
      M("div", Zt, [
        X(At, {
          "current-zoom": i.currentZoom,
          "client-type": i.clientType,
          "theme-color": i.themeColor,
          onChange: r
        }, null, 8, ["current-zoom", "client-type", "theme-color"]),
        i.clientType === "pc" ? (T(), J(Ne, {
          key: 0,
          onClick: s
        })) : R("", !0)
      ])
    ]));
  }
}), Rt = "data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M20%2016C20.5523%2016.0001%2021%2016.4478%2021%2017C21%2017.5523%2020.5523%2018%2020%2018H4C3.44772%2018%203%2017.5523%203%2017C3%2016.4478%203.44772%2016%204%2016H20Z'%20fill='white'/%3e%3cpath%20d='M16.2929%2013.293C16.6834%2012.9025%2017.3165%2012.9025%2017.707%2013.293L20.707%2016.293C21.0975%2016.6835%2021.0975%2017.3165%2020.707%2017.7071L17.707%2020.7071C17.3165%2021.0976%2016.6835%2021.0976%2016.2929%2020.7071C15.9024%2020.3165%2015.9024%2019.6835%2016.2929%2019.293L18.5859%2017L16.2929%2014.7071C15.9025%2014.3166%2015.9025%2013.6835%2016.2929%2013.293Z'%20fill='white'/%3e%3cpath%20d='M20%206.00004C20.5523%206.00006%2021%206.44777%2021%207.00004C21%207.55231%2020.5523%208.00002%2020%208.00004H5C4.44772%208.00004%204%207.55232%204%207.00004C4%206.44775%204.44772%206.00004%205%206.00004H20Z'%20fill='white'/%3e%3cpath%20d='M6.29297%203.29301C6.68349%202.9025%207.31651%202.90249%207.70703%203.29301C8.09754%203.68353%208.09754%204.31655%207.70703%204.70707L5.41406%207.00004L7.70703%209.29301C8.09755%209.68353%208.09755%2010.3165%207.70703%2010.7071C7.31651%2011.0976%206.68349%2011.0976%206.29297%2010.7071L3.29297%207.70707C2.90246%207.31655%202.90245%206.68353%203.29297%206.29301L6.29297%203.29301Z'%20fill='white'/%3e%3c/svg%3e", qt = ["src"], Dt = { class: "cf-mode-switch__text" }, Ft = /* @__PURE__ */ Z({
  __name: "ModeSwitch",
  props: {
    value: { type: Boolean },
    clientType: { default: "pc" }
  },
  emits: ["change"],
  setup(i, { emit: e }) {
    const n = i, t = e, r = A(() => `cf-mode-switch--${n.clientType}`), s = () => {
      t("change", !n.value);
    }, o = A(() => n.value ? "动画模式" : "普通模式");
    return (a, h) => (T(), S("button", {
      class: V(["cf-mode-switch", r.value]),
      onClick: s
    }, [
      M("img", {
        src: pe(Rt),
        alt: "mode switch",
        class: "cf-mode-switch__icon"
      }, null, 8, qt),
      M("span", Dt, ue(o.value), 1)
    ], 2));
  }
}), Vt = /* @__PURE__ */ he(Ft, [["__scopeId", "data-v-3fef0ff1"]]), Ht = "data:image/svg+xml,%3csvg%20width='20'%20height='20'%20viewBox='0%200%2020%2020'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M6.02814%209.21758C5.49062%209.62025%205.49062%2010.3798%206.02814%2010.7824L11.3571%2014.7745C12.067%2015.3062%2013.125%2014.838%2013.125%2013.9921V6.00794C13.125%205.16201%2012.067%204.69376%2011.3571%205.22553L6.02814%209.21758Z'%20fill='white'/%3e%3c/svg%3e", Ut = "data:image/svg+xml,%3csvg%20width='20'%20height='20'%20viewBox='0%200%2020%2020'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M13.9719%209.21758C14.5094%209.62025%2014.5094%2010.3798%2013.9719%2010.7824L8.64288%2014.7745C7.93302%2015.3062%206.875%2014.838%206.875%2013.9921V6.00794C6.875%205.16201%207.93302%204.69376%208.64288%205.22553L13.9719%209.21758Z'%20fill='white'/%3e%3c/svg%3e", Nt = ["src"], Gt = { class: "page-nav-button__text" }, Yt = ["src"], Wt = /* @__PURE__ */ Z({
  __name: "PageNavButton",
  props: {
    type: {},
    clientType: { default: "pc" }
  },
  emits: ["click"],
  setup(i, { emit: e }) {
    const n = i, t = e, r = A(() => n.type === "prev" ? "上一页" : "下一页"), s = () => {
      t("click");
    };
    return (o, a) => (T(), S("button", {
      class: V(["page-nav-button", [`page-nav-button--${i.type}`, `page-nav-button--${i.clientType}`]]),
      onClick: s
    }, [
      i.type === "prev" ? (T(), S("img", {
        key: 0,
        src: pe(Ht),
        class: "page-nav-button__icon",
        alt: "上一页"
      }, null, 8, Nt)) : R("", !0),
      M("span", Gt, ue(r.value), 1),
      i.type === "next" ? (T(), S("img", {
        key: 1,
        src: pe(Ut),
        class: "page-nav-button__icon",
        alt: "下一页"
      }, null, 8, Yt)) : R("", !0)
    ], 2));
  }
}), Re = /* @__PURE__ */ he(Wt, [["__scopeId", "data-v-36710f05"]]), Jt = { class: "ppt-controls" }, Xt = /* @__PURE__ */ Z({
  __name: "PptControls",
  props: {
    animation: { type: Boolean },
    currentPage: {},
    maxPage: {},
    clientType: {}
  },
  emits: ["modeChange", "pageChange", "prevPage", "nextPage", "fullscreen"],
  setup(i, { emit: e }) {
    const n = e, t = (h) => {
      n("modeChange", h);
    }, r = (h) => {
      n("pageChange", h);
    }, s = () => {
      n("prevPage");
    }, o = () => {
      n("nextPage");
    }, a = () => {
      n("fullscreen");
    };
    return (h, u) => (T(), S("div", Jt, [
      X(Vt, {
        value: i.animation,
        "client-type": i.clientType,
        onChange: t
      }, null, 8, ["value", "client-type"]),
      M("div", {
        class: V(["ppt-controls__navigation", `ppt-controls__navigation--${i.clientType}`])
      }, [
        X(Re, {
          "client-type": i.clientType,
          type: "prev",
          onClick: s
        }, null, 8, ["client-type"]),
        X(Ge, {
          value: i.currentPage,
          "max-page": i.maxPage,
          "client-type": i.clientType,
          onChange: r
        }, null, 8, ["value", "max-page", "client-type"]),
        X(Re, {
          "client-type": i.clientType,
          type: "next",
          onClick: o
        }, null, 8, ["client-type"])
      ], 2),
      i.clientType === "pc" ? (T(), J(Ne, {
        key: 0,
        onClick: a
      })) : (T(), S("div", {
        key: 1,
        class: V(["ppt-controls__spacer", `ppt-controls__spacer--${i.clientType}`])
      }, null, 2))
    ]));
  }
}), Kt = {
  key: 3,
  class: "cf-player__mask"
}, en = /* @__PURE__ */ Z({
  __name: "Player",
  props: {
    file: {},
    defaultPage: { default: 1 },
    defaultStep: { default: 1 },
    defaultZoom: { default: 1 },
    vertical: { type: [Boolean, String], default: !1 },
    dark: { type: [Boolean, String], default: !1 },
    themeColor: { default: "#00D98D" },
    headless: { type: Boolean, default: !1 },
    engineBaseUrl: {},
    dev: { type: Boolean, default: !1 },
    clientType: { default: "pc" }
  },
  emits: ["paginationChange", "zoomChange", "fullscreen"],
  setup(i, { expose: e, emit: n }) {
    const t = i, r = A(() => je(t.dark)), s = A(() => je(t.vertical)), o = O(!1), a = A(() => t.themeColor ? {
      "--cf-player-theme-color": t.themeColor
    } : {}), h = A(() => !!(m.value && m.value.type === "document")), u = A(() => !!(m.value && m.value.type === "ppt" && m.value.animation && o.value)), g = A(() => !!(m.value && m.value.type === "ppt" && !o.value && !s.value)), d = n, v = O(null), x = O(null), y = ge({}), w = ge({
      width: 0,
      height: 0
    }), p = ge({
      width: 0,
      height: 0
    }), m = De(null), k = O(t.defaultPage), E = O(t.defaultZoom);
    new U().on("paginationChange", (_) => {
      d("paginationChange", _);
    });
    const $ = O(!1);
    $e(() => {
      console.log("[cf-player] mounted, version: 0.5.0");
    }), ne([() => t.file], async () => {
      if (t.file) {
        if (typeof t.file == "string") {
          const _ = await kt(t.file);
          if (!_)
            return;
          m.value = _;
        } else
          m.value = t.file;
        m.value && (o.value = !!(m.value.type === "ppt" && m.value.animation));
      }
    }, { immediate: !0 }), ne(o, async () => {
      if (!t.file || !m.value)
        return;
      console.log("[cf-player] animation mode changed, reloading...");
      const _ = m.value;
      $.value = !0, m.value = null, await Le(), m.value = _, $.value = !1;
    });
    const D = () => {
      x.value?.prev();
    }, B = () => {
      x.value?.next();
    }, ie = (_) => {
      x.value?.goto(_);
    }, K = () => {
      x.value?.zoomIn();
    }, _e = () => {
      x.value?.zoomOut();
    }, oe = (_) => {
      x.value?.zoomTo(_);
    }, xe = () => {
      if (!m.value || !m.value.page || !m.value.thumb)
        return [];
      const _ = [];
      for (let z = 1; z <= m.value.page; z++)
        _.push({ page: z, url: m.value.thumb + z });
      return _;
    }, N = (_) => {
      $.value = _;
    }, G = (_) => {
      k.value = _.current, d("paginationChange", _);
    }, se = (_) => {
      E.value = _, d("zoomChange", _);
    }, c = (_) => {
      k.value = _, ie({ page: _ });
    }, l = (_) => {
      E.value = _, oe(_);
    }, f = (_) => {
      o.value = _;
    }, C = () => {
      D();
    }, b = () => {
      B();
    }, P = () => {
      d("fullscreen");
    }, L = () => {
      const _ = 1.7777777777777777;
      w.width = v.value.clientWidth, w.height = v.value.clientHeight, console.log(`[cf-player] resize viewport, width ${w.width}, height ${w.height}`), w.width / w.height > _ ? (p.width = Math.round(w.height * _), p.height = w.height, y.width = `${p.width}px`, y.height = `${w.height}px`, y.top = "0", y.left = `${Math.round((w.width - p.width) / 2)}px`) : (p.width = w.width, p.height = Math.round(w.width * (1 / _)), y.width = `${w.width}px`, y.height = `${p.height}px`, y.top = `${Math.round(w.height - p.height) / 2}px`, y.left = "0");
    }, I = new ResizeObserver(() => {
      console.log("[cf-player] resize viewport by observer."), L();
    });
    return $e(() => {
      I.observe(v.value), console.log("[cf-player] resize viewport, when on mounted."), L();
    }), We(() => {
      I.unobserve(v.value);
    }), e({
      prev: D,
      next: B,
      goto: ie,
      zoomIn: K,
      zoomOut: _e,
      zoomTo: oe,
      thumbs: xe
    }), (_, z) => (T(), S("div", {
      ref_key: "playerEl",
      ref: v,
      class: V(["cf-player", { "cf-player--dark": r.value, "cf-player--pc": i.clientType === "pc" }]),
      style: ce(a.value)
    }, [
      M("div", {
        class: "cf-player__viewport",
        style: ce(y)
      }, [
        h.value && m.value ? (T(), J(Pt, {
          key: 0,
          ref_key: "engineEl",
          ref: x,
          metas: m.value,
          "viewport-size": p,
          "default-page": t.defaultPage,
          "default-zoom": t.defaultZoom,
          "engine-base-url": i.engineBaseUrl,
          dev: t.dev,
          onLoading: N,
          onPaginationChange: G,
          onZoomChange: se
        }, null, 8, ["metas", "viewport-size", "default-page", "default-zoom", "engine-base-url", "dev"])) : R("", !0),
        u.value && m.value ? (T(), J(lt, {
          key: 1,
          ref_key: "engineEl",
          ref: x,
          metas: m.value,
          "default-page": t.defaultPage,
          "default-step": t.defaultStep,
          "engine-base-url": i.engineBaseUrl,
          dev: t.dev,
          onLoading: N,
          onPaginationChange: G,
          class: "cf-player__engine cf-player__engine--animation"
        }, null, 8, ["metas", "default-page", "default-step", "engine-base-url", "dev"])) : g.value && m.value ? (T(), J(xt, {
          key: 2,
          ref_key: "engineEl",
          ref: x,
          metas: m.value,
          "viewport-size": p,
          "default-page": t.defaultPage,
          "engine-base-url": i.engineBaseUrl,
          dev: t.dev,
          onLoading: N,
          onPaginationChange: G
        }, null, 8, ["metas", "viewport-size", "default-page", "engine-base-url", "dev"])) : R("", !0),
        $.value ? (T(), S("div", Kt, [
          X(et),
          z[0] || (z[0] = Je()),
          z[1] || (z[1] = M("span", { class: "cf-player__mask__text" }, "文件加载中...", -1))
        ])) : R("", !0)
      ], 4),
      M("div", {
        class: V(["cf-player__controls", `cf-player__controls--${t.clientType}`])
      }, [
        h.value ? (T(), J(jt, {
          key: 0,
          "current-page": k.value,
          "max-page": m.value?.page || 1,
          "current-zoom": E.value,
          "client-type": i.clientType,
          "theme-color": i.themeColor,
          onPageChange: c,
          onZoomChange: l,
          onFullscreen: P
        }, null, 8, ["current-page", "max-page", "current-zoom", "client-type", "theme-color"])) : u.value || g.value ? (T(), J(Xt, {
          key: 1,
          animation: o.value,
          "current-page": k.value,
          "max-page": m.value?.page || 1,
          "client-type": i.clientType,
          onModeChange: f,
          onPageChange: c,
          onPrevPage: C,
          onNextPage: b,
          onFullscreen: P
        }, null, 8, ["animation", "current-page", "max-page", "client-type"])) : R("", !0)
      ], 2)
    ], 6));
  }
});
export {
  en as CloudFilePlayer
};
