2737 lines
95 KiB
JavaScript
2737 lines
95 KiB
JavaScript
/*
|
|
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
|
|
if you want to view the source, please visit the github repository of this plugin
|
|
*/
|
|
|
|
var __create = Object.create;
|
|
var __defProp = Object.defineProperty;
|
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
var __getProtoOf = Object.getPrototypeOf;
|
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
var __export = (target, all) => {
|
|
__markAsModule(target);
|
|
for (var name in all)
|
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
};
|
|
var __reExport = (target, module2, desc) => {
|
|
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
for (let key of __getOwnPropNames(module2))
|
|
if (!__hasOwnProp.call(target, key) && key !== "default")
|
|
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
}
|
|
return target;
|
|
};
|
|
var __toModule = (module2) => {
|
|
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
};
|
|
var __async = (__this, __arguments, generator) => {
|
|
return new Promise((resolve, reject) => {
|
|
var fulfilled = (value) => {
|
|
try {
|
|
step(generator.next(value));
|
|
} catch (e) {
|
|
reject(e);
|
|
}
|
|
};
|
|
var rejected = (value) => {
|
|
try {
|
|
step(generator.throw(value));
|
|
} catch (e) {
|
|
reject(e);
|
|
}
|
|
};
|
|
var step = (x2) => x2.done ? resolve(x2.value) : Promise.resolve(x2.value).then(fulfilled, rejected);
|
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
});
|
|
};
|
|
|
|
// main.ts
|
|
__export(exports, {
|
|
default: () => SequenceHotkeysPlugin
|
|
});
|
|
var import_obsidian2 = __toModule(require("obsidian"));
|
|
|
|
// keys.ts
|
|
var import_obsidian = __toModule(require("obsidian"));
|
|
var CODE_STR_MAP = new Map([
|
|
["Control", "Ctrl-"],
|
|
["ControlLeft", "Ctrl-"],
|
|
["ControlRight", "Ctrl-"],
|
|
["Alt", "Alt-"],
|
|
["AltLeft", "Alt-"],
|
|
["AltRight", "Alt-"],
|
|
["Shift", "Shift-"],
|
|
["ShiftLeft", "Shift-"],
|
|
["ShiftRight", "Shift-"],
|
|
["Meta", "Meta-"],
|
|
["MetaLeft", "Meta-"],
|
|
["MetaRight", "Meta-"],
|
|
["Escape", "Esc"],
|
|
["Enter", "Enter"],
|
|
["CapsLock", "CapsLock"],
|
|
["KeyA", "A"],
|
|
["KeyB", "B"],
|
|
["KeyC", "C"],
|
|
["KeyD", "D"],
|
|
["KeyE", "E"],
|
|
["KeyF", "F"],
|
|
["KeyG", "G"],
|
|
["KeyH", "H"],
|
|
["KeyI", "I"],
|
|
["KeyJ", "J"],
|
|
["KeyK", "K"],
|
|
["KeyL", "L"],
|
|
["KeyM", "M"],
|
|
["KeyN", "N"],
|
|
["KeyO", "O"],
|
|
["KeyP", "P"],
|
|
["KeyQ", "Q"],
|
|
["KeyR", "R"],
|
|
["KeyS", "S"],
|
|
["KeyT", "T"],
|
|
["KeyU", "U"],
|
|
["KeyV", "V"],
|
|
["KeyW", "W"],
|
|
["KeyX", "X"],
|
|
["KeyY", "Y"],
|
|
["KeyZ", "Z"],
|
|
["Digit0", "0"],
|
|
["Digit1", "1"],
|
|
["Digit2", "2"],
|
|
["Digit3", "3"],
|
|
["Digit4", "4"],
|
|
["Digit5", "5"],
|
|
["Digit6", "6"],
|
|
["Digit7", "7"],
|
|
["Digit8", "8"],
|
|
["Digit9", "9"],
|
|
["Minus", "-"],
|
|
["Equal", "="],
|
|
["BracketLeft", "["],
|
|
["BracketRight", "]"],
|
|
["Semicolon", ";"],
|
|
["Quote", "'"],
|
|
["Comma", ","],
|
|
["Period", "."],
|
|
["Slash", "/"],
|
|
["ArrowLeft", "Left"],
|
|
["ArrowRight", "Right"],
|
|
["ArrowUp", "Up"],
|
|
["ArrowDown", "Down"],
|
|
["Backquote", "`"]
|
|
]);
|
|
if (import_obsidian.Platform.isMacOS) {
|
|
CODE_STR_MAP.set("Control", "\u2303");
|
|
CODE_STR_MAP.set("ControlLeft", "\u2303");
|
|
CODE_STR_MAP.set("ControlRight", "\u2303");
|
|
CODE_STR_MAP.set("Alt", "\u2325");
|
|
CODE_STR_MAP.set("AltLeft", "\u2325");
|
|
CODE_STR_MAP.set("AltRight", "\u2325");
|
|
CODE_STR_MAP.set("Shift", "\u21E7");
|
|
CODE_STR_MAP.set("ShiftLeft", "\u21E7");
|
|
CODE_STR_MAP.set("ShiftRight", "\u21E7");
|
|
CODE_STR_MAP.set("Meta", "\u2318");
|
|
CODE_STR_MAP.set("MetaLeft", "\u2318");
|
|
CODE_STR_MAP.set("MetaRight", "\u2318");
|
|
CODE_STR_MAP.set("Escape", "\u238B");
|
|
CODE_STR_MAP.set("Enter", "\u23CE");
|
|
CODE_STR_MAP.set("CapsLock", "\u21EA");
|
|
}
|
|
var codeToString = (e) => CODE_STR_MAP.get(e) || e;
|
|
var isModifier = (key) => {
|
|
switch (key) {
|
|
case "Control":
|
|
case "Alt":
|
|
case "Shift":
|
|
case "Meta":
|
|
case "ControlLeft":
|
|
case "AltLeft":
|
|
case "ShiftLeft":
|
|
case "MetaLeft":
|
|
case "ControlRight":
|
|
case "AltRight":
|
|
case "ShiftRight":
|
|
case "MetaRight":
|
|
return true;
|
|
default:
|
|
return false;
|
|
}
|
|
};
|
|
var keySequenceEqual = (a2, b2) => a2.length === b2.length && a2.every((c2, i2) => c2.equals(b2[i2]));
|
|
var keySequencePartiallyEqual = (a2, b2) => {
|
|
if (a2.length === 0 || b2.length === 0) {
|
|
return false;
|
|
}
|
|
if (a2.length > b2.length) {
|
|
return b2.every((c2, i2) => c2.equals(a2[i2]));
|
|
}
|
|
return a2.every((c2, i2) => c2.equals(b2[i2]));
|
|
};
|
|
var KeyChord = class {
|
|
constructor(input) {
|
|
this.meta = false;
|
|
this.ctrl = false;
|
|
this.alt = false;
|
|
this.shift = false;
|
|
this.key = "";
|
|
this.equals = (other) => {
|
|
return !!other && this.key === other.key && this.meta === other.meta && this.ctrl === other.ctrl && this.alt === other.alt && this.shift === other.shift;
|
|
};
|
|
this.serialize = () => {
|
|
const parts = new Array();
|
|
if (this.meta) {
|
|
parts.push("M");
|
|
}
|
|
if (this.ctrl) {
|
|
parts.push("C");
|
|
}
|
|
if (this.alt) {
|
|
parts.push("A");
|
|
}
|
|
if (this.shift) {
|
|
parts.push("S");
|
|
}
|
|
parts.push(this.key);
|
|
return parts.join("-");
|
|
};
|
|
this.toString = () => {
|
|
const keys = new Array();
|
|
if (this.meta) {
|
|
keys.push("Meta");
|
|
}
|
|
if (this.ctrl) {
|
|
keys.push("Control");
|
|
}
|
|
if (this.alt) {
|
|
keys.push("Alt");
|
|
}
|
|
if (this.shift) {
|
|
keys.push("Shift");
|
|
}
|
|
keys.push(codeToString(this.key));
|
|
return keys.map(codeToString).join("");
|
|
};
|
|
if (typeof input === "string") {
|
|
const parts = input.split("-");
|
|
this.key = parts.pop();
|
|
parts.map((p2) => {
|
|
switch (p2) {
|
|
case "M":
|
|
this.meta = true;
|
|
break;
|
|
case "C":
|
|
this.ctrl = true;
|
|
break;
|
|
case "A":
|
|
this.alt = true;
|
|
break;
|
|
case "S":
|
|
this.shift = true;
|
|
break;
|
|
}
|
|
});
|
|
} else {
|
|
if (!isModifier(input.code)) {
|
|
this.key = input.code;
|
|
}
|
|
this.meta = input.metaKey;
|
|
this.ctrl = input.ctrlKey;
|
|
this.alt = input.altKey;
|
|
this.shift = input.shiftKey;
|
|
}
|
|
}
|
|
};
|
|
|
|
// hotkey-manager.ts
|
|
function arrayStartsWith(arr, start) {
|
|
if (start.length > arr.length) {
|
|
return false;
|
|
}
|
|
return start.every((_2, i2) => arr[i2] === start[i2]);
|
|
}
|
|
var HotkeyManager = class {
|
|
constructor(triggerHandler) {
|
|
this._matchingHotheys = () => {
|
|
const css = this.currentSequence.map((c2) => c2.toString());
|
|
return this.registeredHotkeys.filter((r2) => {
|
|
const rcs = r2.chords.map((c2) => c2.toString());
|
|
return arrayStartsWith(rcs, css);
|
|
});
|
|
};
|
|
this.handleChordPress = (chord) => {
|
|
this.currentSequence.push(chord);
|
|
let hotkeys = this._matchingHotheys();
|
|
if (hotkeys.length === 0 && this.currentSequence.length > 1) {
|
|
this.currentSequence = [chord];
|
|
hotkeys = this._matchingHotheys();
|
|
}
|
|
if (hotkeys.length === 0) {
|
|
this.currentSequence = [];
|
|
return false;
|
|
}
|
|
let exactMatch = hotkeys.find((r2) => {
|
|
return this.currentSequence.length === r2.chords.length;
|
|
});
|
|
if (exactMatch) {
|
|
this.currentSequence = [];
|
|
this.triggerHandler(hotkeys[0].id);
|
|
}
|
|
return true;
|
|
};
|
|
this.reset = () => {
|
|
this.registeredHotkeys = [];
|
|
};
|
|
this.addHotkey = (id, chords) => {
|
|
this.registeredHotkeys.push({ id, chords });
|
|
};
|
|
this.removeHotkey = (id) => {
|
|
this.registeredHotkeys = this.registeredHotkeys.filter((r2) => r2.id !== id);
|
|
};
|
|
this.triggerHandler = triggerHandler;
|
|
this.registeredHotkeys = [];
|
|
this.currentSequence = [];
|
|
}
|
|
};
|
|
|
|
// src/chord_listener.ts
|
|
var ChordListener = class {
|
|
constructor(onChord) {
|
|
this.chordPress = (event) => {
|
|
if (!!this._lastKeydown) {
|
|
if (this.onChord(new KeyChord(this._lastKeydown))) {
|
|
event.preventDefault();
|
|
event.stopPropagation();
|
|
}
|
|
this._lastKeydown = void 0;
|
|
}
|
|
};
|
|
this.destruct = () => {
|
|
document.removeEventListener("keydown", this.handleKeydown, { capture: true });
|
|
document.removeEventListener("keyup", this.handleKeyup, { capture: true });
|
|
};
|
|
this.onChord = onChord;
|
|
this.handleKeydown = (event) => {
|
|
this._lastKeydown = event;
|
|
if (isModifier(event.code)) {
|
|
return;
|
|
}
|
|
this.chordPress(event);
|
|
};
|
|
this.handleKeyup = (event) => {
|
|
this.chordPress(event);
|
|
};
|
|
document.addEventListener("keydown", this.handleKeydown, { capture: true });
|
|
document.addEventListener("keyup", this.handleKeyup, { capture: true });
|
|
}
|
|
};
|
|
|
|
// node_modules/immer/dist/immer.esm.mjs
|
|
function n(n2) {
|
|
for (var r2 = arguments.length, t2 = Array(r2 > 1 ? r2 - 1 : 0), e = 1; e < r2; e++)
|
|
t2[e - 1] = arguments[e];
|
|
if (true) {
|
|
var i2 = Y[n2], o2 = i2 ? typeof i2 == "function" ? i2.apply(null, t2) : i2 : "unknown error nr: " + n2;
|
|
throw Error("[Immer] " + o2);
|
|
}
|
|
throw Error("[Immer] minified error nr: " + n2 + (t2.length ? " " + t2.map(function(n3) {
|
|
return "'" + n3 + "'";
|
|
}).join(",") : "") + ". Find the full error at: https://bit.ly/3cXEKWf");
|
|
}
|
|
function r(n2) {
|
|
return !!n2 && !!n2[Q];
|
|
}
|
|
function t(n2) {
|
|
var r2;
|
|
return !!n2 && (function(n3) {
|
|
if (!n3 || typeof n3 != "object")
|
|
return false;
|
|
var r3 = Object.getPrototypeOf(n3);
|
|
if (r3 === null)
|
|
return true;
|
|
var t2 = Object.hasOwnProperty.call(r3, "constructor") && r3.constructor;
|
|
return t2 === Object || typeof t2 == "function" && Function.toString.call(t2) === Z;
|
|
}(n2) || Array.isArray(n2) || !!n2[L] || !!((r2 = n2.constructor) === null || r2 === void 0 ? void 0 : r2[L]) || s(n2) || v(n2));
|
|
}
|
|
function i(n2, r2, t2) {
|
|
t2 === void 0 && (t2 = false), o(n2) === 0 ? (t2 ? Object.keys : nn)(n2).forEach(function(e) {
|
|
t2 && typeof e == "symbol" || r2(e, n2[e], n2);
|
|
}) : n2.forEach(function(t3, e) {
|
|
return r2(e, t3, n2);
|
|
});
|
|
}
|
|
function o(n2) {
|
|
var r2 = n2[Q];
|
|
return r2 ? r2.i > 3 ? r2.i - 4 : r2.i : Array.isArray(n2) ? 1 : s(n2) ? 2 : v(n2) ? 3 : 0;
|
|
}
|
|
function u(n2, r2) {
|
|
return o(n2) === 2 ? n2.has(r2) : Object.prototype.hasOwnProperty.call(n2, r2);
|
|
}
|
|
function a(n2, r2) {
|
|
return o(n2) === 2 ? n2.get(r2) : n2[r2];
|
|
}
|
|
function f(n2, r2, t2) {
|
|
var e = o(n2);
|
|
e === 2 ? n2.set(r2, t2) : e === 3 ? n2.add(t2) : n2[r2] = t2;
|
|
}
|
|
function c(n2, r2) {
|
|
return n2 === r2 ? n2 !== 0 || 1 / n2 == 1 / r2 : n2 != n2 && r2 != r2;
|
|
}
|
|
function s(n2) {
|
|
return X && n2 instanceof Map;
|
|
}
|
|
function v(n2) {
|
|
return q && n2 instanceof Set;
|
|
}
|
|
function p(n2) {
|
|
return n2.o || n2.t;
|
|
}
|
|
function l(n2) {
|
|
if (Array.isArray(n2))
|
|
return Array.prototype.slice.call(n2);
|
|
var r2 = rn(n2);
|
|
delete r2[Q];
|
|
for (var t2 = nn(r2), e = 0; e < t2.length; e++) {
|
|
var i2 = t2[e], o2 = r2[i2];
|
|
o2.writable === false && (o2.writable = true, o2.configurable = true), (o2.get || o2.set) && (r2[i2] = { configurable: true, writable: true, enumerable: o2.enumerable, value: n2[i2] });
|
|
}
|
|
return Object.create(Object.getPrototypeOf(n2), r2);
|
|
}
|
|
function d(n2, e) {
|
|
return e === void 0 && (e = false), y(n2) || r(n2) || !t(n2) || (o(n2) > 1 && (n2.set = n2.add = n2.clear = n2.delete = h), Object.freeze(n2), e && i(n2, function(n3, r2) {
|
|
return d(r2, true);
|
|
}, true)), n2;
|
|
}
|
|
function h() {
|
|
n(2);
|
|
}
|
|
function y(n2) {
|
|
return n2 == null || typeof n2 != "object" || Object.isFrozen(n2);
|
|
}
|
|
function b(r2) {
|
|
var t2 = tn[r2];
|
|
return t2 || n(18, r2), t2;
|
|
}
|
|
function m(n2, r2) {
|
|
tn[n2] || (tn[n2] = r2);
|
|
}
|
|
function _() {
|
|
return U || n(0), U;
|
|
}
|
|
function j(n2, r2) {
|
|
r2 && (b("Patches"), n2.u = [], n2.s = [], n2.v = r2);
|
|
}
|
|
function g(n2) {
|
|
O(n2), n2.p.forEach(S), n2.p = null;
|
|
}
|
|
function O(n2) {
|
|
n2 === U && (U = n2.l);
|
|
}
|
|
function w(n2) {
|
|
return U = { p: [], l: U, h: n2, m: true, _: 0 };
|
|
}
|
|
function S(n2) {
|
|
var r2 = n2[Q];
|
|
r2.i === 0 || r2.i === 1 ? r2.j() : r2.g = true;
|
|
}
|
|
function P(r2, e) {
|
|
e._ = e.p.length;
|
|
var i2 = e.p[0], o2 = r2 !== void 0 && r2 !== i2;
|
|
return e.h.O || b("ES5").S(e, r2, o2), o2 ? (i2[Q].P && (g(e), n(4)), t(r2) && (r2 = M(e, r2), e.l || x(e, r2)), e.u && b("Patches").M(i2[Q].t, r2, e.u, e.s)) : r2 = M(e, i2, []), g(e), e.u && e.v(e.u, e.s), r2 !== H ? r2 : void 0;
|
|
}
|
|
function M(n2, r2, t2) {
|
|
if (y(r2))
|
|
return r2;
|
|
var e = r2[Q];
|
|
if (!e)
|
|
return i(r2, function(i2, o3) {
|
|
return A(n2, e, r2, i2, o3, t2);
|
|
}, true), r2;
|
|
if (e.A !== n2)
|
|
return r2;
|
|
if (!e.P)
|
|
return x(n2, e.t, true), e.t;
|
|
if (!e.I) {
|
|
e.I = true, e.A._--;
|
|
var o2 = e.i === 4 || e.i === 5 ? e.o = l(e.k) : e.o, u2 = o2, a2 = false;
|
|
e.i === 3 && (u2 = new Set(o2), o2.clear(), a2 = true), i(u2, function(r3, i2) {
|
|
return A(n2, e, o2, r3, i2, t2, a2);
|
|
}), x(n2, o2, false), t2 && n2.u && b("Patches").N(e, t2, n2.u, n2.s);
|
|
}
|
|
return e.o;
|
|
}
|
|
function A(e, i2, o2, a2, c2, s2, v2) {
|
|
if (c2 === o2 && n(5), r(c2)) {
|
|
var p2 = M(e, c2, s2 && i2 && i2.i !== 3 && !u(i2.R, a2) ? s2.concat(a2) : void 0);
|
|
if (f(o2, a2, p2), !r(p2))
|
|
return;
|
|
e.m = false;
|
|
} else
|
|
v2 && o2.add(c2);
|
|
if (t(c2) && !y(c2)) {
|
|
if (!e.h.D && e._ < 1)
|
|
return;
|
|
M(e, c2), i2 && i2.A.l || x(e, c2);
|
|
}
|
|
}
|
|
function x(n2, r2, t2) {
|
|
t2 === void 0 && (t2 = false), !n2.l && n2.h.D && n2.m && d(r2, t2);
|
|
}
|
|
function z(n2, r2) {
|
|
var t2 = n2[Q];
|
|
return (t2 ? p(t2) : n2)[r2];
|
|
}
|
|
function I(n2, r2) {
|
|
if (r2 in n2)
|
|
for (var t2 = Object.getPrototypeOf(n2); t2; ) {
|
|
var e = Object.getOwnPropertyDescriptor(t2, r2);
|
|
if (e)
|
|
return e;
|
|
t2 = Object.getPrototypeOf(t2);
|
|
}
|
|
}
|
|
function k(n2) {
|
|
n2.P || (n2.P = true, n2.l && k(n2.l));
|
|
}
|
|
function E(n2) {
|
|
n2.o || (n2.o = l(n2.t));
|
|
}
|
|
function N(n2, r2, t2) {
|
|
var e = s(r2) ? b("MapSet").F(r2, t2) : v(r2) ? b("MapSet").T(r2, t2) : n2.O ? function(n3, r3) {
|
|
var t3 = Array.isArray(n3), e2 = { i: t3 ? 1 : 0, A: r3 ? r3.A : _(), P: false, I: false, R: {}, l: r3, t: n3, k: null, o: null, j: null, C: false }, i2 = e2, o2 = en;
|
|
t3 && (i2 = [e2], o2 = on);
|
|
var u2 = Proxy.revocable(i2, o2), a2 = u2.revoke, f2 = u2.proxy;
|
|
return e2.k = f2, e2.j = a2, f2;
|
|
}(r2, t2) : b("ES5").J(r2, t2);
|
|
return (t2 ? t2.A : _()).p.push(e), e;
|
|
}
|
|
function R(e) {
|
|
return r(e) || n(22, e), function n2(r2) {
|
|
if (!t(r2))
|
|
return r2;
|
|
var e2, u2 = r2[Q], c2 = o(r2);
|
|
if (u2) {
|
|
if (!u2.P && (u2.i < 4 || !b("ES5").K(u2)))
|
|
return u2.t;
|
|
u2.I = true, e2 = D(r2, c2), u2.I = false;
|
|
} else
|
|
e2 = D(r2, c2);
|
|
return i(e2, function(r3, t2) {
|
|
u2 && a(u2.t, r3) === t2 || f(e2, r3, n2(t2));
|
|
}), c2 === 3 ? new Set(e2) : e2;
|
|
}(e);
|
|
}
|
|
function D(n2, r2) {
|
|
switch (r2) {
|
|
case 2:
|
|
return new Map(n2);
|
|
case 3:
|
|
return Array.from(n2);
|
|
}
|
|
return l(n2);
|
|
}
|
|
function F() {
|
|
function t2(n2, r2) {
|
|
var t3 = s2[n2];
|
|
return t3 ? t3.enumerable = r2 : s2[n2] = t3 = { configurable: true, enumerable: r2, get: function() {
|
|
var r3 = this[Q];
|
|
return f2(r3), en.get(r3, n2);
|
|
}, set: function(r3) {
|
|
var t4 = this[Q];
|
|
f2(t4), en.set(t4, n2, r3);
|
|
} }, t3;
|
|
}
|
|
function e(n2) {
|
|
for (var r2 = n2.length - 1; r2 >= 0; r2--) {
|
|
var t3 = n2[r2][Q];
|
|
if (!t3.P)
|
|
switch (t3.i) {
|
|
case 5:
|
|
a2(t3) && k(t3);
|
|
break;
|
|
case 4:
|
|
o2(t3) && k(t3);
|
|
}
|
|
}
|
|
}
|
|
function o2(n2) {
|
|
for (var r2 = n2.t, t3 = n2.k, e2 = nn(t3), i2 = e2.length - 1; i2 >= 0; i2--) {
|
|
var o3 = e2[i2];
|
|
if (o3 !== Q) {
|
|
var a3 = r2[o3];
|
|
if (a3 === void 0 && !u(r2, o3))
|
|
return true;
|
|
var f3 = t3[o3], s3 = f3 && f3[Q];
|
|
if (s3 ? s3.t !== a3 : !c(f3, a3))
|
|
return true;
|
|
}
|
|
}
|
|
var v2 = !!r2[Q];
|
|
return e2.length !== nn(r2).length + (v2 ? 0 : 1);
|
|
}
|
|
function a2(n2) {
|
|
var r2 = n2.k;
|
|
if (r2.length !== n2.t.length)
|
|
return true;
|
|
var t3 = Object.getOwnPropertyDescriptor(r2, r2.length - 1);
|
|
if (t3 && !t3.get)
|
|
return true;
|
|
for (var e2 = 0; e2 < r2.length; e2++)
|
|
if (!r2.hasOwnProperty(e2))
|
|
return true;
|
|
return false;
|
|
}
|
|
function f2(r2) {
|
|
r2.g && n(3, JSON.stringify(p(r2)));
|
|
}
|
|
var s2 = {};
|
|
m("ES5", { J: function(n2, r2) {
|
|
var e2 = Array.isArray(n2), i2 = function(n3, r3) {
|
|
if (n3) {
|
|
for (var e3 = Array(r3.length), i3 = 0; i3 < r3.length; i3++)
|
|
Object.defineProperty(e3, "" + i3, t2(i3, true));
|
|
return e3;
|
|
}
|
|
var o4 = rn(r3);
|
|
delete o4[Q];
|
|
for (var u2 = nn(o4), a3 = 0; a3 < u2.length; a3++) {
|
|
var f3 = u2[a3];
|
|
o4[f3] = t2(f3, n3 || !!o4[f3].enumerable);
|
|
}
|
|
return Object.create(Object.getPrototypeOf(r3), o4);
|
|
}(e2, n2), o3 = { i: e2 ? 5 : 4, A: r2 ? r2.A : _(), P: false, I: false, R: {}, l: r2, t: n2, k: i2, o: null, g: false, C: false };
|
|
return Object.defineProperty(i2, Q, { value: o3, writable: true }), i2;
|
|
}, S: function(n2, t3, o3) {
|
|
o3 ? r(t3) && t3[Q].A === n2 && e(n2.p) : (n2.u && function n3(r2) {
|
|
if (r2 && typeof r2 == "object") {
|
|
var t4 = r2[Q];
|
|
if (t4) {
|
|
var e2 = t4.t, o4 = t4.k, f3 = t4.R, c2 = t4.i;
|
|
if (c2 === 4)
|
|
i(o4, function(r3) {
|
|
r3 !== Q && (e2[r3] !== void 0 || u(e2, r3) ? f3[r3] || n3(o4[r3]) : (f3[r3] = true, k(t4)));
|
|
}), i(e2, function(n4) {
|
|
o4[n4] !== void 0 || u(o4, n4) || (f3[n4] = false, k(t4));
|
|
});
|
|
else if (c2 === 5) {
|
|
if (a2(t4) && (k(t4), f3.length = true), o4.length < e2.length)
|
|
for (var s3 = o4.length; s3 < e2.length; s3++)
|
|
f3[s3] = false;
|
|
else
|
|
for (var v2 = e2.length; v2 < o4.length; v2++)
|
|
f3[v2] = true;
|
|
for (var p2 = Math.min(o4.length, e2.length), l2 = 0; l2 < p2; l2++)
|
|
o4.hasOwnProperty(l2) || (f3[l2] = true), f3[l2] === void 0 && n3(o4[l2]);
|
|
}
|
|
}
|
|
}
|
|
}(n2.p[0]), e(n2.p));
|
|
}, K: function(n2) {
|
|
return n2.i === 4 ? o2(n2) : a2(n2);
|
|
} });
|
|
}
|
|
var G;
|
|
var U;
|
|
var W = typeof Symbol != "undefined" && typeof Symbol("x") == "symbol";
|
|
var X = typeof Map != "undefined";
|
|
var q = typeof Set != "undefined";
|
|
var B = typeof Proxy != "undefined" && Proxy.revocable !== void 0 && typeof Reflect != "undefined";
|
|
var H = W ? Symbol.for("immer-nothing") : ((G = {})["immer-nothing"] = true, G);
|
|
var L = W ? Symbol.for("immer-draftable") : "__$immer_draftable";
|
|
var Q = W ? Symbol.for("immer-state") : "__$immer_state";
|
|
var V = typeof Symbol != "undefined" && Symbol.iterator || "@@iterator";
|
|
var Y = { 0: "Illegal state", 1: "Immer drafts cannot have computed properties", 2: "This object has been frozen and should not be mutated", 3: function(n2) {
|
|
return "Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? " + n2;
|
|
}, 4: "An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.", 5: "Immer forbids circular references", 6: "The first or second argument to `produce` must be a function", 7: "The third argument to `produce` must be a function or undefined", 8: "First argument to `createDraft` must be a plain object, an array, or an immerable object", 9: "First argument to `finishDraft` must be a draft returned by `createDraft`", 10: "The given draft is already finalized", 11: "Object.defineProperty() cannot be used on an Immer draft", 12: "Object.setPrototypeOf() cannot be used on an Immer draft", 13: "Immer only supports deleting array indices", 14: "Immer only supports setting array indices and the 'length' property", 15: function(n2) {
|
|
return "Cannot apply patch, path doesn't resolve: " + n2;
|
|
}, 16: 'Sets cannot have "replace" patches.', 17: function(n2) {
|
|
return "Unsupported patch operation: " + n2;
|
|
}, 18: function(n2) {
|
|
return "The plugin for '" + n2 + "' has not been loaded into Immer. To enable the plugin, import and call `enable" + n2 + "()` when initializing your application.";
|
|
}, 20: "Cannot use proxies if Proxy, Proxy.revocable or Reflect are not available", 21: function(n2) {
|
|
return "produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '" + n2 + "'";
|
|
}, 22: function(n2) {
|
|
return "'current' expects a draft, got: " + n2;
|
|
}, 23: function(n2) {
|
|
return "'original' expects a draft, got: " + n2;
|
|
}, 24: "Patching reserved attributes like __proto__, prototype and constructor is not allowed" };
|
|
var Z = "" + Object.prototype.constructor;
|
|
var nn = typeof Reflect != "undefined" && Reflect.ownKeys ? Reflect.ownKeys : Object.getOwnPropertySymbols !== void 0 ? function(n2) {
|
|
return Object.getOwnPropertyNames(n2).concat(Object.getOwnPropertySymbols(n2));
|
|
} : Object.getOwnPropertyNames;
|
|
var rn = Object.getOwnPropertyDescriptors || function(n2) {
|
|
var r2 = {};
|
|
return nn(n2).forEach(function(t2) {
|
|
r2[t2] = Object.getOwnPropertyDescriptor(n2, t2);
|
|
}), r2;
|
|
};
|
|
var tn = {};
|
|
var en = { get: function(n2, r2) {
|
|
if (r2 === Q)
|
|
return n2;
|
|
var e = p(n2);
|
|
if (!u(e, r2))
|
|
return function(n3, r3, t2) {
|
|
var e2, i3 = I(r3, t2);
|
|
return i3 ? "value" in i3 ? i3.value : (e2 = i3.get) === null || e2 === void 0 ? void 0 : e2.call(n3.k) : void 0;
|
|
}(n2, e, r2);
|
|
var i2 = e[r2];
|
|
return n2.I || !t(i2) ? i2 : i2 === z(n2.t, r2) ? (E(n2), n2.o[r2] = N(n2.A.h, i2, n2)) : i2;
|
|
}, has: function(n2, r2) {
|
|
return r2 in p(n2);
|
|
}, ownKeys: function(n2) {
|
|
return Reflect.ownKeys(p(n2));
|
|
}, set: function(n2, r2, t2) {
|
|
var e = I(p(n2), r2);
|
|
if (e == null ? void 0 : e.set)
|
|
return e.set.call(n2.k, t2), true;
|
|
if (!n2.P) {
|
|
var i2 = z(p(n2), r2), o2 = i2 == null ? void 0 : i2[Q];
|
|
if (o2 && o2.t === t2)
|
|
return n2.o[r2] = t2, n2.R[r2] = false, true;
|
|
if (c(t2, i2) && (t2 !== void 0 || u(n2.t, r2)))
|
|
return true;
|
|
E(n2), k(n2);
|
|
}
|
|
return n2.o[r2] === t2 && (t2 !== void 0 || r2 in n2.o) || Number.isNaN(t2) && Number.isNaN(n2.o[r2]) || (n2.o[r2] = t2, n2.R[r2] = true), true;
|
|
}, deleteProperty: function(n2, r2) {
|
|
return z(n2.t, r2) !== void 0 || r2 in n2.t ? (n2.R[r2] = false, E(n2), k(n2)) : delete n2.R[r2], n2.o && delete n2.o[r2], true;
|
|
}, getOwnPropertyDescriptor: function(n2, r2) {
|
|
var t2 = p(n2), e = Reflect.getOwnPropertyDescriptor(t2, r2);
|
|
return e ? { writable: true, configurable: n2.i !== 1 || r2 !== "length", enumerable: e.enumerable, value: t2[r2] } : e;
|
|
}, defineProperty: function() {
|
|
n(11);
|
|
}, getPrototypeOf: function(n2) {
|
|
return Object.getPrototypeOf(n2.t);
|
|
}, setPrototypeOf: function() {
|
|
n(12);
|
|
} };
|
|
var on = {};
|
|
i(en, function(n2, r2) {
|
|
on[n2] = function() {
|
|
return arguments[0] = arguments[0][0], r2.apply(this, arguments);
|
|
};
|
|
}), on.deleteProperty = function(r2, t2) {
|
|
return isNaN(parseInt(t2)) && n(13), on.set.call(this, r2, t2, void 0);
|
|
}, on.set = function(r2, t2, e) {
|
|
return t2 !== "length" && isNaN(parseInt(t2)) && n(14), en.set.call(this, r2[0], t2, e, r2[0]);
|
|
};
|
|
var un = function() {
|
|
function e(r2) {
|
|
var e2 = this;
|
|
this.O = B, this.D = true, this.produce = function(r3, i3, o2) {
|
|
if (typeof r3 == "function" && typeof i3 != "function") {
|
|
var u2 = i3;
|
|
i3 = r3;
|
|
var a2 = e2;
|
|
return function(n2) {
|
|
var r4 = this;
|
|
n2 === void 0 && (n2 = u2);
|
|
for (var t2 = arguments.length, e3 = Array(t2 > 1 ? t2 - 1 : 0), o3 = 1; o3 < t2; o3++)
|
|
e3[o3 - 1] = arguments[o3];
|
|
return a2.produce(n2, function(n3) {
|
|
var t3;
|
|
return (t3 = i3).call.apply(t3, [r4, n3].concat(e3));
|
|
});
|
|
};
|
|
}
|
|
var f2;
|
|
if (typeof i3 != "function" && n(6), o2 !== void 0 && typeof o2 != "function" && n(7), t(r3)) {
|
|
var c2 = w(e2), s2 = N(e2, r3, void 0), v2 = true;
|
|
try {
|
|
f2 = i3(s2), v2 = false;
|
|
} finally {
|
|
v2 ? g(c2) : O(c2);
|
|
}
|
|
return typeof Promise != "undefined" && f2 instanceof Promise ? f2.then(function(n2) {
|
|
return j(c2, o2), P(n2, c2);
|
|
}, function(n2) {
|
|
throw g(c2), n2;
|
|
}) : (j(c2, o2), P(f2, c2));
|
|
}
|
|
if (!r3 || typeof r3 != "object") {
|
|
if ((f2 = i3(r3)) === void 0 && (f2 = r3), f2 === H && (f2 = void 0), e2.D && d(f2, true), o2) {
|
|
var p2 = [], l2 = [];
|
|
b("Patches").M(r3, f2, p2, l2), o2(p2, l2);
|
|
}
|
|
return f2;
|
|
}
|
|
n(21, r3);
|
|
}, this.produceWithPatches = function(n2, r3) {
|
|
if (typeof n2 == "function")
|
|
return function(r4) {
|
|
for (var t3 = arguments.length, i4 = Array(t3 > 1 ? t3 - 1 : 0), o3 = 1; o3 < t3; o3++)
|
|
i4[o3 - 1] = arguments[o3];
|
|
return e2.produceWithPatches(r4, function(r5) {
|
|
return n2.apply(void 0, [r5].concat(i4));
|
|
});
|
|
};
|
|
var t2, i3, o2 = e2.produce(n2, r3, function(n3, r4) {
|
|
t2 = n3, i3 = r4;
|
|
});
|
|
return typeof Promise != "undefined" && o2 instanceof Promise ? o2.then(function(n3) {
|
|
return [n3, t2, i3];
|
|
}) : [o2, t2, i3];
|
|
}, typeof (r2 == null ? void 0 : r2.useProxies) == "boolean" && this.setUseProxies(r2.useProxies), typeof (r2 == null ? void 0 : r2.autoFreeze) == "boolean" && this.setAutoFreeze(r2.autoFreeze);
|
|
}
|
|
var i2 = e.prototype;
|
|
return i2.createDraft = function(e2) {
|
|
t(e2) || n(8), r(e2) && (e2 = R(e2));
|
|
var i3 = w(this), o2 = N(this, e2, void 0);
|
|
return o2[Q].C = true, O(i3), o2;
|
|
}, i2.finishDraft = function(r2, t2) {
|
|
var e2 = r2 && r2[Q];
|
|
e2 && e2.C || n(9), e2.I && n(10);
|
|
var i3 = e2.A;
|
|
return j(i3, t2), P(void 0, i3);
|
|
}, i2.setAutoFreeze = function(n2) {
|
|
this.D = n2;
|
|
}, i2.setUseProxies = function(r2) {
|
|
r2 && !B && n(20), this.O = r2;
|
|
}, i2.applyPatches = function(n2, t2) {
|
|
var e2;
|
|
for (e2 = t2.length - 1; e2 >= 0; e2--) {
|
|
var i3 = t2[e2];
|
|
if (i3.path.length === 0 && i3.op === "replace") {
|
|
n2 = i3.value;
|
|
break;
|
|
}
|
|
}
|
|
e2 > -1 && (t2 = t2.slice(e2 + 1));
|
|
var o2 = b("Patches").$;
|
|
return r(n2) ? o2(n2, t2) : this.produce(n2, function(n3) {
|
|
return o2(n3, t2);
|
|
});
|
|
}, e;
|
|
}();
|
|
var an = new un();
|
|
var fn = an.produce;
|
|
var cn = an.produceWithPatches.bind(an);
|
|
var sn = an.setAutoFreeze.bind(an);
|
|
var vn = an.setUseProxies.bind(an);
|
|
var pn = an.applyPatches.bind(an);
|
|
var ln = an.createDraft.bind(an);
|
|
var dn = an.finishDraft.bind(an);
|
|
var immer_esm_default = fn;
|
|
|
|
// node_modules/@babel/runtime/helpers/esm/typeof.js
|
|
function _typeof(o2) {
|
|
"@babel/helpers - typeof";
|
|
return _typeof = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(o3) {
|
|
return typeof o3;
|
|
} : function(o3) {
|
|
return o3 && typeof Symbol == "function" && o3.constructor === Symbol && o3 !== Symbol.prototype ? "symbol" : typeof o3;
|
|
}, _typeof(o2);
|
|
}
|
|
|
|
// node_modules/@babel/runtime/helpers/esm/toPrimitive.js
|
|
function _toPrimitive(input, hint) {
|
|
if (_typeof(input) !== "object" || input === null)
|
|
return input;
|
|
var prim = input[Symbol.toPrimitive];
|
|
if (prim !== void 0) {
|
|
var res = prim.call(input, hint || "default");
|
|
if (_typeof(res) !== "object")
|
|
return res;
|
|
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
}
|
|
return (hint === "string" ? String : Number)(input);
|
|
}
|
|
|
|
// node_modules/@babel/runtime/helpers/esm/toPropertyKey.js
|
|
function _toPropertyKey(arg) {
|
|
var key = _toPrimitive(arg, "string");
|
|
return _typeof(key) === "symbol" ? key : String(key);
|
|
}
|
|
|
|
// node_modules/@babel/runtime/helpers/esm/defineProperty.js
|
|
function _defineProperty(obj, key, value) {
|
|
key = _toPropertyKey(key);
|
|
if (key in obj) {
|
|
Object.defineProperty(obj, key, {
|
|
value,
|
|
enumerable: true,
|
|
configurable: true,
|
|
writable: true
|
|
});
|
|
} else {
|
|
obj[key] = value;
|
|
}
|
|
return obj;
|
|
}
|
|
|
|
// node_modules/@babel/runtime/helpers/esm/objectSpread2.js
|
|
function ownKeys(e, r2) {
|
|
var t2 = Object.keys(e);
|
|
if (Object.getOwnPropertySymbols) {
|
|
var o2 = Object.getOwnPropertySymbols(e);
|
|
r2 && (o2 = o2.filter(function(r3) {
|
|
return Object.getOwnPropertyDescriptor(e, r3).enumerable;
|
|
})), t2.push.apply(t2, o2);
|
|
}
|
|
return t2;
|
|
}
|
|
function _objectSpread2(e) {
|
|
for (var r2 = 1; r2 < arguments.length; r2++) {
|
|
var t2 = arguments[r2] != null ? arguments[r2] : {};
|
|
r2 % 2 ? ownKeys(Object(t2), true).forEach(function(r3) {
|
|
_defineProperty(e, r3, t2[r3]);
|
|
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t2)) : ownKeys(Object(t2)).forEach(function(r3) {
|
|
Object.defineProperty(e, r3, Object.getOwnPropertyDescriptor(t2, r3));
|
|
});
|
|
}
|
|
return e;
|
|
}
|
|
|
|
// node_modules/redux/es/redux.js
|
|
var $$observable = function() {
|
|
return typeof Symbol === "function" && Symbol.observable || "@@observable";
|
|
}();
|
|
var randomString = function randomString2() {
|
|
return Math.random().toString(36).substring(7).split("").join(".");
|
|
};
|
|
var ActionTypes = {
|
|
INIT: "@@redux/INIT" + randomString(),
|
|
REPLACE: "@@redux/REPLACE" + randomString(),
|
|
PROBE_UNKNOWN_ACTION: function PROBE_UNKNOWN_ACTION() {
|
|
return "@@redux/PROBE_UNKNOWN_ACTION" + randomString();
|
|
}
|
|
};
|
|
function isPlainObject(obj) {
|
|
if (typeof obj !== "object" || obj === null)
|
|
return false;
|
|
var proto = obj;
|
|
while (Object.getPrototypeOf(proto) !== null) {
|
|
proto = Object.getPrototypeOf(proto);
|
|
}
|
|
return Object.getPrototypeOf(obj) === proto;
|
|
}
|
|
function miniKindOf(val) {
|
|
if (val === void 0)
|
|
return "undefined";
|
|
if (val === null)
|
|
return "null";
|
|
var type = typeof val;
|
|
switch (type) {
|
|
case "boolean":
|
|
case "string":
|
|
case "number":
|
|
case "symbol":
|
|
case "function": {
|
|
return type;
|
|
}
|
|
}
|
|
if (Array.isArray(val))
|
|
return "array";
|
|
if (isDate(val))
|
|
return "date";
|
|
if (isError(val))
|
|
return "error";
|
|
var constructorName = ctorName(val);
|
|
switch (constructorName) {
|
|
case "Symbol":
|
|
case "Promise":
|
|
case "WeakMap":
|
|
case "WeakSet":
|
|
case "Map":
|
|
case "Set":
|
|
return constructorName;
|
|
}
|
|
return type.slice(8, -1).toLowerCase().replace(/\s/g, "");
|
|
}
|
|
function ctorName(val) {
|
|
return typeof val.constructor === "function" ? val.constructor.name : null;
|
|
}
|
|
function isError(val) {
|
|
return val instanceof Error || typeof val.message === "string" && val.constructor && typeof val.constructor.stackTraceLimit === "number";
|
|
}
|
|
function isDate(val) {
|
|
if (val instanceof Date)
|
|
return true;
|
|
return typeof val.toDateString === "function" && typeof val.getDate === "function" && typeof val.setDate === "function";
|
|
}
|
|
function kindOf(val) {
|
|
var typeOfVal = typeof val;
|
|
if (true) {
|
|
typeOfVal = miniKindOf(val);
|
|
}
|
|
return typeOfVal;
|
|
}
|
|
function createStore(reducer, preloadedState, enhancer) {
|
|
var _ref2;
|
|
if (typeof preloadedState === "function" && typeof enhancer === "function" || typeof enhancer === "function" && typeof arguments[3] === "function") {
|
|
throw new Error(false ? formatProdErrorMessage(0) : "It looks like you are passing several store enhancers to createStore(). This is not supported. Instead, compose them together to a single function. See https://redux.js.org/tutorials/fundamentals/part-4-store#creating-a-store-with-enhancers for an example.");
|
|
}
|
|
if (typeof preloadedState === "function" && typeof enhancer === "undefined") {
|
|
enhancer = preloadedState;
|
|
preloadedState = void 0;
|
|
}
|
|
if (typeof enhancer !== "undefined") {
|
|
if (typeof enhancer !== "function") {
|
|
throw new Error(false ? formatProdErrorMessage(1) : "Expected the enhancer to be a function. Instead, received: '" + kindOf(enhancer) + "'");
|
|
}
|
|
return enhancer(createStore)(reducer, preloadedState);
|
|
}
|
|
if (typeof reducer !== "function") {
|
|
throw new Error(false ? formatProdErrorMessage(2) : "Expected the root reducer to be a function. Instead, received: '" + kindOf(reducer) + "'");
|
|
}
|
|
var currentReducer = reducer;
|
|
var currentState = preloadedState;
|
|
var currentListeners = [];
|
|
var nextListeners = currentListeners;
|
|
var isDispatching = false;
|
|
function ensureCanMutateNextListeners() {
|
|
if (nextListeners === currentListeners) {
|
|
nextListeners = currentListeners.slice();
|
|
}
|
|
}
|
|
function getState() {
|
|
if (isDispatching) {
|
|
throw new Error(false ? formatProdErrorMessage(3) : "You may not call store.getState() while the reducer is executing. The reducer has already received the state as an argument. Pass it down from the top reducer instead of reading it from the store.");
|
|
}
|
|
return currentState;
|
|
}
|
|
function subscribe(listener2) {
|
|
if (typeof listener2 !== "function") {
|
|
throw new Error(false ? formatProdErrorMessage(4) : "Expected the listener to be a function. Instead, received: '" + kindOf(listener2) + "'");
|
|
}
|
|
if (isDispatching) {
|
|
throw new Error(false ? formatProdErrorMessage(5) : "You may not call store.subscribe() while the reducer is executing. If you would like to be notified after the store has been updated, subscribe from a component and invoke store.getState() in the callback to access the latest state. See https://redux.js.org/api/store#subscribelistener for more details.");
|
|
}
|
|
var isSubscribed = true;
|
|
ensureCanMutateNextListeners();
|
|
nextListeners.push(listener2);
|
|
return function unsubscribe() {
|
|
if (!isSubscribed) {
|
|
return;
|
|
}
|
|
if (isDispatching) {
|
|
throw new Error(false ? formatProdErrorMessage(6) : "You may not unsubscribe from a store listener while the reducer is executing. See https://redux.js.org/api/store#subscribelistener for more details.");
|
|
}
|
|
isSubscribed = false;
|
|
ensureCanMutateNextListeners();
|
|
var index = nextListeners.indexOf(listener2);
|
|
nextListeners.splice(index, 1);
|
|
currentListeners = null;
|
|
};
|
|
}
|
|
function dispatch(action) {
|
|
if (!isPlainObject(action)) {
|
|
throw new Error(false ? formatProdErrorMessage(7) : "Actions must be plain objects. Instead, the actual type was: '" + kindOf(action) + "'. You may need to add middleware to your store setup to handle dispatching other values, such as 'redux-thunk' to handle dispatching functions. See https://redux.js.org/tutorials/fundamentals/part-4-store#middleware and https://redux.js.org/tutorials/fundamentals/part-6-async-logic#using-the-redux-thunk-middleware for examples.");
|
|
}
|
|
if (typeof action.type === "undefined") {
|
|
throw new Error(false ? formatProdErrorMessage(8) : 'Actions may not have an undefined "type" property. You may have misspelled an action type string constant.');
|
|
}
|
|
if (isDispatching) {
|
|
throw new Error(false ? formatProdErrorMessage(9) : "Reducers may not dispatch actions.");
|
|
}
|
|
try {
|
|
isDispatching = true;
|
|
currentState = currentReducer(currentState, action);
|
|
} finally {
|
|
isDispatching = false;
|
|
}
|
|
var listeners = currentListeners = nextListeners;
|
|
for (var i2 = 0; i2 < listeners.length; i2++) {
|
|
var listener2 = listeners[i2];
|
|
listener2();
|
|
}
|
|
return action;
|
|
}
|
|
function replaceReducer(nextReducer) {
|
|
if (typeof nextReducer !== "function") {
|
|
throw new Error(false ? formatProdErrorMessage(10) : "Expected the nextReducer to be a function. Instead, received: '" + kindOf(nextReducer));
|
|
}
|
|
currentReducer = nextReducer;
|
|
dispatch({
|
|
type: ActionTypes.REPLACE
|
|
});
|
|
}
|
|
function observable() {
|
|
var _ref;
|
|
var outerSubscribe = subscribe;
|
|
return _ref = {
|
|
subscribe: function subscribe2(observer) {
|
|
if (typeof observer !== "object" || observer === null) {
|
|
throw new Error(false ? formatProdErrorMessage(11) : "Expected the observer to be an object. Instead, received: '" + kindOf(observer) + "'");
|
|
}
|
|
function observeState() {
|
|
if (observer.next) {
|
|
observer.next(getState());
|
|
}
|
|
}
|
|
observeState();
|
|
var unsubscribe = outerSubscribe(observeState);
|
|
return {
|
|
unsubscribe
|
|
};
|
|
}
|
|
}, _ref[$$observable] = function() {
|
|
return this;
|
|
}, _ref;
|
|
}
|
|
dispatch({
|
|
type: ActionTypes.INIT
|
|
});
|
|
return _ref2 = {
|
|
dispatch,
|
|
subscribe,
|
|
getState,
|
|
replaceReducer
|
|
}, _ref2[$$observable] = observable, _ref2;
|
|
}
|
|
function warning(message) {
|
|
if (typeof console !== "undefined" && typeof console.error === "function") {
|
|
console.error(message);
|
|
}
|
|
try {
|
|
throw new Error(message);
|
|
} catch (e) {
|
|
}
|
|
}
|
|
function getUnexpectedStateShapeWarningMessage(inputState, reducers, action, unexpectedKeyCache) {
|
|
var reducerKeys = Object.keys(reducers);
|
|
var argumentName = action && action.type === ActionTypes.INIT ? "preloadedState argument passed to createStore" : "previous state received by the reducer";
|
|
if (reducerKeys.length === 0) {
|
|
return "Store does not have a valid reducer. Make sure the argument passed to combineReducers is an object whose values are reducers.";
|
|
}
|
|
if (!isPlainObject(inputState)) {
|
|
return "The " + argumentName + ' has unexpected type of "' + kindOf(inputState) + '". Expected argument to be an object with the following ' + ('keys: "' + reducerKeys.join('", "') + '"');
|
|
}
|
|
var unexpectedKeys = Object.keys(inputState).filter(function(key) {
|
|
return !reducers.hasOwnProperty(key) && !unexpectedKeyCache[key];
|
|
});
|
|
unexpectedKeys.forEach(function(key) {
|
|
unexpectedKeyCache[key] = true;
|
|
});
|
|
if (action && action.type === ActionTypes.REPLACE)
|
|
return;
|
|
if (unexpectedKeys.length > 0) {
|
|
return "Unexpected " + (unexpectedKeys.length > 1 ? "keys" : "key") + " " + ('"' + unexpectedKeys.join('", "') + '" found in ' + argumentName + ". ") + "Expected to find one of the known reducer keys instead: " + ('"' + reducerKeys.join('", "') + '". Unexpected keys will be ignored.');
|
|
}
|
|
}
|
|
function assertReducerShape(reducers) {
|
|
Object.keys(reducers).forEach(function(key) {
|
|
var reducer = reducers[key];
|
|
var initialState2 = reducer(void 0, {
|
|
type: ActionTypes.INIT
|
|
});
|
|
if (typeof initialState2 === "undefined") {
|
|
throw new Error(false ? formatProdErrorMessage(12) : 'The slice reducer for key "' + key + `" returned undefined during initialization. If the state passed to the reducer is undefined, you must explicitly return the initial state. The initial state may not be undefined. If you don't want to set a value for this reducer, you can use null instead of undefined.`);
|
|
}
|
|
if (typeof reducer(void 0, {
|
|
type: ActionTypes.PROBE_UNKNOWN_ACTION()
|
|
}) === "undefined") {
|
|
throw new Error(false ? formatProdErrorMessage(13) : 'The slice reducer for key "' + key + '" returned undefined when probed with a random type. ' + ("Don't try to handle '" + ActionTypes.INIT + `' or other actions in "redux/*" `) + "namespace. They are considered private. Instead, you must return the current state for any unknown actions, unless it is undefined, in which case you must return the initial state, regardless of the action type. The initial state may not be undefined, but can be null.");
|
|
}
|
|
});
|
|
}
|
|
function combineReducers(reducers) {
|
|
var reducerKeys = Object.keys(reducers);
|
|
var finalReducers = {};
|
|
for (var i2 = 0; i2 < reducerKeys.length; i2++) {
|
|
var key = reducerKeys[i2];
|
|
if (true) {
|
|
if (typeof reducers[key] === "undefined") {
|
|
warning('No reducer provided for key "' + key + '"');
|
|
}
|
|
}
|
|
if (typeof reducers[key] === "function") {
|
|
finalReducers[key] = reducers[key];
|
|
}
|
|
}
|
|
var finalReducerKeys = Object.keys(finalReducers);
|
|
var unexpectedKeyCache;
|
|
if (true) {
|
|
unexpectedKeyCache = {};
|
|
}
|
|
var shapeAssertionError;
|
|
try {
|
|
assertReducerShape(finalReducers);
|
|
} catch (e) {
|
|
shapeAssertionError = e;
|
|
}
|
|
return function combination(state, action) {
|
|
if (state === void 0) {
|
|
state = {};
|
|
}
|
|
if (shapeAssertionError) {
|
|
throw shapeAssertionError;
|
|
}
|
|
if (true) {
|
|
var warningMessage = getUnexpectedStateShapeWarningMessage(state, finalReducers, action, unexpectedKeyCache);
|
|
if (warningMessage) {
|
|
warning(warningMessage);
|
|
}
|
|
}
|
|
var hasChanged = false;
|
|
var nextState = {};
|
|
for (var _i = 0; _i < finalReducerKeys.length; _i++) {
|
|
var _key = finalReducerKeys[_i];
|
|
var reducer = finalReducers[_key];
|
|
var previousStateForKey = state[_key];
|
|
var nextStateForKey = reducer(previousStateForKey, action);
|
|
if (typeof nextStateForKey === "undefined") {
|
|
var actionType = action && action.type;
|
|
throw new Error(false ? formatProdErrorMessage(14) : "When called with an action of type " + (actionType ? '"' + String(actionType) + '"' : "(unknown type)") + ', the slice reducer for key "' + _key + '" returned undefined. To ignore an action, you must explicitly return the previous state. If you want this reducer to hold no value, you can return null instead of undefined.');
|
|
}
|
|
nextState[_key] = nextStateForKey;
|
|
hasChanged = hasChanged || nextStateForKey !== previousStateForKey;
|
|
}
|
|
hasChanged = hasChanged || finalReducerKeys.length !== Object.keys(state).length;
|
|
return hasChanged ? nextState : state;
|
|
};
|
|
}
|
|
function compose() {
|
|
for (var _len = arguments.length, funcs = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
funcs[_key] = arguments[_key];
|
|
}
|
|
if (funcs.length === 0) {
|
|
return function(arg) {
|
|
return arg;
|
|
};
|
|
}
|
|
if (funcs.length === 1) {
|
|
return funcs[0];
|
|
}
|
|
return funcs.reduce(function(a2, b2) {
|
|
return function() {
|
|
return a2(b2.apply(void 0, arguments));
|
|
};
|
|
});
|
|
}
|
|
function applyMiddleware() {
|
|
for (var _len = arguments.length, middlewares = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
middlewares[_key] = arguments[_key];
|
|
}
|
|
return function(createStore2) {
|
|
return function() {
|
|
var store2 = createStore2.apply(void 0, arguments);
|
|
var _dispatch = function dispatch() {
|
|
throw new Error(false ? formatProdErrorMessage(15) : "Dispatching while constructing your middleware is not allowed. Other middleware would not be applied to this dispatch.");
|
|
};
|
|
var middlewareAPI = {
|
|
getState: store2.getState,
|
|
dispatch: function dispatch() {
|
|
return _dispatch.apply(void 0, arguments);
|
|
}
|
|
};
|
|
var chain = middlewares.map(function(middleware) {
|
|
return middleware(middlewareAPI);
|
|
});
|
|
_dispatch = compose.apply(void 0, chain)(store2.dispatch);
|
|
return _objectSpread2(_objectSpread2({}, store2), {}, {
|
|
dispatch: _dispatch
|
|
});
|
|
};
|
|
};
|
|
}
|
|
|
|
// node_modules/redux-thunk/es/index.js
|
|
function createThunkMiddleware(extraArgument) {
|
|
var middleware = function middleware2(_ref) {
|
|
var dispatch = _ref.dispatch, getState = _ref.getState;
|
|
return function(next) {
|
|
return function(action) {
|
|
if (typeof action === "function") {
|
|
return action(dispatch, getState, extraArgument);
|
|
}
|
|
return next(action);
|
|
};
|
|
};
|
|
};
|
|
return middleware;
|
|
}
|
|
var thunk = createThunkMiddleware();
|
|
thunk.withExtraArgument = createThunkMiddleware;
|
|
var es_default = thunk;
|
|
|
|
// node_modules/@reduxjs/toolkit/dist/redux-toolkit.esm.js
|
|
var __extends = function() {
|
|
var extendStatics = function(d2, b2) {
|
|
extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d3, b3) {
|
|
d3.__proto__ = b3;
|
|
} || function(d3, b3) {
|
|
for (var p2 in b3)
|
|
if (Object.prototype.hasOwnProperty.call(b3, p2))
|
|
d3[p2] = b3[p2];
|
|
};
|
|
return extendStatics(d2, b2);
|
|
};
|
|
return function(d2, b2) {
|
|
if (typeof b2 !== "function" && b2 !== null)
|
|
throw new TypeError("Class extends value " + String(b2) + " is not a constructor or null");
|
|
extendStatics(d2, b2);
|
|
function __() {
|
|
this.constructor = d2;
|
|
}
|
|
d2.prototype = b2 === null ? Object.create(b2) : (__.prototype = b2.prototype, new __());
|
|
};
|
|
}();
|
|
var __generator = function(thisArg, body) {
|
|
var _2 = { label: 0, sent: function() {
|
|
if (t2[0] & 1)
|
|
throw t2[1];
|
|
return t2[1];
|
|
}, trys: [], ops: [] }, f2, y2, t2, g2;
|
|
return g2 = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g2[Symbol.iterator] = function() {
|
|
return this;
|
|
}), g2;
|
|
function verb(n2) {
|
|
return function(v2) {
|
|
return step([n2, v2]);
|
|
};
|
|
}
|
|
function step(op) {
|
|
if (f2)
|
|
throw new TypeError("Generator is already executing.");
|
|
while (_2)
|
|
try {
|
|
if (f2 = 1, y2 && (t2 = op[0] & 2 ? y2["return"] : op[0] ? y2["throw"] || ((t2 = y2["return"]) && t2.call(y2), 0) : y2.next) && !(t2 = t2.call(y2, op[1])).done)
|
|
return t2;
|
|
if (y2 = 0, t2)
|
|
op = [op[0] & 2, t2.value];
|
|
switch (op[0]) {
|
|
case 0:
|
|
case 1:
|
|
t2 = op;
|
|
break;
|
|
case 4:
|
|
_2.label++;
|
|
return { value: op[1], done: false };
|
|
case 5:
|
|
_2.label++;
|
|
y2 = op[1];
|
|
op = [0];
|
|
continue;
|
|
case 7:
|
|
op = _2.ops.pop();
|
|
_2.trys.pop();
|
|
continue;
|
|
default:
|
|
if (!(t2 = _2.trys, t2 = t2.length > 0 && t2[t2.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
_2 = 0;
|
|
continue;
|
|
}
|
|
if (op[0] === 3 && (!t2 || op[1] > t2[0] && op[1] < t2[3])) {
|
|
_2.label = op[1];
|
|
break;
|
|
}
|
|
if (op[0] === 6 && _2.label < t2[1]) {
|
|
_2.label = t2[1];
|
|
t2 = op;
|
|
break;
|
|
}
|
|
if (t2 && _2.label < t2[2]) {
|
|
_2.label = t2[2];
|
|
_2.ops.push(op);
|
|
break;
|
|
}
|
|
if (t2[2])
|
|
_2.ops.pop();
|
|
_2.trys.pop();
|
|
continue;
|
|
}
|
|
op = body.call(thisArg, _2);
|
|
} catch (e) {
|
|
op = [6, e];
|
|
y2 = 0;
|
|
} finally {
|
|
f2 = t2 = 0;
|
|
}
|
|
if (op[0] & 5)
|
|
throw op[1];
|
|
return { value: op[0] ? op[1] : void 0, done: true };
|
|
}
|
|
};
|
|
var __spreadArray = function(to, from) {
|
|
for (var i2 = 0, il = from.length, j2 = to.length; i2 < il; i2++, j2++)
|
|
to[j2] = from[i2];
|
|
return to;
|
|
};
|
|
var __defProp2 = Object.defineProperty;
|
|
var __defProps = Object.defineProperties;
|
|
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
var __defNormalProp = function(obj, key, value) {
|
|
return key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
};
|
|
var __spreadValues = function(a2, b2) {
|
|
for (var prop in b2 || (b2 = {}))
|
|
if (__hasOwnProp2.call(b2, prop))
|
|
__defNormalProp(a2, prop, b2[prop]);
|
|
if (__getOwnPropSymbols)
|
|
for (var _i = 0, _c = __getOwnPropSymbols(b2); _i < _c.length; _i++) {
|
|
var prop = _c[_i];
|
|
if (__propIsEnum.call(b2, prop))
|
|
__defNormalProp(a2, prop, b2[prop]);
|
|
}
|
|
return a2;
|
|
};
|
|
var __spreadProps = function(a2, b2) {
|
|
return __defProps(a2, __getOwnPropDescs(b2));
|
|
};
|
|
var __async2 = function(__this, __arguments, generator) {
|
|
return new Promise(function(resolve, reject) {
|
|
var fulfilled = function(value) {
|
|
try {
|
|
step(generator.next(value));
|
|
} catch (e) {
|
|
reject(e);
|
|
}
|
|
};
|
|
var rejected = function(value) {
|
|
try {
|
|
step(generator.throw(value));
|
|
} catch (e) {
|
|
reject(e);
|
|
}
|
|
};
|
|
var step = function(x2) {
|
|
return x2.done ? resolve(x2.value) : Promise.resolve(x2.value).then(fulfilled, rejected);
|
|
};
|
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
});
|
|
};
|
|
var composeWithDevTools = typeof window !== "undefined" && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ ? window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ : function() {
|
|
if (arguments.length === 0)
|
|
return void 0;
|
|
if (typeof arguments[0] === "object")
|
|
return compose;
|
|
return compose.apply(null, arguments);
|
|
};
|
|
var devToolsEnhancer = typeof window !== "undefined" && window.__REDUX_DEVTOOLS_EXTENSION__ ? window.__REDUX_DEVTOOLS_EXTENSION__ : function() {
|
|
return function(noop2) {
|
|
return noop2;
|
|
};
|
|
};
|
|
function isPlainObject2(value) {
|
|
if (typeof value !== "object" || value === null)
|
|
return false;
|
|
var proto = Object.getPrototypeOf(value);
|
|
if (proto === null)
|
|
return true;
|
|
var baseProto = proto;
|
|
while (Object.getPrototypeOf(baseProto) !== null) {
|
|
baseProto = Object.getPrototypeOf(baseProto);
|
|
}
|
|
return proto === baseProto;
|
|
}
|
|
var hasMatchFunction = function(v2) {
|
|
return v2 && typeof v2.match === "function";
|
|
};
|
|
function createAction(type, prepareAction) {
|
|
function actionCreator() {
|
|
var args = [];
|
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
args[_i] = arguments[_i];
|
|
}
|
|
if (prepareAction) {
|
|
var prepared = prepareAction.apply(void 0, args);
|
|
if (!prepared) {
|
|
throw new Error("prepareAction did not return an object");
|
|
}
|
|
return __spreadValues(__spreadValues({
|
|
type,
|
|
payload: prepared.payload
|
|
}, "meta" in prepared && { meta: prepared.meta }), "error" in prepared && { error: prepared.error });
|
|
}
|
|
return { type, payload: args[0] };
|
|
}
|
|
actionCreator.toString = function() {
|
|
return "" + type;
|
|
};
|
|
actionCreator.type = type;
|
|
actionCreator.match = function(action) {
|
|
return action.type === type;
|
|
};
|
|
return actionCreator;
|
|
}
|
|
function isActionCreator(action) {
|
|
return typeof action === "function" && "type" in action && hasMatchFunction(action);
|
|
}
|
|
function getMessage(type) {
|
|
var splitType = type ? ("" + type).split("/") : [];
|
|
var actionName = splitType[splitType.length - 1] || "actionCreator";
|
|
return 'Detected an action creator with type "' + (type || "unknown") + "\" being dispatched. \nMake sure you're calling the action creator before dispatching, i.e. `dispatch(" + actionName + "())` instead of `dispatch(" + actionName + ")`. This is necessary even if the action has no payload.";
|
|
}
|
|
function createActionCreatorInvariantMiddleware(options) {
|
|
if (options === void 0) {
|
|
options = {};
|
|
}
|
|
if (false) {
|
|
return function() {
|
|
return function(next) {
|
|
return function(action) {
|
|
return next(action);
|
|
};
|
|
};
|
|
};
|
|
}
|
|
var _c = options.isActionCreator, isActionCreator2 = _c === void 0 ? isActionCreator : _c;
|
|
return function() {
|
|
return function(next) {
|
|
return function(action) {
|
|
if (isActionCreator2(action)) {
|
|
console.warn(getMessage(action.type));
|
|
}
|
|
return next(action);
|
|
};
|
|
};
|
|
};
|
|
}
|
|
function getTimeMeasureUtils(maxDelay, fnName) {
|
|
var elapsed = 0;
|
|
return {
|
|
measureTime: function(fn2) {
|
|
var started = Date.now();
|
|
try {
|
|
return fn2();
|
|
} finally {
|
|
var finished = Date.now();
|
|
elapsed += finished - started;
|
|
}
|
|
},
|
|
warnIfExceeded: function() {
|
|
if (elapsed > maxDelay) {
|
|
console.warn(fnName + " took " + elapsed + "ms, which is more than the warning threshold of " + maxDelay + "ms. \nIf your state or actions are very large, you may want to disable the middleware as it might cause too much of a slowdown in development mode. See https://redux-toolkit.js.org/api/getDefaultMiddleware for instructions.\nIt is disabled in production builds, so you don't need to worry about that.");
|
|
}
|
|
}
|
|
};
|
|
}
|
|
var MiddlewareArray = function(_super) {
|
|
__extends(MiddlewareArray2, _super);
|
|
function MiddlewareArray2() {
|
|
var args = [];
|
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
args[_i] = arguments[_i];
|
|
}
|
|
var _this = _super.apply(this, args) || this;
|
|
Object.setPrototypeOf(_this, MiddlewareArray2.prototype);
|
|
return _this;
|
|
}
|
|
Object.defineProperty(MiddlewareArray2, Symbol.species, {
|
|
get: function() {
|
|
return MiddlewareArray2;
|
|
},
|
|
enumerable: false,
|
|
configurable: true
|
|
});
|
|
MiddlewareArray2.prototype.concat = function() {
|
|
var arr = [];
|
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
arr[_i] = arguments[_i];
|
|
}
|
|
return _super.prototype.concat.apply(this, arr);
|
|
};
|
|
MiddlewareArray2.prototype.prepend = function() {
|
|
var arr = [];
|
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
arr[_i] = arguments[_i];
|
|
}
|
|
if (arr.length === 1 && Array.isArray(arr[0])) {
|
|
return new (MiddlewareArray2.bind.apply(MiddlewareArray2, __spreadArray([void 0], arr[0].concat(this))))();
|
|
}
|
|
return new (MiddlewareArray2.bind.apply(MiddlewareArray2, __spreadArray([void 0], arr.concat(this))))();
|
|
};
|
|
return MiddlewareArray2;
|
|
}(Array);
|
|
var EnhancerArray = function(_super) {
|
|
__extends(EnhancerArray2, _super);
|
|
function EnhancerArray2() {
|
|
var args = [];
|
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
args[_i] = arguments[_i];
|
|
}
|
|
var _this = _super.apply(this, args) || this;
|
|
Object.setPrototypeOf(_this, EnhancerArray2.prototype);
|
|
return _this;
|
|
}
|
|
Object.defineProperty(EnhancerArray2, Symbol.species, {
|
|
get: function() {
|
|
return EnhancerArray2;
|
|
},
|
|
enumerable: false,
|
|
configurable: true
|
|
});
|
|
EnhancerArray2.prototype.concat = function() {
|
|
var arr = [];
|
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
arr[_i] = arguments[_i];
|
|
}
|
|
return _super.prototype.concat.apply(this, arr);
|
|
};
|
|
EnhancerArray2.prototype.prepend = function() {
|
|
var arr = [];
|
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
arr[_i] = arguments[_i];
|
|
}
|
|
if (arr.length === 1 && Array.isArray(arr[0])) {
|
|
return new (EnhancerArray2.bind.apply(EnhancerArray2, __spreadArray([void 0], arr[0].concat(this))))();
|
|
}
|
|
return new (EnhancerArray2.bind.apply(EnhancerArray2, __spreadArray([void 0], arr.concat(this))))();
|
|
};
|
|
return EnhancerArray2;
|
|
}(Array);
|
|
function freezeDraftable(val) {
|
|
return t(val) ? immer_esm_default(val, function() {
|
|
}) : val;
|
|
}
|
|
var isProduction = false;
|
|
var prefix = "Invariant failed";
|
|
function invariant(condition, message) {
|
|
if (condition) {
|
|
return;
|
|
}
|
|
if (isProduction) {
|
|
throw new Error(prefix);
|
|
}
|
|
throw new Error(prefix + ": " + (message || ""));
|
|
}
|
|
function stringify(obj, serializer, indent, decycler) {
|
|
return JSON.stringify(obj, getSerialize(serializer, decycler), indent);
|
|
}
|
|
function getSerialize(serializer, decycler) {
|
|
var stack = [], keys = [];
|
|
if (!decycler)
|
|
decycler = function(_2, value) {
|
|
if (stack[0] === value)
|
|
return "[Circular ~]";
|
|
return "[Circular ~." + keys.slice(0, stack.indexOf(value)).join(".") + "]";
|
|
};
|
|
return function(key, value) {
|
|
if (stack.length > 0) {
|
|
var thisPos = stack.indexOf(this);
|
|
~thisPos ? stack.splice(thisPos + 1) : stack.push(this);
|
|
~thisPos ? keys.splice(thisPos, Infinity, key) : keys.push(key);
|
|
if (~stack.indexOf(value))
|
|
value = decycler.call(this, key, value);
|
|
} else
|
|
stack.push(value);
|
|
return serializer == null ? value : serializer.call(this, key, value);
|
|
};
|
|
}
|
|
function isImmutableDefault(value) {
|
|
return typeof value !== "object" || value == null || Object.isFrozen(value);
|
|
}
|
|
function trackForMutations(isImmutable, ignorePaths, obj) {
|
|
var trackedProperties = trackProperties(isImmutable, ignorePaths, obj);
|
|
return {
|
|
detectMutations: function() {
|
|
return detectMutations(isImmutable, ignorePaths, trackedProperties, obj);
|
|
}
|
|
};
|
|
}
|
|
function trackProperties(isImmutable, ignorePaths, obj, path, checkedObjects) {
|
|
if (ignorePaths === void 0) {
|
|
ignorePaths = [];
|
|
}
|
|
if (path === void 0) {
|
|
path = "";
|
|
}
|
|
if (checkedObjects === void 0) {
|
|
checkedObjects = new Set();
|
|
}
|
|
var tracked = { value: obj };
|
|
if (!isImmutable(obj) && !checkedObjects.has(obj)) {
|
|
checkedObjects.add(obj);
|
|
tracked.children = {};
|
|
for (var key in obj) {
|
|
var childPath = path ? path + "." + key : key;
|
|
if (ignorePaths.length && ignorePaths.indexOf(childPath) !== -1) {
|
|
continue;
|
|
}
|
|
tracked.children[key] = trackProperties(isImmutable, ignorePaths, obj[key], childPath);
|
|
}
|
|
}
|
|
return tracked;
|
|
}
|
|
function detectMutations(isImmutable, ignoredPaths, trackedProperty, obj, sameParentRef, path) {
|
|
if (ignoredPaths === void 0) {
|
|
ignoredPaths = [];
|
|
}
|
|
if (sameParentRef === void 0) {
|
|
sameParentRef = false;
|
|
}
|
|
if (path === void 0) {
|
|
path = "";
|
|
}
|
|
var prevObj = trackedProperty ? trackedProperty.value : void 0;
|
|
var sameRef = prevObj === obj;
|
|
if (sameParentRef && !sameRef && !Number.isNaN(obj)) {
|
|
return { wasMutated: true, path };
|
|
}
|
|
if (isImmutable(prevObj) || isImmutable(obj)) {
|
|
return { wasMutated: false };
|
|
}
|
|
var keysToDetect = {};
|
|
for (var key in trackedProperty.children) {
|
|
keysToDetect[key] = true;
|
|
}
|
|
for (var key in obj) {
|
|
keysToDetect[key] = true;
|
|
}
|
|
var hasIgnoredPaths = ignoredPaths.length > 0;
|
|
var _loop_1 = function(key2) {
|
|
var nestedPath = path ? path + "." + key2 : key2;
|
|
if (hasIgnoredPaths) {
|
|
var hasMatches = ignoredPaths.some(function(ignored) {
|
|
if (ignored instanceof RegExp) {
|
|
return ignored.test(nestedPath);
|
|
}
|
|
return nestedPath === ignored;
|
|
});
|
|
if (hasMatches) {
|
|
return "continue";
|
|
}
|
|
}
|
|
var result = detectMutations(isImmutable, ignoredPaths, trackedProperty.children[key2], obj[key2], sameRef, nestedPath);
|
|
if (result.wasMutated) {
|
|
return { value: result };
|
|
}
|
|
};
|
|
for (var key in keysToDetect) {
|
|
var state_1 = _loop_1(key);
|
|
if (typeof state_1 === "object")
|
|
return state_1.value;
|
|
}
|
|
return { wasMutated: false };
|
|
}
|
|
function createImmutableStateInvariantMiddleware(options) {
|
|
if (options === void 0) {
|
|
options = {};
|
|
}
|
|
if (false) {
|
|
return function() {
|
|
return function(next) {
|
|
return function(action) {
|
|
return next(action);
|
|
};
|
|
};
|
|
};
|
|
}
|
|
var _c = options.isImmutable, isImmutable = _c === void 0 ? isImmutableDefault : _c, ignoredPaths = options.ignoredPaths, _d = options.warnAfter, warnAfter = _d === void 0 ? 32 : _d, ignore = options.ignore;
|
|
ignoredPaths = ignoredPaths || ignore;
|
|
var track = trackForMutations.bind(null, isImmutable, ignoredPaths);
|
|
return function(_c2) {
|
|
var getState = _c2.getState;
|
|
var state = getState();
|
|
var tracker = track(state);
|
|
var result;
|
|
return function(next) {
|
|
return function(action) {
|
|
var measureUtils = getTimeMeasureUtils(warnAfter, "ImmutableStateInvariantMiddleware");
|
|
measureUtils.measureTime(function() {
|
|
state = getState();
|
|
result = tracker.detectMutations();
|
|
tracker = track(state);
|
|
invariant(!result.wasMutated, "A state mutation was detected between dispatches, in the path '" + (result.path || "") + "'. This may cause incorrect behavior. (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)");
|
|
});
|
|
var dispatchedAction = next(action);
|
|
measureUtils.measureTime(function() {
|
|
state = getState();
|
|
result = tracker.detectMutations();
|
|
tracker = track(state);
|
|
result.wasMutated && invariant(!result.wasMutated, "A state mutation was detected inside a dispatch, in the path: " + (result.path || "") + ". Take a look at the reducer(s) handling the action " + stringify(action) + ". (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)");
|
|
});
|
|
measureUtils.warnIfExceeded();
|
|
return dispatchedAction;
|
|
};
|
|
};
|
|
};
|
|
}
|
|
function isPlain(val) {
|
|
var type = typeof val;
|
|
return val == null || type === "string" || type === "boolean" || type === "number" || Array.isArray(val) || isPlainObject2(val);
|
|
}
|
|
function findNonSerializableValue(value, path, isSerializable, getEntries, ignoredPaths, cache) {
|
|
if (path === void 0) {
|
|
path = "";
|
|
}
|
|
if (isSerializable === void 0) {
|
|
isSerializable = isPlain;
|
|
}
|
|
if (ignoredPaths === void 0) {
|
|
ignoredPaths = [];
|
|
}
|
|
var foundNestedSerializable;
|
|
if (!isSerializable(value)) {
|
|
return {
|
|
keyPath: path || "<root>",
|
|
value
|
|
};
|
|
}
|
|
if (typeof value !== "object" || value === null) {
|
|
return false;
|
|
}
|
|
if (cache == null ? void 0 : cache.has(value))
|
|
return false;
|
|
var entries = getEntries != null ? getEntries(value) : Object.entries(value);
|
|
var hasIgnoredPaths = ignoredPaths.length > 0;
|
|
var _loop_2 = function(key2, nestedValue2) {
|
|
var nestedPath = path ? path + "." + key2 : key2;
|
|
if (hasIgnoredPaths) {
|
|
var hasMatches = ignoredPaths.some(function(ignored) {
|
|
if (ignored instanceof RegExp) {
|
|
return ignored.test(nestedPath);
|
|
}
|
|
return nestedPath === ignored;
|
|
});
|
|
if (hasMatches) {
|
|
return "continue";
|
|
}
|
|
}
|
|
if (!isSerializable(nestedValue2)) {
|
|
return { value: {
|
|
keyPath: nestedPath,
|
|
value: nestedValue2
|
|
} };
|
|
}
|
|
if (typeof nestedValue2 === "object") {
|
|
foundNestedSerializable = findNonSerializableValue(nestedValue2, nestedPath, isSerializable, getEntries, ignoredPaths, cache);
|
|
if (foundNestedSerializable) {
|
|
return { value: foundNestedSerializable };
|
|
}
|
|
}
|
|
};
|
|
for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
|
|
var _c = entries_1[_i], key = _c[0], nestedValue = _c[1];
|
|
var state_2 = _loop_2(key, nestedValue);
|
|
if (typeof state_2 === "object")
|
|
return state_2.value;
|
|
}
|
|
if (cache && isNestedFrozen(value))
|
|
cache.add(value);
|
|
return false;
|
|
}
|
|
function isNestedFrozen(value) {
|
|
if (!Object.isFrozen(value))
|
|
return false;
|
|
for (var _i = 0, _c = Object.values(value); _i < _c.length; _i++) {
|
|
var nestedValue = _c[_i];
|
|
if (typeof nestedValue !== "object" || nestedValue === null)
|
|
continue;
|
|
if (!isNestedFrozen(nestedValue))
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
function createSerializableStateInvariantMiddleware(options) {
|
|
if (options === void 0) {
|
|
options = {};
|
|
}
|
|
if (false) {
|
|
return function() {
|
|
return function(next) {
|
|
return function(action) {
|
|
return next(action);
|
|
};
|
|
};
|
|
};
|
|
}
|
|
var _c = options.isSerializable, isSerializable = _c === void 0 ? isPlain : _c, getEntries = options.getEntries, _d = options.ignoredActions, ignoredActions = _d === void 0 ? [] : _d, _e = options.ignoredActionPaths, ignoredActionPaths = _e === void 0 ? ["meta.arg", "meta.baseQueryMeta"] : _e, _f = options.ignoredPaths, ignoredPaths = _f === void 0 ? [] : _f, _g = options.warnAfter, warnAfter = _g === void 0 ? 32 : _g, _h = options.ignoreState, ignoreState = _h === void 0 ? false : _h, _j = options.ignoreActions, ignoreActions = _j === void 0 ? false : _j, _k = options.disableCache, disableCache = _k === void 0 ? false : _k;
|
|
var cache = !disableCache && WeakSet ? new WeakSet() : void 0;
|
|
return function(storeAPI) {
|
|
return function(next) {
|
|
return function(action) {
|
|
var result = next(action);
|
|
var measureUtils = getTimeMeasureUtils(warnAfter, "SerializableStateInvariantMiddleware");
|
|
if (!ignoreActions && !(ignoredActions.length && ignoredActions.indexOf(action.type) !== -1)) {
|
|
measureUtils.measureTime(function() {
|
|
var foundActionNonSerializableValue = findNonSerializableValue(action, "", isSerializable, getEntries, ignoredActionPaths, cache);
|
|
if (foundActionNonSerializableValue) {
|
|
var keyPath = foundActionNonSerializableValue.keyPath, value = foundActionNonSerializableValue.value;
|
|
console.error("A non-serializable value was detected in an action, in the path: `" + keyPath + "`. Value:", value, "\nTake a look at the logic that dispatched this action: ", action, "\n(See https://redux.js.org/faq/actions#why-should-type-be-a-string-or-at-least-serializable-why-should-my-action-types-be-constants)", "\n(To allow non-serializable values see: https://redux-toolkit.js.org/usage/usage-guide#working-with-non-serializable-data)");
|
|
}
|
|
});
|
|
}
|
|
if (!ignoreState) {
|
|
measureUtils.measureTime(function() {
|
|
var state = storeAPI.getState();
|
|
var foundStateNonSerializableValue = findNonSerializableValue(state, "", isSerializable, getEntries, ignoredPaths, cache);
|
|
if (foundStateNonSerializableValue) {
|
|
var keyPath = foundStateNonSerializableValue.keyPath, value = foundStateNonSerializableValue.value;
|
|
console.error("A non-serializable value was detected in the state, in the path: `" + keyPath + "`. Value:", value, "\nTake a look at the reducer(s) handling this action type: " + action.type + ".\n(See https://redux.js.org/faq/organizing-state#can-i-put-functions-promises-or-other-non-serializable-items-in-my-store-state)");
|
|
}
|
|
});
|
|
measureUtils.warnIfExceeded();
|
|
}
|
|
return result;
|
|
};
|
|
};
|
|
};
|
|
}
|
|
function isBoolean(x2) {
|
|
return typeof x2 === "boolean";
|
|
}
|
|
function curryGetDefaultMiddleware() {
|
|
return function curriedGetDefaultMiddleware(options) {
|
|
return getDefaultMiddleware(options);
|
|
};
|
|
}
|
|
function getDefaultMiddleware(options) {
|
|
if (options === void 0) {
|
|
options = {};
|
|
}
|
|
var _c = options.thunk, thunk2 = _c === void 0 ? true : _c, _d = options.immutableCheck, immutableCheck = _d === void 0 ? true : _d, _e = options.serializableCheck, serializableCheck = _e === void 0 ? true : _e, _f = options.actionCreatorCheck, actionCreatorCheck = _f === void 0 ? true : _f;
|
|
var middlewareArray = new MiddlewareArray();
|
|
if (thunk2) {
|
|
if (isBoolean(thunk2)) {
|
|
middlewareArray.push(es_default);
|
|
} else {
|
|
middlewareArray.push(es_default.withExtraArgument(thunk2.extraArgument));
|
|
}
|
|
}
|
|
if (true) {
|
|
if (immutableCheck) {
|
|
var immutableOptions = {};
|
|
if (!isBoolean(immutableCheck)) {
|
|
immutableOptions = immutableCheck;
|
|
}
|
|
middlewareArray.unshift(createImmutableStateInvariantMiddleware(immutableOptions));
|
|
}
|
|
if (serializableCheck) {
|
|
var serializableOptions = {};
|
|
if (!isBoolean(serializableCheck)) {
|
|
serializableOptions = serializableCheck;
|
|
}
|
|
middlewareArray.push(createSerializableStateInvariantMiddleware(serializableOptions));
|
|
}
|
|
if (actionCreatorCheck) {
|
|
var actionCreatorOptions = {};
|
|
if (!isBoolean(actionCreatorCheck)) {
|
|
actionCreatorOptions = actionCreatorCheck;
|
|
}
|
|
middlewareArray.unshift(createActionCreatorInvariantMiddleware(actionCreatorOptions));
|
|
}
|
|
}
|
|
return middlewareArray;
|
|
}
|
|
var IS_PRODUCTION = false;
|
|
function configureStore(options) {
|
|
var curriedGetDefaultMiddleware = curryGetDefaultMiddleware();
|
|
var _c = options || {}, _d = _c.reducer, reducer = _d === void 0 ? void 0 : _d, _e = _c.middleware, middleware = _e === void 0 ? curriedGetDefaultMiddleware() : _e, _f = _c.devTools, devTools = _f === void 0 ? true : _f, _g = _c.preloadedState, preloadedState = _g === void 0 ? void 0 : _g, _h = _c.enhancers, enhancers = _h === void 0 ? void 0 : _h;
|
|
var rootReducer;
|
|
if (typeof reducer === "function") {
|
|
rootReducer = reducer;
|
|
} else if (isPlainObject2(reducer)) {
|
|
rootReducer = combineReducers(reducer);
|
|
} else {
|
|
throw new Error('"reducer" is a required argument, and must be a function or an object of functions that can be passed to combineReducers');
|
|
}
|
|
var finalMiddleware = middleware;
|
|
if (typeof finalMiddleware === "function") {
|
|
finalMiddleware = finalMiddleware(curriedGetDefaultMiddleware);
|
|
if (!IS_PRODUCTION && !Array.isArray(finalMiddleware)) {
|
|
throw new Error("when using a middleware builder function, an array of middleware must be returned");
|
|
}
|
|
}
|
|
if (!IS_PRODUCTION && finalMiddleware.some(function(item) {
|
|
return typeof item !== "function";
|
|
})) {
|
|
throw new Error("each middleware provided to configureStore must be a function");
|
|
}
|
|
var middlewareEnhancer = applyMiddleware.apply(void 0, finalMiddleware);
|
|
var finalCompose = compose;
|
|
if (devTools) {
|
|
finalCompose = composeWithDevTools(__spreadValues({
|
|
trace: !IS_PRODUCTION
|
|
}, typeof devTools === "object" && devTools));
|
|
}
|
|
var defaultEnhancers = new EnhancerArray(middlewareEnhancer);
|
|
var storeEnhancers = defaultEnhancers;
|
|
if (Array.isArray(enhancers)) {
|
|
storeEnhancers = __spreadArray([middlewareEnhancer], enhancers);
|
|
} else if (typeof enhancers === "function") {
|
|
storeEnhancers = enhancers(defaultEnhancers);
|
|
}
|
|
var composedEnhancer = finalCompose.apply(void 0, storeEnhancers);
|
|
return createStore(rootReducer, preloadedState, composedEnhancer);
|
|
}
|
|
function executeReducerBuilderCallback(builderCallback) {
|
|
var actionsMap = {};
|
|
var actionMatchers = [];
|
|
var defaultCaseReducer;
|
|
var builder = {
|
|
addCase: function(typeOrActionCreator, reducer) {
|
|
if (true) {
|
|
if (actionMatchers.length > 0) {
|
|
throw new Error("`builder.addCase` should only be called before calling `builder.addMatcher`");
|
|
}
|
|
if (defaultCaseReducer) {
|
|
throw new Error("`builder.addCase` should only be called before calling `builder.addDefaultCase`");
|
|
}
|
|
}
|
|
var type = typeof typeOrActionCreator === "string" ? typeOrActionCreator : typeOrActionCreator.type;
|
|
if (!type) {
|
|
throw new Error("`builder.addCase` cannot be called with an empty action type");
|
|
}
|
|
if (type in actionsMap) {
|
|
throw new Error("`builder.addCase` cannot be called with two reducers for the same action type");
|
|
}
|
|
actionsMap[type] = reducer;
|
|
return builder;
|
|
},
|
|
addMatcher: function(matcher, reducer) {
|
|
if (true) {
|
|
if (defaultCaseReducer) {
|
|
throw new Error("`builder.addMatcher` should only be called before calling `builder.addDefaultCase`");
|
|
}
|
|
}
|
|
actionMatchers.push({ matcher, reducer });
|
|
return builder;
|
|
},
|
|
addDefaultCase: function(reducer) {
|
|
if (true) {
|
|
if (defaultCaseReducer) {
|
|
throw new Error("`builder.addDefaultCase` can only be called once");
|
|
}
|
|
}
|
|
defaultCaseReducer = reducer;
|
|
return builder;
|
|
}
|
|
};
|
|
builderCallback(builder);
|
|
return [actionsMap, actionMatchers, defaultCaseReducer];
|
|
}
|
|
function isStateFunction(x2) {
|
|
return typeof x2 === "function";
|
|
}
|
|
var hasWarnedAboutObjectNotation = false;
|
|
function createReducer(initialState2, mapOrBuilderCallback, actionMatchers, defaultCaseReducer) {
|
|
if (actionMatchers === void 0) {
|
|
actionMatchers = [];
|
|
}
|
|
if (true) {
|
|
if (typeof mapOrBuilderCallback === "object") {
|
|
if (!hasWarnedAboutObjectNotation) {
|
|
hasWarnedAboutObjectNotation = true;
|
|
console.warn("The object notation for `createReducer` is deprecated, and will be removed in RTK 2.0. Please use the 'builder callback' notation instead: https://redux-toolkit.js.org/api/createReducer");
|
|
}
|
|
}
|
|
}
|
|
var _c = typeof mapOrBuilderCallback === "function" ? executeReducerBuilderCallback(mapOrBuilderCallback) : [mapOrBuilderCallback, actionMatchers, defaultCaseReducer], actionsMap = _c[0], finalActionMatchers = _c[1], finalDefaultCaseReducer = _c[2];
|
|
var getInitialState;
|
|
if (isStateFunction(initialState2)) {
|
|
getInitialState = function() {
|
|
return freezeDraftable(initialState2());
|
|
};
|
|
} else {
|
|
var frozenInitialState_1 = freezeDraftable(initialState2);
|
|
getInitialState = function() {
|
|
return frozenInitialState_1;
|
|
};
|
|
}
|
|
function reducer(state, action) {
|
|
if (state === void 0) {
|
|
state = getInitialState();
|
|
}
|
|
var caseReducers = __spreadArray([
|
|
actionsMap[action.type]
|
|
], finalActionMatchers.filter(function(_c2) {
|
|
var matcher = _c2.matcher;
|
|
return matcher(action);
|
|
}).map(function(_c2) {
|
|
var reducer2 = _c2.reducer;
|
|
return reducer2;
|
|
}));
|
|
if (caseReducers.filter(function(cr) {
|
|
return !!cr;
|
|
}).length === 0) {
|
|
caseReducers = [finalDefaultCaseReducer];
|
|
}
|
|
return caseReducers.reduce(function(previousState, caseReducer) {
|
|
if (caseReducer) {
|
|
if (r(previousState)) {
|
|
var draft = previousState;
|
|
var result = caseReducer(draft, action);
|
|
if (result === void 0) {
|
|
return previousState;
|
|
}
|
|
return result;
|
|
} else if (!t(previousState)) {
|
|
var result = caseReducer(previousState, action);
|
|
if (result === void 0) {
|
|
if (previousState === null) {
|
|
return previousState;
|
|
}
|
|
throw Error("A case reducer on a non-draftable value must not return undefined");
|
|
}
|
|
return result;
|
|
} else {
|
|
return immer_esm_default(previousState, function(draft2) {
|
|
return caseReducer(draft2, action);
|
|
});
|
|
}
|
|
}
|
|
return previousState;
|
|
}, state);
|
|
}
|
|
reducer.getInitialState = getInitialState;
|
|
return reducer;
|
|
}
|
|
var hasWarnedAboutObjectNotation2 = false;
|
|
function getType2(slice, actionKey) {
|
|
return slice + "/" + actionKey;
|
|
}
|
|
function createSlice(options) {
|
|
var name = options.name;
|
|
if (!name) {
|
|
throw new Error("`name` is a required option for createSlice");
|
|
}
|
|
if (typeof process !== "undefined" && true) {
|
|
if (options.initialState === void 0) {
|
|
console.error("You must provide an `initialState` value that is not `undefined`. You may have misspelled `initialState`");
|
|
}
|
|
}
|
|
var initialState2 = typeof options.initialState == "function" ? options.initialState : freezeDraftable(options.initialState);
|
|
var reducers = options.reducers || {};
|
|
var reducerNames = Object.keys(reducers);
|
|
var sliceCaseReducersByName = {};
|
|
var sliceCaseReducersByType = {};
|
|
var actionCreators = {};
|
|
reducerNames.forEach(function(reducerName) {
|
|
var maybeReducerWithPrepare = reducers[reducerName];
|
|
var type = getType2(name, reducerName);
|
|
var caseReducer;
|
|
var prepareCallback;
|
|
if ("reducer" in maybeReducerWithPrepare) {
|
|
caseReducer = maybeReducerWithPrepare.reducer;
|
|
prepareCallback = maybeReducerWithPrepare.prepare;
|
|
} else {
|
|
caseReducer = maybeReducerWithPrepare;
|
|
}
|
|
sliceCaseReducersByName[reducerName] = caseReducer;
|
|
sliceCaseReducersByType[type] = caseReducer;
|
|
actionCreators[reducerName] = prepareCallback ? createAction(type, prepareCallback) : createAction(type);
|
|
});
|
|
function buildReducer() {
|
|
if (true) {
|
|
if (typeof options.extraReducers === "object") {
|
|
if (!hasWarnedAboutObjectNotation2) {
|
|
hasWarnedAboutObjectNotation2 = true;
|
|
console.warn("The object notation for `createSlice.extraReducers` is deprecated, and will be removed in RTK 2.0. Please use the 'builder callback' notation instead: https://redux-toolkit.js.org/api/createSlice");
|
|
}
|
|
}
|
|
}
|
|
var _c = typeof options.extraReducers === "function" ? executeReducerBuilderCallback(options.extraReducers) : [options.extraReducers], _d = _c[0], extraReducers = _d === void 0 ? {} : _d, _e = _c[1], actionMatchers = _e === void 0 ? [] : _e, _f = _c[2], defaultCaseReducer = _f === void 0 ? void 0 : _f;
|
|
var finalCaseReducers = __spreadValues(__spreadValues({}, extraReducers), sliceCaseReducersByType);
|
|
return createReducer(initialState2, function(builder) {
|
|
for (var key in finalCaseReducers) {
|
|
builder.addCase(key, finalCaseReducers[key]);
|
|
}
|
|
for (var _i = 0, actionMatchers_1 = actionMatchers; _i < actionMatchers_1.length; _i++) {
|
|
var m2 = actionMatchers_1[_i];
|
|
builder.addMatcher(m2.matcher, m2.reducer);
|
|
}
|
|
if (defaultCaseReducer) {
|
|
builder.addDefaultCase(defaultCaseReducer);
|
|
}
|
|
});
|
|
}
|
|
var _reducer;
|
|
return {
|
|
name,
|
|
reducer: function(state, action) {
|
|
if (!_reducer)
|
|
_reducer = buildReducer();
|
|
return _reducer(state, action);
|
|
},
|
|
actions: actionCreators,
|
|
caseReducers: sliceCaseReducersByName,
|
|
getInitialState: function() {
|
|
if (!_reducer)
|
|
_reducer = buildReducer();
|
|
return _reducer.getInitialState();
|
|
}
|
|
};
|
|
}
|
|
var urlAlphabet = "ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW";
|
|
var nanoid = function(size) {
|
|
if (size === void 0) {
|
|
size = 21;
|
|
}
|
|
var id = "";
|
|
var i2 = size;
|
|
while (i2--) {
|
|
id += urlAlphabet[Math.random() * 64 | 0];
|
|
}
|
|
return id;
|
|
};
|
|
var commonProperties = [
|
|
"name",
|
|
"message",
|
|
"stack",
|
|
"code"
|
|
];
|
|
var RejectWithValue = function() {
|
|
function RejectWithValue2(payload, meta) {
|
|
this.payload = payload;
|
|
this.meta = meta;
|
|
}
|
|
return RejectWithValue2;
|
|
}();
|
|
var FulfillWithMeta = function() {
|
|
function FulfillWithMeta2(payload, meta) {
|
|
this.payload = payload;
|
|
this.meta = meta;
|
|
}
|
|
return FulfillWithMeta2;
|
|
}();
|
|
var miniSerializeError = function(value) {
|
|
if (typeof value === "object" && value !== null) {
|
|
var simpleError = {};
|
|
for (var _i = 0, commonProperties_1 = commonProperties; _i < commonProperties_1.length; _i++) {
|
|
var property = commonProperties_1[_i];
|
|
if (typeof value[property] === "string") {
|
|
simpleError[property] = value[property];
|
|
}
|
|
}
|
|
return simpleError;
|
|
}
|
|
return { message: String(value) };
|
|
};
|
|
var createAsyncThunk = function() {
|
|
function createAsyncThunk2(typePrefix, payloadCreator, options) {
|
|
var fulfilled = createAction(typePrefix + "/fulfilled", function(payload, requestId, arg, meta) {
|
|
return {
|
|
payload,
|
|
meta: __spreadProps(__spreadValues({}, meta || {}), {
|
|
arg,
|
|
requestId,
|
|
requestStatus: "fulfilled"
|
|
})
|
|
};
|
|
});
|
|
var pending = createAction(typePrefix + "/pending", function(requestId, arg, meta) {
|
|
return {
|
|
payload: void 0,
|
|
meta: __spreadProps(__spreadValues({}, meta || {}), {
|
|
arg,
|
|
requestId,
|
|
requestStatus: "pending"
|
|
})
|
|
};
|
|
});
|
|
var rejected = createAction(typePrefix + "/rejected", function(error, requestId, arg, payload, meta) {
|
|
return {
|
|
payload,
|
|
error: (options && options.serializeError || miniSerializeError)(error || "Rejected"),
|
|
meta: __spreadProps(__spreadValues({}, meta || {}), {
|
|
arg,
|
|
requestId,
|
|
rejectedWithValue: !!payload,
|
|
requestStatus: "rejected",
|
|
aborted: (error == null ? void 0 : error.name) === "AbortError",
|
|
condition: (error == null ? void 0 : error.name) === "ConditionError"
|
|
})
|
|
};
|
|
});
|
|
var displayedWarning = false;
|
|
var AC = typeof AbortController !== "undefined" ? AbortController : function() {
|
|
function class_1() {
|
|
this.signal = {
|
|
aborted: false,
|
|
addEventListener: function() {
|
|
},
|
|
dispatchEvent: function() {
|
|
return false;
|
|
},
|
|
onabort: function() {
|
|
},
|
|
removeEventListener: function() {
|
|
},
|
|
reason: void 0,
|
|
throwIfAborted: function() {
|
|
}
|
|
};
|
|
}
|
|
class_1.prototype.abort = function() {
|
|
if (true) {
|
|
if (!displayedWarning) {
|
|
displayedWarning = true;
|
|
console.info("This platform does not implement AbortController. \nIf you want to use the AbortController to react to `abort` events, please consider importing a polyfill like 'abortcontroller-polyfill/dist/abortcontroller-polyfill-only'.");
|
|
}
|
|
}
|
|
};
|
|
return class_1;
|
|
}();
|
|
function actionCreator(arg) {
|
|
return function(dispatch, getState, extra) {
|
|
var requestId = (options == null ? void 0 : options.idGenerator) ? options.idGenerator(arg) : nanoid();
|
|
var abortController = new AC();
|
|
var abortReason;
|
|
var started = false;
|
|
function abort(reason) {
|
|
abortReason = reason;
|
|
abortController.abort();
|
|
}
|
|
var promise2 = function() {
|
|
return __async2(this, null, function() {
|
|
var _a, _b, finalAction, conditionResult, abortedPromise, err_1, skipDispatch;
|
|
return __generator(this, function(_c) {
|
|
switch (_c.label) {
|
|
case 0:
|
|
_c.trys.push([0, 4, , 5]);
|
|
conditionResult = (_a = options == null ? void 0 : options.condition) == null ? void 0 : _a.call(options, arg, { getState, extra });
|
|
if (!isThenable(conditionResult))
|
|
return [3, 2];
|
|
return [4, conditionResult];
|
|
case 1:
|
|
conditionResult = _c.sent();
|
|
_c.label = 2;
|
|
case 2:
|
|
if (conditionResult === false || abortController.signal.aborted) {
|
|
throw {
|
|
name: "ConditionError",
|
|
message: "Aborted due to condition callback returning false."
|
|
};
|
|
}
|
|
started = true;
|
|
abortedPromise = new Promise(function(_2, reject) {
|
|
return abortController.signal.addEventListener("abort", function() {
|
|
return reject({
|
|
name: "AbortError",
|
|
message: abortReason || "Aborted"
|
|
});
|
|
});
|
|
});
|
|
dispatch(pending(requestId, arg, (_b = options == null ? void 0 : options.getPendingMeta) == null ? void 0 : _b.call(options, { requestId, arg }, { getState, extra })));
|
|
return [4, Promise.race([
|
|
abortedPromise,
|
|
Promise.resolve(payloadCreator(arg, {
|
|
dispatch,
|
|
getState,
|
|
extra,
|
|
requestId,
|
|
signal: abortController.signal,
|
|
abort,
|
|
rejectWithValue: function(value, meta) {
|
|
return new RejectWithValue(value, meta);
|
|
},
|
|
fulfillWithValue: function(value, meta) {
|
|
return new FulfillWithMeta(value, meta);
|
|
}
|
|
})).then(function(result) {
|
|
if (result instanceof RejectWithValue) {
|
|
throw result;
|
|
}
|
|
if (result instanceof FulfillWithMeta) {
|
|
return fulfilled(result.payload, requestId, arg, result.meta);
|
|
}
|
|
return fulfilled(result, requestId, arg);
|
|
})
|
|
])];
|
|
case 3:
|
|
finalAction = _c.sent();
|
|
return [3, 5];
|
|
case 4:
|
|
err_1 = _c.sent();
|
|
finalAction = err_1 instanceof RejectWithValue ? rejected(null, requestId, arg, err_1.payload, err_1.meta) : rejected(err_1, requestId, arg);
|
|
return [3, 5];
|
|
case 5:
|
|
skipDispatch = options && !options.dispatchConditionRejection && rejected.match(finalAction) && finalAction.meta.condition;
|
|
if (!skipDispatch) {
|
|
dispatch(finalAction);
|
|
}
|
|
return [2, finalAction];
|
|
}
|
|
});
|
|
});
|
|
}();
|
|
return Object.assign(promise2, {
|
|
abort,
|
|
requestId,
|
|
arg,
|
|
unwrap: function() {
|
|
return promise2.then(unwrapResult);
|
|
}
|
|
});
|
|
};
|
|
}
|
|
return Object.assign(actionCreator, {
|
|
pending,
|
|
rejected,
|
|
fulfilled,
|
|
typePrefix
|
|
});
|
|
}
|
|
createAsyncThunk2.withTypes = function() {
|
|
return createAsyncThunk2;
|
|
};
|
|
return createAsyncThunk2;
|
|
}();
|
|
function unwrapResult(action) {
|
|
if (action.meta && action.meta.rejectedWithValue) {
|
|
throw action.payload;
|
|
}
|
|
if (action.error) {
|
|
throw action.error;
|
|
}
|
|
return action.payload;
|
|
}
|
|
function isThenable(value) {
|
|
return value !== null && typeof value === "object" && typeof value.then === "function";
|
|
}
|
|
var task = "task";
|
|
var listener = "listener";
|
|
var completed = "completed";
|
|
var cancelled = "cancelled";
|
|
var taskCancelled = "task-" + cancelled;
|
|
var taskCompleted = "task-" + completed;
|
|
var listenerCancelled = listener + "-" + cancelled;
|
|
var listenerCompleted = listener + "-" + completed;
|
|
var TaskAbortError = function() {
|
|
function TaskAbortError2(code) {
|
|
this.code = code;
|
|
this.name = "TaskAbortError";
|
|
this.message = task + " " + cancelled + " (reason: " + code + ")";
|
|
}
|
|
return TaskAbortError2;
|
|
}();
|
|
var alm = "listenerMiddleware";
|
|
var addListener = createAction(alm + "/add");
|
|
var clearAllListeners = createAction(alm + "/removeAll");
|
|
var removeListener = createAction(alm + "/remove");
|
|
var promise;
|
|
var queueMicrotaskShim = typeof queueMicrotask === "function" ? queueMicrotask.bind(typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : globalThis) : function(cb) {
|
|
return (promise || (promise = Promise.resolve())).then(cb).catch(function(err) {
|
|
return setTimeout(function() {
|
|
throw err;
|
|
}, 0);
|
|
});
|
|
};
|
|
var createQueueWithTimer = function(timeout) {
|
|
return function(notify) {
|
|
setTimeout(notify, timeout);
|
|
};
|
|
};
|
|
var rAF = typeof window !== "undefined" && window.requestAnimationFrame ? window.requestAnimationFrame : createQueueWithTimer(10);
|
|
F();
|
|
|
|
// store.ts
|
|
var initialState = {
|
|
filter: "",
|
|
filterOption: "All"
|
|
};
|
|
var appSlice = createSlice({
|
|
name: "app",
|
|
initialState,
|
|
reducers: {
|
|
changeFilter: (state, action) => {
|
|
state.filter = action.payload;
|
|
},
|
|
changeFilterOption: (state, action) => {
|
|
state.filterOption = action.payload;
|
|
}
|
|
}
|
|
});
|
|
var { changeFilter, changeFilterOption } = appSlice.actions;
|
|
var store = configureStore({
|
|
reducer: appSlice.reducer
|
|
});
|
|
|
|
// main.ts
|
|
var hotkeysEqual = (a2, b2) => a2.command === b2.command && keySequenceEqual(a2.chords, b2.chords);
|
|
var DEFAULT_SETTINGS = {
|
|
hotkeys: Array()
|
|
};
|
|
var SerializeSettings = (settings) => {
|
|
return {
|
|
hotkeys: settings.hotkeys.map((h2) => ({
|
|
command: h2.command,
|
|
chords: h2.chords.map((c2) => c2.serialize())
|
|
}))
|
|
};
|
|
};
|
|
var DeserializeSettings = (data) => {
|
|
let settings = DEFAULT_SETTINGS;
|
|
if (data == null ? void 0 : data.hotkeys) {
|
|
settings.hotkeys = data.hotkeys.map((h2) => ({
|
|
command: h2.command,
|
|
chords: h2.chords.map((c2) => new KeyChord(c2))
|
|
}));
|
|
}
|
|
return settings;
|
|
};
|
|
function allCommands(app) {
|
|
const commands = Object.values(app.commands.commands);
|
|
commands.sort((a2, b2) => a2.name.localeCompare(b2.name));
|
|
return commands;
|
|
}
|
|
var commandName = (app, id) => {
|
|
var _a;
|
|
return (_a = allCommands(app).find((c2) => c2.id === id)) == null ? void 0 : _a.name;
|
|
};
|
|
var hotkeysForCommand = (s2, id) => s2.hotkeys.filter((h2) => h2.command === id);
|
|
var SequenceHotkeysPlugin = class extends import_obsidian2.Plugin {
|
|
constructor() {
|
|
super(...arguments);
|
|
this._settingsUpdated = () => {
|
|
var _a;
|
|
this.saveSettings();
|
|
this.hotkeyManager.reset();
|
|
this.settings.hotkeys.map((h2) => this.hotkeyManager.addHotkey(h2.command, h2.chords));
|
|
(_a = this.saveListener) == null ? void 0 : _a.call(this, this.settings);
|
|
};
|
|
this.setSaveListener = (fn2) => {
|
|
this.saveListener = fn2;
|
|
};
|
|
this.addHotkey = (commandId, chords) => {
|
|
if (chords == null ? void 0 : chords.length) {
|
|
this.settings.hotkeys = [
|
|
...this.settings.hotkeys,
|
|
{
|
|
command: commandId,
|
|
chords
|
|
}
|
|
];
|
|
}
|
|
this._settingsUpdated();
|
|
};
|
|
this.deleteHotkey = (commandId, chords) => {
|
|
this.settings.hotkeys = this.settings.hotkeys.filter((h2) => h2.command != commandId || !keySequenceEqual(h2.chords, chords));
|
|
this._settingsUpdated();
|
|
};
|
|
}
|
|
onload() {
|
|
return __async(this, null, function* () {
|
|
this.hotkeyManager = new HotkeyManager((id) => this.app.commands.executeCommandById(id));
|
|
yield this.loadSettings();
|
|
this.addSettingTab(new SequenceHotkeysSettingTab(this.app, this));
|
|
this.chordListener = new ChordListener((chord) => {
|
|
if (!!this.app.setting.activeTab) {
|
|
return false;
|
|
}
|
|
return this.hotkeyManager.handleChordPress(chord);
|
|
});
|
|
});
|
|
}
|
|
onunload() {
|
|
this.chordListener.destruct();
|
|
}
|
|
loadSettings() {
|
|
return __async(this, null, function* () {
|
|
this.settings = Object.assign({}, DeserializeSettings(yield this.loadData()));
|
|
this._settingsUpdated();
|
|
});
|
|
}
|
|
saveSettings() {
|
|
return __async(this, null, function* () {
|
|
yield this.saveData(SerializeSettings(this.settings));
|
|
});
|
|
}
|
|
};
|
|
var SequenceHotkeysSettingTab = class extends import_obsidian2.PluginSettingTab {
|
|
constructor(app, plugin) {
|
|
super(app, plugin);
|
|
this.menuItems = {};
|
|
this.hasCommands = (cs) => {
|
|
const hotkeys = hotkeysForCommand(this.plugin.settings, cs.getCommand().id);
|
|
return hotkeys.length > 0;
|
|
};
|
|
this.render = () => {
|
|
const state = store.getState();
|
|
this.filterOptionDiv.setText(state.filterOption);
|
|
Object.keys(this.menuItems).forEach((k2) => {
|
|
this.menuItems[k2].setActive(k2 === state.filterOption);
|
|
});
|
|
const filterParts = state.filter.toLowerCase().split(" ");
|
|
this.commandSettingEls.map((cs) => {
|
|
const matchesFilter = filterParts.every((part) => cs.getCommand().name.toLowerCase().contains(part));
|
|
let assignedFilter = true;
|
|
if (state.filterOption === "Assigned") {
|
|
assignedFilter = this.hasCommands(cs);
|
|
} else if (state.filterOption === "Unassigned") {
|
|
assignedFilter = !this.hasCommands(cs);
|
|
}
|
|
cs.settingEl.toggle(matchesFilter && assignedFilter);
|
|
});
|
|
this.updateDescription();
|
|
};
|
|
this.updateDescription = () => {
|
|
this.descEl.setText(`Showing ${this.commandSettingEls.filter((e) => e.settingEl.isShown()).length} hotkeys.`);
|
|
};
|
|
this.plugin = plugin;
|
|
this.commandSettingEls = new Array();
|
|
}
|
|
hide() {
|
|
this.unsubscribe();
|
|
this.commandSettingEls.map((s2) => s2.hide());
|
|
}
|
|
display() {
|
|
this.unsubscribe = store.subscribe(this.render);
|
|
const { containerEl } = this;
|
|
containerEl.empty();
|
|
const searchBar = new import_obsidian2.Setting(containerEl);
|
|
const title = searchBar.infoEl.createDiv();
|
|
title.addClass("setting-item-name");
|
|
title.setText("Search hotkeys");
|
|
this.descEl = searchBar.infoEl.createDiv();
|
|
this.descEl.addClass("setting-item-description");
|
|
const filterMenu = new import_obsidian2.Menu();
|
|
["All", "Assigned", "Unassigned"].forEach((o2) => {
|
|
filterMenu.addItem((i2) => {
|
|
i2.setTitle(o2);
|
|
i2.onClick(() => {
|
|
store.dispatch(changeFilterOption(o2));
|
|
});
|
|
this.menuItems[o2] = i2;
|
|
});
|
|
});
|
|
this.filterOptionDiv = searchBar.controlEl.createDiv();
|
|
this.filterOptionDiv.addClass("setting-item-description");
|
|
const filterButton = new import_obsidian2.ButtonComponent(searchBar.controlEl);
|
|
filterButton.setClass("clickable-icon");
|
|
filterButton.setIcon("lucide-filter");
|
|
filterButton.onClick((e) => {
|
|
filterMenu.showAtPosition({ x: e.pageX, y: e.pageY });
|
|
});
|
|
const searchEl = new import_obsidian2.SearchComponent(searchBar.controlEl);
|
|
searchEl.setPlaceholder("Filter...");
|
|
searchEl.onChange((s2) => store.dispatch(changeFilter(s2)));
|
|
const spacer = containerEl.createDiv();
|
|
spacer.addClass("setting-filter-container");
|
|
const commandsContainer = containerEl.createDiv();
|
|
this.commandSettingEls = allCommands(this.app).map((command) => new CommandSetting(commandsContainer, command, this.plugin.addHotkey, this.plugin.deleteHotkey));
|
|
const updateCommands = (s2) => {
|
|
this.commandSettingEls.map((cs) => {
|
|
const hotkeys = hotkeysForCommand(s2, cs.getCommand().id).map((h2) => {
|
|
const conflict = s2.hotkeys.find((shc) => !hotkeysEqual(shc, h2) && keySequencePartiallyEqual(shc.chords, h2.chords));
|
|
return {
|
|
chords: h2.chords,
|
|
warning: !!conflict ? `This hotkey conflicts with "${commandName(this.app, conflict.command)}"` : ""
|
|
};
|
|
});
|
|
cs.display(hotkeys);
|
|
});
|
|
};
|
|
this.plugin.setSaveListener(updateCommands);
|
|
updateCommands(this.plugin.settings);
|
|
this.render();
|
|
searchEl.inputEl.focus();
|
|
}
|
|
};
|
|
var CommandSetting = class extends import_obsidian2.Setting {
|
|
constructor(containerEl, command, onCreated, onDelete) {
|
|
super(containerEl);
|
|
this.getCommand = () => this.command;
|
|
this.hide = () => {
|
|
this.setCancelCapture(void 0);
|
|
};
|
|
this.setCancelCapture = (cb) => {
|
|
var _a;
|
|
(_a = this.cancelCapture) == null ? void 0 : _a.call(this);
|
|
this.cancelCapture = cb;
|
|
};
|
|
this.display = (hotkeys) => {
|
|
this.clear();
|
|
this.setName(this.command.name);
|
|
const hotkeyDiv = this.controlEl.createDiv({
|
|
cls: "setting-command-hotkeys"
|
|
});
|
|
for (const hotkey of hotkeys) {
|
|
const warnClass = !!hotkey.warning ? " has-conflict" : "";
|
|
const hotkeySpan = hotkeyDiv.createSpan({
|
|
cls: "setting-hotkey" + warnClass,
|
|
attr: { "aria-label": hotkey.warning }
|
|
});
|
|
const hotkeySpanText = hotkeySpan.createSpan({
|
|
text: hotkey.chords.map((c2) => c2.toString()).join(" ") + " "
|
|
});
|
|
const deleteBtn = hotkeySpanText.createSpan({
|
|
cls: "setting-hotkey-icon setting-delete-hotkey",
|
|
attr: { "aria-label": "Delete hotkey" }
|
|
});
|
|
(0, import_obsidian2.setIcon)(deleteBtn, "cross", 8);
|
|
deleteBtn.onClickEvent(() => {
|
|
this.onDelete(this.command.id, hotkey.chords);
|
|
});
|
|
}
|
|
const addBtn = this.controlEl.createSpan({
|
|
cls: "setting-add-hotkey-button",
|
|
attr: { "aria-label": "Customize this command" }
|
|
});
|
|
(0, import_obsidian2.setIcon)(addBtn, "any-key", 22);
|
|
addBtn.onClickEvent(() => {
|
|
const newHotkeySpan = hotkeyDiv.createSpan({
|
|
cls: "setting-hotkey"
|
|
});
|
|
const newHotkeySpanText = newHotkeySpan.createSpan({
|
|
text: "Press hotkey..."
|
|
});
|
|
const onUpdate = (chords) => {
|
|
newHotkeySpanText.setText(chords.map((c2) => c2.toString()).join(" "));
|
|
};
|
|
const onComplete = (chords) => {
|
|
var _a;
|
|
this.setCancelCapture(void 0);
|
|
(_a = this.onCreated) == null ? void 0 : _a.call(this, this.command.id, chords);
|
|
};
|
|
const chordCapturer = new CaptureChord(onUpdate, onComplete);
|
|
this.setCancelCapture(chordCapturer.destruct);
|
|
newHotkeySpan.addClass("mod-active");
|
|
addBtn.hide();
|
|
const menuBtn = this.controlEl.createSpan({
|
|
cls: "setting-add-hotkey-button",
|
|
attr: {
|
|
"aria-label": `Add ${codeToString("Enter")} or ${codeToString("Escape")} key to sequence`
|
|
}
|
|
});
|
|
(0, import_obsidian2.setIcon)(menuBtn, "plus", 22);
|
|
const menu = new import_obsidian2.Menu(menuBtn).setNoIcon();
|
|
menu.addItem((item) => item.setTitle("Add " + codeToString("Enter")).onClick(() => {
|
|
chordCapturer.pushChord(new KeyChord("Enter"));
|
|
}));
|
|
menu.addItem((item) => item.setTitle("Add " + codeToString("Escape")).onClick(() => {
|
|
chordCapturer.pushChord(new KeyChord("Escape"));
|
|
}));
|
|
menuBtn.onClickEvent((event) => {
|
|
menu.showAtMouseEvent(event);
|
|
});
|
|
const doneBtn = this.controlEl.createSpan({
|
|
cls: "setting-add-hotkey-button",
|
|
attr: {
|
|
"aria-label": "Accept hotkey sequence"
|
|
}
|
|
});
|
|
(0, import_obsidian2.setIcon)(doneBtn, "checkbox-glyph", 22);
|
|
doneBtn.onClickEvent(() => {
|
|
onComplete(chordCapturer.chords);
|
|
});
|
|
});
|
|
};
|
|
this.command = command;
|
|
this.onCreated = onCreated;
|
|
this.onDelete = onDelete;
|
|
}
|
|
};
|
|
var CaptureChord = class {
|
|
constructor(onUpdate, onComplete) {
|
|
this.pushChord = (c2) => {
|
|
this.chords.push(c2);
|
|
this.onUpdate(this.chords);
|
|
};
|
|
this.destruct = () => {
|
|
this.chordListener.destruct();
|
|
};
|
|
this.chords = new Array();
|
|
this.onUpdate = onUpdate;
|
|
this.onComplete = onComplete;
|
|
this.chordListener = new ChordListener((c2) => {
|
|
if (!c2.alt && !c2.ctrl && !c2.shift && !c2.meta && (c2.key === "Enter" || c2.key === "Escape")) {
|
|
this.destruct();
|
|
if (c2.key === "Enter") {
|
|
this.onComplete(this.chords);
|
|
}
|
|
return true;
|
|
}
|
|
this.pushChord(c2);
|
|
return true;
|
|
});
|
|
}
|
|
};
|