@react-querybuilder/dnd
Version:
Drag-and-drop-enabled version of react-querybuilder
1,092 lines (1,081 loc) • 64.3 kB
JavaScript
// ../../utils/react-compiler/react-compiler-runtime.ts
import * as React from "react";
var $empty = Symbol["for"]("react.memo_cache_sentinel");
function c(size) {
return React.useMemo(
function() {
var $ = Array.from({ length: size });
for (var ii = 0; ii < size; ii++) {
$[ii] = $empty;
}
$[$empty] = true;
return $;
},
// eslint-disable-next-line react-hooks/exhaustive-deps
[]
);
}
// src/InlineCombinatorDnD.tsx
import { jsx } from "react/jsx-runtime";
import { useContext, useRef } from "react";
import { getParentPath, isAncestor, pathsAreEqual, standardClassnames, TestID } from "react-querybuilder";
// src/isHotkeyPressed.ts
function _createForOfIteratorHelper(r, e) {
var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
if (!t) {
if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) {
t && (r = t);
var _n = 0, F = function F2() {
};
return { s: F, n: function n() {
return _n >= r.length ? { done: true } : { done: false, value: r[_n++] };
}, e: function e2(r2) {
throw r2;
}, f: F };
}
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
var o, a = true, u = false;
return { s: function s() {
t = t.call(r);
}, n: function n() {
var r2 = t.next();
return a = r2.done, r2;
}, e: function e2(r2) {
u = true, o = r2;
}, f: function f() {
try {
a || null == t["return"] || t["return"]();
} finally {
if (u) throw o;
}
} };
}
function _unsupportedIterableToArray(r, a) {
if (r) {
if ("string" == typeof r) return _arrayLikeToArray(r, a);
var t = {}.toString.call(r).slice(8, -1);
return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
}
}
function _arrayLikeToArray(r, a) {
(null == a || a > r.length) && (a = r.length);
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
return n;
}
var reservedModifierKeywords = /* @__PURE__ */ new Set(["shift", "alt", "meta", "mod", "ctrl"]);
var mappedKeys = { esc: "escape", "return": "enter", ".": "period", ",": "comma", "-": "slash", " ": "space", "`": "backquote", "#": "backslash", "+": "bracketright", ShiftLeft: "shift", ShiftRight: "shift", AltLeft: "alt", AltRight: "alt", MetaLeft: "meta", MetaRight: "meta", OSLeft: "meta", OSRight: "meta", ControlLeft: "ctrl", ControlRight: "ctrl" };
var mapKey = function mapKey2(key) {
return (key && mappedKeys[key] || key || "").trim().toLowerCase().replace(/key|digit|numpad|arrow/, "");
};
var isHotkeyModifier = function isHotkeyModifier2(key) {
return reservedModifierKeywords.has(key);
};
var keyAliases = { "\u2318": "meta", cmd: "meta", command: "meta", "\u229E": "meta", win: "meta", windows: "meta", "\u21E7": "shift", "\u2325": "alt", "\u2303": "ctrl", control: "ctrl" };
(function() {
if (typeof document !== "undefined") {
document.addEventListener("keydown", function(e) {
if (e.key === void 0) {
return;
}
pushToCurrentlyPressedKeys([mapKey(e.key), mapKey(e.code)]);
});
document.addEventListener("keyup", function(e) {
if (e.key === void 0) {
return;
}
removeFromCurrentlyPressedKeys([mapKey(e.key), mapKey(e.code)]);
});
}
if (typeof window !== "undefined") {
window.addEventListener("blur", function() {
currentlyPressedKeys.clear();
});
}
})();
var currentlyPressedKeys = /* @__PURE__ */ new Set();
var isReadonlyArray = function isReadonlyArray2(value) {
return Array.isArray(value);
};
var isHotkeyPressed = function isHotkeyPressed2(key) {
var splitKey = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : ",";
return (isReadonlyArray(key) ? key : key.split(splitKey)).every(function(hotkey) {
var _keyAliases$hk;
var hk = hotkey.trim().toLowerCase();
return currentlyPressedKeys.has((_keyAliases$hk = keyAliases[hk]) !== null && _keyAliases$hk !== void 0 ? _keyAliases$hk : hk);
});
};
var pushToCurrentlyPressedKeys = function pushToCurrentlyPressedKeys2(key) {
var hotkeyArray = Array.isArray(key) ? key : [key];
if (currentlyPressedKeys.has("meta")) {
var _iterator = _createForOfIteratorHelper(currentlyPressedKeys), _step;
try {
for (_iterator.s(); !(_step = _iterator.n()).done; ) {
var key2 = _step.value;
if (!isHotkeyModifier(key2)) {
currentlyPressedKeys["delete"](key2.toLowerCase());
}
}
} catch (err) {
_iterator.e(err);
} finally {
_iterator.f();
}
}
var _iterator2 = _createForOfIteratorHelper(hotkeyArray), _step2;
try {
for (_iterator2.s(); !(_step2 = _iterator2.n()).done; ) {
var hotkey = _step2.value;
currentlyPressedKeys.add(hotkey.toLowerCase());
}
} catch (err) {
_iterator2.e(err);
} finally {
_iterator2.f();
}
};
var removeFromCurrentlyPressedKeys = function removeFromCurrentlyPressedKeys2(key) {
var hotkeyArray = Array.isArray(key) ? key : [key];
if (key === "meta") {
currentlyPressedKeys.clear();
} else {
var _iterator3 = _createForOfIteratorHelper(hotkeyArray), _step3;
try {
for (_iterator3.s(); !(_step3 = _iterator3.n()).done; ) {
var hotkey = _step3.value;
currentlyPressedKeys["delete"](hotkey.toLowerCase());
}
} catch (err) {
_iterator3.e(err);
} finally {
_iterator3.f();
}
}
};
// src/QueryBuilderDndContext.ts
import { createContext } from "react";
import { defaultControlElements } from "react-querybuilder";
var rule = defaultControlElements.rule;
var ruleGroup = defaultControlElements.ruleGroup;
var combinatorSelector = defaultControlElements.combinatorSelector;
var QueryBuilderDndContext = /* @__PURE__ */ createContext({ baseControls: { rule, ruleGroup, combinatorSelector } });
// src/InlineCombinatorDnD.tsx
function _typeof(o) {
"@babel/helpers - typeof";
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o2) {
return typeof o2;
} : function(o2) {
return o2 && "function" == typeof Symbol && o2.constructor === Symbol && o2 !== Symbol.prototype ? "symbol" : typeof o2;
}, _typeof(o);
}
var _excluded = ["component"];
function _slicedToArray(r, e) {
return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray2(r, e) || _nonIterableRest();
}
function _nonIterableRest() {
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
function _unsupportedIterableToArray2(r, a) {
if (r) {
if ("string" == typeof r) return _arrayLikeToArray2(r, a);
var t = {}.toString.call(r).slice(8, -1);
return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray2(r, a) : void 0;
}
}
function _arrayLikeToArray2(r, a) {
(null == a || a > r.length) && (a = r.length);
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
return n;
}
function _iterableToArrayLimit(r, l) {
var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
if (null != t) {
var e, n, i, u, a = [], f = true, o = false;
try {
if (i = (t = t.call(r)).next, 0 === l) {
if (Object(t) !== t) return;
f = false;
} else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = true) ;
} catch (r2) {
o = true, n = r2;
} finally {
try {
if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return;
} finally {
if (o) throw n;
}
}
return a;
}
}
function _arrayWithHoles(r) {
if (Array.isArray(r)) return r;
}
function ownKeys(e, r) {
var t = Object.keys(e);
if (Object.getOwnPropertySymbols) {
var o = Object.getOwnPropertySymbols(e);
r && (o = o.filter(function(r2) {
return Object.getOwnPropertyDescriptor(e, r2).enumerable;
})), t.push.apply(t, o);
}
return t;
}
function _objectSpread(e) {
for (var r = 1; r < arguments.length; r++) {
var t = null != arguments[r] ? arguments[r] : {};
r % 2 ? ownKeys(Object(t), true).forEach(function(r2) {
_defineProperty(e, r2, t[r2]);
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r2) {
Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
});
}
return e;
}
function _defineProperty(e, r, t) {
return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
}
function _toPropertyKey(t) {
var i = _toPrimitive(t, "string");
return "symbol" == _typeof(i) ? i : i + "";
}
function _toPrimitive(t, r) {
if ("object" != _typeof(t) || !t) return t;
var e = t[Symbol.toPrimitive];
if (void 0 !== e) {
var i = e.call(t, r || "default");
if ("object" != _typeof(i)) return i;
throw new TypeError("@@toPrimitive must return a primitive value.");
}
return ("string" === r ? String : Number)(t);
}
function _objectWithoutProperties(e, t) {
if (null == e) return {};
var o, r, i = _objectWithoutPropertiesLoose(e, t);
if (Object.getOwnPropertySymbols) {
var n = Object.getOwnPropertySymbols(e);
for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
}
return i;
}
function _objectWithoutPropertiesLoose(r, e) {
if (null == r) return {};
var t = {};
for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
if (-1 !== e.indexOf(n)) continue;
t[n] = r[n];
}
return t;
}
var InlineCombinatorDnD = function InlineCombinatorDnD2(t0) {
var $ = c(20);
var CombinatorSelectorComponent;
var props;
if ($[0] !== t0) {
var _t = t0;
CombinatorSelectorComponent = _t.component;
props = _objectWithoutProperties(_t, _excluded);
_t;
$[0] = t0;
$[1] = CombinatorSelectorComponent;
$[2] = props;
} else {
CombinatorSelectorComponent = $[1];
props = $[2];
}
var _useContext = useContext(QueryBuilderDndContext), canDrop = _useContext.canDrop, useDrop = _useContext.useDrop, copyModeModifierKey = _useContext.copyModeModifierKey, groupModeModifierKey = _useContext.groupModeModifierKey;
var t1;
if ($[3] !== CombinatorSelectorComponent || $[4] !== canDrop || $[5] !== copyModeModifierKey || $[6] !== groupModeModifierKey || $[7] !== props || $[8] !== useDrop) {
t1 = _objectSpread(_objectSpread({}, props), {}, { component: CombinatorSelectorComponent, useDrop, canDrop, copyModeModifierKey, groupModeModifierKey });
$[3] = CombinatorSelectorComponent;
$[4] = canDrop;
$[5] = copyModeModifierKey;
$[6] = groupModeModifierKey;
$[7] = props;
$[8] = useDrop;
$[9] = t1;
} else {
t1 = $[9];
}
var _useInlineCombinatorD = useInlineCombinatorDnD(t1), dropRef = _useInlineCombinatorD.dropRef, dropMonitorId = _useInlineCombinatorD.dropMonitorId, isOver = _useInlineCombinatorD.isOver;
var t2 = props.schema.suppressStandardClassnames || standardClassnames.betweenRules;
var t3 = isOver && !props.schema.classNames.dndOver || false;
var t4 = isOver && !props.schema.suppressStandardClassnames && standardClassnames.dndOver || false;
var t5;
if ($[10] !== t2 || $[11] !== t3 || $[12] !== t4) {
t5 = [t2, t3, t4].filter(_temp);
$[10] = t2;
$[11] = t3;
$[12] = t4;
$[13] = t5;
} else {
t5 = $[13];
}
var wrapperClassName = t5.join(" ");
var t6;
if ($[14] !== CombinatorSelectorComponent || $[15] !== dropMonitorId || $[16] !== dropRef || $[17] !== props || $[18] !== wrapperClassName) {
t6 = jsx("div", { ref: dropRef, className: wrapperClassName, "data-dropmonitorid": dropMonitorId, "data-testid": TestID.inlineCombinator, children: jsx(CombinatorSelectorComponent, _objectSpread(_objectSpread({}, props), {}, { testID: TestID.combinators })) }, "dnd");
$[14] = CombinatorSelectorComponent;
$[15] = dropMonitorId;
$[16] = dropRef;
$[17] = props;
$[18] = wrapperClassName;
$[19] = t6;
} else {
t6 = $[19];
}
return t6;
};
var useInlineCombinatorDnD = function useInlineCombinatorDnD2(params) {
var dropRef = useRef(null);
var path = params.path, _canDrop = params.canDrop, schema = params.schema, useDrop = params.useDrop, rules = params.rules, _params$copyModeModif = params.copyModeModifierKey, copyModeModifierKey = _params$copyModeModif === void 0 ? "alt" : _params$copyModeModif, _params$groupModeModi = params.groupModeModifierKey, groupModeModifierKey = _params$groupModeModi === void 0 ? "ctrl" : _params$groupModeModi;
var hoveringItem = (rules !== null && rules !== void 0 ? rules : (
/* istanbul ignore next */
[]
))[path.at(-1) - 1];
var _useDrop = useDrop(function() {
return { accept: ["rule", "ruleGroup"], canDrop: function canDrop(dragging) {
var itemPath = dragging.path;
if (isHotkeyPressed(groupModeModifierKey) || dragging && typeof _canDrop === "function" && !_canDrop({ dragging, hovering: _objectSpread(_objectSpread({}, hoveringItem), {}, { path, qbId: schema.qbId }) })) {
return false;
}
var parentHoverPath = getParentPath(path);
var parentItemPath = getParentPath(itemPath);
var hoverIndex = path.at(-1);
var itemIndex = itemPath.at(-1);
return !// 1) the item is an ancestor of the drop target,
(isAncestor(itemPath, path) || // 2) the item is hovered over itself (which should never
// happen since combinators don't have drag handles),
pathsAreEqual(itemPath, path) || pathsAreEqual(parentHoverPath, parentItemPath) && hoverIndex - 1 === itemIndex || // 3) independentCombinators is true and the drop target is just above the hovering item
schema.independentCombinators && pathsAreEqual(parentHoverPath, parentItemPath) && hoverIndex === itemIndex - 1);
}, collect: function collect(monitor) {
var _monitor$getHandlerId;
return { isOver: monitor.canDrop() && monitor.isOver(), dropMonitorId: (_monitor$getHandlerId = monitor.getHandlerId()) !== null && _monitor$getHandlerId !== void 0 ? _monitor$getHandlerId : "", dropEffect: isHotkeyPressed(copyModeModifierKey) ? "copy" : "move", groupItems: isHotkeyPressed(groupModeModifierKey) };
}, drop: function drop2() {
var qbId = schema.qbId, getQuery = schema.getQuery, dispatchQuery = schema.dispatchQuery;
var dropEffect2 = isHotkeyPressed(copyModeModifierKey) ? "copy" : "move";
var groupItems = isHotkeyPressed(groupModeModifierKey);
return { type: "inlineCombinator", path, qbId, getQuery, dispatchQuery, groupItems, dropEffect: dropEffect2 };
} };
}, [_canDrop, hoveringItem, path, schema]), _useDrop2 = _slicedToArray(_useDrop, 2), _useDrop2$ = _useDrop2[0], isOver = _useDrop2$.isOver, dropMonitorId = _useDrop2$.dropMonitorId, dropEffect = _useDrop2$.dropEffect, drop = _useDrop2[1];
drop(dropRef);
return { dropRef, dropMonitorId, isOver, dropEffect };
};
function _temp(c2) {
return typeof c2 === "string";
}
// src/QueryBuilderDnD.tsx
import { jsx as jsx4 } from "react/jsx-runtime";
import { useContext as useContext4, useEffect, useMemo as useMemo2, useState } from "react";
import { messages, QueryBuilderContext, useMergedContext, usePreferAnyProp, usePreferProp } from "react-querybuilder";
// src/RuleDnD.tsx
import { jsx as jsx2 } from "react/jsx-runtime";
import { useContext as useContext2, useRef as useRef2 } from "react";
import { getParentPath as getParentPath3, isAncestor as isAncestor2, pathsAreEqual as pathsAreEqual2 } from "react-querybuilder";
// src/useDragCommon.ts
import { add, findPath, getParentPath as getParentPath2, group, insert } from "react-querybuilder";
function _typeof2(o) {
"@babel/helpers - typeof";
return _typeof2 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o2) {
return typeof o2;
} : function(o2) {
return o2 && "function" == typeof Symbol && o2.constructor === Symbol && o2 !== Symbol.prototype ? "symbol" : typeof o2;
}, _typeof2(o);
}
function _toConsumableArray(r) {
return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray3(r) || _nonIterableSpread();
}
function _nonIterableSpread() {
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
function _unsupportedIterableToArray3(r, a) {
if (r) {
if ("string" == typeof r) return _arrayLikeToArray3(r, a);
var t = {}.toString.call(r).slice(8, -1);
return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray3(r, a) : void 0;
}
}
function _iterableToArray(r) {
if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
}
function _arrayWithoutHoles(r) {
if (Array.isArray(r)) return _arrayLikeToArray3(r);
}
function _arrayLikeToArray3(r, a) {
(null == a || a > r.length) && (a = r.length);
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
return n;
}
function ownKeys2(e, r) {
var t = Object.keys(e);
if (Object.getOwnPropertySymbols) {
var o = Object.getOwnPropertySymbols(e);
r && (o = o.filter(function(r2) {
return Object.getOwnPropertyDescriptor(e, r2).enumerable;
})), t.push.apply(t, o);
}
return t;
}
function _objectSpread2(e) {
for (var r = 1; r < arguments.length; r++) {
var t = null != arguments[r] ? arguments[r] : {};
r % 2 ? ownKeys2(Object(t), true).forEach(function(r2) {
_defineProperty2(e, r2, t[r2]);
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys2(Object(t)).forEach(function(r2) {
Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
});
}
return e;
}
function _defineProperty2(e, r, t) {
return (r = _toPropertyKey2(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
}
function _toPropertyKey2(t) {
var i = _toPrimitive2(t, "string");
return "symbol" == _typeof2(i) ? i : i + "";
}
function _toPrimitive2(t, r) {
if ("object" != _typeof2(t) || !t) return t;
var e = t[Symbol.toPrimitive];
if (void 0 !== e) {
var i = e.call(t, r || "default");
if ("object" != _typeof2(i)) return i;
throw new TypeError("@@toPrimitive must return a primitive value.");
}
return ("string" === r ? String : Number)(t);
}
var useDragCommon = function useDragCommon2(_ref) {
var type = _ref.type, path = _ref.path, disabled = _ref.disabled, actions = _ref.actions, schema = _ref.schema, useDrag = _ref.useDrag, copyModeModifierKey = _ref.copyModeModifierKey, groupModeModifierKey = _ref.groupModeModifierKey;
return useDrag(function() {
return { type, item: function item() {
return _objectSpread2(_objectSpread2({}, findPath(path, schema.getQuery())), {}, { path, qbId: schema.qbId });
}, canDrag: !disabled, collect: function collect(monitor) {
var _monitor$getHandlerId;
return { isDragging: !disabled && monitor.isDragging(), dragMonitorId: (_monitor$getHandlerId = monitor.getHandlerId()) !== null && _monitor$getHandlerId !== void 0 ? _monitor$getHandlerId : "" };
}, end: function end(item, monitor_0) {
var dropResult = monitor_0.getDropResult();
if (!dropResult) return;
var dropEffect = isHotkeyPressed(copyModeModifierKey) ? "copy" : "move";
var groupItems = isHotkeyPressed(groupModeModifierKey);
var parentHoverPath = getParentPath2(dropResult.path);
var hoverIndex = dropResult.path.at(-1);
var destinationPath = groupItems ? dropResult.path : dropResult.type === "ruleGroup" ? [].concat(_toConsumableArray(dropResult.path), [0]) : dropResult.type === "inlineCombinator" ? [].concat(_toConsumableArray(parentHoverPath), [hoverIndex]) : [].concat(_toConsumableArray(parentHoverPath), [hoverIndex + 1]);
if (schema.qbId === dropResult.qbId) {
if (groupItems) {
actions.groupRule(item.path, destinationPath, dropEffect === "copy");
} else {
actions.moveRule(item.path, destinationPath, dropEffect === "copy");
}
} else {
var otherBuilderQuery = dropResult.getQuery();
if (otherBuilderQuery) {
if (groupItems) {
dropResult.dispatchQuery(group(add(otherBuilderQuery, item, []), [otherBuilderQuery.rules.length], destinationPath, { clone: false }));
} else {
dropResult.dispatchQuery(insert(otherBuilderQuery, item, destinationPath));
}
if (dropEffect !== "copy") {
actions.onRuleRemove(item.path);
}
}
}
} };
}, [actions.groupRule, actions.moveRule, disabled, path]);
};
// src/RuleDnD.tsx
function _typeof3(o) {
"@babel/helpers - typeof";
return _typeof3 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o2) {
return typeof o2;
} : function(o2) {
return o2 && "function" == typeof Symbol && o2.constructor === Symbol && o2 !== Symbol.prototype ? "symbol" : typeof o2;
}, _typeof3(o);
}
function _slicedToArray2(r, e) {
return _arrayWithHoles2(r) || _iterableToArrayLimit2(r, e) || _unsupportedIterableToArray4(r, e) || _nonIterableRest2();
}
function _nonIterableRest2() {
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
function _unsupportedIterableToArray4(r, a) {
if (r) {
if ("string" == typeof r) return _arrayLikeToArray4(r, a);
var t = {}.toString.call(r).slice(8, -1);
return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray4(r, a) : void 0;
}
}
function _arrayLikeToArray4(r, a) {
(null == a || a > r.length) && (a = r.length);
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
return n;
}
function _iterableToArrayLimit2(r, l) {
var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
if (null != t) {
var e, n, i, u, a = [], f = true, o = false;
try {
if (i = (t = t.call(r)).next, 0 === l) {
if (Object(t) !== t) return;
f = false;
} else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = true) ;
} catch (r2) {
o = true, n = r2;
} finally {
try {
if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return;
} finally {
if (o) throw n;
}
}
return a;
}
}
function _arrayWithHoles2(r) {
if (Array.isArray(r)) return r;
}
function ownKeys3(e, r) {
var t = Object.keys(e);
if (Object.getOwnPropertySymbols) {
var o = Object.getOwnPropertySymbols(e);
r && (o = o.filter(function(r2) {
return Object.getOwnPropertyDescriptor(e, r2).enumerable;
})), t.push.apply(t, o);
}
return t;
}
function _objectSpread3(e) {
for (var r = 1; r < arguments.length; r++) {
var t = null != arguments[r] ? arguments[r] : {};
r % 2 ? ownKeys3(Object(t), true).forEach(function(r2) {
_defineProperty3(e, r2, t[r2]);
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys3(Object(t)).forEach(function(r2) {
Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
});
}
return e;
}
function _defineProperty3(e, r, t) {
return (r = _toPropertyKey3(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
}
function _toPropertyKey3(t) {
var i = _toPrimitive3(t, "string");
return "symbol" == _typeof3(i) ? i : i + "";
}
function _toPrimitive3(t, r) {
if ("object" != _typeof3(t) || !t) return t;
var e = t[Symbol.toPrimitive];
if (void 0 !== e) {
var i = e.call(t, r || "default");
if ("object" != _typeof3(i)) return i;
throw new TypeError("@@toPrimitive must return a primitive value.");
}
return ("string" === r ? String : Number)(t);
}
var RuleDnD = function RuleDnD2(props) {
var $ = c(13);
var rqbDndContext = useContext2(QueryBuilderDndContext);
var canDrop = rqbDndContext.canDrop, useDrag = rqbDndContext.useDrag, useDrop = rqbDndContext.useDrop, copyModeModifierKey = rqbDndContext.copyModeModifierKey, groupModeModifierKey = rqbDndContext.groupModeModifierKey;
var disabled = !!props.parentDisabled || !!props.disabled;
var t0;
if ($[0] !== canDrop || $[1] !== copyModeModifierKey || $[2] !== disabled || $[3] !== groupModeModifierKey || $[4] !== props || $[5] !== useDrag || $[6] !== useDrop) {
t0 = _objectSpread3(_objectSpread3({}, props), {}, { disabled, useDrag, useDrop, canDrop, copyModeModifierKey, groupModeModifierKey });
$[0] = canDrop;
$[1] = copyModeModifierKey;
$[2] = disabled;
$[3] = groupModeModifierKey;
$[4] = props;
$[5] = useDrag;
$[6] = useDrop;
$[7] = t0;
} else {
t0 = $[7];
}
var dndRefs = useRuleDnD(t0);
var BaseRuleComponent = rqbDndContext.baseControls.rule;
var t1;
if ($[8] !== BaseRuleComponent || $[9] !== dndRefs || $[10] !== props || $[11] !== rqbDndContext) {
t1 = jsx2(QueryBuilderDndContext.Provider, { value: rqbDndContext, children: jsx2(BaseRuleComponent, _objectSpread3(_objectSpread3({}, props), dndRefs)) });
$[8] = BaseRuleComponent;
$[9] = dndRefs;
$[10] = props;
$[11] = rqbDndContext;
$[12] = t1;
} else {
t1 = $[12];
}
return t1;
};
var accept = ["rule", "ruleGroup"];
var useRuleDnD = function useRuleDnD2(params) {
var dndRef = useRef2(null);
var dragRef = useRef2(null);
var path = params.path, rule2 = params.rule, disabled = params.disabled, schema = params.schema, actions = params.actions, useDrag = params.useDrag, useDrop = params.useDrop, _canDrop = params.canDrop, _params$copyModeModif = params.copyModeModifierKey, copyModeModifierKey = _params$copyModeModif === void 0 ? "alt" : _params$copyModeModif, _params$groupModeModi = params.groupModeModifierKey, groupModeModifierKey = _params$groupModeModi === void 0 ? "ctrl" : _params$groupModeModi;
var _useDragCommon = useDragCommon({ type: "rule", path, disabled, independentCombinators: schema.independentCombinators, schema, actions, useDrag, copyModeModifierKey, groupModeModifierKey }), _useDragCommon2 = _slicedToArray2(_useDragCommon, 3), _useDragCommon2$ = _useDragCommon2[0], isDragging = _useDragCommon2$.isDragging, dragMonitorId = _useDragCommon2$.dragMonitorId, drag = _useDragCommon2[1], preview = _useDragCommon2[2];
var _useDrop = useDrop(function() {
return { accept, canDrop: function canDrop(dragging) {
if (isHotkeyPressed(groupModeModifierKey) && disabled || dragging && typeof _canDrop === "function" && !_canDrop({ dragging, hovering: _objectSpread3(_objectSpread3({}, rule2), {}, { path, qbId: schema.qbId }) })) {
return false;
}
if (schema.qbId !== dragging.qbId) return true;
var parentHoverPath = getParentPath3(path);
var parentItemPath = getParentPath3(dragging.path);
var hoverIndex = path.at(-1);
var itemIndex = dragging.path.at(-1);
return !// 1) item is ancestor of drop target, OR
(isAncestor2(dragging.path, path) || // 2) item is hovered over itself, OR
pathsAreEqual2(path, dragging.path) || // 3) item is hovered over the previous item AND this is a move, not a group
!isHotkeyPressed(groupModeModifierKey) && pathsAreEqual2(parentHoverPath, parentItemPath) && (hoverIndex === itemIndex - 1 || schema.independentCombinators && hoverIndex === itemIndex - 2));
}, collect: function collect(monitor) {
var _monitor$getHandlerId;
return { isOver: monitor.canDrop() && monitor.isOver(), dropMonitorId: (_monitor$getHandlerId = monitor.getHandlerId()) !== null && _monitor$getHandlerId !== void 0 ? _monitor$getHandlerId : "", dropEffect: isHotkeyPressed(copyModeModifierKey) ? "copy" : "move", groupItems: isHotkeyPressed(groupModeModifierKey) };
}, drop: function drop2() {
var qbId = schema.qbId, getQuery = schema.getQuery, dispatchQuery = schema.dispatchQuery;
var dropEffect2 = isHotkeyPressed(copyModeModifierKey) ? "copy" : "move";
var groupItems2 = isHotkeyPressed(groupModeModifierKey);
return { type: "rule", path, qbId, getQuery, dispatchQuery, groupItems: groupItems2, dropEffect: dropEffect2 };
} };
}, [disabled, actions.moveRule, path, _canDrop, rule2, schema]), _useDrop2 = _slicedToArray2(_useDrop, 2), _useDrop2$ = _useDrop2[0], isOver = _useDrop2$.isOver, dropMonitorId = _useDrop2$.dropMonitorId, dropEffect = _useDrop2$.dropEffect, groupItems = _useDrop2$.groupItems, drop = _useDrop2[1];
drag(dragRef);
preview(drop(dndRef));
return { isDragging, dragMonitorId, isOver, dropMonitorId, dndRef, dragRef, dropEffect, groupItems };
};
// src/RuleGroupDnD.tsx
import { jsx as jsx3 } from "react/jsx-runtime";
import { useContext as useContext3, useRef as useRef3 } from "react";
import { getParentPath as getParentPath4, isAncestor as isAncestor3, pathsAreEqual as pathsAreEqual3 } from "react-querybuilder";
function _typeof4(o) {
"@babel/helpers - typeof";
return _typeof4 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o2) {
return typeof o2;
} : function(o2) {
return o2 && "function" == typeof Symbol && o2.constructor === Symbol && o2 !== Symbol.prototype ? "symbol" : typeof o2;
}, _typeof4(o);
}
function _slicedToArray3(r, e) {
return _arrayWithHoles3(r) || _iterableToArrayLimit3(r, e) || _unsupportedIterableToArray5(r, e) || _nonIterableRest3();
}
function _nonIterableRest3() {
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
function _unsupportedIterableToArray5(r, a) {
if (r) {
if ("string" == typeof r) return _arrayLikeToArray5(r, a);
var t = {}.toString.call(r).slice(8, -1);
return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray5(r, a) : void 0;
}
}
function _arrayLikeToArray5(r, a) {
(null == a || a > r.length) && (a = r.length);
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
return n;
}
function _iterableToArrayLimit3(r, l) {
var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
if (null != t) {
var e, n, i, u, a = [], f = true, o = false;
try {
if (i = (t = t.call(r)).next, 0 === l) {
if (Object(t) !== t) return;
f = false;
} else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = true) ;
} catch (r2) {
o = true, n = r2;
} finally {
try {
if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return;
} finally {
if (o) throw n;
}
}
return a;
}
}
function _arrayWithHoles3(r) {
if (Array.isArray(r)) return r;
}
function ownKeys4(e, r) {
var t = Object.keys(e);
if (Object.getOwnPropertySymbols) {
var o = Object.getOwnPropertySymbols(e);
r && (o = o.filter(function(r2) {
return Object.getOwnPropertyDescriptor(e, r2).enumerable;
})), t.push.apply(t, o);
}
return t;
}
function _objectSpread4(e) {
for (var r = 1; r < arguments.length; r++) {
var t = null != arguments[r] ? arguments[r] : {};
r % 2 ? ownKeys4(Object(t), true).forEach(function(r2) {
_defineProperty4(e, r2, t[r2]);
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys4(Object(t)).forEach(function(r2) {
Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
});
}
return e;
}
function _defineProperty4(e, r, t) {
return (r = _toPropertyKey4(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: true, configurable: true, writable: true }) : e[r] = t, e;
}
function _toPropertyKey4(t) {
var i = _toPrimitive4(t, "string");
return "symbol" == _typeof4(i) ? i : i + "";
}
function _toPrimitive4(t, r) {
if ("object" != _typeof4(t) || !t) return t;
var e = t[Symbol.toPrimitive];
if (void 0 !== e) {
var i = e.call(t, r || "default");
if ("object" != _typeof4(i)) return i;
throw new TypeError("@@toPrimitive must return a primitive value.");
}
return ("string" === r ? String : Number)(t);
}
var RuleGroupDnD = function RuleGroupDnD2(props) {
var $ = c(12);
var rqbDndContext = useContext3(QueryBuilderDndContext);
var canDrop = rqbDndContext.canDrop, t0 = rqbDndContext.baseControls, useDrag = rqbDndContext.useDrag, useDrop = rqbDndContext.useDrop, copyModeModifierKey = rqbDndContext.copyModeModifierKey, groupModeModifierKey = rqbDndContext.groupModeModifierKey;
var BaseRuleGroupComponent = t0.ruleGroup;
var t1 = !!props.parentDisabled || !!props.disabled;
var t2;
if ($[0] !== canDrop || $[1] !== copyModeModifierKey || $[2] !== groupModeModifierKey || $[3] !== props || $[4] !== t1 || $[5] !== useDrag || $[6] !== useDrop) {
t2 = _objectSpread4(_objectSpread4({}, props), {}, { disabled: t1, useDrag, useDrop, canDrop, copyModeModifierKey, groupModeModifierKey });
$[0] = canDrop;
$[1] = copyModeModifierKey;
$[2] = groupModeModifierKey;
$[3] = props;
$[4] = t1;
$[5] = useDrag;
$[6] = useDrop;
$[7] = t2;
} else {
t2 = $[7];
}
var dndRefs = useRuleGroupDnD(t2);
var t3;
if ($[8] !== BaseRuleGroupComponent || $[9] !== dndRefs || $[10] !== props) {
t3 = jsx3(BaseRuleGroupComponent, _objectSpread4(_objectSpread4({}, props), dndRefs));
$[8] = BaseRuleGroupComponent;
$[9] = dndRefs;
$[10] = props;
$[11] = t3;
} else {
t3 = $[11];
}
return t3;
};
var accept2 = ["rule", "ruleGroup"];
var useRuleGroupDnD = function useRuleGroupDnD2(params) {
var previewRef = useRef3(null);
var dragRef = useRef3(null);
var dropRef = useRef3(null);
var disabled = params.disabled, path = params.path, ruleGroup2 = params.ruleGroup, schema = params.schema, actions = params.actions, useDrag = params.useDrag, useDrop = params.useDrop, _canDrop = params.canDrop, _params$copyModeModif = params.copyModeModifierKey, copyModeModifierKey = _params$copyModeModif === void 0 ? "alt" : _params$copyModeModif, _params$groupModeModi = params.groupModeModifierKey, groupModeModifierKey = _params$groupModeModi === void 0 ? "ctrl" : _params$groupModeModi;
var _useDragCommon = useDragCommon({ type: "ruleGroup", path, disabled, independentCombinators: schema.independentCombinators, schema, actions, useDrag, copyModeModifierKey, groupModeModifierKey }), _useDragCommon2 = _slicedToArray3(_useDragCommon, 3), _useDragCommon2$ = _useDragCommon2[0], isDragging = _useDragCommon2$.isDragging, dragMonitorId = _useDragCommon2$.dragMonitorId, drag = _useDragCommon2[1], preview = _useDragCommon2[2];
var _useDrop = useDrop(function() {
return { accept: accept2, canDrop: function canDrop(dragging) {
if (disabled || dragging && typeof _canDrop === "function" && !_canDrop({ dragging, hovering: _objectSpread4(_objectSpread4({}, ruleGroup2), {}, { path, qbId: schema.qbId }) })) {
return false;
}
if (schema.qbId !== dragging.qbId) return true;
var parentItemPath = getParentPath4(dragging.path);
var itemIndex = dragging.path.at(-1);
return !// 1) item is ancestor of drop target, OR
(isAncestor3(dragging.path, path) || // 2) item is first child and is dropped on its own group header, OR
pathsAreEqual3(path, parentItemPath) && itemIndex === 0 || // 3) the group is dropped on itself
pathsAreEqual3(path, dragging.path));
}, collect: function collect(monitor) {
var _monitor$getHandlerId;
return { isOver: monitor.canDrop() && monitor.isOver(), dropMonitorId: (_monitor$getHandlerId = monitor.getHandlerId()) !== null && _monitor$getHandlerId !== void 0 ? _monitor$getHandlerId : "", dropEffect: isHotkeyPressed(copyModeModifierKey) ? "copy" : "move", groupItems: isHotkeyPressed(groupModeModifierKey) };
}, drop: function drop2() {
var qbId = schema.qbId, getQuery = schema.getQuery, dispatchQuery = schema.dispatchQuery;
var dropEffect2 = isHotkeyPressed(copyModeModifierKey) ? "copy" : "move";
var groupItems2 = isHotkeyPressed(groupModeModifierKey);
return { type: "ruleGroup", path, qbId, getQuery, dispatchQuery, groupItems: groupItems2, dropEffect: dropEffect2 };
} };
}, [disabled, actions.groupRule, actions.moveRule, path, _canDrop, ruleGroup2, schema]), _useDrop2 = _slicedToArray3(_useDrop, 2), _useDrop2$ = _useDrop2[0], isOver = _useDrop2$.isOver, dropMonitorId = _useDrop2$.dropMonitorId, dropEffect = _useDrop2$.dropEffect, groupItems = _useDrop2$.groupItems, drop = _useDrop2[1];
if (path.length > 0) {
drag(dragRef);
preview(previewRef);
}
drop(dropRef);
return { isDragging, dragMonitorId, isOver, dropMonitorId, previewRef, dragRef, dropRef, dropEffect, groupItems };
};
// src/isTouchDevice.ts
var isTouchDevice = function isTouchDevice2() {
return typeof window !== "undefined" && "ontouchstart" in window || typeof navigator !== "undefined" && navigator.maxTouchPoints > 0;
};
// src/QueryBuilderDnD.tsx
function _typeof5(o) {
"@babel/helpers - typeof";
return _typeof5 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o2) {
return typeof o2;
} : function(o2) {
return o2 && "function" == typeof Symbol && o2.constructor === Symbol && o2 !== Symbol.prototype ? "symbol" : typeof o2;
}, _typeof5(o);
}
function _regeneratorRuntime() {
"use strict";
_regeneratorRuntime = function _regeneratorRuntime2() {
return e;
};
var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function(t2, e2, r2) {
t2[e2] = r2.value;
}, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c2 = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag";
function define(t2, e2, r2) {
return Object.defineProperty(t2, e2, { value: r2, enumerable: true, configurable: true, writable: true }), t2[e2];
}
try {
define({}, "");
} catch (t2) {
define = function define2(t3, e2, r2) {
return t3[e2] = r2;
};
}
function wrap(t2, e2, r2, n2) {
var i2 = e2 && e2.prototype instanceof Generator ? e2 : Generator, a2 = Object.create(i2.prototype), c3 = new Context(n2 || []);
return o(a2, "_invoke", { value: makeInvokeMethod(t2, r2, c3) }), a2;
}
function tryCatch(t2, e2, r2) {
try {
return { type: "normal", arg: t2.call(e2, r2) };
} catch (t3) {
return { type: "throw", arg: t3 };
}
}
e.wrap = wrap;
var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {};
function Generator() {
}
function GeneratorFunction() {
}
function GeneratorFunctionPrototype() {
}
var p = {};
define(p, a, function() {
return this;
});
var d = Object.getPrototypeOf, v = d && d(d(values([])));
v && v !== r && n.call(v, a) && (p = v);
var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p);
function defineIteratorMethods(t2) {
["next", "throw", "return"].forEach(function(e2) {
define(t2, e2, function(t3) {
return this._invoke(e2, t3);
});
});
}
function AsyncIterator(t2, e2) {
function invoke(r3, o2, i2, a2) {
var c3 = tryCatch(t2[r3], t2, o2);
if ("throw" !== c3.type) {
var u2 = c3.arg, h2 = u2.value;
return h2 && "object" == _typeof5(h2) && n.call(h2, "__await") ? e2.resolve(h2.__await).then(function(t3) {
invoke("next", t3, i2, a2);
}, function(t3) {
invoke("throw", t3, i2, a2);
}) : e2.resolve(h2).then(function(t3) {
u2.value = t3, i2(u2);
}, function(t3) {
return invoke("throw", t3, i2, a2);
});
}
a2(c3.arg);
}
var r2;
o(this, "_invoke", { value: function value(t3, n2) {
function callInvokeWithMethodAndArg() {
return new e2(function(e3, r3) {
invoke(t3, n2, e3, r3);
});
}
return r2 = r2 ? r2.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
} });
}
function makeInvokeMethod(e2, r2, n2) {
var o2 = h;
return function(i2, a2) {
if (o2 === f) throw Error("Generator is already running");
if (o2 === s) {
if ("throw" === i2) throw a2;
return { value: t, done: true };
}
for (n2.method = i2, n2.arg = a2; ; ) {
var c3 = n2.delegate;
if (c3) {
var u2 = maybeInvokeDelegate(c3, n2);
if (u2) {
if (u2 === y) continue;
return u2;
}
}
if ("next" === n2.method) n2.sent = n2._sent = n2.arg;
else if ("throw" === n2.method) {
if (o2 === h) throw o2 = s, n2.arg;
n2.dispatchException(n2.arg);
} else "return" === n2.method && n2.abrupt("return", n2.arg);
o2 = f;
var p2 = tryCatch(e2, r2, n2);
if ("normal" === p2.type) {
if (o2 = n2.done ? s : l, p2.arg === y) continue;
return { value: p2.arg, done: n2.done };
}
"throw" === p2.type && (o2 = s, n2.method = "throw", n2.arg = p2.arg);
}
};
}
function maybeInvokeDelegate(e2, r2) {
var n2 = r2.method, o2 = e2.iterator[n2];
if (o2 === t) return r2.delegate = null, "throw" === n2 && e2.iterator["return"] && (r2.method = "return", r2.arg = t, maybeInvokeDelegate(e2, r2), "throw" === r2.method) || "return" !== n2 && (r2.method = "throw", r2.arg = new TypeError("The iterator does not provide a '" + n2 + "' method")), y;
var i2 = tryCatch(o2, e2.iterator, r2.arg);
if ("throw" === i2.type) return r2.method = "throw", r2.arg = i2.arg, r2.delegate = null, y;
var a2 = i2.arg;
return a2 ? a2.done ? (r2[e2.resultName] = a2.value, r2.next = e2.nextLoc, "return" !== r2.method && (r2.method = "next", r2.arg = t), r2.delegate = null, y) : a2 : (r2.method = "throw", r2.arg = new TypeError("iterator result is not an object"), r2.delegate = null, y);
}
function pushTryEntry(t2) {
var e2 = { tryLoc: t2[0] };
1 in t2 && (e2.catchLoc = t2[1]), 2 in t2 && (e2.finallyLoc = t2[2], e2.afterLoc = t2[3]), this.tryEntries.push(e2);
}
function resetTryEntry(t2) {
var e2 = t2.completion || {};
e2.type = "normal", delete e2.arg, t2.completion = e2;
}
function Context(t2) {
this.tryEntries = [{ tryLoc: "root" }], t2.forEach(pushTryEntry, this), this.reset(true);
}
function values(e2) {
if (e2 || "" === e2) {
var r2 = e2[a];
if (r2) return r2.call(e2);
if ("function" == typeof e2.next) return e2;
if (!isNaN(e2.length)) {
var o2 = -1, i2 = function next() {
for (; ++o2 < e2.length; ) if (n.call(e2, o2)) return next.value = e2[o2], next.done = false, next;
return next.value = t, next.done = true, next;
};
return i2.next = i2;
}
}
throw new TypeError(_typeof5(e2) + " is not iterable");
}
return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: true }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: true }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function(t2) {
var e2 = "function" == typeof t2 && t2.constructor;
return !!e2 && (e2 === GeneratorFunction || "GeneratorFunction" === (e2.displayName || e2.name));
}, e.mark = function(t2) {
return Object.setPrototypeOf ? Object.setPrototypeOf(t2, GeneratorFunctionPrototype) : (t2.__proto__ = GeneratorFunctionPrototype, define(t2, u, "GeneratorFunction")), t2.prototype = Object.create(g), t2;
}, e.awrap = function(t2) {
return { __await: t2 };
}, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c2, function() {
return this;
}), e.AsyncIterator = AsyncIterator, e.async = function(t2, r2, n2, o2, i2) {
void 0 === i2 && (i2 = Promise);
var a2 = new AsyncIterator(wrap(t2, r2, n2, o2), i2);
return e.isGeneratorFunction(r2) ? a2 : a2.next().then(function(t3) {
return t3.done ? t3.value : a2.next();
});
}, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function() {
return this;
}), define(g, "toString", function() {
return "[object Generator]";
}), e.keys = function(t2) {
var e2 = Object(t2), r2 = [];
for (var n2 in e2) r2.push(n2);
return r2.reverse(), function next() {
for (; r2.length; ) {
var t3 = r2.pop();
if (t3 in e2) return next.value = t3, next.done = false, next;
}
return next.done = true, next;
};
}, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e2) {
if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = false, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e2) for (var r2 in this) "t" === r2.charAt(0) && n.call(this, r2) && !isNaN(+r2.slice(1)) && (this[r2] = t);
}, stop: function stop() {
this.done = true;
var t2 = this.tryEntries[0].completion;
if ("throw" === t2.type) throw t2.arg;
return this.rval;
}, dispatchException: function dispatchException(e2) {
if (this.done) throw e2;
var r2 = this;
function handle(n2, o3) {
return a2.type = "throw", a2.arg = e2, r2.next = n2, o3 && (r2.method = "next", r2.arg = t), !!o3;
}
for (var o2 = this.tryEntries.length - 1; o2 >= 0; --o2) {
var i2 = this.tryEntries[o2], a2 = i2.completion;
if ("root" === i2.tryLoc) return handle("end");
if (i2.tryLoc <= this.prev) {
var c3 = n.call(i2, "catchLoc"), u2 = n.call(i2, "finallyLoc");
if (c3 && u2) {
if (this.prev < i2.catchLoc) return handle(i2.catchLoc, true);
if (this.prev < i2.finallyLoc) return handle(i2.finallyLoc);
} else if (c3) {
if (this.prev < i2.catchLoc) return handle(i2.catchLoc, true);
} else {
if (!u2) throw Error("try statement without catch or finally");
if (this.prev < i2.finallyLoc) return handle(i2.finallyLoc);
}
}
}
}, abrupt: function abrupt(t2, e2) {
for (var r2 = this.tryEntries.length - 1; r2 >= 0; --r2) {
var o2 = this.tryEntries[r2];
if (o2.tryLoc <= this.prev && n.call(o2, "finallyLoc") && this.prev < o2.finallyLoc) {
var i2 = o2;
break;
}
}
i2 && ("break" === t2 || "continue" === t2) && i2.tryLoc <= e2 && e2 <= i2.finallyLoc && (i2 = null);
var a2 = i2 ? i2.completion : {};
return a2.type = t2, a2.arg = e2, i2 ? (this.method = "next", this.next = i2.finallyLoc, y) : this.complete(a2);
}, complete: function complete(t2, e2) {
if ("throw" === t2.type) throw t2.arg;
return "break" === t2.type || "continue" === t2.type ? this.next = t2.arg : "return" === t2.type ? (this.rval = this.arg = t2.arg, this.method = "return", this.next = "end") : "normal" === t2.type && e2 && (this.next = e2), y;
}, finish: function finish(t2) {
for (var e2 = this.tryEntries.length - 1; e2 >= 0; --e2) {
var r2 = this.tryEntries[e2];
if (r2.finallyLoc === t2) return this.complete(r2.completion, r2.afterLoc), resetTryEntry(r2), y;
}
}, "catch": function _catch(t2) {
for (var e2 = this.tryEntries.length - 1; e2 >= 0; --e2) {
var r2 = this.tryEntries[e2];
if (r2.tryLoc === t2) {
var n2 = r2.completion;
if ("throw" === n2.type) {
var o2 = n2.arg;
resetTryEntry(r2);
}
return o2;
}
}
throw Error("illegal catch attempt");
}, delegateYield: function delegateYield(e2, r2, n2) {
return this.delegate = { iterator: values(e2), resultName: r2, nextLoc: n2 }, "next" === this.method && (this.arg = t), y;
} }, e;
}
function asyncGeneratorStep(n, t, e, r, o, a, c2) {
try {
var i = n[a](c2), u = i.value;
} catch (n2) {
return void e(n2);
}
i.done ? t(u) : Promise.resolve(u).then(r, o);
}
function _asyncToGenerator(n) {
return function() {
var t = this, e = arguments;
return new Promise(function(r, o) {
var a = n.apply(t, e);
function _next(n2) {
asyncGeneratorStep(a, r, o, _next, _throw, "next", n2);
}
function _throw(n2) {
asyncGeneratorStep(a, r, o, _next, _throw, "throw", n2);
}
_next(void 0);
});
};
}
function _slicedToArray4(r, e) {
return _arrayWithHoles4(r) || _iterableToArrayLimit4(r, e) || _unsupportedIterableToArray6(r, e) || _nonIterableRest4();
}
function _nonIterableRest4() {
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]