nodes/packages/ui/.histoire/dist/assets/vendor-BCKkA27H.js
Max Richter 4db1cc7d4f
All checks were successful
Deploy to GitHub Pages / build_site (push) Successful in 2m21s
feat: add path_geometry data
2024-04-24 19:11:00 +02:00

40965 lines
1.3 MiB
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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

var __defProp2 = Object.defineProperty;
var __defNormalProp2 = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __publicField = (obj, key, value) => {
__defNormalProp2(obj, typeof key !== "symbol" ? key + "" : key, value);
return value;
};
function makeMap(str, expectsLowerCase) {
const map2 = /* @__PURE__ */ Object.create(null);
const list = str.split(",");
for (let i2 = 0; i2 < list.length; i2++) {
map2[list[i2]] = true;
}
return expectsLowerCase ? (val) => !!map2[val.toLowerCase()] : (val) => !!map2[val];
}
const EMPTY_OBJ = Object.freeze({});
const EMPTY_ARR = Object.freeze([]);
const NOOP = () => {
};
const NO = () => false;
const onRE = /^on[^a-z]/;
const isOn = (key) => onRE.test(key);
const isModelListener = (key) => key.startsWith("onUpdate:");
const extend = Object.assign;
const remove = (arr, el2) => {
const i2 = arr.indexOf(el2);
if (i2 > -1) {
arr.splice(i2, 1);
}
};
const hasOwnProperty$1 = Object.prototype.hasOwnProperty;
const hasOwn = (val, key) => hasOwnProperty$1.call(val, key);
const isArray$1 = Array.isArray;
const isMap = (val) => toTypeString(val) === "[object Map]";
const isSet = (val) => toTypeString(val) === "[object Set]";
const isFunction$1 = (val) => typeof val === "function";
const isString$1 = (val) => typeof val === "string";
const isSymbol = (val) => typeof val === "symbol";
const isObject = (val) => val !== null && typeof val === "object";
const isPromise = (val) => {
return (isObject(val) || isFunction$1(val)) && isFunction$1(val.then) && isFunction$1(val.catch);
};
const objectToString = Object.prototype.toString;
const toTypeString = (value) => objectToString.call(value);
const toRawType = (value) => {
return toTypeString(value).slice(8, -1);
};
const isPlainObject$1 = (val) => toTypeString(val) === "[object Object]";
const isIntegerKey = (key) => isString$1(key) && key !== "NaN" && key[0] !== "-" && "" + parseInt(key, 10) === key;
const isReservedProp = /* @__PURE__ */ makeMap(
// the leading comma is intentional so empty string "" is also included
",key,ref,ref_for,ref_key,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted"
);
const isBuiltInDirective = /* @__PURE__ */ makeMap(
"bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text,memo"
);
const cacheStringFunction = (fn2) => {
const cache2 = /* @__PURE__ */ Object.create(null);
return (str) => {
const hit = cache2[str];
return hit || (cache2[str] = fn2(str));
};
};
const camelizeRE = /-(\w)/g;
const camelize = cacheStringFunction((str) => {
return str.replace(camelizeRE, (_2, c2) => c2 ? c2.toUpperCase() : "");
});
const hyphenateRE = /\B([A-Z])/g;
const hyphenate = cacheStringFunction(
(str) => str.replace(hyphenateRE, "-$1").toLowerCase()
);
const capitalize = cacheStringFunction((str) => {
return str.charAt(0).toUpperCase() + str.slice(1);
});
const toHandlerKey = cacheStringFunction((str) => {
const s = str ? `on${capitalize(str)}` : ``;
return s;
});
const hasChanged = (value, oldValue) => !Object.is(value, oldValue);
const invokeArrayFns = (fns, arg) => {
for (let i2 = 0; i2 < fns.length; i2++) {
fns[i2](arg);
}
};
const def = (obj, key, value) => {
Object.defineProperty(obj, key, {
configurable: true,
enumerable: false,
value
});
};
const looseToNumber = (val) => {
const n2 = parseFloat(val);
return isNaN(n2) ? val : n2;
};
const toNumber = (val) => {
const n2 = isString$1(val) ? Number(val) : NaN;
return isNaN(n2) ? val : n2;
};
let _globalThis;
const getGlobalThis = () => {
return _globalThis || (_globalThis = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : {});
};
function normalizeStyle(value) {
if (isArray$1(value)) {
const res = {};
for (let i2 = 0; i2 < value.length; i2++) {
const item = value[i2];
const normalized = isString$1(item) ? parseStringStyle(item) : normalizeStyle(item);
if (normalized) {
for (const key in normalized) {
res[key] = normalized[key];
}
}
}
return res;
} else if (isString$1(value) || isObject(value)) {
return value;
}
}
const listDelimiterRE = /;(?![^(]*\))/g;
const propertyDelimiterRE = /:([^]+)/;
const styleCommentRE = /\/\*[^]*?\*\//g;
function parseStringStyle(cssText) {
const ret = {};
cssText.replace(styleCommentRE, "").split(listDelimiterRE).forEach((item) => {
if (item) {
const tmp = item.split(propertyDelimiterRE);
tmp.length > 1 && (ret[tmp[0].trim()] = tmp[1].trim());
}
});
return ret;
}
function normalizeClass(value) {
let res = "";
if (isString$1(value)) {
res = value;
} else if (isArray$1(value)) {
for (let i2 = 0; i2 < value.length; i2++) {
const normalized = normalizeClass(value[i2]);
if (normalized) {
res += normalized + " ";
}
}
} else if (isObject(value)) {
for (const name in value) {
if (value[name]) {
res += name + " ";
}
}
}
return res.trim();
}
function normalizeProps(props) {
if (!props)
return null;
let { class: klass, style } = props;
if (klass && !isString$1(klass)) {
props.class = normalizeClass(klass);
}
if (style) {
props.style = normalizeStyle(style);
}
return props;
}
const HTML_TAGS = "html,body,base,head,link,meta,style,title,address,article,aside,footer,header,hgroup,h1,h2,h3,h4,h5,h6,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,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,summary,template,blockquote,iframe,tfoot";
const SVG_TAGS = "svg,animate,animateMotion,animateTransform,circle,clipPath,color-profile,defs,desc,discard,ellipse,feBlend,feColorMatrix,feComponentTransfer,feComposite,feConvolveMatrix,feDiffuseLighting,feDisplacementMap,feDistantLight,feDropShadow,feFlood,feFuncA,feFuncB,feFuncG,feFuncR,feGaussianBlur,feImage,feMerge,feMergeNode,feMorphology,feOffset,fePointLight,feSpecularLighting,feSpotLight,feTile,feTurbulence,filter,foreignObject,g,hatch,hatchpath,image,line,linearGradient,marker,mask,mesh,meshgradient,meshpatch,meshrow,metadata,mpath,path,pattern,polygon,polyline,radialGradient,rect,set,solidcolor,stop,switch,symbol,text,textPath,title,tspan,unknown,use,view";
const isHTMLTag = /* @__PURE__ */ makeMap(HTML_TAGS);
const isSVGTag = /* @__PURE__ */ makeMap(SVG_TAGS);
const specialBooleanAttrs = `itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly`;
const isSpecialBooleanAttr = /* @__PURE__ */ makeMap(specialBooleanAttrs);
function includeBooleanAttr(value) {
return !!value || value === "";
}
const toDisplayString = (val) => {
return isString$1(val) ? val : val == null ? "" : isArray$1(val) || isObject(val) && (val.toString === objectToString || !isFunction$1(val.toString)) ? JSON.stringify(val, replacer, 2) : String(val);
};
const replacer = (_key, val) => {
if (val && val.__v_isRef) {
return replacer(_key, val.value);
} else if (isMap(val)) {
return {
[`Map(${val.size})`]: [...val.entries()].reduce((entries, [key, val2]) => {
entries[`${key} =>`] = val2;
return entries;
}, {})
};
} else if (isSet(val)) {
return {
[`Set(${val.size})`]: [...val.values()]
};
} else if (isObject(val) && !isArray$1(val) && !isPlainObject$1(val)) {
return String(val);
}
return val;
};
function warn$1(msg, ...args) {
console.warn(`[Vue warn] ${msg}`, ...args);
}
let activeEffectScope;
class EffectScope {
constructor(detached = false) {
this.detached = detached;
this._active = true;
this.effects = [];
this.cleanups = [];
this.parent = activeEffectScope;
if (!detached && activeEffectScope) {
this.index = (activeEffectScope.scopes || (activeEffectScope.scopes = [])).push(
this
) - 1;
}
}
get active() {
return this._active;
}
run(fn2) {
if (this._active) {
const currentEffectScope = activeEffectScope;
try {
activeEffectScope = this;
return fn2();
} finally {
activeEffectScope = currentEffectScope;
}
} else {
warn$1(`cannot run an inactive effect scope.`);
}
}
/**
* This should only be called on non-detached scopes
* @internal
*/
on() {
activeEffectScope = this;
}
/**
* This should only be called on non-detached scopes
* @internal
*/
off() {
activeEffectScope = this.parent;
}
stop(fromParent) {
if (this._active) {
let i2, l;
for (i2 = 0, l = this.effects.length; i2 < l; i2++) {
this.effects[i2].stop();
}
for (i2 = 0, l = this.cleanups.length; i2 < l; i2++) {
this.cleanups[i2]();
}
if (this.scopes) {
for (i2 = 0, l = this.scopes.length; i2 < l; i2++) {
this.scopes[i2].stop(true);
}
}
if (!this.detached && this.parent && !fromParent) {
const last = this.parent.scopes.pop();
if (last && last !== this) {
this.parent.scopes[this.index] = last;
last.index = this.index;
}
}
this.parent = void 0;
this._active = false;
}
}
}
function effectScope(detached) {
return new EffectScope(detached);
}
function recordEffectScope(effect2, scope = activeEffectScope) {
if (scope && scope.active) {
scope.effects.push(effect2);
}
}
function getCurrentScope() {
return activeEffectScope;
}
function onScopeDispose(fn2) {
if (activeEffectScope) {
activeEffectScope.cleanups.push(fn2);
} else {
warn$1(
`onScopeDispose() is called when there is no active effect scope to be associated with.`
);
}
}
const createDep = (effects) => {
const dep = new Set(effects);
dep.w = 0;
dep.n = 0;
return dep;
};
const wasTracked = (dep) => (dep.w & trackOpBit) > 0;
const newTracked = (dep) => (dep.n & trackOpBit) > 0;
const initDepMarkers = ({ deps }) => {
if (deps.length) {
for (let i2 = 0; i2 < deps.length; i2++) {
deps[i2].w |= trackOpBit;
}
}
};
const finalizeDepMarkers = (effect2) => {
const { deps } = effect2;
if (deps.length) {
let ptr = 0;
for (let i2 = 0; i2 < deps.length; i2++) {
const dep = deps[i2];
if (wasTracked(dep) && !newTracked(dep)) {
dep.delete(effect2);
} else {
deps[ptr++] = dep;
}
dep.w &= ~trackOpBit;
dep.n &= ~trackOpBit;
}
deps.length = ptr;
}
};
const targetMap = /* @__PURE__ */ new WeakMap();
let effectTrackDepth = 0;
let trackOpBit = 1;
const maxMarkerBits = 30;
let activeEffect;
const ITERATE_KEY = Symbol("iterate");
const MAP_KEY_ITERATE_KEY = Symbol("Map key iterate");
class ReactiveEffect {
constructor(fn2, scheduler2 = null, scope) {
this.fn = fn2;
this.scheduler = scheduler2;
this.active = true;
this.deps = [];
this.parent = void 0;
recordEffectScope(this, scope);
}
run() {
if (!this.active) {
return this.fn();
}
let parent = activeEffect;
let lastShouldTrack = shouldTrack;
while (parent) {
if (parent === this) {
return;
}
parent = parent.parent;
}
try {
this.parent = activeEffect;
activeEffect = this;
shouldTrack = true;
trackOpBit = 1 << ++effectTrackDepth;
if (effectTrackDepth <= maxMarkerBits) {
initDepMarkers(this);
} else {
cleanupEffect(this);
}
return this.fn();
} finally {
if (effectTrackDepth <= maxMarkerBits) {
finalizeDepMarkers(this);
}
trackOpBit = 1 << --effectTrackDepth;
activeEffect = this.parent;
shouldTrack = lastShouldTrack;
this.parent = void 0;
if (this.deferStop) {
this.stop();
}
}
}
stop() {
if (activeEffect === this) {
this.deferStop = true;
} else if (this.active) {
cleanupEffect(this);
if (this.onStop) {
this.onStop();
}
this.active = false;
}
}
}
function cleanupEffect(effect2) {
const { deps } = effect2;
if (deps.length) {
for (let i2 = 0; i2 < deps.length; i2++) {
deps[i2].delete(effect2);
}
deps.length = 0;
}
}
let shouldTrack = true;
const trackStack = [];
function pauseTracking() {
trackStack.push(shouldTrack);
shouldTrack = false;
}
function resetTracking() {
const last = trackStack.pop();
shouldTrack = last === void 0 ? true : last;
}
function track(target, type, key) {
if (shouldTrack && activeEffect) {
let depsMap = targetMap.get(target);
if (!depsMap) {
targetMap.set(target, depsMap = /* @__PURE__ */ new Map());
}
let dep = depsMap.get(key);
if (!dep) {
depsMap.set(key, dep = createDep());
}
const eventInfo = { effect: activeEffect, target, type, key };
trackEffects(dep, eventInfo);
}
}
function trackEffects(dep, debuggerEventExtraInfo) {
let shouldTrack2 = false;
if (effectTrackDepth <= maxMarkerBits) {
if (!newTracked(dep)) {
dep.n |= trackOpBit;
shouldTrack2 = !wasTracked(dep);
}
} else {
shouldTrack2 = !dep.has(activeEffect);
}
if (shouldTrack2) {
dep.add(activeEffect);
activeEffect.deps.push(dep);
if (activeEffect.onTrack) {
activeEffect.onTrack(
extend(
{
effect: activeEffect
},
debuggerEventExtraInfo
)
);
}
}
}
function trigger(target, type, key, newValue, oldValue, oldTarget) {
const depsMap = targetMap.get(target);
if (!depsMap) {
return;
}
let deps = [];
if (type === "clear") {
deps = [...depsMap.values()];
} else if (key === "length" && isArray$1(target)) {
const newLength = Number(newValue);
depsMap.forEach((dep, key2) => {
if (key2 === "length" || !isSymbol(key2) && key2 >= newLength) {
deps.push(dep);
}
});
} else {
if (key !== void 0) {
deps.push(depsMap.get(key));
}
switch (type) {
case "add":
if (!isArray$1(target)) {
deps.push(depsMap.get(ITERATE_KEY));
if (isMap(target)) {
deps.push(depsMap.get(MAP_KEY_ITERATE_KEY));
}
} else if (isIntegerKey(key)) {
deps.push(depsMap.get("length"));
}
break;
case "delete":
if (!isArray$1(target)) {
deps.push(depsMap.get(ITERATE_KEY));
if (isMap(target)) {
deps.push(depsMap.get(MAP_KEY_ITERATE_KEY));
}
}
break;
case "set":
if (isMap(target)) {
deps.push(depsMap.get(ITERATE_KEY));
}
break;
}
}
const eventInfo = { target, type, key, newValue, oldValue, oldTarget };
if (deps.length === 1) {
if (deps[0]) {
{
triggerEffects(deps[0], eventInfo);
}
}
} else {
const effects = [];
for (const dep of deps) {
if (dep) {
effects.push(...dep);
}
}
{
triggerEffects(createDep(effects), eventInfo);
}
}
}
function triggerEffects(dep, debuggerEventExtraInfo) {
const effects = isArray$1(dep) ? dep : [...dep];
for (const effect2 of effects) {
if (effect2.computed) {
triggerEffect(effect2, debuggerEventExtraInfo);
}
}
for (const effect2 of effects) {
if (!effect2.computed) {
triggerEffect(effect2, debuggerEventExtraInfo);
}
}
}
function triggerEffect(effect2, debuggerEventExtraInfo) {
if (effect2 !== activeEffect || effect2.allowRecurse) {
if (effect2.onTrigger) {
effect2.onTrigger(extend({ effect: effect2 }, debuggerEventExtraInfo));
}
if (effect2.scheduler) {
effect2.scheduler();
} else {
effect2.run();
}
}
}
function getDepFromReactive(object, key) {
var _a2;
return (_a2 = targetMap.get(object)) == null ? void 0 : _a2.get(key);
}
const isNonTrackableKeys = /* @__PURE__ */ makeMap(`__proto__,__v_isRef,__isVue`);
const builtInSymbols = new Set(
/* @__PURE__ */ Object.getOwnPropertyNames(Symbol).filter((key) => key !== "arguments" && key !== "caller").map((key) => Symbol[key]).filter(isSymbol)
);
const arrayInstrumentations = /* @__PURE__ */ createArrayInstrumentations();
function createArrayInstrumentations() {
const instrumentations = {};
["includes", "indexOf", "lastIndexOf"].forEach((key) => {
instrumentations[key] = function(...args) {
const arr = toRaw(this);
for (let i2 = 0, l = this.length; i2 < l; i2++) {
track(arr, "get", i2 + "");
}
const res = arr[key](...args);
if (res === -1 || res === false) {
return arr[key](...args.map(toRaw));
} else {
return res;
}
};
});
["push", "pop", "shift", "unshift", "splice"].forEach((key) => {
instrumentations[key] = function(...args) {
pauseTracking();
const res = toRaw(this)[key].apply(this, args);
resetTracking();
return res;
};
});
return instrumentations;
}
function hasOwnProperty(key) {
const obj = toRaw(this);
track(obj, "has", key);
return obj.hasOwnProperty(key);
}
class BaseReactiveHandler {
constructor(_isReadonly = false, _shallow = false) {
this._isReadonly = _isReadonly;
this._shallow = _shallow;
}
get(target, key, receiver) {
const isReadonly2 = this._isReadonly, shallow = this._shallow;
if (key === "__v_isReactive") {
return !isReadonly2;
} else if (key === "__v_isReadonly") {
return isReadonly2;
} else if (key === "__v_isShallow") {
return shallow;
} else if (key === "__v_raw" && receiver === (isReadonly2 ? shallow ? shallowReadonlyMap : readonlyMap : shallow ? shallowReactiveMap : reactiveMap).get(target)) {
return target;
}
const targetIsArray = isArray$1(target);
if (!isReadonly2) {
if (targetIsArray && hasOwn(arrayInstrumentations, key)) {
return Reflect.get(arrayInstrumentations, key, receiver);
}
if (key === "hasOwnProperty") {
return hasOwnProperty;
}
}
const res = Reflect.get(target, key, receiver);
if (isSymbol(key) ? builtInSymbols.has(key) : isNonTrackableKeys(key)) {
return res;
}
if (!isReadonly2) {
track(target, "get", key);
}
if (shallow) {
return res;
}
if (isRef(res)) {
return targetIsArray && isIntegerKey(key) ? res : res.value;
}
if (isObject(res)) {
return isReadonly2 ? readonly(res) : reactive(res);
}
return res;
}
}
class MutableReactiveHandler extends BaseReactiveHandler {
constructor(shallow = false) {
super(false, shallow);
}
set(target, key, value, receiver) {
let oldValue = target[key];
if (isReadonly(oldValue) && isRef(oldValue) && !isRef(value)) {
return false;
}
if (!this._shallow) {
if (!isShallow$1(value) && !isReadonly(value)) {
oldValue = toRaw(oldValue);
value = toRaw(value);
}
if (!isArray$1(target) && isRef(oldValue) && !isRef(value)) {
oldValue.value = value;
return true;
}
}
const hadKey = isArray$1(target) && isIntegerKey(key) ? Number(key) < target.length : hasOwn(target, key);
const result = Reflect.set(target, key, value, receiver);
if (target === toRaw(receiver)) {
if (!hadKey) {
trigger(target, "add", key, value);
} else if (hasChanged(value, oldValue)) {
trigger(target, "set", key, value, oldValue);
}
}
return result;
}
deleteProperty(target, key) {
const hadKey = hasOwn(target, key);
const oldValue = target[key];
const result = Reflect.deleteProperty(target, key);
if (result && hadKey) {
trigger(target, "delete", key, void 0, oldValue);
}
return result;
}
has(target, key) {
const result = Reflect.has(target, key);
if (!isSymbol(key) || !builtInSymbols.has(key)) {
track(target, "has", key);
}
return result;
}
ownKeys(target) {
track(
target,
"iterate",
isArray$1(target) ? "length" : ITERATE_KEY
);
return Reflect.ownKeys(target);
}
}
class ReadonlyReactiveHandler extends BaseReactiveHandler {
constructor(shallow = false) {
super(true, shallow);
}
set(target, key) {
{
warn$1(
`Set operation on key "${String(key)}" failed: target is readonly.`,
target
);
}
return true;
}
deleteProperty(target, key) {
{
warn$1(
`Delete operation on key "${String(key)}" failed: target is readonly.`,
target
);
}
return true;
}
}
const mutableHandlers = /* @__PURE__ */ new MutableReactiveHandler();
const readonlyHandlers = /* @__PURE__ */ new ReadonlyReactiveHandler();
const shallowReactiveHandlers = /* @__PURE__ */ new MutableReactiveHandler(
true
);
const shallowReadonlyHandlers = /* @__PURE__ */ new ReadonlyReactiveHandler(true);
const toShallow = (value) => value;
const getProto = (v2) => Reflect.getPrototypeOf(v2);
function get(target, key, isReadonly2 = false, isShallow2 = false) {
target = target["__v_raw"];
const rawTarget = toRaw(target);
const rawKey = toRaw(key);
if (!isReadonly2) {
if (hasChanged(key, rawKey)) {
track(rawTarget, "get", key);
}
track(rawTarget, "get", rawKey);
}
const { has: has2 } = getProto(rawTarget);
const wrap = isShallow2 ? toShallow : isReadonly2 ? toReadonly : toReactive;
if (has2.call(rawTarget, key)) {
return wrap(target.get(key));
} else if (has2.call(rawTarget, rawKey)) {
return wrap(target.get(rawKey));
} else if (target !== rawTarget) {
target.get(key);
}
}
function has(key, isReadonly2 = false) {
const target = this["__v_raw"];
const rawTarget = toRaw(target);
const rawKey = toRaw(key);
if (!isReadonly2) {
if (hasChanged(key, rawKey)) {
track(rawTarget, "has", key);
}
track(rawTarget, "has", rawKey);
}
return key === rawKey ? target.has(key) : target.has(key) || target.has(rawKey);
}
function size$1(target, isReadonly2 = false) {
target = target["__v_raw"];
!isReadonly2 && track(toRaw(target), "iterate", ITERATE_KEY);
return Reflect.get(target, "size", target);
}
function add(value) {
value = toRaw(value);
const target = toRaw(this);
const proto = getProto(target);
const hadKey = proto.has.call(target, value);
if (!hadKey) {
target.add(value);
trigger(target, "add", value, value);
}
return this;
}
function set$1(key, value) {
value = toRaw(value);
const target = toRaw(this);
const { has: has2, get: get2 } = getProto(target);
let hadKey = has2.call(target, key);
if (!hadKey) {
key = toRaw(key);
hadKey = has2.call(target, key);
} else {
checkIdentityKeys(target, has2, key);
}
const oldValue = get2.call(target, key);
target.set(key, value);
if (!hadKey) {
trigger(target, "add", key, value);
} else if (hasChanged(value, oldValue)) {
trigger(target, "set", key, value, oldValue);
}
return this;
}
function deleteEntry(key) {
const target = toRaw(this);
const { has: has2, get: get2 } = getProto(target);
let hadKey = has2.call(target, key);
if (!hadKey) {
key = toRaw(key);
hadKey = has2.call(target, key);
} else {
checkIdentityKeys(target, has2, key);
}
const oldValue = get2 ? get2.call(target, key) : void 0;
const result = target.delete(key);
if (hadKey) {
trigger(target, "delete", key, void 0, oldValue);
}
return result;
}
function clear() {
const target = toRaw(this);
const hadItems = target.size !== 0;
const oldTarget = isMap(target) ? new Map(target) : new Set(target);
const result = target.clear();
if (hadItems) {
trigger(target, "clear", void 0, void 0, oldTarget);
}
return result;
}
function createForEach(isReadonly2, isShallow2) {
return function forEach(callback, thisArg) {
const observed = this;
const target = observed["__v_raw"];
const rawTarget = toRaw(target);
const wrap = isShallow2 ? toShallow : isReadonly2 ? toReadonly : toReactive;
!isReadonly2 && track(rawTarget, "iterate", ITERATE_KEY);
return target.forEach((value, key) => {
return callback.call(thisArg, wrap(value), wrap(key), observed);
});
};
}
function createIterableMethod(method, isReadonly2, isShallow2) {
return function(...args) {
const target = this["__v_raw"];
const rawTarget = toRaw(target);
const targetIsMap = isMap(rawTarget);
const isPair = method === "entries" || method === Symbol.iterator && targetIsMap;
const isKeyOnly = method === "keys" && targetIsMap;
const innerIterator = target[method](...args);
const wrap = isShallow2 ? toShallow : isReadonly2 ? toReadonly : toReactive;
!isReadonly2 && track(
rawTarget,
"iterate",
isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY
);
return {
// iterator protocol
next() {
const { value, done } = innerIterator.next();
return done ? { value, done } : {
value: isPair ? [wrap(value[0]), wrap(value[1])] : wrap(value),
done
};
},
// iterable protocol
[Symbol.iterator]() {
return this;
}
};
};
}
function createReadonlyMethod(type) {
return function(...args) {
{
const key = args[0] ? `on key "${args[0]}" ` : ``;
console.warn(
`${capitalize(type)} operation ${key}failed: target is readonly.`,
toRaw(this)
);
}
return type === "delete" ? false : this;
};
}
function createInstrumentations() {
const mutableInstrumentations2 = {
get(key) {
return get(this, key);
},
get size() {
return size$1(this);
},
has,
add,
set: set$1,
delete: deleteEntry,
clear,
forEach: createForEach(false, false)
};
const shallowInstrumentations2 = {
get(key) {
return get(this, key, false, true);
},
get size() {
return size$1(this);
},
has,
add,
set: set$1,
delete: deleteEntry,
clear,
forEach: createForEach(false, true)
};
const readonlyInstrumentations2 = {
get(key) {
return get(this, key, true);
},
get size() {
return size$1(this, true);
},
has(key) {
return has.call(this, key, true);
},
add: createReadonlyMethod("add"),
set: createReadonlyMethod("set"),
delete: createReadonlyMethod("delete"),
clear: createReadonlyMethod("clear"),
forEach: createForEach(true, false)
};
const shallowReadonlyInstrumentations2 = {
get(key) {
return get(this, key, true, true);
},
get size() {
return size$1(this, true);
},
has(key) {
return has.call(this, key, true);
},
add: createReadonlyMethod("add"),
set: createReadonlyMethod("set"),
delete: createReadonlyMethod("delete"),
clear: createReadonlyMethod("clear"),
forEach: createForEach(true, true)
};
const iteratorMethods = ["keys", "values", "entries", Symbol.iterator];
iteratorMethods.forEach((method) => {
mutableInstrumentations2[method] = createIterableMethod(
method,
false,
false
);
readonlyInstrumentations2[method] = createIterableMethod(
method,
true,
false
);
shallowInstrumentations2[method] = createIterableMethod(
method,
false,
true
);
shallowReadonlyInstrumentations2[method] = createIterableMethod(
method,
true,
true
);
});
return [
mutableInstrumentations2,
readonlyInstrumentations2,
shallowInstrumentations2,
shallowReadonlyInstrumentations2
];
}
const [
mutableInstrumentations,
readonlyInstrumentations,
shallowInstrumentations,
shallowReadonlyInstrumentations
] = /* @__PURE__ */ createInstrumentations();
function createInstrumentationGetter(isReadonly2, shallow) {
const instrumentations = shallow ? isReadonly2 ? shallowReadonlyInstrumentations : shallowInstrumentations : isReadonly2 ? readonlyInstrumentations : mutableInstrumentations;
return (target, key, receiver) => {
if (key === "__v_isReactive") {
return !isReadonly2;
} else if (key === "__v_isReadonly") {
return isReadonly2;
} else if (key === "__v_raw") {
return target;
}
return Reflect.get(
hasOwn(instrumentations, key) && key in target ? instrumentations : target,
key,
receiver
);
};
}
const mutableCollectionHandlers = {
get: /* @__PURE__ */ createInstrumentationGetter(false, false)
};
const shallowCollectionHandlers = {
get: /* @__PURE__ */ createInstrumentationGetter(false, true)
};
const readonlyCollectionHandlers = {
get: /* @__PURE__ */ createInstrumentationGetter(true, false)
};
const shallowReadonlyCollectionHandlers = {
get: /* @__PURE__ */ createInstrumentationGetter(true, true)
};
function checkIdentityKeys(target, has2, key) {
const rawKey = toRaw(key);
if (rawKey !== key && has2.call(target, rawKey)) {
const type = toRawType(target);
console.warn(
`Reactive ${type} contains both the raw and reactive versions of the same object${type === `Map` ? ` as keys` : ``}, which can lead to inconsistencies. Avoid differentiating between the raw and reactive versions of an object and only use the reactive version if possible.`
);
}
}
const reactiveMap = /* @__PURE__ */ new WeakMap();
const shallowReactiveMap = /* @__PURE__ */ new WeakMap();
const readonlyMap = /* @__PURE__ */ new WeakMap();
const shallowReadonlyMap = /* @__PURE__ */ new WeakMap();
function targetTypeMap(rawType) {
switch (rawType) {
case "Object":
case "Array":
return 1;
case "Map":
case "Set":
case "WeakMap":
case "WeakSet":
return 2;
default:
return 0;
}
}
function getTargetType(value) {
return value["__v_skip"] || !Object.isExtensible(value) ? 0 : targetTypeMap(toRawType(value));
}
function reactive(target) {
if (isReadonly(target)) {
return target;
}
return createReactiveObject(
target,
false,
mutableHandlers,
mutableCollectionHandlers,
reactiveMap
);
}
function shallowReactive(target) {
return createReactiveObject(
target,
false,
shallowReactiveHandlers,
shallowCollectionHandlers,
shallowReactiveMap
);
}
function readonly(target) {
return createReactiveObject(
target,
true,
readonlyHandlers,
readonlyCollectionHandlers,
readonlyMap
);
}
function shallowReadonly(target) {
return createReactiveObject(
target,
true,
shallowReadonlyHandlers,
shallowReadonlyCollectionHandlers,
shallowReadonlyMap
);
}
function createReactiveObject(target, isReadonly2, baseHandlers, collectionHandlers, proxyMap) {
if (!isObject(target)) {
{
console.warn(`value cannot be made reactive: ${String(target)}`);
}
return target;
}
if (target["__v_raw"] && !(isReadonly2 && target["__v_isReactive"])) {
return target;
}
const existingProxy = proxyMap.get(target);
if (existingProxy) {
return existingProxy;
}
const targetType = getTargetType(target);
if (targetType === 0) {
return target;
}
const proxy = new Proxy(
target,
targetType === 2 ? collectionHandlers : baseHandlers
);
proxyMap.set(target, proxy);
return proxy;
}
function isReactive(value) {
if (isReadonly(value)) {
return isReactive(value["__v_raw"]);
}
return !!(value && value["__v_isReactive"]);
}
function isReadonly(value) {
return !!(value && value["__v_isReadonly"]);
}
function isShallow$1(value) {
return !!(value && value["__v_isShallow"]);
}
function isProxy(value) {
return isReactive(value) || isReadonly(value);
}
function toRaw(observed) {
const raw = observed && observed["__v_raw"];
return raw ? toRaw(raw) : observed;
}
function markRaw(value) {
def(value, "__v_skip", true);
return value;
}
const toReactive = (value) => isObject(value) ? reactive(value) : value;
const toReadonly = (value) => isObject(value) ? readonly(value) : value;
function trackRefValue(ref2) {
if (shouldTrack && activeEffect) {
ref2 = toRaw(ref2);
{
trackEffects(ref2.dep || (ref2.dep = createDep()), {
target: ref2,
type: "get",
key: "value"
});
}
}
}
function triggerRefValue(ref2, newVal) {
ref2 = toRaw(ref2);
const dep = ref2.dep;
if (dep) {
{
triggerEffects(dep, {
target: ref2,
type: "set",
key: "value",
newValue: newVal
});
}
}
}
function isRef(r2) {
return !!(r2 && r2.__v_isRef === true);
}
function ref(value) {
return createRef(value, false);
}
function shallowRef(value) {
return createRef(value, true);
}
function createRef(rawValue, shallow) {
if (isRef(rawValue)) {
return rawValue;
}
return new RefImpl(rawValue, shallow);
}
class RefImpl {
constructor(value, __v_isShallow) {
this.__v_isShallow = __v_isShallow;
this.dep = void 0;
this.__v_isRef = true;
this._rawValue = __v_isShallow ? value : toRaw(value);
this._value = __v_isShallow ? value : toReactive(value);
}
get value() {
trackRefValue(this);
return this._value;
}
set value(newVal) {
const useDirectValue = this.__v_isShallow || isShallow$1(newVal) || isReadonly(newVal);
newVal = useDirectValue ? newVal : toRaw(newVal);
if (hasChanged(newVal, this._rawValue)) {
this._rawValue = newVal;
this._value = useDirectValue ? newVal : toReactive(newVal);
triggerRefValue(this, newVal);
}
}
}
function unref(ref2) {
return isRef(ref2) ? ref2.value : ref2;
}
const shallowUnwrapHandlers = {
get: (target, key, receiver) => unref(Reflect.get(target, key, receiver)),
set: (target, key, value, receiver) => {
const oldValue = target[key];
if (isRef(oldValue) && !isRef(value)) {
oldValue.value = value;
return true;
} else {
return Reflect.set(target, key, value, receiver);
}
}
};
function proxyRefs(objectWithRefs) {
return isReactive(objectWithRefs) ? objectWithRefs : new Proxy(objectWithRefs, shallowUnwrapHandlers);
}
function toRefs(object) {
if (!isProxy(object)) {
console.warn(`toRefs() expects a reactive object but received a plain one.`);
}
const ret = isArray$1(object) ? new Array(object.length) : {};
for (const key in object) {
ret[key] = propertyToRef(object, key);
}
return ret;
}
class ObjectRefImpl {
constructor(_object, _key, _defaultValue) {
this._object = _object;
this._key = _key;
this._defaultValue = _defaultValue;
this.__v_isRef = true;
}
get value() {
const val = this._object[this._key];
return val === void 0 ? this._defaultValue : val;
}
set value(newVal) {
this._object[this._key] = newVal;
}
get dep() {
return getDepFromReactive(toRaw(this._object), this._key);
}
}
class GetterRefImpl {
constructor(_getter) {
this._getter = _getter;
this.__v_isRef = true;
this.__v_isReadonly = true;
}
get value() {
return this._getter();
}
}
function toRef(source, key, defaultValue) {
if (isRef(source)) {
return source;
} else if (isFunction$1(source)) {
return new GetterRefImpl(source);
} else if (isObject(source) && arguments.length > 1) {
return propertyToRef(source, key, defaultValue);
} else {
return ref(source);
}
}
function propertyToRef(source, key, defaultValue) {
const val = source[key];
return isRef(val) ? val : new ObjectRefImpl(source, key, defaultValue);
}
class ComputedRefImpl {
constructor(getter, _setter, isReadonly2, isSSR) {
this._setter = _setter;
this.dep = void 0;
this.__v_isRef = true;
this["__v_isReadonly"] = false;
this._dirty = true;
this.effect = new ReactiveEffect(getter, () => {
if (!this._dirty) {
this._dirty = true;
triggerRefValue(this);
}
});
this.effect.computed = this;
this.effect.active = this._cacheable = !isSSR;
this["__v_isReadonly"] = isReadonly2;
}
get value() {
const self2 = toRaw(this);
trackRefValue(self2);
if (self2._dirty || !self2._cacheable) {
self2._dirty = false;
self2._value = self2.effect.run();
}
return self2._value;
}
set value(newValue) {
this._setter(newValue);
}
}
function computed$1(getterOrOptions, debugOptions, isSSR = false) {
let getter;
let setter;
const onlyGetter = isFunction$1(getterOrOptions);
if (onlyGetter) {
getter = getterOrOptions;
setter = () => {
console.warn("Write operation failed: computed value is readonly");
};
} else {
getter = getterOrOptions.get;
setter = getterOrOptions.set;
}
const cRef = new ComputedRefImpl(getter, setter, onlyGetter || !setter, isSSR);
if (debugOptions && !isSSR) {
cRef.effect.onTrack = debugOptions.onTrack;
cRef.effect.onTrigger = debugOptions.onTrigger;
}
return cRef;
}
const stack = [];
function pushWarningContext(vnode) {
stack.push(vnode);
}
function popWarningContext() {
stack.pop();
}
function warn$2(msg, ...args) {
pauseTracking();
const instance = stack.length ? stack[stack.length - 1].component : null;
const appWarnHandler = instance && instance.appContext.config.warnHandler;
const trace = getComponentTrace();
if (appWarnHandler) {
callWithErrorHandling(
appWarnHandler,
instance,
11,
[
msg + args.join(""),
instance && instance.proxy,
trace.map(
({ vnode }) => `at <${formatComponentName(instance, vnode.type)}>`
).join("\n"),
trace
]
);
} else {
const warnArgs = [`[Vue warn]: ${msg}`, ...args];
if (trace.length && // avoid spamming console during tests
true) {
warnArgs.push(`
`, ...formatTrace(trace));
}
console.warn(...warnArgs);
}
resetTracking();
}
function getComponentTrace() {
let currentVNode = stack[stack.length - 1];
if (!currentVNode) {
return [];
}
const normalizedStack = [];
while (currentVNode) {
const last = normalizedStack[0];
if (last && last.vnode === currentVNode) {
last.recurseCount++;
} else {
normalizedStack.push({
vnode: currentVNode,
recurseCount: 0
});
}
const parentInstance = currentVNode.component && currentVNode.component.parent;
currentVNode = parentInstance && parentInstance.vnode;
}
return normalizedStack;
}
function formatTrace(trace) {
const logs = [];
trace.forEach((entry, i2) => {
logs.push(...i2 === 0 ? [] : [`
`], ...formatTraceEntry(entry));
});
return logs;
}
function formatTraceEntry({ vnode, recurseCount }) {
const postfix = recurseCount > 0 ? `... (${recurseCount} recursive calls)` : ``;
const isRoot = vnode.component ? vnode.component.parent == null : false;
const open2 = ` at <${formatComponentName(
vnode.component,
vnode.type,
isRoot
)}`;
const close = `>` + postfix;
return vnode.props ? [open2, ...formatProps(vnode.props), close] : [open2 + close];
}
function formatProps(props) {
const res = [];
const keys = Object.keys(props);
keys.slice(0, 3).forEach((key) => {
res.push(...formatProp(key, props[key]));
});
if (keys.length > 3) {
res.push(` ...`);
}
return res;
}
function formatProp(key, value, raw) {
if (isString$1(value)) {
value = JSON.stringify(value);
return raw ? value : [`${key}=${value}`];
} else if (typeof value === "number" || typeof value === "boolean" || value == null) {
return raw ? value : [`${key}=${value}`];
} else if (isRef(value)) {
value = formatProp(key, toRaw(value.value), true);
return raw ? value : [`${key}=Ref<`, value, `>`];
} else if (isFunction$1(value)) {
return [`${key}=fn${value.name ? `<${value.name}>` : ``}`];
} else {
value = toRaw(value);
return raw ? value : [`${key}=`, value];
}
}
function assertNumber(val, type) {
if (val === void 0) {
return;
} else if (typeof val !== "number") {
warn$2(`${type} is not a valid number - got ${JSON.stringify(val)}.`);
} else if (isNaN(val)) {
warn$2(`${type} is NaN - the duration expression might be incorrect.`);
}
}
const ErrorTypeStrings = {
["sp"]: "serverPrefetch hook",
["bc"]: "beforeCreate hook",
["c"]: "created hook",
["bm"]: "beforeMount hook",
["m"]: "mounted hook",
["bu"]: "beforeUpdate hook",
["u"]: "updated",
["bum"]: "beforeUnmount hook",
["um"]: "unmounted hook",
["a"]: "activated hook",
["da"]: "deactivated hook",
["ec"]: "errorCaptured hook",
["rtc"]: "renderTracked hook",
["rtg"]: "renderTriggered hook",
[0]: "setup function",
[1]: "render function",
[2]: "watcher getter",
[3]: "watcher callback",
[4]: "watcher cleanup function",
[5]: "native event handler",
[6]: "component event handler",
[7]: "vnode hook",
[8]: "directive hook",
[9]: "transition hook",
[10]: "app errorHandler",
[11]: "app warnHandler",
[12]: "ref function",
[13]: "async component loader",
[14]: "scheduler flush. This is likely a Vue internals bug. Please open an issue at https://new-issue.vuejs.org/?repo=vuejs/core"
};
function callWithErrorHandling(fn2, instance, type, args) {
let res;
try {
res = args ? fn2(...args) : fn2();
} catch (err) {
handleError(err, instance, type);
}
return res;
}
function callWithAsyncErrorHandling(fn2, instance, type, args) {
if (isFunction$1(fn2)) {
const res = callWithErrorHandling(fn2, instance, type, args);
if (res && isPromise(res)) {
res.catch((err) => {
handleError(err, instance, type);
});
}
return res;
}
const values = [];
for (let i2 = 0; i2 < fn2.length; i2++) {
values.push(callWithAsyncErrorHandling(fn2[i2], instance, type, args));
}
return values;
}
function handleError(err, instance, type, throwInDev = true) {
const contextVNode = instance ? instance.vnode : null;
if (instance) {
let cur = instance.parent;
const exposedInstance = instance.proxy;
const errorInfo = ErrorTypeStrings[type];
while (cur) {
const errorCapturedHooks = cur.ec;
if (errorCapturedHooks) {
for (let i2 = 0; i2 < errorCapturedHooks.length; i2++) {
if (errorCapturedHooks[i2](err, exposedInstance, errorInfo) === false) {
return;
}
}
}
cur = cur.parent;
}
const appErrorHandler = instance.appContext.config.errorHandler;
if (appErrorHandler) {
callWithErrorHandling(
appErrorHandler,
null,
10,
[err, exposedInstance, errorInfo]
);
return;
}
}
logError(err, type, contextVNode, throwInDev);
}
function logError(err, type, contextVNode, throwInDev = true) {
{
const info = ErrorTypeStrings[type];
if (contextVNode) {
pushWarningContext(contextVNode);
}
warn$2(`Unhandled error${info ? ` during execution of ${info}` : ``}`);
if (contextVNode) {
popWarningContext();
}
if (throwInDev) {
throw err;
} else {
console.error(err);
}
}
}
let isFlushing = false;
let isFlushPending = false;
const queue = [];
let flushIndex = 0;
const pendingPostFlushCbs = [];
let activePostFlushCbs = null;
let postFlushIndex = 0;
const resolvedPromise = /* @__PURE__ */ Promise.resolve();
let currentFlushPromise = null;
const RECURSION_LIMIT = 100;
function nextTick(fn2) {
const p2 = currentFlushPromise || resolvedPromise;
return fn2 ? p2.then(this ? fn2.bind(this) : fn2) : p2;
}
function findInsertionIndex(id2) {
let start = flushIndex + 1;
let end = queue.length;
while (start < end) {
const middle = start + end >>> 1;
const middleJob = queue[middle];
const middleJobId = getId(middleJob);
if (middleJobId < id2 || middleJobId === id2 && middleJob.pre) {
start = middle + 1;
} else {
end = middle;
}
}
return start;
}
function queueJob(job) {
if (!queue.length || !queue.includes(
job,
isFlushing && job.allowRecurse ? flushIndex + 1 : flushIndex
)) {
if (job.id == null) {
queue.push(job);
} else {
queue.splice(findInsertionIndex(job.id), 0, job);
}
queueFlush();
}
}
function queueFlush() {
if (!isFlushing && !isFlushPending) {
isFlushPending = true;
currentFlushPromise = resolvedPromise.then(flushJobs);
}
}
function invalidateJob(job) {
const i2 = queue.indexOf(job);
if (i2 > flushIndex) {
queue.splice(i2, 1);
}
}
function queuePostFlushCb(cb) {
if (!isArray$1(cb)) {
if (!activePostFlushCbs || !activePostFlushCbs.includes(
cb,
cb.allowRecurse ? postFlushIndex + 1 : postFlushIndex
)) {
pendingPostFlushCbs.push(cb);
}
} else {
pendingPostFlushCbs.push(...cb);
}
queueFlush();
}
function flushPreFlushCbs(seen, i2 = isFlushing ? flushIndex + 1 : 0) {
{
seen = seen || /* @__PURE__ */ new Map();
}
for (; i2 < queue.length; i2++) {
const cb = queue[i2];
if (cb && cb.pre) {
if (checkRecursiveUpdates(seen, cb)) {
continue;
}
queue.splice(i2, 1);
i2--;
cb();
}
}
}
function flushPostFlushCbs(seen) {
if (pendingPostFlushCbs.length) {
const deduped = [...new Set(pendingPostFlushCbs)];
pendingPostFlushCbs.length = 0;
if (activePostFlushCbs) {
activePostFlushCbs.push(...deduped);
return;
}
activePostFlushCbs = deduped;
{
seen = seen || /* @__PURE__ */ new Map();
}
activePostFlushCbs.sort((a2, b3) => getId(a2) - getId(b3));
for (postFlushIndex = 0; postFlushIndex < activePostFlushCbs.length; postFlushIndex++) {
if (checkRecursiveUpdates(seen, activePostFlushCbs[postFlushIndex])) {
continue;
}
activePostFlushCbs[postFlushIndex]();
}
activePostFlushCbs = null;
postFlushIndex = 0;
}
}
const getId = (job) => job.id == null ? Infinity : job.id;
const comparator = (a2, b3) => {
const diff = getId(a2) - getId(b3);
if (diff === 0) {
if (a2.pre && !b3.pre)
return -1;
if (b3.pre && !a2.pre)
return 1;
}
return diff;
};
function flushJobs(seen) {
isFlushPending = false;
isFlushing = true;
{
seen = seen || /* @__PURE__ */ new Map();
}
queue.sort(comparator);
const check = (job) => checkRecursiveUpdates(seen, job);
try {
for (flushIndex = 0; flushIndex < queue.length; flushIndex++) {
const job = queue[flushIndex];
if (job && job.active !== false) {
if (check(job)) {
continue;
}
callWithErrorHandling(job, null, 14);
}
}
} finally {
flushIndex = 0;
queue.length = 0;
flushPostFlushCbs(seen);
isFlushing = false;
currentFlushPromise = null;
if (queue.length || pendingPostFlushCbs.length) {
flushJobs(seen);
}
}
}
function checkRecursiveUpdates(seen, fn2) {
if (!seen.has(fn2)) {
seen.set(fn2, 1);
} else {
const count2 = seen.get(fn2);
if (count2 > RECURSION_LIMIT) {
const instance = fn2.ownerInstance;
const componentName = instance && getComponentName(instance.type);
warn$2(
`Maximum recursive updates exceeded${componentName ? ` in component <${componentName}>` : ``}. This means you have a reactive effect that is mutating its own dependencies and thus recursively triggering itself. Possible sources include component template, render function, updated hook or watcher source function.`
);
return true;
} else {
seen.set(fn2, count2 + 1);
}
}
}
let isHmrUpdating = false;
const hmrDirtyComponents = /* @__PURE__ */ new Set();
{
getGlobalThis().__VUE_HMR_RUNTIME__ = {
createRecord: tryWrap(createRecord),
rerender: tryWrap(rerender),
reload: tryWrap(reload)
};
}
const map = /* @__PURE__ */ new Map();
function registerHMR(instance) {
const id2 = instance.type.__hmrId;
let record = map.get(id2);
if (!record) {
createRecord(id2, instance.type);
record = map.get(id2);
}
record.instances.add(instance);
}
function unregisterHMR(instance) {
map.get(instance.type.__hmrId).instances.delete(instance);
}
function createRecord(id2, initialDef) {
if (map.has(id2)) {
return false;
}
map.set(id2, {
initialDef: normalizeClassComponent(initialDef),
instances: /* @__PURE__ */ new Set()
});
return true;
}
function normalizeClassComponent(component) {
return isClassComponent(component) ? component.__vccOpts : component;
}
function rerender(id2, newRender) {
const record = map.get(id2);
if (!record) {
return;
}
record.initialDef.render = newRender;
[...record.instances].forEach((instance) => {
if (newRender) {
instance.render = newRender;
normalizeClassComponent(instance.type).render = newRender;
}
instance.renderCache = [];
isHmrUpdating = true;
instance.update();
isHmrUpdating = false;
});
}
function reload(id2, newComp) {
const record = map.get(id2);
if (!record)
return;
newComp = normalizeClassComponent(newComp);
updateComponentDef(record.initialDef, newComp);
const instances = [...record.instances];
for (const instance of instances) {
const oldComp = normalizeClassComponent(instance.type);
if (!hmrDirtyComponents.has(oldComp)) {
if (oldComp !== record.initialDef) {
updateComponentDef(oldComp, newComp);
}
hmrDirtyComponents.add(oldComp);
}
instance.appContext.propsCache.delete(instance.type);
instance.appContext.emitsCache.delete(instance.type);
instance.appContext.optionsCache.delete(instance.type);
if (instance.ceReload) {
hmrDirtyComponents.add(oldComp);
instance.ceReload(newComp.styles);
hmrDirtyComponents.delete(oldComp);
} else if (instance.parent) {
queueJob(instance.parent.update);
} else if (instance.appContext.reload) {
instance.appContext.reload();
} else if (typeof window !== "undefined") {
window.location.reload();
} else {
console.warn(
"[HMR] Root or manually mounted instance modified. Full reload required."
);
}
}
queuePostFlushCb(() => {
for (const instance of instances) {
hmrDirtyComponents.delete(
normalizeClassComponent(instance.type)
);
}
});
}
function updateComponentDef(oldComp, newComp) {
extend(oldComp, newComp);
for (const key in oldComp) {
if (key !== "__file" && !(key in newComp)) {
delete oldComp[key];
}
}
}
function tryWrap(fn2) {
return (id2, arg) => {
try {
return fn2(id2, arg);
} catch (e2) {
console.error(e2);
console.warn(
`[HMR] Something went wrong during Vue component hot-reload. Full reload required.`
);
}
};
}
let devtools;
let buffer = [];
let devtoolsNotInstalled = false;
function emit$1(event, ...args) {
if (devtools) {
devtools.emit(event, ...args);
} else if (!devtoolsNotInstalled) {
buffer.push({ event, args });
}
}
function setDevtoolsHook(hook, target) {
var _a2, _b;
devtools = hook;
if (devtools) {
devtools.enabled = true;
buffer.forEach(({ event, args }) => devtools.emit(event, ...args));
buffer = [];
} else if (
// handle late devtools injection - only do this if we are in an actual
// browser environment to avoid the timer handle stalling test runner exit
// (#4815)
typeof window !== "undefined" && // some envs mock window but not fully
window.HTMLElement && // also exclude jsdom
!((_b = (_a2 = window.navigator) == null ? void 0 : _a2.userAgent) == null ? void 0 : _b.includes("jsdom"))
) {
const replay = target.__VUE_DEVTOOLS_HOOK_REPLAY__ = target.__VUE_DEVTOOLS_HOOK_REPLAY__ || [];
replay.push((newHook) => {
setDevtoolsHook(newHook, target);
});
setTimeout(() => {
if (!devtools) {
target.__VUE_DEVTOOLS_HOOK_REPLAY__ = null;
devtoolsNotInstalled = true;
buffer = [];
}
}, 3e3);
} else {
devtoolsNotInstalled = true;
buffer = [];
}
}
function devtoolsInitApp(app, version2) {
emit$1("app:init", app, version2, {
Fragment,
Text,
Comment,
Static
});
}
function devtoolsUnmountApp(app) {
emit$1("app:unmount", app);
}
const devtoolsComponentAdded = /* @__PURE__ */ createDevtoolsComponentHook(
"component:added"
/* COMPONENT_ADDED */
);
const devtoolsComponentUpdated = /* @__PURE__ */ createDevtoolsComponentHook(
"component:updated"
/* COMPONENT_UPDATED */
);
const _devtoolsComponentRemoved = /* @__PURE__ */ createDevtoolsComponentHook(
"component:removed"
/* COMPONENT_REMOVED */
);
const devtoolsComponentRemoved = (component) => {
if (devtools && typeof devtools.cleanupBuffer === "function" && // remove the component if it wasn't buffered
!devtools.cleanupBuffer(component)) {
_devtoolsComponentRemoved(component);
}
};
function createDevtoolsComponentHook(hook) {
return (component) => {
emit$1(
hook,
component.appContext.app,
component.uid,
component.parent ? component.parent.uid : void 0,
component
);
};
}
const devtoolsPerfStart = /* @__PURE__ */ createDevtoolsPerformanceHook(
"perf:start"
/* PERFORMANCE_START */
);
const devtoolsPerfEnd = /* @__PURE__ */ createDevtoolsPerformanceHook(
"perf:end"
/* PERFORMANCE_END */
);
function createDevtoolsPerformanceHook(hook) {
return (component, type, time) => {
emit$1(hook, component.appContext.app, component.uid, component, type, time);
};
}
function devtoolsComponentEmit(component, event, params) {
emit$1(
"component:emit",
component.appContext.app,
component,
event,
params
);
}
function emit(instance, event, ...rawArgs) {
if (instance.isUnmounted)
return;
const props = instance.vnode.props || EMPTY_OBJ;
{
const {
emitsOptions,
propsOptions: [propsOptions]
} = instance;
if (emitsOptions) {
if (!(event in emitsOptions) && true) {
if (!propsOptions || !(toHandlerKey(event) in propsOptions)) {
warn$2(
`Component emitted event "${event}" but it is neither declared in the emits option nor as an "${toHandlerKey(event)}" prop.`
);
}
} else {
const validator = emitsOptions[event];
if (isFunction$1(validator)) {
const isValid = validator(...rawArgs);
if (!isValid) {
warn$2(
`Invalid event arguments: event validation failed for event "${event}".`
);
}
}
}
}
}
let args = rawArgs;
const isModelListener2 = event.startsWith("update:");
const modelArg = isModelListener2 && event.slice(7);
if (modelArg && modelArg in props) {
const modifiersKey = `${modelArg === "modelValue" ? "model" : modelArg}Modifiers`;
const { number, trim } = props[modifiersKey] || EMPTY_OBJ;
if (trim) {
args = rawArgs.map((a2) => isString$1(a2) ? a2.trim() : a2);
}
if (number) {
args = rawArgs.map(looseToNumber);
}
}
{
devtoolsComponentEmit(instance, event, args);
}
{
const lowerCaseEvent = event.toLowerCase();
if (lowerCaseEvent !== event && props[toHandlerKey(lowerCaseEvent)]) {
warn$2(
`Event "${lowerCaseEvent}" is emitted in component ${formatComponentName(
instance,
instance.type
)} but the handler is registered for "${event}". Note that HTML attributes are case-insensitive and you cannot use v-on to listen to camelCase events when using in-DOM templates. You should probably use "${hyphenate(event)}" instead of "${event}".`
);
}
}
let handlerName;
let handler = props[handlerName = toHandlerKey(event)] || // also try camelCase event handler (#2249)
props[handlerName = toHandlerKey(camelize(event))];
if (!handler && isModelListener2) {
handler = props[handlerName = toHandlerKey(hyphenate(event))];
}
if (handler) {
callWithAsyncErrorHandling(
handler,
instance,
6,
args
);
}
const onceHandler = props[handlerName + `Once`];
if (onceHandler) {
if (!instance.emitted) {
instance.emitted = {};
} else if (instance.emitted[handlerName]) {
return;
}
instance.emitted[handlerName] = true;
callWithAsyncErrorHandling(
onceHandler,
instance,
6,
args
);
}
}
function normalizeEmitsOptions(comp, appContext, asMixin = false) {
const cache2 = appContext.emitsCache;
const cached = cache2.get(comp);
if (cached !== void 0) {
return cached;
}
const raw = comp.emits;
let normalized = {};
let hasExtends = false;
if (!isFunction$1(comp)) {
const extendEmits = (raw2) => {
const normalizedFromExtend = normalizeEmitsOptions(raw2, appContext, true);
if (normalizedFromExtend) {
hasExtends = true;
extend(normalized, normalizedFromExtend);
}
};
if (!asMixin && appContext.mixins.length) {
appContext.mixins.forEach(extendEmits);
}
if (comp.extends) {
extendEmits(comp.extends);
}
if (comp.mixins) {
comp.mixins.forEach(extendEmits);
}
}
if (!raw && !hasExtends) {
if (isObject(comp)) {
cache2.set(comp, null);
}
return null;
}
if (isArray$1(raw)) {
raw.forEach((key) => normalized[key] = null);
} else {
extend(normalized, raw);
}
if (isObject(comp)) {
cache2.set(comp, normalized);
}
return normalized;
}
function isEmitListener(options, key) {
if (!options || !isOn(key)) {
return false;
}
key = key.slice(2).replace(/Once$/, "");
return hasOwn(options, key[0].toLowerCase() + key.slice(1)) || hasOwn(options, hyphenate(key)) || hasOwn(options, key);
}
let currentRenderingInstance = null;
let currentScopeId = null;
function setCurrentRenderingInstance(instance) {
const prev = currentRenderingInstance;
currentRenderingInstance = instance;
currentScopeId = instance && instance.type.__scopeId || null;
return prev;
}
function pushScopeId(id2) {
currentScopeId = id2;
}
function popScopeId() {
currentScopeId = null;
}
const withScopeId = (_id) => withCtx;
function withCtx(fn2, ctx = currentRenderingInstance, isNonScopedSlot) {
if (!ctx)
return fn2;
if (fn2._n) {
return fn2;
}
const renderFnWithContext = (...args) => {
if (renderFnWithContext._d) {
setBlockTracking(-1);
}
const prevInstance = setCurrentRenderingInstance(ctx);
let res;
try {
res = fn2(...args);
} finally {
setCurrentRenderingInstance(prevInstance);
if (renderFnWithContext._d) {
setBlockTracking(1);
}
}
{
devtoolsComponentUpdated(ctx);
}
return res;
};
renderFnWithContext._n = true;
renderFnWithContext._c = true;
renderFnWithContext._d = true;
return renderFnWithContext;
}
let accessedAttrs = false;
function markAttrsAccessed() {
accessedAttrs = true;
}
function renderComponentRoot(instance) {
const {
type: Component,
vnode,
proxy,
withProxy,
props,
propsOptions: [propsOptions],
slots,
attrs,
emit: emit2,
render: render2,
renderCache,
data,
setupState,
ctx,
inheritAttrs
} = instance;
let result;
let fallthroughAttrs;
const prev = setCurrentRenderingInstance(instance);
{
accessedAttrs = false;
}
try {
if (vnode.shapeFlag & 4) {
const proxyToUse = withProxy || proxy;
result = normalizeVNode(
render2.call(
proxyToUse,
proxyToUse,
renderCache,
props,
setupState,
data,
ctx
)
);
fallthroughAttrs = attrs;
} else {
const render22 = Component;
if (attrs === props) {
markAttrsAccessed();
}
result = normalizeVNode(
render22.length > 1 ? render22(
props,
true ? {
get attrs() {
markAttrsAccessed();
return attrs;
},
slots,
emit: emit2
} : { attrs, slots, emit: emit2 }
) : render22(
props,
null
/* we know it doesn't need it */
)
);
fallthroughAttrs = Component.props ? attrs : getFunctionalFallthrough(attrs);
}
} catch (err) {
blockStack.length = 0;
handleError(err, instance, 1);
result = createVNode(Comment);
}
let root = result;
let setRoot = void 0;
if (result.patchFlag > 0 && result.patchFlag & 2048) {
[root, setRoot] = getChildRoot(result);
}
if (fallthroughAttrs && inheritAttrs !== false) {
const keys = Object.keys(fallthroughAttrs);
const { shapeFlag } = root;
if (keys.length) {
if (shapeFlag & (1 | 6)) {
if (propsOptions && keys.some(isModelListener)) {
fallthroughAttrs = filterModelListeners(
fallthroughAttrs,
propsOptions
);
}
root = cloneVNode(root, fallthroughAttrs);
} else if (!accessedAttrs && root.type !== Comment) {
const allAttrs = Object.keys(attrs);
const eventAttrs = [];
const extraAttrs = [];
for (let i2 = 0, l = allAttrs.length; i2 < l; i2++) {
const key = allAttrs[i2];
if (isOn(key)) {
if (!isModelListener(key)) {
eventAttrs.push(key[2].toLowerCase() + key.slice(3));
}
} else {
extraAttrs.push(key);
}
}
if (extraAttrs.length) {
warn$2(
`Extraneous non-props attributes (${extraAttrs.join(", ")}) were passed to component but could not be automatically inherited because component renders fragment or text root nodes.`
);
}
if (eventAttrs.length) {
warn$2(
`Extraneous non-emits event listeners (${eventAttrs.join(", ")}) were passed to component but could not be automatically inherited because component renders fragment or text root nodes. If the listener is intended to be a component custom event listener only, declare it using the "emits" option.`
);
}
}
}
}
if (vnode.dirs) {
if (!isElementRoot(root)) {
warn$2(
`Runtime directive used on component with non-element root node. The directives will not function as intended.`
);
}
root = cloneVNode(root);
root.dirs = root.dirs ? root.dirs.concat(vnode.dirs) : vnode.dirs;
}
if (vnode.transition) {
if (!isElementRoot(root)) {
warn$2(
`Component inside <Transition> renders non-element root node that cannot be animated.`
);
}
root.transition = vnode.transition;
}
if (setRoot) {
setRoot(root);
} else {
result = root;
}
setCurrentRenderingInstance(prev);
return result;
}
const getChildRoot = (vnode) => {
const rawChildren = vnode.children;
const dynamicChildren = vnode.dynamicChildren;
const childRoot = filterSingleRoot(rawChildren);
if (!childRoot) {
return [vnode, void 0];
}
const index2 = rawChildren.indexOf(childRoot);
const dynamicIndex = dynamicChildren ? dynamicChildren.indexOf(childRoot) : -1;
const setRoot = (updatedRoot) => {
rawChildren[index2] = updatedRoot;
if (dynamicChildren) {
if (dynamicIndex > -1) {
dynamicChildren[dynamicIndex] = updatedRoot;
} else if (updatedRoot.patchFlag > 0) {
vnode.dynamicChildren = [...dynamicChildren, updatedRoot];
}
}
};
return [normalizeVNode(childRoot), setRoot];
};
function filterSingleRoot(children2) {
let singleRoot;
for (let i2 = 0; i2 < children2.length; i2++) {
const child = children2[i2];
if (isVNode(child)) {
if (child.type !== Comment || child.children === "v-if") {
if (singleRoot) {
return;
} else {
singleRoot = child;
}
}
} else {
return;
}
}
return singleRoot;
}
const getFunctionalFallthrough = (attrs) => {
let res;
for (const key in attrs) {
if (key === "class" || key === "style" || isOn(key)) {
(res || (res = {}))[key] = attrs[key];
}
}
return res;
};
const filterModelListeners = (attrs, props) => {
const res = {};
for (const key in attrs) {
if (!isModelListener(key) || !(key.slice(9) in props)) {
res[key] = attrs[key];
}
}
return res;
};
const isElementRoot = (vnode) => {
return vnode.shapeFlag & (6 | 1) || vnode.type === Comment;
};
function shouldUpdateComponent(prevVNode, nextVNode, optimized) {
const { props: prevProps, children: prevChildren, component } = prevVNode;
const { props: nextProps, children: nextChildren, patchFlag } = nextVNode;
const emits = component.emitsOptions;
if ((prevChildren || nextChildren) && isHmrUpdating) {
return true;
}
if (nextVNode.dirs || nextVNode.transition) {
return true;
}
if (optimized && patchFlag >= 0) {
if (patchFlag & 1024) {
return true;
}
if (patchFlag & 16) {
if (!prevProps) {
return !!nextProps;
}
return hasPropsChanged(prevProps, nextProps, emits);
} else if (patchFlag & 8) {
const dynamicProps = nextVNode.dynamicProps;
for (let i2 = 0; i2 < dynamicProps.length; i2++) {
const key = dynamicProps[i2];
if (nextProps[key] !== prevProps[key] && !isEmitListener(emits, key)) {
return true;
}
}
}
} else {
if (prevChildren || nextChildren) {
if (!nextChildren || !nextChildren.$stable) {
return true;
}
}
if (prevProps === nextProps) {
return false;
}
if (!prevProps) {
return !!nextProps;
}
if (!nextProps) {
return true;
}
return hasPropsChanged(prevProps, nextProps, emits);
}
return false;
}
function hasPropsChanged(prevProps, nextProps, emitsOptions) {
const nextKeys = Object.keys(nextProps);
if (nextKeys.length !== Object.keys(prevProps).length) {
return true;
}
for (let i2 = 0; i2 < nextKeys.length; i2++) {
const key = nextKeys[i2];
if (nextProps[key] !== prevProps[key] && !isEmitListener(emitsOptions, key)) {
return true;
}
}
return false;
}
function updateHOCHostEl({ vnode, parent }, el2) {
while (parent && parent.subTree === vnode) {
(vnode = parent.vnode).el = el2;
parent = parent.parent;
}
}
const COMPONENTS = "components";
const DIRECTIVES = "directives";
function resolveComponent(name, maybeSelfReference) {
return resolveAsset(COMPONENTS, name, true, maybeSelfReference) || name;
}
const NULL_DYNAMIC_COMPONENT = Symbol.for("v-ndc");
function resolveDynamicComponent(component) {
if (isString$1(component)) {
return resolveAsset(COMPONENTS, component, false) || component;
} else {
return component || NULL_DYNAMIC_COMPONENT;
}
}
function resolveDirective(name) {
return resolveAsset(DIRECTIVES, name);
}
function resolveAsset(type, name, warnMissing = true, maybeSelfReference = false) {
const instance = currentRenderingInstance || currentInstance;
if (instance) {
const Component = instance.type;
if (type === COMPONENTS) {
const selfName = getComponentName(
Component,
false
/* do not include inferred name to avoid breaking existing code */
);
if (selfName && (selfName === name || selfName === camelize(name) || selfName === capitalize(camelize(name)))) {
return Component;
}
}
const res = (
// local registration
// check instance[type] first which is resolved for options API
resolve(instance[type] || Component[type], name) || // global registration
resolve(instance.appContext[type], name)
);
if (!res && maybeSelfReference) {
return Component;
}
if (warnMissing && !res) {
const extra = type === COMPONENTS ? `
If this is a native custom element, make sure to exclude it from component resolution via compilerOptions.isCustomElement.` : ``;
warn$2(`Failed to resolve ${type.slice(0, -1)}: ${name}${extra}`);
}
return res;
} else {
warn$2(
`resolve${capitalize(type.slice(0, -1))} can only be used in render() or setup().`
);
}
}
function resolve(registry, name) {
return registry && (registry[name] || registry[camelize(name)] || registry[capitalize(camelize(name))]);
}
const isSuspense = (type) => type.__isSuspense;
function queueEffectWithSuspense(fn2, suspense) {
if (suspense && suspense.pendingBranch) {
if (isArray$1(fn2)) {
suspense.effects.push(...fn2);
} else {
suspense.effects.push(fn2);
}
} else {
queuePostFlushCb(fn2);
}
}
function watchEffect(effect2, options) {
return doWatch(effect2, null, options);
}
function watchPostEffect(effect2, options) {
return doWatch(
effect2,
null,
extend({}, options, { flush: "post" })
);
}
const INITIAL_WATCHER_VALUE = {};
function watch(source, cb, options) {
if (!isFunction$1(cb)) {
warn$2(
`\`watch(fn, options?)\` signature has been moved to a separate API. Use \`watchEffect(fn, options?)\` instead. \`watch\` now only supports \`watch(source, cb, options?) signature.`
);
}
return doWatch(source, cb, options);
}
function doWatch(source, cb, { immediate, deep, flush: flush2, onTrack, onTrigger } = EMPTY_OBJ) {
var _a2;
if (!cb) {
if (immediate !== void 0) {
warn$2(
`watch() "immediate" option is only respected when using the watch(source, callback, options?) signature.`
);
}
if (deep !== void 0) {
warn$2(
`watch() "deep" option is only respected when using the watch(source, callback, options?) signature.`
);
}
}
const warnInvalidSource = (s) => {
warn$2(
`Invalid watch source: `,
s,
`A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types.`
);
};
const instance = getCurrentScope() === ((_a2 = currentInstance) == null ? void 0 : _a2.scope) ? currentInstance : null;
let getter;
let forceTrigger = false;
let isMultiSource = false;
if (isRef(source)) {
getter = () => source.value;
forceTrigger = isShallow$1(source);
} else if (isReactive(source)) {
getter = () => source;
deep = true;
} else if (isArray$1(source)) {
isMultiSource = true;
forceTrigger = source.some((s) => isReactive(s) || isShallow$1(s));
getter = () => source.map((s) => {
if (isRef(s)) {
return s.value;
} else if (isReactive(s)) {
return traverse(s);
} else if (isFunction$1(s)) {
return callWithErrorHandling(s, instance, 2);
} else {
warnInvalidSource(s);
}
});
} else if (isFunction$1(source)) {
if (cb) {
getter = () => callWithErrorHandling(source, instance, 2);
} else {
getter = () => {
if (instance && instance.isUnmounted) {
return;
}
if (cleanup) {
cleanup();
}
return callWithAsyncErrorHandling(
source,
instance,
3,
[onCleanup]
);
};
}
} else {
getter = NOOP;
warnInvalidSource(source);
}
if (cb && deep) {
const baseGetter = getter;
getter = () => traverse(baseGetter());
}
let cleanup;
let onCleanup = (fn2) => {
cleanup = effect2.onStop = () => {
callWithErrorHandling(fn2, instance, 4);
};
};
let ssrCleanup;
if (isInSSRComponentSetup) {
onCleanup = NOOP;
if (!cb) {
getter();
} else if (immediate) {
callWithAsyncErrorHandling(cb, instance, 3, [
getter(),
isMultiSource ? [] : void 0,
onCleanup
]);
}
if (flush2 === "sync") {
const ctx = useSSRContext();
ssrCleanup = ctx.__watcherHandles || (ctx.__watcherHandles = []);
} else {
return NOOP;
}
}
let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
const job = () => {
if (!effect2.active) {
return;
}
if (cb) {
const newValue = effect2.run();
if (deep || forceTrigger || (isMultiSource ? newValue.some((v2, i2) => hasChanged(v2, oldValue[i2])) : hasChanged(newValue, oldValue)) || false) {
if (cleanup) {
cleanup();
}
callWithAsyncErrorHandling(cb, instance, 3, [
newValue,
// pass undefined as the old value when it's changed for the first time
oldValue === INITIAL_WATCHER_VALUE ? void 0 : isMultiSource && oldValue[0] === INITIAL_WATCHER_VALUE ? [] : oldValue,
onCleanup
]);
oldValue = newValue;
}
} else {
effect2.run();
}
};
job.allowRecurse = !!cb;
let scheduler2;
if (flush2 === "sync") {
scheduler2 = job;
} else if (flush2 === "post") {
scheduler2 = () => queuePostRenderEffect(job, instance && instance.suspense);
} else {
job.pre = true;
if (instance)
job.id = instance.uid;
scheduler2 = () => queueJob(job);
}
const effect2 = new ReactiveEffect(getter, scheduler2);
{
effect2.onTrack = onTrack;
effect2.onTrigger = onTrigger;
}
if (cb) {
if (immediate) {
job();
} else {
oldValue = effect2.run();
}
} else if (flush2 === "post") {
queuePostRenderEffect(
effect2.run.bind(effect2),
instance && instance.suspense
);
} else {
effect2.run();
}
const unwatch = () => {
effect2.stop();
if (instance && instance.scope) {
remove(instance.scope.effects, effect2);
}
};
if (ssrCleanup)
ssrCleanup.push(unwatch);
return unwatch;
}
function instanceWatch(source, value, options) {
const publicThis = this.proxy;
const getter = isString$1(source) ? source.includes(".") ? createPathGetter(publicThis, source) : () => publicThis[source] : source.bind(publicThis, publicThis);
let cb;
if (isFunction$1(value)) {
cb = value;
} else {
cb = value.handler;
options = value;
}
const cur = currentInstance;
setCurrentInstance(this);
const res = doWatch(getter, cb.bind(publicThis), options);
if (cur) {
setCurrentInstance(cur);
} else {
unsetCurrentInstance();
}
return res;
}
function createPathGetter(ctx, path) {
const segments = path.split(".");
return () => {
let cur = ctx;
for (let i2 = 0; i2 < segments.length && cur; i2++) {
cur = cur[segments[i2]];
}
return cur;
};
}
function traverse(value, seen) {
if (!isObject(value) || value["__v_skip"]) {
return value;
}
seen = seen || /* @__PURE__ */ new Set();
if (seen.has(value)) {
return value;
}
seen.add(value);
if (isRef(value)) {
traverse(value.value, seen);
} else if (isArray$1(value)) {
for (let i2 = 0; i2 < value.length; i2++) {
traverse(value[i2], seen);
}
} else if (isSet(value) || isMap(value)) {
value.forEach((v2) => {
traverse(v2, seen);
});
} else if (isPlainObject$1(value)) {
for (const key in value) {
traverse(value[key], seen);
}
}
return value;
}
function validateDirectiveName(name) {
if (isBuiltInDirective(name)) {
warn$2("Do not use built-in directive ids as custom directive id: " + name);
}
}
function withDirectives(vnode, directives2) {
const internalInstance = currentRenderingInstance;
if (internalInstance === null) {
warn$2(`withDirectives can only be used inside render functions.`);
return vnode;
}
const instance = getExposeProxy(internalInstance) || internalInstance.proxy;
const bindings = vnode.dirs || (vnode.dirs = []);
for (let i2 = 0; i2 < directives2.length; i2++) {
let [dir, value, arg, modifiers = EMPTY_OBJ] = directives2[i2];
if (dir) {
if (isFunction$1(dir)) {
dir = {
mounted: dir,
updated: dir
};
}
if (dir.deep) {
traverse(value);
}
bindings.push({
dir,
instance,
value,
oldValue: void 0,
arg,
modifiers
});
}
}
return vnode;
}
function invokeDirectiveHook(vnode, prevVNode, instance, name) {
const bindings = vnode.dirs;
const oldBindings = prevVNode && prevVNode.dirs;
for (let i2 = 0; i2 < bindings.length; i2++) {
const binding = bindings[i2];
if (oldBindings) {
binding.oldValue = oldBindings[i2].value;
}
let hook = binding.dir[name];
if (hook) {
pauseTracking();
callWithAsyncErrorHandling(hook, instance, 8, [
vnode.el,
binding,
vnode,
prevVNode
]);
resetTracking();
}
}
}
const leaveCbKey = Symbol("_leaveCb");
const enterCbKey$1 = Symbol("_enterCb");
function useTransitionState() {
const state = {
isMounted: false,
isLeaving: false,
isUnmounting: false,
leavingVNodes: /* @__PURE__ */ new Map()
};
onMounted(() => {
state.isMounted = true;
});
onBeforeUnmount(() => {
state.isUnmounting = true;
});
return state;
}
const TransitionHookValidator = [Function, Array];
const BaseTransitionPropsValidators = {
mode: String,
appear: Boolean,
persisted: Boolean,
// enter
onBeforeEnter: TransitionHookValidator,
onEnter: TransitionHookValidator,
onAfterEnter: TransitionHookValidator,
onEnterCancelled: TransitionHookValidator,
// leave
onBeforeLeave: TransitionHookValidator,
onLeave: TransitionHookValidator,
onAfterLeave: TransitionHookValidator,
onLeaveCancelled: TransitionHookValidator,
// appear
onBeforeAppear: TransitionHookValidator,
onAppear: TransitionHookValidator,
onAfterAppear: TransitionHookValidator,
onAppearCancelled: TransitionHookValidator
};
const BaseTransitionImpl = {
name: `BaseTransition`,
props: BaseTransitionPropsValidators,
setup(props, { slots }) {
const instance = getCurrentInstance();
const state = useTransitionState();
let prevTransitionKey;
return () => {
const children2 = slots.default && getTransitionRawChildren(slots.default(), true);
if (!children2 || !children2.length) {
return;
}
let child = children2[0];
if (children2.length > 1) {
let hasFound = false;
for (const c2 of children2) {
if (c2.type !== Comment) {
if (hasFound) {
warn$2(
"<transition> can only be used on a single element or component. Use <transition-group> for lists."
);
break;
}
child = c2;
hasFound = true;
}
}
}
const rawProps = toRaw(props);
const { mode } = rawProps;
if (mode && mode !== "in-out" && mode !== "out-in" && mode !== "default") {
warn$2(`invalid <transition> mode: ${mode}`);
}
if (state.isLeaving) {
return emptyPlaceholder(child);
}
const innerChild = getKeepAliveChild(child);
if (!innerChild) {
return emptyPlaceholder(child);
}
const enterHooks = resolveTransitionHooks(
innerChild,
rawProps,
state,
instance
);
setTransitionHooks(innerChild, enterHooks);
const oldChild = instance.subTree;
const oldInnerChild = oldChild && getKeepAliveChild(oldChild);
let transitionKeyChanged = false;
const { getTransitionKey } = innerChild.type;
if (getTransitionKey) {
const key = getTransitionKey();
if (prevTransitionKey === void 0) {
prevTransitionKey = key;
} else if (key !== prevTransitionKey) {
prevTransitionKey = key;
transitionKeyChanged = true;
}
}
if (oldInnerChild && oldInnerChild.type !== Comment && (!isSameVNodeType(innerChild, oldInnerChild) || transitionKeyChanged)) {
const leavingHooks = resolveTransitionHooks(
oldInnerChild,
rawProps,
state,
instance
);
setTransitionHooks(oldInnerChild, leavingHooks);
if (mode === "out-in") {
state.isLeaving = true;
leavingHooks.afterLeave = () => {
state.isLeaving = false;
if (instance.update.active !== false) {
instance.update();
}
};
return emptyPlaceholder(child);
} else if (mode === "in-out" && innerChild.type !== Comment) {
leavingHooks.delayLeave = (el2, earlyRemove, delayedLeave) => {
const leavingVNodesCache = getLeavingNodesForType(
state,
oldInnerChild
);
leavingVNodesCache[String(oldInnerChild.key)] = oldInnerChild;
el2[leaveCbKey] = () => {
earlyRemove();
el2[leaveCbKey] = void 0;
delete enterHooks.delayedLeave;
};
enterHooks.delayedLeave = delayedLeave;
};
}
}
return child;
};
}
};
const BaseTransition = BaseTransitionImpl;
function getLeavingNodesForType(state, vnode) {
const { leavingVNodes } = state;
let leavingVNodesCache = leavingVNodes.get(vnode.type);
if (!leavingVNodesCache) {
leavingVNodesCache = /* @__PURE__ */ Object.create(null);
leavingVNodes.set(vnode.type, leavingVNodesCache);
}
return leavingVNodesCache;
}
function resolveTransitionHooks(vnode, props, state, instance) {
const {
appear,
mode,
persisted = false,
onBeforeEnter,
onEnter,
onAfterEnter,
onEnterCancelled,
onBeforeLeave,
onLeave,
onAfterLeave,
onLeaveCancelled,
onBeforeAppear,
onAppear,
onAfterAppear,
onAppearCancelled
} = props;
const key = String(vnode.key);
const leavingVNodesCache = getLeavingNodesForType(state, vnode);
const callHook2 = (hook, args) => {
hook && callWithAsyncErrorHandling(
hook,
instance,
9,
args
);
};
const callAsyncHook = (hook, args) => {
const done = args[1];
callHook2(hook, args);
if (isArray$1(hook)) {
if (hook.every((hook2) => hook2.length <= 1))
done();
} else if (hook.length <= 1) {
done();
}
};
const hooks = {
mode,
persisted,
beforeEnter(el2) {
let hook = onBeforeEnter;
if (!state.isMounted) {
if (appear) {
hook = onBeforeAppear || onBeforeEnter;
} else {
return;
}
}
if (el2[leaveCbKey]) {
el2[leaveCbKey](
true
/* cancelled */
);
}
const leavingVNode = leavingVNodesCache[key];
if (leavingVNode && isSameVNodeType(vnode, leavingVNode) && leavingVNode.el[leaveCbKey]) {
leavingVNode.el[leaveCbKey]();
}
callHook2(hook, [el2]);
},
enter(el2) {
let hook = onEnter;
let afterHook = onAfterEnter;
let cancelHook = onEnterCancelled;
if (!state.isMounted) {
if (appear) {
hook = onAppear || onEnter;
afterHook = onAfterAppear || onAfterEnter;
cancelHook = onAppearCancelled || onEnterCancelled;
} else {
return;
}
}
let called = false;
const done = el2[enterCbKey$1] = (cancelled) => {
if (called)
return;
called = true;
if (cancelled) {
callHook2(cancelHook, [el2]);
} else {
callHook2(afterHook, [el2]);
}
if (hooks.delayedLeave) {
hooks.delayedLeave();
}
el2[enterCbKey$1] = void 0;
};
if (hook) {
callAsyncHook(hook, [el2, done]);
} else {
done();
}
},
leave(el2, remove2) {
const key2 = String(vnode.key);
if (el2[enterCbKey$1]) {
el2[enterCbKey$1](
true
/* cancelled */
);
}
if (state.isUnmounting) {
return remove2();
}
callHook2(onBeforeLeave, [el2]);
let called = false;
const done = el2[leaveCbKey] = (cancelled) => {
if (called)
return;
called = true;
remove2();
if (cancelled) {
callHook2(onLeaveCancelled, [el2]);
} else {
callHook2(onAfterLeave, [el2]);
}
el2[leaveCbKey] = void 0;
if (leavingVNodesCache[key2] === vnode) {
delete leavingVNodesCache[key2];
}
};
leavingVNodesCache[key2] = vnode;
if (onLeave) {
callAsyncHook(onLeave, [el2, done]);
} else {
done();
}
},
clone(vnode2) {
return resolveTransitionHooks(vnode2, props, state, instance);
}
};
return hooks;
}
function emptyPlaceholder(vnode) {
if (isKeepAlive(vnode)) {
vnode = cloneVNode(vnode);
vnode.children = null;
return vnode;
}
}
function getKeepAliveChild(vnode) {
return isKeepAlive(vnode) ? vnode.children ? vnode.children[0] : void 0 : vnode;
}
function setTransitionHooks(vnode, hooks) {
if (vnode.shapeFlag & 6 && vnode.component) {
setTransitionHooks(vnode.component.subTree, hooks);
} else if (vnode.shapeFlag & 128) {
vnode.ssContent.transition = hooks.clone(vnode.ssContent);
vnode.ssFallback.transition = hooks.clone(vnode.ssFallback);
} else {
vnode.transition = hooks;
}
}
function getTransitionRawChildren(children2, keepComment = false, parentKey) {
let ret = [];
let keyedFragmentCount = 0;
for (let i2 = 0; i2 < children2.length; i2++) {
let child = children2[i2];
const key = parentKey == null ? child.key : String(parentKey) + String(child.key != null ? child.key : i2);
if (child.type === Fragment) {
if (child.patchFlag & 128)
keyedFragmentCount++;
ret = ret.concat(
getTransitionRawChildren(child.children, keepComment, key)
);
} else if (keepComment || child.type !== Comment) {
ret.push(key != null ? cloneVNode(child, { key }) : child);
}
}
if (keyedFragmentCount > 1) {
for (let i2 = 0; i2 < ret.length; i2++) {
ret[i2].patchFlag = -2;
}
}
return ret;
}
/*! #__NO_SIDE_EFFECTS__ */
// @__NO_SIDE_EFFECTS__
function defineComponent(options, extraOptions) {
return isFunction$1(options) ? (
// #8326: extend call and options.name access are considered side-effects
// by Rollup, so we have to wrap it in a pure-annotated IIFE.
/* @__PURE__ */ (() => extend({ name: options.name }, extraOptions, { setup: options }))()
) : options;
}
const isAsyncWrapper = (i2) => !!i2.type.__asyncLoader;
/*! #__NO_SIDE_EFFECTS__ */
// @__NO_SIDE_EFFECTS__
function defineAsyncComponent(source) {
if (isFunction$1(source)) {
source = { loader: source };
}
const {
loader,
loadingComponent,
errorComponent,
delay = 200,
timeout,
// undefined = never times out
suspensible = true,
onError: userOnError
} = source;
let pendingRequest = null;
let resolvedComp;
let retries = 0;
const retry = () => {
retries++;
pendingRequest = null;
return load();
};
const load = () => {
let thisRequest;
return pendingRequest || (thisRequest = pendingRequest = loader().catch((err) => {
err = err instanceof Error ? err : new Error(String(err));
if (userOnError) {
return new Promise((resolve2, reject) => {
const userRetry = () => resolve2(retry());
const userFail = () => reject(err);
userOnError(err, userRetry, userFail, retries + 1);
});
} else {
throw err;
}
}).then((comp) => {
if (thisRequest !== pendingRequest && pendingRequest) {
return pendingRequest;
}
if (!comp) {
warn$2(
`Async component loader resolved to undefined. If you are using retry(), make sure to return its return value.`
);
}
if (comp && (comp.__esModule || comp[Symbol.toStringTag] === "Module")) {
comp = comp.default;
}
if (comp && !isObject(comp) && !isFunction$1(comp)) {
throw new Error(`Invalid async component load result: ${comp}`);
}
resolvedComp = comp;
return comp;
}));
};
return /* @__PURE__ */ defineComponent({
name: "AsyncComponentWrapper",
__asyncLoader: load,
get __asyncResolved() {
return resolvedComp;
},
setup() {
const instance = currentInstance;
if (resolvedComp) {
return () => createInnerComp(resolvedComp, instance);
}
const onError = (err) => {
pendingRequest = null;
handleError(
err,
instance,
13,
!errorComponent
/* do not throw in dev if user provided error component */
);
};
if (suspensible && instance.suspense || isInSSRComponentSetup) {
return load().then((comp) => {
return () => createInnerComp(comp, instance);
}).catch((err) => {
onError(err);
return () => errorComponent ? createVNode(errorComponent, {
error: err
}) : null;
});
}
const loaded2 = ref(false);
const error = ref();
const delayed = ref(!!delay);
if (delay) {
setTimeout(() => {
delayed.value = false;
}, delay);
}
if (timeout != null) {
setTimeout(() => {
if (!loaded2.value && !error.value) {
const err = new Error(
`Async component timed out after ${timeout}ms.`
);
onError(err);
error.value = err;
}
}, timeout);
}
load().then(() => {
loaded2.value = true;
if (instance.parent && isKeepAlive(instance.parent.vnode)) {
queueJob(instance.parent.update);
}
}).catch((err) => {
onError(err);
error.value = err;
});
return () => {
if (loaded2.value && resolvedComp) {
return createInnerComp(resolvedComp, instance);
} else if (error.value && errorComponent) {
return createVNode(errorComponent, {
error: error.value
});
} else if (loadingComponent && !delayed.value) {
return createVNode(loadingComponent);
}
};
}
});
}
function createInnerComp(comp, parent) {
const { ref: ref2, props, children: children2, ce: ce2 } = parent.vnode;
const vnode = createVNode(comp, props, children2);
vnode.ref = ref2;
vnode.ce = ce2;
delete parent.vnode.ce;
return vnode;
}
const isKeepAlive = (vnode) => vnode.type.__isKeepAlive;
function onActivated(hook, target) {
registerKeepAliveHook(hook, "a", target);
}
function onDeactivated(hook, target) {
registerKeepAliveHook(hook, "da", target);
}
function registerKeepAliveHook(hook, type, target = currentInstance) {
const wrappedHook = hook.__wdc || (hook.__wdc = () => {
let current = target;
while (current) {
if (current.isDeactivated) {
return;
}
current = current.parent;
}
return hook();
});
injectHook(type, wrappedHook, target);
if (target) {
let current = target.parent;
while (current && current.parent) {
if (isKeepAlive(current.parent.vnode)) {
injectToKeepAliveRoot(wrappedHook, type, target, current);
}
current = current.parent;
}
}
}
function injectToKeepAliveRoot(hook, type, target, keepAliveRoot) {
const injected = injectHook(
type,
hook,
keepAliveRoot,
true
/* prepend */
);
onUnmounted(() => {
remove(keepAliveRoot[type], injected);
}, target);
}
function injectHook(type, hook, target = currentInstance, prepend = false) {
if (target) {
const hooks = target[type] || (target[type] = []);
const wrappedHook = hook.__weh || (hook.__weh = (...args) => {
if (target.isUnmounted) {
return;
}
pauseTracking();
setCurrentInstance(target);
const res = callWithAsyncErrorHandling(hook, target, type, args);
unsetCurrentInstance();
resetTracking();
return res;
});
if (prepend) {
hooks.unshift(wrappedHook);
} else {
hooks.push(wrappedHook);
}
return wrappedHook;
} else {
const apiName = toHandlerKey(ErrorTypeStrings[type].replace(/ hook$/, ""));
warn$2(
`${apiName} is called when there is no active component instance to be associated with. Lifecycle injection APIs can only be used during execution of setup(). If you are using async setup(), make sure to register lifecycle hooks before the first await statement.`
);
}
}
const createHook = (lifecycle) => (hook, target = currentInstance) => (
// post-create lifecycle registrations are noops during SSR (except for serverPrefetch)
(!isInSSRComponentSetup || lifecycle === "sp") && injectHook(lifecycle, (...args) => hook(...args), target)
);
const onBeforeMount = createHook("bm");
const onMounted = createHook("m");
const onBeforeUpdate = createHook("bu");
const onUpdated = createHook("u");
const onBeforeUnmount = createHook("bum");
const onUnmounted = createHook("um");
const onServerPrefetch = createHook("sp");
const onRenderTriggered = createHook(
"rtg"
);
const onRenderTracked = createHook(
"rtc"
);
function onErrorCaptured(hook, target = currentInstance) {
injectHook("ec", hook, target);
}
function renderList(source, renderItem, cache2, index2) {
let ret;
const cached = cache2 && cache2[index2];
if (isArray$1(source) || isString$1(source)) {
ret = new Array(source.length);
for (let i2 = 0, l = source.length; i2 < l; i2++) {
ret[i2] = renderItem(source[i2], i2, void 0, cached && cached[i2]);
}
} else if (typeof source === "number") {
if (!Number.isInteger(source)) {
warn$2(`The v-for range expect an integer value but got ${source}.`);
}
ret = new Array(source);
for (let i2 = 0; i2 < source; i2++) {
ret[i2] = renderItem(i2 + 1, i2, void 0, cached && cached[i2]);
}
} else if (isObject(source)) {
if (source[Symbol.iterator]) {
ret = Array.from(
source,
(item, i2) => renderItem(item, i2, void 0, cached && cached[i2])
);
} else {
const keys = Object.keys(source);
ret = new Array(keys.length);
for (let i2 = 0, l = keys.length; i2 < l; i2++) {
const key = keys[i2];
ret[i2] = renderItem(source[key], key, i2, cached && cached[i2]);
}
}
} else {
ret = [];
}
if (cache2) {
cache2[index2] = ret;
}
return ret;
}
function renderSlot(slots, name, props = {}, fallback, noSlotted) {
if (currentRenderingInstance.isCE || currentRenderingInstance.parent && isAsyncWrapper(currentRenderingInstance.parent) && currentRenderingInstance.parent.isCE) {
if (name !== "default")
props.name = name;
return createVNode("slot", props, fallback && fallback());
}
let slot = slots[name];
if (slot && slot.length > 1) {
warn$2(
`SSR-optimized slot function detected in a non-SSR-optimized render function. You need to mark this component with $dynamic-slots in the parent template.`
);
slot = () => [];
}
if (slot && slot._c) {
slot._d = false;
}
openBlock();
const validSlotContent = slot && ensureValidVNode(slot(props));
const rendered = createBlock(
Fragment,
{
key: props.key || // slot content array of a dynamic conditional slot may have a branch
// key attached in the `createSlots` helper, respect that
validSlotContent && validSlotContent.key || `_${name}`
},
validSlotContent || (fallback ? fallback() : []),
validSlotContent && slots._ === 1 ? 64 : -2
);
if (!noSlotted && rendered.scopeId) {
rendered.slotScopeIds = [rendered.scopeId + "-s"];
}
if (slot && slot._c) {
slot._d = true;
}
return rendered;
}
function ensureValidVNode(vnodes) {
return vnodes.some((child) => {
if (!isVNode(child))
return true;
if (child.type === Comment)
return false;
if (child.type === Fragment && !ensureValidVNode(child.children))
return false;
return true;
}) ? vnodes : null;
}
const getPublicInstance = (i2) => {
if (!i2)
return null;
if (isStatefulComponent(i2))
return getExposeProxy(i2) || i2.proxy;
return getPublicInstance(i2.parent);
};
const publicPropertiesMap = (
// Move PURE marker to new line to workaround compiler discarding it
// due to type annotation
/* @__PURE__ */ extend(/* @__PURE__ */ Object.create(null), {
$: (i2) => i2,
$el: (i2) => i2.vnode.el,
$data: (i2) => i2.data,
$props: (i2) => shallowReadonly(i2.props),
$attrs: (i2) => shallowReadonly(i2.attrs),
$slots: (i2) => shallowReadonly(i2.slots),
$refs: (i2) => shallowReadonly(i2.refs),
$parent: (i2) => getPublicInstance(i2.parent),
$root: (i2) => getPublicInstance(i2.root),
$emit: (i2) => i2.emit,
$options: (i2) => resolveMergedOptions(i2),
$forceUpdate: (i2) => i2.f || (i2.f = () => queueJob(i2.update)),
$nextTick: (i2) => i2.n || (i2.n = nextTick.bind(i2.proxy)),
$watch: (i2) => instanceWatch.bind(i2)
})
);
const isReservedPrefix = (key) => key === "_" || key === "$";
const hasSetupBinding = (state, key) => state !== EMPTY_OBJ && !state.__isScriptSetup && hasOwn(state, key);
const PublicInstanceProxyHandlers = {
get({ _: instance }, key) {
const { ctx, setupState, data, props, accessCache, type, appContext } = instance;
if (key === "__isVue") {
return true;
}
let normalizedProps;
if (key[0] !== "$") {
const n2 = accessCache[key];
if (n2 !== void 0) {
switch (n2) {
case 1:
return setupState[key];
case 2:
return data[key];
case 4:
return ctx[key];
case 3:
return props[key];
}
} else if (hasSetupBinding(setupState, key)) {
accessCache[key] = 1;
return setupState[key];
} else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
accessCache[key] = 2;
return data[key];
} else if (
// only cache other properties when instance has declared (thus stable)
// props
(normalizedProps = instance.propsOptions[0]) && hasOwn(normalizedProps, key)
) {
accessCache[key] = 3;
return props[key];
} else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
accessCache[key] = 4;
return ctx[key];
} else if (shouldCacheAccess) {
accessCache[key] = 0;
}
}
const publicGetter = publicPropertiesMap[key];
let cssModule, globalProperties;
if (publicGetter) {
if (key === "$attrs") {
track(instance, "get", key);
markAttrsAccessed();
} else if (key === "$slots") {
track(instance, "get", key);
}
return publicGetter(instance);
} else if (
// css module (injected by vue-loader)
(cssModule = type.__cssModules) && (cssModule = cssModule[key])
) {
return cssModule;
} else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
accessCache[key] = 4;
return ctx[key];
} else if (
// global properties
globalProperties = appContext.config.globalProperties, hasOwn(globalProperties, key)
) {
{
return globalProperties[key];
}
} else if (currentRenderingInstance && (!isString$1(key) || // #1091 avoid internal isRef/isVNode checks on component instance leading
// to infinite warning loop
key.indexOf("__v") !== 0)) {
if (data !== EMPTY_OBJ && isReservedPrefix(key[0]) && hasOwn(data, key)) {
warn$2(
`Property ${JSON.stringify(
key
)} must be accessed via $data because it starts with a reserved character ("$" or "_") and is not proxied on the render context.`
);
} else if (instance === currentRenderingInstance) {
warn$2(
`Property ${JSON.stringify(key)} was accessed during render but is not defined on instance.`
);
}
}
},
set({ _: instance }, key, value) {
const { data, setupState, ctx } = instance;
if (hasSetupBinding(setupState, key)) {
setupState[key] = value;
return true;
} else if (setupState.__isScriptSetup && hasOwn(setupState, key)) {
warn$2(`Cannot mutate <script setup> binding "${key}" from Options API.`);
return false;
} else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
data[key] = value;
return true;
} else if (hasOwn(instance.props, key)) {
warn$2(`Attempting to mutate prop "${key}". Props are readonly.`);
return false;
}
if (key[0] === "$" && key.slice(1) in instance) {
warn$2(
`Attempting to mutate public property "${key}". Properties starting with $ are reserved and readonly.`
);
return false;
} else {
if (key in instance.appContext.config.globalProperties) {
Object.defineProperty(ctx, key, {
enumerable: true,
configurable: true,
value
});
} else {
ctx[key] = value;
}
}
return true;
},
has({
_: { data, setupState, accessCache, ctx, appContext, propsOptions }
}, key) {
let normalizedProps;
return !!accessCache[key] || data !== EMPTY_OBJ && hasOwn(data, key) || hasSetupBinding(setupState, key) || (normalizedProps = propsOptions[0]) && hasOwn(normalizedProps, key) || hasOwn(ctx, key) || hasOwn(publicPropertiesMap, key) || hasOwn(appContext.config.globalProperties, key);
},
defineProperty(target, key, descriptor) {
if (descriptor.get != null) {
target._.accessCache[key] = 0;
} else if (hasOwn(descriptor, "value")) {
this.set(target, key, descriptor.value, null);
}
return Reflect.defineProperty(target, key, descriptor);
}
};
{
PublicInstanceProxyHandlers.ownKeys = (target) => {
warn$2(
`Avoid app logic that relies on enumerating keys on a component instance. The keys will be empty in production mode to avoid performance overhead.`
);
return Reflect.ownKeys(target);
};
}
function createDevRenderContext(instance) {
const target = {};
Object.defineProperty(target, `_`, {
configurable: true,
enumerable: false,
get: () => instance
});
Object.keys(publicPropertiesMap).forEach((key) => {
Object.defineProperty(target, key, {
configurable: true,
enumerable: false,
get: () => publicPropertiesMap[key](instance),
// intercepted by the proxy so no need for implementation,
// but needed to prevent set errors
set: NOOP
});
});
return target;
}
function exposePropsOnRenderContext(instance) {
const {
ctx,
propsOptions: [propsOptions]
} = instance;
if (propsOptions) {
Object.keys(propsOptions).forEach((key) => {
Object.defineProperty(ctx, key, {
enumerable: true,
configurable: true,
get: () => instance.props[key],
set: NOOP
});
});
}
}
function exposeSetupStateOnRenderContext(instance) {
const { ctx, setupState } = instance;
Object.keys(toRaw(setupState)).forEach((key) => {
if (!setupState.__isScriptSetup) {
if (isReservedPrefix(key[0])) {
warn$2(
`setup() return property ${JSON.stringify(
key
)} should not start with "$" or "_" which are reserved prefixes for Vue internals.`
);
return;
}
Object.defineProperty(ctx, key, {
enumerable: true,
configurable: true,
get: () => setupState[key],
set: NOOP
});
}
});
}
function normalizePropsOrEmits(props) {
return isArray$1(props) ? props.reduce(
(normalized, p2) => (normalized[p2] = null, normalized),
{}
) : props;
}
function createDuplicateChecker() {
const cache2 = /* @__PURE__ */ Object.create(null);
return (type, key) => {
if (cache2[key]) {
warn$2(`${type} property "${key}" is already defined in ${cache2[key]}.`);
} else {
cache2[key] = type;
}
};
}
let shouldCacheAccess = true;
function applyOptions(instance) {
const options = resolveMergedOptions(instance);
const publicThis = instance.proxy;
const ctx = instance.ctx;
shouldCacheAccess = false;
if (options.beforeCreate) {
callHook$1(options.beforeCreate, instance, "bc");
}
const {
// state
data: dataOptions,
computed: computedOptions,
methods,
watch: watchOptions,
provide: provideOptions,
inject: injectOptions,
// lifecycle
created,
beforeMount,
mounted,
beforeUpdate,
updated,
activated,
deactivated,
beforeDestroy,
beforeUnmount,
destroyed,
unmounted,
render: render2,
renderTracked,
renderTriggered,
errorCaptured,
serverPrefetch,
// public API
expose,
inheritAttrs,
// assets
components,
directives: directives2,
filters
} = options;
const checkDuplicateProperties = createDuplicateChecker();
{
const [propsOptions] = instance.propsOptions;
if (propsOptions) {
for (const key in propsOptions) {
checkDuplicateProperties("Props", key);
}
}
}
if (injectOptions) {
resolveInjections(injectOptions, ctx, checkDuplicateProperties);
}
if (methods) {
for (const key in methods) {
const methodHandler = methods[key];
if (isFunction$1(methodHandler)) {
{
Object.defineProperty(ctx, key, {
value: methodHandler.bind(publicThis),
configurable: true,
enumerable: true,
writable: true
});
}
{
checkDuplicateProperties("Methods", key);
}
} else {
warn$2(
`Method "${key}" has type "${typeof methodHandler}" in the component definition. Did you reference the function correctly?`
);
}
}
}
if (dataOptions) {
if (!isFunction$1(dataOptions)) {
warn$2(
`The data option must be a function. Plain object usage is no longer supported.`
);
}
const data = dataOptions.call(publicThis, publicThis);
if (isPromise(data)) {
warn$2(
`data() returned a Promise - note data() cannot be async; If you intend to perform data fetching before component renders, use async setup() + <Suspense>.`
);
}
if (!isObject(data)) {
warn$2(`data() should return an object.`);
} else {
instance.data = reactive(data);
{
for (const key in data) {
checkDuplicateProperties("Data", key);
if (!isReservedPrefix(key[0])) {
Object.defineProperty(ctx, key, {
configurable: true,
enumerable: true,
get: () => data[key],
set: NOOP
});
}
}
}
}
}
shouldCacheAccess = true;
if (computedOptions) {
for (const key in computedOptions) {
const opt = computedOptions[key];
const get2 = isFunction$1(opt) ? opt.bind(publicThis, publicThis) : isFunction$1(opt.get) ? opt.get.bind(publicThis, publicThis) : NOOP;
if (get2 === NOOP) {
warn$2(`Computed property "${key}" has no getter.`);
}
const set2 = !isFunction$1(opt) && isFunction$1(opt.set) ? opt.set.bind(publicThis) : () => {
warn$2(
`Write operation failed: computed property "${key}" is readonly.`
);
};
const c2 = computed({
get: get2,
set: set2
});
Object.defineProperty(ctx, key, {
enumerable: true,
configurable: true,
get: () => c2.value,
set: (v2) => c2.value = v2
});
{
checkDuplicateProperties("Computed", key);
}
}
}
if (watchOptions) {
for (const key in watchOptions) {
createWatcher(watchOptions[key], ctx, publicThis, key);
}
}
if (provideOptions) {
const provides = isFunction$1(provideOptions) ? provideOptions.call(publicThis) : provideOptions;
Reflect.ownKeys(provides).forEach((key) => {
provide(key, provides[key]);
});
}
if (created) {
callHook$1(created, instance, "c");
}
function registerLifecycleHook(register, hook) {
if (isArray$1(hook)) {
hook.forEach((_hook) => register(_hook.bind(publicThis)));
} else if (hook) {
register(hook.bind(publicThis));
}
}
registerLifecycleHook(onBeforeMount, beforeMount);
registerLifecycleHook(onMounted, mounted);
registerLifecycleHook(onBeforeUpdate, beforeUpdate);
registerLifecycleHook(onUpdated, updated);
registerLifecycleHook(onActivated, activated);
registerLifecycleHook(onDeactivated, deactivated);
registerLifecycleHook(onErrorCaptured, errorCaptured);
registerLifecycleHook(onRenderTracked, renderTracked);
registerLifecycleHook(onRenderTriggered, renderTriggered);
registerLifecycleHook(onBeforeUnmount, beforeUnmount);
registerLifecycleHook(onUnmounted, unmounted);
registerLifecycleHook(onServerPrefetch, serverPrefetch);
if (isArray$1(expose)) {
if (expose.length) {
const exposed = instance.exposed || (instance.exposed = {});
expose.forEach((key) => {
Object.defineProperty(exposed, key, {
get: () => publicThis[key],
set: (val) => publicThis[key] = val
});
});
} else if (!instance.exposed) {
instance.exposed = {};
}
}
if (render2 && instance.render === NOOP) {
instance.render = render2;
}
if (inheritAttrs != null) {
instance.inheritAttrs = inheritAttrs;
}
if (components)
instance.components = components;
if (directives2)
instance.directives = directives2;
}
function resolveInjections(injectOptions, ctx, checkDuplicateProperties = NOOP) {
if (isArray$1(injectOptions)) {
injectOptions = normalizeInject(injectOptions);
}
for (const key in injectOptions) {
const opt = injectOptions[key];
let injected;
if (isObject(opt)) {
if ("default" in opt) {
injected = inject(
opt.from || key,
opt.default,
true
/* treat default function as factory */
);
} else {
injected = inject(opt.from || key);
}
} else {
injected = inject(opt);
}
if (isRef(injected)) {
Object.defineProperty(ctx, key, {
enumerable: true,
configurable: true,
get: () => injected.value,
set: (v2) => injected.value = v2
});
} else {
ctx[key] = injected;
}
{
checkDuplicateProperties("Inject", key);
}
}
}
function callHook$1(hook, instance, type) {
callWithAsyncErrorHandling(
isArray$1(hook) ? hook.map((h2) => h2.bind(instance.proxy)) : hook.bind(instance.proxy),
instance,
type
);
}
function createWatcher(raw, ctx, publicThis, key) {
const getter = key.includes(".") ? createPathGetter(publicThis, key) : () => publicThis[key];
if (isString$1(raw)) {
const handler = ctx[raw];
if (isFunction$1(handler)) {
watch(getter, handler);
} else {
warn$2(`Invalid watch handler specified by key "${raw}"`, handler);
}
} else if (isFunction$1(raw)) {
watch(getter, raw.bind(publicThis));
} else if (isObject(raw)) {
if (isArray$1(raw)) {
raw.forEach((r2) => createWatcher(r2, ctx, publicThis, key));
} else {
const handler = isFunction$1(raw.handler) ? raw.handler.bind(publicThis) : ctx[raw.handler];
if (isFunction$1(handler)) {
watch(getter, handler, raw);
} else {
warn$2(`Invalid watch handler specified by key "${raw.handler}"`, handler);
}
}
} else {
warn$2(`Invalid watch option: "${key}"`, raw);
}
}
function resolveMergedOptions(instance) {
const base = instance.type;
const { mixins, extends: extendsOptions } = base;
const {
mixins: globalMixins,
optionsCache: cache2,
config: { optionMergeStrategies }
} = instance.appContext;
const cached = cache2.get(base);
let resolved;
if (cached) {
resolved = cached;
} else if (!globalMixins.length && !mixins && !extendsOptions) {
{
resolved = base;
}
} else {
resolved = {};
if (globalMixins.length) {
globalMixins.forEach(
(m) => mergeOptions$1(resolved, m, optionMergeStrategies, true)
);
}
mergeOptions$1(resolved, base, optionMergeStrategies);
}
if (isObject(base)) {
cache2.set(base, resolved);
}
return resolved;
}
function mergeOptions$1(to2, from, strats, asMixin = false) {
const { mixins, extends: extendsOptions } = from;
if (extendsOptions) {
mergeOptions$1(to2, extendsOptions, strats, true);
}
if (mixins) {
mixins.forEach(
(m) => mergeOptions$1(to2, m, strats, true)
);
}
for (const key in from) {
if (asMixin && key === "expose") {
warn$2(
`"expose" option is ignored when declared in mixins or extends. It should only be declared in the base component itself.`
);
} else {
const strat = internalOptionMergeStrats[key] || strats && strats[key];
to2[key] = strat ? strat(to2[key], from[key]) : from[key];
}
}
return to2;
}
const internalOptionMergeStrats = {
data: mergeDataFn,
props: mergeEmitsOrPropsOptions,
emits: mergeEmitsOrPropsOptions,
// objects
methods: mergeObjectOptions,
computed: mergeObjectOptions,
// lifecycle
beforeCreate: mergeAsArray,
created: mergeAsArray,
beforeMount: mergeAsArray,
mounted: mergeAsArray,
beforeUpdate: mergeAsArray,
updated: mergeAsArray,
beforeDestroy: mergeAsArray,
beforeUnmount: mergeAsArray,
destroyed: mergeAsArray,
unmounted: mergeAsArray,
activated: mergeAsArray,
deactivated: mergeAsArray,
errorCaptured: mergeAsArray,
serverPrefetch: mergeAsArray,
// assets
components: mergeObjectOptions,
directives: mergeObjectOptions,
// watch
watch: mergeWatchOptions,
// provide / inject
provide: mergeDataFn,
inject: mergeInject
};
function mergeDataFn(to2, from) {
if (!from) {
return to2;
}
if (!to2) {
return from;
}
return function mergedDataFn() {
return extend(
isFunction$1(to2) ? to2.call(this, this) : to2,
isFunction$1(from) ? from.call(this, this) : from
);
};
}
function mergeInject(to2, from) {
return mergeObjectOptions(normalizeInject(to2), normalizeInject(from));
}
function normalizeInject(raw) {
if (isArray$1(raw)) {
const res = {};
for (let i2 = 0; i2 < raw.length; i2++) {
res[raw[i2]] = raw[i2];
}
return res;
}
return raw;
}
function mergeAsArray(to2, from) {
return to2 ? [...new Set([].concat(to2, from))] : from;
}
function mergeObjectOptions(to2, from) {
return to2 ? extend(/* @__PURE__ */ Object.create(null), to2, from) : from;
}
function mergeEmitsOrPropsOptions(to2, from) {
if (to2) {
if (isArray$1(to2) && isArray$1(from)) {
return [.../* @__PURE__ */ new Set([...to2, ...from])];
}
return extend(
/* @__PURE__ */ Object.create(null),
normalizePropsOrEmits(to2),
normalizePropsOrEmits(from != null ? from : {})
);
} else {
return from;
}
}
function mergeWatchOptions(to2, from) {
if (!to2)
return from;
if (!from)
return to2;
const merged = extend(/* @__PURE__ */ Object.create(null), to2);
for (const key in from) {
merged[key] = mergeAsArray(to2[key], from[key]);
}
return merged;
}
function createAppContext() {
return {
app: null,
config: {
isNativeTag: NO,
performance: false,
globalProperties: {},
optionMergeStrategies: {},
errorHandler: void 0,
warnHandler: void 0,
compilerOptions: {}
},
mixins: [],
components: {},
directives: {},
provides: /* @__PURE__ */ Object.create(null),
optionsCache: /* @__PURE__ */ new WeakMap(),
propsCache: /* @__PURE__ */ new WeakMap(),
emitsCache: /* @__PURE__ */ new WeakMap()
};
}
let uid$1 = 0;
function createAppAPI(render2, hydrate2) {
return function createApp2(rootComponent, rootProps = null) {
if (!isFunction$1(rootComponent)) {
rootComponent = extend({}, rootComponent);
}
if (rootProps != null && !isObject(rootProps)) {
warn$2(`root props passed to app.mount() must be an object.`);
rootProps = null;
}
const context = createAppContext();
{
Object.defineProperty(context.config, "unwrapInjectedRef", {
get() {
return true;
},
set() {
warn$2(
`app.config.unwrapInjectedRef has been deprecated. 3.3 now always unwraps injected refs in Options API.`
);
}
});
}
const installedPlugins = /* @__PURE__ */ new WeakSet();
let isMounted = false;
const app = context.app = {
_uid: uid$1++,
_component: rootComponent,
_props: rootProps,
_container: null,
_context: context,
_instance: null,
version: version$1,
get config() {
return context.config;
},
set config(v2) {
{
warn$2(
`app.config cannot be replaced. Modify individual options instead.`
);
}
},
use(plugin2, ...options) {
if (installedPlugins.has(plugin2)) {
warn$2(`Plugin has already been applied to target app.`);
} else if (plugin2 && isFunction$1(plugin2.install)) {
installedPlugins.add(plugin2);
plugin2.install(app, ...options);
} else if (isFunction$1(plugin2)) {
installedPlugins.add(plugin2);
plugin2(app, ...options);
} else {
warn$2(
`A plugin must either be a function or an object with an "install" function.`
);
}
return app;
},
mixin(mixin) {
{
if (!context.mixins.includes(mixin)) {
context.mixins.push(mixin);
} else {
warn$2(
"Mixin has already been applied to target app" + (mixin.name ? `: ${mixin.name}` : "")
);
}
}
return app;
},
component(name, component) {
{
validateComponentName(name, context.config);
}
if (!component) {
return context.components[name];
}
if (context.components[name]) {
warn$2(`Component "${name}" has already been registered in target app.`);
}
context.components[name] = component;
return app;
},
directive(name, directive) {
{
validateDirectiveName(name);
}
if (!directive) {
return context.directives[name];
}
if (context.directives[name]) {
warn$2(`Directive "${name}" has already been registered in target app.`);
}
context.directives[name] = directive;
return app;
},
mount(rootContainer, isHydrate, isSVG) {
if (!isMounted) {
if (rootContainer.__vue_app__) {
warn$2(
`There is already an app instance mounted on the host container.
If you want to mount another app on the same host container, you need to unmount the previous app by calling \`app.unmount()\` first.`
);
}
const vnode = createVNode(rootComponent, rootProps);
vnode.appContext = context;
{
context.reload = () => {
render2(cloneVNode(vnode), rootContainer, isSVG);
};
}
if (isHydrate && hydrate2) {
hydrate2(vnode, rootContainer);
} else {
render2(vnode, rootContainer, isSVG);
}
isMounted = true;
app._container = rootContainer;
rootContainer.__vue_app__ = app;
{
app._instance = vnode.component;
devtoolsInitApp(app, version$1);
}
return getExposeProxy(vnode.component) || vnode.component.proxy;
} else {
warn$2(
`App has already been mounted.
If you want to remount the same app, move your app creation logic into a factory function and create fresh app instances for each mount - e.g. \`const createMyApp = () => createApp(App)\``
);
}
},
unmount() {
if (isMounted) {
render2(null, app._container);
{
app._instance = null;
devtoolsUnmountApp(app);
}
delete app._container.__vue_app__;
} else {
warn$2(`Cannot unmount an app that is not mounted.`);
}
},
provide(key, value) {
if (key in context.provides) {
warn$2(
`App already provides property with key "${String(key)}". It will be overwritten with the new value.`
);
}
context.provides[key] = value;
return app;
},
runWithContext(fn2) {
currentApp = app;
try {
return fn2();
} finally {
currentApp = null;
}
}
};
return app;
};
}
let currentApp = null;
function provide(key, value) {
if (!currentInstance) {
{
warn$2(`provide() can only be used inside setup().`);
}
} else {
let provides = currentInstance.provides;
const parentProvides = currentInstance.parent && currentInstance.parent.provides;
if (parentProvides === provides) {
provides = currentInstance.provides = Object.create(parentProvides);
}
provides[key] = value;
}
}
function inject(key, defaultValue, treatDefaultAsFactory = false) {
const instance = currentInstance || currentRenderingInstance;
if (instance || currentApp) {
const provides = instance ? instance.parent == null ? instance.vnode.appContext && instance.vnode.appContext.provides : instance.parent.provides : currentApp._context.provides;
if (provides && key in provides) {
return provides[key];
} else if (arguments.length > 1) {
return treatDefaultAsFactory && isFunction$1(defaultValue) ? defaultValue.call(instance && instance.proxy) : defaultValue;
} else {
warn$2(`injection "${String(key)}" not found.`);
}
} else {
warn$2(`inject() can only be used inside setup() or functional components.`);
}
}
function hasInjectionContext() {
return !!(currentInstance || currentRenderingInstance || currentApp);
}
function initProps(instance, rawProps, isStateful, isSSR = false) {
const props = {};
const attrs = {};
def(attrs, InternalObjectKey, 1);
instance.propsDefaults = /* @__PURE__ */ Object.create(null);
setFullProps(instance, rawProps, props, attrs);
for (const key in instance.propsOptions[0]) {
if (!(key in props)) {
props[key] = void 0;
}
}
{
validateProps(rawProps || {}, props, instance);
}
if (isStateful) {
instance.props = isSSR ? props : shallowReactive(props);
} else {
if (!instance.type.props) {
instance.props = attrs;
} else {
instance.props = props;
}
}
instance.attrs = attrs;
}
function isInHmrContext(instance) {
while (instance) {
if (instance.type.__hmrId)
return true;
instance = instance.parent;
}
}
function updateProps(instance, rawProps, rawPrevProps, optimized) {
const {
props,
attrs,
vnode: { patchFlag }
} = instance;
const rawCurrentProps = toRaw(props);
const [options] = instance.propsOptions;
let hasAttrsChanged = false;
if (
// always force full diff in dev
// - #1942 if hmr is enabled with sfc component
// - vite#872 non-sfc component used by sfc component
!isInHmrContext(instance) && (optimized || patchFlag > 0) && !(patchFlag & 16)
) {
if (patchFlag & 8) {
const propsToUpdate = instance.vnode.dynamicProps;
for (let i2 = 0; i2 < propsToUpdate.length; i2++) {
let key = propsToUpdate[i2];
if (isEmitListener(instance.emitsOptions, key)) {
continue;
}
const value = rawProps[key];
if (options) {
if (hasOwn(attrs, key)) {
if (value !== attrs[key]) {
attrs[key] = value;
hasAttrsChanged = true;
}
} else {
const camelizedKey = camelize(key);
props[camelizedKey] = resolvePropValue(
options,
rawCurrentProps,
camelizedKey,
value,
instance,
false
/* isAbsent */
);
}
} else {
if (value !== attrs[key]) {
attrs[key] = value;
hasAttrsChanged = true;
}
}
}
}
} else {
if (setFullProps(instance, rawProps, props, attrs)) {
hasAttrsChanged = true;
}
let kebabKey;
for (const key in rawCurrentProps) {
if (!rawProps || // for camelCase
!hasOwn(rawProps, key) && // it's possible the original props was passed in as kebab-case
// and converted to camelCase (#955)
((kebabKey = hyphenate(key)) === key || !hasOwn(rawProps, kebabKey))) {
if (options) {
if (rawPrevProps && // for camelCase
(rawPrevProps[key] !== void 0 || // for kebab-case
rawPrevProps[kebabKey] !== void 0)) {
props[key] = resolvePropValue(
options,
rawCurrentProps,
key,
void 0,
instance,
true
/* isAbsent */
);
}
} else {
delete props[key];
}
}
}
if (attrs !== rawCurrentProps) {
for (const key in attrs) {
if (!rawProps || !hasOwn(rawProps, key) && true) {
delete attrs[key];
hasAttrsChanged = true;
}
}
}
}
if (hasAttrsChanged) {
trigger(instance, "set", "$attrs");
}
{
validateProps(rawProps || {}, props, instance);
}
}
function setFullProps(instance, rawProps, props, attrs) {
const [options, needCastKeys] = instance.propsOptions;
let hasAttrsChanged = false;
let rawCastValues;
if (rawProps) {
for (let key in rawProps) {
if (isReservedProp(key)) {
continue;
}
const value = rawProps[key];
let camelKey;
if (options && hasOwn(options, camelKey = camelize(key))) {
if (!needCastKeys || !needCastKeys.includes(camelKey)) {
props[camelKey] = value;
} else {
(rawCastValues || (rawCastValues = {}))[camelKey] = value;
}
} else if (!isEmitListener(instance.emitsOptions, key)) {
if (!(key in attrs) || value !== attrs[key]) {
attrs[key] = value;
hasAttrsChanged = true;
}
}
}
}
if (needCastKeys) {
const rawCurrentProps = toRaw(props);
const castValues = rawCastValues || EMPTY_OBJ;
for (let i2 = 0; i2 < needCastKeys.length; i2++) {
const key = needCastKeys[i2];
props[key] = resolvePropValue(
options,
rawCurrentProps,
key,
castValues[key],
instance,
!hasOwn(castValues, key)
);
}
}
return hasAttrsChanged;
}
function resolvePropValue(options, props, key, value, instance, isAbsent) {
const opt = options[key];
if (opt != null) {
const hasDefault = hasOwn(opt, "default");
if (hasDefault && value === void 0) {
const defaultValue = opt.default;
if (opt.type !== Function && !opt.skipFactory && isFunction$1(defaultValue)) {
const { propsDefaults } = instance;
if (key in propsDefaults) {
value = propsDefaults[key];
} else {
setCurrentInstance(instance);
value = propsDefaults[key] = defaultValue.call(
null,
props
);
unsetCurrentInstance();
}
} else {
value = defaultValue;
}
}
if (opt[
0
/* shouldCast */
]) {
if (isAbsent && !hasDefault) {
value = false;
} else if (opt[
1
/* shouldCastTrue */
] && (value === "" || value === hyphenate(key))) {
value = true;
}
}
}
return value;
}
function normalizePropsOptions(comp, appContext, asMixin = false) {
const cache2 = appContext.propsCache;
const cached = cache2.get(comp);
if (cached) {
return cached;
}
const raw = comp.props;
const normalized = {};
const needCastKeys = [];
let hasExtends = false;
if (!isFunction$1(comp)) {
const extendProps = (raw2) => {
hasExtends = true;
const [props, keys] = normalizePropsOptions(raw2, appContext, true);
extend(normalized, props);
if (keys)
needCastKeys.push(...keys);
};
if (!asMixin && appContext.mixins.length) {
appContext.mixins.forEach(extendProps);
}
if (comp.extends) {
extendProps(comp.extends);
}
if (comp.mixins) {
comp.mixins.forEach(extendProps);
}
}
if (!raw && !hasExtends) {
if (isObject(comp)) {
cache2.set(comp, EMPTY_ARR);
}
return EMPTY_ARR;
}
if (isArray$1(raw)) {
for (let i2 = 0; i2 < raw.length; i2++) {
if (!isString$1(raw[i2])) {
warn$2(`props must be strings when using array syntax.`, raw[i2]);
}
const normalizedKey = camelize(raw[i2]);
if (validatePropName(normalizedKey)) {
normalized[normalizedKey] = EMPTY_OBJ;
}
}
} else if (raw) {
if (!isObject(raw)) {
warn$2(`invalid props options`, raw);
}
for (const key in raw) {
const normalizedKey = camelize(key);
if (validatePropName(normalizedKey)) {
const opt = raw[key];
const prop = normalized[normalizedKey] = isArray$1(opt) || isFunction$1(opt) ? { type: opt } : extend({}, opt);
if (prop) {
const booleanIndex = getTypeIndex(Boolean, prop.type);
const stringIndex = getTypeIndex(String, prop.type);
prop[
0
/* shouldCast */
] = booleanIndex > -1;
prop[
1
/* shouldCastTrue */
] = stringIndex < 0 || booleanIndex < stringIndex;
if (booleanIndex > -1 || hasOwn(prop, "default")) {
needCastKeys.push(normalizedKey);
}
}
}
}
}
const res = [normalized, needCastKeys];
if (isObject(comp)) {
cache2.set(comp, res);
}
return res;
}
function validatePropName(key) {
if (key[0] !== "$") {
return true;
} else {
warn$2(`Invalid prop name: "${key}" is a reserved property.`);
}
return false;
}
function getType(ctor) {
const match = ctor && ctor.toString().match(/^\s*(function|class) (\w+)/);
return match ? match[2] : ctor === null ? "null" : "";
}
function isSameType(a2, b3) {
return getType(a2) === getType(b3);
}
function getTypeIndex(type, expectedTypes) {
if (isArray$1(expectedTypes)) {
return expectedTypes.findIndex((t2) => isSameType(t2, type));
} else if (isFunction$1(expectedTypes)) {
return isSameType(expectedTypes, type) ? 0 : -1;
}
return -1;
}
function validateProps(rawProps, props, instance) {
const resolvedValues = toRaw(props);
const options = instance.propsOptions[0];
for (const key in options) {
let opt = options[key];
if (opt == null)
continue;
validateProp(
key,
resolvedValues[key],
opt,
!hasOwn(rawProps, key) && !hasOwn(rawProps, hyphenate(key))
);
}
}
function validateProp(name, value, prop, isAbsent) {
const { type, required, validator, skipCheck } = prop;
if (required && isAbsent) {
warn$2('Missing required prop: "' + name + '"');
return;
}
if (value == null && !required) {
return;
}
if (type != null && type !== true && !skipCheck) {
let isValid = false;
const types = isArray$1(type) ? type : [type];
const expectedTypes = [];
for (let i2 = 0; i2 < types.length && !isValid; i2++) {
const { valid, expectedType } = assertType(value, types[i2]);
expectedTypes.push(expectedType || "");
isValid = valid;
}
if (!isValid) {
warn$2(getInvalidTypeMessage(name, value, expectedTypes));
return;
}
}
if (validator && !validator(value)) {
warn$2('Invalid prop: custom validator check failed for prop "' + name + '".');
}
}
const isSimpleType = /* @__PURE__ */ makeMap(
"String,Number,Boolean,Function,Symbol,BigInt"
);
function assertType(value, type) {
let valid;
const expectedType = getType(type);
if (isSimpleType(expectedType)) {
const t2 = typeof value;
valid = t2 === expectedType.toLowerCase();
if (!valid && t2 === "object") {
valid = value instanceof type;
}
} else if (expectedType === "Object") {
valid = isObject(value);
} else if (expectedType === "Array") {
valid = isArray$1(value);
} else if (expectedType === "null") {
valid = value === null;
} else {
valid = value instanceof type;
}
return {
valid,
expectedType
};
}
function getInvalidTypeMessage(name, value, expectedTypes) {
let message = `Invalid prop: type check failed for prop "${name}". Expected ${expectedTypes.map(capitalize).join(" | ")}`;
const expectedType = expectedTypes[0];
const receivedType = toRawType(value);
const expectedValue = styleValue(value, expectedType);
const receivedValue = styleValue(value, receivedType);
if (expectedTypes.length === 1 && isExplicable(expectedType) && !isBoolean(expectedType, receivedType)) {
message += ` with value ${expectedValue}`;
}
message += `, got ${receivedType} `;
if (isExplicable(receivedType)) {
message += `with value ${receivedValue}.`;
}
return message;
}
function styleValue(value, type) {
if (type === "String") {
return `"${value}"`;
} else if (type === "Number") {
return `${Number(value)}`;
} else {
return `${value}`;
}
}
function isExplicable(type) {
const explicitTypes = ["string", "number", "boolean"];
return explicitTypes.some((elem) => type.toLowerCase() === elem);
}
function isBoolean(...args) {
return args.some((elem) => elem.toLowerCase() === "boolean");
}
const isInternalKey = (key) => key[0] === "_" || key === "$stable";
const normalizeSlotValue = (value) => isArray$1(value) ? value.map(normalizeVNode) : [normalizeVNode(value)];
const normalizeSlot$1 = (key, rawSlot, ctx) => {
if (rawSlot._n) {
return rawSlot;
}
const normalized = withCtx((...args) => {
if (currentInstance) {
warn$2(
`Slot "${key}" invoked outside of the render function: this will not track dependencies used in the slot. Invoke the slot function inside the render function instead.`
);
}
return normalizeSlotValue(rawSlot(...args));
}, ctx);
normalized._c = false;
return normalized;
};
const normalizeObjectSlots = (rawSlots, slots, instance) => {
const ctx = rawSlots._ctx;
for (const key in rawSlots) {
if (isInternalKey(key))
continue;
const value = rawSlots[key];
if (isFunction$1(value)) {
slots[key] = normalizeSlot$1(key, value, ctx);
} else if (value != null) {
{
warn$2(
`Non-function value encountered for slot "${key}". Prefer function slots for better performance.`
);
}
const normalized = normalizeSlotValue(value);
slots[key] = () => normalized;
}
}
};
const normalizeVNodeSlots = (instance, children2) => {
if (!isKeepAlive(instance.vnode) && true) {
warn$2(
`Non-function value encountered for default slot. Prefer function slots for better performance.`
);
}
const normalized = normalizeSlotValue(children2);
instance.slots.default = () => normalized;
};
const initSlots = (instance, children2) => {
if (instance.vnode.shapeFlag & 32) {
const type = children2._;
if (type) {
instance.slots = toRaw(children2);
def(children2, "_", type);
} else {
normalizeObjectSlots(
children2,
instance.slots = {}
);
}
} else {
instance.slots = {};
if (children2) {
normalizeVNodeSlots(instance, children2);
}
}
def(instance.slots, InternalObjectKey, 1);
};
const updateSlots = (instance, children2, optimized) => {
const { vnode, slots } = instance;
let needDeletionCheck = true;
let deletionComparisonTarget = EMPTY_OBJ;
if (vnode.shapeFlag & 32) {
const type = children2._;
if (type) {
if (isHmrUpdating) {
extend(slots, children2);
trigger(instance, "set", "$slots");
} else if (optimized && type === 1) {
needDeletionCheck = false;
} else {
extend(slots, children2);
if (!optimized && type === 1) {
delete slots._;
}
}
} else {
needDeletionCheck = !children2.$stable;
normalizeObjectSlots(children2, slots);
}
deletionComparisonTarget = children2;
} else if (children2) {
normalizeVNodeSlots(instance, children2);
deletionComparisonTarget = { default: 1 };
}
if (needDeletionCheck) {
for (const key in slots) {
if (!isInternalKey(key) && deletionComparisonTarget[key] == null) {
delete slots[key];
}
}
}
};
function setRef(rawRef, oldRawRef, parentSuspense, vnode, isUnmount = false) {
if (isArray$1(rawRef)) {
rawRef.forEach(
(r2, i2) => setRef(
r2,
oldRawRef && (isArray$1(oldRawRef) ? oldRawRef[i2] : oldRawRef),
parentSuspense,
vnode,
isUnmount
)
);
return;
}
if (isAsyncWrapper(vnode) && !isUnmount) {
return;
}
const refValue = vnode.shapeFlag & 4 ? getExposeProxy(vnode.component) || vnode.component.proxy : vnode.el;
const value = isUnmount ? null : refValue;
const { i: owner, r: ref2 } = rawRef;
if (!owner) {
warn$2(
`Missing ref owner context. ref cannot be used on hoisted vnodes. A vnode with ref must be created inside the render function.`
);
return;
}
const oldRef = oldRawRef && oldRawRef.r;
const refs = owner.refs === EMPTY_OBJ ? owner.refs = {} : owner.refs;
const setupState = owner.setupState;
if (oldRef != null && oldRef !== ref2) {
if (isString$1(oldRef)) {
refs[oldRef] = null;
if (hasOwn(setupState, oldRef)) {
setupState[oldRef] = null;
}
} else if (isRef(oldRef)) {
oldRef.value = null;
}
}
if (isFunction$1(ref2)) {
callWithErrorHandling(ref2, owner, 12, [value, refs]);
} else {
const _isString = isString$1(ref2);
const _isRef = isRef(ref2);
if (_isString || _isRef) {
const doSet = () => {
if (rawRef.f) {
const existing = _isString ? hasOwn(setupState, ref2) ? setupState[ref2] : refs[ref2] : ref2.value;
if (isUnmount) {
isArray$1(existing) && remove(existing, refValue);
} else {
if (!isArray$1(existing)) {
if (_isString) {
refs[ref2] = [refValue];
if (hasOwn(setupState, ref2)) {
setupState[ref2] = refs[ref2];
}
} else {
ref2.value = [refValue];
if (rawRef.k)
refs[rawRef.k] = ref2.value;
}
} else if (!existing.includes(refValue)) {
existing.push(refValue);
}
}
} else if (_isString) {
refs[ref2] = value;
if (hasOwn(setupState, ref2)) {
setupState[ref2] = value;
}
} else if (_isRef) {
ref2.value = value;
if (rawRef.k)
refs[rawRef.k] = value;
} else {
warn$2("Invalid template ref type:", ref2, `(${typeof ref2})`);
}
};
if (value) {
doSet.id = -1;
queuePostRenderEffect(doSet, parentSuspense);
} else {
doSet();
}
} else {
warn$2("Invalid template ref type:", ref2, `(${typeof ref2})`);
}
}
}
let supported$1;
let perf$1;
function startMeasure(instance, type) {
if (instance.appContext.config.performance && isSupported()) {
perf$1.mark(`vue-${type}-${instance.uid}`);
}
{
devtoolsPerfStart(instance, type, isSupported() ? perf$1.now() : Date.now());
}
}
function endMeasure(instance, type) {
if (instance.appContext.config.performance && isSupported()) {
const startTag = `vue-${type}-${instance.uid}`;
const endTag = startTag + `:end`;
perf$1.mark(endTag);
perf$1.measure(
`<${formatComponentName(instance, instance.type)}> ${type}`,
startTag,
endTag
);
perf$1.clearMarks(startTag);
perf$1.clearMarks(endTag);
}
{
devtoolsPerfEnd(instance, type, isSupported() ? perf$1.now() : Date.now());
}
}
function isSupported() {
if (supported$1 !== void 0) {
return supported$1;
}
if (typeof window !== "undefined" && window.performance) {
supported$1 = true;
perf$1 = window.performance;
} else {
supported$1 = false;
}
return supported$1;
}
function initFeatureFlags() {
const needWarn = [];
if (needWarn.length) {
const multi = needWarn.length > 1;
console.warn(
`Feature flag${multi ? `s` : ``} ${needWarn.join(", ")} ${multi ? `are` : `is`} not explicitly defined. You are running the esm-bundler build of Vue, which expects these compile-time feature flags to be globally injected via the bundler config in order to get better tree-shaking in the production bundle.
For more details, see https://link.vuejs.org/feature-flags.`
);
}
}
const queuePostRenderEffect = queueEffectWithSuspense;
function createRenderer(options) {
return baseCreateRenderer(options);
}
function baseCreateRenderer(options, createHydrationFns) {
{
initFeatureFlags();
}
const target = getGlobalThis();
target.__VUE__ = true;
{
setDevtoolsHook(target.__VUE_DEVTOOLS_GLOBAL_HOOK__, target);
}
const {
insert: hostInsert,
remove: hostRemove,
patchProp: hostPatchProp,
createElement: hostCreateElement,
createText: hostCreateText,
createComment: hostCreateComment,
setText: hostSetText,
setElementText: hostSetElementText,
parentNode: hostParentNode,
nextSibling: hostNextSibling,
setScopeId: hostSetScopeId = NOOP,
insertStaticContent: hostInsertStaticContent
} = options;
const patch = (n1, n2, container, anchor = null, parentComponent = null, parentSuspense = null, isSVG = false, slotScopeIds = null, optimized = isHmrUpdating ? false : !!n2.dynamicChildren) => {
if (n1 === n2) {
return;
}
if (n1 && !isSameVNodeType(n1, n2)) {
anchor = getNextHostNode(n1);
unmount(n1, parentComponent, parentSuspense, true);
n1 = null;
}
if (n2.patchFlag === -2) {
optimized = false;
n2.dynamicChildren = null;
}
const { type, ref: ref2, shapeFlag } = n2;
switch (type) {
case Text:
processText(n1, n2, container, anchor);
break;
case Comment:
processCommentNode(n1, n2, container, anchor);
break;
case Static:
if (n1 == null) {
mountStaticNode(n2, container, anchor, isSVG);
} else {
patchStaticNode(n1, n2, container, isSVG);
}
break;
case Fragment:
processFragment(
n1,
n2,
container,
anchor,
parentComponent,
parentSuspense,
isSVG,
slotScopeIds,
optimized
);
break;
default:
if (shapeFlag & 1) {
processElement(
n1,
n2,
container,
anchor,
parentComponent,
parentSuspense,
isSVG,
slotScopeIds,
optimized
);
} else if (shapeFlag & 6) {
processComponent(
n1,
n2,
container,
anchor,
parentComponent,
parentSuspense,
isSVG,
slotScopeIds,
optimized
);
} else if (shapeFlag & 64) {
type.process(
n1,
n2,
container,
anchor,
parentComponent,
parentSuspense,
isSVG,
slotScopeIds,
optimized,
internals
);
} else if (shapeFlag & 128) {
type.process(
n1,
n2,
container,
anchor,
parentComponent,
parentSuspense,
isSVG,
slotScopeIds,
optimized,
internals
);
} else {
warn$2("Invalid VNode type:", type, `(${typeof type})`);
}
}
if (ref2 != null && parentComponent) {
setRef(ref2, n1 && n1.ref, parentSuspense, n2 || n1, !n2);
}
};
const processText = (n1, n2, container, anchor) => {
if (n1 == null) {
hostInsert(
n2.el = hostCreateText(n2.children),
container,
anchor
);
} else {
const el2 = n2.el = n1.el;
if (n2.children !== n1.children) {
hostSetText(el2, n2.children);
}
}
};
const processCommentNode = (n1, n2, container, anchor) => {
if (n1 == null) {
hostInsert(
n2.el = hostCreateComment(n2.children || ""),
container,
anchor
);
} else {
n2.el = n1.el;
}
};
const mountStaticNode = (n2, container, anchor, isSVG) => {
[n2.el, n2.anchor] = hostInsertStaticContent(
n2.children,
container,
anchor,
isSVG,
n2.el,
n2.anchor
);
};
const patchStaticNode = (n1, n2, container, isSVG) => {
if (n2.children !== n1.children) {
const anchor = hostNextSibling(n1.anchor);
removeStaticNode(n1);
[n2.el, n2.anchor] = hostInsertStaticContent(
n2.children,
container,
anchor,
isSVG
);
} else {
n2.el = n1.el;
n2.anchor = n1.anchor;
}
};
const moveStaticNode = ({ el: el2, anchor }, container, nextSibling) => {
let next;
while (el2 && el2 !== anchor) {
next = hostNextSibling(el2);
hostInsert(el2, container, nextSibling);
el2 = next;
}
hostInsert(anchor, container, nextSibling);
};
const removeStaticNode = ({ el: el2, anchor }) => {
let next;
while (el2 && el2 !== anchor) {
next = hostNextSibling(el2);
hostRemove(el2);
el2 = next;
}
hostRemove(anchor);
};
const processElement = (n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
isSVG = isSVG || n2.type === "svg";
if (n1 == null) {
mountElement(
n2,
container,
anchor,
parentComponent,
parentSuspense,
isSVG,
slotScopeIds,
optimized
);
} else {
patchElement(
n1,
n2,
parentComponent,
parentSuspense,
isSVG,
slotScopeIds,
optimized
);
}
};
const mountElement = (vnode, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
let el2;
let vnodeHook;
const { type, props, shapeFlag, transition, dirs } = vnode;
el2 = vnode.el = hostCreateElement(
vnode.type,
isSVG,
props && props.is,
props
);
if (shapeFlag & 8) {
hostSetElementText(el2, vnode.children);
} else if (shapeFlag & 16) {
mountChildren(
vnode.children,
el2,
null,
parentComponent,
parentSuspense,
isSVG && type !== "foreignObject",
slotScopeIds,
optimized
);
}
if (dirs) {
invokeDirectiveHook(vnode, null, parentComponent, "created");
}
setScopeId(el2, vnode, vnode.scopeId, slotScopeIds, parentComponent);
if (props) {
for (const key in props) {
if (key !== "value" && !isReservedProp(key)) {
hostPatchProp(
el2,
key,
null,
props[key],
isSVG,
vnode.children,
parentComponent,
parentSuspense,
unmountChildren
);
}
}
if ("value" in props) {
hostPatchProp(el2, "value", null, props.value);
}
if (vnodeHook = props.onVnodeBeforeMount) {
invokeVNodeHook(vnodeHook, parentComponent, vnode);
}
}
{
Object.defineProperty(el2, "__vnode", {
value: vnode,
enumerable: false
});
Object.defineProperty(el2, "__vueParentComponent", {
value: parentComponent,
enumerable: false
});
}
if (dirs) {
invokeDirectiveHook(vnode, null, parentComponent, "beforeMount");
}
const needCallTransitionHooks = needTransition(parentSuspense, transition);
if (needCallTransitionHooks) {
transition.beforeEnter(el2);
}
hostInsert(el2, container, anchor);
if ((vnodeHook = props && props.onVnodeMounted) || needCallTransitionHooks || dirs) {
queuePostRenderEffect(() => {
vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, vnode);
needCallTransitionHooks && transition.enter(el2);
dirs && invokeDirectiveHook(vnode, null, parentComponent, "mounted");
}, parentSuspense);
}
};
const setScopeId = (el2, vnode, scopeId, slotScopeIds, parentComponent) => {
if (scopeId) {
hostSetScopeId(el2, scopeId);
}
if (slotScopeIds) {
for (let i2 = 0; i2 < slotScopeIds.length; i2++) {
hostSetScopeId(el2, slotScopeIds[i2]);
}
}
if (parentComponent) {
let subTree = parentComponent.subTree;
if (subTree.patchFlag > 0 && subTree.patchFlag & 2048) {
subTree = filterSingleRoot(subTree.children) || subTree;
}
if (vnode === subTree) {
const parentVNode = parentComponent.vnode;
setScopeId(
el2,
parentVNode,
parentVNode.scopeId,
parentVNode.slotScopeIds,
parentComponent.parent
);
}
}
};
const mountChildren = (children2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, start = 0) => {
for (let i2 = start; i2 < children2.length; i2++) {
const child = children2[i2] = optimized ? cloneIfMounted(children2[i2]) : normalizeVNode(children2[i2]);
patch(
null,
child,
container,
anchor,
parentComponent,
parentSuspense,
isSVG,
slotScopeIds,
optimized
);
}
};
const patchElement = (n1, n2, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
const el2 = n2.el = n1.el;
let { patchFlag, dynamicChildren, dirs } = n2;
patchFlag |= n1.patchFlag & 16;
const oldProps = n1.props || EMPTY_OBJ;
const newProps = n2.props || EMPTY_OBJ;
let vnodeHook;
parentComponent && toggleRecurse(parentComponent, false);
if (vnodeHook = newProps.onVnodeBeforeUpdate) {
invokeVNodeHook(vnodeHook, parentComponent, n2, n1);
}
if (dirs) {
invokeDirectiveHook(n2, n1, parentComponent, "beforeUpdate");
}
parentComponent && toggleRecurse(parentComponent, true);
if (isHmrUpdating) {
patchFlag = 0;
optimized = false;
dynamicChildren = null;
}
const areChildrenSVG = isSVG && n2.type !== "foreignObject";
if (dynamicChildren) {
patchBlockChildren(
n1.dynamicChildren,
dynamicChildren,
el2,
parentComponent,
parentSuspense,
areChildrenSVG,
slotScopeIds
);
{
traverseStaticChildren(n1, n2);
}
} else if (!optimized) {
patchChildren(
n1,
n2,
el2,
null,
parentComponent,
parentSuspense,
areChildrenSVG,
slotScopeIds,
false
);
}
if (patchFlag > 0) {
if (patchFlag & 16) {
patchProps(
el2,
n2,
oldProps,
newProps,
parentComponent,
parentSuspense,
isSVG
);
} else {
if (patchFlag & 2) {
if (oldProps.class !== newProps.class) {
hostPatchProp(el2, "class", null, newProps.class, isSVG);
}
}
if (patchFlag & 4) {
hostPatchProp(el2, "style", oldProps.style, newProps.style, isSVG);
}
if (patchFlag & 8) {
const propsToUpdate = n2.dynamicProps;
for (let i2 = 0; i2 < propsToUpdate.length; i2++) {
const key = propsToUpdate[i2];
const prev = oldProps[key];
const next = newProps[key];
if (next !== prev || key === "value") {
hostPatchProp(
el2,
key,
prev,
next,
isSVG,
n1.children,
parentComponent,
parentSuspense,
unmountChildren
);
}
}
}
}
if (patchFlag & 1) {
if (n1.children !== n2.children) {
hostSetElementText(el2, n2.children);
}
}
} else if (!optimized && dynamicChildren == null) {
patchProps(
el2,
n2,
oldProps,
newProps,
parentComponent,
parentSuspense,
isSVG
);
}
if ((vnodeHook = newProps.onVnodeUpdated) || dirs) {
queuePostRenderEffect(() => {
vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, n2, n1);
dirs && invokeDirectiveHook(n2, n1, parentComponent, "updated");
}, parentSuspense);
}
};
const patchBlockChildren = (oldChildren, newChildren, fallbackContainer, parentComponent, parentSuspense, isSVG, slotScopeIds) => {
for (let i2 = 0; i2 < newChildren.length; i2++) {
const oldVNode = oldChildren[i2];
const newVNode = newChildren[i2];
const container = (
// oldVNode may be an errored async setup() component inside Suspense
// which will not have a mounted element
oldVNode.el && // - In the case of a Fragment, we need to provide the actual parent
// of the Fragment itself so it can move its children.
(oldVNode.type === Fragment || // - In the case of different nodes, there is going to be a replacement
// which also requires the correct parent container
!isSameVNodeType(oldVNode, newVNode) || // - In the case of a component, it could contain anything.
oldVNode.shapeFlag & (6 | 64)) ? hostParentNode(oldVNode.el) : (
// In other cases, the parent container is not actually used so we
// just pass the block element here to avoid a DOM parentNode call.
fallbackContainer
)
);
patch(
oldVNode,
newVNode,
container,
null,
parentComponent,
parentSuspense,
isSVG,
slotScopeIds,
true
);
}
};
const patchProps = (el2, vnode, oldProps, newProps, parentComponent, parentSuspense, isSVG) => {
if (oldProps !== newProps) {
if (oldProps !== EMPTY_OBJ) {
for (const key in oldProps) {
if (!isReservedProp(key) && !(key in newProps)) {
hostPatchProp(
el2,
key,
oldProps[key],
null,
isSVG,
vnode.children,
parentComponent,
parentSuspense,
unmountChildren
);
}
}
}
for (const key in newProps) {
if (isReservedProp(key))
continue;
const next = newProps[key];
const prev = oldProps[key];
if (next !== prev && key !== "value") {
hostPatchProp(
el2,
key,
prev,
next,
isSVG,
vnode.children,
parentComponent,
parentSuspense,
unmountChildren
);
}
}
if ("value" in newProps) {
hostPatchProp(el2, "value", oldProps.value, newProps.value);
}
}
};
const processFragment = (n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
const fragmentStartAnchor = n2.el = n1 ? n1.el : hostCreateText("");
const fragmentEndAnchor = n2.anchor = n1 ? n1.anchor : hostCreateText("");
let { patchFlag, dynamicChildren, slotScopeIds: fragmentSlotScopeIds } = n2;
if (
// #5523 dev root fragment may inherit directives
isHmrUpdating || patchFlag & 2048
) {
patchFlag = 0;
optimized = false;
dynamicChildren = null;
}
if (fragmentSlotScopeIds) {
slotScopeIds = slotScopeIds ? slotScopeIds.concat(fragmentSlotScopeIds) : fragmentSlotScopeIds;
}
if (n1 == null) {
hostInsert(fragmentStartAnchor, container, anchor);
hostInsert(fragmentEndAnchor, container, anchor);
mountChildren(
n2.children,
container,
fragmentEndAnchor,
parentComponent,
parentSuspense,
isSVG,
slotScopeIds,
optimized
);
} else {
if (patchFlag > 0 && patchFlag & 64 && dynamicChildren && // #2715 the previous fragment could've been a BAILed one as a result
// of renderSlot() with no valid children
n1.dynamicChildren) {
patchBlockChildren(
n1.dynamicChildren,
dynamicChildren,
container,
parentComponent,
parentSuspense,
isSVG,
slotScopeIds
);
{
traverseStaticChildren(n1, n2);
}
} else {
patchChildren(
n1,
n2,
container,
fragmentEndAnchor,
parentComponent,
parentSuspense,
isSVG,
slotScopeIds,
optimized
);
}
}
};
const processComponent = (n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
n2.slotScopeIds = slotScopeIds;
if (n1 == null) {
if (n2.shapeFlag & 512) {
parentComponent.ctx.activate(
n2,
container,
anchor,
isSVG,
optimized
);
} else {
mountComponent(
n2,
container,
anchor,
parentComponent,
parentSuspense,
isSVG,
optimized
);
}
} else {
updateComponent(n1, n2, optimized);
}
};
const mountComponent = (initialVNode, container, anchor, parentComponent, parentSuspense, isSVG, optimized) => {
const instance = initialVNode.component = createComponentInstance(
initialVNode,
parentComponent,
parentSuspense
);
if (instance.type.__hmrId) {
registerHMR(instance);
}
{
pushWarningContext(initialVNode);
startMeasure(instance, `mount`);
}
if (isKeepAlive(initialVNode)) {
instance.ctx.renderer = internals;
}
{
{
startMeasure(instance, `init`);
}
setupComponent(instance);
{
endMeasure(instance, `init`);
}
}
if (instance.asyncDep) {
parentSuspense && parentSuspense.registerDep(instance, setupRenderEffect);
if (!initialVNode.el) {
const placeholder = instance.subTree = createVNode(Comment);
processCommentNode(null, placeholder, container, anchor);
}
return;
}
setupRenderEffect(
instance,
initialVNode,
container,
anchor,
parentSuspense,
isSVG,
optimized
);
{
popWarningContext();
endMeasure(instance, `mount`);
}
};
const updateComponent = (n1, n2, optimized) => {
const instance = n2.component = n1.component;
if (shouldUpdateComponent(n1, n2, optimized)) {
if (instance.asyncDep && !instance.asyncResolved) {
{
pushWarningContext(n2);
}
updateComponentPreRender(instance, n2, optimized);
{
popWarningContext();
}
return;
} else {
instance.next = n2;
invalidateJob(instance.update);
instance.update();
}
} else {
n2.el = n1.el;
instance.vnode = n2;
}
};
const setupRenderEffect = (instance, initialVNode, container, anchor, parentSuspense, isSVG, optimized) => {
const componentUpdateFn = () => {
if (!instance.isMounted) {
let vnodeHook;
const { el: el2, props } = initialVNode;
const { bm: bm2, m, parent } = instance;
const isAsyncWrapperVNode = isAsyncWrapper(initialVNode);
toggleRecurse(instance, false);
if (bm2) {
invokeArrayFns(bm2);
}
if (!isAsyncWrapperVNode && (vnodeHook = props && props.onVnodeBeforeMount)) {
invokeVNodeHook(vnodeHook, parent, initialVNode);
}
toggleRecurse(instance, true);
if (el2 && hydrateNode) {
const hydrateSubTree = () => {
{
startMeasure(instance, `render`);
}
instance.subTree = renderComponentRoot(instance);
{
endMeasure(instance, `render`);
}
{
startMeasure(instance, `hydrate`);
}
hydrateNode(
el2,
instance.subTree,
instance,
parentSuspense,
null
);
{
endMeasure(instance, `hydrate`);
}
};
if (isAsyncWrapperVNode) {
initialVNode.type.__asyncLoader().then(
// note: we are moving the render call into an async callback,
// which means it won't track dependencies - but it's ok because
// a server-rendered async wrapper is already in resolved state
// and it will never need to change.
() => !instance.isUnmounted && hydrateSubTree()
);
} else {
hydrateSubTree();
}
} else {
{
startMeasure(instance, `render`);
}
const subTree = instance.subTree = renderComponentRoot(instance);
{
endMeasure(instance, `render`);
}
{
startMeasure(instance, `patch`);
}
patch(
null,
subTree,
container,
anchor,
instance,
parentSuspense,
isSVG
);
{
endMeasure(instance, `patch`);
}
initialVNode.el = subTree.el;
}
if (m) {
queuePostRenderEffect(m, parentSuspense);
}
if (!isAsyncWrapperVNode && (vnodeHook = props && props.onVnodeMounted)) {
const scopedInitialVNode = initialVNode;
queuePostRenderEffect(
() => invokeVNodeHook(vnodeHook, parent, scopedInitialVNode),
parentSuspense
);
}
if (initialVNode.shapeFlag & 256 || parent && isAsyncWrapper(parent.vnode) && parent.vnode.shapeFlag & 256) {
instance.a && queuePostRenderEffect(instance.a, parentSuspense);
}
instance.isMounted = true;
{
devtoolsComponentAdded(instance);
}
initialVNode = container = anchor = null;
} else {
let { next, bu: bu2, u: u2, parent, vnode } = instance;
let originNext = next;
let vnodeHook;
{
pushWarningContext(next || instance.vnode);
}
toggleRecurse(instance, false);
if (next) {
next.el = vnode.el;
updateComponentPreRender(instance, next, optimized);
} else {
next = vnode;
}
if (bu2) {
invokeArrayFns(bu2);
}
if (vnodeHook = next.props && next.props.onVnodeBeforeUpdate) {
invokeVNodeHook(vnodeHook, parent, next, vnode);
}
toggleRecurse(instance, true);
{
startMeasure(instance, `render`);
}
const nextTree = renderComponentRoot(instance);
{
endMeasure(instance, `render`);
}
const prevTree = instance.subTree;
instance.subTree = nextTree;
{
startMeasure(instance, `patch`);
}
patch(
prevTree,
nextTree,
// parent may have changed if it's in a teleport
hostParentNode(prevTree.el),
// anchor may have changed if it's in a fragment
getNextHostNode(prevTree),
instance,
parentSuspense,
isSVG
);
{
endMeasure(instance, `patch`);
}
next.el = nextTree.el;
if (originNext === null) {
updateHOCHostEl(instance, nextTree.el);
}
if (u2) {
queuePostRenderEffect(u2, parentSuspense);
}
if (vnodeHook = next.props && next.props.onVnodeUpdated) {
queuePostRenderEffect(
() => invokeVNodeHook(vnodeHook, parent, next, vnode),
parentSuspense
);
}
{
devtoolsComponentUpdated(instance);
}
{
popWarningContext();
}
}
};
const effect2 = instance.effect = new ReactiveEffect(
componentUpdateFn,
() => queueJob(update2),
instance.scope
// track it in component's effect scope
);
const update2 = instance.update = () => effect2.run();
update2.id = instance.uid;
toggleRecurse(instance, true);
{
effect2.onTrack = instance.rtc ? (e2) => invokeArrayFns(instance.rtc, e2) : void 0;
effect2.onTrigger = instance.rtg ? (e2) => invokeArrayFns(instance.rtg, e2) : void 0;
update2.ownerInstance = instance;
}
update2();
};
const updateComponentPreRender = (instance, nextVNode, optimized) => {
nextVNode.component = instance;
const prevProps = instance.vnode.props;
instance.vnode = nextVNode;
instance.next = null;
updateProps(instance, nextVNode.props, prevProps, optimized);
updateSlots(instance, nextVNode.children, optimized);
pauseTracking();
flushPreFlushCbs();
resetTracking();
};
const patchChildren = (n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized = false) => {
const c1 = n1 && n1.children;
const prevShapeFlag = n1 ? n1.shapeFlag : 0;
const c2 = n2.children;
const { patchFlag, shapeFlag } = n2;
if (patchFlag > 0) {
if (patchFlag & 128) {
patchKeyedChildren(
c1,
c2,
container,
anchor,
parentComponent,
parentSuspense,
isSVG,
slotScopeIds,
optimized
);
return;
} else if (patchFlag & 256) {
patchUnkeyedChildren(
c1,
c2,
container,
anchor,
parentComponent,
parentSuspense,
isSVG,
slotScopeIds,
optimized
);
return;
}
}
if (shapeFlag & 8) {
if (prevShapeFlag & 16) {
unmountChildren(c1, parentComponent, parentSuspense);
}
if (c2 !== c1) {
hostSetElementText(container, c2);
}
} else {
if (prevShapeFlag & 16) {
if (shapeFlag & 16) {
patchKeyedChildren(
c1,
c2,
container,
anchor,
parentComponent,
parentSuspense,
isSVG,
slotScopeIds,
optimized
);
} else {
unmountChildren(c1, parentComponent, parentSuspense, true);
}
} else {
if (prevShapeFlag & 8) {
hostSetElementText(container, "");
}
if (shapeFlag & 16) {
mountChildren(
c2,
container,
anchor,
parentComponent,
parentSuspense,
isSVG,
slotScopeIds,
optimized
);
}
}
}
};
const patchUnkeyedChildren = (c1, c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
c1 = c1 || EMPTY_ARR;
c2 = c2 || EMPTY_ARR;
const oldLength = c1.length;
const newLength = c2.length;
const commonLength = Math.min(oldLength, newLength);
let i2;
for (i2 = 0; i2 < commonLength; i2++) {
const nextChild = c2[i2] = optimized ? cloneIfMounted(c2[i2]) : normalizeVNode(c2[i2]);
patch(
c1[i2],
nextChild,
container,
null,
parentComponent,
parentSuspense,
isSVG,
slotScopeIds,
optimized
);
}
if (oldLength > newLength) {
unmountChildren(
c1,
parentComponent,
parentSuspense,
true,
false,
commonLength
);
} else {
mountChildren(
c2,
container,
anchor,
parentComponent,
parentSuspense,
isSVG,
slotScopeIds,
optimized,
commonLength
);
}
};
const patchKeyedChildren = (c1, c2, container, parentAnchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized) => {
let i2 = 0;
const l2 = c2.length;
let e1 = c1.length - 1;
let e2 = l2 - 1;
while (i2 <= e1 && i2 <= e2) {
const n1 = c1[i2];
const n2 = c2[i2] = optimized ? cloneIfMounted(c2[i2]) : normalizeVNode(c2[i2]);
if (isSameVNodeType(n1, n2)) {
patch(
n1,
n2,
container,
null,
parentComponent,
parentSuspense,
isSVG,
slotScopeIds,
optimized
);
} else {
break;
}
i2++;
}
while (i2 <= e1 && i2 <= e2) {
const n1 = c1[e1];
const n2 = c2[e2] = optimized ? cloneIfMounted(c2[e2]) : normalizeVNode(c2[e2]);
if (isSameVNodeType(n1, n2)) {
patch(
n1,
n2,
container,
null,
parentComponent,
parentSuspense,
isSVG,
slotScopeIds,
optimized
);
} else {
break;
}
e1--;
e2--;
}
if (i2 > e1) {
if (i2 <= e2) {
const nextPos = e2 + 1;
const anchor = nextPos < l2 ? c2[nextPos].el : parentAnchor;
while (i2 <= e2) {
patch(
null,
c2[i2] = optimized ? cloneIfMounted(c2[i2]) : normalizeVNode(c2[i2]),
container,
anchor,
parentComponent,
parentSuspense,
isSVG,
slotScopeIds,
optimized
);
i2++;
}
}
} else if (i2 > e2) {
while (i2 <= e1) {
unmount(c1[i2], parentComponent, parentSuspense, true);
i2++;
}
} else {
const s1 = i2;
const s2 = i2;
const keyToNewIndexMap = /* @__PURE__ */ new Map();
for (i2 = s2; i2 <= e2; i2++) {
const nextChild = c2[i2] = optimized ? cloneIfMounted(c2[i2]) : normalizeVNode(c2[i2]);
if (nextChild.key != null) {
if (keyToNewIndexMap.has(nextChild.key)) {
warn$2(
`Duplicate keys found during update:`,
JSON.stringify(nextChild.key),
`Make sure keys are unique.`
);
}
keyToNewIndexMap.set(nextChild.key, i2);
}
}
let j2;
let patched = 0;
const toBePatched = e2 - s2 + 1;
let moved = false;
let maxNewIndexSoFar = 0;
const newIndexToOldIndexMap = new Array(toBePatched);
for (i2 = 0; i2 < toBePatched; i2++)
newIndexToOldIndexMap[i2] = 0;
for (i2 = s1; i2 <= e1; i2++) {
const prevChild = c1[i2];
if (patched >= toBePatched) {
unmount(prevChild, parentComponent, parentSuspense, true);
continue;
}
let newIndex;
if (prevChild.key != null) {
newIndex = keyToNewIndexMap.get(prevChild.key);
} else {
for (j2 = s2; j2 <= e2; j2++) {
if (newIndexToOldIndexMap[j2 - s2] === 0 && isSameVNodeType(prevChild, c2[j2])) {
newIndex = j2;
break;
}
}
}
if (newIndex === void 0) {
unmount(prevChild, parentComponent, parentSuspense, true);
} else {
newIndexToOldIndexMap[newIndex - s2] = i2 + 1;
if (newIndex >= maxNewIndexSoFar) {
maxNewIndexSoFar = newIndex;
} else {
moved = true;
}
patch(
prevChild,
c2[newIndex],
container,
null,
parentComponent,
parentSuspense,
isSVG,
slotScopeIds,
optimized
);
patched++;
}
}
const increasingNewIndexSequence = moved ? getSequence(newIndexToOldIndexMap) : EMPTY_ARR;
j2 = increasingNewIndexSequence.length - 1;
for (i2 = toBePatched - 1; i2 >= 0; i2--) {
const nextIndex = s2 + i2;
const nextChild = c2[nextIndex];
const anchor = nextIndex + 1 < l2 ? c2[nextIndex + 1].el : parentAnchor;
if (newIndexToOldIndexMap[i2] === 0) {
patch(
null,
nextChild,
container,
anchor,
parentComponent,
parentSuspense,
isSVG,
slotScopeIds,
optimized
);
} else if (moved) {
if (j2 < 0 || i2 !== increasingNewIndexSequence[j2]) {
move(nextChild, container, anchor, 2);
} else {
j2--;
}
}
}
}
};
const move = (vnode, container, anchor, moveType, parentSuspense = null) => {
const { el: el2, type, transition, children: children2, shapeFlag } = vnode;
if (shapeFlag & 6) {
move(vnode.component.subTree, container, anchor, moveType);
return;
}
if (shapeFlag & 128) {
vnode.suspense.move(container, anchor, moveType);
return;
}
if (shapeFlag & 64) {
type.move(vnode, container, anchor, internals);
return;
}
if (type === Fragment) {
hostInsert(el2, container, anchor);
for (let i2 = 0; i2 < children2.length; i2++) {
move(children2[i2], container, anchor, moveType);
}
hostInsert(vnode.anchor, container, anchor);
return;
}
if (type === Static) {
moveStaticNode(vnode, container, anchor);
return;
}
const needTransition2 = moveType !== 2 && shapeFlag & 1 && transition;
if (needTransition2) {
if (moveType === 0) {
transition.beforeEnter(el2);
hostInsert(el2, container, anchor);
queuePostRenderEffect(() => transition.enter(el2), parentSuspense);
} else {
const { leave, delayLeave, afterLeave } = transition;
const remove22 = () => hostInsert(el2, container, anchor);
const performLeave = () => {
leave(el2, () => {
remove22();
afterLeave && afterLeave();
});
};
if (delayLeave) {
delayLeave(el2, remove22, performLeave);
} else {
performLeave();
}
}
} else {
hostInsert(el2, container, anchor);
}
};
const unmount = (vnode, parentComponent, parentSuspense, doRemove = false, optimized = false) => {
const {
type,
props,
ref: ref2,
children: children2,
dynamicChildren,
shapeFlag,
patchFlag,
dirs
} = vnode;
if (ref2 != null) {
setRef(ref2, null, parentSuspense, vnode, true);
}
if (shapeFlag & 256) {
parentComponent.ctx.deactivate(vnode);
return;
}
const shouldInvokeDirs = shapeFlag & 1 && dirs;
const shouldInvokeVnodeHook = !isAsyncWrapper(vnode);
let vnodeHook;
if (shouldInvokeVnodeHook && (vnodeHook = props && props.onVnodeBeforeUnmount)) {
invokeVNodeHook(vnodeHook, parentComponent, vnode);
}
if (shapeFlag & 6) {
unmountComponent(vnode.component, parentSuspense, doRemove);
} else {
if (shapeFlag & 128) {
vnode.suspense.unmount(parentSuspense, doRemove);
return;
}
if (shouldInvokeDirs) {
invokeDirectiveHook(vnode, null, parentComponent, "beforeUnmount");
}
if (shapeFlag & 64) {
vnode.type.remove(
vnode,
parentComponent,
parentSuspense,
optimized,
internals,
doRemove
);
} else if (dynamicChildren && // #1153: fast path should not be taken for non-stable (v-for) fragments
(type !== Fragment || patchFlag > 0 && patchFlag & 64)) {
unmountChildren(
dynamicChildren,
parentComponent,
parentSuspense,
false,
true
);
} else if (type === Fragment && patchFlag & (128 | 256) || !optimized && shapeFlag & 16) {
unmountChildren(children2, parentComponent, parentSuspense);
}
if (doRemove) {
remove2(vnode);
}
}
if (shouldInvokeVnodeHook && (vnodeHook = props && props.onVnodeUnmounted) || shouldInvokeDirs) {
queuePostRenderEffect(() => {
vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, vnode);
shouldInvokeDirs && invokeDirectiveHook(vnode, null, parentComponent, "unmounted");
}, parentSuspense);
}
};
const remove2 = (vnode) => {
const { type, el: el2, anchor, transition } = vnode;
if (type === Fragment) {
if (vnode.patchFlag > 0 && vnode.patchFlag & 2048 && transition && !transition.persisted) {
vnode.children.forEach((child) => {
if (child.type === Comment) {
hostRemove(child.el);
} else {
remove2(child);
}
});
} else {
removeFragment(el2, anchor);
}
return;
}
if (type === Static) {
removeStaticNode(vnode);
return;
}
const performRemove = () => {
hostRemove(el2);
if (transition && !transition.persisted && transition.afterLeave) {
transition.afterLeave();
}
};
if (vnode.shapeFlag & 1 && transition && !transition.persisted) {
const { leave, delayLeave } = transition;
const performLeave = () => leave(el2, performRemove);
if (delayLeave) {
delayLeave(vnode.el, performRemove, performLeave);
} else {
performLeave();
}
} else {
performRemove();
}
};
const removeFragment = (cur, end) => {
let next;
while (cur !== end) {
next = hostNextSibling(cur);
hostRemove(cur);
cur = next;
}
hostRemove(end);
};
const unmountComponent = (instance, parentSuspense, doRemove) => {
if (instance.type.__hmrId) {
unregisterHMR(instance);
}
const { bum, scope, update: update2, subTree, um: um2 } = instance;
if (bum) {
invokeArrayFns(bum);
}
scope.stop();
if (update2) {
update2.active = false;
unmount(subTree, instance, parentSuspense, doRemove);
}
if (um2) {
queuePostRenderEffect(um2, parentSuspense);
}
queuePostRenderEffect(() => {
instance.isUnmounted = true;
}, parentSuspense);
if (parentSuspense && parentSuspense.pendingBranch && !parentSuspense.isUnmounted && instance.asyncDep && !instance.asyncResolved && instance.suspenseId === parentSuspense.pendingId) {
parentSuspense.deps--;
if (parentSuspense.deps === 0) {
parentSuspense.resolve();
}
}
{
devtoolsComponentRemoved(instance);
}
};
const unmountChildren = (children2, parentComponent, parentSuspense, doRemove = false, optimized = false, start = 0) => {
for (let i2 = start; i2 < children2.length; i2++) {
unmount(children2[i2], parentComponent, parentSuspense, doRemove, optimized);
}
};
const getNextHostNode = (vnode) => {
if (vnode.shapeFlag & 6) {
return getNextHostNode(vnode.component.subTree);
}
if (vnode.shapeFlag & 128) {
return vnode.suspense.next();
}
return hostNextSibling(vnode.anchor || vnode.el);
};
const render2 = (vnode, container, isSVG) => {
if (vnode == null) {
if (container._vnode) {
unmount(container._vnode, null, null, true);
}
} else {
patch(container._vnode || null, vnode, container, null, null, null, isSVG);
}
flushPreFlushCbs();
flushPostFlushCbs();
container._vnode = vnode;
};
const internals = {
p: patch,
um: unmount,
m: move,
r: remove2,
mt: mountComponent,
mc: mountChildren,
pc: patchChildren,
pbc: patchBlockChildren,
n: getNextHostNode,
o: options
};
let hydrate2;
let hydrateNode;
if (createHydrationFns) {
[hydrate2, hydrateNode] = createHydrationFns(
internals
);
}
return {
render: render2,
hydrate: hydrate2,
createApp: createAppAPI(render2, hydrate2)
};
}
function toggleRecurse({ effect: effect2, update: update2 }, allowed) {
effect2.allowRecurse = update2.allowRecurse = allowed;
}
function needTransition(parentSuspense, transition) {
return (!parentSuspense || parentSuspense && !parentSuspense.pendingBranch) && transition && !transition.persisted;
}
function traverseStaticChildren(n1, n2, shallow = false) {
const ch1 = n1.children;
const ch2 = n2.children;
if (isArray$1(ch1) && isArray$1(ch2)) {
for (let i2 = 0; i2 < ch1.length; i2++) {
const c1 = ch1[i2];
let c2 = ch2[i2];
if (c2.shapeFlag & 1 && !c2.dynamicChildren) {
if (c2.patchFlag <= 0 || c2.patchFlag === 32) {
c2 = ch2[i2] = cloneIfMounted(ch2[i2]);
c2.el = c1.el;
}
if (!shallow)
traverseStaticChildren(c1, c2);
}
if (c2.type === Text) {
c2.el = c1.el;
}
if (c2.type === Comment && !c2.el) {
c2.el = c1.el;
}
}
}
}
function getSequence(arr) {
const p2 = arr.slice();
const result = [0];
let i2, j2, u2, v2, c2;
const len = arr.length;
for (i2 = 0; i2 < len; i2++) {
const arrI = arr[i2];
if (arrI !== 0) {
j2 = result[result.length - 1];
if (arr[j2] < arrI) {
p2[i2] = j2;
result.push(i2);
continue;
}
u2 = 0;
v2 = result.length - 1;
while (u2 < v2) {
c2 = u2 + v2 >> 1;
if (arr[result[c2]] < arrI) {
u2 = c2 + 1;
} else {
v2 = c2;
}
}
if (arrI < arr[result[u2]]) {
if (u2 > 0) {
p2[i2] = result[u2 - 1];
}
result[u2] = i2;
}
}
}
u2 = result.length;
v2 = result[u2 - 1];
while (u2-- > 0) {
result[u2] = v2;
v2 = p2[v2];
}
return result;
}
const isTeleport = (type) => type.__isTeleport;
const Fragment = Symbol.for("v-fgt");
const Text = Symbol.for("v-txt");
const Comment = Symbol.for("v-cmt");
const Static = Symbol.for("v-stc");
const blockStack = [];
let currentBlock = null;
function openBlock(disableTracking = false) {
blockStack.push(currentBlock = disableTracking ? null : []);
}
function closeBlock() {
blockStack.pop();
currentBlock = blockStack[blockStack.length - 1] || null;
}
let isBlockTreeEnabled = 1;
function setBlockTracking(value) {
isBlockTreeEnabled += value;
}
function setupBlock(vnode) {
vnode.dynamicChildren = isBlockTreeEnabled > 0 ? currentBlock || EMPTY_ARR : null;
closeBlock();
if (isBlockTreeEnabled > 0 && currentBlock) {
currentBlock.push(vnode);
}
return vnode;
}
function createElementBlock(type, props, children2, patchFlag, dynamicProps, shapeFlag) {
return setupBlock(
createBaseVNode(
type,
props,
children2,
patchFlag,
dynamicProps,
shapeFlag,
true
/* isBlock */
)
);
}
function createBlock(type, props, children2, patchFlag, dynamicProps) {
return setupBlock(
createVNode(
type,
props,
children2,
patchFlag,
dynamicProps,
true
/* isBlock: prevent a block from tracking itself */
)
);
}
function isVNode(value) {
return value ? value.__v_isVNode === true : false;
}
function isSameVNodeType(n1, n2) {
if (n2.shapeFlag & 6 && hmrDirtyComponents.has(n2.type)) {
n1.shapeFlag &= ~256;
n2.shapeFlag &= ~512;
return false;
}
return n1.type === n2.type && n1.key === n2.key;
}
const createVNodeWithArgsTransform = (...args) => {
return _createVNode(
...args
);
};
const InternalObjectKey = `__vInternal`;
const normalizeKey = ({ key }) => key != null ? key : null;
const normalizeRef = ({
ref: ref2,
ref_key,
ref_for
}) => {
if (typeof ref2 === "number") {
ref2 = "" + ref2;
}
return ref2 != null ? isString$1(ref2) || isRef(ref2) || isFunction$1(ref2) ? { i: currentRenderingInstance, r: ref2, k: ref_key, f: !!ref_for } : ref2 : null;
};
function createBaseVNode(type, props = null, children2 = null, patchFlag = 0, dynamicProps = null, shapeFlag = type === Fragment ? 0 : 1, isBlockNode = false, needFullChildrenNormalization = false) {
const vnode = {
__v_isVNode: true,
__v_skip: true,
type,
props,
key: props && normalizeKey(props),
ref: props && normalizeRef(props),
scopeId: currentScopeId,
slotScopeIds: null,
children: children2,
component: null,
suspense: null,
ssContent: null,
ssFallback: null,
dirs: null,
transition: null,
el: null,
anchor: null,
target: null,
targetAnchor: null,
staticCount: 0,
shapeFlag,
patchFlag,
dynamicProps,
dynamicChildren: null,
appContext: null,
ctx: currentRenderingInstance
};
if (needFullChildrenNormalization) {
normalizeChildren(vnode, children2);
if (shapeFlag & 128) {
type.normalize(vnode);
}
} else if (children2) {
vnode.shapeFlag |= isString$1(children2) ? 8 : 16;
}
if (vnode.key !== vnode.key) {
warn$2(`VNode created with invalid key (NaN). VNode type:`, vnode.type);
}
if (isBlockTreeEnabled > 0 && // avoid a block node from tracking itself
!isBlockNode && // has current parent block
currentBlock && // presence of a patch flag indicates this node needs patching on updates.
// component nodes also should always be patched, because even if the
// component doesn't need to update, it needs to persist the instance on to
// the next vnode so that it can be properly unmounted later.
(vnode.patchFlag > 0 || shapeFlag & 6) && // the EVENTS flag is only for hydration and if it is the only flag, the
// vnode should not be considered dynamic due to handler caching.
vnode.patchFlag !== 32) {
currentBlock.push(vnode);
}
return vnode;
}
const createVNode = createVNodeWithArgsTransform;
function _createVNode(type, props = null, children2 = null, patchFlag = 0, dynamicProps = null, isBlockNode = false) {
if (!type || type === NULL_DYNAMIC_COMPONENT) {
if (!type) {
warn$2(`Invalid vnode type when creating vnode: ${type}.`);
}
type = Comment;
}
if (isVNode(type)) {
const cloned = cloneVNode(
type,
props,
true
/* mergeRef: true */
);
if (children2) {
normalizeChildren(cloned, children2);
}
if (isBlockTreeEnabled > 0 && !isBlockNode && currentBlock) {
if (cloned.shapeFlag & 6) {
currentBlock[currentBlock.indexOf(type)] = cloned;
} else {
currentBlock.push(cloned);
}
}
cloned.patchFlag |= -2;
return cloned;
}
if (isClassComponent(type)) {
type = type.__vccOpts;
}
if (props) {
props = guardReactiveProps(props);
let { class: klass, style } = props;
if (klass && !isString$1(klass)) {
props.class = normalizeClass(klass);
}
if (isObject(style)) {
if (isProxy(style) && !isArray$1(style)) {
style = extend({}, style);
}
props.style = normalizeStyle(style);
}
}
const shapeFlag = isString$1(type) ? 1 : isSuspense(type) ? 128 : isTeleport(type) ? 64 : isObject(type) ? 4 : isFunction$1(type) ? 2 : 0;
if (shapeFlag & 4 && isProxy(type)) {
type = toRaw(type);
warn$2(
`Vue received a Component which was made a reactive object. This can lead to unnecessary performance overhead, and should be avoided by marking the component with \`markRaw\` or using \`shallowRef\` instead of \`ref\`.`,
`
Component that was made reactive: `,
type
);
}
return createBaseVNode(
type,
props,
children2,
patchFlag,
dynamicProps,
shapeFlag,
isBlockNode,
true
);
}
function guardReactiveProps(props) {
if (!props)
return null;
return isProxy(props) || InternalObjectKey in props ? extend({}, props) : props;
}
function cloneVNode(vnode, extraProps, mergeRef = false) {
const { props, ref: ref2, patchFlag, children: children2 } = vnode;
const mergedProps = extraProps ? mergeProps(props || {}, extraProps) : props;
const cloned = {
__v_isVNode: true,
__v_skip: true,
type: vnode.type,
props: mergedProps,
key: mergedProps && normalizeKey(mergedProps),
ref: extraProps && extraProps.ref ? (
// #2078 in the case of <component :is="vnode" ref="extra"/>
// if the vnode itself already has a ref, cloneVNode will need to merge
// the refs so the single vnode can be set on multiple refs
mergeRef && ref2 ? isArray$1(ref2) ? ref2.concat(normalizeRef(extraProps)) : [ref2, normalizeRef(extraProps)] : normalizeRef(extraProps)
) : ref2,
scopeId: vnode.scopeId,
slotScopeIds: vnode.slotScopeIds,
children: patchFlag === -1 && isArray$1(children2) ? children2.map(deepCloneVNode) : children2,
target: vnode.target,
targetAnchor: vnode.targetAnchor,
staticCount: vnode.staticCount,
shapeFlag: vnode.shapeFlag,
// if the vnode is cloned with extra props, we can no longer assume its
// existing patch flag to be reliable and need to add the FULL_PROPS flag.
// note: preserve flag for fragments since they use the flag for children
// fast paths only.
patchFlag: extraProps && vnode.type !== Fragment ? patchFlag === -1 ? 16 : patchFlag | 16 : patchFlag,
dynamicProps: vnode.dynamicProps,
dynamicChildren: vnode.dynamicChildren,
appContext: vnode.appContext,
dirs: vnode.dirs,
transition: vnode.transition,
// These should technically only be non-null on mounted VNodes. However,
// they *should* be copied for kept-alive vnodes. So we just always copy
// them since them being non-null during a mount doesn't affect the logic as
// they will simply be overwritten.
component: vnode.component,
suspense: vnode.suspense,
ssContent: vnode.ssContent && cloneVNode(vnode.ssContent),
ssFallback: vnode.ssFallback && cloneVNode(vnode.ssFallback),
el: vnode.el,
anchor: vnode.anchor,
ctx: vnode.ctx,
ce: vnode.ce
};
return cloned;
}
function deepCloneVNode(vnode) {
const cloned = cloneVNode(vnode);
if (isArray$1(vnode.children)) {
cloned.children = vnode.children.map(deepCloneVNode);
}
return cloned;
}
function createTextVNode(text2 = " ", flag = 0) {
return createVNode(Text, null, text2, flag);
}
function createStaticVNode(content, numberOfNodes) {
const vnode = createVNode(Static, null, content);
vnode.staticCount = numberOfNodes;
return vnode;
}
function createCommentVNode(text2 = "", asBlock = false) {
return asBlock ? (openBlock(), createBlock(Comment, null, text2)) : createVNode(Comment, null, text2);
}
function normalizeVNode(child) {
if (child == null || typeof child === "boolean") {
return createVNode(Comment);
} else if (isArray$1(child)) {
return createVNode(
Fragment,
null,
// #3666, avoid reference pollution when reusing vnode
child.slice()
);
} else if (typeof child === "object") {
return cloneIfMounted(child);
} else {
return createVNode(Text, null, String(child));
}
}
function cloneIfMounted(child) {
return child.el === null && child.patchFlag !== -1 || child.memo ? child : cloneVNode(child);
}
function normalizeChildren(vnode, children2) {
let type = 0;
const { shapeFlag } = vnode;
if (children2 == null) {
children2 = null;
} else if (isArray$1(children2)) {
type = 16;
} else if (typeof children2 === "object") {
if (shapeFlag & (1 | 64)) {
const slot = children2.default;
if (slot) {
slot._c && (slot._d = false);
normalizeChildren(vnode, slot());
slot._c && (slot._d = true);
}
return;
} else {
type = 32;
const slotFlag = children2._;
if (!slotFlag && !(InternalObjectKey in children2)) {
children2._ctx = currentRenderingInstance;
} else if (slotFlag === 3 && currentRenderingInstance) {
if (currentRenderingInstance.slots._ === 1) {
children2._ = 1;
} else {
children2._ = 2;
vnode.patchFlag |= 1024;
}
}
}
} else if (isFunction$1(children2)) {
children2 = { default: children2, _ctx: currentRenderingInstance };
type = 32;
} else {
children2 = String(children2);
if (shapeFlag & 64) {
type = 16;
children2 = [createTextVNode(children2)];
} else {
type = 8;
}
}
vnode.children = children2;
vnode.shapeFlag |= type;
}
function mergeProps(...args) {
const ret = {};
for (let i2 = 0; i2 < args.length; i2++) {
const toMerge = args[i2];
for (const key in toMerge) {
if (key === "class") {
if (ret.class !== toMerge.class) {
ret.class = normalizeClass([ret.class, toMerge.class]);
}
} else if (key === "style") {
ret.style = normalizeStyle([ret.style, toMerge.style]);
} else if (isOn(key)) {
const existing = ret[key];
const incoming = toMerge[key];
if (incoming && existing !== incoming && !(isArray$1(existing) && existing.includes(incoming))) {
ret[key] = existing ? [].concat(existing, incoming) : incoming;
}
} else if (key !== "") {
ret[key] = toMerge[key];
}
}
}
return ret;
}
function invokeVNodeHook(hook, instance, vnode, prevVNode = null) {
callWithAsyncErrorHandling(hook, instance, 7, [
vnode,
prevVNode
]);
}
const emptyAppContext = createAppContext();
let uid$2 = 0;
function createComponentInstance(vnode, parent, suspense) {
const type = vnode.type;
const appContext = (parent ? parent.appContext : vnode.appContext) || emptyAppContext;
const instance = {
uid: uid$2++,
vnode,
type,
parent,
appContext,
root: null,
// to be immediately set
next: null,
subTree: null,
// will be set synchronously right after creation
effect: null,
update: null,
// will be set synchronously right after creation
scope: new EffectScope(
true
/* detached */
),
render: null,
proxy: null,
exposed: null,
exposeProxy: null,
withProxy: null,
provides: parent ? parent.provides : Object.create(appContext.provides),
accessCache: null,
renderCache: [],
// local resolved assets
components: null,
directives: null,
// resolved props and emits options
propsOptions: normalizePropsOptions(type, appContext),
emitsOptions: normalizeEmitsOptions(type, appContext),
// emit
emit: null,
// to be set immediately
emitted: null,
// props default value
propsDefaults: EMPTY_OBJ,
// inheritAttrs
inheritAttrs: type.inheritAttrs,
// state
ctx: EMPTY_OBJ,
data: EMPTY_OBJ,
props: EMPTY_OBJ,
attrs: EMPTY_OBJ,
slots: EMPTY_OBJ,
refs: EMPTY_OBJ,
setupState: EMPTY_OBJ,
setupContext: null,
attrsProxy: null,
slotsProxy: null,
// suspense related
suspense,
suspenseId: suspense ? suspense.pendingId : 0,
asyncDep: null,
asyncResolved: false,
// lifecycle hooks
// not using enums here because it results in computed properties
isMounted: false,
isUnmounted: false,
isDeactivated: false,
bc: null,
c: null,
bm: null,
m: null,
bu: null,
u: null,
um: null,
bum: null,
da: null,
a: null,
rtg: null,
rtc: null,
ec: null,
sp: null
};
{
instance.ctx = createDevRenderContext(instance);
}
instance.root = parent ? parent.root : instance;
instance.emit = emit.bind(null, instance);
if (vnode.ce) {
vnode.ce(instance);
}
return instance;
}
let currentInstance = null;
const getCurrentInstance = () => currentInstance || currentRenderingInstance;
let internalSetCurrentInstance;
let globalCurrentInstanceSetters;
let settersKey = "__VUE_INSTANCE_SETTERS__";
{
if (!(globalCurrentInstanceSetters = getGlobalThis()[settersKey])) {
globalCurrentInstanceSetters = getGlobalThis()[settersKey] = [];
}
globalCurrentInstanceSetters.push((i2) => currentInstance = i2);
internalSetCurrentInstance = (instance) => {
if (globalCurrentInstanceSetters.length > 1) {
globalCurrentInstanceSetters.forEach((s) => s(instance));
} else {
globalCurrentInstanceSetters[0](instance);
}
};
}
const setCurrentInstance = (instance) => {
internalSetCurrentInstance(instance);
instance.scope.on();
};
const unsetCurrentInstance = () => {
currentInstance && currentInstance.scope.off();
internalSetCurrentInstance(null);
};
const isBuiltInTag = /* @__PURE__ */ makeMap("slot,component");
function validateComponentName(name, config2) {
const appIsNativeTag = config2.isNativeTag || NO;
if (isBuiltInTag(name) || appIsNativeTag(name)) {
warn$2(
"Do not use built-in or reserved HTML elements as component id: " + name
);
}
}
function isStatefulComponent(instance) {
return instance.vnode.shapeFlag & 4;
}
let isInSSRComponentSetup = false;
function setupComponent(instance, isSSR = false) {
isInSSRComponentSetup = isSSR;
const { props, children: children2 } = instance.vnode;
const isStateful = isStatefulComponent(instance);
initProps(instance, props, isStateful, isSSR);
initSlots(instance, children2);
const setupResult = isStateful ? setupStatefulComponent(instance, isSSR) : void 0;
isInSSRComponentSetup = false;
return setupResult;
}
function setupStatefulComponent(instance, isSSR) {
var _a2;
const Component = instance.type;
{
if (Component.name) {
validateComponentName(Component.name, instance.appContext.config);
}
if (Component.components) {
const names = Object.keys(Component.components);
for (let i2 = 0; i2 < names.length; i2++) {
validateComponentName(names[i2], instance.appContext.config);
}
}
if (Component.directives) {
const names = Object.keys(Component.directives);
for (let i2 = 0; i2 < names.length; i2++) {
validateDirectiveName(names[i2]);
}
}
if (Component.compilerOptions && isRuntimeOnly()) {
warn$2(
`"compilerOptions" is only supported when using a build of Vue that includes the runtime compiler. Since you are using a runtime-only build, the options should be passed via your build tool config instead.`
);
}
}
instance.accessCache = /* @__PURE__ */ Object.create(null);
instance.proxy = markRaw(new Proxy(instance.ctx, PublicInstanceProxyHandlers));
{
exposePropsOnRenderContext(instance);
}
const { setup } = Component;
if (setup) {
const setupContext = instance.setupContext = setup.length > 1 ? createSetupContext(instance) : null;
setCurrentInstance(instance);
pauseTracking();
const setupResult = callWithErrorHandling(
setup,
instance,
0,
[shallowReadonly(instance.props), setupContext]
);
resetTracking();
unsetCurrentInstance();
if (isPromise(setupResult)) {
setupResult.then(unsetCurrentInstance, unsetCurrentInstance);
if (isSSR) {
return setupResult.then((resolvedResult) => {
handleSetupResult(instance, resolvedResult, isSSR);
}).catch((e2) => {
handleError(e2, instance, 0);
});
} else {
instance.asyncDep = setupResult;
if (!instance.suspense) {
const name = (_a2 = Component.name) != null ? _a2 : "Anonymous";
warn$2(
`Component <${name}>: setup function returned a promise, but no <Suspense> boundary was found in the parent component tree. A component with async setup() must be nested in a <Suspense> in order to be rendered.`
);
}
}
} else {
handleSetupResult(instance, setupResult, isSSR);
}
} else {
finishComponentSetup(instance, isSSR);
}
}
function handleSetupResult(instance, setupResult, isSSR) {
if (isFunction$1(setupResult)) {
if (instance.type.__ssrInlineRender) {
instance.ssrRender = setupResult;
} else {
instance.render = setupResult;
}
} else if (isObject(setupResult)) {
if (isVNode(setupResult)) {
warn$2(
`setup() should not return VNodes directly - return a render function instead.`
);
}
{
instance.devtoolsRawSetupState = setupResult;
}
instance.setupState = proxyRefs(setupResult);
{
exposeSetupStateOnRenderContext(instance);
}
} else if (setupResult !== void 0) {
warn$2(
`setup() should return an object. Received: ${setupResult === null ? "null" : typeof setupResult}`
);
}
finishComponentSetup(instance, isSSR);
}
let compile$1;
const isRuntimeOnly = () => !compile$1;
function finishComponentSetup(instance, isSSR, skipOptions) {
const Component = instance.type;
if (!instance.render) {
if (!isSSR && compile$1 && !Component.render) {
const template = Component.template || resolveMergedOptions(instance).template;
if (template) {
{
startMeasure(instance, `compile`);
}
const { isCustomElement, compilerOptions } = instance.appContext.config;
const { delimiters, compilerOptions: componentCompilerOptions } = Component;
const finalCompilerOptions = extend(
extend(
{
isCustomElement,
delimiters
},
compilerOptions
),
componentCompilerOptions
);
Component.render = compile$1(template, finalCompilerOptions);
{
endMeasure(instance, `compile`);
}
}
}
instance.render = Component.render || NOOP;
}
{
setCurrentInstance(instance);
pauseTracking();
try {
applyOptions(instance);
} finally {
resetTracking();
unsetCurrentInstance();
}
}
if (!Component.render && instance.render === NOOP && !isSSR) {
if (Component.template) {
warn$2(
`Component provided template option but runtime compilation is not supported in this build of Vue. Configure your bundler to alias "vue" to "vue/dist/vue.esm-bundler.js".`
/* should not happen */
);
} else {
warn$2(`Component is missing template or render function.`);
}
}
}
function getAttrsProxy(instance) {
return instance.attrsProxy || (instance.attrsProxy = new Proxy(
instance.attrs,
{
get(target, key) {
markAttrsAccessed();
track(instance, "get", "$attrs");
return target[key];
},
set() {
warn$2(`setupContext.attrs is readonly.`);
return false;
},
deleteProperty() {
warn$2(`setupContext.attrs is readonly.`);
return false;
}
}
));
}
function getSlotsProxy(instance) {
return instance.slotsProxy || (instance.slotsProxy = new Proxy(instance.slots, {
get(target, key) {
track(instance, "get", "$slots");
return target[key];
}
}));
}
function createSetupContext(instance) {
const expose = (exposed) => {
{
if (instance.exposed) {
warn$2(`expose() should be called only once per setup().`);
}
if (exposed != null) {
let exposedType = typeof exposed;
if (exposedType === "object") {
if (isArray$1(exposed)) {
exposedType = "array";
} else if (isRef(exposed)) {
exposedType = "ref";
}
}
if (exposedType !== "object") {
warn$2(
`expose() should be passed a plain object, received ${exposedType}.`
);
}
}
}
instance.exposed = exposed || {};
};
{
return Object.freeze({
get attrs() {
return getAttrsProxy(instance);
},
get slots() {
return getSlotsProxy(instance);
},
get emit() {
return (event, ...args) => instance.emit(event, ...args);
},
expose
});
}
}
function getExposeProxy(instance) {
if (instance.exposed) {
return instance.exposeProxy || (instance.exposeProxy = new Proxy(proxyRefs(markRaw(instance.exposed)), {
get(target, key) {
if (key in target) {
return target[key];
} else if (key in publicPropertiesMap) {
return publicPropertiesMap[key](instance);
}
},
has(target, key) {
return key in target || key in publicPropertiesMap;
}
}));
}
}
const classifyRE = /(?:^|[-_])(\w)/g;
const classify = (str) => str.replace(classifyRE, (c2) => c2.toUpperCase()).replace(/[-_]/g, "");
function getComponentName(Component, includeInferred = true) {
return isFunction$1(Component) ? Component.displayName || Component.name : Component.name || includeInferred && Component.__name;
}
function formatComponentName(instance, Component, isRoot = false) {
let name = getComponentName(Component);
if (!name && Component.__file) {
const match = Component.__file.match(/([^/\\]+)\.\w+$/);
if (match) {
name = match[1];
}
}
if (!name && instance && instance.parent) {
const inferFromRegistry = (registry) => {
for (const key in registry) {
if (registry[key] === Component) {
return key;
}
}
};
name = inferFromRegistry(
instance.components || instance.parent.type.components
) || inferFromRegistry(instance.appContext.components);
}
return name ? classify(name) : isRoot ? `App` : `Anonymous`;
}
function isClassComponent(value) {
return isFunction$1(value) && "__vccOpts" in value;
}
const computed = (getterOrOptions, debugOptions) => {
return computed$1(getterOrOptions, debugOptions, isInSSRComponentSetup);
};
function h$2(type, propsOrChildren, children2) {
const l = arguments.length;
if (l === 2) {
if (isObject(propsOrChildren) && !isArray$1(propsOrChildren)) {
if (isVNode(propsOrChildren)) {
return createVNode(type, null, [propsOrChildren]);
}
return createVNode(type, propsOrChildren);
} else {
return createVNode(type, null, propsOrChildren);
}
} else {
if (l > 3) {
children2 = Array.prototype.slice.call(arguments, 2);
} else if (l === 3 && isVNode(children2)) {
children2 = [children2];
}
return createVNode(type, propsOrChildren, children2);
}
}
const ssrContextKey = Symbol.for("v-scx");
const useSSRContext = () => {
{
const ctx = inject(ssrContextKey);
if (!ctx) {
warn$2(
`Server rendering context not provided. Make sure to only call useSSRContext() conditionally in the server build.`
);
}
return ctx;
}
};
function isShallow(value) {
return !!(value && value["__v_isShallow"]);
}
function initCustomFormatter() {
if (typeof window === "undefined") {
return;
}
const vueStyle = { style: "color:#3ba776" };
const numberStyle = { style: "color:#0b1bc9" };
const stringStyle = { style: "color:#b62e24" };
const keywordStyle = { style: "color:#9d288c" };
const formatter = {
header(obj) {
if (!isObject(obj)) {
return null;
}
if (obj.__isVue) {
return ["div", vueStyle, `VueInstance`];
} else if (isRef(obj)) {
return [
"div",
{},
["span", vueStyle, genRefFlag(obj)],
"<",
formatValue(obj.value),
`>`
];
} else if (isReactive(obj)) {
return [
"div",
{},
["span", vueStyle, isShallow(obj) ? "ShallowReactive" : "Reactive"],
"<",
formatValue(obj),
`>${isReadonly(obj) ? ` (readonly)` : ``}`
];
} else if (isReadonly(obj)) {
return [
"div",
{},
["span", vueStyle, isShallow(obj) ? "ShallowReadonly" : "Readonly"],
"<",
formatValue(obj),
">"
];
}
return null;
},
hasBody(obj) {
return obj && obj.__isVue;
},
body(obj) {
if (obj && obj.__isVue) {
return [
"div",
{},
...formatInstance(obj.$)
];
}
}
};
function formatInstance(instance) {
const blocks = [];
if (instance.type.props && instance.props) {
blocks.push(createInstanceBlock("props", toRaw(instance.props)));
}
if (instance.setupState !== EMPTY_OBJ) {
blocks.push(createInstanceBlock("setup", instance.setupState));
}
if (instance.data !== EMPTY_OBJ) {
blocks.push(createInstanceBlock("data", toRaw(instance.data)));
}
const computed2 = extractKeys(instance, "computed");
if (computed2) {
blocks.push(createInstanceBlock("computed", computed2));
}
const injected = extractKeys(instance, "inject");
if (injected) {
blocks.push(createInstanceBlock("injected", injected));
}
blocks.push([
"div",
{},
[
"span",
{
style: keywordStyle.style + ";opacity:0.66"
},
"$ (internal): "
],
["object", { object: instance }]
]);
return blocks;
}
function createInstanceBlock(type, target) {
target = extend({}, target);
if (!Object.keys(target).length) {
return ["span", {}];
}
return [
"div",
{ style: "line-height:1.25em;margin-bottom:0.6em" },
[
"div",
{
style: "color:#476582"
},
type
],
[
"div",
{
style: "padding-left:1.25em"
},
...Object.keys(target).map((key) => {
return [
"div",
{},
["span", keywordStyle, key + ": "],
formatValue(target[key], false)
];
})
]
];
}
function formatValue(v2, asRaw = true) {
if (typeof v2 === "number") {
return ["span", numberStyle, v2];
} else if (typeof v2 === "string") {
return ["span", stringStyle, JSON.stringify(v2)];
} else if (typeof v2 === "boolean") {
return ["span", keywordStyle, v2];
} else if (isObject(v2)) {
return ["object", { object: asRaw ? toRaw(v2) : v2 }];
} else {
return ["span", stringStyle, String(v2)];
}
}
function extractKeys(instance, type) {
const Comp = instance.type;
if (isFunction$1(Comp)) {
return;
}
const extracted = {};
for (const key in instance.ctx) {
if (isKeyOfType(Comp, key, type)) {
extracted[key] = instance.ctx[key];
}
}
return extracted;
}
function isKeyOfType(Comp, key, type) {
const opts = Comp[type];
if (isArray$1(opts) && opts.includes(key) || isObject(opts) && key in opts) {
return true;
}
if (Comp.extends && isKeyOfType(Comp.extends, key, type)) {
return true;
}
if (Comp.mixins && Comp.mixins.some((m) => isKeyOfType(m, key, type))) {
return true;
}
}
function genRefFlag(v2) {
if (isShallow(v2)) {
return `ShallowRef`;
}
if (v2.effect) {
return `ComputedRef`;
}
return `Ref`;
}
if (window.devtoolsFormatters) {
window.devtoolsFormatters.push(formatter);
} else {
window.devtoolsFormatters = [formatter];
}
}
const version$1 = "3.3.8";
const svgNS = "http://www.w3.org/2000/svg";
const doc = typeof document !== "undefined" ? document : null;
const templateContainer = doc && /* @__PURE__ */ doc.createElement("template");
const nodeOps = {
insert: (child, parent, anchor) => {
parent.insertBefore(child, anchor || null);
},
remove: (child) => {
const parent = child.parentNode;
if (parent) {
parent.removeChild(child);
}
},
createElement: (tag, isSVG, is2, props) => {
const el2 = isSVG ? doc.createElementNS(svgNS, tag) : doc.createElement(tag, is2 ? { is: is2 } : void 0);
if (tag === "select" && props && props.multiple != null) {
el2.setAttribute("multiple", props.multiple);
}
return el2;
},
createText: (text2) => doc.createTextNode(text2),
createComment: (text2) => doc.createComment(text2),
setText: (node, text2) => {
node.nodeValue = text2;
},
setElementText: (el2, text2) => {
el2.textContent = text2;
},
parentNode: (node) => node.parentNode,
nextSibling: (node) => node.nextSibling,
querySelector: (selector) => doc.querySelector(selector),
setScopeId(el2, id2) {
el2.setAttribute(id2, "");
},
// __UNSAFE__
// Reason: innerHTML.
// Static content here can only come from compiled templates.
// As long as the user only uses trusted templates, this is safe.
insertStaticContent(content, parent, anchor, isSVG, start, end) {
const before = anchor ? anchor.previousSibling : parent.lastChild;
if (start && (start === end || start.nextSibling)) {
while (true) {
parent.insertBefore(start.cloneNode(true), anchor);
if (start === end || !(start = start.nextSibling))
break;
}
} else {
templateContainer.innerHTML = isSVG ? `<svg>${content}</svg>` : content;
const template = templateContainer.content;
if (isSVG) {
const wrapper = template.firstChild;
while (wrapper.firstChild) {
template.appendChild(wrapper.firstChild);
}
template.removeChild(wrapper);
}
parent.insertBefore(template, anchor);
}
return [
// first
before ? before.nextSibling : parent.firstChild,
// last
anchor ? anchor.previousSibling : parent.lastChild
];
}
};
const TRANSITION = "transition";
const ANIMATION = "animation";
const vtcKey = Symbol("_vtc");
const Transition = (props, { slots }) => h$2(BaseTransition, resolveTransitionProps(props), slots);
Transition.displayName = "Transition";
const DOMTransitionPropsValidators = {
name: String,
type: String,
css: {
type: Boolean,
default: true
},
duration: [String, Number, Object],
enterFromClass: String,
enterActiveClass: String,
enterToClass: String,
appearFromClass: String,
appearActiveClass: String,
appearToClass: String,
leaveFromClass: String,
leaveActiveClass: String,
leaveToClass: String
};
const TransitionPropsValidators = Transition.props = /* @__PURE__ */ extend(
{},
BaseTransitionPropsValidators,
DOMTransitionPropsValidators
);
const callHook = (hook, args = []) => {
if (isArray$1(hook)) {
hook.forEach((h2) => h2(...args));
} else if (hook) {
hook(...args);
}
};
const hasExplicitCallback = (hook) => {
return hook ? isArray$1(hook) ? hook.some((h2) => h2.length > 1) : hook.length > 1 : false;
};
function resolveTransitionProps(rawProps) {
const baseProps = {};
for (const key in rawProps) {
if (!(key in DOMTransitionPropsValidators)) {
baseProps[key] = rawProps[key];
}
}
if (rawProps.css === false) {
return baseProps;
}
const {
name = "v",
type,
duration,
enterFromClass = `${name}-enter-from`,
enterActiveClass = `${name}-enter-active`,
enterToClass = `${name}-enter-to`,
appearFromClass = enterFromClass,
appearActiveClass = enterActiveClass,
appearToClass = enterToClass,
leaveFromClass = `${name}-leave-from`,
leaveActiveClass = `${name}-leave-active`,
leaveToClass = `${name}-leave-to`
} = rawProps;
const durations = normalizeDuration(duration);
const enterDuration = durations && durations[0];
const leaveDuration = durations && durations[1];
const {
onBeforeEnter,
onEnter,
onEnterCancelled,
onLeave,
onLeaveCancelled,
onBeforeAppear = onBeforeEnter,
onAppear = onEnter,
onAppearCancelled = onEnterCancelled
} = baseProps;
const finishEnter = (el2, isAppear, done) => {
removeTransitionClass(el2, isAppear ? appearToClass : enterToClass);
removeTransitionClass(el2, isAppear ? appearActiveClass : enterActiveClass);
done && done();
};
const finishLeave = (el2, done) => {
el2._isLeaving = false;
removeTransitionClass(el2, leaveFromClass);
removeTransitionClass(el2, leaveToClass);
removeTransitionClass(el2, leaveActiveClass);
done && done();
};
const makeEnterHook = (isAppear) => {
return (el2, done) => {
const hook = isAppear ? onAppear : onEnter;
const resolve2 = () => finishEnter(el2, isAppear, done);
callHook(hook, [el2, resolve2]);
nextFrame$1(() => {
removeTransitionClass(el2, isAppear ? appearFromClass : enterFromClass);
addTransitionClass(el2, isAppear ? appearToClass : enterToClass);
if (!hasExplicitCallback(hook)) {
whenTransitionEnds(el2, type, enterDuration, resolve2);
}
});
};
};
return extend(baseProps, {
onBeforeEnter(el2) {
callHook(onBeforeEnter, [el2]);
addTransitionClass(el2, enterFromClass);
addTransitionClass(el2, enterActiveClass);
},
onBeforeAppear(el2) {
callHook(onBeforeAppear, [el2]);
addTransitionClass(el2, appearFromClass);
addTransitionClass(el2, appearActiveClass);
},
onEnter: makeEnterHook(false),
onAppear: makeEnterHook(true),
onLeave(el2, done) {
el2._isLeaving = true;
const resolve2 = () => finishLeave(el2, done);
addTransitionClass(el2, leaveFromClass);
forceReflow();
addTransitionClass(el2, leaveActiveClass);
nextFrame$1(() => {
if (!el2._isLeaving) {
return;
}
removeTransitionClass(el2, leaveFromClass);
addTransitionClass(el2, leaveToClass);
if (!hasExplicitCallback(onLeave)) {
whenTransitionEnds(el2, type, leaveDuration, resolve2);
}
});
callHook(onLeave, [el2, resolve2]);
},
onEnterCancelled(el2) {
finishEnter(el2, false);
callHook(onEnterCancelled, [el2]);
},
onAppearCancelled(el2) {
finishEnter(el2, true);
callHook(onAppearCancelled, [el2]);
},
onLeaveCancelled(el2) {
finishLeave(el2);
callHook(onLeaveCancelled, [el2]);
}
});
}
function normalizeDuration(duration) {
if (duration == null) {
return null;
} else if (isObject(duration)) {
return [NumberOf(duration.enter), NumberOf(duration.leave)];
} else {
const n2 = NumberOf(duration);
return [n2, n2];
}
}
function NumberOf(val) {
const res = toNumber(val);
{
assertNumber(res, "<transition> explicit duration");
}
return res;
}
function addTransitionClass(el2, cls) {
cls.split(/\s+/).forEach((c2) => c2 && el2.classList.add(c2));
(el2[vtcKey] || (el2[vtcKey] = /* @__PURE__ */ new Set())).add(cls);
}
function removeTransitionClass(el2, cls) {
cls.split(/\s+/).forEach((c2) => c2 && el2.classList.remove(c2));
const _vtc = el2[vtcKey];
if (_vtc) {
_vtc.delete(cls);
if (!_vtc.size) {
el2[vtcKey] = void 0;
}
}
}
function nextFrame$1(cb) {
requestAnimationFrame(() => {
requestAnimationFrame(cb);
});
}
let endId = 0;
function whenTransitionEnds(el2, expectedType, explicitTimeout, resolve2) {
const id2 = el2._endId = ++endId;
const resolveIfNotStale = () => {
if (id2 === el2._endId) {
resolve2();
}
};
if (explicitTimeout) {
return setTimeout(resolveIfNotStale, explicitTimeout);
}
const { type, timeout, propCount } = getTransitionInfo(el2, expectedType);
if (!type) {
return resolve2();
}
const endEvent = type + "end";
let ended = 0;
const end = () => {
el2.removeEventListener(endEvent, onEnd);
resolveIfNotStale();
};
const onEnd = (e2) => {
if (e2.target === el2 && ++ended >= propCount) {
end();
}
};
setTimeout(() => {
if (ended < propCount) {
end();
}
}, timeout + 1);
el2.addEventListener(endEvent, onEnd);
}
function getTransitionInfo(el2, expectedType) {
const styles = window.getComputedStyle(el2);
const getStyleProperties = (key) => (styles[key] || "").split(", ");
const transitionDelays = getStyleProperties(`${TRANSITION}Delay`);
const transitionDurations = getStyleProperties(`${TRANSITION}Duration`);
const transitionTimeout = getTimeout(transitionDelays, transitionDurations);
const animationDelays = getStyleProperties(`${ANIMATION}Delay`);
const animationDurations = getStyleProperties(`${ANIMATION}Duration`);
const animationTimeout = getTimeout(animationDelays, animationDurations);
let type = null;
let timeout = 0;
let 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;
}
const hasTransform = type === TRANSITION && /\b(transform|all)(,|$)/.test(
getStyleProperties(`${TRANSITION}Property`).toString()
);
return {
type,
timeout,
propCount,
hasTransform
};
}
function getTimeout(delays, durations) {
while (delays.length < durations.length) {
delays = delays.concat(delays);
}
return Math.max(...durations.map((d2, i2) => toMs(d2) + toMs(delays[i2])));
}
function toMs(s) {
if (s === "auto")
return 0;
return Number(s.slice(0, -1).replace(",", ".")) * 1e3;
}
function forceReflow() {
return document.body.offsetHeight;
}
function patchClass(el2, value, isSVG) {
const transitionClasses = el2[vtcKey];
if (transitionClasses) {
value = (value ? [value, ...transitionClasses] : [...transitionClasses]).join(" ");
}
if (value == null) {
el2.removeAttribute("class");
} else if (isSVG) {
el2.setAttribute("class", value);
} else {
el2.className = value;
}
}
const vShowOldKey = Symbol("_vod");
const vShow = {
beforeMount(el2, { value }, { transition }) {
el2[vShowOldKey] = el2.style.display === "none" ? "" : el2.style.display;
if (transition && value) {
transition.beforeEnter(el2);
} else {
setDisplay(el2, value);
}
},
mounted(el2, { value }, { transition }) {
if (transition && value) {
transition.enter(el2);
}
},
updated(el2, { value, oldValue }, { transition }) {
if (!value === !oldValue)
return;
if (transition) {
if (value) {
transition.beforeEnter(el2);
setDisplay(el2, true);
transition.enter(el2);
} else {
transition.leave(el2, () => {
setDisplay(el2, false);
});
}
} else {
setDisplay(el2, value);
}
},
beforeUnmount(el2, { value }) {
setDisplay(el2, value);
}
};
function setDisplay(el2, value) {
el2.style.display = value ? el2[vShowOldKey] : "none";
}
function patchStyle(el2, prev, next) {
const style = el2.style;
const isCssString = isString$1(next);
if (next && !isCssString) {
if (prev && !isString$1(prev)) {
for (const key in prev) {
if (next[key] == null) {
setStyle(style, key, "");
}
}
}
for (const key in next) {
setStyle(style, key, next[key]);
}
} else {
const currentDisplay = style.display;
if (isCssString) {
if (prev !== next) {
style.cssText = next;
}
} else if (prev) {
el2.removeAttribute("style");
}
if (vShowOldKey in el2) {
style.display = currentDisplay;
}
}
}
const semicolonRE = /[^\\];\s*$/;
const importantRE = /\s*!important$/;
function setStyle(style, name, val) {
if (isArray$1(val)) {
val.forEach((v2) => setStyle(style, name, v2));
} else {
if (val == null)
val = "";
{
if (semicolonRE.test(val)) {
warn$2(
`Unexpected semicolon at the end of '${name}' style value: '${val}'`
);
}
}
if (name.startsWith("--")) {
style.setProperty(name, val);
} else {
const prefixed = autoPrefix(style, name);
if (importantRE.test(val)) {
style.setProperty(
hyphenate(prefixed),
val.replace(importantRE, ""),
"important"
);
} else {
style[prefixed] = val;
}
}
}
}
const prefixes = ["Webkit", "Moz", "ms"];
const prefixCache = {};
function autoPrefix(style, rawName) {
const cached = prefixCache[rawName];
if (cached) {
return cached;
}
let name = camelize(rawName);
if (name !== "filter" && name in style) {
return prefixCache[rawName] = name;
}
name = capitalize(name);
for (let i2 = 0; i2 < prefixes.length; i2++) {
const prefixed = prefixes[i2] + name;
if (prefixed in style) {
return prefixCache[rawName] = prefixed;
}
}
return rawName;
}
const xlinkNS = "http://www.w3.org/1999/xlink";
function patchAttr(el2, key, value, isSVG, instance) {
if (isSVG && key.startsWith("xlink:")) {
if (value == null) {
el2.removeAttributeNS(xlinkNS, key.slice(6, key.length));
} else {
el2.setAttributeNS(xlinkNS, key, value);
}
} else {
const isBoolean2 = isSpecialBooleanAttr(key);
if (value == null || isBoolean2 && !includeBooleanAttr(value)) {
el2.removeAttribute(key);
} else {
el2.setAttribute(key, isBoolean2 ? "" : value);
}
}
}
function patchDOMProp(el2, key, value, prevChildren, parentComponent, parentSuspense, unmountChildren) {
if (key === "innerHTML" || key === "textContent") {
if (prevChildren) {
unmountChildren(prevChildren, parentComponent, parentSuspense);
}
el2[key] = value == null ? "" : value;
return;
}
const tag = el2.tagName;
if (key === "value" && tag !== "PROGRESS" && // custom elements may use _value internally
!tag.includes("-")) {
el2._value = value;
const oldValue = tag === "OPTION" ? el2.getAttribute("value") : el2.value;
const newValue = value == null ? "" : value;
if (oldValue !== newValue) {
el2.value = newValue;
}
if (value == null) {
el2.removeAttribute(key);
}
return;
}
let needRemove = false;
if (value === "" || value == null) {
const type = typeof el2[key];
if (type === "boolean") {
value = includeBooleanAttr(value);
} else if (value == null && type === "string") {
value = "";
needRemove = true;
} else if (type === "number") {
value = 0;
needRemove = true;
}
}
try {
el2[key] = value;
} catch (e2) {
if (!needRemove) {
warn$2(
`Failed setting prop "${key}" on <${tag.toLowerCase()}>: value ${value} is invalid.`,
e2
);
}
}
needRemove && el2.removeAttribute(key);
}
function addEventListener(el2, event, handler, options) {
el2.addEventListener(event, handler, options);
}
function removeEventListener(el2, event, handler, options) {
el2.removeEventListener(event, handler, options);
}
const veiKey = Symbol("_vei");
function patchEvent(el2, rawName, prevValue, nextValue, instance = null) {
const invokers = el2[veiKey] || (el2[veiKey] = {});
const existingInvoker = invokers[rawName];
if (nextValue && existingInvoker) {
existingInvoker.value = nextValue;
} else {
const [name, options] = parseName(rawName);
if (nextValue) {
const invoker = invokers[rawName] = createInvoker(nextValue, instance);
addEventListener(el2, name, invoker, options);
} else if (existingInvoker) {
removeEventListener(el2, name, existingInvoker, options);
invokers[rawName] = void 0;
}
}
}
const optionsModifierRE = /(?:Once|Passive|Capture)$/;
function parseName(name) {
let options;
if (optionsModifierRE.test(name)) {
options = {};
let m;
while (m = name.match(optionsModifierRE)) {
name = name.slice(0, name.length - m[0].length);
options[m[0].toLowerCase()] = true;
}
}
const event = name[2] === ":" ? name.slice(3) : hyphenate(name.slice(2));
return [event, options];
}
let cachedNow = 0;
const p = /* @__PURE__ */ Promise.resolve();
const getNow = () => cachedNow || (p.then(() => cachedNow = 0), cachedNow = Date.now());
function createInvoker(initialValue, instance) {
const invoker = (e2) => {
if (!e2._vts) {
e2._vts = Date.now();
} else if (e2._vts <= invoker.attached) {
return;
}
callWithAsyncErrorHandling(
patchStopImmediatePropagation(e2, invoker.value),
instance,
5,
[e2]
);
};
invoker.value = initialValue;
invoker.attached = getNow();
return invoker;
}
function patchStopImmediatePropagation(e2, value) {
if (isArray$1(value)) {
const originalStop = e2.stopImmediatePropagation;
e2.stopImmediatePropagation = () => {
originalStop.call(e2);
e2._stopped = true;
};
return value.map((fn2) => (e22) => !e22._stopped && fn2 && fn2(e22));
} else {
return value;
}
}
const nativeOnRE = /^on[a-z]/;
const patchProp = (el2, key, prevValue, nextValue, isSVG = false, prevChildren, parentComponent, parentSuspense, unmountChildren) => {
if (key === "class") {
patchClass(el2, nextValue, isSVG);
} else if (key === "style") {
patchStyle(el2, prevValue, nextValue);
} else if (isOn(key)) {
if (!isModelListener(key)) {
patchEvent(el2, key, prevValue, nextValue, parentComponent);
}
} else if (key[0] === "." ? (key = key.slice(1), true) : key[0] === "^" ? (key = key.slice(1), false) : shouldSetAsProp(el2, key, nextValue, isSVG)) {
patchDOMProp(
el2,
key,
nextValue,
prevChildren,
parentComponent,
parentSuspense,
unmountChildren
);
} else {
if (key === "true-value") {
el2._trueValue = nextValue;
} else if (key === "false-value") {
el2._falseValue = nextValue;
}
patchAttr(el2, key, nextValue, isSVG);
}
};
function shouldSetAsProp(el2, key, value, isSVG) {
if (isSVG) {
if (key === "innerHTML" || key === "textContent") {
return true;
}
if (key in el2 && nativeOnRE.test(key) && isFunction$1(value)) {
return true;
}
return false;
}
if (key === "spellcheck" || key === "draggable" || key === "translate") {
return false;
}
if (key === "form") {
return false;
}
if (key === "list" && el2.tagName === "INPUT") {
return false;
}
if (key === "type" && el2.tagName === "TEXTAREA") {
return false;
}
if (nativeOnRE.test(key) && isString$1(value)) {
return false;
}
return key in el2;
}
function useCssVars(getter) {
const instance = getCurrentInstance();
if (!instance) {
warn$2(`useCssVars is called without current active component instance.`);
return;
}
const updateTeleports = instance.ut = (vars = getter(instance.proxy)) => {
Array.from(
document.querySelectorAll(`[data-v-owner="${instance.uid}"]`)
).forEach((node) => setVarsOnNode(node, vars));
};
const setVars = () => {
const vars = getter(instance.proxy);
setVarsOnVNode(instance.subTree, vars);
updateTeleports(vars);
};
watchPostEffect(setVars);
onMounted(() => {
const ob = new MutationObserver(setVars);
ob.observe(instance.subTree.el.parentNode, { childList: true });
onUnmounted(() => ob.disconnect());
});
}
function setVarsOnVNode(vnode, vars) {
if (vnode.shapeFlag & 128) {
const suspense = vnode.suspense;
vnode = suspense.activeBranch;
if (suspense.pendingBranch && !suspense.isHydrating) {
suspense.effects.push(() => {
setVarsOnVNode(suspense.activeBranch, vars);
});
}
}
while (vnode.component) {
vnode = vnode.component.subTree;
}
if (vnode.shapeFlag & 1 && vnode.el) {
setVarsOnNode(vnode.el, vars);
} else if (vnode.type === Fragment) {
vnode.children.forEach((c2) => setVarsOnVNode(c2, vars));
} else if (vnode.type === Static) {
let { el: el2, anchor } = vnode;
while (el2) {
setVarsOnNode(el2, vars);
if (el2 === anchor)
break;
el2 = el2.nextSibling;
}
}
}
function setVarsOnNode(el2, vars) {
if (el2.nodeType === 1) {
const style = el2.style;
for (const key in vars) {
style.setProperty(`--${key}`, vars[key]);
}
}
}
const positionMap = /* @__PURE__ */ new WeakMap();
const newPositionMap = /* @__PURE__ */ new WeakMap();
const moveCbKey = Symbol("_moveCb");
const enterCbKey = Symbol("_enterCb");
const TransitionGroupImpl = {
name: "TransitionGroup",
props: /* @__PURE__ */ extend({}, TransitionPropsValidators, {
tag: String,
moveClass: String
}),
setup(props, { slots }) {
const instance = getCurrentInstance();
const state = useTransitionState();
let prevChildren;
let children2;
onUpdated(() => {
if (!prevChildren.length) {
return;
}
const moveClass = props.moveClass || `${props.name || "v"}-move`;
if (!hasCSSTransform(
prevChildren[0].el,
instance.vnode.el,
moveClass
)) {
return;
}
prevChildren.forEach(callPendingCbs);
prevChildren.forEach(recordPosition);
const movedChildren = prevChildren.filter(applyTranslation);
forceReflow();
movedChildren.forEach((c2) => {
const el2 = c2.el;
const style = el2.style;
addTransitionClass(el2, moveClass);
style.transform = style.webkitTransform = style.transitionDuration = "";
const cb = el2[moveCbKey] = (e2) => {
if (e2 && e2.target !== el2) {
return;
}
if (!e2 || /transform$/.test(e2.propertyName)) {
el2.removeEventListener("transitionend", cb);
el2[moveCbKey] = null;
removeTransitionClass(el2, moveClass);
}
};
el2.addEventListener("transitionend", cb);
});
});
return () => {
const rawProps = toRaw(props);
const cssTransitionProps = resolveTransitionProps(rawProps);
let tag = rawProps.tag || Fragment;
prevChildren = children2;
children2 = slots.default ? getTransitionRawChildren(slots.default()) : [];
for (let i2 = 0; i2 < children2.length; i2++) {
const child = children2[i2];
if (child.key != null) {
setTransitionHooks(
child,
resolveTransitionHooks(child, cssTransitionProps, state, instance)
);
} else {
warn$2(`<TransitionGroup> children must be keyed.`);
}
}
if (prevChildren) {
for (let i2 = 0; i2 < prevChildren.length; i2++) {
const child = prevChildren[i2];
setTransitionHooks(
child,
resolveTransitionHooks(child, cssTransitionProps, state, instance)
);
positionMap.set(child, child.el.getBoundingClientRect());
}
}
return createVNode(tag, null, children2);
};
}
};
const removeMode = (props) => delete props.mode;
/* @__PURE__ */ removeMode(TransitionGroupImpl.props);
function callPendingCbs(c2) {
const el2 = c2.el;
if (el2[moveCbKey]) {
el2[moveCbKey]();
}
if (el2[enterCbKey]) {
el2[enterCbKey]();
}
}
function recordPosition(c2) {
newPositionMap.set(c2, c2.el.getBoundingClientRect());
}
function applyTranslation(c2) {
const oldPos = positionMap.get(c2);
const newPos = newPositionMap.get(c2);
const dx = oldPos.left - newPos.left;
const dy = oldPos.top - newPos.top;
if (dx || dy) {
const s = c2.el.style;
s.transform = s.webkitTransform = `translate(${dx}px,${dy}px)`;
s.transitionDuration = "0s";
return c2;
}
}
function hasCSSTransform(el2, root, moveClass) {
const clone2 = el2.cloneNode();
const _vtc = el2[vtcKey];
if (_vtc) {
_vtc.forEach((cls) => {
cls.split(/\s+/).forEach((c2) => c2 && clone2.classList.remove(c2));
});
}
moveClass.split(/\s+/).forEach((c2) => c2 && clone2.classList.add(c2));
clone2.style.display = "none";
const container = root.nodeType === 1 ? root : root.parentNode;
container.appendChild(clone2);
const { hasTransform } = getTransitionInfo(clone2);
container.removeChild(clone2);
return hasTransform;
}
const getModelAssigner = (vnode) => {
const fn2 = vnode.props["onUpdate:modelValue"] || false;
return isArray$1(fn2) ? (value) => invokeArrayFns(fn2, value) : fn2;
};
function onCompositionStart(e2) {
e2.target.composing = true;
}
function onCompositionEnd(e2) {
const target = e2.target;
if (target.composing) {
target.composing = false;
target.dispatchEvent(new Event("input"));
}
}
const assignKey = Symbol("_assign");
const vModelText = {
created(el2, { modifiers: { lazy, trim, number } }, vnode) {
el2[assignKey] = getModelAssigner(vnode);
const castToNumber = number || vnode.props && vnode.props.type === "number";
addEventListener(el2, lazy ? "change" : "input", (e2) => {
if (e2.target.composing)
return;
let domValue = el2.value;
if (trim) {
domValue = domValue.trim();
}
if (castToNumber) {
domValue = looseToNumber(domValue);
}
el2[assignKey](domValue);
});
if (trim) {
addEventListener(el2, "change", () => {
el2.value = el2.value.trim();
});
}
if (!lazy) {
addEventListener(el2, "compositionstart", onCompositionStart);
addEventListener(el2, "compositionend", onCompositionEnd);
addEventListener(el2, "change", onCompositionEnd);
}
},
// set value on mounted so it's after min/max for type="range"
mounted(el2, { value }) {
el2.value = value == null ? "" : value;
},
beforeUpdate(el2, { value, modifiers: { lazy, trim, number } }, vnode) {
el2[assignKey] = getModelAssigner(vnode);
if (el2.composing)
return;
if (document.activeElement === el2 && el2.type !== "range") {
if (lazy) {
return;
}
if (trim && el2.value.trim() === value) {
return;
}
if ((number || el2.type === "number") && looseToNumber(el2.value) === value) {
return;
}
}
const newValue = value == null ? "" : value;
if (el2.value !== newValue) {
el2.value = newValue;
}
}
};
const systemModifiers = ["ctrl", "shift", "alt", "meta"];
const modifierGuards = {
stop: (e2) => e2.stopPropagation(),
prevent: (e2) => e2.preventDefault(),
self: (e2) => e2.target !== e2.currentTarget,
ctrl: (e2) => !e2.ctrlKey,
shift: (e2) => !e2.shiftKey,
alt: (e2) => !e2.altKey,
meta: (e2) => !e2.metaKey,
left: (e2) => "button" in e2 && e2.button !== 0,
middle: (e2) => "button" in e2 && e2.button !== 1,
right: (e2) => "button" in e2 && e2.button !== 2,
exact: (e2, modifiers) => systemModifiers.some((m) => e2[`${m}Key`] && !modifiers.includes(m))
};
const withModifiers = (fn2, modifiers) => {
return (event, ...args) => {
for (let i2 = 0; i2 < modifiers.length; i2++) {
const guard = modifierGuards[modifiers[i2]];
if (guard && guard(event, modifiers))
return;
}
return fn2(event, ...args);
};
};
const keyNames = {
esc: "escape",
space: " ",
up: "arrow-up",
left: "arrow-left",
right: "arrow-right",
down: "arrow-down",
delete: "backspace"
};
const withKeys = (fn2, modifiers) => {
return (event) => {
if (!("key" in event)) {
return;
}
const eventKey = hyphenate(event.key);
if (modifiers.some((k2) => k2 === eventKey || keyNames[k2] === eventKey)) {
return fn2(event);
}
};
};
const rendererOptions = /* @__PURE__ */ extend({ patchProp }, nodeOps);
let renderer;
function ensureRenderer() {
return renderer || (renderer = createRenderer(rendererOptions));
}
const createApp = (...args) => {
const app = ensureRenderer().createApp(...args);
{
injectNativeTagCheck(app);
injectCompilerOptionsCheck(app);
}
const { mount } = app;
app.mount = (containerOrSelector) => {
const container = normalizeContainer(containerOrSelector);
if (!container)
return;
const component = app._component;
if (!isFunction$1(component) && !component.render && !component.template) {
component.template = container.innerHTML;
}
container.innerHTML = "";
const proxy = mount(container, false, container instanceof SVGElement);
if (container instanceof Element) {
container.removeAttribute("v-cloak");
container.setAttribute("data-v-app", "");
}
return proxy;
};
return app;
};
function injectNativeTagCheck(app) {
Object.defineProperty(app.config, "isNativeTag", {
value: (tag) => isHTMLTag(tag) || isSVGTag(tag),
writable: false
});
}
function injectCompilerOptionsCheck(app) {
{
const isCustomElement = app.config.isCustomElement;
Object.defineProperty(app.config, "isCustomElement", {
get() {
return isCustomElement;
},
set() {
warn$2(
`The \`isCustomElement\` config option is deprecated. Use \`compilerOptions.isCustomElement\` instead.`
);
}
});
const compilerOptions = app.config.compilerOptions;
const msg = `The \`compilerOptions\` config option is only respected when using a build of Vue.js that includes the runtime compiler (aka "full build"). Since you are using the runtime-only build, \`compilerOptions\` must be passed to \`@vue/compiler-dom\` in the build setup instead.
- For vue-loader: pass it via vue-loader's \`compilerOptions\` loader option.
- For vue-cli: see https://cli.vuejs.org/guide/webpack.html#modifying-options-of-a-loader
- For vite: pass it via @vitejs/plugin-vue options. See https://github.com/vitejs/vite-plugin-vue/tree/main/packages/plugin-vue#example-for-passing-options-to-vuecompiler-sfc`;
Object.defineProperty(app.config, "compilerOptions", {
get() {
warn$2(msg);
return compilerOptions;
},
set() {
warn$2(msg);
}
});
}
}
function normalizeContainer(container) {
if (isString$1(container)) {
const res = document.querySelector(container);
if (!res) {
warn$2(
`Failed to mount app: mount target selector "${container}" returned null.`
);
}
return res;
}
if (window.ShadowRoot && container instanceof window.ShadowRoot && container.mode === "closed") {
warn$2(
`mounting on a ShadowRoot with \`{mode: "closed"}\` may lead to unpredictable bugs`
);
}
return container;
}
function initDev() {
{
initCustomFormatter();
}
}
{
initDev();
}
var isVue2 = false;
function set(target, key, val) {
if (Array.isArray(target)) {
target.length = Math.max(target.length, key);
target.splice(key, 1, val);
return val;
}
target[key] = val;
return val;
}
function del(target, key) {
if (Array.isArray(target)) {
target.splice(key, 1);
return;
}
delete target[key];
}
function getDevtoolsGlobalHook() {
return getTarget().__VUE_DEVTOOLS_GLOBAL_HOOK__;
}
function getTarget() {
return typeof navigator !== "undefined" && typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : {};
}
const isProxyAvailable = typeof Proxy === "function";
const HOOK_SETUP = "devtools-plugin:setup";
const HOOK_PLUGIN_SETTINGS_SET = "plugin:settings:set";
let supported;
let perf;
function isPerformanceSupported() {
var _a2;
if (supported !== void 0) {
return supported;
}
if (typeof window !== "undefined" && window.performance) {
supported = true;
perf = window.performance;
} else if (typeof global !== "undefined" && ((_a2 = global.perf_hooks) === null || _a2 === void 0 ? void 0 : _a2.performance)) {
supported = true;
perf = global.perf_hooks.performance;
} else {
supported = false;
}
return supported;
}
function now() {
return isPerformanceSupported() ? perf.now() : Date.now();
}
class ApiProxy {
constructor(plugin2, hook) {
this.target = null;
this.targetQueue = [];
this.onQueue = [];
this.plugin = plugin2;
this.hook = hook;
const defaultSettings = {};
if (plugin2.settings) {
for (const id2 in plugin2.settings) {
const item = plugin2.settings[id2];
defaultSettings[id2] = item.defaultValue;
}
}
const localSettingsSaveId = `__vue-devtools-plugin-settings__${plugin2.id}`;
let currentSettings = Object.assign({}, defaultSettings);
try {
const raw = localStorage.getItem(localSettingsSaveId);
const data = JSON.parse(raw);
Object.assign(currentSettings, data);
} catch (e2) {
}
this.fallbacks = {
getSettings() {
return currentSettings;
},
setSettings(value) {
try {
localStorage.setItem(localSettingsSaveId, JSON.stringify(value));
} catch (e2) {
}
currentSettings = value;
},
now() {
return now();
}
};
if (hook) {
hook.on(HOOK_PLUGIN_SETTINGS_SET, (pluginId, value) => {
if (pluginId === this.plugin.id) {
this.fallbacks.setSettings(value);
}
});
}
this.proxiedOn = new Proxy({}, {
get: (_target, prop) => {
if (this.target) {
return this.target.on[prop];
} else {
return (...args) => {
this.onQueue.push({
method: prop,
args
});
};
}
}
});
this.proxiedTarget = new Proxy({}, {
get: (_target, prop) => {
if (this.target) {
return this.target[prop];
} else if (prop === "on") {
return this.proxiedOn;
} else if (Object.keys(this.fallbacks).includes(prop)) {
return (...args) => {
this.targetQueue.push({
method: prop,
args,
resolve: () => {
}
});
return this.fallbacks[prop](...args);
};
} else {
return (...args) => {
return new Promise((resolve2) => {
this.targetQueue.push({
method: prop,
args,
resolve: resolve2
});
});
};
}
}
});
}
async setRealTarget(target) {
this.target = target;
for (const item of this.onQueue) {
this.target.on[item.method](...item.args);
}
for (const item of this.targetQueue) {
item.resolve(await this.target[item.method](...item.args));
}
}
}
function setupDevtoolsPlugin(pluginDescriptor, setupFn) {
const descriptor = pluginDescriptor;
const target = getTarget();
const hook = getDevtoolsGlobalHook();
const enableProxy = isProxyAvailable && descriptor.enableEarlyProxy;
if (hook && (target.__VUE_DEVTOOLS_PLUGIN_API_AVAILABLE__ || !enableProxy)) {
hook.emit(HOOK_SETUP, pluginDescriptor, setupFn);
} else {
const proxy = enableProxy ? new ApiProxy(descriptor, hook) : null;
const list = target.__VUE_DEVTOOLS_PLUGINS__ = target.__VUE_DEVTOOLS_PLUGINS__ || [];
list.push({
pluginDescriptor: descriptor,
setupFn,
proxy
});
if (proxy)
setupFn(proxy.proxiedTarget);
}
}
/*!
* pinia v2.1.7
* (c) 2023 Eduardo San Martin Morote
* @license MIT
*/
let activePinia;
const setActivePinia = (pinia) => activePinia = pinia;
const piniaSymbol = Symbol("pinia");
function isPlainObject(o) {
return o && typeof o === "object" && Object.prototype.toString.call(o) === "[object Object]" && typeof o.toJSON !== "function";
}
var MutationType;
(function(MutationType2) {
MutationType2["direct"] = "direct";
MutationType2["patchObject"] = "patch object";
MutationType2["patchFunction"] = "patch function";
})(MutationType || (MutationType = {}));
const IS_CLIENT = typeof window !== "undefined";
const USE_DEVTOOLS = IS_CLIENT;
const _global$1 = /* @__PURE__ */ (() => typeof window === "object" && window.window === window ? window : typeof self === "object" && self.self === self ? self : typeof global === "object" && global.global === global ? global : typeof globalThis === "object" ? globalThis : { HTMLElement: null })();
function bom(blob, { autoBom = false } = {}) {
if (autoBom && /^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(blob.type)) {
return new Blob([String.fromCharCode(65279), blob], { type: blob.type });
}
return blob;
}
function download(url, name, opts) {
const xhr = new XMLHttpRequest();
xhr.open("GET", url);
xhr.responseType = "blob";
xhr.onload = function() {
saveAs(xhr.response, name, opts);
};
xhr.onerror = function() {
console.error("could not download file");
};
xhr.send();
}
function corsEnabled(url) {
const xhr = new XMLHttpRequest();
xhr.open("HEAD", url, false);
try {
xhr.send();
} catch (e2) {
}
return xhr.status >= 200 && xhr.status <= 299;
}
function click(node) {
try {
node.dispatchEvent(new MouseEvent("click"));
} catch (e2) {
const evt = document.createEvent("MouseEvents");
evt.initMouseEvent("click", true, true, window, 0, 0, 0, 80, 20, false, false, false, false, 0, null);
node.dispatchEvent(evt);
}
}
const _navigator = typeof navigator === "object" ? navigator : { userAgent: "" };
const isMacOSWebView = /* @__PURE__ */ (() => /Macintosh/.test(_navigator.userAgent) && /AppleWebKit/.test(_navigator.userAgent) && !/Safari/.test(_navigator.userAgent))();
const saveAs = !IS_CLIENT ? () => {
} : (
// Use download attribute first if possible (#193 Lumia mobile) unless this is a macOS WebView or mini program
typeof HTMLAnchorElement !== "undefined" && "download" in HTMLAnchorElement.prototype && !isMacOSWebView ? downloadSaveAs : (
// Use msSaveOrOpenBlob as a second approach
"msSaveOrOpenBlob" in _navigator ? msSaveAs : (
// Fallback to using FileReader and a popup
fileSaverSaveAs
)
)
);
function downloadSaveAs(blob, name = "download", opts) {
const a2 = document.createElement("a");
a2.download = name;
a2.rel = "noopener";
if (typeof blob === "string") {
a2.href = blob;
if (a2.origin !== location.origin) {
if (corsEnabled(a2.href)) {
download(blob, name, opts);
} else {
a2.target = "_blank";
click(a2);
}
} else {
click(a2);
}
} else {
a2.href = URL.createObjectURL(blob);
setTimeout(function() {
URL.revokeObjectURL(a2.href);
}, 4e4);
setTimeout(function() {
click(a2);
}, 0);
}
}
function msSaveAs(blob, name = "download", opts) {
if (typeof blob === "string") {
if (corsEnabled(blob)) {
download(blob, name, opts);
} else {
const a2 = document.createElement("a");
a2.href = blob;
a2.target = "_blank";
setTimeout(function() {
click(a2);
});
}
} else {
navigator.msSaveOrOpenBlob(bom(blob, opts), name);
}
}
function fileSaverSaveAs(blob, name, opts, popup) {
popup = popup || open("", "_blank");
if (popup) {
popup.document.title = popup.document.body.innerText = "downloading...";
}
if (typeof blob === "string")
return download(blob, name, opts);
const force = blob.type === "application/octet-stream";
const isSafari = /constructor/i.test(String(_global$1.HTMLElement)) || "safari" in _global$1;
const isChromeIOS = /CriOS\/[\d]+/.test(navigator.userAgent);
if ((isChromeIOS || force && isSafari || isMacOSWebView) && typeof FileReader !== "undefined") {
const reader = new FileReader();
reader.onloadend = function() {
let url = reader.result;
if (typeof url !== "string") {
popup = null;
throw new Error("Wrong reader.result type");
}
url = isChromeIOS ? url : url.replace(/^data:[^;]*;/, "data:attachment/file;");
if (popup) {
popup.location.href = url;
} else {
location.assign(url);
}
popup = null;
};
reader.readAsDataURL(blob);
} else {
const url = URL.createObjectURL(blob);
if (popup)
popup.location.assign(url);
else
location.href = url;
popup = null;
setTimeout(function() {
URL.revokeObjectURL(url);
}, 4e4);
}
}
function toastMessage(message, type) {
const piniaMessage = "🍍 " + message;
if (typeof __VUE_DEVTOOLS_TOAST__ === "function") {
__VUE_DEVTOOLS_TOAST__(piniaMessage, type);
} else if (type === "error") {
console.error(piniaMessage);
} else if (type === "warn") {
console.warn(piniaMessage);
} else {
console.log(piniaMessage);
}
}
function isPinia(o) {
return "_a" in o && "install" in o;
}
function checkClipboardAccess() {
if (!("clipboard" in navigator)) {
toastMessage(`Your browser doesn't support the Clipboard API`, "error");
return true;
}
}
function checkNotFocusedError(error) {
if (error instanceof Error && error.message.toLowerCase().includes("document is not focused")) {
toastMessage('You need to activate the "Emulate a focused page" setting in the "Rendering" panel of devtools.', "warn");
return true;
}
return false;
}
async function actionGlobalCopyState(pinia) {
if (checkClipboardAccess())
return;
try {
await navigator.clipboard.writeText(JSON.stringify(pinia.state.value));
toastMessage("Global state copied to clipboard.");
} catch (error) {
if (checkNotFocusedError(error))
return;
toastMessage(`Failed to serialize the state. Check the console for more details.`, "error");
console.error(error);
}
}
async function actionGlobalPasteState(pinia) {
if (checkClipboardAccess())
return;
try {
loadStoresState(pinia, JSON.parse(await navigator.clipboard.readText()));
toastMessage("Global state pasted from clipboard.");
} catch (error) {
if (checkNotFocusedError(error))
return;
toastMessage(`Failed to deserialize the state from clipboard. Check the console for more details.`, "error");
console.error(error);
}
}
async function actionGlobalSaveState(pinia) {
try {
saveAs(new Blob([JSON.stringify(pinia.state.value)], {
type: "text/plain;charset=utf-8"
}), "pinia-state.json");
} catch (error) {
toastMessage(`Failed to export the state as JSON. Check the console for more details.`, "error");
console.error(error);
}
}
let fileInput;
function getFileOpener() {
if (!fileInput) {
fileInput = document.createElement("input");
fileInput.type = "file";
fileInput.accept = ".json";
}
function openFile() {
return new Promise((resolve2, reject) => {
fileInput.onchange = async () => {
const files = fileInput.files;
if (!files)
return resolve2(null);
const file = files.item(0);
if (!file)
return resolve2(null);
return resolve2({ text: await file.text(), file });
};
fileInput.oncancel = () => resolve2(null);
fileInput.onerror = reject;
fileInput.click();
});
}
return openFile;
}
async function actionGlobalOpenStateFile(pinia) {
try {
const open2 = getFileOpener();
const result = await open2();
if (!result)
return;
const { text: text2, file } = result;
loadStoresState(pinia, JSON.parse(text2));
toastMessage(`Global state imported from "${file.name}".`);
} catch (error) {
toastMessage(`Failed to import the state from JSON. Check the console for more details.`, "error");
console.error(error);
}
}
function loadStoresState(pinia, state) {
for (const key in state) {
const storeState = pinia.state.value[key];
if (storeState) {
Object.assign(storeState, state[key]);
} else {
pinia.state.value[key] = state[key];
}
}
}
function formatDisplay$1(display) {
return {
_custom: {
display
}
};
}
const PINIA_ROOT_LABEL = "🍍 Pinia (root)";
const PINIA_ROOT_ID = "_root";
function formatStoreForInspectorTree(store) {
return isPinia(store) ? {
id: PINIA_ROOT_ID,
label: PINIA_ROOT_LABEL
} : {
id: store.$id,
label: store.$id
};
}
function formatStoreForInspectorState(store) {
if (isPinia(store)) {
const storeNames = Array.from(store._s.keys());
const storeMap = store._s;
const state2 = {
state: storeNames.map((storeId) => ({
editable: true,
key: storeId,
value: store.state.value[storeId]
})),
getters: storeNames.filter((id2) => storeMap.get(id2)._getters).map((id2) => {
const store2 = storeMap.get(id2);
return {
editable: false,
key: id2,
value: store2._getters.reduce((getters, key) => {
getters[key] = store2[key];
return getters;
}, {})
};
})
};
return state2;
}
const state = {
state: Object.keys(store.$state).map((key) => ({
editable: true,
key,
value: store.$state[key]
}))
};
if (store._getters && store._getters.length) {
state.getters = store._getters.map((getterName) => ({
editable: false,
key: getterName,
value: store[getterName]
}));
}
if (store._customProperties.size) {
state.customProperties = Array.from(store._customProperties).map((key) => ({
editable: true,
key,
value: store[key]
}));
}
return state;
}
function formatEventData(events) {
if (!events)
return {};
if (Array.isArray(events)) {
return events.reduce((data, event) => {
data.keys.push(event.key);
data.operations.push(event.type);
data.oldValue[event.key] = event.oldValue;
data.newValue[event.key] = event.newValue;
return data;
}, {
oldValue: {},
keys: [],
operations: [],
newValue: {}
});
} else {
return {
operation: formatDisplay$1(events.type),
key: formatDisplay$1(events.key),
oldValue: events.oldValue,
newValue: events.newValue
};
}
}
function formatMutationType(type) {
switch (type) {
case MutationType.direct:
return "mutation";
case MutationType.patchFunction:
return "$patch";
case MutationType.patchObject:
return "$patch";
default:
return "unknown";
}
}
let isTimelineActive = true;
const componentStateTypes = [];
const MUTATIONS_LAYER_ID = "pinia:mutations";
const INSPECTOR_ID = "pinia";
const { assign: assign$1$1 } = Object;
const getStoreType = (id2) => "🍍 " + id2;
function registerPiniaDevtools(app, pinia) {
setupDevtoolsPlugin({
id: "dev.esm.pinia",
label: "Pinia 🍍",
logo: "https://pinia.vuejs.org/logo.svg",
packageName: "pinia",
homepage: "https://pinia.vuejs.org",
componentStateTypes,
app
}, (api) => {
if (typeof api.now !== "function") {
toastMessage("You seem to be using an outdated version of Vue Devtools. Are you still using the Beta release instead of the stable one? You can find the links at https://devtools.vuejs.org/guide/installation.html.");
}
api.addTimelineLayer({
id: MUTATIONS_LAYER_ID,
label: `Pinia 🍍`,
color: 15064968
});
api.addInspector({
id: INSPECTOR_ID,
label: "Pinia 🍍",
icon: "storage",
treeFilterPlaceholder: "Search stores",
actions: [
{
icon: "content_copy",
action: () => {
actionGlobalCopyState(pinia);
},
tooltip: "Serialize and copy the state"
},
{
icon: "content_paste",
action: async () => {
await actionGlobalPasteState(pinia);
api.sendInspectorTree(INSPECTOR_ID);
api.sendInspectorState(INSPECTOR_ID);
},
tooltip: "Replace the state with the content of your clipboard"
},
{
icon: "save",
action: () => {
actionGlobalSaveState(pinia);
},
tooltip: "Save the state as a JSON file"
},
{
icon: "folder_open",
action: async () => {
await actionGlobalOpenStateFile(pinia);
api.sendInspectorTree(INSPECTOR_ID);
api.sendInspectorState(INSPECTOR_ID);
},
tooltip: "Import the state from a JSON file"
}
],
nodeActions: [
{
icon: "restore",
tooltip: 'Reset the state (with "$reset")',
action: (nodeId) => {
const store = pinia._s.get(nodeId);
if (!store) {
toastMessage(`Cannot reset "${nodeId}" store because it wasn't found.`, "warn");
} else if (typeof store.$reset !== "function") {
toastMessage(`Cannot reset "${nodeId}" store because it doesn't have a "$reset" method implemented.`, "warn");
} else {
store.$reset();
toastMessage(`Store "${nodeId}" reset.`);
}
}
}
]
});
api.on.inspectComponent((payload, ctx) => {
const proxy = payload.componentInstance && payload.componentInstance.proxy;
if (proxy && proxy._pStores) {
const piniaStores = payload.componentInstance.proxy._pStores;
Object.values(piniaStores).forEach((store) => {
payload.instanceData.state.push({
type: getStoreType(store.$id),
key: "state",
editable: true,
value: store._isOptionsAPI ? {
_custom: {
value: toRaw(store.$state),
actions: [
{
icon: "restore",
tooltip: "Reset the state of this store",
action: () => store.$reset()
}
]
}
} : (
// NOTE: workaround to unwrap transferred refs
Object.keys(store.$state).reduce((state, key) => {
state[key] = store.$state[key];
return state;
}, {})
)
});
if (store._getters && store._getters.length) {
payload.instanceData.state.push({
type: getStoreType(store.$id),
key: "getters",
editable: false,
value: store._getters.reduce((getters, key) => {
try {
getters[key] = store[key];
} catch (error) {
getters[key] = error;
}
return getters;
}, {})
});
}
});
}
});
api.on.getInspectorTree((payload) => {
if (payload.app === app && payload.inspectorId === INSPECTOR_ID) {
let stores = [pinia];
stores = stores.concat(Array.from(pinia._s.values()));
payload.rootNodes = (payload.filter ? stores.filter((store) => "$id" in store ? store.$id.toLowerCase().includes(payload.filter.toLowerCase()) : PINIA_ROOT_LABEL.toLowerCase().includes(payload.filter.toLowerCase())) : stores).map(formatStoreForInspectorTree);
}
});
api.on.getInspectorState((payload) => {
if (payload.app === app && payload.inspectorId === INSPECTOR_ID) {
const inspectedStore = payload.nodeId === PINIA_ROOT_ID ? pinia : pinia._s.get(payload.nodeId);
if (!inspectedStore) {
return;
}
if (inspectedStore) {
payload.state = formatStoreForInspectorState(inspectedStore);
}
}
});
api.on.editInspectorState((payload, ctx) => {
if (payload.app === app && payload.inspectorId === INSPECTOR_ID) {
const inspectedStore = payload.nodeId === PINIA_ROOT_ID ? pinia : pinia._s.get(payload.nodeId);
if (!inspectedStore) {
return toastMessage(`store "${payload.nodeId}" not found`, "error");
}
const { path } = payload;
if (!isPinia(inspectedStore)) {
if (path.length !== 1 || !inspectedStore._customProperties.has(path[0]) || path[0] in inspectedStore.$state) {
path.unshift("$state");
}
} else {
path.unshift("state");
}
isTimelineActive = false;
payload.set(inspectedStore, path, payload.state.value);
isTimelineActive = true;
}
});
api.on.editComponentState((payload) => {
if (payload.type.startsWith("🍍")) {
const storeId = payload.type.replace(/^🍍\s*/, "");
const store = pinia._s.get(storeId);
if (!store) {
return toastMessage(`store "${storeId}" not found`, "error");
}
const { path } = payload;
if (path[0] !== "state") {
return toastMessage(`Invalid path for store "${storeId}":
${path}
Only state can be modified.`);
}
path[0] = "$state";
isTimelineActive = false;
payload.set(store, path, payload.state.value);
isTimelineActive = true;
}
});
});
}
function addStoreToDevtools(app, store) {
if (!componentStateTypes.includes(getStoreType(store.$id))) {
componentStateTypes.push(getStoreType(store.$id));
}
setupDevtoolsPlugin({
id: "dev.esm.pinia",
label: "Pinia 🍍",
logo: "https://pinia.vuejs.org/logo.svg",
packageName: "pinia",
homepage: "https://pinia.vuejs.org",
componentStateTypes,
app,
settings: {
logStoreChanges: {
label: "Notify about new/deleted stores",
type: "boolean",
defaultValue: true
}
// useEmojis: {
// label: 'Use emojis in messages ⚡️',
// type: 'boolean',
// defaultValue: true,
// },
}
}, (api) => {
const now2 = typeof api.now === "function" ? api.now.bind(api) : Date.now;
store.$onAction(({ after, onError, name, args }) => {
const groupId = runningActionId++;
api.addTimelineEvent({
layerId: MUTATIONS_LAYER_ID,
event: {
time: now2(),
title: "🛫 " + name,
subtitle: "start",
data: {
store: formatDisplay$1(store.$id),
action: formatDisplay$1(name),
args
},
groupId
}
});
after((result) => {
activeAction = void 0;
api.addTimelineEvent({
layerId: MUTATIONS_LAYER_ID,
event: {
time: now2(),
title: "🛬 " + name,
subtitle: "end",
data: {
store: formatDisplay$1(store.$id),
action: formatDisplay$1(name),
args,
result
},
groupId
}
});
});
onError((error) => {
activeAction = void 0;
api.addTimelineEvent({
layerId: MUTATIONS_LAYER_ID,
event: {
time: now2(),
logType: "error",
title: "💥 " + name,
subtitle: "end",
data: {
store: formatDisplay$1(store.$id),
action: formatDisplay$1(name),
args,
error
},
groupId
}
});
});
}, true);
store._customProperties.forEach((name) => {
watch(() => unref(store[name]), (newValue, oldValue) => {
api.notifyComponentUpdate();
api.sendInspectorState(INSPECTOR_ID);
if (isTimelineActive) {
api.addTimelineEvent({
layerId: MUTATIONS_LAYER_ID,
event: {
time: now2(),
title: "Change",
subtitle: name,
data: {
newValue,
oldValue
},
groupId: activeAction
}
});
}
}, { deep: true });
});
store.$subscribe(({ events, type }, state) => {
api.notifyComponentUpdate();
api.sendInspectorState(INSPECTOR_ID);
if (!isTimelineActive)
return;
const eventData = {
time: now2(),
title: formatMutationType(type),
data: assign$1$1({ store: formatDisplay$1(store.$id) }, formatEventData(events)),
groupId: activeAction
};
if (type === MutationType.patchFunction) {
eventData.subtitle = "⤵️";
} else if (type === MutationType.patchObject) {
eventData.subtitle = "🧩";
} else if (events && !Array.isArray(events)) {
eventData.subtitle = events.type;
}
if (events) {
eventData.data["rawEvent(s)"] = {
_custom: {
display: "DebuggerEvent",
type: "object",
tooltip: "raw DebuggerEvent[]",
value: events
}
};
}
api.addTimelineEvent({
layerId: MUTATIONS_LAYER_ID,
event: eventData
});
}, { detached: true, flush: "sync" });
const hotUpdate = store._hotUpdate;
store._hotUpdate = markRaw((newStore) => {
hotUpdate(newStore);
api.addTimelineEvent({
layerId: MUTATIONS_LAYER_ID,
event: {
time: now2(),
title: "🔥 " + store.$id,
subtitle: "HMR update",
data: {
store: formatDisplay$1(store.$id),
info: formatDisplay$1(`HMR update`)
}
}
});
api.notifyComponentUpdate();
api.sendInspectorTree(INSPECTOR_ID);
api.sendInspectorState(INSPECTOR_ID);
});
const { $dispose } = store;
store.$dispose = () => {
$dispose();
api.notifyComponentUpdate();
api.sendInspectorTree(INSPECTOR_ID);
api.sendInspectorState(INSPECTOR_ID);
api.getSettings().logStoreChanges && toastMessage(`Disposed "${store.$id}" store 🗑`);
};
api.notifyComponentUpdate();
api.sendInspectorTree(INSPECTOR_ID);
api.sendInspectorState(INSPECTOR_ID);
api.getSettings().logStoreChanges && toastMessage(`"${store.$id}" store installed 🆕`);
});
}
let runningActionId = 0;
let activeAction;
function patchActionForGrouping(store, actionNames, wrapWithProxy) {
const actions = actionNames.reduce((storeActions, actionName) => {
storeActions[actionName] = toRaw(store)[actionName];
return storeActions;
}, {});
for (const actionName in actions) {
store[actionName] = function() {
const _actionId = runningActionId;
const trackedStore = wrapWithProxy ? new Proxy(store, {
get(...args) {
activeAction = _actionId;
return Reflect.get(...args);
},
set(...args) {
activeAction = _actionId;
return Reflect.set(...args);
}
}) : store;
activeAction = _actionId;
const retValue = actions[actionName].apply(trackedStore, arguments);
activeAction = void 0;
return retValue;
};
}
}
function devtoolsPlugin({ app, store, options }) {
if (store.$id.startsWith("__hot:")) {
return;
}
store._isOptionsAPI = !!options.state;
patchActionForGrouping(store, Object.keys(options.actions), store._isOptionsAPI);
const originalHotUpdate = store._hotUpdate;
toRaw(store)._hotUpdate = function(newStore) {
originalHotUpdate.apply(this, arguments);
patchActionForGrouping(store, Object.keys(newStore._hmrPayload.actions), !!store._isOptionsAPI);
};
addStoreToDevtools(
app,
// FIXME: is there a way to allow the assignment from Store<Id, S, G, A> to StoreGeneric?
store
);
}
function createPinia() {
const scope = effectScope(true);
const state = scope.run(() => ref({}));
let _p2 = [];
let toBeInstalled = [];
const pinia = markRaw({
install(app) {
setActivePinia(pinia);
{
pinia._a = app;
app.provide(piniaSymbol, pinia);
app.config.globalProperties.$pinia = pinia;
if (USE_DEVTOOLS) {
registerPiniaDevtools(app, pinia);
}
toBeInstalled.forEach((plugin2) => _p2.push(plugin2));
toBeInstalled = [];
}
},
use(plugin2) {
if (!this._a && !isVue2) {
toBeInstalled.push(plugin2);
} else {
_p2.push(plugin2);
}
return this;
},
_p: _p2,
// it's actually undefined here
// @ts-expect-error
_a: null,
_e: scope,
_s: /* @__PURE__ */ new Map(),
state
});
if (USE_DEVTOOLS && typeof Proxy !== "undefined") {
pinia.use(devtoolsPlugin);
}
return pinia;
}
function patchObject(newState, oldState) {
for (const key in oldState) {
const subPatch = oldState[key];
if (!(key in newState)) {
continue;
}
const targetValue = newState[key];
if (isPlainObject(targetValue) && isPlainObject(subPatch) && !isRef(subPatch) && !isReactive(subPatch)) {
newState[key] = patchObject(targetValue, subPatch);
} else {
{
newState[key] = subPatch;
}
}
}
return newState;
}
const noop$3 = () => {
};
function addSubscription(subscriptions, callback, detached, onCleanup = noop$3) {
subscriptions.push(callback);
const removeSubscription = () => {
const idx = subscriptions.indexOf(callback);
if (idx > -1) {
subscriptions.splice(idx, 1);
onCleanup();
}
};
if (!detached && getCurrentScope()) {
onScopeDispose(removeSubscription);
}
return removeSubscription;
}
function triggerSubscriptions(subscriptions, ...args) {
subscriptions.slice().forEach((callback) => {
callback(...args);
});
}
const fallbackRunWithContext = (fn2) => fn2();
function mergeReactiveObjects(target, patchToApply) {
if (target instanceof Map && patchToApply instanceof Map) {
patchToApply.forEach((value, key) => target.set(key, value));
}
if (target instanceof Set && patchToApply instanceof Set) {
patchToApply.forEach(target.add, target);
}
for (const key in patchToApply) {
if (!patchToApply.hasOwnProperty(key))
continue;
const subPatch = patchToApply[key];
const targetValue = target[key];
if (isPlainObject(targetValue) && isPlainObject(subPatch) && target.hasOwnProperty(key) && !isRef(subPatch) && !isReactive(subPatch)) {
target[key] = mergeReactiveObjects(targetValue, subPatch);
} else {
target[key] = subPatch;
}
}
return target;
}
const skipHydrateSymbol = Symbol("pinia:skipHydration");
function shouldHydrate(obj) {
return !isPlainObject(obj) || !obj.hasOwnProperty(skipHydrateSymbol);
}
const { assign: assign$3 } = Object;
function isComputed(o) {
return !!(isRef(o) && o.effect);
}
function createOptionsStore(id2, options, pinia, hot) {
const { state, actions, getters } = options;
const initialState = pinia.state.value[id2];
let store;
function setup() {
if (!initialState && !hot) {
{
pinia.state.value[id2] = state ? state() : {};
}
}
const localState = hot ? (
// use ref() to unwrap refs inside state TODO: check if this is still necessary
toRefs(ref(state ? state() : {}).value)
) : toRefs(pinia.state.value[id2]);
return assign$3(localState, actions, Object.keys(getters || {}).reduce((computedGetters, name) => {
if (name in localState) {
console.warn(`[🍍]: A getter cannot have the same name as another state property. Rename one of them. Found with "${name}" in store "${id2}".`);
}
computedGetters[name] = markRaw(computed(() => {
setActivePinia(pinia);
const store2 = pinia._s.get(id2);
return getters[name].call(store2, store2);
}));
return computedGetters;
}, {}));
}
store = createSetupStore(id2, setup, options, pinia, hot, true);
return store;
}
function createSetupStore($id, setup, options = {}, pinia, hot, isOptionsStore) {
let scope;
const optionsForPlugin = assign$3({ actions: {} }, options);
if (!pinia._e.active) {
throw new Error("Pinia destroyed");
}
const $subscribeOptions = {
deep: true
// flush: 'post',
};
{
$subscribeOptions.onTrigger = (event) => {
if (isListening) {
debuggerEvents = event;
} else if (isListening == false && !store._hotUpdating) {
if (Array.isArray(debuggerEvents)) {
debuggerEvents.push(event);
} else {
console.error("🍍 debuggerEvents should be an array. This is most likely an internal Pinia bug.");
}
}
};
}
let isListening;
let isSyncListening;
let subscriptions = [];
let actionSubscriptions = [];
let debuggerEvents;
const initialState = pinia.state.value[$id];
if (!isOptionsStore && !initialState && !hot) {
{
pinia.state.value[$id] = {};
}
}
const hotState = ref({});
let activeListener;
function $patch(partialStateOrMutator) {
let subscriptionMutation;
isListening = isSyncListening = false;
{
debuggerEvents = [];
}
if (typeof partialStateOrMutator === "function") {
partialStateOrMutator(pinia.state.value[$id]);
subscriptionMutation = {
type: MutationType.patchFunction,
storeId: $id,
events: debuggerEvents
};
} else {
mergeReactiveObjects(pinia.state.value[$id], partialStateOrMutator);
subscriptionMutation = {
type: MutationType.patchObject,
payload: partialStateOrMutator,
storeId: $id,
events: debuggerEvents
};
}
const myListenerId = activeListener = Symbol();
nextTick().then(() => {
if (activeListener === myListenerId) {
isListening = true;
}
});
isSyncListening = true;
triggerSubscriptions(subscriptions, subscriptionMutation, pinia.state.value[$id]);
}
const $reset = isOptionsStore ? function $reset2() {
const { state } = options;
const newState = state ? state() : {};
this.$patch(($state) => {
assign$3($state, newState);
});
} : (
/* istanbul ignore next */
() => {
throw new Error(`🍍: Store "${$id}" is built using the setup syntax and does not implement $reset().`);
}
);
function $dispose() {
scope.stop();
subscriptions = [];
actionSubscriptions = [];
pinia._s.delete($id);
}
function wrapAction(name, action) {
return function() {
setActivePinia(pinia);
const args = Array.from(arguments);
const afterCallbackList = [];
const onErrorCallbackList = [];
function after(callback) {
afterCallbackList.push(callback);
}
function onError(callback) {
onErrorCallbackList.push(callback);
}
triggerSubscriptions(actionSubscriptions, {
args,
name,
store,
after,
onError
});
let ret;
try {
ret = action.apply(this && this.$id === $id ? this : store, args);
} catch (error) {
triggerSubscriptions(onErrorCallbackList, error);
throw error;
}
if (ret instanceof Promise) {
return ret.then((value) => {
triggerSubscriptions(afterCallbackList, value);
return value;
}).catch((error) => {
triggerSubscriptions(onErrorCallbackList, error);
return Promise.reject(error);
});
}
triggerSubscriptions(afterCallbackList, ret);
return ret;
};
}
const _hmrPayload = /* @__PURE__ */ markRaw({
actions: {},
getters: {},
state: [],
hotState
});
const partialStore = {
_p: pinia,
// _s: scope,
$id,
$onAction: addSubscription.bind(null, actionSubscriptions),
$patch,
$reset,
$subscribe(callback, options2 = {}) {
const removeSubscription = addSubscription(subscriptions, callback, options2.detached, () => stopWatcher());
const stopWatcher = scope.run(() => watch(() => pinia.state.value[$id], (state) => {
if (options2.flush === "sync" ? isSyncListening : isListening) {
callback({
storeId: $id,
type: MutationType.direct,
events: debuggerEvents
}, state);
}
}, assign$3({}, $subscribeOptions, options2)));
return removeSubscription;
},
$dispose
};
const store = reactive(assign$3(
{
_hmrPayload,
_customProperties: markRaw(/* @__PURE__ */ new Set())
// devtools custom properties
},
partialStore
// must be added later
// setupStore
));
pinia._s.set($id, store);
const runWithContext = pinia._a && pinia._a.runWithContext || fallbackRunWithContext;
const setupStore = runWithContext(() => pinia._e.run(() => (scope = effectScope()).run(setup)));
for (const key in setupStore) {
const prop = setupStore[key];
if (isRef(prop) && !isComputed(prop) || isReactive(prop)) {
if (hot) {
set(hotState.value, key, toRef(setupStore, key));
} else if (!isOptionsStore) {
if (initialState && shouldHydrate(prop)) {
if (isRef(prop)) {
prop.value = initialState[key];
} else {
mergeReactiveObjects(prop, initialState[key]);
}
}
{
pinia.state.value[$id][key] = prop;
}
}
{
_hmrPayload.state.push(key);
}
} else if (typeof prop === "function") {
const actionValue = hot ? prop : wrapAction(key, prop);
{
setupStore[key] = actionValue;
}
{
_hmrPayload.actions[key] = prop;
}
optionsForPlugin.actions[key] = prop;
} else {
if (isComputed(prop)) {
_hmrPayload.getters[key] = isOptionsStore ? (
// @ts-expect-error
options.getters[key]
) : prop;
if (IS_CLIENT) {
const getters = setupStore._getters || // @ts-expect-error: same
(setupStore._getters = markRaw([]));
getters.push(key);
}
}
}
}
{
assign$3(store, setupStore);
assign$3(toRaw(store), setupStore);
}
Object.defineProperty(store, "$state", {
get: () => hot ? hotState.value : pinia.state.value[$id],
set: (state) => {
if (hot) {
throw new Error("cannot set hotState");
}
$patch(($state) => {
assign$3($state, state);
});
}
});
{
store._hotUpdate = markRaw((newStore) => {
store._hotUpdating = true;
newStore._hmrPayload.state.forEach((stateKey) => {
if (stateKey in store.$state) {
const newStateTarget = newStore.$state[stateKey];
const oldStateSource = store.$state[stateKey];
if (typeof newStateTarget === "object" && isPlainObject(newStateTarget) && isPlainObject(oldStateSource)) {
patchObject(newStateTarget, oldStateSource);
} else {
newStore.$state[stateKey] = oldStateSource;
}
}
set(store, stateKey, toRef(newStore.$state, stateKey));
});
Object.keys(store.$state).forEach((stateKey) => {
if (!(stateKey in newStore.$state)) {
del(store, stateKey);
}
});
isListening = false;
isSyncListening = false;
pinia.state.value[$id] = toRef(newStore._hmrPayload, "hotState");
isSyncListening = true;
nextTick().then(() => {
isListening = true;
});
for (const actionName in newStore._hmrPayload.actions) {
const action = newStore[actionName];
set(store, actionName, wrapAction(actionName, action));
}
for (const getterName in newStore._hmrPayload.getters) {
const getter = newStore._hmrPayload.getters[getterName];
const getterValue = isOptionsStore ? (
// special handling of options api
computed(() => {
setActivePinia(pinia);
return getter.call(store, store);
})
) : getter;
set(store, getterName, getterValue);
}
Object.keys(store._hmrPayload.getters).forEach((key) => {
if (!(key in newStore._hmrPayload.getters)) {
del(store, key);
}
});
Object.keys(store._hmrPayload.actions).forEach((key) => {
if (!(key in newStore._hmrPayload.actions)) {
del(store, key);
}
});
store._hmrPayload = newStore._hmrPayload;
store._getters = newStore._getters;
store._hotUpdating = false;
});
}
if (USE_DEVTOOLS) {
const nonEnumerable = {
writable: true,
configurable: true,
// avoid warning on devtools trying to display this property
enumerable: false
};
["_p", "_hmrPayload", "_getters", "_customProperties"].forEach((p2) => {
Object.defineProperty(store, p2, assign$3({ value: store[p2] }, nonEnumerable));
});
}
pinia._p.forEach((extender) => {
if (USE_DEVTOOLS) {
const extensions = scope.run(() => extender({
store,
app: pinia._a,
pinia,
options: optionsForPlugin
}));
Object.keys(extensions || {}).forEach((key) => store._customProperties.add(key));
assign$3(store, extensions);
} else {
assign$3(store, scope.run(() => extender({
store,
app: pinia._a,
pinia,
options: optionsForPlugin
})));
}
});
if (store.$state && typeof store.$state === "object" && typeof store.$state.constructor === "function" && !store.$state.constructor.toString().includes("[native code]")) {
console.warn(`[🍍]: The "state" must be a plain object. It cannot be
state: () => new MyClass()
Found in store "${store.$id}".`);
}
if (initialState && isOptionsStore && options.hydrate) {
options.hydrate(store.$state, initialState);
}
isListening = true;
isSyncListening = true;
return store;
}
function defineStore(idOrOptions, setup, setupOptions) {
let id2;
let options;
const isSetupStore = typeof setup === "function";
if (typeof idOrOptions === "string") {
id2 = idOrOptions;
options = isSetupStore ? setupOptions : setup;
} else {
options = idOrOptions;
id2 = idOrOptions.id;
if (typeof id2 !== "string") {
throw new Error(`[🍍]: "defineStore()" must be passed a store id as its first argument.`);
}
}
function useStore(pinia, hot) {
const hasContext = hasInjectionContext();
pinia = // in test mode, ignore the argument provided as we can always retrieve a
// pinia instance with getActivePinia()
pinia || (hasContext ? inject(piniaSymbol, null) : null);
if (pinia)
setActivePinia(pinia);
if (!activePinia) {
throw new Error(`[🍍]: "getActivePinia()" was called but there was no active Pinia. Are you trying to use a store before calling "app.use(pinia)"?
See https://pinia.vuejs.org/core-concepts/outside-component-usage.html for help.
This will fail in production.`);
}
pinia = activePinia;
if (!pinia._s.has(id2)) {
if (isSetupStore) {
createSetupStore(id2, setup, options, pinia);
} else {
createOptionsStore(id2, options, pinia);
}
{
useStore._pinia = pinia;
}
}
const store = pinia._s.get(id2);
if (hot) {
const hotId = "__hot:" + id2;
const newStore = isSetupStore ? createSetupStore(hotId, setup, options, pinia, true) : createOptionsStore(hotId, assign$3({}, options), pinia, true);
hot._hotUpdate(newStore);
delete pinia.state.value[hotId];
pinia._s.delete(hotId);
}
if (IS_CLIENT) {
const currentInstance2 = getCurrentInstance();
if (currentInstance2 && currentInstance2.proxy && // avoid adding stores that are just built for hot module replacement
!hot) {
const vm2 = currentInstance2.proxy;
const cache2 = "_pStores" in vm2 ? vm2._pStores : vm2._pStores = {};
cache2[id2] = store;
}
}
return store;
}
useStore.$id = id2;
return useStore;
}
function getBasePlacement(placement) {
return placement.split("-")[0];
}
function getAlignment(placement) {
return placement.split("-")[1];
}
function getMainAxisFromPlacement(placement) {
return ["top", "bottom"].includes(getBasePlacement(placement)) ? "x" : "y";
}
function getLengthFromAxis(axis) {
return axis === "y" ? "height" : "width";
}
function computeCoordsFromPlacement(_ref) {
let {
reference,
floating,
placement
} = _ref;
const commonX = reference.x + reference.width / 2 - floating.width / 2;
const commonY = reference.y + reference.height / 2 - floating.height / 2;
let coords;
switch (getBasePlacement(placement)) {
case "top":
coords = {
x: commonX,
y: reference.y - floating.height
};
break;
case "bottom":
coords = {
x: commonX,
y: reference.y + reference.height
};
break;
case "right":
coords = {
x: reference.x + reference.width,
y: commonY
};
break;
case "left":
coords = {
x: reference.x - floating.width,
y: commonY
};
break;
default:
coords = {
x: reference.x,
y: reference.y
};
}
const mainAxis = getMainAxisFromPlacement(placement);
const length = getLengthFromAxis(mainAxis);
switch (getAlignment(placement)) {
case "start":
coords[mainAxis] = coords[mainAxis] - (reference[length] / 2 - floating[length] / 2);
break;
case "end":
coords[mainAxis] = coords[mainAxis] + (reference[length] / 2 - floating[length] / 2);
break;
}
return coords;
}
const computePosition$1 = async (reference, floating, config2) => {
const {
placement = "bottom",
strategy = "absolute",
middleware = [],
platform: platform2
} = config2;
{
if (platform2 == null) {
console.error(["Floating UI: `platform` property was not passed to config. If you", "want to use Floating UI on the web, install @floating-ui/dom", "instead of the /core package. Otherwise, you can create your own", "`platform`: https://floating-ui.com/docs/platform"].join(" "));
}
if (middleware.filter((_ref) => {
let {
name
} = _ref;
return name === "autoPlacement" || name === "flip";
}).length > 1) {
throw new Error(["Floating UI: duplicate `flip` and/or `autoPlacement`", "middleware detected. This will lead to an infinite loop. Ensure only", "one of either has been passed to the `middleware` array."].join(" "));
}
}
let rects = await platform2.getElementRects({
reference,
floating,
strategy
});
let {
x: x2,
y: y2
} = computeCoordsFromPlacement({
...rects,
placement
});
let statefulPlacement = placement;
let middlewareData = {};
let _debug_loop_count_ = 0;
for (let i2 = 0; i2 < middleware.length; i2++) {
{
_debug_loop_count_++;
if (_debug_loop_count_ > 100) {
throw new Error(["Floating UI: The middleware lifecycle appears to be", "running in an infinite loop. This is usually caused by a `reset`", "continually being returned without a break condition."].join(" "));
}
}
const {
name,
fn: fn2
} = middleware[i2];
const {
x: nextX,
y: nextY,
data,
reset
} = await fn2({
x: x2,
y: y2,
initialPlacement: placement,
placement: statefulPlacement,
strategy,
middlewareData,
rects,
platform: platform2,
elements: {
reference,
floating
}
});
x2 = nextX != null ? nextX : x2;
y2 = nextY != null ? nextY : y2;
middlewareData = {
...middlewareData,
[name]: data != null ? data : {}
};
if (reset) {
if (typeof reset === "object") {
if (reset.placement) {
statefulPlacement = reset.placement;
}
if (reset.rects) {
rects = reset.rects === true ? await platform2.getElementRects({
reference,
floating,
strategy
}) : reset.rects;
}
({
x: x2,
y: y2
} = computeCoordsFromPlacement({
...rects,
placement: statefulPlacement
}));
}
i2 = -1;
continue;
}
}
return {
x: x2,
y: y2,
placement: statefulPlacement,
strategy,
middlewareData
};
};
function expandPaddingObject(padding) {
return {
top: 0,
right: 0,
bottom: 0,
left: 0,
...padding
};
}
function getSideObjectFromPadding(padding) {
return typeof padding !== "number" ? expandPaddingObject(padding) : {
top: padding,
right: padding,
bottom: padding,
left: padding
};
}
function rectToClientRect(rect) {
return {
...rect,
top: rect.y,
left: rect.x,
right: rect.x + rect.width,
bottom: rect.y + rect.height
};
}
async function detectOverflow(middlewareArguments, options2) {
if (options2 === void 0) {
options2 = {};
}
const {
x: x2,
y: y2,
platform: platform2,
rects,
elements,
strategy
} = middlewareArguments;
const {
boundary = "clippingParents",
rootBoundary = "viewport",
elementContext = "floating",
altBoundary = false,
padding = 0
} = options2;
const paddingObject = getSideObjectFromPadding(padding);
const altContext = elementContext === "floating" ? "reference" : "floating";
const element2 = elements[altBoundary ? altContext : elementContext];
const clippingClientRect = await platform2.getClippingClientRect({
element: await platform2.isElement(element2) ? element2 : element2.contextElement || await platform2.getDocumentElement({
element: elements.floating
}),
boundary,
rootBoundary
});
const elementClientRect = rectToClientRect(await platform2.convertOffsetParentRelativeRectToViewportRelativeRect({
rect: elementContext === "floating" ? {
...rects.floating,
x: x2,
y: y2
} : rects.reference,
offsetParent: await platform2.getOffsetParent({
element: elements.floating
}),
strategy
}));
return {
top: clippingClientRect.top - elementClientRect.top + paddingObject.top,
bottom: elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom,
left: clippingClientRect.left - elementClientRect.left + paddingObject.left,
right: elementClientRect.right - clippingClientRect.right + paddingObject.right
};
}
const min$1 = Math.min;
const max$1 = Math.max;
function within(min$1$1, value, max$1$1) {
return max$1(min$1$1, min$1(value, max$1$1));
}
const arrow = (options2) => ({
name: "arrow",
options: options2,
async fn(middlewareArguments) {
const {
element: element2,
padding = 0
} = options2 != null ? options2 : {};
const {
x: x2,
y: y2,
placement,
rects,
platform: platform2
} = middlewareArguments;
if (element2 == null) {
{
console.warn("Floating UI: No `element` was passed to the `arrow` middleware.");
}
return {};
}
const paddingObject = getSideObjectFromPadding(padding);
const coords = {
x: x2,
y: y2
};
const basePlacement = getBasePlacement(placement);
const axis = getMainAxisFromPlacement(basePlacement);
const length = getLengthFromAxis(axis);
const arrowDimensions = await platform2.getDimensions({
element: element2
});
const minProp = axis === "y" ? "top" : "left";
const maxProp = axis === "y" ? "bottom" : "right";
const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
const startDiff = coords[axis] - rects.reference[axis];
const arrowOffsetParent = await platform2.getOffsetParent({
element: element2
});
const clientSize = arrowOffsetParent ? axis === "y" ? arrowOffsetParent.clientHeight || 0 : arrowOffsetParent.clientWidth || 0 : 0;
const centerToReference = endDiff / 2 - startDiff / 2;
const min2 = paddingObject[minProp];
const max2 = clientSize - arrowDimensions[length] - paddingObject[maxProp];
const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
const offset2 = within(min2, center, max2);
return {
data: {
[axis]: offset2,
centerOffset: center - offset2
}
};
}
});
const hash$1 = {
left: "right",
right: "left",
bottom: "top",
top: "bottom"
};
function getOppositePlacement(placement) {
return placement.replace(/left|right|bottom|top/g, (matched) => hash$1[matched]);
}
function getAlignmentSides(placement, rects) {
const isStart = getAlignment(placement) === "start";
const mainAxis = getMainAxisFromPlacement(placement);
const length = getLengthFromAxis(mainAxis);
let mainAlignmentSide = mainAxis === "x" ? isStart ? "right" : "left" : isStart ? "bottom" : "top";
if (rects.reference[length] > rects.floating[length]) {
mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
}
return {
main: mainAlignmentSide,
cross: getOppositePlacement(mainAlignmentSide)
};
}
const hash = {
start: "end",
end: "start"
};
function getOppositeAlignmentPlacement(placement) {
return placement.replace(/start|end/g, (matched) => hash[matched]);
}
const basePlacements = ["top", "right", "bottom", "left"];
const allPlacements = /* @__PURE__ */ basePlacements.reduce((acc, basePlacement) => acc.concat(basePlacement, basePlacement + "-start", basePlacement + "-end"), []);
function getPlacementList(alignment, autoAlignment, allowedPlacements) {
const allowedPlacementsSortedByAlignment = alignment ? [...allowedPlacements.filter((placement) => getAlignment(placement) === alignment), ...allowedPlacements.filter((placement) => getAlignment(placement) !== alignment)] : allowedPlacements.filter((placement) => getBasePlacement(placement) === placement);
return allowedPlacementsSortedByAlignment.filter((placement) => {
if (alignment) {
return getAlignment(placement) === alignment || (autoAlignment ? getOppositeAlignmentPlacement(placement) !== placement : false);
}
return true;
});
}
const autoPlacement = function(options2) {
if (options2 === void 0) {
options2 = {};
}
return {
name: "autoPlacement",
options: options2,
async fn(middlewareArguments) {
var _middlewareData$autoP, _middlewareData$autoP2, _middlewareData$autoP3, _middlewareData$autoP4, _middlewareData$autoP5, _placementsSortedByLe;
const {
x: x2,
y: y2,
rects,
middlewareData,
placement
} = middlewareArguments;
const {
alignment = null,
allowedPlacements = allPlacements,
autoAlignment = true,
...detectOverflowOptions
} = options2;
if ((_middlewareData$autoP = middlewareData.autoPlacement) != null && _middlewareData$autoP.skip) {
return {};
}
const placements2 = getPlacementList(alignment, autoAlignment, allowedPlacements);
const overflow = await detectOverflow(middlewareArguments, detectOverflowOptions);
const currentIndex = (_middlewareData$autoP2 = (_middlewareData$autoP3 = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP3.index) != null ? _middlewareData$autoP2 : 0;
const currentPlacement = placements2[currentIndex];
const {
main: main2,
cross
} = getAlignmentSides(currentPlacement, rects);
if (placement !== currentPlacement) {
return {
x: x2,
y: y2,
reset: {
placement: placements2[0]
}
};
}
const currentOverflows = [overflow[getBasePlacement(currentPlacement)], overflow[main2], overflow[cross]];
const allOverflows = [...(_middlewareData$autoP4 = (_middlewareData$autoP5 = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP5.overflows) != null ? _middlewareData$autoP4 : [], {
placement: currentPlacement,
overflows: currentOverflows
}];
const nextPlacement = placements2[currentIndex + 1];
if (nextPlacement) {
return {
data: {
index: currentIndex + 1,
overflows: allOverflows
},
reset: {
placement: nextPlacement
}
};
}
const placementsSortedByLeastOverflow = allOverflows.slice().sort((a2, b3) => a2.overflows[0] - b3.overflows[0]);
const placementThatFitsOnAllSides = (_placementsSortedByLe = placementsSortedByLeastOverflow.find((_ref) => {
let {
overflows
} = _ref;
return overflows.every((overflow2) => overflow2 <= 0);
})) == null ? void 0 : _placementsSortedByLe.placement;
return {
data: {
skip: true
},
reset: {
placement: placementThatFitsOnAllSides != null ? placementThatFitsOnAllSides : placementsSortedByLeastOverflow[0].placement
}
};
}
};
};
function getExpandedPlacements(placement) {
const oppositePlacement = getOppositePlacement(placement);
return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
}
const flip = function(options2) {
if (options2 === void 0) {
options2 = {};
}
return {
name: "flip",
options: options2,
async fn(middlewareArguments) {
var _middlewareData$flip, _middlewareData$flip2;
const {
placement,
middlewareData,
rects,
initialPlacement
} = middlewareArguments;
if ((_middlewareData$flip = middlewareData.flip) != null && _middlewareData$flip.skip) {
return {};
}
const {
mainAxis: checkMainAxis = true,
crossAxis: checkCrossAxis = true,
fallbackPlacements: specifiedFallbackPlacements,
fallbackStrategy = "bestFit",
flipAlignment = true,
...detectOverflowOptions
} = options2;
const basePlacement = getBasePlacement(placement);
const isBasePlacement = basePlacement === initialPlacement;
const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
const placements2 = [initialPlacement, ...fallbackPlacements];
const overflow = await detectOverflow(middlewareArguments, detectOverflowOptions);
const overflows = [];
let overflowsData = ((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.overflows) || [];
if (checkMainAxis) {
overflows.push(overflow[basePlacement]);
}
if (checkCrossAxis) {
const {
main: main2,
cross
} = getAlignmentSides(placement, rects);
overflows.push(overflow[main2], overflow[cross]);
}
overflowsData = [...overflowsData, {
placement,
overflows
}];
if (!overflows.every((side) => side <= 0)) {
var _middlewareData$flip$, _middlewareData$flip3;
const nextIndex = ((_middlewareData$flip$ = (_middlewareData$flip3 = middlewareData.flip) == null ? void 0 : _middlewareData$flip3.index) != null ? _middlewareData$flip$ : 0) + 1;
const nextPlacement = placements2[nextIndex];
if (nextPlacement) {
return {
data: {
index: nextIndex,
overflows: overflowsData
},
reset: {
placement: nextPlacement
}
};
}
let resetPlacement = "bottom";
switch (fallbackStrategy) {
case "bestFit": {
var _overflowsData$slice$;
const placement2 = (_overflowsData$slice$ = overflowsData.slice().sort((a2, b3) => a2.overflows.filter((overflow2) => overflow2 > 0).reduce((acc, overflow2) => acc + overflow2, 0) - b3.overflows.filter((overflow2) => overflow2 > 0).reduce((acc, overflow2) => acc + overflow2, 0))[0]) == null ? void 0 : _overflowsData$slice$.placement;
if (placement2) {
resetPlacement = placement2;
}
break;
}
case "initialPlacement":
resetPlacement = initialPlacement;
break;
}
return {
data: {
skip: true
},
reset: {
placement: resetPlacement
}
};
}
return {};
}
};
};
function convertValueToCoords(_ref) {
let {
placement,
rects,
value
} = _ref;
const basePlacement = getBasePlacement(placement);
const multiplier = ["left", "top"].includes(basePlacement) ? -1 : 1;
const rawValue = typeof value === "function" ? value({
...rects,
placement
}) : value;
const {
mainAxis,
crossAxis
} = typeof rawValue === "number" ? {
mainAxis: rawValue,
crossAxis: 0
} : {
mainAxis: 0,
crossAxis: 0,
...rawValue
};
return getMainAxisFromPlacement(basePlacement) === "x" ? {
x: crossAxis,
y: mainAxis * multiplier
} : {
x: mainAxis * multiplier,
y: crossAxis
};
}
const offset = function(value) {
if (value === void 0) {
value = 0;
}
return {
name: "offset",
options: value,
fn(middlewareArguments) {
const {
x: x2,
y: y2,
placement,
rects
} = middlewareArguments;
const diffCoords = convertValueToCoords({
placement,
rects,
value
});
return {
x: x2 + diffCoords.x,
y: y2 + diffCoords.y,
data: diffCoords
};
}
};
};
function getCrossAxis(axis) {
return axis === "x" ? "y" : "x";
}
const shift = function(options2) {
if (options2 === void 0) {
options2 = {};
}
return {
name: "shift",
options: options2,
async fn(middlewareArguments) {
const {
x: x2,
y: y2,
placement
} = middlewareArguments;
const {
mainAxis: checkMainAxis = true,
crossAxis: checkCrossAxis = false,
limiter = {
fn: (_ref) => {
let {
x: x22,
y: y22
} = _ref;
return {
x: x22,
y: y22
};
}
},
...detectOverflowOptions
} = options2;
const coords = {
x: x2,
y: y2
};
const overflow = await detectOverflow(middlewareArguments, detectOverflowOptions);
const mainAxis = getMainAxisFromPlacement(getBasePlacement(placement));
const crossAxis = getCrossAxis(mainAxis);
let mainAxisCoord = coords[mainAxis];
let crossAxisCoord = coords[crossAxis];
if (checkMainAxis) {
const minSide = mainAxis === "y" ? "top" : "left";
const maxSide = mainAxis === "y" ? "bottom" : "right";
const min2 = mainAxisCoord + overflow[minSide];
const max2 = mainAxisCoord - overflow[maxSide];
mainAxisCoord = within(min2, mainAxisCoord, max2);
}
if (checkCrossAxis) {
const minSide = crossAxis === "y" ? "top" : "left";
const maxSide = crossAxis === "y" ? "bottom" : "right";
const min2 = crossAxisCoord + overflow[minSide];
const max2 = crossAxisCoord - overflow[maxSide];
crossAxisCoord = within(min2, crossAxisCoord, max2);
}
const limitedCoords = limiter.fn({
...middlewareArguments,
[mainAxis]: mainAxisCoord,
[crossAxis]: crossAxisCoord
});
return {
...limitedCoords,
data: {
x: limitedCoords.x - x2,
y: limitedCoords.y - y2
}
};
}
};
};
const size = function(options2) {
if (options2 === void 0) {
options2 = {};
}
return {
name: "size",
options: options2,
async fn(middlewareArguments) {
var _middlewareData$size;
const {
placement,
rects,
middlewareData
} = middlewareArguments;
const {
apply,
...detectOverflowOptions
} = options2;
if ((_middlewareData$size = middlewareData.size) != null && _middlewareData$size.skip) {
return {};
}
const overflow = await detectOverflow(middlewareArguments, detectOverflowOptions);
const basePlacement = getBasePlacement(placement);
const isEnd = getAlignment(placement) === "end";
let heightSide;
let widthSide;
if (basePlacement === "top" || basePlacement === "bottom") {
heightSide = basePlacement;
widthSide = isEnd ? "left" : "right";
} else {
widthSide = basePlacement;
heightSide = isEnd ? "top" : "bottom";
}
const xMin = max$1(overflow.left, 0);
const xMax = max$1(overflow.right, 0);
const yMin = max$1(overflow.top, 0);
const yMax = max$1(overflow.bottom, 0);
const dimensions = {
height: rects.floating.height - (["left", "right"].includes(placement) ? 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max$1(overflow.top, overflow.bottom)) : overflow[heightSide]),
width: rects.floating.width - (["top", "bottom"].includes(placement) ? 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max$1(overflow.left, overflow.right)) : overflow[widthSide])
};
apply == null ? void 0 : apply({
...dimensions,
...rects
});
return {
data: {
skip: true
},
reset: {
rects: true
}
};
}
};
};
function isWindow(value) {
return (value == null ? void 0 : value.toString()) === "[object Window]";
}
function getWindow(node) {
if (node == null) {
return window;
}
if (!isWindow(node)) {
const ownerDocument = node.ownerDocument;
return ownerDocument ? ownerDocument.defaultView || window : window;
}
return node;
}
function getComputedStyle$1(element2) {
return getWindow(element2).getComputedStyle(element2);
}
function getNodeName(node) {
return isWindow(node) ? "" : node ? (node.nodeName || "").toLowerCase() : "";
}
function isHTMLElement(value) {
return value instanceof getWindow(value).HTMLElement;
}
function isElement(value) {
return value instanceof getWindow(value).Element;
}
function isNode(value) {
return value instanceof getWindow(value).Node;
}
function isShadowRoot(node) {
const OwnElement = getWindow(node).ShadowRoot;
return node instanceof OwnElement || node instanceof ShadowRoot;
}
function isScrollParent(element2) {
const {
overflow,
overflowX,
overflowY
} = getComputedStyle$1(element2);
return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX);
}
function isTableElement(element2) {
return ["table", "td", "th"].includes(getNodeName(element2));
}
function isContainingBlock(element2) {
const isFirefox = navigator.userAgent.toLowerCase().includes("firefox");
const css = getComputedStyle$1(element2);
return css.transform !== "none" || css.perspective !== "none" || css.contain === "paint" || ["transform", "perspective"].includes(css.willChange) || isFirefox && css.willChange === "filter" || isFirefox && (css.filter ? css.filter !== "none" : false);
}
const min = Math.min;
const max = Math.max;
const round = Math.round;
function getBoundingClientRect(element2, includeScale) {
if (includeScale === void 0) {
includeScale = false;
}
const clientRect = element2.getBoundingClientRect();
let scaleX = 1;
let scaleY = 1;
if (includeScale && isHTMLElement(element2)) {
scaleX = element2.offsetWidth > 0 ? round(clientRect.width) / element2.offsetWidth || 1 : 1;
scaleY = element2.offsetHeight > 0 ? round(clientRect.height) / element2.offsetHeight || 1 : 1;
}
return {
width: clientRect.width / scaleX,
height: clientRect.height / scaleY,
top: clientRect.top / scaleY,
right: clientRect.right / scaleX,
bottom: clientRect.bottom / scaleY,
left: clientRect.left / scaleX,
x: clientRect.left / scaleX,
y: clientRect.top / scaleY
};
}
function getDocumentElement(node) {
return ((isNode(node) ? node.ownerDocument : node.document) || window.document).documentElement;
}
function getNodeScroll(element2) {
if (isWindow(element2)) {
return {
scrollLeft: element2.pageXOffset,
scrollTop: element2.pageYOffset
};
}
return {
scrollLeft: element2.scrollLeft,
scrollTop: element2.scrollTop
};
}
function getWindowScrollBarX(element2) {
return getBoundingClientRect(getDocumentElement(element2)).left + getNodeScroll(element2).scrollLeft;
}
function isScaled(element2) {
const rect = getBoundingClientRect(element2);
return round(rect.width) !== element2.offsetWidth || round(rect.height) !== element2.offsetHeight;
}
function getRectRelativeToOffsetParent(element2, offsetParent, strategy) {
const isOffsetParentAnElement = isHTMLElement(offsetParent);
const documentElement = getDocumentElement(offsetParent);
const rect = getBoundingClientRect(element2, isOffsetParentAnElement && isScaled(offsetParent));
let scroll = {
scrollLeft: 0,
scrollTop: 0
};
const offsets = {
x: 0,
y: 0
};
if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== "fixed") {
if (getNodeName(offsetParent) !== "body" || isScrollParent(documentElement)) {
scroll = getNodeScroll(offsetParent);
}
if (isHTMLElement(offsetParent)) {
const offsetRect = getBoundingClientRect(offsetParent, true);
offsets.x = offsetRect.x + offsetParent.clientLeft;
offsets.y = offsetRect.y + offsetParent.clientTop;
} else if (documentElement) {
offsets.x = getWindowScrollBarX(documentElement);
}
}
return {
x: rect.left + scroll.scrollLeft - offsets.x,
y: rect.top + scroll.scrollTop - offsets.y,
width: rect.width,
height: rect.height
};
}
function getParentNode(node) {
if (getNodeName(node) === "html") {
return node;
}
return (
// this is a quicker (but less type safe) way to save quite some bytes from the bundle
// @ts-ignore
node.assignedSlot || // step into the shadow DOM of the parent of a slotted node
node.parentNode || // DOM Element detected
(isShadowRoot(node) ? node.host : null) || // ShadowRoot detected
getDocumentElement(node)
);
}
function getTrueOffsetParent(element2) {
if (!isHTMLElement(element2) || getComputedStyle(element2).position === "fixed") {
return null;
}
return element2.offsetParent;
}
function getContainingBlock(element2) {
let currentNode = getParentNode(element2);
while (isHTMLElement(currentNode) && !["html", "body"].includes(getNodeName(currentNode))) {
if (isContainingBlock(currentNode)) {
return currentNode;
} else {
currentNode = currentNode.parentNode;
}
}
return null;
}
function getOffsetParent(element2) {
const window2 = getWindow(element2);
let offsetParent = getTrueOffsetParent(element2);
while (offsetParent && isTableElement(offsetParent) && getComputedStyle(offsetParent).position === "static") {
offsetParent = getTrueOffsetParent(offsetParent);
}
if (offsetParent && (getNodeName(offsetParent) === "html" || getNodeName(offsetParent) === "body" && getComputedStyle(offsetParent).position === "static" && !isContainingBlock(offsetParent))) {
return window2;
}
return offsetParent || getContainingBlock(element2) || window2;
}
function getDimensions(element2) {
return {
width: element2.offsetWidth,
height: element2.offsetHeight
};
}
function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
let {
rect,
offsetParent,
strategy
} = _ref;
const isOffsetParentAnElement = isHTMLElement(offsetParent);
const documentElement = getDocumentElement(offsetParent);
if (offsetParent === documentElement) {
return rect;
}
let scroll = {
scrollLeft: 0,
scrollTop: 0
};
const offsets = {
x: 0,
y: 0
};
if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== "fixed") {
if (getNodeName(offsetParent) !== "body" || isScrollParent(documentElement)) {
scroll = getNodeScroll(offsetParent);
}
if (isHTMLElement(offsetParent)) {
const offsetRect = getBoundingClientRect(offsetParent, true);
offsets.x = offsetRect.x + offsetParent.clientLeft;
offsets.y = offsetRect.y + offsetParent.clientTop;
}
}
return {
...rect,
x: rect.x - scroll.scrollLeft + offsets.x,
y: rect.y - scroll.scrollTop + offsets.y
};
}
function getViewportRect(element2) {
const win = getWindow(element2);
const html = getDocumentElement(element2);
const visualViewport = win.visualViewport;
let width = html.clientWidth;
let height = html.clientHeight;
let x2 = 0;
let y2 = 0;
if (visualViewport) {
width = visualViewport.width;
height = visualViewport.height;
if (Math.abs(win.innerWidth / visualViewport.scale - visualViewport.width) < 0.01) {
x2 = visualViewport.offsetLeft;
y2 = visualViewport.offsetTop;
}
}
return {
width,
height,
x: x2,
y: y2
};
}
function getDocumentRect(element2) {
var _element$ownerDocumen;
const html = getDocumentElement(element2);
const scroll = getNodeScroll(element2);
const body = (_element$ownerDocumen = element2.ownerDocument) == null ? void 0 : _element$ownerDocumen.body;
const width = max(html.scrollWidth, html.clientWidth, body ? body.scrollWidth : 0, body ? body.clientWidth : 0);
const height = max(html.scrollHeight, html.clientHeight, body ? body.scrollHeight : 0, body ? body.clientHeight : 0);
let x2 = -scroll.scrollLeft + getWindowScrollBarX(element2);
const y2 = -scroll.scrollTop;
if (getComputedStyle$1(body || html).direction === "rtl") {
x2 += max(html.clientWidth, body ? body.clientWidth : 0) - width;
}
return {
width,
height,
x: x2,
y: y2
};
}
function getScrollParent(node) {
if (["html", "body", "#document"].includes(getNodeName(node))) {
return node.ownerDocument.body;
}
if (isHTMLElement(node) && isScrollParent(node)) {
return node;
}
return getScrollParent(getParentNode(node));
}
function getScrollParents(node, list) {
var _node$ownerDocument;
if (list === void 0) {
list = [];
}
const scrollParent = getScrollParent(node);
const isBody = scrollParent === ((_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.body);
const win = getWindow(scrollParent);
const target = isBody ? [win].concat(win.visualViewport || [], isScrollParent(scrollParent) ? scrollParent : []) : scrollParent;
const updatedList = list.concat(target);
return isBody ? updatedList : (
// @ts-ignore: isBody tells us target will be an HTMLElement here
updatedList.concat(getScrollParents(getParentNode(target)))
);
}
function contains(parent, child) {
const rootNode = child.getRootNode == null ? void 0 : child.getRootNode();
if (parent.contains(child)) {
return true;
} else if (rootNode && isShadowRoot(rootNode)) {
let next = child;
do {
if (next && parent === next) {
return true;
}
next = next.parentNode || next.host;
} while (next);
}
return false;
}
function getInnerBoundingClientRect(element2) {
const clientRect = getBoundingClientRect(element2);
const top = clientRect.top + element2.clientTop;
const left = clientRect.left + element2.clientLeft;
return {
top,
left,
x: left,
y: top,
right: left + element2.clientWidth,
bottom: top + element2.clientHeight,
width: element2.clientWidth,
height: element2.clientHeight
};
}
function getClientRectFromClippingParent(element2, clippingParent) {
if (clippingParent === "viewport") {
return rectToClientRect(getViewportRect(element2));
}
if (isElement(clippingParent)) {
return getInnerBoundingClientRect(clippingParent);
}
return rectToClientRect(getDocumentRect(getDocumentElement(element2)));
}
function getClippingParents(element2) {
const clippingParents = getScrollParents(getParentNode(element2));
const canEscapeClipping = ["absolute", "fixed"].includes(getComputedStyle$1(element2).position);
const clipperElement = canEscapeClipping && isHTMLElement(element2) ? getOffsetParent(element2) : element2;
if (!isElement(clipperElement)) {
return [];
}
return clippingParents.filter((clippingParent) => isElement(clippingParent) && contains(clippingParent, clipperElement) && getNodeName(clippingParent) !== "body");
}
function getClippingClientRect(_ref) {
let {
element: element2,
boundary,
rootBoundary
} = _ref;
const mainClippingParents = boundary === "clippingParents" ? getClippingParents(element2) : [].concat(boundary);
const clippingParents = [...mainClippingParents, rootBoundary];
const firstClippingParent = clippingParents[0];
const clippingRect = clippingParents.reduce((accRect, clippingParent) => {
const rect = getClientRectFromClippingParent(element2, clippingParent);
accRect.top = max(rect.top, accRect.top);
accRect.right = min(rect.right, accRect.right);
accRect.bottom = min(rect.bottom, accRect.bottom);
accRect.left = max(rect.left, accRect.left);
return accRect;
}, getClientRectFromClippingParent(element2, firstClippingParent));
clippingRect.width = clippingRect.right - clippingRect.left;
clippingRect.height = clippingRect.bottom - clippingRect.top;
clippingRect.x = clippingRect.left;
clippingRect.y = clippingRect.top;
return clippingRect;
}
const platform = {
getElementRects: (_ref) => {
let {
reference,
floating,
strategy
} = _ref;
return {
reference: getRectRelativeToOffsetParent(reference, getOffsetParent(floating), strategy),
floating: {
...getDimensions(floating),
x: 0,
y: 0
}
};
},
convertOffsetParentRelativeRectToViewportRelativeRect: (args) => convertOffsetParentRelativeRectToViewportRelativeRect(args),
getOffsetParent: (_ref2) => {
let {
element: element2
} = _ref2;
return getOffsetParent(element2);
},
isElement: (value) => isElement(value),
getDocumentElement: (_ref3) => {
let {
element: element2
} = _ref3;
return getDocumentElement(element2);
},
getClippingClientRect: (args) => getClippingClientRect(args),
getDimensions: (_ref4) => {
let {
element: element2
} = _ref4;
return getDimensions(element2);
},
getClientRects: (_ref5) => {
let {
element: element2
} = _ref5;
return element2.getClientRects();
}
};
const computePosition = (reference, floating, options2) => computePosition$1(reference, floating, {
platform,
...options2
});
var __defProp$1 = Object.defineProperty;
var __defProps = Object.defineProperties;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues$1 = (a2, b3) => {
for (var prop in b3 || (b3 = {}))
if (__hasOwnProp$1.call(b3, prop))
__defNormalProp$1(a2, prop, b3[prop]);
if (__getOwnPropSymbols$1)
for (var prop of __getOwnPropSymbols$1(b3)) {
if (__propIsEnum$1.call(b3, prop))
__defNormalProp$1(a2, prop, b3[prop]);
}
return a2;
};
var __spreadProps = (a2, b3) => __defProps(a2, __getOwnPropDescs(b3));
function assign$2(to2, from) {
for (const key in from) {
if (Object.prototype.hasOwnProperty.call(from, key)) {
if (typeof from[key] === "object" && to2[key]) {
assign$2(to2[key], from[key]);
} else {
to2[key] = from[key];
}
}
}
}
const config$1 = {
disabled: false,
distance: 5,
skidding: 0,
container: "body",
boundary: void 0,
instantMove: false,
disposeTimeout: 5e3,
popperTriggers: [],
strategy: "absolute",
preventOverflow: true,
flip: true,
shift: true,
overflowPadding: 0,
arrowPadding: 0,
arrowOverflow: true,
themes: {
tooltip: {
placement: "top",
triggers: ["hover", "focus", "touch"],
hideTriggers: (events) => [...events, "click"],
delay: {
show: 200,
hide: 0
},
handleResize: false,
html: false,
loadingContent: "..."
},
dropdown: {
placement: "bottom",
triggers: ["click"],
delay: 0,
handleResize: true,
autoHide: true
},
menu: {
$extend: "dropdown",
triggers: ["hover", "focus"],
popperTriggers: ["hover", "focus"],
delay: {
show: 0,
hide: 400
}
}
}
};
function getDefaultConfig(theme, key) {
let themeConfig = config$1.themes[theme] || {};
let value;
do {
value = themeConfig[key];
if (typeof value === "undefined") {
if (themeConfig.$extend) {
themeConfig = config$1.themes[themeConfig.$extend] || {};
} else {
themeConfig = null;
value = config$1[key];
}
} else {
themeConfig = null;
}
} while (themeConfig);
return value;
}
function getThemeClasses(theme) {
const result = [theme];
let themeConfig = config$1.themes[theme] || {};
do {
if (themeConfig.$extend && !themeConfig.$resetCss) {
result.push(themeConfig.$extend);
themeConfig = config$1.themes[themeConfig.$extend] || {};
} else {
themeConfig = null;
}
} while (themeConfig);
return result.map((c2) => `v-popper--theme-${c2}`);
}
function getAllParentThemes(theme) {
const result = [theme];
let themeConfig = config$1.themes[theme] || {};
do {
if (themeConfig.$extend) {
result.push(themeConfig.$extend);
themeConfig = config$1.themes[themeConfig.$extend] || {};
} else {
themeConfig = null;
}
} while (themeConfig);
return result;
}
let supportsPassive = false;
if (typeof window !== "undefined") {
supportsPassive = false;
try {
const opts = Object.defineProperty({}, "passive", {
get() {
supportsPassive = true;
}
});
window.addEventListener("test", null, opts);
} catch (e2) {
}
}
let isIOS$1 = false;
if (typeof window !== "undefined" && typeof navigator !== "undefined") {
isIOS$1 = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
}
const placements = ["auto", "top", "bottom", "left", "right"].reduce((acc, base) => acc.concat([
base,
`${base}-start`,
`${base}-end`
]), []);
const SHOW_EVENT_MAP = {
hover: "mouseenter",
focus: "focus",
click: "click",
touch: "touchstart"
};
const HIDE_EVENT_MAP = {
hover: "mouseleave",
focus: "blur",
click: "click",
touch: "touchend"
};
function removeFromArray(array, item) {
const index2 = array.indexOf(item);
if (index2 !== -1) {
array.splice(index2, 1);
}
}
function nextFrame() {
return new Promise((resolve2) => requestAnimationFrame(() => {
requestAnimationFrame(resolve2);
}));
}
const shownPoppers = [];
let hidingPopper = null;
const shownPoppersByTheme = {};
function getShownPoppersByTheme(theme) {
let list = shownPoppersByTheme[theme];
if (!list) {
list = shownPoppersByTheme[theme] = [];
}
return list;
}
let Element$1 = function() {
};
if (typeof window !== "undefined") {
Element$1 = window.Element;
}
function defaultPropFactory(prop) {
return function(props) {
return getDefaultConfig(props.theme, prop);
};
}
const PROVIDE_KEY = "__floating-vue__popper";
var PrivatePopper = () => /* @__PURE__ */ defineComponent({
name: "VPopper",
provide() {
return {
[PROVIDE_KEY]: {
parentPopper: this
}
};
},
inject: {
[PROVIDE_KEY]: { default: null }
},
props: {
theme: {
type: String,
required: true
},
targetNodes: {
type: Function,
required: true
},
referenceNode: {
type: Function,
default: null
},
popperNode: {
type: Function,
required: true
},
shown: {
type: Boolean,
default: false
},
showGroup: {
type: String,
default: null
},
ariaId: {
default: null
},
disabled: {
type: Boolean,
default: defaultPropFactory("disabled")
},
positioningDisabled: {
type: Boolean,
default: defaultPropFactory("positioningDisabled")
},
placement: {
type: String,
default: defaultPropFactory("placement"),
validator: (value) => placements.includes(value)
},
delay: {
type: [String, Number, Object],
default: defaultPropFactory("delay")
},
distance: {
type: [Number, String],
default: defaultPropFactory("distance")
},
skidding: {
type: [Number, String],
default: defaultPropFactory("skidding")
},
triggers: {
type: Array,
default: defaultPropFactory("triggers")
},
showTriggers: {
type: [Array, Function],
default: defaultPropFactory("showTriggers")
},
hideTriggers: {
type: [Array, Function],
default: defaultPropFactory("hideTriggers")
},
popperTriggers: {
type: Array,
default: defaultPropFactory("popperTriggers")
},
popperShowTriggers: {
type: [Array, Function],
default: defaultPropFactory("popperShowTriggers")
},
popperHideTriggers: {
type: [Array, Function],
default: defaultPropFactory("popperHideTriggers")
},
container: {
type: [String, Object, Element$1, Boolean],
default: defaultPropFactory("container")
},
boundary: {
type: [String, Element$1],
default: defaultPropFactory("boundary")
},
strategy: {
type: String,
validator: (value) => ["absolute", "fixed"].includes(value),
default: defaultPropFactory("strategy")
},
autoHide: {
type: [Boolean, Function],
default: defaultPropFactory("autoHide")
},
handleResize: {
type: Boolean,
default: defaultPropFactory("handleResize")
},
instantMove: {
type: Boolean,
default: defaultPropFactory("instantMove")
},
eagerMount: {
type: Boolean,
default: defaultPropFactory("eagerMount")
},
popperClass: {
type: [String, Array, Object],
default: defaultPropFactory("popperClass")
},
computeTransformOrigin: {
type: Boolean,
default: defaultPropFactory("computeTransformOrigin")
},
autoMinSize: {
type: Boolean,
default: defaultPropFactory("autoMinSize")
},
autoSize: {
type: [Boolean, String],
default: defaultPropFactory("autoSize")
},
autoMaxSize: {
type: Boolean,
default: defaultPropFactory("autoMaxSize")
},
autoBoundaryMaxSize: {
type: Boolean,
default: defaultPropFactory("autoBoundaryMaxSize")
},
preventOverflow: {
type: Boolean,
default: defaultPropFactory("preventOverflow")
},
overflowPadding: {
type: [Number, String],
default: defaultPropFactory("overflowPadding")
},
arrowPadding: {
type: [Number, String],
default: defaultPropFactory("arrowPadding")
},
arrowOverflow: {
type: Boolean,
default: defaultPropFactory("arrowOverflow")
},
flip: {
type: Boolean,
default: defaultPropFactory("flip")
},
shift: {
type: Boolean,
default: defaultPropFactory("shift")
},
shiftCrossAxis: {
type: Boolean,
default: defaultPropFactory("shiftCrossAxis")
}
},
emits: [
"show",
"hide",
"update:shown",
"apply-show",
"apply-hide",
"close-group",
"close-directive",
"auto-hide",
"resize",
"dispose"
],
data() {
return {
isShown: false,
isMounted: false,
skipTransition: false,
classes: {
showFrom: false,
showTo: false,
hideFrom: false,
hideTo: true
},
result: {
x: 0,
y: 0,
placement: "",
strategy: this.strategy,
arrow: {
x: 0,
y: 0,
centerOffset: 0
},
transformOrigin: null
},
shownChildren: /* @__PURE__ */ new Set(),
lastAutoHide: true
};
},
computed: {
popperId() {
return this.ariaId != null ? this.ariaId : this.randomId;
},
shouldMountContent() {
return this.eagerMount || this.isMounted;
},
slotData() {
return {
popperId: this.popperId,
isShown: this.isShown,
shouldMountContent: this.shouldMountContent,
skipTransition: this.skipTransition,
autoHide: typeof this.autoHide === "function" ? this.lastAutoHide : this.autoHide,
show: this.show,
hide: this.hide,
handleResize: this.handleResize,
onResize: this.onResize,
classes: __spreadProps(__spreadValues$1({}, this.classes), {
popperClass: this.popperClass
}),
result: this.positioningDisabled ? null : this.result,
attrs: this.$attrs
};
},
parentPopper() {
var _a2;
return (_a2 = this[PROVIDE_KEY]) == null ? void 0 : _a2.parentPopper;
},
hasPopperShowTriggerHover() {
var _a2, _b;
return ((_a2 = this.popperTriggers) == null ? void 0 : _a2.includes("hover")) || ((_b = this.popperShowTriggers) == null ? void 0 : _b.includes("hover"));
}
},
watch: __spreadValues$1(__spreadValues$1({
shown: "$_autoShowHide",
disabled(value) {
if (value) {
this.dispose();
} else {
this.init();
}
},
async container() {
if (this.isShown) {
this.$_ensureTeleport();
await this.$_computePosition();
}
}
}, [
"triggers",
"positioningDisabled"
].reduce((acc, prop) => {
acc[prop] = "$_refreshListeners";
return acc;
}, {})), [
"placement",
"distance",
"skidding",
"boundary",
"strategy",
"overflowPadding",
"arrowPadding",
"preventOverflow",
"shift",
"shiftCrossAxis",
"flip"
].reduce((acc, prop) => {
acc[prop] = "$_computePosition";
return acc;
}, {})),
created() {
this.$_isDisposed = true;
this.randomId = `popper_${[Math.random(), Date.now()].map((n2) => n2.toString(36).substring(2, 10)).join("_")}`;
if (this.autoMinSize) {
console.warn('[floating-vue] `autoMinSize` option is deprecated. Use `autoSize="min"` instead.');
}
if (this.autoMaxSize) {
console.warn("[floating-vue] `autoMaxSize` option is deprecated. Use `autoBoundaryMaxSize` instead.");
}
},
mounted() {
this.init();
this.$_detachPopperNode();
},
activated() {
this.$_autoShowHide();
},
deactivated() {
this.hide();
},
beforeUnmount() {
this.dispose();
},
methods: {
show({ event = null, skipDelay = false, force = false } = {}) {
var _a2, _b;
if (((_a2 = this.parentPopper) == null ? void 0 : _a2.lockedChild) && this.parentPopper.lockedChild !== this)
return;
this.$_pendingHide = false;
if (force || !this.disabled) {
if (((_b = this.parentPopper) == null ? void 0 : _b.lockedChild) === this) {
this.parentPopper.lockedChild = null;
}
this.$_scheduleShow(event, skipDelay);
this.$emit("show");
this.$_showFrameLocked = true;
requestAnimationFrame(() => {
this.$_showFrameLocked = false;
});
}
this.$emit("update:shown", true);
},
hide({ event = null, skipDelay = false } = {}) {
var _a2;
if (this.$_hideInProgress)
return;
if (this.shownChildren.size > 0) {
this.$_pendingHide = true;
return;
}
if (this.hasPopperShowTriggerHover && this.$_isAimingPopper()) {
if (this.parentPopper) {
this.parentPopper.lockedChild = this;
clearTimeout(this.parentPopper.lockedChildTimer);
this.parentPopper.lockedChildTimer = setTimeout(() => {
if (this.parentPopper.lockedChild === this) {
this.parentPopper.lockedChild.hide({ skipDelay });
this.parentPopper.lockedChild = null;
}
}, 1e3);
}
return;
}
if (((_a2 = this.parentPopper) == null ? void 0 : _a2.lockedChild) === this) {
this.parentPopper.lockedChild = null;
}
this.$_pendingHide = false;
this.$_scheduleHide(event, skipDelay);
this.$emit("hide");
this.$emit("update:shown", false);
},
init() {
var _a2, _b;
if (!this.$_isDisposed)
return;
this.$_isDisposed = false;
this.isMounted = false;
this.$_events = [];
this.$_preventShow = false;
this.$_referenceNode = (_b = (_a2 = this.referenceNode) == null ? void 0 : _a2.call(this)) != null ? _b : this.$el;
this.$_targetNodes = this.targetNodes().filter((e2) => e2.nodeType === e2.ELEMENT_NODE);
this.$_popperNode = this.popperNode();
this.$_innerNode = this.$_popperNode.querySelector(".v-popper__inner");
this.$_arrowNode = this.$_popperNode.querySelector(".v-popper__arrow-container");
this.$_swapTargetAttrs("title", "data-original-title");
this.$_detachPopperNode();
if (this.triggers.length) {
this.$_addEventListeners();
}
if (this.shown) {
this.show();
}
},
dispose() {
if (this.$_isDisposed)
return;
this.$_isDisposed = true;
this.$_removeEventListeners();
this.hide({ skipDelay: true });
this.$_detachPopperNode();
this.isMounted = false;
this.isShown = false;
this.$_updateParentShownChildren(false);
this.$_swapTargetAttrs("data-original-title", "title");
this.$emit("dispose");
},
async onResize() {
if (this.isShown) {
await this.$_computePosition();
this.$emit("resize");
}
},
async $_computePosition() {
var _a2;
if (this.$_isDisposed || this.positioningDisabled)
return;
const options2 = {
strategy: this.strategy,
middleware: []
};
if (this.distance || this.skidding) {
options2.middleware.push(offset({
mainAxis: this.distance,
crossAxis: this.skidding
}));
}
const isPlacementAuto = this.placement.startsWith("auto");
if (isPlacementAuto) {
options2.middleware.push(autoPlacement({
alignment: (_a2 = this.placement.split("-")[1]) != null ? _a2 : ""
}));
} else {
options2.placement = this.placement;
}
if (this.preventOverflow) {
if (this.shift) {
options2.middleware.push(shift({
padding: this.overflowPadding,
boundary: this.boundary,
crossAxis: this.shiftCrossAxis
}));
}
if (!isPlacementAuto && this.flip) {
options2.middleware.push(flip({
padding: this.overflowPadding,
boundary: this.boundary
}));
}
}
options2.middleware.push(arrow({
element: this.$_arrowNode,
padding: this.arrowPadding
}));
if (this.arrowOverflow) {
options2.middleware.push({
name: "arrowOverflow",
fn: ({ placement, rects, middlewareData }) => {
let overflow;
const { centerOffset } = middlewareData.arrow;
if (placement.startsWith("top") || placement.startsWith("bottom")) {
overflow = Math.abs(centerOffset) > rects.reference.width / 2;
} else {
overflow = Math.abs(centerOffset) > rects.reference.height / 2;
}
return {
data: {
overflow
}
};
}
});
}
if (this.autoMinSize || this.autoSize) {
const autoSize = this.autoSize ? this.autoSize : this.autoMinSize ? "min" : null;
options2.middleware.push({
name: "autoSize",
fn: ({ rects, placement, middlewareData }) => {
var _a22;
if ((_a22 = middlewareData.autoSize) == null ? void 0 : _a22.skip) {
return {};
}
let width;
let height;
if (placement.startsWith("top") || placement.startsWith("bottom")) {
width = rects.reference.width;
} else {
height = rects.reference.height;
}
this.$_innerNode.style[autoSize === "min" ? "minWidth" : autoSize === "max" ? "maxWidth" : "width"] = width != null ? `${width}px` : null;
this.$_innerNode.style[autoSize === "min" ? "minHeight" : autoSize === "max" ? "maxHeight" : "height"] = height != null ? `${height}px` : null;
return {
data: {
skip: true
},
reset: {
rects: true
}
};
}
});
}
if (this.autoMaxSize || this.autoBoundaryMaxSize) {
this.$_innerNode.style.maxWidth = null;
this.$_innerNode.style.maxHeight = null;
options2.middleware.push(size({
boundary: this.boundary,
padding: this.overflowPadding,
apply: ({ width, height }) => {
this.$_innerNode.style.maxWidth = width != null ? `${width}px` : null;
this.$_innerNode.style.maxHeight = height != null ? `${height}px` : null;
}
}));
}
const data = await computePosition(this.$_referenceNode, this.$_popperNode, options2);
Object.assign(this.result, {
x: data.x,
y: data.y,
placement: data.placement,
strategy: data.strategy,
arrow: __spreadValues$1(__spreadValues$1({}, data.middlewareData.arrow), data.middlewareData.arrowOverflow)
});
},
$_scheduleShow(event = null, skipDelay = false) {
this.$_updateParentShownChildren(true);
this.$_hideInProgress = false;
clearTimeout(this.$_scheduleTimer);
if (hidingPopper && this.instantMove && hidingPopper.instantMove && hidingPopper !== this.parentPopper) {
hidingPopper.$_applyHide(true);
this.$_applyShow(true);
return;
}
if (skipDelay) {
this.$_applyShow();
} else {
this.$_scheduleTimer = setTimeout(this.$_applyShow.bind(this), this.$_computeDelay("show"));
}
},
$_scheduleHide(event = null, skipDelay = false) {
if (this.shownChildren.size > 0) {
this.$_pendingHide = true;
return;
}
this.$_updateParentShownChildren(false);
this.$_hideInProgress = true;
clearTimeout(this.$_scheduleTimer);
if (this.isShown) {
hidingPopper = this;
}
if (skipDelay) {
this.$_applyHide();
} else {
this.$_scheduleTimer = setTimeout(this.$_applyHide.bind(this), this.$_computeDelay("hide"));
}
},
$_computeDelay(type) {
const delay = this.delay;
return parseInt(delay && delay[type] || delay || 0);
},
async $_applyShow(skipTransition = false) {
clearTimeout(this.$_disposeTimer);
clearTimeout(this.$_scheduleTimer);
this.skipTransition = skipTransition;
if (this.isShown) {
return;
}
this.$_ensureTeleport();
await nextFrame();
await this.$_computePosition();
await this.$_applyShowEffect();
if (!this.positioningDisabled) {
this.$_registerEventListeners([
...getScrollParents(this.$_referenceNode),
...getScrollParents(this.$_popperNode)
], "scroll", () => {
this.$_computePosition();
});
}
},
async $_applyShowEffect() {
if (this.$_hideInProgress)
return;
if (this.computeTransformOrigin) {
const bounds = this.$_referenceNode.getBoundingClientRect();
const popperWrapper = this.$_popperNode.querySelector(".v-popper__wrapper");
const parentBounds = popperWrapper.parentNode.getBoundingClientRect();
const x2 = bounds.x + bounds.width / 2 - (parentBounds.left + popperWrapper.offsetLeft);
const y2 = bounds.y + bounds.height / 2 - (parentBounds.top + popperWrapper.offsetTop);
this.result.transformOrigin = `${x2}px ${y2}px`;
}
this.isShown = true;
this.$_applyAttrsToTarget({
"aria-describedby": this.popperId,
"data-popper-shown": ""
});
const showGroup = this.showGroup;
if (showGroup) {
let popover;
for (let i2 = 0; i2 < shownPoppers.length; i2++) {
popover = shownPoppers[i2];
if (popover.showGroup !== showGroup) {
popover.hide();
popover.$emit("close-group");
}
}
}
shownPoppers.push(this);
document.body.classList.add("v-popper--some-open");
for (const theme of getAllParentThemes(this.theme)) {
getShownPoppersByTheme(theme).push(this);
document.body.classList.add(`v-popper--some-open--${theme}`);
}
this.$emit("apply-show");
this.classes.showFrom = true;
this.classes.showTo = false;
this.classes.hideFrom = false;
this.classes.hideTo = false;
await nextFrame();
this.classes.showFrom = false;
this.classes.showTo = true;
this.$_popperNode.focus();
},
async $_applyHide(skipTransition = false) {
if (this.shownChildren.size > 0) {
this.$_pendingHide = true;
this.$_hideInProgress = false;
return;
}
clearTimeout(this.$_scheduleTimer);
if (!this.isShown) {
return;
}
this.skipTransition = skipTransition;
removeFromArray(shownPoppers, this);
if (shownPoppers.length === 0) {
document.body.classList.remove("v-popper--some-open");
}
for (const theme of getAllParentThemes(this.theme)) {
const list = getShownPoppersByTheme(theme);
removeFromArray(list, this);
if (list.length === 0) {
document.body.classList.remove(`v-popper--some-open--${theme}`);
}
}
if (hidingPopper === this) {
hidingPopper = null;
}
this.isShown = false;
this.$_applyAttrsToTarget({
"aria-describedby": void 0,
"data-popper-shown": void 0
});
clearTimeout(this.$_disposeTimer);
const disposeTime = getDefaultConfig(this.theme, "disposeTimeout");
if (disposeTime !== null) {
this.$_disposeTimer = setTimeout(() => {
if (this.$_popperNode) {
this.$_detachPopperNode();
this.isMounted = false;
}
}, disposeTime);
}
this.$_removeEventListeners("scroll");
this.$emit("apply-hide");
this.classes.showFrom = false;
this.classes.showTo = false;
this.classes.hideFrom = true;
this.classes.hideTo = false;
await nextFrame();
this.classes.hideFrom = false;
this.classes.hideTo = true;
},
$_autoShowHide() {
if (this.shown) {
this.show();
} else {
this.hide();
}
},
$_ensureTeleport() {
if (this.$_isDisposed)
return;
let container = this.container;
if (typeof container === "string") {
container = window.document.querySelector(container);
} else if (container === false) {
container = this.$_targetNodes[0].parentNode;
}
if (!container) {
throw new Error("No container for popover: " + this.container);
}
container.appendChild(this.$_popperNode);
this.isMounted = true;
},
$_addEventListeners() {
const handleShow = (event) => {
if (this.isShown && !this.$_hideInProgress) {
return;
}
event.usedByTooltip = true;
!this.$_preventShow && this.show({ event });
};
this.$_registerTriggerListeners(this.$_targetNodes, SHOW_EVENT_MAP, this.triggers, this.showTriggers, handleShow);
this.$_registerTriggerListeners([this.$_popperNode], SHOW_EVENT_MAP, this.popperTriggers, this.popperShowTriggers, handleShow);
const handleHide = (event) => {
if (event.usedByTooltip) {
return;
}
this.hide({ event });
};
this.$_registerTriggerListeners(this.$_targetNodes, HIDE_EVENT_MAP, this.triggers, this.hideTriggers, handleHide);
this.$_registerTriggerListeners([this.$_popperNode], HIDE_EVENT_MAP, this.popperTriggers, this.popperHideTriggers, handleHide);
},
$_registerEventListeners(targetNodes, eventType, handler) {
this.$_events.push({ targetNodes, eventType, handler });
targetNodes.forEach((node) => node.addEventListener(eventType, handler, supportsPassive ? {
passive: true
} : void 0));
},
$_registerTriggerListeners(targetNodes, eventMap, commonTriggers, customTrigger, handler) {
let triggers = commonTriggers;
if (customTrigger != null) {
triggers = typeof customTrigger === "function" ? customTrigger(triggers) : customTrigger;
}
triggers.forEach((trigger2) => {
const eventType = eventMap[trigger2];
if (eventType) {
this.$_registerEventListeners(targetNodes, eventType, handler);
}
});
},
$_removeEventListeners(filterEventType) {
const newList = [];
this.$_events.forEach((listener) => {
const { targetNodes, eventType, handler } = listener;
if (!filterEventType || filterEventType === eventType) {
targetNodes.forEach((node) => node.removeEventListener(eventType, handler));
} else {
newList.push(listener);
}
});
this.$_events = newList;
},
$_refreshListeners() {
if (!this.$_isDisposed) {
this.$_removeEventListeners();
this.$_addEventListeners();
}
},
$_handleGlobalClose(event, touch = false) {
if (this.$_showFrameLocked)
return;
this.hide({ event });
if (event.closePopover) {
this.$emit("close-directive");
} else {
this.$emit("auto-hide");
}
if (touch) {
this.$_preventShow = true;
setTimeout(() => {
this.$_preventShow = false;
}, 300);
}
},
$_detachPopperNode() {
this.$_popperNode.parentNode && this.$_popperNode.parentNode.removeChild(this.$_popperNode);
},
$_swapTargetAttrs(attrFrom, attrTo) {
for (const el2 of this.$_targetNodes) {
const value = el2.getAttribute(attrFrom);
if (value) {
el2.removeAttribute(attrFrom);
el2.setAttribute(attrTo, value);
}
}
},
$_applyAttrsToTarget(attrs) {
for (const el2 of this.$_targetNodes) {
for (const n2 in attrs) {
const value = attrs[n2];
if (value == null) {
el2.removeAttribute(n2);
} else {
el2.setAttribute(n2, value);
}
}
}
},
$_updateParentShownChildren(value) {
let parent = this.parentPopper;
while (parent) {
if (value) {
parent.shownChildren.add(this.randomId);
} else {
parent.shownChildren.delete(this.randomId);
if (parent.$_pendingHide) {
parent.hide();
}
}
parent = parent.parentPopper;
}
},
$_isAimingPopper() {
const referenceBounds = this.$_referenceNode.getBoundingClientRect();
if (mouseX >= referenceBounds.left && mouseX <= referenceBounds.right && mouseY >= referenceBounds.top && mouseY <= referenceBounds.bottom) {
const popperBounds = this.$_popperNode.getBoundingClientRect();
const vectorX = mouseX - mousePreviousX;
const vectorY = mouseY - mousePreviousY;
const distance = popperBounds.left + popperBounds.width / 2 - mousePreviousX + (popperBounds.top + popperBounds.height / 2) - mousePreviousY;
const newVectorLength = distance + popperBounds.width + popperBounds.height;
const edgeX = mousePreviousX + vectorX * newVectorLength;
const edgeY = mousePreviousY + vectorY * newVectorLength;
return lineIntersectsLine(mousePreviousX, mousePreviousY, edgeX, edgeY, popperBounds.left, popperBounds.top, popperBounds.left, popperBounds.bottom) || lineIntersectsLine(mousePreviousX, mousePreviousY, edgeX, edgeY, popperBounds.left, popperBounds.top, popperBounds.right, popperBounds.top) || lineIntersectsLine(mousePreviousX, mousePreviousY, edgeX, edgeY, popperBounds.right, popperBounds.top, popperBounds.right, popperBounds.bottom) || lineIntersectsLine(mousePreviousX, mousePreviousY, edgeX, edgeY, popperBounds.left, popperBounds.bottom, popperBounds.right, popperBounds.bottom);
}
return false;
}
},
render() {
return this.$slots.default(this.slotData);
}
});
if (typeof document !== "undefined" && typeof window !== "undefined") {
if (isIOS$1) {
document.addEventListener("touchstart", handleGlobalMousedown, supportsPassive ? {
passive: true,
capture: true
} : true);
document.addEventListener("touchend", handleGlobalTouchend, supportsPassive ? {
passive: true,
capture: true
} : true);
} else {
window.addEventListener("mousedown", handleGlobalMousedown, true);
window.addEventListener("click", handleGlobalClick, true);
}
window.addEventListener("resize", computePositionAllShownPoppers);
}
function handleGlobalMousedown(event) {
for (let i2 = 0; i2 < shownPoppers.length; i2++) {
const popper = shownPoppers[i2];
try {
const popperContent = popper.popperNode();
popper.$_mouseDownContains = popperContent.contains(event.target);
} catch (e2) {
}
}
}
function handleGlobalClick(event) {
handleGlobalClose(event);
}
function handleGlobalTouchend(event) {
handleGlobalClose(event, true);
}
function handleGlobalClose(event, touch = false) {
const preventClose = {};
for (let i2 = shownPoppers.length - 1; i2 >= 0; i2--) {
const popper = shownPoppers[i2];
try {
const contains2 = popper.$_containsGlobalTarget = isContainingEventTarget(popper, event);
popper.$_pendingHide = false;
requestAnimationFrame(() => {
popper.$_pendingHide = false;
if (preventClose[popper.randomId])
return;
if (shouldAutoHide(popper, contains2, event)) {
popper.$_handleGlobalClose(event, touch);
if (!event.closeAllPopover && event.closePopover && contains2) {
let parent2 = popper.parentPopper;
while (parent2) {
preventClose[parent2.randomId] = true;
parent2 = parent2.parentPopper;
}
return;
}
let parent = popper.parentPopper;
while (parent) {
if (shouldAutoHide(parent, parent.$_containsGlobalTarget, event)) {
parent.$_handleGlobalClose(event, touch);
} else {
break;
}
parent = parent.parentPopper;
}
}
});
} catch (e2) {
}
}
}
function isContainingEventTarget(popper, event) {
const popperContent = popper.popperNode();
return popper.$_mouseDownContains || popperContent.contains(event.target);
}
function shouldAutoHide(popper, contains2, event) {
return event.closeAllPopover || event.closePopover && contains2 || getAutoHideResult(popper, event) && !contains2;
}
function getAutoHideResult(popper, event) {
if (typeof popper.autoHide === "function") {
const result = popper.autoHide(event);
popper.lastAutoHide = result;
return result;
}
return popper.autoHide;
}
function computePositionAllShownPoppers(event) {
for (let i2 = 0; i2 < shownPoppers.length; i2++) {
const popper = shownPoppers[i2];
popper.$_computePosition(event);
}
}
let mousePreviousX = 0;
let mousePreviousY = 0;
let mouseX = 0;
let mouseY = 0;
if (typeof window !== "undefined") {
window.addEventListener("mousemove", (event) => {
mousePreviousX = mouseX;
mousePreviousY = mouseY;
mouseX = event.clientX;
mouseY = event.clientY;
}, supportsPassive ? {
passive: true
} : void 0);
}
function lineIntersectsLine(x1, y1, x2, y2, x3, y3, x4, y4) {
const uA = ((x4 - x3) * (y1 - y3) - (y4 - y3) * (x1 - x3)) / ((y4 - y3) * (x2 - x1) - (x4 - x3) * (y2 - y1));
const uB = ((x2 - x1) * (y1 - y3) - (y2 - y1) * (x1 - x3)) / ((y4 - y3) * (x2 - x1) - (x4 - x3) * (y2 - y1));
return uA >= 0 && uA <= 1 && uB >= 0 && uB <= 1;
}
var _export_sfc = (sfc, props) => {
const target = sfc.__vccOpts || sfc;
for (const [key, val] of props) {
target[key] = val;
}
return target;
};
const _sfc_main$6 = {
extends: PrivatePopper()
};
function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
return openBlock(), createElementBlock("div", {
ref: "reference",
class: normalizeClass(["v-popper", {
"v-popper--shown": _ctx.slotData.isShown
}])
}, [
renderSlot(_ctx.$slots, "default", normalizeProps(guardReactiveProps(_ctx.slotData)))
], 2);
}
var Popper$1 = /* @__PURE__ */ _export_sfc(_sfc_main$6, [["render", _sfc_render$3]]);
function getInternetExplorerVersion() {
var ua2 = window.navigator.userAgent;
var msie = ua2.indexOf("MSIE ");
if (msie > 0) {
return parseInt(ua2.substring(msie + 5, ua2.indexOf(".", msie)), 10);
}
var trident = ua2.indexOf("Trident/");
if (trident > 0) {
var rv = ua2.indexOf("rv:");
return parseInt(ua2.substring(rv + 3, ua2.indexOf(".", rv)), 10);
}
var edge = ua2.indexOf("Edge/");
if (edge > 0) {
return parseInt(ua2.substring(edge + 5, ua2.indexOf(".", edge)), 10);
}
return -1;
}
let isIE;
function initCompat() {
if (!initCompat.init) {
initCompat.init = true;
isIE = getInternetExplorerVersion() !== -1;
}
}
var script = {
name: "ResizeObserver",
props: {
emitOnMount: {
type: Boolean,
default: false
},
ignoreWidth: {
type: Boolean,
default: false
},
ignoreHeight: {
type: Boolean,
default: false
}
},
emits: [
"notify"
],
mounted() {
initCompat();
nextTick(() => {
this._w = this.$el.offsetWidth;
this._h = this.$el.offsetHeight;
if (this.emitOnMount) {
this.emitSize();
}
});
const object = document.createElement("object");
this._resizeObject = object;
object.setAttribute("aria-hidden", "true");
object.setAttribute("tabindex", -1);
object.onload = this.addResizeHandlers;
object.type = "text/html";
if (isIE) {
this.$el.appendChild(object);
}
object.data = "about:blank";
if (!isIE) {
this.$el.appendChild(object);
}
},
beforeUnmount() {
this.removeResizeHandlers();
},
methods: {
compareAndNotify() {
if (!this.ignoreWidth && this._w !== this.$el.offsetWidth || !this.ignoreHeight && this._h !== this.$el.offsetHeight) {
this._w = this.$el.offsetWidth;
this._h = this.$el.offsetHeight;
this.emitSize();
}
},
emitSize() {
this.$emit("notify", {
width: this._w,
height: this._h
});
},
addResizeHandlers() {
this._resizeObject.contentDocument.defaultView.addEventListener("resize", this.compareAndNotify);
this.compareAndNotify();
},
removeResizeHandlers() {
if (this._resizeObject && this._resizeObject.onload) {
if (!isIE && this._resizeObject.contentDocument) {
this._resizeObject.contentDocument.defaultView.removeEventListener("resize", this.compareAndNotify);
}
this.$el.removeChild(this._resizeObject);
this._resizeObject.onload = null;
this._resizeObject = null;
}
}
}
};
const _withId = /* @__PURE__ */ withScopeId();
pushScopeId("data-v-b329ee4c");
const _hoisted_1$2 = {
class: "resize-observer",
tabindex: "-1"
};
popScopeId();
const render$1 = /* @__PURE__ */ _withId((_ctx, _cache, $props, $setup, $data, $options) => {
return openBlock(), createBlock("div", _hoisted_1$2);
});
script.render = render$1;
script.__scopeId = "data-v-b329ee4c";
script.__file = "src/components/ResizeObserver.vue";
var PrivateThemeClass = (prop = "theme") => ({
computed: {
themeClass() {
return getThemeClasses(this[prop]);
}
}
});
const _sfc_main$5 = /* @__PURE__ */ defineComponent({
name: "VPopperContent",
components: {
ResizeObserver: script
},
mixins: [
PrivateThemeClass()
],
props: {
popperId: String,
theme: String,
shown: Boolean,
mounted: Boolean,
skipTransition: Boolean,
autoHide: Boolean,
handleResize: Boolean,
classes: Object,
result: Object
},
emits: [
"hide",
"resize"
],
methods: {
toPx(value) {
if (value != null && !isNaN(value)) {
return `${value}px`;
}
return null;
}
}
});
const _hoisted_1$1 = ["id", "aria-hidden", "tabindex", "data-popper-placement"];
const _hoisted_2$1 = {
ref: "inner",
class: "v-popper__inner"
};
const _hoisted_3 = /* @__PURE__ */ createBaseVNode("div", { class: "v-popper__arrow-outer" }, null, -1);
const _hoisted_4 = /* @__PURE__ */ createBaseVNode("div", { class: "v-popper__arrow-inner" }, null, -1);
const _hoisted_5 = [
_hoisted_3,
_hoisted_4
];
function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
const _component_ResizeObserver = resolveComponent("ResizeObserver");
return openBlock(), createElementBlock("div", {
id: _ctx.popperId,
ref: "popover",
class: normalizeClass(["v-popper__popper", [
_ctx.themeClass,
_ctx.classes.popperClass,
{
"v-popper__popper--shown": _ctx.shown,
"v-popper__popper--hidden": !_ctx.shown,
"v-popper__popper--show-from": _ctx.classes.showFrom,
"v-popper__popper--show-to": _ctx.classes.showTo,
"v-popper__popper--hide-from": _ctx.classes.hideFrom,
"v-popper__popper--hide-to": _ctx.classes.hideTo,
"v-popper__popper--skip-transition": _ctx.skipTransition,
"v-popper__popper--arrow-overflow": _ctx.result && _ctx.result.arrow.overflow,
"v-popper__popper--no-positioning": !_ctx.result
}
]]),
style: normalizeStyle(_ctx.result ? {
position: _ctx.result.strategy,
transform: `translate3d(${Math.round(_ctx.result.x)}px,${Math.round(_ctx.result.y)}px,0)`
} : void 0),
"aria-hidden": _ctx.shown ? "false" : "true",
tabindex: _ctx.autoHide ? 0 : void 0,
"data-popper-placement": _ctx.result ? _ctx.result.placement : void 0,
onKeyup: _cache[2] || (_cache[2] = withKeys(($event) => _ctx.autoHide && _ctx.$emit("hide"), ["esc"]))
}, [
createBaseVNode("div", {
class: "v-popper__backdrop",
onClick: _cache[0] || (_cache[0] = ($event) => _ctx.autoHide && _ctx.$emit("hide"))
}),
createBaseVNode("div", {
class: "v-popper__wrapper",
style: normalizeStyle(_ctx.result ? {
transformOrigin: _ctx.result.transformOrigin
} : void 0)
}, [
createBaseVNode("div", _hoisted_2$1, [
_ctx.mounted ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
createBaseVNode("div", null, [
renderSlot(_ctx.$slots, "default")
]),
_ctx.handleResize ? (openBlock(), createBlock(_component_ResizeObserver, {
key: 0,
onNotify: _cache[1] || (_cache[1] = ($event) => _ctx.$emit("resize", $event))
})) : createCommentVNode("", true)
], 64)) : createCommentVNode("", true)
], 512),
createBaseVNode("div", {
ref: "arrow",
class: "v-popper__arrow-container",
style: normalizeStyle(_ctx.result ? {
left: _ctx.toPx(_ctx.result.arrow.x),
top: _ctx.toPx(_ctx.result.arrow.y)
} : void 0)
}, _hoisted_5, 4)
], 4)
], 46, _hoisted_1$1);
}
var PrivatePopperContent = /* @__PURE__ */ _export_sfc(_sfc_main$5, [["render", _sfc_render$2]]);
var PrivatePopperMethods = {
methods: {
show(...args) {
return this.$refs.popper.show(...args);
},
hide(...args) {
return this.$refs.popper.hide(...args);
},
dispose(...args) {
return this.$refs.popper.dispose(...args);
},
onResize(...args) {
return this.$refs.popper.onResize(...args);
}
}
};
const _sfc_main$4 = /* @__PURE__ */ defineComponent({
name: "VPopperWrapper",
components: {
Popper: Popper$1,
PopperContent: PrivatePopperContent
},
mixins: [
PrivatePopperMethods,
PrivateThemeClass("finalTheme")
],
props: {
theme: {
type: String,
default: null
}
},
computed: {
finalTheme() {
var _a2;
return (_a2 = this.theme) != null ? _a2 : this.$options.vPopperTheme;
}
},
methods: {
getTargetNodes() {
return Array.from(this.$el.children).filter((node) => node !== this.$refs.popperContent.$el);
}
}
});
function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
const _component_PopperContent = resolveComponent("PopperContent");
const _component_Popper = resolveComponent("Popper");
return openBlock(), createBlock(_component_Popper, {
ref: "popper",
theme: _ctx.finalTheme,
"target-nodes": _ctx.getTargetNodes,
"popper-node": () => _ctx.$refs.popperContent.$el,
class: normalizeClass([
_ctx.themeClass
])
}, {
default: withCtx(({
popperId,
isShown,
shouldMountContent,
skipTransition,
autoHide,
show,
hide: hide2,
handleResize,
onResize,
classes,
result
}) => [
renderSlot(_ctx.$slots, "default", {
shown: isShown,
show,
hide: hide2
}),
createVNode(_component_PopperContent, {
ref: "popperContent",
"popper-id": popperId,
theme: _ctx.finalTheme,
shown: isShown,
mounted: shouldMountContent,
"skip-transition": skipTransition,
"auto-hide": autoHide,
"handle-resize": handleResize,
classes,
result,
onHide: hide2,
onResize
}, {
default: withCtx(() => [
renderSlot(_ctx.$slots, "popper", {
shown: isShown,
hide: hide2
})
]),
_: 2
}, 1032, ["popper-id", "theme", "shown", "mounted", "skip-transition", "auto-hide", "handle-resize", "classes", "result", "onHide", "onResize"])
]),
_: 3
}, 8, ["theme", "target-nodes", "popper-node", "class"]);
}
var PrivatePopperWrapper = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["render", _sfc_render$1]]);
const _sfc_main$3 = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues$1({}, PrivatePopperWrapper), {
name: "VDropdown",
vPopperTheme: "dropdown"
}));
const _sfc_main$2 = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues$1({}, PrivatePopperWrapper), {
name: "VMenu",
vPopperTheme: "menu"
}));
const _sfc_main$1 = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues$1({}, PrivatePopperWrapper), {
name: "VTooltip",
vPopperTheme: "tooltip"
}));
const _sfc_main = /* @__PURE__ */ defineComponent({
name: "VTooltipDirective",
components: {
Popper: PrivatePopper(),
PopperContent: PrivatePopperContent
},
mixins: [
PrivatePopperMethods
],
inheritAttrs: false,
props: {
theme: {
type: String,
default: "tooltip"
},
html: {
type: Boolean,
default: (props) => getDefaultConfig(props.theme, "html")
},
content: {
type: [String, Number, Function],
default: null
},
loadingContent: {
type: String,
default: (props) => getDefaultConfig(props.theme, "loadingContent")
}
},
data() {
return {
asyncContent: null
};
},
computed: {
isContentAsync() {
return typeof this.content === "function";
},
loading() {
return this.isContentAsync && this.asyncContent == null;
},
finalContent() {
if (this.isContentAsync) {
return this.loading ? this.loadingContent : this.asyncContent;
}
return this.content;
}
},
watch: {
content: {
handler() {
this.fetchContent(true);
},
immediate: true
},
async finalContent() {
await this.$nextTick();
this.$refs.popper.onResize();
}
},
created() {
this.$_fetchId = 0;
},
methods: {
fetchContent(force) {
if (typeof this.content === "function" && this.$_isShown && (force || !this.$_loading && this.asyncContent == null)) {
this.asyncContent = null;
this.$_loading = true;
const fetchId = ++this.$_fetchId;
const result = this.content(this);
if (result.then) {
result.then((res) => this.onResult(fetchId, res));
} else {
this.onResult(fetchId, result);
}
}
},
onResult(fetchId, result) {
if (fetchId !== this.$_fetchId)
return;
this.$_loading = false;
this.asyncContent = result;
},
onShow() {
this.$_isShown = true;
this.fetchContent();
},
onHide() {
this.$_isShown = false;
}
}
});
const _hoisted_1 = ["innerHTML"];
const _hoisted_2 = ["textContent"];
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
const _component_PopperContent = resolveComponent("PopperContent");
const _component_Popper = resolveComponent("Popper");
return openBlock(), createBlock(_component_Popper, mergeProps({ ref: "popper" }, _ctx.$attrs, {
theme: _ctx.theme,
"popper-node": () => _ctx.$refs.popperContent.$el,
onApplyShow: _ctx.onShow,
onApplyHide: _ctx.onHide
}), {
default: withCtx(({
popperId,
isShown,
shouldMountContent,
skipTransition,
autoHide,
hide: hide2,
handleResize,
onResize,
classes,
result
}) => [
createVNode(_component_PopperContent, {
ref: "popperContent",
class: normalizeClass({
"v-popper--tooltip-loading": _ctx.loading
}),
"popper-id": popperId,
theme: _ctx.theme,
shown: isShown,
mounted: shouldMountContent,
"skip-transition": skipTransition,
"auto-hide": autoHide,
"handle-resize": handleResize,
classes,
result,
onHide: hide2,
onResize
}, {
default: withCtx(() => [
_ctx.html ? (openBlock(), createElementBlock("div", {
key: 0,
innerHTML: _ctx.finalContent
}, null, 8, _hoisted_1)) : (openBlock(), createElementBlock("div", {
key: 1,
textContent: toDisplayString(_ctx.finalContent)
}, null, 8, _hoisted_2))
]),
_: 2
}, 1032, ["class", "popper-id", "theme", "shown", "mounted", "skip-transition", "auto-hide", "handle-resize", "classes", "result", "onHide", "onResize"])
]),
_: 1
}, 16, ["theme", "popper-node", "onApplyShow", "onApplyHide"]);
}
var PrivateTooltipDirective = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
const TARGET_CLASS = "v-popper--has-tooltip";
function getPlacement(options2, modifiers) {
let result = options2.placement;
if (!result && modifiers) {
for (const pos of placements) {
if (modifiers[pos]) {
result = pos;
}
}
}
if (!result) {
result = getDefaultConfig(options2.theme || "tooltip", "placement");
}
return result;
}
function getOptions$1(el2, value, modifiers) {
let options2;
const type = typeof value;
if (type === "string") {
options2 = { content: value };
} else if (value && type === "object") {
options2 = value;
} else {
options2 = { content: false };
}
options2.placement = getPlacement(options2, modifiers);
options2.targetNodes = () => [el2];
options2.referenceNode = () => el2;
return options2;
}
let directiveApp;
let directives;
let uid = 0;
function ensureDirectiveApp() {
if (directiveApp)
return;
directives = ref([]);
directiveApp = createApp({
name: "VTooltipDirectiveApp",
setup() {
return {
directives
};
},
render() {
return this.directives.map((directive) => {
return h$2(PrivateTooltipDirective, __spreadProps(__spreadValues$1({}, directive.options), {
shown: directive.shown || directive.options.shown,
key: directive.id
}));
});
},
devtools: {
hide: true
}
});
const mountTarget = document.createElement("div");
document.body.appendChild(mountTarget);
directiveApp.mount(mountTarget);
}
function createTooltip(el2, value, modifiers) {
ensureDirectiveApp();
const options2 = ref(getOptions$1(el2, value, modifiers));
const shown = ref(false);
const item = {
id: uid++,
options: options2,
shown
};
directives.value.push(item);
if (el2.classList) {
el2.classList.add(TARGET_CLASS);
}
const result = el2.$_popper = {
options: options2,
item,
show() {
shown.value = true;
},
hide() {
shown.value = false;
}
};
return result;
}
function destroyTooltip(el2) {
if (el2.$_popper) {
const index2 = directives.value.indexOf(el2.$_popper.item);
if (index2 !== -1)
directives.value.splice(index2, 1);
delete el2.$_popper;
delete el2.$_popperOldShown;
delete el2.$_popperMountTarget;
}
if (el2.classList) {
el2.classList.remove(TARGET_CLASS);
}
}
function bind(el2, { value, modifiers }) {
const options2 = getOptions$1(el2, value, modifiers);
if (!options2.content || getDefaultConfig(options2.theme || "tooltip", "disabled")) {
destroyTooltip(el2);
} else {
let directive;
if (el2.$_popper) {
directive = el2.$_popper;
directive.options.value = options2;
} else {
directive = createTooltip(el2, value, modifiers);
}
if (typeof value.shown !== "undefined" && value.shown !== el2.$_popperOldShown) {
el2.$_popperOldShown = value.shown;
value.shown ? directive.show() : directive.hide();
}
}
}
var PrivateVTooltip = {
beforeMount: bind,
updated: bind,
beforeUnmount(el2) {
destroyTooltip(el2);
}
};
function addListeners(el2) {
el2.addEventListener("click", onClick);
el2.addEventListener("touchstart", onTouchStart, supportsPassive ? {
passive: true
} : false);
}
function removeListeners(el2) {
el2.removeEventListener("click", onClick);
el2.removeEventListener("touchstart", onTouchStart);
el2.removeEventListener("touchend", onTouchEnd);
el2.removeEventListener("touchcancel", onTouchCancel);
}
function onClick(event) {
const el2 = event.currentTarget;
event.closePopover = !el2.$_vclosepopover_touch;
event.closeAllPopover = el2.$_closePopoverModifiers && !!el2.$_closePopoverModifiers.all;
}
function onTouchStart(event) {
if (event.changedTouches.length === 1) {
const el2 = event.currentTarget;
el2.$_vclosepopover_touch = true;
const touch = event.changedTouches[0];
el2.$_vclosepopover_touchPoint = touch;
el2.addEventListener("touchend", onTouchEnd);
el2.addEventListener("touchcancel", onTouchCancel);
}
}
function onTouchEnd(event) {
const el2 = event.currentTarget;
el2.$_vclosepopover_touch = false;
if (event.changedTouches.length === 1) {
const touch = event.changedTouches[0];
const firstTouch = el2.$_vclosepopover_touchPoint;
event.closePopover = Math.abs(touch.screenY - firstTouch.screenY) < 20 && Math.abs(touch.screenX - firstTouch.screenX) < 20;
event.closeAllPopover = el2.$_closePopoverModifiers && !!el2.$_closePopoverModifiers.all;
}
}
function onTouchCancel(event) {
const el2 = event.currentTarget;
el2.$_vclosepopover_touch = false;
}
var PrivateVClosePopper = {
beforeMount(el2, { value, modifiers }) {
el2.$_closePopoverModifiers = modifiers;
if (typeof value === "undefined" || value) {
addListeners(el2);
}
},
updated(el2, { value, oldValue, modifiers }) {
el2.$_closePopoverModifiers = modifiers;
if (value !== oldValue) {
if (typeof value === "undefined" || value) {
addListeners(el2);
} else {
removeListeners(el2);
}
}
},
beforeUnmount(el2) {
removeListeners(el2);
}
};
const VTooltip = PrivateVTooltip;
const Dropdown = _sfc_main$3;
function install(app, options2 = {}) {
if (app.$_vTooltipInstalled)
return;
app.$_vTooltipInstalled = true;
assign$2(config$1, options2);
app.directive("tooltip", PrivateVTooltip);
app.directive("close-popper", PrivateVClosePopper);
app.component("VTooltip", _sfc_main$1);
app.component("VDropdown", _sfc_main$3);
app.component("VMenu", _sfc_main$2);
}
const plugin = {
version: "2.0.0-beta.19",
install,
options: config$1
};
function noop$2() {
}
function assign$1(tar, src) {
for (const k2 in src)
tar[k2] = src[k2];
return (
/** @type {T & S} */
tar
);
}
function add_location(element2, file, line, column, char) {
element2.__svelte_meta = {
loc: { file, line, column, char }
};
}
function run(fn2) {
return fn2();
}
function blank_object() {
return /* @__PURE__ */ Object.create(null);
}
function run_all(fns) {
fns.forEach(run);
}
function is_function(thing) {
return typeof thing === "function";
}
function safe_not_equal(a2, b3) {
return a2 != a2 ? b3 == b3 : a2 !== b3 || a2 && typeof a2 === "object" || typeof a2 === "function";
}
function is_empty(obj) {
return Object.keys(obj).length === 0;
}
function create_slot(definition, ctx, $$scope, fn2) {
if (definition) {
const slot_ctx = get_slot_context(definition, ctx, $$scope, fn2);
return definition[0](slot_ctx);
}
}
function get_slot_context(definition, ctx, $$scope, fn2) {
return definition[1] && fn2 ? assign$1($$scope.ctx.slice(), definition[1](fn2(ctx))) : $$scope.ctx;
}
function get_slot_changes(definition, $$scope, dirty, fn2) {
if (definition[2] && fn2) {
const lets = definition[2](fn2(dirty));
if ($$scope.dirty === void 0) {
return lets;
}
if (typeof lets === "object") {
const merged = [];
const len = Math.max($$scope.dirty.length, lets.length);
for (let i2 = 0; i2 < len; i2 += 1) {
merged[i2] = $$scope.dirty[i2] | lets[i2];
}
return merged;
}
return $$scope.dirty | lets;
}
return $$scope.dirty;
}
function update_slot_base(slot, slot_definition, ctx, $$scope, slot_changes, get_slot_context_fn) {
if (slot_changes) {
const slot_context = get_slot_context(slot_definition, ctx, $$scope, get_slot_context_fn);
slot.p(slot_context, slot_changes);
}
}
function get_all_dirty_from_scope($$scope) {
if ($$scope.ctx.length > 32) {
const dirty = [];
const length = $$scope.ctx.length / 32;
for (let i2 = 0; i2 < length; i2++) {
dirty[i2] = -1;
}
return dirty;
}
return -1;
}
function exclude_internal_props(props) {
const result = {};
for (const k2 in props)
if (k2[0] !== "$")
result[k2] = props[k2];
return result;
}
function compute_rest_props(props, keys) {
const rest = {};
keys = new Set(keys);
for (const k2 in props)
if (!keys.has(k2) && k2[0] !== "$")
rest[k2] = props[k2];
return rest;
}
function compute_slots(slots) {
const result = {};
for (const key in slots) {
result[key] = true;
}
return result;
}
let is_hydrating = false;
function start_hydrating() {
is_hydrating = true;
}
function end_hydrating() {
is_hydrating = false;
}
function upper_bound(low, high, key, value) {
while (low < high) {
const mid = low + (high - low >> 1);
if (key(mid) <= value) {
low = mid + 1;
} else {
high = mid;
}
}
return low;
}
function init_hydrate(target) {
if (target.hydrate_init)
return;
target.hydrate_init = true;
let children2 = (
/** @type {ArrayLike<NodeEx2>} */
target.childNodes
);
if (target.nodeName === "HEAD") {
const my_children = [];
for (let i2 = 0; i2 < children2.length; i2++) {
const node = children2[i2];
if (node.claim_order !== void 0) {
my_children.push(node);
}
}
children2 = my_children;
}
const m = new Int32Array(children2.length + 1);
const p2 = new Int32Array(children2.length);
m[0] = -1;
let longest = 0;
for (let i2 = 0; i2 < children2.length; i2++) {
const current = children2[i2].claim_order;
const seq_len = (longest > 0 && children2[m[longest]].claim_order <= current ? longest + 1 : upper_bound(1, longest, (idx) => children2[m[idx]].claim_order, current)) - 1;
p2[i2] = m[seq_len] + 1;
const new_len = seq_len + 1;
m[new_len] = i2;
longest = Math.max(new_len, longest);
}
const lis = [];
const to_move = [];
let last = children2.length - 1;
for (let cur = m[longest] + 1; cur != 0; cur = p2[cur - 1]) {
lis.push(children2[cur - 1]);
for (; last >= cur; last--) {
to_move.push(children2[last]);
}
last--;
}
for (; last >= 0; last--) {
to_move.push(children2[last]);
}
lis.reverse();
to_move.sort((a2, b3) => a2.claim_order - b3.claim_order);
for (let i2 = 0, j2 = 0; i2 < to_move.length; i2++) {
while (j2 < lis.length && to_move[i2].claim_order >= lis[j2].claim_order) {
j2++;
}
const anchor = j2 < lis.length ? lis[j2] : null;
target.insertBefore(to_move[i2], anchor);
}
}
function append(target, node) {
target.appendChild(node);
}
function append_hydration(target, node) {
if (is_hydrating) {
init_hydrate(target);
if (target.actual_end_child === void 0 || target.actual_end_child !== null && target.actual_end_child.parentNode !== target) {
target.actual_end_child = target.firstChild;
}
while (target.actual_end_child !== null && target.actual_end_child.claim_order === void 0) {
target.actual_end_child = target.actual_end_child.nextSibling;
}
if (node !== target.actual_end_child) {
if (node.claim_order !== void 0 || node.parentNode !== target) {
target.insertBefore(node, target.actual_end_child);
}
} else {
target.actual_end_child = node.nextSibling;
}
} else if (node.parentNode !== target || node.nextSibling !== null) {
target.appendChild(node);
}
}
function insert(target, node, anchor) {
target.insertBefore(node, anchor || null);
}
function insert_hydration(target, node, anchor) {
if (is_hydrating && !anchor) {
append_hydration(target, node);
} else if (node.parentNode !== target || node.nextSibling != anchor) {
target.insertBefore(node, anchor || null);
}
}
function detach(node) {
if (node.parentNode) {
node.parentNode.removeChild(node);
}
}
function destroy_each(iterations, detaching) {
for (let i2 = 0; i2 < iterations.length; i2 += 1) {
if (iterations[i2])
iterations[i2].d(detaching);
}
}
function element(name) {
return document.createElement(name);
}
function svg_element(name) {
return document.createElementNS("http://www.w3.org/2000/svg", name);
}
function text(data) {
return document.createTextNode(data);
}
function space() {
return text(" ");
}
function empty() {
return text("");
}
function listen(node, event, handler, options) {
node.addEventListener(event, handler, options);
return () => node.removeEventListener(event, handler, options);
}
function attr(node, attribute, value) {
if (value == null)
node.removeAttribute(attribute);
else if (node.getAttribute(attribute) !== value)
node.setAttribute(attribute, value);
}
function get_svelte_dataset(node) {
return node.dataset.svelteH;
}
function to_number(value) {
return value === "" ? null : +value;
}
function children(element2) {
return Array.from(element2.childNodes);
}
function init_claim_info(nodes) {
if (nodes.claim_info === void 0) {
nodes.claim_info = { last_index: 0, total_claimed: 0 };
}
}
function claim_node(nodes, predicate, process_node, create_node, dont_update_last_index = false) {
init_claim_info(nodes);
const result_node = (() => {
for (let i2 = nodes.claim_info.last_index; i2 < nodes.length; i2++) {
const node = nodes[i2];
if (predicate(node)) {
const replacement = process_node(node);
if (replacement === void 0) {
nodes.splice(i2, 1);
} else {
nodes[i2] = replacement;
}
if (!dont_update_last_index) {
nodes.claim_info.last_index = i2;
}
return node;
}
}
for (let i2 = nodes.claim_info.last_index - 1; i2 >= 0; i2--) {
const node = nodes[i2];
if (predicate(node)) {
const replacement = process_node(node);
if (replacement === void 0) {
nodes.splice(i2, 1);
} else {
nodes[i2] = replacement;
}
if (!dont_update_last_index) {
nodes.claim_info.last_index = i2;
} else if (replacement === void 0) {
nodes.claim_info.last_index--;
}
return node;
}
}
return create_node();
})();
result_node.claim_order = nodes.claim_info.total_claimed;
nodes.claim_info.total_claimed += 1;
return result_node;
}
function claim_element_base(nodes, name, attributes, create_element) {
return claim_node(
nodes,
/** @returns {node is Element | SVGElement} */
(node) => node.nodeName === name,
/** @param {Element} node */
(node) => {
const remove2 = [];
for (let j2 = 0; j2 < node.attributes.length; j2++) {
const attribute = node.attributes[j2];
if (!attributes[attribute.name]) {
remove2.push(attribute.name);
}
}
remove2.forEach((v2) => node.removeAttribute(v2));
return void 0;
},
() => create_element(name)
);
}
function claim_element(nodes, name, attributes) {
return claim_element_base(nodes, name, attributes, element);
}
function claim_svg_element(nodes, name, attributes) {
return claim_element_base(nodes, name, attributes, svg_element);
}
function claim_text(nodes, data) {
return claim_node(
nodes,
/** @returns {node is Text} */
(node) => node.nodeType === 3,
/** @param {Text} node */
(node) => {
const data_str = "" + data;
if (node.data.startsWith(data_str)) {
if (node.data.length !== data_str.length) {
return node.splitText(data_str.length);
}
} else {
node.data = data_str;
}
},
() => text(data),
true
// Text nodes should not update last index since it is likely not worth it to eliminate an increasing subsequence of actual elements
);
}
function claim_space(nodes) {
return claim_text(nodes, " ");
}
function set_data(text2, data) {
data = "" + data;
if (text2.data === data)
return;
text2.data = /** @type {string} */
data;
}
function set_input_value(input, value) {
input.value = value == null ? "" : value;
}
function select_option(select, value, mounting) {
for (let i2 = 0; i2 < select.options.length; i2 += 1) {
const option = select.options[i2];
if (option.__value === value) {
option.selected = true;
return;
}
}
if (!mounting || value !== void 0) {
select.selectedIndex = -1;
}
}
function select_value(select) {
const selected_option = select.querySelector(":checked");
return selected_option && selected_option.__value;
}
function toggle_class(element2, name, toggle) {
element2.classList.toggle(name, !!toggle);
}
function custom_event(type, detail, { bubbles = false, cancelable = false } = {}) {
return new CustomEvent(type, { detail, bubbles, cancelable });
}
let current_component;
function set_current_component(component) {
current_component = component;
}
function get_current_component() {
if (!current_component)
throw new Error("Function called outside component initialization");
return current_component;
}
function onMount(fn2) {
get_current_component().$$.on_mount.push(fn2);
}
function afterUpdate(fn2) {
get_current_component().$$.after_update.push(fn2);
}
function createEventDispatcher() {
const component = get_current_component();
return (type, detail, { cancelable = false } = {}) => {
const callbacks2 = component.$$.callbacks[type];
if (callbacks2) {
const event = custom_event(
/** @type {string} */
type,
detail,
{ cancelable }
);
callbacks2.slice().forEach((fn2) => {
fn2.call(component, event);
});
return !event.defaultPrevented;
}
return true;
};
}
function setContext(key, context) {
get_current_component().$$.context.set(key, context);
return context;
}
function getContext(key) {
return get_current_component().$$.context.get(key);
}
const dirty_components = [];
const binding_callbacks = [];
let render_callbacks = [];
const flush_callbacks = [];
const resolved_promise = /* @__PURE__ */ Promise.resolve();
let update_scheduled = false;
function schedule_update() {
if (!update_scheduled) {
update_scheduled = true;
resolved_promise.then(flush);
}
}
function add_render_callback(fn2) {
render_callbacks.push(fn2);
}
const seen_callbacks = /* @__PURE__ */ new Set();
let flushidx = 0;
function flush() {
if (flushidx !== 0) {
return;
}
const saved_component = current_component;
do {
try {
while (flushidx < dirty_components.length) {
const component = dirty_components[flushidx];
flushidx++;
set_current_component(component);
update(component.$$);
}
} catch (e2) {
dirty_components.length = 0;
flushidx = 0;
throw e2;
}
set_current_component(null);
dirty_components.length = 0;
flushidx = 0;
while (binding_callbacks.length)
binding_callbacks.pop()();
for (let i2 = 0; i2 < render_callbacks.length; i2 += 1) {
const callback = render_callbacks[i2];
if (!seen_callbacks.has(callback)) {
seen_callbacks.add(callback);
callback();
}
}
render_callbacks.length = 0;
} while (dirty_components.length);
while (flush_callbacks.length) {
flush_callbacks.pop()();
}
update_scheduled = false;
seen_callbacks.clear();
set_current_component(saved_component);
}
function update($$) {
if ($$.fragment !== null) {
$$.update();
run_all($$.before_update);
const dirty = $$.dirty;
$$.dirty = [-1];
$$.fragment && $$.fragment.p($$.ctx, dirty);
$$.after_update.forEach(add_render_callback);
}
}
function flush_render_callbacks(fns) {
const filtered = [];
const targets = [];
render_callbacks.forEach((c2) => fns.indexOf(c2) === -1 ? filtered.push(c2) : targets.push(c2));
targets.forEach((c2) => c2());
render_callbacks = filtered;
}
const outroing = /* @__PURE__ */ new Set();
let outros;
function group_outros() {
outros = {
r: 0,
c: [],
p: outros
// parent group
};
}
function check_outros() {
if (!outros.r) {
run_all(outros.c);
}
outros = outros.p;
}
function transition_in(block, local) {
if (block && block.i) {
outroing.delete(block);
block.i(local);
}
}
function transition_out(block, local, detach2, callback) {
if (block && block.o) {
if (outroing.has(block))
return;
outroing.add(block);
outros.c.push(() => {
outroing.delete(block);
if (callback) {
if (detach2)
block.d(1);
callback();
}
});
block.o(local);
} else if (callback) {
callback();
}
}
function ensure_array_like(array_like_or_iterator) {
return (array_like_or_iterator == null ? void 0 : array_like_or_iterator.length) !== void 0 ? array_like_or_iterator : Array.from(array_like_or_iterator);
}
function get_spread_update(levels, updates) {
const update2 = {};
const to_null_out = {};
const accounted_for = { $$scope: 1 };
let i2 = levels.length;
while (i2--) {
const o = levels[i2];
const n2 = updates[i2];
if (n2) {
for (const key in o) {
if (!(key in n2))
to_null_out[key] = 1;
}
for (const key in n2) {
if (!accounted_for[key]) {
update2[key] = n2[key];
accounted_for[key] = 1;
}
}
levels[i2] = n2;
} else {
for (const key in o) {
accounted_for[key] = 1;
}
}
}
for (const key in to_null_out) {
if (!(key in update2))
update2[key] = void 0;
}
return update2;
}
function get_spread_object(spread_props) {
return typeof spread_props === "object" && spread_props !== null ? spread_props : {};
}
function create_component(block) {
block && block.c();
}
function claim_component(block, parent_nodes) {
block && block.l(parent_nodes);
}
function mount_component(component, target, anchor) {
const { fragment, after_update } = component.$$;
fragment && fragment.m(target, anchor);
add_render_callback(() => {
const new_on_destroy = component.$$.on_mount.map(run).filter(is_function);
if (component.$$.on_destroy) {
component.$$.on_destroy.push(...new_on_destroy);
} else {
run_all(new_on_destroy);
}
component.$$.on_mount = [];
});
after_update.forEach(add_render_callback);
}
function destroy_component(component, detaching) {
const $$ = component.$$;
if ($$.fragment !== null) {
flush_render_callbacks($$.after_update);
run_all($$.on_destroy);
$$.fragment && $$.fragment.d(detaching);
$$.on_destroy = $$.fragment = null;
$$.ctx = [];
}
}
function make_dirty(component, i2) {
if (component.$$.dirty[0] === -1) {
dirty_components.push(component);
schedule_update();
component.$$.dirty.fill(0);
}
component.$$.dirty[i2 / 31 | 0] |= 1 << i2 % 31;
}
function init(component, options, instance, create_fragment, not_equal, props, append_styles = null, dirty = [-1]) {
const parent_component = current_component;
set_current_component(component);
const $$ = component.$$ = {
fragment: null,
ctx: [],
// state
props,
update: noop$2,
not_equal,
bound: blank_object(),
// lifecycle
on_mount: [],
on_destroy: [],
on_disconnect: [],
before_update: [],
after_update: [],
context: new Map(options.context || (parent_component ? parent_component.$$.context : [])),
// everything else
callbacks: blank_object(),
dirty,
skip_bound: false,
root: options.target || parent_component.$$.root
};
append_styles && append_styles($$.root);
let ready = false;
$$.ctx = instance ? instance(component, options.props || {}, (i2, ret, ...rest) => {
const value = rest.length ? rest[0] : ret;
if ($$.ctx && not_equal($$.ctx[i2], $$.ctx[i2] = value)) {
if (!$$.skip_bound && $$.bound[i2])
$$.bound[i2](value);
if (ready)
make_dirty(component, i2);
}
return ret;
}) : [];
$$.update();
ready = true;
run_all($$.before_update);
$$.fragment = create_fragment ? create_fragment($$.ctx) : false;
if (options.target) {
if (options.hydrate) {
start_hydrating();
const nodes = children(options.target);
$$.fragment && $$.fragment.l(nodes);
nodes.forEach(detach);
} else {
$$.fragment && $$.fragment.c();
}
if (options.intro)
transition_in(component.$$.fragment);
mount_component(component, options.target, options.anchor);
end_hydrating();
flush();
}
set_current_component(parent_component);
}
class SvelteComponent {
constructor() {
/**
* ### PRIVATE API
*
* Do not use, may change at any time
*
* @type {any}
*/
__publicField(this, "$$");
/**
* ### PRIVATE API
*
* Do not use, may change at any time
*
* @type {any}
*/
__publicField(this, "$$set");
}
/** @returns {void} */
$destroy() {
destroy_component(this, 1);
this.$destroy = noop$2;
}
/**
* @template {Extract<keyof Events, string>} K
* @param {K} type
* @param {((e: Events[K]) => void) | null | undefined} callback
* @returns {() => void}
*/
$on(type, callback) {
if (!is_function(callback)) {
return noop$2;
}
const callbacks2 = this.$$.callbacks[type] || (this.$$.callbacks[type] = []);
callbacks2.push(callback);
return () => {
const index2 = callbacks2.indexOf(callback);
if (index2 !== -1)
callbacks2.splice(index2, 1);
};
}
/**
* @param {Partial<Props>} props
* @returns {void}
*/
$set(props) {
if (this.$$set && !is_empty(props)) {
this.$$.skip_bound = true;
this.$$set(props);
this.$$.skip_bound = false;
}
}
}
const VERSION = "4.2.15";
const PUBLIC_VERSION = "4";
function dispatch_dev(type, detail) {
document.dispatchEvent(custom_event(type, { version: VERSION, ...detail }, { bubbles: true }));
}
function append_hydration_dev(target, node) {
dispatch_dev("SvelteDOMInsert", { target, node });
append_hydration(target, node);
}
function insert_hydration_dev(target, node, anchor) {
dispatch_dev("SvelteDOMInsert", { target, node, anchor });
insert_hydration(target, node, anchor);
}
function detach_dev(node) {
dispatch_dev("SvelteDOMRemove", { node });
detach(node);
}
function listen_dev(node, event, handler, options, has_prevent_default, has_stop_propagation, has_stop_immediate_propagation) {
const modifiers = options === true ? ["capture"] : options ? Array.from(Object.keys(options)) : [];
if (has_prevent_default)
modifiers.push("preventDefault");
if (has_stop_propagation)
modifiers.push("stopPropagation");
if (has_stop_immediate_propagation)
modifiers.push("stopImmediatePropagation");
dispatch_dev("SvelteDOMAddEventListener", { node, event, handler, modifiers });
const dispose = listen(node, event, handler, options);
return () => {
dispatch_dev("SvelteDOMRemoveEventListener", { node, event, handler, modifiers });
dispose();
};
}
function attr_dev(node, attribute, value) {
attr(node, attribute, value);
if (value == null)
dispatch_dev("SvelteDOMRemoveAttribute", { node, attribute });
else
dispatch_dev("SvelteDOMSetAttribute", { node, attribute, value });
}
function set_data_dev(text2, data) {
data = "" + data;
if (text2.data === data)
return;
dispatch_dev("SvelteDOMSetData", { node: text2, data });
text2.data = /** @type {string} */
data;
}
function ensure_array_like_dev(arg) {
if (typeof arg !== "string" && !(arg && typeof arg === "object" && "length" in arg) && !(typeof Symbol === "function" && arg && Symbol.iterator in arg)) {
throw new Error("{#each} only works with iterable values.");
}
return ensure_array_like(arg);
}
function validate_slots(name, slot, keys) {
for (const slot_key of Object.keys(slot)) {
if (!~keys.indexOf(slot_key)) {
console.warn(`<${name}> received an unexpected slot "${slot_key}".`);
}
}
}
class SvelteComponentDev extends SvelteComponent {
/** @param {import('./public.js').ComponentConstructorOptions<Props>} options */
constructor(options) {
if (!options || !options.target && !options.$$inline) {
throw new Error("'target' is a required option");
}
super();
/**
* For type checking capabilities only.
* Does not exist at runtime.
* ### DO NOT USE!
*
* @type {Props}
*/
__publicField(this, "$$prop_def");
/**
* For type checking capabilities only.
* Does not exist at runtime.
* ### DO NOT USE!
*
* @type {Events}
*/
__publicField(this, "$$events_def");
/**
* For type checking capabilities only.
* Does not exist at runtime.
* ### DO NOT USE!
*
* @type {Slots}
*/
__publicField(this, "$$slot_def");
}
/** @returns {void} */
$destroy() {
super.$destroy();
this.$destroy = () => {
console.warn("Component was already destroyed");
};
}
/** @returns {void} */
$capture_state() {
}
/** @returns {void} */
$inject_state() {
}
}
if (typeof window !== "undefined")
(window.__svelte || (window.__svelte = { v: /* @__PURE__ */ new Set() })).v.add(PUBLIC_VERSION);
var _a$1;
const isClient = typeof window !== "undefined";
const isFunction = (val) => typeof val === "function";
const isString = (val) => typeof val === "string";
const noop$1 = () => {
};
const isIOS = isClient && ((_a$1 = window == null ? void 0 : window.navigator) == null ? void 0 : _a$1.userAgent) && /iP(ad|hone|od)/.test(window.navigator.userAgent);
function resolveUnref(r2) {
return typeof r2 === "function" ? r2() : unref(r2);
}
function createFilterWrapper(filter, fn2) {
function wrapper(...args) {
return new Promise((resolve2, reject) => {
Promise.resolve(filter(() => fn2.apply(this, args), { fn: fn2, thisArg: this, args })).then(resolve2).catch(reject);
});
}
return wrapper;
}
const bypassFilter = (invoke) => {
return invoke();
};
function debounceFilter(ms2, options = {}) {
let timer;
let maxTimer;
let lastRejector = noop$1;
const _clearTimeout = (timer2) => {
clearTimeout(timer2);
lastRejector();
lastRejector = noop$1;
};
const filter = (invoke) => {
const duration = resolveUnref(ms2);
const maxDuration = resolveUnref(options.maxWait);
if (timer)
_clearTimeout(timer);
if (duration <= 0 || maxDuration !== void 0 && maxDuration <= 0) {
if (maxTimer) {
_clearTimeout(maxTimer);
maxTimer = null;
}
return Promise.resolve(invoke());
}
return new Promise((resolve2, reject) => {
lastRejector = options.rejectOnCancel ? reject : resolve2;
if (maxDuration && !maxTimer) {
maxTimer = setTimeout(() => {
if (timer)
_clearTimeout(timer);
maxTimer = null;
resolve2(invoke());
}, maxDuration);
}
timer = setTimeout(() => {
if (maxTimer)
_clearTimeout(maxTimer);
maxTimer = null;
resolve2(invoke());
}, duration);
});
};
return filter;
}
function pausableFilter(extendFilter = bypassFilter) {
const isActive = ref(true);
function pause() {
isActive.value = false;
}
function resume() {
isActive.value = true;
}
const eventFilter = (...args) => {
if (isActive.value)
extendFilter(...args);
};
return { isActive: readonly(isActive), pause, resume, eventFilter };
}
function identity(arg) {
return arg;
}
function tryOnScopeDispose(fn2) {
if (getCurrentScope()) {
onScopeDispose(fn2);
return true;
}
return false;
}
function useDebounceFn(fn2, ms2 = 200, options = {}) {
return createFilterWrapper(debounceFilter(ms2, options), fn2);
}
function refDebounced(value, ms2 = 200, options = {}) {
const debounced = ref(value.value);
const updater = useDebounceFn(() => {
debounced.value = value.value;
}, ms2, options);
watch(value, () => updater());
return debounced;
}
function resolveRef(r2) {
return typeof r2 === "function" ? computed(r2) : ref(r2);
}
function tryOnMounted(fn2, sync = true) {
if (getCurrentInstance())
onMounted(fn2);
else if (sync)
fn2();
else
nextTick(fn2);
}
function useTimeoutFn(cb, interval, options = {}) {
const {
immediate = true
} = options;
const isPending = ref(false);
let timer = null;
function clear2() {
if (timer) {
clearTimeout(timer);
timer = null;
}
}
function stop() {
isPending.value = false;
clear2();
}
function start(...args) {
clear2();
isPending.value = true;
timer = setTimeout(() => {
isPending.value = false;
timer = null;
cb(...args);
}, resolveUnref(interval));
}
if (immediate) {
isPending.value = true;
if (isClient)
start();
}
tryOnScopeDispose(stop);
return {
isPending: readonly(isPending),
start,
stop
};
}
function useToggle(initialValue = false, options = {}) {
const {
truthyValue = true,
falsyValue = false
} = options;
const valueIsRef = isRef(initialValue);
const _value = ref(initialValue);
function toggle(value) {
if (arguments.length) {
_value.value = value;
return _value.value;
} else {
const truthy = resolveUnref(truthyValue);
_value.value = _value.value === truthy ? resolveUnref(falsyValue) : truthy;
return _value.value;
}
}
if (valueIsRef)
return toggle;
else
return [_value, toggle];
}
var __getOwnPropSymbols$6$1 = Object.getOwnPropertySymbols;
var __hasOwnProp$6$1 = Object.prototype.hasOwnProperty;
var __propIsEnum$6$1 = Object.prototype.propertyIsEnumerable;
var __objRest$5 = (source, exclude) => {
var target = {};
for (var prop in source)
if (__hasOwnProp$6$1.call(source, prop) && exclude.indexOf(prop) < 0)
target[prop] = source[prop];
if (source != null && __getOwnPropSymbols$6$1)
for (var prop of __getOwnPropSymbols$6$1(source)) {
if (exclude.indexOf(prop) < 0 && __propIsEnum$6$1.call(source, prop))
target[prop] = source[prop];
}
return target;
};
function watchWithFilter(source, cb, options = {}) {
const _a2 = options, {
eventFilter = bypassFilter
} = _a2, watchOptions = __objRest$5(_a2, [
"eventFilter"
]);
return watch(source, createFilterWrapper(eventFilter, cb), watchOptions);
}
var __defProp$2$1 = Object.defineProperty;
var __defProps$2$1 = Object.defineProperties;
var __getOwnPropDescs$2$1 = Object.getOwnPropertyDescriptors;
var __getOwnPropSymbols$2$1 = Object.getOwnPropertySymbols;
var __hasOwnProp$2$1 = Object.prototype.hasOwnProperty;
var __propIsEnum$2$1 = Object.prototype.propertyIsEnumerable;
var __defNormalProp$2$1 = (obj, key, value) => key in obj ? __defProp$2$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues$2$1 = (a2, b3) => {
for (var prop in b3 || (b3 = {}))
if (__hasOwnProp$2$1.call(b3, prop))
__defNormalProp$2$1(a2, prop, b3[prop]);
if (__getOwnPropSymbols$2$1)
for (var prop of __getOwnPropSymbols$2$1(b3)) {
if (__propIsEnum$2$1.call(b3, prop))
__defNormalProp$2$1(a2, prop, b3[prop]);
}
return a2;
};
var __spreadProps$2$1 = (a2, b3) => __defProps$2$1(a2, __getOwnPropDescs$2$1(b3));
var __objRest$1$1 = (source, exclude) => {
var target = {};
for (var prop in source)
if (__hasOwnProp$2$1.call(source, prop) && exclude.indexOf(prop) < 0)
target[prop] = source[prop];
if (source != null && __getOwnPropSymbols$2$1)
for (var prop of __getOwnPropSymbols$2$1(source)) {
if (exclude.indexOf(prop) < 0 && __propIsEnum$2$1.call(source, prop))
target[prop] = source[prop];
}
return target;
};
function watchPausable(source, cb, options = {}) {
const _a2 = options, {
eventFilter: filter
} = _a2, watchOptions = __objRest$1$1(_a2, [
"eventFilter"
]);
const { eventFilter, pause, resume, isActive } = pausableFilter(filter);
const stop = watchWithFilter(source, cb, __spreadProps$2$1(__spreadValues$2$1({}, watchOptions), {
eventFilter
}));
return { stop, pause, resume, isActive };
}
function unrefElement(elRef) {
var _a2;
const plain = resolveUnref(elRef);
return (_a2 = plain == null ? void 0 : plain.$el) != null ? _a2 : plain;
}
const defaultWindow = isClient ? window : void 0;
const defaultDocument = isClient ? window.document : void 0;
const defaultNavigator = isClient ? window.navigator : void 0;
function useEventListener(...args) {
let target;
let events;
let listeners;
let options;
if (isString(args[0]) || Array.isArray(args[0])) {
[events, listeners, options] = args;
target = defaultWindow;
} else {
[target, events, listeners, options] = args;
}
if (!target)
return noop$1;
if (!Array.isArray(events))
events = [events];
if (!Array.isArray(listeners))
listeners = [listeners];
const cleanups = [];
const cleanup = () => {
cleanups.forEach((fn2) => fn2());
cleanups.length = 0;
};
const register = (el2, event, listener, options2) => {
el2.addEventListener(event, listener, options2);
return () => el2.removeEventListener(event, listener, options2);
};
const stopWatch = watch(() => [unrefElement(target), resolveUnref(options)], ([el2, options2]) => {
cleanup();
if (!el2)
return;
cleanups.push(...events.flatMap((event) => {
return listeners.map((listener) => register(el2, event, listener, options2));
}));
}, { immediate: true, flush: "post" });
const stop = () => {
stopWatch();
cleanup();
};
tryOnScopeDispose(stop);
return stop;
}
let _iOSWorkaround = false;
function onClickOutside(target, handler, options = {}) {
const { window: window2 = defaultWindow, ignore = [], capture = true, detectIframe = false } = options;
if (!window2)
return;
if (isIOS && !_iOSWorkaround) {
_iOSWorkaround = true;
Array.from(window2.document.body.children).forEach((el2) => el2.addEventListener("click", noop$1));
}
let shouldListen = true;
const shouldIgnore = (event) => {
return ignore.some((target2) => {
if (typeof target2 === "string") {
return Array.from(window2.document.querySelectorAll(target2)).some((el2) => el2 === event.target || event.composedPath().includes(el2));
} else {
const el2 = unrefElement(target2);
return el2 && (event.target === el2 || event.composedPath().includes(el2));
}
});
};
const listener = (event) => {
const el2 = unrefElement(target);
if (!el2 || el2 === event.target || event.composedPath().includes(el2))
return;
if (event.detail === 0)
shouldListen = !shouldIgnore(event);
if (!shouldListen) {
shouldListen = true;
return;
}
handler(event);
};
const cleanup = [
useEventListener(window2, "click", listener, { passive: true, capture }),
useEventListener(window2, "pointerdown", (e2) => {
const el2 = unrefElement(target);
if (el2)
shouldListen = !e2.composedPath().includes(el2) && !shouldIgnore(e2);
}, { passive: true }),
detectIframe && useEventListener(window2, "blur", (event) => {
var _a2;
const el2 = unrefElement(target);
if (((_a2 = window2.document.activeElement) == null ? void 0 : _a2.tagName) === "IFRAME" && !(el2 == null ? void 0 : el2.contains(window2.document.activeElement)))
handler(event);
})
].filter(Boolean);
const stop = () => cleanup.forEach((fn2) => fn2());
return stop;
}
function useSupported(callback, sync = false) {
const isSupported2 = ref();
const update2 = () => isSupported2.value = Boolean(callback());
update2();
tryOnMounted(update2, sync);
return isSupported2;
}
function useMediaQuery(query, options = {}) {
const { window: window2 = defaultWindow } = options;
const isSupported2 = useSupported(() => window2 && "matchMedia" in window2 && typeof window2.matchMedia === "function");
let mediaQuery;
const matches2 = ref(false);
const cleanup = () => {
if (!mediaQuery)
return;
if ("removeEventListener" in mediaQuery)
mediaQuery.removeEventListener("change", update2);
else
mediaQuery.removeListener(update2);
};
const update2 = () => {
if (!isSupported2.value)
return;
cleanup();
mediaQuery = window2.matchMedia(resolveRef(query).value);
matches2.value = mediaQuery.matches;
if ("addEventListener" in mediaQuery)
mediaQuery.addEventListener("change", update2);
else
mediaQuery.addListener(update2);
};
watchEffect(update2);
tryOnScopeDispose(() => cleanup());
return matches2;
}
function useClipboard(options = {}) {
const {
navigator: navigator2 = defaultNavigator,
read: read2 = false,
source,
copiedDuring = 1500,
legacy = false
} = options;
const events = ["copy", "cut"];
const isClipboardApiSupported = useSupported(() => navigator2 && "clipboard" in navigator2);
const isSupported2 = computed(() => isClipboardApiSupported.value || legacy);
const text2 = ref("");
const copied = ref(false);
const timeout = useTimeoutFn(() => copied.value = false, copiedDuring);
function updateText() {
if (isClipboardApiSupported.value) {
navigator2.clipboard.readText().then((value) => {
text2.value = value;
});
} else {
text2.value = legacyRead();
}
}
if (isSupported2.value && read2) {
for (const event of events)
useEventListener(event, updateText);
}
async function copy(value = resolveUnref(source)) {
if (isSupported2.value && value != null) {
if (isClipboardApiSupported.value)
await navigator2.clipboard.writeText(value);
else
legacyCopy(value);
text2.value = value;
copied.value = true;
timeout.start();
}
}
function legacyCopy(value) {
const ta2 = document.createElement("textarea");
ta2.value = value != null ? value : "";
ta2.style.position = "absolute";
ta2.style.opacity = "0";
document.body.appendChild(ta2);
ta2.select();
document.execCommand("copy");
ta2.remove();
}
function legacyRead() {
var _a2, _b, _c2;
return (_c2 = (_b = (_a2 = document == null ? void 0 : document.getSelection) == null ? void 0 : _a2.call(document)) == null ? void 0 : _b.toString()) != null ? _c2 : "";
}
return {
isSupported: isSupported2,
text: text2,
copied,
copy
};
}
const _global = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
const globalKey = "__vueuse_ssr_handlers__";
_global[globalKey] = _global[globalKey] || {};
const handlers = _global[globalKey];
function getSSRHandler(key, fallback) {
return handlers[key] || fallback;
}
function guessSerializerType(rawInit) {
return rawInit == null ? "any" : rawInit instanceof Set ? "set" : rawInit instanceof Map ? "map" : rawInit instanceof Date ? "date" : typeof rawInit === "boolean" ? "boolean" : typeof rawInit === "string" ? "string" : typeof rawInit === "object" ? "object" : !Number.isNaN(rawInit) ? "number" : "any";
}
var __defProp$k = Object.defineProperty;
var __getOwnPropSymbols$m = Object.getOwnPropertySymbols;
var __hasOwnProp$m = Object.prototype.hasOwnProperty;
var __propIsEnum$m = Object.prototype.propertyIsEnumerable;
var __defNormalProp$k = (obj, key, value) => key in obj ? __defProp$k(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues$k = (a2, b3) => {
for (var prop in b3 || (b3 = {}))
if (__hasOwnProp$m.call(b3, prop))
__defNormalProp$k(a2, prop, b3[prop]);
if (__getOwnPropSymbols$m)
for (var prop of __getOwnPropSymbols$m(b3)) {
if (__propIsEnum$m.call(b3, prop))
__defNormalProp$k(a2, prop, b3[prop]);
}
return a2;
};
const StorageSerializers = {
boolean: {
read: (v2) => v2 === "true",
write: (v2) => String(v2)
},
object: {
read: (v2) => JSON.parse(v2),
write: (v2) => JSON.stringify(v2)
},
number: {
read: (v2) => Number.parseFloat(v2),
write: (v2) => String(v2)
},
any: {
read: (v2) => v2,
write: (v2) => String(v2)
},
string: {
read: (v2) => v2,
write: (v2) => String(v2)
},
map: {
read: (v2) => new Map(JSON.parse(v2)),
write: (v2) => JSON.stringify(Array.from(v2.entries()))
},
set: {
read: (v2) => new Set(JSON.parse(v2)),
write: (v2) => JSON.stringify(Array.from(v2))
},
date: {
read: (v2) => new Date(v2),
write: (v2) => v2.toISOString()
}
};
const customStorageEventName = "vueuse-storage";
function useStorage(key, defaults2, storage2, options = {}) {
var _a2;
const {
flush: flush2 = "pre",
deep = true,
listenToStorageChanges = true,
writeDefaults = true,
mergeDefaults = false,
shallow,
window: window2 = defaultWindow,
eventFilter,
onError = (e2) => {
console.error(e2);
}
} = options;
const data = (shallow ? shallowRef : ref)(defaults2);
if (!storage2) {
try {
storage2 = getSSRHandler("getDefaultStorage", () => {
var _a22;
return (_a22 = defaultWindow) == null ? void 0 : _a22.localStorage;
})();
} catch (e2) {
onError(e2);
}
}
if (!storage2)
return data;
const rawInit = resolveUnref(defaults2);
const type = guessSerializerType(rawInit);
const serializer = (_a2 = options.serializer) != null ? _a2 : StorageSerializers[type];
const { pause: pauseWatch, resume: resumeWatch } = watchPausable(data, () => write(data.value), { flush: flush2, deep, eventFilter });
if (window2 && listenToStorageChanges) {
useEventListener(window2, "storage", update2);
useEventListener(window2, customStorageEventName, updateFromCustomEvent);
}
update2();
return data;
function write(v2) {
try {
if (v2 == null) {
storage2.removeItem(key);
} else {
const serialized = serializer.write(v2);
const oldValue = storage2.getItem(key);
if (oldValue !== serialized) {
storage2.setItem(key, serialized);
if (window2) {
window2.dispatchEvent(new CustomEvent(customStorageEventName, {
detail: {
key,
oldValue,
newValue: serialized,
storageArea: storage2
}
}));
}
}
}
} catch (e2) {
onError(e2);
}
}
function read2(event) {
const rawValue = event ? event.newValue : storage2.getItem(key);
if (rawValue == null) {
if (writeDefaults && rawInit !== null)
storage2.setItem(key, serializer.write(rawInit));
return rawInit;
} else if (!event && mergeDefaults) {
const value = serializer.read(rawValue);
if (isFunction(mergeDefaults))
return mergeDefaults(value, rawInit);
else if (type === "object" && !Array.isArray(value))
return __spreadValues$k(__spreadValues$k({}, rawInit), value);
return value;
} else if (typeof rawValue !== "string") {
return rawValue;
} else {
return serializer.read(rawValue);
}
}
function updateFromCustomEvent(event) {
update2(event.detail);
}
function update2(event) {
if (event && event.storageArea !== storage2)
return;
if (event && event.key == null) {
data.value = rawInit;
return;
}
if (event && event.key !== key)
return;
pauseWatch();
try {
data.value = read2(event);
} catch (e2) {
onError(e2);
} finally {
if (event)
nextTick(resumeWatch);
else
resumeWatch();
}
}
}
function usePreferredDark(options) {
return useMediaQuery("(prefers-color-scheme: dark)", options);
}
var __defProp$j = Object.defineProperty;
var __getOwnPropSymbols$l = Object.getOwnPropertySymbols;
var __hasOwnProp$l = Object.prototype.hasOwnProperty;
var __propIsEnum$l = Object.prototype.propertyIsEnumerable;
var __defNormalProp$j = (obj, key, value) => key in obj ? __defProp$j(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues$j = (a2, b3) => {
for (var prop in b3 || (b3 = {}))
if (__hasOwnProp$l.call(b3, prop))
__defNormalProp$j(a2, prop, b3[prop]);
if (__getOwnPropSymbols$l)
for (var prop of __getOwnPropSymbols$l(b3)) {
if (__propIsEnum$l.call(b3, prop))
__defNormalProp$j(a2, prop, b3[prop]);
}
return a2;
};
function useColorMode(options = {}) {
const {
selector = "html",
attribute = "class",
initialValue = "auto",
window: window2 = defaultWindow,
storage: storage2,
storageKey = "vueuse-color-scheme",
listenToStorageChanges = true,
storageRef,
emitAuto
} = options;
const modes = __spreadValues$j({
auto: "",
light: "light",
dark: "dark"
}, options.modes || {});
const preferredDark = usePreferredDark({ window: window2 });
const preferredMode = computed(() => preferredDark.value ? "dark" : "light");
const store = storageRef || (storageKey == null ? ref(initialValue) : useStorage(storageKey, initialValue, storage2, { window: window2, listenToStorageChanges }));
const state = computed({
get() {
return store.value === "auto" && !emitAuto ? preferredMode.value : store.value;
},
set(v2) {
store.value = v2;
}
});
const updateHTMLAttrs = getSSRHandler("updateHTMLAttrs", (selector2, attribute2, value) => {
const el2 = window2 == null ? void 0 : window2.document.querySelector(selector2);
if (!el2)
return;
if (attribute2 === "class") {
const current = value.split(/\s/g);
Object.values(modes).flatMap((i2) => (i2 || "").split(/\s/g)).filter(Boolean).forEach((v2) => {
if (current.includes(v2))
el2.classList.add(v2);
else
el2.classList.remove(v2);
});
} else {
el2.setAttribute(attribute2, value);
}
});
function defaultOnChanged(mode) {
var _a2;
const resolvedMode = mode === "auto" ? preferredMode.value : mode;
updateHTMLAttrs(selector, attribute, (_a2 = modes[resolvedMode]) != null ? _a2 : resolvedMode);
}
function onChanged(mode) {
if (options.onChanged)
options.onChanged(mode, defaultOnChanged);
else
defaultOnChanged(mode);
}
watch(state, onChanged, { flush: "post", immediate: true });
if (emitAuto)
watch(preferredMode, () => onChanged(state.value), { flush: "post" });
tryOnMounted(() => onChanged(state.value));
return state;
}
var __defProp$i = Object.defineProperty;
var __defProps$7 = Object.defineProperties;
var __getOwnPropDescs$7 = Object.getOwnPropertyDescriptors;
var __getOwnPropSymbols$k = Object.getOwnPropertySymbols;
var __hasOwnProp$k = Object.prototype.hasOwnProperty;
var __propIsEnum$k = Object.prototype.propertyIsEnumerable;
var __defNormalProp$i = (obj, key, value) => key in obj ? __defProp$i(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues$i = (a2, b3) => {
for (var prop in b3 || (b3 = {}))
if (__hasOwnProp$k.call(b3, prop))
__defNormalProp$i(a2, prop, b3[prop]);
if (__getOwnPropSymbols$k)
for (var prop of __getOwnPropSymbols$k(b3)) {
if (__propIsEnum$k.call(b3, prop))
__defNormalProp$i(a2, prop, b3[prop]);
}
return a2;
};
var __spreadProps$7 = (a2, b3) => __defProps$7(a2, __getOwnPropDescs$7(b3));
function useDark(options = {}) {
const {
valueDark = "dark",
valueLight = "",
window: window2 = defaultWindow
} = options;
const mode = useColorMode(__spreadProps$7(__spreadValues$i({}, options), {
onChanged: (mode2, defaultHandler) => {
var _a2;
if (options.onChanged)
(_a2 = options.onChanged) == null ? void 0 : _a2.call(options, mode2 === "dark");
else
defaultHandler(mode2);
},
modes: {
dark: valueDark,
light: valueLight
}
}));
const preferredDark = usePreferredDark({ window: window2 });
const isDark = computed({
get() {
return mode.value === "dark";
},
set(v2) {
if (v2 === preferredDark.value)
mode.value = "auto";
else
mode.value = v2 ? "dark" : "light";
}
});
return isDark;
}
var __getOwnPropSymbols$g = Object.getOwnPropertySymbols;
var __hasOwnProp$g = Object.prototype.hasOwnProperty;
var __propIsEnum$g = Object.prototype.propertyIsEnumerable;
var __objRest$2 = (source, exclude) => {
var target = {};
for (var prop in source)
if (__hasOwnProp$g.call(source, prop) && exclude.indexOf(prop) < 0)
target[prop] = source[prop];
if (source != null && __getOwnPropSymbols$g)
for (var prop of __getOwnPropSymbols$g(source)) {
if (exclude.indexOf(prop) < 0 && __propIsEnum$g.call(source, prop))
target[prop] = source[prop];
}
return target;
};
function useResizeObserver(target, callback, options = {}) {
const _a2 = options, { window: window2 = defaultWindow } = _a2, observerOptions = __objRest$2(_a2, ["window"]);
let observer;
const isSupported2 = useSupported(() => window2 && "ResizeObserver" in window2);
const cleanup = () => {
if (observer) {
observer.disconnect();
observer = void 0;
}
};
const stopWatch = watch(() => unrefElement(target), (el2) => {
cleanup();
if (isSupported2.value && window2 && el2) {
observer = new ResizeObserver(callback);
observer.observe(el2, observerOptions);
}
}, { immediate: true, flush: "post" });
const stop = () => {
cleanup();
stopWatch();
};
tryOnScopeDispose(stop);
return {
isSupported: isSupported2,
stop
};
}
function useFocus(target, options = {}) {
const { initialValue = false } = options;
const innerFocused = ref(false);
const targetElement = computed(() => unrefElement(target));
useEventListener(targetElement, "focus", () => innerFocused.value = true);
useEventListener(targetElement, "blur", () => innerFocused.value = false);
const focused = computed({
get: () => innerFocused.value,
set(value) {
var _a2, _b;
if (!value && innerFocused.value)
(_a2 = targetElement.value) == null ? void 0 : _a2.blur();
else if (value && !innerFocused.value)
(_b = targetElement.value) == null ? void 0 : _b.focus();
}
});
watch(targetElement, () => {
focused.value = initialValue;
}, { immediate: true, flush: "post" });
return { focused };
}
var __getOwnPropSymbols$8 = Object.getOwnPropertySymbols;
var __hasOwnProp$8 = Object.prototype.hasOwnProperty;
var __propIsEnum$8 = Object.prototype.propertyIsEnumerable;
var __objRest$1 = (source, exclude) => {
var target = {};
for (var prop in source)
if (__hasOwnProp$8.call(source, prop) && exclude.indexOf(prop) < 0)
target[prop] = source[prop];
if (source != null && __getOwnPropSymbols$8)
for (var prop of __getOwnPropSymbols$8(source)) {
if (exclude.indexOf(prop) < 0 && __propIsEnum$8.call(source, prop))
target[prop] = source[prop];
}
return target;
};
function useMutationObserver(target, callback, options = {}) {
const _a2 = options, { window: window2 = defaultWindow } = _a2, mutationOptions = __objRest$1(_a2, ["window"]);
let observer;
const isSupported2 = useSupported(() => window2 && "MutationObserver" in window2);
const cleanup = () => {
if (observer) {
observer.disconnect();
observer = void 0;
}
};
const stopWatch = watch(() => unrefElement(target), (el2) => {
cleanup();
if (isSupported2.value && window2 && el2) {
observer = new MutationObserver(callback);
observer.observe(el2, mutationOptions);
}
}, { immediate: true });
const stop = () => {
cleanup();
stopWatch();
};
tryOnScopeDispose(stop);
return {
isSupported: isSupported2,
stop
};
}
var SwipeDirection;
(function(SwipeDirection2) {
SwipeDirection2["UP"] = "UP";
SwipeDirection2["RIGHT"] = "RIGHT";
SwipeDirection2["DOWN"] = "DOWN";
SwipeDirection2["LEFT"] = "LEFT";
SwipeDirection2["NONE"] = "NONE";
})(SwipeDirection || (SwipeDirection = {}));
function useTitle(newTitle = null, options = {}) {
var _a2, _b;
const {
document: document2 = defaultDocument
} = options;
const title = resolveRef((_a2 = newTitle != null ? newTitle : document2 == null ? void 0 : document2.title) != null ? _a2 : null);
const isReadonly2 = newTitle && isFunction(newTitle);
function format(t2) {
if (!("titleTemplate" in options))
return t2;
const template = options.titleTemplate || "%s";
return isFunction(template) ? template(t2) : unref(template).replace(/%s/g, t2);
}
watch(title, (t2, o) => {
if (t2 !== o && document2)
document2.title = format(isString(t2) ? t2 : "");
}, { immediate: true });
if (options.observe && !options.titleTemplate && document2 && !isReadonly2) {
useMutationObserver((_b = document2.head) == null ? void 0 : _b.querySelector("title"), () => {
if (document2 && document2.title !== title.value)
title.value = format(document2.title);
}, { childList: true });
}
return title;
}
var __defProp = Object.defineProperty;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
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 __spreadValues = (a2, b3) => {
for (var prop in b3 || (b3 = {}))
if (__hasOwnProp.call(b3, prop))
__defNormalProp(a2, prop, b3[prop]);
if (__getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(b3)) {
if (__propIsEnum.call(b3, prop))
__defNormalProp(a2, prop, b3[prop]);
}
return a2;
};
const _TransitionPresets = {
easeInSine: [0.12, 0, 0.39, 0],
easeOutSine: [0.61, 1, 0.88, 1],
easeInOutSine: [0.37, 0, 0.63, 1],
easeInQuad: [0.11, 0, 0.5, 0],
easeOutQuad: [0.5, 1, 0.89, 1],
easeInOutQuad: [0.45, 0, 0.55, 1],
easeInCubic: [0.32, 0, 0.67, 0],
easeOutCubic: [0.33, 1, 0.68, 1],
easeInOutCubic: [0.65, 0, 0.35, 1],
easeInQuart: [0.5, 0, 0.75, 0],
easeOutQuart: [0.25, 1, 0.5, 1],
easeInOutQuart: [0.76, 0, 0.24, 1],
easeInQuint: [0.64, 0, 0.78, 0],
easeOutQuint: [0.22, 1, 0.36, 1],
easeInOutQuint: [0.83, 0, 0.17, 1],
easeInExpo: [0.7, 0, 0.84, 0],
easeOutExpo: [0.16, 1, 0.3, 1],
easeInOutExpo: [0.87, 0, 0.13, 1],
easeInCirc: [0.55, 0, 1, 0.45],
easeOutCirc: [0, 0.55, 0.45, 1],
easeInOutCirc: [0.85, 0, 0.15, 1],
easeInBack: [0.36, 0, 0.66, -0.56],
easeOutBack: [0.34, 1.56, 0.64, 1],
easeInOutBack: [0.68, -0.6, 0.32, 1.6]
};
__spreadValues({
linear: identity
}, _TransitionPresets);
const matchName = /^[a-z0-9]+(-[a-z0-9]+)*$/;
const iconDefaults = Object.freeze({
left: 0,
top: 0,
width: 16,
height: 16,
rotate: 0,
vFlip: false,
hFlip: false
});
function fullIcon(data) {
return { ...iconDefaults, ...data };
}
const stringToIcon = (value, validate, allowSimpleName, provider = "") => {
const colonSeparated = value.split(":");
if (value.slice(0, 1) === "@") {
if (colonSeparated.length < 2 || colonSeparated.length > 3) {
return null;
}
provider = colonSeparated.shift().slice(1);
}
if (colonSeparated.length > 3 || !colonSeparated.length) {
return null;
}
if (colonSeparated.length > 1) {
const name2 = colonSeparated.pop();
const prefix = colonSeparated.pop();
const result = {
provider: colonSeparated.length > 0 ? colonSeparated[0] : provider,
prefix,
name: name2
};
return validate && !validateIcon(result) ? null : result;
}
const name = colonSeparated[0];
const dashSeparated = name.split("-");
if (dashSeparated.length > 1) {
const result = {
provider,
prefix: dashSeparated.shift(),
name: dashSeparated.join("-")
};
return validate && !validateIcon(result) ? null : result;
}
if (allowSimpleName && provider === "") {
const result = {
provider,
prefix: "",
name
};
return validate && !validateIcon(result, allowSimpleName) ? null : result;
}
return null;
};
const validateIcon = (icon, allowSimpleName) => {
if (!icon) {
return false;
}
return !!((icon.provider === "" || icon.provider.match(matchName)) && (allowSimpleName && icon.prefix === "" || icon.prefix.match(matchName)) && icon.name.match(matchName));
};
function mergeIconData(icon, alias) {
const result = { ...icon };
for (const key in iconDefaults) {
const prop = key;
if (alias[prop] !== void 0) {
const value = alias[prop];
if (result[prop] === void 0) {
result[prop] = value;
continue;
}
switch (prop) {
case "rotate":
result[prop] = (result[prop] + value) % 4;
break;
case "hFlip":
case "vFlip":
result[prop] = value !== result[prop];
break;
default:
result[prop] = value;
}
}
}
return result;
}
function getIconData$1(data, name, full = false) {
function getIcon(name2, iteration) {
if (data.icons[name2] !== void 0) {
return Object.assign({}, data.icons[name2]);
}
if (iteration > 5) {
return null;
}
const aliases = data.aliases;
if (aliases && aliases[name2] !== void 0) {
const item = aliases[name2];
const result2 = getIcon(item.parent, iteration + 1);
if (result2) {
return mergeIconData(result2, item);
}
return result2;
}
const chars = data.chars;
if (!iteration && chars && chars[name2] !== void 0) {
return getIcon(chars[name2], iteration + 1);
}
return null;
}
const result = getIcon(name, 0);
if (result) {
for (const key in iconDefaults) {
if (result[key] === void 0 && data[key] !== void 0) {
result[key] = data[key];
}
}
}
return result && full ? fullIcon(result) : result;
}
function isVariation(item) {
for (const key in iconDefaults) {
if (item[key] !== void 0) {
return true;
}
}
return false;
}
function parseIconSet(data, callback, options) {
options = options || {};
const names = [];
if (typeof data !== "object" || typeof data.icons !== "object") {
return names;
}
if (data.not_found instanceof Array) {
data.not_found.forEach((name) => {
callback(name, null);
names.push(name);
});
}
const icons = data.icons;
Object.keys(icons).forEach((name) => {
const iconData = getIconData$1(data, name, true);
if (iconData) {
callback(name, iconData);
names.push(name);
}
});
const parseAliases = options.aliases || "all";
if (parseAliases !== "none" && typeof data.aliases === "object") {
const aliases = data.aliases;
Object.keys(aliases).forEach((name) => {
if (parseAliases === "variations" && isVariation(aliases[name])) {
return;
}
const iconData = getIconData$1(data, name, true);
if (iconData) {
callback(name, iconData);
names.push(name);
}
});
}
return names;
}
const optionalProperties = {
provider: "string",
aliases: "object",
not_found: "object"
};
for (const prop in iconDefaults) {
optionalProperties[prop] = typeof iconDefaults[prop];
}
function quicklyValidateIconSet(obj) {
if (typeof obj !== "object" || obj === null) {
return null;
}
const data = obj;
if (typeof data.prefix !== "string" || !obj.icons || typeof obj.icons !== "object") {
return null;
}
for (const prop in optionalProperties) {
if (obj[prop] !== void 0 && typeof obj[prop] !== optionalProperties[prop]) {
return null;
}
}
const icons = data.icons;
for (const name in icons) {
const icon = icons[name];
if (!name.match(matchName) || typeof icon.body !== "string") {
return null;
}
for (const prop in iconDefaults) {
if (icon[prop] !== void 0 && typeof icon[prop] !== typeof iconDefaults[prop]) {
return null;
}
}
}
const aliases = data.aliases;
if (aliases) {
for (const name in aliases) {
const icon = aliases[name];
const parent = icon.parent;
if (!name.match(matchName) || typeof parent !== "string" || !icons[parent] && !aliases[parent]) {
return null;
}
for (const prop in iconDefaults) {
if (icon[prop] !== void 0 && typeof icon[prop] !== typeof iconDefaults[prop]) {
return null;
}
}
}
}
return data;
}
const storageVersion = 1;
let storage$1 = /* @__PURE__ */ Object.create(null);
try {
const w2 = window || self;
if (w2 && w2._iconifyStorage.version === storageVersion) {
storage$1 = w2._iconifyStorage.storage;
}
} catch (err) {
}
function newStorage(provider, prefix) {
return {
provider,
prefix,
icons: /* @__PURE__ */ Object.create(null),
missing: /* @__PURE__ */ Object.create(null)
};
}
function getStorage(provider, prefix) {
if (storage$1[provider] === void 0) {
storage$1[provider] = /* @__PURE__ */ Object.create(null);
}
const providerStorage = storage$1[provider];
if (providerStorage[prefix] === void 0) {
providerStorage[prefix] = newStorage(provider, prefix);
}
return providerStorage[prefix];
}
function addIconSet(storage2, data) {
if (!quicklyValidateIconSet(data)) {
return [];
}
const t2 = Date.now();
return parseIconSet(data, (name, icon) => {
if (icon) {
storage2.icons[name] = icon;
} else {
storage2.missing[name] = t2;
}
});
}
function addIconToStorage(storage2, name, icon) {
try {
if (typeof icon.body === "string") {
storage2.icons[name] = Object.freeze(fullIcon(icon));
return true;
}
} catch (err) {
}
return false;
}
function getIconFromStorage(storage2, name) {
const value = storage2.icons[name];
return value === void 0 ? null : value;
}
let simpleNames = false;
function allowSimpleNames(allow) {
if (typeof allow === "boolean") {
simpleNames = allow;
}
return simpleNames;
}
function getIconData(name) {
const icon = typeof name === "string" ? stringToIcon(name, true, simpleNames) : name;
return icon ? getIconFromStorage(getStorage(icon.provider, icon.prefix), icon.name) : null;
}
function addIcon(name, data) {
const icon = stringToIcon(name, true, simpleNames);
if (!icon) {
return false;
}
const storage2 = getStorage(icon.provider, icon.prefix);
return addIconToStorage(storage2, icon.name, data);
}
function addCollection(data, provider) {
if (typeof data !== "object") {
return false;
}
if (typeof provider !== "string") {
provider = typeof data.provider === "string" ? data.provider : "";
}
if (simpleNames && provider === "" && (typeof data.prefix !== "string" || data.prefix === "")) {
let added = false;
if (quicklyValidateIconSet(data)) {
data.prefix = "";
parseIconSet(data, (name, icon) => {
if (icon && addIcon(name, icon)) {
added = true;
}
});
}
return added;
}
if (typeof data.prefix !== "string" || !validateIcon({
provider,
prefix: data.prefix,
name: "a"
})) {
return false;
}
const storage2 = getStorage(provider, data.prefix);
return !!addIconSet(storage2, data);
}
const defaults = Object.freeze({
inline: false,
width: null,
height: null,
hAlign: "center",
vAlign: "middle",
slice: false,
hFlip: false,
vFlip: false,
rotate: 0
});
function mergeCustomisations(defaults2, item) {
const result = {};
for (const key in defaults2) {
const attr2 = key;
result[attr2] = defaults2[attr2];
if (item[attr2] === void 0) {
continue;
}
const value = item[attr2];
switch (attr2) {
case "inline":
case "slice":
if (typeof value === "boolean") {
result[attr2] = value;
}
break;
case "hFlip":
case "vFlip":
if (value === true) {
result[attr2] = !result[attr2];
}
break;
case "hAlign":
case "vAlign":
if (typeof value === "string" && value !== "") {
result[attr2] = value;
}
break;
case "width":
case "height":
if (typeof value === "string" && value !== "" || typeof value === "number" && value || value === null) {
result[attr2] = value;
}
break;
case "rotate":
if (typeof value === "number") {
result[attr2] += value;
}
break;
}
}
return result;
}
const unitsSplit = /(-?[0-9.]*[0-9]+[0-9.]*)/g;
const unitsTest = /^-?[0-9.]*[0-9]+[0-9.]*$/g;
function calculateSize(size2, ratio, precision) {
if (ratio === 1) {
return size2;
}
precision = precision === void 0 ? 100 : precision;
if (typeof size2 === "number") {
return Math.ceil(size2 * ratio * precision) / precision;
}
if (typeof size2 !== "string") {
return size2;
}
const oldParts = size2.split(unitsSplit);
if (oldParts === null || !oldParts.length) {
return size2;
}
const newParts = [];
let code = oldParts.shift();
let isNumber = unitsTest.test(code);
while (true) {
if (isNumber) {
const num = parseFloat(code);
if (isNaN(num)) {
newParts.push(code);
} else {
newParts.push(Math.ceil(num * ratio * precision) / precision);
}
} else {
newParts.push(code);
}
code = oldParts.shift();
if (code === void 0) {
return newParts.join("");
}
isNumber = !isNumber;
}
}
function preserveAspectRatio(props) {
let result = "";
switch (props.hAlign) {
case "left":
result += "xMin";
break;
case "right":
result += "xMax";
break;
default:
result += "xMid";
}
switch (props.vAlign) {
case "top":
result += "YMin";
break;
case "bottom":
result += "YMax";
break;
default:
result += "YMid";
}
result += props.slice ? " slice" : " meet";
return result;
}
function iconToSVG(icon, customisations) {
const box = {
left: icon.left,
top: icon.top,
width: icon.width,
height: icon.height
};
let body = icon.body;
[icon, customisations].forEach((props) => {
const transformations = [];
const hFlip = props.hFlip;
const vFlip = props.vFlip;
let rotation = props.rotate;
if (hFlip) {
if (vFlip) {
rotation += 2;
} else {
transformations.push("translate(" + (box.width + box.left).toString() + " " + (0 - box.top).toString() + ")");
transformations.push("scale(-1 1)");
box.top = box.left = 0;
}
} else if (vFlip) {
transformations.push("translate(" + (0 - box.left).toString() + " " + (box.height + box.top).toString() + ")");
transformations.push("scale(1 -1)");
box.top = box.left = 0;
}
let tempValue;
if (rotation < 0) {
rotation -= Math.floor(rotation / 4) * 4;
}
rotation = rotation % 4;
switch (rotation) {
case 1:
tempValue = box.height / 2 + box.top;
transformations.unshift("rotate(90 " + tempValue.toString() + " " + tempValue.toString() + ")");
break;
case 2:
transformations.unshift("rotate(180 " + (box.width / 2 + box.left).toString() + " " + (box.height / 2 + box.top).toString() + ")");
break;
case 3:
tempValue = box.width / 2 + box.left;
transformations.unshift("rotate(-90 " + tempValue.toString() + " " + tempValue.toString() + ")");
break;
}
if (rotation % 2 === 1) {
if (box.left !== 0 || box.top !== 0) {
tempValue = box.left;
box.left = box.top;
box.top = tempValue;
}
if (box.width !== box.height) {
tempValue = box.width;
box.width = box.height;
box.height = tempValue;
}
}
if (transformations.length) {
body = '<g transform="' + transformations.join(" ") + '">' + body + "</g>";
}
});
let width, height;
if (customisations.width === null && customisations.height === null) {
height = "1em";
width = calculateSize(height, box.width / box.height);
} else if (customisations.width !== null && customisations.height !== null) {
width = customisations.width;
height = customisations.height;
} else if (customisations.height !== null) {
height = customisations.height;
width = calculateSize(height, box.width / box.height);
} else {
width = customisations.width;
height = calculateSize(width, box.height / box.width);
}
if (width === "auto") {
width = box.width;
}
if (height === "auto") {
height = box.height;
}
width = typeof width === "string" ? width : width.toString() + "";
height = typeof height === "string" ? height : height.toString() + "";
const result = {
attributes: {
width,
height,
preserveAspectRatio: preserveAspectRatio(customisations),
viewBox: box.left.toString() + " " + box.top.toString() + " " + box.width.toString() + " " + box.height.toString()
},
body
};
if (customisations.inline) {
result.inline = true;
}
return result;
}
const regex = /\sid="(\S+)"/g;
const randomPrefix = "IconifyId" + Date.now().toString(16) + (Math.random() * 16777216 | 0).toString(16);
let counter = 0;
function replaceIDs(body, prefix = randomPrefix) {
const ids = [];
let match;
while (match = regex.exec(body)) {
ids.push(match[1]);
}
if (!ids.length) {
return body;
}
ids.forEach((id2) => {
const newID = typeof prefix === "function" ? prefix(id2) : prefix + (counter++).toString();
const escapedID = id2.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
body = body.replace(new RegExp('([#;"])(' + escapedID + ')([")]|\\.[a-z])', "g"), "$1" + newID + "$3");
});
return body;
}
const storage = /* @__PURE__ */ Object.create(null);
function setAPIModule(provider, item) {
storage[provider] = item;
}
function getAPIModule(provider) {
return storage[provider] || storage[""];
}
function createAPIConfig(source) {
let resources;
if (typeof source.resources === "string") {
resources = [source.resources];
} else {
resources = source.resources;
if (!(resources instanceof Array) || !resources.length) {
return null;
}
}
const result = {
resources,
path: source.path === void 0 ? "/" : source.path,
maxURL: source.maxURL ? source.maxURL : 500,
rotate: source.rotate ? source.rotate : 750,
timeout: source.timeout ? source.timeout : 5e3,
random: source.random === true,
index: source.index ? source.index : 0,
dataAfterTimeout: source.dataAfterTimeout !== false
};
return result;
}
const configStorage = /* @__PURE__ */ Object.create(null);
const fallBackAPISources = [
"https://api.simplesvg.com",
"https://api.unisvg.com"
];
const fallBackAPI = [];
while (fallBackAPISources.length > 0) {
if (fallBackAPISources.length === 1) {
fallBackAPI.push(fallBackAPISources.shift());
} else {
if (Math.random() > 0.5) {
fallBackAPI.push(fallBackAPISources.shift());
} else {
fallBackAPI.push(fallBackAPISources.pop());
}
}
}
configStorage[""] = createAPIConfig({
resources: ["https://api.iconify.design"].concat(fallBackAPI)
});
function addAPIProvider(provider, customConfig) {
const config2 = createAPIConfig(customConfig);
if (config2 === null) {
return false;
}
configStorage[provider] = config2;
return true;
}
function getAPIConfig(provider) {
return configStorage[provider];
}
const mergeParams = (base, params) => {
let result = base, hasParams = result.indexOf("?") !== -1;
function paramToString(value) {
switch (typeof value) {
case "boolean":
return value ? "true" : "false";
case "number":
return encodeURIComponent(value);
case "string":
return encodeURIComponent(value);
default:
throw new Error("Invalid parameter");
}
}
Object.keys(params).forEach((key) => {
let value;
try {
value = paramToString(params[key]);
} catch (err) {
return;
}
result += (hasParams ? "&" : "?") + encodeURIComponent(key) + "=" + value;
hasParams = true;
});
return result;
};
const maxLengthCache = {};
const pathCache = {};
const detectFetch = () => {
let callback;
try {
callback = fetch;
if (typeof callback === "function") {
return callback;
}
} catch (err) {
}
return null;
};
let fetchModule = detectFetch();
function calculateMaxLength(provider, prefix) {
const config2 = getAPIConfig(provider);
if (!config2) {
return 0;
}
let result;
if (!config2.maxURL) {
result = 0;
} else {
let maxHostLength = 0;
config2.resources.forEach((item) => {
const host = item;
maxHostLength = Math.max(maxHostLength, host.length);
});
const url = mergeParams(prefix + ".json", {
icons: ""
});
result = config2.maxURL - maxHostLength - config2.path.length - url.length;
}
const cacheKey = provider + ":" + prefix;
pathCache[provider] = config2.path;
maxLengthCache[cacheKey] = result;
return result;
}
function shouldAbort(status) {
return status === 404;
}
const prepare = (provider, prefix, icons) => {
const results = [];
let maxLength = maxLengthCache[prefix];
if (maxLength === void 0) {
maxLength = calculateMaxLength(provider, prefix);
}
const type = "icons";
let item = {
type,
provider,
prefix,
icons: []
};
let length = 0;
icons.forEach((name, index2) => {
length += name.length + 1;
if (length >= maxLength && index2 > 0) {
results.push(item);
item = {
type,
provider,
prefix,
icons: []
};
length = name.length;
}
item.icons.push(name);
});
results.push(item);
return results;
};
function getPath(provider) {
if (typeof provider === "string") {
if (pathCache[provider] === void 0) {
const config2 = getAPIConfig(provider);
if (!config2) {
return "/";
}
pathCache[provider] = config2.path;
}
return pathCache[provider];
}
return "/";
}
const send = (host, params, callback) => {
if (!fetchModule) {
callback("abort", 424);
return;
}
let path = getPath(params.provider);
switch (params.type) {
case "icons": {
const prefix = params.prefix;
const icons = params.icons;
const iconsList = icons.join(",");
path += mergeParams(prefix + ".json", {
icons: iconsList
});
break;
}
case "custom": {
const uri = params.uri;
path += uri.slice(0, 1) === "/" ? uri.slice(1) : uri;
break;
}
default:
callback("abort", 400);
return;
}
let defaultError = 503;
fetchModule(host + path).then((response) => {
const status = response.status;
if (status !== 200) {
setTimeout(() => {
callback(shouldAbort(status) ? "abort" : "next", status);
});
return;
}
defaultError = 501;
return response.json();
}).then((data) => {
if (typeof data !== "object" || data === null) {
setTimeout(() => {
callback("next", defaultError);
});
return;
}
setTimeout(() => {
callback("success", data);
});
}).catch(() => {
callback("next", defaultError);
});
};
const fetchAPIModule = {
prepare,
send
};
function sortIcons(icons) {
const result = {
loaded: [],
missing: [],
pending: []
};
const storage2 = /* @__PURE__ */ Object.create(null);
icons.sort((a2, b3) => {
if (a2.provider !== b3.provider) {
return a2.provider.localeCompare(b3.provider);
}
if (a2.prefix !== b3.prefix) {
return a2.prefix.localeCompare(b3.prefix);
}
return a2.name.localeCompare(b3.name);
});
let lastIcon = {
provider: "",
prefix: "",
name: ""
};
icons.forEach((icon) => {
if (lastIcon.name === icon.name && lastIcon.prefix === icon.prefix && lastIcon.provider === icon.provider) {
return;
}
lastIcon = icon;
const provider = icon.provider;
const prefix = icon.prefix;
const name = icon.name;
if (storage2[provider] === void 0) {
storage2[provider] = /* @__PURE__ */ Object.create(null);
}
const providerStorage = storage2[provider];
if (providerStorage[prefix] === void 0) {
providerStorage[prefix] = getStorage(provider, prefix);
}
const localStorage2 = providerStorage[prefix];
let list;
if (localStorage2.icons[name] !== void 0) {
list = result.loaded;
} else if (prefix === "" || localStorage2.missing[name] !== void 0) {
list = result.missing;
} else {
list = result.pending;
}
const item = {
provider,
prefix,
name
};
list.push(item);
});
return result;
}
const callbacks = /* @__PURE__ */ Object.create(null);
const pendingUpdates = /* @__PURE__ */ Object.create(null);
function removeCallback(sources, id2) {
sources.forEach((source) => {
const provider = source.provider;
if (callbacks[provider] === void 0) {
return;
}
const providerCallbacks = callbacks[provider];
const prefix = source.prefix;
const items = providerCallbacks[prefix];
if (items) {
providerCallbacks[prefix] = items.filter((row) => row.id !== id2);
}
});
}
function updateCallbacks(provider, prefix) {
if (pendingUpdates[provider] === void 0) {
pendingUpdates[provider] = /* @__PURE__ */ Object.create(null);
}
const providerPendingUpdates = pendingUpdates[provider];
if (!providerPendingUpdates[prefix]) {
providerPendingUpdates[prefix] = true;
setTimeout(() => {
providerPendingUpdates[prefix] = false;
if (callbacks[provider] === void 0 || callbacks[provider][prefix] === void 0) {
return;
}
const items = callbacks[provider][prefix].slice(0);
if (!items.length) {
return;
}
const storage2 = getStorage(provider, prefix);
let hasPending = false;
items.forEach((item) => {
const icons = item.icons;
const oldLength = icons.pending.length;
icons.pending = icons.pending.filter((icon) => {
if (icon.prefix !== prefix) {
return true;
}
const name = icon.name;
if (storage2.icons[name] !== void 0) {
icons.loaded.push({
provider,
prefix,
name
});
} else if (storage2.missing[name] !== void 0) {
icons.missing.push({
provider,
prefix,
name
});
} else {
hasPending = true;
return true;
}
return false;
});
if (icons.pending.length !== oldLength) {
if (!hasPending) {
removeCallback([
{
provider,
prefix
}
], item.id);
}
item.callback(icons.loaded.slice(0), icons.missing.slice(0), icons.pending.slice(0), item.abort);
}
});
});
}
}
let idCounter = 0;
function storeCallback(callback, icons, pendingSources) {
const id2 = idCounter++;
const abort = removeCallback.bind(null, pendingSources, id2);
if (!icons.pending.length) {
return abort;
}
const item = {
id: id2,
icons,
callback,
abort
};
pendingSources.forEach((source) => {
const provider = source.provider;
const prefix = source.prefix;
if (callbacks[provider] === void 0) {
callbacks[provider] = /* @__PURE__ */ Object.create(null);
}
const providerCallbacks = callbacks[provider];
if (providerCallbacks[prefix] === void 0) {
providerCallbacks[prefix] = [];
}
providerCallbacks[prefix].push(item);
});
return abort;
}
function listToIcons(list, validate = true, simpleNames2 = false) {
const result = [];
list.forEach((item) => {
const icon = typeof item === "string" ? stringToIcon(item, false, simpleNames2) : item;
if (!validate || validateIcon(icon, simpleNames2)) {
result.push({
provider: icon.provider,
prefix: icon.prefix,
name: icon.name
});
}
});
return result;
}
var defaultConfig = {
resources: [],
index: 0,
timeout: 2e3,
rotate: 750,
random: false,
dataAfterTimeout: false
};
function sendQuery(config2, payload, query, done) {
const resourcesCount = config2.resources.length;
const startIndex = config2.random ? Math.floor(Math.random() * resourcesCount) : config2.index;
let resources;
if (config2.random) {
let list = config2.resources.slice(0);
resources = [];
while (list.length > 1) {
const nextIndex = Math.floor(Math.random() * list.length);
resources.push(list[nextIndex]);
list = list.slice(0, nextIndex).concat(list.slice(nextIndex + 1));
}
resources = resources.concat(list);
} else {
resources = config2.resources.slice(startIndex).concat(config2.resources.slice(0, startIndex));
}
const startTime = Date.now();
let status = "pending";
let queriesSent = 0;
let lastError;
let timer = null;
let queue2 = [];
let doneCallbacks = [];
if (typeof done === "function") {
doneCallbacks.push(done);
}
function resetTimer() {
if (timer) {
clearTimeout(timer);
timer = null;
}
}
function abort() {
if (status === "pending") {
status = "aborted";
}
resetTimer();
queue2.forEach((item) => {
if (item.status === "pending") {
item.status = "aborted";
}
});
queue2 = [];
}
function subscribe(callback, overwrite) {
if (overwrite) {
doneCallbacks = [];
}
if (typeof callback === "function") {
doneCallbacks.push(callback);
}
}
function getQueryStatus() {
return {
startTime,
payload,
status,
queriesSent,
queriesPending: queue2.length,
subscribe,
abort
};
}
function failQuery() {
status = "failed";
doneCallbacks.forEach((callback) => {
callback(void 0, lastError);
});
}
function clearQueue() {
queue2.forEach((item) => {
if (item.status === "pending") {
item.status = "aborted";
}
});
queue2 = [];
}
function moduleResponse(item, response, data) {
const isError = response !== "success";
queue2 = queue2.filter((queued) => queued !== item);
switch (status) {
case "pending":
break;
case "failed":
if (isError || !config2.dataAfterTimeout) {
return;
}
break;
default:
return;
}
if (response === "abort") {
lastError = data;
failQuery();
return;
}
if (isError) {
lastError = data;
if (!queue2.length) {
if (!resources.length) {
failQuery();
} else {
execNext();
}
}
return;
}
resetTimer();
clearQueue();
if (!config2.random) {
const index2 = config2.resources.indexOf(item.resource);
if (index2 !== -1 && index2 !== config2.index) {
config2.index = index2;
}
}
status = "completed";
doneCallbacks.forEach((callback) => {
callback(data);
});
}
function execNext() {
if (status !== "pending") {
return;
}
resetTimer();
const resource = resources.shift();
if (resource === void 0) {
if (queue2.length) {
timer = setTimeout(() => {
resetTimer();
if (status === "pending") {
clearQueue();
failQuery();
}
}, config2.timeout);
return;
}
failQuery();
return;
}
const item = {
status: "pending",
resource,
callback: (status2, data) => {
moduleResponse(item, status2, data);
}
};
queue2.push(item);
queriesSent++;
timer = setTimeout(execNext, config2.rotate);
query(resource, payload, item.callback);
}
setTimeout(execNext);
return getQueryStatus;
}
function setConfig(config2) {
if (typeof config2 !== "object" || typeof config2.resources !== "object" || !(config2.resources instanceof Array) || !config2.resources.length) {
throw new Error("Invalid Reduncancy configuration");
}
const newConfig = /* @__PURE__ */ Object.create(null);
let key;
for (key in defaultConfig) {
if (config2[key] !== void 0) {
newConfig[key] = config2[key];
} else {
newConfig[key] = defaultConfig[key];
}
}
return newConfig;
}
function initRedundancy(cfg) {
const config2 = setConfig(cfg);
let queries = [];
function cleanup() {
queries = queries.filter((item) => item().status === "pending");
}
function query(payload, queryCallback, doneCallback) {
const query2 = sendQuery(config2, payload, queryCallback, (data, error) => {
cleanup();
if (doneCallback) {
doneCallback(data, error);
}
});
queries.push(query2);
return query2;
}
function find(callback) {
const result = queries.find((value) => {
return callback(value);
});
return result !== void 0 ? result : null;
}
const instance = {
query,
find,
setIndex: (index2) => {
config2.index = index2;
},
getIndex: () => config2.index,
cleanup
};
return instance;
}
function emptyCallback$1() {
}
const redundancyCache = /* @__PURE__ */ Object.create(null);
function getRedundancyCache(provider) {
if (redundancyCache[provider] === void 0) {
const config2 = getAPIConfig(provider);
if (!config2) {
return;
}
const redundancy = initRedundancy(config2);
const cachedReundancy = {
config: config2,
redundancy
};
redundancyCache[provider] = cachedReundancy;
}
return redundancyCache[provider];
}
function sendAPIQuery(target, query, callback) {
let redundancy;
let send2;
if (typeof target === "string") {
const api = getAPIModule(target);
if (!api) {
callback(void 0, 424);
return emptyCallback$1;
}
send2 = api.send;
const cached = getRedundancyCache(target);
if (cached) {
redundancy = cached.redundancy;
}
} else {
const config2 = createAPIConfig(target);
if (config2) {
redundancy = initRedundancy(config2);
const moduleKey = target.resources ? target.resources[0] : "";
const api = getAPIModule(moduleKey);
if (api) {
send2 = api.send;
}
}
}
if (!redundancy || !send2) {
callback(void 0, 424);
return emptyCallback$1;
}
return redundancy.query(query, send2, callback)().abort;
}
const cache = {};
function emptyCallback() {
}
const pendingIcons = /* @__PURE__ */ Object.create(null);
const iconsToLoad = /* @__PURE__ */ Object.create(null);
const loaderFlags = /* @__PURE__ */ Object.create(null);
const queueFlags = /* @__PURE__ */ Object.create(null);
function loadedNewIcons(provider, prefix) {
if (loaderFlags[provider] === void 0) {
loaderFlags[provider] = /* @__PURE__ */ Object.create(null);
}
const providerLoaderFlags = loaderFlags[provider];
if (!providerLoaderFlags[prefix]) {
providerLoaderFlags[prefix] = true;
setTimeout(() => {
providerLoaderFlags[prefix] = false;
updateCallbacks(provider, prefix);
});
}
}
const errorsCache = /* @__PURE__ */ Object.create(null);
function loadNewIcons(provider, prefix, icons) {
function err() {
const key = (provider === "" ? "" : "@" + provider + ":") + prefix;
const time = Math.floor(Date.now() / 6e4);
if (errorsCache[key] < time) {
errorsCache[key] = time;
console.error('Unable to retrieve icons for "' + key + '" because API is not configured properly.');
}
}
if (iconsToLoad[provider] === void 0) {
iconsToLoad[provider] = /* @__PURE__ */ Object.create(null);
}
const providerIconsToLoad = iconsToLoad[provider];
if (queueFlags[provider] === void 0) {
queueFlags[provider] = /* @__PURE__ */ Object.create(null);
}
const providerQueueFlags = queueFlags[provider];
if (pendingIcons[provider] === void 0) {
pendingIcons[provider] = /* @__PURE__ */ Object.create(null);
}
const providerPendingIcons = pendingIcons[provider];
if (providerIconsToLoad[prefix] === void 0) {
providerIconsToLoad[prefix] = icons;
} else {
providerIconsToLoad[prefix] = providerIconsToLoad[prefix].concat(icons).sort();
}
if (!providerQueueFlags[prefix]) {
providerQueueFlags[prefix] = true;
setTimeout(() => {
providerQueueFlags[prefix] = false;
const icons2 = providerIconsToLoad[prefix];
delete providerIconsToLoad[prefix];
const api = getAPIModule(provider);
if (!api) {
err();
return;
}
const params = api.prepare(provider, prefix, icons2);
params.forEach((item) => {
sendAPIQuery(provider, item, (data, error) => {
const storage2 = getStorage(provider, prefix);
if (typeof data !== "object") {
if (error !== 404) {
return;
}
const t2 = Date.now();
item.icons.forEach((name) => {
storage2.missing[name] = t2;
});
} else {
try {
const parsed = addIconSet(storage2, data);
if (!parsed.length) {
return;
}
const pending = providerPendingIcons[prefix];
parsed.forEach((name) => {
delete pending[name];
});
if (cache.store) {
cache.store(provider, data);
}
} catch (err2) {
console.error(err2);
}
}
loadedNewIcons(provider, prefix);
});
});
});
}
}
const loadIcons = (icons, callback) => {
const cleanedIcons = listToIcons(icons, true, allowSimpleNames());
const sortedIcons = sortIcons(cleanedIcons);
if (!sortedIcons.pending.length) {
let callCallback = true;
if (callback) {
setTimeout(() => {
if (callCallback) {
callback(sortedIcons.loaded, sortedIcons.missing, sortedIcons.pending, emptyCallback);
}
});
}
return () => {
callCallback = false;
};
}
const newIcons = /* @__PURE__ */ Object.create(null);
const sources = [];
let lastProvider, lastPrefix;
sortedIcons.pending.forEach((icon) => {
const provider = icon.provider;
const prefix = icon.prefix;
if (prefix === lastPrefix && provider === lastProvider) {
return;
}
lastProvider = provider;
lastPrefix = prefix;
sources.push({
provider,
prefix
});
if (pendingIcons[provider] === void 0) {
pendingIcons[provider] = /* @__PURE__ */ Object.create(null);
}
const providerPendingIcons = pendingIcons[provider];
if (providerPendingIcons[prefix] === void 0) {
providerPendingIcons[prefix] = /* @__PURE__ */ Object.create(null);
}
if (newIcons[provider] === void 0) {
newIcons[provider] = /* @__PURE__ */ Object.create(null);
}
const providerNewIcons = newIcons[provider];
if (providerNewIcons[prefix] === void 0) {
providerNewIcons[prefix] = [];
}
});
const time = Date.now();
sortedIcons.pending.forEach((icon) => {
const provider = icon.provider;
const prefix = icon.prefix;
const name = icon.name;
const pendingQueue = pendingIcons[provider][prefix];
if (pendingQueue[name] === void 0) {
pendingQueue[name] = time;
newIcons[provider][prefix].push(name);
}
});
sources.forEach((source) => {
const provider = source.provider;
const prefix = source.prefix;
if (newIcons[provider][prefix].length) {
loadNewIcons(provider, prefix, newIcons[provider][prefix]);
}
});
return callback ? storeCallback(callback, sortedIcons, sources) : emptyCallback;
};
const cacheVersion = "iconify2";
const cachePrefix = "iconify";
const countKey = cachePrefix + "-count";
const versionKey = cachePrefix + "-version";
const hour = 36e5;
const cacheExpiration = 168;
const config = {
local: true,
session: true
};
let loaded = false;
const count = {
local: 0,
session: 0
};
const emptyList = {
local: [],
session: []
};
let _window = typeof window === "undefined" ? {} : window;
function getGlobal(key) {
const attr2 = key + "Storage";
try {
if (_window && _window[attr2] && typeof _window[attr2].length === "number") {
return _window[attr2];
}
} catch (err) {
}
config[key] = false;
return null;
}
function setCount(storage2, key, value) {
try {
storage2.setItem(countKey, value.toString());
count[key] = value;
return true;
} catch (err) {
return false;
}
}
function getCount(storage2) {
const count2 = storage2.getItem(countKey);
if (count2) {
const total = parseInt(count2);
return total ? total : 0;
}
return 0;
}
function initCache(storage2, key) {
try {
storage2.setItem(versionKey, cacheVersion);
} catch (err) {
}
setCount(storage2, key, 0);
}
function destroyCache(storage2) {
try {
const total = getCount(storage2);
for (let i2 = 0; i2 < total; i2++) {
storage2.removeItem(cachePrefix + i2.toString());
}
} catch (err) {
}
}
const loadCache = () => {
if (loaded) {
return;
}
loaded = true;
const minTime = Math.floor(Date.now() / hour) - cacheExpiration;
function load(key) {
const func = getGlobal(key);
if (!func) {
return;
}
const getItem = (index2) => {
const name = cachePrefix + index2.toString();
const item = func.getItem(name);
if (typeof item !== "string") {
return false;
}
let valid = true;
try {
const data = JSON.parse(item);
if (typeof data !== "object" || typeof data.cached !== "number" || data.cached < minTime || typeof data.provider !== "string" || typeof data.data !== "object" || typeof data.data.prefix !== "string") {
valid = false;
} else {
const provider = data.provider;
const prefix = data.data.prefix;
const storage2 = getStorage(provider, prefix);
valid = addIconSet(storage2, data.data).length > 0;
}
} catch (err) {
valid = false;
}
if (!valid) {
func.removeItem(name);
}
return valid;
};
try {
const version2 = func.getItem(versionKey);
if (version2 !== cacheVersion) {
if (version2) {
destroyCache(func);
}
initCache(func, key);
return;
}
let total = getCount(func);
for (let i2 = total - 1; i2 >= 0; i2--) {
if (!getItem(i2)) {
if (i2 === total - 1) {
total--;
} else {
emptyList[key].push(i2);
}
}
}
setCount(func, key, total);
} catch (err) {
}
}
for (const key in config) {
load(key);
}
};
const storeCache = (provider, data) => {
if (!loaded) {
loadCache();
}
function store(key) {
if (!config[key]) {
return false;
}
const func = getGlobal(key);
if (!func) {
return false;
}
let index2 = emptyList[key].shift();
if (index2 === void 0) {
index2 = count[key];
if (!setCount(func, key, index2 + 1)) {
return false;
}
}
try {
const item = {
cached: Math.floor(Date.now() / hour),
provider,
data
};
func.setItem(cachePrefix + index2.toString(), JSON.stringify(item));
} catch (err) {
return false;
}
return true;
}
if (!Object.keys(data.icons).length) {
return;
}
if (data.not_found) {
data = Object.assign({}, data);
delete data.not_found;
}
if (!store("local")) {
store("session");
}
};
const separator = /[\s,]+/;
function flipFromString(custom, flip2) {
flip2.split(separator).forEach((str) => {
const value = str.trim();
switch (value) {
case "horizontal":
custom.hFlip = true;
break;
case "vertical":
custom.vFlip = true;
break;
}
});
}
function alignmentFromString(custom, align) {
align.split(separator).forEach((str) => {
const value = str.trim();
switch (value) {
case "left":
case "center":
case "right":
custom.hAlign = value;
break;
case "top":
case "middle":
case "bottom":
custom.vAlign = value;
break;
case "slice":
case "crop":
custom.slice = true;
break;
case "meet":
custom.slice = false;
}
});
}
function rotateFromString(value, defaultValue = 0) {
const units = value.replace(/^-?[0-9.]*/, "");
function cleanup(value2) {
while (value2 < 0) {
value2 += 4;
}
return value2 % 4;
}
if (units === "") {
const num = parseInt(value);
return isNaN(num) ? 0 : cleanup(num);
} else if (units !== value) {
let split = 0;
switch (units) {
case "%":
split = 25;
break;
case "deg":
split = 90;
}
if (split) {
let num = parseFloat(value.slice(0, value.length - units.length));
if (isNaN(num)) {
return 0;
}
num = num / split;
return num % 1 === 0 ? cleanup(num) : 0;
}
}
return defaultValue;
}
const svgDefaults = {
"xmlns": "http://www.w3.org/2000/svg",
"xmlns:xlink": "http://www.w3.org/1999/xlink",
"aria-hidden": true,
"role": "img"
};
let customisationAliases = {};
["horizontal", "vertical"].forEach((prefix) => {
["Align", "Flip"].forEach((suffix) => {
const attr2 = prefix.slice(0, 1) + suffix;
const value = {
attr: attr2,
boolean: suffix === "Flip"
};
customisationAliases[prefix + "-" + suffix.toLowerCase()] = value;
customisationAliases[prefix.slice(0, 1) + "-" + suffix.toLowerCase()] = value;
customisationAliases[prefix + suffix] = value;
});
});
const render = (icon, props) => {
const customisations = mergeCustomisations(defaults, props);
const componentProps = { ...svgDefaults };
let style = typeof props.style === "object" && !(props.style instanceof Array) ? { ...props.style } : {};
for (let key in props) {
const value = props[key];
if (value === void 0) {
continue;
}
switch (key) {
case "icon":
case "style":
case "onLoad":
break;
case "inline":
case "hFlip":
case "vFlip":
customisations[key] = value === true || value === "true" || value === 1;
break;
case "flip":
if (typeof value === "string") {
flipFromString(customisations, value);
}
break;
case "align":
if (typeof value === "string") {
alignmentFromString(customisations, value);
}
break;
case "color":
style.color = value;
break;
case "rotate":
if (typeof value === "string") {
customisations[key] = rotateFromString(value);
} else if (typeof value === "number") {
customisations[key] = value;
}
break;
case "ariaHidden":
case "aria-hidden":
if (value !== true && value !== "true") {
delete componentProps["aria-hidden"];
}
break;
default:
if (customisationAliases[key] !== void 0) {
if (customisationAliases[key].boolean && (value === true || value === "true" || value === 1)) {
customisations[customisationAliases[key].attr] = true;
} else if (!customisationAliases[key].boolean && typeof value === "string" && value !== "") {
customisations[customisationAliases[key].attr] = value;
}
} else if (defaults[key] === void 0) {
componentProps[key] = value;
}
}
}
const item = iconToSVG(icon, customisations);
for (let key in item.attributes) {
componentProps[key] = item.attributes[key];
}
if (item.inline && style.verticalAlign === void 0 && style["vertical-align"] === void 0) {
style.verticalAlign = "-0.125em";
}
let localCounter = 0;
let id2 = props.id;
if (typeof id2 === "string") {
id2 = id2.replace(/-/g, "_");
}
componentProps["innerHTML"] = replaceIDs(item.body, id2 ? () => id2 + "ID" + localCounter++ : "iconifyVue");
if (Object.keys(style).length > 0) {
componentProps["style"] = style;
}
return h$2("svg", componentProps);
};
allowSimpleNames(true);
setAPIModule("", fetchAPIModule);
if (typeof document !== "undefined" && typeof window !== "undefined") {
cache.store = storeCache;
loadCache();
const _window2 = window;
if (_window2.IconifyPreload !== void 0) {
const preload = _window2.IconifyPreload;
const err = "Invalid IconifyPreload syntax.";
if (typeof preload === "object" && preload !== null) {
(preload instanceof Array ? preload : [preload]).forEach((item) => {
try {
if (
// Check if item is an object and not null/array
typeof item !== "object" || item === null || item instanceof Array || // Check for 'icons' and 'prefix'
typeof item.icons !== "object" || typeof item.prefix !== "string" || // Add icon set
!addCollection(item)
) {
console.error(err);
}
} catch (e2) {
console.error(err);
}
});
}
}
if (_window2.IconifyProviders !== void 0) {
const providers = _window2.IconifyProviders;
if (typeof providers === "object" && providers !== null) {
for (let key in providers) {
const err = "IconifyProviders[" + key + "] is invalid.";
try {
const value = providers[key];
if (typeof value !== "object" || !value || value.resources === void 0) {
continue;
}
if (!addAPIProvider(key, value)) {
console.error(err);
}
} catch (e2) {
console.error(err);
}
}
}
}
}
const emptyIcon = fullIcon({
body: ""
});
const Icon = /* @__PURE__ */ defineComponent({
// Do not inherit other attributes: it is handled by render()
inheritAttrs: false,
// Set initial data
data() {
return {
// Mounted status
iconMounted: false,
// Callback counter to trigger re-render
counter: 0
};
},
mounted() {
this._name = "";
this._loadingIcon = null;
this.iconMounted = true;
},
unmounted() {
this.abortLoading();
},
methods: {
abortLoading() {
if (this._loadingIcon) {
this._loadingIcon.abort();
this._loadingIcon = null;
}
},
// Get data for icon to render or null
getIcon(icon, onload) {
if (typeof icon === "object" && icon !== null && typeof icon.body === "string") {
this._name = "";
this.abortLoading();
return {
data: fullIcon(icon)
};
}
let iconName;
if (typeof icon !== "string" || (iconName = stringToIcon(icon, false, true)) === null) {
this.abortLoading();
return null;
}
const data = getIconData(iconName);
if (data === null) {
if (!this._loadingIcon || this._loadingIcon.name !== icon) {
this.abortLoading();
this._name = "";
this._loadingIcon = {
name: icon,
abort: loadIcons([iconName], () => {
this.counter++;
})
};
}
return null;
}
this.abortLoading();
if (this._name !== icon) {
this._name = icon;
if (onload) {
onload(icon);
}
}
const classes = ["iconify"];
if (iconName.prefix !== "") {
classes.push("iconify--" + iconName.prefix);
}
if (iconName.provider !== "") {
classes.push("iconify--" + iconName.provider);
}
return { data, classes };
}
},
// Render icon
render() {
this.counter;
const props = this.$attrs;
const icon = this.iconMounted ? this.getIcon(props.icon, props.onLoad) : null;
if (!icon) {
return render(emptyIcon, props);
}
let newProps = props;
if (icon.classes) {
newProps = {
...props,
class: (typeof props["class"] === "string" ? props["class"] + " " : "") + icon.classes.join(" ")
};
}
return render(icon.data, newProps);
}
});
/*!
* vue-router v4.2.5
* (c) 2023 Eduardo San Martin Morote
* @license MIT
*/
const isBrowser = typeof window !== "undefined";
function isESModule(obj) {
return obj.__esModule || obj[Symbol.toStringTag] === "Module";
}
const assign = Object.assign;
function applyToParams(fn2, params) {
const newParams = {};
for (const key in params) {
const value = params[key];
newParams[key] = isArray(value) ? value.map(fn2) : fn2(value);
}
return newParams;
}
const noop = () => {
};
const isArray = Array.isArray;
function warn(msg) {
const args = Array.from(arguments).slice(1);
console.warn.apply(console, ["[Vue Router warn]: " + msg].concat(args));
}
const TRAILING_SLASH_RE = /\/$/;
const removeTrailingSlash = (path) => path.replace(TRAILING_SLASH_RE, "");
function parseURL(parseQuery2, location2, currentLocation = "/") {
let path, query = {}, searchString = "", hash2 = "";
const hashPos = location2.indexOf("#");
let searchPos = location2.indexOf("?");
if (hashPos < searchPos && hashPos >= 0) {
searchPos = -1;
}
if (searchPos > -1) {
path = location2.slice(0, searchPos);
searchString = location2.slice(searchPos + 1, hashPos > -1 ? hashPos : location2.length);
query = parseQuery2(searchString);
}
if (hashPos > -1) {
path = path || location2.slice(0, hashPos);
hash2 = location2.slice(hashPos, location2.length);
}
path = resolveRelativePath(path != null ? path : location2, currentLocation);
return {
fullPath: path + (searchString && "?") + searchString + hash2,
path,
query,
hash: hash2
};
}
function stringifyURL(stringifyQuery2, location2) {
const query = location2.query ? stringifyQuery2(location2.query) : "";
return location2.path + (query && "?") + query + (location2.hash || "");
}
function stripBase(pathname, base) {
if (!base || !pathname.toLowerCase().startsWith(base.toLowerCase()))
return pathname;
return pathname.slice(base.length) || "/";
}
function isSameRouteLocation(stringifyQuery2, a2, b3) {
const aLastIndex = a2.matched.length - 1;
const bLastIndex = b3.matched.length - 1;
return aLastIndex > -1 && aLastIndex === bLastIndex && isSameRouteRecord(a2.matched[aLastIndex], b3.matched[bLastIndex]) && isSameRouteLocationParams(a2.params, b3.params) && stringifyQuery2(a2.query) === stringifyQuery2(b3.query) && a2.hash === b3.hash;
}
function isSameRouteRecord(a2, b3) {
return (a2.aliasOf || a2) === (b3.aliasOf || b3);
}
function isSameRouteLocationParams(a2, b3) {
if (Object.keys(a2).length !== Object.keys(b3).length)
return false;
for (const key in a2) {
if (!isSameRouteLocationParamsValue(a2[key], b3[key]))
return false;
}
return true;
}
function isSameRouteLocationParamsValue(a2, b3) {
return isArray(a2) ? isEquivalentArray(a2, b3) : isArray(b3) ? isEquivalentArray(b3, a2) : a2 === b3;
}
function isEquivalentArray(a2, b3) {
return isArray(b3) ? a2.length === b3.length && a2.every((value, i2) => value === b3[i2]) : a2.length === 1 && a2[0] === b3;
}
function resolveRelativePath(to2, from) {
if (to2.startsWith("/"))
return to2;
if (!from.startsWith("/")) {
warn(`Cannot resolve a relative location without an absolute path. Trying to resolve "${to2}" from "${from}". It should look like "/${from}".`);
return to2;
}
if (!to2)
return from;
const fromSegments = from.split("/");
const toSegments = to2.split("/");
const lastToSegment = toSegments[toSegments.length - 1];
if (lastToSegment === ".." || lastToSegment === ".") {
toSegments.push("");
}
let position = fromSegments.length - 1;
let toPosition;
let segment;
for (toPosition = 0; toPosition < toSegments.length; toPosition++) {
segment = toSegments[toPosition];
if (segment === ".")
continue;
if (segment === "..") {
if (position > 1)
position--;
} else
break;
}
return fromSegments.slice(0, position).join("/") + "/" + toSegments.slice(toPosition - (toPosition === toSegments.length ? 1 : 0)).join("/");
}
var NavigationType;
(function(NavigationType2) {
NavigationType2["pop"] = "pop";
NavigationType2["push"] = "push";
})(NavigationType || (NavigationType = {}));
var NavigationDirection;
(function(NavigationDirection2) {
NavigationDirection2["back"] = "back";
NavigationDirection2["forward"] = "forward";
NavigationDirection2["unknown"] = "";
})(NavigationDirection || (NavigationDirection = {}));
function normalizeBase(base) {
if (!base) {
if (isBrowser) {
const baseEl = document.querySelector("base");
base = baseEl && baseEl.getAttribute("href") || "/";
base = base.replace(/^\w+:\/\/[^\/]+/, "");
} else {
base = "/";
}
}
if (base[0] !== "/" && base[0] !== "#")
base = "/" + base;
return removeTrailingSlash(base);
}
const BEFORE_HASH_RE = /^[^#]+#/;
function createHref(base, location2) {
return base.replace(BEFORE_HASH_RE, "#") + location2;
}
function getElementPosition(el2, offset2) {
const docRect = document.documentElement.getBoundingClientRect();
const elRect = el2.getBoundingClientRect();
return {
behavior: offset2.behavior,
left: elRect.left - docRect.left - (offset2.left || 0),
top: elRect.top - docRect.top - (offset2.top || 0)
};
}
const computeScrollPosition = () => ({
left: window.pageXOffset,
top: window.pageYOffset
});
function scrollToPosition(position) {
let scrollToOptions;
if ("el" in position) {
const positionEl = position.el;
const isIdSelector = typeof positionEl === "string" && positionEl.startsWith("#");
if (typeof position.el === "string") {
if (!isIdSelector || !document.getElementById(position.el.slice(1))) {
try {
const foundEl = document.querySelector(position.el);
if (isIdSelector && foundEl) {
warn(`The selector "${position.el}" should be passed as "el: document.querySelector('${position.el}')" because it starts with "#".`);
return;
}
} catch (err) {
warn(`The selector "${position.el}" is invalid. If you are using an id selector, make sure to escape it. You can find more information about escaping characters in selectors at https://mathiasbynens.be/notes/css-escapes or use CSS.escape (https://developer.mozilla.org/en-US/docs/Web/API/CSS/escape).`);
return;
}
}
}
const el2 = typeof positionEl === "string" ? isIdSelector ? document.getElementById(positionEl.slice(1)) : document.querySelector(positionEl) : positionEl;
if (!el2) {
warn(`Couldn't find element using selector "${position.el}" returned by scrollBehavior.`);
return;
}
scrollToOptions = getElementPosition(el2, position);
} else {
scrollToOptions = position;
}
if ("scrollBehavior" in document.documentElement.style)
window.scrollTo(scrollToOptions);
else {
window.scrollTo(scrollToOptions.left != null ? scrollToOptions.left : window.pageXOffset, scrollToOptions.top != null ? scrollToOptions.top : window.pageYOffset);
}
}
function getScrollKey(path, delta) {
const position = history.state ? history.state.position - delta : -1;
return position + path;
}
const scrollPositions = /* @__PURE__ */ new Map();
function saveScrollPosition(key, scrollPosition) {
scrollPositions.set(key, scrollPosition);
}
function getSavedScrollPosition(key) {
const scroll = scrollPositions.get(key);
scrollPositions.delete(key);
return scroll;
}
let createBaseLocation = () => location.protocol + "//" + location.host;
function createCurrentLocation(base, location2) {
const { pathname, search, hash: hash2 } = location2;
const hashPos = base.indexOf("#");
if (hashPos > -1) {
let slicePos = hash2.includes(base.slice(hashPos)) ? base.slice(hashPos).length : 1;
let pathFromHash = hash2.slice(slicePos);
if (pathFromHash[0] !== "/")
pathFromHash = "/" + pathFromHash;
return stripBase(pathFromHash, "");
}
const path = stripBase(pathname, base);
return path + search + hash2;
}
function useHistoryListeners(base, historyState, currentLocation, replace) {
let listeners = [];
let teardowns = [];
let pauseState = null;
const popStateHandler = ({ state }) => {
const to2 = createCurrentLocation(base, location);
const from = currentLocation.value;
const fromState = historyState.value;
let delta = 0;
if (state) {
currentLocation.value = to2;
historyState.value = state;
if (pauseState && pauseState === from) {
pauseState = null;
return;
}
delta = fromState ? state.position - fromState.position : 0;
} else {
replace(to2);
}
listeners.forEach((listener) => {
listener(currentLocation.value, from, {
delta,
type: NavigationType.pop,
direction: delta ? delta > 0 ? NavigationDirection.forward : NavigationDirection.back : NavigationDirection.unknown
});
});
};
function pauseListeners() {
pauseState = currentLocation.value;
}
function listen2(callback) {
listeners.push(callback);
const teardown = () => {
const index2 = listeners.indexOf(callback);
if (index2 > -1)
listeners.splice(index2, 1);
};
teardowns.push(teardown);
return teardown;
}
function beforeUnloadListener() {
const { history: history2 } = window;
if (!history2.state)
return;
history2.replaceState(assign({}, history2.state, { scroll: computeScrollPosition() }), "");
}
function destroy() {
for (const teardown of teardowns)
teardown();
teardowns = [];
window.removeEventListener("popstate", popStateHandler);
window.removeEventListener("beforeunload", beforeUnloadListener);
}
window.addEventListener("popstate", popStateHandler);
window.addEventListener("beforeunload", beforeUnloadListener, {
passive: true
});
return {
pauseListeners,
listen: listen2,
destroy
};
}
function buildState(back, current, forward, replaced = false, computeScroll = false) {
return {
back,
current,
forward,
replaced,
position: window.history.length,
scroll: computeScroll ? computeScrollPosition() : null
};
}
function useHistoryStateNavigation(base) {
const { history: history2, location: location2 } = window;
const currentLocation = {
value: createCurrentLocation(base, location2)
};
const historyState = { value: history2.state };
if (!historyState.value) {
changeLocation(currentLocation.value, {
back: null,
current: currentLocation.value,
forward: null,
// the length is off by one, we need to decrease it
position: history2.length - 1,
replaced: true,
// don't add a scroll as the user may have an anchor, and we want
// scrollBehavior to be triggered without a saved position
scroll: null
}, true);
}
function changeLocation(to2, state, replace2) {
const hashIndex = base.indexOf("#");
const url = hashIndex > -1 ? (location2.host && document.querySelector("base") ? base : base.slice(hashIndex)) + to2 : createBaseLocation() + base + to2;
try {
history2[replace2 ? "replaceState" : "pushState"](state, "", url);
historyState.value = state;
} catch (err) {
{
warn("Error with push/replace State", err);
}
location2[replace2 ? "replace" : "assign"](url);
}
}
function replace(to2, data) {
const state = assign({}, history2.state, buildState(
historyState.value.back,
// keep back and forward entries but override current position
to2,
historyState.value.forward,
true
), data, { position: historyState.value.position });
changeLocation(to2, state, true);
currentLocation.value = to2;
}
function push(to2, data) {
const currentState = assign(
{},
// use current history state to gracefully handle a wrong call to
// history.replaceState
// https://github.com/vuejs/router/issues/366
historyState.value,
history2.state,
{
forward: to2,
scroll: computeScrollPosition()
}
);
if (!history2.state) {
warn(`history.state seems to have been manually replaced without preserving the necessary values. Make sure to preserve existing history state if you are manually calling history.replaceState:
history.replaceState(history.state, '', url)
You can find more information at https://next.router.vuejs.org/guide/migration/#usage-of-history-state.`);
}
changeLocation(currentState.current, currentState, true);
const state = assign({}, buildState(currentLocation.value, to2, null), { position: currentState.position + 1 }, data);
changeLocation(to2, state, false);
currentLocation.value = to2;
}
return {
location: currentLocation,
state: historyState,
push,
replace
};
}
function createWebHistory(base) {
base = normalizeBase(base);
const historyNavigation = useHistoryStateNavigation(base);
const historyListeners = useHistoryListeners(base, historyNavigation.state, historyNavigation.location, historyNavigation.replace);
function go2(delta, triggerListeners = true) {
if (!triggerListeners)
historyListeners.pauseListeners();
history.go(delta);
}
const routerHistory = assign({
// it's overridden right after
location: "",
base,
go: go2,
createHref: createHref.bind(null, base)
}, historyNavigation, historyListeners);
Object.defineProperty(routerHistory, "location", {
enumerable: true,
get: () => historyNavigation.location.value
});
Object.defineProperty(routerHistory, "state", {
enumerable: true,
get: () => historyNavigation.state.value
});
return routerHistory;
}
function createWebHashHistory(base) {
base = location.host ? base || location.pathname + location.search : "";
if (!base.includes("#"))
base += "#";
if (!base.endsWith("#/") && !base.endsWith("#")) {
warn(`A hash base must end with a "#":
"${base}" should be "${base.replace(/#.*$/, "#")}".`);
}
return createWebHistory(base);
}
function isRouteLocation(route) {
return typeof route === "string" || route && typeof route === "object";
}
function isRouteName(name) {
return typeof name === "string" || typeof name === "symbol";
}
const START_LOCATION_NORMALIZED = {
path: "/",
name: void 0,
params: {},
query: {},
hash: "",
fullPath: "/",
matched: [],
meta: {},
redirectedFrom: void 0
};
const NavigationFailureSymbol = Symbol("navigation failure");
var NavigationFailureType;
(function(NavigationFailureType2) {
NavigationFailureType2[NavigationFailureType2["aborted"] = 4] = "aborted";
NavigationFailureType2[NavigationFailureType2["cancelled"] = 8] = "cancelled";
NavigationFailureType2[NavigationFailureType2["duplicated"] = 16] = "duplicated";
})(NavigationFailureType || (NavigationFailureType = {}));
const ErrorTypeMessages = {
[
1
/* ErrorTypes.MATCHER_NOT_FOUND */
]({ location: location2, currentLocation }) {
return `No match for
${JSON.stringify(location2)}${currentLocation ? "\nwhile being at\n" + JSON.stringify(currentLocation) : ""}`;
},
[
2
/* ErrorTypes.NAVIGATION_GUARD_REDIRECT */
]({ from, to: to2 }) {
return `Redirected from "${from.fullPath}" to "${stringifyRoute(to2)}" via a navigation guard.`;
},
[
4
/* ErrorTypes.NAVIGATION_ABORTED */
]({ from, to: to2 }) {
return `Navigation aborted from "${from.fullPath}" to "${to2.fullPath}" via a navigation guard.`;
},
[
8
/* ErrorTypes.NAVIGATION_CANCELLED */
]({ from, to: to2 }) {
return `Navigation cancelled from "${from.fullPath}" to "${to2.fullPath}" with a new navigation.`;
},
[
16
/* ErrorTypes.NAVIGATION_DUPLICATED */
]({ from, to: to2 }) {
return `Avoided redundant navigation to current location: "${from.fullPath}".`;
}
};
function createRouterError(type, params) {
{
return assign(new Error(ErrorTypeMessages[type](params)), {
type,
[NavigationFailureSymbol]: true
}, params);
}
}
function isNavigationFailure(error, type) {
return error instanceof Error && NavigationFailureSymbol in error && (type == null || !!(error.type & type));
}
const propertiesToLog = ["params", "query", "hash"];
function stringifyRoute(to2) {
if (typeof to2 === "string")
return to2;
if ("path" in to2)
return to2.path;
const location2 = {};
for (const key of propertiesToLog) {
if (key in to2)
location2[key] = to2[key];
}
return JSON.stringify(location2, null, 2);
}
const BASE_PARAM_PATTERN = "[^/]+?";
const BASE_PATH_PARSER_OPTIONS = {
sensitive: false,
strict: false,
start: true,
end: true
};
const REGEX_CHARS_RE = /[.+*?^${}()[\]/\\]/g;
function tokensToParser(segments, extraOptions) {
const options = assign({}, BASE_PATH_PARSER_OPTIONS, extraOptions);
const score = [];
let pattern = options.start ? "^" : "";
const keys = [];
for (const segment of segments) {
const segmentScores = segment.length ? [] : [
90
/* PathScore.Root */
];
if (options.strict && !segment.length)
pattern += "/";
for (let tokenIndex = 0; tokenIndex < segment.length; tokenIndex++) {
const token = segment[tokenIndex];
let subSegmentScore = 40 + (options.sensitive ? 0.25 : 0);
if (token.type === 0) {
if (!tokenIndex)
pattern += "/";
pattern += token.value.replace(REGEX_CHARS_RE, "\\$&");
subSegmentScore += 40;
} else if (token.type === 1) {
const { value, repeatable, optional, regexp } = token;
keys.push({
name: value,
repeatable,
optional
});
const re22 = regexp ? regexp : BASE_PARAM_PATTERN;
if (re22 !== BASE_PARAM_PATTERN) {
subSegmentScore += 10;
try {
new RegExp(`(${re22})`);
} catch (err) {
throw new Error(`Invalid custom RegExp for param "${value}" (${re22}): ` + err.message);
}
}
let subPattern = repeatable ? `((?:${re22})(?:/(?:${re22}))*)` : `(${re22})`;
if (!tokenIndex)
subPattern = // avoid an optional / if there are more segments e.g. /:p?-static
// or /:p?-:p2
optional && segment.length < 2 ? `(?:/${subPattern})` : "/" + subPattern;
if (optional)
subPattern += "?";
pattern += subPattern;
subSegmentScore += 20;
if (optional)
subSegmentScore += -8;
if (repeatable)
subSegmentScore += -20;
if (re22 === ".*")
subSegmentScore += -50;
}
segmentScores.push(subSegmentScore);
}
score.push(segmentScores);
}
if (options.strict && options.end) {
const i2 = score.length - 1;
score[i2][score[i2].length - 1] += 0.7000000000000001;
}
if (!options.strict)
pattern += "/?";
if (options.end)
pattern += "$";
else if (options.strict)
pattern += "(?:/|$)";
const re2 = new RegExp(pattern, options.sensitive ? "" : "i");
function parse2(path) {
const match = path.match(re2);
const params = {};
if (!match)
return null;
for (let i2 = 1; i2 < match.length; i2++) {
const value = match[i2] || "";
const key = keys[i2 - 1];
params[key.name] = value && key.repeatable ? value.split("/") : value;
}
return params;
}
function stringify(params) {
let path = "";
let avoidDuplicatedSlash = false;
for (const segment of segments) {
if (!avoidDuplicatedSlash || !path.endsWith("/"))
path += "/";
avoidDuplicatedSlash = false;
for (const token of segment) {
if (token.type === 0) {
path += token.value;
} else if (token.type === 1) {
const { value, repeatable, optional } = token;
const param = value in params ? params[value] : "";
if (isArray(param) && !repeatable) {
throw new Error(`Provided param "${value}" is an array but it is not repeatable (* or + modifiers)`);
}
const text2 = isArray(param) ? param.join("/") : param;
if (!text2) {
if (optional) {
if (segment.length < 2) {
if (path.endsWith("/"))
path = path.slice(0, -1);
else
avoidDuplicatedSlash = true;
}
} else
throw new Error(`Missing required param "${value}"`);
}
path += text2;
}
}
}
return path || "/";
}
return {
re: re2,
score,
keys,
parse: parse2,
stringify
};
}
function compareScoreArray(a2, b3) {
let i2 = 0;
while (i2 < a2.length && i2 < b3.length) {
const diff = b3[i2] - a2[i2];
if (diff)
return diff;
i2++;
}
if (a2.length < b3.length) {
return a2.length === 1 && a2[0] === 40 + 40 ? -1 : 1;
} else if (a2.length > b3.length) {
return b3.length === 1 && b3[0] === 40 + 40 ? 1 : -1;
}
return 0;
}
function comparePathParserScore(a2, b3) {
let i2 = 0;
const aScore = a2.score;
const bScore = b3.score;
while (i2 < aScore.length && i2 < bScore.length) {
const comp = compareScoreArray(aScore[i2], bScore[i2]);
if (comp)
return comp;
i2++;
}
if (Math.abs(bScore.length - aScore.length) === 1) {
if (isLastScoreNegative(aScore))
return 1;
if (isLastScoreNegative(bScore))
return -1;
}
return bScore.length - aScore.length;
}
function isLastScoreNegative(score) {
const last = score[score.length - 1];
return score.length > 0 && last[last.length - 1] < 0;
}
const ROOT_TOKEN = {
type: 0,
value: ""
};
const VALID_PARAM_RE = /[a-zA-Z0-9_]/;
function tokenizePath(path) {
if (!path)
return [[]];
if (path === "/")
return [[ROOT_TOKEN]];
if (!path.startsWith("/")) {
throw new Error(`Route paths should start with a "/": "${path}" should be "/${path}".`);
}
function crash(message) {
throw new Error(`ERR (${state})/"${buffer2}": ${message}`);
}
let state = 0;
let previousState = state;
const tokens = [];
let segment;
function finalizeSegment() {
if (segment)
tokens.push(segment);
segment = [];
}
let i2 = 0;
let char;
let buffer2 = "";
let customRe = "";
function consumeBuffer() {
if (!buffer2)
return;
if (state === 0) {
segment.push({
type: 0,
value: buffer2
});
} else if (state === 1 || state === 2 || state === 3) {
if (segment.length > 1 && (char === "*" || char === "+"))
crash(`A repeatable param (${buffer2}) must be alone in its segment. eg: '/:ids+.`);
segment.push({
type: 1,
value: buffer2,
regexp: customRe,
repeatable: char === "*" || char === "+",
optional: char === "*" || char === "?"
});
} else {
crash("Invalid state to consume buffer");
}
buffer2 = "";
}
function addCharToBuffer() {
buffer2 += char;
}
while (i2 < path.length) {
char = path[i2++];
if (char === "\\" && state !== 2) {
previousState = state;
state = 4;
continue;
}
switch (state) {
case 0:
if (char === "/") {
if (buffer2) {
consumeBuffer();
}
finalizeSegment();
} else if (char === ":") {
consumeBuffer();
state = 1;
} else {
addCharToBuffer();
}
break;
case 4:
addCharToBuffer();
state = previousState;
break;
case 1:
if (char === "(") {
state = 2;
} else if (VALID_PARAM_RE.test(char)) {
addCharToBuffer();
} else {
consumeBuffer();
state = 0;
if (char !== "*" && char !== "?" && char !== "+")
i2--;
}
break;
case 2:
if (char === ")") {
if (customRe[customRe.length - 1] == "\\")
customRe = customRe.slice(0, -1) + char;
else
state = 3;
} else {
customRe += char;
}
break;
case 3:
consumeBuffer();
state = 0;
if (char !== "*" && char !== "?" && char !== "+")
i2--;
customRe = "";
break;
default:
crash("Unknown state");
break;
}
}
if (state === 2)
crash(`Unfinished custom RegExp for param "${buffer2}"`);
consumeBuffer();
finalizeSegment();
return tokens;
}
function createRouteRecordMatcher(record, parent, options) {
const parser = tokensToParser(tokenizePath(record.path), options);
{
const existingKeys = /* @__PURE__ */ new Set();
for (const key of parser.keys) {
if (existingKeys.has(key.name))
warn(`Found duplicated params with name "${key.name}" for path "${record.path}". Only the last one will be available on "$route.params".`);
existingKeys.add(key.name);
}
}
const matcher = assign(parser, {
record,
parent,
// these needs to be populated by the parent
children: [],
alias: []
});
if (parent) {
if (!matcher.record.aliasOf === !parent.record.aliasOf)
parent.children.push(matcher);
}
return matcher;
}
function createRouterMatcher(routes, globalOptions) {
const matchers = [];
const matcherMap = /* @__PURE__ */ new Map();
globalOptions = mergeOptions({ strict: false, end: true, sensitive: false }, globalOptions);
function getRecordMatcher(name) {
return matcherMap.get(name);
}
function addRoute(record, parent, originalRecord) {
const isRootAdd = !originalRecord;
const mainNormalizedRecord = normalizeRouteRecord(record);
{
checkChildMissingNameWithEmptyPath(mainNormalizedRecord, parent);
}
mainNormalizedRecord.aliasOf = originalRecord && originalRecord.record;
const options = mergeOptions(globalOptions, record);
const normalizedRecords = [
mainNormalizedRecord
];
if ("alias" in record) {
const aliases = typeof record.alias === "string" ? [record.alias] : record.alias;
for (const alias of aliases) {
normalizedRecords.push(assign({}, mainNormalizedRecord, {
// this allows us to hold a copy of the `components` option
// so that async components cache is hold on the original record
components: originalRecord ? originalRecord.record.components : mainNormalizedRecord.components,
path: alias,
// we might be the child of an alias
aliasOf: originalRecord ? originalRecord.record : mainNormalizedRecord
// the aliases are always of the same kind as the original since they
// are defined on the same record
}));
}
}
let matcher;
let originalMatcher;
for (const normalizedRecord of normalizedRecords) {
const { path } = normalizedRecord;
if (parent && path[0] !== "/") {
const parentPath = parent.record.path;
const connectingSlash = parentPath[parentPath.length - 1] === "/" ? "" : "/";
normalizedRecord.path = parent.record.path + (path && connectingSlash + path);
}
if (normalizedRecord.path === "*") {
throw new Error('Catch all routes ("*") must now be defined using a param with a custom regexp.\nSee more at https://next.router.vuejs.org/guide/migration/#removed-star-or-catch-all-routes.');
}
matcher = createRouteRecordMatcher(normalizedRecord, parent, options);
if (parent && path[0] === "/")
checkMissingParamsInAbsolutePath(matcher, parent);
if (originalRecord) {
originalRecord.alias.push(matcher);
{
checkSameParams(originalRecord, matcher);
}
} else {
originalMatcher = originalMatcher || matcher;
if (originalMatcher !== matcher)
originalMatcher.alias.push(matcher);
if (isRootAdd && record.name && !isAliasRecord(matcher))
removeRoute(record.name);
}
if (mainNormalizedRecord.children) {
const children2 = mainNormalizedRecord.children;
for (let i2 = 0; i2 < children2.length; i2++) {
addRoute(children2[i2], matcher, originalRecord && originalRecord.children[i2]);
}
}
originalRecord = originalRecord || matcher;
if (matcher.record.components && Object.keys(matcher.record.components).length || matcher.record.name || matcher.record.redirect) {
insertMatcher(matcher);
}
}
return originalMatcher ? () => {
removeRoute(originalMatcher);
} : noop;
}
function removeRoute(matcherRef) {
if (isRouteName(matcherRef)) {
const matcher = matcherMap.get(matcherRef);
if (matcher) {
matcherMap.delete(matcherRef);
matchers.splice(matchers.indexOf(matcher), 1);
matcher.children.forEach(removeRoute);
matcher.alias.forEach(removeRoute);
}
} else {
const index2 = matchers.indexOf(matcherRef);
if (index2 > -1) {
matchers.splice(index2, 1);
if (matcherRef.record.name)
matcherMap.delete(matcherRef.record.name);
matcherRef.children.forEach(removeRoute);
matcherRef.alias.forEach(removeRoute);
}
}
}
function getRoutes() {
return matchers;
}
function insertMatcher(matcher) {
let i2 = 0;
while (i2 < matchers.length && comparePathParserScore(matcher, matchers[i2]) >= 0 && // Adding children with empty path should still appear before the parent
// https://github.com/vuejs/router/issues/1124
(matcher.record.path !== matchers[i2].record.path || !isRecordChildOf(matcher, matchers[i2])))
i2++;
matchers.splice(i2, 0, matcher);
if (matcher.record.name && !isAliasRecord(matcher))
matcherMap.set(matcher.record.name, matcher);
}
function resolve2(location2, currentLocation) {
let matcher;
let params = {};
let path;
let name;
if ("name" in location2 && location2.name) {
matcher = matcherMap.get(location2.name);
if (!matcher)
throw createRouterError(1, {
location: location2
});
{
const invalidParams = Object.keys(location2.params || {}).filter((paramName) => !matcher.keys.find((k2) => k2.name === paramName));
if (invalidParams.length) {
warn(`Discarded invalid param(s) "${invalidParams.join('", "')}" when navigating. See https://github.com/vuejs/router/blob/main/packages/router/CHANGELOG.md#414-2022-08-22 for more details.`);
}
}
name = matcher.record.name;
params = assign(
// paramsFromLocation is a new object
paramsFromLocation(
currentLocation.params,
// only keep params that exist in the resolved location
// TODO: only keep optional params coming from a parent record
matcher.keys.filter((k2) => !k2.optional).map((k2) => k2.name)
),
// discard any existing params in the current location that do not exist here
// #1497 this ensures better active/exact matching
location2.params && paramsFromLocation(location2.params, matcher.keys.map((k2) => k2.name))
);
path = matcher.stringify(params);
} else if ("path" in location2) {
path = location2.path;
if (!path.startsWith("/")) {
warn(`The Matcher cannot resolve relative paths but received "${path}". Unless you directly called \`matcher.resolve("${path}")\`, this is probably a bug in vue-router. Please open an issue at https://github.com/vuejs/router/issues/new/choose.`);
}
matcher = matchers.find((m) => m.re.test(path));
if (matcher) {
params = matcher.parse(path);
name = matcher.record.name;
}
} else {
matcher = currentLocation.name ? matcherMap.get(currentLocation.name) : matchers.find((m) => m.re.test(currentLocation.path));
if (!matcher)
throw createRouterError(1, {
location: location2,
currentLocation
});
name = matcher.record.name;
params = assign({}, currentLocation.params, location2.params);
path = matcher.stringify(params);
}
const matched = [];
let parentMatcher = matcher;
while (parentMatcher) {
matched.unshift(parentMatcher.record);
parentMatcher = parentMatcher.parent;
}
return {
name,
path,
params,
matched,
meta: mergeMetaFields(matched)
};
}
routes.forEach((route) => addRoute(route));
return { addRoute, resolve: resolve2, removeRoute, getRoutes, getRecordMatcher };
}
function paramsFromLocation(params, keys) {
const newParams = {};
for (const key of keys) {
if (key in params)
newParams[key] = params[key];
}
return newParams;
}
function normalizeRouteRecord(record) {
return {
path: record.path,
redirect: record.redirect,
name: record.name,
meta: record.meta || {},
aliasOf: void 0,
beforeEnter: record.beforeEnter,
props: normalizeRecordProps(record),
children: record.children || [],
instances: {},
leaveGuards: /* @__PURE__ */ new Set(),
updateGuards: /* @__PURE__ */ new Set(),
enterCallbacks: {},
components: "components" in record ? record.components || null : record.component && { default: record.component }
};
}
function normalizeRecordProps(record) {
const propsObject = {};
const props = record.props || false;
if ("component" in record) {
propsObject.default = props;
} else {
for (const name in record.components)
propsObject[name] = typeof props === "object" ? props[name] : props;
}
return propsObject;
}
function isAliasRecord(record) {
while (record) {
if (record.record.aliasOf)
return true;
record = record.parent;
}
return false;
}
function mergeMetaFields(matched) {
return matched.reduce((meta, record) => assign(meta, record.meta), {});
}
function mergeOptions(defaults2, partialOptions) {
const options = {};
for (const key in defaults2) {
options[key] = key in partialOptions ? partialOptions[key] : defaults2[key];
}
return options;
}
function isSameParam(a2, b3) {
return a2.name === b3.name && a2.optional === b3.optional && a2.repeatable === b3.repeatable;
}
function checkSameParams(a2, b3) {
for (const key of a2.keys) {
if (!key.optional && !b3.keys.find(isSameParam.bind(null, key)))
return warn(`Alias "${b3.record.path}" and the original record: "${a2.record.path}" must have the exact same param named "${key.name}"`);
}
for (const key of b3.keys) {
if (!key.optional && !a2.keys.find(isSameParam.bind(null, key)))
return warn(`Alias "${b3.record.path}" and the original record: "${a2.record.path}" must have the exact same param named "${key.name}"`);
}
}
function checkChildMissingNameWithEmptyPath(mainNormalizedRecord, parent) {
if (parent && parent.record.name && !mainNormalizedRecord.name && !mainNormalizedRecord.path) {
warn(`The route named "${String(parent.record.name)}" has a child without a name and an empty path. Using that name won't render the empty path child so you probably want to move the name to the child instead. If this is intentional, add a name to the child route to remove the warning.`);
}
}
function checkMissingParamsInAbsolutePath(record, parent) {
for (const key of parent.keys) {
if (!record.keys.find(isSameParam.bind(null, key)))
return warn(`Absolute path "${record.record.path}" must have the exact same param named "${key.name}" as its parent "${parent.record.path}".`);
}
}
function isRecordChildOf(record, parent) {
return parent.children.some((child) => child === record || isRecordChildOf(record, child));
}
const HASH_RE = /#/g;
const AMPERSAND_RE = /&/g;
const SLASH_RE = /\//g;
const EQUAL_RE = /=/g;
const IM_RE = /\?/g;
const PLUS_RE = /\+/g;
const ENC_BRACKET_OPEN_RE = /%5B/g;
const ENC_BRACKET_CLOSE_RE = /%5D/g;
const ENC_CARET_RE = /%5E/g;
const ENC_BACKTICK_RE = /%60/g;
const ENC_CURLY_OPEN_RE = /%7B/g;
const ENC_PIPE_RE = /%7C/g;
const ENC_CURLY_CLOSE_RE = /%7D/g;
const ENC_SPACE_RE = /%20/g;
function commonEncode(text2) {
return encodeURI("" + text2).replace(ENC_PIPE_RE, "|").replace(ENC_BRACKET_OPEN_RE, "[").replace(ENC_BRACKET_CLOSE_RE, "]");
}
function encodeHash(text2) {
return commonEncode(text2).replace(ENC_CURLY_OPEN_RE, "{").replace(ENC_CURLY_CLOSE_RE, "}").replace(ENC_CARET_RE, "^");
}
function encodeQueryValue(text2) {
return commonEncode(text2).replace(PLUS_RE, "%2B").replace(ENC_SPACE_RE, "+").replace(HASH_RE, "%23").replace(AMPERSAND_RE, "%26").replace(ENC_BACKTICK_RE, "`").replace(ENC_CURLY_OPEN_RE, "{").replace(ENC_CURLY_CLOSE_RE, "}").replace(ENC_CARET_RE, "^");
}
function encodeQueryKey(text2) {
return encodeQueryValue(text2).replace(EQUAL_RE, "%3D");
}
function encodePath(text2) {
return commonEncode(text2).replace(HASH_RE, "%23").replace(IM_RE, "%3F");
}
function encodeParam(text2) {
return text2 == null ? "" : encodePath(text2).replace(SLASH_RE, "%2F");
}
function decode(text2) {
try {
return decodeURIComponent("" + text2);
} catch (err) {
warn(`Error decoding "${text2}". Using original value`);
}
return "" + text2;
}
function parseQuery(search) {
const query = {};
if (search === "" || search === "?")
return query;
const hasLeadingIM = search[0] === "?";
const searchParams = (hasLeadingIM ? search.slice(1) : search).split("&");
for (let i2 = 0; i2 < searchParams.length; ++i2) {
const searchParam = searchParams[i2].replace(PLUS_RE, " ");
const eqPos = searchParam.indexOf("=");
const key = decode(eqPos < 0 ? searchParam : searchParam.slice(0, eqPos));
const value = eqPos < 0 ? null : decode(searchParam.slice(eqPos + 1));
if (key in query) {
let currentValue = query[key];
if (!isArray(currentValue)) {
currentValue = query[key] = [currentValue];
}
currentValue.push(value);
} else {
query[key] = value;
}
}
return query;
}
function stringifyQuery(query) {
let search = "";
for (let key in query) {
const value = query[key];
key = encodeQueryKey(key);
if (value == null) {
if (value !== void 0) {
search += (search.length ? "&" : "") + key;
}
continue;
}
const values = isArray(value) ? value.map((v2) => v2 && encodeQueryValue(v2)) : [value && encodeQueryValue(value)];
values.forEach((value2) => {
if (value2 !== void 0) {
search += (search.length ? "&" : "") + key;
if (value2 != null)
search += "=" + value2;
}
});
}
return search;
}
function normalizeQuery(query) {
const normalizedQuery = {};
for (const key in query) {
const value = query[key];
if (value !== void 0) {
normalizedQuery[key] = isArray(value) ? value.map((v2) => v2 == null ? null : "" + v2) : value == null ? value : "" + value;
}
}
return normalizedQuery;
}
const matchedRouteKey = Symbol("router view location matched");
const viewDepthKey = Symbol("router view depth");
const routerKey = Symbol("router");
const routeLocationKey = Symbol("route location");
const routerViewLocationKey = Symbol("router view location");
function useCallbacks() {
let handlers2 = [];
function add2(handler) {
handlers2.push(handler);
return () => {
const i2 = handlers2.indexOf(handler);
if (i2 > -1)
handlers2.splice(i2, 1);
};
}
function reset() {
handlers2 = [];
}
return {
add: add2,
list: () => handlers2.slice(),
reset
};
}
function guardToPromiseFn(guard, to2, from, record, name) {
const enterCallbackArray = record && // name is defined if record is because of the function overload
(record.enterCallbacks[name] = record.enterCallbacks[name] || []);
return () => new Promise((resolve2, reject) => {
const next = (valid) => {
if (valid === false) {
reject(createRouterError(4, {
from,
to: to2
}));
} else if (valid instanceof Error) {
reject(valid);
} else if (isRouteLocation(valid)) {
reject(createRouterError(2, {
from: to2,
to: valid
}));
} else {
if (enterCallbackArray && // since enterCallbackArray is truthy, both record and name also are
record.enterCallbacks[name] === enterCallbackArray && typeof valid === "function") {
enterCallbackArray.push(valid);
}
resolve2();
}
};
const guardReturn = guard.call(record && record.instances[name], to2, from, canOnlyBeCalledOnce(next, to2, from));
let guardCall = Promise.resolve(guardReturn);
if (guard.length < 3)
guardCall = guardCall.then(next);
if (guard.length > 2) {
const message = `The "next" callback was never called inside of ${guard.name ? '"' + guard.name + '"' : ""}:
${guard.toString()}
. If you are returning a value instead of calling "next", make sure to remove the "next" parameter from your function.`;
if (typeof guardReturn === "object" && "then" in guardReturn) {
guardCall = guardCall.then((resolvedValue) => {
if (!next._called) {
warn(message);
return Promise.reject(new Error("Invalid navigation guard"));
}
return resolvedValue;
});
} else if (guardReturn !== void 0) {
if (!next._called) {
warn(message);
reject(new Error("Invalid navigation guard"));
return;
}
}
}
guardCall.catch((err) => reject(err));
});
}
function canOnlyBeCalledOnce(next, to2, from) {
let called = 0;
return function() {
if (called++ === 1)
warn(`The "next" callback was called more than once in one navigation guard when going from "${from.fullPath}" to "${to2.fullPath}". It should be called exactly one time in each navigation guard. This will fail in production.`);
next._called = true;
if (called === 1)
next.apply(null, arguments);
};
}
function extractComponentsGuards(matched, guardType, to2, from) {
const guards = [];
for (const record of matched) {
if (!record.components && !record.children.length) {
warn(`Record with path "${record.path}" is either missing a "component(s)" or "children" property.`);
}
for (const name in record.components) {
let rawComponent = record.components[name];
{
if (!rawComponent || typeof rawComponent !== "object" && typeof rawComponent !== "function") {
warn(`Component "${name}" in record with path "${record.path}" is not a valid component. Received "${String(rawComponent)}".`);
throw new Error("Invalid route component");
} else if ("then" in rawComponent) {
warn(`Component "${name}" in record with path "${record.path}" is a Promise instead of a function that returns a Promise. Did you write "import('./MyPage.vue')" instead of "() => import('./MyPage.vue')" ? This will break in production if not fixed.`);
const promise = rawComponent;
rawComponent = () => promise;
} else if (rawComponent.__asyncLoader && // warn only once per component
!rawComponent.__warnedDefineAsync) {
rawComponent.__warnedDefineAsync = true;
warn(`Component "${name}" in record with path "${record.path}" is defined using "defineAsyncComponent()". Write "() => import('./MyPage.vue')" instead of "defineAsyncComponent(() => import('./MyPage.vue'))".`);
}
}
if (guardType !== "beforeRouteEnter" && !record.instances[name])
continue;
if (isRouteComponent(rawComponent)) {
const options = rawComponent.__vccOpts || rawComponent;
const guard = options[guardType];
guard && guards.push(guardToPromiseFn(guard, to2, from, record, name));
} else {
let componentPromise = rawComponent();
if (!("catch" in componentPromise)) {
warn(`Component "${name}" in record with path "${record.path}" is a function that does not return a Promise. If you were passing a functional component, make sure to add a "displayName" to the component. This will break in production if not fixed.`);
componentPromise = Promise.resolve(componentPromise);
}
guards.push(() => componentPromise.then((resolved) => {
if (!resolved)
return Promise.reject(new Error(`Couldn't resolve component "${name}" at "${record.path}"`));
const resolvedComponent = isESModule(resolved) ? resolved.default : resolved;
record.components[name] = resolvedComponent;
const options = resolvedComponent.__vccOpts || resolvedComponent;
const guard = options[guardType];
return guard && guardToPromiseFn(guard, to2, from, record, name)();
}));
}
}
}
return guards;
}
function isRouteComponent(component) {
return typeof component === "object" || "displayName" in component || "props" in component || "__vccOpts" in component;
}
function useLink(props) {
const router = inject(routerKey);
const currentRoute = inject(routeLocationKey);
const route = computed(() => router.resolve(unref(props.to)));
const activeRecordIndex = computed(() => {
const { matched } = route.value;
const { length } = matched;
const routeMatched = matched[length - 1];
const currentMatched = currentRoute.matched;
if (!routeMatched || !currentMatched.length)
return -1;
const index2 = currentMatched.findIndex(isSameRouteRecord.bind(null, routeMatched));
if (index2 > -1)
return index2;
const parentRecordPath = getOriginalPath(matched[length - 2]);
return (
// we are dealing with nested routes
length > 1 && // if the parent and matched route have the same path, this link is
// referring to the empty child. Or we currently are on a different
// child of the same parent
getOriginalPath(routeMatched) === parentRecordPath && // avoid comparing the child with its parent
currentMatched[currentMatched.length - 1].path !== parentRecordPath ? currentMatched.findIndex(isSameRouteRecord.bind(null, matched[length - 2])) : index2
);
});
const isActive = computed(() => activeRecordIndex.value > -1 && includesParams(currentRoute.params, route.value.params));
const isExactActive = computed(() => activeRecordIndex.value > -1 && activeRecordIndex.value === currentRoute.matched.length - 1 && isSameRouteLocationParams(currentRoute.params, route.value.params));
function navigate(e2 = {}) {
if (guardEvent(e2)) {
return router[unref(props.replace) ? "replace" : "push"](
unref(props.to)
// avoid uncaught errors are they are logged anyway
).catch(noop);
}
return Promise.resolve();
}
if (isBrowser) {
const instance = getCurrentInstance();
if (instance) {
const linkContextDevtools = {
route: route.value,
isActive: isActive.value,
isExactActive: isExactActive.value
};
instance.__vrl_devtools = instance.__vrl_devtools || [];
instance.__vrl_devtools.push(linkContextDevtools);
watchEffect(() => {
linkContextDevtools.route = route.value;
linkContextDevtools.isActive = isActive.value;
linkContextDevtools.isExactActive = isExactActive.value;
}, { flush: "post" });
}
}
return {
route,
href: computed(() => route.value.href),
isActive,
isExactActive,
navigate
};
}
const RouterLinkImpl = /* @__PURE__ */ defineComponent({
name: "RouterLink",
compatConfig: { MODE: 3 },
props: {
to: {
type: [String, Object],
required: true
},
replace: Boolean,
activeClass: String,
// inactiveClass: String,
exactActiveClass: String,
custom: Boolean,
ariaCurrentValue: {
type: String,
default: "page"
}
},
useLink,
setup(props, { slots }) {
const link = reactive(useLink(props));
const { options } = inject(routerKey);
const elClass = computed(() => ({
[getLinkClass(props.activeClass, options.linkActiveClass, "router-link-active")]: link.isActive,
// [getLinkClass(
// props.inactiveClass,
// options.linkInactiveClass,
// 'router-link-inactive'
// )]: !link.isExactActive,
[getLinkClass(props.exactActiveClass, options.linkExactActiveClass, "router-link-exact-active")]: link.isExactActive
}));
return () => {
const children2 = slots.default && slots.default(link);
return props.custom ? children2 : h$2("a", {
"aria-current": link.isExactActive ? props.ariaCurrentValue : null,
href: link.href,
// this would override user added attrs but Vue will still add
// the listener, so we end up triggering both
onClick: link.navigate,
class: elClass.value
}, children2);
};
}
});
const RouterLink = RouterLinkImpl;
function guardEvent(e2) {
if (e2.metaKey || e2.altKey || e2.ctrlKey || e2.shiftKey)
return;
if (e2.defaultPrevented)
return;
if (e2.button !== void 0 && e2.button !== 0)
return;
if (e2.currentTarget && e2.currentTarget.getAttribute) {
const target = e2.currentTarget.getAttribute("target");
if (/\b_blank\b/i.test(target))
return;
}
if (e2.preventDefault)
e2.preventDefault();
return true;
}
function includesParams(outer, inner) {
for (const key in inner) {
const innerValue = inner[key];
const outerValue = outer[key];
if (typeof innerValue === "string") {
if (innerValue !== outerValue)
return false;
} else {
if (!isArray(outerValue) || outerValue.length !== innerValue.length || innerValue.some((value, i2) => value !== outerValue[i2]))
return false;
}
}
return true;
}
function getOriginalPath(record) {
return record ? record.aliasOf ? record.aliasOf.path : record.path : "";
}
const getLinkClass = (propClass, globalClass, defaultClass) => propClass != null ? propClass : globalClass != null ? globalClass : defaultClass;
const RouterViewImpl = /* @__PURE__ */ defineComponent({
name: "RouterView",
// #674 we manually inherit them
inheritAttrs: false,
props: {
name: {
type: String,
default: "default"
},
route: Object
},
// Better compat for @vue/compat users
// https://github.com/vuejs/router/issues/1315
compatConfig: { MODE: 3 },
setup(props, { attrs, slots }) {
warnDeprecatedUsage();
const injectedRoute = inject(routerViewLocationKey);
const routeToDisplay = computed(() => props.route || injectedRoute.value);
const injectedDepth = inject(viewDepthKey, 0);
const depth = computed(() => {
let initialDepth = unref(injectedDepth);
const { matched } = routeToDisplay.value;
let matchedRoute;
while ((matchedRoute = matched[initialDepth]) && !matchedRoute.components) {
initialDepth++;
}
return initialDepth;
});
const matchedRouteRef = computed(() => routeToDisplay.value.matched[depth.value]);
provide(viewDepthKey, computed(() => depth.value + 1));
provide(matchedRouteKey, matchedRouteRef);
provide(routerViewLocationKey, routeToDisplay);
const viewRef = ref();
watch(() => [viewRef.value, matchedRouteRef.value, props.name], ([instance, to2, name], [oldInstance, from, oldName]) => {
if (to2) {
to2.instances[name] = instance;
if (from && from !== to2 && instance && instance === oldInstance) {
if (!to2.leaveGuards.size) {
to2.leaveGuards = from.leaveGuards;
}
if (!to2.updateGuards.size) {
to2.updateGuards = from.updateGuards;
}
}
}
if (instance && to2 && // if there is no instance but to and from are the same this might be
// the first visit
(!from || !isSameRouteRecord(to2, from) || !oldInstance)) {
(to2.enterCallbacks[name] || []).forEach((callback) => callback(instance));
}
}, { flush: "post" });
return () => {
const route = routeToDisplay.value;
const currentName = props.name;
const matchedRoute = matchedRouteRef.value;
const ViewComponent = matchedRoute && matchedRoute.components[currentName];
if (!ViewComponent) {
return normalizeSlot(slots.default, { Component: ViewComponent, route });
}
const routePropsOption = matchedRoute.props[currentName];
const routeProps = routePropsOption ? routePropsOption === true ? route.params : typeof routePropsOption === "function" ? routePropsOption(route) : routePropsOption : null;
const onVnodeUnmounted = (vnode) => {
if (vnode.component.isUnmounted) {
matchedRoute.instances[currentName] = null;
}
};
const component = h$2(ViewComponent, assign({}, routeProps, attrs, {
onVnodeUnmounted,
ref: viewRef
}));
if (isBrowser && component.ref) {
const info = {
depth: depth.value,
name: matchedRoute.name,
path: matchedRoute.path,
meta: matchedRoute.meta
};
const internalInstances = isArray(component.ref) ? component.ref.map((r2) => r2.i) : [component.ref.i];
internalInstances.forEach((instance) => {
instance.__vrv_devtools = info;
});
}
return (
// pass the vnode to the slot as a prop.
// h and <component :is="..."> both accept vnodes
normalizeSlot(slots.default, { Component: component, route }) || component
);
};
}
});
function normalizeSlot(slot, data) {
if (!slot)
return null;
const slotContent = slot(data);
return slotContent.length === 1 ? slotContent[0] : slotContent;
}
const RouterView = RouterViewImpl;
function warnDeprecatedUsage() {
const instance = getCurrentInstance();
const parentName = instance.parent && instance.parent.type.name;
const parentSubTreeType = instance.parent && instance.parent.subTree && instance.parent.subTree.type;
if (parentName && (parentName === "KeepAlive" || parentName.includes("Transition")) && typeof parentSubTreeType === "object" && parentSubTreeType.name === "RouterView") {
const comp = parentName === "KeepAlive" ? "keep-alive" : "transition";
warn(`<router-view> can no longer be used directly inside <transition> or <keep-alive>.
Use slot props instead:
<router-view v-slot="{ Component }">
<${comp}>
<component :is="Component" />
</${comp}>
</router-view>`);
}
}
function formatRouteLocation(routeLocation, tooltip) {
const copy = assign({}, routeLocation, {
// remove variables that can contain vue instances
matched: routeLocation.matched.map((matched) => omit$1(matched, ["instances", "children", "aliasOf"]))
});
return {
_custom: {
type: null,
readOnly: true,
display: routeLocation.fullPath,
tooltip,
value: copy
}
};
}
function formatDisplay(display) {
return {
_custom: {
display
}
};
}
let routerId = 0;
function addDevtools(app, router, matcher) {
if (router.__hasDevtools)
return;
router.__hasDevtools = true;
const id2 = routerId++;
setupDevtoolsPlugin({
id: "org.vuejs.router" + (id2 ? "." + id2 : ""),
label: "Vue Router",
packageName: "vue-router",
homepage: "https://router.vuejs.org",
logo: "https://router.vuejs.org/logo.png",
componentStateTypes: ["Routing"],
app
}, (api) => {
if (typeof api.now !== "function") {
console.warn("[Vue Router]: You seem to be using an outdated version of Vue Devtools. Are you still using the Beta release instead of the stable one? You can find the links at https://devtools.vuejs.org/guide/installation.html.");
}
api.on.inspectComponent((payload, ctx) => {
if (payload.instanceData) {
payload.instanceData.state.push({
type: "Routing",
key: "$route",
editable: false,
value: formatRouteLocation(router.currentRoute.value, "Current Route")
});
}
});
api.on.visitComponentTree(({ treeNode: node, componentInstance }) => {
if (componentInstance.__vrv_devtools) {
const info = componentInstance.__vrv_devtools;
node.tags.push({
label: (info.name ? `${info.name.toString()}: ` : "") + info.path,
textColor: 0,
tooltip: "This component is rendered by &lt;router-view&gt;",
backgroundColor: PINK_500
});
}
if (isArray(componentInstance.__vrl_devtools)) {
componentInstance.__devtoolsApi = api;
componentInstance.__vrl_devtools.forEach((devtoolsData) => {
let backgroundColor = ORANGE_400;
let tooltip = "";
if (devtoolsData.isExactActive) {
backgroundColor = LIME_500;
tooltip = "This is exactly active";
} else if (devtoolsData.isActive) {
backgroundColor = BLUE_600;
tooltip = "This link is active";
}
node.tags.push({
label: devtoolsData.route.path,
textColor: 0,
tooltip,
backgroundColor
});
});
}
});
watch(router.currentRoute, () => {
refreshRoutesView();
api.notifyComponentUpdate();
api.sendInspectorTree(routerInspectorId);
api.sendInspectorState(routerInspectorId);
});
const navigationsLayerId = "router:navigations:" + id2;
api.addTimelineLayer({
id: navigationsLayerId,
label: `Router${id2 ? " " + id2 : ""} Navigations`,
color: 4237508
});
router.onError((error, to2) => {
api.addTimelineEvent({
layerId: navigationsLayerId,
event: {
title: "Error during Navigation",
subtitle: to2.fullPath,
logType: "error",
time: api.now(),
data: { error },
groupId: to2.meta.__navigationId
}
});
});
let navigationId = 0;
router.beforeEach((to2, from) => {
const data = {
guard: formatDisplay("beforeEach"),
from: formatRouteLocation(from, "Current Location during this navigation"),
to: formatRouteLocation(to2, "Target location")
};
Object.defineProperty(to2.meta, "__navigationId", {
value: navigationId++
});
api.addTimelineEvent({
layerId: navigationsLayerId,
event: {
time: api.now(),
title: "Start of navigation",
subtitle: to2.fullPath,
data,
groupId: to2.meta.__navigationId
}
});
});
router.afterEach((to2, from, failure) => {
const data = {
guard: formatDisplay("afterEach")
};
if (failure) {
data.failure = {
_custom: {
type: Error,
readOnly: true,
display: failure ? failure.message : "",
tooltip: "Navigation Failure",
value: failure
}
};
data.status = formatDisplay("❌");
} else {
data.status = formatDisplay("✅");
}
data.from = formatRouteLocation(from, "Current Location during this navigation");
data.to = formatRouteLocation(to2, "Target location");
api.addTimelineEvent({
layerId: navigationsLayerId,
event: {
title: "End of navigation",
subtitle: to2.fullPath,
time: api.now(),
data,
logType: failure ? "warning" : "default",
groupId: to2.meta.__navigationId
}
});
});
const routerInspectorId = "router-inspector:" + id2;
api.addInspector({
id: routerInspectorId,
label: "Routes" + (id2 ? " " + id2 : ""),
icon: "book",
treeFilterPlaceholder: "Search routes"
});
function refreshRoutesView() {
if (!activeRoutesPayload)
return;
const payload = activeRoutesPayload;
let routes = matcher.getRoutes().filter((route) => !route.parent || // these routes have a parent with no component which will not appear in the view
// therefore we still need to include them
!route.parent.record.components);
routes.forEach(resetMatchStateOnRouteRecord);
if (payload.filter) {
routes = routes.filter((route) => (
// save matches state based on the payload
isRouteMatching(route, payload.filter.toLowerCase())
));
}
routes.forEach((route) => markRouteRecordActive(route, router.currentRoute.value));
payload.rootNodes = routes.map(formatRouteRecordForInspector);
}
let activeRoutesPayload;
api.on.getInspectorTree((payload) => {
activeRoutesPayload = payload;
if (payload.app === app && payload.inspectorId === routerInspectorId) {
refreshRoutesView();
}
});
api.on.getInspectorState((payload) => {
if (payload.app === app && payload.inspectorId === routerInspectorId) {
const routes = matcher.getRoutes();
const route = routes.find((route2) => route2.record.__vd_id === payload.nodeId);
if (route) {
payload.state = {
options: formatRouteRecordMatcherForStateInspector(route)
};
}
}
});
api.sendInspectorTree(routerInspectorId);
api.sendInspectorState(routerInspectorId);
});
}
function modifierForKey(key) {
if (key.optional) {
return key.repeatable ? "*" : "?";
} else {
return key.repeatable ? "+" : "";
}
}
function formatRouteRecordMatcherForStateInspector(route) {
const { record } = route;
const fields = [
{ editable: false, key: "path", value: record.path }
];
if (record.name != null) {
fields.push({
editable: false,
key: "name",
value: record.name
});
}
fields.push({ editable: false, key: "regexp", value: route.re });
if (route.keys.length) {
fields.push({
editable: false,
key: "keys",
value: {
_custom: {
type: null,
readOnly: true,
display: route.keys.map((key) => `${key.name}${modifierForKey(key)}`).join(" "),
tooltip: "Param keys",
value: route.keys
}
}
});
}
if (record.redirect != null) {
fields.push({
editable: false,
key: "redirect",
value: record.redirect
});
}
if (route.alias.length) {
fields.push({
editable: false,
key: "aliases",
value: route.alias.map((alias) => alias.record.path)
});
}
if (Object.keys(route.record.meta).length) {
fields.push({
editable: false,
key: "meta",
value: route.record.meta
});
}
fields.push({
key: "score",
editable: false,
value: {
_custom: {
type: null,
readOnly: true,
display: route.score.map((score) => score.join(", ")).join(" | "),
tooltip: "Score used to sort routes",
value: route.score
}
}
});
return fields;
}
const PINK_500 = 15485081;
const BLUE_600 = 2450411;
const LIME_500 = 8702998;
const CYAN_400 = 2282478;
const ORANGE_400 = 16486972;
const DARK = 6710886;
function formatRouteRecordForInspector(route) {
const tags = [];
const { record } = route;
if (record.name != null) {
tags.push({
label: String(record.name),
textColor: 0,
backgroundColor: CYAN_400
});
}
if (record.aliasOf) {
tags.push({
label: "alias",
textColor: 0,
backgroundColor: ORANGE_400
});
}
if (route.__vd_match) {
tags.push({
label: "matches",
textColor: 0,
backgroundColor: PINK_500
});
}
if (route.__vd_exactActive) {
tags.push({
label: "exact",
textColor: 0,
backgroundColor: LIME_500
});
}
if (route.__vd_active) {
tags.push({
label: "active",
textColor: 0,
backgroundColor: BLUE_600
});
}
if (record.redirect) {
tags.push({
label: typeof record.redirect === "string" ? `redirect: ${record.redirect}` : "redirects",
textColor: 16777215,
backgroundColor: DARK
});
}
let id2 = record.__vd_id;
if (id2 == null) {
id2 = String(routeRecordId++);
record.__vd_id = id2;
}
return {
id: id2,
label: record.path,
tags,
children: route.children.map(formatRouteRecordForInspector)
};
}
let routeRecordId = 0;
const EXTRACT_REGEXP_RE = /^\/(.*)\/([a-z]*)$/;
function markRouteRecordActive(route, currentRoute) {
const isExactActive = currentRoute.matched.length && isSameRouteRecord(currentRoute.matched[currentRoute.matched.length - 1], route.record);
route.__vd_exactActive = route.__vd_active = isExactActive;
if (!isExactActive) {
route.__vd_active = currentRoute.matched.some((match) => isSameRouteRecord(match, route.record));
}
route.children.forEach((childRoute) => markRouteRecordActive(childRoute, currentRoute));
}
function resetMatchStateOnRouteRecord(route) {
route.__vd_match = false;
route.children.forEach(resetMatchStateOnRouteRecord);
}
function isRouteMatching(route, filter) {
const found = String(route.re).match(EXTRACT_REGEXP_RE);
route.__vd_match = false;
if (!found || found.length < 3) {
return false;
}
const nonEndingRE = new RegExp(found[1].replace(/\$$/, ""), found[2]);
if (nonEndingRE.test(filter)) {
route.children.forEach((child) => isRouteMatching(child, filter));
if (route.record.path !== "/" || filter === "/") {
route.__vd_match = route.re.test(filter);
return true;
}
return false;
}
const path = route.record.path.toLowerCase();
const decodedPath = decode(path);
if (!filter.startsWith("/") && (decodedPath.includes(filter) || path.includes(filter)))
return true;
if (decodedPath.startsWith(filter) || path.startsWith(filter))
return true;
if (route.record.name && String(route.record.name).includes(filter))
return true;
return route.children.some((child) => isRouteMatching(child, filter));
}
function omit$1(obj, keys) {
const ret = {};
for (const key in obj) {
if (!keys.includes(key)) {
ret[key] = obj[key];
}
}
return ret;
}
function createRouter(options) {
const matcher = createRouterMatcher(options.routes, options);
const parseQuery$1 = options.parseQuery || parseQuery;
const stringifyQuery$1 = options.stringifyQuery || stringifyQuery;
const routerHistory = options.history;
if (!routerHistory)
throw new Error('Provide the "history" option when calling "createRouter()": https://next.router.vuejs.org/api/#history.');
const beforeGuards = useCallbacks();
const beforeResolveGuards = useCallbacks();
const afterGuards = useCallbacks();
const currentRoute = shallowRef(START_LOCATION_NORMALIZED);
let pendingLocation = START_LOCATION_NORMALIZED;
if (isBrowser && options.scrollBehavior && "scrollRestoration" in history) {
history.scrollRestoration = "manual";
}
const normalizeParams = applyToParams.bind(null, (paramValue) => "" + paramValue);
const encodeParams = applyToParams.bind(null, encodeParam);
const decodeParams = (
// @ts-expect-error: intentionally avoid the type check
applyToParams.bind(null, decode)
);
function addRoute(parentOrRoute, route) {
let parent;
let record;
if (isRouteName(parentOrRoute)) {
parent = matcher.getRecordMatcher(parentOrRoute);
record = route;
} else {
record = parentOrRoute;
}
return matcher.addRoute(record, parent);
}
function removeRoute(name) {
const recordMatcher = matcher.getRecordMatcher(name);
if (recordMatcher) {
matcher.removeRoute(recordMatcher);
} else {
warn(`Cannot remove non-existent route "${String(name)}"`);
}
}
function getRoutes() {
return matcher.getRoutes().map((routeMatcher) => routeMatcher.record);
}
function hasRoute(name) {
return !!matcher.getRecordMatcher(name);
}
function resolve2(rawLocation, currentLocation) {
currentLocation = assign({}, currentLocation || currentRoute.value);
if (typeof rawLocation === "string") {
const locationNormalized = parseURL(parseQuery$1, rawLocation, currentLocation.path);
const matchedRoute2 = matcher.resolve({ path: locationNormalized.path }, currentLocation);
const href2 = routerHistory.createHref(locationNormalized.fullPath);
{
if (href2.startsWith("//"))
warn(`Location "${rawLocation}" resolved to "${href2}". A resolved location cannot start with multiple slashes.`);
else if (!matchedRoute2.matched.length) {
warn(`No match found for location with path "${rawLocation}"`);
}
}
return assign(locationNormalized, matchedRoute2, {
params: decodeParams(matchedRoute2.params),
hash: decode(locationNormalized.hash),
redirectedFrom: void 0,
href: href2
});
}
let matcherLocation;
if ("path" in rawLocation) {
if ("params" in rawLocation && !("name" in rawLocation) && // @ts-expect-error: the type is never
Object.keys(rawLocation.params).length) {
warn(`Path "${rawLocation.path}" was passed with params but they will be ignored. Use a named route alongside params instead.`);
}
matcherLocation = assign({}, rawLocation, {
path: parseURL(parseQuery$1, rawLocation.path, currentLocation.path).path
});
} else {
const targetParams = assign({}, rawLocation.params);
for (const key in targetParams) {
if (targetParams[key] == null) {
delete targetParams[key];
}
}
matcherLocation = assign({}, rawLocation, {
params: encodeParams(targetParams)
});
currentLocation.params = encodeParams(currentLocation.params);
}
const matchedRoute = matcher.resolve(matcherLocation, currentLocation);
const hash2 = rawLocation.hash || "";
if (hash2 && !hash2.startsWith("#")) {
warn(`A \`hash\` should always start with the character "#". Replace "${hash2}" with "#${hash2}".`);
}
matchedRoute.params = normalizeParams(decodeParams(matchedRoute.params));
const fullPath = stringifyURL(stringifyQuery$1, assign({}, rawLocation, {
hash: encodeHash(hash2),
path: matchedRoute.path
}));
const href = routerHistory.createHref(fullPath);
{
if (href.startsWith("//")) {
warn(`Location "${rawLocation}" resolved to "${href}". A resolved location cannot start with multiple slashes.`);
} else if (!matchedRoute.matched.length) {
warn(`No match found for location with path "${"path" in rawLocation ? rawLocation.path : rawLocation}"`);
}
}
return assign({
fullPath,
// keep the hash encoded so fullPath is effectively path + encodedQuery +
// hash
hash: hash2,
query: (
// if the user is using a custom query lib like qs, we might have
// nested objects, so we keep the query as is, meaning it can contain
// numbers at `$route.query`, but at the point, the user will have to
// use their own type anyway.
// https://github.com/vuejs/router/issues/328#issuecomment-649481567
stringifyQuery$1 === stringifyQuery ? normalizeQuery(rawLocation.query) : rawLocation.query || {}
)
}, matchedRoute, {
redirectedFrom: void 0,
href
});
}
function locationAsObject(to2) {
return typeof to2 === "string" ? parseURL(parseQuery$1, to2, currentRoute.value.path) : assign({}, to2);
}
function checkCanceledNavigation(to2, from) {
if (pendingLocation !== to2) {
return createRouterError(8, {
from,
to: to2
});
}
}
function push(to2) {
return pushWithRedirect(to2);
}
function replace(to2) {
return push(assign(locationAsObject(to2), { replace: true }));
}
function handleRedirectRecord(to2) {
const lastMatched = to2.matched[to2.matched.length - 1];
if (lastMatched && lastMatched.redirect) {
const { redirect } = lastMatched;
let newTargetLocation = typeof redirect === "function" ? redirect(to2) : redirect;
if (typeof newTargetLocation === "string") {
newTargetLocation = newTargetLocation.includes("?") || newTargetLocation.includes("#") ? newTargetLocation = locationAsObject(newTargetLocation) : (
// force empty params
{ path: newTargetLocation }
);
newTargetLocation.params = {};
}
if (!("path" in newTargetLocation) && !("name" in newTargetLocation)) {
warn(`Invalid redirect found:
${JSON.stringify(newTargetLocation, null, 2)}
when navigating to "${to2.fullPath}". A redirect must contain a name or path. This will break in production.`);
throw new Error("Invalid redirect");
}
return assign({
query: to2.query,
hash: to2.hash,
// avoid transferring params if the redirect has a path
params: "path" in newTargetLocation ? {} : to2.params
}, newTargetLocation);
}
}
function pushWithRedirect(to2, redirectedFrom) {
const targetLocation = pendingLocation = resolve2(to2);
const from = currentRoute.value;
const data = to2.state;
const force = to2.force;
const replace2 = to2.replace === true;
const shouldRedirect = handleRedirectRecord(targetLocation);
if (shouldRedirect)
return pushWithRedirect(
assign(locationAsObject(shouldRedirect), {
state: typeof shouldRedirect === "object" ? assign({}, data, shouldRedirect.state) : data,
force,
replace: replace2
}),
// keep original redirectedFrom if it exists
redirectedFrom || targetLocation
);
const toLocation = targetLocation;
toLocation.redirectedFrom = redirectedFrom;
let failure;
if (!force && isSameRouteLocation(stringifyQuery$1, from, targetLocation)) {
failure = createRouterError(16, { to: toLocation, from });
handleScroll(
from,
from,
// this is a push, the only way for it to be triggered from a
// history.listen is with a redirect, which makes it become a push
true,
// This cannot be the first navigation because the initial location
// cannot be manually navigated to
false
);
}
return (failure ? Promise.resolve(failure) : navigate(toLocation, from)).catch((error) => isNavigationFailure(error) ? (
// navigation redirects still mark the router as ready
isNavigationFailure(
error,
2
/* ErrorTypes.NAVIGATION_GUARD_REDIRECT */
) ? error : markAsReady(error)
) : (
// reject any unknown error
triggerError(error, toLocation, from)
)).then((failure2) => {
if (failure2) {
if (isNavigationFailure(
failure2,
2
/* ErrorTypes.NAVIGATION_GUARD_REDIRECT */
)) {
if (
// we are redirecting to the same location we were already at
isSameRouteLocation(stringifyQuery$1, resolve2(failure2.to), toLocation) && // and we have done it a couple of times
redirectedFrom && // @ts-expect-error: added only in dev
(redirectedFrom._count = redirectedFrom._count ? (
// @ts-expect-error
redirectedFrom._count + 1
) : 1) > 30
) {
warn(`Detected a possibly infinite redirection in a navigation guard when going from "${from.fullPath}" to "${toLocation.fullPath}". Aborting to avoid a Stack Overflow.
Are you always returning a new location within a navigation guard? That would lead to this error. Only return when redirecting or aborting, that should fix this. This might break in production if not fixed.`);
return Promise.reject(new Error("Infinite redirect in navigation guard"));
}
return pushWithRedirect(
// keep options
assign({
// preserve an existing replacement but allow the redirect to override it
replace: replace2
}, locationAsObject(failure2.to), {
state: typeof failure2.to === "object" ? assign({}, data, failure2.to.state) : data,
force
}),
// preserve the original redirectedFrom if any
redirectedFrom || toLocation
);
}
} else {
failure2 = finalizeNavigation(toLocation, from, true, replace2, data);
}
triggerAfterEach(toLocation, from, failure2);
return failure2;
});
}
function checkCanceledNavigationAndReject(to2, from) {
const error = checkCanceledNavigation(to2, from);
return error ? Promise.reject(error) : Promise.resolve();
}
function runWithContext(fn2) {
const app = installedApps.values().next().value;
return app && typeof app.runWithContext === "function" ? app.runWithContext(fn2) : fn2();
}
function navigate(to2, from) {
let guards;
const [leavingRecords, updatingRecords, enteringRecords] = extractChangingRecords(to2, from);
guards = extractComponentsGuards(leavingRecords.reverse(), "beforeRouteLeave", to2, from);
for (const record of leavingRecords) {
record.leaveGuards.forEach((guard) => {
guards.push(guardToPromiseFn(guard, to2, from));
});
}
const canceledNavigationCheck = checkCanceledNavigationAndReject.bind(null, to2, from);
guards.push(canceledNavigationCheck);
return runGuardQueue(guards).then(() => {
guards = [];
for (const guard of beforeGuards.list()) {
guards.push(guardToPromiseFn(guard, to2, from));
}
guards.push(canceledNavigationCheck);
return runGuardQueue(guards);
}).then(() => {
guards = extractComponentsGuards(updatingRecords, "beforeRouteUpdate", to2, from);
for (const record of updatingRecords) {
record.updateGuards.forEach((guard) => {
guards.push(guardToPromiseFn(guard, to2, from));
});
}
guards.push(canceledNavigationCheck);
return runGuardQueue(guards);
}).then(() => {
guards = [];
for (const record of enteringRecords) {
if (record.beforeEnter) {
if (isArray(record.beforeEnter)) {
for (const beforeEnter of record.beforeEnter)
guards.push(guardToPromiseFn(beforeEnter, to2, from));
} else {
guards.push(guardToPromiseFn(record.beforeEnter, to2, from));
}
}
}
guards.push(canceledNavigationCheck);
return runGuardQueue(guards);
}).then(() => {
to2.matched.forEach((record) => record.enterCallbacks = {});
guards = extractComponentsGuards(enteringRecords, "beforeRouteEnter", to2, from);
guards.push(canceledNavigationCheck);
return runGuardQueue(guards);
}).then(() => {
guards = [];
for (const guard of beforeResolveGuards.list()) {
guards.push(guardToPromiseFn(guard, to2, from));
}
guards.push(canceledNavigationCheck);
return runGuardQueue(guards);
}).catch((err) => isNavigationFailure(
err,
8
/* ErrorTypes.NAVIGATION_CANCELLED */
) ? err : Promise.reject(err));
}
function triggerAfterEach(to2, from, failure) {
afterGuards.list().forEach((guard) => runWithContext(() => guard(to2, from, failure)));
}
function finalizeNavigation(toLocation, from, isPush, replace2, data) {
const error = checkCanceledNavigation(toLocation, from);
if (error)
return error;
const isFirstNavigation = from === START_LOCATION_NORMALIZED;
const state = !isBrowser ? {} : history.state;
if (isPush) {
if (replace2 || isFirstNavigation)
routerHistory.replace(toLocation.fullPath, assign({
scroll: isFirstNavigation && state && state.scroll
}, data));
else
routerHistory.push(toLocation.fullPath, data);
}
currentRoute.value = toLocation;
handleScroll(toLocation, from, isPush, isFirstNavigation);
markAsReady();
}
let removeHistoryListener;
function setupListeners() {
if (removeHistoryListener)
return;
removeHistoryListener = routerHistory.listen((to2, _from, info) => {
if (!router.listening)
return;
const toLocation = resolve2(to2);
const shouldRedirect = handleRedirectRecord(toLocation);
if (shouldRedirect) {
pushWithRedirect(assign(shouldRedirect, { replace: true }), toLocation).catch(noop);
return;
}
pendingLocation = toLocation;
const from = currentRoute.value;
if (isBrowser) {
saveScrollPosition(getScrollKey(from.fullPath, info.delta), computeScrollPosition());
}
navigate(toLocation, from).catch((error) => {
if (isNavigationFailure(
error,
4 | 8
/* ErrorTypes.NAVIGATION_CANCELLED */
)) {
return error;
}
if (isNavigationFailure(
error,
2
/* ErrorTypes.NAVIGATION_GUARD_REDIRECT */
)) {
pushWithRedirect(
error.to,
toLocation
// avoid an uncaught rejection, let push call triggerError
).then((failure) => {
if (isNavigationFailure(
failure,
4 | 16
/* ErrorTypes.NAVIGATION_DUPLICATED */
) && !info.delta && info.type === NavigationType.pop) {
routerHistory.go(-1, false);
}
}).catch(noop);
return Promise.reject();
}
if (info.delta) {
routerHistory.go(-info.delta, false);
}
return triggerError(error, toLocation, from);
}).then((failure) => {
failure = failure || finalizeNavigation(
// after navigation, all matched components are resolved
toLocation,
from,
false
);
if (failure) {
if (info.delta && // a new navigation has been triggered, so we do not want to revert, that will change the current history
// entry while a different route is displayed
!isNavigationFailure(
failure,
8
/* ErrorTypes.NAVIGATION_CANCELLED */
)) {
routerHistory.go(-info.delta, false);
} else if (info.type === NavigationType.pop && isNavigationFailure(
failure,
4 | 16
/* ErrorTypes.NAVIGATION_DUPLICATED */
)) {
routerHistory.go(-1, false);
}
}
triggerAfterEach(toLocation, from, failure);
}).catch(noop);
});
}
let readyHandlers = useCallbacks();
let errorListeners = useCallbacks();
let ready;
function triggerError(error, to2, from) {
markAsReady(error);
const list = errorListeners.list();
if (list.length) {
list.forEach((handler) => handler(error, to2, from));
} else {
{
warn("uncaught error during route navigation:");
}
console.error(error);
}
return Promise.reject(error);
}
function isReady() {
if (ready && currentRoute.value !== START_LOCATION_NORMALIZED)
return Promise.resolve();
return new Promise((resolve22, reject) => {
readyHandlers.add([resolve22, reject]);
});
}
function markAsReady(err) {
if (!ready) {
ready = !err;
setupListeners();
readyHandlers.list().forEach(([resolve22, reject]) => err ? reject(err) : resolve22());
readyHandlers.reset();
}
return err;
}
function handleScroll(to2, from, isPush, isFirstNavigation) {
const { scrollBehavior } = options;
if (!isBrowser || !scrollBehavior)
return Promise.resolve();
const scrollPosition = !isPush && getSavedScrollPosition(getScrollKey(to2.fullPath, 0)) || (isFirstNavigation || !isPush) && history.state && history.state.scroll || null;
return nextTick().then(() => scrollBehavior(to2, from, scrollPosition)).then((position) => position && scrollToPosition(position)).catch((err) => triggerError(err, to2, from));
}
const go2 = (delta) => routerHistory.go(delta);
let started;
const installedApps = /* @__PURE__ */ new Set();
const router = {
currentRoute,
listening: true,
addRoute,
removeRoute,
hasRoute,
getRoutes,
resolve: resolve2,
options,
push,
replace,
go: go2,
back: () => go2(-1),
forward: () => go2(1),
beforeEach: beforeGuards.add,
beforeResolve: beforeResolveGuards.add,
afterEach: afterGuards.add,
onError: errorListeners.add,
isReady,
install(app) {
const router2 = this;
app.component("RouterLink", RouterLink);
app.component("RouterView", RouterView);
app.config.globalProperties.$router = router2;
Object.defineProperty(app.config.globalProperties, "$route", {
enumerable: true,
get: () => unref(currentRoute)
});
if (isBrowser && // used for the initial navigation client side to avoid pushing
// multiple times when the router is used in multiple apps
!started && currentRoute.value === START_LOCATION_NORMALIZED) {
started = true;
push(routerHistory.location).catch((err) => {
warn("Unexpected error when starting the router:", err);
});
}
const reactiveRoute = {};
for (const key in START_LOCATION_NORMALIZED) {
Object.defineProperty(reactiveRoute, key, {
get: () => currentRoute.value[key],
enumerable: true
});
}
app.provide(routerKey, router2);
app.provide(routeLocationKey, shallowReactive(reactiveRoute));
app.provide(routerViewLocationKey, currentRoute);
const unmountApp = app.unmount;
installedApps.add(app);
app.unmount = function() {
installedApps.delete(app);
if (installedApps.size < 1) {
pendingLocation = START_LOCATION_NORMALIZED;
removeHistoryListener && removeHistoryListener();
removeHistoryListener = null;
currentRoute.value = START_LOCATION_NORMALIZED;
started = false;
ready = false;
}
unmountApp();
};
if (isBrowser) {
addDevtools(app, router2, matcher);
}
}
};
function runGuardQueue(guards) {
return guards.reduce((promise, guard) => promise.then(() => runWithContext(guard)), Promise.resolve());
}
return router;
}
function extractChangingRecords(to2, from) {
const leavingRecords = [];
const updatingRecords = [];
const enteringRecords = [];
const len = Math.max(from.matched.length, to2.matched.length);
for (let i2 = 0; i2 < len; i2++) {
const recordFrom = from.matched[i2];
if (recordFrom) {
if (to2.matched.find((record) => isSameRouteRecord(record, recordFrom)))
updatingRecords.push(recordFrom);
else
leavingRecords.push(recordFrom);
}
const recordTo = to2.matched[i2];
if (recordTo) {
if (!from.matched.find((record) => isSameRouteRecord(record, recordTo))) {
enteringRecords.push(recordTo);
}
}
}
return [leavingRecords, updatingRecords, enteringRecords];
}
function useRouter() {
return inject(routerKey);
}
function useRoute() {
return inject(routeLocationKey);
}
function t(t2) {
return "object" == typeof t2 && null != t2 && 1 === t2.nodeType;
}
function e$1(t2, e2) {
return (!e2 || "hidden" !== t2) && "visible" !== t2 && "clip" !== t2;
}
function n(t2, n2) {
if (t2.clientHeight < t2.scrollHeight || t2.clientWidth < t2.scrollWidth) {
var r2 = getComputedStyle(t2, null);
return e$1(r2.overflowY, n2) || e$1(r2.overflowX, n2) || function(t3) {
var e2 = function(t4) {
if (!t4.ownerDocument || !t4.ownerDocument.defaultView)
return null;
try {
return t4.ownerDocument.defaultView.frameElement;
} catch (t5) {
return null;
}
}(t3);
return !!e2 && (e2.clientHeight < t3.scrollHeight || e2.clientWidth < t3.scrollWidth);
}(t2);
}
return false;
}
function r$1(t2, e2, n2, r2, i2, o, l, d2) {
return o < t2 && l > e2 || o > t2 && l < e2 ? 0 : o <= t2 && d2 <= n2 || l >= e2 && d2 >= n2 ? o - t2 - r2 : l > e2 && d2 < n2 || o < t2 && d2 > n2 ? l - e2 + i2 : 0;
}
var i = function(e2, i2) {
var o = window, l = i2.scrollMode, d2 = i2.block, f2 = i2.inline, h2 = i2.boundary, u2 = i2.skipOverflowHiddenElements, s = "function" == typeof h2 ? h2 : function(t2) {
return t2 !== h2;
};
if (!t(e2))
throw new TypeError("Invalid target");
for (var a2, c2, g = document.scrollingElement || document.documentElement, p2 = [], m = e2; t(m) && s(m); ) {
if ((m = null == (c2 = (a2 = m).parentElement) ? a2.getRootNode().host || null : c2) === g) {
p2.push(m);
break;
}
null != m && m === document.body && n(m) && !n(document.documentElement) || null != m && n(m, u2) && p2.push(m);
}
for (var w2 = o.visualViewport ? o.visualViewport.width : innerWidth, v2 = o.visualViewport ? o.visualViewport.height : innerHeight, W2 = window.scrollX || pageXOffset, H4 = window.scrollY || pageYOffset, b3 = e2.getBoundingClientRect(), y2 = b3.height, E2 = b3.width, M2 = b3.top, V2 = b3.right, x2 = b3.bottom, I2 = b3.left, C2 = "start" === d2 || "nearest" === d2 ? M2 : "end" === d2 ? x2 : M2 + y2 / 2, R3 = "center" === f2 ? I2 + E2 / 2 : "end" === f2 ? V2 : I2, T2 = [], k2 = 0; k2 < p2.length; k2++) {
var B2 = p2[k2], D3 = B2.getBoundingClientRect(), O3 = D3.height, X2 = D3.width, Y2 = D3.top, L2 = D3.right, S2 = D3.bottom, j2 = D3.left;
if ("if-needed" === l && M2 >= 0 && I2 >= 0 && x2 <= v2 && V2 <= w2 && M2 >= Y2 && x2 <= S2 && I2 >= j2 && V2 <= L2)
return T2;
var N3 = getComputedStyle(B2), q3 = parseInt(N3.borderLeftWidth, 10), z3 = parseInt(N3.borderTopWidth, 10), A2 = parseInt(N3.borderRightWidth, 10), F2 = parseInt(N3.borderBottomWidth, 10), G2 = 0, J3 = 0, K2 = "offsetWidth" in B2 ? B2.offsetWidth - B2.clientWidth - q3 - A2 : 0, P2 = "offsetHeight" in B2 ? B2.offsetHeight - B2.clientHeight - z3 - F2 : 0, Q2 = "offsetWidth" in B2 ? 0 === B2.offsetWidth ? 0 : X2 / B2.offsetWidth : 0, U2 = "offsetHeight" in B2 ? 0 === B2.offsetHeight ? 0 : O3 / B2.offsetHeight : 0;
if (g === B2)
G2 = "start" === d2 ? C2 : "end" === d2 ? C2 - v2 : "nearest" === d2 ? r$1(H4, H4 + v2, v2, z3, F2, H4 + C2, H4 + C2 + y2, y2) : C2 - v2 / 2, J3 = "start" === f2 ? R3 : "center" === f2 ? R3 - w2 / 2 : "end" === f2 ? R3 - w2 : r$1(W2, W2 + w2, w2, q3, A2, W2 + R3, W2 + R3 + E2, E2), G2 = Math.max(0, G2 + H4), J3 = Math.max(0, J3 + W2);
else {
G2 = "start" === d2 ? C2 - Y2 - z3 : "end" === d2 ? C2 - S2 + F2 + P2 : "nearest" === d2 ? r$1(Y2, S2, O3, z3, F2 + P2, C2, C2 + y2, y2) : C2 - (Y2 + O3 / 2) + P2 / 2, J3 = "start" === f2 ? R3 - j2 - q3 : "center" === f2 ? R3 - (j2 + X2 / 2) + K2 / 2 : "end" === f2 ? R3 - L2 + A2 + K2 : r$1(j2, L2, X2, q3, A2 + K2, R3, R3 + E2, E2);
var Z3 = B2.scrollLeft, $ = B2.scrollTop;
C2 += $ - (G2 = Math.max(0, Math.min($ + G2 / U2, B2.scrollHeight - O3 / U2 + P2))), R3 += Z3 - (J3 = Math.max(0, Math.min(Z3 + J3 / Q2, B2.scrollWidth - X2 / Q2 + K2)));
}
T2.push({ el: B2, top: G2, left: J3 });
}
return T2;
};
function isOptionsObject(options) {
return options === Object(options) && Object.keys(options).length !== 0;
}
function defaultBehavior(actions, behavior) {
if (behavior === void 0) {
behavior = "auto";
}
var canSmoothScroll = "scrollBehavior" in document.body.style;
actions.forEach(function(_ref) {
var el2 = _ref.el, top = _ref.top, left = _ref.left;
if (el2.scroll && canSmoothScroll) {
el2.scroll({
top,
left,
behavior
});
} else {
el2.scrollTop = top;
el2.scrollLeft = left;
}
});
}
function getOptions(options) {
if (options === false) {
return {
block: "end",
inline: "nearest"
};
}
if (isOptionsObject(options)) {
return options;
}
return {
block: "start",
inline: "nearest"
};
}
function scrollIntoView(target, options) {
var isTargetAttached = target.isConnected || target.ownerDocument.documentElement.contains(target);
if (isOptionsObject(options) && typeof options.behavior === "function") {
return options.behavior(isTargetAttached ? i(target, options) : []);
}
if (!isTargetAttached) {
return;
}
var computeOptions = getOptions(options);
return defaultBehavior(i(target, computeOptions), computeOptions.behavior);
}
const Logo_square = "data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='UTF-8'%20standalone='no'?%3e%3c!--%20Created%20with%20Inkscape%20(http://www.inkscape.org/)%20--%3e%3csvg%20width='512'%20height='512'%20viewBox='0%200%20512%20512'%20version='1.1'%20id='svg5'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:svg='http://www.w3.org/2000/svg'%3e%3cdefs%20id='defs2'%20/%3e%3cg%20id='layer1'%3e%3crect%20style='opacity:0.5;fill:%23ff3e00;fill-opacity:1;stroke-width:1.00375'%20id='rect1372'%20width='314.30923'%20height='406.60901'%20x='-26.565063'%20y='134.75079'%20transform='rotate(-23.821262)'%20ry='8'%20/%3e%3crect%20style='fill:%23ff3e00;fill-opacity:1;stroke-width:1.00375'%20id='rect850'%20width='314.30923'%20height='406.60901'%20x='77.571838'%20y='72.808708'%20ry='8'%20transform='rotate(-4.5744534)'%20/%3e%3c/g%3e%3cg%20id='layer3'%20style='display:inline'%3e%3cpath%20id='path1657-3'%20style='display:inline;fill:%23ffffff;fill-opacity:1;stroke:%23ffffff;stroke-width:8.34923;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1'%20d='M%20359.38947,355.95134%20320.72935,176.52942%20238.34613,238.94118%20Z%20M%20273.64124,273.06608%20152.59788,156.05591%20191.25804,335.47786%20Z'%20/%3e%3c/g%3e%3cg%20id='layer2'%20style='display:none'%3e%3cpath%20id='path1657'%20style='fill:%23b4fae2;fill-opacity:1;stroke:%23b4fae2;stroke-width:8;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1'%20d='m%20296,103.98242%20-135.53125,177.9668%20h%2088.70117%20z%20M%20262.83008,230.05078%20216,408.01758%20351.53125,230.05078%20Z'%20transform='rotate(-4.156553,256,256.00691)'%20/%3e%3c/g%3e%3c/svg%3e";
const Logo_dark = "/assets/histoire-svelte-text-DosH-Q74.svg";
function unindent(code) {
const lines = code.split("\n");
let indentLevel = -1;
let indentText;
const linesToAnalyze = lines.filter((line) => line.trim().length > 0);
for (const line of linesToAnalyze) {
const match = /^\s*/.exec(line);
if (match && (indentLevel === -1 || indentLevel > match[0].length)) {
indentLevel = match[0].length;
indentText = match[0];
}
}
const result = [];
for (const line of lines) {
result.push(line.replace(indentText, ""));
}
return result.join("\n").trim();
}
function clone(data) {
try {
return structuredClone(data);
} catch (e2) {
console.warn(e2, `Fallback to JSON cloning`);
try {
return JSON.parse(JSON.stringify(data));
} catch (e3) {
console.error(e3);
}
return data;
}
}
function omit(data, keys) {
const copy = {};
for (const key in data) {
if (!keys.includes(key)) {
copy[key] = data[key];
}
}
return copy;
}
function applyState(target, state, override = false) {
for (const key in state) {
if (!override && target[key] && !key.startsWith("_h") && typeof target[key] === "object" && !Array.isArray(target[key])) {
Object.assign(target[key], state[key]);
} else {
try {
target[key] = state[key];
} catch (e2) {
}
}
}
}
const omitInheritStoryProps = [
"id",
"title",
"group",
"layout",
"variants",
"file",
"slots",
"lastSelectedVariant"
];
var define_process_env_default$1 = {};
const va = {
name: "HstButton"
}, Zo = /* @__PURE__ */ defineComponent({
...va,
props: {
color: {}
},
setup(n2) {
const t2 = {
default: "htw-bg-gray-200 dark:htw-bg-gray-750 htw-text-gray-900 dark:htw-text-gray-100 hover:htw-bg-primary-200 dark:hover:htw-bg-primary-900",
primary: "htw-bg-primary-500 hover:htw-bg-primary-600 htw-text-white dark:htw-text-black",
flat: "htw-bg-transparent hover:htw-bg-gray-500/20 htw-text-gray-900 dark:htw-text-gray-100"
};
return (e2, i2) => (openBlock(), createElementBlock("button", {
class: normalizeClass(["histoire-button htw-cursor-pointer htw-rounded-sm", t2[e2.color ?? "default"]])
}, [
renderSlot(e2.$slots, "default")
], 2));
}
}), Sa = { class: "htw-w-28 htw-whitespace-nowrap htw-text-ellipsis htw-overflow-hidden htw-shrink-0" }, Ca = { class: "htw-grow htw-max-w-full htw-flex htw-items-center htw-gap-1" }, Aa = { class: "htw-block htw-grow htw-max-w-full" }, Oa = {
name: "HstWrapper"
}, Vt = /* @__PURE__ */ defineComponent({
...Oa,
props: {
title: { default: void 0 },
tag: { default: "label" }
},
setup(n2) {
return (t2, e2) => (openBlock(), createBlock(resolveDynamicComponent(t2.tag), { class: "histoire-wrapper htw-p-2 hover:htw-bg-primary-100 dark:hover:htw-bg-primary-800 htw-flex htw-gap-2 htw-flex-wrap" }, {
default: withCtx(() => [
withDirectives((openBlock(), createElementBlock("span", Sa, [
createTextVNode(toDisplayString(t2.title), 1)
])), [
[unref(VTooltip), {
content: t2.title,
placement: "left",
distance: 12
}]
]),
createBaseVNode("span", Ca, [
createBaseVNode("span", Aa, [
renderSlot(t2.$slots, "default")
]),
renderSlot(t2.$slots, "actions")
])
]),
_: 3
}));
}
}), Ma = { class: "htw-flex htw-gap-px htw-border htw-border-solid htw-border-black/25 dark:htw-border-white/25 htw-rounded-sm htw-p-px" }, Ta = {
name: "HstButtonGroup"
}, Da = /* @__PURE__ */ defineComponent({
...Ta,
props: {
title: {},
modelValue: {},
options: {}
},
emits: ["update:modelValue"],
setup(n2, { emit: t2 }) {
const e2 = n2, i2 = computed(() => Array.isArray(e2.options) ? e2.options.map((o) => typeof o == "string" || typeof o == "number" ? { value: o, label: String(o) } : o) : Object.keys(e2.options).map((o) => ({
value: o,
label: e2.options[o]
}))), s = t2;
function r2(o) {
s("update:modelValue", o);
}
return (o, l) => (openBlock(), createBlock(Vt, {
tag: "div",
role: "group",
title: o.title,
class: "histoire-button-group htw-flex-nowrap htw-items-center"
}, {
actions: withCtx(() => [
renderSlot(o.$slots, "actions")
]),
default: withCtx(() => [
createBaseVNode("div", Ma, [
(openBlock(true), createElementBlock(Fragment, null, renderList(i2.value, ({ label: h2, value: a2 }) => (openBlock(), createBlock(Zo, {
key: a2,
class: "htw-px-1 htw-h-[22px] htw-flex-1 !htw-rounded-[3px]",
color: a2 === o.modelValue ? "primary" : "flat",
rounded: false,
onClick: (c2) => r2(a2)
}, {
default: withCtx(() => [
createTextVNode(toDisplayString(h2), 1)
]),
_: 2
}, 1032, ["color", "onClick"]))), 128))
])
]),
_: 3
}, 8, ["title"]));
}
}), Pa = {
width: "16",
height: "16",
viewBox: "0 0 24 24",
class: "htw-relative htw-z-10"
}, Ba = ["stroke-dasharray", "stroke-dashoffset"], Ra = {
name: "HstSimpleCheckbox"
}, tl = /* @__PURE__ */ defineComponent({
...Ra,
props: {
modelValue: { type: Boolean },
withToggle: { type: Boolean }
},
emits: {
"update:modelValue": (n2) => true
},
setup(n2, { emit: t2 }) {
const e2 = n2, i2 = t2;
function s() {
e2.withToggle && i2("update:modelValue", !e2.modelValue);
}
watch(() => e2.modelValue, () => {
a2.value = true;
});
const r2 = ref(), o = ref(0), l = computed(() => e2.modelValue ? 1 : 0), h2 = computed(() => (1 - l.value) * o.value), a2 = ref(false);
return watch(r2, () => {
var c2, f2;
o.value = ((f2 = (c2 = r2.value).getTotalLength) == null ? void 0 : f2.call(c2)) ?? 21.21;
}), (c2, f2) => (openBlock(), createElementBlock("div", {
class: normalizeClass(["histoire-simple-checkbox htw-group htw-text-white htw-w-[16px] htw-h-[16px] htw-relative", { "htw-cursor-pointer": c2.withToggle }]),
onClick: s
}, [
createBaseVNode("div", {
class: normalizeClass(["htw-border htw-border-solid group-active:htw-bg-gray-500/20 htw-rounded-sm htw-box-border htw-absolute htw-inset-0 htw-transition-border htw-duration-150 htw-ease-out group-hover:htw-border-primary-500 group-hover:dark:htw-border-primary-500", [
c2.modelValue ? "htw-border-primary-500 htw-border-8" : "htw-border-black/25 dark:htw-border-white/25 htw-delay-150"
]])
}, null, 2),
(openBlock(), createElementBlock("svg", Pa, [
createBaseVNode("path", {
ref_key: "path",
ref: r2,
d: "m 4 12 l 5 5 l 10 -10",
fill: "none",
class: normalizeClass(["htw-stroke-white htw-stroke-2 htw-duration-200 htw-ease-in-out", [
a2.value ? "htw-transition-all" : "htw-transition-none",
{
"htw-delay-150": c2.modelValue
}
]]),
"stroke-dasharray": o.value,
"stroke-dashoffset": h2.value
}, null, 10, Ba)
]))
], 2));
}
}), La = {
name: "HstCheckbox"
}, Ea = /* @__PURE__ */ defineComponent({
...La,
props: {
modelValue: { type: [Boolean, String] },
title: {}
},
emits: {
"update:modelValue": (n2) => true
},
setup(n2, { emit: t2 }) {
const e2 = n2, i2 = t2;
function s() {
if (typeof e2.modelValue == "string") {
i2("update:modelValue", e2.modelValue === "false" ? "true" : "false");
return;
}
i2("update:modelValue", !e2.modelValue);
}
const r2 = computed(() => typeof e2.modelValue == "string" ? e2.modelValue !== "false" : e2.modelValue);
return (o, l) => (openBlock(), createBlock(Vt, {
role: "checkbox",
tabindex: "0",
class: "histoire-checkbox htw-cursor-pointer htw-items-center",
title: o.title,
onClick: l[0] || (l[0] = (h2) => s()),
onKeydown: [
l[1] || (l[1] = withKeys(withModifiers((h2) => s(), ["prevent"]), ["enter"])),
l[2] || (l[2] = withKeys(withModifiers((h2) => s(), ["prevent"]), ["space"]))
]
}, {
actions: withCtx(() => [
renderSlot(o.$slots, "actions")
]),
default: withCtx(() => [
createVNode(tl, { "model-value": r2.value }, null, 8, ["model-value"])
]),
_: 3
}, 8, ["title"]));
}
}), Na = { class: "-htw-my-1" }, Ia = ["for", "onKeydown", "onClick"], Va = {
name: "HstCheckboxList"
}, Ha = /* @__PURE__ */ defineComponent({
...Va,
props: {
title: {},
modelValue: {},
options: {}
},
emits: ["update:modelValue"],
setup(n2, { emit: t2 }) {
const e2 = n2, i2 = computed(() => Array.isArray(e2.options) ? Object.fromEntries(e2.options.map((o) => typeof o == "string" ? [o, o] : [o.value, o.label])) : e2.options), s = t2;
function r2(o) {
e2.modelValue.includes(o) ? s("update:modelValue", e2.modelValue.filter((l) => l !== o)) : s("update:modelValue", [...e2.modelValue, o]);
}
return (o, l) => (openBlock(), createBlock(Vt, {
role: "group",
title: o.title,
class: normalizeClass(["histoire-checkbox-list htw-cursor-text", o.$attrs.class]),
style: normalizeStyle(o.$attrs.style)
}, {
actions: withCtx(() => [
renderSlot(o.$slots, "actions")
]),
default: withCtx(() => [
createBaseVNode("div", Na, [
(openBlock(true), createElementBlock(Fragment, null, renderList(i2.value, (h2, a2) => (openBlock(), createElementBlock("label", {
key: a2,
tabindex: "0",
for: `${a2}-radio`,
class: "htw-cursor-pointer htw-flex htw-items-center htw-relative htw-py-1 htw-group",
onKeydown: [
withKeys(withModifiers((c2) => r2(a2), ["prevent"]), ["enter"]),
withKeys(withModifiers((c2) => r2(a2), ["prevent"]), ["space"])
],
onClick: (c2) => r2(a2)
}, [
createVNode(tl, {
"model-value": o.modelValue.includes(a2),
class: "htw-mr-2"
}, null, 8, ["model-value"]),
createTextVNode(" " + toDisplayString(h2), 1)
], 40, Ia))), 128))
])
]),
_: 3
}, 8, ["title", "class", "style"]));
}
}), $a = ["value"], Fa = {
name: "HstText"
}, _a = /* @__PURE__ */ defineComponent({
...Fa,
props: {
title: {},
modelValue: {}
},
emits: {
"update:modelValue": (n2) => true
},
setup(n2, { emit: t2 }) {
const e2 = t2, i2 = ref();
return (s, r2) => (openBlock(), createBlock(Vt, {
title: s.title,
class: normalizeClass(["histoire-text htw-cursor-text htw-items-center", s.$attrs.class]),
style: normalizeStyle(s.$attrs.style),
onClick: r2[1] || (r2[1] = (o) => i2.value.focus())
}, {
actions: withCtx(() => [
renderSlot(s.$slots, "actions")
]),
default: withCtx(() => [
createBaseVNode("input", mergeProps({
ref_key: "input",
ref: i2
}, { ...s.$attrs, class: null, style: null }, {
type: "text",
value: s.modelValue,
class: "htw-text-inherit htw-bg-transparent htw-w-full htw-outline-none htw-px-2 htw-py-1 -htw-my-1 htw-border htw-border-solid htw-border-black/25 dark:htw-border-white/25 focus:htw-border-primary-500 dark:focus:htw-border-primary-500 htw-rounded-sm",
onInput: r2[0] || (r2[0] = (o) => e2("update:modelValue", o.target.value))
}), null, 16, $a)
]),
_: 3
}, 8, ["title", "class", "style"]));
}
}), za = {
name: "HstNumber",
inheritAttrs: false
}, Wa = /* @__PURE__ */ defineComponent({
...za,
props: {
title: {},
modelValue: {}
},
emits: {
"update:modelValue": (n2) => true
},
setup(n2, { emit: t2 }) {
const e2 = n2, i2 = t2, s = computed({
get: () => e2.modelValue,
set: (d2) => {
i2("update:modelValue", d2);
}
}), r2 = ref();
function o() {
r2.value.focus(), r2.value.select();
}
const l = ref(false);
let h2, a2;
function c2(d2) {
l.value = true, h2 = d2.clientX, a2 = s.value, window.addEventListener("mousemove", f2), window.addEventListener("mouseup", u2);
}
function f2(d2) {
let p2 = Number.parseFloat(r2.value.step);
Number.isNaN(p2) && (p2 = 1), s.value = a2 + Math.round((d2.clientX - h2) / 10 / p2) * p2;
}
function u2() {
l.value = false, window.removeEventListener("mousemove", f2), window.removeEventListener("mouseup", u2);
}
return onUnmounted(() => {
u2();
}), (d2, p2) => (openBlock(), createBlock(Vt, {
class: normalizeClass(["histoire-number htw-cursor-ew-resize htw-items-center", [
d2.$attrs.class,
{ "htw-select-none": l.value }
]]),
title: d2.title,
style: normalizeStyle(d2.$attrs.style),
onClick: o,
onMousedown: c2
}, {
actions: withCtx(() => [
renderSlot(d2.$slots, "actions")
]),
default: withCtx(() => [
withDirectives(createBaseVNode("input", mergeProps({
ref_key: "input",
ref: r2
}, { ...d2.$attrs, class: null, style: null }, {
"onUpdate:modelValue": p2[0] || (p2[0] = (m) => s.value = m),
type: "number",
class: [{
"htw-select-none": l.value
}, "htw-text-inherit htw-bg-transparent htw-w-full htw-outline-none htw-pl-2 htw-py-1 -htw-my-1 htw-border htw-border-solid htw-border-black/25 dark:htw-border-white/25 focus:htw-border-primary-500 dark:focus:htw-border-primary-500 htw-rounded-sm htw-cursor-ew-resize htw-box-border"]
}), null, 16), [
[
vModelText,
s.value,
void 0,
{ number: true }
]
])
]),
_: 3
}, 8, ["title", "class", "style"]));
}
}), ja = { class: "htw-relative htw-w-full htw-flex htw-items-center" }, Ka = /* @__PURE__ */ createBaseVNode("div", { class: "htw-absolute htw-inset-0 htw-flex htw-items-center" }, [
/* @__PURE__ */ createBaseVNode("div", { class: "htw-border htw-border-black/25 dark:htw-border-white/25 htw-h-1 htw-w-full htw-rounded-full" })
], -1), qa = {
name: "HstSlider",
inheritAttrs: false
}, Ga = /* @__PURE__ */ defineComponent({
...qa,
props: {
title: {},
modelValue: {},
min: {},
max: {}
},
emits: {
"update:modelValue": (n2) => true
},
setup(n2, { emit: t2 }) {
const e2 = n2, i2 = t2, s = ref(false), r2 = ref(null), o = computed({
get: () => e2.modelValue,
set: (a2) => {
i2("update:modelValue", a2);
}
}), l = computed(() => (e2.modelValue - e2.min) / (e2.max - e2.min)), h2 = computed(() => r2.value ? {
left: `${8 + (r2.value.clientWidth - 16) * l.value}px`
} : {});
return (a2, c2) => (openBlock(), createBlock(Vt, {
class: normalizeClass(["histoire-slider htw-items-center", a2.$attrs.class]),
title: a2.title,
style: normalizeStyle(a2.$attrs.style)
}, {
default: withCtx(() => [
createBaseVNode("div", ja, [
Ka,
withDirectives(createBaseVNode("input", mergeProps({
ref_key: "input",
ref: r2,
"onUpdate:modelValue": c2[0] || (c2[0] = (f2) => o.value = f2),
class: "htw-range-input htw-appearance-none htw-border-0 htw-bg-transparent htw-cursor-pointer htw-relative htw-w-full htw-m-0 htw-text-gray-700",
type: "range"
}, { ...a2.$attrs, class: null, style: null, min: a2.min, max: a2.max }, {
onMouseover: c2[1] || (c2[1] = (f2) => s.value = true),
onMouseleave: c2[2] || (c2[2] = (f2) => s.value = false)
}), null, 16), [
[
vModelText,
o.value,
void 0,
{ number: true }
]
]),
s.value ? withDirectives((openBlock(), createElementBlock("div", {
key: 0,
class: "htw-absolute",
style: normalizeStyle(h2.value)
}, null, 4)), [
[unref(VTooltip), { content: a2.modelValue.toString(), shown: true, distance: 16, delay: 0 }]
]) : createCommentVNode("", true)
])
]),
_: 1
}, 8, ["title", "class", "style"]));
}
}), Ua = ["value"], Ya = {
name: "HstTextarea",
inheritAttrs: false
}, Qa = /* @__PURE__ */ defineComponent({
...Ya,
props: {
title: {},
modelValue: {}
},
emits: {
"update:modelValue": (n2) => true
},
setup(n2, { emit: t2 }) {
const e2 = t2, i2 = ref();
return (s, r2) => (openBlock(), createBlock(Vt, {
title: s.title,
class: normalizeClass(["histoire-textarea htw-cursor-text", s.$attrs.class]),
style: normalizeStyle(s.$attrs.style),
onClick: r2[1] || (r2[1] = (o) => i2.value.focus())
}, {
actions: withCtx(() => [
renderSlot(s.$slots, "actions")
]),
default: withCtx(() => [
createBaseVNode("textarea", mergeProps({
ref_key: "input",
ref: i2
}, { ...s.$attrs, class: null, style: null }, {
value: s.modelValue,
class: "htw-text-inherit htw-bg-transparent htw-w-full htw-outline-none htw-px-2 htw-py-1 -htw-my-1 htw-border htw-border-solid htw-border-black/25 dark:htw-border-white/25 focus:htw-border-primary-500 dark:focus:htw-border-primary-500 htw-rounded-sm htw-box-border htw-resize-y htw-min-h-[26px]",
onInput: r2[0] || (r2[0] = (o) => e2("update:modelValue", o.target.value))
}), null, 16, Ua)
]),
_: 3
}, 8, ["title", "class", "style"]));
}
}), Ja = { class: "htw-cursor-pointer htw-w-full htw-outline-none htw-px-2 htw-h-[27px] -htw-my-1 htw-border htw-border-solid htw-border-black/25 dark:htw-border-white/25 hover:htw-border-primary-500 dark:hover:htw-border-primary-500 htw-rounded-sm htw-flex htw-gap-2 htw-items-center htw-leading-normal" }, Xa = { class: "htw-flex-1 htw-truncate" }, Za = { class: "htw-flex htw-flex-col htw-bg-gray-50 dark:htw-bg-gray-700" }, tc = ["onClick"], ec = {
name: "CustomSelect"
}, ic = /* @__PURE__ */ defineComponent({
...ec,
props: {
modelValue: {},
options: {}
},
emits: ["update:modelValue"],
setup(n2, { emit: t2 }) {
const e2 = n2, i2 = t2, s = computed(() => Array.isArray(e2.options) ? e2.options.map((l) => typeof l == "string" || typeof l == "number" ? [l, String(l)] : [l.value, l.label]) : Object.entries(e2.options)), r2 = computed(() => {
var l;
return (l = s.value.find(([h2]) => h2 === e2.modelValue)) == null ? void 0 : l[1];
});
function o(l, h2) {
i2("update:modelValue", l), h2();
}
return (l, h2) => (openBlock(), createBlock(unref(Dropdown), {
"auto-size": "",
"auto-boundary-max-size": ""
}, {
popper: withCtx(({ hide: a2 }) => [
createBaseVNode("div", Za, [
(openBlock(true), createElementBlock(Fragment, null, renderList(s.value, ([c2, f2]) => (openBlock(), createElementBlock("div", mergeProps({ ...l.$attrs, class: null, style: null }, {
key: f2,
class: ["htw-px-2 htw-py-1 htw-cursor-pointer hover:htw-bg-primary-100 dark:hover:htw-bg-primary-700", {
"htw-bg-primary-200 dark:htw-bg-primary-800": e2.modelValue === c2
}],
onClick: (u2) => o(c2, a2)
}), toDisplayString(f2), 17, tc))), 128))
])
]),
default: withCtx(() => [
createBaseVNode("div", Ja, [
createBaseVNode("div", Xa, [
renderSlot(l.$slots, "default", { label: r2.value }, () => [
createTextVNode(toDisplayString(r2.value), 1)
])
]),
createVNode(unref(Icon), {
icon: "carbon:chevron-sort",
class: "htw-w-4 htw-h-4 htw-flex-none htw-ml-auto"
})
])
]),
_: 3
}));
}
}), sc = {
name: "HstSelect"
}, nc = /* @__PURE__ */ defineComponent({
...sc,
props: {
title: {},
modelValue: {},
options: {}
},
emits: ["update:modelValue"],
setup(n2, { emit: t2 }) {
const e2 = t2;
return (i2, s) => (openBlock(), createBlock(Vt, {
title: i2.title,
class: normalizeClass(["histoire-select htw-cursor-text htw-items-center", i2.$attrs.class]),
style: normalizeStyle(i2.$attrs.style)
}, {
actions: withCtx(() => [
renderSlot(i2.$slots, "actions")
]),
default: withCtx(() => [
createVNode(ic, {
options: i2.options,
"model-value": i2.modelValue,
"onUpdate:modelValue": s[0] || (s[0] = (r2) => e2("update:modelValue", r2))
}, null, 8, ["options", "model-value"])
]),
_: 3
}, 8, ["title", "class", "style"]));
}
}), rc = {
name: "HstCopyIcon"
}, Le = /* @__PURE__ */ defineComponent({
...rc,
props: {
content: { type: [String, Function] }
},
setup(n2) {
const t2 = n2, { copy: e2, copied: i2 } = useClipboard();
async function s() {
const r2 = typeof t2.content == "function" ? await t2.content() : t2.content;
e2(r2);
}
return (r2, o) => withDirectives((openBlock(), createBlock(unref(Icon), {
icon: "carbon:copy-file",
class: "htw-w-4 htw-h-4 htw-opacity-50 hover:htw-opacity-100 hover:htw-text-primary-500 htw-cursor-pointer",
onClick: o[0] || (o[0] = (l) => s())
}, null, 512)), [
[unref(VTooltip), {
content: "Copied!",
triggers: [],
shown: unref(i2),
distance: 12,
delay: 0
}]
]);
}
}), oc = {
key: 0,
class: "histoire-color-shades htw-grid htw-gap-4 htw-grid-cols-[repeat(auto-fill,minmax(200px,1fr))] htw-m-4"
}, lc = ["onMouseenter"], hc = { class: "htw-flex htw-gap-1" }, ac = { class: "htw-my-0 htw-truncate htw-shrink" }, cc = { class: "htw-flex htw-gap-1" }, fc = { class: "htw-my-0 htw-opacity-50 htw-truncate htw-shrink" }, uc = {
name: "HstColorShades"
}, dc = /* @__PURE__ */ defineComponent({
...uc,
props: {
shades: {},
getName: { type: Function },
search: {}
},
setup(n2) {
const t2 = n2;
function e2(o, l = "") {
return Object.entries(o).reduce((h2, [a2, c2]) => {
const f2 = l ? a2 === "DEFAULT" ? l : `${l}-${a2}` : a2, u2 = typeof c2 == "object" ? e2(c2, f2) : { [f2]: c2 };
return { ...h2, ...u2 };
}, {});
}
const i2 = computed(() => {
const o = t2.shades, l = t2.getName, h2 = e2(o);
return Object.entries(h2).map(([a2, c2]) => {
const f2 = l ? l(a2, c2) : a2;
return {
key: a2,
color: c2,
name: f2
};
});
}), s = computed(() => {
let o = i2.value;
if (t2.search) {
const l = new RegExp(t2.search, "i");
o = o.filter(({ name: h2 }) => l.test(h2));
}
return o;
}), r2 = ref(null);
return (o, l) => s.value.length ? (openBlock(), createElementBlock("div", oc, [
(openBlock(true), createElementBlock(Fragment, null, renderList(s.value, (h2) => (openBlock(), createElementBlock("div", {
key: h2.key,
class: "htw-flex htw-flex-col htw-gap-2",
onMouseenter: (a2) => r2.value = h2.key,
onMouseleave: l[0] || (l[0] = (a2) => r2.value = null)
}, [
renderSlot(o.$slots, "default", {
color: h2.color
}, () => [
createBaseVNode("div", {
class: "htw-rounded-full htw-w-16 htw-h-16",
style: normalizeStyle({
backgroundColor: h2.color
})
}, null, 4)
]),
createBaseVNode("div", null, [
createBaseVNode("div", hc, [
withDirectives((openBlock(), createElementBlock("pre", ac, [
createTextVNode(toDisplayString(h2.name), 1)
])), [
[unref(VTooltip), h2.name.length > 23 ? h2.name : ""]
]),
r2.value === h2.key ? (openBlock(), createBlock(Le, {
key: 0,
content: h2.name,
class: "htw-flex-none"
}, null, 8, ["content"])) : createCommentVNode("", true)
]),
createBaseVNode("div", cc, [
withDirectives((openBlock(), createElementBlock("pre", fc, [
createTextVNode(toDisplayString(h2.color), 1)
])), [
[unref(VTooltip), h2.color.length > 23 ? h2.color : ""]
]),
r2.value === h2.key ? (openBlock(), createBlock(Le, {
key: 0,
content: h2.color,
class: "htw-flex-none"
}, null, 8, ["content"])) : createCommentVNode("", true)
])
])
], 40, lc))), 128))
])) : createCommentVNode("", true);
}
}), pc = ["onMouseenter"], gc = { class: "htw-mx-4" }, mc = { class: "htw-flex htw-gap-1" }, wc = { class: "htw-my-0 htw-truncate htw-shrink" }, yc = { class: "htw-flex htw-gap-1" }, bc = { class: "htw-my-0 htw-opacity-50 htw-truncate htw-shrink" }, kc = {
name: "HstTokenList"
}, xc = /* @__PURE__ */ defineComponent({
...kc,
props: {
tokens: {},
getName: { type: Function }
},
setup(n2) {
const t2 = n2, e2 = computed(() => {
const s = t2.tokens, r2 = t2.getName;
return Object.entries(s).map(([o, l]) => {
const h2 = r2 ? r2(o, l) : o;
return {
key: o,
name: h2,
value: typeof l == "number" ? l.toString() : l
};
});
}), i2 = ref(null);
return (s, r2) => (openBlock(true), createElementBlock(Fragment, null, renderList(e2.value, (o) => (openBlock(), createElementBlock("div", {
key: o.key,
class: "histoire-token-list htw-flex htw-flex-col htw-gap-2 htw-my-8",
onMouseenter: (l) => i2.value = o.key,
onMouseleave: r2[0] || (r2[0] = (l) => i2.value = null)
}, [
renderSlot(s.$slots, "default", { token: o }),
createBaseVNode("div", gc, [
createBaseVNode("div", mc, [
createBaseVNode("pre", wc, toDisplayString(o.name), 1),
i2.value === o.key ? (openBlock(), createBlock(Le, {
key: 0,
content: o.name,
class: "htw-flex-none"
}, null, 8, ["content"])) : createCommentVNode("", true)
]),
createBaseVNode("div", yc, [
createBaseVNode("pre", bc, toDisplayString(o.value), 1),
i2.value === o.key ? (openBlock(), createBlock(Le, {
key: 0,
content: typeof o.value == "string" ? o.value : JSON.stringify(o.value),
class: "htw-flex-none"
}, null, 8, ["content"])) : createCommentVNode("", true)
])
])
], 40, pc))), 128));
}
}), vc = ["onMouseenter"], Sc = { class: "htw-flex htw-gap-1" }, Cc = { class: "htw-my-0 htw-truncate htw-shrink" }, Ac = { class: "htw-flex htw-gap-1" }, Oc = { class: "htw-my-0 htw-opacity-50 htw-truncate htw-shrink" }, Mc = {
name: "HstTokenGrid"
}, Tc = /* @__PURE__ */ defineComponent({
...Mc,
props: {
tokens: {},
colSize: { default: 180 },
getName: { type: Function, default: null }
},
setup(n2) {
const t2 = n2, e2 = computed(() => {
const r2 = t2.tokens, o = t2.getName;
return Object.entries(r2).map(([l, h2]) => {
const a2 = o ? o(l, h2) : l;
return {
key: l,
name: a2,
value: typeof h2 == "number" ? h2.toString() : h2
};
});
}), i2 = computed(() => `${t2.colSize}px`), s = ref(null);
return (r2, o) => (openBlock(), createElementBlock("div", {
class: "histoire-token-grid htw-bind-col-size htw-grid htw-gap-4 htw-m-4",
style: normalizeStyle({
"--histoire-col-size": i2.value
})
}, [
(openBlock(true), createElementBlock(Fragment, null, renderList(e2.value, (l) => (openBlock(), createElementBlock("div", {
key: l.key,
class: "htw-flex htw-flex-col htw-gap-2",
onMouseenter: (h2) => s.value = l.key,
onMouseleave: o[0] || (o[0] = (h2) => s.value = null)
}, [
renderSlot(r2.$slots, "default", { token: l }),
createBaseVNode("div", null, [
createBaseVNode("div", Sc, [
withDirectives((openBlock(), createElementBlock("pre", Cc, [
createTextVNode(toDisplayString(l.name), 1)
])), [
[unref(VTooltip), l.name.length > r2.colSize / 8 ? l.name : ""]
]),
s.value === l.key ? (openBlock(), createBlock(Le, {
key: 0,
content: l.name,
class: "htw-flex-none"
}, null, 8, ["content"])) : createCommentVNode("", true)
]),
createBaseVNode("div", Ac, [
withDirectives((openBlock(), createElementBlock("pre", Oc, [
createTextVNode(toDisplayString(l.value), 1)
])), [
[unref(VTooltip), l.value.length > r2.colSize / 8 ? l.value : ""]
]),
s.value === l.key ? (openBlock(), createBlock(Le, {
key: 0,
content: typeof l.value == "string" ? l.value : JSON.stringify(l.value),
class: "htw-flex-none"
}, null, 8, ["content"])) : createCommentVNode("", true)
])
])
], 40, vc))), 128))
], 4));
}
}), Dc = { class: "-htw-my-1" }, Pc = ["id", "name", "value", "checked", "onChange"], Bc = ["for", "onKeydown"], Rc = {
name: "HstRadio"
}, Lc = /* @__PURE__ */ defineComponent({
...Rc,
props: {
title: {},
modelValue: {},
options: {}
},
emits: ["update:modelValue"],
setup(n2, { emit: t2 }) {
const e2 = n2, i2 = computed(() => Array.isArray(e2.options) ? Object.fromEntries(e2.options.map((l) => typeof l == "string" ? [l, l] : [l.value, l.label])) : e2.options), s = t2;
function r2(l) {
s("update:modelValue", l), o.value = true;
}
const o = ref(false);
return (l, h2) => (openBlock(), createBlock(Vt, {
role: "group",
title: l.title,
class: normalizeClass(["histoire-radio htw-cursor-text", l.$attrs.class]),
style: normalizeStyle(l.$attrs.style)
}, {
actions: withCtx(() => [
renderSlot(l.$slots, "actions")
]),
default: withCtx(() => [
createBaseVNode("div", Dc, [
(openBlock(true), createElementBlock(Fragment, null, renderList(i2.value, (a2, c2) => (openBlock(), createElementBlock(Fragment, { key: c2 }, [
createBaseVNode("input", {
id: `${c2}-radio_${l.title}`,
type: "radio",
name: `${c2}-radio_${l.title}`,
value: c2,
checked: c2 === l.modelValue,
class: "!htw-hidden",
onChange: (f2) => r2(c2)
}, null, 40, Pc),
createBaseVNode("label", {
tabindex: "0",
for: `${c2}-radio_${l.title}`,
class: "htw-cursor-pointer htw-flex htw-items-center htw-relative htw-py-1 htw-group",
onKeydown: [
withKeys(withModifiers((f2) => r2(c2), ["prevent"]), ["enter"]),
withKeys(withModifiers((f2) => r2(c2), ["prevent"]), ["space"])
]
}, [
(openBlock(), createElementBlock("svg", {
width: "16",
height: "16",
viewBox: "-12 -12 24 24",
class: normalizeClass(["htw-relative htw-z-10 htw-border htw-border-solid htw-text-inherit htw-rounded-full htw-box-border htw-inset-0 htw-transition-border htw-duration-150 htw-ease-out htw-mr-2 group-hover:htw-border-primary-500", [
l.modelValue === c2 ? "htw-border-primary-500" : "htw-border-black/25 dark:htw-border-white/25"
]])
}, [
createBaseVNode("circle", {
r: "7",
class: normalizeClass(["htw-will-change-transform", [
o.value ? "htw-transition-all" : "htw-transition-none",
{
"htw-delay-150": l.modelValue === c2
},
l.modelValue === c2 ? "htw-fill-primary-500" : "htw-fill-transparent htw-scale-0"
]])
}, null, 2)
], 2)),
createTextVNode(" " + toDisplayString(a2), 1)
], 40, Bc)
], 64))), 128))
])
]),
_: 3
}, 8, ["title", "class", "style"]));
}
});
class V {
/**
Get the line description around the given position.
*/
lineAt(t2) {
if (t2 < 0 || t2 > this.length)
throw new RangeError(`Invalid position ${t2} in document of length ${this.length}`);
return this.lineInner(t2, false, 1, 0);
}
/**
Get the description for the given (1-based) line number.
*/
line(t2) {
if (t2 < 1 || t2 > this.lines)
throw new RangeError(`Invalid line number ${t2} in ${this.lines}-line document`);
return this.lineInner(t2, true, 1, 0);
}
/**
Replace a range of the text with the given content.
*/
replace(t2, e2, i2) {
let s = [];
return this.decompose(
0,
t2,
s,
2
/* Open.To */
), i2.length && i2.decompose(
0,
i2.length,
s,
3
/* Open.To */
), this.decompose(
e2,
this.length,
s,
1
/* Open.From */
), qt.from(s, this.length - (e2 - t2) + i2.length);
}
/**
Append another document to this one.
*/
append(t2) {
return this.replace(this.length, this.length, t2);
}
/**
Retrieve the text between the given points.
*/
slice(t2, e2 = this.length) {
let i2 = [];
return this.decompose(t2, e2, i2, 0), qt.from(i2, e2 - t2);
}
/**
Test whether this text is equal to another instance.
*/
eq(t2) {
if (t2 == this)
return true;
if (t2.length != this.length || t2.lines != this.lines)
return false;
let e2 = this.scanIdentical(t2, 1), i2 = this.length - this.scanIdentical(t2, -1), s = new ui(this), r2 = new ui(t2);
for (let o = e2, l = e2; ; ) {
if (s.next(o), r2.next(o), o = 0, s.lineBreak != r2.lineBreak || s.done != r2.done || s.value != r2.value)
return false;
if (l += s.value.length, s.done || l >= i2)
return true;
}
}
/**
Iterate over the text. When `dir` is `-1`, iteration happens
from end to start. This will return lines and the breaks between
them as separate strings.
*/
iter(t2 = 1) {
return new ui(this, t2);
}
/**
Iterate over a range of the text. When `from` > `to`, the
iterator will run in reverse.
*/
iterRange(t2, e2 = this.length) {
return new el(this, t2, e2);
}
/**
Return a cursor that iterates over the given range of lines,
_without_ returning the line breaks between, and yielding empty
strings for empty lines.
When `from` and `to` are given, they should be 1-based line numbers.
*/
iterLines(t2, e2) {
let i2;
if (t2 == null)
i2 = this.iter();
else {
e2 == null && (e2 = this.lines + 1);
let s = this.line(t2).from;
i2 = this.iterRange(s, Math.max(s, e2 == this.lines + 1 ? this.length : e2 <= 1 ? 0 : this.line(e2 - 1).to));
}
return new il(i2);
}
/**
Return the document as a string, using newline characters to
separate lines.
*/
toString() {
return this.sliceString(0);
}
/**
Convert the document to an array of lines (which can be
deserialized again via [`Text.of`](https://codemirror.net/6/docs/ref/#state.Text^of)).
*/
toJSON() {
let t2 = [];
return this.flatten(t2), t2;
}
/**
@internal
*/
constructor() {
}
/**
Create a `Text` instance for the given array of lines.
*/
static of(t2) {
if (t2.length == 0)
throw new RangeError("A document must have at least one line");
return t2.length == 1 && !t2[0] ? V.empty : t2.length <= 32 ? new J$1(t2) : qt.from(J$1.split(t2, []));
}
}
let J$1 = class J2 extends V {
constructor(t2, e2 = Ec(t2)) {
super(), this.text = t2, this.length = e2;
}
get lines() {
return this.text.length;
}
get children() {
return null;
}
lineInner(t2, e2, i2, s) {
for (let r2 = 0; ; r2++) {
let o = this.text[r2], l = s + o.length;
if ((e2 ? i2 : l) >= t2)
return new Nc(s, l, i2, o);
s = l + 1, i2++;
}
}
decompose(t2, e2, i2, s) {
let r2 = t2 <= 0 && e2 >= this.length ? this : new J2(br(this.text, t2, e2), Math.min(e2, this.length) - Math.max(0, t2));
if (s & 1) {
let o = i2.pop(), l = Xi(r2.text, o.text.slice(), 0, r2.length);
if (l.length <= 32)
i2.push(new J2(l, o.length + r2.length));
else {
let h2 = l.length >> 1;
i2.push(new J2(l.slice(0, h2)), new J2(l.slice(h2)));
}
} else
i2.push(r2);
}
replace(t2, e2, i2) {
if (!(i2 instanceof J2))
return super.replace(t2, e2, i2);
let s = Xi(this.text, Xi(i2.text, br(this.text, 0, t2)), e2), r2 = this.length + i2.length - (e2 - t2);
return s.length <= 32 ? new J2(s, r2) : qt.from(J2.split(s, []), r2);
}
sliceString(t2, e2 = this.length, i2 = `
`) {
let s = "";
for (let r2 = 0, o = 0; r2 <= e2 && o < this.text.length; o++) {
let l = this.text[o], h2 = r2 + l.length;
r2 > t2 && o && (s += i2), t2 < h2 && e2 > r2 && (s += l.slice(Math.max(0, t2 - r2), e2 - r2)), r2 = h2 + 1;
}
return s;
}
flatten(t2) {
for (let e2 of this.text)
t2.push(e2);
}
scanIdentical() {
return 0;
}
static split(t2, e2) {
let i2 = [], s = -1;
for (let r2 of t2)
i2.push(r2), s += r2.length + 1, i2.length == 32 && (e2.push(new J2(i2, s)), i2 = [], s = -1);
return s > -1 && e2.push(new J2(i2, s)), e2;
}
};
class qt extends V {
constructor(t2, e2) {
super(), this.children = t2, this.length = e2, this.lines = 0;
for (let i2 of t2)
this.lines += i2.lines;
}
lineInner(t2, e2, i2, s) {
for (let r2 = 0; ; r2++) {
let o = this.children[r2], l = s + o.length, h2 = i2 + o.lines - 1;
if ((e2 ? h2 : l) >= t2)
return o.lineInner(t2, e2, i2, s);
s = l + 1, i2 = h2 + 1;
}
}
decompose(t2, e2, i2, s) {
for (let r2 = 0, o = 0; o <= e2 && r2 < this.children.length; r2++) {
let l = this.children[r2], h2 = o + l.length;
if (t2 <= h2 && e2 >= o) {
let a2 = s & ((o <= t2 ? 1 : 0) | (h2 >= e2 ? 2 : 0));
o >= t2 && h2 <= e2 && !a2 ? i2.push(l) : l.decompose(t2 - o, e2 - o, i2, a2);
}
o = h2 + 1;
}
}
replace(t2, e2, i2) {
if (i2.lines < this.lines)
for (let s = 0, r2 = 0; s < this.children.length; s++) {
let o = this.children[s], l = r2 + o.length;
if (t2 >= r2 && e2 <= l) {
let h2 = o.replace(t2 - r2, e2 - r2, i2), a2 = this.lines - o.lines + h2.lines;
if (h2.lines < a2 >> 4 && h2.lines > a2 >> 6) {
let c2 = this.children.slice();
return c2[s] = h2, new qt(c2, this.length - (e2 - t2) + i2.length);
}
return super.replace(r2, l, h2);
}
r2 = l + 1;
}
return super.replace(t2, e2, i2);
}
sliceString(t2, e2 = this.length, i2 = `
`) {
let s = "";
for (let r2 = 0, o = 0; r2 < this.children.length && o <= e2; r2++) {
let l = this.children[r2], h2 = o + l.length;
o > t2 && r2 && (s += i2), t2 < h2 && e2 > o && (s += l.sliceString(t2 - o, e2 - o, i2)), o = h2 + 1;
}
return s;
}
flatten(t2) {
for (let e2 of this.children)
e2.flatten(t2);
}
scanIdentical(t2, e2) {
if (!(t2 instanceof qt))
return 0;
let i2 = 0, [s, r2, o, l] = e2 > 0 ? [0, 0, this.children.length, t2.children.length] : [this.children.length - 1, t2.children.length - 1, -1, -1];
for (; ; s += e2, r2 += e2) {
if (s == o || r2 == l)
return i2;
let h2 = this.children[s], a2 = t2.children[r2];
if (h2 != a2)
return i2 + h2.scanIdentical(a2, e2);
i2 += h2.length + 1;
}
}
static from(t2, e2 = t2.reduce((i2, s) => i2 + s.length + 1, -1)) {
let i2 = 0;
for (let d2 of t2)
i2 += d2.lines;
if (i2 < 32) {
let d2 = [];
for (let p2 of t2)
p2.flatten(d2);
return new J$1(d2, e2);
}
let s = Math.max(
32,
i2 >> 5
/* Tree.BranchShift */
), r2 = s << 1, o = s >> 1, l = [], h2 = 0, a2 = -1, c2 = [];
function f2(d2) {
let p2;
if (d2.lines > r2 && d2 instanceof qt)
for (let m of d2.children)
f2(m);
else
d2.lines > o && (h2 > o || !h2) ? (u2(), l.push(d2)) : d2 instanceof J$1 && h2 && (p2 = c2[c2.length - 1]) instanceof J$1 && d2.lines + p2.lines <= 32 ? (h2 += d2.lines, a2 += d2.length + 1, c2[c2.length - 1] = new J$1(p2.text.concat(d2.text), p2.length + 1 + d2.length)) : (h2 + d2.lines > s && u2(), h2 += d2.lines, a2 += d2.length + 1, c2.push(d2));
}
function u2() {
h2 != 0 && (l.push(c2.length == 1 ? c2[0] : qt.from(c2, a2)), a2 = -1, h2 = c2.length = 0);
}
for (let d2 of t2)
f2(d2);
return u2(), l.length == 1 ? l[0] : new qt(l, e2);
}
}
V.empty = /* @__PURE__ */ new J$1([""], 0);
function Ec(n2) {
let t2 = -1;
for (let e2 of n2)
t2 += e2.length + 1;
return t2;
}
function Xi(n2, t2, e2 = 0, i2 = 1e9) {
for (let s = 0, r2 = 0, o = true; r2 < n2.length && s <= i2; r2++) {
let l = n2[r2], h2 = s + l.length;
h2 >= e2 && (h2 > i2 && (l = l.slice(0, i2 - s)), s < e2 && (l = l.slice(e2 - s)), o ? (t2[t2.length - 1] += l, o = false) : t2.push(l)), s = h2 + 1;
}
return t2;
}
function br(n2, t2, e2) {
return Xi(n2, [""], t2, e2);
}
class ui {
constructor(t2, e2 = 1) {
this.dir = e2, this.done = false, this.lineBreak = false, this.value = "", this.nodes = [t2], this.offsets = [e2 > 0 ? 1 : (t2 instanceof J$1 ? t2.text.length : t2.children.length) << 1];
}
nextInner(t2, e2) {
for (this.done = this.lineBreak = false; ; ) {
let i2 = this.nodes.length - 1, s = this.nodes[i2], r2 = this.offsets[i2], o = r2 >> 1, l = s instanceof J$1 ? s.text.length : s.children.length;
if (o == (e2 > 0 ? l : 0)) {
if (i2 == 0)
return this.done = true, this.value = "", this;
e2 > 0 && this.offsets[i2 - 1]++, this.nodes.pop(), this.offsets.pop();
} else if ((r2 & 1) == (e2 > 0 ? 0 : 1)) {
if (this.offsets[i2] += e2, t2 == 0)
return this.lineBreak = true, this.value = `
`, this;
t2--;
} else if (s instanceof J$1) {
let h2 = s.text[o + (e2 < 0 ? -1 : 0)];
if (this.offsets[i2] += e2, h2.length > Math.max(0, t2))
return this.value = t2 == 0 ? h2 : e2 > 0 ? h2.slice(t2) : h2.slice(0, h2.length - t2), this;
t2 -= h2.length;
} else {
let h2 = s.children[o + (e2 < 0 ? -1 : 0)];
t2 > h2.length ? (t2 -= h2.length, this.offsets[i2] += e2) : (e2 < 0 && this.offsets[i2]--, this.nodes.push(h2), this.offsets.push(e2 > 0 ? 1 : (h2 instanceof J$1 ? h2.text.length : h2.children.length) << 1));
}
}
}
next(t2 = 0) {
return t2 < 0 && (this.nextInner(-t2, -this.dir), t2 = this.value.length), this.nextInner(t2, this.dir);
}
}
class el {
constructor(t2, e2, i2) {
this.value = "", this.done = false, this.cursor = new ui(t2, e2 > i2 ? -1 : 1), this.pos = e2 > i2 ? t2.length : 0, this.from = Math.min(e2, i2), this.to = Math.max(e2, i2);
}
nextInner(t2, e2) {
if (e2 < 0 ? this.pos <= this.from : this.pos >= this.to)
return this.value = "", this.done = true, this;
t2 += Math.max(0, e2 < 0 ? this.pos - this.to : this.from - this.pos);
let i2 = e2 < 0 ? this.pos - this.from : this.to - this.pos;
t2 > i2 && (t2 = i2), i2 -= t2;
let { value: s } = this.cursor.next(t2);
return this.pos += (s.length + t2) * e2, this.value = s.length <= i2 ? s : e2 < 0 ? s.slice(s.length - i2) : s.slice(0, i2), this.done = !this.value, this;
}
next(t2 = 0) {
return t2 < 0 ? t2 = Math.max(t2, this.from - this.pos) : t2 > 0 && (t2 = Math.min(t2, this.to - this.pos)), this.nextInner(t2, this.cursor.dir);
}
get lineBreak() {
return this.cursor.lineBreak && this.value != "";
}
}
class il {
constructor(t2) {
this.inner = t2, this.afterBreak = true, this.value = "", this.done = false;
}
next(t2 = 0) {
let { done: e2, lineBreak: i2, value: s } = this.inner.next(t2);
return e2 ? (this.done = true, this.value = "") : i2 ? this.afterBreak ? this.value = "" : (this.afterBreak = true, this.next()) : (this.value = s, this.afterBreak = false), this;
}
get lineBreak() {
return false;
}
}
typeof Symbol < "u" && (V.prototype[Symbol.iterator] = function() {
return this.iter();
}, ui.prototype[Symbol.iterator] = el.prototype[Symbol.iterator] = il.prototype[Symbol.iterator] = function() {
return this;
});
class Nc {
/**
@internal
*/
constructor(t2, e2, i2, s) {
this.from = t2, this.to = e2, this.number = i2, this.text = s;
}
/**
The length of the line (not including any line break after it).
*/
get length() {
return this.to - this.from;
}
}
let We = /* @__PURE__ */ "lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map((n2) => n2 ? parseInt(n2, 36) : 1);
for (let n2 = 1; n2 < We.length; n2++)
We[n2] += We[n2 - 1];
function Ic(n2) {
for (let t2 = 1; t2 < We.length; t2 += 2)
if (We[t2] > n2)
return We[t2 - 1] <= n2;
return false;
}
function kr(n2) {
return n2 >= 127462 && n2 <= 127487;
}
const xr = 8205;
function wt(n2, t2, e2 = true, i2 = true) {
return (e2 ? sl : Vc)(n2, t2, i2);
}
function sl(n2, t2, e2) {
if (t2 == n2.length)
return t2;
t2 && nl(n2.charCodeAt(t2)) && rl(n2.charCodeAt(t2 - 1)) && t2--;
let i2 = di(n2, t2);
for (t2 += nn(i2); t2 < n2.length; ) {
let s = di(n2, t2);
if (i2 == xr || s == xr || e2 && Ic(s))
t2 += nn(s), i2 = s;
else if (kr(s)) {
let r2 = 0, o = t2 - 2;
for (; o >= 0 && kr(di(n2, o)); )
r2++, o -= 2;
if (r2 % 2 == 0)
break;
t2 += 2;
} else
break;
}
return t2;
}
function Vc(n2, t2, e2) {
for (; t2 > 0; ) {
let i2 = sl(n2, t2 - 2, e2);
if (i2 < t2)
return i2;
t2--;
}
return 0;
}
function nl(n2) {
return n2 >= 56320 && n2 < 57344;
}
function rl(n2) {
return n2 >= 55296 && n2 < 56320;
}
function di(n2, t2) {
let e2 = n2.charCodeAt(t2);
if (!rl(e2) || t2 + 1 == n2.length)
return e2;
let i2 = n2.charCodeAt(t2 + 1);
return nl(i2) ? (e2 - 55296 << 10) + (i2 - 56320) + 65536 : e2;
}
function nn(n2) {
return n2 < 65536 ? 1 : 2;
}
const rn = /\r\n?|\n/;
var mt = /* @__PURE__ */ function(n2) {
return n2[n2.Simple = 0] = "Simple", n2[n2.TrackDel = 1] = "TrackDel", n2[n2.TrackBefore = 2] = "TrackBefore", n2[n2.TrackAfter = 3] = "TrackAfter", n2;
}(mt || (mt = {}));
class ee {
// Sections are encoded as pairs of integers. The first is the
// length in the current document, and the second is -1 for
// unaffected sections, and the length of the replacement content
// otherwise. So an insertion would be (0, n>0), a deletion (n>0,
// 0), and a replacement two positive numbers.
/**
@internal
*/
constructor(t2) {
this.sections = t2;
}
/**
The length of the document before the change.
*/
get length() {
let t2 = 0;
for (let e2 = 0; e2 < this.sections.length; e2 += 2)
t2 += this.sections[e2];
return t2;
}
/**
The length of the document after the change.
*/
get newLength() {
let t2 = 0;
for (let e2 = 0; e2 < this.sections.length; e2 += 2) {
let i2 = this.sections[e2 + 1];
t2 += i2 < 0 ? this.sections[e2] : i2;
}
return t2;
}
/**
False when there are actual changes in this set.
*/
get empty() {
return this.sections.length == 0 || this.sections.length == 2 && this.sections[1] < 0;
}
/**
Iterate over the unchanged parts left by these changes. `posA`
provides the position of the range in the old document, `posB`
the new position in the changed document.
*/
iterGaps(t2) {
for (let e2 = 0, i2 = 0, s = 0; e2 < this.sections.length; ) {
let r2 = this.sections[e2++], o = this.sections[e2++];
o < 0 ? (t2(i2, s, r2), s += r2) : s += o, i2 += r2;
}
}
/**
Iterate over the ranges changed by these changes. (See
[`ChangeSet.iterChanges`](https://codemirror.net/6/docs/ref/#state.ChangeSet.iterChanges) for a
variant that also provides you with the inserted text.)
`fromA`/`toA` provides the extent of the change in the starting
document, `fromB`/`toB` the extent of the replacement in the
changed document.
When `individual` is true, adjacent changes (which are kept
separate for [position mapping](https://codemirror.net/6/docs/ref/#state.ChangeDesc.mapPos)) are
reported separately.
*/
iterChangedRanges(t2, e2 = false) {
on(this, t2, e2);
}
/**
Get a description of the inverted form of these changes.
*/
get invertedDesc() {
let t2 = [];
for (let e2 = 0; e2 < this.sections.length; ) {
let i2 = this.sections[e2++], s = this.sections[e2++];
s < 0 ? t2.push(i2, s) : t2.push(s, i2);
}
return new ee(t2);
}
/**
Compute the combined effect of applying another set of changes
after this one. The length of the document after this set should
match the length before `other`.
*/
composeDesc(t2) {
return this.empty ? t2 : t2.empty ? this : ol(this, t2);
}
/**
Map this description, which should start with the same document
as `other`, over another set of changes, so that it can be
applied after it. When `before` is true, map as if the changes
in `other` happened before the ones in `this`.
*/
mapDesc(t2, e2 = false) {
return t2.empty ? this : ln(this, t2, e2);
}
mapPos(t2, e2 = -1, i2 = mt.Simple) {
let s = 0, r2 = 0;
for (let o = 0; o < this.sections.length; ) {
let l = this.sections[o++], h2 = this.sections[o++], a2 = s + l;
if (h2 < 0) {
if (a2 > t2)
return r2 + (t2 - s);
r2 += l;
} else {
if (i2 != mt.Simple && a2 >= t2 && (i2 == mt.TrackDel && s < t2 && a2 > t2 || i2 == mt.TrackBefore && s < t2 || i2 == mt.TrackAfter && a2 > t2))
return null;
if (a2 > t2 || a2 == t2 && e2 < 0 && !l)
return t2 == s || e2 < 0 ? r2 : r2 + h2;
r2 += h2;
}
s = a2;
}
if (t2 > s)
throw new RangeError(`Position ${t2} is out of range for changeset of length ${s}`);
return r2;
}
/**
Check whether these changes touch a given range. When one of the
changes entirely covers the range, the string `"cover"` is
returned.
*/
touchesRange(t2, e2 = t2) {
for (let i2 = 0, s = 0; i2 < this.sections.length && s <= e2; ) {
let r2 = this.sections[i2++], o = this.sections[i2++], l = s + r2;
if (o >= 0 && s <= e2 && l >= t2)
return s < t2 && l > e2 ? "cover" : true;
s = l;
}
return false;
}
/**
@internal
*/
toString() {
let t2 = "";
for (let e2 = 0; e2 < this.sections.length; ) {
let i2 = this.sections[e2++], s = this.sections[e2++];
t2 += (t2 ? " " : "") + i2 + (s >= 0 ? ":" + s : "");
}
return t2;
}
/**
Serialize this change desc to a JSON-representable value.
*/
toJSON() {
return this.sections;
}
/**
Create a change desc from its JSON representation (as produced
by [`toJSON`](https://codemirror.net/6/docs/ref/#state.ChangeDesc.toJSON).
*/
static fromJSON(t2) {
if (!Array.isArray(t2) || t2.length % 2 || t2.some((e2) => typeof e2 != "number"))
throw new RangeError("Invalid JSON representation of ChangeDesc");
return new ee(t2);
}
/**
@internal
*/
static create(t2) {
return new ee(t2);
}
}
class it extends ee {
constructor(t2, e2) {
super(t2), this.inserted = e2;
}
/**
Apply the changes to a document, returning the modified
document.
*/
apply(t2) {
if (this.length != t2.length)
throw new RangeError("Applying change set to a document with the wrong length");
return on(this, (e2, i2, s, r2, o) => t2 = t2.replace(s, s + (i2 - e2), o), false), t2;
}
mapDesc(t2, e2 = false) {
return ln(this, t2, e2, true);
}
/**
Given the document as it existed _before_ the changes, return a
change set that represents the inverse of this set, which could
be used to go from the document created by the changes back to
the document as it existed before the changes.
*/
invert(t2) {
let e2 = this.sections.slice(), i2 = [];
for (let s = 0, r2 = 0; s < e2.length; s += 2) {
let o = e2[s], l = e2[s + 1];
if (l >= 0) {
e2[s] = l, e2[s + 1] = o;
let h2 = s >> 1;
for (; i2.length < h2; )
i2.push(V.empty);
i2.push(o ? t2.slice(r2, r2 + o) : V.empty);
}
r2 += o;
}
return new it(e2, i2);
}
/**
Combine two subsequent change sets into a single set. `other`
must start in the document produced by `this`. If `this` goes
`docA` → `docB` and `other` represents `docB` → `docC`, the
returned value will represent the change `docA` → `docC`.
*/
compose(t2) {
return this.empty ? t2 : t2.empty ? this : ol(this, t2, true);
}
/**
Given another change set starting in the same document, maps this
change set over the other, producing a new change set that can be
applied to the document produced by applying `other`. When
`before` is `true`, order changes as if `this` comes before
`other`, otherwise (the default) treat `other` as coming first.
Given two changes `A` and `B`, `A.compose(B.map(A))` and
`B.compose(A.map(B, true))` will produce the same document. This
provides a basic form of [operational
transformation](https://en.wikipedia.org/wiki/Operational_transformation),
and can be used for collaborative editing.
*/
map(t2, e2 = false) {
return t2.empty ? this : ln(this, t2, e2, true);
}
/**
Iterate over the changed ranges in the document, calling `f` for
each, with the range in the original document (`fromA`-`toA`)
and the range that replaces it in the new document
(`fromB`-`toB`).
When `individual` is true, adjacent changes are reported
separately.
*/
iterChanges(t2, e2 = false) {
on(this, t2, e2);
}
/**
Get a [change description](https://codemirror.net/6/docs/ref/#state.ChangeDesc) for this change
set.
*/
get desc() {
return ee.create(this.sections);
}
/**
@internal
*/
filter(t2) {
let e2 = [], i2 = [], s = [], r2 = new mi(this);
t:
for (let o = 0, l = 0; ; ) {
let h2 = o == t2.length ? 1e9 : t2[o++];
for (; l < h2 || l == h2 && r2.len == 0; ) {
if (r2.done)
break t;
let c2 = Math.min(r2.len, h2 - l);
at(s, c2, -1);
let f2 = r2.ins == -1 ? -1 : r2.off == 0 ? r2.ins : 0;
at(e2, c2, f2), f2 > 0 && ce(i2, e2, r2.text), r2.forward(c2), l += c2;
}
let a2 = t2[o++];
for (; l < a2; ) {
if (r2.done)
break t;
let c2 = Math.min(r2.len, a2 - l);
at(e2, c2, -1), at(s, c2, r2.ins == -1 ? -1 : r2.off == 0 ? r2.ins : 0), r2.forward(c2), l += c2;
}
}
return {
changes: new it(e2, i2),
filtered: ee.create(s)
};
}
/**
Serialize this change set to a JSON-representable value.
*/
toJSON() {
let t2 = [];
for (let e2 = 0; e2 < this.sections.length; e2 += 2) {
let i2 = this.sections[e2], s = this.sections[e2 + 1];
s < 0 ? t2.push(i2) : s == 0 ? t2.push([i2]) : t2.push([i2].concat(this.inserted[e2 >> 1].toJSON()));
}
return t2;
}
/**
Create a change set for the given changes, for a document of the
given length, using `lineSep` as line separator.
*/
static of(t2, e2, i2) {
let s = [], r2 = [], o = 0, l = null;
function h2(c2 = false) {
if (!c2 && !s.length)
return;
o < e2 && at(s, e2 - o, -1);
let f2 = new it(s, r2);
l = l ? l.compose(f2.map(l)) : f2, s = [], r2 = [], o = 0;
}
function a2(c2) {
if (Array.isArray(c2))
for (let f2 of c2)
a2(f2);
else if (c2 instanceof it) {
if (c2.length != e2)
throw new RangeError(`Mismatched change set length (got ${c2.length}, expected ${e2})`);
h2(), l = l ? l.compose(c2.map(l)) : c2;
} else {
let { from: f2, to: u2 = f2, insert: d2 } = c2;
if (f2 > u2 || f2 < 0 || u2 > e2)
throw new RangeError(`Invalid change range ${f2} to ${u2} (in doc of length ${e2})`);
let p2 = d2 ? typeof d2 == "string" ? V.of(d2.split(i2 || rn)) : d2 : V.empty, m = p2.length;
if (f2 == u2 && m == 0)
return;
f2 < o && h2(), f2 > o && at(s, f2 - o, -1), at(s, u2 - f2, m), ce(r2, s, p2), o = u2;
}
}
return a2(t2), h2(!l), l;
}
/**
Create an empty changeset of the given length.
*/
static empty(t2) {
return new it(t2 ? [t2, -1] : [], []);
}
/**
Create a changeset from its JSON representation (as produced by
[`toJSON`](https://codemirror.net/6/docs/ref/#state.ChangeSet.toJSON).
*/
static fromJSON(t2) {
if (!Array.isArray(t2))
throw new RangeError("Invalid JSON representation of ChangeSet");
let e2 = [], i2 = [];
for (let s = 0; s < t2.length; s++) {
let r2 = t2[s];
if (typeof r2 == "number")
e2.push(r2, -1);
else {
if (!Array.isArray(r2) || typeof r2[0] != "number" || r2.some((o, l) => l && typeof o != "string"))
throw new RangeError("Invalid JSON representation of ChangeSet");
if (r2.length == 1)
e2.push(r2[0], 0);
else {
for (; i2.length < s; )
i2.push(V.empty);
i2[s] = V.of(r2.slice(1)), e2.push(r2[0], i2[s].length);
}
}
}
return new it(e2, i2);
}
/**
@internal
*/
static createSet(t2, e2) {
return new it(t2, e2);
}
}
function at(n2, t2, e2, i2 = false) {
if (t2 == 0 && e2 <= 0)
return;
let s = n2.length - 2;
s >= 0 && e2 <= 0 && e2 == n2[s + 1] ? n2[s] += t2 : t2 == 0 && n2[s] == 0 ? n2[s + 1] += e2 : i2 ? (n2[s] += t2, n2[s + 1] += e2) : n2.push(t2, e2);
}
function ce(n2, t2, e2) {
if (e2.length == 0)
return;
let i2 = t2.length - 2 >> 1;
if (i2 < n2.length)
n2[n2.length - 1] = n2[n2.length - 1].append(e2);
else {
for (; n2.length < i2; )
n2.push(V.empty);
n2.push(e2);
}
}
function on(n2, t2, e2) {
let i2 = n2.inserted;
for (let s = 0, r2 = 0, o = 0; o < n2.sections.length; ) {
let l = n2.sections[o++], h2 = n2.sections[o++];
if (h2 < 0)
s += l, r2 += l;
else {
let a2 = s, c2 = r2, f2 = V.empty;
for (; a2 += l, c2 += h2, h2 && i2 && (f2 = f2.append(i2[o - 2 >> 1])), !(e2 || o == n2.sections.length || n2.sections[o + 1] < 0); )
l = n2.sections[o++], h2 = n2.sections[o++];
t2(s, a2, r2, c2, f2), s = a2, r2 = c2;
}
}
}
function ln(n2, t2, e2, i2 = false) {
let s = [], r2 = i2 ? [] : null, o = new mi(n2), l = new mi(t2);
for (let h2 = -1; ; )
if (o.ins == -1 && l.ins == -1) {
let a2 = Math.min(o.len, l.len);
at(s, a2, -1), o.forward(a2), l.forward(a2);
} else if (l.ins >= 0 && (o.ins < 0 || h2 == o.i || o.off == 0 && (l.len < o.len || l.len == o.len && !e2))) {
let a2 = l.len;
for (at(s, l.ins, -1); a2; ) {
let c2 = Math.min(o.len, a2);
o.ins >= 0 && h2 < o.i && o.len <= c2 && (at(s, 0, o.ins), r2 && ce(r2, s, o.text), h2 = o.i), o.forward(c2), a2 -= c2;
}
l.next();
} else if (o.ins >= 0) {
let a2 = 0, c2 = o.len;
for (; c2; )
if (l.ins == -1) {
let f2 = Math.min(c2, l.len);
a2 += f2, c2 -= f2, l.forward(f2);
} else if (l.ins == 0 && l.len < c2)
c2 -= l.len, l.next();
else
break;
at(s, a2, h2 < o.i ? o.ins : 0), r2 && h2 < o.i && ce(r2, s, o.text), h2 = o.i, o.forward(o.len - c2);
} else {
if (o.done && l.done)
return r2 ? it.createSet(s, r2) : ee.create(s);
throw new Error("Mismatched change set lengths");
}
}
function ol(n2, t2, e2 = false) {
let i2 = [], s = e2 ? [] : null, r2 = new mi(n2), o = new mi(t2);
for (let l = false; ; ) {
if (r2.done && o.done)
return s ? it.createSet(i2, s) : ee.create(i2);
if (r2.ins == 0)
at(i2, r2.len, 0, l), r2.next();
else if (o.len == 0 && !o.done)
at(i2, 0, o.ins, l), s && ce(s, i2, o.text), o.next();
else {
if (r2.done || o.done)
throw new Error("Mismatched change set lengths");
{
let h2 = Math.min(r2.len2, o.len), a2 = i2.length;
if (r2.ins == -1) {
let c2 = o.ins == -1 ? -1 : o.off ? 0 : o.ins;
at(i2, h2, c2, l), s && c2 && ce(s, i2, o.text);
} else
o.ins == -1 ? (at(i2, r2.off ? 0 : r2.len, h2, l), s && ce(s, i2, r2.textBit(h2))) : (at(i2, r2.off ? 0 : r2.len, o.off ? 0 : o.ins, l), s && !o.off && ce(s, i2, o.text));
l = (r2.ins > h2 || o.ins >= 0 && o.len > h2) && (l || i2.length > a2), r2.forward2(h2), o.forward(h2);
}
}
}
}
class mi {
constructor(t2) {
this.set = t2, this.i = 0, this.next();
}
next() {
let { sections: t2 } = this.set;
this.i < t2.length ? (this.len = t2[this.i++], this.ins = t2[this.i++]) : (this.len = 0, this.ins = -2), this.off = 0;
}
get done() {
return this.ins == -2;
}
get len2() {
return this.ins < 0 ? this.len : this.ins;
}
get text() {
let { inserted: t2 } = this.set, e2 = this.i - 2 >> 1;
return e2 >= t2.length ? V.empty : t2[e2];
}
textBit(t2) {
let { inserted: e2 } = this.set, i2 = this.i - 2 >> 1;
return i2 >= e2.length && !t2 ? V.empty : e2[i2].slice(this.off, t2 == null ? void 0 : this.off + t2);
}
forward(t2) {
t2 == this.len ? this.next() : (this.len -= t2, this.off += t2);
}
forward2(t2) {
this.ins == -1 ? this.forward(t2) : t2 == this.ins ? this.next() : (this.ins -= t2, this.off += t2);
}
}
class Be {
constructor(t2, e2, i2) {
this.from = t2, this.to = e2, this.flags = i2;
}
/**
The anchor of the range—the side that doesn't move when you
extend it.
*/
get anchor() {
return this.flags & 32 ? this.to : this.from;
}
/**
The head of the range, which is moved when the range is
[extended](https://codemirror.net/6/docs/ref/#state.SelectionRange.extend).
*/
get head() {
return this.flags & 32 ? this.from : this.to;
}
/**
True when `anchor` and `head` are at the same position.
*/
get empty() {
return this.from == this.to;
}
/**
If this is a cursor that is explicitly associated with the
character on one of its sides, this returns the side. -1 means
the character before its position, 1 the character after, and 0
means no association.
*/
get assoc() {
return this.flags & 8 ? -1 : this.flags & 16 ? 1 : 0;
}
/**
The bidirectional text level associated with this cursor, if
any.
*/
get bidiLevel() {
let t2 = this.flags & 7;
return t2 == 7 ? null : t2;
}
/**
The goal column (stored vertical offset) associated with a
cursor. This is used to preserve the vertical position when
[moving](https://codemirror.net/6/docs/ref/#view.EditorView.moveVertically) across
lines of different length.
*/
get goalColumn() {
let t2 = this.flags >> 6;
return t2 == 16777215 ? void 0 : t2;
}
/**
Map this range through a change, producing a valid range in the
updated document.
*/
map(t2, e2 = -1) {
let i2, s;
return this.empty ? i2 = s = t2.mapPos(this.from, e2) : (i2 = t2.mapPos(this.from, 1), s = t2.mapPos(this.to, -1)), i2 == this.from && s == this.to ? this : new Be(i2, s, this.flags);
}
/**
Extend this range to cover at least `from` to `to`.
*/
extend(t2, e2 = t2) {
if (t2 <= this.anchor && e2 >= this.anchor)
return b$1.range(t2, e2);
let i2 = Math.abs(t2 - this.anchor) > Math.abs(e2 - this.anchor) ? t2 : e2;
return b$1.range(this.anchor, i2);
}
/**
Compare this range to another range.
*/
eq(t2) {
return this.anchor == t2.anchor && this.head == t2.head;
}
/**
Return a JSON-serializable object representing the range.
*/
toJSON() {
return { anchor: this.anchor, head: this.head };
}
/**
Convert a JSON representation of a range to a `SelectionRange`
instance.
*/
static fromJSON(t2) {
if (!t2 || typeof t2.anchor != "number" || typeof t2.head != "number")
throw new RangeError("Invalid JSON representation for SelectionRange");
return b$1.range(t2.anchor, t2.head);
}
/**
@internal
*/
static create(t2, e2, i2) {
return new Be(t2, e2, i2);
}
}
let b$1 = class b2 {
constructor(t2, e2) {
this.ranges = t2, this.mainIndex = e2;
}
/**
Map a selection through a change. Used to adjust the selection
position for changes.
*/
map(t2, e2 = -1) {
return t2.empty ? this : b2.create(this.ranges.map((i2) => i2.map(t2, e2)), this.mainIndex);
}
/**
Compare this selection to another selection.
*/
eq(t2) {
if (this.ranges.length != t2.ranges.length || this.mainIndex != t2.mainIndex)
return false;
for (let e2 = 0; e2 < this.ranges.length; e2++)
if (!this.ranges[e2].eq(t2.ranges[e2]))
return false;
return true;
}
/**
Get the primary selection range. Usually, you should make sure
your code applies to _all_ ranges, by using methods like
[`changeByRange`](https://codemirror.net/6/docs/ref/#state.EditorState.changeByRange).
*/
get main() {
return this.ranges[this.mainIndex];
}
/**
Make sure the selection only has one range. Returns a selection
holding only the main range from this selection.
*/
asSingle() {
return this.ranges.length == 1 ? this : new b2([this.main], 0);
}
/**
Extend this selection with an extra range.
*/
addRange(t2, e2 = true) {
return b2.create([t2].concat(this.ranges), e2 ? 0 : this.mainIndex + 1);
}
/**
Replace a given range with another range, and then normalize the
selection to merge and sort ranges if necessary.
*/
replaceRange(t2, e2 = this.mainIndex) {
let i2 = this.ranges.slice();
return i2[e2] = t2, b2.create(i2, this.mainIndex);
}
/**
Convert this selection to an object that can be serialized to
JSON.
*/
toJSON() {
return { ranges: this.ranges.map((t2) => t2.toJSON()), main: this.mainIndex };
}
/**
Create a selection from a JSON representation.
*/
static fromJSON(t2) {
if (!t2 || !Array.isArray(t2.ranges) || typeof t2.main != "number" || t2.main >= t2.ranges.length)
throw new RangeError("Invalid JSON representation for EditorSelection");
return new b2(t2.ranges.map((e2) => Be.fromJSON(e2)), t2.main);
}
/**
Create a selection holding a single range.
*/
static single(t2, e2 = t2) {
return new b2([b2.range(t2, e2)], 0);
}
/**
Sort and merge the given set of ranges, creating a valid
selection.
*/
static create(t2, e2 = 0) {
if (t2.length == 0)
throw new RangeError("A selection needs at least one range");
for (let i2 = 0, s = 0; s < t2.length; s++) {
let r2 = t2[s];
if (r2.empty ? r2.from <= i2 : r2.from < i2)
return b2.normalized(t2.slice(), e2);
i2 = r2.to;
}
return new b2(t2, e2);
}
/**
Create a cursor selection range at the given position. You can
safely ignore the optional arguments in most situations.
*/
static cursor(t2, e2 = 0, i2, s) {
return Be.create(t2, t2, (e2 == 0 ? 0 : e2 < 0 ? 8 : 16) | (i2 == null ? 7 : Math.min(6, i2)) | (s ?? 16777215) << 6);
}
/**
Create a selection range.
*/
static range(t2, e2, i2, s) {
let r2 = (i2 ?? 16777215) << 6 | (s == null ? 7 : Math.min(6, s));
return e2 < t2 ? Be.create(e2, t2, 48 | r2) : Be.create(t2, e2, (e2 > t2 ? 8 : 0) | r2);
}
/**
@internal
*/
static normalized(t2, e2 = 0) {
let i2 = t2[e2];
t2.sort((s, r2) => s.from - r2.from), e2 = t2.indexOf(i2);
for (let s = 1; s < t2.length; s++) {
let r2 = t2[s], o = t2[s - 1];
if (r2.empty ? r2.from <= o.to : r2.from < o.to) {
let l = o.from, h2 = Math.max(r2.to, o.to);
s <= e2 && e2--, t2.splice(--s, 2, r2.anchor > r2.head ? b2.range(h2, l) : b2.range(l, h2));
}
}
return new b2(t2, e2);
}
};
function ll(n2, t2) {
for (let e2 of n2.ranges)
if (e2.to > t2)
throw new RangeError("Selection points outside of document");
}
let Un = 0;
let O$3 = class O2 {
constructor(t2, e2, i2, s, r2) {
this.combine = t2, this.compareInput = e2, this.compare = i2, this.isStatic = s, this.id = Un++, this.default = t2([]), this.extensions = typeof r2 == "function" ? r2(this) : r2;
}
/**
Returns a facet reader for this facet, which can be used to
[read](https://codemirror.net/6/docs/ref/#state.EditorState.facet) it but not to define values for it.
*/
get reader() {
return this;
}
/**
Define a new facet.
*/
static define(t2 = {}) {
return new O2(t2.combine || ((e2) => e2), t2.compareInput || ((e2, i2) => e2 === i2), t2.compare || (t2.combine ? (e2, i2) => e2 === i2 : Yn), !!t2.static, t2.enables);
}
/**
Returns an extension that adds the given value to this facet.
*/
of(t2) {
return new Zi([], this, 0, t2);
}
/**
Create an extension that computes a value for the facet from a
state. You must take care to declare the parts of the state that
this value depends on, since your function is only called again
for a new state when one of those parts changed.
In cases where your value depends only on a single field, you'll
want to use the [`from`](https://codemirror.net/6/docs/ref/#state.Facet.from) method instead.
*/
compute(t2, e2) {
if (this.isStatic)
throw new Error("Can't compute a static facet");
return new Zi(t2, this, 1, e2);
}
/**
Create an extension that computes zero or more values for this
facet from a state.
*/
computeN(t2, e2) {
if (this.isStatic)
throw new Error("Can't compute a static facet");
return new Zi(t2, this, 2, e2);
}
from(t2, e2) {
return e2 || (e2 = (i2) => i2), this.compute([t2], (i2) => e2(i2.field(t2)));
}
};
function Yn(n2, t2) {
return n2 == t2 || n2.length == t2.length && n2.every((e2, i2) => e2 === t2[i2]);
}
class Zi {
constructor(t2, e2, i2, s) {
this.dependencies = t2, this.facet = e2, this.type = i2, this.value = s, this.id = Un++;
}
dynamicSlot(t2) {
var e2;
let i2 = this.value, s = this.facet.compareInput, r2 = this.id, o = t2[r2] >> 1, l = this.type == 2, h2 = false, a2 = false, c2 = [];
for (let f2 of this.dependencies)
f2 == "doc" ? h2 = true : f2 == "selection" ? a2 = true : ((e2 = t2[f2.id]) !== null && e2 !== void 0 ? e2 : 1) & 1 || c2.push(t2[f2.id]);
return {
create(f2) {
return f2.values[o] = i2(f2), 1;
},
update(f2, u2) {
if (h2 && u2.docChanged || a2 && (u2.docChanged || u2.selection) || hn(f2, c2)) {
let d2 = i2(f2);
if (l ? !vr(d2, f2.values[o], s) : !s(d2, f2.values[o]))
return f2.values[o] = d2, 1;
}
return 0;
},
reconfigure: (f2, u2) => {
let d2, p2 = u2.config.address[r2];
if (p2 != null) {
let m = fs(u2, p2);
if (this.dependencies.every((g) => g instanceof O$3 ? u2.facet(g) === f2.facet(g) : g instanceof Ht ? u2.field(g, false) == f2.field(g, false) : true) || (l ? vr(d2 = i2(f2), m, s) : s(d2 = i2(f2), m)))
return f2.values[o] = m, 0;
} else
d2 = i2(f2);
return f2.values[o] = d2, 1;
}
};
}
}
function vr(n2, t2, e2) {
if (n2.length != t2.length)
return false;
for (let i2 = 0; i2 < n2.length; i2++)
if (!e2(n2[i2], t2[i2]))
return false;
return true;
}
function hn(n2, t2) {
let e2 = false;
for (let i2 of t2)
pi(n2, i2) & 1 && (e2 = true);
return e2;
}
function Hc(n2, t2, e2) {
let i2 = e2.map((h2) => n2[h2.id]), s = e2.map((h2) => h2.type), r2 = i2.filter((h2) => !(h2 & 1)), o = n2[t2.id] >> 1;
function l(h2) {
let a2 = [];
for (let c2 = 0; c2 < i2.length; c2++) {
let f2 = fs(h2, i2[c2]);
if (s[c2] == 2)
for (let u2 of f2)
a2.push(u2);
else
a2.push(f2);
}
return t2.combine(a2);
}
return {
create(h2) {
for (let a2 of i2)
pi(h2, a2);
return h2.values[o] = l(h2), 1;
},
update(h2, a2) {
if (!hn(h2, r2))
return 0;
let c2 = l(h2);
return t2.compare(c2, h2.values[o]) ? 0 : (h2.values[o] = c2, 1);
},
reconfigure(h2, a2) {
let c2 = hn(h2, i2), f2 = a2.config.facets[t2.id], u2 = a2.facet(t2);
if (f2 && !c2 && Yn(e2, f2))
return h2.values[o] = u2, 0;
let d2 = l(h2);
return t2.compare(d2, u2) ? (h2.values[o] = u2, 0) : (h2.values[o] = d2, 1);
}
};
}
const Sr = /* @__PURE__ */ O$3.define({ static: true });
class Ht {
constructor(t2, e2, i2, s, r2) {
this.id = t2, this.createF = e2, this.updateF = i2, this.compareF = s, this.spec = r2, this.provides = void 0;
}
/**
Define a state field.
*/
static define(t2) {
let e2 = new Ht(Un++, t2.create, t2.update, t2.compare || ((i2, s) => i2 === s), t2);
return t2.provide && (e2.provides = t2.provide(e2)), e2;
}
create(t2) {
let e2 = t2.facet(Sr).find((i2) => i2.field == this);
return ((e2 == null ? void 0 : e2.create) || this.createF)(t2);
}
/**
@internal
*/
slot(t2) {
let e2 = t2[this.id] >> 1;
return {
create: (i2) => (i2.values[e2] = this.create(i2), 1),
update: (i2, s) => {
let r2 = i2.values[e2], o = this.updateF(r2, s);
return this.compareF(r2, o) ? 0 : (i2.values[e2] = o, 1);
},
reconfigure: (i2, s) => s.config.address[this.id] != null ? (i2.values[e2] = s.field(this), 0) : (i2.values[e2] = this.create(i2), 1)
};
}
/**
Returns an extension that enables this field and overrides the
way it is initialized. Can be useful when you need to provide a
non-default starting value for the field.
*/
init(t2) {
return [this, Sr.of({ field: this, create: t2 })];
}
/**
State field instances can be used as
[`Extension`](https://codemirror.net/6/docs/ref/#state.Extension) values to enable the field in a
given state.
*/
get extension() {
return this;
}
}
const De = { lowest: 4, low: 3, default: 2, high: 1, highest: 0 };
function ii(n2) {
return (t2) => new hl(t2, n2);
}
const Qn = {
/**
The highest precedence level, for extensions that should end up
near the start of the precedence ordering.
*/
highest: /* @__PURE__ */ ii(De.highest),
/**
A higher-than-default precedence, for extensions that should
come before those with default precedence.
*/
high: /* @__PURE__ */ ii(De.high),
/**
The default precedence, which is also used for extensions
without an explicit precedence.
*/
default: /* @__PURE__ */ ii(De.default),
/**
A lower-than-default precedence.
*/
low: /* @__PURE__ */ ii(De.low),
/**
The lowest precedence level. Meant for things that should end up
near the end of the extension order.
*/
lowest: /* @__PURE__ */ ii(De.lowest)
};
class hl {
constructor(t2, e2) {
this.inner = t2, this.prec = e2;
}
}
class Ai {
/**
Create an instance of this compartment to add to your [state
configuration](https://codemirror.net/6/docs/ref/#state.EditorStateConfig.extensions).
*/
of(t2) {
return new an(this, t2);
}
/**
Create an [effect](https://codemirror.net/6/docs/ref/#state.TransactionSpec.effects) that
reconfigures this compartment.
*/
reconfigure(t2) {
return Ai.reconfigure.of({ compartment: this, extension: t2 });
}
/**
Get the current content of the compartment in the state, or
`undefined` if it isn't present.
*/
get(t2) {
return t2.config.compartments.get(this);
}
}
class an {
constructor(t2, e2) {
this.compartment = t2, this.inner = e2;
}
}
class cs {
constructor(t2, e2, i2, s, r2, o) {
for (this.base = t2, this.compartments = e2, this.dynamicSlots = i2, this.address = s, this.staticValues = r2, this.facets = o, this.statusTemplate = []; this.statusTemplate.length < i2.length; )
this.statusTemplate.push(
0
/* SlotStatus.Unresolved */
);
}
staticFacet(t2) {
let e2 = this.address[t2.id];
return e2 == null ? t2.default : this.staticValues[e2 >> 1];
}
static resolve(t2, e2, i2) {
let s = [], r2 = /* @__PURE__ */ Object.create(null), o = /* @__PURE__ */ new Map();
for (let u2 of $c(t2, e2, o))
u2 instanceof Ht ? s.push(u2) : (r2[u2.facet.id] || (r2[u2.facet.id] = [])).push(u2);
let l = /* @__PURE__ */ Object.create(null), h2 = [], a2 = [];
for (let u2 of s)
l[u2.id] = a2.length << 1, a2.push((d2) => u2.slot(d2));
let c2 = i2 == null ? void 0 : i2.config.facets;
for (let u2 in r2) {
let d2 = r2[u2], p2 = d2[0].facet, m = c2 && c2[u2] || [];
if (d2.every(
(g) => g.type == 0
/* Provider.Static */
))
if (l[p2.id] = h2.length << 1 | 1, Yn(m, d2))
h2.push(i2.facet(p2));
else {
let g = p2.combine(d2.map((y2) => y2.value));
h2.push(i2 && p2.compare(g, i2.facet(p2)) ? i2.facet(p2) : g);
}
else {
for (let g of d2)
g.type == 0 ? (l[g.id] = h2.length << 1 | 1, h2.push(g.value)) : (l[g.id] = a2.length << 1, a2.push((y2) => g.dynamicSlot(y2)));
l[p2.id] = a2.length << 1, a2.push((g) => Hc(g, p2, d2));
}
}
let f2 = a2.map((u2) => u2(l));
return new cs(t2, o, f2, l, h2, r2);
}
}
function $c(n2, t2, e2) {
let i2 = [[], [], [], [], []], s = /* @__PURE__ */ new Map();
function r2(o, l) {
let h2 = s.get(o);
if (h2 != null) {
if (h2 <= l)
return;
let a2 = i2[h2].indexOf(o);
a2 > -1 && i2[h2].splice(a2, 1), o instanceof an && e2.delete(o.compartment);
}
if (s.set(o, l), Array.isArray(o))
for (let a2 of o)
r2(a2, l);
else if (o instanceof an) {
if (e2.has(o.compartment))
throw new RangeError("Duplicate use of compartment in extensions");
let a2 = t2.get(o.compartment) || o.inner;
e2.set(o.compartment, a2), r2(a2, l);
} else if (o instanceof hl)
r2(o.inner, o.prec);
else if (o instanceof Ht)
i2[l].push(o), o.provides && r2(o.provides, l);
else if (o instanceof Zi)
i2[l].push(o), o.facet.extensions && r2(o.facet.extensions, De.default);
else {
let a2 = o.extension;
if (!a2)
throw new Error(`Unrecognized extension value in extension set (${o}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);
r2(a2, l);
}
}
return r2(n2, De.default), i2.reduce((o, l) => o.concat(l));
}
function pi(n2, t2) {
if (t2 & 1)
return 2;
let e2 = t2 >> 1, i2 = n2.status[e2];
if (i2 == 4)
throw new Error("Cyclic dependency between fields and/or facets");
if (i2 & 2)
return i2;
n2.status[e2] = 4;
let s = n2.computeSlot(n2, n2.config.dynamicSlots[e2]);
return n2.status[e2] = 2 | s;
}
function fs(n2, t2) {
return t2 & 1 ? n2.config.staticValues[t2 >> 1] : n2.values[t2 >> 1];
}
const al = /* @__PURE__ */ O$3.define(), cl = /* @__PURE__ */ O$3.define({
combine: (n2) => n2.some((t2) => t2),
static: true
}), fl = /* @__PURE__ */ O$3.define({
combine: (n2) => n2.length ? n2[0] : void 0,
static: true
}), ul = /* @__PURE__ */ O$3.define(), dl = /* @__PURE__ */ O$3.define(), pl = /* @__PURE__ */ O$3.define(), gl = /* @__PURE__ */ O$3.define({
combine: (n2) => n2.length ? n2[0] : false
});
class ti {
/**
@internal
*/
constructor(t2, e2) {
this.type = t2, this.value = e2;
}
/**
Define a new type of annotation.
*/
static define() {
return new Fc();
}
}
class Fc {
/**
Create an instance of this annotation.
*/
of(t2) {
return new ti(this, t2);
}
}
class _c {
/**
@internal
*/
constructor(t2) {
this.map = t2;
}
/**
Create a [state effect](https://codemirror.net/6/docs/ref/#state.StateEffect) instance of this
type.
*/
of(t2) {
return new z$2(this, t2);
}
}
let z$2 = class z2 {
/**
@internal
*/
constructor(t2, e2) {
this.type = t2, this.value = e2;
}
/**
Map this effect through a position mapping. Will return
`undefined` when that ends up deleting the effect.
*/
map(t2) {
let e2 = this.type.map(this.value, t2);
return e2 === void 0 ? void 0 : e2 == this.value ? this : new z2(this.type, e2);
}
/**
Tells you whether this effect object is of a given
[type](https://codemirror.net/6/docs/ref/#state.StateEffectType).
*/
is(t2) {
return this.type == t2;
}
/**
Define a new effect type. The type parameter indicates the type
of values that his effect holds. It should be a type that
doesn't include `undefined`, since that is used in
[mapping](https://codemirror.net/6/docs/ref/#state.StateEffect.map) to indicate that an effect is
removed.
*/
static define(t2 = {}) {
return new _c(t2.map || ((e2) => e2));
}
/**
Map an array of effects through a change set.
*/
static mapEffects(t2, e2) {
if (!t2.length)
return t2;
let i2 = [];
for (let s of t2) {
let r2 = s.map(e2);
r2 && i2.push(r2);
}
return i2;
}
};
z$2.reconfigure = /* @__PURE__ */ z$2.define();
z$2.appendConfig = /* @__PURE__ */ z$2.define();
class ft {
constructor(t2, e2, i2, s, r2, o) {
this.startState = t2, this.changes = e2, this.selection = i2, this.effects = s, this.annotations = r2, this.scrollIntoView = o, this._doc = null, this._state = null, i2 && ll(i2, e2.newLength), r2.some((l) => l.type == ft.time) || (this.annotations = r2.concat(ft.time.of(Date.now())));
}
/**
@internal
*/
static create(t2, e2, i2, s, r2, o) {
return new ft(t2, e2, i2, s, r2, o);
}
/**
The new document produced by the transaction. Contrary to
[`.state`](https://codemirror.net/6/docs/ref/#state.Transaction.state)`.doc`, accessing this won't
force the entire new state to be computed right away, so it is
recommended that [transaction
filters](https://codemirror.net/6/docs/ref/#state.EditorState^transactionFilter) use this getter
when they need to look at the new document.
*/
get newDoc() {
return this._doc || (this._doc = this.changes.apply(this.startState.doc));
}
/**
The new selection produced by the transaction. If
[`this.selection`](https://codemirror.net/6/docs/ref/#state.Transaction.selection) is undefined,
this will [map](https://codemirror.net/6/docs/ref/#state.EditorSelection.map) the start state's
current selection through the changes made by the transaction.
*/
get newSelection() {
return this.selection || this.startState.selection.map(this.changes);
}
/**
The new state created by the transaction. Computed on demand
(but retained for subsequent access), so it is recommended not to
access it in [transaction
filters](https://codemirror.net/6/docs/ref/#state.EditorState^transactionFilter) when possible.
*/
get state() {
return this._state || this.startState.applyTransaction(this), this._state;
}
/**
Get the value of the given annotation type, if any.
*/
annotation(t2) {
for (let e2 of this.annotations)
if (e2.type == t2)
return e2.value;
}
/**
Indicates whether the transaction changed the document.
*/
get docChanged() {
return !this.changes.empty;
}
/**
Indicates whether this transaction reconfigures the state
(through a [configuration compartment](https://codemirror.net/6/docs/ref/#state.Compartment) or
with a top-level configuration
[effect](https://codemirror.net/6/docs/ref/#state.StateEffect^reconfigure).
*/
get reconfigured() {
return this.startState.config != this.state.config;
}
/**
Returns true if the transaction has a [user
event](https://codemirror.net/6/docs/ref/#state.Transaction^userEvent) annotation that is equal to
or more specific than `event`. For example, if the transaction
has `"select.pointer"` as user event, `"select"` and
`"select.pointer"` will match it.
*/
isUserEvent(t2) {
let e2 = this.annotation(ft.userEvent);
return !!(e2 && (e2 == t2 || e2.length > t2.length && e2.slice(0, t2.length) == t2 && e2[t2.length] == "."));
}
}
ft.time = /* @__PURE__ */ ti.define();
ft.userEvent = /* @__PURE__ */ ti.define();
ft.addToHistory = /* @__PURE__ */ ti.define();
ft.remote = /* @__PURE__ */ ti.define();
function zc(n2, t2) {
let e2 = [];
for (let i2 = 0, s = 0; ; ) {
let r2, o;
if (i2 < n2.length && (s == t2.length || t2[s] >= n2[i2]))
r2 = n2[i2++], o = n2[i2++];
else if (s < t2.length)
r2 = t2[s++], o = t2[s++];
else
return e2;
!e2.length || e2[e2.length - 1] < r2 ? e2.push(r2, o) : e2[e2.length - 1] < o && (e2[e2.length - 1] = o);
}
}
function ml(n2, t2, e2) {
var i2;
let s, r2, o;
return e2 ? (s = t2.changes, r2 = it.empty(t2.changes.length), o = n2.changes.compose(t2.changes)) : (s = t2.changes.map(n2.changes), r2 = n2.changes.mapDesc(t2.changes, true), o = n2.changes.compose(s)), {
changes: o,
selection: t2.selection ? t2.selection.map(r2) : (i2 = n2.selection) === null || i2 === void 0 ? void 0 : i2.map(s),
effects: z$2.mapEffects(n2.effects, s).concat(z$2.mapEffects(t2.effects, r2)),
annotations: n2.annotations.length ? n2.annotations.concat(t2.annotations) : t2.annotations,
scrollIntoView: n2.scrollIntoView || t2.scrollIntoView
};
}
function cn(n2, t2, e2) {
let i2 = t2.selection, s = je(t2.annotations);
return t2.userEvent && (s = s.concat(ft.userEvent.of(t2.userEvent))), {
changes: t2.changes instanceof it ? t2.changes : it.of(t2.changes || [], e2, n2.facet(fl)),
selection: i2 && (i2 instanceof b$1 ? i2 : b$1.single(i2.anchor, i2.head)),
effects: je(t2.effects),
annotations: s,
scrollIntoView: !!t2.scrollIntoView
};
}
function wl(n2, t2, e2) {
let i2 = cn(n2, t2.length ? t2[0] : {}, n2.doc.length);
t2.length && t2[0].filter === false && (e2 = false);
for (let r2 = 1; r2 < t2.length; r2++) {
t2[r2].filter === false && (e2 = false);
let o = !!t2[r2].sequential;
i2 = ml(i2, cn(n2, t2[r2], o ? i2.changes.newLength : n2.doc.length), o);
}
let s = ft.create(n2, i2.changes, i2.selection, i2.effects, i2.annotations, i2.scrollIntoView);
return jc(e2 ? Wc(s) : s);
}
function Wc(n2) {
let t2 = n2.startState, e2 = true;
for (let s of t2.facet(ul)) {
let r2 = s(n2);
if (r2 === false) {
e2 = false;
break;
}
Array.isArray(r2) && (e2 = e2 === true ? r2 : zc(e2, r2));
}
if (e2 !== true) {
let s, r2;
if (e2 === false)
r2 = n2.changes.invertedDesc, s = it.empty(t2.doc.length);
else {
let o = n2.changes.filter(e2);
s = o.changes, r2 = o.filtered.mapDesc(o.changes).invertedDesc;
}
n2 = ft.create(t2, s, n2.selection && n2.selection.map(r2), z$2.mapEffects(n2.effects, r2), n2.annotations, n2.scrollIntoView);
}
let i2 = t2.facet(dl);
for (let s = i2.length - 1; s >= 0; s--) {
let r2 = i2[s](n2);
r2 instanceof ft ? n2 = r2 : Array.isArray(r2) && r2.length == 1 && r2[0] instanceof ft ? n2 = r2[0] : n2 = wl(t2, je(r2), false);
}
return n2;
}
function jc(n2) {
let t2 = n2.startState, e2 = t2.facet(pl), i2 = n2;
for (let s = e2.length - 1; s >= 0; s--) {
let r2 = e2[s](n2);
r2 && Object.keys(r2).length && (i2 = ml(i2, cn(t2, r2, n2.changes.newLength), true));
}
return i2 == n2 ? n2 : ft.create(t2, n2.changes, n2.selection, i2.effects, i2.annotations, i2.scrollIntoView);
}
const Kc = [];
function je(n2) {
return n2 == null ? Kc : Array.isArray(n2) ? n2 : [n2];
}
var Zt = /* @__PURE__ */ function(n2) {
return n2[n2.Word = 0] = "Word", n2[n2.Space = 1] = "Space", n2[n2.Other = 2] = "Other", n2;
}(Zt || (Zt = {}));
const qc = /[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;
let fn;
try {
fn = /* @__PURE__ */ new RegExp("[\\p{Alphabetic}\\p{Number}_]", "u");
} catch {
}
function Gc(n2) {
if (fn)
return fn.test(n2);
for (let t2 = 0; t2 < n2.length; t2++) {
let e2 = n2[t2];
if (/\w/.test(e2) || e2 > "€" && (e2.toUpperCase() != e2.toLowerCase() || qc.test(e2)))
return true;
}
return false;
}
function Uc(n2) {
return (t2) => {
if (!/\S/.test(t2))
return Zt.Space;
if (Gc(t2))
return Zt.Word;
for (let e2 = 0; e2 < n2.length; e2++)
if (t2.indexOf(n2[e2]) > -1)
return Zt.Word;
return Zt.Other;
};
}
let H$3 = class H2 {
constructor(t2, e2, i2, s, r2, o) {
this.config = t2, this.doc = e2, this.selection = i2, this.values = s, this.status = t2.statusTemplate.slice(), this.computeSlot = r2, o && (o._state = this);
for (let l = 0; l < this.config.dynamicSlots.length; l++)
pi(this, l << 1);
this.computeSlot = null;
}
field(t2, e2 = true) {
let i2 = this.config.address[t2.id];
if (i2 == null) {
if (e2)
throw new RangeError("Field is not present in this state");
return;
}
return pi(this, i2), fs(this, i2);
}
/**
Create a [transaction](https://codemirror.net/6/docs/ref/#state.Transaction) that updates this
state. Any number of [transaction specs](https://codemirror.net/6/docs/ref/#state.TransactionSpec)
can be passed. Unless
[`sequential`](https://codemirror.net/6/docs/ref/#state.TransactionSpec.sequential) is set, the
[changes](https://codemirror.net/6/docs/ref/#state.TransactionSpec.changes) (if any) of each spec
are assumed to start in the _current_ document (not the document
produced by previous specs), and its
[selection](https://codemirror.net/6/docs/ref/#state.TransactionSpec.selection) and
[effects](https://codemirror.net/6/docs/ref/#state.TransactionSpec.effects) are assumed to refer
to the document created by its _own_ changes. The resulting
transaction contains the combined effect of all the different
specs. For [selection](https://codemirror.net/6/docs/ref/#state.TransactionSpec.selection), later
specs take precedence over earlier ones.
*/
update(...t2) {
return wl(this, t2, true);
}
/**
@internal
*/
applyTransaction(t2) {
let e2 = this.config, { base: i2, compartments: s } = e2;
for (let o of t2.effects)
o.is(Ai.reconfigure) ? (e2 && (s = /* @__PURE__ */ new Map(), e2.compartments.forEach((l, h2) => s.set(h2, l)), e2 = null), s.set(o.value.compartment, o.value.extension)) : o.is(z$2.reconfigure) ? (e2 = null, i2 = o.value) : o.is(z$2.appendConfig) && (e2 = null, i2 = je(i2).concat(o.value));
let r2;
e2 ? r2 = t2.startState.values.slice() : (e2 = cs.resolve(i2, s, this), r2 = new H2(e2, this.doc, this.selection, e2.dynamicSlots.map(() => null), (l, h2) => h2.reconfigure(l, this), null).values), new H2(e2, t2.newDoc, t2.newSelection, r2, (o, l) => l.update(o, t2), t2);
}
/**
Create a [transaction spec](https://codemirror.net/6/docs/ref/#state.TransactionSpec) that
replaces every selection range with the given content.
*/
replaceSelection(t2) {
return typeof t2 == "string" && (t2 = this.toText(t2)), this.changeByRange((e2) => ({
changes: { from: e2.from, to: e2.to, insert: t2 },
range: b$1.cursor(e2.from + t2.length)
}));
}
/**
Create a set of changes and a new selection by running the given
function for each range in the active selection. The function
can return an optional set of changes (in the coordinate space
of the start document), plus an updated range (in the coordinate
space of the document produced by the call's own changes). This
method will merge all the changes and ranges into a single
changeset and selection, and return it as a [transaction
spec](https://codemirror.net/6/docs/ref/#state.TransactionSpec), which can be passed to
[`update`](https://codemirror.net/6/docs/ref/#state.EditorState.update).
*/
changeByRange(t2) {
let e2 = this.selection, i2 = t2(e2.ranges[0]), s = this.changes(i2.changes), r2 = [i2.range], o = je(i2.effects);
for (let l = 1; l < e2.ranges.length; l++) {
let h2 = t2(e2.ranges[l]), a2 = this.changes(h2.changes), c2 = a2.map(s);
for (let u2 = 0; u2 < l; u2++)
r2[u2] = r2[u2].map(c2);
let f2 = s.mapDesc(a2, true);
r2.push(h2.range.map(f2)), s = s.compose(c2), o = z$2.mapEffects(o, c2).concat(z$2.mapEffects(je(h2.effects), f2));
}
return {
changes: s,
selection: b$1.create(r2, e2.mainIndex),
effects: o
};
}
/**
Create a [change set](https://codemirror.net/6/docs/ref/#state.ChangeSet) from the given change
description, taking the state's document length and line
separator into account.
*/
changes(t2 = []) {
return t2 instanceof it ? t2 : it.of(t2, this.doc.length, this.facet(H2.lineSeparator));
}
/**
Using the state's [line
separator](https://codemirror.net/6/docs/ref/#state.EditorState^lineSeparator), create a
[`Text`](https://codemirror.net/6/docs/ref/#state.Text) instance from the given string.
*/
toText(t2) {
return V.of(t2.split(this.facet(H2.lineSeparator) || rn));
}
/**
Return the given range of the document as a string.
*/
sliceDoc(t2 = 0, e2 = this.doc.length) {
return this.doc.sliceString(t2, e2, this.lineBreak);
}
/**
Get the value of a state [facet](https://codemirror.net/6/docs/ref/#state.Facet).
*/
facet(t2) {
let e2 = this.config.address[t2.id];
return e2 == null ? t2.default : (pi(this, e2), fs(this, e2));
}
/**
Convert this state to a JSON-serializable object. When custom
fields should be serialized, you can pass them in as an object
mapping property names (in the resulting object, which should
not use `doc` or `selection`) to fields.
*/
toJSON(t2) {
let e2 = {
doc: this.sliceDoc(),
selection: this.selection.toJSON()
};
if (t2)
for (let i2 in t2) {
let s = t2[i2];
s instanceof Ht && this.config.address[s.id] != null && (e2[i2] = s.spec.toJSON(this.field(t2[i2]), this));
}
return e2;
}
/**
Deserialize a state from its JSON representation. When custom
fields should be deserialized, pass the same object you passed
to [`toJSON`](https://codemirror.net/6/docs/ref/#state.EditorState.toJSON) when serializing as
third argument.
*/
static fromJSON(t2, e2 = {}, i2) {
if (!t2 || typeof t2.doc != "string")
throw new RangeError("Invalid JSON representation for EditorState");
let s = [];
if (i2) {
for (let r2 in i2)
if (Object.prototype.hasOwnProperty.call(t2, r2)) {
let o = i2[r2], l = t2[r2];
s.push(o.init((h2) => o.spec.fromJSON(l, h2)));
}
}
return H2.create({
doc: t2.doc,
selection: b$1.fromJSON(t2.selection),
extensions: e2.extensions ? s.concat([e2.extensions]) : s
});
}
/**
Create a new state. You'll usually only need this when
initializing an editor—updated states are created by applying
transactions.
*/
static create(t2 = {}) {
let e2 = cs.resolve(t2.extensions || [], /* @__PURE__ */ new Map()), i2 = t2.doc instanceof V ? t2.doc : V.of((t2.doc || "").split(e2.staticFacet(H2.lineSeparator) || rn)), s = t2.selection ? t2.selection instanceof b$1 ? t2.selection : b$1.single(t2.selection.anchor, t2.selection.head) : b$1.single(0);
return ll(s, i2.length), e2.staticFacet(cl) || (s = s.asSingle()), new H2(e2, i2, s, e2.dynamicSlots.map(() => null), (r2, o) => o.create(r2), null);
}
/**
The size (in columns) of a tab in the document, determined by
the [`tabSize`](https://codemirror.net/6/docs/ref/#state.EditorState^tabSize) facet.
*/
get tabSize() {
return this.facet(H2.tabSize);
}
/**
Get the proper [line-break](https://codemirror.net/6/docs/ref/#state.EditorState^lineSeparator)
string for this state.
*/
get lineBreak() {
return this.facet(H2.lineSeparator) || `
`;
}
/**
Returns true when the editor is
[configured](https://codemirror.net/6/docs/ref/#state.EditorState^readOnly) to be read-only.
*/
get readOnly() {
return this.facet(gl);
}
/**
Look up a translation for the given phrase (via the
[`phrases`](https://codemirror.net/6/docs/ref/#state.EditorState^phrases) facet), or return the
original string if no translation is found.
If additional arguments are passed, they will be inserted in
place of markers like `$1` (for the first value) and `$2`, etc.
A single `$` is equivalent to `$1`, and `$$` will produce a
literal dollar sign.
*/
phrase(t2, ...e2) {
for (let i2 of this.facet(H2.phrases))
if (Object.prototype.hasOwnProperty.call(i2, t2)) {
t2 = i2[t2];
break;
}
return e2.length && (t2 = t2.replace(/\$(\$|\d*)/g, (i2, s) => {
if (s == "$")
return "$";
let r2 = +(s || 1);
return !r2 || r2 > e2.length ? i2 : e2[r2 - 1];
})), t2;
}
/**
Find the values for a given language data field, provided by the
the [`languageData`](https://codemirror.net/6/docs/ref/#state.EditorState^languageData) facet.
Examples of language data fields are...
- [`"commentTokens"`](https://codemirror.net/6/docs/ref/#commands.CommentTokens) for specifying
comment syntax.
- [`"autocomplete"`](https://codemirror.net/6/docs/ref/#autocomplete.autocompletion^config.override)
for providing language-specific completion sources.
- [`"wordChars"`](https://codemirror.net/6/docs/ref/#state.EditorState.charCategorizer) for adding
characters that should be considered part of words in this
language.
- [`"closeBrackets"`](https://codemirror.net/6/docs/ref/#autocomplete.CloseBracketConfig) controls
bracket closing behavior.
*/
languageDataAt(t2, e2, i2 = -1) {
let s = [];
for (let r2 of this.facet(al))
for (let o of r2(this, e2, i2))
Object.prototype.hasOwnProperty.call(o, t2) && s.push(o[t2]);
return s;
}
/**
Return a function that can categorize strings (expected to
represent a single [grapheme cluster](https://codemirror.net/6/docs/ref/#state.findClusterBreak))
into one of:
- Word (contains an alphanumeric character or a character
explicitly listed in the local language's `"wordChars"`
language data, which should be a string)
- Space (contains only whitespace)
- Other (anything else)
*/
charCategorizer(t2) {
return Uc(this.languageDataAt("wordChars", t2).join(""));
}
/**
Find the word at the given position, meaning the range
containing all [word](https://codemirror.net/6/docs/ref/#state.CharCategory.Word) characters
around it. If no word characters are adjacent to the position,
this returns null.
*/
wordAt(t2) {
let { text: e2, from: i2, length: s } = this.doc.lineAt(t2), r2 = this.charCategorizer(t2), o = t2 - i2, l = t2 - i2;
for (; o > 0; ) {
let h2 = wt(e2, o, false);
if (r2(e2.slice(h2, o)) != Zt.Word)
break;
o = h2;
}
for (; l < s; ) {
let h2 = wt(e2, l);
if (r2(e2.slice(l, h2)) != Zt.Word)
break;
l = h2;
}
return o == l ? null : b$1.range(o + i2, l + i2);
}
};
H$3.allowMultipleSelections = cl;
H$3.tabSize = /* @__PURE__ */ O$3.define({
combine: (n2) => n2.length ? n2[0] : 4
});
H$3.lineSeparator = fl;
H$3.readOnly = gl;
H$3.phrases = /* @__PURE__ */ O$3.define({
compare(n2, t2) {
let e2 = Object.keys(n2), i2 = Object.keys(t2);
return e2.length == i2.length && e2.every((s) => n2[s] == t2[s]);
}
});
H$3.languageData = al;
H$3.changeFilter = ul;
H$3.transactionFilter = dl;
H$3.transactionExtender = pl;
Ai.reconfigure = /* @__PURE__ */ z$2.define();
function Ds(n2, t2, e2 = {}) {
let i2 = {};
for (let s of n2)
for (let r2 of Object.keys(s)) {
let o = s[r2], l = i2[r2];
if (l === void 0)
i2[r2] = o;
else if (!(l === o || o === void 0))
if (Object.hasOwnProperty.call(e2, r2))
i2[r2] = e2[r2](l, o);
else
throw new Error("Config merge conflict for field " + r2);
}
for (let s in t2)
i2[s] === void 0 && (i2[s] = t2[s]);
return i2;
}
class Qe {
/**
Compare this value with another value. Used when comparing
rangesets. The default implementation compares by identity.
Unless you are only creating a fixed number of unique instances
of your value type, it is a good idea to implement this
properly.
*/
eq(t2) {
return this == t2;
}
/**
Create a [range](https://codemirror.net/6/docs/ref/#state.Range) with this value.
*/
range(t2, e2 = t2) {
return un.create(t2, e2, this);
}
}
Qe.prototype.startSide = Qe.prototype.endSide = 0;
Qe.prototype.point = false;
Qe.prototype.mapMode = mt.TrackDel;
let un = class yl {
constructor(t2, e2, i2) {
this.from = t2, this.to = e2, this.value = i2;
}
/**
@internal
*/
static create(t2, e2, i2) {
return new yl(t2, e2, i2);
}
};
function dn(n2, t2) {
return n2.from - t2.from || n2.value.startSide - t2.value.startSide;
}
class Jn {
constructor(t2, e2, i2, s) {
this.from = t2, this.to = e2, this.value = i2, this.maxPoint = s;
}
get length() {
return this.to[this.to.length - 1];
}
// Find the index of the given position and side. Use the ranges'
// `from` pos when `end == false`, `to` when `end == true`.
findIndex(t2, e2, i2, s = 0) {
let r2 = i2 ? this.to : this.from;
for (let o = s, l = r2.length; ; ) {
if (o == l)
return o;
let h2 = o + l >> 1, a2 = r2[h2] - t2 || (i2 ? this.value[h2].endSide : this.value[h2].startSide) - e2;
if (h2 == o)
return a2 >= 0 ? o : l;
a2 >= 0 ? l = h2 : o = h2 + 1;
}
}
between(t2, e2, i2, s) {
for (let r2 = this.findIndex(e2, -1e9, true), o = this.findIndex(i2, 1e9, false, r2); r2 < o; r2++)
if (s(this.from[r2] + t2, this.to[r2] + t2, this.value[r2]) === false)
return false;
}
map(t2, e2) {
let i2 = [], s = [], r2 = [], o = -1, l = -1;
for (let h2 = 0; h2 < this.value.length; h2++) {
let a2 = this.value[h2], c2 = this.from[h2] + t2, f2 = this.to[h2] + t2, u2, d2;
if (c2 == f2) {
let p2 = e2.mapPos(c2, a2.startSide, a2.mapMode);
if (p2 == null || (u2 = d2 = p2, a2.startSide != a2.endSide && (d2 = e2.mapPos(c2, a2.endSide), d2 < u2)))
continue;
} else if (u2 = e2.mapPos(c2, a2.startSide), d2 = e2.mapPos(f2, a2.endSide), u2 > d2 || u2 == d2 && a2.startSide > 0 && a2.endSide <= 0)
continue;
(d2 - u2 || a2.endSide - a2.startSide) < 0 || (o < 0 && (o = u2), a2.point && (l = Math.max(l, d2 - u2)), i2.push(a2), s.push(u2 - o), r2.push(d2 - o));
}
return { mapped: i2.length ? new Jn(s, r2, i2, l) : null, pos: o };
}
}
class F {
constructor(t2, e2, i2, s) {
this.chunkPos = t2, this.chunk = e2, this.nextLayer = i2, this.maxPoint = s;
}
/**
@internal
*/
static create(t2, e2, i2, s) {
return new F(t2, e2, i2, s);
}
/**
@internal
*/
get length() {
let t2 = this.chunk.length - 1;
return t2 < 0 ? 0 : Math.max(this.chunkEnd(t2), this.nextLayer.length);
}
/**
The number of ranges in the set.
*/
get size() {
if (this.isEmpty)
return 0;
let t2 = this.nextLayer.size;
for (let e2 of this.chunk)
t2 += e2.value.length;
return t2;
}
/**
@internal
*/
chunkEnd(t2) {
return this.chunkPos[t2] + this.chunk[t2].length;
}
/**
Update the range set, optionally adding new ranges or filtering
out existing ones.
(Note: The type parameter is just there as a kludge to work
around TypeScript variance issues that prevented `RangeSet<X>`
from being a subtype of `RangeSet<Y>` when `X` is a subtype of
`Y`.)
*/
update(t2) {
let { add: e2 = [], sort: i2 = false, filterFrom: s = 0, filterTo: r2 = this.length } = t2, o = t2.filter;
if (e2.length == 0 && !o)
return this;
if (i2 && (e2 = e2.slice().sort(dn)), this.isEmpty)
return e2.length ? F.of(e2) : this;
let l = new bl(this, null, -1).goto(0), h2 = 0, a2 = [], c2 = new Ee();
for (; l.value || h2 < e2.length; )
if (h2 < e2.length && (l.from - e2[h2].from || l.startSide - e2[h2].value.startSide) >= 0) {
let f2 = e2[h2++];
c2.addInner(f2.from, f2.to, f2.value) || a2.push(f2);
} else
l.rangeIndex == 1 && l.chunkIndex < this.chunk.length && (h2 == e2.length || this.chunkEnd(l.chunkIndex) < e2[h2].from) && (!o || s > this.chunkEnd(l.chunkIndex) || r2 < this.chunkPos[l.chunkIndex]) && c2.addChunk(this.chunkPos[l.chunkIndex], this.chunk[l.chunkIndex]) ? l.nextChunk() : ((!o || s > l.to || r2 < l.from || o(l.from, l.to, l.value)) && (c2.addInner(l.from, l.to, l.value) || a2.push(un.create(l.from, l.to, l.value))), l.next());
return c2.finishInner(this.nextLayer.isEmpty && !a2.length ? F.empty : this.nextLayer.update({ add: a2, filter: o, filterFrom: s, filterTo: r2 }));
}
/**
Map this range set through a set of changes, return the new set.
*/
map(t2) {
if (t2.empty || this.isEmpty)
return this;
let e2 = [], i2 = [], s = -1;
for (let o = 0; o < this.chunk.length; o++) {
let l = this.chunkPos[o], h2 = this.chunk[o], a2 = t2.touchesRange(l, l + h2.length);
if (a2 === false)
s = Math.max(s, h2.maxPoint), e2.push(h2), i2.push(t2.mapPos(l));
else if (a2 === true) {
let { mapped: c2, pos: f2 } = h2.map(l, t2);
c2 && (s = Math.max(s, c2.maxPoint), e2.push(c2), i2.push(f2));
}
}
let r2 = this.nextLayer.map(t2);
return e2.length == 0 ? r2 : new F(i2, e2, r2 || F.empty, s);
}
/**
Iterate over the ranges that touch the region `from` to `to`,
calling `f` for each. There is no guarantee that the ranges will
be reported in any specific order. When the callback returns
`false`, iteration stops.
*/
between(t2, e2, i2) {
if (!this.isEmpty) {
for (let s = 0; s < this.chunk.length; s++) {
let r2 = this.chunkPos[s], o = this.chunk[s];
if (e2 >= r2 && t2 <= r2 + o.length && o.between(r2, t2 - r2, e2 - r2, i2) === false)
return;
}
this.nextLayer.between(t2, e2, i2);
}
}
/**
Iterate over the ranges in this set, in order, including all
ranges that end at or after `from`.
*/
iter(t2 = 0) {
return wi.from([this]).goto(t2);
}
/**
@internal
*/
get isEmpty() {
return this.nextLayer == this;
}
/**
Iterate over the ranges in a collection of sets, in order,
starting from `from`.
*/
static iter(t2, e2 = 0) {
return wi.from(t2).goto(e2);
}
/**
Iterate over two groups of sets, calling methods on `comparator`
to notify it of possible differences.
*/
static compare(t2, e2, i2, s, r2 = -1) {
let o = t2.filter((f2) => f2.maxPoint > 0 || !f2.isEmpty && f2.maxPoint >= r2), l = e2.filter((f2) => f2.maxPoint > 0 || !f2.isEmpty && f2.maxPoint >= r2), h2 = Cr(o, l, i2), a2 = new si(o, h2, r2), c2 = new si(l, h2, r2);
i2.iterGaps((f2, u2, d2) => Ar(a2, f2, c2, u2, d2, s)), i2.empty && i2.length == 0 && Ar(a2, 0, c2, 0, 0, s);
}
/**
Compare the contents of two groups of range sets, returning true
if they are equivalent in the given range.
*/
static eq(t2, e2, i2 = 0, s) {
s == null && (s = 999999999);
let r2 = t2.filter((c2) => !c2.isEmpty && e2.indexOf(c2) < 0), o = e2.filter((c2) => !c2.isEmpty && t2.indexOf(c2) < 0);
if (r2.length != o.length)
return false;
if (!r2.length)
return true;
let l = Cr(r2, o), h2 = new si(r2, l, 0).goto(i2), a2 = new si(o, l, 0).goto(i2);
for (; ; ) {
if (h2.to != a2.to || !pn(h2.active, a2.active) || h2.point && (!a2.point || !h2.point.eq(a2.point)))
return false;
if (h2.to > s)
return true;
h2.next(), a2.next();
}
}
/**
Iterate over a group of range sets at the same time, notifying
the iterator about the ranges covering every given piece of
content. Returns the open count (see
[`SpanIterator.span`](https://codemirror.net/6/docs/ref/#state.SpanIterator.span)) at the end
of the iteration.
*/
static spans(t2, e2, i2, s, r2 = -1) {
let o = new si(t2, null, r2).goto(e2), l = e2, h2 = o.openStart;
for (; ; ) {
let a2 = Math.min(o.to, i2);
if (o.point) {
let c2 = o.activeForPoint(o.to), f2 = o.pointFrom < e2 ? c2.length + 1 : Math.min(c2.length, h2);
s.point(l, a2, o.point, c2, f2, o.pointRank), h2 = Math.min(o.openEnd(a2), c2.length);
} else
a2 > l && (s.span(l, a2, o.active, h2), h2 = o.openEnd(a2));
if (o.to > i2)
return h2 + (o.point && o.to > i2 ? 1 : 0);
l = o.to, o.next();
}
}
/**
Create a range set for the given range or array of ranges. By
default, this expects the ranges to be _sorted_ (by start
position and, if two start at the same position,
`value.startSide`). You can pass `true` as second argument to
cause the method to sort them.
*/
static of(t2, e2 = false) {
let i2 = new Ee();
for (let s of t2 instanceof un ? [t2] : e2 ? Yc(t2) : t2)
i2.add(s.from, s.to, s.value);
return i2.finish();
}
}
F.empty = /* @__PURE__ */ new F([], [], null, -1);
function Yc(n2) {
if (n2.length > 1)
for (let t2 = n2[0], e2 = 1; e2 < n2.length; e2++) {
let i2 = n2[e2];
if (dn(t2, i2) > 0)
return n2.slice().sort(dn);
t2 = i2;
}
return n2;
}
F.empty.nextLayer = F.empty;
class Ee {
finishChunk(t2) {
this.chunks.push(new Jn(this.from, this.to, this.value, this.maxPoint)), this.chunkPos.push(this.chunkStart), this.chunkStart = -1, this.setMaxPoint = Math.max(this.setMaxPoint, this.maxPoint), this.maxPoint = -1, t2 && (this.from = [], this.to = [], this.value = []);
}
/**
Create an empty builder.
*/
constructor() {
this.chunks = [], this.chunkPos = [], this.chunkStart = -1, this.last = null, this.lastFrom = -1e9, this.lastTo = -1e9, this.from = [], this.to = [], this.value = [], this.maxPoint = -1, this.setMaxPoint = -1, this.nextLayer = null;
}
/**
Add a range. Ranges should be added in sorted (by `from` and
`value.startSide`) order.
*/
add(t2, e2, i2) {
this.addInner(t2, e2, i2) || (this.nextLayer || (this.nextLayer = new Ee())).add(t2, e2, i2);
}
/**
@internal
*/
addInner(t2, e2, i2) {
let s = t2 - this.lastTo || i2.startSide - this.last.endSide;
if (s <= 0 && (t2 - this.lastFrom || i2.startSide - this.last.startSide) < 0)
throw new Error("Ranges must be added sorted by `from` position and `startSide`");
return s < 0 ? false : (this.from.length == 250 && this.finishChunk(true), this.chunkStart < 0 && (this.chunkStart = t2), this.from.push(t2 - this.chunkStart), this.to.push(e2 - this.chunkStart), this.last = i2, this.lastFrom = t2, this.lastTo = e2, this.value.push(i2), i2.point && (this.maxPoint = Math.max(this.maxPoint, e2 - t2)), true);
}
/**
@internal
*/
addChunk(t2, e2) {
if ((t2 - this.lastTo || e2.value[0].startSide - this.last.endSide) < 0)
return false;
this.from.length && this.finishChunk(true), this.setMaxPoint = Math.max(this.setMaxPoint, e2.maxPoint), this.chunks.push(e2), this.chunkPos.push(t2);
let i2 = e2.value.length - 1;
return this.last = e2.value[i2], this.lastFrom = e2.from[i2] + t2, this.lastTo = e2.to[i2] + t2, true;
}
/**
Finish the range set. Returns the new set. The builder can't be
used anymore after this has been called.
*/
finish() {
return this.finishInner(F.empty);
}
/**
@internal
*/
finishInner(t2) {
if (this.from.length && this.finishChunk(false), this.chunks.length == 0)
return t2;
let e2 = F.create(this.chunkPos, this.chunks, this.nextLayer ? this.nextLayer.finishInner(t2) : t2, this.setMaxPoint);
return this.from = null, e2;
}
}
function Cr(n2, t2, e2) {
let i2 = /* @__PURE__ */ new Map();
for (let r2 of n2)
for (let o = 0; o < r2.chunk.length; o++)
r2.chunk[o].maxPoint <= 0 && i2.set(r2.chunk[o], r2.chunkPos[o]);
let s = /* @__PURE__ */ new Set();
for (let r2 of t2)
for (let o = 0; o < r2.chunk.length; o++) {
let l = i2.get(r2.chunk[o]);
l != null && (e2 ? e2.mapPos(l) : l) == r2.chunkPos[o] && !(e2 != null && e2.touchesRange(l, l + r2.chunk[o].length)) && s.add(r2.chunk[o]);
}
return s;
}
class bl {
constructor(t2, e2, i2, s = 0) {
this.layer = t2, this.skip = e2, this.minPoint = i2, this.rank = s;
}
get startSide() {
return this.value ? this.value.startSide : 0;
}
get endSide() {
return this.value ? this.value.endSide : 0;
}
goto(t2, e2 = -1e9) {
return this.chunkIndex = this.rangeIndex = 0, this.gotoInner(t2, e2, false), this;
}
gotoInner(t2, e2, i2) {
for (; this.chunkIndex < this.layer.chunk.length; ) {
let s = this.layer.chunk[this.chunkIndex];
if (!(this.skip && this.skip.has(s) || this.layer.chunkEnd(this.chunkIndex) < t2 || s.maxPoint < this.minPoint))
break;
this.chunkIndex++, i2 = false;
}
if (this.chunkIndex < this.layer.chunk.length) {
let s = this.layer.chunk[this.chunkIndex].findIndex(t2 - this.layer.chunkPos[this.chunkIndex], e2, true);
(!i2 || this.rangeIndex < s) && this.setRangeIndex(s);
}
this.next();
}
forward(t2, e2) {
(this.to - t2 || this.endSide - e2) < 0 && this.gotoInner(t2, e2, true);
}
next() {
for (; ; )
if (this.chunkIndex == this.layer.chunk.length) {
this.from = this.to = 1e9, this.value = null;
break;
} else {
let t2 = this.layer.chunkPos[this.chunkIndex], e2 = this.layer.chunk[this.chunkIndex], i2 = t2 + e2.from[this.rangeIndex];
if (this.from = i2, this.to = t2 + e2.to[this.rangeIndex], this.value = e2.value[this.rangeIndex], this.setRangeIndex(this.rangeIndex + 1), this.minPoint < 0 || this.value.point && this.to - this.from >= this.minPoint)
break;
}
}
setRangeIndex(t2) {
if (t2 == this.layer.chunk[this.chunkIndex].value.length) {
if (this.chunkIndex++, this.skip)
for (; this.chunkIndex < this.layer.chunk.length && this.skip.has(this.layer.chunk[this.chunkIndex]); )
this.chunkIndex++;
this.rangeIndex = 0;
} else
this.rangeIndex = t2;
}
nextChunk() {
this.chunkIndex++, this.rangeIndex = 0, this.next();
}
compare(t2) {
return this.from - t2.from || this.startSide - t2.startSide || this.rank - t2.rank || this.to - t2.to || this.endSide - t2.endSide;
}
}
class wi {
constructor(t2) {
this.heap = t2;
}
static from(t2, e2 = null, i2 = -1) {
let s = [];
for (let r2 = 0; r2 < t2.length; r2++)
for (let o = t2[r2]; !o.isEmpty; o = o.nextLayer)
o.maxPoint >= i2 && s.push(new bl(o, e2, i2, r2));
return s.length == 1 ? s[0] : new wi(s);
}
get startSide() {
return this.value ? this.value.startSide : 0;
}
goto(t2, e2 = -1e9) {
for (let i2 of this.heap)
i2.goto(t2, e2);
for (let i2 = this.heap.length >> 1; i2 >= 0; i2--)
Hs(this.heap, i2);
return this.next(), this;
}
forward(t2, e2) {
for (let i2 of this.heap)
i2.forward(t2, e2);
for (let i2 = this.heap.length >> 1; i2 >= 0; i2--)
Hs(this.heap, i2);
(this.to - t2 || this.value.endSide - e2) < 0 && this.next();
}
next() {
if (this.heap.length == 0)
this.from = this.to = 1e9, this.value = null, this.rank = -1;
else {
let t2 = this.heap[0];
this.from = t2.from, this.to = t2.to, this.value = t2.value, this.rank = t2.rank, t2.value && t2.next(), Hs(this.heap, 0);
}
}
}
function Hs(n2, t2) {
for (let e2 = n2[t2]; ; ) {
let i2 = (t2 << 1) + 1;
if (i2 >= n2.length)
break;
let s = n2[i2];
if (i2 + 1 < n2.length && s.compare(n2[i2 + 1]) >= 0 && (s = n2[i2 + 1], i2++), e2.compare(s) < 0)
break;
n2[i2] = e2, n2[t2] = s, t2 = i2;
}
}
class si {
constructor(t2, e2, i2) {
this.minPoint = i2, this.active = [], this.activeTo = [], this.activeRank = [], this.minActive = -1, this.point = null, this.pointFrom = 0, this.pointRank = 0, this.to = -1e9, this.endSide = 0, this.openStart = -1, this.cursor = wi.from(t2, e2, i2);
}
goto(t2, e2 = -1e9) {
return this.cursor.goto(t2, e2), this.active.length = this.activeTo.length = this.activeRank.length = 0, this.minActive = -1, this.to = t2, this.endSide = e2, this.openStart = -1, this.next(), this;
}
forward(t2, e2) {
for (; this.minActive > -1 && (this.activeTo[this.minActive] - t2 || this.active[this.minActive].endSide - e2) < 0; )
this.removeActive(this.minActive);
this.cursor.forward(t2, e2);
}
removeActive(t2) {
Li(this.active, t2), Li(this.activeTo, t2), Li(this.activeRank, t2), this.minActive = Or(this.active, this.activeTo);
}
addActive(t2) {
let e2 = 0, { value: i2, to: s, rank: r2 } = this.cursor;
for (; e2 < this.activeRank.length && this.activeRank[e2] <= r2; )
e2++;
Ei(this.active, e2, i2), Ei(this.activeTo, e2, s), Ei(this.activeRank, e2, r2), t2 && Ei(t2, e2, this.cursor.from), this.minActive = Or(this.active, this.activeTo);
}
// After calling this, if `this.point` != null, the next range is a
// point. Otherwise, it's a regular range, covered by `this.active`.
next() {
let t2 = this.to, e2 = this.point;
this.point = null;
let i2 = this.openStart < 0 ? [] : null;
for (; ; ) {
let s = this.minActive;
if (s > -1 && (this.activeTo[s] - this.cursor.from || this.active[s].endSide - this.cursor.startSide) < 0) {
if (this.activeTo[s] > t2) {
this.to = this.activeTo[s], this.endSide = this.active[s].endSide;
break;
}
this.removeActive(s), i2 && Li(i2, s);
} else if (this.cursor.value)
if (this.cursor.from > t2) {
this.to = this.cursor.from, this.endSide = this.cursor.startSide;
break;
} else {
let r2 = this.cursor.value;
if (!r2.point)
this.addActive(i2), this.cursor.next();
else if (e2 && this.cursor.to == this.to && this.cursor.from < this.cursor.to)
this.cursor.next();
else {
this.point = r2, this.pointFrom = this.cursor.from, this.pointRank = this.cursor.rank, this.to = this.cursor.to, this.endSide = r2.endSide, this.cursor.next(), this.forward(this.to, this.endSide);
break;
}
}
else {
this.to = this.endSide = 1e9;
break;
}
}
if (i2) {
this.openStart = 0;
for (let s = i2.length - 1; s >= 0 && i2[s] < t2; s--)
this.openStart++;
}
}
activeForPoint(t2) {
if (!this.active.length)
return this.active;
let e2 = [];
for (let i2 = this.active.length - 1; i2 >= 0 && !(this.activeRank[i2] < this.pointRank); i2--)
(this.activeTo[i2] > t2 || this.activeTo[i2] == t2 && this.active[i2].endSide >= this.point.endSide) && e2.push(this.active[i2]);
return e2.reverse();
}
openEnd(t2) {
let e2 = 0;
for (let i2 = this.activeTo.length - 1; i2 >= 0 && this.activeTo[i2] > t2; i2--)
e2++;
return e2;
}
}
function Ar(n2, t2, e2, i2, s, r2) {
n2.goto(t2), e2.goto(i2);
let o = i2 + s, l = i2, h2 = i2 - t2;
for (; ; ) {
let a2 = n2.to + h2 - e2.to || n2.endSide - e2.endSide, c2 = a2 < 0 ? n2.to + h2 : e2.to, f2 = Math.min(c2, o);
if (n2.point || e2.point ? n2.point && e2.point && (n2.point == e2.point || n2.point.eq(e2.point)) && pn(n2.activeForPoint(n2.to), e2.activeForPoint(e2.to)) || r2.comparePoint(l, f2, n2.point, e2.point) : f2 > l && !pn(n2.active, e2.active) && r2.compareRange(l, f2, n2.active, e2.active), c2 > o)
break;
l = c2, a2 <= 0 && n2.next(), a2 >= 0 && e2.next();
}
}
function pn(n2, t2) {
if (n2.length != t2.length)
return false;
for (let e2 = 0; e2 < n2.length; e2++)
if (n2[e2] != t2[e2] && !n2[e2].eq(t2[e2]))
return false;
return true;
}
function Li(n2, t2) {
for (let e2 = t2, i2 = n2.length - 1; e2 < i2; e2++)
n2[e2] = n2[e2 + 1];
n2.pop();
}
function Ei(n2, t2, e2) {
for (let i2 = n2.length - 1; i2 >= t2; i2--)
n2[i2 + 1] = n2[i2];
n2[t2] = e2;
}
function Or(n2, t2) {
let e2 = -1, i2 = 1e9;
for (let s = 0; s < t2.length; s++)
(t2[s] - i2 || n2[s].endSide - n2[e2].endSide) < 0 && (e2 = s, i2 = t2[s]);
return e2;
}
function Oi(n2, t2, e2 = n2.length) {
let i2 = 0;
for (let s = 0; s < e2; )
n2.charCodeAt(s) == 9 ? (i2 += t2 - i2 % t2, s++) : (i2++, s = wt(n2, s));
return i2;
}
function Qc(n2, t2, e2, i2) {
for (let s = 0, r2 = 0; ; ) {
if (r2 >= t2)
return s;
if (s == n2.length)
break;
r2 += n2.charCodeAt(s) == 9 ? e2 - r2 % e2 : 1, s = wt(n2, s);
}
return i2 === true ? -1 : n2.length;
}
const gn = "ͼ", Mr = typeof Symbol > "u" ? "__" + gn : Symbol.for(gn), mn = typeof Symbol > "u" ? "__styleSet" + Math.floor(Math.random() * 1e8) : Symbol("styleSet"), Tr = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : {};
class we {
// :: (Object<Style>, ?{finish: ?(string) → string})
// Create a style module from the given spec.
//
// When `finish` is given, it is called on regular (non-`@`)
// selectors (after `&` expansion) to compute the final selector.
constructor(t2, e2) {
this.rules = [];
let { finish: i2 } = e2 || {};
function s(o) {
return /^@/.test(o) ? [o] : o.split(/,\s*/);
}
function r2(o, l, h2, a2) {
let c2 = [], f2 = /^@(\w+)\b/.exec(o[0]), u2 = f2 && f2[1] == "keyframes";
if (f2 && l == null)
return h2.push(o[0] + ";");
for (let d2 in l) {
let p2 = l[d2];
if (/&/.test(d2))
r2(
d2.split(/,\s*/).map((m) => o.map((g) => m.replace(/&/, g))).reduce((m, g) => m.concat(g)),
p2,
h2
);
else if (p2 && typeof p2 == "object") {
if (!f2)
throw new RangeError("The value of a property (" + d2 + ") should be a primitive value.");
r2(s(d2), p2, c2, u2);
} else
p2 != null && c2.push(d2.replace(/_.*/, "").replace(/[A-Z]/g, (m) => "-" + m.toLowerCase()) + ": " + p2 + ";");
}
(c2.length || u2) && h2.push((i2 && !f2 && !a2 ? o.map(i2) : o).join(", ") + " {" + c2.join(" ") + "}");
}
for (let o in t2)
r2(s(o), t2[o], this.rules);
}
// :: () → string
// Returns a string containing the module's CSS rules.
getRules() {
return this.rules.join(`
`);
}
// :: () → string
// Generate a new unique CSS class name.
static newName() {
let t2 = Tr[Mr] || 1;
return Tr[Mr] = t2 + 1, gn + t2.toString(36);
}
// :: (union<Document, ShadowRoot>, union<[StyleModule], StyleModule>, ?{nonce: ?string})
//
// Mount the given set of modules in the given DOM root, which ensures
// that the CSS rules defined by the module are available in that
// context.
//
// Rules are only added to the document once per root.
//
// Rule order will follow the order of the modules, so that rules from
// modules later in the array take precedence of those from earlier
// modules. If you call this function multiple times for the same root
// in a way that changes the order of already mounted modules, the old
// order will be changed.
//
// If a Content Security Policy nonce is provided, it is added to
// the `<style>` tag generated by the library.
static mount(t2, e2, i2) {
let s = t2[mn], r2 = i2 && i2.nonce;
s ? r2 && s.setNonce(r2) : s = new Jc(t2, r2), s.mount(Array.isArray(e2) ? e2 : [e2]);
}
}
let Dr = /* @__PURE__ */ new Map();
class Jc {
constructor(t2, e2) {
let i2 = t2.ownerDocument || t2, s = i2.defaultView;
if (!t2.head && t2.adoptedStyleSheets && s.CSSStyleSheet) {
let r2 = Dr.get(i2);
if (r2)
return t2.adoptedStyleSheets = [r2.sheet, ...t2.adoptedStyleSheets], t2[mn] = r2;
this.sheet = new s.CSSStyleSheet(), t2.adoptedStyleSheets = [this.sheet, ...t2.adoptedStyleSheets], Dr.set(i2, this);
} else {
this.styleTag = i2.createElement("style"), e2 && this.styleTag.setAttribute("nonce", e2);
let r2 = t2.head || t2;
r2.insertBefore(this.styleTag, r2.firstChild);
}
this.modules = [], t2[mn] = this;
}
mount(t2) {
let e2 = this.sheet, i2 = 0, s = 0;
for (let r2 = 0; r2 < t2.length; r2++) {
let o = t2[r2], l = this.modules.indexOf(o);
if (l < s && l > -1 && (this.modules.splice(l, 1), s--, l = -1), l == -1) {
if (this.modules.splice(s++, 0, o), e2)
for (let h2 = 0; h2 < o.rules.length; h2++)
e2.insertRule(o.rules[h2], i2++);
} else {
for (; s < l; )
i2 += this.modules[s++].rules.length;
i2 += o.rules.length, s++;
}
}
if (!e2) {
let r2 = "";
for (let o = 0; o < this.modules.length; o++)
r2 += this.modules[o].getRules() + `
`;
this.styleTag.textContent = r2;
}
}
setNonce(t2) {
this.styleTag && this.styleTag.getAttribute("nonce") != t2 && this.styleTag.setAttribute("nonce", t2);
}
}
var ye = {
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: "'"
}, yi = {
48: ")",
49: "!",
50: "@",
51: "#",
52: "$",
53: "%",
54: "^",
55: "&",
56: "*",
57: "(",
59: ":",
61: "+",
173: "_",
186: ":",
187: "+",
188: "<",
189: "_",
190: ">",
191: "?",
192: "~",
219: "{",
220: "|",
221: "}",
222: '"'
}, Xc = typeof navigator < "u" && /Mac/.test(navigator.platform), Zc = typeof navigator < "u" && /MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);
for (var ot = 0; ot < 10; ot++)
ye[48 + ot] = ye[96 + ot] = String(ot);
for (var ot = 1; ot <= 24; ot++)
ye[ot + 111] = "F" + ot;
for (var ot = 65; ot <= 90; ot++)
ye[ot] = String.fromCharCode(ot + 32), yi[ot] = String.fromCharCode(ot);
for (var $s in ye)
yi.hasOwnProperty($s) || (yi[$s] = ye[$s]);
function tf(n2) {
var t2 = Xc && n2.metaKey && n2.shiftKey && !n2.ctrlKey && !n2.altKey || Zc && n2.shiftKey && n2.key && n2.key.length == 1 || n2.key == "Unidentified", e2 = !t2 && n2.key || (n2.shiftKey ? yi : ye)[n2.keyCode] || n2.key || "Unidentified";
return e2 == "Esc" && (e2 = "Escape"), e2 == "Del" && (e2 = "Delete"), e2 == "Left" && (e2 = "ArrowLeft"), e2 == "Up" && (e2 = "ArrowUp"), e2 == "Right" && (e2 = "ArrowRight"), e2 == "Down" && (e2 = "ArrowDown"), e2;
}
function us(n2) {
let t2;
return n2.nodeType == 11 ? t2 = n2.getSelection ? n2 : n2.ownerDocument : t2 = n2, t2.getSelection();
}
function wn(n2, t2) {
return t2 ? n2 == t2 || n2.contains(t2.nodeType != 1 ? t2.parentNode : t2) : false;
}
function ef(n2) {
let t2 = n2.activeElement;
for (; t2 && t2.shadowRoot; )
t2 = t2.shadowRoot.activeElement;
return t2;
}
function ts(n2, t2) {
if (!t2.anchorNode)
return false;
try {
return wn(n2, t2.anchorNode);
} catch {
return false;
}
}
function bi(n2) {
return n2.nodeType == 3 ? Ne(n2, 0, n2.nodeValue.length).getClientRects() : n2.nodeType == 1 ? n2.getClientRects() : [];
}
function ds(n2, t2, e2, i2) {
return e2 ? Pr(n2, t2, e2, i2, -1) || Pr(n2, t2, e2, i2, 1) : false;
}
function ki(n2) {
for (var t2 = 0; ; t2++)
if (n2 = n2.previousSibling, !n2)
return t2;
}
function Pr(n2, t2, e2, i2, s) {
for (; ; ) {
if (n2 == e2 && t2 == i2)
return true;
if (t2 == (s < 0 ? 0 : ne(n2))) {
if (n2.nodeName == "DIV")
return false;
let r2 = n2.parentNode;
if (!r2 || r2.nodeType != 1)
return false;
t2 = ki(n2) + (s < 0 ? 0 : 1), n2 = r2;
} else if (n2.nodeType == 1) {
if (n2 = n2.childNodes[t2 + (s < 0 ? -1 : 0)], n2.nodeType == 1 && n2.contentEditable == "false")
return false;
t2 = s < 0 ? ne(n2) : 0;
} else
return false;
}
}
function ne(n2) {
return n2.nodeType == 3 ? n2.nodeValue.length : n2.childNodes.length;
}
function Xn(n2, t2) {
let e2 = t2 ? n2.left : n2.right;
return { left: e2, right: e2, top: n2.top, bottom: n2.bottom };
}
function sf(n2) {
return {
left: 0,
right: n2.innerWidth,
top: 0,
bottom: n2.innerHeight
};
}
function nf(n2, t2, e2, i2, s, r2, o, l) {
let h2 = n2.ownerDocument, a2 = h2.defaultView || window;
for (let c2 = n2, f2 = false; c2 && !f2; )
if (c2.nodeType == 1) {
let u2, d2 = c2 == h2.body, p2 = 1, m = 1;
if (d2)
u2 = sf(a2);
else {
if (/^(fixed|sticky)$/.test(getComputedStyle(c2).position) && (f2 = true), c2.scrollHeight <= c2.clientHeight && c2.scrollWidth <= c2.clientWidth) {
c2 = c2.assignedSlot || c2.parentNode;
continue;
}
let x2 = c2.getBoundingClientRect();
p2 = x2.width / c2.offsetWidth, m = x2.height / c2.offsetHeight, u2 = {
left: x2.left,
right: x2.left + c2.clientWidth * p2,
top: x2.top,
bottom: x2.top + c2.clientHeight * m
};
}
let g = 0, y2 = 0;
if (s == "nearest")
t2.top < u2.top ? (y2 = -(u2.top - t2.top + o), e2 > 0 && t2.bottom > u2.bottom + y2 && (y2 = t2.bottom - u2.bottom + y2 + o)) : t2.bottom > u2.bottom && (y2 = t2.bottom - u2.bottom + o, e2 < 0 && t2.top - y2 < u2.top && (y2 = -(u2.top + y2 - t2.top + o)));
else {
let x2 = t2.bottom - t2.top, S2 = u2.bottom - u2.top;
y2 = (s == "center" && x2 <= S2 ? t2.top + x2 / 2 - S2 / 2 : s == "start" || s == "center" && e2 < 0 ? t2.top - o : t2.bottom - S2 + o) - u2.top;
}
if (i2 == "nearest" ? t2.left < u2.left ? (g = -(u2.left - t2.left + r2), e2 > 0 && t2.right > u2.right + g && (g = t2.right - u2.right + g + r2)) : t2.right > u2.right && (g = t2.right - u2.right + r2, e2 < 0 && t2.left < u2.left + g && (g = -(u2.left + g - t2.left + r2))) : g = (i2 == "center" ? t2.left + (t2.right - t2.left) / 2 - (u2.right - u2.left) / 2 : i2 == "start" == l ? t2.left - r2 : t2.right - (u2.right - u2.left) + r2) - u2.left, g || y2)
if (d2)
a2.scrollBy(g, y2);
else {
let x2 = 0, S2 = 0;
if (y2) {
let v2 = c2.scrollTop;
c2.scrollTop += y2 / m, S2 = (c2.scrollTop - v2) * m;
}
if (g) {
let v2 = c2.scrollLeft;
c2.scrollLeft += g / p2, x2 = (c2.scrollLeft - v2) * p2;
}
t2 = {
left: t2.left - x2,
top: t2.top - S2,
right: t2.right - x2,
bottom: t2.bottom - S2
}, x2 && Math.abs(x2 - g) < 1 && (i2 = "nearest"), S2 && Math.abs(S2 - y2) < 1 && (s = "nearest");
}
if (d2)
break;
c2 = c2.assignedSlot || c2.parentNode;
} else if (c2.nodeType == 11)
c2 = c2.host;
else
break;
}
function rf(n2) {
let t2 = n2.ownerDocument;
for (let e2 = n2.parentNode; e2 && e2 != t2.body; )
if (e2.nodeType == 1) {
if (e2.scrollHeight > e2.clientHeight || e2.scrollWidth > e2.clientWidth)
return e2;
e2 = e2.assignedSlot || e2.parentNode;
} else if (e2.nodeType == 11)
e2 = e2.host;
else
break;
return null;
}
class of {
constructor() {
this.anchorNode = null, this.anchorOffset = 0, this.focusNode = null, this.focusOffset = 0;
}
eq(t2) {
return this.anchorNode == t2.anchorNode && this.anchorOffset == t2.anchorOffset && this.focusNode == t2.focusNode && this.focusOffset == t2.focusOffset;
}
setRange(t2) {
let { anchorNode: e2, focusNode: i2 } = t2;
this.set(e2, Math.min(t2.anchorOffset, e2 ? ne(e2) : 0), i2, Math.min(t2.focusOffset, i2 ? ne(i2) : 0));
}
set(t2, e2, i2, s) {
this.anchorNode = t2, this.anchorOffset = e2, this.focusNode = i2, this.focusOffset = s;
}
}
let _e = null;
function kl(n2) {
if (n2.setActive)
return n2.setActive();
if (_e)
return n2.focus(_e);
let t2 = [];
for (let e2 = n2; e2 && (t2.push(e2, e2.scrollTop, e2.scrollLeft), e2 != e2.ownerDocument); e2 = e2.parentNode)
;
if (n2.focus(_e == null ? {
get preventScroll() {
return _e = { preventScroll: true }, true;
}
} : void 0), !_e) {
_e = false;
for (let e2 = 0; e2 < t2.length; ) {
let i2 = t2[e2++], s = t2[e2++], r2 = t2[e2++];
i2.scrollTop != s && (i2.scrollTop = s), i2.scrollLeft != r2 && (i2.scrollLeft = r2);
}
}
}
let Br;
function Ne(n2, t2, e2 = t2) {
let i2 = Br || (Br = document.createRange());
return i2.setEnd(n2, e2), i2.setStart(n2, t2), i2;
}
function Ke(n2, t2, e2) {
let i2 = { key: t2, code: t2, keyCode: e2, which: e2, cancelable: true }, s = new KeyboardEvent("keydown", i2);
s.synthetic = true, n2.dispatchEvent(s);
let r2 = new KeyboardEvent("keyup", i2);
return r2.synthetic = true, n2.dispatchEvent(r2), s.defaultPrevented || r2.defaultPrevented;
}
function lf(n2) {
for (; n2; ) {
if (n2 && (n2.nodeType == 9 || n2.nodeType == 11 && n2.host))
return n2;
n2 = n2.assignedSlot || n2.parentNode;
}
return null;
}
function xl(n2) {
for (; n2.attributes.length; )
n2.removeAttributeNode(n2.attributes[0]);
}
function hf(n2, t2) {
let e2 = t2.focusNode, i2 = t2.focusOffset;
if (!e2 || t2.anchorNode != e2 || t2.anchorOffset != i2)
return false;
for (i2 = Math.min(i2, ne(e2)); ; )
if (i2) {
if (e2.nodeType != 1)
return false;
let s = e2.childNodes[i2 - 1];
s.contentEditable == "false" ? i2-- : (e2 = s, i2 = ne(e2));
} else {
if (e2 == n2)
return true;
i2 = ki(e2), e2 = e2.parentNode;
}
}
function vl(n2) {
return n2.scrollTop > Math.max(1, n2.scrollHeight - n2.clientHeight - 4);
}
class ct {
constructor(t2, e2, i2 = true) {
this.node = t2, this.offset = e2, this.precise = i2;
}
static before(t2, e2) {
return new ct(t2.parentNode, ki(t2), e2);
}
static after(t2, e2) {
return new ct(t2.parentNode, ki(t2) + 1, e2);
}
}
const Zn = [];
let q$1 = class q2 {
constructor() {
this.parent = null, this.dom = null, this.flags = 2;
}
get overrideDOMText() {
return null;
}
get posAtStart() {
return this.parent ? this.parent.posBefore(this) : 0;
}
get posAtEnd() {
return this.posAtStart + this.length;
}
posBefore(t2) {
let e2 = this.posAtStart;
for (let i2 of this.children) {
if (i2 == t2)
return e2;
e2 += i2.length + i2.breakAfter;
}
throw new RangeError("Invalid child in posBefore");
}
posAfter(t2) {
return this.posBefore(t2) + t2.length;
}
sync(t2, e2) {
if (this.flags & 2) {
let i2 = this.dom, s = null, r2;
for (let o of this.children) {
if (o.flags & 7) {
if (!o.dom && (r2 = s ? s.nextSibling : i2.firstChild)) {
let l = q2.get(r2);
(!l || !l.parent && l.canReuseDOM(o)) && o.reuseDOM(r2);
}
o.sync(t2, e2), o.flags &= -8;
}
if (r2 = s ? s.nextSibling : i2.firstChild, e2 && !e2.written && e2.node == i2 && r2 != o.dom && (e2.written = true), o.dom.parentNode == i2)
for (; r2 && r2 != o.dom; )
r2 = Rr(r2);
else
i2.insertBefore(o.dom, r2);
s = o.dom;
}
for (r2 = s ? s.nextSibling : i2.firstChild, r2 && e2 && e2.node == i2 && (e2.written = true); r2; )
r2 = Rr(r2);
} else if (this.flags & 1)
for (let i2 of this.children)
i2.flags & 7 && (i2.sync(t2, e2), i2.flags &= -8);
}
reuseDOM(t2) {
}
localPosFromDOM(t2, e2) {
let i2;
if (t2 == this.dom)
i2 = this.dom.childNodes[e2];
else {
let s = ne(t2) == 0 ? 0 : e2 == 0 ? -1 : 1;
for (; ; ) {
let r2 = t2.parentNode;
if (r2 == this.dom)
break;
s == 0 && r2.firstChild != r2.lastChild && (t2 == r2.firstChild ? s = -1 : s = 1), t2 = r2;
}
s < 0 ? i2 = t2 : i2 = t2.nextSibling;
}
if (i2 == this.dom.firstChild)
return 0;
for (; i2 && !q2.get(i2); )
i2 = i2.nextSibling;
if (!i2)
return this.length;
for (let s = 0, r2 = 0; ; s++) {
let o = this.children[s];
if (o.dom == i2)
return r2;
r2 += o.length + o.breakAfter;
}
}
domBoundsAround(t2, e2, i2 = 0) {
let s = -1, r2 = -1, o = -1, l = -1;
for (let h2 = 0, a2 = i2, c2 = i2; h2 < this.children.length; h2++) {
let f2 = this.children[h2], u2 = a2 + f2.length;
if (a2 < t2 && u2 > e2)
return f2.domBoundsAround(t2, e2, a2);
if (u2 >= t2 && s == -1 && (s = h2, r2 = a2), a2 > e2 && f2.dom.parentNode == this.dom) {
o = h2, l = c2;
break;
}
c2 = u2, a2 = u2 + f2.breakAfter;
}
return {
from: r2,
to: l < 0 ? i2 + this.length : l,
startDOM: (s ? this.children[s - 1].dom.nextSibling : null) || this.dom.firstChild,
endDOM: o < this.children.length && o >= 0 ? this.children[o].dom : null
};
}
markDirty(t2 = false) {
this.flags |= 2, this.markParentsDirty(t2);
}
markParentsDirty(t2) {
for (let e2 = this.parent; e2; e2 = e2.parent) {
if (t2 && (e2.flags |= 2), e2.flags & 1)
return;
e2.flags |= 1, t2 = false;
}
}
setParent(t2) {
this.parent != t2 && (this.parent = t2, this.flags & 7 && this.markParentsDirty(true));
}
setDOM(t2) {
this.dom != t2 && (this.dom && (this.dom.cmView = null), this.dom = t2, t2.cmView = this);
}
get rootView() {
for (let t2 = this; ; ) {
let e2 = t2.parent;
if (!e2)
return t2;
t2 = e2;
}
}
replaceChildren(t2, e2, i2 = Zn) {
this.markDirty();
for (let s = t2; s < e2; s++) {
let r2 = this.children[s];
r2.parent == this && r2.destroy();
}
this.children.splice(t2, e2 - t2, ...i2);
for (let s = 0; s < i2.length; s++)
i2[s].setParent(this);
}
ignoreMutation(t2) {
return false;
}
ignoreEvent(t2) {
return false;
}
childCursor(t2 = this.length) {
return new Sl(this.children, t2, this.children.length);
}
childPos(t2, e2 = 1) {
return this.childCursor().findPos(t2, e2);
}
toString() {
let t2 = this.constructor.name.replace("View", "");
return t2 + (this.children.length ? "(" + this.children.join() + ")" : this.length ? "[" + (t2 == "Text" ? this.text : this.length) + "]" : "") + (this.breakAfter ? "#" : "");
}
static get(t2) {
return t2.cmView;
}
get isEditable() {
return true;
}
get isWidget() {
return false;
}
get isHidden() {
return false;
}
merge(t2, e2, i2, s, r2, o) {
return false;
}
become(t2) {
return false;
}
canReuseDOM(t2) {
return t2.constructor == this.constructor && !((this.flags | t2.flags) & 8);
}
// When this is a zero-length view with a side, this should return a
// number <= 0 to indicate it is before its position, or a
// number > 0 when after its position.
getSide() {
return 0;
}
destroy() {
this.parent = null;
}
};
q$1.prototype.breakAfter = 0;
function Rr(n2) {
let t2 = n2.nextSibling;
return n2.parentNode.removeChild(n2), t2;
}
class Sl {
constructor(t2, e2, i2) {
this.children = t2, this.pos = e2, this.i = i2, this.off = 0;
}
findPos(t2, e2 = 1) {
for (; ; ) {
if (t2 > this.pos || t2 == this.pos && (e2 > 0 || this.i == 0 || this.children[this.i - 1].breakAfter))
return this.off = t2 - this.pos, this;
let i2 = this.children[--this.i];
this.pos -= i2.length + i2.breakAfter;
}
}
}
function Cl(n2, t2, e2, i2, s, r2, o, l, h2) {
let { children: a2 } = n2, c2 = a2.length ? a2[t2] : null, f2 = r2.length ? r2[r2.length - 1] : null, u2 = f2 ? f2.breakAfter : o;
if (!(t2 == i2 && c2 && !o && !u2 && r2.length < 2 && c2.merge(e2, s, r2.length ? f2 : null, e2 == 0, l, h2))) {
if (i2 < a2.length) {
let d2 = a2[i2];
d2 && (s < d2.length || d2.breakAfter && (f2 != null && f2.breakAfter)) ? (t2 == i2 && (d2 = d2.split(s), s = 0), !u2 && f2 && d2.merge(0, s, f2, true, 0, h2) ? r2[r2.length - 1] = d2 : ((s || d2.children.length && !d2.children[0].length) && d2.merge(0, s, null, false, 0, h2), r2.push(d2))) : d2 != null && d2.breakAfter && (f2 ? f2.breakAfter = 1 : o = 1), i2++;
}
for (c2 && (c2.breakAfter = o, e2 > 0 && (!o && r2.length && c2.merge(e2, c2.length, r2[0], false, l, 0) ? c2.breakAfter = r2.shift().breakAfter : (e2 < c2.length || c2.children.length && c2.children[c2.children.length - 1].length == 0) && c2.merge(e2, c2.length, null, false, l, 0), t2++)); t2 < i2 && r2.length; )
if (a2[i2 - 1].become(r2[r2.length - 1]))
i2--, r2.pop(), h2 = r2.length ? 0 : l;
else if (a2[t2].become(r2[0]))
t2++, r2.shift(), l = r2.length ? 0 : h2;
else
break;
!r2.length && t2 && i2 < a2.length && !a2[t2 - 1].breakAfter && a2[i2].merge(0, 0, a2[t2 - 1], false, l, h2) && t2--, (t2 < i2 || r2.length) && n2.replaceChildren(t2, i2, r2);
}
}
function Al(n2, t2, e2, i2, s, r2) {
let o = n2.childCursor(), { i: l, off: h2 } = o.findPos(e2, 1), { i: a2, off: c2 } = o.findPos(t2, -1), f2 = t2 - e2;
for (let u2 of i2)
f2 += u2.length;
n2.length += f2, Cl(n2, a2, c2, l, h2, i2, 0, s, r2);
}
let vt = typeof navigator < "u" ? navigator : { userAgent: "", vendor: "", platform: "" }, yn = typeof document < "u" ? document : { documentElement: { style: {} } };
const bn = /* @__PURE__ */ /Edge\/(\d+)/.exec(vt.userAgent), Ol = /* @__PURE__ */ /MSIE \d/.test(vt.userAgent), kn = /* @__PURE__ */ /Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(vt.userAgent), Ps = !!(Ol || kn || bn), Lr = !Ps && /* @__PURE__ */ /gecko\/(\d+)/i.test(vt.userAgent), Fs = !Ps && /* @__PURE__ */ /Chrome\/(\d+)/.exec(vt.userAgent), Er = "webkitFontSmoothing" in yn.documentElement.style, Ml = !Ps && /* @__PURE__ */ /Apple Computer/.test(vt.vendor), Nr = Ml && (/* @__PURE__ */ /Mobile\/\w+/.test(vt.userAgent) || vt.maxTouchPoints > 2);
var C = {
mac: Nr || /* @__PURE__ */ /Mac/.test(vt.platform),
windows: /* @__PURE__ */ /Win/.test(vt.platform),
linux: /* @__PURE__ */ /Linux|X11/.test(vt.platform),
ie: Ps,
ie_version: Ol ? yn.documentMode || 6 : kn ? +kn[1] : bn ? +bn[1] : 0,
gecko: Lr,
gecko_version: Lr ? +(/* @__PURE__ */ /Firefox\/(\d+)/.exec(vt.userAgent) || [0, 0])[1] : 0,
chrome: !!Fs,
chrome_version: Fs ? +Fs[1] : 0,
ios: Nr,
android: /* @__PURE__ */ /Android\b/.test(vt.userAgent),
webkit: Er,
safari: Ml,
webkit_version: Er ? +(/* @__PURE__ */ /\bAppleWebKit\/(\d+)/.exec(navigator.userAgent) || [0, 0])[1] : 0,
tabSize: yn.documentElement.style.tabSize != null ? "tab-size" : "-moz-tab-size"
};
const af = 256;
class re extends q$1 {
constructor(t2) {
super(), this.text = t2;
}
get length() {
return this.text.length;
}
createDOM(t2) {
this.setDOM(t2 || document.createTextNode(this.text));
}
sync(t2, e2) {
this.dom || this.createDOM(), this.dom.nodeValue != this.text && (e2 && e2.node == this.dom && (e2.written = true), this.dom.nodeValue = this.text);
}
reuseDOM(t2) {
t2.nodeType == 3 && this.createDOM(t2);
}
merge(t2, e2, i2) {
return this.flags & 8 || i2 && (!(i2 instanceof re) || this.length - (e2 - t2) + i2.length > af || i2.flags & 8) ? false : (this.text = this.text.slice(0, t2) + (i2 ? i2.text : "") + this.text.slice(e2), this.markDirty(), true);
}
split(t2) {
let e2 = new re(this.text.slice(t2));
return this.text = this.text.slice(0, t2), this.markDirty(), e2.flags |= this.flags & 8, e2;
}
localPosFromDOM(t2, e2) {
return t2 == this.dom ? e2 : e2 ? this.text.length : 0;
}
domAtPos(t2) {
return new ct(this.dom, t2);
}
domBoundsAround(t2, e2, i2) {
return { from: i2, to: i2 + this.length, startDOM: this.dom, endDOM: this.dom.nextSibling };
}
coordsAt(t2, e2) {
return cf(this.dom, t2, e2);
}
}
class oe extends q$1 {
constructor(t2, e2 = [], i2 = 0) {
super(), this.mark = t2, this.children = e2, this.length = i2;
for (let s of e2)
s.setParent(this);
}
setAttrs(t2) {
if (xl(t2), this.mark.class && (t2.className = this.mark.class), this.mark.attrs)
for (let e2 in this.mark.attrs)
t2.setAttribute(e2, this.mark.attrs[e2]);
return t2;
}
canReuseDOM(t2) {
return super.canReuseDOM(t2) && !((this.flags | t2.flags) & 8);
}
reuseDOM(t2) {
t2.nodeName == this.mark.tagName.toUpperCase() && (this.setDOM(t2), this.flags |= 6);
}
sync(t2, e2) {
this.dom ? this.flags & 4 && this.setAttrs(this.dom) : this.setDOM(this.setAttrs(document.createElement(this.mark.tagName))), super.sync(t2, e2);
}
merge(t2, e2, i2, s, r2, o) {
return i2 && (!(i2 instanceof oe && i2.mark.eq(this.mark)) || t2 && r2 <= 0 || e2 < this.length && o <= 0) ? false : (Al(this, t2, e2, i2 ? i2.children : [], r2 - 1, o - 1), this.markDirty(), true);
}
split(t2) {
let e2 = [], i2 = 0, s = -1, r2 = 0;
for (let l of this.children) {
let h2 = i2 + l.length;
h2 > t2 && e2.push(i2 < t2 ? l.split(t2 - i2) : l), s < 0 && i2 >= t2 && (s = r2), i2 = h2, r2++;
}
let o = this.length - t2;
return this.length = t2, s > -1 && (this.children.length = s, this.markDirty()), new oe(this.mark, e2, o);
}
domAtPos(t2) {
return Tl(this, t2);
}
coordsAt(t2, e2) {
return Pl(this, t2, e2);
}
}
function cf(n2, t2, e2) {
let i2 = n2.nodeValue.length;
t2 > i2 && (t2 = i2);
let s = t2, r2 = t2, o = 0;
t2 == 0 && e2 < 0 || t2 == i2 && e2 >= 0 ? C.chrome || C.gecko || (t2 ? (s--, o = 1) : r2 < i2 && (r2++, o = -1)) : e2 < 0 ? s-- : r2 < i2 && r2++;
let l = Ne(n2, s, r2).getClientRects();
if (!l.length)
return null;
let h2 = l[(o ? o < 0 : e2 >= 0) ? 0 : l.length - 1];
return C.safari && !o && h2.width == 0 && (h2 = Array.prototype.find.call(l, (a2) => a2.width) || h2), o ? Xn(h2, o < 0) : h2 || null;
}
class fe extends q$1 {
static create(t2, e2, i2) {
return new fe(t2, e2, i2);
}
constructor(t2, e2, i2) {
super(), this.widget = t2, this.length = e2, this.side = i2, this.prevWidget = null;
}
split(t2) {
let e2 = fe.create(this.widget, this.length - t2, this.side);
return this.length -= t2, e2;
}
sync(t2) {
(!this.dom || !this.widget.updateDOM(this.dom, t2)) && (this.dom && this.prevWidget && this.prevWidget.destroy(this.dom), this.prevWidget = null, this.setDOM(this.widget.toDOM(t2)), this.dom.contentEditable = "false");
}
getSide() {
return this.side;
}
merge(t2, e2, i2, s, r2, o) {
return i2 && (!(i2 instanceof fe) || !this.widget.compare(i2.widget) || t2 > 0 && r2 <= 0 || e2 < this.length && o <= 0) ? false : (this.length = t2 + (i2 ? i2.length : 0) + (this.length - e2), true);
}
become(t2) {
return t2 instanceof fe && t2.side == this.side && this.widget.constructor == t2.widget.constructor ? (this.widget.compare(t2.widget) || this.markDirty(true), this.dom && !this.prevWidget && (this.prevWidget = this.widget), this.widget = t2.widget, this.length = t2.length, true) : false;
}
ignoreMutation() {
return true;
}
ignoreEvent(t2) {
return this.widget.ignoreEvent(t2);
}
get overrideDOMText() {
if (this.length == 0)
return V.empty;
let t2 = this;
for (; t2.parent; )
t2 = t2.parent;
let { view: e2 } = t2, i2 = e2 && e2.state.doc, s = this.posAtStart;
return i2 ? i2.slice(s, s + this.length) : V.empty;
}
domAtPos(t2) {
return (this.length ? t2 == 0 : this.side > 0) ? ct.before(this.dom) : ct.after(this.dom, t2 == this.length);
}
domBoundsAround() {
return null;
}
coordsAt(t2, e2) {
let i2 = this.widget.coordsAt(this.dom, t2, e2);
if (i2)
return i2;
let s = this.dom.getClientRects(), r2 = null;
if (!s.length)
return null;
let o = this.side ? this.side < 0 : t2 > 0;
for (let l = o ? s.length - 1 : 0; r2 = s[l], !(t2 > 0 ? l == 0 : l == s.length - 1 || r2.top < r2.bottom); l += o ? -1 : 1)
;
return Xn(r2, !o);
}
get isEditable() {
return false;
}
get isWidget() {
return true;
}
get isHidden() {
return this.widget.isHidden;
}
destroy() {
super.destroy(), this.dom && this.widget.destroy(this.dom);
}
}
class Je extends q$1 {
constructor(t2) {
super(), this.side = t2;
}
get length() {
return 0;
}
merge() {
return false;
}
become(t2) {
return t2 instanceof Je && t2.side == this.side;
}
split() {
return new Je(this.side);
}
sync() {
if (!this.dom) {
let t2 = document.createElement("img");
t2.className = "cm-widgetBuffer", t2.setAttribute("aria-hidden", "true"), this.setDOM(t2);
}
}
getSide() {
return this.side;
}
domAtPos(t2) {
return this.side > 0 ? ct.before(this.dom) : ct.after(this.dom);
}
localPosFromDOM() {
return 0;
}
domBoundsAround() {
return null;
}
coordsAt(t2) {
return this.dom.getBoundingClientRect();
}
get overrideDOMText() {
return V.empty;
}
get isHidden() {
return true;
}
}
re.prototype.children = fe.prototype.children = Je.prototype.children = Zn;
function Tl(n2, t2) {
let e2 = n2.dom, { children: i2 } = n2, s = 0;
for (let r2 = 0; s < i2.length; s++) {
let o = i2[s], l = r2 + o.length;
if (!(l == r2 && o.getSide() <= 0)) {
if (t2 > r2 && t2 < l && o.dom.parentNode == e2)
return o.domAtPos(t2 - r2);
if (t2 <= r2)
break;
r2 = l;
}
}
for (let r2 = s; r2 > 0; r2--) {
let o = i2[r2 - 1];
if (o.dom.parentNode == e2)
return o.domAtPos(o.length);
}
for (let r2 = s; r2 < i2.length; r2++) {
let o = i2[r2];
if (o.dom.parentNode == e2)
return o.domAtPos(0);
}
return new ct(e2, 0);
}
function Dl(n2, t2, e2) {
let i2, { children: s } = n2;
e2 > 0 && t2 instanceof oe && s.length && (i2 = s[s.length - 1]) instanceof oe && i2.mark.eq(t2.mark) ? Dl(i2, t2.children[0], e2 - 1) : (s.push(t2), t2.setParent(n2)), n2.length += t2.length;
}
function Pl(n2, t2, e2) {
let i2 = null, s = -1, r2 = null, o = -1;
function l(a2, c2) {
for (let f2 = 0, u2 = 0; f2 < a2.children.length && u2 <= c2; f2++) {
let d2 = a2.children[f2], p2 = u2 + d2.length;
p2 >= c2 && (d2.children.length ? l(d2, c2 - u2) : (!r2 || r2.isHidden && e2 > 0) && (p2 > c2 || u2 == p2 && d2.getSide() > 0) ? (r2 = d2, o = c2 - u2) : (u2 < c2 || u2 == p2 && d2.getSide() < 0 && !d2.isHidden) && (i2 = d2, s = c2 - u2)), u2 = p2;
}
}
l(n2, t2);
let h2 = (e2 < 0 ? i2 : r2) || i2 || r2;
return h2 ? h2.coordsAt(Math.max(0, h2 == i2 ? s : o), e2) : ff(n2);
}
function ff(n2) {
let t2 = n2.dom.lastChild;
if (!t2)
return n2.dom.getBoundingClientRect();
let e2 = bi(t2);
return e2[e2.length - 1] || null;
}
function xn(n2, t2) {
for (let e2 in n2)
e2 == "class" && t2.class ? t2.class += " " + n2.class : e2 == "style" && t2.style ? t2.style += ";" + n2.style : t2[e2] = n2[e2];
return t2;
}
const Ir = /* @__PURE__ */ Object.create(null);
function tr(n2, t2, e2) {
if (n2 == t2)
return true;
n2 || (n2 = Ir), t2 || (t2 = Ir);
let i2 = Object.keys(n2), s = Object.keys(t2);
if (i2.length - (e2 && i2.indexOf(e2) > -1 ? 1 : 0) != s.length - (e2 && s.indexOf(e2) > -1 ? 1 : 0))
return false;
for (let r2 of i2)
if (r2 != e2 && (s.indexOf(r2) == -1 || n2[r2] !== t2[r2]))
return false;
return true;
}
function vn(n2, t2, e2) {
let i2 = false;
if (t2)
for (let s in t2)
e2 && s in e2 || (i2 = true, s == "style" ? n2.style.cssText = "" : n2.removeAttribute(s));
if (e2)
for (let s in e2)
t2 && t2[s] == e2[s] || (i2 = true, s == "style" ? n2.style.cssText = e2[s] : n2.setAttribute(s, e2[s]));
return i2;
}
function uf(n2) {
let t2 = /* @__PURE__ */ Object.create(null);
for (let e2 = 0; e2 < n2.attributes.length; e2++) {
let i2 = n2.attributes[e2];
t2[i2.name] = i2.value;
}
return t2;
}
let Z$1 = class Z2 extends q$1 {
constructor() {
super(...arguments), this.children = [], this.length = 0, this.prevAttrs = void 0, this.attrs = null, this.breakAfter = 0;
}
// Consumes source
merge(t2, e2, i2, s, r2, o) {
if (i2) {
if (!(i2 instanceof Z2))
return false;
this.dom || i2.transferDOM(this);
}
return s && this.setDeco(i2 ? i2.attrs : null), Al(this, t2, e2, i2 ? i2.children : [], r2, o), true;
}
split(t2) {
let e2 = new Z2();
if (e2.breakAfter = this.breakAfter, this.length == 0)
return e2;
let { i: i2, off: s } = this.childPos(t2);
s && (e2.append(this.children[i2].split(s), 0), this.children[i2].merge(s, this.children[i2].length, null, false, 0, 0), i2++);
for (let r2 = i2; r2 < this.children.length; r2++)
e2.append(this.children[r2], 0);
for (; i2 > 0 && this.children[i2 - 1].length == 0; )
this.children[--i2].destroy();
return this.children.length = i2, this.markDirty(), this.length = t2, e2;
}
transferDOM(t2) {
this.dom && (this.markDirty(), t2.setDOM(this.dom), t2.prevAttrs = this.prevAttrs === void 0 ? this.attrs : this.prevAttrs, this.prevAttrs = void 0, this.dom = null);
}
setDeco(t2) {
tr(this.attrs, t2) || (this.dom && (this.prevAttrs = this.attrs, this.markDirty()), this.attrs = t2);
}
append(t2, e2) {
Dl(this, t2, e2);
}
// Only called when building a line view in ContentBuilder
addLineDeco(t2) {
let e2 = t2.spec.attributes, i2 = t2.spec.class;
e2 && (this.attrs = xn(e2, this.attrs || {})), i2 && (this.attrs = xn({ class: i2 }, this.attrs || {}));
}
domAtPos(t2) {
return Tl(this, t2);
}
reuseDOM(t2) {
t2.nodeName == "DIV" && (this.setDOM(t2), this.flags |= 6);
}
sync(t2, e2) {
var i2;
this.dom ? this.flags & 4 && (xl(this.dom), this.dom.className = "cm-line", this.prevAttrs = this.attrs ? null : void 0) : (this.setDOM(document.createElement("div")), this.dom.className = "cm-line", this.prevAttrs = this.attrs ? null : void 0), this.prevAttrs !== void 0 && (vn(this.dom, this.prevAttrs, this.attrs), this.dom.classList.add("cm-line"), this.prevAttrs = void 0), super.sync(t2, e2);
let s = this.dom.lastChild;
for (; s && q$1.get(s) instanceof oe; )
s = s.lastChild;
if (!s || !this.length || s.nodeName != "BR" && ((i2 = q$1.get(s)) === null || i2 === void 0 ? void 0 : i2.isEditable) == false && (!C.ios || !this.children.some((r2) => r2 instanceof re))) {
let r2 = document.createElement("BR");
r2.cmIgnore = true, this.dom.appendChild(r2);
}
}
measureTextSize() {
if (this.children.length == 0 || this.length > 20)
return null;
let t2 = 0, e2;
for (let i2 of this.children) {
if (!(i2 instanceof re) || /[^ -~]/.test(i2.text))
return null;
let s = bi(i2.dom);
if (s.length != 1)
return null;
t2 += s[0].width, e2 = s[0].height;
}
return t2 ? {
lineHeight: this.dom.getBoundingClientRect().height,
charWidth: t2 / this.length,
textHeight: e2
} : null;
}
coordsAt(t2, e2) {
let i2 = Pl(this, t2, e2);
if (!this.children.length && i2 && this.parent) {
let { heightOracle: s } = this.parent.view.viewState, r2 = i2.bottom - i2.top;
if (Math.abs(r2 - s.lineHeight) < 2 && s.textHeight < r2) {
let o = (r2 - s.textHeight) / 2;
return { top: i2.top + o, bottom: i2.bottom - o, left: i2.left, right: i2.left };
}
}
return i2;
}
become(t2) {
return false;
}
covers() {
return true;
}
static find(t2, e2) {
for (let i2 = 0, s = 0; i2 < t2.children.length; i2++) {
let r2 = t2.children[i2], o = s + r2.length;
if (o >= e2) {
if (r2 instanceof Z2)
return r2;
if (o > e2)
break;
}
s = o + r2.breakAfter;
}
return null;
}
};
class pe extends q$1 {
constructor(t2, e2, i2) {
super(), this.widget = t2, this.length = e2, this.deco = i2, this.breakAfter = 0, this.prevWidget = null;
}
merge(t2, e2, i2, s, r2, o) {
return i2 && (!(i2 instanceof pe) || !this.widget.compare(i2.widget) || t2 > 0 && r2 <= 0 || e2 < this.length && o <= 0) ? false : (this.length = t2 + (i2 ? i2.length : 0) + (this.length - e2), true);
}
domAtPos(t2) {
return t2 == 0 ? ct.before(this.dom) : ct.after(this.dom, t2 == this.length);
}
split(t2) {
let e2 = this.length - t2;
this.length = t2;
let i2 = new pe(this.widget, e2, this.deco);
return i2.breakAfter = this.breakAfter, i2;
}
get children() {
return Zn;
}
sync(t2) {
(!this.dom || !this.widget.updateDOM(this.dom, t2)) && (this.dom && this.prevWidget && this.prevWidget.destroy(this.dom), this.prevWidget = null, this.setDOM(this.widget.toDOM(t2)), this.dom.contentEditable = "false");
}
get overrideDOMText() {
return this.parent ? this.parent.view.state.doc.slice(this.posAtStart, this.posAtEnd) : V.empty;
}
domBoundsAround() {
return null;
}
become(t2) {
return t2 instanceof pe && t2.widget.constructor == this.widget.constructor ? (t2.widget.compare(this.widget) || this.markDirty(true), this.dom && !this.prevWidget && (this.prevWidget = this.widget), this.widget = t2.widget, this.length = t2.length, this.deco = t2.deco, this.breakAfter = t2.breakAfter, true) : false;
}
ignoreMutation() {
return true;
}
ignoreEvent(t2) {
return this.widget.ignoreEvent(t2);
}
get isEditable() {
return false;
}
get isWidget() {
return true;
}
coordsAt(t2, e2) {
return this.widget.coordsAt(this.dom, t2, e2);
}
destroy() {
super.destroy(), this.dom && this.widget.destroy(this.dom);
}
covers(t2) {
let { startSide: e2, endSide: i2 } = this.deco;
return e2 == i2 ? false : t2 < 0 ? e2 < 0 : i2 > 0;
}
}
class Se {
/**
Compare this instance to another instance of the same type.
(TypeScript can't express this, but only instances of the same
specific class will be passed to this method.) This is used to
avoid redrawing widgets when they are replaced by a new
decoration of the same type. The default implementation just
returns `false`, which will cause new instances of the widget to
always be redrawn.
*/
eq(t2) {
return false;
}
/**
Update a DOM element created by a widget of the same type (but
different, non-`eq` content) to reflect this widget. May return
true to indicate that it could update, false to indicate it
couldn't (in which case the widget will be redrawn). The default
implementation just returns false.
*/
updateDOM(t2, e2) {
return false;
}
/**
@internal
*/
compare(t2) {
return this == t2 || this.constructor == t2.constructor && this.eq(t2);
}
/**
The estimated height this widget will have, to be used when
estimating the height of content that hasn't been drawn. May
return -1 to indicate you don't know. The default implementation
returns -1.
*/
get estimatedHeight() {
return -1;
}
/**
For inline widgets that are displayed inline (as opposed to
`inline-block`) and introduce line breaks (through `<br>` tags
or textual newlines), this must indicate the amount of line
breaks they introduce. Defaults to 0.
*/
get lineBreaks() {
return 0;
}
/**
Can be used to configure which kinds of events inside the widget
should be ignored by the editor. The default is to ignore all
events.
*/
ignoreEvent(t2) {
return true;
}
/**
Override the way screen coordinates for positions at/in the
widget are found. `pos` will be the offset into the widget, and
`side` the side of the position that is being queried—less than
zero for before, greater than zero for after, and zero for
directly at that position.
*/
coordsAt(t2, e2, i2) {
return null;
}
/**
@internal
*/
get isHidden() {
return false;
}
/**
This is called when the an instance of the widget is removed
from the editor view.
*/
destroy(t2) {
}
}
var Lt = /* @__PURE__ */ function(n2) {
return n2[n2.Text = 0] = "Text", n2[n2.WidgetBefore = 1] = "WidgetBefore", n2[n2.WidgetAfter = 2] = "WidgetAfter", n2[n2.WidgetRange = 3] = "WidgetRange", n2;
}(Lt || (Lt = {}));
let N$2 = class N2 extends Qe {
constructor(t2, e2, i2, s) {
super(), this.startSide = t2, this.endSide = e2, this.widget = i2, this.spec = s;
}
/**
@internal
*/
get heightRelevant() {
return false;
}
/**
Create a mark decoration, which influences the styling of the
content in its range. Nested mark decorations will cause nested
DOM elements to be created. Nesting order is determined by
precedence of the [facet](https://codemirror.net/6/docs/ref/#view.EditorView^decorations), with
the higher-precedence decorations creating the inner DOM nodes.
Such elements are split on line boundaries and on the boundaries
of lower-precedence decorations.
*/
static mark(t2) {
return new Mi(t2);
}
/**
Create a widget decoration, which displays a DOM element at the
given position.
*/
static widget(t2) {
let e2 = Math.max(-1e4, Math.min(1e4, t2.side || 0)), i2 = !!t2.block;
return e2 += i2 && !t2.inlineOrder ? e2 > 0 ? 3e8 : -4e8 : e2 > 0 ? 1e8 : -1e8, new be(t2, e2, e2, i2, t2.widget || null, false);
}
/**
Create a replace decoration which replaces the given range with
a widget, or simply hides it.
*/
static replace(t2) {
let e2 = !!t2.block, i2, s;
if (t2.isBlockGap)
i2 = -5e8, s = 4e8;
else {
let { start: r2, end: o } = Bl(t2, e2);
i2 = (r2 ? e2 ? -3e8 : -1 : 5e8) - 1, s = (o ? e2 ? 2e8 : 1 : -6e8) + 1;
}
return new be(t2, i2, s, e2, t2.widget || null, true);
}
/**
Create a line decoration, which can add DOM attributes to the
line starting at the given position.
*/
static line(t2) {
return new Ti(t2);
}
/**
Build a [`DecorationSet`](https://codemirror.net/6/docs/ref/#view.DecorationSet) from the given
decorated range or ranges. If the ranges aren't already sorted,
pass `true` for `sort` to make the library sort them for you.
*/
static set(t2, e2 = false) {
return F.of(t2, e2);
}
/**
@internal
*/
hasHeight() {
return this.widget ? this.widget.estimatedHeight > -1 : false;
}
};
N$2.none = F.empty;
class Mi extends N$2 {
constructor(t2) {
let { start: e2, end: i2 } = Bl(t2);
super(e2 ? -1 : 5e8, i2 ? 1 : -6e8, null, t2), this.tagName = t2.tagName || "span", this.class = t2.class || "", this.attrs = t2.attributes || null;
}
eq(t2) {
var e2, i2;
return this == t2 || t2 instanceof Mi && this.tagName == t2.tagName && (this.class || ((e2 = this.attrs) === null || e2 === void 0 ? void 0 : e2.class)) == (t2.class || ((i2 = t2.attrs) === null || i2 === void 0 ? void 0 : i2.class)) && tr(this.attrs, t2.attrs, "class");
}
range(t2, e2 = t2) {
if (t2 >= e2)
throw new RangeError("Mark decorations may not be empty");
return super.range(t2, e2);
}
}
Mi.prototype.point = false;
class Ti extends N$2 {
constructor(t2) {
super(-2e8, -2e8, null, t2);
}
eq(t2) {
return t2 instanceof Ti && this.spec.class == t2.spec.class && tr(this.spec.attributes, t2.spec.attributes);
}
range(t2, e2 = t2) {
if (e2 != t2)
throw new RangeError("Line decoration ranges must be zero-length");
return super.range(t2, e2);
}
}
Ti.prototype.mapMode = mt.TrackBefore;
Ti.prototype.point = true;
class be extends N$2 {
constructor(t2, e2, i2, s, r2, o) {
super(e2, i2, r2, t2), this.block = s, this.isReplace = o, this.mapMode = s ? e2 <= 0 ? mt.TrackBefore : mt.TrackAfter : mt.TrackDel;
}
// Only relevant when this.block == true
get type() {
return this.startSide != this.endSide ? Lt.WidgetRange : this.startSide <= 0 ? Lt.WidgetBefore : Lt.WidgetAfter;
}
get heightRelevant() {
return this.block || !!this.widget && (this.widget.estimatedHeight >= 5 || this.widget.lineBreaks > 0);
}
eq(t2) {
return t2 instanceof be && df(this.widget, t2.widget) && this.block == t2.block && this.startSide == t2.startSide && this.endSide == t2.endSide;
}
range(t2, e2 = t2) {
if (this.isReplace && (t2 > e2 || t2 == e2 && this.startSide > 0 && this.endSide <= 0))
throw new RangeError("Invalid range for replacement decoration");
if (!this.isReplace && e2 != t2)
throw new RangeError("Widget decorations can only have zero-length ranges");
return super.range(t2, e2);
}
}
be.prototype.point = true;
function Bl(n2, t2 = false) {
let { inclusiveStart: e2, inclusiveEnd: i2 } = n2;
return e2 == null && (e2 = n2.inclusive), i2 == null && (i2 = n2.inclusive), { start: e2 ?? t2, end: i2 ?? t2 };
}
function df(n2, t2) {
return n2 == t2 || !!(n2 && t2 && n2.compare(t2));
}
function Sn(n2, t2, e2, i2 = 0) {
let s = e2.length - 1;
s >= 0 && e2[s] + i2 >= n2 ? e2[s] = Math.max(e2[s], t2) : e2.push(n2, t2);
}
class gi {
constructor(t2, e2, i2, s) {
this.doc = t2, this.pos = e2, this.end = i2, this.disallowBlockEffectsFor = s, this.content = [], this.curLine = null, this.breakAtStart = 0, this.pendingBuffer = 0, this.bufferMarks = [], this.atCursorPos = true, this.openStart = -1, this.openEnd = -1, this.text = "", this.textOff = 0, this.cursor = t2.iter(), this.skip = e2;
}
posCovered() {
if (this.content.length == 0)
return !this.breakAtStart && this.doc.lineAt(this.pos).from != this.pos;
let t2 = this.content[this.content.length - 1];
return !(t2.breakAfter || t2 instanceof pe && t2.deco.endSide < 0);
}
getLine() {
return this.curLine || (this.content.push(this.curLine = new Z$1()), this.atCursorPos = true), this.curLine;
}
flushBuffer(t2 = this.bufferMarks) {
this.pendingBuffer && (this.curLine.append(Ni(new Je(-1), t2), t2.length), this.pendingBuffer = 0);
}
addBlockWidget(t2) {
this.flushBuffer(), this.curLine = null, this.content.push(t2);
}
finish(t2) {
this.pendingBuffer && t2 <= this.bufferMarks.length ? this.flushBuffer() : this.pendingBuffer = 0, !this.posCovered() && !(t2 && this.content.length && this.content[this.content.length - 1] instanceof pe) && this.getLine();
}
buildText(t2, e2, i2) {
for (; t2 > 0; ) {
if (this.textOff == this.text.length) {
let { value: r2, lineBreak: o, done: l } = this.cursor.next(this.skip);
if (this.skip = 0, l)
throw new Error("Ran out of text content when drawing inline views");
if (o) {
this.posCovered() || this.getLine(), this.content.length ? this.content[this.content.length - 1].breakAfter = 1 : this.breakAtStart = 1, this.flushBuffer(), this.curLine = null, this.atCursorPos = true, t2--;
continue;
} else
this.text = r2, this.textOff = 0;
}
let s = Math.min(
this.text.length - this.textOff,
t2,
512
/* T.Chunk */
);
this.flushBuffer(e2.slice(e2.length - i2)), this.getLine().append(Ni(new re(this.text.slice(this.textOff, this.textOff + s)), e2), i2), this.atCursorPos = true, this.textOff += s, t2 -= s, i2 = 0;
}
}
span(t2, e2, i2, s) {
this.buildText(e2 - t2, i2, s), this.pos = e2, this.openStart < 0 && (this.openStart = s);
}
point(t2, e2, i2, s, r2, o) {
if (this.disallowBlockEffectsFor[o] && i2 instanceof be) {
if (i2.block)
throw new RangeError("Block decorations may not be specified via plugins");
if (e2 > this.doc.lineAt(this.pos).to)
throw new RangeError("Decorations that replace line breaks may not be specified via plugins");
}
let l = e2 - t2;
if (i2 instanceof be)
if (i2.block)
i2.startSide > 0 && !this.posCovered() && this.getLine(), this.addBlockWidget(new pe(i2.widget || new Vr("div"), l, i2));
else {
let h2 = fe.create(i2.widget || new Vr("span"), l, l ? 0 : i2.startSide), a2 = this.atCursorPos && !h2.isEditable && r2 <= s.length && (t2 < e2 || i2.startSide > 0), c2 = !h2.isEditable && (t2 < e2 || r2 > s.length || i2.startSide <= 0), f2 = this.getLine();
this.pendingBuffer == 2 && !a2 && !h2.isEditable && (this.pendingBuffer = 0), this.flushBuffer(s), a2 && (f2.append(Ni(new Je(1), s), r2), r2 = s.length + Math.max(0, r2 - s.length)), f2.append(Ni(h2, s), r2), this.atCursorPos = c2, this.pendingBuffer = c2 ? t2 < e2 || r2 > s.length ? 1 : 2 : 0, this.pendingBuffer && (this.bufferMarks = s.slice());
}
else
this.doc.lineAt(this.pos).from == this.pos && this.getLine().addLineDeco(i2);
l && (this.textOff + l <= this.text.length ? this.textOff += l : (this.skip += l - (this.text.length - this.textOff), this.text = "", this.textOff = 0), this.pos = e2), this.openStart < 0 && (this.openStart = r2);
}
static build(t2, e2, i2, s, r2) {
let o = new gi(t2, e2, i2, r2);
return o.openEnd = F.spans(s, e2, i2, o), o.openStart < 0 && (o.openStart = o.openEnd), o.finish(o.openEnd), o;
}
}
function Ni(n2, t2) {
for (let e2 of t2)
n2 = new oe(e2, [n2], n2.length);
return n2;
}
class Vr extends Se {
constructor(t2) {
super(), this.tag = t2;
}
eq(t2) {
return t2.tag == this.tag;
}
toDOM() {
return document.createElement(this.tag);
}
updateDOM(t2) {
return t2.nodeName.toLowerCase() == this.tag;
}
get isHidden() {
return true;
}
}
const Rl = /* @__PURE__ */ O$3.define(), Ll = /* @__PURE__ */ O$3.define(), El = /* @__PURE__ */ O$3.define(), Nl = /* @__PURE__ */ O$3.define(), Cn = /* @__PURE__ */ O$3.define(), Il = /* @__PURE__ */ O$3.define(), Vl = /* @__PURE__ */ O$3.define(), Hl = /* @__PURE__ */ O$3.define({
combine: (n2) => n2.some((t2) => t2)
}), pf = /* @__PURE__ */ O$3.define({
combine: (n2) => n2.some((t2) => t2)
});
class qe {
constructor(t2, e2 = "nearest", i2 = "nearest", s = 5, r2 = 5, o = false) {
this.range = t2, this.y = e2, this.x = i2, this.yMargin = s, this.xMargin = r2, this.isSnapshot = o;
}
map(t2) {
return t2.empty ? this : new qe(this.range.map(t2), this.y, this.x, this.yMargin, this.xMargin, this.isSnapshot);
}
clip(t2) {
return this.range.to <= t2.doc.length ? this : new qe(b$1.cursor(t2.doc.length), this.y, this.x, this.yMargin, this.xMargin, this.isSnapshot);
}
}
const Ii = /* @__PURE__ */ z$2.define({ map: (n2, t2) => n2.map(t2) });
function ie(n2, t2, e2) {
let i2 = n2.facet(Nl);
i2.length ? i2[0](t2) : window.onerror ? window.onerror(String(t2), e2, void 0, void 0, t2) : e2 ? console.error(e2 + ":", t2) : console.error(t2);
}
const Bs = /* @__PURE__ */ O$3.define({ combine: (n2) => n2.length ? n2[0] : true });
let gf = 0;
const hi = /* @__PURE__ */ O$3.define();
class yt {
constructor(t2, e2, i2, s, r2) {
this.id = t2, this.create = e2, this.domEventHandlers = i2, this.domEventObservers = s, this.extension = r2(this);
}
/**
Define a plugin from a constructor function that creates the
plugin's value, given an editor view.
*/
static define(t2, e2) {
const { eventHandlers: i2, eventObservers: s, provide: r2, decorations: o } = e2 || {};
return new yt(gf++, t2, i2, s, (l) => {
let h2 = [hi.of(l)];
return o && h2.push(xi.of((a2) => {
let c2 = a2.plugin(l);
return c2 ? o(c2) : N$2.none;
})), r2 && h2.push(r2(l)), h2;
});
}
/**
Create a plugin for a class whose constructor takes a single
editor view as argument.
*/
static fromClass(t2, e2) {
return yt.define((i2) => new t2(i2), e2);
}
}
class _s {
constructor(t2) {
this.spec = t2, this.mustUpdate = null, this.value = null;
}
update(t2) {
if (this.value) {
if (this.mustUpdate) {
let e2 = this.mustUpdate;
if (this.mustUpdate = null, this.value.update)
try {
this.value.update(e2);
} catch (i2) {
if (ie(e2.state, i2, "CodeMirror plugin crashed"), this.value.destroy)
try {
this.value.destroy();
} catch {
}
this.deactivate();
}
}
} else if (this.spec)
try {
this.value = this.spec.create(t2);
} catch (e2) {
ie(t2.state, e2, "CodeMirror plugin crashed"), this.deactivate();
}
return this;
}
destroy(t2) {
var e2;
if (!((e2 = this.value) === null || e2 === void 0) && e2.destroy)
try {
this.value.destroy();
} catch (i2) {
ie(t2.state, i2, "CodeMirror plugin crashed");
}
}
deactivate() {
this.spec = this.value = null;
}
}
const $l = /* @__PURE__ */ O$3.define(), er = /* @__PURE__ */ O$3.define(), xi = /* @__PURE__ */ O$3.define(), ir = /* @__PURE__ */ O$3.define(), Fl = /* @__PURE__ */ O$3.define();
function Hr(n2, t2, e2) {
let i2 = n2.state.facet(Fl);
if (!i2.length)
return i2;
let s = i2.map((o) => o instanceof Function ? o(n2) : o), r2 = [];
return F.spans(s, t2, e2, {
point() {
},
span(o, l, h2, a2) {
let c2 = r2;
for (let f2 = h2.length - 1; f2 >= 0; f2--, a2--) {
let u2 = h2[f2].spec.bidiIsolate, d2;
if (u2 != null)
if (a2 > 0 && c2.length && (d2 = c2[c2.length - 1]).to == o && d2.direction == u2)
d2.to = l, c2 = d2.inner;
else {
let p2 = { from: o, to: l, direction: u2, inner: [] };
c2.push(p2), c2 = p2.inner;
}
}
}
}), r2;
}
const _l = /* @__PURE__ */ O$3.define();
function zl(n2) {
let t2 = 0, e2 = 0, i2 = 0, s = 0;
for (let r2 of n2.state.facet(_l)) {
let o = r2(n2);
o && (o.left != null && (t2 = Math.max(t2, o.left)), o.right != null && (e2 = Math.max(e2, o.right)), o.top != null && (i2 = Math.max(i2, o.top)), o.bottom != null && (s = Math.max(s, o.bottom)));
}
return { left: t2, right: e2, top: i2, bottom: s };
}
const ai = /* @__PURE__ */ O$3.define();
class Mt {
constructor(t2, e2, i2, s) {
this.fromA = t2, this.toA = e2, this.fromB = i2, this.toB = s;
}
join(t2) {
return new Mt(Math.min(this.fromA, t2.fromA), Math.max(this.toA, t2.toA), Math.min(this.fromB, t2.fromB), Math.max(this.toB, t2.toB));
}
addToSet(t2) {
let e2 = t2.length, i2 = this;
for (; e2 > 0; e2--) {
let s = t2[e2 - 1];
if (!(s.fromA > i2.toA)) {
if (s.toA < i2.fromA)
break;
i2 = i2.join(s), t2.splice(e2 - 1, 1);
}
}
return t2.splice(e2, 0, i2), t2;
}
static extendWithRanges(t2, e2) {
if (e2.length == 0)
return t2;
let i2 = [];
for (let s = 0, r2 = 0, o = 0, l = 0; ; s++) {
let h2 = s == t2.length ? null : t2[s], a2 = o - l, c2 = h2 ? h2.fromB : 1e9;
for (; r2 < e2.length && e2[r2] < c2; ) {
let f2 = e2[r2], u2 = e2[r2 + 1], d2 = Math.max(l, f2), p2 = Math.min(c2, u2);
if (d2 <= p2 && new Mt(d2 + a2, p2 + a2, d2, p2).addToSet(i2), u2 > c2)
break;
r2 += 2;
}
if (!h2)
return i2;
new Mt(h2.fromA, h2.toA, h2.fromB, h2.toB).addToSet(i2), o = h2.toA, l = h2.toB;
}
}
}
class ps {
constructor(t2, e2, i2) {
this.view = t2, this.state = e2, this.transactions = i2, this.flags = 0, this.startState = t2.state, this.changes = it.empty(this.startState.doc.length);
for (let r2 of i2)
this.changes = this.changes.compose(r2.changes);
let s = [];
this.changes.iterChangedRanges((r2, o, l, h2) => s.push(new Mt(r2, o, l, h2))), this.changedRanges = s;
}
/**
@internal
*/
static create(t2, e2, i2) {
return new ps(t2, e2, i2);
}
/**
Tells you whether the [viewport](https://codemirror.net/6/docs/ref/#view.EditorView.viewport) or
[visible ranges](https://codemirror.net/6/docs/ref/#view.EditorView.visibleRanges) changed in this
update.
*/
get viewportChanged() {
return (this.flags & 4) > 0;
}
/**
Indicates whether the height of a block element in the editor
changed in this update.
*/
get heightChanged() {
return (this.flags & 2) > 0;
}
/**
Returns true when the document was modified or the size of the
editor, or elements within the editor, changed.
*/
get geometryChanged() {
return this.docChanged || (this.flags & 10) > 0;
}
/**
True when this update indicates a focus change.
*/
get focusChanged() {
return (this.flags & 1) > 0;
}
/**
Whether the document changed in this update.
*/
get docChanged() {
return !this.changes.empty;
}
/**
Whether the selection was explicitly set in this update.
*/
get selectionSet() {
return this.transactions.some((t2) => t2.selection);
}
/**
@internal
*/
get empty() {
return this.flags == 0 && this.transactions.length == 0;
}
}
var tt = /* @__PURE__ */ function(n2) {
return n2[n2.LTR = 0] = "LTR", n2[n2.RTL = 1] = "RTL", n2;
}(tt || (tt = {}));
const vi = tt.LTR, Wl = tt.RTL;
function jl(n2) {
let t2 = [];
for (let e2 = 0; e2 < n2.length; e2++)
t2.push(1 << +n2[e2]);
return t2;
}
const mf = /* @__PURE__ */ jl("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"), wf = /* @__PURE__ */ jl("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"), An = /* @__PURE__ */ Object.create(null), _t = [];
for (let n2 of ["()", "[]", "{}"]) {
let t2 = /* @__PURE__ */ n2.charCodeAt(0), e2 = /* @__PURE__ */ n2.charCodeAt(1);
An[t2] = e2, An[e2] = -t2;
}
function yf(n2) {
return n2 <= 247 ? mf[n2] : 1424 <= n2 && n2 <= 1524 ? 2 : 1536 <= n2 && n2 <= 1785 ? wf[n2 - 1536] : 1774 <= n2 && n2 <= 2220 ? 4 : 8192 <= n2 && n2 <= 8203 ? 256 : 64336 <= n2 && n2 <= 65023 ? 4 : n2 == 8204 ? 256 : 1;
}
const bf = /[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;
class ue {
/**
The direction of this span.
*/
get dir() {
return this.level % 2 ? Wl : vi;
}
/**
@internal
*/
constructor(t2, e2, i2) {
this.from = t2, this.to = e2, this.level = i2;
}
/**
@internal
*/
side(t2, e2) {
return this.dir == e2 == t2 ? this.to : this.from;
}
/**
@internal
*/
static find(t2, e2, i2, s) {
let r2 = -1;
for (let o = 0; o < t2.length; o++) {
let l = t2[o];
if (l.from <= e2 && l.to >= e2) {
if (l.level == i2)
return o;
(r2 < 0 || (s != 0 ? s < 0 ? l.from < e2 : l.to > e2 : t2[r2].level > l.level)) && (r2 = o);
}
}
if (r2 < 0)
throw new RangeError("Index out of range");
return r2;
}
}
function Kl(n2, t2) {
if (n2.length != t2.length)
return false;
for (let e2 = 0; e2 < n2.length; e2++) {
let i2 = n2[e2], s = t2[e2];
if (i2.from != s.from || i2.to != s.to || i2.direction != s.direction || !Kl(i2.inner, s.inner))
return false;
}
return true;
}
const _ = [];
function kf(n2, t2, e2, i2, s) {
for (let r2 = 0; r2 <= i2.length; r2++) {
let o = r2 ? i2[r2 - 1].to : t2, l = r2 < i2.length ? i2[r2].from : e2, h2 = r2 ? 256 : s;
for (let a2 = o, c2 = h2, f2 = h2; a2 < l; a2++) {
let u2 = yf(n2.charCodeAt(a2));
u2 == 512 ? u2 = c2 : u2 == 8 && f2 == 4 && (u2 = 16), _[a2] = u2 == 4 ? 2 : u2, u2 & 7 && (f2 = u2), c2 = u2;
}
for (let a2 = o, c2 = h2, f2 = h2; a2 < l; a2++) {
let u2 = _[a2];
if (u2 == 128)
a2 < l - 1 && c2 == _[a2 + 1] && c2 & 24 ? u2 = _[a2] = c2 : _[a2] = 256;
else if (u2 == 64) {
let d2 = a2 + 1;
for (; d2 < l && _[d2] == 64; )
d2++;
let p2 = a2 && c2 == 8 || d2 < e2 && _[d2] == 8 ? f2 == 1 ? 1 : 8 : 256;
for (let m = a2; m < d2; m++)
_[m] = p2;
a2 = d2 - 1;
} else
u2 == 8 && f2 == 1 && (_[a2] = 1);
c2 = u2, u2 & 7 && (f2 = u2);
}
}
}
function xf(n2, t2, e2, i2, s) {
let r2 = s == 1 ? 2 : 1;
for (let o = 0, l = 0, h2 = 0; o <= i2.length; o++) {
let a2 = o ? i2[o - 1].to : t2, c2 = o < i2.length ? i2[o].from : e2;
for (let f2 = a2, u2, d2, p2; f2 < c2; f2++)
if (d2 = An[u2 = n2.charCodeAt(f2)])
if (d2 < 0) {
for (let m = l - 3; m >= 0; m -= 3)
if (_t[m + 1] == -d2) {
let g = _t[m + 2], y2 = g & 2 ? s : g & 4 ? g & 1 ? r2 : s : 0;
y2 && (_[f2] = _[_t[m]] = y2), l = m;
break;
}
} else {
if (_t.length == 189)
break;
_t[l++] = f2, _t[l++] = u2, _t[l++] = h2;
}
else if ((p2 = _[f2]) == 2 || p2 == 1) {
let m = p2 == s;
h2 = m ? 0 : 1;
for (let g = l - 3; g >= 0; g -= 3) {
let y2 = _t[g + 2];
if (y2 & 2)
break;
if (m)
_t[g + 2] |= 2;
else {
if (y2 & 4)
break;
_t[g + 2] |= 4;
}
}
}
}
}
function vf(n2, t2, e2, i2) {
for (let s = 0, r2 = i2; s <= e2.length; s++) {
let o = s ? e2[s - 1].to : n2, l = s < e2.length ? e2[s].from : t2;
for (let h2 = o; h2 < l; ) {
let a2 = _[h2];
if (a2 == 256) {
let c2 = h2 + 1;
for (; ; )
if (c2 == l) {
if (s == e2.length)
break;
c2 = e2[s++].to, l = s < e2.length ? e2[s].from : t2;
} else if (_[c2] == 256)
c2++;
else
break;
let f2 = r2 == 1, u2 = (c2 < t2 ? _[c2] : i2) == 1, d2 = f2 == u2 ? f2 ? 1 : 2 : i2;
for (let p2 = c2, m = s, g = m ? e2[m - 1].to : n2; p2 > h2; )
p2 == g && (p2 = e2[--m].from, g = m ? e2[m - 1].to : n2), _[--p2] = d2;
h2 = c2;
} else
r2 = a2, h2++;
}
}
}
function On(n2, t2, e2, i2, s, r2, o) {
let l = i2 % 2 ? 2 : 1;
if (i2 % 2 == s % 2)
for (let h2 = t2, a2 = 0; h2 < e2; ) {
let c2 = true, f2 = false;
if (a2 == r2.length || h2 < r2[a2].from) {
let m = _[h2];
m != l && (c2 = false, f2 = m == 16);
}
let u2 = !c2 && l == 1 ? [] : null, d2 = c2 ? i2 : i2 + 1, p2 = h2;
t:
for (; ; )
if (a2 < r2.length && p2 == r2[a2].from) {
if (f2)
break t;
let m = r2[a2];
if (!c2)
for (let g = m.to, y2 = a2 + 1; ; ) {
if (g == e2)
break t;
if (y2 < r2.length && r2[y2].from == g)
g = r2[y2++].to;
else {
if (_[g] == l)
break t;
break;
}
}
if (a2++, u2)
u2.push(m);
else {
m.from > h2 && o.push(new ue(h2, m.from, d2));
let g = m.direction == vi != !(d2 % 2);
Mn(n2, g ? i2 + 1 : i2, s, m.inner, m.from, m.to, o), h2 = m.to;
}
p2 = m.to;
} else {
if (p2 == e2 || (c2 ? _[p2] != l : _[p2] == l))
break;
p2++;
}
u2 ? On(n2, h2, p2, i2 + 1, s, u2, o) : h2 < p2 && o.push(new ue(h2, p2, d2)), h2 = p2;
}
else
for (let h2 = e2, a2 = r2.length; h2 > t2; ) {
let c2 = true, f2 = false;
if (!a2 || h2 > r2[a2 - 1].to) {
let m = _[h2 - 1];
m != l && (c2 = false, f2 = m == 16);
}
let u2 = !c2 && l == 1 ? [] : null, d2 = c2 ? i2 : i2 + 1, p2 = h2;
t:
for (; ; )
if (a2 && p2 == r2[a2 - 1].to) {
if (f2)
break t;
let m = r2[--a2];
if (!c2)
for (let g = m.from, y2 = a2; ; ) {
if (g == t2)
break t;
if (y2 && r2[y2 - 1].to == g)
g = r2[--y2].from;
else {
if (_[g - 1] == l)
break t;
break;
}
}
if (u2)
u2.push(m);
else {
m.to < h2 && o.push(new ue(m.to, h2, d2));
let g = m.direction == vi != !(d2 % 2);
Mn(n2, g ? i2 + 1 : i2, s, m.inner, m.from, m.to, o), h2 = m.from;
}
p2 = m.from;
} else {
if (p2 == t2 || (c2 ? _[p2 - 1] != l : _[p2 - 1] == l))
break;
p2--;
}
u2 ? On(n2, p2, h2, i2 + 1, s, u2, o) : p2 < h2 && o.push(new ue(p2, h2, d2)), h2 = p2;
}
}
function Mn(n2, t2, e2, i2, s, r2, o) {
let l = t2 % 2 ? 2 : 1;
kf(n2, s, r2, i2, l), xf(n2, s, r2, i2, l), vf(s, r2, i2, l), On(n2, s, r2, t2, e2, i2, o);
}
function Sf(n2, t2, e2) {
if (!n2)
return [new ue(0, 0, t2 == Wl ? 1 : 0)];
if (t2 == vi && !e2.length && !bf.test(n2))
return ql(n2.length);
if (e2.length)
for (; n2.length > _.length; )
_[_.length] = 256;
let i2 = [], s = t2 == vi ? 0 : 1;
return Mn(n2, s, s, e2, 0, n2.length, i2), i2;
}
function ql(n2) {
return [new ue(0, n2, 0)];
}
let Gl = "";
function Cf(n2, t2, e2, i2, s) {
var r2;
let o = i2.head - n2.from, l = -1;
if (o == 0) {
if (!s || !n2.length)
return null;
t2[0].level != e2 && (o = t2[0].side(false, e2), l = 0);
} else if (o == n2.length) {
if (s)
return null;
let u2 = t2[t2.length - 1];
u2.level != e2 && (o = u2.side(true, e2), l = t2.length - 1);
}
l < 0 && (l = ue.find(t2, o, (r2 = i2.bidiLevel) !== null && r2 !== void 0 ? r2 : -1, i2.assoc));
let h2 = t2[l];
o == h2.side(s, e2) && (h2 = t2[l += s ? 1 : -1], o = h2.side(!s, e2));
let a2 = s == (h2.dir == e2), c2 = wt(n2.text, o, a2);
if (Gl = n2.text.slice(Math.min(o, c2), Math.max(o, c2)), c2 != h2.side(s, e2))
return b$1.cursor(c2 + n2.from, a2 ? -1 : 1, h2.level);
let f2 = l == (s ? t2.length - 1 : 0) ? null : t2[l + (s ? 1 : -1)];
return !f2 && h2.level != e2 ? b$1.cursor(s ? n2.to : n2.from, s ? -1 : 1, e2) : f2 && f2.level < h2.level ? b$1.cursor(f2.side(!s, e2) + n2.from, s ? 1 : -1, f2.level) : b$1.cursor(c2 + n2.from, s ? -1 : 1, h2.level);
}
class $r extends q$1 {
get length() {
return this.view.state.doc.length;
}
constructor(t2) {
super(), this.view = t2, this.decorations = [], this.dynamicDecorationMap = [], this.domChanged = null, this.hasComposition = null, this.markedForComposition = /* @__PURE__ */ new Set(), this.minWidth = 0, this.minWidthFrom = 0, this.minWidthTo = 0, this.impreciseAnchor = null, this.impreciseHead = null, this.forceSelection = false, this.lastUpdate = Date.now(), this.setDOM(t2.contentDOM), this.children = [new Z$1()], this.children[0].setParent(this), this.updateDeco(), this.updateInner([new Mt(0, 0, 0, t2.state.doc.length)], 0, null);
}
// Update the document view to a given state.
update(t2) {
var e2;
let i2 = t2.changedRanges;
this.minWidth > 0 && i2.length && (i2.every(({ fromA: a2, toA: c2 }) => c2 < this.minWidthFrom || a2 > this.minWidthTo) ? (this.minWidthFrom = t2.changes.mapPos(this.minWidthFrom, 1), this.minWidthTo = t2.changes.mapPos(this.minWidthTo, 1)) : this.minWidth = this.minWidthFrom = this.minWidthTo = 0);
let s = -1;
this.view.inputState.composing >= 0 && (!((e2 = this.domChanged) === null || e2 === void 0) && e2.newSel ? s = this.domChanged.newSel.head : !Bf(t2.changes, this.hasComposition) && !t2.selectionSet && (s = t2.state.selection.main.head));
let r2 = s > -1 ? Of(this.view, t2.changes, s) : null;
if (this.domChanged = null, this.hasComposition) {
this.markedForComposition.clear();
let { from: a2, to: c2 } = this.hasComposition;
i2 = new Mt(a2, c2, t2.changes.mapPos(a2, -1), t2.changes.mapPos(c2, 1)).addToSet(i2.slice());
}
this.hasComposition = r2 ? { from: r2.range.fromB, to: r2.range.toB } : null, (C.ie || C.chrome) && !r2 && t2 && t2.state.doc.lines != t2.startState.doc.lines && (this.forceSelection = true);
let o = this.decorations, l = this.updateDeco(), h2 = Df(o, l, t2.changes);
return i2 = Mt.extendWithRanges(i2, h2), !(this.flags & 7) && i2.length == 0 ? false : (this.updateInner(i2, t2.startState.doc.length, r2), t2.transactions.length && (this.lastUpdate = Date.now()), true);
}
// Used by update and the constructor do perform the actual DOM
// update
updateInner(t2, e2, i2) {
this.view.viewState.mustMeasureContent = true, this.updateChildren(t2, e2, i2);
let { observer: s } = this.view;
s.ignore(() => {
this.dom.style.height = this.view.viewState.contentHeight / this.view.scaleY + "px", this.dom.style.flexBasis = this.minWidth ? this.minWidth + "px" : "";
let o = C.chrome || C.ios ? { node: s.selectionRange.focusNode, written: false } : void 0;
this.sync(this.view, o), this.flags &= -8, o && (o.written || s.selectionRange.focusNode != o.node) && (this.forceSelection = true), this.dom.style.height = "";
}), this.markedForComposition.forEach(
(o) => o.flags &= -9
/* ViewFlag.Composition */
);
let r2 = [];
if (this.view.viewport.from || this.view.viewport.to < this.view.state.doc.length)
for (let o of this.children)
o instanceof pe && o.widget instanceof Fr && r2.push(o.dom);
s.updateGaps(r2);
}
updateChildren(t2, e2, i2) {
let s = i2 ? i2.range.addToSet(t2.slice()) : t2, r2 = this.childCursor(e2);
for (let o = s.length - 1; ; o--) {
let l = o >= 0 ? s[o] : null;
if (!l)
break;
let { fromA: h2, toA: a2, fromB: c2, toB: f2 } = l, u2, d2, p2, m;
if (i2 && i2.range.fromB < f2 && i2.range.toB > c2) {
let v2 = gi.build(this.view.state.doc, c2, i2.range.fromB, this.decorations, this.dynamicDecorationMap), A2 = gi.build(this.view.state.doc, i2.range.toB, f2, this.decorations, this.dynamicDecorationMap);
d2 = v2.breakAtStart, p2 = v2.openStart, m = A2.openEnd;
let P2 = this.compositionView(i2);
A2.breakAtStart ? P2.breakAfter = 1 : A2.content.length && P2.merge(P2.length, P2.length, A2.content[0], false, A2.openStart, 0) && (P2.breakAfter = A2.content[0].breakAfter, A2.content.shift()), v2.content.length && P2.merge(0, 0, v2.content[v2.content.length - 1], true, 0, v2.openEnd) && v2.content.pop(), u2 = v2.content.concat(P2).concat(A2.content);
} else
({ content: u2, breakAtStart: d2, openStart: p2, openEnd: m } = gi.build(this.view.state.doc, c2, f2, this.decorations, this.dynamicDecorationMap));
let { i: g, off: y2 } = r2.findPos(a2, 1), { i: x2, off: S2 } = r2.findPos(h2, -1);
Cl(this, x2, S2, g, y2, u2, d2, p2, m);
}
i2 && this.fixCompositionDOM(i2);
}
compositionView(t2) {
let e2 = new re(t2.text.nodeValue);
e2.flags |= 8;
for (let { deco: s } of t2.marks)
e2 = new oe(s, [e2], e2.length);
let i2 = new Z$1();
return i2.append(e2, 0), i2;
}
fixCompositionDOM(t2) {
let e2 = (r2, o) => {
o.flags |= 8 | (o.children.some(
(h2) => h2.flags & 7
/* ViewFlag.Dirty */
) ? 1 : 0), this.markedForComposition.add(o);
let l = q$1.get(r2);
l && l != o && (l.dom = null), o.setDOM(r2);
}, i2 = this.childPos(t2.range.fromB, 1), s = this.children[i2.i];
e2(t2.line, s);
for (let r2 = t2.marks.length - 1; r2 >= -1; r2--)
i2 = s.childPos(i2.off, 1), s = s.children[i2.i], e2(r2 >= 0 ? t2.marks[r2].node : t2.text, s);
}
// Sync the DOM selection to this.state.selection
updateSelection(t2 = false, e2 = false) {
(t2 || !this.view.observer.selectionRange.focusNode) && this.view.observer.readSelectionRange();
let i2 = this.view.root.activeElement, s = i2 == this.dom, r2 = !s && ts(this.dom, this.view.observer.selectionRange) && !(i2 && this.dom.contains(i2));
if (!(s || e2 || r2))
return;
let o = this.forceSelection;
this.forceSelection = false;
let l = this.view.state.selection.main, h2 = this.moveToLine(this.domAtPos(l.anchor)), a2 = l.empty ? h2 : this.moveToLine(this.domAtPos(l.head));
if (C.gecko && l.empty && !this.hasComposition && Af(h2)) {
let f2 = document.createTextNode("");
this.view.observer.ignore(() => h2.node.insertBefore(f2, h2.node.childNodes[h2.offset] || null)), h2 = a2 = new ct(f2, 0), o = true;
}
let c2 = this.view.observer.selectionRange;
(o || !c2.focusNode || !ds(h2.node, h2.offset, c2.anchorNode, c2.anchorOffset) || !ds(a2.node, a2.offset, c2.focusNode, c2.focusOffset)) && (this.view.observer.ignore(() => {
C.android && C.chrome && this.dom.contains(c2.focusNode) && Pf(c2.focusNode, this.dom) && (this.dom.blur(), this.dom.focus({ preventScroll: true }));
let f2 = us(this.view.root);
if (f2)
if (l.empty) {
if (C.gecko) {
let u2 = Mf(h2.node, h2.offset);
if (u2 && u2 != 3) {
let d2 = Yl(h2.node, h2.offset, u2 == 1 ? 1 : -1);
d2 && (h2 = new ct(d2.node, d2.offset));
}
}
f2.collapse(h2.node, h2.offset), l.bidiLevel != null && f2.caretBidiLevel !== void 0 && (f2.caretBidiLevel = l.bidiLevel);
} else if (f2.extend) {
f2.collapse(h2.node, h2.offset);
try {
f2.extend(a2.node, a2.offset);
} catch {
}
} else {
let u2 = document.createRange();
l.anchor > l.head && ([h2, a2] = [a2, h2]), u2.setEnd(a2.node, a2.offset), u2.setStart(h2.node, h2.offset), f2.removeAllRanges(), f2.addRange(u2);
}
r2 && this.view.root.activeElement == this.dom && (this.dom.blur(), i2 && i2.focus());
}), this.view.observer.setSelectionRange(h2, a2)), this.impreciseAnchor = h2.precise ? null : new ct(c2.anchorNode, c2.anchorOffset), this.impreciseHead = a2.precise ? null : new ct(c2.focusNode, c2.focusOffset);
}
enforceCursorAssoc() {
if (this.hasComposition)
return;
let { view: t2 } = this, e2 = t2.state.selection.main, i2 = us(t2.root), { anchorNode: s, anchorOffset: r2 } = t2.observer.selectionRange;
if (!i2 || !e2.empty || !e2.assoc || !i2.modify)
return;
let o = Z$1.find(this, e2.head);
if (!o)
return;
let l = o.posAtStart;
if (e2.head == l || e2.head == l + o.length)
return;
let h2 = this.coordsAt(e2.head, -1), a2 = this.coordsAt(e2.head, 1);
if (!h2 || !a2 || h2.bottom > a2.top)
return;
let c2 = this.domAtPos(e2.head + e2.assoc);
i2.collapse(c2.node, c2.offset), i2.modify("move", e2.assoc < 0 ? "forward" : "backward", "lineboundary"), t2.observer.readSelectionRange();
let f2 = t2.observer.selectionRange;
t2.docView.posFromDOM(f2.anchorNode, f2.anchorOffset) != e2.from && i2.collapse(s, r2);
}
// If a position is in/near a block widget, move it to a nearby text
// line, since we don't want the cursor inside a block widget.
moveToLine(t2) {
let e2 = this.dom, i2;
if (t2.node != e2)
return t2;
for (let s = t2.offset; !i2 && s < e2.childNodes.length; s++) {
let r2 = q$1.get(e2.childNodes[s]);
r2 instanceof Z$1 && (i2 = r2.domAtPos(0));
}
for (let s = t2.offset - 1; !i2 && s >= 0; s--) {
let r2 = q$1.get(e2.childNodes[s]);
r2 instanceof Z$1 && (i2 = r2.domAtPos(r2.length));
}
return i2 ? new ct(i2.node, i2.offset, true) : t2;
}
nearest(t2) {
for (let e2 = t2; e2; ) {
let i2 = q$1.get(e2);
if (i2 && i2.rootView == this)
return i2;
e2 = e2.parentNode;
}
return null;
}
posFromDOM(t2, e2) {
let i2 = this.nearest(t2);
if (!i2)
throw new RangeError("Trying to find position for a DOM position outside of the document");
return i2.localPosFromDOM(t2, e2) + i2.posAtStart;
}
domAtPos(t2) {
let { i: e2, off: i2 } = this.childCursor().findPos(t2, -1);
for (; e2 < this.children.length - 1; ) {
let s = this.children[e2];
if (i2 < s.length || s instanceof Z$1)
break;
e2++, i2 = 0;
}
return this.children[e2].domAtPos(i2);
}
coordsAt(t2, e2) {
let i2 = null, s = 0;
for (let r2 = this.length, o = this.children.length - 1; o >= 0; o--) {
let l = this.children[o], h2 = r2 - l.breakAfter, a2 = h2 - l.length;
if (h2 < t2)
break;
a2 <= t2 && (a2 < t2 || l.covers(-1)) && (h2 > t2 || l.covers(1)) && (!i2 || l instanceof Z$1 && !(i2 instanceof Z$1 && e2 >= 0)) && (i2 = l, s = a2), r2 = a2;
}
return i2 ? i2.coordsAt(t2 - s, e2) : null;
}
coordsForChar(t2) {
let { i: e2, off: i2 } = this.childPos(t2, 1), s = this.children[e2];
if (!(s instanceof Z$1))
return null;
for (; s.children.length; ) {
let { i: l, off: h2 } = s.childPos(i2, 1);
for (; ; l++) {
if (l == s.children.length)
return null;
if ((s = s.children[l]).length)
break;
}
i2 = h2;
}
if (!(s instanceof re))
return null;
let r2 = wt(s.text, i2);
if (r2 == i2)
return null;
let o = Ne(s.dom, i2, r2).getClientRects();
for (let l = 0; l < o.length; l++) {
let h2 = o[l];
if (l == o.length - 1 || h2.top < h2.bottom && h2.left < h2.right)
return h2;
}
return null;
}
measureVisibleLineHeights(t2) {
let e2 = [], { from: i2, to: s } = t2, r2 = this.view.contentDOM.clientWidth, o = r2 > Math.max(this.view.scrollDOM.clientWidth, this.minWidth) + 1, l = -1, h2 = this.view.textDirection == tt.LTR;
for (let a2 = 0, c2 = 0; c2 < this.children.length; c2++) {
let f2 = this.children[c2], u2 = a2 + f2.length;
if (u2 > s)
break;
if (a2 >= i2) {
let d2 = f2.dom.getBoundingClientRect();
if (e2.push(d2.height), o) {
let p2 = f2.dom.lastChild, m = p2 ? bi(p2) : [];
if (m.length) {
let g = m[m.length - 1], y2 = h2 ? g.right - d2.left : d2.right - g.left;
y2 > l && (l = y2, this.minWidth = r2, this.minWidthFrom = a2, this.minWidthTo = u2);
}
}
}
a2 = u2 + f2.breakAfter;
}
return e2;
}
textDirectionAt(t2) {
let { i: e2 } = this.childPos(t2, 1);
return getComputedStyle(this.children[e2].dom).direction == "rtl" ? tt.RTL : tt.LTR;
}
measureTextSize() {
for (let r2 of this.children)
if (r2 instanceof Z$1) {
let o = r2.measureTextSize();
if (o)
return o;
}
let t2 = document.createElement("div"), e2, i2, s;
return t2.className = "cm-line", t2.style.width = "99999px", t2.style.position = "absolute", t2.textContent = "abc def ghi jkl mno pqr stu", this.view.observer.ignore(() => {
this.dom.appendChild(t2);
let r2 = bi(t2.firstChild)[0];
e2 = t2.getBoundingClientRect().height, i2 = r2 ? r2.width / 27 : 7, s = r2 ? r2.height : e2, t2.remove();
}), { lineHeight: e2, charWidth: i2, textHeight: s };
}
childCursor(t2 = this.length) {
let e2 = this.children.length;
return e2 && (t2 -= this.children[--e2].length), new Sl(this.children, t2, e2);
}
computeBlockGapDeco() {
let t2 = [], e2 = this.view.viewState;
for (let i2 = 0, s = 0; ; s++) {
let r2 = s == e2.viewports.length ? null : e2.viewports[s], o = r2 ? r2.from - 1 : this.length;
if (o > i2) {
let l = (e2.lineBlockAt(o).bottom - e2.lineBlockAt(i2).top) / this.view.scaleY;
t2.push(N$2.replace({
widget: new Fr(l),
block: true,
inclusive: true,
isBlockGap: true
}).range(i2, o));
}
if (!r2)
break;
i2 = r2.to + 1;
}
return N$2.set(t2);
}
updateDeco() {
let t2 = this.view.state.facet(xi).map((e2, i2) => (this.dynamicDecorationMap[i2] = typeof e2 == "function") ? e2(this.view) : e2);
for (let e2 = t2.length; e2 < t2.length + 3; e2++)
this.dynamicDecorationMap[e2] = false;
return this.decorations = [
...t2,
this.computeBlockGapDeco(),
this.view.viewState.lineGapDeco
];
}
scrollIntoView(t2) {
if (t2.isSnapshot) {
let a2 = this.view.viewState.lineBlockAt(t2.range.head);
this.view.scrollDOM.scrollTop = a2.top - t2.yMargin, this.view.scrollDOM.scrollLeft = t2.xMargin;
return;
}
let { range: e2 } = t2, i2 = this.coordsAt(e2.head, e2.empty ? e2.assoc : e2.head > e2.anchor ? -1 : 1), s;
if (!i2)
return;
!e2.empty && (s = this.coordsAt(e2.anchor, e2.anchor > e2.head ? -1 : 1)) && (i2 = {
left: Math.min(i2.left, s.left),
top: Math.min(i2.top, s.top),
right: Math.max(i2.right, s.right),
bottom: Math.max(i2.bottom, s.bottom)
});
let r2 = zl(this.view), o = {
left: i2.left - r2.left,
top: i2.top - r2.top,
right: i2.right + r2.right,
bottom: i2.bottom + r2.bottom
}, { offsetWidth: l, offsetHeight: h2 } = this.view.scrollDOM;
nf(this.view.scrollDOM, o, e2.head < e2.anchor ? -1 : 1, t2.x, t2.y, Math.max(Math.min(t2.xMargin, l), -l), Math.max(Math.min(t2.yMargin, h2), -h2), this.view.textDirection == tt.LTR);
}
}
function Af(n2) {
return n2.node.nodeType == 1 && n2.node.firstChild && (n2.offset == 0 || n2.node.childNodes[n2.offset - 1].contentEditable == "false") && (n2.offset == n2.node.childNodes.length || n2.node.childNodes[n2.offset].contentEditable == "false");
}
class Fr extends Se {
constructor(t2) {
super(), this.height = t2;
}
toDOM() {
let t2 = document.createElement("div");
return this.updateDOM(t2), t2;
}
eq(t2) {
return t2.height == this.height;
}
updateDOM(t2) {
return t2.style.height = this.height + "px", true;
}
get estimatedHeight() {
return this.height;
}
}
function Ul(n2, t2) {
let e2 = n2.observer.selectionRange, i2 = e2.focusNode && Yl(e2.focusNode, e2.focusOffset, 0);
if (!i2)
return null;
let s = t2 - i2.offset;
return { from: s, to: s + i2.node.nodeValue.length, node: i2.node };
}
function Of(n2, t2, e2) {
let i2 = Ul(n2, e2);
if (!i2)
return null;
let { node: s, from: r2, to: o } = i2, l = s.nodeValue;
if (/[\n\r]/.test(l) || n2.state.doc.sliceString(i2.from, i2.to) != l)
return null;
let h2 = t2.invertedDesc, a2 = new Mt(h2.mapPos(r2), h2.mapPos(o), r2, o), c2 = [];
for (let f2 = s.parentNode; ; f2 = f2.parentNode) {
let u2 = q$1.get(f2);
if (u2 instanceof oe)
c2.push({ node: f2, deco: u2.mark });
else {
if (u2 instanceof Z$1 || f2.nodeName == "DIV" && f2.parentNode == n2.contentDOM)
return { range: a2, text: s, marks: c2, line: f2 };
if (f2 != n2.contentDOM)
c2.push({ node: f2, deco: new Mi({
inclusive: true,
attributes: uf(f2),
tagName: f2.tagName.toLowerCase()
}) });
else
return null;
}
}
}
function Yl(n2, t2, e2) {
if (e2 <= 0)
for (let i2 = n2, s = t2; ; ) {
if (i2.nodeType == 3)
return { node: i2, offset: s };
if (i2.nodeType == 1 && s > 0)
i2 = i2.childNodes[s - 1], s = ne(i2);
else
break;
}
if (e2 >= 0)
for (let i2 = n2, s = t2; ; ) {
if (i2.nodeType == 3)
return { node: i2, offset: s };
if (i2.nodeType == 1 && s < i2.childNodes.length && e2 >= 0)
i2 = i2.childNodes[s], s = 0;
else
break;
}
return null;
}
function Mf(n2, t2) {
return n2.nodeType != 1 ? 0 : (t2 && n2.childNodes[t2 - 1].contentEditable == "false" ? 1 : 0) | (t2 < n2.childNodes.length && n2.childNodes[t2].contentEditable == "false" ? 2 : 0);
}
let Tf = class {
constructor() {
this.changes = [];
}
compareRange(t2, e2) {
Sn(t2, e2, this.changes);
}
comparePoint(t2, e2) {
Sn(t2, e2, this.changes);
}
};
function Df(n2, t2, e2) {
let i2 = new Tf();
return F.compare(n2, t2, e2, i2), i2.changes;
}
function Pf(n2, t2) {
for (let e2 = n2; e2 && e2 != t2; e2 = e2.assignedSlot || e2.parentNode)
if (e2.nodeType == 1 && e2.contentEditable == "false")
return true;
return false;
}
function Bf(n2, t2) {
let e2 = false;
return t2 && n2.iterChangedRanges((i2, s) => {
i2 < t2.to && s > t2.from && (e2 = true);
}), e2;
}
function Rf(n2, t2, e2 = 1) {
let i2 = n2.charCategorizer(t2), s = n2.doc.lineAt(t2), r2 = t2 - s.from;
if (s.length == 0)
return b$1.cursor(t2);
r2 == 0 ? e2 = 1 : r2 == s.length && (e2 = -1);
let o = r2, l = r2;
e2 < 0 ? o = wt(s.text, r2, false) : l = wt(s.text, r2);
let h2 = i2(s.text.slice(o, l));
for (; o > 0; ) {
let a2 = wt(s.text, o, false);
if (i2(s.text.slice(a2, o)) != h2)
break;
o = a2;
}
for (; l < s.length; ) {
let a2 = wt(s.text, l);
if (i2(s.text.slice(l, a2)) != h2)
break;
l = a2;
}
return b$1.range(o + s.from, l + s.from);
}
function Lf(n2, t2) {
return t2.left > n2 ? t2.left - n2 : Math.max(0, n2 - t2.right);
}
function Ef(n2, t2) {
return t2.top > n2 ? t2.top - n2 : Math.max(0, n2 - t2.bottom);
}
function zs(n2, t2) {
return n2.top < t2.bottom - 1 && n2.bottom > t2.top + 1;
}
function _r(n2, t2) {
return t2 < n2.top ? { top: t2, left: n2.left, right: n2.right, bottom: n2.bottom } : n2;
}
function zr(n2, t2) {
return t2 > n2.bottom ? { top: n2.top, left: n2.left, right: n2.right, bottom: t2 } : n2;
}
function Tn(n2, t2, e2) {
let i2, s, r2, o, l = false, h2, a2, c2, f2;
for (let p2 = n2.firstChild; p2; p2 = p2.nextSibling) {
let m = bi(p2);
for (let g = 0; g < m.length; g++) {
let y2 = m[g];
s && zs(s, y2) && (y2 = _r(zr(y2, s.bottom), s.top));
let x2 = Lf(t2, y2), S2 = Ef(e2, y2);
if (x2 == 0 && S2 == 0)
return p2.nodeType == 3 ? Wr(p2, t2, e2) : Tn(p2, t2, e2);
if (!i2 || o > S2 || o == S2 && r2 > x2) {
i2 = p2, s = y2, r2 = x2, o = S2;
let v2 = S2 ? e2 < y2.top ? -1 : 1 : x2 ? t2 < y2.left ? -1 : 1 : 0;
l = !v2 || (v2 > 0 ? g < m.length - 1 : g > 0);
}
x2 == 0 ? e2 > y2.bottom && (!c2 || c2.bottom < y2.bottom) ? (h2 = p2, c2 = y2) : e2 < y2.top && (!f2 || f2.top > y2.top) && (a2 = p2, f2 = y2) : c2 && zs(c2, y2) ? c2 = zr(c2, y2.bottom) : f2 && zs(f2, y2) && (f2 = _r(f2, y2.top));
}
}
if (c2 && c2.bottom >= e2 ? (i2 = h2, s = c2) : f2 && f2.top <= e2 && (i2 = a2, s = f2), !i2)
return { node: n2, offset: 0 };
let u2 = Math.max(s.left, Math.min(s.right, t2));
if (i2.nodeType == 3)
return Wr(i2, u2, e2);
if (l && i2.contentEditable != "false")
return Tn(i2, u2, e2);
let d2 = Array.prototype.indexOf.call(n2.childNodes, i2) + (t2 >= (s.left + s.right) / 2 ? 1 : 0);
return { node: n2, offset: d2 };
}
function Wr(n2, t2, e2) {
let i2 = n2.nodeValue.length, s = -1, r2 = 1e9, o = 0;
for (let l = 0; l < i2; l++) {
let h2 = Ne(n2, l, l + 1).getClientRects();
for (let a2 = 0; a2 < h2.length; a2++) {
let c2 = h2[a2];
if (c2.top == c2.bottom)
continue;
o || (o = t2 - c2.left);
let f2 = (c2.top > e2 ? c2.top - e2 : e2 - c2.bottom) - 1;
if (c2.left - 1 <= t2 && c2.right + 1 >= t2 && f2 < r2) {
let u2 = t2 >= (c2.left + c2.right) / 2, d2 = u2;
if ((C.chrome || C.gecko) && Ne(n2, l).getBoundingClientRect().left == c2.right && (d2 = !u2), f2 <= 0)
return { node: n2, offset: l + (d2 ? 1 : 0) };
s = l + (d2 ? 1 : 0), r2 = f2;
}
}
}
return { node: n2, offset: s > -1 ? s : o > 0 ? n2.nodeValue.length : 0 };
}
function Ql(n2, t2, e2, i2 = -1) {
var s, r2;
let o = n2.contentDOM.getBoundingClientRect(), l = o.top + n2.viewState.paddingTop, h2, { docHeight: a2 } = n2.viewState, { x: c2, y: f2 } = t2, u2 = f2 - l;
if (u2 < 0)
return 0;
if (u2 > a2)
return n2.state.doc.length;
for (let v2 = n2.viewState.heightOracle.textHeight / 2, A2 = false; h2 = n2.elementAtHeight(u2), h2.type != Lt.Text; )
for (; u2 = i2 > 0 ? h2.bottom + v2 : h2.top - v2, !(u2 >= 0 && u2 <= a2); ) {
if (A2)
return e2 ? null : 0;
A2 = true, i2 = -i2;
}
f2 = l + u2;
let d2 = h2.from;
if (d2 < n2.viewport.from)
return n2.viewport.from == 0 ? 0 : e2 ? null : jr(n2, o, h2, c2, f2);
if (d2 > n2.viewport.to)
return n2.viewport.to == n2.state.doc.length ? n2.state.doc.length : e2 ? null : jr(n2, o, h2, c2, f2);
let p2 = n2.dom.ownerDocument, m = n2.root.elementFromPoint ? n2.root : p2, g = m.elementFromPoint(c2, f2);
g && !n2.contentDOM.contains(g) && (g = null), g || (c2 = Math.max(o.left + 1, Math.min(o.right - 1, c2)), g = m.elementFromPoint(c2, f2), g && !n2.contentDOM.contains(g) && (g = null));
let y2, x2 = -1;
if (g && ((s = n2.docView.nearest(g)) === null || s === void 0 ? void 0 : s.isEditable) != false) {
if (p2.caretPositionFromPoint) {
let v2 = p2.caretPositionFromPoint(c2, f2);
v2 && ({ offsetNode: y2, offset: x2 } = v2);
} else if (p2.caretRangeFromPoint) {
let v2 = p2.caretRangeFromPoint(c2, f2);
v2 && ({ startContainer: y2, startOffset: x2 } = v2, (!n2.contentDOM.contains(y2) || C.safari && Nf(y2, x2, c2) || C.chrome && If(y2, x2, c2)) && (y2 = void 0));
}
}
if (!y2 || !n2.docView.dom.contains(y2)) {
let v2 = Z$1.find(n2.docView, d2);
if (!v2)
return u2 > h2.top + h2.height / 2 ? h2.to : h2.from;
({ node: y2, offset: x2 } = Tn(v2.dom, c2, f2));
}
let S2 = n2.docView.nearest(y2);
if (!S2)
return null;
if (S2.isWidget && ((r2 = S2.dom) === null || r2 === void 0 ? void 0 : r2.nodeType) == 1) {
let v2 = S2.dom.getBoundingClientRect();
return t2.y < v2.top || t2.y <= v2.bottom && t2.x <= (v2.left + v2.right) / 2 ? S2.posAtStart : S2.posAtEnd;
} else
return S2.localPosFromDOM(y2, x2) + S2.posAtStart;
}
function jr(n2, t2, e2, i2, s) {
let r2 = Math.round((i2 - t2.left) * n2.defaultCharacterWidth);
if (n2.lineWrapping && e2.height > n2.defaultLineHeight * 1.5) {
let l = n2.viewState.heightOracle.textHeight, h2 = Math.floor((s - e2.top - (n2.defaultLineHeight - l) * 0.5) / l);
r2 += h2 * n2.viewState.heightOracle.lineLength;
}
let o = n2.state.sliceDoc(e2.from, e2.to);
return e2.from + Qc(o, r2, n2.state.tabSize);
}
function Nf(n2, t2, e2) {
let i2;
if (n2.nodeType != 3 || t2 != (i2 = n2.nodeValue.length))
return false;
for (let s = n2.nextSibling; s; s = s.nextSibling)
if (s.nodeType != 1 || s.nodeName != "BR")
return false;
return Ne(n2, i2 - 1, i2).getBoundingClientRect().left > e2;
}
function If(n2, t2, e2) {
if (t2 != 0)
return false;
for (let s = n2; ; ) {
let r2 = s.parentNode;
if (!r2 || r2.nodeType != 1 || r2.firstChild != s)
return false;
if (r2.classList.contains("cm-line"))
break;
s = r2;
}
let i2 = n2.nodeType == 1 ? n2.getBoundingClientRect() : Ne(n2, 0, Math.max(n2.nodeValue.length, 1)).getBoundingClientRect();
return e2 - i2.left > 5;
}
function Vf(n2, t2) {
let e2 = n2.lineBlockAt(t2);
if (Array.isArray(e2.type)) {
for (let i2 of e2.type)
if (i2.to > t2 || i2.to == t2 && (i2.to == e2.to || i2.type == Lt.Text))
return i2;
}
return e2;
}
function Hf(n2, t2, e2, i2) {
let s = Vf(n2, t2.head), r2 = !i2 || s.type != Lt.Text || !(n2.lineWrapping || s.widgetLineBreaks) ? null : n2.coordsAtPos(t2.assoc < 0 && t2.head > s.from ? t2.head - 1 : t2.head);
if (r2) {
let o = n2.dom.getBoundingClientRect(), l = n2.textDirectionAt(s.from), h2 = n2.posAtCoords({
x: e2 == (l == tt.LTR) ? o.right - 1 : o.left + 1,
y: (r2.top + r2.bottom) / 2
});
if (h2 != null)
return b$1.cursor(h2, e2 ? -1 : 1);
}
return b$1.cursor(e2 ? s.to : s.from, e2 ? -1 : 1);
}
function Kr(n2, t2, e2, i2) {
let s = n2.state.doc.lineAt(t2.head), r2 = n2.bidiSpans(s), o = n2.textDirectionAt(s.from);
for (let l = t2, h2 = null; ; ) {
let a2 = Cf(s, r2, o, l, e2), c2 = Gl;
if (!a2) {
if (s.number == (e2 ? n2.state.doc.lines : 1))
return l;
c2 = `
`, s = n2.state.doc.line(s.number + (e2 ? 1 : -1)), r2 = n2.bidiSpans(s), a2 = b$1.cursor(e2 ? s.from : s.to);
}
if (h2) {
if (!h2(c2))
return l;
} else {
if (!i2)
return a2;
h2 = i2(c2);
}
l = a2;
}
}
function $f(n2, t2, e2) {
let i2 = n2.state.charCategorizer(t2), s = i2(e2);
return (r2) => {
let o = i2(r2);
return s == Zt.Space && (s = o), s == o;
};
}
function Ff(n2, t2, e2, i2) {
let s = t2.head, r2 = e2 ? 1 : -1;
if (s == (e2 ? n2.state.doc.length : 0))
return b$1.cursor(s, t2.assoc);
let o = t2.goalColumn, l, h2 = n2.contentDOM.getBoundingClientRect(), a2 = n2.coordsAtPos(s, t2.assoc || -1), c2 = n2.documentTop;
if (a2)
o == null && (o = a2.left - h2.left), l = r2 < 0 ? a2.top : a2.bottom;
else {
let d2 = n2.viewState.lineBlockAt(s);
o == null && (o = Math.min(h2.right - h2.left, n2.defaultCharacterWidth * (s - d2.from))), l = (r2 < 0 ? d2.top : d2.bottom) + c2;
}
let f2 = h2.left + o, u2 = i2 ?? n2.viewState.heightOracle.textHeight >> 1;
for (let d2 = 0; ; d2 += 10) {
let p2 = l + (u2 + d2) * r2, m = Ql(n2, { x: f2, y: p2 }, false, r2);
if (p2 < h2.top || p2 > h2.bottom || (r2 < 0 ? m < s : m > s)) {
let g = n2.docView.coordsForChar(m), y2 = !g || p2 < g.top ? -1 : 1;
return b$1.cursor(m, y2, void 0, o);
}
}
}
function es(n2, t2, e2) {
for (; ; ) {
let i2 = 0;
for (let s of n2)
s.between(t2 - 1, t2 + 1, (r2, o, l) => {
if (t2 > r2 && t2 < o) {
let h2 = i2 || e2 || (t2 - r2 < o - t2 ? -1 : 1);
t2 = h2 < 0 ? r2 : o, i2 = h2;
}
});
if (!i2)
return t2;
}
}
function Ws(n2, t2, e2) {
let i2 = es(n2.state.facet(ir).map((s) => s(n2)), e2.from, t2.head > e2.from ? -1 : 1);
return i2 == e2.from ? e2 : b$1.cursor(i2, i2 < e2.from ? 1 : -1);
}
class _f {
setSelectionOrigin(t2) {
this.lastSelectionOrigin = t2, this.lastSelectionTime = Date.now();
}
constructor(t2) {
this.view = t2, this.lastKeyCode = 0, this.lastKeyTime = 0, this.lastTouchTime = 0, this.lastFocusTime = 0, this.lastScrollTop = 0, this.lastScrollLeft = 0, this.pendingIOSKey = void 0, this.lastSelectionOrigin = null, this.lastSelectionTime = 0, this.lastEscPress = 0, this.lastContextMenu = 0, this.scrollHandlers = [], this.handlers = /* @__PURE__ */ Object.create(null), this.composing = -1, this.compositionFirstChange = null, this.compositionEndedAt = 0, this.compositionPendingKey = false, this.compositionPendingChange = false, this.mouseSelection = null, this.draggedContent = null, this.handleEvent = this.handleEvent.bind(this), this.notifiedFocused = t2.hasFocus, C.safari && t2.contentDOM.addEventListener("input", () => null), C.gecko && su(t2.contentDOM.ownerDocument);
}
handleEvent(t2) {
!Yf(this.view, t2) || this.ignoreDuringComposition(t2) || t2.type == "keydown" && this.keydown(t2) || this.runHandlers(t2.type, t2);
}
runHandlers(t2, e2) {
let i2 = this.handlers[t2];
if (i2) {
for (let s of i2.observers)
s(this.view, e2);
for (let s of i2.handlers) {
if (e2.defaultPrevented)
break;
if (s(this.view, e2)) {
e2.preventDefault();
break;
}
}
}
}
ensureHandlers(t2) {
let e2 = zf(t2), i2 = this.handlers, s = this.view.contentDOM;
for (let r2 in e2)
if (r2 != "scroll") {
let o = !e2[r2].handlers.length, l = i2[r2];
l && o != !l.handlers.length && (s.removeEventListener(r2, this.handleEvent), l = null), l || s.addEventListener(r2, this.handleEvent, { passive: o });
}
for (let r2 in i2)
r2 != "scroll" && !e2[r2] && s.removeEventListener(r2, this.handleEvent);
this.handlers = e2;
}
keydown(t2) {
if (this.lastKeyCode = t2.keyCode, this.lastKeyTime = Date.now(), t2.keyCode == 9 && Date.now() < this.lastEscPress + 2e3)
return true;
if (t2.keyCode != 27 && Xl.indexOf(t2.keyCode) < 0 && (this.view.inputState.lastEscPress = 0), C.android && C.chrome && !t2.synthetic && (t2.keyCode == 13 || t2.keyCode == 8))
return this.view.observer.delayAndroidKey(t2.key, t2.keyCode), true;
let e2;
return C.ios && !t2.synthetic && !t2.altKey && !t2.metaKey && ((e2 = Jl.find((i2) => i2.keyCode == t2.keyCode)) && !t2.ctrlKey || Wf.indexOf(t2.key) > -1 && t2.ctrlKey && !t2.shiftKey) ? (this.pendingIOSKey = e2 || t2, setTimeout(() => this.flushIOSKey(), 250), true) : (t2.keyCode != 229 && this.view.observer.forceFlush(), false);
}
flushIOSKey() {
let t2 = this.pendingIOSKey;
return t2 ? (this.pendingIOSKey = void 0, Ke(this.view.contentDOM, t2.key, t2.keyCode)) : false;
}
ignoreDuringComposition(t2) {
return /^key/.test(t2.type) ? this.composing > 0 ? true : C.safari && !C.ios && this.compositionPendingKey && Date.now() - this.compositionEndedAt < 100 ? (this.compositionPendingKey = false, true) : false : false;
}
startMouseSelection(t2) {
this.mouseSelection && this.mouseSelection.destroy(), this.mouseSelection = t2;
}
update(t2) {
this.mouseSelection && this.mouseSelection.update(t2), this.draggedContent && t2.docChanged && (this.draggedContent = this.draggedContent.map(t2.changes)), t2.transactions.length && (this.lastKeyCode = this.lastSelectionTime = 0);
}
destroy() {
this.mouseSelection && this.mouseSelection.destroy();
}
}
function qr(n2, t2) {
return (e2, i2) => {
try {
return t2.call(n2, i2, e2);
} catch (s) {
ie(e2.state, s);
}
};
}
function zf(n2) {
let t2 = /* @__PURE__ */ Object.create(null);
function e2(i2) {
return t2[i2] || (t2[i2] = { observers: [], handlers: [] });
}
for (let i2 of n2) {
let s = i2.spec;
if (s && s.domEventHandlers)
for (let r2 in s.domEventHandlers) {
let o = s.domEventHandlers[r2];
o && e2(r2).handlers.push(qr(i2.value, o));
}
if (s && s.domEventObservers)
for (let r2 in s.domEventObservers) {
let o = s.domEventObservers[r2];
o && e2(r2).observers.push(qr(i2.value, o));
}
}
for (let i2 in Nt)
e2(i2).handlers.push(Nt[i2]);
for (let i2 in It)
e2(i2).observers.push(It[i2]);
return t2;
}
const Jl = [
{ key: "Backspace", keyCode: 8, inputType: "deleteContentBackward" },
{ key: "Enter", keyCode: 13, inputType: "insertParagraph" },
{ key: "Enter", keyCode: 13, inputType: "insertLineBreak" },
{ key: "Delete", keyCode: 46, inputType: "deleteContentForward" }
], Wf = "dthko", Xl = [16, 17, 18, 20, 91, 92, 224, 225], Vi = 6;
function Hi(n2) {
return Math.max(0, n2) * 0.7 + 8;
}
function jf(n2, t2) {
return Math.max(Math.abs(n2.clientX - t2.clientX), Math.abs(n2.clientY - t2.clientY));
}
class Kf {
constructor(t2, e2, i2, s) {
this.view = t2, this.startEvent = e2, this.style = i2, this.mustSelect = s, this.scrollSpeed = { x: 0, y: 0 }, this.scrolling = -1, this.lastEvent = e2, this.scrollParent = rf(t2.contentDOM), this.atoms = t2.state.facet(ir).map((o) => o(t2));
let r2 = t2.contentDOM.ownerDocument;
r2.addEventListener("mousemove", this.move = this.move.bind(this)), r2.addEventListener("mouseup", this.up = this.up.bind(this)), this.extend = e2.shiftKey, this.multiple = t2.state.facet(H$3.allowMultipleSelections) && qf(t2, e2), this.dragging = Uf(t2, e2) && ih(e2) == 1 ? null : false;
}
start(t2) {
this.dragging === false && this.select(t2);
}
move(t2) {
var e2;
if (t2.buttons == 0)
return this.destroy();
if (this.dragging || this.dragging == null && jf(this.startEvent, t2) < 10)
return;
this.select(this.lastEvent = t2);
let i2 = 0, s = 0, r2 = ((e2 = this.scrollParent) === null || e2 === void 0 ? void 0 : e2.getBoundingClientRect()) || { left: 0, top: 0, right: this.view.win.innerWidth, bottom: this.view.win.innerHeight }, o = zl(this.view);
t2.clientX - o.left <= r2.left + Vi ? i2 = -Hi(r2.left - t2.clientX) : t2.clientX + o.right >= r2.right - Vi && (i2 = Hi(t2.clientX - r2.right)), t2.clientY - o.top <= r2.top + Vi ? s = -Hi(r2.top - t2.clientY) : t2.clientY + o.bottom >= r2.bottom - Vi && (s = Hi(t2.clientY - r2.bottom)), this.setScrollSpeed(i2, s);
}
up(t2) {
this.dragging == null && this.select(this.lastEvent), this.dragging || t2.preventDefault(), this.destroy();
}
destroy() {
this.setScrollSpeed(0, 0);
let t2 = this.view.contentDOM.ownerDocument;
t2.removeEventListener("mousemove", this.move), t2.removeEventListener("mouseup", this.up), this.view.inputState.mouseSelection = this.view.inputState.draggedContent = null;
}
setScrollSpeed(t2, e2) {
this.scrollSpeed = { x: t2, y: e2 }, t2 || e2 ? this.scrolling < 0 && (this.scrolling = setInterval(() => this.scroll(), 50)) : this.scrolling > -1 && (clearInterval(this.scrolling), this.scrolling = -1);
}
scroll() {
this.scrollParent ? (this.scrollParent.scrollLeft += this.scrollSpeed.x, this.scrollParent.scrollTop += this.scrollSpeed.y) : this.view.win.scrollBy(this.scrollSpeed.x, this.scrollSpeed.y), this.dragging === false && this.select(this.lastEvent);
}
skipAtoms(t2) {
let e2 = null;
for (let i2 = 0; i2 < t2.ranges.length; i2++) {
let s = t2.ranges[i2], r2 = null;
if (s.empty) {
let o = es(this.atoms, s.from, 0);
o != s.from && (r2 = b$1.cursor(o, -1));
} else {
let o = es(this.atoms, s.from, -1), l = es(this.atoms, s.to, 1);
(o != s.from || l != s.to) && (r2 = b$1.range(s.from == s.anchor ? o : l, s.from == s.head ? o : l));
}
r2 && (e2 || (e2 = t2.ranges.slice()), e2[i2] = r2);
}
return e2 ? b$1.create(e2, t2.mainIndex) : t2;
}
select(t2) {
let { view: e2 } = this, i2 = this.skipAtoms(this.style.get(t2, this.extend, this.multiple));
(this.mustSelect || !i2.eq(e2.state.selection) || i2.main.assoc != e2.state.selection.main.assoc && this.dragging === false) && this.view.dispatch({
selection: i2,
userEvent: "select.pointer"
}), this.mustSelect = false;
}
update(t2) {
this.style.update(t2) && setTimeout(() => this.select(this.lastEvent), 20);
}
}
function qf(n2, t2) {
let e2 = n2.state.facet(Rl);
return e2.length ? e2[0](t2) : C.mac ? t2.metaKey : t2.ctrlKey;
}
function Gf(n2, t2) {
let e2 = n2.state.facet(Ll);
return e2.length ? e2[0](t2) : C.mac ? !t2.altKey : !t2.ctrlKey;
}
function Uf(n2, t2) {
let { main: e2 } = n2.state.selection;
if (e2.empty)
return false;
let i2 = us(n2.root);
if (!i2 || i2.rangeCount == 0)
return true;
let s = i2.getRangeAt(0).getClientRects();
for (let r2 = 0; r2 < s.length; r2++) {
let o = s[r2];
if (o.left <= t2.clientX && o.right >= t2.clientX && o.top <= t2.clientY && o.bottom >= t2.clientY)
return true;
}
return false;
}
function Yf(n2, t2) {
if (!t2.bubbles)
return true;
if (t2.defaultPrevented)
return false;
for (let e2 = t2.target, i2; e2 != n2.contentDOM; e2 = e2.parentNode)
if (!e2 || e2.nodeType == 11 || (i2 = q$1.get(e2)) && i2.ignoreEvent(t2))
return false;
return true;
}
const Nt = /* @__PURE__ */ Object.create(null), It = /* @__PURE__ */ Object.create(null), Zl = C.ie && C.ie_version < 15 || C.ios && C.webkit_version < 604;
function Qf(n2) {
let t2 = n2.dom.parentNode;
if (!t2)
return;
let e2 = t2.appendChild(document.createElement("textarea"));
e2.style.cssText = "position: fixed; left: -10000px; top: 10px", e2.focus(), setTimeout(() => {
n2.focus(), e2.remove(), th(n2, e2.value);
}, 50);
}
function th(n2, t2) {
let { state: e2 } = n2, i2, s = 1, r2 = e2.toText(t2), o = r2.lines == e2.selection.ranges.length;
if (Dn != null && e2.selection.ranges.every((h2) => h2.empty) && Dn == r2.toString()) {
let h2 = -1;
i2 = e2.changeByRange((a2) => {
let c2 = e2.doc.lineAt(a2.from);
if (c2.from == h2)
return { range: a2 };
h2 = c2.from;
let f2 = e2.toText((o ? r2.line(s++).text : t2) + e2.lineBreak);
return {
changes: { from: c2.from, insert: f2 },
range: b$1.cursor(a2.from + f2.length)
};
});
} else
o ? i2 = e2.changeByRange((h2) => {
let a2 = r2.line(s++);
return {
changes: { from: h2.from, to: h2.to, insert: a2.text },
range: b$1.cursor(h2.from + a2.length)
};
}) : i2 = e2.replaceSelection(r2);
n2.dispatch(i2, {
userEvent: "input.paste",
scrollIntoView: true
});
}
It.scroll = (n2) => {
n2.inputState.lastScrollTop = n2.scrollDOM.scrollTop, n2.inputState.lastScrollLeft = n2.scrollDOM.scrollLeft;
};
Nt.keydown = (n2, t2) => (n2.inputState.setSelectionOrigin("select"), t2.keyCode == 27 && (n2.inputState.lastEscPress = Date.now()), false);
It.touchstart = (n2, t2) => {
n2.inputState.lastTouchTime = Date.now(), n2.inputState.setSelectionOrigin("select.pointer");
};
It.touchmove = (n2) => {
n2.inputState.setSelectionOrigin("select.pointer");
};
Nt.mousedown = (n2, t2) => {
if (n2.observer.flush(), n2.inputState.lastTouchTime > Date.now() - 2e3)
return false;
let e2 = null;
for (let i2 of n2.state.facet(El))
if (e2 = i2(n2, t2), e2)
break;
if (!e2 && t2.button == 0 && (e2 = Zf(n2, t2)), e2) {
let i2 = !n2.hasFocus;
n2.inputState.startMouseSelection(new Kf(n2, t2, e2, i2)), i2 && n2.observer.ignore(() => kl(n2.contentDOM));
let s = n2.inputState.mouseSelection;
if (s)
return s.start(t2), s.dragging === false;
}
return false;
};
function Gr(n2, t2, e2, i2) {
if (i2 == 1)
return b$1.cursor(t2, e2);
if (i2 == 2)
return Rf(n2.state, t2, e2);
{
let s = Z$1.find(n2.docView, t2), r2 = n2.state.doc.lineAt(s ? s.posAtEnd : t2), o = s ? s.posAtStart : r2.from, l = s ? s.posAtEnd : r2.to;
return l < n2.state.doc.length && l == r2.to && l++, b$1.range(o, l);
}
}
let eh = (n2, t2) => n2 >= t2.top && n2 <= t2.bottom, Ur = (n2, t2, e2) => eh(t2, e2) && n2 >= e2.left && n2 <= e2.right;
function Jf(n2, t2, e2, i2) {
let s = Z$1.find(n2.docView, t2);
if (!s)
return 1;
let r2 = t2 - s.posAtStart;
if (r2 == 0)
return 1;
if (r2 == s.length)
return -1;
let o = s.coordsAt(r2, -1);
if (o && Ur(e2, i2, o))
return -1;
let l = s.coordsAt(r2, 1);
return l && Ur(e2, i2, l) ? 1 : o && eh(i2, o) ? -1 : 1;
}
function Yr(n2, t2) {
let e2 = n2.posAtCoords({ x: t2.clientX, y: t2.clientY }, false);
return { pos: e2, bias: Jf(n2, e2, t2.clientX, t2.clientY) };
}
const Xf = C.ie && C.ie_version <= 11;
let Qr = null, Jr = 0, Xr = 0;
function ih(n2) {
if (!Xf)
return n2.detail;
let t2 = Qr, e2 = Xr;
return Qr = n2, Xr = Date.now(), Jr = !t2 || e2 > Date.now() - 400 && Math.abs(t2.clientX - n2.clientX) < 2 && Math.abs(t2.clientY - n2.clientY) < 2 ? (Jr + 1) % 3 : 1;
}
function Zf(n2, t2) {
let e2 = Yr(n2, t2), i2 = ih(t2), s = n2.state.selection;
return {
update(r2) {
r2.docChanged && (e2.pos = r2.changes.mapPos(e2.pos), s = s.map(r2.changes));
},
get(r2, o, l) {
let h2 = Yr(n2, r2), a2, c2 = Gr(n2, h2.pos, h2.bias, i2);
if (e2.pos != h2.pos && !o) {
let f2 = Gr(n2, e2.pos, e2.bias, i2), u2 = Math.min(f2.from, c2.from), d2 = Math.max(f2.to, c2.to);
c2 = u2 < c2.from ? b$1.range(u2, d2) : b$1.range(d2, u2);
}
return o ? s.replaceRange(s.main.extend(c2.from, c2.to)) : l && i2 == 1 && s.ranges.length > 1 && (a2 = tu(s, h2.pos)) ? a2 : l ? s.addRange(c2) : b$1.create([c2]);
}
};
}
function tu(n2, t2) {
for (let e2 = 0; e2 < n2.ranges.length; e2++) {
let { from: i2, to: s } = n2.ranges[e2];
if (i2 <= t2 && s >= t2)
return b$1.create(n2.ranges.slice(0, e2).concat(n2.ranges.slice(e2 + 1)), n2.mainIndex == e2 ? 0 : n2.mainIndex - (n2.mainIndex > e2 ? 1 : 0));
}
return null;
}
Nt.dragstart = (n2, t2) => {
let { selection: { main: e2 } } = n2.state;
if (t2.target.draggable) {
let s = n2.docView.nearest(t2.target);
if (s && s.isWidget) {
let r2 = s.posAtStart, o = r2 + s.length;
(r2 >= e2.to || o <= e2.from) && (e2 = b$1.range(r2, o));
}
}
let { inputState: i2 } = n2;
return i2.mouseSelection && (i2.mouseSelection.dragging = true), i2.draggedContent = e2, t2.dataTransfer && (t2.dataTransfer.setData("Text", n2.state.sliceDoc(e2.from, e2.to)), t2.dataTransfer.effectAllowed = "copyMove"), false;
};
Nt.dragend = (n2) => (n2.inputState.draggedContent = null, false);
function Zr(n2, t2, e2, i2) {
if (!e2)
return;
let s = n2.posAtCoords({ x: t2.clientX, y: t2.clientY }, false), { draggedContent: r2 } = n2.inputState, o = i2 && r2 && Gf(n2, t2) ? { from: r2.from, to: r2.to } : null, l = { from: s, insert: e2 }, h2 = n2.state.changes(o ? [o, l] : l);
n2.focus(), n2.dispatch({
changes: h2,
selection: { anchor: h2.mapPos(s, -1), head: h2.mapPos(s, 1) },
userEvent: o ? "move.drop" : "input.drop"
}), n2.inputState.draggedContent = null;
}
Nt.drop = (n2, t2) => {
if (!t2.dataTransfer)
return false;
if (n2.state.readOnly)
return true;
let e2 = t2.dataTransfer.files;
if (e2 && e2.length) {
let i2 = Array(e2.length), s = 0, r2 = () => {
++s == e2.length && Zr(n2, t2, i2.filter((o) => o != null).join(n2.state.lineBreak), false);
};
for (let o = 0; o < e2.length; o++) {
let l = new FileReader();
l.onerror = r2, l.onload = () => {
/[\x00-\x08\x0e-\x1f]{2}/.test(l.result) || (i2[o] = l.result), r2();
}, l.readAsText(e2[o]);
}
return true;
} else {
let i2 = t2.dataTransfer.getData("Text");
if (i2)
return Zr(n2, t2, i2, true), true;
}
return false;
};
Nt.paste = (n2, t2) => {
if (n2.state.readOnly)
return true;
n2.observer.flush();
let e2 = Zl ? null : t2.clipboardData;
return e2 ? (th(n2, e2.getData("text/plain") || e2.getData("text/uri-text")), true) : (Qf(n2), false);
};
function eu(n2, t2) {
let e2 = n2.dom.parentNode;
if (!e2)
return;
let i2 = e2.appendChild(document.createElement("textarea"));
i2.style.cssText = "position: fixed; left: -10000px; top: 10px", i2.value = t2, i2.focus(), i2.selectionEnd = t2.length, i2.selectionStart = 0, setTimeout(() => {
i2.remove(), n2.focus();
}, 50);
}
function iu(n2) {
let t2 = [], e2 = [], i2 = false;
for (let s of n2.selection.ranges)
s.empty || (t2.push(n2.sliceDoc(s.from, s.to)), e2.push(s));
if (!t2.length) {
let s = -1;
for (let { from: r2 } of n2.selection.ranges) {
let o = n2.doc.lineAt(r2);
o.number > s && (t2.push(o.text), e2.push({ from: o.from, to: Math.min(n2.doc.length, o.to + 1) })), s = o.number;
}
i2 = true;
}
return { text: t2.join(n2.lineBreak), ranges: e2, linewise: i2 };
}
let Dn = null;
Nt.copy = Nt.cut = (n2, t2) => {
let { text: e2, ranges: i2, linewise: s } = iu(n2.state);
if (!e2 && !s)
return false;
Dn = s ? e2 : null, t2.type == "cut" && !n2.state.readOnly && n2.dispatch({
changes: i2,
scrollIntoView: true,
userEvent: "delete.cut"
});
let r2 = Zl ? null : t2.clipboardData;
return r2 ? (r2.clearData(), r2.setData("text/plain", e2), true) : (eu(n2, e2), false);
};
const sh = /* @__PURE__ */ ti.define();
function nh(n2, t2) {
let e2 = [];
for (let i2 of n2.facet(Vl)) {
let s = i2(n2, t2);
s && e2.push(s);
}
return e2 ? n2.update({ effects: e2, annotations: sh.of(true) }) : null;
}
function rh(n2) {
setTimeout(() => {
let t2 = n2.hasFocus;
if (t2 != n2.inputState.notifiedFocused) {
let e2 = nh(n2.state, t2);
e2 ? n2.dispatch(e2) : n2.update([]);
}
}, 10);
}
It.focus = (n2) => {
n2.inputState.lastFocusTime = Date.now(), !n2.scrollDOM.scrollTop && (n2.inputState.lastScrollTop || n2.inputState.lastScrollLeft) && (n2.scrollDOM.scrollTop = n2.inputState.lastScrollTop, n2.scrollDOM.scrollLeft = n2.inputState.lastScrollLeft), rh(n2);
};
It.blur = (n2) => {
n2.observer.clearSelectionRange(), rh(n2);
};
It.compositionstart = It.compositionupdate = (n2) => {
n2.inputState.compositionFirstChange == null && (n2.inputState.compositionFirstChange = true), n2.inputState.composing < 0 && (n2.inputState.composing = 0);
};
It.compositionend = (n2) => {
n2.inputState.composing = -1, n2.inputState.compositionEndedAt = Date.now(), n2.inputState.compositionPendingKey = true, n2.inputState.compositionPendingChange = n2.observer.pendingRecords().length > 0, n2.inputState.compositionFirstChange = null, C.chrome && C.android ? n2.observer.flushSoon() : n2.inputState.compositionPendingChange ? Promise.resolve().then(() => n2.observer.flush()) : setTimeout(() => {
n2.inputState.composing < 0 && n2.docView.hasComposition && n2.update([]);
}, 50);
};
It.contextmenu = (n2) => {
n2.inputState.lastContextMenu = Date.now();
};
Nt.beforeinput = (n2, t2) => {
var e2;
let i2;
if (C.chrome && C.android && (i2 = Jl.find((s) => s.inputType == t2.inputType)) && (n2.observer.delayAndroidKey(i2.key, i2.keyCode), i2.key == "Backspace" || i2.key == "Delete")) {
let s = ((e2 = window.visualViewport) === null || e2 === void 0 ? void 0 : e2.height) || 0;
setTimeout(() => {
var r2;
(((r2 = window.visualViewport) === null || r2 === void 0 ? void 0 : r2.height) || 0) > s + 10 && n2.hasFocus && (n2.contentDOM.blur(), n2.focus());
}, 100);
}
return false;
};
const to = /* @__PURE__ */ new Set();
function su(n2) {
to.has(n2) || (to.add(n2), n2.addEventListener("copy", () => {
}), n2.addEventListener("cut", () => {
}));
}
const eo = ["pre-wrap", "normal", "pre-line", "break-spaces"];
class nu {
constructor(t2) {
this.lineWrapping = t2, this.doc = V.empty, this.heightSamples = {}, this.lineHeight = 14, this.charWidth = 7, this.textHeight = 14, this.lineLength = 30, this.heightChanged = false;
}
heightForGap(t2, e2) {
let i2 = this.doc.lineAt(e2).number - this.doc.lineAt(t2).number + 1;
return this.lineWrapping && (i2 += Math.max(0, Math.ceil((e2 - t2 - i2 * this.lineLength * 0.5) / this.lineLength))), this.lineHeight * i2;
}
heightForLine(t2) {
return this.lineWrapping ? (1 + Math.max(0, Math.ceil((t2 - this.lineLength) / (this.lineLength - 5)))) * this.lineHeight : this.lineHeight;
}
setDoc(t2) {
return this.doc = t2, this;
}
mustRefreshForWrapping(t2) {
return eo.indexOf(t2) > -1 != this.lineWrapping;
}
mustRefreshForHeights(t2) {
let e2 = false;
for (let i2 = 0; i2 < t2.length; i2++) {
let s = t2[i2];
s < 0 ? i2++ : this.heightSamples[Math.floor(s * 10)] || (e2 = true, this.heightSamples[Math.floor(s * 10)] = true);
}
return e2;
}
refresh(t2, e2, i2, s, r2, o) {
let l = eo.indexOf(t2) > -1, h2 = Math.round(e2) != Math.round(this.lineHeight) || this.lineWrapping != l;
if (this.lineWrapping = l, this.lineHeight = e2, this.charWidth = i2, this.textHeight = s, this.lineLength = r2, h2) {
this.heightSamples = {};
for (let a2 = 0; a2 < o.length; a2++) {
let c2 = o[a2];
c2 < 0 ? a2++ : this.heightSamples[Math.floor(c2 * 10)] = true;
}
}
return h2;
}
}
class ru {
constructor(t2, e2) {
this.from = t2, this.heights = e2, this.index = 0;
}
get more() {
return this.index < this.heights.length;
}
}
class Gt {
/**
@internal
*/
constructor(t2, e2, i2, s, r2) {
this.from = t2, this.length = e2, this.top = i2, this.height = s, this._content = r2;
}
/**
The type of element this is. When querying lines, this may be
an array of all the blocks that make up the line.
*/
get type() {
return typeof this._content == "number" ? Lt.Text : Array.isArray(this._content) ? this._content : this._content.type;
}
/**
The end of the element as a document position.
*/
get to() {
return this.from + this.length;
}
/**
The bottom position of the element.
*/
get bottom() {
return this.top + this.height;
}
/**
If this is a widget block, this will return the widget
associated with it.
*/
get widget() {
return this._content instanceof be ? this._content.widget : null;
}
/**
If this is a textblock, this holds the number of line breaks
that appear in widgets inside the block.
*/
get widgetLineBreaks() {
return typeof this._content == "number" ? this._content : 0;
}
/**
@internal
*/
join(t2) {
let e2 = (Array.isArray(this._content) ? this._content : [this]).concat(Array.isArray(t2._content) ? t2._content : [t2]);
return new Gt(this.from, this.length + t2.length, this.top, this.height + t2.height, e2);
}
}
var j$1 = /* @__PURE__ */ function(n2) {
return n2[n2.ByPos = 0] = "ByPos", n2[n2.ByHeight = 1] = "ByHeight", n2[n2.ByPosNoHeight = 2] = "ByPosNoHeight", n2;
}(j$1 || (j$1 = {}));
const is = 1e-3;
class pt {
constructor(t2, e2, i2 = 2) {
this.length = t2, this.height = e2, this.flags = i2;
}
get outdated() {
return (this.flags & 2) > 0;
}
set outdated(t2) {
this.flags = (t2 ? 2 : 0) | this.flags & -3;
}
setHeight(t2, e2) {
this.height != e2 && (Math.abs(this.height - e2) > is && (t2.heightChanged = true), this.height = e2);
}
// Base case is to replace a leaf node, which simply builds a tree
// from the new nodes and returns that (HeightMapBranch and
// HeightMapGap override this to actually use from/to)
replace(t2, e2, i2) {
return pt.of(i2);
}
// Again, these are base cases, and are overridden for branch and gap nodes.
decomposeLeft(t2, e2) {
e2.push(this);
}
decomposeRight(t2, e2) {
e2.push(this);
}
applyChanges(t2, e2, i2, s) {
let r2 = this, o = i2.doc;
for (let l = s.length - 1; l >= 0; l--) {
let { fromA: h2, toA: a2, fromB: c2, toB: f2 } = s[l], u2 = r2.lineAt(h2, j$1.ByPosNoHeight, i2.setDoc(e2), 0, 0), d2 = u2.to >= a2 ? u2 : r2.lineAt(a2, j$1.ByPosNoHeight, i2, 0, 0);
for (f2 += d2.to - a2, a2 = d2.to; l > 0 && u2.from <= s[l - 1].toA; )
h2 = s[l - 1].fromA, c2 = s[l - 1].fromB, l--, h2 < u2.from && (u2 = r2.lineAt(h2, j$1.ByPosNoHeight, i2, 0, 0));
c2 += u2.from - h2, h2 = u2.from;
let p2 = sr.build(i2.setDoc(o), t2, c2, f2);
r2 = r2.replace(h2, a2, p2);
}
return r2.updateHeight(i2, 0);
}
static empty() {
return new xt(0, 0);
}
// nodes uses null values to indicate the position of line breaks.
// There are never line breaks at the start or end of the array, or
// two line breaks next to each other, and the array isn't allowed
// to be empty (same restrictions as return value from the builder).
static of(t2) {
if (t2.length == 1)
return t2[0];
let e2 = 0, i2 = t2.length, s = 0, r2 = 0;
for (; ; )
if (e2 == i2)
if (s > r2 * 2) {
let l = t2[e2 - 1];
l.break ? t2.splice(--e2, 1, l.left, null, l.right) : t2.splice(--e2, 1, l.left, l.right), i2 += 1 + l.break, s -= l.size;
} else if (r2 > s * 2) {
let l = t2[i2];
l.break ? t2.splice(i2, 1, l.left, null, l.right) : t2.splice(i2, 1, l.left, l.right), i2 += 2 + l.break, r2 -= l.size;
} else
break;
else if (s < r2) {
let l = t2[e2++];
l && (s += l.size);
} else {
let l = t2[--i2];
l && (r2 += l.size);
}
let o = 0;
return t2[e2 - 1] == null ? (o = 1, e2--) : t2[e2] == null && (o = 1, i2++), new ou(pt.of(t2.slice(0, e2)), o, pt.of(t2.slice(i2)));
}
}
pt.prototype.size = 1;
class oh extends pt {
constructor(t2, e2, i2) {
super(t2, e2), this.deco = i2;
}
blockAt(t2, e2, i2, s) {
return new Gt(s, this.length, i2, this.height, this.deco || 0);
}
lineAt(t2, e2, i2, s, r2) {
return this.blockAt(0, i2, s, r2);
}
forEachLine(t2, e2, i2, s, r2, o) {
t2 <= r2 + this.length && e2 >= r2 && o(this.blockAt(0, i2, s, r2));
}
updateHeight(t2, e2 = 0, i2 = false, s) {
return s && s.from <= e2 && s.more && this.setHeight(t2, s.heights[s.index++]), this.outdated = false, this;
}
toString() {
return `block(${this.length})`;
}
}
class xt extends oh {
constructor(t2, e2) {
super(t2, e2, null), this.collapsed = 0, this.widgetHeight = 0, this.breaks = 0;
}
blockAt(t2, e2, i2, s) {
return new Gt(s, this.length, i2, this.height, this.breaks);
}
replace(t2, e2, i2) {
let s = i2[0];
return i2.length == 1 && (s instanceof xt || s instanceof rt && s.flags & 4) && Math.abs(this.length - s.length) < 10 ? (s instanceof rt ? s = new xt(s.length, this.height) : s.height = this.height, this.outdated || (s.outdated = false), s) : pt.of(i2);
}
updateHeight(t2, e2 = 0, i2 = false, s) {
return s && s.from <= e2 && s.more ? this.setHeight(t2, s.heights[s.index++]) : (i2 || this.outdated) && this.setHeight(t2, Math.max(this.widgetHeight, t2.heightForLine(this.length - this.collapsed)) + this.breaks * t2.lineHeight), this.outdated = false, this;
}
toString() {
return `line(${this.length}${this.collapsed ? -this.collapsed : ""}${this.widgetHeight ? ":" + this.widgetHeight : ""})`;
}
}
class rt extends pt {
constructor(t2) {
super(t2, 0);
}
heightMetrics(t2, e2) {
let i2 = t2.doc.lineAt(e2).number, s = t2.doc.lineAt(e2 + this.length).number, r2 = s - i2 + 1, o, l = 0;
if (t2.lineWrapping) {
let h2 = Math.min(this.height, t2.lineHeight * r2);
o = h2 / r2, this.length > r2 + 1 && (l = (this.height - h2) / (this.length - r2 - 1));
} else
o = this.height / r2;
return { firstLine: i2, lastLine: s, perLine: o, perChar: l };
}
blockAt(t2, e2, i2, s) {
let { firstLine: r2, lastLine: o, perLine: l, perChar: h2 } = this.heightMetrics(e2, s);
if (e2.lineWrapping) {
let a2 = s + Math.round(Math.max(0, Math.min(1, (t2 - i2) / this.height)) * this.length), c2 = e2.doc.lineAt(a2), f2 = l + c2.length * h2, u2 = Math.max(i2, t2 - f2 / 2);
return new Gt(c2.from, c2.length, u2, f2, 0);
} else {
let a2 = Math.max(0, Math.min(o - r2, Math.floor((t2 - i2) / l))), { from: c2, length: f2 } = e2.doc.line(r2 + a2);
return new Gt(c2, f2, i2 + l * a2, l, 0);
}
}
lineAt(t2, e2, i2, s, r2) {
if (e2 == j$1.ByHeight)
return this.blockAt(t2, i2, s, r2);
if (e2 == j$1.ByPosNoHeight) {
let { from: d2, to: p2 } = i2.doc.lineAt(t2);
return new Gt(d2, p2 - d2, 0, 0, 0);
}
let { firstLine: o, perLine: l, perChar: h2 } = this.heightMetrics(i2, r2), a2 = i2.doc.lineAt(t2), c2 = l + a2.length * h2, f2 = a2.number - o, u2 = s + l * f2 + h2 * (a2.from - r2 - f2);
return new Gt(a2.from, a2.length, Math.max(s, Math.min(u2, s + this.height - c2)), c2, 0);
}
forEachLine(t2, e2, i2, s, r2, o) {
t2 = Math.max(t2, r2), e2 = Math.min(e2, r2 + this.length);
let { firstLine: l, perLine: h2, perChar: a2 } = this.heightMetrics(i2, r2);
for (let c2 = t2, f2 = s; c2 <= e2; ) {
let u2 = i2.doc.lineAt(c2);
if (c2 == t2) {
let p2 = u2.number - l;
f2 += h2 * p2 + a2 * (t2 - r2 - p2);
}
let d2 = h2 + a2 * u2.length;
o(new Gt(u2.from, u2.length, f2, d2, 0)), f2 += d2, c2 = u2.to + 1;
}
}
replace(t2, e2, i2) {
let s = this.length - e2;
if (s > 0) {
let r2 = i2[i2.length - 1];
r2 instanceof rt ? i2[i2.length - 1] = new rt(r2.length + s) : i2.push(null, new rt(s - 1));
}
if (t2 > 0) {
let r2 = i2[0];
r2 instanceof rt ? i2[0] = new rt(t2 + r2.length) : i2.unshift(new rt(t2 - 1), null);
}
return pt.of(i2);
}
decomposeLeft(t2, e2) {
e2.push(new rt(t2 - 1), null);
}
decomposeRight(t2, e2) {
e2.push(null, new rt(this.length - t2 - 1));
}
updateHeight(t2, e2 = 0, i2 = false, s) {
let r2 = e2 + this.length;
if (s && s.from <= e2 + this.length && s.more) {
let o = [], l = Math.max(e2, s.from), h2 = -1;
for (s.from > e2 && o.push(new rt(s.from - e2 - 1).updateHeight(t2, e2)); l <= r2 && s.more; ) {
let c2 = t2.doc.lineAt(l).length;
o.length && o.push(null);
let f2 = s.heights[s.index++];
h2 == -1 ? h2 = f2 : Math.abs(f2 - h2) >= is && (h2 = -2);
let u2 = new xt(c2, f2);
u2.outdated = false, o.push(u2), l += c2 + 1;
}
l <= r2 && o.push(null, new rt(r2 - l).updateHeight(t2, l));
let a2 = pt.of(o);
return (h2 < 0 || Math.abs(a2.height - this.height) >= is || Math.abs(h2 - this.heightMetrics(t2, e2).perLine) >= is) && (t2.heightChanged = true), a2;
} else
(i2 || this.outdated) && (this.setHeight(t2, t2.heightForGap(e2, e2 + this.length)), this.outdated = false);
return this;
}
toString() {
return `gap(${this.length})`;
}
}
class ou extends pt {
constructor(t2, e2, i2) {
super(t2.length + e2 + i2.length, t2.height + i2.height, e2 | (t2.outdated || i2.outdated ? 2 : 0)), this.left = t2, this.right = i2, this.size = t2.size + i2.size;
}
get break() {
return this.flags & 1;
}
blockAt(t2, e2, i2, s) {
let r2 = i2 + this.left.height;
return t2 < r2 ? this.left.blockAt(t2, e2, i2, s) : this.right.blockAt(t2, e2, r2, s + this.left.length + this.break);
}
lineAt(t2, e2, i2, s, r2) {
let o = s + this.left.height, l = r2 + this.left.length + this.break, h2 = e2 == j$1.ByHeight ? t2 < o : t2 < l, a2 = h2 ? this.left.lineAt(t2, e2, i2, s, r2) : this.right.lineAt(t2, e2, i2, o, l);
if (this.break || (h2 ? a2.to < l : a2.from > l))
return a2;
let c2 = e2 == j$1.ByPosNoHeight ? j$1.ByPosNoHeight : j$1.ByPos;
return h2 ? a2.join(this.right.lineAt(l, c2, i2, o, l)) : this.left.lineAt(l, c2, i2, s, r2).join(a2);
}
forEachLine(t2, e2, i2, s, r2, o) {
let l = s + this.left.height, h2 = r2 + this.left.length + this.break;
if (this.break)
t2 < h2 && this.left.forEachLine(t2, e2, i2, s, r2, o), e2 >= h2 && this.right.forEachLine(t2, e2, i2, l, h2, o);
else {
let a2 = this.lineAt(h2, j$1.ByPos, i2, s, r2);
t2 < a2.from && this.left.forEachLine(t2, a2.from - 1, i2, s, r2, o), a2.to >= t2 && a2.from <= e2 && o(a2), e2 > a2.to && this.right.forEachLine(a2.to + 1, e2, i2, l, h2, o);
}
}
replace(t2, e2, i2) {
let s = this.left.length + this.break;
if (e2 < s)
return this.balanced(this.left.replace(t2, e2, i2), this.right);
if (t2 > this.left.length)
return this.balanced(this.left, this.right.replace(t2 - s, e2 - s, i2));
let r2 = [];
t2 > 0 && this.decomposeLeft(t2, r2);
let o = r2.length;
for (let l of i2)
r2.push(l);
if (t2 > 0 && io(r2, o - 1), e2 < this.length) {
let l = r2.length;
this.decomposeRight(e2, r2), io(r2, l);
}
return pt.of(r2);
}
decomposeLeft(t2, e2) {
let i2 = this.left.length;
if (t2 <= i2)
return this.left.decomposeLeft(t2, e2);
e2.push(this.left), this.break && (i2++, t2 >= i2 && e2.push(null)), t2 > i2 && this.right.decomposeLeft(t2 - i2, e2);
}
decomposeRight(t2, e2) {
let i2 = this.left.length, s = i2 + this.break;
if (t2 >= s)
return this.right.decomposeRight(t2 - s, e2);
t2 < i2 && this.left.decomposeRight(t2, e2), this.break && t2 < s && e2.push(null), e2.push(this.right);
}
balanced(t2, e2) {
return t2.size > 2 * e2.size || e2.size > 2 * t2.size ? pt.of(this.break ? [t2, null, e2] : [t2, e2]) : (this.left = t2, this.right = e2, this.height = t2.height + e2.height, this.outdated = t2.outdated || e2.outdated, this.size = t2.size + e2.size, this.length = t2.length + this.break + e2.length, this);
}
updateHeight(t2, e2 = 0, i2 = false, s) {
let { left: r2, right: o } = this, l = e2 + r2.length + this.break, h2 = null;
return s && s.from <= e2 + r2.length && s.more ? h2 = r2 = r2.updateHeight(t2, e2, i2, s) : r2.updateHeight(t2, e2, i2), s && s.from <= l + o.length && s.more ? h2 = o = o.updateHeight(t2, l, i2, s) : o.updateHeight(t2, l, i2), h2 ? this.balanced(r2, o) : (this.height = this.left.height + this.right.height, this.outdated = false, this);
}
toString() {
return this.left + (this.break ? " " : "-") + this.right;
}
}
function io(n2, t2) {
let e2, i2;
n2[t2] == null && (e2 = n2[t2 - 1]) instanceof rt && (i2 = n2[t2 + 1]) instanceof rt && n2.splice(t2 - 1, 3, new rt(e2.length + 1 + i2.length));
}
const lu = 5;
class sr {
constructor(t2, e2) {
this.pos = t2, this.oracle = e2, this.nodes = [], this.lineStart = -1, this.lineEnd = -1, this.covering = null, this.writtenTo = t2;
}
get isCovered() {
return this.covering && this.nodes[this.nodes.length - 1] == this.covering;
}
span(t2, e2) {
if (this.lineStart > -1) {
let i2 = Math.min(e2, this.lineEnd), s = this.nodes[this.nodes.length - 1];
s instanceof xt ? s.length += i2 - this.pos : (i2 > this.pos || !this.isCovered) && this.nodes.push(new xt(i2 - this.pos, -1)), this.writtenTo = i2, e2 > i2 && (this.nodes.push(null), this.writtenTo++, this.lineStart = -1);
}
this.pos = e2;
}
point(t2, e2, i2) {
if (t2 < e2 || i2.heightRelevant) {
let s = i2.widget ? i2.widget.estimatedHeight : 0, r2 = i2.widget ? i2.widget.lineBreaks : 0;
s < 0 && (s = this.oracle.lineHeight);
let o = e2 - t2;
i2.block ? this.addBlock(new oh(o, s, i2)) : (o || r2 || s >= lu) && this.addLineDeco(s, r2, o);
} else
e2 > t2 && this.span(t2, e2);
this.lineEnd > -1 && this.lineEnd < this.pos && (this.lineEnd = this.oracle.doc.lineAt(this.pos).to);
}
enterLine() {
if (this.lineStart > -1)
return;
let { from: t2, to: e2 } = this.oracle.doc.lineAt(this.pos);
this.lineStart = t2, this.lineEnd = e2, this.writtenTo < t2 && ((this.writtenTo < t2 - 1 || this.nodes[this.nodes.length - 1] == null) && this.nodes.push(this.blankContent(this.writtenTo, t2 - 1)), this.nodes.push(null)), this.pos > t2 && this.nodes.push(new xt(this.pos - t2, -1)), this.writtenTo = this.pos;
}
blankContent(t2, e2) {
let i2 = new rt(e2 - t2);
return this.oracle.doc.lineAt(t2).to == e2 && (i2.flags |= 4), i2;
}
ensureLine() {
this.enterLine();
let t2 = this.nodes.length ? this.nodes[this.nodes.length - 1] : null;
if (t2 instanceof xt)
return t2;
let e2 = new xt(0, -1);
return this.nodes.push(e2), e2;
}
addBlock(t2) {
this.enterLine();
let e2 = t2.deco;
e2 && e2.startSide > 0 && !this.isCovered && this.ensureLine(), this.nodes.push(t2), this.writtenTo = this.pos = this.pos + t2.length, e2 && e2.endSide > 0 && (this.covering = t2);
}
addLineDeco(t2, e2, i2) {
let s = this.ensureLine();
s.length += i2, s.collapsed += i2, s.widgetHeight = Math.max(s.widgetHeight, t2), s.breaks += e2, this.writtenTo = this.pos = this.pos + i2;
}
finish(t2) {
let e2 = this.nodes.length == 0 ? null : this.nodes[this.nodes.length - 1];
this.lineStart > -1 && !(e2 instanceof xt) && !this.isCovered ? this.nodes.push(new xt(0, -1)) : (this.writtenTo < this.pos || e2 == null) && this.nodes.push(this.blankContent(this.writtenTo, this.pos));
let i2 = t2;
for (let s of this.nodes)
s instanceof xt && s.updateHeight(this.oracle, i2), i2 += s ? s.length : 1;
return this.nodes;
}
// Always called with a region that on both sides either stretches
// to a line break or the end of the document.
// The returned array uses null to indicate line breaks, but never
// starts or ends in a line break, or has multiple line breaks next
// to each other.
static build(t2, e2, i2, s) {
let r2 = new sr(i2, t2);
return F.spans(e2, i2, s, r2, 0), r2.finish(i2);
}
}
function hu(n2, t2, e2) {
let i2 = new au();
return F.compare(n2, t2, e2, i2, 0), i2.changes;
}
class au {
constructor() {
this.changes = [];
}
compareRange() {
}
comparePoint(t2, e2, i2, s) {
(t2 < e2 || i2 && i2.heightRelevant || s && s.heightRelevant) && Sn(t2, e2, this.changes, 5);
}
}
function cu(n2, t2) {
let e2 = n2.getBoundingClientRect(), i2 = n2.ownerDocument, s = i2.defaultView || window, r2 = Math.max(0, e2.left), o = Math.min(s.innerWidth, e2.right), l = Math.max(0, e2.top), h2 = Math.min(s.innerHeight, e2.bottom);
for (let a2 = n2.parentNode; a2 && a2 != i2.body; )
if (a2.nodeType == 1) {
let c2 = a2, f2 = window.getComputedStyle(c2);
if ((c2.scrollHeight > c2.clientHeight || c2.scrollWidth > c2.clientWidth) && f2.overflow != "visible") {
let u2 = c2.getBoundingClientRect();
r2 = Math.max(r2, u2.left), o = Math.min(o, u2.right), l = Math.max(l, u2.top), h2 = a2 == n2.parentNode ? u2.bottom : Math.min(h2, u2.bottom);
}
a2 = f2.position == "absolute" || f2.position == "fixed" ? c2.offsetParent : c2.parentNode;
} else if (a2.nodeType == 11)
a2 = a2.host;
else
break;
return {
left: r2 - e2.left,
right: Math.max(r2, o) - e2.left,
top: l - (e2.top + t2),
bottom: Math.max(l, h2) - (e2.top + t2)
};
}
function fu(n2, t2) {
let e2 = n2.getBoundingClientRect();
return {
left: 0,
right: e2.right - e2.left,
top: t2,
bottom: e2.bottom - (e2.top + t2)
};
}
class js {
constructor(t2, e2, i2) {
this.from = t2, this.to = e2, this.size = i2;
}
static same(t2, e2) {
if (t2.length != e2.length)
return false;
for (let i2 = 0; i2 < t2.length; i2++) {
let s = t2[i2], r2 = e2[i2];
if (s.from != r2.from || s.to != r2.to || s.size != r2.size)
return false;
}
return true;
}
draw(t2, e2) {
return N$2.replace({
widget: new uu(this.size * (e2 ? t2.scaleY : t2.scaleX), e2)
}).range(this.from, this.to);
}
}
class uu extends Se {
constructor(t2, e2) {
super(), this.size = t2, this.vertical = e2;
}
eq(t2) {
return t2.size == this.size && t2.vertical == this.vertical;
}
toDOM() {
let t2 = document.createElement("div");
return this.vertical ? t2.style.height = this.size + "px" : (t2.style.width = this.size + "px", t2.style.height = "2px", t2.style.display = "inline-block"), t2;
}
get estimatedHeight() {
return this.vertical ? this.size : -1;
}
}
class so {
constructor(t2) {
this.state = t2, this.pixelViewport = { left: 0, right: window.innerWidth, top: 0, bottom: 0 }, this.inView = true, this.paddingTop = 0, this.paddingBottom = 0, this.contentDOMWidth = 0, this.contentDOMHeight = 0, this.editorHeight = 0, this.editorWidth = 0, this.scrollTop = 0, this.scrolledToBottom = true, this.scaleX = 1, this.scaleY = 1, this.scrollAnchorPos = 0, this.scrollAnchorHeight = -1, this.scaler = no, this.scrollTarget = null, this.printing = false, this.mustMeasureContent = true, this.defaultTextDirection = tt.LTR, this.visibleRanges = [], this.mustEnforceCursorAssoc = false;
let e2 = t2.facet(er).some((i2) => typeof i2 != "function" && i2.class == "cm-lineWrapping");
this.heightOracle = new nu(e2), this.stateDeco = t2.facet(xi).filter((i2) => typeof i2 != "function"), this.heightMap = pt.empty().applyChanges(this.stateDeco, V.empty, this.heightOracle.setDoc(t2.doc), [new Mt(0, 0, 0, t2.doc.length)]), this.viewport = this.getViewport(0, null), this.updateViewportLines(), this.updateForViewport(), this.lineGaps = this.ensureLineGaps([]), this.lineGapDeco = N$2.set(this.lineGaps.map((i2) => i2.draw(this, false))), this.computeVisibleRanges();
}
updateForViewport() {
let t2 = [this.viewport], { main: e2 } = this.state.selection;
for (let i2 = 0; i2 <= 1; i2++) {
let s = i2 ? e2.head : e2.anchor;
if (!t2.some(({ from: r2, to: o }) => s >= r2 && s <= o)) {
let { from: r2, to: o } = this.lineBlockAt(s);
t2.push(new $i(r2, o));
}
}
this.viewports = t2.sort((i2, s) => i2.from - s.from), this.scaler = this.heightMap.height <= 7e6 ? no : new gu(this.heightOracle, this.heightMap, this.viewports);
}
updateViewportLines() {
this.viewportLines = [], this.heightMap.forEachLine(this.viewport.from, this.viewport.to, this.heightOracle.setDoc(this.state.doc), 0, 0, (t2) => {
this.viewportLines.push(this.scaler.scale == 1 ? t2 : ci(t2, this.scaler));
});
}
update(t2, e2 = null) {
this.state = t2.state;
let i2 = this.stateDeco;
this.stateDeco = this.state.facet(xi).filter((c2) => typeof c2 != "function");
let s = t2.changedRanges, r2 = Mt.extendWithRanges(s, hu(i2, this.stateDeco, t2 ? t2.changes : it.empty(this.state.doc.length))), o = this.heightMap.height, l = this.scrolledToBottom ? null : this.scrollAnchorAt(this.scrollTop);
this.heightMap = this.heightMap.applyChanges(this.stateDeco, t2.startState.doc, this.heightOracle.setDoc(this.state.doc), r2), this.heightMap.height != o && (t2.flags |= 2), l ? (this.scrollAnchorPos = t2.changes.mapPos(l.from, -1), this.scrollAnchorHeight = l.top) : (this.scrollAnchorPos = -1, this.scrollAnchorHeight = this.heightMap.height);
let h2 = r2.length ? this.mapViewport(this.viewport, t2.changes) : this.viewport;
(e2 && (e2.range.head < h2.from || e2.range.head > h2.to) || !this.viewportIsAppropriate(h2)) && (h2 = this.getViewport(0, e2));
let a2 = !t2.changes.empty || t2.flags & 2 || h2.from != this.viewport.from || h2.to != this.viewport.to;
this.viewport = h2, this.updateForViewport(), a2 && this.updateViewportLines(), (this.lineGaps.length || this.viewport.to - this.viewport.from > 4e3) && this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps, t2.changes))), t2.flags |= this.computeVisibleRanges(), e2 && (this.scrollTarget = e2), !this.mustEnforceCursorAssoc && t2.selectionSet && t2.view.lineWrapping && t2.state.selection.main.empty && t2.state.selection.main.assoc && !t2.state.facet(pf) && (this.mustEnforceCursorAssoc = true);
}
measure(t2) {
let e2 = t2.contentDOM, i2 = window.getComputedStyle(e2), s = this.heightOracle, r2 = i2.whiteSpace;
this.defaultTextDirection = i2.direction == "rtl" ? tt.RTL : tt.LTR;
let o = this.heightOracle.mustRefreshForWrapping(r2), l = e2.getBoundingClientRect(), h2 = o || this.mustMeasureContent || this.contentDOMHeight != l.height;
this.contentDOMHeight = l.height, this.mustMeasureContent = false;
let a2 = 0, c2 = 0;
if (l.width && l.height) {
let v2 = l.width / e2.offsetWidth, A2 = l.height / e2.offsetHeight;
(v2 > 0.995 && v2 < 1.005 || !isFinite(v2) || Math.abs(l.width - e2.offsetWidth) < 1) && (v2 = 1), (A2 > 0.995 && A2 < 1.005 || !isFinite(A2) || Math.abs(l.height - e2.offsetHeight) < 1) && (A2 = 1), (this.scaleX != v2 || this.scaleY != A2) && (this.scaleX = v2, this.scaleY = A2, a2 |= 8, o = h2 = true);
}
let f2 = (parseInt(i2.paddingTop) || 0) * this.scaleY, u2 = (parseInt(i2.paddingBottom) || 0) * this.scaleY;
(this.paddingTop != f2 || this.paddingBottom != u2) && (this.paddingTop = f2, this.paddingBottom = u2, a2 |= 10), this.editorWidth != t2.scrollDOM.clientWidth && (s.lineWrapping && (h2 = true), this.editorWidth = t2.scrollDOM.clientWidth, a2 |= 8);
let d2 = t2.scrollDOM.scrollTop * this.scaleY;
this.scrollTop != d2 && (this.scrollAnchorHeight = -1, this.scrollTop = d2), this.scrolledToBottom = vl(t2.scrollDOM);
let p2 = (this.printing ? fu : cu)(e2, this.paddingTop), m = p2.top - this.pixelViewport.top, g = p2.bottom - this.pixelViewport.bottom;
this.pixelViewport = p2;
let y2 = this.pixelViewport.bottom > this.pixelViewport.top && this.pixelViewport.right > this.pixelViewport.left;
if (y2 != this.inView && (this.inView = y2, y2 && (h2 = true)), !this.inView && !this.scrollTarget)
return 0;
let x2 = l.width;
if ((this.contentDOMWidth != x2 || this.editorHeight != t2.scrollDOM.clientHeight) && (this.contentDOMWidth = l.width, this.editorHeight = t2.scrollDOM.clientHeight, a2 |= 8), h2) {
let v2 = t2.docView.measureVisibleLineHeights(this.viewport);
if (s.mustRefreshForHeights(v2) && (o = true), o || s.lineWrapping && Math.abs(x2 - this.contentDOMWidth) > s.charWidth) {
let { lineHeight: A2, charWidth: P2, textHeight: M2 } = t2.docView.measureTextSize();
o = A2 > 0 && s.refresh(r2, A2, P2, M2, x2 / P2, v2), o && (t2.docView.minWidth = 0, a2 |= 8);
}
m > 0 && g > 0 ? c2 = Math.max(m, g) : m < 0 && g < 0 && (c2 = Math.min(m, g)), s.heightChanged = false;
for (let A2 of this.viewports) {
let P2 = A2.from == this.viewport.from ? v2 : t2.docView.measureVisibleLineHeights(A2);
this.heightMap = (o ? pt.empty().applyChanges(this.stateDeco, V.empty, this.heightOracle, [new Mt(0, 0, 0, t2.state.doc.length)]) : this.heightMap).updateHeight(s, 0, o, new ru(A2.from, P2));
}
s.heightChanged && (a2 |= 2);
}
let S2 = !this.viewportIsAppropriate(this.viewport, c2) || this.scrollTarget && (this.scrollTarget.range.head < this.viewport.from || this.scrollTarget.range.head > this.viewport.to);
return S2 && (this.viewport = this.getViewport(c2, this.scrollTarget)), this.updateForViewport(), (a2 & 2 || S2) && this.updateViewportLines(), (this.lineGaps.length || this.viewport.to - this.viewport.from > 4e3) && this.updateLineGaps(this.ensureLineGaps(o ? [] : this.lineGaps, t2)), a2 |= this.computeVisibleRanges(), this.mustEnforceCursorAssoc && (this.mustEnforceCursorAssoc = false, t2.docView.enforceCursorAssoc()), a2;
}
get visibleTop() {
return this.scaler.fromDOM(this.pixelViewport.top);
}
get visibleBottom() {
return this.scaler.fromDOM(this.pixelViewport.bottom);
}
getViewport(t2, e2) {
let i2 = 0.5 - Math.max(-0.5, Math.min(0.5, t2 / 1e3 / 2)), s = this.heightMap, r2 = this.heightOracle, { visibleTop: o, visibleBottom: l } = this, h2 = new $i(s.lineAt(o - i2 * 1e3, j$1.ByHeight, r2, 0, 0).from, s.lineAt(l + (1 - i2) * 1e3, j$1.ByHeight, r2, 0, 0).to);
if (e2) {
let { head: a2 } = e2.range;
if (a2 < h2.from || a2 > h2.to) {
let c2 = Math.min(this.editorHeight, this.pixelViewport.bottom - this.pixelViewport.top), f2 = s.lineAt(a2, j$1.ByPos, r2, 0, 0), u2;
e2.y == "center" ? u2 = (f2.top + f2.bottom) / 2 - c2 / 2 : e2.y == "start" || e2.y == "nearest" && a2 < h2.from ? u2 = f2.top : u2 = f2.bottom - c2, h2 = new $i(s.lineAt(u2 - 1e3 / 2, j$1.ByHeight, r2, 0, 0).from, s.lineAt(u2 + c2 + 1e3 / 2, j$1.ByHeight, r2, 0, 0).to);
}
}
return h2;
}
mapViewport(t2, e2) {
let i2 = e2.mapPos(t2.from, -1), s = e2.mapPos(t2.to, 1);
return new $i(this.heightMap.lineAt(i2, j$1.ByPos, this.heightOracle, 0, 0).from, this.heightMap.lineAt(s, j$1.ByPos, this.heightOracle, 0, 0).to);
}
// Checks if a given viewport covers the visible part of the
// document and not too much beyond that.
viewportIsAppropriate({ from: t2, to: e2 }, i2 = 0) {
if (!this.inView)
return true;
let { top: s } = this.heightMap.lineAt(t2, j$1.ByPos, this.heightOracle, 0, 0), { bottom: r2 } = this.heightMap.lineAt(e2, j$1.ByPos, this.heightOracle, 0, 0), { visibleTop: o, visibleBottom: l } = this;
return (t2 == 0 || s <= o - Math.max(10, Math.min(
-i2,
250
/* VP.MaxCoverMargin */
))) && (e2 == this.state.doc.length || r2 >= l + Math.max(10, Math.min(
i2,
250
/* VP.MaxCoverMargin */
))) && s > o - 2 * 1e3 && r2 < l + 2 * 1e3;
}
mapLineGaps(t2, e2) {
if (!t2.length || e2.empty)
return t2;
let i2 = [];
for (let s of t2)
e2.touchesRange(s.from, s.to) || i2.push(new js(e2.mapPos(s.from), e2.mapPos(s.to), s.size));
return i2;
}
// Computes positions in the viewport where the start or end of a
// line should be hidden, trying to reuse existing line gaps when
// appropriate to avoid unneccesary redraws.
// Uses crude character-counting for the positioning and sizing,
// since actual DOM coordinates aren't always available and
// predictable. Relies on generous margins (see LG.Margin) to hide
// the artifacts this might produce from the user.
ensureLineGaps(t2, e2) {
let i2 = this.heightOracle.lineWrapping, s = i2 ? 1e4 : 2e3, r2 = s >> 1, o = s << 1;
if (this.defaultTextDirection != tt.LTR && !i2)
return [];
let l = [], h2 = (a2, c2, f2, u2) => {
if (c2 - a2 < r2)
return;
let d2 = this.state.selection.main, p2 = [d2.from];
d2.empty || p2.push(d2.to);
for (let g of p2)
if (g > a2 && g < c2) {
h2(a2, g - 10, f2, u2), h2(g + 10, c2, f2, u2);
return;
}
let m = pu(t2, (g) => g.from >= f2.from && g.to <= f2.to && Math.abs(g.from - a2) < r2 && Math.abs(g.to - c2) < r2 && !p2.some((y2) => g.from < y2 && g.to > y2));
if (!m) {
if (c2 < f2.to && e2 && i2 && e2.visibleRanges.some((g) => g.from <= c2 && g.to >= c2)) {
let g = e2.moveToLineBoundary(b$1.cursor(c2), false, true).head;
g > a2 && (c2 = g);
}
m = new js(a2, c2, this.gapSize(f2, a2, c2, u2));
}
l.push(m);
};
for (let a2 of this.viewportLines) {
if (a2.length < o)
continue;
let c2 = du(a2.from, a2.to, this.stateDeco);
if (c2.total < o)
continue;
let f2 = this.scrollTarget ? this.scrollTarget.range.head : null, u2, d2;
if (i2) {
let p2 = s / this.heightOracle.lineLength * this.heightOracle.lineHeight, m, g;
if (f2 != null) {
let y2 = _i(c2, f2), x2 = ((this.visibleBottom - this.visibleTop) / 2 + p2) / a2.height;
m = y2 - x2, g = y2 + x2;
} else
m = (this.visibleTop - a2.top - p2) / a2.height, g = (this.visibleBottom - a2.top + p2) / a2.height;
u2 = Fi(c2, m), d2 = Fi(c2, g);
} else {
let p2 = c2.total * this.heightOracle.charWidth, m = s * this.heightOracle.charWidth, g, y2;
if (f2 != null) {
let x2 = _i(c2, f2), S2 = ((this.pixelViewport.right - this.pixelViewport.left) / 2 + m) / p2;
g = x2 - S2, y2 = x2 + S2;
} else
g = (this.pixelViewport.left - m) / p2, y2 = (this.pixelViewport.right + m) / p2;
u2 = Fi(c2, g), d2 = Fi(c2, y2);
}
u2 > a2.from && h2(a2.from, u2, a2, c2), d2 < a2.to && h2(d2, a2.to, a2, c2);
}
return l;
}
gapSize(t2, e2, i2, s) {
let r2 = _i(s, i2) - _i(s, e2);
return this.heightOracle.lineWrapping ? t2.height * r2 : s.total * this.heightOracle.charWidth * r2;
}
updateLineGaps(t2) {
js.same(t2, this.lineGaps) || (this.lineGaps = t2, this.lineGapDeco = N$2.set(t2.map((e2) => e2.draw(this, this.heightOracle.lineWrapping))));
}
computeVisibleRanges() {
let t2 = this.stateDeco;
this.lineGaps.length && (t2 = t2.concat(this.lineGapDeco));
let e2 = [];
F.spans(t2, this.viewport.from, this.viewport.to, {
span(s, r2) {
e2.push({ from: s, to: r2 });
},
point() {
}
}, 20);
let i2 = e2.length != this.visibleRanges.length || this.visibleRanges.some((s, r2) => s.from != e2[r2].from || s.to != e2[r2].to);
return this.visibleRanges = e2, i2 ? 4 : 0;
}
lineBlockAt(t2) {
return t2 >= this.viewport.from && t2 <= this.viewport.to && this.viewportLines.find((e2) => e2.from <= t2 && e2.to >= t2) || ci(this.heightMap.lineAt(t2, j$1.ByPos, this.heightOracle, 0, 0), this.scaler);
}
lineBlockAtHeight(t2) {
return ci(this.heightMap.lineAt(this.scaler.fromDOM(t2), j$1.ByHeight, this.heightOracle, 0, 0), this.scaler);
}
scrollAnchorAt(t2) {
let e2 = this.lineBlockAtHeight(t2 + 8);
return e2.from >= this.viewport.from || this.viewportLines[0].top - t2 > 200 ? e2 : this.viewportLines[0];
}
elementAtHeight(t2) {
return ci(this.heightMap.blockAt(this.scaler.fromDOM(t2), this.heightOracle, 0, 0), this.scaler);
}
get docHeight() {
return this.scaler.toDOM(this.heightMap.height);
}
get contentHeight() {
return this.docHeight + this.paddingTop + this.paddingBottom;
}
}
class $i {
constructor(t2, e2) {
this.from = t2, this.to = e2;
}
}
function du(n2, t2, e2) {
let i2 = [], s = n2, r2 = 0;
return F.spans(e2, n2, t2, {
span() {
},
point(o, l) {
o > s && (i2.push({ from: s, to: o }), r2 += o - s), s = l;
}
}, 20), s < t2 && (i2.push({ from: s, to: t2 }), r2 += t2 - s), { total: r2, ranges: i2 };
}
function Fi({ total: n2, ranges: t2 }, e2) {
if (e2 <= 0)
return t2[0].from;
if (e2 >= 1)
return t2[t2.length - 1].to;
let i2 = Math.floor(n2 * e2);
for (let s = 0; ; s++) {
let { from: r2, to: o } = t2[s], l = o - r2;
if (i2 <= l)
return r2 + i2;
i2 -= l;
}
}
function _i(n2, t2) {
let e2 = 0;
for (let { from: i2, to: s } of n2.ranges) {
if (t2 <= s) {
e2 += t2 - i2;
break;
}
e2 += s - i2;
}
return e2 / n2.total;
}
function pu(n2, t2) {
for (let e2 of n2)
if (t2(e2))
return e2;
}
const no = {
toDOM(n2) {
return n2;
},
fromDOM(n2) {
return n2;
},
scale: 1
};
class gu {
constructor(t2, e2, i2) {
let s = 0, r2 = 0, o = 0;
this.viewports = i2.map(({ from: l, to: h2 }) => {
let a2 = e2.lineAt(l, j$1.ByPos, t2, 0, 0).top, c2 = e2.lineAt(h2, j$1.ByPos, t2, 0, 0).bottom;
return s += c2 - a2, { from: l, to: h2, top: a2, bottom: c2, domTop: 0, domBottom: 0 };
}), this.scale = (7e6 - s) / (e2.height - s);
for (let l of this.viewports)
l.domTop = o + (l.top - r2) * this.scale, o = l.domBottom = l.domTop + (l.bottom - l.top), r2 = l.bottom;
}
toDOM(t2) {
for (let e2 = 0, i2 = 0, s = 0; ; e2++) {
let r2 = e2 < this.viewports.length ? this.viewports[e2] : null;
if (!r2 || t2 < r2.top)
return s + (t2 - i2) * this.scale;
if (t2 <= r2.bottom)
return r2.domTop + (t2 - r2.top);
i2 = r2.bottom, s = r2.domBottom;
}
}
fromDOM(t2) {
for (let e2 = 0, i2 = 0, s = 0; ; e2++) {
let r2 = e2 < this.viewports.length ? this.viewports[e2] : null;
if (!r2 || t2 < r2.domTop)
return i2 + (t2 - s) / this.scale;
if (t2 <= r2.domBottom)
return r2.top + (t2 - r2.domTop);
i2 = r2.bottom, s = r2.domBottom;
}
}
}
function ci(n2, t2) {
if (t2.scale == 1)
return n2;
let e2 = t2.toDOM(n2.top), i2 = t2.toDOM(n2.bottom);
return new Gt(n2.from, n2.length, e2, i2 - e2, Array.isArray(n2._content) ? n2._content.map((s) => ci(s, t2)) : n2._content);
}
const zi = /* @__PURE__ */ O$3.define({ combine: (n2) => n2.join(" ") }), Pn = /* @__PURE__ */ O$3.define({ combine: (n2) => n2.indexOf(true) > -1 }), Bn = /* @__PURE__ */ we.newName(), lh = /* @__PURE__ */ we.newName(), hh = /* @__PURE__ */ we.newName(), ah = { "&light": "." + lh, "&dark": "." + hh };
function Rn(n2, t2, e2) {
return new we(t2, {
finish(i2) {
return /&/.test(i2) ? i2.replace(/&\w*/, (s) => {
if (s == "&")
return n2;
if (!e2 || !e2[s])
throw new RangeError(`Unsupported selector: ${s}`);
return e2[s];
}) : n2 + " " + i2;
}
});
}
const mu = /* @__PURE__ */ Rn("." + Bn, {
"&": {
position: "relative !important",
boxSizing: "border-box",
"&.cm-focused": {
// Provide a simple default outline to make sure a focused
// editor is visually distinct. Can't leave the default behavior
// because that will apply to the content element, which is
// inside the scrollable container and doesn't include the
// gutters. We also can't use an 'auto' outline, since those
// are, for some reason, drawn behind the element content, which
// will cause things like the active line background to cover
// the outline (#297).
outline: "1px dotted #212121"
},
display: "flex !important",
flexDirection: "column"
},
".cm-scroller": {
display: "flex !important",
alignItems: "flex-start !important",
fontFamily: "monospace",
lineHeight: 1.4,
height: "100%",
overflowX: "auto",
position: "relative",
zIndex: 0
},
".cm-content": {
margin: 0,
flexGrow: 2,
flexShrink: 0,
display: "block",
whiteSpace: "pre",
wordWrap: "normal",
boxSizing: "border-box",
minHeight: "100%",
padding: "4px 0",
outline: "none",
"&[contenteditable=true]": {
WebkitUserModify: "read-write-plaintext-only"
}
},
".cm-lineWrapping": {
whiteSpace_fallback: "pre-wrap",
whiteSpace: "break-spaces",
wordBreak: "break-word",
overflowWrap: "anywhere",
flexShrink: 1
},
"&light .cm-content": { caretColor: "black" },
"&dark .cm-content": { caretColor: "white" },
".cm-line": {
display: "block",
padding: "0 2px 0 6px"
},
".cm-layer": {
position: "absolute",
left: 0,
top: 0,
contain: "size style",
"& > *": {
position: "absolute"
}
},
"&light .cm-selectionBackground": {
background: "#d9d9d9"
},
"&dark .cm-selectionBackground": {
background: "#222"
},
"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground": {
background: "#d7d4f0"
},
"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground": {
background: "#233"
},
".cm-cursorLayer": {
pointerEvents: "none"
},
"&.cm-focused > .cm-scroller > .cm-cursorLayer": {
animation: "steps(1) cm-blink 1.2s infinite"
},
// Two animations defined so that we can switch between them to
// restart the animation without forcing another style
// recomputation.
"@keyframes cm-blink": { "0%": {}, "50%": { opacity: 0 }, "100%": {} },
"@keyframes cm-blink2": { "0%": {}, "50%": { opacity: 0 }, "100%": {} },
".cm-cursor, .cm-dropCursor": {
borderLeft: "1.2px solid black",
marginLeft: "-0.6px",
pointerEvents: "none"
},
".cm-cursor": {
display: "none"
},
"&dark .cm-cursor": {
borderLeftColor: "#444"
},
".cm-dropCursor": {
position: "absolute"
},
"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor": {
display: "block"
},
"&light .cm-activeLine": { backgroundColor: "#cceeff44" },
"&dark .cm-activeLine": { backgroundColor: "#99eeff33" },
"&light .cm-specialChar": { color: "red" },
"&dark .cm-specialChar": { color: "#f78" },
".cm-gutters": {
flexShrink: 0,
display: "flex",
height: "100%",
boxSizing: "border-box",
insetInlineStart: 0,
zIndex: 200
},
"&light .cm-gutters": {
backgroundColor: "#f5f5f5",
color: "#6c6c6c",
borderRight: "1px solid #ddd"
},
"&dark .cm-gutters": {
backgroundColor: "#333338",
color: "#ccc"
},
".cm-gutter": {
display: "flex !important",
flexDirection: "column",
flexShrink: 0,
boxSizing: "border-box",
minHeight: "100%",
overflow: "hidden"
},
".cm-gutterElement": {
boxSizing: "border-box"
},
".cm-lineNumbers .cm-gutterElement": {
padding: "0 3px 0 5px",
minWidth: "20px",
textAlign: "right",
whiteSpace: "nowrap"
},
"&light .cm-activeLineGutter": {
backgroundColor: "#e2f2ff"
},
"&dark .cm-activeLineGutter": {
backgroundColor: "#222227"
},
".cm-panels": {
boxSizing: "border-box",
position: "sticky",
left: 0,
right: 0
},
"&light .cm-panels": {
backgroundColor: "#f5f5f5",
color: "black"
},
"&light .cm-panels-top": {
borderBottom: "1px solid #ddd"
},
"&light .cm-panels-bottom": {
borderTop: "1px solid #ddd"
},
"&dark .cm-panels": {
backgroundColor: "#333338",
color: "white"
},
".cm-tab": {
display: "inline-block",
overflow: "hidden",
verticalAlign: "bottom"
},
".cm-widgetBuffer": {
verticalAlign: "text-top",
height: "1em",
width: 0,
display: "inline"
},
".cm-placeholder": {
color: "#888",
display: "inline-block",
verticalAlign: "top"
},
".cm-highlightSpace:before": {
content: "attr(data-display)",
position: "absolute",
pointerEvents: "none",
color: "#888"
},
".cm-highlightTab": {
backgroundImage: `url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>')`,
backgroundSize: "auto 100%",
backgroundPosition: "right 90%",
backgroundRepeat: "no-repeat"
},
".cm-trailingSpace": {
backgroundColor: "#ff332255"
},
".cm-button": {
verticalAlign: "middle",
color: "inherit",
fontSize: "70%",
padding: ".2em 1em",
borderRadius: "1px"
},
"&light .cm-button": {
backgroundImage: "linear-gradient(#eff1f5, #d9d9df)",
border: "1px solid #888",
"&:active": {
backgroundImage: "linear-gradient(#b4b4b4, #d0d3d6)"
}
},
"&dark .cm-button": {
backgroundImage: "linear-gradient(#393939, #111)",
border: "1px solid #888",
"&:active": {
backgroundImage: "linear-gradient(#111, #333)"
}
},
".cm-textfield": {
verticalAlign: "middle",
color: "inherit",
fontSize: "70%",
border: "1px solid silver",
padding: ".2em .5em"
},
"&light .cm-textfield": {
backgroundColor: "white"
},
"&dark .cm-textfield": {
border: "1px solid #555",
backgroundColor: "inherit"
}
}, ah), fi = "￿";
class wu {
constructor(t2, e2) {
this.points = t2, this.text = "", this.lineSeparator = e2.facet(H$3.lineSeparator);
}
append(t2) {
this.text += t2;
}
lineBreak() {
this.text += fi;
}
readRange(t2, e2) {
if (!t2)
return this;
let i2 = t2.parentNode;
for (let s = t2; ; ) {
this.findPointBefore(i2, s);
let r2 = this.text.length;
this.readNode(s);
let o = s.nextSibling;
if (o == e2)
break;
let l = q$1.get(s), h2 = q$1.get(o);
(l && h2 ? l.breakAfter : (l ? l.breakAfter : ro(s)) || ro(o) && (s.nodeName != "BR" || s.cmIgnore) && this.text.length > r2) && this.lineBreak(), s = o;
}
return this.findPointBefore(i2, e2), this;
}
readTextNode(t2) {
let e2 = t2.nodeValue;
for (let i2 of this.points)
i2.node == t2 && (i2.pos = this.text.length + Math.min(i2.offset, e2.length));
for (let i2 = 0, s = this.lineSeparator ? null : /\r\n?|\n/g; ; ) {
let r2 = -1, o = 1, l;
if (this.lineSeparator ? (r2 = e2.indexOf(this.lineSeparator, i2), o = this.lineSeparator.length) : (l = s.exec(e2)) && (r2 = l.index, o = l[0].length), this.append(e2.slice(i2, r2 < 0 ? e2.length : r2)), r2 < 0)
break;
if (this.lineBreak(), o > 1)
for (let h2 of this.points)
h2.node == t2 && h2.pos > this.text.length && (h2.pos -= o - 1);
i2 = r2 + o;
}
}
readNode(t2) {
if (t2.cmIgnore)
return;
let e2 = q$1.get(t2), i2 = e2 && e2.overrideDOMText;
if (i2 != null) {
this.findPointInside(t2, i2.length);
for (let s = i2.iter(); !s.next().done; )
s.lineBreak ? this.lineBreak() : this.append(s.value);
} else
t2.nodeType == 3 ? this.readTextNode(t2) : t2.nodeName == "BR" ? t2.nextSibling && this.lineBreak() : t2.nodeType == 1 && this.readRange(t2.firstChild, null);
}
findPointBefore(t2, e2) {
for (let i2 of this.points)
i2.node == t2 && t2.childNodes[i2.offset] == e2 && (i2.pos = this.text.length);
}
findPointInside(t2, e2) {
for (let i2 of this.points)
(t2.nodeType == 3 ? i2.node == t2 : t2.contains(i2.node)) && (i2.pos = this.text.length + (yu(t2, i2.node, i2.offset) ? e2 : 0));
}
}
function yu(n2, t2, e2) {
for (; ; ) {
if (!t2 || e2 < ne(t2))
return false;
if (t2 == n2)
return true;
e2 = ki(t2) + 1, t2 = t2.parentNode;
}
}
function ro(n2) {
return n2.nodeType == 1 && /^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(n2.nodeName);
}
class oo {
constructor(t2, e2) {
this.node = t2, this.offset = e2, this.pos = -1;
}
}
class bu {
constructor(t2, e2, i2, s) {
this.typeOver = s, this.bounds = null, this.text = "";
let { impreciseHead: r2, impreciseAnchor: o } = t2.docView;
if (t2.state.readOnly && e2 > -1)
this.newSel = null;
else if (e2 > -1 && (this.bounds = t2.docView.domBoundsAround(e2, i2, 0))) {
let l = r2 || o ? [] : vu(t2), h2 = new wu(l, t2.state);
h2.readRange(this.bounds.startDOM, this.bounds.endDOM), this.text = h2.text, this.newSel = Su(l, this.bounds.from);
} else {
let l = t2.observer.selectionRange, h2 = r2 && r2.node == l.focusNode && r2.offset == l.focusOffset || !wn(t2.contentDOM, l.focusNode) ? t2.state.selection.main.head : t2.docView.posFromDOM(l.focusNode, l.focusOffset), a2 = o && o.node == l.anchorNode && o.offset == l.anchorOffset || !wn(t2.contentDOM, l.anchorNode) ? t2.state.selection.main.anchor : t2.docView.posFromDOM(l.anchorNode, l.anchorOffset);
this.newSel = b$1.single(a2, h2);
}
}
}
function ch(n2, t2) {
let e2, { newSel: i2 } = t2, s = n2.state.selection.main, r2 = n2.inputState.lastKeyTime > Date.now() - 100 ? n2.inputState.lastKeyCode : -1;
if (t2.bounds) {
let { from: o, to: l } = t2.bounds, h2 = s.from, a2 = null;
(r2 === 8 || C.android && t2.text.length < l - o) && (h2 = s.to, a2 = "end");
let c2 = xu(n2.state.doc.sliceString(o, l, fi), t2.text, h2 - o, a2);
c2 && (C.chrome && r2 == 13 && c2.toB == c2.from + 2 && t2.text.slice(c2.from, c2.toB) == fi + fi && c2.toB--, e2 = {
from: o + c2.from,
to: o + c2.toA,
insert: V.of(t2.text.slice(c2.from, c2.toB).split(fi))
});
} else
i2 && (!n2.hasFocus && n2.state.facet(Bs) || i2.main.eq(s)) && (i2 = null);
if (!e2 && !i2)
return false;
if (!e2 && t2.typeOver && !s.empty && i2 && i2.main.empty ? e2 = { from: s.from, to: s.to, insert: n2.state.doc.slice(s.from, s.to) } : e2 && e2.from >= s.from && e2.to <= s.to && (e2.from != s.from || e2.to != s.to) && s.to - s.from - (e2.to - e2.from) <= 4 ? e2 = {
from: s.from,
to: s.to,
insert: n2.state.doc.slice(s.from, e2.from).append(e2.insert).append(n2.state.doc.slice(e2.to, s.to))
} : (C.mac || C.android) && e2 && e2.from == e2.to && e2.from == s.head - 1 && /^\. ?$/.test(e2.insert.toString()) && n2.contentDOM.getAttribute("autocorrect") == "off" ? (i2 && e2.insert.length == 2 && (i2 = b$1.single(i2.main.anchor - 1, i2.main.head - 1)), e2 = { from: s.from, to: s.to, insert: V.of([" "]) }) : C.chrome && e2 && e2.from == e2.to && e2.from == s.head && e2.insert.toString() == `
` && n2.lineWrapping && (i2 && (i2 = b$1.single(i2.main.anchor - 1, i2.main.head - 1)), e2 = { from: s.from, to: s.to, insert: V.of([" "]) }), e2) {
if (C.ios && n2.inputState.flushIOSKey() || C.android && (e2.from == s.from && e2.to == s.to && e2.insert.length == 1 && e2.insert.lines == 2 && Ke(n2.contentDOM, "Enter", 13) || (e2.from == s.from - 1 && e2.to == s.to && e2.insert.length == 0 || r2 == 8 && e2.insert.length < e2.to - e2.from && e2.to > s.head) && Ke(n2.contentDOM, "Backspace", 8) || e2.from == s.from && e2.to == s.to + 1 && e2.insert.length == 0 && Ke(n2.contentDOM, "Delete", 46)))
return true;
let o = e2.insert.toString();
n2.inputState.composing >= 0 && n2.inputState.composing++;
let l, h2 = () => l || (l = ku(n2, e2, i2));
return n2.state.facet(Il).some((a2) => a2(n2, e2.from, e2.to, o, h2)) || n2.dispatch(h2()), true;
} else if (i2 && !i2.main.eq(s)) {
let o = false, l = "select";
return n2.inputState.lastSelectionTime > Date.now() - 50 && (n2.inputState.lastSelectionOrigin == "select" && (o = true), l = n2.inputState.lastSelectionOrigin), n2.dispatch({ selection: i2, scrollIntoView: o, userEvent: l }), true;
} else
return false;
}
function ku(n2, t2, e2) {
let i2, s = n2.state, r2 = s.selection.main;
if (t2.from >= r2.from && t2.to <= r2.to && t2.to - t2.from >= (r2.to - r2.from) / 3 && (!e2 || e2.main.empty && e2.main.from == t2.from + t2.insert.length) && n2.inputState.composing < 0) {
let l = r2.from < t2.from ? s.sliceDoc(r2.from, t2.from) : "", h2 = r2.to > t2.to ? s.sliceDoc(t2.to, r2.to) : "";
i2 = s.replaceSelection(n2.state.toText(l + t2.insert.sliceString(0, void 0, n2.state.lineBreak) + h2));
} else {
let l = s.changes(t2), h2 = e2 && e2.main.to <= l.newLength ? e2.main : void 0;
if (s.selection.ranges.length > 1 && n2.inputState.composing >= 0 && t2.to <= r2.to && t2.to >= r2.to - 10) {
let a2 = n2.state.sliceDoc(t2.from, t2.to), c2, f2 = e2 && Ul(n2, e2.main.head);
if (f2) {
let p2 = t2.insert.length - (t2.to - t2.from);
c2 = { from: f2.from, to: f2.to - p2 };
} else
c2 = n2.state.doc.lineAt(r2.head);
let u2 = r2.to - t2.to, d2 = r2.to - r2.from;
i2 = s.changeByRange((p2) => {
if (p2.from == r2.from && p2.to == r2.to)
return { changes: l, range: h2 || p2.map(l) };
let m = p2.to - u2, g = m - a2.length;
if (p2.to - p2.from != d2 || n2.state.sliceDoc(g, m) != a2 || // Unfortunately, there's no way to make multiple
// changes in the same node work without aborting
// composition, so cursors in the composition range are
// ignored.
p2.to >= c2.from && p2.from <= c2.to)
return { range: p2 };
let y2 = s.changes({ from: g, to: m, insert: t2.insert }), x2 = p2.to - r2.to;
return {
changes: y2,
range: h2 ? b$1.range(Math.max(0, h2.anchor + x2), Math.max(0, h2.head + x2)) : p2.map(y2)
};
});
} else
i2 = {
changes: l,
selection: h2 && s.selection.replaceRange(h2)
};
}
let o = "input.type";
return (n2.composing || n2.inputState.compositionPendingChange && n2.inputState.compositionEndedAt > Date.now() - 50) && (n2.inputState.compositionPendingChange = false, o += ".compose", n2.inputState.compositionFirstChange && (o += ".start", n2.inputState.compositionFirstChange = false)), s.update(i2, { userEvent: o, scrollIntoView: true });
}
function xu(n2, t2, e2, i2) {
let s = Math.min(n2.length, t2.length), r2 = 0;
for (; r2 < s && n2.charCodeAt(r2) == t2.charCodeAt(r2); )
r2++;
if (r2 == s && n2.length == t2.length)
return null;
let o = n2.length, l = t2.length;
for (; o > 0 && l > 0 && n2.charCodeAt(o - 1) == t2.charCodeAt(l - 1); )
o--, l--;
if (i2 == "end") {
let h2 = Math.max(0, r2 - Math.min(o, l));
e2 -= o + h2 - r2;
}
if (o < r2 && n2.length < t2.length) {
let h2 = e2 <= r2 && e2 >= o ? r2 - e2 : 0;
r2 -= h2, l = r2 + (l - o), o = r2;
} else if (l < r2) {
let h2 = e2 <= r2 && e2 >= l ? r2 - e2 : 0;
r2 -= h2, o = r2 + (o - l), l = r2;
}
return { from: r2, toA: o, toB: l };
}
function vu(n2) {
let t2 = [];
if (n2.root.activeElement != n2.contentDOM)
return t2;
let { anchorNode: e2, anchorOffset: i2, focusNode: s, focusOffset: r2 } = n2.observer.selectionRange;
return e2 && (t2.push(new oo(e2, i2)), (s != e2 || r2 != i2) && t2.push(new oo(s, r2))), t2;
}
function Su(n2, t2) {
if (n2.length == 0)
return null;
let e2 = n2[0].pos, i2 = n2.length == 2 ? n2[1].pos : e2;
return e2 > -1 && i2 > -1 ? b$1.single(e2 + t2, i2 + t2) : null;
}
const Cu = {
childList: true,
characterData: true,
subtree: true,
attributes: true,
characterDataOldValue: true
}, Ks = C.ie && C.ie_version <= 11;
class Au {
constructor(t2) {
this.view = t2, this.active = false, this.selectionRange = new of(), this.selectionChanged = false, this.delayedFlush = -1, this.resizeTimeout = -1, this.queue = [], this.delayedAndroidKey = null, this.flushingAndroidKey = -1, this.lastChange = 0, this.scrollTargets = [], this.intersection = null, this.resizeScroll = null, this.intersecting = false, this.gapIntersection = null, this.gaps = [], this.parentCheck = -1, this.dom = t2.contentDOM, this.observer = new MutationObserver((e2) => {
for (let i2 of e2)
this.queue.push(i2);
(C.ie && C.ie_version <= 11 || C.ios && t2.composing) && e2.some((i2) => i2.type == "childList" && i2.removedNodes.length || i2.type == "characterData" && i2.oldValue.length > i2.target.nodeValue.length) ? this.flushSoon() : this.flush();
}), Ks && (this.onCharData = (e2) => {
this.queue.push({
target: e2.target,
type: "characterData",
oldValue: e2.prevValue
}), this.flushSoon();
}), this.onSelectionChange = this.onSelectionChange.bind(this), this.onResize = this.onResize.bind(this), this.onPrint = this.onPrint.bind(this), this.onScroll = this.onScroll.bind(this), typeof ResizeObserver == "function" && (this.resizeScroll = new ResizeObserver(() => {
var e2;
((e2 = this.view.docView) === null || e2 === void 0 ? void 0 : e2.lastUpdate) < Date.now() - 75 && this.onResize();
}), this.resizeScroll.observe(t2.scrollDOM)), this.addWindowListeners(this.win = t2.win), this.start(), typeof IntersectionObserver == "function" && (this.intersection = new IntersectionObserver((e2) => {
this.parentCheck < 0 && (this.parentCheck = setTimeout(this.listenForScroll.bind(this), 1e3)), e2.length > 0 && e2[e2.length - 1].intersectionRatio > 0 != this.intersecting && (this.intersecting = !this.intersecting, this.intersecting != this.view.inView && this.onScrollChanged(document.createEvent("Event")));
}, { threshold: [0, 1e-3] }), this.intersection.observe(this.dom), this.gapIntersection = new IntersectionObserver((e2) => {
e2.length > 0 && e2[e2.length - 1].intersectionRatio > 0 && this.onScrollChanged(document.createEvent("Event"));
}, {})), this.listenForScroll(), this.readSelectionRange();
}
onScrollChanged(t2) {
this.view.inputState.runHandlers("scroll", t2), this.intersecting && this.view.measure();
}
onScroll(t2) {
this.intersecting && this.flush(false), this.onScrollChanged(t2);
}
onResize() {
this.resizeTimeout < 0 && (this.resizeTimeout = setTimeout(() => {
this.resizeTimeout = -1, this.view.requestMeasure();
}, 50));
}
onPrint() {
this.view.viewState.printing = true, this.view.measure(), setTimeout(() => {
this.view.viewState.printing = false, this.view.requestMeasure();
}, 500);
}
updateGaps(t2) {
if (this.gapIntersection && (t2.length != this.gaps.length || this.gaps.some((e2, i2) => e2 != t2[i2]))) {
this.gapIntersection.disconnect();
for (let e2 of t2)
this.gapIntersection.observe(e2);
this.gaps = t2;
}
}
onSelectionChange(t2) {
let e2 = this.selectionChanged;
if (!this.readSelectionRange() || this.delayedAndroidKey)
return;
let { view: i2 } = this, s = this.selectionRange;
if (i2.state.facet(Bs) ? i2.root.activeElement != this.dom : !ts(i2.dom, s))
return;
let r2 = s.anchorNode && i2.docView.nearest(s.anchorNode);
if (r2 && r2.ignoreEvent(t2)) {
e2 || (this.selectionChanged = false);
return;
}
(C.ie && C.ie_version <= 11 || C.android && C.chrome) && !i2.state.selection.main.empty && // (Selection.isCollapsed isn't reliable on IE)
s.focusNode && ds(s.focusNode, s.focusOffset, s.anchorNode, s.anchorOffset) ? this.flushSoon() : this.flush(false);
}
readSelectionRange() {
let { view: t2 } = this, e2 = C.safari && t2.root.nodeType == 11 && ef(this.dom.ownerDocument) == this.dom && Ou(this.view) || us(t2.root);
if (!e2 || this.selectionRange.eq(e2))
return false;
let i2 = ts(this.dom, e2);
return i2 && !this.selectionChanged && t2.inputState.lastFocusTime > Date.now() - 200 && t2.inputState.lastTouchTime < Date.now() - 300 && hf(this.dom, e2) ? (this.view.inputState.lastFocusTime = 0, t2.docView.updateSelection(), false) : (this.selectionRange.setRange(e2), i2 && (this.selectionChanged = true), true);
}
setSelectionRange(t2, e2) {
this.selectionRange.set(t2.node, t2.offset, e2.node, e2.offset), this.selectionChanged = false;
}
clearSelectionRange() {
this.selectionRange.set(null, 0, null, 0);
}
listenForScroll() {
this.parentCheck = -1;
let t2 = 0, e2 = null;
for (let i2 = this.dom; i2; )
if (i2.nodeType == 1)
!e2 && t2 < this.scrollTargets.length && this.scrollTargets[t2] == i2 ? t2++ : e2 || (e2 = this.scrollTargets.slice(0, t2)), e2 && e2.push(i2), i2 = i2.assignedSlot || i2.parentNode;
else if (i2.nodeType == 11)
i2 = i2.host;
else
break;
if (t2 < this.scrollTargets.length && !e2 && (e2 = this.scrollTargets.slice(0, t2)), e2) {
for (let i2 of this.scrollTargets)
i2.removeEventListener("scroll", this.onScroll);
for (let i2 of this.scrollTargets = e2)
i2.addEventListener("scroll", this.onScroll);
}
}
ignore(t2) {
if (!this.active)
return t2();
try {
return this.stop(), t2();
} finally {
this.start(), this.clear();
}
}
start() {
this.active || (this.observer.observe(this.dom, Cu), Ks && this.dom.addEventListener("DOMCharacterDataModified", this.onCharData), this.active = true);
}
stop() {
this.active && (this.active = false, this.observer.disconnect(), Ks && this.dom.removeEventListener("DOMCharacterDataModified", this.onCharData));
}
// Throw away any pending changes
clear() {
this.processRecords(), this.queue.length = 0, this.selectionChanged = false;
}
// Chrome Android, especially in combination with GBoard, not only
// doesn't reliably fire regular key events, but also often
// surrounds the effect of enter or backspace with a bunch of
// composition events that, when interrupted, cause text duplication
// or other kinds of corruption. This hack makes the editor back off
// from handling DOM changes for a moment when such a key is
// detected (via beforeinput or keydown), and then tries to flush
// them or, if that has no effect, dispatches the given key.
delayAndroidKey(t2, e2) {
var i2;
if (!this.delayedAndroidKey) {
let s = () => {
let r2 = this.delayedAndroidKey;
r2 && (this.clearDelayedAndroidKey(), this.view.inputState.lastKeyCode = r2.keyCode, this.view.inputState.lastKeyTime = Date.now(), !this.flush() && r2.force && Ke(this.dom, r2.key, r2.keyCode));
};
this.flushingAndroidKey = this.view.win.requestAnimationFrame(s);
}
(!this.delayedAndroidKey || t2 == "Enter") && (this.delayedAndroidKey = {
key: t2,
keyCode: e2,
// Only run the key handler when no changes are detected if
// this isn't coming right after another change, in which case
// it is probably part of a weird chain of updates, and should
// be ignored if it returns the DOM to its previous state.
force: this.lastChange < Date.now() - 50 || !!(!((i2 = this.delayedAndroidKey) === null || i2 === void 0) && i2.force)
});
}
clearDelayedAndroidKey() {
this.win.cancelAnimationFrame(this.flushingAndroidKey), this.delayedAndroidKey = null, this.flushingAndroidKey = -1;
}
flushSoon() {
this.delayedFlush < 0 && (this.delayedFlush = this.view.win.requestAnimationFrame(() => {
this.delayedFlush = -1, this.flush();
}));
}
forceFlush() {
this.delayedFlush >= 0 && (this.view.win.cancelAnimationFrame(this.delayedFlush), this.delayedFlush = -1), this.flush();
}
pendingRecords() {
for (let t2 of this.observer.takeRecords())
this.queue.push(t2);
return this.queue;
}
processRecords() {
let t2 = this.pendingRecords();
t2.length && (this.queue = []);
let e2 = -1, i2 = -1, s = false;
for (let r2 of t2) {
let o = this.readMutation(r2);
o && (o.typeOver && (s = true), e2 == -1 ? { from: e2, to: i2 } = o : (e2 = Math.min(o.from, e2), i2 = Math.max(o.to, i2)));
}
return { from: e2, to: i2, typeOver: s };
}
readChange() {
let { from: t2, to: e2, typeOver: i2 } = this.processRecords(), s = this.selectionChanged && ts(this.dom, this.selectionRange);
if (t2 < 0 && !s)
return null;
t2 > -1 && (this.lastChange = Date.now()), this.view.inputState.lastFocusTime = 0, this.selectionChanged = false;
let r2 = new bu(this.view, t2, e2, i2);
return this.view.docView.domChanged = { newSel: r2.newSel ? r2.newSel.main : null }, r2;
}
// Apply pending changes, if any
flush(t2 = true) {
if (this.delayedFlush >= 0 || this.delayedAndroidKey)
return false;
t2 && this.readSelectionRange();
let e2 = this.readChange();
if (!e2)
return this.view.requestMeasure(), false;
let i2 = this.view.state, s = ch(this.view, e2);
return this.view.state == i2 && this.view.update([]), s;
}
readMutation(t2) {
let e2 = this.view.docView.nearest(t2.target);
if (!e2 || e2.ignoreMutation(t2))
return null;
if (e2.markDirty(t2.type == "attributes"), t2.type == "attributes" && (e2.flags |= 4), t2.type == "childList") {
let i2 = lo(e2, t2.previousSibling || t2.target.previousSibling, -1), s = lo(e2, t2.nextSibling || t2.target.nextSibling, 1);
return {
from: i2 ? e2.posAfter(i2) : e2.posAtStart,
to: s ? e2.posBefore(s) : e2.posAtEnd,
typeOver: false
};
} else
return t2.type == "characterData" ? { from: e2.posAtStart, to: e2.posAtEnd, typeOver: t2.target.nodeValue == t2.oldValue } : null;
}
setWindow(t2) {
t2 != this.win && (this.removeWindowListeners(this.win), this.win = t2, this.addWindowListeners(this.win));
}
addWindowListeners(t2) {
t2.addEventListener("resize", this.onResize), t2.addEventListener("beforeprint", this.onPrint), t2.addEventListener("scroll", this.onScroll), t2.document.addEventListener("selectionchange", this.onSelectionChange);
}
removeWindowListeners(t2) {
t2.removeEventListener("scroll", this.onScroll), t2.removeEventListener("resize", this.onResize), t2.removeEventListener("beforeprint", this.onPrint), t2.document.removeEventListener("selectionchange", this.onSelectionChange);
}
destroy() {
var t2, e2, i2;
this.stop(), (t2 = this.intersection) === null || t2 === void 0 || t2.disconnect(), (e2 = this.gapIntersection) === null || e2 === void 0 || e2.disconnect(), (i2 = this.resizeScroll) === null || i2 === void 0 || i2.disconnect();
for (let s of this.scrollTargets)
s.removeEventListener("scroll", this.onScroll);
this.removeWindowListeners(this.win), clearTimeout(this.parentCheck), clearTimeout(this.resizeTimeout), this.win.cancelAnimationFrame(this.delayedFlush), this.win.cancelAnimationFrame(this.flushingAndroidKey);
}
}
function lo(n2, t2, e2) {
for (; t2; ) {
let i2 = q$1.get(t2);
if (i2 && i2.parent == n2)
return i2;
let s = t2.parentNode;
t2 = s != n2.dom ? s : e2 > 0 ? t2.nextSibling : t2.previousSibling;
}
return null;
}
function Ou(n2) {
let t2 = null;
function e2(h2) {
h2.preventDefault(), h2.stopImmediatePropagation(), t2 = h2.getTargetRanges()[0];
}
if (n2.contentDOM.addEventListener("beforeinput", e2, true), n2.dom.ownerDocument.execCommand("indent"), n2.contentDOM.removeEventListener("beforeinput", e2, true), !t2)
return null;
let i2 = t2.startContainer, s = t2.startOffset, r2 = t2.endContainer, o = t2.endOffset, l = n2.docView.domAtPos(n2.state.selection.main.anchor);
return ds(l.node, l.offset, r2, o) && ([i2, s, r2, o] = [r2, o, i2, s]), { anchorNode: i2, anchorOffset: s, focusNode: r2, focusOffset: o };
}
class T {
/**
The current editor state.
*/
get state() {
return this.viewState.state;
}
/**
To be able to display large documents without consuming too much
memory or overloading the browser, CodeMirror only draws the
code that is visible (plus a margin around it) to the DOM. This
property tells you the extent of the current drawn viewport, in
document positions.
*/
get viewport() {
return this.viewState.viewport;
}
/**
When there are, for example, large collapsed ranges in the
viewport, its size can be a lot bigger than the actual visible
content. Thus, if you are doing something like styling the
content in the viewport, it is preferable to only do so for
these ranges, which are the subset of the viewport that is
actually drawn.
*/
get visibleRanges() {
return this.viewState.visibleRanges;
}
/**
Returns false when the editor is entirely scrolled out of view
or otherwise hidden.
*/
get inView() {
return this.viewState.inView;
}
/**
Indicates whether the user is currently composing text via
[IME](https://en.wikipedia.org/wiki/Input_method), and at least
one change has been made in the current composition.
*/
get composing() {
return this.inputState.composing > 0;
}
/**
Indicates whether the user is currently in composing state. Note
that on some platforms, like Android, this will be the case a
lot, since just putting the cursor on a word starts a
composition there.
*/
get compositionStarted() {
return this.inputState.composing >= 0;
}
/**
The document or shadow root that the view lives in.
*/
get root() {
return this._root;
}
/**
@internal
*/
get win() {
return this.dom.ownerDocument.defaultView || window;
}
/**
Construct a new view. You'll want to either provide a `parent`
option, or put `view.dom` into your document after creating a
view, so that the user can see the editor.
*/
constructor(t2 = {}) {
this.plugins = [], this.pluginMap = /* @__PURE__ */ new Map(), this.editorAttrs = {}, this.contentAttrs = {}, this.bidiCache = [], this.destroyed = false, this.updateState = 2, this.measureScheduled = -1, this.measureRequests = [], this.contentDOM = document.createElement("div"), this.scrollDOM = document.createElement("div"), this.scrollDOM.tabIndex = -1, this.scrollDOM.className = "cm-scroller", this.scrollDOM.appendChild(this.contentDOM), this.announceDOM = document.createElement("div"), this.announceDOM.style.cssText = "position: fixed; top: -10000px", this.announceDOM.setAttribute("aria-live", "polite"), this.dom = document.createElement("div"), this.dom.appendChild(this.announceDOM), this.dom.appendChild(this.scrollDOM);
let { dispatch: e2 } = t2;
this.dispatchTransactions = t2.dispatchTransactions || e2 && ((i2) => i2.forEach((s) => e2(s, this))) || ((i2) => this.update(i2)), this.dispatch = this.dispatch.bind(this), this._root = t2.root || lf(t2.parent) || document, this.viewState = new so(t2.state || H$3.create(t2)), t2.scrollTo && t2.scrollTo.is(Ii) && (this.viewState.scrollTarget = t2.scrollTo.value.clip(this.viewState.state)), this.plugins = this.state.facet(hi).map((i2) => new _s(i2));
for (let i2 of this.plugins)
i2.update(this);
this.observer = new Au(this), this.inputState = new _f(this), this.inputState.ensureHandlers(this.plugins), this.docView = new $r(this), this.mountStyles(), this.updateAttrs(), this.updateState = 0, this.requestMeasure(), t2.parent && t2.parent.appendChild(this.dom);
}
dispatch(...t2) {
let e2 = t2.length == 1 && t2[0] instanceof ft ? t2 : t2.length == 1 && Array.isArray(t2[0]) ? t2[0] : [this.state.update(...t2)];
this.dispatchTransactions(e2, this);
}
/**
Update the view for the given array of transactions. This will
update the visible document and selection to match the state
produced by the transactions, and notify view plugins of the
change. You should usually call
[`dispatch`](https://codemirror.net/6/docs/ref/#view.EditorView.dispatch) instead, which uses this
as a primitive.
*/
update(t2) {
if (this.updateState != 0)
throw new Error("Calls to EditorView.update are not allowed while an update is in progress");
let e2 = false, i2 = false, s, r2 = this.state;
for (let u2 of t2) {
if (u2.startState != r2)
throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");
r2 = u2.state;
}
if (this.destroyed) {
this.viewState.state = r2;
return;
}
let o = this.hasFocus, l = 0, h2 = null;
t2.some((u2) => u2.annotation(sh)) ? (this.inputState.notifiedFocused = o, l = 1) : o != this.inputState.notifiedFocused && (this.inputState.notifiedFocused = o, h2 = nh(r2, o), h2 || (l = 1));
let a2 = this.observer.delayedAndroidKey, c2 = null;
if (a2 ? (this.observer.clearDelayedAndroidKey(), c2 = this.observer.readChange(), (c2 && !this.state.doc.eq(r2.doc) || !this.state.selection.eq(r2.selection)) && (c2 = null)) : this.observer.clear(), r2.facet(H$3.phrases) != this.state.facet(H$3.phrases))
return this.setState(r2);
s = ps.create(this, r2, t2), s.flags |= l;
let f2 = this.viewState.scrollTarget;
try {
this.updateState = 2;
for (let u2 of t2) {
if (f2 && (f2 = f2.map(u2.changes)), u2.scrollIntoView) {
let { main: d2 } = u2.state.selection;
f2 = new qe(d2.empty ? d2 : b$1.cursor(d2.head, d2.head > d2.anchor ? -1 : 1));
}
for (let d2 of u2.effects)
d2.is(Ii) && (f2 = d2.value.clip(this.state));
}
this.viewState.update(s, f2), this.bidiCache = gs.update(this.bidiCache, s.changes), s.empty || (this.updatePlugins(s), this.inputState.update(s)), e2 = this.docView.update(s), this.state.facet(ai) != this.styleModules && this.mountStyles(), i2 = this.updateAttrs(), this.showAnnouncements(t2), this.docView.updateSelection(e2, t2.some((u2) => u2.isUserEvent("select.pointer")));
} finally {
this.updateState = 0;
}
if (s.startState.facet(zi) != s.state.facet(zi) && (this.viewState.mustMeasureContent = true), (e2 || i2 || f2 || this.viewState.mustEnforceCursorAssoc || this.viewState.mustMeasureContent) && this.requestMeasure(), !s.empty)
for (let u2 of this.state.facet(Cn))
try {
u2(s);
} catch (d2) {
ie(this.state, d2, "update listener");
}
(h2 || c2) && Promise.resolve().then(() => {
h2 && this.state == h2.startState && this.dispatch(h2), c2 && !ch(this, c2) && a2.force && Ke(this.contentDOM, a2.key, a2.keyCode);
});
}
/**
Reset the view to the given state. (This will cause the entire
document to be redrawn and all view plugins to be reinitialized,
so you should probably only use it when the new state isn't
derived from the old state. Otherwise, use
[`dispatch`](https://codemirror.net/6/docs/ref/#view.EditorView.dispatch) instead.)
*/
setState(t2) {
if (this.updateState != 0)
throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");
if (this.destroyed) {
this.viewState.state = t2;
return;
}
this.updateState = 2;
let e2 = this.hasFocus;
try {
for (let i2 of this.plugins)
i2.destroy(this);
this.viewState = new so(t2), this.plugins = t2.facet(hi).map((i2) => new _s(i2)), this.pluginMap.clear();
for (let i2 of this.plugins)
i2.update(this);
this.docView = new $r(this), this.inputState.ensureHandlers(this.plugins), this.mountStyles(), this.updateAttrs(), this.bidiCache = [];
} finally {
this.updateState = 0;
}
e2 && this.focus(), this.requestMeasure();
}
updatePlugins(t2) {
let e2 = t2.startState.facet(hi), i2 = t2.state.facet(hi);
if (e2 != i2) {
let s = [];
for (let r2 of i2) {
let o = e2.indexOf(r2);
if (o < 0)
s.push(new _s(r2));
else {
let l = this.plugins[o];
l.mustUpdate = t2, s.push(l);
}
}
for (let r2 of this.plugins)
r2.mustUpdate != t2 && r2.destroy(this);
this.plugins = s, this.pluginMap.clear();
} else
for (let s of this.plugins)
s.mustUpdate = t2;
for (let s = 0; s < this.plugins.length; s++)
this.plugins[s].update(this);
e2 != i2 && this.inputState.ensureHandlers(this.plugins);
}
/**
@internal
*/
measure(t2 = true) {
if (this.destroyed)
return;
if (this.measureScheduled > -1 && this.win.cancelAnimationFrame(this.measureScheduled), this.observer.delayedAndroidKey) {
this.measureScheduled = -1, this.requestMeasure();
return;
}
this.measureScheduled = 0, t2 && this.observer.forceFlush();
let e2 = null, i2 = this.scrollDOM, s = i2.scrollTop * this.scaleY, { scrollAnchorPos: r2, scrollAnchorHeight: o } = this.viewState;
Math.abs(s - this.viewState.scrollTop) > 1 && (o = -1), this.viewState.scrollAnchorHeight = -1;
try {
for (let l = 0; ; l++) {
if (o < 0)
if (vl(i2))
r2 = -1, o = this.viewState.heightMap.height;
else {
let d2 = this.viewState.scrollAnchorAt(s);
r2 = d2.from, o = d2.top;
}
this.updateState = 1;
let h2 = this.viewState.measure(this);
if (!h2 && !this.measureRequests.length && this.viewState.scrollTarget == null)
break;
if (l > 5) {
console.warn(this.measureRequests.length ? "Measure loop restarted more than 5 times" : "Viewport failed to stabilize");
break;
}
let a2 = [];
h2 & 4 || ([this.measureRequests, a2] = [a2, this.measureRequests]);
let c2 = a2.map((d2) => {
try {
return d2.read(this);
} catch (p2) {
return ie(this.state, p2), ho;
}
}), f2 = ps.create(this, this.state, []), u2 = false;
f2.flags |= h2, e2 ? e2.flags |= h2 : e2 = f2, this.updateState = 2, f2.empty || (this.updatePlugins(f2), this.inputState.update(f2), this.updateAttrs(), u2 = this.docView.update(f2));
for (let d2 = 0; d2 < a2.length; d2++)
if (c2[d2] != ho)
try {
let p2 = a2[d2];
p2.write && p2.write(c2[d2], this);
} catch (p2) {
ie(this.state, p2);
}
if (u2 && this.docView.updateSelection(true), !f2.viewportChanged && this.measureRequests.length == 0) {
if (this.viewState.editorHeight)
if (this.viewState.scrollTarget) {
this.docView.scrollIntoView(this.viewState.scrollTarget), this.viewState.scrollTarget = null;
continue;
} else {
let p2 = (r2 < 0 ? this.viewState.heightMap.height : this.viewState.lineBlockAt(r2).top) - o;
if (p2 > 1 || p2 < -1) {
s = s + p2, i2.scrollTop = s / this.scaleY, o = -1;
continue;
}
}
break;
}
}
} finally {
this.updateState = 0, this.measureScheduled = -1;
}
if (e2 && !e2.empty)
for (let l of this.state.facet(Cn))
l(e2);
}
/**
Get the CSS classes for the currently active editor themes.
*/
get themeClasses() {
return Bn + " " + (this.state.facet(Pn) ? hh : lh) + " " + this.state.facet(zi);
}
updateAttrs() {
let t2 = ao(this, $l, {
class: "cm-editor" + (this.hasFocus ? " cm-focused " : " ") + this.themeClasses
}), e2 = {
spellcheck: "false",
autocorrect: "off",
autocapitalize: "off",
translate: "no",
contenteditable: this.state.facet(Bs) ? "true" : "false",
class: "cm-content",
style: `${C.tabSize}: ${this.state.tabSize}`,
role: "textbox",
"aria-multiline": "true"
};
this.state.readOnly && (e2["aria-readonly"] = "true"), ao(this, er, e2);
let i2 = this.observer.ignore(() => {
let s = vn(this.contentDOM, this.contentAttrs, e2), r2 = vn(this.dom, this.editorAttrs, t2);
return s || r2;
});
return this.editorAttrs = t2, this.contentAttrs = e2, i2;
}
showAnnouncements(t2) {
let e2 = true;
for (let i2 of t2)
for (let s of i2.effects)
if (s.is(T.announce)) {
e2 && (this.announceDOM.textContent = ""), e2 = false;
let r2 = this.announceDOM.appendChild(document.createElement("div"));
r2.textContent = s.value;
}
}
mountStyles() {
this.styleModules = this.state.facet(ai);
let t2 = this.state.facet(T.cspNonce);
we.mount(this.root, this.styleModules.concat(mu).reverse(), t2 ? { nonce: t2 } : void 0);
}
readMeasured() {
if (this.updateState == 2)
throw new Error("Reading the editor layout isn't allowed during an update");
this.updateState == 0 && this.measureScheduled > -1 && this.measure(false);
}
/**
Schedule a layout measurement, optionally providing callbacks to
do custom DOM measuring followed by a DOM write phase. Using
this is preferable reading DOM layout directly from, for
example, an event handler, because it'll make sure measuring and
drawing done by other components is synchronized, avoiding
unnecessary DOM layout computations.
*/
requestMeasure(t2) {
if (this.measureScheduled < 0 && (this.measureScheduled = this.win.requestAnimationFrame(() => this.measure())), t2) {
if (this.measureRequests.indexOf(t2) > -1)
return;
if (t2.key != null) {
for (let e2 = 0; e2 < this.measureRequests.length; e2++)
if (this.measureRequests[e2].key === t2.key) {
this.measureRequests[e2] = t2;
return;
}
}
this.measureRequests.push(t2);
}
}
/**
Get the value of a specific plugin, if present. Note that
plugins that crash can be dropped from a view, so even when you
know you registered a given plugin, it is recommended to check
the return value of this method.
*/
plugin(t2) {
let e2 = this.pluginMap.get(t2);
return (e2 === void 0 || e2 && e2.spec != t2) && this.pluginMap.set(t2, e2 = this.plugins.find((i2) => i2.spec == t2) || null), e2 && e2.update(this).value;
}
/**
The top position of the document, in screen coordinates. This
may be negative when the editor is scrolled down. Points
directly to the top of the first line, not above the padding.
*/
get documentTop() {
return this.contentDOM.getBoundingClientRect().top + this.viewState.paddingTop;
}
/**
Reports the padding above and below the document.
*/
get documentPadding() {
return { top: this.viewState.paddingTop, bottom: this.viewState.paddingBottom };
}
/**
If the editor is transformed with CSS, this provides the scale
along the X axis. Otherwise, it will just be 1. Note that
transforms other than translation and scaling are not supported.
*/
get scaleX() {
return this.viewState.scaleX;
}
/**
Provide the CSS transformed scale along the Y axis.
*/
get scaleY() {
return this.viewState.scaleY;
}
/**
Find the text line or block widget at the given vertical
position (which is interpreted as relative to the [top of the
document](https://codemirror.net/6/docs/ref/#view.EditorView.documentTop)).
*/
elementAtHeight(t2) {
return this.readMeasured(), this.viewState.elementAtHeight(t2);
}
/**
Find the line block (see
[`lineBlockAt`](https://codemirror.net/6/docs/ref/#view.EditorView.lineBlockAt) at the given
height, again interpreted relative to the [top of the
document](https://codemirror.net/6/docs/ref/#view.EditorView.documentTop).
*/
lineBlockAtHeight(t2) {
return this.readMeasured(), this.viewState.lineBlockAtHeight(t2);
}
/**
Get the extent and vertical position of all [line
blocks](https://codemirror.net/6/docs/ref/#view.EditorView.lineBlockAt) in the viewport. Positions
are relative to the [top of the
document](https://codemirror.net/6/docs/ref/#view.EditorView.documentTop);
*/
get viewportLineBlocks() {
return this.viewState.viewportLines;
}
/**
Find the line block around the given document position. A line
block is a range delimited on both sides by either a
non-[hidden](https://codemirror.net/6/docs/ref/#view.Decoration^replace) line breaks, or the
start/end of the document. It will usually just hold a line of
text, but may be broken into multiple textblocks by block
widgets.
*/
lineBlockAt(t2) {
return this.viewState.lineBlockAt(t2);
}
/**
The editor's total content height.
*/
get contentHeight() {
return this.viewState.contentHeight;
}
/**
Move a cursor position by [grapheme
cluster](https://codemirror.net/6/docs/ref/#state.findClusterBreak). `forward` determines whether
the motion is away from the line start, or towards it. In
bidirectional text, the line is traversed in visual order, using
the editor's [text direction](https://codemirror.net/6/docs/ref/#view.EditorView.textDirection).
When the start position was the last one on the line, the
returned position will be across the line break. If there is no
further line, the original position is returned.
By default, this method moves over a single cluster. The
optional `by` argument can be used to move across more. It will
be called with the first cluster as argument, and should return
a predicate that determines, for each subsequent cluster,
whether it should also be moved over.
*/
moveByChar(t2, e2, i2) {
return Ws(this, t2, Kr(this, t2, e2, i2));
}
/**
Move a cursor position across the next group of either
[letters](https://codemirror.net/6/docs/ref/#state.EditorState.charCategorizer) or non-letter
non-whitespace characters.
*/
moveByGroup(t2, e2) {
return Ws(this, t2, Kr(this, t2, e2, (i2) => $f(this, t2.head, i2)));
}
/**
Move to the next line boundary in the given direction. If
`includeWrap` is true, line wrapping is on, and there is a
further wrap point on the current line, the wrap point will be
returned. Otherwise this function will return the start or end
of the line.
*/
moveToLineBoundary(t2, e2, i2 = true) {
return Hf(this, t2, e2, i2);
}
/**
Move a cursor position vertically. When `distance` isn't given,
it defaults to moving to the next line (including wrapped
lines). Otherwise, `distance` should provide a positive distance
in pixels.
When `start` has a
[`goalColumn`](https://codemirror.net/6/docs/ref/#state.SelectionRange.goalColumn), the vertical
motion will use that as a target horizontal position. Otherwise,
the cursor's own horizontal position is used. The returned
cursor will have its goal column set to whichever column was
used.
*/
moveVertically(t2, e2, i2) {
return Ws(this, t2, Ff(this, t2, e2, i2));
}
/**
Find the DOM parent node and offset (child offset if `node` is
an element, character offset when it is a text node) at the
given document position.
Note that for positions that aren't currently in
`visibleRanges`, the resulting DOM position isn't necessarily
meaningful (it may just point before or after a placeholder
element).
*/
domAtPos(t2) {
return this.docView.domAtPos(t2);
}
/**
Find the document position at the given DOM node. Can be useful
for associating positions with DOM events. Will raise an error
when `node` isn't part of the editor content.
*/
posAtDOM(t2, e2 = 0) {
return this.docView.posFromDOM(t2, e2);
}
posAtCoords(t2, e2 = true) {
return this.readMeasured(), Ql(this, t2, e2);
}
/**
Get the screen coordinates at the given document position.
`side` determines whether the coordinates are based on the
element before (-1) or after (1) the position (if no element is
available on the given side, the method will transparently use
another strategy to get reasonable coordinates).
*/
coordsAtPos(t2, e2 = 1) {
this.readMeasured();
let i2 = this.docView.coordsAt(t2, e2);
if (!i2 || i2.left == i2.right)
return i2;
let s = this.state.doc.lineAt(t2), r2 = this.bidiSpans(s), o = r2[ue.find(r2, t2 - s.from, -1, e2)];
return Xn(i2, o.dir == tt.LTR == e2 > 0);
}
/**
Return the rectangle around a given character. If `pos` does not
point in front of a character that is in the viewport and
rendered (i.e. not replaced, not a line break), this will return
null. For space characters that are a line wrap point, this will
return the position before the line break.
*/
coordsForChar(t2) {
return this.readMeasured(), this.docView.coordsForChar(t2);
}
/**
The default width of a character in the editor. May not
accurately reflect the width of all characters (given variable
width fonts or styling of invididual ranges).
*/
get defaultCharacterWidth() {
return this.viewState.heightOracle.charWidth;
}
/**
The default height of a line in the editor. May not be accurate
for all lines.
*/
get defaultLineHeight() {
return this.viewState.heightOracle.lineHeight;
}
/**
The text direction
([`direction`](https://developer.mozilla.org/en-US/docs/Web/CSS/direction)
CSS property) of the editor's content element.
*/
get textDirection() {
return this.viewState.defaultTextDirection;
}
/**
Find the text direction of the block at the given position, as
assigned by CSS. If
[`perLineTextDirection`](https://codemirror.net/6/docs/ref/#view.EditorView^perLineTextDirection)
isn't enabled, or the given position is outside of the viewport,
this will always return the same as
[`textDirection`](https://codemirror.net/6/docs/ref/#view.EditorView.textDirection). Note that
this may trigger a DOM layout.
*/
textDirectionAt(t2) {
return !this.state.facet(Hl) || t2 < this.viewport.from || t2 > this.viewport.to ? this.textDirection : (this.readMeasured(), this.docView.textDirectionAt(t2));
}
/**
Whether this editor [wraps lines](https://codemirror.net/6/docs/ref/#view.EditorView.lineWrapping)
(as determined by the
[`white-space`](https://developer.mozilla.org/en-US/docs/Web/CSS/white-space)
CSS property of its content element).
*/
get lineWrapping() {
return this.viewState.heightOracle.lineWrapping;
}
/**
Returns the bidirectional text structure of the given line
(which should be in the current document) as an array of span
objects. The order of these spans matches the [text
direction](https://codemirror.net/6/docs/ref/#view.EditorView.textDirection)—if that is
left-to-right, the leftmost spans come first, otherwise the
rightmost spans come first.
*/
bidiSpans(t2) {
if (t2.length > Mu)
return ql(t2.length);
let e2 = this.textDirectionAt(t2.from), i2;
for (let r2 of this.bidiCache)
if (r2.from == t2.from && r2.dir == e2 && (r2.fresh || Kl(r2.isolates, i2 = Hr(this, t2.from, t2.to))))
return r2.order;
i2 || (i2 = Hr(this, t2.from, t2.to));
let s = Sf(t2.text, e2, i2);
return this.bidiCache.push(new gs(t2.from, t2.to, e2, i2, true, s)), s;
}
/**
Check whether the editor has focus.
*/
get hasFocus() {
var t2;
return (this.dom.ownerDocument.hasFocus() || C.safari && ((t2 = this.inputState) === null || t2 === void 0 ? void 0 : t2.lastContextMenu) > Date.now() - 3e4) && this.root.activeElement == this.contentDOM;
}
/**
Put focus on the editor.
*/
focus() {
this.observer.ignore(() => {
kl(this.contentDOM), this.docView.updateSelection();
});
}
/**
Update the [root](https://codemirror.net/6/docs/ref/##view.EditorViewConfig.root) in which the editor lives. This is only
necessary when moving the editor's existing DOM to a new window or shadow root.
*/
setRoot(t2) {
this._root != t2 && (this._root = t2, this.observer.setWindow((t2.nodeType == 9 ? t2 : t2.ownerDocument).defaultView || window), this.mountStyles());
}
/**
Clean up this editor view, removing its element from the
document, unregistering event handlers, and notifying
plugins. The view instance can no longer be used after
calling this.
*/
destroy() {
for (let t2 of this.plugins)
t2.destroy(this);
this.plugins = [], this.inputState.destroy(), this.dom.remove(), this.observer.destroy(), this.measureScheduled > -1 && this.win.cancelAnimationFrame(this.measureScheduled), this.destroyed = true;
}
/**
Returns an effect that can be
[added](https://codemirror.net/6/docs/ref/#state.TransactionSpec.effects) to a transaction to
cause it to scroll the given position or range into view.
*/
static scrollIntoView(t2, e2 = {}) {
return Ii.of(new qe(typeof t2 == "number" ? b$1.cursor(t2) : t2, e2.y, e2.x, e2.yMargin, e2.xMargin));
}
/**
Return an effect that resets the editor to its current (at the
time this method was called) scroll position. Note that this
only affects the editor's own scrollable element, not parents.
See also
[`EditorViewConfig.scrollTo`](https://codemirror.net/6/docs/ref/#view.EditorViewConfig.scrollTo).
The effect should be used with a document identical to the one
it was created for. Failing to do so is not an error, but may
not scroll to the expected position. You can
[map](https://codemirror.net/6/docs/ref/#state.StateEffect.map) the effect to account for changes.
*/
scrollSnapshot() {
let { scrollTop: t2, scrollLeft: e2 } = this.scrollDOM, i2 = this.viewState.scrollAnchorAt(t2);
return Ii.of(new qe(b$1.cursor(i2.from), "start", "start", i2.top - t2, e2, true));
}
/**
Returns an extension that can be used to add DOM event handlers.
The value should be an object mapping event names to handler
functions. For any given event, such functions are ordered by
extension precedence, and the first handler to return true will
be assumed to have handled that event, and no other handlers or
built-in behavior will be activated for it. These are registered
on the [content element](https://codemirror.net/6/docs/ref/#view.EditorView.contentDOM), except
for `scroll` handlers, which will be called any time the
editor's [scroll element](https://codemirror.net/6/docs/ref/#view.EditorView.scrollDOM) or one of
its parent nodes is scrolled.
*/
static domEventHandlers(t2) {
return yt.define(() => ({}), { eventHandlers: t2 });
}
/**
Create an extension that registers DOM event observers. Contrary
to event [handlers](https://codemirror.net/6/docs/ref/#view.EditorView^domEventHandlers),
observers can't be prevented from running by a higher-precedence
handler returning true. They also don't prevent other handlers
and observers from running when they return true, and should not
call `preventDefault`.
*/
static domEventObservers(t2) {
return yt.define(() => ({}), { eventObservers: t2 });
}
/**
Create a theme extension. The first argument can be a
[`style-mod`](https://github.com/marijnh/style-mod#documentation)
style spec providing the styles for the theme. These will be
prefixed with a generated class for the style.
Because the selectors will be prefixed with a scope class, rule
that directly match the editor's [wrapper
element](https://codemirror.net/6/docs/ref/#view.EditorView.dom)—to which the scope class will be
added—need to be explicitly differentiated by adding an `&` to
the selector for that element—for example
`&.cm-focused`.
When `dark` is set to true, the theme will be marked as dark,
which will cause the `&dark` rules from [base
themes](https://codemirror.net/6/docs/ref/#view.EditorView^baseTheme) to be used (as opposed to
`&light` when a light theme is active).
*/
static theme(t2, e2) {
let i2 = we.newName(), s = [zi.of(i2), ai.of(Rn(`.${i2}`, t2))];
return e2 && e2.dark && s.push(Pn.of(true)), s;
}
/**
Create an extension that adds styles to the base theme. Like
with [`theme`](https://codemirror.net/6/docs/ref/#view.EditorView^theme), use `&` to indicate the
place of the editor wrapper element when directly targeting
that. You can also use `&dark` or `&light` instead to only
target editors with a dark or light theme.
*/
static baseTheme(t2) {
return Qn.lowest(ai.of(Rn("." + Bn, t2, ah)));
}
/**
Retrieve an editor view instance from the view's DOM
representation.
*/
static findFromDOM(t2) {
var e2;
let i2 = t2.querySelector(".cm-content"), s = i2 && q$1.get(i2) || q$1.get(t2);
return ((e2 = s == null ? void 0 : s.rootView) === null || e2 === void 0 ? void 0 : e2.view) || null;
}
}
T.styleModule = ai;
T.inputHandler = Il;
T.focusChangeEffect = Vl;
T.perLineTextDirection = Hl;
T.exceptionSink = Nl;
T.updateListener = Cn;
T.editable = Bs;
T.mouseSelectionStyle = El;
T.dragMovesSelection = Ll;
T.clickAddsSelectionRange = Rl;
T.decorations = xi;
T.atomicRanges = ir;
T.bidiIsolatedRanges = Fl;
T.scrollMargins = _l;
T.darkTheme = Pn;
T.cspNonce = /* @__PURE__ */ O$3.define({ combine: (n2) => n2.length ? n2[0] : "" });
T.contentAttributes = er;
T.editorAttributes = $l;
T.lineWrapping = /* @__PURE__ */ T.contentAttributes.of({ class: "cm-lineWrapping" });
T.announce = /* @__PURE__ */ z$2.define();
const Mu = 4096, ho = {};
class gs {
constructor(t2, e2, i2, s, r2, o) {
this.from = t2, this.to = e2, this.dir = i2, this.isolates = s, this.fresh = r2, this.order = o;
}
static update(t2, e2) {
if (e2.empty && !t2.some((r2) => r2.fresh))
return t2;
let i2 = [], s = t2.length ? t2[t2.length - 1].dir : tt.LTR;
for (let r2 = Math.max(0, t2.length - 10); r2 < t2.length; r2++) {
let o = t2[r2];
o.dir == s && !e2.touchesRange(o.from, o.to) && i2.push(new gs(e2.mapPos(o.from, 1), e2.mapPos(o.to, -1), o.dir, o.isolates, false, o.order));
}
return i2;
}
}
function ao(n2, t2, e2) {
for (let i2 = n2.state.facet(t2), s = i2.length - 1; s >= 0; s--) {
let r2 = i2[s], o = typeof r2 == "function" ? r2(n2) : r2;
o && xn(o, e2);
}
return e2;
}
const Tu = C.mac ? "mac" : C.windows ? "win" : C.linux ? "linux" : "key";
function Du(n2, t2) {
const e2 = n2.split(/-(?!$)/);
let i2 = e2[e2.length - 1];
i2 == "Space" && (i2 = " ");
let s, r2, o, l;
for (let h2 = 0; h2 < e2.length - 1; ++h2) {
const a2 = e2[h2];
if (/^(cmd|meta|m)$/i.test(a2))
l = true;
else if (/^a(lt)?$/i.test(a2))
s = true;
else if (/^(c|ctrl|control)$/i.test(a2))
r2 = true;
else if (/^s(hift)?$/i.test(a2))
o = true;
else if (/^mod$/i.test(a2))
t2 == "mac" ? l = true : r2 = true;
else
throw new Error("Unrecognized modifier name: " + a2);
}
return s && (i2 = "Alt-" + i2), r2 && (i2 = "Ctrl-" + i2), l && (i2 = "Meta-" + i2), o && (i2 = "Shift-" + i2), i2;
}
function Wi(n2, t2, e2) {
return t2.altKey && (n2 = "Alt-" + n2), t2.ctrlKey && (n2 = "Ctrl-" + n2), t2.metaKey && (n2 = "Meta-" + n2), e2 !== false && t2.shiftKey && (n2 = "Shift-" + n2), n2;
}
const Pu = /* @__PURE__ */ Qn.default(/* @__PURE__ */ T.domEventHandlers({
keydown(n2, t2) {
return Eu(Bu(t2.state), n2, t2, "editor");
}
})), fh = /* @__PURE__ */ O$3.define({ enables: Pu }), co = /* @__PURE__ */ new WeakMap();
function Bu(n2) {
let t2 = n2.facet(fh), e2 = co.get(t2);
return e2 || co.set(t2, e2 = Lu(t2.reduce((i2, s) => i2.concat(s), []))), e2;
}
let ae = null;
const Ru = 4e3;
function Lu(n2, t2 = Tu) {
let e2 = /* @__PURE__ */ Object.create(null), i2 = /* @__PURE__ */ Object.create(null), s = (o, l) => {
let h2 = i2[o];
if (h2 == null)
i2[o] = l;
else if (h2 != l)
throw new Error("Key binding " + o + " is used both as a regular binding and as a multi-stroke prefix");
}, r2 = (o, l, h2, a2, c2) => {
var f2, u2;
let d2 = e2[o] || (e2[o] = /* @__PURE__ */ Object.create(null)), p2 = l.split(/ (?!$)/).map((y2) => Du(y2, t2));
for (let y2 = 1; y2 < p2.length; y2++) {
let x2 = p2.slice(0, y2).join(" ");
s(x2, true), d2[x2] || (d2[x2] = {
preventDefault: true,
stopPropagation: false,
run: [(S2) => {
let v2 = ae = { view: S2, prefix: x2, scope: o };
return setTimeout(() => {
ae == v2 && (ae = null);
}, Ru), true;
}]
});
}
let m = p2.join(" ");
s(m, false);
let g = d2[m] || (d2[m] = {
preventDefault: false,
stopPropagation: false,
run: ((u2 = (f2 = d2._any) === null || f2 === void 0 ? void 0 : f2.run) === null || u2 === void 0 ? void 0 : u2.slice()) || []
});
h2 && g.run.push(h2), a2 && (g.preventDefault = true), c2 && (g.stopPropagation = true);
};
for (let o of n2) {
let l = o.scope ? o.scope.split(" ") : ["editor"];
if (o.any)
for (let a2 of l) {
let c2 = e2[a2] || (e2[a2] = /* @__PURE__ */ Object.create(null));
c2._any || (c2._any = { preventDefault: false, stopPropagation: false, run: [] });
for (let f2 in c2)
c2[f2].run.push(o.any);
}
let h2 = o[t2] || o.key;
if (h2)
for (let a2 of l)
r2(a2, h2, o.run, o.preventDefault, o.stopPropagation), o.shift && r2(a2, "Shift-" + h2, o.shift, o.preventDefault, o.stopPropagation);
}
return e2;
}
function Eu(n2, t2, e2, i2) {
let s = tf(t2), r2 = di(s, 0), o = nn(r2) == s.length && s != " ", l = "", h2 = false, a2 = false, c2 = false;
ae && ae.view == e2 && ae.scope == i2 && (l = ae.prefix + " ", Xl.indexOf(t2.keyCode) < 0 && (a2 = true, ae = null));
let f2 = /* @__PURE__ */ new Set(), u2 = (g) => {
if (g) {
for (let y2 of g.run)
if (!f2.has(y2) && (f2.add(y2), y2(e2, t2)))
return g.stopPropagation && (c2 = true), true;
g.preventDefault && (g.stopPropagation && (c2 = true), a2 = true);
}
return false;
}, d2 = n2[i2], p2, m;
return d2 && (u2(d2[l + Wi(s, t2, !o)]) ? h2 = true : o && (t2.altKey || t2.metaKey || t2.ctrlKey) && // Ctrl-Alt may be used for AltGr on Windows
!(C.windows && t2.ctrlKey && t2.altKey) && (p2 = ye[t2.keyCode]) && p2 != s ? (u2(d2[l + Wi(p2, t2, true)]) || t2.shiftKey && (m = yi[t2.keyCode]) != s && m != p2 && u2(d2[l + Wi(m, t2, false)])) && (h2 = true) : o && t2.shiftKey && u2(d2[l + Wi(s, t2, true)]) && (h2 = true), !h2 && u2(d2._any) && (h2 = true)), a2 && (h2 = true), h2 && c2 && t2.stopPropagation(), h2;
}
function fo(n2, t2, e2, i2, s) {
t2.lastIndex = 0;
for (let r2 = n2.iterRange(e2, i2), o = e2, l; !r2.next().done; o += r2.value.length)
if (!r2.lineBreak)
for (; l = t2.exec(r2.value); )
s(o + l.index, l);
}
function Vu(n2, t2) {
let e2 = n2.visibleRanges;
if (e2.length == 1 && e2[0].from == n2.viewport.from && e2[0].to == n2.viewport.to)
return e2;
let i2 = [];
for (let { from: s, to: r2 } of e2)
s = Math.max(n2.state.doc.lineAt(s).from, s - t2), r2 = Math.min(n2.state.doc.lineAt(r2).to, r2 + t2), i2.length && i2[i2.length - 1].to >= s ? i2[i2.length - 1].to = r2 : i2.push({ from: s, to: r2 });
return i2;
}
class Hu {
/**
Create a decorator.
*/
constructor(t2) {
const { regexp: e2, decoration: i2, decorate: s, boundary: r2, maxLength: o = 1e3 } = t2;
if (!e2.global)
throw new RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");
if (this.regexp = e2, s)
this.addMatch = (l, h2, a2, c2) => s(c2, a2, a2 + l[0].length, l, h2);
else if (typeof i2 == "function")
this.addMatch = (l, h2, a2, c2) => {
let f2 = i2(l, h2, a2);
f2 && c2(a2, a2 + l[0].length, f2);
};
else if (i2)
this.addMatch = (l, h2, a2, c2) => c2(a2, a2 + l[0].length, i2);
else
throw new RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");
this.boundary = r2, this.maxLength = o;
}
/**
Compute the full set of decorations for matches in the given
view's viewport. You'll want to call this when initializing your
plugin.
*/
createDeco(t2) {
let e2 = new Ee(), i2 = e2.add.bind(e2);
for (let { from: s, to: r2 } of Vu(t2, this.maxLength))
fo(t2.state.doc, this.regexp, s, r2, (o, l) => this.addMatch(l, t2, o, i2));
return e2.finish();
}
/**
Update a set of decorations for a view update. `deco` _must_ be
the set of decorations produced by _this_ `MatchDecorator` for
the view state before the update.
*/
updateDeco(t2, e2) {
let i2 = 1e9, s = -1;
return t2.docChanged && t2.changes.iterChanges((r2, o, l, h2) => {
h2 > t2.view.viewport.from && l < t2.view.viewport.to && (i2 = Math.min(l, i2), s = Math.max(h2, s));
}), t2.viewportChanged || s - i2 > 1e3 ? this.createDeco(t2.view) : s > -1 ? this.updateRange(t2.view, e2.map(t2.changes), i2, s) : e2;
}
updateRange(t2, e2, i2, s) {
for (let r2 of t2.visibleRanges) {
let o = Math.max(r2.from, i2), l = Math.min(r2.to, s);
if (l > o) {
let h2 = t2.state.doc.lineAt(o), a2 = h2.to < l ? t2.state.doc.lineAt(l) : h2, c2 = Math.max(r2.from, h2.from), f2 = Math.min(r2.to, a2.to);
if (this.boundary) {
for (; o > h2.from; o--)
if (this.boundary.test(h2.text[o - 1 - h2.from])) {
c2 = o;
break;
}
for (; l < a2.to; l++)
if (this.boundary.test(a2.text[l - a2.from])) {
f2 = l;
break;
}
}
let u2 = [], d2, p2 = (m, g, y2) => u2.push(y2.range(m, g));
if (h2 == a2)
for (this.regexp.lastIndex = c2 - h2.from; (d2 = this.regexp.exec(h2.text)) && d2.index < f2 - h2.from; )
this.addMatch(d2, t2, d2.index + h2.from, p2);
else
fo(t2.state.doc, this.regexp, c2, f2, (m, g) => this.addMatch(g, t2, m, p2));
e2 = e2.update({ filterFrom: c2, filterTo: f2, filter: (m, g) => m < c2 || g > f2, add: u2 });
}
}
return e2;
}
}
const Ln = /x/.unicode != null ? "gu" : "g", $u = /* @__PURE__ */ new RegExp(`[\0-\b
--Ÿ­؜\u2028\u2029\uFEFF-]`, Ln), Fu = {
0: "null",
7: "bell",
8: "backspace",
10: "newline",
11: "vertical tab",
13: "carriage return",
27: "escape",
8203: "zero width space",
8204: "zero width non-joiner",
8205: "zero width joiner",
8206: "left-to-right mark",
8207: "right-to-left mark",
8232: "line separator",
8237: "left-to-right override",
8238: "right-to-left override",
8294: "left-to-right isolate",
8295: "right-to-left isolate",
8297: "pop directional isolate",
8233: "paragraph separator",
65279: "zero width no-break space",
65532: "object replacement"
};
let qs = null;
function _u() {
var n2;
if (qs == null && typeof document < "u" && document.body) {
let t2 = document.body.style;
qs = ((n2 = t2.tabSize) !== null && n2 !== void 0 ? n2 : t2.MozTabSize) != null;
}
return qs || false;
}
const ss = /* @__PURE__ */ O$3.define({
combine(n2) {
let t2 = Ds(n2, {
render: null,
specialChars: $u,
addSpecialChars: null
});
return (t2.replaceTabs = !_u()) && (t2.specialChars = new RegExp(" |" + t2.specialChars.source, Ln)), t2.addSpecialChars && (t2.specialChars = new RegExp(t2.specialChars.source + "|" + t2.addSpecialChars.source, Ln)), t2;
}
});
function zu(n2 = {}) {
return [ss.of(n2), Wu()];
}
let uo = null;
function Wu() {
return uo || (uo = yt.fromClass(class {
constructor(n2) {
this.view = n2, this.decorations = N$2.none, this.decorationCache = /* @__PURE__ */ Object.create(null), this.decorator = this.makeDecorator(n2.state.facet(ss)), this.decorations = this.decorator.createDeco(n2);
}
makeDecorator(n2) {
return new Hu({
regexp: n2.specialChars,
decoration: (t2, e2, i2) => {
let { doc: s } = e2.state, r2 = di(t2[0], 0);
if (r2 == 9) {
let o = s.lineAt(i2), l = e2.state.tabSize, h2 = Oi(o.text, l, i2 - o.from);
return N$2.replace({
widget: new Gu((l - h2 % l) * this.view.defaultCharacterWidth / this.view.scaleX)
});
}
return this.decorationCache[r2] || (this.decorationCache[r2] = N$2.replace({ widget: new qu(n2, r2) }));
},
boundary: n2.replaceTabs ? void 0 : /[^]/
});
}
update(n2) {
let t2 = n2.state.facet(ss);
n2.startState.facet(ss) != t2 ? (this.decorator = this.makeDecorator(t2), this.decorations = this.decorator.createDeco(n2.view)) : this.decorations = this.decorator.updateDeco(n2, this.decorations);
}
}, {
decorations: (n2) => n2.decorations
}));
}
const ju = "•";
function Ku(n2) {
return n2 >= 32 ? ju : n2 == 10 ? "␤" : String.fromCharCode(9216 + n2);
}
class qu extends Se {
constructor(t2, e2) {
super(), this.options = t2, this.code = e2;
}
eq(t2) {
return t2.code == this.code;
}
toDOM(t2) {
let e2 = Ku(this.code), i2 = t2.state.phrase("Control character") + " " + (Fu[this.code] || "0x" + this.code.toString(16)), s = this.options.render && this.options.render(this.code, i2, e2);
if (s)
return s;
let r2 = document.createElement("span");
return r2.textContent = e2, r2.title = i2, r2.setAttribute("aria-label", i2), r2.className = "cm-specialChar", r2;
}
ignoreEvent() {
return false;
}
}
class Gu extends Se {
constructor(t2) {
super(), this.width = t2;
}
eq(t2) {
return t2.width == this.width;
}
toDOM() {
let t2 = document.createElement("span");
return t2.textContent = " ", t2.className = "cm-tab", t2.style.width = this.width + "px", t2;
}
ignoreEvent() {
return false;
}
}
function Uu() {
return Qu;
}
const Yu = /* @__PURE__ */ N$2.line({ class: "cm-activeLine" }), Qu = /* @__PURE__ */ yt.fromClass(class {
constructor(n2) {
this.decorations = this.getDeco(n2);
}
update(n2) {
(n2.docChanged || n2.selectionSet) && (this.decorations = this.getDeco(n2.view));
}
getDeco(n2) {
let t2 = -1, e2 = [];
for (let i2 of n2.state.selection.ranges) {
let s = n2.lineBlockAt(i2.head);
s.from > t2 && (e2.push(Yu.range(s.from)), t2 = s.from);
}
return N$2.set(e2);
}
}, {
decorations: (n2) => n2.decorations
}), ni = "-10000px";
class uh {
constructor(t2, e2, i2) {
this.facet = e2, this.createTooltipView = i2, this.input = t2.state.facet(e2), this.tooltips = this.input.filter((s) => s), this.tooltipViews = this.tooltips.map(i2);
}
update(t2, e2) {
var i2;
let s = t2.state.facet(this.facet), r2 = s.filter((h2) => h2);
if (s === this.input) {
for (let h2 of this.tooltipViews)
h2.update && h2.update(t2);
return false;
}
let o = [], l = e2 ? [] : null;
for (let h2 = 0; h2 < r2.length; h2++) {
let a2 = r2[h2], c2 = -1;
if (a2) {
for (let f2 = 0; f2 < this.tooltips.length; f2++) {
let u2 = this.tooltips[f2];
u2 && u2.create == a2.create && (c2 = f2);
}
if (c2 < 0)
o[h2] = this.createTooltipView(a2), l && (l[h2] = !!a2.above);
else {
let f2 = o[h2] = this.tooltipViews[c2];
l && (l[h2] = e2[c2]), f2.update && f2.update(t2);
}
}
}
for (let h2 of this.tooltipViews)
o.indexOf(h2) < 0 && (h2.dom.remove(), (i2 = h2.destroy) === null || i2 === void 0 || i2.call(h2));
return e2 && (l.forEach((h2, a2) => e2[a2] = h2), e2.length = l.length), this.input = s, this.tooltips = r2, this.tooltipViews = o, true;
}
}
function Ju(n2) {
let { win: t2 } = n2;
return { top: 0, left: 0, bottom: t2.innerHeight, right: t2.innerWidth };
}
const Gs = /* @__PURE__ */ O$3.define({
combine: (n2) => {
var t2, e2, i2;
return {
position: C.ios ? "absolute" : ((t2 = n2.find((s) => s.position)) === null || t2 === void 0 ? void 0 : t2.position) || "fixed",
parent: ((e2 = n2.find((s) => s.parent)) === null || e2 === void 0 ? void 0 : e2.parent) || null,
tooltipSpace: ((i2 = n2.find((s) => s.tooltipSpace)) === null || i2 === void 0 ? void 0 : i2.tooltipSpace) || Ju
};
}
}), po = /* @__PURE__ */ new WeakMap(), Xu = /* @__PURE__ */ yt.fromClass(class {
constructor(n2) {
this.view = n2, this.above = [], this.inView = true, this.madeAbsolute = false, this.lastTransaction = 0, this.measureTimeout = -1;
let t2 = n2.state.facet(Gs);
this.position = t2.position, this.parent = t2.parent, this.classes = n2.themeClasses, this.createContainer(), this.measureReq = { read: this.readMeasure.bind(this), write: this.writeMeasure.bind(this), key: this }, this.manager = new uh(n2, dh, (e2) => this.createTooltip(e2)), this.intersectionObserver = typeof IntersectionObserver == "function" ? new IntersectionObserver((e2) => {
Date.now() > this.lastTransaction - 50 && e2.length > 0 && e2[e2.length - 1].intersectionRatio < 1 && this.measureSoon();
}, { threshold: [1] }) : null, this.observeIntersection(), n2.win.addEventListener("resize", this.measureSoon = this.measureSoon.bind(this)), this.maybeMeasure();
}
createContainer() {
this.parent ? (this.container = document.createElement("div"), this.container.style.position = "relative", this.container.className = this.view.themeClasses, this.parent.appendChild(this.container)) : this.container = this.view.dom;
}
observeIntersection() {
if (this.intersectionObserver) {
this.intersectionObserver.disconnect();
for (let n2 of this.manager.tooltipViews)
this.intersectionObserver.observe(n2.dom);
}
}
measureSoon() {
this.measureTimeout < 0 && (this.measureTimeout = setTimeout(() => {
this.measureTimeout = -1, this.maybeMeasure();
}, 50));
}
update(n2) {
n2.transactions.length && (this.lastTransaction = Date.now());
let t2 = this.manager.update(n2, this.above);
t2 && this.observeIntersection();
let e2 = t2 || n2.geometryChanged, i2 = n2.state.facet(Gs);
if (i2.position != this.position && !this.madeAbsolute) {
this.position = i2.position;
for (let s of this.manager.tooltipViews)
s.dom.style.position = this.position;
e2 = true;
}
if (i2.parent != this.parent) {
this.parent && this.container.remove(), this.parent = i2.parent, this.createContainer();
for (let s of this.manager.tooltipViews)
this.container.appendChild(s.dom);
e2 = true;
} else
this.parent && this.view.themeClasses != this.classes && (this.classes = this.container.className = this.view.themeClasses);
e2 && this.maybeMeasure();
}
createTooltip(n2) {
let t2 = n2.create(this.view);
if (t2.dom.classList.add("cm-tooltip"), n2.arrow && !t2.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")) {
let e2 = document.createElement("div");
e2.className = "cm-tooltip-arrow", t2.dom.appendChild(e2);
}
return t2.dom.style.position = this.position, t2.dom.style.top = ni, t2.dom.style.left = "0px", this.container.appendChild(t2.dom), t2.mount && t2.mount(this.view), t2;
}
destroy() {
var n2, t2;
this.view.win.removeEventListener("resize", this.measureSoon);
for (let e2 of this.manager.tooltipViews)
e2.dom.remove(), (n2 = e2.destroy) === null || n2 === void 0 || n2.call(e2);
this.parent && this.container.remove(), (t2 = this.intersectionObserver) === null || t2 === void 0 || t2.disconnect(), clearTimeout(this.measureTimeout);
}
readMeasure() {
let n2 = this.view.dom.getBoundingClientRect(), t2 = 1, e2 = 1, i2 = false;
if (this.position == "fixed" && this.manager.tooltipViews.length) {
let { dom: s } = this.manager.tooltipViews[0];
if (C.gecko)
i2 = s.offsetParent != this.container.ownerDocument.body;
else if (this.view.scaleX != 1 || this.view.scaleY != 1)
i2 = true;
else if (s.style.top == ni && s.style.left == "0px") {
let r2 = s.getBoundingClientRect();
i2 = Math.abs(r2.top + 1e4) > 1 || Math.abs(r2.left) > 1;
}
}
if (i2 || this.position == "absolute")
if (this.parent) {
let s = this.parent.getBoundingClientRect();
s.width && s.height && (t2 = s.width / this.parent.offsetWidth, e2 = s.height / this.parent.offsetHeight);
} else
({ scaleX: t2, scaleY: e2 } = this.view.viewState);
return {
editor: n2,
parent: this.parent ? this.container.getBoundingClientRect() : n2,
pos: this.manager.tooltips.map((s, r2) => {
let o = this.manager.tooltipViews[r2];
return o.getCoords ? o.getCoords(s.pos) : this.view.coordsAtPos(s.pos);
}),
size: this.manager.tooltipViews.map(({ dom: s }) => s.getBoundingClientRect()),
space: this.view.state.facet(Gs).tooltipSpace(this.view),
scaleX: t2,
scaleY: e2,
makeAbsolute: i2
};
}
writeMeasure(n2) {
var t2;
if (n2.makeAbsolute) {
this.madeAbsolute = true, this.position = "absolute";
for (let l of this.manager.tooltipViews)
l.dom.style.position = "absolute";
}
let { editor: e2, space: i2, scaleX: s, scaleY: r2 } = n2, o = [];
for (let l = 0; l < this.manager.tooltips.length; l++) {
let h2 = this.manager.tooltips[l], a2 = this.manager.tooltipViews[l], { dom: c2 } = a2, f2 = n2.pos[l], u2 = n2.size[l];
if (!f2 || f2.bottom <= Math.max(e2.top, i2.top) || f2.top >= Math.min(e2.bottom, i2.bottom) || f2.right < Math.max(e2.left, i2.left) - 0.1 || f2.left > Math.min(e2.right, i2.right) + 0.1) {
c2.style.top = ni;
continue;
}
let d2 = h2.arrow ? a2.dom.querySelector(".cm-tooltip-arrow") : null, p2 = d2 ? 7 : 0, m = u2.right - u2.left, g = (t2 = po.get(a2)) !== null && t2 !== void 0 ? t2 : u2.bottom - u2.top, y2 = a2.offset || td, x2 = this.view.textDirection == tt.LTR, S2 = u2.width > i2.right - i2.left ? x2 ? i2.left : i2.right - u2.width : x2 ? Math.min(f2.left - (d2 ? 14 : 0) + y2.x, i2.right - m) : Math.max(i2.left, f2.left - m + (d2 ? 14 : 0) - y2.x), v2 = this.above[l];
!h2.strictSide && (v2 ? f2.top - (u2.bottom - u2.top) - y2.y < i2.top : f2.bottom + (u2.bottom - u2.top) + y2.y > i2.bottom) && v2 == i2.bottom - f2.bottom > f2.top - i2.top && (v2 = this.above[l] = !v2);
let A2 = (v2 ? f2.top - i2.top : i2.bottom - f2.bottom) - p2;
if (A2 < g && a2.resize !== false) {
if (A2 < this.view.defaultLineHeight) {
c2.style.top = ni;
continue;
}
po.set(a2, g), c2.style.height = (g = A2) / r2 + "px";
} else
c2.style.height && (c2.style.height = "");
let P2 = v2 ? f2.top - g - p2 - y2.y : f2.bottom + p2 + y2.y, M2 = S2 + m;
if (a2.overlap !== true)
for (let I2 of o)
I2.left < M2 && I2.right > S2 && I2.top < P2 + g && I2.bottom > P2 && (P2 = v2 ? I2.top - g - 2 - p2 : I2.bottom + p2 + 2);
if (this.position == "absolute" ? (c2.style.top = (P2 - n2.parent.top) / r2 + "px", c2.style.left = (S2 - n2.parent.left) / s + "px") : (c2.style.top = P2 / r2 + "px", c2.style.left = S2 / s + "px"), d2) {
let I2 = f2.left + (x2 ? y2.x : -y2.x) - (S2 + 14 - 7);
d2.style.left = I2 / s + "px";
}
a2.overlap !== true && o.push({ left: S2, top: P2, right: M2, bottom: P2 + g }), c2.classList.toggle("cm-tooltip-above", v2), c2.classList.toggle("cm-tooltip-below", !v2), a2.positioned && a2.positioned(n2.space);
}
}
maybeMeasure() {
if (this.manager.tooltips.length && (this.view.inView && this.view.requestMeasure(this.measureReq), this.inView != this.view.inView && (this.inView = this.view.inView, !this.inView)))
for (let n2 of this.manager.tooltipViews)
n2.dom.style.top = ni;
}
}, {
eventObservers: {
scroll() {
this.maybeMeasure();
}
}
}), Zu = /* @__PURE__ */ T.baseTheme({
".cm-tooltip": {
zIndex: 100,
boxSizing: "border-box"
},
"&light .cm-tooltip": {
border: "1px solid #bbb",
backgroundColor: "#f5f5f5"
},
"&light .cm-tooltip-section:not(:first-child)": {
borderTop: "1px solid #bbb"
},
"&dark .cm-tooltip": {
backgroundColor: "#333338",
color: "white"
},
".cm-tooltip-arrow": {
height: "7px",
width: `${7 * 2}px`,
position: "absolute",
zIndex: -1,
overflow: "hidden",
"&:before, &:after": {
content: "''",
position: "absolute",
width: 0,
height: 0,
borderLeft: "7px solid transparent",
borderRight: "7px solid transparent"
},
".cm-tooltip-above &": {
bottom: "-7px",
"&:before": {
borderTop: "7px solid #bbb"
},
"&:after": {
borderTop: "7px solid #f5f5f5",
bottom: "1px"
}
},
".cm-tooltip-below &": {
top: "-7px",
"&:before": {
borderBottom: "7px solid #bbb"
},
"&:after": {
borderBottom: "7px solid #f5f5f5",
top: "1px"
}
}
},
"&dark .cm-tooltip .cm-tooltip-arrow": {
"&:before": {
borderTopColor: "#333338",
borderBottomColor: "#333338"
},
"&:after": {
borderTopColor: "transparent",
borderBottomColor: "transparent"
}
}
}), td = { x: 0, y: 0 }, dh = /* @__PURE__ */ O$3.define({
enables: [Xu, Zu]
}), ms = /* @__PURE__ */ O$3.define();
class nr {
// Needs to be static so that host tooltip instances always match
static create(t2) {
return new nr(t2);
}
constructor(t2) {
this.view = t2, this.mounted = false, this.dom = document.createElement("div"), this.dom.classList.add("cm-tooltip-hover"), this.manager = new uh(t2, ms, (e2) => this.createHostedView(e2));
}
createHostedView(t2) {
let e2 = t2.create(this.view);
return e2.dom.classList.add("cm-tooltip-section"), this.dom.appendChild(e2.dom), this.mounted && e2.mount && e2.mount(this.view), e2;
}
mount(t2) {
for (let e2 of this.manager.tooltipViews)
e2.mount && e2.mount(t2);
this.mounted = true;
}
positioned(t2) {
for (let e2 of this.manager.tooltipViews)
e2.positioned && e2.positioned(t2);
}
update(t2) {
this.manager.update(t2);
}
destroy() {
var t2;
for (let e2 of this.manager.tooltipViews)
(t2 = e2.destroy) === null || t2 === void 0 || t2.call(e2);
}
passProp(t2) {
let e2;
for (let i2 of this.manager.tooltipViews) {
let s = i2[t2];
if (s !== void 0) {
if (e2 === void 0)
e2 = s;
else if (e2 !== s)
return;
}
}
return e2;
}
get offset() {
return this.passProp("offset");
}
get getCoords() {
return this.passProp("getCoords");
}
get overlap() {
return this.passProp("overlap");
}
get resize() {
return this.passProp("resize");
}
}
const ed = /* @__PURE__ */ dh.compute([ms], (n2) => {
let t2 = n2.facet(ms).filter((e2) => e2);
return t2.length === 0 ? null : {
pos: Math.min(...t2.map((e2) => e2.pos)),
end: Math.max(...t2.filter((e2) => e2.end != null).map((e2) => e2.end)),
create: nr.create,
above: t2[0].above,
arrow: t2.some((e2) => e2.arrow)
};
});
class id {
constructor(t2, e2, i2, s, r2) {
this.view = t2, this.source = e2, this.field = i2, this.setHover = s, this.hoverTime = r2, this.hoverTimeout = -1, this.restartTimeout = -1, this.pending = null, this.lastMove = { x: 0, y: 0, target: t2.dom, time: 0 }, this.checkHover = this.checkHover.bind(this), t2.dom.addEventListener("mouseleave", this.mouseleave = this.mouseleave.bind(this)), t2.dom.addEventListener("mousemove", this.mousemove = this.mousemove.bind(this));
}
update() {
this.pending && (this.pending = null, clearTimeout(this.restartTimeout), this.restartTimeout = setTimeout(() => this.startHover(), 20));
}
get active() {
return this.view.state.field(this.field);
}
checkHover() {
if (this.hoverTimeout = -1, this.active)
return;
let t2 = Date.now() - this.lastMove.time;
t2 < this.hoverTime ? this.hoverTimeout = setTimeout(this.checkHover, this.hoverTime - t2) : this.startHover();
}
startHover() {
clearTimeout(this.restartTimeout);
let { view: t2, lastMove: e2 } = this, i2 = t2.docView.nearest(e2.target);
if (!i2)
return;
let s, r2 = 1;
if (i2 instanceof fe)
s = i2.posAtStart;
else {
if (s = t2.posAtCoords(e2), s == null)
return;
let l = t2.coordsAtPos(s);
if (!l || e2.y < l.top || e2.y > l.bottom || e2.x < l.left - t2.defaultCharacterWidth || e2.x > l.right + t2.defaultCharacterWidth)
return;
let h2 = t2.bidiSpans(t2.state.doc.lineAt(s)).find((c2) => c2.from <= s && c2.to >= s), a2 = h2 && h2.dir == tt.RTL ? -1 : 1;
r2 = e2.x < l.left ? -a2 : a2;
}
let o = this.source(t2, s, r2);
if (o != null && o.then) {
let l = this.pending = { pos: s };
o.then((h2) => {
this.pending == l && (this.pending = null, h2 && t2.dispatch({ effects: this.setHover.of(h2) }));
}, (h2) => ie(t2.state, h2, "hover tooltip"));
} else
o && t2.dispatch({ effects: this.setHover.of(o) });
}
mousemove(t2) {
var e2;
this.lastMove = { x: t2.clientX, y: t2.clientY, target: t2.target, time: Date.now() }, this.hoverTimeout < 0 && (this.hoverTimeout = setTimeout(this.checkHover, this.hoverTime));
let i2 = this.active;
if (i2 && !go(this.lastMove.target) || this.pending) {
let { pos: s } = i2 || this.pending, r2 = (e2 = i2 == null ? void 0 : i2.end) !== null && e2 !== void 0 ? e2 : s;
(s == r2 ? this.view.posAtCoords(this.lastMove) != s : !sd(this.view, s, r2, t2.clientX, t2.clientY)) && (this.view.dispatch({ effects: this.setHover.of(null) }), this.pending = null);
}
}
mouseleave(t2) {
clearTimeout(this.hoverTimeout), this.hoverTimeout = -1, this.active && !go(t2.relatedTarget) && this.view.dispatch({ effects: this.setHover.of(null) });
}
destroy() {
clearTimeout(this.hoverTimeout), this.view.dom.removeEventListener("mouseleave", this.mouseleave), this.view.dom.removeEventListener("mousemove", this.mousemove);
}
}
function go(n2) {
for (let t2 = n2; t2; t2 = t2.parentNode)
if (t2.nodeType == 1 && t2.classList.contains("cm-tooltip"))
return true;
return false;
}
function sd(n2, t2, e2, i2, s, r2) {
let o = n2.scrollDOM.getBoundingClientRect(), l = n2.documentTop + n2.documentPadding.top + n2.contentHeight;
if (o.left > i2 || o.right < i2 || o.top > s || Math.min(o.bottom, l) < s)
return false;
let h2 = n2.posAtCoords({ x: i2, y: s }, false);
return h2 >= t2 && h2 <= e2;
}
function nd(n2, t2 = {}) {
let e2 = z$2.define(), i2 = Ht.define({
create() {
return null;
},
update(s, r2) {
if (s && (t2.hideOnChange && (r2.docChanged || r2.selection) || t2.hideOn && t2.hideOn(r2, s)))
return null;
if (s && r2.docChanged) {
let o = r2.changes.mapPos(s.pos, -1, mt.TrackDel);
if (o == null)
return null;
let l = Object.assign(/* @__PURE__ */ Object.create(null), s);
l.pos = o, s.end != null && (l.end = r2.changes.mapPos(s.end)), s = l;
}
for (let o of r2.effects)
o.is(e2) && (s = o.value), o.is(rd) && (s = null);
return s;
},
provide: (s) => ms.from(s)
});
return [
i2,
yt.define((s) => new id(
s,
n2,
i2,
e2,
t2.hoverTime || 300
/* Hover.Time */
)),
ed
];
}
const rd = /* @__PURE__ */ z$2.define(), mo = /* @__PURE__ */ O$3.define({
combine(n2) {
let t2, e2;
for (let i2 of n2)
t2 = t2 || i2.topContainer, e2 = e2 || i2.bottomContainer;
return { topContainer: t2, bottomContainer: e2 };
}
});
function od(n2, t2) {
let e2 = n2.plugin(ph), i2 = e2 ? e2.specs.indexOf(t2) : -1;
return i2 > -1 ? e2.panels[i2] : null;
}
const ph = /* @__PURE__ */ yt.fromClass(class {
constructor(n2) {
this.input = n2.state.facet(En), this.specs = this.input.filter((e2) => e2), this.panels = this.specs.map((e2) => e2(n2));
let t2 = n2.state.facet(mo);
this.top = new ji(n2, true, t2.topContainer), this.bottom = new ji(n2, false, t2.bottomContainer), this.top.sync(this.panels.filter((e2) => e2.top)), this.bottom.sync(this.panels.filter((e2) => !e2.top));
for (let e2 of this.panels)
e2.dom.classList.add("cm-panel"), e2.mount && e2.mount();
}
update(n2) {
let t2 = n2.state.facet(mo);
this.top.container != t2.topContainer && (this.top.sync([]), this.top = new ji(n2.view, true, t2.topContainer)), this.bottom.container != t2.bottomContainer && (this.bottom.sync([]), this.bottom = new ji(n2.view, false, t2.bottomContainer)), this.top.syncClasses(), this.bottom.syncClasses();
let e2 = n2.state.facet(En);
if (e2 != this.input) {
let i2 = e2.filter((h2) => h2), s = [], r2 = [], o = [], l = [];
for (let h2 of i2) {
let a2 = this.specs.indexOf(h2), c2;
a2 < 0 ? (c2 = h2(n2.view), l.push(c2)) : (c2 = this.panels[a2], c2.update && c2.update(n2)), s.push(c2), (c2.top ? r2 : o).push(c2);
}
this.specs = i2, this.panels = s, this.top.sync(r2), this.bottom.sync(o);
for (let h2 of l)
h2.dom.classList.add("cm-panel"), h2.mount && h2.mount();
} else
for (let i2 of this.panels)
i2.update && i2.update(n2);
}
destroy() {
this.top.sync([]), this.bottom.sync([]);
}
}, {
provide: (n2) => T.scrollMargins.of((t2) => {
let e2 = t2.plugin(n2);
return e2 && { top: e2.top.scrollMargin(), bottom: e2.bottom.scrollMargin() };
})
});
class ji {
constructor(t2, e2, i2) {
this.view = t2, this.top = e2, this.container = i2, this.dom = void 0, this.classes = "", this.panels = [], this.syncClasses();
}
sync(t2) {
for (let e2 of this.panels)
e2.destroy && t2.indexOf(e2) < 0 && e2.destroy();
this.panels = t2, this.syncDOM();
}
syncDOM() {
if (this.panels.length == 0) {
this.dom && (this.dom.remove(), this.dom = void 0);
return;
}
if (!this.dom) {
this.dom = document.createElement("div"), this.dom.className = this.top ? "cm-panels cm-panels-top" : "cm-panels cm-panels-bottom", this.dom.style[this.top ? "top" : "bottom"] = "0";
let e2 = this.container || this.view.dom;
e2.insertBefore(this.dom, this.top ? e2.firstChild : null);
}
let t2 = this.dom.firstChild;
for (let e2 of this.panels)
if (e2.dom.parentNode == this.dom) {
for (; t2 != e2.dom; )
t2 = wo(t2);
t2 = t2.nextSibling;
} else
this.dom.insertBefore(e2.dom, t2);
for (; t2; )
t2 = wo(t2);
}
scrollMargin() {
return !this.dom || this.container ? 0 : Math.max(0, this.top ? this.dom.getBoundingClientRect().bottom - Math.max(0, this.view.scrollDOM.getBoundingClientRect().top) : Math.min(innerHeight, this.view.scrollDOM.getBoundingClientRect().bottom) - this.dom.getBoundingClientRect().top);
}
syncClasses() {
if (!(!this.container || this.classes == this.view.themeClasses)) {
for (let t2 of this.classes.split(" "))
t2 && this.container.classList.remove(t2);
for (let t2 of (this.classes = this.view.themeClasses).split(" "))
t2 && this.container.classList.add(t2);
}
}
}
function wo(n2) {
let t2 = n2.nextSibling;
return n2.remove(), t2;
}
const En = /* @__PURE__ */ O$3.define({
enables: ph
});
class ke extends Qe {
/**
@internal
*/
compare(t2) {
return this == t2 || this.constructor == t2.constructor && this.eq(t2);
}
/**
Compare this marker to another marker of the same type.
*/
eq(t2) {
return false;
}
/**
Called if the marker has a `toDOM` method and its representation
was removed from a gutter.
*/
destroy(t2) {
}
}
ke.prototype.elementClass = "";
ke.prototype.toDOM = void 0;
ke.prototype.mapMode = mt.TrackBefore;
ke.prototype.startSide = ke.prototype.endSide = -1;
ke.prototype.point = true;
const ns = /* @__PURE__ */ O$3.define(), ld = {
class: "",
renderEmptyElements: false,
elementStyle: "",
markers: () => F.empty,
lineMarker: () => null,
widgetMarker: () => null,
lineMarkerChange: null,
initialSpacer: null,
updateSpacer: null,
domEventHandlers: {}
}, rs = /* @__PURE__ */ O$3.define();
function hd(n2) {
return [ad(), rs.of(Object.assign(Object.assign({}, ld), n2))];
}
const Nn = /* @__PURE__ */ O$3.define({
combine: (n2) => n2.some((t2) => t2)
});
function ad(n2) {
let t2 = [
cd
];
return n2 && n2.fixed === false && t2.push(Nn.of(true)), t2;
}
const cd = /* @__PURE__ */ yt.fromClass(class {
constructor(n2) {
this.view = n2, this.prevViewport = n2.viewport, this.dom = document.createElement("div"), this.dom.className = "cm-gutters", this.dom.setAttribute("aria-hidden", "true"), this.dom.style.minHeight = this.view.contentHeight / this.view.scaleY + "px", this.gutters = n2.state.facet(rs).map((t2) => new bo(n2, t2));
for (let t2 of this.gutters)
this.dom.appendChild(t2.dom);
this.fixed = !n2.state.facet(Nn), this.fixed && (this.dom.style.position = "sticky"), this.syncGutters(false), n2.scrollDOM.insertBefore(this.dom, n2.contentDOM);
}
update(n2) {
if (this.updateGutters(n2)) {
let t2 = this.prevViewport, e2 = n2.view.viewport, i2 = Math.min(t2.to, e2.to) - Math.max(t2.from, e2.from);
this.syncGutters(i2 < (e2.to - e2.from) * 0.8);
}
n2.geometryChanged && (this.dom.style.minHeight = this.view.contentHeight + "px"), this.view.state.facet(Nn) != !this.fixed && (this.fixed = !this.fixed, this.dom.style.position = this.fixed ? "sticky" : ""), this.prevViewport = n2.view.viewport;
}
syncGutters(n2) {
let t2 = this.dom.nextSibling;
n2 && this.dom.remove();
let e2 = F.iter(this.view.state.facet(ns), this.view.viewport.from), i2 = [], s = this.gutters.map((r2) => new fd(r2, this.view.viewport, -this.view.documentPadding.top));
for (let r2 of this.view.viewportLineBlocks)
if (i2.length && (i2 = []), Array.isArray(r2.type)) {
let o = true;
for (let l of r2.type)
if (l.type == Lt.Text && o) {
In(e2, i2, l.from);
for (let h2 of s)
h2.line(this.view, l, i2);
o = false;
} else if (l.widget)
for (let h2 of s)
h2.widget(this.view, l);
} else if (r2.type == Lt.Text) {
In(e2, i2, r2.from);
for (let o of s)
o.line(this.view, r2, i2);
} else if (r2.widget)
for (let o of s)
o.widget(this.view, r2);
for (let r2 of s)
r2.finish();
n2 && this.view.scrollDOM.insertBefore(this.dom, t2);
}
updateGutters(n2) {
let t2 = n2.startState.facet(rs), e2 = n2.state.facet(rs), i2 = n2.docChanged || n2.heightChanged || n2.viewportChanged || !F.eq(n2.startState.facet(ns), n2.state.facet(ns), n2.view.viewport.from, n2.view.viewport.to);
if (t2 == e2)
for (let s of this.gutters)
s.update(n2) && (i2 = true);
else {
i2 = true;
let s = [];
for (let r2 of e2) {
let o = t2.indexOf(r2);
o < 0 ? s.push(new bo(this.view, r2)) : (this.gutters[o].update(n2), s.push(this.gutters[o]));
}
for (let r2 of this.gutters)
r2.dom.remove(), s.indexOf(r2) < 0 && r2.destroy();
for (let r2 of s)
this.dom.appendChild(r2.dom);
this.gutters = s;
}
return i2;
}
destroy() {
for (let n2 of this.gutters)
n2.destroy();
this.dom.remove();
}
}, {
provide: (n2) => T.scrollMargins.of((t2) => {
let e2 = t2.plugin(n2);
return !e2 || e2.gutters.length == 0 || !e2.fixed ? null : t2.textDirection == tt.LTR ? { left: e2.dom.offsetWidth * t2.scaleX } : { right: e2.dom.offsetWidth * t2.scaleX };
})
});
function yo(n2) {
return Array.isArray(n2) ? n2 : [n2];
}
function In(n2, t2, e2) {
for (; n2.value && n2.from <= e2; )
n2.from == e2 && t2.push(n2.value), n2.next();
}
class fd {
constructor(t2, e2, i2) {
this.gutter = t2, this.height = i2, this.i = 0, this.cursor = F.iter(t2.markers, e2.from);
}
addElement(t2, e2, i2) {
let { gutter: s } = this, r2 = (e2.top - this.height) / t2.scaleY, o = e2.height / t2.scaleY;
if (this.i == s.elements.length) {
let l = new gh(t2, o, r2, i2);
s.elements.push(l), s.dom.appendChild(l.dom);
} else
s.elements[this.i].update(t2, o, r2, i2);
this.height = e2.bottom, this.i++;
}
line(t2, e2, i2) {
let s = [];
In(this.cursor, s, e2.from), i2.length && (s = s.concat(i2));
let r2 = this.gutter.config.lineMarker(t2, e2, s);
r2 && s.unshift(r2);
let o = this.gutter;
s.length == 0 && !o.config.renderEmptyElements || this.addElement(t2, e2, s);
}
widget(t2, e2) {
let i2 = this.gutter.config.widgetMarker(t2, e2.widget, e2);
i2 && this.addElement(t2, e2, [i2]);
}
finish() {
let t2 = this.gutter;
for (; t2.elements.length > this.i; ) {
let e2 = t2.elements.pop();
t2.dom.removeChild(e2.dom), e2.destroy();
}
}
}
class bo {
constructor(t2, e2) {
this.view = t2, this.config = e2, this.elements = [], this.spacer = null, this.dom = document.createElement("div"), this.dom.className = "cm-gutter" + (this.config.class ? " " + this.config.class : "");
for (let i2 in e2.domEventHandlers)
this.dom.addEventListener(i2, (s) => {
let r2 = s.target, o;
if (r2 != this.dom && this.dom.contains(r2)) {
for (; r2.parentNode != this.dom; )
r2 = r2.parentNode;
let h2 = r2.getBoundingClientRect();
o = (h2.top + h2.bottom) / 2;
} else
o = s.clientY;
let l = t2.lineBlockAtHeight(o - t2.documentTop);
e2.domEventHandlers[i2](t2, l, s) && s.preventDefault();
});
this.markers = yo(e2.markers(t2)), e2.initialSpacer && (this.spacer = new gh(t2, 0, 0, [e2.initialSpacer(t2)]), this.dom.appendChild(this.spacer.dom), this.spacer.dom.style.cssText += "visibility: hidden; pointer-events: none");
}
update(t2) {
let e2 = this.markers;
if (this.markers = yo(this.config.markers(t2.view)), this.spacer && this.config.updateSpacer) {
let s = this.config.updateSpacer(this.spacer.markers[0], t2);
s != this.spacer.markers[0] && this.spacer.update(t2.view, 0, 0, [s]);
}
let i2 = t2.view.viewport;
return !F.eq(this.markers, e2, i2.from, i2.to) || (this.config.lineMarkerChange ? this.config.lineMarkerChange(t2) : false);
}
destroy() {
for (let t2 of this.elements)
t2.destroy();
}
}
class gh {
constructor(t2, e2, i2, s) {
this.height = -1, this.above = 0, this.markers = [], this.dom = document.createElement("div"), this.dom.className = "cm-gutterElement", this.update(t2, e2, i2, s);
}
update(t2, e2, i2, s) {
this.height != e2 && (this.height = e2, this.dom.style.height = e2 + "px"), this.above != i2 && (this.dom.style.marginTop = (this.above = i2) ? i2 + "px" : ""), ud(this.markers, s) || this.setMarkers(t2, s);
}
setMarkers(t2, e2) {
let i2 = "cm-gutterElement", s = this.dom.firstChild;
for (let r2 = 0, o = 0; ; ) {
let l = o, h2 = r2 < e2.length ? e2[r2++] : null, a2 = false;
if (h2) {
let c2 = h2.elementClass;
c2 && (i2 += " " + c2);
for (let f2 = o; f2 < this.markers.length; f2++)
if (this.markers[f2].compare(h2)) {
l = f2, a2 = true;
break;
}
} else
l = this.markers.length;
for (; o < l; ) {
let c2 = this.markers[o++];
if (c2.toDOM) {
c2.destroy(s);
let f2 = s.nextSibling;
s.remove(), s = f2;
}
}
if (!h2)
break;
h2.toDOM && (a2 ? s = s.nextSibling : this.dom.insertBefore(h2.toDOM(t2), s)), a2 && o++;
}
this.dom.className = i2, this.markers = e2;
}
destroy() {
this.setMarkers(null, []);
}
}
function ud(n2, t2) {
if (n2.length != t2.length)
return false;
for (let e2 = 0; e2 < n2.length; e2++)
if (!n2[e2].compare(t2[e2]))
return false;
return true;
}
const dd = /* @__PURE__ */ new class extends ke {
constructor() {
super(...arguments), this.elementClass = "cm-activeLineGutter";
}
}(), pd = /* @__PURE__ */ ns.compute(["selection"], (n2) => {
let t2 = [], e2 = -1;
for (let i2 of n2.selection.ranges) {
let s = n2.doc.lineAt(i2.head).from;
s > e2 && (e2 = s, t2.push(dd.range(s)));
}
return F.of(t2);
});
function gd() {
return pd;
}
const mh = 1024;
let md = 0;
class Us {
constructor(t2, e2) {
this.from = t2, this.to = e2;
}
}
let R$1 = class R2 {
/**
Create a new node prop type.
*/
constructor(t2 = {}) {
this.id = md++, this.perNode = !!t2.perNode, this.deserialize = t2.deserialize || (() => {
throw new Error("This node type doesn't define a deserialize function");
});
}
/**
This is meant to be used with
[`NodeSet.extend`](#common.NodeSet.extend) or
[`LRParser.configure`](#lr.ParserConfig.props) to compute
prop values for each node type in the set. Takes a [match
object](#common.NodeType^match) or function that returns undefined
if the node type doesn't get this prop, and the prop's value if
it does.
*/
add(t2) {
if (this.perNode)
throw new RangeError("Can't add per-node props to node types");
return typeof t2 != "function" && (t2 = bt.match(t2)), (e2) => {
let i2 = t2(e2);
return i2 === void 0 ? null : [this, i2];
};
}
};
R$1.closedBy = new R$1({ deserialize: (n2) => n2.split(" ") });
R$1.openedBy = new R$1({ deserialize: (n2) => n2.split(" ") });
R$1.group = new R$1({ deserialize: (n2) => n2.split(" ") });
R$1.contextHash = new R$1({ perNode: true });
R$1.lookAhead = new R$1({ perNode: true });
R$1.mounted = new R$1({ perNode: true });
class ws {
constructor(t2, e2, i2) {
this.tree = t2, this.overlay = e2, this.parser = i2;
}
/**
@internal
*/
static get(t2) {
return t2 && t2.props && t2.props[R$1.mounted.id];
}
}
const wd = /* @__PURE__ */ Object.create(null);
class bt {
/**
@internal
*/
constructor(t2, e2, i2, s = 0) {
this.name = t2, this.props = e2, this.id = i2, this.flags = s;
}
/**
Define a node type.
*/
static define(t2) {
let e2 = t2.props && t2.props.length ? /* @__PURE__ */ Object.create(null) : wd, i2 = (t2.top ? 1 : 0) | (t2.skipped ? 2 : 0) | (t2.error ? 4 : 0) | (t2.name == null ? 8 : 0), s = new bt(t2.name || "", e2, t2.id, i2);
if (t2.props) {
for (let r2 of t2.props)
if (Array.isArray(r2) || (r2 = r2(s)), r2) {
if (r2[0].perNode)
throw new RangeError("Can't store a per-node prop on a node type");
e2[r2[0].id] = r2[1];
}
}
return s;
}
/**
Retrieves a node prop for this type. Will return `undefined` if
the prop isn't present on this node.
*/
prop(t2) {
return this.props[t2.id];
}
/**
True when this is the top node of a grammar.
*/
get isTop() {
return (this.flags & 1) > 0;
}
/**
True when this node is produced by a skip rule.
*/
get isSkipped() {
return (this.flags & 2) > 0;
}
/**
Indicates whether this is an error node.
*/
get isError() {
return (this.flags & 4) > 0;
}
/**
When true, this node type doesn't correspond to a user-declared
named node, for example because it is used to cache repetition.
*/
get isAnonymous() {
return (this.flags & 8) > 0;
}
/**
Returns true when this node's name or one of its
[groups](#common.NodeProp^group) matches the given string.
*/
is(t2) {
if (typeof t2 == "string") {
if (this.name == t2)
return true;
let e2 = this.prop(R$1.group);
return e2 ? e2.indexOf(t2) > -1 : false;
}
return this.id == t2;
}
/**
Create a function from node types to arbitrary values by
specifying an object whose property names are node or
[group](#common.NodeProp^group) names. Often useful with
[`NodeProp.add`](#common.NodeProp.add). You can put multiple
names, separated by spaces, in a single property name to map
multiple node names to a single value.
*/
static match(t2) {
let e2 = /* @__PURE__ */ Object.create(null);
for (let i2 in t2)
for (let s of i2.split(" "))
e2[s] = t2[i2];
return (i2) => {
for (let s = i2.prop(R$1.group), r2 = -1; r2 < (s ? s.length : 0); r2++) {
let o = e2[r2 < 0 ? i2.name : s[r2]];
if (o)
return o;
}
};
}
}
bt.none = new bt(
"",
/* @__PURE__ */ Object.create(null),
0,
8
/* NodeFlag.Anonymous */
);
class rr {
/**
Create a set with the given types. The `id` property of each
type should correspond to its position within the array.
*/
constructor(t2) {
this.types = t2;
for (let e2 = 0; e2 < t2.length; e2++)
if (t2[e2].id != e2)
throw new RangeError("Node type ids should correspond to array positions when creating a node set");
}
/**
Create a copy of this set with some node properties added. The
arguments to this method can be created with
[`NodeProp.add`](#common.NodeProp.add).
*/
extend(...t2) {
let e2 = [];
for (let i2 of this.types) {
let s = null;
for (let r2 of t2) {
let o = r2(i2);
o && (s || (s = Object.assign({}, i2.props)), s[o[0].id] = o[1]);
}
e2.push(s ? new bt(i2.name, s, i2.id, i2.flags) : i2);
}
return new rr(e2);
}
}
const Ki = /* @__PURE__ */ new WeakMap(), ko = /* @__PURE__ */ new WeakMap();
var st;
(function(n2) {
n2[n2.ExcludeBuffers = 1] = "ExcludeBuffers", n2[n2.IncludeAnonymous = 2] = "IncludeAnonymous", n2[n2.IgnoreMounts = 4] = "IgnoreMounts", n2[n2.IgnoreOverlays = 8] = "IgnoreOverlays";
})(st || (st = {}));
class X {
/**
Construct a new tree. See also [`Tree.build`](#common.Tree^build).
*/
constructor(t2, e2, i2, s, r2) {
if (this.type = t2, this.children = e2, this.positions = i2, this.length = s, this.props = null, r2 && r2.length) {
this.props = /* @__PURE__ */ Object.create(null);
for (let [o, l] of r2)
this.props[typeof o == "number" ? o : o.id] = l;
}
}
/**
@internal
*/
toString() {
let t2 = ws.get(this);
if (t2 && !t2.overlay)
return t2.tree.toString();
let e2 = "";
for (let i2 of this.children) {
let s = i2.toString();
s && (e2 && (e2 += ","), e2 += s);
}
return this.type.name ? (/\W/.test(this.type.name) && !this.type.isError ? JSON.stringify(this.type.name) : this.type.name) + (e2.length ? "(" + e2 + ")" : "") : e2;
}
/**
Get a [tree cursor](#common.TreeCursor) positioned at the top of
the tree. Mode can be used to [control](#common.IterMode) which
nodes the cursor visits.
*/
cursor(t2 = 0) {
return new Hn(this.topNode, t2);
}
/**
Get a [tree cursor](#common.TreeCursor) pointing into this tree
at the given position and side (see
[`moveTo`](#common.TreeCursor.moveTo).
*/
cursorAt(t2, e2 = 0, i2 = 0) {
let s = Ki.get(this) || this.topNode, r2 = new Hn(s);
return r2.moveTo(t2, e2), Ki.set(this, r2._tree), r2;
}
/**
Get a [syntax node](#common.SyntaxNode) object for the top of the
tree.
*/
get topNode() {
return new Tt(this, 0, 0, null);
}
/**
Get the [syntax node](#common.SyntaxNode) at the given position.
If `side` is -1, this will move into nodes that end at the
position. If 1, it'll move into nodes that start at the
position. With 0, it'll only enter nodes that cover the position
from both sides.
Note that this will not enter
[overlays](#common.MountedTree.overlay), and you often want
[`resolveInner`](#common.Tree.resolveInner) instead.
*/
resolve(t2, e2 = 0) {
let i2 = Si(Ki.get(this) || this.topNode, t2, e2, false);
return Ki.set(this, i2), i2;
}
/**
Like [`resolve`](#common.Tree.resolve), but will enter
[overlaid](#common.MountedTree.overlay) nodes, producing a syntax node
pointing into the innermost overlaid tree at the given position
(with parent links going through all parent structure, including
the host trees).
*/
resolveInner(t2, e2 = 0) {
let i2 = Si(ko.get(this) || this.topNode, t2, e2, true);
return ko.set(this, i2), i2;
}
/**
In some situations, it can be useful to iterate through all
nodes around a position, including those in overlays that don't
directly cover the position. This method gives you an iterator
that will produce all nodes, from small to big, around the given
position.
*/
resolveStack(t2, e2 = 0) {
return kd(this, t2, e2);
}
/**
Iterate over the tree and its children, calling `enter` for any
node that touches the `from`/`to` region (if given) before
running over such a node's children, and `leave` (if given) when
leaving the node. When `enter` returns `false`, that node will
not have its children iterated over (or `leave` called).
*/
iterate(t2) {
let { enter: e2, leave: i2, from: s = 0, to: r2 = this.length } = t2, o = t2.mode || 0, l = (o & st.IncludeAnonymous) > 0;
for (let h2 = this.cursor(o | st.IncludeAnonymous); ; ) {
let a2 = false;
if (h2.from <= r2 && h2.to >= s && (!l && h2.type.isAnonymous || e2(h2) !== false)) {
if (h2.firstChild())
continue;
a2 = true;
}
for (; a2 && i2 && (l || !h2.type.isAnonymous) && i2(h2), !h2.nextSibling(); ) {
if (!h2.parent())
return;
a2 = true;
}
}
}
/**
Get the value of the given [node prop](#common.NodeProp) for this
node. Works with both per-node and per-type props.
*/
prop(t2) {
return t2.perNode ? this.props ? this.props[t2.id] : void 0 : this.type.prop(t2);
}
/**
Returns the node's [per-node props](#common.NodeProp.perNode) in a
format that can be passed to the [`Tree`](#common.Tree)
constructor.
*/
get propValues() {
let t2 = [];
if (this.props)
for (let e2 in this.props)
t2.push([+e2, this.props[e2]]);
return t2;
}
/**
Balance the direct children of this tree, producing a copy of
which may have children grouped into subtrees with type
[`NodeType.none`](#common.NodeType^none).
*/
balance(t2 = {}) {
return this.children.length <= 8 ? this : hr(bt.none, this.children, this.positions, 0, this.children.length, 0, this.length, (e2, i2, s) => new X(this.type, e2, i2, s, this.propValues), t2.makeTree || ((e2, i2, s) => new X(bt.none, e2, i2, s)));
}
/**
Build a tree from a postfix-ordered buffer of node information,
or a cursor over such a buffer.
*/
static build(t2) {
return xd(t2);
}
}
X.empty = new X(bt.none, [], [], 0);
class or {
constructor(t2, e2) {
this.buffer = t2, this.index = e2;
}
get id() {
return this.buffer[this.index - 4];
}
get start() {
return this.buffer[this.index - 3];
}
get end() {
return this.buffer[this.index - 2];
}
get size() {
return this.buffer[this.index - 1];
}
get pos() {
return this.index;
}
next() {
this.index -= 4;
}
fork() {
return new or(this.buffer, this.index);
}
}
class xe {
/**
Create a tree buffer.
*/
constructor(t2, e2, i2) {
this.buffer = t2, this.length = e2, this.set = i2;
}
/**
@internal
*/
get type() {
return bt.none;
}
/**
@internal
*/
toString() {
let t2 = [];
for (let e2 = 0; e2 < this.buffer.length; )
t2.push(this.childString(e2)), e2 = this.buffer[e2 + 3];
return t2.join(",");
}
/**
@internal
*/
childString(t2) {
let e2 = this.buffer[t2], i2 = this.buffer[t2 + 3], s = this.set.types[e2], r2 = s.name;
if (/\W/.test(r2) && !s.isError && (r2 = JSON.stringify(r2)), t2 += 4, i2 == t2)
return r2;
let o = [];
for (; t2 < i2; )
o.push(this.childString(t2)), t2 = this.buffer[t2 + 3];
return r2 + "(" + o.join(",") + ")";
}
/**
@internal
*/
findChild(t2, e2, i2, s, r2) {
let { buffer: o } = this, l = -1;
for (let h2 = t2; h2 != e2 && !(wh(r2, s, o[h2 + 1], o[h2 + 2]) && (l = h2, i2 > 0)); h2 = o[h2 + 3])
;
return l;
}
/**
@internal
*/
slice(t2, e2, i2) {
let s = this.buffer, r2 = new Uint16Array(e2 - t2), o = 0;
for (let l = t2, h2 = 0; l < e2; ) {
r2[h2++] = s[l++], r2[h2++] = s[l++] - i2;
let a2 = r2[h2++] = s[l++] - i2;
r2[h2++] = s[l++] - t2, o = Math.max(o, a2);
}
return new xe(r2, o, this.set);
}
}
function wh(n2, t2, e2, i2) {
switch (n2) {
case -2:
return e2 < t2;
case -1:
return i2 >= t2 && e2 < t2;
case 0:
return e2 < t2 && i2 > t2;
case 1:
return e2 <= t2 && i2 > t2;
case 2:
return i2 > t2;
case 4:
return true;
}
}
function Si(n2, t2, e2, i2) {
for (var s; n2.from == n2.to || (e2 < 1 ? n2.from >= t2 : n2.from > t2) || (e2 > -1 ? n2.to <= t2 : n2.to < t2); ) {
let o = !i2 && n2 instanceof Tt && n2.index < 0 ? null : n2.parent;
if (!o)
return n2;
n2 = o;
}
let r2 = i2 ? 0 : st.IgnoreOverlays;
if (i2)
for (let o = n2, l = o.parent; l; o = l, l = o.parent)
o instanceof Tt && o.index < 0 && ((s = l.enter(t2, e2, r2)) === null || s === void 0 ? void 0 : s.from) != o.from && (n2 = l);
for (; ; ) {
let o = n2.enter(t2, e2, r2);
if (!o)
return n2;
n2 = o;
}
}
class yh {
cursor(t2 = 0) {
return new Hn(this, t2);
}
getChild(t2, e2 = null, i2 = null) {
let s = xo(this, t2, e2, i2);
return s.length ? s[0] : null;
}
getChildren(t2, e2 = null, i2 = null) {
return xo(this, t2, e2, i2);
}
resolve(t2, e2 = 0) {
return Si(this, t2, e2, false);
}
resolveInner(t2, e2 = 0) {
return Si(this, t2, e2, true);
}
matchContext(t2) {
return Vn(this, t2);
}
enterUnfinishedNodesBefore(t2) {
let e2 = this.childBefore(t2), i2 = this;
for (; e2; ) {
let s = e2.lastChild;
if (!s || s.to != e2.to)
break;
s.type.isError && s.from == s.to ? (i2 = e2, e2 = s.prevSibling) : e2 = s;
}
return i2;
}
get node() {
return this;
}
get next() {
return this.parent;
}
}
class Tt extends yh {
constructor(t2, e2, i2, s) {
super(), this._tree = t2, this.from = e2, this.index = i2, this._parent = s;
}
get type() {
return this._tree.type;
}
get name() {
return this._tree.type.name;
}
get to() {
return this.from + this._tree.length;
}
nextChild(t2, e2, i2, s, r2 = 0) {
for (let o = this; ; ) {
for (let { children: l, positions: h2 } = o._tree, a2 = e2 > 0 ? l.length : -1; t2 != a2; t2 += e2) {
let c2 = l[t2], f2 = h2[t2] + o.from;
if (wh(s, i2, f2, f2 + c2.length)) {
if (c2 instanceof xe) {
if (r2 & st.ExcludeBuffers)
continue;
let u2 = c2.findChild(0, c2.buffer.length, e2, i2 - f2, s);
if (u2 > -1)
return new de(new yd(o, c2, t2, f2), null, u2);
} else if (r2 & st.IncludeAnonymous || !c2.type.isAnonymous || lr(c2)) {
let u2;
if (!(r2 & st.IgnoreMounts) && (u2 = ws.get(c2)) && !u2.overlay)
return new Tt(u2.tree, f2, t2, o);
let d2 = new Tt(c2, f2, t2, o);
return r2 & st.IncludeAnonymous || !d2.type.isAnonymous ? d2 : d2.nextChild(e2 < 0 ? c2.children.length - 1 : 0, e2, i2, s);
}
}
}
if (r2 & st.IncludeAnonymous || !o.type.isAnonymous || (o.index >= 0 ? t2 = o.index + e2 : t2 = e2 < 0 ? -1 : o._parent._tree.children.length, o = o._parent, !o))
return null;
}
}
get firstChild() {
return this.nextChild(
0,
1,
0,
4
/* Side.DontCare */
);
}
get lastChild() {
return this.nextChild(
this._tree.children.length - 1,
-1,
0,
4
/* Side.DontCare */
);
}
childAfter(t2) {
return this.nextChild(
0,
1,
t2,
2
/* Side.After */
);
}
childBefore(t2) {
return this.nextChild(
this._tree.children.length - 1,
-1,
t2,
-2
/* Side.Before */
);
}
enter(t2, e2, i2 = 0) {
let s;
if (!(i2 & st.IgnoreOverlays) && (s = ws.get(this._tree)) && s.overlay) {
let r2 = t2 - this.from;
for (let { from: o, to: l } of s.overlay)
if ((e2 > 0 ? o <= r2 : o < r2) && (e2 < 0 ? l >= r2 : l > r2))
return new Tt(s.tree, s.overlay[0].from + this.from, -1, this);
}
return this.nextChild(0, 1, t2, e2, i2);
}
nextSignificantParent() {
let t2 = this;
for (; t2.type.isAnonymous && t2._parent; )
t2 = t2._parent;
return t2;
}
get parent() {
return this._parent ? this._parent.nextSignificantParent() : null;
}
get nextSibling() {
return this._parent && this.index >= 0 ? this._parent.nextChild(
this.index + 1,
1,
0,
4
/* Side.DontCare */
) : null;
}
get prevSibling() {
return this._parent && this.index >= 0 ? this._parent.nextChild(
this.index - 1,
-1,
0,
4
/* Side.DontCare */
) : null;
}
get tree() {
return this._tree;
}
toTree() {
return this._tree;
}
/**
@internal
*/
toString() {
return this._tree.toString();
}
}
function xo(n2, t2, e2, i2) {
let s = n2.cursor(), r2 = [];
if (!s.firstChild())
return r2;
if (e2 != null) {
for (; !s.type.is(e2); )
if (!s.nextSibling())
return r2;
}
for (; ; ) {
if (i2 != null && s.type.is(i2))
return r2;
if (s.type.is(t2) && r2.push(s.node), !s.nextSibling())
return i2 == null ? r2 : [];
}
}
function Vn(n2, t2, e2 = t2.length - 1) {
for (let i2 = n2.parent; e2 >= 0; i2 = i2.parent) {
if (!i2)
return false;
if (!i2.type.isAnonymous) {
if (t2[e2] && t2[e2] != i2.name)
return false;
e2--;
}
}
return true;
}
class yd {
constructor(t2, e2, i2, s) {
this.parent = t2, this.buffer = e2, this.index = i2, this.start = s;
}
}
class de extends yh {
get name() {
return this.type.name;
}
get from() {
return this.context.start + this.context.buffer.buffer[this.index + 1];
}
get to() {
return this.context.start + this.context.buffer.buffer[this.index + 2];
}
constructor(t2, e2, i2) {
super(), this.context = t2, this._parent = e2, this.index = i2, this.type = t2.buffer.set.types[t2.buffer.buffer[i2]];
}
child(t2, e2, i2) {
let { buffer: s } = this.context, r2 = s.findChild(this.index + 4, s.buffer[this.index + 3], t2, e2 - this.context.start, i2);
return r2 < 0 ? null : new de(this.context, this, r2);
}
get firstChild() {
return this.child(
1,
0,
4
/* Side.DontCare */
);
}
get lastChild() {
return this.child(
-1,
0,
4
/* Side.DontCare */
);
}
childAfter(t2) {
return this.child(
1,
t2,
2
/* Side.After */
);
}
childBefore(t2) {
return this.child(
-1,
t2,
-2
/* Side.Before */
);
}
enter(t2, e2, i2 = 0) {
if (i2 & st.ExcludeBuffers)
return null;
let { buffer: s } = this.context, r2 = s.findChild(this.index + 4, s.buffer[this.index + 3], e2 > 0 ? 1 : -1, t2 - this.context.start, e2);
return r2 < 0 ? null : new de(this.context, this, r2);
}
get parent() {
return this._parent || this.context.parent.nextSignificantParent();
}
externalSibling(t2) {
return this._parent ? null : this.context.parent.nextChild(
this.context.index + t2,
t2,
0,
4
/* Side.DontCare */
);
}
get nextSibling() {
let { buffer: t2 } = this.context, e2 = t2.buffer[this.index + 3];
return e2 < (this._parent ? t2.buffer[this._parent.index + 3] : t2.buffer.length) ? new de(this.context, this._parent, e2) : this.externalSibling(1);
}
get prevSibling() {
let { buffer: t2 } = this.context, e2 = this._parent ? this._parent.index + 4 : 0;
return this.index == e2 ? this.externalSibling(-1) : new de(this.context, this._parent, t2.findChild(
e2,
this.index,
-1,
0,
4
/* Side.DontCare */
));
}
get tree() {
return null;
}
toTree() {
let t2 = [], e2 = [], { buffer: i2 } = this.context, s = this.index + 4, r2 = i2.buffer[this.index + 3];
if (r2 > s) {
let o = i2.buffer[this.index + 1];
t2.push(i2.slice(s, r2, o)), e2.push(0);
}
return new X(this.type, t2, e2, this.to - this.from);
}
/**
@internal
*/
toString() {
return this.context.buffer.childString(this.index);
}
}
function bh(n2) {
if (!n2.length)
return null;
let t2 = 0, e2 = n2[0];
for (let r2 = 1; r2 < n2.length; r2++) {
let o = n2[r2];
(o.from > e2.from || o.to < e2.to) && (e2 = o, t2 = r2);
}
let i2 = e2 instanceof Tt && e2.index < 0 ? null : e2.parent, s = n2.slice();
return i2 ? s[t2] = i2 : s.splice(t2, 1), new bd(s, e2);
}
class bd {
constructor(t2, e2) {
this.heads = t2, this.node = e2;
}
get next() {
return bh(this.heads);
}
}
function kd(n2, t2, e2) {
let i2 = n2.resolveInner(t2, e2), s = null;
for (let r2 = i2 instanceof Tt ? i2 : i2.context.parent; r2; r2 = r2.parent)
if (r2.index < 0) {
let o = r2.parent;
(s || (s = [i2])).push(o.resolve(t2, e2)), r2 = o;
} else {
let o = ws.get(r2.tree);
if (o && o.overlay && o.overlay[0].from <= t2 && o.overlay[o.overlay.length - 1].to >= t2) {
let l = new Tt(o.tree, o.overlay[0].from + r2.from, -1, r2);
(s || (s = [i2])).push(Si(l, t2, e2, false));
}
}
return s ? bh(s) : i2;
}
class Hn {
/**
Shorthand for `.type.name`.
*/
get name() {
return this.type.name;
}
/**
@internal
*/
constructor(t2, e2 = 0) {
if (this.mode = e2, this.buffer = null, this.stack = [], this.index = 0, this.bufferNode = null, t2 instanceof Tt)
this.yieldNode(t2);
else {
this._tree = t2.context.parent, this.buffer = t2.context;
for (let i2 = t2._parent; i2; i2 = i2._parent)
this.stack.unshift(i2.index);
this.bufferNode = t2, this.yieldBuf(t2.index);
}
}
yieldNode(t2) {
return t2 ? (this._tree = t2, this.type = t2.type, this.from = t2.from, this.to = t2.to, true) : false;
}
yieldBuf(t2, e2) {
this.index = t2;
let { start: i2, buffer: s } = this.buffer;
return this.type = e2 || s.set.types[s.buffer[t2]], this.from = i2 + s.buffer[t2 + 1], this.to = i2 + s.buffer[t2 + 2], true;
}
/**
@internal
*/
yield(t2) {
return t2 ? t2 instanceof Tt ? (this.buffer = null, this.yieldNode(t2)) : (this.buffer = t2.context, this.yieldBuf(t2.index, t2.type)) : false;
}
/**
@internal
*/
toString() {
return this.buffer ? this.buffer.buffer.childString(this.index) : this._tree.toString();
}
/**
@internal
*/
enterChild(t2, e2, i2) {
if (!this.buffer)
return this.yield(this._tree.nextChild(t2 < 0 ? this._tree._tree.children.length - 1 : 0, t2, e2, i2, this.mode));
let { buffer: s } = this.buffer, r2 = s.findChild(this.index + 4, s.buffer[this.index + 3], t2, e2 - this.buffer.start, i2);
return r2 < 0 ? false : (this.stack.push(this.index), this.yieldBuf(r2));
}
/**
Move the cursor to this node's first child. When this returns
false, the node has no child, and the cursor has not been moved.
*/
firstChild() {
return this.enterChild(
1,
0,
4
/* Side.DontCare */
);
}
/**
Move the cursor to this node's last child.
*/
lastChild() {
return this.enterChild(
-1,
0,
4
/* Side.DontCare */
);
}
/**
Move the cursor to the first child that ends after `pos`.
*/
childAfter(t2) {
return this.enterChild(
1,
t2,
2
/* Side.After */
);
}
/**
Move to the last child that starts before `pos`.
*/
childBefore(t2) {
return this.enterChild(
-1,
t2,
-2
/* Side.Before */
);
}
/**
Move the cursor to the child around `pos`. If side is -1 the
child may end at that position, when 1 it may start there. This
will also enter [overlaid](#common.MountedTree.overlay)
[mounted](#common.NodeProp^mounted) trees unless `overlays` is
set to false.
*/
enter(t2, e2, i2 = this.mode) {
return this.buffer ? i2 & st.ExcludeBuffers ? false : this.enterChild(1, t2, e2) : this.yield(this._tree.enter(t2, e2, i2));
}
/**
Move to the node's parent node, if this isn't the top node.
*/
parent() {
if (!this.buffer)
return this.yieldNode(this.mode & st.IncludeAnonymous ? this._tree._parent : this._tree.parent);
if (this.stack.length)
return this.yieldBuf(this.stack.pop());
let t2 = this.mode & st.IncludeAnonymous ? this.buffer.parent : this.buffer.parent.nextSignificantParent();
return this.buffer = null, this.yieldNode(t2);
}
/**
@internal
*/
sibling(t2) {
if (!this.buffer)
return this._tree._parent ? this.yield(this._tree.index < 0 ? null : this._tree._parent.nextChild(this._tree.index + t2, t2, 0, 4, this.mode)) : false;
let { buffer: e2 } = this.buffer, i2 = this.stack.length - 1;
if (t2 < 0) {
let s = i2 < 0 ? 0 : this.stack[i2] + 4;
if (this.index != s)
return this.yieldBuf(e2.findChild(
s,
this.index,
-1,
0,
4
/* Side.DontCare */
));
} else {
let s = e2.buffer[this.index + 3];
if (s < (i2 < 0 ? e2.buffer.length : e2.buffer[this.stack[i2] + 3]))
return this.yieldBuf(s);
}
return i2 < 0 ? this.yield(this.buffer.parent.nextChild(this.buffer.index + t2, t2, 0, 4, this.mode)) : false;
}
/**
Move to this node's next sibling, if any.
*/
nextSibling() {
return this.sibling(1);
}
/**
Move to this node's previous sibling, if any.
*/
prevSibling() {
return this.sibling(-1);
}
atLastNode(t2) {
let e2, i2, { buffer: s } = this;
if (s) {
if (t2 > 0) {
if (this.index < s.buffer.buffer.length)
return false;
} else
for (let r2 = 0; r2 < this.index; r2++)
if (s.buffer.buffer[r2 + 3] < this.index)
return false;
({ index: e2, parent: i2 } = s);
} else
({ index: e2, _parent: i2 } = this._tree);
for (; i2; { index: e2, _parent: i2 } = i2)
if (e2 > -1)
for (let r2 = e2 + t2, o = t2 < 0 ? -1 : i2._tree.children.length; r2 != o; r2 += t2) {
let l = i2._tree.children[r2];
if (this.mode & st.IncludeAnonymous || l instanceof xe || !l.type.isAnonymous || lr(l))
return false;
}
return true;
}
move(t2, e2) {
if (e2 && this.enterChild(
t2,
0,
4
/* Side.DontCare */
))
return true;
for (; ; ) {
if (this.sibling(t2))
return true;
if (this.atLastNode(t2) || !this.parent())
return false;
}
}
/**
Move to the next node in a
[pre-order](https://en.wikipedia.org/wiki/Tree_traversal#Pre-order,_NLR)
traversal, going from a node to its first child or, if the
current node is empty or `enter` is false, its next sibling or
the next sibling of the first parent node that has one.
*/
next(t2 = true) {
return this.move(1, t2);
}
/**
Move to the next node in a last-to-first pre-order traveral. A
node is followed by its last child or, if it has none, its
previous sibling or the previous sibling of the first parent
node that has one.
*/
prev(t2 = true) {
return this.move(-1, t2);
}
/**
Move the cursor to the innermost node that covers `pos`. If
`side` is -1, it will enter nodes that end at `pos`. If it is 1,
it will enter nodes that start at `pos`.
*/
moveTo(t2, e2 = 0) {
for (; (this.from == this.to || (e2 < 1 ? this.from >= t2 : this.from > t2) || (e2 > -1 ? this.to <= t2 : this.to < t2)) && this.parent(); )
;
for (; this.enterChild(1, t2, e2); )
;
return this;
}
/**
Get a [syntax node](#common.SyntaxNode) at the cursor's current
position.
*/
get node() {
if (!this.buffer)
return this._tree;
let t2 = this.bufferNode, e2 = null, i2 = 0;
if (t2 && t2.context == this.buffer)
t:
for (let s = this.index, r2 = this.stack.length; r2 >= 0; ) {
for (let o = t2; o; o = o._parent)
if (o.index == s) {
if (s == this.index)
return o;
e2 = o, i2 = r2 + 1;
break t;
}
s = this.stack[--r2];
}
for (let s = i2; s < this.stack.length; s++)
e2 = new de(this.buffer, e2, this.stack[s]);
return this.bufferNode = new de(this.buffer, e2, this.index);
}
/**
Get the [tree](#common.Tree) that represents the current node, if
any. Will return null when the node is in a [tree
buffer](#common.TreeBuffer).
*/
get tree() {
return this.buffer ? null : this._tree._tree;
}
/**
Iterate over the current node and all its descendants, calling
`enter` when entering a node and `leave`, if given, when leaving
one. When `enter` returns `false`, any children of that node are
skipped, and `leave` isn't called for it.
*/
iterate(t2, e2) {
for (let i2 = 0; ; ) {
let s = false;
if (this.type.isAnonymous || t2(this) !== false) {
if (this.firstChild()) {
i2++;
continue;
}
this.type.isAnonymous || (s = true);
}
for (; s && e2 && e2(this), s = this.type.isAnonymous, !this.nextSibling(); ) {
if (!i2)
return;
this.parent(), i2--, s = true;
}
}
}
/**
Test whether the current node matches a given context—a sequence
of direct parent node names. Empty strings in the context array
are treated as wildcards.
*/
matchContext(t2) {
if (!this.buffer)
return Vn(this.node, t2);
let { buffer: e2 } = this.buffer, { types: i2 } = e2.set;
for (let s = t2.length - 1, r2 = this.stack.length - 1; s >= 0; r2--) {
if (r2 < 0)
return Vn(this.node, t2, s);
let o = i2[e2.buffer[this.stack[r2]]];
if (!o.isAnonymous) {
if (t2[s] && t2[s] != o.name)
return false;
s--;
}
}
return true;
}
}
function lr(n2) {
return n2.children.some((t2) => t2 instanceof xe || !t2.type.isAnonymous || lr(t2));
}
function xd(n2) {
var t2;
let { buffer: e2, nodeSet: i2, maxBufferLength: s = mh, reused: r2 = [], minRepeatType: o = i2.types.length } = n2, l = Array.isArray(e2) ? new or(e2, e2.length) : e2, h2 = i2.types, a2 = 0, c2 = 0;
function f2(A2, P2, M2, I2, W2, $) {
let { id: L2, start: E2, end: Y2, size: U2 } = l, gt = c2;
for (; U2 < 0; )
if (l.next(), U2 == -1) {
let Jt = r2[L2];
M2.push(Jt), I2.push(E2 - A2);
return;
} else if (U2 == -3) {
a2 = L2;
return;
} else if (U2 == -4) {
c2 = L2;
return;
} else
throw new RangeError(`Unrecognized record size: ${U2}`);
let Ae = h2[L2], $e, Oe, wr = E2 - A2;
if (Y2 - E2 <= s && (Oe = g(l.pos - P2, W2))) {
let Jt = new Uint16Array(Oe.size - Oe.skip), Ot = l.pos - Oe.size, Ft = Jt.length;
for (; l.pos > Ot; )
Ft = y2(Oe.start, Jt, Ft);
$e = new xe(Jt, Y2 - Oe.start, i2), wr = Oe.start - A2;
} else {
let Jt = l.pos - U2;
l.next();
let Ot = [], Ft = [], Me = L2 >= o ? L2 : -1, Fe = 0, Ri = Y2;
for (; l.pos > Jt; )
Me >= 0 && l.id == Me && l.size >= 0 ? (l.end <= Ri - s && (p2(Ot, Ft, E2, Fe, l.end, Ri, Me, gt), Fe = Ot.length, Ri = l.end), l.next()) : $ > 2500 ? u2(E2, Jt, Ot, Ft) : f2(E2, Jt, Ot, Ft, Me, $ + 1);
if (Me >= 0 && Fe > 0 && Fe < Ot.length && p2(Ot, Ft, E2, Fe, E2, Ri, Me, gt), Ot.reverse(), Ft.reverse(), Me > -1 && Fe > 0) {
let yr = d2(Ae);
$e = hr(Ae, Ot, Ft, 0, Ot.length, 0, Y2 - E2, yr, yr);
} else
$e = m(Ae, Ot, Ft, Y2 - E2, gt - Y2);
}
M2.push($e), I2.push(wr);
}
function u2(A2, P2, M2, I2) {
let W2 = [], $ = 0, L2 = -1;
for (; l.pos > P2; ) {
let { id: E2, start: Y2, end: U2, size: gt } = l;
if (gt > 4)
l.next();
else {
if (L2 > -1 && Y2 < L2)
break;
L2 < 0 && (L2 = U2 - s), W2.push(E2, Y2, U2), $++, l.next();
}
}
if ($) {
let E2 = new Uint16Array($ * 4), Y2 = W2[W2.length - 2];
for (let U2 = W2.length - 3, gt = 0; U2 >= 0; U2 -= 3)
E2[gt++] = W2[U2], E2[gt++] = W2[U2 + 1] - Y2, E2[gt++] = W2[U2 + 2] - Y2, E2[gt++] = gt;
M2.push(new xe(E2, W2[2] - Y2, i2)), I2.push(Y2 - A2);
}
}
function d2(A2) {
return (P2, M2, I2) => {
let W2 = 0, $ = P2.length - 1, L2, E2;
if ($ >= 0 && (L2 = P2[$]) instanceof X) {
if (!$ && L2.type == A2 && L2.length == I2)
return L2;
(E2 = L2.prop(R$1.lookAhead)) && (W2 = M2[$] + L2.length + E2);
}
return m(A2, P2, M2, I2, W2);
};
}
function p2(A2, P2, M2, I2, W2, $, L2, E2) {
let Y2 = [], U2 = [];
for (; A2.length > I2; )
Y2.push(A2.pop()), U2.push(P2.pop() + M2 - W2);
A2.push(m(i2.types[L2], Y2, U2, $ - W2, E2 - $)), P2.push(W2 - M2);
}
function m(A2, P2, M2, I2, W2 = 0, $) {
if (a2) {
let L2 = [R$1.contextHash, a2];
$ = $ ? [L2].concat($) : [L2];
}
if (W2 > 25) {
let L2 = [R$1.lookAhead, W2];
$ = $ ? [L2].concat($) : [L2];
}
return new X(A2, P2, M2, I2, $);
}
function g(A2, P2) {
let M2 = l.fork(), I2 = 0, W2 = 0, $ = 0, L2 = M2.end - s, E2 = { size: 0, start: 0, skip: 0 };
t:
for (let Y2 = M2.pos - A2; M2.pos > Y2; ) {
let U2 = M2.size;
if (M2.id == P2 && U2 >= 0) {
E2.size = I2, E2.start = W2, E2.skip = $, $ += 4, I2 += 4, M2.next();
continue;
}
let gt = M2.pos - U2;
if (U2 < 0 || gt < Y2 || M2.start < L2)
break;
let Ae = M2.id >= o ? 4 : 0, $e = M2.start;
for (M2.next(); M2.pos > gt; ) {
if (M2.size < 0)
if (M2.size == -3)
Ae += 4;
else
break t;
else
M2.id >= o && (Ae += 4);
M2.next();
}
W2 = $e, I2 += U2, $ += Ae;
}
return (P2 < 0 || I2 == A2) && (E2.size = I2, E2.start = W2, E2.skip = $), E2.size > 4 ? E2 : void 0;
}
function y2(A2, P2, M2) {
let { id: I2, start: W2, end: $, size: L2 } = l;
if (l.next(), L2 >= 0 && I2 < o) {
let E2 = M2;
if (L2 > 4) {
let Y2 = l.pos - (L2 - 4);
for (; l.pos > Y2; )
M2 = y2(A2, P2, M2);
}
P2[--M2] = E2, P2[--M2] = $ - A2, P2[--M2] = W2 - A2, P2[--M2] = I2;
} else
L2 == -3 ? a2 = I2 : L2 == -4 && (c2 = I2);
return M2;
}
let x2 = [], S2 = [];
for (; l.pos > 0; )
f2(n2.start || 0, n2.bufferStart || 0, x2, S2, -1, 0);
let v2 = (t2 = n2.length) !== null && t2 !== void 0 ? t2 : x2.length ? S2[0] + x2[0].length : 0;
return new X(h2[n2.topID], x2.reverse(), S2.reverse(), v2);
}
const vo = /* @__PURE__ */ new WeakMap();
function os(n2, t2) {
if (!n2.isAnonymous || t2 instanceof xe || t2.type != n2)
return 1;
let e2 = vo.get(t2);
if (e2 == null) {
e2 = 1;
for (let i2 of t2.children) {
if (i2.type != n2 || !(i2 instanceof X)) {
e2 = 1;
break;
}
e2 += os(n2, i2);
}
vo.set(t2, e2);
}
return e2;
}
function hr(n2, t2, e2, i2, s, r2, o, l, h2) {
let a2 = 0;
for (let p2 = i2; p2 < s; p2++)
a2 += os(n2, t2[p2]);
let c2 = Math.ceil(
a2 * 1.5 / 8
/* Balance.BranchFactor */
), f2 = [], u2 = [];
function d2(p2, m, g, y2, x2) {
for (let S2 = g; S2 < y2; ) {
let v2 = S2, A2 = m[S2], P2 = os(n2, p2[S2]);
for (S2++; S2 < y2; S2++) {
let M2 = os(n2, p2[S2]);
if (P2 + M2 >= c2)
break;
P2 += M2;
}
if (S2 == v2 + 1) {
if (P2 > c2) {
let M2 = p2[v2];
d2(M2.children, M2.positions, 0, M2.children.length, m[v2] + x2);
continue;
}
f2.push(p2[v2]);
} else {
let M2 = m[S2 - 1] + p2[S2 - 1].length - A2;
f2.push(hr(n2, p2, m, v2, S2, A2, M2, null, h2));
}
u2.push(A2 + x2 - r2);
}
}
return d2(t2, e2, i2, s, 0), (l || h2)(f2, u2, o);
}
class Re {
/**
Construct a tree fragment. You'll usually want to use
[`addTree`](#common.TreeFragment^addTree) and
[`applyChanges`](#common.TreeFragment^applyChanges) instead of
calling this directly.
*/
constructor(t2, e2, i2, s, r2 = false, o = false) {
this.from = t2, this.to = e2, this.tree = i2, this.offset = s, this.open = (r2 ? 1 : 0) | (o ? 2 : 0);
}
/**
Whether the start of the fragment represents the start of a
parse, or the end of a change. (In the second case, it may not
be safe to reuse some nodes at the start, depending on the
parsing algorithm.)
*/
get openStart() {
return (this.open & 1) > 0;
}
/**
Whether the end of the fragment represents the end of a
full-document parse, or the start of a change.
*/
get openEnd() {
return (this.open & 2) > 0;
}
/**
Create a set of fragments from a freshly parsed tree, or update
an existing set of fragments by replacing the ones that overlap
with a tree with content from the new tree. When `partial` is
true, the parse is treated as incomplete, and the resulting
fragment has [`openEnd`](#common.TreeFragment.openEnd) set to
true.
*/
static addTree(t2, e2 = [], i2 = false) {
let s = [new Re(0, t2.length, t2, 0, false, i2)];
for (let r2 of e2)
r2.to > t2.length && s.push(r2);
return s;
}
/**
Apply a set of edits to an array of fragments, removing or
splitting fragments as necessary to remove edited ranges, and
adjusting offsets for fragments that moved.
*/
static applyChanges(t2, e2, i2 = 128) {
if (!e2.length)
return t2;
let s = [], r2 = 1, o = t2.length ? t2[0] : null;
for (let l = 0, h2 = 0, a2 = 0; ; l++) {
let c2 = l < e2.length ? e2[l] : null, f2 = c2 ? c2.fromA : 1e9;
if (f2 - h2 >= i2)
for (; o && o.from < f2; ) {
let u2 = o;
if (h2 >= u2.from || f2 <= u2.to || a2) {
let d2 = Math.max(u2.from, h2) - a2, p2 = Math.min(u2.to, f2) - a2;
u2 = d2 >= p2 ? null : new Re(d2, p2, u2.tree, u2.offset + a2, l > 0, !!c2);
}
if (u2 && s.push(u2), o.to > f2)
break;
o = r2 < t2.length ? t2[r2++] : null;
}
if (!c2)
break;
h2 = c2.toA, a2 = c2.toA - c2.toB;
}
return s;
}
}
class kh {
/**
Start a parse, returning a [partial parse](#common.PartialParse)
object. [`fragments`](#common.TreeFragment) can be passed in to
make the parse incremental.
By default, the entire input is parsed. You can pass `ranges`,
which should be a sorted array of non-empty, non-overlapping
ranges, to parse only those ranges. The tree returned in that
case will start at `ranges[0].from`.
*/
startParse(t2, e2, i2) {
return typeof t2 == "string" && (t2 = new vd(t2)), i2 = i2 ? i2.length ? i2.map((s) => new Us(s.from, s.to)) : [new Us(0, 0)] : [new Us(0, t2.length)], this.createParse(t2, e2 || [], i2);
}
/**
Run a full parse, returning the resulting tree.
*/
parse(t2, e2, i2) {
let s = this.startParse(t2, e2, i2);
for (; ; ) {
let r2 = s.advance();
if (r2)
return r2;
}
}
}
class vd {
constructor(t2) {
this.string = t2;
}
get length() {
return this.string.length;
}
chunk(t2) {
return this.string.slice(t2);
}
get lineChunks() {
return false;
}
read(t2, e2) {
return this.string.slice(t2, e2);
}
}
new R$1({ perNode: true });
let Sd = 0;
class Kt {
/**
@internal
*/
constructor(t2, e2, i2) {
this.set = t2, this.base = e2, this.modified = i2, this.id = Sd++;
}
/**
Define a new tag. If `parent` is given, the tag is treated as a
sub-tag of that parent, and
[highlighters](#highlight.tagHighlighter) that don't mention
this tag will try to fall back to the parent tag (or grandparent
tag, etc).
*/
static define(t2) {
if (t2 != null && t2.base)
throw new Error("Can not derive from a modified tag");
let e2 = new Kt([], null, []);
if (e2.set.push(e2), t2)
for (let i2 of t2.set)
e2.set.push(i2);
return e2;
}
/**
Define a tag _modifier_, which is a function that, given a tag,
will return a tag that is a subtag of the original. Applying the
same modifier to a twice tag will return the same value (`m1(t1)
== m1(t1)`) and applying multiple modifiers will, regardless or
order, produce the same tag (`m1(m2(t1)) == m2(m1(t1))`).
When multiple modifiers are applied to a given base tag, each
smaller set of modifiers is registered as a parent, so that for
example `m1(m2(m3(t1)))` is a subtype of `m1(m2(t1))`,
`m1(m3(t1)`, and so on.
*/
static defineModifier() {
let t2 = new ys();
return (e2) => e2.modified.indexOf(t2) > -1 ? e2 : ys.get(e2.base || e2, e2.modified.concat(t2).sort((i2, s) => i2.id - s.id));
}
}
let Cd = 0;
class ys {
constructor() {
this.instances = [], this.id = Cd++;
}
static get(t2, e2) {
if (!e2.length)
return t2;
let i2 = e2[0].instances.find((l) => l.base == t2 && Ad(e2, l.modified));
if (i2)
return i2;
let s = [], r2 = new Kt(s, t2, e2);
for (let l of e2)
l.instances.push(r2);
let o = Od(e2);
for (let l of t2.set)
if (!l.modified.length)
for (let h2 of o)
s.push(ys.get(l, h2));
return r2;
}
}
function Ad(n2, t2) {
return n2.length == t2.length && n2.every((e2, i2) => e2 == t2[i2]);
}
function Od(n2) {
let t2 = [[]];
for (let e2 = 0; e2 < n2.length; e2++)
for (let i2 = 0, s = t2.length; i2 < s; i2++)
t2.push(t2[i2].concat(n2[e2]));
return t2.sort((e2, i2) => i2.length - e2.length);
}
function xh(n2) {
let t2 = /* @__PURE__ */ Object.create(null);
for (let e2 in n2) {
let i2 = n2[e2];
Array.isArray(i2) || (i2 = [i2]);
for (let s of e2.split(" "))
if (s) {
let r2 = [], o = 2, l = s;
for (let f2 = 0; ; ) {
if (l == "..." && f2 > 0 && f2 + 3 == s.length) {
o = 1;
break;
}
let u2 = /^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(l);
if (!u2)
throw new RangeError("Invalid path: " + s);
if (r2.push(u2[0] == "*" ? "" : u2[0][0] == '"' ? JSON.parse(u2[0]) : u2[0]), f2 += u2[0].length, f2 == s.length)
break;
let d2 = s[f2++];
if (f2 == s.length && d2 == "!") {
o = 0;
break;
}
if (d2 != "/")
throw new RangeError("Invalid path: " + s);
l = s.slice(f2);
}
let h2 = r2.length - 1, a2 = r2[h2];
if (!a2)
throw new RangeError("Invalid path: " + s);
let c2 = new bs(i2, o, h2 > 0 ? r2.slice(0, h2) : null);
t2[a2] = c2.sort(t2[a2]);
}
}
return vh.add(t2);
}
const vh = new R$1();
class bs {
constructor(t2, e2, i2, s) {
this.tags = t2, this.mode = e2, this.context = i2, this.next = s;
}
get opaque() {
return this.mode == 0;
}
get inherit() {
return this.mode == 1;
}
sort(t2) {
return !t2 || t2.depth < this.depth ? (this.next = t2, this) : (t2.next = this.sort(t2.next), t2);
}
get depth() {
return this.context ? this.context.length : 0;
}
}
bs.empty = new bs([], 2, null);
function Sh(n2, t2) {
let e2 = /* @__PURE__ */ Object.create(null);
for (let r2 of n2)
if (!Array.isArray(r2.tag))
e2[r2.tag.id] = r2.class;
else
for (let o of r2.tag)
e2[o.id] = r2.class;
let { scope: i2, all: s = null } = t2 || {};
return {
style: (r2) => {
let o = s;
for (let l of r2)
for (let h2 of l.set) {
let a2 = e2[h2.id];
if (a2) {
o = o ? o + " " + a2 : a2;
break;
}
}
return o;
},
scope: i2
};
}
function Md(n2, t2) {
let e2 = null;
for (let i2 of n2) {
let s = i2.style(t2);
s && (e2 = e2 ? e2 + " " + s : s);
}
return e2;
}
function Td(n2, t2, e2, i2 = 0, s = n2.length) {
let r2 = new Dd(i2, Array.isArray(t2) ? t2 : [t2], e2);
r2.highlightRange(n2.cursor(), i2, s, "", r2.highlighters), r2.flush(s);
}
class Dd {
constructor(t2, e2, i2) {
this.at = t2, this.highlighters = e2, this.span = i2, this.class = "";
}
startSpan(t2, e2) {
e2 != this.class && (this.flush(t2), t2 > this.at && (this.at = t2), this.class = e2);
}
flush(t2) {
t2 > this.at && this.class && this.span(this.at, t2, this.class);
}
highlightRange(t2, e2, i2, s, r2) {
let { type: o, from: l, to: h2 } = t2;
if (l >= i2 || h2 <= e2)
return;
o.isTop && (r2 = this.highlighters.filter((d2) => !d2.scope || d2.scope(o)));
let a2 = s, c2 = Pd(t2) || bs.empty, f2 = Md(r2, c2.tags);
if (f2 && (a2 && (a2 += " "), a2 += f2, c2.mode == 1 && (s += (s ? " " : "") + f2)), this.startSpan(Math.max(e2, l), a2), c2.opaque)
return;
let u2 = t2.tree && t2.tree.prop(R$1.mounted);
if (u2 && u2.overlay) {
let d2 = t2.node.enter(u2.overlay[0].from + l, 1), p2 = this.highlighters.filter((g) => !g.scope || g.scope(u2.tree.type)), m = t2.firstChild();
for (let g = 0, y2 = l; ; g++) {
let x2 = g < u2.overlay.length ? u2.overlay[g] : null, S2 = x2 ? x2.from + l : h2, v2 = Math.max(e2, y2), A2 = Math.min(i2, S2);
if (v2 < A2 && m)
for (; t2.from < A2 && (this.highlightRange(t2, v2, A2, s, r2), this.startSpan(Math.min(A2, t2.to), a2), !(t2.to >= S2 || !t2.nextSibling())); )
;
if (!x2 || S2 > i2)
break;
y2 = x2.to + l, y2 > e2 && (this.highlightRange(d2.cursor(), Math.max(e2, x2.from + l), Math.min(i2, y2), "", p2), this.startSpan(Math.min(i2, y2), a2));
}
m && t2.parent();
} else if (t2.firstChild()) {
u2 && (s = "");
do
if (!(t2.to <= e2)) {
if (t2.from >= i2)
break;
this.highlightRange(t2, e2, i2, s, r2), this.startSpan(Math.min(i2, t2.to), a2);
}
while (t2.nextSibling());
t2.parent();
}
}
}
function Pd(n2) {
let t2 = n2.type.prop(vh);
for (; t2 && t2.context && !n2.matchContext(t2.context); )
t2 = t2.next;
return t2 || null;
}
const k$1 = Kt.define, qi = k$1(), le = k$1(), So = k$1(le), Co = k$1(le), he = k$1(), Gi = k$1(he), Ys = k$1(he), jt = k$1(), Te = k$1(jt), zt = k$1(), Wt = k$1(), $n = k$1(), ri = k$1($n), Ui = k$1(), w$2 = {
/**
A comment.
*/
comment: qi,
/**
A line [comment](#highlight.tags.comment).
*/
lineComment: k$1(qi),
/**
A block [comment](#highlight.tags.comment).
*/
blockComment: k$1(qi),
/**
A documentation [comment](#highlight.tags.comment).
*/
docComment: k$1(qi),
/**
Any kind of identifier.
*/
name: le,
/**
The [name](#highlight.tags.name) of a variable.
*/
variableName: k$1(le),
/**
A type [name](#highlight.tags.name).
*/
typeName: So,
/**
A tag name (subtag of [`typeName`](#highlight.tags.typeName)).
*/
tagName: k$1(So),
/**
A property or field [name](#highlight.tags.name).
*/
propertyName: Co,
/**
An attribute name (subtag of [`propertyName`](#highlight.tags.propertyName)).
*/
attributeName: k$1(Co),
/**
The [name](#highlight.tags.name) of a class.
*/
className: k$1(le),
/**
A label [name](#highlight.tags.name).
*/
labelName: k$1(le),
/**
A namespace [name](#highlight.tags.name).
*/
namespace: k$1(le),
/**
The [name](#highlight.tags.name) of a macro.
*/
macroName: k$1(le),
/**
A literal value.
*/
literal: he,
/**
A string [literal](#highlight.tags.literal).
*/
string: Gi,
/**
A documentation [string](#highlight.tags.string).
*/
docString: k$1(Gi),
/**
A character literal (subtag of [string](#highlight.tags.string)).
*/
character: k$1(Gi),
/**
An attribute value (subtag of [string](#highlight.tags.string)).
*/
attributeValue: k$1(Gi),
/**
A number [literal](#highlight.tags.literal).
*/
number: Ys,
/**
An integer [number](#highlight.tags.number) literal.
*/
integer: k$1(Ys),
/**
A floating-point [number](#highlight.tags.number) literal.
*/
float: k$1(Ys),
/**
A boolean [literal](#highlight.tags.literal).
*/
bool: k$1(he),
/**
Regular expression [literal](#highlight.tags.literal).
*/
regexp: k$1(he),
/**
An escape [literal](#highlight.tags.literal), for example a
backslash escape in a string.
*/
escape: k$1(he),
/**
A color [literal](#highlight.tags.literal).
*/
color: k$1(he),
/**
A URL [literal](#highlight.tags.literal).
*/
url: k$1(he),
/**
A language keyword.
*/
keyword: zt,
/**
The [keyword](#highlight.tags.keyword) for the self or this
object.
*/
self: k$1(zt),
/**
The [keyword](#highlight.tags.keyword) for null.
*/
null: k$1(zt),
/**
A [keyword](#highlight.tags.keyword) denoting some atomic value.
*/
atom: k$1(zt),
/**
A [keyword](#highlight.tags.keyword) that represents a unit.
*/
unit: k$1(zt),
/**
A modifier [keyword](#highlight.tags.keyword).
*/
modifier: k$1(zt),
/**
A [keyword](#highlight.tags.keyword) that acts as an operator.
*/
operatorKeyword: k$1(zt),
/**
A control-flow related [keyword](#highlight.tags.keyword).
*/
controlKeyword: k$1(zt),
/**
A [keyword](#highlight.tags.keyword) that defines something.
*/
definitionKeyword: k$1(zt),
/**
A [keyword](#highlight.tags.keyword) related to defining or
interfacing with modules.
*/
moduleKeyword: k$1(zt),
/**
An operator.
*/
operator: Wt,
/**
An [operator](#highlight.tags.operator) that dereferences something.
*/
derefOperator: k$1(Wt),
/**
Arithmetic-related [operator](#highlight.tags.operator).
*/
arithmeticOperator: k$1(Wt),
/**
Logical [operator](#highlight.tags.operator).
*/
logicOperator: k$1(Wt),
/**
Bit [operator](#highlight.tags.operator).
*/
bitwiseOperator: k$1(Wt),
/**
Comparison [operator](#highlight.tags.operator).
*/
compareOperator: k$1(Wt),
/**
[Operator](#highlight.tags.operator) that updates its operand.
*/
updateOperator: k$1(Wt),
/**
[Operator](#highlight.tags.operator) that defines something.
*/
definitionOperator: k$1(Wt),
/**
Type-related [operator](#highlight.tags.operator).
*/
typeOperator: k$1(Wt),
/**
Control-flow [operator](#highlight.tags.operator).
*/
controlOperator: k$1(Wt),
/**
Program or markup punctuation.
*/
punctuation: $n,
/**
[Punctuation](#highlight.tags.punctuation) that separates
things.
*/
separator: k$1($n),
/**
Bracket-style [punctuation](#highlight.tags.punctuation).
*/
bracket: ri,
/**
Angle [brackets](#highlight.tags.bracket) (usually `<` and `>`
tokens).
*/
angleBracket: k$1(ri),
/**
Square [brackets](#highlight.tags.bracket) (usually `[` and `]`
tokens).
*/
squareBracket: k$1(ri),
/**
Parentheses (usually `(` and `)` tokens). Subtag of
[bracket](#highlight.tags.bracket).
*/
paren: k$1(ri),
/**
Braces (usually `{` and `}` tokens). Subtag of
[bracket](#highlight.tags.bracket).
*/
brace: k$1(ri),
/**
Content, for example plain text in XML or markup documents.
*/
content: jt,
/**
[Content](#highlight.tags.content) that represents a heading.
*/
heading: Te,
/**
A level 1 [heading](#highlight.tags.heading).
*/
heading1: k$1(Te),
/**
A level 2 [heading](#highlight.tags.heading).
*/
heading2: k$1(Te),
/**
A level 3 [heading](#highlight.tags.heading).
*/
heading3: k$1(Te),
/**
A level 4 [heading](#highlight.tags.heading).
*/
heading4: k$1(Te),
/**
A level 5 [heading](#highlight.tags.heading).
*/
heading5: k$1(Te),
/**
A level 6 [heading](#highlight.tags.heading).
*/
heading6: k$1(Te),
/**
A prose separator (such as a horizontal rule).
*/
contentSeparator: k$1(jt),
/**
[Content](#highlight.tags.content) that represents a list.
*/
list: k$1(jt),
/**
[Content](#highlight.tags.content) that represents a quote.
*/
quote: k$1(jt),
/**
[Content](#highlight.tags.content) that is emphasized.
*/
emphasis: k$1(jt),
/**
[Content](#highlight.tags.content) that is styled strong.
*/
strong: k$1(jt),
/**
[Content](#highlight.tags.content) that is part of a link.
*/
link: k$1(jt),
/**
[Content](#highlight.tags.content) that is styled as code or
monospace.
*/
monospace: k$1(jt),
/**
[Content](#highlight.tags.content) that has a strike-through
style.
*/
strikethrough: k$1(jt),
/**
Inserted text in a change-tracking format.
*/
inserted: k$1(),
/**
Deleted text.
*/
deleted: k$1(),
/**
Changed text.
*/
changed: k$1(),
/**
An invalid or unsyntactic element.
*/
invalid: k$1(),
/**
Metadata or meta-instruction.
*/
meta: Ui,
/**
[Metadata](#highlight.tags.meta) that applies to the entire
document.
*/
documentMeta: k$1(Ui),
/**
[Metadata](#highlight.tags.meta) that annotates or adds
attributes to a given syntactic element.
*/
annotation: k$1(Ui),
/**
Processing instruction or preprocessor directive. Subtag of
[meta](#highlight.tags.meta).
*/
processingInstruction: k$1(Ui),
/**
[Modifier](#highlight.Tag^defineModifier) that indicates that a
given element is being defined. Expected to be used with the
various [name](#highlight.tags.name) tags.
*/
definition: Kt.defineModifier(),
/**
[Modifier](#highlight.Tag^defineModifier) that indicates that
something is constant. Mostly expected to be used with
[variable names](#highlight.tags.variableName).
*/
constant: Kt.defineModifier(),
/**
[Modifier](#highlight.Tag^defineModifier) used to indicate that
a [variable](#highlight.tags.variableName) or [property
name](#highlight.tags.propertyName) is being called or defined
as a function.
*/
function: Kt.defineModifier(),
/**
[Modifier](#highlight.Tag^defineModifier) that can be applied to
[names](#highlight.tags.name) to indicate that they belong to
the language's standard environment.
*/
standard: Kt.defineModifier(),
/**
[Modifier](#highlight.Tag^defineModifier) that indicates a given
[names](#highlight.tags.name) is local to some scope.
*/
local: Kt.defineModifier(),
/**
A generic variant [modifier](#highlight.Tag^defineModifier) that
can be used to tag language-specific alternative variants of
some common tag. It is recommended for themes to define special
forms of at least the [string](#highlight.tags.string) and
[variable name](#highlight.tags.variableName) tags, since those
come up a lot.
*/
special: Kt.defineModifier()
};
Sh([
{ tag: w$2.link, class: "tok-link" },
{ tag: w$2.heading, class: "tok-heading" },
{ tag: w$2.emphasis, class: "tok-emphasis" },
{ tag: w$2.strong, class: "tok-strong" },
{ tag: w$2.keyword, class: "tok-keyword" },
{ tag: w$2.atom, class: "tok-atom" },
{ tag: w$2.bool, class: "tok-bool" },
{ tag: w$2.url, class: "tok-url" },
{ tag: w$2.labelName, class: "tok-labelName" },
{ tag: w$2.inserted, class: "tok-inserted" },
{ tag: w$2.deleted, class: "tok-deleted" },
{ tag: w$2.literal, class: "tok-literal" },
{ tag: w$2.string, class: "tok-string" },
{ tag: w$2.number, class: "tok-number" },
{ tag: [w$2.regexp, w$2.escape, w$2.special(w$2.string)], class: "tok-string2" },
{ tag: w$2.variableName, class: "tok-variableName" },
{ tag: w$2.local(w$2.variableName), class: "tok-variableName tok-local" },
{ tag: w$2.definition(w$2.variableName), class: "tok-variableName tok-definition" },
{ tag: w$2.special(w$2.variableName), class: "tok-variableName2" },
{ tag: w$2.definition(w$2.propertyName), class: "tok-propertyName tok-definition" },
{ tag: w$2.typeName, class: "tok-typeName" },
{ tag: w$2.namespace, class: "tok-namespace" },
{ tag: w$2.className, class: "tok-className" },
{ tag: w$2.macroName, class: "tok-macroName" },
{ tag: w$2.propertyName, class: "tok-propertyName" },
{ tag: w$2.operator, class: "tok-operator" },
{ tag: w$2.comment, class: "tok-comment" },
{ tag: w$2.meta, class: "tok-meta" },
{ tag: w$2.invalid, class: "tok-invalid" },
{ tag: w$2.punctuation, class: "tok-punctuation" }
]);
var Qs;
const ze = /* @__PURE__ */ new R$1();
function Bd(n2) {
return O$3.define({
combine: n2 ? (t2) => t2.concat(n2) : void 0
});
}
const Rd = /* @__PURE__ */ new R$1();
class Rt {
/**
Construct a language object. If you need to invoke this
directly, first define a data facet with
[`defineLanguageFacet`](https://codemirror.net/6/docs/ref/#language.defineLanguageFacet), and then
configure your parser to [attach](https://codemirror.net/6/docs/ref/#language.languageDataProp) it
to the language's outer syntax node.
*/
constructor(t2, e2, i2 = [], s = "") {
this.data = t2, this.name = s, H$3.prototype.hasOwnProperty("tree") || Object.defineProperty(H$3.prototype, "tree", { get() {
return At(this);
} }), this.parser = e2, this.extension = [
ve.of(this),
H$3.languageData.of((r2, o, l) => {
let h2 = Ao(r2, o, l), a2 = h2.type.prop(ze);
if (!a2)
return [];
let c2 = r2.facet(a2), f2 = h2.type.prop(Rd);
if (f2) {
let u2 = h2.resolve(o - h2.from, l);
for (let d2 of f2)
if (d2.test(u2, r2)) {
let p2 = r2.facet(d2.facet);
return d2.type == "replace" ? p2 : p2.concat(c2);
}
}
return c2;
})
].concat(i2);
}
/**
Query whether this language is active at the given position.
*/
isActiveAt(t2, e2, i2 = -1) {
return Ao(t2, e2, i2).type.prop(ze) == this.data;
}
/**
Find the document regions that were parsed using this language.
The returned regions will _include_ any nested languages rooted
in this language, when those exist.
*/
findRegions(t2) {
let e2 = t2.facet(ve);
if ((e2 == null ? void 0 : e2.data) == this.data)
return [{ from: 0, to: t2.doc.length }];
if (!e2 || !e2.allowsNesting)
return [];
let i2 = [], s = (r2, o) => {
if (r2.prop(ze) == this.data) {
i2.push({ from: o, to: o + r2.length });
return;
}
let l = r2.prop(R$1.mounted);
if (l) {
if (l.tree.prop(ze) == this.data) {
if (l.overlay)
for (let h2 of l.overlay)
i2.push({ from: h2.from + o, to: h2.to + o });
else
i2.push({ from: o, to: o + r2.length });
return;
} else if (l.overlay) {
let h2 = i2.length;
if (s(l.tree, l.overlay[0].from + o), i2.length > h2)
return;
}
}
for (let h2 = 0; h2 < r2.children.length; h2++) {
let a2 = r2.children[h2];
a2 instanceof X && s(a2, r2.positions[h2] + o);
}
};
return s(At(t2), 0), i2;
}
/**
Indicates whether this language allows nested languages. The
default implementation returns true.
*/
get allowsNesting() {
return true;
}
}
Rt.setState = /* @__PURE__ */ z$2.define();
function Ao(n2, t2, e2) {
let i2 = n2.facet(ve), s = At(n2).topNode;
if (!i2 || i2.allowsNesting)
for (let r2 = s; r2; r2 = r2.enter(t2, e2, st.ExcludeBuffers))
r2.type.isTop && (s = r2);
return s;
}
class ks extends Rt {
constructor(t2, e2, i2) {
super(t2, e2, [], i2), this.parser = e2;
}
/**
Define a language from a parser.
*/
static define(t2) {
let e2 = Bd(t2.languageData);
return new ks(e2, t2.parser.configure({
props: [ze.add((i2) => i2.isTop ? e2 : void 0)]
}), t2.name);
}
/**
Create a new instance of this language with a reconfigured
version of its parser and optionally a new name.
*/
configure(t2, e2) {
return new ks(this.data, this.parser.configure(t2), e2 || this.name);
}
get allowsNesting() {
return this.parser.hasWrappers();
}
}
function At(n2) {
let t2 = n2.field(Rt.state, false);
return t2 ? t2.tree : X.empty;
}
class Ld {
/**
Create an input object for the given document.
*/
constructor(t2) {
this.doc = t2, this.cursorPos = 0, this.string = "", this.cursor = t2.iter();
}
get length() {
return this.doc.length;
}
syncTo(t2) {
return this.string = this.cursor.next(t2 - this.cursorPos).value, this.cursorPos = t2 + this.string.length, this.cursorPos - this.string.length;
}
chunk(t2) {
return this.syncTo(t2), this.string;
}
get lineChunks() {
return true;
}
read(t2, e2) {
let i2 = this.cursorPos - this.string.length;
return t2 < i2 || e2 >= this.cursorPos ? this.doc.sliceString(t2, e2) : this.string.slice(t2 - i2, e2 - i2);
}
}
let oi = null;
class xs {
constructor(t2, e2, i2 = [], s, r2, o, l, h2) {
this.parser = t2, this.state = e2, this.fragments = i2, this.tree = s, this.treeLen = r2, this.viewport = o, this.skipped = l, this.scheduleOn = h2, this.parse = null, this.tempSkipped = [];
}
/**
@internal
*/
static create(t2, e2, i2) {
return new xs(t2, e2, [], X.empty, 0, i2, [], null);
}
startParse() {
return this.parser.startParse(new Ld(this.state.doc), this.fragments);
}
/**
@internal
*/
work(t2, e2) {
return e2 != null && e2 >= this.state.doc.length && (e2 = void 0), this.tree != X.empty && this.isDone(e2 ?? this.state.doc.length) ? (this.takeTree(), true) : this.withContext(() => {
var i2;
if (typeof t2 == "number") {
let s = Date.now() + t2;
t2 = () => Date.now() > s;
}
for (this.parse || (this.parse = this.startParse()), e2 != null && (this.parse.stoppedAt == null || this.parse.stoppedAt > e2) && e2 < this.state.doc.length && this.parse.stopAt(e2); ; ) {
let s = this.parse.advance();
if (s)
if (this.fragments = this.withoutTempSkipped(Re.addTree(s, this.fragments, this.parse.stoppedAt != null)), this.treeLen = (i2 = this.parse.stoppedAt) !== null && i2 !== void 0 ? i2 : this.state.doc.length, this.tree = s, this.parse = null, this.treeLen < (e2 ?? this.state.doc.length))
this.parse = this.startParse();
else
return true;
if (t2())
return false;
}
});
}
/**
@internal
*/
takeTree() {
let t2, e2;
this.parse && (t2 = this.parse.parsedPos) >= this.treeLen && ((this.parse.stoppedAt == null || this.parse.stoppedAt > t2) && this.parse.stopAt(t2), this.withContext(() => {
for (; !(e2 = this.parse.advance()); )
;
}), this.treeLen = t2, this.tree = e2, this.fragments = this.withoutTempSkipped(Re.addTree(this.tree, this.fragments, true)), this.parse = null);
}
withContext(t2) {
let e2 = oi;
oi = this;
try {
return t2();
} finally {
oi = e2;
}
}
withoutTempSkipped(t2) {
for (let e2; e2 = this.tempSkipped.pop(); )
t2 = Oo(t2, e2.from, e2.to);
return t2;
}
/**
@internal
*/
changes(t2, e2) {
let { fragments: i2, tree: s, treeLen: r2, viewport: o, skipped: l } = this;
if (this.takeTree(), !t2.empty) {
let h2 = [];
if (t2.iterChangedRanges((a2, c2, f2, u2) => h2.push({ fromA: a2, toA: c2, fromB: f2, toB: u2 })), i2 = Re.applyChanges(i2, h2), s = X.empty, r2 = 0, o = { from: t2.mapPos(o.from, -1), to: t2.mapPos(o.to, 1) }, this.skipped.length) {
l = [];
for (let a2 of this.skipped) {
let c2 = t2.mapPos(a2.from, 1), f2 = t2.mapPos(a2.to, -1);
c2 < f2 && l.push({ from: c2, to: f2 });
}
}
}
return new xs(this.parser, e2, i2, s, r2, o, l, this.scheduleOn);
}
/**
@internal
*/
updateViewport(t2) {
if (this.viewport.from == t2.from && this.viewport.to == t2.to)
return false;
this.viewport = t2;
let e2 = this.skipped.length;
for (let i2 = 0; i2 < this.skipped.length; i2++) {
let { from: s, to: r2 } = this.skipped[i2];
s < t2.to && r2 > t2.from && (this.fragments = Oo(this.fragments, s, r2), this.skipped.splice(i2--, 1));
}
return this.skipped.length >= e2 ? false : (this.reset(), true);
}
/**
@internal
*/
reset() {
this.parse && (this.takeTree(), this.parse = null);
}
/**
Notify the parse scheduler that the given region was skipped
because it wasn't in view, and the parse should be restarted
when it comes into view.
*/
skipUntilInView(t2, e2) {
this.skipped.push({ from: t2, to: e2 });
}
/**
Returns a parser intended to be used as placeholder when
asynchronously loading a nested parser. It'll skip its input and
mark it as not-really-parsed, so that the next update will parse
it again.
When `until` is given, a reparse will be scheduled when that
promise resolves.
*/
static getSkippingParser(t2) {
return new class extends kh {
createParse(e2, i2, s) {
let r2 = s[0].from, o = s[s.length - 1].to;
return {
parsedPos: r2,
advance() {
let h2 = oi;
if (h2) {
for (let a2 of s)
h2.tempSkipped.push(a2);
t2 && (h2.scheduleOn = h2.scheduleOn ? Promise.all([h2.scheduleOn, t2]) : t2);
}
return this.parsedPos = o, new X(bt.none, [], [], o - r2);
},
stoppedAt: null,
stopAt() {
}
};
}
}();
}
/**
@internal
*/
isDone(t2) {
t2 = Math.min(t2, this.state.doc.length);
let e2 = this.fragments;
return this.treeLen >= t2 && e2.length && e2[0].from == 0 && e2[0].to >= t2;
}
/**
Get the context for the current parse, or `null` if no editor
parse is in progress.
*/
static get() {
return oi;
}
}
function Oo(n2, t2, e2) {
return Re.applyChanges(n2, [{ fromA: t2, toA: e2, fromB: t2, toB: e2 }]);
}
class Xe {
constructor(t2) {
this.context = t2, this.tree = t2.tree;
}
apply(t2) {
if (!t2.docChanged && this.tree == this.context.tree)
return this;
let e2 = this.context.changes(t2.changes, t2.state), i2 = this.context.treeLen == t2.startState.doc.length ? void 0 : Math.max(t2.changes.mapPos(this.context.treeLen), e2.viewport.to);
return e2.work(20, i2) || e2.takeTree(), new Xe(e2);
}
static init(t2) {
let e2 = Math.min(3e3, t2.doc.length), i2 = xs.create(t2.facet(ve).parser, t2, { from: 0, to: e2 });
return i2.work(20, e2) || i2.takeTree(), new Xe(i2);
}
}
Rt.state = /* @__PURE__ */ Ht.define({
create: Xe.init,
update(n2, t2) {
for (let e2 of t2.effects)
if (e2.is(Rt.setState))
return e2.value;
return t2.startState.facet(ve) != t2.state.facet(ve) ? Xe.init(t2.state) : n2.apply(t2);
}
});
let Ch = (n2) => {
let t2 = setTimeout(
() => n2(),
500
/* Work.MaxPause */
);
return () => clearTimeout(t2);
};
typeof requestIdleCallback < "u" && (Ch = (n2) => {
let t2 = -1, e2 = setTimeout(
() => {
t2 = requestIdleCallback(n2, {
timeout: 400
/* Work.MinPause */
});
},
100
/* Work.MinPause */
);
return () => t2 < 0 ? clearTimeout(e2) : cancelIdleCallback(t2);
});
const Js = typeof navigator < "u" && (!((Qs = navigator.scheduling) === null || Qs === void 0) && Qs.isInputPending) ? () => navigator.scheduling.isInputPending() : null, Ed = /* @__PURE__ */ yt.fromClass(class {
constructor(t2) {
this.view = t2, this.working = null, this.workScheduled = 0, this.chunkEnd = -1, this.chunkBudget = -1, this.work = this.work.bind(this), this.scheduleWork();
}
update(t2) {
let e2 = this.view.state.field(Rt.state).context;
(e2.updateViewport(t2.view.viewport) || this.view.viewport.to > e2.treeLen) && this.scheduleWork(), (t2.docChanged || t2.selectionSet) && (this.view.hasFocus && (this.chunkBudget += 50), this.scheduleWork()), this.checkAsyncSchedule(e2);
}
scheduleWork() {
if (this.working)
return;
let { state: t2 } = this.view, e2 = t2.field(Rt.state);
(e2.tree != e2.context.tree || !e2.context.isDone(t2.doc.length)) && (this.working = Ch(this.work));
}
work(t2) {
this.working = null;
let e2 = Date.now();
if (this.chunkEnd < e2 && (this.chunkEnd < 0 || this.view.hasFocus) && (this.chunkEnd = e2 + 3e4, this.chunkBudget = 3e3), this.chunkBudget <= 0)
return;
let { state: i2, viewport: { to: s } } = this.view, r2 = i2.field(Rt.state);
if (r2.tree == r2.context.tree && r2.context.isDone(
s + 1e5
/* Work.MaxParseAhead */
))
return;
let o = Date.now() + Math.min(this.chunkBudget, 100, t2 && !Js ? Math.max(25, t2.timeRemaining() - 5) : 1e9), l = r2.context.treeLen < s && i2.doc.length > s + 1e3, h2 = r2.context.work(() => Js && Js() || Date.now() > o, s + (l ? 0 : 1e5));
this.chunkBudget -= Date.now() - e2, (h2 || this.chunkBudget <= 0) && (r2.context.takeTree(), this.view.dispatch({ effects: Rt.setState.of(new Xe(r2.context)) })), this.chunkBudget > 0 && !(h2 && !l) && this.scheduleWork(), this.checkAsyncSchedule(r2.context);
}
checkAsyncSchedule(t2) {
t2.scheduleOn && (this.workScheduled++, t2.scheduleOn.then(() => this.scheduleWork()).catch((e2) => ie(this.view.state, e2)).then(() => this.workScheduled--), t2.scheduleOn = null);
}
destroy() {
this.working && this.working();
}
isWorking() {
return !!(this.working || this.workScheduled > 0);
}
}, {
eventHandlers: { focus() {
this.scheduleWork();
} }
}), ve = /* @__PURE__ */ O$3.define({
combine(n2) {
return n2.length ? n2[0] : null;
},
enables: (n2) => [
Rt.state,
Ed,
T.contentAttributes.compute([n2], (t2) => {
let e2 = t2.facet(n2);
return e2 && e2.name ? { "data-language": e2.name } : {};
})
]
});
class Nd {
/**
Create a language support object.
*/
constructor(t2, e2 = []) {
this.language = t2, this.support = e2, this.extension = [t2, e2];
}
}
const Id = /* @__PURE__ */ O$3.define(), ar = /* @__PURE__ */ O$3.define({
combine: (n2) => {
if (!n2.length)
return " ";
let t2 = n2[0];
if (!t2 || /\S/.test(t2) || Array.from(t2).some((e2) => e2 != t2[0]))
throw new Error("Invalid indent unit: " + JSON.stringify(n2[0]));
return t2;
}
});
function vs(n2) {
let t2 = n2.facet(ar);
return t2.charCodeAt(0) == 9 ? n2.tabSize * t2.length : t2.length;
}
function Ci(n2, t2) {
let e2 = "", i2 = n2.tabSize, s = n2.facet(ar)[0];
if (s == " ") {
for (; t2 >= i2; )
e2 += " ", t2 -= i2;
s = " ";
}
for (let r2 = 0; r2 < t2; r2++)
e2 += s;
return e2;
}
function cr(n2, t2) {
n2 instanceof H$3 && (n2 = new Rs(n2));
for (let i2 of n2.state.facet(Id)) {
let s = i2(n2, t2);
if (s !== void 0)
return s;
}
let e2 = At(n2.state);
return e2.length >= t2 ? Vd(n2, e2, t2) : null;
}
class Rs {
/**
Create an indent context.
*/
constructor(t2, e2 = {}) {
this.state = t2, this.options = e2, this.unit = vs(t2);
}
/**
Get a description of the line at the given position, taking
[simulated line
breaks](https://codemirror.net/6/docs/ref/#language.IndentContext.constructor^options.simulateBreak)
into account. If there is such a break at `pos`, the `bias`
argument determines whether the part of the line line before or
after the break is used.
*/
lineAt(t2, e2 = 1) {
let i2 = this.state.doc.lineAt(t2), { simulateBreak: s, simulateDoubleBreak: r2 } = this.options;
return s != null && s >= i2.from && s <= i2.to ? r2 && s == t2 ? { text: "", from: t2 } : (e2 < 0 ? s < t2 : s <= t2) ? { text: i2.text.slice(s - i2.from), from: s } : { text: i2.text.slice(0, s - i2.from), from: i2.from } : i2;
}
/**
Get the text directly after `pos`, either the entire line
or the next 100 characters, whichever is shorter.
*/
textAfterPos(t2, e2 = 1) {
if (this.options.simulateDoubleBreak && t2 == this.options.simulateBreak)
return "";
let { text: i2, from: s } = this.lineAt(t2, e2);
return i2.slice(t2 - s, Math.min(i2.length, t2 + 100 - s));
}
/**
Find the column for the given position.
*/
column(t2, e2 = 1) {
let { text: i2, from: s } = this.lineAt(t2, e2), r2 = this.countColumn(i2, t2 - s), o = this.options.overrideIndentation ? this.options.overrideIndentation(s) : -1;
return o > -1 && (r2 += o - this.countColumn(i2, i2.search(/\S|$/))), r2;
}
/**
Find the column position (taking tabs into account) of the given
position in the given string.
*/
countColumn(t2, e2 = t2.length) {
return Oi(t2, this.state.tabSize, e2);
}
/**
Find the indentation column of the line at the given point.
*/
lineIndent(t2, e2 = 1) {
let { text: i2, from: s } = this.lineAt(t2, e2), r2 = this.options.overrideIndentation;
if (r2) {
let o = r2(s);
if (o > -1)
return o;
}
return this.countColumn(i2, i2.search(/\S|$/));
}
/**
Returns the [simulated line
break](https://codemirror.net/6/docs/ref/#language.IndentContext.constructor^options.simulateBreak)
for this context, if any.
*/
get simulatedBreak() {
return this.options.simulateBreak || null;
}
}
const Ah = /* @__PURE__ */ new R$1();
function Vd(n2, t2, e2) {
let i2 = t2.resolveStack(e2), s = i2.node.enterUnfinishedNodesBefore(e2);
if (s != i2.node) {
let r2 = [];
for (let o = s; o != i2.node; o = o.parent)
r2.push(o);
for (let o = r2.length - 1; o >= 0; o--)
i2 = { node: r2[o], next: i2 };
}
return Oh(i2, n2, e2);
}
function Oh(n2, t2, e2) {
for (let i2 = n2; i2; i2 = i2.next) {
let s = $d(i2.node);
if (s)
return s(fr.create(t2, e2, i2));
}
return 0;
}
function Hd(n2) {
return n2.pos == n2.options.simulateBreak && n2.options.simulateDoubleBreak;
}
function $d(n2) {
let t2 = n2.type.prop(Ah);
if (t2)
return t2;
let e2 = n2.firstChild, i2;
if (e2 && (i2 = e2.type.prop(R$1.closedBy))) {
let s = n2.lastChild, r2 = s && i2.indexOf(s.name) > -1;
return (o) => Wd(o, true, 1, void 0, r2 && !Hd(o) ? s.from : void 0);
}
return n2.parent == null ? Fd : null;
}
function Fd() {
return 0;
}
class fr extends Rs {
constructor(t2, e2, i2) {
super(t2.state, t2.options), this.base = t2, this.pos = e2, this.context = i2;
}
/**
The syntax tree node to which the indentation strategy
applies.
*/
get node() {
return this.context.node;
}
/**
@internal
*/
static create(t2, e2, i2) {
return new fr(t2, e2, i2);
}
/**
Get the text directly after `this.pos`, either the entire line
or the next 100 characters, whichever is shorter.
*/
get textAfter() {
return this.textAfterPos(this.pos);
}
/**
Get the indentation at the reference line for `this.node`, which
is the line on which it starts, unless there is a node that is
_not_ a parent of this node covering the start of that line. If
so, the line at the start of that node is tried, again skipping
on if it is covered by another such node.
*/
get baseIndent() {
return this.baseIndentFor(this.node);
}
/**
Get the indentation for the reference line of the given node
(see [`baseIndent`](https://codemirror.net/6/docs/ref/#language.TreeIndentContext.baseIndent)).
*/
baseIndentFor(t2) {
let e2 = this.state.doc.lineAt(t2.from);
for (; ; ) {
let i2 = t2.resolve(e2.from);
for (; i2.parent && i2.parent.from == i2.from; )
i2 = i2.parent;
if (_d(i2, t2))
break;
e2 = this.state.doc.lineAt(i2.from);
}
return this.lineIndent(e2.from);
}
/**
Continue looking for indentations in the node's parent nodes,
and return the result of that.
*/
continue() {
return Oh(this.context.next, this.base, this.pos);
}
}
function _d(n2, t2) {
for (let e2 = t2; e2; e2 = e2.parent)
if (n2 == e2)
return true;
return false;
}
function zd(n2) {
let t2 = n2.node, e2 = t2.childAfter(t2.from), i2 = t2.lastChild;
if (!e2)
return null;
let s = n2.options.simulateBreak, r2 = n2.state.doc.lineAt(e2.from), o = s == null || s <= r2.from ? r2.to : Math.min(r2.to, s);
for (let l = e2.to; ; ) {
let h2 = t2.childAfter(l);
if (!h2 || h2 == i2)
return null;
if (!h2.type.isSkipped)
return h2.from < o ? e2 : null;
l = h2.to;
}
}
function Wd(n2, t2, e2, i2, s) {
let r2 = n2.textAfter, o = r2.match(/^\s*/)[0].length, l = i2 && r2.slice(o, o + i2.length) == i2 || s == n2.pos + o, h2 = t2 ? zd(n2) : null;
return h2 ? l ? n2.column(h2.from) : n2.column(h2.to) : n2.baseIndent + (l ? 0 : n2.unit * e2);
}
function Mo({ except: n2, units: t2 = 1 } = {}) {
return (e2) => {
let i2 = n2 && n2.test(e2.textAfter);
return e2.baseIndent + (i2 ? 0 : t2 * e2.unit);
};
}
const jd = 200;
function Kd() {
return H$3.transactionFilter.of((n2) => {
if (!n2.docChanged || !n2.isUserEvent("input.type") && !n2.isUserEvent("input.complete"))
return n2;
let t2 = n2.startState.languageDataAt("indentOnInput", n2.startState.selection.main.head);
if (!t2.length)
return n2;
let e2 = n2.newDoc, { head: i2 } = n2.newSelection.main, s = e2.lineAt(i2);
if (i2 > s.from + jd)
return n2;
let r2 = e2.sliceString(s.from, i2);
if (!t2.some((a2) => a2.test(r2)))
return n2;
let { state: o } = n2, l = -1, h2 = [];
for (let { head: a2 } of o.selection.ranges) {
let c2 = o.doc.lineAt(a2);
if (c2.from == l)
continue;
l = c2.from;
let f2 = cr(o, c2.from);
if (f2 == null)
continue;
let u2 = /^\s*/.exec(c2.text)[0], d2 = Ci(o, f2);
u2 != d2 && h2.push({ from: c2.from, to: c2.from + u2.length, insert: d2 });
}
return h2.length ? [n2, { changes: h2, sequential: true }] : n2;
});
}
const qd = /* @__PURE__ */ O$3.define(), Mh = /* @__PURE__ */ new R$1();
function Gd(n2) {
let t2 = n2.firstChild, e2 = n2.lastChild;
return t2 && t2.to < e2.from ? { from: t2.to, to: e2.type.isError ? n2.to : e2.from } : null;
}
function Ud(n2, t2, e2) {
let i2 = At(n2);
if (i2.length < e2)
return null;
let s = i2.resolveStack(e2, 1), r2 = null;
for (let o = s; o; o = o.next) {
let l = o.node;
if (l.to <= e2 || l.from > e2)
continue;
if (r2 && l.from < t2)
break;
let h2 = l.type.prop(Mh);
if (h2 && (l.to < i2.length - 50 || i2.length == n2.doc.length || !Yd(l))) {
let a2 = h2(l, n2);
a2 && a2.from <= e2 && a2.from >= t2 && a2.to > e2 && (r2 = a2);
}
}
return r2;
}
function Yd(n2) {
let t2 = n2.lastChild;
return t2 && t2.to == n2.to && t2.type.isError;
}
function Ss(n2, t2, e2) {
for (let i2 of n2.facet(qd)) {
let s = i2(n2, t2, e2);
if (s)
return s;
}
return Ud(n2, t2, e2);
}
function Th(n2, t2) {
let e2 = t2.mapPos(n2.from, 1), i2 = t2.mapPos(n2.to, -1);
return e2 >= i2 ? void 0 : { from: e2, to: i2 };
}
const Ls = /* @__PURE__ */ z$2.define({ map: Th }), Di = /* @__PURE__ */ z$2.define({ map: Th });
function Dh(n2) {
let t2 = [];
for (let { head: e2 } of n2.state.selection.ranges)
t2.some((i2) => i2.from <= e2 && i2.to >= e2) || t2.push(n2.lineBlockAt(e2));
return t2;
}
const Ie = /* @__PURE__ */ Ht.define({
create() {
return N$2.none;
},
update(n2, t2) {
n2 = n2.map(t2.changes);
for (let e2 of t2.effects)
if (e2.is(Ls) && !Qd(n2, e2.value.from, e2.value.to)) {
let { preparePlaceholder: i2 } = t2.state.facet(ur), s = i2 ? N$2.replace({ widget: new sp(i2(t2.state, e2.value)) }) : To;
n2 = n2.update({ add: [s.range(e2.value.from, e2.value.to)] });
} else
e2.is(Di) && (n2 = n2.update({
filter: (i2, s) => e2.value.from != i2 || e2.value.to != s,
filterFrom: e2.value.from,
filterTo: e2.value.to
}));
if (t2.selection) {
let e2 = false, { head: i2 } = t2.selection.main;
n2.between(i2, i2, (s, r2) => {
s < i2 && r2 > i2 && (e2 = true);
}), e2 && (n2 = n2.update({
filterFrom: i2,
filterTo: i2,
filter: (s, r2) => r2 <= i2 || s >= i2
}));
}
return n2;
},
provide: (n2) => T.decorations.from(n2),
toJSON(n2, t2) {
let e2 = [];
return n2.between(0, t2.doc.length, (i2, s) => {
e2.push(i2, s);
}), e2;
},
fromJSON(n2) {
if (!Array.isArray(n2) || n2.length % 2)
throw new RangeError("Invalid JSON for fold state");
let t2 = [];
for (let e2 = 0; e2 < n2.length; ) {
let i2 = n2[e2++], s = n2[e2++];
if (typeof i2 != "number" || typeof s != "number")
throw new RangeError("Invalid JSON for fold state");
t2.push(To.range(i2, s));
}
return N$2.set(t2, true);
}
});
function Cs(n2, t2, e2) {
var i2;
let s = null;
return (i2 = n2.field(Ie, false)) === null || i2 === void 0 || i2.between(t2, e2, (r2, o) => {
(!s || s.from > r2) && (s = { from: r2, to: o });
}), s;
}
function Qd(n2, t2, e2) {
let i2 = false;
return n2.between(t2, t2, (s, r2) => {
s == t2 && r2 == e2 && (i2 = true);
}), i2;
}
function Ph(n2, t2) {
return n2.field(Ie, false) ? t2 : t2.concat(z$2.appendConfig.of(Rh()));
}
const Jd = (n2) => {
for (let t2 of Dh(n2)) {
let e2 = Ss(n2.state, t2.from, t2.to);
if (e2)
return n2.dispatch({ effects: Ph(n2.state, [Ls.of(e2), Bh(n2, e2)]) }), true;
}
return false;
}, Xd = (n2) => {
if (!n2.state.field(Ie, false))
return false;
let t2 = [];
for (let e2 of Dh(n2)) {
let i2 = Cs(n2.state, e2.from, e2.to);
i2 && t2.push(Di.of(i2), Bh(n2, i2, false));
}
return t2.length && n2.dispatch({ effects: t2 }), t2.length > 0;
};
function Bh(n2, t2, e2 = true) {
let i2 = n2.state.doc.lineAt(t2.from).number, s = n2.state.doc.lineAt(t2.to).number;
return T.announce.of(`${n2.state.phrase(e2 ? "Folded lines" : "Unfolded lines")} ${i2} ${n2.state.phrase("to")} ${s}.`);
}
const Zd = (n2) => {
let { state: t2 } = n2, e2 = [];
for (let i2 = 0; i2 < t2.doc.length; ) {
let s = n2.lineBlockAt(i2), r2 = Ss(t2, s.from, s.to);
r2 && e2.push(Ls.of(r2)), i2 = (r2 ? n2.lineBlockAt(r2.to) : s).to + 1;
}
return e2.length && n2.dispatch({ effects: Ph(n2.state, e2) }), !!e2.length;
}, tp = (n2) => {
let t2 = n2.state.field(Ie, false);
if (!t2 || !t2.size)
return false;
let e2 = [];
return t2.between(0, n2.state.doc.length, (i2, s) => {
e2.push(Di.of({ from: i2, to: s }));
}), n2.dispatch({ effects: e2 }), true;
}, ep = [
{ key: "Ctrl-Shift-[", mac: "Cmd-Alt-[", run: Jd },
{ key: "Ctrl-Shift-]", mac: "Cmd-Alt-]", run: Xd },
{ key: "Ctrl-Alt-[", run: Zd },
{ key: "Ctrl-Alt-]", run: tp }
], ip = {
placeholderDOM: null,
preparePlaceholder: null,
placeholderText: "…"
}, ur = /* @__PURE__ */ O$3.define({
combine(n2) {
return Ds(n2, ip);
}
});
function Rh(n2) {
let t2 = [Ie, op];
return n2 && t2.push(ur.of(n2)), t2;
}
function Lh(n2, t2) {
let { state: e2 } = n2, i2 = e2.facet(ur), s = (o) => {
let l = n2.lineBlockAt(n2.posAtDOM(o.target)), h2 = Cs(n2.state, l.from, l.to);
h2 && n2.dispatch({ effects: Di.of(h2) }), o.preventDefault();
};
if (i2.placeholderDOM)
return i2.placeholderDOM(n2, s, t2);
let r2 = document.createElement("span");
return r2.textContent = i2.placeholderText, r2.setAttribute("aria-label", e2.phrase("folded code")), r2.title = e2.phrase("unfold"), r2.className = "cm-foldPlaceholder", r2.onclick = s, r2;
}
const To = /* @__PURE__ */ N$2.replace({ widget: /* @__PURE__ */ new class extends Se {
toDOM(n2) {
return Lh(n2, null);
}
}() });
class sp extends Se {
constructor(t2) {
super(), this.value = t2;
}
eq(t2) {
return this.value == t2.value;
}
toDOM(t2) {
return Lh(t2, this.value);
}
}
const np = {
openText: "⌄",
closedText: "",
markerDOM: null,
domEventHandlers: {},
foldingChanged: () => false
};
class Xs extends ke {
constructor(t2, e2) {
super(), this.config = t2, this.open = e2;
}
eq(t2) {
return this.config == t2.config && this.open == t2.open;
}
toDOM(t2) {
if (this.config.markerDOM)
return this.config.markerDOM(this.open);
let e2 = document.createElement("span");
return e2.textContent = this.open ? this.config.openText : this.config.closedText, e2.title = t2.state.phrase(this.open ? "Fold line" : "Unfold line"), e2;
}
}
function rp(n2 = {}) {
let t2 = Object.assign(Object.assign({}, np), n2), e2 = new Xs(t2, true), i2 = new Xs(t2, false), s = yt.fromClass(class {
constructor(o) {
this.from = o.viewport.from, this.markers = this.buildMarkers(o);
}
update(o) {
(o.docChanged || o.viewportChanged || o.startState.facet(ve) != o.state.facet(ve) || o.startState.field(Ie, false) != o.state.field(Ie, false) || At(o.startState) != At(o.state) || t2.foldingChanged(o)) && (this.markers = this.buildMarkers(o.view));
}
buildMarkers(o) {
let l = new Ee();
for (let h2 of o.viewportLineBlocks) {
let a2 = Cs(o.state, h2.from, h2.to) ? i2 : Ss(o.state, h2.from, h2.to) ? e2 : null;
a2 && l.add(h2.from, h2.from, a2);
}
return l.finish();
}
}), { domEventHandlers: r2 } = t2;
return [
s,
hd({
class: "cm-foldGutter",
markers(o) {
var l;
return ((l = o.plugin(s)) === null || l === void 0 ? void 0 : l.markers) || F.empty;
},
initialSpacer() {
return new Xs(t2, false);
},
domEventHandlers: Object.assign(Object.assign({}, r2), { click: (o, l, h2) => {
if (r2.click && r2.click(o, l, h2))
return true;
let a2 = Cs(o.state, l.from, l.to);
if (a2)
return o.dispatch({ effects: Di.of(a2) }), true;
let c2 = Ss(o.state, l.from, l.to);
return c2 ? (o.dispatch({ effects: Ls.of(c2) }), true) : false;
} })
}),
Rh()
];
}
const op = /* @__PURE__ */ T.baseTheme({
".cm-foldPlaceholder": {
backgroundColor: "#eee",
border: "1px solid #ddd",
color: "#888",
borderRadius: ".2em",
margin: "0 1px",
padding: "0 1px",
cursor: "pointer"
},
".cm-foldGutter span": {
padding: "0 1px",
cursor: "pointer"
}
});
class Pi {
constructor(t2, e2) {
this.specs = t2;
let i2;
function s(l) {
let h2 = we.newName();
return (i2 || (i2 = /* @__PURE__ */ Object.create(null)))["." + h2] = l, h2;
}
const r2 = typeof e2.all == "string" ? e2.all : e2.all ? s(e2.all) : void 0, o = e2.scope;
this.scope = o instanceof Rt ? (l) => l.prop(ze) == o.data : o ? (l) => l == o : void 0, this.style = Sh(t2.map((l) => ({
tag: l.tag,
class: l.class || s(Object.assign({}, l, { tag: null }))
})), {
all: r2
}).style, this.module = i2 ? new we(i2) : null, this.themeType = e2.themeType;
}
/**
Create a highlighter style that associates the given styles to
the given tags. The specs must be objects that hold a style tag
or array of tags in their `tag` property, and either a single
`class` property providing a static CSS class (for highlighter
that rely on external styling), or a
[`style-mod`](https://github.com/marijnh/style-mod#documentation)-style
set of CSS properties (which define the styling for those tags).
The CSS rules created for a highlighter will be emitted in the
order of the spec's properties. That means that for elements that
have multiple tags associated with them, styles defined further
down in the list will have a higher CSS precedence than styles
defined earlier.
*/
static define(t2, e2) {
return new Pi(t2, e2 || {});
}
}
const Fn = /* @__PURE__ */ O$3.define(), Eh = /* @__PURE__ */ O$3.define({
combine(n2) {
return n2.length ? [n2[0]] : null;
}
});
function Zs(n2) {
let t2 = n2.facet(Fn);
return t2.length ? t2 : n2.facet(Eh);
}
function Do(n2, t2) {
let e2 = [hp], i2;
return n2 instanceof Pi && (n2.module && e2.push(T.styleModule.of(n2.module)), i2 = n2.themeType), t2 != null && t2.fallback ? e2.push(Eh.of(n2)) : i2 ? e2.push(Fn.computeN([T.darkTheme], (s) => s.facet(T.darkTheme) == (i2 == "dark") ? [n2] : [])) : e2.push(Fn.of(n2)), e2;
}
class lp {
constructor(t2) {
this.markCache = /* @__PURE__ */ Object.create(null), this.tree = At(t2.state), this.decorations = this.buildDeco(t2, Zs(t2.state));
}
update(t2) {
let e2 = At(t2.state), i2 = Zs(t2.state), s = i2 != Zs(t2.startState);
e2.length < t2.view.viewport.to && !s && e2.type == this.tree.type ? this.decorations = this.decorations.map(t2.changes) : (e2 != this.tree || t2.viewportChanged || s) && (this.tree = e2, this.decorations = this.buildDeco(t2.view, i2));
}
buildDeco(t2, e2) {
if (!e2 || !this.tree.length)
return N$2.none;
let i2 = new Ee();
for (let { from: s, to: r2 } of t2.visibleRanges)
Td(this.tree, e2, (o, l, h2) => {
i2.add(o, l, this.markCache[h2] || (this.markCache[h2] = N$2.mark({ class: h2 })));
}, s, r2);
return i2.finish();
}
}
const hp = /* @__PURE__ */ Qn.high(/* @__PURE__ */ yt.fromClass(lp, {
decorations: (n2) => n2.decorations
})), ap = /* @__PURE__ */ Pi.define([
{
tag: w$2.meta,
color: "#404740"
},
{
tag: w$2.link,
textDecoration: "underline"
},
{
tag: w$2.heading,
textDecoration: "underline",
fontWeight: "bold"
},
{
tag: w$2.emphasis,
fontStyle: "italic"
},
{
tag: w$2.strong,
fontWeight: "bold"
},
{
tag: w$2.strikethrough,
textDecoration: "line-through"
},
{
tag: w$2.keyword,
color: "#708"
},
{
tag: [w$2.atom, w$2.bool, w$2.url, w$2.contentSeparator, w$2.labelName],
color: "#219"
},
{
tag: [w$2.literal, w$2.inserted],
color: "#164"
},
{
tag: [w$2.string, w$2.deleted],
color: "#a11"
},
{
tag: [w$2.regexp, w$2.escape, /* @__PURE__ */ w$2.special(w$2.string)],
color: "#e40"
},
{
tag: /* @__PURE__ */ w$2.definition(w$2.variableName),
color: "#00f"
},
{
tag: /* @__PURE__ */ w$2.local(w$2.variableName),
color: "#30a"
},
{
tag: [w$2.typeName, w$2.namespace],
color: "#085"
},
{
tag: w$2.className,
color: "#167"
},
{
tag: [/* @__PURE__ */ w$2.special(w$2.variableName), w$2.macroName],
color: "#256"
},
{
tag: /* @__PURE__ */ w$2.definition(w$2.propertyName),
color: "#00c"
},
{
tag: w$2.comment,
color: "#940"
},
{
tag: w$2.invalid,
color: "#f00"
}
]), cp = /* @__PURE__ */ T.baseTheme({
"&.cm-focused .cm-matchingBracket": { backgroundColor: "#328c8252" },
"&.cm-focused .cm-nonmatchingBracket": { backgroundColor: "#bb555544" }
}), Nh = 1e4, Ih = "()[]{}", Vh = /* @__PURE__ */ O$3.define({
combine(n2) {
return Ds(n2, {
afterCursor: true,
brackets: Ih,
maxScanDistance: Nh,
renderMatch: dp
});
}
}), fp = /* @__PURE__ */ N$2.mark({ class: "cm-matchingBracket" }), up = /* @__PURE__ */ N$2.mark({ class: "cm-nonmatchingBracket" });
function dp(n2) {
let t2 = [], e2 = n2.matched ? fp : up;
return t2.push(e2.range(n2.start.from, n2.start.to)), n2.end && t2.push(e2.range(n2.end.from, n2.end.to)), t2;
}
const pp = /* @__PURE__ */ Ht.define({
create() {
return N$2.none;
},
update(n2, t2) {
if (!t2.docChanged && !t2.selection)
return n2;
let e2 = [], i2 = t2.state.facet(Vh);
for (let s of t2.state.selection.ranges) {
if (!s.empty)
continue;
let r2 = Yt(t2.state, s.head, -1, i2) || s.head > 0 && Yt(t2.state, s.head - 1, 1, i2) || i2.afterCursor && (Yt(t2.state, s.head, 1, i2) || s.head < t2.state.doc.length && Yt(t2.state, s.head + 1, -1, i2));
r2 && (e2 = e2.concat(i2.renderMatch(r2, t2.state)));
}
return N$2.set(e2, true);
},
provide: (n2) => T.decorations.from(n2)
}), gp = [
pp,
cp
];
function mp(n2 = {}) {
return [Vh.of(n2), gp];
}
const wp = /* @__PURE__ */ new R$1();
function _n(n2, t2, e2) {
let i2 = n2.prop(t2 < 0 ? R$1.openedBy : R$1.closedBy);
if (i2)
return i2;
if (n2.name.length == 1) {
let s = e2.indexOf(n2.name);
if (s > -1 && s % 2 == (t2 < 0 ? 1 : 0))
return [e2[s + t2]];
}
return null;
}
function zn(n2) {
let t2 = n2.type.prop(wp);
return t2 ? t2(n2.node) : n2;
}
function Yt(n2, t2, e2, i2 = {}) {
let s = i2.maxScanDistance || Nh, r2 = i2.brackets || Ih, o = At(n2), l = o.resolveInner(t2, e2);
for (let h2 = l; h2; h2 = h2.parent) {
let a2 = _n(h2.type, e2, r2);
if (a2 && h2.from < h2.to) {
let c2 = zn(h2);
if (c2 && (e2 > 0 ? t2 >= c2.from && t2 < c2.to : t2 > c2.from && t2 <= c2.to))
return yp(n2, t2, e2, h2, c2, a2, r2);
}
}
return bp(n2, t2, e2, o, l.type, s, r2);
}
function yp(n2, t2, e2, i2, s, r2, o) {
let l = i2.parent, h2 = { from: s.from, to: s.to }, a2 = 0, c2 = l == null ? void 0 : l.cursor();
if (c2 && (e2 < 0 ? c2.childBefore(i2.from) : c2.childAfter(i2.to)))
do
if (e2 < 0 ? c2.to <= i2.from : c2.from >= i2.to) {
if (a2 == 0 && r2.indexOf(c2.type.name) > -1 && c2.from < c2.to) {
let f2 = zn(c2);
return { start: h2, end: f2 ? { from: f2.from, to: f2.to } : void 0, matched: true };
} else if (_n(c2.type, e2, o))
a2++;
else if (_n(c2.type, -e2, o)) {
if (a2 == 0) {
let f2 = zn(c2);
return {
start: h2,
end: f2 && f2.from < f2.to ? { from: f2.from, to: f2.to } : void 0,
matched: false
};
}
a2--;
}
}
while (e2 < 0 ? c2.prevSibling() : c2.nextSibling());
return { start: h2, matched: false };
}
function bp(n2, t2, e2, i2, s, r2, o) {
let l = e2 < 0 ? n2.sliceDoc(t2 - 1, t2) : n2.sliceDoc(t2, t2 + 1), h2 = o.indexOf(l);
if (h2 < 0 || h2 % 2 == 0 != e2 > 0)
return null;
let a2 = { from: e2 < 0 ? t2 - 1 : t2, to: e2 > 0 ? t2 + 1 : t2 }, c2 = n2.doc.iterRange(t2, e2 > 0 ? n2.doc.length : 0), f2 = 0;
for (let u2 = 0; !c2.next().done && u2 <= r2; ) {
let d2 = c2.value;
e2 < 0 && (u2 += d2.length);
let p2 = t2 + u2 * e2;
for (let m = e2 > 0 ? 0 : d2.length - 1, g = e2 > 0 ? d2.length : -1; m != g; m += e2) {
let y2 = o.indexOf(d2[m]);
if (!(y2 < 0 || i2.resolveInner(p2 + m, 1).type != s))
if (y2 % 2 == 0 == e2 > 0)
f2++;
else {
if (f2 == 1)
return { start: a2, end: { from: p2 + m, to: p2 + m + 1 }, matched: y2 >> 1 == h2 >> 1 };
f2--;
}
}
e2 > 0 && (u2 += d2.length);
}
return c2.done ? { start: a2, matched: false } : null;
}
const kp = /* @__PURE__ */ Object.create(null), Po = [bt.none], Bo = [], xp = /* @__PURE__ */ Object.create(null);
for (let [n2, t2] of [
["variable", "variableName"],
["variable-2", "variableName.special"],
["string-2", "string.special"],
["def", "variableName.definition"],
["tag", "tagName"],
["attribute", "attributeName"],
["type", "typeName"],
["builtin", "variableName.standard"],
["qualifier", "modifier"],
["error", "invalid"],
["header", "heading"],
["property", "propertyName"]
])
xp[n2] = /* @__PURE__ */ vp(kp, t2);
function tn(n2, t2) {
Bo.indexOf(n2) > -1 || (Bo.push(n2), console.warn(t2));
}
function vp(n2, t2) {
let e2 = [];
for (let r2 of t2.split(" ")) {
let o = [];
for (let l of r2.split(".")) {
let h2 = n2[l] || w$2[l];
h2 ? typeof h2 == "function" ? o.length ? o = o.map(h2) : tn(l, `Modifier ${l} used at start of tag`) : o.length ? tn(l, `Tag ${l} used as modifier`) : o = Array.isArray(h2) ? h2 : [h2] : tn(l, `Unknown highlighting tag ${l}`);
}
for (let l of o)
e2.push(l);
}
if (!e2.length)
return 0;
let i2 = t2.replace(/ /g, "_"), s = bt.define({
id: Po.length,
name: i2,
props: [xh({ [i2]: e2 })]
});
return Po.push(s), s.id;
}
const Sp = (n2) => {
let { state: t2 } = n2, e2 = t2.doc.lineAt(t2.selection.main.from), i2 = pr(n2.state, e2.from);
return i2.line ? Cp(n2) : i2.block ? Op(n2) : false;
};
function dr(n2, t2) {
return ({ state: e2, dispatch: i2 }) => {
if (e2.readOnly)
return false;
let s = n2(t2, e2);
return s ? (i2(e2.update(s)), true) : false;
};
}
const Cp = /* @__PURE__ */ dr(
Dp,
0
/* CommentOption.Toggle */
), Ap = /* @__PURE__ */ dr(
Hh,
0
/* CommentOption.Toggle */
), Op = /* @__PURE__ */ dr(
(n2, t2) => Hh(n2, t2, Tp(t2)),
0
/* CommentOption.Toggle */
);
function pr(n2, t2) {
let e2 = n2.languageDataAt("commentTokens", t2);
return e2.length ? e2[0] : {};
}
const li = 50;
function Mp(n2, { open: t2, close: e2 }, i2, s) {
let r2 = n2.sliceDoc(i2 - li, i2), o = n2.sliceDoc(s, s + li), l = /\s*$/.exec(r2)[0].length, h2 = /^\s*/.exec(o)[0].length, a2 = r2.length - l;
if (r2.slice(a2 - t2.length, a2) == t2 && o.slice(h2, h2 + e2.length) == e2)
return {
open: { pos: i2 - l, margin: l && 1 },
close: { pos: s + h2, margin: h2 && 1 }
};
let c2, f2;
s - i2 <= 2 * li ? c2 = f2 = n2.sliceDoc(i2, s) : (c2 = n2.sliceDoc(i2, i2 + li), f2 = n2.sliceDoc(s - li, s));
let u2 = /^\s*/.exec(c2)[0].length, d2 = /\s*$/.exec(f2)[0].length, p2 = f2.length - d2 - e2.length;
return c2.slice(u2, u2 + t2.length) == t2 && f2.slice(p2, p2 + e2.length) == e2 ? {
open: {
pos: i2 + u2 + t2.length,
margin: /\s/.test(c2.charAt(u2 + t2.length)) ? 1 : 0
},
close: {
pos: s - d2 - e2.length,
margin: /\s/.test(f2.charAt(p2 - 1)) ? 1 : 0
}
} : null;
}
function Tp(n2) {
let t2 = [];
for (let e2 of n2.selection.ranges) {
let i2 = n2.doc.lineAt(e2.from), s = e2.to <= i2.to ? i2 : n2.doc.lineAt(e2.to), r2 = t2.length - 1;
r2 >= 0 && t2[r2].to > i2.from ? t2[r2].to = s.to : t2.push({ from: i2.from + /^\s*/.exec(i2.text)[0].length, to: s.to });
}
return t2;
}
function Hh(n2, t2, e2 = t2.selection.ranges) {
let i2 = e2.map((r2) => pr(t2, r2.from).block);
if (!i2.every((r2) => r2))
return null;
let s = e2.map((r2, o) => Mp(t2, i2[o], r2.from, r2.to));
if (n2 != 2 && !s.every((r2) => r2))
return { changes: t2.changes(e2.map((r2, o) => s[o] ? [] : [{ from: r2.from, insert: i2[o].open + " " }, { from: r2.to, insert: " " + i2[o].close }])) };
if (n2 != 1 && s.some((r2) => r2)) {
let r2 = [];
for (let o = 0, l; o < s.length; o++)
if (l = s[o]) {
let h2 = i2[o], { open: a2, close: c2 } = l;
r2.push({ from: a2.pos - h2.open.length, to: a2.pos + a2.margin }, { from: c2.pos - c2.margin, to: c2.pos + h2.close.length });
}
return { changes: r2 };
}
return null;
}
function Dp(n2, t2, e2 = t2.selection.ranges) {
let i2 = [], s = -1;
for (let { from: r2, to: o } of e2) {
let l = i2.length, h2 = 1e9, a2 = pr(t2, r2).line;
if (a2) {
for (let c2 = r2; c2 <= o; ) {
let f2 = t2.doc.lineAt(c2);
if (f2.from > s && (r2 == o || o > f2.from)) {
s = f2.from;
let u2 = /^\s*/.exec(f2.text)[0].length, d2 = u2 == f2.length, p2 = f2.text.slice(u2, u2 + a2.length) == a2 ? u2 : -1;
u2 < f2.text.length && u2 < h2 && (h2 = u2), i2.push({ line: f2, comment: p2, token: a2, indent: u2, empty: d2, single: false });
}
c2 = f2.to + 1;
}
if (h2 < 1e9)
for (let c2 = l; c2 < i2.length; c2++)
i2[c2].indent < i2[c2].line.text.length && (i2[c2].indent = h2);
i2.length == l + 1 && (i2[l].single = true);
}
}
if (n2 != 2 && i2.some((r2) => r2.comment < 0 && (!r2.empty || r2.single))) {
let r2 = [];
for (let { line: l, token: h2, indent: a2, empty: c2, single: f2 } of i2)
(f2 || !c2) && r2.push({ from: l.from + a2, insert: h2 + " " });
let o = t2.changes(r2);
return { changes: o, selection: t2.selection.map(o, 1) };
} else if (n2 != 1 && i2.some((r2) => r2.comment >= 0)) {
let r2 = [];
for (let { line: o, comment: l, token: h2 } of i2)
if (l >= 0) {
let a2 = o.from + l, c2 = a2 + h2.length;
o.text[c2 - o.from] == " " && c2++, r2.push({ from: a2, to: c2 });
}
return { changes: r2 };
}
return null;
}
function ei(n2, t2) {
return b$1.create(n2.ranges.map(t2), n2.mainIndex);
}
function Qt(n2, t2) {
return n2.update({ selection: t2, scrollIntoView: true, userEvent: "select" });
}
function $t({ state: n2, dispatch: t2 }, e2) {
let i2 = ei(n2.selection, e2);
return i2.eq(n2.selection) ? false : (t2(Qt(n2, i2)), true);
}
function Es(n2, t2) {
return b$1.cursor(t2 ? n2.to : n2.from);
}
function $h(n2, t2) {
return $t(n2, (e2) => e2.empty ? n2.moveByChar(e2, t2) : Es(e2, t2));
}
function ut(n2) {
return n2.textDirectionAt(n2.state.selection.main.head) == tt.LTR;
}
const Fh = (n2) => $h(n2, !ut(n2)), _h = (n2) => $h(n2, ut(n2));
function zh(n2, t2) {
return $t(n2, (e2) => e2.empty ? n2.moveByGroup(e2, t2) : Es(e2, t2));
}
const Pp = (n2) => zh(n2, !ut(n2)), Bp = (n2) => zh(n2, ut(n2));
function Rp(n2, t2, e2) {
if (t2.type.prop(e2))
return true;
let i2 = t2.to - t2.from;
return i2 && (i2 > 2 || /[^\s,.;:]/.test(n2.sliceDoc(t2.from, t2.to))) || t2.firstChild;
}
function Ns(n2, t2, e2) {
let i2 = At(n2).resolveInner(t2.head), s = e2 ? R$1.closedBy : R$1.openedBy;
for (let h2 = t2.head; ; ) {
let a2 = e2 ? i2.childAfter(h2) : i2.childBefore(h2);
if (!a2)
break;
Rp(n2, a2, s) ? i2 = a2 : h2 = e2 ? a2.to : a2.from;
}
let r2 = i2.type.prop(s), o, l;
return r2 && (o = e2 ? Yt(n2, i2.from, 1) : Yt(n2, i2.to, -1)) && o.matched ? l = e2 ? o.end.to : o.end.from : l = e2 ? i2.to : i2.from, b$1.cursor(l, e2 ? -1 : 1);
}
const Lp = (n2) => $t(n2, (t2) => Ns(n2.state, t2, !ut(n2))), Ep = (n2) => $t(n2, (t2) => Ns(n2.state, t2, ut(n2)));
function Wh(n2, t2) {
return $t(n2, (e2) => {
if (!e2.empty)
return Es(e2, t2);
let i2 = n2.moveVertically(e2, t2);
return i2.head != e2.head ? i2 : n2.moveToLineBoundary(e2, t2);
});
}
const jh = (n2) => Wh(n2, false), Kh = (n2) => Wh(n2, true);
function qh(n2) {
let t2 = n2.scrollDOM.clientHeight < n2.scrollDOM.scrollHeight - 2, e2 = 0, i2 = 0, s;
if (t2) {
for (let r2 of n2.state.facet(T.scrollMargins)) {
let o = r2(n2);
o != null && o.top && (e2 = Math.max(o == null ? void 0 : o.top, e2)), o != null && o.bottom && (i2 = Math.max(o == null ? void 0 : o.bottom, i2));
}
s = n2.scrollDOM.clientHeight - e2 - i2;
} else
s = (n2.dom.ownerDocument.defaultView || window).innerHeight;
return {
marginTop: e2,
marginBottom: i2,
selfScroll: t2,
height: Math.max(n2.defaultLineHeight, s - 5)
};
}
function Gh(n2, t2) {
let e2 = qh(n2), { state: i2 } = n2, s = ei(i2.selection, (o) => o.empty ? n2.moveVertically(o, t2, e2.height) : Es(o, t2));
if (s.eq(i2.selection))
return false;
let r2;
if (e2.selfScroll) {
let o = n2.coordsAtPos(i2.selection.main.head), l = n2.scrollDOM.getBoundingClientRect(), h2 = l.top + e2.marginTop, a2 = l.bottom - e2.marginBottom;
o && o.top > h2 && o.bottom < a2 && (r2 = T.scrollIntoView(s.main.head, { y: "start", yMargin: o.top - h2 }));
}
return n2.dispatch(Qt(i2, s), { effects: r2 }), true;
}
const Ro = (n2) => Gh(n2, false), Wn = (n2) => Gh(n2, true);
function Ce(n2, t2, e2) {
let i2 = n2.lineBlockAt(t2.head), s = n2.moveToLineBoundary(t2, e2);
if (s.head == t2.head && s.head != (e2 ? i2.to : i2.from) && (s = n2.moveToLineBoundary(t2, e2, false)), !e2 && s.head == i2.from && i2.length) {
let r2 = /^\s*/.exec(n2.state.sliceDoc(i2.from, Math.min(i2.from + 100, i2.to)))[0].length;
r2 && t2.head != i2.from + r2 && (s = b$1.cursor(i2.from + r2));
}
return s;
}
const Np = (n2) => $t(n2, (t2) => Ce(n2, t2, true)), Ip = (n2) => $t(n2, (t2) => Ce(n2, t2, false)), Vp = (n2) => $t(n2, (t2) => Ce(n2, t2, !ut(n2))), Hp = (n2) => $t(n2, (t2) => Ce(n2, t2, ut(n2))), $p = (n2) => $t(n2, (t2) => b$1.cursor(n2.lineBlockAt(t2.head).from, 1)), Fp = (n2) => $t(n2, (t2) => b$1.cursor(n2.lineBlockAt(t2.head).to, -1));
function _p(n2, t2, e2) {
let i2 = false, s = ei(n2.selection, (r2) => {
let o = Yt(n2, r2.head, -1) || Yt(n2, r2.head, 1) || r2.head > 0 && Yt(n2, r2.head - 1, 1) || r2.head < n2.doc.length && Yt(n2, r2.head + 1, -1);
if (!o || !o.end)
return r2;
i2 = true;
let l = o.start.from == r2.head ? o.end.to : o.end.from;
return e2 ? b$1.range(r2.anchor, l) : b$1.cursor(l);
});
return i2 ? (t2(Qt(n2, s)), true) : false;
}
const zp = ({ state: n2, dispatch: t2 }) => _p(n2, t2, false);
function Bt(n2, t2) {
let e2 = ei(n2.state.selection, (i2) => {
let s = t2(i2);
return b$1.range(i2.anchor, s.head, s.goalColumn, s.bidiLevel || void 0);
});
return e2.eq(n2.state.selection) ? false : (n2.dispatch(Qt(n2.state, e2)), true);
}
function Uh(n2, t2) {
return Bt(n2, (e2) => n2.moveByChar(e2, t2));
}
const Yh = (n2) => Uh(n2, !ut(n2)), Qh = (n2) => Uh(n2, ut(n2));
function Jh(n2, t2) {
return Bt(n2, (e2) => n2.moveByGroup(e2, t2));
}
const Wp = (n2) => Jh(n2, !ut(n2)), jp = (n2) => Jh(n2, ut(n2)), Kp = (n2) => Bt(n2, (t2) => Ns(n2.state, t2, !ut(n2))), qp = (n2) => Bt(n2, (t2) => Ns(n2.state, t2, ut(n2)));
function Xh(n2, t2) {
return Bt(n2, (e2) => n2.moveVertically(e2, t2));
}
const Zh = (n2) => Xh(n2, false), ta = (n2) => Xh(n2, true);
function ea(n2, t2) {
return Bt(n2, (e2) => n2.moveVertically(e2, t2, qh(n2).height));
}
const Lo = (n2) => ea(n2, false), Eo = (n2) => ea(n2, true), Gp = (n2) => Bt(n2, (t2) => Ce(n2, t2, true)), Up = (n2) => Bt(n2, (t2) => Ce(n2, t2, false)), Yp = (n2) => Bt(n2, (t2) => Ce(n2, t2, !ut(n2))), Qp = (n2) => Bt(n2, (t2) => Ce(n2, t2, ut(n2))), Jp = (n2) => Bt(n2, (t2) => b$1.cursor(n2.lineBlockAt(t2.head).from)), Xp = (n2) => Bt(n2, (t2) => b$1.cursor(n2.lineBlockAt(t2.head).to)), No = ({ state: n2, dispatch: t2 }) => (t2(Qt(n2, { anchor: 0 })), true), Io = ({ state: n2, dispatch: t2 }) => (t2(Qt(n2, { anchor: n2.doc.length })), true), Vo = ({ state: n2, dispatch: t2 }) => (t2(Qt(n2, { anchor: n2.selection.main.anchor, head: 0 })), true), Ho = ({ state: n2, dispatch: t2 }) => (t2(Qt(n2, { anchor: n2.selection.main.anchor, head: n2.doc.length })), true), Zp = ({ state: n2, dispatch: t2 }) => (t2(n2.update({ selection: { anchor: 0, head: n2.doc.length }, userEvent: "select" })), true), tg = ({ state: n2, dispatch: t2 }) => {
let e2 = Is(n2).map(({ from: i2, to: s }) => b$1.range(i2, Math.min(s + 1, n2.doc.length)));
return t2(n2.update({ selection: b$1.create(e2), userEvent: "select" })), true;
}, eg = ({ state: n2, dispatch: t2 }) => {
let e2 = ei(n2.selection, (i2) => {
var s;
let r2 = At(n2).resolveStack(i2.from, 1);
for (let o = r2; o; o = o.next) {
let { node: l } = o;
if ((l.from < i2.from && l.to >= i2.to || l.to > i2.to && l.from <= i2.from) && (!((s = l.parent) === null || s === void 0) && s.parent))
return b$1.range(l.to, l.from);
}
return i2;
});
return t2(Qt(n2, e2)), true;
}, ig = ({ state: n2, dispatch: t2 }) => {
let e2 = n2.selection, i2 = null;
return e2.ranges.length > 1 ? i2 = b$1.create([e2.main]) : e2.main.empty || (i2 = b$1.create([b$1.cursor(e2.main.head)])), i2 ? (t2(Qt(n2, i2)), true) : false;
};
function Bi(n2, t2) {
if (n2.state.readOnly)
return false;
let e2 = "delete.selection", { state: i2 } = n2, s = i2.changeByRange((r2) => {
let { from: o, to: l } = r2;
if (o == l) {
let h2 = t2(r2);
h2 < o ? (e2 = "delete.backward", h2 = Yi(n2, h2, false)) : h2 > o && (e2 = "delete.forward", h2 = Yi(n2, h2, true)), o = Math.min(o, h2), l = Math.max(l, h2);
} else
o = Yi(n2, o, false), l = Yi(n2, l, true);
return o == l ? { range: r2 } : { changes: { from: o, to: l }, range: b$1.cursor(o, o < r2.head ? -1 : 1) };
});
return s.changes.empty ? false : (n2.dispatch(i2.update(s, {
scrollIntoView: true,
userEvent: e2,
effects: e2 == "delete.selection" ? T.announce.of(i2.phrase("Selection deleted")) : void 0
})), true);
}
function Yi(n2, t2, e2) {
if (n2 instanceof T)
for (let i2 of n2.state.facet(T.atomicRanges).map((s) => s(n2)))
i2.between(t2, t2, (s, r2) => {
s < t2 && r2 > t2 && (t2 = e2 ? r2 : s);
});
return t2;
}
const ia = (n2, t2) => Bi(n2, (e2) => {
let i2 = e2.from, { state: s } = n2, r2 = s.doc.lineAt(i2), o, l;
if (!t2 && i2 > r2.from && i2 < r2.from + 200 && !/[^ \t]/.test(o = r2.text.slice(0, i2 - r2.from))) {
if (o[o.length - 1] == " ")
return i2 - 1;
let h2 = Oi(o, s.tabSize), a2 = h2 % vs(s) || vs(s);
for (let c2 = 0; c2 < a2 && o[o.length - 1 - c2] == " "; c2++)
i2--;
l = i2;
} else
l = wt(r2.text, i2 - r2.from, t2, t2) + r2.from, l == i2 && r2.number != (t2 ? s.doc.lines : 1) && (l += t2 ? 1 : -1);
return l;
}), jn = (n2) => ia(n2, false), sa = (n2) => ia(n2, true), na = (n2, t2) => Bi(n2, (e2) => {
let i2 = e2.head, { state: s } = n2, r2 = s.doc.lineAt(i2), o = s.charCategorizer(i2);
for (let l = null; ; ) {
if (i2 == (t2 ? r2.to : r2.from)) {
i2 == e2.head && r2.number != (t2 ? s.doc.lines : 1) && (i2 += t2 ? 1 : -1);
break;
}
let h2 = wt(r2.text, i2 - r2.from, t2) + r2.from, a2 = r2.text.slice(Math.min(i2, h2) - r2.from, Math.max(i2, h2) - r2.from), c2 = o(a2);
if (l != null && c2 != l)
break;
(a2 != " " || i2 != e2.head) && (l = c2), i2 = h2;
}
return i2;
}), ra = (n2) => na(n2, false), sg = (n2) => na(n2, true), ng = (n2) => Bi(n2, (t2) => {
let e2 = n2.lineBlockAt(t2.head).to;
return t2.head < e2 ? e2 : Math.min(n2.state.doc.length, t2.head + 1);
}), rg = (n2) => Bi(n2, (t2) => {
let e2 = n2.moveToLineBoundary(t2, false).head;
return t2.head > e2 ? e2 : Math.max(0, t2.head - 1);
}), og = (n2) => Bi(n2, (t2) => {
let e2 = n2.moveToLineBoundary(t2, true).head;
return t2.head < e2 ? e2 : Math.min(n2.state.doc.length, t2.head + 1);
}), lg = ({ state: n2, dispatch: t2 }) => {
if (n2.readOnly)
return false;
let e2 = n2.changeByRange((i2) => ({
changes: { from: i2.from, to: i2.to, insert: V.of(["", ""]) },
range: b$1.cursor(i2.from)
}));
return t2(n2.update(e2, { scrollIntoView: true, userEvent: "input" })), true;
}, hg = ({ state: n2, dispatch: t2 }) => {
if (n2.readOnly)
return false;
let e2 = n2.changeByRange((i2) => {
if (!i2.empty || i2.from == 0 || i2.from == n2.doc.length)
return { range: i2 };
let s = i2.from, r2 = n2.doc.lineAt(s), o = s == r2.from ? s - 1 : wt(r2.text, s - r2.from, false) + r2.from, l = s == r2.to ? s + 1 : wt(r2.text, s - r2.from, true) + r2.from;
return {
changes: { from: o, to: l, insert: n2.doc.slice(s, l).append(n2.doc.slice(o, s)) },
range: b$1.cursor(l)
};
});
return e2.changes.empty ? false : (t2(n2.update(e2, { scrollIntoView: true, userEvent: "move.character" })), true);
};
function Is(n2) {
let t2 = [], e2 = -1;
for (let i2 of n2.selection.ranges) {
let s = n2.doc.lineAt(i2.from), r2 = n2.doc.lineAt(i2.to);
if (!i2.empty && i2.to == r2.from && (r2 = n2.doc.lineAt(i2.to - 1)), e2 >= s.number) {
let o = t2[t2.length - 1];
o.to = r2.to, o.ranges.push(i2);
} else
t2.push({ from: s.from, to: r2.to, ranges: [i2] });
e2 = r2.number + 1;
}
return t2;
}
function oa(n2, t2, e2) {
if (n2.readOnly)
return false;
let i2 = [], s = [];
for (let r2 of Is(n2)) {
if (e2 ? r2.to == n2.doc.length : r2.from == 0)
continue;
let o = n2.doc.lineAt(e2 ? r2.to + 1 : r2.from - 1), l = o.length + 1;
if (e2) {
i2.push({ from: r2.to, to: o.to }, { from: r2.from, insert: o.text + n2.lineBreak });
for (let h2 of r2.ranges)
s.push(b$1.range(Math.min(n2.doc.length, h2.anchor + l), Math.min(n2.doc.length, h2.head + l)));
} else {
i2.push({ from: o.from, to: r2.from }, { from: r2.to, insert: n2.lineBreak + o.text });
for (let h2 of r2.ranges)
s.push(b$1.range(h2.anchor - l, h2.head - l));
}
}
return i2.length ? (t2(n2.update({
changes: i2,
scrollIntoView: true,
selection: b$1.create(s, n2.selection.mainIndex),
userEvent: "move.line"
})), true) : false;
}
const ag = ({ state: n2, dispatch: t2 }) => oa(n2, t2, false), cg = ({ state: n2, dispatch: t2 }) => oa(n2, t2, true);
function la(n2, t2, e2) {
if (n2.readOnly)
return false;
let i2 = [];
for (let s of Is(n2))
e2 ? i2.push({ from: s.from, insert: n2.doc.slice(s.from, s.to) + n2.lineBreak }) : i2.push({ from: s.to, insert: n2.lineBreak + n2.doc.slice(s.from, s.to) });
return t2(n2.update({ changes: i2, scrollIntoView: true, userEvent: "input.copyline" })), true;
}
const fg = ({ state: n2, dispatch: t2 }) => la(n2, t2, false), ug = ({ state: n2, dispatch: t2 }) => la(n2, t2, true), dg = (n2) => {
if (n2.state.readOnly)
return false;
let { state: t2 } = n2, e2 = t2.changes(Is(t2).map(({ from: s, to: r2 }) => (s > 0 ? s-- : r2 < t2.doc.length && r2++, { from: s, to: r2 }))), i2 = ei(t2.selection, (s) => n2.moveVertically(s, true)).map(e2);
return n2.dispatch({ changes: e2, selection: i2, scrollIntoView: true, userEvent: "delete.line" }), true;
};
function pg(n2, t2) {
if (/\(\)|\[\]|\{\}/.test(n2.sliceDoc(t2 - 1, t2 + 1)))
return { from: t2, to: t2 };
let e2 = At(n2).resolveInner(t2), i2 = e2.childBefore(t2), s = e2.childAfter(t2), r2;
return i2 && s && i2.to <= t2 && s.from >= t2 && (r2 = i2.type.prop(R$1.closedBy)) && r2.indexOf(s.name) > -1 && n2.doc.lineAt(i2.to).from == n2.doc.lineAt(s.from).from && !/\S/.test(n2.sliceDoc(i2.to, s.from)) ? { from: i2.to, to: s.from } : null;
}
const gg = /* @__PURE__ */ ha(false), mg = /* @__PURE__ */ ha(true);
function ha(n2) {
return ({ state: t2, dispatch: e2 }) => {
if (t2.readOnly)
return false;
let i2 = t2.changeByRange((s) => {
let { from: r2, to: o } = s, l = t2.doc.lineAt(r2), h2 = !n2 && r2 == o && pg(t2, r2);
n2 && (r2 = o = (o <= l.to ? l : t2.doc.lineAt(o)).to);
let a2 = new Rs(t2, { simulateBreak: r2, simulateDoubleBreak: !!h2 }), c2 = cr(a2, r2);
for (c2 == null && (c2 = Oi(/^\s*/.exec(t2.doc.lineAt(r2).text)[0], t2.tabSize)); o < l.to && /\s/.test(l.text[o - l.from]); )
o++;
h2 ? { from: r2, to: o } = h2 : r2 > l.from && r2 < l.from + 100 && !/\S/.test(l.text.slice(0, r2)) && (r2 = l.from);
let f2 = ["", Ci(t2, c2)];
return h2 && f2.push(Ci(t2, a2.lineIndent(l.from, -1))), {
changes: { from: r2, to: o, insert: V.of(f2) },
range: b$1.cursor(r2 + 1 + f2[1].length)
};
});
return e2(t2.update(i2, { scrollIntoView: true, userEvent: "input" })), true;
};
}
function gr(n2, t2) {
let e2 = -1;
return n2.changeByRange((i2) => {
let s = [];
for (let o = i2.from; o <= i2.to; ) {
let l = n2.doc.lineAt(o);
l.number > e2 && (i2.empty || i2.to > l.from) && (t2(l, s, i2), e2 = l.number), o = l.to + 1;
}
let r2 = n2.changes(s);
return {
changes: s,
range: b$1.range(r2.mapPos(i2.anchor, 1), r2.mapPos(i2.head, 1))
};
});
}
const wg = ({ state: n2, dispatch: t2 }) => {
if (n2.readOnly)
return false;
let e2 = /* @__PURE__ */ Object.create(null), i2 = new Rs(n2, { overrideIndentation: (r2) => {
let o = e2[r2];
return o ?? -1;
} }), s = gr(n2, (r2, o, l) => {
let h2 = cr(i2, r2.from);
if (h2 == null)
return;
/\S/.test(r2.text) || (h2 = 0);
let a2 = /^\s*/.exec(r2.text)[0], c2 = Ci(n2, h2);
(a2 != c2 || l.from < r2.from + a2.length) && (e2[r2.from] = h2, o.push({ from: r2.from, to: r2.from + a2.length, insert: c2 }));
});
return s.changes.empty || t2(n2.update(s, { userEvent: "indent" })), true;
}, yg = ({ state: n2, dispatch: t2 }) => n2.readOnly ? false : (t2(n2.update(gr(n2, (e2, i2) => {
i2.push({ from: e2.from, insert: n2.facet(ar) });
}), { userEvent: "input.indent" })), true), bg = ({ state: n2, dispatch: t2 }) => n2.readOnly ? false : (t2(n2.update(gr(n2, (e2, i2) => {
let s = /^\s*/.exec(e2.text)[0];
if (!s)
return;
let r2 = Oi(s, n2.tabSize), o = 0, l = Ci(n2, Math.max(0, r2 - vs(n2)));
for (; o < s.length && o < l.length && s.charCodeAt(o) == l.charCodeAt(o); )
o++;
i2.push({ from: e2.from + o, to: e2.from + s.length, insert: l.slice(o) });
}), { userEvent: "delete.dedent" })), true), kg = [
{ key: "Ctrl-b", run: Fh, shift: Yh, preventDefault: true },
{ key: "Ctrl-f", run: _h, shift: Qh },
{ key: "Ctrl-p", run: jh, shift: Zh },
{ key: "Ctrl-n", run: Kh, shift: ta },
{ key: "Ctrl-a", run: $p, shift: Jp },
{ key: "Ctrl-e", run: Fp, shift: Xp },
{ key: "Ctrl-d", run: sa },
{ key: "Ctrl-h", run: jn },
{ key: "Ctrl-k", run: ng },
{ key: "Ctrl-Alt-h", run: ra },
{ key: "Ctrl-o", run: lg },
{ key: "Ctrl-t", run: hg },
{ key: "Ctrl-v", run: Wn }
], xg = /* @__PURE__ */ [
{ key: "ArrowLeft", run: Fh, shift: Yh, preventDefault: true },
{ key: "Mod-ArrowLeft", mac: "Alt-ArrowLeft", run: Pp, shift: Wp, preventDefault: true },
{ mac: "Cmd-ArrowLeft", run: Vp, shift: Yp, preventDefault: true },
{ key: "ArrowRight", run: _h, shift: Qh, preventDefault: true },
{ key: "Mod-ArrowRight", mac: "Alt-ArrowRight", run: Bp, shift: jp, preventDefault: true },
{ mac: "Cmd-ArrowRight", run: Hp, shift: Qp, preventDefault: true },
{ key: "ArrowUp", run: jh, shift: Zh, preventDefault: true },
{ mac: "Cmd-ArrowUp", run: No, shift: Vo },
{ mac: "Ctrl-ArrowUp", run: Ro, shift: Lo },
{ key: "ArrowDown", run: Kh, shift: ta, preventDefault: true },
{ mac: "Cmd-ArrowDown", run: Io, shift: Ho },
{ mac: "Ctrl-ArrowDown", run: Wn, shift: Eo },
{ key: "PageUp", run: Ro, shift: Lo },
{ key: "PageDown", run: Wn, shift: Eo },
{ key: "Home", run: Ip, shift: Up, preventDefault: true },
{ key: "Mod-Home", run: No, shift: Vo },
{ key: "End", run: Np, shift: Gp, preventDefault: true },
{ key: "Mod-End", run: Io, shift: Ho },
{ key: "Enter", run: gg },
{ key: "Mod-a", run: Zp },
{ key: "Backspace", run: jn, shift: jn },
{ key: "Delete", run: sa },
{ key: "Mod-Backspace", mac: "Alt-Backspace", run: ra },
{ key: "Mod-Delete", mac: "Alt-Delete", run: sg },
{ mac: "Mod-Backspace", run: rg },
{ mac: "Mod-Delete", run: og }
].concat(/* @__PURE__ */ kg.map((n2) => ({ mac: n2.key, run: n2.run, shift: n2.shift }))), vg = /* @__PURE__ */ [
{ key: "Alt-ArrowLeft", mac: "Ctrl-ArrowLeft", run: Lp, shift: Kp },
{ key: "Alt-ArrowRight", mac: "Ctrl-ArrowRight", run: Ep, shift: qp },
{ key: "Alt-ArrowUp", run: ag },
{ key: "Shift-Alt-ArrowUp", run: fg },
{ key: "Alt-ArrowDown", run: cg },
{ key: "Shift-Alt-ArrowDown", run: ug },
{ key: "Escape", run: ig },
{ key: "Mod-Enter", run: mg },
{ key: "Alt-l", mac: "Ctrl-l", run: tg },
{ key: "Mod-i", run: eg, preventDefault: true },
{ key: "Mod-[", run: bg },
{ key: "Mod-]", run: yg },
{ key: "Mod-Alt-\\", run: wg },
{ key: "Shift-Mod-k", run: dg },
{ key: "Shift-Mod-\\", run: zp },
{ key: "Mod-/", run: Sp },
{ key: "Alt-A", run: Ap }
].concat(xg);
class As {
/**
@internal
*/
constructor(t2, e2, i2, s, r2, o, l, h2, a2, c2 = 0, f2) {
this.p = t2, this.stack = e2, this.state = i2, this.reducePos = s, this.pos = r2, this.score = o, this.buffer = l, this.bufferBase = h2, this.curContext = a2, this.lookAhead = c2, this.parent = f2;
}
/**
@internal
*/
toString() {
return `[${this.stack.filter((t2, e2) => e2 % 3 == 0).concat(this.state)}]@${this.pos}${this.score ? "!" + this.score : ""}`;
}
// Start an empty stack
/**
@internal
*/
static start(t2, e2, i2 = 0) {
let s = t2.parser.context;
return new As(t2, [], e2, i2, i2, 0, [], 0, s ? new $o(s, s.start) : null, 0, null);
}
/**
The stack's current [context](#lr.ContextTracker) value, if
any. Its type will depend on the context tracker's type
parameter, or it will be `null` if there is no context
tracker.
*/
get context() {
return this.curContext ? this.curContext.context : null;
}
// Push a state onto the stack, tracking its start position as well
// as the buffer base at that point.
/**
@internal
*/
pushState(t2, e2) {
this.stack.push(this.state, e2, this.bufferBase + this.buffer.length), this.state = t2;
}
// Apply a reduce action
/**
@internal
*/
reduce(t2) {
var e2;
let i2 = t2 >> 19, s = t2 & 65535, { parser: r2 } = this.p, o = r2.dynamicPrecedence(s);
if (o && (this.score += o), i2 == 0) {
this.pushState(r2.getGoto(this.state, s, true), this.reducePos), s < r2.minRepeatTerm && this.storeNode(s, this.reducePos, this.reducePos, 4, true), this.reduceContext(s, this.reducePos);
return;
}
let l = this.stack.length - (i2 - 1) * 3 - (t2 & 262144 ? 6 : 0), h2 = l ? this.stack[l - 2] : this.p.ranges[0].from, a2 = this.reducePos - h2;
a2 >= 2e3 && !(!((e2 = this.p.parser.nodeSet.types[s]) === null || e2 === void 0) && e2.isAnonymous) && (h2 == this.p.lastBigReductionStart ? (this.p.bigReductionCount++, this.p.lastBigReductionSize = a2) : this.p.lastBigReductionSize < a2 && (this.p.bigReductionCount = 1, this.p.lastBigReductionStart = h2, this.p.lastBigReductionSize = a2));
let c2 = l ? this.stack[l - 1] : 0, f2 = this.bufferBase + this.buffer.length - c2;
if (s < r2.minRepeatTerm || t2 & 131072) {
let u2 = r2.stateFlag(
this.state,
1
/* StateFlag.Skipped */
) ? this.pos : this.reducePos;
this.storeNode(s, h2, u2, f2 + 4, true);
}
if (t2 & 262144)
this.state = this.stack[l];
else {
let u2 = this.stack[l - 3];
this.state = r2.getGoto(u2, s, true);
}
for (; this.stack.length > l; )
this.stack.pop();
this.reduceContext(s, h2);
}
// Shift a value into the buffer
/**
@internal
*/
storeNode(t2, e2, i2, s = 4, r2 = false) {
if (t2 == 0 && (!this.stack.length || this.stack[this.stack.length - 1] < this.buffer.length + this.bufferBase)) {
let o = this, l = this.buffer.length;
if (l == 0 && o.parent && (l = o.bufferBase - o.parent.bufferBase, o = o.parent), l > 0 && o.buffer[l - 4] == 0 && o.buffer[l - 1] > -1) {
if (e2 == i2)
return;
if (o.buffer[l - 2] >= e2) {
o.buffer[l - 2] = i2;
return;
}
}
}
if (!r2 || this.pos == i2)
this.buffer.push(t2, e2, i2, s);
else {
let o = this.buffer.length;
if (o > 0 && this.buffer[o - 4] != 0)
for (; o > 0 && this.buffer[o - 2] > i2; )
this.buffer[o] = this.buffer[o - 4], this.buffer[o + 1] = this.buffer[o - 3], this.buffer[o + 2] = this.buffer[o - 2], this.buffer[o + 3] = this.buffer[o - 1], o -= 4, s > 4 && (s -= 4);
this.buffer[o] = t2, this.buffer[o + 1] = e2, this.buffer[o + 2] = i2, this.buffer[o + 3] = s;
}
}
// Apply a shift action
/**
@internal
*/
shift(t2, e2, i2, s) {
if (t2 & 131072)
this.pushState(t2 & 65535, this.pos);
else if (t2 & 262144)
this.pos = s, this.shiftContext(e2, i2), e2 <= this.p.parser.maxNode && this.buffer.push(e2, i2, s, 4);
else {
let r2 = t2, { parser: o } = this.p;
(s > this.pos || e2 <= o.maxNode) && (this.pos = s, o.stateFlag(
r2,
1
/* StateFlag.Skipped */
) || (this.reducePos = s)), this.pushState(r2, i2), this.shiftContext(e2, i2), e2 <= o.maxNode && this.buffer.push(e2, i2, s, 4);
}
}
// Apply an action
/**
@internal
*/
apply(t2, e2, i2, s) {
t2 & 65536 ? this.reduce(t2) : this.shift(t2, e2, i2, s);
}
// Add a prebuilt (reused) node into the buffer.
/**
@internal
*/
useNode(t2, e2) {
let i2 = this.p.reused.length - 1;
(i2 < 0 || this.p.reused[i2] != t2) && (this.p.reused.push(t2), i2++);
let s = this.pos;
this.reducePos = this.pos = s + t2.length, this.pushState(e2, s), this.buffer.push(
i2,
s,
this.reducePos,
-1
/* size == -1 means this is a reused value */
), this.curContext && this.updateContext(this.curContext.tracker.reuse(this.curContext.context, t2, this, this.p.stream.reset(this.pos - t2.length)));
}
// Split the stack. Due to the buffer sharing and the fact
// that `this.stack` tends to stay quite shallow, this isn't very
// expensive.
/**
@internal
*/
split() {
let t2 = this, e2 = t2.buffer.length;
for (; e2 > 0 && t2.buffer[e2 - 2] > t2.reducePos; )
e2 -= 4;
let i2 = t2.buffer.slice(e2), s = t2.bufferBase + e2;
for (; t2 && s == t2.bufferBase; )
t2 = t2.parent;
return new As(this.p, this.stack.slice(), this.state, this.reducePos, this.pos, this.score, i2, s, this.curContext, this.lookAhead, t2);
}
// Try to recover from an error by 'deleting' (ignoring) one token.
/**
@internal
*/
recoverByDelete(t2, e2) {
let i2 = t2 <= this.p.parser.maxNode;
i2 && this.storeNode(t2, this.pos, e2, 4), this.storeNode(0, this.pos, e2, i2 ? 8 : 4), this.pos = this.reducePos = e2, this.score -= 190;
}
/**
Check if the given term would be able to be shifted (optionally
after some reductions) on this stack. This can be useful for
external tokenizers that want to make sure they only provide a
given token when it applies.
*/
canShift(t2) {
for (let e2 = new Sg(this); ; ) {
let i2 = this.p.parser.stateSlot(
e2.state,
4
/* ParseState.DefaultReduce */
) || this.p.parser.hasAction(e2.state, t2);
if (i2 == 0)
return false;
if (!(i2 & 65536))
return true;
e2.reduce(i2);
}
}
// Apply up to Recover.MaxNext recovery actions that conceptually
// inserts some missing token or rule.
/**
@internal
*/
recoverByInsert(t2) {
if (this.stack.length >= 300)
return [];
let e2 = this.p.parser.nextStates(this.state);
if (e2.length > 8 || this.stack.length >= 120) {
let s = [];
for (let r2 = 0, o; r2 < e2.length; r2 += 2)
(o = e2[r2 + 1]) != this.state && this.p.parser.hasAction(o, t2) && s.push(e2[r2], o);
if (this.stack.length < 120)
for (let r2 = 0; s.length < 8 && r2 < e2.length; r2 += 2) {
let o = e2[r2 + 1];
s.some((l, h2) => h2 & 1 && l == o) || s.push(e2[r2], o);
}
e2 = s;
}
let i2 = [];
for (let s = 0; s < e2.length && i2.length < 4; s += 2) {
let r2 = e2[s + 1];
if (r2 == this.state)
continue;
let o = this.split();
o.pushState(r2, this.pos), o.storeNode(0, o.pos, o.pos, 4, true), o.shiftContext(e2[s], this.pos), o.reducePos = this.pos, o.score -= 200, i2.push(o);
}
return i2;
}
// Force a reduce, if possible. Return false if that can't
// be done.
/**
@internal
*/
forceReduce() {
let { parser: t2 } = this.p, e2 = t2.stateSlot(
this.state,
5
/* ParseState.ForcedReduce */
);
if (!(e2 & 65536))
return false;
if (!t2.validAction(this.state, e2)) {
let i2 = e2 >> 19, s = e2 & 65535, r2 = this.stack.length - i2 * 3;
if (r2 < 0 || t2.getGoto(this.stack[r2], s, false) < 0) {
let o = this.findForcedReduction();
if (o == null)
return false;
e2 = o;
}
this.storeNode(0, this.pos, this.pos, 4, true), this.score -= 100;
}
return this.reducePos = this.pos, this.reduce(e2), true;
}
/**
Try to scan through the automaton to find some kind of reduction
that can be applied. Used when the regular ForcedReduce field
isn't a valid action. @internal
*/
findForcedReduction() {
let { parser: t2 } = this.p, e2 = [], i2 = (s, r2) => {
if (!e2.includes(s))
return e2.push(s), t2.allActions(s, (o) => {
if (!(o & 393216))
if (o & 65536) {
let l = (o >> 19) - r2;
if (l > 1) {
let h2 = o & 65535, a2 = this.stack.length - l * 3;
if (a2 >= 0 && t2.getGoto(this.stack[a2], h2, false) >= 0)
return l << 19 | 65536 | h2;
}
} else {
let l = i2(o, r2 + 1);
if (l != null)
return l;
}
});
};
return i2(this.state, 0);
}
/**
@internal
*/
forceAll() {
for (; !this.p.parser.stateFlag(
this.state,
2
/* StateFlag.Accepting */
); )
if (!this.forceReduce()) {
this.storeNode(0, this.pos, this.pos, 4, true);
break;
}
return this;
}
/**
Check whether this state has no further actions (assumed to be a direct descendant of the
top state, since any other states must be able to continue
somehow). @internal
*/
get deadEnd() {
if (this.stack.length != 3)
return false;
let { parser: t2 } = this.p;
return t2.data[t2.stateSlot(
this.state,
1
/* ParseState.Actions */
)] == 65535 && !t2.stateSlot(
this.state,
4
/* ParseState.DefaultReduce */
);
}
/**
Restart the stack (put it back in its start state). Only safe
when this.stack.length == 3 (state is directly below the top
state). @internal
*/
restart() {
this.storeNode(0, this.pos, this.pos, 4, true), this.state = this.stack[0], this.stack.length = 0;
}
/**
@internal
*/
sameState(t2) {
if (this.state != t2.state || this.stack.length != t2.stack.length)
return false;
for (let e2 = 0; e2 < this.stack.length; e2 += 3)
if (this.stack[e2] != t2.stack[e2])
return false;
return true;
}
/**
Get the parser used by this stack.
*/
get parser() {
return this.p.parser;
}
/**
Test whether a given dialect (by numeric ID, as exported from
the terms file) is enabled.
*/
dialectEnabled(t2) {
return this.p.parser.dialect.flags[t2];
}
shiftContext(t2, e2) {
this.curContext && this.updateContext(this.curContext.tracker.shift(this.curContext.context, t2, this, this.p.stream.reset(e2)));
}
reduceContext(t2, e2) {
this.curContext && this.updateContext(this.curContext.tracker.reduce(this.curContext.context, t2, this, this.p.stream.reset(e2)));
}
/**
@internal
*/
emitContext() {
let t2 = this.buffer.length - 1;
(t2 < 0 || this.buffer[t2] != -3) && this.buffer.push(this.curContext.hash, this.pos, this.pos, -3);
}
/**
@internal
*/
emitLookAhead() {
let t2 = this.buffer.length - 1;
(t2 < 0 || this.buffer[t2] != -4) && this.buffer.push(this.lookAhead, this.pos, this.pos, -4);
}
updateContext(t2) {
if (t2 != this.curContext.context) {
let e2 = new $o(this.curContext.tracker, t2);
e2.hash != this.curContext.hash && this.emitContext(), this.curContext = e2;
}
}
/**
@internal
*/
setLookAhead(t2) {
t2 > this.lookAhead && (this.emitLookAhead(), this.lookAhead = t2);
}
/**
@internal
*/
close() {
this.curContext && this.curContext.tracker.strict && this.emitContext(), this.lookAhead > 0 && this.emitLookAhead();
}
}
class $o {
constructor(t2, e2) {
this.tracker = t2, this.context = e2, this.hash = t2.strict ? t2.hash(e2) : 0;
}
}
class Sg {
constructor(t2) {
this.start = t2, this.state = t2.state, this.stack = t2.stack, this.base = this.stack.length;
}
reduce(t2) {
let e2 = t2 & 65535, i2 = t2 >> 19;
i2 == 0 ? (this.stack == this.start.stack && (this.stack = this.stack.slice()), this.stack.push(this.state, 0, 0), this.base += 3) : this.base -= (i2 - 1) * 3;
let s = this.start.p.parser.getGoto(this.stack[this.base - 3], e2, true);
this.state = s;
}
}
class Os {
constructor(t2, e2, i2) {
this.stack = t2, this.pos = e2, this.index = i2, this.buffer = t2.buffer, this.index == 0 && this.maybeNext();
}
static create(t2, e2 = t2.bufferBase + t2.buffer.length) {
return new Os(t2, e2, e2 - t2.bufferBase);
}
maybeNext() {
let t2 = this.stack.parent;
t2 != null && (this.index = this.stack.bufferBase - t2.bufferBase, this.stack = t2, this.buffer = t2.buffer);
}
get id() {
return this.buffer[this.index - 4];
}
get start() {
return this.buffer[this.index - 3];
}
get end() {
return this.buffer[this.index - 2];
}
get size() {
return this.buffer[this.index - 1];
}
next() {
this.index -= 4, this.pos -= 4, this.index == 0 && this.maybeNext();
}
fork() {
return new Os(this.stack, this.pos, this.index);
}
}
function Qi(n2, t2 = Uint16Array) {
if (typeof n2 != "string")
return n2;
let e2 = null;
for (let i2 = 0, s = 0; i2 < n2.length; ) {
let r2 = 0;
for (; ; ) {
let o = n2.charCodeAt(i2++), l = false;
if (o == 126) {
r2 = 65535;
break;
}
o >= 92 && o--, o >= 34 && o--;
let h2 = o - 32;
if (h2 >= 46 && (h2 -= 46, l = true), r2 += h2, l)
break;
r2 *= 46;
}
e2 ? e2[s++] = r2 : e2 = new t2(r2);
}
return e2;
}
class ls {
constructor() {
this.start = -1, this.value = -1, this.end = -1, this.extended = -1, this.lookAhead = 0, this.mask = 0, this.context = 0;
}
}
const Fo = new ls();
class Cg {
/**
@internal
*/
constructor(t2, e2) {
this.input = t2, this.ranges = e2, this.chunk = "", this.chunkOff = 0, this.chunk2 = "", this.chunk2Pos = 0, this.next = -1, this.token = Fo, this.rangeIndex = 0, this.pos = this.chunkPos = e2[0].from, this.range = e2[0], this.end = e2[e2.length - 1].to, this.readNext();
}
/**
@internal
*/
resolveOffset(t2, e2) {
let i2 = this.range, s = this.rangeIndex, r2 = this.pos + t2;
for (; r2 < i2.from; ) {
if (!s)
return null;
let o = this.ranges[--s];
r2 -= i2.from - o.to, i2 = o;
}
for (; e2 < 0 ? r2 > i2.to : r2 >= i2.to; ) {
if (s == this.ranges.length - 1)
return null;
let o = this.ranges[++s];
r2 += o.from - i2.to, i2 = o;
}
return r2;
}
/**
@internal
*/
clipPos(t2) {
if (t2 >= this.range.from && t2 < this.range.to)
return t2;
for (let e2 of this.ranges)
if (e2.to > t2)
return Math.max(t2, e2.from);
return this.end;
}
/**
Look at a code unit near the stream position. `.peek(0)` equals
`.next`, `.peek(-1)` gives you the previous character, and so
on.
Note that looking around during tokenizing creates dependencies
on potentially far-away content, which may reduce the
effectiveness incremental parsing—when looking forward—or even
cause invalid reparses when looking backward more than 25 code
units, since the library does not track lookbehind.
*/
peek(t2) {
let e2 = this.chunkOff + t2, i2, s;
if (e2 >= 0 && e2 < this.chunk.length)
i2 = this.pos + t2, s = this.chunk.charCodeAt(e2);
else {
let r2 = this.resolveOffset(t2, 1);
if (r2 == null)
return -1;
if (i2 = r2, i2 >= this.chunk2Pos && i2 < this.chunk2Pos + this.chunk2.length)
s = this.chunk2.charCodeAt(i2 - this.chunk2Pos);
else {
let o = this.rangeIndex, l = this.range;
for (; l.to <= i2; )
l = this.ranges[++o];
this.chunk2 = this.input.chunk(this.chunk2Pos = i2), i2 + this.chunk2.length > l.to && (this.chunk2 = this.chunk2.slice(0, l.to - i2)), s = this.chunk2.charCodeAt(0);
}
}
return i2 >= this.token.lookAhead && (this.token.lookAhead = i2 + 1), s;
}
/**
Accept a token. By default, the end of the token is set to the
current stream position, but you can pass an offset (relative to
the stream position) to change that.
*/
acceptToken(t2, e2 = 0) {
let i2 = e2 ? this.resolveOffset(e2, -1) : this.pos;
if (i2 == null || i2 < this.token.start)
throw new RangeError("Token end out of bounds");
this.token.value = t2, this.token.end = i2;
}
getChunk() {
if (this.pos >= this.chunk2Pos && this.pos < this.chunk2Pos + this.chunk2.length) {
let { chunk: t2, chunkPos: e2 } = this;
this.chunk = this.chunk2, this.chunkPos = this.chunk2Pos, this.chunk2 = t2, this.chunk2Pos = e2, this.chunkOff = this.pos - this.chunkPos;
} else {
this.chunk2 = this.chunk, this.chunk2Pos = this.chunkPos;
let t2 = this.input.chunk(this.pos), e2 = this.pos + t2.length;
this.chunk = e2 > this.range.to ? t2.slice(0, this.range.to - this.pos) : t2, this.chunkPos = this.pos, this.chunkOff = 0;
}
}
readNext() {
return this.chunkOff >= this.chunk.length && (this.getChunk(), this.chunkOff == this.chunk.length) ? this.next = -1 : this.next = this.chunk.charCodeAt(this.chunkOff);
}
/**
Move the stream forward N (defaults to 1) code units. Returns
the new value of [`next`](#lr.InputStream.next).
*/
advance(t2 = 1) {
for (this.chunkOff += t2; this.pos + t2 >= this.range.to; ) {
if (this.rangeIndex == this.ranges.length - 1)
return this.setDone();
t2 -= this.range.to - this.pos, this.range = this.ranges[++this.rangeIndex], this.pos = this.range.from;
}
return this.pos += t2, this.pos >= this.token.lookAhead && (this.token.lookAhead = this.pos + 1), this.readNext();
}
setDone() {
return this.pos = this.chunkPos = this.end, this.range = this.ranges[this.rangeIndex = this.ranges.length - 1], this.chunk = "", this.next = -1;
}
/**
@internal
*/
reset(t2, e2) {
if (e2 ? (this.token = e2, e2.start = t2, e2.lookAhead = t2 + 1, e2.value = e2.extended = -1) : this.token = Fo, this.pos != t2) {
if (this.pos = t2, t2 == this.end)
return this.setDone(), this;
for (; t2 < this.range.from; )
this.range = this.ranges[--this.rangeIndex];
for (; t2 >= this.range.to; )
this.range = this.ranges[++this.rangeIndex];
t2 >= this.chunkPos && t2 < this.chunkPos + this.chunk.length ? this.chunkOff = t2 - this.chunkPos : (this.chunk = "", this.chunkOff = 0), this.readNext();
}
return this;
}
/**
@internal
*/
read(t2, e2) {
if (t2 >= this.chunkPos && e2 <= this.chunkPos + this.chunk.length)
return this.chunk.slice(t2 - this.chunkPos, e2 - this.chunkPos);
if (t2 >= this.chunk2Pos && e2 <= this.chunk2Pos + this.chunk2.length)
return this.chunk2.slice(t2 - this.chunk2Pos, e2 - this.chunk2Pos);
if (t2 >= this.range.from && e2 <= this.range.to)
return this.input.read(t2, e2);
let i2 = "";
for (let s of this.ranges) {
if (s.from >= e2)
break;
s.to > t2 && (i2 += this.input.read(Math.max(s.from, t2), Math.min(s.to, e2)));
}
return i2;
}
}
class Ge {
constructor(t2, e2) {
this.data = t2, this.id = e2;
}
token(t2, e2) {
let { parser: i2 } = e2.p;
Ag(this.data, t2, e2, this.id, i2.data, i2.tokenPrecTable);
}
}
Ge.prototype.contextual = Ge.prototype.fallback = Ge.prototype.extend = false;
Ge.prototype.fallback = Ge.prototype.extend = false;
function Ag(n2, t2, e2, i2, s, r2) {
let o = 0, l = 1 << i2, { dialect: h2 } = e2.p.parser;
t:
for (; l & n2[o]; ) {
let a2 = n2[o + 1];
for (let d2 = o + 3; d2 < a2; d2 += 2)
if ((n2[d2 + 1] & l) > 0) {
let p2 = n2[d2];
if (h2.allows(p2) && (t2.token.value == -1 || t2.token.value == p2 || Og(p2, t2.token.value, s, r2))) {
t2.acceptToken(p2);
break;
}
}
let c2 = t2.next, f2 = 0, u2 = n2[o + 2];
if (t2.next < 0 && u2 > f2 && n2[a2 + u2 * 3 - 3] == 65535) {
o = n2[a2 + u2 * 3 - 1];
continue t;
}
for (; f2 < u2; ) {
let d2 = f2 + u2 >> 1, p2 = a2 + d2 + (d2 << 1), m = n2[p2], g = n2[p2 + 1] || 65536;
if (c2 < m)
u2 = d2;
else if (c2 >= g)
f2 = d2 + 1;
else {
o = n2[p2 + 2], t2.advance();
continue t;
}
}
break;
}
}
function _o(n2, t2, e2) {
for (let i2 = t2, s; (s = n2[i2]) != 65535; i2++)
if (s == e2)
return i2 - t2;
return -1;
}
function Og(n2, t2, e2, i2) {
let s = _o(e2, i2, t2);
return s < 0 || _o(e2, i2, n2) < s;
}
const kt = typeof process < "u" && define_process_env_default$1 && /\bparse\b/.test(define_process_env_default$1.LOG);
let en = null;
function zo(n2, t2, e2) {
let i2 = n2.cursor(st.IncludeAnonymous);
for (i2.moveTo(t2); ; )
if (!(e2 < 0 ? i2.childBefore(t2) : i2.childAfter(t2)))
for (; ; ) {
if ((e2 < 0 ? i2.to < t2 : i2.from > t2) && !i2.type.isError)
return e2 < 0 ? Math.max(0, Math.min(
i2.to - 1,
t2 - 25
/* Safety.Margin */
)) : Math.min(n2.length, Math.max(
i2.from + 1,
t2 + 25
/* Safety.Margin */
));
if (e2 < 0 ? i2.prevSibling() : i2.nextSibling())
break;
if (!i2.parent())
return e2 < 0 ? 0 : n2.length;
}
}
class Mg {
constructor(t2, e2) {
this.fragments = t2, this.nodeSet = e2, this.i = 0, this.fragment = null, this.safeFrom = -1, this.safeTo = -1, this.trees = [], this.start = [], this.index = [], this.nextFragment();
}
nextFragment() {
let t2 = this.fragment = this.i == this.fragments.length ? null : this.fragments[this.i++];
if (t2) {
for (this.safeFrom = t2.openStart ? zo(t2.tree, t2.from + t2.offset, 1) - t2.offset : t2.from, this.safeTo = t2.openEnd ? zo(t2.tree, t2.to + t2.offset, -1) - t2.offset : t2.to; this.trees.length; )
this.trees.pop(), this.start.pop(), this.index.pop();
this.trees.push(t2.tree), this.start.push(-t2.offset), this.index.push(0), this.nextStart = this.safeFrom;
} else
this.nextStart = 1e9;
}
// `pos` must be >= any previously given `pos` for this cursor
nodeAt(t2) {
if (t2 < this.nextStart)
return null;
for (; this.fragment && this.safeTo <= t2; )
this.nextFragment();
if (!this.fragment)
return null;
for (; ; ) {
let e2 = this.trees.length - 1;
if (e2 < 0)
return this.nextFragment(), null;
let i2 = this.trees[e2], s = this.index[e2];
if (s == i2.children.length) {
this.trees.pop(), this.start.pop(), this.index.pop();
continue;
}
let r2 = i2.children[s], o = this.start[e2] + i2.positions[s];
if (o > t2)
return this.nextStart = o, null;
if (r2 instanceof X) {
if (o == t2) {
if (o < this.safeFrom)
return null;
let l = o + r2.length;
if (l <= this.safeTo) {
let h2 = r2.prop(R$1.lookAhead);
if (!h2 || l + h2 < this.fragment.to)
return r2;
}
}
this.index[e2]++, o + r2.length >= Math.max(this.safeFrom, t2) && (this.trees.push(r2), this.start.push(o), this.index.push(0));
} else
this.index[e2]++, this.nextStart = o + r2.length;
}
}
}
class Tg {
constructor(t2, e2) {
this.stream = e2, this.tokens = [], this.mainToken = null, this.actions = [], this.tokens = t2.tokenizers.map((i2) => new ls());
}
getActions(t2) {
let e2 = 0, i2 = null, { parser: s } = t2.p, { tokenizers: r2 } = s, o = s.stateSlot(
t2.state,
3
/* ParseState.TokenizerMask */
), l = t2.curContext ? t2.curContext.hash : 0, h2 = 0;
for (let a2 = 0; a2 < r2.length; a2++) {
if (!(1 << a2 & o))
continue;
let c2 = r2[a2], f2 = this.tokens[a2];
if (!(i2 && !c2.fallback) && ((c2.contextual || f2.start != t2.pos || f2.mask != o || f2.context != l) && (this.updateCachedToken(f2, c2, t2), f2.mask = o, f2.context = l), f2.lookAhead > f2.end + 25 && (h2 = Math.max(f2.lookAhead, h2)), f2.value != 0)) {
let u2 = e2;
if (f2.extended > -1 && (e2 = this.addActions(t2, f2.extended, f2.end, e2)), e2 = this.addActions(t2, f2.value, f2.end, e2), !c2.extend && (i2 = f2, e2 > u2))
break;
}
}
for (; this.actions.length > e2; )
this.actions.pop();
return h2 && t2.setLookAhead(h2), !i2 && t2.pos == this.stream.end && (i2 = new ls(), i2.value = t2.p.parser.eofTerm, i2.start = i2.end = t2.pos, e2 = this.addActions(t2, i2.value, i2.end, e2)), this.mainToken = i2, this.actions;
}
getMainToken(t2) {
if (this.mainToken)
return this.mainToken;
let e2 = new ls(), { pos: i2, p: s } = t2;
return e2.start = i2, e2.end = Math.min(i2 + 1, s.stream.end), e2.value = i2 == s.stream.end ? s.parser.eofTerm : 0, e2;
}
updateCachedToken(t2, e2, i2) {
let s = this.stream.clipPos(i2.pos);
if (e2.token(this.stream.reset(s, t2), i2), t2.value > -1) {
let { parser: r2 } = i2.p;
for (let o = 0; o < r2.specialized.length; o++)
if (r2.specialized[o] == t2.value) {
let l = r2.specializers[o](this.stream.read(t2.start, t2.end), i2);
if (l >= 0 && i2.p.parser.dialect.allows(l >> 1)) {
l & 1 ? t2.extended = l >> 1 : t2.value = l >> 1;
break;
}
}
} else
t2.value = 0, t2.end = this.stream.clipPos(s + 1);
}
putAction(t2, e2, i2, s) {
for (let r2 = 0; r2 < s; r2 += 3)
if (this.actions[r2] == t2)
return s;
return this.actions[s++] = t2, this.actions[s++] = e2, this.actions[s++] = i2, s;
}
addActions(t2, e2, i2, s) {
let { state: r2 } = t2, { parser: o } = t2.p, { data: l } = o;
for (let h2 = 0; h2 < 2; h2++)
for (let a2 = o.stateSlot(
r2,
h2 ? 2 : 1
/* ParseState.Actions */
); ; a2 += 3) {
if (l[a2] == 65535)
if (l[a2 + 1] == 1)
a2 = Xt(l, a2 + 2);
else {
s == 0 && l[a2 + 1] == 2 && (s = this.putAction(Xt(l, a2 + 2), e2, i2, s));
break;
}
l[a2] == e2 && (s = this.putAction(Xt(l, a2 + 1), e2, i2, s));
}
return s;
}
}
class Dg {
constructor(t2, e2, i2, s) {
this.parser = t2, this.input = e2, this.ranges = s, this.recovering = 0, this.nextStackID = 9812, this.minStackPos = 0, this.reused = [], this.stoppedAt = null, this.lastBigReductionStart = -1, this.lastBigReductionSize = 0, this.bigReductionCount = 0, this.stream = new Cg(e2, s), this.tokens = new Tg(t2, this.stream), this.topTerm = t2.top[1];
let { from: r2 } = s[0];
this.stacks = [As.start(this, t2.top[0], r2)], this.fragments = i2.length && this.stream.end - r2 > t2.bufferLength * 4 ? new Mg(i2, t2.nodeSet) : null;
}
get parsedPos() {
return this.minStackPos;
}
// Move the parser forward. This will process all parse stacks at
// `this.pos` and try to advance them to a further position. If no
// stack for such a position is found, it'll start error-recovery.
//
// When the parse is finished, this will return a syntax tree. When
// not, it returns `null`.
advance() {
let t2 = this.stacks, e2 = this.minStackPos, i2 = this.stacks = [], s, r2;
if (this.bigReductionCount > 300 && t2.length == 1) {
let [o] = t2;
for (; o.forceReduce() && o.stack.length && o.stack[o.stack.length - 2] >= this.lastBigReductionStart; )
;
this.bigReductionCount = this.lastBigReductionSize = 0;
}
for (let o = 0; o < t2.length; o++) {
let l = t2[o];
for (; ; ) {
if (this.tokens.mainToken = null, l.pos > e2)
i2.push(l);
else {
if (this.advanceStack(l, i2, t2))
continue;
{
s || (s = [], r2 = []), s.push(l);
let h2 = this.tokens.getMainToken(l);
r2.push(h2.value, h2.end);
}
}
break;
}
}
if (!i2.length) {
let o = s && Bg(s);
if (o)
return kt && console.log("Finish with " + this.stackID(o)), this.stackToTree(o);
if (this.parser.strict)
throw kt && s && console.log("Stuck with token " + (this.tokens.mainToken ? this.parser.getName(this.tokens.mainToken.value) : "none")), new SyntaxError("No parse at " + e2);
this.recovering || (this.recovering = 5);
}
if (this.recovering && s) {
let o = this.stoppedAt != null && s[0].pos > this.stoppedAt ? s[0] : this.runRecovery(s, r2, i2);
if (o)
return kt && console.log("Force-finish " + this.stackID(o)), this.stackToTree(o.forceAll());
}
if (this.recovering) {
let o = this.recovering == 1 ? 1 : this.recovering * 3;
if (i2.length > o)
for (i2.sort((l, h2) => h2.score - l.score); i2.length > o; )
i2.pop();
i2.some((l) => l.reducePos > e2) && this.recovering--;
} else if (i2.length > 1) {
t:
for (let o = 0; o < i2.length - 1; o++) {
let l = i2[o];
for (let h2 = o + 1; h2 < i2.length; h2++) {
let a2 = i2[h2];
if (l.sameState(a2) || l.buffer.length > 500 && a2.buffer.length > 500)
if ((l.score - a2.score || l.buffer.length - a2.buffer.length) > 0)
i2.splice(h2--, 1);
else {
i2.splice(o--, 1);
continue t;
}
}
}
i2.length > 12 && i2.splice(
12,
i2.length - 12
/* Rec.MaxStackCount */
);
}
this.minStackPos = i2[0].pos;
for (let o = 1; o < i2.length; o++)
i2[o].pos < this.minStackPos && (this.minStackPos = i2[o].pos);
return null;
}
stopAt(t2) {
if (this.stoppedAt != null && this.stoppedAt < t2)
throw new RangeError("Can't move stoppedAt forward");
this.stoppedAt = t2;
}
// Returns an updated version of the given stack, or null if the
// stack can't advance normally. When `split` and `stacks` are
// given, stacks split off by ambiguous operations will be pushed to
// `split`, or added to `stacks` if they move `pos` forward.
advanceStack(t2, e2, i2) {
let s = t2.pos, { parser: r2 } = this, o = kt ? this.stackID(t2) + " -> " : "";
if (this.stoppedAt != null && s > this.stoppedAt)
return t2.forceReduce() ? t2 : null;
if (this.fragments) {
let a2 = t2.curContext && t2.curContext.tracker.strict, c2 = a2 ? t2.curContext.hash : 0;
for (let f2 = this.fragments.nodeAt(s); f2; ) {
let u2 = this.parser.nodeSet.types[f2.type.id] == f2.type ? r2.getGoto(t2.state, f2.type.id) : -1;
if (u2 > -1 && f2.length && (!a2 || (f2.prop(R$1.contextHash) || 0) == c2))
return t2.useNode(f2, u2), kt && console.log(o + this.stackID(t2) + ` (via reuse of ${r2.getName(f2.type.id)})`), true;
if (!(f2 instanceof X) || f2.children.length == 0 || f2.positions[0] > 0)
break;
let d2 = f2.children[0];
if (d2 instanceof X && f2.positions[0] == 0)
f2 = d2;
else
break;
}
}
let l = r2.stateSlot(
t2.state,
4
/* ParseState.DefaultReduce */
);
if (l > 0)
return t2.reduce(l), kt && console.log(o + this.stackID(t2) + ` (via always-reduce ${r2.getName(
l & 65535
/* Action.ValueMask */
)})`), true;
if (t2.stack.length >= 8400)
for (; t2.stack.length > 6e3 && t2.forceReduce(); )
;
let h2 = this.tokens.getActions(t2);
for (let a2 = 0; a2 < h2.length; ) {
let c2 = h2[a2++], f2 = h2[a2++], u2 = h2[a2++], d2 = a2 == h2.length || !i2, p2 = d2 ? t2 : t2.split(), m = this.tokens.mainToken;
if (p2.apply(c2, f2, m ? m.start : p2.pos, u2), kt && console.log(o + this.stackID(p2) + ` (via ${c2 & 65536 ? `reduce of ${r2.getName(
c2 & 65535
/* Action.ValueMask */
)}` : "shift"} for ${r2.getName(f2)} @ ${s}${p2 == t2 ? "" : ", split"})`), d2)
return true;
p2.pos > s ? e2.push(p2) : i2.push(p2);
}
return false;
}
// Advance a given stack forward as far as it will go. Returns the
// (possibly updated) stack if it got stuck, or null if it moved
// forward and was given to `pushStackDedup`.
advanceFully(t2, e2) {
let i2 = t2.pos;
for (; ; ) {
if (!this.advanceStack(t2, null, null))
return false;
if (t2.pos > i2)
return Wo(t2, e2), true;
}
}
runRecovery(t2, e2, i2) {
let s = null, r2 = false;
for (let o = 0; o < t2.length; o++) {
let l = t2[o], h2 = e2[o << 1], a2 = e2[(o << 1) + 1], c2 = kt ? this.stackID(l) + " -> " : "";
if (l.deadEnd && (r2 || (r2 = true, l.restart(), kt && console.log(c2 + this.stackID(l) + " (restarted)"), this.advanceFully(l, i2))))
continue;
let f2 = l.split(), u2 = c2;
for (let d2 = 0; f2.forceReduce() && d2 < 10 && (kt && console.log(u2 + this.stackID(f2) + " (via force-reduce)"), !this.advanceFully(f2, i2)); d2++)
kt && (u2 = this.stackID(f2) + " -> ");
for (let d2 of l.recoverByInsert(h2))
kt && console.log(c2 + this.stackID(d2) + " (via recover-insert)"), this.advanceFully(d2, i2);
this.stream.end > l.pos ? (a2 == l.pos && (a2++, h2 = 0), l.recoverByDelete(h2, a2), kt && console.log(c2 + this.stackID(l) + ` (via recover-delete ${this.parser.getName(h2)})`), Wo(l, i2)) : (!s || s.score < l.score) && (s = l);
}
return s;
}
// Convert the stack's buffer to a syntax tree.
stackToTree(t2) {
return t2.close(), X.build({
buffer: Os.create(t2),
nodeSet: this.parser.nodeSet,
topID: this.topTerm,
maxBufferLength: this.parser.bufferLength,
reused: this.reused,
start: this.ranges[0].from,
length: t2.pos - this.ranges[0].from,
minRepeatType: this.parser.minRepeatTerm
});
}
stackID(t2) {
let e2 = (en || (en = /* @__PURE__ */ new WeakMap())).get(t2);
return e2 || en.set(t2, e2 = String.fromCodePoint(this.nextStackID++)), e2 + t2;
}
}
function Wo(n2, t2) {
for (let e2 = 0; e2 < t2.length; e2++) {
let i2 = t2[e2];
if (i2.pos == n2.pos && i2.sameState(n2)) {
t2[e2].score < n2.score && (t2[e2] = n2);
return;
}
}
t2.push(n2);
}
class Pg {
constructor(t2, e2, i2) {
this.source = t2, this.flags = e2, this.disabled = i2;
}
allows(t2) {
return !this.disabled || this.disabled[t2] == 0;
}
}
class Ms extends kh {
/**
@internal
*/
constructor(t2) {
if (super(), this.wrappers = [], t2.version != 14)
throw new RangeError(`Parser version (${t2.version}) doesn't match runtime version (14)`);
let e2 = t2.nodeNames.split(" ");
this.minRepeatTerm = e2.length;
for (let l = 0; l < t2.repeatNodeCount; l++)
e2.push("");
let i2 = Object.keys(t2.topRules).map((l) => t2.topRules[l][1]), s = [];
for (let l = 0; l < e2.length; l++)
s.push([]);
function r2(l, h2, a2) {
s[l].push([h2, h2.deserialize(String(a2))]);
}
if (t2.nodeProps)
for (let l of t2.nodeProps) {
let h2 = l[0];
typeof h2 == "string" && (h2 = R$1[h2]);
for (let a2 = 1; a2 < l.length; ) {
let c2 = l[a2++];
if (c2 >= 0)
r2(c2, h2, l[a2++]);
else {
let f2 = l[a2 + -c2];
for (let u2 = -c2; u2 > 0; u2--)
r2(l[a2++], h2, f2);
a2++;
}
}
}
this.nodeSet = new rr(e2.map((l, h2) => bt.define({
name: h2 >= this.minRepeatTerm ? void 0 : l,
id: h2,
props: s[h2],
top: i2.indexOf(h2) > -1,
error: h2 == 0,
skipped: t2.skippedNodes && t2.skippedNodes.indexOf(h2) > -1
}))), t2.propSources && (this.nodeSet = this.nodeSet.extend(...t2.propSources)), this.strict = false, this.bufferLength = mh;
let o = Qi(t2.tokenData);
this.context = t2.context, this.specializerSpecs = t2.specialized || [], this.specialized = new Uint16Array(this.specializerSpecs.length);
for (let l = 0; l < this.specializerSpecs.length; l++)
this.specialized[l] = this.specializerSpecs[l].term;
this.specializers = this.specializerSpecs.map(jo), this.states = Qi(t2.states, Uint32Array), this.data = Qi(t2.stateData), this.goto = Qi(t2.goto), this.maxTerm = t2.maxTerm, this.tokenizers = t2.tokenizers.map((l) => typeof l == "number" ? new Ge(o, l) : l), this.topRules = t2.topRules, this.dialects = t2.dialects || {}, this.dynamicPrecedences = t2.dynamicPrecedences || null, this.tokenPrecTable = t2.tokenPrec, this.termNames = t2.termNames || null, this.maxNode = this.nodeSet.types.length - 1, this.dialect = this.parseDialect(), this.top = this.topRules[Object.keys(this.topRules)[0]];
}
createParse(t2, e2, i2) {
let s = new Dg(this, t2, e2, i2);
for (let r2 of this.wrappers)
s = r2(s, t2, e2, i2);
return s;
}
/**
Get a goto table entry @internal
*/
getGoto(t2, e2, i2 = false) {
let s = this.goto;
if (e2 >= s[0])
return -1;
for (let r2 = s[e2 + 1]; ; ) {
let o = s[r2++], l = o & 1, h2 = s[r2++];
if (l && i2)
return h2;
for (let a2 = r2 + (o >> 1); r2 < a2; r2++)
if (s[r2] == t2)
return h2;
if (l)
return -1;
}
}
/**
Check if this state has an action for a given terminal @internal
*/
hasAction(t2, e2) {
let i2 = this.data;
for (let s = 0; s < 2; s++)
for (let r2 = this.stateSlot(
t2,
s ? 2 : 1
/* ParseState.Actions */
), o; ; r2 += 3) {
if ((o = i2[r2]) == 65535)
if (i2[r2 + 1] == 1)
o = i2[r2 = Xt(i2, r2 + 2)];
else {
if (i2[r2 + 1] == 2)
return Xt(i2, r2 + 2);
break;
}
if (o == e2 || o == 0)
return Xt(i2, r2 + 1);
}
return 0;
}
/**
@internal
*/
stateSlot(t2, e2) {
return this.states[t2 * 6 + e2];
}
/**
@internal
*/
stateFlag(t2, e2) {
return (this.stateSlot(
t2,
0
/* ParseState.Flags */
) & e2) > 0;
}
/**
@internal
*/
validAction(t2, e2) {
return !!this.allActions(t2, (i2) => i2 == e2 ? true : null);
}
/**
@internal
*/
allActions(t2, e2) {
let i2 = this.stateSlot(
t2,
4
/* ParseState.DefaultReduce */
), s = i2 ? e2(i2) : void 0;
for (let r2 = this.stateSlot(
t2,
1
/* ParseState.Actions */
); s == null; r2 += 3) {
if (this.data[r2] == 65535)
if (this.data[r2 + 1] == 1)
r2 = Xt(this.data, r2 + 2);
else
break;
s = e2(Xt(this.data, r2 + 1));
}
return s;
}
/**
Get the states that can follow this one through shift actions or
goto jumps. @internal
*/
nextStates(t2) {
let e2 = [];
for (let i2 = this.stateSlot(
t2,
1
/* ParseState.Actions */
); ; i2 += 3) {
if (this.data[i2] == 65535)
if (this.data[i2 + 1] == 1)
i2 = Xt(this.data, i2 + 2);
else
break;
if (!(this.data[i2 + 2] & 1)) {
let s = this.data[i2 + 1];
e2.some((r2, o) => o & 1 && r2 == s) || e2.push(this.data[i2], s);
}
}
return e2;
}
/**
Configure the parser. Returns a new parser instance that has the
given settings modified. Settings not provided in `config` are
kept from the original parser.
*/
configure(t2) {
let e2 = Object.assign(Object.create(Ms.prototype), this);
if (t2.props && (e2.nodeSet = this.nodeSet.extend(...t2.props)), t2.top) {
let i2 = this.topRules[t2.top];
if (!i2)
throw new RangeError(`Invalid top rule name ${t2.top}`);
e2.top = i2;
}
return t2.tokenizers && (e2.tokenizers = this.tokenizers.map((i2) => {
let s = t2.tokenizers.find((r2) => r2.from == i2);
return s ? s.to : i2;
})), t2.specializers && (e2.specializers = this.specializers.slice(), e2.specializerSpecs = this.specializerSpecs.map((i2, s) => {
let r2 = t2.specializers.find((l) => l.from == i2.external);
if (!r2)
return i2;
let o = Object.assign(Object.assign({}, i2), { external: r2.to });
return e2.specializers[s] = jo(o), o;
})), t2.contextTracker && (e2.context = t2.contextTracker), t2.dialect && (e2.dialect = this.parseDialect(t2.dialect)), t2.strict != null && (e2.strict = t2.strict), t2.wrap && (e2.wrappers = e2.wrappers.concat(t2.wrap)), t2.bufferLength != null && (e2.bufferLength = t2.bufferLength), e2;
}
/**
Tells you whether any [parse wrappers](#lr.ParserConfig.wrap)
are registered for this parser.
*/
hasWrappers() {
return this.wrappers.length > 0;
}
/**
Returns the name associated with a given term. This will only
work for all terms when the parser was generated with the
`--names` option. By default, only the names of tagged terms are
stored.
*/
getName(t2) {
return this.termNames ? this.termNames[t2] : String(t2 <= this.maxNode && this.nodeSet.types[t2].name || t2);
}
/**
The eof term id is always allocated directly after the node
types. @internal
*/
get eofTerm() {
return this.maxNode + 1;
}
/**
The type of top node produced by the parser.
*/
get topNode() {
return this.nodeSet.types[this.top[1]];
}
/**
@internal
*/
dynamicPrecedence(t2) {
let e2 = this.dynamicPrecedences;
return e2 == null ? 0 : e2[t2] || 0;
}
/**
@internal
*/
parseDialect(t2) {
let e2 = Object.keys(this.dialects), i2 = e2.map(() => false);
if (t2)
for (let r2 of t2.split(" ")) {
let o = e2.indexOf(r2);
o >= 0 && (i2[o] = true);
}
let s = null;
for (let r2 = 0; r2 < e2.length; r2++)
if (!i2[r2])
for (let o = this.dialects[e2[r2]], l; (l = this.data[o++]) != 65535; )
(s || (s = new Uint8Array(this.maxTerm + 1)))[l] = 1;
return new Pg(t2, i2, s);
}
/**
Used by the output of the parser generator. Not available to
user code. @hide
*/
static deserialize(t2) {
return new Ms(t2);
}
}
function Xt(n2, t2) {
return n2[t2] | n2[t2 + 1] << 16;
}
function Bg(n2) {
let t2 = null;
for (let e2 of n2) {
let i2 = e2.p.stoppedAt;
(e2.pos == e2.p.stream.end || i2 != null && e2.pos > i2) && e2.p.parser.stateFlag(
e2.state,
2
/* StateFlag.Accepting */
) && (!t2 || t2.score < e2.score) && (t2 = e2);
}
return t2;
}
function jo(n2) {
if (n2.external) {
let t2 = n2.extend ? 1 : 0;
return (e2, i2) => n2.external(e2, i2) << 1 | t2;
}
return n2.get;
}
const Rg = xh({
String: w$2.string,
Number: w$2.number,
"True False": w$2.bool,
PropertyName: w$2.propertyName,
Null: w$2.null,
",": w$2.separator,
"[ ]": w$2.squareBracket,
"{ }": w$2.brace
}), Lg = Ms.deserialize({
version: 14,
states: "$bOVQPOOOOQO'#Cb'#CbOnQPO'#CeOvQPO'#CjOOQO'#Cp'#CpQOQPOOOOQO'#Cg'#CgO}QPO'#CfO!SQPO'#CrOOQO,59P,59PO![QPO,59PO!aQPO'#CuOOQO,59U,59UO!iQPO,59UOVQPO,59QOqQPO'#CkO!nQPO,59^OOQO1G.k1G.kOVQPO'#ClO!vQPO,59aOOQO1G.p1G.pOOQO1G.l1G.lOOQO,59V,59VOOQO-E6i-E6iOOQO,59W,59WOOQO-E6j-E6j",
stateData: "#O~OcOS~OQSORSOSSOTSOWQO]ROePO~OVXOeUO~O[[O~PVOg^O~Oh_OVfX~OVaO~OhbO[iX~O[dO~Oh_OVfa~OhbO[ia~O",
goto: "!kjPPPPPPkPPkqwPPk{!RPPP!XP!ePP!hXSOR^bQWQRf_TVQ_Q`WRg`QcZRicQTOQZRQe^RhbRYQR]R",
nodeNames: "⚠ JsonText True False Null Number String } { Object Property PropertyName ] [ Array",
maxTerm: 25,
nodeProps: [
["openedBy", 7, "{", 12, "["],
["closedBy", 8, "}", 13, "]"]
],
propSources: [Rg],
skippedNodes: [0],
repeatNodeCount: 2,
tokenData: "(|~RaXY!WYZ!W]^!Wpq!Wrs!]|}$u}!O$z!Q!R%T!R![&c![!]&t!}#O&y#P#Q'O#Y#Z'T#b#c'r#h#i(Z#o#p(r#q#r(w~!]Oc~~!`Wpq!]qr!]rs!xs#O!]#O#P!}#P;'S!];'S;=`$o<%lO!]~!}Oe~~#QXrs!]!P!Q!]#O#P!]#U#V!]#Y#Z!]#b#c!]#f#g!]#h#i!]#i#j#m~#pR!Q![#y!c!i#y#T#Z#y~#|R!Q![$V!c!i$V#T#Z$V~$YR!Q![$c!c!i$c#T#Z$c~$fR!Q![!]!c!i!]#T#Z!]~$rP;=`<%l!]~$zOh~~$}Q!Q!R%T!R![&c~%YRT~!O!P%c!g!h%w#X#Y%w~%fP!Q![%i~%nRT~!Q![%i!g!h%w#X#Y%w~%zR{|&T}!O&T!Q![&Z~&WP!Q![&Z~&`PT~!Q![&Z~&hST~!O!P%c!Q![&c!g!h%w#X#Y%w~&yOg~~'OO]~~'TO[~~'WP#T#U'Z~'^P#`#a'a~'dP#g#h'g~'jP#X#Y'm~'rOR~~'uP#i#j'x~'{P#`#a(O~(RP#`#a(U~(ZOS~~(^P#f#g(a~(dP#i#j(g~(jP#X#Y(m~(rOQ~~(wOW~~(|OV~",
tokenizers: [0],
topRules: { JsonText: [0, 1] },
tokenPrec: 0
}), Eg = /* @__PURE__ */ ks.define({
name: "json",
parser: /* @__PURE__ */ Lg.configure({
props: [
/* @__PURE__ */ Ah.add({
Object: /* @__PURE__ */ Mo({ except: /^\s*\}/ }),
Array: /* @__PURE__ */ Mo({ except: /^\s*\]/ })
}),
/* @__PURE__ */ Mh.add({
"Object Array": Gd
})
]
}),
languageData: {
closeBrackets: { brackets: ["[", "{", '"'] },
indentOnInput: /^\s*[\}\]]$/
}
});
function Ng() {
return new Nd(Eg);
}
function Ut() {
var n2 = arguments[0];
typeof n2 == "string" && (n2 = document.createElement(n2));
var t2 = 1, e2 = arguments[1];
if (e2 && typeof e2 == "object" && e2.nodeType == null && !Array.isArray(e2)) {
for (var i2 in e2)
if (Object.prototype.hasOwnProperty.call(e2, i2)) {
var s = e2[i2];
typeof s == "string" ? n2.setAttribute(i2, s) : s != null && (n2[i2] = s);
}
t2++;
}
for (; t2 < arguments.length; t2++)
aa(n2, arguments[t2]);
return n2;
}
function aa(n2, t2) {
if (typeof t2 == "string")
n2.appendChild(document.createTextNode(t2));
else if (t2 != null)
if (t2.nodeType != null)
n2.appendChild(t2);
else if (Array.isArray(t2))
for (var e2 = 0; e2 < t2.length; e2++)
aa(n2, t2[e2]);
else
throw new RangeError("Unsupported child node: " + t2);
}
class Ig {
constructor(t2, e2, i2) {
this.from = t2, this.to = e2, this.diagnostic = i2;
}
}
class Pe {
constructor(t2, e2, i2) {
this.diagnostics = t2, this.panel = e2, this.selected = i2;
}
static init(t2, e2, i2) {
let s = t2, r2 = i2.facet(ua).markerFilter;
r2 && (s = r2(s));
let o = N$2.set(s.map((l) => l.from == l.to || l.from == l.to - 1 && i2.doc.lineAt(l.from).to == l.from ? N$2.widget({
widget: new Kg(l),
diagnostic: l
}).range(l.from) : N$2.mark({
attributes: { class: "cm-lintRange cm-lintRange-" + l.severity + (l.markClass ? " " + l.markClass : "") },
diagnostic: l
}).range(l.from, l.to)), true);
return new Pe(o, e2, Ze(o));
}
}
function Ze(n2, t2 = null, e2 = 0) {
let i2 = null;
return n2.between(e2, 1e9, (s, r2, { spec: o }) => {
if (!(t2 && o.diagnostic != t2))
return i2 = new Ig(s, r2, o.diagnostic), false;
}), i2;
}
function Vg(n2, t2) {
let e2 = n2.startState.doc.lineAt(t2.pos);
return !!(n2.effects.some((i2) => i2.is(ca)) || n2.changes.touchesRange(e2.from, e2.to));
}
function Hg(n2, t2) {
return n2.field(St, false) ? t2 : t2.concat(z$2.appendConfig.of(Ug));
}
const ca = /* @__PURE__ */ z$2.define(), mr = /* @__PURE__ */ z$2.define(), fa = /* @__PURE__ */ z$2.define(), St = /* @__PURE__ */ Ht.define({
create() {
return new Pe(N$2.none, null, null);
},
update(n2, t2) {
if (t2.docChanged) {
let e2 = n2.diagnostics.map(t2.changes), i2 = null;
if (n2.selected) {
let s = t2.changes.mapPos(n2.selected.from, 1);
i2 = Ze(e2, n2.selected.diagnostic, s) || Ze(e2, null, s);
}
n2 = new Pe(e2, n2.panel, i2);
}
for (let e2 of t2.effects)
e2.is(ca) ? n2 = Pe.init(e2.value, n2.panel, t2.state) : e2.is(mr) ? n2 = new Pe(n2.diagnostics, e2.value ? Vs.open : null, n2.selected) : e2.is(fa) && (n2 = new Pe(n2.diagnostics, n2.panel, e2.value));
return n2;
},
provide: (n2) => [
En.from(n2, (t2) => t2.panel),
T.decorations.from(n2, (t2) => t2.diagnostics)
]
}), $g = /* @__PURE__ */ N$2.mark({ class: "cm-lintRange cm-lintRange-active" });
function Fg(n2, t2, e2) {
let { diagnostics: i2 } = n2.state.field(St), s = [], r2 = 2e8, o = 0;
i2.between(t2 - (e2 < 0 ? 1 : 0), t2 + (e2 > 0 ? 1 : 0), (h2, a2, { spec: c2 }) => {
t2 >= h2 && t2 <= a2 && (h2 == a2 || (t2 > h2 || e2 > 0) && (t2 < a2 || e2 < 0)) && (s.push(c2.diagnostic), r2 = Math.min(h2, r2), o = Math.max(a2, o));
});
let l = n2.state.facet(ua).tooltipFilter;
return l && (s = l(s)), s.length ? {
pos: r2,
end: o,
above: n2.state.doc.lineAt(r2).to < o,
create() {
return { dom: _g(n2, s) };
}
} : null;
}
function _g(n2, t2) {
return Ut("ul", { class: "cm-tooltip-lint" }, t2.map((e2) => pa(n2, e2, false)));
}
const zg = (n2) => {
let t2 = n2.state.field(St, false);
(!t2 || !t2.panel) && n2.dispatch({ effects: Hg(n2.state, [mr.of(true)]) });
let e2 = od(n2, Vs.open);
return e2 && e2.dom.querySelector(".cm-panel-lint ul").focus(), true;
}, Ko = (n2) => {
let t2 = n2.state.field(St, false);
return !t2 || !t2.panel ? false : (n2.dispatch({ effects: mr.of(false) }), true);
}, Wg = (n2) => {
let t2 = n2.state.field(St, false);
if (!t2)
return false;
let e2 = n2.state.selection.main, i2 = t2.diagnostics.iter(e2.to + 1);
return !i2.value && (i2 = t2.diagnostics.iter(0), !i2.value || i2.from == e2.from && i2.to == e2.to) ? false : (n2.dispatch({ selection: { anchor: i2.from, head: i2.to }, scrollIntoView: true }), true);
}, jg = [
{ key: "Mod-Shift-m", run: zg, preventDefault: true },
{ key: "F8", run: Wg }
], ua = /* @__PURE__ */ O$3.define({
combine(n2) {
return Object.assign({ sources: n2.map((t2) => t2.source) }, Ds(n2.map((t2) => t2.config), {
delay: 750,
markerFilter: null,
tooltipFilter: null,
needsRefresh: null
}, {
needsRefresh: (t2, e2) => t2 ? e2 ? (i2) => t2(i2) || e2(i2) : t2 : e2
}));
}
});
function da(n2) {
let t2 = [];
if (n2)
t:
for (let { name: e2 } of n2) {
for (let i2 = 0; i2 < e2.length; i2++) {
let s = e2[i2];
if (/[a-zA-Z]/.test(s) && !t2.some((r2) => r2.toLowerCase() == s.toLowerCase())) {
t2.push(s);
continue t;
}
}
t2.push("");
}
return t2;
}
function pa(n2, t2, e2) {
var i2;
let s = e2 ? da(t2.actions) : [];
return Ut("li", { class: "cm-diagnostic cm-diagnostic-" + t2.severity }, Ut("span", { class: "cm-diagnosticText" }, t2.renderMessage ? t2.renderMessage() : t2.message), (i2 = t2.actions) === null || i2 === void 0 ? void 0 : i2.map((r2, o) => {
let l = false, h2 = (u2) => {
if (u2.preventDefault(), l)
return;
l = true;
let d2 = Ze(n2.state.field(St).diagnostics, t2);
d2 && r2.apply(n2, d2.from, d2.to);
}, { name: a2 } = r2, c2 = s[o] ? a2.indexOf(s[o]) : -1, f2 = c2 < 0 ? a2 : [
a2.slice(0, c2),
Ut("u", a2.slice(c2, c2 + 1)),
a2.slice(c2 + 1)
];
return Ut("button", {
type: "button",
class: "cm-diagnosticAction",
onclick: h2,
onmousedown: h2,
"aria-label": ` Action: ${a2}${c2 < 0 ? "" : ` (access key "${s[o]})"`}.`
}, f2);
}), t2.source && Ut("div", { class: "cm-diagnosticSource" }, t2.source));
}
class Kg extends Se {
constructor(t2) {
super(), this.diagnostic = t2;
}
eq(t2) {
return t2.diagnostic == this.diagnostic;
}
toDOM() {
return Ut("span", { class: "cm-lintPoint cm-lintPoint-" + this.diagnostic.severity });
}
}
class qo {
constructor(t2, e2) {
this.diagnostic = e2, this.id = "item_" + Math.floor(Math.random() * 4294967295).toString(16), this.dom = pa(t2, e2, true), this.dom.id = this.id, this.dom.setAttribute("role", "option");
}
}
class Vs {
constructor(t2) {
this.view = t2, this.items = [];
let e2 = (s) => {
if (s.keyCode == 27)
Ko(this.view), this.view.focus();
else if (s.keyCode == 38 || s.keyCode == 33)
this.moveSelection((this.selectedIndex - 1 + this.items.length) % this.items.length);
else if (s.keyCode == 40 || s.keyCode == 34)
this.moveSelection((this.selectedIndex + 1) % this.items.length);
else if (s.keyCode == 36)
this.moveSelection(0);
else if (s.keyCode == 35)
this.moveSelection(this.items.length - 1);
else if (s.keyCode == 13)
this.view.focus();
else if (s.keyCode >= 65 && s.keyCode <= 90 && this.selectedIndex >= 0) {
let { diagnostic: r2 } = this.items[this.selectedIndex], o = da(r2.actions);
for (let l = 0; l < o.length; l++)
if (o[l].toUpperCase().charCodeAt(0) == s.keyCode) {
let h2 = Ze(this.view.state.field(St).diagnostics, r2);
h2 && r2.actions[l].apply(t2, h2.from, h2.to);
}
} else
return;
s.preventDefault();
}, i2 = (s) => {
for (let r2 = 0; r2 < this.items.length; r2++)
this.items[r2].dom.contains(s.target) && this.moveSelection(r2);
};
this.list = Ut("ul", {
tabIndex: 0,
role: "listbox",
"aria-label": this.view.state.phrase("Diagnostics"),
onkeydown: e2,
onclick: i2
}), this.dom = Ut("div", { class: "cm-panel-lint" }, this.list, Ut("button", {
type: "button",
name: "close",
"aria-label": this.view.state.phrase("close"),
onclick: () => Ko(this.view)
}, "×")), this.update();
}
get selectedIndex() {
let t2 = this.view.state.field(St).selected;
if (!t2)
return -1;
for (let e2 = 0; e2 < this.items.length; e2++)
if (this.items[e2].diagnostic == t2.diagnostic)
return e2;
return -1;
}
update() {
let { diagnostics: t2, selected: e2 } = this.view.state.field(St), i2 = 0, s = false, r2 = null;
for (t2.between(0, this.view.state.doc.length, (o, l, { spec: h2 }) => {
let a2 = -1, c2;
for (let f2 = i2; f2 < this.items.length; f2++)
if (this.items[f2].diagnostic == h2.diagnostic) {
a2 = f2;
break;
}
a2 < 0 ? (c2 = new qo(this.view, h2.diagnostic), this.items.splice(i2, 0, c2), s = true) : (c2 = this.items[a2], a2 > i2 && (this.items.splice(i2, a2 - i2), s = true)), e2 && c2.diagnostic == e2.diagnostic ? c2.dom.hasAttribute("aria-selected") || (c2.dom.setAttribute("aria-selected", "true"), r2 = c2) : c2.dom.hasAttribute("aria-selected") && c2.dom.removeAttribute("aria-selected"), i2++;
}); i2 < this.items.length && !(this.items.length == 1 && this.items[0].diagnostic.from < 0); )
s = true, this.items.pop();
this.items.length == 0 && (this.items.push(new qo(this.view, {
from: -1,
to: -1,
severity: "info",
message: this.view.state.phrase("No diagnostics")
})), s = true), r2 ? (this.list.setAttribute("aria-activedescendant", r2.id), this.view.requestMeasure({
key: this,
read: () => ({ sel: r2.dom.getBoundingClientRect(), panel: this.list.getBoundingClientRect() }),
write: ({ sel: o, panel: l }) => {
let h2 = l.height / this.list.offsetHeight;
o.top < l.top ? this.list.scrollTop -= (l.top - o.top) / h2 : o.bottom > l.bottom && (this.list.scrollTop += (o.bottom - l.bottom) / h2);
}
})) : this.selectedIndex < 0 && this.list.removeAttribute("aria-activedescendant"), s && this.sync();
}
sync() {
let t2 = this.list.firstChild;
function e2() {
let i2 = t2;
t2 = i2.nextSibling, i2.remove();
}
for (let i2 of this.items)
if (i2.dom.parentNode == this.list) {
for (; t2 != i2.dom; )
e2();
t2 = i2.dom.nextSibling;
} else
this.list.insertBefore(i2.dom, t2);
for (; t2; )
e2();
}
moveSelection(t2) {
if (this.selectedIndex < 0)
return;
let e2 = this.view.state.field(St), i2 = Ze(e2.diagnostics, this.items[t2].diagnostic);
i2 && this.view.dispatch({
selection: { anchor: i2.from, head: i2.to },
scrollIntoView: true,
effects: fa.of(i2)
});
}
static open(t2) {
return new Vs(t2);
}
}
function qg(n2, t2 = 'viewBox="0 0 40 40"') {
return `url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${t2}>${encodeURIComponent(n2)}</svg>')`;
}
function Ji(n2) {
return qg(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${n2}" fill="none" stroke-width=".7"/>`, 'width="6" height="3"');
}
const Gg = /* @__PURE__ */ T.baseTheme({
".cm-diagnostic": {
padding: "3px 6px 3px 8px",
marginLeft: "-1px",
display: "block",
whiteSpace: "pre-wrap"
},
".cm-diagnostic-error": { borderLeft: "5px solid #d11" },
".cm-diagnostic-warning": { borderLeft: "5px solid orange" },
".cm-diagnostic-info": { borderLeft: "5px solid #999" },
".cm-diagnostic-hint": { borderLeft: "5px solid #66d" },
".cm-diagnosticAction": {
font: "inherit",
border: "none",
padding: "2px 4px",
backgroundColor: "#444",
color: "white",
borderRadius: "3px",
marginLeft: "8px",
cursor: "pointer"
},
".cm-diagnosticSource": {
fontSize: "70%",
opacity: 0.7
},
".cm-lintRange": {
backgroundPosition: "left bottom",
backgroundRepeat: "repeat-x",
paddingBottom: "0.7px"
},
".cm-lintRange-error": { backgroundImage: /* @__PURE__ */ Ji("#d11") },
".cm-lintRange-warning": { backgroundImage: /* @__PURE__ */ Ji("orange") },
".cm-lintRange-info": { backgroundImage: /* @__PURE__ */ Ji("#999") },
".cm-lintRange-hint": { backgroundImage: /* @__PURE__ */ Ji("#66d") },
".cm-lintRange-active": { backgroundColor: "#ffdd9980" },
".cm-tooltip-lint": {
padding: 0,
margin: 0
},
".cm-lintPoint": {
position: "relative",
"&:after": {
content: '""',
position: "absolute",
bottom: 0,
left: "-2px",
borderLeft: "3px solid transparent",
borderRight: "3px solid transparent",
borderBottom: "4px solid #d11"
}
},
".cm-lintPoint-warning": {
"&:after": { borderBottomColor: "orange" }
},
".cm-lintPoint-info": {
"&:after": { borderBottomColor: "#999" }
},
".cm-lintPoint-hint": {
"&:after": { borderBottomColor: "#66d" }
},
".cm-panel.cm-panel-lint": {
position: "relative",
"& ul": {
maxHeight: "100px",
overflowY: "auto",
"& [aria-selected]": {
backgroundColor: "#ddd",
"& u": { textDecoration: "underline" }
},
"&:focus [aria-selected]": {
background_fallback: "#bdf",
backgroundColor: "Highlight",
color_fallback: "white",
color: "HighlightText"
},
"& u": { textDecoration: "none" },
padding: 0,
margin: 0
},
"& [name=close]": {
position: "absolute",
top: "0",
right: "2px",
background: "inherit",
border: "none",
font: "inherit",
padding: 0,
margin: 0
}
}
}), Ug = [
St,
/* @__PURE__ */ T.decorations.compute([St], (n2) => {
let { selected: t2, panel: e2 } = n2.field(St);
return !t2 || !e2 || t2.from == t2.to ? N$2.none : N$2.set([
$g.range(t2.from, t2.to)
]);
}),
/* @__PURE__ */ nd(Fg, { hideOn: Vg }),
Gg
], Yg = "#e5c07b", Go = "#e06c75", Qg = "#56b6c2", Jg = "#ffffff", hs = "#abb2bf", Kn = "#7d8799", Xg = "#61afef", Zg = "#98c379", Uo = "#d19a66", tm = "#c678dd", em = "#21252b", Yo = "#2c313a", Qo = "#282c34", sn = "#353a42", im = "#3E4451", Jo = "#528bff", sm = /* @__PURE__ */ T.theme({
"&": {
color: hs,
backgroundColor: Qo
},
".cm-content": {
caretColor: Jo
},
".cm-cursor, .cm-dropCursor": { borderLeftColor: Jo },
"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection": { backgroundColor: im },
".cm-panels": { backgroundColor: em, color: hs },
".cm-panels.cm-panels-top": { borderBottom: "2px solid black" },
".cm-panels.cm-panels-bottom": { borderTop: "2px solid black" },
".cm-searchMatch": {
backgroundColor: "#72a1ff59",
outline: "1px solid #457dff"
},
".cm-searchMatch.cm-searchMatch-selected": {
backgroundColor: "#6199ff2f"
},
".cm-activeLine": { backgroundColor: "#6699ff0b" },
".cm-selectionMatch": { backgroundColor: "#aafe661a" },
"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket": {
backgroundColor: "#bad0f847"
},
".cm-gutters": {
backgroundColor: Qo,
color: Kn,
border: "none"
},
".cm-activeLineGutter": {
backgroundColor: Yo
},
".cm-foldPlaceholder": {
backgroundColor: "transparent",
border: "none",
color: "#ddd"
},
".cm-tooltip": {
border: "none",
backgroundColor: sn
},
".cm-tooltip .cm-tooltip-arrow:before": {
borderTopColor: "transparent",
borderBottomColor: "transparent"
},
".cm-tooltip .cm-tooltip-arrow:after": {
borderTopColor: sn,
borderBottomColor: sn
},
".cm-tooltip-autocomplete": {
"& > ul > li[aria-selected]": {
backgroundColor: Yo,
color: hs
}
}
}, { dark: true }), nm = /* @__PURE__ */ Pi.define([
{
tag: w$2.keyword,
color: tm
},
{
tag: [w$2.name, w$2.deleted, w$2.character, w$2.propertyName, w$2.macroName],
color: Go
},
{
tag: [/* @__PURE__ */ w$2.function(w$2.variableName), w$2.labelName],
color: Xg
},
{
tag: [w$2.color, /* @__PURE__ */ w$2.constant(w$2.name), /* @__PURE__ */ w$2.standard(w$2.name)],
color: Uo
},
{
tag: [/* @__PURE__ */ w$2.definition(w$2.name), w$2.separator],
color: hs
},
{
tag: [w$2.typeName, w$2.className, w$2.number, w$2.changed, w$2.annotation, w$2.modifier, w$2.self, w$2.namespace],
color: Yg
},
{
tag: [w$2.operator, w$2.operatorKeyword, w$2.url, w$2.escape, w$2.regexp, w$2.link, /* @__PURE__ */ w$2.special(w$2.string)],
color: Qg
},
{
tag: [w$2.meta, w$2.comment],
color: Kn
},
{
tag: w$2.strong,
fontWeight: "bold"
},
{
tag: w$2.emphasis,
fontStyle: "italic"
},
{
tag: w$2.strikethrough,
textDecoration: "line-through"
},
{
tag: w$2.link,
color: Kn,
textDecoration: "underline"
},
{
tag: w$2.heading,
fontWeight: "bold",
color: Go
},
{
tag: [w$2.atom, w$2.bool, /* @__PURE__ */ w$2.special(w$2.variableName)],
color: Uo
},
{
tag: [w$2.processingInstruction, w$2.string, w$2.inserted],
color: Zg
},
{
tag: w$2.invalid,
color: Jg
}
]), ga = ref(false);
window.__hst_controls_dark || (window.__hst_controls_dark = []);
window.__hst_controls_dark.push(ga);
var Xo;
(Xo = window.__hst_controls_dark_ready) == null || Xo.call(window);
const rm = {
name: "HstJson",
inheritAttrs: false
}, om = /* @__PURE__ */ defineComponent({
...rm,
props: {
title: {},
modelValue: {}
},
emits: {
"update:modelValue": (n2) => true
},
setup(n2, { emit: t2 }) {
const e2 = n2, i2 = t2;
let s;
const r2 = ref(""), o = ref(false), l = ref(), h2 = {
light: [T.baseTheme({}), Do(ap)],
dark: [sm, Do(nm)]
}, a2 = new Ai(), c2 = [
gd(),
Uu(),
zu(),
Ng(),
mp(),
Kd(),
rp(),
fh.of([
...vg,
...ep,
...jg
]),
T.updateListener.of((f2) => {
r2.value = f2.view.state.doc.toString();
}),
a2.of(h2.light)
];
return onMounted(() => {
s = new T({
doc: JSON.stringify(e2.modelValue, null, 2),
extensions: c2,
parent: l.value
}), watchEffect(() => {
s.dispatch({
effects: [
a2.reconfigure(h2[ga.value ? "dark" : "light"])
]
});
});
}), watch(() => e2.modelValue, () => {
let f2;
try {
f2 = JSON.stringify(JSON.parse(r2.value)) === JSON.stringify(e2.modelValue);
} catch {
f2 = false;
}
f2 || s.dispatch({ changes: [{ from: 0, to: s.state.doc.length, insert: JSON.stringify(e2.modelValue, null, 2) }] });
}, { deep: true }), watch(() => r2.value, () => {
o.value = false;
try {
i2("update:modelValue", JSON.parse(r2.value));
} catch {
o.value = true;
}
}), (f2, u2) => (openBlock(), createBlock(Vt, {
title: f2.title,
class: normalizeClass(["histoire-json htw-cursor-text", f2.$attrs.class]),
style: normalizeStyle(f2.$attrs.style)
}, {
actions: withCtx(() => [
o.value ? withDirectives((openBlock(), createBlock(unref(Icon), {
key: 0,
icon: "carbon:warning-alt",
class: "htw-text-orange-500"
}, null, 512)), [
[unref(VTooltip), "JSON error"]
]) : createCommentVNode("", true),
renderSlot(f2.$slots, "actions", {}, void 0, true)
]),
default: withCtx(() => [
createBaseVNode("div", mergeProps({
ref_key: "editorElement",
ref: l,
class: "__histoire-json-code htw-w-full htw-border htw-border-solid htw-border-black/25 dark:htw-border-white/25 focus-within:htw-border-primary-500 dark:focus-within:htw-border-primary-500 htw-rounded-sm htw-box-border htw-overflow-auto htw-resize-y htw-min-h-32 htw-h-48 htw-relative"
}, { ...f2.$attrs, class: null, style: null }), null, 16)
]),
_: 3
}, 8, ["title", "class", "style"]));
}
}), lm = (n2, t2) => {
const e2 = n2.__vccOpts || n2;
for (const [i2, s] of t2)
e2[i2] = s;
return e2;
}, hm = /* @__PURE__ */ lm(om, [["__scopeId", "data-v-935458a7"]]), am = { class: "htw-flex htw-flex-row htw-gap-1" }, cm = ["value"], fm = {
name: "HstColorSelect",
inheritAttrs: false
}, um = /* @__PURE__ */ defineComponent({
...fm,
props: {
title: {},
modelValue: {}
},
emits: {
"update:modelValue": (n2) => true
},
setup(n2, { emit: t2 }) {
const e2 = n2, i2 = t2, s = computed({
get: () => e2.modelValue,
set: (h2) => {
i2("update:modelValue", h2);
}
});
function r2(h2, a2 = 15) {
let c2 = false, f2;
const u2 = () => {
f2 == null ? c2 = false : (h2(...f2), f2 = null, setTimeout(u2, a2));
};
return (...d2) => {
if (c2) {
f2 = d2;
return;
}
h2(...d2), c2 = true, setTimeout(u2, a2);
};
}
const o = r2((h2) => {
i2("update:modelValue", h2);
});
function l(h2) {
o(h2);
}
return (h2, a2) => (openBlock(), createBlock(Vt, {
title: h2.title,
class: normalizeClass(["histoire-select htw-cursor-text htw-items-center", h2.$attrs.class]),
style: normalizeStyle(h2.$attrs.style)
}, {
actions: withCtx(() => [
renderSlot(h2.$slots, "actions")
]),
default: withCtx(() => [
createBaseVNode("div", am, [
withDirectives(createBaseVNode("input", mergeProps({ ...h2.$attrs, class: null, style: null }, {
"onUpdate:modelValue": a2[0] || (a2[0] = (c2) => s.value = c2),
type: "text",
class: "htw-text-inherit htw-bg-transparent htw-w-full htw-outline-none htw-px-2 htw-py-1 -htw-my-1 htw-border htw-border-solid htw-border-black/25 dark:htw-border-white/25 focus:htw-border-primary-500 dark:focus:htw-border-primary-500 htw-rounded-sm"
}), null, 16), [
[vModelText, s.value]
]),
createBaseVNode("input", {
type: "color",
value: h2.modelValue,
onInput: a2[1] || (a2[1] = (c2) => l(c2.target.value))
}, null, 40, cm)
])
]),
_: 3
}, 8, ["title", "class", "style"]));
}
}), dm = Zo, pm = Da, gm = Ea, mm = Ha, wm = _a, ym = Wa, bm = Ga, km = Qa, xm = nc, vm = dc, Sm = xc, Cm = Tc, Am = Le, Om = Lc, Mm = hm, Tm = um, Nm = {
HstButton: dm,
HstButtonGroup: pm,
HstCheckbox: gm,
HstCheckboxList: mm,
HstText: wm,
HstNumber: ym,
HstSlider: bm,
HstTextarea: km,
HstSelect: xm,
HstRadio: Om,
HstJson: Mm,
HstColorShades: vm,
HstTokenList: Sm,
HstTokenGrid: Cm,
HstCopyIcon: Am,
HstColorSelect: Tm
};
var define_process_env_default = {};
var commonjsGlobal$1 = typeof globalThis !== "undefined" ? globalThis : typeof {} !== "undefined" ? {} : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
var mainExports$1 = {};
var main$1 = {
get exports() {
return mainExports$1;
},
set exports(v2) {
mainExports$1 = v2;
}
};
(function(module2, exports) {
!function(t2, n2) {
module2.exports = n2();
}(commonjsGlobal$1, () => {
return t2 = { 770: function(t22, n22, e2) {
var r2 = this && this.__importDefault || function(t3) {
return t3 && t3.__esModule ? t3 : { default: t3 };
};
Object.defineProperty(n22, "__esModule", { value: true }), n22.setDefaultDebugCall = n22.createOnigScanner = n22.createOnigString = n22.loadWASM = n22.OnigScanner = n22.OnigString = void 0;
const i2 = r2(e2(418));
let o = null, a2 = false;
class f2 {
static _utf8ByteLength(t3) {
let n3 = 0;
for (let e22 = 0, r22 = t3.length; e22 < r22; e22++) {
const i22 = t3.charCodeAt(e22);
let o2 = i22, a22 = false;
if (i22 >= 55296 && i22 <= 56319 && e22 + 1 < r22) {
const n4 = t3.charCodeAt(e22 + 1);
n4 >= 56320 && n4 <= 57343 && (o2 = 65536 + (i22 - 55296 << 10) | n4 - 56320, a22 = true);
}
n3 += o2 <= 127 ? 1 : o2 <= 2047 ? 2 : o2 <= 65535 ? 3 : 4, a22 && e22++;
}
return n3;
}
constructor(t3) {
const n3 = t3.length, e22 = f2._utf8ByteLength(t3), r22 = e22 !== n3, i22 = r22 ? new Uint32Array(n3 + 1) : null;
r22 && (i22[n3] = e22);
const o2 = r22 ? new Uint32Array(e22 + 1) : null;
r22 && (o2[e22] = n3);
const a22 = new Uint8Array(e22);
let s2 = 0;
for (let e3 = 0; e3 < n3; e3++) {
const f22 = t3.charCodeAt(e3);
let u22 = f22, c22 = false;
if (f22 >= 55296 && f22 <= 56319 && e3 + 1 < n3) {
const n4 = t3.charCodeAt(e3 + 1);
n4 >= 56320 && n4 <= 57343 && (u22 = 65536 + (f22 - 55296 << 10) | n4 - 56320, c22 = true);
}
r22 && (i22[e3] = s2, c22 && (i22[e3 + 1] = s2), u22 <= 127 ? o2[s2 + 0] = e3 : u22 <= 2047 ? (o2[s2 + 0] = e3, o2[s2 + 1] = e3) : u22 <= 65535 ? (o2[s2 + 0] = e3, o2[s2 + 1] = e3, o2[s2 + 2] = e3) : (o2[s2 + 0] = e3, o2[s2 + 1] = e3, o2[s2 + 2] = e3, o2[s2 + 3] = e3)), u22 <= 127 ? a22[s2++] = u22 : u22 <= 2047 ? (a22[s2++] = 192 | (1984 & u22) >>> 6, a22[s2++] = 128 | (63 & u22) >>> 0) : u22 <= 65535 ? (a22[s2++] = 224 | (61440 & u22) >>> 12, a22[s2++] = 128 | (4032 & u22) >>> 6, a22[s2++] = 128 | (63 & u22) >>> 0) : (a22[s2++] = 240 | (1835008 & u22) >>> 18, a22[s2++] = 128 | (258048 & u22) >>> 12, a22[s2++] = 128 | (4032 & u22) >>> 6, a22[s2++] = 128 | (63 & u22) >>> 0), c22 && e3++;
}
this.utf16Length = n3, this.utf8Length = e22, this.utf16Value = t3, this.utf8Value = a22, this.utf16OffsetToUtf8 = i22, this.utf8OffsetToUtf16 = o2;
}
createString(t3) {
const n3 = t3._omalloc(this.utf8Length);
return t3.HEAPU8.set(this.utf8Value, n3), n3;
}
}
class s {
constructor(t3) {
if (this.id = ++s.LAST_ID, !o)
throw new Error("Must invoke loadWASM first.");
this._onigBinding = o, this.content = t3;
const n3 = new f2(t3);
this.utf16Length = n3.utf16Length, this.utf8Length = n3.utf8Length, this.utf16OffsetToUtf8 = n3.utf16OffsetToUtf8, this.utf8OffsetToUtf16 = n3.utf8OffsetToUtf16, this.utf8Length < 1e4 && !s._sharedPtrInUse ? (s._sharedPtr || (s._sharedPtr = o._omalloc(1e4)), s._sharedPtrInUse = true, o.HEAPU8.set(n3.utf8Value, s._sharedPtr), this.ptr = s._sharedPtr) : this.ptr = n3.createString(o);
}
convertUtf8OffsetToUtf16(t3) {
return this.utf8OffsetToUtf16 ? t3 < 0 ? 0 : t3 > this.utf8Length ? this.utf16Length : this.utf8OffsetToUtf16[t3] : t3;
}
convertUtf16OffsetToUtf8(t3) {
return this.utf16OffsetToUtf8 ? t3 < 0 ? 0 : t3 > this.utf16Length ? this.utf8Length : this.utf16OffsetToUtf8[t3] : t3;
}
dispose() {
this.ptr === s._sharedPtr ? s._sharedPtrInUse = false : this._onigBinding._ofree(this.ptr);
}
}
n22.OnigString = s, s.LAST_ID = 0, s._sharedPtr = 0, s._sharedPtrInUse = false;
class u2 {
constructor(t3) {
if (!o)
throw new Error("Must invoke loadWASM first.");
const n3 = [], e22 = [];
for (let r3 = 0, i3 = t3.length; r3 < i3; r3++) {
const i4 = new f2(t3[r3]);
n3[r3] = i4.createString(o), e22[r3] = i4.utf8Length;
}
const r22 = o._omalloc(4 * t3.length);
o.HEAPU32.set(n3, r22 / 4);
const i22 = o._omalloc(4 * t3.length);
o.HEAPU32.set(e22, i22 / 4);
const a22 = o._createOnigScanner(r22, i22, t3.length);
for (let e3 = 0, r3 = t3.length; e3 < r3; e3++)
o._ofree(n3[e3]);
o._ofree(i22), o._ofree(r22), 0 === a22 && function(t4) {
throw new Error(t4.UTF8ToString(t4._getLastOnigError()));
}(o), this._onigBinding = o, this._ptr = a22;
}
dispose() {
this._onigBinding._freeOnigScanner(this._ptr);
}
findNextMatchSync(t3, n3, e22) {
let r22 = a2, i22 = 0;
if ("number" == typeof e22 ? (8 & e22 && (r22 = true), i22 = e22) : "boolean" == typeof e22 && (r22 = e22), "string" == typeof t3) {
t3 = new s(t3);
const e3 = this._findNextMatchSync(t3, n3, r22, i22);
return t3.dispose(), e3;
}
return this._findNextMatchSync(t3, n3, r22, i22);
}
_findNextMatchSync(t3, n3, e22, r22) {
const i22 = this._onigBinding;
let o2;
if (o2 = e22 ? i22._findNextOnigScannerMatchDbg(this._ptr, t3.id, t3.ptr, t3.utf8Length, t3.convertUtf16OffsetToUtf8(n3), r22) : i22._findNextOnigScannerMatch(this._ptr, t3.id, t3.ptr, t3.utf8Length, t3.convertUtf16OffsetToUtf8(n3), r22), 0 === o2)
return null;
const a22 = i22.HEAPU32;
let f22 = o2 / 4;
const s2 = a22[f22++], u22 = a22[f22++];
let c22 = [];
for (let n4 = 0; n4 < u22; n4++) {
const e3 = t3.convertUtf8OffsetToUtf16(a22[f22++]), r3 = t3.convertUtf8OffsetToUtf16(a22[f22++]);
c22[n4] = { start: e3, end: r3, length: r3 - e3 };
}
return { index: s2, captureIndices: c22 };
}
}
n22.OnigScanner = u2;
let c2 = false, l = null;
n22.loadWASM = function(t3) {
if (c2)
return l;
let n3, e22, r22, a22;
if (c2 = true, function(t4) {
return "function" == typeof t4.instantiator;
}(t3))
n3 = t3.instantiator, e22 = t3.print;
else {
let r3;
!function(t4) {
return void 0 !== t4.data;
}(t3) ? r3 = t3 : (r3 = t3.data, e22 = t3.print), n3 = function(t4) {
return "undefined" != typeof Response && t4 instanceof Response;
}(r3) ? "function" == typeof WebAssembly.instantiateStreaming ? /* @__PURE__ */ function(t4) {
return (n4) => WebAssembly.instantiateStreaming(t4, n4);
}(r3) : /* @__PURE__ */ function(t4) {
return async (n4) => {
const e3 = await t4.arrayBuffer();
return WebAssembly.instantiate(e3, n4);
};
}(r3) : /* @__PURE__ */ function(t4) {
return (n4) => WebAssembly.instantiate(t4, n4);
}(r3);
}
return l = new Promise((t4, n4) => {
r22 = t4, a22 = n4;
}), function(t4, n4, e3, r3) {
(0, i2.default)({ print: n4, instantiateWasm: (n5, e4) => {
if ("undefined" == typeof performance) {
const t5 = () => Date.now();
n5.env.emscripten_get_now = t5, n5.wasi_snapshot_preview1.emscripten_get_now = t5;
}
return t4(n5).then((t5) => e4(t5.instance), r3), {};
} }).then((t5) => {
o = t5, e3();
});
}(n3, e22, r22, a22), l;
}, n22.createOnigString = function(t3) {
return new s(t3);
}, n22.createOnigScanner = function(t3) {
return new u2(t3);
}, n22.setDefaultDebugCall = function(t3) {
a2 = t3;
};
}, 418: (t22) => {
var n22 = ("undefined" != typeof document && document.currentScript && document.currentScript.src, function(t3) {
var n3, e2, r2 = void 0 !== (t3 = t3 || {}) ? t3 : {};
r2.ready = new Promise(function(t4, r22) {
n3 = t4, e2 = r22;
});
var i2, o = Object.assign({}, r2), s = false, c2 = "";
function l(t4) {
return r2.locateFile ? r2.locateFile(t4, c2) : c2 + t4;
}
i2 = function(t4) {
let n4;
return "function" == typeof readbuffer ? new Uint8Array(readbuffer(t4)) : (n4 = read(t4, "binary"), m("object" == typeof n4), n4);
}, "undefined" != typeof scriptArgs ? scriptArgs : void 0 !== arguments && arguments, "undefined" != typeof onig_print && ("undefined" == typeof console && (console = {}), console.log = onig_print, console.warn = console.error = "undefined" != typeof printErr ? printErr : onig_print);
var h2, p2, d2 = r2.print || console.log.bind(console), g = r2.printErr || console.warn.bind(console);
Object.assign(r2, o), o = null, r2.arguments && r2.arguments, r2.thisProgram && r2.thisProgram, r2.quit && r2.quit, r2.wasmBinary && (h2 = r2.wasmBinary), r2.noExitRuntime, "object" != typeof WebAssembly && k2("no native wasm support detected");
var _2 = false;
function m(t4, n4) {
t4 || k2(n4);
}
var y2, w2, S2, v2 = "undefined" != typeof TextDecoder ? new TextDecoder("utf8") : void 0;
function A2(t4, n4, e22) {
for (var r22 = n4 + e22, i22 = n4; t4[i22] && !(i22 >= r22); )
++i22;
if (i22 - n4 > 16 && t4.buffer && v2)
return v2.decode(t4.subarray(n4, i22));
for (var o2 = ""; n4 < i22; ) {
var a2 = t4[n4++];
if (128 & a2) {
var f2 = 63 & t4[n4++];
if (192 != (224 & a2)) {
var s2 = 63 & t4[n4++];
if ((a2 = 224 == (240 & a2) ? (15 & a2) << 12 | f2 << 6 | s2 : (7 & a2) << 18 | f2 << 12 | s2 << 6 | 63 & t4[n4++]) < 65536)
o2 += String.fromCharCode(a2);
else {
var u2 = a2 - 65536;
o2 += String.fromCharCode(55296 | u2 >> 10, 56320 | 1023 & u2);
}
} else
o2 += String.fromCharCode((31 & a2) << 6 | f2);
} else
o2 += String.fromCharCode(a2);
}
return o2;
}
function b3(t4, n4) {
return t4 ? A2(w2, t4, n4) : "";
}
function O3(t4) {
y2 = t4, r2.HEAP8 = new Int8Array(t4), r2.HEAP16 = new Int16Array(t4), r2.HEAP32 = new Int32Array(t4), r2.HEAPU8 = w2 = new Uint8Array(t4), r2.HEAPU16 = new Uint16Array(t4), r2.HEAPU32 = S2 = new Uint32Array(t4), r2.HEAPF32 = new Float32Array(t4), r2.HEAPF64 = new Float64Array(t4);
}
r2.INITIAL_MEMORY;
var U2 = [], P2 = [], R3 = [];
function x2() {
if (r2.preRun)
for ("function" == typeof r2.preRun && (r2.preRun = [r2.preRun]); r2.preRun.length; )
M2(r2.preRun.shift());
G2(U2);
}
function T2() {
G2(P2);
}
function E2() {
if (r2.postRun)
for ("function" == typeof r2.postRun && (r2.postRun = [r2.postRun]); r2.postRun.length; )
I2(r2.postRun.shift());
G2(R3);
}
function M2(t4) {
U2.unshift(t4);
}
function L2(t4) {
P2.unshift(t4);
}
function I2(t4) {
R3.unshift(t4);
}
var W2 = 0, C2 = null;
function N3(t4) {
W2++, r2.monitorRunDependencies && r2.monitorRunDependencies(W2);
}
function j2(t4) {
if (W2--, r2.monitorRunDependencies && r2.monitorRunDependencies(W2), 0 == W2 && C2) {
var n4 = C2;
C2 = null, n4();
}
}
function k2(t4) {
r2.onAbort && r2.onAbort(t4), g(t4 = "Aborted(" + t4 + ")"), _2 = true, t4 += ". Build with -sASSERTIONS for more info.";
var n4 = new WebAssembly.RuntimeError(t4);
throw e2(n4), n4;
}
var B2, H4, F2 = "data:application/octet-stream;base64,";
function V2(t4) {
return t4.startsWith(F2);
}
function z3(t4) {
try {
if (t4 == B2 && h2)
return new Uint8Array(h2);
if (i2)
return i2(t4);
throw "both async and sync fetching of the wasm failed";
} catch (t5) {
k2(t5);
}
}
function q3() {
return h2 || !s || "function" != typeof fetch ? Promise.resolve().then(function() {
return z3(B2);
}) : fetch(B2, { credentials: "same-origin" }).then(function(t4) {
if (!t4.ok)
throw "failed to load wasm binary file at '" + B2 + "'";
return t4.arrayBuffer();
}).catch(function() {
return z3(B2);
});
}
function Y2() {
var t4 = { env: nt, wasi_snapshot_preview1: nt };
function n4(t5, n5) {
var e22 = t5.exports;
r2.asm = e22, O3((p2 = r2.asm.memory).buffer), r2.asm.__indirect_function_table, L2(r2.asm.__wasm_call_ctors), j2();
}
function i22(t5) {
n4(t5.instance);
}
function o2(n5) {
return q3().then(function(n6) {
return WebAssembly.instantiate(n6, t4);
}).then(function(t5) {
return t5;
}).then(n5, function(t5) {
g("failed to asynchronously prepare wasm: " + t5), k2(t5);
});
}
if (N3(), r2.instantiateWasm)
try {
return r2.instantiateWasm(t4, n4);
} catch (t5) {
g("Module.instantiateWasm callback failed with error: " + t5), e2(t5);
}
return (h2 || "function" != typeof WebAssembly.instantiateStreaming || V2(B2) || "function" != typeof fetch ? o2(i22) : fetch(B2, { credentials: "same-origin" }).then(function(n5) {
return WebAssembly.instantiateStreaming(n5, t4).then(i22, function(t5) {
return g("wasm streaming compile failed: " + t5), g("falling back to ArrayBuffer instantiation"), o2(i22);
});
})).catch(e2), {};
}
function G2(t4) {
for (; t4.length > 0; )
t4.shift()(r2);
}
function J3(t4, n4, e22) {
w2.copyWithin(t4, n4, n4 + e22);
}
function K2(t4) {
try {
return p2.grow(t4 - y2.byteLength + 65535 >>> 16), O3(p2.buffer), 1;
} catch (t5) {
}
}
function Q2(t4) {
var n4, e22 = w2.length, r22 = 2147483648;
if ((t4 >>>= 0) > r22)
return false;
for (var i22 = 1; i22 <= 4; i22 *= 2) {
var o2 = e22 * (1 + 0.2 / i22);
if (o2 = Math.min(o2, t4 + 100663296), K2(Math.min(r22, (n4 = Math.max(t4, o2)) + (65536 - n4 % 65536) % 65536)))
return true;
}
return false;
}
V2(B2 = "onig.wasm") || (B2 = l(B2)), H4 = "undefined" != typeof dateNow ? dateNow : () => performance.now();
var X2 = [null, [], []];
function Z3(t4, n4) {
var e22 = X2[t4];
0 === n4 || 10 === n4 ? ((1 === t4 ? d2 : g)(A2(e22, 0)), e22.length = 0) : e22.push(n4);
}
function $(t4, n4, e22, r22) {
for (var i22 = 0, o2 = 0; o2 < e22; o2++) {
var a2 = S2[n4 >> 2], f2 = S2[n4 + 4 >> 2];
n4 += 8;
for (var s2 = 0; s2 < f2; s2++)
Z3(t4, w2[a2 + s2]);
i22 += f2;
}
return S2[r22 >> 2] = i22, 0;
}
var tt2, nt = { emscripten_get_now: H4, emscripten_memcpy_big: J3, emscripten_resize_heap: Q2, fd_write: $ };
function et(t4) {
function e22() {
tt2 || (tt2 = true, r2.calledRun = true, _2 || (T2(), n3(r2), r2.onRuntimeInitialized && r2.onRuntimeInitialized(), E2()));
}
W2 > 0 || (x2(), W2 > 0 || (r2.setStatus ? (r2.setStatus("Running..."), setTimeout(function() {
setTimeout(function() {
r2.setStatus("");
}, 1), e22();
}, 1)) : e22()));
}
if (Y2(), r2.___wasm_call_ctors = function() {
return (r2.___wasm_call_ctors = r2.asm.__wasm_call_ctors).apply(null, arguments);
}, r2.___errno_location = function() {
return (r2.___errno_location = r2.asm.__errno_location).apply(null, arguments);
}, r2._omalloc = function() {
return (r2._omalloc = r2.asm.omalloc).apply(null, arguments);
}, r2._ofree = function() {
return (r2._ofree = r2.asm.ofree).apply(null, arguments);
}, r2._getLastOnigError = function() {
return (r2._getLastOnigError = r2.asm.getLastOnigError).apply(null, arguments);
}, r2._createOnigScanner = function() {
return (r2._createOnigScanner = r2.asm.createOnigScanner).apply(null, arguments);
}, r2._freeOnigScanner = function() {
return (r2._freeOnigScanner = r2.asm.freeOnigScanner).apply(null, arguments);
}, r2._findNextOnigScannerMatch = function() {
return (r2._findNextOnigScannerMatch = r2.asm.findNextOnigScannerMatch).apply(null, arguments);
}, r2._findNextOnigScannerMatchDbg = function() {
return (r2._findNextOnigScannerMatchDbg = r2.asm.findNextOnigScannerMatchDbg).apply(null, arguments);
}, r2.stackSave = function() {
return (r2.stackSave = r2.asm.stackSave).apply(null, arguments);
}, r2.stackRestore = function() {
return (r2.stackRestore = r2.asm.stackRestore).apply(null, arguments);
}, r2.stackAlloc = function() {
return (r2.stackAlloc = r2.asm.stackAlloc).apply(null, arguments);
}, r2.dynCall_jiji = function() {
return (r2.dynCall_jiji = r2.asm.dynCall_jiji).apply(null, arguments);
}, r2.UTF8ToString = b3, C2 = function t4() {
tt2 || et(), tt2 || (C2 = t4);
}, r2.preInit)
for ("function" == typeof r2.preInit && (r2.preInit = [r2.preInit]); r2.preInit.length > 0; )
r2.preInit.pop()();
return et(), t3.ready;
});
t22.exports = n22;
} }, n2 = {}, function e2(r2) {
var i2 = n2[r2];
if (void 0 !== i2)
return i2.exports;
var o = n2[r2] = { exports: {} };
return t2[r2].call(o.exports, o, o.exports, e2), o.exports;
}(770);
var t2, n2;
});
})(main$1);
var mainExports = {};
var main = {
get exports() {
return mainExports;
},
set exports(v2) {
mainExports = v2;
}
};
(function(module2, exports) {
!function(e2, t2) {
module2.exports = t2();
}(commonjsGlobal$1, function() {
return (() => {
var e2 = { 350: (e22, t22) => {
Object.defineProperty(t22, "__esModule", { value: true }), t22.UseOnigurumaFindOptions = t22.DebugFlags = void 0, t22.DebugFlags = { InDebugMode: "undefined" != typeof process && !!define_process_env_default.VSCODE_TEXTMATE_DEBUG }, t22.UseOnigurumaFindOptions = false;
}, 36: (e22, t22) => {
var n2;
Object.defineProperty(t22, "__esModule", { value: true }), t22.toOptionalTokenType = t22.EncodedTokenAttributes = void 0, (n2 = t22.EncodedTokenAttributes || (t22.EncodedTokenAttributes = {})).toBinaryStr = function(e3) {
let t3 = e3.toString(2);
for (; t3.length < 32; )
t3 = "0" + t3;
return t3;
}, n2.print = function(e3) {
const t3 = n2.getLanguageId(e3), s = n2.getTokenType(e3), r2 = n2.getFontStyle(e3), i2 = n2.getForeground(e3), o = n2.getBackground(e3);
console.log({ languageId: t3, tokenType: s, fontStyle: r2, foreground: i2, background: o });
}, n2.getLanguageId = function(e3) {
return (255 & e3) >>> 0;
}, n2.getTokenType = function(e3) {
return (768 & e3) >>> 8;
}, n2.containsBalancedBrackets = function(e3) {
return 0 != (1024 & e3);
}, n2.getFontStyle = function(e3) {
return (30720 & e3) >>> 11;
}, n2.getForeground = function(e3) {
return (16744448 & e3) >>> 15;
}, n2.getBackground = function(e3) {
return (4278190080 & e3) >>> 24;
}, n2.set = function(e3, t3, s, r2, i2, o, c2) {
let a2 = n2.getLanguageId(e3), l = n2.getTokenType(e3), u2 = n2.containsBalancedBrackets(e3) ? 1 : 0, h2 = n2.getFontStyle(e3), p2 = n2.getForeground(e3), d2 = n2.getBackground(e3);
return 0 !== t3 && (a2 = t3), 8 !== s && (l = s), null !== r2 && (u2 = r2 ? 1 : 0), -1 !== i2 && (h2 = i2), 0 !== o && (p2 = o), 0 !== c2 && (d2 = c2), (a2 << 0 | l << 8 | u2 << 10 | h2 << 11 | p2 << 15 | d2 << 24) >>> 0;
}, t22.toOptionalTokenType = function(e3) {
return e3;
};
}, 996: (e22, t22, n2) => {
Object.defineProperty(t22, "__esModule", { value: true }), t22.BasicScopeAttributesProvider = t22.BasicScopeAttributes = void 0;
const s = n2(878);
class r2 {
constructor(e3, t3) {
this.languageId = e3, this.tokenType = t3;
}
}
t22.BasicScopeAttributes = r2;
class i2 {
constructor(e3, t3) {
this._getBasicScopeAttributes = new s.CachedFn((e4) => {
const t4 = this._scopeToLanguage(e4), n22 = this._toStandardTokenType(e4);
return new r2(t4, n22);
}), this._defaultAttributes = new r2(e3, 8), this._embeddedLanguagesMatcher = new o(Object.entries(t3 || {}));
}
getDefaultAttributes() {
return this._defaultAttributes;
}
getBasicScopeAttributes(e3) {
return null === e3 ? i2._NULL_SCOPE_METADATA : this._getBasicScopeAttributes.get(e3);
}
_scopeToLanguage(e3) {
return this._embeddedLanguagesMatcher.match(e3) || 0;
}
_toStandardTokenType(e3) {
const t3 = e3.match(i2.STANDARD_TOKEN_TYPE_REGEXP);
if (!t3)
return 8;
switch (t3[1]) {
case "comment":
return 1;
case "string":
return 2;
case "regex":
return 3;
case "meta.embedded":
return 0;
}
throw new Error("Unexpected match for standard token type!");
}
}
t22.BasicScopeAttributesProvider = i2, i2._NULL_SCOPE_METADATA = new r2(0, 0), i2.STANDARD_TOKEN_TYPE_REGEXP = /\b(comment|string|regex|meta\.embedded)\b/;
class o {
constructor(e3) {
if (0 === e3.length)
this.values = null, this.scopesRegExp = null;
else {
this.values = new Map(e3);
const t3 = e3.map(([e4, t4]) => s.escapeRegExpCharacters(e4));
t3.sort(), t3.reverse(), this.scopesRegExp = new RegExp(`^((${t3.join(")|(")}))($|\\.)`, "");
}
}
match(e3) {
if (!this.scopesRegExp)
return;
const t3 = e3.match(this.scopesRegExp);
return t3 ? this.values.get(t3[1]) : void 0;
}
}
}, 947: (e22, t22, n2) => {
Object.defineProperty(t22, "__esModule", { value: true }), t22.LineTokens = t22.BalancedBracketSelectors = t22.StateStack = t22.AttributedScopeStack = t22.Grammar = t22.createGrammar = void 0;
const s = n2(350), r2 = n2(36), i2 = n2(736), o = n2(44), c2 = n2(792), a2 = n2(583), l = n2(878), u2 = n2(996), h2 = n2(47);
function p2(e3, t3, n22, s2, r22) {
const o2 = i2.createMatchers(t3, d2), a22 = c2.RuleFactory.getCompiledRuleId(n22, s2, r22.repository);
for (const n3 of o2)
e3.push({ debugSelector: t3, matcher: n3.matcher, ruleId: a22, grammar: r22, priority: n3.priority });
}
function d2(e3, t3) {
if (t3.length < e3.length)
return false;
let n22 = 0;
return e3.every((e4) => {
for (let s2 = n22; s2 < t3.length; s2++)
if (f2(t3[s2], e4))
return n22 = s2 + 1, true;
return false;
});
}
function f2(e3, t3) {
if (!e3)
return false;
if (e3 === t3)
return true;
const n22 = t3.length;
return e3.length > n22 && e3.substr(0, n22) === t3 && "." === e3[n22];
}
t22.createGrammar = function(e3, t3, n22, s2, r22, i22, o2, c22) {
return new g(e3, t3, n22, s2, r22, i22, o2, c22);
};
class g {
constructor(e3, t3, n22, s2, r22, o2, c22, a22) {
if (this._rootScopeName = e3, this.balancedBracketSelectors = o2, this._onigLib = a22, this._basicScopeAttributesProvider = new u2.BasicScopeAttributesProvider(n22, s2), this._rootId = -1, this._lastRuleId = 0, this._ruleId2desc = [null], this._includedGrammars = {}, this._grammarRepository = c22, this._grammar = m(t3, null), this._injections = null, this._tokenTypeMatchers = [], r22)
for (const e4 of Object.keys(r22)) {
const t4 = i2.createMatchers(e4, d2);
for (const n3 of t4)
this._tokenTypeMatchers.push({ matcher: n3.matcher, type: r22[e4] });
}
}
get themeProvider() {
return this._grammarRepository;
}
dispose() {
for (const e3 of this._ruleId2desc)
e3 && e3.dispose();
}
createOnigScanner(e3) {
return this._onigLib.createOnigScanner(e3);
}
createOnigString(e3) {
return this._onigLib.createOnigString(e3);
}
getMetadataForScope(e3) {
return this._basicScopeAttributesProvider.getBasicScopeAttributes(e3);
}
_collectInjections() {
const e3 = [], t3 = this._rootScopeName, n22 = ((e4) => e4 === this._rootScopeName ? this._grammar : this.getExternalGrammar(e4))(t3);
if (n22) {
const s2 = n22.injections;
if (s2)
for (let t4 in s2)
p2(e3, t4, s2[t4], this, n22);
const r22 = this._grammarRepository.injections(t3);
r22 && r22.forEach((t4) => {
const n3 = this.getExternalGrammar(t4);
if (n3) {
const t5 = n3.injectionSelector;
t5 && p2(e3, t5, n3, this, n3);
}
});
}
return e3.sort((e4, t4) => e4.priority - t4.priority), e3;
}
getInjections() {
if (null === this._injections && (this._injections = this._collectInjections(), s.DebugFlags.InDebugMode && this._injections.length > 0)) {
console.log(`Grammar ${this._rootScopeName} contains the following injections:`);
for (const e3 of this._injections)
console.log(` - ${e3.debugSelector}`);
}
return this._injections;
}
registerRule(e3) {
const t3 = ++this._lastRuleId, n22 = e3(c2.ruleIdFromNumber(t3));
return this._ruleId2desc[t3] = n22, n22;
}
getRule(e3) {
return this._ruleId2desc[c2.ruleIdToNumber(e3)];
}
getExternalGrammar(e3, t3) {
if (this._includedGrammars[e3])
return this._includedGrammars[e3];
if (this._grammarRepository) {
const n22 = this._grammarRepository.lookup(e3);
if (n22)
return this._includedGrammars[e3] = m(n22, t3 && t3.$base), this._includedGrammars[e3];
}
}
tokenizeLine(e3, t3, n22 = 0) {
const s2 = this._tokenize(e3, t3, false, n22);
return { tokens: s2.lineTokens.getResult(s2.ruleStack, s2.lineLength), ruleStack: s2.ruleStack, stoppedEarly: s2.stoppedEarly };
}
tokenizeLine2(e3, t3, n22 = 0) {
const s2 = this._tokenize(e3, t3, true, n22);
return { tokens: s2.lineTokens.getBinaryResult(s2.ruleStack, s2.lineLength), ruleStack: s2.ruleStack, stoppedEarly: s2.stoppedEarly };
}
_tokenize(e3, t3, n22, s2) {
let i22;
if (-1 === this._rootId && (this._rootId = c2.RuleFactory.getCompiledRuleId(this._grammar.repository.$self, this, this._grammar.repository)), t3 && t3 !== b3.NULL)
i22 = false, t3.reset();
else {
i22 = true;
const e4 = this._basicScopeAttributesProvider.getDefaultAttributes(), n3 = this.themeProvider.getDefaults(), s3 = r2.EncodedTokenAttributes.set(0, e4.languageId, e4.tokenType, null, n3.fontStyle, n3.foregroundId, n3.backgroundId), o2 = this.getRule(this._rootId).getName(null, null);
let c22;
c22 = o2 ? _2.createRootAndLookUpScopeName(o2, s3, this) : _2.createRoot("unknown", s3), t3 = new b3(null, this._rootId, -1, -1, false, null, c22, c22);
}
e3 += "\n";
const a22 = this.createOnigString(e3), l2 = a22.content.length, u22 = new y2(n22, e3, this._tokenTypeMatchers, this.balancedBracketSelectors), p22 = h2._tokenizeString(this, a22, i22, 0, t3, u22, true, s2);
return o.disposeOnigString(a22), { lineLength: l2, lineTokens: u22, ruleStack: p22.stack, stoppedEarly: p22.stoppedEarly };
}
}
function m(e3, t3) {
return (e3 = l.clone(e3)).repository = e3.repository || {}, e3.repository.$self = { $vscodeTextmateLocation: e3.$vscodeTextmateLocation, patterns: e3.patterns, name: e3.scopeName }, e3.repository.$base = t3 || e3.repository.$self, e3;
}
t22.Grammar = g;
class _2 {
constructor(e3, t3, n22) {
this.parent = e3, this.scopePath = t3, this.tokenAttributes = n22;
}
static createRoot(e3, t3) {
return new _2(null, new a2.ScopeStack(null, e3), t3);
}
static createRootAndLookUpScopeName(e3, t3, n22) {
const s2 = n22.getMetadataForScope(e3), r22 = new a2.ScopeStack(null, e3), i22 = n22.themeProvider.themeMatch(r22), o2 = _2.mergeAttributes(t3, s2, i22);
return new _2(null, r22, o2);
}
get scopeName() {
return this.scopePath.scopeName;
}
equals(e3) {
return _2._equals(this, e3);
}
static _equals(e3, t3) {
for (; ; ) {
if (e3 === t3)
return true;
if (!e3 && !t3)
return true;
if (!e3 || !t3)
return false;
if (e3.scopeName !== t3.scopeName || e3.tokenAttributes !== t3.tokenAttributes)
return false;
e3 = e3.parent, t3 = t3.parent;
}
}
static mergeAttributes(e3, t3, n22) {
let s2 = -1, i22 = 0, o2 = 0;
return null !== n22 && (s2 = n22.fontStyle, i22 = n22.foregroundId, o2 = n22.backgroundId), r2.EncodedTokenAttributes.set(e3, t3.languageId, t3.tokenType, null, s2, i22, o2);
}
pushAttributed(e3, t3) {
if (null === e3)
return this;
if (-1 === e3.indexOf(" "))
return _2._pushAttributed(this, e3, t3);
const n22 = e3.split(/ /g);
let s2 = this;
for (const e4 of n22)
s2 = _2._pushAttributed(s2, e4, t3);
return s2;
}
static _pushAttributed(e3, t3, n22) {
const s2 = n22.getMetadataForScope(t3), r22 = e3.scopePath.push(t3), i22 = n22.themeProvider.themeMatch(r22), o2 = _2.mergeAttributes(e3.tokenAttributes, s2, i22);
return new _2(e3, r22, o2);
}
getScopeNames() {
return this.scopePath.getSegments();
}
}
t22.AttributedScopeStack = _2;
class b3 {
constructor(e3, t3, n22, s2, r22, i22, o2, c22) {
this.parent = e3, this.ruleId = t3, this.beginRuleCapturedEOL = r22, this.endRule = i22, this.nameScopesList = o2, this.contentNameScopesList = c22, this._stackElementBrand = void 0, this.depth = this.parent ? this.parent.depth + 1 : 1, this._enterPos = n22, this._anchorPos = s2;
}
equals(e3) {
return null !== e3 && b3._equals(this, e3);
}
static _equals(e3, t3) {
return e3 === t3 || !!this._structuralEquals(e3, t3) && e3.contentNameScopesList.equals(t3.contentNameScopesList);
}
static _structuralEquals(e3, t3) {
for (; ; ) {
if (e3 === t3)
return true;
if (!e3 && !t3)
return true;
if (!e3 || !t3)
return false;
if (e3.depth !== t3.depth || e3.ruleId !== t3.ruleId || e3.endRule !== t3.endRule)
return false;
e3 = e3.parent, t3 = t3.parent;
}
}
clone() {
return this;
}
static _reset(e3) {
for (; e3; )
e3._enterPos = -1, e3._anchorPos = -1, e3 = e3.parent;
}
reset() {
b3._reset(this);
}
pop() {
return this.parent;
}
safePop() {
return this.parent ? this.parent : this;
}
push(e3, t3, n22, s2, r22, i22, o2) {
return new b3(this, e3, t3, n22, s2, r22, i22, o2);
}
getEnterPos() {
return this._enterPos;
}
getAnchorPos() {
return this._anchorPos;
}
getRule(e3) {
return e3.getRule(this.ruleId);
}
toString() {
const e3 = [];
return this._writeString(e3, 0), "[" + e3.join(",") + "]";
}
_writeString(e3, t3) {
return this.parent && (t3 = this.parent._writeString(e3, t3)), e3[t3++] = `(${this.ruleId}, TODO-${this.nameScopesList}, TODO-${this.contentNameScopesList})`, t3;
}
withContentNameScopesList(e3) {
return this.contentNameScopesList === e3 ? this : this.parent.push(this.ruleId, this._enterPos, this._anchorPos, this.beginRuleCapturedEOL, this.endRule, this.nameScopesList, e3);
}
withEndRule(e3) {
return this.endRule === e3 ? this : new b3(this.parent, this.ruleId, this._enterPos, this._anchorPos, this.beginRuleCapturedEOL, e3, this.nameScopesList, this.contentNameScopesList);
}
hasSameRuleAs(e3) {
let t3 = this;
for (; t3 && t3._enterPos === e3._enterPos; ) {
if (t3.ruleId === e3.ruleId)
return true;
t3 = t3.parent;
}
return false;
}
}
t22.StateStack = b3, b3.NULL = new b3(null, 0, 0, 0, false, null, null, null), t22.BalancedBracketSelectors = class {
constructor(e3, t3) {
this.allowAny = false, this.balancedBracketScopes = e3.flatMap((e4) => "*" === e4 ? (this.allowAny = true, []) : i2.createMatchers(e4, d2).map((e5) => e5.matcher)), this.unbalancedBracketScopes = t3.flatMap((e4) => i2.createMatchers(e4, d2).map((e5) => e5.matcher));
}
get matchesAlways() {
return this.allowAny && 0 === this.unbalancedBracketScopes.length;
}
get matchesNever() {
return 0 === this.balancedBracketScopes.length && !this.allowAny;
}
match(e3) {
for (const t3 of this.unbalancedBracketScopes)
if (t3(e3))
return false;
for (const t3 of this.balancedBracketScopes)
if (t3(e3))
return true;
return this.allowAny;
}
};
class y2 {
constructor(e3, t3, n22, r22) {
this.balancedBracketSelectors = r22, this._emitBinaryTokens = e3, this._tokenTypeOverrides = n22, s.DebugFlags.InDebugMode ? this._lineText = t3 : this._lineText = null, this._tokens = [], this._binaryTokens = [], this._lastTokenEndIndex = 0;
}
produce(e3, t3) {
this.produceFromScopes(e3.contentNameScopesList, t3);
}
produceFromScopes(e3, t3) {
var _a2;
if (this._lastTokenEndIndex >= t3)
return;
if (this._emitBinaryTokens) {
let n3 = e3.tokenAttributes, i22 = false;
if (((_a2 = this.balancedBracketSelectors) == null ? void 0 : _a2.matchesAlways) && (i22 = true), this._tokenTypeOverrides.length > 0 || this.balancedBracketSelectors && !this.balancedBracketSelectors.matchesAlways && !this.balancedBracketSelectors.matchesNever) {
const t4 = e3.getScopeNames();
for (const e4 of this._tokenTypeOverrides)
e4.matcher(t4) && (n3 = r2.EncodedTokenAttributes.set(n3, 0, r2.toOptionalTokenType(e4.type), null, -1, 0, 0));
this.balancedBracketSelectors && (i22 = this.balancedBracketSelectors.match(t4));
}
if (i22 && (n3 = r2.EncodedTokenAttributes.set(n3, 0, 8, i22, -1, 0, 0)), this._binaryTokens.length > 0 && this._binaryTokens[this._binaryTokens.length - 1] === n3)
return void (this._lastTokenEndIndex = t3);
if (s.DebugFlags.InDebugMode) {
const n4 = e3.getScopeNames();
console.log(" token: |" + this._lineText.substring(this._lastTokenEndIndex, t3).replace(/\n$/, "\\n") + "|");
for (let e4 = 0; e4 < n4.length; e4++)
console.log(" * " + n4[e4]);
}
return this._binaryTokens.push(this._lastTokenEndIndex), this._binaryTokens.push(n3), void (this._lastTokenEndIndex = t3);
}
const n22 = e3.getScopeNames();
if (s.DebugFlags.InDebugMode) {
console.log(" token: |" + this._lineText.substring(this._lastTokenEndIndex, t3).replace(/\n$/, "\\n") + "|");
for (let e4 = 0; e4 < n22.length; e4++)
console.log(" * " + n22[e4]);
}
this._tokens.push({ startIndex: this._lastTokenEndIndex, endIndex: t3, scopes: n22 }), this._lastTokenEndIndex = t3;
}
getResult(e3, t3) {
return this._tokens.length > 0 && this._tokens[this._tokens.length - 1].startIndex === t3 - 1 && this._tokens.pop(), 0 === this._tokens.length && (this._lastTokenEndIndex = -1, this.produce(e3, t3), this._tokens[this._tokens.length - 1].startIndex = 0), this._tokens;
}
getBinaryResult(e3, t3) {
this._binaryTokens.length > 0 && this._binaryTokens[this._binaryTokens.length - 2] === t3 - 1 && (this._binaryTokens.pop(), this._binaryTokens.pop()), 0 === this._binaryTokens.length && (this._lastTokenEndIndex = -1, this.produce(e3, t3), this._binaryTokens[this._binaryTokens.length - 2] = 0);
const n22 = new Uint32Array(this._binaryTokens.length);
for (let e4 = 0, t4 = this._binaryTokens.length; e4 < t4; e4++)
n22[e4] = this._binaryTokens[e4];
return n22;
}
}
t22.LineTokens = y2;
}, 965: (e22, t22, n2) => {
Object.defineProperty(t22, "__esModule", { value: true }), t22.parseInclude = t22.TopLevelRepositoryReference = t22.TopLevelReference = t22.RelativeReference = t22.SelfReference = t22.BaseReference = t22.ScopeDependencyProcessor = t22.ExternalReferenceCollector = t22.TopLevelRepositoryRuleReference = t22.TopLevelRuleReference = void 0;
const s = n2(878);
class r2 {
constructor(e3) {
this.scopeName = e3;
}
toKey() {
return this.scopeName;
}
}
t22.TopLevelRuleReference = r2;
class i2 {
constructor(e3, t3) {
this.scopeName = e3, this.ruleName = t3;
}
toKey() {
return `${this.scopeName}#${this.ruleName}`;
}
}
t22.TopLevelRepositoryRuleReference = i2;
class o {
constructor() {
this._references = [], this._seenReferenceKeys = /* @__PURE__ */ new Set(), this.visitedRule = /* @__PURE__ */ new Set();
}
get references() {
return this._references;
}
add(e3) {
const t3 = e3.toKey();
this._seenReferenceKeys.has(t3) || (this._seenReferenceKeys.add(t3), this._references.push(e3));
}
}
function c2(e3, t3, n22, s2) {
const i22 = n22.lookup(e3.scopeName);
if (!i22) {
if (e3.scopeName === t3)
throw new Error(`No grammar provided for <${t3}>`);
return;
}
const o2 = n22.lookup(t3);
e3 instanceof r2 ? l({ baseGrammar: o2, selfGrammar: i22 }, s2) : a2(e3.ruleName, { baseGrammar: o2, selfGrammar: i22, repository: i22.repository }, s2);
const c22 = n22.injections(e3.scopeName);
if (c22)
for (const e4 of c22)
s2.add(new r2(e4));
}
function a2(e3, t3, n22) {
t3.repository && t3.repository[e3] && u2([t3.repository[e3]], t3, n22);
}
function l(e3, t3) {
e3.selfGrammar.patterns && Array.isArray(e3.selfGrammar.patterns) && u2(e3.selfGrammar.patterns, { ...e3, repository: e3.selfGrammar.repository }, t3), e3.selfGrammar.injections && u2(Object.values(e3.selfGrammar.injections), { ...e3, repository: e3.selfGrammar.repository }, t3);
}
function u2(e3, t3, n22) {
for (const o2 of e3) {
if (n22.visitedRule.has(o2))
continue;
n22.visitedRule.add(o2);
const e4 = o2.repository ? s.mergeObjects({}, t3.repository, o2.repository) : t3.repository;
Array.isArray(o2.patterns) && u2(o2.patterns, { ...t3, repository: e4 }, n22);
const c22 = o2.include;
if (!c22)
continue;
const h22 = m(c22);
switch (h22.kind) {
case 0:
l({ ...t3, selfGrammar: t3.baseGrammar }, n22);
break;
case 1:
l(t3, n22);
break;
case 2:
a2(h22.ruleName, { ...t3, repository: e4 }, n22);
break;
case 3:
case 4:
const s2 = h22.scopeName === t3.selfGrammar.scopeName ? t3.selfGrammar : h22.scopeName === t3.baseGrammar.scopeName ? t3.baseGrammar : void 0;
if (s2) {
const r22 = { baseGrammar: t3.baseGrammar, selfGrammar: s2, repository: e4 };
4 === h22.kind ? a2(h22.ruleName, r22, n22) : l(r22, n22);
} else
4 === h22.kind ? n22.add(new i2(h22.scopeName, h22.ruleName)) : n22.add(new r2(h22.scopeName));
}
}
}
t22.ExternalReferenceCollector = o, t22.ScopeDependencyProcessor = class {
constructor(e3, t3) {
this.repo = e3, this.initialScopeName = t3, this.seenFullScopeRequests = /* @__PURE__ */ new Set(), this.seenPartialScopeRequests = /* @__PURE__ */ new Set(), this.seenFullScopeRequests.add(this.initialScopeName), this.Q = [new r2(this.initialScopeName)];
}
processQueue() {
const e3 = this.Q;
this.Q = [];
const t3 = new o();
for (const n22 of e3)
c2(n22, this.initialScopeName, this.repo, t3);
for (const e4 of t3.references)
if (e4 instanceof r2) {
if (this.seenFullScopeRequests.has(e4.scopeName))
continue;
this.seenFullScopeRequests.add(e4.scopeName), this.Q.push(e4);
} else {
if (this.seenFullScopeRequests.has(e4.scopeName))
continue;
if (this.seenPartialScopeRequests.has(e4.toKey()))
continue;
this.seenPartialScopeRequests.add(e4.toKey()), this.Q.push(e4);
}
}
};
class h2 {
constructor() {
this.kind = 0;
}
}
t22.BaseReference = h2;
class p2 {
constructor() {
this.kind = 1;
}
}
t22.SelfReference = p2;
class d2 {
constructor(e3) {
this.ruleName = e3, this.kind = 2;
}
}
t22.RelativeReference = d2;
class f2 {
constructor(e3) {
this.scopeName = e3, this.kind = 3;
}
}
t22.TopLevelReference = f2;
class g {
constructor(e3, t3) {
this.scopeName = e3, this.ruleName = t3, this.kind = 4;
}
}
function m(e3) {
if ("$base" === e3)
return new h2();
if ("$self" === e3)
return new p2();
const t3 = e3.indexOf("#");
if (-1 === t3)
return new f2(e3);
if (0 === t3)
return new d2(e3.substring(1));
{
const n22 = e3.substring(0, t3), s2 = e3.substring(t3 + 1);
return new g(n22, s2);
}
}
t22.TopLevelRepositoryReference = g, t22.parseInclude = m;
}, 391: function(e22, t22, n2) {
var s = this && this.__createBinding || (Object.create ? function(e3, t3, n22, s2) {
void 0 === s2 && (s2 = n22), Object.defineProperty(e3, s2, { enumerable: true, get: function() {
return t3[n22];
} });
} : function(e3, t3, n22, s2) {
void 0 === s2 && (s2 = n22), e3[s2] = t3[n22];
}), r2 = this && this.__exportStar || function(e3, t3) {
for (var n22 in e3)
"default" === n22 || Object.prototype.hasOwnProperty.call(t3, n22) || s(t3, e3, n22);
};
Object.defineProperty(t22, "__esModule", { value: true }), r2(n2(947), t22);
}, 47: (e22, t22, n2) => {
Object.defineProperty(t22, "__esModule", { value: true }), t22.LocalStackElement = t22._tokenizeString = void 0;
const s = n2(350), r2 = n2(44), i2 = n2(792), o = n2(878);
class c2 {
constructor(e3, t3) {
this.stack = e3, this.stoppedEarly = t3;
}
}
function a2(e3, t3, n22, r22, a22, h22, d22, f2) {
const g = t3.content.length;
let m = false, _2 = -1;
if (d22) {
const o2 = function(e4, t4, n3, r3, o3, c22) {
let a3 = o3.beginRuleCapturedEOL ? 0 : -1;
const l2 = [];
for (let t5 = o3; t5; t5 = t5.pop()) {
const n4 = t5.getRule(e4);
n4 instanceof i2.BeginWhileRule && l2.push({ rule: n4, stack: t5 });
}
for (let h3 = l2.pop(); h3; h3 = l2.pop()) {
const { ruleScanner: l3, findOptions: d3 } = u2(h3.rule, e4, h3.stack.endRule, n3, r3 === a3), f22 = l3.findNextMatchSync(t4, r3, d3);
if (s.DebugFlags.InDebugMode && (console.log(" scanning for while rule"), console.log(l3.toString())), !f22) {
s.DebugFlags.InDebugMode && console.log(" popping " + h3.rule.debugName + " - " + h3.rule.debugWhileRegExp), o3 = h3.stack.pop();
break;
}
if (f22.ruleId !== i2.whileRuleId) {
o3 = h3.stack.pop();
break;
}
f22.captureIndices && f22.captureIndices.length && (c22.produce(h3.stack, f22.captureIndices[0].start), p2(e4, t4, n3, h3.stack, c22, h3.rule.whileCaptures, f22.captureIndices), c22.produce(h3.stack, f22.captureIndices[0].end), a3 = f22.captureIndices[0].end, f22.captureIndices[0].end > r3 && (r3 = f22.captureIndices[0].end, n3 = false));
}
return { stack: o3, linePos: r3, anchorPosition: a3, isFirstLine: n3 };
}(e3, t3, n22, r22, a22, h22);
a22 = o2.stack, r22 = o2.linePos, n22 = o2.isFirstLine, _2 = o2.anchorPosition;
}
const b3 = Date.now();
for (; !m; ) {
if (0 !== f2 && Date.now() - b3 > f2)
return new c2(a22, true);
y2();
}
return new c2(a22, false);
function y2() {
s.DebugFlags.InDebugMode && (console.log(""), console.log(`@@scanNext ${r22}: |${t3.content.substr(r22).replace(/\n$/, "\\n")}|`));
const c22 = function(e4, t4, n3, r3, i22, c3) {
const a3 = function(e5, t5, n4, r4, i3, c4) {
const a4 = i3.getRule(e5), { ruleScanner: u4, findOptions: h4 } = l(a4, e5, i3.endRule, n4, r4 === c4);
let p3 = 0;
s.DebugFlags.InDebugMode && (p3 = o.performanceNow());
const d5 = u4.findNextMatchSync(t5, r4, h4);
if (s.DebugFlags.InDebugMode) {
const e6 = o.performanceNow() - p3;
e6 > 5 && console.warn(`Rule ${a4.debugName} (${a4.id}) matching took ${e6} against '${t5}'`), console.log(` scanning for (linePos: ${r4}, anchorPosition: ${c4})`), console.log(u4.toString()), d5 && console.log(`matched rule id: ${d5.ruleId} from ${d5.captureIndices[0].start} to ${d5.captureIndices[0].end}`);
}
return d5 ? { captureIndices: d5.captureIndices, matchedRuleId: d5.ruleId } : null;
}(e4, t4, n3, r3, i22, c3), u3 = e4.getInjections();
if (0 === u3.length)
return a3;
const h3 = function(e5, t5, n4, r4, i3, o2, c4) {
let a4, u4 = Number.MAX_VALUE, h4 = null, p3 = 0;
const d5 = o2.contentNameScopesList.getScopeNames();
for (let o3 = 0, f3 = e5.length; o3 < f3; o3++) {
const f4 = e5[o3];
if (!f4.matcher(d5))
continue;
const g2 = t5.getRule(f4.ruleId), { ruleScanner: m2, findOptions: _22 } = l(g2, t5, null, r4, i3 === c4), b22 = m2.findNextMatchSync(n4, i3, _22);
if (!b22)
continue;
s.DebugFlags.InDebugMode && (console.log(` matched injection: ${f4.debugSelector}`), console.log(m2.toString()));
const y22 = b22.captureIndices[0].start;
if (!(y22 >= u4) && (u4 = y22, h4 = b22.captureIndices, a4 = b22.ruleId, p3 = f4.priority, u4 === i3))
break;
}
return h4 ? { priorityMatch: -1 === p3, captureIndices: h4, matchedRuleId: a4 } : null;
}(u3, e4, t4, n3, r3, i22, c3);
if (!h3)
return a3;
if (!a3)
return h3;
const p22 = a3.captureIndices[0].start, d4 = h3.captureIndices[0].start;
return d4 < p22 || h3.priorityMatch && d4 === p22 ? h3 : a3;
}(e3, t3, n22, r22, a22, _2);
if (!c22)
return s.DebugFlags.InDebugMode && console.log(" no more matches."), h22.produce(a22, g), void (m = true);
const u22 = c22.captureIndices, d3 = c22.matchedRuleId, f22 = !!(u22 && u22.length > 0) && u22[0].end > r22;
if (d3 === i2.endRuleId) {
const i22 = a22.getRule(e3);
s.DebugFlags.InDebugMode && console.log(" popping " + i22.debugName + " - " + i22.debugEndRegExp), h22.produce(a22, u22[0].start), a22 = a22.withContentNameScopesList(a22.nameScopesList), p2(e3, t3, n22, a22, h22, i22.endCaptures, u22), h22.produce(a22, u22[0].end);
const o2 = a22;
if (a22 = a22.parent, _2 = o2.getAnchorPos(), !f22 && o2.getEnterPos() === r22)
return s.DebugFlags.InDebugMode && console.error("[1] - Grammar is in an endless loop - Grammar pushed & popped a rule without advancing"), a22 = o2, h22.produce(a22, g), void (m = true);
} else {
const o2 = e3.getRule(d3);
h22.produce(a22, u22[0].start);
const c3 = a22, l2 = o2.getName(t3.content, u22), b22 = a22.contentNameScopesList.pushAttributed(l2, e3);
if (a22 = a22.push(d3, r22, _2, u22[0].end === g, null, b22, b22), o2 instanceof i2.BeginEndRule) {
const r3 = o2;
s.DebugFlags.InDebugMode && console.log(" pushing " + r3.debugName + " - " + r3.debugBeginRegExp), p2(e3, t3, n22, a22, h22, r3.beginCaptures, u22), h22.produce(a22, u22[0].end), _2 = u22[0].end;
const i22 = r3.getContentName(t3.content, u22), l3 = b22.pushAttributed(i22, e3);
if (a22 = a22.withContentNameScopesList(l3), r3.endHasBackReferences && (a22 = a22.withEndRule(r3.getEndWithResolvedBackReferences(t3.content, u22))), !f22 && c3.hasSameRuleAs(a22))
return s.DebugFlags.InDebugMode && console.error("[2] - Grammar is in an endless loop - Grammar pushed the same rule without advancing"), a22 = a22.pop(), h22.produce(a22, g), void (m = true);
} else if (o2 instanceof i2.BeginWhileRule) {
const r3 = o2;
s.DebugFlags.InDebugMode && console.log(" pushing " + r3.debugName), p2(e3, t3, n22, a22, h22, r3.beginCaptures, u22), h22.produce(a22, u22[0].end), _2 = u22[0].end;
const i22 = r3.getContentName(t3.content, u22), l3 = b22.pushAttributed(i22, e3);
if (a22 = a22.withContentNameScopesList(l3), r3.whileHasBackReferences && (a22 = a22.withEndRule(r3.getWhileWithResolvedBackReferences(t3.content, u22))), !f22 && c3.hasSameRuleAs(a22))
return s.DebugFlags.InDebugMode && console.error("[3] - Grammar is in an endless loop - Grammar pushed the same rule without advancing"), a22 = a22.pop(), h22.produce(a22, g), void (m = true);
} else {
const r3 = o2;
if (s.DebugFlags.InDebugMode && console.log(" matched " + r3.debugName + " - " + r3.debugMatchRegExp), p2(e3, t3, n22, a22, h22, r3.captures, u22), h22.produce(a22, u22[0].end), a22 = a22.pop(), !f22)
return s.DebugFlags.InDebugMode && console.error("[4] - Grammar is in an endless loop - Grammar is not advancing, nor is it pushing/popping"), a22 = a22.safePop(), h22.produce(a22, g), void (m = true);
}
}
u22[0].end > r22 && (r22 = u22[0].end, n22 = false);
}
}
function l(e3, t3, n22, r22, i22) {
return s.UseOnigurumaFindOptions ? { ruleScanner: e3.compile(t3, n22), findOptions: h2(r22, i22) } : { ruleScanner: e3.compileAG(t3, n22, r22, i22), findOptions: 0 };
}
function u2(e3, t3, n22, r22, i22) {
return s.UseOnigurumaFindOptions ? { ruleScanner: e3.compileWhile(t3, n22), findOptions: h2(r22, i22) } : { ruleScanner: e3.compileWhileAG(t3, n22, r22, i22), findOptions: 0 };
}
function h2(e3, t3) {
let n22 = 0;
return e3 || (n22 |= 1), t3 || (n22 |= 4), n22;
}
function p2(e3, t3, n22, s2, i22, o2, c22) {
if (0 === o2.length)
return;
const l2 = t3.content, u22 = Math.min(o2.length, c22.length), h22 = [], p22 = c22[0].end;
for (let t4 = 0; t4 < u22; t4++) {
const u3 = o2[t4];
if (null === u3)
continue;
const f2 = c22[t4];
if (0 === f2.length)
continue;
if (f2.start > p22)
break;
for (; h22.length > 0 && h22[h22.length - 1].endPos <= f2.start; )
i22.produceFromScopes(h22[h22.length - 1].scopes, h22[h22.length - 1].endPos), h22.pop();
if (h22.length > 0 ? i22.produceFromScopes(h22[h22.length - 1].scopes, f2.start) : i22.produce(s2, f2.start), u3.retokenizeCapturedWithRuleId) {
const t5 = u3.getName(l2, c22), o3 = s2.contentNameScopesList.pushAttributed(t5, e3), h3 = u3.getContentName(l2, c22), p3 = o3.pushAttributed(h3, e3), d22 = s2.push(u3.retokenizeCapturedWithRuleId, f2.start, -1, false, null, o3, p3), g2 = e3.createOnigString(l2.substring(0, f2.end));
a2(e3, g2, n22 && 0 === f2.start, f2.start, d22, i22, false, 0), r2.disposeOnigString(g2);
continue;
}
const g = u3.getName(l2, c22);
if (null !== g) {
const t5 = (h22.length > 0 ? h22[h22.length - 1].scopes : s2.contentNameScopesList).pushAttributed(g, e3);
h22.push(new d2(t5, f2.end));
}
}
for (; h22.length > 0; )
i22.produceFromScopes(h22[h22.length - 1].scopes, h22[h22.length - 1].endPos), h22.pop();
}
t22._tokenizeString = a2;
class d2 {
constructor(e3, t3) {
this.scopes = e3, this.endPos = t3;
}
}
t22.LocalStackElement = d2;
}, 974: (e22, t22) => {
function n2(e3, t3) {
throw new Error("Near offset " + e3.pos + ": " + t3 + " ~~~" + e3.source.substr(e3.pos, 50) + "~~~");
}
Object.defineProperty(t22, "__esModule", { value: true }), t22.parseJSON = void 0, t22.parseJSON = function(e3, t3, o) {
let c2 = new s(e3), a2 = new r2(), l = 0, u2 = null, h2 = [], p2 = [];
function d2() {
h2.push(l), p2.push(u2);
}
function f2() {
l = h2.pop(), u2 = p2.pop();
}
function g(e4) {
n2(c2, e4);
}
for (; i2(c2, a2); ) {
if (0 === l) {
if (null !== u2 && g("too many constructs in root"), 3 === a2.type) {
u2 = {}, o && (u2.$vscodeTextmateLocation = a2.toLocation(t3)), d2(), l = 1;
continue;
}
if (2 === a2.type) {
u2 = [], d2(), l = 4;
continue;
}
g("unexpected token in root");
}
if (2 === l) {
if (5 === a2.type) {
f2();
continue;
}
if (7 === a2.type) {
l = 3;
continue;
}
g("expected , or }");
}
if (1 === l || 3 === l) {
if (1 === l && 5 === a2.type) {
f2();
continue;
}
if (1 === a2.type) {
let e4 = a2.value;
if (i2(c2, a2) && 6 === a2.type || g("expected colon"), i2(c2, a2) || g("expected value"), l = 2, 1 === a2.type) {
u2[e4] = a2.value;
continue;
}
if (8 === a2.type) {
u2[e4] = null;
continue;
}
if (9 === a2.type) {
u2[e4] = true;
continue;
}
if (10 === a2.type) {
u2[e4] = false;
continue;
}
if (11 === a2.type) {
u2[e4] = parseFloat(a2.value);
continue;
}
if (2 === a2.type) {
let t4 = [];
u2[e4] = t4, d2(), l = 4, u2 = t4;
continue;
}
if (3 === a2.type) {
let n22 = {};
o && (n22.$vscodeTextmateLocation = a2.toLocation(t3)), u2[e4] = n22, d2(), l = 1, u2 = n22;
continue;
}
}
g("unexpected token in dict");
}
if (5 === l) {
if (4 === a2.type) {
f2();
continue;
}
if (7 === a2.type) {
l = 6;
continue;
}
g("expected , or ]");
}
if (4 === l || 6 === l) {
if (4 === l && 4 === a2.type) {
f2();
continue;
}
if (l = 5, 1 === a2.type) {
u2.push(a2.value);
continue;
}
if (8 === a2.type) {
u2.push(null);
continue;
}
if (9 === a2.type) {
u2.push(true);
continue;
}
if (10 === a2.type) {
u2.push(false);
continue;
}
if (11 === a2.type) {
u2.push(parseFloat(a2.value));
continue;
}
if (2 === a2.type) {
let e4 = [];
u2.push(e4), d2(), l = 4, u2 = e4;
continue;
}
if (3 === a2.type) {
let e4 = {};
o && (e4.$vscodeTextmateLocation = a2.toLocation(t3)), u2.push(e4), d2(), l = 1, u2 = e4;
continue;
}
g("unexpected token in array");
}
g("unknown state");
}
return 0 !== p2.length && g("unclosed constructs"), u2;
};
class s {
constructor(e3) {
this.source = e3, this.pos = 0, this.len = e3.length, this.line = 1, this.char = 0;
}
}
class r2 {
constructor() {
this.value = null, this.type = 0, this.offset = -1, this.len = -1, this.line = -1, this.char = -1;
}
toLocation(e3) {
return { filename: e3, line: this.line, char: this.char };
}
}
function i2(e3, t3) {
t3.value = null, t3.type = 0, t3.offset = -1, t3.len = -1, t3.line = -1, t3.char = -1;
let s2, r22 = e3.source, i22 = e3.pos, o = e3.len, c2 = e3.line, a2 = e3.char;
for (; ; ) {
if (i22 >= o)
return false;
if (s2 = r22.charCodeAt(i22), 32 !== s2 && 9 !== s2 && 13 !== s2) {
if (10 !== s2)
break;
i22++, c2++, a2 = 0;
} else
i22++, a2++;
}
if (t3.offset = i22, t3.line = c2, t3.char = a2, 34 === s2) {
for (t3.type = 1, i22++, a2++; ; ) {
if (i22 >= o)
return false;
if (s2 = r22.charCodeAt(i22), i22++, a2++, 92 !== s2) {
if (34 === s2)
break;
} else
i22++, a2++;
}
t3.value = r22.substring(t3.offset + 1, i22 - 1).replace(/\\u([0-9A-Fa-f]{4})/g, (e4, t4) => String.fromCodePoint(parseInt(t4, 16))).replace(/\\(.)/g, (t4, s3) => {
switch (s3) {
case '"':
return '"';
case "\\":
return "\\";
case "/":
return "/";
case "b":
return "\b";
case "f":
return "\f";
case "n":
return "\n";
case "r":
return "\r";
case "t":
return " ";
default:
n2(e3, "invalid escape sequence");
}
throw new Error("unreachable");
});
} else if (91 === s2)
t3.type = 2, i22++, a2++;
else if (123 === s2)
t3.type = 3, i22++, a2++;
else if (93 === s2)
t3.type = 4, i22++, a2++;
else if (125 === s2)
t3.type = 5, i22++, a2++;
else if (58 === s2)
t3.type = 6, i22++, a2++;
else if (44 === s2)
t3.type = 7, i22++, a2++;
else if (110 === s2) {
if (t3.type = 8, i22++, a2++, s2 = r22.charCodeAt(i22), 117 !== s2)
return false;
if (i22++, a2++, s2 = r22.charCodeAt(i22), 108 !== s2)
return false;
if (i22++, a2++, s2 = r22.charCodeAt(i22), 108 !== s2)
return false;
i22++, a2++;
} else if (116 === s2) {
if (t3.type = 9, i22++, a2++, s2 = r22.charCodeAt(i22), 114 !== s2)
return false;
if (i22++, a2++, s2 = r22.charCodeAt(i22), 117 !== s2)
return false;
if (i22++, a2++, s2 = r22.charCodeAt(i22), 101 !== s2)
return false;
i22++, a2++;
} else if (102 === s2) {
if (t3.type = 10, i22++, a2++, s2 = r22.charCodeAt(i22), 97 !== s2)
return false;
if (i22++, a2++, s2 = r22.charCodeAt(i22), 108 !== s2)
return false;
if (i22++, a2++, s2 = r22.charCodeAt(i22), 115 !== s2)
return false;
if (i22++, a2++, s2 = r22.charCodeAt(i22), 101 !== s2)
return false;
i22++, a2++;
} else
for (t3.type = 11; ; ) {
if (i22 >= o)
return false;
if (s2 = r22.charCodeAt(i22), !(46 === s2 || s2 >= 48 && s2 <= 57 || 101 === s2 || 69 === s2 || 45 === s2 || 43 === s2))
break;
i22++, a2++;
}
return t3.len = i22 - t3.offset, null === t3.value && (t3.value = r22.substr(t3.offset, t3.len)), e3.pos = i22, e3.line = c2, e3.char = a2, true;
}
}, 787: function(e22, t22, n2) {
var s = this && this.__createBinding || (Object.create ? function(e3, t3, n22, s2) {
void 0 === s2 && (s2 = n22), Object.defineProperty(e3, s2, { enumerable: true, get: function() {
return t3[n22];
} });
} : function(e3, t3, n22, s2) {
void 0 === s2 && (s2 = n22), e3[s2] = t3[n22];
}), r2 = this && this.__exportStar || function(e3, t3) {
for (var n22 in e3)
"default" === n22 || Object.prototype.hasOwnProperty.call(t3, n22) || s(t3, e3, n22);
};
Object.defineProperty(t22, "__esModule", { value: true }), t22.parseRawGrammar = t22.INITIAL = t22.Registry = void 0;
const i2 = n2(391), o = n2(50), c2 = n2(652), a2 = n2(583), l = n2(965);
r2(n2(44), t22), t22.Registry = class {
constructor(e3) {
this._options = e3, this._syncRegistry = new c2.SyncRegistry(a2.Theme.createFromRawTheme(e3.theme, e3.colorMap), e3.onigLib), this._ensureGrammarCache = /* @__PURE__ */ new Map();
}
dispose() {
this._syncRegistry.dispose();
}
setTheme(e3, t3) {
this._syncRegistry.setTheme(a2.Theme.createFromRawTheme(e3, t3));
}
getColorMap() {
return this._syncRegistry.getColorMap();
}
loadGrammarWithEmbeddedLanguages(e3, t3, n22) {
return this.loadGrammarWithConfiguration(e3, t3, { embeddedLanguages: n22 });
}
loadGrammarWithConfiguration(e3, t3, n22) {
return this._loadGrammar(e3, t3, n22.embeddedLanguages, n22.tokenTypes, new i2.BalancedBracketSelectors(n22.balancedBracketSelectors || [], n22.unbalancedBracketSelectors || []));
}
loadGrammar(e3) {
return this._loadGrammar(e3, 0, null, null, null);
}
async _loadGrammar(e3, t3, n22, s2, r22) {
const i22 = new l.ScopeDependencyProcessor(this._syncRegistry, e3);
for (; i22.Q.length > 0; )
await Promise.all(i22.Q.map((e4) => this._loadSingleGrammar(e4.scopeName))), i22.processQueue();
return this._grammarForScopeName(e3, t3, n22, s2, r22);
}
async _loadSingleGrammar(e3) {
return this._ensureGrammarCache.has(e3) || this._ensureGrammarCache.set(e3, this._doLoadSingleGrammar(e3)), this._ensureGrammarCache.get(e3);
}
async _doLoadSingleGrammar(e3) {
const t3 = await this._options.loadGrammar(e3);
if (t3) {
const n22 = "function" == typeof this._options.getInjections ? this._options.getInjections(e3) : void 0;
this._syncRegistry.addGrammar(t3, n22);
}
}
async addGrammar(e3, t3 = [], n22 = 0, s2 = null) {
return this._syncRegistry.addGrammar(e3, t3), await this._grammarForScopeName(e3.scopeName, n22, s2);
}
_grammarForScopeName(e3, t3 = 0, n22 = null, s2 = null, r22 = null) {
return this._syncRegistry.grammarForScopeName(e3, t3, n22, s2, r22);
}
}, t22.INITIAL = i2.StateStack.NULL, t22.parseRawGrammar = o.parseRawGrammar;
}, 736: (e22, t22) => {
function n2(e3) {
return !!e3 && !!e3.match(/[\w\.:]+/);
}
Object.defineProperty(t22, "__esModule", { value: true }), t22.createMatchers = void 0, t22.createMatchers = function(e3, t3) {
const s = [], r2 = function(e4) {
let t4 = /([LR]:|[\w\.:][\w\.:\-]*|[\,\|\-\(\)])/g, n22 = t4.exec(e4);
return { next: () => {
if (!n22)
return null;
const s2 = n22[0];
return n22 = t4.exec(e4), s2;
} };
}(e3);
let i2 = r2.next();
for (; null !== i2; ) {
let e4 = 0;
if (2 === i2.length && ":" === i2.charAt(1)) {
switch (i2.charAt(0)) {
case "R":
e4 = 1;
break;
case "L":
e4 = -1;
break;
default:
console.log(`Unknown priority ${i2} in scope selector`);
}
i2 = r2.next();
}
let t4 = c2();
if (s.push({ matcher: t4, priority: e4 }), "," !== i2)
break;
i2 = r2.next();
}
return s;
function o() {
if ("-" === i2) {
i2 = r2.next();
const e4 = o();
return (t4) => !!e4 && !e4(t4);
}
if ("(" === i2) {
i2 = r2.next();
const e4 = function() {
const e5 = [];
let t4 = c2();
for (; t4 && (e5.push(t4), "|" === i2 || "," === i2); ) {
do {
i2 = r2.next();
} while ("|" === i2 || "," === i2);
t4 = c2();
}
return (t5) => e5.some((e6) => e6(t5));
}();
return ")" === i2 && (i2 = r2.next()), e4;
}
if (n2(i2)) {
const e4 = [];
do {
e4.push(i2), i2 = r2.next();
} while (n2(i2));
return (n22) => t3(e4, n22);
}
return null;
}
function c2() {
const e4 = [];
let t4 = o();
for (; t4; )
e4.push(t4), t4 = o();
return (t5) => e4.every((e5) => e5(t5));
}
};
}, 44: (e22, t22) => {
Object.defineProperty(t22, "__esModule", { value: true }), t22.disposeOnigString = void 0, t22.disposeOnigString = function(e3) {
"function" == typeof e3.dispose && e3.dispose();
};
}, 50: (e22, t22, n2) => {
Object.defineProperty(t22, "__esModule", { value: true }), t22.parseRawGrammar = void 0;
const s = n2(69), r2 = n2(350), i2 = n2(974);
t22.parseRawGrammar = function(e3, t3 = null) {
return null !== t3 && /\.json$/.test(t3) ? (n22 = e3, o = t3, r2.DebugFlags.InDebugMode ? i2.parseJSON(n22, o, true) : JSON.parse(n22)) : function(e4, t4) {
return r2.DebugFlags.InDebugMode ? s.parseWithLocation(e4, t4, "$vscodeTextmateLocation") : s.parsePLIST(e4);
}(e3, t3);
var n22, o;
};
}, 69: (e22, t22) => {
function n2(e3, t3, n22) {
const s = e3.length;
let r2 = 0, i2 = 1, o = 0;
function c2(t4) {
if (null === n22)
r2 += t4;
else
for (; t4 > 0; )
10 === e3.charCodeAt(r2) ? (r2++, i2++, o = 0) : (r2++, o++), t4--;
}
function a2(e4) {
null === n22 ? r2 = e4 : c2(e4 - r2);
}
function l() {
for (; r2 < s; ) {
let t4 = e3.charCodeAt(r2);
if (32 !== t4 && 9 !== t4 && 13 !== t4 && 10 !== t4)
break;
c2(1);
}
}
function u2(t4) {
return e3.substr(r2, t4.length) === t4 && (c2(t4.length), true);
}
function h2(t4) {
let n3 = e3.indexOf(t4, r2);
a2(-1 !== n3 ? n3 + t4.length : s);
}
function p2(t4) {
let n3 = e3.indexOf(t4, r2);
if (-1 !== n3) {
let s2 = e3.substring(r2, n3);
return a2(n3 + t4.length), s2;
}
{
let t5 = e3.substr(r2);
return a2(s), t5;
}
}
s > 0 && 65279 === e3.charCodeAt(0) && (r2 = 1);
let d2 = 0, f2 = null, g = [], m = [], _2 = null;
function b3(e4, t4) {
g.push(d2), m.push(f2), d2 = e4, f2 = t4;
}
function y2() {
if (0 === g.length)
return S2("illegal state stack");
d2 = g.pop(), f2 = m.pop();
}
function S2(t4) {
throw new Error("Near offset " + r2 + ": " + t4 + " ~~~" + e3.substr(r2, 50) + "~~~");
}
const k2 = function() {
if (null === _2)
return S2("missing <key>");
let e4 = {};
null !== n22 && (e4[n22] = { filename: t3, line: i2, char: o }), f2[_2] = e4, _2 = null, b3(1, e4);
}, C2 = function() {
if (null === _2)
return S2("missing <key>");
let e4 = [];
f2[_2] = e4, _2 = null, b3(2, e4);
}, R3 = function() {
let e4 = {};
null !== n22 && (e4[n22] = { filename: t3, line: i2, char: o }), f2.push(e4), b3(1, e4);
}, A2 = function() {
let e4 = [];
f2.push(e4), b3(2, e4);
};
function w2() {
if (1 !== d2)
return S2("unexpected </dict>");
y2();
}
function P2() {
return 1 === d2 || 2 !== d2 ? S2("unexpected </array>") : void y2();
}
function I2(e4) {
if (1 === d2) {
if (null === _2)
return S2("missing <key>");
f2[_2] = e4, _2 = null;
} else
2 === d2 ? f2.push(e4) : f2 = e4;
}
function v2(e4) {
if (isNaN(e4))
return S2("cannot parse float");
if (1 === d2) {
if (null === _2)
return S2("missing <key>");
f2[_2] = e4, _2 = null;
} else
2 === d2 ? f2.push(e4) : f2 = e4;
}
function N3(e4) {
if (isNaN(e4))
return S2("cannot parse integer");
if (1 === d2) {
if (null === _2)
return S2("missing <key>");
f2[_2] = e4, _2 = null;
} else
2 === d2 ? f2.push(e4) : f2 = e4;
}
function T2(e4) {
if (1 === d2) {
if (null === _2)
return S2("missing <key>");
f2[_2] = e4, _2 = null;
} else
2 === d2 ? f2.push(e4) : f2 = e4;
}
function x2(e4) {
if (1 === d2) {
if (null === _2)
return S2("missing <key>");
f2[_2] = e4, _2 = null;
} else
2 === d2 ? f2.push(e4) : f2 = e4;
}
function G2(e4) {
if (1 === d2) {
if (null === _2)
return S2("missing <key>");
f2[_2] = e4, _2 = null;
} else
2 === d2 ? f2.push(e4) : f2 = e4;
}
function E2() {
let e4 = p2(">"), t4 = false;
return 47 === e4.charCodeAt(e4.length - 1) && (t4 = true, e4 = e4.substring(0, e4.length - 1)), { name: e4.trim(), isClosed: t4 };
}
function L2(e4) {
if (e4.isClosed)
return "";
let t4 = p2("</");
return h2(">"), t4.replace(/&#([0-9]+);/g, function(e5, t5) {
return String.fromCodePoint(parseInt(t5, 10));
}).replace(/&#x([0-9a-f]+);/g, function(e5, t5) {
return String.fromCodePoint(parseInt(t5, 16));
}).replace(/&amp;|&lt;|&gt;|&quot;|&apos;/g, function(e5) {
switch (e5) {
case "&amp;":
return "&";
case "&lt;":
return "<";
case "&gt;":
return ">";
case "&quot;":
return '"';
case "&apos;":
return "'";
}
return e5;
});
}
for (; r2 < s && (l(), !(r2 >= s)); ) {
const a22 = e3.charCodeAt(r2);
if (c2(1), 60 !== a22)
return S2("expected <");
if (r2 >= s)
return S2("unexpected end of input");
const p22 = e3.charCodeAt(r2);
if (63 === p22) {
c2(1), h2("?>");
continue;
}
if (33 === p22) {
if (c2(1), u2("--")) {
h2("-->");
continue;
}
h2(">");
continue;
}
if (47 === p22) {
if (c2(1), l(), u2("plist")) {
h2(">");
continue;
}
if (u2("dict")) {
h2(">"), w2();
continue;
}
if (u2("array")) {
h2(">"), P2();
continue;
}
return S2("unexpected closed tag");
}
let g2 = E2();
switch (g2.name) {
case "dict":
1 === d2 ? k2() : 2 === d2 ? R3() : (f2 = {}, null !== n22 && (f2[n22] = { filename: t3, line: i2, char: o }), b3(1, f2)), g2.isClosed && w2();
continue;
case "array":
1 === d2 ? C2() : 2 === d2 ? A2() : (f2 = [], b3(2, f2)), g2.isClosed && P2();
continue;
case "key":
M2 = L2(g2), 1 !== d2 ? S2("unexpected <key>") : null !== _2 ? S2("too many <key>") : _2 = M2;
continue;
case "string":
I2(L2(g2));
continue;
case "real":
v2(parseFloat(L2(g2)));
continue;
case "integer":
N3(parseInt(L2(g2), 10));
continue;
case "date":
T2(new Date(L2(g2)));
continue;
case "data":
x2(L2(g2));
continue;
case "true":
L2(g2), G2(true);
continue;
case "false":
L2(g2), G2(false);
continue;
}
if (!/^plist/.test(g2.name))
return S2("unexpected opened tag " + g2.name);
}
var M2;
return f2;
}
Object.defineProperty(t22, "__esModule", { value: true }), t22.parsePLIST = t22.parseWithLocation = void 0, t22.parseWithLocation = function(e3, t3, s) {
return n2(e3, t3, s);
}, t22.parsePLIST = function(e3) {
return n2(e3, null, null);
};
}, 652: (e22, t22, n2) => {
Object.defineProperty(t22, "__esModule", { value: true }), t22.SyncRegistry = void 0;
const s = n2(391);
t22.SyncRegistry = class {
constructor(e3, t3) {
this._onigLibPromise = t3, this._grammars = /* @__PURE__ */ new Map(), this._rawGrammars = /* @__PURE__ */ new Map(), this._injectionGrammars = /* @__PURE__ */ new Map(), this._theme = e3;
}
dispose() {
for (const e3 of this._grammars.values())
e3.dispose();
}
setTheme(e3) {
this._theme = e3;
}
getColorMap() {
return this._theme.getColorMap();
}
addGrammar(e3, t3) {
this._rawGrammars.set(e3.scopeName, e3), t3 && this._injectionGrammars.set(e3.scopeName, t3);
}
lookup(e3) {
return this._rawGrammars.get(e3);
}
injections(e3) {
return this._injectionGrammars.get(e3);
}
getDefaults() {
return this._theme.getDefaults();
}
themeMatch(e3) {
return this._theme.match(e3);
}
async grammarForScopeName(e3, t3, n22, r2, i2) {
if (!this._grammars.has(e3)) {
let o = this._rawGrammars.get(e3);
if (!o)
return null;
this._grammars.set(e3, s.createGrammar(e3, o, t3, n22, r2, i2, this, await this._onigLibPromise));
}
return this._grammars.get(e3);
}
};
}, 792: (e22, t22, n2) => {
Object.defineProperty(t22, "__esModule", { value: true }), t22.CompiledRule = t22.RegExpSourceList = t22.RegExpSource = t22.RuleFactory = t22.BeginWhileRule = t22.BeginEndRule = t22.IncludeOnlyRule = t22.MatchRule = t22.CaptureRule = t22.Rule = t22.ruleIdToNumber = t22.ruleIdFromNumber = t22.whileRuleId = t22.endRuleId = void 0;
const s = n2(878), r2 = n2(965), i2 = /\\(\d+)/, o = /\\(\d+)/g;
t22.endRuleId = -1, t22.whileRuleId = -2, t22.ruleIdFromNumber = function(e3) {
return e3;
}, t22.ruleIdToNumber = function(e3) {
return e3;
};
class c2 {
constructor(e3, t3, n22, r22) {
this.$location = e3, this.id = t3, this._name = n22 || null, this._nameIsCapturing = s.RegexSource.hasCaptures(this._name), this._contentName = r22 || null, this._contentNameIsCapturing = s.RegexSource.hasCaptures(this._contentName);
}
get debugName() {
const e3 = this.$location ? `${s.basename(this.$location.filename)}:${this.$location.line}` : "unknown";
return `${this.constructor.name}#${this.id} @ ${e3}`;
}
getName(e3, t3) {
return this._nameIsCapturing && null !== this._name && null !== e3 && null !== t3 ? s.RegexSource.replaceCaptures(this._name, e3, t3) : this._name;
}
getContentName(e3, t3) {
return this._contentNameIsCapturing && null !== this._contentName ? s.RegexSource.replaceCaptures(this._contentName, e3, t3) : this._contentName;
}
}
t22.Rule = c2;
class a2 extends c2 {
constructor(e3, t3, n22, s2, r22) {
super(e3, t3, n22, s2), this.retokenizeCapturedWithRuleId = r22;
}
dispose() {
}
collectPatterns(e3, t3) {
throw new Error("Not supported!");
}
compile(e3, t3) {
throw new Error("Not supported!");
}
compileAG(e3, t3, n22, s2) {
throw new Error("Not supported!");
}
}
t22.CaptureRule = a2;
class l extends c2 {
constructor(e3, t3, n22, s2, r22) {
super(e3, t3, n22, null), this._match = new f2(s2, this.id), this.captures = r22, this._cachedCompiledPatterns = null;
}
dispose() {
this._cachedCompiledPatterns && (this._cachedCompiledPatterns.dispose(), this._cachedCompiledPatterns = null);
}
get debugMatchRegExp() {
return `${this._match.source}`;
}
collectPatterns(e3, t3) {
t3.push(this._match);
}
compile(e3, t3) {
return this._getCachedCompiledPatterns(e3).compile(e3);
}
compileAG(e3, t3, n22, s2) {
return this._getCachedCompiledPatterns(e3).compileAG(e3, n22, s2);
}
_getCachedCompiledPatterns(e3) {
return this._cachedCompiledPatterns || (this._cachedCompiledPatterns = new g(), this.collectPatterns(e3, this._cachedCompiledPatterns)), this._cachedCompiledPatterns;
}
}
t22.MatchRule = l;
class u2 extends c2 {
constructor(e3, t3, n22, s2, r22) {
super(e3, t3, n22, s2), this.patterns = r22.patterns, this.hasMissingPatterns = r22.hasMissingPatterns, this._cachedCompiledPatterns = null;
}
dispose() {
this._cachedCompiledPatterns && (this._cachedCompiledPatterns.dispose(), this._cachedCompiledPatterns = null);
}
collectPatterns(e3, t3) {
for (const n22 of this.patterns)
e3.getRule(n22).collectPatterns(e3, t3);
}
compile(e3, t3) {
return this._getCachedCompiledPatterns(e3).compile(e3);
}
compileAG(e3, t3, n22, s2) {
return this._getCachedCompiledPatterns(e3).compileAG(e3, n22, s2);
}
_getCachedCompiledPatterns(e3) {
return this._cachedCompiledPatterns || (this._cachedCompiledPatterns = new g(), this.collectPatterns(e3, this._cachedCompiledPatterns)), this._cachedCompiledPatterns;
}
}
t22.IncludeOnlyRule = u2;
class h2 extends c2 {
constructor(e3, t3, n22, s2, r22, i22, o2, c22, a22, l2) {
super(e3, t3, n22, s2), this._begin = new f2(r22, this.id), this.beginCaptures = i22, this._end = new f2(o2 || "￿", -1), this.endHasBackReferences = this._end.hasBackReferences, this.endCaptures = c22, this.applyEndPatternLast = a22 || false, this.patterns = l2.patterns, this.hasMissingPatterns = l2.hasMissingPatterns, this._cachedCompiledPatterns = null;
}
dispose() {
this._cachedCompiledPatterns && (this._cachedCompiledPatterns.dispose(), this._cachedCompiledPatterns = null);
}
get debugBeginRegExp() {
return `${this._begin.source}`;
}
get debugEndRegExp() {
return `${this._end.source}`;
}
getEndWithResolvedBackReferences(e3, t3) {
return this._end.resolveBackReferences(e3, t3);
}
collectPatterns(e3, t3) {
t3.push(this._begin);
}
compile(e3, t3) {
return this._getCachedCompiledPatterns(e3, t3).compile(e3);
}
compileAG(e3, t3, n22, s2) {
return this._getCachedCompiledPatterns(e3, t3).compileAG(e3, n22, s2);
}
_getCachedCompiledPatterns(e3, t3) {
if (!this._cachedCompiledPatterns) {
this._cachedCompiledPatterns = new g();
for (const t4 of this.patterns)
e3.getRule(t4).collectPatterns(e3, this._cachedCompiledPatterns);
this.applyEndPatternLast ? this._cachedCompiledPatterns.push(this._end.hasBackReferences ? this._end.clone() : this._end) : this._cachedCompiledPatterns.unshift(this._end.hasBackReferences ? this._end.clone() : this._end);
}
return this._end.hasBackReferences && (this.applyEndPatternLast ? this._cachedCompiledPatterns.setSource(this._cachedCompiledPatterns.length() - 1, t3) : this._cachedCompiledPatterns.setSource(0, t3)), this._cachedCompiledPatterns;
}
}
t22.BeginEndRule = h2;
class p2 extends c2 {
constructor(e3, n22, s2, r22, i22, o2, c22, a22, l2) {
super(e3, n22, s2, r22), this._begin = new f2(i22, this.id), this.beginCaptures = o2, this.whileCaptures = a22, this._while = new f2(c22, t22.whileRuleId), this.whileHasBackReferences = this._while.hasBackReferences, this.patterns = l2.patterns, this.hasMissingPatterns = l2.hasMissingPatterns, this._cachedCompiledPatterns = null, this._cachedCompiledWhilePatterns = null;
}
dispose() {
this._cachedCompiledPatterns && (this._cachedCompiledPatterns.dispose(), this._cachedCompiledPatterns = null), this._cachedCompiledWhilePatterns && (this._cachedCompiledWhilePatterns.dispose(), this._cachedCompiledWhilePatterns = null);
}
get debugBeginRegExp() {
return `${this._begin.source}`;
}
get debugWhileRegExp() {
return `${this._while.source}`;
}
getWhileWithResolvedBackReferences(e3, t3) {
return this._while.resolveBackReferences(e3, t3);
}
collectPatterns(e3, t3) {
t3.push(this._begin);
}
compile(e3, t3) {
return this._getCachedCompiledPatterns(e3).compile(e3);
}
compileAG(e3, t3, n22, s2) {
return this._getCachedCompiledPatterns(e3).compileAG(e3, n22, s2);
}
_getCachedCompiledPatterns(e3) {
if (!this._cachedCompiledPatterns) {
this._cachedCompiledPatterns = new g();
for (const t3 of this.patterns)
e3.getRule(t3).collectPatterns(e3, this._cachedCompiledPatterns);
}
return this._cachedCompiledPatterns;
}
compileWhile(e3, t3) {
return this._getCachedCompiledWhilePatterns(e3, t3).compile(e3);
}
compileWhileAG(e3, t3, n22, s2) {
return this._getCachedCompiledWhilePatterns(e3, t3).compileAG(e3, n22, s2);
}
_getCachedCompiledWhilePatterns(e3, t3) {
return this._cachedCompiledWhilePatterns || (this._cachedCompiledWhilePatterns = new g(), this._cachedCompiledWhilePatterns.push(this._while.hasBackReferences ? this._while.clone() : this._while)), this._while.hasBackReferences && this._cachedCompiledWhilePatterns.setSource(0, t3 || "￿"), this._cachedCompiledWhilePatterns;
}
}
t22.BeginWhileRule = p2;
class d2 {
static createCaptureRule(e3, t3, n22, s2, r22) {
return e3.registerRule((e4) => new a2(t3, e4, n22, s2, r22));
}
static getCompiledRuleId(e3, t3, n22) {
return e3.id || t3.registerRule((r22) => {
if (e3.id = r22, e3.match)
return new l(e3.$vscodeTextmateLocation, e3.id, e3.name, e3.match, d2._compileCaptures(e3.captures, t3, n22));
if (void 0 === e3.begin) {
e3.repository && (n22 = s.mergeObjects({}, n22, e3.repository));
let r3 = e3.patterns;
return void 0 === r3 && e3.include && (r3 = [{ include: e3.include }]), new u2(e3.$vscodeTextmateLocation, e3.id, e3.name, e3.contentName, d2._compilePatterns(r3, t3, n22));
}
return e3.while ? new p2(e3.$vscodeTextmateLocation, e3.id, e3.name, e3.contentName, e3.begin, d2._compileCaptures(e3.beginCaptures || e3.captures, t3, n22), e3.while, d2._compileCaptures(e3.whileCaptures || e3.captures, t3, n22), d2._compilePatterns(e3.patterns, t3, n22)) : new h2(e3.$vscodeTextmateLocation, e3.id, e3.name, e3.contentName, e3.begin, d2._compileCaptures(e3.beginCaptures || e3.captures, t3, n22), e3.end, d2._compileCaptures(e3.endCaptures || e3.captures, t3, n22), e3.applyEndPatternLast, d2._compilePatterns(e3.patterns, t3, n22));
}), e3.id;
}
static _compileCaptures(e3, t3, n22) {
let s2 = [];
if (e3) {
let r22 = 0;
for (const t4 in e3) {
if ("$vscodeTextmateLocation" === t4)
continue;
const e4 = parseInt(t4, 10);
e4 > r22 && (r22 = e4);
}
for (let e4 = 0; e4 <= r22; e4++)
s2[e4] = null;
for (const r3 in e3) {
if ("$vscodeTextmateLocation" === r3)
continue;
const i22 = parseInt(r3, 10);
let o2 = 0;
e3[r3].patterns && (o2 = d2.getCompiledRuleId(e3[r3], t3, n22)), s2[i22] = d2.createCaptureRule(t3, e3[r3].$vscodeTextmateLocation, e3[r3].name, e3[r3].contentName, o2);
}
}
return s2;
}
static _compilePatterns(e3, t3, n22) {
let s2 = [];
if (e3)
for (let i22 = 0, o2 = e3.length; i22 < o2; i22++) {
const o3 = e3[i22];
let c22 = -1;
if (o3.include) {
const e4 = r2.parseInclude(o3.include);
switch (e4.kind) {
case 0:
case 1:
c22 = d2.getCompiledRuleId(n22[o3.include], t3, n22);
break;
case 2:
let s3 = n22[e4.ruleName];
s3 && (c22 = d2.getCompiledRuleId(s3, t3, n22));
break;
case 3:
case 4:
const r22 = e4.scopeName, i3 = 4 === e4.kind ? e4.ruleName : null, a22 = t3.getExternalGrammar(r22, n22);
if (a22)
if (i3) {
let e5 = a22.repository[i3];
e5 && (c22 = d2.getCompiledRuleId(e5, t3, a22.repository));
} else
c22 = d2.getCompiledRuleId(a22.repository.$self, t3, a22.repository);
}
} else
c22 = d2.getCompiledRuleId(o3, t3, n22);
if (-1 !== c22) {
const e4 = t3.getRule(c22);
let n3 = false;
if ((e4 instanceof u2 || e4 instanceof h2 || e4 instanceof p2) && e4.hasMissingPatterns && 0 === e4.patterns.length && (n3 = true), n3)
continue;
s2.push(c22);
}
}
return { patterns: s2, hasMissingPatterns: (e3 ? e3.length : 0) !== s2.length };
}
}
t22.RuleFactory = d2;
class f2 {
constructor(e3, t3) {
if (e3) {
const t4 = e3.length;
let n22 = 0, s2 = [], r22 = false;
for (let i22 = 0; i22 < t4; i22++)
if ("\\" === e3.charAt(i22) && i22 + 1 < t4) {
const t5 = e3.charAt(i22 + 1);
"z" === t5 ? (s2.push(e3.substring(n22, i22)), s2.push("$(?!\\n)(?<!\\n)"), n22 = i22 + 2) : "A" !== t5 && "G" !== t5 || (r22 = true), i22++;
}
this.hasAnchor = r22, 0 === n22 ? this.source = e3 : (s2.push(e3.substring(n22, t4)), this.source = s2.join(""));
} else
this.hasAnchor = false, this.source = e3;
this.hasAnchor ? this._anchorCache = this._buildAnchorCache() : this._anchorCache = null, this.ruleId = t3, this.hasBackReferences = i2.test(this.source);
}
clone() {
return new f2(this.source, this.ruleId);
}
setSource(e3) {
this.source !== e3 && (this.source = e3, this.hasAnchor && (this._anchorCache = this._buildAnchorCache()));
}
resolveBackReferences(e3, t3) {
let n22 = t3.map((t4) => e3.substring(t4.start, t4.end));
return o.lastIndex = 0, this.source.replace(o, (e4, t4) => s.escapeRegExpCharacters(n22[parseInt(t4, 10)] || ""));
}
_buildAnchorCache() {
let e3, t3, n22, s2, r22 = [], i22 = [], o2 = [], c22 = [];
for (e3 = 0, t3 = this.source.length; e3 < t3; e3++)
n22 = this.source.charAt(e3), r22[e3] = n22, i22[e3] = n22, o2[e3] = n22, c22[e3] = n22, "\\" === n22 && e3 + 1 < t3 && (s2 = this.source.charAt(e3 + 1), "A" === s2 ? (r22[e3 + 1] = "￿", i22[e3 + 1] = "￿", o2[e3 + 1] = "A", c22[e3 + 1] = "A") : "G" === s2 ? (r22[e3 + 1] = "￿", i22[e3 + 1] = "G", o2[e3 + 1] = "￿", c22[e3 + 1] = "G") : (r22[e3 + 1] = s2, i22[e3 + 1] = s2, o2[e3 + 1] = s2, c22[e3 + 1] = s2), e3++);
return { A0_G0: r22.join(""), A0_G1: i22.join(""), A1_G0: o2.join(""), A1_G1: c22.join("") };
}
resolveAnchors(e3, t3) {
return this.hasAnchor && this._anchorCache ? e3 ? t3 ? this._anchorCache.A1_G1 : this._anchorCache.A1_G0 : t3 ? this._anchorCache.A0_G1 : this._anchorCache.A0_G0 : this.source;
}
}
t22.RegExpSource = f2;
class g {
constructor() {
this._items = [], this._hasAnchors = false, this._cached = null, this._anchorCache = { A0_G0: null, A0_G1: null, A1_G0: null, A1_G1: null };
}
dispose() {
this._disposeCaches();
}
_disposeCaches() {
this._cached && (this._cached.dispose(), this._cached = null), this._anchorCache.A0_G0 && (this._anchorCache.A0_G0.dispose(), this._anchorCache.A0_G0 = null), this._anchorCache.A0_G1 && (this._anchorCache.A0_G1.dispose(), this._anchorCache.A0_G1 = null), this._anchorCache.A1_G0 && (this._anchorCache.A1_G0.dispose(), this._anchorCache.A1_G0 = null), this._anchorCache.A1_G1 && (this._anchorCache.A1_G1.dispose(), this._anchorCache.A1_G1 = null);
}
push(e3) {
this._items.push(e3), this._hasAnchors = this._hasAnchors || e3.hasAnchor;
}
unshift(e3) {
this._items.unshift(e3), this._hasAnchors = this._hasAnchors || e3.hasAnchor;
}
length() {
return this._items.length;
}
setSource(e3, t3) {
this._items[e3].source !== t3 && (this._disposeCaches(), this._items[e3].setSource(t3));
}
compile(e3) {
if (!this._cached) {
let t3 = this._items.map((e4) => e4.source);
this._cached = new m(e3, t3, this._items.map((e4) => e4.ruleId));
}
return this._cached;
}
compileAG(e3, t3, n22) {
return this._hasAnchors ? t3 ? n22 ? (this._anchorCache.A1_G1 || (this._anchorCache.A1_G1 = this._resolveAnchors(e3, t3, n22)), this._anchorCache.A1_G1) : (this._anchorCache.A1_G0 || (this._anchorCache.A1_G0 = this._resolveAnchors(e3, t3, n22)), this._anchorCache.A1_G0) : n22 ? (this._anchorCache.A0_G1 || (this._anchorCache.A0_G1 = this._resolveAnchors(e3, t3, n22)), this._anchorCache.A0_G1) : (this._anchorCache.A0_G0 || (this._anchorCache.A0_G0 = this._resolveAnchors(e3, t3, n22)), this._anchorCache.A0_G0) : this.compile(e3);
}
_resolveAnchors(e3, t3, n22) {
let s2 = this._items.map((e4) => e4.resolveAnchors(t3, n22));
return new m(e3, s2, this._items.map((e4) => e4.ruleId));
}
}
t22.RegExpSourceList = g;
class m {
constructor(e3, t3, n22) {
this.regExps = t3, this.rules = n22, this.scanner = e3.createOnigScanner(t3);
}
dispose() {
"function" == typeof this.scanner.dispose && this.scanner.dispose();
}
toString() {
const e3 = [];
for (let t3 = 0, n22 = this.rules.length; t3 < n22; t3++)
e3.push(" - " + this.rules[t3] + ": " + this.regExps[t3]);
return e3.join("\n");
}
findNextMatchSync(e3, t3, n22) {
const s2 = this.scanner.findNextMatchSync(e3, t3, n22);
return s2 ? { ruleId: this.rules[s2.index], captureIndices: s2.captureIndices } : null;
}
}
t22.CompiledRule = m;
}, 583: (e22, t22, n2) => {
Object.defineProperty(t22, "__esModule", { value: true }), t22.ThemeTrieElement = t22.ThemeTrieElementRule = t22.ColorMap = t22.fontStyleToString = t22.ParsedThemeRule = t22.parseTheme = t22.StyleAttributes = t22.ScopeStack = t22.Theme = void 0;
const s = n2(878);
class r2 {
constructor(e3, t3, n22) {
this._colorMap = e3, this._defaults = t3, this._root = n22, this._cachedMatchRoot = new s.CachedFn((e4) => this._root.match(e4));
}
static createFromRawTheme(e3, t3) {
return this.createFromParsedTheme(a2(e3), t3);
}
static createFromParsedTheme(e3, t3) {
return function(e4, t4) {
e4.sort((e5, t5) => {
let n3 = s.strcmp(e5.scope, t5.scope);
return 0 !== n3 ? n3 : (n3 = s.strArrCmp(e5.parentScopes, t5.parentScopes), 0 !== n3 ? n3 : e5.index - t5.index);
});
let n22 = 0, i22 = "#000000", o2 = "#ffffff";
for (; e4.length >= 1 && "" === e4[0].scope; ) {
let t5 = e4.shift();
-1 !== t5.fontStyle && (n22 = t5.fontStyle), null !== t5.foreground && (i22 = t5.foreground), null !== t5.background && (o2 = t5.background);
}
let a22 = new u2(t4), l2 = new c2(n22, a22.getId(i22), a22.getId(o2)), d2 = new p2(new h2(0, null, -1, 0, 0), []);
for (let t5 = 0, n3 = e4.length; t5 < n3; t5++) {
let n4 = e4[t5];
d2.insert(0, n4.scope, n4.parentScopes, n4.fontStyle, a22.getId(n4.foreground), a22.getId(n4.background));
}
return new r2(a22, l2, d2);
}(e3, t3);
}
getColorMap() {
return this._colorMap.getColorMap();
}
getDefaults() {
return this._defaults;
}
match(e3) {
if (null === e3)
return this._defaults;
const t3 = e3.scopeName, n22 = this._cachedMatchRoot.get(t3).find((t4) => function(e4, t5) {
if (null === t5)
return true;
let n3 = 0, s2 = t5[n3];
for (; e4; ) {
if (o(e4.scopeName, s2)) {
if (n3++, n3 === t5.length)
return true;
s2 = t5[n3];
}
e4 = e4.parent;
}
return false;
}(e3.parent, t4.parentScopes));
return n22 ? new c2(n22.fontStyle, n22.foreground, n22.background) : null;
}
}
t22.Theme = r2;
class i2 {
constructor(e3, t3) {
this.parent = e3, this.scopeName = t3;
}
static from(...e3) {
let t3 = null;
for (let n22 = 0; n22 < e3.length; n22++)
t3 = new i2(t3, e3[n22]);
return t3;
}
push(e3) {
return new i2(this, e3);
}
getSegments() {
let e3 = this;
const t3 = [];
for (; e3; )
t3.push(e3.scopeName), e3 = e3.parent;
return t3.reverse(), t3;
}
toString() {
return this.getSegments().join(" ");
}
}
function o(e3, t3) {
return t3 === e3 || e3.startsWith(t3) && "." === e3[t3.length];
}
t22.ScopeStack = i2;
class c2 {
constructor(e3, t3, n22) {
this.fontStyle = e3, this.foregroundId = t3, this.backgroundId = n22;
}
}
function a2(e3) {
if (!e3)
return [];
if (!e3.settings || !Array.isArray(e3.settings))
return [];
let t3 = e3.settings, n22 = [], r22 = 0;
for (let e4 = 0, i22 = t3.length; e4 < i22; e4++) {
let i3, o2 = t3[e4];
if (!o2.settings)
continue;
if ("string" == typeof o2.scope) {
let e5 = o2.scope;
e5 = e5.replace(/^[,]+/, ""), e5 = e5.replace(/[,]+$/, ""), i3 = e5.split(",");
} else
i3 = Array.isArray(o2.scope) ? o2.scope : [""];
let c22 = -1;
if ("string" == typeof o2.settings.fontStyle) {
c22 = 0;
let e5 = o2.settings.fontStyle.split(" ");
for (let t4 = 0, n3 = e5.length; t4 < n3; t4++)
switch (e5[t4]) {
case "italic":
c22 |= 1;
break;
case "bold":
c22 |= 2;
break;
case "underline":
c22 |= 4;
break;
case "strikethrough":
c22 |= 8;
}
}
let a22 = null;
"string" == typeof o2.settings.foreground && s.isValidHexColor(o2.settings.foreground) && (a22 = o2.settings.foreground);
let u22 = null;
"string" == typeof o2.settings.background && s.isValidHexColor(o2.settings.background) && (u22 = o2.settings.background);
for (let t4 = 0, s2 = i3.length; t4 < s2; t4++) {
let s3 = i3[t4].trim().split(" "), o3 = s3[s3.length - 1], h22 = null;
s3.length > 1 && (h22 = s3.slice(0, s3.length - 1), h22.reverse()), n22[r22++] = new l(o3, h22, e4, c22, a22, u22);
}
}
return n22;
}
t22.StyleAttributes = c2, t22.parseTheme = a2;
class l {
constructor(e3, t3, n22, s2, r22, i22) {
this.scope = e3, this.parentScopes = t3, this.index = n22, this.fontStyle = s2, this.foreground = r22, this.background = i22;
}
}
t22.ParsedThemeRule = l, t22.fontStyleToString = function(e3) {
if (-1 === e3)
return "not set";
let t3 = "";
return 1 & e3 && (t3 += "italic "), 2 & e3 && (t3 += "bold "), 4 & e3 && (t3 += "underline "), 8 & e3 && (t3 += "strikethrough "), "" === t3 && (t3 = "none"), t3.trim();
};
class u2 {
constructor(e3) {
if (this._lastColorId = 0, this._id2color = [], this._color2id = /* @__PURE__ */ Object.create(null), Array.isArray(e3)) {
this._isFrozen = true;
for (let t3 = 0, n22 = e3.length; t3 < n22; t3++)
this._color2id[e3[t3]] = t3, this._id2color[t3] = e3[t3];
} else
this._isFrozen = false;
}
getId(e3) {
if (null === e3)
return 0;
e3 = e3.toUpperCase();
let t3 = this._color2id[e3];
if (t3)
return t3;
if (this._isFrozen)
throw new Error(`Missing color in color map - ${e3}`);
return t3 = ++this._lastColorId, this._color2id[e3] = t3, this._id2color[t3] = e3, t3;
}
getColorMap() {
return this._id2color.slice(0);
}
}
t22.ColorMap = u2;
class h2 {
constructor(e3, t3, n22, s2, r22) {
this.scopeDepth = e3, this.parentScopes = t3, this.fontStyle = n22, this.foreground = s2, this.background = r22;
}
clone() {
return new h2(this.scopeDepth, this.parentScopes, this.fontStyle, this.foreground, this.background);
}
static cloneArr(e3) {
let t3 = [];
for (let n22 = 0, s2 = e3.length; n22 < s2; n22++)
t3[n22] = e3[n22].clone();
return t3;
}
acceptOverwrite(e3, t3, n22, s2) {
this.scopeDepth > e3 ? console.log("how did this happen?") : this.scopeDepth = e3, -1 !== t3 && (this.fontStyle = t3), 0 !== n22 && (this.foreground = n22), 0 !== s2 && (this.background = s2);
}
}
t22.ThemeTrieElementRule = h2;
class p2 {
constructor(e3, t3 = [], n22 = {}) {
this._mainRule = e3, this._children = n22, this._rulesWithParentScopes = t3;
}
static _sortBySpecificity(e3) {
return 1 === e3.length || e3.sort(this._cmpBySpecificity), e3;
}
static _cmpBySpecificity(e3, t3) {
if (e3.scopeDepth === t3.scopeDepth) {
const n22 = e3.parentScopes, s2 = t3.parentScopes;
let r22 = null === n22 ? 0 : n22.length, i22 = null === s2 ? 0 : s2.length;
if (r22 === i22)
for (let e4 = 0; e4 < r22; e4++) {
const t4 = n22[e4].length, r3 = s2[e4].length;
if (t4 !== r3)
return r3 - t4;
}
return i22 - r22;
}
return t3.scopeDepth - e3.scopeDepth;
}
match(e3) {
if ("" === e3)
return p2._sortBySpecificity([].concat(this._mainRule).concat(this._rulesWithParentScopes));
let t3, n22, s2 = e3.indexOf(".");
return -1 === s2 ? (t3 = e3, n22 = "") : (t3 = e3.substring(0, s2), n22 = e3.substring(s2 + 1)), this._children.hasOwnProperty(t3) ? this._children[t3].match(n22) : p2._sortBySpecificity([].concat(this._mainRule).concat(this._rulesWithParentScopes));
}
insert(e3, t3, n22, s2, r22, i22) {
if ("" === t3)
return void this._doInsertHere(e3, n22, s2, r22, i22);
let o2, c22, a22, l2 = t3.indexOf(".");
-1 === l2 ? (o2 = t3, c22 = "") : (o2 = t3.substring(0, l2), c22 = t3.substring(l2 + 1)), this._children.hasOwnProperty(o2) ? a22 = this._children[o2] : (a22 = new p2(this._mainRule.clone(), h2.cloneArr(this._rulesWithParentScopes)), this._children[o2] = a22), a22.insert(e3 + 1, c22, n22, s2, r22, i22);
}
_doInsertHere(e3, t3, n22, r22, i22) {
if (null !== t3) {
for (let o2 = 0, c22 = this._rulesWithParentScopes.length; o2 < c22; o2++) {
let c3 = this._rulesWithParentScopes[o2];
if (0 === s.strArrCmp(c3.parentScopes, t3))
return void c3.acceptOverwrite(e3, n22, r22, i22);
}
-1 === n22 && (n22 = this._mainRule.fontStyle), 0 === r22 && (r22 = this._mainRule.foreground), 0 === i22 && (i22 = this._mainRule.background), this._rulesWithParentScopes.push(new h2(e3, t3, n22, r22, i22));
} else
this._mainRule.acceptOverwrite(e3, n22, r22, i22);
}
}
t22.ThemeTrieElement = p2;
}, 878: (e22, t22) => {
function n2(e3) {
return Array.isArray(e3) ? function(e4) {
let t3 = [];
for (let s2 = 0, r22 = e4.length; s2 < r22; s2++)
t3[s2] = n2(e4[s2]);
return t3;
}(e3) : "object" == typeof e3 ? function(e4) {
let t3 = {};
for (let s2 in e4)
t3[s2] = n2(e4[s2]);
return t3;
}(e3) : e3;
}
Object.defineProperty(t22, "__esModule", { value: true }), t22.performanceNow = t22.CachedFn = t22.escapeRegExpCharacters = t22.isValidHexColor = t22.strArrCmp = t22.strcmp = t22.RegexSource = t22.basename = t22.mergeObjects = t22.clone = void 0, t22.clone = function(e3) {
return n2(e3);
}, t22.mergeObjects = function(e3, ...t3) {
return t3.forEach((t4) => {
for (let n22 in t4)
e3[n22] = t4[n22];
}), e3;
}, t22.basename = function e3(t3) {
const n22 = ~t3.lastIndexOf("/") || ~t3.lastIndexOf("\\");
return 0 === n22 ? t3 : ~n22 == t3.length - 1 ? e3(t3.substring(0, t3.length - 1)) : t3.substr(1 + ~n22);
};
let s = /\$(\d+)|\${(\d+):\/(downcase|upcase)}/g;
function r2(e3, t3) {
return e3 < t3 ? -1 : e3 > t3 ? 1 : 0;
}
t22.RegexSource = class {
static hasCaptures(e3) {
return null !== e3 && (s.lastIndex = 0, s.test(e3));
}
static replaceCaptures(e3, t3, n22) {
return e3.replace(s, (e4, s2, r22, i2) => {
let o = n22[parseInt(s2 || r22, 10)];
if (!o)
return e4;
{
let e5 = t3.substring(o.start, o.end);
for (; "." === e5[0]; )
e5 = e5.substring(1);
switch (i2) {
case "downcase":
return e5.toLowerCase();
case "upcase":
return e5.toUpperCase();
default:
return e5;
}
}
});
}
}, t22.strcmp = r2, t22.strArrCmp = function(e3, t3) {
if (null === e3 && null === t3)
return 0;
if (!e3)
return -1;
if (!t3)
return 1;
let n22 = e3.length, s2 = t3.length;
if (n22 === s2) {
for (let s3 = 0; s3 < n22; s3++) {
let n3 = r2(e3[s3], t3[s3]);
if (0 !== n3)
return n3;
}
return 0;
}
return n22 - s2;
}, t22.isValidHexColor = function(e3) {
return !!(/^#[0-9a-f]{6}$/i.test(e3) || /^#[0-9a-f]{8}$/i.test(e3) || /^#[0-9a-f]{3}$/i.test(e3) || /^#[0-9a-f]{4}$/i.test(e3));
}, t22.escapeRegExpCharacters = function(e3) {
return e3.replace(/[\-\\\{\}\*\+\?\|\^\$\.\,\[\]\(\)\#\s]/g, "\\$&");
}, t22.CachedFn = class {
constructor(e3) {
this.fn = e3, this.cache = /* @__PURE__ */ new Map();
}
get(e3) {
if (this.cache.has(e3))
return this.cache.get(e3);
const t3 = this.fn(e3);
return this.cache.set(e3, t3), t3;
}
}, t22.performanceNow = "undefined" == typeof performance ? function() {
return Date.now();
} : function() {
return performance.now();
};
} }, t2 = {};
return function n2(s) {
var r2 = t2[s];
if (void 0 !== r2)
return r2.exports;
var i2 = t2[s] = { exports: {} };
return e2[s].call(i2.exports, i2, i2.exports, n2), i2.exports;
}(787);
})();
});
})(main);
const languages = [
{
id: "abap",
scopeName: "source.abap",
path: "abap.tmLanguage.json",
samplePath: "abap.sample"
},
{
id: "actionscript-3",
scopeName: "source.actionscript.3",
path: "actionscript-3.tmLanguage.json",
samplePath: "actionscript-3.sample"
},
{
id: "ada",
scopeName: "source.ada",
path: "ada.tmLanguage.json",
samplePath: "ada.sample"
},
{
id: "apache",
scopeName: "source.apacheconf",
path: "apache.tmLanguage.json"
},
{
id: "apex",
scopeName: "source.apex",
path: "apex.tmLanguage.json",
samplePath: "apex.sample"
},
{
id: "apl",
scopeName: "source.apl",
path: "apl.tmLanguage.json",
embeddedLangs: ["html", "xml", "css", "javascript", "json"]
},
{
id: "applescript",
scopeName: "source.applescript",
path: "applescript.tmLanguage.json",
samplePath: "applescript.sample"
},
{
id: "asm",
scopeName: "source.asm.x86_64",
path: "asm.tmLanguage.json",
samplePath: "asm.sample"
},
{
id: "astro",
scopeName: "source.astro",
path: "astro.tmLanguage.json",
samplePath: "astro.sample",
embeddedLangs: ["json", "javascript", "typescript", "tsx", "css", "less", "sass", "scss", "stylus"]
},
{
id: "awk",
scopeName: "source.awk",
path: "awk.tmLanguage.json",
samplePath: "awk.sample"
},
{
id: "ballerina",
scopeName: "source.ballerina",
path: "ballerina.tmLanguage.json",
samplePath: "ballerina.sample"
},
{
id: "bat",
scopeName: "source.batchfile",
path: "bat.tmLanguage.json",
samplePath: "bat.sample",
aliases: ["batch"]
},
{
id: "berry",
scopeName: "source.berry",
path: "berry.tmLanguage.json",
samplePath: "berry.sample",
aliases: ["be"]
},
{
id: "bibtex",
scopeName: "text.bibtex",
path: "bibtex.tmLanguage.json"
},
{
id: "bicep",
scopeName: "source.bicep",
path: "bicep.tmLanguage.json",
samplePath: "bicep.sample"
},
{
id: "blade",
scopeName: "text.html.php.blade",
path: "blade.tmLanguage.json",
samplePath: "blade.sample",
embeddedLangs: ["html", "xml", "sql", "javascript", "json", "css"]
},
{
id: "c",
scopeName: "source.c",
path: "c.tmLanguage.json",
samplePath: "c.sample"
},
{
id: "cadence",
scopeName: "source.cadence",
path: "cadence.tmLanguage.json",
samplePath: "cadence.sample",
aliases: ["cdc"]
},
{
id: "clarity",
scopeName: "source.clar",
path: "clarity.tmLanguage.json",
samplePath: "clarity.sample"
},
{
id: "clojure",
scopeName: "source.clojure",
path: "clojure.tmLanguage.json",
samplePath: "clojure.sample",
aliases: ["clj"]
},
{
id: "cmake",
scopeName: "source.cmake",
path: "cmake.tmLanguage.json",
samplePath: "cmake.sample"
},
{
id: "cobol",
scopeName: "source.cobol",
path: "cobol.tmLanguage.json",
samplePath: "cobol.sample",
embeddedLangs: ["sql", "html", "java"]
},
{
id: "codeql",
scopeName: "source.ql",
path: "codeql.tmLanguage.json",
samplePath: "codeql.sample",
aliases: ["ql"],
embeddedLangs: ["markdown"]
},
{
id: "coffee",
scopeName: "source.coffee",
path: "coffee.tmLanguage.json",
samplePath: "coffee.sample",
embeddedLangs: ["javascript"]
},
{
id: "cpp",
scopeName: "source.cpp",
path: "cpp.tmLanguage.json",
samplePath: "cpp.sample",
embeddedLangs: ["glsl", "sql"]
},
{
id: "crystal",
scopeName: "source.crystal",
path: "crystal.tmLanguage.json",
samplePath: "crystal.sample",
embeddedLangs: ["html", "sql", "css", "c", "javascript", "shellscript"]
},
{
id: "csharp",
scopeName: "source.cs",
path: "csharp.tmLanguage.json",
samplePath: "csharp.sample",
aliases: ["c#", "cs"]
},
{
id: "css",
scopeName: "source.css",
path: "css.tmLanguage.json",
samplePath: "css.sample"
},
{
id: "cue",
scopeName: "source.cue",
path: "cue.tmLanguage.json",
samplePath: "cue.sample"
},
{
id: "d",
scopeName: "source.d",
path: "d.tmLanguage.json",
samplePath: "d.sample"
},
{
id: "dart",
scopeName: "source.dart",
path: "dart.tmLanguage.json",
samplePath: "dart.sample"
},
{
id: "diff",
scopeName: "source.diff",
path: "diff.tmLanguage.json",
samplePath: "diff.sample"
},
{
id: "docker",
scopeName: "source.dockerfile",
path: "docker.tmLanguage.json",
samplePath: "docker.sample"
},
{
id: "dream-maker",
scopeName: "source.dm",
path: "dream-maker.tmLanguage.json"
},
{
id: "elixir",
scopeName: "source.elixir",
path: "elixir.tmLanguage.json",
samplePath: "elixir.sample",
embeddedLangs: ["html"]
},
{
id: "elm",
scopeName: "source.elm",
path: "elm.tmLanguage.json",
samplePath: "elm.sample",
embeddedLangs: ["glsl"]
},
{
id: "erb",
scopeName: "text.html.erb",
path: "erb.tmLanguage.json",
samplePath: "erb.sample",
embeddedLangs: ["html", "ruby"]
},
{
id: "erlang",
scopeName: "source.erlang",
path: "erlang.tmLanguage.json",
samplePath: "erlang.sample",
aliases: ["erl"]
},
{
id: "fish",
scopeName: "source.fish",
path: "fish.tmLanguage.json",
samplePath: "fish.sample"
},
{
id: "fsharp",
scopeName: "source.fsharp",
path: "fsharp.tmLanguage.json",
samplePath: "fsharp.sample",
aliases: ["f#", "fs"],
embeddedLangs: ["markdown"]
},
{
id: "gherkin",
scopeName: "text.gherkin.feature",
path: "gherkin.tmLanguage.json"
},
{
id: "git-commit",
scopeName: "text.git-commit",
path: "git-commit.tmLanguage.json",
embeddedLangs: ["diff"]
},
{
id: "git-rebase",
scopeName: "text.git-rebase",
path: "git-rebase.tmLanguage.json",
embeddedLangs: ["shellscript"]
},
{
id: "glsl",
scopeName: "source.glsl",
path: "glsl.tmLanguage.json",
samplePath: "glsl.sample",
embeddedLangs: ["c"]
},
{
id: "gnuplot",
scopeName: "source.gnuplot",
path: "gnuplot.tmLanguage.json"
},
{
id: "go",
scopeName: "source.go",
path: "go.tmLanguage.json",
samplePath: "go.sample"
},
{
id: "graphql",
scopeName: "source.graphql",
path: "graphql.tmLanguage.json",
embeddedLangs: ["javascript", "typescript", "jsx", "tsx"]
},
{
id: "groovy",
scopeName: "source.groovy",
path: "groovy.tmLanguage.json"
},
{
id: "hack",
scopeName: "source.hack",
path: "hack.tmLanguage.json",
embeddedLangs: ["html", "sql"]
},
{
id: "haml",
scopeName: "text.haml",
path: "haml.tmLanguage.json",
embeddedLangs: ["ruby", "javascript", "sass", "coffee", "markdown", "css"]
},
{
id: "handlebars",
scopeName: "text.html.handlebars",
path: "handlebars.tmLanguage.json",
aliases: ["hbs"],
embeddedLangs: ["html", "css", "javascript", "yaml"]
},
{
id: "haskell",
scopeName: "source.haskell",
path: "haskell.tmLanguage.json",
aliases: ["hs"]
},
{
id: "hcl",
scopeName: "source.hcl",
path: "hcl.tmLanguage.json",
samplePath: "hcl.sample"
},
{
id: "hlsl",
scopeName: "source.hlsl",
path: "hlsl.tmLanguage.json"
},
{
id: "html",
scopeName: "text.html.basic",
path: "html.tmLanguage.json",
samplePath: "html.sample",
embeddedLangs: ["javascript", "css"]
},
{
id: "imba",
scopeName: "source.imba",
path: "imba.tmLanguage.json",
samplePath: "imba.sample"
},
{
id: "ini",
scopeName: "source.ini",
path: "ini.tmLanguage.json"
},
{
id: "java",
scopeName: "source.java",
path: "java.tmLanguage.json",
samplePath: "java.sample"
},
{
id: "javascript",
scopeName: "source.js",
path: "javascript.tmLanguage.json",
samplePath: "javascript.sample",
aliases: ["js"]
},
{
id: "jinja-html",
scopeName: "text.html.jinja",
path: "jinja-html.tmLanguage.json",
embeddedLangs: ["html"]
},
{
id: "json",
scopeName: "source.json",
path: "json.tmLanguage.json"
},
{
id: "json5",
scopeName: "source.json5",
path: "json5.tmLanguage.json",
samplePath: "json5.sample"
},
{
id: "jsonc",
scopeName: "source.json.comments",
path: "jsonc.tmLanguage.json"
},
{
id: "jsonnet",
scopeName: "source.jsonnet",
path: "jsonnet.tmLanguage.json"
},
{
id: "jssm",
scopeName: "source.jssm",
path: "jssm.tmLanguage.json",
samplePath: "jssm.sample",
aliases: ["fsl"]
},
{
id: "jsx",
scopeName: "source.js.jsx",
path: "jsx.tmLanguage.json"
},
{
id: "julia",
scopeName: "source.julia",
path: "julia.tmLanguage.json",
embeddedLangs: ["cpp", "python", "javascript", "r", "sql"]
},
{
id: "kotlin",
scopeName: "source.kotlin",
path: "kotlin.tmLanguage.json"
},
{
id: "latex",
scopeName: "text.tex.latex",
path: "latex.tmLanguage.json",
embeddedLangs: ["tex", "css", "haskell", "html", "xml", "java", "lua", "julia", "ruby", "javascript", "typescript", "python", "yaml", "rust", "scala", "gnuplot"]
},
{
id: "less",
scopeName: "source.css.less",
path: "less.tmLanguage.json",
embeddedLangs: ["css"]
},
{
id: "liquid",
scopeName: "text.html.liquid",
path: "liquid.tmLanguage.json",
samplePath: "liquid.sample",
embeddedLangs: ["html", "css", "json", "javascript"]
},
{
id: "lisp",
scopeName: "source.lisp",
path: "lisp.tmLanguage.json"
},
{
id: "logo",
scopeName: "source.logo",
path: "logo.tmLanguage.json"
},
{
id: "lua",
scopeName: "source.lua",
path: "lua.tmLanguage.json",
embeddedLangs: ["c"]
},
{
id: "make",
scopeName: "source.makefile",
path: "make.tmLanguage.json",
aliases: ["makefile"]
},
{
id: "markdown",
scopeName: "text.html.markdown",
path: "markdown.tmLanguage.json",
aliases: ["md"],
embeddedLangs: ["css", "html", "ini", "java", "lua", "make", "perl", "r", "ruby", "php", "sql", "vb", "xml", "xsl", "yaml", "bat", "clojure", "coffee", "c", "cpp", "diff", "docker", "git-commit", "git-rebase", "go", "groovy", "pug", "javascript", "json", "jsonc", "less", "objective-c", "swift", "scss", "raku", "powershell", "python", "julia", "rust", "scala", "shellscript", "typescript", "tsx", "csharp", "fsharp", "dart", "handlebars", "erlang", "elixir", "latex", "bibtex"]
},
{
id: "marko",
scopeName: "text.marko",
path: "marko.tmLanguage.json",
embeddedLangs: ["css", "less", "scss", "typescript"]
},
{
id: "matlab",
scopeName: "source.matlab",
path: "matlab.tmLanguage.json"
},
{
id: "mdx",
scopeName: "text.html.markdown.jsx",
path: "mdx.tmLanguage.json",
embeddedLangs: ["jsx", "markdown"]
},
{
id: "mermaid",
scopeName: "source.mermaid",
path: "mermaid.tmLanguage.json"
},
{
id: "nginx",
scopeName: "source.nginx",
path: "nginx.tmLanguage.json",
embeddedLangs: ["lua"]
},
{
id: "nim",
scopeName: "source.nim",
path: "nim.tmLanguage.json",
embeddedLangs: ["c", "html", "xml", "javascript", "css", "glsl", "markdown"]
},
{
id: "nix",
scopeName: "source.nix",
path: "nix.tmLanguage.json"
},
{
id: "objective-c",
scopeName: "source.objc",
path: "objective-c.tmLanguage.json",
aliases: ["objc"]
},
{
id: "objective-cpp",
scopeName: "source.objcpp",
path: "objective-cpp.tmLanguage.json"
},
{
id: "ocaml",
scopeName: "source.ocaml",
path: "ocaml.tmLanguage.json"
},
{
id: "pascal",
scopeName: "source.pascal",
path: "pascal.tmLanguage.json"
},
{
id: "perl",
scopeName: "source.perl",
path: "perl.tmLanguage.json",
embeddedLangs: ["html", "xml", "css", "javascript", "sql"]
},
{
id: "php",
scopeName: "source.php",
path: "php.tmLanguage.json",
embeddedLangs: ["html", "xml", "sql", "javascript", "json", "css"]
},
{
id: "plsql",
scopeName: "source.plsql.oracle",
path: "plsql.tmLanguage.json"
},
{
id: "postcss",
scopeName: "source.css.postcss",
path: "postcss.tmLanguage.json"
},
{
id: "powershell",
scopeName: "source.powershell",
path: "powershell.tmLanguage.json",
aliases: ["ps", "ps1"]
},
{
id: "prisma",
scopeName: "source.prisma",
path: "prisma.tmLanguage.json",
samplePath: "prisma.sample"
},
{
id: "prolog",
scopeName: "source.prolog",
path: "prolog.tmLanguage.json"
},
{
id: "proto",
scopeName: "source.proto",
path: "proto.tmLanguage.json",
samplePath: "proto.sample"
},
{
id: "pug",
scopeName: "text.pug",
path: "pug.tmLanguage.json",
aliases: ["jade"],
embeddedLangs: ["javascript", "css", "sass", "scss", "stylus", "coffee", "html"]
},
{
id: "puppet",
scopeName: "source.puppet",
path: "puppet.tmLanguage.json"
},
{
id: "purescript",
scopeName: "source.purescript",
path: "purescript.tmLanguage.json"
},
{
id: "python",
scopeName: "source.python",
path: "python.tmLanguage.json",
samplePath: "python.sample",
aliases: ["py"]
},
{
id: "r",
scopeName: "source.r",
path: "r.tmLanguage.json"
},
{
id: "raku",
scopeName: "source.perl.6",
path: "raku.tmLanguage.json",
aliases: ["perl6"]
},
{
id: "razor",
scopeName: "text.aspnetcorerazor",
path: "razor.tmLanguage.json",
embeddedLangs: ["html", "csharp"]
},
{
id: "rel",
scopeName: "source.rel",
path: "rel.tmLanguage.json",
samplePath: "rel.sample"
},
{
id: "riscv",
scopeName: "source.riscv",
path: "riscv.tmLanguage.json"
},
{
id: "rst",
scopeName: "source.rst",
path: "rst.tmLanguage.json",
embeddedLangs: ["cpp", "python", "javascript", "shellscript", "yaml", "cmake", "ruby"]
},
{
id: "ruby",
scopeName: "source.ruby",
path: "ruby.tmLanguage.json",
samplePath: "ruby.sample",
aliases: ["rb"],
embeddedLangs: ["html", "xml", "sql", "css", "c", "javascript", "shellscript", "lua"]
},
{
id: "rust",
scopeName: "source.rust",
path: "rust.tmLanguage.json",
aliases: ["rs"]
},
{
id: "sas",
scopeName: "source.sas",
path: "sas.tmLanguage.json",
embeddedLangs: ["sql"]
},
{
id: "sass",
scopeName: "source.sass",
path: "sass.tmLanguage.json"
},
{
id: "scala",
scopeName: "source.scala",
path: "scala.tmLanguage.json"
},
{
id: "scheme",
scopeName: "source.scheme",
path: "scheme.tmLanguage.json"
},
{
id: "scss",
scopeName: "source.css.scss",
path: "scss.tmLanguage.json",
embeddedLangs: ["css"]
},
{
id: "shaderlab",
scopeName: "source.shaderlab",
path: "shaderlab.tmLanguage.json",
aliases: ["shader"],
embeddedLangs: ["hlsl"]
},
{
id: "shellscript",
scopeName: "source.shell",
path: "shellscript.tmLanguage.json",
aliases: ["shell", "bash", "sh", "zsh"]
},
{
id: "smalltalk",
scopeName: "source.smalltalk",
path: "smalltalk.tmLanguage.json"
},
{
id: "solidity",
scopeName: "source.solidity",
path: "solidity.tmLanguage.json"
},
{
id: "sparql",
scopeName: "source.sparql",
path: "sparql.tmLanguage.json",
samplePath: "sparql.sample",
embeddedLangs: ["turtle"]
},
{
id: "sql",
scopeName: "source.sql",
path: "sql.tmLanguage.json"
},
{
id: "ssh-config",
scopeName: "source.ssh-config",
path: "ssh-config.tmLanguage.json"
},
{
id: "stata",
scopeName: "source.stata",
path: "stata.tmLanguage.json",
samplePath: "stata.sample",
embeddedLangs: ["sql"]
},
{
id: "stylus",
scopeName: "source.stylus",
path: "stylus.tmLanguage.json",
aliases: ["styl"]
},
{
id: "svelte",
scopeName: "source.svelte",
path: "svelte.tmLanguage.json",
embeddedLangs: ["javascript", "typescript", "coffee", "stylus", "sass", "css", "scss", "less", "postcss", "pug", "markdown"]
},
{
id: "swift",
scopeName: "source.swift",
path: "swift.tmLanguage.json"
},
{
id: "system-verilog",
scopeName: "source.systemverilog",
path: "system-verilog.tmLanguage.json"
},
{
id: "tasl",
scopeName: "source.tasl",
path: "tasl.tmLanguage.json",
samplePath: "tasl.sample"
},
{
id: "tcl",
scopeName: "source.tcl",
path: "tcl.tmLanguage.json"
},
{
id: "tex",
scopeName: "text.tex",
path: "tex.tmLanguage.json",
embeddedLangs: ["r"]
},
{
id: "toml",
scopeName: "source.toml",
path: "toml.tmLanguage.json"
},
{
id: "tsx",
scopeName: "source.tsx",
path: "tsx.tmLanguage.json",
samplePath: "tsx.sample"
},
{
id: "turtle",
scopeName: "source.turtle",
path: "turtle.tmLanguage.json",
samplePath: "turtle.sample"
},
{
id: "twig",
scopeName: "text.html.twig",
path: "twig.tmLanguage.json",
embeddedLangs: ["css", "javascript", "php", "python", "ruby"]
},
{
id: "typescript",
scopeName: "source.ts",
path: "typescript.tmLanguage.json",
aliases: ["ts"]
},
{
id: "v",
scopeName: "source.v",
path: "v.tmLanguage.json",
samplePath: "v.sample"
},
{
id: "vb",
scopeName: "source.asp.vb.net",
path: "vb.tmLanguage.json",
aliases: ["cmd"]
},
{
id: "verilog",
scopeName: "source.verilog",
path: "verilog.tmLanguage.json"
},
{
id: "vhdl",
scopeName: "source.vhdl",
path: "vhdl.tmLanguage.json"
},
{
id: "viml",
scopeName: "source.viml",
path: "viml.tmLanguage.json",
aliases: ["vim", "vimscript"]
},
{
id: "vue-html",
scopeName: "text.html.vue-html",
path: "vue-html.tmLanguage.json",
embeddedLangs: ["vue", "javascript"]
},
{
id: "vue",
scopeName: "source.vue",
path: "vue.tmLanguage.json",
embeddedLangs: ["html", "markdown", "pug", "stylus", "sass", "css", "scss", "less", "javascript", "typescript", "jsx", "tsx", "json", "jsonc", "yaml", "toml", "graphql"]
},
{
id: "wasm",
scopeName: "source.wat",
path: "wasm.tmLanguage.json"
},
{
id: "wenyan",
scopeName: "source.wenyan",
path: "wenyan.tmLanguage.json",
aliases: ["文言"]
},
{
id: "xml",
scopeName: "text.xml",
path: "xml.tmLanguage.json",
embeddedLangs: ["java"]
},
{
id: "xsl",
scopeName: "text.xml.xsl",
path: "xsl.tmLanguage.json",
embeddedLangs: ["xml"]
},
{
id: "yaml",
scopeName: "source.yaml",
path: "yaml.tmLanguage.json"
},
{
id: "zenscript",
scopeName: "source.zenscript",
path: "zenscript.tmLanguage.json",
samplePath: "zenscript.sample"
}
];
var FontStyle = /* @__PURE__ */ ((FontStyle2) => {
FontStyle2[FontStyle2["NotSet"] = -1] = "NotSet";
FontStyle2[FontStyle2["None"] = 0] = "None";
FontStyle2[FontStyle2["Italic"] = 1] = "Italic";
FontStyle2[FontStyle2["Bold"] = 2] = "Bold";
FontStyle2[FontStyle2["Underline"] = 4] = "Underline";
return FontStyle2;
})(FontStyle || {});
class StackElementMetadata {
static toBinaryStr(metadata) {
let r2 = metadata.toString(2);
while (r2.length < 32) {
r2 = "0" + r2;
}
return r2;
}
static printMetadata(metadata) {
let languageId = StackElementMetadata.getLanguageId(metadata);
let tokenType = StackElementMetadata.getTokenType(metadata);
let fontStyle = StackElementMetadata.getFontStyle(metadata);
let foreground = StackElementMetadata.getForeground(metadata);
let background = StackElementMetadata.getBackground(metadata);
console.log({
languageId,
tokenType,
fontStyle,
foreground,
background
});
}
static getLanguageId(metadata) {
return (metadata & 255) >>> 0;
}
static getTokenType(metadata) {
return (metadata & 768) >>> 8;
}
static getFontStyle(metadata) {
return (metadata & 14336) >>> 11;
}
static getForeground(metadata) {
return (metadata & 8372224) >>> 15;
}
static getBackground(metadata) {
return (metadata & 4286578688) >>> 24;
}
static containsBalancedBrackets(metadata) {
return (metadata & 1024) !== 0;
}
static set(metadata, languageId, tokenType, fontStyle, foreground, background) {
let _languageId = StackElementMetadata.getLanguageId(metadata);
let _tokenType = StackElementMetadata.getTokenType(metadata);
let _fontStyle = StackElementMetadata.getFontStyle(metadata);
let _foreground = StackElementMetadata.getForeground(metadata);
let _background = StackElementMetadata.getBackground(metadata);
let _containsBalancedBracketsBit = StackElementMetadata.containsBalancedBrackets(
metadata
) ? 1 : 0;
if (languageId !== 0) {
_languageId = languageId;
}
if (tokenType !== 0) {
_tokenType = tokenType === 8 ? 0 : tokenType;
}
if (fontStyle !== -1) {
_fontStyle = fontStyle;
}
if (foreground !== 0) {
_foreground = foreground;
}
if (background !== 0) {
_background = background;
}
return (_languageId << 0 | _tokenType << 8 | _fontStyle << 11 | _containsBalancedBracketsBit << 10 | _foreground << 15 | _background << 24) >>> 0;
}
}
function trimEndSlash(str) {
if (str.endsWith("/") || str.endsWith("\\"))
return str.slice(0, -1);
return str;
}
function trimStartDot(str) {
if (str.startsWith("./"))
return str.slice(2);
return str;
}
function dirpathparts(str) {
const parts = str.split(/[\/\\]/g);
return parts.slice(0, parts.length - 1);
}
function join(...parts) {
return parts.map(trimEndSlash).map(trimStartDot).join("/");
}
function groupBy(elements, keyGetter) {
const map2 = /* @__PURE__ */ new Map();
for (const element2 of elements) {
const key = keyGetter(element2);
if (map2.has(key)) {
const group = map2.get(key);
group.push(element2);
} else {
map2.set(key, [element2]);
}
}
return map2;
}
function createScanner(text2, ignoreTrivia = false) {
const len = text2.length;
let pos = 0, value = "", tokenOffset = 0, token = 16, lineNumber = 0, lineStartOffset = 0, tokenLineStartOffset = 0, prevTokenLineStartOffset = 0, scanError = 0;
function scanHexDigits(count2, exact) {
let digits = 0;
let value2 = 0;
while (digits < count2 || !exact) {
let ch2 = text2.charCodeAt(pos);
if (ch2 >= 48 && ch2 <= 57) {
value2 = value2 * 16 + ch2 - 48;
} else if (ch2 >= 65 && ch2 <= 70) {
value2 = value2 * 16 + ch2 - 65 + 10;
} else if (ch2 >= 97 && ch2 <= 102) {
value2 = value2 * 16 + ch2 - 97 + 10;
} else {
break;
}
pos++;
digits++;
}
if (digits < count2) {
value2 = -1;
}
return value2;
}
function setPosition(newPosition) {
pos = newPosition;
value = "";
tokenOffset = 0;
token = 16;
scanError = 0;
}
function scanNumber() {
let start = pos;
if (text2.charCodeAt(pos) === 48) {
pos++;
} else {
pos++;
while (pos < text2.length && isDigit(text2.charCodeAt(pos))) {
pos++;
}
}
if (pos < text2.length && text2.charCodeAt(pos) === 46) {
pos++;
if (pos < text2.length && isDigit(text2.charCodeAt(pos))) {
pos++;
while (pos < text2.length && isDigit(text2.charCodeAt(pos))) {
pos++;
}
} else {
scanError = 3;
return text2.substring(start, pos);
}
}
let end = pos;
if (pos < text2.length && (text2.charCodeAt(pos) === 69 || text2.charCodeAt(pos) === 101)) {
pos++;
if (pos < text2.length && text2.charCodeAt(pos) === 43 || text2.charCodeAt(pos) === 45) {
pos++;
}
if (pos < text2.length && isDigit(text2.charCodeAt(pos))) {
pos++;
while (pos < text2.length && isDigit(text2.charCodeAt(pos))) {
pos++;
}
end = pos;
} else {
scanError = 3;
}
}
return text2.substring(start, end);
}
function scanString() {
let result = "", start = pos;
while (true) {
if (pos >= len) {
result += text2.substring(start, pos);
scanError = 2;
break;
}
const ch2 = text2.charCodeAt(pos);
if (ch2 === 34) {
result += text2.substring(start, pos);
pos++;
break;
}
if (ch2 === 92) {
result += text2.substring(start, pos);
pos++;
if (pos >= len) {
scanError = 2;
break;
}
const ch22 = text2.charCodeAt(pos++);
switch (ch22) {
case 34:
result += '"';
break;
case 92:
result += "\\";
break;
case 47:
result += "/";
break;
case 98:
result += "\b";
break;
case 102:
result += "\f";
break;
case 110:
result += "\n";
break;
case 114:
result += "\r";
break;
case 116:
result += " ";
break;
case 117:
const ch3 = scanHexDigits(4, true);
if (ch3 >= 0) {
result += String.fromCharCode(ch3);
} else {
scanError = 4;
}
break;
default:
scanError = 5;
}
start = pos;
continue;
}
if (ch2 >= 0 && ch2 <= 31) {
if (isLineBreak(ch2)) {
result += text2.substring(start, pos);
scanError = 2;
break;
} else {
scanError = 6;
}
}
pos++;
}
return result;
}
function scanNext() {
value = "";
scanError = 0;
tokenOffset = pos;
lineStartOffset = lineNumber;
prevTokenLineStartOffset = tokenLineStartOffset;
if (pos >= len) {
tokenOffset = len;
return token = 17;
}
let code = text2.charCodeAt(pos);
if (isWhiteSpace(code)) {
do {
pos++;
value += String.fromCharCode(code);
code = text2.charCodeAt(pos);
} while (isWhiteSpace(code));
return token = 15;
}
if (isLineBreak(code)) {
pos++;
value += String.fromCharCode(code);
if (code === 13 && text2.charCodeAt(pos) === 10) {
pos++;
value += "\n";
}
lineNumber++;
tokenLineStartOffset = pos;
return token = 14;
}
switch (code) {
case 123:
pos++;
return token = 1;
case 125:
pos++;
return token = 2;
case 91:
pos++;
return token = 3;
case 93:
pos++;
return token = 4;
case 58:
pos++;
return token = 6;
case 44:
pos++;
return token = 5;
case 34:
pos++;
value = scanString();
return token = 10;
case 47:
const start = pos - 1;
if (text2.charCodeAt(pos + 1) === 47) {
pos += 2;
while (pos < len) {
if (isLineBreak(text2.charCodeAt(pos))) {
break;
}
pos++;
}
value = text2.substring(start, pos);
return token = 12;
}
if (text2.charCodeAt(pos + 1) === 42) {
pos += 2;
const safeLength = len - 1;
let commentClosed = false;
while (pos < safeLength) {
const ch2 = text2.charCodeAt(pos);
if (ch2 === 42 && text2.charCodeAt(pos + 1) === 47) {
pos += 2;
commentClosed = true;
break;
}
pos++;
if (isLineBreak(ch2)) {
if (ch2 === 13 && text2.charCodeAt(pos) === 10) {
pos++;
}
lineNumber++;
tokenLineStartOffset = pos;
}
}
if (!commentClosed) {
pos++;
scanError = 1;
}
value = text2.substring(start, pos);
return token = 13;
}
value += String.fromCharCode(code);
pos++;
return token = 16;
case 45:
value += String.fromCharCode(code);
pos++;
if (pos === len || !isDigit(text2.charCodeAt(pos))) {
return token = 16;
}
case 48:
case 49:
case 50:
case 51:
case 52:
case 53:
case 54:
case 55:
case 56:
case 57:
value += scanNumber();
return token = 11;
default:
while (pos < len && isUnknownContentCharacter(code)) {
pos++;
code = text2.charCodeAt(pos);
}
if (tokenOffset !== pos) {
value = text2.substring(tokenOffset, pos);
switch (value) {
case "true":
return token = 8;
case "false":
return token = 9;
case "null":
return token = 7;
}
return token = 16;
}
value += String.fromCharCode(code);
pos++;
return token = 16;
}
}
function isUnknownContentCharacter(code) {
if (isWhiteSpace(code) || isLineBreak(code)) {
return false;
}
switch (code) {
case 125:
case 93:
case 123:
case 91:
case 34:
case 58:
case 44:
case 47:
return false;
}
return true;
}
function scanNextNonTrivia() {
let result;
do {
result = scanNext();
} while (result >= 12 && result <= 15);
return result;
}
return {
setPosition,
getPosition: () => pos,
scan: ignoreTrivia ? scanNextNonTrivia : scanNext,
getToken: () => token,
getTokenValue: () => value,
getTokenOffset: () => tokenOffset,
getTokenLength: () => pos - tokenOffset,
getTokenStartLine: () => lineStartOffset,
getTokenStartCharacter: () => tokenOffset - prevTokenLineStartOffset,
getTokenError: () => scanError
};
}
function isWhiteSpace(ch2) {
return ch2 === 32 || ch2 === 9;
}
function isLineBreak(ch2) {
return ch2 === 10 || ch2 === 13;
}
function isDigit(ch2) {
return ch2 >= 48 && ch2 <= 57;
}
var CharacterCodes;
(function(CharacterCodes2) {
CharacterCodes2[CharacterCodes2["lineFeed"] = 10] = "lineFeed";
CharacterCodes2[CharacterCodes2["carriageReturn"] = 13] = "carriageReturn";
CharacterCodes2[CharacterCodes2["space"] = 32] = "space";
CharacterCodes2[CharacterCodes2["_0"] = 48] = "_0";
CharacterCodes2[CharacterCodes2["_1"] = 49] = "_1";
CharacterCodes2[CharacterCodes2["_2"] = 50] = "_2";
CharacterCodes2[CharacterCodes2["_3"] = 51] = "_3";
CharacterCodes2[CharacterCodes2["_4"] = 52] = "_4";
CharacterCodes2[CharacterCodes2["_5"] = 53] = "_5";
CharacterCodes2[CharacterCodes2["_6"] = 54] = "_6";
CharacterCodes2[CharacterCodes2["_7"] = 55] = "_7";
CharacterCodes2[CharacterCodes2["_8"] = 56] = "_8";
CharacterCodes2[CharacterCodes2["_9"] = 57] = "_9";
CharacterCodes2[CharacterCodes2["a"] = 97] = "a";
CharacterCodes2[CharacterCodes2["b"] = 98] = "b";
CharacterCodes2[CharacterCodes2["c"] = 99] = "c";
CharacterCodes2[CharacterCodes2["d"] = 100] = "d";
CharacterCodes2[CharacterCodes2["e"] = 101] = "e";
CharacterCodes2[CharacterCodes2["f"] = 102] = "f";
CharacterCodes2[CharacterCodes2["g"] = 103] = "g";
CharacterCodes2[CharacterCodes2["h"] = 104] = "h";
CharacterCodes2[CharacterCodes2["i"] = 105] = "i";
CharacterCodes2[CharacterCodes2["j"] = 106] = "j";
CharacterCodes2[CharacterCodes2["k"] = 107] = "k";
CharacterCodes2[CharacterCodes2["l"] = 108] = "l";
CharacterCodes2[CharacterCodes2["m"] = 109] = "m";
CharacterCodes2[CharacterCodes2["n"] = 110] = "n";
CharacterCodes2[CharacterCodes2["o"] = 111] = "o";
CharacterCodes2[CharacterCodes2["p"] = 112] = "p";
CharacterCodes2[CharacterCodes2["q"] = 113] = "q";
CharacterCodes2[CharacterCodes2["r"] = 114] = "r";
CharacterCodes2[CharacterCodes2["s"] = 115] = "s";
CharacterCodes2[CharacterCodes2["t"] = 116] = "t";
CharacterCodes2[CharacterCodes2["u"] = 117] = "u";
CharacterCodes2[CharacterCodes2["v"] = 118] = "v";
CharacterCodes2[CharacterCodes2["w"] = 119] = "w";
CharacterCodes2[CharacterCodes2["x"] = 120] = "x";
CharacterCodes2[CharacterCodes2["y"] = 121] = "y";
CharacterCodes2[CharacterCodes2["z"] = 122] = "z";
CharacterCodes2[CharacterCodes2["A"] = 65] = "A";
CharacterCodes2[CharacterCodes2["B"] = 66] = "B";
CharacterCodes2[CharacterCodes2["C"] = 67] = "C";
CharacterCodes2[CharacterCodes2["D"] = 68] = "D";
CharacterCodes2[CharacterCodes2["E"] = 69] = "E";
CharacterCodes2[CharacterCodes2["F"] = 70] = "F";
CharacterCodes2[CharacterCodes2["G"] = 71] = "G";
CharacterCodes2[CharacterCodes2["H"] = 72] = "H";
CharacterCodes2[CharacterCodes2["I"] = 73] = "I";
CharacterCodes2[CharacterCodes2["J"] = 74] = "J";
CharacterCodes2[CharacterCodes2["K"] = 75] = "K";
CharacterCodes2[CharacterCodes2["L"] = 76] = "L";
CharacterCodes2[CharacterCodes2["M"] = 77] = "M";
CharacterCodes2[CharacterCodes2["N"] = 78] = "N";
CharacterCodes2[CharacterCodes2["O"] = 79] = "O";
CharacterCodes2[CharacterCodes2["P"] = 80] = "P";
CharacterCodes2[CharacterCodes2["Q"] = 81] = "Q";
CharacterCodes2[CharacterCodes2["R"] = 82] = "R";
CharacterCodes2[CharacterCodes2["S"] = 83] = "S";
CharacterCodes2[CharacterCodes2["T"] = 84] = "T";
CharacterCodes2[CharacterCodes2["U"] = 85] = "U";
CharacterCodes2[CharacterCodes2["V"] = 86] = "V";
CharacterCodes2[CharacterCodes2["W"] = 87] = "W";
CharacterCodes2[CharacterCodes2["X"] = 88] = "X";
CharacterCodes2[CharacterCodes2["Y"] = 89] = "Y";
CharacterCodes2[CharacterCodes2["Z"] = 90] = "Z";
CharacterCodes2[CharacterCodes2["asterisk"] = 42] = "asterisk";
CharacterCodes2[CharacterCodes2["backslash"] = 92] = "backslash";
CharacterCodes2[CharacterCodes2["closeBrace"] = 125] = "closeBrace";
CharacterCodes2[CharacterCodes2["closeBracket"] = 93] = "closeBracket";
CharacterCodes2[CharacterCodes2["colon"] = 58] = "colon";
CharacterCodes2[CharacterCodes2["comma"] = 44] = "comma";
CharacterCodes2[CharacterCodes2["dot"] = 46] = "dot";
CharacterCodes2[CharacterCodes2["doubleQuote"] = 34] = "doubleQuote";
CharacterCodes2[CharacterCodes2["minus"] = 45] = "minus";
CharacterCodes2[CharacterCodes2["openBrace"] = 123] = "openBrace";
CharacterCodes2[CharacterCodes2["openBracket"] = 91] = "openBracket";
CharacterCodes2[CharacterCodes2["plus"] = 43] = "plus";
CharacterCodes2[CharacterCodes2["slash"] = 47] = "slash";
CharacterCodes2[CharacterCodes2["formFeed"] = 12] = "formFeed";
CharacterCodes2[CharacterCodes2["tab"] = 9] = "tab";
})(CharacterCodes || (CharacterCodes = {}));
var ParseOptions;
(function(ParseOptions2) {
ParseOptions2.DEFAULT = {
allowTrailingComma: false
};
})(ParseOptions || (ParseOptions = {}));
function parse$1(text2, errors = [], options = ParseOptions.DEFAULT) {
let currentProperty = null;
let currentParent = [];
const previousParents = [];
function onValue(value) {
if (Array.isArray(currentParent)) {
currentParent.push(value);
} else if (currentProperty !== null) {
currentParent[currentProperty] = value;
}
}
const visitor = {
onObjectBegin: () => {
const object = {};
onValue(object);
previousParents.push(currentParent);
currentParent = object;
currentProperty = null;
},
onObjectProperty: (name) => {
currentProperty = name;
},
onObjectEnd: () => {
currentParent = previousParents.pop();
},
onArrayBegin: () => {
const array = [];
onValue(array);
previousParents.push(currentParent);
currentParent = array;
currentProperty = null;
},
onArrayEnd: () => {
currentParent = previousParents.pop();
},
onLiteralValue: onValue,
onError: (error, offset2, length) => {
errors.push({ error, offset: offset2, length });
}
};
visit(text2, visitor, options);
return currentParent[0];
}
function visit(text2, visitor, options = ParseOptions.DEFAULT) {
const _scanner = createScanner(text2, false);
const _jsonPath = [];
function toNoArgVisit(visitFunction) {
return visitFunction ? () => visitFunction(_scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter()) : () => true;
}
function toNoArgVisitWithPath(visitFunction) {
return visitFunction ? () => visitFunction(_scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter(), () => _jsonPath.slice()) : () => true;
}
function toOneArgVisit(visitFunction) {
return visitFunction ? (arg) => visitFunction(arg, _scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter()) : () => true;
}
function toOneArgVisitWithPath(visitFunction) {
return visitFunction ? (arg) => visitFunction(arg, _scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter(), () => _jsonPath.slice()) : () => true;
}
const onObjectBegin = toNoArgVisitWithPath(visitor.onObjectBegin), onObjectProperty = toOneArgVisitWithPath(visitor.onObjectProperty), onObjectEnd = toNoArgVisit(visitor.onObjectEnd), onArrayBegin = toNoArgVisitWithPath(visitor.onArrayBegin), onArrayEnd = toNoArgVisit(visitor.onArrayEnd), onLiteralValue = toOneArgVisitWithPath(visitor.onLiteralValue), onSeparator = toOneArgVisit(visitor.onSeparator), onComment = toNoArgVisit(visitor.onComment), onError = toOneArgVisit(visitor.onError);
const disallowComments = options && options.disallowComments;
const allowTrailingComma = options && options.allowTrailingComma;
function scanNext() {
while (true) {
const token = _scanner.scan();
switch (_scanner.getTokenError()) {
case 4:
handleError2(
14
/* ParseErrorCode.InvalidUnicode */
);
break;
case 5:
handleError2(
15
/* ParseErrorCode.InvalidEscapeCharacter */
);
break;
case 3:
handleError2(
13
/* ParseErrorCode.UnexpectedEndOfNumber */
);
break;
case 1:
if (!disallowComments) {
handleError2(
11
/* ParseErrorCode.UnexpectedEndOfComment */
);
}
break;
case 2:
handleError2(
12
/* ParseErrorCode.UnexpectedEndOfString */
);
break;
case 6:
handleError2(
16
/* ParseErrorCode.InvalidCharacter */
);
break;
}
switch (token) {
case 12:
case 13:
if (disallowComments) {
handleError2(
10
/* ParseErrorCode.InvalidCommentToken */
);
} else {
onComment();
}
break;
case 16:
handleError2(
1
/* ParseErrorCode.InvalidSymbol */
);
break;
case 15:
case 14:
break;
default:
return token;
}
}
}
function handleError2(error, skipUntilAfter = [], skipUntil = []) {
onError(error);
if (skipUntilAfter.length + skipUntil.length > 0) {
let token = _scanner.getToken();
while (token !== 17) {
if (skipUntilAfter.indexOf(token) !== -1) {
scanNext();
break;
} else if (skipUntil.indexOf(token) !== -1) {
break;
}
token = scanNext();
}
}
}
function parseString(isValue) {
const value = _scanner.getTokenValue();
if (isValue) {
onLiteralValue(value);
} else {
onObjectProperty(value);
_jsonPath.push(value);
}
scanNext();
return true;
}
function parseLiteral() {
switch (_scanner.getToken()) {
case 11:
const tokenValue = _scanner.getTokenValue();
let value = Number(tokenValue);
if (isNaN(value)) {
handleError2(
2
/* ParseErrorCode.InvalidNumberFormat */
);
value = 0;
}
onLiteralValue(value);
break;
case 7:
onLiteralValue(null);
break;
case 8:
onLiteralValue(true);
break;
case 9:
onLiteralValue(false);
break;
default:
return false;
}
scanNext();
return true;
}
function parseProperty() {
if (_scanner.getToken() !== 10) {
handleError2(3, [], [
2,
5
/* SyntaxKind.CommaToken */
]);
return false;
}
parseString(false);
if (_scanner.getToken() === 6) {
onSeparator(":");
scanNext();
if (!parseValue()) {
handleError2(4, [], [
2,
5
/* SyntaxKind.CommaToken */
]);
}
} else {
handleError2(5, [], [
2,
5
/* SyntaxKind.CommaToken */
]);
}
_jsonPath.pop();
return true;
}
function parseObject() {
onObjectBegin();
scanNext();
let needsComma = false;
while (_scanner.getToken() !== 2 && _scanner.getToken() !== 17) {
if (_scanner.getToken() === 5) {
if (!needsComma) {
handleError2(4, [], []);
}
onSeparator(",");
scanNext();
if (_scanner.getToken() === 2 && allowTrailingComma) {
break;
}
} else if (needsComma) {
handleError2(6, [], []);
}
if (!parseProperty()) {
handleError2(4, [], [
2,
5
/* SyntaxKind.CommaToken */
]);
}
needsComma = true;
}
onObjectEnd();
if (_scanner.getToken() !== 2) {
handleError2(7, [
2
/* SyntaxKind.CloseBraceToken */
], []);
} else {
scanNext();
}
return true;
}
function parseArray() {
onArrayBegin();
scanNext();
let isFirstElement = true;
let needsComma = false;
while (_scanner.getToken() !== 4 && _scanner.getToken() !== 17) {
if (_scanner.getToken() === 5) {
if (!needsComma) {
handleError2(4, [], []);
}
onSeparator(",");
scanNext();
if (_scanner.getToken() === 4 && allowTrailingComma) {
break;
}
} else if (needsComma) {
handleError2(6, [], []);
}
if (isFirstElement) {
_jsonPath.push(0);
isFirstElement = false;
} else {
_jsonPath[_jsonPath.length - 1]++;
}
if (!parseValue()) {
handleError2(4, [], [
4,
5
/* SyntaxKind.CommaToken */
]);
}
needsComma = true;
}
onArrayEnd();
if (!isFirstElement) {
_jsonPath.pop();
}
if (_scanner.getToken() !== 4) {
handleError2(8, [
4
/* SyntaxKind.CloseBracketToken */
], []);
} else {
scanNext();
}
return true;
}
function parseValue() {
switch (_scanner.getToken()) {
case 3:
return parseArray();
case 1:
return parseObject();
case 10:
return parseString(true);
default:
return parseLiteral();
}
}
scanNext();
if (_scanner.getToken() === 17) {
if (options.allowEmptyContent) {
return true;
}
handleError2(4, [], []);
return false;
}
if (!parseValue()) {
handleError2(4, [], []);
return false;
}
if (_scanner.getToken() !== 17) {
handleError2(9, [], []);
}
return true;
}
var ScanError;
(function(ScanError2) {
ScanError2[ScanError2["None"] = 0] = "None";
ScanError2[ScanError2["UnexpectedEndOfComment"] = 1] = "UnexpectedEndOfComment";
ScanError2[ScanError2["UnexpectedEndOfString"] = 2] = "UnexpectedEndOfString";
ScanError2[ScanError2["UnexpectedEndOfNumber"] = 3] = "UnexpectedEndOfNumber";
ScanError2[ScanError2["InvalidUnicode"] = 4] = "InvalidUnicode";
ScanError2[ScanError2["InvalidEscapeCharacter"] = 5] = "InvalidEscapeCharacter";
ScanError2[ScanError2["InvalidCharacter"] = 6] = "InvalidCharacter";
})(ScanError || (ScanError = {}));
var SyntaxKind;
(function(SyntaxKind2) {
SyntaxKind2[SyntaxKind2["OpenBraceToken"] = 1] = "OpenBraceToken";
SyntaxKind2[SyntaxKind2["CloseBraceToken"] = 2] = "CloseBraceToken";
SyntaxKind2[SyntaxKind2["OpenBracketToken"] = 3] = "OpenBracketToken";
SyntaxKind2[SyntaxKind2["CloseBracketToken"] = 4] = "CloseBracketToken";
SyntaxKind2[SyntaxKind2["CommaToken"] = 5] = "CommaToken";
SyntaxKind2[SyntaxKind2["ColonToken"] = 6] = "ColonToken";
SyntaxKind2[SyntaxKind2["NullKeyword"] = 7] = "NullKeyword";
SyntaxKind2[SyntaxKind2["TrueKeyword"] = 8] = "TrueKeyword";
SyntaxKind2[SyntaxKind2["FalseKeyword"] = 9] = "FalseKeyword";
SyntaxKind2[SyntaxKind2["StringLiteral"] = 10] = "StringLiteral";
SyntaxKind2[SyntaxKind2["NumericLiteral"] = 11] = "NumericLiteral";
SyntaxKind2[SyntaxKind2["LineCommentTrivia"] = 12] = "LineCommentTrivia";
SyntaxKind2[SyntaxKind2["BlockCommentTrivia"] = 13] = "BlockCommentTrivia";
SyntaxKind2[SyntaxKind2["LineBreakTrivia"] = 14] = "LineBreakTrivia";
SyntaxKind2[SyntaxKind2["Trivia"] = 15] = "Trivia";
SyntaxKind2[SyntaxKind2["Unknown"] = 16] = "Unknown";
SyntaxKind2[SyntaxKind2["EOF"] = 17] = "EOF";
})(SyntaxKind || (SyntaxKind = {}));
const parse = parse$1;
var ParseErrorCode;
(function(ParseErrorCode2) {
ParseErrorCode2[ParseErrorCode2["InvalidSymbol"] = 1] = "InvalidSymbol";
ParseErrorCode2[ParseErrorCode2["InvalidNumberFormat"] = 2] = "InvalidNumberFormat";
ParseErrorCode2[ParseErrorCode2["PropertyNameExpected"] = 3] = "PropertyNameExpected";
ParseErrorCode2[ParseErrorCode2["ValueExpected"] = 4] = "ValueExpected";
ParseErrorCode2[ParseErrorCode2["ColonExpected"] = 5] = "ColonExpected";
ParseErrorCode2[ParseErrorCode2["CommaExpected"] = 6] = "CommaExpected";
ParseErrorCode2[ParseErrorCode2["CloseBraceExpected"] = 7] = "CloseBraceExpected";
ParseErrorCode2[ParseErrorCode2["CloseBracketExpected"] = 8] = "CloseBracketExpected";
ParseErrorCode2[ParseErrorCode2["EndOfFileExpected"] = 9] = "EndOfFileExpected";
ParseErrorCode2[ParseErrorCode2["InvalidCommentToken"] = 10] = "InvalidCommentToken";
ParseErrorCode2[ParseErrorCode2["UnexpectedEndOfComment"] = 11] = "UnexpectedEndOfComment";
ParseErrorCode2[ParseErrorCode2["UnexpectedEndOfString"] = 12] = "UnexpectedEndOfString";
ParseErrorCode2[ParseErrorCode2["UnexpectedEndOfNumber"] = 13] = "UnexpectedEndOfNumber";
ParseErrorCode2[ParseErrorCode2["InvalidUnicode"] = 14] = "InvalidUnicode";
ParseErrorCode2[ParseErrorCode2["InvalidEscapeCharacter"] = 15] = "InvalidEscapeCharacter";
ParseErrorCode2[ParseErrorCode2["InvalidCharacter"] = 16] = "InvalidCharacter";
})(ParseErrorCode || (ParseErrorCode = {}));
"process" in globalThis && typeof process !== "undefined" && typeof process.release !== "undefined" && process.release.name === "node";
let CDN_ROOT = "";
const WASM_PATH = "dist/";
function setCDN(root) {
CDN_ROOT = root.endsWith("/") ? root : root + "/";
}
let _onigurumaPromise = null;
async function getOniguruma(wasmPath) {
if (!_onigurumaPromise) {
let loader;
{
{
loader = mainExports$1.loadWASM({
data: await (globalThis.__shiki_fetch__ || globalThis.fetch)(_resolvePath(join(...dirpathparts(wasmPath), "onig.wasm")))
});
}
}
_onigurumaPromise = loader.then(() => {
return {
createOnigScanner(patterns) {
return mainExports$1.createOnigScanner(patterns);
},
createOnigString(s) {
return mainExports$1.createOnigString(s);
}
};
});
}
return _onigurumaPromise;
}
function _resolvePath(filepath) {
{
return `${CDN_ROOT}${filepath}`;
}
}
async function _fetchAssets(filepath) {
const path = _resolvePath(filepath);
{
return await (globalThis.__shiki_fetch__ || globalThis.fetch)(path).then((r2) => r2.text());
}
}
async function _fetchJSONAssets(filepath) {
const errors = [];
const rawTheme = parse(await _fetchAssets(filepath), errors, {
allowTrailingComma: true
});
if (errors.length) {
throw errors[0];
}
return rawTheme;
}
async function fetchTheme(themePath) {
let theme = await _fetchJSONAssets(themePath);
const shikiTheme = toShikiTheme(theme);
if (shikiTheme.include) {
const includedTheme = await fetchTheme(join(...dirpathparts(themePath), shikiTheme.include));
if (includedTheme.settings) {
shikiTheme.settings = includedTheme.settings.concat(shikiTheme.settings);
}
if (includedTheme.bg && !shikiTheme.bg) {
shikiTheme.bg = includedTheme.bg;
}
if (includedTheme.colors) {
shikiTheme.colors = { ...includedTheme.colors, ...shikiTheme.colors };
}
delete shikiTheme.include;
}
return shikiTheme;
}
async function fetchGrammar(filepath) {
return await _fetchJSONAssets(filepath);
}
function repairTheme(theme) {
if (!theme.settings)
theme.settings = [];
if (theme.settings[0] && theme.settings[0].settings && !theme.settings[0].scope) {
return;
}
theme.settings.unshift({
settings: {
foreground: theme.fg,
background: theme.bg
}
});
}
function toShikiTheme(rawTheme) {
const type = rawTheme.type || "dark";
const shikiTheme = {
name: rawTheme.name,
type,
...rawTheme,
...getThemeDefaultColors(rawTheme)
};
if (rawTheme.include) {
shikiTheme.include = rawTheme.include;
}
if (rawTheme.tokenColors) {
shikiTheme.settings = rawTheme.tokenColors;
delete shikiTheme.tokenColors;
}
repairTheme(shikiTheme);
return shikiTheme;
}
const VSCODE_FALLBACK_EDITOR_FG = { light: "#333333", dark: "#bbbbbb" };
const VSCODE_FALLBACK_EDITOR_BG = { light: "#fffffe", dark: "#1e1e1e" };
function getThemeDefaultColors(theme) {
var _a2, _b, _c2, _d2;
let fg2, bg2;
let settings = theme.settings ? theme.settings : theme.tokenColors;
const globalSetting = settings ? settings.find((s) => {
return !s.name && !s.scope;
}) : void 0;
if ((_a2 = globalSetting == null ? void 0 : globalSetting.settings) == null ? void 0 : _a2.foreground) {
fg2 = globalSetting.settings.foreground;
}
if ((_b = globalSetting == null ? void 0 : globalSetting.settings) == null ? void 0 : _b.background) {
bg2 = globalSetting.settings.background;
}
if (!fg2 && ((_c2 = theme == null ? void 0 : theme.colors) == null ? void 0 : _c2["editor.foreground"])) {
fg2 = theme.colors["editor.foreground"];
}
if (!bg2 && ((_d2 = theme == null ? void 0 : theme.colors) == null ? void 0 : _d2["editor.background"])) {
bg2 = theme.colors["editor.background"];
}
if (!fg2) {
fg2 = theme.type === "light" ? VSCODE_FALLBACK_EDITOR_FG.light : VSCODE_FALLBACK_EDITOR_FG.dark;
}
if (!bg2) {
bg2 = theme.type === "light" ? VSCODE_FALLBACK_EDITOR_BG.light : VSCODE_FALLBACK_EDITOR_BG.dark;
}
return {
fg: fg2,
bg: bg2
};
}
class Resolver {
constructor(onigLibPromise, onigLibName) {
this.languagesPath = "languages/";
this.languageMap = {};
this.scopeToLangMap = {};
this._onigLibPromise = onigLibPromise;
this._onigLibName = onigLibName;
}
get onigLib() {
return this._onigLibPromise;
}
getOnigLibName() {
return this._onigLibName;
}
getLangRegistration(langIdOrAlias) {
return this.languageMap[langIdOrAlias];
}
async loadGrammar(scopeName) {
const lang = this.scopeToLangMap[scopeName];
if (!lang) {
return null;
}
if (lang.grammar) {
return lang.grammar;
}
const g = await fetchGrammar(
languages.includes(lang) ? `${this.languagesPath}${lang.path}` : lang.path
);
lang.grammar = g;
return g;
}
addLanguage(l) {
this.languageMap[l.id] = l;
if (l.aliases) {
l.aliases.forEach((a2) => {
this.languageMap[a2] = l;
});
}
this.scopeToLangMap[l.scopeName] = l;
}
}
function tokenizeWithTheme(theme, colorMap, fileContents, grammar, options) {
let lines = fileContents.split(/\r\n|\r|\n/);
let ruleStack = mainExports.INITIAL;
let actual = [];
let final = [];
for (let i2 = 0, len = lines.length; i2 < len; i2++) {
let line = lines[i2];
if (line === "") {
actual = [];
final.push([]);
continue;
}
let resultWithScopes;
let tokensWithScopes;
let tokensWithScopesIndex;
if (options.includeExplanation) {
resultWithScopes = grammar.tokenizeLine(line, ruleStack);
tokensWithScopes = resultWithScopes.tokens;
tokensWithScopesIndex = 0;
}
let result = grammar.tokenizeLine2(line, ruleStack);
let tokensLength = result.tokens.length / 2;
for (let j2 = 0; j2 < tokensLength; j2++) {
let startIndex = result.tokens[2 * j2];
let nextStartIndex = j2 + 1 < tokensLength ? result.tokens[2 * j2 + 2] : line.length;
if (startIndex === nextStartIndex) {
continue;
}
let metadata = result.tokens[2 * j2 + 1];
let foreground = StackElementMetadata.getForeground(metadata);
let foregroundColor = colorMap[foreground];
let fontStyle = StackElementMetadata.getFontStyle(metadata);
let explanation = [];
if (options.includeExplanation) {
let offset2 = 0;
while (startIndex + offset2 < nextStartIndex) {
let tokenWithScopes = tokensWithScopes[tokensWithScopesIndex];
let tokenWithScopesText = line.substring(
tokenWithScopes.startIndex,
tokenWithScopes.endIndex
);
offset2 += tokenWithScopesText.length;
explanation.push({
content: tokenWithScopesText,
scopes: explainThemeScopes(theme, tokenWithScopes.scopes)
});
tokensWithScopesIndex++;
}
}
actual.push({
content: line.substring(startIndex, nextStartIndex),
color: foregroundColor,
fontStyle,
explanation
});
}
final.push(actual);
actual = [];
ruleStack = result.ruleStack;
}
return final;
}
function explainThemeScopes(theme, scopes) {
let result = [];
for (let i2 = 0, len = scopes.length; i2 < len; i2++) {
let parentScopes = scopes.slice(0, i2);
let scope = scopes[i2];
result[i2] = {
scopeName: scope,
themeMatches: explainThemeScope(theme, scope, parentScopes)
};
}
return result;
}
function matchesOne(selector, scope) {
let selectorPrefix = selector + ".";
if (selector === scope || scope.substring(0, selectorPrefix.length) === selectorPrefix) {
return true;
}
return false;
}
function matches(selector, selectorParentScopes, scope, parentScopes) {
if (!matchesOne(selector, scope)) {
return false;
}
let selectorParentIndex = selectorParentScopes.length - 1;
let parentIndex = parentScopes.length - 1;
while (selectorParentIndex >= 0 && parentIndex >= 0) {
if (matchesOne(selectorParentScopes[selectorParentIndex], parentScopes[parentIndex])) {
selectorParentIndex--;
}
parentIndex--;
}
if (selectorParentIndex === -1) {
return true;
}
return false;
}
function explainThemeScope(theme, scope, parentScopes) {
let result = [], resultLen = 0;
for (let i2 = 0, len = theme.settings.length; i2 < len; i2++) {
let setting = theme.settings[i2];
let selectors;
if (typeof setting.scope === "string") {
selectors = setting.scope.split(/,/).map((scope2) => scope2.trim());
} else if (Array.isArray(setting.scope)) {
selectors = setting.scope;
} else {
continue;
}
for (let j2 = 0, lenJ = selectors.length; j2 < lenJ; j2++) {
let rawSelector = selectors[j2];
let rawSelectorPieces = rawSelector.split(/ /);
let selector = rawSelectorPieces[rawSelectorPieces.length - 1];
let selectorParentScopes = rawSelectorPieces.slice(0, rawSelectorPieces.length - 1);
if (matches(selector, selectorParentScopes, scope, parentScopes)) {
result[resultLen++] = setting;
j2 = lenJ;
}
}
}
return result;
}
const defaultElements = {
pre({ className, style, children: children2 }) {
return `<pre class="${className}" style="${style}">${children2}</pre>`;
},
code({ children: children2 }) {
return `<code>${children2}</code>`;
},
line({ className, children: children2 }) {
return `<span class="${className}">${children2}</span>`;
},
token({ style, children: children2 }) {
return `<span style="${style}">${children2}</span>`;
}
};
function renderToHtml(lines, options = {}) {
const bg2 = options.bg || "#fff";
const optionsByLineNumber = groupBy(options.lineOptions ?? [], (option) => option.line);
const userElements = options.elements || {};
function h2(type = "", props = {}, children2) {
const element2 = userElements[type] || defaultElements[type];
if (element2) {
children2 = children2.filter(Boolean);
return element2({
...props,
children: type === "code" ? children2.join("\n") : children2.join("")
});
}
return "";
}
return h2(
"pre",
{ className: "shiki " + (options.themeName || ""), style: `background-color: ${bg2}` },
[
options.langId ? `<div class="language-id">${options.langId}</div>` : "",
h2(
"code",
{},
lines.map((line, index2) => {
const lineNumber = index2 + 1;
const lineOptions = optionsByLineNumber.get(lineNumber) ?? [];
const lineClasses = getLineClasses(lineOptions).join(" ");
return h2(
"line",
{
className: lineClasses,
lines,
line,
index: index2
},
line.map((token, index22) => {
const cssDeclarations = [`color: ${token.color || options.fg}`];
if (token.fontStyle & FontStyle.Italic) {
cssDeclarations.push("font-style: italic");
}
if (token.fontStyle & FontStyle.Bold) {
cssDeclarations.push("font-weight: bold");
}
if (token.fontStyle & FontStyle.Underline) {
cssDeclarations.push("text-decoration: underline");
}
return h2(
"token",
{
style: cssDeclarations.join("; "),
tokens: line,
token,
index: index22
},
[escapeHtml(token.content)]
);
})
);
})
)
]
);
}
const htmlEscapes = {
"&": "&amp;",
"<": "&lt;",
">": "&gt;",
'"': "&quot;",
"'": "&#39;"
};
function escapeHtml(html) {
return html.replace(/[&<>"']/g, (chr) => htmlEscapes[chr]);
}
function getLineClasses(lineOptions) {
const lineClasses = /* @__PURE__ */ new Set(["line"]);
for (const lineOption of lineOptions) {
for (const lineClass of lineOption.classes ?? []) {
lineClasses.add(lineClass);
}
}
return Array.from(lineClasses);
}
class Registry extends mainExports.Registry {
constructor(_resolver) {
super(_resolver);
this._resolver = _resolver;
this.themesPath = "themes/";
this._resolvedThemes = {};
this._resolvedGrammars = {};
this._langGraph = /* @__PURE__ */ new Map();
this._langMap = languages.reduce((acc, lang) => {
acc[lang.id] = lang;
return acc;
}, {});
}
getTheme(theme) {
if (typeof theme === "string") {
return this._resolvedThemes[theme];
} else {
return theme;
}
}
async loadTheme(theme) {
if (typeof theme === "string") {
if (!this._resolvedThemes[theme]) {
this._resolvedThemes[theme] = await fetchTheme(`${this.themesPath}${theme}.json`);
}
return this._resolvedThemes[theme];
} else {
theme = toShikiTheme(theme);
if (theme.name) {
this._resolvedThemes[theme.name] = theme;
}
return theme;
}
}
async loadThemes(themes2) {
return await Promise.all(themes2.map((theme) => this.loadTheme(theme)));
}
getLoadedThemes() {
return Object.keys(this._resolvedThemes);
}
getGrammar(name) {
return this._resolvedGrammars[name];
}
async loadLanguage(lang) {
var _a2;
const embeddedLanguages = (_a2 = lang.embeddedLangs) == null ? void 0 : _a2.reduce(async (acc, l, idx) => {
if (!this.getLoadedLanguages().includes(l) && this._resolver.getLangRegistration(l)) {
await this._resolver.loadGrammar(this._resolver.getLangRegistration(l).scopeName);
acc[this._resolver.getLangRegistration(l).scopeName] = idx + 2;
return acc;
}
}, {});
const grammarConfig = {
embeddedLanguages,
balancedBracketSelectors: lang.balancedBracketSelectors || ["*"],
unbalancedBracketSelectors: lang.unbalancedBracketSelectors || []
};
const g = await this.loadGrammarWithConfiguration(lang.scopeName, 1, grammarConfig);
this._resolvedGrammars[lang.id] = g;
if (lang.aliases) {
lang.aliases.forEach((la2) => {
this._resolvedGrammars[la2] = g;
});
}
}
async loadLanguages(langs) {
for (const lang of langs) {
this.resolveEmbeddedLanguages(lang);
}
const langsGraphArray = Array.from(this._langGraph.values());
for (const lang of langsGraphArray) {
this._resolver.addLanguage(lang);
}
for (const lang of langsGraphArray) {
await this.loadLanguage(lang);
}
}
getLoadedLanguages() {
return Object.keys(this._resolvedGrammars);
}
resolveEmbeddedLanguages(lang) {
if (!this._langGraph.has(lang.id)) {
this._langGraph.set(lang.id, lang);
}
if (lang.embeddedLangs) {
for (const embeddedLang of lang.embeddedLangs) {
this._langGraph.set(embeddedLang, this._langMap[embeddedLang]);
}
}
}
}
function resolveLang(lang) {
return typeof lang === "string" ? languages.find((l) => {
var _a2;
return l.id === lang || ((_a2 = l.aliases) == null ? void 0 : _a2.includes(lang));
}) : lang;
}
function resolveOptions(options) {
var _a2;
let _languages = languages;
let _themes = options.themes || [];
let _wasmPath = ((_a2 = options.paths) == null ? void 0 : _a2.wasm) ? options.paths.wasm.endsWith("/") ? options.paths.wasm : options.paths.wasm + "/" : WASM_PATH;
if (options.langs) {
_languages = options.langs.map(resolveLang);
}
if (options.theme) {
_themes.unshift(options.theme);
}
if (!_themes.length) {
_themes = ["nord"];
}
return { _languages, _themes, _wasmPath };
}
async function getHighlighter(options) {
var _a2, _b;
const { _languages, _themes, _wasmPath } = resolveOptions(options);
const _resolver = new Resolver(getOniguruma(_wasmPath), "vscode-oniguruma");
const _registry = new Registry(_resolver);
if ((_a2 = options.paths) == null ? void 0 : _a2.themes) {
_registry.themesPath = options.paths.themes.endsWith("/") ? options.paths.themes : options.paths.themes + "/";
}
if ((_b = options.paths) == null ? void 0 : _b.languages) {
_resolver.languagesPath = options.paths.languages.endsWith("/") ? options.paths.languages : options.paths.languages + "/";
}
const themes2 = await _registry.loadThemes(_themes);
const _defaultTheme = themes2[0];
let _currentTheme;
await _registry.loadLanguages(_languages);
let COLOR_REPLACEMENTS = {
"#000001": "var(--shiki-color-text)",
"#000002": "var(--shiki-color-background)",
"#000004": "var(--shiki-token-constant)",
"#000005": "var(--shiki-token-string)",
"#000006": "var(--shiki-token-comment)",
"#000007": "var(--shiki-token-keyword)",
"#000008": "var(--shiki-token-parameter)",
"#000009": "var(--shiki-token-function)",
"#000010": "var(--shiki-token-string-expression)",
"#000011": "var(--shiki-token-punctuation)",
"#000012": "var(--shiki-token-link)"
};
function setColorReplacements(map2) {
COLOR_REPLACEMENTS = map2;
}
function fixCssVariablesTheme(theme, colorMap) {
theme.bg = COLOR_REPLACEMENTS[theme.bg] || theme.bg;
theme.fg = COLOR_REPLACEMENTS[theme.fg] || theme.fg;
colorMap.forEach((val, i2) => {
colorMap[i2] = COLOR_REPLACEMENTS[val] || val;
});
}
function getTheme(theme) {
const _theme = theme ? _registry.getTheme(theme) : _defaultTheme;
if (!_theme) {
throw Error(`No theme registration for ${theme}`);
}
if (!_currentTheme || _currentTheme.name !== _theme.name) {
_registry.setTheme(_theme);
_currentTheme = _theme;
}
const _colorMap = _registry.getColorMap();
if (_theme.type === "css") {
fixCssVariablesTheme(_theme, _colorMap);
}
return { _theme, _colorMap };
}
function getGrammar(lang) {
const _grammar = _registry.getGrammar(lang);
if (!_grammar) {
throw Error(`No language registration for ${lang}`);
}
return { _grammar };
}
function codeToThemedTokens(code, lang = "text", theme, options2 = { includeExplanation: true }) {
if (isPlaintext(lang)) {
const lines = code.split(/\r\n|\r|\n/);
return [...lines.map((line) => [{ content: line }])];
}
const { _grammar } = getGrammar(lang);
const { _theme, _colorMap } = getTheme(theme);
return tokenizeWithTheme(_theme, _colorMap, code, _grammar, options2);
}
function codeToHtml(code, arg1 = "text", arg2) {
let options2;
if (typeof arg1 === "object") {
options2 = arg1;
} else {
options2 = {
lang: arg1,
theme: arg2
};
}
const tokens = codeToThemedTokens(code, options2.lang, options2.theme, {
includeExplanation: false
});
const { _theme } = getTheme(options2.theme);
return renderToHtml(tokens, {
fg: _theme.fg,
bg: _theme.bg,
lineOptions: options2 == null ? void 0 : options2.lineOptions,
themeName: _theme.name
});
}
async function loadTheme(theme) {
await _registry.loadTheme(theme);
}
async function loadLanguage(lang) {
const _lang = resolveLang(lang);
_resolver.addLanguage(_lang);
await _registry.loadLanguage(_lang);
}
function getLoadedThemes() {
return _registry.getLoadedThemes();
}
function getLoadedLanguages() {
return _registry.getLoadedLanguages();
}
function getBackgroundColor(theme) {
const { _theme } = getTheme(theme);
return _theme.bg;
}
function getForegroundColor(theme) {
const { _theme } = getTheme(theme);
return _theme.fg;
}
return {
codeToThemedTokens,
codeToHtml,
getTheme: (theme) => {
return getTheme(theme)._theme;
},
loadTheme,
loadLanguage,
getBackgroundColor,
getForegroundColor,
getLoadedThemes,
getLoadedLanguages,
setColorReplacements
};
}
function isPlaintext(lang) {
return !lang || ["plaintext", "txt", "text"].includes(lang);
}
const version = "0.2.0";
setCDN(`https://cdn.jsdelivr.net/npm/shiki-es@${version}/dist/assets/`);
var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
var flexsearch_bundle = { exports: {} };
flexsearch_bundle.exports;
(function(module) {
(function _f(self) {
try {
if (module)
self = module;
} catch (e2) {
}
self._factory = _f;
var t;
function u(a2) {
return "undefined" !== typeof a2 ? a2 : true;
}
function aa(a2) {
const b3 = Array(a2);
for (let c2 = 0; c2 < a2; c2++)
b3[c2] = v();
return b3;
}
function v() {
return /* @__PURE__ */ Object.create(null);
}
function ba(a2, b3) {
return b3.length - a2.length;
}
function x(a2) {
return "string" === typeof a2;
}
function C(a2) {
return "object" === typeof a2;
}
function D(a2) {
return "function" === typeof a2;
}
function ca(a2, b3) {
var c2 = da;
if (a2 && (b3 && (a2 = E(a2, b3)), this.H && (a2 = E(a2, this.H)), this.J && 1 < a2.length && (a2 = E(a2, this.J)), c2 || "" === c2)) {
a2 = a2.split(c2);
if (this.filter) {
b3 = this.filter;
c2 = a2.length;
const d2 = [];
for (let e2 = 0, f2 = 0; e2 < c2; e2++) {
const g = a2[e2];
g && !b3[g] && (d2[f2++] = g);
}
a2 = d2;
}
return a2;
}
return a2;
}
const da = /[\p{Z}\p{S}\p{P}\p{C}]+/u, ea = /[\u0300-\u036f]/g;
function fa(a2, b3) {
const c2 = Object.keys(a2), d2 = c2.length, e2 = [];
let f2 = "", g = 0;
for (let h2 = 0, k2, m; h2 < d2; h2++)
k2 = c2[h2], (m = a2[k2]) ? (e2[g++] = F(b3 ? "(?!\\b)" + k2 + "(\\b|_)" : k2), e2[g++] = m) : f2 += (f2 ? "|" : "") + k2;
f2 && (e2[g++] = F(b3 ? "(?!\\b)(" + f2 + ")(\\b|_)" : "(" + f2 + ")"), e2[g] = "");
return e2;
}
function E(a2, b3) {
for (let c2 = 0, d2 = b3.length; c2 < d2 && (a2 = a2.replace(b3[c2], b3[c2 + 1]), a2); c2 += 2)
;
return a2;
}
function F(a2) {
return new RegExp(a2, "g");
}
function ha(a2) {
let b3 = "", c2 = "";
for (let d2 = 0, e2 = a2.length, f2; d2 < e2; d2++)
(f2 = a2[d2]) !== c2 && (b3 += c2 = f2);
return b3;
}
var ja = { encode: ia, F: false, G: "" };
function ia(a2) {
return ca.call(this, ("" + a2).toLowerCase(), false);
}
const ka = {}, G = {};
function la(a2) {
I(a2, "add");
I(a2, "append");
I(a2, "search");
I(a2, "update");
I(a2, "remove");
}
function I(a2, b3) {
a2[b3 + "Async"] = function() {
const c2 = this, d2 = arguments;
var e2 = d2[d2.length - 1];
let f2;
D(e2) && (f2 = e2, delete d2[d2.length - 1]);
e2 = new Promise(function(g) {
setTimeout(function() {
c2.async = true;
const h2 = c2[b3].apply(c2, d2);
c2.async = false;
g(h2);
});
});
return f2 ? (e2.then(f2), this) : e2;
};
}
function ma(a2, b3, c2, d2) {
const e2 = a2.length;
let f2 = [], g, h2, k2 = 0;
d2 && (d2 = []);
for (let m = e2 - 1; 0 <= m; m--) {
const n2 = a2[m], w2 = n2.length, q3 = v();
let r2 = !g;
for (let l = 0; l < w2; l++) {
const p2 = n2[l], z3 = p2.length;
if (z3)
for (let B2 = 0, A2, y2; B2 < z3; B2++)
if (y2 = p2[B2], g) {
if (g[y2]) {
if (!m) {
if (c2)
c2--;
else if (f2[k2++] = y2, k2 === b3)
return f2;
}
if (m || d2)
q3[y2] = 1;
r2 = true;
}
if (d2 && (h2[y2] = (A2 = h2[y2]) ? ++A2 : A2 = 1, A2 < e2)) {
const H4 = d2[A2 - 2] || (d2[A2 - 2] = []);
H4[H4.length] = y2;
}
} else
q3[y2] = 1;
}
if (d2)
g || (h2 = q3);
else if (!r2)
return [];
g = q3;
}
if (d2)
for (let m = d2.length - 1, n2, w2; 0 <= m; m--) {
n2 = d2[m];
w2 = n2.length;
for (let q3 = 0, r2; q3 < w2; q3++)
if (r2 = n2[q3], !g[r2]) {
if (c2)
c2--;
else if (f2[k2++] = r2, k2 === b3)
return f2;
g[r2] = 1;
}
}
return f2;
}
function na(a2, b3) {
const c2 = v(), d2 = v(), e2 = [];
for (let f2 = 0; f2 < a2.length; f2++)
c2[a2[f2]] = 1;
for (let f2 = 0, g; f2 < b3.length; f2++) {
g = b3[f2];
for (let h2 = 0, k2; h2 < g.length; h2++)
k2 = g[h2], c2[k2] && !d2[k2] && (d2[k2] = 1, e2[e2.length] = k2);
}
return e2;
}
function J(a2) {
this.l = true !== a2 && a2;
this.cache = v();
this.h = [];
}
function oa(a2, b3, c2) {
C(a2) && (a2 = a2.query);
let d2 = this.cache.get(a2);
d2 || (d2 = this.search(a2, b3, c2), this.cache.set(a2, d2));
return d2;
}
J.prototype.set = function(a2, b3) {
if (!this.cache[a2]) {
var c2 = this.h.length;
c2 === this.l ? delete this.cache[this.h[c2 - 1]] : c2++;
for (--c2; 0 < c2; c2--)
this.h[c2] = this.h[c2 - 1];
this.h[0] = a2;
}
this.cache[a2] = b3;
};
J.prototype.get = function(a2) {
const b3 = this.cache[a2];
if (this.l && b3 && (a2 = this.h.indexOf(a2))) {
const c2 = this.h[a2 - 1];
this.h[a2 - 1] = this.h[a2];
this.h[a2] = c2;
}
return b3;
};
const qa = { memory: { charset: "latin:extra", D: 3, B: 4, m: false }, performance: { D: 3, B: 3, s: false, context: { depth: 2, D: 1 } }, match: { charset: "latin:extra", G: "reverse" }, score: { charset: "latin:advanced", D: 20, B: 3, context: { depth: 3, D: 9 } }, "default": {} };
function ra(a2, b3, c2, d2, e2, f2) {
setTimeout(function() {
const g = a2(c2, JSON.stringify(f2));
g && g.then ? g.then(function() {
b3.export(a2, b3, c2, d2, e2 + 1);
}) : b3.export(a2, b3, c2, d2, e2 + 1);
});
}
function K(a2, b3) {
if (!(this instanceof K))
return new K(a2);
var c2;
if (a2) {
x(a2) ? a2 = qa[a2] : (c2 = a2.preset) && (a2 = Object.assign({}, c2[c2], a2));
c2 = a2.charset;
var d2 = a2.lang;
x(c2) && (-1 === c2.indexOf(":") && (c2 += ":default"), c2 = G[c2]);
x(d2) && (d2 = ka[d2]);
} else
a2 = {};
let e2, f2, g = a2.context || {};
this.encode = a2.encode || c2 && c2.encode || ia;
this.register = b3 || v();
this.D = e2 = a2.resolution || 9;
this.G = b3 = c2 && c2.G || a2.tokenize || "strict";
this.depth = "strict" === b3 && g.depth;
this.l = u(g.bidirectional);
this.s = f2 = u(a2.optimize);
this.m = u(a2.fastupdate);
this.B = a2.minlength || 1;
this.C = a2.boost;
this.map = f2 ? aa(e2) : v();
this.A = e2 = g.resolution || 1;
this.h = f2 ? aa(e2) : v();
this.F = c2 && c2.F || a2.rtl;
this.H = (b3 = a2.matcher || d2 && d2.H) && fa(b3, false);
this.J = (b3 = a2.stemmer || d2 && d2.J) && fa(b3, true);
if (c2 = b3 = a2.filter || d2 && d2.filter) {
c2 = b3;
d2 = v();
for (let h2 = 0, k2 = c2.length; h2 < k2; h2++)
d2[c2[h2]] = 1;
c2 = d2;
}
this.filter = c2;
this.cache = (b3 = a2.cache) && new J(b3);
}
t = K.prototype;
t.append = function(a2, b3) {
return this.add(a2, b3, true);
};
t.add = function(a2, b3, c2, d2) {
if (b3 && (a2 || 0 === a2)) {
if (!d2 && !c2 && this.register[a2])
return this.update(a2, b3);
b3 = this.encode(b3);
if (d2 = b3.length) {
const m = v(), n2 = v(), w2 = this.depth, q3 = this.D;
for (let r2 = 0; r2 < d2; r2++) {
let l = b3[this.F ? d2 - 1 - r2 : r2];
var e2 = l.length;
if (l && e2 >= this.B && (w2 || !n2[l])) {
var f2 = L(q3, d2, r2), g = "";
switch (this.G) {
case "full":
if (3 < e2) {
for (f2 = 0; f2 < e2; f2++)
for (var h2 = e2; h2 > f2; h2--)
if (h2 - f2 >= this.B) {
var k2 = L(q3, d2, r2, e2, f2);
g = l.substring(f2, h2);
M(this, n2, g, k2, a2, c2);
}
break;
}
case "reverse":
if (2 < e2) {
for (h2 = e2 - 1; 0 < h2; h2--)
g = l[h2] + g, g.length >= this.B && M(
this,
n2,
g,
L(q3, d2, r2, e2, h2),
a2,
c2
);
g = "";
}
case "forward":
if (1 < e2) {
for (h2 = 0; h2 < e2; h2++)
g += l[h2], g.length >= this.B && M(this, n2, g, f2, a2, c2);
break;
}
default:
if (this.C && (f2 = Math.min(f2 / this.C(b3, l, r2) | 0, q3 - 1)), M(this, n2, l, f2, a2, c2), w2 && 1 < d2 && r2 < d2 - 1) {
for (e2 = v(), g = this.A, f2 = l, h2 = Math.min(w2 + 1, d2 - r2), e2[f2] = 1, k2 = 1; k2 < h2; k2++)
if ((l = b3[this.F ? d2 - 1 - r2 - k2 : r2 + k2]) && l.length >= this.B && !e2[l]) {
e2[l] = 1;
const p2 = this.l && l > f2;
M(this, m, p2 ? f2 : l, L(g + (d2 / 2 > g ? 0 : 1), d2, r2, h2 - 1, k2 - 1), a2, c2, p2 ? l : f2);
}
}
}
}
}
this.m || (this.register[a2] = 1);
}
}
return this;
};
function L(a2, b3, c2, d2, e2) {
return c2 && 1 < a2 ? b3 + (d2 || 0) <= a2 ? c2 + (e2 || 0) : (a2 - 1) / (b3 + (d2 || 0)) * (c2 + (e2 || 0)) + 1 | 0 : 0;
}
function M(a2, b3, c2, d2, e2, f2, g) {
let h2 = g ? a2.h : a2.map;
if (!b3[c2] || g && !b3[c2][g])
a2.s && (h2 = h2[d2]), g ? (b3 = b3[c2] || (b3[c2] = v()), b3[g] = 1, h2 = h2[g] || (h2[g] = v())) : b3[c2] = 1, h2 = h2[c2] || (h2[c2] = []), a2.s || (h2 = h2[d2] || (h2[d2] = [])), f2 && -1 !== h2.indexOf(e2) || (h2[h2.length] = e2, a2.m && (a2 = a2.register[e2] || (a2.register[e2] = []), a2[a2.length] = h2));
}
t.search = function(a2, b3, c2) {
c2 || (!b3 && C(a2) ? (c2 = a2, a2 = c2.query) : C(b3) && (c2 = b3));
let d2 = [], e2;
let f2, g = 0;
if (c2) {
b3 = c2.limit;
g = c2.offset || 0;
var h2 = c2.context;
f2 = c2.suggest;
}
if (a2 && (a2 = this.encode(a2), e2 = a2.length, 1 < e2)) {
c2 = v();
var k2 = [];
for (let n2 = 0, w2 = 0, q3; n2 < e2; n2++)
if ((q3 = a2[n2]) && q3.length >= this.B && !c2[q3])
if (this.s || f2 || this.map[q3])
k2[w2++] = q3, c2[q3] = 1;
else
return d2;
a2 = k2;
e2 = a2.length;
}
if (!e2)
return d2;
b3 || (b3 = 100);
h2 = this.depth && 1 < e2 && false !== h2;
c2 = 0;
let m;
h2 ? (m = a2[0], c2 = 1) : 1 < e2 && a2.sort(ba);
for (let n2, w2; c2 < e2; c2++) {
w2 = a2[c2];
h2 ? (n2 = sa(this, d2, f2, b3, g, 2 === e2, w2, m), f2 && false === n2 && d2.length || (m = w2)) : n2 = sa(this, d2, f2, b3, g, 1 === e2, w2);
if (n2)
return n2;
if (f2 && c2 === e2 - 1) {
k2 = d2.length;
if (!k2) {
if (h2) {
h2 = 0;
c2 = -1;
continue;
}
return d2;
}
if (1 === k2)
return ta(d2[0], b3, g);
}
}
return ma(d2, b3, g, f2);
};
function sa(a2, b3, c2, d2, e2, f2, g, h2) {
let k2 = [], m = h2 ? a2.h : a2.map;
a2.s || (m = ua(m, g, h2, a2.l));
if (m) {
let n2 = 0;
const w2 = Math.min(m.length, h2 ? a2.A : a2.D);
for (let q3 = 0, r2 = 0, l, p2; q3 < w2; q3++)
if (l = m[q3]) {
if (a2.s && (l = ua(l, g, h2, a2.l)), e2 && l && f2 && (p2 = l.length, p2 <= e2 ? (e2 -= p2, l = null) : (l = l.slice(e2), e2 = 0)), l && (k2[n2++] = l, f2 && (r2 += l.length, r2 >= d2)))
break;
}
if (n2) {
if (f2)
return ta(k2, d2, 0);
b3[b3.length] = k2;
return;
}
}
return !c2 && k2;
}
function ta(a2, b3, c2) {
a2 = 1 === a2.length ? a2[0] : [].concat.apply([], a2);
return c2 || a2.length > b3 ? a2.slice(c2, c2 + b3) : a2;
}
function ua(a2, b3, c2, d2) {
c2 ? (d2 = d2 && b3 > c2, a2 = (a2 = a2[d2 ? b3 : c2]) && a2[d2 ? c2 : b3]) : a2 = a2[b3];
return a2;
}
t.contain = function(a2) {
return !!this.register[a2];
};
t.update = function(a2, b3) {
return this.remove(a2).add(a2, b3);
};
t.remove = function(a2, b3) {
const c2 = this.register[a2];
if (c2) {
if (this.m)
for (let d2 = 0, e2; d2 < c2.length; d2++)
e2 = c2[d2], e2.splice(e2.indexOf(a2), 1);
else
N(this.map, a2, this.D, this.s), this.depth && N(this.h, a2, this.A, this.s);
b3 || delete this.register[a2];
if (this.cache) {
b3 = this.cache;
for (let d2 = 0, e2, f2; d2 < b3.h.length; d2++)
f2 = b3.h[d2], e2 = b3.cache[f2], -1 !== e2.indexOf(a2) && (b3.h.splice(d2--, 1), delete b3.cache[f2]);
}
}
return this;
};
function N(a2, b3, c2, d2, e2) {
let f2 = 0;
if (a2.constructor === Array)
if (e2)
b3 = a2.indexOf(b3), -1 !== b3 ? 1 < a2.length && (a2.splice(b3, 1), f2++) : f2++;
else {
e2 = Math.min(a2.length, c2);
for (let g = 0, h2; g < e2; g++)
if (h2 = a2[g])
f2 = N(h2, b3, c2, d2, e2), d2 || f2 || delete a2[g];
}
else
for (let g in a2)
(f2 = N(a2[g], b3, c2, d2, e2)) || delete a2[g];
return f2;
}
t.searchCache = oa;
t.export = function(a2, b3, c2, d2, e2) {
let f2, g;
switch (e2 || (e2 = 0)) {
case 0:
f2 = "reg";
if (this.m) {
g = v();
for (let h2 in this.register)
g[h2] = 1;
} else
g = this.register;
break;
case 1:
f2 = "cfg";
g = { doc: 0, opt: this.s ? 1 : 0 };
break;
case 2:
f2 = "map";
g = this.map;
break;
case 3:
f2 = "ctx";
g = this.h;
break;
default:
return;
}
ra(a2, b3 || this, c2 ? c2 + "." + f2 : f2, d2, e2, g);
return true;
};
t.import = function(a2, b3) {
if (b3)
switch (x(b3) && (b3 = JSON.parse(b3)), a2) {
case "cfg":
this.s = !!b3.opt;
break;
case "reg":
this.m = false;
this.register = b3;
break;
case "map":
this.map = b3;
break;
case "ctx":
this.h = b3;
}
};
la(K.prototype);
function va(a2) {
a2 = a2.data;
var b3 = self._index;
const c2 = a2.args;
var d2 = a2.task;
switch (d2) {
case "init":
d2 = a2.options || {};
a2 = a2.factory;
b3 = d2.encode;
d2.cache = false;
b3 && 0 === b3.indexOf("function") && (d2.encode = Function("return " + b3)());
a2 ? (Function("return " + a2)()(self), self._index = new self.FlexSearch.Index(d2), delete self.FlexSearch) : self._index = new K(d2);
break;
default:
a2 = a2.id, b3 = b3[d2].apply(b3, c2), postMessage("search" === d2 ? { id: a2, msg: b3 } : { id: a2 });
}
}
let wa = 0;
function O(a2) {
if (!(this instanceof O))
return new O(a2);
var b3;
a2 ? D(b3 = a2.encode) && (a2.encode = b3.toString()) : a2 = {};
(b3 = (self || window)._factory) && (b3 = b3.toString());
const c2 = self.exports, d2 = this;
this.o = xa(b3, c2, a2.worker);
this.h = v();
if (this.o) {
if (c2)
this.o.on("message", function(e2) {
d2.h[e2.id](e2.msg);
delete d2.h[e2.id];
});
else
this.o.onmessage = function(e2) {
e2 = e2.data;
d2.h[e2.id](e2.msg);
delete d2.h[e2.id];
};
this.o.postMessage({ task: "init", factory: b3, options: a2 });
}
}
P("add");
P("append");
P("search");
P("update");
P("remove");
function P(a2) {
O.prototype[a2] = O.prototype[a2 + "Async"] = function() {
const b3 = this, c2 = [].slice.call(arguments);
var d2 = c2[c2.length - 1];
let e2;
D(d2) && (e2 = d2, c2.splice(c2.length - 1, 1));
d2 = new Promise(function(f2) {
setTimeout(function() {
b3.h[++wa] = f2;
b3.o.postMessage({ task: a2, id: wa, args: c2 });
});
});
return e2 ? (d2.then(e2), this) : d2;
};
}
function xa(a, b, c) {
let d;
try {
d = b ? eval('new (require("worker_threads")["Worker"])("../dist/node/node.js")') : a ? new Worker(URL.createObjectURL(new Blob(["onmessage=" + va.toString()], { type: "text/javascript" }))) : new Worker(x(c) ? c : "worker/worker.js", { type: "module" });
} catch (e2) {
}
return d;
}
function Q(a2) {
if (!(this instanceof Q))
return new Q(a2);
var b3 = a2.document || a2.doc || a2, c2;
this.K = [];
this.h = [];
this.A = [];
this.register = v();
this.key = (c2 = b3.key || b3.id) && S(c2, this.A) || "id";
this.m = u(a2.fastupdate);
this.C = (c2 = b3.store) && true !== c2 && [];
this.store = c2 && v();
this.I = (c2 = b3.tag) && S(c2, this.A);
this.l = c2 && v();
this.cache = (c2 = a2.cache) && new J(c2);
a2.cache = false;
this.o = a2.worker;
this.async = false;
c2 = v();
let d2 = b3.index || b3.field || b3;
x(d2) && (d2 = [d2]);
for (let e2 = 0, f2, g; e2 < d2.length; e2++)
f2 = d2[e2], x(f2) || (g = f2, f2 = f2.field), g = C(g) ? Object.assign({}, a2, g) : a2, this.o && (c2[f2] = new O(g), c2[f2].o || (this.o = false)), this.o || (c2[f2] = new K(g, this.register)), this.K[e2] = S(f2, this.A), this.h[e2] = f2;
if (this.C)
for (a2 = b3.store, x(a2) && (a2 = [a2]), b3 = 0; b3 < a2.length; b3++)
this.C[b3] = S(a2[b3], this.A);
this.index = c2;
}
function S(a2, b3) {
const c2 = a2.split(":");
let d2 = 0;
for (let e2 = 0; e2 < c2.length; e2++)
a2 = c2[e2], 0 <= a2.indexOf("[]") && (a2 = a2.substring(0, a2.length - 2)) && (b3[d2] = true), a2 && (c2[d2++] = a2);
d2 < c2.length && (c2.length = d2);
return 1 < d2 ? c2 : c2[0];
}
function T(a2, b3) {
if (x(b3))
a2 = a2[b3];
else
for (let c2 = 0; a2 && c2 < b3.length; c2++)
a2 = a2[b3[c2]];
return a2;
}
function U(a2, b3, c2, d2, e2) {
a2 = a2[e2];
if (d2 === c2.length - 1)
b3[e2] = a2;
else if (a2)
if (a2.constructor === Array)
for (b3 = b3[e2] = Array(a2.length), e2 = 0; e2 < a2.length; e2++)
U(a2, b3, c2, d2, e2);
else
b3 = b3[e2] || (b3[e2] = v()), e2 = c2[++d2], U(a2, b3, c2, d2, e2);
}
function V(a2, b3, c2, d2, e2, f2, g, h2) {
if (a2 = a2[g])
if (d2 === b3.length - 1) {
if (a2.constructor === Array) {
if (c2[d2]) {
for (b3 = 0; b3 < a2.length; b3++)
e2.add(f2, a2[b3], true, true);
return;
}
a2 = a2.join(" ");
}
e2.add(f2, a2, h2, true);
} else if (a2.constructor === Array)
for (g = 0; g < a2.length; g++)
V(a2, b3, c2, d2, e2, f2, g, h2);
else
g = b3[++d2], V(a2, b3, c2, d2, e2, f2, g, h2);
}
t = Q.prototype;
t.add = function(a2, b3, c2) {
C(a2) && (b3 = a2, a2 = T(b3, this.key));
if (b3 && (a2 || 0 === a2)) {
if (!c2 && this.register[a2])
return this.update(a2, b3);
for (let d2 = 0, e2, f2; d2 < this.h.length; d2++)
f2 = this.h[d2], e2 = this.K[d2], x(e2) && (e2 = [e2]), V(b3, e2, this.A, 0, this.index[f2], a2, e2[0], c2);
if (this.I) {
let d2 = T(b3, this.I), e2 = v();
x(d2) && (d2 = [d2]);
for (let f2 = 0, g, h2; f2 < d2.length; f2++)
if (g = d2[f2], !e2[g] && (e2[g] = 1, h2 = this.l[g] || (this.l[g] = []), !c2 || -1 === h2.indexOf(a2))) {
if (h2[h2.length] = a2, this.m) {
const k2 = this.register[a2] || (this.register[a2] = []);
k2[k2.length] = h2;
}
}
}
if (this.store && (!c2 || !this.store[a2])) {
let d2;
if (this.C) {
d2 = v();
for (let e2 = 0, f2; e2 < this.C.length; e2++)
f2 = this.C[e2], x(f2) ? d2[f2] = b3[f2] : U(b3, d2, f2, 0, f2[0]);
}
this.store[a2] = d2 || b3;
}
}
return this;
};
t.append = function(a2, b3) {
return this.add(a2, b3, true);
};
t.update = function(a2, b3) {
return this.remove(a2).add(a2, b3);
};
t.remove = function(a2) {
C(a2) && (a2 = T(a2, this.key));
if (this.register[a2]) {
for (var b3 = 0; b3 < this.h.length && (this.index[this.h[b3]].remove(a2, !this.o), !this.m); b3++)
;
if (this.I && !this.m)
for (let c2 in this.l) {
b3 = this.l[c2];
const d2 = b3.indexOf(a2);
-1 !== d2 && (1 < b3.length ? b3.splice(d2, 1) : delete this.l[c2]);
}
this.store && delete this.store[a2];
delete this.register[a2];
}
return this;
};
t.search = function(a2, b3, c2, d2) {
c2 || (!b3 && C(a2) ? (c2 = a2, a2 = c2.query) : C(b3) && (c2 = b3, b3 = 0));
let e2 = [], f2 = [], g, h2, k2, m, n2, w2, q3 = 0;
if (c2)
if (c2.constructor === Array)
k2 = c2, c2 = null;
else {
k2 = (g = c2.pluck) || c2.index || c2.field;
m = c2.tag;
h2 = this.store && c2.enrich;
n2 = "and" === c2.bool;
b3 = c2.limit || 100;
w2 = c2.offset || 0;
if (m && (x(m) && (m = [m]), !a2)) {
for (let l = 0, p2; l < m.length; l++)
if (p2 = ya.call(this, m[l], b3, w2, h2))
e2[e2.length] = p2, q3++;
return q3 ? e2 : [];
}
x(k2) && (k2 = [k2]);
}
k2 || (k2 = this.h);
n2 = n2 && (1 < k2.length || m && 1 < m.length);
const r2 = !d2 && (this.o || this.async) && [];
for (let l = 0, p2, z3, B2; l < k2.length; l++) {
let A2;
z3 = k2[l];
x(z3) || (A2 = z3, z3 = z3.field);
if (r2)
r2[l] = this.index[z3].searchAsync(a2, b3, A2 || c2);
else {
d2 ? p2 = d2[l] : p2 = this.index[z3].search(a2, b3, A2 || c2);
B2 = p2 && p2.length;
if (m && B2) {
const y2 = [];
let H4 = 0;
n2 && (y2[0] = [p2]);
for (let X2 = 0, pa2, R3; X2 < m.length; X2++)
if (pa2 = m[X2], B2 = (R3 = this.l[pa2]) && R3.length)
H4++, y2[y2.length] = n2 ? [R3] : R3;
H4 && (p2 = n2 ? ma(y2, b3 || 100, w2 || 0) : na(p2, y2), B2 = p2.length);
}
if (B2)
f2[q3] = z3, e2[q3++] = p2;
else if (n2)
return [];
}
}
if (r2) {
const l = this;
return new Promise(function(p2) {
Promise.all(r2).then(function(z3) {
p2(l.search(a2, b3, c2, z3));
});
});
}
if (!q3)
return [];
if (g && (!h2 || !this.store))
return e2[0];
for (let l = 0, p2; l < f2.length; l++) {
p2 = e2[l];
p2.length && h2 && (p2 = za.call(this, p2));
if (g)
return p2;
e2[l] = { field: f2[l], result: p2 };
}
return e2;
};
function ya(a2, b3, c2, d2) {
let e2 = this.l[a2], f2 = e2 && e2.length - c2;
if (f2 && 0 < f2) {
if (f2 > b3 || c2)
e2 = e2.slice(c2, c2 + b3);
d2 && (e2 = za.call(this, e2));
return { tag: a2, result: e2 };
}
}
function za(a2) {
const b3 = Array(a2.length);
for (let c2 = 0, d2; c2 < a2.length; c2++)
d2 = a2[c2], b3[c2] = { id: d2, doc: this.store[d2] };
return b3;
}
t.contain = function(a2) {
return !!this.register[a2];
};
t.get = function(a2) {
return this.store[a2];
};
t.set = function(a2, b3) {
this.store[a2] = b3;
return this;
};
t.searchCache = oa;
t.export = function(a2, b3, c2, d2, e2) {
e2 || (e2 = 0);
d2 || (d2 = 0);
if (d2 < this.h.length) {
const f2 = this.h[d2], g = this.index[f2];
b3 = this;
setTimeout(function() {
g.export(a2, b3, e2 ? f2.replace(":", "-") : "", d2, e2++) || (d2++, e2 = 1, b3.export(a2, b3, f2, d2, e2));
});
} else {
let f2;
switch (e2) {
case 1:
c2 = "tag";
f2 = this.l;
break;
case 2:
c2 = "store";
f2 = this.store;
break;
default:
return;
}
ra(a2, this, c2, d2, e2, f2);
}
};
t.import = function(a2, b3) {
if (b3)
switch (x(b3) && (b3 = JSON.parse(b3)), a2) {
case "tag":
this.l = b3;
break;
case "reg":
this.m = false;
this.register = b3;
for (let d2 = 0, e2; d2 < this.h.length; d2++)
e2 = this.index[this.h[d2]], e2.register = b3, e2.m = false;
break;
case "store":
this.store = b3;
break;
default:
a2 = a2.split(".");
const c2 = a2[0];
a2 = a2[1];
c2 && a2 && this.index[c2].import(a2, b3);
}
};
la(Q.prototype);
var Ba = { encode: Aa, F: false, G: "" };
const Ca = [F("[àáâãäå]"), "a", F("[èéêë]"), "e", F("[ìíîï]"), "i", F("[òóôõöő]"), "o", F("[ùúûüű]"), "u", F("[ýŷÿ]"), "y", F("ñ"), "n", F("[çc]"), "k", F("ß"), "s", F(" & "), " and "];
function Aa(a2) {
var b3 = a2;
b3.normalize && (b3 = b3.normalize("NFD").replace(ea, ""));
return ca.call(this, b3.toLowerCase(), !a2.normalize && Ca);
}
var Ea = { encode: Da, F: false, G: "strict" };
const Fa = /[^a-z0-9]+/, Ga = { b: "p", v: "f", w: "f", z: "s", x: "s", "ß": "s", d: "t", n: "m", c: "k", g: "k", j: "k", q: "k", i: "e", y: "e", u: "o" };
function Da(a2) {
a2 = Aa.call(this, a2).join(" ");
const b3 = [];
if (a2) {
const c2 = a2.split(Fa), d2 = c2.length;
for (let e2 = 0, f2, g = 0; e2 < d2; e2++)
if ((a2 = c2[e2]) && (!this.filter || !this.filter[a2])) {
f2 = a2[0];
let h2 = Ga[f2] || f2, k2 = h2;
for (let m = 1; m < a2.length; m++) {
f2 = a2[m];
const n2 = Ga[f2] || f2;
n2 && n2 !== k2 && (h2 += n2, k2 = n2);
}
b3[g++] = h2;
}
}
return b3;
}
var Ia = { encode: Ha, F: false, G: "" };
const Ja = [F("ae"), "a", F("oe"), "o", F("sh"), "s", F("th"), "t", F("ph"), "f", F("pf"), "f", F("(?![aeo])h(?![aeo])"), "", F("(?!^[aeo])h(?!^[aeo])"), ""];
function Ha(a2, b3) {
a2 && (a2 = Da.call(this, a2).join(" "), 2 < a2.length && (a2 = E(a2, Ja)), b3 || (1 < a2.length && (a2 = ha(a2)), a2 && (a2 = a2.split(" "))));
return a2;
}
var La = { encode: Ka, F: false, G: "" };
const Ma = F("(?!\\b)[aeo]");
function Ka(a2) {
a2 && (a2 = Ha.call(this, a2, true), 1 < a2.length && (a2 = a2.replace(Ma, "")), 1 < a2.length && (a2 = ha(a2)), a2 && (a2 = a2.split(" ")));
return a2;
}
G["latin:default"] = ja;
G["latin:simple"] = Ba;
G["latin:balance"] = Ea;
G["latin:advanced"] = Ia;
G["latin:extra"] = La;
const W = self;
let Y;
const Z = { Index: K, Document: Q, Worker: O, registerCharset: function(a2, b3) {
G[a2] = b3;
}, registerLanguage: function(a2, b3) {
ka[a2] = b3;
} };
(Y = W.define) && Y.amd ? Y([], function() {
return Z;
}) : W.exports ? W.exports = Z : W.FlexSearch = Z;
})(commonjsGlobal);
})(flexsearch_bundle);
var flexsearch_bundleExports = flexsearch_bundle.exports;
const MountStory = /* @__PURE__ */ defineComponent({
name: "MountStory",
props: {
story: {
type: Object,
required: true
}
},
setup(props) {
const options = props.story.file.component;
let rawVariants = [];
if (options.onMount) {
rawVariants = [{
id: "_default",
title: "default",
onMount: options.onMount,
onMountControls: options.onMountControls
}];
} else {
rawVariants = options.variants;
}
for (const index2 in props.story.variants) {
const rawVariant = rawVariants[index2];
Object.assign(props.story.variants[index2], {
slots: () => ({ default: rawVariant.onMount, controls: rawVariant.onMountControls }),
source: rawVariant.source ?? options.source,
responsiveDisabled: rawVariant.responsiveDisabled ?? options.responsiveDisabled,
autoPropsDisabled: rawVariant.autoPropsDisabled ?? options.autoPropsDisabled,
setupApp: rawVariant.setupApp ?? options.setupApp,
configReady: true
});
}
},
render() {
return null;
}
});
const r = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null
}, Symbol.toStringTag, { value: "Module" }));
const a = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null
}, Symbol.toStringTag, { value: "Module" }));
const RenderStory = /* @__PURE__ */ defineComponent({
name: "RenderStory",
props: {
variant: {
type: Object,
required: true
},
story: {
type: Object,
required: true
},
slotName: {
type: String,
default: "default"
}
},
emits: {
ready: () => true
},
setup(props, { emit: emit2 }) {
const sandbox = ref();
let mounting = false;
let app;
let appHooks;
async function unmountVariant() {
var _a2;
if (app) {
await ((_a2 = app.onUnmount) == null ? void 0 : _a2.call(app));
if (appHooks) {
for (const hook of appHooks.onUnmount) {
await hook();
}
}
app.el.parentNode.removeChild(app.el);
app = null;
}
}
async function mountVariant() {
var _a2;
if (mounting)
return;
mounting = true;
await unmountVariant();
app = {
el: document.createElement("div")
};
if (typeof props.variant.setupApp === "function") {
await props.variant.setupApp({
app,
story: props.story,
variant: props.variant
});
}
await ((_a2 = app.onMount) == null ? void 0 : _a2.call(app));
appHooks = {
onUpdate: [],
onUnmount: []
};
const api = {
el: app.el,
state: props.variant.state,
onUpdate: (cb) => {
appHooks.onUpdate.push(cb);
},
onUnmount: (cb) => {
appHooks.onUnmount.push(cb);
}
};
const onMount2 = props.variant.slots()[props.slotName];
await onMount2(api);
sandbox.value.appendChild(app.el);
emit2("ready");
}
onMounted(async () => {
if (props.variant.configReady) {
await mountVariant();
}
});
watch(() => props.variant, async (value) => {
if (value.configReady && !mounting) {
if (!app) {
await mountVariant();
}
}
}, {
deep: true
});
watch(() => props.variant.state, async () => {
if (appHooks) {
for (const hook of appHooks.onUpdate) {
await hook();
}
}
}, {
deep: true
});
onBeforeUnmount(() => {
unmountVariant();
});
return {
sandbox
};
},
render() {
return h$2("div", {
ref: "sandbox"
});
}
});
function generateSourceCode() {
}
const client = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
MountStory,
RenderStory,
generateSourceCode
}, Symbol.toStringTag, { value: "Module" }));
function j(a2) {
let e2, s, o = false;
return { c() {
e2 = empty();
}, m(l, i2) {
insert(l, e2, i2), s = true;
}, p(l, [i2]) {
}, i(l) {
s || (transition_in(o), s = true);
}, o(l) {
transition_out(o), s = false;
}, d(l) {
l && detach(e2);
} };
}
function O$2(a2, e2, s) {
let { $$slots: o = {}, $$scope: l } = e2;
const i2 = compute_slots(o);
let { source: f2 = null } = e2, { responsiveDisabled: c2 = false } = e2, { autoPropsDisabled: u2 = false } = e2, { setupApp: r2 = null } = e2, { implicit: _2 = false } = e2;
const n2 = getContext("__hstStory"), d2 = getContext("__hstIndex"), b3 = getContext("__hstSlots"), D3 = n2.variants[d2.value];
d2.value++;
function p2() {
var t2;
Object.assign(D3, { slots: () => ({ default: true, controls: i2.controls ?? b3.controls }), source: f2, responsiveDisabled: c2, autoPropsDisabled: u2, setupApp: r2, configReady: true }), !_2 && !((t2 = n2.meta) != null && t2.hasVariantChildComponents) && (n2.meta = n2.meta || {}, Object.assign(n2.meta, { hasVariantChildComponents: true }));
}
return p2(), afterUpdate(() => {
p2();
}), a2.$$set = (t2) => {
"source" in t2 && s(0, f2 = t2.source), "responsiveDisabled" in t2 && s(1, c2 = t2.responsiveDisabled), "autoPropsDisabled" in t2 && s(2, u2 = t2.autoPropsDisabled), "setupApp" in t2 && s(3, r2 = t2.setupApp), "implicit" in t2 && s(4, _2 = t2.implicit), "$$scope" in t2 && s(5, l = t2.$$scope);
}, [f2, c2, u2, r2, _2, l, o];
}
class E extends SvelteComponent {
constructor(e2) {
super(), init(this, e2, O$2, j, safe_not_equal, { source: 0, responsiveDisabled: 1, autoPropsDisabled: 2, setupApp: 3, implicit: 4 });
}
}
const G = (s) => ({}), S = (s) => ({ slot: "controls" });
function H$2(s) {
let o;
const r2 = s[3].default, e2 = create_slot(r2, s, s[4], null);
return { c() {
e2 && e2.c();
}, m(t2, n2) {
e2 && e2.m(t2, n2), o = true;
}, p(t2, n2) {
e2 && e2.p && (!o || n2 & 16) && update_slot_base(e2, r2, t2, t2[4], o ? get_slot_changes(r2, t2[4], n2, null) : get_all_dirty_from_scope(t2[4]), null);
}, i(t2) {
o || (transition_in(e2, t2), o = true);
}, o(t2) {
transition_out(e2, t2), o = false;
}, d(t2) {
e2 && e2.d(t2);
} };
}
function J(s) {
let o, r2;
const e2 = [s[0], s[2], { implicit: true }];
let t2 = { $$slots: { controls: [L], default: [K] }, $$scope: { ctx: s } };
for (let n2 = 0; n2 < e2.length; n2 += 1)
t2 = assign$1(t2, e2[n2]);
return o = new E({ props: t2 }), { c() {
create_component(o.$$.fragment);
}, m(n2, l) {
mount_component(o, n2, l), r2 = true;
}, p(n2, l) {
const c2 = l & 5 ? get_spread_update(e2, [l & 1 && get_spread_object(n2[0]), l & 4 && get_spread_object(n2[2]), e2[2]]) : {};
l & 16 && (c2.$$scope = { dirty: l, ctx: n2 }), o.$set(c2);
}, i(n2) {
r2 || (transition_in(o.$$.fragment, n2), r2 = true);
}, o(n2) {
transition_out(o.$$.fragment, n2), r2 = false;
}, d(n2) {
destroy_component(o, n2);
} };
}
function K(s) {
let o;
const r2 = s[3].default, e2 = create_slot(r2, s, s[4], null);
return { c() {
e2 && e2.c();
}, m(t2, n2) {
e2 && e2.m(t2, n2), o = true;
}, p(t2, n2) {
e2 && e2.p && (!o || n2 & 16) && update_slot_base(e2, r2, t2, t2[4], o ? get_slot_changes(r2, t2[4], n2, null) : get_all_dirty_from_scope(t2[4]), null);
}, i(t2) {
o || (transition_in(e2, t2), o = true);
}, o(t2) {
transition_out(e2, t2), o = false;
}, d(t2) {
e2 && e2.d(t2);
} };
}
function L(s) {
let o;
const r2 = s[3].controls, e2 = create_slot(r2, s, s[4], S);
return { c() {
e2 && e2.c();
}, m(t2, n2) {
e2 && e2.m(t2, n2), o = true;
}, p(t2, n2) {
e2 && e2.p && (!o || n2 & 16) && update_slot_base(e2, r2, t2, t2[4], o ? get_slot_changes(r2, t2[4], n2, G) : get_all_dirty_from_scope(t2[4]), S);
}, i(t2) {
o || (transition_in(e2, t2), o = true);
}, o(t2) {
transition_out(e2, t2), o = false;
}, d(t2) {
e2 && e2.d(t2);
} };
}
function N$1(s) {
let o, r2, e2, t2;
const n2 = [J, H$2], l = [];
function c2(u2, i2) {
return u2[1].variants.length === 1 && u2[1].variants[0].id === "_default" ? 0 : 1;
}
return o = c2(s), r2 = l[o] = n2[o](s), { c() {
r2.c(), e2 = empty();
}, m(u2, i2) {
l[o].m(u2, i2), insert(u2, e2, i2), t2 = true;
}, p(u2, [i2]) {
r2.p(u2, i2);
}, i(u2) {
t2 || (transition_in(r2), t2 = true);
}, o(u2) {
transition_out(r2), t2 = false;
}, d(u2) {
u2 && detach(e2), l[o].d(u2);
} };
}
function Q(s, o, r2) {
let e2;
const t2 = [];
let n2 = compute_rest_props(o, t2), { $$slots: l = {}, $$scope: c2 } = o;
const u2 = compute_slots(l), i2 = getContext("__hstStory");
return setContext("__hstIndex", { value: 0 }), setContext("__hstSlots", u2), s.$$set = (_2) => {
o = assign$1(assign$1({}, o), exclude_internal_props(_2)), r2(2, n2 = compute_rest_props(o, t2)), "$$scope" in _2 && r2(4, c2 = _2.$$scope);
}, r2(0, e2 = Object.keys(i2).filter((_2) => !omitInheritStoryProps.includes(_2)).reduce((_2, h2) => (_2[h2] = i2[h2], _2), {})), [e2, i2, n2, l, c2];
}
class Z extends SvelteComponent {
constructor(o) {
super(), init(this, o, Q, N$1, safe_not_equal, {});
}
}
class u extends SvelteComponent {
constructor(t2) {
super(), init(this, t2, null, null, safe_not_equal, {});
}
}
const O$1 = /* @__PURE__ */ defineComponent({ name: "MountStory", props: { story: { type: Object, required: true } }, setup(e2) {
const s = ref();
let i2, n2;
async function u2() {
n2 = document.createElement("div"), s.value.appendChild(n2), i2 = new e2.story.file.component({ target: n2, props: { Hst: { Story: Z, Variant: E, ...h$1() } }, context: new Map(Object.entries({ __hstStory: e2.story })) });
const r$12 = { app: i2, story: e2.story, variant: null };
typeof (a == null ? void 0 : void 0) == "function" && await (void 0)(r$12), typeof (r == null ? void 0 : void 0) == "function" && await (void 0)(r$12), typeof (a == null ? void 0 : void 0) == "function" && await (void 0)(r$12), typeof (r == null ? void 0 : void 0) == "function" && await (void 0)(r$12);
}
function a$1() {
var r2;
i2 == null || i2.$destroy(), n2 && ((r2 = n2.parentNode) == null || r2.removeChild(n2), n2 = null);
}
return watch(() => e2.story.id, async () => {
a$1(), await u2();
}), onMounted(async () => {
await u2();
}), onUnmounted(() => {
a$1();
}), { el: s };
}, render() {
return h$2("div", { ref: "el" });
} });
function h$1() {
const e2 = {};
for (const s in Nm)
e2[s.substring(3)] = u;
return e2;
}
const I$1 = (l) => ({}), h = (l) => ({});
function N(l) {
let o;
const i2 = l[4].controls, e2 = create_slot(i2, l, l[3], h);
return { c() {
e2 && e2.c();
}, m(t2, n2) {
e2 && e2.m(t2, n2), o = true;
}, p(t2, n2) {
e2 && e2.p && (!o || n2 & 8) && update_slot_base(e2, i2, t2, t2[3], o ? get_slot_changes(i2, t2[3], n2, I$1) : get_all_dirty_from_scope(t2[3]), h);
}, i(t2) {
o || (transition_in(e2, t2), o = true);
}, o(t2) {
transition_out(e2, t2), o = false;
}, d(t2) {
e2 && e2.d(t2);
} };
}
function O(l) {
let o;
const i2 = l[4].default, e2 = create_slot(i2, l, l[3], null);
return { c() {
e2 && e2.c();
}, m(t2, n2) {
e2 && e2.m(t2, n2), o = true;
}, p(t2, n2) {
e2 && e2.p && (!o || n2 & 8) && update_slot_base(e2, i2, t2, t2[3], o ? get_slot_changes(i2, t2[3], n2, null) : get_all_dirty_from_scope(t2[3]), null);
}, i(t2) {
o || (transition_in(e2, t2), o = true);
}, o(t2) {
transition_out(e2, t2), o = false;
}, d(t2) {
e2 && e2.d(t2);
} };
}
function R(l) {
var u2;
let o, i2, e2, t2 = l[1] === "controls" && N(l), n2 = (l[1] === "default" || ((u2 = l[0].meta) == null ? void 0 : u2.hasVariantChildComponents)) && O(l);
return { c() {
t2 && t2.c(), o = space(), n2 && n2.c(), i2 = empty();
}, m(s, r2) {
t2 && t2.m(s, r2), insert(s, o, r2), n2 && n2.m(s, r2), insert(s, i2, r2), e2 = true;
}, p(s, [r2]) {
var f2;
s[1] === "controls" && t2.p(s, r2), (s[1] === "default" || (f2 = s[0].meta) != null && f2.hasVariantChildComponents) && n2.p(s, r2);
}, i(s) {
e2 || (transition_in(t2), transition_in(n2), e2 = true);
}, o(s) {
transition_out(t2), transition_out(n2), e2 = false;
}, d(s) {
s && (detach(o), detach(i2)), t2 && t2.d(s), n2 && n2.d(s);
} };
}
function w$1(l, o, i2) {
let { $$slots: e2 = {}, $$scope: t2 } = o;
const n2 = getContext("__hstStory"), u2 = getContext("__hstVariant"), s = getContext("__hstSlot");
setContext("__hstIndex", { value: 0 });
let { source: f2 = null } = o;
return l.$$set = (_2) => {
"source" in _2 && i2(2, f2 = _2.source), "$$scope" in _2 && i2(3, t2 = _2.$$scope);
}, l.$$.update = () => {
l.$$.dirty & 4 && f2 != null && Object.assign(u2, { source: f2 });
}, [n2, s, f2, t2, e2];
}
let D$1 = class D2 extends SvelteComponent {
constructor(o) {
super(), init(this, o, w$1, R, safe_not_equal, { source: 2 });
}
};
const w = (n2) => ({}), b = (n2) => ({});
function k(n2) {
let o, i2, t2, e2 = n2[1] === "default" && z$1(n2), l = n2[1] === "controls" && A(n2);
return { c() {
e2 && e2.c(), o = space(), l && l.c(), i2 = empty();
}, m(r2, s) {
e2 && e2.m(r2, s), insert(r2, o, s), l && l.m(r2, s), insert(r2, i2, s), t2 = true;
}, p(r2, s) {
r2[1] === "default" && e2.p(r2, s), r2[1] === "controls" && l.p(r2, s);
}, i(r2) {
t2 || (transition_in(e2), transition_in(l), t2 = true);
}, o(r2) {
transition_out(e2), transition_out(l), t2 = false;
}, d(r2) {
r2 && (detach(o), detach(i2)), e2 && e2.d(r2), l && l.d(r2);
} };
}
function z$1(n2) {
let o;
const i2 = n2[4].default, t2 = create_slot(i2, n2, n2[3], null);
return { c() {
t2 && t2.c();
}, m(e2, l) {
t2 && t2.m(e2, l), o = true;
}, p(e2, l) {
t2 && t2.p && (!o || l & 8) && update_slot_base(t2, i2, e2, e2[3], o ? get_slot_changes(i2, e2[3], l, null) : get_all_dirty_from_scope(e2[3]), null);
}, i(e2) {
o || (transition_in(t2, e2), o = true);
}, o(e2) {
transition_out(t2, e2), o = false;
}, d(e2) {
t2 && t2.d(e2);
} };
}
function A(n2) {
let o;
const i2 = n2[4].controls, t2 = create_slot(i2, n2, n2[3], b);
return { c() {
t2 && t2.c();
}, m(e2, l) {
t2 && t2.m(e2, l), o = true;
}, p(e2, l) {
t2 && t2.p && (!o || l & 8) && update_slot_base(t2, i2, e2, e2[3], o ? get_slot_changes(i2, e2[3], l, w) : get_all_dirty_from_scope(e2[3]), b);
}, i(e2) {
o || (transition_in(t2, e2), o = true);
}, o(e2) {
transition_out(t2, e2), o = false;
}, d(e2) {
t2 && t2.d(e2);
} };
}
function B(n2) {
let o, i2, t2 = n2[0] && k(n2);
return { c() {
t2 && t2.c(), o = empty();
}, m(e2, l) {
t2 && t2.m(e2, l), insert(e2, o, l), i2 = true;
}, p(e2, [l]) {
e2[0] ? t2 ? (t2.p(e2, l), l & 1 && transition_in(t2, 1)) : (t2 = k(e2), t2.c(), transition_in(t2, 1), t2.m(o.parentNode, o)) : t2 && (group_outros(), transition_out(t2, 1, 1, () => {
t2 = null;
}), check_outros());
}, i(e2) {
i2 || (transition_in(t2), i2 = true);
}, o(e2) {
transition_out(t2), i2 = false;
}, d(e2) {
e2 && detach(o), t2 && t2.d(e2);
} };
}
function D(n2, o, i2) {
let t2, { $$slots: e2 = {}, $$scope: l } = o;
const r2 = getContext("__hstStory"), s = getContext("__hstVariant"), y2 = getContext("__hstSlot"), p2 = getContext("__hstIndex"), C2 = r2.variants[p2.value];
p2.value++;
let { source: c2 = null } = o;
return n2.$$set = (_2) => {
"source" in _2 && i2(2, c2 = _2.source), "$$scope" in _2 && i2(3, l = _2.$$scope);
}, n2.$$.update = () => {
n2.$$.dirty & 4 && c2 != null && Object.assign(s, { source: c2 });
}, i2(0, t2 = s.id === C2.id), [t2, y2, c2, l, e2];
}
let H$1 = class H3 extends SvelteComponent {
constructor(o) {
super(), init(this, o, D, B, safe_not_equal, { source: 2 });
}
};
function W(a2) {
let t2, o = a2[0].name + "", r2;
return { c() {
t2 = element("div"), r2 = text(o);
}, m(i2, n2) {
insert(i2, t2, n2), append(t2, r2), a2[3](t2);
}, p(i2, [n2]) {
n2 & 1 && o !== (o = i2[0].name + "") && set_data(r2, o);
}, i: noop$2, o: noop$2, d(i2) {
i2 && detach(t2), a2[3](null);
} };
}
function z(a2, t2, o) {
const r2 = ["controlComponent", "value"];
let i2 = compute_rest_props(t2, r2), { controlComponent: n2 } = t2, { value: s } = t2;
const b3 = createEventDispatcher();
let l, m;
const p2 = reactive({});
function f2(e2, c2) {
Object.assign(p2, { value: e2, attrs: c2 });
}
onMount(() => {
f2(s, i2), m = createApp({ render() {
const e2 = {};
if (n2.emits)
for (const c2 in n2.emits) {
const u2 = Array.isArray(n2.emits) ? n2.emits[c2] : c2, d2 = u2 === "input" ? "update:modelValue" : u2;
e2[`on${d2.charAt(0).toUpperCase()}${d2.substring(1)}`] = (..._2) => {
u2 === "update:modelValue" ? o(2, s = _2[0]) : b3(u2, ..._2);
};
}
return h$2(n2, { modelValue: s, ...p2.attrs, ...e2, key: "component" });
} }), m.mount(l);
});
function g(e2) {
binding_callbacks[e2 ? "unshift" : "push"](() => {
l = e2, o(1, l);
});
}
return a2.$$set = (e2) => {
t2 = assign$1(assign$1({}, t2), exclude_internal_props(e2)), o(8, i2 = compute_rest_props(t2, r2)), "controlComponent" in e2 && o(0, n2 = e2.controlComponent), "value" in e2 && o(2, s = e2.value);
}, a2.$$.update = () => {
f2(s, i2);
}, [n2, l, s, g];
}
class I extends SvelteComponent {
constructor(t2) {
super(), init(this, t2, z, W, safe_not_equal, { controlComponent: 0, value: 2 });
}
}
function f(n2) {
const i2 = {};
for (const t2 in n2) {
if (t2 === "Hst")
continue;
const e2 = n2[t2];
typeof e2 != "function" && (typeof e2 > "u" || e2 instanceof HTMLElement || typeof e2 == "object" && (e2 != null && e2.$$) || (i2[t2] = e2));
}
return i2;
}
function y(n2, i2) {
let t2 = false;
const e2 = watch(() => n2, (o) => {
o != null && (t2 ? t2 = false : (t2 = true, i2(f(o))));
}, { deep: true, immediate: true });
function c2(o) {
o != null && (t2 ? t2 = false : (t2 = true, applyState(n2, clone(f(o)))));
}
return { apply: c2, stop() {
e2();
} };
}
const U = /* @__PURE__ */ defineComponent({ name: "RenderStory", props: { variant: { type: Object, required: true }, story: { type: Object, required: true }, slotName: { type: String, default: "default" } }, setup(t2, { emit: s }) {
const f2 = ref();
let u2, i2, l = [];
function _2(n2, c2) {
document.addEventListener(n2, c2);
const e2 = () => document.removeEventListener(n2, c2);
return l.push(e2), { off: e2 };
}
async function y$1() {
i2 = document.createElement("div"), f2.value.appendChild(i2);
let n2 = [];
const { off: c2 } = _2("SvelteRegisterComponent", (o) => {
const { component: m } = o.detail;
n2.push(m);
});
u2 = new t2.story.file.component({ target: i2, props: { Hst: { Story: D$1, Variant: H$1, ...q() } }, context: new Map(Object.entries({ __hstStory: t2.story, __hstVariant: t2.variant, __hstSlot: t2.slotName })) });
let e2 = n2.find((o) => o.$$ === u2.$$);
c2(), n2 = [];
function v2() {
const o = e2.$replace;
o && (e2.$replace = (...m) => {
const w2 = o.apply(e2, m);
return e2 = w2, h2(), v2(), w2;
});
}
v2();
const { apply: S2, stop: C2 } = y(t2.variant.state, (o) => {
e2.$inject_state(o);
});
l.push(C2);
function h2() {
e2.$$.after_update.push(() => {
S2(e2.$capture_state());
});
}
h2(), S2(e2.$capture_state());
const p2 = { app: u2, story: t2.story, variant: t2.variant };
typeof (a == null ? void 0 : void 0) == "function" && await (void 0)(p2), typeof (r == null ? void 0 : void 0) == "function" && await (void 0)(p2), typeof (a == null ? void 0 : void 0) == "function" && await (void 0)(p2), typeof (r == null ? void 0 : void 0) == "function" && await (void 0)(p2), typeof t2.variant.setupApp == "function" && await t2.variant.setupApp(p2), s("ready");
}
function d2() {
var n2;
u2 == null || u2.$destroy(), i2 && ((n2 = i2.parentNode) == null || n2.removeChild(i2), i2 = null), l.forEach((c2) => c2()), l = [];
}
return watch(() => t2.story.id, async () => {
d2(), await y$1();
}), onMounted(async () => {
await y$1();
}), onUnmounted(() => {
d2();
}), { el: f2 };
}, render() {
return h$2("div", { ref: "el" });
} });
function q() {
const t2 = {};
for (const s in Nm)
t2[s.substring(3)] = H(Nm[s]);
return t2;
}
function H(t2) {
function s(f2) {
return new I({ ...f2, props: { ...f2.props, controlComponent: t2 } });
}
return s;
}
function e() {
}
const index = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
MountStory: O$1,
RenderStory: U,
generateSourceCode: e
}, Symbol.toStringTag, { value: "Module" }));
export {
children as $,
pushScopeId as A,
popScopeId as B,
vShow as C,
defineAsyncComponent as D,
reactive as E,
Fragment as F,
normalizeStyle as G,
useTitle as H,
Icon as I,
onMounted as J,
createApp as K,
createPinia as L,
plugin as M,
parseQuery as N,
h$2 as O,
applyState as P,
init as Q,
safe_not_equal as R,
SvelteComponentDev as S,
Transition as T,
dispatch_dev as U,
validate_slots as V,
element as W,
space as X,
svg_element as Y,
claim_element as Z,
claim_space as _,
useRoute as a,
VTooltip as a$,
claim_svg_element as a0,
detach_dev as a1,
attr_dev as a2,
add_location as a3,
insert_hydration_dev as a4,
append_hydration_dev as a5,
listen_dev as a6,
noop$2 as a7,
create_component as a8,
claim_component as a9,
useToggle as aA,
markRaw as aB,
watchEffect as aC,
mergeProps as aD,
resolveDynamicComponent as aE,
renderSlot as aF,
Dropdown as aG,
clone as aH,
omit as aI,
useTimeoutFn as aJ,
onClickOutside as aK,
withModifiers as aL,
vModelText as aM,
nextTick as aN,
Mm as aO,
gm as aP,
ym as aQ,
wm as aR,
toRefs as aS,
useRouter as aT,
shallowRef as aU,
unindent as aV,
getHighlighter as aW,
Am as aX,
useResizeObserver as aY,
onBeforeUnmount as aZ,
onUnmounted as a_,
mount_component as aa,
transition_in as ab,
transition_out as ac,
destroy_component as ad,
createEventDispatcher as ae,
toggle_class as af,
set_input_value as ag,
to_number as ah,
run_all as ai,
binding_callbacks as aj,
flush as ak,
get_svelte_dataset as al,
ensure_array_like_dev as am,
add_render_callback as an,
select_option as ao,
destroy_each as ap,
select_value as aq,
text as ar,
claim_text as as,
set_data_dev as at,
Logo_square as au,
Logo_dark as av,
createRouter as aw,
createWebHistory as ax,
createWebHashHistory as ay,
useDark as az,
createElementBlock as b,
createStaticVNode as b0,
toRaw as b1,
scrollIntoView as b2,
useMediaQuery as b3,
useFocus as b4,
refDebounced as b5,
flexsearch_bundleExports as b6,
client as b7,
index as b8,
computed as c,
defineComponent as d,
createVNode as e,
createBaseVNode as f,
unref as g,
createCommentVNode as h,
defineStore as i,
useStorage as j,
watch as k,
resolveComponent as l,
withKeys as m,
normalizeClass as n,
openBlock as o,
renderList as p,
createBlock as q,
ref as r,
useEventListener as s,
toDisplayString as t,
useCssVars as u,
isRef as v,
withCtx as w,
resolveDirective as x,
withDirectives as y,
createTextVNode as z
};