graphql-birdseye
Version:
graphql visualizer
502 lines (500 loc) • 89.5 kB
JavaScript
'use strict';Object.defineProperty(exports,"__esModule",{value:!0});function _interopDefault(e){return e&&"object"==typeof e&&"default"in e?e["default"]:e}var React=require("react"),React__default=_interopDefault(React),ReactDOM=require("react-dom"),PropTypes=_interopDefault(require("prop-types")),extendStatics=function(e,t){return extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},extendStatics(e,t)};function __extends(e,t){function n(){this.constructor=e}extendStatics(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var __assign=function(){return __assign=Object.assign||function(e){for(var t,r=1,o=arguments.length;r<o;r++)for(var n in t=arguments[r],t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e},__assign.apply(this,arguments)};function __rest(n,r){var e={};for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&0>r.indexOf(t)&&(e[t]=n[t]);if(null!=n&&"function"==typeof Object.getOwnPropertySymbols)for(var o=0,t=Object.getOwnPropertySymbols(n);o<t.length;o++)0>r.indexOf(t[o])&&Object.prototype.propertyIsEnumerable.call(n,t[o])&&(e[t[o]]=n[t[o]]);return e}function __awaiter(e,t,n,r){return new(n||(n=Promise))(function(o,i){function a(e){try{d(r.next(e))}catch(t){i(t)}}function s(e){try{d(r["throw"](e))}catch(t){i(t)}}function d(e){e.done?o(e.value):new n(function(t){t(e.value)}).then(a,s)}d((r=r.apply(e,t||[])).next())})}function __generator(e,n){function r(e){return function(t){return o([e,t])}}function o(t){if(i)throw new TypeError("Generator is already executing.");for(;p;)try{if(i=1,a&&(s=2&t[0]?a["return"]:t[0]?a["throw"]||((s=a["return"])&&s.call(a),0):a.next)&&!(s=s.call(a,t[1])).done)return s;switch((a=0,s)&&(t=[2&t[0],s.value]),t[0]){case 0:case 1:s=t;break;case 4:return p.label++,{value:t[1],done:!1};case 5:p.label++,a=t[1],t=[0];continue;case 7:t=p.ops.pop(),p.trys.pop();continue;default:if((s=p.trys,!(s=0<s.length&&s[s.length-1]))&&(6===t[0]||2===t[0])){p=0;continue}if(3===t[0]&&(!s||t[1]>s[0]&&t[1]<s[3])){p.label=t[1];break}if(6===t[0]&&p.label<s[1]){p.label=s[1],s=t;break}if(s&&p.label<s[2]){p.label=s[2],p.ops.push(t);break}s[2]&&p.ops.pop(),p.trys.pop();continue;}t=n.call(e,p)}catch(n){t=[6,n],a=0}finally{i=s=0}if(5&t[0])throw t[1];return{value:t[0]?t[1]:void 0,done:!0}}var i,a,s,d,p={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]};return d={next:r(0),throw:r(1),return:r(2)},"function"==typeof Symbol&&(d[Symbol.iterator]=function(){return this}),d}/**
* A collection of shims that provide minimal functionality of the ES6 collections.
*
* These implementations are not meant to be used outside of the ResizeObserver
* modules as they cover only a limited range of use cases.
*/ /* eslint-disable require-jsdoc, valid-jsdoc */var MapShim=function(){/**
* Returns index in provided array that matches the specified key.
*
* @param {Array<Array>} arr
* @param {*} key
* @returns {number}
*/function e(e,t){var n=-1;return e.some(function(e,r){return e[0]===t&&(n=r,!0)}),n}return"undefined"==typeof Map?/** @class */function(){function t(){this.__entries__=[]}return Object.defineProperty(t.prototype,"size",{/**
* @returns {boolean}
*/get:function(){return this.__entries__.length},enumerable:!0,configurable:!0}),t.prototype.get=function(t){var n=e(this.__entries__,t),r=this.__entries__[n];return r&&r[1]},t.prototype.set=function(t,n){var r=e(this.__entries__,t);~r?this.__entries__[r][1]=n:this.__entries__.push([t,n])},t.prototype.delete=function(t){var n=this.__entries__,r=e(n,t);~r&&n.splice(r,1)},t.prototype.has=function(t){return!!~e(this.__entries__,t)},t.prototype.clear=function(){this.__entries__.splice(0)},t.prototype.forEach=function(e,t){void 0===t&&(t=null);for(var n,r=0,o=this.__entries__;r<o.length;r++)n=o[r],e.call(t,n[1],n[0])},t}():Map}(),isBrowser="undefined"!=typeof window&&"undefined"!=typeof document&&window.document===document,global$1=function(){return"undefined"!=typeof global&&global.Math===Math?global:"undefined"!=typeof self&&self.Math===Math?self:"undefined"!=typeof window&&window.Math===Math?window:Function("return this")();// eslint-disable-next-line no-new-func
}(),requestAnimationFrame$1=function(){return"function"==typeof requestAnimationFrame?requestAnimationFrame.bind(global$1):function(e){return setTimeout(function(){return e(Date.now())},1e3/60)}}(),trailingTimeout=2;/**
* Detects whether window and document objects are available in current environment.
*/ /**
* Creates a wrapper function which ensures that provided callback will be
* invoked only once during the specified delay period.
*
* @param {Function} callback - Function to be invoked after the delay period.
* @param {number} delay - Delay after which to invoke callback.
* @returns {Function}
*/function throttle(e,t){/**
* Invokes the original callback function and schedules new invocation if
* the "proxy" was called during current request.
*
* @returns {void}
*/function n(){i&&(i=!1,e()),a&&o()}/**
* Callback invoked after the specified delay. It will further postpone
* invocation of the original function delegating it to the
* requestAnimationFrame.
*
* @returns {void}
*/function r(){requestAnimationFrame$1(n)}/**
* Schedules invocation of the original function.
*
* @returns {void}
*/function o(){var e=Date.now();if(i){// Reject immediately following calls.
if(e-s<trailingTimeout)return;// Schedule new call to be in invoked when the pending one is resolved.
// This is important for "transitions" which never actually start
// immediately so there is a chance that we might miss one if change
// happens amids the pending invocation.
a=!0}else i=!0,a=!1,setTimeout(r,t);s=e}var i=!1,a=!1,s=0;return o}// Minimum delay before invoking the update of observers.
var REFRESH_DELAY=20,transitionKeys=["top","right","bottom","left","width","height","size","weight"],mutationObserverSupported="undefined"!=typeof MutationObserver,ResizeObserverController=/** @class */function(){/**
* Creates a new instance of ResizeObserverController.
*
* @private
*/function e(){this.connected_=!1,this.mutationEventsAdded_=!1,this.mutationsObserver_=null,this.observers_=[],this.onTransitionEnd_=this.onTransitionEnd_.bind(this),this.refresh=throttle(this.refresh.bind(this),REFRESH_DELAY)}/**
* Adds observer to observers list.
*
* @param {ResizeObserverSPI} observer - Observer to be added.
* @returns {void}
*/return e.prototype.addObserver=function(e){~this.observers_.indexOf(e)||this.observers_.push(e),this.connected_||this.connect_()},e.prototype.removeObserver=function(e){var t=this.observers_,n=t.indexOf(e);~n&&t.splice(n,1),!t.length&&this.connected_&&this.disconnect_()},e.prototype.refresh=function(){var e=this.updateObservers_();// Continue running updates if changes have been detected as there might
// be future ones caused by CSS transitions.
e&&this.refresh()},e.prototype.updateObservers_=function(){// Collect observers that have active observations.
var e=this.observers_.filter(function(e){return e.gatherActive(),e.hasActive()});// Deliver notifications in a separate cycle in order to avoid any
// collisions between observers, e.g. when multiple instances of
// ResizeObserver are tracking the same element and the callback of one
// of them changes content dimensions of the observed target. Sometimes
// this may result in notifications being blocked for the rest of observers.
return e.forEach(function(e){return e.broadcastActive()}),0<e.length},e.prototype.connect_=function(){!isBrowser||this.connected_||(// Subscription to the "Transitionend" event is used as a workaround for
// delayed transitions. This way it's possible to capture at least the
// final state of an element.
document.addEventListener("transitionend",this.onTransitionEnd_),window.addEventListener("resize",this.refresh),mutationObserverSupported?(this.mutationsObserver_=new MutationObserver(this.refresh),this.mutationsObserver_.observe(document,{attributes:!0,childList:!0,characterData:!0,subtree:!0})):(document.addEventListener("DOMSubtreeModified",this.refresh),this.mutationEventsAdded_=!0),this.connected_=!0)},e.prototype.disconnect_=function(){isBrowser&&this.connected_&&(document.removeEventListener("transitionend",this.onTransitionEnd_),window.removeEventListener("resize",this.refresh),this.mutationsObserver_&&this.mutationsObserver_.disconnect(),this.mutationEventsAdded_&&document.removeEventListener("DOMSubtreeModified",this.refresh),this.mutationsObserver_=null,this.mutationEventsAdded_=!1,this.connected_=!1)},e.prototype.onTransitionEnd_=function(e){var t=e.propertyName,n=void 0===t?"":t,r=transitionKeys.some(function(e){return!!~n.indexOf(e)});// Detect whether transition may affect dimensions of an element.
r&&this.refresh()},e.getInstance=function(){return this.instance_||(this.instance_=new e),this.instance_},e.instance_=null,e}(),defineConfigurable=function(e,t){for(var n,r=0,o=Object.keys(t);r<o.length;r++)n=o[r],Object.defineProperty(e,n,{value:t[n],enumerable:!1,writable:!1,configurable:!0});return e},getWindowOf=function(e){// Assume that the element is an instance of Node, which means that it
// has the "ownerDocument" property from which we can retrieve a
// corresponding global object.
var t=e&&e.ownerDocument&&e.ownerDocument.defaultView;// Return the local global object if it's not possible extract one from
// provided element.
return t||global$1},emptyRect=createRectInit(0,0,0,0);// A list of substrings of CSS properties used to find transition events that
// might affect dimensions of observed elements.
/**
* Converts provided string to a number.
*
* @param {number|string} value
* @returns {number}
*/function toFloat(e){return parseFloat(e)||0}/**
* Extracts borders size from provided styles.
*
* @param {CSSStyleDeclaration} styles
* @param {...string} positions - Borders positions (top, right, ...)
* @returns {number}
*/function getBordersSize(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];return t.reduce(function(t,n){var r=e["border-"+n+"-width"];return t+toFloat(r)},0)}/**
* Extracts paddings sizes from provided styles.
*
* @param {CSSStyleDeclaration} styles
* @returns {Object} Paddings box.
*/function getPaddings(e){for(var t=["top","right","bottom","left"],n={},r=0,o=t;r<o.length;r++){var i=o[r],a=e["padding-"+i];n[i]=toFloat(a)}return n}/**
* Calculates content rectangle of provided SVG element.
*
* @param {SVGGraphicsElement} target - Element content rectangle of which needs
* to be calculated.
* @returns {DOMRectInit}
*/function getSVGContentRect(e){var t=e.getBBox();return createRectInit(0,0,t.width,t.height)}/**
* Calculates content rectangle of provided HTMLElement.
*
* @param {HTMLElement} target - Element for which to calculate the content rectangle.
* @returns {DOMRectInit}
*/function getHTMLElementContentRect(e){var t=Math.abs,n=Math.round,r=e.clientWidth,o=e.clientHeight;// By this condition we can catch all non-replaced inline, hidden and
// detached elements. Though elements with width & height properties less
// than 0.5 will be discarded as well.
//
// Without it we would need to implement separate methods for each of
// those cases and it's not possible to perform a precise and performance
// effective test for hidden elements. E.g. even jQuery's ':visible' filter
// gives wrong results for elements with width & height less than 0.5.
if(!r&&!o)return emptyRect;var i=getWindowOf(e).getComputedStyle(e),a=getPaddings(i),s=a.left+a.right,d=a.top+a.bottom,p=toFloat(i.width),l=toFloat(i.height);// Following steps can't be applied to the document's root element as its
// client[Width/Height] properties represent viewport area of the window.
// Besides, it's as well not necessary as the <html> itself neither has
// rendered scroll bars nor it can be clipped.
if("border-box"===i.boxSizing&&(n(p+s)!==r&&(p-=getBordersSize(i,"left","right")+s),n(l+d)!==o&&(l-=getBordersSize(i,"top","bottom")+d)),!isDocumentElement(e)){// In some browsers (only in Firefox, actually) CSS width & height
// include scroll bars size which can be removed at this step as scroll
// bars are the only difference between rounded dimensions + paddings
// and "client" properties, though that is not always true in Chrome.
var c=n(p+s)-r,h=n(l+d)-o;1!==t(c)&&(p-=c),1!==t(h)&&(l-=h)}return createRectInit(a.left,a.top,p,l)}/**
* Checks whether provided element is an instance of the SVGGraphicsElement.
*
* @param {Element} target - Element to be checked.
* @returns {boolean}
*/var isSVGGraphicsElement=function(){// Some browsers, namely IE and Edge, don't have the SVGGraphicsElement
// interface.
return"undefined"==typeof SVGGraphicsElement?function(e){return e instanceof getWindowOf(e).SVGElement&&"function"==typeof e.getBBox}:function(e){return e instanceof getWindowOf(e).SVGGraphicsElement};// If it's so, then check that element is at least an instance of the
// SVGElement and that it has the "getBBox" method.
// eslint-disable-next-line no-extra-parens
}();/**
* Checks whether provided element is a document element (<html>).
*
* @param {Element} target - Element to be checked.
* @returns {boolean}
*/function isDocumentElement(e){return e===getWindowOf(e).document.documentElement}/**
* Calculates an appropriate content rectangle for provided html or svg element.
*
* @param {Element} target - Element content rectangle of which needs to be calculated.
* @returns {DOMRectInit}
*/function getContentRect(e){return isBrowser?isSVGGraphicsElement(e)?getSVGContentRect(e):getHTMLElementContentRect(e):emptyRect}/**
* Creates rectangle with an interface of the DOMRectReadOnly.
* Spec: https://drafts.fxtf.org/geometry/#domrectreadonly
*
* @param {DOMRectInit} rectInit - Object with rectangle's x/y coordinates and dimensions.
* @returns {DOMRectReadOnly}
*/function createReadOnlyRect(e){var t=e.x,n=e.y,r=e.width,o=e.height,i="undefined"==typeof DOMRectReadOnly?Object:DOMRectReadOnly,a=Object.create(i.prototype);// If DOMRectReadOnly is available use it as a prototype for the rectangle.
return defineConfigurable(a,{x:t,y:n,width:r,height:o,top:n,right:t+r,bottom:o+n,left:t}),a}/**
* Creates DOMRectInit object based on the provided dimensions and the x/y coordinates.
* Spec: https://drafts.fxtf.org/geometry/#dictdef-domrectinit
*
* @param {number} x - X coordinate.
* @param {number} y - Y coordinate.
* @param {number} width - Rectangle's width.
* @param {number} height - Rectangle's height.
* @returns {DOMRectInit}
*/function createRectInit(e,t,n,r){return{x:e,y:t,width:n,height:r}}/**
* Class that is responsible for computations of the content rectangle of
* provided DOM element and for keeping track of it's changes.
*/var ResizeObservation=/** @class */function(){/**
* Creates an instance of ResizeObservation.
*
* @param {Element} target - Element to be observed.
*/function e(e){this.broadcastWidth=0,this.broadcastHeight=0,this.contentRect_=createRectInit(0,0,0,0),this.target=e}/**
* Updates content rectangle and tells whether it's width or height properties
* have changed since the last broadcast.
*
* @returns {boolean}
*/return e.prototype.isActive=function(){var e=getContentRect(this.target);return this.contentRect_=e,e.width!==this.broadcastWidth||e.height!==this.broadcastHeight},e.prototype.broadcastRect=function(){var e=this.contentRect_;return this.broadcastWidth=e.width,this.broadcastHeight=e.height,e},e}(),ResizeObserverEntry=/** @class */function(){/**
* Creates an instance of ResizeObserverEntry.
*
* @param {Element} target - Element that is being observed.
* @param {DOMRectInit} rectInit - Data of the element's content rectangle.
*/return function(e,t){var n=createReadOnlyRect(t);// According to the specification following properties are not writable
// and are also not enumerable in the native implementation.
//
// Property accessors are not being used as they'd require to define a
// private WeakMap storage which may cause memory leaks in browsers that
// don't support this type of collections.
defineConfigurable(this,{target:e,contentRect:n})}}(),ResizeObserverSPI=/** @class */function(){/**
* Creates a new instance of ResizeObserver.
*
* @param {ResizeObserverCallback} callback - Callback function that is invoked
* when one of the observed elements changes it's content dimensions.
* @param {ResizeObserverController} controller - Controller instance which
* is responsible for the updates of observer.
* @param {ResizeObserver} callbackCtx - Reference to the public
* ResizeObserver instance which will be passed to callback function.
*/function e(e,t,n){if(this.activeObservations_=[],this.observations_=new MapShim,"function"!=typeof e)throw new TypeError("The callback provided as parameter 1 is not a function.");this.callback_=e,this.controller_=t,this.callbackCtx_=n}/**
* Starts observing provided element.
*
* @param {Element} target - Element to be observed.
* @returns {void}
*/return e.prototype.observe=function(e){if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");// Do nothing if current environment doesn't have the Element interface.
if("undefined"!=typeof Element&&Element instanceof Object){if(!(e instanceof getWindowOf(e).Element))throw new TypeError("parameter 1 is not of type \"Element\".");var t=this.observations_;// Do nothing if element is already being observed.
t.has(e)||(// Force the update of observations.
t.set(e,new ResizeObservation(e)),this.controller_.addObserver(this),this.controller_.refresh())}},e.prototype.unobserve=function(e){if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");// Do nothing if current environment doesn't have the Element interface.
if("undefined"!=typeof Element&&Element instanceof Object){if(!(e instanceof getWindowOf(e).Element))throw new TypeError("parameter 1 is not of type \"Element\".");var t=this.observations_;// Do nothing if element is not being observed.
t.has(e)&&(t.delete(e),!t.size&&this.controller_.removeObserver(this))}},e.prototype.disconnect=function(){this.clearActive(),this.observations_.clear(),this.controller_.removeObserver(this)},e.prototype.gatherActive=function(){var e=this;this.clearActive(),this.observations_.forEach(function(t){t.isActive()&&e.activeObservations_.push(t)})},e.prototype.broadcastActive=function(){// Do nothing if observer doesn't have active observations.
if(this.hasActive()){var e=this.callbackCtx_,t=this.activeObservations_.map(function(e){return new ResizeObserverEntry(e.target,e.broadcastRect())});// Create ResizeObserverEntry instance for every active observation.
this.callback_.call(e,t,e),this.clearActive()}},e.prototype.clearActive=function(){this.activeObservations_.splice(0)},e.prototype.hasActive=function(){return 0<this.activeObservations_.length},e}(),observers="undefined"==typeof WeakMap?new MapShim:new WeakMap,ResizeObserver=/** @class */function(){/**
* Creates a new instance of ResizeObserver.
*
* @param {ResizeObserverCallback} callback - Callback that is invoked when
* dimensions of the observed elements change.
*/function e(t){if(!(this instanceof e))throw new TypeError("Cannot call a class as a function.");if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");var n=ResizeObserverController.getInstance(),r=new ResizeObserverSPI(t,n,this);observers.set(this,r)}return e}();["observe","unobserve","disconnect"].forEach(function(e){ResizeObserver.prototype[e]=function(){var t;return(t=observers.get(this))[e].apply(t,arguments)}});var index=function(){// Export existing implementation if available.
return"undefined"==typeof global$1.ResizeObserver?ResizeObserver:global$1.ResizeObserver}();/**
* Checks if `value` is the
* [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
* of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
*
* @static
* @memberOf _
* @since 0.1.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is an object, else `false`.
* @example
*
* _.isObject({});
* // => true
*
* _.isObject([1, 2, 3]);
* // => true
*
* _.isObject(_.noop);
* // => true
*
* _.isObject(null);
* // => false
*/function isObject(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}/** Detect free variable `global` from Node.js. */var freeGlobal="object"==typeof global&&global&&global.Object===Object&&global,freeSelf="object"==typeof self&&self&&self.Object===Object&&self,root=freeGlobal||freeSelf||Function("return this")(),now=function(){return root.Date.now()},Symbol$1=root.Symbol,objectProto=Object.prototype,hasOwnProperty=objectProto.hasOwnProperty,nativeObjectToString=objectProto.toString,symToStringTag=Symbol$1?Symbol$1.toStringTag:void 0;/** Detect free variable `self`. */ /**
* A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
*
* @private
* @param {*} value The value to query.
* @returns {string} Returns the raw `toStringTag`.
*/function getRawTag(e){var t=hasOwnProperty.call(e,symToStringTag),n=e[symToStringTag];try{e[symToStringTag]=void 0;var r=!0}catch(t){}var o=nativeObjectToString.call(e);return r&&(t?e[symToStringTag]=n:delete e[symToStringTag]),o}/** Used for built-in method references. */var objectProto$1=Object.prototype,nativeObjectToString$1=objectProto$1.toString;/**
* Used to resolve the
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
* of values.
*/ /**
* Converts `value` to a string using `Object.prototype.toString`.
*
* @private
* @param {*} value The value to convert.
* @returns {string} Returns the converted string.
*/function objectToString(e){return nativeObjectToString$1.call(e)}/** `Object#toString` result references. */var nullTag="[object Null]",undefinedTag="[object Undefined]",symToStringTag$1=Symbol$1?Symbol$1.toStringTag:void 0;/** Built-in value references. */ /**
* The base implementation of `getTag` without fallbacks for buggy environments.
*
* @private
* @param {*} value The value to query.
* @returns {string} Returns the `toStringTag`.
*/function baseGetTag(e){return null==e?void 0===e?undefinedTag:nullTag:symToStringTag$1&&symToStringTag$1 in Object(e)?getRawTag(e):objectToString(e)}/**
* Checks if `value` is object-like. A value is object-like if it's not `null`
* and has a `typeof` result of "object".
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is object-like, else `false`.
* @example
*
* _.isObjectLike({});
* // => true
*
* _.isObjectLike([1, 2, 3]);
* // => true
*
* _.isObjectLike(_.noop);
* // => false
*
* _.isObjectLike(null);
* // => false
*/function isObjectLike(e){return null!=e&&"object"==typeof e}/** `Object#toString` result references. */var symbolTag="[object Symbol]";/**
* Checks if `value` is classified as a `Symbol` primitive or object.
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
* @example
*
* _.isSymbol(Symbol.iterator);
* // => true
*
* _.isSymbol('abc');
* // => false
*/function isSymbol(e){return"symbol"==typeof e||isObjectLike(e)&&baseGetTag(e)==symbolTag}/** Used as references for various `Number` constants. */var NAN=0/0,reTrim=/^\s+|\s+$/g,reIsBadHex=/^[-+]0x[0-9a-f]+$/i,reIsBinary=/^0b[01]+$/i,reIsOctal=/^0o[0-7]+$/i,freeParseInt=parseInt;/** Used to match leading and trailing whitespace. */ /**
* Converts `value` to a number.
*
* @static
* @memberOf _
* @since 4.0.0
* @category Lang
* @param {*} value The value to process.
* @returns {number} Returns the number.
* @example
*
* _.toNumber(3.2);
* // => 3.2
*
* _.toNumber(Number.MIN_VALUE);
* // => 5e-324
*
* _.toNumber(Infinity);
* // => Infinity
*
* _.toNumber('3.2');
* // => 3.2
*/function toNumber(e){if("number"==typeof e)return e;if(isSymbol(e))return NAN;if(isObject(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=isObject(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(reTrim,"");var n=reIsBinary.test(e);return n||reIsOctal.test(e)?freeParseInt(e.slice(2),n?2:8):reIsBadHex.test(e)?NAN:+e}/** Error message constants. */var FUNC_ERROR_TEXT="Expected a function",nativeMax=Math.max,nativeMin=Math.min;/* Built-in method references for those with the same name as other `lodash` methods. */ /**
* Creates a debounced function that delays invoking `func` until after `wait`
* milliseconds have elapsed since the last time the debounced function was
* invoked. The debounced function comes with a `cancel` method to cancel
* delayed `func` invocations and a `flush` method to immediately invoke them.
* Provide `options` to indicate whether `func` should be invoked on the
* leading and/or trailing edge of the `wait` timeout. The `func` is invoked
* with the last arguments provided to the debounced function. Subsequent
* calls to the debounced function return the result of the last `func`
* invocation.
*
* **Note:** If `leading` and `trailing` options are `true`, `func` is
* invoked on the trailing edge of the timeout only if the debounced function
* is invoked more than once during the `wait` timeout.
*
* If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
* until to the next tick, similar to `setTimeout` with a timeout of `0`.
*
* See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
* for details over the differences between `_.debounce` and `_.throttle`.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Function
* @param {Function} func The function to debounce.
* @param {number} [wait=0] The number of milliseconds to delay.
* @param {Object} [options={}] The options object.
* @param {boolean} [options.leading=false]
* Specify invoking on the leading edge of the timeout.
* @param {number} [options.maxWait]
* The maximum time `func` is allowed to be delayed before it's invoked.
* @param {boolean} [options.trailing=true]
* Specify invoking on the trailing edge of the timeout.
* @returns {Function} Returns the new debounced function.
* @example
*
* // Avoid costly calculations while the window size is in flux.
* jQuery(window).on('resize', _.debounce(calculateLayout, 150));
*
* // Invoke `sendMail` when clicked, debouncing subsequent calls.
* jQuery(element).on('click', _.debounce(sendMail, 300, {
* 'leading': true,
* 'trailing': false
* }));
*
* // Ensure `batchLog` is invoked once after 1 second of debounced calls.
* var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });
* var source = new EventSource('/stream');
* jQuery(source).on('message', debounced);
*
* // Cancel the trailing debounced invocation.
* jQuery(window).on('popstate', debounced.cancel);
*/function debounce(e,t,n){function r(t){var n=h,r=m;return h=m=void 0,y=t,g=e.apply(r,n),g}function o(e){// Invoke the leading edge.
return y=e,_=setTimeout(s,t),b?r(e):g}function i(e){var n=e-f,r=e-y,o=t-n;return v?nativeMin(o,u-r):o}function a(e){var n=e-f,r=e-y;// Either this is the first call, activity has stopped and we're at the
// trailing edge, the system time has gone backwards and we're treating
// it as the trailing edge, or we've hit the `maxWait` limit.
return void 0===f||n>=t||0>n||v&&r>=u}function s(){var e=now();return a(e)?d(e):void(// Restart the timer.
_=setTimeout(s,i(e)))}function d(e){// Only invoke if we have `lastArgs` which means `func` has been
// debounced at least once.
return(_=void 0,L&&h)?r(e):(h=m=void 0,g)}function p(){void 0!==_&&clearTimeout(_),y=0,h=f=m=_=void 0}function l(){return void 0===_?g:d(now())}function c(){var e=now(),n=a(e);if(h=arguments,m=this,f=e,n){if(void 0===_)return o(f);if(v)return clearTimeout(_),_=setTimeout(s,t),r(f)}return void 0===_&&(_=setTimeout(s,t)),g}var h,m,u,g,_,f,y=0,b=!1,v=!1,L=!0;if("function"!=typeof e)throw new TypeError(FUNC_ERROR_TEXT);return t=toNumber(t)||0,isObject(n)&&(b=!!n.leading,v="maxWait"in n,u=v?nativeMax(toNumber(n.maxWait)||0,t):u,L="trailing"in n?!!n.trailing:L),c.cancel=p,c.flush=l,c}/** Error message constants. */var FUNC_ERROR_TEXT$1="Expected a function";/**
* Creates a throttled function that only invokes `func` at most once per
* every `wait` milliseconds. The throttled function comes with a `cancel`
* method to cancel delayed `func` invocations and a `flush` method to
* immediately invoke them. Provide `options` to indicate whether `func`
* should be invoked on the leading and/or trailing edge of the `wait`
* timeout. The `func` is invoked with the last arguments provided to the
* throttled function. Subsequent calls to the throttled function return the
* result of the last `func` invocation.
*
* **Note:** If `leading` and `trailing` options are `true`, `func` is
* invoked on the trailing edge of the timeout only if the throttled function
* is invoked more than once during the `wait` timeout.
*
* If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
* until to the next tick, similar to `setTimeout` with a timeout of `0`.
*
* See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
* for details over the differences between `_.throttle` and `_.debounce`.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Function
* @param {Function} func The function to throttle.
* @param {number} [wait=0] The number of milliseconds to throttle invocations to.
* @param {Object} [options={}] The options object.
* @param {boolean} [options.leading=true]
* Specify invoking on the leading edge of the timeout.
* @param {boolean} [options.trailing=true]
* Specify invoking on the trailing edge of the timeout.
* @returns {Function} Returns the new throttled function.
* @example
*
* // Avoid excessively updating the position while scrolling.
* jQuery(window).on('scroll', _.throttle(updatePosition, 100));
*
* // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes.
* var throttled = _.throttle(renewToken, 300000, { 'trailing': false });
* jQuery(element).on('click', throttled);
*
* // Cancel the trailing throttled invocation.
* jQuery(window).on('popstate', throttled.cancel);
*/function throttle$1(e,t,n){var r=!0,o=!0;if("function"!=typeof e)throw new TypeError(FUNC_ERROR_TEXT$1);return isObject(n)&&(r="leading"in n?!!n.leading:r,o="trailing"in n?!!n.trailing:o),debounce(e,t,{leading:r,maxWait:t,trailing:o})}/** `Object#toString` result references. */var asyncTag="[object AsyncFunction]",funcTag="[object Function]",genTag="[object GeneratorFunction]",proxyTag="[object Proxy]";/**
* Checks if `value` is classified as a `Function` object.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a function, else `false`.
* @example
*
* _.isFunction(_);
* // => true
*
* _.isFunction(/abc/);
* // => false
*/function isFunction(e){if(!isObject(e))return!1;// The use of `Object#toString` avoids issues with the `typeof` operator
// in Safari 9 which returns 'object' for typed arrays and other constructors.
var t=baseGetTag(e);return t==funcTag||t==genTag||t==asyncTag||t==proxyTag}function _typeof(e){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_typeof(e)}function _toConsumableArray(e){return _arrayWithoutHoles(e)||_iterableToArray(e)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance")}function _iterableToArray(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}function _arrayWithoutHoles(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var n,r=0;r<t.length;r++)n=t[r],n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}function _createClass(e,t,n){return t&&_defineProperties(e.prototype,t),n&&_defineProperties(e,n),e}function _possibleConstructorReturn(e,t){return t&&("object"===_typeof(t)||"function"==typeof t)?t:_assertThisInitialized(e)}function _getPrototypeOf(e){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},_getPrototypeOf(e)}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&_setPrototypeOf(e,t)}function _setPrototypeOf(e,t){return _setPrototypeOf=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},_setPrototypeOf(e,t)}function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _defineProperty(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var listMode={debounce:debounce,throttle:throttle$1},styles={position:"absolute",width:0,height:0,visibility:"hidden",display:"none"};/**
* detect component's children and convert them to array
* @param {*} children - component's children
*/function convertChildrenToArray(e){return e?Array.isArray(e)?e:[e]:[]}var ResizeDetector=/*#__PURE__*/function(e){function t(e){var n;_classCallCheck(this,t),n=_possibleConstructorReturn(this,_getPrototypeOf(t).call(this,e)),_defineProperty(_assertThisInitialized(_assertThisInitialized(n)),"getElement",function(){var e=n.props.resizableElementId,t=e&&document.getElementById(e),r=n.el&&n.el.parentElement;return t||r}),_defineProperty(_assertThisInitialized(_assertThisInitialized(n)),"createResizeHandler",function(e){var t=n.props,r=t.handleWidth,o=t.handleHeight,i=t.onResize;e.forEach(function(e){var t=e.contentRect,a=t.width,s=t.height,d=r&&n.state.width!==a,p=o&&n.state.height!==s;!n.skipOnMount&&(d||p)&&"undefined"!=typeof window&&(n.animationFrameID=window.requestAnimationFrame(function(){i(a,s),n.setState({width:a,height:s})})),n.skipOnMount=!1})}),_defineProperty(_assertThisInitialized(_assertThisInitialized(n)),"handleRenderProp",function(){var e=n.state,t=e.width,r=e.height,o=n.props.render;return o&&"function"==typeof o?React.cloneElement(o({width:t,height:r}),{key:"render"}):void 0}),_defineProperty(_assertThisInitialized(_assertThisInitialized(n)),"renderChildren",function(){var e=n.state,t=e.width,r=e.height,o=n.props.children;return convertChildrenToArray(o).filter(function(e){return!!e}).map(function(e,n){return isFunction(e)?React.cloneElement(e(t,r),{key:n}):React.isValidElement(e)?React.cloneElement(e,{width:t,height:r,key:n}):e})});var r=e.skipOnMount,o=e.refreshMode,i=e.refreshRate,a=e.refreshOptions;return n.state={width:void 0,height:void 0},n.skipOnMount=r,n.animationFrameID=null,n.resizeHandler=listMode[o]?listMode[o](n.createResizeHandler,i,a):n.createResizeHandler,n.ro=new index(n.resizeHandler),n}return _inherits(t,e),_createClass(t,[{key:"componentDidMount",value:function(){var e=this.getElement();e&&this.ro.observe(e)}},{key:"componentWillUnmount",value:function(){var e=this.getElement();e&&this.ro.unobserve(e),"undefined"!=typeof window&&this.animationFrameID&&window.cancelAnimationFrame(this.animationFrameID),this.resizeHandler&&this.resizeHandler.cancel&&this.resizeHandler.cancel()}},{key:"render",value:function(){var e=this,t=this.props.nodeType,n=React.createElement(t,{key:"resize-detector",style:styles,ref:function(t){e.el=t}});return[n,this.handleRenderProp()].concat(_toConsumableArray(this.renderChildren()))}}]),t}(React.PureComponent);ResizeDetector.propTypes={handleWidth:PropTypes.bool,handleHeight:PropTypes.bool,skipOnMount:PropTypes.bool,refreshRate:PropTypes.number,refreshMode:PropTypes.string,refreshOptions:PropTypes.shape({leading:PropTypes.bool,trailing:PropTypes.bool}),resizableElementId:PropTypes.string,onResize:PropTypes.func,render:PropTypes.func,children:PropTypes.any,// eslint-disable-line react/forbid-prop-types
nodeType:PropTypes.node// eslint-disable-line react/forbid-prop-types
},ResizeDetector.defaultProps={handleWidth:!1,handleHeight:!1,skipOnMount:!1,refreshRate:1e3,refreshMode:void 0,refreshOptions:void 0,resizableElementId:"",onResize:function(t){return t},render:void 0,children:null,nodeType:"div"};var withResizeDetector=function(e){var t=1<arguments.length&&arguments[1]!==void 0?arguments[1]:{handleWidth:!0,handleHeight:!0};return(/*#__PURE__*/ // eslint-disable-next-line
function(n){function r(){return _classCallCheck(this,r),_possibleConstructorReturn(this,_getPrototypeOf(r).apply(this,arguments))}return _inherits(r,n),_createClass(r,[{key:"render",value:function(){return React__default.createElement(ResizeDetector,t,React__default.createElement(e,this.props))}}]),r}(React.Component))},extendStatics$1=function(n,e){return extendStatics$1=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,e){n.__proto__=e}||function(n,e){for(var t in e)e.hasOwnProperty(t)&&(n[t]=e[t])},extendStatics$1(n,e)};/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */ /* global Reflect, Promise */function __extends$1(n,e){function t(){this.constructor=n}extendStatics$1(n,e),n.prototype=null===e?Object.create(e):(t.prototype=e.prototype,new t)}var __assign$1=function(){return __assign$1=Object.assign||function(r){for(var e,i=1,s=arguments.length;i<s;i++)for(var a in e=arguments[i],e)Object.prototype.hasOwnProperty.call(e,a)&&(r[a]=e[a]);return r},__assign$1.apply(this,arguments)};function __awaiter$1(d,e,t,l){return new(t||(t=Promise))(function(o,i){function n(t){try{a(l.next(t))}catch(e){i(e)}}function r(t){try{a(l["throw"](t))}catch(e){i(e)}}function a(i){i.done?o(i.value):new t(function(e){e(i.value)}).then(n,r)}a((l=l.apply(d,e||[])).next())})}function __generator$1(d,e){function t(n){return function(e){return o([n,e])}}function o(n){if(i)throw new TypeError("Generator is already executing.");for(;m;)try{if(i=1,a&&(c=2&n[0]?a["return"]:n[0]?a["throw"]||((c=a["return"])&&c.call(a),0):a.next)&&!(c=c.call(a,n[1])).done)return c;switch((a=0,c)&&(n=[2&n[0],c.value]),n[0]){case 0:case 1:c=n;break;case 4:return m.label++,{value:n[1],done:!1};case 5:m.label++,a=n[1],n=[0];continue;case 7:n=m.ops.pop(),m.trys.pop();continue;default:if((c=m.trys,!(c=0<c.length&&c[c.length-1]))&&(6===n[0]||2===n[0])){m=0;continue}if(3===n[0]&&(!c||n[1]>c[0]&&n[1]<c[3])){m.label=n[1];break}if(6===n[0]&&m.label<c[1]){m.label=c[1],c=n;break}if(c&&m.label<c[2]){m.label=c[2],m.ops.push(n);break}c[2]&&m.ops.pop(),m.trys.pop();continue;}n=e.call(d,m)}catch(e){n=[6,e],a=0}finally{i=c=0}if(5&n[0])throw n[1];return{value:n[0]?n[1]:void 0,done:!0}}var i,a,c,h,m={label:0,sent:function(){if(1&c[0])throw c[1];return c[1]},trys:[],ops:[]};return h={next:t(0),throw:t(1),return:t(2)},"function"==typeof Symbol&&(h[Symbol.iterator]=function(){return this}),h}function mapToArray(n){return Object.keys(n).map(function(e){return n[e]})}function arrayToMap(n,r){return n.reduce(function(t,e){return t[r(e)]=e,t},{})}var BirdseyeDataStructure=/** @class */function(){function t(t){void 0===t&&(t={}),this.typeMap={},this.config={},this.config=t}// addConnection(connection: Connection) {
// this.connections.push(connection);
// }
return t.prototype.getType=function(t){return this.typeMap[t]},t.prototype.getAdjacentTypes=function(n){var e=this;return mapToArray(this.typeMap).filter(function(t){return"root"===n?!!["Query","QueryRoot","Mutation"].includes(t.name)||e.checkRelation("Query",t)||e.checkRelation("QueryRoot",t)||e.checkRelation("Mutation",t):n===t.name||t.isRelatedTo(e.getType(n))||e.getType(n).isRelatedTo(t)})},t.prototype.checkRelation=function(n,e){return this.getType(n)&&this.getType(n).isRelatedTo(e)},t}(),Type=/** @class */function(){function t(t){this.fieldMap={},this.name=t}return t.prototype.addField=function(t){this.fieldMap[t.name]=t},t.prototype.getFields=function(){return this.fieldMap},t.prototype.getFieldArray=function(){return mapToArray(this.fieldMap)},t.prototype.isRelatedTo=function(n){return mapToArray(this.fieldMap).find(function(e){return e.type===n})&&!0},t}(),Field=/** @class */function(){return function(){}}(),baseEntities=["Boolean","Int","String","Float","ID"],filteredTypes=["DateTime"];function instanceOf(n,e){for(var r,o=0,s=n;o<s.length;o++)if(r=s[o],e.constructor.name===r)return!0;return!1}var DataStructure=/** @class */function(n){function e(e,t){void 0===t&&(t={});var r=n.call(this,t)||this;return r.typeMap=r.convert(e.getTypeMap()),r}return __extends$1(e,n),e.prototype.convert=function(n){var d=this,t=Object.keys(n).filter(function(e){var t=n[e];return!(d.isFilteredEntity(t)||d.isBaseEntity(t))}).reduce(function(e,t){return e[t]=n[t],e},{}),l=mapToArray(t).reduce(function(n,e){var t=new Type(e.name);return n[e.name]=t,n},{});return mapToArray(l).map(function(a){var e=t[a.name].getFields();Object.keys(e).map(function(t){var o=e[t],n=new Field;n.name=o.name,n.typeLabel=d.getFieldLabel(o.type),n.typeLabel&&"undefined"!==n.typeLabel||(n.typeLabel=d.getFieldLabel(o.type));var r=d.getNestedType(o.type).name,i=l[r];n.type=i||r,a.addField(n)},{})}),l},e.prototype.isFilteredEntity=function(t){return-1<filteredTypes.indexOf(t.name)},e.prototype.isBaseEntity=function(t){return t.name.startsWith("__")||-1<baseEntities.indexOf(t.name)||instanceOf(["GraphQLEnumType","GraphQLInputObjectType","GraphQLScalarType","GraphQLUnionType"],t)||"Mutation"===t.name},e.prototype.getFieldLabel=function(t){return"GraphQLList"===t.constructor.name?"["+this.getFieldLabel(t.ofType)+"]":"GraphQLNonNull"===t.constructor.name?this.getFieldLabel(t.ofType)+"!":""+t.name},e.prototype.getNestedType=function(t){return Object.keys(t).includes("name")?t:this.getNestedType(t.ofType)},e.prototype.isRelatedType=function(n,r){var t=this,o=n.getFields(),e=Object.keys(o).find(function(n){var e=t.getNestedType(o[n].type);return e.name===r.name})||!1;return e},e}(BirdseyeDataStructure),DataStructure$1=/** @class */function(n){function e(e,t){void 0===t&&(t={});var r=n.call(this,t)||this;return r.typeMap=r.convert(e.types),r}return __extends$1(e,n),e.prototype.convert=function(n){var s=this,r=arrayToMap(n,function(t){return t.name}),t=n.filter(function(t){return!s.isBaseEntity(t)}).reduce(function(n,e){return n[e.name]=r[e.name],n},{}),d=mapToArray(t).reduce(function(n,e){var t=new Type(e.name);return n[e.name]=t,n},{});return mapToArray(d).map(function(i){var e=t[i.name].fields;e.map(function(e){var t=new Field;t.name=e.name,t.typeLabel=s.getFieldLabel(e.type),t.typeLabel&&"undefined"!==t.typeLabel||(t.typeLabel=s.getFieldLabel(e.type));var o=s.getNestedType(e.type).name;o||console.log(o,e.type);var n=d[o];t.type=n||o,i.addField(t)},{})}),d},e.prototype.isBaseEntity=function(t){return["SCALAR","UNION","ENUM","INPUT_OBJECT"].includes(t.kind)||t.name.startsWith("__")||"Mutation"===t.name},e.prototype.getFieldLabel=function(t){return"LIST"===t.kind?"["+this.getFieldLabel(t.ofType)+"]":"NON_NULL"===t.kind?this.getFieldLabel(t.ofType)+"!":""+t.name},e.prototype.getNestedType=function(t){return Object.keys(t).includes("name")&&t.name?t:this.getNestedType(t.ofType)},e}(BirdseyeDataStructure);function injectCustomRouter(n){var _=Math.floor,o=n.g;n.routers.manhattan=function(ne,e,i,O){// HELPER CLASSES //
// Map of obstacles
// Helper structure to identify whether a point lies inside an obstacle.
function n(t){this.map={},this.options=t,this.mapGridSize=100}// Sorted Set
// Set of items sorted by given value.
function t(){this.items=[],this.hash={},this.values={},this.OPEN=1,this.CLOSE=2}// HELPERS //
// return source bbox
function r(n,e){// expand by padding box
return e&&e.paddingBox?n.sourceBBox.clone().moveAndExpand(e.paddingBox):n.sourceBBox.clone()}// return target bbox
function s(n,e){// expand by padding box
return e&&e.paddingBox?n.targetBBox.clone().moveAndExpand(e.paddingBox):n.targetBBox.clone()}// return source anchor
function re(n,e){if(n.sourceAnchor)return n.sourceAnchor;// fallback: center of bbox
var t=r(n,e);return t.center()}// return target anchor
function d(n,e){if(n.targetAnchor)return n.targetAnchor;// fallback: center of bbox
var t=s(n,e);return t.center();// default
}// returns a direction index from start point to end point
// corrects for grid deformation between start and end
function o(e,t,o,i,n){var r=360/o,a=e.theta(c(e,t,i,n)),s=ne.normalizeAngle(a+r/2);return r*_(s/r)}// helper function for getDirectionAngle()
// corrects for grid deformation
// (if a point is one grid steps away from another in both dimensions,
// it is considered to be 45 degrees away, even if the real angle is different)
// this causes visible angle discrepancies if `opt.step` is much larger than `paper.gridSize`
function c(e,t,o,a){var i=a.step,n=t.x-e.x,r=t.y-e.y,d=n/o.x,s=r/o.y;return new ne.Point(e.x+d*i,e.y+s*i)}// return the change in direction between two direction angles
function p(n,e){var t=x(n-e);return 180<t?360-t:t}// fix direction offsets according to current grid
function l(n,r,e){var t=e.step;O.toArray(e.directions).forEach(function(n){n.gridOffsetX=n.offsetX/t*r.x,n.gridOffsetY=n.offsetY/t*r.y})}// get grid size in x and y dimensions, adapted to source and target positions
function u(n,e,t){return{source:e.clone(),x:a(t.x-e.x,n),y:a(t.y-e.y,n)}}// helper function for getGrid()
function a(n,e){var t=Math.round;// return step if diff = 0
if(!n)return e;var r=x(n),o=t(r/e);// return absDiff if less than one step apart
return o?e+(r-o*e)/o:r;// otherwise, return corrected step
}// return a clone of point snapped to grid
function ie(e,t){var r=t.source,o=ne.snapToGrid(e.x-r.x,t.x)+r.x,i=ne.snapToGrid(e.y-r.y,t.y)+r.y;return new ne.Point(o,i)}// round the point to opt.precision
function b(n,e){return n?n.round(e.precision):n}// return a string representing the point
// string is rounded to nearest int in both dimensions
function h(t){return t.clone().round().toString()}// return a normalized vector from given point
// used to determine the direction of a difference of two points
function m(e){return new ne.Point(0===e.x?0:x(e.x)/e.x,0===e.y?0:x(e.y)/e.y)}// PATHFINDING //
// reconstructs a route by concatenating points with their parents
function g(u,e,t,o,a,i){for(var n,_=[],p=m(a.difference(t)),f=h(t),y=u[f];y;){n=b(e[f],i);var v=m(n.difference(b(y.clone(),i)));v.equals(p)||(_.unshift(n),p=v),f=h(y),y=u[f]}var c=b(e[f],i),g=m(c.difference(o));return g.equals(p)||_.unshift(c),_}// heuristic method to determine the distance between two points
function y(i,e){for(var t,s=1/0,d=0,p=e.length;d<p;d++)t=i.manhattanDistance(e[d]),t<s&&(s=t);return s}// find points around the bbox taking given directions into account
// lines are drawn from anchor in given directions, intersections recorded
// if anchor is outside bbox, only those directions that intersect get a rect point
// the anchor itself is returned as rect point (representing some directions)
// (since those directions are unobstructed by the bbox)
function L(e,t,n,o,r){var i=r.directionMap,a=b(ie(e,o),r),s=b(ie(t.center(),o),r),p=a.difference(s),d=O.isObject(i)?Object.keys(i):[],l=O.toArray(n),c=d.reduce(function(s,c){if(l.includes(c)){for(var n,h=i[c],g=new ne.Point(a.x+h.x*(x(p.x)+t.width),a.y+h.y*(x(p.y)+t.height)),_=new ne.Line(e,g),u=_.intersect(t)||[],m=u.length,f=null,y=0;y<m;y++){var T=u[y],O=a.squaredDistance(T);(void 0===n||O>n)&&(n=O,f=ie(T,o))}var L=b(f,r);// if an intersection was found in this direction, it is our rectPoint
L&&(t.containsPoint(L)&&b(L.offset(h.x*o.x,h.y*o.y),r),s.push(L))}return s},[]);return t.containsPoint(a)||c.push(a),c}// finds the route between two points/rectangles (`from`, `to`) implementing A* algorithm
// rectangles get rect points assigned by getRectPoints()
function S(e,n,i,a){// Get grid for this route.
var r,c;r=e instanceof ne.Rect?re(this,a).clone():e.clone(),c=n instanceof ne.Rect?d(this,a).clone():n.clone();var m,x,k,w,P=u(a.step,r,c);// Get pathfinding points.
// Check that there is an accessible route point on both sides.
// Otherwise, use fallbackRoute().
if(e instanceof ne.Rect?(m=b(ie(r,P),a