diff options
author | Ulrich-Matthias Schäfer <ulima.ums@googlemail.com> | 2018-11-05 15:12:58 +0100 |
---|---|---|
committer | Ulrich-Matthias Schäfer <ulima.ums@googlemail.com> | 2018-11-05 15:12:58 +0100 |
commit | 4049e2e6361d5ed9120f1edd02ef96ecc138fa6d (patch) | |
tree | eeaee230519f755a6d8bd655e84fb08335da8bbd | |
parent | edc9454ddf9a0fc29a81713b98e15ddfded04bf4 (diff) | |
download | svg.js-4049e2e6361d5ed9120f1edd02ef96ecc138fa6d.tar.gz svg.js-4049e2e6361d5ed9120f1edd02ef96ecc138fa6d.zip |
rework of classes, make events on every object possible
-rw-r--r-- | dirty.html | 3 | ||||
-rw-r--r-- | dist/svg.js | 1653 | ||||
-rw-r--r-- | dist/svg.min.js | 2 | ||||
-rw-r--r-- | spec/spec/container.js | 6 | ||||
-rw-r--r-- | src/Bare.js | 4 | ||||
-rw-r--r-- | src/Box.js | 1 | ||||
-rw-r--r-- | src/Container.js | 28 | ||||
-rw-r--r-- | src/Dom.js | 237 | ||||
-rw-r--r-- | src/Element.js | 232 | ||||
-rw-r--r-- | src/EventTarget.js | 31 | ||||
-rw-r--r-- | src/HtmlNode.js | 34 | ||||
-rw-r--r-- | src/Parent.js | 169 | ||||
-rw-r--r-- | src/Runner.js | 15 | ||||
-rw-r--r-- | src/Shape.js | 4 | ||||
-rw-r--r-- | src/Text.js | 4 | ||||
-rw-r--r-- | src/Tspan.js | 5 | ||||
-rw-r--r-- | src/arrange.js | 2 | ||||
-rw-r--r-- | src/attr.js | 4 | ||||
-rw-r--r-- | src/classHandling.js | 44 | ||||
-rw-r--r-- | src/classes.js | 3 | ||||
-rw-r--r-- | src/css.js | 2 | ||||
-rw-r--r-- | src/data.js | 2 | ||||
-rw-r--r-- | src/elemnts-svg.js | 4 | ||||
-rw-r--r-- | src/event.js | 28 | ||||
-rw-r--r-- | src/memory.js | 2 | ||||
-rw-r--r-- | src/selector.js | 2 | ||||
-rw-r--r-- | src/sugar.js | 7 | ||||
-rw-r--r-- | src/svg.js | 13 |
28 files changed, 1286 insertions, 1255 deletions
@@ -267,6 +267,9 @@ let moon = canvas.circle(50).center(1200, 300).attr({fill: '#ffa'}) earth.animate(10000).loop().ease('-') .transform({rotate: 360, origin: [500, 300]}, true) .transform({rotate: 720, origin: 'center'}, true) + .on('step', (e) => { + // console.log(e) + }) moon.animate(10000).loop().ease('-') .transform({rotate: 360, origin: [500, 300]}, true) diff --git a/dist/svg.js b/dist/svg.js index ba5a1d8..1d465b9 100644 --- a/dist/svg.js +++ b/dist/svg.js @@ -669,22 +669,32 @@ var SVG = (function () { var listenerId = 0; + function getEvents(node) { + var n = makeInstance(node).getEventHolder(); + if (!n.events) n.events = {}; + return n.events; + } + function getEventTarget(node) { - return typeof node.getEventTarget === 'function' ? node.getEventTarget() : node; + return makeInstance(node).getEventTarget(); + } + + function clearEvents(node) { + var n = makeInstance(node).getEventHolder(); + if (n.events) n.events = {}; } // Add event binder in the SVG namespace function on(node, events, listener, binding, options) { var l = listener.bind(binding || node); + var bag = getEvents(node); var n = getEventTarget(node); // events can be an array of events or a string of events events = Array.isArray(events) ? events : events.split(delimiter); // ensure instance object for nodes which are not adopted - - n.instance = n.instance || { - events: {} // pull event handlers from the element - - }; - var bag = n.instance.events; // add id to listener + // n.instance = n.instance || {events: {}} + // pull event handlers from the element + // var bag = n.instance.events + // add id to listener if (!listener._svgjsListenerId) { listener._svgjsListenerId = ++listenerId; @@ -704,18 +714,19 @@ var SVG = (function () { } // Add event unbinder in the SVG namespace function off(node, events, listener, options) { + var bag = getEvents(node); var n = getEventTarget(node); // we cannot remove an event if its not an svg.js instance - - if (!n.instance) return; // listener can be a function or a number + // if (!n.instance) return + // listener can be a function or a number if (typeof listener === 'function') { listener = listener._svgjsListenerId; if (!listener) return; } // pull event handlers from the element + // var bag = n.instance.events + // events can be an array of events or a string or undefined - var bag = n.instance.events; // events can be an array of events or a string or undefined - events = Array.isArray(events) ? events : (events || '').split(delimiter); events.forEach(function (event) { var ev = event && event.split('.')[0]; @@ -762,7 +773,7 @@ var SVG = (function () { off(n, event); } - n.instance.events = {}; + clearEvents(node); } }); } @@ -796,17 +807,22 @@ var SVG = (function () { function EventTarget() { var _this; - var node = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, + _ref$events = _ref.events, + events = _ref$events === void 0 ? {} : _ref$events; _classCallCheck(this, EventTarget); _this = _possibleConstructorReturn(this, _getPrototypeOf(EventTarget).call(this)); - _this.events = node.events || {}; + _this.events = events; return _this; - } // Bind given event to listener - + } _createClass(EventTarget, [{ + key: "addEventListener", + value: function addEventListener() {} // Bind given event to listener + + }, { key: "on", value: function on$$1(event, listener, binding, options) { on(this, event, listener, binding, options); @@ -825,6 +841,21 @@ var SVG = (function () { key: "dispatch", value: function dispatch$$1(event, data) { return dispatch(this, event, data); + } + }, { + key: "dispatchEvent", + value: function dispatchEvent(event) { + var bag = this.getEventHolder().events; + if (!bag) return true; + var events = bag[event.type]; + + for (var i in events) { + for (var j in events[i]) { + events[i][j](event); + } + } + + return !event.defaultPrevented; } // Fire given event }, { @@ -833,6 +864,19 @@ var SVG = (function () { this.dispatch(event, data); return this; } + }, { + key: "getEventHolder", + value: function getEventHolder() { + return this; + } + }, { + key: "getEventTarget", + value: function getEventTarget() { + return this; + } + }, { + key: "removeEventListener", + value: function removeEventListener() {} }]); return EventTarget; @@ -858,6 +902,307 @@ var SVG = (function () { // // registerConstructor('EventTarget', setup) + // Map function + function map(array, block) { + var i; + var il = array.length; + var result = []; + + for (i = 0; i < il; i++) { + result.push(block(array[i])); + } + + return result; + } // Filter function + + function filter(array, block) { + var i; + var il = array.length; + var result = []; + + for (i = 0; i < il; i++) { + if (block(array[i])) { + result.push(array[i]); + } + } + + return result; + } // Degrees to radians + + function radians(d) { + return d % 360 * Math.PI / 180; + } // Radians to degrees + + function degrees(r) { + return r * 180 / Math.PI % 360; + } + function filterSVGElements(nodes) { + return this.filter(nodes, function (el) { + return el instanceof window.SVGElement; + }); + } + + var utils = /*#__PURE__*/Object.freeze({ + map: map, + filter: filter, + radians: radians, + degrees: degrees, + filterSVGElements: filterSVGElements + }); + + function noop() {} // Default animation values + + var timeline = { + duration: 400, + ease: '>', + delay: 0 // Default attribute values + + }; + var attrs = { + // fill and stroke + 'fill-opacity': 1, + 'stroke-opacity': 1, + 'stroke-width': 0, + 'stroke-linejoin': 'miter', + 'stroke-linecap': 'butt', + fill: '#000000', + stroke: '#000000', + opacity: 1, + // position + x: 0, + y: 0, + cx: 0, + cy: 0, + // size + width: 0, + height: 0, + // radius + r: 0, + rx: 0, + ry: 0, + // gradient + offset: 0, + 'stop-opacity': 1, + 'stop-color': '#000000', + // text + 'font-size': 16, + 'font-family': 'Helvetica, Arial, sans-serif', + 'text-anchor': 'start' + }; + + var defaults = /*#__PURE__*/Object.freeze({ + noop: noop, + timeline: timeline, + attrs: attrs + }); + + var Color = + /*#__PURE__*/ + function () { + function Color() { + _classCallCheck(this, Color); + + this.init.apply(this, arguments); + } + + _createClass(Color, [{ + key: "init", + value: function init(color, g, b) { + var match; // initialize defaults + + this.r = 0; + this.g = 0; + this.b = 0; + if (!color) return; // parse color + + if (typeof color === 'string') { + if (isRgb.test(color)) { + // get rgb values + match = rgb.exec(color.replace(whitespace, '')); // parse numeric values + + this.r = parseInt(match[1]); + this.g = parseInt(match[2]); + this.b = parseInt(match[3]); + } else if (isHex.test(color)) { + // get hex values + match = hex.exec(fullHex(color)); // parse numeric values + + this.r = parseInt(match[1], 16); + this.g = parseInt(match[2], 16); + this.b = parseInt(match[3], 16); + } + } else if (Array.isArray(color)) { + this.r = color[0]; + this.g = color[1]; + this.b = color[2]; + } else if (_typeof(color) === 'object') { + this.r = color.r; + this.g = color.g; + this.b = color.b; + } else if (arguments.length === 3) { + this.r = color; + this.g = g; + this.b = b; + } + } // Default to hex conversion + + }, { + key: "toString", + value: function toString() { + return this.toHex(); + } + }, { + key: "toArray", + value: function toArray() { + return [this.r, this.g, this.b]; + } // Build hex value + + }, { + key: "toHex", + value: function toHex() { + return '#' + compToHex(Math.round(this.r)) + compToHex(Math.round(this.g)) + compToHex(Math.round(this.b)); + } // Build rgb value + + }, { + key: "toRgb", + value: function toRgb() { + return 'rgb(' + [this.r, this.g, this.b].join() + ')'; + } // Calculate true brightness + + }, { + key: "brightness", + value: function brightness() { + return this.r / 255 * 0.30 + this.g / 255 * 0.59 + this.b / 255 * 0.11; + } // Testers + // Test if given value is a color string + + }], [{ + key: "test", + value: function test(color) { + color += ''; + return isHex.test(color) || isRgb.test(color); + } // Test if given value is a rgb object + + }, { + key: "isRgb", + value: function isRgb$$1(color) { + return color && typeof color.r === 'number' && typeof color.g === 'number' && typeof color.b === 'number'; + } // Test if given value is a color + + }, { + key: "isColor", + value: function isColor(color) { + return this.isRgb(color) || this.test(color); + } + }]); + + return Color; + }(); + + var subClassArray = function () { + try { + // try es6 subclassing + return Function('name', 'baseClass', '_constructor', ['baseClass = baseClass || Array', 'return {', '[name]: class extends baseClass {', 'constructor (...args) {', 'super(...args)', '_constructor && _constructor.apply(this, args)', '}', '}', '}[name]'].join('\n')); + } catch (e) { + // Use es5 approach + return function (name) { + var baseClass = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Array; + + var _constructor = arguments.length > 2 ? arguments[2] : undefined; + + var Arr = function Arr() { + baseClass.apply(this, arguments); + _constructor && _constructor.apply(this, arguments); + }; + + Arr.prototype = Object.create(baseClass.prototype); + Arr.prototype.constructor = Arr; + return Arr; + }; + } + }(); + + var SVGArray = subClassArray('SVGArray', Array, function () { + this.init.apply(this, arguments); + }); + extend(SVGArray, { + init: function init() { + //this.splice(0, this.length) + this.length = 0; + this.push.apply(this, _toConsumableArray(this.parse.apply(this, arguments))); + }, + toArray: function toArray() { + // const ret = [] + // ret.push(...this) + // return ret + return Array.prototype.concat.apply([], this); + }, + toString: function toString() { + return this.join(' '); + }, + // Flattens the array if needed + valueOf: function valueOf() { + var ret = []; + ret.push.apply(ret, _toConsumableArray(this)); + return ret; // return this.toArray() + }, + // Parse whitespace separated string + parse: function parse() { + var array = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; + //array = array.valueOf() + // If already is an array, no need to parse it + if (array instanceof Array) return array; + return array.trim().split(delimiter).map(parseFloat); + }, + clone: function clone() { + return new this.constructor(this); + }, + toSet: function toSet() { + return new Set(this); + } + }); // export default class SVGArray extends BaseArray { + // constructor (...args) { + // super() + // this.init(...args) + // } + // + // init (array, fallback = []) { + // //this.splice(0, this.length) + // this.length = 0 + // this.push(...this.parse(array || fallback)) + // } + // + // toArray () { + // return [].concat(this) + // } + // + // toString () { + // return this.join(' ') + // } + // + // valueOf () { + // return this.toArray() + // } + // + // // Parse whitespace separated string + // parse (array) { + // array = array.valueOf() + // + // // if already is an array, no need to parse it + // if (Array.isArray(array)) return array + // + // return array.trim().split(delimiter).map(parseFloat) + // } + // + // clone () { + // return new this.constructor(this) + // } + // + // toSet () { + // return new Set(this) + // } + // } + var SVGNumber = /*#__PURE__*/ function () { @@ -956,88 +1301,153 @@ var SVG = (function () { return SVGNumber; }(); - var Doc = getClass(root); //export const name = 'Element' + // Set svg element attribute - var Element = - /*#__PURE__*/ - function (_EventTarget) { - _inherits(Element, _EventTarget); + function attr(attr, val, ns) { + // act as full getter + if (attr == null) { + // get an object of attributes + attr = {}; + val = this.node.attributes; + var _iteratorNormalCompletion = true; + var _didIteratorError = false; + var _iteratorError = undefined; - function Element(node) { - var _this; + try { + for (var _iterator = val[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { + var node = _step.value; + attr[node.nodeName] = isNumber.test(node.nodeValue) ? parseFloat(node.nodeValue) : node.nodeValue; + } + } catch (err) { + _didIteratorError = true; + _iteratorError = err; + } finally { + try { + if (!_iteratorNormalCompletion && _iterator.return != null) { + _iterator.return(); + } + } finally { + if (_didIteratorError) { + throw _iteratorError; + } + } + } - _classCallCheck(this, Element); + return attr; + } else if (Array.isArray(attr)) ; else if (_typeof(attr) === 'object') { + // apply every attribute individually if an object is passed + for (val in attr) { + this.attr(val, attr[val]); + } + } else if (val === null) { + // remove value + this.node.removeAttribute(attr); + } else if (val == null) { + // act as a getter if the first and only argument is not an object + val = this.node.getAttribute(attr); + return val == null ? attrs[attr] // FIXME: do we need to return defaults? + : isNumber.test(val) ? parseFloat(val) : val; + } else { + // convert image fill and stroke to patterns + if (attr === 'fill' || attr === 'stroke') { + if (isImage.test(val)) { + val = this.doc().defs().image(val); + } + } // FIXME: This is fine, but what about the lines above? + // How does attr know about image()? - _this = _possibleConstructorReturn(this, _getPrototypeOf(Element).call(this)); // initialize data object - _this.dom = {}; // create circular reference + while (typeof val.attrHook == 'function') { + val = val.attrHook(this, attr); + } // ensure correct numeric values (also accepts NaN and Infinity) - _this.node = node; - _this.type = node.nodeName; - _this.node.instance = _assertThisInitialized(_assertThisInitialized(_this)); - if (node.hasAttribute('svgjs:data')) { - // pull svgjs data from the dom (getAttributeNS doesn't work in html5) - _this.setData(JSON.parse(node.getAttribute('svgjs:data')) || {}); + if (typeof val === 'number') { + val = new SVGNumber(val); + } else if (Color.isColor(val)) { + // ensure full hex color + val = new Color(val); + } else if (val.constructor === Array) { + // Check for plain arrays and parse array values + val = new SVGArray(val); + } // if the passed attribute is leading... + + + if (attr === 'leading') { + // ... call the leading method instead + if (this.leading) { + this.leading(val); + } + } else { + // set given attribute on node + typeof ns === 'string' ? this.node.setAttributeNS(ns, attr, val.toString()) : this.node.setAttribute(attr, val.toString()); + } // rebuild if required + + + if (this.rebuild && (attr === 'font-size' || attr === 'x')) { + this.rebuild(); } + } - return _this; - } // Move over x-axis + return this; + } //registerMethods('Element', {attr}) + var Dom = + /*#__PURE__*/ + function (_EventTarget) { + _inherits(Dom, _EventTarget); - _createClass(Element, [{ - key: "x", - value: function x(_x) { - return this.attr('x', _x); - } // Move over y-axis + function Dom(node) { + var _this; - }, { - key: "y", - value: function y(_y) { - return this.attr('y', _y); - } // Move by center over x-axis + _classCallCheck(this, Dom); - }, { - key: "cx", - value: function cx(x) { - return x == null ? this.x() + this.width() / 2 : this.x(x - this.width() / 2); - } // Move by center over y-axis + _this = _possibleConstructorReturn(this, _getPrototypeOf(Dom).call(this, node)); + _this.node = node; + _this.type = node.nodeName; + return _this; + } // Add given element at a position - }, { - key: "cy", - value: function cy(y) { - return y == null ? this.y() + this.height() / 2 : this.y(y - this.height() / 2); - } // Move element to given x and y values - }, { - key: "move", - value: function move(x, y) { - return this.x(x).y(y); - } // Move element by its center + _createClass(Dom, [{ + key: "add", + value: function add(element, i) { + element = makeInstance(element); - }, { - key: "center", - value: function center(x, y) { - return this.cx(x).cy(y); - } // Set width of element + if (i == null) { + this.node.appendChild(element.node); + } else if (element.node !== this.node.childNodes[i]) { + this.node.insertBefore(element.node, this.node.childNodes[i]); + } + + return this; + } // Add element to given container and return self }, { - key: "width", - value: function width(_width) { - return this.attr('width', _width); - } // Set height of element + key: "addTo", + value: function addTo(parent) { + return makeInstance(parent).put(this); + } // Returns all child elements }, { - key: "height", - value: function height(_height) { - return this.attr('height', _height); - } // Set element size to given width and height + key: "children", + value: function children() { + return map(this.node.children, function (node) { + return adopt(node); + }); + } // Remove all elements in this container }, { - key: "size", - value: function size(width, height) { - var p = proportionalSize(this, width, height); - return this.width(new SVGNumber(p.width)).height(new SVGNumber(p.height)); + key: "clear", + value: function clear() { + // remove children + while (this.node.hasChildNodes()) { + this.node.removeChild(this.node.lastChild); + } // remove defs reference + + + delete this._defs; + return this; } // Clone element }, { @@ -1048,37 +1458,54 @@ var SVG = (function () { var clone = assignNewId(this.node.cloneNode(true)); // insert the clone in the given parent or after myself - if (parent) parent.add(clone);else this.after(clone); + if (parent) parent.add(clone); // FIXME: after might not be available here + else this.after(clone); return clone; - } // Remove element + } // Iterates over all children and invokes a given block }, { - key: "remove", - value: function remove() { - if (this.parent()) { - this.parent().removeElement(this); + key: "each", + value: function each(block, deep) { + var children = this.children(); + var i, il; + + for (i = 0, il = children.length; i < il; i++) { + block.apply(children[i], [i, children]); + + if (deep) { + children[i].each(block, deep); + } } return this; - } // Replace element + } // Get first child }, { - key: "replace", - value: function replace(element) { - this.after(element).remove(); - return element; - } // Add element to given container and return self + key: "first", + value: function first() { + return adopt(this.node.firstChild); + } // Get a element at the given index }, { - key: "addTo", - value: function addTo(parent) { - return makeInstance(parent).put(this); - } // Add element to given container and return container + key: "get", + value: function get(i) { + return adopt(this.node.childNodes[i]); + } + }, { + key: "getEventHolder", + value: function getEventHolder() { + return this.node; + } + }, { + key: "getEventTarget", + value: function getEventTarget() { + return this.node; + } // Checks if the given element is a child }, { - key: "putIn", - value: function putIn(parent) { - return makeInstance(parent).add(this); + key: "has", + value: function has(element) { + return this.index(element) >= 0; } // Get / set id }, { @@ -1091,69 +1518,30 @@ var SVG = (function () { return this.attr('id', _id); - } // Checks whether the given point inside the bounding box of the element - - }, { - key: "inside", - value: function inside(x, y) { - var box = this.bbox(); - return x > box.x && y > box.y && x < box.x + box.width && y < box.y + box.height; - } // Return id on string conversion - - }, { - key: "toString", - value: function toString() { - return this.id(); - } // Return array of classes on the node - - }, { - key: "classes", - value: function classes() { - var attr = this.attr('class'); - return attr == null ? [] : attr.trim().split(delimiter); - } // Return true if class exists on the node, false otherwise - - }, { - key: "hasClass", - value: function hasClass(name) { - return this.classes().indexOf(name) !== -1; - } // Add class to the node + } // Gets index of given element }, { - key: "addClass", - value: function addClass(name) { - if (!this.hasClass(name)) { - var array = this.classes(); - array.push(name); - this.attr('class', array.join(' ')); - } - - return this; - } // Remove class from the node + key: "index", + value: function index(element) { + return [].slice.call(this.node.childNodes).indexOf(element.node); + } // Get the last child }, { - key: "removeClass", - value: function removeClass(name) { - if (this.hasClass(name)) { - this.attr('class', this.classes().filter(function (c) { - return c !== name; - }).join(' ')); - } - - return this; - } // Toggle the presence of a class on the node + key: "last", + value: function last() { + return adopt(this.node.lastChild); + } // matches the element vs a css selector }, { - key: "toggleClass", - value: function toggleClass(name) { - return this.hasClass(name) ? this.removeClass(name) : this.addClass(name); - } // Get referenced element form attribute value + key: "matches", + value: function matches(selector) { + return matcher(this.node, selector); + } // Returns the svg node to call native svg methods on it }, { - key: "reference", - value: function reference$$1(attr) { - var id = idFromReference(this.attr(attr)); - return id ? makeInstance(id) : null; + key: "native", + value: function native() { + return this.node; } // Returns the parent element instance }, { @@ -1170,313 +1558,250 @@ var SVG = (function () { if (typeof type === 'string' ? parent.matches(type) : parent instanceof type) return parent; parent = adopt(parent.node.parentNode); } - } // Get parent document + } // Basically does the same as `add()` but returns the added element instead }, { - key: "doc", - value: function doc() { - var p = this.parent(Doc); - return p && p.doc(); - } // Get defs + key: "put", + value: function put(element, i) { + this.add(element, i); + return element; + } // Add element to given container and return container }, { - key: "defs", - value: function defs() { - return this.doc().defs(); - } // return array of all ancestors of given type up to the root svg + key: "putIn", + value: function putIn(parent) { + return makeInstance(parent).add(this); + } // Remove element }, { - key: "parents", - value: function parents(type) { - var parents = []; - var parent = this; + key: "remove", + value: function remove() { + if (this.parent()) { + this.parent().removeElement(this); + } - do { - parent = parent.parent(type); - if (!parent || parent instanceof getClass('HtmlNode')) break; - parents.push(parent); - } while (parent.parent); + return this; + } // Remove a given child - return parents; - } // matches the element vs a css selector + }, { + key: "removeElement", + value: function removeElement(element) { + this.node.removeChild(element.node); + return this; + } // Replace element }, { - key: "matches", - value: function matches(selector) { - return matcher(this.node, selector); - } // Returns the svg node to call native svg methods on it + key: "replace", + value: function replace(element) { + // FIXME: after might not be available here + this.after(element).remove(); + return element; + } // Return id on string conversion }, { - key: "native", - value: function native() { - return this.node; + key: "toString", + value: function toString() { + return this.id(); } // Import raw svg }, { key: "svg", - value: function svg() { - // write svgjs data to the dom - this.writeDataToDom(); - return this.node.outerHTML; - } // write svgjs data to the dom + value: function svg(_svg) { + var well, len; // act as a setter if svg is given - }, { - key: "writeDataToDom", - value: function writeDataToDom() { - // remove previously set data - this.node.removeAttribute('svgjs:data'); + if (_svg) { + // create temporary holder + well = document.createElementNS(ns, 'svg'); // dump raw svg - if (Object.keys(this.dom).length) { - this.node.setAttribute('svgjs:data', JSON.stringify(this.dom)); // see #428 + well.innerHTML = _svg; // transplant nodes + + for (len = well.children.length; len--;) { + this.node.appendChild(well.firstElementChild); + } // otherwise act as a getter + + } else { + // write svgjs data to the dom + this.writeDataToDom(); + return this.node.outerHTML; } return this; - } // set given data to the elements data property + } // write svgjs data to the dom }, { - key: "setData", - value: function setData(o) { - this.dom = o; + key: "writeDataToDom", + value: function writeDataToDom() { + // dump variables recursively + this.each(function () { + this.writeDataToDom(); + }); return this; } - }, { - key: "getEventTarget", - value: function getEventTarget() { - return this.node; - } }]); - return Element; - }(EventTarget); // registerMethods('Element', { - - // Map function - function map(array, block) { - var i; - var il = array.length; - var result = []; - - for (i = 0; i < il; i++) { - result.push(block(array[i])); - } + return Dom; + }(EventTarget); + extend(Dom, { + attr: attr + }); - return result; - } // Filter function + var Doc = getClass(root); - function filter(array, block) { - var i; - var il = array.length; - var result = []; + var Element = + /*#__PURE__*/ + function (_Dom) { + _inherits(Element, _Dom); - for (i = 0; i < il; i++) { - if (block(array[i])) { - result.push(array[i]); - } - } + function Element(node) { + var _this; - return result; - } // Degrees to radians + _classCallCheck(this, Element); - function radians(d) { - return d % 360 * Math.PI / 180; - } // Radians to degrees + _this = _possibleConstructorReturn(this, _getPrototypeOf(Element).call(this, node)); // initialize data object - function degrees(r) { - return r * 180 / Math.PI % 360; - } - function filterSVGElements(nodes) { - return this.filter(nodes, function (el) { - return el instanceof window.SVGElement; - }); - } + _this.dom = {}; // create circular reference - var utils = /*#__PURE__*/Object.freeze({ - map: map, - filter: filter, - radians: radians, - degrees: degrees, - filterSVGElements: filterSVGElements - }); + _this.node.instance = _assertThisInitialized(_assertThisInitialized(_this)); - var Parent = - /*#__PURE__*/ - function (_Element) { - _inherits(Parent, _Element); + if (node.hasAttribute('svgjs:data')) { + // pull svgjs data from the dom (getAttributeNS doesn't work in html5) + _this.setData(JSON.parse(node.getAttribute('svgjs:data')) || {}); + } - function Parent() { - _classCallCheck(this, Parent); + return _this; + } // Move element by its center - return _possibleConstructorReturn(this, _getPrototypeOf(Parent).apply(this, arguments)); - } - _createClass(Parent, [{ - key: "children", - // Returns all child elements - value: function children() { - return map(this.node.children, function (node) { - return adopt(node); - }); - } // Add given element at a position + _createClass(Element, [{ + key: "center", + value: function center(x, y) { + return this.cx(x).cy(y); + } // Move by center over x-axis }, { - key: "add", - value: function add(element, i) { - element = makeInstance(element); - - if (i == null) { - this.node.appendChild(element.node); - } else if (element.node !== this.node.childNodes[i]) { - this.node.insertBefore(element.node, this.node.childNodes[i]); - } - - return this; - } // Basically does the same as `add()` but returns the added element instead + key: "cx", + value: function cx(x) { + return x == null ? this.x() + this.width() / 2 : this.x(x - this.width() / 2); + } // Move by center over y-axis }, { - key: "put", - value: function put(element, i) { - this.add(element, i); - return element.instance || element; - } // Checks if the given element is a child + key: "cy", + value: function cy(y) { + return y == null ? this.y() + this.height() / 2 : this.y(y - this.height() / 2); + } // Get defs }, { - key: "has", - value: function has(element) { - return this.index(element) >= 0; - } // Gets index of given element + key: "defs", + value: function defs() { + return this.doc().defs(); + } // Get parent document }, { - key: "index", - value: function index(element) { - return [].slice.call(this.node.childNodes).indexOf(element.node); - } // Get a element at the given index - + key: "doc", + value: function doc() { + var p = this.parent(Doc); + return p && p.doc(); + } }, { - key: "get", - value: function get(i) { - return adopt(this.node.childNodes[i]); - } // Get first child + key: "getEventHolder", + value: function getEventHolder() { + return this; + } // Set height of element }, { - key: "first", - value: function first() { - return adopt(this.node.firstChild); - } // Get the last child + key: "height", + value: function height(_height) { + return this.attr('height', _height); + } // Checks whether the given point inside the bounding box of the element }, { - key: "last", - value: function last() { - return adopt(this.node.lastChild); - } // Iterates over all children and invokes a given block + key: "inside", + value: function inside(x, y) { + var box = this.bbox(); + return x > box.x && y > box.y && x < box.x + box.width && y < box.y + box.height; + } // Move element to given x and y values }, { - key: "each", - value: function each(block, deep) { - var children = this.children(); - var i, il; + key: "move", + value: function move(x, y) { + return this.x(x).y(y); + } // return array of all ancestors of given type up to the root svg - for (i = 0, il = children.length; i < il; i++) { - if (children[i] instanceof Element) { - block.apply(children[i], [i, children]); - } + }, { + key: "parents", + value: function parents(type) { + var parents = []; + var parent = this; - if (deep && children[i] instanceof Parent) { - children[i].each(block, deep); - } - } + do { + parent = parent.parent(type); + if (!parent || parent instanceof getClass('HtmlNode')) break; + parents.push(parent); + } while (parent.parent); - return this; - } // Remove a given child + return parents; + } // Get referenced element form attribute value }, { - key: "removeElement", - value: function removeElement(element) { - this.node.removeChild(element.node); - return this; - } // Remove all elements in this container + key: "reference", + value: function reference$$1(attr) { + var id = idFromReference(this.attr(attr)); + return id ? makeInstance(id) : null; + } // set given data to the elements data property }, { - key: "clear", - value: function clear() { - // remove children - while (this.node.hasChildNodes()) { - this.node.removeChild(this.node.lastChild); - } // remove defs reference - - - delete this._defs; + key: "setData", + value: function setData(o) { + this.dom = o; return this; - } // Import raw svg + } // Set element size to given width and height }, { - key: "svg", - value: function svg(_svg) { - var well, len; // act as a setter if svg is given - - if (_svg) { - // create temporary holder - well = document.createElementNS(ns, 'svg'); // dump raw svg - - well.innerHTML = _svg; // transplant nodes - - for (len = well.children.length; len--;) { - this.node.appendChild(well.firstElementChild); - } // otherwise act as a getter - - } else { - // write svgjs data to the dom - this.writeDataToDom(); - return this.node.outerHTML; - } + key: "size", + value: function size(width, height) { + var p = proportionalSize(this, width, height); + return this.width(new SVGNumber(p.width)).height(new SVGNumber(p.height)); + } // Set width of element - return this; + }, { + key: "width", + value: function width(_width) { + return this.attr('width', _width); } // write svgjs data to the dom }, { key: "writeDataToDom", value: function writeDataToDom() { - // dump variables recursively - this.each(function () { - this.writeDataToDom(); - }); // remove previously set data - + // remove previously set data this.node.removeAttribute('svgjs:data'); if (Object.keys(this.dom).length) { this.node.setAttribute('svgjs:data', JSON.stringify(this.dom)); // see #428 } - return this; - } + return _get(_getPrototypeOf(Element.prototype), "writeDataToDom", this).call(this); + } // Move over x-axis + }, { - key: "flatten", - value: function flatten(parent) { - this.each(function () { - if (this instanceof Parent) return this.flatten(parent).ungroup(parent); - return this.toParent(parent); - }); // we need this so that Doc does not get removed + key: "x", + value: function x(_x) { + return this.attr('x', _x); + } // Move over y-axis - this.node.firstElementChild || this.remove(); - return this; - } }, { - key: "ungroup", - value: function ungroup(parent) { - parent = parent || this.parent(); - this.each(function () { - return this.toParent(parent); - }); - this.remove(); - return this; + key: "y", + value: function y(_y) { + return this.attr('y', _y); } }]); - return Parent; - }(Element); // registerMethods('Container', { + return Element; + }(Dom); // registerMethods('Element', { var Shape = /*#__PURE__*/ - function (_Parent) { - _inherits(Shape, _Parent); + function (_Element) { + _inherits(Shape, _Element); function Shape() { _classCallCheck(this, Shape); @@ -1485,12 +1810,12 @@ var SVG = (function () { } return Shape; - }(Parent); + }(Element); var Container$1 = /*#__PURE__*/ - function (_Parent) { - _inherits(Container, _Parent); + function (_Element) { + _inherits(Container, _Element); function Container() { _classCallCheck(this, Container); @@ -1498,56 +1823,45 @@ var SVG = (function () { return _possibleConstructorReturn(this, _getPrototypeOf(Container).apply(this, arguments)); } + _createClass(Container, [{ + key: "flatten", + value: function flatten(parent) { + this.each(function () { + if (this instanceof Container) return this.flatten(parent).ungroup(parent); + return this.toParent(parent); + }); // we need this so that Doc does not get removed + + this.node.firstElementChild || this.remove(); + return this; + } + }, { + key: "ungroup", + value: function ungroup(parent) { + parent = parent || this.parent(); + this.each(function () { + return this.toParent(parent); + }); + this.remove(); + return this; + } + }]); + return Container; - }(Parent); + }(Element); var HtmlNode = /*#__PURE__*/ - function (_Parent) { - _inherits(HtmlNode, _Parent); - - function HtmlNode(element) { - var _this; + function (_Dom) { + _inherits(HtmlNode, _Dom); + function HtmlNode(node) { _classCallCheck(this, HtmlNode); - _this = _possibleConstructorReturn(this, _getPrototypeOf(HtmlNode).call(this, element, HtmlNode)); - _this.node = element; - return _this; + return _possibleConstructorReturn(this, _getPrototypeOf(HtmlNode).call(this, node, HtmlNode)); } - _createClass(HtmlNode, [{ - key: "add", - value: function add(element, i) { - element = makeInstance(element); - - if (element.node !== this.node.children[i]) { - this.node.insertBefore(element.node, this.node.children[i] || null); - } - - return this; - } - }, { - key: "put", - value: function put(element, i) { - this.add(element, i); - return element; - } - }, { - key: "removeElement", - value: function removeElement(element) { - this.node.removeChild(element.node); - return this; - } - }, { - key: "getEventTarget", - value: function getEventTarget() { - return this.node; - } - }]); - return HtmlNode; - }(Parent); + }(Dom); register(HtmlNode); var Defs = @@ -1848,8 +2162,8 @@ var SVG = (function () { var Bare = /*#__PURE__*/ - function (_Parent) { - _inherits(Bare, _Parent); + function (_Container) { + _inherits(Bare, _Container); function Bare(node) { _classCallCheck(this, Bare); @@ -1872,7 +2186,7 @@ var SVG = (function () { }]); return Bare; - }(Parent); + }(Container$1); register(Bare); registerMethods('Container', { // Create an element that is not described by SVG.js @@ -2014,7 +2328,7 @@ var SVG = (function () { function find$1(query) { return baseFind(query, this.node); } - registerMethods('Element', { + registerMethods('Dom', { find: find$1 }); @@ -2648,110 +2962,6 @@ var SVG = (function () { }); register(Image); - var subClassArray = function () { - try { - // try es6 subclassing - return Function('name', 'baseClass', '_constructor', ['baseClass = baseClass || Array', 'return {', '[name]: class extends baseClass {', 'constructor (...args) {', 'super(...args)', '_constructor && _constructor.apply(this, args)', '}', '}', '}[name]'].join('\n')); - } catch (e) { - // Use es5 approach - return function (name) { - var baseClass = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Array; - - var _constructor = arguments.length > 2 ? arguments[2] : undefined; - - var Arr = function Arr() { - baseClass.apply(this, arguments); - _constructor && _constructor.apply(this, arguments); - }; - - Arr.prototype = Object.create(baseClass.prototype); - Arr.prototype.constructor = Arr; - return Arr; - }; - } - }(); - - var SVGArray = subClassArray('SVGArray', Array, function () { - this.init.apply(this, arguments); - }); - extend(SVGArray, { - init: function init() { - //this.splice(0, this.length) - this.length = 0; - this.push.apply(this, _toConsumableArray(this.parse.apply(this, arguments))); - }, - toArray: function toArray() { - // const ret = [] - // ret.push(...this) - // return ret - return Array.prototype.concat.apply([], this); - }, - toString: function toString() { - return this.join(' '); - }, - // Flattens the array if needed - valueOf: function valueOf() { - var ret = []; - ret.push.apply(ret, _toConsumableArray(this)); - return ret; // return this.toArray() - }, - // Parse whitespace separated string - parse: function parse() { - var array = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; - //array = array.valueOf() - // If already is an array, no need to parse it - if (array instanceof Array) return array; - return array.trim().split(delimiter).map(parseFloat); - }, - clone: function clone() { - return new this.constructor(this); - }, - toSet: function toSet() { - return new Set(this); - } - }); // export default class SVGArray extends BaseArray { - // constructor (...args) { - // super() - // this.init(...args) - // } - // - // init (array, fallback = []) { - // //this.splice(0, this.length) - // this.length = 0 - // this.push(...this.parse(array || fallback)) - // } - // - // toArray () { - // return [].concat(this) - // } - // - // toString () { - // return this.join(' ') - // } - // - // valueOf () { - // return this.toArray() - // } - // - // // Parse whitespace separated string - // parse (array) { - // array = array.valueOf() - // - // // if already is an array, no need to parse it - // if (Array.isArray(array)) return array - // - // return array.trim().split(delimiter).map(parseFloat) - // } - // - // clone () { - // return new this.constructor(this) - // } - // - // toSet () { - // return new Set(this) - // } - // } - var PointArray = subClassArray('PointArray', SVGArray); extend(PointArray, { // Convert array to string @@ -3940,52 +4150,6 @@ var SVG = (function () { }); register(_Symbol); - function noop() {} // Default animation values - - var timeline = { - duration: 400, - ease: '>', - delay: 0 // Default attribute values - - }; - var attrs = { - // fill and stroke - 'fill-opacity': 1, - 'stroke-opacity': 1, - 'stroke-width': 0, - 'stroke-linejoin': 'miter', - 'stroke-linecap': 'butt', - fill: '#000000', - stroke: '#000000', - opacity: 1, - // position - x: 0, - y: 0, - cx: 0, - cy: 0, - // size - width: 0, - height: 0, - // radius - r: 0, - rx: 0, - ry: 0, - // gradient - offset: 0, - 'stop-opacity': 1, - 'stop-color': '#000000', - // text - 'font-size': 16, - 'font-family': 'Helvetica, Arial, sans-serif', - 'text-anchor': 'start' - }; - - var defaults = /*#__PURE__*/Object.freeze({ - noop: noop, - timeline: timeline, - attrs: attrs - }); - // Create plain text node function plain(text) { // clear if build mode is disabled @@ -4010,8 +4174,8 @@ var SVG = (function () { var Text = /*#__PURE__*/ - function (_Parent) { - _inherits(Text, _Parent); + function (_Shape) { + _inherits(Text, _Shape); // Initialize node function Text(node) { @@ -4178,7 +4342,7 @@ var SVG = (function () { }]); return Text; - }(Parent); + }(Shape); extend(Text, textable); registerMethods({ Container: { @@ -4282,8 +4446,8 @@ var SVG = (function () { var Tspan = /*#__PURE__*/ - function (_Parent) { - _inherits(Tspan, _Parent); + function (_Text) { + _inherits(Tspan, _Text); // Initialize node function Tspan(node) { @@ -4326,7 +4490,7 @@ var SVG = (function () { }]); return Tspan; - }(Parent); + }(Text); extend(Tspan, textable); registerMethods({ Tspan: { @@ -4895,109 +5059,6 @@ var SVG = (function () { } }); - var Color = - /*#__PURE__*/ - function () { - function Color() { - _classCallCheck(this, Color); - - this.init.apply(this, arguments); - } - - _createClass(Color, [{ - key: "init", - value: function init(color, g, b) { - var match; // initialize defaults - - this.r = 0; - this.g = 0; - this.b = 0; - if (!color) return; // parse color - - if (typeof color === 'string') { - if (isRgb.test(color)) { - // get rgb values - match = rgb.exec(color.replace(whitespace, '')); // parse numeric values - - this.r = parseInt(match[1]); - this.g = parseInt(match[2]); - this.b = parseInt(match[3]); - } else if (isHex.test(color)) { - // get hex values - match = hex.exec(fullHex(color)); // parse numeric values - - this.r = parseInt(match[1], 16); - this.g = parseInt(match[2], 16); - this.b = parseInt(match[3], 16); - } - } else if (Array.isArray(color)) { - this.r = color[0]; - this.g = color[1]; - this.b = color[2]; - } else if (_typeof(color) === 'object') { - this.r = color.r; - this.g = color.g; - this.b = color.b; - } else if (arguments.length === 3) { - this.r = color; - this.g = g; - this.b = b; - } - } // Default to hex conversion - - }, { - key: "toString", - value: function toString() { - return this.toHex(); - } - }, { - key: "toArray", - value: function toArray() { - return [this.r, this.g, this.b]; - } // Build hex value - - }, { - key: "toHex", - value: function toHex() { - return '#' + compToHex(Math.round(this.r)) + compToHex(Math.round(this.g)) + compToHex(Math.round(this.b)); - } // Build rgb value - - }, { - key: "toRgb", - value: function toRgb() { - return 'rgb(' + [this.r, this.g, this.b].join() + ')'; - } // Calculate true brightness - - }, { - key: "brightness", - value: function brightness() { - return this.r / 255 * 0.30 + this.g / 255 * 0.59 + this.b / 255 * 0.11; - } // Testers - // Test if given value is a color string - - }], [{ - key: "test", - value: function test(color) { - color += ''; - return isHex.test(color) || isRgb.test(color); - } // Test if given value is a rgb object - - }, { - key: "isRgb", - value: function isRgb$$1(color) { - return color && typeof color.r === 'number' && typeof color.g === 'number' && typeof color.b === 'number'; - } // Test if given value is a color - - }, { - key: "isColor", - value: function isColor(color) { - return this.isRgb(color) || this.test(color); - } - }]); - - return Color; - }(); - /***
Base Class
==========
@@ -5781,41 +5842,47 @@ var SVG = (function () { var Runner = /*#__PURE__*/ - function () { + function (_EventTarget) { + _inherits(Runner, _EventTarget); + function Runner(options) { + var _this; + _classCallCheck(this, Runner); - // Store a unique id on the runner, so that we can identify it later - this.id = Runner.id++; // Ensure a default value + _this = _possibleConstructorReturn(this, _getPrototypeOf(Runner).call(this)); // Store a unique id on the runner, so that we can identify it later + + _this.id = Runner.id++; // Ensure a default value options = options == null ? timeline.duration : options; // Ensure that we get a controller options = typeof options === 'function' ? new Controller(options) : options; // Declare all of the variables - this._element = null; - this._timeline = null; - this.done = false; - this._queue = []; // Work out the stepper and the duration + _this._element = null; + _this._timeline = null; + _this.done = false; + _this._queue = []; // Work out the stepper and the duration - this._duration = typeof options === 'number' && options; - this._isDeclarative = options instanceof Controller; - this._stepper = this._isDeclarative ? options : new Ease(); // We copy the current values from the timeline because they can change + _this._duration = typeof options === 'number' && options; + _this._isDeclarative = options instanceof Controller; + _this._stepper = _this._isDeclarative ? options : new Ease(); // We copy the current values from the timeline because they can change - this._history = {}; // Store the state of the runner + _this._history = {}; // Store the state of the runner - this.enabled = true; - this._time = 0; - this._last = 0; // Save transforms applied to this runner + _this.enabled = true; + _this._time = 0; + _this._last = 0; // Save transforms applied to this runner - this.transforms = new Matrix(); - this.transformId = 1; // Looping variables + _this.transforms = new Matrix(); + _this.transformId = 1; // Looping variables - this._haveReversed = false; - this._reverse = false; - this._loopsDone = 0; - this._swing = false; - this._wait = 0; - this._times = 1; + _this._haveReversed = false; + _this._reverse = false; + _this._loopsDone = 0; + _this._swing = false; + _this._wait = 0; + _this._times = 1; + return _this; } /*
Runner Definitions
@@ -6036,7 +6103,10 @@ var SVG = (function () { var justStarted = this._lastTime < 0 && this._time > 0; var justFinished = this._lastTime < this._time && this.time > duration; this._lastTime = this._time; - // Work out if the runner is finished set the done flag here so animations + + if (justStarted) { + this.fire('start', this); + } // Work out if the runner is finished set the done flag here so animations // know, that they are running in the last step (this is good for // transformations which can be merged) @@ -6050,15 +6120,18 @@ var SVG = (function () { this.transforms = new Matrix(); - var converged = this._run(declarative ? dt : position); // this.fire('step', this) + var converged = this._run(declarative ? dt : position); + this.fire('step', this); } // correct the done flag here // declaritive animations itself know when they converged - this.done = this.done || converged && declarative; // if (this.done) { - // this.fire('finish', this) - // } + this.done = this.done || converged && declarative; + + if (this.done) { + this.fire('finish', this); + } return this; } @@ -6217,7 +6290,7 @@ var SVG = (function () { }]); return Runner; - }(); + }(EventTarget); Runner.id = 0; var FakeRunner = function FakeRunner() { @@ -6299,14 +6372,14 @@ var SVG = (function () { }, { key: "merge", value: function merge() { - var _this = this; + var _this2 = this; var lastRunner = null; this.runners.forEach(function (runner, i) { if (lastRunner && runner.done && lastRunner.done) { - _this.remove(runner.id); + _this2.remove(runner.id); - _this.edit(lastRunner.id, runner.mergeWith(lastRunner)); + _this2.edit(lastRunner.id, runner.mergeWith(lastRunner)); } lastRunner = runner; @@ -6691,7 +6764,6 @@ var SVG = (function () { // export {default as Matrix} from './Matrix.js' // export {default as Morphable} from './Morphable.js' // export {default as SVGNumber} from './SVGNumber.js' - // export {default as Parent} from './Parent.js' // export {default as Path} from './Path.js' // export {default as PathArray} from './PathArray.js' // export {default as Pattern} from './Pattern.js' @@ -6712,9 +6784,9 @@ var SVG = (function () { var Classes = /*#__PURE__*/Object.freeze({ EventTarget: EventTarget, + Dom: Dom, Element: Element, Shape: Shape, - Parent: Parent, Container: Container$1, HtmlNode: HtmlNode, Doc: Doc$1, @@ -6760,98 +6832,6 @@ var SVG = (function () { Spring: Spring }); - function attr(attr, val, ns) { - // act as full getter - if (attr == null) { - // get an object of attributes - attr = {}; - val = this.node.attributes; - var _iteratorNormalCompletion = true; - var _didIteratorError = false; - var _iteratorError = undefined; - - try { - for (var _iterator = val[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { - var node = _step.value; - attr[node.nodeName] = isNumber.test(node.nodeValue) ? parseFloat(node.nodeValue) : node.nodeValue; - } - } catch (err) { - _didIteratorError = true; - _iteratorError = err; - } finally { - try { - if (!_iteratorNormalCompletion && _iterator.return != null) { - _iterator.return(); - } - } finally { - if (_didIteratorError) { - throw _iteratorError; - } - } - } - - return attr; - } else if (Array.isArray(attr)) ; else if (_typeof(attr) === 'object') { - // apply every attribute individually if an object is passed - for (val in attr) { - this.attr(val, attr[val]); - } - } else if (val === null) { - // remove value - this.node.removeAttribute(attr); - } else if (val == null) { - // act as a getter if the first and only argument is not an object - val = this.node.getAttribute(attr); - return val == null ? attrs[attr] // FIXME: do we need to return defaults? - : isNumber.test(val) ? parseFloat(val) : val; - } else { - // convert image fill and stroke to patterns - if (attr === 'fill' || attr === 'stroke') { - if (isImage.test(val)) { - val = this.doc().defs().image(val); - } - } // FIXME: This is fine, but what about the lines above? - // How does attr know about image()? - - - while (typeof val.attrHook == 'function') { - val = val.attrHook(this, attr); - } // ensure correct numeric values (also accepts NaN and Infinity) - - - if (typeof val === 'number') { - val = new SVGNumber(val); - } else if (Color.isColor(val)) { - // ensure full hex color - val = new Color(val); - } else if (val.constructor === Array) { - // Check for plain arrays and parse array values - val = new SVGArray(val); - } // if the passed attribute is leading... - - - if (attr === 'leading') { - // ... call the leading method instead - if (this.leading) { - this.leading(val); - } - } else { - // set given attribute on node - typeof ns === 'string' ? this.node.setAttributeNS(ns, attr, val.toString()) : this.node.setAttribute(attr, val.toString()); - } // rebuild if required - - - if (this.rebuild && (attr === 'font-size' || attr === 'x')) { - this.rebuild(); - } - } - - return this; - } - registerMethods('Element', { - attr: attr - }); - // ### This module adds backward / forward functionality to elements. function siblings() { @@ -6926,7 +6906,7 @@ var SVG = (function () { this.parent().add(element, i + 1); return this; } - registerMethods('Element', { + registerMethods('Dom', { siblings: siblings, position: position, next: next, @@ -6956,10 +6936,55 @@ var SVG = (function () { return this; } - registerMethods('Element', { + registerMethods('Dom', { data: data }); + function classes() { + var attr = this.attr('class'); + return attr == null ? [] : attr.trim().split(delimiter); + } // Return true if class exists on the node, false otherwise + + + function hasClass(name) { + return this.classes().indexOf(name) !== -1; + } // Add class to the node + + + function addClass(name) { + if (!this.hasClass(name)) { + var array = this.classes(); + array.push(name); + this.attr('class', array.join(' ')); + } + + return this; + } // Remove class from the node + + + function removeClass(name) { + if (this.hasClass(name)) { + this.attr('class', this.classes().filter(function (c) { + return c !== name; + }).join(' ')); + } + + return this; + } // Toggle the presence of a class on the node + + + function toggleClass(name) { + return this.hasClass(name) ? this.removeClass(name) : this.addClass(name); + } + + registerMethods('Dom', { + classes: classes, + hasClass: hasClass, + addClass: addClass, + removeClass: removeClass, + toggleClass: toggleClass + }); + // Dynamic style generator function css(style, val) { @@ -7040,7 +7065,7 @@ var SVG = (function () { function visible() { return this.css('display') !== 'none'; } - registerMethods('Element', { + registerMethods('Dom', { css: css, show: show, hide: hide, @@ -7147,7 +7172,7 @@ var SVG = (function () { function memory() { return this._memory = this._memory || {}; } - registerMethods('Element', { + registerMethods('Dom', { remember: remember, forget: forget, memory: memory @@ -7170,7 +7195,7 @@ var SVG = (function () { return this; } - if (typeof o === 'string' || Color.isRgb(o) || o && typeof o.fill === 'function') { + if (typeof o === 'string' || Color.isRgb(o) || o instanceof Element) { this.attr(m, o); } else { // set all attributes from sugar.fill and sugar.stroke list @@ -7184,7 +7209,7 @@ var SVG = (function () { return this; }; - registerMethods(['Element', 'Runner'], extension); + registerMethods(['Shape', 'Runner'], extension); }); registerMethods(['Element', 'Runner'], { // Let the user set the matrix directly @@ -7291,7 +7316,7 @@ var SVG = (function () { return new Point(this.node.getPointAtLength(length)); } }); - registerMethods(['Parent', 'Runner'], { + registerMethods(['Element', 'Runner'], { // Set font font: function font(a, v) { if (_typeof(a) === 'object') { @@ -7304,7 +7329,6 @@ var SVG = (function () { } }); - // import {extend} from './tools.js' var extend$1 = extend; extend$1([Doc$1, _Symbol, Image, Pattern, Marker], getMethodsFor('viewbox')); extend$1([Line, Polyline, Polygon, Path], getMethodsFor('marker')); @@ -7314,8 +7338,9 @@ var SVG = (function () { extend$1([Text, Tspan], getMethodsFor('Tspan')); extend$1([Rect, Ellipse, Circle, Gradient], getMethodsFor('radius')); extend$1(EventTarget, getMethodsFor('EventTarget')); + extend$1(Dom, getMethodsFor('Dom')); extend$1(Element, getMethodsFor('Element')); - extend$1(Element, getMethodsFor('Parent')); //extend(Classes.Element, getConstructor('Memory')) + extend$1(Shape, getMethodsFor('Shape')); //extend(Classes.Element, getConstructor('Memory')) extend$1(Container$1, getMethodsFor('Container')); registerMorphableType([SVGNumber, Color, Box$1, Matrix, SVGArray, PointArray, PathArray]); @@ -7331,7 +7356,7 @@ var SVG = (function () { SVG.regex = regex; // satisfy tests, fix later SVG.get = SVG; SVG.find = baseFind; - Object.assign(SVG, ns$1); // import Base from './Base.js' + Object.assign(SVG, ns$1); SVG.easing = easing; Object.assign(SVG, events); SVG.TransformBag = TransformBag; diff --git a/dist/svg.min.js b/dist/svg.min.js index 27a2e20..ed14bb2 100644 --- a/dist/svg.min.js +++ b/dist/svg.min.js @@ -1 +1 @@ -var SVG=function(){"use strict";function l(t){return(l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}function a(t,e,n){return e&&i(t.prototype,e),n&&i(t,n),t}function _(r){for(var t=1;t<arguments.length;t++){var s=null!=arguments[t]?arguments[t]:{},e=Object.keys(s);"function"==typeof Object.getOwnPropertySymbols&&(e=e.concat(Object.getOwnPropertySymbols(s).filter(function(t){return Object.getOwnPropertyDescriptor(s,t).enumerable}))),e.forEach(function(t){var e,n,i;e=r,i=s[n=t],n in e?Object.defineProperty(e,n,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[n]=i})}return r}function r(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&n(t,e)}function u(t){return(u=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function n(t,e){return(n=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function s(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function h(t,e){return!e||"object"!=typeof e&&"function"!=typeof e?s(t):e}function c(t,e,n){return(c="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,n){var i=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=u(t)););return t}(t,e);if(i){var r=Object.getOwnPropertyDescriptor(i,e);return r.get?r.get.call(n):r.value}})(t,e,n||t)}function f(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=[],i=!0,r=!1,s=void 0;try{for(var u,o=t[Symbol.iterator]();!(i=(u=o.next()).done)&&(n.push(u.value),!e||n.length!==e);i=!0);}catch(t){r=!0,s=t}finally{try{i||null==o.return||o.return()}finally{if(r)throw s}}return n}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}function O(t){return function(t){if(Array.isArray(t)){for(var e=0,n=new Array(t.length);e<t.length;e++)n[e]=t[e];return n}}(t)||function(t){if(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t))return Array.from(t)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}var d=function(){function e(t){o(this,e)}return a(e,[{key:"is",value:function(t){return this.tags.includes(t)}}]),e}(),y=/^([+-]?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?)([a-z%]*)$/i,v=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i,p=/rgb\((\d+),(\d+),(\d+)\)/,m=/(#[a-z0-9\-_]+)/i,t=/\)\s*,?\s*/,g=/\s/g,w=/^#[a-f0-9]{3,6}$/i,k=/^rgb\(/,b=/^(\s+)?$/,x=/^[+-]?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,A=/\.(jpg|jpeg|png|gif|svg)(\?[^=]+.*)?/i,j=/[\s,]+/,C=/([^e])-/gi,M=/[MLHVCSQTAZ]/gi,S=/[MLHVCSQTAZ]/i,T=/((\d?\.\d+(?:e[+-]?\d+)?)((?:\.\d+(?:e[+-]?\d+)?)+))+/gi,E=/\./g,e=Object.freeze({numberAndUnit:y,hex:v,rgb:p,reference:m,transforms:t,whitespace:g,isHex:w,isRgb:k,isCss:/[^:]+:[^;]+;?/,isBlank:b,isNumber:x,isPercent:/^-?[\d.]+%$/,isImage:A,delimiter:j,hyphen:C,pathLetters:M,isPathLetter:S,numbersWithDots:T,dots:E});function N(t,e,n,i){return n+i.replace(E," .")}function P(t){return t.toLowerCase().replace(/-(.)/g,function(t,e){return e.toUpperCase()})}function D(t){return t.charAt(0).toUpperCase()+t.slice(1)}function z(t){var e=t.toString(16);return 1===e.length?"0"+e:e}function R(t,e,n){if(null==e||null==n){var i=t.bbox();null==e?e=i.width/i.height*n:null==n&&(n=i.height/i.width*e)}return{width:e,height:n}}function q(t){return{a:t[0],b:t[1],c:t[2],d:t[3],e:t[4],f:t[5]}}var L="abcdef".split("");function F(t,e,n){return Math.abs(e-t)<(n||1e-6)}function I(t){return null!=t.a||null!=t.b||null!=t.c||null!=t.d||null!=t.e||null!=t.f}function X(t,e){var n,i,r=t.origin;if("string"==typeof r||null==r){var s=(r||"center").toLowerCase().trim(),u=e.bbox(),o=u.height,a=u.width,h=u.x,l=u.y,c=s.includes("left")?h:s.includes("right")?h+a:h+a/2,f=s.includes("top")?l:s.includes("bottom")?l+o:l+o/2;n=null!=t.ox?t.ox:c,i=null!=t.oy?t.oy:f}else n=r[0],i=r[1];return[n,i]}var Y="http://www.w3.org/2000/svg",H="http://www.w3.org/2000/xmlns/",B="http://www.w3.org/1999/xlink",G="http://svgjs.com/svgjs",V=Object.freeze({ns:Y,xmlns:H,xlink:B,svgjs:G});function Q(t,e){return e||U(t)}function U(t){return document.createElementNS(Y,t)}function $(t,e){var n,i;for(i=(t=Array.isArray(t)?t:[t]).length-1;0<=i;i--)for(n in e)t[i].prototype[n]=e[n]}var J=Object.freeze({nodeOrNew:Q,makeNode:U,extend:$,addFactory:function(t,e){$(t,e)},invent:function(e){var t="function"==typeof e.create?e.create:function(t){e.inherit.call(this,t||U(e.create))};return e.inherit&&(t.prototype=new e.inherit,t.prototype.constructor=t),e.extend&&$(t,e.extend),e.construct&&$(e.parent||Container,e.construct),t}}),W={},Z=Symbol("root");function K(t){if(t instanceof d)return t;if("object"===l(t))return tt(t);if(null==t)return new W[Z];if("string"==typeof t&&"<"!==t.charAt(0))return tt(document.querySelector(t));var e=U("svg");return e.innerHTML=t,t=tt(e.firstChild)}function tt(t){return t?t.instance instanceof d?t.instance:t instanceof window.SVGElement?"svg"===t.nodeName?new W[Z](t):"linearGradient"===t.nodeName||"radialGradient"===t.nodeName?new W.Gradient(t):W[D(t.nodeName)]?new(W[D(t.nodeName)])(t):new W.Bare(t):new W.HtmlNode(t):null}function et(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:t.name,n=2<arguments.length&&void 0!==arguments[2]&&arguments[2];return W[e]=t,n&&(W[Z]=t),t}function nt(t){return W[t]}var it=1e3;function rt(t){return"Svgjs"+D(t)+it++}function st(t){for(var e=t.children.length-1;0<=e;e--)st(t.children[e]);return t.id?tt(t).id(rt(t.nodeName)):tt(t)}var ut=Object.freeze({root:Z,makeInstance:K,adopt:tt,register:et,getClass:nt,eid:rt,assignNewId:st}),ot={};function at(t,e){if(Array.isArray(t)){var n=!0,i=!1,r=void 0;try{for(var s,u=t[Symbol.iterator]();!(n=(s=u.next()).done);n=!0){at(s.value,e)}}catch(t){i=!0,r=t}finally{try{n||null==u.return||u.return()}finally{if(i)throw r}}}else if("object"!=l(t))ot[t]=Object.assign(ot[t]||{},e);else for(var o=Object.entries(t),a=0;a<o.length;a++){var h=f(o[a],2);at(h[0],h[1])}}function ht(t){return ot[t]||{}}var lt=0;function ct(t){return"function"==typeof t.getEventTarget?t.getEventTarget():t}function ft(t,e,i,n,r){var s=i.bind(n||t),u=ct(t);e=Array.isArray(e)?e:e.split(j),u.instance=u.instance||{events:{}};var o=u.instance.events;i._svgjsListenerId||(i._svgjsListenerId=++lt),e.forEach(function(t){var e=t.split(".")[0],n=t.split(".")[1]||"*";o[e]=o[e]||{},o[e][n]=o[e][n]||{},o[e][n][i._svgjsListenerId]=s,u.addEventListener(e,s,r||!1)})}function dt(t,e,s,u){var o=ct(t);if(o.instance&&("function"!=typeof s||(s=s._svgjsListenerId))){var a=o.instance.events;(e=Array.isArray(e)?e:(e||"").split(j)).forEach(function(t){var e,n,i=t&&t.split(".")[0],r=t&&t.split(".")[1];if(s)a[i]&&a[i][r||"*"]&&(o.removeEventListener(i,a[i][r||"*"][s],u||!1),delete a[i][r||"*"][s]);else if(i&&r){if(a[i]&&a[i][r]){for(n in a[i][r])dt(o,[i,r].join("."),n);delete a[i][r]}}else if(r)for(t in a)for(e in a[t])r===e&&dt(o,[t,r].join("."));else if(i){if(a[i]){for(e in a[i])dt(o,[i,e].join("."));delete a[i]}}else{for(t in a)dt(o,t);o.instance.events={}}})}}function yt(t,e,n){var i=ct(t);return e instanceof window.Event||(e=new window.CustomEvent(e,{detail:n,cancelable:!0})),i.dispatchEvent(e),e}var vt=Object.freeze({on:ft,off:dt,dispatch:yt}),pt=function(t){function n(){var t,e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};return o(this,n),(t=h(this,u(n).call(this))).events=e.events||{},t}return r(n,d),a(n,[{key:"on",value:function(t,e,n,i){return ft(this,t,e,n,i),this}},{key:"off",value:function(t,e){return dt(this,t,e),this}},{key:"dispatch",value:function(t,e){return yt(this,t,e)}},{key:"fire",value:function(t,e){return this.dispatch(t,e),this}}]),n}();$(pt,["click","dblclick","mousedown","mouseup","mouseover","mouseout","mousemove","mouseenter","mouseleave","touchstart","touchmove","touchleave","touchend","touchcancel"].reduce(function(t,e){return t[e]=function(t){return null===t?dt(this,e):ft(this,e,t),this},t},{}));var mt=function(){function n(){o(this,n),this.init.apply(this,arguments)}return a(n,[{key:"init",value:function(t,e){e=Array.isArray(t)?t[1]:e,t=Array.isArray(t)?t[0]:t,this.value=0,this.unit=e||"","number"==typeof t?this.value=isNaN(t)?0:isFinite(t)?t:t<0?-34e37:34e37:"string"==typeof t?(e=t.match(y))&&(this.value=parseFloat(e[1]),"%"===e[5]?this.value/=100:"s"===e[5]&&(this.value*=1e3),this.unit=e[5]):t instanceof n&&(this.value=t.valueOf(),this.unit=t.unit)}},{key:"toString",value:function(){return("%"===this.unit?~~(1e8*this.value)/1e6:"s"===this.unit?this.value/1e3:this.value)+this.unit}},{key:"toJSON",value:function(){return this.toString()}},{key:"toArray",value:function(){return[this.value,this.unit]}},{key:"valueOf",value:function(){return this.value}},{key:"plus",value:function(t){return new n(this+(t=new n(t)),this.unit||t.unit)}},{key:"minus",value:function(t){return new n(this-(t=new n(t)),this.unit||t.unit)}},{key:"times",value:function(t){return new n(this*(t=new n(t)),this.unit||t.unit)}},{key:"divide",value:function(t){return new n(this/(t=new n(t)),this.unit||t.unit)}}]),n}(),gt=nt(Z),wt=function(t){function n(t){var e;return o(this,n),(e=h(this,u(n).call(this))).dom={},e.node=t,e.type=t.nodeName,e.node.instance=s(s(e)),t.hasAttribute("svgjs:data")&&e.setData(JSON.parse(t.getAttribute("svgjs:data"))||{}),e}return r(n,pt),a(n,[{key:"x",value:function(t){return this.attr("x",t)}},{key:"y",value:function(t){return this.attr("y",t)}},{key:"cx",value:function(t){return null==t?this.x()+this.width()/2:this.x(t-this.width()/2)}},{key:"cy",value:function(t){return null==t?this.y()+this.height()/2:this.y(t-this.height()/2)}},{key:"move",value:function(t,e){return this.x(t).y(e)}},{key:"center",value:function(t,e){return this.cx(t).cy(e)}},{key:"width",value:function(t){return this.attr("width",t)}},{key:"height",value:function(t){return this.attr("height",t)}},{key:"size",value:function(t,e){var n=R(this,t,e);return this.width(new mt(n.width)).height(new mt(n.height))}},{key:"clone",value:function(t){this.writeDataToDom();var e=st(this.node.cloneNode(!0));return t?t.add(e):this.after(e),e}},{key:"remove",value:function(){return this.parent()&&this.parent().removeElement(this),this}},{key:"replace",value:function(t){return this.after(t).remove(),t}},{key:"addTo",value:function(t){return K(t).put(this)}},{key:"putIn",value:function(t){return K(t).add(this)}},{key:"id",value:function(t){return void 0!==t||this.node.id||(this.node.id=rt(this.type)),this.attr("id",t)}},{key:"inside",value:function(t,e){var n=this.bbox();return t>n.x&&e>n.y&&t<n.x+n.width&&e<n.y+n.height}},{key:"toString",value:function(){return this.id()}},{key:"classes",value:function(){var t=this.attr("class");return null==t?[]:t.trim().split(j)}},{key:"hasClass",value:function(t){return-1!==this.classes().indexOf(t)}},{key:"addClass",value:function(t){if(!this.hasClass(t)){var e=this.classes();e.push(t),this.attr("class",e.join(" "))}return this}},{key:"removeClass",value:function(e){return this.hasClass(e)&&this.attr("class",this.classes().filter(function(t){return t!==e}).join(" ")),this}},{key:"toggleClass",value:function(t){return this.hasClass(t)?this.removeClass(t):this.addClass(t)}},{key:"reference",value:function(t){var e=function(t){var e=(t||"").toString().match(m);if(e)return e[1]}(this.attr(t));return e?K(e):null}},{key:"parent",value:function(t){var e=this;if(!e.node.parentNode)return null;if(e=tt(e.node.parentNode),!t)return e;for(;e&&e.node instanceof window.SVGElement;){if("string"==typeof t?e.matches(t):e instanceof t)return e;e=tt(e.node.parentNode)}}},{key:"doc",value:function(){var t=this.parent(gt);return t&&t.doc()}},{key:"defs",value:function(){return this.doc().defs()}},{key:"parents",value:function(t){var e=[],n=this;do{if(!(n=n.parent(t))||n instanceof nt("HtmlNode"))break;e.push(n)}while(n.parent);return e}},{key:"matches",value:function(t){return e=this.node,n=t,(e.matches||e.matchesSelector||e.msMatchesSelector||e.mozMatchesSelector||e.webkitMatchesSelector||e.oMatchesSelector).call(e,n);var e,n}},{key:"native",value:function(){return this.node}},{key:"svg",value:function(){return this.writeDataToDom(),this.node.outerHTML}},{key:"writeDataToDom",value:function(){return this.node.removeAttribute("svgjs:data"),Object.keys(this.dom).length&&this.node.setAttribute("svgjs:data",JSON.stringify(this.dom)),this}},{key:"setData",value:function(t){return this.dom=t,this}},{key:"getEventTarget",value:function(){return this.node}}]),n}();function kt(t,e){var n,i=t.length,r=[];for(n=0;n<i;n++)r.push(e(t[n]));return r}function bt(t){return t%360*Math.PI/180}var xt=Object.freeze({map:kt,filter:function(t,e){var n,i=t.length,r=[];for(n=0;n<i;n++)e(t[n])&&r.push(t[n]);return r},radians:bt,degrees:function(t){return 180*t/Math.PI%360},filterSVGElements:function(t){return this.filter(t,function(t){return t instanceof window.SVGElement})}}),_t=function(t){function s(){return o(this,s),h(this,u(s).apply(this,arguments))}return r(s,wt),a(s,[{key:"children",value:function(){return kt(this.node.children,function(t){return tt(t)})}},{key:"add",value:function(t,e){return t=K(t),null==e?this.node.appendChild(t.node):t.node!==this.node.childNodes[e]&&this.node.insertBefore(t.node,this.node.childNodes[e]),this}},{key:"put",value:function(t,e){return this.add(t,e),t.instance||t}},{key:"has",value:function(t){return 0<=this.index(t)}},{key:"index",value:function(t){return[].slice.call(this.node.childNodes).indexOf(t.node)}},{key:"get",value:function(t){return tt(this.node.childNodes[t])}},{key:"first",value:function(){return tt(this.node.firstChild)}},{key:"last",value:function(){return tt(this.node.lastChild)}},{key:"each",value:function(t,e){var n,i,r=this.children();for(n=0,i=r.length;n<i;n++)r[n]instanceof wt&&t.apply(r[n],[n,r]),e&&r[n]instanceof s&&r[n].each(t,e);return this}},{key:"removeElement",value:function(t){return this.node.removeChild(t.node),this}},{key:"clear",value:function(){for(;this.node.hasChildNodes();)this.node.removeChild(this.node.lastChild);return delete this._defs,this}},{key:"svg",value:function(t){var e,n;if(!t)return this.writeDataToDom(),this.node.outerHTML;for((e=document.createElementNS(Y,"svg")).innerHTML=t,n=e.children.length;n--;)this.node.appendChild(e.firstElementChild);return this}},{key:"writeDataToDom",value:function(){return this.each(function(){this.writeDataToDom()}),this.node.removeAttribute("svgjs:data"),Object.keys(this.dom).length&&this.node.setAttribute("svgjs:data",JSON.stringify(this.dom)),this}},{key:"flatten",value:function(t){return this.each(function(){return this instanceof s?this.flatten(t).ungroup(t):this.toParent(t)}),this.node.firstElementChild||this.remove(),this}},{key:"ungroup",value:function(t){return t=t||this.parent(),this.each(function(){return this.toParent(t)}),this.remove(),this}}]),s}(),Ot=function(t){function e(){return o(this,e),h(this,u(e).apply(this,arguments))}return r(e,_t),e}(),At=function(t){function e(){return o(this,e),h(this,u(e).apply(this,arguments))}return r(e,_t),e}(),jt=function(t){function n(t){var e;return o(this,n),(e=h(this,u(n).call(this,t,n))).node=t,e}return r(n,_t),a(n,[{key:"add",value:function(t,e){return(t=K(t)).node!==this.node.children[e]&&this.node.insertBefore(t.node,this.node.children[e]||null),this}},{key:"put",value:function(t,e){return this.add(t,e),t}},{key:"removeElement",value:function(t){return this.node.removeChild(t.node),this}},{key:"getEventTarget",value:function(){return this.node}}]),n}();et(jt);var Ct=function(t){function e(t){return o(this,e),h(this,u(e).call(this,Q("defs",t),e))}return r(e,At),a(e,[{key:"flatten",value:function(){return this}},{key:"ungroup",value:function(){return this}}]),e}();et(Ct);var Mt=function(t){function n(t){var e;return o(this,n),(e=h(this,u(n).call(this,Q("svg",t),n))).namespace(),e}return r(n,At),a(n,[{key:"isRoot",value:function(){return!(this.node.parentNode&&this.node.parentNode instanceof window.SVGElement&&"#document"!==this.node.parentNode.nodeName)}},{key:"doc",value:function(){return this.isRoot()?this:c(u(n.prototype),"doc",this).call(this)}},{key:"namespace",value:function(){return this.isRoot()?this.attr({xmlns:Y,version:"1.1"}).attr("xmlns:xlink",B,H).attr("xmlns:svgjs",G,H):this.doc().namespace()}},{key:"defs",value:function(){return this.isRoot()?tt(this.node.getElementsByTagName("defs")[0])||this.put(new Ct):this.doc().defs()}},{key:"parent",value:function(t){return this.isRoot()?"#document"===this.node.parentNode.nodeName?null:tt(this.node.parentNode):c(u(n.prototype),"parent",this).call(this,t)}},{key:"clear",value:function(){for(;this.node.hasChildNodes();)this.node.removeChild(this.node.lastChild);return this}}]),n}();at({Container:{nested:function(){return this.put(new Mt)}}}),et(Mt,"Doc",!0);var St=function(t){function e(t){return o(this,e),h(this,u(e).call(this,Q("g",t),e))}return r(e,At),e}();at({Element:{group:function(){return this.put(new St)}}}),et(St);var Tt=function(){function t(){o(this,t),this._first=null,this._last=null}return a(t,[{key:"push",value:function(t){var e=t.next?t:{value:t,next:null,prev:null};return this._last?(e.prev=this._last,this._last.next=e,this._last=e):(this._last=e,this._first=e),e}},{key:"shift",value:function(){var t=this._first;return t?(this._first=t.next,this._first&&(this._first.prev=null),this._last=this._first?this._last:null,t.value):null}},{key:"first",value:function(){return this._first&&this._first.value}},{key:"last",value:function(){return this._last&&this._last.value}},{key:"remove",value:function(t){t.prev&&(t.prev.next=t.next),t.next&&(t.next.prev=t.prev),t===this._last&&(this._last=t.prev),t===this._first&&(this._first=t.next),t.prev=null,t.next=null}}]),t}(),Et={nextDraw:null,frames:new Tt,timeouts:new Tt,timer:window.performance||window.Date,transforms:[],frame:function(t){var e=Et.frames.push({run:t});return null===Et.nextDraw&&(Et.nextDraw=window.requestAnimationFrame(Et._draw)),e},transform_frame:function(t,e){Et.transforms[e]=t},timeout:function(t,e){e=e||0;var n=Et.timer.now()+e,i=Et.timeouts.push({run:t,time:n});return null===Et.nextDraw&&(Et.nextDraw=window.requestAnimationFrame(Et._draw)),i},cancelFrame:function(t){Et.frames.remove(t)},clearTimeout:function(t){Et.timeouts.remove(t)},_draw:function(t){for(var e=null,n=Et.timeouts.last();(e=Et.timeouts.shift())&&(t>=e.time?e.run():Et.timeouts.push(e),e!==n););for(var i=null,r=Et.frames.last();i!==r&&(i=Et.frames.shift());)i.run();Et.transforms.forEach(function(t){t()}),Et.nextDraw=Et.timeouts.first()||Et.frames.first()?window.requestAnimationFrame(Et._draw):null}},Nt=function(t){function e(t){return o(this,e),h(this,u(e).call(this,Q(t,"string"==typeof t?null:t),e))}return r(e,_t),a(e,[{key:"words",value:function(t){for(;this.node.hasChildNodes();)this.node.removeChild(this.node.lastChild);return this.node.appendChild(document.createTextNode(t)),this}}]),e}();function Pt(t){return null==t?this.cx()-this.rx():this.cx(t+this.rx())}function Dt(t){return null==t?this.cy()-this.ry():this.cy(t+this.ry())}function zt(t){return null==t?this.attr("cx"):this.attr("cx",t)}function Rt(t){return null==t?this.attr("cy"):this.attr("cy",t)}function qt(t){return null==t?2*this.rx():this.rx(new mt(t).divide(2))}function Lt(t){return null==t?2*this.ry():this.ry(new mt(t).divide(2))}function Ft(t,e){var n=R(this,t,e);return this.rx(new mt(n.width).divide(2)).ry(new mt(n.height).divide(2))}et(Nt),at("Container",{element:function(t,e){return this.put(new Nt(t,e))}});var It=Object.freeze({rx:function(t){return this.attr("rx",t)},ry:function(t){return this.attr("ry",t)},x:Pt,y:Dt,cx:zt,cy:Rt,width:qt,height:Lt,size:Ft}),Xt=function(t){function e(t){return o(this,e),h(this,u(e).call(this,Q("circle",t),e))}return r(e,Ot),a(e,[{key:"radius",value:function(t){return this.attr("r",t)}},{key:"rx",value:function(t){return this.attr("r",t)}},{key:"ry",value:function(t){return this.rx(t)}}]),e}();function Yt(t,e){return kt((e||document).querySelectorAll(t),function(t){return tt(t)})}$(Xt,{x:Pt,y:Dt,cx:zt,cy:Rt,width:qt,height:Lt,size:Ft}),at({Element:{circle:function(t){return this.put(new Xt).radius(new mt(t).divide(2)).move(0,0)}}}),et(Xt),at("Element",{find:function(t){return Yt(t,this.node)}});var Ht=function(t){function e(t){return o(this,e),h(this,u(e).call(this,Q("clipPath",t),e))}return r(e,At),a(e,[{key:"remove",value:function(){return this.targets().forEach(function(t){t.unclip()}),c(u(e.prototype),"remove",this).call(this)}},{key:"targets",value:function(){return Yt('svg [clip-path*="'+this.id()+'"]')}}]),e}();at({Container:{clip:function(){return this.defs().put(new Ht)}},Element:{clipWith:function(t){var e=t instanceof Ht?t:this.parent().clip().add(t);return this.attr("clip-path",'url("#'+e.id()+'")')},unclip:function(){return this.attr("clip-path",null)},clipper:function(){return this.reference("clip-path")}}}),et(Ht);var Bt=function(t){function e(t){return o(this,e),h(this,u(e).call(this,Q("a",t),e))}return r(e,At),a(e,[{key:"to",value:function(t){return this.attr("href",t,B)}},{key:"target",value:function(t){return this.attr("target",t)}}]),e}();at({Container:{link:function(t){return this.put(new Bt).to(t)}},Element:{linkTo:function(t){var e=new Bt;return"function"==typeof t?t.call(e,e):e.to(t),this.parent().put(e).put(this)}}}),et(Bt);var Gt=function(t){function e(t){return o(this,e),h(this,u(e).call(this,Q("ellipse",t),e))}return r(e,Ot),e}();$(Gt,It),at("Container",{ellipse:function(t,e){return this.put(new Gt).size(t,e).move(0,0)}}),et(Gt);var Vt=function(t){function e(t){return o(this,e),h(this,u(e).call(this,Q("stop",t),e))}return r(e,wt),a(e,[{key:"update",value:function(t){return("number"==typeof t||t instanceof mt)&&(t={offset:arguments[0],color:arguments[1],opacity:arguments[2]}),null!=t.opacity&&this.attr("stop-opacity",t.opacity),null!=t.color&&this.attr("stop-color",t.color),null!=t.offset&&this.attr("offset",new mt(t.offset)),this}}]),e}();et(Vt);var Qt=Object.freeze({from:function(t,e){return"radialGradient"===(this._element||this).type?this.attr({fx:new mt(t),fy:new mt(e)}):this.attr({x1:new mt(t),y1:new mt(e)})},to:function(t,e){return"radialGradient"===(this._element||this).type?this.attr({cx:new mt(t),cy:new mt(e)}):this.attr({x2:new mt(t),y2:new mt(e)})}});function Ut(){if(!Ut.nodes){var t=(new Mt).size(2,0).css({opacity:0,position:"absolute",left:"-100%",top:"-100%",overflow:"hidden"}),e=t.path().node;Ut.nodes={svg:t,path:e}}if(!Ut.nodes.svg.node.parentNode){var n=document.body||document.documentElement;Ut.nodes.svg.addTo(n)}return Ut.nodes}var $t=function(){function r(t,e,n){var i;o(this,r),n=n||{x:0,y:0},i=Array.isArray(t)?{x:t[0],y:t[1]}:"object"===l(t)?{x:t.x,y:t.y}:{x:t,y:e},this.x=null==i.x?n.x:i.x,this.y=null==i.y?n.y:i.y}return a(r,[{key:"clone",value:function(){return new r(this)}},{key:"native",value:function(){var t=Ut().svg.node.createSVGPoint();return t.x=this.x,t.y=this.y,t}},{key:"transform",value:function(t){return new r(t.a*this.x+t.c*this.y+t.e,t.b*this.x+t.d*this.y+t.f)}}]),r}();at({Element:{point:function(t,e){return new $t(t,e).transform(this.screenCTM().inverse())}}});var Jt=function(){function u(){o(this,u),this.init.apply(this,arguments)}return a(u,[{key:"init",value:function(t){var e;t="string"==typeof t?t.split(j).map(parseFloat):Array.isArray(t)?t:"object"===l(t)?[null!=t.left?t.left:t.x,null!=t.top?t.top:t.y,t.width,t.height]:4===arguments.length?[].slice.call(arguments):[0,0,0,0],this.x=t[0],this.y=t[1],this.width=t[2],this.height=t[3],null==(e=this).x&&(e.x=0,e.y=0,e.width=0,e.height=0),e.w=e.width,e.h=e.height,e.x2=e.x+e.width,e.y2=e.y+e.height,e.cx=e.x+e.width/2,e.cy=e.y+e.height/2}},{key:"merge",value:function(t){var e=Math.min(this.x,t.x),n=Math.min(this.y,t.y);return new u(e,n,Math.max(this.x+this.width,t.x+t.width)-e,Math.max(this.y+this.height,t.y+t.height)-n)}},{key:"transform",value:function(e){var n=1/0,i=-1/0,r=1/0,s=-1/0;return[new $t(this.x,this.y),new $t(this.x2,this.y),new $t(this.x,this.y2),new $t(this.x2,this.y2)].forEach(function(t){t=t.transform(e),n=Math.min(n,t.x),i=Math.max(i,t.x),r=Math.min(r,t.y),s=Math.max(s,t.y)}),new u(n,r,i-n,s-r)}},{key:"addOffset",value:function(){return this.x+=window.pageXOffset,this.y+=window.pageYOffset,this}},{key:"toString",value:function(){return this.x+" "+this.y+" "+this.width+" "+this.height}},{key:"toArray",value:function(){return[this.x,this.y,this.width,this.height]}}]),u}();function Wt(e){var n,t,i;try{if(n=e(this.node),!((i=n).w||i.h||i.x||i.y||(t=this.node,(document.documentElement.contains||function(t){for(;t.parentNode;)t=t.parentNode;return t===document}).call(document.documentElement,t))))throw new Error("Element not in the dom")}catch(t){try{var r=this.clone(Ut().svg).show();n=e(r.node),r.remove()}catch(t){console.warn("Getting a bounding box of this element is not possible")}}return n}at({Element:{bbox:function(){return new Jt(Wt.call(this,function(t){return t.getBBox()}))},rbox:function(t){var e=new Jt(Wt.call(this,function(t){return t.getBoundingClientRect()}));return t?e.transform(t.screenCTM().inverse()):e.addOffset()}},viewbox:{viewbox:function(t,e,n,i){return null==t?new Jt(this.attr("viewBox")):this.attr("viewBox",new Jt(t,e,n,i))}}});var Zt=function(t){function i(t){return o(this,i),h(this,u(i).call(this,Q(t+"Gradient","string"==typeof t?null:t),i))}return r(i,At),a(i,[{key:"stop",value:function(t,e,n){return this.put(new Vt).update(t,e,n)}},{key:"update",value:function(t){return this.clear(),"function"==typeof t&&t.call(this,this),this}},{key:"url",value:function(){return"url(#"+this.id()+")"}},{key:"toString",value:function(){return this.url()}},{key:"attr",value:function(t,e,n){return"transform"===t&&(t="gradientTransform"),c(u(i.prototype),"attr",this).call(this,t,e,n)}},{key:"targets",value:function(){return find('svg [fill*="'+this.id()+'"]')}},{key:"bbox",value:function(){return new Jt}}]),i}();$(Zt,Qt),at({Container:{gradient:function(t,e){return this.defs().gradient(t,e)}},Defs:{gradient:function(t,e){return this.put(new Zt(t)).update(e)}}}),et(Zt);var Kt=function(t){function i(t){return o(this,i),h(this,u(i).call(this,Q("pattern",t),i))}return r(i,At),a(i,[{key:"url",value:function(){return"url(#"+this.id()+")"}},{key:"update",value:function(t){return this.clear(),"function"==typeof t&&t.call(this,this),this}},{key:"toString",value:function(){return this.url()}},{key:"attr",value:function(t,e,n){return"transform"===t&&(t="patternTransform"),c(u(i.prototype),"attr",this).call(this,t,e,n)}},{key:"targets",value:function(){return find('svg [fill*="'+this.id()+'"]')}},{key:"bbox",value:function(){return new Jt}}]),i}();at({Container:{pattern:function(t,e,n){return this.defs().pattern(t,e,n)}},Defs:{pattern:function(t,e,n){return this.put(new Kt).update(n).attr({x:0,y:0,width:t,height:e,patternUnits:"userSpaceOnUse"})}}}),et(Kt);var te=function(t){function e(t){return o(this,e),h(this,u(e).call(this,Q("image",t),e))}return r(e,Ot),a(e,[{key:"load",value:function(n,i){if(!n)return this;var r=new window.Image;return ft(r,"load",function(t){var e=this.parent(Kt);0===this.width()&&0===this.height()&&this.size(r.width,r.height),e instanceof Kt&&0===e.width()&&0===e.height()&&e.size(this.width(),this.height()),"function"==typeof i&&i.call(this,{width:r.width,height:r.height,ratio:r.width/r.height,url:n})},this),ft(r,"load error",function(){dt(r)}),this.attr("href",r.src=n,B)}},{key:"attrHook",value:function(t){var e=this;return t.doc().defs().pattern(0,0,function(t){t.add(e)})}}]),e}();at({Container:{image:function(t,e){return this.put(new te).size(0,0).load(t,e)}}}),et(te);var ee=function(){try{return Function("name","baseClass","_constructor",["baseClass = baseClass || Array","return {","[name]: class extends baseClass {","constructor (...args) {","super(...args)","_constructor && _constructor.apply(this, args)","}","}","}[name]"].join("\n"))}catch(t){return function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:Array,n=2<arguments.length?arguments[2]:void 0,i=function(){e.apply(this,arguments),n&&n.apply(this,arguments)};return(i.prototype=Object.create(e.prototype)).constructor=i}}}(),ne=ee("SVGArray",Array,function(){this.init.apply(this,arguments)});$(ne,{init:function(){this.length=0,this.push.apply(this,O(this.parse.apply(this,arguments)))},toArray:function(){return Array.prototype.concat.apply([],this)},toString:function(){return this.join(" ")},valueOf:function(){var t=[];return t.push.apply(t,O(this)),t},parse:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:[];return t instanceof Array?t:t.trim().split(j).map(parseFloat)},clone:function(){return new this.constructor(this)},toSet:function(){return new Set(this)}});var ie=ee("PointArray",ne);$(ie,{toString:function(){for(var t=0,e=this.length,n=[];t<e;t++)n.push(this[t].join(","));return n.join(" ")},toLine:function(){return{x1:this[0][0],y1:this[0][1],x2:this[1][0],y2:this[1][1]}},at:function(t){if(!this.destination)return this;for(var e=0,n=this.length,i=[];e<n;e++)i.push([this[e][0]+(this.destination[e][0]-this[e][0])*t,this[e][1]+(this.destination[e][1]-this[e][1])*t]);return new ie(i)},parse:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:[[0,0]],e=[];if(t instanceof Array){if(t[0]instanceof Array)return t}else t=t.trim().split(j).map(parseFloat);t.length%2!=0&&t.pop();for(var n=0,i=t.length;n<i;n+=2)e.push([t[n],t[n+1]]);return e},move:function(t,e){var n=this.bbox();if(t-=n.x,e-=n.y,!isNaN(t)&&!isNaN(e))for(var i=this.length-1;0<=i;i--)this[i]=[this[i][0]+t,this[i][1]+e];return this},size:function(t,e){var n,i=this.bbox();for(n=this.length-1;0<=n;n--)i.width&&(this[n][0]=(this[n][0]-i.x)*t/i.width+i.x),i.height&&(this[n][1]=(this[n][1]-i.y)*e/i.height+i.y);return this},bbox:function(){var e=-1/0,n=-1/0,i=1/0,r=1/0;return this.forEach(function(t){e=Math.max(t[0],e),n=Math.max(t[1],n),i=Math.min(t[0],i),r=Math.min(t[1],r)}),{x:i,y:r,width:e-i,height:n-r}}});var re=ie;var se=Object.freeze({MorphArray:re,x:function(t){return null==t?this.bbox().x:this.move(t,this.bbox().y)},y:function(t){return null==t?this.bbox().y:this.move(this.bbox().x,t)},width:function(t){var e=this.bbox();return null==t?e.width:this.size(t,e.height)},height:function(t){var e=this.bbox();return null==t?e.height:this.size(e.width,t)}}),ue=function(t){function e(t){return o(this,e),h(this,u(e).call(this,Q("line",t),e))}return r(e,Ot),a(e,[{key:"array",value:function(){return new ie([[this.attr("x1"),this.attr("y1")],[this.attr("x2"),this.attr("y2")]])}},{key:"plot",value:function(t,e,n,i){return null==t?this.array():(t=void 0!==e?{x1:t,y1:e,x2:n,y2:i}:new ie(t).toLine(),this.attr(t))}},{key:"move",value:function(t,e){return this.attr(this.array().move(t,e).toLine())}},{key:"size",value:function(t,e){var n=R(this,t,e);return this.attr(this.array().size(n.width,n.height).toLine())}}]),e}();$(ue,se),at({Container:{line:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return ue.prototype.plot.apply(this.put(new ue),null!=e[0]?e:[0,0,0,0])}}}),et(ue);var oe=function(t){function e(t){return o(this,e),h(this,u(e).call(this,Q("marker",t),e))}return r(e,At),a(e,[{key:"width",value:function(t){return this.attr("markerWidth",t)}},{key:"height",value:function(t){return this.attr("markerHeight",t)}},{key:"ref",value:function(t,e){return this.attr("refX",t).attr("refY",e)}},{key:"update",value:function(t){return this.clear(),"function"==typeof t&&t.call(this,this),this}},{key:"toString",value:function(){return"url(#"+this.id()+")"}}]),e}();at({Container:{marker:function(t,e,n){return this.defs().marker(t,e,n)}},Defs:{marker:function(t,e,n){return this.put(new oe).size(t,e).ref(t/2,e/2).viewbox(0,0,t,e).attr("orient","auto").update(n)}},marker:{marker:function(t,e,n,i){var r=["marker"];return"all"!==t&&r.push(t),r=r.join("-"),t=e instanceof oe?e:this.defs().marker(e,n,i),this.attr(r,t)}}}),et(oe);var ae=function(t){function e(t){return o(this,e),h(this,u(e).call(this,Q("mask",t),e))}return r(e,At),a(e,[{key:"remove",value:function(){return this.targets().forEach(function(t){t.unmask()}),c(u(e.prototype),"remove",this).call(this)}},{key:"targets",value:function(){return Yt('svg [mask*="'+this.id()+'"]')}}]),e}();at({Container:{mask:function(){return this.defs().put(new ae)}},Element:{maskWith:function(t){var e=t instanceof ae?t:this.parent().mask().add(t);return this.attr("mask",'url("#'+e.id()+'")')},unmask:function(){return this.attr("mask",null)},masker:function(){return this.reference("mask")}}}),et(ae);for(var he=ee("PathArray",ne),le={M:function(t,e,n){return e.x=n.x=t[0],e.y=n.y=t[1],["M",e.x,e.y]},L:function(t,e){return e.x=t[0],e.y=t[1],["L",t[0],t[1]]},H:function(t,e){return e.x=t[0],["H",t[0]]},V:function(t,e){return e.y=t[0],["V",t[0]]},C:function(t,e){return e.x=t[4],e.y=t[5],["C",t[0],t[1],t[2],t[3],t[4],t[5]]},S:function(t,e){return e.x=t[2],e.y=t[3],["S",t[0],t[1],t[2],t[3]]},Q:function(t,e){return e.x=t[2],e.y=t[3],["Q",t[0],t[1],t[2],t[3]]},T:function(t,e){return e.x=t[0],e.y=t[1],["T",t[0],t[1]]},Z:function(t,e,n){return e.x=n.x,e.y=n.y,["Z"]},A:function(t,e){return e.x=t[5],e.y=t[6],["A",t[0],t[1],t[2],t[3],t[4],t[5],t[6]]}},ce="mlhvqtcsaz".split(""),fe=0,de=ce.length;fe<de;++fe)le[ce[fe]]=function(s){return function(t,e,n){if("H"===s)t[0]=t[0]+e.x;else if("V"===s)t[0]=t[0]+e.y;else if("A"===s)t[5]=t[5]+e.x,t[6]=t[6]+e.y;else for(var i=0,r=t.length;i<r;++i)t[i]=t[i]+(i%2?e.y:e.x);return le[s](t,e,n)}}(ce[fe].toUpperCase());$(he,{toString:function(){return function(t){for(var e=0,n=t.length,i="";e<n;e++)i+=t[e][0],null!=t[e][1]&&(i+=t[e][1],null!=t[e][2]&&(i+=" ",i+=t[e][2],null!=t[e][3]&&(i+=" ",i+=t[e][3],i+=" ",i+=t[e][4],null!=t[e][5]&&(i+=" ",i+=t[e][5],i+=" ",i+=t[e][6],null!=t[e][7]&&(i+=" ",i+=t[e][7])))));return i+" "}(this)},move:function(t,e){var n=this.bbox();if(t-=n.x,e-=n.y,!isNaN(t)&&!isNaN(e))for(var i,r=this.length-1;0<=r;r--)"M"===(i=this[r][0])||"L"===i||"T"===i?(this[r][1]+=t,this[r][2]+=e):"H"===i?this[r][1]+=t:"V"===i?this[r][1]+=e:"C"===i||"S"===i||"Q"===i?(this[r][1]+=t,this[r][2]+=e,this[r][3]+=t,this[r][4]+=e,"C"===i&&(this[r][5]+=t,this[r][6]+=e)):"A"===i&&(this[r][6]+=t,this[r][7]+=e);return this},size:function(t,e){var n,i,r=this.bbox();for(n=this.length-1;0<=n;n--)"M"===(i=this[n][0])||"L"===i||"T"===i?(this[n][1]=(this[n][1]-r.x)*t/r.width+r.x,this[n][2]=(this[n][2]-r.y)*e/r.height+r.y):"H"===i?this[n][1]=(this[n][1]-r.x)*t/r.width+r.x:"V"===i?this[n][1]=(this[n][1]-r.y)*e/r.height+r.y:"C"===i||"S"===i||"Q"===i?(this[n][1]=(this[n][1]-r.x)*t/r.width+r.x,this[n][2]=(this[n][2]-r.y)*e/r.height+r.y,this[n][3]=(this[n][3]-r.x)*t/r.width+r.x,this[n][4]=(this[n][4]-r.y)*e/r.height+r.y,"C"===i&&(this[n][5]=(this[n][5]-r.x)*t/r.width+r.x,this[n][6]=(this[n][6]-r.y)*e/r.height+r.y)):"A"===i&&(this[n][1]=this[n][1]*t/r.width,this[n][2]=this[n][2]*e/r.height,this[n][6]=(this[n][6]-r.x)*t/r.width+r.x,this[n][7]=(this[n][7]-r.y)*e/r.height+r.y);return this},equalCommands:function(t){var e,n,i;for(t=new he(t),i=this.length===t.length,e=0,n=this.length;i&&e<n;e++)i=this[e][0]===t[e][0];return i},morph:function(t){return t=new he(t),this.equalCommands(t)?this.destination=t:this.destination=null,this},at:function(t){if(!this.destination)return this;var e,n,i,r,s=this,u=this.destination.value,o=[],a=new he;for(e=0,n=s.length;e<n;e++){for(o[e]=[s[e][0]],i=1,r=s[e].length;i<r;i++)o[e][i]=s[e][i]+(u[e][i]-s[e][i])*t;"A"===o[e][0]&&(o[e][4]=+(0!==o[e][4]),o[e][5]=+(0!==o[e][5]))}return a.value=o,a},parse:function(){var t,e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:[["M",0,0]];if(e instanceof he)return e;var n={M:2,L:2,H:1,V:1,C:6,S:4,Q:4,T:2,A:7,Z:0};e="string"==typeof e?e.replace(T,N).replace(M," $& ").replace(C,"$1 -").trim().split(j):e.reduce(function(t,e){return[].concat.call(t,e)},[]);for(var i=[],r=new $t,s=new $t,u=0,o=e.length;S.test(e[u])?(t=e[u],++u):"M"===t?t="L":"m"===t&&(t="l"),i.push(le[t].call(null,e.slice(u,u+=n[t.toUpperCase()]).map(parseFloat),r,s)),u<o;);return i},bbox:function(){return Ut().path.setAttribute("d",this.toString()),Ut.nodes.path.getBBox()}});var ye=function(t){function e(t){return o(this,e),h(this,u(e).call(this,Q("path",t),e))}return r(e,Ot),a(e,[{key:"array",value:function(){return this._array||(this._array=new he(this.attr("d")))}},{key:"plot",value:function(t){return null==t?this.array():this.clear().attr("d","string"==typeof t?t:this._array=new he(t))}},{key:"clear",value:function(){return delete this._array,this}},{key:"move",value:function(t,e){return this.attr("d",this.array().move(t,e))}},{key:"x",value:function(t){return null==t?this.bbox().x:this.move(t,this.bbox().y)}},{key:"y",value:function(t){return null==t?this.bbox().y:this.move(this.bbox().x,t)}},{key:"size",value:function(t,e){var n=R(this,t,e);return this.attr("d",this.array().size(n.width,n.height))}},{key:"width",value:function(t){return null==t?this.bbox().width:this.size(t,this.bbox().height)}},{key:"height",value:function(t){return null==t?this.bbox().height:this.size(this.bbox().width,t)}},{key:"targets",value:function(){return Yt('svg textpath [href*="'+this.id()+'"]')}}]),e}();ye.prototype.MorphArray=he,at({Container:{path:function(t){return this.put(new ye).plot(t||new he)}}}),et(ye);var ve=Object.freeze({array:function(){return this._array||(this._array=new ie(this.attr("points")))},plot:function(t){return null==t?this.array():this.clear().attr("points","string"==typeof t?t:this._array=new ie(t))},clear:function(){return delete this._array,this},move:function(t,e){return this.attr("points",this.array().move(t,e))},size:function(t,e){var n=R(this,t,e);return this.attr("points",this.array().size(n.width,n.height))}}),pe=function(t){function e(t){return o(this,e),h(this,u(e).call(this,Q("polygon",t),e))}return r(e,Ot),e}();at({Container:{polygon:function(t){return this.put(new pe).plot(t||new ie)}}}),$(pe,se),$(pe,ve),et(pe);var me=function(t){function e(t){return o(this,e),h(this,u(e).call(this,Q("polyline",t),e))}return r(e,Ot),e}();at({Container:{polyline:function(t){return this.put(new me).plot(t||new ie)}}}),$(me,se),$(me,ve),et(me);var ge=function(t){function e(t){return o(this,e),h(this,u(e).call(this,Q("rect",t),e))}return r(e,Ot),a(e,[{key:"rx",value:function(t){return this.attr("rx",t)}},{key:"ry",value:function(t){return this.attr("ry",t)}}]),e}();at({Container:{rect:function(t,e){return this.put(new ge).size(t,e)}}}),et(ge);var we=function(t){function e(t){return o(this,e),h(this,u(e).call(this,Q("symbol",t),e))}return r(e,At),e}();function ke(){}at({Container:{symbol:function(){return this.put(new we)}}}),et(we);var be={duration:400,ease:">",delay:0},xe={"fill-opacity":1,"stroke-opacity":1,"stroke-width":0,"stroke-linejoin":"miter","stroke-linecap":"butt",fill:"#000000",stroke:"#000000",opacity:1,x:0,y:0,cx:0,cy:0,width:0,height:0,r:0,rx:0,ry:0,offset:0,"stop-opacity":1,"stop-color":"#000000","font-size":16,"font-family":"Helvetica, Arial, sans-serif","text-anchor":"start"},_e=Object.freeze({noop:ke,timeline:be,attrs:xe});var Oe=Object.freeze({plain:function(t){return!1===this._build&&this.clear(),this.node.appendChild(document.createTextNode(t)),this},length:function(){return this.node.getComputedTextLength()}}),Ae=function(t){function n(t){var e;return o(this,n),(e=h(this,u(n).call(this,Q("text",t),n))).dom.leading=new mt(1.3),e._rebuild=!0,e._build=!1,e.attr("font-family",xe["font-family"]),e}return r(n,_t),a(n,[{key:"x",value:function(t){return null==t?this.attr("x"):this.attr("x",t)}},{key:"y",value:function(t){var e=this.attr("y"),n="number"==typeof e?e-this.bbox().y:0;return null==t?"number"==typeof e?e-n:e:this.attr("y","number"==typeof t?t+n:t)}},{key:"cx",value:function(t){return null==t?this.bbox().cx:this.x(t-this.bbox().width/2)}},{key:"cy",value:function(t){return null==t?this.bbox().cy:this.y(t-this.bbox().height/2)}},{key:"text",value:function(t){if(void 0===t){var e=this.node.childNodes,n=0;t="";for(var i=0,r=e.length;i<r;++i)"textPath"!==e[i].nodeName?(i!==n&&3!==e[i].nodeType&&!0===tt(e[i]).dom.newLined&&(t+="\n"),t+=e[i].textContent):0===i&&(n=1);return t}if(this.clear().build(!0),"function"==typeof t)t.call(this,this);else for(var s=0,u=(t=t.split("\n")).length;s<u;s++)this.tspan(t[s]).newLine();return this.build(!1).rebuild()}},{key:"leading",value:function(t){return null==t?this.dom.leading:(this.dom.leading=new mt(t),this.rebuild())}},{key:"rebuild",value:function(t){if("boolean"==typeof t&&(this._rebuild=t),this._rebuild){var e=this,n=0,i=this.dom.leading*new mt(this.attr("font-size"));this.each(function(){this.dom.newLined&&(this.attr("x",e.attr("x")),"\n"===this.text()?n+=i:(this.attr("dy",i+n),n=0))}),this.fire("rebuild")}return this}},{key:"build",value:function(t){return this._build=!!t,this}},{key:"setData",value:function(t){return this.dom=t,this.dom.leading=new mt(t.leading||1.3),this}}]),n}();$(Ae,Oe),at({Container:{text:function(t){return this.put(new Ae).text(t)},plain:function(t){return this.put(new Ae).plain(t)}}}),et(Ae);var je=function(t){function e(t){return o(this,e),h(this,u(e).call(this,Q("textPath",t),e))}return r(e,Ae),a(e,[{key:"array",value:function(){var t=this.track();return t?t.array():null}},{key:"plot",value:function(t){var e=this.track(),n=null;return e&&(n=e.plot(t)),null==t?n:this}},{key:"track",value:function(){return this.reference("href")}}]),e}();at({Container:{textPath:function(t,e){return this.defs().path(e).text(t).addTo(this)}},Text:{path:function(t){var e=new je;return t instanceof ye||(t=this.doc().defs().path(t)),e.attr("href","#"+t,B),this.put(e)},textPath:function(){return this.find("textPath")}},Path:{text:function(t){if(t instanceof Ae){var e=t.text();return t.clear().path(this).text(e)}return this.parent().put(new Ae).path(this).text(t)}}}),je.prototype.MorphArray=he,et(je);var Ce=function(t){function e(t){return o(this,e),h(this,u(e).call(this,Q("tspan",t),e))}return r(e,_t),a(e,[{key:"text",value:function(t){return null==t?this.node.textContent+(this.dom.newLined?"\n":""):("function"==typeof t?t.call(this,this):this.plain(t),this)}},{key:"dx",value:function(t){return this.attr("dx",t)}},{key:"dy",value:function(t){return this.attr("dy",t)}},{key:"newLine",value:function(){var t=this.parent(Ae);return this.dom.newLined=!0,this.dy(t.dom.leading*t.attr("font-size")).attr("x",t.x())}}]),e}();$(Ce,Oe),at({Tspan:{tspan:function(t){var e=new Ce;return this._build||this.clear(),this.node.appendChild(e.node),e.text(t)}}}),et(Ce);var Me=function(t){function e(t){return o(this,e),h(this,u(e).call(this,Q("use",t),e))}return r(e,Ot),a(e,[{key:"element",value:function(t,e){return this.attr("href",(e||"")+"#"+t,B)}}]),e}();at({Container:{use:function(t,e){return this.put(new Me).element(t,e)}}}),et(Me);var Se=function(){function h(){o(this,h),this.init.apply(this,arguments)}return a(h,[{key:"init",value:function(t){var e=q([1,0,0,1,0,0]);t=t instanceof wt?t.matrixify():"string"==typeof t?q(t.split(j).map(parseFloat)):Array.isArray(t)?q(t):"object"===l(t)&&I(t)?t:"object"===l(t)?(new h).transform(t):6===arguments.length?q([].slice.call(arguments)):e,this.a=null!=t.a?t.a:e.a,this.b=null!=t.b?t.b:e.b,this.c=null!=t.c?t.c:e.c,this.d=null!=t.d?t.d:e.d,this.e=null!=t.e?t.e:e.e,this.f=null!=t.f?t.f:e.f}},{key:"clone",value:function(){return new h(this)}},{key:"transform",value:function(t){if(I(t))return new h(t).multiplyO(this);var e=h.formatTransforms(t),n=new $t(e.ox,e.oy).transform(this),i=n.x,r=n.y,s=(new h).translateO(e.rx,e.ry).lmultiplyO(this).translateO(-i,-r).scaleO(e.scaleX,e.scaleY).skewO(e.skewX,e.skewY).shearO(e.shear).rotateO(e.theta).translateO(i,r);if(isFinite(e.px)||isFinite(e.py)){var u=new $t(i,r).transform(s),o=e.px?e.px-u.x:0,a=e.py?e.py-u.y:0;s.translateO(o,a)}return s.translateO(e.tx,e.ty),s}},{key:"compose",value:function(t){t.origin&&(t.originX=t.origin[0],t.originY=t.origin[1]);var e=t.originX||0,n=t.originY||0,i=t.scaleX||1,r=t.scaleY||1,s=t.shear||0,u=t.rotate||0,o=t.translateX||0,a=t.translateY||0;return(new h).translateO(-e,-n).scaleO(i,r).shearO(s).rotateO(u).translateO(o,a).lmultiplyO(this).translateO(e,n)}},{key:"decompose",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:0,e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0,n=this.a,i=this.b,r=this.c,s=this.d,u=this.e,o=this.f,a=n*s-i*r,h=0<a?1:-1,l=h*Math.sqrt(n*n+i*i),c=Math.atan2(h*i,h*n),f=180/Math.PI*c,d=Math.cos(c),y=Math.sin(c),v=(n*r+i*s)/a,p=r*l/(v*n-i)||s*l/(v*i+n);return{scaleX:l,scaleY:p,shear:v,rotate:f,translateX:u-t+t*d*l+e*(v*d*l-y*p),translateY:o-e+t*y*l+e*(v*y*l+d*p),originX:t,originY:e,a:this.a,b:this.b,c:this.c,d:this.d,e:this.e,f:this.f}}},{key:"multiply",value:function(t){return this.clone().multiplyO(t)}},{key:"multiplyO",value:function(t){var e=t instanceof h?t:new h(t);return h.matrixMultiply(this,e,this)}},{key:"lmultiply",value:function(t){return this.clone().lmultiplyO(t)}},{key:"lmultiplyO",value:function(t){var e=t instanceof h?t:new h(t);return h.matrixMultiply(e,this,this)}},{key:"inverseO",value:function(){var t=this.a,e=this.b,n=this.c,i=this.d,r=this.e,s=this.f,u=t*i-e*n;if(!u)throw new Error("Cannot invert "+this);var o=i/u,a=-e/u,h=-n/u,l=t/u,c=-(o*r+h*s),f=-(a*r+l*s);return this.a=o,this.b=a,this.c=h,this.d=l,this.e=c,this.f=f,this}},{key:"inverse",value:function(){return this.clone().inverseO()}},{key:"translate",value:function(t,e){return this.clone().translateO(t,e)}},{key:"translateO",value:function(t,e){return this.e+=t||0,this.f+=e||0,this}},{key:"scale",value:function(t,e,n,i){var r;return(r=this.clone()).scaleO.apply(r,arguments)}},{key:"scaleO",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:t,n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:0,i=3<arguments.length&&void 0!==arguments[3]?arguments[3]:0;3===arguments.length&&(i=n,n=e,e=t);var r=this.a,s=this.b,u=this.c,o=this.d,a=this.e,h=this.f;return this.a=r*t,this.b=s*e,this.c=u*t,this.d=o*e,this.e=a*t-n*t+n,this.f=h*e-i*e+i,this}},{key:"rotate",value:function(t,e,n){return this.clone().rotateO(t,e,n)}},{key:"rotateO",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0,n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:0;t=bt(t);var i=Math.cos(t),r=Math.sin(t),s=this.a,u=this.b,o=this.c,a=this.d,h=this.e,l=this.f;return this.a=s*i-u*r,this.b=u*i+s*r,this.c=o*i-a*r,this.d=a*i+o*r,this.e=h*i-l*r+n*r-e*i+e,this.f=l*i+h*r-e*r-n*i+n,this}},{key:"flip",value:function(t,e){return this.clone().flipO(t,e)}},{key:"flipO",value:function(t,e){return"x"===t?this.scaleO(-1,1,e,0):"y"===t?this.scaleO(1,-1,0,e):this.scaleO(-1,-1,t,e||t)}},{key:"shear",value:function(t,e,n){return this.clone().shearO(t,e,n)}},{key:"shearO",value:function(t){var e=2<arguments.length&&void 0!==arguments[2]?arguments[2]:0,n=this.a,i=this.b,r=this.c,s=this.d,u=this.e,o=this.f;return this.a=n+i*t,this.c=r+s*t,this.e=u+o*t-e*t,this}},{key:"skew",value:function(t,e,n,i){var r;return(r=this.clone()).skewO.apply(r,arguments)}},{key:"skewO",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:t,n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:0,i=3<arguments.length&&void 0!==arguments[3]?arguments[3]:0;3===arguments.length&&(i=n,n=e,e=t),t=bt(t),e=bt(e);var r=Math.tan(t),s=Math.tan(e),u=this.a,o=this.b,a=this.c,h=this.d,l=this.e,c=this.f;return this.a=u+o*r,this.b=o+u*s,this.c=a+h*r,this.d=h+a*s,this.e=l+c*r-i*r,this.f=c+l*s-n*s,this}},{key:"skewX",value:function(t,e,n){return this.skew(t,0,e,n)}},{key:"skewXO",value:function(t,e,n){return this.skewO(t,0,e,n)}},{key:"skewY",value:function(t,e,n){return this.skew(0,t,e,n)}},{key:"skewYO",value:function(t,e,n){return this.skewO(0,t,e,n)}},{key:"aroundO",value:function(t,e,n){var i=t||0,r=e||0;return this.translateO(-i,-r).lmultiplyO(n).translateO(i,r)}},{key:"around",value:function(t,e,n){return this.clone().aroundO(t,e,n)}},{key:"native",value:function(){for(var t=Ut().svg.node.createSVGMatrix(),e=L.length-1;0<=e;e--)t[L[e]]=this[L[e]];return t}},{key:"equals",value:function(t){var e=new h(t);return F(this.a,e.a)&&F(this.b,e.b)&&F(this.c,e.c)&&F(this.d,e.d)&&F(this.e,e.e)&&F(this.f,e.f)}},{key:"toString",value:function(){return"matrix("+this.a+","+this.b+","+this.c+","+this.d+","+this.e+","+this.f+")"}},{key:"toArray",value:function(){return[this.a,this.b,this.c,this.d,this.e,this.f]}},{key:"valueOf",value:function(){return{a:this.a,b:this.b,c:this.c,d:this.d,e:this.e,f:this.f}}}],[{key:"formatTransforms",value:function(t){var e="both"===t.flip||!0===t.flip,n=t.flip&&(e||"x"===t.flip)?-1:1,i=t.flip&&(e||"y"===t.flip)?-1:1,r=t.skew&&t.skew.length?t.skew[0]:isFinite(t.skew)?t.skew:isFinite(t.skewX)?t.skewX:0,s=t.skew&&t.skew.length?t.skew[1]:isFinite(t.skew)?t.skew:isFinite(t.skewY)?t.skewY:0,u=t.scale&&t.scale.length?t.scale[0]*n:isFinite(t.scale)?t.scale*n:isFinite(t.scaleX)?t.scaleX*n:n,o=t.scale&&t.scale.length?t.scale[1]*i:isFinite(t.scale)?t.scale*i:isFinite(t.scaleY)?t.scaleY*i:i,a=t.shear||0,h=t.rotate||t.theta||0,l=new $t(t.origin||t.around||t.ox||t.originX,t.oy||t.originY),c=l.x,f=l.y,d=new $t(t.position||t.px||t.positionX,t.py||t.positionY),y=d.x,v=d.y,p=new $t(t.translate||t.tx||t.translateX,t.ty||t.translateY),m=p.x,g=p.y,w=new $t(t.relative||t.rx||t.relativeX,t.ry||t.relativeY);return{scaleX:u,scaleY:o,skewX:r,skewY:s,shear:a,theta:h,rx:w.x,ry:w.y,tx:m,ty:g,ox:c,oy:f,px:y,py:v}}},{key:"matrixMultiply",value:function(t,e,n){var i=t.a*e.a+t.c*e.b,r=t.b*e.a+t.d*e.b,s=t.a*e.c+t.c*e.d,u=t.b*e.c+t.d*e.d,o=t.e+t.a*e.e+t.c*e.f,a=t.f+t.b*e.e+t.d*e.f;return n.a=i,n.b=r,n.c=s,n.d=u,n.e=o,n.f=a,n}}]),h}();at({Element:{ctm:function(){return new Se(this.node.getCTM())},screenCTM:function(){if("function"!=typeof this.isRoot||this.isRoot())return new Se(this.node.getScreenCTM());var t=this.rect(1,1),e=t.node.getScreenCTM();return t.remove(),new Se(e)}}});var Te=function(){function t(){o(this,t),this.init.apply(this,arguments)}return a(t,[{key:"init",value:function(t,e,n){var i,r;(this.r=0,this.g=0,this.b=0,t)&&("string"==typeof t?k.test(t)?(i=p.exec(t.replace(g,"")),this.r=parseInt(i[1]),this.g=parseInt(i[2]),this.b=parseInt(i[3])):w.test(t)&&(i=v.exec(4===(r=t).length?["#",r.substring(1,2),r.substring(1,2),r.substring(2,3),r.substring(2,3),r.substring(3,4),r.substring(3,4)].join(""):r),this.r=parseInt(i[1],16),this.g=parseInt(i[2],16),this.b=parseInt(i[3],16)):Array.isArray(t)?(this.r=t[0],this.g=t[1],this.b=t[2]):"object"===l(t)?(this.r=t.r,this.g=t.g,this.b=t.b):3===arguments.length&&(this.r=t,this.g=e,this.b=n))}},{key:"toString",value:function(){return this.toHex()}},{key:"toArray",value:function(){return[this.r,this.g,this.b]}},{key:"toHex",value:function(){return"#"+z(Math.round(this.r))+z(Math.round(this.g))+z(Math.round(this.b))}},{key:"toRgb",value:function(){return"rgb("+[this.r,this.g,this.b].join()+")"}},{key:"brightness",value:function(){return this.r/255*.3+this.g/255*.59+this.b/255*.11}}],[{key:"test",value:function(t){return t+="",w.test(t)||k.test(t)}},{key:"isRgb",value:function(t){return t&&"number"==typeof t.r&&"number"==typeof t.g&&"number"==typeof t.b}},{key:"isColor",value:function(t){return this.isRgb(t)||this.test(t)}}]),t}();function Ee(e,n){return function(t){return null==t?this[t]:(this[e]=t,n&&n.call(this),this)}}var Ne={"-":function(t){return t},"<>":function(t){return-Math.cos(t*Math.PI)/2+.5},">":function(t){return Math.sin(t*Math.PI/2)},"<":function(t){return 1-Math.cos(t*Math.PI/2)},bezier:function(t,e,n,i){return function(t){}}},Pe=function(){function t(){o(this,t)}return a(t,[{key:"done",value:function(){return!1}}]),t}(),De=function(t){function n(t){var e;return o(this,n),(e=h(this,u(n).call(this))).ease=Ne[t||be.ease]||t,e}return r(n,Pe),a(n,[{key:"step",value:function(t,e,n){return"number"!=typeof t?n<1?t:e:t+(e-t)*this.ease(n)}}]),n}(),ze=function(t){function n(t){var e;return o(this,n),(e=h(this,u(n).call(this))).stepper=t,e}return r(n,Pe),a(n,[{key:"step",value:function(t,e,n,i){return this.stepper(t,e,n,i)}},{key:"done",value:function(t){return t.done}}]),n}();function Re(){var t=(this._duration||500)/1e3,e=this._overshoot||0,n=Math.PI,i=Math.log(e/100+1e-10),r=-i/Math.sqrt(n*n+i*i),s=3.9/(r*t);this.d=2*r*s,this.k=s*s}var qe=function(t){function i(t,e){var n;return o(this,i),(n=h(this,u(i).call(this))).duration(t||500).overshoot(e||0),n}return r(i,ze),a(i,[{key:"step",value:function(t,e,n,i){if("string"==typeof t)return t;if(i.done=n===1/0,n===1/0)return e;if(0===n)return t;100<n&&(n=16),n/=1e3;var r=i.velocity||0,s=-this.d*r-this.k*(t-e),u=t+r*n+s*n*n/2;return i.velocity=r+s*n,i.done=Math.abs(e-u)+Math.abs(r)<.002,i.done?e:u}}]),i}();$(qe,{duration:Ee("_duration",Re),overshoot:Ee("_overshoot",Re)});var Le=function(t){function s(t,e,n,i){var r;return o(this,s),t=null==t?.1:t,e=null==e?.01:e,n=null==n?0:n,i=null==i?1e3:i,(r=h(this,u(s).call(this))).p(t).i(e).d(n).windup(i),r}return r(s,ze),a(s,[{key:"step",value:function(t,e,n,i){if("string"==typeof t)return t;if(i.done=n===1/0,n===1/0)return e;if(0===n)return t;var r=e-t,s=(i.integral||0)+r*n,u=(r-(i.error||0))/n,o=this.windup;return!1!==o&&(s=Math.max(-o,Math.min(s,o))),i.error=r,i.integral=s,i.done=Math.abs(r)<.001,i.done?e:t+(this.P*r+this.I*s+this.D*u)}}]),s}();$(Le,{windup:Ee("windup"),p:Ee("P"),i:Ee("I"),d:Ee("D")});var Fe=function(){function e(t){o(this,e),this._stepper=t||new De("-"),this._from=null,this._to=null,this._type=null,this._context=null,this._morphObj=null}return a(e,[{key:"from",value:function(t){return null==t?this._from:(this._from=this._set(t),this)}},{key:"to",value:function(t){return null==t?this._to:(this._to=this._set(t),this)}},{key:"type",value:function(t){return null==t?this._type:(this._type=t,this)}},{key:"_set",value:function(t){if(!this._type){var e=l(t);"number"===e?this.type(mt):"string"===e?Te.isColor(t)?this.type(Te):j.test(t)?this.type(M.test(t)?he:ne):y.test(t)?this.type(mt):this.type(Ie):-1<He.indexOf(t.constructor)?this.type(t.constructor):Array.isArray(t)?this.type(ne):"object"===e?this.type(Ye):this.type(Ie)}var n=new this._type(t).toArray();return this._morphObj=this._morphObj||new this._type,this._context=this._context||Array.apply(null,Array(n.length)).map(Object),n}},{key:"stepper",value:function(t){return null==t?this._stepper:(this._stepper=t,this)}},{key:"done",value:function(){return this._context.map(this._stepper.done).reduce(function(t,e){return t&&e},!0)}},{key:"at",value:function(n){var i=this;return this._morphObj.fromArray(this._from.map(function(t,e){return i._stepper.step(t,i._to[e],n,i._context[e],i._context)}))}}]),e}(),Ie=function(){function t(){o(this,t),this.init.apply(this,arguments)}return a(t,[{key:"init",value:function(t){t=Array.isArray(t)?t[0]:t,this.value=t}},{key:"valueOf",value:function(){return this.value}},{key:"toArray",value:function(){return[this.value]}}]),t}(),Xe=function(){function e(){o(this,e),this.init.apply(this,arguments)}return a(e,[{key:"init",value:function(t){Array.isArray(t)&&(t={scaleX:t[0],scaleY:t[1],shear:t[2],rotate:t[3],translateX:t[4],translateY:t[5],originX:t[6],originY:t[7]}),Object.assign(this,e.defaults,t)}},{key:"toArray",value:function(){var t=this;return[t.scaleX,t.scaleY,t.shear,t.rotate,t.translateX,t.translateY,t.originX,t.originY]}}]),e}();Xe.defaults={scaleX:1,scaleY:1,shear:0,rotate:0,translateX:0,translateY:0,originX:0,originY:0};var Ye=function(){function t(){o(this,t),this.init.apply(this,arguments)}return a(t,[{key:"init",value:function(t){if(this.values=[],Array.isArray(t))this.values=t;else{var e=Object.entries(t||{}).sort(function(t,e){return t[0]-e[0]});this.values=e.reduce(function(t,e){return t.concat(e)},[])}}},{key:"valueOf",value:function(){for(var t={},e=this.values,n=0,i=e.length;n<i;n+=2)t[e[n]]=e[n+1];return t}},{key:"toArray",value:function(){return this.values}}]),t}(),He=[Ie,Xe,Ye];var Be=window.performance||Date,Ge=function(t){var e=t.start,n=t.runner.duration();return{start:e,duration:n,end:e+n,runner:t.runner}},Ve=function(){function t(){o(this,t),this._timeSource=function(){return Be.now()},this._dispatcher=document.createElement("div"),this._startTime=0,this._speed=1,this._reverse=!1,this._persist=0,this._nextFrame=null,this._paused=!1,this._runners=[],this._order=[],this._time=0,this._lastSourceTime=0,this._lastStepTime=0}return a(t,[{key:"getEventTarget",value:function(){return this._dispatcher}},{key:"schedule",value:function(t,e,n){if(null==t)return this._runners.map(Ge).sort(function(t,e){return t.start-e.start||t.duration-e.duration});this.active()||(this._step(),null==n&&(n="now"));var i=0;if(e=e||0,null==n||"last"===n||"after"===n)i=this._startTime;else if("absolute"===n||"start"===n)i=e,e=0;else if("now"===n)i=this._time;else{if("relative"!==n)throw new Error('Invalid value for the "when" parameter');var r=this._runners[t.id];r&&(i=r.start+e,e=0)}return t.unschedule(),t.timeline(this),t.time(-e),this._startTime=i+t.duration()+e,this._runners[t.id]={persist:this.persist(),runner:t,start:i},this._order.push(t.id),this._continue(),this}},{key:"unschedule",value:function(t){var e=this._order.indexOf(t.id);return e<0||(delete this._runners[t.id],this._order.splice(e,1),t.timeline(null)),this}},{key:"play",value:function(){return this._paused=!1,this._continue()}},{key:"pause",value:function(){return this._nextFrame=null,this._paused=!0,this}},{key:"stop",value:function(){return this.seek(-this._time),this.pause()}},{key:"finish",value:function(){return this.seek(1/0),this.pause()}},{key:"speed",value:function(t){return null==t?this._speed:(this._speed=t,this)}},{key:"reverse",value:function(t){var e=this.speed();if(null==t)return this.speed(-e);var n=Math.abs(e);return this.speed(t?n:-n)}},{key:"seek",value:function(t){return this._time+=t,this._continue()}},{key:"time",value:function(t){return null==t?this._time:(this._time=t,this)}},{key:"persist",value:function(t){return null==t?this._persist:(this._persist=t,this)}},{key:"source",value:function(t){return null==t?this._timeSource:(this._timeSource=t,this)}},{key:"_step",value:function(){if(!this._paused){var t=this._timeSource(),e=t-this._lastSourceTime,n=this._speed*e+(this._time-this._lastStepTime);this._lastSourceTime=t,this._time+=n,this._lastStepTime=this._time;for(var i=!1,r=0,s=this._order.length;r<s;r++){var u=this._runners[this._order[r]],o=u.runner,a=n,h=this._time-u.start;if(h<0)i=!0;else if(h<a&&(a=h),o.active())if(o.step(a).done){if(!0!==u.persist){o.duration()-o.time()+this._time+this._persist<this._time&&(delete this._runners[this._order[r]],this._order.splice(r--,1)&&--s,o.timeline(null))}}else i=!0}return this._nextFrame=i?Et.frame(this._step.bind(this)):null,this}}},{key:"_continue",value:function(){return this._paused||this._nextFrame||(this._nextFrame=Et.frame(this._step.bind(this))),this}},{key:"active",value:function(){return!!this._nextFrame}}]),t}();at({Element:{timeline:function(){return this._timeline=this._timeline||new Ve,this._timeline}}});var Qe=function(){function s(t){o(this,s),this.id=s.id++,t="function"==typeof(t=null==t?be.duration:t)?new ze(t):t,this._element=null,this._timeline=null,this.done=!1,this._queue=[],this._duration="number"==typeof t&&t,this._isDeclarative=t instanceof ze,this._stepper=this._isDeclarative?t:new De,this._history={},this.enabled=!0,this._time=0,this._last=0,this.transforms=new Se,this.transformId=1,this._haveReversed=!1,this._reverse=!1,this._loopsDone=0,this._swing=!1,this._wait=0,this._times=1}return a(s,[{key:"element",value:function(t){return null==t?this._element:((this._element=t)._prepareRunner(),this)}},{key:"timeline",value:function(t){return void 0===t?this._timeline:(this._timeline=t,this)}},{key:"animate",value:function(t,e,n){var i=s.sanitise(t,e,n),r=new s(i.duration);return this._timeline&&r.timeline(this._timeline),this._element&&r.element(this._element),r.loop(i).schedule(e,n)}},{key:"schedule",value:function(t,e,n){if(t instanceof Ve||(n=e,e=t,t=this.timeline()),!t)throw Error("Runner cannot be scheduled without timeline");return t.schedule(this,e,n),this}},{key:"unschedule",value:function(){var t=this.timeline();return t&&t.unschedule(this),this}},{key:"loop",value:function(t,e,n){return"object"===l(t)&&(e=t.swing,n=t.wait,t=t.times),this._times=t||1/0,this._swing=e||!1,this._wait=n||0,this}},{key:"delay",value:function(t){return this.animate(0,t)}},{key:"queue",value:function(t,e,n){return this._queue.push({initialiser:t||ke,runner:e||ke,isTransform:n,initialised:!1,finished:!1}),this.timeline()&&this.timeline()._continue(),this}},{key:"during",value:function(t){return this.queue(null,t)}},{key:"after",value:function(t){return this.on("finish",t)}},{key:"time",value:function(t){if(null==t)return this._time;var e=t-this._time;return this.step(e),this}},{key:"duration",value:function(){return this._times*(this._wait+this._duration)-this._wait}},{key:"loops",value:function(t){var e=this._duration+this._wait;if(null==t){var n=Math.floor(this._time/e),i=(this._time-n*e)/this._duration;return Math.min(n+i,this._times)}var r=t%1,s=e*Math.floor(t)+this._duration*r;return this.time(s)}},{key:"position",value:function(t){var e,n=this._time,r=this._duration,s=this._wait,i=this._times,u=this._swing,o=this._reverse;if(null==t){var a=function(t){var e=u*Math.floor(t%(2*(s+r))/(s+r)),n=e&&!o||!e&&o,i=Math.pow(-1,n)*(t%(s+r))/r+n;return Math.max(Math.min(i,1),0)},h=i*(s+r)-s;return e=n<=0?Math.round(a(1e-5)):n<h?a(n):Math.round(a(h-1e-5)),e}var l=Math.floor(this.loops()),c=u&&l%2==0;return e=l+(c&&!o||o&&c?t:1-t),this.loops(e)}},{key:"progress",value:function(t){return null==t?Math.min(1,this._time/this.duration()):this.time(t*this.duration())}},{key:"step",value:function(t){if(!this.enabled)return this;t=null==t?16:t,this._time+=t;var e=this.position(),n=this._lastPosition!==e&&0<=this._time;this._lastPosition=e;var i=this.duration(),r=(this._lastTime<0&&this._time,this._lastTime<this._time&&this.time>i);this._lastTime=this._time;var s=this._isDeclarative;if(this.done=!s&&!r&&this._time>=i,n||s){this._initialise(n),this.transforms=new Se;var u=this._run(s?t:e)}return this.done=this.done||u&&s,this}},{key:"finish",value:function(){return this.step(1/0)}},{key:"reverse",value:function(t){return this._reverse=null==t?!this._reverse:t,this}},{key:"ease",value:function(t){return this._stepper=new De(t),this}},{key:"active",value:function(t){return null==t?this.enabled:(this.enabled=t,this)}},{key:"_rememberMorpher",value:function(t,e){this._history[t]={morpher:e,caller:this._queue[this._queue.length-1]}}},{key:"_tryRetarget",value:function(t,e){if(this._history[t]){if(!this._history[t].caller.initialised){var n=this._queue.indexOf(this._history[t].caller);return this._queue.splice(n,1),!1}this._history[t].caller.isTransform?this._history[t].caller.isTransform(e):this._history[t].morpher.to(e),this._history[t].caller.finished=!1;var i=this.timeline();return i&&i._continue(),!0}return!1}},{key:"_initialise",value:function(t){if(t||this._isDeclarative)for(var e=0,n=this._queue.length;e<n;++e){var i=this._queue[e],r=this._isDeclarative||!i.initialised&&t;t=!i.finished,r&&t&&(i.initialiser.call(this),i.initialised=!0)}}},{key:"_run",value:function(t){for(var e=!0,n=0,i=this._queue.length;n<i;++n){var r=this._queue[n],s=r.runner.call(this,t);r.finished=r.finished||!0===s,e=e&&r.finished}return e}},{key:"addTransform",value:function(t,e){return this.transforms.lmultiplyO(t),this}},{key:"clearTransform",value:function(){return this.transforms=new Se,this}}],[{key:"sanitise",value:function(t,e,n){var i=1,r=!1,s=0;return e=e||be.delay,n=n||"last","object"!==l(t=t||be.duration)||t instanceof Pe||(e=t.delay||e,n=t.when||n,r=t.swing||r,i=t.times||i,s=t.wait||s,t=t.duration||be.duration),{duration:t,delay:e,swing:r,times:i,wait:s,when:n}}}]),s}();Qe.id=0;var Ue=function t(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:new Se,n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:-1,i=!(2<arguments.length&&void 0!==arguments[2])||arguments[2];o(this,t),this.transforms=e,this.id=n,this.done=i};$([Qe,Ue],{mergeWith:function(t){return new Ue(t.transforms.lmultiply(this.transforms),t.id)}});var $e=function(t,e){return t.lmultiplyO(e)},Je=function(t){return t.transforms};var We=function(){function t(){o(this,t),this.runners=[],this.ids=[]}return a(t,[{key:"add",value:function(t){if(!this.runners.includes(t)){var n=t.id+1,e=this.ids.reduce(function(t,e){return t<e&&e<n?e:t},0),i=this.ids.indexOf(e)+1;return this.ids.splice(i,0,n),this.runners.splice(i,0,t),this}}},{key:"getByID",value:function(t){return this.runners[this.ids.indexOf(t+1)]}},{key:"remove",value:function(t){var e=this.ids.indexOf(t+1);return this.ids.splice(e,1),this.runners.splice(e,1),this}},{key:"merge",value:function(){var n=this,i=null;return this.runners.forEach(function(t,e){i&&t.done&&i.done&&(n.remove(t.id),n.edit(i.id,t.mergeWith(i))),i=t}),this}},{key:"edit",value:function(t,e){var n=this.ids.indexOf(t+1);return this.ids.splice(n,1,t),this.runners.splice(n,1,e),this}},{key:"length",value:function(){return this.ids.length}},{key:"clearBefore",value:function(t){var e=this.ids.indexOf(t+1)||1;return this.ids.splice(0,e,0),this.runners.splice(0,e,new Ue),this}}]),t}(),Ze=0;at({Element:{animate:function(t,e,n){var i=Qe.sanitise(t,e,n),r=this.timeline();return new Qe(i.duration).loop(i).element(this).timeline(r).schedule(e,n)},delay:function(t,e){return this.animate(0,t,e)},_clearTransformRunnersBefore:function(t){this._transformationRunners.clearBefore(t.id)},_currentTransform:function(e){return this._transformationRunners.runners.filter(function(t){return t.id<=e.id}).map(Je).reduce($e,new Se)},addRunner:function(t){this._transformationRunners.add(t),Et.transform_frame(function(){var t=this._transformationRunners.runners.map(Je).reduce($e,new Se);this.transform(t),this._transformationRunners.merge(),1===this._transformationRunners.length()&&(this._frameId=null)}.bind(this),this._frameId)},_prepareRunner:function(){null==this._frameId&&(this._transformationRunners=(new We).add(new Ue(new Se(this))),this._frameId=Ze++)}}}),$(Qe,{attr:function(t,e){return this.styleAttr("attr",t,e)},css:function(t,e){return this.styleAttr("css",t,e)},styleAttr:function(e,n,t){if("object"===l(n))for(var i in t)this.styleAttr(e,i,t[i]);var r=new Fe(this._stepper).to(t);return this.queue(function(){r=r.from(this.element()[e](n))},function(t){return this.element()[e](n,r.at(t)),r.done()}),this},zoom:function(t,e){var n=new Fe(this._stepper).to(new mt(t));return this.queue(function(){n=n.from(this.zoom())},function(t){return this.element().zoom(n.at(t),e),n.done()}),this},transform:function(d,y,v){if(y=d.relative||y,this._isDeclarative&&!y&&this._tryRetarget("transform",d))return this;var p=I(d);v=null!=d.affine?d.affine:null!=v?v:!p;var m,g,w,k,b,x=(new Fe).type(v?Xe:Se).stepper(this._stepper);return this.queue(function(){g=g||this.element(),m=m||X(d,g),b=new Se(y?void 0:g),g.addRunner(this),y||g._clearTransformRunnersBefore(this)},function(t){y||this.clearTransform();var e=new $t(m).transform(g._currentTransform(this)),n=e.x,i=e.y,r=new Se(_({},d,{origin:[n,i]})),s=this._isDeclarative&&w?w:b;if(v){r=r.decompose(n,i),s=s.decompose(n,i);var u=r.rotate,o=s.rotate,a=[u-360,u,u+360],h=a.map(function(t){return Math.abs(t-o)}),l=Math.min.apply(Math,O(h)),c=h.indexOf(l);r.rotate=a[c]}y&&(p||(r.rotate=d.rotate||0),this._isDeclarative&&k&&(s.rotate=k)),x.from(s),x.to(r);var f=x.at(t);return k=f.rotate,w=new Se(f),this.addTransform(w),x.done()},function(t){(t.origin||"center").toString()!==(d.origin||"center").toString()&&(m=X(d,g)),d=_({},t,{origin:m})}),this._isDeclarative&&this._rememberMorpher("transform",x),this},x:function(t,e){return this._queueNumber("x",t)},y:function(t){return this._queueNumber("y",t)},dx:function(t){return this._queueNumberDelta("dx",t)},dy:function(t){return this._queueNumberDelta("dy",t)},_queueNumberDelta:function(e,n){if(n=new mt(n),this._tryRetargetDelta(e,n))return this;var i=new Fe(this._stepper).to(n);return this.queue(function(){var t=this.element()[e]();i.from(t),i.to(t+n)},function(t){return this.element()[e](i.at(t)),i.done()}),this._rememberMorpher(e,i),this},_queueObject:function(e,t){if(this._tryRetarget(e,t))return this;var n=new Fe(this._stepper).to(t);return this.queue(function(){n.from(this.element()[e]())},function(t){return this.element()[e](n.at(t)),n.done()}),this._rememberMorpher(e,n),this},_queueNumber:function(t,e){return this._queueObject(t,new mt(e))},cx:function(t){return this._queueNumber("cx",t)},cy:function(t){return this._queueNumber("cy",t)},move:function(t,e){return this.x(t).y(e)},center:function(t,e){return this.cx(t).cy(e)},size:function(t,e){var n;return t&&e||(n=this._element.bbox()),t||(t=n.width/n.height*e),e||(e=n.height/n.width*t),this.width(t).height(e)},width:function(t){return this._queueNumber("width",t)},height:function(t){return this._queueNumber("height",t)},plot:function(t,e,n,i){return 4===arguments.length?this.plot([t,e,n,i]):this._queueObject("plot",new this._element.MorphArray(t))},leading:function(t){return this._queueNumber("leading",t)},viewbox:function(t,e,n,i){return this._queueObject("viewbox",new Box(t,e,n,i))},update:function(t){return"object"!==l(t)?this.update({offset:t,color:arguments[1],opacity:arguments[2]}):(null!=t.opacity&&this.attr("stop-opacity",t.opacity),null!=t.color&&this.attr("stop-color",t.color),null!=t.offset&&this.attr("offset",t.offset),this)}});var Ke=Object.freeze({EventTarget:pt,Element:wt,Shape:Ot,Parent:_t,Container:At,HtmlNode:jt,Doc:Mt,Defs:Ct,G:St,Animator:Et,Bare:Nt,Circle:Xt,ClipPath:Ht,A:Bt,Ellipse:Gt,Stop:Vt,Gradient:Zt,Image:te,Line:ue,Marker:oe,Mask:ae,Path:ye,Pattern:Kt,Polygon:pe,Polyline:me,Rect:ge,Symbol:we,Text:Ae,TextPath:je,Tspan:Ce,Use:Me,SVGNumber:mt,SVGArray:ne,PathArray:he,PointArray:ie,Matrix:Se,Point:$t,Box:Jt,Color:Te,Morphable:Fe,Queue:Tt,Runner:Qe,Timeline:Ve,Controller:ze,Ease:De,PID:Le,Spring:qe});at("Element",{attr:function(t,e,n){if(null==t){t={},e=this.node.attributes;var i=!0,r=!1,s=void 0;try{for(var u,o=e[Symbol.iterator]();!(i=(u=o.next()).done);i=!0){var a=u.value;t[a.nodeName]=x.test(a.nodeValue)?parseFloat(a.nodeValue):a.nodeValue}}catch(t){r=!0,s=t}finally{try{i||null==o.return||o.return()}finally{if(r)throw s}}return t}if(Array.isArray(t));else if("object"===l(t))for(e in t)this.attr(e,t[e]);else if(null===e)this.node.removeAttribute(t);else{if(null==e)return null==(e=this.node.getAttribute(t))?xe[t]:x.test(e)?parseFloat(e):e;for("fill"!==t&&"stroke"!==t||A.test(e)&&(e=this.doc().defs().image(e));"function"==typeof e.attrHook;)e=e.attrHook(this,t);"number"==typeof e?e=new mt(e):Te.isColor(e)?e=new Te(e):e.constructor===Array&&(e=new ne(e)),"leading"===t?this.leading&&this.leading(e):"string"==typeof n?this.node.setAttributeNS(n,t,e.toString()):this.node.setAttribute(t,e.toString()),!this.rebuild||"font-size"!==t&&"x"!==t||this.rebuild()}return this}}),at("Element",{siblings:function(){return this.parent().children()},position:function(){return this.parent().index(this)},next:function(){return this.siblings()[this.position()+1]},prev:function(){return this.siblings()[this.position()-1]},forward:function(){var t=this.position()+1,e=this.parent();return e.removeElement(this).add(this,t),"function"==typeof e.isRoot&&e.isRoot()&&e.node.appendChild(e.defs().node),this},backward:function(){var t=this.position();return 0<t&&this.parent().removeElement(this).add(this,t-1),this},front:function(){var t=this.parent();return t.node.appendChild(this.node),"function"==typeof t.isRoot&&t.isRoot()&&t.node.appendChild(t.defs().node),this},back:function(){return 0<this.position()&&this.parent().removeElement(this).add(this,0),this},before:function(t){t.remove();var e=this.position();return this.parent().add(t,e),this},after:function(t){t.remove();var e=this.position();return this.parent().add(t,e+1),this}}),at("Element",{data:function(e,t,n){if("object"===l(e))for(t in e)this.data(t,e[t]);else if(arguments.length<2)try{return JSON.parse(this.attr("data-"+e))}catch(t){return this.attr("data-"+e)}else this.attr("data-"+e,null===t?null:!0===n||"string"==typeof t||"number"==typeof t?t:JSON.stringify(t));return this}}),at("Element",{css:function(t,e){var n={};if(0===arguments.length)return this.node.style.cssText.split(/\s*;\s*/).filter(function(t){return!!t.length}).forEach(function(t){var e=t.split(/\s*:\s*/);n[e[0]]=e[1]}),n;if(arguments.length<2){if(Array.isArray(t)){var i=!0,r=!1,s=void 0;try{for(var u,o=t[Symbol.iterator]();!(i=(u=o.next()).done);i=!0){var a=P(u.value);n[a]=this.node.style[a]}}catch(t){r=!0,s=t}finally{try{i||null==o.return||o.return()}finally{if(r)throw s}}return n}if("string"==typeof t)return this.node.style[P(t)];if("object"===l(t))for(name in t)this.node.style[P(name)]=null==t[name]||b.test(t[name])?"":t[name]}return 2===arguments.length&&(this.node.style[P(t)]=null==e||b.test(e)?"":e),this},show:function(){return this.css("display","")},hide:function(){return this.css("display","none")},visible:function(){return"none"!==this.css("display")}}),at("Element",{untransform:function(){return this.attr("transform",null)},matrixify:function(){return(this.attr("transform")||"").split(t).slice(0,-1).map(function(t){var e=t.trim().split("(");return[e[0],e[1].split(j).map(function(t){return parseFloat(t)})]}).reverse().reduce(function(t,e){return"matrix"===e[0]?t.lmultiply(q(e[1])):t[e[0]].apply(t,e[1])},new Se)},toParent:function(t){if(this===t)return this;var e=this.screenCTM(),n=t.screenCTM().inverse();return this.addTo(t).untransform().transform(n.multiply(e)),this},toDoc:function(){return this.toParent(this.doc())},transform:function(t,e){if(null==t||"string"==typeof t){var n=new Se(this).decompose();return n[t]||n}I(t)||(t=_({},t,{origin:X(t,this)}));var i=new Se(!0===e?this:e||!1).transform(t);return this.attr("transform",i)}}),at("Element",{remember:function(t,e){if("object"===l(t))for(var n in t)this.remember(n,t[n]);else{if(1===arguments.length)return this.memory()[t];this.memory()[t]=e}return this},forget:function(){if(0===arguments.length)this._memory={};else for(var t=arguments.length-1;0<=t;t--)delete this.memory()[arguments[t]];return this},memory:function(){return this._memory=this._memory||{}}});var tn={stroke:["color","width","opacity","linecap","linejoin","miterlimit","dasharray","dashoffset"],fill:["color","opacity","rule"],prefix:function(t,e){return"color"===e?t:t+"-"+e}};["fill","stroke"].forEach(function(e){var n,t={};t[e]=function(t){if(void 0===t)return this;if("string"==typeof t||Te.isRgb(t)||t&&"function"==typeof t.fill)this.attr(e,t);else for(n=tn[e].length-1;0<=n;n--)null!=t[tn[e][n]]&&this.attr(tn.prefix(e,tn[e][n]),t[tn[e][n]]);return this},at(["Element","Runner"],t)}),at(["Element","Runner"],{matrix:function(t,e,n,i,r,s){return null==t?new Se(this):this.attr("transform",new Se(t,e,n,i,r,s))},rotate:function(t,e,n){return this.transform({rotate:t,ox:e,oy:n},!0)},skew:function(t,e,n,i){return 1===arguments.length||3===arguments.length?this.transform({skew:t,ox:e,oy:n},!0):this.transform({skew:[t,e],ox:n,oy:i},!0)},shear:function(t,e,n){return this.transform({shear:t,ox:e,oy:n},!0)},scale:function(t,e,n,i){return 1===arguments.length||3===arguments.length?this.transform({scale:t,ox:e,oy:n},!0):this.transform({scale:[t,e],ox:n,oy:i},!0)},translate:function(t,e){return this.transform({translate:[t,e]},!0)},relative:function(t,e){return this.transform({relative:[t,e]},!0)},flip:function(t,e){var n="string"==typeof t?t:(isFinite(t),"both"),i="both"===t&&isFinite(e)?[e,e]:"x"===t?[e,0]:"y"===t?[0,e]:isFinite(t)?[t,t]:[0,0];this.transform({flip:n,origin:i},!0)},opacity:function(t){return this.attr("opacity",t)},dx:function(t){return this.x(new mt(t).plus(this instanceof Qe?0:this.x()),!0)},dy:function(t){return this.y(new mt(t).plus(this instanceof Qe?0:this.y()),!0)},dmove:function(t,e){return this.dx(t).dy(e)}}),at("radius",{radius:function(t,e){var n=(this._element||this).type;return"radialGradient"===n||"radialGradient"===n?this.attr("r",new mt(t)):this.rx(t).ry(null==e?t:e)}}),at("Path",{length:function(){return this.node.getTotalLength()},pointAt:function(t){return new $t(this.node.getPointAtLength(t))}}),at(["Parent","Runner"],{font:function(t,e){if("object"===l(t))for(e in t)this.font(e,t[e]);return"leading"===t?this.leading(e):"anchor"===t?this.attr("text-anchor",e):"size"===t||"family"===t||"weight"===t||"stretch"===t||"variant"===t||"style"===t?this.attr("font-"+t,e):this.attr(t,e)}});var en=$;function nn(t){return K(t)}return en([Mt,we,te,Kt,oe],ht("viewbox")),en([ue,me,pe,ye],ht("marker")),en(Ae,ht("Text")),en(ye,ht("Path")),en(Ct,ht("Defs")),en([Ae,Ce],ht("Tspan")),en([ge,Gt,Xt,Zt],ht("radius")),en(pt,ht("EventTarget")),en(wt,ht("Element")),en(wt,ht("Parent")),en(At,ht("Container")),function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:[];He.push.apply(He,O([].concat(t)))}([mt,Te,Jt,Se,ne,ie,he]),$(He,{to:function(t,e){return(new Fe).type(this.constructor).from(this.valueOf()).to(t,e)},fromArray:function(t){return this.init(t),this}}),Object.assign(nn,Ke),Object.assign(nn,J),Object.assign(nn,ut),nn.utils=xt,nn.regex=e,(nn.get=nn).find=Yt,Object.assign(nn,V),nn.easing=Ne,Object.assign(nn,vt),nn.TransformBag=Xe,nn.ObjectBag=Ye,nn.NonMorphable=Ie,nn.parser=Ut,nn.defaults=_e,nn}(); +var SVG=function(){"use strict";function l(t){return(l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}function a(t,e,n){return e&&i(t.prototype,e),n&&i(t,n),t}function _(r){for(var t=1;t<arguments.length;t++){var s=null!=arguments[t]?arguments[t]:{},e=Object.keys(s);"function"==typeof Object.getOwnPropertySymbols&&(e=e.concat(Object.getOwnPropertySymbols(s).filter(function(t){return Object.getOwnPropertyDescriptor(s,t).enumerable}))),e.forEach(function(t){var e,n,i;e=r,i=s[n=t],n in e?Object.defineProperty(e,n,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[n]=i})}return r}function r(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&n(t,e)}function u(t){return(u=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function n(t,e){return(n=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function s(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function h(t,e){return!e||"object"!=typeof e&&"function"!=typeof e?s(t):e}function c(t,e,n){return(c="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,n){var i=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=u(t)););return t}(t,e);if(i){var r=Object.getOwnPropertyDescriptor(i,e);return r.get?r.get.call(n):r.value}})(t,e,n||t)}function f(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=[],i=!0,r=!1,s=void 0;try{for(var u,o=t[Symbol.iterator]();!(i=(u=o.next()).done)&&(n.push(u.value),!e||n.length!==e);i=!0);}catch(t){r=!0,s=t}finally{try{i||null==o.return||o.return()}finally{if(r)throw s}}return n}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}function O(t){return function(t){if(Array.isArray(t)){for(var e=0,n=new Array(t.length);e<t.length;e++)n[e]=t[e];return n}}(t)||function(t){if(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t))return Array.from(t)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}var d=function(){function e(t){o(this,e)}return a(e,[{key:"is",value:function(t){return this.tags.includes(t)}}]),e}(),v=/^([+-]?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?)([a-z%]*)$/i,y=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i,p=/rgb\((\d+),(\d+),(\d+)\)/,m=/(#[a-z0-9\-_]+)/i,t=/\)\s*,?\s*/,g=/\s/g,w=/^#[a-f0-9]{3,6}$/i,k=/^rgb\(/,b=/^(\s+)?$/,x=/^[+-]?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,A=/\.(jpg|jpeg|png|gif|svg)(\?[^=]+.*)?/i,C=/[\s,]+/,j=/([^e])-/gi,M=/[MLHVCSQTAZ]/gi,S=/[MLHVCSQTAZ]/i,T=/((\d?\.\d+(?:e[+-]?\d+)?)((?:\.\d+(?:e[+-]?\d+)?)+))+/gi,E=/\./g,e=Object.freeze({numberAndUnit:v,hex:y,rgb:p,reference:m,transforms:t,whitespace:g,isHex:w,isRgb:k,isCss:/[^:]+:[^;]+;?/,isBlank:b,isNumber:x,isPercent:/^-?[\d.]+%$/,isImage:A,delimiter:C,hyphen:j,pathLetters:M,isPathLetter:S,numbersWithDots:T,dots:E});function N(t,e,n,i){return n+i.replace(E," .")}function D(t){return t.toLowerCase().replace(/-(.)/g,function(t,e){return e.toUpperCase()})}function P(t){return t.charAt(0).toUpperCase()+t.slice(1)}function z(t){var e=t.toString(16);return 1===e.length?"0"+e:e}function R(t,e,n){if(null==e||null==n){var i=t.bbox();null==e?e=i.width/i.height*n:null==n&&(n=i.height/i.width*e)}return{width:e,height:n}}function q(t){return{a:t[0],b:t[1],c:t[2],d:t[3],e:t[4],f:t[5]}}var L="abcdef".split("");function F(t,e,n){return Math.abs(e-t)<(n||1e-6)}function I(t){return null!=t.a||null!=t.b||null!=t.c||null!=t.d||null!=t.e||null!=t.f}function X(t,e){var n,i,r=t.origin;if("string"==typeof r||null==r){var s=(r||"center").toLowerCase().trim(),u=e.bbox(),o=u.height,a=u.width,h=u.x,l=u.y,c=s.includes("left")?h:s.includes("right")?h+a:h+a/2,f=s.includes("top")?l:s.includes("bottom")?l+o:l+o/2;n=null!=t.ox?t.ox:c,i=null!=t.oy?t.oy:f}else n=r[0],i=r[1];return[n,i]}var Y="http://www.w3.org/2000/svg",H="http://www.w3.org/2000/xmlns/",G="http://www.w3.org/1999/xlink",V="http://svgjs.com/svgjs",B=Object.freeze({ns:Y,xmlns:H,xlink:G,svgjs:V});function Q(t,e){return e||U(t)}function U(t){return document.createElementNS(Y,t)}function $(t,e){var n,i;for(i=(t=Array.isArray(t)?t:[t]).length-1;0<=i;i--)for(n in e)t[i].prototype[n]=e[n]}var W=Object.freeze({nodeOrNew:Q,makeNode:U,extend:$,addFactory:function(t,e){$(t,e)},invent:function(e){var t="function"==typeof e.create?e.create:function(t){e.inherit.call(this,t||U(e.create))};return e.inherit&&(t.prototype=new e.inherit,t.prototype.constructor=t),e.extend&&$(t,e.extend),e.construct&&$(e.parent||Container,e.construct),t}}),J={},Z=Symbol("root");function K(t){if(t instanceof d)return t;if("object"===l(t))return tt(t);if(null==t)return new J[Z];if("string"==typeof t&&"<"!==t.charAt(0))return tt(document.querySelector(t));var e=U("svg");return e.innerHTML=t,t=tt(e.firstChild)}function tt(t){return t?t.instance instanceof d?t.instance:t instanceof window.SVGElement?"svg"===t.nodeName?new J[Z](t):"linearGradient"===t.nodeName||"radialGradient"===t.nodeName?new J.Gradient(t):J[P(t.nodeName)]?new(J[P(t.nodeName)])(t):new J.Bare(t):new J.HtmlNode(t):null}function et(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:t.name,n=2<arguments.length&&void 0!==arguments[2]&&arguments[2];return J[e]=t,n&&(J[Z]=t),t}function nt(t){return J[t]}var it=1e3;function rt(t){return"Svgjs"+P(t)+it++}function st(t){for(var e=t.children.length-1;0<=e;e--)st(t.children[e]);return t.id?tt(t).id(rt(t.nodeName)):tt(t)}var ut=Object.freeze({root:Z,makeInstance:K,adopt:tt,register:et,getClass:nt,eid:rt,assignNewId:st}),ot={};function at(t,e){if(Array.isArray(t)){var n=!0,i=!1,r=void 0;try{for(var s,u=t[Symbol.iterator]();!(n=(s=u.next()).done);n=!0){at(s.value,e)}}catch(t){i=!0,r=t}finally{try{n||null==u.return||u.return()}finally{if(i)throw r}}}else if("object"!=l(t))ot[t]=Object.assign(ot[t]||{},e);else for(var o=Object.entries(t),a=0;a<o.length;a++){var h=f(o[a],2);at(h[0],h[1])}}function ht(t){return ot[t]||{}}var lt=0;function ct(t){var e=K(t).getEventHolder();return e.events||(e.events={}),e.events}function ft(t){return K(t).getEventTarget()}function dt(t,e,i,n,r){var s=i.bind(n||t),u=ct(t),o=ft(t);e=Array.isArray(e)?e:e.split(C),i._svgjsListenerId||(i._svgjsListenerId=++lt),e.forEach(function(t){var e=t.split(".")[0],n=t.split(".")[1]||"*";u[e]=u[e]||{},u[e][n]=u[e][n]||{},u[e][n][i._svgjsListenerId]=s,o.addEventListener(e,s,r||!1)})}function vt(u,t,o,a){var h=ct(u),l=ft(u);("function"!=typeof o||(o=o._svgjsListenerId))&&(t=Array.isArray(t)?t:(t||"").split(C)).forEach(function(t){var e,n,i,r=t&&t.split(".")[0],s=t&&t.split(".")[1];if(o)h[r]&&h[r][s||"*"]&&(l.removeEventListener(r,h[r][s||"*"][o],a||!1),delete h[r][s||"*"][o]);else if(r&&s){if(h[r]&&h[r][s]){for(n in h[r][s])vt(l,[r,s].join("."),n);delete h[r][s]}}else if(s)for(t in h)for(e in h[t])s===e&&vt(l,[t,s].join("."));else if(r){if(h[r]){for(e in h[r])vt(l,[r,e].join("."));delete h[r]}}else{for(t in h)vt(l,t);(i=K(u).getEventHolder()).events&&(i.events={})}})}function yt(t,e,n){var i=ft(t);return e instanceof window.Event||(e=new window.CustomEvent(e,{detail:n,cancelable:!0})),i.dispatchEvent(e),e}var pt=Object.freeze({on:dt,off:vt,dispatch:yt}),mt=function(t){function i(){var t,e=(0<arguments.length&&void 0!==arguments[0]?arguments[0]:{}).events,n=void 0===e?{}:e;return o(this,i),(t=h(this,u(i).call(this))).events=n,t}return r(i,d),a(i,[{key:"addEventListener",value:function(){}},{key:"on",value:function(t,e,n,i){return dt(this,t,e,n,i),this}},{key:"off",value:function(t,e){return vt(this,t,e),this}},{key:"dispatch",value:function(t,e){return yt(this,t,e)}},{key:"dispatchEvent",value:function(t){var e=this.getEventHolder().events;if(!e)return!0;var n=e[t.type];for(var i in n)for(var r in n[i])n[i][r](t);return!t.defaultPrevented}},{key:"fire",value:function(t,e){return this.dispatch(t,e),this}},{key:"getEventHolder",value:function(){return this}},{key:"getEventTarget",value:function(){return this}},{key:"removeEventListener",value:function(){}}]),i}();function gt(t,e){var n,i=t.length,r=[];for(n=0;n<i;n++)r.push(e(t[n]));return r}function wt(t){return t%360*Math.PI/180}$(mt,["click","dblclick","mousedown","mouseup","mouseover","mouseout","mousemove","mouseenter","mouseleave","touchstart","touchmove","touchleave","touchend","touchcancel"].reduce(function(t,e){return t[e]=function(t){return null===t?vt(this,e):dt(this,e,t),this},t},{}));var kt=Object.freeze({map:gt,filter:function(t,e){var n,i=t.length,r=[];for(n=0;n<i;n++)e(t[n])&&r.push(t[n]);return r},radians:wt,degrees:function(t){return 180*t/Math.PI%360},filterSVGElements:function(t){return this.filter(t,function(t){return t instanceof window.SVGElement})}});function bt(){}var xt={duration:400,ease:">",delay:0},_t={"fill-opacity":1,"stroke-opacity":1,"stroke-width":0,"stroke-linejoin":"miter","stroke-linecap":"butt",fill:"#000000",stroke:"#000000",opacity:1,x:0,y:0,cx:0,cy:0,width:0,height:0,r:0,rx:0,ry:0,offset:0,"stop-opacity":1,"stop-color":"#000000","font-size":16,"font-family":"Helvetica, Arial, sans-serif","text-anchor":"start"},Ot=Object.freeze({noop:bt,timeline:xt,attrs:_t}),At=function(){function t(){o(this,t),this.init.apply(this,arguments)}return a(t,[{key:"init",value:function(t,e,n){var i,r;(this.r=0,this.g=0,this.b=0,t)&&("string"==typeof t?k.test(t)?(i=p.exec(t.replace(g,"")),this.r=parseInt(i[1]),this.g=parseInt(i[2]),this.b=parseInt(i[3])):w.test(t)&&(i=y.exec(4===(r=t).length?["#",r.substring(1,2),r.substring(1,2),r.substring(2,3),r.substring(2,3),r.substring(3,4),r.substring(3,4)].join(""):r),this.r=parseInt(i[1],16),this.g=parseInt(i[2],16),this.b=parseInt(i[3],16)):Array.isArray(t)?(this.r=t[0],this.g=t[1],this.b=t[2]):"object"===l(t)?(this.r=t.r,this.g=t.g,this.b=t.b):3===arguments.length&&(this.r=t,this.g=e,this.b=n))}},{key:"toString",value:function(){return this.toHex()}},{key:"toArray",value:function(){return[this.r,this.g,this.b]}},{key:"toHex",value:function(){return"#"+z(Math.round(this.r))+z(Math.round(this.g))+z(Math.round(this.b))}},{key:"toRgb",value:function(){return"rgb("+[this.r,this.g,this.b].join()+")"}},{key:"brightness",value:function(){return this.r/255*.3+this.g/255*.59+this.b/255*.11}}],[{key:"test",value:function(t){return t+="",w.test(t)||k.test(t)}},{key:"isRgb",value:function(t){return t&&"number"==typeof t.r&&"number"==typeof t.g&&"number"==typeof t.b}},{key:"isColor",value:function(t){return this.isRgb(t)||this.test(t)}}]),t}(),Ct=function(){try{return Function("name","baseClass","_constructor",["baseClass = baseClass || Array","return {","[name]: class extends baseClass {","constructor (...args) {","super(...args)","_constructor && _constructor.apply(this, args)","}","}","}[name]"].join("\n"))}catch(t){return function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:Array,n=2<arguments.length?arguments[2]:void 0,i=function(){e.apply(this,arguments),n&&n.apply(this,arguments)};return(i.prototype=Object.create(e.prototype)).constructor=i}}}(),jt=Ct("SVGArray",Array,function(){this.init.apply(this,arguments)});$(jt,{init:function(){this.length=0,this.push.apply(this,O(this.parse.apply(this,arguments)))},toArray:function(){return Array.prototype.concat.apply([],this)},toString:function(){return this.join(" ")},valueOf:function(){var t=[];return t.push.apply(t,O(this)),t},parse:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:[];return t instanceof Array?t:t.trim().split(C).map(parseFloat)},clone:function(){return new this.constructor(this)},toSet:function(){return new Set(this)}});var Mt=function(){function n(){o(this,n),this.init.apply(this,arguments)}return a(n,[{key:"init",value:function(t,e){e=Array.isArray(t)?t[1]:e,t=Array.isArray(t)?t[0]:t,this.value=0,this.unit=e||"","number"==typeof t?this.value=isNaN(t)?0:isFinite(t)?t:t<0?-34e37:34e37:"string"==typeof t?(e=t.match(v))&&(this.value=parseFloat(e[1]),"%"===e[5]?this.value/=100:"s"===e[5]&&(this.value*=1e3),this.unit=e[5]):t instanceof n&&(this.value=t.valueOf(),this.unit=t.unit)}},{key:"toString",value:function(){return("%"===this.unit?~~(1e8*this.value)/1e6:"s"===this.unit?this.value/1e3:this.value)+this.unit}},{key:"toJSON",value:function(){return this.toString()}},{key:"toArray",value:function(){return[this.value,this.unit]}},{key:"valueOf",value:function(){return this.value}},{key:"plus",value:function(t){return new n(this+(t=new n(t)),this.unit||t.unit)}},{key:"minus",value:function(t){return new n(this-(t=new n(t)),this.unit||t.unit)}},{key:"times",value:function(t){return new n(this*(t=new n(t)),this.unit||t.unit)}},{key:"divide",value:function(t){return new n(this/(t=new n(t)),this.unit||t.unit)}}]),n}();var St=function(t){function n(t){var e;return o(this,n),(e=h(this,u(n).call(this,t))).node=t,e.type=t.nodeName,e}return r(n,mt),a(n,[{key:"add",value:function(t,e){return t=K(t),null==e?this.node.appendChild(t.node):t.node!==this.node.childNodes[e]&&this.node.insertBefore(t.node,this.node.childNodes[e]),this}},{key:"addTo",value:function(t){return K(t).put(this)}},{key:"children",value:function(){return gt(this.node.children,function(t){return tt(t)})}},{key:"clear",value:function(){for(;this.node.hasChildNodes();)this.node.removeChild(this.node.lastChild);return delete this._defs,this}},{key:"clone",value:function(t){this.writeDataToDom();var e=st(this.node.cloneNode(!0));return t?t.add(e):this.after(e),e}},{key:"each",value:function(t,e){var n,i,r=this.children();for(n=0,i=r.length;n<i;n++)t.apply(r[n],[n,r]),e&&r[n].each(t,e);return this}},{key:"first",value:function(){return tt(this.node.firstChild)}},{key:"get",value:function(t){return tt(this.node.childNodes[t])}},{key:"getEventHolder",value:function(){return this.node}},{key:"getEventTarget",value:function(){return this.node}},{key:"has",value:function(t){return 0<=this.index(t)}},{key:"id",value:function(t){return void 0!==t||this.node.id||(this.node.id=rt(this.type)),this.attr("id",t)}},{key:"index",value:function(t){return[].slice.call(this.node.childNodes).indexOf(t.node)}},{key:"last",value:function(){return tt(this.node.lastChild)}},{key:"matches",value:function(t){return e=this.node,n=t,(e.matches||e.matchesSelector||e.msMatchesSelector||e.mozMatchesSelector||e.webkitMatchesSelector||e.oMatchesSelector).call(e,n);var e,n}},{key:"native",value:function(){return this.node}},{key:"parent",value:function(t){var e=this;if(!e.node.parentNode)return null;if(e=tt(e.node.parentNode),!t)return e;for(;e&&e.node instanceof window.SVGElement;){if("string"==typeof t?e.matches(t):e instanceof t)return e;e=tt(e.node.parentNode)}}},{key:"put",value:function(t,e){return this.add(t,e),t}},{key:"putIn",value:function(t){return K(t).add(this)}},{key:"remove",value:function(){return this.parent()&&this.parent().removeElement(this),this}},{key:"removeElement",value:function(t){return this.node.removeChild(t.node),this}},{key:"replace",value:function(t){return this.after(t).remove(),t}},{key:"toString",value:function(){return this.id()}},{key:"svg",value:function(t){var e,n;if(!t)return this.writeDataToDom(),this.node.outerHTML;for((e=document.createElementNS(Y,"svg")).innerHTML=t,n=e.children.length;n--;)this.node.appendChild(e.firstElementChild);return this}},{key:"writeDataToDom",value:function(){return this.each(function(){this.writeDataToDom()}),this}}]),n}();$(St,{attr:function(t,e,n){if(null==t){t={},e=this.node.attributes;var i=!0,r=!1,s=void 0;try{for(var u,o=e[Symbol.iterator]();!(i=(u=o.next()).done);i=!0){var a=u.value;t[a.nodeName]=x.test(a.nodeValue)?parseFloat(a.nodeValue):a.nodeValue}}catch(t){r=!0,s=t}finally{try{i||null==o.return||o.return()}finally{if(r)throw s}}return t}if(Array.isArray(t));else if("object"===l(t))for(e in t)this.attr(e,t[e]);else if(null===e)this.node.removeAttribute(t);else{if(null==e)return null==(e=this.node.getAttribute(t))?_t[t]:x.test(e)?parseFloat(e):e;for("fill"!==t&&"stroke"!==t||A.test(e)&&(e=this.doc().defs().image(e));"function"==typeof e.attrHook;)e=e.attrHook(this,t);"number"==typeof e?e=new Mt(e):At.isColor(e)?e=new At(e):e.constructor===Array&&(e=new jt(e)),"leading"===t?this.leading&&this.leading(e):"string"==typeof n?this.node.setAttributeNS(n,t,e.toString()):this.node.setAttribute(t,e.toString()),!this.rebuild||"font-size"!==t&&"x"!==t||this.rebuild()}return this}});var Tt=nt(Z),Et=function(t){function n(t){var e;return o(this,n),(e=h(this,u(n).call(this,t))).dom={},e.node.instance=s(s(e)),t.hasAttribute("svgjs:data")&&e.setData(JSON.parse(t.getAttribute("svgjs:data"))||{}),e}return r(n,St),a(n,[{key:"center",value:function(t,e){return this.cx(t).cy(e)}},{key:"cx",value:function(t){return null==t?this.x()+this.width()/2:this.x(t-this.width()/2)}},{key:"cy",value:function(t){return null==t?this.y()+this.height()/2:this.y(t-this.height()/2)}},{key:"defs",value:function(){return this.doc().defs()}},{key:"doc",value:function(){var t=this.parent(Tt);return t&&t.doc()}},{key:"getEventHolder",value:function(){return this}},{key:"height",value:function(t){return this.attr("height",t)}},{key:"inside",value:function(t,e){var n=this.bbox();return t>n.x&&e>n.y&&t<n.x+n.width&&e<n.y+n.height}},{key:"move",value:function(t,e){return this.x(t).y(e)}},{key:"parents",value:function(t){var e=[],n=this;do{if(!(n=n.parent(t))||n instanceof nt("HtmlNode"))break;e.push(n)}while(n.parent);return e}},{key:"reference",value:function(t){var e=function(t){var e=(t||"").toString().match(m);if(e)return e[1]}(this.attr(t));return e?K(e):null}},{key:"setData",value:function(t){return this.dom=t,this}},{key:"size",value:function(t,e){var n=R(this,t,e);return this.width(new Mt(n.width)).height(new Mt(n.height))}},{key:"width",value:function(t){return this.attr("width",t)}},{key:"writeDataToDom",value:function(){return this.node.removeAttribute("svgjs:data"),Object.keys(this.dom).length&&this.node.setAttribute("svgjs:data",JSON.stringify(this.dom)),c(u(n.prototype),"writeDataToDom",this).call(this)}},{key:"x",value:function(t){return this.attr("x",t)}},{key:"y",value:function(t){return this.attr("y",t)}}]),n}(),Nt=function(t){function e(){return o(this,e),h(this,u(e).apply(this,arguments))}return r(e,Et),e}(),Dt=function(t){function e(){return o(this,e),h(this,u(e).apply(this,arguments))}return r(e,Et),a(e,[{key:"flatten",value:function(t){return this.each(function(){return this instanceof e?this.flatten(t).ungroup(t):this.toParent(t)}),this.node.firstElementChild||this.remove(),this}},{key:"ungroup",value:function(t){return t=t||this.parent(),this.each(function(){return this.toParent(t)}),this.remove(),this}}]),e}(),Pt=function(t){function e(t){return o(this,e),h(this,u(e).call(this,t,e))}return r(e,St),e}();et(Pt);var zt=function(t){function e(t){return o(this,e),h(this,u(e).call(this,Q("defs",t),e))}return r(e,Dt),a(e,[{key:"flatten",value:function(){return this}},{key:"ungroup",value:function(){return this}}]),e}();et(zt);var Rt=function(t){function n(t){var e;return o(this,n),(e=h(this,u(n).call(this,Q("svg",t),n))).namespace(),e}return r(n,Dt),a(n,[{key:"isRoot",value:function(){return!(this.node.parentNode&&this.node.parentNode instanceof window.SVGElement&&"#document"!==this.node.parentNode.nodeName)}},{key:"doc",value:function(){return this.isRoot()?this:c(u(n.prototype),"doc",this).call(this)}},{key:"namespace",value:function(){return this.isRoot()?this.attr({xmlns:Y,version:"1.1"}).attr("xmlns:xlink",G,H).attr("xmlns:svgjs",V,H):this.doc().namespace()}},{key:"defs",value:function(){return this.isRoot()?tt(this.node.getElementsByTagName("defs")[0])||this.put(new zt):this.doc().defs()}},{key:"parent",value:function(t){return this.isRoot()?"#document"===this.node.parentNode.nodeName?null:tt(this.node.parentNode):c(u(n.prototype),"parent",this).call(this,t)}},{key:"clear",value:function(){for(;this.node.hasChildNodes();)this.node.removeChild(this.node.lastChild);return this}}]),n}();at({Container:{nested:function(){return this.put(new Rt)}}}),et(Rt,"Doc",!0);var qt=function(t){function e(t){return o(this,e),h(this,u(e).call(this,Q("g",t),e))}return r(e,Dt),e}();at({Element:{group:function(){return this.put(new qt)}}}),et(qt);var Lt=function(){function t(){o(this,t),this._first=null,this._last=null}return a(t,[{key:"push",value:function(t){var e=t.next?t:{value:t,next:null,prev:null};return this._last?(e.prev=this._last,this._last.next=e,this._last=e):(this._last=e,this._first=e),e}},{key:"shift",value:function(){var t=this._first;return t?(this._first=t.next,this._first&&(this._first.prev=null),this._last=this._first?this._last:null,t.value):null}},{key:"first",value:function(){return this._first&&this._first.value}},{key:"last",value:function(){return this._last&&this._last.value}},{key:"remove",value:function(t){t.prev&&(t.prev.next=t.next),t.next&&(t.next.prev=t.prev),t===this._last&&(this._last=t.prev),t===this._first&&(this._first=t.next),t.prev=null,t.next=null}}]),t}(),Ft={nextDraw:null,frames:new Lt,timeouts:new Lt,timer:window.performance||window.Date,transforms:[],frame:function(t){var e=Ft.frames.push({run:t});return null===Ft.nextDraw&&(Ft.nextDraw=window.requestAnimationFrame(Ft._draw)),e},transform_frame:function(t,e){Ft.transforms[e]=t},timeout:function(t,e){e=e||0;var n=Ft.timer.now()+e,i=Ft.timeouts.push({run:t,time:n});return null===Ft.nextDraw&&(Ft.nextDraw=window.requestAnimationFrame(Ft._draw)),i},cancelFrame:function(t){Ft.frames.remove(t)},clearTimeout:function(t){Ft.timeouts.remove(t)},_draw:function(t){for(var e=null,n=Ft.timeouts.last();(e=Ft.timeouts.shift())&&(t>=e.time?e.run():Ft.timeouts.push(e),e!==n););for(var i=null,r=Ft.frames.last();i!==r&&(i=Ft.frames.shift());)i.run();Ft.transforms.forEach(function(t){t()}),Ft.nextDraw=Ft.timeouts.first()||Ft.frames.first()?window.requestAnimationFrame(Ft._draw):null}},It=function(t){function e(t){return o(this,e),h(this,u(e).call(this,Q(t,"string"==typeof t?null:t),e))}return r(e,Dt),a(e,[{key:"words",value:function(t){for(;this.node.hasChildNodes();)this.node.removeChild(this.node.lastChild);return this.node.appendChild(document.createTextNode(t)),this}}]),e}();function Xt(t){return null==t?this.cx()-this.rx():this.cx(t+this.rx())}function Yt(t){return null==t?this.cy()-this.ry():this.cy(t+this.ry())}function Ht(t){return null==t?this.attr("cx"):this.attr("cx",t)}function Gt(t){return null==t?this.attr("cy"):this.attr("cy",t)}function Vt(t){return null==t?2*this.rx():this.rx(new Mt(t).divide(2))}function Bt(t){return null==t?2*this.ry():this.ry(new Mt(t).divide(2))}function Qt(t,e){var n=R(this,t,e);return this.rx(new Mt(n.width).divide(2)).ry(new Mt(n.height).divide(2))}et(It),at("Container",{element:function(t,e){return this.put(new It(t,e))}});var Ut=Object.freeze({rx:function(t){return this.attr("rx",t)},ry:function(t){return this.attr("ry",t)},x:Xt,y:Yt,cx:Ht,cy:Gt,width:Vt,height:Bt,size:Qt}),$t=function(t){function e(t){return o(this,e),h(this,u(e).call(this,Q("circle",t),e))}return r(e,Nt),a(e,[{key:"radius",value:function(t){return this.attr("r",t)}},{key:"rx",value:function(t){return this.attr("r",t)}},{key:"ry",value:function(t){return this.rx(t)}}]),e}();function Wt(t,e){return gt((e||document).querySelectorAll(t),function(t){return tt(t)})}$($t,{x:Xt,y:Yt,cx:Ht,cy:Gt,width:Vt,height:Bt,size:Qt}),at({Element:{circle:function(t){return this.put(new $t).radius(new Mt(t).divide(2)).move(0,0)}}}),et($t),at("Dom",{find:function(t){return Wt(t,this.node)}});var Jt=function(t){function e(t){return o(this,e),h(this,u(e).call(this,Q("clipPath",t),e))}return r(e,Dt),a(e,[{key:"remove",value:function(){return this.targets().forEach(function(t){t.unclip()}),c(u(e.prototype),"remove",this).call(this)}},{key:"targets",value:function(){return Wt('svg [clip-path*="'+this.id()+'"]')}}]),e}();at({Container:{clip:function(){return this.defs().put(new Jt)}},Element:{clipWith:function(t){var e=t instanceof Jt?t:this.parent().clip().add(t);return this.attr("clip-path",'url("#'+e.id()+'")')},unclip:function(){return this.attr("clip-path",null)},clipper:function(){return this.reference("clip-path")}}}),et(Jt);var Zt=function(t){function e(t){return o(this,e),h(this,u(e).call(this,Q("a",t),e))}return r(e,Dt),a(e,[{key:"to",value:function(t){return this.attr("href",t,G)}},{key:"target",value:function(t){return this.attr("target",t)}}]),e}();at({Container:{link:function(t){return this.put(new Zt).to(t)}},Element:{linkTo:function(t){var e=new Zt;return"function"==typeof t?t.call(e,e):e.to(t),this.parent().put(e).put(this)}}}),et(Zt);var Kt=function(t){function e(t){return o(this,e),h(this,u(e).call(this,Q("ellipse",t),e))}return r(e,Nt),e}();$(Kt,Ut),at("Container",{ellipse:function(t,e){return this.put(new Kt).size(t,e).move(0,0)}}),et(Kt);var te=function(t){function e(t){return o(this,e),h(this,u(e).call(this,Q("stop",t),e))}return r(e,Et),a(e,[{key:"update",value:function(t){return("number"==typeof t||t instanceof Mt)&&(t={offset:arguments[0],color:arguments[1],opacity:arguments[2]}),null!=t.opacity&&this.attr("stop-opacity",t.opacity),null!=t.color&&this.attr("stop-color",t.color),null!=t.offset&&this.attr("offset",new Mt(t.offset)),this}}]),e}();et(te);var ee=Object.freeze({from:function(t,e){return"radialGradient"===(this._element||this).type?this.attr({fx:new Mt(t),fy:new Mt(e)}):this.attr({x1:new Mt(t),y1:new Mt(e)})},to:function(t,e){return"radialGradient"===(this._element||this).type?this.attr({cx:new Mt(t),cy:new Mt(e)}):this.attr({x2:new Mt(t),y2:new Mt(e)})}});function ne(){if(!ne.nodes){var t=(new Rt).size(2,0).css({opacity:0,position:"absolute",left:"-100%",top:"-100%",overflow:"hidden"}),e=t.path().node;ne.nodes={svg:t,path:e}}if(!ne.nodes.svg.node.parentNode){var n=document.body||document.documentElement;ne.nodes.svg.addTo(n)}return ne.nodes}var ie=function(){function r(t,e,n){var i;o(this,r),n=n||{x:0,y:0},i=Array.isArray(t)?{x:t[0],y:t[1]}:"object"===l(t)?{x:t.x,y:t.y}:{x:t,y:e},this.x=null==i.x?n.x:i.x,this.y=null==i.y?n.y:i.y}return a(r,[{key:"clone",value:function(){return new r(this)}},{key:"native",value:function(){var t=ne().svg.node.createSVGPoint();return t.x=this.x,t.y=this.y,t}},{key:"transform",value:function(t){return new r(t.a*this.x+t.c*this.y+t.e,t.b*this.x+t.d*this.y+t.f)}}]),r}();at({Element:{point:function(t,e){return new ie(t,e).transform(this.screenCTM().inverse())}}});var re=function(){function u(){o(this,u),this.init.apply(this,arguments)}return a(u,[{key:"init",value:function(t){var e;t="string"==typeof t?t.split(C).map(parseFloat):Array.isArray(t)?t:"object"===l(t)?[null!=t.left?t.left:t.x,null!=t.top?t.top:t.y,t.width,t.height]:4===arguments.length?[].slice.call(arguments):[0,0,0,0],this.x=t[0],this.y=t[1],this.width=t[2],this.height=t[3],null==(e=this).x&&(e.x=0,e.y=0,e.width=0,e.height=0),e.w=e.width,e.h=e.height,e.x2=e.x+e.width,e.y2=e.y+e.height,e.cx=e.x+e.width/2,e.cy=e.y+e.height/2}},{key:"merge",value:function(t){var e=Math.min(this.x,t.x),n=Math.min(this.y,t.y);return new u(e,n,Math.max(this.x+this.width,t.x+t.width)-e,Math.max(this.y+this.height,t.y+t.height)-n)}},{key:"transform",value:function(e){var n=1/0,i=-1/0,r=1/0,s=-1/0;return[new ie(this.x,this.y),new ie(this.x2,this.y),new ie(this.x,this.y2),new ie(this.x2,this.y2)].forEach(function(t){t=t.transform(e),n=Math.min(n,t.x),i=Math.max(i,t.x),r=Math.min(r,t.y),s=Math.max(s,t.y)}),new u(n,r,i-n,s-r)}},{key:"addOffset",value:function(){return this.x+=window.pageXOffset,this.y+=window.pageYOffset,this}},{key:"toString",value:function(){return this.x+" "+this.y+" "+this.width+" "+this.height}},{key:"toArray",value:function(){return[this.x,this.y,this.width,this.height]}}]),u}();function se(e){var n,t,i;try{if(n=e(this.node),!((i=n).w||i.h||i.x||i.y||(t=this.node,(document.documentElement.contains||function(t){for(;t.parentNode;)t=t.parentNode;return t===document}).call(document.documentElement,t))))throw new Error("Element not in the dom")}catch(t){try{var r=this.clone(ne().svg).show();n=e(r.node),r.remove()}catch(t){console.warn("Getting a bounding box of this element is not possible")}}return n}at({Element:{bbox:function(){return new re(se.call(this,function(t){return t.getBBox()}))},rbox:function(t){var e=new re(se.call(this,function(t){return t.getBoundingClientRect()}));return t?e.transform(t.screenCTM().inverse()):e.addOffset()}},viewbox:{viewbox:function(t,e,n,i){return null==t?new re(this.attr("viewBox")):this.attr("viewBox",new re(t,e,n,i))}}});var ue=function(t){function i(t){return o(this,i),h(this,u(i).call(this,Q(t+"Gradient","string"==typeof t?null:t),i))}return r(i,Dt),a(i,[{key:"stop",value:function(t,e,n){return this.put(new te).update(t,e,n)}},{key:"update",value:function(t){return this.clear(),"function"==typeof t&&t.call(this,this),this}},{key:"url",value:function(){return"url(#"+this.id()+")"}},{key:"toString",value:function(){return this.url()}},{key:"attr",value:function(t,e,n){return"transform"===t&&(t="gradientTransform"),c(u(i.prototype),"attr",this).call(this,t,e,n)}},{key:"targets",value:function(){return find('svg [fill*="'+this.id()+'"]')}},{key:"bbox",value:function(){return new re}}]),i}();$(ue,ee),at({Container:{gradient:function(t,e){return this.defs().gradient(t,e)}},Defs:{gradient:function(t,e){return this.put(new ue(t)).update(e)}}}),et(ue);var oe=function(t){function i(t){return o(this,i),h(this,u(i).call(this,Q("pattern",t),i))}return r(i,Dt),a(i,[{key:"url",value:function(){return"url(#"+this.id()+")"}},{key:"update",value:function(t){return this.clear(),"function"==typeof t&&t.call(this,this),this}},{key:"toString",value:function(){return this.url()}},{key:"attr",value:function(t,e,n){return"transform"===t&&(t="patternTransform"),c(u(i.prototype),"attr",this).call(this,t,e,n)}},{key:"targets",value:function(){return find('svg [fill*="'+this.id()+'"]')}},{key:"bbox",value:function(){return new re}}]),i}();at({Container:{pattern:function(t,e,n){return this.defs().pattern(t,e,n)}},Defs:{pattern:function(t,e,n){return this.put(new oe).update(n).attr({x:0,y:0,width:t,height:e,patternUnits:"userSpaceOnUse"})}}}),et(oe);var ae=function(t){function e(t){return o(this,e),h(this,u(e).call(this,Q("image",t),e))}return r(e,Nt),a(e,[{key:"load",value:function(n,i){if(!n)return this;var r=new window.Image;return dt(r,"load",function(t){var e=this.parent(oe);0===this.width()&&0===this.height()&&this.size(r.width,r.height),e instanceof oe&&0===e.width()&&0===e.height()&&e.size(this.width(),this.height()),"function"==typeof i&&i.call(this,{width:r.width,height:r.height,ratio:r.width/r.height,url:n})},this),dt(r,"load error",function(){vt(r)}),this.attr("href",r.src=n,G)}},{key:"attrHook",value:function(t){var e=this;return t.doc().defs().pattern(0,0,function(t){t.add(e)})}}]),e}();at({Container:{image:function(t,e){return this.put(new ae).size(0,0).load(t,e)}}}),et(ae);var he=Ct("PointArray",jt);$(he,{toString:function(){for(var t=0,e=this.length,n=[];t<e;t++)n.push(this[t].join(","));return n.join(" ")},toLine:function(){return{x1:this[0][0],y1:this[0][1],x2:this[1][0],y2:this[1][1]}},at:function(t){if(!this.destination)return this;for(var e=0,n=this.length,i=[];e<n;e++)i.push([this[e][0]+(this.destination[e][0]-this[e][0])*t,this[e][1]+(this.destination[e][1]-this[e][1])*t]);return new he(i)},parse:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:[[0,0]],e=[];if(t instanceof Array){if(t[0]instanceof Array)return t}else t=t.trim().split(C).map(parseFloat);t.length%2!=0&&t.pop();for(var n=0,i=t.length;n<i;n+=2)e.push([t[n],t[n+1]]);return e},move:function(t,e){var n=this.bbox();if(t-=n.x,e-=n.y,!isNaN(t)&&!isNaN(e))for(var i=this.length-1;0<=i;i--)this[i]=[this[i][0]+t,this[i][1]+e];return this},size:function(t,e){var n,i=this.bbox();for(n=this.length-1;0<=n;n--)i.width&&(this[n][0]=(this[n][0]-i.x)*t/i.width+i.x),i.height&&(this[n][1]=(this[n][1]-i.y)*e/i.height+i.y);return this},bbox:function(){var e=-1/0,n=-1/0,i=1/0,r=1/0;return this.forEach(function(t){e=Math.max(t[0],e),n=Math.max(t[1],n),i=Math.min(t[0],i),r=Math.min(t[1],r)}),{x:i,y:r,width:e-i,height:n-r}}});var le=he;var ce=Object.freeze({MorphArray:le,x:function(t){return null==t?this.bbox().x:this.move(t,this.bbox().y)},y:function(t){return null==t?this.bbox().y:this.move(this.bbox().x,t)},width:function(t){var e=this.bbox();return null==t?e.width:this.size(t,e.height)},height:function(t){var e=this.bbox();return null==t?e.height:this.size(e.width,t)}}),fe=function(t){function e(t){return o(this,e),h(this,u(e).call(this,Q("line",t),e))}return r(e,Nt),a(e,[{key:"array",value:function(){return new he([[this.attr("x1"),this.attr("y1")],[this.attr("x2"),this.attr("y2")]])}},{key:"plot",value:function(t,e,n,i){return null==t?this.array():(t=void 0!==e?{x1:t,y1:e,x2:n,y2:i}:new he(t).toLine(),this.attr(t))}},{key:"move",value:function(t,e){return this.attr(this.array().move(t,e).toLine())}},{key:"size",value:function(t,e){var n=R(this,t,e);return this.attr(this.array().size(n.width,n.height).toLine())}}]),e}();$(fe,ce),at({Container:{line:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return fe.prototype.plot.apply(this.put(new fe),null!=e[0]?e:[0,0,0,0])}}}),et(fe);var de=function(t){function e(t){return o(this,e),h(this,u(e).call(this,Q("marker",t),e))}return r(e,Dt),a(e,[{key:"width",value:function(t){return this.attr("markerWidth",t)}},{key:"height",value:function(t){return this.attr("markerHeight",t)}},{key:"ref",value:function(t,e){return this.attr("refX",t).attr("refY",e)}},{key:"update",value:function(t){return this.clear(),"function"==typeof t&&t.call(this,this),this}},{key:"toString",value:function(){return"url(#"+this.id()+")"}}]),e}();at({Container:{marker:function(t,e,n){return this.defs().marker(t,e,n)}},Defs:{marker:function(t,e,n){return this.put(new de).size(t,e).ref(t/2,e/2).viewbox(0,0,t,e).attr("orient","auto").update(n)}},marker:{marker:function(t,e,n,i){var r=["marker"];return"all"!==t&&r.push(t),r=r.join("-"),t=e instanceof de?e:this.defs().marker(e,n,i),this.attr(r,t)}}}),et(de);var ve=function(t){function e(t){return o(this,e),h(this,u(e).call(this,Q("mask",t),e))}return r(e,Dt),a(e,[{key:"remove",value:function(){return this.targets().forEach(function(t){t.unmask()}),c(u(e.prototype),"remove",this).call(this)}},{key:"targets",value:function(){return Wt('svg [mask*="'+this.id()+'"]')}}]),e}();at({Container:{mask:function(){return this.defs().put(new ve)}},Element:{maskWith:function(t){var e=t instanceof ve?t:this.parent().mask().add(t);return this.attr("mask",'url("#'+e.id()+'")')},unmask:function(){return this.attr("mask",null)},masker:function(){return this.reference("mask")}}}),et(ve);for(var ye=Ct("PathArray",jt),pe={M:function(t,e,n){return e.x=n.x=t[0],e.y=n.y=t[1],["M",e.x,e.y]},L:function(t,e){return e.x=t[0],e.y=t[1],["L",t[0],t[1]]},H:function(t,e){return e.x=t[0],["H",t[0]]},V:function(t,e){return e.y=t[0],["V",t[0]]},C:function(t,e){return e.x=t[4],e.y=t[5],["C",t[0],t[1],t[2],t[3],t[4],t[5]]},S:function(t,e){return e.x=t[2],e.y=t[3],["S",t[0],t[1],t[2],t[3]]},Q:function(t,e){return e.x=t[2],e.y=t[3],["Q",t[0],t[1],t[2],t[3]]},T:function(t,e){return e.x=t[0],e.y=t[1],["T",t[0],t[1]]},Z:function(t,e,n){return e.x=n.x,e.y=n.y,["Z"]},A:function(t,e){return e.x=t[5],e.y=t[6],["A",t[0],t[1],t[2],t[3],t[4],t[5],t[6]]}},me="mlhvqtcsaz".split(""),ge=0,we=me.length;ge<we;++ge)pe[me[ge]]=function(s){return function(t,e,n){if("H"===s)t[0]=t[0]+e.x;else if("V"===s)t[0]=t[0]+e.y;else if("A"===s)t[5]=t[5]+e.x,t[6]=t[6]+e.y;else for(var i=0,r=t.length;i<r;++i)t[i]=t[i]+(i%2?e.y:e.x);return pe[s](t,e,n)}}(me[ge].toUpperCase());$(ye,{toString:function(){return function(t){for(var e=0,n=t.length,i="";e<n;e++)i+=t[e][0],null!=t[e][1]&&(i+=t[e][1],null!=t[e][2]&&(i+=" ",i+=t[e][2],null!=t[e][3]&&(i+=" ",i+=t[e][3],i+=" ",i+=t[e][4],null!=t[e][5]&&(i+=" ",i+=t[e][5],i+=" ",i+=t[e][6],null!=t[e][7]&&(i+=" ",i+=t[e][7])))));return i+" "}(this)},move:function(t,e){var n=this.bbox();if(t-=n.x,e-=n.y,!isNaN(t)&&!isNaN(e))for(var i,r=this.length-1;0<=r;r--)"M"===(i=this[r][0])||"L"===i||"T"===i?(this[r][1]+=t,this[r][2]+=e):"H"===i?this[r][1]+=t:"V"===i?this[r][1]+=e:"C"===i||"S"===i||"Q"===i?(this[r][1]+=t,this[r][2]+=e,this[r][3]+=t,this[r][4]+=e,"C"===i&&(this[r][5]+=t,this[r][6]+=e)):"A"===i&&(this[r][6]+=t,this[r][7]+=e);return this},size:function(t,e){var n,i,r=this.bbox();for(n=this.length-1;0<=n;n--)"M"===(i=this[n][0])||"L"===i||"T"===i?(this[n][1]=(this[n][1]-r.x)*t/r.width+r.x,this[n][2]=(this[n][2]-r.y)*e/r.height+r.y):"H"===i?this[n][1]=(this[n][1]-r.x)*t/r.width+r.x:"V"===i?this[n][1]=(this[n][1]-r.y)*e/r.height+r.y:"C"===i||"S"===i||"Q"===i?(this[n][1]=(this[n][1]-r.x)*t/r.width+r.x,this[n][2]=(this[n][2]-r.y)*e/r.height+r.y,this[n][3]=(this[n][3]-r.x)*t/r.width+r.x,this[n][4]=(this[n][4]-r.y)*e/r.height+r.y,"C"===i&&(this[n][5]=(this[n][5]-r.x)*t/r.width+r.x,this[n][6]=(this[n][6]-r.y)*e/r.height+r.y)):"A"===i&&(this[n][1]=this[n][1]*t/r.width,this[n][2]=this[n][2]*e/r.height,this[n][6]=(this[n][6]-r.x)*t/r.width+r.x,this[n][7]=(this[n][7]-r.y)*e/r.height+r.y);return this},equalCommands:function(t){var e,n,i;for(t=new ye(t),i=this.length===t.length,e=0,n=this.length;i&&e<n;e++)i=this[e][0]===t[e][0];return i},morph:function(t){return t=new ye(t),this.equalCommands(t)?this.destination=t:this.destination=null,this},at:function(t){if(!this.destination)return this;var e,n,i,r,s=this,u=this.destination.value,o=[],a=new ye;for(e=0,n=s.length;e<n;e++){for(o[e]=[s[e][0]],i=1,r=s[e].length;i<r;i++)o[e][i]=s[e][i]+(u[e][i]-s[e][i])*t;"A"===o[e][0]&&(o[e][4]=+(0!==o[e][4]),o[e][5]=+(0!==o[e][5]))}return a.value=o,a},parse:function(){var t,e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:[["M",0,0]];if(e instanceof ye)return e;var n={M:2,L:2,H:1,V:1,C:6,S:4,Q:4,T:2,A:7,Z:0};e="string"==typeof e?e.replace(T,N).replace(M," $& ").replace(j,"$1 -").trim().split(C):e.reduce(function(t,e){return[].concat.call(t,e)},[]);for(var i=[],r=new ie,s=new ie,u=0,o=e.length;S.test(e[u])?(t=e[u],++u):"M"===t?t="L":"m"===t&&(t="l"),i.push(pe[t].call(null,e.slice(u,u+=n[t.toUpperCase()]).map(parseFloat),r,s)),u<o;);return i},bbox:function(){return ne().path.setAttribute("d",this.toString()),ne.nodes.path.getBBox()}});var ke=function(t){function e(t){return o(this,e),h(this,u(e).call(this,Q("path",t),e))}return r(e,Nt),a(e,[{key:"array",value:function(){return this._array||(this._array=new ye(this.attr("d")))}},{key:"plot",value:function(t){return null==t?this.array():this.clear().attr("d","string"==typeof t?t:this._array=new ye(t))}},{key:"clear",value:function(){return delete this._array,this}},{key:"move",value:function(t,e){return this.attr("d",this.array().move(t,e))}},{key:"x",value:function(t){return null==t?this.bbox().x:this.move(t,this.bbox().y)}},{key:"y",value:function(t){return null==t?this.bbox().y:this.move(this.bbox().x,t)}},{key:"size",value:function(t,e){var n=R(this,t,e);return this.attr("d",this.array().size(n.width,n.height))}},{key:"width",value:function(t){return null==t?this.bbox().width:this.size(t,this.bbox().height)}},{key:"height",value:function(t){return null==t?this.bbox().height:this.size(this.bbox().width,t)}},{key:"targets",value:function(){return Wt('svg textpath [href*="'+this.id()+'"]')}}]),e}();ke.prototype.MorphArray=ye,at({Container:{path:function(t){return this.put(new ke).plot(t||new ye)}}}),et(ke);var be=Object.freeze({array:function(){return this._array||(this._array=new he(this.attr("points")))},plot:function(t){return null==t?this.array():this.clear().attr("points","string"==typeof t?t:this._array=new he(t))},clear:function(){return delete this._array,this},move:function(t,e){return this.attr("points",this.array().move(t,e))},size:function(t,e){var n=R(this,t,e);return this.attr("points",this.array().size(n.width,n.height))}}),xe=function(t){function e(t){return o(this,e),h(this,u(e).call(this,Q("polygon",t),e))}return r(e,Nt),e}();at({Container:{polygon:function(t){return this.put(new xe).plot(t||new he)}}}),$(xe,ce),$(xe,be),et(xe);var _e=function(t){function e(t){return o(this,e),h(this,u(e).call(this,Q("polyline",t),e))}return r(e,Nt),e}();at({Container:{polyline:function(t){return this.put(new _e).plot(t||new he)}}}),$(_e,ce),$(_e,be),et(_e);var Oe=function(t){function e(t){return o(this,e),h(this,u(e).call(this,Q("rect",t),e))}return r(e,Nt),a(e,[{key:"rx",value:function(t){return this.attr("rx",t)}},{key:"ry",value:function(t){return this.attr("ry",t)}}]),e}();at({Container:{rect:function(t,e){return this.put(new Oe).size(t,e)}}}),et(Oe);var Ae=function(t){function e(t){return o(this,e),h(this,u(e).call(this,Q("symbol",t),e))}return r(e,Dt),e}();at({Container:{symbol:function(){return this.put(new Ae)}}}),et(Ae);var Ce=Object.freeze({plain:function(t){return!1===this._build&&this.clear(),this.node.appendChild(document.createTextNode(t)),this},length:function(){return this.node.getComputedTextLength()}}),je=function(t){function n(t){var e;return o(this,n),(e=h(this,u(n).call(this,Q("text",t),n))).dom.leading=new Mt(1.3),e._rebuild=!0,e._build=!1,e.attr("font-family",_t["font-family"]),e}return r(n,Nt),a(n,[{key:"x",value:function(t){return null==t?this.attr("x"):this.attr("x",t)}},{key:"y",value:function(t){var e=this.attr("y"),n="number"==typeof e?e-this.bbox().y:0;return null==t?"number"==typeof e?e-n:e:this.attr("y","number"==typeof t?t+n:t)}},{key:"cx",value:function(t){return null==t?this.bbox().cx:this.x(t-this.bbox().width/2)}},{key:"cy",value:function(t){return null==t?this.bbox().cy:this.y(t-this.bbox().height/2)}},{key:"text",value:function(t){if(void 0===t){var e=this.node.childNodes,n=0;t="";for(var i=0,r=e.length;i<r;++i)"textPath"!==e[i].nodeName?(i!==n&&3!==e[i].nodeType&&!0===tt(e[i]).dom.newLined&&(t+="\n"),t+=e[i].textContent):0===i&&(n=1);return t}if(this.clear().build(!0),"function"==typeof t)t.call(this,this);else for(var s=0,u=(t=t.split("\n")).length;s<u;s++)this.tspan(t[s]).newLine();return this.build(!1).rebuild()}},{key:"leading",value:function(t){return null==t?this.dom.leading:(this.dom.leading=new Mt(t),this.rebuild())}},{key:"rebuild",value:function(t){if("boolean"==typeof t&&(this._rebuild=t),this._rebuild){var e=this,n=0,i=this.dom.leading*new Mt(this.attr("font-size"));this.each(function(){this.dom.newLined&&(this.attr("x",e.attr("x")),"\n"===this.text()?n+=i:(this.attr("dy",i+n),n=0))}),this.fire("rebuild")}return this}},{key:"build",value:function(t){return this._build=!!t,this}},{key:"setData",value:function(t){return this.dom=t,this.dom.leading=new Mt(t.leading||1.3),this}}]),n}();$(je,Ce),at({Container:{text:function(t){return this.put(new je).text(t)},plain:function(t){return this.put(new je).plain(t)}}}),et(je);var Me=function(t){function e(t){return o(this,e),h(this,u(e).call(this,Q("textPath",t),e))}return r(e,je),a(e,[{key:"array",value:function(){var t=this.track();return t?t.array():null}},{key:"plot",value:function(t){var e=this.track(),n=null;return e&&(n=e.plot(t)),null==t?n:this}},{key:"track",value:function(){return this.reference("href")}}]),e}();at({Container:{textPath:function(t,e){return this.defs().path(e).text(t).addTo(this)}},Text:{path:function(t){var e=new Me;return t instanceof ke||(t=this.doc().defs().path(t)),e.attr("href","#"+t,G),this.put(e)},textPath:function(){return this.find("textPath")}},Path:{text:function(t){if(t instanceof je){var e=t.text();return t.clear().path(this).text(e)}return this.parent().put(new je).path(this).text(t)}}}),Me.prototype.MorphArray=ye,et(Me);var Se=function(t){function e(t){return o(this,e),h(this,u(e).call(this,Q("tspan",t),e))}return r(e,je),a(e,[{key:"text",value:function(t){return null==t?this.node.textContent+(this.dom.newLined?"\n":""):("function"==typeof t?t.call(this,this):this.plain(t),this)}},{key:"dx",value:function(t){return this.attr("dx",t)}},{key:"dy",value:function(t){return this.attr("dy",t)}},{key:"newLine",value:function(){var t=this.parent(je);return this.dom.newLined=!0,this.dy(t.dom.leading*t.attr("font-size")).attr("x",t.x())}}]),e}();$(Se,Ce),at({Tspan:{tspan:function(t){var e=new Se;return this._build||this.clear(),this.node.appendChild(e.node),e.text(t)}}}),et(Se);var Te=function(t){function e(t){return o(this,e),h(this,u(e).call(this,Q("use",t),e))}return r(e,Nt),a(e,[{key:"element",value:function(t,e){return this.attr("href",(e||"")+"#"+t,G)}}]),e}();at({Container:{use:function(t,e){return this.put(new Te).element(t,e)}}}),et(Te);var Ee=function(){function h(){o(this,h),this.init.apply(this,arguments)}return a(h,[{key:"init",value:function(t){var e=q([1,0,0,1,0,0]);t=t instanceof Et?t.matrixify():"string"==typeof t?q(t.split(C).map(parseFloat)):Array.isArray(t)?q(t):"object"===l(t)&&I(t)?t:"object"===l(t)?(new h).transform(t):6===arguments.length?q([].slice.call(arguments)):e,this.a=null!=t.a?t.a:e.a,this.b=null!=t.b?t.b:e.b,this.c=null!=t.c?t.c:e.c,this.d=null!=t.d?t.d:e.d,this.e=null!=t.e?t.e:e.e,this.f=null!=t.f?t.f:e.f}},{key:"clone",value:function(){return new h(this)}},{key:"transform",value:function(t){if(I(t))return new h(t).multiplyO(this);var e=h.formatTransforms(t),n=new ie(e.ox,e.oy).transform(this),i=n.x,r=n.y,s=(new h).translateO(e.rx,e.ry).lmultiplyO(this).translateO(-i,-r).scaleO(e.scaleX,e.scaleY).skewO(e.skewX,e.skewY).shearO(e.shear).rotateO(e.theta).translateO(i,r);if(isFinite(e.px)||isFinite(e.py)){var u=new ie(i,r).transform(s),o=e.px?e.px-u.x:0,a=e.py?e.py-u.y:0;s.translateO(o,a)}return s.translateO(e.tx,e.ty),s}},{key:"compose",value:function(t){t.origin&&(t.originX=t.origin[0],t.originY=t.origin[1]);var e=t.originX||0,n=t.originY||0,i=t.scaleX||1,r=t.scaleY||1,s=t.shear||0,u=t.rotate||0,o=t.translateX||0,a=t.translateY||0;return(new h).translateO(-e,-n).scaleO(i,r).shearO(s).rotateO(u).translateO(o,a).lmultiplyO(this).translateO(e,n)}},{key:"decompose",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:0,e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0,n=this.a,i=this.b,r=this.c,s=this.d,u=this.e,o=this.f,a=n*s-i*r,h=0<a?1:-1,l=h*Math.sqrt(n*n+i*i),c=Math.atan2(h*i,h*n),f=180/Math.PI*c,d=Math.cos(c),v=Math.sin(c),y=(n*r+i*s)/a,p=r*l/(y*n-i)||s*l/(y*i+n);return{scaleX:l,scaleY:p,shear:y,rotate:f,translateX:u-t+t*d*l+e*(y*d*l-v*p),translateY:o-e+t*v*l+e*(y*v*l+d*p),originX:t,originY:e,a:this.a,b:this.b,c:this.c,d:this.d,e:this.e,f:this.f}}},{key:"multiply",value:function(t){return this.clone().multiplyO(t)}},{key:"multiplyO",value:function(t){var e=t instanceof h?t:new h(t);return h.matrixMultiply(this,e,this)}},{key:"lmultiply",value:function(t){return this.clone().lmultiplyO(t)}},{key:"lmultiplyO",value:function(t){var e=t instanceof h?t:new h(t);return h.matrixMultiply(e,this,this)}},{key:"inverseO",value:function(){var t=this.a,e=this.b,n=this.c,i=this.d,r=this.e,s=this.f,u=t*i-e*n;if(!u)throw new Error("Cannot invert "+this);var o=i/u,a=-e/u,h=-n/u,l=t/u,c=-(o*r+h*s),f=-(a*r+l*s);return this.a=o,this.b=a,this.c=h,this.d=l,this.e=c,this.f=f,this}},{key:"inverse",value:function(){return this.clone().inverseO()}},{key:"translate",value:function(t,e){return this.clone().translateO(t,e)}},{key:"translateO",value:function(t,e){return this.e+=t||0,this.f+=e||0,this}},{key:"scale",value:function(t,e,n,i){var r;return(r=this.clone()).scaleO.apply(r,arguments)}},{key:"scaleO",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:t,n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:0,i=3<arguments.length&&void 0!==arguments[3]?arguments[3]:0;3===arguments.length&&(i=n,n=e,e=t);var r=this.a,s=this.b,u=this.c,o=this.d,a=this.e,h=this.f;return this.a=r*t,this.b=s*e,this.c=u*t,this.d=o*e,this.e=a*t-n*t+n,this.f=h*e-i*e+i,this}},{key:"rotate",value:function(t,e,n){return this.clone().rotateO(t,e,n)}},{key:"rotateO",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:0,n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:0;t=wt(t);var i=Math.cos(t),r=Math.sin(t),s=this.a,u=this.b,o=this.c,a=this.d,h=this.e,l=this.f;return this.a=s*i-u*r,this.b=u*i+s*r,this.c=o*i-a*r,this.d=a*i+o*r,this.e=h*i-l*r+n*r-e*i+e,this.f=l*i+h*r-e*r-n*i+n,this}},{key:"flip",value:function(t,e){return this.clone().flipO(t,e)}},{key:"flipO",value:function(t,e){return"x"===t?this.scaleO(-1,1,e,0):"y"===t?this.scaleO(1,-1,0,e):this.scaleO(-1,-1,t,e||t)}},{key:"shear",value:function(t,e,n){return this.clone().shearO(t,e,n)}},{key:"shearO",value:function(t){var e=2<arguments.length&&void 0!==arguments[2]?arguments[2]:0,n=this.a,i=this.b,r=this.c,s=this.d,u=this.e,o=this.f;return this.a=n+i*t,this.c=r+s*t,this.e=u+o*t-e*t,this}},{key:"skew",value:function(t,e,n,i){var r;return(r=this.clone()).skewO.apply(r,arguments)}},{key:"skewO",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:t,n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:0,i=3<arguments.length&&void 0!==arguments[3]?arguments[3]:0;3===arguments.length&&(i=n,n=e,e=t),t=wt(t),e=wt(e);var r=Math.tan(t),s=Math.tan(e),u=this.a,o=this.b,a=this.c,h=this.d,l=this.e,c=this.f;return this.a=u+o*r,this.b=o+u*s,this.c=a+h*r,this.d=h+a*s,this.e=l+c*r-i*r,this.f=c+l*s-n*s,this}},{key:"skewX",value:function(t,e,n){return this.skew(t,0,e,n)}},{key:"skewXO",value:function(t,e,n){return this.skewO(t,0,e,n)}},{key:"skewY",value:function(t,e,n){return this.skew(0,t,e,n)}},{key:"skewYO",value:function(t,e,n){return this.skewO(0,t,e,n)}},{key:"aroundO",value:function(t,e,n){var i=t||0,r=e||0;return this.translateO(-i,-r).lmultiplyO(n).translateO(i,r)}},{key:"around",value:function(t,e,n){return this.clone().aroundO(t,e,n)}},{key:"native",value:function(){for(var t=ne().svg.node.createSVGMatrix(),e=L.length-1;0<=e;e--)t[L[e]]=this[L[e]];return t}},{key:"equals",value:function(t){var e=new h(t);return F(this.a,e.a)&&F(this.b,e.b)&&F(this.c,e.c)&&F(this.d,e.d)&&F(this.e,e.e)&&F(this.f,e.f)}},{key:"toString",value:function(){return"matrix("+this.a+","+this.b+","+this.c+","+this.d+","+this.e+","+this.f+")"}},{key:"toArray",value:function(){return[this.a,this.b,this.c,this.d,this.e,this.f]}},{key:"valueOf",value:function(){return{a:this.a,b:this.b,c:this.c,d:this.d,e:this.e,f:this.f}}}],[{key:"formatTransforms",value:function(t){var e="both"===t.flip||!0===t.flip,n=t.flip&&(e||"x"===t.flip)?-1:1,i=t.flip&&(e||"y"===t.flip)?-1:1,r=t.skew&&t.skew.length?t.skew[0]:isFinite(t.skew)?t.skew:isFinite(t.skewX)?t.skewX:0,s=t.skew&&t.skew.length?t.skew[1]:isFinite(t.skew)?t.skew:isFinite(t.skewY)?t.skewY:0,u=t.scale&&t.scale.length?t.scale[0]*n:isFinite(t.scale)?t.scale*n:isFinite(t.scaleX)?t.scaleX*n:n,o=t.scale&&t.scale.length?t.scale[1]*i:isFinite(t.scale)?t.scale*i:isFinite(t.scaleY)?t.scaleY*i:i,a=t.shear||0,h=t.rotate||t.theta||0,l=new ie(t.origin||t.around||t.ox||t.originX,t.oy||t.originY),c=l.x,f=l.y,d=new ie(t.position||t.px||t.positionX,t.py||t.positionY),v=d.x,y=d.y,p=new ie(t.translate||t.tx||t.translateX,t.ty||t.translateY),m=p.x,g=p.y,w=new ie(t.relative||t.rx||t.relativeX,t.ry||t.relativeY);return{scaleX:u,scaleY:o,skewX:r,skewY:s,shear:a,theta:h,rx:w.x,ry:w.y,tx:m,ty:g,ox:c,oy:f,px:v,py:y}}},{key:"matrixMultiply",value:function(t,e,n){var i=t.a*e.a+t.c*e.b,r=t.b*e.a+t.d*e.b,s=t.a*e.c+t.c*e.d,u=t.b*e.c+t.d*e.d,o=t.e+t.a*e.e+t.c*e.f,a=t.f+t.b*e.e+t.d*e.f;return n.a=i,n.b=r,n.c=s,n.d=u,n.e=o,n.f=a,n}}]),h}();function Ne(e,n){return function(t){return null==t?this[t]:(this[e]=t,n&&n.call(this),this)}}at({Element:{ctm:function(){return new Ee(this.node.getCTM())},screenCTM:function(){if("function"!=typeof this.isRoot||this.isRoot())return new Ee(this.node.getScreenCTM());var t=this.rect(1,1),e=t.node.getScreenCTM();return t.remove(),new Ee(e)}}});var De={"-":function(t){return t},"<>":function(t){return-Math.cos(t*Math.PI)/2+.5},">":function(t){return Math.sin(t*Math.PI/2)},"<":function(t){return 1-Math.cos(t*Math.PI/2)},bezier:function(t,e,n,i){return function(t){}}},Pe=function(){function t(){o(this,t)}return a(t,[{key:"done",value:function(){return!1}}]),t}(),ze=function(t){function n(t){var e;return o(this,n),(e=h(this,u(n).call(this))).ease=De[t||xt.ease]||t,e}return r(n,Pe),a(n,[{key:"step",value:function(t,e,n){return"number"!=typeof t?n<1?t:e:t+(e-t)*this.ease(n)}}]),n}(),Re=function(t){function n(t){var e;return o(this,n),(e=h(this,u(n).call(this))).stepper=t,e}return r(n,Pe),a(n,[{key:"step",value:function(t,e,n,i){return this.stepper(t,e,n,i)}},{key:"done",value:function(t){return t.done}}]),n}();function qe(){var t=(this._duration||500)/1e3,e=this._overshoot||0,n=Math.PI,i=Math.log(e/100+1e-10),r=-i/Math.sqrt(n*n+i*i),s=3.9/(r*t);this.d=2*r*s,this.k=s*s}var Le=function(t){function i(t,e){var n;return o(this,i),(n=h(this,u(i).call(this))).duration(t||500).overshoot(e||0),n}return r(i,Re),a(i,[{key:"step",value:function(t,e,n,i){if("string"==typeof t)return t;if(i.done=n===1/0,n===1/0)return e;if(0===n)return t;100<n&&(n=16),n/=1e3;var r=i.velocity||0,s=-this.d*r-this.k*(t-e),u=t+r*n+s*n*n/2;return i.velocity=r+s*n,i.done=Math.abs(e-u)+Math.abs(r)<.002,i.done?e:u}}]),i}();$(Le,{duration:Ne("_duration",qe),overshoot:Ne("_overshoot",qe)});var Fe=function(t){function s(t,e,n,i){var r;return o(this,s),t=null==t?.1:t,e=null==e?.01:e,n=null==n?0:n,i=null==i?1e3:i,(r=h(this,u(s).call(this))).p(t).i(e).d(n).windup(i),r}return r(s,Re),a(s,[{key:"step",value:function(t,e,n,i){if("string"==typeof t)return t;if(i.done=n===1/0,n===1/0)return e;if(0===n)return t;var r=e-t,s=(i.integral||0)+r*n,u=(r-(i.error||0))/n,o=this.windup;return!1!==o&&(s=Math.max(-o,Math.min(s,o))),i.error=r,i.integral=s,i.done=Math.abs(r)<.001,i.done?e:t+(this.P*r+this.I*s+this.D*u)}}]),s}();$(Fe,{windup:Ne("windup"),p:Ne("P"),i:Ne("I"),d:Ne("D")});var Ie=function(){function e(t){o(this,e),this._stepper=t||new ze("-"),this._from=null,this._to=null,this._type=null,this._context=null,this._morphObj=null}return a(e,[{key:"from",value:function(t){return null==t?this._from:(this._from=this._set(t),this)}},{key:"to",value:function(t){return null==t?this._to:(this._to=this._set(t),this)}},{key:"type",value:function(t){return null==t?this._type:(this._type=t,this)}},{key:"_set",value:function(t){if(!this._type){var e=l(t);"number"===e?this.type(Mt):"string"===e?At.isColor(t)?this.type(At):C.test(t)?this.type(M.test(t)?ye:jt):v.test(t)?this.type(Mt):this.type(Xe):-1<Ge.indexOf(t.constructor)?this.type(t.constructor):Array.isArray(t)?this.type(jt):"object"===e?this.type(He):this.type(Xe)}var n=new this._type(t).toArray();return this._morphObj=this._morphObj||new this._type,this._context=this._context||Array.apply(null,Array(n.length)).map(Object),n}},{key:"stepper",value:function(t){return null==t?this._stepper:(this._stepper=t,this)}},{key:"done",value:function(){return this._context.map(this._stepper.done).reduce(function(t,e){return t&&e},!0)}},{key:"at",value:function(n){var i=this;return this._morphObj.fromArray(this._from.map(function(t,e){return i._stepper.step(t,i._to[e],n,i._context[e],i._context)}))}}]),e}(),Xe=function(){function t(){o(this,t),this.init.apply(this,arguments)}return a(t,[{key:"init",value:function(t){t=Array.isArray(t)?t[0]:t,this.value=t}},{key:"valueOf",value:function(){return this.value}},{key:"toArray",value:function(){return[this.value]}}]),t}(),Ye=function(){function e(){o(this,e),this.init.apply(this,arguments)}return a(e,[{key:"init",value:function(t){Array.isArray(t)&&(t={scaleX:t[0],scaleY:t[1],shear:t[2],rotate:t[3],translateX:t[4],translateY:t[5],originX:t[6],originY:t[7]}),Object.assign(this,e.defaults,t)}},{key:"toArray",value:function(){var t=this;return[t.scaleX,t.scaleY,t.shear,t.rotate,t.translateX,t.translateY,t.originX,t.originY]}}]),e}();Ye.defaults={scaleX:1,scaleY:1,shear:0,rotate:0,translateX:0,translateY:0,originX:0,originY:0};var He=function(){function t(){o(this,t),this.init.apply(this,arguments)}return a(t,[{key:"init",value:function(t){if(this.values=[],Array.isArray(t))this.values=t;else{var e=Object.entries(t||{}).sort(function(t,e){return t[0]-e[0]});this.values=e.reduce(function(t,e){return t.concat(e)},[])}}},{key:"valueOf",value:function(){for(var t={},e=this.values,n=0,i=e.length;n<i;n+=2)t[e[n]]=e[n+1];return t}},{key:"toArray",value:function(){return this.values}}]),t}(),Ge=[Xe,Ye,He];var Ve=window.performance||Date,Be=function(t){var e=t.start,n=t.runner.duration();return{start:e,duration:n,end:e+n,runner:t.runner}},Qe=function(){function t(){o(this,t),this._timeSource=function(){return Ve.now()},this._dispatcher=document.createElement("div"),this._startTime=0,this._speed=1,this._reverse=!1,this._persist=0,this._nextFrame=null,this._paused=!1,this._runners=[],this._order=[],this._time=0,this._lastSourceTime=0,this._lastStepTime=0}return a(t,[{key:"getEventTarget",value:function(){return this._dispatcher}},{key:"schedule",value:function(t,e,n){if(null==t)return this._runners.map(Be).sort(function(t,e){return t.start-e.start||t.duration-e.duration});this.active()||(this._step(),null==n&&(n="now"));var i=0;if(e=e||0,null==n||"last"===n||"after"===n)i=this._startTime;else if("absolute"===n||"start"===n)i=e,e=0;else if("now"===n)i=this._time;else{if("relative"!==n)throw new Error('Invalid value for the "when" parameter');var r=this._runners[t.id];r&&(i=r.start+e,e=0)}return t.unschedule(),t.timeline(this),t.time(-e),this._startTime=i+t.duration()+e,this._runners[t.id]={persist:this.persist(),runner:t,start:i},this._order.push(t.id),this._continue(),this}},{key:"unschedule",value:function(t){var e=this._order.indexOf(t.id);return e<0||(delete this._runners[t.id],this._order.splice(e,1),t.timeline(null)),this}},{key:"play",value:function(){return this._paused=!1,this._continue()}},{key:"pause",value:function(){return this._nextFrame=null,this._paused=!0,this}},{key:"stop",value:function(){return this.seek(-this._time),this.pause()}},{key:"finish",value:function(){return this.seek(1/0),this.pause()}},{key:"speed",value:function(t){return null==t?this._speed:(this._speed=t,this)}},{key:"reverse",value:function(t){var e=this.speed();if(null==t)return this.speed(-e);var n=Math.abs(e);return this.speed(t?n:-n)}},{key:"seek",value:function(t){return this._time+=t,this._continue()}},{key:"time",value:function(t){return null==t?this._time:(this._time=t,this)}},{key:"persist",value:function(t){return null==t?this._persist:(this._persist=t,this)}},{key:"source",value:function(t){return null==t?this._timeSource:(this._timeSource=t,this)}},{key:"_step",value:function(){if(!this._paused){var t=this._timeSource(),e=t-this._lastSourceTime,n=this._speed*e+(this._time-this._lastStepTime);this._lastSourceTime=t,this._time+=n,this._lastStepTime=this._time;for(var i=!1,r=0,s=this._order.length;r<s;r++){var u=this._runners[this._order[r]],o=u.runner,a=n,h=this._time-u.start;if(h<0)i=!0;else if(h<a&&(a=h),o.active())if(o.step(a).done){if(!0!==u.persist){o.duration()-o.time()+this._time+this._persist<this._time&&(delete this._runners[this._order[r]],this._order.splice(r--,1)&&--s,o.timeline(null))}}else i=!0}return this._nextFrame=i?Ft.frame(this._step.bind(this)):null,this}}},{key:"_continue",value:function(){return this._paused||this._nextFrame||(this._nextFrame=Ft.frame(this._step.bind(this))),this}},{key:"active",value:function(){return!!this._nextFrame}}]),t}();at({Element:{timeline:function(){return this._timeline=this._timeline||new Qe,this._timeline}}});var Ue=function(t){function s(t){var e;return o(this,s),(e=h(this,u(s).call(this))).id=s.id++,t="function"==typeof(t=null==t?xt.duration:t)?new Re(t):t,e._element=null,e._timeline=null,e.done=!1,e._queue=[],e._duration="number"==typeof t&&t,e._isDeclarative=t instanceof Re,e._stepper=e._isDeclarative?t:new ze,e._history={},e.enabled=!0,e._time=0,e._last=0,e.transforms=new Ee,e.transformId=1,e._haveReversed=!1,e._reverse=!1,e._loopsDone=0,e._swing=!1,e._wait=0,e._times=1,e}return r(s,mt),a(s,[{key:"element",value:function(t){return null==t?this._element:((this._element=t)._prepareRunner(),this)}},{key:"timeline",value:function(t){return void 0===t?this._timeline:(this._timeline=t,this)}},{key:"animate",value:function(t,e,n){var i=s.sanitise(t,e,n),r=new s(i.duration);return this._timeline&&r.timeline(this._timeline),this._element&&r.element(this._element),r.loop(i).schedule(e,n)}},{key:"schedule",value:function(t,e,n){if(t instanceof Qe||(n=e,e=t,t=this.timeline()),!t)throw Error("Runner cannot be scheduled without timeline");return t.schedule(this,e,n),this}},{key:"unschedule",value:function(){var t=this.timeline();return t&&t.unschedule(this),this}},{key:"loop",value:function(t,e,n){return"object"===l(t)&&(e=t.swing,n=t.wait,t=t.times),this._times=t||1/0,this._swing=e||!1,this._wait=n||0,this}},{key:"delay",value:function(t){return this.animate(0,t)}},{key:"queue",value:function(t,e,n){return this._queue.push({initialiser:t||bt,runner:e||bt,isTransform:n,initialised:!1,finished:!1}),this.timeline()&&this.timeline()._continue(),this}},{key:"during",value:function(t){return this.queue(null,t)}},{key:"after",value:function(t){return this.on("finish",t)}},{key:"time",value:function(t){if(null==t)return this._time;var e=t-this._time;return this.step(e),this}},{key:"duration",value:function(){return this._times*(this._wait+this._duration)-this._wait}},{key:"loops",value:function(t){var e=this._duration+this._wait;if(null==t){var n=Math.floor(this._time/e),i=(this._time-n*e)/this._duration;return Math.min(n+i,this._times)}var r=t%1,s=e*Math.floor(t)+this._duration*r;return this.time(s)}},{key:"position",value:function(t){var e,n=this._time,r=this._duration,s=this._wait,i=this._times,u=this._swing,o=this._reverse;if(null==t){var a=function(t){var e=u*Math.floor(t%(2*(s+r))/(s+r)),n=e&&!o||!e&&o,i=Math.pow(-1,n)*(t%(s+r))/r+n;return Math.max(Math.min(i,1),0)},h=i*(s+r)-s;return e=n<=0?Math.round(a(1e-5)):n<h?a(n):Math.round(a(h-1e-5)),e}var l=Math.floor(this.loops()),c=u&&l%2==0;return e=l+(c&&!o||o&&c?t:1-t),this.loops(e)}},{key:"progress",value:function(t){return null==t?Math.min(1,this._time/this.duration()):this.time(t*this.duration())}},{key:"step",value:function(t){if(!this.enabled)return this;t=null==t?16:t,this._time+=t;var e=this.position(),n=this._lastPosition!==e&&0<=this._time;this._lastPosition=e;var i=this.duration(),r=this._lastTime<0&&0<this._time,s=this._lastTime<this._time&&this.time>i;this._lastTime=this._time,r&&this.fire("start",this);var u=this._isDeclarative;if(this.done=!u&&!s&&this._time>=i,n||u){this._initialise(n),this.transforms=new Ee;var o=this._run(u?t:e);this.fire("step",this)}return this.done=this.done||o&&u,this.done&&this.fire("finish",this),this}},{key:"finish",value:function(){return this.step(1/0)}},{key:"reverse",value:function(t){return this._reverse=null==t?!this._reverse:t,this}},{key:"ease",value:function(t){return this._stepper=new ze(t),this}},{key:"active",value:function(t){return null==t?this.enabled:(this.enabled=t,this)}},{key:"_rememberMorpher",value:function(t,e){this._history[t]={morpher:e,caller:this._queue[this._queue.length-1]}}},{key:"_tryRetarget",value:function(t,e){if(this._history[t]){if(!this._history[t].caller.initialised){var n=this._queue.indexOf(this._history[t].caller);return this._queue.splice(n,1),!1}this._history[t].caller.isTransform?this._history[t].caller.isTransform(e):this._history[t].morpher.to(e),this._history[t].caller.finished=!1;var i=this.timeline();return i&&i._continue(),!0}return!1}},{key:"_initialise",value:function(t){if(t||this._isDeclarative)for(var e=0,n=this._queue.length;e<n;++e){var i=this._queue[e],r=this._isDeclarative||!i.initialised&&t;t=!i.finished,r&&t&&(i.initialiser.call(this),i.initialised=!0)}}},{key:"_run",value:function(t){for(var e=!0,n=0,i=this._queue.length;n<i;++n){var r=this._queue[n],s=r.runner.call(this,t);r.finished=r.finished||!0===s,e=e&&r.finished}return e}},{key:"addTransform",value:function(t,e){return this.transforms.lmultiplyO(t),this}},{key:"clearTransform",value:function(){return this.transforms=new Ee,this}}],[{key:"sanitise",value:function(t,e,n){var i=1,r=!1,s=0;return e=e||xt.delay,n=n||"last","object"!==l(t=t||xt.duration)||t instanceof Pe||(e=t.delay||e,n=t.when||n,r=t.swing||r,i=t.times||i,s=t.wait||s,t=t.duration||xt.duration),{duration:t,delay:e,swing:r,times:i,wait:s,when:n}}}]),s}();Ue.id=0;var $e=function t(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:new Ee,n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:-1,i=!(2<arguments.length&&void 0!==arguments[2])||arguments[2];o(this,t),this.transforms=e,this.id=n,this.done=i};$([Ue,$e],{mergeWith:function(t){return new $e(t.transforms.lmultiply(this.transforms),t.id)}});var We=function(t,e){return t.lmultiplyO(e)},Je=function(t){return t.transforms};var Ze=function(){function t(){o(this,t),this.runners=[],this.ids=[]}return a(t,[{key:"add",value:function(t){if(!this.runners.includes(t)){var n=t.id+1,e=this.ids.reduce(function(t,e){return t<e&&e<n?e:t},0),i=this.ids.indexOf(e)+1;return this.ids.splice(i,0,n),this.runners.splice(i,0,t),this}}},{key:"getByID",value:function(t){return this.runners[this.ids.indexOf(t+1)]}},{key:"remove",value:function(t){var e=this.ids.indexOf(t+1);return this.ids.splice(e,1),this.runners.splice(e,1),this}},{key:"merge",value:function(){var n=this,i=null;return this.runners.forEach(function(t,e){i&&t.done&&i.done&&(n.remove(t.id),n.edit(i.id,t.mergeWith(i))),i=t}),this}},{key:"edit",value:function(t,e){var n=this.ids.indexOf(t+1);return this.ids.splice(n,1,t),this.runners.splice(n,1,e),this}},{key:"length",value:function(){return this.ids.length}},{key:"clearBefore",value:function(t){var e=this.ids.indexOf(t+1)||1;return this.ids.splice(0,e,0),this.runners.splice(0,e,new $e),this}}]),t}(),Ke=0;at({Element:{animate:function(t,e,n){var i=Ue.sanitise(t,e,n),r=this.timeline();return new Ue(i.duration).loop(i).element(this).timeline(r).schedule(e,n)},delay:function(t,e){return this.animate(0,t,e)},_clearTransformRunnersBefore:function(t){this._transformationRunners.clearBefore(t.id)},_currentTransform:function(e){return this._transformationRunners.runners.filter(function(t){return t.id<=e.id}).map(Je).reduce(We,new Ee)},addRunner:function(t){this._transformationRunners.add(t),Ft.transform_frame(function(){var t=this._transformationRunners.runners.map(Je).reduce(We,new Ee);this.transform(t),this._transformationRunners.merge(),1===this._transformationRunners.length()&&(this._frameId=null)}.bind(this),this._frameId)},_prepareRunner:function(){null==this._frameId&&(this._transformationRunners=(new Ze).add(new $e(new Ee(this))),this._frameId=Ke++)}}}),$(Ue,{attr:function(t,e){return this.styleAttr("attr",t,e)},css:function(t,e){return this.styleAttr("css",t,e)},styleAttr:function(e,n,t){if("object"===l(n))for(var i in t)this.styleAttr(e,i,t[i]);var r=new Ie(this._stepper).to(t);return this.queue(function(){r=r.from(this.element()[e](n))},function(t){return this.element()[e](n,r.at(t)),r.done()}),this},zoom:function(t,e){var n=new Ie(this._stepper).to(new Mt(t));return this.queue(function(){n=n.from(this.zoom())},function(t){return this.element().zoom(n.at(t),e),n.done()}),this},transform:function(d,v,y){if(v=d.relative||v,this._isDeclarative&&!v&&this._tryRetarget("transform",d))return this;var p=I(d);y=null!=d.affine?d.affine:null!=y?y:!p;var m,g,w,k,b,x=(new Ie).type(y?Ye:Ee).stepper(this._stepper);return this.queue(function(){g=g||this.element(),m=m||X(d,g),b=new Ee(v?void 0:g),g.addRunner(this),v||g._clearTransformRunnersBefore(this)},function(t){v||this.clearTransform();var e=new ie(m).transform(g._currentTransform(this)),n=e.x,i=e.y,r=new Ee(_({},d,{origin:[n,i]})),s=this._isDeclarative&&w?w:b;if(y){r=r.decompose(n,i),s=s.decompose(n,i);var u=r.rotate,o=s.rotate,a=[u-360,u,u+360],h=a.map(function(t){return Math.abs(t-o)}),l=Math.min.apply(Math,O(h)),c=h.indexOf(l);r.rotate=a[c]}v&&(p||(r.rotate=d.rotate||0),this._isDeclarative&&k&&(s.rotate=k)),x.from(s),x.to(r);var f=x.at(t);return k=f.rotate,w=new Ee(f),this.addTransform(w),x.done()},function(t){(t.origin||"center").toString()!==(d.origin||"center").toString()&&(m=X(d,g)),d=_({},t,{origin:m})}),this._isDeclarative&&this._rememberMorpher("transform",x),this},x:function(t,e){return this._queueNumber("x",t)},y:function(t){return this._queueNumber("y",t)},dx:function(t){return this._queueNumberDelta("dx",t)},dy:function(t){return this._queueNumberDelta("dy",t)},_queueNumberDelta:function(e,n){if(n=new Mt(n),this._tryRetargetDelta(e,n))return this;var i=new Ie(this._stepper).to(n);return this.queue(function(){var t=this.element()[e]();i.from(t),i.to(t+n)},function(t){return this.element()[e](i.at(t)),i.done()}),this._rememberMorpher(e,i),this},_queueObject:function(e,t){if(this._tryRetarget(e,t))return this;var n=new Ie(this._stepper).to(t);return this.queue(function(){n.from(this.element()[e]())},function(t){return this.element()[e](n.at(t)),n.done()}),this._rememberMorpher(e,n),this},_queueNumber:function(t,e){return this._queueObject(t,new Mt(e))},cx:function(t){return this._queueNumber("cx",t)},cy:function(t){return this._queueNumber("cy",t)},move:function(t,e){return this.x(t).y(e)},center:function(t,e){return this.cx(t).cy(e)},size:function(t,e){var n;return t&&e||(n=this._element.bbox()),t||(t=n.width/n.height*e),e||(e=n.height/n.width*t),this.width(t).height(e)},width:function(t){return this._queueNumber("width",t)},height:function(t){return this._queueNumber("height",t)},plot:function(t,e,n,i){return 4===arguments.length?this.plot([t,e,n,i]):this._queueObject("plot",new this._element.MorphArray(t))},leading:function(t){return this._queueNumber("leading",t)},viewbox:function(t,e,n,i){return this._queueObject("viewbox",new Box(t,e,n,i))},update:function(t){return"object"!==l(t)?this.update({offset:t,color:arguments[1],opacity:arguments[2]}):(null!=t.opacity&&this.attr("stop-opacity",t.opacity),null!=t.color&&this.attr("stop-color",t.color),null!=t.offset&&this.attr("offset",t.offset),this)}});var tn=Object.freeze({EventTarget:mt,Dom:St,Element:Et,Shape:Nt,Container:Dt,HtmlNode:Pt,Doc:Rt,Defs:zt,G:qt,Animator:Ft,Bare:It,Circle:$t,ClipPath:Jt,A:Zt,Ellipse:Kt,Stop:te,Gradient:ue,Image:ae,Line:fe,Marker:de,Mask:ve,Path:ke,Pattern:oe,Polygon:xe,Polyline:_e,Rect:Oe,Symbol:Ae,Text:je,TextPath:Me,Tspan:Se,Use:Te,SVGNumber:Mt,SVGArray:jt,PathArray:ye,PointArray:he,Matrix:Ee,Point:ie,Box:re,Color:At,Morphable:Ie,Queue:Lt,Runner:Ue,Timeline:Qe,Controller:Re,Ease:ze,PID:Fe,Spring:Le});at("Dom",{siblings:function(){return this.parent().children()},position:function(){return this.parent().index(this)},next:function(){return this.siblings()[this.position()+1]},prev:function(){return this.siblings()[this.position()-1]},forward:function(){var t=this.position()+1,e=this.parent();return e.removeElement(this).add(this,t),"function"==typeof e.isRoot&&e.isRoot()&&e.node.appendChild(e.defs().node),this},backward:function(){var t=this.position();return 0<t&&this.parent().removeElement(this).add(this,t-1),this},front:function(){var t=this.parent();return t.node.appendChild(this.node),"function"==typeof t.isRoot&&t.isRoot()&&t.node.appendChild(t.defs().node),this},back:function(){return 0<this.position()&&this.parent().removeElement(this).add(this,0),this},before:function(t){t.remove();var e=this.position();return this.parent().add(t,e),this},after:function(t){t.remove();var e=this.position();return this.parent().add(t,e+1),this}}),at("Dom",{data:function(e,t,n){if("object"===l(e))for(t in e)this.data(t,e[t]);else if(arguments.length<2)try{return JSON.parse(this.attr("data-"+e))}catch(t){return this.attr("data-"+e)}else this.attr("data-"+e,null===t?null:!0===n||"string"==typeof t||"number"==typeof t?t:JSON.stringify(t));return this}}),at("Dom",{classes:function(){var t=this.attr("class");return null==t?[]:t.trim().split(C)},hasClass:function(t){return-1!==this.classes().indexOf(t)},addClass:function(t){if(!this.hasClass(t)){var e=this.classes();e.push(t),this.attr("class",e.join(" "))}return this},removeClass:function(e){return this.hasClass(e)&&this.attr("class",this.classes().filter(function(t){return t!==e}).join(" ")),this},toggleClass:function(t){return this.hasClass(t)?this.removeClass(t):this.addClass(t)}}),at("Dom",{css:function(t,e){var n={};if(0===arguments.length)return this.node.style.cssText.split(/\s*;\s*/).filter(function(t){return!!t.length}).forEach(function(t){var e=t.split(/\s*:\s*/);n[e[0]]=e[1]}),n;if(arguments.length<2){if(Array.isArray(t)){var i=!0,r=!1,s=void 0;try{for(var u,o=t[Symbol.iterator]();!(i=(u=o.next()).done);i=!0){var a=D(u.value);n[a]=this.node.style[a]}}catch(t){r=!0,s=t}finally{try{i||null==o.return||o.return()}finally{if(r)throw s}}return n}if("string"==typeof t)return this.node.style[D(t)];if("object"===l(t))for(name in t)this.node.style[D(name)]=null==t[name]||b.test(t[name])?"":t[name]}return 2===arguments.length&&(this.node.style[D(t)]=null==e||b.test(e)?"":e),this},show:function(){return this.css("display","")},hide:function(){return this.css("display","none")},visible:function(){return"none"!==this.css("display")}}),at("Element",{untransform:function(){return this.attr("transform",null)},matrixify:function(){return(this.attr("transform")||"").split(t).slice(0,-1).map(function(t){var e=t.trim().split("(");return[e[0],e[1].split(C).map(function(t){return parseFloat(t)})]}).reverse().reduce(function(t,e){return"matrix"===e[0]?t.lmultiply(q(e[1])):t[e[0]].apply(t,e[1])},new Ee)},toParent:function(t){if(this===t)return this;var e=this.screenCTM(),n=t.screenCTM().inverse();return this.addTo(t).untransform().transform(n.multiply(e)),this},toDoc:function(){return this.toParent(this.doc())},transform:function(t,e){if(null==t||"string"==typeof t){var n=new Ee(this).decompose();return n[t]||n}I(t)||(t=_({},t,{origin:X(t,this)}));var i=new Ee(!0===e?this:e||!1).transform(t);return this.attr("transform",i)}}),at("Dom",{remember:function(t,e){if("object"===l(t))for(var n in t)this.remember(n,t[n]);else{if(1===arguments.length)return this.memory()[t];this.memory()[t]=e}return this},forget:function(){if(0===arguments.length)this._memory={};else for(var t=arguments.length-1;0<=t;t--)delete this.memory()[arguments[t]];return this},memory:function(){return this._memory=this._memory||{}}});var en={stroke:["color","width","opacity","linecap","linejoin","miterlimit","dasharray","dashoffset"],fill:["color","opacity","rule"],prefix:function(t,e){return"color"===e?t:t+"-"+e}};["fill","stroke"].forEach(function(e){var n,t={};t[e]=function(t){if(void 0===t)return this;if("string"==typeof t||At.isRgb(t)||t instanceof Et)this.attr(e,t);else for(n=en[e].length-1;0<=n;n--)null!=t[en[e][n]]&&this.attr(en.prefix(e,en[e][n]),t[en[e][n]]);return this},at(["Shape","Runner"],t)}),at(["Element","Runner"],{matrix:function(t,e,n,i,r,s){return null==t?new Ee(this):this.attr("transform",new Ee(t,e,n,i,r,s))},rotate:function(t,e,n){return this.transform({rotate:t,ox:e,oy:n},!0)},skew:function(t,e,n,i){return 1===arguments.length||3===arguments.length?this.transform({skew:t,ox:e,oy:n},!0):this.transform({skew:[t,e],ox:n,oy:i},!0)},shear:function(t,e,n){return this.transform({shear:t,ox:e,oy:n},!0)},scale:function(t,e,n,i){return 1===arguments.length||3===arguments.length?this.transform({scale:t,ox:e,oy:n},!0):this.transform({scale:[t,e],ox:n,oy:i},!0)},translate:function(t,e){return this.transform({translate:[t,e]},!0)},relative:function(t,e){return this.transform({relative:[t,e]},!0)},flip:function(t,e){var n="string"==typeof t?t:(isFinite(t),"both"),i="both"===t&&isFinite(e)?[e,e]:"x"===t?[e,0]:"y"===t?[0,e]:isFinite(t)?[t,t]:[0,0];this.transform({flip:n,origin:i},!0)},opacity:function(t){return this.attr("opacity",t)},dx:function(t){return this.x(new Mt(t).plus(this instanceof Ue?0:this.x()),!0)},dy:function(t){return this.y(new Mt(t).plus(this instanceof Ue?0:this.y()),!0)},dmove:function(t,e){return this.dx(t).dy(e)}}),at("radius",{radius:function(t,e){var n=(this._element||this).type;return"radialGradient"===n||"radialGradient"===n?this.attr("r",new Mt(t)):this.rx(t).ry(null==e?t:e)}}),at("Path",{length:function(){return this.node.getTotalLength()},pointAt:function(t){return new ie(this.node.getPointAtLength(t))}}),at(["Element","Runner"],{font:function(t,e){if("object"===l(t))for(e in t)this.font(e,t[e]);return"leading"===t?this.leading(e):"anchor"===t?this.attr("text-anchor",e):"size"===t||"family"===t||"weight"===t||"stretch"===t||"variant"===t||"style"===t?this.attr("font-"+t,e):this.attr(t,e)}});var nn=$;function rn(t){return K(t)}return nn([Rt,Ae,ae,oe,de],ht("viewbox")),nn([fe,_e,xe,ke],ht("marker")),nn(je,ht("Text")),nn(ke,ht("Path")),nn(zt,ht("Defs")),nn([je,Se],ht("Tspan")),nn([Oe,Kt,$t,ue],ht("radius")),nn(mt,ht("EventTarget")),nn(St,ht("Dom")),nn(Et,ht("Element")),nn(Nt,ht("Shape")),nn(Dt,ht("Container")),function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:[];Ge.push.apply(Ge,O([].concat(t)))}([Mt,At,re,Ee,jt,he,ye]),$(Ge,{to:function(t,e){return(new Ie).type(this.constructor).from(this.valueOf()).to(t,e)},fromArray:function(t){return this.init(t),this}}),Object.assign(rn,tn),Object.assign(rn,W),Object.assign(rn,ut),rn.utils=kt,rn.regex=e,(rn.get=rn).find=Wt,Object.assign(rn,B),rn.easing=De,Object.assign(rn,pt),rn.TransformBag=Ye,rn.ObjectBag=He,rn.NonMorphable=Xe,rn.parser=ne,rn.defaults=Ot,rn}(); diff --git a/spec/spec/container.js b/spec/spec/container.js index a1bfa6e..6f63ba5 100644 --- a/spec/spec/container.js +++ b/spec/spec/container.js @@ -176,8 +176,8 @@ describe('Container', function() { it('creates an instance of SVG.Text', function() { expect(draw.text(loremIpsum) instanceof SVG.Text).toBe(true) }) - it('is an instance of SVG.Parent', function() { - expect(draw.text(loremIpsum) instanceof SVG.Parent).toBe(true) + it('is an instance of SVG.Shape', function() { + expect(draw.text(loremIpsum) instanceof SVG.Shape).toBe(true) }) it('is an instance of SVG.Element', function() { expect(draw.text(loremIpsum) instanceof SVG.Element).toBe(true) @@ -197,7 +197,7 @@ describe('Container', function() { expect(draw.plain(loremIpsum) instanceof SVG.Text).toBe(true) }) it('is an instance of SVG.Parent', function() { - expect(draw.plain(loremIpsum) instanceof SVG.Parent).toBe(true) + expect(draw.plain(loremIpsum) instanceof SVG.Shape).toBe(true) }) it('is an instance of SVG.Element', function() { expect(draw.plain(loremIpsum) instanceof SVG.Element).toBe(true) diff --git a/src/Bare.js b/src/Bare.js index 76aa3bf..c08d8fc 100644 --- a/src/Bare.js +++ b/src/Bare.js @@ -1,10 +1,10 @@ import {nodeOrNew} from './tools.js' import {register} from './adopter.js' -import Parent from './Parent.js' +import Container from './Container.js' import {registerMethods} from './methods.js' import {extend} from './tools.js' -export default class Bare extends Parent { +export default class Bare extends Container { constructor (node) { super(nodeOrNew(node, typeof node === 'string' ? null : node), Bare) } @@ -1,4 +1,3 @@ -//import {Parent, Doc, Symbol, Image, Pattern, Marker, Point} from './classes.js' import Point from './Point.js' import parser from './parser.js' import {fullBox, domContains, isNulledBox} from './helpers.js' diff --git a/src/Container.js b/src/Container.js index 5d6dc43..c45d805 100644 --- a/src/Container.js +++ b/src/Container.js @@ -1,2 +1,26 @@ -import Parent from './Parent.js' -export default class Container extends Parent {} +import Element from './Element.js' +export default class Container extends Element { + flatten (parent) { + this.each(function () { + if (this instanceof Container) return this.flatten(parent).ungroup(parent) + return this.toParent(parent) + }) + + // we need this so that Doc does not get removed + this.node.firstElementChild || this.remove() + + return this + } + + ungroup (parent) { + parent = parent || this.parent() + + this.each(function () { + return this.toParent(parent) + }) + + this.remove() + + return this + } +} diff --git a/src/Dom.js b/src/Dom.js new file mode 100644 index 0000000..515c872 --- /dev/null +++ b/src/Dom.js @@ -0,0 +1,237 @@ +import EventTarget from './EventTarget.js' +import {assignNewId, adopt, makeInstance, eid} from './adopter.js' +import {map} from './utils.js' +import {matcher} from './helpers.js' +import {ns} from './namespaces.js' + +export default class Dom extends EventTarget { + constructor (node) { + super(node) + this.node = node + this.type = node.nodeName + } + + // Add given element at a position + add (element, i) { + element = makeInstance(element) + + if (i == null) { + this.node.appendChild(element.node) + } else if (element.node !== this.node.childNodes[i]) { + this.node.insertBefore(element.node, this.node.childNodes[i]) + } + + return this + } + + // Add element to given container and return self + addTo (parent) { + return makeInstance(parent).put(this) + } + + // Returns all child elements + children () { + return map(this.node.children, function (node) { + return adopt(node) + }) + } + + // Remove all elements in this container + clear () { + // remove children + while (this.node.hasChildNodes()) { + this.node.removeChild(this.node.lastChild) + } + + // remove defs reference + delete this._defs + + return this + } + + // Clone element + clone (parent) { + // write dom data to the dom so the clone can pickup the data + this.writeDataToDom() + + // clone element and assign new id + let clone = assignNewId(this.node.cloneNode(true)) + + // insert the clone in the given parent or after myself + if (parent) parent.add(clone) + // FIXME: after might not be available here + else this.after(clone) + + return clone + } + + // Iterates over all children and invokes a given block + each (block, deep) { + var children = this.children() + var i, il + + for (i = 0, il = children.length; i < il; i++) { + block.apply(children[i], [i, children]) + + if (deep) { + children[i].each(block, deep) + } + } + + return this + } + + // Get first child + first () { + return adopt(this.node.firstChild) + } + + // Get a element at the given index + get (i) { + return adopt(this.node.childNodes[i]) + } + + getEventHolder () { + return this.node + } + + getEventTarget () { + return this.node + } + + // Checks if the given element is a child + has (element) { + return this.index(element) >= 0 + } + + // Get / set id + id (id) { + // generate new id if no id set + if (typeof id === 'undefined' && !this.node.id) { + this.node.id = eid(this.type) + } + + // dont't set directly width this.node.id to make `null` work correctly + return this.attr('id', id) + } + + // Gets index of given element + index (element) { + return [].slice.call(this.node.childNodes).indexOf(element.node) + } + + // Get the last child + last () { + return adopt(this.node.lastChild) + } + + // matches the element vs a css selector + matches (selector) { + return matcher(this.node, selector) + } + + // Returns the svg node to call native svg methods on it + native () { + return this.node + } + + // Returns the parent element instance + parent (type) { + var parent = this + + // check for parent + if (!parent.node.parentNode) return null + + // get parent element + parent = adopt(parent.node.parentNode) + + if (!type) return parent + + // loop trough ancestors if type is given + while (parent && parent.node instanceof window.SVGElement) { + if (typeof type === 'string' ? parent.matches(type) : parent instanceof type) return parent + parent = adopt(parent.node.parentNode) + } + } + + // Basically does the same as `add()` but returns the added element instead + put (element, i) { + this.add(element, i) + return element + } + + // Add element to given container and return container + putIn (parent) { + return makeInstance(parent).add(this) + } + + // Remove element + remove () { + if (this.parent()) { + this.parent().removeElement(this) + } + + return this + } + + // Remove a given child + removeElement (element) { + this.node.removeChild(element.node) + + return this + } + + // Replace element + replace (element) { + // FIXME: after might not be available here + this.after(element).remove() + + return element + } + + // Return id on string conversion + toString () { + return this.id() + } + + // Import raw svg + svg (svg) { + var well, len + + // act as a setter if svg is given + if (svg) { + // create temporary holder + well = document.createElementNS(ns, 'svg') + // dump raw svg + well.innerHTML = svg + + // transplant nodes + for (len = well.children.length; len--;) { + this.node.appendChild(well.firstElementChild) + } + + // otherwise act as a getter + } else { + // write svgjs data to the dom + this.writeDataToDom() + + return this.node.outerHTML + } + + return this + } + + // write svgjs data to the dom + writeDataToDom () { + // dump variables recursively + this.each(function () { + this.writeDataToDom() + }) + + return this + } +} + +import {extend} from './tools.js' +import attr from './attr.js' +extend(Dom, {attr}) diff --git a/src/Element.js b/src/Element.js index 5e798ff..e7944fc 100644 --- a/src/Element.js +++ b/src/Element.js @@ -1,27 +1,20 @@ import {proportionalSize, matcher, idFromReference} from './helpers.js' -import {makeInstance, adopt, assignNewId, eid, root, getClass} from './adopter.js' +import {makeInstance, root, getClass} from './adopter.js' import {delimiter} from './regex.js' import {ns} from './namespaces.js' import SVGNumber from './SVGNumber.js' -import {registerMethods} from './methods.js' -import {registerConstructor} from './methods.js' -import EventTarget from './EventTarget.js' +import Dom from './Dom.js' const Doc = getClass(root) -//export const name = 'Element' - -export default class Element extends EventTarget { +export default class Element extends Dom { constructor (node) { - super() + super(node) - // initialize data object + // initialize data object this.dom = {} - // create circular reference - this.node = node - - this.type = node.nodeName + // create circular reference this.node.instance = this if (node.hasAttribute('svgjs:data')) { @@ -30,14 +23,9 @@ export default class Element extends EventTarget { } } - // Move over x-axis - x (x) { - return this.attr('x', x) - } - - // Move over y-axis - y (y) { - return this.attr('y', y) + // Move element by its center + center (x, y) { + return this.cx(x).cy(y) } // Move by center over x-axis @@ -52,19 +40,19 @@ export default class Element extends EventTarget { : this.y(y - this.height() / 2) } - // Move element to given x and y values - move (x, y) { - return this.x(x).y(y) + // Get defs + defs () { + return this.doc().defs() } - // Move element by its center - center (x, y) { - return this.cx(x).cy(y) + // Get parent document + doc () { + let p = this.parent(Doc) + return p && p.doc() } - // Set width of element - width (width) { - return this.attr('width', width) + getEventHolder () { + return this } // Set height of element @@ -72,65 +60,6 @@ export default class Element extends EventTarget { return this.attr('height', height) } - // Set element size to given width and height - size (width, height) { - let p = proportionalSize(this, width, height) - - return this - .width(new SVGNumber(p.width)) - .height(new SVGNumber(p.height)) - } - - // Clone element - clone (parent) { - // write dom data to the dom so the clone can pickup the data - this.writeDataToDom() - - // clone element and assign new id - let clone = assignNewId(this.node.cloneNode(true)) - - // insert the clone in the given parent or after myself - if (parent) parent.add(clone) - else this.after(clone) - - return clone - } - - // Remove element - remove () { - if (this.parent()) { this.parent().removeElement(this) } - - return this - } - - // Replace element - replace (element) { - this.after(element).remove() - - return element - } - - // Add element to given container and return self - addTo (parent) { - return makeInstance(parent).put(this) - } - - // Add element to given container and return container - putIn (parent) { - return makeInstance(parent).add(this) - } - - // Get / set id - id (id) { - // generate new id if no id set - if (typeof id === 'undefined' && !this.node.id) { - this.node.id = eid(this.type) - } - - // dont't set directly width this.node.id to make `null` work correctly - return this.attr('id', id) - } - // Checks whether the given point inside the bounding box of the element inside (x, y) { let box = this.bbox() @@ -141,83 +70,9 @@ export default class Element extends EventTarget { y < box.y + box.height } - // Return id on string conversion - toString () { - return this.id() - } - - // Return array of classes on the node - classes () { - var attr = this.attr('class') - return attr == null ? [] : attr.trim().split(delimiter) - } - - // Return true if class exists on the node, false otherwise - hasClass (name) { - return this.classes().indexOf(name) !== -1 - } - - // Add class to the node - addClass (name) { - if (!this.hasClass(name)) { - var array = this.classes() - array.push(name) - this.attr('class', array.join(' ')) - } - - return this - } - - // Remove class from the node - removeClass (name) { - if (this.hasClass(name)) { - this.attr('class', this.classes().filter(function (c) { - return c !== name - }).join(' ')) - } - - return this - } - - // Toggle the presence of a class on the node - toggleClass (name) { - return this.hasClass(name) ? this.removeClass(name) : this.addClass(name) - } - - // Get referenced element form attribute value - reference (attr) { - let id = idFromReference(this.attr(attr)) - return id ? makeInstance(id) : null - } - - // Returns the parent element instance - parent (type) { - var parent = this - - // check for parent - if (!parent.node.parentNode) return null - - // get parent element - parent = adopt(parent.node.parentNode) - - if (!type) return parent - - // loop trough ancestors if type is given - while (parent && parent.node instanceof window.SVGElement) { - if (typeof type === 'string' ? parent.matches(type) : parent instanceof type) return parent - parent = adopt(parent.node.parentNode) - } - } - - // Get parent document - doc () { - let p = this.parent(Doc) - return p && p.doc() - } - - // Get defs - defs () { - return this.doc().defs() + // Move element to given x and y values + move (x, y) { + return this.x(x).y(y) } // return array of all ancestors of given type up to the root svg @@ -235,22 +90,30 @@ export default class Element extends EventTarget { return parents } - // matches the element vs a css selector - matches (selector) { - return matcher(this.node, selector) + // Get referenced element form attribute value + reference (attr) { + let id = idFromReference(this.attr(attr)) + return id ? makeInstance(id) : null } - // Returns the svg node to call native svg methods on it - native () { - return this.node + // set given data to the elements data property + setData (o) { + this.dom = o + return this } - // Import raw svg - svg () { - // write svgjs data to the dom - this.writeDataToDom() + // Set element size to given width and height + size (width, height) { + let p = proportionalSize(this, width, height) - return this.node.outerHTML + return this + .width(new SVGNumber(p.width)) + .height(new SVGNumber(p.height)) + } + + // Set width of element + width (width) { + return this.attr('width', width) } // write svgjs data to the dom @@ -261,17 +124,18 @@ export default class Element extends EventTarget { if (Object.keys(this.dom).length) { this.node.setAttribute('svgjs:data', JSON.stringify(this.dom)) // see #428 } - return this + + return super.writeDataToDom() } - // set given data to the elements data property - setData (o) { - this.dom = o - return this + // Move over x-axis + x (x) { + return this.attr('x', x) } - getEventTarget () { - return this.node + // Move over y-axis + y (y) { + return this.attr('y', y) } } diff --git a/src/EventTarget.js b/src/EventTarget.js index a72cafd..637f7f8 100644 --- a/src/EventTarget.js +++ b/src/EventTarget.js @@ -3,11 +3,13 @@ import {on, off, dispatch} from './event.js' import {extend} from './tools.js' export default class EventTarget extends Base{ - constructor (node = {}) { + constructor ({events = {}} = {}) { super() - this.events = node.events || {} + this.events = events } + addEventListener () {} + // Bind given event to listener on (event, listener, binding, options) { on(this, event, listener, binding, options) @@ -24,11 +26,36 @@ export default class EventTarget extends Base{ return dispatch(this, event, data) } + dispatchEvent (event) { + const bag = this.getEventHolder().events + if (!bag) return true + + const events = bag[event.type] + + for (let i in events) { + for (let j in events[i]) { + events[i][j](event) + } + } + + return !event.defaultPrevented + } + // Fire given event fire (event, data) { this.dispatch(event, data) return this } + + getEventHolder () { + return this + } + + getEventTarget () { + return this + } + + removeEventListener () {} } diff --git a/src/HtmlNode.js b/src/HtmlNode.js index 258c0ec..ff45984 100644 --- a/src/HtmlNode.js +++ b/src/HtmlNode.js @@ -1,35 +1,9 @@ -import {makeInstance} from './adopter.js' -import Parent from './Parent.js' +import Dom from './Dom.js' import {register} from './adopter.js' -export default class HtmlNode extends Parent { - constructor (element) { - super(element, HtmlNode) - this.node = element - } - - add (element, i) { - element = makeInstance(element) - - if (element.node !== this.node.children[i]) { - this.node.insertBefore(element.node, this.node.children[i] || null) - } - - return this - } - - put (element, i) { - this.add(element, i) - return element - } - - removeElement (element) { - this.node.removeChild(element.node) - return this - } - - getEventTarget () { - return this.node +export default class HtmlNode extends Dom { + constructor (node) { + super(node, HtmlNode) } } diff --git a/src/Parent.js b/src/Parent.js deleted file mode 100644 index 6786329..0000000 --- a/src/Parent.js +++ /dev/null @@ -1,169 +0,0 @@ -import {makeInstance, adopt} from './adopter.js' -import {map} from './utils.js' -import {registerMethods} from './methods.js' -import Element from './Element.js' -import {ns} from './namespaces.js' - -export default class Parent extends Element { - // Returns all child elements - children () { - return map(this.node.children, function (node) { - return adopt(node) - }) - } - - // Add given element at a position - add (element, i) { - element = makeInstance(element) - - if (i == null) { - this.node.appendChild(element.node) - } else if (element.node !== this.node.childNodes[i]) { - this.node.insertBefore(element.node, this.node.childNodes[i]) - } - - return this - } - - // Basically does the same as `add()` but returns the added element instead - put (element, i) { - this.add(element, i) - return element.instance || element - } - - // Checks if the given element is a child - has (element) { - return this.index(element) >= 0 - } - - // Gets index of given element - index (element) { - return [].slice.call(this.node.childNodes).indexOf(element.node) - } - - // Get a element at the given index - get (i) { - return adopt(this.node.childNodes[i]) - } - - // Get first child - first () { - return adopt(this.node.firstChild) - } - - // Get the last child - last () { - return adopt(this.node.lastChild) - } - - // Iterates over all children and invokes a given block - each (block, deep) { - var children = this.children() - var i, il - - for (i = 0, il = children.length; i < il; i++) { - if (children[i] instanceof Element) { - block.apply(children[i], [i, children]) - } - - if (deep && (children[i] instanceof Parent)) { - children[i].each(block, deep) - } - } - - return this - } - - // Remove a given child - removeElement (element) { - this.node.removeChild(element.node) - - return this - } - - // Remove all elements in this container - clear () { - // remove children - while (this.node.hasChildNodes()) { - this.node.removeChild(this.node.lastChild) - } - - // remove defs reference - delete this._defs - - return this - } - - // Import raw svg - svg (svg) { - var well, len - - // act as a setter if svg is given - if (svg) { - // create temporary holder - well = document.createElementNS(ns, 'svg') - // dump raw svg - well.innerHTML = svg - - // transplant nodes - for (len = well.children.length; len--;) { - this.node.appendChild(well.firstElementChild) - } - - // otherwise act as a getter - } else { - // write svgjs data to the dom - this.writeDataToDom() - - return this.node.outerHTML - } - - return this - } - - // write svgjs data to the dom - writeDataToDom () { - // dump variables recursively - this.each(function () { - this.writeDataToDom() - }) - - // remove previously set data - this.node.removeAttribute('svgjs:data') - - if (Object.keys(this.dom).length) { - this.node.setAttribute('svgjs:data', JSON.stringify(this.dom)) // see #428 - } - return this - } - - flatten (parent) { - this.each(function () { - if (this instanceof Parent) return this.flatten(parent).ungroup(parent) - return this.toParent(parent) - }) - - // we need this so that Doc does not get removed - this.node.firstElementChild || this.remove() - - return this - } - - ungroup (parent) { - parent = parent || this.parent() - - this.each(function () { - return this.toParent(parent) - }) - - this.remove() - - return this - } -} - - -// registerMethods('Container', { -// children, add, put, has, index, get, first, last, each, -// removeElement, clear, svg, writeDataToDom, flatten, ungroup -// }) diff --git a/src/Runner.js b/src/Runner.js index 52731e0..b8bafa6 100644 --- a/src/Runner.js +++ b/src/Runner.js @@ -9,6 +9,7 @@ import {extend} from './tools.js' import Animator from './Animator.js' import Point from './Point.js' import {registerMethods} from './methods.js' +import EventTarget from './EventTarget.js' // FIXME: What is this doing here? // easing = { @@ -18,8 +19,10 @@ import {registerMethods} from './methods.js' // '<': function (pos) { return -Math.cos(pos * Math.PI / 2) + 1 } // } -export default class Runner { +export default class Runner extends EventTarget { constructor (options) { + super() + // Store a unique id on the runner, so that we can identify it later this.id = Runner.id++ @@ -266,7 +269,7 @@ export default class Runner { var justFinished = this._lastTime < this._time && this.time > duration this._lastTime = this._time if (justStarted) { - // this.fire('start', this) + this.fire('start', this) } // Work out if the runner is finished set the done flag here so animations @@ -282,14 +285,14 @@ export default class Runner { // clear the transforms on this runner so they dont get added again and again this.transforms = new Matrix() var converged = this._run(declarative ? dt : position) - // this.fire('step', this) + this.fire('step', this) } // correct the done flag here // declaritive animations itself know when they converged this.done = this.done || (converged && declarative) - // if (this.done) { - // this.fire('finish', this) - // } + if (this.done) { + this.fire('finish', this) + } return this } diff --git a/src/Shape.js b/src/Shape.js index bf4ae8f..f02fec2 100644 --- a/src/Shape.js +++ b/src/Shape.js @@ -1,2 +1,2 @@ -import Parent from './Parent.js' -export default class Shape extends Parent {} +import Element from './Element.js' +export default class Shape extends Element {} diff --git a/src/Text.js b/src/Text.js index 239b429..55fed22 100644 --- a/src/Text.js +++ b/src/Text.js @@ -1,4 +1,4 @@ -import Parent from './Parent.js' +import Shape from './Shape.js' import SVGNumber from './SVGNumber.js' import {nodeOrNew, extend} from './tools.js' import {attrs} from './defaults.js' @@ -6,7 +6,7 @@ import * as textable from './textable.js' import {register, adopt} from './adopter.js' import {registerMethods} from './methods.js' -export default class Text extends Parent { +export default class Text extends Shape { // Initialize node constructor (node) { super(nodeOrNew('text', node), Text) diff --git a/src/Tspan.js b/src/Tspan.js index 677adf4..148fb16 100644 --- a/src/Tspan.js +++ b/src/Tspan.js @@ -1,11 +1,10 @@ -import Parent from './Parent.js' +import Text from './Text.js' import {nodeOrNew, extend} from './tools.js' import * as textable from './textable.js' import {register} from './adopter.js' import {registerMethods} from './methods.js' -import Text from './Text.js' -export default class Tspan extends Parent { +export default class Tspan extends Text { // Initialize node constructor (node) { super(nodeOrNew('tspan', node), Tspan) diff --git a/src/arrange.js b/src/arrange.js index 4d4ec1c..d0a5b23 100644 --- a/src/arrange.js +++ b/src/arrange.js @@ -94,6 +94,6 @@ export function after (element) { return this } -registerMethods('Element', { +registerMethods('Dom', { siblings, position, next, prev, forward, backward, front, back, before, after }) diff --git a/src/attr.js b/src/attr.js index 23baf51..c44fa68 100644 --- a/src/attr.js +++ b/src/attr.js @@ -3,7 +3,7 @@ import {attrs as defaults} from './defaults.js' import Color from './Color.js' import SVGArray from './SVGArray.js' import SVGNumber from './SVGNumber.js' -import {registerMethods} from './methods.js' +//import {registerMethods} from './methods.js' // Set svg element attribute export default function attr (attr, val, ns) { @@ -80,4 +80,4 @@ export default function attr (attr, val, ns) { return this } -registerMethods('Element', {attr}) +//registerMethods('Element', {attr}) diff --git a/src/classHandling.js b/src/classHandling.js new file mode 100644 index 0000000..27bf11a --- /dev/null +++ b/src/classHandling.js @@ -0,0 +1,44 @@ +import {registerMethods} from './methods.js' +import {delimiter} from './regex.js' + +// Return array of classes on the node +function classes () { + var attr = this.attr('class') + return attr == null ? [] : attr.trim().split(delimiter) +} + +// Return true if class exists on the node, false otherwise +function hasClass (name) { + return this.classes().indexOf(name) !== -1 +} + +// Add class to the node +function addClass (name) { + if (!this.hasClass(name)) { + var array = this.classes() + array.push(name) + this.attr('class', array.join(' ')) + } + + return this +} + +// Remove class from the node +function removeClass (name) { + if (this.hasClass(name)) { + this.attr('class', this.classes().filter(function (c) { + return c !== name + }).join(' ')) + } + + return this +} + +// Toggle the presence of a class on the node +function toggleClass (name) { + return this.hasClass(name) ? this.removeClass(name) : this.addClass(name) +} + +registerMethods('Dom', { + classes, hasClass, addClass, removeClass, toggleClass +}) diff --git a/src/classes.js b/src/classes.js index 8385c20..283baaa 100644 --- a/src/classes.js +++ b/src/classes.js @@ -1,7 +1,7 @@ export {default as EventTarget} from './EventTarget.js' +export {default as Dom} from './Dom.js' export {default as Element} from './Element.js' export {default as Shape} from './Shape.js' -export {default as Parent} from './Parent.js' export {default as Container} from './Container.js' export {default as HtmlNode} from './HtmlNode.js' export {default as Doc} from './Doc.js' @@ -68,7 +68,6 @@ export {Controller, Ease, PID, Spring} from './Controller.js' // export {default as Matrix} from './Matrix.js' // export {default as Morphable} from './Morphable.js' // export {default as SVGNumber} from './SVGNumber.js' -// export {default as Parent} from './Parent.js' // export {default as Path} from './Path.js' // export {default as PathArray} from './PathArray.js' // export {default as Pattern} from './Pattern.js' @@ -68,6 +68,6 @@ export function visible () { return this.css('display') !== 'none' } -registerMethods('Element', { +registerMethods('Dom', { css, show, hide, visible }) diff --git a/src/data.js b/src/data.js index c49f6a9..6374987 100644 --- a/src/data.js +++ b/src/data.js @@ -23,4 +23,4 @@ export function data (a, v, r) { return this } -registerMethods('Element', {data}) +registerMethods('Dom', {data}) diff --git a/src/elemnts-svg.js b/src/elemnts-svg.js index 5e51034..5ee97b7 100644 --- a/src/elemnts-svg.js +++ b/src/elemnts-svg.js @@ -44,10 +44,6 @@ // Act as setter if we got a string - // Make sure we are on a current when trying to import - if(!(this instanceof SVG.Parent)) - throw Error('Cannot import svg into non-current element') - // Create temporary holder well = document.createElementNS(SVG.ns, 'svg') fragment = document.createDocumentFragment() diff --git a/src/event.js b/src/event.js index acc4dd6..2aa9daf 100644 --- a/src/event.js +++ b/src/event.js @@ -1,27 +1,38 @@ import {delimiter} from './regex.js' import {registerMethods} from './methods.js' +import {makeInstance} from './adopter.js' let listenerId = 0 +function getEvents (node) { + const n = makeInstance(node).getEventHolder() + if (!n.events) n.events = {} + return n.events +} + function getEventTarget (node) { - return typeof node.getEventTarget === 'function' - ? node.getEventTarget() - : node + return makeInstance(node).getEventTarget() +} + +function clearEvents (node) { + const n = makeInstance(node).getEventHolder() + if (n.events) n.events = {} } // Add event binder in the SVG namespace export function on (node, events, listener, binding, options) { var l = listener.bind(binding || node) + var bag = getEvents(node) var n = getEventTarget(node) // events can be an array of events or a string of events events = Array.isArray(events) ? events : events.split(delimiter) // ensure instance object for nodes which are not adopted - n.instance = n.instance || {events: {}} + // n.instance = n.instance || {events: {}} // pull event handlers from the element - var bag = n.instance.events + // var bag = n.instance.events // add id to listener if (!listener._svgjsListenerId) { @@ -46,10 +57,11 @@ export function on (node, events, listener, binding, options) { // Add event unbinder in the SVG namespace export function off (node, events, listener, options) { + var bag = getEvents(node) var n = getEventTarget(node) // we cannot remove an event if its not an svg.js instance - if (!n.instance) return + // if (!n.instance) return // listener can be a function or a number if (typeof listener === 'function') { @@ -58,7 +70,7 @@ export function off (node, events, listener, options) { } // pull event handlers from the element - var bag = n.instance.events + // var bag = n.instance.events // events can be an array of events or a string or undefined events = Array.isArray(events) ? events : (events || '').split(delimiter) @@ -101,7 +113,7 @@ export function off (node, events, listener, options) { // remove all listeners on a given node for (event in bag) { off(n, event) } - n.instance.events = {} + clearEvents(node) } }) } diff --git a/src/memory.js b/src/memory.js index 77d3518..a94f0e2 100644 --- a/src/memory.js +++ b/src/memory.js @@ -42,5 +42,5 @@ export function memory () { return (this._memory = this._memory || {}) } -registerMethods('Element', {remember, forget, memory}) +registerMethods('Dom', {remember, forget, memory}) //registerConstructor('Memory', setup) diff --git a/src/selector.js b/src/selector.js index 973787d..c6717fb 100644 --- a/src/selector.js +++ b/src/selector.js @@ -37,4 +37,4 @@ export function find (query) { return baseFind(query, this.node) } -registerMethods('Element', {find}) +registerMethods('Dom', {find}) diff --git a/src/sugar.js b/src/sugar.js index e5d6b61..6465985 100644 --- a/src/sugar.js +++ b/src/sugar.js @@ -3,6 +3,7 @@ import Runner from './Runner.js' import SVGNumber from './SVGNumber.js' import Matrix from './Matrix.js' import Point from './Point.js' +import Element from './Element.js' import {registerMethods} from './methods.js' // Define list of available attributes for stroke and fill @@ -23,7 +24,7 @@ var sugar = { if (typeof o === 'undefined') { return this } - if (typeof o === 'string' || Color.isRgb(o) || (o && typeof o.fill === 'function')) { + if (typeof o === 'string' || Color.isRgb(o) || (o instanceof Element)) { this.attr(m, o) } else { // set all attributes from sugar.fill and sugar.stroke list @@ -37,7 +38,7 @@ var sugar = { return this } - registerMethods(['Element', 'Runner'], extension) + registerMethods(['Shape', 'Runner'], extension) }) registerMethods(['Element', 'Runner'], { @@ -140,7 +141,7 @@ registerMethods('Path', { } }) -registerMethods(['Parent', 'Runner'], { +registerMethods(['Element', 'Runner'], { // Set font font: function (a, v) { if (typeof a === 'object') { @@ -1,9 +1,3 @@ -// import {extend} from './tools.js' -// import * as Element from './Element.js' -// import Defs from './Defs.js' -// -// extend(Defs, [EventTarget, Element, Parent]) - import {makeInstance} from './adopter.js' import * as Classes from './classes.js' import * as adopter from './adopter.js' @@ -13,6 +7,7 @@ import * as elements from './elements.js' import './attr.js' import './arrange.js' import './data.js' +import './classHandling.js' import find from './selector.js' import './css.js' import './transform.js' @@ -24,7 +19,6 @@ const extend = tools.extend import './EventTarget.js' import './Element.js' -import './Parent.js' extend([ Classes.Doc, @@ -59,8 +53,9 @@ extend([ ], getMethodsFor('radius')) extend(Classes.EventTarget, getMethodsFor('EventTarget')) +extend(Classes.Dom, getMethodsFor('Dom')) extend(Classes.Element, getMethodsFor('Element')) -extend(Classes.Element, getMethodsFor('Parent')) +extend(Classes.Shape, getMethodsFor('Shape')) //extend(Classes.Element, getConstructor('Memory')) extend(Classes.Container, getMethodsFor('Container')) @@ -97,8 +92,6 @@ import * as ns from './namespaces.js' SVG.get = SVG SVG.find = find Object.assign(SVG, ns) -// import Base from './Base.js' -// SVG.Element = SVG.Parent = SVG.Shape = SVG.Container = Base import {easing} from './Controller.js' SVG.easing = easing import * as events from './event.js' |