Files
mixtape/zero.Backoffice.UI/dist/zero/vendor.js
T
2021-11-19 16:11:12 +01:00

33807 lines
1.1 MiB
Plaintext

var __defProp = Object.defineProperty;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {enumerable: true, configurable: true, writable: true, value}) : obj[key] = value;
var __assign = (a, b) => {
for (var prop in b || (b = {}))
if (__hasOwnProp.call(b, prop))
__defNormalProp(a, prop, b[prop]);
if (__getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(b)) {
if (__propIsEnum.call(b, prop))
__defNormalProp(a, prop, b[prop]);
}
return a;
};
/*!
* Vue.js v2.6.12
* (c) 2014-2020 Evan You
* Released under the MIT License.
*/
var emptyObject = Object.freeze({});
function isUndef(v) {
return v === void 0 || v === null;
}
function isDef(v) {
return v !== void 0 && v !== null;
}
function isTrue(v) {
return v === true;
}
function isFalse(v) {
return v === false;
}
function isPrimitive(value) {
return typeof value === "string" || typeof value === "number" || typeof value === "symbol" || typeof value === "boolean";
}
function isObject$1(obj) {
return obj !== null && typeof obj === "object";
}
var _toString = Object.prototype.toString;
function toRawType(value) {
return _toString.call(value).slice(8, -1);
}
function isPlainObject(obj) {
return _toString.call(obj) === "[object Object]";
}
function isRegExp$3(v) {
return _toString.call(v) === "[object RegExp]";
}
function isValidArrayIndex(val) {
var n = parseFloat(String(val));
return n >= 0 && Math.floor(n) === n && isFinite(val);
}
function isPromise(val) {
return isDef(val) && typeof val.then === "function" && typeof val.catch === "function";
}
function toString$1(val) {
return val == null ? "" : Array.isArray(val) || isPlainObject(val) && val.toString === _toString ? JSON.stringify(val, null, 2) : String(val);
}
function toNumber(val) {
var n = parseFloat(val);
return isNaN(n) ? val : n;
}
function makeMap(str2, expectsLowerCase) {
var map16 = Object.create(null);
var list = str2.split(",");
for (var i = 0; i < list.length; i++) {
map16[list[i]] = true;
}
return expectsLowerCase ? function(val) {
return map16[val.toLowerCase()];
} : function(val) {
return map16[val];
};
}
var isBuiltInTag = makeMap("slot,component", true);
var isReservedAttribute = makeMap("key,ref,slot,slot-scope,is");
function remove(arr, item) {
if (arr.length) {
var index3 = arr.indexOf(item);
if (index3 > -1) {
return arr.splice(index3, 1);
}
}
}
var hasOwnProperty$1 = Object.prototype.hasOwnProperty;
function hasOwn$1(obj, key) {
return hasOwnProperty$1.call(obj, key);
}
function cached(fn) {
var cache = Object.create(null);
return function cachedFn(str2) {
var hit = cache[str2];
return hit || (cache[str2] = fn(str2));
};
}
var camelizeRE = /-(\w)/g;
var camelize = cached(function(str2) {
return str2.replace(camelizeRE, function(_2, c) {
return c ? c.toUpperCase() : "";
});
});
var capitalize = cached(function(str2) {
return str2.charAt(0).toUpperCase() + str2.slice(1);
});
var hyphenateRE = /\B([A-Z])/g;
var hyphenate = cached(function(str2) {
return str2.replace(hyphenateRE, "-$1").toLowerCase();
});
function polyfillBind(fn, ctx) {
function boundFn(a) {
var l = arguments.length;
return l ? l > 1 ? fn.apply(ctx, arguments) : fn.call(ctx, a) : fn.call(ctx);
}
boundFn._length = fn.length;
return boundFn;
}
function nativeBind(fn, ctx) {
return fn.bind(ctx);
}
var bind$2 = Function.prototype.bind ? nativeBind : polyfillBind;
function toArray$1(list, start3) {
start3 = start3 || 0;
var i = list.length - start3;
var ret = new Array(i);
while (i--) {
ret[i] = list[i + start3];
}
return ret;
}
function extend$3(to, _from) {
for (var key in _from) {
to[key] = _from[key];
}
return to;
}
function toObject(arr) {
var res = {};
for (var i = 0; i < arr.length; i++) {
if (arr[i]) {
extend$3(res, arr[i]);
}
}
return res;
}
function noop$3(a, b, c) {
}
var no = function(a, b, c) {
return false;
};
var identity$1 = function(_2) {
return _2;
};
function genStaticKeys(modules2) {
return modules2.reduce(function(keys2, m) {
return keys2.concat(m.staticKeys || []);
}, []).join(",");
}
function looseEqual(a, b) {
if (a === b) {
return true;
}
var isObjectA = isObject$1(a);
var isObjectB = isObject$1(b);
if (isObjectA && isObjectB) {
try {
var isArrayA = Array.isArray(a);
var isArrayB = Array.isArray(b);
if (isArrayA && isArrayB) {
return a.length === b.length && a.every(function(e, i) {
return looseEqual(e, b[i]);
});
} else if (a instanceof Date && b instanceof Date) {
return a.getTime() === b.getTime();
} else if (!isArrayA && !isArrayB) {
var keysA = Object.keys(a);
var keysB = Object.keys(b);
return keysA.length === keysB.length && keysA.every(function(key) {
return looseEqual(a[key], b[key]);
});
} else {
return false;
}
} catch (e) {
return false;
}
} else if (!isObjectA && !isObjectB) {
return String(a) === String(b);
} else {
return false;
}
}
function looseIndexOf(arr, val) {
for (var i = 0; i < arr.length; i++) {
if (looseEqual(arr[i], val)) {
return i;
}
}
return -1;
}
function once$2(fn) {
var called = false;
return function() {
if (!called) {
called = true;
fn.apply(this, arguments);
}
};
}
var SSR_ATTR = "data-server-rendered";
var ASSET_TYPES = [
"component",
"directive",
"filter"
];
var LIFECYCLE_HOOKS = [
"beforeCreate",
"created",
"beforeMount",
"mounted",
"beforeUpdate",
"updated",
"beforeDestroy",
"destroyed",
"activated",
"deactivated",
"errorCaptured",
"serverPrefetch"
];
var config = {
optionMergeStrategies: Object.create(null),
silent: false,
productionTip: false,
devtools: false,
performance: false,
errorHandler: null,
warnHandler: null,
ignoredElements: [],
keyCodes: Object.create(null),
isReservedTag: no,
isReservedAttr: no,
isUnknownElement: no,
getTagNamespace: noop$3,
parsePlatformTagName: identity$1,
mustUseProp: no,
async: true,
_lifecycleHooks: LIFECYCLE_HOOKS
};
var unicodeRegExp = /a-zA-Z\u00B7\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u037D\u037F-\u1FFF\u200C-\u200D\u203F-\u2040\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD/;
function isReserved(str2) {
var c = (str2 + "").charCodeAt(0);
return c === 36 || c === 95;
}
function def(obj, key, val, enumerable) {
Object.defineProperty(obj, key, {
value: val,
enumerable: !!enumerable,
writable: true,
configurable: true
});
}
var bailRE = new RegExp("[^" + unicodeRegExp.source + ".$_\\d]");
function parsePath$1(path) {
if (bailRE.test(path)) {
return;
}
var segments = path.split(".");
return function(obj) {
for (var i = 0; i < segments.length; i++) {
if (!obj) {
return;
}
obj = obj[segments[i]];
}
return obj;
};
}
var hasProto = "__proto__" in {};
var inBrowser$1 = typeof window !== "undefined";
var inWeex = typeof WXEnvironment !== "undefined" && !!WXEnvironment.platform;
var weexPlatform = inWeex && WXEnvironment.platform.toLowerCase();
var UA = inBrowser$1 && window.navigator.userAgent.toLowerCase();
var isIE = UA && /msie|trident/.test(UA);
var isIE9 = UA && UA.indexOf("msie 9.0") > 0;
var isEdge = UA && UA.indexOf("edge/") > 0;
UA && UA.indexOf("android") > 0 || weexPlatform === "android";
var isIOS = UA && /iphone|ipad|ipod|ios/.test(UA) || weexPlatform === "ios";
UA && /chrome\/\d+/.test(UA) && !isEdge;
UA && /phantomjs/.test(UA);
var isFF = UA && UA.match(/firefox\/(\d+)/);
var nativeWatch = {}.watch;
var supportsPassive = false;
if (inBrowser$1) {
try {
var opts = {};
Object.defineProperty(opts, "passive", {
get: function get7() {
supportsPassive = true;
}
});
window.addEventListener("test-passive", null, opts);
} catch (e) {
}
}
var _isServer;
var isServerRendering = function() {
if (_isServer === void 0) {
if (!inBrowser$1 && !inWeex && typeof global !== "undefined") {
_isServer = global["process"] && global["process"].env.VUE_ENV === "server";
} else {
_isServer = false;
}
}
return _isServer;
};
var devtools = inBrowser$1 && window.__VUE_DEVTOOLS_GLOBAL_HOOK__;
function isNative(Ctor) {
return typeof Ctor === "function" && /native code/.test(Ctor.toString());
}
var hasSymbol$1 = typeof Symbol !== "undefined" && isNative(Symbol) && typeof Reflect !== "undefined" && isNative(Reflect.ownKeys);
var _Set;
if (typeof Set !== "undefined" && isNative(Set)) {
_Set = Set;
} else {
_Set = /* @__PURE__ */ function() {
function Set2() {
this.set = Object.create(null);
}
Set2.prototype.has = function has2(key) {
return this.set[key] === true;
};
Set2.prototype.add = function add3(key) {
this.set[key] = true;
};
Set2.prototype.clear = function clear() {
this.set = Object.create(null);
};
return Set2;
}();
}
var warn$1 = noop$3;
var uid = 0;
var Dep = function Dep2() {
this.id = uid++;
this.subs = [];
};
Dep.prototype.addSub = function addSub(sub) {
this.subs.push(sub);
};
Dep.prototype.removeSub = function removeSub(sub) {
remove(this.subs, sub);
};
Dep.prototype.depend = function depend() {
if (Dep.target) {
Dep.target.addDep(this);
}
};
Dep.prototype.notify = function notify() {
var subs = this.subs.slice();
for (var i = 0, l = subs.length; i < l; i++) {
subs[i].update();
}
};
Dep.target = null;
var targetStack = [];
function pushTarget(target2) {
targetStack.push(target2);
Dep.target = target2;
}
function popTarget() {
targetStack.pop();
Dep.target = targetStack[targetStack.length - 1];
}
var VNode = function VNode2(tag2, data, children, text3, elm, context, componentOptions, asyncFactory) {
this.tag = tag2;
this.data = data;
this.children = children;
this.text = text3;
this.elm = elm;
this.ns = void 0;
this.context = context;
this.fnContext = void 0;
this.fnOptions = void 0;
this.fnScopeId = void 0;
this.key = data && data.key;
this.componentOptions = componentOptions;
this.componentInstance = void 0;
this.parent = void 0;
this.raw = false;
this.isStatic = false;
this.isRootInsert = true;
this.isComment = false;
this.isCloned = false;
this.isOnce = false;
this.asyncFactory = asyncFactory;
this.asyncMeta = void 0;
this.isAsyncPlaceholder = false;
};
var prototypeAccessors$8 = {child: {configurable: true}};
prototypeAccessors$8.child.get = function() {
return this.componentInstance;
};
Object.defineProperties(VNode.prototype, prototypeAccessors$8);
var createEmptyVNode = function(text3) {
if (text3 === void 0)
text3 = "";
var node4 = new VNode();
node4.text = text3;
node4.isComment = true;
return node4;
};
function createTextVNode(val) {
return new VNode(void 0, void 0, void 0, String(val));
}
function cloneVNode(vnode) {
var cloned = new VNode(vnode.tag, vnode.data, vnode.children && vnode.children.slice(), vnode.text, vnode.elm, vnode.context, vnode.componentOptions, vnode.asyncFactory);
cloned.ns = vnode.ns;
cloned.isStatic = vnode.isStatic;
cloned.key = vnode.key;
cloned.isComment = vnode.isComment;
cloned.fnContext = vnode.fnContext;
cloned.fnOptions = vnode.fnOptions;
cloned.fnScopeId = vnode.fnScopeId;
cloned.asyncMeta = vnode.asyncMeta;
cloned.isCloned = true;
return cloned;
}
var arrayProto = Array.prototype;
var arrayMethods = Object.create(arrayProto);
var methodsToPatch = [
"push",
"pop",
"shift",
"unshift",
"splice",
"sort",
"reverse"
];
methodsToPatch.forEach(function(method) {
var original = arrayProto[method];
def(arrayMethods, method, function mutator() {
var args = [], len2 = arguments.length;
while (len2--)
args[len2] = arguments[len2];
var result2 = original.apply(this, args);
var ob = this.__ob__;
var inserted2;
switch (method) {
case "push":
case "unshift":
inserted2 = args;
break;
case "splice":
inserted2 = args.slice(2);
break;
}
if (inserted2) {
ob.observeArray(inserted2);
}
ob.dep.notify();
return result2;
});
});
var arrayKeys = Object.getOwnPropertyNames(arrayMethods);
var shouldObserve = true;
function toggleObserving(value) {
shouldObserve = value;
}
var Observer = function Observer2(value) {
this.value = value;
this.dep = new Dep();
this.vmCount = 0;
def(value, "__ob__", this);
if (Array.isArray(value)) {
if (hasProto) {
protoAugment(value, arrayMethods);
} else {
copyAugment(value, arrayMethods, arrayKeys);
}
this.observeArray(value);
} else {
this.walk(value);
}
};
Observer.prototype.walk = function walk(obj) {
var keys2 = Object.keys(obj);
for (var i = 0; i < keys2.length; i++) {
defineReactive$$1(obj, keys2[i]);
}
};
Observer.prototype.observeArray = function observeArray(items) {
for (var i = 0, l = items.length; i < l; i++) {
observe(items[i]);
}
};
function protoAugment(target2, src) {
target2.__proto__ = src;
}
function copyAugment(target2, src, keys2) {
for (var i = 0, l = keys2.length; i < l; i++) {
var key = keys2[i];
def(target2, key, src[key]);
}
}
function observe(value, asRootData) {
if (!isObject$1(value) || value instanceof VNode) {
return;
}
var ob;
if (hasOwn$1(value, "__ob__") && value.__ob__ instanceof Observer) {
ob = value.__ob__;
} else if (shouldObserve && !isServerRendering() && (Array.isArray(value) || isPlainObject(value)) && Object.isExtensible(value) && !value._isVue) {
ob = new Observer(value);
}
if (asRootData && ob) {
ob.vmCount++;
}
return ob;
}
function defineReactive$$1(obj, key, val, customSetter, shallow) {
var dep = new Dep();
var property2 = Object.getOwnPropertyDescriptor(obj, key);
if (property2 && property2.configurable === false) {
return;
}
var getter = property2 && property2.get;
var setter = property2 && property2.set;
if ((!getter || setter) && arguments.length === 2) {
val = obj[key];
}
var childOb = !shallow && observe(val);
Object.defineProperty(obj, key, {
enumerable: true,
configurable: true,
get: function reactiveGetter() {
var value = getter ? getter.call(obj) : val;
if (Dep.target) {
dep.depend();
if (childOb) {
childOb.dep.depend();
if (Array.isArray(value)) {
dependArray(value);
}
}
}
return value;
},
set: function reactiveSetter(newVal) {
var value = getter ? getter.call(obj) : val;
if (newVal === value || newVal !== newVal && value !== value) {
return;
}
if (getter && !setter) {
return;
}
if (setter) {
setter.call(obj, newVal);
} else {
val = newVal;
}
childOb = !shallow && observe(newVal);
dep.notify();
}
});
}
function set(target2, key, val) {
if (Array.isArray(target2) && isValidArrayIndex(key)) {
target2.length = Math.max(target2.length, key);
target2.splice(key, 1, val);
return val;
}
if (key in target2 && !(key in Object.prototype)) {
target2[key] = val;
return val;
}
var ob = target2.__ob__;
if (target2._isVue || ob && ob.vmCount) {
return val;
}
if (!ob) {
target2[key] = val;
return val;
}
defineReactive$$1(ob.value, key, val);
ob.dep.notify();
return val;
}
function del$1(target2, key) {
if (Array.isArray(target2) && isValidArrayIndex(key)) {
target2.splice(key, 1);
return;
}
var ob = target2.__ob__;
if (target2._isVue || ob && ob.vmCount) {
return;
}
if (!hasOwn$1(target2, key)) {
return;
}
delete target2[key];
if (!ob) {
return;
}
ob.dep.notify();
}
function dependArray(value) {
for (var e = void 0, i = 0, l = value.length; i < l; i++) {
e = value[i];
e && e.__ob__ && e.__ob__.dep.depend();
if (Array.isArray(e)) {
dependArray(e);
}
}
}
var strats = config.optionMergeStrategies;
function mergeData(to, from4) {
if (!from4) {
return to;
}
var key, toVal, fromVal;
var keys2 = hasSymbol$1 ? Reflect.ownKeys(from4) : Object.keys(from4);
for (var i = 0; i < keys2.length; i++) {
key = keys2[i];
if (key === "__ob__") {
continue;
}
toVal = to[key];
fromVal = from4[key];
if (!hasOwn$1(to, key)) {
set(to, key, fromVal);
} else if (toVal !== fromVal && isPlainObject(toVal) && isPlainObject(fromVal)) {
mergeData(toVal, fromVal);
}
}
return to;
}
function mergeDataOrFn(parentVal, childVal, vm) {
if (!vm) {
if (!childVal) {
return parentVal;
}
if (!parentVal) {
return childVal;
}
return function mergedDataFn() {
return mergeData(typeof childVal === "function" ? childVal.call(this, this) : childVal, typeof parentVal === "function" ? parentVal.call(this, this) : parentVal);
};
} else {
return function mergedInstanceDataFn() {
var instanceData = typeof childVal === "function" ? childVal.call(vm, vm) : childVal;
var defaultData = typeof parentVal === "function" ? parentVal.call(vm, vm) : parentVal;
if (instanceData) {
return mergeData(instanceData, defaultData);
} else {
return defaultData;
}
};
}
}
strats.data = function(parentVal, childVal, vm) {
if (!vm) {
if (childVal && typeof childVal !== "function") {
return parentVal;
}
return mergeDataOrFn(parentVal, childVal);
}
return mergeDataOrFn(parentVal, childVal, vm);
};
function mergeHook(parentVal, childVal) {
var res = childVal ? parentVal ? parentVal.concat(childVal) : Array.isArray(childVal) ? childVal : [childVal] : parentVal;
return res ? dedupeHooks(res) : res;
}
function dedupeHooks(hooks2) {
var res = [];
for (var i = 0; i < hooks2.length; i++) {
if (res.indexOf(hooks2[i]) === -1) {
res.push(hooks2[i]);
}
}
return res;
}
LIFECYCLE_HOOKS.forEach(function(hook) {
strats[hook] = mergeHook;
});
function mergeAssets(parentVal, childVal, vm, key) {
var res = Object.create(parentVal || null);
if (childVal) {
return extend$3(res, childVal);
} else {
return res;
}
}
ASSET_TYPES.forEach(function(type) {
strats[type + "s"] = mergeAssets;
});
strats.watch = function(parentVal, childVal, vm, key) {
if (parentVal === nativeWatch) {
parentVal = void 0;
}
if (childVal === nativeWatch) {
childVal = void 0;
}
if (!childVal) {
return Object.create(parentVal || null);
}
if (!parentVal) {
return childVal;
}
var ret = {};
extend$3(ret, parentVal);
for (var key$1 in childVal) {
var parent = ret[key$1];
var child3 = childVal[key$1];
if (parent && !Array.isArray(parent)) {
parent = [parent];
}
ret[key$1] = parent ? parent.concat(child3) : Array.isArray(child3) ? child3 : [child3];
}
return ret;
};
strats.props = strats.methods = strats.inject = strats.computed = function(parentVal, childVal, vm, key) {
if (childVal && false) {
assertObjectType(key, childVal);
}
if (!parentVal) {
return childVal;
}
var ret = Object.create(null);
extend$3(ret, parentVal);
if (childVal) {
extend$3(ret, childVal);
}
return ret;
};
strats.provide = mergeDataOrFn;
var defaultStrat = function(parentVal, childVal) {
return childVal === void 0 ? parentVal : childVal;
};
function normalizeProps(options, vm) {
var props2 = options.props;
if (!props2) {
return;
}
var res = {};
var i, val, name;
if (Array.isArray(props2)) {
i = props2.length;
while (i--) {
val = props2[i];
if (typeof val === "string") {
name = camelize(val);
res[name] = {type: null};
}
}
} else if (isPlainObject(props2)) {
for (var key in props2) {
val = props2[key];
name = camelize(key);
res[name] = isPlainObject(val) ? val : {type: val};
}
} else
;
options.props = res;
}
function normalizeInject(options, vm) {
var inject = options.inject;
if (!inject) {
return;
}
var normalized = options.inject = {};
if (Array.isArray(inject)) {
for (var i = 0; i < inject.length; i++) {
normalized[inject[i]] = {from: inject[i]};
}
} else if (isPlainObject(inject)) {
for (var key in inject) {
var val = inject[key];
normalized[key] = isPlainObject(val) ? extend$3({from: key}, val) : {from: val};
}
} else
;
}
function normalizeDirectives(options) {
var dirs = options.directives;
if (dirs) {
for (var key in dirs) {
var def$$1 = dirs[key];
if (typeof def$$1 === "function") {
dirs[key] = {bind: def$$1, update: def$$1};
}
}
}
}
function assertObjectType(name, value, vm) {
if (!isPlainObject(value)) {
warn$1('Invalid value for option "' + name + '": expected an Object, but got ' + toRawType(value) + ".");
}
}
function mergeOptions(parent, child3, vm) {
if (typeof child3 === "function") {
child3 = child3.options;
}
normalizeProps(child3);
normalizeInject(child3);
normalizeDirectives(child3);
if (!child3._base) {
if (child3.extends) {
parent = mergeOptions(parent, child3.extends, vm);
}
if (child3.mixins) {
for (var i = 0, l = child3.mixins.length; i < l; i++) {
parent = mergeOptions(parent, child3.mixins[i], vm);
}
}
}
var options = {};
var key;
for (key in parent) {
mergeField(key);
}
for (key in child3) {
if (!hasOwn$1(parent, key)) {
mergeField(key);
}
}
function mergeField(key2) {
var strat = strats[key2] || defaultStrat;
options[key2] = strat(parent[key2], child3[key2], vm, key2);
}
return options;
}
function resolveAsset(options, type, id, warnMissing) {
if (typeof id !== "string") {
return;
}
var assets = options[type];
if (hasOwn$1(assets, id)) {
return assets[id];
}
var camelizedId = camelize(id);
if (hasOwn$1(assets, camelizedId)) {
return assets[camelizedId];
}
var PascalCaseId = capitalize(camelizedId);
if (hasOwn$1(assets, PascalCaseId)) {
return assets[PascalCaseId];
}
var res = assets[id] || assets[camelizedId] || assets[PascalCaseId];
return res;
}
function validateProp(key, propOptions, propsData, vm) {
var prop = propOptions[key];
var absent = !hasOwn$1(propsData, key);
var value = propsData[key];
var booleanIndex = getTypeIndex(Boolean, prop.type);
if (booleanIndex > -1) {
if (absent && !hasOwn$1(prop, "default")) {
value = false;
} else if (value === "" || value === hyphenate(key)) {
var stringIndex = getTypeIndex(String, prop.type);
if (stringIndex < 0 || booleanIndex < stringIndex) {
value = true;
}
}
}
if (value === void 0) {
value = getPropDefaultValue(vm, prop, key);
var prevShouldObserve = shouldObserve;
toggleObserving(true);
observe(value);
toggleObserving(prevShouldObserve);
}
return value;
}
function getPropDefaultValue(vm, prop, key) {
if (!hasOwn$1(prop, "default")) {
return void 0;
}
var def2 = prop.default;
if (vm && vm.$options.propsData && vm.$options.propsData[key] === void 0 && vm._props[key] !== void 0) {
return vm._props[key];
}
return typeof def2 === "function" && getType(prop.type) !== "Function" ? def2.call(vm) : def2;
}
function getType(fn) {
var match3 = fn && fn.toString().match(/^\s*function (\w+)/);
return match3 ? match3[1] : "";
}
function isSameType(a, b) {
return getType(a) === getType(b);
}
function getTypeIndex(type, expectedTypes) {
if (!Array.isArray(expectedTypes)) {
return isSameType(expectedTypes, type) ? 0 : -1;
}
for (var i = 0, len2 = expectedTypes.length; i < len2; i++) {
if (isSameType(expectedTypes[i], type)) {
return i;
}
}
return -1;
}
function handleError(err2, vm, info) {
pushTarget();
try {
if (vm) {
var cur = vm;
while (cur = cur.$parent) {
var hooks2 = cur.$options.errorCaptured;
if (hooks2) {
for (var i = 0; i < hooks2.length; i++) {
try {
var capture = hooks2[i].call(cur, err2, vm, info) === false;
if (capture) {
return;
}
} catch (e) {
globalHandleError(e, cur, "errorCaptured hook");
}
}
}
}
}
globalHandleError(err2, vm, info);
} finally {
popTarget();
}
}
function invokeWithErrorHandling(handler, context, args, vm, info) {
var res;
try {
res = args ? handler.apply(context, args) : handler.call(context);
if (res && !res._isVue && isPromise(res) && !res._handled) {
res.catch(function(e) {
return handleError(e, vm, info + " (Promise/async)");
});
res._handled = true;
}
} catch (e) {
handleError(e, vm, info);
}
return res;
}
function globalHandleError(err2, vm, info) {
if (config.errorHandler) {
try {
return config.errorHandler.call(null, err2, vm, info);
} catch (e) {
if (e !== err2) {
logError(e);
}
}
}
logError(err2);
}
function logError(err2, vm, info) {
if ((inBrowser$1 || inWeex) && typeof console !== "undefined") {
console.error(err2);
} else {
throw err2;
}
}
var isUsingMicroTask = false;
var callbacks = [];
var pending = false;
function flushCallbacks() {
pending = false;
var copies = callbacks.slice(0);
callbacks.length = 0;
for (var i = 0; i < copies.length; i++) {
copies[i]();
}
}
var timerFunc;
if (typeof Promise !== "undefined" && isNative(Promise)) {
var p = Promise.resolve();
timerFunc = function() {
p.then(flushCallbacks);
if (isIOS) {
setTimeout(noop$3);
}
};
isUsingMicroTask = true;
} else if (!isIE && typeof MutationObserver !== "undefined" && (isNative(MutationObserver) || MutationObserver.toString() === "[object MutationObserverConstructor]")) {
var counter = 1;
var observer = new MutationObserver(flushCallbacks);
var textNode = document.createTextNode(String(counter));
observer.observe(textNode, {
characterData: true
});
timerFunc = function() {
counter = (counter + 1) % 2;
textNode.data = String(counter);
};
isUsingMicroTask = true;
} else if (typeof setImmediate !== "undefined" && isNative(setImmediate)) {
timerFunc = function() {
setImmediate(flushCallbacks);
};
} else {
timerFunc = function() {
setTimeout(flushCallbacks, 0);
};
}
function nextTick(cb2, ctx) {
var _resolve;
callbacks.push(function() {
if (cb2) {
try {
cb2.call(ctx);
} catch (e) {
handleError(e, ctx, "nextTick");
}
} else if (_resolve) {
_resolve(ctx);
}
});
if (!pending) {
pending = true;
timerFunc();
}
if (!cb2 && typeof Promise !== "undefined") {
return new Promise(function(resolve9) {
_resolve = resolve9;
});
}
}
var seenObjects = new _Set();
function traverse(val) {
_traverse(val, seenObjects);
seenObjects.clear();
}
function _traverse(val, seen) {
var i, keys2;
var isA = Array.isArray(val);
if (!isA && !isObject$1(val) || Object.isFrozen(val) || val instanceof VNode) {
return;
}
if (val.__ob__) {
var depId = val.__ob__.dep.id;
if (seen.has(depId)) {
return;
}
seen.add(depId);
}
if (isA) {
i = val.length;
while (i--) {
_traverse(val[i], seen);
}
} else {
keys2 = Object.keys(val);
i = keys2.length;
while (i--) {
_traverse(val[keys2[i]], seen);
}
}
}
var normalizeEvent = cached(function(name) {
var passive = name.charAt(0) === "&";
name = passive ? name.slice(1) : name;
var once$$1 = name.charAt(0) === "~";
name = once$$1 ? name.slice(1) : name;
var capture = name.charAt(0) === "!";
name = capture ? name.slice(1) : name;
return {
name,
once: once$$1,
capture,
passive
};
});
function createFnInvoker(fns, vm) {
function invoker() {
var arguments$1 = arguments;
var fns2 = invoker.fns;
if (Array.isArray(fns2)) {
var cloned = fns2.slice();
for (var i = 0; i < cloned.length; i++) {
invokeWithErrorHandling(cloned[i], null, arguments$1, vm, "v-on handler");
}
} else {
return invokeWithErrorHandling(fns2, null, arguments, vm, "v-on handler");
}
}
invoker.fns = fns;
return invoker;
}
function updateListeners(on2, oldOn, add3, remove$$12, createOnceHandler2, vm) {
var name, cur, old, event;
for (name in on2) {
cur = on2[name];
old = oldOn[name];
event = normalizeEvent(name);
if (isUndef(cur))
;
else if (isUndef(old)) {
if (isUndef(cur.fns)) {
cur = on2[name] = createFnInvoker(cur, vm);
}
if (isTrue(event.once)) {
cur = on2[name] = createOnceHandler2(event.name, cur, event.capture);
}
add3(event.name, cur, event.capture, event.passive, event.params);
} else if (cur !== old) {
old.fns = cur;
on2[name] = old;
}
}
for (name in oldOn) {
if (isUndef(on2[name])) {
event = normalizeEvent(name);
remove$$12(event.name, oldOn[name], event.capture);
}
}
}
function mergeVNodeHook(def2, hookKey, hook) {
if (def2 instanceof VNode) {
def2 = def2.data.hook || (def2.data.hook = {});
}
var invoker;
var oldHook = def2[hookKey];
function wrappedHook() {
hook.apply(this, arguments);
remove(invoker.fns, wrappedHook);
}
if (isUndef(oldHook)) {
invoker = createFnInvoker([wrappedHook]);
} else {
if (isDef(oldHook.fns) && isTrue(oldHook.merged)) {
invoker = oldHook;
invoker.fns.push(wrappedHook);
} else {
invoker = createFnInvoker([oldHook, wrappedHook]);
}
}
invoker.merged = true;
def2[hookKey] = invoker;
}
function extractPropsFromVNodeData(data, Ctor, tag2) {
var propOptions = Ctor.options.props;
if (isUndef(propOptions)) {
return;
}
var res = {};
var attrs2 = data.attrs;
var props2 = data.props;
if (isDef(attrs2) || isDef(props2)) {
for (var key in propOptions) {
var altKey = hyphenate(key);
checkProp(res, props2, key, altKey, true) || checkProp(res, attrs2, key, altKey, false);
}
}
return res;
}
function checkProp(res, hash2, key, altKey, preserve) {
if (isDef(hash2)) {
if (hasOwn$1(hash2, key)) {
res[key] = hash2[key];
if (!preserve) {
delete hash2[key];
}
return true;
} else if (hasOwn$1(hash2, altKey)) {
res[key] = hash2[altKey];
if (!preserve) {
delete hash2[altKey];
}
return true;
}
}
return false;
}
function simpleNormalizeChildren(children) {
for (var i = 0; i < children.length; i++) {
if (Array.isArray(children[i])) {
return Array.prototype.concat.apply([], children);
}
}
return children;
}
function normalizeChildren(children) {
return isPrimitive(children) ? [createTextVNode(children)] : Array.isArray(children) ? normalizeArrayChildren(children) : void 0;
}
function isTextNode(node4) {
return isDef(node4) && isDef(node4.text) && isFalse(node4.isComment);
}
function normalizeArrayChildren(children, nestedIndex) {
var res = [];
var i, c, lastIndex, last2;
for (i = 0; i < children.length; i++) {
c = children[i];
if (isUndef(c) || typeof c === "boolean") {
continue;
}
lastIndex = res.length - 1;
last2 = res[lastIndex];
if (Array.isArray(c)) {
if (c.length > 0) {
c = normalizeArrayChildren(c, (nestedIndex || "") + "_" + i);
if (isTextNode(c[0]) && isTextNode(last2)) {
res[lastIndex] = createTextVNode(last2.text + c[0].text);
c.shift();
}
res.push.apply(res, c);
}
} else if (isPrimitive(c)) {
if (isTextNode(last2)) {
res[lastIndex] = createTextVNode(last2.text + c);
} else if (c !== "") {
res.push(createTextVNode(c));
}
} else {
if (isTextNode(c) && isTextNode(last2)) {
res[lastIndex] = createTextVNode(last2.text + c.text);
} else {
if (isTrue(children._isVList) && isDef(c.tag) && isUndef(c.key) && isDef(nestedIndex)) {
c.key = "__vlist" + nestedIndex + "_" + i + "__";
}
res.push(c);
}
}
}
return res;
}
function initProvide(vm) {
var provide = vm.$options.provide;
if (provide) {
vm._provided = typeof provide === "function" ? provide.call(vm) : provide;
}
}
function initInjections(vm) {
var result2 = resolveInject(vm.$options.inject, vm);
if (result2) {
toggleObserving(false);
Object.keys(result2).forEach(function(key) {
{
defineReactive$$1(vm, key, result2[key]);
}
});
toggleObserving(true);
}
}
function resolveInject(inject, vm) {
if (inject) {
var result2 = Object.create(null);
var keys2 = hasSymbol$1 ? Reflect.ownKeys(inject) : Object.keys(inject);
for (var i = 0; i < keys2.length; i++) {
var key = keys2[i];
if (key === "__ob__") {
continue;
}
var provideKey = inject[key].from;
var source2 = vm;
while (source2) {
if (source2._provided && hasOwn$1(source2._provided, provideKey)) {
result2[key] = source2._provided[provideKey];
break;
}
source2 = source2.$parent;
}
if (!source2) {
if ("default" in inject[key]) {
var provideDefault = inject[key].default;
result2[key] = typeof provideDefault === "function" ? provideDefault.call(vm) : provideDefault;
}
}
}
return result2;
}
}
function resolveSlots(children, context) {
if (!children || !children.length) {
return {};
}
var slots = {};
for (var i = 0, l = children.length; i < l; i++) {
var child3 = children[i];
var data = child3.data;
if (data && data.attrs && data.attrs.slot) {
delete data.attrs.slot;
}
if ((child3.context === context || child3.fnContext === context) && data && data.slot != null) {
var name = data.slot;
var slot = slots[name] || (slots[name] = []);
if (child3.tag === "template") {
slot.push.apply(slot, child3.children || []);
} else {
slot.push(child3);
}
} else {
(slots.default || (slots.default = [])).push(child3);
}
}
for (var name$1 in slots) {
if (slots[name$1].every(isWhitespace)) {
delete slots[name$1];
}
}
return slots;
}
function isWhitespace(node4) {
return node4.isComment && !node4.asyncFactory || node4.text === " ";
}
function normalizeScopedSlots(slots, normalSlots, prevSlots) {
var res;
var hasNormalSlots = Object.keys(normalSlots).length > 0;
var isStable = slots ? !!slots.$stable : !hasNormalSlots;
var key = slots && slots.$key;
if (!slots) {
res = {};
} else if (slots._normalized) {
return slots._normalized;
} else if (isStable && prevSlots && prevSlots !== emptyObject && key === prevSlots.$key && !hasNormalSlots && !prevSlots.$hasNormal) {
return prevSlots;
} else {
res = {};
for (var key$1 in slots) {
if (slots[key$1] && key$1[0] !== "$") {
res[key$1] = normalizeScopedSlot(normalSlots, key$1, slots[key$1]);
}
}
}
for (var key$2 in normalSlots) {
if (!(key$2 in res)) {
res[key$2] = proxyNormalSlot(normalSlots, key$2);
}
}
if (slots && Object.isExtensible(slots)) {
slots._normalized = res;
}
def(res, "$stable", isStable);
def(res, "$key", key);
def(res, "$hasNormal", hasNormalSlots);
return res;
}
function normalizeScopedSlot(normalSlots, key, fn) {
var normalized = function() {
var res = arguments.length ? fn.apply(null, arguments) : fn({});
res = res && typeof res === "object" && !Array.isArray(res) ? [res] : normalizeChildren(res);
return res && (res.length === 0 || res.length === 1 && res[0].isComment) ? void 0 : res;
};
if (fn.proxy) {
Object.defineProperty(normalSlots, key, {
get: normalized,
enumerable: true,
configurable: true
});
}
return normalized;
}
function proxyNormalSlot(slots, key) {
return function() {
return slots[key];
};
}
function renderList(val, render6) {
var ret, i, l, keys2, key;
if (Array.isArray(val) || typeof val === "string") {
ret = new Array(val.length);
for (i = 0, l = val.length; i < l; i++) {
ret[i] = render6(val[i], i);
}
} else if (typeof val === "number") {
ret = new Array(val);
for (i = 0; i < val; i++) {
ret[i] = render6(i + 1, i);
}
} else if (isObject$1(val)) {
if (hasSymbol$1 && val[Symbol.iterator]) {
ret = [];
var iterator = val[Symbol.iterator]();
var result2 = iterator.next();
while (!result2.done) {
ret.push(render6(result2.value, ret.length));
result2 = iterator.next();
}
} else {
keys2 = Object.keys(val);
ret = new Array(keys2.length);
for (i = 0, l = keys2.length; i < l; i++) {
key = keys2[i];
ret[i] = render6(val[key], key, i);
}
}
}
if (!isDef(ret)) {
ret = [];
}
ret._isVList = true;
return ret;
}
function renderSlot(name, fallback, props2, bindObject) {
var scopedSlotFn = this.$scopedSlots[name];
var nodes;
if (scopedSlotFn) {
props2 = props2 || {};
if (bindObject) {
props2 = extend$3(extend$3({}, bindObject), props2);
}
nodes = scopedSlotFn(props2) || fallback;
} else {
nodes = this.$slots[name] || fallback;
}
var target2 = props2 && props2.slot;
if (target2) {
return this.$createElement("template", {slot: target2}, nodes);
} else {
return nodes;
}
}
function resolveFilter(id) {
return resolveAsset(this.$options, "filters", id) || identity$1;
}
function isKeyNotMatch(expect, actual) {
if (Array.isArray(expect)) {
return expect.indexOf(actual) === -1;
} else {
return expect !== actual;
}
}
function checkKeyCodes(eventKeyCode, key, builtInKeyCode, eventKeyName, builtInKeyName) {
var mappedKeyCode = config.keyCodes[key] || builtInKeyCode;
if (builtInKeyName && eventKeyName && !config.keyCodes[key]) {
return isKeyNotMatch(builtInKeyName, eventKeyName);
} else if (mappedKeyCode) {
return isKeyNotMatch(mappedKeyCode, eventKeyCode);
} else if (eventKeyName) {
return hyphenate(eventKeyName) !== key;
}
}
function bindObjectProps(data, tag2, value, asProp, isSync) {
if (value) {
if (!isObject$1(value))
;
else {
if (Array.isArray(value)) {
value = toObject(value);
}
var hash2;
var loop = function(key2) {
if (key2 === "class" || key2 === "style" || isReservedAttribute(key2)) {
hash2 = data;
} else {
var type = data.attrs && data.attrs.type;
hash2 = asProp || config.mustUseProp(tag2, type, key2) ? data.domProps || (data.domProps = {}) : data.attrs || (data.attrs = {});
}
var camelizedKey = camelize(key2);
var hyphenatedKey = hyphenate(key2);
if (!(camelizedKey in hash2) && !(hyphenatedKey in hash2)) {
hash2[key2] = value[key2];
if (isSync) {
var on2 = data.on || (data.on = {});
on2["update:" + key2] = function($event) {
value[key2] = $event;
};
}
}
};
for (var key in value)
loop(key);
}
}
return data;
}
function renderStatic(index3, isInFor) {
var cached2 = this._staticTrees || (this._staticTrees = []);
var tree = cached2[index3];
if (tree && !isInFor) {
return tree;
}
tree = cached2[index3] = this.$options.staticRenderFns[index3].call(this._renderProxy, null, this);
markStatic(tree, "__static__" + index3, false);
return tree;
}
function markOnce(tree, index3, key) {
markStatic(tree, "__once__" + index3 + (key ? "_" + key : ""), true);
return tree;
}
function markStatic(tree, key, isOnce) {
if (Array.isArray(tree)) {
for (var i = 0; i < tree.length; i++) {
if (tree[i] && typeof tree[i] !== "string") {
markStaticNode(tree[i], key + "_" + i, isOnce);
}
}
} else {
markStaticNode(tree, key, isOnce);
}
}
function markStaticNode(node4, key, isOnce) {
node4.isStatic = true;
node4.key = key;
node4.isOnce = isOnce;
}
function bindObjectListeners(data, value) {
if (value) {
if (!isPlainObject(value))
;
else {
var on2 = data.on = data.on ? extend$3({}, data.on) : {};
for (var key in value) {
var existing = on2[key];
var ours = value[key];
on2[key] = existing ? [].concat(existing, ours) : ours;
}
}
}
return data;
}
function resolveScopedSlots(fns, res, hasDynamicKeys, contentHashKey) {
res = res || {$stable: !hasDynamicKeys};
for (var i = 0; i < fns.length; i++) {
var slot = fns[i];
if (Array.isArray(slot)) {
resolveScopedSlots(slot, res, hasDynamicKeys);
} else if (slot) {
if (slot.proxy) {
slot.fn.proxy = true;
}
res[slot.key] = slot.fn;
}
}
if (contentHashKey) {
res.$key = contentHashKey;
}
return res;
}
function bindDynamicKeys(baseObj, values2) {
for (var i = 0; i < values2.length; i += 2) {
var key = values2[i];
if (typeof key === "string" && key) {
baseObj[values2[i]] = values2[i + 1];
}
}
return baseObj;
}
function prependModifier(value, symbol) {
return typeof value === "string" ? symbol + value : value;
}
function installRenderHelpers(target2) {
target2._o = markOnce;
target2._n = toNumber;
target2._s = toString$1;
target2._l = renderList;
target2._t = renderSlot;
target2._q = looseEqual;
target2._i = looseIndexOf;
target2._m = renderStatic;
target2._f = resolveFilter;
target2._k = checkKeyCodes;
target2._b = bindObjectProps;
target2._v = createTextVNode;
target2._e = createEmptyVNode;
target2._u = resolveScopedSlots;
target2._g = bindObjectListeners;
target2._d = bindDynamicKeys;
target2._p = prependModifier;
}
function FunctionalRenderContext(data, props2, children, parent, Ctor) {
var this$1 = this;
var options = Ctor.options;
var contextVm;
if (hasOwn$1(parent, "_uid")) {
contextVm = Object.create(parent);
contextVm._original = parent;
} else {
contextVm = parent;
parent = parent._original;
}
var isCompiled = isTrue(options._compiled);
var needNormalization = !isCompiled;
this.data = data;
this.props = props2;
this.children = children;
this.parent = parent;
this.listeners = data.on || emptyObject;
this.injections = resolveInject(options.inject, parent);
this.slots = function() {
if (!this$1.$slots) {
normalizeScopedSlots(data.scopedSlots, this$1.$slots = resolveSlots(children, parent));
}
return this$1.$slots;
};
Object.defineProperty(this, "scopedSlots", {
enumerable: true,
get: function get7() {
return normalizeScopedSlots(data.scopedSlots, this.slots());
}
});
if (isCompiled) {
this.$options = options;
this.$slots = this.slots();
this.$scopedSlots = normalizeScopedSlots(data.scopedSlots, this.$slots);
}
if (options._scopeId) {
this._c = function(a, b, c, d) {
var vnode = createElement$1(contextVm, a, b, c, d, needNormalization);
if (vnode && !Array.isArray(vnode)) {
vnode.fnScopeId = options._scopeId;
vnode.fnContext = parent;
}
return vnode;
};
} else {
this._c = function(a, b, c, d) {
return createElement$1(contextVm, a, b, c, d, needNormalization);
};
}
}
installRenderHelpers(FunctionalRenderContext.prototype);
function createFunctionalComponent(Ctor, propsData, data, contextVm, children) {
var options = Ctor.options;
var props2 = {};
var propOptions = options.props;
if (isDef(propOptions)) {
for (var key in propOptions) {
props2[key] = validateProp(key, propOptions, propsData || emptyObject);
}
} else {
if (isDef(data.attrs)) {
mergeProps(props2, data.attrs);
}
if (isDef(data.props)) {
mergeProps(props2, data.props);
}
}
var renderContext = new FunctionalRenderContext(data, props2, children, contextVm, Ctor);
var vnode = options.render.call(null, renderContext._c, renderContext);
if (vnode instanceof VNode) {
return cloneAndMarkFunctionalResult(vnode, data, renderContext.parent, options);
} else if (Array.isArray(vnode)) {
var vnodes = normalizeChildren(vnode) || [];
var res = new Array(vnodes.length);
for (var i = 0; i < vnodes.length; i++) {
res[i] = cloneAndMarkFunctionalResult(vnodes[i], data, renderContext.parent, options);
}
return res;
}
}
function cloneAndMarkFunctionalResult(vnode, data, contextVm, options, renderContext) {
var clone2 = cloneVNode(vnode);
clone2.fnContext = contextVm;
clone2.fnOptions = options;
if (data.slot) {
(clone2.data || (clone2.data = {})).slot = data.slot;
}
return clone2;
}
function mergeProps(to, from4) {
for (var key in from4) {
to[camelize(key)] = from4[key];
}
}
var componentVNodeHooks = {
init: function init(vnode, hydrating) {
if (vnode.componentInstance && !vnode.componentInstance._isDestroyed && vnode.data.keepAlive) {
var mountedNode = vnode;
componentVNodeHooks.prepatch(mountedNode, mountedNode);
} else {
var child3 = vnode.componentInstance = createComponentInstanceForVnode(vnode, activeInstance);
child3.$mount(hydrating ? vnode.elm : void 0, hydrating);
}
},
prepatch: function prepatch(oldVnode, vnode) {
var options = vnode.componentOptions;
var child3 = vnode.componentInstance = oldVnode.componentInstance;
updateChildComponent(child3, options.propsData, options.listeners, vnode, options.children);
},
insert: function insert(vnode) {
var context = vnode.context;
var componentInstance = vnode.componentInstance;
if (!componentInstance._isMounted) {
componentInstance._isMounted = true;
callHook(componentInstance, "mounted");
}
if (vnode.data.keepAlive) {
if (context._isMounted) {
queueActivatedComponent(componentInstance);
} else {
activateChildComponent(componentInstance, true);
}
}
},
destroy: function destroy(vnode) {
var componentInstance = vnode.componentInstance;
if (!componentInstance._isDestroyed) {
if (!vnode.data.keepAlive) {
componentInstance.$destroy();
} else {
deactivateChildComponent(componentInstance, true);
}
}
}
};
var hooksToMerge = Object.keys(componentVNodeHooks);
function createComponent(Ctor, data, context, children, tag2) {
if (isUndef(Ctor)) {
return;
}
var baseCtor = context.$options._base;
if (isObject$1(Ctor)) {
Ctor = baseCtor.extend(Ctor);
}
if (typeof Ctor !== "function") {
return;
}
var asyncFactory;
if (isUndef(Ctor.cid)) {
asyncFactory = Ctor;
Ctor = resolveAsyncComponent(asyncFactory, baseCtor);
if (Ctor === void 0) {
return createAsyncPlaceholder(asyncFactory, data, context, children, tag2);
}
}
data = data || {};
resolveConstructorOptions(Ctor);
if (isDef(data.model)) {
transformModel(Ctor.options, data);
}
var propsData = extractPropsFromVNodeData(data, Ctor);
if (isTrue(Ctor.options.functional)) {
return createFunctionalComponent(Ctor, propsData, data, context, children);
}
var listeners = data.on;
data.on = data.nativeOn;
if (isTrue(Ctor.options.abstract)) {
var slot = data.slot;
data = {};
if (slot) {
data.slot = slot;
}
}
installComponentHooks(data);
var name = Ctor.options.name || tag2;
var vnode = new VNode("vue-component-" + Ctor.cid + (name ? "-" + name : ""), data, void 0, void 0, void 0, context, {Ctor, propsData, listeners, tag: tag2, children}, asyncFactory);
return vnode;
}
function createComponentInstanceForVnode(vnode, parent) {
var options = {
_isComponent: true,
_parentVnode: vnode,
parent
};
var inlineTemplate = vnode.data.inlineTemplate;
if (isDef(inlineTemplate)) {
options.render = inlineTemplate.render;
options.staticRenderFns = inlineTemplate.staticRenderFns;
}
return new vnode.componentOptions.Ctor(options);
}
function installComponentHooks(data) {
var hooks2 = data.hook || (data.hook = {});
for (var i = 0; i < hooksToMerge.length; i++) {
var key = hooksToMerge[i];
var existing = hooks2[key];
var toMerge = componentVNodeHooks[key];
if (existing !== toMerge && !(existing && existing._merged)) {
hooks2[key] = existing ? mergeHook$1(toMerge, existing) : toMerge;
}
}
}
function mergeHook$1(f1, f2) {
var merged = function(a, b) {
f1(a, b);
f2(a, b);
};
merged._merged = true;
return merged;
}
function transformModel(options, data) {
var prop = options.model && options.model.prop || "value";
var event = options.model && options.model.event || "input";
(data.attrs || (data.attrs = {}))[prop] = data.model.value;
var on2 = data.on || (data.on = {});
var existing = on2[event];
var callback = data.model.callback;
if (isDef(existing)) {
if (Array.isArray(existing) ? existing.indexOf(callback) === -1 : existing !== callback) {
on2[event] = [callback].concat(existing);
}
} else {
on2[event] = callback;
}
}
var SIMPLE_NORMALIZE = 1;
var ALWAYS_NORMALIZE = 2;
function createElement$1(context, tag2, data, children, normalizationType, alwaysNormalize) {
if (Array.isArray(data) || isPrimitive(data)) {
normalizationType = children;
children = data;
data = void 0;
}
if (isTrue(alwaysNormalize)) {
normalizationType = ALWAYS_NORMALIZE;
}
return _createElement(context, tag2, data, children, normalizationType);
}
function _createElement(context, tag2, data, children, normalizationType) {
if (isDef(data) && isDef(data.__ob__)) {
return createEmptyVNode();
}
if (isDef(data) && isDef(data.is)) {
tag2 = data.is;
}
if (!tag2) {
return createEmptyVNode();
}
if (Array.isArray(children) && typeof children[0] === "function") {
data = data || {};
data.scopedSlots = {default: children[0]};
children.length = 0;
}
if (normalizationType === ALWAYS_NORMALIZE) {
children = normalizeChildren(children);
} else if (normalizationType === SIMPLE_NORMALIZE) {
children = simpleNormalizeChildren(children);
}
var vnode, ns;
if (typeof tag2 === "string") {
var Ctor;
ns = context.$vnode && context.$vnode.ns || config.getTagNamespace(tag2);
if (config.isReservedTag(tag2)) {
vnode = new VNode(config.parsePlatformTagName(tag2), data, children, void 0, void 0, context);
} else if ((!data || !data.pre) && isDef(Ctor = resolveAsset(context.$options, "components", tag2))) {
vnode = createComponent(Ctor, data, context, children, tag2);
} else {
vnode = new VNode(tag2, data, children, void 0, void 0, context);
}
} else {
vnode = createComponent(tag2, data, context, children);
}
if (Array.isArray(vnode)) {
return vnode;
} else if (isDef(vnode)) {
if (isDef(ns)) {
applyNS(vnode, ns);
}
if (isDef(data)) {
registerDeepBindings(data);
}
return vnode;
} else {
return createEmptyVNode();
}
}
function applyNS(vnode, ns, force) {
vnode.ns = ns;
if (vnode.tag === "foreignObject") {
ns = void 0;
force = true;
}
if (isDef(vnode.children)) {
for (var i = 0, l = vnode.children.length; i < l; i++) {
var child3 = vnode.children[i];
if (isDef(child3.tag) && (isUndef(child3.ns) || isTrue(force) && child3.tag !== "svg")) {
applyNS(child3, ns, force);
}
}
}
}
function registerDeepBindings(data) {
if (isObject$1(data.style)) {
traverse(data.style);
}
if (isObject$1(data.class)) {
traverse(data.class);
}
}
function initRender(vm) {
vm._vnode = null;
vm._staticTrees = null;
var options = vm.$options;
var parentVnode = vm.$vnode = options._parentVnode;
var renderContext = parentVnode && parentVnode.context;
vm.$slots = resolveSlots(options._renderChildren, renderContext);
vm.$scopedSlots = emptyObject;
vm._c = function(a, b, c, d) {
return createElement$1(vm, a, b, c, d, false);
};
vm.$createElement = function(a, b, c, d) {
return createElement$1(vm, a, b, c, d, true);
};
var parentData = parentVnode && parentVnode.data;
{
defineReactive$$1(vm, "$attrs", parentData && parentData.attrs || emptyObject, null, true);
defineReactive$$1(vm, "$listeners", options._parentListeners || emptyObject, null, true);
}
}
var currentRenderingInstance = null;
function renderMixin(Vue2) {
installRenderHelpers(Vue2.prototype);
Vue2.prototype.$nextTick = function(fn) {
return nextTick(fn, this);
};
Vue2.prototype._render = function() {
var vm = this;
var ref2 = vm.$options;
var render6 = ref2.render;
var _parentVnode = ref2._parentVnode;
if (_parentVnode) {
vm.$scopedSlots = normalizeScopedSlots(_parentVnode.data.scopedSlots, vm.$slots, vm.$scopedSlots);
}
vm.$vnode = _parentVnode;
var vnode;
try {
currentRenderingInstance = vm;
vnode = render6.call(vm._renderProxy, vm.$createElement);
} catch (e) {
handleError(e, vm, "render");
{
vnode = vm._vnode;
}
} finally {
currentRenderingInstance = null;
}
if (Array.isArray(vnode) && vnode.length === 1) {
vnode = vnode[0];
}
if (!(vnode instanceof VNode)) {
vnode = createEmptyVNode();
}
vnode.parent = _parentVnode;
return vnode;
};
}
function ensureCtor(comp, base2) {
if (comp.__esModule || hasSymbol$1 && comp[Symbol.toStringTag] === "Module") {
comp = comp.default;
}
return isObject$1(comp) ? base2.extend(comp) : comp;
}
function createAsyncPlaceholder(factory, data, context, children, tag2) {
var node4 = createEmptyVNode();
node4.asyncFactory = factory;
node4.asyncMeta = {data, context, children, tag: tag2};
return node4;
}
function resolveAsyncComponent(factory, baseCtor) {
if (isTrue(factory.error) && isDef(factory.errorComp)) {
return factory.errorComp;
}
if (isDef(factory.resolved)) {
return factory.resolved;
}
var owner = currentRenderingInstance;
if (owner && isDef(factory.owners) && factory.owners.indexOf(owner) === -1) {
factory.owners.push(owner);
}
if (isTrue(factory.loading) && isDef(factory.loadingComp)) {
return factory.loadingComp;
}
if (owner && !isDef(factory.owners)) {
var owners = factory.owners = [owner];
var sync2 = true;
var timerLoading = null;
var timerTimeout = null;
owner.$on("hook:destroyed", function() {
return remove(owners, owner);
});
var forceRender = function(renderCompleted) {
for (var i = 0, l = owners.length; i < l; i++) {
owners[i].$forceUpdate();
}
if (renderCompleted) {
owners.length = 0;
if (timerLoading !== null) {
clearTimeout(timerLoading);
timerLoading = null;
}
if (timerTimeout !== null) {
clearTimeout(timerTimeout);
timerTimeout = null;
}
}
};
var resolve9 = once$2(function(res2) {
factory.resolved = ensureCtor(res2, baseCtor);
if (!sync2) {
forceRender(true);
} else {
owners.length = 0;
}
});
var reject2 = once$2(function(reason) {
if (isDef(factory.errorComp)) {
factory.error = true;
forceRender(true);
}
});
var res = factory(resolve9, reject2);
if (isObject$1(res)) {
if (isPromise(res)) {
if (isUndef(factory.resolved)) {
res.then(resolve9, reject2);
}
} else if (isPromise(res.component)) {
res.component.then(resolve9, reject2);
if (isDef(res.error)) {
factory.errorComp = ensureCtor(res.error, baseCtor);
}
if (isDef(res.loading)) {
factory.loadingComp = ensureCtor(res.loading, baseCtor);
if (res.delay === 0) {
factory.loading = true;
} else {
timerLoading = setTimeout(function() {
timerLoading = null;
if (isUndef(factory.resolved) && isUndef(factory.error)) {
factory.loading = true;
forceRender(false);
}
}, res.delay || 200);
}
}
if (isDef(res.timeout)) {
timerTimeout = setTimeout(function() {
timerTimeout = null;
if (isUndef(factory.resolved)) {
reject2(null);
}
}, res.timeout);
}
}
}
sync2 = false;
return factory.loading ? factory.loadingComp : factory.resolved;
}
}
function isAsyncPlaceholder(node4) {
return node4.isComment && node4.asyncFactory;
}
function getFirstComponentChild(children) {
if (Array.isArray(children)) {
for (var i = 0; i < children.length; i++) {
var c = children[i];
if (isDef(c) && (isDef(c.componentOptions) || isAsyncPlaceholder(c))) {
return c;
}
}
}
}
function initEvents(vm) {
vm._events = Object.create(null);
vm._hasHookEvent = false;
var listeners = vm.$options._parentListeners;
if (listeners) {
updateComponentListeners(vm, listeners);
}
}
var target;
function add(event, fn) {
target.$on(event, fn);
}
function remove$1(event, fn) {
target.$off(event, fn);
}
function createOnceHandler(event, fn) {
var _target = target;
return function onceHandler() {
var res = fn.apply(null, arguments);
if (res !== null) {
_target.$off(event, onceHandler);
}
};
}
function updateComponentListeners(vm, listeners, oldListeners) {
target = vm;
updateListeners(listeners, oldListeners || {}, add, remove$1, createOnceHandler, vm);
target = void 0;
}
function eventsMixin(Vue2) {
var hookRE = /^hook:/;
Vue2.prototype.$on = function(event, fn) {
var vm = this;
if (Array.isArray(event)) {
for (var i = 0, l = event.length; i < l; i++) {
vm.$on(event[i], fn);
}
} else {
(vm._events[event] || (vm._events[event] = [])).push(fn);
if (hookRE.test(event)) {
vm._hasHookEvent = true;
}
}
return vm;
};
Vue2.prototype.$once = function(event, fn) {
var vm = this;
function on2() {
vm.$off(event, on2);
fn.apply(vm, arguments);
}
on2.fn = fn;
vm.$on(event, on2);
return vm;
};
Vue2.prototype.$off = function(event, fn) {
var vm = this;
if (!arguments.length) {
vm._events = Object.create(null);
return vm;
}
if (Array.isArray(event)) {
for (var i$1 = 0, l = event.length; i$1 < l; i$1++) {
vm.$off(event[i$1], fn);
}
return vm;
}
var cbs = vm._events[event];
if (!cbs) {
return vm;
}
if (!fn) {
vm._events[event] = null;
return vm;
}
var cb2;
var i = cbs.length;
while (i--) {
cb2 = cbs[i];
if (cb2 === fn || cb2.fn === fn) {
cbs.splice(i, 1);
break;
}
}
return vm;
};
Vue2.prototype.$emit = function(event) {
var vm = this;
var cbs = vm._events[event];
if (cbs) {
cbs = cbs.length > 1 ? toArray$1(cbs) : cbs;
var args = toArray$1(arguments, 1);
var info = 'event handler for "' + event + '"';
for (var i = 0, l = cbs.length; i < l; i++) {
invokeWithErrorHandling(cbs[i], vm, args, vm, info);
}
}
return vm;
};
}
var activeInstance = null;
function setActiveInstance(vm) {
var prevActiveInstance = activeInstance;
activeInstance = vm;
return function() {
activeInstance = prevActiveInstance;
};
}
function initLifecycle(vm) {
var options = vm.$options;
var parent = options.parent;
if (parent && !options.abstract) {
while (parent.$options.abstract && parent.$parent) {
parent = parent.$parent;
}
parent.$children.push(vm);
}
vm.$parent = parent;
vm.$root = parent ? parent.$root : vm;
vm.$children = [];
vm.$refs = {};
vm._watcher = null;
vm._inactive = null;
vm._directInactive = false;
vm._isMounted = false;
vm._isDestroyed = false;
vm._isBeingDestroyed = false;
}
function lifecycleMixin(Vue2) {
Vue2.prototype._update = function(vnode, hydrating) {
var vm = this;
var prevEl = vm.$el;
var prevVnode = vm._vnode;
var restoreActiveInstance = setActiveInstance(vm);
vm._vnode = vnode;
if (!prevVnode) {
vm.$el = vm.__patch__(vm.$el, vnode, hydrating, false);
} else {
vm.$el = vm.__patch__(prevVnode, vnode);
}
restoreActiveInstance();
if (prevEl) {
prevEl.__vue__ = null;
}
if (vm.$el) {
vm.$el.__vue__ = vm;
}
if (vm.$vnode && vm.$parent && vm.$vnode === vm.$parent._vnode) {
vm.$parent.$el = vm.$el;
}
};
Vue2.prototype.$forceUpdate = function() {
var vm = this;
if (vm._watcher) {
vm._watcher.update();
}
};
Vue2.prototype.$destroy = function() {
var vm = this;
if (vm._isBeingDestroyed) {
return;
}
callHook(vm, "beforeDestroy");
vm._isBeingDestroyed = true;
var parent = vm.$parent;
if (parent && !parent._isBeingDestroyed && !vm.$options.abstract) {
remove(parent.$children, vm);
}
if (vm._watcher) {
vm._watcher.teardown();
}
var i = vm._watchers.length;
while (i--) {
vm._watchers[i].teardown();
}
if (vm._data.__ob__) {
vm._data.__ob__.vmCount--;
}
vm._isDestroyed = true;
vm.__patch__(vm._vnode, null);
callHook(vm, "destroyed");
vm.$off();
if (vm.$el) {
vm.$el.__vue__ = null;
}
if (vm.$vnode) {
vm.$vnode.parent = null;
}
};
}
function mountComponent(vm, el, hydrating) {
vm.$el = el;
if (!vm.$options.render) {
vm.$options.render = createEmptyVNode;
}
callHook(vm, "beforeMount");
var updateComponent;
{
updateComponent = function() {
vm._update(vm._render(), hydrating);
};
}
new Watcher(vm, updateComponent, noop$3, {
before: function before3() {
if (vm._isMounted && !vm._isDestroyed) {
callHook(vm, "beforeUpdate");
}
}
}, true);
hydrating = false;
if (vm.$vnode == null) {
vm._isMounted = true;
callHook(vm, "mounted");
}
return vm;
}
function updateChildComponent(vm, propsData, listeners, parentVnode, renderChildren) {
var newScopedSlots = parentVnode.data.scopedSlots;
var oldScopedSlots = vm.$scopedSlots;
var hasDynamicScopedSlot = !!(newScopedSlots && !newScopedSlots.$stable || oldScopedSlots !== emptyObject && !oldScopedSlots.$stable || newScopedSlots && vm.$scopedSlots.$key !== newScopedSlots.$key);
var needsForceUpdate = !!(renderChildren || vm.$options._renderChildren || hasDynamicScopedSlot);
vm.$options._parentVnode = parentVnode;
vm.$vnode = parentVnode;
if (vm._vnode) {
vm._vnode.parent = parentVnode;
}
vm.$options._renderChildren = renderChildren;
vm.$attrs = parentVnode.data.attrs || emptyObject;
vm.$listeners = listeners || emptyObject;
if (propsData && vm.$options.props) {
toggleObserving(false);
var props2 = vm._props;
var propKeys = vm.$options._propKeys || [];
for (var i = 0; i < propKeys.length; i++) {
var key = propKeys[i];
var propOptions = vm.$options.props;
props2[key] = validateProp(key, propOptions, propsData, vm);
}
toggleObserving(true);
vm.$options.propsData = propsData;
}
listeners = listeners || emptyObject;
var oldListeners = vm.$options._parentListeners;
vm.$options._parentListeners = listeners;
updateComponentListeners(vm, listeners, oldListeners);
if (needsForceUpdate) {
vm.$slots = resolveSlots(renderChildren, parentVnode.context);
vm.$forceUpdate();
}
}
function isInInactiveTree(vm) {
while (vm && (vm = vm.$parent)) {
if (vm._inactive) {
return true;
}
}
return false;
}
function activateChildComponent(vm, direct) {
if (direct) {
vm._directInactive = false;
if (isInInactiveTree(vm)) {
return;
}
} else if (vm._directInactive) {
return;
}
if (vm._inactive || vm._inactive === null) {
vm._inactive = false;
for (var i = 0; i < vm.$children.length; i++) {
activateChildComponent(vm.$children[i]);
}
callHook(vm, "activated");
}
}
function deactivateChildComponent(vm, direct) {
if (direct) {
vm._directInactive = true;
if (isInInactiveTree(vm)) {
return;
}
}
if (!vm._inactive) {
vm._inactive = true;
for (var i = 0; i < vm.$children.length; i++) {
deactivateChildComponent(vm.$children[i]);
}
callHook(vm, "deactivated");
}
}
function callHook(vm, hook) {
pushTarget();
var handlers2 = vm.$options[hook];
var info = hook + " hook";
if (handlers2) {
for (var i = 0, j = handlers2.length; i < j; i++) {
invokeWithErrorHandling(handlers2[i], vm, null, vm, info);
}
}
if (vm._hasHookEvent) {
vm.$emit("hook:" + hook);
}
popTarget();
}
var queue = [];
var activatedChildren = [];
var has$5 = {};
var waiting = false;
var flushing = false;
var index$1 = 0;
function resetSchedulerState() {
index$1 = queue.length = activatedChildren.length = 0;
has$5 = {};
waiting = flushing = false;
}
var currentFlushTimestamp = 0;
var getNow = Date.now;
if (inBrowser$1 && !isIE) {
var performance = window.performance;
if (performance && typeof performance.now === "function" && getNow() > document.createEvent("Event").timeStamp) {
getNow = function() {
return performance.now();
};
}
}
function flushSchedulerQueue() {
currentFlushTimestamp = getNow();
flushing = true;
var watcher, id;
queue.sort(function(a, b) {
return a.id - b.id;
});
for (index$1 = 0; index$1 < queue.length; index$1++) {
watcher = queue[index$1];
if (watcher.before) {
watcher.before();
}
id = watcher.id;
has$5[id] = null;
watcher.run();
}
var activatedQueue = activatedChildren.slice();
var updatedQueue = queue.slice();
resetSchedulerState();
callActivatedHooks(activatedQueue);
callUpdatedHooks(updatedQueue);
if (devtools && config.devtools) {
devtools.emit("flush");
}
}
function callUpdatedHooks(queue2) {
var i = queue2.length;
while (i--) {
var watcher = queue2[i];
var vm = watcher.vm;
if (vm._watcher === watcher && vm._isMounted && !vm._isDestroyed) {
callHook(vm, "updated");
}
}
}
function queueActivatedComponent(vm) {
vm._inactive = false;
activatedChildren.push(vm);
}
function callActivatedHooks(queue2) {
for (var i = 0; i < queue2.length; i++) {
queue2[i]._inactive = true;
activateChildComponent(queue2[i], true);
}
}
function queueWatcher(watcher) {
var id = watcher.id;
if (has$5[id] == null) {
has$5[id] = true;
if (!flushing) {
queue.push(watcher);
} else {
var i = queue.length - 1;
while (i > index$1 && queue[i].id > watcher.id) {
i--;
}
queue.splice(i + 1, 0, watcher);
}
if (!waiting) {
waiting = true;
nextTick(flushSchedulerQueue);
}
}
}
var uid$2 = 0;
var Watcher = function Watcher2(vm, expOrFn, cb2, options, isRenderWatcher) {
this.vm = vm;
if (isRenderWatcher) {
vm._watcher = this;
}
vm._watchers.push(this);
if (options) {
this.deep = !!options.deep;
this.user = !!options.user;
this.lazy = !!options.lazy;
this.sync = !!options.sync;
this.before = options.before;
} else {
this.deep = this.user = this.lazy = this.sync = false;
}
this.cb = cb2;
this.id = ++uid$2;
this.active = true;
this.dirty = this.lazy;
this.deps = [];
this.newDeps = [];
this.depIds = new _Set();
this.newDepIds = new _Set();
this.expression = "";
if (typeof expOrFn === "function") {
this.getter = expOrFn;
} else {
this.getter = parsePath$1(expOrFn);
if (!this.getter) {
this.getter = noop$3;
}
}
this.value = this.lazy ? void 0 : this.get();
};
Watcher.prototype.get = function get() {
pushTarget(this);
var value;
var vm = this.vm;
try {
value = this.getter.call(vm, vm);
} catch (e) {
if (this.user) {
handleError(e, vm, 'getter for watcher "' + this.expression + '"');
} else {
throw e;
}
} finally {
if (this.deep) {
traverse(value);
}
popTarget();
this.cleanupDeps();
}
return value;
};
Watcher.prototype.addDep = function addDep(dep) {
var id = dep.id;
if (!this.newDepIds.has(id)) {
this.newDepIds.add(id);
this.newDeps.push(dep);
if (!this.depIds.has(id)) {
dep.addSub(this);
}
}
};
Watcher.prototype.cleanupDeps = function cleanupDeps() {
var i = this.deps.length;
while (i--) {
var dep = this.deps[i];
if (!this.newDepIds.has(dep.id)) {
dep.removeSub(this);
}
}
var tmp = this.depIds;
this.depIds = this.newDepIds;
this.newDepIds = tmp;
this.newDepIds.clear();
tmp = this.deps;
this.deps = this.newDeps;
this.newDeps = tmp;
this.newDeps.length = 0;
};
Watcher.prototype.update = function update() {
if (this.lazy) {
this.dirty = true;
} else if (this.sync) {
this.run();
} else {
queueWatcher(this);
}
};
Watcher.prototype.run = function run() {
if (this.active) {
var value = this.get();
if (value !== this.value || isObject$1(value) || this.deep) {
var oldValue = this.value;
this.value = value;
if (this.user) {
try {
this.cb.call(this.vm, value, oldValue);
} catch (e) {
handleError(e, this.vm, 'callback for watcher "' + this.expression + '"');
}
} else {
this.cb.call(this.vm, value, oldValue);
}
}
}
};
Watcher.prototype.evaluate = function evaluate() {
this.value = this.get();
this.dirty = false;
};
Watcher.prototype.depend = function depend2() {
var i = this.deps.length;
while (i--) {
this.deps[i].depend();
}
};
Watcher.prototype.teardown = function teardown() {
if (this.active) {
if (!this.vm._isBeingDestroyed) {
remove(this.vm._watchers, this);
}
var i = this.deps.length;
while (i--) {
this.deps[i].removeSub(this);
}
this.active = false;
}
};
var sharedPropertyDefinition = {
enumerable: true,
configurable: true,
get: noop$3,
set: noop$3
};
function proxy(target2, sourceKey, key) {
sharedPropertyDefinition.get = function proxyGetter() {
return this[sourceKey][key];
};
sharedPropertyDefinition.set = function proxySetter(val) {
this[sourceKey][key] = val;
};
Object.defineProperty(target2, key, sharedPropertyDefinition);
}
function initState(vm) {
vm._watchers = [];
var opts = vm.$options;
if (opts.props) {
initProps(vm, opts.props);
}
if (opts.methods) {
initMethods(vm, opts.methods);
}
if (opts.data) {
initData(vm);
} else {
observe(vm._data = {}, true);
}
if (opts.computed) {
initComputed(vm, opts.computed);
}
if (opts.watch && opts.watch !== nativeWatch) {
initWatch(vm, opts.watch);
}
}
function initProps(vm, propsOptions) {
var propsData = vm.$options.propsData || {};
var props2 = vm._props = {};
var keys2 = vm.$options._propKeys = [];
var isRoot = !vm.$parent;
if (!isRoot) {
toggleObserving(false);
}
var loop = function(key2) {
keys2.push(key2);
var value = validateProp(key2, propsOptions, propsData, vm);
{
defineReactive$$1(props2, key2, value);
}
if (!(key2 in vm)) {
proxy(vm, "_props", key2);
}
};
for (var key in propsOptions)
loop(key);
toggleObserving(true);
}
function initData(vm) {
var data = vm.$options.data;
data = vm._data = typeof data === "function" ? getData(data, vm) : data || {};
if (!isPlainObject(data)) {
data = {};
}
var keys2 = Object.keys(data);
var props2 = vm.$options.props;
vm.$options.methods;
var i = keys2.length;
while (i--) {
var key = keys2[i];
if (props2 && hasOwn$1(props2, key))
;
else if (!isReserved(key)) {
proxy(vm, "_data", key);
}
}
observe(data, true);
}
function getData(data, vm) {
pushTarget();
try {
return data.call(vm, vm);
} catch (e) {
handleError(e, vm, "data()");
return {};
} finally {
popTarget();
}
}
var computedWatcherOptions = {lazy: true};
function initComputed(vm, computed) {
var watchers = vm._computedWatchers = Object.create(null);
var isSSR = isServerRendering();
for (var key in computed) {
var userDef = computed[key];
var getter = typeof userDef === "function" ? userDef : userDef.get;
if (!isSSR) {
watchers[key] = new Watcher(vm, getter || noop$3, noop$3, computedWatcherOptions);
}
if (!(key in vm)) {
defineComputed(vm, key, userDef);
}
}
}
function defineComputed(target2, key, userDef) {
var shouldCache = !isServerRendering();
if (typeof userDef === "function") {
sharedPropertyDefinition.get = shouldCache ? createComputedGetter(key) : createGetterInvoker(userDef);
sharedPropertyDefinition.set = noop$3;
} else {
sharedPropertyDefinition.get = userDef.get ? shouldCache && userDef.cache !== false ? createComputedGetter(key) : createGetterInvoker(userDef.get) : noop$3;
sharedPropertyDefinition.set = userDef.set || noop$3;
}
Object.defineProperty(target2, key, sharedPropertyDefinition);
}
function createComputedGetter(key) {
return function computedGetter() {
var watcher = this._computedWatchers && this._computedWatchers[key];
if (watcher) {
if (watcher.dirty) {
watcher.evaluate();
}
if (Dep.target) {
watcher.depend();
}
return watcher.value;
}
};
}
function createGetterInvoker(fn) {
return function computedGetter() {
return fn.call(this, this);
};
}
function initMethods(vm, methods) {
vm.$options.props;
for (var key in methods) {
vm[key] = typeof methods[key] !== "function" ? noop$3 : bind$2(methods[key], vm);
}
}
function initWatch(vm, watch) {
for (var key in watch) {
var handler = watch[key];
if (Array.isArray(handler)) {
for (var i = 0; i < handler.length; i++) {
createWatcher(vm, key, handler[i]);
}
} else {
createWatcher(vm, key, handler);
}
}
}
function createWatcher(vm, expOrFn, handler, options) {
if (isPlainObject(handler)) {
options = handler;
handler = handler.handler;
}
if (typeof handler === "string") {
handler = vm[handler];
}
return vm.$watch(expOrFn, handler, options);
}
function stateMixin(Vue2) {
var dataDef = {};
dataDef.get = function() {
return this._data;
};
var propsDef = {};
propsDef.get = function() {
return this._props;
};
Object.defineProperty(Vue2.prototype, "$data", dataDef);
Object.defineProperty(Vue2.prototype, "$props", propsDef);
Vue2.prototype.$set = set;
Vue2.prototype.$delete = del$1;
Vue2.prototype.$watch = function(expOrFn, cb2, options) {
var vm = this;
if (isPlainObject(cb2)) {
return createWatcher(vm, expOrFn, cb2, options);
}
options = options || {};
options.user = true;
var watcher = new Watcher(vm, expOrFn, cb2, options);
if (options.immediate) {
try {
cb2.call(vm, watcher.value);
} catch (error2) {
handleError(error2, vm, 'callback for immediate watcher "' + watcher.expression + '"');
}
}
return function unwatchFn() {
watcher.teardown();
};
};
}
var uid$3 = 0;
function initMixin(Vue2) {
Vue2.prototype._init = function(options) {
var vm = this;
vm._uid = uid$3++;
vm._isVue = true;
if (options && options._isComponent) {
initInternalComponent(vm, options);
} else {
vm.$options = mergeOptions(resolveConstructorOptions(vm.constructor), options || {}, vm);
}
{
vm._renderProxy = vm;
}
vm._self = vm;
initLifecycle(vm);
initEvents(vm);
initRender(vm);
callHook(vm, "beforeCreate");
initInjections(vm);
initState(vm);
initProvide(vm);
callHook(vm, "created");
if (vm.$options.el) {
vm.$mount(vm.$options.el);
}
};
}
function initInternalComponent(vm, options) {
var opts = vm.$options = Object.create(vm.constructor.options);
var parentVnode = options._parentVnode;
opts.parent = options.parent;
opts._parentVnode = parentVnode;
var vnodeComponentOptions = parentVnode.componentOptions;
opts.propsData = vnodeComponentOptions.propsData;
opts._parentListeners = vnodeComponentOptions.listeners;
opts._renderChildren = vnodeComponentOptions.children;
opts._componentTag = vnodeComponentOptions.tag;
if (options.render) {
opts.render = options.render;
opts.staticRenderFns = options.staticRenderFns;
}
}
function resolveConstructorOptions(Ctor) {
var options = Ctor.options;
if (Ctor.super) {
var superOptions = resolveConstructorOptions(Ctor.super);
var cachedSuperOptions = Ctor.superOptions;
if (superOptions !== cachedSuperOptions) {
Ctor.superOptions = superOptions;
var modifiedOptions = resolveModifiedOptions(Ctor);
if (modifiedOptions) {
extend$3(Ctor.extendOptions, modifiedOptions);
}
options = Ctor.options = mergeOptions(superOptions, Ctor.extendOptions);
if (options.name) {
options.components[options.name] = Ctor;
}
}
}
return options;
}
function resolveModifiedOptions(Ctor) {
var modified;
var latest = Ctor.options;
var sealed = Ctor.sealedOptions;
for (var key in latest) {
if (latest[key] !== sealed[key]) {
if (!modified) {
modified = {};
}
modified[key] = latest[key];
}
}
return modified;
}
function Vue(options) {
this._init(options);
}
initMixin(Vue);
stateMixin(Vue);
eventsMixin(Vue);
lifecycleMixin(Vue);
renderMixin(Vue);
function initUse(Vue2) {
Vue2.use = function(plugin) {
var installedPlugins = this._installedPlugins || (this._installedPlugins = []);
if (installedPlugins.indexOf(plugin) > -1) {
return this;
}
var args = toArray$1(arguments, 1);
args.unshift(this);
if (typeof plugin.install === "function") {
plugin.install.apply(plugin, args);
} else if (typeof plugin === "function") {
plugin.apply(null, args);
}
installedPlugins.push(plugin);
return this;
};
}
function initMixin$1(Vue2) {
Vue2.mixin = function(mixin2) {
this.options = mergeOptions(this.options, mixin2);
return this;
};
}
function initExtend(Vue2) {
Vue2.cid = 0;
var cid = 1;
Vue2.extend = function(extendOptions) {
extendOptions = extendOptions || {};
var Super = this;
var SuperId = Super.cid;
var cachedCtors = extendOptions._Ctor || (extendOptions._Ctor = {});
if (cachedCtors[SuperId]) {
return cachedCtors[SuperId];
}
var name = extendOptions.name || Super.options.name;
var Sub = function VueComponent(options) {
this._init(options);
};
Sub.prototype = Object.create(Super.prototype);
Sub.prototype.constructor = Sub;
Sub.cid = cid++;
Sub.options = mergeOptions(Super.options, extendOptions);
Sub["super"] = Super;
if (Sub.options.props) {
initProps$1(Sub);
}
if (Sub.options.computed) {
initComputed$1(Sub);
}
Sub.extend = Super.extend;
Sub.mixin = Super.mixin;
Sub.use = Super.use;
ASSET_TYPES.forEach(function(type) {
Sub[type] = Super[type];
});
if (name) {
Sub.options.components[name] = Sub;
}
Sub.superOptions = Super.options;
Sub.extendOptions = extendOptions;
Sub.sealedOptions = extend$3({}, Sub.options);
cachedCtors[SuperId] = Sub;
return Sub;
};
}
function initProps$1(Comp) {
var props2 = Comp.options.props;
for (var key in props2) {
proxy(Comp.prototype, "_props", key);
}
}
function initComputed$1(Comp) {
var computed = Comp.options.computed;
for (var key in computed) {
defineComputed(Comp.prototype, key, computed[key]);
}
}
function initAssetRegisters(Vue2) {
ASSET_TYPES.forEach(function(type) {
Vue2[type] = function(id, definition) {
if (!definition) {
return this.options[type + "s"][id];
} else {
if (type === "component" && isPlainObject(definition)) {
definition.name = definition.name || id;
definition = this.options._base.extend(definition);
}
if (type === "directive" && typeof definition === "function") {
definition = {bind: definition, update: definition};
}
this.options[type + "s"][id] = definition;
return definition;
}
};
});
}
function getComponentName(opts) {
return opts && (opts.Ctor.options.name || opts.tag);
}
function matches$2(pattern, name) {
if (Array.isArray(pattern)) {
return pattern.indexOf(name) > -1;
} else if (typeof pattern === "string") {
return pattern.split(",").indexOf(name) > -1;
} else if (isRegExp$3(pattern)) {
return pattern.test(name);
}
return false;
}
function pruneCache(keepAliveInstance, filter2) {
var cache = keepAliveInstance.cache;
var keys2 = keepAliveInstance.keys;
var _vnode = keepAliveInstance._vnode;
for (var key in cache) {
var cachedNode = cache[key];
if (cachedNode) {
var name = getComponentName(cachedNode.componentOptions);
if (name && !filter2(name)) {
pruneCacheEntry(cache, key, keys2, _vnode);
}
}
}
}
function pruneCacheEntry(cache, key, keys2, current) {
var cached$$1 = cache[key];
if (cached$$1 && (!current || cached$$1.tag !== current.tag)) {
cached$$1.componentInstance.$destroy();
}
cache[key] = null;
remove(keys2, key);
}
var patternTypes = [String, RegExp, Array];
var KeepAlive = {
name: "keep-alive",
abstract: true,
props: {
include: patternTypes,
exclude: patternTypes,
max: [String, Number]
},
created: function created() {
this.cache = Object.create(null);
this.keys = [];
},
destroyed: function destroyed() {
for (var key in this.cache) {
pruneCacheEntry(this.cache, key, this.keys);
}
},
mounted: function mounted() {
var this$1 = this;
this.$watch("include", function(val) {
pruneCache(this$1, function(name) {
return matches$2(val, name);
});
});
this.$watch("exclude", function(val) {
pruneCache(this$1, function(name) {
return !matches$2(val, name);
});
});
},
render: function render() {
var slot = this.$slots.default;
var vnode = getFirstComponentChild(slot);
var componentOptions = vnode && vnode.componentOptions;
if (componentOptions) {
var name = getComponentName(componentOptions);
var ref2 = this;
var include = ref2.include;
var exclude = ref2.exclude;
if (include && (!name || !matches$2(include, name)) || exclude && name && matches$2(exclude, name)) {
return vnode;
}
var ref$12 = this;
var cache = ref$12.cache;
var keys2 = ref$12.keys;
var key = vnode.key == null ? componentOptions.Ctor.cid + (componentOptions.tag ? "::" + componentOptions.tag : "") : vnode.key;
if (cache[key]) {
vnode.componentInstance = cache[key].componentInstance;
remove(keys2, key);
keys2.push(key);
} else {
cache[key] = vnode;
keys2.push(key);
if (this.max && keys2.length > parseInt(this.max)) {
pruneCacheEntry(cache, keys2[0], keys2, this._vnode);
}
}
vnode.data.keepAlive = true;
}
return vnode || slot && slot[0];
}
};
var builtInComponents = {
KeepAlive
};
function initGlobalAPI(Vue2) {
var configDef = {};
configDef.get = function() {
return config;
};
Object.defineProperty(Vue2, "config", configDef);
Vue2.util = {
warn: warn$1,
extend: extend$3,
mergeOptions,
defineReactive: defineReactive$$1
};
Vue2.set = set;
Vue2.delete = del$1;
Vue2.nextTick = nextTick;
Vue2.observable = function(obj) {
observe(obj);
return obj;
};
Vue2.options = Object.create(null);
ASSET_TYPES.forEach(function(type) {
Vue2.options[type + "s"] = Object.create(null);
});
Vue2.options._base = Vue2;
extend$3(Vue2.options.components, builtInComponents);
initUse(Vue2);
initMixin$1(Vue2);
initExtend(Vue2);
initAssetRegisters(Vue2);
}
initGlobalAPI(Vue);
Object.defineProperty(Vue.prototype, "$isServer", {
get: isServerRendering
});
Object.defineProperty(Vue.prototype, "$ssrContext", {
get: function get2() {
return this.$vnode && this.$vnode.ssrContext;
}
});
Object.defineProperty(Vue, "FunctionalRenderContext", {
value: FunctionalRenderContext
});
Vue.version = "2.6.12";
var isReservedAttr = makeMap("style,class");
var acceptValue = makeMap("input,textarea,option,select,progress");
var mustUseProp = function(tag2, type, attr) {
return attr === "value" && acceptValue(tag2) && type !== "button" || attr === "selected" && tag2 === "option" || attr === "checked" && tag2 === "input" || attr === "muted" && tag2 === "video";
};
var isEnumeratedAttr = makeMap("contenteditable,draggable,spellcheck");
var isValidContentEditableValue = makeMap("events,caret,typing,plaintext-only");
var convertEnumeratedValue = function(key, value) {
return isFalsyAttrValue(value) || value === "false" ? "false" : key === "contenteditable" && isValidContentEditableValue(value) ? value : "true";
};
var isBooleanAttr = makeMap("allowfullscreen,async,autofocus,autoplay,checked,compact,controls,declare,default,defaultchecked,defaultmuted,defaultselected,defer,disabled,enabled,formnovalidate,hidden,indeterminate,inert,ismap,itemscope,loop,multiple,muted,nohref,noresize,noshade,novalidate,nowrap,open,pauseonexit,readonly,required,reversed,scoped,seamless,selected,sortable,translate,truespeed,typemustmatch,visible");
var xlinkNS = "http://www.w3.org/1999/xlink";
var isXlink = function(name) {
return name.charAt(5) === ":" && name.slice(0, 5) === "xlink";
};
var getXlinkProp = function(name) {
return isXlink(name) ? name.slice(6, name.length) : "";
};
var isFalsyAttrValue = function(val) {
return val == null || val === false;
};
function genClassForVnode(vnode) {
var data = vnode.data;
var parentNode2 = vnode;
var childNode = vnode;
while (isDef(childNode.componentInstance)) {
childNode = childNode.componentInstance._vnode;
if (childNode && childNode.data) {
data = mergeClassData(childNode.data, data);
}
}
while (isDef(parentNode2 = parentNode2.parent)) {
if (parentNode2 && parentNode2.data) {
data = mergeClassData(data, parentNode2.data);
}
}
return renderClass(data.staticClass, data.class);
}
function mergeClassData(child3, parent) {
return {
staticClass: concat$1(child3.staticClass, parent.staticClass),
class: isDef(child3.class) ? [child3.class, parent.class] : parent.class
};
}
function renderClass(staticClass, dynamicClass) {
if (isDef(staticClass) || isDef(dynamicClass)) {
return concat$1(staticClass, stringifyClass(dynamicClass));
}
return "";
}
function concat$1(a, b) {
return a ? b ? a + " " + b : a : b || "";
}
function stringifyClass(value) {
if (Array.isArray(value)) {
return stringifyArray(value);
}
if (isObject$1(value)) {
return stringifyObject(value);
}
if (typeof value === "string") {
return value;
}
return "";
}
function stringifyArray(value) {
var res = "";
var stringified;
for (var i = 0, l = value.length; i < l; i++) {
if (isDef(stringified = stringifyClass(value[i])) && stringified !== "") {
if (res) {
res += " ";
}
res += stringified;
}
}
return res;
}
function stringifyObject(value) {
var res = "";
for (var key in value) {
if (value[key]) {
if (res) {
res += " ";
}
res += key;
}
}
return res;
}
var namespaceMap = {
svg: "http://www.w3.org/2000/svg",
math: "http://www.w3.org/1998/Math/MathML"
};
var isHTMLTag = makeMap("html,body,base,head,link,meta,style,title,address,article,aside,footer,header,h1,h2,h3,h4,h5,h6,hgroup,nav,section,div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,rtc,ruby,s,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,embed,object,param,source,canvas,script,noscript,del,ins,caption,col,colgroup,table,thead,tbody,td,th,tr,button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,output,progress,select,textarea,details,dialog,menu,menuitem,summary,content,element,shadow,template,blockquote,iframe,tfoot");
var isSVG = makeMap("svg,animate,circle,clippath,cursor,defs,desc,ellipse,filter,font-face,foreignObject,g,glyph,image,line,marker,mask,missing-glyph,path,pattern,polygon,polyline,rect,switch,symbol,text,textpath,tspan,use,view", true);
var isPreTag = function(tag2) {
return tag2 === "pre";
};
var isReservedTag = function(tag2) {
return isHTMLTag(tag2) || isSVG(tag2);
};
function getTagNamespace(tag2) {
if (isSVG(tag2)) {
return "svg";
}
if (tag2 === "math") {
return "math";
}
}
var unknownElementCache = Object.create(null);
function isUnknownElement(tag2) {
if (!inBrowser$1) {
return true;
}
if (isReservedTag(tag2)) {
return false;
}
tag2 = tag2.toLowerCase();
if (unknownElementCache[tag2] != null) {
return unknownElementCache[tag2];
}
var el = document.createElement(tag2);
if (tag2.indexOf("-") > -1) {
return unknownElementCache[tag2] = el.constructor === window.HTMLUnknownElement || el.constructor === window.HTMLElement;
} else {
return unknownElementCache[tag2] = /HTMLUnknownElement/.test(el.toString());
}
}
var isTextInputType = makeMap("text,number,password,search,email,tel,url");
function query(el) {
if (typeof el === "string") {
var selected = document.querySelector(el);
if (!selected) {
return document.createElement("div");
}
return selected;
} else {
return el;
}
}
function createElement$1$1(tagName2, vnode) {
var elm = document.createElement(tagName2);
if (tagName2 !== "select") {
return elm;
}
if (vnode.data && vnode.data.attrs && vnode.data.attrs.multiple !== void 0) {
elm.setAttribute("multiple", "multiple");
}
return elm;
}
function createElementNS(namespace, tagName2) {
return document.createElementNS(namespaceMap[namespace], tagName2);
}
function createTextNode(text3) {
return document.createTextNode(text3);
}
function createComment(text3) {
return document.createComment(text3);
}
function insertBefore(parentNode2, newNode, referenceNode) {
parentNode2.insertBefore(newNode, referenceNode);
}
function removeChild(node4, child3) {
node4.removeChild(child3);
}
function appendChild(node4, child3) {
node4.appendChild(child3);
}
function parentNode$1(node4) {
return node4.parentNode;
}
function nextSibling(node4) {
return node4.nextSibling;
}
function tagName(node4) {
return node4.tagName;
}
function setTextContent(node4, text3) {
node4.textContent = text3;
}
function setStyleScope(node4, scopeId) {
node4.setAttribute(scopeId, "");
}
var nodeOps = /* @__PURE__ */ Object.freeze({
createElement: createElement$1$1,
createElementNS,
createTextNode,
createComment,
insertBefore,
removeChild,
appendChild,
parentNode: parentNode$1,
nextSibling,
tagName,
setTextContent,
setStyleScope
});
var ref = {
create: function create(_2, vnode) {
registerRef(vnode);
},
update: function update2(oldVnode, vnode) {
if (oldVnode.data.ref !== vnode.data.ref) {
registerRef(oldVnode, true);
registerRef(vnode);
}
},
destroy: function destroy2(vnode) {
registerRef(vnode, true);
}
};
function registerRef(vnode, isRemoval) {
var key = vnode.data.ref;
if (!isDef(key)) {
return;
}
var vm = vnode.context;
var ref2 = vnode.componentInstance || vnode.elm;
var refs = vm.$refs;
if (isRemoval) {
if (Array.isArray(refs[key])) {
remove(refs[key], ref2);
} else if (refs[key] === ref2) {
refs[key] = void 0;
}
} else {
if (vnode.data.refInFor) {
if (!Array.isArray(refs[key])) {
refs[key] = [ref2];
} else if (refs[key].indexOf(ref2) < 0) {
refs[key].push(ref2);
}
} else {
refs[key] = ref2;
}
}
}
var emptyNode = new VNode("", {}, []);
var hooks = ["create", "activate", "update", "remove", "destroy"];
function sameVnode(a, b) {
return a.key === b.key && (a.tag === b.tag && a.isComment === b.isComment && isDef(a.data) === isDef(b.data) && sameInputType(a, b) || isTrue(a.isAsyncPlaceholder) && a.asyncFactory === b.asyncFactory && isUndef(b.asyncFactory.error));
}
function sameInputType(a, b) {
if (a.tag !== "input") {
return true;
}
var i;
var typeA = isDef(i = a.data) && isDef(i = i.attrs) && i.type;
var typeB = isDef(i = b.data) && isDef(i = i.attrs) && i.type;
return typeA === typeB || isTextInputType(typeA) && isTextInputType(typeB);
}
function createKeyToOldIdx(children, beginIdx, endIdx) {
var i, key;
var map16 = {};
for (i = beginIdx; i <= endIdx; ++i) {
key = children[i].key;
if (isDef(key)) {
map16[key] = i;
}
}
return map16;
}
function createPatchFunction(backend) {
var i, j;
var cbs = {};
var modules2 = backend.modules;
var nodeOps2 = backend.nodeOps;
for (i = 0; i < hooks.length; ++i) {
cbs[hooks[i]] = [];
for (j = 0; j < modules2.length; ++j) {
if (isDef(modules2[j][hooks[i]])) {
cbs[hooks[i]].push(modules2[j][hooks[i]]);
}
}
}
function emptyNodeAt(elm) {
return new VNode(nodeOps2.tagName(elm).toLowerCase(), {}, [], void 0, elm);
}
function createRmCb(childElm, listeners) {
function remove$$12() {
if (--remove$$12.listeners === 0) {
removeNode(childElm);
}
}
remove$$12.listeners = listeners;
return remove$$12;
}
function removeNode(el) {
var parent = nodeOps2.parentNode(el);
if (isDef(parent)) {
nodeOps2.removeChild(parent, el);
}
}
function createElm(vnode, insertedVnodeQueue, parentElm, refElm, nested, ownerArray, index3) {
if (isDef(vnode.elm) && isDef(ownerArray)) {
vnode = ownerArray[index3] = cloneVNode(vnode);
}
vnode.isRootInsert = !nested;
if (createComponent2(vnode, insertedVnodeQueue, parentElm, refElm)) {
return;
}
var data = vnode.data;
var children = vnode.children;
var tag2 = vnode.tag;
if (isDef(tag2)) {
vnode.elm = vnode.ns ? nodeOps2.createElementNS(vnode.ns, tag2) : nodeOps2.createElement(tag2, vnode);
setScope(vnode);
{
createChildren(vnode, children, insertedVnodeQueue);
if (isDef(data)) {
invokeCreateHooks(vnode, insertedVnodeQueue);
}
insert2(parentElm, vnode.elm, refElm);
}
} else if (isTrue(vnode.isComment)) {
vnode.elm = nodeOps2.createComment(vnode.text);
insert2(parentElm, vnode.elm, refElm);
} else {
vnode.elm = nodeOps2.createTextNode(vnode.text);
insert2(parentElm, vnode.elm, refElm);
}
}
function createComponent2(vnode, insertedVnodeQueue, parentElm, refElm) {
var i2 = vnode.data;
if (isDef(i2)) {
var isReactivated = isDef(vnode.componentInstance) && i2.keepAlive;
if (isDef(i2 = i2.hook) && isDef(i2 = i2.init)) {
i2(vnode, false);
}
if (isDef(vnode.componentInstance)) {
initComponent(vnode, insertedVnodeQueue);
insert2(parentElm, vnode.elm, refElm);
if (isTrue(isReactivated)) {
reactivateComponent(vnode, insertedVnodeQueue, parentElm, refElm);
}
return true;
}
}
}
function initComponent(vnode, insertedVnodeQueue) {
if (isDef(vnode.data.pendingInsert)) {
insertedVnodeQueue.push.apply(insertedVnodeQueue, vnode.data.pendingInsert);
vnode.data.pendingInsert = null;
}
vnode.elm = vnode.componentInstance.$el;
if (isPatchable(vnode)) {
invokeCreateHooks(vnode, insertedVnodeQueue);
setScope(vnode);
} else {
registerRef(vnode);
insertedVnodeQueue.push(vnode);
}
}
function reactivateComponent(vnode, insertedVnodeQueue, parentElm, refElm) {
var i2;
var innerNode = vnode;
while (innerNode.componentInstance) {
innerNode = innerNode.componentInstance._vnode;
if (isDef(i2 = innerNode.data) && isDef(i2 = i2.transition)) {
for (i2 = 0; i2 < cbs.activate.length; ++i2) {
cbs.activate[i2](emptyNode, innerNode);
}
insertedVnodeQueue.push(innerNode);
break;
}
}
insert2(parentElm, vnode.elm, refElm);
}
function insert2(parent, elm, ref$$1) {
if (isDef(parent)) {
if (isDef(ref$$1)) {
if (nodeOps2.parentNode(ref$$1) === parent) {
nodeOps2.insertBefore(parent, elm, ref$$1);
}
} else {
nodeOps2.appendChild(parent, elm);
}
}
}
function createChildren(vnode, children, insertedVnodeQueue) {
if (Array.isArray(children)) {
for (var i2 = 0; i2 < children.length; ++i2) {
createElm(children[i2], insertedVnodeQueue, vnode.elm, null, true, children, i2);
}
} else if (isPrimitive(vnode.text)) {
nodeOps2.appendChild(vnode.elm, nodeOps2.createTextNode(String(vnode.text)));
}
}
function isPatchable(vnode) {
while (vnode.componentInstance) {
vnode = vnode.componentInstance._vnode;
}
return isDef(vnode.tag);
}
function invokeCreateHooks(vnode, insertedVnodeQueue) {
for (var i$1 = 0; i$1 < cbs.create.length; ++i$1) {
cbs.create[i$1](emptyNode, vnode);
}
i = vnode.data.hook;
if (isDef(i)) {
if (isDef(i.create)) {
i.create(emptyNode, vnode);
}
if (isDef(i.insert)) {
insertedVnodeQueue.push(vnode);
}
}
}
function setScope(vnode) {
var i2;
if (isDef(i2 = vnode.fnScopeId)) {
nodeOps2.setStyleScope(vnode.elm, i2);
} else {
var ancestor = vnode;
while (ancestor) {
if (isDef(i2 = ancestor.context) && isDef(i2 = i2.$options._scopeId)) {
nodeOps2.setStyleScope(vnode.elm, i2);
}
ancestor = ancestor.parent;
}
}
if (isDef(i2 = activeInstance) && i2 !== vnode.context && i2 !== vnode.fnContext && isDef(i2 = i2.$options._scopeId)) {
nodeOps2.setStyleScope(vnode.elm, i2);
}
}
function addVnodes(parentElm, refElm, vnodes, startIdx, endIdx, insertedVnodeQueue) {
for (; startIdx <= endIdx; ++startIdx) {
createElm(vnodes[startIdx], insertedVnodeQueue, parentElm, refElm, false, vnodes, startIdx);
}
}
function invokeDestroyHook(vnode) {
var i2, j2;
var data = vnode.data;
if (isDef(data)) {
if (isDef(i2 = data.hook) && isDef(i2 = i2.destroy)) {
i2(vnode);
}
for (i2 = 0; i2 < cbs.destroy.length; ++i2) {
cbs.destroy[i2](vnode);
}
}
if (isDef(i2 = vnode.children)) {
for (j2 = 0; j2 < vnode.children.length; ++j2) {
invokeDestroyHook(vnode.children[j2]);
}
}
}
function removeVnodes(vnodes, startIdx, endIdx) {
for (; startIdx <= endIdx; ++startIdx) {
var ch = vnodes[startIdx];
if (isDef(ch)) {
if (isDef(ch.tag)) {
removeAndInvokeRemoveHook(ch);
invokeDestroyHook(ch);
} else {
removeNode(ch.elm);
}
}
}
}
function removeAndInvokeRemoveHook(vnode, rm2) {
if (isDef(rm2) || isDef(vnode.data)) {
var i2;
var listeners = cbs.remove.length + 1;
if (isDef(rm2)) {
rm2.listeners += listeners;
} else {
rm2 = createRmCb(vnode.elm, listeners);
}
if (isDef(i2 = vnode.componentInstance) && isDef(i2 = i2._vnode) && isDef(i2.data)) {
removeAndInvokeRemoveHook(i2, rm2);
}
for (i2 = 0; i2 < cbs.remove.length; ++i2) {
cbs.remove[i2](vnode, rm2);
}
if (isDef(i2 = vnode.data.hook) && isDef(i2 = i2.remove)) {
i2(vnode, rm2);
} else {
rm2();
}
} else {
removeNode(vnode.elm);
}
}
function updateChildren(parentElm, oldCh, newCh, insertedVnodeQueue, removeOnly) {
var oldStartIdx = 0;
var newStartIdx = 0;
var oldEndIdx = oldCh.length - 1;
var oldStartVnode = oldCh[0];
var oldEndVnode = oldCh[oldEndIdx];
var newEndIdx = newCh.length - 1;
var newStartVnode = newCh[0];
var newEndVnode = newCh[newEndIdx];
var oldKeyToIdx, idxInOld, vnodeToMove, refElm;
var canMove = !removeOnly;
while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
if (isUndef(oldStartVnode)) {
oldStartVnode = oldCh[++oldStartIdx];
} else if (isUndef(oldEndVnode)) {
oldEndVnode = oldCh[--oldEndIdx];
} else if (sameVnode(oldStartVnode, newStartVnode)) {
patchVnode(oldStartVnode, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
oldStartVnode = oldCh[++oldStartIdx];
newStartVnode = newCh[++newStartIdx];
} else if (sameVnode(oldEndVnode, newEndVnode)) {
patchVnode(oldEndVnode, newEndVnode, insertedVnodeQueue, newCh, newEndIdx);
oldEndVnode = oldCh[--oldEndIdx];
newEndVnode = newCh[--newEndIdx];
} else if (sameVnode(oldStartVnode, newEndVnode)) {
patchVnode(oldStartVnode, newEndVnode, insertedVnodeQueue, newCh, newEndIdx);
canMove && nodeOps2.insertBefore(parentElm, oldStartVnode.elm, nodeOps2.nextSibling(oldEndVnode.elm));
oldStartVnode = oldCh[++oldStartIdx];
newEndVnode = newCh[--newEndIdx];
} else if (sameVnode(oldEndVnode, newStartVnode)) {
patchVnode(oldEndVnode, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
canMove && nodeOps2.insertBefore(parentElm, oldEndVnode.elm, oldStartVnode.elm);
oldEndVnode = oldCh[--oldEndIdx];
newStartVnode = newCh[++newStartIdx];
} else {
if (isUndef(oldKeyToIdx)) {
oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx);
}
idxInOld = isDef(newStartVnode.key) ? oldKeyToIdx[newStartVnode.key] : findIdxInOld(newStartVnode, oldCh, oldStartIdx, oldEndIdx);
if (isUndef(idxInOld)) {
createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm, false, newCh, newStartIdx);
} else {
vnodeToMove = oldCh[idxInOld];
if (sameVnode(vnodeToMove, newStartVnode)) {
patchVnode(vnodeToMove, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
oldCh[idxInOld] = void 0;
canMove && nodeOps2.insertBefore(parentElm, vnodeToMove.elm, oldStartVnode.elm);
} else {
createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm, false, newCh, newStartIdx);
}
}
newStartVnode = newCh[++newStartIdx];
}
}
if (oldStartIdx > oldEndIdx) {
refElm = isUndef(newCh[newEndIdx + 1]) ? null : newCh[newEndIdx + 1].elm;
addVnodes(parentElm, refElm, newCh, newStartIdx, newEndIdx, insertedVnodeQueue);
} else if (newStartIdx > newEndIdx) {
removeVnodes(oldCh, oldStartIdx, oldEndIdx);
}
}
function findIdxInOld(node4, oldCh, start3, end2) {
for (var i2 = start3; i2 < end2; i2++) {
var c = oldCh[i2];
if (isDef(c) && sameVnode(node4, c)) {
return i2;
}
}
}
function patchVnode(oldVnode, vnode, insertedVnodeQueue, ownerArray, index3, removeOnly) {
if (oldVnode === vnode) {
return;
}
if (isDef(vnode.elm) && isDef(ownerArray)) {
vnode = ownerArray[index3] = cloneVNode(vnode);
}
var elm = vnode.elm = oldVnode.elm;
if (isTrue(oldVnode.isAsyncPlaceholder)) {
if (isDef(vnode.asyncFactory.resolved)) {
hydrate(oldVnode.elm, vnode, insertedVnodeQueue);
} else {
vnode.isAsyncPlaceholder = true;
}
return;
}
if (isTrue(vnode.isStatic) && isTrue(oldVnode.isStatic) && vnode.key === oldVnode.key && (isTrue(vnode.isCloned) || isTrue(vnode.isOnce))) {
vnode.componentInstance = oldVnode.componentInstance;
return;
}
var i2;
var data = vnode.data;
if (isDef(data) && isDef(i2 = data.hook) && isDef(i2 = i2.prepatch)) {
i2(oldVnode, vnode);
}
var oldCh = oldVnode.children;
var ch = vnode.children;
if (isDef(data) && isPatchable(vnode)) {
for (i2 = 0; i2 < cbs.update.length; ++i2) {
cbs.update[i2](oldVnode, vnode);
}
if (isDef(i2 = data.hook) && isDef(i2 = i2.update)) {
i2(oldVnode, vnode);
}
}
if (isUndef(vnode.text)) {
if (isDef(oldCh) && isDef(ch)) {
if (oldCh !== ch) {
updateChildren(elm, oldCh, ch, insertedVnodeQueue, removeOnly);
}
} else if (isDef(ch)) {
if (isDef(oldVnode.text)) {
nodeOps2.setTextContent(elm, "");
}
addVnodes(elm, null, ch, 0, ch.length - 1, insertedVnodeQueue);
} else if (isDef(oldCh)) {
removeVnodes(oldCh, 0, oldCh.length - 1);
} else if (isDef(oldVnode.text)) {
nodeOps2.setTextContent(elm, "");
}
} else if (oldVnode.text !== vnode.text) {
nodeOps2.setTextContent(elm, vnode.text);
}
if (isDef(data)) {
if (isDef(i2 = data.hook) && isDef(i2 = i2.postpatch)) {
i2(oldVnode, vnode);
}
}
}
function invokeInsertHook(vnode, queue2, initial2) {
if (isTrue(initial2) && isDef(vnode.parent)) {
vnode.parent.data.pendingInsert = queue2;
} else {
for (var i2 = 0; i2 < queue2.length; ++i2) {
queue2[i2].data.hook.insert(queue2[i2]);
}
}
}
var isRenderedModule = makeMap("attrs,class,staticClass,staticStyle,key");
function hydrate(elm, vnode, insertedVnodeQueue, inVPre) {
var i2;
var tag2 = vnode.tag;
var data = vnode.data;
var children = vnode.children;
inVPre = inVPre || data && data.pre;
vnode.elm = elm;
if (isTrue(vnode.isComment) && isDef(vnode.asyncFactory)) {
vnode.isAsyncPlaceholder = true;
return true;
}
if (isDef(data)) {
if (isDef(i2 = data.hook) && isDef(i2 = i2.init)) {
i2(vnode, true);
}
if (isDef(i2 = vnode.componentInstance)) {
initComponent(vnode, insertedVnodeQueue);
return true;
}
}
if (isDef(tag2)) {
if (isDef(children)) {
if (!elm.hasChildNodes()) {
createChildren(vnode, children, insertedVnodeQueue);
} else {
if (isDef(i2 = data) && isDef(i2 = i2.domProps) && isDef(i2 = i2.innerHTML)) {
if (i2 !== elm.innerHTML) {
return false;
}
} else {
var childrenMatch = true;
var childNode = elm.firstChild;
for (var i$1 = 0; i$1 < children.length; i$1++) {
if (!childNode || !hydrate(childNode, children[i$1], insertedVnodeQueue, inVPre)) {
childrenMatch = false;
break;
}
childNode = childNode.nextSibling;
}
if (!childrenMatch || childNode) {
return false;
}
}
}
}
if (isDef(data)) {
var fullInvoke = false;
for (var key in data) {
if (!isRenderedModule(key)) {
fullInvoke = true;
invokeCreateHooks(vnode, insertedVnodeQueue);
break;
}
}
if (!fullInvoke && data["class"]) {
traverse(data["class"]);
}
}
} else if (elm.data !== vnode.text) {
elm.data = vnode.text;
}
return true;
}
return function patch2(oldVnode, vnode, hydrating, removeOnly) {
if (isUndef(vnode)) {
if (isDef(oldVnode)) {
invokeDestroyHook(oldVnode);
}
return;
}
var isInitialPatch = false;
var insertedVnodeQueue = [];
if (isUndef(oldVnode)) {
isInitialPatch = true;
createElm(vnode, insertedVnodeQueue);
} else {
var isRealElement = isDef(oldVnode.nodeType);
if (!isRealElement && sameVnode(oldVnode, vnode)) {
patchVnode(oldVnode, vnode, insertedVnodeQueue, null, null, removeOnly);
} else {
if (isRealElement) {
if (oldVnode.nodeType === 1 && oldVnode.hasAttribute(SSR_ATTR)) {
oldVnode.removeAttribute(SSR_ATTR);
hydrating = true;
}
if (isTrue(hydrating)) {
if (hydrate(oldVnode, vnode, insertedVnodeQueue)) {
invokeInsertHook(vnode, insertedVnodeQueue, true);
return oldVnode;
}
}
oldVnode = emptyNodeAt(oldVnode);
}
var oldElm = oldVnode.elm;
var parentElm = nodeOps2.parentNode(oldElm);
createElm(vnode, insertedVnodeQueue, oldElm._leaveCb ? null : parentElm, nodeOps2.nextSibling(oldElm));
if (isDef(vnode.parent)) {
var ancestor = vnode.parent;
var patchable = isPatchable(vnode);
while (ancestor) {
for (var i2 = 0; i2 < cbs.destroy.length; ++i2) {
cbs.destroy[i2](ancestor);
}
ancestor.elm = vnode.elm;
if (patchable) {
for (var i$1 = 0; i$1 < cbs.create.length; ++i$1) {
cbs.create[i$1](emptyNode, ancestor);
}
var insert3 = ancestor.data.hook.insert;
if (insert3.merged) {
for (var i$2 = 1; i$2 < insert3.fns.length; i$2++) {
insert3.fns[i$2]();
}
}
} else {
registerRef(ancestor);
}
ancestor = ancestor.parent;
}
}
if (isDef(parentElm)) {
removeVnodes([oldVnode], 0, 0);
} else if (isDef(oldVnode.tag)) {
invokeDestroyHook(oldVnode);
}
}
}
invokeInsertHook(vnode, insertedVnodeQueue, isInitialPatch);
return vnode.elm;
};
}
var directives = {
create: updateDirectives,
update: updateDirectives,
destroy: function unbindDirectives(vnode) {
updateDirectives(vnode, emptyNode);
}
};
function updateDirectives(oldVnode, vnode) {
if (oldVnode.data.directives || vnode.data.directives) {
_update(oldVnode, vnode);
}
}
function _update(oldVnode, vnode) {
var isCreate = oldVnode === emptyNode;
var isDestroy = vnode === emptyNode;
var oldDirs = normalizeDirectives$1(oldVnode.data.directives, oldVnode.context);
var newDirs = normalizeDirectives$1(vnode.data.directives, vnode.context);
var dirsWithInsert = [];
var dirsWithPostpatch = [];
var key, oldDir, dir;
for (key in newDirs) {
oldDir = oldDirs[key];
dir = newDirs[key];
if (!oldDir) {
callHook$1(dir, "bind", vnode, oldVnode);
if (dir.def && dir.def.inserted) {
dirsWithInsert.push(dir);
}
} else {
dir.oldValue = oldDir.value;
dir.oldArg = oldDir.arg;
callHook$1(dir, "update", vnode, oldVnode);
if (dir.def && dir.def.componentUpdated) {
dirsWithPostpatch.push(dir);
}
}
}
if (dirsWithInsert.length) {
var callInsert = function() {
for (var i = 0; i < dirsWithInsert.length; i++) {
callHook$1(dirsWithInsert[i], "inserted", vnode, oldVnode);
}
};
if (isCreate) {
mergeVNodeHook(vnode, "insert", callInsert);
} else {
callInsert();
}
}
if (dirsWithPostpatch.length) {
mergeVNodeHook(vnode, "postpatch", function() {
for (var i = 0; i < dirsWithPostpatch.length; i++) {
callHook$1(dirsWithPostpatch[i], "componentUpdated", vnode, oldVnode);
}
});
}
if (!isCreate) {
for (key in oldDirs) {
if (!newDirs[key]) {
callHook$1(oldDirs[key], "unbind", oldVnode, oldVnode, isDestroy);
}
}
}
}
var emptyModifiers = Object.create(null);
function normalizeDirectives$1(dirs, vm) {
var res = Object.create(null);
if (!dirs) {
return res;
}
var i, dir;
for (i = 0; i < dirs.length; i++) {
dir = dirs[i];
if (!dir.modifiers) {
dir.modifiers = emptyModifiers;
}
res[getRawDirName(dir)] = dir;
dir.def = resolveAsset(vm.$options, "directives", dir.name);
}
return res;
}
function getRawDirName(dir) {
return dir.rawName || dir.name + "." + Object.keys(dir.modifiers || {}).join(".");
}
function callHook$1(dir, hook, vnode, oldVnode, isDestroy) {
var fn = dir.def && dir.def[hook];
if (fn) {
try {
fn(vnode.elm, dir, vnode, oldVnode, isDestroy);
} catch (e) {
handleError(e, vnode.context, "directive " + dir.name + " " + hook + " hook");
}
}
}
var baseModules = [
ref,
directives
];
function updateAttrs(oldVnode, vnode) {
var opts = vnode.componentOptions;
if (isDef(opts) && opts.Ctor.options.inheritAttrs === false) {
return;
}
if (isUndef(oldVnode.data.attrs) && isUndef(vnode.data.attrs)) {
return;
}
var key, cur, old;
var elm = vnode.elm;
var oldAttrs = oldVnode.data.attrs || {};
var attrs2 = vnode.data.attrs || {};
if (isDef(attrs2.__ob__)) {
attrs2 = vnode.data.attrs = extend$3({}, attrs2);
}
for (key in attrs2) {
cur = attrs2[key];
old = oldAttrs[key];
if (old !== cur) {
setAttr$1(elm, key, cur);
}
}
if ((isIE || isEdge) && attrs2.value !== oldAttrs.value) {
setAttr$1(elm, "value", attrs2.value);
}
for (key in oldAttrs) {
if (isUndef(attrs2[key])) {
if (isXlink(key)) {
elm.removeAttributeNS(xlinkNS, getXlinkProp(key));
} else if (!isEnumeratedAttr(key)) {
elm.removeAttribute(key);
}
}
}
}
function setAttr$1(el, key, value) {
if (el.tagName.indexOf("-") > -1) {
baseSetAttr(el, key, value);
} else if (isBooleanAttr(key)) {
if (isFalsyAttrValue(value)) {
el.removeAttribute(key);
} else {
value = key === "allowfullscreen" && el.tagName === "EMBED" ? "true" : key;
el.setAttribute(key, value);
}
} else if (isEnumeratedAttr(key)) {
el.setAttribute(key, convertEnumeratedValue(key, value));
} else if (isXlink(key)) {
if (isFalsyAttrValue(value)) {
el.removeAttributeNS(xlinkNS, getXlinkProp(key));
} else {
el.setAttributeNS(xlinkNS, key, value);
}
} else {
baseSetAttr(el, key, value);
}
}
function baseSetAttr(el, key, value) {
if (isFalsyAttrValue(value)) {
el.removeAttribute(key);
} else {
if (isIE && !isIE9 && el.tagName === "TEXTAREA" && key === "placeholder" && value !== "" && !el.__ieph) {
var blocker = function(e) {
e.stopImmediatePropagation();
el.removeEventListener("input", blocker);
};
el.addEventListener("input", blocker);
el.__ieph = true;
}
el.setAttribute(key, value);
}
}
var attrs = {
create: updateAttrs,
update: updateAttrs
};
function updateClass(oldVnode, vnode) {
var el = vnode.elm;
var data = vnode.data;
var oldData = oldVnode.data;
if (isUndef(data.staticClass) && isUndef(data.class) && (isUndef(oldData) || isUndef(oldData.staticClass) && isUndef(oldData.class))) {
return;
}
var cls = genClassForVnode(vnode);
var transitionClass = el._transitionClasses;
if (isDef(transitionClass)) {
cls = concat$1(cls, stringifyClass(transitionClass));
}
if (cls !== el._prevClass) {
el.setAttribute("class", cls);
el._prevClass = cls;
}
}
var klass = {
create: updateClass,
update: updateClass
};
var validDivisionCharRE = /[\w).+\-_$\]]/;
function parseFilters(exp) {
var inSingle = false;
var inDouble = false;
var inTemplateString = false;
var inRegex = false;
var curly = 0;
var square = 0;
var paren = 0;
var lastFilterIndex = 0;
var c, prev, i, expression, filters;
for (i = 0; i < exp.length; i++) {
prev = c;
c = exp.charCodeAt(i);
if (inSingle) {
if (c === 39 && prev !== 92) {
inSingle = false;
}
} else if (inDouble) {
if (c === 34 && prev !== 92) {
inDouble = false;
}
} else if (inTemplateString) {
if (c === 96 && prev !== 92) {
inTemplateString = false;
}
} else if (inRegex) {
if (c === 47 && prev !== 92) {
inRegex = false;
}
} else if (c === 124 && exp.charCodeAt(i + 1) !== 124 && exp.charCodeAt(i - 1) !== 124 && !curly && !square && !paren) {
if (expression === void 0) {
lastFilterIndex = i + 1;
expression = exp.slice(0, i).trim();
} else {
pushFilter();
}
} else {
switch (c) {
case 34:
inDouble = true;
break;
case 39:
inSingle = true;
break;
case 96:
inTemplateString = true;
break;
case 40:
paren++;
break;
case 41:
paren--;
break;
case 91:
square++;
break;
case 93:
square--;
break;
case 123:
curly++;
break;
case 125:
curly--;
break;
}
if (c === 47) {
var j = i - 1;
var p = void 0;
for (; j >= 0; j--) {
p = exp.charAt(j);
if (p !== " ") {
break;
}
}
if (!p || !validDivisionCharRE.test(p)) {
inRegex = true;
}
}
}
}
if (expression === void 0) {
expression = exp.slice(0, i).trim();
} else if (lastFilterIndex !== 0) {
pushFilter();
}
function pushFilter() {
(filters || (filters = [])).push(exp.slice(lastFilterIndex, i).trim());
lastFilterIndex = i + 1;
}
if (filters) {
for (i = 0; i < filters.length; i++) {
expression = wrapFilter(expression, filters[i]);
}
}
return expression;
}
function wrapFilter(exp, filter2) {
var i = filter2.indexOf("(");
if (i < 0) {
return '_f("' + filter2 + '")(' + exp + ")";
} else {
var name = filter2.slice(0, i);
var args = filter2.slice(i + 1);
return '_f("' + name + '")(' + exp + (args !== ")" ? "," + args : args);
}
}
function baseWarn(msg, range2) {
console.error("[Vue compiler]: " + msg);
}
function pluckModuleFunction(modules2, key) {
return modules2 ? modules2.map(function(m) {
return m[key];
}).filter(function(_2) {
return _2;
}) : [];
}
function addProp(el, name, value, range2, dynamic) {
(el.props || (el.props = [])).push(rangeSetItem({name, value, dynamic}, range2));
el.plain = false;
}
function addAttr(el, name, value, range2, dynamic) {
var attrs2 = dynamic ? el.dynamicAttrs || (el.dynamicAttrs = []) : el.attrs || (el.attrs = []);
attrs2.push(rangeSetItem({name, value, dynamic}, range2));
el.plain = false;
}
function addRawAttr(el, name, value, range2) {
el.attrsMap[name] = value;
el.attrsList.push(rangeSetItem({name, value}, range2));
}
function addDirective(el, name, rawName, value, arg, isDynamicArg, modifiers2, range2) {
(el.directives || (el.directives = [])).push(rangeSetItem({
name,
rawName,
value,
arg,
isDynamicArg,
modifiers: modifiers2
}, range2));
el.plain = false;
}
function prependModifierMarker(symbol, name, dynamic) {
return dynamic ? "_p(" + name + ',"' + symbol + '")' : symbol + name;
}
function addHandler(el, name, value, modifiers2, important, warn2, range2, dynamic) {
modifiers2 = modifiers2 || emptyObject;
if (modifiers2.right) {
if (dynamic) {
name = "(" + name + ")==='click'?'contextmenu':(" + name + ")";
} else if (name === "click") {
name = "contextmenu";
delete modifiers2.right;
}
} else if (modifiers2.middle) {
if (dynamic) {
name = "(" + name + ")==='click'?'mouseup':(" + name + ")";
} else if (name === "click") {
name = "mouseup";
}
}
if (modifiers2.capture) {
delete modifiers2.capture;
name = prependModifierMarker("!", name, dynamic);
}
if (modifiers2.once) {
delete modifiers2.once;
name = prependModifierMarker("~", name, dynamic);
}
if (modifiers2.passive) {
delete modifiers2.passive;
name = prependModifierMarker("&", name, dynamic);
}
var events2;
if (modifiers2.native) {
delete modifiers2.native;
events2 = el.nativeEvents || (el.nativeEvents = {});
} else {
events2 = el.events || (el.events = {});
}
var newHandler = rangeSetItem({value: value.trim(), dynamic}, range2);
if (modifiers2 !== emptyObject) {
newHandler.modifiers = modifiers2;
}
var handlers2 = events2[name];
if (Array.isArray(handlers2)) {
important ? handlers2.unshift(newHandler) : handlers2.push(newHandler);
} else if (handlers2) {
events2[name] = important ? [newHandler, handlers2] : [handlers2, newHandler];
} else {
events2[name] = newHandler;
}
el.plain = false;
}
function getRawBindingAttr(el, name) {
return el.rawAttrsMap[":" + name] || el.rawAttrsMap["v-bind:" + name] || el.rawAttrsMap[name];
}
function getBindingAttr(el, name, getStatic) {
var dynamicValue = getAndRemoveAttr(el, ":" + name) || getAndRemoveAttr(el, "v-bind:" + name);
if (dynamicValue != null) {
return parseFilters(dynamicValue);
} else if (getStatic !== false) {
var staticValue = getAndRemoveAttr(el, name);
if (staticValue != null) {
return JSON.stringify(staticValue);
}
}
}
function getAndRemoveAttr(el, name, removeFromMap) {
var val;
if ((val = el.attrsMap[name]) != null) {
var list = el.attrsList;
for (var i = 0, l = list.length; i < l; i++) {
if (list[i].name === name) {
list.splice(i, 1);
break;
}
}
}
if (removeFromMap) {
delete el.attrsMap[name];
}
return val;
}
function getAndRemoveAttrByRegex(el, name) {
var list = el.attrsList;
for (var i = 0, l = list.length; i < l; i++) {
var attr = list[i];
if (name.test(attr.name)) {
list.splice(i, 1);
return attr;
}
}
}
function rangeSetItem(item, range2) {
if (range2) {
if (range2.start != null) {
item.start = range2.start;
}
if (range2.end != null) {
item.end = range2.end;
}
}
return item;
}
function genComponentModel(el, value, modifiers2) {
var ref2 = modifiers2 || {};
var number = ref2.number;
var trim = ref2.trim;
var baseValueExpression = "$$v";
var valueExpression = baseValueExpression;
if (trim) {
valueExpression = "(typeof " + baseValueExpression + " === 'string'? " + baseValueExpression + ".trim(): " + baseValueExpression + ")";
}
if (number) {
valueExpression = "_n(" + valueExpression + ")";
}
var assignment = genAssignmentCode(value, valueExpression);
el.model = {
value: "(" + value + ")",
expression: JSON.stringify(value),
callback: "function (" + baseValueExpression + ") {" + assignment + "}"
};
}
function genAssignmentCode(value, assignment) {
var res = parseModel(value);
if (res.key === null) {
return value + "=" + assignment;
} else {
return "$set(" + res.exp + ", " + res.key + ", " + assignment + ")";
}
}
var len, str, chr, index$1$1, expressionPos, expressionEndPos;
function parseModel(val) {
val = val.trim();
len = val.length;
if (val.indexOf("[") < 0 || val.lastIndexOf("]") < len - 1) {
index$1$1 = val.lastIndexOf(".");
if (index$1$1 > -1) {
return {
exp: val.slice(0, index$1$1),
key: '"' + val.slice(index$1$1 + 1) + '"'
};
} else {
return {
exp: val,
key: null
};
}
}
str = val;
index$1$1 = expressionPos = expressionEndPos = 0;
while (!eof()) {
chr = next();
if (isStringStart(chr)) {
parseString(chr);
} else if (chr === 91) {
parseBracket(chr);
}
}
return {
exp: val.slice(0, expressionPos),
key: val.slice(expressionPos + 1, expressionEndPos)
};
}
function next() {
return str.charCodeAt(++index$1$1);
}
function eof() {
return index$1$1 >= len;
}
function isStringStart(chr2) {
return chr2 === 34 || chr2 === 39;
}
function parseBracket(chr2) {
var inBracket = 1;
expressionPos = index$1$1;
while (!eof()) {
chr2 = next();
if (isStringStart(chr2)) {
parseString(chr2);
continue;
}
if (chr2 === 91) {
inBracket++;
}
if (chr2 === 93) {
inBracket--;
}
if (inBracket === 0) {
expressionEndPos = index$1$1;
break;
}
}
}
function parseString(chr2) {
var stringQuote = chr2;
while (!eof()) {
chr2 = next();
if (chr2 === stringQuote) {
break;
}
}
}
var RANGE_TOKEN = "__r";
var CHECKBOX_RADIO_TOKEN = "__c";
function model(el, dir, _warn) {
var value = dir.value;
var modifiers2 = dir.modifiers;
var tag2 = el.tag;
var type = el.attrsMap.type;
if (el.component) {
genComponentModel(el, value, modifiers2);
return false;
} else if (tag2 === "select") {
genSelect(el, value, modifiers2);
} else if (tag2 === "input" && type === "checkbox") {
genCheckboxModel(el, value, modifiers2);
} else if (tag2 === "input" && type === "radio") {
genRadioModel(el, value, modifiers2);
} else if (tag2 === "input" || tag2 === "textarea") {
genDefaultModel(el, value, modifiers2);
} else if (!config.isReservedTag(tag2)) {
genComponentModel(el, value, modifiers2);
return false;
} else
;
return true;
}
function genCheckboxModel(el, value, modifiers2) {
var number = modifiers2 && modifiers2.number;
var valueBinding = getBindingAttr(el, "value") || "null";
var trueValueBinding = getBindingAttr(el, "true-value") || "true";
var falseValueBinding = getBindingAttr(el, "false-value") || "false";
addProp(el, "checked", "Array.isArray(" + value + ")?_i(" + value + "," + valueBinding + ")>-1" + (trueValueBinding === "true" ? ":(" + value + ")" : ":_q(" + value + "," + trueValueBinding + ")"));
addHandler(el, "change", "var $$a=" + value + ",$$el=$event.target,$$c=$$el.checked?(" + trueValueBinding + "):(" + falseValueBinding + ");if(Array.isArray($$a)){var $$v=" + (number ? "_n(" + valueBinding + ")" : valueBinding) + ",$$i=_i($$a,$$v);if($$el.checked){$$i<0&&(" + genAssignmentCode(value, "$$a.concat([$$v])") + ")}else{$$i>-1&&(" + genAssignmentCode(value, "$$a.slice(0,$$i).concat($$a.slice($$i+1))") + ")}}else{" + genAssignmentCode(value, "$$c") + "}", null, true);
}
function genRadioModel(el, value, modifiers2) {
var number = modifiers2 && modifiers2.number;
var valueBinding = getBindingAttr(el, "value") || "null";
valueBinding = number ? "_n(" + valueBinding + ")" : valueBinding;
addProp(el, "checked", "_q(" + value + "," + valueBinding + ")");
addHandler(el, "change", genAssignmentCode(value, valueBinding), null, true);
}
function genSelect(el, value, modifiers2) {
var number = modifiers2 && modifiers2.number;
var selectedVal = 'Array.prototype.filter.call($event.target.options,function(o){return o.selected}).map(function(o){var val = "_value" in o ? o._value : o.value;return ' + (number ? "_n(val)" : "val") + "})";
var assignment = "$event.target.multiple ? $$selectedVal : $$selectedVal[0]";
var code = "var $$selectedVal = " + selectedVal + ";";
code = code + " " + genAssignmentCode(value, assignment);
addHandler(el, "change", code, null, true);
}
function genDefaultModel(el, value, modifiers2) {
var type = el.attrsMap.type;
var ref2 = modifiers2 || {};
var lazy = ref2.lazy;
var number = ref2.number;
var trim = ref2.trim;
var needCompositionGuard = !lazy && type !== "range";
var event = lazy ? "change" : type === "range" ? RANGE_TOKEN : "input";
var valueExpression = "$event.target.value";
if (trim) {
valueExpression = "$event.target.value.trim()";
}
if (number) {
valueExpression = "_n(" + valueExpression + ")";
}
var code = genAssignmentCode(value, valueExpression);
if (needCompositionGuard) {
code = "if($event.target.composing)return;" + code;
}
addProp(el, "value", "(" + value + ")");
addHandler(el, event, code, null, true);
if (trim || number) {
addHandler(el, "blur", "$forceUpdate()");
}
}
function normalizeEvents(on2) {
if (isDef(on2[RANGE_TOKEN])) {
var event = isIE ? "change" : "input";
on2[event] = [].concat(on2[RANGE_TOKEN], on2[event] || []);
delete on2[RANGE_TOKEN];
}
if (isDef(on2[CHECKBOX_RADIO_TOKEN])) {
on2.change = [].concat(on2[CHECKBOX_RADIO_TOKEN], on2.change || []);
delete on2[CHECKBOX_RADIO_TOKEN];
}
}
var target$1;
function createOnceHandler$1(event, handler, capture) {
var _target = target$1;
return function onceHandler() {
var res = handler.apply(null, arguments);
if (res !== null) {
remove$2(event, onceHandler, capture, _target);
}
};
}
var useMicrotaskFix = isUsingMicroTask && !(isFF && Number(isFF[1]) <= 53);
function add$1(name, handler, capture, passive) {
if (useMicrotaskFix) {
var attachedTimestamp = currentFlushTimestamp;
var original = handler;
handler = original._wrapper = function(e) {
if (e.target === e.currentTarget || e.timeStamp >= attachedTimestamp || e.timeStamp <= 0 || e.target.ownerDocument !== document) {
return original.apply(this, arguments);
}
};
}
target$1.addEventListener(name, handler, supportsPassive ? {capture, passive} : capture);
}
function remove$2(name, handler, capture, _target) {
(_target || target$1).removeEventListener(name, handler._wrapper || handler, capture);
}
function updateDOMListeners(oldVnode, vnode) {
if (isUndef(oldVnode.data.on) && isUndef(vnode.data.on)) {
return;
}
var on2 = vnode.data.on || {};
var oldOn = oldVnode.data.on || {};
target$1 = vnode.elm;
normalizeEvents(on2);
updateListeners(on2, oldOn, add$1, remove$2, createOnceHandler$1, vnode.context);
target$1 = void 0;
}
var events = {
create: updateDOMListeners,
update: updateDOMListeners
};
var svgContainer;
function updateDOMProps(oldVnode, vnode) {
if (isUndef(oldVnode.data.domProps) && isUndef(vnode.data.domProps)) {
return;
}
var key, cur;
var elm = vnode.elm;
var oldProps = oldVnode.data.domProps || {};
var props2 = vnode.data.domProps || {};
if (isDef(props2.__ob__)) {
props2 = vnode.data.domProps = extend$3({}, props2);
}
for (key in oldProps) {
if (!(key in props2)) {
elm[key] = "";
}
}
for (key in props2) {
cur = props2[key];
if (key === "textContent" || key === "innerHTML") {
if (vnode.children) {
vnode.children.length = 0;
}
if (cur === oldProps[key]) {
continue;
}
if (elm.childNodes.length === 1) {
elm.removeChild(elm.childNodes[0]);
}
}
if (key === "value" && elm.tagName !== "PROGRESS") {
elm._value = cur;
var strCur = isUndef(cur) ? "" : String(cur);
if (shouldUpdateValue(elm, strCur)) {
elm.value = strCur;
}
} else if (key === "innerHTML" && isSVG(elm.tagName) && isUndef(elm.innerHTML)) {
svgContainer = svgContainer || document.createElement("div");
svgContainer.innerHTML = "<svg>" + cur + "</svg>";
var svg = svgContainer.firstChild;
while (elm.firstChild) {
elm.removeChild(elm.firstChild);
}
while (svg.firstChild) {
elm.appendChild(svg.firstChild);
}
} else if (cur !== oldProps[key]) {
try {
elm[key] = cur;
} catch (e) {
}
}
}
}
function shouldUpdateValue(elm, checkVal) {
return !elm.composing && (elm.tagName === "OPTION" || isNotInFocusAndDirty(elm, checkVal) || isDirtyWithModifiers(elm, checkVal));
}
function isNotInFocusAndDirty(elm, checkVal) {
var notInFocus = true;
try {
notInFocus = document.activeElement !== elm;
} catch (e) {
}
return notInFocus && elm.value !== checkVal;
}
function isDirtyWithModifiers(elm, newVal) {
var value = elm.value;
var modifiers2 = elm._vModifiers;
if (isDef(modifiers2)) {
if (modifiers2.number) {
return toNumber(value) !== toNumber(newVal);
}
if (modifiers2.trim) {
return value.trim() !== newVal.trim();
}
}
return value !== newVal;
}
var domProps = {
create: updateDOMProps,
update: updateDOMProps
};
var parseStyleText = cached(function(cssText) {
var res = {};
var listDelimiter = /;(?![^(]*\))/g;
var propertyDelimiter = /:(.+)/;
cssText.split(listDelimiter).forEach(function(item) {
if (item) {
var tmp = item.split(propertyDelimiter);
tmp.length > 1 && (res[tmp[0].trim()] = tmp[1].trim());
}
});
return res;
});
function normalizeStyleData(data) {
var style2 = normalizeStyleBinding(data.style);
return data.staticStyle ? extend$3(data.staticStyle, style2) : style2;
}
function normalizeStyleBinding(bindingStyle) {
if (Array.isArray(bindingStyle)) {
return toObject(bindingStyle);
}
if (typeof bindingStyle === "string") {
return parseStyleText(bindingStyle);
}
return bindingStyle;
}
function getStyle(vnode, checkChild) {
var res = {};
var styleData;
if (checkChild) {
var childNode = vnode;
while (childNode.componentInstance) {
childNode = childNode.componentInstance._vnode;
if (childNode && childNode.data && (styleData = normalizeStyleData(childNode.data))) {
extend$3(res, styleData);
}
}
}
if (styleData = normalizeStyleData(vnode.data)) {
extend$3(res, styleData);
}
var parentNode2 = vnode;
while (parentNode2 = parentNode2.parent) {
if (parentNode2.data && (styleData = normalizeStyleData(parentNode2.data))) {
extend$3(res, styleData);
}
}
return res;
}
var cssVarRE = /^--/;
var importantRE = /\s*!important$/;
var setProp = function(el, name, val) {
if (cssVarRE.test(name)) {
el.style.setProperty(name, val);
} else if (importantRE.test(val)) {
el.style.setProperty(hyphenate(name), val.replace(importantRE, ""), "important");
} else {
var normalizedName = normalize$1(name);
if (Array.isArray(val)) {
for (var i = 0, len2 = val.length; i < len2; i++) {
el.style[normalizedName] = val[i];
}
} else {
el.style[normalizedName] = val;
}
}
};
var vendorNames = ["Webkit", "Moz", "ms"];
var emptyStyle;
var normalize$1 = cached(function(prop) {
emptyStyle = emptyStyle || document.createElement("div").style;
prop = camelize(prop);
if (prop !== "filter" && prop in emptyStyle) {
return prop;
}
var capName = prop.charAt(0).toUpperCase() + prop.slice(1);
for (var i = 0; i < vendorNames.length; i++) {
var name = vendorNames[i] + capName;
if (name in emptyStyle) {
return name;
}
}
});
function updateStyle(oldVnode, vnode) {
var data = vnode.data;
var oldData = oldVnode.data;
if (isUndef(data.staticStyle) && isUndef(data.style) && isUndef(oldData.staticStyle) && isUndef(oldData.style)) {
return;
}
var cur, name;
var el = vnode.elm;
var oldStaticStyle = oldData.staticStyle;
var oldStyleBinding = oldData.normalizedStyle || oldData.style || {};
var oldStyle = oldStaticStyle || oldStyleBinding;
var style2 = normalizeStyleBinding(vnode.data.style) || {};
vnode.data.normalizedStyle = isDef(style2.__ob__) ? extend$3({}, style2) : style2;
var newStyle = getStyle(vnode, true);
for (name in oldStyle) {
if (isUndef(newStyle[name])) {
setProp(el, name, "");
}
}
for (name in newStyle) {
cur = newStyle[name];
if (cur !== oldStyle[name]) {
setProp(el, name, cur == null ? "" : cur);
}
}
}
var style = {
create: updateStyle,
update: updateStyle
};
var whitespaceRE = /\s+/;
function addClass(el, cls) {
if (!cls || !(cls = cls.trim())) {
return;
}
if (el.classList) {
if (cls.indexOf(" ") > -1) {
cls.split(whitespaceRE).forEach(function(c) {
return el.classList.add(c);
});
} else {
el.classList.add(cls);
}
} else {
var cur = " " + (el.getAttribute("class") || "") + " ";
if (cur.indexOf(" " + cls + " ") < 0) {
el.setAttribute("class", (cur + cls).trim());
}
}
}
function removeClass(el, cls) {
if (!cls || !(cls = cls.trim())) {
return;
}
if (el.classList) {
if (cls.indexOf(" ") > -1) {
cls.split(whitespaceRE).forEach(function(c) {
return el.classList.remove(c);
});
} else {
el.classList.remove(cls);
}
if (!el.classList.length) {
el.removeAttribute("class");
}
} else {
var cur = " " + (el.getAttribute("class") || "") + " ";
var tar = " " + cls + " ";
while (cur.indexOf(tar) >= 0) {
cur = cur.replace(tar, " ");
}
cur = cur.trim();
if (cur) {
el.setAttribute("class", cur);
} else {
el.removeAttribute("class");
}
}
}
function resolveTransition(def$$1) {
if (!def$$1) {
return;
}
if (typeof def$$1 === "object") {
var res = {};
if (def$$1.css !== false) {
extend$3(res, autoCssTransition(def$$1.name || "v"));
}
extend$3(res, def$$1);
return res;
} else if (typeof def$$1 === "string") {
return autoCssTransition(def$$1);
}
}
var autoCssTransition = cached(function(name) {
return {
enterClass: name + "-enter",
enterToClass: name + "-enter-to",
enterActiveClass: name + "-enter-active",
leaveClass: name + "-leave",
leaveToClass: name + "-leave-to",
leaveActiveClass: name + "-leave-active"
};
});
var hasTransition = inBrowser$1 && !isIE9;
var TRANSITION = "transition";
var ANIMATION = "animation";
var transitionProp = "transition";
var transitionEndEvent = "transitionend";
var animationProp = "animation";
var animationEndEvent = "animationend";
if (hasTransition) {
if (window.ontransitionend === void 0 && window.onwebkittransitionend !== void 0) {
transitionProp = "WebkitTransition";
transitionEndEvent = "webkitTransitionEnd";
}
if (window.onanimationend === void 0 && window.onwebkitanimationend !== void 0) {
animationProp = "WebkitAnimation";
animationEndEvent = "webkitAnimationEnd";
}
}
var raf = inBrowser$1 ? window.requestAnimationFrame ? window.requestAnimationFrame.bind(window) : setTimeout : function(fn) {
return fn();
};
function nextFrame(fn) {
raf(function() {
raf(fn);
});
}
function addTransitionClass(el, cls) {
var transitionClasses = el._transitionClasses || (el._transitionClasses = []);
if (transitionClasses.indexOf(cls) < 0) {
transitionClasses.push(cls);
addClass(el, cls);
}
}
function removeTransitionClass(el, cls) {
if (el._transitionClasses) {
remove(el._transitionClasses, cls);
}
removeClass(el, cls);
}
function whenTransitionEnds(el, expectedType, cb2) {
var ref2 = getTransitionInfo(el, expectedType);
var type = ref2.type;
var timeout = ref2.timeout;
var propCount = ref2.propCount;
if (!type) {
return cb2();
}
var event = type === TRANSITION ? transitionEndEvent : animationEndEvent;
var ended = 0;
var end2 = function() {
el.removeEventListener(event, onEnd);
cb2();
};
var onEnd = function(e) {
if (e.target === el) {
if (++ended >= propCount) {
end2();
}
}
};
setTimeout(function() {
if (ended < propCount) {
end2();
}
}, timeout + 1);
el.addEventListener(event, onEnd);
}
var transformRE = /\b(transform|all)(,|$)/;
function getTransitionInfo(el, expectedType) {
var styles = window.getComputedStyle(el);
var transitionDelays = (styles[transitionProp + "Delay"] || "").split(", ");
var transitionDurations = (styles[transitionProp + "Duration"] || "").split(", ");
var transitionTimeout = getTimeout(transitionDelays, transitionDurations);
var animationDelays = (styles[animationProp + "Delay"] || "").split(", ");
var animationDurations = (styles[animationProp + "Duration"] || "").split(", ");
var animationTimeout = getTimeout(animationDelays, animationDurations);
var type;
var timeout = 0;
var propCount = 0;
if (expectedType === TRANSITION) {
if (transitionTimeout > 0) {
type = TRANSITION;
timeout = transitionTimeout;
propCount = transitionDurations.length;
}
} else if (expectedType === ANIMATION) {
if (animationTimeout > 0) {
type = ANIMATION;
timeout = animationTimeout;
propCount = animationDurations.length;
}
} else {
timeout = Math.max(transitionTimeout, animationTimeout);
type = timeout > 0 ? transitionTimeout > animationTimeout ? TRANSITION : ANIMATION : null;
propCount = type ? type === TRANSITION ? transitionDurations.length : animationDurations.length : 0;
}
var hasTransform = type === TRANSITION && transformRE.test(styles[transitionProp + "Property"]);
return {
type,
timeout,
propCount,
hasTransform
};
}
function getTimeout(delays, durations) {
while (delays.length < durations.length) {
delays = delays.concat(delays);
}
return Math.max.apply(null, durations.map(function(d, i) {
return toMs(d) + toMs(delays[i]);
}));
}
function toMs(s) {
return Number(s.slice(0, -1).replace(",", ".")) * 1e3;
}
function enter(vnode, toggleDisplay) {
var el = vnode.elm;
if (isDef(el._leaveCb)) {
el._leaveCb.cancelled = true;
el._leaveCb();
}
var data = resolveTransition(vnode.data.transition);
if (isUndef(data)) {
return;
}
if (isDef(el._enterCb) || el.nodeType !== 1) {
return;
}
var css2 = data.css;
var type = data.type;
var enterClass = data.enterClass;
var enterToClass = data.enterToClass;
var enterActiveClass = data.enterActiveClass;
var appearClass = data.appearClass;
var appearToClass = data.appearToClass;
var appearActiveClass = data.appearActiveClass;
var beforeEnter = data.beforeEnter;
var enter3 = data.enter;
var afterEnter = data.afterEnter;
var enterCancelled = data.enterCancelled;
var beforeAppear = data.beforeAppear;
var appear = data.appear;
var afterAppear = data.afterAppear;
var appearCancelled = data.appearCancelled;
var duration2 = data.duration;
var context = activeInstance;
var transitionNode = activeInstance.$vnode;
while (transitionNode && transitionNode.parent) {
context = transitionNode.context;
transitionNode = transitionNode.parent;
}
var isAppear = !context._isMounted || !vnode.isRootInsert;
if (isAppear && !appear && appear !== "") {
return;
}
var startClass = isAppear && appearClass ? appearClass : enterClass;
var activeClass = isAppear && appearActiveClass ? appearActiveClass : enterActiveClass;
var toClass = isAppear && appearToClass ? appearToClass : enterToClass;
var beforeEnterHook = isAppear ? beforeAppear || beforeEnter : beforeEnter;
var enterHook = isAppear ? typeof appear === "function" ? appear : enter3 : enter3;
var afterEnterHook = isAppear ? afterAppear || afterEnter : afterEnter;
var enterCancelledHook = isAppear ? appearCancelled || enterCancelled : enterCancelled;
var explicitEnterDuration = toNumber(isObject$1(duration2) ? duration2.enter : duration2);
var expectsCSS = css2 !== false && !isIE9;
var userWantsControl = getHookArgumentsLength(enterHook);
var cb2 = el._enterCb = once$2(function() {
if (expectsCSS) {
removeTransitionClass(el, toClass);
removeTransitionClass(el, activeClass);
}
if (cb2.cancelled) {
if (expectsCSS) {
removeTransitionClass(el, startClass);
}
enterCancelledHook && enterCancelledHook(el);
} else {
afterEnterHook && afterEnterHook(el);
}
el._enterCb = null;
});
if (!vnode.data.show) {
mergeVNodeHook(vnode, "insert", function() {
var parent = el.parentNode;
var pendingNode = parent && parent._pending && parent._pending[vnode.key];
if (pendingNode && pendingNode.tag === vnode.tag && pendingNode.elm._leaveCb) {
pendingNode.elm._leaveCb();
}
enterHook && enterHook(el, cb2);
});
}
beforeEnterHook && beforeEnterHook(el);
if (expectsCSS) {
addTransitionClass(el, startClass);
addTransitionClass(el, activeClass);
nextFrame(function() {
removeTransitionClass(el, startClass);
if (!cb2.cancelled) {
addTransitionClass(el, toClass);
if (!userWantsControl) {
if (isValidDuration(explicitEnterDuration)) {
setTimeout(cb2, explicitEnterDuration);
} else {
whenTransitionEnds(el, type, cb2);
}
}
}
});
}
if (vnode.data.show) {
toggleDisplay && toggleDisplay();
enterHook && enterHook(el, cb2);
}
if (!expectsCSS && !userWantsControl) {
cb2();
}
}
function leave(vnode, rm2) {
var el = vnode.elm;
if (isDef(el._enterCb)) {
el._enterCb.cancelled = true;
el._enterCb();
}
var data = resolveTransition(vnode.data.transition);
if (isUndef(data) || el.nodeType !== 1) {
return rm2();
}
if (isDef(el._leaveCb)) {
return;
}
var css2 = data.css;
var type = data.type;
var leaveClass = data.leaveClass;
var leaveToClass = data.leaveToClass;
var leaveActiveClass = data.leaveActiveClass;
var beforeLeave = data.beforeLeave;
var leave2 = data.leave;
var afterLeave = data.afterLeave;
var leaveCancelled = data.leaveCancelled;
var delayLeave = data.delayLeave;
var duration2 = data.duration;
var expectsCSS = css2 !== false && !isIE9;
var userWantsControl = getHookArgumentsLength(leave2);
var explicitLeaveDuration = toNumber(isObject$1(duration2) ? duration2.leave : duration2);
var cb2 = el._leaveCb = once$2(function() {
if (el.parentNode && el.parentNode._pending) {
el.parentNode._pending[vnode.key] = null;
}
if (expectsCSS) {
removeTransitionClass(el, leaveToClass);
removeTransitionClass(el, leaveActiveClass);
}
if (cb2.cancelled) {
if (expectsCSS) {
removeTransitionClass(el, leaveClass);
}
leaveCancelled && leaveCancelled(el);
} else {
rm2();
afterLeave && afterLeave(el);
}
el._leaveCb = null;
});
if (delayLeave) {
delayLeave(performLeave);
} else {
performLeave();
}
function performLeave() {
if (cb2.cancelled) {
return;
}
if (!vnode.data.show && el.parentNode) {
(el.parentNode._pending || (el.parentNode._pending = {}))[vnode.key] = vnode;
}
beforeLeave && beforeLeave(el);
if (expectsCSS) {
addTransitionClass(el, leaveClass);
addTransitionClass(el, leaveActiveClass);
nextFrame(function() {
removeTransitionClass(el, leaveClass);
if (!cb2.cancelled) {
addTransitionClass(el, leaveToClass);
if (!userWantsControl) {
if (isValidDuration(explicitLeaveDuration)) {
setTimeout(cb2, explicitLeaveDuration);
} else {
whenTransitionEnds(el, type, cb2);
}
}
}
});
}
leave2 && leave2(el, cb2);
if (!expectsCSS && !userWantsControl) {
cb2();
}
}
}
function isValidDuration(val) {
return typeof val === "number" && !isNaN(val);
}
function getHookArgumentsLength(fn) {
if (isUndef(fn)) {
return false;
}
var invokerFns = fn.fns;
if (isDef(invokerFns)) {
return getHookArgumentsLength(Array.isArray(invokerFns) ? invokerFns[0] : invokerFns);
} else {
return (fn._length || fn.length) > 1;
}
}
function _enter(_2, vnode) {
if (vnode.data.show !== true) {
enter(vnode);
}
}
var transition = inBrowser$1 ? {
create: _enter,
activate: _enter,
remove: function remove$$1(vnode, rm2) {
if (vnode.data.show !== true) {
leave(vnode, rm2);
} else {
rm2();
}
}
} : {};
var platformModules = [
attrs,
klass,
events,
domProps,
style,
transition
];
var modules = platformModules.concat(baseModules);
var patch = createPatchFunction({nodeOps, modules});
if (isIE9) {
document.addEventListener("selectionchange", function() {
var el = document.activeElement;
if (el && el.vmodel) {
trigger(el, "input");
}
});
}
var directive = {
inserted: function inserted(el, binding, vnode, oldVnode) {
if (vnode.tag === "select") {
if (oldVnode.elm && !oldVnode.elm._vOptions) {
mergeVNodeHook(vnode, "postpatch", function() {
directive.componentUpdated(el, binding, vnode);
});
} else {
setSelected(el, binding, vnode.context);
}
el._vOptions = [].map.call(el.options, getValue);
} else if (vnode.tag === "textarea" || isTextInputType(el.type)) {
el._vModifiers = binding.modifiers;
if (!binding.modifiers.lazy) {
el.addEventListener("compositionstart", onCompositionStart);
el.addEventListener("compositionend", onCompositionEnd);
el.addEventListener("change", onCompositionEnd);
if (isIE9) {
el.vmodel = true;
}
}
}
},
componentUpdated: function componentUpdated(el, binding, vnode) {
if (vnode.tag === "select") {
setSelected(el, binding, vnode.context);
var prevOptions = el._vOptions;
var curOptions = el._vOptions = [].map.call(el.options, getValue);
if (curOptions.some(function(o, i) {
return !looseEqual(o, prevOptions[i]);
})) {
var needReset = el.multiple ? binding.value.some(function(v) {
return hasNoMatchingOption(v, curOptions);
}) : binding.value !== binding.oldValue && hasNoMatchingOption(binding.value, curOptions);
if (needReset) {
trigger(el, "change");
}
}
}
}
};
function setSelected(el, binding, vm) {
actuallySetSelected(el, binding);
if (isIE || isEdge) {
setTimeout(function() {
actuallySetSelected(el, binding);
}, 0);
}
}
function actuallySetSelected(el, binding, vm) {
var value = binding.value;
var isMultiple = el.multiple;
if (isMultiple && !Array.isArray(value)) {
return;
}
var selected, option2;
for (var i = 0, l = el.options.length; i < l; i++) {
option2 = el.options[i];
if (isMultiple) {
selected = looseIndexOf(value, getValue(option2)) > -1;
if (option2.selected !== selected) {
option2.selected = selected;
}
} else {
if (looseEqual(getValue(option2), value)) {
if (el.selectedIndex !== i) {
el.selectedIndex = i;
}
return;
}
}
}
if (!isMultiple) {
el.selectedIndex = -1;
}
}
function hasNoMatchingOption(value, options) {
return options.every(function(o) {
return !looseEqual(o, value);
});
}
function getValue(option2) {
return "_value" in option2 ? option2._value : option2.value;
}
function onCompositionStart(e) {
e.target.composing = true;
}
function onCompositionEnd(e) {
if (!e.target.composing) {
return;
}
e.target.composing = false;
trigger(e.target, "input");
}
function trigger(el, type) {
var e = document.createEvent("HTMLEvents");
e.initEvent(type, true, true);
el.dispatchEvent(e);
}
function locateNode(vnode) {
return vnode.componentInstance && (!vnode.data || !vnode.data.transition) ? locateNode(vnode.componentInstance._vnode) : vnode;
}
var show = {
bind: function bind(el, ref2, vnode) {
var value = ref2.value;
vnode = locateNode(vnode);
var transition$$1 = vnode.data && vnode.data.transition;
var originalDisplay = el.__vOriginalDisplay = el.style.display === "none" ? "" : el.style.display;
if (value && transition$$1) {
vnode.data.show = true;
enter(vnode, function() {
el.style.display = originalDisplay;
});
} else {
el.style.display = value ? originalDisplay : "none";
}
},
update: function update3(el, ref2, vnode) {
var value = ref2.value;
var oldValue = ref2.oldValue;
if (!value === !oldValue) {
return;
}
vnode = locateNode(vnode);
var transition$$1 = vnode.data && vnode.data.transition;
if (transition$$1) {
vnode.data.show = true;
if (value) {
enter(vnode, function() {
el.style.display = el.__vOriginalDisplay;
});
} else {
leave(vnode, function() {
el.style.display = "none";
});
}
} else {
el.style.display = value ? el.__vOriginalDisplay : "none";
}
},
unbind: function unbind(el, binding, vnode, oldVnode, isDestroy) {
if (!isDestroy) {
el.style.display = el.__vOriginalDisplay;
}
}
};
var platformDirectives = {
model: directive,
show
};
var transitionProps = {
name: String,
appear: Boolean,
css: Boolean,
mode: String,
type: String,
enterClass: String,
leaveClass: String,
enterToClass: String,
leaveToClass: String,
enterActiveClass: String,
leaveActiveClass: String,
appearClass: String,
appearActiveClass: String,
appearToClass: String,
duration: [Number, String, Object]
};
function getRealChild(vnode) {
var compOptions = vnode && vnode.componentOptions;
if (compOptions && compOptions.Ctor.options.abstract) {
return getRealChild(getFirstComponentChild(compOptions.children));
} else {
return vnode;
}
}
function extractTransitionData(comp) {
var data = {};
var options = comp.$options;
for (var key in options.propsData) {
data[key] = comp[key];
}
var listeners = options._parentListeners;
for (var key$1 in listeners) {
data[camelize(key$1)] = listeners[key$1];
}
return data;
}
function placeholder(h, rawChild) {
if (/\d-keep-alive$/.test(rawChild.tag)) {
return h("keep-alive", {
props: rawChild.componentOptions.propsData
});
}
}
function hasParentTransition(vnode) {
while (vnode = vnode.parent) {
if (vnode.data.transition) {
return true;
}
}
}
function isSameChild(child3, oldChild) {
return oldChild.key === child3.key && oldChild.tag === child3.tag;
}
var isNotTextNode = function(c) {
return c.tag || isAsyncPlaceholder(c);
};
var isVShowDirective = function(d) {
return d.name === "show";
};
var Transition = {
name: "transition",
props: transitionProps,
abstract: true,
render: function render2(h) {
var this$1 = this;
var children = this.$slots.default;
if (!children) {
return;
}
children = children.filter(isNotTextNode);
if (!children.length) {
return;
}
var mode = this.mode;
var rawChild = children[0];
if (hasParentTransition(this.$vnode)) {
return rawChild;
}
var child3 = getRealChild(rawChild);
if (!child3) {
return rawChild;
}
if (this._leaving) {
return placeholder(h, rawChild);
}
var id = "__transition-" + this._uid + "-";
child3.key = child3.key == null ? child3.isComment ? id + "comment" : id + child3.tag : isPrimitive(child3.key) ? String(child3.key).indexOf(id) === 0 ? child3.key : id + child3.key : child3.key;
var data = (child3.data || (child3.data = {})).transition = extractTransitionData(this);
var oldRawChild = this._vnode;
var oldChild = getRealChild(oldRawChild);
if (child3.data.directives && child3.data.directives.some(isVShowDirective)) {
child3.data.show = true;
}
if (oldChild && oldChild.data && !isSameChild(child3, oldChild) && !isAsyncPlaceholder(oldChild) && !(oldChild.componentInstance && oldChild.componentInstance._vnode.isComment)) {
var oldData = oldChild.data.transition = extend$3({}, data);
if (mode === "out-in") {
this._leaving = true;
mergeVNodeHook(oldData, "afterLeave", function() {
this$1._leaving = false;
this$1.$forceUpdate();
});
return placeholder(h, rawChild);
} else if (mode === "in-out") {
if (isAsyncPlaceholder(child3)) {
return oldRawChild;
}
var delayedLeave;
var performLeave = function() {
delayedLeave();
};
mergeVNodeHook(data, "afterEnter", performLeave);
mergeVNodeHook(data, "enterCancelled", performLeave);
mergeVNodeHook(oldData, "delayLeave", function(leave2) {
delayedLeave = leave2;
});
}
}
return rawChild;
}
};
var props = extend$3({
tag: String,
moveClass: String
}, transitionProps);
delete props.mode;
var TransitionGroup = {
props,
beforeMount: function beforeMount() {
var this$1 = this;
var update6 = this._update;
this._update = function(vnode, hydrating) {
var restoreActiveInstance = setActiveInstance(this$1);
this$1.__patch__(this$1._vnode, this$1.kept, false, true);
this$1._vnode = this$1.kept;
restoreActiveInstance();
update6.call(this$1, vnode, hydrating);
};
},
render: function render3(h) {
var tag2 = this.tag || this.$vnode.data.tag || "span";
var map16 = Object.create(null);
var prevChildren = this.prevChildren = this.children;
var rawChildren = this.$slots.default || [];
var children = this.children = [];
var transitionData = extractTransitionData(this);
for (var i = 0; i < rawChildren.length; i++) {
var c = rawChildren[i];
if (c.tag) {
if (c.key != null && String(c.key).indexOf("__vlist") !== 0) {
children.push(c);
map16[c.key] = c;
(c.data || (c.data = {})).transition = transitionData;
}
}
}
if (prevChildren) {
var kept = [];
var removed = [];
for (var i$1 = 0; i$1 < prevChildren.length; i$1++) {
var c$1 = prevChildren[i$1];
c$1.data.transition = transitionData;
c$1.data.pos = c$1.elm.getBoundingClientRect();
if (map16[c$1.key]) {
kept.push(c$1);
} else {
removed.push(c$1);
}
}
this.kept = h(tag2, null, kept);
this.removed = removed;
}
return h(tag2, null, children);
},
updated: function updated() {
var children = this.prevChildren;
var moveClass = this.moveClass || (this.name || "v") + "-move";
if (!children.length || !this.hasMove(children[0].elm, moveClass)) {
return;
}
children.forEach(callPendingCbs);
children.forEach(recordPosition);
children.forEach(applyTranslation);
this._reflow = document.body.offsetHeight;
children.forEach(function(c) {
if (c.data.moved) {
var el = c.elm;
var s = el.style;
addTransitionClass(el, moveClass);
s.transform = s.WebkitTransform = s.transitionDuration = "";
el.addEventListener(transitionEndEvent, el._moveCb = function cb2(e) {
if (e && e.target !== el) {
return;
}
if (!e || /transform$/.test(e.propertyName)) {
el.removeEventListener(transitionEndEvent, cb2);
el._moveCb = null;
removeTransitionClass(el, moveClass);
}
});
}
});
},
methods: {
hasMove: function hasMove(el, moveClass) {
if (!hasTransition) {
return false;
}
if (this._hasMove) {
return this._hasMove;
}
var clone2 = el.cloneNode();
if (el._transitionClasses) {
el._transitionClasses.forEach(function(cls) {
removeClass(clone2, cls);
});
}
addClass(clone2, moveClass);
clone2.style.display = "none";
this.$el.appendChild(clone2);
var info = getTransitionInfo(clone2);
this.$el.removeChild(clone2);
return this._hasMove = info.hasTransform;
}
}
};
function callPendingCbs(c) {
if (c.elm._moveCb) {
c.elm._moveCb();
}
if (c.elm._enterCb) {
c.elm._enterCb();
}
}
function recordPosition(c) {
c.data.newPos = c.elm.getBoundingClientRect();
}
function applyTranslation(c) {
var oldPos = c.data.pos;
var newPos = c.data.newPos;
var dx = oldPos.left - newPos.left;
var dy = oldPos.top - newPos.top;
if (dx || dy) {
c.data.moved = true;
var s = c.elm.style;
s.transform = s.WebkitTransform = "translate(" + dx + "px," + dy + "px)";
s.transitionDuration = "0s";
}
}
var platformComponents = {
Transition,
TransitionGroup
};
Vue.config.mustUseProp = mustUseProp;
Vue.config.isReservedTag = isReservedTag;
Vue.config.isReservedAttr = isReservedAttr;
Vue.config.getTagNamespace = getTagNamespace;
Vue.config.isUnknownElement = isUnknownElement;
extend$3(Vue.options.directives, platformDirectives);
extend$3(Vue.options.components, platformComponents);
Vue.prototype.__patch__ = inBrowser$1 ? patch : noop$3;
Vue.prototype.$mount = function(el, hydrating) {
el = el && inBrowser$1 ? query(el) : void 0;
return mountComponent(this, el, hydrating);
};
if (inBrowser$1) {
setTimeout(function() {
if (config.devtools) {
if (devtools) {
devtools.emit("init", Vue);
}
}
}, 0);
}
var defaultTagRE = /\{\{((?:.|\r?\n)+?)\}\}/g;
var regexEscapeRE = /[-.*+?^${}()|[\]\/\\]/g;
var buildRegex = cached(function(delimiters2) {
var open2 = delimiters2[0].replace(regexEscapeRE, "\\$&");
var close3 = delimiters2[1].replace(regexEscapeRE, "\\$&");
return new RegExp(open2 + "((?:.|\\n)+?)" + close3, "g");
});
function parseText(text3, delimiters2) {
var tagRE = delimiters2 ? buildRegex(delimiters2) : defaultTagRE;
if (!tagRE.test(text3)) {
return;
}
var tokens = [];
var rawTokens = [];
var lastIndex = tagRE.lastIndex = 0;
var match3, index3, tokenValue;
while (match3 = tagRE.exec(text3)) {
index3 = match3.index;
if (index3 > lastIndex) {
rawTokens.push(tokenValue = text3.slice(lastIndex, index3));
tokens.push(JSON.stringify(tokenValue));
}
var exp = parseFilters(match3[1].trim());
tokens.push("_s(" + exp + ")");
rawTokens.push({"@binding": exp});
lastIndex = index3 + match3[0].length;
}
if (lastIndex < text3.length) {
rawTokens.push(tokenValue = text3.slice(lastIndex));
tokens.push(JSON.stringify(tokenValue));
}
return {
expression: tokens.join("+"),
tokens: rawTokens
};
}
function transformNode(el, options) {
options.warn || baseWarn;
var staticClass = getAndRemoveAttr(el, "class");
if (staticClass) {
el.staticClass = JSON.stringify(staticClass);
}
var classBinding = getBindingAttr(el, "class", false);
if (classBinding) {
el.classBinding = classBinding;
}
}
function genData(el) {
var data = "";
if (el.staticClass) {
data += "staticClass:" + el.staticClass + ",";
}
if (el.classBinding) {
data += "class:" + el.classBinding + ",";
}
return data;
}
var klass$1 = {
staticKeys: ["staticClass"],
transformNode,
genData
};
function transformNode$1(el, options) {
options.warn || baseWarn;
var staticStyle = getAndRemoveAttr(el, "style");
if (staticStyle) {
el.staticStyle = JSON.stringify(parseStyleText(staticStyle));
}
var styleBinding = getBindingAttr(el, "style", false);
if (styleBinding) {
el.styleBinding = styleBinding;
}
}
function genData$1(el) {
var data = "";
if (el.staticStyle) {
data += "staticStyle:" + el.staticStyle + ",";
}
if (el.styleBinding) {
data += "style:(" + el.styleBinding + "),";
}
return data;
}
var style$1 = {
staticKeys: ["staticStyle"],
transformNode: transformNode$1,
genData: genData$1
};
var decoder;
var he = {
decode: function decode(html2) {
decoder = decoder || document.createElement("div");
decoder.innerHTML = html2;
return decoder.textContent;
}
};
var isUnaryTag = makeMap("area,base,br,col,embed,frame,hr,img,input,isindex,keygen,link,meta,param,source,track,wbr");
var canBeLeftOpenTag = makeMap("colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr,source");
var isNonPhrasingTag = makeMap("address,article,aside,base,blockquote,body,caption,col,colgroup,dd,details,dialog,div,dl,dt,fieldset,figcaption,figure,footer,form,h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,legend,li,menuitem,meta,optgroup,option,param,rp,rt,source,style,summary,tbody,td,tfoot,th,thead,title,tr,track");
var attribute = /^\s*([^\s"'<>\/=]+)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/;
var dynamicArgAttribute = /^\s*((?:v-[\w-]+:|@|:|#)\[[^=]+\][^\s"'<>\/=]*)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/;
var ncname = "[a-zA-Z_][\\-\\.0-9_a-zA-Z" + unicodeRegExp.source + "]*";
var qnameCapture = "((?:" + ncname + "\\:)?" + ncname + ")";
var startTagOpen = new RegExp("^<" + qnameCapture);
var startTagClose = /^\s*(\/?)>/;
var endTag = new RegExp("^<\\/" + qnameCapture + "[^>]*>");
var doctype = /^<!DOCTYPE [^>]+>/i;
var comment = /^<!\--/;
var conditionalComment = /^<!\[/;
var isPlainTextElement = makeMap("script,style,textarea", true);
var reCache = {};
var decodingMap = {
"&lt;": "<",
"&gt;": ">",
"&quot;": '"',
"&amp;": "&",
"&#10;": "\n",
"&#9;": " ",
"&#39;": "'"
};
var encodedAttr = /&(?:lt|gt|quot|amp|#39);/g;
var encodedAttrWithNewLines = /&(?:lt|gt|quot|amp|#39|#10|#9);/g;
var isIgnoreNewlineTag = makeMap("pre,textarea", true);
var shouldIgnoreFirstNewline = function(tag2, html2) {
return tag2 && isIgnoreNewlineTag(tag2) && html2[0] === "\n";
};
function decodeAttr(value, shouldDecodeNewlines2) {
var re = shouldDecodeNewlines2 ? encodedAttrWithNewLines : encodedAttr;
return value.replace(re, function(match3) {
return decodingMap[match3];
});
}
function parseHTML(html2, options) {
var stack = [];
var expectHTML = options.expectHTML;
var isUnaryTag$$1 = options.isUnaryTag || no;
var canBeLeftOpenTag$$1 = options.canBeLeftOpenTag || no;
var index3 = 0;
var last2, lastTag;
while (html2) {
last2 = html2;
if (!lastTag || !isPlainTextElement(lastTag)) {
var textEnd = html2.indexOf("<");
if (textEnd === 0) {
if (comment.test(html2)) {
var commentEnd = html2.indexOf("-->");
if (commentEnd >= 0) {
if (options.shouldKeepComment) {
options.comment(html2.substring(4, commentEnd), index3, index3 + commentEnd + 3);
}
advance(commentEnd + 3);
continue;
}
}
if (conditionalComment.test(html2)) {
var conditionalEnd = html2.indexOf("]>");
if (conditionalEnd >= 0) {
advance(conditionalEnd + 2);
continue;
}
}
var doctypeMatch = html2.match(doctype);
if (doctypeMatch) {
advance(doctypeMatch[0].length);
continue;
}
var endTagMatch = html2.match(endTag);
if (endTagMatch) {
var curIndex = index3;
advance(endTagMatch[0].length);
parseEndTag(endTagMatch[1], curIndex, index3);
continue;
}
var startTagMatch = parseStartTag();
if (startTagMatch) {
handleStartTag(startTagMatch);
if (shouldIgnoreFirstNewline(startTagMatch.tagName, html2)) {
advance(1);
}
continue;
}
}
var text3 = void 0, rest2 = void 0, next2 = void 0;
if (textEnd >= 0) {
rest2 = html2.slice(textEnd);
while (!endTag.test(rest2) && !startTagOpen.test(rest2) && !comment.test(rest2) && !conditionalComment.test(rest2)) {
next2 = rest2.indexOf("<", 1);
if (next2 < 0) {
break;
}
textEnd += next2;
rest2 = html2.slice(textEnd);
}
text3 = html2.substring(0, textEnd);
}
if (textEnd < 0) {
text3 = html2;
}
if (text3) {
advance(text3.length);
}
if (options.chars && text3) {
options.chars(text3, index3 - text3.length, index3);
}
} else {
var endTagLength = 0;
var stackedTag = lastTag.toLowerCase();
var reStackedTag = reCache[stackedTag] || (reCache[stackedTag] = new RegExp("([\\s\\S]*?)(</" + stackedTag + "[^>]*>)", "i"));
var rest$1 = html2.replace(reStackedTag, function(all, text4, endTag2) {
endTagLength = endTag2.length;
if (!isPlainTextElement(stackedTag) && stackedTag !== "noscript") {
text4 = text4.replace(/<!\--([\s\S]*?)-->/g, "$1").replace(/<!\[CDATA\[([\s\S]*?)]]>/g, "$1");
}
if (shouldIgnoreFirstNewline(stackedTag, text4)) {
text4 = text4.slice(1);
}
if (options.chars) {
options.chars(text4);
}
return "";
});
index3 += html2.length - rest$1.length;
html2 = rest$1;
parseEndTag(stackedTag, index3 - endTagLength, index3);
}
if (html2 === last2) {
options.chars && options.chars(html2);
break;
}
}
parseEndTag();
function advance(n) {
index3 += n;
html2 = html2.substring(n);
}
function parseStartTag() {
var start3 = html2.match(startTagOpen);
if (start3) {
var match3 = {
tagName: start3[1],
attrs: [],
start: index3
};
advance(start3[0].length);
var end2, attr;
while (!(end2 = html2.match(startTagClose)) && (attr = html2.match(dynamicArgAttribute) || html2.match(attribute))) {
attr.start = index3;
advance(attr[0].length);
attr.end = index3;
match3.attrs.push(attr);
}
if (end2) {
match3.unarySlash = end2[1];
advance(end2[0].length);
match3.end = index3;
return match3;
}
}
}
function handleStartTag(match3) {
var tagName2 = match3.tagName;
var unarySlash = match3.unarySlash;
if (expectHTML) {
if (lastTag === "p" && isNonPhrasingTag(tagName2)) {
parseEndTag(lastTag);
}
if (canBeLeftOpenTag$$1(tagName2) && lastTag === tagName2) {
parseEndTag(tagName2);
}
}
var unary = isUnaryTag$$1(tagName2) || !!unarySlash;
var l = match3.attrs.length;
var attrs2 = new Array(l);
for (var i = 0; i < l; i++) {
var args = match3.attrs[i];
var value = args[3] || args[4] || args[5] || "";
var shouldDecodeNewlines2 = tagName2 === "a" && args[1] === "href" ? options.shouldDecodeNewlinesForHref : options.shouldDecodeNewlines;
attrs2[i] = {
name: args[1],
value: decodeAttr(value, shouldDecodeNewlines2)
};
}
if (!unary) {
stack.push({tag: tagName2, lowerCasedTag: tagName2.toLowerCase(), attrs: attrs2, start: match3.start, end: match3.end});
lastTag = tagName2;
}
if (options.start) {
options.start(tagName2, attrs2, unary, match3.start, match3.end);
}
}
function parseEndTag(tagName2, start3, end2) {
var pos, lowerCasedTagName;
if (start3 == null) {
start3 = index3;
}
if (end2 == null) {
end2 = index3;
}
if (tagName2) {
lowerCasedTagName = tagName2.toLowerCase();
for (pos = stack.length - 1; pos >= 0; pos--) {
if (stack[pos].lowerCasedTag === lowerCasedTagName) {
break;
}
}
} else {
pos = 0;
}
if (pos >= 0) {
for (var i = stack.length - 1; i >= pos; i--) {
if (options.end) {
options.end(stack[i].tag, start3, end2);
}
}
stack.length = pos;
lastTag = pos && stack[pos - 1].tag;
} else if (lowerCasedTagName === "br") {
if (options.start) {
options.start(tagName2, [], true, start3, end2);
}
} else if (lowerCasedTagName === "p") {
if (options.start) {
options.start(tagName2, [], false, start3, end2);
}
if (options.end) {
options.end(tagName2, start3, end2);
}
}
}
}
var onRE = /^@|^v-on:/;
var dirRE = /^v-|^@|^:|^#/;
var forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/;
var forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/;
var stripParensRE = /^\(|\)$/g;
var dynamicArgRE = /^\[.*\]$/;
var argRE = /:(.*)$/;
var bindRE = /^:|^\.|^v-bind:/;
var modifierRE = /\.[^.\]]+(?=[^\]]*$)/g;
var slotRE = /^v-slot(:|$)|^#/;
var lineBreakRE = /[\r\n]/;
var whitespaceRE$1 = /\s+/g;
var decodeHTMLCached = cached(he.decode);
var emptySlotScopeToken = "_empty_";
var warn$2;
var delimiters;
var transforms;
var preTransforms;
var postTransforms;
var platformIsPreTag;
var platformMustUseProp;
var platformGetTagNamespace;
function createASTElement(tag2, attrs2, parent) {
return {
type: 1,
tag: tag2,
attrsList: attrs2,
attrsMap: makeAttrsMap(attrs2),
rawAttrsMap: {},
parent,
children: []
};
}
function parse$2(template2, options) {
warn$2 = options.warn || baseWarn;
platformIsPreTag = options.isPreTag || no;
platformMustUseProp = options.mustUseProp || no;
platformGetTagNamespace = options.getTagNamespace || no;
options.isReservedTag || no;
transforms = pluckModuleFunction(options.modules, "transformNode");
preTransforms = pluckModuleFunction(options.modules, "preTransformNode");
postTransforms = pluckModuleFunction(options.modules, "postTransformNode");
delimiters = options.delimiters;
var stack = [];
var preserveWhitespace = options.preserveWhitespace !== false;
var whitespaceOption = options.whitespace;
var root2;
var currentParent;
var inVPre = false;
var inPre = false;
function closeElement(element) {
trimEndingWhitespace(element);
if (!inVPre && !element.processed) {
element = processElement(element, options);
}
if (!stack.length && element !== root2) {
if (root2.if && (element.elseif || element.else)) {
addIfCondition(root2, {
exp: element.elseif,
block: element
});
}
}
if (currentParent && !element.forbidden) {
if (element.elseif || element.else) {
processIfConditions(element, currentParent);
} else {
if (element.slotScope) {
var name = element.slotTarget || '"default"';
(currentParent.scopedSlots || (currentParent.scopedSlots = {}))[name] = element;
}
currentParent.children.push(element);
element.parent = currentParent;
}
}
element.children = element.children.filter(function(c) {
return !c.slotScope;
});
trimEndingWhitespace(element);
if (element.pre) {
inVPre = false;
}
if (platformIsPreTag(element.tag)) {
inPre = false;
}
for (var i = 0; i < postTransforms.length; i++) {
postTransforms[i](element, options);
}
}
function trimEndingWhitespace(el) {
if (!inPre) {
var lastNode;
while ((lastNode = el.children[el.children.length - 1]) && lastNode.type === 3 && lastNode.text === " ") {
el.children.pop();
}
}
}
parseHTML(template2, {
warn: warn$2,
expectHTML: options.expectHTML,
isUnaryTag: options.isUnaryTag,
canBeLeftOpenTag: options.canBeLeftOpenTag,
shouldDecodeNewlines: options.shouldDecodeNewlines,
shouldDecodeNewlinesForHref: options.shouldDecodeNewlinesForHref,
shouldKeepComment: options.comments,
outputSourceRange: options.outputSourceRange,
start: function start3(tag2, attrs2, unary, start$1, end2) {
var ns = currentParent && currentParent.ns || platformGetTagNamespace(tag2);
if (isIE && ns === "svg") {
attrs2 = guardIESVGBug(attrs2);
}
var element = createASTElement(tag2, attrs2, currentParent);
if (ns) {
element.ns = ns;
}
if (isForbiddenTag(element) && !isServerRendering()) {
element.forbidden = true;
}
for (var i = 0; i < preTransforms.length; i++) {
element = preTransforms[i](element, options) || element;
}
if (!inVPre) {
processPre(element);
if (element.pre) {
inVPre = true;
}
}
if (platformIsPreTag(element.tag)) {
inPre = true;
}
if (inVPre) {
processRawAttrs(element);
} else if (!element.processed) {
processFor(element);
processIf(element);
processOnce(element);
}
if (!root2) {
root2 = element;
}
if (!unary) {
currentParent = element;
stack.push(element);
} else {
closeElement(element);
}
},
end: function end2(tag2, start3, end$1) {
var element = stack[stack.length - 1];
stack.length -= 1;
currentParent = stack[stack.length - 1];
closeElement(element);
},
chars: function chars(text3, start3, end2) {
if (!currentParent) {
return;
}
if (isIE && currentParent.tag === "textarea" && currentParent.attrsMap.placeholder === text3) {
return;
}
var children = currentParent.children;
if (inPre || text3.trim()) {
text3 = isTextTag(currentParent) ? text3 : decodeHTMLCached(text3);
} else if (!children.length) {
text3 = "";
} else if (whitespaceOption) {
if (whitespaceOption === "condense") {
text3 = lineBreakRE.test(text3) ? "" : " ";
} else {
text3 = " ";
}
} else {
text3 = preserveWhitespace ? " " : "";
}
if (text3) {
if (!inPre && whitespaceOption === "condense") {
text3 = text3.replace(whitespaceRE$1, " ");
}
var res;
var child3;
if (!inVPre && text3 !== " " && (res = parseText(text3, delimiters))) {
child3 = {
type: 2,
expression: res.expression,
tokens: res.tokens,
text: text3
};
} else if (text3 !== " " || !children.length || children[children.length - 1].text !== " ") {
child3 = {
type: 3,
text: text3
};
}
if (child3) {
children.push(child3);
}
}
},
comment: function comment2(text3, start3, end2) {
if (currentParent) {
var child3 = {
type: 3,
text: text3,
isComment: true
};
currentParent.children.push(child3);
}
}
});
return root2;
}
function processPre(el) {
if (getAndRemoveAttr(el, "v-pre") != null) {
el.pre = true;
}
}
function processRawAttrs(el) {
var list = el.attrsList;
var len2 = list.length;
if (len2) {
var attrs2 = el.attrs = new Array(len2);
for (var i = 0; i < len2; i++) {
attrs2[i] = {
name: list[i].name,
value: JSON.stringify(list[i].value)
};
if (list[i].start != null) {
attrs2[i].start = list[i].start;
attrs2[i].end = list[i].end;
}
}
} else if (!el.pre) {
el.plain = true;
}
}
function processElement(element, options) {
processKey(element);
element.plain = !element.key && !element.scopedSlots && !element.attrsList.length;
processRef(element);
processSlotContent(element);
processSlotOutlet(element);
processComponent(element);
for (var i = 0; i < transforms.length; i++) {
element = transforms[i](element, options) || element;
}
processAttrs(element);
return element;
}
function processKey(el) {
var exp = getBindingAttr(el, "key");
if (exp) {
el.key = exp;
}
}
function processRef(el) {
var ref2 = getBindingAttr(el, "ref");
if (ref2) {
el.ref = ref2;
el.refInFor = checkInFor(el);
}
}
function processFor(el) {
var exp;
if (exp = getAndRemoveAttr(el, "v-for")) {
var res = parseFor(exp);
if (res) {
extend$3(el, res);
}
}
}
function parseFor(exp) {
var inMatch = exp.match(forAliasRE);
if (!inMatch) {
return;
}
var res = {};
res.for = inMatch[2].trim();
var alias = inMatch[1].trim().replace(stripParensRE, "");
var iteratorMatch = alias.match(forIteratorRE);
if (iteratorMatch) {
res.alias = alias.replace(forIteratorRE, "").trim();
res.iterator1 = iteratorMatch[1].trim();
if (iteratorMatch[2]) {
res.iterator2 = iteratorMatch[2].trim();
}
} else {
res.alias = alias;
}
return res;
}
function processIf(el) {
var exp = getAndRemoveAttr(el, "v-if");
if (exp) {
el.if = exp;
addIfCondition(el, {
exp,
block: el
});
} else {
if (getAndRemoveAttr(el, "v-else") != null) {
el.else = true;
}
var elseif = getAndRemoveAttr(el, "v-else-if");
if (elseif) {
el.elseif = elseif;
}
}
}
function processIfConditions(el, parent) {
var prev = findPrevElement(parent.children);
if (prev && prev.if) {
addIfCondition(prev, {
exp: el.elseif,
block: el
});
}
}
function findPrevElement(children) {
var i = children.length;
while (i--) {
if (children[i].type === 1) {
return children[i];
} else {
children.pop();
}
}
}
function addIfCondition(el, condition) {
if (!el.ifConditions) {
el.ifConditions = [];
}
el.ifConditions.push(condition);
}
function processOnce(el) {
var once$$1 = getAndRemoveAttr(el, "v-once");
if (once$$1 != null) {
el.once = true;
}
}
function processSlotContent(el) {
var slotScope;
if (el.tag === "template") {
slotScope = getAndRemoveAttr(el, "scope");
el.slotScope = slotScope || getAndRemoveAttr(el, "slot-scope");
} else if (slotScope = getAndRemoveAttr(el, "slot-scope")) {
el.slotScope = slotScope;
}
var slotTarget = getBindingAttr(el, "slot");
if (slotTarget) {
el.slotTarget = slotTarget === '""' ? '"default"' : slotTarget;
el.slotTargetDynamic = !!(el.attrsMap[":slot"] || el.attrsMap["v-bind:slot"]);
if (el.tag !== "template" && !el.slotScope) {
addAttr(el, "slot", slotTarget, getRawBindingAttr(el, "slot"));
}
}
{
if (el.tag === "template") {
var slotBinding = getAndRemoveAttrByRegex(el, slotRE);
if (slotBinding) {
var ref2 = getSlotName(slotBinding);
var name = ref2.name;
var dynamic = ref2.dynamic;
el.slotTarget = name;
el.slotTargetDynamic = dynamic;
el.slotScope = slotBinding.value || emptySlotScopeToken;
}
} else {
var slotBinding$1 = getAndRemoveAttrByRegex(el, slotRE);
if (slotBinding$1) {
var slots = el.scopedSlots || (el.scopedSlots = {});
var ref$12 = getSlotName(slotBinding$1);
var name$1 = ref$12.name;
var dynamic$1 = ref$12.dynamic;
var slotContainer = slots[name$1] = createASTElement("template", [], el);
slotContainer.slotTarget = name$1;
slotContainer.slotTargetDynamic = dynamic$1;
slotContainer.children = el.children.filter(function(c) {
if (!c.slotScope) {
c.parent = slotContainer;
return true;
}
});
slotContainer.slotScope = slotBinding$1.value || emptySlotScopeToken;
el.children = [];
el.plain = false;
}
}
}
}
function getSlotName(binding) {
var name = binding.name.replace(slotRE, "");
if (!name) {
if (binding.name[0] !== "#") {
name = "default";
}
}
return dynamicArgRE.test(name) ? {name: name.slice(1, -1), dynamic: true} : {name: '"' + name + '"', dynamic: false};
}
function processSlotOutlet(el) {
if (el.tag === "slot") {
el.slotName = getBindingAttr(el, "name");
}
}
function processComponent(el) {
var binding;
if (binding = getBindingAttr(el, "is")) {
el.component = binding;
}
if (getAndRemoveAttr(el, "inline-template") != null) {
el.inlineTemplate = true;
}
}
function processAttrs(el) {
var list = el.attrsList;
var i, l, name, rawName, value, modifiers2, syncGen, isDynamic;
for (i = 0, l = list.length; i < l; i++) {
name = rawName = list[i].name;
value = list[i].value;
if (dirRE.test(name)) {
el.hasBindings = true;
modifiers2 = parseModifiers(name.replace(dirRE, ""));
if (modifiers2) {
name = name.replace(modifierRE, "");
}
if (bindRE.test(name)) {
name = name.replace(bindRE, "");
value = parseFilters(value);
isDynamic = dynamicArgRE.test(name);
if (isDynamic) {
name = name.slice(1, -1);
}
if (modifiers2) {
if (modifiers2.prop && !isDynamic) {
name = camelize(name);
if (name === "innerHtml") {
name = "innerHTML";
}
}
if (modifiers2.camel && !isDynamic) {
name = camelize(name);
}
if (modifiers2.sync) {
syncGen = genAssignmentCode(value, "$event");
if (!isDynamic) {
addHandler(el, "update:" + camelize(name), syncGen, null, false, warn$2, list[i]);
if (hyphenate(name) !== camelize(name)) {
addHandler(el, "update:" + hyphenate(name), syncGen, null, false, warn$2, list[i]);
}
} else {
addHandler(el, '"update:"+(' + name + ")", syncGen, null, false, warn$2, list[i], true);
}
}
}
if (modifiers2 && modifiers2.prop || !el.component && platformMustUseProp(el.tag, el.attrsMap.type, name)) {
addProp(el, name, value, list[i], isDynamic);
} else {
addAttr(el, name, value, list[i], isDynamic);
}
} else if (onRE.test(name)) {
name = name.replace(onRE, "");
isDynamic = dynamicArgRE.test(name);
if (isDynamic) {
name = name.slice(1, -1);
}
addHandler(el, name, value, modifiers2, false, warn$2, list[i], isDynamic);
} else {
name = name.replace(dirRE, "");
var argMatch = name.match(argRE);
var arg = argMatch && argMatch[1];
isDynamic = false;
if (arg) {
name = name.slice(0, -(arg.length + 1));
if (dynamicArgRE.test(arg)) {
arg = arg.slice(1, -1);
isDynamic = true;
}
}
addDirective(el, name, rawName, value, arg, isDynamic, modifiers2, list[i]);
}
} else {
addAttr(el, name, JSON.stringify(value), list[i]);
if (!el.component && name === "muted" && platformMustUseProp(el.tag, el.attrsMap.type, name)) {
addProp(el, name, "true", list[i]);
}
}
}
}
function checkInFor(el) {
var parent = el;
while (parent) {
if (parent.for !== void 0) {
return true;
}
parent = parent.parent;
}
return false;
}
function parseModifiers(name) {
var match3 = name.match(modifierRE);
if (match3) {
var ret = {};
match3.forEach(function(m) {
ret[m.slice(1)] = true;
});
return ret;
}
}
function makeAttrsMap(attrs2) {
var map16 = {};
for (var i = 0, l = attrs2.length; i < l; i++) {
map16[attrs2[i].name] = attrs2[i].value;
}
return map16;
}
function isTextTag(el) {
return el.tag === "script" || el.tag === "style";
}
function isForbiddenTag(el) {
return el.tag === "style" || el.tag === "script" && (!el.attrsMap.type || el.attrsMap.type === "text/javascript");
}
var ieNSBug = /^xmlns:NS\d+/;
var ieNSPrefix = /^NS\d+:/;
function guardIESVGBug(attrs2) {
var res = [];
for (var i = 0; i < attrs2.length; i++) {
var attr = attrs2[i];
if (!ieNSBug.test(attr.name)) {
attr.name = attr.name.replace(ieNSPrefix, "");
res.push(attr);
}
}
return res;
}
function preTransformNode(el, options) {
if (el.tag === "input") {
var map16 = el.attrsMap;
if (!map16["v-model"]) {
return;
}
var typeBinding;
if (map16[":type"] || map16["v-bind:type"]) {
typeBinding = getBindingAttr(el, "type");
}
if (!map16.type && !typeBinding && map16["v-bind"]) {
typeBinding = "(" + map16["v-bind"] + ").type";
}
if (typeBinding) {
var ifCondition = getAndRemoveAttr(el, "v-if", true);
var ifConditionExtra = ifCondition ? "&&(" + ifCondition + ")" : "";
var hasElse = getAndRemoveAttr(el, "v-else", true) != null;
var elseIfCondition = getAndRemoveAttr(el, "v-else-if", true);
var branch0 = cloneASTElement(el);
processFor(branch0);
addRawAttr(branch0, "type", "checkbox");
processElement(branch0, options);
branch0.processed = true;
branch0.if = "(" + typeBinding + ")==='checkbox'" + ifConditionExtra;
addIfCondition(branch0, {
exp: branch0.if,
block: branch0
});
var branch1 = cloneASTElement(el);
getAndRemoveAttr(branch1, "v-for", true);
addRawAttr(branch1, "type", "radio");
processElement(branch1, options);
addIfCondition(branch0, {
exp: "(" + typeBinding + ")==='radio'" + ifConditionExtra,
block: branch1
});
var branch2 = cloneASTElement(el);
getAndRemoveAttr(branch2, "v-for", true);
addRawAttr(branch2, ":type", typeBinding);
processElement(branch2, options);
addIfCondition(branch0, {
exp: ifCondition,
block: branch2
});
if (hasElse) {
branch0.else = true;
} else if (elseIfCondition) {
branch0.elseif = elseIfCondition;
}
return branch0;
}
}
}
function cloneASTElement(el) {
return createASTElement(el.tag, el.attrsList.slice(), el.parent);
}
var model$1 = {
preTransformNode
};
var modules$1 = [
klass$1,
style$1,
model$1
];
function text$1(el, dir) {
if (dir.value) {
addProp(el, "textContent", "_s(" + dir.value + ")", dir);
}
}
function html(el, dir) {
if (dir.value) {
addProp(el, "innerHTML", "_s(" + dir.value + ")", dir);
}
}
var directives$1 = {
model,
text: text$1,
html
};
var baseOptions = {
expectHTML: true,
modules: modules$1,
directives: directives$1,
isPreTag,
isUnaryTag,
mustUseProp,
canBeLeftOpenTag,
isReservedTag,
getTagNamespace,
staticKeys: genStaticKeys(modules$1)
};
var isStaticKey;
var isPlatformReservedTag;
var genStaticKeysCached = cached(genStaticKeys$1);
function optimize(root2, options) {
if (!root2) {
return;
}
isStaticKey = genStaticKeysCached(options.staticKeys || "");
isPlatformReservedTag = options.isReservedTag || no;
markStatic$1(root2);
markStaticRoots(root2, false);
}
function genStaticKeys$1(keys2) {
return makeMap("type,tag,attrsList,attrsMap,plain,parent,children,attrs,start,end,rawAttrsMap" + (keys2 ? "," + keys2 : ""));
}
function markStatic$1(node4) {
node4.static = isStatic(node4);
if (node4.type === 1) {
if (!isPlatformReservedTag(node4.tag) && node4.tag !== "slot" && node4.attrsMap["inline-template"] == null) {
return;
}
for (var i = 0, l = node4.children.length; i < l; i++) {
var child3 = node4.children[i];
markStatic$1(child3);
if (!child3.static) {
node4.static = false;
}
}
if (node4.ifConditions) {
for (var i$1 = 1, l$1 = node4.ifConditions.length; i$1 < l$1; i$1++) {
var block = node4.ifConditions[i$1].block;
markStatic$1(block);
if (!block.static) {
node4.static = false;
}
}
}
}
}
function markStaticRoots(node4, isInFor) {
if (node4.type === 1) {
if (node4.static || node4.once) {
node4.staticInFor = isInFor;
}
if (node4.static && node4.children.length && !(node4.children.length === 1 && node4.children[0].type === 3)) {
node4.staticRoot = true;
return;
} else {
node4.staticRoot = false;
}
if (node4.children) {
for (var i = 0, l = node4.children.length; i < l; i++) {
markStaticRoots(node4.children[i], isInFor || !!node4.for);
}
}
if (node4.ifConditions) {
for (var i$1 = 1, l$1 = node4.ifConditions.length; i$1 < l$1; i$1++) {
markStaticRoots(node4.ifConditions[i$1].block, isInFor);
}
}
}
}
function isStatic(node4) {
if (node4.type === 2) {
return false;
}
if (node4.type === 3) {
return true;
}
return !!(node4.pre || !node4.hasBindings && !node4.if && !node4.for && !isBuiltInTag(node4.tag) && isPlatformReservedTag(node4.tag) && !isDirectChildOfTemplateFor(node4) && Object.keys(node4).every(isStaticKey));
}
function isDirectChildOfTemplateFor(node4) {
while (node4.parent) {
node4 = node4.parent;
if (node4.tag !== "template") {
return false;
}
if (node4.for) {
return true;
}
}
return false;
}
var fnExpRE = /^([\w$_]+|\([^)]*?\))\s*=>|^function(?:\s+[\w$]+)?\s*\(/;
var fnInvokeRE = /\([^)]*?\);*$/;
var simplePathRE = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['[^']*?']|\["[^"]*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*$/;
var keyCodes = {
esc: 27,
tab: 9,
enter: 13,
space: 32,
up: 38,
left: 37,
right: 39,
down: 40,
delete: [8, 46]
};
var keyNames = {
esc: ["Esc", "Escape"],
tab: "Tab",
enter: "Enter",
space: [" ", "Spacebar"],
up: ["Up", "ArrowUp"],
left: ["Left", "ArrowLeft"],
right: ["Right", "ArrowRight"],
down: ["Down", "ArrowDown"],
delete: ["Backspace", "Delete", "Del"]
};
var genGuard = function(condition) {
return "if(" + condition + ")return null;";
};
var modifierCode = {
stop: "$event.stopPropagation();",
prevent: "$event.preventDefault();",
self: genGuard("$event.target !== $event.currentTarget"),
ctrl: genGuard("!$event.ctrlKey"),
shift: genGuard("!$event.shiftKey"),
alt: genGuard("!$event.altKey"),
meta: genGuard("!$event.metaKey"),
left: genGuard("'button' in $event && $event.button !== 0"),
middle: genGuard("'button' in $event && $event.button !== 1"),
right: genGuard("'button' in $event && $event.button !== 2")
};
function genHandlers(events2, isNative2) {
var prefix = isNative2 ? "nativeOn:" : "on:";
var staticHandlers = "";
var dynamicHandlers = "";
for (var name in events2) {
var handlerCode = genHandler(events2[name]);
if (events2[name] && events2[name].dynamic) {
dynamicHandlers += name + "," + handlerCode + ",";
} else {
staticHandlers += '"' + name + '":' + handlerCode + ",";
}
}
staticHandlers = "{" + staticHandlers.slice(0, -1) + "}";
if (dynamicHandlers) {
return prefix + "_d(" + staticHandlers + ",[" + dynamicHandlers.slice(0, -1) + "])";
} else {
return prefix + staticHandlers;
}
}
function genHandler(handler) {
if (!handler) {
return "function(){}";
}
if (Array.isArray(handler)) {
return "[" + handler.map(function(handler2) {
return genHandler(handler2);
}).join(",") + "]";
}
var isMethodPath = simplePathRE.test(handler.value);
var isFunctionExpression = fnExpRE.test(handler.value);
var isFunctionInvocation = simplePathRE.test(handler.value.replace(fnInvokeRE, ""));
if (!handler.modifiers) {
if (isMethodPath || isFunctionExpression) {
return handler.value;
}
return "function($event){" + (isFunctionInvocation ? "return " + handler.value : handler.value) + "}";
} else {
var code = "";
var genModifierCode = "";
var keys2 = [];
for (var key in handler.modifiers) {
if (modifierCode[key]) {
genModifierCode += modifierCode[key];
if (keyCodes[key]) {
keys2.push(key);
}
} else if (key === "exact") {
var modifiers2 = handler.modifiers;
genModifierCode += genGuard(["ctrl", "shift", "alt", "meta"].filter(function(keyModifier) {
return !modifiers2[keyModifier];
}).map(function(keyModifier) {
return "$event." + keyModifier + "Key";
}).join("||"));
} else {
keys2.push(key);
}
}
if (keys2.length) {
code += genKeyFilter(keys2);
}
if (genModifierCode) {
code += genModifierCode;
}
var handlerCode = isMethodPath ? "return " + handler.value + "($event)" : isFunctionExpression ? "return (" + handler.value + ")($event)" : isFunctionInvocation ? "return " + handler.value : handler.value;
return "function($event){" + code + handlerCode + "}";
}
}
function genKeyFilter(keys2) {
return "if(!$event.type.indexOf('key')&&" + keys2.map(genFilterCode).join("&&") + ")return null;";
}
function genFilterCode(key) {
var keyVal = parseInt(key, 10);
if (keyVal) {
return "$event.keyCode!==" + keyVal;
}
var keyCode = keyCodes[key];
var keyName2 = keyNames[key];
return "_k($event.keyCode," + JSON.stringify(key) + "," + JSON.stringify(keyCode) + ",$event.key," + JSON.stringify(keyName2) + ")";
}
function on$1(el, dir) {
el.wrapListeners = function(code) {
return "_g(" + code + "," + dir.value + ")";
};
}
function bind$1$1(el, dir) {
el.wrapData = function(code) {
return "_b(" + code + ",'" + el.tag + "'," + dir.value + "," + (dir.modifiers && dir.modifiers.prop ? "true" : "false") + (dir.modifiers && dir.modifiers.sync ? ",true" : "") + ")";
};
}
var baseDirectives = {
on: on$1,
bind: bind$1$1,
cloak: noop$3
};
var CodegenState = function CodegenState2(options) {
this.options = options;
this.warn = options.warn || baseWarn;
this.transforms = pluckModuleFunction(options.modules, "transformCode");
this.dataGenFns = pluckModuleFunction(options.modules, "genData");
this.directives = extend$3(extend$3({}, baseDirectives), options.directives);
var isReservedTag2 = options.isReservedTag || no;
this.maybeComponent = function(el) {
return !!el.component || !isReservedTag2(el.tag);
};
this.onceId = 0;
this.staticRenderFns = [];
this.pre = false;
};
function generate(ast, options) {
var state = new CodegenState(options);
var code = ast ? genElement(ast, state) : '_c("div")';
return {
render: "with(this){return " + code + "}",
staticRenderFns: state.staticRenderFns
};
}
function genElement(el, state) {
if (el.parent) {
el.pre = el.pre || el.parent.pre;
}
if (el.staticRoot && !el.staticProcessed) {
return genStatic(el, state);
} else if (el.once && !el.onceProcessed) {
return genOnce(el, state);
} else if (el.for && !el.forProcessed) {
return genFor(el, state);
} else if (el.if && !el.ifProcessed) {
return genIf(el, state);
} else if (el.tag === "template" && !el.slotTarget && !state.pre) {
return genChildren(el, state) || "void 0";
} else if (el.tag === "slot") {
return genSlot(el, state);
} else {
var code;
if (el.component) {
code = genComponent(el.component, el, state);
} else {
var data;
if (!el.plain || el.pre && state.maybeComponent(el)) {
data = genData$2(el, state);
}
var children = el.inlineTemplate ? null : genChildren(el, state, true);
code = "_c('" + el.tag + "'" + (data ? "," + data : "") + (children ? "," + children : "") + ")";
}
for (var i = 0; i < state.transforms.length; i++) {
code = state.transforms[i](el, code);
}
return code;
}
}
function genStatic(el, state) {
el.staticProcessed = true;
var originalPreState = state.pre;
if (el.pre) {
state.pre = el.pre;
}
state.staticRenderFns.push("with(this){return " + genElement(el, state) + "}");
state.pre = originalPreState;
return "_m(" + (state.staticRenderFns.length - 1) + (el.staticInFor ? ",true" : "") + ")";
}
function genOnce(el, state) {
el.onceProcessed = true;
if (el.if && !el.ifProcessed) {
return genIf(el, state);
} else if (el.staticInFor) {
var key = "";
var parent = el.parent;
while (parent) {
if (parent.for) {
key = parent.key;
break;
}
parent = parent.parent;
}
if (!key) {
return genElement(el, state);
}
return "_o(" + genElement(el, state) + "," + state.onceId++ + "," + key + ")";
} else {
return genStatic(el, state);
}
}
function genIf(el, state, altGen, altEmpty) {
el.ifProcessed = true;
return genIfConditions(el.ifConditions.slice(), state, altGen, altEmpty);
}
function genIfConditions(conditions, state, altGen, altEmpty) {
if (!conditions.length) {
return altEmpty || "_e()";
}
var condition = conditions.shift();
if (condition.exp) {
return "(" + condition.exp + ")?" + genTernaryExp(condition.block) + ":" + genIfConditions(conditions, state, altGen, altEmpty);
} else {
return "" + genTernaryExp(condition.block);
}
function genTernaryExp(el) {
return altGen ? altGen(el, state) : el.once ? genOnce(el, state) : genElement(el, state);
}
}
function genFor(el, state, altGen, altHelper) {
var exp = el.for;
var alias = el.alias;
var iterator1 = el.iterator1 ? "," + el.iterator1 : "";
var iterator2 = el.iterator2 ? "," + el.iterator2 : "";
el.forProcessed = true;
return (altHelper || "_l") + "((" + exp + "),function(" + alias + iterator1 + iterator2 + "){return " + (altGen || genElement)(el, state) + "})";
}
function genData$2(el, state) {
var data = "{";
var dirs = genDirectives(el, state);
if (dirs) {
data += dirs + ",";
}
if (el.key) {
data += "key:" + el.key + ",";
}
if (el.ref) {
data += "ref:" + el.ref + ",";
}
if (el.refInFor) {
data += "refInFor:true,";
}
if (el.pre) {
data += "pre:true,";
}
if (el.component) {
data += 'tag:"' + el.tag + '",';
}
for (var i = 0; i < state.dataGenFns.length; i++) {
data += state.dataGenFns[i](el);
}
if (el.attrs) {
data += "attrs:" + genProps(el.attrs) + ",";
}
if (el.props) {
data += "domProps:" + genProps(el.props) + ",";
}
if (el.events) {
data += genHandlers(el.events, false) + ",";
}
if (el.nativeEvents) {
data += genHandlers(el.nativeEvents, true) + ",";
}
if (el.slotTarget && !el.slotScope) {
data += "slot:" + el.slotTarget + ",";
}
if (el.scopedSlots) {
data += genScopedSlots(el, el.scopedSlots, state) + ",";
}
if (el.model) {
data += "model:{value:" + el.model.value + ",callback:" + el.model.callback + ",expression:" + el.model.expression + "},";
}
if (el.inlineTemplate) {
var inlineTemplate = genInlineTemplate(el, state);
if (inlineTemplate) {
data += inlineTemplate + ",";
}
}
data = data.replace(/,$/, "") + "}";
if (el.dynamicAttrs) {
data = "_b(" + data + ',"' + el.tag + '",' + genProps(el.dynamicAttrs) + ")";
}
if (el.wrapData) {
data = el.wrapData(data);
}
if (el.wrapListeners) {
data = el.wrapListeners(data);
}
return data;
}
function genDirectives(el, state) {
var dirs = el.directives;
if (!dirs) {
return;
}
var res = "directives:[";
var hasRuntime = false;
var i, l, dir, needRuntime;
for (i = 0, l = dirs.length; i < l; i++) {
dir = dirs[i];
needRuntime = true;
var gen = state.directives[dir.name];
if (gen) {
needRuntime = !!gen(el, dir, state.warn);
}
if (needRuntime) {
hasRuntime = true;
res += '{name:"' + dir.name + '",rawName:"' + dir.rawName + '"' + (dir.value ? ",value:(" + dir.value + "),expression:" + JSON.stringify(dir.value) : "") + (dir.arg ? ",arg:" + (dir.isDynamicArg ? dir.arg : '"' + dir.arg + '"') : "") + (dir.modifiers ? ",modifiers:" + JSON.stringify(dir.modifiers) : "") + "},";
}
}
if (hasRuntime) {
return res.slice(0, -1) + "]";
}
}
function genInlineTemplate(el, state) {
var ast = el.children[0];
if (ast && ast.type === 1) {
var inlineRenderFns = generate(ast, state.options);
return "inlineTemplate:{render:function(){" + inlineRenderFns.render + "},staticRenderFns:[" + inlineRenderFns.staticRenderFns.map(function(code) {
return "function(){" + code + "}";
}).join(",") + "]}";
}
}
function genScopedSlots(el, slots, state) {
var needsForceUpdate = el.for || Object.keys(slots).some(function(key) {
var slot = slots[key];
return slot.slotTargetDynamic || slot.if || slot.for || containsSlotChild(slot);
});
var needsKey = !!el.if;
if (!needsForceUpdate) {
var parent = el.parent;
while (parent) {
if (parent.slotScope && parent.slotScope !== emptySlotScopeToken || parent.for) {
needsForceUpdate = true;
break;
}
if (parent.if) {
needsKey = true;
}
parent = parent.parent;
}
}
var generatedSlots = Object.keys(slots).map(function(key) {
return genScopedSlot(slots[key], state);
}).join(",");
return "scopedSlots:_u([" + generatedSlots + "]" + (needsForceUpdate ? ",null,true" : "") + (!needsForceUpdate && needsKey ? ",null,false," + hash(generatedSlots) : "") + ")";
}
function hash(str2) {
var hash2 = 5381;
var i = str2.length;
while (i) {
hash2 = hash2 * 33 ^ str2.charCodeAt(--i);
}
return hash2 >>> 0;
}
function containsSlotChild(el) {
if (el.type === 1) {
if (el.tag === "slot") {
return true;
}
return el.children.some(containsSlotChild);
}
return false;
}
function genScopedSlot(el, state) {
var isLegacySyntax = el.attrsMap["slot-scope"];
if (el.if && !el.ifProcessed && !isLegacySyntax) {
return genIf(el, state, genScopedSlot, "null");
}
if (el.for && !el.forProcessed) {
return genFor(el, state, genScopedSlot);
}
var slotScope = el.slotScope === emptySlotScopeToken ? "" : String(el.slotScope);
var fn = "function(" + slotScope + "){return " + (el.tag === "template" ? el.if && isLegacySyntax ? "(" + el.if + ")?" + (genChildren(el, state) || "undefined") + ":undefined" : genChildren(el, state) || "undefined" : genElement(el, state)) + "}";
var reverseProxy = slotScope ? "" : ",proxy:true";
return "{key:" + (el.slotTarget || '"default"') + ",fn:" + fn + reverseProxy + "}";
}
function genChildren(el, state, checkSkip, altGenElement, altGenNode) {
var children = el.children;
if (children.length) {
var el$1 = children[0];
if (children.length === 1 && el$1.for && el$1.tag !== "template" && el$1.tag !== "slot") {
var normalizationType = checkSkip ? state.maybeComponent(el$1) ? ",1" : ",0" : "";
return "" + (altGenElement || genElement)(el$1, state) + normalizationType;
}
var normalizationType$1 = checkSkip ? getNormalizationType(children, state.maybeComponent) : 0;
var gen = altGenNode || genNode;
return "[" + children.map(function(c) {
return gen(c, state);
}).join(",") + "]" + (normalizationType$1 ? "," + normalizationType$1 : "");
}
}
function getNormalizationType(children, maybeComponent) {
var res = 0;
for (var i = 0; i < children.length; i++) {
var el = children[i];
if (el.type !== 1) {
continue;
}
if (needsNormalization(el) || el.ifConditions && el.ifConditions.some(function(c) {
return needsNormalization(c.block);
})) {
res = 2;
break;
}
if (maybeComponent(el) || el.ifConditions && el.ifConditions.some(function(c) {
return maybeComponent(c.block);
})) {
res = 1;
}
}
return res;
}
function needsNormalization(el) {
return el.for !== void 0 || el.tag === "template" || el.tag === "slot";
}
function genNode(node4, state) {
if (node4.type === 1) {
return genElement(node4, state);
} else if (node4.type === 3 && node4.isComment) {
return genComment(node4);
} else {
return genText(node4);
}
}
function genText(text3) {
return "_v(" + (text3.type === 2 ? text3.expression : transformSpecialNewlines(JSON.stringify(text3.text))) + ")";
}
function genComment(comment2) {
return "_e(" + JSON.stringify(comment2.text) + ")";
}
function genSlot(el, state) {
var slotName = el.slotName || '"default"';
var children = genChildren(el, state);
var res = "_t(" + slotName + (children ? "," + children : "");
var attrs2 = el.attrs || el.dynamicAttrs ? genProps((el.attrs || []).concat(el.dynamicAttrs || []).map(function(attr) {
return {
name: camelize(attr.name),
value: attr.value,
dynamic: attr.dynamic
};
})) : null;
var bind$$1 = el.attrsMap["v-bind"];
if ((attrs2 || bind$$1) && !children) {
res += ",null";
}
if (attrs2) {
res += "," + attrs2;
}
if (bind$$1) {
res += (attrs2 ? "" : ",null") + "," + bind$$1;
}
return res + ")";
}
function genComponent(componentName, el, state) {
var children = el.inlineTemplate ? null : genChildren(el, state, true);
return "_c(" + componentName + "," + genData$2(el, state) + (children ? "," + children : "") + ")";
}
function genProps(props2) {
var staticProps = "";
var dynamicProps = "";
for (var i = 0; i < props2.length; i++) {
var prop = props2[i];
var value = transformSpecialNewlines(prop.value);
if (prop.dynamic) {
dynamicProps += prop.name + "," + value + ",";
} else {
staticProps += '"' + prop.name + '":' + value + ",";
}
}
staticProps = "{" + staticProps.slice(0, -1) + "}";
if (dynamicProps) {
return "_d(" + staticProps + ",[" + dynamicProps.slice(0, -1) + "])";
} else {
return staticProps;
}
}
function transformSpecialNewlines(text3) {
return text3.replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
}
new RegExp("\\b" + "do,if,for,let,new,try,var,case,else,with,await,break,catch,class,const,super,throw,while,yield,delete,export,import,return,switch,default,extends,finally,continue,debugger,function,arguments".split(",").join("\\b|\\b") + "\\b");
function createFunction(code, errors) {
try {
return new Function(code);
} catch (err2) {
errors.push({err: err2, code});
return noop$3;
}
}
function createCompileToFunctionFn(compile4) {
var cache = Object.create(null);
return function compileToFunctions2(template2, options, vm) {
options = extend$3({}, options);
options.warn || warn$1;
delete options.warn;
var key = options.delimiters ? String(options.delimiters) + template2 : template2;
if (cache[key]) {
return cache[key];
}
var compiled = compile4(template2, options);
var res = {};
var fnGenErrors = [];
res.render = createFunction(compiled.render, fnGenErrors);
res.staticRenderFns = compiled.staticRenderFns.map(function(code) {
return createFunction(code, fnGenErrors);
});
return cache[key] = res;
};
}
function createCompilerCreator(baseCompile2) {
return function createCompiler2(baseOptions2) {
function compile4(template2, options) {
var finalOptions = Object.create(baseOptions2);
var errors = [];
var tips = [];
var warn2 = function(msg, range2, tip) {
(tip ? tips : errors).push(msg);
};
if (options) {
if (options.modules) {
finalOptions.modules = (baseOptions2.modules || []).concat(options.modules);
}
if (options.directives) {
finalOptions.directives = extend$3(Object.create(baseOptions2.directives || null), options.directives);
}
for (var key in options) {
if (key !== "modules" && key !== "directives") {
finalOptions[key] = options[key];
}
}
}
finalOptions.warn = warn2;
var compiled = baseCompile2(template2.trim(), finalOptions);
compiled.errors = errors;
compiled.tips = tips;
return compiled;
}
return {
compile: compile4,
compileToFunctions: createCompileToFunctionFn(compile4)
};
};
}
var createCompiler = createCompilerCreator(function baseCompile(template2, options) {
var ast = parse$2(template2.trim(), options);
if (options.optimize !== false) {
optimize(ast, options);
}
var code = generate(ast, options);
return {
ast,
render: code.render,
staticRenderFns: code.staticRenderFns
};
});
var ref$1 = createCompiler(baseOptions);
var compileToFunctions = ref$1.compileToFunctions;
var div;
function getShouldDecode(href) {
div = div || document.createElement("div");
div.innerHTML = href ? '<a href="\n"/>' : '<div a="\n"/>';
return div.innerHTML.indexOf("&#10;") > 0;
}
var shouldDecodeNewlines = inBrowser$1 ? getShouldDecode(false) : false;
var shouldDecodeNewlinesForHref = inBrowser$1 ? getShouldDecode(true) : false;
var idToTemplate = cached(function(id) {
var el = query(id);
return el && el.innerHTML;
});
var mount = Vue.prototype.$mount;
Vue.prototype.$mount = function(el, hydrating) {
el = el && query(el);
if (el === document.body || el === document.documentElement) {
return this;
}
var options = this.$options;
if (!options.render) {
var template2 = options.template;
if (template2) {
if (typeof template2 === "string") {
if (template2.charAt(0) === "#") {
template2 = idToTemplate(template2);
}
} else if (template2.nodeType) {
template2 = template2.innerHTML;
} else {
return this;
}
} else if (el) {
template2 = getOuterHTML(el);
}
if (template2) {
var ref2 = compileToFunctions(template2, {
outputSourceRange: false,
shouldDecodeNewlines,
shouldDecodeNewlinesForHref,
delimiters: options.delimiters,
comments: options.comments
}, this);
var render6 = ref2.render;
var staticRenderFns = ref2.staticRenderFns;
options.render = render6;
options.staticRenderFns = staticRenderFns;
}
}
return mount.call(this, el, hydrating);
};
function getOuterHTML(el) {
if (el.outerHTML) {
return el.outerHTML;
} else {
var container = document.createElement("div");
container.appendChild(el.cloneNode(true));
return container.innerHTML;
}
}
Vue.compile = compileToFunctions;
/*!
* vue-router v3.5.1
* (c) 2021 Evan You
* @license MIT
*/
function extend$2(a, b) {
for (var key in b) {
a[key] = b[key];
}
return a;
}
var encodeReserveRE = /[!'()*]/g;
var encodeReserveReplacer = function(c) {
return "%" + c.charCodeAt(0).toString(16);
};
var commaRE = /%2C/g;
var encode$1 = function(str2) {
return encodeURIComponent(str2).replace(encodeReserveRE, encodeReserveReplacer).replace(commaRE, ",");
};
function decode$1(str2) {
try {
return decodeURIComponent(str2);
} catch (err2) {
}
return str2;
}
function resolveQuery(query2, extraQuery, _parseQuery) {
if (extraQuery === void 0)
extraQuery = {};
var parse4 = _parseQuery || parseQuery;
var parsedQuery;
try {
parsedQuery = parse4(query2 || "");
} catch (e) {
parsedQuery = {};
}
for (var key in extraQuery) {
var value = extraQuery[key];
parsedQuery[key] = Array.isArray(value) ? value.map(castQueryParamValue) : castQueryParamValue(value);
}
return parsedQuery;
}
var castQueryParamValue = function(value) {
return value == null || typeof value === "object" ? value : String(value);
};
function parseQuery(query2) {
var res = {};
query2 = query2.trim().replace(/^(\?|#|&)/, "");
if (!query2) {
return res;
}
query2.split("&").forEach(function(param) {
var parts = param.replace(/\+/g, " ").split("=");
var key = decode$1(parts.shift());
var val = parts.length > 0 ? decode$1(parts.join("=")) : null;
if (res[key] === void 0) {
res[key] = val;
} else if (Array.isArray(res[key])) {
res[key].push(val);
} else {
res[key] = [res[key], val];
}
});
return res;
}
function stringifyQuery(obj) {
var res = obj ? Object.keys(obj).map(function(key) {
var val = obj[key];
if (val === void 0) {
return "";
}
if (val === null) {
return encode$1(key);
}
if (Array.isArray(val)) {
var result2 = [];
val.forEach(function(val2) {
if (val2 === void 0) {
return;
}
if (val2 === null) {
result2.push(encode$1(key));
} else {
result2.push(encode$1(key) + "=" + encode$1(val2));
}
});
return result2.join("&");
}
return encode$1(key) + "=" + encode$1(val);
}).filter(function(x) {
return x.length > 0;
}).join("&") : null;
return res ? "?" + res : "";
}
var trailingSlashRE = /\/?$/;
function createRoute(record, location, redirectedFrom, router) {
var stringifyQuery2 = router && router.options.stringifyQuery;
var query2 = location.query || {};
try {
query2 = clone$2(query2);
} catch (e) {
}
var route = {
name: location.name || record && record.name,
meta: record && record.meta || {},
path: location.path || "/",
hash: location.hash || "",
query: query2,
params: location.params || {},
fullPath: getFullPath(location, stringifyQuery2),
matched: record ? formatMatch(record) : []
};
if (redirectedFrom) {
route.redirectedFrom = getFullPath(redirectedFrom, stringifyQuery2);
}
return Object.freeze(route);
}
function clone$2(value) {
if (Array.isArray(value)) {
return value.map(clone$2);
} else if (value && typeof value === "object") {
var res = {};
for (var key in value) {
res[key] = clone$2(value[key]);
}
return res;
} else {
return value;
}
}
var START = createRoute(null, {
path: "/"
});
function formatMatch(record) {
var res = [];
while (record) {
res.unshift(record);
record = record.parent;
}
return res;
}
function getFullPath(ref2, _stringifyQuery) {
var path = ref2.path;
var query2 = ref2.query;
if (query2 === void 0)
query2 = {};
var hash2 = ref2.hash;
if (hash2 === void 0)
hash2 = "";
var stringify3 = _stringifyQuery || stringifyQuery;
return (path || "/") + stringify3(query2) + hash2;
}
function isSameRoute(a, b, onlyPath) {
if (b === START) {
return a === b;
} else if (!b) {
return false;
} else if (a.path && b.path) {
return a.path.replace(trailingSlashRE, "") === b.path.replace(trailingSlashRE, "") && (onlyPath || a.hash === b.hash && isObjectEqual(a.query, b.query));
} else if (a.name && b.name) {
return a.name === b.name && (onlyPath || a.hash === b.hash && isObjectEqual(a.query, b.query) && isObjectEqual(a.params, b.params));
} else {
return false;
}
}
function isObjectEqual(a, b) {
if (a === void 0)
a = {};
if (b === void 0)
b = {};
if (!a || !b) {
return a === b;
}
var aKeys = Object.keys(a).sort();
var bKeys = Object.keys(b).sort();
if (aKeys.length !== bKeys.length) {
return false;
}
return aKeys.every(function(key, i) {
var aVal = a[key];
var bKey = bKeys[i];
if (bKey !== key) {
return false;
}
var bVal = b[key];
if (aVal == null || bVal == null) {
return aVal === bVal;
}
if (typeof aVal === "object" && typeof bVal === "object") {
return isObjectEqual(aVal, bVal);
}
return String(aVal) === String(bVal);
});
}
function isIncludedRoute(current, target2) {
return current.path.replace(trailingSlashRE, "/").indexOf(target2.path.replace(trailingSlashRE, "/")) === 0 && (!target2.hash || current.hash === target2.hash) && queryIncludes(current.query, target2.query);
}
function queryIncludes(current, target2) {
for (var key in target2) {
if (!(key in current)) {
return false;
}
}
return true;
}
function handleRouteEntered(route) {
for (var i = 0; i < route.matched.length; i++) {
var record = route.matched[i];
for (var name in record.instances) {
var instance = record.instances[name];
var cbs = record.enteredCbs[name];
if (!instance || !cbs) {
continue;
}
delete record.enteredCbs[name];
for (var i$1 = 0; i$1 < cbs.length; i$1++) {
if (!instance._isBeingDestroyed) {
cbs[i$1](instance);
}
}
}
}
}
var View = {
name: "RouterView",
functional: true,
props: {
name: {
type: String,
default: "default"
}
},
render: function render4(_2, ref2) {
var props2 = ref2.props;
var children = ref2.children;
var parent = ref2.parent;
var data = ref2.data;
data.routerView = true;
var h = parent.$createElement;
var name = props2.name;
var route = parent.$route;
var cache = parent._routerViewCache || (parent._routerViewCache = {});
var depth = 0;
var inactive = false;
while (parent && parent._routerRoot !== parent) {
var vnodeData = parent.$vnode ? parent.$vnode.data : {};
if (vnodeData.routerView) {
depth++;
}
if (vnodeData.keepAlive && parent._directInactive && parent._inactive) {
inactive = true;
}
parent = parent.$parent;
}
data.routerViewDepth = depth;
if (inactive) {
var cachedData = cache[name];
var cachedComponent = cachedData && cachedData.component;
if (cachedComponent) {
if (cachedData.configProps) {
fillPropsinData(cachedComponent, data, cachedData.route, cachedData.configProps);
}
return h(cachedComponent, data, children);
} else {
return h();
}
}
var matched = route.matched[depth];
var component = matched && matched.components[name];
if (!matched || !component) {
cache[name] = null;
return h();
}
cache[name] = {component};
data.registerRouteInstance = function(vm, val) {
var current = matched.instances[name];
if (val && current !== vm || !val && current === vm) {
matched.instances[name] = val;
}
};
(data.hook || (data.hook = {})).prepatch = function(_3, vnode) {
matched.instances[name] = vnode.componentInstance;
};
data.hook.init = function(vnode) {
if (vnode.data.keepAlive && vnode.componentInstance && vnode.componentInstance !== matched.instances[name]) {
matched.instances[name] = vnode.componentInstance;
}
handleRouteEntered(route);
};
var configProps = matched.props && matched.props[name];
if (configProps) {
extend$2(cache[name], {
route,
configProps
});
fillPropsinData(component, data, route, configProps);
}
return h(component, data, children);
}
};
function fillPropsinData(component, data, route, configProps) {
var propsToPass = data.props = resolveProps(route, configProps);
if (propsToPass) {
propsToPass = data.props = extend$2({}, propsToPass);
var attrs2 = data.attrs = data.attrs || {};
for (var key in propsToPass) {
if (!component.props || !(key in component.props)) {
attrs2[key] = propsToPass[key];
delete propsToPass[key];
}
}
}
}
function resolveProps(route, config2) {
switch (typeof config2) {
case "undefined":
return;
case "object":
return config2;
case "function":
return config2(route);
case "boolean":
return config2 ? route.params : void 0;
}
}
function resolvePath(relative, base2, append3) {
var firstChar = relative.charAt(0);
if (firstChar === "/") {
return relative;
}
if (firstChar === "?" || firstChar === "#") {
return base2 + relative;
}
var stack = base2.split("/");
if (!append3 || !stack[stack.length - 1]) {
stack.pop();
}
var segments = relative.replace(/^\//, "").split("/");
for (var i = 0; i < segments.length; i++) {
var segment = segments[i];
if (segment === "..") {
stack.pop();
} else if (segment !== ".") {
stack.push(segment);
}
}
if (stack[0] !== "") {
stack.unshift("");
}
return stack.join("/");
}
function parsePath(path) {
var hash2 = "";
var query2 = "";
var hashIndex = path.indexOf("#");
if (hashIndex >= 0) {
hash2 = path.slice(hashIndex);
path = path.slice(0, hashIndex);
}
var queryIndex = path.indexOf("?");
if (queryIndex >= 0) {
query2 = path.slice(queryIndex + 1);
path = path.slice(0, queryIndex);
}
return {
path,
query: query2,
hash: hash2
};
}
function cleanPath(path) {
return path.replace(/\/\//g, "/");
}
var isarray = Array.isArray || function(arr) {
return Object.prototype.toString.call(arr) == "[object Array]";
};
var pathToRegexp_1 = pathToRegexp;
var parse_1 = parse$1;
var compile_1 = compile;
var tokensToFunction_1 = tokensToFunction;
var tokensToRegExp_1 = tokensToRegExp;
var PATH_REGEXP = new RegExp([
"(\\\\.)",
"([\\/.])?(?:(?:\\:(\\w+)(?:\\(((?:\\\\.|[^\\\\()])+)\\))?|\\(((?:\\\\.|[^\\\\()])+)\\))([+*?])?|(\\*))"
].join("|"), "g");
function parse$1(str2, options) {
var tokens = [];
var key = 0;
var index3 = 0;
var path = "";
var defaultDelimiter = options && options.delimiter || "/";
var res;
while ((res = PATH_REGEXP.exec(str2)) != null) {
var m = res[0];
var escaped = res[1];
var offset2 = res.index;
path += str2.slice(index3, offset2);
index3 = offset2 + m.length;
if (escaped) {
path += escaped[1];
continue;
}
var next2 = str2[index3];
var prefix = res[2];
var name = res[3];
var capture = res[4];
var group2 = res[5];
var modifier = res[6];
var asterisk = res[7];
if (path) {
tokens.push(path);
path = "";
}
var partial2 = prefix != null && next2 != null && next2 !== prefix;
var repeat2 = modifier === "+" || modifier === "*";
var optional = modifier === "?" || modifier === "*";
var delimiter = res[2] || defaultDelimiter;
var pattern = capture || group2;
tokens.push({
name: name || key++,
prefix: prefix || "",
delimiter,
optional,
repeat: repeat2,
partial: partial2,
asterisk: !!asterisk,
pattern: pattern ? escapeGroup(pattern) : asterisk ? ".*" : "[^" + escapeString(delimiter) + "]+?"
});
}
if (index3 < str2.length) {
path += str2.substr(index3);
}
if (path) {
tokens.push(path);
}
return tokens;
}
function compile(str2, options) {
return tokensToFunction(parse$1(str2, options), options);
}
function encodeURIComponentPretty(str2) {
return encodeURI(str2).replace(/[\/?#]/g, function(c) {
return "%" + c.charCodeAt(0).toString(16).toUpperCase();
});
}
function encodeAsterisk(str2) {
return encodeURI(str2).replace(/[?#]/g, function(c) {
return "%" + c.charCodeAt(0).toString(16).toUpperCase();
});
}
function tokensToFunction(tokens, options) {
var matches2 = new Array(tokens.length);
for (var i = 0; i < tokens.length; i++) {
if (typeof tokens[i] === "object") {
matches2[i] = new RegExp("^(?:" + tokens[i].pattern + ")$", flags(options));
}
}
return function(obj, opts) {
var path = "";
var data = obj || {};
var options2 = opts || {};
var encode3 = options2.pretty ? encodeURIComponentPretty : encodeURIComponent;
for (var i2 = 0; i2 < tokens.length; i2++) {
var token = tokens[i2];
if (typeof token === "string") {
path += token;
continue;
}
var value = data[token.name];
var segment;
if (value == null) {
if (token.optional) {
if (token.partial) {
path += token.prefix;
}
continue;
} else {
throw new TypeError('Expected "' + token.name + '" to be defined');
}
}
if (isarray(value)) {
if (!token.repeat) {
throw new TypeError('Expected "' + token.name + '" to not repeat, but received `' + JSON.stringify(value) + "`");
}
if (value.length === 0) {
if (token.optional) {
continue;
} else {
throw new TypeError('Expected "' + token.name + '" to not be empty');
}
}
for (var j = 0; j < value.length; j++) {
segment = encode3(value[j]);
if (!matches2[i2].test(segment)) {
throw new TypeError('Expected all "' + token.name + '" to match "' + token.pattern + '", but received `' + JSON.stringify(segment) + "`");
}
path += (j === 0 ? token.prefix : token.delimiter) + segment;
}
continue;
}
segment = token.asterisk ? encodeAsterisk(value) : encode3(value);
if (!matches2[i2].test(segment)) {
throw new TypeError('Expected "' + token.name + '" to match "' + token.pattern + '", but received "' + segment + '"');
}
path += token.prefix + segment;
}
return path;
};
}
function escapeString(str2) {
return str2.replace(/([.+*?=^!:${}()[\]|\/\\])/g, "\\$1");
}
function escapeGroup(group2) {
return group2.replace(/([=!:$\/()])/g, "\\$1");
}
function attachKeys(re, keys2) {
re.keys = keys2;
return re;
}
function flags(options) {
return options && options.sensitive ? "" : "i";
}
function regexpToRegexp(path, keys2) {
var groups = path.source.match(/\((?!\?)/g);
if (groups) {
for (var i = 0; i < groups.length; i++) {
keys2.push({
name: i,
prefix: null,
delimiter: null,
optional: false,
repeat: false,
partial: false,
asterisk: false,
pattern: null
});
}
}
return attachKeys(path, keys2);
}
function arrayToRegexp(path, keys2, options) {
var parts = [];
for (var i = 0; i < path.length; i++) {
parts.push(pathToRegexp(path[i], keys2, options).source);
}
var regexp = new RegExp("(?:" + parts.join("|") + ")", flags(options));
return attachKeys(regexp, keys2);
}
function stringToRegexp(path, keys2, options) {
return tokensToRegExp(parse$1(path, options), keys2, options);
}
function tokensToRegExp(tokens, keys2, options) {
if (!isarray(keys2)) {
options = keys2 || options;
keys2 = [];
}
options = options || {};
var strict = options.strict;
var end2 = options.end !== false;
var route = "";
for (var i = 0; i < tokens.length; i++) {
var token = tokens[i];
if (typeof token === "string") {
route += escapeString(token);
} else {
var prefix = escapeString(token.prefix);
var capture = "(?:" + token.pattern + ")";
keys2.push(token);
if (token.repeat) {
capture += "(?:" + prefix + capture + ")*";
}
if (token.optional) {
if (!token.partial) {
capture = "(?:" + prefix + "(" + capture + "))?";
} else {
capture = prefix + "(" + capture + ")?";
}
} else {
capture = prefix + "(" + capture + ")";
}
route += capture;
}
}
var delimiter = escapeString(options.delimiter || "/");
var endsWithDelimiter = route.slice(-delimiter.length) === delimiter;
if (!strict) {
route = (endsWithDelimiter ? route.slice(0, -delimiter.length) : route) + "(?:" + delimiter + "(?=$))?";
}
if (end2) {
route += "$";
} else {
route += strict && endsWithDelimiter ? "" : "(?=" + delimiter + "|$)";
}
return attachKeys(new RegExp("^" + route, flags(options)), keys2);
}
function pathToRegexp(path, keys2, options) {
if (!isarray(keys2)) {
options = keys2 || options;
keys2 = [];
}
options = options || {};
if (path instanceof RegExp) {
return regexpToRegexp(path, keys2);
}
if (isarray(path)) {
return arrayToRegexp(path, keys2, options);
}
return stringToRegexp(path, keys2, options);
}
pathToRegexp_1.parse = parse_1;
pathToRegexp_1.compile = compile_1;
pathToRegexp_1.tokensToFunction = tokensToFunction_1;
pathToRegexp_1.tokensToRegExp = tokensToRegExp_1;
var regexpCompileCache = Object.create(null);
function fillParams(path, params, routeMsg) {
params = params || {};
try {
var filler = regexpCompileCache[path] || (regexpCompileCache[path] = pathToRegexp_1.compile(path));
if (typeof params.pathMatch === "string") {
params[0] = params.pathMatch;
}
return filler(params, {pretty: true});
} catch (e) {
return "";
} finally {
delete params[0];
}
}
function normalizeLocation(raw, current, append3, router) {
var next2 = typeof raw === "string" ? {path: raw} : raw;
if (next2._normalized) {
return next2;
} else if (next2.name) {
next2 = extend$2({}, raw);
var params = next2.params;
if (params && typeof params === "object") {
next2.params = extend$2({}, params);
}
return next2;
}
if (!next2.path && next2.params && current) {
next2 = extend$2({}, next2);
next2._normalized = true;
var params$1 = extend$2(extend$2({}, current.params), next2.params);
if (current.name) {
next2.name = current.name;
next2.params = params$1;
} else if (current.matched.length) {
var rawPath = current.matched[current.matched.length - 1].path;
next2.path = fillParams(rawPath, params$1, "path " + current.path);
} else
;
return next2;
}
var parsedPath = parsePath(next2.path || "");
var basePath = current && current.path || "/";
var path = parsedPath.path ? resolvePath(parsedPath.path, basePath, append3 || next2.append) : basePath;
var query2 = resolveQuery(parsedPath.query, next2.query, router && router.options.parseQuery);
var hash2 = next2.hash || parsedPath.hash;
if (hash2 && hash2.charAt(0) !== "#") {
hash2 = "#" + hash2;
}
return {
_normalized: true,
path,
query: query2,
hash: hash2
};
}
var toTypes = [String, Object];
var eventTypes = [String, Array];
var noop$2 = function() {
};
var Link$1 = {
name: "RouterLink",
props: {
to: {
type: toTypes,
required: true
},
tag: {
type: String,
default: "a"
},
custom: Boolean,
exact: Boolean,
exactPath: Boolean,
append: Boolean,
replace: Boolean,
activeClass: String,
exactActiveClass: String,
ariaCurrentValue: {
type: String,
default: "page"
},
event: {
type: eventTypes,
default: "click"
}
},
render: function render5(h) {
var this$1 = this;
var router = this.$router;
var current = this.$route;
var ref2 = router.resolve(this.to, current, this.append);
var location = ref2.location;
var route = ref2.route;
var href = ref2.href;
var classes = {};
var globalActiveClass = router.options.linkActiveClass;
var globalExactActiveClass = router.options.linkExactActiveClass;
var activeClassFallback = globalActiveClass == null ? "router-link-active" : globalActiveClass;
var exactActiveClassFallback = globalExactActiveClass == null ? "router-link-exact-active" : globalExactActiveClass;
var activeClass = this.activeClass == null ? activeClassFallback : this.activeClass;
var exactActiveClass = this.exactActiveClass == null ? exactActiveClassFallback : this.exactActiveClass;
var compareTarget = route.redirectedFrom ? createRoute(null, normalizeLocation(route.redirectedFrom), null, router) : route;
classes[exactActiveClass] = isSameRoute(current, compareTarget, this.exactPath);
classes[activeClass] = this.exact || this.exactPath ? classes[exactActiveClass] : isIncludedRoute(current, compareTarget);
var ariaCurrentValue = classes[exactActiveClass] ? this.ariaCurrentValue : null;
var handler = function(e) {
if (guardEvent(e)) {
if (this$1.replace) {
router.replace(location, noop$2);
} else {
router.push(location, noop$2);
}
}
};
var on2 = {click: guardEvent};
if (Array.isArray(this.event)) {
this.event.forEach(function(e) {
on2[e] = handler;
});
} else {
on2[this.event] = handler;
}
var data = {class: classes};
var scopedSlot = !this.$scopedSlots.$hasNormal && this.$scopedSlots.default && this.$scopedSlots.default({
href,
route,
navigate: handler,
isActive: classes[activeClass],
isExactActive: classes[exactActiveClass]
});
if (scopedSlot) {
if (scopedSlot.length === 1) {
return scopedSlot[0];
} else if (scopedSlot.length > 1 || !scopedSlot.length) {
return scopedSlot.length === 0 ? h() : h("span", {}, scopedSlot);
}
}
if (this.tag === "a") {
data.on = on2;
data.attrs = {href, "aria-current": ariaCurrentValue};
} else {
var a = findAnchor(this.$slots.default);
if (a) {
a.isStatic = false;
var aData = a.data = extend$2({}, a.data);
aData.on = aData.on || {};
for (var event in aData.on) {
var handler$1 = aData.on[event];
if (event in on2) {
aData.on[event] = Array.isArray(handler$1) ? handler$1 : [handler$1];
}
}
for (var event$1 in on2) {
if (event$1 in aData.on) {
aData.on[event$1].push(on2[event$1]);
} else {
aData.on[event$1] = handler;
}
}
var aAttrs = a.data.attrs = extend$2({}, a.data.attrs);
aAttrs.href = href;
aAttrs["aria-current"] = ariaCurrentValue;
} else {
data.on = on2;
}
}
return h(this.tag, data, this.$slots.default);
}
};
function guardEvent(e) {
if (e.metaKey || e.altKey || e.ctrlKey || e.shiftKey) {
return;
}
if (e.defaultPrevented) {
return;
}
if (e.button !== void 0 && e.button !== 0) {
return;
}
if (e.currentTarget && e.currentTarget.getAttribute) {
var target2 = e.currentTarget.getAttribute("target");
if (/\b_blank\b/i.test(target2)) {
return;
}
}
if (e.preventDefault) {
e.preventDefault();
}
return true;
}
function findAnchor(children) {
if (children) {
var child3;
for (var i = 0; i < children.length; i++) {
child3 = children[i];
if (child3.tag === "a") {
return child3;
}
if (child3.children && (child3 = findAnchor(child3.children))) {
return child3;
}
}
}
}
var _Vue;
function install(Vue2) {
if (install.installed && _Vue === Vue2) {
return;
}
install.installed = true;
_Vue = Vue2;
var isDef2 = function(v) {
return v !== void 0;
};
var registerInstance = function(vm, callVal) {
var i = vm.$options._parentVnode;
if (isDef2(i) && isDef2(i = i.data) && isDef2(i = i.registerRouteInstance)) {
i(vm, callVal);
}
};
Vue2.mixin({
beforeCreate: function beforeCreate() {
if (isDef2(this.$options.router)) {
this._routerRoot = this;
this._router = this.$options.router;
this._router.init(this);
Vue2.util.defineReactive(this, "_route", this._router.history.current);
} else {
this._routerRoot = this.$parent && this.$parent._routerRoot || this;
}
registerInstance(this, this);
},
destroyed: function destroyed2() {
registerInstance(this);
}
});
Object.defineProperty(Vue2.prototype, "$router", {
get: function get7() {
return this._routerRoot._router;
}
});
Object.defineProperty(Vue2.prototype, "$route", {
get: function get7() {
return this._routerRoot._route;
}
});
Vue2.component("RouterView", View);
Vue2.component("RouterLink", Link$1);
var strats2 = Vue2.config.optionMergeStrategies;
strats2.beforeRouteEnter = strats2.beforeRouteLeave = strats2.beforeRouteUpdate = strats2.created;
}
var inBrowser = typeof window !== "undefined";
function createRouteMap(routes, oldPathList, oldPathMap, oldNameMap, parentRoute) {
var pathList = oldPathList || [];
var pathMap = oldPathMap || Object.create(null);
var nameMap = oldNameMap || Object.create(null);
routes.forEach(function(route) {
addRouteRecord(pathList, pathMap, nameMap, route, parentRoute);
});
for (var i = 0, l = pathList.length; i < l; i++) {
if (pathList[i] === "*") {
pathList.push(pathList.splice(i, 1)[0]);
l--;
i--;
}
}
return {
pathList,
pathMap,
nameMap
};
}
function addRouteRecord(pathList, pathMap, nameMap, route, parent, matchAs) {
var path = route.path;
var name = route.name;
var pathToRegexpOptions = route.pathToRegexpOptions || {};
var normalizedPath = normalizePath(path, parent, pathToRegexpOptions.strict);
if (typeof route.caseSensitive === "boolean") {
pathToRegexpOptions.sensitive = route.caseSensitive;
}
var record = {
path: normalizedPath,
regex: compileRouteRegex(normalizedPath, pathToRegexpOptions),
components: route.components || {default: route.component},
alias: route.alias ? typeof route.alias === "string" ? [route.alias] : route.alias : [],
instances: {},
enteredCbs: {},
name,
parent,
matchAs,
redirect: route.redirect,
beforeEnter: route.beforeEnter,
meta: route.meta || {},
props: route.props == null ? {} : route.components ? route.props : {default: route.props}
};
if (route.children) {
route.children.forEach(function(child3) {
var childMatchAs = matchAs ? cleanPath(matchAs + "/" + child3.path) : void 0;
addRouteRecord(pathList, pathMap, nameMap, child3, record, childMatchAs);
});
}
if (!pathMap[record.path]) {
pathList.push(record.path);
pathMap[record.path] = record;
}
if (route.alias !== void 0) {
var aliases = Array.isArray(route.alias) ? route.alias : [route.alias];
for (var i = 0; i < aliases.length; ++i) {
var alias = aliases[i];
var aliasRoute = {
path: alias,
children: route.children
};
addRouteRecord(pathList, pathMap, nameMap, aliasRoute, parent, record.path || "/");
}
}
if (name) {
if (!nameMap[name]) {
nameMap[name] = record;
}
}
}
function compileRouteRegex(path, pathToRegexpOptions) {
var regex = pathToRegexp_1(path, [], pathToRegexpOptions);
return regex;
}
function normalizePath(path, parent, strict) {
if (!strict) {
path = path.replace(/\/$/, "");
}
if (path[0] === "/") {
return path;
}
if (parent == null) {
return path;
}
return cleanPath(parent.path + "/" + path);
}
function createMatcher(routes, router) {
var ref2 = createRouteMap(routes);
var pathList = ref2.pathList;
var pathMap = ref2.pathMap;
var nameMap = ref2.nameMap;
function addRoutes2(routes2) {
createRouteMap(routes2, pathList, pathMap, nameMap);
}
function addRoute2(parentOrRoute, route) {
var parent = typeof parentOrRoute !== "object" ? nameMap[parentOrRoute] : void 0;
createRouteMap([route || parentOrRoute], pathList, pathMap, nameMap, parent);
if (parent) {
createRouteMap(parent.alias.map(function(alias2) {
return {path: alias2, children: [route]};
}), pathList, pathMap, nameMap, parent);
}
}
function getRoutes2() {
return pathList.map(function(path) {
return pathMap[path];
});
}
function match3(raw, currentRoute, redirectedFrom) {
var location = normalizeLocation(raw, currentRoute, false, router);
var name = location.name;
if (name) {
var record = nameMap[name];
if (!record) {
return _createRoute(null, location);
}
var paramNames = record.regex.keys.filter(function(key2) {
return !key2.optional;
}).map(function(key2) {
return key2.name;
});
if (typeof location.params !== "object") {
location.params = {};
}
if (currentRoute && typeof currentRoute.params === "object") {
for (var key in currentRoute.params) {
if (!(key in location.params) && paramNames.indexOf(key) > -1) {
location.params[key] = currentRoute.params[key];
}
}
}
location.path = fillParams(record.path, location.params);
return _createRoute(record, location, redirectedFrom);
} else if (location.path) {
location.params = {};
for (var i = 0; i < pathList.length; i++) {
var path = pathList[i];
var record$1 = pathMap[path];
if (matchRoute(record$1.regex, location.path, location.params)) {
return _createRoute(record$1, location, redirectedFrom);
}
}
}
return _createRoute(null, location);
}
function redirect(record, location) {
var originalRedirect = record.redirect;
var redirect2 = typeof originalRedirect === "function" ? originalRedirect(createRoute(record, location, null, router)) : originalRedirect;
if (typeof redirect2 === "string") {
redirect2 = {path: redirect2};
}
if (!redirect2 || typeof redirect2 !== "object") {
return _createRoute(null, location);
}
var re = redirect2;
var name = re.name;
var path = re.path;
var query2 = location.query;
var hash2 = location.hash;
var params = location.params;
query2 = re.hasOwnProperty("query") ? re.query : query2;
hash2 = re.hasOwnProperty("hash") ? re.hash : hash2;
params = re.hasOwnProperty("params") ? re.params : params;
if (name) {
nameMap[name];
return match3({
_normalized: true,
name,
query: query2,
hash: hash2,
params
}, void 0, location);
} else if (path) {
var rawPath = resolveRecordPath(path, record);
var resolvedPath = fillParams(rawPath, params);
return match3({
_normalized: true,
path: resolvedPath,
query: query2,
hash: hash2
}, void 0, location);
} else {
return _createRoute(null, location);
}
}
function alias(record, location, matchAs) {
var aliasedPath = fillParams(matchAs, location.params);
var aliasedMatch = match3({
_normalized: true,
path: aliasedPath
});
if (aliasedMatch) {
var matched = aliasedMatch.matched;
var aliasedRecord = matched[matched.length - 1];
location.params = aliasedMatch.params;
return _createRoute(aliasedRecord, location);
}
return _createRoute(null, location);
}
function _createRoute(record, location, redirectedFrom) {
if (record && record.redirect) {
return redirect(record, redirectedFrom || location);
}
if (record && record.matchAs) {
return alias(record, location, record.matchAs);
}
return createRoute(record, location, redirectedFrom, router);
}
return {
match: match3,
addRoute: addRoute2,
getRoutes: getRoutes2,
addRoutes: addRoutes2
};
}
function matchRoute(regex, path, params) {
var m = path.match(regex);
if (!m) {
return false;
} else if (!params) {
return true;
}
for (var i = 1, len2 = m.length; i < len2; ++i) {
var key = regex.keys[i - 1];
if (key) {
params[key.name || "pathMatch"] = typeof m[i] === "string" ? decode$1(m[i]) : m[i];
}
}
return true;
}
function resolveRecordPath(path, record) {
return resolvePath(path, record.parent ? record.parent.path : "/", true);
}
var Time = inBrowser && window.performance && window.performance.now ? window.performance : Date;
function genStateKey() {
return Time.now().toFixed(3);
}
var _key = genStateKey();
function getStateKey() {
return _key;
}
function setStateKey(key) {
return _key = key;
}
var positionStore = Object.create(null);
function setupScroll() {
if ("scrollRestoration" in window.history) {
window.history.scrollRestoration = "manual";
}
var protocolAndPath = window.location.protocol + "//" + window.location.host;
var absolutePath = window.location.href.replace(protocolAndPath, "");
var stateCopy = extend$2({}, window.history.state);
stateCopy.key = getStateKey();
window.history.replaceState(stateCopy, "", absolutePath);
window.addEventListener("popstate", handlePopState);
return function() {
window.removeEventListener("popstate", handlePopState);
};
}
function handleScroll(router, to, from4, isPop) {
if (!router.app) {
return;
}
var behavior = router.options.scrollBehavior;
if (!behavior) {
return;
}
router.app.$nextTick(function() {
var position = getScrollPosition();
var shouldScroll = behavior.call(router, to, from4, isPop ? position : null);
if (!shouldScroll) {
return;
}
if (typeof shouldScroll.then === "function") {
shouldScroll.then(function(shouldScroll2) {
scrollToPosition(shouldScroll2, position);
}).catch(function(err2) {
});
} else {
scrollToPosition(shouldScroll, position);
}
});
}
function saveScrollPosition() {
var key = getStateKey();
if (key) {
positionStore[key] = {
x: window.pageXOffset,
y: window.pageYOffset
};
}
}
function handlePopState(e) {
saveScrollPosition();
if (e.state && e.state.key) {
setStateKey(e.state.key);
}
}
function getScrollPosition() {
var key = getStateKey();
if (key) {
return positionStore[key];
}
}
function getElementPosition(el, offset2) {
var docEl = document.documentElement;
var docRect = docEl.getBoundingClientRect();
var elRect = el.getBoundingClientRect();
return {
x: elRect.left - docRect.left - offset2.x,
y: elRect.top - docRect.top - offset2.y
};
}
function isValidPosition(obj) {
return isNumber$2(obj.x) || isNumber$2(obj.y);
}
function normalizePosition(obj) {
return {
x: isNumber$2(obj.x) ? obj.x : window.pageXOffset,
y: isNumber$2(obj.y) ? obj.y : window.pageYOffset
};
}
function normalizeOffset(obj) {
return {
x: isNumber$2(obj.x) ? obj.x : 0,
y: isNumber$2(obj.y) ? obj.y : 0
};
}
function isNumber$2(v) {
return typeof v === "number";
}
var hashStartsWithNumberRE = /^#\d/;
function scrollToPosition(shouldScroll, position) {
var isObject2 = typeof shouldScroll === "object";
if (isObject2 && typeof shouldScroll.selector === "string") {
var el = hashStartsWithNumberRE.test(shouldScroll.selector) ? document.getElementById(shouldScroll.selector.slice(1)) : document.querySelector(shouldScroll.selector);
if (el) {
var offset2 = shouldScroll.offset && typeof shouldScroll.offset === "object" ? shouldScroll.offset : {};
offset2 = normalizeOffset(offset2);
position = getElementPosition(el, offset2);
} else if (isValidPosition(shouldScroll)) {
position = normalizePosition(shouldScroll);
}
} else if (isObject2 && isValidPosition(shouldScroll)) {
position = normalizePosition(shouldScroll);
}
if (position) {
if ("scrollBehavior" in document.documentElement.style) {
window.scrollTo({
left: position.x,
top: position.y,
behavior: shouldScroll.behavior
});
} else {
window.scrollTo(position.x, position.y);
}
}
}
var supportsPushState = inBrowser && function() {
var ua = window.navigator.userAgent;
if ((ua.indexOf("Android 2.") !== -1 || ua.indexOf("Android 4.0") !== -1) && ua.indexOf("Mobile Safari") !== -1 && ua.indexOf("Chrome") === -1 && ua.indexOf("Windows Phone") === -1) {
return false;
}
return window.history && typeof window.history.pushState === "function";
}();
function pushState(url, replace4) {
saveScrollPosition();
var history2 = window.history;
try {
if (replace4) {
var stateCopy = extend$2({}, history2.state);
stateCopy.key = getStateKey();
history2.replaceState(stateCopy, "", url);
} else {
history2.pushState({key: setStateKey(genStateKey())}, "", url);
}
} catch (e) {
window.location[replace4 ? "replace" : "assign"](url);
}
}
function replaceState(url) {
pushState(url, true);
}
function runQueue(queue2, fn, cb2) {
var step2 = function(index3) {
if (index3 >= queue2.length) {
cb2();
} else {
if (queue2[index3]) {
fn(queue2[index3], function() {
step2(index3 + 1);
});
} else {
step2(index3 + 1);
}
}
};
step2(0);
}
var NavigationFailureType = {
redirected: 2,
aborted: 4,
cancelled: 8,
duplicated: 16
};
function createNavigationRedirectedError(from4, to) {
return createRouterError(from4, to, NavigationFailureType.redirected, 'Redirected when going from "' + from4.fullPath + '" to "' + stringifyRoute(to) + '" via a navigation guard.');
}
function createNavigationDuplicatedError(from4, to) {
var error2 = createRouterError(from4, to, NavigationFailureType.duplicated, 'Avoided redundant navigation to current location: "' + from4.fullPath + '".');
error2.name = "NavigationDuplicated";
return error2;
}
function createNavigationCancelledError(from4, to) {
return createRouterError(from4, to, NavigationFailureType.cancelled, 'Navigation cancelled from "' + from4.fullPath + '" to "' + to.fullPath + '" with a new navigation.');
}
function createNavigationAbortedError(from4, to) {
return createRouterError(from4, to, NavigationFailureType.aborted, 'Navigation aborted from "' + from4.fullPath + '" to "' + to.fullPath + '" via a navigation guard.');
}
function createRouterError(from4, to, type, message) {
var error2 = new Error(message);
error2._isRouter = true;
error2.from = from4;
error2.to = to;
error2.type = type;
return error2;
}
var propertiesToLog = ["params", "query", "hash"];
function stringifyRoute(to) {
if (typeof to === "string") {
return to;
}
if ("path" in to) {
return to.path;
}
var location = {};
propertiesToLog.forEach(function(key) {
if (key in to) {
location[key] = to[key];
}
});
return JSON.stringify(location, null, 2);
}
function isError$2(err2) {
return Object.prototype.toString.call(err2).indexOf("Error") > -1;
}
function isNavigationFailure(err2, errorType) {
return isError$2(err2) && err2._isRouter && (errorType == null || err2.type === errorType);
}
function resolveAsyncComponents(matched) {
return function(to, from4, next2) {
var hasAsync = false;
var pending2 = 0;
var error2 = null;
flatMapComponents(matched, function(def2, _2, match3, key) {
if (typeof def2 === "function" && def2.cid === void 0) {
hasAsync = true;
pending2++;
var resolve9 = once$1(function(resolvedDef) {
if (isESModule(resolvedDef)) {
resolvedDef = resolvedDef.default;
}
def2.resolved = typeof resolvedDef === "function" ? resolvedDef : _Vue.extend(resolvedDef);
match3.components[key] = resolvedDef;
pending2--;
if (pending2 <= 0) {
next2();
}
});
var reject2 = once$1(function(reason) {
var msg = "Failed to resolve async component " + key + ": " + reason;
if (!error2) {
error2 = isError$2(reason) ? reason : new Error(msg);
next2(error2);
}
});
var res;
try {
res = def2(resolve9, reject2);
} catch (e) {
reject2(e);
}
if (res) {
if (typeof res.then === "function") {
res.then(resolve9, reject2);
} else {
var comp = res.component;
if (comp && typeof comp.then === "function") {
comp.then(resolve9, reject2);
}
}
}
}
});
if (!hasAsync) {
next2();
}
};
}
function flatMapComponents(matched, fn) {
return flatten$2(matched.map(function(m) {
return Object.keys(m.components).map(function(key) {
return fn(m.components[key], m.instances[key], m, key);
});
}));
}
function flatten$2(arr) {
return Array.prototype.concat.apply([], arr);
}
var hasSymbol = typeof Symbol === "function" && typeof Symbol.toStringTag === "symbol";
function isESModule(obj) {
return obj.__esModule || hasSymbol && obj[Symbol.toStringTag] === "Module";
}
function once$1(fn) {
var called = false;
return function() {
var args = [], len2 = arguments.length;
while (len2--)
args[len2] = arguments[len2];
if (called) {
return;
}
called = true;
return fn.apply(this, args);
};
}
var History$1 = function History(router, base2) {
this.router = router;
this.base = normalizeBase(base2);
this.current = START;
this.pending = null;
this.ready = false;
this.readyCbs = [];
this.readyErrorCbs = [];
this.errorCbs = [];
this.listeners = [];
};
History$1.prototype.listen = function listen(cb2) {
this.cb = cb2;
};
History$1.prototype.onReady = function onReady(cb2, errorCb) {
if (this.ready) {
cb2();
} else {
this.readyCbs.push(cb2);
if (errorCb) {
this.readyErrorCbs.push(errorCb);
}
}
};
History$1.prototype.onError = function onError(errorCb) {
this.errorCbs.push(errorCb);
};
History$1.prototype.transitionTo = function transitionTo(location, onComplete, onAbort) {
var this$1 = this;
var route;
try {
route = this.router.match(location, this.current);
} catch (e) {
this.errorCbs.forEach(function(cb2) {
cb2(e);
});
throw e;
}
var prev = this.current;
this.confirmTransition(route, function() {
this$1.updateRoute(route);
onComplete && onComplete(route);
this$1.ensureURL();
this$1.router.afterHooks.forEach(function(hook) {
hook && hook(route, prev);
});
if (!this$1.ready) {
this$1.ready = true;
this$1.readyCbs.forEach(function(cb2) {
cb2(route);
});
}
}, function(err2) {
if (onAbort) {
onAbort(err2);
}
if (err2 && !this$1.ready) {
if (!isNavigationFailure(err2, NavigationFailureType.redirected) || prev !== START) {
this$1.ready = true;
this$1.readyErrorCbs.forEach(function(cb2) {
cb2(err2);
});
}
}
});
};
History$1.prototype.confirmTransition = function confirmTransition(route, onComplete, onAbort) {
var this$1 = this;
var current = this.current;
this.pending = route;
var abort = function(err2) {
if (!isNavigationFailure(err2) && isError$2(err2)) {
if (this$1.errorCbs.length) {
this$1.errorCbs.forEach(function(cb2) {
cb2(err2);
});
} else {
console.error(err2);
}
}
onAbort && onAbort(err2);
};
var lastRouteIndex = route.matched.length - 1;
var lastCurrentIndex = current.matched.length - 1;
if (isSameRoute(route, current) && lastRouteIndex === lastCurrentIndex && route.matched[lastRouteIndex] === current.matched[lastCurrentIndex]) {
this.ensureURL();
return abort(createNavigationDuplicatedError(current, route));
}
var ref2 = resolveQueue(this.current.matched, route.matched);
var updated2 = ref2.updated;
var deactivated = ref2.deactivated;
var activated = ref2.activated;
var queue2 = [].concat(extractLeaveGuards(deactivated), this.router.beforeHooks, extractUpdateHooks(updated2), activated.map(function(m) {
return m.beforeEnter;
}), resolveAsyncComponents(activated));
var iterator = function(hook, next2) {
if (this$1.pending !== route) {
return abort(createNavigationCancelledError(current, route));
}
try {
hook(route, current, function(to) {
if (to === false) {
this$1.ensureURL(true);
abort(createNavigationAbortedError(current, route));
} else if (isError$2(to)) {
this$1.ensureURL(true);
abort(to);
} else if (typeof to === "string" || typeof to === "object" && (typeof to.path === "string" || typeof to.name === "string")) {
abort(createNavigationRedirectedError(current, route));
if (typeof to === "object" && to.replace) {
this$1.replace(to);
} else {
this$1.push(to);
}
} else {
next2(to);
}
});
} catch (e) {
abort(e);
}
};
runQueue(queue2, iterator, function() {
var enterGuards = extractEnterGuards(activated);
var queue3 = enterGuards.concat(this$1.router.resolveHooks);
runQueue(queue3, iterator, function() {
if (this$1.pending !== route) {
return abort(createNavigationCancelledError(current, route));
}
this$1.pending = null;
onComplete(route);
if (this$1.router.app) {
this$1.router.app.$nextTick(function() {
handleRouteEntered(route);
});
}
});
});
};
History$1.prototype.updateRoute = function updateRoute(route) {
this.current = route;
this.cb && this.cb(route);
};
History$1.prototype.setupListeners = function setupListeners() {
};
History$1.prototype.teardown = function teardown2() {
this.listeners.forEach(function(cleanupListener) {
cleanupListener();
});
this.listeners = [];
this.current = START;
this.pending = null;
};
function normalizeBase(base2) {
if (!base2) {
if (inBrowser) {
var baseEl = document.querySelector("base");
base2 = baseEl && baseEl.getAttribute("href") || "/";
base2 = base2.replace(/^https?:\/\/[^\/]+/, "");
} else {
base2 = "/";
}
}
if (base2.charAt(0) !== "/") {
base2 = "/" + base2;
}
return base2.replace(/\/$/, "");
}
function resolveQueue(current, next2) {
var i;
var max3 = Math.max(current.length, next2.length);
for (i = 0; i < max3; i++) {
if (current[i] !== next2[i]) {
break;
}
}
return {
updated: next2.slice(0, i),
activated: next2.slice(i),
deactivated: current.slice(i)
};
}
function extractGuards(records, name, bind4, reverse) {
var guards = flatMapComponents(records, function(def2, instance, match3, key) {
var guard = extractGuard(def2, name);
if (guard) {
return Array.isArray(guard) ? guard.map(function(guard2) {
return bind4(guard2, instance, match3, key);
}) : bind4(guard, instance, match3, key);
}
});
return flatten$2(reverse ? guards.reverse() : guards);
}
function extractGuard(def2, key) {
if (typeof def2 !== "function") {
def2 = _Vue.extend(def2);
}
return def2.options[key];
}
function extractLeaveGuards(deactivated) {
return extractGuards(deactivated, "beforeRouteLeave", bindGuard, true);
}
function extractUpdateHooks(updated2) {
return extractGuards(updated2, "beforeRouteUpdate", bindGuard);
}
function bindGuard(guard, instance) {
if (instance) {
return function boundRouteGuard() {
return guard.apply(instance, arguments);
};
}
}
function extractEnterGuards(activated) {
return extractGuards(activated, "beforeRouteEnter", function(guard, _2, match3, key) {
return bindEnterGuard(guard, match3, key);
});
}
function bindEnterGuard(guard, match3, key) {
return function routeEnterGuard(to, from4, next2) {
return guard(to, from4, function(cb2) {
if (typeof cb2 === "function") {
if (!match3.enteredCbs[key]) {
match3.enteredCbs[key] = [];
}
match3.enteredCbs[key].push(cb2);
}
next2(cb2);
});
};
}
var HTML5History = /* @__PURE__ */ function(History3) {
function HTML5History2(router, base2) {
History3.call(this, router, base2);
this._startLocation = getLocation(this.base);
}
if (History3)
HTML5History2.__proto__ = History3;
HTML5History2.prototype = Object.create(History3 && History3.prototype);
HTML5History2.prototype.constructor = HTML5History2;
HTML5History2.prototype.setupListeners = function setupListeners2() {
var this$1 = this;
if (this.listeners.length > 0) {
return;
}
var router = this.router;
var expectScroll = router.options.scrollBehavior;
var supportsScroll = supportsPushState && expectScroll;
if (supportsScroll) {
this.listeners.push(setupScroll());
}
var handleRoutingEvent = function() {
var current = this$1.current;
var location = getLocation(this$1.base);
if (this$1.current === START && location === this$1._startLocation) {
return;
}
this$1.transitionTo(location, function(route) {
if (supportsScroll) {
handleScroll(router, route, current, true);
}
});
};
window.addEventListener("popstate", handleRoutingEvent);
this.listeners.push(function() {
window.removeEventListener("popstate", handleRoutingEvent);
});
};
HTML5History2.prototype.go = function go2(n) {
window.history.go(n);
};
HTML5History2.prototype.push = function push3(location, onComplete, onAbort) {
var this$1 = this;
var ref2 = this;
var fromRoute = ref2.current;
this.transitionTo(location, function(route) {
pushState(cleanPath(this$1.base + route.fullPath));
handleScroll(this$1.router, route, fromRoute, false);
onComplete && onComplete(route);
}, onAbort);
};
HTML5History2.prototype.replace = function replace4(location, onComplete, onAbort) {
var this$1 = this;
var ref2 = this;
var fromRoute = ref2.current;
this.transitionTo(location, function(route) {
replaceState(cleanPath(this$1.base + route.fullPath));
handleScroll(this$1.router, route, fromRoute, false);
onComplete && onComplete(route);
}, onAbort);
};
HTML5History2.prototype.ensureURL = function ensureURL(push3) {
if (getLocation(this.base) !== this.current.fullPath) {
var current = cleanPath(this.base + this.current.fullPath);
push3 ? pushState(current) : replaceState(current);
}
};
HTML5History2.prototype.getCurrentLocation = function getCurrentLocation() {
return getLocation(this.base);
};
return HTML5History2;
}(History$1);
function getLocation(base2) {
var path = window.location.pathname;
if (base2 && path.toLowerCase().indexOf(base2.toLowerCase()) === 0) {
path = path.slice(base2.length);
}
return (path || "/") + window.location.search + window.location.hash;
}
var HashHistory = /* @__PURE__ */ function(History3) {
function HashHistory2(router, base2, fallback) {
History3.call(this, router, base2);
if (fallback && checkFallback(this.base)) {
return;
}
ensureSlash();
}
if (History3)
HashHistory2.__proto__ = History3;
HashHistory2.prototype = Object.create(History3 && History3.prototype);
HashHistory2.prototype.constructor = HashHistory2;
HashHistory2.prototype.setupListeners = function setupListeners2() {
var this$1 = this;
if (this.listeners.length > 0) {
return;
}
var router = this.router;
var expectScroll = router.options.scrollBehavior;
var supportsScroll = supportsPushState && expectScroll;
if (supportsScroll) {
this.listeners.push(setupScroll());
}
var handleRoutingEvent = function() {
var current = this$1.current;
if (!ensureSlash()) {
return;
}
this$1.transitionTo(getHash(), function(route) {
if (supportsScroll) {
handleScroll(this$1.router, route, current, true);
}
if (!supportsPushState) {
replaceHash(route.fullPath);
}
});
};
var eventType = supportsPushState ? "popstate" : "hashchange";
window.addEventListener(eventType, handleRoutingEvent);
this.listeners.push(function() {
window.removeEventListener(eventType, handleRoutingEvent);
});
};
HashHistory2.prototype.push = function push3(location, onComplete, onAbort) {
var this$1 = this;
var ref2 = this;
var fromRoute = ref2.current;
this.transitionTo(location, function(route) {
pushHash(route.fullPath);
handleScroll(this$1.router, route, fromRoute, false);
onComplete && onComplete(route);
}, onAbort);
};
HashHistory2.prototype.replace = function replace4(location, onComplete, onAbort) {
var this$1 = this;
var ref2 = this;
var fromRoute = ref2.current;
this.transitionTo(location, function(route) {
replaceHash(route.fullPath);
handleScroll(this$1.router, route, fromRoute, false);
onComplete && onComplete(route);
}, onAbort);
};
HashHistory2.prototype.go = function go2(n) {
window.history.go(n);
};
HashHistory2.prototype.ensureURL = function ensureURL(push3) {
var current = this.current.fullPath;
if (getHash() !== current) {
push3 ? pushHash(current) : replaceHash(current);
}
};
HashHistory2.prototype.getCurrentLocation = function getCurrentLocation() {
return getHash();
};
return HashHistory2;
}(History$1);
function checkFallback(base2) {
var location = getLocation(base2);
if (!/^\/#/.test(location)) {
window.location.replace(cleanPath(base2 + "/#" + location));
return true;
}
}
function ensureSlash() {
var path = getHash();
if (path.charAt(0) === "/") {
return true;
}
replaceHash("/" + path);
return false;
}
function getHash() {
var href = window.location.href;
var index3 = href.indexOf("#");
if (index3 < 0) {
return "";
}
href = href.slice(index3 + 1);
return href;
}
function getUrl(path) {
var href = window.location.href;
var i = href.indexOf("#");
var base2 = i >= 0 ? href.slice(0, i) : href;
return base2 + "#" + path;
}
function pushHash(path) {
if (supportsPushState) {
pushState(getUrl(path));
} else {
window.location.hash = path;
}
}
function replaceHash(path) {
if (supportsPushState) {
replaceState(getUrl(path));
} else {
window.location.replace(getUrl(path));
}
}
var AbstractHistory = /* @__PURE__ */ function(History3) {
function AbstractHistory2(router, base2) {
History3.call(this, router, base2);
this.stack = [];
this.index = -1;
}
if (History3)
AbstractHistory2.__proto__ = History3;
AbstractHistory2.prototype = Object.create(History3 && History3.prototype);
AbstractHistory2.prototype.constructor = AbstractHistory2;
AbstractHistory2.prototype.push = function push3(location, onComplete, onAbort) {
var this$1 = this;
this.transitionTo(location, function(route) {
this$1.stack = this$1.stack.slice(0, this$1.index + 1).concat(route);
this$1.index++;
onComplete && onComplete(route);
}, onAbort);
};
AbstractHistory2.prototype.replace = function replace4(location, onComplete, onAbort) {
var this$1 = this;
this.transitionTo(location, function(route) {
this$1.stack = this$1.stack.slice(0, this$1.index).concat(route);
onComplete && onComplete(route);
}, onAbort);
};
AbstractHistory2.prototype.go = function go2(n) {
var this$1 = this;
var targetIndex = this.index + n;
if (targetIndex < 0 || targetIndex >= this.stack.length) {
return;
}
var route = this.stack[targetIndex];
this.confirmTransition(route, function() {
var prev = this$1.current;
this$1.index = targetIndex;
this$1.updateRoute(route);
this$1.router.afterHooks.forEach(function(hook) {
hook && hook(route, prev);
});
}, function(err2) {
if (isNavigationFailure(err2, NavigationFailureType.duplicated)) {
this$1.index = targetIndex;
}
});
};
AbstractHistory2.prototype.getCurrentLocation = function getCurrentLocation() {
var current = this.stack[this.stack.length - 1];
return current ? current.fullPath : "/";
};
AbstractHistory2.prototype.ensureURL = function ensureURL() {
};
return AbstractHistory2;
}(History$1);
var VueRouter = function VueRouter2(options) {
if (options === void 0)
options = {};
this.app = null;
this.apps = [];
this.options = options;
this.beforeHooks = [];
this.resolveHooks = [];
this.afterHooks = [];
this.matcher = createMatcher(options.routes || [], this);
var mode = options.mode || "hash";
this.fallback = mode === "history" && !supportsPushState && options.fallback !== false;
if (this.fallback) {
mode = "hash";
}
if (!inBrowser) {
mode = "abstract";
}
this.mode = mode;
switch (mode) {
case "history":
this.history = new HTML5History(this, options.base);
break;
case "hash":
this.history = new HashHistory(this, options.base, this.fallback);
break;
case "abstract":
this.history = new AbstractHistory(this, options.base);
break;
}
};
var prototypeAccessors$7 = {currentRoute: {configurable: true}};
VueRouter.prototype.match = function match(raw, current, redirectedFrom) {
return this.matcher.match(raw, current, redirectedFrom);
};
prototypeAccessors$7.currentRoute.get = function() {
return this.history && this.history.current;
};
VueRouter.prototype.init = function init2(app) {
var this$1 = this;
this.apps.push(app);
app.$once("hook:destroyed", function() {
var index3 = this$1.apps.indexOf(app);
if (index3 > -1) {
this$1.apps.splice(index3, 1);
}
if (this$1.app === app) {
this$1.app = this$1.apps[0] || null;
}
if (!this$1.app) {
this$1.history.teardown();
}
});
if (this.app) {
return;
}
this.app = app;
var history2 = this.history;
if (history2 instanceof HTML5History || history2 instanceof HashHistory) {
var handleInitialScroll = function(routeOrError) {
var from4 = history2.current;
var expectScroll = this$1.options.scrollBehavior;
var supportsScroll = supportsPushState && expectScroll;
if (supportsScroll && "fullPath" in routeOrError) {
handleScroll(this$1, routeOrError, from4, false);
}
};
var setupListeners2 = function(routeOrError) {
history2.setupListeners();
handleInitialScroll(routeOrError);
};
history2.transitionTo(history2.getCurrentLocation(), setupListeners2, setupListeners2);
}
history2.listen(function(route) {
this$1.apps.forEach(function(app2) {
app2._route = route;
});
});
};
VueRouter.prototype.beforeEach = function beforeEach(fn) {
return registerHook(this.beforeHooks, fn);
};
VueRouter.prototype.beforeResolve = function beforeResolve(fn) {
return registerHook(this.resolveHooks, fn);
};
VueRouter.prototype.afterEach = function afterEach(fn) {
return registerHook(this.afterHooks, fn);
};
VueRouter.prototype.onReady = function onReady2(cb2, errorCb) {
this.history.onReady(cb2, errorCb);
};
VueRouter.prototype.onError = function onError2(errorCb) {
this.history.onError(errorCb);
};
VueRouter.prototype.push = function push(location, onComplete, onAbort) {
var this$1 = this;
if (!onComplete && !onAbort && typeof Promise !== "undefined") {
return new Promise(function(resolve9, reject2) {
this$1.history.push(location, resolve9, reject2);
});
} else {
this.history.push(location, onComplete, onAbort);
}
};
VueRouter.prototype.replace = function replace(location, onComplete, onAbort) {
var this$1 = this;
if (!onComplete && !onAbort && typeof Promise !== "undefined") {
return new Promise(function(resolve9, reject2) {
this$1.history.replace(location, resolve9, reject2);
});
} else {
this.history.replace(location, onComplete, onAbort);
}
};
VueRouter.prototype.go = function go(n) {
this.history.go(n);
};
VueRouter.prototype.back = function back() {
this.go(-1);
};
VueRouter.prototype.forward = function forward() {
this.go(1);
};
VueRouter.prototype.getMatchedComponents = function getMatchedComponents(to) {
var route = to ? to.matched ? to : this.resolve(to).route : this.currentRoute;
if (!route) {
return [];
}
return [].concat.apply([], route.matched.map(function(m) {
return Object.keys(m.components).map(function(key) {
return m.components[key];
});
}));
};
VueRouter.prototype.resolve = function resolve(to, current, append3) {
current = current || this.history.current;
var location = normalizeLocation(to, current, append3, this);
var route = this.match(location, current);
var fullPath = route.redirectedFrom || route.fullPath;
var base2 = this.history.base;
var href = createHref(base2, fullPath, this.mode);
return {
location,
route,
href,
normalizedTo: location,
resolved: route
};
};
VueRouter.prototype.getRoutes = function getRoutes() {
return this.matcher.getRoutes();
};
VueRouter.prototype.addRoute = function addRoute(parentOrRoute, route) {
this.matcher.addRoute(parentOrRoute, route);
if (this.history.current !== START) {
this.history.transitionTo(this.history.getCurrentLocation());
}
};
VueRouter.prototype.addRoutes = function addRoutes(routes) {
this.matcher.addRoutes(routes);
if (this.history.current !== START) {
this.history.transitionTo(this.history.getCurrentLocation());
}
};
Object.defineProperties(VueRouter.prototype, prototypeAccessors$7);
function registerHook(list, fn) {
list.push(fn);
return function() {
var i = list.indexOf(fn);
if (i > -1) {
list.splice(i, 1);
}
};
}
function createHref(base2, fullPath, mode) {
var path = mode === "hash" ? "#" + fullPath : fullPath;
return base2 ? cleanPath(base2 + "/" + path) : path;
}
VueRouter.install = install;
VueRouter.version = "3.5.1";
VueRouter.isNavigationFailure = isNavigationFailure;
VueRouter.NavigationFailureType = NavigationFailureType;
VueRouter.START_LOCATION = START;
if (inBrowser && window.Vue) {
window.Vue.use(VueRouter);
}
var SECONDS_A_MINUTE = 60;
var SECONDS_A_HOUR = SECONDS_A_MINUTE * 60;
var SECONDS_A_DAY = SECONDS_A_HOUR * 24;
var SECONDS_A_WEEK = SECONDS_A_DAY * 7;
var MILLISECONDS_A_SECOND = 1e3;
var MILLISECONDS_A_MINUTE = SECONDS_A_MINUTE * MILLISECONDS_A_SECOND;
var MILLISECONDS_A_HOUR = SECONDS_A_HOUR * MILLISECONDS_A_SECOND;
var MILLISECONDS_A_DAY = SECONDS_A_DAY * MILLISECONDS_A_SECOND;
var MILLISECONDS_A_WEEK = SECONDS_A_WEEK * MILLISECONDS_A_SECOND;
var MS = "millisecond";
var S = "second";
var MIN = "minute";
var H = "hour";
var D = "day";
var W = "week";
var M = "month";
var Q = "quarter";
var Y = "year";
var DATE = "date";
var FORMAT_DEFAULT = "YYYY-MM-DDTHH:mm:ssZ";
var INVALID_DATE_STRING = "Invalid Date";
var REGEX_PARSE = /^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[^0-9]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/;
var REGEX_FORMAT = /\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g;
var en = {
name: "en",
weekdays: "Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),
months: "January_February_March_April_May_June_July_August_September_October_November_December".split("_")
};
var padStart = function padStart2(string, length, pad2) {
var s = String(string);
if (!s || s.length >= length)
return string;
return "" + Array(length + 1 - s.length).join(pad2) + string;
};
var padZoneStr = function padZoneStr2(instance) {
var negMinutes = -instance.utcOffset();
var minutes = Math.abs(negMinutes);
var hourOffset = Math.floor(minutes / 60);
var minuteOffset = minutes % 60;
return "" + (negMinutes <= 0 ? "+" : "-") + padStart(hourOffset, 2, "0") + ":" + padStart(minuteOffset, 2, "0");
};
var monthDiff = function monthDiff2(a, b) {
if (a.date() < b.date())
return -monthDiff2(b, a);
var wholeMonthDiff = (b.year() - a.year()) * 12 + (b.month() - a.month());
var anchor = a.clone().add(wholeMonthDiff, M);
var c = b - anchor < 0;
var anchor2 = a.clone().add(wholeMonthDiff + (c ? -1 : 1), M);
return +(-(wholeMonthDiff + (b - anchor) / (c ? anchor - anchor2 : anchor2 - anchor)) || 0);
};
var absFloor = function absFloor2(n) {
return n < 0 ? Math.ceil(n) || 0 : Math.floor(n);
};
var prettyUnit = function prettyUnit2(u) {
var special = {
M,
y: Y,
w: W,
d: D,
D: DATE,
h: H,
m: MIN,
s: S,
ms: MS,
Q
};
return special[u] || String(u || "").toLowerCase().replace(/s$/, "");
};
var isUndefined$1 = function isUndefined(s) {
return s === void 0;
};
var U = {
s: padStart,
z: padZoneStr,
m: monthDiff,
a: absFloor,
p: prettyUnit,
u: isUndefined$1
};
var L = "en";
var Ls = {};
Ls[L] = en;
var isDayjs = function isDayjs2(d) {
return d instanceof Dayjs;
};
var parseLocale = function parseLocale2(preset, object2, isLocal) {
var l;
if (!preset)
return L;
if (typeof preset === "string") {
if (Ls[preset]) {
l = preset;
}
if (object2) {
Ls[preset] = object2;
l = preset;
}
} else {
var name = preset.name;
Ls[name] = preset;
l = name;
}
if (!isLocal && l)
L = l;
return l || !isLocal && L;
};
var dayjs = function dayjs2(date, c) {
if (isDayjs(date)) {
return date.clone();
}
var cfg = typeof c === "object" ? c : {};
cfg.date = date;
cfg.args = arguments;
return new Dayjs(cfg);
};
var wrapper = function wrapper2(date, instance) {
return dayjs(date, {
locale: instance.$L,
utc: instance.$u,
x: instance.$x,
$offset: instance.$offset
});
};
var Utils = U;
Utils.l = parseLocale;
Utils.i = isDayjs;
Utils.w = wrapper;
var parseDate = function parseDate2(cfg) {
var date = cfg.date, utc = cfg.utc;
if (date === null)
return new Date(NaN);
if (Utils.u(date))
return new Date();
if (date instanceof Date)
return new Date(date);
if (typeof date === "string" && !/Z$/i.test(date)) {
var d = date.match(REGEX_PARSE);
if (d) {
var m = d[2] - 1 || 0;
var ms = (d[7] || "0").substring(0, 3);
if (utc) {
return new Date(Date.UTC(d[1], m, d[3] || 1, d[4] || 0, d[5] || 0, d[6] || 0, ms));
}
return new Date(d[1], m, d[3] || 1, d[4] || 0, d[5] || 0, d[6] || 0, ms);
}
}
return new Date(date);
};
var Dayjs = /* @__PURE__ */ function() {
function Dayjs2(cfg) {
this.$L = parseLocale(cfg.locale, null, true);
this.parse(cfg);
}
var _proto = Dayjs2.prototype;
_proto.parse = function parse4(cfg) {
this.$d = parseDate(cfg);
this.$x = cfg.x || {};
this.init();
};
_proto.init = function init7() {
var $d = this.$d;
this.$y = $d.getFullYear();
this.$M = $d.getMonth();
this.$D = $d.getDate();
this.$W = $d.getDay();
this.$H = $d.getHours();
this.$m = $d.getMinutes();
this.$s = $d.getSeconds();
this.$ms = $d.getMilliseconds();
};
_proto.$utils = function $utils() {
return Utils;
};
_proto.isValid = function isValid() {
return !(this.$d.toString() === INVALID_DATE_STRING);
};
_proto.isSame = function isSame(that, units) {
var other = dayjs(that);
return this.startOf(units) <= other && other <= this.endOf(units);
};
_proto.isAfter = function isAfter(that, units) {
return dayjs(that) < this.startOf(units);
};
_proto.isBefore = function isBefore(that, units) {
return this.endOf(units) < dayjs(that);
};
_proto.$g = function $g(input, get7, set3) {
if (Utils.u(input))
return this[get7];
return this.set(set3, input);
};
_proto.unix = function unix() {
return Math.floor(this.valueOf() / 1e3);
};
_proto.valueOf = function valueOf() {
return this.$d.getTime();
};
_proto.startOf = function startOf(units, _startOf) {
var _this = this;
var isStartOf = !Utils.u(_startOf) ? _startOf : true;
var unit = Utils.p(units);
var instanceFactory = function instanceFactory2(d, m) {
var ins = Utils.w(_this.$u ? Date.UTC(_this.$y, m, d) : new Date(_this.$y, m, d), _this);
return isStartOf ? ins : ins.endOf(D);
};
var instanceFactorySet = function instanceFactorySet2(method, slice5) {
var argumentStart = [0, 0, 0, 0];
var argumentEnd = [23, 59, 59, 999];
return Utils.w(_this.toDate()[method].apply(_this.toDate("s"), (isStartOf ? argumentStart : argumentEnd).slice(slice5)), _this);
};
var $W = this.$W, $M = this.$M, $D = this.$D;
var utcPad = "set" + (this.$u ? "UTC" : "");
switch (unit) {
case Y:
return isStartOf ? instanceFactory(1, 0) : instanceFactory(31, 11);
case M:
return isStartOf ? instanceFactory(1, $M) : instanceFactory(0, $M + 1);
case W: {
var weekStart = this.$locale().weekStart || 0;
var gap = ($W < weekStart ? $W + 7 : $W) - weekStart;
return instanceFactory(isStartOf ? $D - gap : $D + (6 - gap), $M);
}
case D:
case DATE:
return instanceFactorySet(utcPad + "Hours", 0);
case H:
return instanceFactorySet(utcPad + "Minutes", 1);
case MIN:
return instanceFactorySet(utcPad + "Seconds", 2);
case S:
return instanceFactorySet(utcPad + "Milliseconds", 3);
default:
return this.clone();
}
};
_proto.endOf = function endOf(arg) {
return this.startOf(arg, false);
};
_proto.$set = function $set(units, _int) {
var _C$D$C$DATE$C$M$C$Y$C;
var unit = Utils.p(units);
var utcPad = "set" + (this.$u ? "UTC" : "");
var name = (_C$D$C$DATE$C$M$C$Y$C = {}, _C$D$C$DATE$C$M$C$Y$C[D] = utcPad + "Date", _C$D$C$DATE$C$M$C$Y$C[DATE] = utcPad + "Date", _C$D$C$DATE$C$M$C$Y$C[M] = utcPad + "Month", _C$D$C$DATE$C$M$C$Y$C[Y] = utcPad + "FullYear", _C$D$C$DATE$C$M$C$Y$C[H] = utcPad + "Hours", _C$D$C$DATE$C$M$C$Y$C[MIN] = utcPad + "Minutes", _C$D$C$DATE$C$M$C$Y$C[S] = utcPad + "Seconds", _C$D$C$DATE$C$M$C$Y$C[MS] = utcPad + "Milliseconds", _C$D$C$DATE$C$M$C$Y$C)[unit];
var arg = unit === D ? this.$D + (_int - this.$W) : _int;
if (unit === M || unit === Y) {
var date = this.clone().set(DATE, 1);
date.$d[name](arg);
date.init();
this.$d = date.set(DATE, Math.min(this.$D, date.daysInMonth())).$d;
} else if (name)
this.$d[name](arg);
this.init();
return this;
};
_proto.set = function set3(string, _int2) {
return this.clone().$set(string, _int2);
};
_proto.get = function get7(unit) {
return this[Utils.p(unit)]();
};
_proto.add = function add3(number, units) {
var _this2 = this, _C$MIN$C$H$C$S$unit;
number = Number(number);
var unit = Utils.p(units);
var instanceFactorySet = function instanceFactorySet2(n) {
var d = dayjs(_this2);
return Utils.w(d.date(d.date() + Math.round(n * number)), _this2);
};
if (unit === M) {
return this.set(M, this.$M + number);
}
if (unit === Y) {
return this.set(Y, this.$y + number);
}
if (unit === D) {
return instanceFactorySet(1);
}
if (unit === W) {
return instanceFactorySet(7);
}
var step2 = (_C$MIN$C$H$C$S$unit = {}, _C$MIN$C$H$C$S$unit[MIN] = MILLISECONDS_A_MINUTE, _C$MIN$C$H$C$S$unit[H] = MILLISECONDS_A_HOUR, _C$MIN$C$H$C$S$unit[S] = MILLISECONDS_A_SECOND, _C$MIN$C$H$C$S$unit)[unit] || 1;
var nextTimeStamp = this.$d.getTime() + number * step2;
return Utils.w(nextTimeStamp, this);
};
_proto.subtract = function subtract(number, string) {
return this.add(number * -1, string);
};
_proto.format = function format2(formatStr) {
var _this3 = this;
if (!this.isValid())
return INVALID_DATE_STRING;
var str2 = formatStr || FORMAT_DEFAULT;
var zoneStr = Utils.z(this);
var locale = this.$locale();
var $H = this.$H, $m = this.$m, $M = this.$M;
var weekdays = locale.weekdays, months = locale.months, meridiem = locale.meridiem;
var getShort = function getShort2(arr, index3, full, length) {
return arr && (arr[index3] || arr(_this3, str2)) || full[index3].substr(0, length);
};
var get$H = function get$H2(num) {
return Utils.s($H % 12 || 12, num, "0");
};
var meridiemFunc = meridiem || function(hour, minute, isLowercase) {
var m = hour < 12 ? "AM" : "PM";
return isLowercase ? m.toLowerCase() : m;
};
var matches2 = {
YY: String(this.$y).slice(-2),
YYYY: this.$y,
M: $M + 1,
MM: Utils.s($M + 1, 2, "0"),
MMM: getShort(locale.monthsShort, $M, months, 3),
MMMM: getShort(months, $M),
D: this.$D,
DD: Utils.s(this.$D, 2, "0"),
d: String(this.$W),
dd: getShort(locale.weekdaysMin, this.$W, weekdays, 2),
ddd: getShort(locale.weekdaysShort, this.$W, weekdays, 3),
dddd: weekdays[this.$W],
H: String($H),
HH: Utils.s($H, 2, "0"),
h: get$H(1),
hh: get$H(2),
a: meridiemFunc($H, $m, true),
A: meridiemFunc($H, $m, false),
m: String($m),
mm: Utils.s($m, 2, "0"),
s: String(this.$s),
ss: Utils.s(this.$s, 2, "0"),
SSS: Utils.s(this.$ms, 3, "0"),
Z: zoneStr
};
return str2.replace(REGEX_FORMAT, function(match3, $1) {
return $1 || matches2[match3] || zoneStr.replace(":", "");
});
};
_proto.utcOffset = function utcOffset() {
return -Math.round(this.$d.getTimezoneOffset() / 15) * 15;
};
_proto.diff = function diff(input, units, _float) {
var _C$Y$C$M$C$Q$C$W$C$D$;
var unit = Utils.p(units);
var that = dayjs(input);
var zoneDelta = (that.utcOffset() - this.utcOffset()) * MILLISECONDS_A_MINUTE;
var diff2 = this - that;
var result2 = Utils.m(this, that);
result2 = (_C$Y$C$M$C$Q$C$W$C$D$ = {}, _C$Y$C$M$C$Q$C$W$C$D$[Y] = result2 / 12, _C$Y$C$M$C$Q$C$W$C$D$[M] = result2, _C$Y$C$M$C$Q$C$W$C$D$[Q] = result2 / 3, _C$Y$C$M$C$Q$C$W$C$D$[W] = (diff2 - zoneDelta) / MILLISECONDS_A_WEEK, _C$Y$C$M$C$Q$C$W$C$D$[D] = (diff2 - zoneDelta) / MILLISECONDS_A_DAY, _C$Y$C$M$C$Q$C$W$C$D$[H] = diff2 / MILLISECONDS_A_HOUR, _C$Y$C$M$C$Q$C$W$C$D$[MIN] = diff2 / MILLISECONDS_A_MINUTE, _C$Y$C$M$C$Q$C$W$C$D$[S] = diff2 / MILLISECONDS_A_SECOND, _C$Y$C$M$C$Q$C$W$C$D$)[unit] || diff2;
return _float ? result2 : Utils.a(result2);
};
_proto.daysInMonth = function daysInMonth() {
return this.endOf(M).$D;
};
_proto.$locale = function $locale() {
return Ls[this.$L];
};
_proto.locale = function locale(preset, object2) {
if (!preset)
return this.$L;
var that = this.clone();
var nextLocaleName = parseLocale(preset, object2, true);
if (nextLocaleName)
that.$L = nextLocaleName;
return that;
};
_proto.clone = function clone2() {
return Utils.w(this.$d, this);
};
_proto.toDate = function toDate() {
return new Date(this.valueOf());
};
_proto.toJSON = function toJSON7() {
return this.isValid() ? this.toISOString() : null;
};
_proto.toISOString = function toISOString() {
return this.$d.toISOString();
};
_proto.toString = function toString8() {
return this.$d.toUTCString();
};
return Dayjs2;
}();
var proto = Dayjs.prototype;
dayjs.prototype = proto;
[["$ms", MS], ["$s", S], ["$m", MIN], ["$H", H], ["$W", D], ["$M", M], ["$y", Y], ["$D", DATE]].forEach(function(g) {
proto[g[1]] = function(input) {
return this.$g(input, g[0], g[1]);
};
});
dayjs.extend = function(plugin, option2) {
if (!plugin.$i) {
plugin(option2, Dayjs, dayjs);
plugin.$i = true;
}
return dayjs;
};
dayjs.locale = parseLocale;
dayjs.isDayjs = isDayjs;
dayjs.unix = function(timestamp) {
return dayjs(timestamp * 1e3);
};
dayjs.en = Ls[L];
dayjs.Ls = Ls;
dayjs.p = {};
var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
function getAugmentedNamespace(n) {
if (n.__esModule)
return n;
var a = Object.defineProperty({}, "__esModule", {value: true});
Object.keys(n).forEach(function(k) {
var d = Object.getOwnPropertyDescriptor(n, k);
Object.defineProperty(a, k, d.get ? d : {
enumerable: true,
get: function() {
return n[k];
}
});
});
return a;
}
function createCommonjsModule(fn) {
var module = {exports: {}};
return fn(module, module.exports), module.exports;
}
var axios = createCommonjsModule(function(module, exports) {
(function webpackUniversalModuleDefinition(root2, factory) {
module.exports = factory();
})(commonjsGlobal, function() {
return function(modules2) {
var installedModules = {};
function __webpack_require__(moduleId) {
if (installedModules[moduleId])
return installedModules[moduleId].exports;
var module2 = installedModules[moduleId] = {
exports: {},
id: moduleId,
loaded: false
};
modules2[moduleId].call(module2.exports, module2, module2.exports, __webpack_require__);
module2.loaded = true;
return module2.exports;
}
__webpack_require__.m = modules2;
__webpack_require__.c = installedModules;
__webpack_require__.p = "";
return __webpack_require__(0);
}([
function(module2, exports2, __webpack_require__) {
module2.exports = __webpack_require__(1);
},
function(module2, exports2, __webpack_require__) {
var utils2 = __webpack_require__(2);
var bind4 = __webpack_require__(3);
var Axios = __webpack_require__(4);
var mergeConfig = __webpack_require__(22);
var defaults2 = __webpack_require__(10);
function createInstance(defaultConfig) {
var context = new Axios(defaultConfig);
var instance = bind4(Axios.prototype.request, context);
utils2.extend(instance, Axios.prototype, context);
utils2.extend(instance, context);
return instance;
}
var axios2 = createInstance(defaults2);
axios2.Axios = Axios;
axios2.create = function create7(instanceConfig) {
return createInstance(mergeConfig(axios2.defaults, instanceConfig));
};
axios2.Cancel = __webpack_require__(23);
axios2.CancelToken = __webpack_require__(24);
axios2.isCancel = __webpack_require__(9);
axios2.all = function all(promises) {
return Promise.all(promises);
};
axios2.spread = __webpack_require__(25);
axios2.isAxiosError = __webpack_require__(26);
module2.exports = axios2;
module2.exports.default = axios2;
},
function(module2, exports2, __webpack_require__) {
var bind4 = __webpack_require__(3);
var toString8 = Object.prototype.toString;
function isArray2(val) {
return toString8.call(val) === "[object Array]";
}
function isUndefined3(val) {
return typeof val === "undefined";
}
function isBuffer3(val) {
return val !== null && !isUndefined3(val) && val.constructor !== null && !isUndefined3(val.constructor) && typeof val.constructor.isBuffer === "function" && val.constructor.isBuffer(val);
}
function isArrayBuffer2(val) {
return toString8.call(val) === "[object ArrayBuffer]";
}
function isFormData(val) {
return typeof FormData !== "undefined" && val instanceof FormData;
}
function isArrayBufferView(val) {
var result2;
if (typeof ArrayBuffer !== "undefined" && ArrayBuffer.isView) {
result2 = ArrayBuffer.isView(val);
} else {
result2 = val && val.buffer && val.buffer instanceof ArrayBuffer;
}
return result2;
}
function isString2(val) {
return typeof val === "string";
}
function isNumber2(val) {
return typeof val === "number";
}
function isObject2(val) {
return val !== null && typeof val === "object";
}
function isPlainObject2(val) {
if (toString8.call(val) !== "[object Object]") {
return false;
}
var prototype = Object.getPrototypeOf(val);
return prototype === null || prototype === Object.prototype;
}
function isDate2(val) {
return toString8.call(val) === "[object Date]";
}
function isFile(val) {
return toString8.call(val) === "[object File]";
}
function isBlob(val) {
return toString8.call(val) === "[object Blob]";
}
function isFunction2(val) {
return toString8.call(val) === "[object Function]";
}
function isStream(val) {
return isObject2(val) && isFunction2(val.pipe);
}
function isURLSearchParams(val) {
return typeof URLSearchParams !== "undefined" && val instanceof URLSearchParams;
}
function trim(str2) {
return str2.replace(/^\s*/, "").replace(/\s*$/, "");
}
function isStandardBrowserEnv() {
if (typeof navigator !== "undefined" && (navigator.product === "ReactNative" || navigator.product === "NativeScript" || navigator.product === "NS")) {
return false;
}
return typeof window !== "undefined" && typeof document !== "undefined";
}
function forEach5(obj, fn) {
if (obj === null || typeof obj === "undefined") {
return;
}
if (typeof obj !== "object") {
obj = [obj];
}
if (isArray2(obj)) {
for (var i = 0, l = obj.length; i < l; i++) {
fn.call(null, obj[i], i, obj);
}
} else {
for (var key in obj) {
if (Object.prototype.hasOwnProperty.call(obj, key)) {
fn.call(null, obj[key], key, obj);
}
}
}
}
function merge5() {
var result2 = {};
function assignValue(val, key) {
if (isPlainObject2(result2[key]) && isPlainObject2(val)) {
result2[key] = merge5(result2[key], val);
} else if (isPlainObject2(val)) {
result2[key] = merge5({}, val);
} else if (isArray2(val)) {
result2[key] = val.slice();
} else {
result2[key] = val;
}
}
for (var i = 0, l = arguments.length; i < l; i++) {
forEach5(arguments[i], assignValue);
}
return result2;
}
function extend2(a, b, thisArg) {
forEach5(b, function assignValue(val, key) {
if (thisArg && typeof val === "function") {
a[key] = bind4(val, thisArg);
} else {
a[key] = val;
}
});
return a;
}
function stripBOM(content2) {
if (content2.charCodeAt(0) === 65279) {
content2 = content2.slice(1);
}
return content2;
}
module2.exports = {
isArray: isArray2,
isArrayBuffer: isArrayBuffer2,
isBuffer: isBuffer3,
isFormData,
isArrayBufferView,
isString: isString2,
isNumber: isNumber2,
isObject: isObject2,
isPlainObject: isPlainObject2,
isUndefined: isUndefined3,
isDate: isDate2,
isFile,
isBlob,
isFunction: isFunction2,
isStream,
isURLSearchParams,
isStandardBrowserEnv,
forEach: forEach5,
merge: merge5,
extend: extend2,
trim,
stripBOM
};
},
function(module2, exports2) {
module2.exports = function bind4(fn, thisArg) {
return function wrap2() {
var args = new Array(arguments.length);
for (var i = 0; i < args.length; i++) {
args[i] = arguments[i];
}
return fn.apply(thisArg, args);
};
};
},
function(module2, exports2, __webpack_require__) {
var utils2 = __webpack_require__(2);
var buildURL = __webpack_require__(5);
var InterceptorManager = __webpack_require__(6);
var dispatchRequest = __webpack_require__(7);
var mergeConfig = __webpack_require__(22);
function Axios(instanceConfig) {
this.defaults = instanceConfig;
this.interceptors = {
request: new InterceptorManager(),
response: new InterceptorManager()
};
}
Axios.prototype.request = function request(config2) {
if (typeof config2 === "string") {
config2 = arguments[1] || {};
config2.url = arguments[0];
} else {
config2 = config2 || {};
}
config2 = mergeConfig(this.defaults, config2);
if (config2.method) {
config2.method = config2.method.toLowerCase();
} else if (this.defaults.method) {
config2.method = this.defaults.method.toLowerCase();
} else {
config2.method = "get";
}
var chain2 = [dispatchRequest, void 0];
var promise = Promise.resolve(config2);
this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
chain2.unshift(interceptor.fulfilled, interceptor.rejected);
});
this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
chain2.push(interceptor.fulfilled, interceptor.rejected);
});
while (chain2.length) {
promise = promise.then(chain2.shift(), chain2.shift());
}
return promise;
};
Axios.prototype.getUri = function getUri(config2) {
config2 = mergeConfig(this.defaults, config2);
return buildURL(config2.url, config2.params, config2.paramsSerializer).replace(/^\?/, "");
};
utils2.forEach(["delete", "get", "head", "options"], function forEachMethodNoData(method) {
Axios.prototype[method] = function(url, config2) {
return this.request(mergeConfig(config2 || {}, {
method,
url,
data: (config2 || {}).data
}));
};
});
utils2.forEach(["post", "put", "patch"], function forEachMethodWithData(method) {
Axios.prototype[method] = function(url, data, config2) {
return this.request(mergeConfig(config2 || {}, {
method,
url,
data
}));
};
});
module2.exports = Axios;
},
function(module2, exports2, __webpack_require__) {
var utils2 = __webpack_require__(2);
function encode3(val) {
return encodeURIComponent(val).replace(/%3A/gi, ":").replace(/%24/g, "$").replace(/%2C/gi, ",").replace(/%20/g, "+").replace(/%5B/gi, "[").replace(/%5D/gi, "]");
}
module2.exports = function buildURL(url, params, paramsSerializer) {
if (!params) {
return url;
}
var serializedParams;
if (paramsSerializer) {
serializedParams = paramsSerializer(params);
} else if (utils2.isURLSearchParams(params)) {
serializedParams = params.toString();
} else {
var parts = [];
utils2.forEach(params, function serialize(val, key) {
if (val === null || typeof val === "undefined") {
return;
}
if (utils2.isArray(val)) {
key = key + "[]";
} else {
val = [val];
}
utils2.forEach(val, function parseValue(v) {
if (utils2.isDate(v)) {
v = v.toISOString();
} else if (utils2.isObject(v)) {
v = JSON.stringify(v);
}
parts.push(encode3(key) + "=" + encode3(v));
});
});
serializedParams = parts.join("&");
}
if (serializedParams) {
var hashmarkIndex = url.indexOf("#");
if (hashmarkIndex !== -1) {
url = url.slice(0, hashmarkIndex);
}
url += (url.indexOf("?") === -1 ? "?" : "&") + serializedParams;
}
return url;
};
},
function(module2, exports2, __webpack_require__) {
var utils2 = __webpack_require__(2);
function InterceptorManager() {
this.handlers = [];
}
InterceptorManager.prototype.use = function use(fulfilled, rejected) {
this.handlers.push({
fulfilled,
rejected
});
return this.handlers.length - 1;
};
InterceptorManager.prototype.eject = function eject(id) {
if (this.handlers[id]) {
this.handlers[id] = null;
}
};
InterceptorManager.prototype.forEach = function forEach5(fn) {
utils2.forEach(this.handlers, function forEachHandler(h) {
if (h !== null) {
fn(h);
}
});
};
module2.exports = InterceptorManager;
},
function(module2, exports2, __webpack_require__) {
var utils2 = __webpack_require__(2);
var transformData = __webpack_require__(8);
var isCancel = __webpack_require__(9);
var defaults2 = __webpack_require__(10);
function throwIfCancellationRequested(config2) {
if (config2.cancelToken) {
config2.cancelToken.throwIfRequested();
}
}
module2.exports = function dispatchRequest(config2) {
throwIfCancellationRequested(config2);
config2.headers = config2.headers || {};
config2.data = transformData(config2.data, config2.headers, config2.transformRequest);
config2.headers = utils2.merge(config2.headers.common || {}, config2.headers[config2.method] || {}, config2.headers);
utils2.forEach(["delete", "get", "head", "post", "put", "patch", "common"], function cleanHeaderConfig(method) {
delete config2.headers[method];
});
var adapter = config2.adapter || defaults2.adapter;
return adapter(config2).then(function onAdapterResolution(response) {
throwIfCancellationRequested(config2);
response.data = transformData(response.data, response.headers, config2.transformResponse);
return response;
}, function onAdapterRejection(reason) {
if (!isCancel(reason)) {
throwIfCancellationRequested(config2);
if (reason && reason.response) {
reason.response.data = transformData(reason.response.data, reason.response.headers, config2.transformResponse);
}
}
return Promise.reject(reason);
});
};
},
function(module2, exports2, __webpack_require__) {
var utils2 = __webpack_require__(2);
module2.exports = function transformData(data, headers, fns) {
utils2.forEach(fns, function transform(fn) {
data = fn(data, headers);
});
return data;
};
},
function(module2, exports2) {
module2.exports = function isCancel(value) {
return !!(value && value.__CANCEL__);
};
},
function(module2, exports2, __webpack_require__) {
var utils2 = __webpack_require__(2);
var normalizeHeaderName = __webpack_require__(11);
var DEFAULT_CONTENT_TYPE = {
"Content-Type": "application/x-www-form-urlencoded"
};
function setContentTypeIfUnset(headers, value) {
if (!utils2.isUndefined(headers) && utils2.isUndefined(headers["Content-Type"])) {
headers["Content-Type"] = value;
}
}
function getDefaultAdapter() {
var adapter;
if (typeof XMLHttpRequest !== "undefined") {
adapter = __webpack_require__(12);
} else if (typeof process !== "undefined" && Object.prototype.toString.call(process) === "[object process]") {
adapter = __webpack_require__(12);
}
return adapter;
}
var defaults2 = {
adapter: getDefaultAdapter(),
transformRequest: [function transformRequest(data, headers) {
normalizeHeaderName(headers, "Accept");
normalizeHeaderName(headers, "Content-Type");
if (utils2.isFormData(data) || utils2.isArrayBuffer(data) || utils2.isBuffer(data) || utils2.isStream(data) || utils2.isFile(data) || utils2.isBlob(data)) {
return data;
}
if (utils2.isArrayBufferView(data)) {
return data.buffer;
}
if (utils2.isURLSearchParams(data)) {
setContentTypeIfUnset(headers, "application/x-www-form-urlencoded;charset=utf-8");
return data.toString();
}
if (utils2.isObject(data)) {
setContentTypeIfUnset(headers, "application/json;charset=utf-8");
return JSON.stringify(data);
}
return data;
}],
transformResponse: [function transformResponse(data) {
if (typeof data === "string") {
try {
data = JSON.parse(data);
} catch (e) {
}
}
return data;
}],
timeout: 0,
xsrfCookieName: "XSRF-TOKEN",
xsrfHeaderName: "X-XSRF-TOKEN",
maxContentLength: -1,
maxBodyLength: -1,
validateStatus: function validateStatus(status) {
return status >= 200 && status < 300;
}
};
defaults2.headers = {
common: {
Accept: "application/json, text/plain, */*"
}
};
utils2.forEach(["delete", "get", "head"], function forEachMethodNoData(method) {
defaults2.headers[method] = {};
});
utils2.forEach(["post", "put", "patch"], function forEachMethodWithData(method) {
defaults2.headers[method] = utils2.merge(DEFAULT_CONTENT_TYPE);
});
module2.exports = defaults2;
},
function(module2, exports2, __webpack_require__) {
var utils2 = __webpack_require__(2);
module2.exports = function normalizeHeaderName(headers, normalizedName) {
utils2.forEach(headers, function processHeader(value, name) {
if (name !== normalizedName && name.toUpperCase() === normalizedName.toUpperCase()) {
headers[normalizedName] = value;
delete headers[name];
}
});
};
},
function(module2, exports2, __webpack_require__) {
var utils2 = __webpack_require__(2);
var settle = __webpack_require__(13);
var cookies = __webpack_require__(16);
var buildURL = __webpack_require__(5);
var buildFullPath = __webpack_require__(17);
var parseHeaders = __webpack_require__(20);
var isURLSameOrigin = __webpack_require__(21);
var createError = __webpack_require__(14);
module2.exports = function xhrAdapter(config2) {
return new Promise(function dispatchXhrRequest(resolve9, reject2) {
var requestData = config2.data;
var requestHeaders = config2.headers;
if (utils2.isFormData(requestData)) {
delete requestHeaders["Content-Type"];
}
var request = new XMLHttpRequest();
if (config2.auth) {
var username = config2.auth.username || "";
var password = config2.auth.password ? unescape(encodeURIComponent(config2.auth.password)) : "";
requestHeaders.Authorization = "Basic " + btoa(username + ":" + password);
}
var fullPath = buildFullPath(config2.baseURL, config2.url);
request.open(config2.method.toUpperCase(), buildURL(fullPath, config2.params, config2.paramsSerializer), true);
request.timeout = config2.timeout;
request.onreadystatechange = function handleLoad() {
if (!request || request.readyState !== 4) {
return;
}
if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf("file:") === 0)) {
return;
}
var responseHeaders = "getAllResponseHeaders" in request ? parseHeaders(request.getAllResponseHeaders()) : null;
var responseData = !config2.responseType || config2.responseType === "text" ? request.responseText : request.response;
var response = {
data: responseData,
status: request.status,
statusText: request.statusText,
headers: responseHeaders,
config: config2,
request
};
settle(resolve9, reject2, response);
request = null;
};
request.onabort = function handleAbort() {
if (!request) {
return;
}
reject2(createError("Request aborted", config2, "ECONNABORTED", request));
request = null;
};
request.onerror = function handleError2() {
reject2(createError("Network Error", config2, null, request));
request = null;
};
request.ontimeout = function handleTimeout() {
var timeoutErrorMessage = "timeout of " + config2.timeout + "ms exceeded";
if (config2.timeoutErrorMessage) {
timeoutErrorMessage = config2.timeoutErrorMessage;
}
reject2(createError(timeoutErrorMessage, config2, "ECONNABORTED", request));
request = null;
};
if (utils2.isStandardBrowserEnv()) {
var xsrfValue = (config2.withCredentials || isURLSameOrigin(fullPath)) && config2.xsrfCookieName ? cookies.read(config2.xsrfCookieName) : void 0;
if (xsrfValue) {
requestHeaders[config2.xsrfHeaderName] = xsrfValue;
}
}
if ("setRequestHeader" in request) {
utils2.forEach(requestHeaders, function setRequestHeader(val, key) {
if (typeof requestData === "undefined" && key.toLowerCase() === "content-type") {
delete requestHeaders[key];
} else {
request.setRequestHeader(key, val);
}
});
}
if (!utils2.isUndefined(config2.withCredentials)) {
request.withCredentials = !!config2.withCredentials;
}
if (config2.responseType) {
try {
request.responseType = config2.responseType;
} catch (e) {
if (config2.responseType !== "json") {
throw e;
}
}
}
if (typeof config2.onDownloadProgress === "function") {
request.addEventListener("progress", config2.onDownloadProgress);
}
if (typeof config2.onUploadProgress === "function" && request.upload) {
request.upload.addEventListener("progress", config2.onUploadProgress);
}
if (config2.cancelToken) {
config2.cancelToken.promise.then(function onCanceled(cancel) {
if (!request) {
return;
}
request.abort();
reject2(cancel);
request = null;
});
}
if (!requestData) {
requestData = null;
}
request.send(requestData);
});
};
},
function(module2, exports2, __webpack_require__) {
var createError = __webpack_require__(14);
module2.exports = function settle(resolve9, reject2, response) {
var validateStatus = response.config.validateStatus;
if (!response.status || !validateStatus || validateStatus(response.status)) {
resolve9(response);
} else {
reject2(createError("Request failed with status code " + response.status, response.config, null, response.request, response));
}
};
},
function(module2, exports2, __webpack_require__) {
var enhanceError = __webpack_require__(15);
module2.exports = function createError(message, config2, code, request, response) {
var error2 = new Error(message);
return enhanceError(error2, config2, code, request, response);
};
},
function(module2, exports2) {
module2.exports = function enhanceError(error2, config2, code, request, response) {
error2.config = config2;
if (code) {
error2.code = code;
}
error2.request = request;
error2.response = response;
error2.isAxiosError = true;
error2.toJSON = function toJSON7() {
return {
message: this.message,
name: this.name,
description: this.description,
number: this.number,
fileName: this.fileName,
lineNumber: this.lineNumber,
columnNumber: this.columnNumber,
stack: this.stack,
config: this.config,
code: this.code
};
};
return error2;
};
},
function(module2, exports2, __webpack_require__) {
var utils2 = __webpack_require__(2);
module2.exports = utils2.isStandardBrowserEnv() ? function standardBrowserEnv() {
return {
write: function write(name, value, expires, path, domain, secure) {
var cookie = [];
cookie.push(name + "=" + encodeURIComponent(value));
if (utils2.isNumber(expires)) {
cookie.push("expires=" + new Date(expires).toGMTString());
}
if (utils2.isString(path)) {
cookie.push("path=" + path);
}
if (utils2.isString(domain)) {
cookie.push("domain=" + domain);
}
if (secure === true) {
cookie.push("secure");
}
document.cookie = cookie.join("; ");
},
read: function read(name) {
var match3 = document.cookie.match(new RegExp("(^|;\\s*)(" + name + ")=([^;]*)"));
return match3 ? decodeURIComponent(match3[3]) : null;
},
remove: function remove3(name) {
this.write(name, "", Date.now() - 864e5);
}
};
}() : function nonStandardBrowserEnv() {
return {
write: function write() {
},
read: function read() {
return null;
},
remove: function remove3() {
}
};
}();
},
function(module2, exports2, __webpack_require__) {
var isAbsoluteURL = __webpack_require__(18);
var combineURLs = __webpack_require__(19);
module2.exports = function buildFullPath(baseURL, requestedURL) {
if (baseURL && !isAbsoluteURL(requestedURL)) {
return combineURLs(baseURL, requestedURL);
}
return requestedURL;
};
},
function(module2, exports2) {
module2.exports = function isAbsoluteURL(url) {
return /^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(url);
};
},
function(module2, exports2) {
module2.exports = function combineURLs(baseURL, relativeURL) {
return relativeURL ? baseURL.replace(/\/+$/, "") + "/" + relativeURL.replace(/^\/+/, "") : baseURL;
};
},
function(module2, exports2, __webpack_require__) {
var utils2 = __webpack_require__(2);
var ignoreDuplicateOf = [
"age",
"authorization",
"content-length",
"content-type",
"etag",
"expires",
"from",
"host",
"if-modified-since",
"if-unmodified-since",
"last-modified",
"location",
"max-forwards",
"proxy-authorization",
"referer",
"retry-after",
"user-agent"
];
module2.exports = function parseHeaders(headers) {
var parsed = {};
var key;
var val;
var i;
if (!headers) {
return parsed;
}
utils2.forEach(headers.split("\n"), function parser(line) {
i = line.indexOf(":");
key = utils2.trim(line.substr(0, i)).toLowerCase();
val = utils2.trim(line.substr(i + 1));
if (key) {
if (parsed[key] && ignoreDuplicateOf.indexOf(key) >= 0) {
return;
}
if (key === "set-cookie") {
parsed[key] = (parsed[key] ? parsed[key] : []).concat([val]);
} else {
parsed[key] = parsed[key] ? parsed[key] + ", " + val : val;
}
}
});
return parsed;
};
},
function(module2, exports2, __webpack_require__) {
var utils2 = __webpack_require__(2);
module2.exports = utils2.isStandardBrowserEnv() ? function standardBrowserEnv() {
var msie = /(msie|trident)/i.test(navigator.userAgent);
var urlParsingNode = document.createElement("a");
var originURL;
function resolveURL(url) {
var href = url;
if (msie) {
urlParsingNode.setAttribute("href", href);
href = urlParsingNode.href;
}
urlParsingNode.setAttribute("href", href);
return {
href: urlParsingNode.href,
protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, "") : "",
host: urlParsingNode.host,
search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, "") : "",
hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, "") : "",
hostname: urlParsingNode.hostname,
port: urlParsingNode.port,
pathname: urlParsingNode.pathname.charAt(0) === "/" ? urlParsingNode.pathname : "/" + urlParsingNode.pathname
};
}
originURL = resolveURL(window.location.href);
return function isURLSameOrigin(requestURL) {
var parsed = utils2.isString(requestURL) ? resolveURL(requestURL) : requestURL;
return parsed.protocol === originURL.protocol && parsed.host === originURL.host;
};
}() : function nonStandardBrowserEnv() {
return function isURLSameOrigin() {
return true;
};
}();
},
function(module2, exports2, __webpack_require__) {
var utils2 = __webpack_require__(2);
module2.exports = function mergeConfig(config1, config2) {
config2 = config2 || {};
var config3 = {};
var valueFromConfig2Keys = ["url", "method", "data"];
var mergeDeepPropertiesKeys = ["headers", "auth", "proxy", "params"];
var defaultToConfig2Keys = [
"baseURL",
"transformRequest",
"transformResponse",
"paramsSerializer",
"timeout",
"timeoutMessage",
"withCredentials",
"adapter",
"responseType",
"xsrfCookieName",
"xsrfHeaderName",
"onUploadProgress",
"onDownloadProgress",
"decompress",
"maxContentLength",
"maxBodyLength",
"maxRedirects",
"transport",
"httpAgent",
"httpsAgent",
"cancelToken",
"socketPath",
"responseEncoding"
];
var directMergeKeys = ["validateStatus"];
function getMergedValue(target2, source2) {
if (utils2.isPlainObject(target2) && utils2.isPlainObject(source2)) {
return utils2.merge(target2, source2);
} else if (utils2.isPlainObject(source2)) {
return utils2.merge({}, source2);
} else if (utils2.isArray(source2)) {
return source2.slice();
}
return source2;
}
function mergeDeepProperties(prop) {
if (!utils2.isUndefined(config2[prop])) {
config3[prop] = getMergedValue(config1[prop], config2[prop]);
} else if (!utils2.isUndefined(config1[prop])) {
config3[prop] = getMergedValue(void 0, config1[prop]);
}
}
utils2.forEach(valueFromConfig2Keys, function valueFromConfig2(prop) {
if (!utils2.isUndefined(config2[prop])) {
config3[prop] = getMergedValue(void 0, config2[prop]);
}
});
utils2.forEach(mergeDeepPropertiesKeys, mergeDeepProperties);
utils2.forEach(defaultToConfig2Keys, function defaultToConfig2(prop) {
if (!utils2.isUndefined(config2[prop])) {
config3[prop] = getMergedValue(void 0, config2[prop]);
} else if (!utils2.isUndefined(config1[prop])) {
config3[prop] = getMergedValue(void 0, config1[prop]);
}
});
utils2.forEach(directMergeKeys, function merge5(prop) {
if (prop in config2) {
config3[prop] = getMergedValue(config1[prop], config2[prop]);
} else if (prop in config1) {
config3[prop] = getMergedValue(void 0, config1[prop]);
}
});
var axiosKeys = valueFromConfig2Keys.concat(mergeDeepPropertiesKeys).concat(defaultToConfig2Keys).concat(directMergeKeys);
var otherKeys = Object.keys(config1).concat(Object.keys(config2)).filter(function filterAxiosKeys(key) {
return axiosKeys.indexOf(key) === -1;
});
utils2.forEach(otherKeys, mergeDeepProperties);
return config3;
};
},
function(module2, exports2) {
function Cancel(message) {
this.message = message;
}
Cancel.prototype.toString = function toString8() {
return "Cancel" + (this.message ? ": " + this.message : "");
};
Cancel.prototype.__CANCEL__ = true;
module2.exports = Cancel;
},
function(module2, exports2, __webpack_require__) {
var Cancel = __webpack_require__(23);
function CancelToken(executor) {
if (typeof executor !== "function") {
throw new TypeError("executor must be a function.");
}
var resolvePromise;
this.promise = new Promise(function promiseExecutor(resolve9) {
resolvePromise = resolve9;
});
var token = this;
executor(function cancel(message) {
if (token.reason) {
return;
}
token.reason = new Cancel(message);
resolvePromise(token.reason);
});
}
CancelToken.prototype.throwIfRequested = function throwIfRequested() {
if (this.reason) {
throw this.reason;
}
};
CancelToken.source = function source2() {
var cancel;
var token = new CancelToken(function executor(c) {
cancel = c;
});
return {
token,
cancel
};
};
module2.exports = CancelToken;
},
function(module2, exports2) {
module2.exports = function spread(callback) {
return function wrap2(arr) {
return callback.apply(null, arr);
};
};
},
function(module2, exports2) {
module2.exports = function isAxiosError(payload) {
return typeof payload === "object" && payload.isAxiosError === true;
};
}
]);
});
});
var VERSION = "1.13.1";
var root = typeof self == "object" && self.self === self && self || typeof global == "object" && global.global === global && global || Function("return this")() || {};
var ArrayProto = Array.prototype, ObjProto = Object.prototype;
var SymbolProto = typeof Symbol !== "undefined" ? Symbol.prototype : null;
var push$1 = ArrayProto.push, slice$1 = ArrayProto.slice, toString = ObjProto.toString, hasOwnProperty = ObjProto.hasOwnProperty;
var supportsArrayBuffer = typeof ArrayBuffer !== "undefined", supportsDataView = typeof DataView !== "undefined";
var nativeIsArray = Array.isArray, nativeKeys = Object.keys, nativeCreate = Object.create, nativeIsView = supportsArrayBuffer && ArrayBuffer.isView;
var _isNaN = isNaN, _isFinite = isFinite;
var hasEnumBug = !{toString: null}.propertyIsEnumerable("toString");
var nonEnumerableProps = [
"valueOf",
"isPrototypeOf",
"toString",
"propertyIsEnumerable",
"hasOwnProperty",
"toLocaleString"
];
var MAX_ARRAY_INDEX = Math.pow(2, 53) - 1;
function restArguments(func, startIndex) {
startIndex = startIndex == null ? func.length - 1 : +startIndex;
return function() {
var length = Math.max(arguments.length - startIndex, 0), rest2 = Array(length), index3 = 0;
for (; index3 < length; index3++) {
rest2[index3] = arguments[index3 + startIndex];
}
switch (startIndex) {
case 0:
return func.call(this, rest2);
case 1:
return func.call(this, arguments[0], rest2);
case 2:
return func.call(this, arguments[0], arguments[1], rest2);
}
var args = Array(startIndex + 1);
for (index3 = 0; index3 < startIndex; index3++) {
args[index3] = arguments[index3];
}
args[startIndex] = rest2;
return func.apply(this, args);
};
}
function isObject(obj) {
var type = typeof obj;
return type === "function" || type === "object" && !!obj;
}
function isNull(obj) {
return obj === null;
}
function isUndefined2(obj) {
return obj === void 0;
}
function isBoolean$1(obj) {
return obj === true || obj === false || toString.call(obj) === "[object Boolean]";
}
function isElement$1(obj) {
return !!(obj && obj.nodeType === 1);
}
function tagTester(name) {
var tag2 = "[object " + name + "]";
return function(obj) {
return toString.call(obj) === tag2;
};
}
var isString$1 = tagTester("String");
var isNumber$1 = tagTester("Number");
var isDate$1 = tagTester("Date");
var isRegExp$2 = tagTester("RegExp");
var isError$1 = tagTester("Error");
var isSymbol$1 = tagTester("Symbol");
var isArrayBuffer = tagTester("ArrayBuffer");
var isFunction = tagTester("Function");
var nodelist = root.document && root.document.childNodes;
if (typeof /./ != "function" && typeof Int8Array != "object" && typeof nodelist != "function") {
isFunction = function(obj) {
return typeof obj == "function" || false;
};
}
var isFunction$1 = isFunction;
var hasObjectTag = tagTester("Object");
var hasStringTagBug = supportsDataView && hasObjectTag(new DataView(new ArrayBuffer(8))), isIE11 = typeof Map !== "undefined" && hasObjectTag(new Map());
var isDataView = tagTester("DataView");
function ie10IsDataView(obj) {
return obj != null && isFunction$1(obj.getInt8) && isArrayBuffer(obj.buffer);
}
var isDataView$1 = hasStringTagBug ? ie10IsDataView : isDataView;
var isArray$4 = nativeIsArray || tagTester("Array");
function has$1$1(obj, key) {
return obj != null && hasOwnProperty.call(obj, key);
}
var isArguments = tagTester("Arguments");
(function() {
if (!isArguments(arguments)) {
isArguments = function(obj) {
return has$1$1(obj, "callee");
};
}
})();
var isArguments$1 = isArguments;
function isFinite$1(obj) {
return !isSymbol$1(obj) && _isFinite(obj) && !isNaN(parseFloat(obj));
}
function isNaN$1(obj) {
return isNumber$1(obj) && _isNaN(obj);
}
function constant(value) {
return function() {
return value;
};
}
function createSizePropertyCheck(getSizeProperty) {
return function(collection) {
var sizeProperty = getSizeProperty(collection);
return typeof sizeProperty == "number" && sizeProperty >= 0 && sizeProperty <= MAX_ARRAY_INDEX;
};
}
function shallowProperty(key) {
return function(obj) {
return obj == null ? void 0 : obj[key];
};
}
var getByteLength = shallowProperty("byteLength");
var isBufferLike = createSizePropertyCheck(getByteLength);
var typedArrayPattern = /\[object ((I|Ui)nt(8|16|32)|Float(32|64)|Uint8Clamped|Big(I|Ui)nt64)Array\]/;
function isTypedArray(obj) {
return nativeIsView ? nativeIsView(obj) && !isDataView$1(obj) : isBufferLike(obj) && typedArrayPattern.test(toString.call(obj));
}
var isTypedArray$1 = supportsArrayBuffer ? isTypedArray : constant(false);
var getLength = shallowProperty("length");
function emulatedSet(keys2) {
var hash2 = {};
for (var l = keys2.length, i = 0; i < l; ++i)
hash2[keys2[i]] = true;
return {
contains: function(key) {
return hash2[key];
},
push: function(key) {
hash2[key] = true;
return keys2.push(key);
}
};
}
function collectNonEnumProps(obj, keys2) {
keys2 = emulatedSet(keys2);
var nonEnumIdx = nonEnumerableProps.length;
var constructor = obj.constructor;
var proto2 = isFunction$1(constructor) && constructor.prototype || ObjProto;
var prop = "constructor";
if (has$1$1(obj, prop) && !keys2.contains(prop))
keys2.push(prop);
while (nonEnumIdx--) {
prop = nonEnumerableProps[nonEnumIdx];
if (prop in obj && obj[prop] !== proto2[prop] && !keys2.contains(prop)) {
keys2.push(prop);
}
}
}
function keys$1(obj) {
if (!isObject(obj))
return [];
if (nativeKeys)
return nativeKeys(obj);
var keys2 = [];
for (var key in obj)
if (has$1$1(obj, key))
keys2.push(key);
if (hasEnumBug)
collectNonEnumProps(obj, keys2);
return keys2;
}
function isEmpty(obj) {
if (obj == null)
return true;
var length = getLength(obj);
if (typeof length == "number" && (isArray$4(obj) || isString$1(obj) || isArguments$1(obj)))
return length === 0;
return getLength(keys$1(obj)) === 0;
}
function isMatch(object2, attrs2) {
var _keys = keys$1(attrs2), length = _keys.length;
if (object2 == null)
return !length;
var obj = Object(object2);
for (var i = 0; i < length; i++) {
var key = _keys[i];
if (attrs2[key] !== obj[key] || !(key in obj))
return false;
}
return true;
}
function _$1(obj) {
if (obj instanceof _$1)
return obj;
if (!(this instanceof _$1))
return new _$1(obj);
this._wrapped = obj;
}
_$1.VERSION = VERSION;
_$1.prototype.value = function() {
return this._wrapped;
};
_$1.prototype.valueOf = _$1.prototype.toJSON = _$1.prototype.value;
_$1.prototype.toString = function() {
return String(this._wrapped);
};
function toBufferView(bufferSource) {
return new Uint8Array(bufferSource.buffer || bufferSource, bufferSource.byteOffset || 0, getByteLength(bufferSource));
}
var tagDataView = "[object DataView]";
function eq(a, b, aStack, bStack) {
if (a === b)
return a !== 0 || 1 / a === 1 / b;
if (a == null || b == null)
return false;
if (a !== a)
return b !== b;
var type = typeof a;
if (type !== "function" && type !== "object" && typeof b != "object")
return false;
return deepEq(a, b, aStack, bStack);
}
function deepEq(a, b, aStack, bStack) {
if (a instanceof _$1)
a = a._wrapped;
if (b instanceof _$1)
b = b._wrapped;
var className = toString.call(a);
if (className !== toString.call(b))
return false;
if (hasStringTagBug && className == "[object Object]" && isDataView$1(a)) {
if (!isDataView$1(b))
return false;
className = tagDataView;
}
switch (className) {
case "[object RegExp]":
case "[object String]":
return "" + a === "" + b;
case "[object Number]":
if (+a !== +a)
return +b !== +b;
return +a === 0 ? 1 / +a === 1 / b : +a === +b;
case "[object Date]":
case "[object Boolean]":
return +a === +b;
case "[object Symbol]":
return SymbolProto.valueOf.call(a) === SymbolProto.valueOf.call(b);
case "[object ArrayBuffer]":
case tagDataView:
return deepEq(toBufferView(a), toBufferView(b), aStack, bStack);
}
var areArrays = className === "[object Array]";
if (!areArrays && isTypedArray$1(a)) {
var byteLength = getByteLength(a);
if (byteLength !== getByteLength(b))
return false;
if (a.buffer === b.buffer && a.byteOffset === b.byteOffset)
return true;
areArrays = true;
}
if (!areArrays) {
if (typeof a != "object" || typeof b != "object")
return false;
var aCtor = a.constructor, bCtor = b.constructor;
if (aCtor !== bCtor && !(isFunction$1(aCtor) && aCtor instanceof aCtor && isFunction$1(bCtor) && bCtor instanceof bCtor) && ("constructor" in a && "constructor" in b)) {
return false;
}
}
aStack = aStack || [];
bStack = bStack || [];
var length = aStack.length;
while (length--) {
if (aStack[length] === a)
return bStack[length] === b;
}
aStack.push(a);
bStack.push(b);
if (areArrays) {
length = a.length;
if (length !== b.length)
return false;
while (length--) {
if (!eq(a[length], b[length], aStack, bStack))
return false;
}
} else {
var _keys = keys$1(a), key;
length = _keys.length;
if (keys$1(b).length !== length)
return false;
while (length--) {
key = _keys[length];
if (!(has$1$1(b, key) && eq(a[key], b[key], aStack, bStack)))
return false;
}
}
aStack.pop();
bStack.pop();
return true;
}
function isEqual(a, b) {
return eq(a, b);
}
function allKeys(obj) {
if (!isObject(obj))
return [];
var keys2 = [];
for (var key in obj)
keys2.push(key);
if (hasEnumBug)
collectNonEnumProps(obj, keys2);
return keys2;
}
function ie11fingerprint(methods) {
var length = getLength(methods);
return function(obj) {
if (obj == null)
return false;
var keys2 = allKeys(obj);
if (getLength(keys2))
return false;
for (var i = 0; i < length; i++) {
if (!isFunction$1(obj[methods[i]]))
return false;
}
return methods !== weakMapMethods || !isFunction$1(obj[forEachName]);
};
}
var forEachName = "forEach", hasName = "has", commonInit = ["clear", "delete"], mapTail = ["get", hasName, "set"];
var mapMethods = commonInit.concat(forEachName, mapTail), weakMapMethods = commonInit.concat(mapTail), setMethods = ["add"].concat(commonInit, forEachName, hasName);
var isMap$1 = isIE11 ? ie11fingerprint(mapMethods) : tagTester("Map");
var isWeakMap$1 = isIE11 ? ie11fingerprint(weakMapMethods) : tagTester("WeakMap");
var isSet$1 = isIE11 ? ie11fingerprint(setMethods) : tagTester("Set");
var isWeakSet$1 = tagTester("WeakSet");
function values(obj) {
var _keys = keys$1(obj);
var length = _keys.length;
var values2 = Array(length);
for (var i = 0; i < length; i++) {
values2[i] = obj[_keys[i]];
}
return values2;
}
function pairs(obj) {
var _keys = keys$1(obj);
var length = _keys.length;
var pairs2 = Array(length);
for (var i = 0; i < length; i++) {
pairs2[i] = [_keys[i], obj[_keys[i]]];
}
return pairs2;
}
function invert(obj) {
var result2 = {};
var _keys = keys$1(obj);
for (var i = 0, length = _keys.length; i < length; i++) {
result2[obj[_keys[i]]] = _keys[i];
}
return result2;
}
function functions(obj) {
var names = [];
for (var key in obj) {
if (isFunction$1(obj[key]))
names.push(key);
}
return names.sort();
}
function createAssigner(keysFunc, defaults2) {
return function(obj) {
var length = arguments.length;
if (defaults2)
obj = Object(obj);
if (length < 2 || obj == null)
return obj;
for (var index3 = 1; index3 < length; index3++) {
var source2 = arguments[index3], keys2 = keysFunc(source2), l = keys2.length;
for (var i = 0; i < l; i++) {
var key = keys2[i];
if (!defaults2 || obj[key] === void 0)
obj[key] = source2[key];
}
}
return obj;
};
}
var extend$1 = createAssigner(allKeys);
var extendOwn = createAssigner(keys$1);
var defaults$4 = createAssigner(allKeys, true);
function ctor() {
return function() {
};
}
function baseCreate(prototype) {
if (!isObject(prototype))
return {};
if (nativeCreate)
return nativeCreate(prototype);
var Ctor = ctor();
Ctor.prototype = prototype;
var result2 = new Ctor();
Ctor.prototype = null;
return result2;
}
function create$1(prototype, props2) {
var result2 = baseCreate(prototype);
if (props2)
extendOwn(result2, props2);
return result2;
}
function clone$1(obj) {
if (!isObject(obj))
return obj;
return isArray$4(obj) ? obj.slice() : extend$1({}, obj);
}
function tap(obj, interceptor) {
interceptor(obj);
return obj;
}
function toPath$1(path) {
return isArray$4(path) ? path : [path];
}
_$1.toPath = toPath$1;
function toPath(path) {
return _$1.toPath(path);
}
function deepGet(obj, path) {
var length = path.length;
for (var i = 0; i < length; i++) {
if (obj == null)
return void 0;
obj = obj[path[i]];
}
return length ? obj : void 0;
}
function get3(object2, path, defaultValue) {
var value = deepGet(object2, toPath(path));
return isUndefined2(value) ? defaultValue : value;
}
function has$4(obj, path) {
path = toPath(path);
var length = path.length;
for (var i = 0; i < length; i++) {
var key = path[i];
if (!has$1$1(obj, key))
return false;
obj = obj[key];
}
return !!length;
}
function identity(value) {
return value;
}
function matcher(attrs2) {
attrs2 = extendOwn({}, attrs2);
return function(obj) {
return isMatch(obj, attrs2);
};
}
function property(path) {
path = toPath(path);
return function(obj) {
return deepGet(obj, path);
};
}
function optimizeCb(func, context, argCount) {
if (context === void 0)
return func;
switch (argCount == null ? 3 : argCount) {
case 1:
return function(value) {
return func.call(context, value);
};
case 3:
return function(value, index3, collection) {
return func.call(context, value, index3, collection);
};
case 4:
return function(accumulator, value, index3, collection) {
return func.call(context, accumulator, value, index3, collection);
};
}
return function() {
return func.apply(context, arguments);
};
}
function baseIteratee(value, context, argCount) {
if (value == null)
return identity;
if (isFunction$1(value))
return optimizeCb(value, context, argCount);
if (isObject(value) && !isArray$4(value))
return matcher(value);
return property(value);
}
function iteratee(value, context) {
return baseIteratee(value, context, Infinity);
}
_$1.iteratee = iteratee;
function cb(value, context, argCount) {
if (_$1.iteratee !== iteratee)
return _$1.iteratee(value, context);
return baseIteratee(value, context, argCount);
}
function mapObject(obj, iteratee2, context) {
iteratee2 = cb(iteratee2, context);
var _keys = keys$1(obj), length = _keys.length, results = {};
for (var index3 = 0; index3 < length; index3++) {
var currentKey = _keys[index3];
results[currentKey] = iteratee2(obj[currentKey], currentKey, obj);
}
return results;
}
function noop$1() {
}
function propertyOf(obj) {
if (obj == null)
return noop$1;
return function(path) {
return get3(obj, path);
};
}
function times(n, iteratee2, context) {
var accum = Array(Math.max(0, n));
iteratee2 = optimizeCb(iteratee2, context, 1);
for (var i = 0; i < n; i++)
accum[i] = iteratee2(i);
return accum;
}
function random(min3, max3) {
if (max3 == null) {
max3 = min3;
min3 = 0;
}
return min3 + Math.floor(Math.random() * (max3 - min3 + 1));
}
var now = Date.now || function() {
return new Date().getTime();
};
function createEscaper(map16) {
var escaper = function(match3) {
return map16[match3];
};
var source2 = "(?:" + keys$1(map16).join("|") + ")";
var testRegexp = RegExp(source2);
var replaceRegexp = RegExp(source2, "g");
return function(string) {
string = string == null ? "" : "" + string;
return testRegexp.test(string) ? string.replace(replaceRegexp, escaper) : string;
};
}
var escapeMap = {
"&": "&amp;",
"<": "&lt;",
">": "&gt;",
'"': "&quot;",
"'": "&#x27;",
"`": "&#x60;"
};
var _escape = createEscaper(escapeMap);
var unescapeMap = invert(escapeMap);
var _unescape = createEscaper(unescapeMap);
var templateSettings = _$1.templateSettings = {
evaluate: /<%([\s\S]+?)%>/g,
interpolate: /<%=([\s\S]+?)%>/g,
escape: /<%-([\s\S]+?)%>/g
};
var noMatch = /(.)^/;
var escapes = {
"'": "'",
"\\": "\\",
"\r": "r",
"\n": "n",
"\u2028": "u2028",
"\u2029": "u2029"
};
var escapeRegExp = /\\|'|\r|\n|\u2028|\u2029/g;
function escapeChar(match3) {
return "\\" + escapes[match3];
}
var bareIdentifier = /^\s*(\w|\$)+\s*$/;
function template(text3, settings, oldSettings) {
if (!settings && oldSettings)
settings = oldSettings;
settings = defaults$4({}, settings, _$1.templateSettings);
var matcher2 = RegExp([
(settings.escape || noMatch).source,
(settings.interpolate || noMatch).source,
(settings.evaluate || noMatch).source
].join("|") + "|$", "g");
var index3 = 0;
var source2 = "__p+='";
text3.replace(matcher2, function(match3, escape2, interpolate, evaluate2, offset2) {
source2 += text3.slice(index3, offset2).replace(escapeRegExp, escapeChar);
index3 = offset2 + match3.length;
if (escape2) {
source2 += "'+\n((__t=(" + escape2 + "))==null?'':_.escape(__t))+\n'";
} else if (interpolate) {
source2 += "'+\n((__t=(" + interpolate + "))==null?'':__t)+\n'";
} else if (evaluate2) {
source2 += "';\n" + evaluate2 + "\n__p+='";
}
return match3;
});
source2 += "';\n";
var argument = settings.variable;
if (argument) {
if (!bareIdentifier.test(argument))
throw new Error("variable is not a bare identifier: " + argument);
} else {
source2 = "with(obj||{}){\n" + source2 + "}\n";
argument = "obj";
}
source2 = "var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n" + source2 + "return __p;\n";
var render6;
try {
render6 = new Function(argument, "_", source2);
} catch (e) {
e.source = source2;
throw e;
}
var template2 = function(data) {
return render6.call(this, data, _$1);
};
template2.source = "function(" + argument + "){\n" + source2 + "}";
return template2;
}
function result$1(obj, path, fallback) {
path = toPath(path);
var length = path.length;
if (!length) {
return isFunction$1(fallback) ? fallback.call(obj) : fallback;
}
for (var i = 0; i < length; i++) {
var prop = obj == null ? void 0 : obj[path[i]];
if (prop === void 0) {
prop = fallback;
i = length;
}
obj = isFunction$1(prop) ? prop.call(obj) : prop;
}
return obj;
}
var idCounter = 0;
function uniqueId(prefix) {
var id = ++idCounter + "";
return prefix ? prefix + id : id;
}
function chain(obj) {
var instance = _$1(obj);
instance._chain = true;
return instance;
}
function executeBound(sourceFunc, boundFunc, context, callingContext, args) {
if (!(callingContext instanceof boundFunc))
return sourceFunc.apply(context, args);
var self2 = baseCreate(sourceFunc.prototype);
var result2 = sourceFunc.apply(self2, args);
if (isObject(result2))
return result2;
return self2;
}
var partial = restArguments(function(func, boundArgs) {
var placeholder2 = partial.placeholder;
var bound = function() {
var position = 0, length = boundArgs.length;
var args = Array(length);
for (var i = 0; i < length; i++) {
args[i] = boundArgs[i] === placeholder2 ? arguments[position++] : boundArgs[i];
}
while (position < arguments.length)
args.push(arguments[position++]);
return executeBound(func, bound, this, this, args);
};
return bound;
});
partial.placeholder = _$1;
var bind$1 = restArguments(function(func, context, args) {
if (!isFunction$1(func))
throw new TypeError("Bind must be called on a function");
var bound = restArguments(function(callArgs) {
return executeBound(func, bound, context, this, args.concat(callArgs));
});
return bound;
});
var isArrayLike = createSizePropertyCheck(getLength);
function flatten$1(input, depth, strict, output) {
output = output || [];
if (!depth && depth !== 0) {
depth = Infinity;
} else if (depth <= 0) {
return output.concat(input);
}
var idx = output.length;
for (var i = 0, length = getLength(input); i < length; i++) {
var value = input[i];
if (isArrayLike(value) && (isArray$4(value) || isArguments$1(value))) {
if (depth > 1) {
flatten$1(value, depth - 1, strict, output);
idx = output.length;
} else {
var j = 0, len2 = value.length;
while (j < len2)
output[idx++] = value[j++];
}
} else if (!strict) {
output[idx++] = value;
}
}
return output;
}
var bindAll = restArguments(function(obj, keys2) {
keys2 = flatten$1(keys2, false, false);
var index3 = keys2.length;
if (index3 < 1)
throw new Error("bindAll must be passed function names");
while (index3--) {
var key = keys2[index3];
obj[key] = bind$1(obj[key], obj);
}
return obj;
});
function memoize(func, hasher) {
var memoize2 = function(key) {
var cache = memoize2.cache;
var address = "" + (hasher ? hasher.apply(this, arguments) : key);
if (!has$1$1(cache, address))
cache[address] = func.apply(this, arguments);
return cache[address];
};
memoize2.cache = {};
return memoize2;
}
var delay = restArguments(function(func, wait, args) {
return setTimeout(function() {
return func.apply(null, args);
}, wait);
});
var defer = partial(delay, _$1, 1);
function throttle$1(func, wait, options) {
var timeout, context, args, result2;
var previous = 0;
if (!options)
options = {};
var later = function() {
previous = options.leading === false ? 0 : now();
timeout = null;
result2 = func.apply(context, args);
if (!timeout)
context = args = null;
};
var throttled = function() {
var _now = now();
if (!previous && options.leading === false)
previous = _now;
var remaining = wait - (_now - previous);
context = this;
args = arguments;
if (remaining <= 0 || remaining > wait) {
if (timeout) {
clearTimeout(timeout);
timeout = null;
}
previous = _now;
result2 = func.apply(context, args);
if (!timeout)
context = args = null;
} else if (!timeout && options.trailing !== false) {
timeout = setTimeout(later, remaining);
}
return result2;
};
throttled.cancel = function() {
clearTimeout(timeout);
previous = 0;
timeout = context = args = null;
};
return throttled;
}
function debounce$1(func, wait, immediate) {
var timeout, previous, args, result2, context;
var later = function() {
var passed = now() - previous;
if (wait > passed) {
timeout = setTimeout(later, wait - passed);
} else {
timeout = null;
if (!immediate)
result2 = func.apply(context, args);
if (!timeout)
args = context = null;
}
};
var debounced = restArguments(function(_args) {
context = this;
args = _args;
previous = now();
if (!timeout) {
timeout = setTimeout(later, wait);
if (immediate)
result2 = func.apply(context, args);
}
return result2;
});
debounced.cancel = function() {
clearTimeout(timeout);
timeout = args = context = null;
};
return debounced;
}
function wrap(func, wrapper3) {
return partial(wrapper3, func);
}
function negate(predicate) {
return function() {
return !predicate.apply(this, arguments);
};
}
function compose() {
var args = arguments;
var start3 = args.length - 1;
return function() {
var i = start3;
var result2 = args[start3].apply(this, arguments);
while (i--)
result2 = args[i].call(this, result2);
return result2;
};
}
function after(times2, func) {
return function() {
if (--times2 < 1) {
return func.apply(this, arguments);
}
};
}
function before(times2, func) {
var memo;
return function() {
if (--times2 > 0) {
memo = func.apply(this, arguments);
}
if (times2 <= 1)
func = null;
return memo;
};
}
var once = partial(before, 2);
function findKey(obj, predicate, context) {
predicate = cb(predicate, context);
var _keys = keys$1(obj), key;
for (var i = 0, length = _keys.length; i < length; i++) {
key = _keys[i];
if (predicate(obj[key], key, obj))
return key;
}
}
function createPredicateIndexFinder(dir) {
return function(array, predicate, context) {
predicate = cb(predicate, context);
var length = getLength(array);
var index3 = dir > 0 ? 0 : length - 1;
for (; index3 >= 0 && index3 < length; index3 += dir) {
if (predicate(array[index3], index3, array))
return index3;
}
return -1;
};
}
var findIndex = createPredicateIndexFinder(1);
var findLastIndex = createPredicateIndexFinder(-1);
function sortedIndex(array, obj, iteratee2, context) {
iteratee2 = cb(iteratee2, context, 1);
var value = iteratee2(obj);
var low = 0, high = getLength(array);
while (low < high) {
var mid = Math.floor((low + high) / 2);
if (iteratee2(array[mid]) < value)
low = mid + 1;
else
high = mid;
}
return low;
}
function createIndexFinder(dir, predicateFind, sortedIndex2) {
return function(array, item, idx) {
var i = 0, length = getLength(array);
if (typeof idx == "number") {
if (dir > 0) {
i = idx >= 0 ? idx : Math.max(idx + length, i);
} else {
length = idx >= 0 ? Math.min(idx + 1, length) : idx + length + 1;
}
} else if (sortedIndex2 && idx && length) {
idx = sortedIndex2(array, item);
return array[idx] === item ? idx : -1;
}
if (item !== item) {
idx = predicateFind(slice$1.call(array, i, length), isNaN$1);
return idx >= 0 ? idx + i : -1;
}
for (idx = dir > 0 ? i : length - 1; idx >= 0 && idx < length; idx += dir) {
if (array[idx] === item)
return idx;
}
return -1;
};
}
var indexOf$1 = createIndexFinder(1, findIndex, sortedIndex);
var lastIndexOf = createIndexFinder(-1, findLastIndex);
function find$1(obj, predicate, context) {
var keyFinder = isArrayLike(obj) ? findIndex : findKey;
var key = keyFinder(obj, predicate, context);
if (key !== void 0 && key !== -1)
return obj[key];
}
function findWhere(obj, attrs2) {
return find$1(obj, matcher(attrs2));
}
function each(obj, iteratee2, context) {
iteratee2 = optimizeCb(iteratee2, context);
var i, length;
if (isArrayLike(obj)) {
for (i = 0, length = obj.length; i < length; i++) {
iteratee2(obj[i], i, obj);
}
} else {
var _keys = keys$1(obj);
for (i = 0, length = _keys.length; i < length; i++) {
iteratee2(obj[_keys[i]], _keys[i], obj);
}
}
return obj;
}
function map(obj, iteratee2, context) {
iteratee2 = cb(iteratee2, context);
var _keys = !isArrayLike(obj) && keys$1(obj), length = (_keys || obj).length, results = Array(length);
for (var index3 = 0; index3 < length; index3++) {
var currentKey = _keys ? _keys[index3] : index3;
results[index3] = iteratee2(obj[currentKey], currentKey, obj);
}
return results;
}
function createReduce(dir) {
var reducer = function(obj, iteratee2, memo, initial2) {
var _keys = !isArrayLike(obj) && keys$1(obj), length = (_keys || obj).length, index3 = dir > 0 ? 0 : length - 1;
if (!initial2) {
memo = obj[_keys ? _keys[index3] : index3];
index3 += dir;
}
for (; index3 >= 0 && index3 < length; index3 += dir) {
var currentKey = _keys ? _keys[index3] : index3;
memo = iteratee2(memo, obj[currentKey], currentKey, obj);
}
return memo;
};
return function(obj, iteratee2, memo, context) {
var initial2 = arguments.length >= 3;
return reducer(obj, optimizeCb(iteratee2, context, 4), memo, initial2);
};
}
var reduce = createReduce(1);
var reduceRight = createReduce(-1);
function filter(obj, predicate, context) {
var results = [];
predicate = cb(predicate, context);
each(obj, function(value, index3, list) {
if (predicate(value, index3, list))
results.push(value);
});
return results;
}
function reject(obj, predicate, context) {
return filter(obj, negate(cb(predicate)), context);
}
function every(obj, predicate, context) {
predicate = cb(predicate, context);
var _keys = !isArrayLike(obj) && keys$1(obj), length = (_keys || obj).length;
for (var index3 = 0; index3 < length; index3++) {
var currentKey = _keys ? _keys[index3] : index3;
if (!predicate(obj[currentKey], currentKey, obj))
return false;
}
return true;
}
function some(obj, predicate, context) {
predicate = cb(predicate, context);
var _keys = !isArrayLike(obj) && keys$1(obj), length = (_keys || obj).length;
for (var index3 = 0; index3 < length; index3++) {
var currentKey = _keys ? _keys[index3] : index3;
if (predicate(obj[currentKey], currentKey, obj))
return true;
}
return false;
}
function contains(obj, item, fromIndex, guard) {
if (!isArrayLike(obj))
obj = values(obj);
if (typeof fromIndex != "number" || guard)
fromIndex = 0;
return indexOf$1(obj, item, fromIndex) >= 0;
}
var invoke = restArguments(function(obj, path, args) {
var contextPath, func;
if (isFunction$1(path)) {
func = path;
} else {
path = toPath(path);
contextPath = path.slice(0, -1);
path = path[path.length - 1];
}
return map(obj, function(context) {
var method = func;
if (!method) {
if (contextPath && contextPath.length) {
context = deepGet(context, contextPath);
}
if (context == null)
return void 0;
method = context[path];
}
return method == null ? method : method.apply(context, args);
});
});
function pluck(obj, key) {
return map(obj, property(key));
}
function where(obj, attrs2) {
return filter(obj, matcher(attrs2));
}
function max(obj, iteratee2, context) {
var result2 = -Infinity, lastComputed = -Infinity, value, computed;
if (iteratee2 == null || typeof iteratee2 == "number" && typeof obj[0] != "object" && obj != null) {
obj = isArrayLike(obj) ? obj : values(obj);
for (var i = 0, length = obj.length; i < length; i++) {
value = obj[i];
if (value != null && value > result2) {
result2 = value;
}
}
} else {
iteratee2 = cb(iteratee2, context);
each(obj, function(v, index3, list) {
computed = iteratee2(v, index3, list);
if (computed > lastComputed || computed === -Infinity && result2 === -Infinity) {
result2 = v;
lastComputed = computed;
}
});
}
return result2;
}
function min(obj, iteratee2, context) {
var result2 = Infinity, lastComputed = Infinity, value, computed;
if (iteratee2 == null || typeof iteratee2 == "number" && typeof obj[0] != "object" && obj != null) {
obj = isArrayLike(obj) ? obj : values(obj);
for (var i = 0, length = obj.length; i < length; i++) {
value = obj[i];
if (value != null && value < result2) {
result2 = value;
}
}
} else {
iteratee2 = cb(iteratee2, context);
each(obj, function(v, index3, list) {
computed = iteratee2(v, index3, list);
if (computed < lastComputed || computed === Infinity && result2 === Infinity) {
result2 = v;
lastComputed = computed;
}
});
}
return result2;
}
function sample(obj, n, guard) {
if (n == null || guard) {
if (!isArrayLike(obj))
obj = values(obj);
return obj[random(obj.length - 1)];
}
var sample2 = isArrayLike(obj) ? clone$1(obj) : values(obj);
var length = getLength(sample2);
n = Math.max(Math.min(n, length), 0);
var last2 = length - 1;
for (var index3 = 0; index3 < n; index3++) {
var rand = random(index3, last2);
var temp = sample2[index3];
sample2[index3] = sample2[rand];
sample2[rand] = temp;
}
return sample2.slice(0, n);
}
function shuffle(obj) {
return sample(obj, Infinity);
}
function sortBy(obj, iteratee2, context) {
var index3 = 0;
iteratee2 = cb(iteratee2, context);
return pluck(map(obj, function(value, key, list) {
return {
value,
index: index3++,
criteria: iteratee2(value, key, list)
};
}).sort(function(left, right) {
var a = left.criteria;
var b = right.criteria;
if (a !== b) {
if (a > b || a === void 0)
return 1;
if (a < b || b === void 0)
return -1;
}
return left.index - right.index;
}), "value");
}
function group(behavior, partition2) {
return function(obj, iteratee2, context) {
var result2 = partition2 ? [[], []] : {};
iteratee2 = cb(iteratee2, context);
each(obj, function(value, index3) {
var key = iteratee2(value, index3, obj);
behavior(result2, value, key);
});
return result2;
};
}
var groupBy = group(function(result2, value, key) {
if (has$1$1(result2, key))
result2[key].push(value);
else
result2[key] = [value];
});
var indexBy = group(function(result2, value, key) {
result2[key] = value;
});
var countBy = group(function(result2, value, key) {
if (has$1$1(result2, key))
result2[key]++;
else
result2[key] = 1;
});
var partition = group(function(result2, value, pass) {
result2[pass ? 0 : 1].push(value);
}, true);
var reStrSymbol = /[^\ud800-\udfff]|[\ud800-\udbff][\udc00-\udfff]|[\ud800-\udfff]/g;
function toArray(obj) {
if (!obj)
return [];
if (isArray$4(obj))
return slice$1.call(obj);
if (isString$1(obj)) {
return obj.match(reStrSymbol);
}
if (isArrayLike(obj))
return map(obj, identity);
return values(obj);
}
function size(obj) {
if (obj == null)
return 0;
return isArrayLike(obj) ? obj.length : keys$1(obj).length;
}
function keyInObj(value, key, obj) {
return key in obj;
}
var pick = restArguments(function(obj, keys2) {
var result2 = {}, iteratee2 = keys2[0];
if (obj == null)
return result2;
if (isFunction$1(iteratee2)) {
if (keys2.length > 1)
iteratee2 = optimizeCb(iteratee2, keys2[1]);
keys2 = allKeys(obj);
} else {
iteratee2 = keyInObj;
keys2 = flatten$1(keys2, false, false);
obj = Object(obj);
}
for (var i = 0, length = keys2.length; i < length; i++) {
var key = keys2[i];
var value = obj[key];
if (iteratee2(value, key, obj))
result2[key] = value;
}
return result2;
});
var omit = restArguments(function(obj, keys2) {
var iteratee2 = keys2[0], context;
if (isFunction$1(iteratee2)) {
iteratee2 = negate(iteratee2);
if (keys2.length > 1)
context = keys2[1];
} else {
keys2 = map(flatten$1(keys2, false, false), String);
iteratee2 = function(value, key) {
return !contains(keys2, key);
};
}
return pick(obj, iteratee2, context);
});
function initial(array, n, guard) {
return slice$1.call(array, 0, Math.max(0, array.length - (n == null || guard ? 1 : n)));
}
function first(array, n, guard) {
if (array == null || array.length < 1)
return n == null || guard ? void 0 : [];
if (n == null || guard)
return array[0];
return initial(array, array.length - n);
}
function rest(array, n, guard) {
return slice$1.call(array, n == null || guard ? 1 : n);
}
function last(array, n, guard) {
if (array == null || array.length < 1)
return n == null || guard ? void 0 : [];
if (n == null || guard)
return array[array.length - 1];
return rest(array, Math.max(0, array.length - n));
}
function compact$1(array) {
return filter(array, Boolean);
}
function flatten(array, depth) {
return flatten$1(array, depth, false);
}
var difference = restArguments(function(array, rest2) {
rest2 = flatten$1(rest2, true, true);
return filter(array, function(value) {
return !contains(rest2, value);
});
});
var without = restArguments(function(array, otherArrays) {
return difference(array, otherArrays);
});
function uniq(array, isSorted, iteratee2, context) {
if (!isBoolean$1(isSorted)) {
context = iteratee2;
iteratee2 = isSorted;
isSorted = false;
}
if (iteratee2 != null)
iteratee2 = cb(iteratee2, context);
var result2 = [];
var seen = [];
for (var i = 0, length = getLength(array); i < length; i++) {
var value = array[i], computed = iteratee2 ? iteratee2(value, i, array) : value;
if (isSorted && !iteratee2) {
if (!i || seen !== computed)
result2.push(value);
seen = computed;
} else if (iteratee2) {
if (!contains(seen, computed)) {
seen.push(computed);
result2.push(value);
}
} else if (!contains(result2, value)) {
result2.push(value);
}
}
return result2;
}
var union = restArguments(function(arrays) {
return uniq(flatten$1(arrays, true, true));
});
function intersection(array) {
var result2 = [];
var argsLength = arguments.length;
for (var i = 0, length = getLength(array); i < length; i++) {
var item = array[i];
if (contains(result2, item))
continue;
var j;
for (j = 1; j < argsLength; j++) {
if (!contains(arguments[j], item))
break;
}
if (j === argsLength)
result2.push(item);
}
return result2;
}
function unzip(array) {
var length = array && max(array, getLength).length || 0;
var result2 = Array(length);
for (var index3 = 0; index3 < length; index3++) {
result2[index3] = pluck(array, index3);
}
return result2;
}
var zip = restArguments(unzip);
function object(list, values2) {
var result2 = {};
for (var i = 0, length = getLength(list); i < length; i++) {
if (values2) {
result2[list[i]] = values2[i];
} else {
result2[list[i][0]] = list[i][1];
}
}
return result2;
}
function range(start3, stop2, step2) {
if (stop2 == null) {
stop2 = start3 || 0;
start3 = 0;
}
if (!step2) {
step2 = stop2 < start3 ? -1 : 1;
}
var length = Math.max(Math.ceil((stop2 - start3) / step2), 0);
var range2 = Array(length);
for (var idx = 0; idx < length; idx++, start3 += step2) {
range2[idx] = start3;
}
return range2;
}
function chunk(array, count) {
if (count == null || count < 1)
return [];
var result2 = [];
var i = 0, length = array.length;
while (i < length) {
result2.push(slice$1.call(array, i, i += count));
}
return result2;
}
function chainResult(instance, obj) {
return instance._chain ? _$1(obj).chain() : obj;
}
function mixin(obj) {
each(functions(obj), function(name) {
var func = _$1[name] = obj[name];
_$1.prototype[name] = function() {
var args = [this._wrapped];
push$1.apply(args, arguments);
return chainResult(this, func.apply(_$1, args));
};
});
return _$1;
}
each(["pop", "push", "reverse", "shift", "sort", "splice", "unshift"], function(name) {
var method = ArrayProto[name];
_$1.prototype[name] = function() {
var obj = this._wrapped;
if (obj != null) {
method.apply(obj, arguments);
if ((name === "shift" || name === "splice") && obj.length === 0) {
delete obj[0];
}
}
return chainResult(this, obj);
};
});
each(["concat", "join", "slice"], function(name) {
var method = ArrayProto[name];
_$1.prototype[name] = function() {
var obj = this._wrapped;
if (obj != null)
obj = method.apply(obj, arguments);
return chainResult(this, obj);
};
});
var allExports = {
__proto__: null,
VERSION,
restArguments,
isObject,
isNull,
isUndefined: isUndefined2,
isBoolean: isBoolean$1,
isElement: isElement$1,
isString: isString$1,
isNumber: isNumber$1,
isDate: isDate$1,
isRegExp: isRegExp$2,
isError: isError$1,
isSymbol: isSymbol$1,
isArrayBuffer,
isDataView: isDataView$1,
isArray: isArray$4,
isFunction: isFunction$1,
isArguments: isArguments$1,
isFinite: isFinite$1,
isNaN: isNaN$1,
isTypedArray: isTypedArray$1,
isEmpty,
isMatch,
isEqual,
isMap: isMap$1,
isWeakMap: isWeakMap$1,
isSet: isSet$1,
isWeakSet: isWeakSet$1,
keys: keys$1,
allKeys,
values,
pairs,
invert,
functions,
methods: functions,
extend: extend$1,
extendOwn,
assign: extendOwn,
defaults: defaults$4,
create: create$1,
clone: clone$1,
tap,
get: get3,
has: has$4,
mapObject,
identity,
constant,
noop: noop$1,
toPath: toPath$1,
property,
propertyOf,
matcher,
matches: matcher,
times,
random,
now,
escape: _escape,
unescape: _unescape,
templateSettings,
template,
result: result$1,
uniqueId,
chain,
iteratee,
partial,
bind: bind$1,
bindAll,
memoize,
delay,
defer,
throttle: throttle$1,
debounce: debounce$1,
wrap,
negate,
compose,
after,
before,
once,
findKey,
findIndex,
findLastIndex,
sortedIndex,
indexOf: indexOf$1,
lastIndexOf,
find: find$1,
detect: find$1,
findWhere,
each,
forEach: each,
map,
collect: map,
reduce,
foldl: reduce,
inject: reduce,
reduceRight,
foldr: reduceRight,
filter,
select: filter,
reject,
every,
all: every,
some,
any: some,
contains,
includes: contains,
include: contains,
invoke,
pluck,
where,
max,
min,
shuffle,
sample,
sortBy,
groupBy,
indexBy,
countBy,
partition,
toArray,
size,
pick,
omit,
first,
head: first,
take: first,
initial,
last,
rest,
tail: rest,
drop: rest,
compact: compact$1,
flatten,
without,
uniq,
unique: uniq,
union,
intersection,
difference,
unzip,
transpose: unzip,
zip,
object,
range,
chunk,
mixin,
default: _$1
};
var _ = mixin(allExports);
_._ = _;
function OrderedMap(content2) {
this.content = content2;
}
OrderedMap.prototype = {
constructor: OrderedMap,
find: function(key) {
for (var i = 0; i < this.content.length; i += 2)
if (this.content[i] === key)
return i;
return -1;
},
get: function(key) {
var found2 = this.find(key);
return found2 == -1 ? void 0 : this.content[found2 + 1];
},
update: function(key, value, newKey) {
var self2 = newKey && newKey != key ? this.remove(newKey) : this;
var found2 = self2.find(key), content2 = self2.content.slice();
if (found2 == -1) {
content2.push(newKey || key, value);
} else {
content2[found2 + 1] = value;
if (newKey)
content2[found2] = newKey;
}
return new OrderedMap(content2);
},
remove: function(key) {
var found2 = this.find(key);
if (found2 == -1)
return this;
var content2 = this.content.slice();
content2.splice(found2, 2);
return new OrderedMap(content2);
},
addToStart: function(key, value) {
return new OrderedMap([key, value].concat(this.remove(key).content));
},
addToEnd: function(key, value) {
var content2 = this.remove(key).content.slice();
content2.push(key, value);
return new OrderedMap(content2);
},
addBefore: function(place, key, value) {
var without2 = this.remove(key), content2 = without2.content.slice();
var found2 = without2.find(place);
content2.splice(found2 == -1 ? content2.length : found2, 0, key, value);
return new OrderedMap(content2);
},
forEach: function(f) {
for (var i = 0; i < this.content.length; i += 2)
f(this.content[i], this.content[i + 1]);
},
prepend: function(map16) {
map16 = OrderedMap.from(map16);
if (!map16.size)
return this;
return new OrderedMap(map16.content.concat(this.subtract(map16).content));
},
append: function(map16) {
map16 = OrderedMap.from(map16);
if (!map16.size)
return this;
return new OrderedMap(this.subtract(map16).content.concat(map16.content));
},
subtract: function(map16) {
var result2 = this;
map16 = OrderedMap.from(map16);
for (var i = 0; i < map16.content.length; i += 2)
result2 = result2.remove(map16.content[i]);
return result2;
},
get size() {
return this.content.length >> 1;
}
};
OrderedMap.from = function(value) {
if (value instanceof OrderedMap)
return value;
var content2 = [];
if (value)
for (var prop in value)
content2.push(prop, value[prop]);
return new OrderedMap(content2);
};
var orderedmap = OrderedMap;
function findDiffStart(a, b, pos) {
for (var i = 0; ; i++) {
if (i == a.childCount || i == b.childCount) {
return a.childCount == b.childCount ? null : pos;
}
var childA = a.child(i), childB = b.child(i);
if (childA == childB) {
pos += childA.nodeSize;
continue;
}
if (!childA.sameMarkup(childB)) {
return pos;
}
if (childA.isText && childA.text != childB.text) {
for (var j = 0; childA.text[j] == childB.text[j]; j++) {
pos++;
}
return pos;
}
if (childA.content.size || childB.content.size) {
var inner = findDiffStart(childA.content, childB.content, pos + 1);
if (inner != null) {
return inner;
}
}
pos += childA.nodeSize;
}
}
function findDiffEnd(a, b, posA, posB) {
for (var iA = a.childCount, iB = b.childCount; ; ) {
if (iA == 0 || iB == 0) {
return iA == iB ? null : {a: posA, b: posB};
}
var childA = a.child(--iA), childB = b.child(--iB), size2 = childA.nodeSize;
if (childA == childB) {
posA -= size2;
posB -= size2;
continue;
}
if (!childA.sameMarkup(childB)) {
return {a: posA, b: posB};
}
if (childA.isText && childA.text != childB.text) {
var same = 0, minSize = Math.min(childA.text.length, childB.text.length);
while (same < minSize && childA.text[childA.text.length - same - 1] == childB.text[childB.text.length - same - 1]) {
same++;
posA--;
posB--;
}
return {a: posA, b: posB};
}
if (childA.content.size || childB.content.size) {
var inner = findDiffEnd(childA.content, childB.content, posA - 1, posB - 1);
if (inner) {
return inner;
}
}
posA -= size2;
posB -= size2;
}
}
var Fragment = function Fragment2(content2, size2) {
this.content = content2;
this.size = size2 || 0;
if (size2 == null) {
for (var i = 0; i < content2.length; i++) {
this.size += content2[i].nodeSize;
}
}
};
var prototypeAccessors$5 = {firstChild: {configurable: true}, lastChild: {configurable: true}, childCount: {configurable: true}};
Fragment.prototype.nodesBetween = function nodesBetween(from4, to, f, nodeStart, parent) {
if (nodeStart === void 0)
nodeStart = 0;
for (var i = 0, pos = 0; pos < to; i++) {
var child3 = this.content[i], end2 = pos + child3.nodeSize;
if (end2 > from4 && f(child3, nodeStart + pos, parent, i) !== false && child3.content.size) {
var start3 = pos + 1;
child3.nodesBetween(Math.max(0, from4 - start3), Math.min(child3.content.size, to - start3), f, nodeStart + start3);
}
pos = end2;
}
};
Fragment.prototype.descendants = function descendants(f) {
this.nodesBetween(0, this.size, f);
};
Fragment.prototype.textBetween = function textBetween(from4, to, blockSeparator, leafText) {
var text3 = "", separated = true;
this.nodesBetween(from4, to, function(node4, pos) {
if (node4.isText) {
text3 += node4.text.slice(Math.max(from4, pos) - pos, to - pos);
separated = !blockSeparator;
} else if (node4.isLeaf && leafText) {
text3 += leafText;
separated = !blockSeparator;
} else if (!separated && node4.isBlock) {
text3 += blockSeparator;
separated = true;
}
}, 0);
return text3;
};
Fragment.prototype.append = function append(other) {
if (!other.size) {
return this;
}
if (!this.size) {
return other;
}
var last2 = this.lastChild, first2 = other.firstChild, content2 = this.content.slice(), i = 0;
if (last2.isText && last2.sameMarkup(first2)) {
content2[content2.length - 1] = last2.withText(last2.text + first2.text);
i = 1;
}
for (; i < other.content.length; i++) {
content2.push(other.content[i]);
}
return new Fragment(content2, this.size + other.size);
};
Fragment.prototype.cut = function cut(from4, to) {
if (to == null) {
to = this.size;
}
if (from4 == 0 && to == this.size) {
return this;
}
var result2 = [], size2 = 0;
if (to > from4) {
for (var i = 0, pos = 0; pos < to; i++) {
var child3 = this.content[i], end2 = pos + child3.nodeSize;
if (end2 > from4) {
if (pos < from4 || end2 > to) {
if (child3.isText) {
child3 = child3.cut(Math.max(0, from4 - pos), Math.min(child3.text.length, to - pos));
} else {
child3 = child3.cut(Math.max(0, from4 - pos - 1), Math.min(child3.content.size, to - pos - 1));
}
}
result2.push(child3);
size2 += child3.nodeSize;
}
pos = end2;
}
}
return new Fragment(result2, size2);
};
Fragment.prototype.cutByIndex = function cutByIndex(from4, to) {
if (from4 == to) {
return Fragment.empty;
}
if (from4 == 0 && to == this.content.length) {
return this;
}
return new Fragment(this.content.slice(from4, to));
};
Fragment.prototype.replaceChild = function replaceChild(index3, node4) {
var current = this.content[index3];
if (current == node4) {
return this;
}
var copy5 = this.content.slice();
var size2 = this.size + node4.nodeSize - current.nodeSize;
copy5[index3] = node4;
return new Fragment(copy5, size2);
};
Fragment.prototype.addToStart = function addToStart(node4) {
return new Fragment([node4].concat(this.content), this.size + node4.nodeSize);
};
Fragment.prototype.addToEnd = function addToEnd(node4) {
return new Fragment(this.content.concat(node4), this.size + node4.nodeSize);
};
Fragment.prototype.eq = function eq2(other) {
if (this.content.length != other.content.length) {
return false;
}
for (var i = 0; i < this.content.length; i++) {
if (!this.content[i].eq(other.content[i])) {
return false;
}
}
return true;
};
prototypeAccessors$5.firstChild.get = function() {
return this.content.length ? this.content[0] : null;
};
prototypeAccessors$5.lastChild.get = function() {
return this.content.length ? this.content[this.content.length - 1] : null;
};
prototypeAccessors$5.childCount.get = function() {
return this.content.length;
};
Fragment.prototype.child = function child(index3) {
var found2 = this.content[index3];
if (!found2) {
throw new RangeError("Index " + index3 + " out of range for " + this);
}
return found2;
};
Fragment.prototype.maybeChild = function maybeChild(index3) {
return this.content[index3];
};
Fragment.prototype.forEach = function forEach(f) {
for (var i = 0, p = 0; i < this.content.length; i++) {
var child3 = this.content[i];
f(child3, p, i);
p += child3.nodeSize;
}
};
Fragment.prototype.findDiffStart = function findDiffStart$1(other, pos) {
if (pos === void 0)
pos = 0;
return findDiffStart(this, other, pos);
};
Fragment.prototype.findDiffEnd = function findDiffEnd$1(other, pos, otherPos) {
if (pos === void 0)
pos = this.size;
if (otherPos === void 0)
otherPos = other.size;
return findDiffEnd(this, other, pos, otherPos);
};
Fragment.prototype.findIndex = function findIndex2(pos, round) {
if (round === void 0)
round = -1;
if (pos == 0) {
return retIndex(0, pos);
}
if (pos == this.size) {
return retIndex(this.content.length, pos);
}
if (pos > this.size || pos < 0) {
throw new RangeError("Position " + pos + " outside of fragment (" + this + ")");
}
for (var i = 0, curPos = 0; ; i++) {
var cur = this.child(i), end2 = curPos + cur.nodeSize;
if (end2 >= pos) {
if (end2 == pos || round > 0) {
return retIndex(i + 1, end2);
}
return retIndex(i, curPos);
}
curPos = end2;
}
};
Fragment.prototype.toString = function toString2() {
return "<" + this.toStringInner() + ">";
};
Fragment.prototype.toStringInner = function toStringInner() {
return this.content.join(", ");
};
Fragment.prototype.toJSON = function toJSON() {
return this.content.length ? this.content.map(function(n) {
return n.toJSON();
}) : null;
};
Fragment.fromJSON = function fromJSON(schema, value) {
if (!value) {
return Fragment.empty;
}
if (!Array.isArray(value)) {
throw new RangeError("Invalid input for Fragment.fromJSON");
}
return new Fragment(value.map(schema.nodeFromJSON));
};
Fragment.fromArray = function fromArray(array) {
if (!array.length) {
return Fragment.empty;
}
var joined, size2 = 0;
for (var i = 0; i < array.length; i++) {
var node4 = array[i];
size2 += node4.nodeSize;
if (i && node4.isText && array[i - 1].sameMarkup(node4)) {
if (!joined) {
joined = array.slice(0, i);
}
joined[joined.length - 1] = node4.withText(joined[joined.length - 1].text + node4.text);
} else if (joined) {
joined.push(node4);
}
}
return new Fragment(joined || array, size2);
};
Fragment.from = function from(nodes) {
if (!nodes) {
return Fragment.empty;
}
if (nodes instanceof Fragment) {
return nodes;
}
if (Array.isArray(nodes)) {
return this.fromArray(nodes);
}
if (nodes.attrs) {
return new Fragment([nodes], nodes.nodeSize);
}
throw new RangeError("Can not convert " + nodes + " to a Fragment" + (nodes.nodesBetween ? " (looks like multiple versions of prosemirror-model were loaded)" : ""));
};
Object.defineProperties(Fragment.prototype, prototypeAccessors$5);
var found = {index: 0, offset: 0};
function retIndex(index3, offset2) {
found.index = index3;
found.offset = offset2;
return found;
}
Fragment.empty = new Fragment([], 0);
function compareDeep(a, b) {
if (a === b) {
return true;
}
if (!(a && typeof a == "object") || !(b && typeof b == "object")) {
return false;
}
var array = Array.isArray(a);
if (Array.isArray(b) != array) {
return false;
}
if (array) {
if (a.length != b.length) {
return false;
}
for (var i = 0; i < a.length; i++) {
if (!compareDeep(a[i], b[i])) {
return false;
}
}
} else {
for (var p in a) {
if (!(p in b) || !compareDeep(a[p], b[p])) {
return false;
}
}
for (var p$1 in b) {
if (!(p$1 in a)) {
return false;
}
}
}
return true;
}
var Mark$1 = function Mark(type, attrs2) {
this.type = type;
this.attrs = attrs2;
};
Mark$1.prototype.addToSet = function addToSet(set3) {
var copy5, placed = false;
for (var i = 0; i < set3.length; i++) {
var other = set3[i];
if (this.eq(other)) {
return set3;
}
if (this.type.excludes(other.type)) {
if (!copy5) {
copy5 = set3.slice(0, i);
}
} else if (other.type.excludes(this.type)) {
return set3;
} else {
if (!placed && other.type.rank > this.type.rank) {
if (!copy5) {
copy5 = set3.slice(0, i);
}
copy5.push(this);
placed = true;
}
if (copy5) {
copy5.push(other);
}
}
}
if (!copy5) {
copy5 = set3.slice();
}
if (!placed) {
copy5.push(this);
}
return copy5;
};
Mark$1.prototype.removeFromSet = function removeFromSet(set3) {
for (var i = 0; i < set3.length; i++) {
if (this.eq(set3[i])) {
return set3.slice(0, i).concat(set3.slice(i + 1));
}
}
return set3;
};
Mark$1.prototype.isInSet = function isInSet(set3) {
for (var i = 0; i < set3.length; i++) {
if (this.eq(set3[i])) {
return true;
}
}
return false;
};
Mark$1.prototype.eq = function eq3(other) {
return this == other || this.type == other.type && compareDeep(this.attrs, other.attrs);
};
Mark$1.prototype.toJSON = function toJSON2() {
var obj = {type: this.type.name};
for (var _2 in this.attrs) {
obj.attrs = this.attrs;
break;
}
return obj;
};
Mark$1.fromJSON = function fromJSON2(schema, json) {
if (!json) {
throw new RangeError("Invalid input for Mark.fromJSON");
}
var type = schema.marks[json.type];
if (!type) {
throw new RangeError("There is no mark type " + json.type + " in this schema");
}
return type.create(json.attrs);
};
Mark$1.sameSet = function sameSet(a, b) {
if (a == b) {
return true;
}
if (a.length != b.length) {
return false;
}
for (var i = 0; i < a.length; i++) {
if (!a[i].eq(b[i])) {
return false;
}
}
return true;
};
Mark$1.setFrom = function setFrom(marks2) {
if (!marks2 || marks2.length == 0) {
return Mark$1.none;
}
if (marks2 instanceof Mark$1) {
return [marks2];
}
var copy5 = marks2.slice();
copy5.sort(function(a, b) {
return a.type.rank - b.type.rank;
});
return copy5;
};
Mark$1.none = [];
function ReplaceError(message) {
var err2 = Error.call(this, message);
err2.__proto__ = ReplaceError.prototype;
return err2;
}
ReplaceError.prototype = Object.create(Error.prototype);
ReplaceError.prototype.constructor = ReplaceError;
ReplaceError.prototype.name = "ReplaceError";
var Slice = function Slice2(content2, openStart, openEnd) {
this.content = content2;
this.openStart = openStart;
this.openEnd = openEnd;
};
var prototypeAccessors$1$3 = {size: {configurable: true}};
prototypeAccessors$1$3.size.get = function() {
return this.content.size - this.openStart - this.openEnd;
};
Slice.prototype.insertAt = function insertAt(pos, fragment) {
var content2 = insertInto(this.content, pos + this.openStart, fragment, null);
return content2 && new Slice(content2, this.openStart, this.openEnd);
};
Slice.prototype.removeBetween = function removeBetween(from4, to) {
return new Slice(removeRange(this.content, from4 + this.openStart, to + this.openStart), this.openStart, this.openEnd);
};
Slice.prototype.eq = function eq4(other) {
return this.content.eq(other.content) && this.openStart == other.openStart && this.openEnd == other.openEnd;
};
Slice.prototype.toString = function toString3() {
return this.content + "(" + this.openStart + "," + this.openEnd + ")";
};
Slice.prototype.toJSON = function toJSON3() {
if (!this.content.size) {
return null;
}
var json = {content: this.content.toJSON()};
if (this.openStart > 0) {
json.openStart = this.openStart;
}
if (this.openEnd > 0) {
json.openEnd = this.openEnd;
}
return json;
};
Slice.fromJSON = function fromJSON3(schema, json) {
if (!json) {
return Slice.empty;
}
var openStart = json.openStart || 0, openEnd = json.openEnd || 0;
if (typeof openStart != "number" || typeof openEnd != "number") {
throw new RangeError("Invalid input for Slice.fromJSON");
}
return new Slice(Fragment.fromJSON(schema, json.content), openStart, openEnd);
};
Slice.maxOpen = function maxOpen(fragment, openIsolating) {
if (openIsolating === void 0)
openIsolating = true;
var openStart = 0, openEnd = 0;
for (var n = fragment.firstChild; n && !n.isLeaf && (openIsolating || !n.type.spec.isolating); n = n.firstChild) {
openStart++;
}
for (var n$1 = fragment.lastChild; n$1 && !n$1.isLeaf && (openIsolating || !n$1.type.spec.isolating); n$1 = n$1.lastChild) {
openEnd++;
}
return new Slice(fragment, openStart, openEnd);
};
Object.defineProperties(Slice.prototype, prototypeAccessors$1$3);
function removeRange(content2, from4, to) {
var ref2 = content2.findIndex(from4);
var index3 = ref2.index;
var offset2 = ref2.offset;
var child3 = content2.maybeChild(index3);
var ref$12 = content2.findIndex(to);
var indexTo = ref$12.index;
var offsetTo = ref$12.offset;
if (offset2 == from4 || child3.isText) {
if (offsetTo != to && !content2.child(indexTo).isText) {
throw new RangeError("Removing non-flat range");
}
return content2.cut(0, from4).append(content2.cut(to));
}
if (index3 != indexTo) {
throw new RangeError("Removing non-flat range");
}
return content2.replaceChild(index3, child3.copy(removeRange(child3.content, from4 - offset2 - 1, to - offset2 - 1)));
}
function insertInto(content2, dist, insert2, parent) {
var ref2 = content2.findIndex(dist);
var index3 = ref2.index;
var offset2 = ref2.offset;
var child3 = content2.maybeChild(index3);
if (offset2 == dist || child3.isText) {
if (parent && !parent.canReplace(index3, index3, insert2)) {
return null;
}
return content2.cut(0, dist).append(insert2).append(content2.cut(dist));
}
var inner = insertInto(child3.content, dist - offset2 - 1, insert2);
return inner && content2.replaceChild(index3, child3.copy(inner));
}
Slice.empty = new Slice(Fragment.empty, 0, 0);
function replace$1($from, $to, slice5) {
if (slice5.openStart > $from.depth) {
throw new ReplaceError("Inserted content deeper than insertion position");
}
if ($from.depth - slice5.openStart != $to.depth - slice5.openEnd) {
throw new ReplaceError("Inconsistent open depths");
}
return replaceOuter($from, $to, slice5, 0);
}
function replaceOuter($from, $to, slice5, depth) {
var index3 = $from.index(depth), node4 = $from.node(depth);
if (index3 == $to.index(depth) && depth < $from.depth - slice5.openStart) {
var inner = replaceOuter($from, $to, slice5, depth + 1);
return node4.copy(node4.content.replaceChild(index3, inner));
} else if (!slice5.content.size) {
return close$1(node4, replaceTwoWay($from, $to, depth));
} else if (!slice5.openStart && !slice5.openEnd && $from.depth == depth && $to.depth == depth) {
var parent = $from.parent, content2 = parent.content;
return close$1(parent, content2.cut(0, $from.parentOffset).append(slice5.content).append(content2.cut($to.parentOffset)));
} else {
var ref2 = prepareSliceForReplace(slice5, $from);
var start3 = ref2.start;
var end2 = ref2.end;
return close$1(node4, replaceThreeWay($from, start3, end2, $to, depth));
}
}
function checkJoin(main, sub) {
if (!sub.type.compatibleContent(main.type)) {
throw new ReplaceError("Cannot join " + sub.type.name + " onto " + main.type.name);
}
}
function joinable$1($before, $after, depth) {
var node4 = $before.node(depth);
checkJoin(node4, $after.node(depth));
return node4;
}
function addNode(child3, target2) {
var last2 = target2.length - 1;
if (last2 >= 0 && child3.isText && child3.sameMarkup(target2[last2])) {
target2[last2] = child3.withText(target2[last2].text + child3.text);
} else {
target2.push(child3);
}
}
function addRange($start, $end, depth, target2) {
var node4 = ($end || $start).node(depth);
var startIndex = 0, endIndex = $end ? $end.index(depth) : node4.childCount;
if ($start) {
startIndex = $start.index(depth);
if ($start.depth > depth) {
startIndex++;
} else if ($start.textOffset) {
addNode($start.nodeAfter, target2);
startIndex++;
}
}
for (var i = startIndex; i < endIndex; i++) {
addNode(node4.child(i), target2);
}
if ($end && $end.depth == depth && $end.textOffset) {
addNode($end.nodeBefore, target2);
}
}
function close$1(node4, content2) {
if (!node4.type.validContent(content2)) {
throw new ReplaceError("Invalid content for node " + node4.type.name);
}
return node4.copy(content2);
}
function replaceThreeWay($from, $start, $end, $to, depth) {
var openStart = $from.depth > depth && joinable$1($from, $start, depth + 1);
var openEnd = $to.depth > depth && joinable$1($end, $to, depth + 1);
var content2 = [];
addRange(null, $from, depth, content2);
if (openStart && openEnd && $start.index(depth) == $end.index(depth)) {
checkJoin(openStart, openEnd);
addNode(close$1(openStart, replaceThreeWay($from, $start, $end, $to, depth + 1)), content2);
} else {
if (openStart) {
addNode(close$1(openStart, replaceTwoWay($from, $start, depth + 1)), content2);
}
addRange($start, $end, depth, content2);
if (openEnd) {
addNode(close$1(openEnd, replaceTwoWay($end, $to, depth + 1)), content2);
}
}
addRange($to, null, depth, content2);
return new Fragment(content2);
}
function replaceTwoWay($from, $to, depth) {
var content2 = [];
addRange(null, $from, depth, content2);
if ($from.depth > depth) {
var type = joinable$1($from, $to, depth + 1);
addNode(close$1(type, replaceTwoWay($from, $to, depth + 1)), content2);
}
addRange($to, null, depth, content2);
return new Fragment(content2);
}
function prepareSliceForReplace(slice5, $along) {
var extra = $along.depth - slice5.openStart, parent = $along.node(extra);
var node4 = parent.copy(slice5.content);
for (var i = extra - 1; i >= 0; i--) {
node4 = $along.node(i).copy(Fragment.from(node4));
}
return {
start: node4.resolveNoCache(slice5.openStart + extra),
end: node4.resolveNoCache(node4.content.size - slice5.openEnd - extra)
};
}
var ResolvedPos = function ResolvedPos2(pos, path, parentOffset) {
this.pos = pos;
this.path = path;
this.depth = path.length / 3 - 1;
this.parentOffset = parentOffset;
};
var prototypeAccessors$2$1 = {parent: {configurable: true}, doc: {configurable: true}, textOffset: {configurable: true}, nodeAfter: {configurable: true}, nodeBefore: {configurable: true}};
ResolvedPos.prototype.resolveDepth = function resolveDepth(val) {
if (val == null) {
return this.depth;
}
if (val < 0) {
return this.depth + val;
}
return val;
};
prototypeAccessors$2$1.parent.get = function() {
return this.node(this.depth);
};
prototypeAccessors$2$1.doc.get = function() {
return this.node(0);
};
ResolvedPos.prototype.node = function node(depth) {
return this.path[this.resolveDepth(depth) * 3];
};
ResolvedPos.prototype.index = function index(depth) {
return this.path[this.resolveDepth(depth) * 3 + 1];
};
ResolvedPos.prototype.indexAfter = function indexAfter(depth) {
depth = this.resolveDepth(depth);
return this.index(depth) + (depth == this.depth && !this.textOffset ? 0 : 1);
};
ResolvedPos.prototype.start = function start(depth) {
depth = this.resolveDepth(depth);
return depth == 0 ? 0 : this.path[depth * 3 - 1] + 1;
};
ResolvedPos.prototype.end = function end(depth) {
depth = this.resolveDepth(depth);
return this.start(depth) + this.node(depth).content.size;
};
ResolvedPos.prototype.before = function before2(depth) {
depth = this.resolveDepth(depth);
if (!depth) {
throw new RangeError("There is no position before the top-level node");
}
return depth == this.depth + 1 ? this.pos : this.path[depth * 3 - 1];
};
ResolvedPos.prototype.after = function after2(depth) {
depth = this.resolveDepth(depth);
if (!depth) {
throw new RangeError("There is no position after the top-level node");
}
return depth == this.depth + 1 ? this.pos : this.path[depth * 3 - 1] + this.path[depth * 3].nodeSize;
};
prototypeAccessors$2$1.textOffset.get = function() {
return this.pos - this.path[this.path.length - 1];
};
prototypeAccessors$2$1.nodeAfter.get = function() {
var parent = this.parent, index3 = this.index(this.depth);
if (index3 == parent.childCount) {
return null;
}
var dOff = this.pos - this.path[this.path.length - 1], child3 = parent.child(index3);
return dOff ? parent.child(index3).cut(dOff) : child3;
};
prototypeAccessors$2$1.nodeBefore.get = function() {
var index3 = this.index(this.depth);
var dOff = this.pos - this.path[this.path.length - 1];
if (dOff) {
return this.parent.child(index3).cut(0, dOff);
}
return index3 == 0 ? null : this.parent.child(index3 - 1);
};
ResolvedPos.prototype.posAtIndex = function posAtIndex(index3, depth) {
depth = this.resolveDepth(depth);
var node4 = this.path[depth * 3], pos = depth == 0 ? 0 : this.path[depth * 3 - 1] + 1;
for (var i = 0; i < index3; i++) {
pos += node4.child(i).nodeSize;
}
return pos;
};
ResolvedPos.prototype.marks = function marks() {
var parent = this.parent, index3 = this.index();
if (parent.content.size == 0) {
return Mark$1.none;
}
if (this.textOffset) {
return parent.child(index3).marks;
}
var main = parent.maybeChild(index3 - 1), other = parent.maybeChild(index3);
if (!main) {
var tmp = main;
main = other;
other = tmp;
}
var marks2 = main.marks;
for (var i = 0; i < marks2.length; i++) {
if (marks2[i].type.spec.inclusive === false && (!other || !marks2[i].isInSet(other.marks))) {
marks2 = marks2[i--].removeFromSet(marks2);
}
}
return marks2;
};
ResolvedPos.prototype.marksAcross = function marksAcross($end) {
var after3 = this.parent.maybeChild(this.index());
if (!after3 || !after3.isInline) {
return null;
}
var marks2 = after3.marks, next2 = $end.parent.maybeChild($end.index());
for (var i = 0; i < marks2.length; i++) {
if (marks2[i].type.spec.inclusive === false && (!next2 || !marks2[i].isInSet(next2.marks))) {
marks2 = marks2[i--].removeFromSet(marks2);
}
}
return marks2;
};
ResolvedPos.prototype.sharedDepth = function sharedDepth(pos) {
for (var depth = this.depth; depth > 0; depth--) {
if (this.start(depth) <= pos && this.end(depth) >= pos) {
return depth;
}
}
return 0;
};
ResolvedPos.prototype.blockRange = function blockRange(other, pred) {
if (other === void 0)
other = this;
if (other.pos < this.pos) {
return other.blockRange(this);
}
for (var d = this.depth - (this.parent.inlineContent || this.pos == other.pos ? 1 : 0); d >= 0; d--) {
if (other.pos <= this.end(d) && (!pred || pred(this.node(d)))) {
return new NodeRange(this, other, d);
}
}
};
ResolvedPos.prototype.sameParent = function sameParent(other) {
return this.pos - this.parentOffset == other.pos - other.parentOffset;
};
ResolvedPos.prototype.max = function max2(other) {
return other.pos > this.pos ? other : this;
};
ResolvedPos.prototype.min = function min2(other) {
return other.pos < this.pos ? other : this;
};
ResolvedPos.prototype.toString = function toString4() {
var str2 = "";
for (var i = 1; i <= this.depth; i++) {
str2 += (str2 ? "/" : "") + this.node(i).type.name + "_" + this.index(i - 1);
}
return str2 + ":" + this.parentOffset;
};
ResolvedPos.resolve = function resolve2(doc2, pos) {
if (!(pos >= 0 && pos <= doc2.content.size)) {
throw new RangeError("Position " + pos + " out of range");
}
var path = [];
var start3 = 0, parentOffset = pos;
for (var node4 = doc2; ; ) {
var ref2 = node4.content.findIndex(parentOffset);
var index3 = ref2.index;
var offset2 = ref2.offset;
var rem = parentOffset - offset2;
path.push(node4, index3, start3 + offset2);
if (!rem) {
break;
}
node4 = node4.child(index3);
if (node4.isText) {
break;
}
parentOffset = rem - 1;
start3 += offset2 + 1;
}
return new ResolvedPos(pos, path, parentOffset);
};
ResolvedPos.resolveCached = function resolveCached(doc2, pos) {
for (var i = 0; i < resolveCache.length; i++) {
var cached2 = resolveCache[i];
if (cached2.pos == pos && cached2.doc == doc2) {
return cached2;
}
}
var result2 = resolveCache[resolveCachePos] = ResolvedPos.resolve(doc2, pos);
resolveCachePos = (resolveCachePos + 1) % resolveCacheSize;
return result2;
};
Object.defineProperties(ResolvedPos.prototype, prototypeAccessors$2$1);
var resolveCache = [], resolveCachePos = 0, resolveCacheSize = 12;
var NodeRange = function NodeRange2($from, $to, depth) {
this.$from = $from;
this.$to = $to;
this.depth = depth;
};
var prototypeAccessors$1$1$1 = {start: {configurable: true}, end: {configurable: true}, parent: {configurable: true}, startIndex: {configurable: true}, endIndex: {configurable: true}};
prototypeAccessors$1$1$1.start.get = function() {
return this.$from.before(this.depth + 1);
};
prototypeAccessors$1$1$1.end.get = function() {
return this.$to.after(this.depth + 1);
};
prototypeAccessors$1$1$1.parent.get = function() {
return this.$from.node(this.depth);
};
prototypeAccessors$1$1$1.startIndex.get = function() {
return this.$from.index(this.depth);
};
prototypeAccessors$1$1$1.endIndex.get = function() {
return this.$to.indexAfter(this.depth);
};
Object.defineProperties(NodeRange.prototype, prototypeAccessors$1$1$1);
var emptyAttrs = Object.create(null);
var Node$2 = function Node2(type, attrs2, content2, marks2) {
this.type = type;
this.attrs = attrs2;
this.content = content2 || Fragment.empty;
this.marks = marks2 || Mark$1.none;
};
var prototypeAccessors$3$1 = {nodeSize: {configurable: true}, childCount: {configurable: true}, textContent: {configurable: true}, firstChild: {configurable: true}, lastChild: {configurable: true}, isBlock: {configurable: true}, isTextblock: {configurable: true}, inlineContent: {configurable: true}, isInline: {configurable: true}, isText: {configurable: true}, isLeaf: {configurable: true}, isAtom: {configurable: true}};
prototypeAccessors$3$1.nodeSize.get = function() {
return this.isLeaf ? 1 : 2 + this.content.size;
};
prototypeAccessors$3$1.childCount.get = function() {
return this.content.childCount;
};
Node$2.prototype.child = function child2(index3) {
return this.content.child(index3);
};
Node$2.prototype.maybeChild = function maybeChild2(index3) {
return this.content.maybeChild(index3);
};
Node$2.prototype.forEach = function forEach2(f) {
this.content.forEach(f);
};
Node$2.prototype.nodesBetween = function nodesBetween2(from4, to, f, startPos) {
if (startPos === void 0)
startPos = 0;
this.content.nodesBetween(from4, to, f, startPos, this);
};
Node$2.prototype.descendants = function descendants2(f) {
this.nodesBetween(0, this.content.size, f);
};
prototypeAccessors$3$1.textContent.get = function() {
return this.textBetween(0, this.content.size, "");
};
Node$2.prototype.textBetween = function textBetween2(from4, to, blockSeparator, leafText) {
return this.content.textBetween(from4, to, blockSeparator, leafText);
};
prototypeAccessors$3$1.firstChild.get = function() {
return this.content.firstChild;
};
prototypeAccessors$3$1.lastChild.get = function() {
return this.content.lastChild;
};
Node$2.prototype.eq = function eq5(other) {
return this == other || this.sameMarkup(other) && this.content.eq(other.content);
};
Node$2.prototype.sameMarkup = function sameMarkup(other) {
return this.hasMarkup(other.type, other.attrs, other.marks);
};
Node$2.prototype.hasMarkup = function hasMarkup(type, attrs2, marks2) {
return this.type == type && compareDeep(this.attrs, attrs2 || type.defaultAttrs || emptyAttrs) && Mark$1.sameSet(this.marks, marks2 || Mark$1.none);
};
Node$2.prototype.copy = function copy(content2) {
if (content2 === void 0)
content2 = null;
if (content2 == this.content) {
return this;
}
return new this.constructor(this.type, this.attrs, content2, this.marks);
};
Node$2.prototype.mark = function mark(marks2) {
return marks2 == this.marks ? this : new this.constructor(this.type, this.attrs, this.content, marks2);
};
Node$2.prototype.cut = function cut2(from4, to) {
if (from4 == 0 && to == this.content.size) {
return this;
}
return this.copy(this.content.cut(from4, to));
};
Node$2.prototype.slice = function slice(from4, to, includeParents) {
if (to === void 0)
to = this.content.size;
if (includeParents === void 0)
includeParents = false;
if (from4 == to) {
return Slice.empty;
}
var $from = this.resolve(from4), $to = this.resolve(to);
var depth = includeParents ? 0 : $from.sharedDepth(to);
var start3 = $from.start(depth), node4 = $from.node(depth);
var content2 = node4.content.cut($from.pos - start3, $to.pos - start3);
return new Slice(content2, $from.depth - depth, $to.depth - depth);
};
Node$2.prototype.replace = function replace$1$1(from4, to, slice5) {
return replace$1(this.resolve(from4), this.resolve(to), slice5);
};
Node$2.prototype.nodeAt = function nodeAt(pos) {
for (var node4 = this; ; ) {
var ref2 = node4.content.findIndex(pos);
var index3 = ref2.index;
var offset2 = ref2.offset;
node4 = node4.maybeChild(index3);
if (!node4) {
return null;
}
if (offset2 == pos || node4.isText) {
return node4;
}
pos -= offset2 + 1;
}
};
Node$2.prototype.childAfter = function childAfter(pos) {
var ref2 = this.content.findIndex(pos);
var index3 = ref2.index;
var offset2 = ref2.offset;
return {node: this.content.maybeChild(index3), index: index3, offset: offset2};
};
Node$2.prototype.childBefore = function childBefore(pos) {
if (pos == 0) {
return {node: null, index: 0, offset: 0};
}
var ref2 = this.content.findIndex(pos);
var index3 = ref2.index;
var offset2 = ref2.offset;
if (offset2 < pos) {
return {node: this.content.child(index3), index: index3, offset: offset2};
}
var node4 = this.content.child(index3 - 1);
return {node: node4, index: index3 - 1, offset: offset2 - node4.nodeSize};
};
Node$2.prototype.resolve = function resolve3(pos) {
return ResolvedPos.resolveCached(this, pos);
};
Node$2.prototype.resolveNoCache = function resolveNoCache(pos) {
return ResolvedPos.resolve(this, pos);
};
Node$2.prototype.rangeHasMark = function rangeHasMark(from4, to, type) {
var found2 = false;
if (to > from4) {
this.nodesBetween(from4, to, function(node4) {
if (type.isInSet(node4.marks)) {
found2 = true;
}
return !found2;
});
}
return found2;
};
prototypeAccessors$3$1.isBlock.get = function() {
return this.type.isBlock;
};
prototypeAccessors$3$1.isTextblock.get = function() {
return this.type.isTextblock;
};
prototypeAccessors$3$1.inlineContent.get = function() {
return this.type.inlineContent;
};
prototypeAccessors$3$1.isInline.get = function() {
return this.type.isInline;
};
prototypeAccessors$3$1.isText.get = function() {
return this.type.isText;
};
prototypeAccessors$3$1.isLeaf.get = function() {
return this.type.isLeaf;
};
prototypeAccessors$3$1.isAtom.get = function() {
return this.type.isAtom;
};
Node$2.prototype.toString = function toString5() {
if (this.type.spec.toDebugString) {
return this.type.spec.toDebugString(this);
}
var name = this.type.name;
if (this.content.size) {
name += "(" + this.content.toStringInner() + ")";
}
return wrapMarks(this.marks, name);
};
Node$2.prototype.contentMatchAt = function contentMatchAt(index3) {
var match3 = this.type.contentMatch.matchFragment(this.content, 0, index3);
if (!match3) {
throw new Error("Called contentMatchAt on a node with invalid content");
}
return match3;
};
Node$2.prototype.canReplace = function canReplace(from4, to, replacement, start3, end2) {
if (replacement === void 0)
replacement = Fragment.empty;
if (start3 === void 0)
start3 = 0;
if (end2 === void 0)
end2 = replacement.childCount;
var one = this.contentMatchAt(from4).matchFragment(replacement, start3, end2);
var two = one && one.matchFragment(this.content, to);
if (!two || !two.validEnd) {
return false;
}
for (var i = start3; i < end2; i++) {
if (!this.type.allowsMarks(replacement.child(i).marks)) {
return false;
}
}
return true;
};
Node$2.prototype.canReplaceWith = function canReplaceWith(from4, to, type, marks2) {
if (marks2 && !this.type.allowsMarks(marks2)) {
return false;
}
var start3 = this.contentMatchAt(from4).matchType(type);
var end2 = start3 && start3.matchFragment(this.content, to);
return end2 ? end2.validEnd : false;
};
Node$2.prototype.canAppend = function canAppend(other) {
if (other.content.size) {
return this.canReplace(this.childCount, this.childCount, other.content);
} else {
return this.type.compatibleContent(other.type);
}
};
Node$2.prototype.check = function check() {
if (!this.type.validContent(this.content)) {
throw new RangeError("Invalid content for node " + this.type.name + ": " + this.content.toString().slice(0, 50));
}
this.content.forEach(function(node4) {
return node4.check();
});
};
Node$2.prototype.toJSON = function toJSON4() {
var obj = {type: this.type.name};
for (var _2 in this.attrs) {
obj.attrs = this.attrs;
break;
}
if (this.content.size) {
obj.content = this.content.toJSON();
}
if (this.marks.length) {
obj.marks = this.marks.map(function(n) {
return n.toJSON();
});
}
return obj;
};
Node$2.fromJSON = function fromJSON4(schema, json) {
if (!json) {
throw new RangeError("Invalid input for Node.fromJSON");
}
var marks2 = null;
if (json.marks) {
if (!Array.isArray(json.marks)) {
throw new RangeError("Invalid mark data for Node.fromJSON");
}
marks2 = json.marks.map(schema.markFromJSON);
}
if (json.type == "text") {
if (typeof json.text != "string") {
throw new RangeError("Invalid text node in JSON");
}
return schema.text(json.text, marks2);
}
var content2 = Fragment.fromJSON(schema, json.content);
return schema.nodeType(json.type).create(json.attrs, content2, marks2);
};
Object.defineProperties(Node$2.prototype, prototypeAccessors$3$1);
var TextNode = /* @__PURE__ */ function(Node3) {
function TextNode2(type, attrs2, content2, marks2) {
Node3.call(this, type, attrs2, null, marks2);
if (!content2) {
throw new RangeError("Empty text nodes are not allowed");
}
this.text = content2;
}
if (Node3)
TextNode2.__proto__ = Node3;
TextNode2.prototype = Object.create(Node3 && Node3.prototype);
TextNode2.prototype.constructor = TextNode2;
var prototypeAccessors$12 = {textContent: {configurable: true}, nodeSize: {configurable: true}};
TextNode2.prototype.toString = function toString8() {
if (this.type.spec.toDebugString) {
return this.type.spec.toDebugString(this);
}
return wrapMarks(this.marks, JSON.stringify(this.text));
};
prototypeAccessors$12.textContent.get = function() {
return this.text;
};
TextNode2.prototype.textBetween = function textBetween3(from4, to) {
return this.text.slice(from4, to);
};
prototypeAccessors$12.nodeSize.get = function() {
return this.text.length;
};
TextNode2.prototype.mark = function mark3(marks2) {
return marks2 == this.marks ? this : new TextNode2(this.type, this.attrs, this.text, marks2);
};
TextNode2.prototype.withText = function withText(text3) {
if (text3 == this.text) {
return this;
}
return new TextNode2(this.type, this.attrs, text3, this.marks);
};
TextNode2.prototype.cut = function cut3(from4, to) {
if (from4 === void 0)
from4 = 0;
if (to === void 0)
to = this.text.length;
if (from4 == 0 && to == this.text.length) {
return this;
}
return this.withText(this.text.slice(from4, to));
};
TextNode2.prototype.eq = function eq13(other) {
return this.sameMarkup(other) && this.text == other.text;
};
TextNode2.prototype.toJSON = function toJSON7() {
var base2 = Node3.prototype.toJSON.call(this);
base2.text = this.text;
return base2;
};
Object.defineProperties(TextNode2.prototype, prototypeAccessors$12);
return TextNode2;
}(Node$2);
function wrapMarks(marks2, str2) {
for (var i = marks2.length - 1; i >= 0; i--) {
str2 = marks2[i].type.name + "(" + str2 + ")";
}
return str2;
}
var ContentMatch = function ContentMatch2(validEnd) {
this.validEnd = validEnd;
this.next = [];
this.wrapCache = [];
};
var prototypeAccessors$4$1 = {inlineContent: {configurable: true}, defaultType: {configurable: true}, edgeCount: {configurable: true}};
ContentMatch.parse = function parse(string, nodeTypes) {
var stream = new TokenStream(string, nodeTypes);
if (stream.next == null) {
return ContentMatch.empty;
}
var expr = parseExpr(stream);
if (stream.next) {
stream.err("Unexpected trailing text");
}
var match3 = dfa(nfa(expr));
checkForDeadEnds(match3, stream);
return match3;
};
ContentMatch.prototype.matchType = function matchType(type) {
for (var i = 0; i < this.next.length; i += 2) {
if (this.next[i] == type) {
return this.next[i + 1];
}
}
return null;
};
ContentMatch.prototype.matchFragment = function matchFragment(frag, start3, end2) {
if (start3 === void 0)
start3 = 0;
if (end2 === void 0)
end2 = frag.childCount;
var cur = this;
for (var i = start3; cur && i < end2; i++) {
cur = cur.matchType(frag.child(i).type);
}
return cur;
};
prototypeAccessors$4$1.inlineContent.get = function() {
var first2 = this.next[0];
return first2 ? first2.isInline : false;
};
prototypeAccessors$4$1.defaultType.get = function() {
for (var i = 0; i < this.next.length; i += 2) {
var type = this.next[i];
if (!(type.isText || type.hasRequiredAttrs())) {
return type;
}
}
};
ContentMatch.prototype.compatible = function compatible(other) {
for (var i = 0; i < this.next.length; i += 2) {
for (var j = 0; j < other.next.length; j += 2) {
if (this.next[i] == other.next[j]) {
return true;
}
}
}
return false;
};
ContentMatch.prototype.fillBefore = function fillBefore(after3, toEnd, startIndex) {
if (toEnd === void 0)
toEnd = false;
if (startIndex === void 0)
startIndex = 0;
var seen = [this];
function search(match3, types) {
var finished = match3.matchFragment(after3, startIndex);
if (finished && (!toEnd || finished.validEnd)) {
return Fragment.from(types.map(function(tp) {
return tp.createAndFill();
}));
}
for (var i = 0; i < match3.next.length; i += 2) {
var type = match3.next[i], next2 = match3.next[i + 1];
if (!(type.isText || type.hasRequiredAttrs()) && seen.indexOf(next2) == -1) {
seen.push(next2);
var found2 = search(next2, types.concat(type));
if (found2) {
return found2;
}
}
}
}
return search(this, []);
};
ContentMatch.prototype.findWrapping = function findWrapping(target2) {
for (var i = 0; i < this.wrapCache.length; i += 2) {
if (this.wrapCache[i] == target2) {
return this.wrapCache[i + 1];
}
}
var computed = this.computeWrapping(target2);
this.wrapCache.push(target2, computed);
return computed;
};
ContentMatch.prototype.computeWrapping = function computeWrapping(target2) {
var seen = Object.create(null), active = [{match: this, type: null, via: null}];
while (active.length) {
var current = active.shift(), match3 = current.match;
if (match3.matchType(target2)) {
var result2 = [];
for (var obj = current; obj.type; obj = obj.via) {
result2.push(obj.type);
}
return result2.reverse();
}
for (var i = 0; i < match3.next.length; i += 2) {
var type = match3.next[i];
if (!type.isLeaf && !type.hasRequiredAttrs() && !(type.name in seen) && (!current.type || match3.next[i + 1].validEnd)) {
active.push({match: type.contentMatch, type, via: current});
seen[type.name] = true;
}
}
}
};
prototypeAccessors$4$1.edgeCount.get = function() {
return this.next.length >> 1;
};
ContentMatch.prototype.edge = function edge(n) {
var i = n << 1;
if (i >= this.next.length) {
throw new RangeError("There's no " + n + "th edge in this content match");
}
return {type: this.next[i], next: this.next[i + 1]};
};
ContentMatch.prototype.toString = function toString6() {
var seen = [];
function scan(m) {
seen.push(m);
for (var i = 1; i < m.next.length; i += 2) {
if (seen.indexOf(m.next[i]) == -1) {
scan(m.next[i]);
}
}
}
scan(this);
return seen.map(function(m, i) {
var out = i + (m.validEnd ? "*" : " ") + " ";
for (var i$1 = 0; i$1 < m.next.length; i$1 += 2) {
out += (i$1 ? ", " : "") + m.next[i$1].name + "->" + seen.indexOf(m.next[i$1 + 1]);
}
return out;
}).join("\n");
};
Object.defineProperties(ContentMatch.prototype, prototypeAccessors$4$1);
ContentMatch.empty = new ContentMatch(true);
var TokenStream = function TokenStream2(string, nodeTypes) {
this.string = string;
this.nodeTypes = nodeTypes;
this.inline = null;
this.pos = 0;
this.tokens = string.split(/\s*(?=\b|\W|$)/);
if (this.tokens[this.tokens.length - 1] == "") {
this.tokens.pop();
}
if (this.tokens[0] == "") {
this.tokens.shift();
}
};
var prototypeAccessors$1$2$1 = {next: {configurable: true}};
prototypeAccessors$1$2$1.next.get = function() {
return this.tokens[this.pos];
};
TokenStream.prototype.eat = function eat(tok) {
return this.next == tok && (this.pos++ || true);
};
TokenStream.prototype.err = function err(str2) {
throw new SyntaxError(str2 + " (in content expression '" + this.string + "')");
};
Object.defineProperties(TokenStream.prototype, prototypeAccessors$1$2$1);
function parseExpr(stream) {
var exprs = [];
do {
exprs.push(parseExprSeq(stream));
} while (stream.eat("|"));
return exprs.length == 1 ? exprs[0] : {type: "choice", exprs};
}
function parseExprSeq(stream) {
var exprs = [];
do {
exprs.push(parseExprSubscript(stream));
} while (stream.next && stream.next != ")" && stream.next != "|");
return exprs.length == 1 ? exprs[0] : {type: "seq", exprs};
}
function parseExprSubscript(stream) {
var expr = parseExprAtom(stream);
for (; ; ) {
if (stream.eat("+")) {
expr = {type: "plus", expr};
} else if (stream.eat("*")) {
expr = {type: "star", expr};
} else if (stream.eat("?")) {
expr = {type: "opt", expr};
} else if (stream.eat("{")) {
expr = parseExprRange(stream, expr);
} else {
break;
}
}
return expr;
}
function parseNum(stream) {
if (/\D/.test(stream.next)) {
stream.err("Expected number, got '" + stream.next + "'");
}
var result2 = Number(stream.next);
stream.pos++;
return result2;
}
function parseExprRange(stream, expr) {
var min3 = parseNum(stream), max3 = min3;
if (stream.eat(",")) {
if (stream.next != "}") {
max3 = parseNum(stream);
} else {
max3 = -1;
}
}
if (!stream.eat("}")) {
stream.err("Unclosed braced range");
}
return {type: "range", min: min3, max: max3, expr};
}
function resolveName(stream, name) {
var types = stream.nodeTypes, type = types[name];
if (type) {
return [type];
}
var result2 = [];
for (var typeName in types) {
var type$1 = types[typeName];
if (type$1.groups.indexOf(name) > -1) {
result2.push(type$1);
}
}
if (result2.length == 0) {
stream.err("No node type or group '" + name + "' found");
}
return result2;
}
function parseExprAtom(stream) {
if (stream.eat("(")) {
var expr = parseExpr(stream);
if (!stream.eat(")")) {
stream.err("Missing closing paren");
}
return expr;
} else if (!/\W/.test(stream.next)) {
var exprs = resolveName(stream, stream.next).map(function(type) {
if (stream.inline == null) {
stream.inline = type.isInline;
} else if (stream.inline != type.isInline) {
stream.err("Mixing inline and block content");
}
return {type: "name", value: type};
});
stream.pos++;
return exprs.length == 1 ? exprs[0] : {type: "choice", exprs};
} else {
stream.err("Unexpected token '" + stream.next + "'");
}
}
function nfa(expr) {
var nfa2 = [[]];
connect(compile4(expr, 0), node4());
return nfa2;
function node4() {
return nfa2.push([]) - 1;
}
function edge2(from4, to, term) {
var edge3 = {term, to};
nfa2[from4].push(edge3);
return edge3;
}
function connect(edges, to) {
edges.forEach(function(edge3) {
return edge3.to = to;
});
}
function compile4(expr2, from4) {
if (expr2.type == "choice") {
return expr2.exprs.reduce(function(out, expr3) {
return out.concat(compile4(expr3, from4));
}, []);
} else if (expr2.type == "seq") {
for (var i = 0; ; i++) {
var next2 = compile4(expr2.exprs[i], from4);
if (i == expr2.exprs.length - 1) {
return next2;
}
connect(next2, from4 = node4());
}
} else if (expr2.type == "star") {
var loop = node4();
edge2(from4, loop);
connect(compile4(expr2.expr, loop), loop);
return [edge2(loop)];
} else if (expr2.type == "plus") {
var loop$1 = node4();
connect(compile4(expr2.expr, from4), loop$1);
connect(compile4(expr2.expr, loop$1), loop$1);
return [edge2(loop$1)];
} else if (expr2.type == "opt") {
return [edge2(from4)].concat(compile4(expr2.expr, from4));
} else if (expr2.type == "range") {
var cur = from4;
for (var i$1 = 0; i$1 < expr2.min; i$1++) {
var next$1 = node4();
connect(compile4(expr2.expr, cur), next$1);
cur = next$1;
}
if (expr2.max == -1) {
connect(compile4(expr2.expr, cur), cur);
} else {
for (var i$2 = expr2.min; i$2 < expr2.max; i$2++) {
var next$2 = node4();
edge2(cur, next$2);
connect(compile4(expr2.expr, cur), next$2);
cur = next$2;
}
}
return [edge2(cur)];
} else if (expr2.type == "name") {
return [edge2(from4, null, expr2.value)];
}
}
}
function cmp(a, b) {
return b - a;
}
function nullFrom(nfa2, node4) {
var result2 = [];
scan(node4);
return result2.sort(cmp);
function scan(node5) {
var edges = nfa2[node5];
if (edges.length == 1 && !edges[0].term) {
return scan(edges[0].to);
}
result2.push(node5);
for (var i = 0; i < edges.length; i++) {
var ref2 = edges[i];
var term = ref2.term;
var to = ref2.to;
if (!term && result2.indexOf(to) == -1) {
scan(to);
}
}
}
}
function dfa(nfa2) {
var labeled = Object.create(null);
return explore(nullFrom(nfa2, 0));
function explore(states) {
var out = [];
states.forEach(function(node4) {
nfa2[node4].forEach(function(ref2) {
var term = ref2.term;
var to = ref2.to;
if (!term) {
return;
}
var known = out.indexOf(term), set3 = known > -1 && out[known + 1];
nullFrom(nfa2, to).forEach(function(node5) {
if (!set3) {
out.push(term, set3 = []);
}
if (set3.indexOf(node5) == -1) {
set3.push(node5);
}
});
});
});
var state = labeled[states.join(",")] = new ContentMatch(states.indexOf(nfa2.length - 1) > -1);
for (var i = 0; i < out.length; i += 2) {
var states$1 = out[i + 1].sort(cmp);
state.next.push(out[i], labeled[states$1.join(",")] || explore(states$1));
}
return state;
}
}
function checkForDeadEnds(match3, stream) {
for (var i = 0, work = [match3]; i < work.length; i++) {
var state = work[i], dead = !state.validEnd, nodes = [];
for (var j = 0; j < state.next.length; j += 2) {
var node4 = state.next[j], next2 = state.next[j + 1];
nodes.push(node4.name);
if (dead && !(node4.isText || node4.hasRequiredAttrs())) {
dead = false;
}
if (work.indexOf(next2) == -1) {
work.push(next2);
}
}
if (dead) {
stream.err("Only non-generatable nodes (" + nodes.join(", ") + ") in a required position (see https://prosemirror.net/docs/guide/#generatable)");
}
}
}
function defaultAttrs(attrs2) {
var defaults2 = Object.create(null);
for (var attrName in attrs2) {
var attr = attrs2[attrName];
if (!attr.hasDefault) {
return null;
}
defaults2[attrName] = attr.default;
}
return defaults2;
}
function computeAttrs(attrs2, value) {
var built = Object.create(null);
for (var name in attrs2) {
var given = value && value[name];
if (given === void 0) {
var attr = attrs2[name];
if (attr.hasDefault) {
given = attr.default;
} else {
throw new RangeError("No value supplied for attribute " + name);
}
}
built[name] = given;
}
return built;
}
function initAttrs(attrs2) {
var result2 = Object.create(null);
if (attrs2) {
for (var name in attrs2) {
result2[name] = new Attribute(attrs2[name]);
}
}
return result2;
}
var NodeType$1 = function NodeType(name, schema, spec) {
this.name = name;
this.schema = schema;
this.spec = spec;
this.groups = spec.group ? spec.group.split(" ") : [];
this.attrs = initAttrs(spec.attrs);
this.defaultAttrs = defaultAttrs(this.attrs);
this.contentMatch = null;
this.markSet = null;
this.inlineContent = null;
this.isBlock = !(spec.inline || name == "text");
this.isText = name == "text";
};
var prototypeAccessors$5$1 = {isInline: {configurable: true}, isTextblock: {configurable: true}, isLeaf: {configurable: true}, isAtom: {configurable: true}};
prototypeAccessors$5$1.isInline.get = function() {
return !this.isBlock;
};
prototypeAccessors$5$1.isTextblock.get = function() {
return this.isBlock && this.inlineContent;
};
prototypeAccessors$5$1.isLeaf.get = function() {
return this.contentMatch == ContentMatch.empty;
};
prototypeAccessors$5$1.isAtom.get = function() {
return this.isLeaf || this.spec.atom;
};
NodeType$1.prototype.hasRequiredAttrs = function hasRequiredAttrs() {
for (var n in this.attrs) {
if (this.attrs[n].isRequired) {
return true;
}
}
return false;
};
NodeType$1.prototype.compatibleContent = function compatibleContent(other) {
return this == other || this.contentMatch.compatible(other.contentMatch);
};
NodeType$1.prototype.computeAttrs = function computeAttrs$1(attrs2) {
if (!attrs2 && this.defaultAttrs) {
return this.defaultAttrs;
} else {
return computeAttrs(this.attrs, attrs2);
}
};
NodeType$1.prototype.create = function create2(attrs2, content2, marks2) {
if (this.isText) {
throw new Error("NodeType.create can't construct text nodes");
}
return new Node$2(this, this.computeAttrs(attrs2), Fragment.from(content2), Mark$1.setFrom(marks2));
};
NodeType$1.prototype.createChecked = function createChecked(attrs2, content2, marks2) {
content2 = Fragment.from(content2);
if (!this.validContent(content2)) {
throw new RangeError("Invalid content for node " + this.name);
}
return new Node$2(this, this.computeAttrs(attrs2), content2, Mark$1.setFrom(marks2));
};
NodeType$1.prototype.createAndFill = function createAndFill(attrs2, content2, marks2) {
attrs2 = this.computeAttrs(attrs2);
content2 = Fragment.from(content2);
if (content2.size) {
var before3 = this.contentMatch.fillBefore(content2);
if (!before3) {
return null;
}
content2 = before3.append(content2);
}
var after3 = this.contentMatch.matchFragment(content2).fillBefore(Fragment.empty, true);
if (!after3) {
return null;
}
return new Node$2(this, attrs2, content2.append(after3), Mark$1.setFrom(marks2));
};
NodeType$1.prototype.validContent = function validContent(content2) {
var result2 = this.contentMatch.matchFragment(content2);
if (!result2 || !result2.validEnd) {
return false;
}
for (var i = 0; i < content2.childCount; i++) {
if (!this.allowsMarks(content2.child(i).marks)) {
return false;
}
}
return true;
};
NodeType$1.prototype.allowsMarkType = function allowsMarkType(markType) {
return this.markSet == null || this.markSet.indexOf(markType) > -1;
};
NodeType$1.prototype.allowsMarks = function allowsMarks(marks2) {
if (this.markSet == null) {
return true;
}
for (var i = 0; i < marks2.length; i++) {
if (!this.allowsMarkType(marks2[i].type)) {
return false;
}
}
return true;
};
NodeType$1.prototype.allowedMarks = function allowedMarks(marks2) {
if (this.markSet == null) {
return marks2;
}
var copy5;
for (var i = 0; i < marks2.length; i++) {
if (!this.allowsMarkType(marks2[i].type)) {
if (!copy5) {
copy5 = marks2.slice(0, i);
}
} else if (copy5) {
copy5.push(marks2[i]);
}
}
return !copy5 ? marks2 : copy5.length ? copy5 : Mark$1.empty;
};
NodeType$1.compile = function compile2(nodes, schema) {
var result2 = Object.create(null);
nodes.forEach(function(name, spec) {
return result2[name] = new NodeType$1(name, schema, spec);
});
var topType = schema.spec.topNode || "doc";
if (!result2[topType]) {
throw new RangeError("Schema is missing its top node type ('" + topType + "')");
}
if (!result2.text) {
throw new RangeError("Every schema needs a 'text' type");
}
for (var _2 in result2.text.attrs) {
throw new RangeError("The text node type should not have attributes");
}
return result2;
};
Object.defineProperties(NodeType$1.prototype, prototypeAccessors$5$1);
var Attribute = function Attribute2(options) {
this.hasDefault = Object.prototype.hasOwnProperty.call(options, "default");
this.default = options.default;
};
var prototypeAccessors$1$3$1 = {isRequired: {configurable: true}};
prototypeAccessors$1$3$1.isRequired.get = function() {
return !this.hasDefault;
};
Object.defineProperties(Attribute.prototype, prototypeAccessors$1$3$1);
var MarkType = function MarkType2(name, rank, schema, spec) {
this.name = name;
this.schema = schema;
this.spec = spec;
this.attrs = initAttrs(spec.attrs);
this.rank = rank;
this.excluded = null;
var defaults2 = defaultAttrs(this.attrs);
this.instance = defaults2 && new Mark$1(this, defaults2);
};
MarkType.prototype.create = function create3(attrs2) {
if (!attrs2 && this.instance) {
return this.instance;
}
return new Mark$1(this, computeAttrs(this.attrs, attrs2));
};
MarkType.compile = function compile3(marks2, schema) {
var result2 = Object.create(null), rank = 0;
marks2.forEach(function(name, spec) {
return result2[name] = new MarkType(name, rank++, schema, spec);
});
return result2;
};
MarkType.prototype.removeFromSet = function removeFromSet2(set3) {
for (var i = 0; i < set3.length; i++) {
if (set3[i].type == this) {
set3 = set3.slice(0, i).concat(set3.slice(i + 1));
i--;
}
}
return set3;
};
MarkType.prototype.isInSet = function isInSet2(set3) {
for (var i = 0; i < set3.length; i++) {
if (set3[i].type == this) {
return set3[i];
}
}
};
MarkType.prototype.excludes = function excludes(other) {
return this.excluded.indexOf(other) > -1;
};
var Schema = function Schema2(spec) {
this.spec = {};
for (var prop in spec) {
this.spec[prop] = spec[prop];
}
this.spec.nodes = orderedmap.from(spec.nodes);
this.spec.marks = orderedmap.from(spec.marks);
this.nodes = NodeType$1.compile(this.spec.nodes, this);
this.marks = MarkType.compile(this.spec.marks, this);
var contentExprCache = Object.create(null);
for (var prop$1 in this.nodes) {
if (prop$1 in this.marks) {
throw new RangeError(prop$1 + " can not be both a node and a mark");
}
var type = this.nodes[prop$1], contentExpr = type.spec.content || "", markExpr = type.spec.marks;
type.contentMatch = contentExprCache[contentExpr] || (contentExprCache[contentExpr] = ContentMatch.parse(contentExpr, this.nodes));
type.inlineContent = type.contentMatch.inlineContent;
type.markSet = markExpr == "_" ? null : markExpr ? gatherMarks(this, markExpr.split(" ")) : markExpr == "" || !type.inlineContent ? [] : null;
}
for (var prop$2 in this.marks) {
var type$1 = this.marks[prop$2], excl = type$1.spec.excludes;
type$1.excluded = excl == null ? [type$1] : excl == "" ? [] : gatherMarks(this, excl.split(" "));
}
this.nodeFromJSON = this.nodeFromJSON.bind(this);
this.markFromJSON = this.markFromJSON.bind(this);
this.topNodeType = this.nodes[this.spec.topNode || "doc"];
this.cached = Object.create(null);
this.cached.wrappings = Object.create(null);
};
Schema.prototype.node = function node2(type, attrs2, content2, marks2) {
if (typeof type == "string") {
type = this.nodeType(type);
} else if (!(type instanceof NodeType$1)) {
throw new RangeError("Invalid node type: " + type);
} else if (type.schema != this) {
throw new RangeError("Node type from different schema used (" + type.name + ")");
}
return type.createChecked(attrs2, content2, marks2);
};
Schema.prototype.text = function text(text$12, marks2) {
var type = this.nodes.text;
return new TextNode(type, type.defaultAttrs, text$12, Mark$1.setFrom(marks2));
};
Schema.prototype.mark = function mark2(type, attrs2) {
if (typeof type == "string") {
type = this.marks[type];
}
return type.create(attrs2);
};
Schema.prototype.nodeFromJSON = function nodeFromJSON(json) {
return Node$2.fromJSON(this, json);
};
Schema.prototype.markFromJSON = function markFromJSON(json) {
return Mark$1.fromJSON(this, json);
};
Schema.prototype.nodeType = function nodeType(name) {
var found2 = this.nodes[name];
if (!found2) {
throw new RangeError("Unknown node type: " + name);
}
return found2;
};
function gatherMarks(schema, marks2) {
var found2 = [];
for (var i = 0; i < marks2.length; i++) {
var name = marks2[i], mark3 = schema.marks[name], ok2 = mark3;
if (mark3) {
found2.push(mark3);
} else {
for (var prop in schema.marks) {
var mark$1 = schema.marks[prop];
if (name == "_" || mark$1.spec.group && mark$1.spec.group.split(" ").indexOf(name) > -1) {
found2.push(ok2 = mark$1);
}
}
}
if (!ok2) {
throw new SyntaxError("Unknown mark type: '" + marks2[i] + "'");
}
}
return found2;
}
var DOMParser = function DOMParser2(schema, rules) {
var this$1 = this;
this.schema = schema;
this.rules = rules;
this.tags = [];
this.styles = [];
rules.forEach(function(rule) {
if (rule.tag) {
this$1.tags.push(rule);
} else if (rule.style) {
this$1.styles.push(rule);
}
});
this.normalizeLists = !this.tags.some(function(r) {
if (!/^(ul|ol)\b/.test(r.tag) || !r.node) {
return false;
}
var node4 = schema.nodes[r.node];
return node4.contentMatch.matchType(node4);
});
};
DOMParser.prototype.parse = function parse2(dom, options) {
if (options === void 0)
options = {};
var context = new ParseContext(this, options, false);
context.addAll(dom, null, options.from, options.to);
return context.finish();
};
DOMParser.prototype.parseSlice = function parseSlice(dom, options) {
if (options === void 0)
options = {};
var context = new ParseContext(this, options, true);
context.addAll(dom, null, options.from, options.to);
return Slice.maxOpen(context.finish());
};
DOMParser.prototype.matchTag = function matchTag(dom, context, after3) {
for (var i = after3 ? this.tags.indexOf(after3) + 1 : 0; i < this.tags.length; i++) {
var rule = this.tags[i];
if (matches$1(dom, rule.tag) && (rule.namespace === void 0 || dom.namespaceURI == rule.namespace) && (!rule.context || context.matchesContext(rule.context))) {
if (rule.getAttrs) {
var result2 = rule.getAttrs(dom);
if (result2 === false) {
continue;
}
rule.attrs = result2;
}
return rule;
}
}
};
DOMParser.prototype.matchStyle = function matchStyle(prop, value, context, after3) {
for (var i = after3 ? this.styles.indexOf(after3) + 1 : 0; i < this.styles.length; i++) {
var rule = this.styles[i];
if (rule.style.indexOf(prop) != 0 || rule.context && !context.matchesContext(rule.context) || rule.style.length > prop.length && (rule.style.charCodeAt(prop.length) != 61 || rule.style.slice(prop.length + 1) != value)) {
continue;
}
if (rule.getAttrs) {
var result2 = rule.getAttrs(value);
if (result2 === false) {
continue;
}
rule.attrs = result2;
}
return rule;
}
};
DOMParser.schemaRules = function schemaRules(schema) {
var result2 = [];
function insert2(rule) {
var priority = rule.priority == null ? 50 : rule.priority, i = 0;
for (; i < result2.length; i++) {
var next2 = result2[i], nextPriority = next2.priority == null ? 50 : next2.priority;
if (nextPriority < priority) {
break;
}
}
result2.splice(i, 0, rule);
}
var loop = function(name2) {
var rules = schema.marks[name2].spec.parseDOM;
if (rules) {
rules.forEach(function(rule) {
insert2(rule = copy2(rule));
rule.mark = name2;
});
}
};
for (var name in schema.marks)
loop(name);
var loop$1 = function(name2) {
var rules$1 = schema.nodes[name$1].spec.parseDOM;
if (rules$1) {
rules$1.forEach(function(rule) {
insert2(rule = copy2(rule));
rule.node = name$1;
});
}
};
for (var name$1 in schema.nodes)
loop$1();
return result2;
};
DOMParser.fromSchema = function fromSchema(schema) {
return schema.cached.domParser || (schema.cached.domParser = new DOMParser(schema, DOMParser.schemaRules(schema)));
};
var blockTags = {
address: true,
article: true,
aside: true,
blockquote: true,
canvas: true,
dd: true,
div: true,
dl: true,
fieldset: true,
figcaption: true,
figure: true,
footer: true,
form: true,
h1: true,
h2: true,
h3: true,
h4: true,
h5: true,
h6: true,
header: true,
hgroup: true,
hr: true,
li: true,
noscript: true,
ol: true,
output: true,
p: true,
pre: true,
section: true,
table: true,
tfoot: true,
ul: true
};
var ignoreTags = {
head: true,
noscript: true,
object: true,
script: true,
style: true,
title: true
};
var listTags = {ol: true, ul: true};
var OPT_PRESERVE_WS = 1, OPT_PRESERVE_WS_FULL = 2, OPT_OPEN_LEFT = 4;
function wsOptionsFor(preserveWhitespace) {
return (preserveWhitespace ? OPT_PRESERVE_WS : 0) | (preserveWhitespace === "full" ? OPT_PRESERVE_WS_FULL : 0);
}
var NodeContext = function NodeContext2(type, attrs2, marks2, pendingMarks, solid, match3, options) {
this.type = type;
this.attrs = attrs2;
this.solid = solid;
this.match = match3 || (options & OPT_OPEN_LEFT ? null : type.contentMatch);
this.options = options;
this.content = [];
this.marks = marks2;
this.activeMarks = Mark$1.none;
this.pendingMarks = pendingMarks;
this.stashMarks = [];
};
NodeContext.prototype.findWrapping = function findWrapping2(node4) {
if (!this.match) {
if (!this.type) {
return [];
}
var fill = this.type.contentMatch.fillBefore(Fragment.from(node4));
if (fill) {
this.match = this.type.contentMatch.matchFragment(fill);
} else {
var start3 = this.type.contentMatch, wrap2;
if (wrap2 = start3.findWrapping(node4.type)) {
this.match = start3;
return wrap2;
} else {
return null;
}
}
}
return this.match.findWrapping(node4.type);
};
NodeContext.prototype.finish = function finish(openEnd) {
if (!(this.options & OPT_PRESERVE_WS)) {
var last2 = this.content[this.content.length - 1], m;
if (last2 && last2.isText && (m = /[ \t\r\n\u000c]+$/.exec(last2.text))) {
if (last2.text.length == m[0].length) {
this.content.pop();
} else {
this.content[this.content.length - 1] = last2.withText(last2.text.slice(0, last2.text.length - m[0].length));
}
}
}
var content2 = Fragment.from(this.content);
if (!openEnd && this.match) {
content2 = content2.append(this.match.fillBefore(Fragment.empty, true));
}
return this.type ? this.type.create(this.attrs, content2, this.marks) : content2;
};
NodeContext.prototype.popFromStashMark = function popFromStashMark(mark3) {
for (var i = this.stashMarks.length - 1; i >= 0; i--) {
if (mark3.eq(this.stashMarks[i])) {
return this.stashMarks.splice(i, 1)[0];
}
}
};
NodeContext.prototype.applyPending = function applyPending(nextType) {
for (var i = 0, pending2 = this.pendingMarks; i < pending2.length; i++) {
var mark3 = pending2[i];
if ((this.type ? this.type.allowsMarkType(mark3.type) : markMayApply(mark3.type, nextType)) && !mark3.isInSet(this.activeMarks)) {
this.activeMarks = mark3.addToSet(this.activeMarks);
this.pendingMarks = mark3.removeFromSet(this.pendingMarks);
}
}
};
var ParseContext = function ParseContext2(parser, options, open2) {
this.parser = parser;
this.options = options;
this.isOpen = open2;
var topNode = options.topNode, topContext;
var topOptions = wsOptionsFor(options.preserveWhitespace) | (open2 ? OPT_OPEN_LEFT : 0);
if (topNode) {
topContext = new NodeContext(topNode.type, topNode.attrs, Mark$1.none, Mark$1.none, true, options.topMatch || topNode.type.contentMatch, topOptions);
} else if (open2) {
topContext = new NodeContext(null, null, Mark$1.none, Mark$1.none, true, null, topOptions);
} else {
topContext = new NodeContext(parser.schema.topNodeType, null, Mark$1.none, Mark$1.none, true, null, topOptions);
}
this.nodes = [topContext];
this.open = 0;
this.find = options.findPositions;
this.needsBlock = false;
};
var prototypeAccessors$6 = {top: {configurable: true}, currentPos: {configurable: true}};
prototypeAccessors$6.top.get = function() {
return this.nodes[this.open];
};
ParseContext.prototype.addDOM = function addDOM(dom) {
if (dom.nodeType == 3) {
this.addTextNode(dom);
} else if (dom.nodeType == 1) {
var style2 = dom.getAttribute("style");
var marks2 = style2 ? this.readStyles(parseStyles(style2)) : null, top = this.top;
if (marks2 != null) {
for (var i = 0; i < marks2.length; i++) {
this.addPendingMark(marks2[i]);
}
}
this.addElement(dom);
if (marks2 != null) {
for (var i$1 = 0; i$1 < marks2.length; i$1++) {
this.removePendingMark(marks2[i$1], top);
}
}
}
};
ParseContext.prototype.addTextNode = function addTextNode(dom) {
var value = dom.nodeValue;
var top = this.top;
if ((top.type ? top.type.inlineContent : top.content.length && top.content[0].isInline) || /[^ \t\r\n\u000c]/.test(value)) {
if (!(top.options & OPT_PRESERVE_WS)) {
value = value.replace(/[ \t\r\n\u000c]+/g, " ");
if (/^[ \t\r\n\u000c]/.test(value) && this.open == this.nodes.length - 1) {
var nodeBefore = top.content[top.content.length - 1];
var domNodeBefore = dom.previousSibling;
if (!nodeBefore || domNodeBefore && domNodeBefore.nodeName == "BR" || nodeBefore.isText && /[ \t\r\n\u000c]$/.test(nodeBefore.text)) {
value = value.slice(1);
}
}
} else if (!(top.options & OPT_PRESERVE_WS_FULL)) {
value = value.replace(/\r?\n|\r/g, " ");
}
if (value) {
this.insertNode(this.parser.schema.text(value));
}
this.findInText(dom);
} else {
this.findInside(dom);
}
};
ParseContext.prototype.addElement = function addElement(dom, matchAfter) {
var name = dom.nodeName.toLowerCase(), ruleID;
if (listTags.hasOwnProperty(name) && this.parser.normalizeLists) {
normalizeList(dom);
}
var rule = this.options.ruleFromNode && this.options.ruleFromNode(dom) || (ruleID = this.parser.matchTag(dom, this, matchAfter));
if (rule ? rule.ignore : ignoreTags.hasOwnProperty(name)) {
this.findInside(dom);
} else if (!rule || rule.skip || rule.closeParent) {
if (rule && rule.closeParent) {
this.open = Math.max(0, this.open - 1);
} else if (rule && rule.skip.nodeType) {
dom = rule.skip;
}
var sync2, top = this.top, oldNeedsBlock = this.needsBlock;
if (blockTags.hasOwnProperty(name)) {
sync2 = true;
if (!top.type) {
this.needsBlock = true;
}
} else if (!dom.firstChild) {
this.leafFallback(dom);
return;
}
this.addAll(dom);
if (sync2) {
this.sync(top);
}
this.needsBlock = oldNeedsBlock;
} else {
this.addElementByRule(dom, rule, rule.consuming === false ? ruleID : null);
}
};
ParseContext.prototype.leafFallback = function leafFallback(dom) {
if (dom.nodeName == "BR" && this.top.type && this.top.type.inlineContent) {
this.addTextNode(dom.ownerDocument.createTextNode("\n"));
}
};
ParseContext.prototype.readStyles = function readStyles(styles) {
var marks2 = Mark$1.none;
style:
for (var i = 0; i < styles.length; i += 2) {
for (var after3 = null; ; ) {
var rule = this.parser.matchStyle(styles[i], styles[i + 1], this, after3);
if (!rule) {
continue style;
}
if (rule.ignore) {
return null;
}
marks2 = this.parser.schema.marks[rule.mark].create(rule.attrs).addToSet(marks2);
if (rule.consuming === false) {
after3 = rule;
} else {
break;
}
}
}
return marks2;
};
ParseContext.prototype.addElementByRule = function addElementByRule(dom, rule, continueAfter) {
var this$1 = this;
var sync2, nodeType2, markType, mark3;
if (rule.node) {
nodeType2 = this.parser.schema.nodes[rule.node];
if (!nodeType2.isLeaf) {
sync2 = this.enter(nodeType2, rule.attrs, rule.preserveWhitespace);
} else if (!this.insertNode(nodeType2.create(rule.attrs))) {
this.leafFallback(dom);
}
} else {
markType = this.parser.schema.marks[rule.mark];
mark3 = markType.create(rule.attrs);
this.addPendingMark(mark3);
}
var startIn = this.top;
if (nodeType2 && nodeType2.isLeaf) {
this.findInside(dom);
} else if (continueAfter) {
this.addElement(dom, continueAfter);
} else if (rule.getContent) {
this.findInside(dom);
rule.getContent(dom, this.parser.schema).forEach(function(node4) {
return this$1.insertNode(node4);
});
} else {
var contentDOM = rule.contentElement;
if (typeof contentDOM == "string") {
contentDOM = dom.querySelector(contentDOM);
} else if (typeof contentDOM == "function") {
contentDOM = contentDOM(dom);
}
if (!contentDOM) {
contentDOM = dom;
}
this.findAround(dom, contentDOM, true);
this.addAll(contentDOM, sync2);
}
if (sync2) {
this.sync(startIn);
this.open--;
}
if (mark3) {
this.removePendingMark(mark3, startIn);
}
};
ParseContext.prototype.addAll = function addAll(parent, sync2, startIndex, endIndex) {
var index3 = startIndex || 0;
for (var dom = startIndex ? parent.childNodes[startIndex] : parent.firstChild, end2 = endIndex == null ? null : parent.childNodes[endIndex]; dom != end2; dom = dom.nextSibling, ++index3) {
this.findAtPoint(parent, index3);
this.addDOM(dom);
if (sync2 && blockTags.hasOwnProperty(dom.nodeName.toLowerCase())) {
this.sync(sync2);
}
}
this.findAtPoint(parent, index3);
};
ParseContext.prototype.findPlace = function findPlace(node4) {
var route, sync2;
for (var depth = this.open; depth >= 0; depth--) {
var cx = this.nodes[depth];
var found2 = cx.findWrapping(node4);
if (found2 && (!route || route.length > found2.length)) {
route = found2;
sync2 = cx;
if (!found2.length) {
break;
}
}
if (cx.solid) {
break;
}
}
if (!route) {
return false;
}
this.sync(sync2);
for (var i = 0; i < route.length; i++) {
this.enterInner(route[i], null, false);
}
return true;
};
ParseContext.prototype.insertNode = function insertNode(node4) {
if (node4.isInline && this.needsBlock && !this.top.type) {
var block = this.textblockFromContext();
if (block) {
this.enterInner(block);
}
}
if (this.findPlace(node4)) {
this.closeExtra();
var top = this.top;
top.applyPending(node4.type);
if (top.match) {
top.match = top.match.matchType(node4.type);
}
var marks2 = top.activeMarks;
for (var i = 0; i < node4.marks.length; i++) {
if (!top.type || top.type.allowsMarkType(node4.marks[i].type)) {
marks2 = node4.marks[i].addToSet(marks2);
}
}
top.content.push(node4.mark(marks2));
return true;
}
return false;
};
ParseContext.prototype.enter = function enter2(type, attrs2, preserveWS) {
var ok2 = this.findPlace(type.create(attrs2));
if (ok2) {
this.enterInner(type, attrs2, true, preserveWS);
}
return ok2;
};
ParseContext.prototype.enterInner = function enterInner(type, attrs2, solid, preserveWS) {
this.closeExtra();
var top = this.top;
top.applyPending(type);
top.match = top.match && top.match.matchType(type, attrs2);
var options = preserveWS == null ? top.options & ~OPT_OPEN_LEFT : wsOptionsFor(preserveWS);
if (top.options & OPT_OPEN_LEFT && top.content.length == 0) {
options |= OPT_OPEN_LEFT;
}
this.nodes.push(new NodeContext(type, attrs2, top.activeMarks, top.pendingMarks, solid, null, options));
this.open++;
};
ParseContext.prototype.closeExtra = function closeExtra(openEnd) {
var i = this.nodes.length - 1;
if (i > this.open) {
for (; i > this.open; i--) {
this.nodes[i - 1].content.push(this.nodes[i].finish(openEnd));
}
this.nodes.length = this.open + 1;
}
};
ParseContext.prototype.finish = function finish2() {
this.open = 0;
this.closeExtra(this.isOpen);
return this.nodes[0].finish(this.isOpen || this.options.topOpen);
};
ParseContext.prototype.sync = function sync(to) {
for (var i = this.open; i >= 0; i--) {
if (this.nodes[i] == to) {
this.open = i;
return;
}
}
};
prototypeAccessors$6.currentPos.get = function() {
this.closeExtra();
var pos = 0;
for (var i = this.open; i >= 0; i--) {
var content2 = this.nodes[i].content;
for (var j = content2.length - 1; j >= 0; j--) {
pos += content2[j].nodeSize;
}
if (i) {
pos++;
}
}
return pos;
};
ParseContext.prototype.findAtPoint = function findAtPoint(parent, offset2) {
if (this.find) {
for (var i = 0; i < this.find.length; i++) {
if (this.find[i].node == parent && this.find[i].offset == offset2) {
this.find[i].pos = this.currentPos;
}
}
}
};
ParseContext.prototype.findInside = function findInside(parent) {
if (this.find) {
for (var i = 0; i < this.find.length; i++) {
if (this.find[i].pos == null && parent.nodeType == 1 && parent.contains(this.find[i].node)) {
this.find[i].pos = this.currentPos;
}
}
}
};
ParseContext.prototype.findAround = function findAround(parent, content2, before3) {
if (parent != content2 && this.find) {
for (var i = 0; i < this.find.length; i++) {
if (this.find[i].pos == null && parent.nodeType == 1 && parent.contains(this.find[i].node)) {
var pos = content2.compareDocumentPosition(this.find[i].node);
if (pos & (before3 ? 2 : 4)) {
this.find[i].pos = this.currentPos;
}
}
}
}
};
ParseContext.prototype.findInText = function findInText(textNode) {
if (this.find) {
for (var i = 0; i < this.find.length; i++) {
if (this.find[i].node == textNode) {
this.find[i].pos = this.currentPos - (textNode.nodeValue.length - this.find[i].offset);
}
}
}
};
ParseContext.prototype.matchesContext = function matchesContext(context) {
var this$1 = this;
if (context.indexOf("|") > -1) {
return context.split(/\s*\|\s*/).some(this.matchesContext, this);
}
var parts = context.split("/");
var option2 = this.options.context;
var useRoot = !this.isOpen && (!option2 || option2.parent.type == this.nodes[0].type);
var minDepth = -(option2 ? option2.depth + 1 : 0) + (useRoot ? 0 : 1);
var match3 = function(i, depth) {
for (; i >= 0; i--) {
var part = parts[i];
if (part == "") {
if (i == parts.length - 1 || i == 0) {
continue;
}
for (; depth >= minDepth; depth--) {
if (match3(i - 1, depth)) {
return true;
}
}
return false;
} else {
var next2 = depth > 0 || depth == 0 && useRoot ? this$1.nodes[depth].type : option2 && depth >= minDepth ? option2.node(depth - minDepth).type : null;
if (!next2 || next2.name != part && next2.groups.indexOf(part) == -1) {
return false;
}
depth--;
}
}
return true;
};
return match3(parts.length - 1, this.open);
};
ParseContext.prototype.textblockFromContext = function textblockFromContext() {
var $context = this.options.context;
if ($context) {
for (var d = $context.depth; d >= 0; d--) {
var deflt = $context.node(d).contentMatchAt($context.indexAfter(d)).defaultType;
if (deflt && deflt.isTextblock && deflt.defaultAttrs) {
return deflt;
}
}
}
for (var name in this.parser.schema.nodes) {
var type = this.parser.schema.nodes[name];
if (type.isTextblock && type.defaultAttrs) {
return type;
}
}
};
ParseContext.prototype.addPendingMark = function addPendingMark(mark3) {
var found2 = findSameMarkInSet(mark3, this.top.pendingMarks);
if (found2) {
this.top.stashMarks.push(found2);
}
this.top.pendingMarks = mark3.addToSet(this.top.pendingMarks);
};
ParseContext.prototype.removePendingMark = function removePendingMark(mark3, upto) {
for (var depth = this.open; depth >= 0; depth--) {
var level = this.nodes[depth];
var found2 = level.pendingMarks.lastIndexOf(mark3);
if (found2 > -1) {
level.pendingMarks = mark3.removeFromSet(level.pendingMarks);
} else {
level.activeMarks = mark3.removeFromSet(level.activeMarks);
var stashMark = level.popFromStashMark(mark3);
if (stashMark && level.type && level.type.allowsMarkType(stashMark.type)) {
level.activeMarks = stashMark.addToSet(level.activeMarks);
}
}
if (level == upto) {
break;
}
}
};
Object.defineProperties(ParseContext.prototype, prototypeAccessors$6);
function normalizeList(dom) {
for (var child3 = dom.firstChild, prevItem = null; child3; child3 = child3.nextSibling) {
var name = child3.nodeType == 1 ? child3.nodeName.toLowerCase() : null;
if (name && listTags.hasOwnProperty(name) && prevItem) {
prevItem.appendChild(child3);
child3 = prevItem;
} else if (name == "li") {
prevItem = child3;
} else if (name) {
prevItem = null;
}
}
}
function matches$1(dom, selector) {
return (dom.matches || dom.msMatchesSelector || dom.webkitMatchesSelector || dom.mozMatchesSelector).call(dom, selector);
}
function parseStyles(style2) {
var re = /\s*([\w-]+)\s*:\s*([^;]+)/g, m, result2 = [];
while (m = re.exec(style2)) {
result2.push(m[1], m[2].trim());
}
return result2;
}
function copy2(obj) {
var copy5 = {};
for (var prop in obj) {
copy5[prop] = obj[prop];
}
return copy5;
}
function markMayApply(markType, nodeType2) {
var nodes = nodeType2.schema.nodes;
var loop = function(name2) {
var parent = nodes[name2];
if (!parent.allowsMarkType(markType)) {
return;
}
var seen = [], scan = function(match3) {
seen.push(match3);
for (var i = 0; i < match3.edgeCount; i++) {
var ref2 = match3.edge(i);
var type = ref2.type;
var next2 = ref2.next;
if (type == nodeType2) {
return true;
}
if (seen.indexOf(next2) < 0 && scan(next2)) {
return true;
}
}
};
if (scan(parent.contentMatch)) {
return {v: true};
}
};
for (var name in nodes) {
var returned = loop(name);
if (returned)
return returned.v;
}
}
function findSameMarkInSet(mark3, set3) {
for (var i = 0; i < set3.length; i++) {
if (mark3.eq(set3[i])) {
return set3[i];
}
}
}
var DOMSerializer = function DOMSerializer2(nodes, marks2) {
this.nodes = nodes || {};
this.marks = marks2 || {};
};
DOMSerializer.prototype.serializeFragment = function serializeFragment(fragment, options, target2) {
var this$1 = this;
if (options === void 0)
options = {};
if (!target2) {
target2 = doc(options).createDocumentFragment();
}
var top = target2, active = null;
fragment.forEach(function(node4) {
if (active || node4.marks.length) {
if (!active) {
active = [];
}
var keep = 0, rendered = 0;
while (keep < active.length && rendered < node4.marks.length) {
var next2 = node4.marks[rendered];
if (!this$1.marks[next2.type.name]) {
rendered++;
continue;
}
if (!next2.eq(active[keep]) || next2.type.spec.spanning === false) {
break;
}
keep += 2;
rendered++;
}
while (keep < active.length) {
top = active.pop();
active.pop();
}
while (rendered < node4.marks.length) {
var add3 = node4.marks[rendered++];
var markDOM = this$1.serializeMark(add3, node4.isInline, options);
if (markDOM) {
active.push(add3, top);
top.appendChild(markDOM.dom);
top = markDOM.contentDOM || markDOM.dom;
}
}
}
top.appendChild(this$1.serializeNode(node4, options));
});
return target2;
};
DOMSerializer.prototype.serializeNode = function serializeNode(node4, options) {
if (options === void 0)
options = {};
var ref2 = DOMSerializer.renderSpec(doc(options), this.nodes[node4.type.name](node4));
var dom = ref2.dom;
var contentDOM = ref2.contentDOM;
if (contentDOM) {
if (node4.isLeaf) {
throw new RangeError("Content hole not allowed in a leaf node spec");
}
if (options.onContent) {
options.onContent(node4, contentDOM, options);
} else {
this.serializeFragment(node4.content, options, contentDOM);
}
}
return dom;
};
DOMSerializer.prototype.serializeNodeAndMarks = function serializeNodeAndMarks(node4, options) {
if (options === void 0)
options = {};
var dom = this.serializeNode(node4, options);
for (var i = node4.marks.length - 1; i >= 0; i--) {
var wrap2 = this.serializeMark(node4.marks[i], node4.isInline, options);
if (wrap2) {
(wrap2.contentDOM || wrap2.dom).appendChild(dom);
dom = wrap2.dom;
}
}
return dom;
};
DOMSerializer.prototype.serializeMark = function serializeMark(mark3, inline2, options) {
if (options === void 0)
options = {};
var toDOM = this.marks[mark3.type.name];
return toDOM && DOMSerializer.renderSpec(doc(options), toDOM(mark3, inline2));
};
DOMSerializer.renderSpec = function renderSpec(doc2, structure, xmlNS) {
if (xmlNS === void 0)
xmlNS = null;
if (typeof structure == "string") {
return {dom: doc2.createTextNode(structure)};
}
if (structure.nodeType != null) {
return {dom: structure};
}
if (structure.dom && structure.dom.nodeType != null) {
return structure;
}
var tagName2 = structure[0], space = tagName2.indexOf(" ");
if (space > 0) {
xmlNS = tagName2.slice(0, space);
tagName2 = tagName2.slice(space + 1);
}
var contentDOM = null, dom = xmlNS ? doc2.createElementNS(xmlNS, tagName2) : doc2.createElement(tagName2);
var attrs2 = structure[1], start3 = 1;
if (attrs2 && typeof attrs2 == "object" && attrs2.nodeType == null && !Array.isArray(attrs2)) {
start3 = 2;
for (var name in attrs2) {
if (attrs2[name] != null) {
var space$1 = name.indexOf(" ");
if (space$1 > 0) {
dom.setAttributeNS(name.slice(0, space$1), name.slice(space$1 + 1), attrs2[name]);
} else {
dom.setAttribute(name, attrs2[name]);
}
}
}
}
for (var i = start3; i < structure.length; i++) {
var child3 = structure[i];
if (child3 === 0) {
if (i < structure.length - 1 || i > start3) {
throw new RangeError("Content hole must be the only child of its parent node");
}
return {dom, contentDOM: dom};
} else {
var ref2 = DOMSerializer.renderSpec(doc2, child3, xmlNS);
var inner = ref2.dom;
var innerContent = ref2.contentDOM;
dom.appendChild(inner);
if (innerContent) {
if (contentDOM) {
throw new RangeError("Multiple content holes");
}
contentDOM = innerContent;
}
}
}
return {dom, contentDOM};
};
DOMSerializer.fromSchema = function fromSchema2(schema) {
return schema.cached.domSerializer || (schema.cached.domSerializer = new DOMSerializer(this.nodesFromSchema(schema), this.marksFromSchema(schema)));
};
DOMSerializer.nodesFromSchema = function nodesFromSchema(schema) {
var result2 = gatherToDOM(schema.nodes);
if (!result2.text) {
result2.text = function(node4) {
return node4.text;
};
}
return result2;
};
DOMSerializer.marksFromSchema = function marksFromSchema(schema) {
return gatherToDOM(schema.marks);
};
function gatherToDOM(obj) {
var result2 = {};
for (var name in obj) {
var toDOM = obj[name].spec.toDOM;
if (toDOM) {
result2[name] = toDOM;
}
}
return result2;
}
function doc(options) {
return options.document || window.document;
}
var lower16 = 65535;
var factor16 = Math.pow(2, 16);
function makeRecover(index3, offset2) {
return index3 + offset2 * factor16;
}
function recoverIndex(value) {
return value & lower16;
}
function recoverOffset(value) {
return (value - (value & lower16)) / factor16;
}
var MapResult = function MapResult2(pos, deleted, recover2) {
if (deleted === void 0)
deleted = false;
if (recover2 === void 0)
recover2 = null;
this.pos = pos;
this.deleted = deleted;
this.recover = recover2;
};
var StepMap = function StepMap2(ranges, inverted) {
if (inverted === void 0)
inverted = false;
this.ranges = ranges;
this.inverted = inverted;
};
StepMap.prototype.recover = function recover(value) {
var diff = 0, index3 = recoverIndex(value);
if (!this.inverted) {
for (var i = 0; i < index3; i++) {
diff += this.ranges[i * 3 + 2] - this.ranges[i * 3 + 1];
}
}
return this.ranges[index3 * 3] + diff + recoverOffset(value);
};
StepMap.prototype.mapResult = function mapResult(pos, assoc) {
if (assoc === void 0)
assoc = 1;
return this._map(pos, assoc, false);
};
StepMap.prototype.map = function map2(pos, assoc) {
if (assoc === void 0)
assoc = 1;
return this._map(pos, assoc, true);
};
StepMap.prototype._map = function _map(pos, assoc, simple) {
var diff = 0, oldIndex2 = this.inverted ? 2 : 1, newIndex2 = this.inverted ? 1 : 2;
for (var i = 0; i < this.ranges.length; i += 3) {
var start3 = this.ranges[i] - (this.inverted ? diff : 0);
if (start3 > pos) {
break;
}
var oldSize = this.ranges[i + oldIndex2], newSize = this.ranges[i + newIndex2], end2 = start3 + oldSize;
if (pos <= end2) {
var side = !oldSize ? assoc : pos == start3 ? -1 : pos == end2 ? 1 : assoc;
var result2 = start3 + diff + (side < 0 ? 0 : newSize);
if (simple) {
return result2;
}
var recover2 = pos == (assoc < 0 ? start3 : end2) ? null : makeRecover(i / 3, pos - start3);
return new MapResult(result2, assoc < 0 ? pos != start3 : pos != end2, recover2);
}
diff += newSize - oldSize;
}
return simple ? pos + diff : new MapResult(pos + diff);
};
StepMap.prototype.touches = function touches(pos, recover2) {
var diff = 0, index3 = recoverIndex(recover2);
var oldIndex2 = this.inverted ? 2 : 1, newIndex2 = this.inverted ? 1 : 2;
for (var i = 0; i < this.ranges.length; i += 3) {
var start3 = this.ranges[i] - (this.inverted ? diff : 0);
if (start3 > pos) {
break;
}
var oldSize = this.ranges[i + oldIndex2], end2 = start3 + oldSize;
if (pos <= end2 && i == index3 * 3) {
return true;
}
diff += this.ranges[i + newIndex2] - oldSize;
}
return false;
};
StepMap.prototype.forEach = function forEach3(f) {
var oldIndex2 = this.inverted ? 2 : 1, newIndex2 = this.inverted ? 1 : 2;
for (var i = 0, diff = 0; i < this.ranges.length; i += 3) {
var start3 = this.ranges[i], oldStart = start3 - (this.inverted ? diff : 0), newStart = start3 + (this.inverted ? 0 : diff);
var oldSize = this.ranges[i + oldIndex2], newSize = this.ranges[i + newIndex2];
f(oldStart, oldStart + oldSize, newStart, newStart + newSize);
diff += newSize - oldSize;
}
};
StepMap.prototype.invert = function invert2() {
return new StepMap(this.ranges, !this.inverted);
};
StepMap.prototype.toString = function toString7() {
return (this.inverted ? "-" : "") + JSON.stringify(this.ranges);
};
StepMap.offset = function offset(n) {
return n == 0 ? StepMap.empty : new StepMap(n < 0 ? [0, -n, 0] : [0, 0, n]);
};
StepMap.empty = new StepMap([]);
var Mapping = function Mapping2(maps, mirror, from4, to) {
this.maps = maps || [];
this.from = from4 || 0;
this.to = to == null ? this.maps.length : to;
this.mirror = mirror;
};
Mapping.prototype.slice = function slice2(from4, to) {
if (from4 === void 0)
from4 = 0;
if (to === void 0)
to = this.maps.length;
return new Mapping(this.maps, this.mirror, from4, to);
};
Mapping.prototype.copy = function copy3() {
return new Mapping(this.maps.slice(), this.mirror && this.mirror.slice(), this.from, this.to);
};
Mapping.prototype.appendMap = function appendMap(map16, mirrors) {
this.to = this.maps.push(map16);
if (mirrors != null) {
this.setMirror(this.maps.length - 1, mirrors);
}
};
Mapping.prototype.appendMapping = function appendMapping(mapping) {
for (var i = 0, startSize = this.maps.length; i < mapping.maps.length; i++) {
var mirr = mapping.getMirror(i);
this.appendMap(mapping.maps[i], mirr != null && mirr < i ? startSize + mirr : null);
}
};
Mapping.prototype.getMirror = function getMirror(n) {
if (this.mirror) {
for (var i = 0; i < this.mirror.length; i++) {
if (this.mirror[i] == n) {
return this.mirror[i + (i % 2 ? -1 : 1)];
}
}
}
};
Mapping.prototype.setMirror = function setMirror(n, m) {
if (!this.mirror) {
this.mirror = [];
}
this.mirror.push(n, m);
};
Mapping.prototype.appendMappingInverted = function appendMappingInverted(mapping) {
for (var i = mapping.maps.length - 1, totalSize = this.maps.length + mapping.maps.length; i >= 0; i--) {
var mirr = mapping.getMirror(i);
this.appendMap(mapping.maps[i].invert(), mirr != null && mirr > i ? totalSize - mirr - 1 : null);
}
};
Mapping.prototype.invert = function invert3() {
var inverse = new Mapping();
inverse.appendMappingInverted(this);
return inverse;
};
Mapping.prototype.map = function map3(pos, assoc) {
if (assoc === void 0)
assoc = 1;
if (this.mirror) {
return this._map(pos, assoc, true);
}
for (var i = this.from; i < this.to; i++) {
pos = this.maps[i].map(pos, assoc);
}
return pos;
};
Mapping.prototype.mapResult = function mapResult2(pos, assoc) {
if (assoc === void 0)
assoc = 1;
return this._map(pos, assoc, false);
};
Mapping.prototype._map = function _map2(pos, assoc, simple) {
var deleted = false;
for (var i = this.from; i < this.to; i++) {
var map16 = this.maps[i], result2 = map16.mapResult(pos, assoc);
if (result2.recover != null) {
var corr = this.getMirror(i);
if (corr != null && corr > i && corr < this.to) {
i = corr;
pos = this.maps[corr].recover(result2.recover);
continue;
}
}
if (result2.deleted) {
deleted = true;
}
pos = result2.pos;
}
return simple ? pos : new MapResult(pos, deleted);
};
function TransformError(message) {
var err2 = Error.call(this, message);
err2.__proto__ = TransformError.prototype;
return err2;
}
TransformError.prototype = Object.create(Error.prototype);
TransformError.prototype.constructor = TransformError;
TransformError.prototype.name = "TransformError";
var Transform = function Transform2(doc2) {
this.doc = doc2;
this.steps = [];
this.docs = [];
this.mapping = new Mapping();
};
var prototypeAccessors$4 = {before: {configurable: true}, docChanged: {configurable: true}};
prototypeAccessors$4.before.get = function() {
return this.docs.length ? this.docs[0] : this.doc;
};
Transform.prototype.step = function step(object2) {
var result2 = this.maybeStep(object2);
if (result2.failed) {
throw new TransformError(result2.failed);
}
return this;
};
Transform.prototype.maybeStep = function maybeStep(step2) {
var result2 = step2.apply(this.doc);
if (!result2.failed) {
this.addStep(step2, result2.doc);
}
return result2;
};
prototypeAccessors$4.docChanged.get = function() {
return this.steps.length > 0;
};
Transform.prototype.addStep = function addStep(step2, doc2) {
this.docs.push(this.doc);
this.steps.push(step2);
this.mapping.appendMap(step2.getMap());
this.doc = doc2;
};
Object.defineProperties(Transform.prototype, prototypeAccessors$4);
function mustOverride() {
throw new Error("Override me");
}
var stepsByID = Object.create(null);
var Step = function Step2() {
};
Step.prototype.apply = function apply(_doc) {
return mustOverride();
};
Step.prototype.getMap = function getMap() {
return StepMap.empty;
};
Step.prototype.invert = function invert4(_doc) {
return mustOverride();
};
Step.prototype.map = function map4(_mapping) {
return mustOverride();
};
Step.prototype.merge = function merge(_other) {
return null;
};
Step.prototype.toJSON = function toJSON5() {
return mustOverride();
};
Step.fromJSON = function fromJSON5(schema, json) {
if (!json || !json.stepType) {
throw new RangeError("Invalid input for Step.fromJSON");
}
var type = stepsByID[json.stepType];
if (!type) {
throw new RangeError("No step type " + json.stepType + " defined");
}
return type.fromJSON(schema, json);
};
Step.jsonID = function jsonID(id, stepClass) {
if (id in stepsByID) {
throw new RangeError("Duplicate use of step JSON ID " + id);
}
stepsByID[id] = stepClass;
stepClass.prototype.jsonID = id;
return stepClass;
};
var StepResult = function StepResult2(doc2, failed) {
this.doc = doc2;
this.failed = failed;
};
StepResult.ok = function ok(doc2) {
return new StepResult(doc2, null);
};
StepResult.fail = function fail(message) {
return new StepResult(null, message);
};
StepResult.fromReplace = function fromReplace(doc2, from4, to, slice5) {
try {
return StepResult.ok(doc2.replace(from4, to, slice5));
} catch (e) {
if (e instanceof ReplaceError) {
return StepResult.fail(e.message);
}
throw e;
}
};
var ReplaceStep = /* @__PURE__ */ function(Step3) {
function ReplaceStep2(from4, to, slice5, structure) {
Step3.call(this);
this.from = from4;
this.to = to;
this.slice = slice5;
this.structure = !!structure;
}
if (Step3)
ReplaceStep2.__proto__ = Step3;
ReplaceStep2.prototype = Object.create(Step3 && Step3.prototype);
ReplaceStep2.prototype.constructor = ReplaceStep2;
ReplaceStep2.prototype.apply = function apply8(doc2) {
if (this.structure && contentBetween(doc2, this.from, this.to)) {
return StepResult.fail("Structure replace would overwrite content");
}
return StepResult.fromReplace(doc2, this.from, this.to, this.slice);
};
ReplaceStep2.prototype.getMap = function getMap2() {
return new StepMap([this.from, this.to - this.from, this.slice.size]);
};
ReplaceStep2.prototype.invert = function invert5(doc2) {
return new ReplaceStep2(this.from, this.from + this.slice.size, doc2.slice(this.from, this.to));
};
ReplaceStep2.prototype.map = function map16(mapping) {
var from4 = mapping.mapResult(this.from, 1), to = mapping.mapResult(this.to, -1);
if (from4.deleted && to.deleted) {
return null;
}
return new ReplaceStep2(from4.pos, Math.max(from4.pos, to.pos), this.slice);
};
ReplaceStep2.prototype.merge = function merge5(other) {
if (!(other instanceof ReplaceStep2) || other.structure || this.structure) {
return null;
}
if (this.from + this.slice.size == other.from && !this.slice.openEnd && !other.slice.openStart) {
var slice5 = this.slice.size + other.slice.size == 0 ? Slice.empty : new Slice(this.slice.content.append(other.slice.content), this.slice.openStart, other.slice.openEnd);
return new ReplaceStep2(this.from, this.to + (other.to - other.from), slice5, this.structure);
} else if (other.to == this.from && !this.slice.openStart && !other.slice.openEnd) {
var slice$12 = this.slice.size + other.slice.size == 0 ? Slice.empty : new Slice(other.slice.content.append(this.slice.content), other.slice.openStart, this.slice.openEnd);
return new ReplaceStep2(other.from, this.to, slice$12, this.structure);
} else {
return null;
}
};
ReplaceStep2.prototype.toJSON = function toJSON7() {
var json = {stepType: "replace", from: this.from, to: this.to};
if (this.slice.size) {
json.slice = this.slice.toJSON();
}
if (this.structure) {
json.structure = true;
}
return json;
};
ReplaceStep2.fromJSON = function fromJSON8(schema, json) {
if (typeof json.from != "number" || typeof json.to != "number") {
throw new RangeError("Invalid input for ReplaceStep.fromJSON");
}
return new ReplaceStep2(json.from, json.to, Slice.fromJSON(schema, json.slice), !!json.structure);
};
return ReplaceStep2;
}(Step);
Step.jsonID("replace", ReplaceStep);
var ReplaceAroundStep = /* @__PURE__ */ function(Step3) {
function ReplaceAroundStep2(from4, to, gapFrom, gapTo, slice5, insert2, structure) {
Step3.call(this);
this.from = from4;
this.to = to;
this.gapFrom = gapFrom;
this.gapTo = gapTo;
this.slice = slice5;
this.insert = insert2;
this.structure = !!structure;
}
if (Step3)
ReplaceAroundStep2.__proto__ = Step3;
ReplaceAroundStep2.prototype = Object.create(Step3 && Step3.prototype);
ReplaceAroundStep2.prototype.constructor = ReplaceAroundStep2;
ReplaceAroundStep2.prototype.apply = function apply8(doc2) {
if (this.structure && (contentBetween(doc2, this.from, this.gapFrom) || contentBetween(doc2, this.gapTo, this.to))) {
return StepResult.fail("Structure gap-replace would overwrite content");
}
var gap = doc2.slice(this.gapFrom, this.gapTo);
if (gap.openStart || gap.openEnd) {
return StepResult.fail("Gap is not a flat range");
}
var inserted2 = this.slice.insertAt(this.insert, gap.content);
if (!inserted2) {
return StepResult.fail("Content does not fit in gap");
}
return StepResult.fromReplace(doc2, this.from, this.to, inserted2);
};
ReplaceAroundStep2.prototype.getMap = function getMap2() {
return new StepMap([
this.from,
this.gapFrom - this.from,
this.insert,
this.gapTo,
this.to - this.gapTo,
this.slice.size - this.insert
]);
};
ReplaceAroundStep2.prototype.invert = function invert5(doc2) {
var gap = this.gapTo - this.gapFrom;
return new ReplaceAroundStep2(this.from, this.from + this.slice.size + gap, this.from + this.insert, this.from + this.insert + gap, doc2.slice(this.from, this.to).removeBetween(this.gapFrom - this.from, this.gapTo - this.from), this.gapFrom - this.from, this.structure);
};
ReplaceAroundStep2.prototype.map = function map16(mapping) {
var from4 = mapping.mapResult(this.from, 1), to = mapping.mapResult(this.to, -1);
var gapFrom = mapping.map(this.gapFrom, -1), gapTo = mapping.map(this.gapTo, 1);
if (from4.deleted && to.deleted || gapFrom < from4.pos || gapTo > to.pos) {
return null;
}
return new ReplaceAroundStep2(from4.pos, to.pos, gapFrom, gapTo, this.slice, this.insert, this.structure);
};
ReplaceAroundStep2.prototype.toJSON = function toJSON7() {
var json = {
stepType: "replaceAround",
from: this.from,
to: this.to,
gapFrom: this.gapFrom,
gapTo: this.gapTo,
insert: this.insert
};
if (this.slice.size) {
json.slice = this.slice.toJSON();
}
if (this.structure) {
json.structure = true;
}
return json;
};
ReplaceAroundStep2.fromJSON = function fromJSON8(schema, json) {
if (typeof json.from != "number" || typeof json.to != "number" || typeof json.gapFrom != "number" || typeof json.gapTo != "number" || typeof json.insert != "number") {
throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");
}
return new ReplaceAroundStep2(json.from, json.to, json.gapFrom, json.gapTo, Slice.fromJSON(schema, json.slice), json.insert, !!json.structure);
};
return ReplaceAroundStep2;
}(Step);
Step.jsonID("replaceAround", ReplaceAroundStep);
function contentBetween(doc2, from4, to) {
var $from = doc2.resolve(from4), dist = to - from4, depth = $from.depth;
while (dist > 0 && depth > 0 && $from.indexAfter(depth) == $from.node(depth).childCount) {
depth--;
dist--;
}
if (dist > 0) {
var next2 = $from.node(depth).maybeChild($from.indexAfter(depth));
while (dist > 0) {
if (!next2 || next2.isLeaf) {
return true;
}
next2 = next2.firstChild;
dist--;
}
}
return false;
}
function canCut(node4, start3, end2) {
return (start3 == 0 || node4.canReplace(start3, node4.childCount)) && (end2 == node4.childCount || node4.canReplace(0, end2));
}
function liftTarget(range2) {
var parent = range2.parent;
var content2 = parent.content.cutByIndex(range2.startIndex, range2.endIndex);
for (var depth = range2.depth; ; --depth) {
var node4 = range2.$from.node(depth);
var index3 = range2.$from.index(depth), endIndex = range2.$to.indexAfter(depth);
if (depth < range2.depth && node4.canReplace(index3, endIndex, content2)) {
return depth;
}
if (depth == 0 || node4.type.spec.isolating || !canCut(node4, index3, endIndex)) {
break;
}
}
}
Transform.prototype.lift = function(range2, target2) {
var $from = range2.$from;
var $to = range2.$to;
var depth = range2.depth;
var gapStart = $from.before(depth + 1), gapEnd = $to.after(depth + 1);
var start3 = gapStart, end2 = gapEnd;
var before3 = Fragment.empty, openStart = 0;
for (var d = depth, splitting = false; d > target2; d--) {
if (splitting || $from.index(d) > 0) {
splitting = true;
before3 = Fragment.from($from.node(d).copy(before3));
openStart++;
} else {
start3--;
}
}
var after3 = Fragment.empty, openEnd = 0;
for (var d$1 = depth, splitting$1 = false; d$1 > target2; d$1--) {
if (splitting$1 || $to.after(d$1 + 1) < $to.end(d$1)) {
splitting$1 = true;
after3 = Fragment.from($to.node(d$1).copy(after3));
openEnd++;
} else {
end2++;
}
}
return this.step(new ReplaceAroundStep(start3, end2, gapStart, gapEnd, new Slice(before3.append(after3), openStart, openEnd), before3.size - openStart, true));
};
function findWrapping3(range2, nodeType2, attrs2, innerRange) {
if (innerRange === void 0)
innerRange = range2;
var around = findWrappingOutside(range2, nodeType2);
var inner = around && findWrappingInside(innerRange, nodeType2);
if (!inner) {
return null;
}
return around.map(withAttrs).concat({type: nodeType2, attrs: attrs2}).concat(inner.map(withAttrs));
}
function withAttrs(type) {
return {type, attrs: null};
}
function findWrappingOutside(range2, type) {
var parent = range2.parent;
var startIndex = range2.startIndex;
var endIndex = range2.endIndex;
var around = parent.contentMatchAt(startIndex).findWrapping(type);
if (!around) {
return null;
}
var outer = around.length ? around[0] : type;
return parent.canReplaceWith(startIndex, endIndex, outer) ? around : null;
}
function findWrappingInside(range2, type) {
var parent = range2.parent;
var startIndex = range2.startIndex;
var endIndex = range2.endIndex;
var inner = parent.child(startIndex);
var inside = type.contentMatch.findWrapping(inner.type);
if (!inside) {
return null;
}
var lastType = inside.length ? inside[inside.length - 1] : type;
var innerMatch = lastType.contentMatch;
for (var i = startIndex; innerMatch && i < endIndex; i++) {
innerMatch = innerMatch.matchType(parent.child(i).type);
}
if (!innerMatch || !innerMatch.validEnd) {
return null;
}
return inside;
}
Transform.prototype.wrap = function(range2, wrappers) {
var content2 = Fragment.empty;
for (var i = wrappers.length - 1; i >= 0; i--) {
content2 = Fragment.from(wrappers[i].type.create(wrappers[i].attrs, content2));
}
var start3 = range2.start, end2 = range2.end;
return this.step(new ReplaceAroundStep(start3, end2, start3, end2, new Slice(content2, 0, 0), wrappers.length, true));
};
Transform.prototype.setBlockType = function(from4, to, type, attrs2) {
var this$1 = this;
if (to === void 0)
to = from4;
if (!type.isTextblock) {
throw new RangeError("Type given to setBlockType should be a textblock");
}
var mapFrom = this.steps.length;
this.doc.nodesBetween(from4, to, function(node4, pos) {
if (node4.isTextblock && !node4.hasMarkup(type, attrs2) && canChangeType(this$1.doc, this$1.mapping.slice(mapFrom).map(pos), type)) {
this$1.clearIncompatible(this$1.mapping.slice(mapFrom).map(pos, 1), type);
var mapping = this$1.mapping.slice(mapFrom);
var startM = mapping.map(pos, 1), endM = mapping.map(pos + node4.nodeSize, 1);
this$1.step(new ReplaceAroundStep(startM, endM, startM + 1, endM - 1, new Slice(Fragment.from(type.create(attrs2, null, node4.marks)), 0, 0), 1, true));
return false;
}
});
return this;
};
function canChangeType(doc2, pos, type) {
var $pos = doc2.resolve(pos), index3 = $pos.index();
return $pos.parent.canReplaceWith(index3, index3 + 1, type);
}
Transform.prototype.setNodeMarkup = function(pos, type, attrs2, marks2) {
var node4 = this.doc.nodeAt(pos);
if (!node4) {
throw new RangeError("No node at given position");
}
if (!type) {
type = node4.type;
}
var newNode = type.create(attrs2, null, marks2 || node4.marks);
if (node4.isLeaf) {
return this.replaceWith(pos, pos + node4.nodeSize, newNode);
}
if (!type.validContent(node4.content)) {
throw new RangeError("Invalid content for node type " + type.name);
}
return this.step(new ReplaceAroundStep(pos, pos + node4.nodeSize, pos + 1, pos + node4.nodeSize - 1, new Slice(Fragment.from(newNode), 0, 0), 1, true));
};
function canSplit(doc2, pos, depth, typesAfter) {
if (depth === void 0)
depth = 1;
var $pos = doc2.resolve(pos), base2 = $pos.depth - depth;
var innerType = typesAfter && typesAfter[typesAfter.length - 1] || $pos.parent;
if (base2 < 0 || $pos.parent.type.spec.isolating || !$pos.parent.canReplace($pos.index(), $pos.parent.childCount) || !innerType.type.validContent($pos.parent.content.cutByIndex($pos.index(), $pos.parent.childCount))) {
return false;
}
for (var d = $pos.depth - 1, i = depth - 2; d > base2; d--, i--) {
var node4 = $pos.node(d), index$12 = $pos.index(d);
if (node4.type.spec.isolating) {
return false;
}
var rest2 = node4.content.cutByIndex(index$12, node4.childCount);
var after3 = typesAfter && typesAfter[i] || node4;
if (after3 != node4) {
rest2 = rest2.replaceChild(0, after3.type.create(after3.attrs));
}
if (!node4.canReplace(index$12 + 1, node4.childCount) || !after3.type.validContent(rest2)) {
return false;
}
}
var index3 = $pos.indexAfter(base2);
var baseType = typesAfter && typesAfter[0];
return $pos.node(base2).canReplaceWith(index3, index3, baseType ? baseType.type : $pos.node(base2 + 1).type);
}
Transform.prototype.split = function(pos, depth, typesAfter) {
if (depth === void 0)
depth = 1;
var $pos = this.doc.resolve(pos), before3 = Fragment.empty, after3 = Fragment.empty;
for (var d = $pos.depth, e = $pos.depth - depth, i = depth - 1; d > e; d--, i--) {
before3 = Fragment.from($pos.node(d).copy(before3));
var typeAfter = typesAfter && typesAfter[i];
after3 = Fragment.from(typeAfter ? typeAfter.type.create(typeAfter.attrs, after3) : $pos.node(d).copy(after3));
}
return this.step(new ReplaceStep(pos, pos, new Slice(before3.append(after3), depth, depth), true));
};
function canJoin(doc2, pos) {
var $pos = doc2.resolve(pos), index3 = $pos.index();
return joinable($pos.nodeBefore, $pos.nodeAfter) && $pos.parent.canReplace(index3, index3 + 1);
}
function joinable(a, b) {
return a && b && !a.isLeaf && a.canAppend(b);
}
Transform.prototype.join = function(pos, depth) {
if (depth === void 0)
depth = 1;
var step2 = new ReplaceStep(pos - depth, pos + depth, Slice.empty, true);
return this.step(step2);
};
function insertPoint(doc2, pos, nodeType2) {
var $pos = doc2.resolve(pos);
if ($pos.parent.canReplaceWith($pos.index(), $pos.index(), nodeType2)) {
return pos;
}
if ($pos.parentOffset == 0) {
for (var d = $pos.depth - 1; d >= 0; d--) {
var index3 = $pos.index(d);
if ($pos.node(d).canReplaceWith(index3, index3, nodeType2)) {
return $pos.before(d + 1);
}
if (index3 > 0) {
return null;
}
}
}
if ($pos.parentOffset == $pos.parent.content.size) {
for (var d$1 = $pos.depth - 1; d$1 >= 0; d$1--) {
var index$12 = $pos.indexAfter(d$1);
if ($pos.node(d$1).canReplaceWith(index$12, index$12, nodeType2)) {
return $pos.after(d$1 + 1);
}
if (index$12 < $pos.node(d$1).childCount) {
return null;
}
}
}
}
function dropPoint(doc2, pos, slice5) {
var $pos = doc2.resolve(pos);
if (!slice5.content.size) {
return pos;
}
var content2 = slice5.content;
for (var i = 0; i < slice5.openStart; i++) {
content2 = content2.firstChild.content;
}
for (var pass = 1; pass <= (slice5.openStart == 0 && slice5.size ? 2 : 1); pass++) {
for (var d = $pos.depth; d >= 0; d--) {
var bias = d == $pos.depth ? 0 : $pos.pos <= ($pos.start(d + 1) + $pos.end(d + 1)) / 2 ? -1 : 1;
var insertPos = $pos.index(d) + (bias > 0 ? 1 : 0);
if (pass == 1 ? $pos.node(d).canReplace(insertPos, insertPos, content2) : $pos.node(d).contentMatchAt(insertPos).findWrapping(content2.firstChild.type)) {
return bias == 0 ? $pos.pos : bias < 0 ? $pos.before(d + 1) : $pos.after(d + 1);
}
}
}
return null;
}
function mapFragment(fragment, f, parent) {
var mapped = [];
for (var i = 0; i < fragment.childCount; i++) {
var child3 = fragment.child(i);
if (child3.content.size) {
child3 = child3.copy(mapFragment(child3.content, f, child3));
}
if (child3.isInline) {
child3 = f(child3, parent, i);
}
mapped.push(child3);
}
return Fragment.fromArray(mapped);
}
var AddMarkStep = /* @__PURE__ */ function(Step3) {
function AddMarkStep2(from4, to, mark3) {
Step3.call(this);
this.from = from4;
this.to = to;
this.mark = mark3;
}
if (Step3)
AddMarkStep2.__proto__ = Step3;
AddMarkStep2.prototype = Object.create(Step3 && Step3.prototype);
AddMarkStep2.prototype.constructor = AddMarkStep2;
AddMarkStep2.prototype.apply = function apply8(doc2) {
var this$1 = this;
var oldSlice = doc2.slice(this.from, this.to), $from = doc2.resolve(this.from);
var parent = $from.node($from.sharedDepth(this.to));
var slice5 = new Slice(mapFragment(oldSlice.content, function(node4, parent2) {
if (!node4.isAtom || !parent2.type.allowsMarkType(this$1.mark.type)) {
return node4;
}
return node4.mark(this$1.mark.addToSet(node4.marks));
}, parent), oldSlice.openStart, oldSlice.openEnd);
return StepResult.fromReplace(doc2, this.from, this.to, slice5);
};
AddMarkStep2.prototype.invert = function invert5() {
return new RemoveMarkStep(this.from, this.to, this.mark);
};
AddMarkStep2.prototype.map = function map16(mapping) {
var from4 = mapping.mapResult(this.from, 1), to = mapping.mapResult(this.to, -1);
if (from4.deleted && to.deleted || from4.pos >= to.pos) {
return null;
}
return new AddMarkStep2(from4.pos, to.pos, this.mark);
};
AddMarkStep2.prototype.merge = function merge5(other) {
if (other instanceof AddMarkStep2 && other.mark.eq(this.mark) && this.from <= other.to && this.to >= other.from) {
return new AddMarkStep2(Math.min(this.from, other.from), Math.max(this.to, other.to), this.mark);
}
};
AddMarkStep2.prototype.toJSON = function toJSON7() {
return {
stepType: "addMark",
mark: this.mark.toJSON(),
from: this.from,
to: this.to
};
};
AddMarkStep2.fromJSON = function fromJSON8(schema, json) {
if (typeof json.from != "number" || typeof json.to != "number") {
throw new RangeError("Invalid input for AddMarkStep.fromJSON");
}
return new AddMarkStep2(json.from, json.to, schema.markFromJSON(json.mark));
};
return AddMarkStep2;
}(Step);
Step.jsonID("addMark", AddMarkStep);
var RemoveMarkStep = /* @__PURE__ */ function(Step3) {
function RemoveMarkStep2(from4, to, mark3) {
Step3.call(this);
this.from = from4;
this.to = to;
this.mark = mark3;
}
if (Step3)
RemoveMarkStep2.__proto__ = Step3;
RemoveMarkStep2.prototype = Object.create(Step3 && Step3.prototype);
RemoveMarkStep2.prototype.constructor = RemoveMarkStep2;
RemoveMarkStep2.prototype.apply = function apply8(doc2) {
var this$1 = this;
var oldSlice = doc2.slice(this.from, this.to);
var slice5 = new Slice(mapFragment(oldSlice.content, function(node4) {
return node4.mark(this$1.mark.removeFromSet(node4.marks));
}), oldSlice.openStart, oldSlice.openEnd);
return StepResult.fromReplace(doc2, this.from, this.to, slice5);
};
RemoveMarkStep2.prototype.invert = function invert5() {
return new AddMarkStep(this.from, this.to, this.mark);
};
RemoveMarkStep2.prototype.map = function map16(mapping) {
var from4 = mapping.mapResult(this.from, 1), to = mapping.mapResult(this.to, -1);
if (from4.deleted && to.deleted || from4.pos >= to.pos) {
return null;
}
return new RemoveMarkStep2(from4.pos, to.pos, this.mark);
};
RemoveMarkStep2.prototype.merge = function merge5(other) {
if (other instanceof RemoveMarkStep2 && other.mark.eq(this.mark) && this.from <= other.to && this.to >= other.from) {
return new RemoveMarkStep2(Math.min(this.from, other.from), Math.max(this.to, other.to), this.mark);
}
};
RemoveMarkStep2.prototype.toJSON = function toJSON7() {
return {
stepType: "removeMark",
mark: this.mark.toJSON(),
from: this.from,
to: this.to
};
};
RemoveMarkStep2.fromJSON = function fromJSON8(schema, json) {
if (typeof json.from != "number" || typeof json.to != "number") {
throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");
}
return new RemoveMarkStep2(json.from, json.to, schema.markFromJSON(json.mark));
};
return RemoveMarkStep2;
}(Step);
Step.jsonID("removeMark", RemoveMarkStep);
Transform.prototype.addMark = function(from4, to, mark3) {
var this$1 = this;
var removed = [], added = [], removing = null, adding = null;
this.doc.nodesBetween(from4, to, function(node4, pos, parent) {
if (!node4.isInline) {
return;
}
var marks2 = node4.marks;
if (!mark3.isInSet(marks2) && parent.type.allowsMarkType(mark3.type)) {
var start3 = Math.max(pos, from4), end2 = Math.min(pos + node4.nodeSize, to);
var newSet = mark3.addToSet(marks2);
for (var i = 0; i < marks2.length; i++) {
if (!marks2[i].isInSet(newSet)) {
if (removing && removing.to == start3 && removing.mark.eq(marks2[i])) {
removing.to = end2;
} else {
removed.push(removing = new RemoveMarkStep(start3, end2, marks2[i]));
}
}
}
if (adding && adding.to == start3) {
adding.to = end2;
} else {
added.push(adding = new AddMarkStep(start3, end2, mark3));
}
}
});
removed.forEach(function(s) {
return this$1.step(s);
});
added.forEach(function(s) {
return this$1.step(s);
});
return this;
};
Transform.prototype.removeMark = function(from4, to, mark3) {
var this$1 = this;
if (mark3 === void 0)
mark3 = null;
var matched = [], step2 = 0;
this.doc.nodesBetween(from4, to, function(node4, pos) {
if (!node4.isInline) {
return;
}
step2++;
var toRemove = null;
if (mark3 instanceof MarkType) {
var set3 = node4.marks, found2;
while (found2 = mark3.isInSet(set3)) {
(toRemove || (toRemove = [])).push(found2);
set3 = found2.removeFromSet(set3);
}
} else if (mark3) {
if (mark3.isInSet(node4.marks)) {
toRemove = [mark3];
}
} else {
toRemove = node4.marks;
}
if (toRemove && toRemove.length) {
var end2 = Math.min(pos + node4.nodeSize, to);
for (var i = 0; i < toRemove.length; i++) {
var style2 = toRemove[i], found$1 = void 0;
for (var j = 0; j < matched.length; j++) {
var m = matched[j];
if (m.step == step2 - 1 && style2.eq(matched[j].style)) {
found$1 = m;
}
}
if (found$1) {
found$1.to = end2;
found$1.step = step2;
} else {
matched.push({style: style2, from: Math.max(pos, from4), to: end2, step: step2});
}
}
}
});
matched.forEach(function(m) {
return this$1.step(new RemoveMarkStep(m.from, m.to, m.style));
});
return this;
};
Transform.prototype.clearIncompatible = function(pos, parentType, match3) {
if (match3 === void 0)
match3 = parentType.contentMatch;
var node4 = this.doc.nodeAt(pos);
var delSteps = [], cur = pos + 1;
for (var i = 0; i < node4.childCount; i++) {
var child3 = node4.child(i), end2 = cur + child3.nodeSize;
var allowed = match3.matchType(child3.type, child3.attrs);
if (!allowed) {
delSteps.push(new ReplaceStep(cur, end2, Slice.empty));
} else {
match3 = allowed;
for (var j = 0; j < child3.marks.length; j++) {
if (!parentType.allowsMarkType(child3.marks[j].type)) {
this.step(new RemoveMarkStep(cur, end2, child3.marks[j]));
}
}
}
cur = end2;
}
if (!match3.validEnd) {
var fill = match3.fillBefore(Fragment.empty, true);
this.replace(cur, cur, new Slice(fill, 0, 0));
}
for (var i$1 = delSteps.length - 1; i$1 >= 0; i$1--) {
this.step(delSteps[i$1]);
}
return this;
};
function replaceStep(doc2, from4, to, slice5) {
if (to === void 0)
to = from4;
if (slice5 === void 0)
slice5 = Slice.empty;
if (from4 == to && !slice5.size) {
return null;
}
var $from = doc2.resolve(from4), $to = doc2.resolve(to);
if (fitsTrivially($from, $to, slice5)) {
return new ReplaceStep(from4, to, slice5);
}
return new Fitter($from, $to, slice5).fit();
}
Transform.prototype.replace = function(from4, to, slice5) {
if (to === void 0)
to = from4;
if (slice5 === void 0)
slice5 = Slice.empty;
var step2 = replaceStep(this.doc, from4, to, slice5);
if (step2) {
this.step(step2);
}
return this;
};
Transform.prototype.replaceWith = function(from4, to, content2) {
return this.replace(from4, to, new Slice(Fragment.from(content2), 0, 0));
};
Transform.prototype.delete = function(from4, to) {
return this.replace(from4, to, Slice.empty);
};
Transform.prototype.insert = function(pos, content2) {
return this.replaceWith(pos, pos, content2);
};
function fitsTrivially($from, $to, slice5) {
return !slice5.openStart && !slice5.openEnd && $from.start() == $to.start() && $from.parent.canReplace($from.index(), $to.index(), slice5.content);
}
var Fitter = function Fitter2($from, $to, slice5) {
this.$to = $to;
this.$from = $from;
this.unplaced = slice5;
this.frontier = [];
for (var i = 0; i <= $from.depth; i++) {
var node4 = $from.node(i);
this.frontier.push({
type: node4.type,
match: node4.contentMatchAt($from.indexAfter(i))
});
}
this.placed = Fragment.empty;
for (var i$1 = $from.depth; i$1 > 0; i$1--) {
this.placed = Fragment.from($from.node(i$1).copy(this.placed));
}
};
var prototypeAccessors$1$2 = {depth: {configurable: true}};
prototypeAccessors$1$2.depth.get = function() {
return this.frontier.length - 1;
};
Fitter.prototype.fit = function fit() {
while (this.unplaced.size) {
var fit2 = this.findFittable();
if (fit2) {
this.placeNodes(fit2);
} else {
this.openMore() || this.dropNode();
}
}
var moveInline = this.mustMoveInline(), placedSize = this.placed.size - this.depth - this.$from.depth;
var $from = this.$from, $to = this.close(moveInline < 0 ? this.$to : $from.doc.resolve(moveInline));
if (!$to) {
return null;
}
var content2 = this.placed, openStart = $from.depth, openEnd = $to.depth;
while (openStart && openEnd && content2.childCount == 1) {
content2 = content2.firstChild.content;
openStart--;
openEnd--;
}
var slice5 = new Slice(content2, openStart, openEnd);
if (moveInline > -1) {
return new ReplaceAroundStep($from.pos, moveInline, this.$to.pos, this.$to.end(), slice5, placedSize);
}
if (slice5.size || $from.pos != this.$to.pos) {
return new ReplaceStep($from.pos, $to.pos, slice5);
}
};
Fitter.prototype.findFittable = function findFittable() {
for (var pass = 1; pass <= 2; pass++) {
for (var sliceDepth = this.unplaced.openStart; sliceDepth >= 0; sliceDepth--) {
var fragment = void 0, parent = void 0;
if (sliceDepth) {
parent = contentAt(this.unplaced.content, sliceDepth - 1).firstChild;
fragment = parent.content;
} else {
fragment = this.unplaced.content;
}
var first2 = fragment.firstChild;
for (var frontierDepth = this.depth; frontierDepth >= 0; frontierDepth--) {
var ref2 = this.frontier[frontierDepth];
var type = ref2.type;
var match3 = ref2.match;
var wrap2 = void 0, inject = void 0;
if (pass == 1 && (first2 ? match3.matchType(first2.type) || (inject = match3.fillBefore(Fragment.from(first2), false)) : type.compatibleContent(parent.type))) {
return {sliceDepth, frontierDepth, parent, inject};
} else if (pass == 2 && first2 && (wrap2 = match3.findWrapping(first2.type))) {
return {sliceDepth, frontierDepth, parent, wrap: wrap2};
}
if (parent && match3.matchType(parent.type)) {
break;
}
}
}
}
};
Fitter.prototype.openMore = function openMore() {
var ref2 = this.unplaced;
var content2 = ref2.content;
var openStart = ref2.openStart;
var openEnd = ref2.openEnd;
var inner = contentAt(content2, openStart);
if (!inner.childCount || inner.firstChild.isLeaf) {
return false;
}
this.unplaced = new Slice(content2, openStart + 1, Math.max(openEnd, inner.size + openStart >= content2.size - openEnd ? openStart + 1 : 0));
return true;
};
Fitter.prototype.dropNode = function dropNode() {
var ref2 = this.unplaced;
var content2 = ref2.content;
var openStart = ref2.openStart;
var openEnd = ref2.openEnd;
var inner = contentAt(content2, openStart);
if (inner.childCount <= 1 && openStart > 0) {
var openAtEnd = content2.size - openStart <= openStart + inner.size;
this.unplaced = new Slice(dropFromFragment(content2, openStart - 1, 1), openStart - 1, openAtEnd ? openStart - 1 : openEnd);
} else {
this.unplaced = new Slice(dropFromFragment(content2, openStart, 1), openStart, openEnd);
}
};
Fitter.prototype.placeNodes = function placeNodes(ref2) {
var sliceDepth = ref2.sliceDepth;
var frontierDepth = ref2.frontierDepth;
var parent = ref2.parent;
var inject = ref2.inject;
var wrap2 = ref2.wrap;
while (this.depth > frontierDepth) {
this.closeFrontierNode();
}
if (wrap2) {
for (var i = 0; i < wrap2.length; i++) {
this.openFrontierNode(wrap2[i]);
}
}
var slice5 = this.unplaced, fragment = parent ? parent.content : slice5.content;
var openStart = slice5.openStart - sliceDepth;
var taken = 0, add3 = [];
var ref$12 = this.frontier[frontierDepth];
var match3 = ref$12.match;
var type = ref$12.type;
if (inject) {
for (var i$1 = 0; i$1 < inject.childCount; i$1++) {
add3.push(inject.child(i$1));
}
match3 = match3.matchFragment(inject);
}
var openEndCount = fragment.size + sliceDepth - (slice5.content.size - slice5.openEnd);
while (taken < fragment.childCount) {
var next2 = fragment.child(taken), matches2 = match3.matchType(next2.type);
if (!matches2) {
break;
}
taken++;
if (taken > 1 || openStart == 0 || next2.content.size) {
match3 = matches2;
add3.push(closeNodeStart(next2.mark(type.allowedMarks(next2.marks)), taken == 1 ? openStart : 0, taken == fragment.childCount ? openEndCount : -1));
}
}
var toEnd = taken == fragment.childCount;
if (!toEnd) {
openEndCount = -1;
}
this.placed = addToFragment(this.placed, frontierDepth, Fragment.from(add3));
this.frontier[frontierDepth].match = match3;
if (toEnd && openEndCount < 0 && parent && parent.type == this.frontier[this.depth].type && this.frontier.length > 1) {
this.closeFrontierNode();
}
for (var i$2 = 0, cur = fragment; i$2 < openEndCount; i$2++) {
var node4 = cur.lastChild;
this.frontier.push({type: node4.type, match: node4.contentMatchAt(node4.childCount)});
cur = node4.content;
}
this.unplaced = !toEnd ? new Slice(dropFromFragment(slice5.content, sliceDepth, taken), slice5.openStart, slice5.openEnd) : sliceDepth == 0 ? Slice.empty : new Slice(dropFromFragment(slice5.content, sliceDepth - 1, 1), sliceDepth - 1, openEndCount < 0 ? slice5.openEnd : sliceDepth - 1);
};
Fitter.prototype.mustMoveInline = function mustMoveInline() {
if (!this.$to.parent.isTextblock || this.$to.end() == this.$to.pos) {
return -1;
}
var top = this.frontier[this.depth], level;
if (!top.type.isTextblock || !contentAfterFits(this.$to, this.$to.depth, top.type, top.match, false) || this.$to.depth == this.depth && (level = this.findCloseLevel(this.$to)) && level.depth == this.depth) {
return -1;
}
var ref2 = this.$to;
var depth = ref2.depth;
var after3 = this.$to.after(depth);
while (depth > 1 && after3 == this.$to.end(--depth)) {
++after3;
}
return after3;
};
Fitter.prototype.findCloseLevel = function findCloseLevel($to) {
scan:
for (var i = Math.min(this.depth, $to.depth); i >= 0; i--) {
var ref2 = this.frontier[i];
var match3 = ref2.match;
var type = ref2.type;
var dropInner = i < $to.depth && $to.end(i + 1) == $to.pos + ($to.depth - (i + 1));
var fit2 = contentAfterFits($to, i, type, match3, dropInner);
if (!fit2) {
continue;
}
for (var d = i - 1; d >= 0; d--) {
var ref$12 = this.frontier[d];
var match$1 = ref$12.match;
var type$1 = ref$12.type;
var matches2 = contentAfterFits($to, d, type$1, match$1, true);
if (!matches2 || matches2.childCount) {
continue scan;
}
}
return {depth: i, fit: fit2, move: dropInner ? $to.doc.resolve($to.after(i + 1)) : $to};
}
};
Fitter.prototype.close = function close($to) {
var close3 = this.findCloseLevel($to);
if (!close3) {
return null;
}
while (this.depth > close3.depth) {
this.closeFrontierNode();
}
if (close3.fit.childCount) {
this.placed = addToFragment(this.placed, close3.depth, close3.fit);
}
$to = close3.move;
for (var d = close3.depth + 1; d <= $to.depth; d++) {
var node4 = $to.node(d), add3 = node4.type.contentMatch.fillBefore(node4.content, true, $to.index(d));
this.openFrontierNode(node4.type, node4.attrs, add3);
}
return $to;
};
Fitter.prototype.openFrontierNode = function openFrontierNode(type, attrs2, content2) {
var top = this.frontier[this.depth];
top.match = top.match.matchType(type);
this.placed = addToFragment(this.placed, this.depth, Fragment.from(type.create(attrs2, content2)));
this.frontier.push({type, match: type.contentMatch});
};
Fitter.prototype.closeFrontierNode = function closeFrontierNode() {
var open2 = this.frontier.pop();
var add3 = open2.match.fillBefore(Fragment.empty, true);
if (add3.childCount) {
this.placed = addToFragment(this.placed, this.frontier.length, add3);
}
};
Object.defineProperties(Fitter.prototype, prototypeAccessors$1$2);
function dropFromFragment(fragment, depth, count) {
if (depth == 0) {
return fragment.cutByIndex(count);
}
return fragment.replaceChild(0, fragment.firstChild.copy(dropFromFragment(fragment.firstChild.content, depth - 1, count)));
}
function addToFragment(fragment, depth, content2) {
if (depth == 0) {
return fragment.append(content2);
}
return fragment.replaceChild(fragment.childCount - 1, fragment.lastChild.copy(addToFragment(fragment.lastChild.content, depth - 1, content2)));
}
function contentAt(fragment, depth) {
for (var i = 0; i < depth; i++) {
fragment = fragment.firstChild.content;
}
return fragment;
}
function closeNodeStart(node4, openStart, openEnd) {
if (openStart <= 0) {
return node4;
}
var frag = node4.content;
if (openStart > 1) {
frag = frag.replaceChild(0, closeNodeStart(frag.firstChild, openStart - 1, frag.childCount == 1 ? openEnd - 1 : 0));
}
if (openStart > 0) {
frag = node4.type.contentMatch.fillBefore(frag).append(frag);
if (openEnd <= 0) {
frag = frag.append(node4.type.contentMatch.matchFragment(frag).fillBefore(Fragment.empty, true));
}
}
return node4.copy(frag);
}
function contentAfterFits($to, depth, type, match3, open2) {
var node4 = $to.node(depth), index3 = open2 ? $to.indexAfter(depth) : $to.index(depth);
if (index3 == node4.childCount && !type.compatibleContent(node4.type)) {
return null;
}
var fit2 = match3.fillBefore(node4.content, true, index3);
return fit2 && !invalidMarks(type, node4.content, index3) ? fit2 : null;
}
function invalidMarks(type, fragment, start3) {
for (var i = start3; i < fragment.childCount; i++) {
if (!type.allowsMarks(fragment.child(i).marks)) {
return true;
}
}
return false;
}
Transform.prototype.replaceRange = function(from4, to, slice5) {
if (!slice5.size) {
return this.deleteRange(from4, to);
}
var $from = this.doc.resolve(from4), $to = this.doc.resolve(to);
if (fitsTrivially($from, $to, slice5)) {
return this.step(new ReplaceStep(from4, to, slice5));
}
var targetDepths = coveredDepths($from, this.doc.resolve(to));
if (targetDepths[targetDepths.length - 1] == 0) {
targetDepths.pop();
}
var preferredTarget = -($from.depth + 1);
targetDepths.unshift(preferredTarget);
for (var d = $from.depth, pos = $from.pos - 1; d > 0; d--, pos--) {
var spec = $from.node(d).type.spec;
if (spec.defining || spec.isolating) {
break;
}
if (targetDepths.indexOf(d) > -1) {
preferredTarget = d;
} else if ($from.before(d) == pos) {
targetDepths.splice(1, 0, -d);
}
}
var preferredTargetIndex = targetDepths.indexOf(preferredTarget);
var leftNodes = [], preferredDepth = slice5.openStart;
for (var content2 = slice5.content, i = 0; ; i++) {
var node4 = content2.firstChild;
leftNodes.push(node4);
if (i == slice5.openStart) {
break;
}
content2 = node4.content;
}
if (preferredDepth > 0 && leftNodes[preferredDepth - 1].type.spec.defining && $from.node(preferredTargetIndex).type != leftNodes[preferredDepth - 1].type) {
preferredDepth -= 1;
} else if (preferredDepth >= 2 && leftNodes[preferredDepth - 1].isTextblock && leftNodes[preferredDepth - 2].type.spec.defining && $from.node(preferredTargetIndex).type != leftNodes[preferredDepth - 2].type) {
preferredDepth -= 2;
}
for (var j = slice5.openStart; j >= 0; j--) {
var openDepth = (j + preferredDepth + 1) % (slice5.openStart + 1);
var insert2 = leftNodes[openDepth];
if (!insert2) {
continue;
}
for (var i$1 = 0; i$1 < targetDepths.length; i$1++) {
var targetDepth = targetDepths[(i$1 + preferredTargetIndex) % targetDepths.length], expand = true;
if (targetDepth < 0) {
expand = false;
targetDepth = -targetDepth;
}
var parent = $from.node(targetDepth - 1), index3 = $from.index(targetDepth - 1);
if (parent.canReplaceWith(index3, index3, insert2.type, insert2.marks)) {
return this.replace($from.before(targetDepth), expand ? $to.after(targetDepth) : to, new Slice(closeFragment(slice5.content, 0, slice5.openStart, openDepth), openDepth, slice5.openEnd));
}
}
}
var startSteps = this.steps.length;
for (var i$2 = targetDepths.length - 1; i$2 >= 0; i$2--) {
this.replace(from4, to, slice5);
if (this.steps.length > startSteps) {
break;
}
var depth = targetDepths[i$2];
if (i$2 < 0) {
continue;
}
from4 = $from.before(depth);
to = $to.after(depth);
}
return this;
};
function closeFragment(fragment, depth, oldOpen, newOpen, parent) {
if (depth < oldOpen) {
var first2 = fragment.firstChild;
fragment = fragment.replaceChild(0, first2.copy(closeFragment(first2.content, depth + 1, oldOpen, newOpen, first2)));
}
if (depth > newOpen) {
var match3 = parent.contentMatchAt(0);
var start3 = match3.fillBefore(fragment).append(fragment);
fragment = start3.append(match3.matchFragment(start3).fillBefore(Fragment.empty, true));
}
return fragment;
}
Transform.prototype.replaceRangeWith = function(from4, to, node4) {
if (!node4.isInline && from4 == to && this.doc.resolve(from4).parent.content.size) {
var point = insertPoint(this.doc, from4, node4.type);
if (point != null) {
from4 = to = point;
}
}
return this.replaceRange(from4, to, new Slice(Fragment.from(node4), 0, 0));
};
Transform.prototype.deleteRange = function(from4, to) {
var $from = this.doc.resolve(from4), $to = this.doc.resolve(to);
var covered = coveredDepths($from, $to);
for (var i = 0; i < covered.length; i++) {
var depth = covered[i], last2 = i == covered.length - 1;
if (last2 && depth == 0 || $from.node(depth).type.contentMatch.validEnd) {
return this.delete($from.start(depth), $to.end(depth));
}
if (depth > 0 && (last2 || $from.node(depth - 1).canReplace($from.index(depth - 1), $to.indexAfter(depth - 1)))) {
return this.delete($from.before(depth), $to.after(depth));
}
}
for (var d = 1; d <= $from.depth && d <= $to.depth; d++) {
if (from4 - $from.start(d) == $from.depth - d && to > $from.end(d) && $to.end(d) - to != $to.depth - d) {
return this.delete($from.before(d), to);
}
}
return this.delete(from4, to);
};
function coveredDepths($from, $to) {
var result2 = [], minDepth = Math.min($from.depth, $to.depth);
for (var d = minDepth; d >= 0; d--) {
var start3 = $from.start(d);
if (start3 < $from.pos - ($from.depth - d) || $to.end(d) > $to.pos + ($to.depth - d) || $from.node(d).type.spec.isolating || $to.node(d).type.spec.isolating) {
break;
}
if (start3 == $to.start(d)) {
result2.push(d);
}
}
return result2;
}
var classesById = Object.create(null);
var Selection = function Selection2($anchor, $head, ranges) {
this.ranges = ranges || [new SelectionRange($anchor.min($head), $anchor.max($head))];
this.$anchor = $anchor;
this.$head = $head;
};
var prototypeAccessors$3 = {anchor: {configurable: true}, head: {configurable: true}, from: {configurable: true}, to: {configurable: true}, $from: {configurable: true}, $to: {configurable: true}, empty: {configurable: true}};
prototypeAccessors$3.anchor.get = function() {
return this.$anchor.pos;
};
prototypeAccessors$3.head.get = function() {
return this.$head.pos;
};
prototypeAccessors$3.from.get = function() {
return this.$from.pos;
};
prototypeAccessors$3.to.get = function() {
return this.$to.pos;
};
prototypeAccessors$3.$from.get = function() {
return this.ranges[0].$from;
};
prototypeAccessors$3.$to.get = function() {
return this.ranges[0].$to;
};
prototypeAccessors$3.empty.get = function() {
var ranges = this.ranges;
for (var i = 0; i < ranges.length; i++) {
if (ranges[i].$from.pos != ranges[i].$to.pos) {
return false;
}
}
return true;
};
Selection.prototype.content = function content() {
return this.$from.node(0).slice(this.from, this.to, true);
};
Selection.prototype.replace = function replace2(tr, content2) {
if (content2 === void 0)
content2 = Slice.empty;
var lastNode = content2.content.lastChild, lastParent = null;
for (var i = 0; i < content2.openEnd; i++) {
lastParent = lastNode;
lastNode = lastNode.lastChild;
}
var mapFrom = tr.steps.length, ranges = this.ranges;
for (var i$1 = 0; i$1 < ranges.length; i$1++) {
var ref2 = ranges[i$1];
var $from = ref2.$from;
var $to = ref2.$to;
var mapping = tr.mapping.slice(mapFrom);
tr.replaceRange(mapping.map($from.pos), mapping.map($to.pos), i$1 ? Slice.empty : content2);
if (i$1 == 0) {
selectionToInsertionEnd(tr, mapFrom, (lastNode ? lastNode.isInline : lastParent && lastParent.isTextblock) ? -1 : 1);
}
}
};
Selection.prototype.replaceWith = function replaceWith(tr, node4) {
var mapFrom = tr.steps.length, ranges = this.ranges;
for (var i = 0; i < ranges.length; i++) {
var ref2 = ranges[i];
var $from = ref2.$from;
var $to = ref2.$to;
var mapping = tr.mapping.slice(mapFrom);
var from4 = mapping.map($from.pos), to = mapping.map($to.pos);
if (i) {
tr.deleteRange(from4, to);
} else {
tr.replaceRangeWith(from4, to, node4);
selectionToInsertionEnd(tr, mapFrom, node4.isInline ? -1 : 1);
}
}
};
Selection.findFrom = function findFrom($pos, dir, textOnly) {
var inner = $pos.parent.inlineContent ? new TextSelection($pos) : findSelectionIn($pos.node(0), $pos.parent, $pos.pos, $pos.index(), dir, textOnly);
if (inner) {
return inner;
}
for (var depth = $pos.depth - 1; depth >= 0; depth--) {
var found2 = dir < 0 ? findSelectionIn($pos.node(0), $pos.node(depth), $pos.before(depth + 1), $pos.index(depth), dir, textOnly) : findSelectionIn($pos.node(0), $pos.node(depth), $pos.after(depth + 1), $pos.index(depth) + 1, dir, textOnly);
if (found2) {
return found2;
}
}
};
Selection.near = function near($pos, bias) {
if (bias === void 0)
bias = 1;
return this.findFrom($pos, bias) || this.findFrom($pos, -bias) || new AllSelection($pos.node(0));
};
Selection.atStart = function atStart(doc2) {
return findSelectionIn(doc2, doc2, 0, 0, 1) || new AllSelection(doc2);
};
Selection.atEnd = function atEnd(doc2) {
return findSelectionIn(doc2, doc2, doc2.content.size, doc2.childCount, -1) || new AllSelection(doc2);
};
Selection.fromJSON = function fromJSON6(doc2, json) {
if (!json || !json.type) {
throw new RangeError("Invalid input for Selection.fromJSON");
}
var cls = classesById[json.type];
if (!cls) {
throw new RangeError("No selection type " + json.type + " defined");
}
return cls.fromJSON(doc2, json);
};
Selection.jsonID = function jsonID2(id, selectionClass) {
if (id in classesById) {
throw new RangeError("Duplicate use of selection JSON ID " + id);
}
classesById[id] = selectionClass;
selectionClass.prototype.jsonID = id;
return selectionClass;
};
Selection.prototype.getBookmark = function getBookmark() {
return TextSelection.between(this.$anchor, this.$head).getBookmark();
};
Object.defineProperties(Selection.prototype, prototypeAccessors$3);
Selection.prototype.visible = true;
var SelectionRange = function SelectionRange2($from, $to) {
this.$from = $from;
this.$to = $to;
};
var TextSelection = /* @__PURE__ */ function(Selection3) {
function TextSelection2($anchor, $head) {
if ($head === void 0)
$head = $anchor;
Selection3.call(this, $anchor, $head);
}
if (Selection3)
TextSelection2.__proto__ = Selection3;
TextSelection2.prototype = Object.create(Selection3 && Selection3.prototype);
TextSelection2.prototype.constructor = TextSelection2;
var prototypeAccessors$12 = {$cursor: {configurable: true}};
prototypeAccessors$12.$cursor.get = function() {
return this.$anchor.pos == this.$head.pos ? this.$head : null;
};
TextSelection2.prototype.map = function map16(doc2, mapping) {
var $head = doc2.resolve(mapping.map(this.head));
if (!$head.parent.inlineContent) {
return Selection3.near($head);
}
var $anchor = doc2.resolve(mapping.map(this.anchor));
return new TextSelection2($anchor.parent.inlineContent ? $anchor : $head, $head);
};
TextSelection2.prototype.replace = function replace4(tr, content2) {
if (content2 === void 0)
content2 = Slice.empty;
Selection3.prototype.replace.call(this, tr, content2);
if (content2 == Slice.empty) {
var marks2 = this.$from.marksAcross(this.$to);
if (marks2) {
tr.ensureMarks(marks2);
}
}
};
TextSelection2.prototype.eq = function eq13(other) {
return other instanceof TextSelection2 && other.anchor == this.anchor && other.head == this.head;
};
TextSelection2.prototype.getBookmark = function getBookmark2() {
return new TextBookmark(this.anchor, this.head);
};
TextSelection2.prototype.toJSON = function toJSON7() {
return {type: "text", anchor: this.anchor, head: this.head};
};
TextSelection2.fromJSON = function fromJSON8(doc2, json) {
if (typeof json.anchor != "number" || typeof json.head != "number") {
throw new RangeError("Invalid input for TextSelection.fromJSON");
}
return new TextSelection2(doc2.resolve(json.anchor), doc2.resolve(json.head));
};
TextSelection2.create = function create7(doc2, anchor, head) {
if (head === void 0)
head = anchor;
var $anchor = doc2.resolve(anchor);
return new this($anchor, head == anchor ? $anchor : doc2.resolve(head));
};
TextSelection2.between = function between($anchor, $head, bias) {
var dPos = $anchor.pos - $head.pos;
if (!bias || dPos) {
bias = dPos >= 0 ? 1 : -1;
}
if (!$head.parent.inlineContent) {
var found2 = Selection3.findFrom($head, bias, true) || Selection3.findFrom($head, -bias, true);
if (found2) {
$head = found2.$head;
} else {
return Selection3.near($head, bias);
}
}
if (!$anchor.parent.inlineContent) {
if (dPos == 0) {
$anchor = $head;
} else {
$anchor = (Selection3.findFrom($anchor, -bias, true) || Selection3.findFrom($anchor, bias, true)).$anchor;
if ($anchor.pos < $head.pos != dPos < 0) {
$anchor = $head;
}
}
}
return new TextSelection2($anchor, $head);
};
Object.defineProperties(TextSelection2.prototype, prototypeAccessors$12);
return TextSelection2;
}(Selection);
Selection.jsonID("text", TextSelection);
var TextBookmark = function TextBookmark2(anchor, head) {
this.anchor = anchor;
this.head = head;
};
TextBookmark.prototype.map = function map5(mapping) {
return new TextBookmark(mapping.map(this.anchor), mapping.map(this.head));
};
TextBookmark.prototype.resolve = function resolve4(doc2) {
return TextSelection.between(doc2.resolve(this.anchor), doc2.resolve(this.head));
};
var NodeSelection = /* @__PURE__ */ function(Selection3) {
function NodeSelection2($pos) {
var node4 = $pos.nodeAfter;
var $end = $pos.node(0).resolve($pos.pos + node4.nodeSize);
Selection3.call(this, $pos, $end);
this.node = node4;
}
if (Selection3)
NodeSelection2.__proto__ = Selection3;
NodeSelection2.prototype = Object.create(Selection3 && Selection3.prototype);
NodeSelection2.prototype.constructor = NodeSelection2;
NodeSelection2.prototype.map = function map16(doc2, mapping) {
var ref2 = mapping.mapResult(this.anchor);
var deleted = ref2.deleted;
var pos = ref2.pos;
var $pos = doc2.resolve(pos);
if (deleted) {
return Selection3.near($pos);
}
return new NodeSelection2($pos);
};
NodeSelection2.prototype.content = function content2() {
return new Slice(Fragment.from(this.node), 0, 0);
};
NodeSelection2.prototype.eq = function eq13(other) {
return other instanceof NodeSelection2 && other.anchor == this.anchor;
};
NodeSelection2.prototype.toJSON = function toJSON7() {
return {type: "node", anchor: this.anchor};
};
NodeSelection2.prototype.getBookmark = function getBookmark2() {
return new NodeBookmark(this.anchor);
};
NodeSelection2.fromJSON = function fromJSON8(doc2, json) {
if (typeof json.anchor != "number") {
throw new RangeError("Invalid input for NodeSelection.fromJSON");
}
return new NodeSelection2(doc2.resolve(json.anchor));
};
NodeSelection2.create = function create7(doc2, from4) {
return new this(doc2.resolve(from4));
};
NodeSelection2.isSelectable = function isSelectable(node4) {
return !node4.isText && node4.type.spec.selectable !== false;
};
return NodeSelection2;
}(Selection);
NodeSelection.prototype.visible = false;
Selection.jsonID("node", NodeSelection);
var NodeBookmark = function NodeBookmark2(anchor) {
this.anchor = anchor;
};
NodeBookmark.prototype.map = function map6(mapping) {
var ref2 = mapping.mapResult(this.anchor);
var deleted = ref2.deleted;
var pos = ref2.pos;
return deleted ? new TextBookmark(pos, pos) : new NodeBookmark(pos);
};
NodeBookmark.prototype.resolve = function resolve5(doc2) {
var $pos = doc2.resolve(this.anchor), node4 = $pos.nodeAfter;
if (node4 && NodeSelection.isSelectable(node4)) {
return new NodeSelection($pos);
}
return Selection.near($pos);
};
var AllSelection = /* @__PURE__ */ function(Selection3) {
function AllSelection2(doc2) {
Selection3.call(this, doc2.resolve(0), doc2.resolve(doc2.content.size));
}
if (Selection3)
AllSelection2.__proto__ = Selection3;
AllSelection2.prototype = Object.create(Selection3 && Selection3.prototype);
AllSelection2.prototype.constructor = AllSelection2;
AllSelection2.prototype.replace = function replace4(tr, content2) {
if (content2 === void 0)
content2 = Slice.empty;
if (content2 == Slice.empty) {
tr.delete(0, tr.doc.content.size);
var sel = Selection3.atStart(tr.doc);
if (!sel.eq(tr.selection)) {
tr.setSelection(sel);
}
} else {
Selection3.prototype.replace.call(this, tr, content2);
}
};
AllSelection2.prototype.toJSON = function toJSON7() {
return {type: "all"};
};
AllSelection2.fromJSON = function fromJSON8(doc2) {
return new AllSelection2(doc2);
};
AllSelection2.prototype.map = function map16(doc2) {
return new AllSelection2(doc2);
};
AllSelection2.prototype.eq = function eq13(other) {
return other instanceof AllSelection2;
};
AllSelection2.prototype.getBookmark = function getBookmark2() {
return AllBookmark;
};
return AllSelection2;
}(Selection);
Selection.jsonID("all", AllSelection);
var AllBookmark = {
map: function map7() {
return this;
},
resolve: function resolve6(doc2) {
return new AllSelection(doc2);
}
};
function findSelectionIn(doc2, node4, pos, index3, dir, text3) {
if (node4.inlineContent) {
return TextSelection.create(doc2, pos);
}
for (var i = index3 - (dir > 0 ? 0 : 1); dir > 0 ? i < node4.childCount : i >= 0; i += dir) {
var child3 = node4.child(i);
if (!child3.isAtom) {
var inner = findSelectionIn(doc2, child3, pos + dir, dir < 0 ? child3.childCount : 0, dir, text3);
if (inner) {
return inner;
}
} else if (!text3 && NodeSelection.isSelectable(child3)) {
return NodeSelection.create(doc2, pos - (dir < 0 ? child3.nodeSize : 0));
}
pos += child3.nodeSize * dir;
}
}
function selectionToInsertionEnd(tr, startLen, bias) {
var last2 = tr.steps.length - 1;
if (last2 < startLen) {
return;
}
var step2 = tr.steps[last2];
if (!(step2 instanceof ReplaceStep || step2 instanceof ReplaceAroundStep)) {
return;
}
var map16 = tr.mapping.maps[last2], end2;
map16.forEach(function(_from, _to, _newFrom, newTo) {
if (end2 == null) {
end2 = newTo;
}
});
tr.setSelection(Selection.near(tr.doc.resolve(end2), bias));
}
var UPDATED_SEL = 1, UPDATED_MARKS = 2, UPDATED_SCROLL = 4;
var Transaction = /* @__PURE__ */ function(Transform3) {
function Transaction2(state) {
Transform3.call(this, state.doc);
this.time = Date.now();
this.curSelection = state.selection;
this.curSelectionFor = 0;
this.storedMarks = state.storedMarks;
this.updated = 0;
this.meta = Object.create(null);
}
if (Transform3)
Transaction2.__proto__ = Transform3;
Transaction2.prototype = Object.create(Transform3 && Transform3.prototype);
Transaction2.prototype.constructor = Transaction2;
var prototypeAccessors2 = {selection: {configurable: true}, selectionSet: {configurable: true}, storedMarksSet: {configurable: true}, isGeneric: {configurable: true}, scrolledIntoView: {configurable: true}};
prototypeAccessors2.selection.get = function() {
if (this.curSelectionFor < this.steps.length) {
this.curSelection = this.curSelection.map(this.doc, this.mapping.slice(this.curSelectionFor));
this.curSelectionFor = this.steps.length;
}
return this.curSelection;
};
Transaction2.prototype.setSelection = function setSelection2(selection) {
if (selection.$from.doc != this.doc) {
throw new RangeError("Selection passed to setSelection must point at the current document");
}
this.curSelection = selection;
this.curSelectionFor = this.steps.length;
this.updated = (this.updated | UPDATED_SEL) & ~UPDATED_MARKS;
this.storedMarks = null;
return this;
};
prototypeAccessors2.selectionSet.get = function() {
return (this.updated & UPDATED_SEL) > 0;
};
Transaction2.prototype.setStoredMarks = function setStoredMarks(marks2) {
this.storedMarks = marks2;
this.updated |= UPDATED_MARKS;
return this;
};
Transaction2.prototype.ensureMarks = function ensureMarks(marks2) {
if (!Mark$1.sameSet(this.storedMarks || this.selection.$from.marks(), marks2)) {
this.setStoredMarks(marks2);
}
return this;
};
Transaction2.prototype.addStoredMark = function addStoredMark(mark3) {
return this.ensureMarks(mark3.addToSet(this.storedMarks || this.selection.$head.marks()));
};
Transaction2.prototype.removeStoredMark = function removeStoredMark(mark3) {
return this.ensureMarks(mark3.removeFromSet(this.storedMarks || this.selection.$head.marks()));
};
prototypeAccessors2.storedMarksSet.get = function() {
return (this.updated & UPDATED_MARKS) > 0;
};
Transaction2.prototype.addStep = function addStep2(step2, doc2) {
Transform3.prototype.addStep.call(this, step2, doc2);
this.updated = this.updated & ~UPDATED_MARKS;
this.storedMarks = null;
};
Transaction2.prototype.setTime = function setTime(time) {
this.time = time;
return this;
};
Transaction2.prototype.replaceSelection = function replaceSelection(slice5) {
this.selection.replace(this, slice5);
return this;
};
Transaction2.prototype.replaceSelectionWith = function replaceSelectionWith(node4, inheritMarks) {
var selection = this.selection;
if (inheritMarks !== false) {
node4 = node4.mark(this.storedMarks || (selection.empty ? selection.$from.marks() : selection.$from.marksAcross(selection.$to) || Mark$1.none));
}
selection.replaceWith(this, node4);
return this;
};
Transaction2.prototype.deleteSelection = function deleteSelection2() {
this.selection.replace(this);
return this;
};
Transaction2.prototype.insertText = function insertText(text3, from4, to) {
if (to === void 0)
to = from4;
var schema = this.doc.type.schema;
if (from4 == null) {
if (!text3) {
return this.deleteSelection();
}
return this.replaceSelectionWith(schema.text(text3), true);
} else {
if (!text3) {
return this.deleteRange(from4, to);
}
var marks2 = this.storedMarks;
if (!marks2) {
var $from = this.doc.resolve(from4);
marks2 = to == from4 ? $from.marks() : $from.marksAcross(this.doc.resolve(to));
}
this.replaceRangeWith(from4, to, schema.text(text3, marks2));
if (!this.selection.empty) {
this.setSelection(Selection.near(this.selection.$to));
}
return this;
}
};
Transaction2.prototype.setMeta = function setMeta(key, value) {
this.meta[typeof key == "string" ? key : key.key] = value;
return this;
};
Transaction2.prototype.getMeta = function getMeta(key) {
return this.meta[typeof key == "string" ? key : key.key];
};
prototypeAccessors2.isGeneric.get = function() {
for (var _2 in this.meta) {
return false;
}
return true;
};
Transaction2.prototype.scrollIntoView = function scrollIntoView() {
this.updated |= UPDATED_SCROLL;
return this;
};
prototypeAccessors2.scrolledIntoView.get = function() {
return (this.updated & UPDATED_SCROLL) > 0;
};
Object.defineProperties(Transaction2.prototype, prototypeAccessors2);
return Transaction2;
}(Transform);
function bind2(f, self2) {
return !self2 || !f ? f : f.bind(self2);
}
var FieldDesc = function FieldDesc2(name, desc, self2) {
this.name = name;
this.init = bind2(desc.init, self2);
this.apply = bind2(desc.apply, self2);
};
var baseFields = [
new FieldDesc("doc", {
init: function init3(config2) {
return config2.doc || config2.schema.topNodeType.createAndFill();
},
apply: function apply2(tr) {
return tr.doc;
}
}),
new FieldDesc("selection", {
init: function init4(config2, instance) {
return config2.selection || Selection.atStart(instance.doc);
},
apply: function apply3(tr) {
return tr.selection;
}
}),
new FieldDesc("storedMarks", {
init: function init5(config2) {
return config2.storedMarks || null;
},
apply: function apply4(tr, _marks, _old, state) {
return state.selection.$cursor ? tr.storedMarks : null;
}
}),
new FieldDesc("scrollToSelection", {
init: function init6() {
return 0;
},
apply: function apply5(tr, prev) {
return tr.scrolledIntoView ? prev + 1 : prev;
}
})
];
var Configuration = function Configuration2(schema, plugins2) {
var this$1 = this;
this.schema = schema;
this.fields = baseFields.concat();
this.plugins = [];
this.pluginsByKey = Object.create(null);
if (plugins2) {
plugins2.forEach(function(plugin) {
if (this$1.pluginsByKey[plugin.key]) {
throw new RangeError("Adding different instances of a keyed plugin (" + plugin.key + ")");
}
this$1.plugins.push(plugin);
this$1.pluginsByKey[plugin.key] = plugin;
if (plugin.spec.state) {
this$1.fields.push(new FieldDesc(plugin.key, plugin.spec.state, plugin));
}
});
}
};
var EditorState = function EditorState2(config2) {
this.config = config2;
};
var prototypeAccessors$1$1 = {schema: {configurable: true}, plugins: {configurable: true}, tr: {configurable: true}};
prototypeAccessors$1$1.schema.get = function() {
return this.config.schema;
};
prototypeAccessors$1$1.plugins.get = function() {
return this.config.plugins;
};
EditorState.prototype.apply = function apply6(tr) {
return this.applyTransaction(tr).state;
};
EditorState.prototype.filterTransaction = function filterTransaction(tr, ignore) {
if (ignore === void 0)
ignore = -1;
for (var i = 0; i < this.config.plugins.length; i++) {
if (i != ignore) {
var plugin = this.config.plugins[i];
if (plugin.spec.filterTransaction && !plugin.spec.filterTransaction.call(plugin, tr, this)) {
return false;
}
}
}
return true;
};
EditorState.prototype.applyTransaction = function applyTransaction(rootTr) {
if (!this.filterTransaction(rootTr)) {
return {state: this, transactions: []};
}
var trs = [rootTr], newState = this.applyInner(rootTr), seen = null;
for (; ; ) {
var haveNew = false;
for (var i = 0; i < this.config.plugins.length; i++) {
var plugin = this.config.plugins[i];
if (plugin.spec.appendTransaction) {
var n = seen ? seen[i].n : 0, oldState = seen ? seen[i].state : this;
var tr = n < trs.length && plugin.spec.appendTransaction.call(plugin, n ? trs.slice(n) : trs, oldState, newState);
if (tr && newState.filterTransaction(tr, i)) {
tr.setMeta("appendedTransaction", rootTr);
if (!seen) {
seen = [];
for (var j = 0; j < this.config.plugins.length; j++) {
seen.push(j < i ? {state: newState, n: trs.length} : {state: this, n: 0});
}
}
trs.push(tr);
newState = newState.applyInner(tr);
haveNew = true;
}
if (seen) {
seen[i] = {state: newState, n: trs.length};
}
}
}
if (!haveNew) {
return {state: newState, transactions: trs};
}
}
};
EditorState.prototype.applyInner = function applyInner(tr) {
if (!tr.before.eq(this.doc)) {
throw new RangeError("Applying a mismatched transaction");
}
var newInstance = new EditorState(this.config), fields = this.config.fields;
for (var i = 0; i < fields.length; i++) {
var field = fields[i];
newInstance[field.name] = field.apply(tr, this[field.name], this, newInstance);
}
for (var i$1 = 0; i$1 < applyListeners.length; i$1++) {
applyListeners[i$1](this, tr, newInstance);
}
return newInstance;
};
prototypeAccessors$1$1.tr.get = function() {
return new Transaction(this);
};
EditorState.create = function create4(config2) {
var $config = new Configuration(config2.doc ? config2.doc.type.schema : config2.schema, config2.plugins);
var instance = new EditorState($config);
for (var i = 0; i < $config.fields.length; i++) {
instance[$config.fields[i].name] = $config.fields[i].init(config2, instance);
}
return instance;
};
EditorState.prototype.reconfigure = function reconfigure(config2) {
var $config = new Configuration(this.schema, config2.plugins);
var fields = $config.fields, instance = new EditorState($config);
for (var i = 0; i < fields.length; i++) {
var name = fields[i].name;
instance[name] = this.hasOwnProperty(name) ? this[name] : fields[i].init(config2, instance);
}
return instance;
};
EditorState.prototype.toJSON = function toJSON6(pluginFields) {
var result2 = {doc: this.doc.toJSON(), selection: this.selection.toJSON()};
if (this.storedMarks) {
result2.storedMarks = this.storedMarks.map(function(m) {
return m.toJSON();
});
}
if (pluginFields && typeof pluginFields == "object") {
for (var prop in pluginFields) {
if (prop == "doc" || prop == "selection") {
throw new RangeError("The JSON fields `doc` and `selection` are reserved");
}
var plugin = pluginFields[prop], state = plugin.spec.state;
if (state && state.toJSON) {
result2[prop] = state.toJSON.call(plugin, this[plugin.key]);
}
}
}
return result2;
};
EditorState.fromJSON = function fromJSON7(config2, json, pluginFields) {
if (!json) {
throw new RangeError("Invalid input for EditorState.fromJSON");
}
if (!config2.schema) {
throw new RangeError("Required config field 'schema' missing");
}
var $config = new Configuration(config2.schema, config2.plugins);
var instance = new EditorState($config);
$config.fields.forEach(function(field) {
if (field.name == "doc") {
instance.doc = Node$2.fromJSON(config2.schema, json.doc);
} else if (field.name == "selection") {
instance.selection = Selection.fromJSON(instance.doc, json.selection);
} else if (field.name == "storedMarks") {
if (json.storedMarks) {
instance.storedMarks = json.storedMarks.map(config2.schema.markFromJSON);
}
} else {
if (pluginFields) {
for (var prop in pluginFields) {
var plugin = pluginFields[prop], state = plugin.spec.state;
if (plugin.key == field.name && state && state.fromJSON && Object.prototype.hasOwnProperty.call(json, prop)) {
instance[field.name] = state.fromJSON.call(plugin, config2, json[prop], instance);
return;
}
}
}
instance[field.name] = field.init(config2, instance);
}
});
return instance;
};
EditorState.addApplyListener = function addApplyListener(f) {
applyListeners.push(f);
};
EditorState.removeApplyListener = function removeApplyListener(f) {
var found2 = applyListeners.indexOf(f);
if (found2 > -1) {
applyListeners.splice(found2, 1);
}
};
Object.defineProperties(EditorState.prototype, prototypeAccessors$1$1);
var applyListeners = [];
function bindProps(obj, self2, target2) {
for (var prop in obj) {
var val = obj[prop];
if (val instanceof Function) {
val = val.bind(self2);
} else if (prop == "handleDOMEvents") {
val = bindProps(val, self2, {});
}
target2[prop] = val;
}
return target2;
}
var Plugin = function Plugin2(spec) {
this.props = {};
if (spec.props) {
bindProps(spec.props, this, this.props);
}
this.spec = spec;
this.key = spec.key ? spec.key.key : createKey("plugin");
};
Plugin.prototype.getState = function getState(state) {
return state[this.key];
};
var keys = Object.create(null);
function createKey(name) {
if (name in keys) {
return name + "$" + ++keys[name];
}
keys[name] = 0;
return name + "$";
}
var PluginKey = function PluginKey2(name) {
if (name === void 0)
name = "key";
this.key = createKey(name);
};
PluginKey.prototype.get = function get4(state) {
return state.config.pluginsByKey[this.key];
};
PluginKey.prototype.getState = function getState2(state) {
return state[this.key];
};
var result = {};
if (typeof navigator != "undefined" && typeof document != "undefined") {
var ie_edge = /Edge\/(\d+)/.exec(navigator.userAgent);
var ie_upto10 = /MSIE \d/.test(navigator.userAgent);
var ie_11up = /Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);
result.mac = /Mac/.test(navigator.platform);
var ie$1 = result.ie = !!(ie_upto10 || ie_11up || ie_edge);
result.ie_version = ie_upto10 ? document.documentMode || 6 : ie_11up ? +ie_11up[1] : ie_edge ? +ie_edge[1] : null;
result.gecko = !ie$1 && /gecko\/(\d+)/i.test(navigator.userAgent);
result.gecko_version = result.gecko && +(/Firefox\/(\d+)/.exec(navigator.userAgent) || [0, 0])[1];
var chrome$1 = !ie$1 && /Chrome\/(\d+)/.exec(navigator.userAgent);
result.chrome = !!chrome$1;
result.chrome_version = chrome$1 && +chrome$1[1];
result.safari = !ie$1 && /Apple Computer/.test(navigator.vendor);
result.ios = result.safari && (/Mobile\/\w+/.test(navigator.userAgent) || navigator.maxTouchPoints > 2);
result.android = /Android \d/.test(navigator.userAgent);
result.webkit = "webkitFontSmoothing" in document.documentElement.style;
result.webkit_version = result.webkit && +(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent) || [0, 0])[1];
}
var domIndex = function(node4) {
for (var index3 = 0; ; index3++) {
node4 = node4.previousSibling;
if (!node4) {
return index3;
}
}
};
var parentNode = function(node4) {
var parent = node4.parentNode;
return parent && parent.nodeType == 11 ? parent.host : parent;
};
var reusedRange = null;
var textRange$1 = function(node4, from4, to) {
var range2 = reusedRange || (reusedRange = document.createRange());
range2.setEnd(node4, to == null ? node4.nodeValue.length : to);
range2.setStart(node4, from4 || 0);
return range2;
};
var isEquivalentPosition = function(node4, off2, targetNode, targetOff) {
return targetNode && (scanFor(node4, off2, targetNode, targetOff, -1) || scanFor(node4, off2, targetNode, targetOff, 1));
};
var atomElements = /^(img|br|input|textarea|hr)$/i;
function scanFor(node4, off2, targetNode, targetOff, dir) {
for (; ; ) {
if (node4 == targetNode && off2 == targetOff) {
return true;
}
if (off2 == (dir < 0 ? 0 : nodeSize(node4))) {
var parent = node4.parentNode;
if (parent.nodeType != 1 || hasBlockDesc(node4) || atomElements.test(node4.nodeName) || node4.contentEditable == "false") {
return false;
}
off2 = domIndex(node4) + (dir < 0 ? 0 : 1);
node4 = parent;
} else if (node4.nodeType == 1) {
node4 = node4.childNodes[off2 + (dir < 0 ? -1 : 0)];
if (node4.contentEditable == "false") {
return false;
}
off2 = dir < 0 ? nodeSize(node4) : 0;
} else {
return false;
}
}
}
function nodeSize(node4) {
return node4.nodeType == 3 ? node4.nodeValue.length : node4.childNodes.length;
}
function isOnEdge(node4, offset2, parent) {
for (var atStart2 = offset2 == 0, atEnd2 = offset2 == nodeSize(node4); atStart2 || atEnd2; ) {
if (node4 == parent) {
return true;
}
var index3 = domIndex(node4);
node4 = node4.parentNode;
if (!node4) {
return false;
}
atStart2 = atStart2 && index3 == 0;
atEnd2 = atEnd2 && index3 == nodeSize(node4);
}
}
function hasBlockDesc(dom) {
var desc;
for (var cur = dom; cur; cur = cur.parentNode) {
if (desc = cur.pmViewDesc) {
break;
}
}
return desc && desc.node && desc.node.isBlock && (desc.dom == dom || desc.contentDOM == dom);
}
var selectionCollapsed = function(domSel) {
var collapsed = domSel.isCollapsed;
if (collapsed && result.chrome && domSel.rangeCount && !domSel.getRangeAt(0).collapsed) {
collapsed = false;
}
return collapsed;
};
function keyEvent(keyCode, key) {
var event = document.createEvent("Event");
event.initEvent("keydown", true, true);
event.keyCode = keyCode;
event.key = event.code = key;
return event;
}
function windowRect(doc2) {
return {
left: 0,
right: doc2.documentElement.clientWidth,
top: 0,
bottom: doc2.documentElement.clientHeight
};
}
function getSide(value, side) {
return typeof value == "number" ? value : value[side];
}
function clientRect(node4) {
var rect = node4.getBoundingClientRect();
var scaleX = rect.width / node4.offsetWidth || 1;
var scaleY = rect.height / node4.offsetHeight || 1;
return {
left: rect.left,
right: rect.left + node4.clientWidth * scaleX,
top: rect.top,
bottom: rect.top + node4.clientHeight * scaleY
};
}
function scrollRectIntoView(view, rect, startDOM) {
var scrollThreshold = view.someProp("scrollThreshold") || 0, scrollMargin = view.someProp("scrollMargin") || 5;
var doc2 = view.dom.ownerDocument;
for (var parent = startDOM || view.dom; ; parent = parentNode(parent)) {
if (!parent) {
break;
}
if (parent.nodeType != 1) {
continue;
}
var atTop = parent == doc2.body || parent.nodeType != 1;
var bounding = atTop ? windowRect(doc2) : clientRect(parent);
var moveX = 0, moveY = 0;
if (rect.top < bounding.top + getSide(scrollThreshold, "top")) {
moveY = -(bounding.top - rect.top + getSide(scrollMargin, "top"));
} else if (rect.bottom > bounding.bottom - getSide(scrollThreshold, "bottom")) {
moveY = rect.bottom - bounding.bottom + getSide(scrollMargin, "bottom");
}
if (rect.left < bounding.left + getSide(scrollThreshold, "left")) {
moveX = -(bounding.left - rect.left + getSide(scrollMargin, "left"));
} else if (rect.right > bounding.right - getSide(scrollThreshold, "right")) {
moveX = rect.right - bounding.right + getSide(scrollMargin, "right");
}
if (moveX || moveY) {
if (atTop) {
doc2.defaultView.scrollBy(moveX, moveY);
} else {
var startX = parent.scrollLeft, startY = parent.scrollTop;
if (moveY) {
parent.scrollTop += moveY;
}
if (moveX) {
parent.scrollLeft += moveX;
}
var dX = parent.scrollLeft - startX, dY = parent.scrollTop - startY;
rect = {left: rect.left - dX, top: rect.top - dY, right: rect.right - dX, bottom: rect.bottom - dY};
}
}
if (atTop) {
break;
}
}
}
function storeScrollPos(view) {
var rect = view.dom.getBoundingClientRect(), startY = Math.max(0, rect.top);
var refDOM, refTop;
for (var x = (rect.left + rect.right) / 2, y = startY + 1; y < Math.min(innerHeight, rect.bottom); y += 5) {
var dom = view.root.elementFromPoint(x, y);
if (dom == view.dom || !view.dom.contains(dom)) {
continue;
}
var localRect = dom.getBoundingClientRect();
if (localRect.top >= startY - 20) {
refDOM = dom;
refTop = localRect.top;
break;
}
}
return {refDOM, refTop, stack: scrollStack(view.dom)};
}
function scrollStack(dom) {
var stack = [], doc2 = dom.ownerDocument;
for (; dom; dom = parentNode(dom)) {
stack.push({dom, top: dom.scrollTop, left: dom.scrollLeft});
if (dom == doc2) {
break;
}
}
return stack;
}
function resetScrollPos(ref2) {
var refDOM = ref2.refDOM;
var refTop = ref2.refTop;
var stack = ref2.stack;
var newRefTop = refDOM ? refDOM.getBoundingClientRect().top : 0;
restoreScrollStack(stack, newRefTop == 0 ? 0 : newRefTop - refTop);
}
function restoreScrollStack(stack, dTop) {
for (var i = 0; i < stack.length; i++) {
var ref2 = stack[i];
var dom = ref2.dom;
var top = ref2.top;
var left = ref2.left;
if (dom.scrollTop != top + dTop) {
dom.scrollTop = top + dTop;
}
if (dom.scrollLeft != left) {
dom.scrollLeft = left;
}
}
}
var preventScrollSupported = null;
function focusPreventScroll(dom) {
if (dom.setActive) {
return dom.setActive();
}
if (preventScrollSupported) {
return dom.focus(preventScrollSupported);
}
var stored = scrollStack(dom);
dom.focus(preventScrollSupported == null ? {
get preventScroll() {
preventScrollSupported = {preventScroll: true};
return true;
}
} : void 0);
if (!preventScrollSupported) {
preventScrollSupported = false;
restoreScrollStack(stored, 0);
}
}
function findOffsetInNode(node4, coords) {
var closest2, dxClosest = 2e8, coordsClosest, offset2 = 0;
var rowBot = coords.top, rowTop = coords.top;
for (var child3 = node4.firstChild, childIndex = 0; child3; child3 = child3.nextSibling, childIndex++) {
var rects = void 0;
if (child3.nodeType == 1) {
rects = child3.getClientRects();
} else if (child3.nodeType == 3) {
rects = textRange$1(child3).getClientRects();
} else {
continue;
}
for (var i = 0; i < rects.length; i++) {
var rect = rects[i];
if (rect.top <= rowBot && rect.bottom >= rowTop) {
rowBot = Math.max(rect.bottom, rowBot);
rowTop = Math.min(rect.top, rowTop);
var dx = rect.left > coords.left ? rect.left - coords.left : rect.right < coords.left ? coords.left - rect.right : 0;
if (dx < dxClosest) {
closest2 = child3;
dxClosest = dx;
coordsClosest = dx && closest2.nodeType == 3 ? {left: rect.right < coords.left ? rect.right : rect.left, top: coords.top} : coords;
if (child3.nodeType == 1 && dx) {
offset2 = childIndex + (coords.left >= (rect.left + rect.right) / 2 ? 1 : 0);
}
continue;
}
}
if (!closest2 && (coords.left >= rect.right && coords.top >= rect.top || coords.left >= rect.left && coords.top >= rect.bottom)) {
offset2 = childIndex + 1;
}
}
}
if (closest2 && closest2.nodeType == 3) {
return findOffsetInText(closest2, coordsClosest);
}
if (!closest2 || dxClosest && closest2.nodeType == 1) {
return {node: node4, offset: offset2};
}
return findOffsetInNode(closest2, coordsClosest);
}
function findOffsetInText(node4, coords) {
var len2 = node4.nodeValue.length;
var range2 = document.createRange();
for (var i = 0; i < len2; i++) {
range2.setEnd(node4, i + 1);
range2.setStart(node4, i);
var rect = singleRect$1(range2, 1);
if (rect.top == rect.bottom) {
continue;
}
if (inRect(coords, rect)) {
return {node: node4, offset: i + (coords.left >= (rect.left + rect.right) / 2 ? 1 : 0)};
}
}
return {node: node4, offset: 0};
}
function inRect(coords, rect) {
return coords.left >= rect.left - 1 && coords.left <= rect.right + 1 && coords.top >= rect.top - 1 && coords.top <= rect.bottom + 1;
}
function targetKludge(dom, coords) {
var parent = dom.parentNode;
if (parent && /^li$/i.test(parent.nodeName) && coords.left < dom.getBoundingClientRect().left) {
return parent;
}
return dom;
}
function posFromElement(view, elt, coords) {
var ref2 = findOffsetInNode(elt, coords);
var node4 = ref2.node;
var offset2 = ref2.offset;
var bias = -1;
if (node4.nodeType == 1 && !node4.firstChild) {
var rect = node4.getBoundingClientRect();
bias = rect.left != rect.right && coords.left > (rect.left + rect.right) / 2 ? 1 : -1;
}
return view.docView.posFromDOM(node4, offset2, bias);
}
function posFromCaret(view, node4, offset2, coords) {
var outside = -1;
for (var cur = node4; ; ) {
if (cur == view.dom) {
break;
}
var desc = view.docView.nearestDesc(cur, true);
if (!desc) {
return null;
}
if (desc.node.isBlock && desc.parent) {
var rect = desc.dom.getBoundingClientRect();
if (rect.left > coords.left || rect.top > coords.top) {
outside = desc.posBefore;
} else if (rect.right < coords.left || rect.bottom < coords.top) {
outside = desc.posAfter;
} else {
break;
}
}
cur = desc.dom.parentNode;
}
return outside > -1 ? outside : view.docView.posFromDOM(node4, offset2);
}
function elementFromPoint(element, coords, box) {
var len2 = element.childNodes.length;
if (len2 && box.top < box.bottom) {
for (var startI = Math.max(0, Math.min(len2 - 1, Math.floor(len2 * (coords.top - box.top) / (box.bottom - box.top)) - 2)), i = startI; ; ) {
var child3 = element.childNodes[i];
if (child3.nodeType == 1) {
var rects = child3.getClientRects();
for (var j = 0; j < rects.length; j++) {
var rect = rects[j];
if (inRect(coords, rect)) {
return elementFromPoint(child3, coords, rect);
}
}
}
if ((i = (i + 1) % len2) == startI) {
break;
}
}
}
return element;
}
function posAtCoords(view, coords) {
var assign2, assign$1;
var root2 = view.root, node4, offset2;
if (root2.caretPositionFromPoint) {
try {
var pos$1 = root2.caretPositionFromPoint(coords.left, coords.top);
if (pos$1) {
assign2 = pos$1, node4 = assign2.offsetNode, offset2 = assign2.offset;
}
} catch (_2) {
}
}
if (!node4 && root2.caretRangeFromPoint) {
var range2 = root2.caretRangeFromPoint(coords.left, coords.top);
if (range2) {
assign$1 = range2, node4 = assign$1.startContainer, offset2 = assign$1.startOffset;
}
}
var elt = root2.elementFromPoint(coords.left, coords.top + 1), pos;
if (!elt || !view.dom.contains(elt.nodeType != 1 ? elt.parentNode : elt)) {
var box = view.dom.getBoundingClientRect();
if (!inRect(coords, box)) {
return null;
}
elt = elementFromPoint(view.dom, coords, box);
if (!elt) {
return null;
}
}
if (result.safari && elt.draggable) {
node4 = offset2 = null;
}
elt = targetKludge(elt, coords);
if (node4) {
if (result.gecko && node4.nodeType == 1) {
offset2 = Math.min(offset2, node4.childNodes.length);
if (offset2 < node4.childNodes.length) {
var next2 = node4.childNodes[offset2], box$1;
if (next2.nodeName == "IMG" && (box$1 = next2.getBoundingClientRect()).right <= coords.left && box$1.bottom > coords.top) {
offset2++;
}
}
}
if (node4 == view.dom && offset2 == node4.childNodes.length - 1 && node4.lastChild.nodeType == 1 && coords.top > node4.lastChild.getBoundingClientRect().bottom) {
pos = view.state.doc.content.size;
} else if (offset2 == 0 || node4.nodeType != 1 || node4.childNodes[offset2 - 1].nodeName != "BR") {
pos = posFromCaret(view, node4, offset2, coords);
}
}
if (pos == null) {
pos = posFromElement(view, elt, coords);
}
var desc = view.docView.nearestDesc(elt, true);
return {pos, inside: desc ? desc.posAtStart - desc.border : -1};
}
function singleRect$1(object2, bias) {
var rects = object2.getClientRects();
return !rects.length ? object2.getBoundingClientRect() : rects[bias < 0 ? 0 : rects.length - 1];
}
var BIDI = /[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;
function coordsAtPos$1(view, pos, side) {
var ref2 = view.docView.domFromPos(pos, side < 0 ? -1 : 1);
var node4 = ref2.node;
var offset2 = ref2.offset;
var supportEmptyRange = result.webkit || result.gecko;
if (node4.nodeType == 3) {
if (supportEmptyRange && (BIDI.test(node4.nodeValue) || (side < 0 ? !offset2 : offset2 == node4.nodeValue.length))) {
var rect = singleRect$1(textRange$1(node4, offset2, offset2), side);
if (result.gecko && offset2 && /\s/.test(node4.nodeValue[offset2 - 1]) && offset2 < node4.nodeValue.length) {
var rectBefore = singleRect$1(textRange$1(node4, offset2 - 1, offset2 - 1), -1);
if (rectBefore.top == rect.top) {
var rectAfter = singleRect$1(textRange$1(node4, offset2, offset2 + 1), -1);
if (rectAfter.top != rect.top) {
return flattenV(rectAfter, rectAfter.left < rectBefore.left);
}
}
}
return rect;
} else {
var from4 = offset2, to = offset2, takeSide = side < 0 ? 1 : -1;
if (side < 0 && !offset2) {
to++;
takeSide = -1;
} else if (side >= 0 && offset2 == node4.nodeValue.length) {
from4--;
takeSide = 1;
} else if (side < 0) {
from4--;
} else {
to++;
}
return flattenV(singleRect$1(textRange$1(node4, from4, to), takeSide), takeSide < 0);
}
}
if (!view.state.doc.resolve(pos).parent.inlineContent) {
if (offset2 && (side < 0 || offset2 == nodeSize(node4))) {
var before3 = node4.childNodes[offset2 - 1];
if (before3.nodeType == 1) {
return flattenH(before3.getBoundingClientRect(), false);
}
}
if (offset2 < nodeSize(node4)) {
var after3 = node4.childNodes[offset2];
if (after3.nodeType == 1) {
return flattenH(after3.getBoundingClientRect(), true);
}
}
return flattenH(node4.getBoundingClientRect(), side >= 0);
}
if (offset2 && (side < 0 || offset2 == nodeSize(node4))) {
var before$1 = node4.childNodes[offset2 - 1];
var target2 = before$1.nodeType == 3 ? textRange$1(before$1, nodeSize(before$1) - (supportEmptyRange ? 0 : 1)) : before$1.nodeType == 1 && (before$1.nodeName != "BR" || !before$1.nextSibling) ? before$1 : null;
if (target2) {
return flattenV(singleRect$1(target2, 1), false);
}
}
if (offset2 < nodeSize(node4)) {
var after$1 = node4.childNodes[offset2];
var target$12 = after$1.nodeType == 3 ? textRange$1(after$1, 0, supportEmptyRange ? 0 : 1) : after$1.nodeType == 1 ? after$1 : null;
if (target$12) {
return flattenV(singleRect$1(target$12, -1), true);
}
}
return flattenV(singleRect$1(node4.nodeType == 3 ? textRange$1(node4) : node4, -side), side >= 0);
}
function flattenV(rect, left) {
if (rect.width == 0) {
return rect;
}
var x = left ? rect.left : rect.right;
return {top: rect.top, bottom: rect.bottom, left: x, right: x};
}
function flattenH(rect, top) {
if (rect.height == 0) {
return rect;
}
var y = top ? rect.top : rect.bottom;
return {top: y, bottom: y, left: rect.left, right: rect.right};
}
function withFlushedState(view, state, f) {
var viewState = view.state, active = view.root.activeElement;
if (viewState != state) {
view.updateState(state);
}
if (active != view.dom) {
view.focus();
}
try {
return f();
} finally {
if (viewState != state) {
view.updateState(viewState);
}
if (active != view.dom && active) {
active.focus();
}
}
}
function endOfTextblockVertical(view, state, dir) {
var sel = state.selection;
var $pos = dir == "up" ? sel.$from : sel.$to;
return withFlushedState(view, state, function() {
var ref2 = view.docView.domFromPos($pos.pos, dir == "up" ? -1 : 1);
var dom = ref2.node;
for (; ; ) {
var nearest = view.docView.nearestDesc(dom, true);
if (!nearest) {
break;
}
if (nearest.node.isBlock) {
dom = nearest.dom;
break;
}
dom = nearest.dom.parentNode;
}
var coords = coordsAtPos$1(view, $pos.pos, 1);
for (var child3 = dom.firstChild; child3; child3 = child3.nextSibling) {
var boxes = void 0;
if (child3.nodeType == 1) {
boxes = child3.getClientRects();
} else if (child3.nodeType == 3) {
boxes = textRange$1(child3, 0, child3.nodeValue.length).getClientRects();
} else {
continue;
}
for (var i = 0; i < boxes.length; i++) {
var box = boxes[i];
if (box.bottom > box.top && (dir == "up" ? box.bottom < coords.top + 1 : box.top > coords.bottom - 1)) {
return false;
}
}
}
return true;
});
}
var maybeRTL = /[\u0590-\u08ac]/;
function endOfTextblockHorizontal(view, state, dir) {
var ref2 = state.selection;
var $head = ref2.$head;
if (!$head.parent.isTextblock) {
return false;
}
var offset2 = $head.parentOffset, atStart2 = !offset2, atEnd2 = offset2 == $head.parent.content.size;
var sel = getSelection();
if (!maybeRTL.test($head.parent.textContent) || !sel.modify) {
return dir == "left" || dir == "backward" ? atStart2 : atEnd2;
}
return withFlushedState(view, state, function() {
var oldRange = sel.getRangeAt(0), oldNode = sel.focusNode, oldOff = sel.focusOffset;
var oldBidiLevel = sel.caretBidiLevel;
sel.modify("move", dir, "character");
var parentDOM = $head.depth ? view.docView.domAfterPos($head.before()) : view.dom;
var result2 = !parentDOM.contains(sel.focusNode.nodeType == 1 ? sel.focusNode : sel.focusNode.parentNode) || oldNode == sel.focusNode && oldOff == sel.focusOffset;
sel.removeAllRanges();
sel.addRange(oldRange);
if (oldBidiLevel != null) {
sel.caretBidiLevel = oldBidiLevel;
}
return result2;
});
}
var cachedState = null, cachedDir = null, cachedResult = false;
function endOfTextblock(view, state, dir) {
if (cachedState == state && cachedDir == dir) {
return cachedResult;
}
cachedState = state;
cachedDir = dir;
return cachedResult = dir == "up" || dir == "down" ? endOfTextblockVertical(view, state, dir) : endOfTextblockHorizontal(view, state, dir);
}
var NOT_DIRTY = 0, CHILD_DIRTY = 1, CONTENT_DIRTY = 2, NODE_DIRTY = 3;
var ViewDesc = function ViewDesc2(parent, children, dom, contentDOM) {
this.parent = parent;
this.children = children;
this.dom = dom;
dom.pmViewDesc = this;
this.contentDOM = contentDOM;
this.dirty = NOT_DIRTY;
};
var prototypeAccessors = {beforePosition: {configurable: true}, size: {configurable: true}, border: {configurable: true}, posBefore: {configurable: true}, posAtStart: {configurable: true}, posAfter: {configurable: true}, posAtEnd: {configurable: true}, contentLost: {configurable: true}, domAtom: {configurable: true}};
ViewDesc.prototype.matchesWidget = function matchesWidget() {
return false;
};
ViewDesc.prototype.matchesMark = function matchesMark() {
return false;
};
ViewDesc.prototype.matchesNode = function matchesNode() {
return false;
};
ViewDesc.prototype.matchesHack = function matchesHack() {
return false;
};
prototypeAccessors.beforePosition.get = function() {
return false;
};
ViewDesc.prototype.parseRule = function parseRule() {
return null;
};
ViewDesc.prototype.stopEvent = function stopEvent() {
return false;
};
prototypeAccessors.size.get = function() {
var size2 = 0;
for (var i = 0; i < this.children.length; i++) {
size2 += this.children[i].size;
}
return size2;
};
prototypeAccessors.border.get = function() {
return 0;
};
ViewDesc.prototype.destroy = function destroy3() {
this.parent = null;
if (this.dom.pmViewDesc == this) {
this.dom.pmViewDesc = null;
}
for (var i = 0; i < this.children.length; i++) {
this.children[i].destroy();
}
};
ViewDesc.prototype.posBeforeChild = function posBeforeChild(child3) {
for (var i = 0, pos = this.posAtStart; i < this.children.length; i++) {
var cur = this.children[i];
if (cur == child3) {
return pos;
}
pos += cur.size;
}
};
prototypeAccessors.posBefore.get = function() {
return this.parent.posBeforeChild(this);
};
prototypeAccessors.posAtStart.get = function() {
return this.parent ? this.parent.posBeforeChild(this) + this.border : 0;
};
prototypeAccessors.posAfter.get = function() {
return this.posBefore + this.size;
};
prototypeAccessors.posAtEnd.get = function() {
return this.posAtStart + this.size - 2 * this.border;
};
ViewDesc.prototype.localPosFromDOM = function localPosFromDOM(dom, offset2, bias) {
if (this.contentDOM && this.contentDOM.contains(dom.nodeType == 1 ? dom : dom.parentNode)) {
if (bias < 0) {
var domBefore, desc;
if (dom == this.contentDOM) {
domBefore = dom.childNodes[offset2 - 1];
} else {
while (dom.parentNode != this.contentDOM) {
dom = dom.parentNode;
}
domBefore = dom.previousSibling;
}
while (domBefore && !((desc = domBefore.pmViewDesc) && desc.parent == this)) {
domBefore = domBefore.previousSibling;
}
return domBefore ? this.posBeforeChild(desc) + desc.size : this.posAtStart;
} else {
var domAfter, desc$1;
if (dom == this.contentDOM) {
domAfter = dom.childNodes[offset2];
} else {
while (dom.parentNode != this.contentDOM) {
dom = dom.parentNode;
}
domAfter = dom.nextSibling;
}
while (domAfter && !((desc$1 = domAfter.pmViewDesc) && desc$1.parent == this)) {
domAfter = domAfter.nextSibling;
}
return domAfter ? this.posBeforeChild(desc$1) : this.posAtEnd;
}
}
var atEnd2;
if (dom == this.dom && this.contentDOM) {
atEnd2 = offset2 > domIndex(this.contentDOM);
} else if (this.contentDOM && this.contentDOM != this.dom && this.dom.contains(this.contentDOM)) {
atEnd2 = dom.compareDocumentPosition(this.contentDOM) & 2;
} else if (this.dom.firstChild) {
if (offset2 == 0) {
for (var search = dom; ; search = search.parentNode) {
if (search == this.dom) {
atEnd2 = false;
break;
}
if (search.parentNode.firstChild != search) {
break;
}
}
}
if (atEnd2 == null && offset2 == dom.childNodes.length) {
for (var search$1 = dom; ; search$1 = search$1.parentNode) {
if (search$1 == this.dom) {
atEnd2 = true;
break;
}
if (search$1.parentNode.lastChild != search$1) {
break;
}
}
}
}
return (atEnd2 == null ? bias > 0 : atEnd2) ? this.posAtEnd : this.posAtStart;
};
ViewDesc.prototype.nearestDesc = function nearestDesc(dom, onlyNodes) {
for (var first2 = true, cur = dom; cur; cur = cur.parentNode) {
var desc = this.getDesc(cur);
if (desc && (!onlyNodes || desc.node)) {
if (first2 && desc.nodeDOM && !(desc.nodeDOM.nodeType == 1 ? desc.nodeDOM.contains(dom.nodeType == 1 ? dom : dom.parentNode) : desc.nodeDOM == dom)) {
first2 = false;
} else {
return desc;
}
}
}
};
ViewDesc.prototype.getDesc = function getDesc(dom) {
var desc = dom.pmViewDesc;
for (var cur = desc; cur; cur = cur.parent) {
if (cur == this) {
return desc;
}
}
};
ViewDesc.prototype.posFromDOM = function posFromDOM(dom, offset2, bias) {
for (var scan = dom; scan; scan = scan.parentNode) {
var desc = this.getDesc(scan);
if (desc) {
return desc.localPosFromDOM(dom, offset2, bias);
}
}
return -1;
};
ViewDesc.prototype.descAt = function descAt(pos) {
for (var i = 0, offset2 = 0; i < this.children.length; i++) {
var child3 = this.children[i], end2 = offset2 + child3.size;
if (offset2 == pos && end2 != offset2) {
while (!child3.border && child3.children.length) {
child3 = child3.children[0];
}
return child3;
}
if (pos < end2) {
return child3.descAt(pos - offset2 - child3.border);
}
offset2 = end2;
}
};
ViewDesc.prototype.domFromPos = function domFromPos(pos, side) {
if (!this.contentDOM) {
return {node: this.dom, offset: 0};
}
for (var offset2 = 0, i = 0, first2 = true; ; i++, first2 = false) {
while (i < this.children.length && (this.children[i].beforePosition || this.children[i].dom.parentNode != this.contentDOM)) {
offset2 += this.children[i++].size;
}
var child3 = i == this.children.length ? null : this.children[i];
if (offset2 == pos && (side == 0 || !child3 || !child3.size || child3.border || side < 0 && first2) || child3 && child3.domAtom && pos < offset2 + child3.size) {
return {
node: this.contentDOM,
offset: child3 ? domIndex(child3.dom) : this.contentDOM.childNodes.length
};
}
if (!child3) {
throw new Error("Invalid position " + pos);
}
var end2 = offset2 + child3.size;
if (!child3.domAtom && (side < 0 && !child3.border ? end2 >= pos : end2 > pos) && (end2 > pos || i + 1 >= this.children.length || !this.children[i + 1].beforePosition)) {
return child3.domFromPos(pos - offset2 - child3.border, side);
}
offset2 = end2;
}
};
ViewDesc.prototype.parseRange = function parseRange(from4, to, base2) {
if (base2 === void 0)
base2 = 0;
if (this.children.length == 0) {
return {node: this.contentDOM, from: from4, to, fromOffset: 0, toOffset: this.contentDOM.childNodes.length};
}
var fromOffset = -1, toOffset = -1;
for (var offset2 = base2, i = 0; ; i++) {
var child3 = this.children[i], end2 = offset2 + child3.size;
if (fromOffset == -1 && from4 <= end2) {
var childBase = offset2 + child3.border;
if (from4 >= childBase && to <= end2 - child3.border && child3.node && child3.contentDOM && this.contentDOM.contains(child3.contentDOM)) {
return child3.parseRange(from4, to, childBase);
}
from4 = offset2;
for (var j = i; j > 0; j--) {
var prev = this.children[j - 1];
if (prev.size && prev.dom.parentNode == this.contentDOM && !prev.emptyChildAt(1)) {
fromOffset = domIndex(prev.dom) + 1;
break;
}
from4 -= prev.size;
}
if (fromOffset == -1) {
fromOffset = 0;
}
}
if (fromOffset > -1 && (end2 > to || i == this.children.length - 1)) {
to = end2;
for (var j$1 = i + 1; j$1 < this.children.length; j$1++) {
var next2 = this.children[j$1];
if (next2.size && next2.dom.parentNode == this.contentDOM && !next2.emptyChildAt(-1)) {
toOffset = domIndex(next2.dom);
break;
}
to += next2.size;
}
if (toOffset == -1) {
toOffset = this.contentDOM.childNodes.length;
}
break;
}
offset2 = end2;
}
return {node: this.contentDOM, from: from4, to, fromOffset, toOffset};
};
ViewDesc.prototype.emptyChildAt = function emptyChildAt(side) {
if (this.border || !this.contentDOM || !this.children.length) {
return false;
}
var child3 = this.children[side < 0 ? 0 : this.children.length - 1];
return child3.size == 0 || child3.emptyChildAt(side);
};
ViewDesc.prototype.domAfterPos = function domAfterPos(pos) {
var ref2 = this.domFromPos(pos, 0);
var node4 = ref2.node;
var offset2 = ref2.offset;
if (node4.nodeType != 1 || offset2 == node4.childNodes.length) {
throw new RangeError("No node after pos " + pos);
}
return node4.childNodes[offset2];
};
ViewDesc.prototype.setSelection = function setSelection(anchor, head, root2, force) {
var from4 = Math.min(anchor, head), to = Math.max(anchor, head);
for (var i = 0, offset2 = 0; i < this.children.length; i++) {
var child3 = this.children[i], end2 = offset2 + child3.size;
if (from4 > offset2 && to < end2) {
return child3.setSelection(anchor - offset2 - child3.border, head - offset2 - child3.border, root2, force);
}
offset2 = end2;
}
var anchorDOM = this.domFromPos(anchor, anchor ? -1 : 1);
var headDOM = head == anchor ? anchorDOM : this.domFromPos(head, head ? -1 : 1);
var domSel = root2.getSelection();
var brKludge = false;
if ((result.gecko || result.safari) && anchor == head) {
var node4 = anchorDOM.node;
var offset$1 = anchorDOM.offset;
if (node4.nodeType == 3) {
brKludge = offset$1 && node4.nodeValue[offset$1 - 1] == "\n";
if (brKludge && offset$1 == node4.nodeValue.length && node4.nextSibling && node4.nextSibling.nodeName == "BR") {
anchorDOM = headDOM = {node: node4.parentNode, offset: domIndex(node4) + 1};
}
} else {
var prev = node4.childNodes[offset$1 - 1];
brKludge = prev && (prev.nodeName == "BR" || prev.contentEditable == "false");
}
}
if (!(force || brKludge && result.safari) && isEquivalentPosition(anchorDOM.node, anchorDOM.offset, domSel.anchorNode, domSel.anchorOffset) && isEquivalentPosition(headDOM.node, headDOM.offset, domSel.focusNode, domSel.focusOffset)) {
return;
}
var domSelExtended = false;
if ((domSel.extend || anchor == head) && !brKludge) {
domSel.collapse(anchorDOM.node, anchorDOM.offset);
try {
if (anchor != head) {
domSel.extend(headDOM.node, headDOM.offset);
}
domSelExtended = true;
} catch (err2) {
if (!(err2 instanceof DOMException)) {
throw err2;
}
}
}
if (!domSelExtended) {
if (anchor > head) {
var tmp = anchorDOM;
anchorDOM = headDOM;
headDOM = tmp;
}
var range2 = document.createRange();
range2.setEnd(headDOM.node, headDOM.offset);
range2.setStart(anchorDOM.node, anchorDOM.offset);
domSel.removeAllRanges();
domSel.addRange(range2);
}
};
ViewDesc.prototype.ignoreMutation = function ignoreMutation(mutation) {
return !this.contentDOM && mutation.type != "selection";
};
prototypeAccessors.contentLost.get = function() {
return this.contentDOM && this.contentDOM != this.dom && !this.dom.contains(this.contentDOM);
};
ViewDesc.prototype.markDirty = function markDirty(from4, to) {
for (var offset2 = 0, i = 0; i < this.children.length; i++) {
var child3 = this.children[i], end2 = offset2 + child3.size;
if (offset2 == end2 ? from4 <= end2 && to >= offset2 : from4 < end2 && to > offset2) {
var startInside = offset2 + child3.border, endInside = end2 - child3.border;
if (from4 >= startInside && to <= endInside) {
this.dirty = from4 == offset2 || to == end2 ? CONTENT_DIRTY : CHILD_DIRTY;
if (from4 == startInside && to == endInside && (child3.contentLost || child3.dom.parentNode != this.contentDOM)) {
child3.dirty = NODE_DIRTY;
} else {
child3.markDirty(from4 - startInside, to - startInside);
}
return;
} else {
child3.dirty = NODE_DIRTY;
}
}
offset2 = end2;
}
this.dirty = CONTENT_DIRTY;
};
ViewDesc.prototype.markParentsDirty = function markParentsDirty() {
var level = 1;
for (var node4 = this.parent; node4; node4 = node4.parent, level++) {
var dirty = level == 1 ? CONTENT_DIRTY : CHILD_DIRTY;
if (node4.dirty < dirty) {
node4.dirty = dirty;
}
}
};
prototypeAccessors.domAtom.get = function() {
return false;
};
Object.defineProperties(ViewDesc.prototype, prototypeAccessors);
var nothing = [];
var WidgetViewDesc = /* @__PURE__ */ function(ViewDesc3) {
function WidgetViewDesc2(parent, widget2, view, pos) {
var self2, dom = widget2.type.toDOM;
if (typeof dom == "function") {
dom = dom(view, function() {
if (!self2) {
return pos;
}
if (self2.parent) {
return self2.parent.posBeforeChild(self2);
}
});
}
if (!widget2.type.spec.raw) {
if (dom.nodeType != 1) {
var wrap2 = document.createElement("span");
wrap2.appendChild(dom);
dom = wrap2;
}
dom.contentEditable = false;
dom.classList.add("ProseMirror-widget");
}
ViewDesc3.call(this, parent, nothing, dom, null);
this.widget = widget2;
self2 = this;
}
if (ViewDesc3)
WidgetViewDesc2.__proto__ = ViewDesc3;
WidgetViewDesc2.prototype = Object.create(ViewDesc3 && ViewDesc3.prototype);
WidgetViewDesc2.prototype.constructor = WidgetViewDesc2;
var prototypeAccessors$12 = {beforePosition: {configurable: true}, domAtom: {configurable: true}};
prototypeAccessors$12.beforePosition.get = function() {
return this.widget.type.side < 0;
};
WidgetViewDesc2.prototype.matchesWidget = function matchesWidget2(widget2) {
return this.dirty == NOT_DIRTY && widget2.type.eq(this.widget.type);
};
WidgetViewDesc2.prototype.parseRule = function parseRule2() {
return {ignore: true};
};
WidgetViewDesc2.prototype.stopEvent = function stopEvent2(event) {
var stop2 = this.widget.spec.stopEvent;
return stop2 ? stop2(event) : false;
};
WidgetViewDesc2.prototype.ignoreMutation = function ignoreMutation2(mutation) {
return mutation.type != "selection" || this.widget.spec.ignoreSelection;
};
prototypeAccessors$12.domAtom.get = function() {
return true;
};
Object.defineProperties(WidgetViewDesc2.prototype, prototypeAccessors$12);
return WidgetViewDesc2;
}(ViewDesc);
var CompositionViewDesc = /* @__PURE__ */ function(ViewDesc3) {
function CompositionViewDesc2(parent, dom, textDOM, text3) {
ViewDesc3.call(this, parent, nothing, dom, null);
this.textDOM = textDOM;
this.text = text3;
}
if (ViewDesc3)
CompositionViewDesc2.__proto__ = ViewDesc3;
CompositionViewDesc2.prototype = Object.create(ViewDesc3 && ViewDesc3.prototype);
CompositionViewDesc2.prototype.constructor = CompositionViewDesc2;
var prototypeAccessors$22 = {size: {configurable: true}};
prototypeAccessors$22.size.get = function() {
return this.text.length;
};
CompositionViewDesc2.prototype.localPosFromDOM = function localPosFromDOM2(dom, offset2) {
if (dom != this.textDOM) {
return this.posAtStart + (offset2 ? this.size : 0);
}
return this.posAtStart + offset2;
};
CompositionViewDesc2.prototype.domFromPos = function domFromPos2(pos) {
return {node: this.textDOM, offset: pos};
};
CompositionViewDesc2.prototype.ignoreMutation = function ignoreMutation2(mut) {
return mut.type === "characterData" && mut.target.nodeValue == mut.oldValue;
};
Object.defineProperties(CompositionViewDesc2.prototype, prototypeAccessors$22);
return CompositionViewDesc2;
}(ViewDesc);
var MarkViewDesc = /* @__PURE__ */ function(ViewDesc3) {
function MarkViewDesc2(parent, mark3, dom, contentDOM) {
ViewDesc3.call(this, parent, [], dom, contentDOM);
this.mark = mark3;
}
if (ViewDesc3)
MarkViewDesc2.__proto__ = ViewDesc3;
MarkViewDesc2.prototype = Object.create(ViewDesc3 && ViewDesc3.prototype);
MarkViewDesc2.prototype.constructor = MarkViewDesc2;
MarkViewDesc2.create = function create7(parent, mark3, inline2, view) {
var custom = view.nodeViews[mark3.type.name];
var spec = custom && custom(mark3, view, inline2);
if (!spec || !spec.dom) {
spec = DOMSerializer.renderSpec(document, mark3.type.spec.toDOM(mark3, inline2));
}
return new MarkViewDesc2(parent, mark3, spec.dom, spec.contentDOM || spec.dom);
};
MarkViewDesc2.prototype.parseRule = function parseRule2() {
return {mark: this.mark.type.name, attrs: this.mark.attrs, contentElement: this.contentDOM};
};
MarkViewDesc2.prototype.matchesMark = function matchesMark2(mark3) {
return this.dirty != NODE_DIRTY && this.mark.eq(mark3);
};
MarkViewDesc2.prototype.markDirty = function markDirty2(from4, to) {
ViewDesc3.prototype.markDirty.call(this, from4, to);
if (this.dirty != NOT_DIRTY) {
var parent = this.parent;
while (!parent.node) {
parent = parent.parent;
}
if (parent.dirty < this.dirty) {
parent.dirty = this.dirty;
}
this.dirty = NOT_DIRTY;
}
};
MarkViewDesc2.prototype.slice = function slice5(from4, to, view) {
var copy5 = MarkViewDesc2.create(this.parent, this.mark, true, view);
var nodes = this.children, size2 = this.size;
if (to < size2) {
nodes = replaceNodes(nodes, to, size2, view);
}
if (from4 > 0) {
nodes = replaceNodes(nodes, 0, from4, view);
}
for (var i = 0; i < nodes.length; i++) {
nodes[i].parent = copy5;
}
copy5.children = nodes;
return copy5;
};
return MarkViewDesc2;
}(ViewDesc);
var NodeViewDesc = /* @__PURE__ */ function(ViewDesc3) {
function NodeViewDesc2(parent, node4, outerDeco, innerDeco, dom, contentDOM, nodeDOM2, view, pos) {
ViewDesc3.call(this, parent, node4.isLeaf ? nothing : [], dom, contentDOM);
this.nodeDOM = nodeDOM2;
this.node = node4;
this.outerDeco = outerDeco;
this.innerDeco = innerDeco;
if (contentDOM) {
this.updateChildren(view, pos);
}
}
if (ViewDesc3)
NodeViewDesc2.__proto__ = ViewDesc3;
NodeViewDesc2.prototype = Object.create(ViewDesc3 && ViewDesc3.prototype);
NodeViewDesc2.prototype.constructor = NodeViewDesc2;
var prototypeAccessors$32 = {size: {configurable: true}, border: {configurable: true}, domAtom: {configurable: true}};
NodeViewDesc2.create = function create7(parent, node4, outerDeco, innerDeco, view, pos) {
var assign2;
var custom = view.nodeViews[node4.type.name], descObj;
var spec = custom && custom(node4, view, function() {
if (!descObj) {
return pos;
}
if (descObj.parent) {
return descObj.parent.posBeforeChild(descObj);
}
}, outerDeco, innerDeco);
var dom = spec && spec.dom, contentDOM = spec && spec.contentDOM;
if (node4.isText) {
if (!dom) {
dom = document.createTextNode(node4.text);
} else if (dom.nodeType != 3) {
throw new RangeError("Text must be rendered as a DOM text node");
}
} else if (!dom) {
assign2 = DOMSerializer.renderSpec(document, node4.type.spec.toDOM(node4)), dom = assign2.dom, contentDOM = assign2.contentDOM;
}
if (!contentDOM && !node4.isText && dom.nodeName != "BR") {
if (!dom.hasAttribute("contenteditable")) {
dom.contentEditable = false;
}
if (node4.type.spec.draggable) {
dom.draggable = true;
}
}
var nodeDOM2 = dom;
dom = applyOuterDeco(dom, outerDeco, node4);
if (spec) {
return descObj = new CustomNodeViewDesc(parent, node4, outerDeco, innerDeco, dom, contentDOM, nodeDOM2, spec, view, pos + 1);
} else if (node4.isText) {
return new TextViewDesc(parent, node4, outerDeco, innerDeco, dom, nodeDOM2, view);
} else {
return new NodeViewDesc2(parent, node4, outerDeco, innerDeco, dom, contentDOM, nodeDOM2, view, pos + 1);
}
};
NodeViewDesc2.prototype.parseRule = function parseRule2() {
var this$1 = this;
if (this.node.type.spec.reparseInView) {
return null;
}
var rule = {node: this.node.type.name, attrs: this.node.attrs};
if (this.node.type.spec.code) {
rule.preserveWhitespace = "full";
}
if (this.contentDOM && !this.contentLost) {
rule.contentElement = this.contentDOM;
} else {
rule.getContent = function() {
return this$1.contentDOM ? Fragment.empty : this$1.node.content;
};
}
return rule;
};
NodeViewDesc2.prototype.matchesNode = function matchesNode2(node4, outerDeco, innerDeco) {
return this.dirty == NOT_DIRTY && node4.eq(this.node) && sameOuterDeco(outerDeco, this.outerDeco) && innerDeco.eq(this.innerDeco);
};
prototypeAccessors$32.size.get = function() {
return this.node.nodeSize;
};
prototypeAccessors$32.border.get = function() {
return this.node.isLeaf ? 0 : 1;
};
NodeViewDesc2.prototype.updateChildren = function updateChildren(view, pos) {
var this$1 = this;
var inline2 = this.node.inlineContent, off2 = pos;
var composition = inline2 && view.composing && this.localCompositionNode(view, pos);
var updater = new ViewTreeUpdater(this, composition && composition.node);
iterDeco(this.node, this.innerDeco, function(widget2, i, insideNode) {
if (widget2.spec.marks) {
updater.syncToMarks(widget2.spec.marks, inline2, view);
} else if (widget2.type.side >= 0 && !insideNode) {
updater.syncToMarks(i == this$1.node.childCount ? Mark$1.none : this$1.node.child(i).marks, inline2, view);
}
updater.placeWidget(widget2, view, off2);
}, function(child3, outerDeco, innerDeco, i) {
updater.syncToMarks(child3.marks, inline2, view);
updater.findNodeMatch(child3, outerDeco, innerDeco, i) || updater.updateNextNode(child3, outerDeco, innerDeco, view, i) || updater.addNode(child3, outerDeco, innerDeco, view, off2);
off2 += child3.nodeSize;
});
updater.syncToMarks(nothing, inline2, view);
if (this.node.isTextblock) {
updater.addTextblockHacks();
}
updater.destroyRest();
if (updater.changed || this.dirty == CONTENT_DIRTY) {
if (composition) {
this.protectLocalComposition(view, composition);
}
renderDescs(this.contentDOM, this.children, view);
if (result.ios) {
iosHacks(this.dom);
}
}
};
NodeViewDesc2.prototype.localCompositionNode = function localCompositionNode(view, pos) {
var ref2 = view.state.selection;
var from4 = ref2.from;
var to = ref2.to;
if (!(view.state.selection instanceof TextSelection) || from4 < pos || to > pos + this.node.content.size) {
return;
}
var sel = view.root.getSelection();
var textNode = nearbyTextNode(sel.focusNode, sel.focusOffset);
if (!textNode || !this.dom.contains(textNode.parentNode)) {
return;
}
var text3 = textNode.nodeValue;
var textPos = findTextInFragment(this.node.content, text3, from4 - pos, to - pos);
return textPos < 0 ? null : {node: textNode, pos: textPos, text: text3};
};
NodeViewDesc2.prototype.protectLocalComposition = function protectLocalComposition(view, ref2) {
var node4 = ref2.node;
var pos = ref2.pos;
var text3 = ref2.text;
if (this.getDesc(node4)) {
return;
}
var topNode = node4;
for (; ; topNode = topNode.parentNode) {
if (topNode.parentNode == this.contentDOM) {
break;
}
while (topNode.previousSibling) {
topNode.parentNode.removeChild(topNode.previousSibling);
}
while (topNode.nextSibling) {
topNode.parentNode.removeChild(topNode.nextSibling);
}
if (topNode.pmViewDesc) {
topNode.pmViewDesc = null;
}
}
var desc = new CompositionViewDesc(this, topNode, node4, text3);
view.compositionNodes.push(desc);
this.children = replaceNodes(this.children, pos, pos + text3.length, view, desc);
};
NodeViewDesc2.prototype.update = function update6(node4, outerDeco, innerDeco, view) {
if (this.dirty == NODE_DIRTY || !node4.sameMarkup(this.node)) {
return false;
}
this.updateInner(node4, outerDeco, innerDeco, view);
return true;
};
NodeViewDesc2.prototype.updateInner = function updateInner(node4, outerDeco, innerDeco, view) {
this.updateOuterDeco(outerDeco);
this.node = node4;
this.innerDeco = innerDeco;
if (this.contentDOM) {
this.updateChildren(view, this.posAtStart);
}
this.dirty = NOT_DIRTY;
};
NodeViewDesc2.prototype.updateOuterDeco = function updateOuterDeco(outerDeco) {
if (sameOuterDeco(outerDeco, this.outerDeco)) {
return;
}
var needsWrap = this.nodeDOM.nodeType != 1;
var oldDOM = this.dom;
this.dom = patchOuterDeco(this.dom, this.nodeDOM, computeOuterDeco(this.outerDeco, this.node, needsWrap), computeOuterDeco(outerDeco, this.node, needsWrap));
if (this.dom != oldDOM) {
oldDOM.pmViewDesc = null;
this.dom.pmViewDesc = this;
}
this.outerDeco = outerDeco;
};
NodeViewDesc2.prototype.selectNode = function selectNode() {
this.nodeDOM.classList.add("ProseMirror-selectednode");
if (this.contentDOM || !this.node.type.spec.draggable) {
this.dom.draggable = true;
}
};
NodeViewDesc2.prototype.deselectNode = function deselectNode() {
this.nodeDOM.classList.remove("ProseMirror-selectednode");
if (this.contentDOM || !this.node.type.spec.draggable) {
this.dom.removeAttribute("draggable");
}
};
prototypeAccessors$32.domAtom.get = function() {
return this.node.isAtom;
};
Object.defineProperties(NodeViewDesc2.prototype, prototypeAccessors$32);
return NodeViewDesc2;
}(ViewDesc);
function docViewDesc(doc2, outerDeco, innerDeco, dom, view) {
applyOuterDeco(dom, outerDeco, doc2);
return new NodeViewDesc(null, doc2, outerDeco, innerDeco, dom, dom, dom, view, 0);
}
var TextViewDesc = /* @__PURE__ */ function(NodeViewDesc2) {
function TextViewDesc2(parent, node4, outerDeco, innerDeco, dom, nodeDOM2, view) {
NodeViewDesc2.call(this, parent, node4, outerDeco, innerDeco, dom, null, nodeDOM2, view);
}
if (NodeViewDesc2)
TextViewDesc2.__proto__ = NodeViewDesc2;
TextViewDesc2.prototype = Object.create(NodeViewDesc2 && NodeViewDesc2.prototype);
TextViewDesc2.prototype.constructor = TextViewDesc2;
var prototypeAccessors$42 = {domAtom: {configurable: true}};
TextViewDesc2.prototype.parseRule = function parseRule2() {
var skip = this.nodeDOM.parentNode;
while (skip && skip != this.dom && !skip.pmIsDeco) {
skip = skip.parentNode;
}
return {skip: skip || true};
};
TextViewDesc2.prototype.update = function update6(node4, outerDeco, _2, view) {
if (this.dirty == NODE_DIRTY || this.dirty != NOT_DIRTY && !this.inParent() || !node4.sameMarkup(this.node)) {
return false;
}
this.updateOuterDeco(outerDeco);
if ((this.dirty != NOT_DIRTY || node4.text != this.node.text) && node4.text != this.nodeDOM.nodeValue) {
this.nodeDOM.nodeValue = node4.text;
if (view.trackWrites == this.nodeDOM) {
view.trackWrites = null;
}
}
this.node = node4;
this.dirty = NOT_DIRTY;
return true;
};
TextViewDesc2.prototype.inParent = function inParent() {
var parentDOM = this.parent.contentDOM;
for (var n = this.nodeDOM; n; n = n.parentNode) {
if (n == parentDOM) {
return true;
}
}
return false;
};
TextViewDesc2.prototype.domFromPos = function domFromPos2(pos) {
return {node: this.nodeDOM, offset: pos};
};
TextViewDesc2.prototype.localPosFromDOM = function localPosFromDOM2(dom, offset2, bias) {
if (dom == this.nodeDOM) {
return this.posAtStart + Math.min(offset2, this.node.text.length);
}
return NodeViewDesc2.prototype.localPosFromDOM.call(this, dom, offset2, bias);
};
TextViewDesc2.prototype.ignoreMutation = function ignoreMutation2(mutation) {
return mutation.type != "characterData" && mutation.type != "selection";
};
TextViewDesc2.prototype.slice = function slice5(from4, to, view) {
var node4 = this.node.cut(from4, to), dom = document.createTextNode(node4.text);
return new TextViewDesc2(this.parent, node4, this.outerDeco, this.innerDeco, dom, dom, view);
};
prototypeAccessors$42.domAtom.get = function() {
return false;
};
Object.defineProperties(TextViewDesc2.prototype, prototypeAccessors$42);
return TextViewDesc2;
}(NodeViewDesc);
var BRHackViewDesc = /* @__PURE__ */ function(ViewDesc3) {
function BRHackViewDesc2() {
ViewDesc3.apply(this, arguments);
}
if (ViewDesc3)
BRHackViewDesc2.__proto__ = ViewDesc3;
BRHackViewDesc2.prototype = Object.create(ViewDesc3 && ViewDesc3.prototype);
BRHackViewDesc2.prototype.constructor = BRHackViewDesc2;
var prototypeAccessors$52 = {domAtom: {configurable: true}};
BRHackViewDesc2.prototype.parseRule = function parseRule2() {
return {ignore: true};
};
BRHackViewDesc2.prototype.matchesHack = function matchesHack2() {
return this.dirty == NOT_DIRTY;
};
prototypeAccessors$52.domAtom.get = function() {
return true;
};
Object.defineProperties(BRHackViewDesc2.prototype, prototypeAccessors$52);
return BRHackViewDesc2;
}(ViewDesc);
var CustomNodeViewDesc = /* @__PURE__ */ function(NodeViewDesc2) {
function CustomNodeViewDesc2(parent, node4, outerDeco, innerDeco, dom, contentDOM, nodeDOM2, spec, view, pos) {
NodeViewDesc2.call(this, parent, node4, outerDeco, innerDeco, dom, contentDOM, nodeDOM2, view, pos);
this.spec = spec;
}
if (NodeViewDesc2)
CustomNodeViewDesc2.__proto__ = NodeViewDesc2;
CustomNodeViewDesc2.prototype = Object.create(NodeViewDesc2 && NodeViewDesc2.prototype);
CustomNodeViewDesc2.prototype.constructor = CustomNodeViewDesc2;
CustomNodeViewDesc2.prototype.update = function update6(node4, outerDeco, innerDeco, view) {
if (this.dirty == NODE_DIRTY) {
return false;
}
if (this.spec.update) {
var result2 = this.spec.update(node4, outerDeco, innerDeco);
if (result2) {
this.updateInner(node4, outerDeco, innerDeco, view);
}
return result2;
} else if (!this.contentDOM && !node4.isLeaf) {
return false;
} else {
return NodeViewDesc2.prototype.update.call(this, node4, outerDeco, innerDeco, view);
}
};
CustomNodeViewDesc2.prototype.selectNode = function selectNode() {
this.spec.selectNode ? this.spec.selectNode() : NodeViewDesc2.prototype.selectNode.call(this);
};
CustomNodeViewDesc2.prototype.deselectNode = function deselectNode() {
this.spec.deselectNode ? this.spec.deselectNode() : NodeViewDesc2.prototype.deselectNode.call(this);
};
CustomNodeViewDesc2.prototype.setSelection = function setSelection2(anchor, head, root2, force) {
this.spec.setSelection ? this.spec.setSelection(anchor, head, root2) : NodeViewDesc2.prototype.setSelection.call(this, anchor, head, root2, force);
};
CustomNodeViewDesc2.prototype.destroy = function destroy7() {
if (this.spec.destroy) {
this.spec.destroy();
}
NodeViewDesc2.prototype.destroy.call(this);
};
CustomNodeViewDesc2.prototype.stopEvent = function stopEvent2(event) {
return this.spec.stopEvent ? this.spec.stopEvent(event) : false;
};
CustomNodeViewDesc2.prototype.ignoreMutation = function ignoreMutation2(mutation) {
return this.spec.ignoreMutation ? this.spec.ignoreMutation(mutation) : NodeViewDesc2.prototype.ignoreMutation.call(this, mutation);
};
return CustomNodeViewDesc2;
}(NodeViewDesc);
function renderDescs(parentDOM, descs, view) {
var dom = parentDOM.firstChild, written = false;
for (var i = 0; i < descs.length; i++) {
var desc = descs[i], childDOM = desc.dom;
if (childDOM.parentNode == parentDOM) {
while (childDOM != dom) {
dom = rm(dom);
written = true;
}
dom = dom.nextSibling;
} else {
written = true;
parentDOM.insertBefore(childDOM, dom);
}
if (desc instanceof MarkViewDesc) {
var pos = dom ? dom.previousSibling : parentDOM.lastChild;
renderDescs(desc.contentDOM, desc.children, view);
dom = pos ? pos.nextSibling : parentDOM.firstChild;
}
}
while (dom) {
dom = rm(dom);
written = true;
}
if (written && view.trackWrites == parentDOM) {
view.trackWrites = null;
}
}
function OuterDecoLevel(nodeName) {
if (nodeName) {
this.nodeName = nodeName;
}
}
OuterDecoLevel.prototype = Object.create(null);
var noDeco = [new OuterDecoLevel()];
function computeOuterDeco(outerDeco, node4, needsWrap) {
if (outerDeco.length == 0) {
return noDeco;
}
var top = needsWrap ? noDeco[0] : new OuterDecoLevel(), result2 = [top];
for (var i = 0; i < outerDeco.length; i++) {
var attrs2 = outerDeco[i].type.attrs;
if (!attrs2) {
continue;
}
if (attrs2.nodeName) {
result2.push(top = new OuterDecoLevel(attrs2.nodeName));
}
for (var name in attrs2) {
var val = attrs2[name];
if (val == null) {
continue;
}
if (needsWrap && result2.length == 1) {
result2.push(top = new OuterDecoLevel(node4.isInline ? "span" : "div"));
}
if (name == "class") {
top.class = (top.class ? top.class + " " : "") + val;
} else if (name == "style") {
top.style = (top.style ? top.style + ";" : "") + val;
} else if (name != "nodeName") {
top[name] = val;
}
}
}
return result2;
}
function patchOuterDeco(outerDOM, nodeDOM2, prevComputed, curComputed) {
if (prevComputed == noDeco && curComputed == noDeco) {
return nodeDOM2;
}
var curDOM = nodeDOM2;
for (var i = 0; i < curComputed.length; i++) {
var deco = curComputed[i], prev = prevComputed[i];
if (i) {
var parent = void 0;
if (prev && prev.nodeName == deco.nodeName && curDOM != outerDOM && (parent = curDOM.parentNode) && parent.tagName.toLowerCase() == deco.nodeName) {
curDOM = parent;
} else {
parent = document.createElement(deco.nodeName);
parent.pmIsDeco = true;
parent.appendChild(curDOM);
prev = noDeco[0];
curDOM = parent;
}
}
patchAttributes(curDOM, prev || noDeco[0], deco);
}
return curDOM;
}
function patchAttributes(dom, prev, cur) {
for (var name in prev) {
if (name != "class" && name != "style" && name != "nodeName" && !(name in cur)) {
dom.removeAttribute(name);
}
}
for (var name$1 in cur) {
if (name$1 != "class" && name$1 != "style" && name$1 != "nodeName" && cur[name$1] != prev[name$1]) {
dom.setAttribute(name$1, cur[name$1]);
}
}
if (prev.class != cur.class) {
var prevList = prev.class ? prev.class.split(" ").filter(Boolean) : nothing;
var curList = cur.class ? cur.class.split(" ").filter(Boolean) : nothing;
for (var i = 0; i < prevList.length; i++) {
if (curList.indexOf(prevList[i]) == -1) {
dom.classList.remove(prevList[i]);
}
}
for (var i$1 = 0; i$1 < curList.length; i$1++) {
if (prevList.indexOf(curList[i$1]) == -1) {
dom.classList.add(curList[i$1]);
}
}
}
if (prev.style != cur.style) {
if (prev.style) {
var prop = /\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g, m;
while (m = prop.exec(prev.style)) {
dom.style.removeProperty(m[1]);
}
}
if (cur.style) {
dom.style.cssText += cur.style;
}
}
}
function applyOuterDeco(dom, deco, node4) {
return patchOuterDeco(dom, dom, noDeco, computeOuterDeco(deco, node4, dom.nodeType != 1));
}
function sameOuterDeco(a, b) {
if (a.length != b.length) {
return false;
}
for (var i = 0; i < a.length; i++) {
if (!a[i].type.eq(b[i].type)) {
return false;
}
}
return true;
}
function rm(dom) {
var next2 = dom.nextSibling;
dom.parentNode.removeChild(dom);
return next2;
}
var ViewTreeUpdater = function ViewTreeUpdater2(top, lockedNode) {
this.top = top;
this.lock = lockedNode;
this.index = 0;
this.stack = [];
this.changed = false;
this.preMatch = preMatch(top.node.content, top.children);
};
ViewTreeUpdater.prototype.destroyBetween = function destroyBetween(start3, end2) {
if (start3 == end2) {
return;
}
for (var i = start3; i < end2; i++) {
this.top.children[i].destroy();
}
this.top.children.splice(start3, end2 - start3);
this.changed = true;
};
ViewTreeUpdater.prototype.destroyRest = function destroyRest() {
this.destroyBetween(this.index, this.top.children.length);
};
ViewTreeUpdater.prototype.syncToMarks = function syncToMarks(marks2, inline2, view) {
var keep = 0, depth = this.stack.length >> 1;
var maxKeep = Math.min(depth, marks2.length);
while (keep < maxKeep && (keep == depth - 1 ? this.top : this.stack[keep + 1 << 1]).matchesMark(marks2[keep]) && marks2[keep].type.spec.spanning !== false) {
keep++;
}
while (keep < depth) {
this.destroyRest();
this.top.dirty = NOT_DIRTY;
this.index = this.stack.pop();
this.top = this.stack.pop();
depth--;
}
while (depth < marks2.length) {
this.stack.push(this.top, this.index + 1);
var found2 = -1;
for (var i = this.index; i < Math.min(this.index + 3, this.top.children.length); i++) {
if (this.top.children[i].matchesMark(marks2[depth])) {
found2 = i;
break;
}
}
if (found2 > -1) {
if (found2 > this.index) {
this.changed = true;
this.destroyBetween(this.index, found2);
}
this.top = this.top.children[this.index];
} else {
var markDesc = MarkViewDesc.create(this.top, marks2[depth], inline2, view);
this.top.children.splice(this.index, 0, markDesc);
this.top = markDesc;
this.changed = true;
}
this.index = 0;
depth++;
}
};
ViewTreeUpdater.prototype.findNodeMatch = function findNodeMatch(node4, outerDeco, innerDeco, index3) {
var children = this.top.children, found2 = -1;
if (index3 >= this.preMatch.index) {
for (var i = this.index; i < children.length; i++) {
if (children[i].matchesNode(node4, outerDeco, innerDeco)) {
found2 = i;
break;
}
}
} else {
for (var i$1 = this.index, e = Math.min(children.length, i$1 + 1); i$1 < e; i$1++) {
var child3 = children[i$1];
if (child3.matchesNode(node4, outerDeco, innerDeco) && !this.preMatch.matched.has(child3)) {
found2 = i$1;
break;
}
}
}
if (found2 < 0) {
return false;
}
this.destroyBetween(this.index, found2);
this.index++;
return true;
};
ViewTreeUpdater.prototype.updateNextNode = function updateNextNode(node4, outerDeco, innerDeco, view, index3) {
for (var i = this.index; i < this.top.children.length; i++) {
var next2 = this.top.children[i];
if (next2 instanceof NodeViewDesc) {
var preMatch2 = this.preMatch.matched.get(next2);
if (preMatch2 != null && preMatch2 != index3) {
return false;
}
var nextDOM = next2.dom;
var locked = this.lock && (nextDOM == this.lock || nextDOM.nodeType == 1 && nextDOM.contains(this.lock.parentNode)) && !(node4.isText && next2.node && next2.node.isText && next2.nodeDOM.nodeValue == node4.text && next2.dirty != NODE_DIRTY && sameOuterDeco(outerDeco, next2.outerDeco));
if (!locked && next2.update(node4, outerDeco, innerDeco, view)) {
this.destroyBetween(this.index, i);
if (next2.dom != nextDOM) {
this.changed = true;
}
this.index++;
return true;
}
break;
}
}
return false;
};
ViewTreeUpdater.prototype.addNode = function addNode2(node4, outerDeco, innerDeco, view, pos) {
this.top.children.splice(this.index++, 0, NodeViewDesc.create(this.top, node4, outerDeco, innerDeco, view, pos));
this.changed = true;
};
ViewTreeUpdater.prototype.placeWidget = function placeWidget(widget2, view, pos) {
var next2 = this.index < this.top.children.length ? this.top.children[this.index] : null;
if (next2 && next2.matchesWidget(widget2) && (widget2 == next2.widget || !next2.widget.type.toDOM.parentNode)) {
this.index++;
} else {
var desc = new WidgetViewDesc(this.top, widget2, view, pos);
this.top.children.splice(this.index++, 0, desc);
this.changed = true;
}
};
ViewTreeUpdater.prototype.addTextblockHacks = function addTextblockHacks() {
var lastChild2 = this.top.children[this.index - 1];
while (lastChild2 instanceof MarkViewDesc) {
lastChild2 = lastChild2.children[lastChild2.children.length - 1];
}
if (!lastChild2 || !(lastChild2 instanceof TextViewDesc) || /\n$/.test(lastChild2.node.text)) {
if (this.index < this.top.children.length && this.top.children[this.index].matchesHack()) {
this.index++;
} else {
var dom = document.createElement("br");
this.top.children.splice(this.index++, 0, new BRHackViewDesc(this.top, nothing, dom, null));
this.changed = true;
}
}
};
function preMatch(frag, descs) {
var fI = frag.childCount, dI = descs.length, matched = new Map();
for (; fI > 0 && dI > 0; dI--) {
var desc = descs[dI - 1], node4 = desc.node;
if (!node4) {
continue;
}
if (node4 != frag.child(fI - 1)) {
break;
}
--fI;
matched.set(desc, fI);
}
return {index: fI, matched};
}
function compareSide(a, b) {
return a.type.side - b.type.side;
}
function iterDeco(parent, deco, onWidget, onNode) {
var locals3 = deco.locals(parent), offset2 = 0;
if (locals3.length == 0) {
for (var i = 0; i < parent.childCount; i++) {
var child3 = parent.child(i);
onNode(child3, locals3, deco.forChild(offset2, child3), i);
offset2 += child3.nodeSize;
}
return;
}
var decoIndex = 0, active = [], restNode = null;
for (var parentIndex = 0; ; ) {
if (decoIndex < locals3.length && locals3[decoIndex].to == offset2) {
var widget2 = locals3[decoIndex++], widgets = void 0;
while (decoIndex < locals3.length && locals3[decoIndex].to == offset2) {
(widgets || (widgets = [widget2])).push(locals3[decoIndex++]);
}
if (widgets) {
widgets.sort(compareSide);
for (var i$1 = 0; i$1 < widgets.length; i$1++) {
onWidget(widgets[i$1], parentIndex, !!restNode);
}
} else {
onWidget(widget2, parentIndex, !!restNode);
}
}
var child$1 = void 0, index3 = void 0;
if (restNode) {
index3 = -1;
child$1 = restNode;
restNode = null;
} else if (parentIndex < parent.childCount) {
index3 = parentIndex;
child$1 = parent.child(parentIndex++);
} else {
break;
}
for (var i$2 = 0; i$2 < active.length; i$2++) {
if (active[i$2].to <= offset2) {
active.splice(i$2--, 1);
}
}
while (decoIndex < locals3.length && locals3[decoIndex].from <= offset2 && locals3[decoIndex].to > offset2) {
active.push(locals3[decoIndex++]);
}
var end2 = offset2 + child$1.nodeSize;
if (child$1.isText) {
var cutAt = end2;
if (decoIndex < locals3.length && locals3[decoIndex].from < cutAt) {
cutAt = locals3[decoIndex].from;
}
for (var i$3 = 0; i$3 < active.length; i$3++) {
if (active[i$3].to < cutAt) {
cutAt = active[i$3].to;
}
}
if (cutAt < end2) {
restNode = child$1.cut(cutAt - offset2);
child$1 = child$1.cut(0, cutAt - offset2);
end2 = cutAt;
index3 = -1;
}
}
var outerDeco = !active.length ? nothing : child$1.isInline && !child$1.isLeaf ? active.filter(function(d) {
return !d.inline;
}) : active.slice();
onNode(child$1, outerDeco, deco.forChild(offset2, child$1), index3);
offset2 = end2;
}
}
function iosHacks(dom) {
if (dom.nodeName == "UL" || dom.nodeName == "OL") {
var oldCSS = dom.style.cssText;
dom.style.cssText = oldCSS + "; list-style: square !important";
window.getComputedStyle(dom).listStyle;
dom.style.cssText = oldCSS;
}
}
function nearbyTextNode(node4, offset2) {
for (; ; ) {
if (node4.nodeType == 3) {
return node4;
}
if (node4.nodeType == 1 && offset2 > 0) {
if (node4.childNodes.length > offset2 && node4.childNodes[offset2].nodeType == 3) {
return node4.childNodes[offset2];
}
node4 = node4.childNodes[offset2 - 1];
offset2 = nodeSize(node4);
} else if (node4.nodeType == 1 && offset2 < node4.childNodes.length) {
node4 = node4.childNodes[offset2];
offset2 = 0;
} else {
return null;
}
}
}
function findTextInFragment(frag, text3, from4, to) {
for (var i = 0, pos = 0; i < frag.childCount && pos <= to; ) {
var child3 = frag.child(i++), childStart = pos;
pos += child3.nodeSize;
if (!child3.isText) {
continue;
}
var str2 = child3.text;
while (i < frag.childCount) {
var next2 = frag.child(i++);
pos += next2.nodeSize;
if (!next2.isText) {
break;
}
str2 += next2.text;
}
if (pos >= from4) {
var found2 = str2.lastIndexOf(text3, to - childStart);
if (found2 >= 0 && found2 + text3.length + childStart >= from4) {
return childStart + found2;
}
}
}
return -1;
}
function replaceNodes(nodes, from4, to, view, replacement) {
var result2 = [];
for (var i = 0, off2 = 0; i < nodes.length; i++) {
var child3 = nodes[i], start3 = off2, end2 = off2 += child3.size;
if (start3 >= to || end2 <= from4) {
result2.push(child3);
} else {
if (start3 < from4) {
result2.push(child3.slice(0, from4 - start3, view));
}
if (replacement) {
result2.push(replacement);
replacement = null;
}
if (end2 > to) {
result2.push(child3.slice(to - start3, child3.size, view));
}
}
}
return result2;
}
function selectionFromDOM(view, origin) {
var domSel = view.root.getSelection(), doc2 = view.state.doc;
if (!domSel.focusNode) {
return null;
}
var nearestDesc2 = view.docView.nearestDesc(domSel.focusNode), inWidget = nearestDesc2 && nearestDesc2.size == 0;
var head = view.docView.posFromDOM(domSel.focusNode, domSel.focusOffset);
if (head < 0) {
return null;
}
var $head = doc2.resolve(head), $anchor, selection;
if (selectionCollapsed(domSel)) {
$anchor = $head;
while (nearestDesc2 && !nearestDesc2.node) {
nearestDesc2 = nearestDesc2.parent;
}
if (nearestDesc2 && nearestDesc2.node.isAtom && NodeSelection.isSelectable(nearestDesc2.node) && nearestDesc2.parent && !(nearestDesc2.node.isInline && isOnEdge(domSel.focusNode, domSel.focusOffset, nearestDesc2.dom))) {
var pos = nearestDesc2.posBefore;
selection = new NodeSelection(head == pos ? $head : doc2.resolve(pos));
}
} else {
var anchor = view.docView.posFromDOM(domSel.anchorNode, domSel.anchorOffset);
if (anchor < 0) {
return null;
}
$anchor = doc2.resolve(anchor);
}
if (!selection) {
var bias = origin == "pointer" || view.state.selection.head < $head.pos && !inWidget ? 1 : -1;
selection = selectionBetween(view, $anchor, $head, bias);
}
return selection;
}
function editorOwnsSelection(view) {
return view.editable ? view.hasFocus() : hasSelection(view) && document.activeElement && document.activeElement.contains(view.dom);
}
function selectionToDOM(view, force) {
var sel = view.state.selection;
syncNodeSelection(view, sel);
if (!editorOwnsSelection(view)) {
return;
}
view.domObserver.disconnectSelection();
if (view.cursorWrapper) {
selectCursorWrapper(view);
} else {
var anchor = sel.anchor;
var head = sel.head;
var resetEditableFrom, resetEditableTo;
if (brokenSelectBetweenUneditable && !(sel instanceof TextSelection)) {
if (!sel.$from.parent.inlineContent) {
resetEditableFrom = temporarilyEditableNear(view, sel.from);
}
if (!sel.empty && !sel.$from.parent.inlineContent) {
resetEditableTo = temporarilyEditableNear(view, sel.to);
}
}
view.docView.setSelection(anchor, head, view.root, force);
if (brokenSelectBetweenUneditable) {
if (resetEditableFrom) {
resetEditable(resetEditableFrom);
}
if (resetEditableTo) {
resetEditable(resetEditableTo);
}
}
if (sel.visible) {
view.dom.classList.remove("ProseMirror-hideselection");
} else {
view.dom.classList.add("ProseMirror-hideselection");
if ("onselectionchange" in document) {
removeClassOnSelectionChange(view);
}
}
}
view.domObserver.setCurSelection();
view.domObserver.connectSelection();
}
var brokenSelectBetweenUneditable = result.safari || result.chrome && result.chrome_version < 63;
function temporarilyEditableNear(view, pos) {
var ref2 = view.docView.domFromPos(pos, 0);
var node4 = ref2.node;
var offset2 = ref2.offset;
var after3 = offset2 < node4.childNodes.length ? node4.childNodes[offset2] : null;
var before3 = offset2 ? node4.childNodes[offset2 - 1] : null;
if (result.safari && after3 && after3.contentEditable == "false") {
return setEditable(after3);
}
if ((!after3 || after3.contentEditable == "false") && (!before3 || before3.contentEditable == "false")) {
if (after3) {
return setEditable(after3);
} else if (before3) {
return setEditable(before3);
}
}
}
function setEditable(element) {
element.contentEditable = "true";
if (result.safari && element.draggable) {
element.draggable = false;
element.wasDraggable = true;
}
return element;
}
function resetEditable(element) {
element.contentEditable = "false";
if (element.wasDraggable) {
element.draggable = true;
element.wasDraggable = null;
}
}
function removeClassOnSelectionChange(view) {
var doc2 = view.dom.ownerDocument;
doc2.removeEventListener("selectionchange", view.hideSelectionGuard);
var domSel = view.root.getSelection();
var node4 = domSel.anchorNode, offset2 = domSel.anchorOffset;
doc2.addEventListener("selectionchange", view.hideSelectionGuard = function() {
if (domSel.anchorNode != node4 || domSel.anchorOffset != offset2) {
doc2.removeEventListener("selectionchange", view.hideSelectionGuard);
setTimeout(function() {
if (!editorOwnsSelection(view) || view.state.selection.visible) {
view.dom.classList.remove("ProseMirror-hideselection");
}
}, 20);
}
});
}
function selectCursorWrapper(view) {
var domSel = view.root.getSelection(), range2 = document.createRange();
var node4 = view.cursorWrapper.dom, img = node4.nodeName == "IMG";
if (img) {
range2.setEnd(node4.parentNode, domIndex(node4) + 1);
} else {
range2.setEnd(node4, 0);
}
range2.collapse(false);
domSel.removeAllRanges();
domSel.addRange(range2);
if (!img && !view.state.selection.visible && result.ie && result.ie_version <= 11) {
node4.disabled = true;
node4.disabled = false;
}
}
function syncNodeSelection(view, sel) {
if (sel instanceof NodeSelection) {
var desc = view.docView.descAt(sel.from);
if (desc != view.lastSelectedViewDesc) {
clearNodeSelection(view);
if (desc) {
desc.selectNode();
}
view.lastSelectedViewDesc = desc;
}
} else {
clearNodeSelection(view);
}
}
function clearNodeSelection(view) {
if (view.lastSelectedViewDesc) {
if (view.lastSelectedViewDesc.parent) {
view.lastSelectedViewDesc.deselectNode();
}
view.lastSelectedViewDesc = null;
}
}
function selectionBetween(view, $anchor, $head, bias) {
return view.someProp("createSelectionBetween", function(f) {
return f(view, $anchor, $head);
}) || TextSelection.between($anchor, $head, bias);
}
function hasFocusAndSelection(view) {
if (view.editable && view.root.activeElement != view.dom) {
return false;
}
return hasSelection(view);
}
function hasSelection(view) {
var sel = view.root.getSelection();
if (!sel.anchorNode) {
return false;
}
try {
return view.dom.contains(sel.anchorNode.nodeType == 3 ? sel.anchorNode.parentNode : sel.anchorNode) && (view.editable || view.dom.contains(sel.focusNode.nodeType == 3 ? sel.focusNode.parentNode : sel.focusNode));
} catch (_2) {
return false;
}
}
function anchorInRightPlace(view) {
var anchorDOM = view.docView.domFromPos(view.state.selection.anchor, 0);
var domSel = view.root.getSelection();
return isEquivalentPosition(anchorDOM.node, anchorDOM.offset, domSel.anchorNode, domSel.anchorOffset);
}
function moveSelectionBlock(state, dir) {
var ref2 = state.selection;
var $anchor = ref2.$anchor;
var $head = ref2.$head;
var $side = dir > 0 ? $anchor.max($head) : $anchor.min($head);
var $start = !$side.parent.inlineContent ? $side : $side.depth ? state.doc.resolve(dir > 0 ? $side.after() : $side.before()) : null;
return $start && Selection.findFrom($start, dir);
}
function apply7(view, sel) {
view.dispatch(view.state.tr.setSelection(sel).scrollIntoView());
return true;
}
function selectHorizontally(view, dir, mods) {
var sel = view.state.selection;
if (sel instanceof TextSelection) {
if (!sel.empty || mods.indexOf("s") > -1) {
return false;
} else if (view.endOfTextblock(dir > 0 ? "right" : "left")) {
var next2 = moveSelectionBlock(view.state, dir);
if (next2 && next2 instanceof NodeSelection) {
return apply7(view, next2);
}
return false;
} else if (!(result.mac && mods.indexOf("m") > -1)) {
var $head = sel.$head, node4 = $head.textOffset ? null : dir < 0 ? $head.nodeBefore : $head.nodeAfter, desc;
if (!node4 || node4.isText) {
return false;
}
var nodePos = dir < 0 ? $head.pos - node4.nodeSize : $head.pos;
if (!(node4.isAtom || (desc = view.docView.descAt(nodePos)) && !desc.contentDOM)) {
return false;
}
if (NodeSelection.isSelectable(node4)) {
return apply7(view, new NodeSelection(dir < 0 ? view.state.doc.resolve($head.pos - node4.nodeSize) : $head));
} else if (result.webkit) {
return apply7(view, new TextSelection(view.state.doc.resolve(dir < 0 ? nodePos : nodePos + node4.nodeSize)));
} else {
return false;
}
}
} else if (sel instanceof NodeSelection && sel.node.isInline) {
return apply7(view, new TextSelection(dir > 0 ? sel.$to : sel.$from));
} else {
var next$1 = moveSelectionBlock(view.state, dir);
if (next$1) {
return apply7(view, next$1);
}
return false;
}
}
function nodeLen(node4) {
return node4.nodeType == 3 ? node4.nodeValue.length : node4.childNodes.length;
}
function isIgnorable(dom) {
var desc = dom.pmViewDesc;
return desc && desc.size == 0 && (dom.nextSibling || dom.nodeName != "BR");
}
function skipIgnoredNodesLeft(view) {
var sel = view.root.getSelection();
var node4 = sel.focusNode, offset2 = sel.focusOffset;
if (!node4) {
return;
}
var moveNode, moveOffset, force = false;
if (result.gecko && node4.nodeType == 1 && offset2 < nodeLen(node4) && isIgnorable(node4.childNodes[offset2])) {
force = true;
}
for (; ; ) {
if (offset2 > 0) {
if (node4.nodeType != 1) {
break;
} else {
var before3 = node4.childNodes[offset2 - 1];
if (isIgnorable(before3)) {
moveNode = node4;
moveOffset = --offset2;
} else if (before3.nodeType == 3) {
node4 = before3;
offset2 = node4.nodeValue.length;
} else {
break;
}
}
} else if (isBlockNode(node4)) {
break;
} else {
var prev = node4.previousSibling;
while (prev && isIgnorable(prev)) {
moveNode = node4.parentNode;
moveOffset = domIndex(prev);
prev = prev.previousSibling;
}
if (!prev) {
node4 = node4.parentNode;
if (node4 == view.dom) {
break;
}
offset2 = 0;
} else {
node4 = prev;
offset2 = nodeLen(node4);
}
}
}
if (force) {
setSelFocus(view, sel, node4, offset2);
} else if (moveNode) {
setSelFocus(view, sel, moveNode, moveOffset);
}
}
function skipIgnoredNodesRight(view) {
var sel = view.root.getSelection();
var node4 = sel.focusNode, offset2 = sel.focusOffset;
if (!node4) {
return;
}
var len2 = nodeLen(node4);
var moveNode, moveOffset;
for (; ; ) {
if (offset2 < len2) {
if (node4.nodeType != 1) {
break;
}
var after3 = node4.childNodes[offset2];
if (isIgnorable(after3)) {
moveNode = node4;
moveOffset = ++offset2;
} else {
break;
}
} else if (isBlockNode(node4)) {
break;
} else {
var next2 = node4.nextSibling;
while (next2 && isIgnorable(next2)) {
moveNode = next2.parentNode;
moveOffset = domIndex(next2) + 1;
next2 = next2.nextSibling;
}
if (!next2) {
node4 = node4.parentNode;
if (node4 == view.dom) {
break;
}
offset2 = len2 = 0;
} else {
node4 = next2;
offset2 = 0;
len2 = nodeLen(node4);
}
}
}
if (moveNode) {
setSelFocus(view, sel, moveNode, moveOffset);
}
}
function isBlockNode(dom) {
var desc = dom.pmViewDesc;
return desc && desc.node && desc.node.isBlock;
}
function setSelFocus(view, sel, node4, offset2) {
if (selectionCollapsed(sel)) {
var range2 = document.createRange();
range2.setEnd(node4, offset2);
range2.setStart(node4, offset2);
sel.removeAllRanges();
sel.addRange(range2);
} else if (sel.extend) {
sel.extend(node4, offset2);
}
view.domObserver.setCurSelection();
var state = view.state;
setTimeout(function() {
if (view.state == state) {
selectionToDOM(view);
}
}, 50);
}
function selectVertically(view, dir, mods) {
var sel = view.state.selection;
if (sel instanceof TextSelection && !sel.empty || mods.indexOf("s") > -1) {
return false;
}
if (result.mac && mods.indexOf("m") > -1) {
return false;
}
var $from = sel.$from;
var $to = sel.$to;
if (!$from.parent.inlineContent || view.endOfTextblock(dir < 0 ? "up" : "down")) {
var next2 = moveSelectionBlock(view.state, dir);
if (next2 && next2 instanceof NodeSelection) {
return apply7(view, next2);
}
}
if (!$from.parent.inlineContent) {
var side = dir < 0 ? $from : $to;
var beyond = sel instanceof AllSelection ? Selection.near(side, dir) : Selection.findFrom(side, dir);
return beyond ? apply7(view, beyond) : false;
}
return false;
}
function stopNativeHorizontalDelete(view, dir) {
if (!(view.state.selection instanceof TextSelection)) {
return true;
}
var ref2 = view.state.selection;
var $head = ref2.$head;
var $anchor = ref2.$anchor;
var empty2 = ref2.empty;
if (!$head.sameParent($anchor)) {
return true;
}
if (!empty2) {
return false;
}
if (view.endOfTextblock(dir > 0 ? "forward" : "backward")) {
return true;
}
var nextNode = !$head.textOffset && (dir < 0 ? $head.nodeBefore : $head.nodeAfter);
if (nextNode && !nextNode.isText) {
var tr = view.state.tr;
if (dir < 0) {
tr.delete($head.pos - nextNode.nodeSize, $head.pos);
} else {
tr.delete($head.pos, $head.pos + nextNode.nodeSize);
}
view.dispatch(tr);
return true;
}
return false;
}
function switchEditable(view, node4, state) {
view.domObserver.stop();
node4.contentEditable = state;
view.domObserver.start();
}
function safariDownArrowBug(view) {
if (!result.safari || view.state.selection.$head.parentOffset > 0) {
return;
}
var ref2 = view.root.getSelection();
var focusNode = ref2.focusNode;
var focusOffset = ref2.focusOffset;
if (focusNode && focusNode.nodeType == 1 && focusOffset == 0 && focusNode.firstChild && focusNode.firstChild.contentEditable == "false") {
var child3 = focusNode.firstChild;
switchEditable(view, child3, true);
setTimeout(function() {
return switchEditable(view, child3, false);
}, 20);
}
}
function getMods(event) {
var result2 = "";
if (event.ctrlKey) {
result2 += "c";
}
if (event.metaKey) {
result2 += "m";
}
if (event.altKey) {
result2 += "a";
}
if (event.shiftKey) {
result2 += "s";
}
return result2;
}
function captureKeyDown(view, event) {
var code = event.keyCode, mods = getMods(event);
if (code == 8 || result.mac && code == 72 && mods == "c") {
return stopNativeHorizontalDelete(view, -1) || skipIgnoredNodesLeft(view);
} else if (code == 46 || result.mac && code == 68 && mods == "c") {
return stopNativeHorizontalDelete(view, 1) || skipIgnoredNodesRight(view);
} else if (code == 13 || code == 27) {
return true;
} else if (code == 37) {
return selectHorizontally(view, -1, mods) || skipIgnoredNodesLeft(view);
} else if (code == 39) {
return selectHorizontally(view, 1, mods) || skipIgnoredNodesRight(view);
} else if (code == 38) {
return selectVertically(view, -1, mods) || skipIgnoredNodesLeft(view);
} else if (code == 40) {
return safariDownArrowBug(view) || selectVertically(view, 1, mods) || skipIgnoredNodesRight(view);
} else if (mods == (result.mac ? "m" : "c") && (code == 66 || code == 73 || code == 89 || code == 90)) {
return true;
}
return false;
}
function parseBetween(view, from_, to_) {
var ref2 = view.docView.parseRange(from_, to_);
var parent = ref2.node;
var fromOffset = ref2.fromOffset;
var toOffset = ref2.toOffset;
var from4 = ref2.from;
var to = ref2.to;
var domSel = view.root.getSelection(), find3 = null, anchor = domSel.anchorNode;
if (anchor && view.dom.contains(anchor.nodeType == 1 ? anchor : anchor.parentNode)) {
find3 = [{node: anchor, offset: domSel.anchorOffset}];
if (!selectionCollapsed(domSel)) {
find3.push({node: domSel.focusNode, offset: domSel.focusOffset});
}
}
if (result.chrome && view.lastKeyCode === 8) {
for (var off2 = toOffset; off2 > fromOffset; off2--) {
var node4 = parent.childNodes[off2 - 1], desc = node4.pmViewDesc;
if (node4.nodeType == "BR" && !desc) {
toOffset = off2;
break;
}
if (!desc || desc.size) {
break;
}
}
}
var startDoc = view.state.doc;
var parser = view.someProp("domParser") || DOMParser.fromSchema(view.state.schema);
var $from = startDoc.resolve(from4);
var sel = null, doc2 = parser.parse(parent, {
topNode: $from.parent,
topMatch: $from.parent.contentMatchAt($from.index()),
topOpen: true,
from: fromOffset,
to: toOffset,
preserveWhitespace: $from.parent.type.spec.code ? "full" : true,
editableContent: true,
findPositions: find3,
ruleFromNode,
context: $from
});
if (find3 && find3[0].pos != null) {
var anchor$1 = find3[0].pos, head = find3[1] && find3[1].pos;
if (head == null) {
head = anchor$1;
}
sel = {anchor: anchor$1 + from4, head: head + from4};
}
return {doc: doc2, sel, from: from4, to};
}
function ruleFromNode(dom) {
var desc = dom.pmViewDesc;
if (desc) {
return desc.parseRule();
} else if (dom.nodeName == "BR" && dom.parentNode) {
if (result.safari && /^(ul|ol)$/i.test(dom.parentNode.nodeName)) {
var skip = document.createElement("div");
skip.appendChild(document.createElement("li"));
return {skip};
} else if (dom.parentNode.lastChild == dom || result.safari && /^(tr|table)$/i.test(dom.parentNode.nodeName)) {
return {ignore: true};
}
} else if (dom.nodeName == "IMG" && dom.getAttribute("mark-placeholder")) {
return {ignore: true};
}
}
function readDOMChange(view, from4, to, typeOver, addedNodes) {
if (from4 < 0) {
var origin = view.lastSelectionTime > Date.now() - 50 ? view.lastSelectionOrigin : null;
var newSel = selectionFromDOM(view, origin);
if (newSel && !view.state.selection.eq(newSel)) {
var tr$1 = view.state.tr.setSelection(newSel);
if (origin == "pointer") {
tr$1.setMeta("pointer", true);
} else if (origin == "key") {
tr$1.scrollIntoView();
}
view.dispatch(tr$1);
}
return;
}
var $before = view.state.doc.resolve(from4);
var shared = $before.sharedDepth(to);
from4 = $before.before(shared + 1);
to = view.state.doc.resolve(to).after(shared + 1);
var sel = view.state.selection;
var parse4 = parseBetween(view, from4, to);
if (result.chrome && view.cursorWrapper && parse4.sel && parse4.sel.anchor == view.cursorWrapper.deco.from) {
var text3 = view.cursorWrapper.deco.type.toDOM.nextSibling;
var size2 = text3 && text3.nodeValue ? text3.nodeValue.length : 1;
parse4.sel = {anchor: parse4.sel.anchor + size2, head: parse4.sel.anchor + size2};
}
var doc2 = view.state.doc, compare = doc2.slice(parse4.from, parse4.to);
var preferredPos, preferredSide;
if (view.lastKeyCode === 8 && Date.now() - 100 < view.lastKeyCodeTime) {
preferredPos = view.state.selection.to;
preferredSide = "end";
} else {
preferredPos = view.state.selection.from;
preferredSide = "start";
}
view.lastKeyCode = null;
var change = findDiff(compare.content, parse4.doc.content, parse4.from, preferredPos, preferredSide);
if (!change) {
if (typeOver && sel instanceof TextSelection && !sel.empty && sel.$head.sameParent(sel.$anchor) && !view.composing && !(parse4.sel && parse4.sel.anchor != parse4.sel.head)) {
change = {start: sel.from, endA: sel.to, endB: sel.to};
} else if (result.ios && view.lastIOSEnter > Date.now() - 225 && addedNodes.some(function(n) {
return n.nodeName == "DIV" || n.nodeName == "P";
}) && view.someProp("handleKeyDown", function(f) {
return f(view, keyEvent(13, "Enter"));
})) {
view.lastIOSEnter = 0;
return;
} else {
if (parse4.sel) {
var sel$1 = resolveSelection(view, view.state.doc, parse4.sel);
if (sel$1 && !sel$1.eq(view.state.selection)) {
view.dispatch(view.state.tr.setSelection(sel$1));
}
}
return;
}
}
view.domChangeCount++;
if (view.state.selection.from < view.state.selection.to && change.start == change.endB && view.state.selection instanceof TextSelection) {
if (change.start > view.state.selection.from && change.start <= view.state.selection.from + 2) {
change.start = view.state.selection.from;
} else if (change.endA < view.state.selection.to && change.endA >= view.state.selection.to - 2) {
change.endB += view.state.selection.to - change.endA;
change.endA = view.state.selection.to;
}
}
if (result.ie && result.ie_version <= 11 && change.endB == change.start + 1 && change.endA == change.start && change.start > parse4.from && parse4.doc.textBetween(change.start - parse4.from - 1, change.start - parse4.from + 1) == " \xA0") {
change.start--;
change.endA--;
change.endB--;
}
var $from = parse4.doc.resolveNoCache(change.start - parse4.from);
var $to = parse4.doc.resolveNoCache(change.endB - parse4.from);
var inlineChange = $from.sameParent($to) && $from.parent.inlineContent;
var nextSel;
if ((result.ios && view.lastIOSEnter > Date.now() - 225 && (!inlineChange || addedNodes.some(function(n) {
return n.nodeName == "DIV" || n.nodeName == "P";
})) || !inlineChange && $from.pos < parse4.doc.content.size && (nextSel = Selection.findFrom(parse4.doc.resolve($from.pos + 1), 1, true)) && nextSel.head == $to.pos) && view.someProp("handleKeyDown", function(f) {
return f(view, keyEvent(13, "Enter"));
})) {
view.lastIOSEnter = 0;
return;
}
if (view.state.selection.anchor > change.start && looksLikeJoin(doc2, change.start, change.endA, $from, $to) && view.someProp("handleKeyDown", function(f) {
return f(view, keyEvent(8, "Backspace"));
})) {
if (result.android && result.chrome) {
view.domObserver.suppressSelectionUpdates();
}
return;
}
if (result.android && !inlineChange && $from.start() != $to.start() && $to.parentOffset == 0 && $from.depth == $to.depth && parse4.sel && parse4.sel.anchor == parse4.sel.head && parse4.sel.head == change.endA) {
change.endB -= 2;
$to = parse4.doc.resolveNoCache(change.endB - parse4.from);
setTimeout(function() {
view.someProp("handleKeyDown", function(f) {
return f(view, keyEvent(13, "Enter"));
});
}, 20);
}
var chFrom = change.start, chTo = change.endA;
var tr, storedMarks, markChange, $from1;
if (inlineChange) {
if ($from.pos == $to.pos) {
if (result.ie && result.ie_version <= 11 && $from.parentOffset == 0) {
view.domObserver.suppressSelectionUpdates();
setTimeout(function() {
return selectionToDOM(view);
}, 20);
}
tr = view.state.tr.delete(chFrom, chTo);
storedMarks = doc2.resolve(change.start).marksAcross(doc2.resolve(change.endA));
} else if (change.endA == change.endB && ($from1 = doc2.resolve(change.start)) && (markChange = isMarkChange($from.parent.content.cut($from.parentOffset, $to.parentOffset), $from1.parent.content.cut($from1.parentOffset, change.endA - $from1.start())))) {
tr = view.state.tr;
if (markChange.type == "add") {
tr.addMark(chFrom, chTo, markChange.mark);
} else {
tr.removeMark(chFrom, chTo, markChange.mark);
}
} else if ($from.parent.child($from.index()).isText && $from.index() == $to.index() - ($to.textOffset ? 0 : 1)) {
var text$12 = $from.parent.textBetween($from.parentOffset, $to.parentOffset);
if (view.someProp("handleTextInput", function(f) {
return f(view, chFrom, chTo, text$12);
})) {
return;
}
tr = view.state.tr.insertText(text$12, chFrom, chTo);
}
}
if (!tr) {
tr = view.state.tr.replace(chFrom, chTo, parse4.doc.slice(change.start - parse4.from, change.endB - parse4.from));
}
if (parse4.sel) {
var sel$2 = resolveSelection(view, tr.doc, parse4.sel);
if (sel$2 && !(result.chrome && result.android && view.composing && sel$2.empty && (sel$2.head == chFrom || sel$2.head == tr.mapping.map(chTo) - 1) || result.ie && sel$2.empty && sel$2.head == chFrom)) {
tr.setSelection(sel$2);
}
}
if (storedMarks) {
tr.ensureMarks(storedMarks);
}
view.dispatch(tr.scrollIntoView());
}
function resolveSelection(view, doc2, parsedSel) {
if (Math.max(parsedSel.anchor, parsedSel.head) > doc2.content.size) {
return null;
}
return selectionBetween(view, doc2.resolve(parsedSel.anchor), doc2.resolve(parsedSel.head));
}
function isMarkChange(cur, prev) {
var curMarks = cur.firstChild.marks, prevMarks = prev.firstChild.marks;
var added = curMarks, removed = prevMarks, type, mark3, update6;
for (var i = 0; i < prevMarks.length; i++) {
added = prevMarks[i].removeFromSet(added);
}
for (var i$1 = 0; i$1 < curMarks.length; i$1++) {
removed = curMarks[i$1].removeFromSet(removed);
}
if (added.length == 1 && removed.length == 0) {
mark3 = added[0];
type = "add";
update6 = function(node4) {
return node4.mark(mark3.addToSet(node4.marks));
};
} else if (added.length == 0 && removed.length == 1) {
mark3 = removed[0];
type = "remove";
update6 = function(node4) {
return node4.mark(mark3.removeFromSet(node4.marks));
};
} else {
return null;
}
var updated2 = [];
for (var i$2 = 0; i$2 < prev.childCount; i$2++) {
updated2.push(update6(prev.child(i$2)));
}
if (Fragment.from(updated2).eq(cur)) {
return {mark: mark3, type};
}
}
function looksLikeJoin(old, start3, end2, $newStart, $newEnd) {
if (!$newStart.parent.isTextblock || end2 - start3 <= $newEnd.pos - $newStart.pos || skipClosingAndOpening($newStart, true, false) < $newEnd.pos) {
return false;
}
var $start = old.resolve(start3);
if ($start.parentOffset < $start.parent.content.size || !$start.parent.isTextblock) {
return false;
}
var $next = old.resolve(skipClosingAndOpening($start, true, true));
if (!$next.parent.isTextblock || $next.pos > end2 || skipClosingAndOpening($next, true, false) < end2) {
return false;
}
return $newStart.parent.content.cut($newStart.parentOffset).eq($next.parent.content);
}
function skipClosingAndOpening($pos, fromEnd, mayOpen) {
var depth = $pos.depth, end2 = fromEnd ? $pos.end() : $pos.pos;
while (depth > 0 && (fromEnd || $pos.indexAfter(depth) == $pos.node(depth).childCount)) {
depth--;
end2++;
fromEnd = false;
}
if (mayOpen) {
var next2 = $pos.node(depth).maybeChild($pos.indexAfter(depth));
while (next2 && !next2.isLeaf) {
next2 = next2.firstChild;
end2++;
}
}
return end2;
}
function findDiff(a, b, pos, preferredPos, preferredSide) {
var start3 = a.findDiffStart(b, pos);
if (start3 == null) {
return null;
}
var ref2 = a.findDiffEnd(b, pos + a.size, pos + b.size);
var endA = ref2.a;
var endB = ref2.b;
if (preferredSide == "end") {
var adjust = Math.max(0, start3 - Math.min(endA, endB));
preferredPos -= endA + adjust - start3;
}
if (endA < start3 && a.size < b.size) {
var move2 = preferredPos <= start3 && preferredPos >= endA ? start3 - preferredPos : 0;
start3 -= move2;
endB = start3 + (endB - endA);
endA = start3;
} else if (endB < start3) {
var move$1 = preferredPos <= start3 && preferredPos >= endB ? start3 - preferredPos : 0;
start3 -= move$1;
endA = start3 + (endA - endB);
endB = start3;
}
return {start: start3, endA, endB};
}
function serializeForClipboard(view, slice5) {
var context = [];
var content2 = slice5.content;
var openStart = slice5.openStart;
var openEnd = slice5.openEnd;
while (openStart > 1 && openEnd > 1 && content2.childCount == 1 && content2.firstChild.childCount == 1) {
openStart--;
openEnd--;
var node4 = content2.firstChild;
context.push(node4.type.name, node4.attrs != node4.type.defaultAttrs ? node4.attrs : null);
content2 = node4.content;
}
var serializer = view.someProp("clipboardSerializer") || DOMSerializer.fromSchema(view.state.schema);
var doc2 = detachedDoc(), wrap2 = doc2.createElement("div");
wrap2.appendChild(serializer.serializeFragment(content2, {document: doc2}));
var firstChild = wrap2.firstChild, needsWrap;
while (firstChild && firstChild.nodeType == 1 && (needsWrap = wrapMap[firstChild.nodeName.toLowerCase()])) {
for (var i = needsWrap.length - 1; i >= 0; i--) {
var wrapper3 = doc2.createElement(needsWrap[i]);
while (wrap2.firstChild) {
wrapper3.appendChild(wrap2.firstChild);
}
wrap2.appendChild(wrapper3);
}
firstChild = wrap2.firstChild;
}
if (firstChild && firstChild.nodeType == 1) {
firstChild.setAttribute("data-pm-slice", openStart + " " + openEnd + " " + JSON.stringify(context));
}
var text3 = view.someProp("clipboardTextSerializer", function(f) {
return f(slice5);
}) || slice5.content.textBetween(0, slice5.content.size, "\n\n");
return {dom: wrap2, text: text3};
}
function parseFromClipboard(view, text3, html2, plainText, $context) {
var dom, inCode = $context.parent.type.spec.code, slice5;
if (!html2 && !text3) {
return null;
}
var asText = text3 && (plainText || inCode || !html2);
if (asText) {
view.someProp("transformPastedText", function(f) {
text3 = f(text3, inCode || plainText);
});
if (inCode) {
return new Slice(Fragment.from(view.state.schema.text(text3.replace(/\r\n?/g, "\n"))), 0, 0);
}
var parsed = view.someProp("clipboardTextParser", function(f) {
return f(text3, $context, plainText);
});
if (parsed) {
slice5 = parsed;
} else {
dom = document.createElement("div");
text3.trim().split(/(?:\r\n?|\n)+/).forEach(function(block) {
dom.appendChild(document.createElement("p")).textContent = block;
});
}
} else {
view.someProp("transformPastedHTML", function(f) {
html2 = f(html2);
});
dom = readHTML(html2);
}
var contextNode = dom && dom.querySelector("[data-pm-slice]");
var sliceData = contextNode && /^(\d+) (\d+) (.*)/.exec(contextNode.getAttribute("data-pm-slice"));
if (!slice5) {
var parser = view.someProp("clipboardParser") || view.someProp("domParser") || DOMParser.fromSchema(view.state.schema);
slice5 = parser.parseSlice(dom, {preserveWhitespace: !!(asText || sliceData), context: $context});
}
if (sliceData) {
slice5 = addContext(closeSlice(slice5, +sliceData[1], +sliceData[2]), sliceData[3]);
} else {
slice5 = Slice.maxOpen(normalizeSiblings(slice5.content, $context), false);
}
view.someProp("transformPasted", function(f) {
slice5 = f(slice5);
});
return slice5;
}
function normalizeSiblings(fragment, $context) {
if (fragment.childCount < 2) {
return fragment;
}
var loop = function(d2) {
var parent = $context.node(d2);
var match3 = parent.contentMatchAt($context.index(d2));
var lastWrap = void 0, result2 = [];
fragment.forEach(function(node4) {
if (!result2) {
return;
}
var wrap2 = match3.findWrapping(node4.type), inLast;
if (!wrap2) {
return result2 = null;
}
if (inLast = result2.length && lastWrap.length && addToSibling(wrap2, lastWrap, node4, result2[result2.length - 1], 0)) {
result2[result2.length - 1] = inLast;
} else {
if (result2.length) {
result2[result2.length - 1] = closeRight(result2[result2.length - 1], lastWrap.length);
}
var wrapped = withWrappers(node4, wrap2);
result2.push(wrapped);
match3 = match3.matchType(wrapped.type, wrapped.attrs);
lastWrap = wrap2;
}
});
if (result2) {
return {v: Fragment.from(result2)};
}
};
for (var d = $context.depth; d >= 0; d--) {
var returned = loop(d);
if (returned)
return returned.v;
}
return fragment;
}
function withWrappers(node4, wrap2, from4) {
if (from4 === void 0)
from4 = 0;
for (var i = wrap2.length - 1; i >= from4; i--) {
node4 = wrap2[i].create(null, Fragment.from(node4));
}
return node4;
}
function addToSibling(wrap2, lastWrap, node4, sibling, depth) {
if (depth < wrap2.length && depth < lastWrap.length && wrap2[depth] == lastWrap[depth]) {
var inner = addToSibling(wrap2, lastWrap, node4, sibling.lastChild, depth + 1);
if (inner) {
return sibling.copy(sibling.content.replaceChild(sibling.childCount - 1, inner));
}
var match3 = sibling.contentMatchAt(sibling.childCount);
if (match3.matchType(depth == wrap2.length - 1 ? node4.type : wrap2[depth + 1])) {
return sibling.copy(sibling.content.append(Fragment.from(withWrappers(node4, wrap2, depth + 1))));
}
}
}
function closeRight(node4, depth) {
if (depth == 0) {
return node4;
}
var fragment = node4.content.replaceChild(node4.childCount - 1, closeRight(node4.lastChild, depth - 1));
var fill = node4.contentMatchAt(node4.childCount).fillBefore(Fragment.empty, true);
return node4.copy(fragment.append(fill));
}
function closeRange(fragment, side, from4, to, depth, openEnd) {
var node4 = side < 0 ? fragment.firstChild : fragment.lastChild, inner = node4.content;
if (depth < to - 1) {
inner = closeRange(inner, side, from4, to, depth + 1, openEnd);
}
if (depth >= from4) {
inner = side < 0 ? node4.contentMatchAt(0).fillBefore(inner, fragment.childCount > 1 || openEnd <= depth).append(inner) : inner.append(node4.contentMatchAt(node4.childCount).fillBefore(Fragment.empty, true));
}
return fragment.replaceChild(side < 0 ? 0 : fragment.childCount - 1, node4.copy(inner));
}
function closeSlice(slice5, openStart, openEnd) {
if (openStart < slice5.openStart) {
slice5 = new Slice(closeRange(slice5.content, -1, openStart, slice5.openStart, 0, slice5.openEnd), openStart, slice5.openEnd);
}
if (openEnd < slice5.openEnd) {
slice5 = new Slice(closeRange(slice5.content, 1, openEnd, slice5.openEnd, 0, 0), slice5.openStart, openEnd);
}
return slice5;
}
var wrapMap = {
thead: ["table"],
tbody: ["table"],
tfoot: ["table"],
caption: ["table"],
colgroup: ["table"],
col: ["table", "colgroup"],
tr: ["table", "tbody"],
td: ["table", "tbody", "tr"],
th: ["table", "tbody", "tr"]
};
var _detachedDoc = null;
function detachedDoc() {
return _detachedDoc || (_detachedDoc = document.implementation.createHTMLDocument("title"));
}
function readHTML(html2) {
var metas = /(\s*<meta [^>]*>)*/.exec(html2);
if (metas) {
html2 = html2.slice(metas[0].length);
}
var elt = detachedDoc().createElement("div");
var firstTag = /(?:<meta [^>]*>)*<([a-z][^>\s]+)/i.exec(html2), wrap2, depth = 0;
if (wrap2 = firstTag && wrapMap[firstTag[1].toLowerCase()]) {
html2 = wrap2.map(function(n) {
return "<" + n + ">";
}).join("") + html2 + wrap2.map(function(n) {
return "</" + n + ">";
}).reverse().join("");
depth = wrap2.length;
}
elt.innerHTML = html2;
for (var i = 0; i < depth; i++) {
elt = elt.firstChild;
}
return elt;
}
function addContext(slice5, context) {
if (!slice5.size) {
return slice5;
}
var schema = slice5.content.firstChild.type.schema, array;
try {
array = JSON.parse(context);
} catch (e) {
return slice5;
}
var content2 = slice5.content;
var openStart = slice5.openStart;
var openEnd = slice5.openEnd;
for (var i = array.length - 2; i >= 0; i -= 2) {
var type = schema.nodes[array[i]];
if (!type || type.hasRequiredAttrs()) {
break;
}
content2 = Fragment.from(type.create(array[i + 1], content2));
openStart++;
openEnd++;
}
return new Slice(content2, openStart, openEnd);
}
var observeOptions = {
childList: true,
characterData: true,
characterDataOldValue: true,
attributes: true,
attributeOldValue: true,
subtree: true
};
var useCharData = result.ie && result.ie_version <= 11;
var SelectionState = function SelectionState2() {
this.anchorNode = this.anchorOffset = this.focusNode = this.focusOffset = null;
};
SelectionState.prototype.set = function set2(sel) {
this.anchorNode = sel.anchorNode;
this.anchorOffset = sel.anchorOffset;
this.focusNode = sel.focusNode;
this.focusOffset = sel.focusOffset;
};
SelectionState.prototype.eq = function eq6(sel) {
return sel.anchorNode == this.anchorNode && sel.anchorOffset == this.anchorOffset && sel.focusNode == this.focusNode && sel.focusOffset == this.focusOffset;
};
var DOMObserver = function DOMObserver2(view, handleDOMChange) {
var this$1 = this;
this.view = view;
this.handleDOMChange = handleDOMChange;
this.queue = [];
this.flushingSoon = -1;
this.observer = window.MutationObserver && new window.MutationObserver(function(mutations) {
for (var i = 0; i < mutations.length; i++) {
this$1.queue.push(mutations[i]);
}
if (result.ie && result.ie_version <= 11 && mutations.some(function(m) {
return m.type == "childList" && m.removedNodes.length || m.type == "characterData" && m.oldValue.length > m.target.nodeValue.length;
})) {
this$1.flushSoon();
} else {
this$1.flush();
}
});
this.currentSelection = new SelectionState();
if (useCharData) {
this.onCharData = function(e) {
this$1.queue.push({target: e.target, type: "characterData", oldValue: e.prevValue});
this$1.flushSoon();
};
}
this.onSelectionChange = this.onSelectionChange.bind(this);
this.suppressingSelectionUpdates = false;
};
DOMObserver.prototype.flushSoon = function flushSoon() {
var this$1 = this;
if (this.flushingSoon < 0) {
this.flushingSoon = window.setTimeout(function() {
this$1.flushingSoon = -1;
this$1.flush();
}, 20);
}
};
DOMObserver.prototype.forceFlush = function forceFlush() {
if (this.flushingSoon > -1) {
window.clearTimeout(this.flushingSoon);
this.flushingSoon = -1;
this.flush();
}
};
DOMObserver.prototype.start = function start2() {
if (this.observer) {
this.observer.observe(this.view.dom, observeOptions);
}
if (useCharData) {
this.view.dom.addEventListener("DOMCharacterDataModified", this.onCharData);
}
this.connectSelection();
};
DOMObserver.prototype.stop = function stop() {
var this$1 = this;
if (this.observer) {
var take = this.observer.takeRecords();
if (take.length) {
for (var i = 0; i < take.length; i++) {
this.queue.push(take[i]);
}
window.setTimeout(function() {
return this$1.flush();
}, 20);
}
this.observer.disconnect();
}
if (useCharData) {
this.view.dom.removeEventListener("DOMCharacterDataModified", this.onCharData);
}
this.disconnectSelection();
};
DOMObserver.prototype.connectSelection = function connectSelection() {
this.view.dom.ownerDocument.addEventListener("selectionchange", this.onSelectionChange);
};
DOMObserver.prototype.disconnectSelection = function disconnectSelection() {
this.view.dom.ownerDocument.removeEventListener("selectionchange", this.onSelectionChange);
};
DOMObserver.prototype.suppressSelectionUpdates = function suppressSelectionUpdates() {
var this$1 = this;
this.suppressingSelectionUpdates = true;
setTimeout(function() {
return this$1.suppressingSelectionUpdates = false;
}, 50);
};
DOMObserver.prototype.onSelectionChange = function onSelectionChange() {
if (!hasFocusAndSelection(this.view)) {
return;
}
if (this.suppressingSelectionUpdates) {
return selectionToDOM(this.view);
}
if (result.ie && result.ie_version <= 11 && !this.view.state.selection.empty) {
var sel = this.view.root.getSelection();
if (sel.focusNode && isEquivalentPosition(sel.focusNode, sel.focusOffset, sel.anchorNode, sel.anchorOffset)) {
return this.flushSoon();
}
}
this.flush();
};
DOMObserver.prototype.setCurSelection = function setCurSelection() {
this.currentSelection.set(this.view.root.getSelection());
};
DOMObserver.prototype.ignoreSelectionChange = function ignoreSelectionChange(sel) {
if (sel.rangeCount == 0) {
return true;
}
var container = sel.getRangeAt(0).commonAncestorContainer;
var desc = this.view.docView.nearestDesc(container);
if (desc && desc.ignoreMutation({type: "selection", target: container.nodeType == 3 ? container.parentNode : container})) {
this.setCurSelection();
return true;
}
};
DOMObserver.prototype.flush = function flush() {
if (!this.view.docView || this.flushingSoon > -1) {
return;
}
var mutations = this.observer ? this.observer.takeRecords() : [];
if (this.queue.length) {
mutations = this.queue.concat(mutations);
this.queue.length = 0;
}
var sel = this.view.root.getSelection();
var newSel = !this.suppressingSelectionUpdates && !this.currentSelection.eq(sel) && hasSelection(this.view) && !this.ignoreSelectionChange(sel);
var from4 = -1, to = -1, typeOver = false, added = [];
if (this.view.editable) {
for (var i = 0; i < mutations.length; i++) {
var result$12 = this.registerMutation(mutations[i], added);
if (result$12) {
from4 = from4 < 0 ? result$12.from : Math.min(result$12.from, from4);
to = to < 0 ? result$12.to : Math.max(result$12.to, to);
if (result$12.typeOver) {
typeOver = true;
}
}
}
}
if (result.gecko && added.length > 1) {
var brs = added.filter(function(n) {
return n.nodeName == "BR";
});
if (brs.length == 2) {
var a = brs[0];
var b = brs[1];
if (a.parentNode && a.parentNode.parentNode == b.parentNode) {
b.remove();
} else {
a.remove();
}
}
}
if (from4 > -1 || newSel) {
if (from4 > -1) {
this.view.docView.markDirty(from4, to);
checkCSS(this.view);
}
this.handleDOMChange(from4, to, typeOver, added);
if (this.view.docView.dirty) {
this.view.updateState(this.view.state);
} else if (!this.currentSelection.eq(sel)) {
selectionToDOM(this.view);
}
this.currentSelection.set(sel);
}
};
DOMObserver.prototype.registerMutation = function registerMutation(mut, added) {
if (added.indexOf(mut.target) > -1) {
return null;
}
var desc = this.view.docView.nearestDesc(mut.target);
if (mut.type == "attributes" && (desc == this.view.docView || mut.attributeName == "contenteditable" || mut.attributeName == "style" && !mut.oldValue && !mut.target.getAttribute("style"))) {
return null;
}
if (!desc || desc.ignoreMutation(mut)) {
return null;
}
if (mut.type == "childList") {
if (desc.contentDOM && desc.contentDOM != desc.dom && !desc.contentDOM.contains(mut.target)) {
return {from: desc.posBefore, to: desc.posAfter};
}
var prev = mut.previousSibling, next2 = mut.nextSibling;
if (result.ie && result.ie_version <= 11 && mut.addedNodes.length) {
for (var i = 0; i < mut.addedNodes.length; i++) {
var ref2 = mut.addedNodes[i];
var previousSibling = ref2.previousSibling;
var nextSibling2 = ref2.nextSibling;
if (!previousSibling || Array.prototype.indexOf.call(mut.addedNodes, previousSibling) < 0) {
prev = previousSibling;
}
if (!nextSibling2 || Array.prototype.indexOf.call(mut.addedNodes, nextSibling2) < 0) {
next2 = nextSibling2;
}
}
}
var fromOffset = prev && prev.parentNode == mut.target ? domIndex(prev) + 1 : 0;
var from4 = desc.localPosFromDOM(mut.target, fromOffset, -1);
var toOffset = next2 && next2.parentNode == mut.target ? domIndex(next2) : mut.target.childNodes.length;
for (var i$1 = 0; i$1 < mut.addedNodes.length; i$1++) {
added.push(mut.addedNodes[i$1]);
}
var to = desc.localPosFromDOM(mut.target, toOffset, 1);
return {from: from4, to};
} else if (mut.type == "attributes") {
return {from: desc.posAtStart - desc.border, to: desc.posAtEnd + desc.border};
} else {
return {
from: desc.posAtStart,
to: desc.posAtEnd,
typeOver: mut.target.nodeValue == mut.oldValue
};
}
};
var cssChecked = false;
function checkCSS(view) {
if (cssChecked) {
return;
}
cssChecked = true;
if (getComputedStyle(view.dom).whiteSpace == "normal") {
console["warn"]("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package.");
}
}
var handlers = {}, editHandlers = {};
function initInput(view) {
view.shiftKey = false;
view.mouseDown = null;
view.lastKeyCode = null;
view.lastKeyCodeTime = 0;
view.lastClick = {time: 0, x: 0, y: 0, type: ""};
view.lastSelectionOrigin = null;
view.lastSelectionTime = 0;
view.lastIOSEnter = 0;
view.lastIOSEnterFallbackTimeout = null;
view.composing = false;
view.composingTimeout = null;
view.compositionNodes = [];
view.compositionEndedAt = -2e8;
view.domObserver = new DOMObserver(view, function(from4, to, typeOver, added) {
return readDOMChange(view, from4, to, typeOver, added);
});
view.domObserver.start();
view.domChangeCount = 0;
view.eventHandlers = Object.create(null);
var loop = function(event2) {
var handler = handlers[event2];
view.dom.addEventListener(event2, view.eventHandlers[event2] = function(event3) {
if (eventBelongsToView(view, event3) && !runCustomHandler(view, event3) && (view.editable || !(event3.type in editHandlers))) {
handler(view, event3);
}
});
};
for (var event in handlers)
loop(event);
if (result.safari) {
view.dom.addEventListener("input", function() {
return null;
});
}
ensureListeners(view);
}
function setSelectionOrigin(view, origin) {
view.lastSelectionOrigin = origin;
view.lastSelectionTime = Date.now();
}
function destroyInput(view) {
view.domObserver.stop();
for (var type in view.eventHandlers) {
view.dom.removeEventListener(type, view.eventHandlers[type]);
}
clearTimeout(view.composingTimeout);
clearTimeout(view.lastIOSEnterFallbackTimeout);
}
function ensureListeners(view) {
view.someProp("handleDOMEvents", function(currentHandlers) {
for (var type in currentHandlers) {
if (!view.eventHandlers[type]) {
view.dom.addEventListener(type, view.eventHandlers[type] = function(event) {
return runCustomHandler(view, event);
});
}
}
});
}
function runCustomHandler(view, event) {
return view.someProp("handleDOMEvents", function(handlers2) {
var handler = handlers2[event.type];
return handler ? handler(view, event) || event.defaultPrevented : false;
});
}
function eventBelongsToView(view, event) {
if (!event.bubbles) {
return true;
}
if (event.defaultPrevented) {
return false;
}
for (var node4 = event.target; node4 != view.dom; node4 = node4.parentNode) {
if (!node4 || node4.nodeType == 11 || node4.pmViewDesc && node4.pmViewDesc.stopEvent(event)) {
return false;
}
}
return true;
}
function dispatchEvent$1(view, event) {
if (!runCustomHandler(view, event) && handlers[event.type] && (view.editable || !(event.type in editHandlers))) {
handlers[event.type](view, event);
}
}
editHandlers.keydown = function(view, event) {
view.shiftKey = event.keyCode == 16 || event.shiftKey;
if (inOrNearComposition(view, event)) {
return;
}
view.domObserver.forceFlush();
view.lastKeyCode = event.keyCode;
view.lastKeyCodeTime = Date.now();
if (result.ios && event.keyCode == 13 && !event.ctrlKey && !event.altKey && !event.metaKey) {
var now2 = Date.now();
view.lastIOSEnter = now2;
view.lastIOSEnterFallbackTimeout = setTimeout(function() {
if (view.lastIOSEnter == now2) {
view.someProp("handleKeyDown", function(f) {
return f(view, keyEvent(13, "Enter"));
});
view.lastIOSEnter = 0;
}
}, 200);
} else if (view.someProp("handleKeyDown", function(f) {
return f(view, event);
}) || captureKeyDown(view, event)) {
event.preventDefault();
} else {
setSelectionOrigin(view, "key");
}
};
editHandlers.keyup = function(view, e) {
if (e.keyCode == 16) {
view.shiftKey = false;
}
};
editHandlers.keypress = function(view, event) {
if (inOrNearComposition(view, event) || !event.charCode || event.ctrlKey && !event.altKey || result.mac && event.metaKey) {
return;
}
if (view.someProp("handleKeyPress", function(f) {
return f(view, event);
})) {
event.preventDefault();
return;
}
var sel = view.state.selection;
if (!(sel instanceof TextSelection) || !sel.$from.sameParent(sel.$to)) {
var text3 = String.fromCharCode(event.charCode);
if (!view.someProp("handleTextInput", function(f) {
return f(view, sel.$from.pos, sel.$to.pos, text3);
})) {
view.dispatch(view.state.tr.insertText(text3).scrollIntoView());
}
event.preventDefault();
}
};
function eventCoords(event) {
return {left: event.clientX, top: event.clientY};
}
function isNear(event, click) {
var dx = click.x - event.clientX, dy = click.y - event.clientY;
return dx * dx + dy * dy < 100;
}
function runHandlerOnContext(view, propName, pos, inside, event) {
if (inside == -1) {
return false;
}
var $pos = view.state.doc.resolve(inside);
var loop = function(i2) {
if (view.someProp(propName, function(f) {
return i2 > $pos.depth ? f(view, pos, $pos.nodeAfter, $pos.before(i2), event, true) : f(view, pos, $pos.node(i2), $pos.before(i2), event, false);
})) {
return {v: true};
}
};
for (var i = $pos.depth + 1; i > 0; i--) {
var returned = loop(i);
if (returned)
return returned.v;
}
return false;
}
function updateSelection(view, selection, origin) {
if (!view.focused) {
view.focus();
}
var tr = view.state.tr.setSelection(selection);
if (origin == "pointer") {
tr.setMeta("pointer", true);
}
view.dispatch(tr);
}
function selectClickedLeaf(view, inside) {
if (inside == -1) {
return false;
}
var $pos = view.state.doc.resolve(inside), node4 = $pos.nodeAfter;
if (node4 && node4.isAtom && NodeSelection.isSelectable(node4)) {
updateSelection(view, new NodeSelection($pos), "pointer");
return true;
}
return false;
}
function selectClickedNode(view, inside) {
if (inside == -1) {
return false;
}
var sel = view.state.selection, selectedNode, selectAt;
if (sel instanceof NodeSelection) {
selectedNode = sel.node;
}
var $pos = view.state.doc.resolve(inside);
for (var i = $pos.depth + 1; i > 0; i--) {
var node4 = i > $pos.depth ? $pos.nodeAfter : $pos.node(i);
if (NodeSelection.isSelectable(node4)) {
if (selectedNode && sel.$from.depth > 0 && i >= sel.$from.depth && $pos.before(sel.$from.depth + 1) == sel.$from.pos) {
selectAt = $pos.before(sel.$from.depth);
} else {
selectAt = $pos.before(i);
}
break;
}
}
if (selectAt != null) {
updateSelection(view, NodeSelection.create(view.state.doc, selectAt), "pointer");
return true;
} else {
return false;
}
}
function handleSingleClick(view, pos, inside, event, selectNode) {
return runHandlerOnContext(view, "handleClickOn", pos, inside, event) || view.someProp("handleClick", function(f) {
return f(view, pos, event);
}) || (selectNode ? selectClickedNode(view, inside) : selectClickedLeaf(view, inside));
}
function handleDoubleClick(view, pos, inside, event) {
return runHandlerOnContext(view, "handleDoubleClickOn", pos, inside, event) || view.someProp("handleDoubleClick", function(f) {
return f(view, pos, event);
});
}
function handleTripleClick(view, pos, inside, event) {
return runHandlerOnContext(view, "handleTripleClickOn", pos, inside, event) || view.someProp("handleTripleClick", function(f) {
return f(view, pos, event);
}) || defaultTripleClick(view, inside);
}
function defaultTripleClick(view, inside) {
var doc2 = view.state.doc;
if (inside == -1) {
if (doc2.inlineContent) {
updateSelection(view, TextSelection.create(doc2, 0, doc2.content.size), "pointer");
return true;
}
return false;
}
var $pos = doc2.resolve(inside);
for (var i = $pos.depth + 1; i > 0; i--) {
var node4 = i > $pos.depth ? $pos.nodeAfter : $pos.node(i);
var nodePos = $pos.before(i);
if (node4.inlineContent) {
updateSelection(view, TextSelection.create(doc2, nodePos + 1, nodePos + 1 + node4.content.size), "pointer");
} else if (NodeSelection.isSelectable(node4)) {
updateSelection(view, NodeSelection.create(doc2, nodePos), "pointer");
} else {
continue;
}
return true;
}
}
function forceDOMFlush(view) {
return endComposition(view);
}
var selectNodeModifier = result.mac ? "metaKey" : "ctrlKey";
handlers.mousedown = function(view, event) {
view.shiftKey = event.shiftKey;
var flushed = forceDOMFlush(view);
var now2 = Date.now(), type = "singleClick";
if (now2 - view.lastClick.time < 500 && isNear(event, view.lastClick) && !event[selectNodeModifier]) {
if (view.lastClick.type == "singleClick") {
type = "doubleClick";
} else if (view.lastClick.type == "doubleClick") {
type = "tripleClick";
}
}
view.lastClick = {time: now2, x: event.clientX, y: event.clientY, type};
var pos = view.posAtCoords(eventCoords(event));
if (!pos) {
return;
}
if (type == "singleClick") {
view.mouseDown = new MouseDown(view, pos, event, flushed);
} else if ((type == "doubleClick" ? handleDoubleClick : handleTripleClick)(view, pos.pos, pos.inside, event)) {
event.preventDefault();
} else {
setSelectionOrigin(view, "pointer");
}
};
var MouseDown = function MouseDown2(view, pos, event, flushed) {
var this$1 = this;
this.view = view;
this.startDoc = view.state.doc;
this.pos = pos;
this.event = event;
this.flushed = flushed;
this.selectNode = event[selectNodeModifier];
this.allowDefault = event.shiftKey;
var targetNode, targetPos;
if (pos.inside > -1) {
targetNode = view.state.doc.nodeAt(pos.inside);
targetPos = pos.inside;
} else {
var $pos = view.state.doc.resolve(pos.pos);
targetNode = $pos.parent;
targetPos = $pos.depth ? $pos.before() : 0;
}
this.mightDrag = null;
var target2 = flushed ? null : event.target;
var targetDesc = target2 ? view.docView.nearestDesc(target2, true) : null;
this.target = targetDesc ? targetDesc.dom : null;
if (targetNode.type.spec.draggable && targetNode.type.spec.selectable !== false || view.state.selection instanceof NodeSelection && targetPos == view.state.selection.from) {
this.mightDrag = {
node: targetNode,
pos: targetPos,
addAttr: this.target && !this.target.draggable,
setUneditable: this.target && result.gecko && !this.target.hasAttribute("contentEditable")
};
}
if (this.target && this.mightDrag && (this.mightDrag.addAttr || this.mightDrag.setUneditable)) {
this.view.domObserver.stop();
if (this.mightDrag.addAttr) {
this.target.draggable = true;
}
if (this.mightDrag.setUneditable) {
setTimeout(function() {
return this$1.target.setAttribute("contentEditable", "false");
}, 20);
}
this.view.domObserver.start();
}
view.root.addEventListener("mouseup", this.up = this.up.bind(this));
view.root.addEventListener("mousemove", this.move = this.move.bind(this));
setSelectionOrigin(view, "pointer");
};
MouseDown.prototype.done = function done() {
this.view.root.removeEventListener("mouseup", this.up);
this.view.root.removeEventListener("mousemove", this.move);
if (this.mightDrag && this.target) {
this.view.domObserver.stop();
if (this.mightDrag.addAttr) {
this.target.removeAttribute("draggable");
}
if (this.mightDrag.setUneditable) {
this.target.removeAttribute("contentEditable");
}
this.view.domObserver.start();
}
this.view.mouseDown = null;
};
MouseDown.prototype.up = function up(event) {
this.done();
if (!this.view.dom.contains(event.target.nodeType == 3 ? event.target.parentNode : event.target)) {
return;
}
var pos = this.pos;
if (this.view.state.doc != this.startDoc) {
pos = this.view.posAtCoords(eventCoords(event));
}
if (this.allowDefault || !pos) {
setSelectionOrigin(this.view, "pointer");
} else if (handleSingleClick(this.view, pos.pos, pos.inside, event, this.selectNode)) {
event.preventDefault();
} else if (this.flushed || result.safari && this.mightDrag && !this.mightDrag.node.isAtom || result.chrome && !(this.view.state.selection instanceof TextSelection) && (pos.pos == this.view.state.selection.from || pos.pos == this.view.state.selection.to)) {
updateSelection(this.view, Selection.near(this.view.state.doc.resolve(pos.pos)), "pointer");
event.preventDefault();
} else {
setSelectionOrigin(this.view, "pointer");
}
};
MouseDown.prototype.move = function move(event) {
if (!this.allowDefault && (Math.abs(this.event.x - event.clientX) > 4 || Math.abs(this.event.y - event.clientY) > 4)) {
this.allowDefault = true;
}
setSelectionOrigin(this.view, "pointer");
};
handlers.touchdown = function(view) {
forceDOMFlush(view);
setSelectionOrigin(view, "pointer");
};
handlers.contextmenu = function(view) {
return forceDOMFlush(view);
};
function inOrNearComposition(view, event) {
if (view.composing) {
return true;
}
if (result.safari && Math.abs(event.timeStamp - view.compositionEndedAt) < 500) {
view.compositionEndedAt = -2e8;
return true;
}
return false;
}
var timeoutComposition = result.android ? 5e3 : -1;
editHandlers.compositionstart = editHandlers.compositionupdate = function(view) {
if (!view.composing) {
view.domObserver.flush();
var state = view.state;
var $pos = state.selection.$from;
if (state.selection.empty && (state.storedMarks || !$pos.textOffset && $pos.parentOffset && $pos.nodeBefore.marks.some(function(m) {
return m.type.spec.inclusive === false;
}))) {
view.markCursor = view.state.storedMarks || $pos.marks();
endComposition(view, true);
view.markCursor = null;
} else {
endComposition(view);
if (result.gecko && state.selection.empty && $pos.parentOffset && !$pos.textOffset && $pos.nodeBefore.marks.length) {
var sel = view.root.getSelection();
for (var node4 = sel.focusNode, offset2 = sel.focusOffset; node4 && node4.nodeType == 1 && offset2 != 0; ) {
var before3 = offset2 < 0 ? node4.lastChild : node4.childNodes[offset2 - 1];
if (!before3) {
break;
}
if (before3.nodeType == 3) {
sel.collapse(before3, before3.nodeValue.length);
break;
} else {
node4 = before3;
offset2 = -1;
}
}
}
}
view.composing = true;
}
scheduleComposeEnd(view, timeoutComposition);
};
editHandlers.compositionend = function(view, event) {
if (view.composing) {
view.composing = false;
view.compositionEndedAt = event.timeStamp;
scheduleComposeEnd(view, 20);
}
};
function scheduleComposeEnd(view, delay2) {
clearTimeout(view.composingTimeout);
if (delay2 > -1) {
view.composingTimeout = setTimeout(function() {
return endComposition(view);
}, delay2);
}
}
function clearComposition(view) {
view.composing = false;
while (view.compositionNodes.length > 0) {
view.compositionNodes.pop().markParentsDirty();
}
}
function endComposition(view, forceUpdate) {
view.domObserver.forceFlush();
clearComposition(view);
if (forceUpdate || view.docView.dirty) {
var sel = selectionFromDOM(view);
if (sel && !sel.eq(view.state.selection)) {
view.dispatch(view.state.tr.setSelection(sel));
} else {
view.updateState(view.state);
}
return true;
}
return false;
}
function captureCopy(view, dom) {
if (!view.dom.parentNode) {
return;
}
var wrap2 = view.dom.parentNode.appendChild(document.createElement("div"));
wrap2.appendChild(dom);
wrap2.style.cssText = "position: fixed; left: -10000px; top: 10px";
var sel = getSelection(), range2 = document.createRange();
range2.selectNodeContents(dom);
view.dom.blur();
sel.removeAllRanges();
sel.addRange(range2);
setTimeout(function() {
if (wrap2.parentNode) {
wrap2.parentNode.removeChild(wrap2);
}
view.focus();
}, 50);
}
var brokenClipboardAPI = result.ie && result.ie_version < 15 || result.ios && result.webkit_version < 604;
handlers.copy = editHandlers.cut = function(view, e) {
var sel = view.state.selection, cut3 = e.type == "cut";
if (sel.empty) {
return;
}
var data = brokenClipboardAPI ? null : e.clipboardData;
var slice5 = sel.content();
var ref2 = serializeForClipboard(view, slice5);
var dom = ref2.dom;
var text3 = ref2.text;
if (data) {
e.preventDefault();
data.clearData();
data.setData("text/html", dom.innerHTML);
data.setData("text/plain", text3);
} else {
captureCopy(view, dom);
}
if (cut3) {
view.dispatch(view.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent", "cut"));
}
};
function sliceSingleNode(slice5) {
return slice5.openStart == 0 && slice5.openEnd == 0 && slice5.content.childCount == 1 ? slice5.content.firstChild : null;
}
function capturePaste(view, e) {
if (!view.dom.parentNode) {
return;
}
var plainText = view.shiftKey || view.state.selection.$from.parent.type.spec.code;
var target2 = view.dom.parentNode.appendChild(document.createElement(plainText ? "textarea" : "div"));
if (!plainText) {
target2.contentEditable = "true";
}
target2.style.cssText = "position: fixed; left: -10000px; top: 10px";
target2.focus();
setTimeout(function() {
view.focus();
if (target2.parentNode) {
target2.parentNode.removeChild(target2);
}
if (plainText) {
doPaste(view, target2.value, null, e);
} else {
doPaste(view, target2.textContent, target2.innerHTML, e);
}
}, 50);
}
function doPaste(view, text3, html2, e) {
var slice5 = parseFromClipboard(view, text3, html2, view.shiftKey, view.state.selection.$from);
if (view.someProp("handlePaste", function(f) {
return f(view, e, slice5 || Slice.empty);
})) {
return true;
}
if (!slice5) {
return false;
}
var singleNode = sliceSingleNode(slice5);
var tr = singleNode ? view.state.tr.replaceSelectionWith(singleNode, view.shiftKey) : view.state.tr.replaceSelection(slice5);
view.dispatch(tr.scrollIntoView().setMeta("paste", true).setMeta("uiEvent", "paste"));
return true;
}
editHandlers.paste = function(view, e) {
var data = brokenClipboardAPI ? null : e.clipboardData;
if (data && doPaste(view, data.getData("text/plain"), data.getData("text/html"), e)) {
e.preventDefault();
} else {
capturePaste(view, e);
}
};
var Dragging = function Dragging2(slice5, move2) {
this.slice = slice5;
this.move = move2;
};
var dragCopyModifier = result.mac ? "altKey" : "ctrlKey";
handlers.dragstart = function(view, e) {
var mouseDown = view.mouseDown;
if (mouseDown) {
mouseDown.done();
}
if (!e.dataTransfer) {
return;
}
var sel = view.state.selection;
var pos = sel.empty ? null : view.posAtCoords(eventCoords(e));
if (pos && pos.pos >= sel.from && pos.pos <= (sel instanceof NodeSelection ? sel.to - 1 : sel.to))
;
else if (mouseDown && mouseDown.mightDrag) {
view.dispatch(view.state.tr.setSelection(NodeSelection.create(view.state.doc, mouseDown.mightDrag.pos)));
} else if (e.target && e.target.nodeType == 1) {
var desc = view.docView.nearestDesc(e.target, true);
if (!desc || !desc.node.type.spec.draggable || desc == view.docView) {
return;
}
view.dispatch(view.state.tr.setSelection(NodeSelection.create(view.state.doc, desc.posBefore)));
}
var slice5 = view.state.selection.content();
var ref2 = serializeForClipboard(view, slice5);
var dom = ref2.dom;
var text3 = ref2.text;
e.dataTransfer.clearData();
e.dataTransfer.setData(brokenClipboardAPI ? "Text" : "text/html", dom.innerHTML);
if (!brokenClipboardAPI) {
e.dataTransfer.setData("text/plain", text3);
}
view.dragging = new Dragging(slice5, !e[dragCopyModifier]);
};
handlers.dragend = function(view) {
var dragging = view.dragging;
window.setTimeout(function() {
if (view.dragging == dragging) {
view.dragging = null;
}
}, 50);
};
editHandlers.dragover = editHandlers.dragenter = function(_2, e) {
return e.preventDefault();
};
editHandlers.drop = function(view, e) {
var dragging = view.dragging;
view.dragging = null;
if (!e.dataTransfer) {
return;
}
var eventPos = view.posAtCoords(eventCoords(e));
if (!eventPos) {
return;
}
var $mouse = view.state.doc.resolve(eventPos.pos);
if (!$mouse) {
return;
}
var slice5 = dragging && dragging.slice || parseFromClipboard(view, e.dataTransfer.getData(brokenClipboardAPI ? "Text" : "text/plain"), brokenClipboardAPI ? null : e.dataTransfer.getData("text/html"), false, $mouse);
var move2 = dragging && !e[dragCopyModifier];
if (view.someProp("handleDrop", function(f) {
return f(view, e, slice5 || Slice.empty, move2);
})) {
e.preventDefault();
return;
}
if (!slice5) {
return;
}
e.preventDefault();
var insertPos = slice5 ? dropPoint(view.state.doc, $mouse.pos, slice5) : $mouse.pos;
if (insertPos == null) {
insertPos = $mouse.pos;
}
var tr = view.state.tr;
if (move2) {
tr.deleteSelection();
}
var pos = tr.mapping.map(insertPos);
var isNode = slice5.openStart == 0 && slice5.openEnd == 0 && slice5.content.childCount == 1;
var beforeInsert = tr.doc;
if (isNode) {
tr.replaceRangeWith(pos, pos, slice5.content.firstChild);
} else {
tr.replaceRange(pos, pos, slice5);
}
if (tr.doc.eq(beforeInsert)) {
return;
}
var $pos = tr.doc.resolve(pos);
if (isNode && NodeSelection.isSelectable(slice5.content.firstChild) && $pos.nodeAfter && $pos.nodeAfter.sameMarkup(slice5.content.firstChild)) {
tr.setSelection(new NodeSelection($pos));
} else {
var end2 = tr.mapping.map(insertPos);
tr.mapping.maps[tr.mapping.maps.length - 1].forEach(function(_from, _to, _newFrom, newTo) {
return end2 = newTo;
});
tr.setSelection(selectionBetween(view, $pos, tr.doc.resolve(end2)));
}
view.focus();
view.dispatch(tr.setMeta("uiEvent", "drop"));
};
handlers.focus = function(view) {
if (!view.focused) {
view.domObserver.stop();
view.dom.classList.add("ProseMirror-focused");
view.domObserver.start();
view.focused = true;
setTimeout(function() {
if (view.docView && view.hasFocus() && !view.domObserver.currentSelection.eq(view.root.getSelection())) {
selectionToDOM(view);
}
}, 20);
}
};
handlers.blur = function(view) {
if (view.focused) {
view.domObserver.stop();
view.dom.classList.remove("ProseMirror-focused");
view.domObserver.start();
view.domObserver.currentSelection.set({});
view.focused = false;
}
};
handlers.beforeinput = function(view, event) {
if (result.chrome && result.android && event.inputType == "deleteContentBackward") {
var domChangeCount = view.domChangeCount;
setTimeout(function() {
if (view.domChangeCount != domChangeCount) {
return;
}
view.dom.blur();
view.focus();
if (view.someProp("handleKeyDown", function(f) {
return f(view, keyEvent(8, "Backspace"));
})) {
return;
}
var ref2 = view.state.selection;
var $cursor = ref2.$cursor;
if ($cursor && $cursor.pos > 0) {
view.dispatch(view.state.tr.delete($cursor.pos - 1, $cursor.pos).scrollIntoView());
}
}, 50);
}
};
for (var prop in editHandlers) {
handlers[prop] = editHandlers[prop];
}
function compareObjs(a, b) {
if (a == b) {
return true;
}
for (var p in a) {
if (a[p] !== b[p]) {
return false;
}
}
for (var p$1 in b) {
if (!(p$1 in a)) {
return false;
}
}
return true;
}
var WidgetType = function WidgetType2(toDOM, spec) {
this.spec = spec || noSpec;
this.side = this.spec.side || 0;
this.toDOM = toDOM;
};
WidgetType.prototype.map = function map8(mapping, span, offset2, oldOffset) {
var ref2 = mapping.mapResult(span.from + oldOffset, this.side < 0 ? -1 : 1);
var pos = ref2.pos;
var deleted = ref2.deleted;
return deleted ? null : new Decoration(pos - offset2, pos - offset2, this);
};
WidgetType.prototype.valid = function valid() {
return true;
};
WidgetType.prototype.eq = function eq7(other) {
return this == other || other instanceof WidgetType && (this.spec.key && this.spec.key == other.spec.key || this.toDOM == other.toDOM && compareObjs(this.spec, other.spec));
};
var InlineType = function InlineType2(attrs2, spec) {
this.spec = spec || noSpec;
this.attrs = attrs2;
};
InlineType.prototype.map = function map9(mapping, span, offset2, oldOffset) {
var from4 = mapping.map(span.from + oldOffset, this.spec.inclusiveStart ? -1 : 1) - offset2;
var to = mapping.map(span.to + oldOffset, this.spec.inclusiveEnd ? 1 : -1) - offset2;
return from4 >= to ? null : new Decoration(from4, to, this);
};
InlineType.prototype.valid = function valid2(_2, span) {
return span.from < span.to;
};
InlineType.prototype.eq = function eq8(other) {
return this == other || other instanceof InlineType && compareObjs(this.attrs, other.attrs) && compareObjs(this.spec, other.spec);
};
InlineType.is = function is(span) {
return span.type instanceof InlineType;
};
var NodeType2 = function NodeType3(attrs2, spec) {
this.spec = spec || noSpec;
this.attrs = attrs2;
};
NodeType2.prototype.map = function map10(mapping, span, offset2, oldOffset) {
var from4 = mapping.mapResult(span.from + oldOffset, 1);
if (from4.deleted) {
return null;
}
var to = mapping.mapResult(span.to + oldOffset, -1);
if (to.deleted || to.pos <= from4.pos) {
return null;
}
return new Decoration(from4.pos - offset2, to.pos - offset2, this);
};
NodeType2.prototype.valid = function valid3(node4, span) {
var ref2 = node4.content.findIndex(span.from);
var index3 = ref2.index;
var offset2 = ref2.offset;
return offset2 == span.from && offset2 + node4.child(index3).nodeSize == span.to;
};
NodeType2.prototype.eq = function eq9(other) {
return this == other || other instanceof NodeType2 && compareObjs(this.attrs, other.attrs) && compareObjs(this.spec, other.spec);
};
var Decoration = function Decoration2(from4, to, type) {
this.from = from4;
this.to = to;
this.type = type;
};
var prototypeAccessors$1 = {spec: {configurable: true}, inline: {configurable: true}};
Decoration.prototype.copy = function copy4(from4, to) {
return new Decoration(from4, to, this.type);
};
Decoration.prototype.eq = function eq10(other, offset2) {
if (offset2 === void 0)
offset2 = 0;
return this.type.eq(other.type) && this.from + offset2 == other.from && this.to + offset2 == other.to;
};
Decoration.prototype.map = function map11(mapping, offset2, oldOffset) {
return this.type.map(mapping, this, offset2, oldOffset);
};
Decoration.widget = function widget(pos, toDOM, spec) {
return new Decoration(pos, pos, new WidgetType(toDOM, spec));
};
Decoration.inline = function inline(from4, to, attrs2, spec) {
return new Decoration(from4, to, new InlineType(attrs2, spec));
};
Decoration.node = function node3(from4, to, attrs2, spec) {
return new Decoration(from4, to, new NodeType2(attrs2, spec));
};
prototypeAccessors$1.spec.get = function() {
return this.type.spec;
};
prototypeAccessors$1.inline.get = function() {
return this.type instanceof InlineType;
};
Object.defineProperties(Decoration.prototype, prototypeAccessors$1);
var none = [], noSpec = {};
var DecorationSet = function DecorationSet2(local, children) {
this.local = local && local.length ? local : none;
this.children = children && children.length ? children : none;
};
DecorationSet.create = function create5(doc2, decorations) {
return decorations.length ? buildTree(decorations, doc2, 0, noSpec) : empty;
};
DecorationSet.prototype.find = function find(start3, end2, predicate) {
var result2 = [];
this.findInner(start3 == null ? 0 : start3, end2 == null ? 1e9 : end2, result2, 0, predicate);
return result2;
};
DecorationSet.prototype.findInner = function findInner(start3, end2, result2, offset2, predicate) {
for (var i = 0; i < this.local.length; i++) {
var span = this.local[i];
if (span.from <= end2 && span.to >= start3 && (!predicate || predicate(span.spec))) {
result2.push(span.copy(span.from + offset2, span.to + offset2));
}
}
for (var i$1 = 0; i$1 < this.children.length; i$1 += 3) {
if (this.children[i$1] < end2 && this.children[i$1 + 1] > start3) {
var childOff = this.children[i$1] + 1;
this.children[i$1 + 2].findInner(start3 - childOff, end2 - childOff, result2, offset2 + childOff, predicate);
}
}
};
DecorationSet.prototype.map = function map12(mapping, doc2, options) {
if (this == empty || mapping.maps.length == 0) {
return this;
}
return this.mapInner(mapping, doc2, 0, 0, options || noSpec);
};
DecorationSet.prototype.mapInner = function mapInner(mapping, node4, offset2, oldOffset, options) {
var newLocal;
for (var i = 0; i < this.local.length; i++) {
var mapped = this.local[i].map(mapping, offset2, oldOffset);
if (mapped && mapped.type.valid(node4, mapped)) {
(newLocal || (newLocal = [])).push(mapped);
} else if (options.onRemove) {
options.onRemove(this.local[i].spec);
}
}
if (this.children.length) {
return mapChildren(this.children, newLocal, mapping, node4, offset2, oldOffset, options);
} else {
return newLocal ? new DecorationSet(newLocal.sort(byPos)) : empty;
}
};
DecorationSet.prototype.add = function add2(doc2, decorations) {
if (!decorations.length) {
return this;
}
if (this == empty) {
return DecorationSet.create(doc2, decorations);
}
return this.addInner(doc2, decorations, 0);
};
DecorationSet.prototype.addInner = function addInner(doc2, decorations, offset2) {
var this$1 = this;
var children, childIndex = 0;
doc2.forEach(function(childNode, childOffset) {
var baseOffset = childOffset + offset2, found2;
if (!(found2 = takeSpansForNode(decorations, childNode, baseOffset))) {
return;
}
if (!children) {
children = this$1.children.slice();
}
while (childIndex < children.length && children[childIndex] < childOffset) {
childIndex += 3;
}
if (children[childIndex] == childOffset) {
children[childIndex + 2] = children[childIndex + 2].addInner(childNode, found2, baseOffset + 1);
} else {
children.splice(childIndex, 0, childOffset, childOffset + childNode.nodeSize, buildTree(found2, childNode, baseOffset + 1, noSpec));
}
childIndex += 3;
});
var local = moveSpans(childIndex ? withoutNulls(decorations) : decorations, -offset2);
for (var i = 0; i < local.length; i++) {
if (!local[i].type.valid(doc2, local[i])) {
local.splice(i--, 1);
}
}
return new DecorationSet(local.length ? this.local.concat(local).sort(byPos) : this.local, children || this.children);
};
DecorationSet.prototype.remove = function remove2(decorations) {
if (decorations.length == 0 || this == empty) {
return this;
}
return this.removeInner(decorations, 0);
};
DecorationSet.prototype.removeInner = function removeInner(decorations, offset2) {
var children = this.children, local = this.local;
for (var i = 0; i < children.length; i += 3) {
var found2 = void 0, from4 = children[i] + offset2, to = children[i + 1] + offset2;
for (var j = 0, span = void 0; j < decorations.length; j++) {
if (span = decorations[j]) {
if (span.from > from4 && span.to < to) {
decorations[j] = null;
(found2 || (found2 = [])).push(span);
}
}
}
if (!found2) {
continue;
}
if (children == this.children) {
children = this.children.slice();
}
var removed = children[i + 2].removeInner(found2, from4 + 1);
if (removed != empty) {
children[i + 2] = removed;
} else {
children.splice(i, 3);
i -= 3;
}
}
if (local.length) {
for (var i$1 = 0, span$1 = void 0; i$1 < decorations.length; i$1++) {
if (span$1 = decorations[i$1]) {
for (var j$1 = 0; j$1 < local.length; j$1++) {
if (local[j$1].eq(span$1, offset2)) {
if (local == this.local) {
local = this.local.slice();
}
local.splice(j$1--, 1);
}
}
}
}
}
if (children == this.children && local == this.local) {
return this;
}
return local.length || children.length ? new DecorationSet(local, children) : empty;
};
DecorationSet.prototype.forChild = function forChild(offset2, node4) {
if (this == empty) {
return this;
}
if (node4.isLeaf) {
return DecorationSet.empty;
}
var child3, local;
for (var i = 0; i < this.children.length; i += 3) {
if (this.children[i] >= offset2) {
if (this.children[i] == offset2) {
child3 = this.children[i + 2];
}
break;
}
}
var start3 = offset2 + 1, end2 = start3 + node4.content.size;
for (var i$1 = 0; i$1 < this.local.length; i$1++) {
var dec = this.local[i$1];
if (dec.from < end2 && dec.to > start3 && dec.type instanceof InlineType) {
var from4 = Math.max(start3, dec.from) - start3, to = Math.min(end2, dec.to) - start3;
if (from4 < to) {
(local || (local = [])).push(dec.copy(from4, to));
}
}
}
if (local) {
var localSet = new DecorationSet(local.sort(byPos));
return child3 ? new DecorationGroup([localSet, child3]) : localSet;
}
return child3 || empty;
};
DecorationSet.prototype.eq = function eq11(other) {
if (this == other) {
return true;
}
if (!(other instanceof DecorationSet) || this.local.length != other.local.length || this.children.length != other.children.length) {
return false;
}
for (var i = 0; i < this.local.length; i++) {
if (!this.local[i].eq(other.local[i])) {
return false;
}
}
for (var i$1 = 0; i$1 < this.children.length; i$1 += 3) {
if (this.children[i$1] != other.children[i$1] || this.children[i$1 + 1] != other.children[i$1 + 1] || !this.children[i$1 + 2].eq(other.children[i$1 + 2])) {
return false;
}
}
return true;
};
DecorationSet.prototype.locals = function locals(node4) {
return removeOverlap(this.localsInner(node4));
};
DecorationSet.prototype.localsInner = function localsInner(node4) {
if (this == empty) {
return none;
}
if (node4.inlineContent || !this.local.some(InlineType.is)) {
return this.local;
}
var result2 = [];
for (var i = 0; i < this.local.length; i++) {
if (!(this.local[i].type instanceof InlineType)) {
result2.push(this.local[i]);
}
}
return result2;
};
var empty = new DecorationSet();
DecorationSet.empty = empty;
DecorationSet.removeOverlap = removeOverlap;
var DecorationGroup = function DecorationGroup2(members) {
this.members = members;
};
DecorationGroup.prototype.forChild = function forChild2(offset2, child3) {
if (child3.isLeaf) {
return DecorationSet.empty;
}
var found2 = [];
for (var i = 0; i < this.members.length; i++) {
var result2 = this.members[i].forChild(offset2, child3);
if (result2 == empty) {
continue;
}
if (result2 instanceof DecorationGroup) {
found2 = found2.concat(result2.members);
} else {
found2.push(result2);
}
}
return DecorationGroup.from(found2);
};
DecorationGroup.prototype.eq = function eq12(other) {
if (!(other instanceof DecorationGroup) || other.members.length != this.members.length) {
return false;
}
for (var i = 0; i < this.members.length; i++) {
if (!this.members[i].eq(other.members[i])) {
return false;
}
}
return true;
};
DecorationGroup.prototype.locals = function locals2(node4) {
var result2, sorted = true;
for (var i = 0; i < this.members.length; i++) {
var locals3 = this.members[i].localsInner(node4);
if (!locals3.length) {
continue;
}
if (!result2) {
result2 = locals3;
} else {
if (sorted) {
result2 = result2.slice();
sorted = false;
}
for (var j = 0; j < locals3.length; j++) {
result2.push(locals3[j]);
}
}
}
return result2 ? removeOverlap(sorted ? result2 : result2.sort(byPos)) : none;
};
DecorationGroup.from = function from2(members) {
switch (members.length) {
case 0:
return empty;
case 1:
return members[0];
default:
return new DecorationGroup(members);
}
};
function mapChildren(oldChildren, newLocal, mapping, node4, offset2, oldOffset, options) {
var children = oldChildren.slice();
var shift2 = function(oldStart, oldEnd, newStart, newEnd) {
for (var i2 = 0; i2 < children.length; i2 += 3) {
var end2 = children[i2 + 1], dSize = void 0;
if (end2 == -1 || oldStart > end2 + oldOffset) {
continue;
}
if (oldEnd >= children[i2] + oldOffset) {
children[i2 + 1] = -1;
} else if (newStart >= offset2 && (dSize = newEnd - newStart - (oldEnd - oldStart))) {
children[i2] += dSize;
children[i2 + 1] += dSize;
}
}
};
for (var i = 0; i < mapping.maps.length; i++) {
mapping.maps[i].forEach(shift2);
}
var mustRebuild = false;
for (var i$1 = 0; i$1 < children.length; i$1 += 3) {
if (children[i$1 + 1] == -1) {
var from4 = mapping.map(oldChildren[i$1] + oldOffset), fromLocal = from4 - offset2;
if (fromLocal < 0 || fromLocal >= node4.content.size) {
mustRebuild = true;
continue;
}
var to = mapping.map(oldChildren[i$1 + 1] + oldOffset, -1), toLocal = to - offset2;
var ref2 = node4.content.findIndex(fromLocal);
var index3 = ref2.index;
var childOffset = ref2.offset;
var childNode = node4.maybeChild(index3);
if (childNode && childOffset == fromLocal && childOffset + childNode.nodeSize == toLocal) {
var mapped = children[i$1 + 2].mapInner(mapping, childNode, from4 + 1, oldChildren[i$1] + oldOffset + 1, options);
if (mapped != empty) {
children[i$1] = fromLocal;
children[i$1 + 1] = toLocal;
children[i$1 + 2] = mapped;
} else {
children[i$1 + 1] = -2;
mustRebuild = true;
}
} else {
mustRebuild = true;
}
}
}
if (mustRebuild) {
var decorations = mapAndGatherRemainingDecorations(children, oldChildren, newLocal || [], mapping, offset2, oldOffset, options);
var built = buildTree(decorations, node4, 0, options);
newLocal = built.local;
for (var i$2 = 0; i$2 < children.length; i$2 += 3) {
if (children[i$2 + 1] < 0) {
children.splice(i$2, 3);
i$2 -= 3;
}
}
for (var i$3 = 0, j = 0; i$3 < built.children.length; i$3 += 3) {
var from$1 = built.children[i$3];
while (j < children.length && children[j] < from$1) {
j += 3;
}
children.splice(j, 0, built.children[i$3], built.children[i$3 + 1], built.children[i$3 + 2]);
}
}
return new DecorationSet(newLocal && newLocal.sort(byPos), children);
}
function moveSpans(spans, offset2) {
if (!offset2 || !spans.length) {
return spans;
}
var result2 = [];
for (var i = 0; i < spans.length; i++) {
var span = spans[i];
result2.push(new Decoration(span.from + offset2, span.to + offset2, span.type));
}
return result2;
}
function mapAndGatherRemainingDecorations(children, oldChildren, decorations, mapping, offset2, oldOffset, options) {
function gather(set3, oldOffset2) {
for (var i2 = 0; i2 < set3.local.length; i2++) {
var mapped = set3.local[i2].map(mapping, offset2, oldOffset2);
if (mapped) {
decorations.push(mapped);
} else if (options.onRemove) {
options.onRemove(set3.local[i2].spec);
}
}
for (var i$1 = 0; i$1 < set3.children.length; i$1 += 3) {
gather(set3.children[i$1 + 2], set3.children[i$1] + oldOffset2 + 1);
}
}
for (var i = 0; i < children.length; i += 3) {
if (children[i + 1] == -1) {
gather(children[i + 2], oldChildren[i] + oldOffset + 1);
}
}
return decorations;
}
function takeSpansForNode(spans, node4, offset2) {
if (node4.isLeaf) {
return null;
}
var end2 = offset2 + node4.nodeSize, found2 = null;
for (var i = 0, span = void 0; i < spans.length; i++) {
if ((span = spans[i]) && span.from > offset2 && span.to < end2) {
(found2 || (found2 = [])).push(span);
spans[i] = null;
}
}
return found2;
}
function withoutNulls(array) {
var result2 = [];
for (var i = 0; i < array.length; i++) {
if (array[i] != null) {
result2.push(array[i]);
}
}
return result2;
}
function buildTree(spans, node4, offset2, options) {
var children = [], hasNulls = false;
node4.forEach(function(childNode, localStart) {
var found2 = takeSpansForNode(spans, childNode, localStart + offset2);
if (found2) {
hasNulls = true;
var subtree = buildTree(found2, childNode, offset2 + localStart + 1, options);
if (subtree != empty) {
children.push(localStart, localStart + childNode.nodeSize, subtree);
}
}
});
var locals3 = moveSpans(hasNulls ? withoutNulls(spans) : spans, -offset2).sort(byPos);
for (var i = 0; i < locals3.length; i++) {
if (!locals3[i].type.valid(node4, locals3[i])) {
if (options.onRemove) {
options.onRemove(locals3[i].spec);
}
locals3.splice(i--, 1);
}
}
return locals3.length || children.length ? new DecorationSet(locals3, children) : empty;
}
function byPos(a, b) {
return a.from - b.from || a.to - b.to;
}
function removeOverlap(spans) {
var working = spans;
for (var i = 0; i < working.length - 1; i++) {
var span = working[i];
if (span.from != span.to) {
for (var j = i + 1; j < working.length; j++) {
var next2 = working[j];
if (next2.from == span.from) {
if (next2.to != span.to) {
if (working == spans) {
working = spans.slice();
}
working[j] = next2.copy(next2.from, span.to);
insertAhead(working, j + 1, next2.copy(span.to, next2.to));
}
continue;
} else {
if (next2.from < span.to) {
if (working == spans) {
working = spans.slice();
}
working[i] = span.copy(span.from, next2.from);
insertAhead(working, j, span.copy(next2.from, span.to));
}
break;
}
}
}
}
return working;
}
function insertAhead(array, i, deco) {
while (i < array.length && byPos(deco, array[i]) > 0) {
i++;
}
array.splice(i, 0, deco);
}
function viewDecorations(view) {
var found2 = [];
view.someProp("decorations", function(f) {
var result2 = f(view.state);
if (result2 && result2 != empty) {
found2.push(result2);
}
});
if (view.cursorWrapper) {
found2.push(DecorationSet.create(view.state.doc, [view.cursorWrapper.deco]));
}
return DecorationGroup.from(found2);
}
var EditorView = function EditorView2(place, props2) {
this._props = props2;
this.state = props2.state;
this.dispatch = this.dispatch.bind(this);
this._root = null;
this.focused = false;
this.trackWrites = null;
this.dom = place && place.mount || document.createElement("div");
if (place) {
if (place.appendChild) {
place.appendChild(this.dom);
} else if (place.apply) {
place(this.dom);
} else if (place.mount) {
this.mounted = true;
}
}
this.editable = getEditable(this);
this.markCursor = null;
this.cursorWrapper = null;
updateCursorWrapper(this);
this.nodeViews = buildNodeViews(this);
this.docView = docViewDesc(this.state.doc, computeDocDeco(this), viewDecorations(this), this.dom, this);
this.lastSelectedViewDesc = null;
this.dragging = null;
initInput(this);
this.pluginViews = [];
this.updatePluginViews();
};
var prototypeAccessors$2 = {props: {configurable: true}, root: {configurable: true}};
prototypeAccessors$2.props.get = function() {
if (this._props.state != this.state) {
var prev = this._props;
this._props = {};
for (var name in prev) {
this._props[name] = prev[name];
}
this._props.state = this.state;
}
return this._props;
};
EditorView.prototype.update = function update4(props2) {
if (props2.handleDOMEvents != this._props.handleDOMEvents) {
ensureListeners(this);
}
this._props = props2;
this.updateStateInner(props2.state, true);
};
EditorView.prototype.setProps = function setProps(props2) {
var updated2 = {};
for (var name in this._props) {
updated2[name] = this._props[name];
}
updated2.state = this.state;
for (var name$1 in props2) {
updated2[name$1] = props2[name$1];
}
this.update(updated2);
};
EditorView.prototype.updateState = function updateState(state) {
this.updateStateInner(state, this.state.plugins != state.plugins);
};
EditorView.prototype.updateStateInner = function updateStateInner(state, reconfigured) {
var this$1 = this;
var prev = this.state, redraw = false, updateSel = false;
if (state.storedMarks && this.composing) {
clearComposition(this);
updateSel = true;
}
this.state = state;
if (reconfigured) {
var nodeViews = buildNodeViews(this);
if (changedNodeViews(nodeViews, this.nodeViews)) {
this.nodeViews = nodeViews;
redraw = true;
}
ensureListeners(this);
}
this.editable = getEditable(this);
updateCursorWrapper(this);
var innerDeco = viewDecorations(this), outerDeco = computeDocDeco(this);
var scroll = reconfigured ? "reset" : state.scrollToSelection > prev.scrollToSelection ? "to selection" : "preserve";
var updateDoc = redraw || !this.docView.matchesNode(state.doc, outerDeco, innerDeco);
if (updateDoc || !state.selection.eq(prev.selection)) {
updateSel = true;
}
var oldScrollPos = scroll == "preserve" && updateSel && this.dom.style.overflowAnchor == null && storeScrollPos(this);
if (updateSel) {
this.domObserver.stop();
var forceSelUpdate = updateDoc && (result.ie || result.chrome) && !this.composing && !prev.selection.empty && !state.selection.empty && selectionContextChanged(prev.selection, state.selection);
if (updateDoc) {
var chromeKludge = result.chrome ? this.trackWrites = this.root.getSelection().focusNode : null;
if (redraw || !this.docView.update(state.doc, outerDeco, innerDeco, this)) {
this.docView.updateOuterDeco([]);
this.docView.destroy();
this.docView = docViewDesc(state.doc, outerDeco, innerDeco, this.dom, this);
}
if (chromeKludge && !this.trackWrites) {
forceSelUpdate = true;
}
}
if (forceSelUpdate || !(this.mouseDown && this.domObserver.currentSelection.eq(this.root.getSelection()) && anchorInRightPlace(this))) {
selectionToDOM(this, forceSelUpdate);
} else {
syncNodeSelection(this, state.selection);
this.domObserver.setCurSelection();
}
this.domObserver.start();
}
this.updatePluginViews(prev);
if (scroll == "reset") {
this.dom.scrollTop = 0;
} else if (scroll == "to selection") {
var startDOM = this.root.getSelection().focusNode;
if (this.someProp("handleScrollToSelection", function(f) {
return f(this$1);
}))
;
else if (state.selection instanceof NodeSelection) {
scrollRectIntoView(this, this.docView.domAfterPos(state.selection.from).getBoundingClientRect(), startDOM);
} else {
scrollRectIntoView(this, this.coordsAtPos(state.selection.head, 1), startDOM);
}
} else if (oldScrollPos) {
resetScrollPos(oldScrollPos);
}
};
EditorView.prototype.destroyPluginViews = function destroyPluginViews() {
var view;
while (view = this.pluginViews.pop()) {
if (view.destroy) {
view.destroy();
}
}
};
EditorView.prototype.updatePluginViews = function updatePluginViews(prevState) {
if (!prevState || prevState.plugins != this.state.plugins) {
this.destroyPluginViews();
for (var i = 0; i < this.state.plugins.length; i++) {
var plugin = this.state.plugins[i];
if (plugin.spec.view) {
this.pluginViews.push(plugin.spec.view(this));
}
}
} else {
for (var i$1 = 0; i$1 < this.pluginViews.length; i$1++) {
var pluginView = this.pluginViews[i$1];
if (pluginView.update) {
pluginView.update(this, prevState);
}
}
}
};
EditorView.prototype.someProp = function someProp(propName, f) {
var prop = this._props && this._props[propName], value;
if (prop != null && (value = f ? f(prop) : prop)) {
return value;
}
var plugins2 = this.state.plugins;
if (plugins2) {
for (var i = 0; i < plugins2.length; i++) {
var prop$1 = plugins2[i].props[propName];
if (prop$1 != null && (value = f ? f(prop$1) : prop$1)) {
return value;
}
}
}
};
EditorView.prototype.hasFocus = function hasFocus() {
return this.root.activeElement == this.dom;
};
EditorView.prototype.focus = function focus() {
this.domObserver.stop();
if (this.editable) {
focusPreventScroll(this.dom);
}
selectionToDOM(this);
this.domObserver.start();
};
prototypeAccessors$2.root.get = function() {
var cached2 = this._root;
if (cached2 == null) {
for (var search = this.dom.parentNode; search; search = search.parentNode) {
if (search.nodeType == 9 || search.nodeType == 11 && search.host) {
if (!search.getSelection) {
Object.getPrototypeOf(search).getSelection = function() {
return document.getSelection();
};
}
return this._root = search;
}
}
}
return cached2 || document;
};
EditorView.prototype.posAtCoords = function posAtCoords$1(coords) {
return posAtCoords(this, coords);
};
EditorView.prototype.coordsAtPos = function coordsAtPos$1$1(pos, side) {
if (side === void 0)
side = 1;
return coordsAtPos$1(this, pos, side);
};
EditorView.prototype.domAtPos = function domAtPos(pos, side) {
if (side === void 0)
side = 0;
return this.docView.domFromPos(pos, side);
};
EditorView.prototype.nodeDOM = function nodeDOM(pos) {
var desc = this.docView.descAt(pos);
return desc ? desc.nodeDOM : null;
};
EditorView.prototype.posAtDOM = function posAtDOM(node4, offset2, bias) {
if (bias === void 0)
bias = -1;
var pos = this.docView.posFromDOM(node4, offset2, bias);
if (pos == null) {
throw new RangeError("DOM position not inside the editor");
}
return pos;
};
EditorView.prototype.endOfTextblock = function endOfTextblock$1(dir, state) {
return endOfTextblock(this, state || this.state, dir);
};
EditorView.prototype.destroy = function destroy4() {
if (!this.docView) {
return;
}
destroyInput(this);
this.destroyPluginViews();
if (this.mounted) {
this.docView.update(this.state.doc, [], viewDecorations(this), this);
this.dom.textContent = "";
} else if (this.dom.parentNode) {
this.dom.parentNode.removeChild(this.dom);
}
this.docView.destroy();
this.docView = null;
};
EditorView.prototype.dispatchEvent = function dispatchEvent$1$1(event) {
return dispatchEvent$1(this, event);
};
EditorView.prototype.dispatch = function dispatch(tr) {
var dispatchTransaction = this._props.dispatchTransaction;
if (dispatchTransaction) {
dispatchTransaction.call(this, tr);
} else {
this.updateState(this.state.apply(tr));
}
};
Object.defineProperties(EditorView.prototype, prototypeAccessors$2);
function computeDocDeco(view) {
var attrs2 = Object.create(null);
attrs2.class = "ProseMirror";
attrs2.contenteditable = String(view.editable);
view.someProp("attributes", function(value) {
if (typeof value == "function") {
value = value(view.state);
}
if (value) {
for (var attr in value) {
if (attr == "class") {
attrs2.class += " " + value[attr];
} else if (!attrs2[attr] && attr != "contenteditable" && attr != "nodeName") {
attrs2[attr] = String(value[attr]);
}
}
}
});
return [Decoration.node(0, view.state.doc.content.size, attrs2)];
}
function updateCursorWrapper(view) {
if (view.markCursor) {
var dom = document.createElement("img");
dom.setAttribute("mark-placeholder", "true");
view.cursorWrapper = {dom, deco: Decoration.widget(view.state.selection.head, dom, {raw: true, marks: view.markCursor})};
} else {
view.cursorWrapper = null;
}
}
function getEditable(view) {
return !view.someProp("editable", function(value) {
return value(view.state) === false;
});
}
function selectionContextChanged(sel1, sel2) {
var depth = Math.min(sel1.$anchor.sharedDepth(sel1.head), sel2.$anchor.sharedDepth(sel2.head));
return sel1.$anchor.start(depth) != sel2.$anchor.start(depth);
}
function buildNodeViews(view) {
var result2 = {};
view.someProp("nodeViews", function(obj) {
for (var prop in obj) {
if (!Object.prototype.hasOwnProperty.call(result2, prop)) {
result2[prop] = obj[prop];
}
}
});
return result2;
}
function changedNodeViews(a, b) {
var nA = 0, nB = 0;
for (var prop in a) {
if (a[prop] != b[prop]) {
return true;
}
nA++;
}
for (var _2 in b) {
nB++;
}
return nA != nB;
}
function dropCursor(options) {
if (options === void 0)
options = {};
return new Plugin({
view: function view(editorView) {
return new DropCursorView(editorView, options);
}
});
}
var DropCursorView = function DropCursorView2(editorView, options) {
var this$1 = this;
this.editorView = editorView;
this.width = options.width || 1;
this.color = options.color || "black";
this.class = options.class;
this.cursorPos = null;
this.element = null;
this.timeout = null;
this.handlers = ["dragover", "dragend", "drop", "dragleave"].map(function(name) {
var handler = function(e) {
return this$1[name](e);
};
editorView.dom.addEventListener(name, handler);
return {name, handler};
});
};
DropCursorView.prototype.destroy = function destroy5() {
var this$1 = this;
this.handlers.forEach(function(ref2) {
var name = ref2.name;
var handler = ref2.handler;
return this$1.editorView.dom.removeEventListener(name, handler);
});
};
DropCursorView.prototype.update = function update5(editorView, prevState) {
if (this.cursorPos != null && prevState.doc != editorView.state.doc) {
this.updateOverlay();
}
};
DropCursorView.prototype.setCursor = function setCursor(pos) {
if (pos == this.cursorPos) {
return;
}
this.cursorPos = pos;
if (pos == null) {
this.element.parentNode.removeChild(this.element);
this.element = null;
} else {
this.updateOverlay();
}
};
DropCursorView.prototype.updateOverlay = function updateOverlay() {
var $pos = this.editorView.state.doc.resolve(this.cursorPos), rect;
if (!$pos.parent.inlineContent) {
var before3 = $pos.nodeBefore, after3 = $pos.nodeAfter;
if (before3 || after3) {
var nodeRect = this.editorView.nodeDOM(this.cursorPos - (before3 ? before3.nodeSize : 0)).getBoundingClientRect();
var top = before3 ? nodeRect.bottom : nodeRect.top;
if (before3 && after3) {
top = (top + this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top) / 2;
}
rect = {left: nodeRect.left, right: nodeRect.right, top: top - this.width / 2, bottom: top + this.width / 2};
}
}
if (!rect) {
var coords = this.editorView.coordsAtPos(this.cursorPos);
rect = {left: coords.left - this.width / 2, right: coords.left + this.width / 2, top: coords.top, bottom: coords.bottom};
}
var parent = this.editorView.dom.offsetParent;
if (!this.element) {
this.element = parent.appendChild(document.createElement("div"));
if (this.class) {
this.element.className = this.class;
}
this.element.style.cssText = "position: absolute; z-index: 50; pointer-events: none; background-color: " + this.color;
}
var parentLeft, parentTop;
if (!parent || parent == document.body && getComputedStyle(parent).position == "static") {
parentLeft = -pageXOffset;
parentTop = -pageYOffset;
} else {
var rect$1 = parent.getBoundingClientRect();
parentLeft = rect$1.left - parent.scrollLeft;
parentTop = rect$1.top - parent.scrollTop;
}
this.element.style.left = rect.left - parentLeft + "px";
this.element.style.top = rect.top - parentTop + "px";
this.element.style.width = rect.right - rect.left + "px";
this.element.style.height = rect.bottom - rect.top + "px";
};
DropCursorView.prototype.scheduleRemoval = function scheduleRemoval(timeout) {
var this$1 = this;
clearTimeout(this.timeout);
this.timeout = setTimeout(function() {
return this$1.setCursor(null);
}, timeout);
};
DropCursorView.prototype.dragover = function dragover(event) {
if (!this.editorView.editable) {
return;
}
var pos = this.editorView.posAtCoords({left: event.clientX, top: event.clientY});
if (pos) {
var target2 = pos.pos;
if (this.editorView.dragging && this.editorView.dragging.slice) {
target2 = dropPoint(this.editorView.state.doc, target2, this.editorView.dragging.slice);
if (target2 == null) {
target2 = pos.pos;
}
}
this.setCursor(target2);
this.scheduleRemoval(5e3);
}
};
DropCursorView.prototype.dragend = function dragend() {
this.scheduleRemoval(20);
};
DropCursorView.prototype.drop = function drop() {
this.scheduleRemoval(20);
};
DropCursorView.prototype.dragleave = function dragleave(event) {
if (event.target == this.editorView.dom || !this.editorView.dom.contains(event.relatedTarget)) {
this.setCursor(null);
}
};
var base = {
8: "Backspace",
9: "Tab",
10: "Enter",
12: "NumLock",
13: "Enter",
16: "Shift",
17: "Control",
18: "Alt",
20: "CapsLock",
27: "Escape",
32: " ",
33: "PageUp",
34: "PageDown",
35: "End",
36: "Home",
37: "ArrowLeft",
38: "ArrowUp",
39: "ArrowRight",
40: "ArrowDown",
44: "PrintScreen",
45: "Insert",
46: "Delete",
59: ";",
61: "=",
91: "Meta",
92: "Meta",
106: "*",
107: "+",
108: ",",
109: "-",
110: ".",
111: "/",
144: "NumLock",
145: "ScrollLock",
160: "Shift",
161: "Shift",
162: "Control",
163: "Control",
164: "Alt",
165: "Alt",
173: "-",
186: ";",
187: "=",
188: ",",
189: "-",
190: ".",
191: "/",
192: "`",
219: "[",
220: "\\",
221: "]",
222: "'",
229: "q"
};
var shift = {
48: ")",
49: "!",
50: "@",
51: "#",
52: "$",
53: "%",
54: "^",
55: "&",
56: "*",
57: "(",
59: ":",
61: "+",
173: "_",
186: ":",
187: "+",
188: "<",
189: "_",
190: ">",
191: "?",
192: "~",
219: "{",
220: "|",
221: "}",
222: '"',
229: "Q"
};
var chrome = typeof navigator != "undefined" && /Chrome\/(\d+)/.exec(navigator.userAgent);
var safari = typeof navigator != "undefined" && /Apple Computer/.test(navigator.vendor);
var gecko = typeof navigator != "undefined" && /Gecko\/\d+/.test(navigator.userAgent);
var mac$2 = typeof navigator != "undefined" && /Mac/.test(navigator.platform);
var ie = typeof navigator != "undefined" && /MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);
var brokenModifierNames = chrome && (mac$2 || +chrome[1] < 57) || gecko && mac$2;
for (var i = 0; i < 10; i++)
base[48 + i] = base[96 + i] = String(i);
for (var i = 1; i <= 24; i++)
base[i + 111] = "F" + i;
for (var i = 65; i <= 90; i++) {
base[i] = String.fromCharCode(i + 32);
shift[i] = String.fromCharCode(i);
}
for (var code in base)
if (!shift.hasOwnProperty(code))
shift[code] = base[code];
function keyName(event) {
var ignoreKey = brokenModifierNames && (event.ctrlKey || event.altKey || event.metaKey) || (safari || ie) && event.shiftKey && event.key && event.key.length == 1;
var name = !ignoreKey && event.key || (event.shiftKey ? shift : base)[event.keyCode] || event.key || "Unidentified";
if (name == "Esc")
name = "Escape";
if (name == "Del")
name = "Delete";
if (name == "Left")
name = "ArrowLeft";
if (name == "Up")
name = "ArrowUp";
if (name == "Right")
name = "ArrowRight";
if (name == "Down")
name = "ArrowDown";
return name;
}
var mac$1 = typeof navigator != "undefined" ? /Mac/.test(navigator.platform) : false;
function normalizeKeyName(name) {
var parts = name.split(/-(?!$)/), result2 = parts[parts.length - 1];
if (result2 == "Space") {
result2 = " ";
}
var alt, ctrl, shift2, meta;
for (var i = 0; i < parts.length - 1; i++) {
var mod = parts[i];
if (/^(cmd|meta|m)$/i.test(mod)) {
meta = true;
} else if (/^a(lt)?$/i.test(mod)) {
alt = true;
} else if (/^(c|ctrl|control)$/i.test(mod)) {
ctrl = true;
} else if (/^s(hift)?$/i.test(mod)) {
shift2 = true;
} else if (/^mod$/i.test(mod)) {
if (mac$1) {
meta = true;
} else {
ctrl = true;
}
} else {
throw new Error("Unrecognized modifier name: " + mod);
}
}
if (alt) {
result2 = "Alt-" + result2;
}
if (ctrl) {
result2 = "Ctrl-" + result2;
}
if (meta) {
result2 = "Meta-" + result2;
}
if (shift2) {
result2 = "Shift-" + result2;
}
return result2;
}
function normalize(map16) {
var copy5 = Object.create(null);
for (var prop in map16) {
copy5[normalizeKeyName(prop)] = map16[prop];
}
return copy5;
}
function modifiers(name, event, shift2) {
if (event.altKey) {
name = "Alt-" + name;
}
if (event.ctrlKey) {
name = "Ctrl-" + name;
}
if (event.metaKey) {
name = "Meta-" + name;
}
if (shift2 !== false && event.shiftKey) {
name = "Shift-" + name;
}
return name;
}
function keymap(bindings) {
return new Plugin({props: {handleKeyDown: keydownHandler(bindings)}});
}
function keydownHandler(bindings) {
var map16 = normalize(bindings);
return function(view, event) {
var name = keyName(event), isChar = name.length == 1 && name != " ", baseName;
var direct = map16[modifiers(name, event, !isChar)];
if (direct && direct(view.state, view.dispatch, view)) {
return true;
}
if (isChar && (event.shiftKey || event.altKey || event.metaKey || name.charCodeAt(0) > 127) && (baseName = base[event.keyCode]) && baseName != name) {
var fromCode = map16[modifiers(baseName, event, true)];
if (fromCode && fromCode(view.state, view.dispatch, view)) {
return true;
}
} else if (isChar && event.shiftKey) {
var withShift = map16[modifiers(name, event, true)];
if (withShift && withShift(view.state, view.dispatch, view)) {
return true;
}
}
return false;
};
}
var GapCursor = /* @__PURE__ */ function(Selection3) {
function GapCursor2($pos) {
Selection3.call(this, $pos, $pos);
}
if (Selection3)
GapCursor2.__proto__ = Selection3;
GapCursor2.prototype = Object.create(Selection3 && Selection3.prototype);
GapCursor2.prototype.constructor = GapCursor2;
GapCursor2.prototype.map = function map16(doc2, mapping) {
var $pos = doc2.resolve(mapping.map(this.head));
return GapCursor2.valid($pos) ? new GapCursor2($pos) : Selection3.near($pos);
};
GapCursor2.prototype.content = function content2() {
return Slice.empty;
};
GapCursor2.prototype.eq = function eq13(other) {
return other instanceof GapCursor2 && other.head == this.head;
};
GapCursor2.prototype.toJSON = function toJSON7() {
return {type: "gapcursor", pos: this.head};
};
GapCursor2.fromJSON = function fromJSON8(doc2, json) {
if (typeof json.pos != "number") {
throw new RangeError("Invalid input for GapCursor.fromJSON");
}
return new GapCursor2(doc2.resolve(json.pos));
};
GapCursor2.prototype.getBookmark = function getBookmark2() {
return new GapBookmark(this.anchor);
};
GapCursor2.valid = function valid4($pos) {
var parent = $pos.parent;
if (parent.isTextblock || !closedBefore($pos) || !closedAfter($pos)) {
return false;
}
var override = parent.type.spec.allowGapCursor;
if (override != null) {
return override;
}
var deflt = parent.contentMatchAt($pos.index()).defaultType;
return deflt && deflt.isTextblock;
};
GapCursor2.findFrom = function findFrom2($pos, dir, mustMove) {
search:
for (; ; ) {
if (!mustMove && GapCursor2.valid($pos)) {
return $pos;
}
var pos = $pos.pos, next2 = null;
for (var d = $pos.depth; ; d--) {
var parent = $pos.node(d);
if (dir > 0 ? $pos.indexAfter(d) < parent.childCount : $pos.index(d) > 0) {
next2 = parent.child(dir > 0 ? $pos.indexAfter(d) : $pos.index(d) - 1);
break;
} else if (d == 0) {
return null;
}
pos += dir;
var $cur = $pos.doc.resolve(pos);
if (GapCursor2.valid($cur)) {
return $cur;
}
}
for (; ; ) {
var inside = dir > 0 ? next2.firstChild : next2.lastChild;
if (!inside) {
if (next2.isAtom && !next2.isText && !NodeSelection.isSelectable(next2)) {
$pos = $pos.doc.resolve(pos + next2.nodeSize * dir);
mustMove = false;
continue search;
}
break;
}
next2 = inside;
pos += dir;
var $cur$1 = $pos.doc.resolve(pos);
if (GapCursor2.valid($cur$1)) {
return $cur$1;
}
}
return null;
}
};
return GapCursor2;
}(Selection);
GapCursor.prototype.visible = false;
Selection.jsonID("gapcursor", GapCursor);
var GapBookmark = function GapBookmark2(pos) {
this.pos = pos;
};
GapBookmark.prototype.map = function map13(mapping) {
return new GapBookmark(mapping.map(this.pos));
};
GapBookmark.prototype.resolve = function resolve7(doc2) {
var $pos = doc2.resolve(this.pos);
return GapCursor.valid($pos) ? new GapCursor($pos) : Selection.near($pos);
};
function closedBefore($pos) {
for (var d = $pos.depth; d >= 0; d--) {
var index3 = $pos.index(d);
if (index3 == 0) {
continue;
}
for (var before3 = $pos.node(d).child(index3 - 1); ; before3 = before3.lastChild) {
if (before3.childCount == 0 && !before3.inlineContent || before3.isAtom || before3.type.spec.isolating) {
return true;
}
if (before3.inlineContent) {
return false;
}
}
}
return true;
}
function closedAfter($pos) {
for (var d = $pos.depth; d >= 0; d--) {
var index3 = $pos.indexAfter(d), parent = $pos.node(d);
if (index3 == parent.childCount) {
continue;
}
for (var after3 = parent.child(index3); ; after3 = after3.firstChild) {
if (after3.childCount == 0 && !after3.inlineContent || after3.isAtom || after3.type.spec.isolating) {
return true;
}
if (after3.inlineContent) {
return false;
}
}
}
return true;
}
var gapCursor = function() {
return new Plugin({
props: {
decorations: drawGapCursor,
createSelectionBetween: function createSelectionBetween(_view, $anchor, $head) {
if ($anchor.pos == $head.pos && GapCursor.valid($head)) {
return new GapCursor($head);
}
},
handleClick,
handleKeyDown
}
});
};
var handleKeyDown = keydownHandler({
ArrowLeft: arrow$1("horiz", -1),
ArrowRight: arrow$1("horiz", 1),
ArrowUp: arrow$1("vert", -1),
ArrowDown: arrow$1("vert", 1)
});
function arrow$1(axis, dir) {
var dirStr = axis == "vert" ? dir > 0 ? "down" : "up" : dir > 0 ? "right" : "left";
return function(state, dispatch2, view) {
var sel = state.selection;
var $start = dir > 0 ? sel.$to : sel.$from, mustMove = sel.empty;
if (sel instanceof TextSelection) {
if (!view.endOfTextblock(dirStr) || $start.depth == 0) {
return false;
}
mustMove = false;
$start = state.doc.resolve(dir > 0 ? $start.after() : $start.before());
}
var $found = GapCursor.findFrom($start, dir, mustMove);
if (!$found) {
return false;
}
if (dispatch2) {
dispatch2(state.tr.setSelection(new GapCursor($found)));
}
return true;
};
}
function handleClick(view, pos, event) {
if (!view.editable) {
return false;
}
var $pos = view.state.doc.resolve(pos);
if (!GapCursor.valid($pos)) {
return false;
}
var ref2 = view.posAtCoords({left: event.clientX, top: event.clientY});
var inside = ref2.inside;
if (inside > -1 && NodeSelection.isSelectable(view.state.doc.nodeAt(inside))) {
return false;
}
view.dispatch(view.state.tr.setSelection(new GapCursor($pos)));
return true;
}
function drawGapCursor(state) {
if (!(state.selection instanceof GapCursor)) {
return null;
}
var node4 = document.createElement("div");
node4.className = "ProseMirror-gapcursor";
return DecorationSet.create(state.doc, [Decoration.widget(state.selection.head, node4, {key: "gapcursor"})]);
}
function deleteSelection(state, dispatch2) {
if (state.selection.empty) {
return false;
}
if (dispatch2) {
dispatch2(state.tr.deleteSelection().scrollIntoView());
}
return true;
}
function joinBackward(state, dispatch2, view) {
var ref2 = state.selection;
var $cursor = ref2.$cursor;
if (!$cursor || (view ? !view.endOfTextblock("backward", state) : $cursor.parentOffset > 0)) {
return false;
}
var $cut = findCutBefore($cursor);
if (!$cut) {
var range2 = $cursor.blockRange(), target2 = range2 && liftTarget(range2);
if (target2 == null) {
return false;
}
if (dispatch2) {
dispatch2(state.tr.lift(range2, target2).scrollIntoView());
}
return true;
}
var before3 = $cut.nodeBefore;
if (!before3.type.spec.isolating && deleteBarrier(state, $cut, dispatch2)) {
return true;
}
if ($cursor.parent.content.size == 0 && (textblockAt(before3, "end") || NodeSelection.isSelectable(before3))) {
if (dispatch2) {
var tr = state.tr.deleteRange($cursor.before(), $cursor.after());
tr.setSelection(textblockAt(before3, "end") ? Selection.findFrom(tr.doc.resolve(tr.mapping.map($cut.pos, -1)), -1) : NodeSelection.create(tr.doc, $cut.pos - before3.nodeSize));
dispatch2(tr.scrollIntoView());
}
return true;
}
if (before3.isAtom && $cut.depth == $cursor.depth - 1) {
if (dispatch2) {
dispatch2(state.tr.delete($cut.pos - before3.nodeSize, $cut.pos).scrollIntoView());
}
return true;
}
return false;
}
function textblockAt(node4, side) {
for (; node4; node4 = side == "start" ? node4.firstChild : node4.lastChild) {
if (node4.isTextblock) {
return true;
}
}
return false;
}
function selectNodeBackward(state, dispatch2, view) {
var ref2 = state.selection;
var $head = ref2.$head;
var empty2 = ref2.empty;
var $cut = $head;
if (!empty2) {
return false;
}
if ($head.parent.isTextblock) {
if (view ? !view.endOfTextblock("backward", state) : $head.parentOffset > 0) {
return false;
}
$cut = findCutBefore($head);
}
var node4 = $cut && $cut.nodeBefore;
if (!node4 || !NodeSelection.isSelectable(node4)) {
return false;
}
if (dispatch2) {
dispatch2(state.tr.setSelection(NodeSelection.create(state.doc, $cut.pos - node4.nodeSize)).scrollIntoView());
}
return true;
}
function findCutBefore($pos) {
if (!$pos.parent.type.spec.isolating) {
for (var i = $pos.depth - 1; i >= 0; i--) {
if ($pos.index(i) > 0) {
return $pos.doc.resolve($pos.before(i + 1));
}
if ($pos.node(i).type.spec.isolating) {
break;
}
}
}
return null;
}
function joinForward(state, dispatch2, view) {
var ref2 = state.selection;
var $cursor = ref2.$cursor;
if (!$cursor || (view ? !view.endOfTextblock("forward", state) : $cursor.parentOffset < $cursor.parent.content.size)) {
return false;
}
var $cut = findCutAfter($cursor);
if (!$cut) {
return false;
}
var after3 = $cut.nodeAfter;
if (deleteBarrier(state, $cut, dispatch2)) {
return true;
}
if ($cursor.parent.content.size == 0 && (textblockAt(after3, "start") || NodeSelection.isSelectable(after3))) {
if (dispatch2) {
var tr = state.tr.deleteRange($cursor.before(), $cursor.after());
tr.setSelection(textblockAt(after3, "start") ? Selection.findFrom(tr.doc.resolve(tr.mapping.map($cut.pos)), 1) : NodeSelection.create(tr.doc, tr.mapping.map($cut.pos)));
dispatch2(tr.scrollIntoView());
}
return true;
}
if (after3.isAtom && $cut.depth == $cursor.depth - 1) {
if (dispatch2) {
dispatch2(state.tr.delete($cut.pos, $cut.pos + after3.nodeSize).scrollIntoView());
}
return true;
}
return false;
}
function selectNodeForward(state, dispatch2, view) {
var ref2 = state.selection;
var $head = ref2.$head;
var empty2 = ref2.empty;
var $cut = $head;
if (!empty2) {
return false;
}
if ($head.parent.isTextblock) {
if (view ? !view.endOfTextblock("forward", state) : $head.parentOffset < $head.parent.content.size) {
return false;
}
$cut = findCutAfter($head);
}
var node4 = $cut && $cut.nodeAfter;
if (!node4 || !NodeSelection.isSelectable(node4)) {
return false;
}
if (dispatch2) {
dispatch2(state.tr.setSelection(NodeSelection.create(state.doc, $cut.pos)).scrollIntoView());
}
return true;
}
function findCutAfter($pos) {
if (!$pos.parent.type.spec.isolating) {
for (var i = $pos.depth - 1; i >= 0; i--) {
var parent = $pos.node(i);
if ($pos.index(i) + 1 < parent.childCount) {
return $pos.doc.resolve($pos.after(i + 1));
}
if (parent.type.spec.isolating) {
break;
}
}
}
return null;
}
function newlineInCode(state, dispatch2) {
var ref2 = state.selection;
var $head = ref2.$head;
var $anchor = ref2.$anchor;
if (!$head.parent.type.spec.code || !$head.sameParent($anchor)) {
return false;
}
if (dispatch2) {
dispatch2(state.tr.insertText("\n").scrollIntoView());
}
return true;
}
function defaultBlockAt(match3) {
for (var i = 0; i < match3.edgeCount; i++) {
var ref2 = match3.edge(i);
var type = ref2.type;
if (type.isTextblock && !type.hasRequiredAttrs()) {
return type;
}
}
return null;
}
function exitCode(state, dispatch2) {
var ref2 = state.selection;
var $head = ref2.$head;
var $anchor = ref2.$anchor;
if (!$head.parent.type.spec.code || !$head.sameParent($anchor)) {
return false;
}
var above = $head.node(-1), after3 = $head.indexAfter(-1), type = defaultBlockAt(above.contentMatchAt(after3));
if (!above.canReplaceWith(after3, after3, type)) {
return false;
}
if (dispatch2) {
var pos = $head.after(), tr = state.tr.replaceWith(pos, pos, type.createAndFill());
tr.setSelection(Selection.near(tr.doc.resolve(pos), 1));
dispatch2(tr.scrollIntoView());
}
return true;
}
function createParagraphNear(state, dispatch2) {
var sel = state.selection;
var $from = sel.$from;
var $to = sel.$to;
if (sel instanceof AllSelection || $from.parent.inlineContent || $to.parent.inlineContent) {
return false;
}
var type = defaultBlockAt($to.parent.contentMatchAt($to.indexAfter()));
if (!type || !type.isTextblock) {
return false;
}
if (dispatch2) {
var side = (!$from.parentOffset && $to.index() < $to.parent.childCount ? $from : $to).pos;
var tr = state.tr.insert(side, type.createAndFill());
tr.setSelection(TextSelection.create(tr.doc, side + 1));
dispatch2(tr.scrollIntoView());
}
return true;
}
function liftEmptyBlock(state, dispatch2) {
var ref2 = state.selection;
var $cursor = ref2.$cursor;
if (!$cursor || $cursor.parent.content.size) {
return false;
}
if ($cursor.depth > 1 && $cursor.after() != $cursor.end(-1)) {
var before3 = $cursor.before();
if (canSplit(state.doc, before3)) {
if (dispatch2) {
dispatch2(state.tr.split(before3).scrollIntoView());
}
return true;
}
}
var range2 = $cursor.blockRange(), target2 = range2 && liftTarget(range2);
if (target2 == null) {
return false;
}
if (dispatch2) {
dispatch2(state.tr.lift(range2, target2).scrollIntoView());
}
return true;
}
function splitBlock(state, dispatch2) {
var ref2 = state.selection;
var $from = ref2.$from;
var $to = ref2.$to;
if (state.selection instanceof NodeSelection && state.selection.node.isBlock) {
if (!$from.parentOffset || !canSplit(state.doc, $from.pos)) {
return false;
}
if (dispatch2) {
dispatch2(state.tr.split($from.pos).scrollIntoView());
}
return true;
}
if (!$from.parent.isBlock) {
return false;
}
if (dispatch2) {
var atEnd2 = $to.parentOffset == $to.parent.content.size;
var tr = state.tr;
if (state.selection instanceof TextSelection || state.selection instanceof AllSelection) {
tr.deleteSelection();
}
var deflt = $from.depth == 0 ? null : defaultBlockAt($from.node(-1).contentMatchAt($from.indexAfter(-1)));
var types = atEnd2 && deflt ? [{type: deflt}] : null;
var can = canSplit(tr.doc, tr.mapping.map($from.pos), 1, types);
if (!types && !can && canSplit(tr.doc, tr.mapping.map($from.pos), 1, deflt && [{type: deflt}])) {
types = [{type: deflt}];
can = true;
}
if (can) {
tr.split(tr.mapping.map($from.pos), 1, types);
if (!atEnd2 && !$from.parentOffset && $from.parent.type != deflt && $from.node(-1).canReplace($from.index(-1), $from.indexAfter(-1), Fragment.from([deflt.create(), $from.parent]))) {
tr.setNodeMarkup(tr.mapping.map($from.before()), deflt);
}
}
dispatch2(tr.scrollIntoView());
}
return true;
}
function selectAll(state, dispatch2) {
if (dispatch2) {
dispatch2(state.tr.setSelection(new AllSelection(state.doc)));
}
return true;
}
function joinMaybeClear(state, $pos, dispatch2) {
var before3 = $pos.nodeBefore, after3 = $pos.nodeAfter, index3 = $pos.index();
if (!before3 || !after3 || !before3.type.compatibleContent(after3.type)) {
return false;
}
if (!before3.content.size && $pos.parent.canReplace(index3 - 1, index3)) {
if (dispatch2) {
dispatch2(state.tr.delete($pos.pos - before3.nodeSize, $pos.pos).scrollIntoView());
}
return true;
}
if (!$pos.parent.canReplace(index3, index3 + 1) || !(after3.isTextblock || canJoin(state.doc, $pos.pos))) {
return false;
}
if (dispatch2) {
dispatch2(state.tr.clearIncompatible($pos.pos, before3.type, before3.contentMatchAt(before3.childCount)).join($pos.pos).scrollIntoView());
}
return true;
}
function deleteBarrier(state, $cut, dispatch2) {
var before3 = $cut.nodeBefore, after3 = $cut.nodeAfter, conn, match3;
if (before3.type.spec.isolating || after3.type.spec.isolating) {
return false;
}
if (joinMaybeClear(state, $cut, dispatch2)) {
return true;
}
var canDelAfter = $cut.parent.canReplace($cut.index(), $cut.index() + 1);
if (canDelAfter && (conn = (match3 = before3.contentMatchAt(before3.childCount)).findWrapping(after3.type)) && match3.matchType(conn[0] || after3.type).validEnd) {
if (dispatch2) {
var end2 = $cut.pos + after3.nodeSize, wrap2 = Fragment.empty;
for (var i = conn.length - 1; i >= 0; i--) {
wrap2 = Fragment.from(conn[i].create(null, wrap2));
}
wrap2 = Fragment.from(before3.copy(wrap2));
var tr = state.tr.step(new ReplaceAroundStep($cut.pos - 1, end2, $cut.pos, end2, new Slice(wrap2, 1, 0), conn.length, true));
var joinAt = end2 + 2 * conn.length;
if (canJoin(tr.doc, joinAt)) {
tr.join(joinAt);
}
dispatch2(tr.scrollIntoView());
}
return true;
}
var selAfter = Selection.findFrom($cut, 1);
var range2 = selAfter && selAfter.$from.blockRange(selAfter.$to), target2 = range2 && liftTarget(range2);
if (target2 != null && target2 >= $cut.depth) {
if (dispatch2) {
dispatch2(state.tr.lift(range2, target2).scrollIntoView());
}
return true;
}
if (canDelAfter && after3.isTextblock && textblockAt(before3, "end")) {
var at = before3, wrap$1 = [];
for (; ; ) {
wrap$1.push(at);
if (at.isTextblock) {
break;
}
at = at.lastChild;
}
if (at.canReplace(at.childCount, at.childCount, after3.content)) {
if (dispatch2) {
var end$1 = Fragment.empty;
for (var i$1 = wrap$1.length - 1; i$1 >= 0; i$1--) {
end$1 = Fragment.from(wrap$1[i$1].copy(end$1));
}
var tr$1 = state.tr.step(new ReplaceAroundStep($cut.pos - wrap$1.length, $cut.pos + after3.nodeSize, $cut.pos + 1, $cut.pos + after3.nodeSize - 1, new Slice(end$1, wrap$1.length, 0), 0, true));
dispatch2(tr$1.scrollIntoView());
}
return true;
}
}
return false;
}
function setBlockType(nodeType2, attrs2) {
return function(state, dispatch2) {
var ref2 = state.selection;
var from4 = ref2.from;
var to = ref2.to;
var applicable = false;
state.doc.nodesBetween(from4, to, function(node4, pos) {
if (applicable) {
return false;
}
if (!node4.isTextblock || node4.hasMarkup(nodeType2, attrs2)) {
return;
}
if (node4.type == nodeType2) {
applicable = true;
} else {
var $pos = state.doc.resolve(pos), index3 = $pos.index();
applicable = $pos.parent.canReplaceWith(index3, index3 + 1, nodeType2);
}
});
if (!applicable) {
return false;
}
if (dispatch2) {
dispatch2(state.tr.setBlockType(from4, to, nodeType2, attrs2).scrollIntoView());
}
return true;
};
}
function markApplies(doc2, ranges, type) {
var loop = function(i2) {
var ref2 = ranges[i2];
var $from = ref2.$from;
var $to = ref2.$to;
var can = $from.depth == 0 ? doc2.type.allowsMarkType(type) : false;
doc2.nodesBetween($from.pos, $to.pos, function(node4) {
if (can) {
return false;
}
can = node4.inlineContent && node4.type.allowsMarkType(type);
});
if (can) {
return {v: true};
}
};
for (var i = 0; i < ranges.length; i++) {
var returned = loop(i);
if (returned)
return returned.v;
}
return false;
}
function toggleMark(markType, attrs2) {
return function(state, dispatch2) {
var ref2 = state.selection;
var empty2 = ref2.empty;
var $cursor = ref2.$cursor;
var ranges = ref2.ranges;
if (empty2 && !$cursor || !markApplies(state.doc, ranges, markType)) {
return false;
}
if (dispatch2) {
if ($cursor) {
if (markType.isInSet(state.storedMarks || $cursor.marks())) {
dispatch2(state.tr.removeStoredMark(markType));
} else {
dispatch2(state.tr.addStoredMark(markType.create(attrs2)));
}
} else {
var has2 = false, tr = state.tr;
for (var i = 0; !has2 && i < ranges.length; i++) {
var ref$12 = ranges[i];
var $from = ref$12.$from;
var $to = ref$12.$to;
has2 = state.doc.rangeHasMark($from.pos, $to.pos, markType);
}
for (var i$1 = 0; i$1 < ranges.length; i$1++) {
var ref$2 = ranges[i$1];
var $from$1 = ref$2.$from;
var $to$1 = ref$2.$to;
if (has2) {
tr.removeMark($from$1.pos, $to$1.pos, markType);
} else {
var from4 = $from$1.pos, to = $to$1.pos, start3 = $from$1.nodeAfter, end2 = $to$1.nodeBefore;
var spaceStart = start3 && start3.isText ? /^\s*/.exec(start3.text)[0].length : 0;
var spaceEnd = end2 && end2.isText ? /\s*$/.exec(end2.text)[0].length : 0;
if (from4 + spaceStart < to) {
from4 += spaceStart;
to -= spaceEnd;
}
tr.addMark(from4, to, markType.create(attrs2));
}
}
dispatch2(tr.scrollIntoView());
}
}
return true;
};
}
function chainCommands() {
var commands = [], len2 = arguments.length;
while (len2--)
commands[len2] = arguments[len2];
return function(state, dispatch2, view) {
for (var i = 0; i < commands.length; i++) {
if (commands[i](state, dispatch2, view)) {
return true;
}
}
return false;
};
}
var backspace = chainCommands(deleteSelection, joinBackward, selectNodeBackward);
var del = chainCommands(deleteSelection, joinForward, selectNodeForward);
var pcBaseKeymap = {
Enter: chainCommands(newlineInCode, createParagraphNear, liftEmptyBlock, splitBlock),
"Mod-Enter": exitCode,
Backspace: backspace,
"Mod-Backspace": backspace,
Delete: del,
"Mod-Delete": del,
"Mod-a": selectAll
};
var macBaseKeymap = {
"Ctrl-h": pcBaseKeymap["Backspace"],
"Alt-Backspace": pcBaseKeymap["Mod-Backspace"],
"Ctrl-d": pcBaseKeymap["Delete"],
"Ctrl-Alt-Backspace": pcBaseKeymap["Mod-Delete"],
"Alt-Delete": pcBaseKeymap["Mod-Delete"],
"Alt-d": pcBaseKeymap["Mod-Delete"]
};
for (var key in pcBaseKeymap) {
macBaseKeymap[key] = pcBaseKeymap[key];
}
var mac = typeof navigator != "undefined" ? /Mac/.test(navigator.platform) : typeof os != "undefined" ? os.platform() == "darwin" : false;
var baseKeymap = mac ? macBaseKeymap : pcBaseKeymap;
var InputRule = function InputRule2(match3, handler) {
this.match = match3;
this.handler = typeof handler == "string" ? stringHandler(handler) : handler;
};
function stringHandler(string) {
return function(state, match3, start3, end2) {
var insert2 = string;
if (match3[1]) {
var offset2 = match3[0].lastIndexOf(match3[1]);
insert2 += match3[0].slice(offset2 + match3[1].length);
start3 += offset2;
var cutOff = start3 - end2;
if (cutOff > 0) {
insert2 = match3[0].slice(offset2 - cutOff, offset2) + insert2;
start3 = end2;
}
}
return state.tr.insertText(insert2, start3, end2);
};
}
var MAX_MATCH = 500;
function inputRules(ref2) {
var rules = ref2.rules;
var plugin = new Plugin({
state: {
init: function init7() {
return null;
},
apply: function apply8(tr, prev) {
var stored = tr.getMeta(this);
if (stored) {
return stored;
}
return tr.selectionSet || tr.docChanged ? null : prev;
}
},
props: {
handleTextInput: function handleTextInput(view, from4, to, text3) {
return run2(view, from4, to, text3, rules, plugin);
},
handleDOMEvents: {
compositionend: function(view) {
setTimeout(function() {
var ref3 = view.state.selection;
var $cursor = ref3.$cursor;
if ($cursor) {
run2(view, $cursor.pos, $cursor.pos, "", rules, plugin);
}
});
}
}
},
isInputRules: true
});
return plugin;
}
function run2(view, from4, to, text3, rules, plugin) {
if (view.composing) {
return false;
}
var state = view.state, $from = state.doc.resolve(from4);
if ($from.parent.type.spec.code) {
return false;
}
var textBefore = $from.parent.textBetween(Math.max(0, $from.parentOffset - MAX_MATCH), $from.parentOffset, null, "\uFFFC") + text3;
for (var i = 0; i < rules.length; i++) {
var match3 = rules[i].match.exec(textBefore);
var tr = match3 && rules[i].handler(state, match3, from4 - (match3[0].length - text3.length), to);
if (!tr) {
continue;
}
view.dispatch(tr.setMeta(plugin, {transform: tr, from: from4, to, text: text3}));
return true;
}
return false;
}
function undoInputRule(state, dispatch2) {
var plugins2 = state.plugins;
for (var i = 0; i < plugins2.length; i++) {
var plugin = plugins2[i], undoable = void 0;
if (plugin.spec.isInputRules && (undoable = plugin.getState(state))) {
if (dispatch2) {
var tr = state.tr, toUndo = undoable.transform;
for (var j = toUndo.steps.length - 1; j >= 0; j--) {
tr.step(toUndo.steps[j].invert(toUndo.docs[j]));
}
if (undoable.text) {
var marks2 = tr.doc.resolve(undoable.from).marks();
tr.replaceWith(undoable.from, undoable.to, state.schema.text(undoable.text, marks2));
} else {
tr.delete(undoable.from, undoable.to);
}
dispatch2(tr);
}
return true;
}
}
return false;
}
function wrappingInputRule(regexp, nodeType2, getAttrs, joinPredicate) {
return new InputRule(regexp, function(state, match3, start3, end2) {
var attrs2 = getAttrs instanceof Function ? getAttrs(match3) : getAttrs;
var tr = state.tr.delete(start3, end2);
var $start = tr.doc.resolve(start3), range2 = $start.blockRange(), wrapping = range2 && findWrapping3(range2, nodeType2, attrs2);
if (!wrapping) {
return null;
}
tr.wrap(range2, wrapping);
var before3 = tr.doc.resolve(start3 - 1).nodeBefore;
if (before3 && before3.type == nodeType2 && canJoin(tr.doc, start3 - 1) && (!joinPredicate || joinPredicate(match3, before3))) {
tr.join(start3 - 1);
}
return tr;
});
}
function textblockTypeInputRule(regexp, nodeType2, getAttrs) {
return new InputRule(regexp, function(state, match3, start3, end2) {
var $start = state.doc.resolve(start3);
var attrs2 = getAttrs instanceof Function ? getAttrs(match3) : getAttrs;
if (!$start.node(-1).canReplaceWith($start.index(-1), $start.indexAfter(-1), nodeType2)) {
return null;
}
return state.tr.delete(start3, end2).setBlockType(start3, start3, nodeType2, attrs2);
});
}
function equalNodeType(nodeType2, node4) {
return Array.isArray(nodeType2) && nodeType2.indexOf(node4.type) > -1 || node4.type === nodeType2;
}
function findParentNodeClosestToPos($pos, predicate) {
for (let i = $pos.depth; i > 0; i -= 1) {
const node4 = $pos.node(i);
if (predicate(node4)) {
return {
pos: i > 0 ? $pos.before(i) : 0,
start: $pos.start(i),
depth: i,
node: node4
};
}
}
}
function findParentNode(predicate) {
return (selection) => findParentNodeClosestToPos(selection.$from, predicate);
}
function isNodeSelection(selection) {
return selection instanceof NodeSelection;
}
function findSelectedNodeOfType(nodeType2) {
return function(selection) {
if (isNodeSelection(selection)) {
const {
node: node4
} = selection;
const {
$from
} = selection;
if (equalNodeType(nodeType2, node4)) {
return {
node: node4,
pos: $from.pos,
depth: $from.depth
};
}
}
};
}
function getMarkAttrs(state, type) {
const {
from: from4,
to
} = state.selection;
let marks2 = [];
state.doc.nodesBetween(from4, to, (node4) => {
marks2 = [...marks2, ...node4.marks];
});
const mark3 = marks2.find((markItem) => markItem.type.name === type.name);
if (mark3) {
return mark3.attrs;
}
return {};
}
function getMarkRange($pos = null, type = null) {
if (!$pos || !type) {
return false;
}
const start3 = $pos.parent.childAfter($pos.parentOffset);
if (!start3.node) {
return false;
}
const link = start3.node.marks.find((mark3) => mark3.type === type);
if (!link) {
return false;
}
let startIndex = $pos.index();
let startPos = $pos.start() + start3.offset;
let endIndex = startIndex + 1;
let endPos = startPos + start3.node.nodeSize;
while (startIndex > 0 && link.isInSet($pos.parent.child(startIndex - 1).marks)) {
startIndex -= 1;
startPos -= $pos.parent.child(startIndex).nodeSize;
}
while (endIndex < $pos.parent.childCount && link.isInSet($pos.parent.child(endIndex).marks)) {
endPos += $pos.parent.child(endIndex).nodeSize;
endIndex += 1;
}
return {
from: startPos,
to: endPos
};
}
function getNodeAttrs(state, type) {
const {
from: from4,
to
} = state.selection;
let nodes = [];
state.doc.nodesBetween(from4, to, (node5) => {
nodes = [...nodes, node5];
});
const node4 = nodes.reverse().find((nodeItem) => nodeItem.type.name === type.name);
if (node4) {
return node4.attrs;
}
return {};
}
function markIsActive(state, type) {
const {
from: from4,
$from,
to,
empty: empty2
} = state.selection;
if (empty2) {
return !!type.isInSet(state.storedMarks || $from.marks());
}
return !!state.doc.rangeHasMark(from4, to, type);
}
function nodeIsActive(state, type, attrs2 = {}) {
const predicate = (node5) => node5.type === type;
const node4 = findSelectedNodeOfType(type)(state.selection) || findParentNode(predicate)(state.selection);
if (!Object.keys(attrs2).length || !node4) {
return !!node4;
}
return node4.node.hasMarkup(type, __assign(__assign({}, node4.node.attrs), attrs2));
}
function wrapInList(listType, attrs2) {
return function(state, dispatch2) {
var ref2 = state.selection;
var $from = ref2.$from;
var $to = ref2.$to;
var range2 = $from.blockRange($to), doJoin = false, outerRange = range2;
if (!range2) {
return false;
}
if (range2.depth >= 2 && $from.node(range2.depth - 1).type.compatibleContent(listType) && range2.startIndex == 0) {
if ($from.index(range2.depth - 1) == 0) {
return false;
}
var $insert = state.doc.resolve(range2.start - 2);
outerRange = new NodeRange($insert, $insert, range2.depth);
if (range2.endIndex < range2.parent.childCount) {
range2 = new NodeRange($from, state.doc.resolve($to.end(range2.depth)), range2.depth);
}
doJoin = true;
}
var wrap2 = findWrapping3(outerRange, listType, attrs2, range2);
if (!wrap2) {
return false;
}
if (dispatch2) {
dispatch2(doWrapInList(state.tr, range2, wrap2, doJoin, listType).scrollIntoView());
}
return true;
};
}
function doWrapInList(tr, range2, wrappers, joinBefore, listType) {
var content2 = Fragment.empty;
for (var i = wrappers.length - 1; i >= 0; i--) {
content2 = Fragment.from(wrappers[i].type.create(wrappers[i].attrs, content2));
}
tr.step(new ReplaceAroundStep(range2.start - (joinBefore ? 2 : 0), range2.end, range2.start, range2.end, new Slice(content2, 0, 0), wrappers.length, true));
var found2 = 0;
for (var i$1 = 0; i$1 < wrappers.length; i$1++) {
if (wrappers[i$1].type == listType) {
found2 = i$1 + 1;
}
}
var splitDepth = wrappers.length - found2;
var splitPos = range2.start + wrappers.length - (joinBefore ? 2 : 0), parent = range2.parent;
for (var i$2 = range2.startIndex, e = range2.endIndex, first2 = true; i$2 < e; i$2++, first2 = false) {
if (!first2 && canSplit(tr.doc, splitPos, splitDepth)) {
tr.split(splitPos, splitDepth);
splitPos += 2 * splitDepth;
}
splitPos += parent.child(i$2).nodeSize;
}
return tr;
}
function splitListItem(itemType) {
return function(state, dispatch2) {
var ref2 = state.selection;
var $from = ref2.$from;
var $to = ref2.$to;
var node4 = ref2.node;
if (node4 && node4.isBlock || $from.depth < 2 || !$from.sameParent($to)) {
return false;
}
var grandParent = $from.node(-1);
if (grandParent.type != itemType) {
return false;
}
if ($from.parent.content.size == 0 && $from.node(-1).childCount == $from.indexAfter(-1)) {
if ($from.depth == 2 || $from.node(-3).type != itemType || $from.index(-2) != $from.node(-2).childCount - 1) {
return false;
}
if (dispatch2) {
var wrap2 = Fragment.empty, keepItem = $from.index(-1) > 0;
for (var d = $from.depth - (keepItem ? 1 : 2); d >= $from.depth - 3; d--) {
wrap2 = Fragment.from($from.node(d).copy(wrap2));
}
wrap2 = wrap2.append(Fragment.from(itemType.createAndFill()));
var tr$1 = state.tr.replace($from.before(keepItem ? null : -1), $from.after(-3), new Slice(wrap2, keepItem ? 3 : 2, 2));
tr$1.setSelection(state.selection.constructor.near(tr$1.doc.resolve($from.pos + (keepItem ? 3 : 2))));
dispatch2(tr$1.scrollIntoView());
}
return true;
}
var nextType = $to.pos == $from.end() ? grandParent.contentMatchAt(0).defaultType : null;
var tr = state.tr.delete($from.pos, $to.pos);
var types = nextType && [null, {type: nextType}];
if (!canSplit(tr.doc, $from.pos, 2, types)) {
return false;
}
if (dispatch2) {
dispatch2(tr.split($from.pos, 2, types).scrollIntoView());
}
return true;
};
}
function liftListItem(itemType) {
return function(state, dispatch2) {
var ref2 = state.selection;
var $from = ref2.$from;
var $to = ref2.$to;
var range2 = $from.blockRange($to, function(node4) {
return node4.childCount && node4.firstChild.type == itemType;
});
if (!range2) {
return false;
}
if (!dispatch2) {
return true;
}
if ($from.node(range2.depth - 1).type == itemType) {
return liftToOuterList(state, dispatch2, itemType, range2);
} else {
return liftOutOfList(state, dispatch2, range2);
}
};
}
function liftToOuterList(state, dispatch2, itemType, range2) {
var tr = state.tr, end2 = range2.end, endOfList = range2.$to.end(range2.depth);
if (end2 < endOfList) {
tr.step(new ReplaceAroundStep(end2 - 1, endOfList, end2, endOfList, new Slice(Fragment.from(itemType.create(null, range2.parent.copy())), 1, 0), 1, true));
range2 = new NodeRange(tr.doc.resolve(range2.$from.pos), tr.doc.resolve(endOfList), range2.depth);
}
dispatch2(tr.lift(range2, liftTarget(range2)).scrollIntoView());
return true;
}
function liftOutOfList(state, dispatch2, range2) {
var tr = state.tr, list = range2.parent;
for (var pos = range2.end, i = range2.endIndex - 1, e = range2.startIndex; i > e; i--) {
pos -= list.child(i).nodeSize;
tr.delete(pos - 1, pos + 1);
}
var $start = tr.doc.resolve(range2.start), item = $start.nodeAfter;
var atStart2 = range2.startIndex == 0, atEnd2 = range2.endIndex == list.childCount;
var parent = $start.node(-1), indexBefore = $start.index(-1);
if (!parent.canReplace(indexBefore + (atStart2 ? 0 : 1), indexBefore + 1, item.content.append(atEnd2 ? Fragment.empty : Fragment.from(list)))) {
return false;
}
var start3 = $start.pos, end2 = start3 + item.nodeSize;
tr.step(new ReplaceAroundStep(start3 - (atStart2 ? 1 : 0), end2 + (atEnd2 ? 1 : 0), start3 + 1, end2 - 1, new Slice((atStart2 ? Fragment.empty : Fragment.from(list.copy(Fragment.empty))).append(atEnd2 ? Fragment.empty : Fragment.from(list.copy(Fragment.empty))), atStart2 ? 0 : 1, atEnd2 ? 0 : 1), atStart2 ? 0 : 1));
dispatch2(tr.scrollIntoView());
return true;
}
function sinkListItem(itemType) {
return function(state, dispatch2) {
var ref2 = state.selection;
var $from = ref2.$from;
var $to = ref2.$to;
var range2 = $from.blockRange($to, function(node4) {
return node4.childCount && node4.firstChild.type == itemType;
});
if (!range2) {
return false;
}
var startIndex = range2.startIndex;
if (startIndex == 0) {
return false;
}
var parent = range2.parent, nodeBefore = parent.child(startIndex - 1);
if (nodeBefore.type != itemType) {
return false;
}
if (dispatch2) {
var nestedBefore = nodeBefore.lastChild && nodeBefore.lastChild.type == parent.type;
var inner = Fragment.from(nestedBefore ? itemType.create() : null);
var slice5 = new Slice(Fragment.from(itemType.create(null, Fragment.from(parent.type.create(null, inner)))), nestedBefore ? 3 : 1, 0);
var before3 = range2.start, after3 = range2.end;
dispatch2(state.tr.step(new ReplaceAroundStep(before3 - (nestedBefore ? 3 : 1), after3, before3, after3, slice5, 1, true)).scrollIntoView());
}
return true;
};
}
function getMarksBetween(start3, end2, state) {
let marks2 = [];
state.doc.nodesBetween(start3, end2, (node4, pos) => {
marks2 = [...marks2, ...node4.marks.map((mark3) => ({
start: pos,
end: pos + node4.nodeSize,
mark: mark3
}))];
});
return marks2;
}
function markInputRule(regexp, markType, getAttrs) {
return new InputRule(regexp, (state, match3, start3, end2) => {
const attrs2 = getAttrs instanceof Function ? getAttrs(match3) : getAttrs;
const {
tr
} = state;
const m = match3.length - 1;
let markEnd = end2;
let markStart = start3;
if (match3[m]) {
const matchStart = start3 + match3[0].indexOf(match3[m - 1]);
const matchEnd = matchStart + match3[m - 1].length - 1;
const textStart = matchStart + match3[m - 1].lastIndexOf(match3[m]);
const textEnd = textStart + match3[m].length;
const excludedMarks = getMarksBetween(start3, end2, state).filter((item) => {
const {
excluded
} = item.mark.type;
return excluded.find((type) => type.name === markType.name);
}).filter((item) => item.end > matchStart);
if (excludedMarks.length) {
return false;
}
if (textEnd < matchEnd) {
tr.delete(textEnd, matchEnd);
}
if (textStart > matchStart) {
tr.delete(matchStart, textStart);
}
markStart = matchStart;
markEnd = markStart + match3[m].length;
}
tr.addMark(markStart, markEnd, markType.create(attrs2));
tr.removeStoredMark(markType);
return tr;
});
}
function nodeInputRule(regexp, type, getAttrs) {
return new InputRule(regexp, (state, match3, start3, end2) => {
const attrs2 = getAttrs instanceof Function ? getAttrs(match3) : getAttrs;
const {
tr
} = state;
if (match3[0]) {
tr.replaceWith(start3 - 1, end2, type.create(attrs2));
}
return tr;
});
}
function pasteRule(regexp, type, getAttrs) {
const handler = (fragment) => {
const nodes = [];
fragment.forEach((child3) => {
if (child3.isText) {
const {
text: text3
} = child3;
let pos = 0;
let match3;
do {
match3 = regexp.exec(text3);
if (match3) {
const start3 = match3.index;
const end2 = start3 + match3[0].length;
const attrs2 = getAttrs instanceof Function ? getAttrs(match3[0]) : getAttrs;
if (start3 > 0) {
nodes.push(child3.cut(pos, start3));
}
nodes.push(child3.cut(start3, end2).mark(type.create(attrs2).addToSet(child3.marks)));
pos = end2;
}
} while (match3);
if (pos < text3.length) {
nodes.push(child3.cut(pos));
}
} else {
nodes.push(child3.copy(handler(child3.content)));
}
});
return Fragment.fromArray(nodes);
};
return new Plugin({
props: {
transformPasted: (slice5) => new Slice(handler(slice5.content), slice5.openStart, slice5.openEnd)
}
});
}
function markPasteRule(regexp, type, getAttrs) {
const handler = (fragment, parent) => {
const nodes = [];
fragment.forEach((child3) => {
if (child3.isText) {
const {
text: text3,
marks: marks2
} = child3;
let pos = 0;
let match3;
const isLink = !!marks2.filter((x) => x.type.name === "link")[0];
while (!isLink && (match3 = regexp.exec(text3)) !== null) {
if (parent && parent.type.allowsMarkType(type) && match3[1]) {
const start3 = match3.index;
const end2 = start3 + match3[0].length;
const textStart = start3 + match3[0].indexOf(match3[1]);
const textEnd = textStart + match3[1].length;
const attrs2 = getAttrs instanceof Function ? getAttrs(match3) : getAttrs;
if (start3 > 0) {
nodes.push(child3.cut(pos, start3));
}
nodes.push(child3.cut(textStart, textEnd).mark(type.create(attrs2).addToSet(child3.marks)));
pos = end2;
}
}
if (pos < text3.length) {
nodes.push(child3.cut(pos));
}
} else {
nodes.push(child3.copy(handler(child3.content, child3)));
}
});
return Fragment.fromArray(nodes);
};
return new Plugin({
props: {
transformPasted: (slice5) => new Slice(handler(slice5.content), slice5.openStart, slice5.openEnd)
}
});
}
function removeMark(type) {
return (state, dispatch2) => {
const {
tr,
selection
} = state;
let {
from: from4,
to
} = selection;
const {
$from,
empty: empty2
} = selection;
if (empty2) {
const range2 = getMarkRange($from, type);
from4 = range2.from;
to = range2.to;
}
tr.removeMark(from4, to, type);
return dispatch2(tr);
};
}
function toggleBlockType(type, toggletype, attrs2 = {}) {
return (state, dispatch2, view) => {
const isActive = nodeIsActive(state, type, attrs2);
if (isActive) {
return setBlockType(toggletype)(state, dispatch2, view);
}
return setBlockType(type, attrs2)(state, dispatch2, view);
};
}
function isList(node4, schema) {
return node4.type === schema.nodes.bullet_list || node4.type === schema.nodes.ordered_list || node4.type === schema.nodes.todo_list;
}
function toggleList(listType, itemType) {
return (state, dispatch2, view) => {
const {
schema,
selection
} = state;
const {
$from,
$to
} = selection;
const range2 = $from.blockRange($to);
if (!range2) {
return false;
}
const parentList = findParentNode((node4) => isList(node4, schema))(selection);
if (range2.depth >= 1 && parentList && range2.depth - parentList.depth <= 1) {
if (parentList.node.type === listType) {
return liftListItem(itemType)(state, dispatch2, view);
}
if (isList(parentList.node, schema) && listType.validContent(parentList.node.content)) {
const {
tr
} = state;
tr.setNodeMarkup(parentList.pos, listType);
if (dispatch2) {
dispatch2(tr);
}
return false;
}
}
return wrapInList(listType)(state, dispatch2, view);
};
}
function updateMark(type, attrs2) {
return (state, dispatch2) => {
const {
tr,
selection,
doc: doc2
} = state;
const {
ranges,
empty: empty2
} = selection;
if (empty2) {
const {
from: from4,
to
} = getMarkRange(selection.$from, type);
if (doc2.rangeHasMark(from4, to, type)) {
tr.removeMark(from4, to, type);
}
tr.addMark(from4, to, type.create(attrs2));
} else {
ranges.forEach((ref$12) => {
const {
$to,
$from
} = ref$12;
if (doc2.rangeHasMark($from.pos, $to.pos, type)) {
tr.removeMark($from.pos, $to.pos, type);
}
tr.addMark($from.pos, $to.pos, type.create(attrs2));
});
}
return dispatch2(tr);
};
}
function camelCase(str2) {
return str2.replace(/(?:^\w|[A-Z]|\b\w)/g, (word, index3) => index3 === 0 ? word.toLowerCase() : word.toUpperCase()).replace(/\s+/g, "");
}
class ComponentView {
constructor(component, {
editor,
extension,
parent,
node: node4,
view,
decorations,
getPos
}) {
this.component = component;
this.editor = editor;
this.extension = extension;
this.parent = parent;
this.node = node4;
this.view = view;
this.decorations = decorations;
this.isNode = !!this.node.marks;
this.isMark = !this.isNode;
this.getPos = this.isMark ? this.getMarkPos : getPos;
this.captureEvents = true;
this.dom = this.createDOM();
this.contentDOM = this.vm.$refs.content;
}
createDOM() {
const Component = Vue.extend(this.component);
const props2 = {
editor: this.editor,
node: this.node,
view: this.view,
getPos: () => this.getPos(),
decorations: this.decorations,
selected: false,
options: this.extension.options,
updateAttrs: (attrs2) => this.updateAttrs(attrs2)
};
if (typeof this.extension.setSelection === "function") {
this.setSelection = this.extension.setSelection;
}
if (typeof this.extension.update === "function") {
this.update = this.extension.update;
}
this.vm = new Component({
parent: this.parent,
propsData: props2
}).$mount();
return this.vm.$el;
}
update(node4, decorations) {
if (node4.type !== this.node.type) {
return false;
}
if (node4 === this.node && this.decorations === decorations) {
return true;
}
this.node = node4;
this.decorations = decorations;
this.updateComponentProps({
node: node4,
decorations
});
return true;
}
updateComponentProps(props2) {
if (!this.vm._props) {
return;
}
const originalSilent = Vue.config.silent;
Vue.config.silent = true;
Object.entries(props2).forEach(([key, value]) => {
this.vm._props[key] = value;
});
Vue.config.silent = originalSilent;
}
updateAttrs(attrs2) {
if (!this.view.editable) {
return;
}
const {
state
} = this.view;
const {
type
} = this.node;
const pos = this.getPos();
const newAttrs = __assign(__assign({}, this.node.attrs), attrs2);
const transaction = this.isMark ? state.tr.removeMark(pos.from, pos.to, type).addMark(pos.from, pos.to, type.create(newAttrs)) : state.tr.setNodeMarkup(pos, null, newAttrs);
this.view.dispatch(transaction);
}
ignoreMutation(mutation) {
if (mutation.type === "selection") {
return false;
}
if (!this.contentDOM) {
return true;
}
return !this.contentDOM.contains(mutation.target);
}
stopEvent(event) {
if (typeof this.extension.stopEvent === "function") {
return this.extension.stopEvent(event);
}
const draggable = !!this.extension.schema.draggable;
if (draggable && event.type === "mousedown") {
const dragHandle = event.target.closest && event.target.closest("[data-drag-handle]");
const isValidDragHandle = dragHandle && (this.dom === dragHandle || this.dom.contains(dragHandle));
if (isValidDragHandle) {
this.captureEvents = false;
document.addEventListener("dragend", () => {
this.captureEvents = true;
}, {
once: true
});
}
}
const isCopy = event.type === "copy";
const isPaste = event.type === "paste";
const isCut = event.type === "cut";
const isDrag = event.type.startsWith("drag") || event.type === "drop";
if (draggable && isDrag || isCopy || isPaste || isCut) {
return false;
}
return this.captureEvents;
}
selectNode() {
this.updateComponentProps({
selected: true
});
}
deselectNode() {
this.updateComponentProps({
selected: false
});
}
getMarkPos() {
const pos = this.view.posAtDOM(this.dom);
const resolvedPos = this.view.state.doc.resolve(pos);
const range2 = getMarkRange(resolvedPos, this.node.type);
return range2;
}
destroy() {
this.vm.$destroy();
}
}
class Emitter$1 {
on(event, fn) {
this._callbacks = this._callbacks || {};
if (!this._callbacks[event]) {
this._callbacks[event] = [];
}
this._callbacks[event].push(fn);
return this;
}
emit(event, ...args) {
this._callbacks = this._callbacks || {};
const callbacks2 = this._callbacks[event];
if (callbacks2) {
callbacks2.forEach((callback) => callback.apply(this, args));
}
return this;
}
off(event, fn) {
if (!arguments.length) {
this._callbacks = {};
} else {
const callbacks2 = this._callbacks ? this._callbacks[event] : null;
if (callbacks2) {
if (fn) {
this._callbacks[event] = callbacks2.filter((cb2) => cb2 !== fn);
} else {
delete this._callbacks[event];
}
}
}
return this;
}
}
class Extension {
constructor(options = {}) {
this.options = __assign(__assign({}, this.defaultOptions), options);
}
init() {
return null;
}
bindEditor(editor = null) {
this.editor = editor;
}
get name() {
return null;
}
get type() {
return "extension";
}
get defaultOptions() {
return {};
}
get plugins() {
return [];
}
inputRules() {
return [];
}
pasteRules() {
return [];
}
keys() {
return {};
}
}
class ExtensionManager {
constructor(extensions = [], editor) {
extensions.forEach((extension) => {
extension.bindEditor(editor);
extension.init();
});
this.extensions = extensions;
}
get nodes() {
return this.extensions.filter((extension) => extension.type === "node").reduce((nodes, {
name,
schema
}) => __assign(__assign({}, nodes), {
[name]: schema
}), {});
}
get options() {
const {
view
} = this;
return this.extensions.reduce((nodes, extension) => __assign(__assign({}, nodes), {
[extension.name]: new Proxy(extension.options, {
set(obj, prop, value) {
const changed = obj[prop] !== value;
Object.assign(obj, {
[prop]: value
});
if (changed) {
view.updateState(view.state);
}
return true;
}
})
}), {});
}
get marks() {
return this.extensions.filter((extension) => extension.type === "mark").reduce((marks2, {
name,
schema
}) => __assign(__assign({}, marks2), {
[name]: schema
}), {});
}
get plugins() {
return this.extensions.filter((extension) => extension.plugins).reduce((allPlugins, {
plugins: plugins2
}) => [...allPlugins, ...plugins2], []);
}
keymaps({
schema
}) {
const extensionKeymaps = this.extensions.filter((extension) => ["extension"].includes(extension.type)).filter((extension) => extension.keys).map((extension) => extension.keys({
schema
}));
const nodeMarkKeymaps = this.extensions.filter((extension) => ["node", "mark"].includes(extension.type)).filter((extension) => extension.keys).map((extension) => extension.keys({
type: schema["".concat(extension.type, "s")][extension.name],
schema
}));
return [...extensionKeymaps, ...nodeMarkKeymaps].map((keys2) => keymap(keys2));
}
inputRules({
schema,
excludedExtensions
}) {
if (!(excludedExtensions instanceof Array) && excludedExtensions)
return [];
const allowedExtensions = excludedExtensions instanceof Array ? this.extensions.filter((extension) => !excludedExtensions.includes(extension.name)) : this.extensions;
const extensionInputRules = allowedExtensions.filter((extension) => ["extension"].includes(extension.type)).filter((extension) => extension.inputRules).map((extension) => extension.inputRules({
schema
}));
const nodeMarkInputRules = allowedExtensions.filter((extension) => ["node", "mark"].includes(extension.type)).filter((extension) => extension.inputRules).map((extension) => extension.inputRules({
type: schema["".concat(extension.type, "s")][extension.name],
schema
}));
return [...extensionInputRules, ...nodeMarkInputRules].reduce((allInputRules, inputRules2) => [...allInputRules, ...inputRules2], []);
}
pasteRules({
schema,
excludedExtensions
}) {
if (!(excludedExtensions instanceof Array) && excludedExtensions)
return [];
const allowedExtensions = excludedExtensions instanceof Array ? this.extensions.filter((extension) => !excludedExtensions.includes(extension.name)) : this.extensions;
const extensionPasteRules = allowedExtensions.filter((extension) => ["extension"].includes(extension.type)).filter((extension) => extension.pasteRules).map((extension) => extension.pasteRules({
schema
}));
const nodeMarkPasteRules = allowedExtensions.filter((extension) => ["node", "mark"].includes(extension.type)).filter((extension) => extension.pasteRules).map((extension) => extension.pasteRules({
type: schema["".concat(extension.type, "s")][extension.name],
schema
}));
return [...extensionPasteRules, ...nodeMarkPasteRules].reduce((allPasteRules, pasteRules) => [...allPasteRules, ...pasteRules], []);
}
commands({
schema,
view
}) {
return this.extensions.filter((extension) => extension.commands).reduce((allCommands, extension) => {
const {
name,
type
} = extension;
const commands = {};
const value = extension.commands(__assign({
schema
}, ["node", "mark"].includes(type) ? {
type: schema["".concat(type, "s")][name]
} : {}));
const apply8 = (cb2, attrs2) => {
if (!view.editable) {
return false;
}
view.focus();
return cb2(attrs2)(view.state, view.dispatch, view);
};
const handle = (_name, _value) => {
if (Array.isArray(_value)) {
commands[_name] = (attrs2) => _value.forEach((callback) => apply8(callback, attrs2));
} else if (typeof _value === "function") {
commands[_name] = (attrs2) => apply8(_value, attrs2);
}
};
if (typeof value === "object") {
Object.entries(value).forEach(([commandName, commandValue]) => {
handle(commandName, commandValue);
});
} else {
handle(name, value);
}
return __assign(__assign({}, allCommands), commands);
}, {});
}
}
function injectCSS(css2) {
{
const style2 = document.createElement("style");
style2.type = "text/css";
style2.textContent = css2;
const {
head
} = document;
const {
firstChild
} = head;
if (firstChild) {
head.insertBefore(style2, firstChild);
} else {
head.appendChild(style2);
}
}
}
class Mark2 extends Extension {
constructor(options = {}) {
super(options);
}
get type() {
return "mark";
}
get view() {
return null;
}
get schema() {
return null;
}
command() {
return () => {
};
}
}
function minMax(value = 0, min3 = 0, max3 = 0) {
return Math.min(Math.max(parseInt(value, 10), min3), max3);
}
class Node$1 extends Extension {
constructor(options = {}) {
super(options);
}
get type() {
return "node";
}
get view() {
return null;
}
get schema() {
return null;
}
command() {
return () => {
};
}
}
class Doc extends Node$1 {
get name() {
return "doc";
}
get schema() {
return {
content: "block+"
};
}
}
class Paragraph extends Node$1 {
get name() {
return "paragraph";
}
get schema() {
return {
content: "inline*",
group: "block",
draggable: false,
parseDOM: [{
tag: "p"
}],
toDOM: () => ["p", 0]
};
}
commands({
type
}) {
return () => setBlockType(type);
}
}
class Text extends Node$1 {
get name() {
return "text";
}
get schema() {
return {
group: "inline"
};
}
}
var css$1 = '.ProseMirror {\n position: relative;\n}\n\n.ProseMirror {\n word-wrap: break-word;\n white-space: pre-wrap;\n -webkit-font-variant-ligatures: none;\n font-variant-ligatures: none;\n}\n\n.ProseMirror pre {\n white-space: pre-wrap;\n}\n\n.ProseMirror-gapcursor {\n display: none;\n pointer-events: none;\n position: absolute;\n}\n\n.ProseMirror-gapcursor:after {\n content: "";\n display: block;\n position: absolute;\n top: -2px;\n width: 20px;\n border-top: 1px solid black;\n animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;\n}\n\n@keyframes ProseMirror-cursor-blink {\n to {\n visibility: hidden;\n }\n}\n\n.ProseMirror-hideselection *::selection {\n background: transparent;\n}\n\n.ProseMirror-hideselection *::-moz-selection {\n background: transparent;\n}\n\n.ProseMirror-hideselection * {\n caret-color: transparent;\n}\n\n.ProseMirror-focused .ProseMirror-gapcursor {\n display: block;\n}\n';
class Editor extends Emitter$1 {
constructor(options = {}) {
super();
this.defaultOptions = {
editorProps: {},
editable: true,
autoFocus: null,
extensions: [],
content: "",
topNode: "doc",
emptyDocument: {
type: "doc",
content: [{
type: "paragraph"
}]
},
useBuiltInExtensions: true,
disableInputRules: false,
disablePasteRules: false,
dropCursor: {},
enableDropCursor: true,
enableGapCursor: true,
parseOptions: {},
injectCSS: true,
onInit: () => {
},
onTransaction: () => {
},
onUpdate: () => {
},
onFocus: () => {
},
onBlur: () => {
},
onPaste: () => {
},
onDrop: () => {
}
};
this.events = ["init", "transaction", "update", "focus", "blur", "paste", "drop"];
this.init(options);
}
init(options = {}) {
this.setOptions(__assign(__assign({}, this.defaultOptions), options));
this.focused = false;
this.selection = {
from: 0,
to: 0
};
this.element = document.createElement("div");
this.extensions = this.createExtensions();
this.nodes = this.createNodes();
this.marks = this.createMarks();
this.schema = this.createSchema();
this.plugins = this.createPlugins();
this.keymaps = this.createKeymaps();
this.inputRules = this.createInputRules();
this.pasteRules = this.createPasteRules();
this.view = this.createView();
this.commands = this.createCommands();
this.setActiveNodesAndMarks();
if (this.options.injectCSS) {
injectCSS(css$1);
}
if (this.options.autoFocus !== null) {
this.focus(this.options.autoFocus);
}
this.events.forEach((name) => {
this.on(name, this.options[camelCase("on ".concat(name))] || (() => {
}));
});
this.emit("init", {
view: this.view,
state: this.state
});
this.extensions.view = this.view;
}
setOptions(options) {
this.options = __assign(__assign({}, this.options), options);
if (this.view && this.state) {
this.view.updateState(this.state);
}
}
get builtInExtensions() {
if (!this.options.useBuiltInExtensions) {
return [];
}
return [new Doc(), new Text(), new Paragraph()];
}
get state() {
return this.view ? this.view.state : null;
}
createExtensions() {
return new ExtensionManager([...this.builtInExtensions, ...this.options.extensions], this);
}
createPlugins() {
return this.extensions.plugins;
}
createKeymaps() {
return this.extensions.keymaps({
schema: this.schema
});
}
createInputRules() {
return this.extensions.inputRules({
schema: this.schema,
excludedExtensions: this.options.disableInputRules
});
}
createPasteRules() {
return this.extensions.pasteRules({
schema: this.schema,
excludedExtensions: this.options.disablePasteRules
});
}
createCommands() {
return this.extensions.commands({
schema: this.schema,
view: this.view
});
}
createNodes() {
return this.extensions.nodes;
}
createMarks() {
return this.extensions.marks;
}
createSchema() {
return new Schema({
topNode: this.options.topNode,
nodes: this.nodes,
marks: this.marks
});
}
createState() {
return EditorState.create({
schema: this.schema,
doc: this.createDocument(this.options.content),
plugins: [...this.plugins, inputRules({
rules: this.inputRules
}), ...this.pasteRules, ...this.keymaps, keymap({
Backspace: undoInputRule
}), keymap(baseKeymap), ...this.options.enableDropCursor ? [dropCursor(this.options.dropCursor)] : [], ...this.options.enableGapCursor ? [gapCursor()] : [], new Plugin({
key: new PluginKey("editable"),
props: {
editable: () => this.options.editable
}
}), new Plugin({
props: {
attributes: {
tabindex: 0
},
handleDOMEvents: {
focus: (view, event) => {
this.focused = true;
this.emit("focus", {
event,
state: view.state,
view
});
const transaction = this.state.tr.setMeta("focused", true);
this.view.dispatch(transaction);
},
blur: (view, event) => {
this.focused = false;
this.emit("blur", {
event,
state: view.state,
view
});
const transaction = this.state.tr.setMeta("focused", false);
this.view.dispatch(transaction);
}
}
}
}), new Plugin({
props: this.options.editorProps
})]
});
}
createDocument(content2, parseOptions = this.options.parseOptions) {
if (content2 === null) {
return this.schema.nodeFromJSON(this.options.emptyDocument);
}
if (typeof content2 === "object") {
try {
return this.schema.nodeFromJSON(content2);
} catch (error2) {
console.warn("[tiptap warn]: Invalid content.", "Passed value:", content2, "Error:", error2);
return this.schema.nodeFromJSON(this.options.emptyDocument);
}
}
if (typeof content2 === "string") {
const htmlString = "<div>".concat(content2, "</div>");
const parser = new window.DOMParser();
const element = parser.parseFromString(htmlString, "text/html").body.firstElementChild;
return DOMParser.fromSchema(this.schema).parse(element, parseOptions);
}
return false;
}
createView() {
return new EditorView(this.element, {
state: this.createState(),
handlePaste: (...args) => {
this.emit("paste", ...args);
},
handleDrop: (...args) => {
this.emit("drop", ...args);
},
dispatchTransaction: this.dispatchTransaction.bind(this)
});
}
setParentComponent(component = null) {
if (!component) {
return;
}
this.view.setProps({
nodeViews: this.initNodeViews({
parent: component,
extensions: [...this.builtInExtensions, ...this.options.extensions]
})
});
}
initNodeViews({
parent,
extensions
}) {
return extensions.filter((extension) => ["node", "mark"].includes(extension.type)).filter((extension) => extension.view).reduce((nodeViews, extension) => {
const nodeView = (node4, view, getPos, decorations) => {
const component = extension.view;
return new ComponentView(component, {
editor: this,
extension,
parent,
node: node4,
view,
getPos,
decorations
});
};
return __assign(__assign({}, nodeViews), {
[extension.name]: nodeView
});
}, {});
}
dispatchTransaction(transaction) {
const newState = this.state.apply(transaction);
this.view.updateState(newState);
this.selection = {
from: this.state.selection.from,
to: this.state.selection.to
};
this.setActiveNodesAndMarks();
this.emit("transaction", {
getHTML: this.getHTML.bind(this),
getJSON: this.getJSON.bind(this),
state: this.state,
transaction
});
if (!transaction.docChanged || transaction.getMeta("preventUpdate")) {
return;
}
this.emitUpdate(transaction);
}
emitUpdate(transaction) {
this.emit("update", {
getHTML: this.getHTML.bind(this),
getJSON: this.getJSON.bind(this),
state: this.state,
transaction
});
}
resolveSelection(position = null) {
if (this.selection && position === null) {
return this.selection;
}
if (position === "start" || position === true) {
return {
from: 0,
to: 0
};
}
if (position === "end") {
const {
doc: doc2
} = this.state;
return {
from: doc2.content.size,
to: doc2.content.size
};
}
return {
from: position,
to: position
};
}
focus(position = null) {
if (this.view.focused && position === null || position === false) {
return;
}
const {
from: from4,
to
} = this.resolveSelection(position);
this.setSelection(from4, to);
setTimeout(() => this.view.focus(), 10);
}
setSelection(from4 = 0, to = 0) {
const {
doc: doc2,
tr
} = this.state;
const resolvedFrom = minMax(from4, 0, doc2.content.size);
const resolvedEnd = minMax(to, 0, doc2.content.size);
const selection = TextSelection.create(doc2, resolvedFrom, resolvedEnd);
const transaction = tr.setSelection(selection);
this.view.dispatch(transaction);
}
blur() {
this.view.dom.blur();
}
getSchemaJSON() {
return JSON.parse(JSON.stringify({
nodes: this.extensions.nodes,
marks: this.extensions.marks
}));
}
getHTML() {
const div2 = document.createElement("div");
const fragment = DOMSerializer.fromSchema(this.schema).serializeFragment(this.state.doc.content);
div2.appendChild(fragment);
return div2.innerHTML;
}
getJSON() {
return this.state.doc.toJSON();
}
setContent(content2 = {}, emitUpdate = false, parseOptions) {
const {
doc: doc2,
tr
} = this.state;
const document2 = this.createDocument(content2, parseOptions);
const selection = TextSelection.create(doc2, 0, doc2.content.size);
const transaction = tr.setSelection(selection).replaceSelectionWith(document2, false).setMeta("preventUpdate", !emitUpdate);
this.view.dispatch(transaction);
}
clearContent(emitUpdate = false) {
this.setContent(this.options.emptyDocument, emitUpdate);
}
setActiveNodesAndMarks() {
this.activeMarks = Object.entries(this.schema.marks).reduce((marks2, [name, mark3]) => __assign(__assign({}, marks2), {
[name]: (attrs2 = {}) => markIsActive(this.state, mark3)
}), {});
this.activeMarkAttrs = Object.entries(this.schema.marks).reduce((marks2, [name, mark3]) => __assign(__assign({}, marks2), {
[name]: getMarkAttrs(this.state, mark3)
}), {});
this.activeNodes = Object.entries(this.schema.nodes).reduce((nodes, [name, node4]) => __assign(__assign({}, nodes), {
[name]: (attrs2 = {}) => nodeIsActive(this.state, node4, attrs2)
}), {});
}
getMarkAttrs(type = null) {
return this.activeMarkAttrs[type];
}
getNodeAttrs(type = null) {
return __assign({}, getNodeAttrs(this.state, this.schema.nodes[type]));
}
get isActive() {
return Object.entries(__assign(__assign({}, this.activeMarks), this.activeNodes)).reduce((types, [name, value]) => __assign(__assign({}, types), {
[name]: (attrs2 = {}) => value(attrs2)
}), {});
}
registerPlugin(plugin = null, handlePlugins) {
const plugins2 = typeof handlePlugins === "function" ? handlePlugins(plugin, this.state.plugins) : [plugin, ...this.state.plugins];
const newState = this.state.reconfigure({
plugins: plugins2
});
this.view.updateState(newState);
}
unregisterPlugin(name = null) {
if (!name || !this.view.docView) {
return;
}
const newState = this.state.reconfigure({
plugins: this.state.plugins.filter((plugin) => !plugin.key.startsWith("".concat(name, "$")))
});
this.view.updateState(newState);
}
destroy() {
if (!this.view) {
return;
}
this.view.destroy();
}
}
var EditorContent = {
props: {
editor: {
default: null,
type: Object
}
},
watch: {
editor: {
immediate: true,
handler(editor) {
if (editor && editor.element) {
this.$nextTick(() => {
this.$el.appendChild(editor.element.firstChild);
editor.setParentComponent(this);
});
}
}
}
},
render(createElement2) {
return createElement2("div");
},
beforeDestroy() {
this.editor.element = this.$el;
}
};
function textRange(node4, from4, to) {
const range2 = document.createRange();
range2.setEnd(node4, to == null ? node4.nodeValue.length : to);
range2.setStart(node4, from4 || 0);
return range2;
}
function singleRect(object2, bias) {
const rects = object2.getClientRects();
return !rects.length ? object2.getBoundingClientRect() : rects[bias < 0 ? 0 : rects.length - 1];
}
function coordsAtPos(view, pos, end2 = false) {
const {
node: node4,
offset: offset2
} = view.docView.domFromPos(pos);
let side;
let rect;
if (node4.nodeType === 3) {
if (end2 && offset2 < node4.nodeValue.length) {
rect = singleRect(textRange(node4, offset2 - 1, offset2), -1);
side = "right";
} else if (offset2 < node4.nodeValue.length) {
rect = singleRect(textRange(node4, offset2, offset2 + 1), -1);
side = "left";
}
} else if (node4.firstChild) {
if (offset2 < node4.childNodes.length) {
const child3 = node4.childNodes[offset2];
rect = singleRect(child3.nodeType === 3 ? textRange(child3) : child3, -1);
side = "left";
}
if ((!rect || rect.top === rect.bottom) && offset2) {
const child3 = node4.childNodes[offset2 - 1];
rect = singleRect(child3.nodeType === 3 ? textRange(child3) : child3, 1);
side = "right";
}
} else {
rect = node4.getBoundingClientRect();
side = "left";
}
const x = rect[side];
return {
top: rect.top,
bottom: rect.bottom,
left: x,
right: x
};
}
class Menu$1 {
constructor({
options,
editorView
}) {
this.options = __assign(__assign({}, {
element: null,
keepInBounds: true,
onUpdate: () => false
}), options);
this.editorView = editorView;
this.isActive = false;
this.left = 0;
this.bottom = 0;
this.top = 0;
this.preventHide = false;
this.mousedownHandler = this.handleClick.bind(this);
this.options.element.addEventListener("mousedown", this.mousedownHandler, {
capture: true
});
this.focusHandler = ({
view
}) => {
this.update(view);
};
this.options.editor.on("focus", this.focusHandler);
this.blurHandler = ({
event
}) => {
if (this.preventHide) {
this.preventHide = false;
return;
}
this.hide(event);
};
this.options.editor.on("blur", this.blurHandler);
}
handleClick() {
this.preventHide = true;
}
update(view, lastState) {
const {
state
} = view;
if (view.composing) {
return;
}
if (lastState && lastState.doc.eq(state.doc) && lastState.selection.eq(state.selection)) {
return;
}
if (state.selection.empty) {
this.hide();
return;
}
const {
from: from4,
to
} = state.selection;
const start3 = coordsAtPos(view, from4);
const end2 = coordsAtPos(view, to, true);
const parent = this.options.element.offsetParent;
if (!parent) {
this.hide();
return;
}
const box = parent.getBoundingClientRect();
const el = this.options.element.getBoundingClientRect();
const left = (start3.left + end2.left) / 2 - box.left;
this.left = Math.round(this.options.keepInBounds ? Math.min(box.width - el.width / 2, Math.max(left, el.width / 2)) : left);
this.bottom = Math.round(box.bottom - start3.top);
this.top = Math.round(end2.bottom - box.top);
this.isActive = true;
this.sendUpdate();
}
sendUpdate() {
this.options.onUpdate({
isActive: this.isActive,
left: this.left,
bottom: this.bottom,
top: this.top
});
}
hide(event) {
if (event && event.relatedTarget && this.options.element.parentNode && this.options.element.parentNode.contains(event.relatedTarget)) {
return;
}
this.isActive = false;
this.sendUpdate();
}
destroy() {
this.options.element.removeEventListener("mousedown", this.mousedownHandler);
this.options.editor.off("focus", this.focusHandler);
this.options.editor.off("blur", this.blurHandler);
}
}
function MenuBubble(options) {
return new Plugin({
key: new PluginKey("menu_bubble"),
view(editorView) {
return new Menu$1({
editorView,
options
});
}
});
}
var EditorMenuBubble = {
props: {
editor: {
default: null,
type: Object
},
keepInBounds: {
default: true,
type: Boolean
}
},
data() {
return {
menu: {
isActive: false,
left: 0,
bottom: 0
}
};
},
watch: {
editor: {
immediate: true,
handler(editor) {
if (editor) {
this.$nextTick(() => {
editor.registerPlugin(MenuBubble({
editor,
element: this.$el,
keepInBounds: this.keepInBounds,
onUpdate: (menu) => {
if (menu.isActive && this.menu.isActive === false) {
this.$emit("show", menu);
} else if (!menu.isActive && this.menu.isActive === true) {
this.$emit("hide", menu);
}
this.menu = menu;
}
}));
});
}
}
}
},
render() {
if (!this.editor) {
return null;
}
return this.$scopedSlots.default({
focused: this.editor.view.focused,
focus: this.editor.focus,
commands: this.editor.commands,
isActive: this.editor.isActive,
getMarkAttrs: this.editor.getMarkAttrs.bind(this.editor),
getNodeAttrs: this.editor.getNodeAttrs.bind(this.editor),
menu: this.menu
});
},
beforeDestroy() {
this.editor.unregisterPlugin("menu_bubble");
}
};
function deepFreeze(obj) {
if (obj instanceof Map) {
obj.clear = obj.delete = obj.set = function() {
throw new Error("map is read-only");
};
} else if (obj instanceof Set) {
obj.add = obj.clear = obj.delete = function() {
throw new Error("set is read-only");
};
}
Object.freeze(obj);
Object.getOwnPropertyNames(obj).forEach(function(name) {
var prop = obj[name];
if (typeof prop == "object" && !Object.isFrozen(prop)) {
deepFreeze(prop);
}
});
return obj;
}
var deepFreezeEs6 = deepFreeze;
var _default = deepFreeze;
deepFreezeEs6.default = _default;
class Response {
constructor(mode) {
if (mode.data === void 0)
mode.data = {};
this.data = mode.data;
this.isMatchIgnored = false;
}
ignoreMatch() {
this.isMatchIgnored = true;
}
}
function escapeHTML(value) {
return value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#x27;");
}
function inherit(original, ...objects) {
const result2 = Object.create(null);
for (const key in original) {
result2[key] = original[key];
}
objects.forEach(function(obj) {
for (const key in obj) {
result2[key] = obj[key];
}
});
return result2;
}
const SPAN_CLOSE = "</span>";
const emitsWrappingTags = (node4) => {
return !!node4.kind;
};
class HTMLRenderer {
constructor(parseTree, options) {
this.buffer = "";
this.classPrefix = options.classPrefix;
parseTree.walk(this);
}
addText(text3) {
this.buffer += escapeHTML(text3);
}
openNode(node4) {
if (!emitsWrappingTags(node4))
return;
let className = node4.kind;
if (!node4.sublanguage) {
className = `${this.classPrefix}${className}`;
}
this.span(className);
}
closeNode(node4) {
if (!emitsWrappingTags(node4))
return;
this.buffer += SPAN_CLOSE;
}
value() {
return this.buffer;
}
span(className) {
this.buffer += `<span class="${className}">`;
}
}
class TokenTree {
constructor() {
this.rootNode = {children: []};
this.stack = [this.rootNode];
}
get top() {
return this.stack[this.stack.length - 1];
}
get root() {
return this.rootNode;
}
add(node4) {
this.top.children.push(node4);
}
openNode(kind) {
const node4 = {kind, children: []};
this.add(node4);
this.stack.push(node4);
}
closeNode() {
if (this.stack.length > 1) {
return this.stack.pop();
}
return void 0;
}
closeAllNodes() {
while (this.closeNode())
;
}
toJSON() {
return JSON.stringify(this.rootNode, null, 4);
}
walk(builder) {
return this.constructor._walk(builder, this.rootNode);
}
static _walk(builder, node4) {
if (typeof node4 === "string") {
builder.addText(node4);
} else if (node4.children) {
builder.openNode(node4);
node4.children.forEach((child3) => this._walk(builder, child3));
builder.closeNode(node4);
}
return builder;
}
static _collapse(node4) {
if (typeof node4 === "string")
return;
if (!node4.children)
return;
if (node4.children.every((el) => typeof el === "string")) {
node4.children = [node4.children.join("")];
} else {
node4.children.forEach((child3) => {
TokenTree._collapse(child3);
});
}
}
}
class TokenTreeEmitter extends TokenTree {
constructor(options) {
super();
this.options = options;
}
addKeyword(text3, kind) {
if (text3 === "") {
return;
}
this.openNode(kind);
this.addText(text3);
this.closeNode();
}
addText(text3) {
if (text3 === "") {
return;
}
this.add(text3);
}
addSublanguage(emitter, name) {
const node4 = emitter.root;
node4.kind = name;
node4.sublanguage = true;
this.add(node4);
}
toHTML() {
const renderer = new HTMLRenderer(this, this.options);
return renderer.value();
}
finalize() {
return true;
}
}
function escape$1(value) {
return new RegExp(value.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&"), "m");
}
function source(re) {
if (!re)
return null;
if (typeof re === "string")
return re;
return re.source;
}
function concat(...args) {
const joined = args.map((x) => source(x)).join("");
return joined;
}
function either(...args) {
const joined = "(" + args.map((x) => source(x)).join("|") + ")";
return joined;
}
function countMatchGroups(re) {
return new RegExp(re.toString() + "|").exec("").length - 1;
}
function startsWith(re, lexeme) {
const match3 = re && re.exec(lexeme);
return match3 && match3.index === 0;
}
const BACKREF_RE = /\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;
function join(regexps, separator = "|") {
let numCaptures = 0;
return regexps.map((regex) => {
numCaptures += 1;
const offset2 = numCaptures;
let re = source(regex);
let out = "";
while (re.length > 0) {
const match3 = BACKREF_RE.exec(re);
if (!match3) {
out += re;
break;
}
out += re.substring(0, match3.index);
re = re.substring(match3.index + match3[0].length);
if (match3[0][0] === "\\" && match3[1]) {
out += "\\" + String(Number(match3[1]) + offset2);
} else {
out += match3[0];
if (match3[0] === "(") {
numCaptures++;
}
}
}
return out;
}).map((re) => `(${re})`).join(separator);
}
const MATCH_NOTHING_RE = /\b\B/;
const IDENT_RE = "[a-zA-Z]\\w*";
const UNDERSCORE_IDENT_RE = "[a-zA-Z_]\\w*";
const NUMBER_RE = "\\b\\d+(\\.\\d+)?";
const C_NUMBER_RE = "(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)";
const BINARY_NUMBER_RE = "\\b(0b[01]+)";
const RE_STARTERS_RE = "!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~";
const SHEBANG = (opts = {}) => {
const beginShebang = /^#![ ]*\//;
if (opts.binary) {
opts.begin = concat(beginShebang, /.*\b/, opts.binary, /\b.*/);
}
return inherit({
className: "meta",
begin: beginShebang,
end: /$/,
relevance: 0,
"on:begin": (m, resp) => {
if (m.index !== 0)
resp.ignoreMatch();
}
}, opts);
};
const BACKSLASH_ESCAPE = {
begin: "\\\\[\\s\\S]",
relevance: 0
};
const APOS_STRING_MODE = {
className: "string",
begin: "'",
end: "'",
illegal: "\\n",
contains: [BACKSLASH_ESCAPE]
};
const QUOTE_STRING_MODE = {
className: "string",
begin: '"',
end: '"',
illegal: "\\n",
contains: [BACKSLASH_ESCAPE]
};
const PHRASAL_WORDS_MODE = {
begin: /\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/
};
const COMMENT = function(begin, end2, modeOptions = {}) {
const mode = inherit({
className: "comment",
begin,
end: end2,
contains: []
}, modeOptions);
mode.contains.push(PHRASAL_WORDS_MODE);
mode.contains.push({
className: "doctag",
begin: "(?:TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):",
relevance: 0
});
return mode;
};
const C_LINE_COMMENT_MODE = COMMENT("//", "$");
const C_BLOCK_COMMENT_MODE = COMMENT("/\\*", "\\*/");
const HASH_COMMENT_MODE = COMMENT("#", "$");
const NUMBER_MODE = {
className: "number",
begin: NUMBER_RE,
relevance: 0
};
const C_NUMBER_MODE = {
className: "number",
begin: C_NUMBER_RE,
relevance: 0
};
const BINARY_NUMBER_MODE = {
className: "number",
begin: BINARY_NUMBER_RE,
relevance: 0
};
const CSS_NUMBER_MODE = {
className: "number",
begin: NUMBER_RE + "(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?",
relevance: 0
};
const REGEXP_MODE = {
begin: /(?=\/[^/\n]*\/)/,
contains: [{
className: "regexp",
begin: /\//,
end: /\/[gimuy]*/,
illegal: /\n/,
contains: [
BACKSLASH_ESCAPE,
{
begin: /\[/,
end: /\]/,
relevance: 0,
contains: [BACKSLASH_ESCAPE]
}
]
}]
};
const TITLE_MODE = {
className: "title",
begin: IDENT_RE,
relevance: 0
};
const UNDERSCORE_TITLE_MODE = {
className: "title",
begin: UNDERSCORE_IDENT_RE,
relevance: 0
};
const METHOD_GUARD = {
begin: "\\.\\s*" + UNDERSCORE_IDENT_RE,
relevance: 0
};
const END_SAME_AS_BEGIN = function(mode) {
return Object.assign(mode, {
"on:begin": (m, resp) => {
resp.data._beginMatch = m[1];
},
"on:end": (m, resp) => {
if (resp.data._beginMatch !== m[1])
resp.ignoreMatch();
}
});
};
var MODES = /* @__PURE__ */ Object.freeze({
__proto__: null,
MATCH_NOTHING_RE,
IDENT_RE,
UNDERSCORE_IDENT_RE,
NUMBER_RE,
C_NUMBER_RE,
BINARY_NUMBER_RE,
RE_STARTERS_RE,
SHEBANG,
BACKSLASH_ESCAPE,
APOS_STRING_MODE,
QUOTE_STRING_MODE,
PHRASAL_WORDS_MODE,
COMMENT,
C_LINE_COMMENT_MODE,
C_BLOCK_COMMENT_MODE,
HASH_COMMENT_MODE,
NUMBER_MODE,
C_NUMBER_MODE,
BINARY_NUMBER_MODE,
CSS_NUMBER_MODE,
REGEXP_MODE,
TITLE_MODE,
UNDERSCORE_TITLE_MODE,
METHOD_GUARD,
END_SAME_AS_BEGIN
});
function skipIfhasPrecedingDot(match3, response) {
const before3 = match3.input[match3.index - 1];
if (before3 === ".") {
response.ignoreMatch();
}
}
function beginKeywords(mode, parent) {
if (!parent)
return;
if (!mode.beginKeywords)
return;
mode.begin = "\\b(" + mode.beginKeywords.split(" ").join("|") + ")(?!\\.)(?=\\b|\\s)";
mode.__beforeBegin = skipIfhasPrecedingDot;
mode.keywords = mode.keywords || mode.beginKeywords;
delete mode.beginKeywords;
if (mode.relevance === void 0)
mode.relevance = 0;
}
function compileIllegal(mode, _parent) {
if (!Array.isArray(mode.illegal))
return;
mode.illegal = either(...mode.illegal);
}
function compileMatch(mode, _parent) {
if (!mode.match)
return;
if (mode.begin || mode.end)
throw new Error("begin & end are not supported with match");
mode.begin = mode.match;
delete mode.match;
}
function compileRelevance(mode, _parent) {
if (mode.relevance === void 0)
mode.relevance = 1;
}
const COMMON_KEYWORDS = [
"of",
"and",
"for",
"in",
"not",
"or",
"if",
"then",
"parent",
"list",
"value"
];
const DEFAULT_KEYWORD_CLASSNAME = "keyword";
function compileKeywords(rawKeywords, caseInsensitive, className = DEFAULT_KEYWORD_CLASSNAME) {
const compiledKeywords = {};
if (typeof rawKeywords === "string") {
compileList(className, rawKeywords.split(" "));
} else if (Array.isArray(rawKeywords)) {
compileList(className, rawKeywords);
} else {
Object.keys(rawKeywords).forEach(function(className2) {
Object.assign(compiledKeywords, compileKeywords(rawKeywords[className2], caseInsensitive, className2));
});
}
return compiledKeywords;
function compileList(className2, keywordList) {
if (caseInsensitive) {
keywordList = keywordList.map((x) => x.toLowerCase());
}
keywordList.forEach(function(keyword) {
const pair = keyword.split("|");
compiledKeywords[pair[0]] = [className2, scoreForKeyword(pair[0], pair[1])];
});
}
}
function scoreForKeyword(keyword, providedScore) {
if (providedScore) {
return Number(providedScore);
}
return commonKeyword(keyword) ? 0 : 1;
}
function commonKeyword(keyword) {
return COMMON_KEYWORDS.includes(keyword.toLowerCase());
}
function compileLanguage(language, {plugins: plugins2}) {
function langRe(value, global2) {
return new RegExp(source(value), "m" + (language.case_insensitive ? "i" : "") + (global2 ? "g" : ""));
}
class MultiRegex {
constructor() {
this.matchIndexes = {};
this.regexes = [];
this.matchAt = 1;
this.position = 0;
}
addRule(re, opts) {
opts.position = this.position++;
this.matchIndexes[this.matchAt] = opts;
this.regexes.push([opts, re]);
this.matchAt += countMatchGroups(re) + 1;
}
compile() {
if (this.regexes.length === 0) {
this.exec = () => null;
}
const terminators = this.regexes.map((el) => el[1]);
this.matcherRe = langRe(join(terminators), true);
this.lastIndex = 0;
}
exec(s) {
this.matcherRe.lastIndex = this.lastIndex;
const match3 = this.matcherRe.exec(s);
if (!match3) {
return null;
}
const i = match3.findIndex((el, i2) => i2 > 0 && el !== void 0);
const matchData = this.matchIndexes[i];
match3.splice(0, i);
return Object.assign(match3, matchData);
}
}
class ResumableMultiRegex {
constructor() {
this.rules = [];
this.multiRegexes = [];
this.count = 0;
this.lastIndex = 0;
this.regexIndex = 0;
}
getMatcher(index3) {
if (this.multiRegexes[index3])
return this.multiRegexes[index3];
const matcher2 = new MultiRegex();
this.rules.slice(index3).forEach(([re, opts]) => matcher2.addRule(re, opts));
matcher2.compile();
this.multiRegexes[index3] = matcher2;
return matcher2;
}
resumingScanAtSamePosition() {
return this.regexIndex !== 0;
}
considerAll() {
this.regexIndex = 0;
}
addRule(re, opts) {
this.rules.push([re, opts]);
if (opts.type === "begin")
this.count++;
}
exec(s) {
const m = this.getMatcher(this.regexIndex);
m.lastIndex = this.lastIndex;
let result2 = m.exec(s);
if (this.resumingScanAtSamePosition()) {
if (result2 && result2.index === this.lastIndex)
;
else {
const m2 = this.getMatcher(0);
m2.lastIndex = this.lastIndex + 1;
result2 = m2.exec(s);
}
}
if (result2) {
this.regexIndex += result2.position + 1;
if (this.regexIndex === this.count) {
this.considerAll();
}
}
return result2;
}
}
function buildModeRegex(mode) {
const mm = new ResumableMultiRegex();
mode.contains.forEach((term) => mm.addRule(term.begin, {rule: term, type: "begin"}));
if (mode.terminatorEnd) {
mm.addRule(mode.terminatorEnd, {type: "end"});
}
if (mode.illegal) {
mm.addRule(mode.illegal, {type: "illegal"});
}
return mm;
}
function compileMode(mode, parent) {
const cmode = mode;
if (mode.isCompiled)
return cmode;
[
compileMatch
].forEach((ext) => ext(mode, parent));
language.compilerExtensions.forEach((ext) => ext(mode, parent));
mode.__beforeBegin = null;
[
beginKeywords,
compileIllegal,
compileRelevance
].forEach((ext) => ext(mode, parent));
mode.isCompiled = true;
let keywordPattern = null;
if (typeof mode.keywords === "object") {
keywordPattern = mode.keywords.$pattern;
delete mode.keywords.$pattern;
}
if (mode.keywords) {
mode.keywords = compileKeywords(mode.keywords, language.case_insensitive);
}
if (mode.lexemes && keywordPattern) {
throw new Error("ERR: Prefer `keywords.$pattern` to `mode.lexemes`, BOTH are not allowed. (see mode reference) ");
}
keywordPattern = keywordPattern || mode.lexemes || /\w+/;
cmode.keywordPatternRe = langRe(keywordPattern, true);
if (parent) {
if (!mode.begin)
mode.begin = /\B|\b/;
cmode.beginRe = langRe(mode.begin);
if (mode.endSameAsBegin)
mode.end = mode.begin;
if (!mode.end && !mode.endsWithParent)
mode.end = /\B|\b/;
if (mode.end)
cmode.endRe = langRe(mode.end);
cmode.terminatorEnd = source(mode.end) || "";
if (mode.endsWithParent && parent.terminatorEnd) {
cmode.terminatorEnd += (mode.end ? "|" : "") + parent.terminatorEnd;
}
}
if (mode.illegal)
cmode.illegalRe = langRe(mode.illegal);
if (!mode.contains)
mode.contains = [];
mode.contains = [].concat(...mode.contains.map(function(c) {
return expandOrCloneMode(c === "self" ? mode : c);
}));
mode.contains.forEach(function(c) {
compileMode(c, cmode);
});
if (mode.starts) {
compileMode(mode.starts, parent);
}
cmode.matcher = buildModeRegex(cmode);
return cmode;
}
if (!language.compilerExtensions)
language.compilerExtensions = [];
if (language.contains && language.contains.includes("self")) {
throw new Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");
}
language.classNameAliases = inherit(language.classNameAliases || {});
return compileMode(language);
}
function dependencyOnParent(mode) {
if (!mode)
return false;
return mode.endsWithParent || dependencyOnParent(mode.starts);
}
function expandOrCloneMode(mode) {
if (mode.variants && !mode.cachedVariants) {
mode.cachedVariants = mode.variants.map(function(variant) {
return inherit(mode, {variants: null}, variant);
});
}
if (mode.cachedVariants) {
return mode.cachedVariants;
}
if (dependencyOnParent(mode)) {
return inherit(mode, {starts: mode.starts ? inherit(mode.starts) : null});
}
if (Object.isFrozen(mode)) {
return inherit(mode);
}
return mode;
}
var version$1 = "10.7.1";
function hasValueOrEmptyAttribute(value) {
return Boolean(value || value === "");
}
function BuildVuePlugin(hljs) {
const Component = {
props: ["language", "code", "autodetect"],
data: function() {
return {
detectedLanguage: "",
unknownLanguage: false
};
},
computed: {
className() {
if (this.unknownLanguage)
return "";
return "hljs " + this.detectedLanguage;
},
highlighted() {
if (!this.autoDetect && !hljs.getLanguage(this.language)) {
console.warn(`The language "${this.language}" you specified could not be found.`);
this.unknownLanguage = true;
return escapeHTML(this.code);
}
let result2 = {};
if (this.autoDetect) {
result2 = hljs.highlightAuto(this.code);
this.detectedLanguage = result2.language;
} else {
result2 = hljs.highlight(this.language, this.code, this.ignoreIllegals);
this.detectedLanguage = this.language;
}
return result2.value;
},
autoDetect() {
return !this.language || hasValueOrEmptyAttribute(this.autodetect);
},
ignoreIllegals() {
return true;
}
},
render(createElement2) {
return createElement2("pre", {}, [
createElement2("code", {
class: this.className,
domProps: {innerHTML: this.highlighted}
})
]);
}
};
const VuePlugin = {
install(Vue2) {
Vue2.component("highlightjs", Component);
}
};
return {Component, VuePlugin};
}
const mergeHTMLPlugin = {
"after:highlightElement": ({el, result: result2, text: text3}) => {
const originalStream = nodeStream(el);
if (!originalStream.length)
return;
const resultNode = document.createElement("div");
resultNode.innerHTML = result2.value;
result2.value = mergeStreams(originalStream, nodeStream(resultNode), text3);
}
};
function tag(node4) {
return node4.nodeName.toLowerCase();
}
function nodeStream(node4) {
const result2 = [];
(function _nodeStream(node5, offset2) {
for (let child3 = node5.firstChild; child3; child3 = child3.nextSibling) {
if (child3.nodeType === 3) {
offset2 += child3.nodeValue.length;
} else if (child3.nodeType === 1) {
result2.push({
event: "start",
offset: offset2,
node: child3
});
offset2 = _nodeStream(child3, offset2);
if (!tag(child3).match(/br|hr|img|input/)) {
result2.push({
event: "stop",
offset: offset2,
node: child3
});
}
}
}
return offset2;
})(node4, 0);
return result2;
}
function mergeStreams(original, highlighted, value) {
let processed = 0;
let result2 = "";
const nodeStack = [];
function selectStream() {
if (!original.length || !highlighted.length) {
return original.length ? original : highlighted;
}
if (original[0].offset !== highlighted[0].offset) {
return original[0].offset < highlighted[0].offset ? original : highlighted;
}
return highlighted[0].event === "start" ? original : highlighted;
}
function open2(node4) {
function attributeString(attr) {
return " " + attr.nodeName + '="' + escapeHTML(attr.value) + '"';
}
result2 += "<" + tag(node4) + [].map.call(node4.attributes, attributeString).join("") + ">";
}
function close3(node4) {
result2 += "</" + tag(node4) + ">";
}
function render6(event) {
(event.event === "start" ? open2 : close3)(event.node);
}
while (original.length || highlighted.length) {
let stream = selectStream();
result2 += escapeHTML(value.substring(processed, stream[0].offset));
processed = stream[0].offset;
if (stream === original) {
nodeStack.reverse().forEach(close3);
do {
render6(stream.splice(0, 1)[0]);
stream = selectStream();
} while (stream === original && stream.length && stream[0].offset === processed);
nodeStack.reverse().forEach(open2);
} else {
if (stream[0].event === "start") {
nodeStack.push(stream[0].node);
} else {
nodeStack.pop();
}
render6(stream.splice(0, 1)[0]);
}
}
return result2 + escapeHTML(value.substr(processed));
}
const error = (message) => {
console.error(message);
};
const warn = (message, ...args) => {
console.log(`WARN: ${message}`, ...args);
};
const deprecated = (version2, message) => {
console.log(`Deprecated as of ${version2}. ${message}`);
};
const escape$1$1 = escapeHTML;
const inherit$1 = inherit;
const NO_MATCH = Symbol("nomatch");
const HLJS = function(hljs) {
const languages = Object.create(null);
const aliases = Object.create(null);
const plugins2 = [];
let SAFE_MODE = true;
const fixMarkupRe = /(^(<[^>]+>|\t|)+|\n)/gm;
const LANGUAGE_NOT_FOUND = "Could not find the language '{}', did you forget to load/include a language module?";
const PLAINTEXT_LANGUAGE = {disableAutodetect: true, name: "Plain text", contains: []};
let options = {
noHighlightRe: /^(no-?highlight)$/i,
languageDetectRe: /\blang(?:uage)?-([\w-]+)\b/i,
classPrefix: "hljs-",
tabReplace: null,
useBR: false,
languages: null,
__emitter: TokenTreeEmitter
};
function shouldNotHighlight(languageName) {
return options.noHighlightRe.test(languageName);
}
function blockLanguage(block) {
let classes = block.className + " ";
classes += block.parentNode ? block.parentNode.className : "";
const match3 = options.languageDetectRe.exec(classes);
if (match3) {
const language = getLanguage(match3[1]);
if (!language) {
warn(LANGUAGE_NOT_FOUND.replace("{}", match3[1]));
warn("Falling back to no-highlight mode for this block.", block);
}
return language ? match3[1] : "no-highlight";
}
return classes.split(/\s+/).find((_class) => shouldNotHighlight(_class) || getLanguage(_class));
}
function highlight(codeOrlanguageName, optionsOrCode, ignoreIllegals, continuation) {
let code = "";
let languageName = "";
if (typeof optionsOrCode === "object") {
code = codeOrlanguageName;
ignoreIllegals = optionsOrCode.ignoreIllegals;
languageName = optionsOrCode.language;
continuation = void 0;
} else {
deprecated("10.7.0", "highlight(lang, code, ...args) has been deprecated.");
deprecated("10.7.0", "Please use highlight(code, options) instead.\nhttps://github.com/highlightjs/highlight.js/issues/2277");
languageName = codeOrlanguageName;
code = optionsOrCode;
}
const context = {
code,
language: languageName
};
fire("before:highlight", context);
const result2 = context.result ? context.result : _highlight(context.language, context.code, ignoreIllegals, continuation);
result2.code = context.code;
fire("after:highlight", result2);
return result2;
}
function _highlight(languageName, codeToHighlight, ignoreIllegals, continuation) {
function keywordData(mode, match3) {
const matchText = language.case_insensitive ? match3[0].toLowerCase() : match3[0];
return Object.prototype.hasOwnProperty.call(mode.keywords, matchText) && mode.keywords[matchText];
}
function processKeywords() {
if (!top.keywords) {
emitter.addText(modeBuffer);
return;
}
let lastIndex = 0;
top.keywordPatternRe.lastIndex = 0;
let match3 = top.keywordPatternRe.exec(modeBuffer);
let buf = "";
while (match3) {
buf += modeBuffer.substring(lastIndex, match3.index);
const data = keywordData(top, match3);
if (data) {
const [kind, keywordRelevance] = data;
emitter.addText(buf);
buf = "";
relevance += keywordRelevance;
if (kind.startsWith("_")) {
buf += match3[0];
} else {
const cssClass = language.classNameAliases[kind] || kind;
emitter.addKeyword(match3[0], cssClass);
}
} else {
buf += match3[0];
}
lastIndex = top.keywordPatternRe.lastIndex;
match3 = top.keywordPatternRe.exec(modeBuffer);
}
buf += modeBuffer.substr(lastIndex);
emitter.addText(buf);
}
function processSubLanguage() {
if (modeBuffer === "")
return;
let result3 = null;
if (typeof top.subLanguage === "string") {
if (!languages[top.subLanguage]) {
emitter.addText(modeBuffer);
return;
}
result3 = _highlight(top.subLanguage, modeBuffer, true, continuations[top.subLanguage]);
continuations[top.subLanguage] = result3.top;
} else {
result3 = highlightAuto(modeBuffer, top.subLanguage.length ? top.subLanguage : null);
}
if (top.relevance > 0) {
relevance += result3.relevance;
}
emitter.addSublanguage(result3.emitter, result3.language);
}
function processBuffer() {
if (top.subLanguage != null) {
processSubLanguage();
} else {
processKeywords();
}
modeBuffer = "";
}
function startNewMode(mode) {
if (mode.className) {
emitter.openNode(language.classNameAliases[mode.className] || mode.className);
}
top = Object.create(mode, {parent: {value: top}});
return top;
}
function endOfMode(mode, match3, matchPlusRemainder) {
let matched = startsWith(mode.endRe, matchPlusRemainder);
if (matched) {
if (mode["on:end"]) {
const resp = new Response(mode);
mode["on:end"](match3, resp);
if (resp.isMatchIgnored)
matched = false;
}
if (matched) {
while (mode.endsParent && mode.parent) {
mode = mode.parent;
}
return mode;
}
}
if (mode.endsWithParent) {
return endOfMode(mode.parent, match3, matchPlusRemainder);
}
}
function doIgnore(lexeme) {
if (top.matcher.regexIndex === 0) {
modeBuffer += lexeme[0];
return 1;
} else {
resumeScanAtSamePosition = true;
return 0;
}
}
function doBeginMatch(match3) {
const lexeme = match3[0];
const newMode = match3.rule;
const resp = new Response(newMode);
const beforeCallbacks = [newMode.__beforeBegin, newMode["on:begin"]];
for (const cb2 of beforeCallbacks) {
if (!cb2)
continue;
cb2(match3, resp);
if (resp.isMatchIgnored)
return doIgnore(lexeme);
}
if (newMode && newMode.endSameAsBegin) {
newMode.endRe = escape$1(lexeme);
}
if (newMode.skip) {
modeBuffer += lexeme;
} else {
if (newMode.excludeBegin) {
modeBuffer += lexeme;
}
processBuffer();
if (!newMode.returnBegin && !newMode.excludeBegin) {
modeBuffer = lexeme;
}
}
startNewMode(newMode);
return newMode.returnBegin ? 0 : lexeme.length;
}
function doEndMatch(match3) {
const lexeme = match3[0];
const matchPlusRemainder = codeToHighlight.substr(match3.index);
const endMode = endOfMode(top, match3, matchPlusRemainder);
if (!endMode) {
return NO_MATCH;
}
const origin = top;
if (origin.skip) {
modeBuffer += lexeme;
} else {
if (!(origin.returnEnd || origin.excludeEnd)) {
modeBuffer += lexeme;
}
processBuffer();
if (origin.excludeEnd) {
modeBuffer = lexeme;
}
}
do {
if (top.className) {
emitter.closeNode();
}
if (!top.skip && !top.subLanguage) {
relevance += top.relevance;
}
top = top.parent;
} while (top !== endMode.parent);
if (endMode.starts) {
if (endMode.endSameAsBegin) {
endMode.starts.endRe = endMode.endRe;
}
startNewMode(endMode.starts);
}
return origin.returnEnd ? 0 : lexeme.length;
}
function processContinuations() {
const list = [];
for (let current = top; current !== language; current = current.parent) {
if (current.className) {
list.unshift(current.className);
}
}
list.forEach((item) => emitter.openNode(item));
}
let lastMatch = {};
function processLexeme(textBeforeMatch, match3) {
const lexeme = match3 && match3[0];
modeBuffer += textBeforeMatch;
if (lexeme == null) {
processBuffer();
return 0;
}
if (lastMatch.type === "begin" && match3.type === "end" && lastMatch.index === match3.index && lexeme === "") {
modeBuffer += codeToHighlight.slice(match3.index, match3.index + 1);
if (!SAFE_MODE) {
const err2 = new Error("0 width match regex");
err2.languageName = languageName;
err2.badRule = lastMatch.rule;
throw err2;
}
return 1;
}
lastMatch = match3;
if (match3.type === "begin") {
return doBeginMatch(match3);
} else if (match3.type === "illegal" && !ignoreIllegals) {
const err2 = new Error('Illegal lexeme "' + lexeme + '" for mode "' + (top.className || "<unnamed>") + '"');
err2.mode = top;
throw err2;
} else if (match3.type === "end") {
const processed = doEndMatch(match3);
if (processed !== NO_MATCH) {
return processed;
}
}
if (match3.type === "illegal" && lexeme === "") {
return 1;
}
if (iterations > 1e5 && iterations > match3.index * 3) {
const err2 = new Error("potential infinite loop, way more iterations than matches");
throw err2;
}
modeBuffer += lexeme;
return lexeme.length;
}
const language = getLanguage(languageName);
if (!language) {
error(LANGUAGE_NOT_FOUND.replace("{}", languageName));
throw new Error('Unknown language: "' + languageName + '"');
}
const md = compileLanguage(language, {plugins: plugins2});
let result2 = "";
let top = continuation || md;
const continuations = {};
const emitter = new options.__emitter(options);
processContinuations();
let modeBuffer = "";
let relevance = 0;
let index3 = 0;
let iterations = 0;
let resumeScanAtSamePosition = false;
try {
top.matcher.considerAll();
for (; ; ) {
iterations++;
if (resumeScanAtSamePosition) {
resumeScanAtSamePosition = false;
} else {
top.matcher.considerAll();
}
top.matcher.lastIndex = index3;
const match3 = top.matcher.exec(codeToHighlight);
if (!match3)
break;
const beforeMatch = codeToHighlight.substring(index3, match3.index);
const processedCount = processLexeme(beforeMatch, match3);
index3 = match3.index + processedCount;
}
processLexeme(codeToHighlight.substr(index3));
emitter.closeAllNodes();
emitter.finalize();
result2 = emitter.toHTML();
return {
relevance: Math.floor(relevance),
value: result2,
language: languageName,
illegal: false,
emitter,
top
};
} catch (err2) {
if (err2.message && err2.message.includes("Illegal")) {
return {
illegal: true,
illegalBy: {
msg: err2.message,
context: codeToHighlight.slice(index3 - 100, index3 + 100),
mode: err2.mode
},
sofar: result2,
relevance: 0,
value: escape$1$1(codeToHighlight),
emitter
};
} else if (SAFE_MODE) {
return {
illegal: false,
relevance: 0,
value: escape$1$1(codeToHighlight),
emitter,
language: languageName,
top,
errorRaised: err2
};
} else {
throw err2;
}
}
}
function justTextHighlightResult(code) {
const result2 = {
relevance: 0,
emitter: new options.__emitter(options),
value: escape$1$1(code),
illegal: false,
top: PLAINTEXT_LANGUAGE
};
result2.emitter.addText(code);
return result2;
}
function highlightAuto(code, languageSubset) {
languageSubset = languageSubset || options.languages || Object.keys(languages);
const plaintext = justTextHighlightResult(code);
const results = languageSubset.filter(getLanguage).filter(autoDetection).map((name) => _highlight(name, code, false));
results.unshift(plaintext);
const sorted = results.sort((a, b) => {
if (a.relevance !== b.relevance)
return b.relevance - a.relevance;
if (a.language && b.language) {
if (getLanguage(a.language).supersetOf === b.language) {
return 1;
} else if (getLanguage(b.language).supersetOf === a.language) {
return -1;
}
}
return 0;
});
const [best, secondBest] = sorted;
const result2 = best;
result2.second_best = secondBest;
return result2;
}
function fixMarkup(html2) {
if (!(options.tabReplace || options.useBR)) {
return html2;
}
return html2.replace(fixMarkupRe, (match3) => {
if (match3 === "\n") {
return options.useBR ? "<br>" : match3;
} else if (options.tabReplace) {
return match3.replace(/\t/g, options.tabReplace);
}
return match3;
});
}
function updateClassName(element, currentLang, resultLang) {
const language = currentLang ? aliases[currentLang] : resultLang;
element.classList.add("hljs");
if (language)
element.classList.add(language);
}
const brPlugin = {
"before:highlightElement": ({el}) => {
if (options.useBR) {
el.innerHTML = el.innerHTML.replace(/\n/g, "").replace(/<br[ /]*>/g, "\n");
}
},
"after:highlightElement": ({result: result2}) => {
if (options.useBR) {
result2.value = result2.value.replace(/\n/g, "<br>");
}
}
};
const TAB_REPLACE_RE = /^(<[^>]+>|\t)+/gm;
const tabReplacePlugin = {
"after:highlightElement": ({result: result2}) => {
if (options.tabReplace) {
result2.value = result2.value.replace(TAB_REPLACE_RE, (m) => m.replace(/\t/g, options.tabReplace));
}
}
};
function highlightElement(element) {
let node4 = null;
const language = blockLanguage(element);
if (shouldNotHighlight(language))
return;
fire("before:highlightElement", {el: element, language});
node4 = element;
const text3 = node4.textContent;
const result2 = language ? highlight(text3, {language, ignoreIllegals: true}) : highlightAuto(text3);
fire("after:highlightElement", {el: element, result: result2, text: text3});
element.innerHTML = result2.value;
updateClassName(element, language, result2.language);
element.result = {
language: result2.language,
re: result2.relevance,
relavance: result2.relevance
};
if (result2.second_best) {
element.second_best = {
language: result2.second_best.language,
re: result2.second_best.relevance,
relavance: result2.second_best.relevance
};
}
}
function configure(userOptions) {
if (userOptions.useBR) {
deprecated("10.3.0", "'useBR' will be removed entirely in v11.0");
deprecated("10.3.0", "Please see https://github.com/highlightjs/highlight.js/issues/2559");
}
options = inherit$1(options, userOptions);
}
const initHighlighting = () => {
if (initHighlighting.called)
return;
initHighlighting.called = true;
deprecated("10.6.0", "initHighlighting() is deprecated. Use highlightAll() instead.");
const blocks = document.querySelectorAll("pre code");
blocks.forEach(highlightElement);
};
function initHighlightingOnLoad() {
deprecated("10.6.0", "initHighlightingOnLoad() is deprecated. Use highlightAll() instead.");
wantsHighlight = true;
}
let wantsHighlight = false;
function highlightAll() {
if (document.readyState === "loading") {
wantsHighlight = true;
return;
}
const blocks = document.querySelectorAll("pre code");
blocks.forEach(highlightElement);
}
function boot() {
if (wantsHighlight)
highlightAll();
}
if (typeof window !== "undefined" && window.addEventListener) {
window.addEventListener("DOMContentLoaded", boot, false);
}
function registerLanguage(languageName, languageDefinition) {
let lang = null;
try {
lang = languageDefinition(hljs);
} catch (error$1) {
error("Language definition for '{}' could not be registered.".replace("{}", languageName));
if (!SAFE_MODE) {
throw error$1;
} else {
error(error$1);
}
lang = PLAINTEXT_LANGUAGE;
}
if (!lang.name)
lang.name = languageName;
languages[languageName] = lang;
lang.rawDefinition = languageDefinition.bind(null, hljs);
if (lang.aliases) {
registerAliases(lang.aliases, {languageName});
}
}
function unregisterLanguage(languageName) {
delete languages[languageName];
for (const alias of Object.keys(aliases)) {
if (aliases[alias] === languageName) {
delete aliases[alias];
}
}
}
function listLanguages() {
return Object.keys(languages);
}
function requireLanguage(name) {
deprecated("10.4.0", "requireLanguage will be removed entirely in v11.");
deprecated("10.4.0", "Please see https://github.com/highlightjs/highlight.js/pull/2844");
const lang = getLanguage(name);
if (lang) {
return lang;
}
const err2 = new Error("The '{}' language is required, but not loaded.".replace("{}", name));
throw err2;
}
function getLanguage(name) {
name = (name || "").toLowerCase();
return languages[name] || languages[aliases[name]];
}
function registerAliases(aliasList, {languageName}) {
if (typeof aliasList === "string") {
aliasList = [aliasList];
}
aliasList.forEach((alias) => {
aliases[alias.toLowerCase()] = languageName;
});
}
function autoDetection(name) {
const lang = getLanguage(name);
return lang && !lang.disableAutodetect;
}
function upgradePluginAPI(plugin) {
if (plugin["before:highlightBlock"] && !plugin["before:highlightElement"]) {
plugin["before:highlightElement"] = (data) => {
plugin["before:highlightBlock"](Object.assign({block: data.el}, data));
};
}
if (plugin["after:highlightBlock"] && !plugin["after:highlightElement"]) {
plugin["after:highlightElement"] = (data) => {
plugin["after:highlightBlock"](Object.assign({block: data.el}, data));
};
}
}
function addPlugin(plugin) {
upgradePluginAPI(plugin);
plugins2.push(plugin);
}
function fire(event, args) {
const cb2 = event;
plugins2.forEach(function(plugin) {
if (plugin[cb2]) {
plugin[cb2](args);
}
});
}
function deprecateFixMarkup(arg) {
deprecated("10.2.0", "fixMarkup will be removed entirely in v11.0");
deprecated("10.2.0", "Please see https://github.com/highlightjs/highlight.js/issues/2534");
return fixMarkup(arg);
}
function deprecateHighlightBlock(el) {
deprecated("10.7.0", "highlightBlock will be removed entirely in v12.0");
deprecated("10.7.0", "Please use highlightElement now.");
return highlightElement(el);
}
Object.assign(hljs, {
highlight,
highlightAuto,
highlightAll,
fixMarkup: deprecateFixMarkup,
highlightElement,
highlightBlock: deprecateHighlightBlock,
configure,
initHighlighting,
initHighlightingOnLoad,
registerLanguage,
unregisterLanguage,
listLanguages,
getLanguage,
registerAliases,
requireLanguage,
autoDetection,
inherit: inherit$1,
addPlugin,
vuePlugin: BuildVuePlugin(hljs).VuePlugin
});
hljs.debugMode = function() {
SAFE_MODE = false;
};
hljs.safeMode = function() {
SAFE_MODE = true;
};
hljs.versionString = version$1;
for (const key in MODES) {
if (typeof MODES[key] === "object") {
deepFreezeEs6(MODES[key]);
}
}
Object.assign(hljs, MODES);
hljs.addPlugin(brPlugin);
hljs.addPlugin(mergeHTMLPlugin);
hljs.addPlugin(tabReplacePlugin);
return hljs;
};
HLJS({});
var format = createCommonjsModule(function(module) {
(function() {
var namespace;
{
namespace = module.exports = format2;
}
namespace.format = format2;
namespace.vsprintf = vsprintf;
if (typeof console !== "undefined" && typeof console.log === "function") {
namespace.printf = printf;
}
function printf() {
console.log(format2.apply(null, arguments));
}
function vsprintf(fmt, replacements) {
return format2.apply(null, [fmt].concat(replacements));
}
function format2(fmt) {
var argIndex = 1, args = [].slice.call(arguments), i = 0, n = fmt.length, result2 = "", c, escaped = false, arg, tmp, leadingZero = false, precision, nextArg = function() {
return args[argIndex++];
}, slurpNumber = function() {
var digits = "";
while (/\d/.test(fmt[i])) {
digits += fmt[i++];
c = fmt[i];
}
return digits.length > 0 ? parseInt(digits) : null;
};
for (; i < n; ++i) {
c = fmt[i];
if (escaped) {
escaped = false;
if (c == ".") {
leadingZero = false;
c = fmt[++i];
} else if (c == "0" && fmt[i + 1] == ".") {
leadingZero = true;
i += 2;
c = fmt[i];
} else {
leadingZero = true;
}
precision = slurpNumber();
switch (c) {
case "b":
result2 += parseInt(nextArg(), 10).toString(2);
break;
case "c":
arg = nextArg();
if (typeof arg === "string" || arg instanceof String)
result2 += arg;
else
result2 += String.fromCharCode(parseInt(arg, 10));
break;
case "d":
result2 += parseInt(nextArg(), 10);
break;
case "f":
tmp = String(parseFloat(nextArg()).toFixed(precision || 6));
result2 += leadingZero ? tmp : tmp.replace(/^0/, "");
break;
case "j":
result2 += JSON.stringify(nextArg());
break;
case "o":
result2 += "0" + parseInt(nextArg(), 10).toString(8);
break;
case "s":
result2 += nextArg();
break;
case "x":
result2 += "0x" + parseInt(nextArg(), 10).toString(16);
break;
case "X":
result2 += "0x" + parseInt(nextArg(), 10).toString(16).toUpperCase();
break;
default:
result2 += c;
break;
}
} else if (c === "%") {
escaped = true;
} else {
result2 += c;
}
}
return result2;
}
})();
});
var fault = create6(Error);
fault.eval = create6(EvalError);
fault.range = create6(RangeError);
fault.reference = create6(ReferenceError);
fault.syntax = create6(SyntaxError);
fault.type = create6(TypeError);
fault.uri = create6(URIError);
fault.create = create6;
function create6(EConstructor) {
FormattedError.displayName = EConstructor.displayName || EConstructor.name;
return FormattedError;
function FormattedError(format$1) {
if (format$1) {
format$1 = format.apply(null, arguments);
}
return new EConstructor(format$1);
}
}
Emitter.prototype.addText = text2;
Emitter.prototype.addKeyword = addKeyword;
Emitter.prototype.addSublanguage = addSublanguage;
Emitter.prototype.openNode = open;
Emitter.prototype.closeNode = close2;
Emitter.prototype.closeAllNodes = noop;
Emitter.prototype.finalize = noop;
Emitter.prototype.toHTML = toHtmlNoop;
function Emitter(options) {
this.options = options;
this.rootNode = {children: []};
this.stack = [this.rootNode];
}
function addKeyword(value, name) {
this.openNode(name);
this.addText(value);
this.closeNode();
}
function addSublanguage(other, name) {
var stack = this.stack;
var current = stack[stack.length - 1];
var results = other.rootNode.children;
var node4 = name ? {
type: "element",
tagName: "span",
properties: {className: [name]},
children: results
} : results;
current.children = current.children.concat(node4);
}
function text2(value) {
var stack = this.stack;
var current;
var tail;
if (value === "")
return;
current = stack[stack.length - 1];
tail = current.children[current.children.length - 1];
if (tail && tail.type === "text") {
tail.value += value;
} else {
current.children.push({type: "text", value});
}
}
function open(name) {
var stack = this.stack;
var className = this.options.classPrefix + name;
var current = stack[stack.length - 1];
var child3 = {
type: "element",
tagName: "span",
properties: {className: [className]},
children: []
};
current.children.push(child3);
stack.push(child3);
}
function close2() {
this.stack.pop();
}
function toHtmlNoop() {
return "";
}
function noop() {
}
var readFromCache, addToCache;
if (typeof WeakMap != "undefined") {
var cache = new WeakMap();
readFromCache = function(key) {
return cache.get(key);
};
addToCache = function(key, value) {
cache.set(key, value);
return value;
};
} else {
var cache$1 = [], cacheSize = 10, cachePos = 0;
readFromCache = function(key) {
for (var i = 0; i < cache$1.length; i += 2) {
if (cache$1[i] == key) {
return cache$1[i + 1];
}
}
};
addToCache = function(key, value) {
if (cachePos == cacheSize) {
cachePos = 0;
}
cache$1[cachePos++] = key;
return cache$1[cachePos++] = value;
};
}
var Rect = function Rect2(left, top, right, bottom) {
this.left = left;
this.top = top;
this.right = right;
this.bottom = bottom;
};
var TableMap = function TableMap2(width, height, map16, problems) {
this.width = width;
this.height = height;
this.map = map16;
this.problems = problems;
};
TableMap.prototype.findCell = function findCell(pos) {
for (var i = 0; i < this.map.length; i++) {
var curPos = this.map[i];
if (curPos != pos) {
continue;
}
var left = i % this.width, top = i / this.width | 0;
var right = left + 1, bottom = top + 1;
for (var j = 1; right < this.width && this.map[i + j] == curPos; j++) {
right++;
}
for (var j$1 = 1; bottom < this.height && this.map[i + this.width * j$1] == curPos; j$1++) {
bottom++;
}
return new Rect(left, top, right, bottom);
}
throw new RangeError("No cell with offset " + pos + " found");
};
TableMap.prototype.colCount = function colCount(pos) {
for (var i = 0; i < this.map.length; i++) {
if (this.map[i] == pos) {
return i % this.width;
}
}
throw new RangeError("No cell with offset " + pos + " found");
};
TableMap.prototype.nextCell = function nextCell(pos, axis, dir) {
var ref2 = this.findCell(pos);
var left = ref2.left;
var right = ref2.right;
var top = ref2.top;
var bottom = ref2.bottom;
if (axis == "horiz") {
if (dir < 0 ? left == 0 : right == this.width) {
return null;
}
return this.map[top * this.width + (dir < 0 ? left - 1 : right)];
} else {
if (dir < 0 ? top == 0 : bottom == this.height) {
return null;
}
return this.map[left + this.width * (dir < 0 ? top - 1 : bottom)];
}
};
TableMap.prototype.rectBetween = function rectBetween(a, b) {
var ref2 = this.findCell(a);
var leftA = ref2.left;
var rightA = ref2.right;
var topA = ref2.top;
var bottomA = ref2.bottom;
var ref$12 = this.findCell(b);
var leftB = ref$12.left;
var rightB = ref$12.right;
var topB = ref$12.top;
var bottomB = ref$12.bottom;
return new Rect(Math.min(leftA, leftB), Math.min(topA, topB), Math.max(rightA, rightB), Math.max(bottomA, bottomB));
};
TableMap.prototype.cellsInRect = function cellsInRect(rect) {
var result2 = [], seen = {};
for (var row = rect.top; row < rect.bottom; row++) {
for (var col = rect.left; col < rect.right; col++) {
var index3 = row * this.width + col, pos = this.map[index3];
if (seen[pos]) {
continue;
}
seen[pos] = true;
if ((col != rect.left || !col || this.map[index3 - 1] != pos) && (row != rect.top || !row || this.map[index3 - this.width] != pos)) {
result2.push(pos);
}
}
}
return result2;
};
TableMap.prototype.positionAt = function positionAt(row, col, table) {
for (var i = 0, rowStart = 0; ; i++) {
var rowEnd = rowStart + table.child(i).nodeSize;
if (i == row) {
var index3 = col + row * this.width, rowEndIndex = (row + 1) * this.width;
while (index3 < rowEndIndex && this.map[index3] < rowStart) {
index3++;
}
return index3 == rowEndIndex ? rowEnd - 1 : this.map[index3];
}
rowStart = rowEnd;
}
};
TableMap.get = function get5(table) {
return readFromCache(table) || addToCache(table, computeMap(table));
};
function computeMap(table) {
if (table.type.spec.tableRole != "table") {
throw new RangeError("Not a table node: " + table.type.name);
}
var width = findWidth(table), height = table.childCount;
var map16 = [], mapPos = 0, problems = null, colWidths = [];
for (var i = 0, e = width * height; i < e; i++) {
map16[i] = 0;
}
for (var row = 0, pos = 0; row < height; row++) {
var rowNode = table.child(row);
pos++;
for (var i$1 = 0; ; i$1++) {
while (mapPos < map16.length && map16[mapPos] != 0) {
mapPos++;
}
if (i$1 == rowNode.childCount) {
break;
}
var cellNode = rowNode.child(i$1);
var ref2 = cellNode.attrs;
var colspan = ref2.colspan;
var rowspan = ref2.rowspan;
var colwidth = ref2.colwidth;
for (var h = 0; h < rowspan; h++) {
if (h + row >= height) {
(problems || (problems = [])).push({type: "overlong_rowspan", pos, n: rowspan - h});
break;
}
var start3 = mapPos + h * width;
for (var w = 0; w < colspan; w++) {
if (map16[start3 + w] == 0) {
map16[start3 + w] = pos;
} else {
(problems || (problems = [])).push({type: "collision", row, pos, n: colspan - w});
}
var colW = colwidth && colwidth[w];
if (colW) {
var widthIndex = (start3 + w) % width * 2, prev = colWidths[widthIndex];
if (prev == null || prev != colW && colWidths[widthIndex + 1] == 1) {
colWidths[widthIndex] = colW;
colWidths[widthIndex + 1] = 1;
} else if (prev == colW) {
colWidths[widthIndex + 1]++;
}
}
}
}
mapPos += colspan;
pos += cellNode.nodeSize;
}
var expectedPos = (row + 1) * width, missing = 0;
while (mapPos < expectedPos) {
if (map16[mapPos++] == 0) {
missing++;
}
}
if (missing) {
(problems || (problems = [])).push({type: "missing", row, n: missing});
}
pos++;
}
var tableMap = new TableMap(width, height, map16, problems), badWidths = false;
for (var i$2 = 0; !badWidths && i$2 < colWidths.length; i$2 += 2) {
if (colWidths[i$2] != null && colWidths[i$2 + 1] < height) {
badWidths = true;
}
}
if (badWidths) {
findBadColWidths(tableMap, colWidths, table);
}
return tableMap;
}
function findWidth(table) {
var width = -1, hasRowSpan = false;
for (var row = 0; row < table.childCount; row++) {
var rowNode = table.child(row), rowWidth = 0;
if (hasRowSpan) {
for (var j = 0; j < row; j++) {
var prevRow = table.child(j);
for (var i = 0; i < prevRow.childCount; i++) {
var cell = prevRow.child(i);
if (j + cell.attrs.rowspan > row) {
rowWidth += cell.attrs.colspan;
}
}
}
}
for (var i$1 = 0; i$1 < rowNode.childCount; i$1++) {
var cell$1 = rowNode.child(i$1);
rowWidth += cell$1.attrs.colspan;
if (cell$1.attrs.rowspan > 1) {
hasRowSpan = true;
}
}
if (width == -1) {
width = rowWidth;
} else if (width != rowWidth) {
width = Math.max(width, rowWidth);
}
}
return width;
}
function findBadColWidths(map16, colWidths, table) {
if (!map16.problems) {
map16.problems = [];
}
for (var i = 0, seen = {}; i < map16.map.length; i++) {
var pos = map16.map[i];
if (seen[pos]) {
continue;
}
seen[pos] = true;
var node4 = table.nodeAt(pos), updated2 = null;
for (var j = 0; j < node4.attrs.colspan; j++) {
var col = (i + j) % map16.width, colWidth = colWidths[col * 2];
if (colWidth != null && (!node4.attrs.colwidth || node4.attrs.colwidth[j] != colWidth)) {
(updated2 || (updated2 = freshColWidth(node4.attrs)))[j] = colWidth;
}
}
if (updated2) {
map16.problems.unshift({type: "colwidth mismatch", pos, colwidth: updated2});
}
}
}
function freshColWidth(attrs2) {
if (attrs2.colwidth) {
return attrs2.colwidth.slice();
}
var result2 = [];
for (var i = 0; i < attrs2.colspan; i++) {
result2.push(0);
}
return result2;
}
function getCellAttrs(dom, extraAttrs) {
var widthAttr = dom.getAttribute("data-colwidth");
var widths = widthAttr && /^\d+(,\d+)*$/.test(widthAttr) ? widthAttr.split(",").map(function(s) {
return Number(s);
}) : null;
var colspan = Number(dom.getAttribute("colspan") || 1);
var result2 = {
colspan,
rowspan: Number(dom.getAttribute("rowspan") || 1),
colwidth: widths && widths.length == colspan ? widths : null
};
for (var prop in extraAttrs) {
var getter = extraAttrs[prop].getFromDOM;
var value = getter && getter(dom);
if (value != null) {
result2[prop] = value;
}
}
return result2;
}
function setCellAttrs(node4, extraAttrs) {
var attrs2 = {};
if (node4.attrs.colspan != 1) {
attrs2.colspan = node4.attrs.colspan;
}
if (node4.attrs.rowspan != 1) {
attrs2.rowspan = node4.attrs.rowspan;
}
if (node4.attrs.colwidth) {
attrs2["data-colwidth"] = node4.attrs.colwidth.join(",");
}
for (var prop in extraAttrs) {
var setter = extraAttrs[prop].setDOMAttr;
if (setter) {
setter(node4.attrs[prop], attrs2);
}
}
return attrs2;
}
function tableNodes(options) {
var extraAttrs = options.cellAttributes || {};
var cellAttrs = {
colspan: {default: 1},
rowspan: {default: 1},
colwidth: {default: null}
};
for (var prop in extraAttrs) {
cellAttrs[prop] = {default: extraAttrs[prop].default};
}
return {
table: {
content: "table_row+",
tableRole: "table",
isolating: true,
group: options.tableGroup,
parseDOM: [{tag: "table"}],
toDOM: function toDOM() {
return ["table", ["tbody", 0]];
}
},
table_row: {
content: "(table_cell | table_header)*",
tableRole: "row",
parseDOM: [{tag: "tr"}],
toDOM: function toDOM() {
return ["tr", 0];
}
},
table_cell: {
content: options.cellContent,
attrs: cellAttrs,
tableRole: "cell",
isolating: true,
parseDOM: [{tag: "td", getAttrs: function(dom) {
return getCellAttrs(dom, extraAttrs);
}}],
toDOM: function toDOM(node4) {
return ["td", setCellAttrs(node4, extraAttrs), 0];
}
},
table_header: {
content: options.cellContent,
attrs: cellAttrs,
tableRole: "header_cell",
isolating: true,
parseDOM: [{tag: "th", getAttrs: function(dom) {
return getCellAttrs(dom, extraAttrs);
}}],
toDOM: function toDOM(node4) {
return ["th", setCellAttrs(node4, extraAttrs), 0];
}
}
};
}
function tableNodeTypes(schema) {
var result2 = schema.cached.tableNodeTypes;
if (!result2) {
result2 = schema.cached.tableNodeTypes = {};
for (var name in schema.nodes) {
var type = schema.nodes[name], role = type.spec.tableRole;
if (role) {
result2[role] = type;
}
}
}
return result2;
}
new PluginKey("selectingCells");
function cellAround($pos) {
for (var d = $pos.depth - 1; d > 0; d--) {
if ($pos.node(d).type.spec.tableRole == "row") {
return $pos.node(0).resolve($pos.before(d + 1));
}
}
return null;
}
function isInTable(state) {
var $head = state.selection.$head;
for (var d = $head.depth; d > 0; d--) {
if ($head.node(d).type.spec.tableRole == "row") {
return true;
}
}
return false;
}
function selectionCell(state) {
var sel = state.selection;
if (sel.$anchorCell) {
return sel.$anchorCell.pos > sel.$headCell.pos ? sel.$anchorCell : sel.$headCell;
} else if (sel.node && sel.node.type.spec.tableRole == "cell") {
return sel.$anchor;
}
return cellAround(sel.$head) || cellNear(sel.$head);
}
function cellNear($pos) {
for (var after3 = $pos.nodeAfter, pos = $pos.pos; after3; after3 = after3.firstChild, pos++) {
var role = after3.type.spec.tableRole;
if (role == "cell" || role == "header_cell") {
return $pos.doc.resolve(pos);
}
}
for (var before3 = $pos.nodeBefore, pos$1 = $pos.pos; before3; before3 = before3.lastChild, pos$1--) {
var role$1 = before3.type.spec.tableRole;
if (role$1 == "cell" || role$1 == "header_cell") {
return $pos.doc.resolve(pos$1 - before3.nodeSize);
}
}
}
function pointsAtCell($pos) {
return $pos.parent.type.spec.tableRole == "row" && $pos.nodeAfter;
}
function inSameTable($a, $b) {
return $a.depth == $b.depth && $a.pos >= $b.start(-1) && $a.pos <= $b.end(-1);
}
function nextCell2($pos, axis, dir) {
var start3 = $pos.start(-1), map16 = TableMap.get($pos.node(-1));
var moved2 = map16.nextCell($pos.pos - start3, axis, dir);
return moved2 == null ? null : $pos.node(0).resolve(start3 + moved2);
}
function setAttr(attrs2, name, value) {
var result2 = {};
for (var prop in attrs2) {
result2[prop] = attrs2[prop];
}
result2[name] = value;
return result2;
}
function removeColSpan(attrs2, pos, n) {
if (n === void 0)
n = 1;
var result2 = setAttr(attrs2, "colspan", attrs2.colspan - n);
if (result2.colwidth) {
result2.colwidth = result2.colwidth.slice();
result2.colwidth.splice(pos, n);
if (!result2.colwidth.some(function(w) {
return w > 0;
})) {
result2.colwidth = null;
}
}
return result2;
}
var CellSelection = /* @__PURE__ */ function(Selection3) {
function CellSelection2($anchorCell, $headCell) {
if ($headCell === void 0)
$headCell = $anchorCell;
var table = $anchorCell.node(-1), map16 = TableMap.get(table), start3 = $anchorCell.start(-1);
var rect = map16.rectBetween($anchorCell.pos - start3, $headCell.pos - start3);
var doc2 = $anchorCell.node(0);
var cells = map16.cellsInRect(rect).filter(function(p) {
return p != $headCell.pos - start3;
});
cells.unshift($headCell.pos - start3);
var ranges = cells.map(function(pos) {
var cell = table.nodeAt(pos), from4 = pos + start3 + 1;
return new SelectionRange(doc2.resolve(from4), doc2.resolve(from4 + cell.content.size));
});
Selection3.call(this, ranges[0].$from, ranges[0].$to, ranges);
this.$anchorCell = $anchorCell;
this.$headCell = $headCell;
}
if (Selection3)
CellSelection2.__proto__ = Selection3;
CellSelection2.prototype = Object.create(Selection3 && Selection3.prototype);
CellSelection2.prototype.constructor = CellSelection2;
CellSelection2.prototype.map = function map16(doc2, mapping) {
var $anchorCell = doc2.resolve(mapping.map(this.$anchorCell.pos));
var $headCell = doc2.resolve(mapping.map(this.$headCell.pos));
if (pointsAtCell($anchorCell) && pointsAtCell($headCell) && inSameTable($anchorCell, $headCell)) {
var tableChanged = this.$anchorCell.node(-1) != $anchorCell.node(-1);
if (tableChanged && this.isRowSelection()) {
return CellSelection2.rowSelection($anchorCell, $headCell);
} else if (tableChanged && this.isColSelection()) {
return CellSelection2.colSelection($anchorCell, $headCell);
} else {
return new CellSelection2($anchorCell, $headCell);
}
}
return TextSelection.between($anchorCell, $headCell);
};
CellSelection2.prototype.content = function content2() {
var table = this.$anchorCell.node(-1), map16 = TableMap.get(table), start3 = this.$anchorCell.start(-1);
var rect = map16.rectBetween(this.$anchorCell.pos - start3, this.$headCell.pos - start3);
var seen = {}, rows = [];
for (var row = rect.top; row < rect.bottom; row++) {
var rowContent = [];
for (var index3 = row * map16.width + rect.left, col = rect.left; col < rect.right; col++, index3++) {
var pos = map16.map[index3];
if (!seen[pos]) {
seen[pos] = true;
var cellRect = map16.findCell(pos), cell = table.nodeAt(pos);
var extraLeft = rect.left - cellRect.left, extraRight = cellRect.right - rect.right;
if (extraLeft > 0 || extraRight > 0) {
var attrs2 = cell.attrs;
if (extraLeft > 0) {
attrs2 = removeColSpan(attrs2, 0, extraLeft);
}
if (extraRight > 0) {
attrs2 = removeColSpan(attrs2, attrs2.colspan - extraRight, extraRight);
}
if (cellRect.left < rect.left) {
cell = cell.type.createAndFill(attrs2);
} else {
cell = cell.type.create(attrs2, cell.content);
}
}
if (cellRect.top < rect.top || cellRect.bottom > rect.bottom) {
var attrs$1 = setAttr(cell.attrs, "rowspan", Math.min(cellRect.bottom, rect.bottom) - Math.max(cellRect.top, rect.top));
if (cellRect.top < rect.top) {
cell = cell.type.createAndFill(attrs$1);
} else {
cell = cell.type.create(attrs$1, cell.content);
}
}
rowContent.push(cell);
}
}
rows.push(table.child(row).copy(Fragment.from(rowContent)));
}
var fragment = this.isColSelection() && this.isRowSelection() ? table : rows;
return new Slice(Fragment.from(fragment), 1, 1);
};
CellSelection2.prototype.replace = function replace4(tr, content2) {
if (content2 === void 0)
content2 = Slice.empty;
var mapFrom = tr.steps.length, ranges = this.ranges;
for (var i = 0; i < ranges.length; i++) {
var ref2 = ranges[i];
var $from = ref2.$from;
var $to = ref2.$to;
var mapping = tr.mapping.slice(mapFrom);
tr.replace(mapping.map($from.pos), mapping.map($to.pos), i ? Slice.empty : content2);
}
var sel = Selection3.findFrom(tr.doc.resolve(tr.mapping.slice(mapFrom).map(this.to)), -1);
if (sel) {
tr.setSelection(sel);
}
};
CellSelection2.prototype.replaceWith = function replaceWith2(tr, node4) {
this.replace(tr, new Slice(Fragment.from(node4), 0, 0));
};
CellSelection2.prototype.forEachCell = function forEachCell(f) {
var table = this.$anchorCell.node(-1), map16 = TableMap.get(table), start3 = this.$anchorCell.start(-1);
var cells = map16.cellsInRect(map16.rectBetween(this.$anchorCell.pos - start3, this.$headCell.pos - start3));
for (var i = 0; i < cells.length; i++) {
f(table.nodeAt(cells[i]), start3 + cells[i]);
}
};
CellSelection2.prototype.isColSelection = function isColSelection() {
var anchorTop = this.$anchorCell.index(-1), headTop = this.$headCell.index(-1);
if (Math.min(anchorTop, headTop) > 0) {
return false;
}
var anchorBot = anchorTop + this.$anchorCell.nodeAfter.attrs.rowspan, headBot = headTop + this.$headCell.nodeAfter.attrs.rowspan;
return Math.max(anchorBot, headBot) == this.$headCell.node(-1).childCount;
};
CellSelection2.colSelection = function colSelection($anchorCell, $headCell) {
if ($headCell === void 0)
$headCell = $anchorCell;
var map16 = TableMap.get($anchorCell.node(-1)), start3 = $anchorCell.start(-1);
var anchorRect = map16.findCell($anchorCell.pos - start3), headRect = map16.findCell($headCell.pos - start3);
var doc2 = $anchorCell.node(0);
if (anchorRect.top <= headRect.top) {
if (anchorRect.top > 0) {
$anchorCell = doc2.resolve(start3 + map16.map[anchorRect.left]);
}
if (headRect.bottom < map16.height) {
$headCell = doc2.resolve(start3 + map16.map[map16.width * (map16.height - 1) + headRect.right - 1]);
}
} else {
if (headRect.top > 0) {
$headCell = doc2.resolve(start3 + map16.map[headRect.left]);
}
if (anchorRect.bottom < map16.height) {
$anchorCell = doc2.resolve(start3 + map16.map[map16.width * (map16.height - 1) + anchorRect.right - 1]);
}
}
return new CellSelection2($anchorCell, $headCell);
};
CellSelection2.prototype.isRowSelection = function isRowSelection() {
var map16 = TableMap.get(this.$anchorCell.node(-1)), start3 = this.$anchorCell.start(-1);
var anchorLeft = map16.colCount(this.$anchorCell.pos - start3), headLeft = map16.colCount(this.$headCell.pos - start3);
if (Math.min(anchorLeft, headLeft) > 0) {
return false;
}
var anchorRight = anchorLeft + this.$anchorCell.nodeAfter.attrs.colspan, headRight = headLeft + this.$headCell.nodeAfter.attrs.colspan;
return Math.max(anchorRight, headRight) == map16.width;
};
CellSelection2.prototype.eq = function eq13(other) {
return other instanceof CellSelection2 && other.$anchorCell.pos == this.$anchorCell.pos && other.$headCell.pos == this.$headCell.pos;
};
CellSelection2.rowSelection = function rowSelection($anchorCell, $headCell) {
if ($headCell === void 0)
$headCell = $anchorCell;
var map16 = TableMap.get($anchorCell.node(-1)), start3 = $anchorCell.start(-1);
var anchorRect = map16.findCell($anchorCell.pos - start3), headRect = map16.findCell($headCell.pos - start3);
var doc2 = $anchorCell.node(0);
if (anchorRect.left <= headRect.left) {
if (anchorRect.left > 0) {
$anchorCell = doc2.resolve(start3 + map16.map[anchorRect.top * map16.width]);
}
if (headRect.right < map16.width) {
$headCell = doc2.resolve(start3 + map16.map[map16.width * (headRect.top + 1) - 1]);
}
} else {
if (headRect.left > 0) {
$headCell = doc2.resolve(start3 + map16.map[headRect.top * map16.width]);
}
if (anchorRect.right < map16.width) {
$anchorCell = doc2.resolve(start3 + map16.map[map16.width * (anchorRect.top + 1) - 1]);
}
}
return new CellSelection2($anchorCell, $headCell);
};
CellSelection2.prototype.toJSON = function toJSON7() {
return {type: "cell", anchor: this.$anchorCell.pos, head: this.$headCell.pos};
};
CellSelection2.fromJSON = function fromJSON8(doc2, json) {
return new CellSelection2(doc2.resolve(json.anchor), doc2.resolve(json.head));
};
CellSelection2.create = function create7(doc2, anchorCell, headCell) {
if (headCell === void 0)
headCell = anchorCell;
return new CellSelection2(doc2.resolve(anchorCell), doc2.resolve(headCell));
};
CellSelection2.prototype.getBookmark = function getBookmark2() {
return new CellBookmark(this.$anchorCell.pos, this.$headCell.pos);
};
return CellSelection2;
}(Selection);
CellSelection.prototype.visible = false;
Selection.jsonID("cell", CellSelection);
var CellBookmark = function CellBookmark2(anchor, head) {
this.anchor = anchor;
this.head = head;
};
CellBookmark.prototype.map = function map14(mapping) {
return new CellBookmark(mapping.map(this.anchor), mapping.map(this.head));
};
CellBookmark.prototype.resolve = function resolve8(doc2) {
var $anchorCell = doc2.resolve(this.anchor), $headCell = doc2.resolve(this.head);
if ($anchorCell.parent.type.spec.tableRole == "row" && $headCell.parent.type.spec.tableRole == "row" && $anchorCell.index() < $anchorCell.parent.childCount && $headCell.index() < $headCell.parent.childCount && inSameTable($anchorCell, $headCell)) {
return new CellSelection($anchorCell, $headCell);
} else {
return Selection.near($headCell, 1);
}
};
keydownHandler({
ArrowLeft: arrow("horiz", -1),
ArrowRight: arrow("horiz", 1),
ArrowUp: arrow("vert", -1),
ArrowDown: arrow("vert", 1),
"Shift-ArrowLeft": shiftArrow("horiz", -1),
"Shift-ArrowRight": shiftArrow("horiz", 1),
"Shift-ArrowUp": shiftArrow("vert", -1),
"Shift-ArrowDown": shiftArrow("vert", 1),
Backspace: deleteCellSelection,
"Mod-Backspace": deleteCellSelection,
Delete: deleteCellSelection,
"Mod-Delete": deleteCellSelection
});
function maybeSetSelection(state, dispatch2, selection) {
if (selection.eq(state.selection)) {
return false;
}
if (dispatch2) {
dispatch2(state.tr.setSelection(selection).scrollIntoView());
}
return true;
}
function arrow(axis, dir) {
return function(state, dispatch2, view) {
var sel = state.selection;
if (sel instanceof CellSelection) {
return maybeSetSelection(state, dispatch2, Selection.near(sel.$headCell, dir));
}
if (axis != "horiz" && !sel.empty) {
return false;
}
var end2 = atEndOfCell(view, axis, dir);
if (end2 == null) {
return false;
}
if (axis == "horiz") {
return maybeSetSelection(state, dispatch2, Selection.near(state.doc.resolve(sel.head + dir), dir));
} else {
var $cell = state.doc.resolve(end2), $next = nextCell2($cell, axis, dir), newSel;
if ($next) {
newSel = Selection.near($next, 1);
} else if (dir < 0) {
newSel = Selection.near(state.doc.resolve($cell.before(-1)), -1);
} else {
newSel = Selection.near(state.doc.resolve($cell.after(-1)), 1);
}
return maybeSetSelection(state, dispatch2, newSel);
}
};
}
function shiftArrow(axis, dir) {
return function(state, dispatch2, view) {
var sel = state.selection;
if (!(sel instanceof CellSelection)) {
var end2 = atEndOfCell(view, axis, dir);
if (end2 == null) {
return false;
}
sel = new CellSelection(state.doc.resolve(end2));
}
var $head = nextCell2(sel.$headCell, axis, dir);
if (!$head) {
return false;
}
return maybeSetSelection(state, dispatch2, new CellSelection(sel.$anchorCell, $head));
};
}
function deleteCellSelection(state, dispatch2) {
var sel = state.selection;
if (!(sel instanceof CellSelection)) {
return false;
}
if (dispatch2) {
var tr = state.tr, baseContent = tableNodeTypes(state.schema).cell.createAndFill().content;
sel.forEachCell(function(cell, pos) {
if (!cell.content.eq(baseContent)) {
tr.replace(tr.mapping.map(pos + 1), tr.mapping.map(pos + cell.nodeSize - 1), new Slice(baseContent, 0, 0));
}
});
if (tr.docChanged) {
dispatch2(tr);
}
}
return true;
}
function atEndOfCell(view, axis, dir) {
if (!(view.state.selection instanceof TextSelection)) {
return null;
}
var ref2 = view.state.selection;
var $head = ref2.$head;
for (var d = $head.depth - 1; d >= 0; d--) {
var parent = $head.node(d), index3 = dir < 0 ? $head.index(d) : $head.indexAfter(d);
if (index3 != (dir < 0 ? 0 : parent.childCount)) {
return null;
}
if (parent.type.spec.tableRole == "cell" || parent.type.spec.tableRole == "header_cell") {
var cellPos = $head.before(d);
var dirStr = axis == "vert" ? dir > 0 ? "down" : "up" : dir > 0 ? "right" : "left";
return view.endOfTextblock(dirStr) ? cellPos : null;
}
}
return null;
}
new PluginKey("fix-tables");
function selectedRect(state) {
var sel = state.selection, $pos = selectionCell(state);
var table = $pos.node(-1), tableStart = $pos.start(-1), map16 = TableMap.get(table);
var rect;
if (sel instanceof CellSelection) {
rect = map16.rectBetween(sel.$anchorCell.pos - tableStart, sel.$headCell.pos - tableStart);
} else {
rect = map16.findCell($pos.pos - tableStart);
}
rect.tableStart = tableStart;
rect.map = map16;
rect.table = table;
return rect;
}
function deprecated_toggleHeader(type) {
return function(state, dispatch2) {
if (!isInTable(state)) {
return false;
}
if (dispatch2) {
var types = tableNodeTypes(state.schema);
var rect = selectedRect(state), tr = state.tr;
var cells = rect.map.cellsInRect(type == "column" ? new Rect(rect.left, 0, rect.right, rect.map.height) : type == "row" ? new Rect(0, rect.top, rect.map.width, rect.bottom) : rect);
var nodes = cells.map(function(pos) {
return rect.table.nodeAt(pos);
});
for (var i = 0; i < cells.length; i++) {
if (nodes[i].type == types.header_cell) {
tr.setNodeMarkup(rect.tableStart + cells[i], types.cell, nodes[i].attrs);
}
}
if (tr.steps.length == 0) {
for (var i$1 = 0; i$1 < cells.length; i$1++) {
tr.setNodeMarkup(rect.tableStart + cells[i$1], types.header_cell, nodes[i$1].attrs);
}
}
dispatch2(tr);
}
return true;
};
}
function isHeaderEnabledByType(type, rect, types) {
var cellPositions = rect.map.cellsInRect({
left: 0,
top: 0,
right: type == "row" ? rect.map.width : 1,
bottom: type == "column" ? rect.map.height : 1
});
for (var i = 0; i < cellPositions.length; i++) {
var cell = rect.table.nodeAt(cellPositions[i]);
if (cell && cell.type !== types.header_cell) {
return false;
}
}
return true;
}
function toggleHeader(type, options) {
options = options || {useDeprecatedLogic: false};
if (options.useDeprecatedLogic) {
return deprecated_toggleHeader(type);
}
return function(state, dispatch2) {
if (!isInTable(state)) {
return false;
}
if (dispatch2) {
var types = tableNodeTypes(state.schema);
var rect = selectedRect(state), tr = state.tr;
var isHeaderRowEnabled = isHeaderEnabledByType("row", rect, types);
var isHeaderColumnEnabled = isHeaderEnabledByType("column", rect, types);
var isHeaderEnabled = type === "column" ? isHeaderRowEnabled : type === "row" ? isHeaderColumnEnabled : false;
var selectionStartsAt = isHeaderEnabled ? 1 : 0;
var cellsRect = type == "column" ? new Rect(0, selectionStartsAt, 1, rect.map.height) : type == "row" ? new Rect(selectionStartsAt, 0, rect.map.width, 1) : rect;
var newType = type == "column" ? isHeaderColumnEnabled ? types.cell : types.header_cell : type == "row" ? isHeaderRowEnabled ? types.cell : types.header_cell : types.cell;
rect.map.cellsInRect(cellsRect).forEach(function(relativeCellPos) {
var cellPos = relativeCellPos + rect.tableStart;
var cell = tr.doc.nodeAt(cellPos);
if (cell) {
tr.setNodeMarkup(cellPos, newType, cell.attrs);
}
});
dispatch2(tr);
}
return true;
};
}
toggleHeader("row", {useDeprecatedLogic: true});
toggleHeader("column", {useDeprecatedLogic: true});
toggleHeader("cell", {useDeprecatedLogic: true});
new PluginKey("tableColumnResizing");
new PluginKey("collab");
var GOOD_LEAF_SIZE = 200;
var RopeSequence = function RopeSequence2() {
};
RopeSequence.prototype.append = function append2(other) {
if (!other.length) {
return this;
}
other = RopeSequence.from(other);
return !this.length && other || other.length < GOOD_LEAF_SIZE && this.leafAppend(other) || this.length < GOOD_LEAF_SIZE && other.leafPrepend(this) || this.appendInner(other);
};
RopeSequence.prototype.prepend = function prepend(other) {
if (!other.length) {
return this;
}
return RopeSequence.from(other).append(this);
};
RopeSequence.prototype.appendInner = function appendInner(other) {
return new Append(this, other);
};
RopeSequence.prototype.slice = function slice3(from4, to) {
if (from4 === void 0)
from4 = 0;
if (to === void 0)
to = this.length;
if (from4 >= to) {
return RopeSequence.empty;
}
return this.sliceInner(Math.max(0, from4), Math.min(this.length, to));
};
RopeSequence.prototype.get = function get6(i) {
if (i < 0 || i >= this.length) {
return void 0;
}
return this.getInner(i);
};
RopeSequence.prototype.forEach = function forEach4(f, from4, to) {
if (from4 === void 0)
from4 = 0;
if (to === void 0)
to = this.length;
if (from4 <= to) {
this.forEachInner(f, from4, to, 0);
} else {
this.forEachInvertedInner(f, from4, to, 0);
}
};
RopeSequence.prototype.map = function map15(f, from4, to) {
if (from4 === void 0)
from4 = 0;
if (to === void 0)
to = this.length;
var result2 = [];
this.forEach(function(elt, i) {
return result2.push(f(elt, i));
}, from4, to);
return result2;
};
RopeSequence.from = function from3(values2) {
if (values2 instanceof RopeSequence) {
return values2;
}
return values2 && values2.length ? new Leaf(values2) : RopeSequence.empty;
};
var Leaf = /* @__PURE__ */ function(RopeSequence3) {
function Leaf2(values2) {
RopeSequence3.call(this);
this.values = values2;
}
if (RopeSequence3)
Leaf2.__proto__ = RopeSequence3;
Leaf2.prototype = Object.create(RopeSequence3 && RopeSequence3.prototype);
Leaf2.prototype.constructor = Leaf2;
var prototypeAccessors2 = {length: {configurable: true}, depth: {configurable: true}};
Leaf2.prototype.flatten = function flatten2() {
return this.values;
};
Leaf2.prototype.sliceInner = function sliceInner(from4, to) {
if (from4 == 0 && to == this.length) {
return this;
}
return new Leaf2(this.values.slice(from4, to));
};
Leaf2.prototype.getInner = function getInner(i) {
return this.values[i];
};
Leaf2.prototype.forEachInner = function forEachInner(f, from4, to, start3) {
for (var i = from4; i < to; i++) {
if (f(this.values[i], start3 + i) === false) {
return false;
}
}
};
Leaf2.prototype.forEachInvertedInner = function forEachInvertedInner(f, from4, to, start3) {
for (var i = from4 - 1; i >= to; i--) {
if (f(this.values[i], start3 + i) === false) {
return false;
}
}
};
Leaf2.prototype.leafAppend = function leafAppend(other) {
if (this.length + other.length <= GOOD_LEAF_SIZE) {
return new Leaf2(this.values.concat(other.flatten()));
}
};
Leaf2.prototype.leafPrepend = function leafPrepend(other) {
if (this.length + other.length <= GOOD_LEAF_SIZE) {
return new Leaf2(other.flatten().concat(this.values));
}
};
prototypeAccessors2.length.get = function() {
return this.values.length;
};
prototypeAccessors2.depth.get = function() {
return 0;
};
Object.defineProperties(Leaf2.prototype, prototypeAccessors2);
return Leaf2;
}(RopeSequence);
RopeSequence.empty = new Leaf([]);
var Append = /* @__PURE__ */ function(RopeSequence3) {
function Append2(left, right) {
RopeSequence3.call(this);
this.left = left;
this.right = right;
this.length = left.length + right.length;
this.depth = Math.max(left.depth, right.depth) + 1;
}
if (RopeSequence3)
Append2.__proto__ = RopeSequence3;
Append2.prototype = Object.create(RopeSequence3 && RopeSequence3.prototype);
Append2.prototype.constructor = Append2;
Append2.prototype.flatten = function flatten2() {
return this.left.flatten().concat(this.right.flatten());
};
Append2.prototype.getInner = function getInner(i) {
return i < this.left.length ? this.left.get(i) : this.right.get(i - this.left.length);
};
Append2.prototype.forEachInner = function forEachInner(f, from4, to, start3) {
var leftLen = this.left.length;
if (from4 < leftLen && this.left.forEachInner(f, from4, Math.min(to, leftLen), start3) === false) {
return false;
}
if (to > leftLen && this.right.forEachInner(f, Math.max(from4 - leftLen, 0), Math.min(this.length, to) - leftLen, start3 + leftLen) === false) {
return false;
}
};
Append2.prototype.forEachInvertedInner = function forEachInvertedInner(f, from4, to, start3) {
var leftLen = this.left.length;
if (from4 > leftLen && this.right.forEachInvertedInner(f, from4 - leftLen, Math.max(to, leftLen) - leftLen, start3 + leftLen) === false) {
return false;
}
if (to < leftLen && this.left.forEachInvertedInner(f, Math.min(from4, leftLen), to, start3) === false) {
return false;
}
};
Append2.prototype.sliceInner = function sliceInner(from4, to) {
if (from4 == 0 && to == this.length) {
return this;
}
var leftLen = this.left.length;
if (to <= leftLen) {
return this.left.slice(from4, to);
}
if (from4 >= leftLen) {
return this.right.slice(from4 - leftLen, to - leftLen);
}
return this.left.slice(from4, leftLen).append(this.right.slice(0, to - leftLen));
};
Append2.prototype.leafAppend = function leafAppend(other) {
var inner = this.right.leafAppend(other);
if (inner) {
return new Append2(this.left, inner);
}
};
Append2.prototype.leafPrepend = function leafPrepend(other) {
var inner = this.left.leafPrepend(other);
if (inner) {
return new Append2(inner, this.right);
}
};
Append2.prototype.appendInner = function appendInner2(other) {
if (this.left.depth >= Math.max(this.right.depth, other.depth) + 1) {
return new Append2(this.left, new Append2(this.right, other));
}
return new Append2(this, other);
};
return Append2;
}(RopeSequence);
var ropeSequence = RopeSequence;
var max_empty_items = 500;
var Branch = function Branch2(items, eventCount) {
this.items = items;
this.eventCount = eventCount;
};
Branch.prototype.popEvent = function popEvent(state, preserveItems) {
var this$1 = this;
if (this.eventCount == 0) {
return null;
}
var end2 = this.items.length;
for (; ; end2--) {
var next2 = this.items.get(end2 - 1);
if (next2.selection) {
--end2;
break;
}
}
var remap, mapFrom;
if (preserveItems) {
remap = this.remapping(end2, this.items.length);
mapFrom = remap.maps.length;
}
var transform = state.tr;
var selection, remaining;
var addAfter = [], addBefore = [];
this.items.forEach(function(item, i) {
if (!item.step) {
if (!remap) {
remap = this$1.remapping(end2, i + 1);
mapFrom = remap.maps.length;
}
mapFrom--;
addBefore.push(item);
return;
}
if (remap) {
addBefore.push(new Item(item.map));
var step2 = item.step.map(remap.slice(mapFrom)), map16;
if (step2 && transform.maybeStep(step2).doc) {
map16 = transform.mapping.maps[transform.mapping.maps.length - 1];
addAfter.push(new Item(map16, null, null, addAfter.length + addBefore.length));
}
mapFrom--;
if (map16) {
remap.appendMap(map16, mapFrom);
}
} else {
transform.maybeStep(item.step);
}
if (item.selection) {
selection = remap ? item.selection.map(remap.slice(mapFrom)) : item.selection;
remaining = new Branch(this$1.items.slice(0, end2).append(addBefore.reverse().concat(addAfter)), this$1.eventCount - 1);
return false;
}
}, this.items.length, 0);
return {remaining, transform, selection};
};
Branch.prototype.addTransform = function addTransform(transform, selection, histOptions, preserveItems) {
var newItems = [], eventCount = this.eventCount;
var oldItems = this.items, lastItem = !preserveItems && oldItems.length ? oldItems.get(oldItems.length - 1) : null;
for (var i = 0; i < transform.steps.length; i++) {
var step2 = transform.steps[i].invert(transform.docs[i]);
var item = new Item(transform.mapping.maps[i], step2, selection), merged = void 0;
if (merged = lastItem && lastItem.merge(item)) {
item = merged;
if (i) {
newItems.pop();
} else {
oldItems = oldItems.slice(0, oldItems.length - 1);
}
}
newItems.push(item);
if (selection) {
eventCount++;
selection = null;
}
if (!preserveItems) {
lastItem = item;
}
}
var overflow = eventCount - histOptions.depth;
if (overflow > DEPTH_OVERFLOW) {
oldItems = cutOffEvents(oldItems, overflow);
eventCount -= overflow;
}
return new Branch(oldItems.append(newItems), eventCount);
};
Branch.prototype.remapping = function remapping(from4, to) {
var maps = new Mapping();
this.items.forEach(function(item, i) {
var mirrorPos = item.mirrorOffset != null && i - item.mirrorOffset >= from4 ? maps.maps.length - item.mirrorOffset : null;
maps.appendMap(item.map, mirrorPos);
}, from4, to);
return maps;
};
Branch.prototype.addMaps = function addMaps(array) {
if (this.eventCount == 0) {
return this;
}
return new Branch(this.items.append(array.map(function(map16) {
return new Item(map16);
})), this.eventCount);
};
Branch.prototype.rebased = function rebased(rebasedTransform, rebasedCount) {
if (!this.eventCount) {
return this;
}
var rebasedItems = [], start3 = Math.max(0, this.items.length - rebasedCount);
var mapping = rebasedTransform.mapping;
var newUntil = rebasedTransform.steps.length;
var eventCount = this.eventCount;
this.items.forEach(function(item) {
if (item.selection) {
eventCount--;
}
}, start3);
var iRebased = rebasedCount;
this.items.forEach(function(item) {
var pos = mapping.getMirror(--iRebased);
if (pos == null) {
return;
}
newUntil = Math.min(newUntil, pos);
var map16 = mapping.maps[pos];
if (item.step) {
var step2 = rebasedTransform.steps[pos].invert(rebasedTransform.docs[pos]);
var selection = item.selection && item.selection.map(mapping.slice(iRebased + 1, pos));
if (selection) {
eventCount++;
}
rebasedItems.push(new Item(map16, step2, selection));
} else {
rebasedItems.push(new Item(map16));
}
}, start3);
var newMaps = [];
for (var i = rebasedCount; i < newUntil; i++) {
newMaps.push(new Item(mapping.maps[i]));
}
var items = this.items.slice(0, start3).append(newMaps).append(rebasedItems);
var branch = new Branch(items, eventCount);
if (branch.emptyItemCount() > max_empty_items) {
branch = branch.compress(this.items.length - rebasedItems.length);
}
return branch;
};
Branch.prototype.emptyItemCount = function emptyItemCount() {
var count = 0;
this.items.forEach(function(item) {
if (!item.step) {
count++;
}
});
return count;
};
Branch.prototype.compress = function compress(upto) {
if (upto === void 0)
upto = this.items.length;
var remap = this.remapping(0, upto), mapFrom = remap.maps.length;
var items = [], events2 = 0;
this.items.forEach(function(item, i) {
if (i >= upto) {
items.push(item);
if (item.selection) {
events2++;
}
} else if (item.step) {
var step2 = item.step.map(remap.slice(mapFrom)), map16 = step2 && step2.getMap();
mapFrom--;
if (map16) {
remap.appendMap(map16, mapFrom);
}
if (step2) {
var selection = item.selection && item.selection.map(remap.slice(mapFrom));
if (selection) {
events2++;
}
var newItem = new Item(map16.invert(), step2, selection), merged, last2 = items.length - 1;
if (merged = items.length && items[last2].merge(newItem)) {
items[last2] = merged;
} else {
items.push(newItem);
}
}
} else if (item.map) {
mapFrom--;
}
}, this.items.length, 0);
return new Branch(ropeSequence.from(items.reverse()), events2);
};
Branch.empty = new Branch(ropeSequence.empty, 0);
function cutOffEvents(items, n) {
var cutPoint;
items.forEach(function(item, i) {
if (item.selection && n-- == 0) {
cutPoint = i;
return false;
}
});
return items.slice(cutPoint);
}
var Item = function Item2(map16, step2, selection, mirrorOffset) {
this.map = map16;
this.step = step2;
this.selection = selection;
this.mirrorOffset = mirrorOffset;
};
Item.prototype.merge = function merge2(other) {
if (this.step && other.step && !other.selection) {
var step2 = other.step.merge(this.step);
if (step2) {
return new Item(step2.getMap().invert(), step2, this.selection);
}
}
};
var HistoryState = function HistoryState2(done2, undone, prevRanges, prevTime) {
this.done = done2;
this.undone = undone;
this.prevRanges = prevRanges;
this.prevTime = prevTime;
};
var DEPTH_OVERFLOW = 20;
function applyTransaction2(history2, state, tr, options) {
var historyTr = tr.getMeta(historyKey), rebased2;
if (historyTr) {
return historyTr.historyState;
}
if (tr.getMeta(closeHistoryKey)) {
history2 = new HistoryState(history2.done, history2.undone, null, 0);
}
var appended = tr.getMeta("appendedTransaction");
if (tr.steps.length == 0) {
return history2;
} else if (appended && appended.getMeta(historyKey)) {
if (appended.getMeta(historyKey).redo) {
return new HistoryState(history2.done.addTransform(tr, null, options, mustPreserveItems(state)), history2.undone, rangesFor(tr.mapping.maps[tr.steps.length - 1]), history2.prevTime);
} else {
return new HistoryState(history2.done, history2.undone.addTransform(tr, null, options, mustPreserveItems(state)), null, history2.prevTime);
}
} else if (tr.getMeta("addToHistory") !== false && !(appended && appended.getMeta("addToHistory") === false)) {
var newGroup = history2.prevTime == 0 || !appended && (history2.prevTime < (tr.time || 0) - options.newGroupDelay || !isAdjacentTo(tr, history2.prevRanges));
var prevRanges = appended ? mapRanges(history2.prevRanges, tr.mapping) : rangesFor(tr.mapping.maps[tr.steps.length - 1]);
return new HistoryState(history2.done.addTransform(tr, newGroup ? state.selection.getBookmark() : null, options, mustPreserveItems(state)), Branch.empty, prevRanges, tr.time);
} else if (rebased2 = tr.getMeta("rebased")) {
return new HistoryState(history2.done.rebased(tr, rebased2), history2.undone.rebased(tr, rebased2), mapRanges(history2.prevRanges, tr.mapping), history2.prevTime);
} else {
return new HistoryState(history2.done.addMaps(tr.mapping.maps), history2.undone.addMaps(tr.mapping.maps), mapRanges(history2.prevRanges, tr.mapping), history2.prevTime);
}
}
function isAdjacentTo(transform, prevRanges) {
if (!prevRanges) {
return false;
}
if (!transform.docChanged) {
return true;
}
var adjacent = false;
transform.mapping.maps[0].forEach(function(start3, end2) {
for (var i = 0; i < prevRanges.length; i += 2) {
if (start3 <= prevRanges[i + 1] && end2 >= prevRanges[i]) {
adjacent = true;
}
}
});
return adjacent;
}
function rangesFor(map16) {
var result2 = [];
map16.forEach(function(_from, _to, from4, to) {
return result2.push(from4, to);
});
return result2;
}
function mapRanges(ranges, mapping) {
if (!ranges) {
return null;
}
var result2 = [];
for (var i = 0; i < ranges.length; i += 2) {
var from4 = mapping.map(ranges[i], 1), to = mapping.map(ranges[i + 1], -1);
if (from4 <= to) {
result2.push(from4, to);
}
}
return result2;
}
function histTransaction(history2, state, dispatch2, redo2) {
var preserveItems = mustPreserveItems(state), histOptions = historyKey.get(state).spec.config;
var pop = (redo2 ? history2.undone : history2.done).popEvent(state, preserveItems);
if (!pop) {
return;
}
var selection = pop.selection.resolve(pop.transform.doc);
var added = (redo2 ? history2.done : history2.undone).addTransform(pop.transform, state.selection.getBookmark(), histOptions, preserveItems);
var newHist = new HistoryState(redo2 ? added : pop.remaining, redo2 ? pop.remaining : added, null, 0);
dispatch2(pop.transform.setSelection(selection).setMeta(historyKey, {redo: redo2, historyState: newHist}).scrollIntoView());
}
var cachedPreserveItems = false, cachedPreserveItemsPlugins = null;
function mustPreserveItems(state) {
var plugins2 = state.plugins;
if (cachedPreserveItemsPlugins != plugins2) {
cachedPreserveItems = false;
cachedPreserveItemsPlugins = plugins2;
for (var i = 0; i < plugins2.length; i++) {
if (plugins2[i].spec.historyPreserveItems) {
cachedPreserveItems = true;
break;
}
}
}
return cachedPreserveItems;
}
var historyKey = new PluginKey("history");
var closeHistoryKey = new PluginKey("closeHistory");
function history(config2) {
config2 = {
depth: config2 && config2.depth || 100,
newGroupDelay: config2 && config2.newGroupDelay || 500
};
return new Plugin({
key: historyKey,
state: {
init: function init7() {
return new HistoryState(Branch.empty, Branch.empty, null, 0);
},
apply: function apply8(tr, hist, state) {
return applyTransaction2(hist, state, tr, config2);
}
},
config: config2
});
}
function undo(state, dispatch2) {
var hist = historyKey.getState(state);
if (!hist || hist.done.eventCount == 0) {
return false;
}
if (dispatch2) {
histTransaction(hist, state, dispatch2, false);
}
return true;
}
function redo(state, dispatch2) {
var hist = historyKey.getState(state);
if (!hist || hist.undone.eventCount == 0) {
return false;
}
if (dispatch2) {
histTransaction(hist, state, dispatch2, true);
}
return true;
}
function undoDepth(state) {
var hist = historyKey.getState(state);
return hist ? hist.done.eventCount : 0;
}
function redoDepth(state) {
var hist = historyKey.getState(state);
return hist ? hist.undone.eventCount : 0;
}
class BulletList extends Node$1 {
get name() {
return "bullet_list";
}
get schema() {
return {
content: "list_item+",
group: "block",
parseDOM: [{
tag: "ul"
}],
toDOM: () => ["ul", 0]
};
}
commands({
type,
schema
}) {
return () => toggleList(type, schema.nodes.list_item);
}
keys({
type,
schema
}) {
return {
"Shift-Ctrl-8": toggleList(type, schema.nodes.list_item)
};
}
inputRules({
type
}) {
return [wrappingInputRule(/^\s*([-+*])\s$/, type)];
}
}
class HardBreak extends Node$1 {
get name() {
return "hard_break";
}
get schema() {
return {
inline: true,
group: "inline",
selectable: false,
parseDOM: [{
tag: "br"
}],
toDOM: () => ["br"]
};
}
commands({
type
}) {
return () => chainCommands(exitCode, (state, dispatch2) => {
dispatch2(state.tr.replaceSelectionWith(type.create()).scrollIntoView());
return true;
});
}
keys({
type
}) {
const command = chainCommands(exitCode, (state, dispatch2) => {
dispatch2(state.tr.replaceSelectionWith(type.create()).scrollIntoView());
return true;
});
return {
"Mod-Enter": command,
"Shift-Enter": command
};
}
}
class Heading extends Node$1 {
get name() {
return "heading";
}
get defaultOptions() {
return {
levels: [1, 2, 3, 4, 5, 6]
};
}
get schema() {
return {
attrs: {
level: {
default: 1
}
},
content: "inline*",
group: "block",
defining: true,
draggable: false,
parseDOM: this.options.levels.map((level) => ({
tag: "h".concat(level),
attrs: {
level
}
})),
toDOM: (node4) => ["h".concat(node4.attrs.level), 0]
};
}
commands({
type,
schema
}) {
return (attrs2) => toggleBlockType(type, schema.nodes.paragraph, attrs2);
}
keys({
type
}) {
return this.options.levels.reduce((items, level) => __assign(__assign({}, items), {
["Shift-Ctrl-".concat(level)]: setBlockType(type, {
level
})
}), {});
}
inputRules({
type
}) {
return this.options.levels.map((level) => textblockTypeInputRule(new RegExp("^(#{1,".concat(level, "})\\s$")), type, () => ({
level
})));
}
}
class HorizontalRule extends Node$1 {
get name() {
return "horizontal_rule";
}
get schema() {
return {
group: "block",
parseDOM: [{
tag: "hr"
}],
toDOM: () => ["hr"]
};
}
commands({
type
}) {
return () => (state, dispatch2) => dispatch2(state.tr.replaceSelectionWith(type.create()));
}
inputRules({
type
}) {
return [nodeInputRule(/^(?:---|___\s|\*\*\*\s)$/, type)];
}
}
class ListItem extends Node$1 {
get name() {
return "list_item";
}
get schema() {
return {
content: "paragraph block*",
defining: true,
draggable: false,
parseDOM: [{
tag: "li"
}],
toDOM: () => ["li", 0]
};
}
keys({
type
}) {
return {
Enter: splitListItem(type),
Tab: sinkListItem(type),
"Shift-Tab": liftListItem(type)
};
}
}
class OrderedList extends Node$1 {
get name() {
return "ordered_list";
}
get schema() {
return {
attrs: {
order: {
default: 1
}
},
content: "list_item+",
group: "block",
parseDOM: [{
tag: "ol",
getAttrs: (dom) => ({
order: dom.hasAttribute("start") ? +dom.getAttribute("start") : 1
})
}],
toDOM: (node4) => node4.attrs.order === 1 ? ["ol", 0] : ["ol", {
start: node4.attrs.order
}, 0]
};
}
commands({
type,
schema
}) {
return () => toggleList(type, schema.nodes.list_item);
}
keys({
type,
schema
}) {
return {
"Shift-Ctrl-9": toggleList(type, schema.nodes.list_item)
};
}
inputRules({
type
}) {
return [wrappingInputRule(/^(\d+)\.\s$/, type, (match3) => ({
order: +match3[1]
}), (match3, node4) => node4.childCount + node4.attrs.order === +match3[1])];
}
}
tableNodes({
tableGroup: "block",
cellContent: "block+",
cellAttributes: {
background: {
default: null,
getFromDOM(dom) {
return dom.style.backgroundColor || null;
},
setDOMAttr(value, attrs2) {
if (value) {
const style2 = {
style: "".concat(attrs2.style || "", "background-color: ").concat(value, ";")
};
Object.assign(attrs2, style2);
}
}
}
}
});
class Bold extends Mark2 {
get name() {
return "bold";
}
get schema() {
return {
parseDOM: [{
tag: "strong"
}, {
tag: "b",
getAttrs: (node4) => node4.style.fontWeight !== "normal" && null
}, {
style: "font-weight",
getAttrs: (value) => /^(bold(er)?|[5-9]\d{2,})$/.test(value) && null
}],
toDOM: () => ["strong", 0]
};
}
keys({
type
}) {
return {
"Mod-b": toggleMark(type)
};
}
commands({
type
}) {
return () => toggleMark(type);
}
inputRules({
type
}) {
return [markInputRule(/(?:\*\*|__)([^*_]+)(?:\*\*|__)$/, type)];
}
pasteRules({
type
}) {
return [markPasteRule(/(?:\*\*|__)([^*_]+)(?:\*\*|__)/g, type)];
}
}
class Code extends Mark2 {
get name() {
return "code";
}
get schema() {
return {
excludes: "_",
parseDOM: [{
tag: "code"
}],
toDOM: () => ["code", 0]
};
}
keys({
type
}) {
return {
"Mod-`": toggleMark(type)
};
}
commands({
type
}) {
return () => toggleMark(type);
}
inputRules({
type
}) {
return [markInputRule(/(?:`)([^`]+)(?:`)$/, type)];
}
pasteRules({
type
}) {
return [markPasteRule(/(?:`)([^`]+)(?:`)/g, type)];
}
}
class Italic extends Mark2 {
get name() {
return "italic";
}
get schema() {
return {
parseDOM: [{
tag: "i"
}, {
tag: "em"
}, {
style: "font-style=italic"
}],
toDOM: () => ["em", 0]
};
}
keys({
type
}) {
return {
"Mod-i": toggleMark(type)
};
}
commands({
type
}) {
return () => toggleMark(type);
}
inputRules({
type
}) {
return [markInputRule(/(?:^|[^_])(_([^_]+)_)$/, type), markInputRule(/(?:^|[^*])(\*([^*]+)\*)$/, type)];
}
pasteRules({
type
}) {
return [markPasteRule(/_([^_]+)_/g, type), markPasteRule(/\*([^*]+)\*/g, type)];
}
}
class Link extends Mark2 {
get name() {
return "link";
}
get defaultOptions() {
return {
openOnClick: true,
target: null
};
}
get schema() {
return {
attrs: {
href: {
default: null
},
target: {
default: null
}
},
inclusive: false,
parseDOM: [{
tag: "a[href]",
getAttrs: (dom) => ({
href: dom.getAttribute("href"),
target: dom.getAttribute("target")
})
}],
toDOM: (node4) => ["a", __assign(__assign({}, node4.attrs), {
rel: "noopener noreferrer nofollow",
target: node4.attrs.target || this.options.target
}), 0]
};
}
commands({
type
}) {
return (attrs2) => {
if (attrs2.href) {
return updateMark(type, attrs2);
}
return removeMark(type);
};
}
pasteRules({
type
}) {
return [pasteRule(/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z]{2,}\b([-a-zA-Z0-9@:%_+.~#?&//=,()!]*)/gi, type, (url) => ({
href: url
}))];
}
get plugins() {
if (!this.options.openOnClick) {
return [];
}
return [new Plugin({
props: {
handleClick: (view, pos, event) => {
const {
schema
} = view.state;
const attrs2 = getMarkAttrs(view.state, schema.marks.link);
if (attrs2.href && event.target instanceof HTMLAnchorElement) {
event.stopPropagation();
window.open(attrs2.href, attrs2.target);
}
}
}
})];
}
}
class Strike extends Mark2 {
get name() {
return "strike";
}
get schema() {
return {
parseDOM: [{
tag: "s"
}, {
tag: "del"
}, {
tag: "strike"
}, {
style: "text-decoration",
getAttrs: (value) => value === "line-through"
}],
toDOM: () => ["s", 0]
};
}
keys({
type
}) {
return {
"Mod-d": toggleMark(type)
};
}
commands({
type
}) {
return () => toggleMark(type);
}
inputRules({
type
}) {
return [markInputRule(/~([^~]+)~$/, type)];
}
pasteRules({
type
}) {
return [markPasteRule(/~([^~]+)~/g, type)];
}
}
class Underline extends Mark2 {
get name() {
return "underline";
}
get schema() {
return {
parseDOM: [{
tag: "u"
}, {
style: "text-decoration",
getAttrs: (value) => value === "underline"
}],
toDOM: () => ["u", 0]
};
}
keys({
type
}) {
return {
"Mod-u": toggleMark(type)
};
}
commands({
type
}) {
return () => toggleMark(type);
}
}
class History2 extends Extension {
get name() {
return "history";
}
get defaultOptions() {
return {
depth: "",
newGroupDelay: ""
};
}
keys() {
const keymap2 = {
"Mod-z": undo,
"Mod-y": redo,
"Shift-Mod-z": redo,
"Mod-\u044F": undo,
"Shift-Mod-\u044F": redo
};
return keymap2;
}
get plugins() {
return [history({
depth: this.options.depth,
newGroupDelay: this.options.newGroupDelay
})];
}
commands() {
return {
undo: () => undo,
redo: () => redo,
undoDepth: () => undoDepth,
redoDepth: () => redoDepth
};
}
}
class Placeholder extends Extension {
get name() {
return "placeholder";
}
get defaultOptions() {
return {
emptyEditorClass: "is-editor-empty",
emptyNodeClass: "is-empty",
emptyNodeText: "Write something \u2026",
showOnlyWhenEditable: true,
showOnlyCurrent: true
};
}
get plugins() {
return [new Plugin({
props: {
decorations: ({
doc: doc2,
plugins: plugins2,
selection
}) => {
const editablePlugin = plugins2.find((plugin) => plugin.key.startsWith("editable$"));
const editable = editablePlugin.props.editable();
const active = editable || !this.options.showOnlyWhenEditable;
const {
anchor
} = selection;
const decorations = [];
const isEditorEmpty = doc2.textContent.length === 0;
if (!active) {
return false;
}
doc2.descendants((node4, pos) => {
const hasAnchor = anchor >= pos && anchor <= pos + node4.nodeSize;
const isNodeEmpty = node4.content.size === 0;
if ((hasAnchor || !this.options.showOnlyCurrent) && isNodeEmpty) {
const classes = [this.options.emptyNodeClass];
if (isEditorEmpty) {
classes.push(this.options.emptyEditorClass);
}
const decoration = Decoration.node(pos, pos + node4.nodeSize, {
class: classes.join(" "),
"data-empty-text": typeof this.options.emptyNodeText === "function" ? this.options.emptyNodeText(node4) : this.options.emptyNodeText
});
decorations.push(decoration);
}
return false;
});
return DecorationSet.create(doc2, decorations);
}
}
})];
}
}
const HOOKS = [
"onChange",
"onClose",
"onDayCreate",
"onDestroy",
"onKeyDown",
"onMonthChange",
"onOpen",
"onParseConfig",
"onReady",
"onValueUpdate",
"onYearChange",
"onPreCalendarPosition"
];
const defaults$3 = {
_disable: [],
allowInput: false,
allowInvalidPreload: false,
altFormat: "F j, Y",
altInput: false,
altInputClass: "form-control input",
animate: typeof window === "object" && window.navigator.userAgent.indexOf("MSIE") === -1,
ariaDateFormat: "F j, Y",
autoFillDefaultTime: true,
clickOpens: true,
closeOnSelect: true,
conjunction: ", ",
dateFormat: "Y-m-d",
defaultHour: 12,
defaultMinute: 0,
defaultSeconds: 0,
disable: [],
disableMobile: false,
enableSeconds: false,
enableTime: false,
errorHandler: (err2) => typeof console !== "undefined" && console.warn(err2),
getWeek: (givenDate) => {
const date = new Date(givenDate.getTime());
date.setHours(0, 0, 0, 0);
date.setDate(date.getDate() + 3 - (date.getDay() + 6) % 7);
var week1 = new Date(date.getFullYear(), 0, 4);
return 1 + Math.round(((date.getTime() - week1.getTime()) / 864e5 - 3 + (week1.getDay() + 6) % 7) / 7);
},
hourIncrement: 1,
ignoredFocusElements: [],
inline: false,
locale: "default",
minuteIncrement: 5,
mode: "single",
monthSelectorType: "dropdown",
nextArrow: "<svg version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' viewBox='0 0 17 17'><g></g><path d='M13.207 8.472l-7.854 7.854-0.707-0.707 7.146-7.146-7.146-7.148 0.707-0.707 7.854 7.854z' /></svg>",
noCalendar: false,
now: new Date(),
onChange: [],
onClose: [],
onDayCreate: [],
onDestroy: [],
onKeyDown: [],
onMonthChange: [],
onOpen: [],
onParseConfig: [],
onReady: [],
onValueUpdate: [],
onYearChange: [],
onPreCalendarPosition: [],
plugins: [],
position: "auto",
positionElement: void 0,
prevArrow: "<svg version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' viewBox='0 0 17 17'><g></g><path d='M5.207 8.471l7.146 7.147-0.707 0.707-7.853-7.854 7.854-7.853 0.707 0.707-7.147 7.146z' /></svg>",
shorthandCurrentMonth: false,
showMonths: 1,
static: false,
time_24hr: false,
weekNumbers: false,
wrap: false
};
const english = {
weekdays: {
shorthand: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
longhand: [
"Sunday",
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday"
]
},
months: {
shorthand: [
"Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
"Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec"
],
longhand: [
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December"
]
},
daysInMonth: [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31],
firstDayOfWeek: 0,
ordinal: (nth) => {
const s = nth % 100;
if (s > 3 && s < 21)
return "th";
switch (s % 10) {
case 1:
return "st";
case 2:
return "nd";
case 3:
return "rd";
default:
return "th";
}
},
rangeSeparator: " to ",
weekAbbreviation: "Wk",
scrollTitle: "Scroll to increment",
toggleTitle: "Click to toggle",
amPM: ["AM", "PM"],
yearAriaLabel: "Year",
monthAriaLabel: "Month",
hourAriaLabel: "Hour",
minuteAriaLabel: "Minute",
time_24hr: false
};
const pad = (number, length = 2) => `000${number}`.slice(length * -1);
const int = (bool) => bool === true ? 1 : 0;
function debounce(fn, wait) {
let t;
return function() {
clearTimeout(t);
t = setTimeout(() => fn.apply(this, arguments), wait);
};
}
const arrayify = (obj) => obj instanceof Array ? obj : [obj];
function toggleClass$1(elem, className, bool) {
if (bool === true)
return elem.classList.add(className);
elem.classList.remove(className);
}
function createElement(tag2, className, content2) {
const e = window.document.createElement(tag2);
className = className || "";
content2 = content2 || "";
e.className = className;
if (content2 !== void 0)
e.textContent = content2;
return e;
}
function clearNode(node4) {
while (node4.firstChild)
node4.removeChild(node4.firstChild);
}
function findParent(node4, condition) {
if (condition(node4))
return node4;
else if (node4.parentNode)
return findParent(node4.parentNode, condition);
return void 0;
}
function createNumberInput(inputClassName, opts) {
const wrapper3 = createElement("div", "numInputWrapper"), numInput = createElement("input", "numInput " + inputClassName), arrowUp = createElement("span", "arrowUp"), arrowDown = createElement("span", "arrowDown");
if (navigator.userAgent.indexOf("MSIE 9.0") === -1) {
numInput.type = "number";
} else {
numInput.type = "text";
numInput.pattern = "\\d*";
}
if (opts !== void 0)
for (const key in opts)
numInput.setAttribute(key, opts[key]);
wrapper3.appendChild(numInput);
wrapper3.appendChild(arrowUp);
wrapper3.appendChild(arrowDown);
return wrapper3;
}
function getEventTarget(event) {
try {
if (typeof event.composedPath === "function") {
const path = event.composedPath();
return path[0];
}
return event.target;
} catch (error2) {
return event.target;
}
}
const doNothing = () => void 0;
const monthToStr = (monthNumber, shorthand, locale) => locale.months[shorthand ? "shorthand" : "longhand"][monthNumber];
const revFormat = {
D: doNothing,
F: function(dateObj, monthName, locale) {
dateObj.setMonth(locale.months.longhand.indexOf(monthName));
},
G: (dateObj, hour) => {
dateObj.setHours(parseFloat(hour));
},
H: (dateObj, hour) => {
dateObj.setHours(parseFloat(hour));
},
J: (dateObj, day) => {
dateObj.setDate(parseFloat(day));
},
K: (dateObj, amPM, locale) => {
dateObj.setHours(dateObj.getHours() % 12 + 12 * int(new RegExp(locale.amPM[1], "i").test(amPM)));
},
M: function(dateObj, shortMonth, locale) {
dateObj.setMonth(locale.months.shorthand.indexOf(shortMonth));
},
S: (dateObj, seconds) => {
dateObj.setSeconds(parseFloat(seconds));
},
U: (_2, unixSeconds) => new Date(parseFloat(unixSeconds) * 1e3),
W: function(dateObj, weekNum, locale) {
const weekNumber = parseInt(weekNum);
const date = new Date(dateObj.getFullYear(), 0, 2 + (weekNumber - 1) * 7, 0, 0, 0, 0);
date.setDate(date.getDate() - date.getDay() + locale.firstDayOfWeek);
return date;
},
Y: (dateObj, year) => {
dateObj.setFullYear(parseFloat(year));
},
Z: (_2, ISODate) => new Date(ISODate),
d: (dateObj, day) => {
dateObj.setDate(parseFloat(day));
},
h: (dateObj, hour) => {
dateObj.setHours(parseFloat(hour));
},
i: (dateObj, minutes) => {
dateObj.setMinutes(parseFloat(minutes));
},
j: (dateObj, day) => {
dateObj.setDate(parseFloat(day));
},
l: doNothing,
m: (dateObj, month) => {
dateObj.setMonth(parseFloat(month) - 1);
},
n: (dateObj, month) => {
dateObj.setMonth(parseFloat(month) - 1);
},
s: (dateObj, seconds) => {
dateObj.setSeconds(parseFloat(seconds));
},
u: (_2, unixMillSeconds) => new Date(parseFloat(unixMillSeconds)),
w: doNothing,
y: (dateObj, year) => {
dateObj.setFullYear(2e3 + parseFloat(year));
}
};
const tokenRegex = {
D: "(\\w+)",
F: "(\\w+)",
G: "(\\d\\d|\\d)",
H: "(\\d\\d|\\d)",
J: "(\\d\\d|\\d)\\w+",
K: "",
M: "(\\w+)",
S: "(\\d\\d|\\d)",
U: "(.+)",
W: "(\\d\\d|\\d)",
Y: "(\\d{4})",
Z: "(.+)",
d: "(\\d\\d|\\d)",
h: "(\\d\\d|\\d)",
i: "(\\d\\d|\\d)",
j: "(\\d\\d|\\d)",
l: "(\\w+)",
m: "(\\d\\d|\\d)",
n: "(\\d\\d|\\d)",
s: "(\\d\\d|\\d)",
u: "(.+)",
w: "(\\d\\d|\\d)",
y: "(\\d{2})"
};
const formats$1 = {
Z: (date) => date.toISOString(),
D: function(date, locale, options) {
return locale.weekdays.shorthand[formats$1.w(date, locale, options)];
},
F: function(date, locale, options) {
return monthToStr(formats$1.n(date, locale, options) - 1, false, locale);
},
G: function(date, locale, options) {
return pad(formats$1.h(date, locale, options));
},
H: (date) => pad(date.getHours()),
J: function(date, locale) {
return locale.ordinal !== void 0 ? date.getDate() + locale.ordinal(date.getDate()) : date.getDate();
},
K: (date, locale) => locale.amPM[int(date.getHours() > 11)],
M: function(date, locale) {
return monthToStr(date.getMonth(), true, locale);
},
S: (date) => pad(date.getSeconds()),
U: (date) => date.getTime() / 1e3,
W: function(date, _2, options) {
return options.getWeek(date);
},
Y: (date) => pad(date.getFullYear(), 4),
d: (date) => pad(date.getDate()),
h: (date) => date.getHours() % 12 ? date.getHours() % 12 : 12,
i: (date) => pad(date.getMinutes()),
j: (date) => date.getDate(),
l: function(date, locale) {
return locale.weekdays.longhand[date.getDay()];
},
m: (date) => pad(date.getMonth() + 1),
n: (date) => date.getMonth() + 1,
s: (date) => date.getSeconds(),
u: (date) => date.getTime(),
w: (date) => date.getDay(),
y: (date) => String(date.getFullYear()).substring(2)
};
const createDateFormatter = ({config: config2 = defaults$3, l10n = english, isMobile = false}) => (dateObj, frmt, overrideLocale) => {
const locale = overrideLocale || l10n;
if (config2.formatDate !== void 0 && !isMobile) {
return config2.formatDate(dateObj, frmt, locale);
}
return frmt.split("").map((c, i, arr) => formats$1[c] && arr[i - 1] !== "\\" ? formats$1[c](dateObj, locale, config2) : c !== "\\" ? c : "").join("");
};
const createDateParser = ({config: config2 = defaults$3, l10n = english}) => (date, givenFormat, timeless, customLocale) => {
if (date !== 0 && !date)
return void 0;
const locale = customLocale || l10n;
let parsedDate;
const dateOrig = date;
if (date instanceof Date)
parsedDate = new Date(date.getTime());
else if (typeof date !== "string" && date.toFixed !== void 0)
parsedDate = new Date(date);
else if (typeof date === "string") {
const format2 = givenFormat || (config2 || defaults$3).dateFormat;
const datestr = String(date).trim();
if (datestr === "today") {
parsedDate = new Date();
timeless = true;
} else if (/Z$/.test(datestr) || /GMT$/.test(datestr))
parsedDate = new Date(date);
else if (config2 && config2.parseDate)
parsedDate = config2.parseDate(date, format2);
else {
parsedDate = !config2 || !config2.noCalendar ? new Date(new Date().getFullYear(), 0, 1, 0, 0, 0, 0) : new Date(new Date().setHours(0, 0, 0, 0));
let matched, ops = [];
for (let i = 0, matchIndex = 0, regexStr = ""; i < format2.length; i++) {
const token = format2[i];
const isBackSlash = token === "\\";
const escaped = format2[i - 1] === "\\" || isBackSlash;
if (tokenRegex[token] && !escaped) {
regexStr += tokenRegex[token];
const match3 = new RegExp(regexStr).exec(date);
if (match3 && (matched = true)) {
ops[token !== "Y" ? "push" : "unshift"]({
fn: revFormat[token],
val: match3[++matchIndex]
});
}
} else if (!isBackSlash)
regexStr += ".";
ops.forEach(({fn, val}) => parsedDate = fn(parsedDate, val, locale) || parsedDate);
}
parsedDate = matched ? parsedDate : void 0;
}
}
if (!(parsedDate instanceof Date && !isNaN(parsedDate.getTime()))) {
config2.errorHandler(new Error(`Invalid date provided: ${dateOrig}`));
return void 0;
}
if (timeless === true)
parsedDate.setHours(0, 0, 0, 0);
return parsedDate;
};
function compareDates(date1, date2, timeless = true) {
if (timeless !== false) {
return new Date(date1.getTime()).setHours(0, 0, 0, 0) - new Date(date2.getTime()).setHours(0, 0, 0, 0);
}
return date1.getTime() - date2.getTime();
}
const isBetween = (ts, ts1, ts2) => {
return ts > Math.min(ts1, ts2) && ts < Math.max(ts1, ts2);
};
const duration = {
DAY: 864e5
};
function getDefaultHours(config2) {
let hours = config2.defaultHour;
let minutes = config2.defaultMinute;
let seconds = config2.defaultSeconds;
if (config2.minDate !== void 0) {
const minHour = config2.minDate.getHours();
const minMinutes = config2.minDate.getMinutes();
const minSeconds = config2.minDate.getSeconds();
if (hours < minHour) {
hours = minHour;
}
if (hours === minHour && minutes < minMinutes) {
minutes = minMinutes;
}
if (hours === minHour && minutes === minMinutes && seconds < minSeconds)
seconds = config2.minDate.getSeconds();
}
if (config2.maxDate !== void 0) {
const maxHr = config2.maxDate.getHours();
const maxMinutes = config2.maxDate.getMinutes();
hours = Math.min(hours, maxHr);
if (hours === maxHr)
minutes = Math.min(maxMinutes, minutes);
if (hours === maxHr && minutes === maxMinutes)
seconds = config2.maxDate.getSeconds();
}
return {hours, minutes, seconds};
}
if (typeof Object.assign !== "function") {
Object.assign = function(target2, ...args) {
if (!target2) {
throw TypeError("Cannot convert undefined or null to object");
}
for (const source2 of args) {
if (source2) {
Object.keys(source2).forEach((key) => target2[key] = source2[key]);
}
}
return target2;
};
}
const DEBOUNCED_CHANGE_MS = 300;
function FlatpickrInstance(element, instanceConfig) {
const self2 = {
config: Object.assign(Object.assign({}, defaults$3), flatpickr.defaultConfig),
l10n: english
};
self2.parseDate = createDateParser({config: self2.config, l10n: self2.l10n});
self2._handlers = [];
self2.pluginElements = [];
self2.loadedPlugins = [];
self2._bind = bind4;
self2._setHoursFromDate = setHoursFromDate;
self2._positionCalendar = positionCalendar;
self2.changeMonth = changeMonth;
self2.changeYear = changeYear;
self2.clear = clear;
self2.close = close3;
self2._createElement = createElement;
self2.destroy = destroy7;
self2.isEnabled = isEnabled;
self2.jumpToDate = jumpToDate;
self2.open = open2;
self2.redraw = redraw;
self2.set = set3;
self2.setDate = setDate;
self2.toggle = toggle;
function setupHelperFunctions() {
self2.utils = {
getDaysInMonth(month = self2.currentMonth, yr = self2.currentYear) {
if (month === 1 && (yr % 4 === 0 && yr % 100 !== 0 || yr % 400 === 0))
return 29;
return self2.l10n.daysInMonth[month];
}
};
}
function init7() {
self2.element = self2.input = element;
self2.isOpen = false;
parseConfig();
setupLocale();
setupInputs();
setupDates();
setupHelperFunctions();
if (!self2.isMobile)
build();
bindEvents();
if (self2.selectedDates.length || self2.config.noCalendar) {
if (self2.config.enableTime) {
setHoursFromDate(self2.config.noCalendar ? self2.latestSelectedDateObj : void 0);
}
updateValue(false);
}
setCalendarWidth();
const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
if (!self2.isMobile && isSafari) {
positionCalendar();
}
triggerEvent("onReady");
}
function bindToInstance(fn) {
return fn.bind(self2);
}
function setCalendarWidth() {
const config2 = self2.config;
if (config2.weekNumbers === false && config2.showMonths === 1) {
return;
} else if (config2.noCalendar !== true) {
window.requestAnimationFrame(function() {
if (self2.calendarContainer !== void 0) {
self2.calendarContainer.style.visibility = "hidden";
self2.calendarContainer.style.display = "block";
}
if (self2.daysContainer !== void 0) {
const daysWidth = (self2.days.offsetWidth + 1) * config2.showMonths;
self2.daysContainer.style.width = daysWidth + "px";
self2.calendarContainer.style.width = daysWidth + (self2.weekWrapper !== void 0 ? self2.weekWrapper.offsetWidth : 0) + "px";
self2.calendarContainer.style.removeProperty("visibility");
self2.calendarContainer.style.removeProperty("display");
}
});
}
}
function updateTime(e) {
if (self2.selectedDates.length === 0) {
const defaultDate = self2.config.minDate === void 0 || compareDates(new Date(), self2.config.minDate) >= 0 ? new Date() : new Date(self2.config.minDate.getTime());
const defaults2 = getDefaultHours(self2.config);
defaultDate.setHours(defaults2.hours, defaults2.minutes, defaults2.seconds, defaultDate.getMilliseconds());
self2.selectedDates = [defaultDate];
self2.latestSelectedDateObj = defaultDate;
}
if (e !== void 0 && e.type !== "blur") {
timeWrapper(e);
}
const prevValue = self2._input.value;
setHoursFromInputs();
updateValue();
if (self2._input.value !== prevValue) {
self2._debouncedChange();
}
}
function ampm2military(hour, amPM) {
return hour % 12 + 12 * int(amPM === self2.l10n.amPM[1]);
}
function military2ampm(hour) {
switch (hour % 24) {
case 0:
case 12:
return 12;
default:
return hour % 12;
}
}
function setHoursFromInputs() {
if (self2.hourElement === void 0 || self2.minuteElement === void 0)
return;
let hours = (parseInt(self2.hourElement.value.slice(-2), 10) || 0) % 24, minutes = (parseInt(self2.minuteElement.value, 10) || 0) % 60, seconds = self2.secondElement !== void 0 ? (parseInt(self2.secondElement.value, 10) || 0) % 60 : 0;
if (self2.amPM !== void 0) {
hours = ampm2military(hours, self2.amPM.textContent);
}
const limitMinHours = self2.config.minTime !== void 0 || self2.config.minDate && self2.minDateHasTime && self2.latestSelectedDateObj && compareDates(self2.latestSelectedDateObj, self2.config.minDate, true) === 0;
const limitMaxHours = self2.config.maxTime !== void 0 || self2.config.maxDate && self2.maxDateHasTime && self2.latestSelectedDateObj && compareDates(self2.latestSelectedDateObj, self2.config.maxDate, true) === 0;
if (limitMaxHours) {
const maxTime = self2.config.maxTime !== void 0 ? self2.config.maxTime : self2.config.maxDate;
hours = Math.min(hours, maxTime.getHours());
if (hours === maxTime.getHours())
minutes = Math.min(minutes, maxTime.getMinutes());
if (minutes === maxTime.getMinutes())
seconds = Math.min(seconds, maxTime.getSeconds());
}
if (limitMinHours) {
const minTime = self2.config.minTime !== void 0 ? self2.config.minTime : self2.config.minDate;
hours = Math.max(hours, minTime.getHours());
if (hours === minTime.getHours() && minutes < minTime.getMinutes())
minutes = minTime.getMinutes();
if (minutes === minTime.getMinutes())
seconds = Math.max(seconds, minTime.getSeconds());
}
setHours(hours, minutes, seconds);
}
function setHoursFromDate(dateObj) {
const date = dateObj || self2.latestSelectedDateObj;
if (date) {
setHours(date.getHours(), date.getMinutes(), date.getSeconds());
}
}
function setHours(hours, minutes, seconds) {
if (self2.latestSelectedDateObj !== void 0) {
self2.latestSelectedDateObj.setHours(hours % 24, minutes, seconds || 0, 0);
}
if (!self2.hourElement || !self2.minuteElement || self2.isMobile)
return;
self2.hourElement.value = pad(!self2.config.time_24hr ? (12 + hours) % 12 + 12 * int(hours % 12 === 0) : hours);
self2.minuteElement.value = pad(minutes);
if (self2.amPM !== void 0)
self2.amPM.textContent = self2.l10n.amPM[int(hours >= 12)];
if (self2.secondElement !== void 0)
self2.secondElement.value = pad(seconds);
}
function onYearInput(event) {
const eventTarget = getEventTarget(event);
const year = parseInt(eventTarget.value) + (event.delta || 0);
if (year / 1e3 > 1 || event.key === "Enter" && !/[^\d]/.test(year.toString())) {
changeYear(year);
}
}
function bind4(element2, event, handler, options) {
if (event instanceof Array)
return event.forEach((ev) => bind4(element2, ev, handler, options));
if (element2 instanceof Array)
return element2.forEach((el) => bind4(el, event, handler, options));
element2.addEventListener(event, handler, options);
self2._handlers.push({
remove: () => element2.removeEventListener(event, handler)
});
}
function triggerChange() {
triggerEvent("onChange");
}
function bindEvents() {
if (self2.config.wrap) {
["open", "close", "toggle", "clear"].forEach((evt) => {
Array.prototype.forEach.call(self2.element.querySelectorAll(`[data-${evt}]`), (el) => bind4(el, "click", self2[evt]));
});
}
if (self2.isMobile) {
setupMobile();
return;
}
const debouncedResize = debounce(onResize, 50);
self2._debouncedChange = debounce(triggerChange, DEBOUNCED_CHANGE_MS);
if (self2.daysContainer && !/iPhone|iPad|iPod/i.test(navigator.userAgent))
bind4(self2.daysContainer, "mouseover", (e) => {
if (self2.config.mode === "range")
onMouseOver(getEventTarget(e));
});
bind4(window.document.body, "keydown", onKeyDown);
if (!self2.config.inline && !self2.config.static)
bind4(window, "resize", debouncedResize);
if (window.ontouchstart !== void 0)
bind4(window.document, "touchstart", documentClick);
else
bind4(window.document, "mousedown", documentClick);
bind4(window.document, "focus", documentClick, {capture: true});
if (self2.config.clickOpens === true) {
bind4(self2._input, "focus", self2.open);
bind4(self2._input, "click", self2.open);
}
if (self2.daysContainer !== void 0) {
bind4(self2.monthNav, "click", onMonthNavClick);
bind4(self2.monthNav, ["keyup", "increment"], onYearInput);
bind4(self2.daysContainer, "click", selectDate);
}
if (self2.timeContainer !== void 0 && self2.minuteElement !== void 0 && self2.hourElement !== void 0) {
const selText = (e) => getEventTarget(e).select();
bind4(self2.timeContainer, ["increment"], updateTime);
bind4(self2.timeContainer, "blur", updateTime, {capture: true});
bind4(self2.timeContainer, "click", timeIncrement);
bind4([self2.hourElement, self2.minuteElement], ["focus", "click"], selText);
if (self2.secondElement !== void 0)
bind4(self2.secondElement, "focus", () => self2.secondElement && self2.secondElement.select());
if (self2.amPM !== void 0) {
bind4(self2.amPM, "click", (e) => {
updateTime(e);
triggerChange();
});
}
}
if (self2.config.allowInput) {
bind4(self2._input, "blur", onBlur);
}
}
function jumpToDate(jumpDate, triggerChange2) {
const jumpTo = jumpDate !== void 0 ? self2.parseDate(jumpDate) : self2.latestSelectedDateObj || (self2.config.minDate && self2.config.minDate > self2.now ? self2.config.minDate : self2.config.maxDate && self2.config.maxDate < self2.now ? self2.config.maxDate : self2.now);
const oldYear = self2.currentYear;
const oldMonth = self2.currentMonth;
try {
if (jumpTo !== void 0) {
self2.currentYear = jumpTo.getFullYear();
self2.currentMonth = jumpTo.getMonth();
}
} catch (e) {
e.message = "Invalid date supplied: " + jumpTo;
self2.config.errorHandler(e);
}
if (triggerChange2 && self2.currentYear !== oldYear) {
triggerEvent("onYearChange");
buildMonthSwitch();
}
if (triggerChange2 && (self2.currentYear !== oldYear || self2.currentMonth !== oldMonth)) {
triggerEvent("onMonthChange");
}
self2.redraw();
}
function timeIncrement(e) {
const eventTarget = getEventTarget(e);
if (~eventTarget.className.indexOf("arrow"))
incrementNumInput(e, eventTarget.classList.contains("arrowUp") ? 1 : -1);
}
function incrementNumInput(e, delta, inputElem) {
const target2 = e && getEventTarget(e);
const input = inputElem || target2 && target2.parentNode && target2.parentNode.firstChild;
const event = createEvent("increment");
event.delta = delta;
input && input.dispatchEvent(event);
}
function build() {
const fragment = window.document.createDocumentFragment();
self2.calendarContainer = createElement("div", "flatpickr-calendar");
self2.calendarContainer.tabIndex = -1;
if (!self2.config.noCalendar) {
fragment.appendChild(buildMonthNav());
self2.innerContainer = createElement("div", "flatpickr-innerContainer");
if (self2.config.weekNumbers) {
const {weekWrapper, weekNumbers} = buildWeeks();
self2.innerContainer.appendChild(weekWrapper);
self2.weekNumbers = weekNumbers;
self2.weekWrapper = weekWrapper;
}
self2.rContainer = createElement("div", "flatpickr-rContainer");
self2.rContainer.appendChild(buildWeekdays());
if (!self2.daysContainer) {
self2.daysContainer = createElement("div", "flatpickr-days");
self2.daysContainer.tabIndex = -1;
}
buildDays();
self2.rContainer.appendChild(self2.daysContainer);
self2.innerContainer.appendChild(self2.rContainer);
fragment.appendChild(self2.innerContainer);
}
if (self2.config.enableTime) {
fragment.appendChild(buildTime());
}
toggleClass$1(self2.calendarContainer, "rangeMode", self2.config.mode === "range");
toggleClass$1(self2.calendarContainer, "animate", self2.config.animate === true);
toggleClass$1(self2.calendarContainer, "multiMonth", self2.config.showMonths > 1);
self2.calendarContainer.appendChild(fragment);
const customAppend = self2.config.appendTo !== void 0 && self2.config.appendTo.nodeType !== void 0;
if (self2.config.inline || self2.config.static) {
self2.calendarContainer.classList.add(self2.config.inline ? "inline" : "static");
if (self2.config.inline) {
if (!customAppend && self2.element.parentNode)
self2.element.parentNode.insertBefore(self2.calendarContainer, self2._input.nextSibling);
else if (self2.config.appendTo !== void 0)
self2.config.appendTo.appendChild(self2.calendarContainer);
}
if (self2.config.static) {
const wrapper3 = createElement("div", "flatpickr-wrapper");
if (self2.element.parentNode)
self2.element.parentNode.insertBefore(wrapper3, self2.element);
wrapper3.appendChild(self2.element);
if (self2.altInput)
wrapper3.appendChild(self2.altInput);
wrapper3.appendChild(self2.calendarContainer);
}
}
if (!self2.config.static && !self2.config.inline)
(self2.config.appendTo !== void 0 ? self2.config.appendTo : window.document.body).appendChild(self2.calendarContainer);
}
function createDay(className, date, dayNumber, i) {
const dateIsEnabled = isEnabled(date, true), dayElement = createElement("span", "flatpickr-day " + className, date.getDate().toString());
dayElement.dateObj = date;
dayElement.$i = i;
dayElement.setAttribute("aria-label", self2.formatDate(date, self2.config.ariaDateFormat));
if (className.indexOf("hidden") === -1 && compareDates(date, self2.now) === 0) {
self2.todayDateElem = dayElement;
dayElement.classList.add("today");
dayElement.setAttribute("aria-current", "date");
}
if (dateIsEnabled) {
dayElement.tabIndex = -1;
if (isDateSelected(date)) {
dayElement.classList.add("selected");
self2.selectedDateElem = dayElement;
if (self2.config.mode === "range") {
toggleClass$1(dayElement, "startRange", self2.selectedDates[0] && compareDates(date, self2.selectedDates[0], true) === 0);
toggleClass$1(dayElement, "endRange", self2.selectedDates[1] && compareDates(date, self2.selectedDates[1], true) === 0);
if (className === "nextMonthDay")
dayElement.classList.add("inRange");
}
}
} else {
dayElement.classList.add("flatpickr-disabled");
}
if (self2.config.mode === "range") {
if (isDateInRange(date) && !isDateSelected(date))
dayElement.classList.add("inRange");
}
if (self2.weekNumbers && self2.config.showMonths === 1 && className !== "prevMonthDay" && dayNumber % 7 === 1) {
self2.weekNumbers.insertAdjacentHTML("beforeend", "<span class='flatpickr-day'>" + self2.config.getWeek(date) + "</span>");
}
triggerEvent("onDayCreate", dayElement);
return dayElement;
}
function focusOnDayElem(targetNode) {
targetNode.focus();
if (self2.config.mode === "range")
onMouseOver(targetNode);
}
function getFirstAvailableDay(delta) {
const startMonth = delta > 0 ? 0 : self2.config.showMonths - 1;
const endMonth = delta > 0 ? self2.config.showMonths : -1;
for (let m = startMonth; m != endMonth; m += delta) {
const month = self2.daysContainer.children[m];
const startIndex = delta > 0 ? 0 : month.children.length - 1;
const endIndex = delta > 0 ? month.children.length : -1;
for (let i = startIndex; i != endIndex; i += delta) {
const c = month.children[i];
if (c.className.indexOf("hidden") === -1 && isEnabled(c.dateObj))
return c;
}
}
return void 0;
}
function getNextAvailableDay(current, delta) {
const givenMonth = current.className.indexOf("Month") === -1 ? current.dateObj.getMonth() : self2.currentMonth;
const endMonth = delta > 0 ? self2.config.showMonths : -1;
const loopDelta = delta > 0 ? 1 : -1;
for (let m = givenMonth - self2.currentMonth; m != endMonth; m += loopDelta) {
const month = self2.daysContainer.children[m];
const startIndex = givenMonth - self2.currentMonth === m ? current.$i + delta : delta < 0 ? month.children.length - 1 : 0;
const numMonthDays = month.children.length;
for (let i = startIndex; i >= 0 && i < numMonthDays && i != (delta > 0 ? numMonthDays : -1); i += loopDelta) {
const c = month.children[i];
if (c.className.indexOf("hidden") === -1 && isEnabled(c.dateObj) && Math.abs(current.$i - i) >= Math.abs(delta))
return focusOnDayElem(c);
}
}
self2.changeMonth(loopDelta);
focusOnDay(getFirstAvailableDay(loopDelta), 0);
return void 0;
}
function focusOnDay(current, offset2) {
const dayFocused = isInView(document.activeElement || document.body);
const startElem = current !== void 0 ? current : dayFocused ? document.activeElement : self2.selectedDateElem !== void 0 && isInView(self2.selectedDateElem) ? self2.selectedDateElem : self2.todayDateElem !== void 0 && isInView(self2.todayDateElem) ? self2.todayDateElem : getFirstAvailableDay(offset2 > 0 ? 1 : -1);
if (startElem === void 0) {
self2._input.focus();
} else if (!dayFocused) {
focusOnDayElem(startElem);
} else {
getNextAvailableDay(startElem, offset2);
}
}
function buildMonthDays(year, month) {
const firstOfMonth = (new Date(year, month, 1).getDay() - self2.l10n.firstDayOfWeek + 7) % 7;
const prevMonthDays = self2.utils.getDaysInMonth((month - 1 + 12) % 12, year);
const daysInMonth = self2.utils.getDaysInMonth(month, year), days = window.document.createDocumentFragment(), isMultiMonth = self2.config.showMonths > 1, prevMonthDayClass = isMultiMonth ? "prevMonthDay hidden" : "prevMonthDay", nextMonthDayClass = isMultiMonth ? "nextMonthDay hidden" : "nextMonthDay";
let dayNumber = prevMonthDays + 1 - firstOfMonth, dayIndex = 0;
for (; dayNumber <= prevMonthDays; dayNumber++, dayIndex++) {
days.appendChild(createDay(prevMonthDayClass, new Date(year, month - 1, dayNumber), dayNumber, dayIndex));
}
for (dayNumber = 1; dayNumber <= daysInMonth; dayNumber++, dayIndex++) {
days.appendChild(createDay("", new Date(year, month, dayNumber), dayNumber, dayIndex));
}
for (let dayNum = daysInMonth + 1; dayNum <= 42 - firstOfMonth && (self2.config.showMonths === 1 || dayIndex % 7 !== 0); dayNum++, dayIndex++) {
days.appendChild(createDay(nextMonthDayClass, new Date(year, month + 1, dayNum % daysInMonth), dayNum, dayIndex));
}
const dayContainer = createElement("div", "dayContainer");
dayContainer.appendChild(days);
return dayContainer;
}
function buildDays() {
if (self2.daysContainer === void 0) {
return;
}
clearNode(self2.daysContainer);
if (self2.weekNumbers)
clearNode(self2.weekNumbers);
const frag = document.createDocumentFragment();
for (let i = 0; i < self2.config.showMonths; i++) {
const d = new Date(self2.currentYear, self2.currentMonth, 1);
d.setMonth(self2.currentMonth + i);
frag.appendChild(buildMonthDays(d.getFullYear(), d.getMonth()));
}
self2.daysContainer.appendChild(frag);
self2.days = self2.daysContainer.firstChild;
if (self2.config.mode === "range" && self2.selectedDates.length === 1) {
onMouseOver();
}
}
function buildMonthSwitch() {
if (self2.config.showMonths > 1 || self2.config.monthSelectorType !== "dropdown")
return;
const shouldBuildMonth = function(month) {
if (self2.config.minDate !== void 0 && self2.currentYear === self2.config.minDate.getFullYear() && month < self2.config.minDate.getMonth()) {
return false;
}
return !(self2.config.maxDate !== void 0 && self2.currentYear === self2.config.maxDate.getFullYear() && month > self2.config.maxDate.getMonth());
};
self2.monthsDropdownContainer.tabIndex = -1;
self2.monthsDropdownContainer.innerHTML = "";
for (let i = 0; i < 12; i++) {
if (!shouldBuildMonth(i))
continue;
const month = createElement("option", "flatpickr-monthDropdown-month");
month.value = new Date(self2.currentYear, i).getMonth().toString();
month.textContent = monthToStr(i, self2.config.shorthandCurrentMonth, self2.l10n);
month.tabIndex = -1;
if (self2.currentMonth === i) {
month.selected = true;
}
self2.monthsDropdownContainer.appendChild(month);
}
}
function buildMonth() {
const container = createElement("div", "flatpickr-month");
const monthNavFragment = window.document.createDocumentFragment();
let monthElement;
if (self2.config.showMonths > 1 || self2.config.monthSelectorType === "static") {
monthElement = createElement("span", "cur-month");
} else {
self2.monthsDropdownContainer = createElement("select", "flatpickr-monthDropdown-months");
self2.monthsDropdownContainer.setAttribute("aria-label", self2.l10n.monthAriaLabel);
bind4(self2.monthsDropdownContainer, "change", (e) => {
const target2 = getEventTarget(e);
const selectedMonth = parseInt(target2.value, 10);
self2.changeMonth(selectedMonth - self2.currentMonth);
triggerEvent("onMonthChange");
});
buildMonthSwitch();
monthElement = self2.monthsDropdownContainer;
}
const yearInput = createNumberInput("cur-year", {tabindex: "-1"});
const yearElement = yearInput.getElementsByTagName("input")[0];
yearElement.setAttribute("aria-label", self2.l10n.yearAriaLabel);
if (self2.config.minDate) {
yearElement.setAttribute("min", self2.config.minDate.getFullYear().toString());
}
if (self2.config.maxDate) {
yearElement.setAttribute("max", self2.config.maxDate.getFullYear().toString());
yearElement.disabled = !!self2.config.minDate && self2.config.minDate.getFullYear() === self2.config.maxDate.getFullYear();
}
const currentMonth = createElement("div", "flatpickr-current-month");
currentMonth.appendChild(monthElement);
currentMonth.appendChild(yearInput);
monthNavFragment.appendChild(currentMonth);
container.appendChild(monthNavFragment);
return {
container,
yearElement,
monthElement
};
}
function buildMonths() {
clearNode(self2.monthNav);
self2.monthNav.appendChild(self2.prevMonthNav);
if (self2.config.showMonths) {
self2.yearElements = [];
self2.monthElements = [];
}
for (let m = self2.config.showMonths; m--; ) {
const month = buildMonth();
self2.yearElements.push(month.yearElement);
self2.monthElements.push(month.monthElement);
self2.monthNav.appendChild(month.container);
}
self2.monthNav.appendChild(self2.nextMonthNav);
}
function buildMonthNav() {
self2.monthNav = createElement("div", "flatpickr-months");
self2.yearElements = [];
self2.monthElements = [];
self2.prevMonthNav = createElement("span", "flatpickr-prev-month");
self2.prevMonthNav.innerHTML = self2.config.prevArrow;
self2.nextMonthNav = createElement("span", "flatpickr-next-month");
self2.nextMonthNav.innerHTML = self2.config.nextArrow;
buildMonths();
Object.defineProperty(self2, "_hidePrevMonthArrow", {
get: () => self2.__hidePrevMonthArrow,
set(bool) {
if (self2.__hidePrevMonthArrow !== bool) {
toggleClass$1(self2.prevMonthNav, "flatpickr-disabled", bool);
self2.__hidePrevMonthArrow = bool;
}
}
});
Object.defineProperty(self2, "_hideNextMonthArrow", {
get: () => self2.__hideNextMonthArrow,
set(bool) {
if (self2.__hideNextMonthArrow !== bool) {
toggleClass$1(self2.nextMonthNav, "flatpickr-disabled", bool);
self2.__hideNextMonthArrow = bool;
}
}
});
self2.currentYearElement = self2.yearElements[0];
updateNavigationCurrentMonth();
return self2.monthNav;
}
function buildTime() {
self2.calendarContainer.classList.add("hasTime");
if (self2.config.noCalendar)
self2.calendarContainer.classList.add("noCalendar");
const defaults2 = getDefaultHours(self2.config);
self2.timeContainer = createElement("div", "flatpickr-time");
self2.timeContainer.tabIndex = -1;
const separator = createElement("span", "flatpickr-time-separator", ":");
const hourInput = createNumberInput("flatpickr-hour", {
"aria-label": self2.l10n.hourAriaLabel
});
self2.hourElement = hourInput.getElementsByTagName("input")[0];
const minuteInput = createNumberInput("flatpickr-minute", {
"aria-label": self2.l10n.minuteAriaLabel
});
self2.minuteElement = minuteInput.getElementsByTagName("input")[0];
self2.hourElement.tabIndex = self2.minuteElement.tabIndex = -1;
self2.hourElement.value = pad(self2.latestSelectedDateObj ? self2.latestSelectedDateObj.getHours() : self2.config.time_24hr ? defaults2.hours : military2ampm(defaults2.hours));
self2.minuteElement.value = pad(self2.latestSelectedDateObj ? self2.latestSelectedDateObj.getMinutes() : defaults2.minutes);
self2.hourElement.setAttribute("step", self2.config.hourIncrement.toString());
self2.minuteElement.setAttribute("step", self2.config.minuteIncrement.toString());
self2.hourElement.setAttribute("min", self2.config.time_24hr ? "0" : "1");
self2.hourElement.setAttribute("max", self2.config.time_24hr ? "23" : "12");
self2.hourElement.setAttribute("maxlength", "2");
self2.minuteElement.setAttribute("min", "0");
self2.minuteElement.setAttribute("max", "59");
self2.minuteElement.setAttribute("maxlength", "2");
self2.timeContainer.appendChild(hourInput);
self2.timeContainer.appendChild(separator);
self2.timeContainer.appendChild(minuteInput);
if (self2.config.time_24hr)
self2.timeContainer.classList.add("time24hr");
if (self2.config.enableSeconds) {
self2.timeContainer.classList.add("hasSeconds");
const secondInput = createNumberInput("flatpickr-second");
self2.secondElement = secondInput.getElementsByTagName("input")[0];
self2.secondElement.value = pad(self2.latestSelectedDateObj ? self2.latestSelectedDateObj.getSeconds() : defaults2.seconds);
self2.secondElement.setAttribute("step", self2.minuteElement.getAttribute("step"));
self2.secondElement.setAttribute("min", "0");
self2.secondElement.setAttribute("max", "59");
self2.secondElement.setAttribute("maxlength", "2");
self2.timeContainer.appendChild(createElement("span", "flatpickr-time-separator", ":"));
self2.timeContainer.appendChild(secondInput);
}
if (!self2.config.time_24hr) {
self2.amPM = createElement("span", "flatpickr-am-pm", self2.l10n.amPM[int((self2.latestSelectedDateObj ? self2.hourElement.value : self2.config.defaultHour) > 11)]);
self2.amPM.title = self2.l10n.toggleTitle;
self2.amPM.tabIndex = -1;
self2.timeContainer.appendChild(self2.amPM);
}
return self2.timeContainer;
}
function buildWeekdays() {
if (!self2.weekdayContainer)
self2.weekdayContainer = createElement("div", "flatpickr-weekdays");
else
clearNode(self2.weekdayContainer);
for (let i = self2.config.showMonths; i--; ) {
const container = createElement("div", "flatpickr-weekdaycontainer");
self2.weekdayContainer.appendChild(container);
}
updateWeekdays();
return self2.weekdayContainer;
}
function updateWeekdays() {
if (!self2.weekdayContainer) {
return;
}
const firstDayOfWeek = self2.l10n.firstDayOfWeek;
let weekdays = [...self2.l10n.weekdays.shorthand];
if (firstDayOfWeek > 0 && firstDayOfWeek < weekdays.length) {
weekdays = [
...weekdays.splice(firstDayOfWeek, weekdays.length),
...weekdays.splice(0, firstDayOfWeek)
];
}
for (let i = self2.config.showMonths; i--; ) {
self2.weekdayContainer.children[i].innerHTML = `
<span class='flatpickr-weekday'>
${weekdays.join("</span><span class='flatpickr-weekday'>")}
</span>
`;
}
}
function buildWeeks() {
self2.calendarContainer.classList.add("hasWeeks");
const weekWrapper = createElement("div", "flatpickr-weekwrapper");
weekWrapper.appendChild(createElement("span", "flatpickr-weekday", self2.l10n.weekAbbreviation));
const weekNumbers = createElement("div", "flatpickr-weeks");
weekWrapper.appendChild(weekNumbers);
return {
weekWrapper,
weekNumbers
};
}
function changeMonth(value, isOffset = true) {
const delta = isOffset ? value : value - self2.currentMonth;
if (delta < 0 && self2._hidePrevMonthArrow === true || delta > 0 && self2._hideNextMonthArrow === true)
return;
self2.currentMonth += delta;
if (self2.currentMonth < 0 || self2.currentMonth > 11) {
self2.currentYear += self2.currentMonth > 11 ? 1 : -1;
self2.currentMonth = (self2.currentMonth + 12) % 12;
triggerEvent("onYearChange");
buildMonthSwitch();
}
buildDays();
triggerEvent("onMonthChange");
updateNavigationCurrentMonth();
}
function clear(triggerChangeEvent = true, toInitial = true) {
self2.input.value = "";
if (self2.altInput !== void 0)
self2.altInput.value = "";
if (self2.mobileInput !== void 0)
self2.mobileInput.value = "";
self2.selectedDates = [];
self2.latestSelectedDateObj = void 0;
if (toInitial === true) {
self2.currentYear = self2._initialDate.getFullYear();
self2.currentMonth = self2._initialDate.getMonth();
}
if (self2.config.enableTime === true) {
const {hours, minutes, seconds} = getDefaultHours(self2.config);
setHours(hours, minutes, seconds);
}
self2.redraw();
if (triggerChangeEvent)
triggerEvent("onChange");
}
function close3() {
self2.isOpen = false;
if (!self2.isMobile) {
if (self2.calendarContainer !== void 0) {
self2.calendarContainer.classList.remove("open");
}
if (self2._input !== void 0) {
self2._input.classList.remove("active");
}
}
triggerEvent("onClose");
}
function destroy7() {
if (self2.config !== void 0)
triggerEvent("onDestroy");
for (let i = self2._handlers.length; i--; ) {
self2._handlers[i].remove();
}
self2._handlers = [];
if (self2.mobileInput) {
if (self2.mobileInput.parentNode)
self2.mobileInput.parentNode.removeChild(self2.mobileInput);
self2.mobileInput = void 0;
} else if (self2.calendarContainer && self2.calendarContainer.parentNode) {
if (self2.config.static && self2.calendarContainer.parentNode) {
const wrapper3 = self2.calendarContainer.parentNode;
wrapper3.lastChild && wrapper3.removeChild(wrapper3.lastChild);
if (wrapper3.parentNode) {
while (wrapper3.firstChild)
wrapper3.parentNode.insertBefore(wrapper3.firstChild, wrapper3);
wrapper3.parentNode.removeChild(wrapper3);
}
} else
self2.calendarContainer.parentNode.removeChild(self2.calendarContainer);
}
if (self2.altInput) {
self2.input.type = "text";
if (self2.altInput.parentNode)
self2.altInput.parentNode.removeChild(self2.altInput);
delete self2.altInput;
}
if (self2.input) {
self2.input.type = self2.input._type;
self2.input.classList.remove("flatpickr-input");
self2.input.removeAttribute("readonly");
}
[
"_showTimeInput",
"latestSelectedDateObj",
"_hideNextMonthArrow",
"_hidePrevMonthArrow",
"__hideNextMonthArrow",
"__hidePrevMonthArrow",
"isMobile",
"isOpen",
"selectedDateElem",
"minDateHasTime",
"maxDateHasTime",
"days",
"daysContainer",
"_input",
"_positionElement",
"innerContainer",
"rContainer",
"monthNav",
"todayDateElem",
"calendarContainer",
"weekdayContainer",
"prevMonthNav",
"nextMonthNav",
"monthsDropdownContainer",
"currentMonthElement",
"currentYearElement",
"navigationCurrentMonth",
"selectedDateElem",
"config"
].forEach((k) => {
try {
delete self2[k];
} catch (_2) {
}
});
}
function isCalendarElem(elem) {
if (self2.config.appendTo && self2.config.appendTo.contains(elem))
return true;
return self2.calendarContainer.contains(elem);
}
function documentClick(e) {
if (self2.isOpen && !self2.config.inline) {
const eventTarget = getEventTarget(e);
const isCalendarElement = isCalendarElem(eventTarget);
const isInput = eventTarget === self2.input || eventTarget === self2.altInput || self2.element.contains(eventTarget) || e.path && e.path.indexOf && (~e.path.indexOf(self2.input) || ~e.path.indexOf(self2.altInput));
const lostFocus = e.type === "blur" ? isInput && e.relatedTarget && !isCalendarElem(e.relatedTarget) : !isInput && !isCalendarElement && !isCalendarElem(e.relatedTarget);
const isIgnored = !self2.config.ignoredFocusElements.some((elem) => elem.contains(eventTarget));
if (lostFocus && isIgnored) {
if (self2.timeContainer !== void 0 && self2.minuteElement !== void 0 && self2.hourElement !== void 0 && self2.input.value !== "" && self2.input.value !== void 0) {
updateTime();
}
self2.close();
if (self2.config && self2.config.mode === "range" && self2.selectedDates.length === 1) {
self2.clear(false);
self2.redraw();
}
}
}
}
function changeYear(newYear) {
if (!newYear || self2.config.minDate && newYear < self2.config.minDate.getFullYear() || self2.config.maxDate && newYear > self2.config.maxDate.getFullYear())
return;
const newYearNum = newYear, isNewYear = self2.currentYear !== newYearNum;
self2.currentYear = newYearNum || self2.currentYear;
if (self2.config.maxDate && self2.currentYear === self2.config.maxDate.getFullYear()) {
self2.currentMonth = Math.min(self2.config.maxDate.getMonth(), self2.currentMonth);
} else if (self2.config.minDate && self2.currentYear === self2.config.minDate.getFullYear()) {
self2.currentMonth = Math.max(self2.config.minDate.getMonth(), self2.currentMonth);
}
if (isNewYear) {
self2.redraw();
triggerEvent("onYearChange");
buildMonthSwitch();
}
}
function isEnabled(date, timeless = true) {
var _a;
const dateToCheck = self2.parseDate(date, void 0, timeless);
if (self2.config.minDate && dateToCheck && compareDates(dateToCheck, self2.config.minDate, timeless !== void 0 ? timeless : !self2.minDateHasTime) < 0 || self2.config.maxDate && dateToCheck && compareDates(dateToCheck, self2.config.maxDate, timeless !== void 0 ? timeless : !self2.maxDateHasTime) > 0)
return false;
if (!self2.config.enable && self2.config.disable.length === 0)
return true;
if (dateToCheck === void 0)
return false;
const bool = !!self2.config.enable, array = (_a = self2.config.enable) !== null && _a !== void 0 ? _a : self2.config.disable;
for (let i = 0, d; i < array.length; i++) {
d = array[i];
if (typeof d === "function" && d(dateToCheck))
return bool;
else if (d instanceof Date && dateToCheck !== void 0 && d.getTime() === dateToCheck.getTime())
return bool;
else if (typeof d === "string") {
const parsed = self2.parseDate(d, void 0, true);
return parsed && parsed.getTime() === dateToCheck.getTime() ? bool : !bool;
} else if (typeof d === "object" && dateToCheck !== void 0 && d.from && d.to && dateToCheck.getTime() >= d.from.getTime() && dateToCheck.getTime() <= d.to.getTime())
return bool;
}
return !bool;
}
function isInView(elem) {
if (self2.daysContainer !== void 0)
return elem.className.indexOf("hidden") === -1 && elem.className.indexOf("flatpickr-disabled") === -1 && self2.daysContainer.contains(elem);
return false;
}
function onBlur(e) {
const isInput = e.target === self2._input;
if (isInput && (self2.selectedDates.length > 0 || self2._input.value.length > 0) && !(e.relatedTarget && isCalendarElem(e.relatedTarget))) {
self2.setDate(self2._input.value, true, e.target === self2.altInput ? self2.config.altFormat : self2.config.dateFormat);
}
}
function onKeyDown(e) {
const eventTarget = getEventTarget(e);
const isInput = self2.config.wrap ? element.contains(eventTarget) : eventTarget === self2._input;
const allowInput = self2.config.allowInput;
const allowKeydown = self2.isOpen && (!allowInput || !isInput);
const allowInlineKeydown = self2.config.inline && isInput && !allowInput;
if (e.keyCode === 13 && isInput) {
if (allowInput) {
self2.setDate(self2._input.value, true, eventTarget === self2.altInput ? self2.config.altFormat : self2.config.dateFormat);
return eventTarget.blur();
} else {
self2.open();
}
} else if (isCalendarElem(eventTarget) || allowKeydown || allowInlineKeydown) {
const isTimeObj = !!self2.timeContainer && self2.timeContainer.contains(eventTarget);
switch (e.keyCode) {
case 13:
if (isTimeObj) {
e.preventDefault();
updateTime();
focusAndClose();
} else
selectDate(e);
break;
case 27:
e.preventDefault();
focusAndClose();
break;
case 8:
case 46:
if (isInput && !self2.config.allowInput) {
e.preventDefault();
self2.clear();
}
break;
case 37:
case 39:
if (!isTimeObj && !isInput) {
e.preventDefault();
if (self2.daysContainer !== void 0 && (allowInput === false || document.activeElement && isInView(document.activeElement))) {
const delta2 = e.keyCode === 39 ? 1 : -1;
if (!e.ctrlKey)
focusOnDay(void 0, delta2);
else {
e.stopPropagation();
changeMonth(delta2);
focusOnDay(getFirstAvailableDay(1), 0);
}
}
} else if (self2.hourElement)
self2.hourElement.focus();
break;
case 38:
case 40:
e.preventDefault();
const delta = e.keyCode === 40 ? 1 : -1;
if (self2.daysContainer && eventTarget.$i !== void 0 || eventTarget === self2.input || eventTarget === self2.altInput) {
if (e.ctrlKey) {
e.stopPropagation();
changeYear(self2.currentYear - delta);
focusOnDay(getFirstAvailableDay(1), 0);
} else if (!isTimeObj)
focusOnDay(void 0, delta * 7);
} else if (eventTarget === self2.currentYearElement) {
changeYear(self2.currentYear - delta);
} else if (self2.config.enableTime) {
if (!isTimeObj && self2.hourElement)
self2.hourElement.focus();
updateTime(e);
self2._debouncedChange();
}
break;
case 9:
if (isTimeObj) {
const elems = [
self2.hourElement,
self2.minuteElement,
self2.secondElement,
self2.amPM
].concat(self2.pluginElements).filter((x) => x);
const i = elems.indexOf(eventTarget);
if (i !== -1) {
const target2 = elems[i + (e.shiftKey ? -1 : 1)];
e.preventDefault();
(target2 || self2._input).focus();
}
} else if (!self2.config.noCalendar && self2.daysContainer && self2.daysContainer.contains(eventTarget) && e.shiftKey) {
e.preventDefault();
self2._input.focus();
}
break;
}
}
if (self2.amPM !== void 0 && eventTarget === self2.amPM) {
switch (e.key) {
case self2.l10n.amPM[0].charAt(0):
case self2.l10n.amPM[0].charAt(0).toLowerCase():
self2.amPM.textContent = self2.l10n.amPM[0];
setHoursFromInputs();
updateValue();
break;
case self2.l10n.amPM[1].charAt(0):
case self2.l10n.amPM[1].charAt(0).toLowerCase():
self2.amPM.textContent = self2.l10n.amPM[1];
setHoursFromInputs();
updateValue();
break;
}
}
if (isInput || isCalendarElem(eventTarget)) {
triggerEvent("onKeyDown", e);
}
}
function onMouseOver(elem) {
if (self2.selectedDates.length !== 1 || elem && (!elem.classList.contains("flatpickr-day") || elem.classList.contains("flatpickr-disabled")))
return;
const hoverDate = elem ? elem.dateObj.getTime() : self2.days.firstElementChild.dateObj.getTime(), initialDate = self2.parseDate(self2.selectedDates[0], void 0, true).getTime(), rangeStartDate = Math.min(hoverDate, self2.selectedDates[0].getTime()), rangeEndDate = Math.max(hoverDate, self2.selectedDates[0].getTime());
let containsDisabled = false;
let minRange = 0, maxRange = 0;
for (let t = rangeStartDate; t < rangeEndDate; t += duration.DAY) {
if (!isEnabled(new Date(t), true)) {
containsDisabled = containsDisabled || t > rangeStartDate && t < rangeEndDate;
if (t < initialDate && (!minRange || t > minRange))
minRange = t;
else if (t > initialDate && (!maxRange || t < maxRange))
maxRange = t;
}
}
for (let m = 0; m < self2.config.showMonths; m++) {
const month = self2.daysContainer.children[m];
for (let i = 0, l = month.children.length; i < l; i++) {
const dayElem = month.children[i], date = dayElem.dateObj;
const timestamp = date.getTime();
const outOfRange = minRange > 0 && timestamp < minRange || maxRange > 0 && timestamp > maxRange;
if (outOfRange) {
dayElem.classList.add("notAllowed");
["inRange", "startRange", "endRange"].forEach((c) => {
dayElem.classList.remove(c);
});
continue;
} else if (containsDisabled && !outOfRange)
continue;
["startRange", "inRange", "endRange", "notAllowed"].forEach((c) => {
dayElem.classList.remove(c);
});
if (elem !== void 0) {
elem.classList.add(hoverDate <= self2.selectedDates[0].getTime() ? "startRange" : "endRange");
if (initialDate < hoverDate && timestamp === initialDate)
dayElem.classList.add("startRange");
else if (initialDate > hoverDate && timestamp === initialDate)
dayElem.classList.add("endRange");
if (timestamp >= minRange && (maxRange === 0 || timestamp <= maxRange) && isBetween(timestamp, initialDate, hoverDate))
dayElem.classList.add("inRange");
}
}
}
}
function onResize() {
if (self2.isOpen && !self2.config.static && !self2.config.inline)
positionCalendar();
}
function open2(e, positionElement = self2._positionElement) {
if (self2.isMobile === true) {
if (e) {
e.preventDefault();
const eventTarget = getEventTarget(e);
if (eventTarget) {
eventTarget.blur();
}
}
if (self2.mobileInput !== void 0) {
self2.mobileInput.focus();
self2.mobileInput.click();
}
triggerEvent("onOpen");
return;
} else if (self2._input.disabled || self2.config.inline) {
return;
}
const wasOpen = self2.isOpen;
self2.isOpen = true;
if (!wasOpen) {
self2.calendarContainer.classList.add("open");
self2._input.classList.add("active");
triggerEvent("onOpen");
positionCalendar(positionElement);
}
if (self2.config.enableTime === true && self2.config.noCalendar === true) {
if (self2.config.allowInput === false && (e === void 0 || !self2.timeContainer.contains(e.relatedTarget))) {
setTimeout(() => self2.hourElement.select(), 50);
}
}
}
function minMaxDateSetter(type) {
return (date) => {
const dateObj = self2.config[`_${type}Date`] = self2.parseDate(date, self2.config.dateFormat);
const inverseDateObj = self2.config[`_${type === "min" ? "max" : "min"}Date`];
if (dateObj !== void 0) {
self2[type === "min" ? "minDateHasTime" : "maxDateHasTime"] = dateObj.getHours() > 0 || dateObj.getMinutes() > 0 || dateObj.getSeconds() > 0;
}
if (self2.selectedDates) {
self2.selectedDates = self2.selectedDates.filter((d) => isEnabled(d));
if (!self2.selectedDates.length && type === "min")
setHoursFromDate(dateObj);
updateValue();
}
if (self2.daysContainer) {
redraw();
if (dateObj !== void 0)
self2.currentYearElement[type] = dateObj.getFullYear().toString();
else
self2.currentYearElement.removeAttribute(type);
self2.currentYearElement.disabled = !!inverseDateObj && dateObj !== void 0 && inverseDateObj.getFullYear() === dateObj.getFullYear();
}
};
}
function parseConfig() {
const boolOpts = [
"wrap",
"weekNumbers",
"allowInput",
"allowInvalidPreload",
"clickOpens",
"time_24hr",
"enableTime",
"noCalendar",
"altInput",
"shorthandCurrentMonth",
"inline",
"static",
"enableSeconds",
"disableMobile"
];
const userConfig = Object.assign(Object.assign({}, JSON.parse(JSON.stringify(element.dataset || {}))), instanceConfig);
const formats2 = {};
self2.config.parseDate = userConfig.parseDate;
self2.config.formatDate = userConfig.formatDate;
Object.defineProperty(self2.config, "enable", {
get: () => self2.config._enable,
set: (dates) => {
self2.config._enable = parseDateRules(dates);
}
});
Object.defineProperty(self2.config, "disable", {
get: () => self2.config._disable,
set: (dates) => {
self2.config._disable = parseDateRules(dates);
}
});
const timeMode = userConfig.mode === "time";
if (!userConfig.dateFormat && (userConfig.enableTime || timeMode)) {
const defaultDateFormat = flatpickr.defaultConfig.dateFormat || defaults$3.dateFormat;
formats2.dateFormat = userConfig.noCalendar || timeMode ? "H:i" + (userConfig.enableSeconds ? ":S" : "") : defaultDateFormat + " H:i" + (userConfig.enableSeconds ? ":S" : "");
}
if (userConfig.altInput && (userConfig.enableTime || timeMode) && !userConfig.altFormat) {
const defaultAltFormat = flatpickr.defaultConfig.altFormat || defaults$3.altFormat;
formats2.altFormat = userConfig.noCalendar || timeMode ? "h:i" + (userConfig.enableSeconds ? ":S K" : " K") : defaultAltFormat + ` h:i${userConfig.enableSeconds ? ":S" : ""} K`;
}
Object.defineProperty(self2.config, "minDate", {
get: () => self2.config._minDate,
set: minMaxDateSetter("min")
});
Object.defineProperty(self2.config, "maxDate", {
get: () => self2.config._maxDate,
set: minMaxDateSetter("max")
});
const minMaxTimeSetter = (type) => (val) => {
self2.config[type === "min" ? "_minTime" : "_maxTime"] = self2.parseDate(val, "H:i:S");
};
Object.defineProperty(self2.config, "minTime", {
get: () => self2.config._minTime,
set: minMaxTimeSetter("min")
});
Object.defineProperty(self2.config, "maxTime", {
get: () => self2.config._maxTime,
set: minMaxTimeSetter("max")
});
if (userConfig.mode === "time") {
self2.config.noCalendar = true;
self2.config.enableTime = true;
}
Object.assign(self2.config, formats2, userConfig);
for (let i = 0; i < boolOpts.length; i++)
self2.config[boolOpts[i]] = self2.config[boolOpts[i]] === true || self2.config[boolOpts[i]] === "true";
HOOKS.filter((hook) => self2.config[hook] !== void 0).forEach((hook) => {
self2.config[hook] = arrayify(self2.config[hook] || []).map(bindToInstance);
});
self2.isMobile = !self2.config.disableMobile && !self2.config.inline && self2.config.mode === "single" && !self2.config.disable.length && !self2.config.enable && !self2.config.weekNumbers && /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
for (let i = 0; i < self2.config.plugins.length; i++) {
const pluginConf = self2.config.plugins[i](self2) || {};
for (const key in pluginConf) {
if (HOOKS.indexOf(key) > -1) {
self2.config[key] = arrayify(pluginConf[key]).map(bindToInstance).concat(self2.config[key]);
} else if (typeof userConfig[key] === "undefined")
self2.config[key] = pluginConf[key];
}
}
if (!userConfig.altInputClass) {
self2.config.altInputClass = getInputElem().className + " " + self2.config.altInputClass;
}
triggerEvent("onParseConfig");
}
function getInputElem() {
return self2.config.wrap ? element.querySelector("[data-input]") : element;
}
function setupLocale() {
if (typeof self2.config.locale !== "object" && typeof flatpickr.l10ns[self2.config.locale] === "undefined")
self2.config.errorHandler(new Error(`flatpickr: invalid locale ${self2.config.locale}`));
self2.l10n = Object.assign(Object.assign({}, flatpickr.l10ns.default), typeof self2.config.locale === "object" ? self2.config.locale : self2.config.locale !== "default" ? flatpickr.l10ns[self2.config.locale] : void 0);
tokenRegex.K = `(${self2.l10n.amPM[0]}|${self2.l10n.amPM[1]}|${self2.l10n.amPM[0].toLowerCase()}|${self2.l10n.amPM[1].toLowerCase()})`;
const userConfig = Object.assign(Object.assign({}, instanceConfig), JSON.parse(JSON.stringify(element.dataset || {})));
if (userConfig.time_24hr === void 0 && flatpickr.defaultConfig.time_24hr === void 0) {
self2.config.time_24hr = self2.l10n.time_24hr;
}
self2.formatDate = createDateFormatter(self2);
self2.parseDate = createDateParser({config: self2.config, l10n: self2.l10n});
}
function positionCalendar(customPositionElement) {
if (typeof self2.config.position === "function") {
return void self2.config.position(self2, customPositionElement);
}
if (self2.calendarContainer === void 0)
return;
triggerEvent("onPreCalendarPosition");
const positionElement = customPositionElement || self2._positionElement;
const calendarHeight = Array.prototype.reduce.call(self2.calendarContainer.children, (acc, child3) => acc + child3.offsetHeight, 0), calendarWidth = self2.calendarContainer.offsetWidth, configPos = self2.config.position.split(" "), configPosVertical = configPos[0], configPosHorizontal = configPos.length > 1 ? configPos[1] : null, inputBounds = positionElement.getBoundingClientRect(), distanceFromBottom = window.innerHeight - inputBounds.bottom, showOnTop = configPosVertical === "above" || configPosVertical !== "below" && distanceFromBottom < calendarHeight && inputBounds.top > calendarHeight;
const top = window.pageYOffset + inputBounds.top + (!showOnTop ? positionElement.offsetHeight + 2 : -calendarHeight - 2);
toggleClass$1(self2.calendarContainer, "arrowTop", !showOnTop);
toggleClass$1(self2.calendarContainer, "arrowBottom", showOnTop);
if (self2.config.inline)
return;
let left = window.pageXOffset + inputBounds.left;
let isCenter = false;
let isRight = false;
if (configPosHorizontal === "center") {
left -= (calendarWidth - inputBounds.width) / 2;
isCenter = true;
} else if (configPosHorizontal === "right") {
left -= calendarWidth - inputBounds.width;
isRight = true;
}
toggleClass$1(self2.calendarContainer, "arrowLeft", !isCenter && !isRight);
toggleClass$1(self2.calendarContainer, "arrowCenter", isCenter);
toggleClass$1(self2.calendarContainer, "arrowRight", isRight);
const right = window.document.body.offsetWidth - (window.pageXOffset + inputBounds.right);
const rightMost = left + calendarWidth > window.document.body.offsetWidth;
const centerMost = right + calendarWidth > window.document.body.offsetWidth;
toggleClass$1(self2.calendarContainer, "rightMost", rightMost);
if (self2.config.static)
return;
self2.calendarContainer.style.top = `${top}px`;
if (!rightMost) {
self2.calendarContainer.style.left = `${left}px`;
self2.calendarContainer.style.right = "auto";
} else if (!centerMost) {
self2.calendarContainer.style.left = "auto";
self2.calendarContainer.style.right = `${right}px`;
} else {
const doc2 = getDocumentStyleSheet();
if (doc2 === void 0)
return;
const bodyWidth = window.document.body.offsetWidth;
const centerLeft = Math.max(0, bodyWidth / 2 - calendarWidth / 2);
const centerBefore = ".flatpickr-calendar.centerMost:before";
const centerAfter = ".flatpickr-calendar.centerMost:after";
const centerIndex = doc2.cssRules.length;
const centerStyle = `{left:${inputBounds.left}px;right:auto;}`;
toggleClass$1(self2.calendarContainer, "rightMost", false);
toggleClass$1(self2.calendarContainer, "centerMost", true);
doc2.insertRule(`${centerBefore},${centerAfter}${centerStyle}`, centerIndex);
self2.calendarContainer.style.left = `${centerLeft}px`;
self2.calendarContainer.style.right = "auto";
}
}
function getDocumentStyleSheet() {
let editableSheet = null;
for (let i = 0; i < document.styleSheets.length; i++) {
const sheet = document.styleSheets[i];
try {
sheet.cssRules;
} catch (err2) {
continue;
}
editableSheet = sheet;
break;
}
return editableSheet != null ? editableSheet : createStyleSheet();
}
function createStyleSheet() {
const style2 = document.createElement("style");
document.head.appendChild(style2);
return style2.sheet;
}
function redraw() {
if (self2.config.noCalendar || self2.isMobile)
return;
buildMonthSwitch();
updateNavigationCurrentMonth();
buildDays();
}
function focusAndClose() {
self2._input.focus();
if (window.navigator.userAgent.indexOf("MSIE") !== -1 || navigator.msMaxTouchPoints !== void 0) {
setTimeout(self2.close, 0);
} else {
self2.close();
}
}
function selectDate(e) {
e.preventDefault();
e.stopPropagation();
const isSelectable = (day) => day.classList && day.classList.contains("flatpickr-day") && !day.classList.contains("flatpickr-disabled") && !day.classList.contains("notAllowed");
const t = findParent(getEventTarget(e), isSelectable);
if (t === void 0)
return;
const target2 = t;
const selectedDate = self2.latestSelectedDateObj = new Date(target2.dateObj.getTime());
const shouldChangeMonth = (selectedDate.getMonth() < self2.currentMonth || selectedDate.getMonth() > self2.currentMonth + self2.config.showMonths - 1) && self2.config.mode !== "range";
self2.selectedDateElem = target2;
if (self2.config.mode === "single")
self2.selectedDates = [selectedDate];
else if (self2.config.mode === "multiple") {
const selectedIndex = isDateSelected(selectedDate);
if (selectedIndex)
self2.selectedDates.splice(parseInt(selectedIndex), 1);
else
self2.selectedDates.push(selectedDate);
} else if (self2.config.mode === "range") {
if (self2.selectedDates.length === 2) {
self2.clear(false, false);
}
self2.latestSelectedDateObj = selectedDate;
self2.selectedDates.push(selectedDate);
if (compareDates(selectedDate, self2.selectedDates[0], true) !== 0)
self2.selectedDates.sort((a, b) => a.getTime() - b.getTime());
}
setHoursFromInputs();
if (shouldChangeMonth) {
const isNewYear = self2.currentYear !== selectedDate.getFullYear();
self2.currentYear = selectedDate.getFullYear();
self2.currentMonth = selectedDate.getMonth();
if (isNewYear) {
triggerEvent("onYearChange");
buildMonthSwitch();
}
triggerEvent("onMonthChange");
}
updateNavigationCurrentMonth();
buildDays();
updateValue();
if (!shouldChangeMonth && self2.config.mode !== "range" && self2.config.showMonths === 1)
focusOnDayElem(target2);
else if (self2.selectedDateElem !== void 0 && self2.hourElement === void 0) {
self2.selectedDateElem && self2.selectedDateElem.focus();
}
if (self2.hourElement !== void 0)
self2.hourElement !== void 0 && self2.hourElement.focus();
if (self2.config.closeOnSelect) {
const single = self2.config.mode === "single" && !self2.config.enableTime;
const range2 = self2.config.mode === "range" && self2.selectedDates.length === 2 && !self2.config.enableTime;
if (single || range2) {
focusAndClose();
}
}
triggerChange();
}
const CALLBACKS = {
locale: [setupLocale, updateWeekdays],
showMonths: [buildMonths, setCalendarWidth, buildWeekdays],
minDate: [jumpToDate],
maxDate: [jumpToDate],
clickOpens: [
() => {
if (self2.config.clickOpens === true) {
bind4(self2._input, "focus", self2.open);
bind4(self2._input, "click", self2.open);
} else {
self2._input.removeEventListener("focus", self2.open);
self2._input.removeEventListener("click", self2.open);
}
}
]
};
function set3(option2, value) {
if (option2 !== null && typeof option2 === "object") {
Object.assign(self2.config, option2);
for (const key in option2) {
if (CALLBACKS[key] !== void 0)
CALLBACKS[key].forEach((x) => x());
}
} else {
self2.config[option2] = value;
if (CALLBACKS[option2] !== void 0)
CALLBACKS[option2].forEach((x) => x());
else if (HOOKS.indexOf(option2) > -1)
self2.config[option2] = arrayify(value);
}
self2.redraw();
updateValue(true);
}
function setSelectedDate(inputDate, format2) {
let dates = [];
if (inputDate instanceof Array)
dates = inputDate.map((d) => self2.parseDate(d, format2));
else if (inputDate instanceof Date || typeof inputDate === "number")
dates = [self2.parseDate(inputDate, format2)];
else if (typeof inputDate === "string") {
switch (self2.config.mode) {
case "single":
case "time":
dates = [self2.parseDate(inputDate, format2)];
break;
case "multiple":
dates = inputDate.split(self2.config.conjunction).map((date) => self2.parseDate(date, format2));
break;
case "range":
dates = inputDate.split(self2.l10n.rangeSeparator).map((date) => self2.parseDate(date, format2));
break;
}
} else
self2.config.errorHandler(new Error(`Invalid date supplied: ${JSON.stringify(inputDate)}`));
self2.selectedDates = self2.config.allowInvalidPreload ? dates : dates.filter((d) => d instanceof Date && isEnabled(d, false));
if (self2.config.mode === "range")
self2.selectedDates.sort((a, b) => a.getTime() - b.getTime());
}
function setDate(date, triggerChange2 = false, format2 = self2.config.dateFormat) {
if (date !== 0 && !date || date instanceof Array && date.length === 0)
return self2.clear(triggerChange2);
setSelectedDate(date, format2);
self2.latestSelectedDateObj = self2.selectedDates[self2.selectedDates.length - 1];
self2.redraw();
jumpToDate(void 0, triggerChange2);
setHoursFromDate();
if (self2.selectedDates.length === 0) {
self2.clear(false);
}
updateValue(triggerChange2);
if (triggerChange2)
triggerEvent("onChange");
}
function parseDateRules(arr) {
return arr.slice().map((rule) => {
if (typeof rule === "string" || typeof rule === "number" || rule instanceof Date) {
return self2.parseDate(rule, void 0, true);
} else if (rule && typeof rule === "object" && rule.from && rule.to)
return {
from: self2.parseDate(rule.from, void 0),
to: self2.parseDate(rule.to, void 0)
};
return rule;
}).filter((x) => x);
}
function setupDates() {
self2.selectedDates = [];
self2.now = self2.parseDate(self2.config.now) || new Date();
const preloadedDate = self2.config.defaultDate || ((self2.input.nodeName === "INPUT" || self2.input.nodeName === "TEXTAREA") && self2.input.placeholder && self2.input.value === self2.input.placeholder ? null : self2.input.value);
if (preloadedDate)
setSelectedDate(preloadedDate, self2.config.dateFormat);
self2._initialDate = self2.selectedDates.length > 0 ? self2.selectedDates[0] : self2.config.minDate && self2.config.minDate.getTime() > self2.now.getTime() ? self2.config.minDate : self2.config.maxDate && self2.config.maxDate.getTime() < self2.now.getTime() ? self2.config.maxDate : self2.now;
self2.currentYear = self2._initialDate.getFullYear();
self2.currentMonth = self2._initialDate.getMonth();
if (self2.selectedDates.length > 0)
self2.latestSelectedDateObj = self2.selectedDates[0];
if (self2.config.minTime !== void 0)
self2.config.minTime = self2.parseDate(self2.config.minTime, "H:i");
if (self2.config.maxTime !== void 0)
self2.config.maxTime = self2.parseDate(self2.config.maxTime, "H:i");
self2.minDateHasTime = !!self2.config.minDate && (self2.config.minDate.getHours() > 0 || self2.config.minDate.getMinutes() > 0 || self2.config.minDate.getSeconds() > 0);
self2.maxDateHasTime = !!self2.config.maxDate && (self2.config.maxDate.getHours() > 0 || self2.config.maxDate.getMinutes() > 0 || self2.config.maxDate.getSeconds() > 0);
}
function setupInputs() {
self2.input = getInputElem();
if (!self2.input) {
self2.config.errorHandler(new Error("Invalid input element specified"));
return;
}
self2.input._type = self2.input.type;
self2.input.type = "text";
self2.input.classList.add("flatpickr-input");
self2._input = self2.input;
if (self2.config.altInput) {
self2.altInput = createElement(self2.input.nodeName, self2.config.altInputClass);
self2._input = self2.altInput;
self2.altInput.placeholder = self2.input.placeholder;
self2.altInput.disabled = self2.input.disabled;
self2.altInput.required = self2.input.required;
self2.altInput.tabIndex = self2.input.tabIndex;
self2.altInput.type = "text";
self2.input.setAttribute("type", "hidden");
if (!self2.config.static && self2.input.parentNode)
self2.input.parentNode.insertBefore(self2.altInput, self2.input.nextSibling);
}
if (!self2.config.allowInput)
self2._input.setAttribute("readonly", "readonly");
self2._positionElement = self2.config.positionElement || self2._input;
}
function setupMobile() {
const inputType = self2.config.enableTime ? self2.config.noCalendar ? "time" : "datetime-local" : "date";
self2.mobileInput = createElement("input", self2.input.className + " flatpickr-mobile");
self2.mobileInput.tabIndex = 1;
self2.mobileInput.type = inputType;
self2.mobileInput.disabled = self2.input.disabled;
self2.mobileInput.required = self2.input.required;
self2.mobileInput.placeholder = self2.input.placeholder;
self2.mobileFormatStr = inputType === "datetime-local" ? "Y-m-d\\TH:i:S" : inputType === "date" ? "Y-m-d" : "H:i:S";
if (self2.selectedDates.length > 0) {
self2.mobileInput.defaultValue = self2.mobileInput.value = self2.formatDate(self2.selectedDates[0], self2.mobileFormatStr);
}
if (self2.config.minDate)
self2.mobileInput.min = self2.formatDate(self2.config.minDate, "Y-m-d");
if (self2.config.maxDate)
self2.mobileInput.max = self2.formatDate(self2.config.maxDate, "Y-m-d");
if (self2.input.getAttribute("step"))
self2.mobileInput.step = String(self2.input.getAttribute("step"));
self2.input.type = "hidden";
if (self2.altInput !== void 0)
self2.altInput.type = "hidden";
try {
if (self2.input.parentNode)
self2.input.parentNode.insertBefore(self2.mobileInput, self2.input.nextSibling);
} catch (_a) {
}
bind4(self2.mobileInput, "change", (e) => {
self2.setDate(getEventTarget(e).value, false, self2.mobileFormatStr);
triggerEvent("onChange");
triggerEvent("onClose");
});
}
function toggle(e) {
if (self2.isOpen === true)
return self2.close();
self2.open(e);
}
function triggerEvent(event, data) {
if (self2.config === void 0)
return;
const hooks2 = self2.config[event];
if (hooks2 !== void 0 && hooks2.length > 0) {
for (let i = 0; hooks2[i] && i < hooks2.length; i++)
hooks2[i](self2.selectedDates, self2.input.value, self2, data);
}
if (event === "onChange") {
self2.input.dispatchEvent(createEvent("change"));
self2.input.dispatchEvent(createEvent("input"));
}
}
function createEvent(name) {
const e = document.createEvent("Event");
e.initEvent(name, true, true);
return e;
}
function isDateSelected(date) {
for (let i = 0; i < self2.selectedDates.length; i++) {
if (compareDates(self2.selectedDates[i], date) === 0)
return "" + i;
}
return false;
}
function isDateInRange(date) {
if (self2.config.mode !== "range" || self2.selectedDates.length < 2)
return false;
return compareDates(date, self2.selectedDates[0]) >= 0 && compareDates(date, self2.selectedDates[1]) <= 0;
}
function updateNavigationCurrentMonth() {
if (self2.config.noCalendar || self2.isMobile || !self2.monthNav)
return;
self2.yearElements.forEach((yearElement, i) => {
const d = new Date(self2.currentYear, self2.currentMonth, 1);
d.setMonth(self2.currentMonth + i);
if (self2.config.showMonths > 1 || self2.config.monthSelectorType === "static") {
self2.monthElements[i].textContent = monthToStr(d.getMonth(), self2.config.shorthandCurrentMonth, self2.l10n) + " ";
} else {
self2.monthsDropdownContainer.value = d.getMonth().toString();
}
yearElement.value = d.getFullYear().toString();
});
self2._hidePrevMonthArrow = self2.config.minDate !== void 0 && (self2.currentYear === self2.config.minDate.getFullYear() ? self2.currentMonth <= self2.config.minDate.getMonth() : self2.currentYear < self2.config.minDate.getFullYear());
self2._hideNextMonthArrow = self2.config.maxDate !== void 0 && (self2.currentYear === self2.config.maxDate.getFullYear() ? self2.currentMonth + 1 > self2.config.maxDate.getMonth() : self2.currentYear > self2.config.maxDate.getFullYear());
}
function getDateStr(format2) {
return self2.selectedDates.map((dObj) => self2.formatDate(dObj, format2)).filter((d, i, arr) => self2.config.mode !== "range" || self2.config.enableTime || arr.indexOf(d) === i).join(self2.config.mode !== "range" ? self2.config.conjunction : self2.l10n.rangeSeparator);
}
function updateValue(triggerChange2 = true) {
if (self2.mobileInput !== void 0 && self2.mobileFormatStr) {
self2.mobileInput.value = self2.latestSelectedDateObj !== void 0 ? self2.formatDate(self2.latestSelectedDateObj, self2.mobileFormatStr) : "";
}
self2.input.value = getDateStr(self2.config.dateFormat);
if (self2.altInput !== void 0) {
self2.altInput.value = getDateStr(self2.config.altFormat);
}
if (triggerChange2 !== false)
triggerEvent("onValueUpdate");
}
function onMonthNavClick(e) {
const eventTarget = getEventTarget(e);
const isPrevMonth = self2.prevMonthNav.contains(eventTarget);
const isNextMonth = self2.nextMonthNav.contains(eventTarget);
if (isPrevMonth || isNextMonth) {
changeMonth(isPrevMonth ? -1 : 1);
} else if (self2.yearElements.indexOf(eventTarget) >= 0) {
eventTarget.select();
} else if (eventTarget.classList.contains("arrowUp")) {
self2.changeYear(self2.currentYear + 1);
} else if (eventTarget.classList.contains("arrowDown")) {
self2.changeYear(self2.currentYear - 1);
}
}
function timeWrapper(e) {
e.preventDefault();
const isKeyDown = e.type === "keydown", eventTarget = getEventTarget(e), input = eventTarget;
if (self2.amPM !== void 0 && eventTarget === self2.amPM) {
self2.amPM.textContent = self2.l10n.amPM[int(self2.amPM.textContent === self2.l10n.amPM[0])];
}
const min3 = parseFloat(input.getAttribute("min")), max3 = parseFloat(input.getAttribute("max")), step2 = parseFloat(input.getAttribute("step")), curValue = parseInt(input.value, 10), delta = e.delta || (isKeyDown ? e.which === 38 ? 1 : -1 : 0);
let newValue = curValue + step2 * delta;
if (typeof input.value !== "undefined" && input.value.length === 2) {
const isHourElem = input === self2.hourElement, isMinuteElem = input === self2.minuteElement;
if (newValue < min3) {
newValue = max3 + newValue + int(!isHourElem) + (int(isHourElem) && int(!self2.amPM));
if (isMinuteElem)
incrementNumInput(void 0, -1, self2.hourElement);
} else if (newValue > max3) {
newValue = input === self2.hourElement ? newValue - max3 - int(!self2.amPM) : min3;
if (isMinuteElem)
incrementNumInput(void 0, 1, self2.hourElement);
}
if (self2.amPM && isHourElem && (step2 === 1 ? newValue + curValue === 23 : Math.abs(newValue - curValue) > step2)) {
self2.amPM.textContent = self2.l10n.amPM[int(self2.amPM.textContent === self2.l10n.amPM[0])];
}
input.value = pad(newValue);
}
}
init7();
return self2;
}
function _flatpickr(nodeList, config2) {
const nodes = Array.prototype.slice.call(nodeList).filter((x) => x instanceof HTMLElement);
const instances = [];
for (let i = 0; i < nodes.length; i++) {
const node4 = nodes[i];
try {
if (node4.getAttribute("data-fp-omit") !== null)
continue;
if (node4._flatpickr !== void 0) {
node4._flatpickr.destroy();
node4._flatpickr = void 0;
}
node4._flatpickr = FlatpickrInstance(node4, config2 || {});
instances.push(node4._flatpickr);
} catch (e) {
console.error(e);
}
}
return instances.length === 1 ? instances[0] : instances;
}
if (typeof HTMLElement !== "undefined" && typeof HTMLCollection !== "undefined" && typeof NodeList !== "undefined") {
HTMLCollection.prototype.flatpickr = NodeList.prototype.flatpickr = function(config2) {
return _flatpickr(this, config2);
};
HTMLElement.prototype.flatpickr = function(config2) {
return _flatpickr([this], config2);
};
}
var flatpickr = function(selector, config2) {
if (typeof selector === "string") {
return _flatpickr(window.document.querySelectorAll(selector), config2);
} else if (selector instanceof Node) {
return _flatpickr([selector], config2);
} else {
return _flatpickr(selector, config2);
}
};
flatpickr.defaultConfig = {};
flatpickr.l10ns = {
en: Object.assign({}, english),
default: Object.assign({}, english)
};
flatpickr.localize = (l10n) => {
flatpickr.l10ns.default = Object.assign(Object.assign({}, flatpickr.l10ns.default), l10n);
};
flatpickr.setDefaults = (config2) => {
flatpickr.defaultConfig = Object.assign(Object.assign({}, flatpickr.defaultConfig), config2);
};
flatpickr.parseDate = createDateParser({});
flatpickr.formatDate = createDateFormatter({});
flatpickr.compareDates = compareDates;
if (typeof jQuery !== "undefined" && typeof jQuery.fn !== "undefined") {
jQuery.fn.flatpickr = function(config2) {
return _flatpickr(this, config2);
};
}
Date.prototype.fp_incr = function(days) {
return new Date(this.getFullYear(), this.getMonth(), this.getDate() + (typeof days === "string" ? parseInt(days, 10) : days));
};
if (typeof window !== "undefined") {
window.flatpickr = flatpickr;
}
var shams = function hasSymbols() {
if (typeof Symbol !== "function" || typeof Object.getOwnPropertySymbols !== "function") {
return false;
}
if (typeof Symbol.iterator === "symbol") {
return true;
}
var obj = {};
var sym = Symbol("test");
var symObj = Object(sym);
if (typeof sym === "string") {
return false;
}
if (Object.prototype.toString.call(sym) !== "[object Symbol]") {
return false;
}
if (Object.prototype.toString.call(symObj) !== "[object Symbol]") {
return false;
}
var symVal = 42;
obj[sym] = symVal;
for (sym in obj) {
return false;
}
if (typeof Object.keys === "function" && Object.keys(obj).length !== 0) {
return false;
}
if (typeof Object.getOwnPropertyNames === "function" && Object.getOwnPropertyNames(obj).length !== 0) {
return false;
}
var syms = Object.getOwnPropertySymbols(obj);
if (syms.length !== 1 || syms[0] !== sym) {
return false;
}
if (!Object.prototype.propertyIsEnumerable.call(obj, sym)) {
return false;
}
if (typeof Object.getOwnPropertyDescriptor === "function") {
var descriptor = Object.getOwnPropertyDescriptor(obj, sym);
if (descriptor.value !== symVal || descriptor.enumerable !== true) {
return false;
}
}
return true;
};
var origSymbol = typeof Symbol !== "undefined" && Symbol;
var O__zero_zero_Web_UI_node_modules_hasSymbols = function hasNativeSymbols() {
if (typeof origSymbol !== "function") {
return false;
}
if (typeof Symbol !== "function") {
return false;
}
if (typeof origSymbol("foo") !== "symbol") {
return false;
}
if (typeof Symbol("bar") !== "symbol") {
return false;
}
return shams();
};
var ERROR_MESSAGE = "Function.prototype.bind called on incompatible ";
var slice4 = Array.prototype.slice;
var toStr$1 = Object.prototype.toString;
var funcType = "[object Function]";
var implementation = function bind3(that) {
var target2 = this;
if (typeof target2 !== "function" || toStr$1.call(target2) !== funcType) {
throw new TypeError(ERROR_MESSAGE + target2);
}
var args = slice4.call(arguments, 1);
var bound;
var binder = function() {
if (this instanceof bound) {
var result2 = target2.apply(this, args.concat(slice4.call(arguments)));
if (Object(result2) === result2) {
return result2;
}
return this;
} else {
return target2.apply(that, args.concat(slice4.call(arguments)));
}
};
var boundLength = Math.max(0, target2.length - args.length);
var boundArgs = [];
for (var i = 0; i < boundLength; i++) {
boundArgs.push("$" + i);
}
bound = Function("binder", "return function (" + boundArgs.join(",") + "){ return binder.apply(this,arguments); }")(binder);
if (target2.prototype) {
var Empty = function Empty2() {
};
Empty.prototype = target2.prototype;
bound.prototype = new Empty();
Empty.prototype = null;
}
return bound;
};
var O__zero_zero_Web_UI_node_modules_functionBind = Function.prototype.bind || implementation;
var O__zero_zero_Web_UI_node_modules_has_src = O__zero_zero_Web_UI_node_modules_functionBind.call(Function.call, Object.prototype.hasOwnProperty);
var undefined$1;
var $SyntaxError = SyntaxError;
var $Function = Function;
var $TypeError$1 = TypeError;
var getEvalledConstructor = function(expressionSyntax) {
try {
return $Function('"use strict"; return (' + expressionSyntax + ").constructor;")();
} catch (e) {
}
};
var $gOPD = Object.getOwnPropertyDescriptor;
if ($gOPD) {
try {
$gOPD({}, "");
} catch (e) {
$gOPD = null;
}
}
var throwTypeError = function() {
throw new $TypeError$1();
};
var ThrowTypeError = $gOPD ? function() {
try {
arguments.callee;
return throwTypeError;
} catch (calleeThrows) {
try {
return $gOPD(arguments, "callee").get;
} catch (gOPDthrows) {
return throwTypeError;
}
}
}() : throwTypeError;
var hasSymbols2 = O__zero_zero_Web_UI_node_modules_hasSymbols();
var getProto = Object.getPrototypeOf || function(x) {
return x.__proto__;
};
var needsEval = {};
var TypedArray = typeof Uint8Array === "undefined" ? undefined$1 : getProto(Uint8Array);
var INTRINSICS = {
"%AggregateError%": typeof AggregateError === "undefined" ? undefined$1 : AggregateError,
"%Array%": Array,
"%ArrayBuffer%": typeof ArrayBuffer === "undefined" ? undefined$1 : ArrayBuffer,
"%ArrayIteratorPrototype%": hasSymbols2 ? getProto([][Symbol.iterator]()) : undefined$1,
"%AsyncFromSyncIteratorPrototype%": undefined$1,
"%AsyncFunction%": needsEval,
"%AsyncGenerator%": needsEval,
"%AsyncGeneratorFunction%": needsEval,
"%AsyncIteratorPrototype%": needsEval,
"%Atomics%": typeof Atomics === "undefined" ? undefined$1 : Atomics,
"%BigInt%": typeof BigInt === "undefined" ? undefined$1 : BigInt,
"%Boolean%": Boolean,
"%DataView%": typeof DataView === "undefined" ? undefined$1 : DataView,
"%Date%": Date,
"%decodeURI%": decodeURI,
"%decodeURIComponent%": decodeURIComponent,
"%encodeURI%": encodeURI,
"%encodeURIComponent%": encodeURIComponent,
"%Error%": Error,
"%eval%": eval,
"%EvalError%": EvalError,
"%Float32Array%": typeof Float32Array === "undefined" ? undefined$1 : Float32Array,
"%Float64Array%": typeof Float64Array === "undefined" ? undefined$1 : Float64Array,
"%FinalizationRegistry%": typeof FinalizationRegistry === "undefined" ? undefined$1 : FinalizationRegistry,
"%Function%": $Function,
"%GeneratorFunction%": needsEval,
"%Int8Array%": typeof Int8Array === "undefined" ? undefined$1 : Int8Array,
"%Int16Array%": typeof Int16Array === "undefined" ? undefined$1 : Int16Array,
"%Int32Array%": typeof Int32Array === "undefined" ? undefined$1 : Int32Array,
"%isFinite%": isFinite,
"%isNaN%": isNaN,
"%IteratorPrototype%": hasSymbols2 ? getProto(getProto([][Symbol.iterator]())) : undefined$1,
"%JSON%": typeof JSON === "object" ? JSON : undefined$1,
"%Map%": typeof Map === "undefined" ? undefined$1 : Map,
"%MapIteratorPrototype%": typeof Map === "undefined" || !hasSymbols2 ? undefined$1 : getProto(new Map()[Symbol.iterator]()),
"%Math%": Math,
"%Number%": Number,
"%Object%": Object,
"%parseFloat%": parseFloat,
"%parseInt%": parseInt,
"%Promise%": typeof Promise === "undefined" ? undefined$1 : Promise,
"%Proxy%": typeof Proxy === "undefined" ? undefined$1 : Proxy,
"%RangeError%": RangeError,
"%ReferenceError%": ReferenceError,
"%Reflect%": typeof Reflect === "undefined" ? undefined$1 : Reflect,
"%RegExp%": RegExp,
"%Set%": typeof Set === "undefined" ? undefined$1 : Set,
"%SetIteratorPrototype%": typeof Set === "undefined" || !hasSymbols2 ? undefined$1 : getProto(new Set()[Symbol.iterator]()),
"%SharedArrayBuffer%": typeof SharedArrayBuffer === "undefined" ? undefined$1 : SharedArrayBuffer,
"%String%": String,
"%StringIteratorPrototype%": hasSymbols2 ? getProto(""[Symbol.iterator]()) : undefined$1,
"%Symbol%": hasSymbols2 ? Symbol : undefined$1,
"%SyntaxError%": $SyntaxError,
"%ThrowTypeError%": ThrowTypeError,
"%TypedArray%": TypedArray,
"%TypeError%": $TypeError$1,
"%Uint8Array%": typeof Uint8Array === "undefined" ? undefined$1 : Uint8Array,
"%Uint8ClampedArray%": typeof Uint8ClampedArray === "undefined" ? undefined$1 : Uint8ClampedArray,
"%Uint16Array%": typeof Uint16Array === "undefined" ? undefined$1 : Uint16Array,
"%Uint32Array%": typeof Uint32Array === "undefined" ? undefined$1 : Uint32Array,
"%URIError%": URIError,
"%WeakMap%": typeof WeakMap === "undefined" ? undefined$1 : WeakMap,
"%WeakRef%": typeof WeakRef === "undefined" ? undefined$1 : WeakRef,
"%WeakSet%": typeof WeakSet === "undefined" ? undefined$1 : WeakSet
};
var doEval = function doEval2(name) {
var value;
if (name === "%AsyncFunction%") {
value = getEvalledConstructor("async function () {}");
} else if (name === "%GeneratorFunction%") {
value = getEvalledConstructor("function* () {}");
} else if (name === "%AsyncGeneratorFunction%") {
value = getEvalledConstructor("async function* () {}");
} else if (name === "%AsyncGenerator%") {
var fn = doEval2("%AsyncGeneratorFunction%");
if (fn) {
value = fn.prototype;
}
} else if (name === "%AsyncIteratorPrototype%") {
var gen = doEval2("%AsyncGenerator%");
if (gen) {
value = getProto(gen.prototype);
}
}
INTRINSICS[name] = value;
return value;
};
var LEGACY_ALIASES = {
"%ArrayBufferPrototype%": ["ArrayBuffer", "prototype"],
"%ArrayPrototype%": ["Array", "prototype"],
"%ArrayProto_entries%": ["Array", "prototype", "entries"],
"%ArrayProto_forEach%": ["Array", "prototype", "forEach"],
"%ArrayProto_keys%": ["Array", "prototype", "keys"],
"%ArrayProto_values%": ["Array", "prototype", "values"],
"%AsyncFunctionPrototype%": ["AsyncFunction", "prototype"],
"%AsyncGenerator%": ["AsyncGeneratorFunction", "prototype"],
"%AsyncGeneratorPrototype%": ["AsyncGeneratorFunction", "prototype", "prototype"],
"%BooleanPrototype%": ["Boolean", "prototype"],
"%DataViewPrototype%": ["DataView", "prototype"],
"%DatePrototype%": ["Date", "prototype"],
"%ErrorPrototype%": ["Error", "prototype"],
"%EvalErrorPrototype%": ["EvalError", "prototype"],
"%Float32ArrayPrototype%": ["Float32Array", "prototype"],
"%Float64ArrayPrototype%": ["Float64Array", "prototype"],
"%FunctionPrototype%": ["Function", "prototype"],
"%Generator%": ["GeneratorFunction", "prototype"],
"%GeneratorPrototype%": ["GeneratorFunction", "prototype", "prototype"],
"%Int8ArrayPrototype%": ["Int8Array", "prototype"],
"%Int16ArrayPrototype%": ["Int16Array", "prototype"],
"%Int32ArrayPrototype%": ["Int32Array", "prototype"],
"%JSONParse%": ["JSON", "parse"],
"%JSONStringify%": ["JSON", "stringify"],
"%MapPrototype%": ["Map", "prototype"],
"%NumberPrototype%": ["Number", "prototype"],
"%ObjectPrototype%": ["Object", "prototype"],
"%ObjProto_toString%": ["Object", "prototype", "toString"],
"%ObjProto_valueOf%": ["Object", "prototype", "valueOf"],
"%PromisePrototype%": ["Promise", "prototype"],
"%PromiseProto_then%": ["Promise", "prototype", "then"],
"%Promise_all%": ["Promise", "all"],
"%Promise_reject%": ["Promise", "reject"],
"%Promise_resolve%": ["Promise", "resolve"],
"%RangeErrorPrototype%": ["RangeError", "prototype"],
"%ReferenceErrorPrototype%": ["ReferenceError", "prototype"],
"%RegExpPrototype%": ["RegExp", "prototype"],
"%SetPrototype%": ["Set", "prototype"],
"%SharedArrayBufferPrototype%": ["SharedArrayBuffer", "prototype"],
"%StringPrototype%": ["String", "prototype"],
"%SymbolPrototype%": ["Symbol", "prototype"],
"%SyntaxErrorPrototype%": ["SyntaxError", "prototype"],
"%TypedArrayPrototype%": ["TypedArray", "prototype"],
"%TypeErrorPrototype%": ["TypeError", "prototype"],
"%Uint8ArrayPrototype%": ["Uint8Array", "prototype"],
"%Uint8ClampedArrayPrototype%": ["Uint8ClampedArray", "prototype"],
"%Uint16ArrayPrototype%": ["Uint16Array", "prototype"],
"%Uint32ArrayPrototype%": ["Uint32Array", "prototype"],
"%URIErrorPrototype%": ["URIError", "prototype"],
"%WeakMapPrototype%": ["WeakMap", "prototype"],
"%WeakSetPrototype%": ["WeakSet", "prototype"]
};
var $concat = O__zero_zero_Web_UI_node_modules_functionBind.call(Function.call, Array.prototype.concat);
var $spliceApply = O__zero_zero_Web_UI_node_modules_functionBind.call(Function.apply, Array.prototype.splice);
var $replace = O__zero_zero_Web_UI_node_modules_functionBind.call(Function.call, String.prototype.replace);
var $strSlice = O__zero_zero_Web_UI_node_modules_functionBind.call(Function.call, String.prototype.slice);
var rePropName = /[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g;
var reEscapeChar = /\\(\\)?/g;
var stringToPath = function stringToPath2(string) {
var first2 = $strSlice(string, 0, 1);
var last2 = $strSlice(string, -1);
if (first2 === "%" && last2 !== "%") {
throw new $SyntaxError("invalid intrinsic syntax, expected closing `%`");
} else if (last2 === "%" && first2 !== "%") {
throw new $SyntaxError("invalid intrinsic syntax, expected opening `%`");
}
var result2 = [];
$replace(string, rePropName, function(match3, number, quote2, subString) {
result2[result2.length] = quote2 ? $replace(subString, reEscapeChar, "$1") : number || match3;
});
return result2;
};
var getBaseIntrinsic = function getBaseIntrinsic2(name, allowMissing) {
var intrinsicName = name;
var alias;
if (O__zero_zero_Web_UI_node_modules_has_src(LEGACY_ALIASES, intrinsicName)) {
alias = LEGACY_ALIASES[intrinsicName];
intrinsicName = "%" + alias[0] + "%";
}
if (O__zero_zero_Web_UI_node_modules_has_src(INTRINSICS, intrinsicName)) {
var value = INTRINSICS[intrinsicName];
if (value === needsEval) {
value = doEval(intrinsicName);
}
if (typeof value === "undefined" && !allowMissing) {
throw new $TypeError$1("intrinsic " + name + " exists, but is not available. Please file an issue!");
}
return {
alias,
name: intrinsicName,
value
};
}
throw new $SyntaxError("intrinsic " + name + " does not exist!");
};
var O__zero_zero_Web_UI_node_modules_getIntrinsic = function GetIntrinsic(name, allowMissing) {
if (typeof name !== "string" || name.length === 0) {
throw new $TypeError$1("intrinsic name must be a non-empty string");
}
if (arguments.length > 1 && typeof allowMissing !== "boolean") {
throw new $TypeError$1('"allowMissing" argument must be a boolean');
}
var parts = stringToPath(name);
var intrinsicBaseName = parts.length > 0 ? parts[0] : "";
var intrinsic = getBaseIntrinsic("%" + intrinsicBaseName + "%", allowMissing);
var intrinsicRealName = intrinsic.name;
var value = intrinsic.value;
var skipFurtherCaching = false;
var alias = intrinsic.alias;
if (alias) {
intrinsicBaseName = alias[0];
$spliceApply(parts, $concat([0, 1], alias));
}
for (var i = 1, isOwn = true; i < parts.length; i += 1) {
var part = parts[i];
var first2 = $strSlice(part, 0, 1);
var last2 = $strSlice(part, -1);
if ((first2 === '"' || first2 === "'" || first2 === "`" || (last2 === '"' || last2 === "'" || last2 === "`")) && first2 !== last2) {
throw new $SyntaxError("property names with quotes must have matching quotes");
}
if (part === "constructor" || !isOwn) {
skipFurtherCaching = true;
}
intrinsicBaseName += "." + part;
intrinsicRealName = "%" + intrinsicBaseName + "%";
if (O__zero_zero_Web_UI_node_modules_has_src(INTRINSICS, intrinsicRealName)) {
value = INTRINSICS[intrinsicRealName];
} else if (value != null) {
if (!(part in value)) {
if (!allowMissing) {
throw new $TypeError$1("base intrinsic for " + name + " exists, but the property is not available.");
}
return void 0;
}
if ($gOPD && i + 1 >= parts.length) {
var desc = $gOPD(value, part);
isOwn = !!desc;
if (isOwn && "get" in desc && !("originalValue" in desc.get)) {
value = desc.get;
} else {
value = value[part];
}
} else {
isOwn = O__zero_zero_Web_UI_node_modules_has_src(value, part);
value = value[part];
}
if (isOwn && !skipFurtherCaching) {
INTRINSICS[intrinsicRealName] = value;
}
}
}
return value;
};
var O__zero_zero_Web_UI_node_modules_callBind = createCommonjsModule(function(module) {
var $apply = O__zero_zero_Web_UI_node_modules_getIntrinsic("%Function.prototype.apply%");
var $call = O__zero_zero_Web_UI_node_modules_getIntrinsic("%Function.prototype.call%");
var $reflectApply = O__zero_zero_Web_UI_node_modules_getIntrinsic("%Reflect.apply%", true) || O__zero_zero_Web_UI_node_modules_functionBind.call($call, $apply);
var $gOPD2 = O__zero_zero_Web_UI_node_modules_getIntrinsic("%Object.getOwnPropertyDescriptor%", true);
var $defineProperty = O__zero_zero_Web_UI_node_modules_getIntrinsic("%Object.defineProperty%", true);
var $max = O__zero_zero_Web_UI_node_modules_getIntrinsic("%Math.max%");
if ($defineProperty) {
try {
$defineProperty({}, "a", {value: 1});
} catch (e) {
$defineProperty = null;
}
}
module.exports = function callBind(originalFunction) {
var func = $reflectApply(O__zero_zero_Web_UI_node_modules_functionBind, $call, arguments);
if ($gOPD2 && $defineProperty) {
var desc = $gOPD2(func, "length");
if (desc.configurable) {
$defineProperty(func, "length", {value: 1 + $max(0, originalFunction.length - (arguments.length - 1))});
}
}
return func;
};
var applyBind = function applyBind2() {
return $reflectApply(O__zero_zero_Web_UI_node_modules_functionBind, $apply, arguments);
};
if ($defineProperty) {
$defineProperty(module.exports, "apply", {value: applyBind});
} else {
module.exports.apply = applyBind;
}
});
var $indexOf = O__zero_zero_Web_UI_node_modules_callBind(O__zero_zero_Web_UI_node_modules_getIntrinsic("String.prototype.indexOf"));
var callBound = function callBoundIntrinsic(name, allowMissing) {
var intrinsic = O__zero_zero_Web_UI_node_modules_getIntrinsic(name, !!allowMissing);
if (typeof intrinsic === "function" && $indexOf(name, ".prototype.") > -1) {
return O__zero_zero_Web_UI_node_modules_callBind(intrinsic);
}
return intrinsic;
};
var __viteBrowserExternal = {};
var __viteBrowserExternal$1 = /* @__PURE__ */ Object.freeze({
__proto__: null,
[Symbol.toStringTag]: "Module",
default: __viteBrowserExternal
});
var require$$0 = /* @__PURE__ */ getAugmentedNamespace(__viteBrowserExternal$1);
var hasMap = typeof Map === "function" && Map.prototype;
var mapSizeDescriptor = Object.getOwnPropertyDescriptor && hasMap ? Object.getOwnPropertyDescriptor(Map.prototype, "size") : null;
var mapSize = hasMap && mapSizeDescriptor && typeof mapSizeDescriptor.get === "function" ? mapSizeDescriptor.get : null;
var mapForEach = hasMap && Map.prototype.forEach;
var hasSet = typeof Set === "function" && Set.prototype;
var setSizeDescriptor = Object.getOwnPropertyDescriptor && hasSet ? Object.getOwnPropertyDescriptor(Set.prototype, "size") : null;
var setSize = hasSet && setSizeDescriptor && typeof setSizeDescriptor.get === "function" ? setSizeDescriptor.get : null;
var setForEach = hasSet && Set.prototype.forEach;
var hasWeakMap = typeof WeakMap === "function" && WeakMap.prototype;
var weakMapHas = hasWeakMap ? WeakMap.prototype.has : null;
var hasWeakSet = typeof WeakSet === "function" && WeakSet.prototype;
var weakSetHas = hasWeakSet ? WeakSet.prototype.has : null;
var booleanValueOf = Boolean.prototype.valueOf;
var objectToString = Object.prototype.toString;
var functionToString = Function.prototype.toString;
var match2 = String.prototype.match;
var bigIntValueOf = typeof BigInt === "function" ? BigInt.prototype.valueOf : null;
var gOPS = Object.getOwnPropertySymbols;
var symToString = typeof Symbol === "function" ? Symbol.prototype.toString : null;
var isEnumerable = Object.prototype.propertyIsEnumerable;
var inspectCustom = require$$0.custom;
var inspectSymbol = inspectCustom && isSymbol(inspectCustom) ? inspectCustom : null;
var O__zero_zero_Web_UI_node_modules_objectInspect = function inspect_(obj, options, depth, seen) {
var opts = options || {};
if (has$3(opts, "quoteStyle") && (opts.quoteStyle !== "single" && opts.quoteStyle !== "double")) {
throw new TypeError('option "quoteStyle" must be "single" or "double"');
}
if (has$3(opts, "maxStringLength") && (typeof opts.maxStringLength === "number" ? opts.maxStringLength < 0 && opts.maxStringLength !== Infinity : opts.maxStringLength !== null)) {
throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');
}
var customInspect = has$3(opts, "customInspect") ? opts.customInspect : true;
if (typeof customInspect !== "boolean") {
throw new TypeError('option "customInspect", if provided, must be `true` or `false`');
}
if (has$3(opts, "indent") && opts.indent !== null && opts.indent !== " " && !(parseInt(opts.indent, 10) === opts.indent && opts.indent > 0)) {
throw new TypeError('options "indent" must be "\\t", an integer > 0, or `null`');
}
if (typeof obj === "undefined") {
return "undefined";
}
if (obj === null) {
return "null";
}
if (typeof obj === "boolean") {
return obj ? "true" : "false";
}
if (typeof obj === "string") {
return inspectString(obj, opts);
}
if (typeof obj === "number") {
if (obj === 0) {
return Infinity / obj > 0 ? "0" : "-0";
}
return String(obj);
}
if (typeof obj === "bigint") {
return String(obj) + "n";
}
var maxDepth = typeof opts.depth === "undefined" ? 5 : opts.depth;
if (typeof depth === "undefined") {
depth = 0;
}
if (depth >= maxDepth && maxDepth > 0 && typeof obj === "object") {
return isArray$3(obj) ? "[Array]" : "[Object]";
}
var indent = getIndent(opts, depth);
if (typeof seen === "undefined") {
seen = [];
} else if (indexOf(seen, obj) >= 0) {
return "[Circular]";
}
function inspect(value, from4, noIndent) {
if (from4) {
seen = seen.slice();
seen.push(from4);
}
if (noIndent) {
var newOpts = {
depth: opts.depth
};
if (has$3(opts, "quoteStyle")) {
newOpts.quoteStyle = opts.quoteStyle;
}
return inspect_(value, newOpts, depth + 1, seen);
}
return inspect_(value, opts, depth + 1, seen);
}
if (typeof obj === "function") {
var name = nameOf(obj);
var keys2 = arrObjKeys(obj, inspect);
return "[Function" + (name ? ": " + name : " (anonymous)") + "]" + (keys2.length > 0 ? " { " + keys2.join(", ") + " }" : "");
}
if (isSymbol(obj)) {
var symString = symToString.call(obj);
return typeof obj === "object" ? markBoxed(symString) : symString;
}
if (isElement(obj)) {
var s = "<" + String(obj.nodeName).toLowerCase();
var attrs2 = obj.attributes || [];
for (var i = 0; i < attrs2.length; i++) {
s += " " + attrs2[i].name + "=" + wrapQuotes(quote(attrs2[i].value), "double", opts);
}
s += ">";
if (obj.childNodes && obj.childNodes.length) {
s += "...";
}
s += "</" + String(obj.nodeName).toLowerCase() + ">";
return s;
}
if (isArray$3(obj)) {
if (obj.length === 0) {
return "[]";
}
var xs = arrObjKeys(obj, inspect);
if (indent && !singleLineValues(xs)) {
return "[" + indentedJoin(xs, indent) + "]";
}
return "[ " + xs.join(", ") + " ]";
}
if (isError(obj)) {
var parts = arrObjKeys(obj, inspect);
if (parts.length === 0) {
return "[" + String(obj) + "]";
}
return "{ [" + String(obj) + "] " + parts.join(", ") + " }";
}
if (typeof obj === "object" && customInspect) {
if (inspectSymbol && typeof obj[inspectSymbol] === "function") {
return obj[inspectSymbol]();
} else if (typeof obj.inspect === "function") {
return obj.inspect();
}
}
if (isMap(obj)) {
var mapParts = [];
mapForEach.call(obj, function(value, key) {
mapParts.push(inspect(key, obj, true) + " => " + inspect(value, obj));
});
return collectionOf("Map", mapSize.call(obj), mapParts, indent);
}
if (isSet(obj)) {
var setParts = [];
setForEach.call(obj, function(value) {
setParts.push(inspect(value, obj));
});
return collectionOf("Set", setSize.call(obj), setParts, indent);
}
if (isWeakMap(obj)) {
return weakCollectionOf("WeakMap");
}
if (isWeakSet(obj)) {
return weakCollectionOf("WeakSet");
}
if (isNumber(obj)) {
return markBoxed(inspect(Number(obj)));
}
if (isBigInt(obj)) {
return markBoxed(inspect(bigIntValueOf.call(obj)));
}
if (isBoolean(obj)) {
return markBoxed(booleanValueOf.call(obj));
}
if (isString(obj)) {
return markBoxed(inspect(String(obj)));
}
if (!isDate(obj) && !isRegExp$1(obj)) {
var ys = arrObjKeys(obj, inspect);
if (ys.length === 0) {
return "{}";
}
if (indent) {
return "{" + indentedJoin(ys, indent) + "}";
}
return "{ " + ys.join(", ") + " }";
}
return String(obj);
};
function wrapQuotes(s, defaultStyle, opts) {
var quoteChar = (opts.quoteStyle || defaultStyle) === "double" ? '"' : "'";
return quoteChar + s + quoteChar;
}
function quote(s) {
return String(s).replace(/"/g, "&quot;");
}
function isArray$3(obj) {
return toStr(obj) === "[object Array]";
}
function isDate(obj) {
return toStr(obj) === "[object Date]";
}
function isRegExp$1(obj) {
return toStr(obj) === "[object RegExp]";
}
function isError(obj) {
return toStr(obj) === "[object Error]";
}
function isSymbol(obj) {
return toStr(obj) === "[object Symbol]";
}
function isString(obj) {
return toStr(obj) === "[object String]";
}
function isNumber(obj) {
return toStr(obj) === "[object Number]";
}
function isBigInt(obj) {
return toStr(obj) === "[object BigInt]";
}
function isBoolean(obj) {
return toStr(obj) === "[object Boolean]";
}
var hasOwn = Object.prototype.hasOwnProperty || function(key) {
return key in this;
};
function has$3(obj, key) {
return hasOwn.call(obj, key);
}
function toStr(obj) {
return objectToString.call(obj);
}
function nameOf(f) {
if (f.name) {
return f.name;
}
var m = match2.call(functionToString.call(f), /^function\s*([\w$]+)/);
if (m) {
return m[1];
}
return null;
}
function indexOf(xs, x) {
if (xs.indexOf) {
return xs.indexOf(x);
}
for (var i = 0, l = xs.length; i < l; i++) {
if (xs[i] === x) {
return i;
}
}
return -1;
}
function isMap(x) {
if (!mapSize || !x || typeof x !== "object") {
return false;
}
try {
mapSize.call(x);
try {
setSize.call(x);
} catch (s) {
return true;
}
return x instanceof Map;
} catch (e) {
}
return false;
}
function isWeakMap(x) {
if (!weakMapHas || !x || typeof x !== "object") {
return false;
}
try {
weakMapHas.call(x, weakMapHas);
try {
weakSetHas.call(x, weakSetHas);
} catch (s) {
return true;
}
return x instanceof WeakMap;
} catch (e) {
}
return false;
}
function isSet(x) {
if (!setSize || !x || typeof x !== "object") {
return false;
}
try {
setSize.call(x);
try {
mapSize.call(x);
} catch (m) {
return true;
}
return x instanceof Set;
} catch (e) {
}
return false;
}
function isWeakSet(x) {
if (!weakSetHas || !x || typeof x !== "object") {
return false;
}
try {
weakSetHas.call(x, weakSetHas);
try {
weakMapHas.call(x, weakMapHas);
} catch (s) {
return true;
}
return x instanceof WeakSet;
} catch (e) {
}
return false;
}
function isElement(x) {
if (!x || typeof x !== "object") {
return false;
}
if (typeof HTMLElement !== "undefined" && x instanceof HTMLElement) {
return true;
}
return typeof x.nodeName === "string" && typeof x.getAttribute === "function";
}
function inspectString(str2, opts) {
if (str2.length > opts.maxStringLength) {
var remaining = str2.length - opts.maxStringLength;
var trailer = "... " + remaining + " more character" + (remaining > 1 ? "s" : "");
return inspectString(str2.slice(0, opts.maxStringLength), opts) + trailer;
}
var s = str2.replace(/(['\\])/g, "\\$1").replace(/[\x00-\x1f]/g, lowbyte);
return wrapQuotes(s, "single", opts);
}
function lowbyte(c) {
var n = c.charCodeAt(0);
var x = {
8: "b",
9: "t",
10: "n",
12: "f",
13: "r"
}[n];
if (x) {
return "\\" + x;
}
return "\\x" + (n < 16 ? "0" : "") + n.toString(16).toUpperCase();
}
function markBoxed(str2) {
return "Object(" + str2 + ")";
}
function weakCollectionOf(type) {
return type + " { ? }";
}
function collectionOf(type, size2, entries, indent) {
var joinedEntries = indent ? indentedJoin(entries, indent) : entries.join(", ");
return type + " (" + size2 + ") {" + joinedEntries + "}";
}
function singleLineValues(xs) {
for (var i = 0; i < xs.length; i++) {
if (indexOf(xs[i], "\n") >= 0) {
return false;
}
}
return true;
}
function getIndent(opts, depth) {
var baseIndent;
if (opts.indent === " ") {
baseIndent = " ";
} else if (typeof opts.indent === "number" && opts.indent > 0) {
baseIndent = Array(opts.indent + 1).join(" ");
} else {
return null;
}
return {
base: baseIndent,
prev: Array(depth + 1).join(baseIndent)
};
}
function indentedJoin(xs, indent) {
if (xs.length === 0) {
return "";
}
var lineJoiner = "\n" + indent.prev + indent.base;
return lineJoiner + xs.join("," + lineJoiner) + "\n" + indent.prev;
}
function arrObjKeys(obj, inspect) {
var isArr = isArray$3(obj);
var xs = [];
if (isArr) {
xs.length = obj.length;
for (var i = 0; i < obj.length; i++) {
xs[i] = has$3(obj, i) ? inspect(obj[i], obj) : "";
}
}
for (var key in obj) {
if (!has$3(obj, key)) {
continue;
}
if (isArr && String(Number(key)) === key && key < obj.length) {
continue;
}
if (/[^\w$]/.test(key)) {
xs.push(inspect(key, obj) + ": " + inspect(obj[key], obj));
} else {
xs.push(key + ": " + inspect(obj[key], obj));
}
}
if (typeof gOPS === "function") {
var syms = gOPS(obj);
for (var j = 0; j < syms.length; j++) {
if (isEnumerable.call(obj, syms[j])) {
xs.push("[" + inspect(syms[j]) + "]: " + inspect(obj[syms[j]], obj));
}
}
}
return xs;
}
var $TypeError = O__zero_zero_Web_UI_node_modules_getIntrinsic("%TypeError%");
var $WeakMap = O__zero_zero_Web_UI_node_modules_getIntrinsic("%WeakMap%", true);
var $Map = O__zero_zero_Web_UI_node_modules_getIntrinsic("%Map%", true);
var $weakMapGet = callBound("WeakMap.prototype.get", true);
var $weakMapSet = callBound("WeakMap.prototype.set", true);
var $weakMapHas = callBound("WeakMap.prototype.has", true);
var $mapGet = callBound("Map.prototype.get", true);
var $mapSet = callBound("Map.prototype.set", true);
var $mapHas = callBound("Map.prototype.has", true);
var listGetNode = function(list, key) {
for (var prev = list, curr; (curr = prev.next) !== null; prev = curr) {
if (curr.key === key) {
prev.next = curr.next;
curr.next = list.next;
list.next = curr;
return curr;
}
}
};
var listGet = function(objects, key) {
var node4 = listGetNode(objects, key);
return node4 && node4.value;
};
var listSet = function(objects, key, value) {
var node4 = listGetNode(objects, key);
if (node4) {
node4.value = value;
} else {
objects.next = {
key,
next: objects.next,
value
};
}
};
var listHas = function(objects, key) {
return !!listGetNode(objects, key);
};
var O__zero_zero_Web_UI_node_modules_sideChannel = function getSideChannel() {
var $wm;
var $m;
var $o;
var channel = {
assert: function(key) {
if (!channel.has(key)) {
throw new $TypeError("Side channel does not contain " + O__zero_zero_Web_UI_node_modules_objectInspect(key));
}
},
get: function(key) {
if ($WeakMap && key && (typeof key === "object" || typeof key === "function")) {
if ($wm) {
return $weakMapGet($wm, key);
}
} else if ($Map) {
if ($m) {
return $mapGet($m, key);
}
} else {
if ($o) {
return listGet($o, key);
}
}
},
has: function(key) {
if ($WeakMap && key && (typeof key === "object" || typeof key === "function")) {
if ($wm) {
return $weakMapHas($wm, key);
}
} else if ($Map) {
if ($m) {
return $mapHas($m, key);
}
} else {
if ($o) {
return listHas($o, key);
}
}
return false;
},
set: function(key, value) {
if ($WeakMap && key && (typeof key === "object" || typeof key === "function")) {
if (!$wm) {
$wm = new $WeakMap();
}
$weakMapSet($wm, key, value);
} else if ($Map) {
if (!$m) {
$m = new $Map();
}
$mapSet($m, key, value);
} else {
if (!$o) {
$o = {key: {}, next: null};
}
listSet($o, key, value);
}
}
};
return channel;
};
var replace3 = String.prototype.replace;
var percentTwenties = /%20/g;
var Format = {
RFC1738: "RFC1738",
RFC3986: "RFC3986"
};
var formats = {
default: Format.RFC3986,
formatters: {
RFC1738: function(value) {
return replace3.call(value, percentTwenties, "+");
},
RFC3986: function(value) {
return String(value);
}
},
RFC1738: Format.RFC1738,
RFC3986: Format.RFC3986
};
var has$2 = Object.prototype.hasOwnProperty;
var isArray$2 = Array.isArray;
var hexTable = function() {
var array = [];
for (var i = 0; i < 256; ++i) {
array.push("%" + ((i < 16 ? "0" : "") + i.toString(16)).toUpperCase());
}
return array;
}();
var compactQueue = function compactQueue2(queue2) {
while (queue2.length > 1) {
var item = queue2.pop();
var obj = item.obj[item.prop];
if (isArray$2(obj)) {
var compacted = [];
for (var j = 0; j < obj.length; ++j) {
if (typeof obj[j] !== "undefined") {
compacted.push(obj[j]);
}
}
item.obj[item.prop] = compacted;
}
}
};
var arrayToObject = function arrayToObject2(source2, options) {
var obj = options && options.plainObjects ? Object.create(null) : {};
for (var i = 0; i < source2.length; ++i) {
if (typeof source2[i] !== "undefined") {
obj[i] = source2[i];
}
}
return obj;
};
var merge3 = function merge4(target2, source2, options) {
if (!source2) {
return target2;
}
if (typeof source2 !== "object") {
if (isArray$2(target2)) {
target2.push(source2);
} else if (target2 && typeof target2 === "object") {
if (options && (options.plainObjects || options.allowPrototypes) || !has$2.call(Object.prototype, source2)) {
target2[source2] = true;
}
} else {
return [target2, source2];
}
return target2;
}
if (!target2 || typeof target2 !== "object") {
return [target2].concat(source2);
}
var mergeTarget = target2;
if (isArray$2(target2) && !isArray$2(source2)) {
mergeTarget = arrayToObject(target2, options);
}
if (isArray$2(target2) && isArray$2(source2)) {
source2.forEach(function(item, i) {
if (has$2.call(target2, i)) {
var targetItem = target2[i];
if (targetItem && typeof targetItem === "object" && item && typeof item === "object") {
target2[i] = merge4(targetItem, item, options);
} else {
target2.push(item);
}
} else {
target2[i] = item;
}
});
return target2;
}
return Object.keys(source2).reduce(function(acc, key) {
var value = source2[key];
if (has$2.call(acc, key)) {
acc[key] = merge4(acc[key], value, options);
} else {
acc[key] = value;
}
return acc;
}, mergeTarget);
};
var assign = function assignSingleSource(target2, source2) {
return Object.keys(source2).reduce(function(acc, key) {
acc[key] = source2[key];
return acc;
}, target2);
};
var decode2 = function(str2, decoder2, charset) {
var strWithoutPlus = str2.replace(/\+/g, " ");
if (charset === "iso-8859-1") {
return strWithoutPlus.replace(/%[0-9a-f]{2}/gi, unescape);
}
try {
return decodeURIComponent(strWithoutPlus);
} catch (e) {
return strWithoutPlus;
}
};
var encode = function encode2(str2, defaultEncoder, charset, kind, format2) {
if (str2.length === 0) {
return str2;
}
var string = str2;
if (typeof str2 === "symbol") {
string = Symbol.prototype.toString.call(str2);
} else if (typeof str2 !== "string") {
string = String(str2);
}
if (charset === "iso-8859-1") {
return escape(string).replace(/%u[0-9a-f]{4}/gi, function($0) {
return "%26%23" + parseInt($0.slice(2), 16) + "%3B";
});
}
var out = "";
for (var i = 0; i < string.length; ++i) {
var c = string.charCodeAt(i);
if (c === 45 || c === 46 || c === 95 || c === 126 || c >= 48 && c <= 57 || c >= 65 && c <= 90 || c >= 97 && c <= 122 || format2 === formats.RFC1738 && (c === 40 || c === 41)) {
out += string.charAt(i);
continue;
}
if (c < 128) {
out = out + hexTable[c];
continue;
}
if (c < 2048) {
out = out + (hexTable[192 | c >> 6] + hexTable[128 | c & 63]);
continue;
}
if (c < 55296 || c >= 57344) {
out = out + (hexTable[224 | c >> 12] + hexTable[128 | c >> 6 & 63] + hexTable[128 | c & 63]);
continue;
}
i += 1;
c = 65536 + ((c & 1023) << 10 | string.charCodeAt(i) & 1023);
out += hexTable[240 | c >> 18] + hexTable[128 | c >> 12 & 63] + hexTable[128 | c >> 6 & 63] + hexTable[128 | c & 63];
}
return out;
};
var compact = function compact2(value) {
var queue2 = [{obj: {o: value}, prop: "o"}];
var refs = [];
for (var i = 0; i < queue2.length; ++i) {
var item = queue2[i];
var obj = item.obj[item.prop];
var keys2 = Object.keys(obj);
for (var j = 0; j < keys2.length; ++j) {
var key = keys2[j];
var val = obj[key];
if (typeof val === "object" && val !== null && refs.indexOf(val) === -1) {
queue2.push({obj, prop: key});
refs.push(val);
}
}
}
compactQueue(queue2);
return value;
};
var isRegExp = function isRegExp2(obj) {
return Object.prototype.toString.call(obj) === "[object RegExp]";
};
var isBuffer = function isBuffer2(obj) {
if (!obj || typeof obj !== "object") {
return false;
}
return !!(obj.constructor && obj.constructor.isBuffer && obj.constructor.isBuffer(obj));
};
var combine = function combine2(a, b) {
return [].concat(a, b);
};
var maybeMap = function maybeMap2(val, fn) {
if (isArray$2(val)) {
var mapped = [];
for (var i = 0; i < val.length; i += 1) {
mapped.push(fn(val[i]));
}
return mapped;
}
return fn(val);
};
var utils = {
arrayToObject,
assign,
combine,
compact,
decode: decode2,
encode,
isBuffer,
isRegExp,
maybeMap,
merge: merge3
};
var has$1 = Object.prototype.hasOwnProperty;
var arrayPrefixGenerators = {
brackets: function brackets(prefix) {
return prefix + "[]";
},
comma: "comma",
indices: function indices(prefix, key) {
return prefix + "[" + key + "]";
},
repeat: function repeat(prefix) {
return prefix;
}
};
var isArray$1 = Array.isArray;
var push2 = Array.prototype.push;
var pushToArray = function(arr, valueOrArray) {
push2.apply(arr, isArray$1(valueOrArray) ? valueOrArray : [valueOrArray]);
};
var toISO = Date.prototype.toISOString;
var defaultFormat = formats["default"];
var defaults$2 = {
addQueryPrefix: false,
allowDots: false,
charset: "utf-8",
charsetSentinel: false,
delimiter: "&",
encode: true,
encoder: utils.encode,
encodeValuesOnly: false,
format: defaultFormat,
formatter: formats.formatters[defaultFormat],
indices: false,
serializeDate: function serializeDate(date) {
return toISO.call(date);
},
skipNulls: false,
strictNullHandling: false
};
var isNonNullishPrimitive = function isNonNullishPrimitive2(v) {
return typeof v === "string" || typeof v === "number" || typeof v === "boolean" || typeof v === "symbol" || typeof v === "bigint";
};
var stringify = function stringify2(object2, prefix, generateArrayPrefix, strictNullHandling, skipNulls, encoder, filter2, sort2, allowDots, serializeDate2, format2, formatter, encodeValuesOnly, charset, sideChannel) {
var obj = object2;
if (sideChannel.has(object2)) {
throw new RangeError("Cyclic object value");
}
if (typeof filter2 === "function") {
obj = filter2(prefix, obj);
} else if (obj instanceof Date) {
obj = serializeDate2(obj);
} else if (generateArrayPrefix === "comma" && isArray$1(obj)) {
obj = utils.maybeMap(obj, function(value2) {
if (value2 instanceof Date) {
return serializeDate2(value2);
}
return value2;
});
}
if (obj === null) {
if (strictNullHandling) {
return encoder && !encodeValuesOnly ? encoder(prefix, defaults$2.encoder, charset, "key", format2) : prefix;
}
obj = "";
}
if (isNonNullishPrimitive(obj) || utils.isBuffer(obj)) {
if (encoder) {
var keyValue = encodeValuesOnly ? prefix : encoder(prefix, defaults$2.encoder, charset, "key", format2);
return [formatter(keyValue) + "=" + formatter(encoder(obj, defaults$2.encoder, charset, "value", format2))];
}
return [formatter(prefix) + "=" + formatter(String(obj))];
}
var values2 = [];
if (typeof obj === "undefined") {
return values2;
}
var objKeys;
if (generateArrayPrefix === "comma" && isArray$1(obj)) {
objKeys = [{value: obj.length > 0 ? obj.join(",") || null : void 0}];
} else if (isArray$1(filter2)) {
objKeys = filter2;
} else {
var keys2 = Object.keys(obj);
objKeys = sort2 ? keys2.sort(sort2) : keys2;
}
for (var i = 0; i < objKeys.length; ++i) {
var key = objKeys[i];
var value = typeof key === "object" && key.value !== void 0 ? key.value : obj[key];
if (skipNulls && value === null) {
continue;
}
var keyPrefix = isArray$1(obj) ? typeof generateArrayPrefix === "function" ? generateArrayPrefix(prefix, key) : prefix : prefix + (allowDots ? "." + key : "[" + key + "]");
sideChannel.set(object2, true);
var valueSideChannel = O__zero_zero_Web_UI_node_modules_sideChannel();
pushToArray(values2, stringify2(value, keyPrefix, generateArrayPrefix, strictNullHandling, skipNulls, encoder, filter2, sort2, allowDots, serializeDate2, format2, formatter, encodeValuesOnly, charset, valueSideChannel));
}
return values2;
};
var normalizeStringifyOptions = function normalizeStringifyOptions2(opts) {
if (!opts) {
return defaults$2;
}
if (opts.encoder !== null && opts.encoder !== void 0 && typeof opts.encoder !== "function") {
throw new TypeError("Encoder has to be a function.");
}
var charset = opts.charset || defaults$2.charset;
if (typeof opts.charset !== "undefined" && opts.charset !== "utf-8" && opts.charset !== "iso-8859-1") {
throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");
}
var format2 = formats["default"];
if (typeof opts.format !== "undefined") {
if (!has$1.call(formats.formatters, opts.format)) {
throw new TypeError("Unknown format option provided.");
}
format2 = opts.format;
}
var formatter = formats.formatters[format2];
var filter2 = defaults$2.filter;
if (typeof opts.filter === "function" || isArray$1(opts.filter)) {
filter2 = opts.filter;
}
return {
addQueryPrefix: typeof opts.addQueryPrefix === "boolean" ? opts.addQueryPrefix : defaults$2.addQueryPrefix,
allowDots: typeof opts.allowDots === "undefined" ? defaults$2.allowDots : !!opts.allowDots,
charset,
charsetSentinel: typeof opts.charsetSentinel === "boolean" ? opts.charsetSentinel : defaults$2.charsetSentinel,
delimiter: typeof opts.delimiter === "undefined" ? defaults$2.delimiter : opts.delimiter,
encode: typeof opts.encode === "boolean" ? opts.encode : defaults$2.encode,
encoder: typeof opts.encoder === "function" ? opts.encoder : defaults$2.encoder,
encodeValuesOnly: typeof opts.encodeValuesOnly === "boolean" ? opts.encodeValuesOnly : defaults$2.encodeValuesOnly,
filter: filter2,
format: format2,
formatter,
serializeDate: typeof opts.serializeDate === "function" ? opts.serializeDate : defaults$2.serializeDate,
skipNulls: typeof opts.skipNulls === "boolean" ? opts.skipNulls : defaults$2.skipNulls,
sort: typeof opts.sort === "function" ? opts.sort : null,
strictNullHandling: typeof opts.strictNullHandling === "boolean" ? opts.strictNullHandling : defaults$2.strictNullHandling
};
};
var stringify_1 = function(object2, opts) {
var obj = object2;
var options = normalizeStringifyOptions(opts);
var objKeys;
var filter2;
if (typeof options.filter === "function") {
filter2 = options.filter;
obj = filter2("", obj);
} else if (isArray$1(options.filter)) {
filter2 = options.filter;
objKeys = filter2;
}
var keys2 = [];
if (typeof obj !== "object" || obj === null) {
return "";
}
var arrayFormat;
if (opts && opts.arrayFormat in arrayPrefixGenerators) {
arrayFormat = opts.arrayFormat;
} else if (opts && "indices" in opts) {
arrayFormat = opts.indices ? "indices" : "repeat";
} else {
arrayFormat = "indices";
}
var generateArrayPrefix = arrayPrefixGenerators[arrayFormat];
if (!objKeys) {
objKeys = Object.keys(obj);
}
if (options.sort) {
objKeys.sort(options.sort);
}
var sideChannel = O__zero_zero_Web_UI_node_modules_sideChannel();
for (var i = 0; i < objKeys.length; ++i) {
var key = objKeys[i];
if (options.skipNulls && obj[key] === null) {
continue;
}
pushToArray(keys2, stringify(obj[key], key, generateArrayPrefix, options.strictNullHandling, options.skipNulls, options.encode ? options.encoder : null, options.filter, options.sort, options.allowDots, options.serializeDate, options.format, options.formatter, options.encodeValuesOnly, options.charset, sideChannel));
}
var joined = keys2.join(options.delimiter);
var prefix = options.addQueryPrefix === true ? "?" : "";
if (options.charsetSentinel) {
if (options.charset === "iso-8859-1") {
prefix += "utf8=%26%2310003%3B&";
} else {
prefix += "utf8=%E2%9C%93&";
}
}
return joined.length > 0 ? prefix + joined : "";
};
var has = Object.prototype.hasOwnProperty;
var isArray = Array.isArray;
var defaults$1 = {
allowDots: false,
allowPrototypes: false,
allowSparse: false,
arrayLimit: 20,
charset: "utf-8",
charsetSentinel: false,
comma: false,
decoder: utils.decode,
delimiter: "&",
depth: 5,
ignoreQueryPrefix: false,
interpretNumericEntities: false,
parameterLimit: 1e3,
parseArrays: true,
plainObjects: false,
strictNullHandling: false
};
var interpretNumericEntities = function(str2) {
return str2.replace(/&#(\d+);/g, function($0, numberStr) {
return String.fromCharCode(parseInt(numberStr, 10));
});
};
var parseArrayValue = function(val, options) {
if (val && typeof val === "string" && options.comma && val.indexOf(",") > -1) {
return val.split(",");
}
return val;
};
var isoSentinel = "utf8=%26%2310003%3B";
var charsetSentinel = "utf8=%E2%9C%93";
var parseValues = function parseQueryStringValues(str2, options) {
var obj = {};
var cleanStr = options.ignoreQueryPrefix ? str2.replace(/^\?/, "") : str2;
var limit = options.parameterLimit === Infinity ? void 0 : options.parameterLimit;
var parts = cleanStr.split(options.delimiter, limit);
var skipIndex = -1;
var i;
var charset = options.charset;
if (options.charsetSentinel) {
for (i = 0; i < parts.length; ++i) {
if (parts[i].indexOf("utf8=") === 0) {
if (parts[i] === charsetSentinel) {
charset = "utf-8";
} else if (parts[i] === isoSentinel) {
charset = "iso-8859-1";
}
skipIndex = i;
i = parts.length;
}
}
}
for (i = 0; i < parts.length; ++i) {
if (i === skipIndex) {
continue;
}
var part = parts[i];
var bracketEqualsPos = part.indexOf("]=");
var pos = bracketEqualsPos === -1 ? part.indexOf("=") : bracketEqualsPos + 1;
var key, val;
if (pos === -1) {
key = options.decoder(part, defaults$1.decoder, charset, "key");
val = options.strictNullHandling ? null : "";
} else {
key = options.decoder(part.slice(0, pos), defaults$1.decoder, charset, "key");
val = utils.maybeMap(parseArrayValue(part.slice(pos + 1), options), function(encodedVal) {
return options.decoder(encodedVal, defaults$1.decoder, charset, "value");
});
}
if (val && options.interpretNumericEntities && charset === "iso-8859-1") {
val = interpretNumericEntities(val);
}
if (part.indexOf("[]=") > -1) {
val = isArray(val) ? [val] : val;
}
if (has.call(obj, key)) {
obj[key] = utils.combine(obj[key], val);
} else {
obj[key] = val;
}
}
return obj;
};
var parseObject = function(chain2, val, options, valuesParsed) {
var leaf = valuesParsed ? val : parseArrayValue(val, options);
for (var i = chain2.length - 1; i >= 0; --i) {
var obj;
var root2 = chain2[i];
if (root2 === "[]" && options.parseArrays) {
obj = [].concat(leaf);
} else {
obj = options.plainObjects ? Object.create(null) : {};
var cleanRoot = root2.charAt(0) === "[" && root2.charAt(root2.length - 1) === "]" ? root2.slice(1, -1) : root2;
var index3 = parseInt(cleanRoot, 10);
if (!options.parseArrays && cleanRoot === "") {
obj = {0: leaf};
} else if (!isNaN(index3) && root2 !== cleanRoot && String(index3) === cleanRoot && index3 >= 0 && (options.parseArrays && index3 <= options.arrayLimit)) {
obj = [];
obj[index3] = leaf;
} else {
obj[cleanRoot] = leaf;
}
}
leaf = obj;
}
return leaf;
};
var parseKeys = function parseQueryStringKeys(givenKey, val, options, valuesParsed) {
if (!givenKey) {
return;
}
var key = options.allowDots ? givenKey.replace(/\.([^.[]+)/g, "[$1]") : givenKey;
var brackets2 = /(\[[^[\]]*])/;
var child3 = /(\[[^[\]]*])/g;
var segment = options.depth > 0 && brackets2.exec(key);
var parent = segment ? key.slice(0, segment.index) : key;
var keys2 = [];
if (parent) {
if (!options.plainObjects && has.call(Object.prototype, parent)) {
if (!options.allowPrototypes) {
return;
}
}
keys2.push(parent);
}
var i = 0;
while (options.depth > 0 && (segment = child3.exec(key)) !== null && i < options.depth) {
i += 1;
if (!options.plainObjects && has.call(Object.prototype, segment[1].slice(1, -1))) {
if (!options.allowPrototypes) {
return;
}
}
keys2.push(segment[1]);
}
if (segment) {
keys2.push("[" + key.slice(segment.index) + "]");
}
return parseObject(keys2, val, options, valuesParsed);
};
var normalizeParseOptions = function normalizeParseOptions2(opts) {
if (!opts) {
return defaults$1;
}
if (opts.decoder !== null && opts.decoder !== void 0 && typeof opts.decoder !== "function") {
throw new TypeError("Decoder has to be a function.");
}
if (typeof opts.charset !== "undefined" && opts.charset !== "utf-8" && opts.charset !== "iso-8859-1") {
throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");
}
var charset = typeof opts.charset === "undefined" ? defaults$1.charset : opts.charset;
return {
allowDots: typeof opts.allowDots === "undefined" ? defaults$1.allowDots : !!opts.allowDots,
allowPrototypes: typeof opts.allowPrototypes === "boolean" ? opts.allowPrototypes : defaults$1.allowPrototypes,
allowSparse: typeof opts.allowSparse === "boolean" ? opts.allowSparse : defaults$1.allowSparse,
arrayLimit: typeof opts.arrayLimit === "number" ? opts.arrayLimit : defaults$1.arrayLimit,
charset,
charsetSentinel: typeof opts.charsetSentinel === "boolean" ? opts.charsetSentinel : defaults$1.charsetSentinel,
comma: typeof opts.comma === "boolean" ? opts.comma : defaults$1.comma,
decoder: typeof opts.decoder === "function" ? opts.decoder : defaults$1.decoder,
delimiter: typeof opts.delimiter === "string" || utils.isRegExp(opts.delimiter) ? opts.delimiter : defaults$1.delimiter,
depth: typeof opts.depth === "number" || opts.depth === false ? +opts.depth : defaults$1.depth,
ignoreQueryPrefix: opts.ignoreQueryPrefix === true,
interpretNumericEntities: typeof opts.interpretNumericEntities === "boolean" ? opts.interpretNumericEntities : defaults$1.interpretNumericEntities,
parameterLimit: typeof opts.parameterLimit === "number" ? opts.parameterLimit : defaults$1.parameterLimit,
parseArrays: opts.parseArrays !== false,
plainObjects: typeof opts.plainObjects === "boolean" ? opts.plainObjects : defaults$1.plainObjects,
strictNullHandling: typeof opts.strictNullHandling === "boolean" ? opts.strictNullHandling : defaults$1.strictNullHandling
};
};
var parse3 = function(str2, opts) {
var options = normalizeParseOptions(opts);
if (str2 === "" || str2 === null || typeof str2 === "undefined") {
return options.plainObjects ? Object.create(null) : {};
}
var tempObj = typeof str2 === "string" ? parseValues(str2, options) : str2;
var obj = options.plainObjects ? Object.create(null) : {};
var keys2 = Object.keys(tempObj);
for (var i = 0; i < keys2.length; ++i) {
var key = keys2[i];
var newObj = parseKeys(key, tempObj[key], options, typeof str2 === "string");
obj = utils.merge(obj, newObj, options);
}
if (options.allowSparse === true) {
return obj;
}
return utils.compact(obj);
};
var O__zero_zero_Web_UI_node_modules_qs_lib = {
formats,
parse: parse3,
stringify: stringify_1
};
/**!
* Sortable 1.13.0
* @author RubaXa <trash@rubaxa.org>
* @author owenm <owen23355@gmail.com>
* @license MIT
*/
function _typeof(obj) {
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
_typeof = function(obj2) {
return typeof obj2;
};
} else {
_typeof = function(obj2) {
return obj2 && typeof Symbol === "function" && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2;
};
}
return _typeof(obj);
}
function _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
function _extends() {
_extends = Object.assign || function(target2) {
for (var i = 1; i < arguments.length; i++) {
var source2 = arguments[i];
for (var key in source2) {
if (Object.prototype.hasOwnProperty.call(source2, key)) {
target2[key] = source2[key];
}
}
}
return target2;
};
return _extends.apply(this, arguments);
}
function _objectSpread(target2) {
for (var i = 1; i < arguments.length; i++) {
var source2 = arguments[i] != null ? arguments[i] : {};
var ownKeys = Object.keys(source2);
if (typeof Object.getOwnPropertySymbols === "function") {
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source2).filter(function(sym) {
return Object.getOwnPropertyDescriptor(source2, sym).enumerable;
}));
}
ownKeys.forEach(function(key) {
_defineProperty(target2, key, source2[key]);
});
}
return target2;
}
function _objectWithoutPropertiesLoose(source2, excluded) {
if (source2 == null)
return {};
var target2 = {};
var sourceKeys = Object.keys(source2);
var key, i;
for (i = 0; i < sourceKeys.length; i++) {
key = sourceKeys[i];
if (excluded.indexOf(key) >= 0)
continue;
target2[key] = source2[key];
}
return target2;
}
function _objectWithoutProperties(source2, excluded) {
if (source2 == null)
return {};
var target2 = _objectWithoutPropertiesLoose(source2, excluded);
var key, i;
if (Object.getOwnPropertySymbols) {
var sourceSymbolKeys = Object.getOwnPropertySymbols(source2);
for (i = 0; i < sourceSymbolKeys.length; i++) {
key = sourceSymbolKeys[i];
if (excluded.indexOf(key) >= 0)
continue;
if (!Object.prototype.propertyIsEnumerable.call(source2, key))
continue;
target2[key] = source2[key];
}
}
return target2;
}
var version = "1.13.0";
function userAgent(pattern) {
if (typeof window !== "undefined" && window.navigator) {
return !!/* @__PURE__ */ navigator.userAgent.match(pattern);
}
}
var IE11OrLess = userAgent(/(?:Trident.*rv[ :]?11\.|msie|iemobile|Windows Phone)/i);
var Edge = userAgent(/Edge/i);
var FireFox = userAgent(/firefox/i);
var Safari = userAgent(/safari/i) && !userAgent(/chrome/i) && !userAgent(/android/i);
var IOS = userAgent(/iP(ad|od|hone)/i);
var ChromeForAndroid = userAgent(/chrome/i) && userAgent(/android/i);
var captureMode = {
capture: false,
passive: false
};
function on(el, event, fn) {
el.addEventListener(event, fn, !IE11OrLess && captureMode);
}
function off(el, event, fn) {
el.removeEventListener(event, fn, !IE11OrLess && captureMode);
}
function matches(el, selector) {
if (!selector)
return;
selector[0] === ">" && (selector = selector.substring(1));
if (el) {
try {
if (el.matches) {
return el.matches(selector);
} else if (el.msMatchesSelector) {
return el.msMatchesSelector(selector);
} else if (el.webkitMatchesSelector) {
return el.webkitMatchesSelector(selector);
}
} catch (_2) {
return false;
}
}
return false;
}
function getParentOrHost(el) {
return el.host && el !== document && el.host.nodeType ? el.host : el.parentNode;
}
function closest(el, selector, ctx, includeCTX) {
if (el) {
ctx = ctx || document;
do {
if (selector != null && (selector[0] === ">" ? el.parentNode === ctx && matches(el, selector) : matches(el, selector)) || includeCTX && el === ctx) {
return el;
}
if (el === ctx)
break;
} while (el = getParentOrHost(el));
}
return null;
}
var R_SPACE = /\s+/g;
function toggleClass(el, name, state) {
if (el && name) {
if (el.classList) {
el.classList[state ? "add" : "remove"](name);
} else {
var className = (" " + el.className + " ").replace(R_SPACE, " ").replace(" " + name + " ", " ");
el.className = (className + (state ? " " + name : "")).replace(R_SPACE, " ");
}
}
}
function css(el, prop, val) {
var style2 = el && el.style;
if (style2) {
if (val === void 0) {
if (document.defaultView && document.defaultView.getComputedStyle) {
val = document.defaultView.getComputedStyle(el, "");
} else if (el.currentStyle) {
val = el.currentStyle;
}
return prop === void 0 ? val : val[prop];
} else {
if (!(prop in style2) && prop.indexOf("webkit") === -1) {
prop = "-webkit-" + prop;
}
style2[prop] = val + (typeof val === "string" ? "" : "px");
}
}
}
function matrix(el, selfOnly) {
var appliedTransforms = "";
if (typeof el === "string") {
appliedTransforms = el;
} else {
do {
var transform = css(el, "transform");
if (transform && transform !== "none") {
appliedTransforms = transform + " " + appliedTransforms;
}
} while (!selfOnly && (el = el.parentNode));
}
var matrixFn = window.DOMMatrix || window.WebKitCSSMatrix || window.CSSMatrix || window.MSCSSMatrix;
return matrixFn && new matrixFn(appliedTransforms);
}
function find2(ctx, tagName2, iterator) {
if (ctx) {
var list = ctx.getElementsByTagName(tagName2), i = 0, n = list.length;
if (iterator) {
for (; i < n; i++) {
iterator(list[i], i);
}
}
return list;
}
return [];
}
function getWindowScrollingElement() {
var scrollingElement = document.scrollingElement;
if (scrollingElement) {
return scrollingElement;
} else {
return document.documentElement;
}
}
function getRect(el, relativeToContainingBlock, relativeToNonStaticParent, undoScale, container) {
if (!el.getBoundingClientRect && el !== window)
return;
var elRect, top, left, bottom, right, height, width;
if (el !== window && el.parentNode && el !== getWindowScrollingElement()) {
elRect = el.getBoundingClientRect();
top = elRect.top;
left = elRect.left;
bottom = elRect.bottom;
right = elRect.right;
height = elRect.height;
width = elRect.width;
} else {
top = 0;
left = 0;
bottom = window.innerHeight;
right = window.innerWidth;
height = window.innerHeight;
width = window.innerWidth;
}
if ((relativeToContainingBlock || relativeToNonStaticParent) && el !== window) {
container = container || el.parentNode;
if (!IE11OrLess) {
do {
if (container && container.getBoundingClientRect && (css(container, "transform") !== "none" || relativeToNonStaticParent && css(container, "position") !== "static")) {
var containerRect = container.getBoundingClientRect();
top -= containerRect.top + parseInt(css(container, "border-top-width"));
left -= containerRect.left + parseInt(css(container, "border-left-width"));
bottom = top + elRect.height;
right = left + elRect.width;
break;
}
} while (container = container.parentNode);
}
}
if (undoScale && el !== window) {
var elMatrix = matrix(container || el), scaleX = elMatrix && elMatrix.a, scaleY = elMatrix && elMatrix.d;
if (elMatrix) {
top /= scaleY;
left /= scaleX;
width /= scaleX;
height /= scaleY;
bottom = top + height;
right = left + width;
}
}
return {
top,
left,
bottom,
right,
width,
height
};
}
function isScrolledPast(el, elSide, parentSide) {
var parent = getParentAutoScrollElement(el, true), elSideVal = getRect(el)[elSide];
while (parent) {
var parentSideVal = getRect(parent)[parentSide], visible = void 0;
if (parentSide === "top" || parentSide === "left") {
visible = elSideVal >= parentSideVal;
} else {
visible = elSideVal <= parentSideVal;
}
if (!visible)
return parent;
if (parent === getWindowScrollingElement())
break;
parent = getParentAutoScrollElement(parent, false);
}
return false;
}
function getChild(el, childNum, options) {
var currentChild = 0, i = 0, children = el.children;
while (i < children.length) {
if (children[i].style.display !== "none" && children[i] !== Sortable.ghost && children[i] !== Sortable.dragged && closest(children[i], options.draggable, el, false)) {
if (currentChild === childNum) {
return children[i];
}
currentChild++;
}
i++;
}
return null;
}
function lastChild(el, selector) {
var last2 = el.lastElementChild;
while (last2 && (last2 === Sortable.ghost || css(last2, "display") === "none" || selector && !matches(last2, selector))) {
last2 = last2.previousElementSibling;
}
return last2 || null;
}
function index2(el, selector) {
var index3 = 0;
if (!el || !el.parentNode) {
return -1;
}
while (el = el.previousElementSibling) {
if (el.nodeName.toUpperCase() !== "TEMPLATE" && el !== Sortable.clone && (!selector || matches(el, selector))) {
index3++;
}
}
return index3;
}
function getRelativeScrollOffset(el) {
var offsetLeft = 0, offsetTop = 0, winScroller = getWindowScrollingElement();
if (el) {
do {
var elMatrix = matrix(el), scaleX = elMatrix.a, scaleY = elMatrix.d;
offsetLeft += el.scrollLeft * scaleX;
offsetTop += el.scrollTop * scaleY;
} while (el !== winScroller && (el = el.parentNode));
}
return [offsetLeft, offsetTop];
}
function indexOfObject(arr, obj) {
for (var i in arr) {
if (!arr.hasOwnProperty(i))
continue;
for (var key in obj) {
if (obj.hasOwnProperty(key) && obj[key] === arr[i][key])
return Number(i);
}
}
return -1;
}
function getParentAutoScrollElement(el, includeSelf) {
if (!el || !el.getBoundingClientRect)
return getWindowScrollingElement();
var elem = el;
var gotSelf = false;
do {
if (elem.clientWidth < elem.scrollWidth || elem.clientHeight < elem.scrollHeight) {
var elemCSS = css(elem);
if (elem.clientWidth < elem.scrollWidth && (elemCSS.overflowX == "auto" || elemCSS.overflowX == "scroll") || elem.clientHeight < elem.scrollHeight && (elemCSS.overflowY == "auto" || elemCSS.overflowY == "scroll")) {
if (!elem.getBoundingClientRect || elem === document.body)
return getWindowScrollingElement();
if (gotSelf || includeSelf)
return elem;
gotSelf = true;
}
}
} while (elem = elem.parentNode);
return getWindowScrollingElement();
}
function extend(dst, src) {
if (dst && src) {
for (var key in src) {
if (src.hasOwnProperty(key)) {
dst[key] = src[key];
}
}
}
return dst;
}
function isRectEqual(rect1, rect2) {
return Math.round(rect1.top) === Math.round(rect2.top) && Math.round(rect1.left) === Math.round(rect2.left) && Math.round(rect1.height) === Math.round(rect2.height) && Math.round(rect1.width) === Math.round(rect2.width);
}
var _throttleTimeout;
function throttle(callback, ms) {
return function() {
if (!_throttleTimeout) {
var args = arguments, _this = this;
if (args.length === 1) {
callback.call(_this, args[0]);
} else {
callback.apply(_this, args);
}
_throttleTimeout = setTimeout(function() {
_throttleTimeout = void 0;
}, ms);
}
};
}
function cancelThrottle() {
clearTimeout(_throttleTimeout);
_throttleTimeout = void 0;
}
function scrollBy(el, x, y) {
el.scrollLeft += x;
el.scrollTop += y;
}
function clone(el) {
var Polymer = window.Polymer;
var $ = window.jQuery || window.Zepto;
if (Polymer && Polymer.dom) {
return Polymer.dom(el).cloneNode(true);
} else if ($) {
return $(el).clone(true)[0];
} else {
return el.cloneNode(true);
}
}
var expando = "Sortable" + new Date().getTime();
function AnimationStateManager() {
var animationStates = [], animationCallbackId;
return {
captureAnimationState: function captureAnimationState() {
animationStates = [];
if (!this.options.animation)
return;
var children = [].slice.call(this.el.children);
children.forEach(function(child3) {
if (css(child3, "display") === "none" || child3 === Sortable.ghost)
return;
animationStates.push({
target: child3,
rect: getRect(child3)
});
var fromRect = _objectSpread({}, animationStates[animationStates.length - 1].rect);
if (child3.thisAnimationDuration) {
var childMatrix = matrix(child3, true);
if (childMatrix) {
fromRect.top -= childMatrix.f;
fromRect.left -= childMatrix.e;
}
}
child3.fromRect = fromRect;
});
},
addAnimationState: function addAnimationState(state) {
animationStates.push(state);
},
removeAnimationState: function removeAnimationState(target2) {
animationStates.splice(indexOfObject(animationStates, {
target: target2
}), 1);
},
animateAll: function animateAll(callback) {
var _this = this;
if (!this.options.animation) {
clearTimeout(animationCallbackId);
if (typeof callback === "function")
callback();
return;
}
var animating = false, animationTime = 0;
animationStates.forEach(function(state) {
var time = 0, target2 = state.target, fromRect = target2.fromRect, toRect = getRect(target2), prevFromRect = target2.prevFromRect, prevToRect = target2.prevToRect, animatingRect = state.rect, targetMatrix = matrix(target2, true);
if (targetMatrix) {
toRect.top -= targetMatrix.f;
toRect.left -= targetMatrix.e;
}
target2.toRect = toRect;
if (target2.thisAnimationDuration) {
if (isRectEqual(prevFromRect, toRect) && !isRectEqual(fromRect, toRect) && (animatingRect.top - toRect.top) / (animatingRect.left - toRect.left) === (fromRect.top - toRect.top) / (fromRect.left - toRect.left)) {
time = calculateRealTime(animatingRect, prevFromRect, prevToRect, _this.options);
}
}
if (!isRectEqual(toRect, fromRect)) {
target2.prevFromRect = fromRect;
target2.prevToRect = toRect;
if (!time) {
time = _this.options.animation;
}
_this.animate(target2, animatingRect, toRect, time);
}
if (time) {
animating = true;
animationTime = Math.max(animationTime, time);
clearTimeout(target2.animationResetTimer);
target2.animationResetTimer = setTimeout(function() {
target2.animationTime = 0;
target2.prevFromRect = null;
target2.fromRect = null;
target2.prevToRect = null;
target2.thisAnimationDuration = null;
}, time);
target2.thisAnimationDuration = time;
}
});
clearTimeout(animationCallbackId);
if (!animating) {
if (typeof callback === "function")
callback();
} else {
animationCallbackId = setTimeout(function() {
if (typeof callback === "function")
callback();
}, animationTime);
}
animationStates = [];
},
animate: function animate(target2, currentRect, toRect, duration2) {
if (duration2) {
css(target2, "transition", "");
css(target2, "transform", "");
var elMatrix = matrix(this.el), scaleX = elMatrix && elMatrix.a, scaleY = elMatrix && elMatrix.d, translateX = (currentRect.left - toRect.left) / (scaleX || 1), translateY = (currentRect.top - toRect.top) / (scaleY || 1);
target2.animatingX = !!translateX;
target2.animatingY = !!translateY;
css(target2, "transform", "translate3d(" + translateX + "px," + translateY + "px,0)");
this.forRepaintDummy = repaint(target2);
css(target2, "transition", "transform " + duration2 + "ms" + (this.options.easing ? " " + this.options.easing : ""));
css(target2, "transform", "translate3d(0,0,0)");
typeof target2.animated === "number" && clearTimeout(target2.animated);
target2.animated = setTimeout(function() {
css(target2, "transition", "");
css(target2, "transform", "");
target2.animated = false;
target2.animatingX = false;
target2.animatingY = false;
}, duration2);
}
}
};
}
function repaint(target2) {
return target2.offsetWidth;
}
function calculateRealTime(animatingRect, fromRect, toRect, options) {
return Math.sqrt(Math.pow(fromRect.top - animatingRect.top, 2) + Math.pow(fromRect.left - animatingRect.left, 2)) / Math.sqrt(Math.pow(fromRect.top - toRect.top, 2) + Math.pow(fromRect.left - toRect.left, 2)) * options.animation;
}
var plugins = [];
var defaults = {
initializeByDefault: true
};
var PluginManager = {
mount: function mount2(plugin) {
for (var option2 in defaults) {
if (defaults.hasOwnProperty(option2) && !(option2 in plugin)) {
plugin[option2] = defaults[option2];
}
}
plugins.forEach(function(p) {
if (p.pluginName === plugin.pluginName) {
throw "Sortable: Cannot mount plugin ".concat(plugin.pluginName, " more than once");
}
});
plugins.push(plugin);
},
pluginEvent: function pluginEvent(eventName, sortable, evt) {
var _this = this;
this.eventCanceled = false;
evt.cancel = function() {
_this.eventCanceled = true;
};
var eventNameGlobal = eventName + "Global";
plugins.forEach(function(plugin) {
if (!sortable[plugin.pluginName])
return;
if (sortable[plugin.pluginName][eventNameGlobal]) {
sortable[plugin.pluginName][eventNameGlobal](_objectSpread({
sortable
}, evt));
}
if (sortable.options[plugin.pluginName] && sortable[plugin.pluginName][eventName]) {
sortable[plugin.pluginName][eventName](_objectSpread({
sortable
}, evt));
}
});
},
initializePlugins: function initializePlugins(sortable, el, defaults2, options) {
plugins.forEach(function(plugin) {
var pluginName = plugin.pluginName;
if (!sortable.options[pluginName] && !plugin.initializeByDefault)
return;
var initialized = new plugin(sortable, el, sortable.options);
initialized.sortable = sortable;
initialized.options = sortable.options;
sortable[pluginName] = initialized;
_extends(defaults2, initialized.defaults);
});
for (var option2 in sortable.options) {
if (!sortable.options.hasOwnProperty(option2))
continue;
var modified = this.modifyOption(sortable, option2, sortable.options[option2]);
if (typeof modified !== "undefined") {
sortable.options[option2] = modified;
}
}
},
getEventProperties: function getEventProperties(name, sortable) {
var eventProperties = {};
plugins.forEach(function(plugin) {
if (typeof plugin.eventProperties !== "function")
return;
_extends(eventProperties, plugin.eventProperties.call(sortable[plugin.pluginName], name));
});
return eventProperties;
},
modifyOption: function modifyOption(sortable, name, value) {
var modifiedValue;
plugins.forEach(function(plugin) {
if (!sortable[plugin.pluginName])
return;
if (plugin.optionListeners && typeof plugin.optionListeners[name] === "function") {
modifiedValue = plugin.optionListeners[name].call(sortable[plugin.pluginName], value);
}
});
return modifiedValue;
}
};
function dispatchEvent(_ref) {
var sortable = _ref.sortable, rootEl2 = _ref.rootEl, name = _ref.name, targetEl = _ref.targetEl, cloneEl2 = _ref.cloneEl, toEl = _ref.toEl, fromEl = _ref.fromEl, oldIndex2 = _ref.oldIndex, newIndex2 = _ref.newIndex, oldDraggableIndex2 = _ref.oldDraggableIndex, newDraggableIndex2 = _ref.newDraggableIndex, originalEvent = _ref.originalEvent, putSortable2 = _ref.putSortable, extraEventProperties = _ref.extraEventProperties;
sortable = sortable || rootEl2 && rootEl2[expando];
if (!sortable)
return;
var evt, options = sortable.options, onName = "on" + name.charAt(0).toUpperCase() + name.substr(1);
if (window.CustomEvent && !IE11OrLess && !Edge) {
evt = new CustomEvent(name, {
bubbles: true,
cancelable: true
});
} else {
evt = document.createEvent("Event");
evt.initEvent(name, true, true);
}
evt.to = toEl || rootEl2;
evt.from = fromEl || rootEl2;
evt.item = targetEl || rootEl2;
evt.clone = cloneEl2;
evt.oldIndex = oldIndex2;
evt.newIndex = newIndex2;
evt.oldDraggableIndex = oldDraggableIndex2;
evt.newDraggableIndex = newDraggableIndex2;
evt.originalEvent = originalEvent;
evt.pullMode = putSortable2 ? putSortable2.lastPutMode : void 0;
var allEventProperties = _objectSpread({}, extraEventProperties, PluginManager.getEventProperties(name, sortable));
for (var option2 in allEventProperties) {
evt[option2] = allEventProperties[option2];
}
if (rootEl2) {
rootEl2.dispatchEvent(evt);
}
if (options[onName]) {
options[onName].call(sortable, evt);
}
}
var pluginEvent2 = function pluginEvent3(eventName, sortable) {
var _ref = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}, originalEvent = _ref.evt, data = _objectWithoutProperties(_ref, ["evt"]);
PluginManager.pluginEvent.bind(Sortable)(eventName, sortable, _objectSpread({
dragEl,
parentEl,
ghostEl,
rootEl,
nextEl,
lastDownEl,
cloneEl,
cloneHidden,
dragStarted: moved,
putSortable,
activeSortable: Sortable.active,
originalEvent,
oldIndex,
oldDraggableIndex,
newIndex,
newDraggableIndex,
hideGhostForTarget: _hideGhostForTarget,
unhideGhostForTarget: _unhideGhostForTarget,
cloneNowHidden: function cloneNowHidden() {
cloneHidden = true;
},
cloneNowShown: function cloneNowShown() {
cloneHidden = false;
},
dispatchSortableEvent: function dispatchSortableEvent(name) {
_dispatchEvent({
sortable,
name,
originalEvent
});
}
}, data));
};
function _dispatchEvent(info) {
dispatchEvent(_objectSpread({
putSortable,
cloneEl,
targetEl: dragEl,
rootEl,
oldIndex,
oldDraggableIndex,
newIndex,
newDraggableIndex
}, info));
}
var dragEl, parentEl, ghostEl, rootEl, nextEl, lastDownEl, cloneEl, cloneHidden, oldIndex, newIndex, oldDraggableIndex, newDraggableIndex, activeGroup, putSortable, awaitingDragStarted = false, ignoreNextClick = false, sortables = [], tapEvt, touchEvt, lastDx, lastDy, tapDistanceLeft, tapDistanceTop, moved, lastTarget, lastDirection, pastFirstInvertThresh = false, isCircumstantialInvert = false, targetMoveDistance, ghostRelativeParent, ghostRelativeParentInitialScroll = [], _silent = false, savedInputChecked = [];
var documentExists = typeof document !== "undefined", PositionGhostAbsolutely = IOS, CSSFloatProperty = Edge || IE11OrLess ? "cssFloat" : "float", supportDraggable = documentExists && !ChromeForAndroid && !IOS && "draggable" in document.createElement("div"), supportCssPointerEvents = function() {
if (!documentExists)
return;
if (IE11OrLess) {
return false;
}
var el = document.createElement("x");
el.style.cssText = "pointer-events:auto";
return el.style.pointerEvents === "auto";
}(), _detectDirection = function _detectDirection2(el, options) {
var elCSS = css(el), elWidth = parseInt(elCSS.width) - parseInt(elCSS.paddingLeft) - parseInt(elCSS.paddingRight) - parseInt(elCSS.borderLeftWidth) - parseInt(elCSS.borderRightWidth), child1 = getChild(el, 0, options), child22 = getChild(el, 1, options), firstChildCSS = child1 && css(child1), secondChildCSS = child22 && css(child22), firstChildWidth = firstChildCSS && parseInt(firstChildCSS.marginLeft) + parseInt(firstChildCSS.marginRight) + getRect(child1).width, secondChildWidth = secondChildCSS && parseInt(secondChildCSS.marginLeft) + parseInt(secondChildCSS.marginRight) + getRect(child22).width;
if (elCSS.display === "flex") {
return elCSS.flexDirection === "column" || elCSS.flexDirection === "column-reverse" ? "vertical" : "horizontal";
}
if (elCSS.display === "grid") {
return elCSS.gridTemplateColumns.split(" ").length <= 1 ? "vertical" : "horizontal";
}
if (child1 && firstChildCSS["float"] && firstChildCSS["float"] !== "none") {
var touchingSideChild2 = firstChildCSS["float"] === "left" ? "left" : "right";
return child22 && (secondChildCSS.clear === "both" || secondChildCSS.clear === touchingSideChild2) ? "vertical" : "horizontal";
}
return child1 && (firstChildCSS.display === "block" || firstChildCSS.display === "flex" || firstChildCSS.display === "table" || firstChildCSS.display === "grid" || firstChildWidth >= elWidth && elCSS[CSSFloatProperty] === "none" || child22 && elCSS[CSSFloatProperty] === "none" && firstChildWidth + secondChildWidth > elWidth) ? "vertical" : "horizontal";
}, _dragElInRowColumn = function _dragElInRowColumn2(dragRect, targetRect, vertical) {
var dragElS1Opp = vertical ? dragRect.left : dragRect.top, dragElS2Opp = vertical ? dragRect.right : dragRect.bottom, dragElOppLength = vertical ? dragRect.width : dragRect.height, targetS1Opp = vertical ? targetRect.left : targetRect.top, targetS2Opp = vertical ? targetRect.right : targetRect.bottom, targetOppLength = vertical ? targetRect.width : targetRect.height;
return dragElS1Opp === targetS1Opp || dragElS2Opp === targetS2Opp || dragElS1Opp + dragElOppLength / 2 === targetS1Opp + targetOppLength / 2;
}, _detectNearestEmptySortable = function _detectNearestEmptySortable2(x, y) {
var ret;
sortables.some(function(sortable) {
if (lastChild(sortable))
return;
var rect = getRect(sortable), threshold = sortable[expando].options.emptyInsertThreshold, insideHorizontally = x >= rect.left - threshold && x <= rect.right + threshold, insideVertically = y >= rect.top - threshold && y <= rect.bottom + threshold;
if (threshold && insideHorizontally && insideVertically) {
return ret = sortable;
}
});
return ret;
}, _prepareGroup = function _prepareGroup2(options) {
function toFn(value, pull) {
return function(to, from4, dragEl2, evt) {
var sameGroup = to.options.group.name && from4.options.group.name && to.options.group.name === from4.options.group.name;
if (value == null && (pull || sameGroup)) {
return true;
} else if (value == null || value === false) {
return false;
} else if (pull && value === "clone") {
return value;
} else if (typeof value === "function") {
return toFn(value(to, from4, dragEl2, evt), pull)(to, from4, dragEl2, evt);
} else {
var otherGroup = (pull ? to : from4).options.group.name;
return value === true || typeof value === "string" && value === otherGroup || value.join && value.indexOf(otherGroup) > -1;
}
};
}
var group2 = {};
var originalGroup = options.group;
if (!originalGroup || _typeof(originalGroup) != "object") {
originalGroup = {
name: originalGroup
};
}
group2.name = originalGroup.name;
group2.checkPull = toFn(originalGroup.pull, true);
group2.checkPut = toFn(originalGroup.put);
group2.revertClone = originalGroup.revertClone;
options.group = group2;
}, _hideGhostForTarget = function _hideGhostForTarget2() {
if (!supportCssPointerEvents && ghostEl) {
css(ghostEl, "display", "none");
}
}, _unhideGhostForTarget = function _unhideGhostForTarget2() {
if (!supportCssPointerEvents && ghostEl) {
css(ghostEl, "display", "");
}
};
if (documentExists) {
document.addEventListener("click", function(evt) {
if (ignoreNextClick) {
evt.preventDefault();
evt.stopPropagation && evt.stopPropagation();
evt.stopImmediatePropagation && evt.stopImmediatePropagation();
ignoreNextClick = false;
return false;
}
}, true);
}
var nearestEmptyInsertDetectEvent = function nearestEmptyInsertDetectEvent2(evt) {
if (dragEl) {
evt = evt.touches ? evt.touches[0] : evt;
var nearest = _detectNearestEmptySortable(evt.clientX, evt.clientY);
if (nearest) {
var event = {};
for (var i in evt) {
if (evt.hasOwnProperty(i)) {
event[i] = evt[i];
}
}
event.target = event.rootEl = nearest;
event.preventDefault = void 0;
event.stopPropagation = void 0;
nearest[expando]._onDragOver(event);
}
}
};
var _checkOutsideTargetEl = function _checkOutsideTargetEl2(evt) {
if (dragEl) {
dragEl.parentNode[expando]._isOutsideThisEl(evt.target);
}
};
function Sortable(el, options) {
if (!(el && el.nodeType && el.nodeType === 1)) {
throw "Sortable: `el` must be an HTMLElement, not ".concat({}.toString.call(el));
}
this.el = el;
this.options = options = _extends({}, options);
el[expando] = this;
var defaults2 = {
group: null,
sort: true,
disabled: false,
store: null,
handle: null,
draggable: /^[uo]l$/i.test(el.nodeName) ? ">li" : ">*",
swapThreshold: 1,
invertSwap: false,
invertedSwapThreshold: null,
removeCloneOnHide: true,
direction: function direction() {
return _detectDirection(el, this.options);
},
ghostClass: "sortable-ghost",
chosenClass: "sortable-chosen",
dragClass: "sortable-drag",
ignore: "a, img",
filter: null,
preventOnFilter: true,
animation: 0,
easing: null,
setData: function setData(dataTransfer, dragEl2) {
dataTransfer.setData("Text", dragEl2.textContent);
},
dropBubble: false,
dragoverBubble: false,
dataIdAttr: "data-id",
delay: 0,
delayOnTouchOnly: false,
touchStartThreshold: (Number.parseInt ? Number : window).parseInt(window.devicePixelRatio, 10) || 1,
forceFallback: false,
fallbackClass: "sortable-fallback",
fallbackOnBody: false,
fallbackTolerance: 0,
fallbackOffset: {
x: 0,
y: 0
},
supportPointer: Sortable.supportPointer !== false && "PointerEvent" in window && !Safari,
emptyInsertThreshold: 5
};
PluginManager.initializePlugins(this, el, defaults2);
for (var name in defaults2) {
!(name in options) && (options[name] = defaults2[name]);
}
_prepareGroup(options);
for (var fn in this) {
if (fn.charAt(0) === "_" && typeof this[fn] === "function") {
this[fn] = this[fn].bind(this);
}
}
this.nativeDraggable = options.forceFallback ? false : supportDraggable;
if (this.nativeDraggable) {
this.options.touchStartThreshold = 1;
}
if (options.supportPointer) {
on(el, "pointerdown", this._onTapStart);
} else {
on(el, "mousedown", this._onTapStart);
on(el, "touchstart", this._onTapStart);
}
if (this.nativeDraggable) {
on(el, "dragover", this);
on(el, "dragenter", this);
}
sortables.push(this.el);
options.store && options.store.get && this.sort(options.store.get(this) || []);
_extends(this, AnimationStateManager());
}
Sortable.prototype = {
constructor: Sortable,
_isOutsideThisEl: function _isOutsideThisEl(target2) {
if (!this.el.contains(target2) && target2 !== this.el) {
lastTarget = null;
}
},
_getDirection: function _getDirection(evt, target2) {
return typeof this.options.direction === "function" ? this.options.direction.call(this, evt, target2, dragEl) : this.options.direction;
},
_onTapStart: function _onTapStart(evt) {
if (!evt.cancelable)
return;
var _this = this, el = this.el, options = this.options, preventOnFilter = options.preventOnFilter, type = evt.type, touch = evt.touches && evt.touches[0] || evt.pointerType && evt.pointerType === "touch" && evt, target2 = (touch || evt).target, originalTarget = evt.target.shadowRoot && (evt.path && evt.path[0] || evt.composedPath && evt.composedPath()[0]) || target2, filter2 = options.filter;
_saveInputCheckedState(el);
if (dragEl) {
return;
}
if (/mousedown|pointerdown/.test(type) && evt.button !== 0 || options.disabled) {
return;
}
if (originalTarget.isContentEditable) {
return;
}
if (!this.nativeDraggable && Safari && target2 && target2.tagName.toUpperCase() === "SELECT") {
return;
}
target2 = closest(target2, options.draggable, el, false);
if (target2 && target2.animated) {
return;
}
if (lastDownEl === target2) {
return;
}
oldIndex = index2(target2);
oldDraggableIndex = index2(target2, options.draggable);
if (typeof filter2 === "function") {
if (filter2.call(this, evt, target2, this)) {
_dispatchEvent({
sortable: _this,
rootEl: originalTarget,
name: "filter",
targetEl: target2,
toEl: el,
fromEl: el
});
pluginEvent2("filter", _this, {
evt
});
preventOnFilter && evt.cancelable && evt.preventDefault();
return;
}
} else if (filter2) {
filter2 = filter2.split(",").some(function(criteria) {
criteria = closest(originalTarget, criteria.trim(), el, false);
if (criteria) {
_dispatchEvent({
sortable: _this,
rootEl: criteria,
name: "filter",
targetEl: target2,
fromEl: el,
toEl: el
});
pluginEvent2("filter", _this, {
evt
});
return true;
}
});
if (filter2) {
preventOnFilter && evt.cancelable && evt.preventDefault();
return;
}
}
if (options.handle && !closest(originalTarget, options.handle, el, false)) {
return;
}
this._prepareDragStart(evt, touch, target2);
},
_prepareDragStart: function _prepareDragStart(evt, touch, target2) {
var _this = this, el = _this.el, options = _this.options, ownerDocument = el.ownerDocument, dragStartFn;
if (target2 && !dragEl && target2.parentNode === el) {
var dragRect = getRect(target2);
rootEl = el;
dragEl = target2;
parentEl = dragEl.parentNode;
nextEl = dragEl.nextSibling;
lastDownEl = target2;
activeGroup = options.group;
Sortable.dragged = dragEl;
tapEvt = {
target: dragEl,
clientX: (touch || evt).clientX,
clientY: (touch || evt).clientY
};
tapDistanceLeft = tapEvt.clientX - dragRect.left;
tapDistanceTop = tapEvt.clientY - dragRect.top;
this._lastX = (touch || evt).clientX;
this._lastY = (touch || evt).clientY;
dragEl.style["will-change"] = "all";
dragStartFn = function dragStartFn2() {
pluginEvent2("delayEnded", _this, {
evt
});
if (Sortable.eventCanceled) {
_this._onDrop();
return;
}
_this._disableDelayedDragEvents();
if (!FireFox && _this.nativeDraggable) {
dragEl.draggable = true;
}
_this._triggerDragStart(evt, touch);
_dispatchEvent({
sortable: _this,
name: "choose",
originalEvent: evt
});
toggleClass(dragEl, options.chosenClass, true);
};
options.ignore.split(",").forEach(function(criteria) {
find2(dragEl, criteria.trim(), _disableDraggable);
});
on(ownerDocument, "dragover", nearestEmptyInsertDetectEvent);
on(ownerDocument, "mousemove", nearestEmptyInsertDetectEvent);
on(ownerDocument, "touchmove", nearestEmptyInsertDetectEvent);
on(ownerDocument, "mouseup", _this._onDrop);
on(ownerDocument, "touchend", _this._onDrop);
on(ownerDocument, "touchcancel", _this._onDrop);
if (FireFox && this.nativeDraggable) {
this.options.touchStartThreshold = 4;
dragEl.draggable = true;
}
pluginEvent2("delayStart", this, {
evt
});
if (options.delay && (!options.delayOnTouchOnly || touch) && (!this.nativeDraggable || !(Edge || IE11OrLess))) {
if (Sortable.eventCanceled) {
this._onDrop();
return;
}
on(ownerDocument, "mouseup", _this._disableDelayedDrag);
on(ownerDocument, "touchend", _this._disableDelayedDrag);
on(ownerDocument, "touchcancel", _this._disableDelayedDrag);
on(ownerDocument, "mousemove", _this._delayedDragTouchMoveHandler);
on(ownerDocument, "touchmove", _this._delayedDragTouchMoveHandler);
options.supportPointer && on(ownerDocument, "pointermove", _this._delayedDragTouchMoveHandler);
_this._dragStartTimer = setTimeout(dragStartFn, options.delay);
} else {
dragStartFn();
}
}
},
_delayedDragTouchMoveHandler: function _delayedDragTouchMoveHandler(e) {
var touch = e.touches ? e.touches[0] : e;
if (Math.max(Math.abs(touch.clientX - this._lastX), Math.abs(touch.clientY - this._lastY)) >= Math.floor(this.options.touchStartThreshold / (this.nativeDraggable && window.devicePixelRatio || 1))) {
this._disableDelayedDrag();
}
},
_disableDelayedDrag: function _disableDelayedDrag() {
dragEl && _disableDraggable(dragEl);
clearTimeout(this._dragStartTimer);
this._disableDelayedDragEvents();
},
_disableDelayedDragEvents: function _disableDelayedDragEvents() {
var ownerDocument = this.el.ownerDocument;
off(ownerDocument, "mouseup", this._disableDelayedDrag);
off(ownerDocument, "touchend", this._disableDelayedDrag);
off(ownerDocument, "touchcancel", this._disableDelayedDrag);
off(ownerDocument, "mousemove", this._delayedDragTouchMoveHandler);
off(ownerDocument, "touchmove", this._delayedDragTouchMoveHandler);
off(ownerDocument, "pointermove", this._delayedDragTouchMoveHandler);
},
_triggerDragStart: function _triggerDragStart(evt, touch) {
touch = touch || evt.pointerType == "touch" && evt;
if (!this.nativeDraggable || touch) {
if (this.options.supportPointer) {
on(document, "pointermove", this._onTouchMove);
} else if (touch) {
on(document, "touchmove", this._onTouchMove);
} else {
on(document, "mousemove", this._onTouchMove);
}
} else {
on(dragEl, "dragend", this);
on(rootEl, "dragstart", this._onDragStart);
}
try {
if (document.selection) {
_nextTick(function() {
document.selection.empty();
});
} else {
window.getSelection().removeAllRanges();
}
} catch (err2) {
}
},
_dragStarted: function _dragStarted(fallback, evt) {
awaitingDragStarted = false;
if (rootEl && dragEl) {
pluginEvent2("dragStarted", this, {
evt
});
if (this.nativeDraggable) {
on(document, "dragover", _checkOutsideTargetEl);
}
var options = this.options;
!fallback && toggleClass(dragEl, options.dragClass, false);
toggleClass(dragEl, options.ghostClass, true);
Sortable.active = this;
fallback && this._appendGhost();
_dispatchEvent({
sortable: this,
name: "start",
originalEvent: evt
});
} else {
this._nulling();
}
},
_emulateDragOver: function _emulateDragOver() {
if (touchEvt) {
this._lastX = touchEvt.clientX;
this._lastY = touchEvt.clientY;
_hideGhostForTarget();
var target2 = document.elementFromPoint(touchEvt.clientX, touchEvt.clientY);
var parent = target2;
while (target2 && target2.shadowRoot) {
target2 = target2.shadowRoot.elementFromPoint(touchEvt.clientX, touchEvt.clientY);
if (target2 === parent)
break;
parent = target2;
}
dragEl.parentNode[expando]._isOutsideThisEl(target2);
if (parent) {
do {
if (parent[expando]) {
var inserted2 = void 0;
inserted2 = parent[expando]._onDragOver({
clientX: touchEvt.clientX,
clientY: touchEvt.clientY,
target: target2,
rootEl: parent
});
if (inserted2 && !this.options.dragoverBubble) {
break;
}
}
target2 = parent;
} while (parent = parent.parentNode);
}
_unhideGhostForTarget();
}
},
_onTouchMove: function _onTouchMove(evt) {
if (tapEvt) {
var options = this.options, fallbackTolerance = options.fallbackTolerance, fallbackOffset = options.fallbackOffset, touch = evt.touches ? evt.touches[0] : evt, ghostMatrix = ghostEl && matrix(ghostEl, true), scaleX = ghostEl && ghostMatrix && ghostMatrix.a, scaleY = ghostEl && ghostMatrix && ghostMatrix.d, relativeScrollOffset = PositionGhostAbsolutely && ghostRelativeParent && getRelativeScrollOffset(ghostRelativeParent), dx = (touch.clientX - tapEvt.clientX + fallbackOffset.x) / (scaleX || 1) + (relativeScrollOffset ? relativeScrollOffset[0] - ghostRelativeParentInitialScroll[0] : 0) / (scaleX || 1), dy = (touch.clientY - tapEvt.clientY + fallbackOffset.y) / (scaleY || 1) + (relativeScrollOffset ? relativeScrollOffset[1] - ghostRelativeParentInitialScroll[1] : 0) / (scaleY || 1);
if (!Sortable.active && !awaitingDragStarted) {
if (fallbackTolerance && Math.max(Math.abs(touch.clientX - this._lastX), Math.abs(touch.clientY - this._lastY)) < fallbackTolerance) {
return;
}
this._onDragStart(evt, true);
}
if (ghostEl) {
if (ghostMatrix) {
ghostMatrix.e += dx - (lastDx || 0);
ghostMatrix.f += dy - (lastDy || 0);
} else {
ghostMatrix = {
a: 1,
b: 0,
c: 0,
d: 1,
e: dx,
f: dy
};
}
var cssMatrix = "matrix(".concat(ghostMatrix.a, ",").concat(ghostMatrix.b, ",").concat(ghostMatrix.c, ",").concat(ghostMatrix.d, ",").concat(ghostMatrix.e, ",").concat(ghostMatrix.f, ")");
css(ghostEl, "webkitTransform", cssMatrix);
css(ghostEl, "mozTransform", cssMatrix);
css(ghostEl, "msTransform", cssMatrix);
css(ghostEl, "transform", cssMatrix);
lastDx = dx;
lastDy = dy;
touchEvt = touch;
}
evt.cancelable && evt.preventDefault();
}
},
_appendGhost: function _appendGhost() {
if (!ghostEl) {
var container = this.options.fallbackOnBody ? document.body : rootEl, rect = getRect(dragEl, true, PositionGhostAbsolutely, true, container), options = this.options;
if (PositionGhostAbsolutely) {
ghostRelativeParent = container;
while (css(ghostRelativeParent, "position") === "static" && css(ghostRelativeParent, "transform") === "none" && ghostRelativeParent !== document) {
ghostRelativeParent = ghostRelativeParent.parentNode;
}
if (ghostRelativeParent !== document.body && ghostRelativeParent !== document.documentElement) {
if (ghostRelativeParent === document)
ghostRelativeParent = getWindowScrollingElement();
rect.top += ghostRelativeParent.scrollTop;
rect.left += ghostRelativeParent.scrollLeft;
} else {
ghostRelativeParent = getWindowScrollingElement();
}
ghostRelativeParentInitialScroll = getRelativeScrollOffset(ghostRelativeParent);
}
ghostEl = dragEl.cloneNode(true);
toggleClass(ghostEl, options.ghostClass, false);
toggleClass(ghostEl, options.fallbackClass, true);
toggleClass(ghostEl, options.dragClass, true);
css(ghostEl, "transition", "");
css(ghostEl, "transform", "");
css(ghostEl, "box-sizing", "border-box");
css(ghostEl, "margin", 0);
css(ghostEl, "top", rect.top);
css(ghostEl, "left", rect.left);
css(ghostEl, "width", rect.width);
css(ghostEl, "height", rect.height);
css(ghostEl, "opacity", "0.8");
css(ghostEl, "position", PositionGhostAbsolutely ? "absolute" : "fixed");
css(ghostEl, "zIndex", "100000");
css(ghostEl, "pointerEvents", "none");
Sortable.ghost = ghostEl;
container.appendChild(ghostEl);
css(ghostEl, "transform-origin", tapDistanceLeft / parseInt(ghostEl.style.width) * 100 + "% " + tapDistanceTop / parseInt(ghostEl.style.height) * 100 + "%");
}
},
_onDragStart: function _onDragStart(evt, fallback) {
var _this = this;
var dataTransfer = evt.dataTransfer;
var options = _this.options;
pluginEvent2("dragStart", this, {
evt
});
if (Sortable.eventCanceled) {
this._onDrop();
return;
}
pluginEvent2("setupClone", this);
if (!Sortable.eventCanceled) {
cloneEl = clone(dragEl);
cloneEl.draggable = false;
cloneEl.style["will-change"] = "";
this._hideClone();
toggleClass(cloneEl, this.options.chosenClass, false);
Sortable.clone = cloneEl;
}
_this.cloneId = _nextTick(function() {
pluginEvent2("clone", _this);
if (Sortable.eventCanceled)
return;
if (!_this.options.removeCloneOnHide) {
rootEl.insertBefore(cloneEl, dragEl);
}
_this._hideClone();
_dispatchEvent({
sortable: _this,
name: "clone"
});
});
!fallback && toggleClass(dragEl, options.dragClass, true);
if (fallback) {
ignoreNextClick = true;
_this._loopId = setInterval(_this._emulateDragOver, 50);
} else {
off(document, "mouseup", _this._onDrop);
off(document, "touchend", _this._onDrop);
off(document, "touchcancel", _this._onDrop);
if (dataTransfer) {
dataTransfer.effectAllowed = "move";
options.setData && options.setData.call(_this, dataTransfer, dragEl);
}
on(document, "drop", _this);
css(dragEl, "transform", "translateZ(0)");
}
awaitingDragStarted = true;
_this._dragStartId = _nextTick(_this._dragStarted.bind(_this, fallback, evt));
on(document, "selectstart", _this);
moved = true;
if (Safari) {
css(document.body, "user-select", "none");
}
},
_onDragOver: function _onDragOver(evt) {
var el = this.el, target2 = evt.target, dragRect, targetRect, revert, options = this.options, group2 = options.group, activeSortable = Sortable.active, isOwner = activeGroup === group2, canSort = options.sort, fromSortable = putSortable || activeSortable, vertical, _this = this, completedFired = false;
if (_silent)
return;
function dragOverEvent(name, extra) {
pluginEvent2(name, _this, _objectSpread({
evt,
isOwner,
axis: vertical ? "vertical" : "horizontal",
revert,
dragRect,
targetRect,
canSort,
fromSortable,
target: target2,
completed,
onMove: function onMove(target3, after4) {
return _onMove(rootEl, el, dragEl, dragRect, target3, getRect(target3), evt, after4);
},
changed
}, extra));
}
function capture() {
dragOverEvent("dragOverAnimationCapture");
_this.captureAnimationState();
if (_this !== fromSortable) {
fromSortable.captureAnimationState();
}
}
function completed(insertion) {
dragOverEvent("dragOverCompleted", {
insertion
});
if (insertion) {
if (isOwner) {
activeSortable._hideClone();
} else {
activeSortable._showClone(_this);
}
if (_this !== fromSortable) {
toggleClass(dragEl, putSortable ? putSortable.options.ghostClass : activeSortable.options.ghostClass, false);
toggleClass(dragEl, options.ghostClass, true);
}
if (putSortable !== _this && _this !== Sortable.active) {
putSortable = _this;
} else if (_this === Sortable.active && putSortable) {
putSortable = null;
}
if (fromSortable === _this) {
_this._ignoreWhileAnimating = target2;
}
_this.animateAll(function() {
dragOverEvent("dragOverAnimationComplete");
_this._ignoreWhileAnimating = null;
});
if (_this !== fromSortable) {
fromSortable.animateAll();
fromSortable._ignoreWhileAnimating = null;
}
}
if (target2 === dragEl && !dragEl.animated || target2 === el && !target2.animated) {
lastTarget = null;
}
if (!options.dragoverBubble && !evt.rootEl && target2 !== document) {
dragEl.parentNode[expando]._isOutsideThisEl(evt.target);
!insertion && nearestEmptyInsertDetectEvent(evt);
}
!options.dragoverBubble && evt.stopPropagation && evt.stopPropagation();
return completedFired = true;
}
function changed() {
newIndex = index2(dragEl);
newDraggableIndex = index2(dragEl, options.draggable);
_dispatchEvent({
sortable: _this,
name: "change",
toEl: el,
newIndex,
newDraggableIndex,
originalEvent: evt
});
}
if (evt.preventDefault !== void 0) {
evt.cancelable && evt.preventDefault();
}
target2 = closest(target2, options.draggable, el, true);
dragOverEvent("dragOver");
if (Sortable.eventCanceled)
return completedFired;
if (dragEl.contains(evt.target) || target2.animated && target2.animatingX && target2.animatingY || _this._ignoreWhileAnimating === target2) {
return completed(false);
}
ignoreNextClick = false;
if (activeSortable && !options.disabled && (isOwner ? canSort || (revert = !rootEl.contains(dragEl)) : putSortable === this || (this.lastPutMode = activeGroup.checkPull(this, activeSortable, dragEl, evt)) && group2.checkPut(this, activeSortable, dragEl, evt))) {
vertical = this._getDirection(evt, target2) === "vertical";
dragRect = getRect(dragEl);
dragOverEvent("dragOverValid");
if (Sortable.eventCanceled)
return completedFired;
if (revert) {
parentEl = rootEl;
capture();
this._hideClone();
dragOverEvent("revert");
if (!Sortable.eventCanceled) {
if (nextEl) {
rootEl.insertBefore(dragEl, nextEl);
} else {
rootEl.appendChild(dragEl);
}
}
return completed(true);
}
var elLastChild = lastChild(el, options.draggable);
if (!elLastChild || _ghostIsLast(evt, vertical, this) && !elLastChild.animated) {
if (elLastChild === dragEl) {
return completed(false);
}
if (elLastChild && el === evt.target) {
target2 = elLastChild;
}
if (target2) {
targetRect = getRect(target2);
}
if (_onMove(rootEl, el, dragEl, dragRect, target2, targetRect, evt, !!target2) !== false) {
capture();
el.appendChild(dragEl);
parentEl = el;
changed();
return completed(true);
}
} else if (target2.parentNode === el) {
targetRect = getRect(target2);
var direction = 0, targetBeforeFirstSwap, differentLevel = dragEl.parentNode !== el, differentRowCol = !_dragElInRowColumn(dragEl.animated && dragEl.toRect || dragRect, target2.animated && target2.toRect || targetRect, vertical), side1 = vertical ? "top" : "left", scrolledPastTop = isScrolledPast(target2, "top", "top") || isScrolledPast(dragEl, "top", "top"), scrollBefore = scrolledPastTop ? scrolledPastTop.scrollTop : void 0;
if (lastTarget !== target2) {
targetBeforeFirstSwap = targetRect[side1];
pastFirstInvertThresh = false;
isCircumstantialInvert = !differentRowCol && options.invertSwap || differentLevel;
}
direction = _getSwapDirection(evt, target2, targetRect, vertical, differentRowCol ? 1 : options.swapThreshold, options.invertedSwapThreshold == null ? options.swapThreshold : options.invertedSwapThreshold, isCircumstantialInvert, lastTarget === target2);
var sibling;
if (direction !== 0) {
var dragIndex = index2(dragEl);
do {
dragIndex -= direction;
sibling = parentEl.children[dragIndex];
} while (sibling && (css(sibling, "display") === "none" || sibling === ghostEl));
}
if (direction === 0 || sibling === target2) {
return completed(false);
}
lastTarget = target2;
lastDirection = direction;
var nextSibling2 = target2.nextElementSibling, after3 = false;
after3 = direction === 1;
var moveVector = _onMove(rootEl, el, dragEl, dragRect, target2, targetRect, evt, after3);
if (moveVector !== false) {
if (moveVector === 1 || moveVector === -1) {
after3 = moveVector === 1;
}
_silent = true;
setTimeout(_unsilent, 30);
capture();
if (after3 && !nextSibling2) {
el.appendChild(dragEl);
} else {
target2.parentNode.insertBefore(dragEl, after3 ? nextSibling2 : target2);
}
if (scrolledPastTop) {
scrollBy(scrolledPastTop, 0, scrollBefore - scrolledPastTop.scrollTop);
}
parentEl = dragEl.parentNode;
if (targetBeforeFirstSwap !== void 0 && !isCircumstantialInvert) {
targetMoveDistance = Math.abs(targetBeforeFirstSwap - getRect(target2)[side1]);
}
changed();
return completed(true);
}
}
if (el.contains(dragEl)) {
return completed(false);
}
}
return false;
},
_ignoreWhileAnimating: null,
_offMoveEvents: function _offMoveEvents() {
off(document, "mousemove", this._onTouchMove);
off(document, "touchmove", this._onTouchMove);
off(document, "pointermove", this._onTouchMove);
off(document, "dragover", nearestEmptyInsertDetectEvent);
off(document, "mousemove", nearestEmptyInsertDetectEvent);
off(document, "touchmove", nearestEmptyInsertDetectEvent);
},
_offUpEvents: function _offUpEvents() {
var ownerDocument = this.el.ownerDocument;
off(ownerDocument, "mouseup", this._onDrop);
off(ownerDocument, "touchend", this._onDrop);
off(ownerDocument, "pointerup", this._onDrop);
off(ownerDocument, "touchcancel", this._onDrop);
off(document, "selectstart", this);
},
_onDrop: function _onDrop(evt) {
var el = this.el, options = this.options;
newIndex = index2(dragEl);
newDraggableIndex = index2(dragEl, options.draggable);
pluginEvent2("drop", this, {
evt
});
parentEl = dragEl && dragEl.parentNode;
newIndex = index2(dragEl);
newDraggableIndex = index2(dragEl, options.draggable);
if (Sortable.eventCanceled) {
this._nulling();
return;
}
awaitingDragStarted = false;
isCircumstantialInvert = false;
pastFirstInvertThresh = false;
clearInterval(this._loopId);
clearTimeout(this._dragStartTimer);
_cancelNextTick(this.cloneId);
_cancelNextTick(this._dragStartId);
if (this.nativeDraggable) {
off(document, "drop", this);
off(el, "dragstart", this._onDragStart);
}
this._offMoveEvents();
this._offUpEvents();
if (Safari) {
css(document.body, "user-select", "");
}
css(dragEl, "transform", "");
if (evt) {
if (moved) {
evt.cancelable && evt.preventDefault();
!options.dropBubble && evt.stopPropagation();
}
ghostEl && ghostEl.parentNode && ghostEl.parentNode.removeChild(ghostEl);
if (rootEl === parentEl || putSortable && putSortable.lastPutMode !== "clone") {
cloneEl && cloneEl.parentNode && cloneEl.parentNode.removeChild(cloneEl);
}
if (dragEl) {
if (this.nativeDraggable) {
off(dragEl, "dragend", this);
}
_disableDraggable(dragEl);
dragEl.style["will-change"] = "";
if (moved && !awaitingDragStarted) {
toggleClass(dragEl, putSortable ? putSortable.options.ghostClass : this.options.ghostClass, false);
}
toggleClass(dragEl, this.options.chosenClass, false);
_dispatchEvent({
sortable: this,
name: "unchoose",
toEl: parentEl,
newIndex: null,
newDraggableIndex: null,
originalEvent: evt
});
if (rootEl !== parentEl) {
if (newIndex >= 0) {
_dispatchEvent({
rootEl: parentEl,
name: "add",
toEl: parentEl,
fromEl: rootEl,
originalEvent: evt
});
_dispatchEvent({
sortable: this,
name: "remove",
toEl: parentEl,
originalEvent: evt
});
_dispatchEvent({
rootEl: parentEl,
name: "sort",
toEl: parentEl,
fromEl: rootEl,
originalEvent: evt
});
_dispatchEvent({
sortable: this,
name: "sort",
toEl: parentEl,
originalEvent: evt
});
}
putSortable && putSortable.save();
} else {
if (newIndex !== oldIndex) {
if (newIndex >= 0) {
_dispatchEvent({
sortable: this,
name: "update",
toEl: parentEl,
originalEvent: evt
});
_dispatchEvent({
sortable: this,
name: "sort",
toEl: parentEl,
originalEvent: evt
});
}
}
}
if (Sortable.active) {
if (newIndex == null || newIndex === -1) {
newIndex = oldIndex;
newDraggableIndex = oldDraggableIndex;
}
_dispatchEvent({
sortable: this,
name: "end",
toEl: parentEl,
originalEvent: evt
});
this.save();
}
}
}
this._nulling();
},
_nulling: function _nulling() {
pluginEvent2("nulling", this);
rootEl = dragEl = parentEl = ghostEl = nextEl = cloneEl = lastDownEl = cloneHidden = tapEvt = touchEvt = moved = newIndex = newDraggableIndex = oldIndex = oldDraggableIndex = lastTarget = lastDirection = putSortable = activeGroup = Sortable.dragged = Sortable.ghost = Sortable.clone = Sortable.active = null;
savedInputChecked.forEach(function(el) {
el.checked = true;
});
savedInputChecked.length = lastDx = lastDy = 0;
},
handleEvent: function handleEvent(evt) {
switch (evt.type) {
case "drop":
case "dragend":
this._onDrop(evt);
break;
case "dragenter":
case "dragover":
if (dragEl) {
this._onDragOver(evt);
_globalDragOver(evt);
}
break;
case "selectstart":
evt.preventDefault();
break;
}
},
toArray: function toArray2() {
var order = [], el, children = this.el.children, i = 0, n = children.length, options = this.options;
for (; i < n; i++) {
el = children[i];
if (closest(el, options.draggable, this.el, false)) {
order.push(el.getAttribute(options.dataIdAttr) || _generateId(el));
}
}
return order;
},
sort: function sort(order, useAnimation) {
var items = {}, rootEl2 = this.el;
this.toArray().forEach(function(id, i) {
var el = rootEl2.children[i];
if (closest(el, this.options.draggable, rootEl2, false)) {
items[id] = el;
}
}, this);
useAnimation && this.captureAnimationState();
order.forEach(function(id) {
if (items[id]) {
rootEl2.removeChild(items[id]);
rootEl2.appendChild(items[id]);
}
});
useAnimation && this.animateAll();
},
save: function save() {
var store = this.options.store;
store && store.set && store.set(this);
},
closest: function closest$1(el, selector) {
return closest(el, selector || this.options.draggable, this.el, false);
},
option: function option(name, value) {
var options = this.options;
if (value === void 0) {
return options[name];
} else {
var modifiedValue = PluginManager.modifyOption(this, name, value);
if (typeof modifiedValue !== "undefined") {
options[name] = modifiedValue;
} else {
options[name] = value;
}
if (name === "group") {
_prepareGroup(options);
}
}
},
destroy: function destroy6() {
pluginEvent2("destroy", this);
var el = this.el;
el[expando] = null;
off(el, "mousedown", this._onTapStart);
off(el, "touchstart", this._onTapStart);
off(el, "pointerdown", this._onTapStart);
if (this.nativeDraggable) {
off(el, "dragover", this);
off(el, "dragenter", this);
}
Array.prototype.forEach.call(el.querySelectorAll("[draggable]"), function(el2) {
el2.removeAttribute("draggable");
});
this._onDrop();
this._disableDelayedDragEvents();
sortables.splice(sortables.indexOf(this.el), 1);
this.el = el = null;
},
_hideClone: function _hideClone() {
if (!cloneHidden) {
pluginEvent2("hideClone", this);
if (Sortable.eventCanceled)
return;
css(cloneEl, "display", "none");
if (this.options.removeCloneOnHide && cloneEl.parentNode) {
cloneEl.parentNode.removeChild(cloneEl);
}
cloneHidden = true;
}
},
_showClone: function _showClone(putSortable2) {
if (putSortable2.lastPutMode !== "clone") {
this._hideClone();
return;
}
if (cloneHidden) {
pluginEvent2("showClone", this);
if (Sortable.eventCanceled)
return;
if (dragEl.parentNode == rootEl && !this.options.group.revertClone) {
rootEl.insertBefore(cloneEl, dragEl);
} else if (nextEl) {
rootEl.insertBefore(cloneEl, nextEl);
} else {
rootEl.appendChild(cloneEl);
}
if (this.options.group.revertClone) {
this.animate(dragEl, cloneEl);
}
css(cloneEl, "display", "");
cloneHidden = false;
}
}
};
function _globalDragOver(evt) {
if (evt.dataTransfer) {
evt.dataTransfer.dropEffect = "move";
}
evt.cancelable && evt.preventDefault();
}
function _onMove(fromEl, toEl, dragEl2, dragRect, targetEl, targetRect, originalEvent, willInsertAfter) {
var evt, sortable = fromEl[expando], onMoveFn = sortable.options.onMove, retVal;
if (window.CustomEvent && !IE11OrLess && !Edge) {
evt = new CustomEvent("move", {
bubbles: true,
cancelable: true
});
} else {
evt = document.createEvent("Event");
evt.initEvent("move", true, true);
}
evt.to = toEl;
evt.from = fromEl;
evt.dragged = dragEl2;
evt.draggedRect = dragRect;
evt.related = targetEl || toEl;
evt.relatedRect = targetRect || getRect(toEl);
evt.willInsertAfter = willInsertAfter;
evt.originalEvent = originalEvent;
fromEl.dispatchEvent(evt);
if (onMoveFn) {
retVal = onMoveFn.call(sortable, evt, originalEvent);
}
return retVal;
}
function _disableDraggable(el) {
el.draggable = false;
}
function _unsilent() {
_silent = false;
}
function _ghostIsLast(evt, vertical, sortable) {
var rect = getRect(lastChild(sortable.el, sortable.options.draggable));
var spacer = 10;
return vertical ? evt.clientX > rect.right + spacer || evt.clientX <= rect.right && evt.clientY > rect.bottom && evt.clientX >= rect.left : evt.clientX > rect.right && evt.clientY > rect.top || evt.clientX <= rect.right && evt.clientY > rect.bottom + spacer;
}
function _getSwapDirection(evt, target2, targetRect, vertical, swapThreshold, invertedSwapThreshold, invertSwap, isLastTarget) {
var mouseOnAxis = vertical ? evt.clientY : evt.clientX, targetLength = vertical ? targetRect.height : targetRect.width, targetS1 = vertical ? targetRect.top : targetRect.left, targetS2 = vertical ? targetRect.bottom : targetRect.right, invert5 = false;
if (!invertSwap) {
if (isLastTarget && targetMoveDistance < targetLength * swapThreshold) {
if (!pastFirstInvertThresh && (lastDirection === 1 ? mouseOnAxis > targetS1 + targetLength * invertedSwapThreshold / 2 : mouseOnAxis < targetS2 - targetLength * invertedSwapThreshold / 2)) {
pastFirstInvertThresh = true;
}
if (!pastFirstInvertThresh) {
if (lastDirection === 1 ? mouseOnAxis < targetS1 + targetMoveDistance : mouseOnAxis > targetS2 - targetMoveDistance) {
return -lastDirection;
}
} else {
invert5 = true;
}
} else {
if (mouseOnAxis > targetS1 + targetLength * (1 - swapThreshold) / 2 && mouseOnAxis < targetS2 - targetLength * (1 - swapThreshold) / 2) {
return _getInsertDirection(target2);
}
}
}
invert5 = invert5 || invertSwap;
if (invert5) {
if (mouseOnAxis < targetS1 + targetLength * invertedSwapThreshold / 2 || mouseOnAxis > targetS2 - targetLength * invertedSwapThreshold / 2) {
return mouseOnAxis > targetS1 + targetLength / 2 ? 1 : -1;
}
}
return 0;
}
function _getInsertDirection(target2) {
if (index2(dragEl) < index2(target2)) {
return 1;
} else {
return -1;
}
}
function _generateId(el) {
var str2 = el.tagName + el.className + el.src + el.href + el.textContent, i = str2.length, sum = 0;
while (i--) {
sum += str2.charCodeAt(i);
}
return sum.toString(36);
}
function _saveInputCheckedState(root2) {
savedInputChecked.length = 0;
var inputs = root2.getElementsByTagName("input");
var idx = inputs.length;
while (idx--) {
var el = inputs[idx];
el.checked && savedInputChecked.push(el);
}
}
function _nextTick(fn) {
return setTimeout(fn, 0);
}
function _cancelNextTick(id) {
return clearTimeout(id);
}
if (documentExists) {
on(document, "touchmove", function(evt) {
if ((Sortable.active || awaitingDragStarted) && evt.cancelable) {
evt.preventDefault();
}
});
}
Sortable.utils = {
on,
off,
css,
find: find2,
is: function is2(el, selector) {
return !!closest(el, selector, el, false);
},
extend,
throttle,
closest,
toggleClass,
clone,
index: index2,
nextTick: _nextTick,
cancelNextTick: _cancelNextTick,
detectDirection: _detectDirection,
getChild
};
Sortable.get = function(element) {
return element[expando];
};
Sortable.mount = function() {
for (var _len = arguments.length, plugins2 = new Array(_len), _key2 = 0; _key2 < _len; _key2++) {
plugins2[_key2] = arguments[_key2];
}
if (plugins2[0].constructor === Array)
plugins2 = plugins2[0];
plugins2.forEach(function(plugin) {
if (!plugin.prototype || !plugin.prototype.constructor) {
throw "Sortable: Mounted plugin must be a constructor function, not ".concat({}.toString.call(plugin));
}
if (plugin.utils)
Sortable.utils = _objectSpread({}, Sortable.utils, plugin.utils);
PluginManager.mount(plugin);
});
};
Sortable.create = function(el, options) {
return new Sortable(el, options);
};
Sortable.version = version;
var autoScrolls = [], scrollEl, scrollRootEl, scrolling = false, lastAutoScrollX, lastAutoScrollY, touchEvt$1, pointerElemChangedInterval;
function AutoScrollPlugin() {
function AutoScroll() {
this.defaults = {
scroll: true,
scrollSensitivity: 30,
scrollSpeed: 10,
bubbleScroll: true
};
for (var fn in this) {
if (fn.charAt(0) === "_" && typeof this[fn] === "function") {
this[fn] = this[fn].bind(this);
}
}
}
AutoScroll.prototype = {
dragStarted: function dragStarted(_ref) {
var originalEvent = _ref.originalEvent;
if (this.sortable.nativeDraggable) {
on(document, "dragover", this._handleAutoScroll);
} else {
if (this.options.supportPointer) {
on(document, "pointermove", this._handleFallbackAutoScroll);
} else if (originalEvent.touches) {
on(document, "touchmove", this._handleFallbackAutoScroll);
} else {
on(document, "mousemove", this._handleFallbackAutoScroll);
}
}
},
dragOverCompleted: function dragOverCompleted(_ref2) {
var originalEvent = _ref2.originalEvent;
if (!this.options.dragOverBubble && !originalEvent.rootEl) {
this._handleAutoScroll(originalEvent);
}
},
drop: function drop4() {
if (this.sortable.nativeDraggable) {
off(document, "dragover", this._handleAutoScroll);
} else {
off(document, "pointermove", this._handleFallbackAutoScroll);
off(document, "touchmove", this._handleFallbackAutoScroll);
off(document, "mousemove", this._handleFallbackAutoScroll);
}
clearPointerElemChangedInterval();
clearAutoScrolls();
cancelThrottle();
},
nulling: function nulling() {
touchEvt$1 = scrollRootEl = scrollEl = scrolling = pointerElemChangedInterval = lastAutoScrollX = lastAutoScrollY = null;
autoScrolls.length = 0;
},
_handleFallbackAutoScroll: function _handleFallbackAutoScroll(evt) {
this._handleAutoScroll(evt, true);
},
_handleAutoScroll: function _handleAutoScroll(evt, fallback) {
var _this = this;
var x = (evt.touches ? evt.touches[0] : evt).clientX, y = (evt.touches ? evt.touches[0] : evt).clientY, elem = document.elementFromPoint(x, y);
touchEvt$1 = evt;
if (fallback || Edge || IE11OrLess || Safari) {
autoScroll(evt, this.options, elem, fallback);
var ogElemScroller = getParentAutoScrollElement(elem, true);
if (scrolling && (!pointerElemChangedInterval || x !== lastAutoScrollX || y !== lastAutoScrollY)) {
pointerElemChangedInterval && clearPointerElemChangedInterval();
pointerElemChangedInterval = setInterval(function() {
var newElem = getParentAutoScrollElement(document.elementFromPoint(x, y), true);
if (newElem !== ogElemScroller) {
ogElemScroller = newElem;
clearAutoScrolls();
}
autoScroll(evt, _this.options, newElem, fallback);
}, 10);
lastAutoScrollX = x;
lastAutoScrollY = y;
}
} else {
if (!this.options.bubbleScroll || getParentAutoScrollElement(elem, true) === getWindowScrollingElement()) {
clearAutoScrolls();
return;
}
autoScroll(evt, this.options, getParentAutoScrollElement(elem, false), false);
}
}
};
return _extends(AutoScroll, {
pluginName: "scroll",
initializeByDefault: true
});
}
function clearAutoScrolls() {
autoScrolls.forEach(function(autoScroll2) {
clearInterval(autoScroll2.pid);
});
autoScrolls = [];
}
function clearPointerElemChangedInterval() {
clearInterval(pointerElemChangedInterval);
}
var autoScroll = throttle(function(evt, options, rootEl2, isFallback) {
if (!options.scroll)
return;
var x = (evt.touches ? evt.touches[0] : evt).clientX, y = (evt.touches ? evt.touches[0] : evt).clientY, sens = options.scrollSensitivity, speed = options.scrollSpeed, winScroller = getWindowScrollingElement();
var scrollThisInstance = false, scrollCustomFn;
if (scrollRootEl !== rootEl2) {
scrollRootEl = rootEl2;
clearAutoScrolls();
scrollEl = options.scroll;
scrollCustomFn = options.scrollFn;
if (scrollEl === true) {
scrollEl = getParentAutoScrollElement(rootEl2, true);
}
}
var layersOut = 0;
var currentParent = scrollEl;
do {
var el = currentParent, rect = getRect(el), top = rect.top, bottom = rect.bottom, left = rect.left, right = rect.right, width = rect.width, height = rect.height, canScrollX = void 0, canScrollY = void 0, scrollWidth = el.scrollWidth, scrollHeight = el.scrollHeight, elCSS = css(el), scrollPosX = el.scrollLeft, scrollPosY = el.scrollTop;
if (el === winScroller) {
canScrollX = width < scrollWidth && (elCSS.overflowX === "auto" || elCSS.overflowX === "scroll" || elCSS.overflowX === "visible");
canScrollY = height < scrollHeight && (elCSS.overflowY === "auto" || elCSS.overflowY === "scroll" || elCSS.overflowY === "visible");
} else {
canScrollX = width < scrollWidth && (elCSS.overflowX === "auto" || elCSS.overflowX === "scroll");
canScrollY = height < scrollHeight && (elCSS.overflowY === "auto" || elCSS.overflowY === "scroll");
}
var vx = canScrollX && (Math.abs(right - x) <= sens && scrollPosX + width < scrollWidth) - (Math.abs(left - x) <= sens && !!scrollPosX);
var vy = canScrollY && (Math.abs(bottom - y) <= sens && scrollPosY + height < scrollHeight) - (Math.abs(top - y) <= sens && !!scrollPosY);
if (!autoScrolls[layersOut]) {
for (var i = 0; i <= layersOut; i++) {
if (!autoScrolls[i]) {
autoScrolls[i] = {};
}
}
}
if (autoScrolls[layersOut].vx != vx || autoScrolls[layersOut].vy != vy || autoScrolls[layersOut].el !== el) {
autoScrolls[layersOut].el = el;
autoScrolls[layersOut].vx = vx;
autoScrolls[layersOut].vy = vy;
clearInterval(autoScrolls[layersOut].pid);
if (vx != 0 || vy != 0) {
scrollThisInstance = true;
autoScrolls[layersOut].pid = setInterval(function() {
if (isFallback && this.layer === 0) {
Sortable.active._onTouchMove(touchEvt$1);
}
var scrollOffsetY = autoScrolls[this.layer].vy ? autoScrolls[this.layer].vy * speed : 0;
var scrollOffsetX = autoScrolls[this.layer].vx ? autoScrolls[this.layer].vx * speed : 0;
if (typeof scrollCustomFn === "function") {
if (scrollCustomFn.call(Sortable.dragged.parentNode[expando], scrollOffsetX, scrollOffsetY, evt, touchEvt$1, autoScrolls[this.layer].el) !== "continue") {
return;
}
}
scrollBy(autoScrolls[this.layer].el, scrollOffsetX, scrollOffsetY);
}.bind({
layer: layersOut
}), 24);
}
}
layersOut++;
} while (options.bubbleScroll && currentParent !== winScroller && (currentParent = getParentAutoScrollElement(currentParent, false)));
scrolling = scrollThisInstance;
}, 30);
var drop2 = function drop3(_ref) {
var originalEvent = _ref.originalEvent, putSortable2 = _ref.putSortable, dragEl2 = _ref.dragEl, activeSortable = _ref.activeSortable, dispatchSortableEvent = _ref.dispatchSortableEvent, hideGhostForTarget = _ref.hideGhostForTarget, unhideGhostForTarget = _ref.unhideGhostForTarget;
if (!originalEvent)
return;
var toSortable = putSortable2 || activeSortable;
hideGhostForTarget();
var touch = originalEvent.changedTouches && originalEvent.changedTouches.length ? originalEvent.changedTouches[0] : originalEvent;
var target2 = document.elementFromPoint(touch.clientX, touch.clientY);
unhideGhostForTarget();
if (toSortable && !toSortable.el.contains(target2)) {
dispatchSortableEvent("spill");
this.onSpill({
dragEl: dragEl2,
putSortable: putSortable2
});
}
};
function Revert() {
}
Revert.prototype = {
startIndex: null,
dragStart: function dragStart(_ref2) {
var oldDraggableIndex2 = _ref2.oldDraggableIndex;
this.startIndex = oldDraggableIndex2;
},
onSpill: function onSpill(_ref3) {
var dragEl2 = _ref3.dragEl, putSortable2 = _ref3.putSortable;
this.sortable.captureAnimationState();
if (putSortable2) {
putSortable2.captureAnimationState();
}
var nextSibling2 = getChild(this.sortable.el, this.startIndex, this.options);
if (nextSibling2) {
this.sortable.el.insertBefore(dragEl2, nextSibling2);
} else {
this.sortable.el.appendChild(dragEl2);
}
this.sortable.animateAll();
if (putSortable2) {
putSortable2.animateAll();
}
},
drop: drop2
};
_extends(Revert, {
pluginName: "revertOnSpill"
});
function Remove() {
}
Remove.prototype = {
onSpill: function onSpill2(_ref4) {
var dragEl2 = _ref4.dragEl, putSortable2 = _ref4.putSortable;
var parentSortable = putSortable2 || this.sortable;
parentSortable.captureAnimationState();
dragEl2.parentNode && dragEl2.parentNode.removeChild(dragEl2);
parentSortable.animateAll();
},
drop: drop2
};
_extends(Remove, {
pluginName: "removeOnSpill"
});
Sortable.mount(new AutoScrollPlugin());
Sortable.mount(Remove, Revert);
export {Sortable as A, Bold as B, Code as C, Doc as D, Extension as E, reduce as F, History2 as H, Italic as I, Link as L, OrderedList as O, Plugin as P, Strike as S, Underline as U, Vue as V, axios as a, each as b, find$1 as c, dayjs as d, extend$1 as e, filter as f, isEmpty as g, debounce$1 as h, isArray$4 as i, clone$1 as j, VueRouter as k, groupBy as l, max as m, map as n, PluginKey as o, HardBreak as p, ListItem as q, BulletList as r, HorizontalRule as s, Heading as t, EditorContent as u, EditorMenuBubble as v, Placeholder as w, Editor as x, flatpickr as y, O__zero_zero_Web_UI_node_modules_qs_lib as z};