2026-03-19 03:41:09 +00:00

5267 lines
179 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

(function(global, factory) {
typeof exports === "object" && typeof module !== "undefined" ? module.exports = factory() : typeof define === "function" && define.amd ? define([], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, global.magicPresetEvents = factory());
})(this, function() {
//#region \0rolldown/runtime.js
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
key = keys[i];
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
get: ((k) => from[k]).bind(null, key),
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
});
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
value: mod,
enumerable: true
}) : target, mod));
//#endregion
//#region ../../node_modules/.pnpm/events@3.3.0/node_modules/events/events.js
var require_events = /* @__PURE__ */ __commonJSMin(((exports, module) => {
var R = typeof Reflect === "object" ? Reflect : null;
var ReflectApply = R && typeof R.apply === "function" ? R.apply : function ReflectApply(target, receiver, args) {
return Function.prototype.apply.call(target, receiver, args);
};
var ReflectOwnKeys;
if (R && typeof R.ownKeys === "function") ReflectOwnKeys = R.ownKeys;
else if (Object.getOwnPropertySymbols) ReflectOwnKeys = function ReflectOwnKeys(target) {
return Object.getOwnPropertyNames(target).concat(Object.getOwnPropertySymbols(target));
};
else ReflectOwnKeys = function ReflectOwnKeys(target) {
return Object.getOwnPropertyNames(target);
};
function ProcessEmitWarning(warning) {
if (console && console.warn) console.warn(warning);
}
var NumberIsNaN = Number.isNaN || function NumberIsNaN(value) {
return value !== value;
};
function EventEmitter() {
EventEmitter.init.call(this);
}
module.exports = EventEmitter;
module.exports.once = once;
EventEmitter.EventEmitter = EventEmitter;
EventEmitter.prototype._events = void 0;
EventEmitter.prototype._eventsCount = 0;
EventEmitter.prototype._maxListeners = void 0;
var defaultMaxListeners = 10;
function checkListener(listener) {
if (typeof listener !== "function") throw new TypeError("The \"listener\" argument must be of type Function. Received type " + typeof listener);
}
Object.defineProperty(EventEmitter, "defaultMaxListeners", {
enumerable: true,
get: function() {
return defaultMaxListeners;
},
set: function(arg) {
if (typeof arg !== "number" || arg < 0 || NumberIsNaN(arg)) throw new RangeError("The value of \"defaultMaxListeners\" is out of range. It must be a non-negative number. Received " + arg + ".");
defaultMaxListeners = arg;
}
});
EventEmitter.init = function() {
if (this._events === void 0 || this._events === Object.getPrototypeOf(this)._events) {
this._events = Object.create(null);
this._eventsCount = 0;
}
this._maxListeners = this._maxListeners || void 0;
};
EventEmitter.prototype.setMaxListeners = function setMaxListeners(n) {
if (typeof n !== "number" || n < 0 || NumberIsNaN(n)) throw new RangeError("The value of \"n\" is out of range. It must be a non-negative number. Received " + n + ".");
this._maxListeners = n;
return this;
};
function _getMaxListeners(that) {
if (that._maxListeners === void 0) return EventEmitter.defaultMaxListeners;
return that._maxListeners;
}
EventEmitter.prototype.getMaxListeners = function getMaxListeners() {
return _getMaxListeners(this);
};
EventEmitter.prototype.emit = function emit(type) {
var args = [];
for (var i = 1; i < arguments.length; i++) args.push(arguments[i]);
var doError = type === "error";
var events = this._events;
if (events !== void 0) doError = doError && events.error === void 0;
else if (!doError) return false;
if (doError) {
var er;
if (args.length > 0) er = args[0];
if (er instanceof Error) throw er;
var err = /* @__PURE__ */ new Error("Unhandled error." + (er ? " (" + er.message + ")" : ""));
err.context = er;
throw err;
}
var handler = events[type];
if (handler === void 0) return false;
if (typeof handler === "function") ReflectApply(handler, this, args);
else {
var len = handler.length;
var listeners = arrayClone(handler, len);
for (var i = 0; i < len; ++i) ReflectApply(listeners[i], this, args);
}
return true;
};
function _addListener(target, type, listener, prepend) {
var m;
var events;
var existing;
checkListener(listener);
events = target._events;
if (events === void 0) {
events = target._events = Object.create(null);
target._eventsCount = 0;
} else {
if (events.newListener !== void 0) {
target.emit("newListener", type, listener.listener ? listener.listener : listener);
events = target._events;
}
existing = events[type];
}
if (existing === void 0) {
existing = events[type] = listener;
++target._eventsCount;
} else {
if (typeof existing === "function") existing = events[type] = prepend ? [listener, existing] : [existing, listener];
else if (prepend) existing.unshift(listener);
else existing.push(listener);
m = _getMaxListeners(target);
if (m > 0 && existing.length > m && !existing.warned) {
existing.warned = true;
var w = /* @__PURE__ */ new Error("Possible EventEmitter memory leak detected. " + existing.length + " " + String(type) + " listeners added. Use emitter.setMaxListeners() to increase limit");
w.name = "MaxListenersExceededWarning";
w.emitter = target;
w.type = type;
w.count = existing.length;
ProcessEmitWarning(w);
}
}
return target;
}
EventEmitter.prototype.addListener = function addListener(type, listener) {
return _addListener(this, type, listener, false);
};
EventEmitter.prototype.on = EventEmitter.prototype.addListener;
EventEmitter.prototype.prependListener = function prependListener(type, listener) {
return _addListener(this, type, listener, true);
};
function onceWrapper() {
if (!this.fired) {
this.target.removeListener(this.type, this.wrapFn);
this.fired = true;
if (arguments.length === 0) return this.listener.call(this.target);
return this.listener.apply(this.target, arguments);
}
}
function _onceWrap(target, type, listener) {
var state = {
fired: false,
wrapFn: void 0,
target,
type,
listener
};
var wrapped = onceWrapper.bind(state);
wrapped.listener = listener;
state.wrapFn = wrapped;
return wrapped;
}
EventEmitter.prototype.once = function once(type, listener) {
checkListener(listener);
this.on(type, _onceWrap(this, type, listener));
return this;
};
EventEmitter.prototype.prependOnceListener = function prependOnceListener(type, listener) {
checkListener(listener);
this.prependListener(type, _onceWrap(this, type, listener));
return this;
};
EventEmitter.prototype.removeListener = function removeListener(type, listener) {
var list, events, position, i, originalListener;
checkListener(listener);
events = this._events;
if (events === void 0) return this;
list = events[type];
if (list === void 0) return this;
if (list === listener || list.listener === listener) if (--this._eventsCount === 0) this._events = Object.create(null);
else {
delete events[type];
if (events.removeListener) this.emit("removeListener", type, list.listener || listener);
}
else if (typeof list !== "function") {
position = -1;
for (i = list.length - 1; i >= 0; i--) if (list[i] === listener || list[i].listener === listener) {
originalListener = list[i].listener;
position = i;
break;
}
if (position < 0) return this;
if (position === 0) list.shift();
else spliceOne(list, position);
if (list.length === 1) events[type] = list[0];
if (events.removeListener !== void 0) this.emit("removeListener", type, originalListener || listener);
}
return this;
};
EventEmitter.prototype.off = EventEmitter.prototype.removeListener;
EventEmitter.prototype.removeAllListeners = function removeAllListeners(type) {
var listeners, events = this._events, i;
if (events === void 0) return this;
if (events.removeListener === void 0) {
if (arguments.length === 0) {
this._events = Object.create(null);
this._eventsCount = 0;
} else if (events[type] !== void 0) if (--this._eventsCount === 0) this._events = Object.create(null);
else delete events[type];
return this;
}
if (arguments.length === 0) {
var keys = Object.keys(events);
var key;
for (i = 0; i < keys.length; ++i) {
key = keys[i];
if (key === "removeListener") continue;
this.removeAllListeners(key);
}
this.removeAllListeners("removeListener");
this._events = Object.create(null);
this._eventsCount = 0;
return this;
}
listeners = events[type];
if (typeof listeners === "function") this.removeListener(type, listeners);
else if (listeners !== void 0) for (i = listeners.length - 1; i >= 0; i--) this.removeListener(type, listeners[i]);
return this;
};
function _listeners(target, type, unwrap) {
var events = target._events;
if (events === void 0) return [];
var evlistener = events[type];
if (evlistener === void 0) return [];
if (typeof evlistener === "function") return unwrap ? [evlistener.listener || evlistener] : [evlistener];
return unwrap ? unwrapListeners(evlistener) : arrayClone(evlistener, evlistener.length);
}
EventEmitter.prototype.listeners = function listeners(type) {
return _listeners(this, type, true);
};
EventEmitter.prototype.rawListeners = function rawListeners(type) {
return _listeners(this, type, false);
};
EventEmitter.listenerCount = function(emitter, type) {
if (typeof emitter.listenerCount === "function") return emitter.listenerCount(type);
else return listenerCount.call(emitter, type);
};
EventEmitter.prototype.listenerCount = listenerCount;
function listenerCount(type) {
var events = this._events;
if (events !== void 0) {
var evlistener = events[type];
if (typeof evlistener === "function") return 1;
else if (evlistener !== void 0) return evlistener.length;
}
return 0;
}
EventEmitter.prototype.eventNames = function eventNames() {
return this._eventsCount > 0 ? ReflectOwnKeys(this._events) : [];
};
function arrayClone(arr, n) {
var copy = new Array(n);
for (var i = 0; i < n; ++i) copy[i] = arr[i];
return copy;
}
function spliceOne(list, index) {
for (; index + 1 < list.length; index++) list[index] = list[index + 1];
list.pop();
}
function unwrapListeners(arr) {
var ret = new Array(arr.length);
for (var i = 0; i < ret.length; ++i) ret[i] = arr[i].listener || arr[i];
return ret;
}
function once(emitter, name) {
return new Promise(function(resolve, reject) {
function errorListener(err) {
emitter.removeListener(name, resolver);
reject(err);
}
function resolver() {
if (typeof emitter.removeListener === "function") emitter.removeListener("error", errorListener);
resolve([].slice.call(arguments));
}
eventTargetAgnosticAddListener(emitter, name, resolver, { once: true });
if (name !== "error") addErrorHandlerIfEventEmitter(emitter, errorListener, { once: true });
});
}
function addErrorHandlerIfEventEmitter(emitter, handler, flags) {
if (typeof emitter.on === "function") eventTargetAgnosticAddListener(emitter, "error", handler, flags);
}
function eventTargetAgnosticAddListener(emitter, name, listener, flags) {
if (typeof emitter.on === "function") if (flags.once) emitter.once(name, listener);
else emitter.on(name, listener);
else if (typeof emitter.addEventListener === "function") emitter.addEventListener(name, function wrapListener(arg) {
if (flags.once) emitter.removeEventListener(name, wrapListener);
listener(arg);
});
else throw new TypeError("The \"emitter\" argument must be of type EventEmitter. Received type " + typeof emitter);
}
}));
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_freeGlobal.js
/** Detect free variable `global` from Node.js. */
var freeGlobal = typeof global == "object" && global && global.Object === Object && global;
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_root.js
/** Detect free variable `self`. */
var freeSelf = typeof self == "object" && self && self.Object === Object && self;
/** Used as a reference to the global object. */
var root = freeGlobal || freeSelf || Function("return this")();
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_Symbol.js
/** Built-in value references. */
var Symbol$1 = root.Symbol;
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_getRawTag.js
/** Used for built-in method references. */
var objectProto$3 = Object.prototype;
/** Used to check objects for own properties. */
var hasOwnProperty$11 = objectProto$3.hasOwnProperty;
/**
* Used to resolve the
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
* of values.
*/
var nativeObjectToString$1 = objectProto$3.toString;
/** Built-in value references. */
var symToStringTag$1 = Symbol$1 ? Symbol$1.toStringTag : void 0;
/**
* A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
*
* @private
* @param {*} value The value to query.
* @returns {string} Returns the raw `toStringTag`.
*/
function getRawTag(value) {
var isOwn = hasOwnProperty$11.call(value, symToStringTag$1), tag = value[symToStringTag$1];
try {
value[symToStringTag$1] = void 0;
var unmasked = true;
} catch (e) {}
var result = nativeObjectToString$1.call(value);
if (unmasked) if (isOwn) value[symToStringTag$1] = tag;
else delete value[symToStringTag$1];
return result;
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_objectToString.js
/**
* Used to resolve the
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
* of values.
*/
var nativeObjectToString = Object.prototype.toString;
/**
* Converts `value` to a string using `Object.prototype.toString`.
*
* @private
* @param {*} value The value to convert.
* @returns {string} Returns the converted string.
*/
function objectToString(value) {
return nativeObjectToString.call(value);
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseGetTag.js
/** `Object#toString` result references. */
var nullTag = "[object Null]", undefinedTag = "[object Undefined]";
/** Built-in value references. */
var symToStringTag = Symbol$1 ? Symbol$1.toStringTag : void 0;
/**
* The base implementation of `getTag` without fallbacks for buggy environments.
*
* @private
* @param {*} value The value to query.
* @returns {string} Returns the `toStringTag`.
*/
function baseGetTag(value) {
if (value == null) return value === void 0 ? undefinedTag : nullTag;
return symToStringTag && symToStringTag in Object(value) ? getRawTag(value) : objectToString(value);
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isObjectLike.js
/**
* Checks if `value` is object-like. A value is object-like if it's not `null`
* and has a `typeof` result of "object".
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is object-like, else `false`.
* @example
*
* _.isObjectLike({});
* // => true
*
* _.isObjectLike([1, 2, 3]);
* // => true
*
* _.isObjectLike(_.noop);
* // => false
*
* _.isObjectLike(null);
* // => false
*/
function isObjectLike(value) {
return value != null && typeof value == "object";
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isSymbol.js
/** `Object#toString` result references. */
var symbolTag$2 = "[object Symbol]";
/**
* Checks if `value` is classified as a `Symbol` primitive or object.
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
* @example
*
* _.isSymbol(Symbol.iterator);
* // => true
*
* _.isSymbol('abc');
* // => false
*/
function isSymbol(value) {
return typeof value == "symbol" || isObjectLike(value) && baseGetTag(value) == symbolTag$2;
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_arrayMap.js
/**
* A specialized version of `_.map` for arrays without support for iteratee
* shorthands.
*
* @private
* @param {Array} [array] The array to iterate over.
* @param {Function} iteratee The function invoked per iteration.
* @returns {Array} Returns the new mapped array.
*/
function arrayMap(array, iteratee) {
var index = -1, length = array == null ? 0 : array.length, result = Array(length);
while (++index < length) result[index] = iteratee(array[index], index, array);
return result;
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isArray.js
/**
* Checks if `value` is classified as an `Array` object.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is an array, else `false`.
* @example
*
* _.isArray([1, 2, 3]);
* // => true
*
* _.isArray(document.body.children);
* // => false
*
* _.isArray('abc');
* // => false
*
* _.isArray(_.noop);
* // => false
*/
var isArray = Array.isArray;
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseToString.js
/** Used as references for various `Number` constants. */
var INFINITY$1 = Infinity;
/** Used to convert symbols to primitives and strings. */
var symbolProto$1 = Symbol$1 ? Symbol$1.prototype : void 0, symbolToString = symbolProto$1 ? symbolProto$1.toString : void 0;
/**
* The base implementation of `_.toString` which doesn't convert nullish
* values to empty strings.
*
* @private
* @param {*} value The value to process.
* @returns {string} Returns the string.
*/
function baseToString(value) {
if (typeof value == "string") return value;
if (isArray(value)) return arrayMap(value, baseToString) + "";
if (isSymbol(value)) return symbolToString ? symbolToString.call(value) : "";
var result = value + "";
return result == "0" && 1 / value == -INFINITY$1 ? "-0" : result;
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isObject.js
/**
* Checks if `value` is the
* [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
* of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
*
* @static
* @memberOf _
* @since 0.1.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is an object, else `false`.
* @example
*
* _.isObject({});
* // => true
*
* _.isObject([1, 2, 3]);
* // => true
*
* _.isObject(_.noop);
* // => true
*
* _.isObject(null);
* // => false
*/
function isObject$1(value) {
var type = typeof value;
return value != null && (type == "object" || type == "function");
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/identity.js
/**
* This method returns the first argument it receives.
*
* @static
* @since 0.1.0
* @memberOf _
* @category Util
* @param {*} value Any value.
* @returns {*} Returns `value`.
* @example
*
* var object = { 'a': 1 };
*
* console.log(_.identity(object) === object);
* // => true
*/
function identity(value) {
return value;
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isFunction.js
/** `Object#toString` result references. */
var asyncTag = "[object AsyncFunction]", funcTag$2 = "[object Function]", genTag$1 = "[object GeneratorFunction]", proxyTag = "[object Proxy]";
/**
* Checks if `value` is classified as a `Function` object.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a function, else `false`.
* @example
*
* _.isFunction(_);
* // => true
*
* _.isFunction(/abc/);
* // => false
*/
function isFunction(value) {
if (!isObject$1(value)) return false;
var tag = baseGetTag(value);
return tag == funcTag$2 || tag == genTag$1 || tag == asyncTag || tag == proxyTag;
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_coreJsData.js
/** Used to detect overreaching core-js shims. */
var coreJsData = root["__core-js_shared__"];
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_isMasked.js
/** Used to detect methods masquerading as native. */
var maskSrcKey = function() {
var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || "");
return uid ? "Symbol(src)_1." + uid : "";
}();
/**
* Checks if `func` has its source masked.
*
* @private
* @param {Function} func The function to check.
* @returns {boolean} Returns `true` if `func` is masked, else `false`.
*/
function isMasked(func) {
return !!maskSrcKey && maskSrcKey in func;
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_toSource.js
/** Used to resolve the decompiled source of functions. */
var funcToString$1 = Function.prototype.toString;
/**
* Converts `func` to its source code.
*
* @private
* @param {Function} func The function to convert.
* @returns {string} Returns the source code.
*/
function toSource(func) {
if (func != null) {
try {
return funcToString$1.call(func);
} catch (e) {}
try {
return func + "";
} catch (e) {}
}
return "";
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseIsNative.js
/**
* Used to match `RegExp`
* [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
*/
var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
/** Used to detect host constructors (Safari). */
var reIsHostCtor = /^\[object .+?Constructor\]$/;
/** Used for built-in method references. */
var funcProto = Function.prototype, objectProto$2 = Object.prototype;
/** Used to resolve the decompiled source of functions. */
var funcToString = funcProto.toString;
/** Used to check objects for own properties. */
var hasOwnProperty$10 = objectProto$2.hasOwnProperty;
/** Used to detect if a method is native. */
var reIsNative = RegExp("^" + funcToString.call(hasOwnProperty$10).replace(reRegExpChar, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$");
/**
* The base implementation of `_.isNative` without bad shim checks.
*
* @private
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a native function,
* else `false`.
*/
function baseIsNative(value) {
if (!isObject$1(value) || isMasked(value)) return false;
return (isFunction(value) ? reIsNative : reIsHostCtor).test(toSource(value));
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_getValue.js
/**
* Gets the value at `key` of `object`.
*
* @private
* @param {Object} [object] The object to query.
* @param {string} key The key of the property to get.
* @returns {*} Returns the property value.
*/
function getValue(object, key) {
return object == null ? void 0 : object[key];
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_getNative.js
/**
* Gets the native function at `key` of `object`.
*
* @private
* @param {Object} object The object to query.
* @param {string} key The key of the method to get.
* @returns {*} Returns the function if it's native, else `undefined`.
*/
function getNative(object, key) {
var value = getValue(object, key);
return baseIsNative(value) ? value : void 0;
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_WeakMap.js
var WeakMap$1 = getNative(root, "WeakMap");
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseCreate.js
/** Built-in value references. */
var objectCreate = Object.create;
/**
* The base implementation of `_.create` without support for assigning
* properties to the created object.
*
* @private
* @param {Object} proto The object to inherit from.
* @returns {Object} Returns the new object.
*/
var baseCreate = function() {
function object() {}
return function(proto) {
if (!isObject$1(proto)) return {};
if (objectCreate) return objectCreate(proto);
object.prototype = proto;
var result = new object();
object.prototype = void 0;
return result;
};
}();
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_apply.js
/**
* A faster alternative to `Function#apply`, this function invokes `func`
* with the `this` binding of `thisArg` and the arguments of `args`.
*
* @private
* @param {Function} func The function to invoke.
* @param {*} thisArg The `this` binding of `func`.
* @param {Array} args The arguments to invoke `func` with.
* @returns {*} Returns the result of `func`.
*/
function apply(func, thisArg, args) {
switch (args.length) {
case 0: return func.call(thisArg);
case 1: return func.call(thisArg, args[0]);
case 2: return func.call(thisArg, args[0], args[1]);
case 3: return func.call(thisArg, args[0], args[1], args[2]);
}
return func.apply(thisArg, args);
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/noop.js
/**
* This method returns `undefined`.
*
* @static
* @memberOf _
* @since 2.3.0
* @category Util
* @example
*
* _.times(2, _.noop);
* // => [undefined, undefined]
*/
function noop() {}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_copyArray.js
/**
* Copies the values of `source` to `array`.
*
* @private
* @param {Array} source The array to copy values from.
* @param {Array} [array=[]] The array to copy values to.
* @returns {Array} Returns `array`.
*/
function copyArray(source, array) {
var index = -1, length = source.length;
array || (array = Array(length));
while (++index < length) array[index] = source[index];
return array;
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_shortOut.js
/** Used to detect hot functions by number of calls within a span of milliseconds. */
var HOT_COUNT = 800, HOT_SPAN = 16;
var nativeNow = Date.now;
/**
* Creates a function that'll short out and invoke `identity` instead
* of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN`
* milliseconds.
*
* @private
* @param {Function} func The function to restrict.
* @returns {Function} Returns the new shortable function.
*/
function shortOut(func) {
var count = 0, lastCalled = 0;
return function() {
var stamp = nativeNow(), remaining = HOT_SPAN - (stamp - lastCalled);
lastCalled = stamp;
if (remaining > 0) {
if (++count >= HOT_COUNT) return arguments[0];
} else count = 0;
return func.apply(void 0, arguments);
};
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/constant.js
/**
* Creates a function that returns `value`.
*
* @static
* @memberOf _
* @since 2.4.0
* @category Util
* @param {*} value The value to return from the new function.
* @returns {Function} Returns the new constant function.
* @example
*
* var objects = _.times(2, _.constant({ 'a': 1 }));
*
* console.log(objects);
* // => [{ 'a': 1 }, { 'a': 1 }]
*
* console.log(objects[0] === objects[1]);
* // => true
*/
function constant(value) {
return function() {
return value;
};
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_defineProperty.js
var defineProperty = function() {
try {
var func = getNative(Object, "defineProperty");
func({}, "", {});
return func;
} catch (e) {}
}();
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseSetToString.js
/**
* The base implementation of `setToString` without support for hot loop shorting.
*
* @private
* @param {Function} func The function to modify.
* @param {Function} string The `toString` result.
* @returns {Function} Returns `func`.
*/
var baseSetToString = !defineProperty ? identity : function(func, string) {
return defineProperty(func, "toString", {
"configurable": true,
"enumerable": false,
"value": constant(string),
"writable": true
});
};
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_setToString.js
/**
* Sets the `toString` method of `func` to return `string`.
*
* @private
* @param {Function} func The function to modify.
* @param {Function} string The `toString` result.
* @returns {Function} Returns `func`.
*/
var setToString = shortOut(baseSetToString);
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_arrayEach.js
/**
* A specialized version of `_.forEach` for arrays without support for
* iteratee shorthands.
*
* @private
* @param {Array} [array] The array to iterate over.
* @param {Function} iteratee The function invoked per iteration.
* @returns {Array} Returns `array`.
*/
function arrayEach(array, iteratee) {
var index = -1, length = array == null ? 0 : array.length;
while (++index < length) if (iteratee(array[index], index, array) === false) break;
return array;
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseFindIndex.js
/**
* The base implementation of `_.findIndex` and `_.findLastIndex` without
* support for iteratee shorthands.
*
* @private
* @param {Array} array The array to inspect.
* @param {Function} predicate The function invoked per iteration.
* @param {number} fromIndex The index to search from.
* @param {boolean} [fromRight] Specify iterating from right to left.
* @returns {number} Returns the index of the matched value, else `-1`.
*/
function baseFindIndex(array, predicate, fromIndex, fromRight) {
var length = array.length, index = fromIndex + (fromRight ? 1 : -1);
while (fromRight ? index-- : ++index < length) if (predicate(array[index], index, array)) return index;
return -1;
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseIsNaN.js
/**
* The base implementation of `_.isNaN` without support for number objects.
*
* @private
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
*/
function baseIsNaN(value) {
return value !== value;
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_strictIndexOf.js
/**
* A specialized version of `_.indexOf` which performs strict equality
* comparisons of values, i.e. `===`.
*
* @private
* @param {Array} array The array to inspect.
* @param {*} value The value to search for.
* @param {number} fromIndex The index to search from.
* @returns {number} Returns the index of the matched value, else `-1`.
*/
function strictIndexOf(array, value, fromIndex) {
var index = fromIndex - 1, length = array.length;
while (++index < length) if (array[index] === value) return index;
return -1;
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseIndexOf.js
/**
* The base implementation of `_.indexOf` without `fromIndex` bounds checks.
*
* @private
* @param {Array} array The array to inspect.
* @param {*} value The value to search for.
* @param {number} fromIndex The index to search from.
* @returns {number} Returns the index of the matched value, else `-1`.
*/
function baseIndexOf(array, value, fromIndex) {
return value === value ? strictIndexOf(array, value, fromIndex) : baseFindIndex(array, baseIsNaN, fromIndex);
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_arrayIncludes.js
/**
* A specialized version of `_.includes` for arrays without support for
* specifying an index to search from.
*
* @private
* @param {Array} [array] The array to inspect.
* @param {*} target The value to search for.
* @returns {boolean} Returns `true` if `target` is found, else `false`.
*/
function arrayIncludes(array, value) {
return !!(array == null ? 0 : array.length) && baseIndexOf(array, value, 0) > -1;
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_isIndex.js
/** Used as references for various `Number` constants. */
var MAX_SAFE_INTEGER$1 = 9007199254740991;
/** Used to detect unsigned integer values. */
var reIsUint = /^(?:0|[1-9]\d*)$/;
/**
* Checks if `value` is a valid array-like index.
*
* @private
* @param {*} value The value to check.
* @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
* @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
*/
function isIndex(value, length) {
var type = typeof value;
length = length == null ? MAX_SAFE_INTEGER$1 : length;
return !!length && (type == "number" || type != "symbol" && reIsUint.test(value)) && value > -1 && value % 1 == 0 && value < length;
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseAssignValue.js
/**
* The base implementation of `assignValue` and `assignMergeValue` without
* value checks.
*
* @private
* @param {Object} object The object to modify.
* @param {string} key The key of the property to assign.
* @param {*} value The value to assign.
*/
function baseAssignValue(object, key, value) {
if (key == "__proto__" && defineProperty) defineProperty(object, key, {
"configurable": true,
"enumerable": true,
"value": value,
"writable": true
});
else object[key] = value;
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/eq.js
/**
* Performs a
* [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
* comparison between two values to determine if they are equivalent.
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to compare.
* @param {*} other The other value to compare.
* @returns {boolean} Returns `true` if the values are equivalent, else `false`.
* @example
*
* var object = { 'a': 1 };
* var other = { 'a': 1 };
*
* _.eq(object, object);
* // => true
*
* _.eq(object, other);
* // => false
*
* _.eq('a', 'a');
* // => true
*
* _.eq('a', Object('a'));
* // => false
*
* _.eq(NaN, NaN);
* // => true
*/
function eq(value, other) {
return value === other || value !== value && other !== other;
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_assignValue.js
/** Used to check objects for own properties. */
var hasOwnProperty$9 = Object.prototype.hasOwnProperty;
/**
* Assigns `value` to `key` of `object` if the existing value is not equivalent
* using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
* for equality comparisons.
*
* @private
* @param {Object} object The object to modify.
* @param {string} key The key of the property to assign.
* @param {*} value The value to assign.
*/
function assignValue(object, key, value) {
var objValue = object[key];
if (!(hasOwnProperty$9.call(object, key) && eq(objValue, value)) || value === void 0 && !(key in object)) baseAssignValue(object, key, value);
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_copyObject.js
/**
* Copies properties of `source` to `object`.
*
* @private
* @param {Object} source The object to copy properties from.
* @param {Array} props The property identifiers to copy.
* @param {Object} [object={}] The object to copy properties to.
* @param {Function} [customizer] The function to customize copied values.
* @returns {Object} Returns `object`.
*/
function copyObject(source, props, object, customizer) {
var isNew = !object;
object || (object = {});
var index = -1, length = props.length;
while (++index < length) {
var key = props[index];
var newValue = customizer ? customizer(object[key], source[key], key, object, source) : void 0;
if (newValue === void 0) newValue = source[key];
if (isNew) baseAssignValue(object, key, newValue);
else assignValue(object, key, newValue);
}
return object;
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_overRest.js
var nativeMax = Math.max;
/**
* A specialized version of `baseRest` which transforms the rest array.
*
* @private
* @param {Function} func The function to apply a rest parameter to.
* @param {number} [start=func.length-1] The start position of the rest parameter.
* @param {Function} transform The rest array transform.
* @returns {Function} Returns the new function.
*/
function overRest(func, start, transform) {
start = nativeMax(start === void 0 ? func.length - 1 : start, 0);
return function() {
var args = arguments, index = -1, length = nativeMax(args.length - start, 0), array = Array(length);
while (++index < length) array[index] = args[start + index];
index = -1;
var otherArgs = Array(start + 1);
while (++index < start) otherArgs[index] = args[index];
otherArgs[start] = transform(array);
return apply(func, this, otherArgs);
};
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseRest.js
/**
* The base implementation of `_.rest` which doesn't validate or coerce arguments.
*
* @private
* @param {Function} func The function to apply a rest parameter to.
* @param {number} [start=func.length-1] The start position of the rest parameter.
* @returns {Function} Returns the new function.
*/
function baseRest(func, start) {
return setToString(overRest(func, start, identity), func + "");
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isLength.js
/** Used as references for various `Number` constants. */
var MAX_SAFE_INTEGER = 9007199254740991;
/**
* Checks if `value` is a valid array-like length.
*
* **Note:** This method is loosely based on
* [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
* @example
*
* _.isLength(3);
* // => true
*
* _.isLength(Number.MIN_VALUE);
* // => false
*
* _.isLength(Infinity);
* // => false
*
* _.isLength('3');
* // => false
*/
function isLength(value) {
return typeof value == "number" && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isArrayLike.js
/**
* Checks if `value` is array-like. A value is considered array-like if it's
* not a function and has a `value.length` that's an integer greater than or
* equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is array-like, else `false`.
* @example
*
* _.isArrayLike([1, 2, 3]);
* // => true
*
* _.isArrayLike(document.body.children);
* // => true
*
* _.isArrayLike('abc');
* // => true
*
* _.isArrayLike(_.noop);
* // => false
*/
function isArrayLike(value) {
return value != null && isLength(value.length) && !isFunction(value);
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_isPrototype.js
/** Used for built-in method references. */
var objectProto$1 = Object.prototype;
/**
* Checks if `value` is likely a prototype object.
*
* @private
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
*/
function isPrototype(value) {
var Ctor = value && value.constructor;
return value === (typeof Ctor == "function" && Ctor.prototype || objectProto$1);
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseTimes.js
/**
* The base implementation of `_.times` without support for iteratee shorthands
* or max array length checks.
*
* @private
* @param {number} n The number of times to invoke `iteratee`.
* @param {Function} iteratee The function invoked per iteration.
* @returns {Array} Returns the array of results.
*/
function baseTimes(n, iteratee) {
var index = -1, result = Array(n);
while (++index < n) result[index] = iteratee(index);
return result;
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseIsArguments.js
/** `Object#toString` result references. */
var argsTag$2 = "[object Arguments]";
/**
* The base implementation of `_.isArguments`.
*
* @private
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is an `arguments` object,
*/
function baseIsArguments(value) {
return isObjectLike(value) && baseGetTag(value) == argsTag$2;
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isArguments.js
/** Used for built-in method references. */
var objectProto = Object.prototype;
/** Used to check objects for own properties. */
var hasOwnProperty$8 = objectProto.hasOwnProperty;
/** Built-in value references. */
var propertyIsEnumerable$1 = objectProto.propertyIsEnumerable;
/**
* Checks if `value` is likely an `arguments` object.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is an `arguments` object,
* else `false`.
* @example
*
* _.isArguments(function() { return arguments; }());
* // => true
*
* _.isArguments([1, 2, 3]);
* // => false
*/
var isArguments = baseIsArguments(function() {
return arguments;
}()) ? baseIsArguments : function(value) {
return isObjectLike(value) && hasOwnProperty$8.call(value, "callee") && !propertyIsEnumerable$1.call(value, "callee");
};
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/stubFalse.js
/**
* This method returns `false`.
*
* @static
* @memberOf _
* @since 4.13.0
* @category Util
* @returns {boolean} Returns `false`.
* @example
*
* _.times(2, _.stubFalse);
* // => [false, false]
*/
function stubFalse() {
return false;
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isBuffer.js
/** Detect free variable `exports`. */
var freeExports$2 = typeof exports == "object" && exports && !exports.nodeType && exports;
/** Detect free variable `module`. */
var freeModule$2 = freeExports$2 && typeof module == "object" && module && !module.nodeType && module;
/** Built-in value references. */
var Buffer$2 = freeModule$2 && freeModule$2.exports === freeExports$2 ? root.Buffer : void 0;
/**
* Checks if `value` is a buffer.
*
* @static
* @memberOf _
* @since 4.3.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
* @example
*
* _.isBuffer(new Buffer(2));
* // => true
*
* _.isBuffer(new Uint8Array(2));
* // => false
*/
var isBuffer = (Buffer$2 ? Buffer$2.isBuffer : void 0) || stubFalse;
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseIsTypedArray.js
/** `Object#toString` result references. */
var argsTag$1 = "[object Arguments]", arrayTag$1 = "[object Array]", boolTag$2 = "[object Boolean]", dateTag$2 = "[object Date]", errorTag$1 = "[object Error]", funcTag$1 = "[object Function]", mapTag$5 = "[object Map]", numberTag$2 = "[object Number]", objectTag$2 = "[object Object]", regexpTag$2 = "[object RegExp]", setTag$5 = "[object Set]", stringTag$2 = "[object String]", weakMapTag$2 = "[object WeakMap]";
var arrayBufferTag$2 = "[object ArrayBuffer]", dataViewTag$3 = "[object DataView]", float32Tag$2 = "[object Float32Array]", float64Tag$2 = "[object Float64Array]", int8Tag$2 = "[object Int8Array]", int16Tag$2 = "[object Int16Array]", int32Tag$2 = "[object Int32Array]", uint8Tag$2 = "[object Uint8Array]", uint8ClampedTag$2 = "[object Uint8ClampedArray]", uint16Tag$2 = "[object Uint16Array]", uint32Tag$2 = "[object Uint32Array]";
/** Used to identify `toStringTag` values of typed arrays. */
var typedArrayTags = {};
typedArrayTags[float32Tag$2] = typedArrayTags[float64Tag$2] = typedArrayTags[int8Tag$2] = typedArrayTags[int16Tag$2] = typedArrayTags[int32Tag$2] = typedArrayTags[uint8Tag$2] = typedArrayTags[uint8ClampedTag$2] = typedArrayTags[uint16Tag$2] = typedArrayTags[uint32Tag$2] = true;
typedArrayTags[argsTag$1] = typedArrayTags[arrayTag$1] = typedArrayTags[arrayBufferTag$2] = typedArrayTags[boolTag$2] = typedArrayTags[dataViewTag$3] = typedArrayTags[dateTag$2] = typedArrayTags[errorTag$1] = typedArrayTags[funcTag$1] = typedArrayTags[mapTag$5] = typedArrayTags[numberTag$2] = typedArrayTags[objectTag$2] = typedArrayTags[regexpTag$2] = typedArrayTags[setTag$5] = typedArrayTags[stringTag$2] = typedArrayTags[weakMapTag$2] = false;
/**
* The base implementation of `_.isTypedArray` without Node.js optimizations.
*
* @private
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
*/
function baseIsTypedArray(value) {
return isObjectLike(value) && isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseUnary.js
/**
* The base implementation of `_.unary` without support for storing metadata.
*
* @private
* @param {Function} func The function to cap arguments for.
* @returns {Function} Returns the new capped function.
*/
function baseUnary(func) {
return function(value) {
return func(value);
};
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_nodeUtil.js
/** Detect free variable `exports`. */
var freeExports$1 = typeof exports == "object" && exports && !exports.nodeType && exports;
/** Detect free variable `module`. */
var freeModule$1 = freeExports$1 && typeof module == "object" && module && !module.nodeType && module;
/** Detect free variable `process` from Node.js. */
var freeProcess = freeModule$1 && freeModule$1.exports === freeExports$1 && freeGlobal.process;
/** Used to access faster Node.js helpers. */
var nodeUtil = function() {
try {
var types = freeModule$1 && freeModule$1.require && freeModule$1.require("util").types;
if (types) return types;
return freeProcess && freeProcess.binding && freeProcess.binding("util");
} catch (e) {}
}();
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isTypedArray.js
var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
/**
* Checks if `value` is classified as a typed array.
*
* @static
* @memberOf _
* @since 3.0.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
* @example
*
* _.isTypedArray(new Uint8Array);
* // => true
*
* _.isTypedArray([]);
* // => false
*/
var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_arrayLikeKeys.js
/** Used to check objects for own properties. */
var hasOwnProperty$7 = Object.prototype.hasOwnProperty;
/**
* Creates an array of the enumerable property names of the array-like `value`.
*
* @private
* @param {*} value The value to query.
* @param {boolean} inherited Specify returning inherited property names.
* @returns {Array} Returns the array of property names.
*/
function arrayLikeKeys(value, inherited) {
var isArr = isArray(value), isArg = !isArr && isArguments(value), isBuff = !isArr && !isArg && isBuffer(value), isType = !isArr && !isArg && !isBuff && isTypedArray(value), skipIndexes = isArr || isArg || isBuff || isType, result = skipIndexes ? baseTimes(value.length, String) : [], length = result.length;
for (var key in value) if ((inherited || hasOwnProperty$7.call(value, key)) && !(skipIndexes && (key == "length" || isBuff && (key == "offset" || key == "parent") || isType && (key == "buffer" || key == "byteLength" || key == "byteOffset") || isIndex(key, length)))) result.push(key);
return result;
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_overArg.js
/**
* Creates a unary function that invokes `func` with its argument transformed.
*
* @private
* @param {Function} func The function to wrap.
* @param {Function} transform The argument transform.
* @returns {Function} Returns the new function.
*/
function overArg(func, transform) {
return function(arg) {
return func(transform(arg));
};
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_nativeKeys.js
var nativeKeys = overArg(Object.keys, Object);
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseKeys.js
/** Used to check objects for own properties. */
var hasOwnProperty$6 = Object.prototype.hasOwnProperty;
/**
* The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
*
* @private
* @param {Object} object The object to query.
* @returns {Array} Returns the array of property names.
*/
function baseKeys(object) {
if (!isPrototype(object)) return nativeKeys(object);
var result = [];
for (var key in Object(object)) if (hasOwnProperty$6.call(object, key) && key != "constructor") result.push(key);
return result;
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/keys.js
/**
* Creates an array of the own enumerable property names of `object`.
*
* **Note:** Non-object values are coerced to objects. See the
* [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
* for more details.
*
* @static
* @since 0.1.0
* @memberOf _
* @category Object
* @param {Object} object The object to query.
* @returns {Array} Returns the array of property names.
* @example
*
* function Foo() {
* this.a = 1;
* this.b = 2;
* }
*
* Foo.prototype.c = 3;
*
* _.keys(new Foo);
* // => ['a', 'b'] (iteration order is not guaranteed)
*
* _.keys('hi');
* // => ['0', '1']
*/
function keys(object) {
return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_nativeKeysIn.js
/**
* This function is like
* [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
* except that it includes inherited enumerable properties.
*
* @private
* @param {Object} object The object to query.
* @returns {Array} Returns the array of property names.
*/
function nativeKeysIn(object) {
var result = [];
if (object != null) for (var key in Object(object)) result.push(key);
return result;
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseKeysIn.js
/** Used to check objects for own properties. */
var hasOwnProperty$5 = Object.prototype.hasOwnProperty;
/**
* The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense.
*
* @private
* @param {Object} object The object to query.
* @returns {Array} Returns the array of property names.
*/
function baseKeysIn(object) {
if (!isObject$1(object)) return nativeKeysIn(object);
var isProto = isPrototype(object), result = [];
for (var key in object) if (!(key == "constructor" && (isProto || !hasOwnProperty$5.call(object, key)))) result.push(key);
return result;
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/keysIn.js
/**
* Creates an array of the own and inherited enumerable property names of `object`.
*
* **Note:** Non-object values are coerced to objects.
*
* @static
* @memberOf _
* @since 3.0.0
* @category Object
* @param {Object} object The object to query.
* @returns {Array} Returns the array of property names.
* @example
*
* function Foo() {
* this.a = 1;
* this.b = 2;
* }
*
* Foo.prototype.c = 3;
*
* _.keysIn(new Foo);
* // => ['a', 'b', 'c'] (iteration order is not guaranteed)
*/
function keysIn(object) {
return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object);
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_isKey.js
/** Used to match property names within property paths. */
var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, reIsPlainProp = /^\w*$/;
/**
* Checks if `value` is a property name and not a property path.
*
* @private
* @param {*} value The value to check.
* @param {Object} [object] The object to query keys on.
* @returns {boolean} Returns `true` if `value` is a property name, else `false`.
*/
function isKey(value, object) {
if (isArray(value)) return false;
var type = typeof value;
if (type == "number" || type == "symbol" || type == "boolean" || value == null || isSymbol(value)) return true;
return reIsPlainProp.test(value) || !reIsDeepProp.test(value) || object != null && value in Object(object);
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_nativeCreate.js
var nativeCreate = getNative(Object, "create");
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_hashClear.js
/**
* Removes all key-value entries from the hash.
*
* @private
* @name clear
* @memberOf Hash
*/
function hashClear() {
this.__data__ = nativeCreate ? nativeCreate(null) : {};
this.size = 0;
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_hashDelete.js
/**
* Removes `key` and its value from the hash.
*
* @private
* @name delete
* @memberOf Hash
* @param {Object} hash The hash to modify.
* @param {string} key The key of the value to remove.
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
*/
function hashDelete(key) {
var result = this.has(key) && delete this.__data__[key];
this.size -= result ? 1 : 0;
return result;
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_hashGet.js
/** Used to stand-in for `undefined` hash values. */
var HASH_UNDEFINED$2 = "__lodash_hash_undefined__";
/** Used to check objects for own properties. */
var hasOwnProperty$4 = Object.prototype.hasOwnProperty;
/**
* Gets the hash value for `key`.
*
* @private
* @name get
* @memberOf Hash
* @param {string} key The key of the value to get.
* @returns {*} Returns the entry value.
*/
function hashGet(key) {
var data = this.__data__;
if (nativeCreate) {
var result = data[key];
return result === HASH_UNDEFINED$2 ? void 0 : result;
}
return hasOwnProperty$4.call(data, key) ? data[key] : void 0;
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_hashHas.js
/** Used to check objects for own properties. */
var hasOwnProperty$3 = Object.prototype.hasOwnProperty;
/**
* Checks if a hash value for `key` exists.
*
* @private
* @name has
* @memberOf Hash
* @param {string} key The key of the entry to check.
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
*/
function hashHas(key) {
var data = this.__data__;
return nativeCreate ? data[key] !== void 0 : hasOwnProperty$3.call(data, key);
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_hashSet.js
/** Used to stand-in for `undefined` hash values. */
var HASH_UNDEFINED$1 = "__lodash_hash_undefined__";
/**
* Sets the hash `key` to `value`.
*
* @private
* @name set
* @memberOf Hash
* @param {string} key The key of the value to set.
* @param {*} value The value to set.
* @returns {Object} Returns the hash instance.
*/
function hashSet(key, value) {
var data = this.__data__;
this.size += this.has(key) ? 0 : 1;
data[key] = nativeCreate && value === void 0 ? HASH_UNDEFINED$1 : value;
return this;
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_Hash.js
/**
* Creates a hash object.
*
* @private
* @constructor
* @param {Array} [entries] The key-value pairs to cache.
*/
function Hash(entries) {
var index = -1, length = entries == null ? 0 : entries.length;
this.clear();
while (++index < length) {
var entry = entries[index];
this.set(entry[0], entry[1]);
}
}
Hash.prototype.clear = hashClear;
Hash.prototype["delete"] = hashDelete;
Hash.prototype.get = hashGet;
Hash.prototype.has = hashHas;
Hash.prototype.set = hashSet;
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_listCacheClear.js
/**
* Removes all key-value entries from the list cache.
*
* @private
* @name clear
* @memberOf ListCache
*/
function listCacheClear() {
this.__data__ = [];
this.size = 0;
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_assocIndexOf.js
/**
* Gets the index at which the `key` is found in `array` of key-value pairs.
*
* @private
* @param {Array} array The array to inspect.
* @param {*} key The key to search for.
* @returns {number} Returns the index of the matched value, else `-1`.
*/
function assocIndexOf(array, key) {
var length = array.length;
while (length--) if (eq(array[length][0], key)) return length;
return -1;
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_listCacheDelete.js
/** Built-in value references. */
var splice = Array.prototype.splice;
/**
* Removes `key` and its value from the list cache.
*
* @private
* @name delete
* @memberOf ListCache
* @param {string} key The key of the value to remove.
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
*/
function listCacheDelete(key) {
var data = this.__data__, index = assocIndexOf(data, key);
if (index < 0) return false;
if (index == data.length - 1) data.pop();
else splice.call(data, index, 1);
--this.size;
return true;
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_listCacheGet.js
/**
* Gets the list cache value for `key`.
*
* @private
* @name get
* @memberOf ListCache
* @param {string} key The key of the value to get.
* @returns {*} Returns the entry value.
*/
function listCacheGet(key) {
var data = this.__data__, index = assocIndexOf(data, key);
return index < 0 ? void 0 : data[index][1];
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_listCacheHas.js
/**
* Checks if a list cache value for `key` exists.
*
* @private
* @name has
* @memberOf ListCache
* @param {string} key The key of the entry to check.
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
*/
function listCacheHas(key) {
return assocIndexOf(this.__data__, key) > -1;
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_listCacheSet.js
/**
* Sets the list cache `key` to `value`.
*
* @private
* @name set
* @memberOf ListCache
* @param {string} key The key of the value to set.
* @param {*} value The value to set.
* @returns {Object} Returns the list cache instance.
*/
function listCacheSet(key, value) {
var data = this.__data__, index = assocIndexOf(data, key);
if (index < 0) {
++this.size;
data.push([key, value]);
} else data[index][1] = value;
return this;
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_ListCache.js
/**
* Creates an list cache object.
*
* @private
* @constructor
* @param {Array} [entries] The key-value pairs to cache.
*/
function ListCache(entries) {
var index = -1, length = entries == null ? 0 : entries.length;
this.clear();
while (++index < length) {
var entry = entries[index];
this.set(entry[0], entry[1]);
}
}
ListCache.prototype.clear = listCacheClear;
ListCache.prototype["delete"] = listCacheDelete;
ListCache.prototype.get = listCacheGet;
ListCache.prototype.has = listCacheHas;
ListCache.prototype.set = listCacheSet;
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_Map.js
var Map$1 = getNative(root, "Map");
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_mapCacheClear.js
/**
* Removes all key-value entries from the map.
*
* @private
* @name clear
* @memberOf MapCache
*/
function mapCacheClear() {
this.size = 0;
this.__data__ = {
"hash": new Hash(),
"map": new (Map$1 || ListCache)(),
"string": new Hash()
};
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_isKeyable.js
/**
* Checks if `value` is suitable for use as unique object key.
*
* @private
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is suitable, else `false`.
*/
function isKeyable(value) {
var type = typeof value;
return type == "string" || type == "number" || type == "symbol" || type == "boolean" ? value !== "__proto__" : value === null;
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_getMapData.js
/**
* Gets the data for `map`.
*
* @private
* @param {Object} map The map to query.
* @param {string} key The reference key.
* @returns {*} Returns the map data.
*/
function getMapData(map, key) {
var data = map.__data__;
return isKeyable(key) ? data[typeof key == "string" ? "string" : "hash"] : data.map;
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_mapCacheDelete.js
/**
* Removes `key` and its value from the map.
*
* @private
* @name delete
* @memberOf MapCache
* @param {string} key The key of the value to remove.
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
*/
function mapCacheDelete(key) {
var result = getMapData(this, key)["delete"](key);
this.size -= result ? 1 : 0;
return result;
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_mapCacheGet.js
/**
* Gets the map value for `key`.
*
* @private
* @name get
* @memberOf MapCache
* @param {string} key The key of the value to get.
* @returns {*} Returns the entry value.
*/
function mapCacheGet(key) {
return getMapData(this, key).get(key);
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_mapCacheHas.js
/**
* Checks if a map value for `key` exists.
*
* @private
* @name has
* @memberOf MapCache
* @param {string} key The key of the entry to check.
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
*/
function mapCacheHas(key) {
return getMapData(this, key).has(key);
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_mapCacheSet.js
/**
* Sets the map `key` to `value`.
*
* @private
* @name set
* @memberOf MapCache
* @param {string} key The key of the value to set.
* @param {*} value The value to set.
* @returns {Object} Returns the map cache instance.
*/
function mapCacheSet(key, value) {
var data = getMapData(this, key), size = data.size;
data.set(key, value);
this.size += data.size == size ? 0 : 1;
return this;
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_MapCache.js
/**
* Creates a map cache object to store key-value pairs.
*
* @private
* @constructor
* @param {Array} [entries] The key-value pairs to cache.
*/
function MapCache(entries) {
var index = -1, length = entries == null ? 0 : entries.length;
this.clear();
while (++index < length) {
var entry = entries[index];
this.set(entry[0], entry[1]);
}
}
MapCache.prototype.clear = mapCacheClear;
MapCache.prototype["delete"] = mapCacheDelete;
MapCache.prototype.get = mapCacheGet;
MapCache.prototype.has = mapCacheHas;
MapCache.prototype.set = mapCacheSet;
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/memoize.js
/** Error message constants. */
var FUNC_ERROR_TEXT = "Expected a function";
/**
* Creates a function that memoizes the result of `func`. If `resolver` is
* provided, it determines the cache key for storing the result based on the
* arguments provided to the memoized function. By default, the first argument
* provided to the memoized function is used as the map cache key. The `func`
* is invoked with the `this` binding of the memoized function.
*
* **Note:** The cache is exposed as the `cache` property on the memoized
* function. Its creation may be customized by replacing the `_.memoize.Cache`
* constructor with one whose instances implement the
* [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
* method interface of `clear`, `delete`, `get`, `has`, and `set`.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Function
* @param {Function} func The function to have its output memoized.
* @param {Function} [resolver] The function to resolve the cache key.
* @returns {Function} Returns the new memoized function.
* @example
*
* var object = { 'a': 1, 'b': 2 };
* var other = { 'c': 3, 'd': 4 };
*
* var values = _.memoize(_.values);
* values(object);
* // => [1, 2]
*
* values(other);
* // => [3, 4]
*
* object.a = 2;
* values(object);
* // => [1, 2]
*
* // Modify the result cache.
* values.cache.set(object, ['a', 'b']);
* values(object);
* // => ['a', 'b']
*
* // Replace `_.memoize.Cache`.
* _.memoize.Cache = WeakMap;
*/
function memoize(func, resolver) {
if (typeof func != "function" || resolver != null && typeof resolver != "function") throw new TypeError(FUNC_ERROR_TEXT);
var memoized = function() {
var args = arguments, key = resolver ? resolver.apply(this, args) : args[0], cache = memoized.cache;
if (cache.has(key)) return cache.get(key);
var result = func.apply(this, args);
memoized.cache = cache.set(key, result) || cache;
return result;
};
memoized.cache = new (memoize.Cache || MapCache)();
return memoized;
}
memoize.Cache = MapCache;
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_memoizeCapped.js
/** Used as the maximum memoize cache size. */
var MAX_MEMOIZE_SIZE = 500;
/**
* A specialized version of `_.memoize` which clears the memoized function's
* cache when it exceeds `MAX_MEMOIZE_SIZE`.
*
* @private
* @param {Function} func The function to have its output memoized.
* @returns {Function} Returns the new memoized function.
*/
function memoizeCapped(func) {
var result = memoize(func, function(key) {
if (cache.size === MAX_MEMOIZE_SIZE) cache.clear();
return key;
});
var cache = result.cache;
return result;
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_stringToPath.js
/** Used to match property names within property paths. */
var rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
/** Used to match backslashes in property paths. */
var reEscapeChar = /\\(\\)?/g;
/**
* Converts `string` to a property path array.
*
* @private
* @param {string} string The string to convert.
* @returns {Array} Returns the property path array.
*/
var stringToPath = memoizeCapped(function(string) {
var result = [];
if (string.charCodeAt(0) === 46) result.push("");
string.replace(rePropName, function(match, number, quote, subString) {
result.push(quote ? subString.replace(reEscapeChar, "$1") : number || match);
});
return result;
});
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/toString.js
/**
* Converts `value` to a string. An empty string is returned for `null`
* and `undefined` values. The sign of `-0` is preserved.
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to convert.
* @returns {string} Returns the converted string.
* @example
*
* _.toString(null);
* // => ''
*
* _.toString(-0);
* // => '-0'
*
* _.toString([1, 2, 3]);
* // => '1,2,3'
*/
function toString(value) {
return value == null ? "" : baseToString(value);
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_castPath.js
/**
* Casts `value` to a path array if it's not one.
*
* @private
* @param {*} value The value to inspect.
* @param {Object} [object] The object to query keys on.
* @returns {Array} Returns the cast property path array.
*/
function castPath(value, object) {
if (isArray(value)) return value;
return isKey(value, object) ? [value] : stringToPath(toString(value));
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_toKey.js
/** Used as references for various `Number` constants. */
var INFINITY = Infinity;
/**
* Converts `value` to a string key if it's not a string or symbol.
*
* @private
* @param {*} value The value to inspect.
* @returns {string|symbol} Returns the key.
*/
function toKey(value) {
if (typeof value == "string" || isSymbol(value)) return value;
var result = value + "";
return result == "0" && 1 / value == -INFINITY ? "-0" : result;
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_arrayPush.js
/**
* Appends the elements of `values` to `array`.
*
* @private
* @param {Array} array The array to modify.
* @param {Array} values The values to append.
* @returns {Array} Returns `array`.
*/
function arrayPush(array, values) {
var index = -1, length = values.length, offset = array.length;
while (++index < length) array[offset + index] = values[index];
return array;
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_isFlattenable.js
/** Built-in value references. */
var spreadableSymbol = Symbol$1 ? Symbol$1.isConcatSpreadable : void 0;
/**
* Checks if `value` is a flattenable `arguments` object or array.
*
* @private
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is flattenable, else `false`.
*/
function isFlattenable(value) {
return isArray(value) || isArguments(value) || !!(spreadableSymbol && value && value[spreadableSymbol]);
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseFlatten.js
/**
* The base implementation of `_.flatten` with support for restricting flattening.
*
* @private
* @param {Array} array The array to flatten.
* @param {number} depth The maximum recursion depth.
* @param {boolean} [predicate=isFlattenable] The function invoked per iteration.
* @param {boolean} [isStrict] Restrict to values that pass `predicate` checks.
* @param {Array} [result=[]] The initial result value.
* @returns {Array} Returns the new flattened array.
*/
function baseFlatten(array, depth, predicate, isStrict, result) {
var index = -1, length = array.length;
predicate || (predicate = isFlattenable);
result || (result = []);
while (++index < length) {
var value = array[index];
if (depth > 0 && predicate(value)) if (depth > 1) baseFlatten(value, depth - 1, predicate, isStrict, result);
else arrayPush(result, value);
else if (!isStrict) result[result.length] = value;
}
return result;
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_getPrototype.js
/** Built-in value references. */
var getPrototype = overArg(Object.getPrototypeOf, Object);
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_stackClear.js
/**
* Removes all key-value entries from the stack.
*
* @private
* @name clear
* @memberOf Stack
*/
function stackClear() {
this.__data__ = new ListCache();
this.size = 0;
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_stackDelete.js
/**
* Removes `key` and its value from the stack.
*
* @private
* @name delete
* @memberOf Stack
* @param {string} key The key of the value to remove.
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
*/
function stackDelete(key) {
var data = this.__data__, result = data["delete"](key);
this.size = data.size;
return result;
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_stackGet.js
/**
* Gets the stack value for `key`.
*
* @private
* @name get
* @memberOf Stack
* @param {string} key The key of the value to get.
* @returns {*} Returns the entry value.
*/
function stackGet(key) {
return this.__data__.get(key);
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_stackHas.js
/**
* Checks if a stack value for `key` exists.
*
* @private
* @name has
* @memberOf Stack
* @param {string} key The key of the entry to check.
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
*/
function stackHas(key) {
return this.__data__.has(key);
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_stackSet.js
/** Used as the size to enable large array optimizations. */
var LARGE_ARRAY_SIZE$1 = 200;
/**
* Sets the stack `key` to `value`.
*
* @private
* @name set
* @memberOf Stack
* @param {string} key The key of the value to set.
* @param {*} value The value to set.
* @returns {Object} Returns the stack cache instance.
*/
function stackSet(key, value) {
var data = this.__data__;
if (data instanceof ListCache) {
var pairs = data.__data__;
if (!Map$1 || pairs.length < LARGE_ARRAY_SIZE$1 - 1) {
pairs.push([key, value]);
this.size = ++data.size;
return this;
}
data = this.__data__ = new MapCache(pairs);
}
data.set(key, value);
this.size = data.size;
return this;
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_Stack.js
/**
* Creates a stack cache object to store key-value pairs.
*
* @private
* @constructor
* @param {Array} [entries] The key-value pairs to cache.
*/
function Stack(entries) {
this.size = (this.__data__ = new ListCache(entries)).size;
}
Stack.prototype.clear = stackClear;
Stack.prototype["delete"] = stackDelete;
Stack.prototype.get = stackGet;
Stack.prototype.has = stackHas;
Stack.prototype.set = stackSet;
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseAssign.js
/**
* The base implementation of `_.assign` without support for multiple sources
* or `customizer` functions.
*
* @private
* @param {Object} object The destination object.
* @param {Object} source The source object.
* @returns {Object} Returns `object`.
*/
function baseAssign(object, source) {
return object && copyObject(source, keys(source), object);
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseAssignIn.js
/**
* The base implementation of `_.assignIn` without support for multiple sources
* or `customizer` functions.
*
* @private
* @param {Object} object The destination object.
* @param {Object} source The source object.
* @returns {Object} Returns `object`.
*/
function baseAssignIn(object, source) {
return object && copyObject(source, keysIn(source), object);
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_cloneBuffer.js
/** Detect free variable `exports`. */
var freeExports = typeof exports == "object" && exports && !exports.nodeType && exports;
/** Detect free variable `module`. */
var freeModule = freeExports && typeof module == "object" && module && !module.nodeType && module;
/** Built-in value references. */
var Buffer$1 = freeModule && freeModule.exports === freeExports ? root.Buffer : void 0, allocUnsafe = Buffer$1 ? Buffer$1.allocUnsafe : void 0;
/**
* Creates a clone of `buffer`.
*
* @private
* @param {Buffer} buffer The buffer to clone.
* @param {boolean} [isDeep] Specify a deep clone.
* @returns {Buffer} Returns the cloned buffer.
*/
function cloneBuffer(buffer, isDeep) {
if (isDeep) return buffer.slice();
var length = buffer.length, result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);
buffer.copy(result);
return result;
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_arrayFilter.js
/**
* A specialized version of `_.filter` for arrays without support for
* iteratee shorthands.
*
* @private
* @param {Array} [array] The array to iterate over.
* @param {Function} predicate The function invoked per iteration.
* @returns {Array} Returns the new filtered array.
*/
function arrayFilter(array, predicate) {
var index = -1, length = array == null ? 0 : array.length, resIndex = 0, result = [];
while (++index < length) {
var value = array[index];
if (predicate(value, index, array)) result[resIndex++] = value;
}
return result;
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/stubArray.js
/**
* This method returns a new empty array.
*
* @static
* @memberOf _
* @since 4.13.0
* @category Util
* @returns {Array} Returns the new empty array.
* @example
*
* var arrays = _.times(2, _.stubArray);
*
* console.log(arrays);
* // => [[], []]
*
* console.log(arrays[0] === arrays[1]);
* // => false
*/
function stubArray() {
return [];
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_getSymbols.js
/** Built-in value references. */
var propertyIsEnumerable = Object.prototype.propertyIsEnumerable;
var nativeGetSymbols = Object.getOwnPropertySymbols;
/**
* Creates an array of the own enumerable symbols of `object`.
*
* @private
* @param {Object} object The object to query.
* @returns {Array} Returns the array of symbols.
*/
var getSymbols = !nativeGetSymbols ? stubArray : function(object) {
if (object == null) return [];
object = Object(object);
return arrayFilter(nativeGetSymbols(object), function(symbol) {
return propertyIsEnumerable.call(object, symbol);
});
};
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_copySymbols.js
/**
* Copies own symbols of `source` to `object`.
*
* @private
* @param {Object} source The object to copy symbols from.
* @param {Object} [object={}] The object to copy symbols to.
* @returns {Object} Returns `object`.
*/
function copySymbols(source, object) {
return copyObject(source, getSymbols(source), object);
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_getSymbolsIn.js
/**
* Creates an array of the own and inherited enumerable symbols of `object`.
*
* @private
* @param {Object} object The object to query.
* @returns {Array} Returns the array of symbols.
*/
var getSymbolsIn = !Object.getOwnPropertySymbols ? stubArray : function(object) {
var result = [];
while (object) {
arrayPush(result, getSymbols(object));
object = getPrototype(object);
}
return result;
};
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_copySymbolsIn.js
/**
* Copies own and inherited symbols of `source` to `object`.
*
* @private
* @param {Object} source The object to copy symbols from.
* @param {Object} [object={}] The object to copy symbols to.
* @returns {Object} Returns `object`.
*/
function copySymbolsIn(source, object) {
return copyObject(source, getSymbolsIn(source), object);
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseGetAllKeys.js
/**
* The base implementation of `getAllKeys` and `getAllKeysIn` which uses
* `keysFunc` and `symbolsFunc` to get the enumerable property names and
* symbols of `object`.
*
* @private
* @param {Object} object The object to query.
* @param {Function} keysFunc The function to get the keys of `object`.
* @param {Function} symbolsFunc The function to get the symbols of `object`.
* @returns {Array} Returns the array of property names and symbols.
*/
function baseGetAllKeys(object, keysFunc, symbolsFunc) {
var result = keysFunc(object);
return isArray(object) ? result : arrayPush(result, symbolsFunc(object));
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_getAllKeys.js
/**
* Creates an array of own enumerable property names and symbols of `object`.
*
* @private
* @param {Object} object The object to query.
* @returns {Array} Returns the array of property names and symbols.
*/
function getAllKeys(object) {
return baseGetAllKeys(object, keys, getSymbols);
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_getAllKeysIn.js
/**
* Creates an array of own and inherited enumerable property names and
* symbols of `object`.
*
* @private
* @param {Object} object The object to query.
* @returns {Array} Returns the array of property names and symbols.
*/
function getAllKeysIn(object) {
return baseGetAllKeys(object, keysIn, getSymbolsIn);
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_DataView.js
var DataView = getNative(root, "DataView");
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_Promise.js
var Promise$1 = getNative(root, "Promise");
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_Set.js
var Set$1 = getNative(root, "Set");
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_getTag.js
/** `Object#toString` result references. */
var mapTag$4 = "[object Map]", objectTag$1 = "[object Object]", promiseTag = "[object Promise]", setTag$4 = "[object Set]", weakMapTag$1 = "[object WeakMap]";
var dataViewTag$2 = "[object DataView]";
/** Used to detect maps, sets, and weakmaps. */
var dataViewCtorString = toSource(DataView), mapCtorString = toSource(Map$1), promiseCtorString = toSource(Promise$1), setCtorString = toSource(Set$1), weakMapCtorString = toSource(WeakMap$1);
/**
* Gets the `toStringTag` of `value`.
*
* @private
* @param {*} value The value to query.
* @returns {string} Returns the `toStringTag`.
*/
var getTag = baseGetTag;
if (DataView && getTag(new DataView(/* @__PURE__ */ new ArrayBuffer(1))) != dataViewTag$2 || Map$1 && getTag(new Map$1()) != mapTag$4 || Promise$1 && getTag(Promise$1.resolve()) != promiseTag || Set$1 && getTag(new Set$1()) != setTag$4 || WeakMap$1 && getTag(new WeakMap$1()) != weakMapTag$1) getTag = function(value) {
var result = baseGetTag(value), Ctor = result == objectTag$1 ? value.constructor : void 0, ctorString = Ctor ? toSource(Ctor) : "";
if (ctorString) switch (ctorString) {
case dataViewCtorString: return dataViewTag$2;
case mapCtorString: return mapTag$4;
case promiseCtorString: return promiseTag;
case setCtorString: return setTag$4;
case weakMapCtorString: return weakMapTag$1;
}
return result;
};
var _getTag_default = getTag;
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_initCloneArray.js
/** Used to check objects for own properties. */
var hasOwnProperty$2 = Object.prototype.hasOwnProperty;
/**
* Initializes an array clone.
*
* @private
* @param {Array} array The array to clone.
* @returns {Array} Returns the initialized clone.
*/
function initCloneArray(array) {
var length = array.length, result = new array.constructor(length);
if (length && typeof array[0] == "string" && hasOwnProperty$2.call(array, "index")) {
result.index = array.index;
result.input = array.input;
}
return result;
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_Uint8Array.js
/** Built-in value references. */
var Uint8Array$1 = root.Uint8Array;
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_cloneArrayBuffer.js
/**
* Creates a clone of `arrayBuffer`.
*
* @private
* @param {ArrayBuffer} arrayBuffer The array buffer to clone.
* @returns {ArrayBuffer} Returns the cloned array buffer.
*/
function cloneArrayBuffer(arrayBuffer) {
var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
new Uint8Array$1(result).set(new Uint8Array$1(arrayBuffer));
return result;
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_cloneDataView.js
/**
* Creates a clone of `dataView`.
*
* @private
* @param {Object} dataView The data view to clone.
* @param {boolean} [isDeep] Specify a deep clone.
* @returns {Object} Returns the cloned data view.
*/
function cloneDataView(dataView, isDeep) {
var buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer;
return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_cloneRegExp.js
/** Used to match `RegExp` flags from their coerced string values. */
var reFlags = /\w*$/;
/**
* Creates a clone of `regexp`.
*
* @private
* @param {Object} regexp The regexp to clone.
* @returns {Object} Returns the cloned regexp.
*/
function cloneRegExp(regexp) {
var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
result.lastIndex = regexp.lastIndex;
return result;
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_cloneSymbol.js
/** Used to convert symbols to primitives and strings. */
var symbolProto = Symbol$1 ? Symbol$1.prototype : void 0, symbolValueOf = symbolProto ? symbolProto.valueOf : void 0;
/**
* Creates a clone of the `symbol` object.
*
* @private
* @param {Object} symbol The symbol object to clone.
* @returns {Object} Returns the cloned symbol object.
*/
function cloneSymbol(symbol) {
return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {};
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_cloneTypedArray.js
/**
* Creates a clone of `typedArray`.
*
* @private
* @param {Object} typedArray The typed array to clone.
* @param {boolean} [isDeep] Specify a deep clone.
* @returns {Object} Returns the cloned typed array.
*/
function cloneTypedArray(typedArray, isDeep) {
var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;
return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_initCloneByTag.js
/** `Object#toString` result references. */
var boolTag$1 = "[object Boolean]", dateTag$1 = "[object Date]", mapTag$3 = "[object Map]", numberTag$1 = "[object Number]", regexpTag$1 = "[object RegExp]", setTag$3 = "[object Set]", stringTag$1 = "[object String]", symbolTag$1 = "[object Symbol]";
var arrayBufferTag$1 = "[object ArrayBuffer]", dataViewTag$1 = "[object DataView]", float32Tag$1 = "[object Float32Array]", float64Tag$1 = "[object Float64Array]", int8Tag$1 = "[object Int8Array]", int16Tag$1 = "[object Int16Array]", int32Tag$1 = "[object Int32Array]", uint8Tag$1 = "[object Uint8Array]", uint8ClampedTag$1 = "[object Uint8ClampedArray]", uint16Tag$1 = "[object Uint16Array]", uint32Tag$1 = "[object Uint32Array]";
/**
* Initializes an object clone based on its `toStringTag`.
*
* **Note:** This function only supports cloning values with tags of
* `Boolean`, `Date`, `Error`, `Map`, `Number`, `RegExp`, `Set`, or `String`.
*
* @private
* @param {Object} object The object to clone.
* @param {string} tag The `toStringTag` of the object to clone.
* @param {boolean} [isDeep] Specify a deep clone.
* @returns {Object} Returns the initialized clone.
*/
function initCloneByTag(object, tag, isDeep) {
var Ctor = object.constructor;
switch (tag) {
case arrayBufferTag$1: return cloneArrayBuffer(object);
case boolTag$1:
case dateTag$1: return new Ctor(+object);
case dataViewTag$1: return cloneDataView(object, isDeep);
case float32Tag$1:
case float64Tag$1:
case int8Tag$1:
case int16Tag$1:
case int32Tag$1:
case uint8Tag$1:
case uint8ClampedTag$1:
case uint16Tag$1:
case uint32Tag$1: return cloneTypedArray(object, isDeep);
case mapTag$3: return new Ctor();
case numberTag$1:
case stringTag$1: return new Ctor(object);
case regexpTag$1: return cloneRegExp(object);
case setTag$3: return new Ctor();
case symbolTag$1: return cloneSymbol(object);
}
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_initCloneObject.js
/**
* Initializes an object clone.
*
* @private
* @param {Object} object The object to clone.
* @returns {Object} Returns the initialized clone.
*/
function initCloneObject(object) {
return typeof object.constructor == "function" && !isPrototype(object) ? baseCreate(getPrototype(object)) : {};
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseIsMap.js
/** `Object#toString` result references. */
var mapTag$2 = "[object Map]";
/**
* The base implementation of `_.isMap` without Node.js optimizations.
*
* @private
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a map, else `false`.
*/
function baseIsMap(value) {
return isObjectLike(value) && _getTag_default(value) == mapTag$2;
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isMap.js
var nodeIsMap = nodeUtil && nodeUtil.isMap;
/**
* Checks if `value` is classified as a `Map` object.
*
* @static
* @memberOf _
* @since 4.3.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a map, else `false`.
* @example
*
* _.isMap(new Map);
* // => true
*
* _.isMap(new WeakMap);
* // => false
*/
var isMap = nodeIsMap ? baseUnary(nodeIsMap) : baseIsMap;
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseIsSet.js
/** `Object#toString` result references. */
var setTag$2 = "[object Set]";
/**
* The base implementation of `_.isSet` without Node.js optimizations.
*
* @private
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a set, else `false`.
*/
function baseIsSet(value) {
return isObjectLike(value) && _getTag_default(value) == setTag$2;
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isSet.js
var nodeIsSet = nodeUtil && nodeUtil.isSet;
/**
* Checks if `value` is classified as a `Set` object.
*
* @static
* @memberOf _
* @since 4.3.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a set, else `false`.
* @example
*
* _.isSet(new Set);
* // => true
*
* _.isSet(new WeakSet);
* // => false
*/
var isSet = nodeIsSet ? baseUnary(nodeIsSet) : baseIsSet;
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseClone.js
/** Used to compose bitmasks for cloning. */
var CLONE_DEEP_FLAG$1 = 1, CLONE_FLAT_FLAG = 2, CLONE_SYMBOLS_FLAG$1 = 4;
/** `Object#toString` result references. */
var argsTag = "[object Arguments]", arrayTag = "[object Array]", boolTag = "[object Boolean]", dateTag = "[object Date]", errorTag = "[object Error]", funcTag = "[object Function]", genTag = "[object GeneratorFunction]", mapTag$1 = "[object Map]", numberTag = "[object Number]", objectTag = "[object Object]", regexpTag = "[object RegExp]", setTag$1 = "[object Set]", stringTag = "[object String]", symbolTag = "[object Symbol]", weakMapTag = "[object WeakMap]";
var arrayBufferTag = "[object ArrayBuffer]", dataViewTag = "[object DataView]", float32Tag = "[object Float32Array]", float64Tag = "[object Float64Array]", int8Tag = "[object Int8Array]", int16Tag = "[object Int16Array]", int32Tag = "[object Int32Array]", uint8Tag = "[object Uint8Array]", uint8ClampedTag = "[object Uint8ClampedArray]", uint16Tag = "[object Uint16Array]", uint32Tag = "[object Uint32Array]";
/** Used to identify `toStringTag` values supported by `_.clone`. */
var cloneableTags = {};
cloneableTags[argsTag] = cloneableTags[arrayTag] = cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] = cloneableTags[boolTag] = cloneableTags[dateTag] = cloneableTags[float32Tag] = cloneableTags[float64Tag] = cloneableTags[int8Tag] = cloneableTags[int16Tag] = cloneableTags[int32Tag] = cloneableTags[mapTag$1] = cloneableTags[numberTag] = cloneableTags[objectTag] = cloneableTags[regexpTag] = cloneableTags[setTag$1] = cloneableTags[stringTag] = cloneableTags[symbolTag] = cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] = cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true;
cloneableTags[errorTag] = cloneableTags[funcTag] = cloneableTags[weakMapTag] = false;
/**
* The base implementation of `_.clone` and `_.cloneDeep` which tracks
* traversed objects.
*
* @private
* @param {*} value The value to clone.
* @param {boolean} bitmask The bitmask flags.
* 1 - Deep clone
* 2 - Flatten inherited properties
* 4 - Clone symbols
* @param {Function} [customizer] The function to customize cloning.
* @param {string} [key] The key of `value`.
* @param {Object} [object] The parent object of `value`.
* @param {Object} [stack] Tracks traversed objects and their clone counterparts.
* @returns {*} Returns the cloned value.
*/
function baseClone(value, bitmask, customizer, key, object, stack) {
var result, isDeep = bitmask & CLONE_DEEP_FLAG$1, isFlat = bitmask & CLONE_FLAT_FLAG, isFull = bitmask & CLONE_SYMBOLS_FLAG$1;
if (customizer) result = object ? customizer(value, key, object, stack) : customizer(value);
if (result !== void 0) return result;
if (!isObject$1(value)) return value;
var isArr = isArray(value);
if (isArr) {
result = initCloneArray(value);
if (!isDeep) return copyArray(value, result);
} else {
var tag = _getTag_default(value), isFunc = tag == funcTag || tag == genTag;
if (isBuffer(value)) return cloneBuffer(value, isDeep);
if (tag == objectTag || tag == argsTag || isFunc && !object) {
result = isFlat || isFunc ? {} : initCloneObject(value);
if (!isDeep) return isFlat ? copySymbolsIn(value, baseAssignIn(result, value)) : copySymbols(value, baseAssign(result, value));
} else {
if (!cloneableTags[tag]) return object ? value : {};
result = initCloneByTag(value, tag, isDeep);
}
}
stack || (stack = new Stack());
var stacked = stack.get(value);
if (stacked) return stacked;
stack.set(value, result);
if (isSet(value)) value.forEach(function(subValue) {
result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack));
});
else if (isMap(value)) value.forEach(function(subValue, key) {
result.set(key, baseClone(subValue, bitmask, customizer, key, value, stack));
});
var props = isArr ? void 0 : (isFull ? isFlat ? getAllKeysIn : getAllKeys : isFlat ? keysIn : keys)(value);
arrayEach(props || value, function(subValue, key) {
if (props) {
key = subValue;
subValue = value[key];
}
assignValue(result, key, baseClone(subValue, bitmask, customizer, key, value, stack));
});
return result;
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/cloneDeep.js
/** Used to compose bitmasks for cloning. */
var CLONE_DEEP_FLAG = 1, CLONE_SYMBOLS_FLAG = 4;
/**
* This method is like `_.clone` except that it recursively clones `value`.
*
* @static
* @memberOf _
* @since 1.0.0
* @category Lang
* @param {*} value The value to recursively clone.
* @returns {*} Returns the deep cloned value.
* @see _.clone
* @example
*
* var objects = [{ 'a': 1 }, { 'b': 2 }];
*
* var deep = _.cloneDeep(objects);
* console.log(deep[0] === objects[0]);
* // => false
*/
function cloneDeep(value) {
return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG);
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_setCacheAdd.js
/** Used to stand-in for `undefined` hash values. */
var HASH_UNDEFINED = "__lodash_hash_undefined__";
/**
* Adds `value` to the array cache.
*
* @private
* @name add
* @memberOf SetCache
* @alias push
* @param {*} value The value to cache.
* @returns {Object} Returns the cache instance.
*/
function setCacheAdd(value) {
this.__data__.set(value, HASH_UNDEFINED);
return this;
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_setCacheHas.js
/**
* Checks if `value` is in the array cache.
*
* @private
* @name has
* @memberOf SetCache
* @param {*} value The value to search for.
* @returns {number} Returns `true` if `value` is found, else `false`.
*/
function setCacheHas(value) {
return this.__data__.has(value);
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_SetCache.js
/**
*
* Creates an array cache object to store unique values.
*
* @private
* @constructor
* @param {Array} [values] The values to cache.
*/
function SetCache(values) {
var index = -1, length = values == null ? 0 : values.length;
this.__data__ = new MapCache();
while (++index < length) this.add(values[index]);
}
SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
SetCache.prototype.has = setCacheHas;
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_cacheHas.js
/**
* Checks if a `cache` value for `key` exists.
*
* @private
* @param {Object} cache The cache to query.
* @param {string} key The key of the entry to check.
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
*/
function cacheHas(cache, key) {
return cache.has(key);
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_setToArray.js
/**
* Converts `set` to an array of its values.
*
* @private
* @param {Object} set The set to convert.
* @returns {Array} Returns the values.
*/
function setToArray(set) {
var index = -1, result = Array(set.size);
set.forEach(function(value) {
result[++index] = value;
});
return result;
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_hasPath.js
/**
* Checks if `path` exists on `object`.
*
* @private
* @param {Object} object The object to query.
* @param {Array|string} path The path to check.
* @param {Function} hasFunc The function to check properties.
* @returns {boolean} Returns `true` if `path` exists, else `false`.
*/
function hasPath(object, path, hasFunc) {
path = castPath(path, object);
var index = -1, length = path.length, result = false;
while (++index < length) {
var key = toKey(path[index]);
if (!(result = object != null && hasFunc(object, key))) break;
object = object[key];
}
if (result || ++index != length) return result;
length = object == null ? 0 : object.length;
return !!length && isLength(length) && isIndex(key, length) && (isArray(object) || isArguments(object));
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isArrayLikeObject.js
/**
* This method is like `_.isArrayLike` except that it also checks if `value`
* is an object.
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is an array-like object,
* else `false`.
* @example
*
* _.isArrayLikeObject([1, 2, 3]);
* // => true
*
* _.isArrayLikeObject(document.body.children);
* // => true
*
* _.isArrayLikeObject('abc');
* // => false
*
* _.isArrayLikeObject(_.noop);
* // => false
*/
function isArrayLikeObject(value) {
return isObjectLike(value) && isArrayLike(value);
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_arrayIncludesWith.js
/**
* This function is like `arrayIncludes` except that it accepts a comparator.
*
* @private
* @param {Array} [array] The array to inspect.
* @param {*} target The value to search for.
* @param {Function} comparator The comparator invoked per element.
* @returns {boolean} Returns `true` if `target` is found, else `false`.
*/
function arrayIncludesWith(array, value, comparator) {
var index = -1, length = array == null ? 0 : array.length;
while (++index < length) if (comparator(value, array[index])) return true;
return false;
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseHas.js
/** Used to check objects for own properties. */
var hasOwnProperty$1 = Object.prototype.hasOwnProperty;
/**
* The base implementation of `_.has` without support for deep paths.
*
* @private
* @param {Object} [object] The object to query.
* @param {Array|string} key The key to check.
* @returns {boolean} Returns `true` if `key` exists, else `false`.
*/
function baseHas(object, key) {
return object != null && hasOwnProperty$1.call(object, key);
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/has.js
/**
* Checks if `path` is a direct property of `object`.
*
* @static
* @since 0.1.0
* @memberOf _
* @category Object
* @param {Object} object The object to query.
* @param {Array|string} path The path to check.
* @returns {boolean} Returns `true` if `path` exists, else `false`.
* @example
*
* var object = { 'a': { 'b': 2 } };
* var other = _.create({ 'a': _.create({ 'b': 2 }) });
*
* _.has(object, 'a');
* // => true
*
* _.has(object, 'a.b');
* // => true
*
* _.has(object, ['a', 'b']);
* // => true
*
* _.has(other, 'a');
* // => false
*/
function has(object, path) {
return object != null && hasPath(object, path, baseHas);
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isEmpty.js
/** `Object#toString` result references. */
var mapTag = "[object Map]", setTag = "[object Set]";
/** Used to check objects for own properties. */
var hasOwnProperty = Object.prototype.hasOwnProperty;
/**
* Checks if `value` is an empty object, collection, map, or set.
*
* Objects are considered empty if they have no own enumerable string keyed
* properties.
*
* Array-like values such as `arguments` objects, arrays, buffers, strings, or
* jQuery-like collections are considered empty if they have a `length` of `0`.
* Similarly, maps and sets are considered empty if they have a `size` of `0`.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is empty, else `false`.
* @example
*
* _.isEmpty(null);
* // => true
*
* _.isEmpty(true);
* // => true
*
* _.isEmpty(1);
* // => true
*
* _.isEmpty([1, 2, 3]);
* // => false
*
* _.isEmpty({ 'a': 1 });
* // => false
*/
function isEmpty(value) {
if (value == null) return true;
if (isArrayLike(value) && (isArray(value) || typeof value == "string" || typeof value.splice == "function" || isBuffer(value) || isTypedArray(value) || isArguments(value))) return !value.length;
var tag = _getTag_default(value);
if (tag == mapTag || tag == setTag) return !value.size;
if (isPrototype(value)) return !baseKeys(value).length;
for (var key in value) if (hasOwnProperty.call(value, key)) return false;
return true;
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseSet.js
/**
* The base implementation of `_.set`.
*
* @private
* @param {Object} object The object to modify.
* @param {Array|string} path The path of the property to set.
* @param {*} value The value to set.
* @param {Function} [customizer] The function to customize path creation.
* @returns {Object} Returns `object`.
*/
function baseSet(object, path, value, customizer) {
if (!isObject$1(object)) return object;
path = castPath(path, object);
var index = -1, length = path.length, lastIndex = length - 1, nested = object;
while (nested != null && ++index < length) {
var key = toKey(path[index]), newValue = value;
if (key === "__proto__" || key === "constructor" || key === "prototype") return object;
if (index != lastIndex) {
var objValue = nested[key];
newValue = customizer ? customizer(objValue, key, nested) : void 0;
if (newValue === void 0) newValue = isObject$1(objValue) ? objValue : isIndex(path[index + 1]) ? [] : {};
}
assignValue(nested, key, newValue);
nested = nested[key];
}
return object;
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/set.js
/**
* Sets the value at `path` of `object`. If a portion of `path` doesn't exist,
* it's created. Arrays are created for missing index properties while objects
* are created for all other missing properties. Use `_.setWith` to customize
* `path` creation.
*
* **Note:** This method mutates `object`.
*
* @static
* @memberOf _
* @since 3.7.0
* @category Object
* @param {Object} object The object to modify.
* @param {Array|string} path The path of the property to set.
* @param {*} value The value to set.
* @returns {Object} Returns `object`.
* @example
*
* var object = { 'a': [{ 'b': { 'c': 3 } }] };
*
* _.set(object, 'a[0].b.c', 4);
* console.log(object.a[0].b.c);
* // => 4
*
* _.set(object, ['x', '0', 'y', 'z'], 5);
* console.log(object.x[0].y.z);
* // => 5
*/
function set(object, path, value) {
return object == null ? object : baseSet(object, path, value);
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_createSet.js
/**
* Creates a set object of `values`.
*
* @private
* @param {Array} values The values to add to the set.
* @returns {Object} Returns the new set.
*/
var createSet = !(Set$1 && 1 / setToArray(new Set$1([, -0]))[1] == Infinity) ? noop : function(values) {
return new Set$1(values);
};
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseUniq.js
/** Used as the size to enable large array optimizations. */
var LARGE_ARRAY_SIZE = 200;
/**
* The base implementation of `_.uniqBy` without support for iteratee shorthands.
*
* @private
* @param {Array} array The array to inspect.
* @param {Function} [iteratee] The iteratee invoked per element.
* @param {Function} [comparator] The comparator invoked per element.
* @returns {Array} Returns the new duplicate free array.
*/
function baseUniq(array, iteratee, comparator) {
var index = -1, includes = arrayIncludes, length = array.length, isCommon = true, result = [], seen = result;
if (comparator) {
isCommon = false;
includes = arrayIncludesWith;
} else if (length >= LARGE_ARRAY_SIZE) {
var set = iteratee ? null : createSet(array);
if (set) return setToArray(set);
isCommon = false;
includes = cacheHas;
seen = new SetCache();
} else seen = iteratee ? [] : result;
outer: while (++index < length) {
var value = array[index], computed = iteratee ? iteratee(value) : value;
value = comparator || value !== 0 ? value : 0;
if (isCommon && computed === computed) {
var seenIndex = seen.length;
while (seenIndex--) if (seen[seenIndex] === computed) continue outer;
if (iteratee) seen.push(computed);
result.push(value);
} else if (!includes(seen, computed, comparator)) {
if (seen !== result) seen.push(computed);
result.push(value);
}
}
return result;
}
//#endregion
//#region ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/union.js
/**
* Creates an array of unique values, in order, from all given arrays using
* [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
* for equality comparisons.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Array
* @param {...Array} [arrays] The arrays to inspect.
* @returns {Array} Returns the new array of combined values.
* @example
*
* _.union([2], [1, 2]);
* // => [2, 1]
*/
var union = baseRest(function(arrays) {
return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true));
});
//#endregion
//#region ../../node_modules/.pnpm/deep-state-observer@5.5.14/node_modules/deep-state-observer/index.esm.js
var import_events = /* @__PURE__ */ __toESM(require_events(), 1);
var cachedTextEncoder = new TextEncoder("utf-8");
var encodeString = typeof cachedTextEncoder.encodeInto === "function" ? function(arg, view) {
return cachedTextEncoder.encodeInto(arg, view);
} : function(arg, view) {
const buf = cachedTextEncoder.encode(arg);
view.set(buf);
return {
read: arg.length,
written: buf.length
};
};
//#endregion
//#region ../../node_modules/.pnpm/@tmagic+data-source@1.7.7_@tmagic+core@1.7.7_typescript@5.9.3__typescript@5.9.3/node_modules/@tmagic/data-source/dist/tmagic-data-source.js
var ObservedData = class {};
var SimpleObservedData = class extends ObservedData {
data = {};
event = new import_events.EventEmitter();
constructor(initialData) {
super();
this.data = initialData;
}
update(data, path) {
if (path) setValueByKeyPath(path, data, this.data);
else this.data = data;
const changeEvent = {
updateData: data,
path: path ?? ""
};
if (path) this.event.emit(path, changeEvent);
this.event.emit("", changeEvent);
}
on(path, callback, options) {
if (options?.immediate) callback(this.getData(path));
this.event.on(path, callback);
}
off(path, callback) {
this.event.off(path, callback);
}
getData(path) {
return path ? getValueByKeyPath(path, this.data) : this.data;
}
destroy() {}
};
var DataSource = class extends import_events.default {
isInit = false;
/** @tmagic/core 实例 */
app;
mockData;
#type = "base";
#id;
#schema;
#observedData;
/** 数据源自定义字段配置 */
#fields = [];
/** 数据源自定义方法配置 */
#methods = [];
constructor(options) {
super();
this.#id = options.schema.id;
this.#schema = options.schema;
this.app = options.app;
this.setFields(options.schema.fields);
this.setMethods(options.schema.methods || []);
let data = options.initialData;
const ObservedDataClass = options.ObservedDataClass || SimpleObservedData;
if (this.app.platform === "editor") {
this.mockData = cloneDeep(options.schema.mocks || []).find((mock) => mock.useInEditor)?.data || this.getDefaultData();
data = cloneDeep(this.mockData);
} else if (typeof options.useMock === "boolean" && options.useMock) {
this.mockData = cloneDeep(options.schema.mocks || []).find((mock) => mock.enable)?.data;
data = cloneDeep(this.mockData) || this.getDefaultData();
} else if (!options.initialData) data = this.getDefaultData();
else {
this.#observedData = new ObservedDataClass(options.initialData ?? {});
this.isInit = true;
return;
}
this.#observedData = new ObservedDataClass(data ?? {});
}
get id() {
return this.#id;
}
get type() {
return this.#type;
}
get schema() {
return this.#schema;
}
get fields() {
return this.#fields;
}
get methods() {
return this.#methods;
}
setFields(fields) {
this.#fields = fields;
}
setMethods(methods) {
this.#methods = methods;
}
get data() {
return this.#observedData.getData("");
}
setData(data, path) {
this.#observedData.update(data, path);
const changeEvent = {
updateData: data,
path
};
this.emit("change", changeEvent);
}
setValue(path, data) {
return this.setData(data, path);
}
onDataChange(path, callback, options) {
this.#observedData.on(path, callback, options);
}
offDataChange(path, callback) {
this.#observedData.off(path, callback);
}
getDefaultData() {
return getDefaultValueFromFields(this.#fields);
}
async init() {
this.isInit = true;
}
destroy() {
this.#fields = [];
this.removeAllListeners();
this.#observedData.destroy();
}
};
var urlencoded = (data) => Object.entries(data).reduce((prev, [key, value]) => {
let v = value;
if (typeof value === "object") v = JSON.stringify(value);
if (typeof value !== "undefined") return `${prev}${prev ? "&" : ""}${globalThis.encodeURIComponent(key)}=${globalThis.encodeURIComponent(`${v}`)}`;
return prev;
}, "");
var webRequest = async (options) => {
const { url, method = "GET", headers = {}, params = {}, data = {}, ...config } = options;
const query = urlencoded(params);
let body = JSON.stringify(data);
if (headers["Content-Type"]?.includes("application/x-www-form-urlencoded")) body = urlencoded(data);
return (await globalThis.fetch(query ? `${url}?${query}` : url, {
method,
headers,
body: method === "GET" ? void 0 : body,
...config
})).json();
};
var HttpDataSource = class extends DataSource {
/** 是否正在发起请求 */
isLoading = false;
error;
/** 请求配置 */
httpOptions;
/** 请求函数 */
#fetch;
/** 请求前需要执行的函数队列 */
#beforeRequest = [];
/** 请求后需要执行的函数队列 */
#afterRequest = [];
#type = "http";
constructor(options) {
const { options: httpOptions } = options.schema;
super(options);
this.httpOptions = httpOptions;
if (typeof options.request === "function") this.#fetch = options.request;
else if (typeof globalThis.fetch === "function") this.#fetch = webRequest;
this.methods.forEach((method) => {
if (typeof method.content !== "function") return;
if (method.timing === "beforeRequest") this.#beforeRequest.push(method.content);
if (method.timing === "afterRequest") this.#afterRequest.push(method.content);
});
}
get type() {
return this.#type;
}
async init() {
if (this.schema.autoFetch) await this.request();
super.init();
}
async request(options = {}) {
this.isLoading = true;
const { url, params, data, headers, ...otherHttpOptions } = this.httpOptions;
let reqOptions = {
url: typeof url === "function" ? url({
app: this.app,
dataSource: this
}) : url,
params: typeof params === "function" ? params({
app: this.app,
dataSource: this
}) : params,
data: typeof data === "function" ? data({
app: this.app,
dataSource: this
}) : data,
headers: typeof headers === "function" ? headers({
app: this.app,
dataSource: this
}) : headers,
...otherHttpOptions,
...options
};
try {
for (const method of this.#beforeRequest) await method({
options: reqOptions,
params: {},
dataSource: this,
app: this.app
});
if (typeof this.schema.beforeRequest === "function") reqOptions = await this.schema.beforeRequest(reqOptions, {
app: this.app,
dataSource: this
});
if (this.mockData) this.setData(this.mockData);
else {
let res = await this.#fetch?.(reqOptions);
for (const method of this.#afterRequest) await method({
res,
options: reqOptions,
params: {},
dataSource: this,
app: this.app
});
if (typeof this.schema.afterResponse === "function") res = await this.schema.afterResponse(res, {
app: this.app,
dataSource: this,
options: reqOptions
});
if (this.schema.responseOptions?.dataPath) {
const data2 = getValueByKeyPath(this.schema.responseOptions.dataPath, res);
this.setData(data2);
} else this.setData(res);
}
this.error = void 0;
} catch (error) {
this.error = { msg: error.message };
this.emit("error", error);
}
this.isLoading = false;
}
get(options) {
return this.request({
...options,
method: "GET"
});
}
post(options) {
return this.request({
...options,
method: "POST"
});
}
};
var cache = /* @__PURE__ */ new Map();
var getDeps = (ds, nodes, inEditor) => {
let cacheKey;
if (inEditor) {
const ids = [];
nodes.forEach((node) => {
traverseNode(node, (node2) => {
ids.push(node2.id);
});
});
cacheKey = `${ds.id}:${ids.join(":")}`;
} else cacheKey = `${ds.id}:${nodes.map((node) => node.id).join(":")}`;
if (cache.has(cacheKey)) return cache.get(cacheKey);
const watcher = new Watcher();
watcher.addTarget(new Target({
id: ds.id,
type: "data-source",
isTarget: (key, value) => {
if (`${key}`.includes("__tmagic__")) return false;
return isDataSourceTarget(ds, key, value, true);
}
}));
watcher.addTarget(new Target({
id: ds.id,
type: "cond",
isTarget: (key, value) => isDataSourceCondTarget(ds, key, value, true)
}));
watcher.collect(nodes, {}, true);
const { deps } = watcher.getTarget(ds.id, "data-source");
const { deps: condDeps } = watcher.getTarget(ds.id, "cond");
const result = {
deps,
condDeps
};
cache.set(cacheKey, result);
return result;
};
var compiledCondition = (cond, data) => {
let result = true;
for (const { op, value, range, field } of cond) {
const [sourceId, ...fields] = field;
const dsData = data[sourceId];
if (!dsData || !fields.length) break;
try {
if (!compiledCond(op, getValueByKeyPath(fields.join("."), dsData), value, range)) {
result = false;
break;
}
} catch (e) {
console.warn(e);
}
}
return result;
};
var compliedConditions = (node, data) => {
if (!node["displayConds"] || !Array.isArray(node["displayConds"]) || !node["displayConds"].length) return true;
for (const { cond } of node[NODE_CONDS_KEY]) {
if (!cond) continue;
if (compiledCondition(cond, data)) return true;
}
return false;
};
var updateNode = (node, dsl) => {
if (isPage(node) || isPageFragment(node)) {
const index = dsl.items?.findIndex((child) => child.id === node.id);
dsl.items.splice(index, 1, node);
} else replaceChildNode(node, dsl.items);
};
var createIteratorContentData = (itemData, dsId, fields = [], dsData = {}) => {
const data = {
...dsData,
[dsId]: {}
};
let rawData = cloneDeep(dsData[dsId]);
let obj = data[dsId];
fields.forEach((key, index) => {
Object.assign(obj, rawData);
if (index === fields.length - 1) {
obj[key] = itemData;
return;
}
if (Array.isArray(rawData[key])) {
rawData[key] = {};
obj[key] = {};
}
rawData = rawData[key];
obj = obj[key];
});
return data;
};
var compliedDataSourceField = (value, data) => {
const [prefixId, ...fields] = value;
const prefixIndex = prefixId.indexOf(DATA_SOURCE_FIELDS_SELECT_VALUE_PREFIX);
if (prefixIndex > -1) {
const dsData = data[prefixId.substring(prefixIndex + DATA_SOURCE_FIELDS_SELECT_VALUE_PREFIX.length)];
if (!dsData) return value;
try {
return getValueByKeyPath(fields.join("."), dsData);
} catch (e) {
return value;
}
}
return value;
};
var template = (value, data) => value.replace(dataSourceTemplateRegExp, (match, $1) => {
try {
return getValueByKeyPath($1, data);
} catch (e) {
return match;
}
});
var compiledNodeField = (value, data) => {
if (typeof value === "string") return template(value, data);
if (value?.isBindDataSource && value.dataSourceId) return data[value.dataSourceId];
if (value?.isBindDataSourceField && value.dataSourceId && typeof value.template === "string") return template(value.template, data[value.dataSourceId]);
if (Array.isArray(value) && typeof value[0] === "string") return compliedDataSourceField(value, data);
return value;
};
var compliedIteratorItem = ({ compile, dsId, item, deps, condDeps, inEditor, ctxData }) => {
const { items, ...node } = item;
const newNode = cloneDeep(node);
if (condDeps[node.id]?.keys.length && !inEditor) newNode.condResult = compliedConditions(node, ctxData);
if (Array.isArray(items) && items.length) newNode.items = items.map((item2) => compliedIteratorItem({
compile,
dsId,
item: item2,
deps,
condDeps,
inEditor,
ctxData
}));
else if (items) newNode.items = items;
if (!deps[newNode.id]?.keys.length) return newNode;
return compiledNode(compile, newNode, { [dsId]: deps }, dsId);
};
var DataSourceManager = class DataSourceManager extends import_events.default {
static dataSourceClassMap = /* @__PURE__ */ new Map([["base", DataSource], ["http", HttpDataSource]]);
static ObservedDataClass = SimpleObservedData;
static waitInitSchemaList = /* @__PURE__ */ new Map();
static register(type, dataSource) {
DataSourceManager.dataSourceClassMap.set(type, dataSource);
DataSourceManager.waitInitSchemaList?.forEach((listMap, app) => {
const list = listMap[type] || [];
for (let config = list.shift(); config; config = list.shift()) {
const ds = app.addDataSource(config);
if (ds) app.init(ds);
}
});
}
static getDataSourceClass(type) {
return DataSourceManager.dataSourceClassMap.get(type);
}
static clearDataSourceClass() {
DataSourceManager.dataSourceClassMap.clear();
DataSourceManager.dataSourceClassMap.set("base", DataSource);
DataSourceManager.dataSourceClassMap.set("http", HttpDataSource);
}
static registerObservedData(ObservedDataClass) {
DataSourceManager.ObservedDataClass = ObservedDataClass;
}
app;
dataSourceMap = /* @__PURE__ */ new Map();
data = {};
initialData = {};
useMock = false;
constructor({ app, useMock, initialData }) {
super();
DataSourceManager.waitInitSchemaList.set(this, {});
this.app = app;
this.useMock = useMock;
if (initialData) {
this.initialData = initialData;
this.data = { ...initialData };
}
app.dsl?.dataSources?.forEach((config) => {
this.addDataSource(config);
});
if (this.isAllDataSourceRegistered()) this.callDsInit();
else this.on("registered-all", () => {
this.callDsInit();
});
}
async init(ds) {
if (ds.isInit) return;
if (this.app.jsEngine && ds.schema.disabledInitInJsEngine?.includes(this.app.jsEngine)) return;
for (const method of ds.methods) {
if (typeof method.content !== "function") return;
if (method.timing === "beforeInit") await method.content({
params: {},
dataSource: ds,
app: this.app
});
}
await ds.init();
for (const method of ds.methods) {
if (typeof method.content !== "function") return;
if (method.timing === "afterInit") await method.content({
params: {},
dataSource: ds,
app: this.app
});
}
}
get(id) {
return this.dataSourceMap.get(id);
}
addDataSource(config) {
if (!config) return;
const DataSourceClass = DataSourceManager.dataSourceClassMap.get(config.type);
if (!DataSourceClass) {
let listMap = DataSourceManager.waitInitSchemaList.get(this);
if (!listMap) {
listMap = {};
DataSourceManager.waitInitSchemaList.set(this, listMap);
}
if (listMap[config.type]) listMap[config.type].push(config);
else listMap[config.type] = [config];
this.data[config.id] = this.initialData[config.id] ?? getDefaultValueFromFields(config.fields);
return;
}
const ds = new DataSourceClass({
app: this.app,
schema: config,
request: this.app.request,
useMock: this.useMock,
initialData: this.initialData[config.id],
ObservedDataClass: DataSourceManager.ObservedDataClass
});
this.dataSourceMap.set(config.id, ds);
this.data[ds.id] = ds.data;
ds.on("change", (changeEvent) => {
this.setData(ds, changeEvent);
});
if (this.isAllDataSourceRegistered()) this.emit("registered-all");
return ds;
}
setData(ds, changeEvent) {
this.data[ds.id] = ds.data;
this.emit("change", ds.id, changeEvent);
}
removeDataSource(id) {
this.get(id)?.destroy();
delete this.data[id];
this.dataSourceMap.delete(id);
}
/**
* 更新数据源dsl在编辑器中修改配置后需要更新一般在其他环境下不需要更新dsl
* @param {DataSourceSchema[]} schemas 所有数据源配置
*/
updateSchema(schemas) {
for (const schema of schemas) {
if (!this.get(schema.id)) return;
this.removeDataSource(schema.id);
}
for (const schema of schemas) {
this.addDataSource(cloneDeep(schema));
const newDs = this.get(schema.id);
if (newDs) this.init(newDs);
}
}
/**
* 将组件dsl中所有key中数据源相关的配置编译成对应的值
* @param {MNode} node 组件dsl
* @param {string | number} sourceId 数据源ID
* @param {boolean} deep 是否编译子项items)默认为false
* @returns {MNode} 编译后的组件dsl
*/
compiledNode(n, sourceId, deep = false) {
if (n["_tmagic_node_disabled_data_source"]) return n;
const { items, ...node } = n;
const newNode = cloneDeep(node);
if (items) newNode.items = Array.isArray(items) && deep ? items.map((item) => this.compiledNode(item, sourceId, deep)) : items;
if (node.condResult === false || typeof node.condResult === "undefined" && node["displayCondsResultReverse"]) return newNode;
return compiledNode((value) => compiledNodeField(value, this.data), newNode, this.app.dsl?.dataSourceDeps || {}, sourceId);
}
/**
* 编译组件条件组配置(用于配置组件显示时机)
* @param {{ [NODE_CONDS_KEY]?: DisplayCond[] }} node 显示条件组配置
* @returns {boolean} 是否显示
*/
compliedConds(node, data = this.data) {
if (node["_tmagic_node_disabled_data_source"]) return true;
const result = compliedConditions(node, data);
if (!node["displayCondsResultReverse"]) return result;
return !result;
}
/**
* 编译迭代器容器的迭代项的显示条件
* @param {any[]} itemData 迭代数据
* @param {{ [NODE_CONDS_KEY]?: DisplayCond[] }} node 显示条件组配置
* @param {string[]} dataSourceField 迭代数据在数据源中的字段,格式如['dsId', 'key1', 'key2']
* @returns {boolean}是否显示
*/
compliedIteratorItemConds(itemData, node, dataSourceField = []) {
const [dsId, ...keys] = dataSourceField;
const ds = this.get(dsId);
if (!ds) return true;
const ctxData = createIteratorContentData(itemData, ds.id, keys, this.data);
return this.compliedConds(node, ctxData);
}
compliedIteratorItems(itemData, nodes, dataSourceField = []) {
const [dsId, ...keys] = dataSourceField;
const ds = this.get(dsId);
if (!ds) return nodes;
const inEditor = this.app.platform === "editor";
const ctxData = createIteratorContentData(itemData, ds.id, keys, this.data);
const { deps = {}, condDeps = {} } = getDeps(ds.schema, nodes, inEditor);
if (!Object.keys(deps).length && !Object.keys(condDeps).length) return nodes;
return nodes.map((item) => compliedIteratorItem({
compile: (value) => compiledNodeField(value, ctxData),
dsId: ds.id,
item,
deps,
condDeps,
inEditor,
ctxData
}));
}
isAllDataSourceRegistered() {
return !this.app.dsl?.dataSources?.length || this.dataSourceMap.size === this.app.dsl.dataSources.length;
}
destroy() {
this.removeAllListeners();
this.data = {};
this.initialData = {};
this.dataSourceMap.forEach((ds) => {
ds.destroy();
});
this.dataSourceMap.clear();
DataSourceManager.waitInitSchemaList.delete(this);
}
onDataChange(id, path, callback, options) {
return this.get(id)?.onDataChange(path, callback, options);
}
offDataChange(id, path, callback) {
return this.get(id)?.offDataChange(path, callback);
}
callDsInit() {
const dataSourceList = Array.from(this.dataSourceMap);
if (typeof Promise.allSettled === "function") Promise.allSettled(dataSourceList.map(([, ds]) => this.init(ds))).then((values) => {
const data = {};
const errors = {};
values.forEach((value, index) => {
const dsId = dataSourceList[index][0];
if (value.status === "fulfilled") if (this.data[dsId]) data[dsId] = this.data[dsId];
else delete data[dsId];
else if (value.status === "rejected") {
delete data[dsId];
errors[dsId] = value.reason;
}
});
this.emit("init", data, errors);
});
else Promise.all(dataSourceList.map(([, ds]) => this.init(ds))).then(() => {
this.emit("init", this.data);
}).catch(() => {
this.emit("init", this.data);
});
}
};
var createDataSourceManager = (app, useMock, initialData) => {
const { dsl, platform } = app;
if (!dsl?.dataSources) return;
const dataSourceManager = new DataSourceManager({
app,
useMock,
initialData
});
if (dsl.dataSources && dsl.dataSourceCondDeps && platform !== "editor") getNodes(getDepNodeIds(dsl.dataSourceCondDeps), dsl.items).forEach((node) => {
node.condResult = dataSourceManager.compliedConds(node);
updateNode(node, dsl);
});
if (dsl.dataSources && dsl.dataSourceDeps) getNodes(getDepNodeIds(dsl.dataSourceDeps), dsl.items).forEach((node) => {
updateNode(dataSourceManager.compiledNode(node), dsl);
});
if (app.jsEngine === "nodejs") return dataSourceManager;
dataSourceManager.on("change", (sourceId, changeEvent) => {
const dep = dsl.dataSourceDeps?.[sourceId] || {};
const condDep = dsl.dataSourceCondDeps?.[sourceId] || {};
const nodeIds = union([...Object.keys(condDep), ...Object.keys(dep)]);
for (const page of dsl.items) if (app.platform === "editor" || isPage(page) && page.id === app.page?.data.id || isPageFragment(page)) {
const newNodes = getNodes(nodeIds, [page]).map((node) => {
if (app.platform !== "editor") node.condResult = dataSourceManager.compliedConds(node);
const newNode = dataSourceManager.compiledNode(node);
if (typeof app.page?.setData === "function") {
if (isPage(newNode)) app.page.setData(newNode);
else if (page.id === app.page.data.id && !app.page.instance) replaceChildNode(newNode, [app.page.data]);
app.getNode(node.id, { strict: true })?.setData(newNode);
for (const [, pageFragment] of app.pageFragments) if (pageFragment.data.id === newNode.id) pageFragment.setData(newNode);
else if (pageFragment.data.id === page.id) {
pageFragment.getNode(newNode.id, { strict: true })?.setData(newNode);
if (!pageFragment.instance) replaceChildNode(newNode, [pageFragment.data]);
}
}
return newNode;
});
if (newNodes.length) dataSourceManager.emit("update-data", newNodes, sourceId, changeEvent, page.id);
}
});
return dataSourceManager;
};
//#endregion
//#region ../../node_modules/.pnpm/@tmagic+schema@1.7.7_typescript@5.9.3/node_modules/@tmagic/schema/dist/tmagic-schema.js
var NodeType = /* @__PURE__ */ ((NodeType2) => {
NodeType2["CONTAINER"] = "container";
NodeType2["PAGE"] = "page";
NodeType2["ROOT"] = "app";
NodeType2["PAGE_FRAGMENT"] = "page-fragment";
return NodeType2;
})(NodeType || {});
var NODE_CONDS_KEY = "displayConds";
var NODE_CONDS_RESULT_KEY = "displayCondsResultReverse";
var NODE_DISABLE_DATA_SOURCE_KEY = "_tmagic_node_disabled_data_source";
var NODE_DISABLE_CODE_BLOCK_KEY = "_tmagic_node_disabled_code_block";
var ActionType = /* @__PURE__ */ ((ActionType2) => {
ActionType2["COMP"] = "comp";
ActionType2["CODE"] = "code";
ActionType2["DATA_SOURCE"] = "data-source";
return ActionType2;
})(ActionType || {});
var HookType = /* @__PURE__ */ ((HookType2) => {
HookType2["CODE"] = "code";
return HookType2;
})(HookType || {});
var HookCodeType = /* @__PURE__ */ ((HookCodeType2) => {
HookCodeType2["CODE"] = "code";
HookCodeType2["DATA_SOURCE_METHOD"] = "data-source-method";
return HookCodeType2;
})(HookCodeType || {});
//#endregion
//#region ../../node_modules/.pnpm/@tmagic+utils@1.7.7_@tmagic+schema@1.7.7_typescript@5.9.3__typescript@5.9.3/node_modules/@tmagic/utils/dist/tmagic-utils.js
var getNodePath = (id, data = []) => {
const path = [];
const get = function(id2, data2) {
if (!Array.isArray(data2)) return null;
for (let i = 0, l = data2.length; i < l; i++) {
const item = data2[i];
path.push(item);
if (`${item.id}` === `${id2}`) return item;
if (item.items) {
const node = get(id2, item.items);
if (node) return node;
}
path.pop();
}
return null;
};
get(id, data);
return path;
};
var isObject = (obj) => Object.prototype.toString.call(obj) === "[object Object]";
var isPage = (node) => {
if (!node) return false;
return Boolean(node.type?.toLowerCase() === NodeType.PAGE);
};
var isPageFragment = (node) => {
if (!node) return false;
return Boolean(node.type?.toLowerCase() === NodeType.PAGE_FRAGMENT);
};
var isNumber = (value) => typeof value === "number" && !isNaN(value) || /^(-?\d+)(\.\d+)?$/.test(`${value}`);
var getKeysArray = (keys) => `${keys}`.replace(/\[(\d+)\]/g, ".$1").split(".");
var getValueByKeyPath = (keys = "", data = {}) => {
return (Array.isArray(keys) ? keys : getKeysArray(keys)).reduce((accumulator, currentValue) => {
if (isObject(accumulator)) return accumulator[currentValue];
if (Array.isArray(accumulator) && /^\d*$/.test(`${currentValue}`)) return accumulator[currentValue];
throw new Error(`${data}中不存在${keys}`);
}, data);
};
var setValueByKeyPath = (keys, value, data = {}) => set(data, keys, value);
var getNodes = (ids, data = []) => {
const nodes = [];
const get = function(ids2, data2) {
if (!Array.isArray(data2)) return;
for (const item of data2) {
const index = ids2.findIndex((id) => `${id}` === `${item.id}`);
if (index > -1) {
ids2.splice(index, 1);
nodes.push(item);
}
if (item.items) get(ids2, item.items);
}
};
get(ids, data);
return nodes;
};
var getDepKeys = (dataSourceDeps = {}, nodeId) => Array.from(Object.values(dataSourceDeps).reduce((prev, cur) => {
(cur[nodeId]?.keys || []).forEach((key) => prev.add(key));
return prev;
}, /* @__PURE__ */ new Set()));
var getDepNodeIds = (dataSourceDeps = {}) => Array.from(Object.values(dataSourceDeps).reduce((prev, cur) => {
Object.keys(cur).forEach((id) => {
prev.add(id);
});
return prev;
}, /* @__PURE__ */ new Set()));
var replaceChildNode = (newNode, data, parentId) => {
const path = getNodePath(newNode.id, data);
const node = path.pop();
let parent = path.pop();
if (parentId) parent = getNodePath(parentId, data).pop();
if (!node) {
console.warn(`未找到目标节点(${newNode.id})`);
return;
}
if (!parent) {
console.warn(`未找到父节点(${newNode.id})`);
return;
}
const index = parent.items?.findIndex((child) => child.id === node.id);
parent.items.splice(index, 1, newNode);
};
var DSL_NODE_KEY_COPY_PREFIX = "__tmagic__";
var compiledNode = (compile, node, dataSourceDeps = {}, sourceId) => {
let keys = [];
if (!sourceId) keys = getDepKeys(dataSourceDeps, node.id);
else keys = dataSourceDeps[sourceId]?.[node.id].keys || [];
keys.forEach((key) => {
const keys2 = getKeysArray(key);
const cacheKey = keys2.map((key2, index) => {
if (index < keys2.length - 1) return key2;
return `${DSL_NODE_KEY_COPY_PREFIX}${key2}`;
});
let templateValue = getValueByKeyPath(cacheKey, node);
if (typeof templateValue === "undefined") try {
const value = getValueByKeyPath(key, node);
setValueByKeyPath(cacheKey.join("."), value, node);
templateValue = value;
} catch (e) {
console.warn(e);
return;
}
let newValue;
try {
newValue = compile(templateValue);
} catch (e) {
console.error(e);
newValue = "";
}
setValueByKeyPath(key, newValue, node);
});
return node;
};
var compiledCond = (op, fieldValue, inputValue, range = []) => {
if (typeof fieldValue === "string" && typeof inputValue === "undefined") inputValue = "";
switch (op) {
case "is": return fieldValue === inputValue;
case "not": return fieldValue !== inputValue;
case "=": return fieldValue === inputValue;
case "!=": return fieldValue !== inputValue;
case ">": return fieldValue > inputValue;
case ">=": return fieldValue >= inputValue;
case "<": return fieldValue < inputValue;
case "<=": return fieldValue <= inputValue;
case "between": return range.length > 1 && fieldValue >= range[0] && fieldValue <= range[1];
case "not_between": return range.length < 2 || fieldValue < range[0] || fieldValue > range[1];
case "include": return fieldValue?.includes?.(inputValue);
case "not_include": return typeof fieldValue === "undefined" || !fieldValue.includes?.(inputValue);
}
return false;
};
var getDefaultValueFromFields = (fields) => {
const data = {};
const defaultValue = {
string: void 0,
object: {},
array: [],
boolean: void 0,
number: void 0,
null: null,
any: void 0
};
fields.forEach((field) => {
if (typeof field.defaultValue !== "undefined") {
if (field.type === "array" && !Array.isArray(field.defaultValue)) {
data[field.name] = defaultValue.array;
return;
}
if (field.type === "object" && !isObject(field.defaultValue)) {
if (typeof field.defaultValue === "string") {
try {
data[field.name] = JSON.parse(field.defaultValue);
} catch (e) {
data[field.name] = defaultValue.object;
console.warn("defaultValue 解析失败", field.defaultValue, e);
}
return;
}
data[field.name] = defaultValue.object;
return;
}
data[field.name] = cloneDeep(field.defaultValue);
return;
}
if (field.type === "object") {
data[field.name] = field.fields ? getDefaultValueFromFields(field.fields) : defaultValue.object;
return;
}
if (field.type) {
data[field.name] = defaultValue[field.type];
return;
}
data[field.name] = void 0;
});
return data;
};
var DATA_SOURCE_FIELDS_SELECT_VALUE_PREFIX = "ds-field::";
var DATA_SOURCE_FIELDS_CHANGE_EVENT_PREFIX = "ds-field-changed";
var dataSourceTemplateRegExp = /\$\{([\s\S]+?)\}/g;
var traverseNode = (node, cb, parents = [], evalCbAfter = false) => {
if (!evalCbAfter) cb(node, parents);
if (Array.isArray(node.items) && node.items.length) {
parents.push(node);
node.items.forEach((item) => {
traverseNode(item, cb, [...parents], evalCbAfter);
});
}
if (evalCbAfter) cb(node, parents);
};
var isValueIncludeDataSource = (value) => {
if (typeof value === "string" && /\$\{([\s\S]+?)\}/.test(value)) return true;
if (Array.isArray(value) && `${value[0]}`.startsWith("ds-field::")) return true;
if (value?.isBindDataSource && value.dataSourceId) return true;
if (value?.isBindDataSourceField && value.dataSourceId) return true;
return false;
};
//#endregion
//#region ../../node_modules/.pnpm/@tmagic+dep@1.7.7_@tmagic+schema@1.7.7_typescript@5.9.3__@tmagic+utils@1.7.7_@tmagic+sc_3a75c4de620d9af1865f72150ddb758c/node_modules/@tmagic/dep/dist/tmagic-dep.js
var DepTargetType = /* @__PURE__ */ ((DepTargetType2) => {
DepTargetType2["DEFAULT"] = "default";
DepTargetType2["CODE_BLOCK"] = "code-block";
DepTargetType2["DATA_SOURCE"] = "data-source";
DepTargetType2["DATA_SOURCE_METHOD"] = "data-source-method";
DepTargetType2["DATA_SOURCE_COND"] = "data-source-cond";
return DepTargetType2;
})(DepTargetType || {});
var Target = class {
/**
* 如何识别目标
*/
isTarget;
/**
* 目标id不可重复
* 例如目标是代码块则为代码块id
*/
id;
/**
* 目标名称,用于显示在依赖列表中
*/
name;
/**
* 不同的目标可以进行分类例如代码块数据源可以为两个不同的type
*/
type = DepTargetType.DEFAULT;
/**
* 依赖详情
* 实例:{ 'node_id': { name: 'node_name', keys: [ created, mounted ] } }
*/
deps = {};
/**
* 是否默认收集默认为true当值为false时需要传入type参数给collect方法才会被收集
*/
isCollectByDefault;
constructor(options) {
this.isTarget = options.isTarget;
this.id = options.id;
this.name = options.name;
this.isCollectByDefault = options.isCollectByDefault ?? true;
if (options.type) this.type = options.type;
if (options.initialDeps) this.deps = options.initialDeps;
}
/**
* 更新依赖
* @param option 节点配置
* @param key 哪个key配置了这个目标的id
*/
updateDep({ id, name, key, data }) {
const dep = this.deps[id] || {
name,
keys: []
};
dep.name = name;
dep.data = data;
this.deps[id] = dep;
if (dep.keys.indexOf(key) === -1) dep.keys.push(key);
}
/**
* 删除依赖
* @param node 哪个节点的依赖需要移除,如果为空,则移除所有依赖
* @param key 节点下哪个key需要移除如果为空则移除改节点下的所有依赖key
* @returns void
*/
removeDep(id, key) {
if (typeof id === "undefined") {
Object.keys(this.deps).forEach((depKey) => {
delete this.deps[depKey];
});
return;
}
const dep = this.deps[id];
if (!dep) return;
if (key) {
const index = dep.keys.indexOf(key);
dep.keys.splice(index, 1);
if (dep.keys.length === 0) delete this.deps[id];
} else delete this.deps[id];
}
/**
* 判断指定节点下的指定key是否存在在依赖列表中
* @param node 哪个节点
* @param key 哪个key
* @returns boolean
*/
hasDep(id, key) {
const dep = this.deps[id];
return Boolean(dep?.keys.find((d) => d === key));
}
destroy() {
this.deps = {};
}
};
var isIncludeArrayField = (keys, fields) => {
let f = fields;
return keys.some((key, index) => {
const field = f.find(({ name }) => name === key);
f = field?.fields || [];
return field?.type === "array" && /^(?!\d+$).*$/.test(`${keys[index + 1]}`) && index < keys.length - 1;
});
};
var isDataSourceTemplate = (value, ds, hasArray = false) => {
const templates = value.match(dataSourceTemplateRegExp) || [];
if (templates.length <= 0) return false;
const arrayFieldTemplates = [];
const fieldTemplates = [];
templates.forEach((tpl) => {
const keys = getKeysArray(tpl.substring(2, tpl.length - 1));
const dsId = keys.shift();
if (!dsId || dsId !== ds.id) return;
if (isIncludeArrayField(keys, ds.fields)) arrayFieldTemplates.push(tpl);
else fieldTemplates.push(tpl);
});
if (hasArray) return arrayFieldTemplates.length > 0;
return fieldTemplates.length > 0;
};
var isSpecificDataSourceTemplate = (value, dsId) => value?.isBindDataSourceField && value.dataSourceId && value.dataSourceId === dsId && typeof value.template === "string";
var isUseDataSourceField = (value, id) => {
if (!Array.isArray(value) || typeof value[0] !== "string") return false;
const [prefixId] = value;
const prefixIndex = prefixId.indexOf(DATA_SOURCE_FIELDS_SELECT_VALUE_PREFIX);
if (prefixIndex === -1) return false;
return prefixId.substring(prefixIndex + DATA_SOURCE_FIELDS_SELECT_VALUE_PREFIX.length) === id;
};
var isDataSourceTarget = (ds, key, value, hasArray = false) => {
if (!value || !["string", "object"].includes(typeof value)) return false;
if (`${key}`.startsWith("displayConds")) return false;
if (typeof value === "string") return isDataSourceTemplate(value, ds, hasArray);
if (isObject(value) && value?.isBindDataSource && value.dataSourceId && value.dataSourceId === ds.id) return true;
if (isSpecificDataSourceTemplate(value, ds.id)) return true;
if (isUseDataSourceField(value, ds.id)) {
const [, ...keys] = value;
const includeArray = isIncludeArrayField(keys, ds.fields);
if (hasArray) return includeArray;
return !includeArray;
}
return false;
};
var isDataSourceCondTarget = (ds, key, value, hasArray = false) => {
if (!Array.isArray(value) || !ds) return false;
const [dsId, ...keys] = value;
if (dsId !== ds.id || !`${key}`.startsWith("displayConds")) return false;
if (ds.fields?.find((field) => field.name === keys[0])) {
const includeArray = isIncludeArrayField(keys, ds.fields);
if (hasArray) return includeArray;
return !includeArray;
}
return false;
};
var traverseTarget = (targetsList, cb, type) => {
for (const targets of Object.values(targetsList)) for (const target of Object.values(targets)) {
if (type && target.type !== type) continue;
cb(target);
}
};
var Watcher = class {
targetsList = {};
childrenProp = "items";
idProp = "id";
nameProp = "name";
constructor(options) {
if (options?.initialTargets) this.targetsList = options.initialTargets;
if (options?.childrenProp) this.childrenProp = options.childrenProp;
}
getTargetsList() {
return this.targetsList;
}
/**
* 获取指定类型中的所有target
* @param type 分类
* @returns Target[]
*/
getTargets(type = DepTargetType.DEFAULT) {
return this.targetsList[type] || {};
}
/**
* 添加新的目标
* @param target Target
*/
addTarget(target) {
const targets = this.getTargets(target.type) || {};
this.targetsList[target.type] = targets;
targets[target.id] = target;
}
/**
* 获取指定id的target
* @param id target id
* @returns Target
*/
getTarget(id, type = DepTargetType.DEFAULT) {
return this.getTargets(type)[id];
}
/**
* 判断是否存在指定id的target
* @param id target id
* @returns boolean
*/
hasTarget(id, type = DepTargetType.DEFAULT) {
return Boolean(this.getTarget(id, type));
}
/**
* 判断是否存在指定类型的target
* @param type target type
* @returns boolean
*/
hasSpecifiedTypeTarget(type = DepTargetType.DEFAULT) {
return Object.keys(this.getTargets(type)).length > 0;
}
/**
* 删除指定id的target
* @param id target id
*/
removeTarget(id, type = DepTargetType.DEFAULT) {
const targets = this.getTargets(type);
if (targets[id]) {
targets[id].destroy();
delete targets[id];
}
}
/**
* 删除指定分类的所有target
* @param type 分类
* @returns void
*/
removeTargets(type = DepTargetType.DEFAULT) {
const targets = this.targetsList[type];
if (!targets) return;
for (const target of Object.values(targets)) target.destroy();
delete this.targetsList[type];
}
/**
* 删除所有target
*/
clearTargets() {
for (const key of Object.keys(this.targetsList)) delete this.targetsList[key];
}
/**
* 收集依赖
* @param nodes 需要收集的节点
* @param deep 是否需要收集子节点
* @param type 强制收集指定类型的依赖
*/
collect(nodes, depExtendedData = {}, deep = false, type) {
this.collectByCallback(nodes, type, ({ node, target }) => {
this.removeTargetDep(target, node);
this.collectItem(node, target, depExtendedData, deep);
});
}
collectByCallback(nodes, type, cb) {
traverseTarget(this.targetsList, (target) => {
if (!type && !target.isCollectByDefault) return;
for (const node of nodes) cb({
node,
target
});
}, type);
}
/**
* 清除所有目标的依赖
* @param nodes 需要清除依赖的节点
*/
clear(nodes, type) {
let { targetsList } = this;
if (type) targetsList = { [type]: this.getTargets(type) };
const clearedItemsNodeIds = [];
traverseTarget(targetsList, (target) => {
if (nodes) for (const node of nodes) {
target.removeDep(node[this.idProp]);
if (Array.isArray(node[this.childrenProp]) && node[this.childrenProp].length && !clearedItemsNodeIds.includes(node[this.idProp])) {
clearedItemsNodeIds.push(node[this.idProp]);
this.clear(node[this.childrenProp]);
}
}
else target.removeDep();
});
}
/**
* 清除指定类型的依赖
* @param type 类型
* @param nodes 需要清除依赖的节点
*/
clearByType(type, nodes) {
this.clear(nodes, type);
}
collectItem(node, target, depExtendedData = {}, deep = false) {
const dataSourceTargetTypes = [
DepTargetType.DATA_SOURCE,
DepTargetType.DATA_SOURCE_COND,
DepTargetType.DATA_SOURCE_METHOD
];
if (node["_tmagic_node_disabled_data_source"] && dataSourceTargetTypes.includes(target.type)) return;
if (node["_tmagic_node_disabled_code_block"] && target.type === DepTargetType.CODE_BLOCK) return;
const collectTarget = (config, prop = "") => {
const doCollect = (key, value) => {
const keyIsItems = key === this.childrenProp;
const fullKey = prop ? `${prop}.${key}` : key;
if (target.isTarget(fullKey, value)) target.updateDep({
id: node[this.idProp],
name: `${node[this.nameProp] || node[this.idProp]}`,
data: depExtendedData,
key: fullKey
});
else if (!keyIsItems && Array.isArray(value)) for (let i = 0, l = value.length; i < l; i++) {
const item = value[i];
if (isObject(item)) collectTarget(item, `${fullKey}[${i}]`);
}
else if (isObject(value)) collectTarget(value, fullKey);
if (keyIsItems && deep && Array.isArray(value)) for (const child of value) this.collectItem(child, target, depExtendedData, deep);
};
for (const [key, value] of Object.entries(config)) {
if (typeof value === "undefined" || value === "") continue;
doCollect(key, value);
}
};
collectTarget(node);
}
removeTargetDep(target, node, key) {
target.removeDep(node[this.idProp], key);
if (typeof key === "undefined" && Array.isArray(node[this.childrenProp]) && node[this.childrenProp].length) for (const item of node[this.childrenProp]) this.removeTargetDep(target, item, key);
}
};
//#endregion
//#region ../../node_modules/.pnpm/@tmagic+core@1.7.7_typescript@5.9.3/node_modules/@tmagic/core/dist/tmagic-core.js
var Env = class {
isIos = false;
isIphone = false;
isIpad = false;
isAndroid = false;
isAndroidPad = false;
isMac = false;
isWin = false;
isMqq = false;
isWechat = false;
isWeb = false;
isOpenHarmony = false;
constructor(ua = globalThis.navigator?.userAgent ?? "", options = {}) {
if (!ua) return;
this.isIphone = ua.indexOf("iPhone") >= 0;
this.isIpad = /(iPad).*OS\s([\d_]+)/.test(ua);
this.isIos = this.isIphone || this.isIpad;
this.isAndroid = ua.indexOf("Android") >= 0;
this.isAndroidPad = this.isAndroid && ua.indexOf("Mobile") < 0;
this.isMac = ua.indexOf("Macintosh") >= 0;
this.isWin = ua.indexOf("Windows") >= 0;
this.isMqq = /QQ\/([\d.]+)/.test(ua);
this.isWechat = ua.indexOf("MicroMessenger") >= 0 && ua.indexOf("wxwork") < 0;
this.isOpenHarmony = ua.includes("OpenHarmony");
this.isWeb = !this.isIos && !this.isAndroid && !this.isOpenHarmony && !/(WebOS|BlackBerry)/.test(ua);
Object.entries(options).forEach(([key, value]) => {
this[key] = value;
});
}
};
var FlowState = class {
isAbort;
constructor() {
this.isAbort = false;
}
abort() {
this.isAbort = true;
}
reset() {
this.isAbort = false;
}
};
var EventHelper = class extends import_events.EventEmitter {
app;
eventQueue = [];
nodeEventList = /* @__PURE__ */ new Map();
dataSourceEventList = /* @__PURE__ */ new Map();
beforeEventHandler;
afterEventHandler;
constructor({ app, beforeEventHandler, afterEventHandler }) {
super();
this.beforeEventHandler = beforeEventHandler;
this.afterEventHandler = afterEventHandler;
this.app = app;
}
destroy() {
this.removeNodeEvents();
this.removeAllListeners();
this.nodeEventList.clear();
this.dataSourceEventList.clear();
}
initEvents() {
this.removeNodeEvents();
if (this.app.page) for (const [, node] of this.app.page.nodes) this.bindNodeEvents(node);
for (const [, page] of this.app.pageFragments) for (const [, node] of page.nodes) this.bindNodeEvents(node);
}
bindNodeEvents(node) {
node.events?.forEach((event, index) => {
if (!event.name) return;
let eventNameKey = `${event.name}_${node.data.id}`;
const eventNames = event.name.split(".");
if (eventNames.length > 1) eventNameKey = `${eventNames[1]}_${eventNames[0]}`;
let eventName = Symbol(eventNameKey);
if (node.eventKeys.has(eventNameKey)) eventName = node.eventKeys.get(eventNameKey);
else node.eventKeys.set(eventNameKey, eventName);
const eventHandler = (_fromCpt, ...args) => {
this.eventHandler(index, node, args);
};
this.nodeEventList.set(eventHandler, eventName);
this.on(eventName, eventHandler);
});
}
removeNodeEvents() {
for (const handler of Array.from(this.nodeEventList.keys())) {
const name = this.nodeEventList.get(handler);
name && this.off(name, handler);
}
this.nodeEventList.clear();
}
bindDataSourceEvents() {
const dataSourceList = Array.from(this.app.dataSourceManager?.dataSourceMap.values() || []);
this.removeDataSourceEvents(dataSourceList);
for (const dataSource of dataSourceList) {
const dataSourceEvent = this.dataSourceEventList.get(dataSource.id) ?? /* @__PURE__ */ new Map();
for (const event of dataSource.schema.events || []) {
const [prefix, ...path] = event.name?.split(".") || [];
if (!prefix) return;
const handler = (...args) => {
this.eventHandler(event, dataSource, args);
};
dataSourceEvent.set(event.name, handler);
if (prefix === "ds-field-changed") dataSource?.onDataChange(path.join("."), handler);
else dataSource.on(prefix, handler);
}
this.dataSourceEventList.set(dataSource.id, dataSourceEvent);
}
}
removeDataSourceEvents(dataSourceList) {
if (!this.dataSourceEventList.size) return;
for (const dataSource of dataSourceList) {
const dataSourceEvent = this.dataSourceEventList.get(dataSource.id);
if (!dataSourceEvent) return;
for (const eventName of Array.from(dataSourceEvent.keys())) {
const [prefix, ...path] = eventName.split(".");
if (prefix === "ds-field-changed") dataSource.offDataChange(path.join("."), dataSourceEvent.get(eventName));
else dataSource.off(prefix, dataSourceEvent.get(eventName));
}
}
this.dataSourceEventList.clear();
}
getEventQueue() {
return this.eventQueue;
}
addEventToQueue(event) {
this.eventQueue.push(event);
}
/**
* 事件联动处理函数
* @param eventsConfigIndex 事件配置索引可以通过此索引从node.event中获取最新事件配置
* @param fromCpt 触发事件的组件
* @param args 事件参数
*/
async eventHandler(config, fromCpt, args) {
const eventConfig = typeof config === "number" ? fromCpt.events[config] : config;
if (typeof this.beforeEventHandler === "function") this.beforeEventHandler({
eventConfig,
source: fromCpt,
args
});
if (has(eventConfig, "actions")) {
const flowState = new FlowState();
const { actions } = eventConfig;
for (let i = 0; i < actions.length; i++) {
if (flowState?.isAbort) break;
if (typeof config === "number") {
const actionItem = fromCpt.events[config].actions[i];
await this.actionHandler(actionItem, fromCpt, args, flowState);
} else await this.actionHandler(actions[i], fromCpt, args, flowState);
}
flowState.reset();
} else try {
await this.compActionHandler(eventConfig, fromCpt, args);
} catch (e) {
if (this.app.errorHandler) this.app.errorHandler(e, fromCpt, {
type: "action-handler",
config: eventConfig,
...args
});
else throw e;
}
if (typeof this.afterEventHandler === "function") this.afterEventHandler({
eventConfig,
source: fromCpt,
args
});
}
async actionHandler(actionItem, fromCpt, args, flowState) {
try {
if (actionItem.actionType === ActionType.COMP) {
const compActionItem = actionItem;
await this.compActionHandler(compActionItem, fromCpt, args);
} else if (actionItem.actionType === ActionType.CODE) {
if (fromCpt.data["_tmagic_node_disabled_code_block"]) return;
const codeActionItem = actionItem;
await this.app.runCode(codeActionItem.codeId, codeActionItem.params || {}, args, flowState);
} else if (actionItem.actionType === ActionType.DATA_SOURCE) {
if (fromCpt.data["_tmagic_node_disabled_data_source"]) return;
const dataSourceActionItem = actionItem;
const [dsId, methodName] = dataSourceActionItem.dataSourceMethod;
await this.app.runDataSourceMethod(dsId, methodName, dataSourceActionItem.params || {}, args, flowState);
}
} catch (e) {
if (this.app.errorHandler) this.app.errorHandler(e, fromCpt, {
type: "action-handler",
config: actionItem,
flowState,
...args
});
else throw e;
}
}
/**
* 执行联动组件动作
* @param eventConfig 联动组件的配置
* @returns void
*/
async compActionHandler(eventConfig, fromCpt, args) {
if (!this.app.page) throw new Error("当前没有页面");
let { method: methodName, to } = eventConfig;
if (Array.isArray(methodName)) [to, methodName] = methodName;
const toNodes = [];
const toNode = this.app.getNode(to, { strict: true });
if (toNode) toNodes.push(toNode);
for (const [, page] of this.app.pageFragments) {
const node = page.getNode(to, { strict: true });
if (node) toNodes.push(node);
}
if (toNodes.length === 0) {
this.addEventToQueue({
toId: to,
method: methodName,
fromCpt,
args
});
return;
}
const instanceMethodPromise = [];
for (const node of toNodes) if (node.instance) {
if (typeof node.instance[methodName] === "function") instanceMethodPromise.push(node.instance[methodName](fromCpt, ...args));
} else node.addEventToQueue({
method: methodName,
fromCpt,
args
});
await Promise.all(instanceMethodPromise);
}
};
var Flexible = class {
designWidth = 375;
tid;
constructor(options) {
if (globalThis.document.readyState === "complete") this.setBodyFontSize();
else globalThis.document.addEventListener("DOMContentLoaded", this.setBodyFontSize, false);
globalThis.addEventListener("resize", this.resizeHandler, false);
globalThis.addEventListener("pageshow", this.pageshowHandler, false);
if (typeof options?.designWidth !== "undefined") this.setDesignWidth(options.designWidth);
}
destroy() {
globalThis.document.removeEventListener("DOMContentLoaded", this.setBodyFontSize, false);
globalThis.removeEventListener("resize", this.resizeHandler, false);
globalThis.removeEventListener("pageshow", this.pageshowHandler, false);
}
setDesignWidth(width) {
this.designWidth = width;
this.refreshRem();
}
setBodyFontSize() {
globalThis.document.body.style.fontSize = ".12rem";
}
refreshRem() {
const { width } = document.documentElement.getBoundingClientRect();
const fontSize = width / (this.designWidth / 100);
globalThis.document.documentElement.style.fontSize = `${fontSize}px`;
globalThis.document.documentElement.style.fontSize = `${this.correctRem(fontSize)}px`;
}
/**
* 纠正由于文字缩放导致的字体大小计算不正确问题
* @param {number} fontSize
* @returns {number}
*/
correctRem(fontSize) {
const { document: document2 } = globalThis;
const d = document2.createElement("div");
d.style.cssText = "width:1rem;height:0;overflow:hidden;position:absolute;z-index:-1;visibility:hidden;";
document2.documentElement.appendChild(d);
const dw = d.offsetWidth;
document2.documentElement.removeChild(d);
if (Math.abs(dw - fontSize) > 1) return fontSize ** 2 / dw;
return fontSize;
}
resizeHandler = () => {
clearTimeout(this.tid);
this.tid = setTimeout(() => {
this.refreshRem();
this.tid = void 0;
}, 300);
};
pageshowHandler = (e) => {
if (e.persisted) this.resizeHandler();
};
};
var Store = class {
data;
constructor({ initialData = {} } = {}) {
this.data = initialData;
}
set(key, value) {
this.data[key] = value;
}
get(key) {
return this.data[key];
}
};
var Node = class extends import_events.EventEmitter {
data;
style;
events = [];
instance = null;
page;
parent;
app;
store;
eventKeys = /* @__PURE__ */ new Map();
eventQueue = [];
constructor(options) {
super();
this.store = new Store({ initialData: options.app.nodeStoreInitialData?.() || {} });
this.page = options.page;
this.parent = options.parent;
this.app = options.app;
this.setData(options.config);
this.listenLifeSafe();
}
setData(data) {
this.data = data;
const { events, style } = data;
this.events = events || [];
this.style = style || {};
try {
if (this.instance && !Object.isFrozen(this.instance) && Object.getOwnPropertyDescriptor(this.instance, "config")?.writable !== false && !this.instance.__isVue) this.instance.config = data;
} catch (e) {}
this.emit("update-data", data);
}
addEventToQueue(event) {
this.eventQueue.push(event);
}
/**
* @deprecated use setInstance instead
*/
registerMethod(methods) {
if (!methods) return;
if (!this.instance) this.instance = {};
for (const [key, fn] of Object.entries(methods)) if (typeof fn === "function") this.instance[key] = fn;
}
setInstance(instance) {
this.instance = instance;
}
async runHookCode(hook, params) {
if (typeof this.data[hook] === "function") {
await this.data[hook](this);
return;
}
const hookData = this.data[hook];
if (hookData?.hookType !== HookType.CODE) return;
for (const item of hookData.hookData) {
const { codeType = HookCodeType.CODE, codeId, params: itemParams = {} } = item;
if (codeType === HookCodeType.CODE && typeof codeId === "string") await this.app.runCode(codeId, params || itemParams, [], void 0, this);
else if (codeType === HookCodeType.DATA_SOURCE_METHOD && Array.isArray(codeId) && codeId.length > 1) await this.app.runDataSourceMethod(codeId[0], codeId[1], params || itemParams, [], void 0, this);
}
}
destroy() {
this.eventQueue.length = 0;
this.instance = null;
this.events = [];
this.style = {};
this.removeAllListeners();
}
listenLifeSafe() {
this.once("created", (instance) => {
this.once("destroy", () => {
this.instance = null;
if (this.data["_tmagic_node_disabled_code_block"] !== true) this.runHookCode("destroy");
this.listenLifeSafe();
});
if (instance) this.setInstance(instance);
if (this.data["_tmagic_node_disabled_code_block"] !== true) this.runHookCode("created");
});
this.once("mounted", (instance) => {
const handler = async () => {
if (instance) this.setInstance(instance);
for (let eventConfig = this.eventQueue.shift(); eventConfig; eventConfig = this.eventQueue.shift()) if (typeof instance[eventConfig.method] === "function") await instance[eventConfig.method](eventConfig.fromCpt, ...eventConfig.args);
if (this.app.eventHelper) {
for (const eventConfig of this.app.eventHelper.getEventQueue()) for (const [, page] of this.app.pageFragments) {
const node = page.getNode(eventConfig.toId, { strict: true });
if (node && node === this) {
if (typeof instance[eventConfig.method] === "function") await instance[eventConfig.method](eventConfig.fromCpt, ...eventConfig.args);
eventConfig.handled = true;
}
}
this.app.eventHelper.eventQueue = this.app.eventHelper.getEventQueue().filter((eventConfig) => !eventConfig.handled);
}
if (this.data["_tmagic_node_disabled_code_block"] !== true) this.runHookCode("mounted");
};
handler();
});
}
};
var IteratorContainer = class IteratorContainer extends Node {
nodes = [];
setData(data) {
this.resetNodes();
super.setData(data);
}
resetNodes() {
this.nodes?.forEach((nodeMap) => {
nodeMap.forEach((node) => {
node.destroy();
});
});
this.nodes = [];
}
initNode(config, parent, map) {
if (map.has(config.id)) map.get(config.id)?.destroy();
if (config.type && this.app.iteratorContainerType.has(config.type)) {
const iteratorContainer = new IteratorContainer({
config,
parent,
page: this.page,
app: this.app
});
map.set(config.id, iteratorContainer);
this.app.eventHelper?.bindNodeEvents(iteratorContainer);
return;
}
const node = new Node({
config,
parent,
page: this.page,
app: this.app
});
this.app.eventHelper?.bindNodeEvents(node);
map.set(config.id, node);
if (config.type && this.app.pageFragmentContainerType.has(config.type) && config.pageFragmentId) {
const pageFragment = this.app.dsl?.items?.find((page) => page.id === config.pageFragmentId);
if (pageFragment) config.items = [pageFragment];
}
config.items?.forEach((element) => {
this.initNode(element, node, map);
});
}
setNodes(nodes, index) {
const map = this.nodes[index] || /* @__PURE__ */ new Map();
nodes.forEach((node) => {
this.initNode(node, this, map);
});
this.nodes[index] = map;
}
getNode(id, index) {
return this.nodes[index]?.get(id);
}
destroy() {
super.destroy();
this.resetNodes();
}
};
var Page = class Page extends Node {
nodes = /* @__PURE__ */ new Map();
constructor(options) {
super(options);
this.setNode(options.config.id, this);
options.config.items.forEach((config) => {
this.initNode(config, this);
});
}
initNode(config, parent) {
if (config.type && this.app.iteratorContainerType.has(config.type)) {
this.setNode(config.id, new IteratorContainer({
config,
parent,
page: this,
app: this.app
}));
return;
}
const node = new (config.type && (App.nodeClassMap.get(config.type)) || Node)({
config,
parent,
page: this,
app: this.app
});
this.setNode(config.id, node);
if (config.type && this.app.pageFragmentContainerType.has(config.type) && config.pageFragmentId) {
const pageFragment = this.app.dsl?.items?.find((page) => page.id === config.pageFragmentId);
if (pageFragment) this.app.pageFragments.set(config.id, new Page({
config: pageFragment,
app: this.app
}));
}
config.items?.forEach((element) => {
this.initNode(element, node);
});
}
getNode(id, { iteratorContainerId, iteratorIndex, pageFragmentContainerId, strict } = {}) {
if (this.nodes.has(id)) return this.nodes.get(id);
if (pageFragmentContainerId) return this.app.pageFragments.get(pageFragmentContainerId)?.getNode(id, {
iteratorContainerId,
iteratorIndex,
strict: true
});
if (Array.isArray(iteratorContainerId) && iteratorContainerId.length && Array.isArray(iteratorIndex)) {
let iteratorContainer = this.nodes.get(iteratorContainerId[0]);
for (let i = 1, l = iteratorContainerId.length; i < l; i++) iteratorContainer = iteratorContainer?.getNode(iteratorContainerId[i], iteratorIndex[i - 1]);
return iteratorContainer?.getNode(id, iteratorIndex[iteratorIndex.length - 1]);
}
if (!strict && this.app.pageFragments.size) {
for (const [, pageFragment] of this.app.pageFragments) if (pageFragment.nodes.has(id)) return pageFragment.nodes.get(id);
}
}
setNode(id, node) {
this.nodes.set(id, node);
}
deleteNode(id) {
this.nodes.delete(id);
}
destroy() {
this.nodes.forEach((node) => {
if (node === this) return;
node.destroy();
});
this.nodes.clear();
super.destroy();
}
};
var style2Obj = (style) => {
if (typeof style !== "string") return style;
const obj = {};
style.split(";").forEach((element) => {
if (!element) return;
const items = element.split(":");
let key = items.shift();
let value = items.join(":");
if (!key) return;
key = key.replace(/^\s*/, "").replace(/\s*$/, "");
value = value.replace(/^\s*/, "").replace(/\s*$/, "");
key = key.split("-").map((v, i) => i > 0 ? `${v[0].toUpperCase()}${v.substr(1)}` : v).join("");
obj[key] = value;
});
return obj;
};
var fillBackgroundImage = (value) => {
if (value && !/^url/.test(value) && !/^linear-gradient/.test(value)) return `url(${value})`;
return value;
};
var getTransform = (value, jsEngine) => {
if (!value) return [];
const transform = Object.entries(value).map(([transformKey, transformValue]) => {
if (!transformValue.trim()) return "";
if (transformKey === "rotate" && isNumber(transformValue)) transformValue = `${transformValue}deg`;
return jsEngine !== "hippy" ? `${transformKey}(${transformValue})` : { [transformKey]: transformValue };
});
if (jsEngine === "hippy") return transform;
const values = transform.join(" ");
return !values.trim() ? "none" : values;
};
var transformStyle = (style, jsEngine) => {
if (!style) return {};
let styleObj = {};
const results = {};
if (typeof style === "string") styleObj = style2Obj(style);
else styleObj = { ...style };
const isHippy = jsEngine === "hippy";
const whiteList = [
"zIndex",
"opacity",
"fontWeight"
];
Object.entries(styleObj).forEach(([key, value]) => {
if (key === "scale" && !results.transform && isHippy) results.transform = [{ scale: value }];
else if (key === "backgroundImage" && !isHippy) value && (results[key] = fillBackgroundImage(value));
else if (key === "transform" && typeof value !== "string") results[key] = getTransform(value, jsEngine);
else if (!whiteList.includes(key) && value && /^[-]?[0-9]*[.]?[0-9]*$/.test(value)) results[key] = isHippy ? value : `${value / 100}rem`;
else results[key] = value;
});
return results;
};
var COMMON_EVENT_PREFIX = "magic:common:events:";
var COMMON_METHOD_PREFIX = "magic:common:actions:";
var App = class App extends import_events.EventEmitter {
static nodeClassMap = /* @__PURE__ */ new Map();
static registerNode(type, NodeClass) {
App.nodeClassMap.set(type, NodeClass);
}
env;
dsl;
codeDsl;
dataSourceManager;
page;
pageFragments = /* @__PURE__ */ new Map();
useMock = false;
platform = "mobile";
jsEngine = "browser";
components = /* @__PURE__ */ new Map();
pageFragmentContainerType = /* @__PURE__ */ new Set(["page-fragment-container"]);
iteratorContainerType = /* @__PURE__ */ new Set(["iterator-container"]);
request;
transformStyle;
eventHelper;
errorHandler;
nodeStoreInitialData;
flexible;
constructor(options) {
super();
if (options.env) this.setEnv(options.env);
else this.setEnv(options.ua);
this.errorHandler = options.errorHandler;
this.codeDsl = options.config?.codeBlocks;
options.platform && (this.platform = options.platform);
options.jsEngine && (this.jsEngine = options.jsEngine);
options.nodeStoreInitialData && (this.nodeStoreInitialData = options.nodeStoreInitialData);
if (options.pageFragmentContainerType) (Array.isArray(options.pageFragmentContainerType) ? options.pageFragmentContainerType : [options.pageFragmentContainerType]).forEach((type) => {
this.pageFragmentContainerType.add(type);
});
if (options.iteratorContainerType) (Array.isArray(options.iteratorContainerType) ? options.iteratorContainerType : [options.iteratorContainerType]).forEach((type) => {
this.iteratorContainerType.add(type);
});
if (typeof options.useMock === "boolean") this.useMock = options.useMock;
if (this.jsEngine === "browser" && !options.disabledFlexible) this.flexible = new Flexible({ designWidth: options.designWidth });
if (this.platform !== "editor") this.eventHelper = new EventHelper({
app: this,
beforeEventHandler: options.beforeEventHandler,
afterEventHandler: options.afterEventHandler
});
this.transformStyle = options.transformStyle || ((style) => transformStyle(style, this.jsEngine));
if (options.request) this.request = options.request;
if (options.config) this.setConfig(options.config, options.curPage, options.dataSourceManagerInitialData);
}
setEnv(ua) {
if (!ua || typeof ua === "string") this.env = new Env(ua);
else this.env = ua;
}
setDesignWidth(width) {
this.flexible?.setDesignWidth(width);
}
/**
* 设置dsl
* @param config dsl跟节点
* @param curPage 当前页面id
* @param initialData 数据源初始数据源
*/
setConfig(config, curPage, initialData) {
this.dsl = config;
if (!curPage && config.items.length) curPage = config.items[0].id;
if (this.dataSourceManager) this.dataSourceManager.destroy();
this.dataSourceManager = createDataSourceManager(this, this.useMock, initialData);
this.codeDsl = config.codeBlocks;
const pageId = curPage || this.page?.data?.id;
super.emit("dsl-change", {
dsl: config,
curPage: pageId
});
this.pageFragments.forEach((page) => {
page.destroy();
});
this.pageFragments.clear();
this.setPage(pageId);
if (this.dataSourceManager) if (this.dataSourceManager.isAllDataSourceRegistered()) this.eventHelper?.bindDataSourceEvents();
else this.dataSourceManager.once("registered-all", () => {
this.eventHelper?.bindDataSourceEvents();
});
}
setPage(id) {
const pageConfig = this.dsl?.items.find((page) => `${page.id}` === `${id}`);
if (!pageConfig) {
this.deletePage();
super.emit("page-change");
return;
}
if (this.page) {
if (pageConfig === this.page.data) return;
this.page.destroy();
}
this.page = new Page({
config: pageConfig,
app: this
});
this.eventHelper?.initEvents();
super.emit("page-change", this.page);
}
deletePage() {
this.page?.destroy();
this.eventHelper?.removeNodeEvents();
this.page = void 0;
}
/**
* 兼容id参数
* @param id 节点id
* @returns Page | void
*/
getPage(id) {
if (!id) return this.page;
if (this.page && `${this.page.data.id}` === `${id}`) return this.page;
}
getNode(id, options) {
return this.page?.getNode(id, options);
}
registerComponent(type, Component) {
this.components.set(type, Component);
}
unregisterComponent(type) {
this.components.delete(type);
}
resolveComponent(type) {
return this.components.get(type);
}
emit(name, ...args) {
const [node, ...otherArgs] = args;
if (this.eventHelper && node instanceof Node && node.data?.id && node.eventKeys.has(`${String(name)}_${node.data.id}`)) return this.eventHelper.emit(node.eventKeys.get(`${String(name)}_${node.data.id}`), node, ...otherArgs);
return super.emit(name, ...args);
}
/**
* 执行代码块动作
* @param eventConfig 代码动作的配置
* @returns void
*/
async runCode(codeId, params, args, flowState, node) {
if (!codeId || isEmpty(this.codeDsl)) return;
const content = this.codeDsl?.[codeId]?.content;
if (typeof content === "function") try {
await content({
app: this,
params,
eventParams: args,
flowState,
node
});
} catch (e) {
if (this.errorHandler) this.errorHandler(e, void 0, {
type: "run-code",
codeId,
params,
eventParams: args,
flowState,
node
});
else throw e;
}
}
async runDataSourceMethod(dsId, methodName, params, args, flowState, node) {
if (!dsId || !methodName) return;
const dataSource = this.dataSourceManager?.get(dsId);
if (!dataSource) return;
try {
const method = (dataSource.methods || []).find((item) => item.name === methodName);
if (method && typeof method.content === "function") await method.content({
app: this,
params,
dataSource,
eventParams: args,
flowState,
node
});
else if (typeof dataSource[methodName] === "function") await dataSource[methodName]();
} catch (e) {
if (this.errorHandler) this.errorHandler(e, dataSource, {
type: "data-source-method",
params,
eventParams: args,
flowState,
node
});
else throw e;
}
}
destroy() {
this.removeAllListeners();
this.page?.destroy();
this.page = void 0;
this.pageFragments.forEach((page) => {
page.destroy();
});
this.pageFragments.clear();
this.flexible?.destroy();
this.flexible = void 0;
this.eventHelper?.destroy();
this.dsl = void 0;
this.dataSourceManager?.destroy();
this.dataSourceManager = void 0;
this.codeDsl = void 0;
this.components.clear();
this.nodeStoreInitialData = void 0;
}
};
var DevToolApi = class {
app;
constructor({ app }) {
this.app = app;
}
openPop(popId) {
if (typeof this.app.openPop === "function") return this.app.openPop(popId);
}
setDataSourceData(dsId, data, path2) {
const ds = this.app.dataSourceManager?.get(dsId);
if (!ds) return;
ds.setData(data, path2);
}
delDataSourceData() {}
requestDataSource(dsId) {
const ds = this.app.dataSourceManager?.get(dsId);
if (!ds) return;
if (typeof ds.refresh === "function") return ds.refresh();
if (typeof ds.request === "function") return ds.request();
ds.isInit = false;
this.app.dataSourceManager?.init(ds);
}
getDisplayCondRealValue(_nodeId, condItem) {
return this.app.dataSourceManager?.compliedConds({ [NODE_CONDS_KEY]: [{ cond: [condItem] }] });
}
async callHook(nodeId, hookName, hookData) {
const node = this.app.getNode(nodeId);
if (!node) return;
for (const item of hookData) await node.runHookCode(hookName, item.params);
}
trigger(nodeId, events) {
const node = this.app.getNode(nodeId);
if (!node) return;
this.app.emit(events.name, node);
}
updateDsl(_nodeId, _data, _path) {}
isValueIncludeDataSource(value2) {
return isValueIncludeDataSource(value2);
}
compileDataSourceValue(value2) {
return compiledNodeField(value2, this.app.dataSourceManager?.data || {});
}
updateCode(codeId, value, path) {
if (!this.app.dsl) return;
const { codeBlocks } = this.app.dsl;
if (!codeBlocks) return;
const code = codeBlocks[codeId];
if (!code) return;
const newCode = cloneDeep(code);
let fuc = value;
if (path === "content" && typeof value === "string" && (value.includes("function") || value.includes("=>"))) eval(`fuc = ${value})`);
setValueByKeyPath(path, fuc, newCode);
codeBlocks[codeId] = newCode;
}
};
//#endregion
//#region ../../node_modules/.pnpm/@tmagic+vue-button@1.0.0_@tmagic+core@1.7.7_typescript@5.9.3__@tmagic+vue-runtime-help@_1b7bdb9712d63f58797c3ea67b7382bc/node_modules/@tmagic/vue-button/src/event.ts
var event_default$9 = {
methods: [],
events: [{
label: "点击",
value: `${COMMON_EVENT_PREFIX}click`
}]
};
//#endregion
//#region ../../node_modules/.pnpm/@tmagic+vue-container@2.0.0_@tmagic+core@1.7.7_typescript@5.9.3__@tmagic+vue-runtime-he_5430b18d848f49c5858c7139f6e159d7/node_modules/@tmagic/vue-container/src/event.ts
var event_default$8 = {
methods: [],
events: [{
label: "点击",
value: `${COMMON_EVENT_PREFIX}click`
}]
};
//#endregion
//#region ../../node_modules/.pnpm/@tmagic+vue-img@1.0.0_@tmagic+core@1.7.7_typescript@5.9.3__@tmagic+vue-runtime-help@2.0_dd82d63286c52e153f9226eeb9da246b/node_modules/@tmagic/vue-img/src/event.ts
var event_default$7 = {
methods: [],
events: []
};
//#endregion
//#region ../../node_modules/.pnpm/@tmagic+vue-iterator-container@1.0.0_@tmagic+core@1.7.7_typescript@5.9.3__@tmagic+vue-r_7bc50d102b2a85dbed783f6245efac78/node_modules/@tmagic/vue-iterator-container/src/event.ts
var event_default$6 = {
methods: [],
events: [{
label: "点击",
value: `${COMMON_EVENT_PREFIX}click`
}]
};
//#endregion
//#region ../../node_modules/.pnpm/@tmagic+vue-overlay@1.0.0_@tmagic+core@1.7.7_typescript@5.9.3__@tmagic+vue-runtime-help_08f9aee12bcec9f7b90a2e73e69e7d59/node_modules/@tmagic/vue-overlay/src/event.ts
var event_default$5 = {
methods: [{
label: "打开蒙层",
value: "openOverlay"
}, {
label: "关闭蒙层",
value: "closeOverlay"
}],
events: [{
label: "打开蒙层",
value: "overlay:open"
}, {
label: "关闭蒙层",
value: "overlay:close"
}]
};
//#endregion
//#region ../../node_modules/.pnpm/@tmagic+vue-page@1.0.0_@tmagic+core@1.7.7_typescript@5.9.3__@tmagic+vue-runtime-help@2._672dff623fde21c79661c3931187f288/node_modules/@tmagic/vue-page/src/event.ts
var event_default$4 = { methods: [{
label: "刷新页面",
value: "refresh"
}] };
//#endregion
//#region ../../node_modules/.pnpm/@tmagic+vue-page-fragment@1.0.0_@tmagic+core@1.7.7_typescript@5.9.3__@tmagic+vue-runtim_21faa0fb81fc96fc55863a7603723ea8/node_modules/@tmagic/vue-page-fragment/src/event.ts
var event_default$3 = {
methods: [],
events: []
};
//#endregion
//#region ../../node_modules/.pnpm/@tmagic+vue-page-fragment-container@1.0.0_@tmagic+core@1.7.7_typescript@5.9.3__@tmagic+_ea42ad99d1285da261474e622a0701ff/node_modules/@tmagic/vue-page-fragment-container/src/event.ts
var event_default$2 = {
methods: [],
events: []
};
//#endregion
//#region ../../node_modules/.pnpm/@tmagic+vue-qrcode@1.0.0_@tmagic+core@1.7.7_typescript@5.9.3__@tmagic+vue-runtime-help@_992444881393088a687b97027e780150/node_modules/@tmagic/vue-qrcode/src/event.ts
var event_default$1 = {
methods: [],
events: [{
label: "点击",
value: `${COMMON_EVENT_PREFIX}click`
}]
};
//#endregion
//#region ../../node_modules/.pnpm/@tmagic+vue-text@1.0.0_@tmagic+core@1.7.7_typescript@5.9.3__@tmagic+vue-runtime-help@2._026c6adc38380745e80b06253287667a/node_modules/@tmagic/vue-text/src/event.ts
var event_default = {
methods: [],
events: [{
label: "点击",
value: `${COMMON_EVENT_PREFIX}click`
}]
};
//#endregion
//#region .tmagic/event-entry.ts
var events = {
"button": event_default$9,
"container": event_default$8,
"img": event_default$7,
"iterator-container": event_default$6,
"overlay": event_default$5,
"page": event_default$4,
"page-fragment": event_default$3,
"page-fragment-container": event_default$2,
"qrcode": event_default$1,
"text": event_default
};
//#endregion
return events;
});
//# sourceMappingURL=index.umd.cjs.map