vue-book-reader
Version:
<div align="center"> <img width=250 src="https://raw.githubusercontent.com/jinhuan138/vue--book-reader/master/public/logo.png" /> <h1>VueReader</h1> </div>
1,458 lines (1,457 loc) • 50.4 kB
JavaScript
import { toRefs, ref, onUnmounted, watch, onMounted, openBlock, createElementBlock, createElementVNode, withDirectives, vShow, renderSlot, createCommentVNode, defineComponent, watchEffect, resolveComponent, Fragment, renderList, normalizeClass, unref, createTextVNode, toDisplayString, createVNode, reactive, mergeProps, withCtx, pushScopeId, popScopeId } from "vue";
import './index.css';var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
var check = function(it) {
return it && it.Math === Math && it;
};
var globalThis_1 = (
// eslint-disable-next-line es/no-global-this -- safe
check(typeof globalThis == "object" && globalThis) || check(typeof window == "object" && window) || // eslint-disable-next-line no-restricted-globals -- safe
check(typeof self == "object" && self) || check(typeof commonjsGlobal == "object" && commonjsGlobal) || check(typeof commonjsGlobal == "object" && commonjsGlobal) || // eslint-disable-next-line no-new-func -- fallback
/* @__PURE__ */ function() {
return this;
}() || Function("return this")()
);
var objectGetOwnPropertyDescriptor = {};
var fails$a = function(exec) {
try {
return !!exec();
} catch (error) {
return true;
}
};
var fails$9 = fails$a;
var descriptors = !fails$9(function() {
return Object.defineProperty({}, 1, { get: function() {
return 7;
} })[1] !== 7;
});
var fails$8 = fails$a;
var functionBindNative = !fails$8(function() {
var test2 = (function() {
}).bind();
return typeof test2 != "function" || test2.hasOwnProperty("prototype");
});
var NATIVE_BIND$2 = functionBindNative;
var call$7 = Function.prototype.call;
var functionCall = NATIVE_BIND$2 ? call$7.bind(call$7) : function() {
return call$7.apply(call$7, arguments);
};
var objectPropertyIsEnumerable = {};
var $propertyIsEnumerable = {}.propertyIsEnumerable;
var getOwnPropertyDescriptor$1 = Object.getOwnPropertyDescriptor;
var NASHORN_BUG = getOwnPropertyDescriptor$1 && !$propertyIsEnumerable.call({ 1: 2 }, 1);
objectPropertyIsEnumerable.f = NASHORN_BUG ? function propertyIsEnumerable(V) {
var descriptor = getOwnPropertyDescriptor$1(this, V);
return !!descriptor && descriptor.enumerable;
} : $propertyIsEnumerable;
var createPropertyDescriptor$2 = function(bitmap, value) {
return {
enumerable: !(bitmap & 1),
configurable: !(bitmap & 2),
writable: !(bitmap & 4),
value
};
};
var NATIVE_BIND$1 = functionBindNative;
var FunctionPrototype$1 = Function.prototype;
var call$6 = FunctionPrototype$1.call;
var uncurryThisWithBind = NATIVE_BIND$1 && FunctionPrototype$1.bind.bind(call$6, call$6);
var functionUncurryThis = NATIVE_BIND$1 ? uncurryThisWithBind : function(fn) {
return function() {
return call$6.apply(fn, arguments);
};
};
var uncurryThis$d = functionUncurryThis;
var toString$1 = uncurryThis$d({}.toString);
var stringSlice$1 = uncurryThis$d("".slice);
var classofRaw$2 = function(it) {
return stringSlice$1(toString$1(it), 8, -1);
};
var uncurryThis$c = functionUncurryThis;
var fails$7 = fails$a;
var classof$2 = classofRaw$2;
var $Object$3 = Object;
var split = uncurryThis$c("".split);
var indexedObject = fails$7(function() {
return !$Object$3("z").propertyIsEnumerable(0);
}) ? function(it) {
return classof$2(it) === "String" ? split(it, "") : $Object$3(it);
} : $Object$3;
var isNullOrUndefined$3 = function(it) {
return it === null || it === void 0;
};
var isNullOrUndefined$2 = isNullOrUndefined$3;
var $TypeError$7 = TypeError;
var requireObjectCoercible$4 = function(it) {
if (isNullOrUndefined$2(it))
throw new $TypeError$7("Can't call method on " + it);
return it;
};
var IndexedObject = indexedObject;
var requireObjectCoercible$3 = requireObjectCoercible$4;
var toIndexedObject$3 = function(it) {
return IndexedObject(requireObjectCoercible$3(it));
};
var documentAll = typeof document == "object" && document.all;
var isCallable$b = typeof documentAll == "undefined" && documentAll !== void 0 ? function(argument) {
return typeof argument == "function" || argument === documentAll;
} : function(argument) {
return typeof argument == "function";
};
var isCallable$a = isCallable$b;
var isObject$5 = function(it) {
return typeof it == "object" ? it !== null : isCallable$a(it);
};
var globalThis$b = globalThis_1;
var isCallable$9 = isCallable$b;
var aFunction = function(argument) {
return isCallable$9(argument) ? argument : void 0;
};
var getBuiltIn$3 = function(namespace, method) {
return arguments.length < 2 ? aFunction(globalThis$b[namespace]) : globalThis$b[namespace] && globalThis$b[namespace][method];
};
var uncurryThis$b = functionUncurryThis;
var objectIsPrototypeOf = uncurryThis$b({}.isPrototypeOf);
var globalThis$a = globalThis_1;
var navigator = globalThis$a.navigator;
var userAgent$1 = navigator && navigator.userAgent;
var environmentUserAgent = userAgent$1 ? String(userAgent$1) : "";
var globalThis$9 = globalThis_1;
var userAgent = environmentUserAgent;
var process = globalThis$9.process;
var Deno = globalThis$9.Deno;
var versions = process && process.versions || Deno && Deno.version;
var v8 = versions && versions.v8;
var match, version;
if (v8) {
match = v8.split(".");
version = match[0] > 0 && match[0] < 4 ? 1 : +(match[0] + match[1]);
}
if (!version && userAgent) {
match = userAgent.match(/Edge\/(\d+)/);
if (!match || match[1] >= 74) {
match = userAgent.match(/Chrome\/(\d+)/);
if (match)
version = +match[1];
}
}
var environmentV8Version = version;
var V8_VERSION = environmentV8Version;
var fails$6 = fails$a;
var globalThis$8 = globalThis_1;
var $String$3 = globalThis$8.String;
var symbolConstructorDetection = !!Object.getOwnPropertySymbols && !fails$6(function() {
var symbol = Symbol("symbol detection");
return !$String$3(symbol) || !(Object(symbol) instanceof Symbol) || // Chrome 38-40 symbols are not inherited from DOM collections prototypes to instances
!Symbol.sham && V8_VERSION && V8_VERSION < 41;
});
var NATIVE_SYMBOL$1 = symbolConstructorDetection;
var useSymbolAsUid = NATIVE_SYMBOL$1 && !Symbol.sham && typeof Symbol.iterator == "symbol";
var getBuiltIn$2 = getBuiltIn$3;
var isCallable$8 = isCallable$b;
var isPrototypeOf$1 = objectIsPrototypeOf;
var USE_SYMBOL_AS_UID$1 = useSymbolAsUid;
var $Object$2 = Object;
var isSymbol$2 = USE_SYMBOL_AS_UID$1 ? function(it) {
return typeof it == "symbol";
} : function(it) {
var $Symbol = getBuiltIn$2("Symbol");
return isCallable$8($Symbol) && isPrototypeOf$1($Symbol.prototype, $Object$2(it));
};
var $String$2 = String;
var tryToString$3 = function(argument) {
try {
return $String$2(argument);
} catch (error) {
return "Object";
}
};
var isCallable$7 = isCallable$b;
var tryToString$2 = tryToString$3;
var $TypeError$6 = TypeError;
var aCallable$5 = function(argument) {
if (isCallable$7(argument))
return argument;
throw new $TypeError$6(tryToString$2(argument) + " is not a function");
};
var aCallable$4 = aCallable$5;
var isNullOrUndefined$1 = isNullOrUndefined$3;
var getMethod$3 = function(V, P) {
var func = V[P];
return isNullOrUndefined$1(func) ? void 0 : aCallable$4(func);
};
var call$5 = functionCall;
var isCallable$6 = isCallable$b;
var isObject$4 = isObject$5;
var $TypeError$5 = TypeError;
var ordinaryToPrimitive$1 = function(input, pref) {
var fn, val;
if (pref === "string" && isCallable$6(fn = input.toString) && !isObject$4(val = call$5(fn, input)))
return val;
if (isCallable$6(fn = input.valueOf) && !isObject$4(val = call$5(fn, input)))
return val;
if (pref !== "string" && isCallable$6(fn = input.toString) && !isObject$4(val = call$5(fn, input)))
return val;
throw new $TypeError$5("Can't convert object to primitive value");
};
var sharedStore = { exports: {} };
var globalThis$7 = globalThis_1;
var defineProperty$1 = Object.defineProperty;
var defineGlobalProperty$3 = function(key, value) {
try {
defineProperty$1(globalThis$7, key, { value, configurable: true, writable: true });
} catch (error) {
globalThis$7[key] = value;
}
return value;
};
var globalThis$6 = globalThis_1;
var defineGlobalProperty$2 = defineGlobalProperty$3;
var SHARED = "__core-js_shared__";
var store$3 = sharedStore.exports = globalThis$6[SHARED] || defineGlobalProperty$2(SHARED, {});
(store$3.versions || (store$3.versions = [])).push({
version: "3.45.1",
mode: "global",
copyright: "© 2014-2025 Denis Pushkarev (zloirock.ru)",
license: "https://github.com/zloirock/core-js/blob/v3.45.1/LICENSE",
source: "https://github.com/zloirock/core-js"
});
var sharedStoreExports = sharedStore.exports;
var store$2 = sharedStoreExports;
var shared$3 = function(key, value) {
return store$2[key] || (store$2[key] = value || {});
};
var requireObjectCoercible$2 = requireObjectCoercible$4;
var $Object$1 = Object;
var toObject$1 = function(argument) {
return $Object$1(requireObjectCoercible$2(argument));
};
var uncurryThis$a = functionUncurryThis;
var toObject = toObject$1;
var hasOwnProperty = uncurryThis$a({}.hasOwnProperty);
var hasOwnProperty_1 = Object.hasOwn || function hasOwn(it, key) {
return hasOwnProperty(toObject(it), key);
};
var uncurryThis$9 = functionUncurryThis;
var id = 0;
var postfix = Math.random();
var toString = uncurryThis$9(1.1.toString);
var uid$2 = function(key) {
return "Symbol(" + (key === void 0 ? "" : key) + ")_" + toString(++id + postfix, 36);
};
var globalThis$5 = globalThis_1;
var shared$2 = shared$3;
var hasOwn$6 = hasOwnProperty_1;
var uid$1 = uid$2;
var NATIVE_SYMBOL = symbolConstructorDetection;
var USE_SYMBOL_AS_UID = useSymbolAsUid;
var Symbol$1 = globalThis$5.Symbol;
var WellKnownSymbolsStore = shared$2("wks");
var createWellKnownSymbol = USE_SYMBOL_AS_UID ? Symbol$1["for"] || Symbol$1 : Symbol$1 && Symbol$1.withoutSetter || uid$1;
var wellKnownSymbol$5 = function(name) {
if (!hasOwn$6(WellKnownSymbolsStore, name)) {
WellKnownSymbolsStore[name] = NATIVE_SYMBOL && hasOwn$6(Symbol$1, name) ? Symbol$1[name] : createWellKnownSymbol("Symbol." + name);
}
return WellKnownSymbolsStore[name];
};
var call$4 = functionCall;
var isObject$3 = isObject$5;
var isSymbol$1 = isSymbol$2;
var getMethod$2 = getMethod$3;
var ordinaryToPrimitive = ordinaryToPrimitive$1;
var wellKnownSymbol$4 = wellKnownSymbol$5;
var $TypeError$4 = TypeError;
var TO_PRIMITIVE = wellKnownSymbol$4("toPrimitive");
var toPrimitive$1 = function(input, pref) {
if (!isObject$3(input) || isSymbol$1(input))
return input;
var exoticToPrim = getMethod$2(input, TO_PRIMITIVE);
var result;
if (exoticToPrim) {
if (pref === void 0)
pref = "default";
result = call$4(exoticToPrim, input, pref);
if (!isObject$3(result) || isSymbol$1(result))
return result;
throw new $TypeError$4("Can't convert object to primitive value");
}
if (pref === void 0)
pref = "number";
return ordinaryToPrimitive(input, pref);
};
var toPrimitive = toPrimitive$1;
var isSymbol = isSymbol$2;
var toPropertyKey$3 = function(argument) {
var key = toPrimitive(argument, "string");
return isSymbol(key) ? key : key + "";
};
var globalThis$4 = globalThis_1;
var isObject$2 = isObject$5;
var document$1 = globalThis$4.document;
var EXISTS$1 = isObject$2(document$1) && isObject$2(document$1.createElement);
var documentCreateElement = function(it) {
return EXISTS$1 ? document$1.createElement(it) : {};
};
var DESCRIPTORS$6 = descriptors;
var fails$5 = fails$a;
var createElement = documentCreateElement;
var ie8DomDefine = !DESCRIPTORS$6 && !fails$5(function() {
return Object.defineProperty(createElement("div"), "a", {
get: function() {
return 7;
}
}).a !== 7;
});
var DESCRIPTORS$5 = descriptors;
var call$3 = functionCall;
var propertyIsEnumerableModule = objectPropertyIsEnumerable;
var createPropertyDescriptor$1 = createPropertyDescriptor$2;
var toIndexedObject$2 = toIndexedObject$3;
var toPropertyKey$2 = toPropertyKey$3;
var hasOwn$5 = hasOwnProperty_1;
var IE8_DOM_DEFINE$1 = ie8DomDefine;
var $getOwnPropertyDescriptor$1 = Object.getOwnPropertyDescriptor;
objectGetOwnPropertyDescriptor.f = DESCRIPTORS$5 ? $getOwnPropertyDescriptor$1 : function getOwnPropertyDescriptor(O, P) {
O = toIndexedObject$2(O);
P = toPropertyKey$2(P);
if (IE8_DOM_DEFINE$1)
try {
return $getOwnPropertyDescriptor$1(O, P);
} catch (error) {
}
if (hasOwn$5(O, P))
return createPropertyDescriptor$1(!call$3(propertyIsEnumerableModule.f, O, P), O[P]);
};
var objectDefineProperty = {};
var DESCRIPTORS$4 = descriptors;
var fails$4 = fails$a;
var v8PrototypeDefineBug = DESCRIPTORS$4 && fails$4(function() {
return Object.defineProperty(function() {
}, "prototype", {
value: 42,
writable: false
}).prototype !== 42;
});
var isObject$1 = isObject$5;
var $String$1 = String;
var $TypeError$3 = TypeError;
var anObject$5 = function(argument) {
if (isObject$1(argument))
return argument;
throw new $TypeError$3($String$1(argument) + " is not an object");
};
var DESCRIPTORS$3 = descriptors;
var IE8_DOM_DEFINE = ie8DomDefine;
var V8_PROTOTYPE_DEFINE_BUG = v8PrototypeDefineBug;
var anObject$4 = anObject$5;
var toPropertyKey$1 = toPropertyKey$3;
var $TypeError$2 = TypeError;
var $defineProperty = Object.defineProperty;
var $getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
var ENUMERABLE = "enumerable";
var CONFIGURABLE$1 = "configurable";
var WRITABLE = "writable";
objectDefineProperty.f = DESCRIPTORS$3 ? V8_PROTOTYPE_DEFINE_BUG ? function defineProperty(O, P, Attributes) {
anObject$4(O);
P = toPropertyKey$1(P);
anObject$4(Attributes);
if (typeof O === "function" && P === "prototype" && "value" in Attributes && WRITABLE in Attributes && !Attributes[WRITABLE]) {
var current = $getOwnPropertyDescriptor(O, P);
if (current && current[WRITABLE]) {
O[P] = Attributes.value;
Attributes = {
configurable: CONFIGURABLE$1 in Attributes ? Attributes[CONFIGURABLE$1] : current[CONFIGURABLE$1],
enumerable: ENUMERABLE in Attributes ? Attributes[ENUMERABLE] : current[ENUMERABLE],
writable: false
};
}
}
return $defineProperty(O, P, Attributes);
} : $defineProperty : function defineProperty2(O, P, Attributes) {
anObject$4(O);
P = toPropertyKey$1(P);
anObject$4(Attributes);
if (IE8_DOM_DEFINE)
try {
return $defineProperty(O, P, Attributes);
} catch (error) {
}
if ("get" in Attributes || "set" in Attributes)
throw new $TypeError$2("Accessors not supported");
if ("value" in Attributes)
O[P] = Attributes.value;
return O;
};
var DESCRIPTORS$2 = descriptors;
var definePropertyModule$2 = objectDefineProperty;
var createPropertyDescriptor = createPropertyDescriptor$2;
var createNonEnumerableProperty$2 = DESCRIPTORS$2 ? function(object, key, value) {
return definePropertyModule$2.f(object, key, createPropertyDescriptor(1, value));
} : function(object, key, value) {
object[key] = value;
return object;
};
var makeBuiltIn$2 = { exports: {} };
var DESCRIPTORS$1 = descriptors;
var hasOwn$4 = hasOwnProperty_1;
var FunctionPrototype = Function.prototype;
var getDescriptor = DESCRIPTORS$1 && Object.getOwnPropertyDescriptor;
var EXISTS = hasOwn$4(FunctionPrototype, "name");
var PROPER = EXISTS && (function something() {
}).name === "something";
var CONFIGURABLE = EXISTS && (!DESCRIPTORS$1 || DESCRIPTORS$1 && getDescriptor(FunctionPrototype, "name").configurable);
var functionName = {
EXISTS,
PROPER,
CONFIGURABLE
};
var uncurryThis$8 = functionUncurryThis;
var isCallable$5 = isCallable$b;
var store$1 = sharedStoreExports;
var functionToString = uncurryThis$8(Function.toString);
if (!isCallable$5(store$1.inspectSource)) {
store$1.inspectSource = function(it) {
return functionToString(it);
};
}
var inspectSource$1 = store$1.inspectSource;
var globalThis$3 = globalThis_1;
var isCallable$4 = isCallable$b;
var WeakMap$1 = globalThis$3.WeakMap;
var weakMapBasicDetection = isCallable$4(WeakMap$1) && /native code/.test(String(WeakMap$1));
var shared$1 = shared$3;
var uid = uid$2;
var keys = shared$1("keys");
var sharedKey$1 = function(key) {
return keys[key] || (keys[key] = uid(key));
};
var hiddenKeys$3 = {};
var NATIVE_WEAK_MAP = weakMapBasicDetection;
var globalThis$2 = globalThis_1;
var isObject = isObject$5;
var createNonEnumerableProperty$1 = createNonEnumerableProperty$2;
var hasOwn$3 = hasOwnProperty_1;
var shared = sharedStoreExports;
var sharedKey = sharedKey$1;
var hiddenKeys$2 = hiddenKeys$3;
var OBJECT_ALREADY_INITIALIZED = "Object already initialized";
var TypeError$1 = globalThis$2.TypeError;
var WeakMap = globalThis$2.WeakMap;
var set$1, get$1, has$1;
var enforce = function(it) {
return has$1(it) ? get$1(it) : set$1(it, {});
};
var getterFor = function(TYPE) {
return function(it) {
var state;
if (!isObject(it) || (state = get$1(it)).type !== TYPE) {
throw new TypeError$1("Incompatible receiver, " + TYPE + " required");
}
return state;
};
};
if (NATIVE_WEAK_MAP || shared.state) {
var store = shared.state || (shared.state = new WeakMap());
store.get = store.get;
store.has = store.has;
store.set = store.set;
set$1 = function(it, metadata) {
if (store.has(it))
throw new TypeError$1(OBJECT_ALREADY_INITIALIZED);
metadata.facade = it;
store.set(it, metadata);
return metadata;
};
get$1 = function(it) {
return store.get(it) || {};
};
has$1 = function(it) {
return store.has(it);
};
} else {
var STATE = sharedKey("state");
hiddenKeys$2[STATE] = true;
set$1 = function(it, metadata) {
if (hasOwn$3(it, STATE))
throw new TypeError$1(OBJECT_ALREADY_INITIALIZED);
metadata.facade = it;
createNonEnumerableProperty$1(it, STATE, metadata);
return metadata;
};
get$1 = function(it) {
return hasOwn$3(it, STATE) ? it[STATE] : {};
};
has$1 = function(it) {
return hasOwn$3(it, STATE);
};
}
var internalState = {
set: set$1,
get: get$1,
has: has$1,
enforce,
getterFor
};
var uncurryThis$7 = functionUncurryThis;
var fails$3 = fails$a;
var isCallable$3 = isCallable$b;
var hasOwn$2 = hasOwnProperty_1;
var DESCRIPTORS = descriptors;
var CONFIGURABLE_FUNCTION_NAME = functionName.CONFIGURABLE;
var inspectSource = inspectSource$1;
var InternalStateModule = internalState;
var enforceInternalState = InternalStateModule.enforce;
var getInternalState = InternalStateModule.get;
var $String = String;
var defineProperty3 = Object.defineProperty;
var stringSlice = uncurryThis$7("".slice);
var replace = uncurryThis$7("".replace);
var join = uncurryThis$7([].join);
var CONFIGURABLE_LENGTH = DESCRIPTORS && !fails$3(function() {
return defineProperty3(function() {
}, "length", { value: 8 }).length !== 8;
});
var TEMPLATE = String(String).split("String");
var makeBuiltIn$1 = makeBuiltIn$2.exports = function(value, name, options) {
if (stringSlice($String(name), 0, 7) === "Symbol(") {
name = "[" + replace($String(name), /^Symbol\(([^)]*)\).*$/, "$1") + "]";
}
if (options && options.getter)
name = "get " + name;
if (options && options.setter)
name = "set " + name;
if (!hasOwn$2(value, "name") || CONFIGURABLE_FUNCTION_NAME && value.name !== name) {
if (DESCRIPTORS)
defineProperty3(value, "name", { value: name, configurable: true });
else
value.name = name;
}
if (CONFIGURABLE_LENGTH && options && hasOwn$2(options, "arity") && value.length !== options.arity) {
defineProperty3(value, "length", { value: options.arity });
}
try {
if (options && hasOwn$2(options, "constructor") && options.constructor) {
if (DESCRIPTORS)
defineProperty3(value, "prototype", { writable: false });
} else if (value.prototype)
value.prototype = void 0;
} catch (error) {
}
var state = enforceInternalState(value);
if (!hasOwn$2(state, "source")) {
state.source = join(TEMPLATE, typeof name == "string" ? name : "");
}
return value;
};
Function.prototype.toString = makeBuiltIn$1(function toString2() {
return isCallable$3(this) && getInternalState(this).source || inspectSource(this);
}, "toString");
var makeBuiltInExports = makeBuiltIn$2.exports;
var isCallable$2 = isCallable$b;
var definePropertyModule$1 = objectDefineProperty;
var makeBuiltIn = makeBuiltInExports;
var defineGlobalProperty$1 = defineGlobalProperty$3;
var defineBuiltIn$1 = function(O, key, value, options) {
if (!options)
options = {};
var simple = options.enumerable;
var name = options.name !== void 0 ? options.name : key;
if (isCallable$2(value))
makeBuiltIn(value, name, options);
if (options.global) {
if (simple)
O[key] = value;
else
defineGlobalProperty$1(key, value);
} else {
try {
if (!options.unsafe)
delete O[key];
else if (O[key])
simple = true;
} catch (error) {
}
if (simple)
O[key] = value;
else
definePropertyModule$1.f(O, key, {
value,
enumerable: false,
configurable: !options.nonConfigurable,
writable: !options.nonWritable
});
}
return O;
};
var objectGetOwnPropertyNames = {};
var ceil = Math.ceil;
var floor = Math.floor;
var mathTrunc = Math.trunc || function trunc(x) {
var n = +x;
return (n > 0 ? floor : ceil)(n);
};
var trunc2 = mathTrunc;
var toIntegerOrInfinity$2 = function(argument) {
var number = +argument;
return number !== number || number === 0 ? 0 : trunc2(number);
};
var toIntegerOrInfinity$1 = toIntegerOrInfinity$2;
var max = Math.max;
var min$1 = Math.min;
var toAbsoluteIndex$1 = function(index, length) {
var integer = toIntegerOrInfinity$1(index);
return integer < 0 ? max(integer + length, 0) : min$1(integer, length);
};
var toIntegerOrInfinity = toIntegerOrInfinity$2;
var min = Math.min;
var toLength$1 = function(argument) {
var len = toIntegerOrInfinity(argument);
return len > 0 ? min(len, 9007199254740991) : 0;
};
var toLength = toLength$1;
var lengthOfArrayLike$2 = function(obj) {
return toLength(obj.length);
};
var toIndexedObject$1 = toIndexedObject$3;
var toAbsoluteIndex = toAbsoluteIndex$1;
var lengthOfArrayLike$1 = lengthOfArrayLike$2;
var createMethod = function(IS_INCLUDES) {
return function($this, el, fromIndex) {
var O = toIndexedObject$1($this);
var length = lengthOfArrayLike$1(O);
if (length === 0)
return !IS_INCLUDES && -1;
var index = toAbsoluteIndex(fromIndex, length);
var value;
if (IS_INCLUDES && el !== el)
while (length > index) {
value = O[index++];
if (value !== value)
return true;
}
else
for (; length > index; index++) {
if ((IS_INCLUDES || index in O) && O[index] === el)
return IS_INCLUDES || index || 0;
}
return !IS_INCLUDES && -1;
};
};
var arrayIncludes = {
// `Array.prototype.includes` method
// https://tc39.es/ecma262/#sec-array.prototype.includes
includes: createMethod(true),
// `Array.prototype.indexOf` method
// https://tc39.es/ecma262/#sec-array.prototype.indexof
indexOf: createMethod(false)
};
var uncurryThis$6 = functionUncurryThis;
var hasOwn$1 = hasOwnProperty_1;
var toIndexedObject = toIndexedObject$3;
var indexOf = arrayIncludes.indexOf;
var hiddenKeys$1 = hiddenKeys$3;
var push$2 = uncurryThis$6([].push);
var objectKeysInternal = function(object, names) {
var O = toIndexedObject(object);
var i = 0;
var result = [];
var key;
for (key in O)
!hasOwn$1(hiddenKeys$1, key) && hasOwn$1(O, key) && push$2(result, key);
while (names.length > i)
if (hasOwn$1(O, key = names[i++])) {
~indexOf(result, key) || push$2(result, key);
}
return result;
};
var enumBugKeys$1 = [
"constructor",
"hasOwnProperty",
"isPrototypeOf",
"propertyIsEnumerable",
"toLocaleString",
"toString",
"valueOf"
];
var internalObjectKeys = objectKeysInternal;
var enumBugKeys = enumBugKeys$1;
var hiddenKeys = enumBugKeys.concat("length", "prototype");
objectGetOwnPropertyNames.f = Object.getOwnPropertyNames || function getOwnPropertyNames(O) {
return internalObjectKeys(O, hiddenKeys);
};
var objectGetOwnPropertySymbols = {};
objectGetOwnPropertySymbols.f = Object.getOwnPropertySymbols;
var getBuiltIn$1 = getBuiltIn$3;
var uncurryThis$5 = functionUncurryThis;
var getOwnPropertyNamesModule = objectGetOwnPropertyNames;
var getOwnPropertySymbolsModule = objectGetOwnPropertySymbols;
var anObject$3 = anObject$5;
var concat = uncurryThis$5([].concat);
var ownKeys$1 = getBuiltIn$1("Reflect", "ownKeys") || function ownKeys(it) {
var keys2 = getOwnPropertyNamesModule.f(anObject$3(it));
var getOwnPropertySymbols = getOwnPropertySymbolsModule.f;
return getOwnPropertySymbols ? concat(keys2, getOwnPropertySymbols(it)) : keys2;
};
var hasOwn2 = hasOwnProperty_1;
var ownKeys2 = ownKeys$1;
var getOwnPropertyDescriptorModule = objectGetOwnPropertyDescriptor;
var definePropertyModule = objectDefineProperty;
var copyConstructorProperties$1 = function(target, source, exceptions) {
var keys2 = ownKeys2(source);
var defineProperty4 = definePropertyModule.f;
var getOwnPropertyDescriptor3 = getOwnPropertyDescriptorModule.f;
for (var i = 0; i < keys2.length; i++) {
var key = keys2[i];
if (!hasOwn2(target, key) && !(exceptions && hasOwn2(exceptions, key))) {
defineProperty4(target, key, getOwnPropertyDescriptor3(source, key));
}
}
};
var fails$2 = fails$a;
var isCallable$1 = isCallable$b;
var replacement = /#|\.prototype\./;
var isForced$1 = function(feature, detection) {
var value = data[normalize(feature)];
return value === POLYFILL ? true : value === NATIVE ? false : isCallable$1(detection) ? fails$2(detection) : !!detection;
};
var normalize = isForced$1.normalize = function(string) {
return String(string).replace(replacement, ".").toLowerCase();
};
var data = isForced$1.data = {};
var NATIVE = isForced$1.NATIVE = "N";
var POLYFILL = isForced$1.POLYFILL = "P";
var isForced_1 = isForced$1;
var globalThis$1 = globalThis_1;
var getOwnPropertyDescriptor2 = objectGetOwnPropertyDescriptor.f;
var createNonEnumerableProperty = createNonEnumerableProperty$2;
var defineBuiltIn = defineBuiltIn$1;
var defineGlobalProperty = defineGlobalProperty$3;
var copyConstructorProperties = copyConstructorProperties$1;
var isForced = isForced_1;
var _export = function(options, source) {
var TARGET = options.target;
var GLOBAL = options.global;
var STATIC = options.stat;
var FORCED, target, key, targetProperty, sourceProperty, descriptor;
if (GLOBAL) {
target = globalThis$1;
} else if (STATIC) {
target = globalThis$1[TARGET] || defineGlobalProperty(TARGET, {});
} else {
target = globalThis$1[TARGET] && globalThis$1[TARGET].prototype;
}
if (target)
for (key in source) {
sourceProperty = source[key];
if (options.dontCallGetSet) {
descriptor = getOwnPropertyDescriptor2(target, key);
targetProperty = descriptor && descriptor.value;
} else
targetProperty = target[key];
FORCED = isForced(GLOBAL ? key : TARGET + (STATIC ? "." : "#") + key, options.forced);
if (!FORCED && targetProperty !== void 0) {
if (typeof sourceProperty == typeof targetProperty)
continue;
copyConstructorProperties(sourceProperty, targetProperty);
}
if (options.sham || targetProperty && targetProperty.sham) {
createNonEnumerableProperty(sourceProperty, "sham", true);
}
defineBuiltIn(target, key, sourceProperty, options);
}
};
var classofRaw$1 = classofRaw$2;
var uncurryThis$4 = functionUncurryThis;
var functionUncurryThisClause = function(fn) {
if (classofRaw$1(fn) === "Function")
return uncurryThis$4(fn);
};
var uncurryThis$3 = functionUncurryThisClause;
var aCallable$3 = aCallable$5;
var NATIVE_BIND = functionBindNative;
var bind$1 = uncurryThis$3(uncurryThis$3.bind);
var functionBindContext = function(fn, that) {
aCallable$3(fn);
return that === void 0 ? fn : NATIVE_BIND ? bind$1(fn, that) : function() {
return fn.apply(that, arguments);
};
};
var iterators = {};
var wellKnownSymbol$3 = wellKnownSymbol$5;
var Iterators$1 = iterators;
var ITERATOR$1 = wellKnownSymbol$3("iterator");
var ArrayPrototype = Array.prototype;
var isArrayIteratorMethod$1 = function(it) {
return it !== void 0 && (Iterators$1.Array === it || ArrayPrototype[ITERATOR$1] === it);
};
var wellKnownSymbol$2 = wellKnownSymbol$5;
var TO_STRING_TAG$1 = wellKnownSymbol$2("toStringTag");
var test = {};
test[TO_STRING_TAG$1] = "z";
var toStringTagSupport = String(test) === "[object z]";
var TO_STRING_TAG_SUPPORT = toStringTagSupport;
var isCallable = isCallable$b;
var classofRaw = classofRaw$2;
var wellKnownSymbol$1 = wellKnownSymbol$5;
var TO_STRING_TAG = wellKnownSymbol$1("toStringTag");
var $Object = Object;
var CORRECT_ARGUMENTS = classofRaw(/* @__PURE__ */ function() {
return arguments;
}()) === "Arguments";
var tryGet = function(it, key) {
try {
return it[key];
} catch (error) {
}
};
var classof$1 = TO_STRING_TAG_SUPPORT ? classofRaw : function(it) {
var O, tag, result;
return it === void 0 ? "Undefined" : it === null ? "Null" : typeof (tag = tryGet(O = $Object(it), TO_STRING_TAG)) == "string" ? tag : CORRECT_ARGUMENTS ? classofRaw(O) : (result = classofRaw(O)) === "Object" && isCallable(O.callee) ? "Arguments" : result;
};
var classof = classof$1;
var getMethod$1 = getMethod$3;
var isNullOrUndefined = isNullOrUndefined$3;
var Iterators = iterators;
var wellKnownSymbol = wellKnownSymbol$5;
var ITERATOR = wellKnownSymbol("iterator");
var getIteratorMethod$2 = function(it) {
if (!isNullOrUndefined(it))
return getMethod$1(it, ITERATOR) || getMethod$1(it, "@@iterator") || Iterators[classof(it)];
};
var call$2 = functionCall;
var aCallable$2 = aCallable$5;
var anObject$2 = anObject$5;
var tryToString$1 = tryToString$3;
var getIteratorMethod$1 = getIteratorMethod$2;
var $TypeError$1 = TypeError;
var getIterator$1 = function(argument, usingIterator) {
var iteratorMethod = arguments.length < 2 ? getIteratorMethod$1(argument) : usingIterator;
if (aCallable$2(iteratorMethod))
return anObject$2(call$2(iteratorMethod, argument));
throw new $TypeError$1(tryToString$1(argument) + " is not iterable");
};
var call$1 = functionCall;
var anObject$1 = anObject$5;
var getMethod = getMethod$3;
var iteratorClose$1 = function(iterator, kind, value) {
var innerResult, innerError;
anObject$1(iterator);
try {
innerResult = getMethod(iterator, "return");
if (!innerResult) {
if (kind === "throw")
throw value;
return value;
}
innerResult = call$1(innerResult, iterator);
} catch (error) {
innerError = true;
innerResult = error;
}
if (kind === "throw")
throw value;
if (innerError)
throw innerResult;
anObject$1(innerResult);
return value;
};
var bind = functionBindContext;
var call = functionCall;
var anObject = anObject$5;
var tryToString = tryToString$3;
var isArrayIteratorMethod = isArrayIteratorMethod$1;
var lengthOfArrayLike = lengthOfArrayLike$2;
var isPrototypeOf = objectIsPrototypeOf;
var getIterator = getIterator$1;
var getIteratorMethod = getIteratorMethod$2;
var iteratorClose = iteratorClose$1;
var $TypeError = TypeError;
var Result = function(stopped, result) {
this.stopped = stopped;
this.result = result;
};
var ResultPrototype = Result.prototype;
var iterate$2 = function(iterable, unboundFunction, options) {
var that = options && options.that;
var AS_ENTRIES = !!(options && options.AS_ENTRIES);
var IS_RECORD = !!(options && options.IS_RECORD);
var IS_ITERATOR = !!(options && options.IS_ITERATOR);
var INTERRUPTED = !!(options && options.INTERRUPTED);
var fn = bind(unboundFunction, that);
var iterator, iterFn, index, length, result, next, step;
var stop = function(condition) {
if (iterator)
iteratorClose(iterator, "normal");
return new Result(true, condition);
};
var callFn = function(value) {
if (AS_ENTRIES) {
anObject(value);
return INTERRUPTED ? fn(value[0], value[1], stop) : fn(value[0], value[1]);
}
return INTERRUPTED ? fn(value, stop) : fn(value);
};
if (IS_RECORD) {
iterator = iterable.iterator;
} else if (IS_ITERATOR) {
iterator = iterable;
} else {
iterFn = getIteratorMethod(iterable);
if (!iterFn)
throw new $TypeError(tryToString(iterable) + " is not iterable");
if (isArrayIteratorMethod(iterFn)) {
for (index = 0, length = lengthOfArrayLike(iterable); length > index; index++) {
result = callFn(iterable[index]);
if (result && isPrototypeOf(ResultPrototype, result))
return result;
}
return new Result(false);
}
iterator = getIterator(iterable, iterFn);
}
next = IS_RECORD ? iterable.next : iterator.next;
while (!(step = call(next, iterator)).done) {
try {
result = callFn(step.value);
} catch (error) {
iteratorClose(iterator, "throw", error);
}
if (typeof result == "object" && result && isPrototypeOf(ResultPrototype, result))
return result;
}
return new Result(false);
};
var uncurryThis$2 = functionUncurryThis;
var MapPrototype = Map.prototype;
var mapHelpers = {
// eslint-disable-next-line es/no-map -- safe
Map,
set: uncurryThis$2(MapPrototype.set),
get: uncurryThis$2(MapPrototype.get),
has: uncurryThis$2(MapPrototype.has),
remove: uncurryThis$2(MapPrototype["delete"]),
proto: MapPrototype
};
var $$1 = _export;
var uncurryThis$1 = functionUncurryThis;
var aCallable$1 = aCallable$5;
var requireObjectCoercible$1 = requireObjectCoercible$4;
var iterate$1 = iterate$2;
var MapHelpers = mapHelpers;
var fails$1 = fails$a;
var Map$1 = MapHelpers.Map;
var has = MapHelpers.has;
var get = MapHelpers.get;
var set = MapHelpers.set;
var push$1 = uncurryThis$1([].push);
var DOES_NOT_WORK_WITH_PRIMITIVES$1 = fails$1(function() {
return Map$1.groupBy("ab", function(it) {
return it;
}).get("a").length !== 1;
});
$$1({ target: "Map", stat: true, forced: DOES_NOT_WORK_WITH_PRIMITIVES$1 }, {
groupBy: function groupBy(items, callbackfn) {
requireObjectCoercible$1(items);
aCallable$1(callbackfn);
var map = new Map$1();
var k = 0;
iterate$1(items, function(value) {
var key = callbackfn(value, k++);
if (!has(map, key))
set(map, key, [value]);
else
push$1(get(map, key), value);
});
return map;
}
});
var $ = _export;
var getBuiltIn = getBuiltIn$3;
var uncurryThis = functionUncurryThis;
var aCallable = aCallable$5;
var requireObjectCoercible = requireObjectCoercible$4;
var toPropertyKey = toPropertyKey$3;
var iterate = iterate$2;
var fails = fails$a;
var nativeGroupBy = Object.groupBy;
var create = getBuiltIn("Object", "create");
var push = uncurryThis([].push);
var DOES_NOT_WORK_WITH_PRIMITIVES = !nativeGroupBy || fails(function() {
return nativeGroupBy("ab", function(it) {
return it;
}).a.length !== 1;
});
$({ target: "Object", stat: true, forced: DOES_NOT_WORK_WITH_PRIMITIVES }, {
groupBy: function groupBy2(items, callbackfn) {
requireObjectCoercible(items);
aCallable(callbackfn);
var obj = create(null);
var k = 0;
iterate(items, function(value) {
var key = toPropertyKey(callbackfn(value, k++));
if (key in obj)
push(obj[key], value);
else
obj[key] = [value];
});
return obj;
}
});
function keyListener(el, fn) {
el.addEventListener(
"keyup",
(e) => {
if (e.key === "ArrowUp" || e.key === "ArrowRight") {
fn("next");
} else if (e.key === "ArrowDown" || e.key === "ArrowLeft") {
fn("prev");
}
},
false
);
}
function wheelListener(el, fn) {
const threshold = 750;
const allowedTime = 50;
let dist = 0;
let isScrolling;
el.addEventListener("wheel", (e) => {
if (e.ignore)
return;
e.ignore = true;
clearTimeout(isScrolling);
dist += e.deltaY;
isScrolling = setTimeout(() => {
if (Math.abs(dist) >= threshold) {
let direction = Math.sign(dist) > 0 ? "next" : "prev";
fn(direction);
dist = 0;
}
dist = 0;
}, allowedTime);
});
}
function swipListener(document2, fn) {
const threshold = 50;
const allowedTime = 500;
const restraint = 200;
let startX;
let startY;
let startTime;
document2.addEventListener(
"touchstart",
(e) => {
if (e.ignore)
return;
e.ignore = true;
startX = e.changedTouches[0].pageX;
startY = e.changedTouches[0].pageY;
startTime = Date.now();
},
false
);
document2.addEventListener(
"touchend",
(e) => {
var _a, _b;
if (e.ignore)
return;
e.ignore = true;
const distX = e.changedTouches[0].pageX - startX;
const distY = e.changedTouches[0].pageY - startY;
const elapsedTime = Date.now() - startTime;
if (elapsedTime <= allowedTime) {
if (Math.abs(distX) >= threshold && Math.abs(distY) <= restraint)
fn(distX < 0 ? "next" : "prev");
else if (Math.abs(distY) >= threshold && Math.abs(distX) <= restraint)
fn(distY < 0 ? "up" : "down");
else {
(_b = (_a = document2 == null ? void 0 : document2.defaultView) == null ? void 0 : _a.getSelection()) == null ? void 0 : _b.removeAllRanges();
document2.dispatchEvent(
new MouseEvent("click", {
clientX: startX,
clientY: startY
})
);
e.preventDefault();
}
}
},
false
);
}
const _export_sfc = (sfc, props) => {
const target = sfc.__vccOpts || sfc;
for (const [key, val] of props) {
target[key] = val;
}
return target;
};
const _hoisted_1$2 = { class: "reader" };
const _hoisted_2$2 = { class: "viewHolder" };
const _hoisted_3$1 = { key: 0 };
const _sfc_main$2 = {
__name: "BookView",
props: {
url: {
type: [String, File]
},
location: {
type: [String, Number]
},
tocChanged: Function,
getRendition: Function
},
emits: ["update:location"],
setup(__props, { expose: __expose, emit: __emit }) {
window.Promise.withResolvers = function() {
let resolve, reject;
const promise = new Promise((res, rej) => {
resolve = res;
reject = rej;
});
return { resolve, reject, promise };
};
const props = __props;
const { tocChanged, getRendition } = props;
const { url, location } = toRefs(props);
const emit = __emit;
let view = null;
const viewer = ref(null);
const isLoaded = ref(false);
const isError = ref(false);
const getCSS = ({ spacing, justify, hyphenate }) => `
@namespace epub "http://www.idpf.org/2007/ops";
html {
color-scheme: light dark;
}
/* https://github.com/whatwg/html/issues/5426 */
@media (prefers-color-scheme: dark) {
a:link {
color: lightblue;
}
}
p, li, blockquote, dd {
line-height: ${spacing};
text-align: ${justify ? "justify" : "start"};
-webkit-hyphens: ${hyphenate ? "auto" : "manual"};
hyphens: ${hyphenate ? "auto" : "manual"};
-webkit-hyphenate-limit-before: 3;
-webkit-hyphenate-limit-after: 2;
-webkit-hyphenate-limit-lines: 2;
hanging-punctuation: allow-end last;
widows: 2;
}
/* prevent the above from overriding the align attribute */
[align="left"] { text-align: left; }
[align="right"] { text-align: right; }
[align="center"] { text-align: center; }
[align="justify"] { text-align: justify; }
pre {
white-space: pre-wrap !important;
}
aside[epub|type~="endnote"],
aside[epub|type~="footnote"],
aside[epub|type~="note"],
aside[epub|type~="rearnote"] {
display: none;
}
`;
const initBook = async () => {
import("./view-DXqPfWdc.js").then((n) => n.v).then(async (res) => {
view = document.createElement("foliate-view");
viewer.value.append(view);
if (url.value) {
view && view.close();
try {
await view.open(url.value);
initReader();
} catch (error) {
console.error("Error opening book:", error);
isError.value = true;
}
}
}).catch((error) => {
console.error("Error opening book:", error);
});
};
const initReader = () => {
var _a, _b;
isLoaded.value = true;
const { book } = view;
(_b = (_a = view.renderer).setStyles) == null ? void 0 : _b.call(
_a,
getCSS({
spacing: 1.4,
justify: true,
hyphenate: true
})
);
registerEvents();
view.addEventListener("load", () => {
getRendition(view);
});
tocChanged && tocChanged(book.toc);
if (location.value) {
view == null ? void 0 : view.goTo(location.value);
} else {
view.renderer.next();
}
};
const flipPage = (direction) => {
if (direction === "next")
nextPage();
else if (direction === "prev")
prevPage();
};
const registerEvents = () => {
view.addEventListener("load", onLoad);
view.addEventListener("relocate", onRelocate);
};
const onLoad = ({ detail: { doc } }) => {
wheelListener(doc, flipPage);
swipListener(doc, flipPage);
keyListener(doc, flipPage);
};
onUnmounted(() => {
view == null ? void 0 : view.removeEventListener("load", onLoad);
view == null ? void 0 : view.removeEventListener("relocate", onRelocate);
});
const onRelocate = ({ detail }) => {
emit("update:location", detail);
};
const nextPage = () => view == null ? void 0 : view.next();
const prevPage = () => view == null ? void 0 : view.prev();
const setLocation = (href) => view == null ? void 0 : view.goTo(href);
watch(url, () => {
initBook();
});
onMounted(() => {
initBook();
});
__expose({
nextPage,
prevPage,
setLocation
});
return (_ctx, _cache) => {
return openBlock(), createElementBlock("div", _hoisted_1$2, [
createElementVNode("div", _hoisted_2$2, [
withDirectives(createElementVNode("div", {
ref_key: "viewer",
ref: viewer,
id: "viewer"
}, null, 512), [
[vShow, isLoaded.value]
]),
!isLoaded.value ? (openBlock(), createElementBlock("div", _hoisted_3$1, [
!isError.value ? renderSlot(_ctx.$slots, "loadingView", { key: 0 }, void 0, true) : renderSlot(_ctx.$slots, "errorView", { key: 1 }, void 0, true)
])) : createCommentVNode("", true)
])
]);
};
}
};
const BookView = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-8392fe11"]]);
const _hoisted_1$1 = ["onClick"];
const _hoisted_2$1 = { key: 0 };
const _sfc_main$1 = /* @__PURE__ */ defineComponent({
__name: "Toc",
props: {
toc: {},
current: {},
setLocation: {},
isSubmenu: { type: Boolean, default: false }
},
setup(__props) {
const bookToc = ref([]);
const props = __props;
const { setLocation } = props;
const { toc, current, isSubmenu } = toRefs(props);
const handleClick = (item) => {
var _a;
if (item.subitems && ((_a = item == null ? void 0 : item.subitems) == null ? void 0 : _a.length) > 0) {
item.expansion = !item.expansion;
console.log("item.href", item.href);
setLocation(item.href, false);
} else {
setLocation(item.href);
}
};
watchEffect(() => {
bookToc.value = toc.value.map((item) => ({
...item,
expansion: false
}));
});
return (_ctx, _cache) => {
const _component_Toc = resolveComponent("Toc", true);
return openBlock(true), createElementBlock(Fragment, null, renderList(bookToc.value, (item, index) => {
return openBlock(), createElementBlock("div", { key: index }, [
createElementVNode("button", {
class: normalizeClass(["tocAreaButton", { active: item.href === unref(current) }]),
onClick: ($event) => handleClick(item)
}, [
createTextVNode(toDisplayString(unref(isSubmenu) ? " ".repeat(4) + item.label : item.label) + " ", 1),
item.subitems && item.subitems.length > 0 ? (openBlock(), createElementBlock("div", {
key: 0,
class: normalizeClass(["expansion", { open: item.expansion }])
}, null, 2)) : createCommentVNode("", true)
], 10, _hoisted_1$1),
item.subitems && item.subitems.length > 0 ? withDirectives((openBlock(), createElementBlock("div", _hoisted_2$1, [
createVNode(_component_Toc, {
toc: item.subitems,
current: unref(current),
setLocation: unref(setLocation),
isSubmenu: true
}, null, 8, ["toc", "current", "setLocation"])
], 512)), [
[vShow, item.expansion]
]) : createCommentVNode("", true)
]);
}), 128);
};
}
});
const Toc = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-300395c2"]]);
const _withScopeId = (n) => (pushScopeId("data-v-a2442a4b"), n = n(), popScopeId(), n);
const _hoisted_1 = { class: "container" };
const _hoisted_2 = /* @__PURE__ */ _withScopeId(() => /* @__PURE__ */ createElementVNode("span", {
class: "tocButtonBar",
style: { "top": "35%" }
}, null, -1));
const _hoisted_3 = /* @__PURE__ */ _withScopeId(() => /* @__PURE__ */ createElementVNode("span", {
class: "tocButtonBar",
style: { "top": "66%" }
}, null, -1));
const _hoisted_4 = [
_hoisted_2,
_hoisted_3
];
const _hoisted_5 = ["title"];
const _hoisted_6 = /* @__PURE__ */ _withScopeId(() => /* @__PURE__ */ createElementVNode("div", { class: "loadingView" }, "Loading…", -1));
const _hoisted_7 = /* @__PURE__ */ _withScopeId(() => /* @__PURE__ */ createElementVNode("div", { class: "errorView" }, "Error loading book", -1));
const _hoisted_8 = { key: 0 };
const _hoisted_9 = { class: "tocArea" };
const _sfc_main = {
__name: "VueReader",
props: {
title: {
type: String
},
showToc: {
type: Boolean,
default: true
},
title: {
type: String,
default: ""
},
getRendition: {
type: Function
}
},
setup(__props, { expose: __expose }) {
const props = __props;
const book = reactive({
toc: [],
//目录
expandedToc: false
//目录展开
});
const { getRendition } = props;
const { toc, expandedToc } = toRefs(book);
const bookRef = ref(null);
const currentHref = ref(null);
const bookName = ref("");
let rendition = null;
const onRelocate = ({ detail }) => {
var _a;
currentHref.value = (_a = detail.tocItem) == null ? void 0 : _a.href;
};
const onGetRendition = (val) => {
var _a;
rendition = val;
getRendition && getRendition(rendition);
const { book: book2 } = rendition;
const title = (_a = book2.metadata) == null ? void 0 : _a.title;
bookName.value = title || "";
rendition.addEventListener("relocate", onRelocate);
};
const onTocChange = (_toc) => {
toc.value = _toc;
};
const toggleToc = () => {
expandedToc.value = !expandedToc.value;
};
const next = () => {
var _a;
(_a = bookRef.value) == null ? void 0 : _a.nextPage();
};
const pre = () => {
var _a;
(_a = bookRef.value) == null ? void 0 : _a.prevPage();
};
const setLocation = (href, close = true) => {
bookRef.value.setLocation(href);
expandedToc.value = !close;
};
__expose({
nextPage: next,
prevPage: pre,
setLocation
});
return (_ctx, _cache) => {
return openBlock(), createElementBlock("div", _hoisted_1, [
createElementVNode("div", {
class: normalizeClass(["readerArea", { containerExpanded: unref(expandedToc) }])
}, [
__props.showToc ? (openBlock(), createElementBlock("button", {
key: 0,
class: normalizeClass(["tocButton", { tocButtonExpanded: unref(expandedToc) }]),
type: "button",
onClick: toggleToc
}, _hoisted_4, 2)) : createCommentVNode("", true),
renderSlot(_ctx.$slots, "title", {}, () => [
createElementVNode("div", {
class: "titleArea",
title: __props.title || bookName.value
}, toDisplayString(__props.title || bookName.value), 9, _hoisted_5)
], true),
createVNode(BookView, mergeProps({
ref_key: "bookRef",
ref: bookRef
}, _ctx.$attrs, {
tocChanged: onTocChange,
getRendition: onGetRendition
}), {
loadingView: withCtx(() => [
renderSlot(_ctx.$slots, "loadingView", {}, () => [
_hoisted_6
], true)
]),
errorView: withCtx(() => [
renderSlot(_ctx.$slots, "errorView", {}, () => [
_hoisted_7
], true)
]),
_: 3
}, 16),
createElementVNode("button", {
class: "arrow pre",
onClick: pre
}, "‹"),
createElementVNode("button", {
class: "arrow next",
onClick: next
}, "›")
], 2),
__props.showToc ? (openBlock(), createElementBlock("div", _hoisted_8, [
createElementVNode("div", _hoisted_9, [
createVNode(Toc, {
toc: unref(toc),
current: currentHref.value,
setLocation
}, null, 8, ["toc", "current"])
]),
unref(expandedToc) ? (openB