From d80af61e7a5df3928dfdc5e43f8b6b2e0d0b23ea Mon Sep 17 00:00:00 2001 From: Klemek Date: Tue, 16 Jul 2019 19:48:13 +0200 Subject: [PATCH] [skip CI] updated docs to use YAML --- build_preview.js | 3 +- dist/fa-diagrams.js | 1804 +++++++++++++++++++++------------------ dist/fa-diagrams.min.js | 2 +- docs/index.html | 9 +- docs/sample.json | 24 - docs/sample.yml | 14 + docs/yaml.min.js | 1 + 7 files changed, 974 insertions(+), 883 deletions(-) delete mode 100644 docs/sample.json create mode 100644 docs/sample.yml create mode 100644 docs/yaml.min.js diff --git a/build_preview.js b/build_preview.js index d63d203..fbacfc8 100644 --- a/build_preview.js +++ b/build_preview.js @@ -1,4 +1,5 @@ const fs = require('fs'); +const YAML = require('yaml'); const rendering = require('./src/rendering')({ 'scale': 0.05, @@ -62,6 +63,6 @@ const data = { ] }; -fs.writeFileSync('docs/sample.json', JSON.stringify(data, null, 4), {encoding: 'utf-8'}); +fs.writeFileSync('docs/sample.yml', YAML.stringify(data, null, 4), {encoding: 'utf-8'}); fs.writeFileSync('preview/sample.svg', faDiagrams.compute(data), {encoding: 'utf-8'}); \ No newline at end of file diff --git a/dist/fa-diagrams.js b/dist/fa-diagrams.js index 0468e2a..a71d3cb 100644 --- a/dist/fa-diagrams.js +++ b/dist/fa-diagrams.js @@ -8252,865 +8252,963 @@ module.exports = function(xml, userOptions) { },{"./options-helper":35,"./xml2js":36}],38:[function(require,module,exports){ (function (global){ -const placing = require('./placing'); -const rendering = require('./rendering'); - -const self = { - /** - * @param {{options: Object|undefined, nodes: Object[]|undefined, links: Object[]|undefined}} data - * @returns {string} - */ - compute: (data) => { - const options = data['options'] || {}; - - let nodes = {}; - const nodeList = (data['nodes'] || []).filter(n => typeof n.name === 'string'); - nodeList.forEach(n => nodes[n.name] = n); - - let links = (data['links'] || []).filter(l => l.from && l.to); - links.filter(l => !nodes[l.from]).forEach(l => console.warn(`unknown source node "${l.from}"`)); - links.filter(l => !nodes[l.to]).forEach(l => console.warn(`unknown destination node "${l.to}"`)); - links = links.filter(l => nodes[l.from] && nodes[l.to]); - - nodes = placing(options['placing']).compute(nodes, links); - - if (!nodes) - throw 'Failed to place nodes'; - - return rendering(options['rendering']).compute(nodes, links); - }, -}; - -module.exports = self; // Node +const placing = require('./placing'); +const rendering = require('./rendering'); + +const self = { + /** + * @param {{options: Object|undefined, nodes: Object[]|undefined, links: Object[]|undefined}} data + * @returns {string} + */ + compute: (data) => { + const options = data['options'] || {}; + + let nodes = {}; + const nodeList = (data['nodes'] || []).filter(n => typeof n.name === 'string'); + nodeList.forEach(n => nodes[n.name] = n); + + let links = (data['links'] || []).filter(l => l.from && l.to); + links.filter(l => !nodes[l.from]).forEach(l => console.warn(`unknown source node "${l.from}"`)); + links.filter(l => !nodes[l.to]).forEach(l => console.warn(`unknown destination node "${l.to}"`)); + links = links.filter(l => nodes[l.from] && nodes[l.to]); + + nodes = placing(options['placing']).compute(nodes, links); + + if (!nodes) + throw 'Failed to place nodes'; + + return rendering(options['rendering']).compute(nodes, links); + }, +}; + +module.exports = self; // Node global['faDiagrams'] = self; // Browserify }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) },{"./placing":39,"./rendering":40}],39:[function(require,module,exports){ -const utils = require('./utils'); - -/** - * @typedef Node1 - * @property {string} name - * @property {undefined|number} x - * @property {undefined|number} y - * @property {undefined|{beforeX: string[], afterX: string[], beforeY: string[], afterY: string[]}} const - */ - -/** - * @typedef Link1 - * @property {string} from - * @property {string} to - * @property {string|undefined} direction - */ - -const NODE_DEF = { - 'name': '!string', - 'x': 'number', - 'y': 'number' -}; - -const LINK_DEF = { - 'from': '!string', - 'to': '!string', - 'direction': 'string' -}; - -const DEFAULT_OPTIONS = { - 'max-link-length': 3, - 'diagonals': true, -}; - -module.exports = (options) => { - - options = utils.merge(DEFAULT_OPTIONS, options); - - const self = { - - /** - * Get the current bounds of the graph of nodes - * @param {Object} nodes - * @returns {{w: number, x: number, h: number, y: number}} - */ - getBounds: (nodes) => { - const list = Object.values(nodes).filter(n => n.x !== undefined); - if (list.length === 0) - return {x: 0, y: 0, w: 0, h: 0}; //empty - let minX = null; - let minY = null; - let maxX = null; - let maxY = null; - list.forEach(n => { - minX = minX !== null ? Math.min(n.x, minX) : n.x; - minY = minY !== null ? Math.min(n.y, minY) : n.y; - maxX = maxX !== null ? Math.max(n.x, maxX) : n.x; - maxY = maxY !== null ? Math.max(n.y, maxY) : n.y; - }); - return {x: minX, y: minY, w: maxX - minX + 1, h: maxY - minY + 1}; - }, - - /** - * Get a new available position around the existing nodes - * @param {Object} nodes - * @returns {{x: number, y: number}} - */ - getNewPos: (nodes) => { - const b = self.getBounds(nodes); - const map = utils.newMap(b.w, b.h, false); - const list = Object.values(nodes).filter(n => n.x !== undefined); - list.forEach(n => { - map[n.x - b.x][n.y - b.y] = true; - }); - for (let y = 0; y < b.h; y++) { - for (let x = 0; x < b.w; x++) { - if (!map[x][y]) - return {x: x + b.x, y: y + b.y}; - } - } - if (b.w <= b.h) - return {x: b.x + b.w, y: b.y}; //expand horizontally - else - return {x: b.x, y: b.y + b.h}; //expand vertically - }, - - /** - * Check if no other nodes are located in the path of n1 <-> n2 - * @param {Object} nodes - * @param {string} n1 - * @param {string} n2 - * @returns {boolean} - */ - nodeBetween: (nodes, n1, n2) => { - let x1 = nodes[n1].x; - let y1 = nodes[n1].y; - let x2 = nodes[n2].x; - let y2 = nodes[n2].y; - - const dx = x2 - x1; - const dy = y2 - y1; - - const samePos = (x, y) => n => n.x === x && n.y === y && n.name !== n1 && n.name !== n2; - - if (Math.abs(dx) >= Math.abs(dy)) { - if (x1 > x2) { - let tmp = x1; - x1 = x2; - x2 = tmp; - } - for (let x = x1; x <= x2; x++) { - let y = Math.round(y1 + dy * (x - x1) / dx); - if (Object.values(nodes).find(samePos(x, y))) - return true; - } - } else { - if (y1 > y2) { - let tmp = y1; - y1 = y2; - y2 = tmp; - } - for (let y = y1; y <= y2; y++) { - let x = Math.round(x1 + dx * (y - y1) / dy); - if (Object.values(nodes).find(samePos(x, y))) - return true; - } - } - return false; - }, - - /** - * Compute the area of possibility for the node placement and return the node calculated position or if it is unconstrained - * @param {Object} nodes - * @param {string} n - node key - * @param {boolean} diagonals - * @returns {null|{x: number, y: number, free: boolean}} null if not possible - */ - getPosition: (nodes, n, diagonals) => { - const node = nodes[n]; - const c = { - maxX: null, - maxY: null, - minX: null, - minY: null, - startX: null, - startY: null, - free: true, - }; - - const apply = (dMinX, dMaxX, dMinY, dMaxY) => n2 => { - if (nodes[n2].x !== undefined) { - const x2 = nodes[n2].x; - const y2 = nodes[n2].y; - c.minX = c.minX !== null ? Math.max(x2 + dMinX, c.minX) : x2 + dMinX; - c.maxX = c.maxX !== null ? Math.min(x2 + dMaxX, c.maxX) : x2 + dMaxX; - c.minY = c.minY !== null ? Math.max(y2 + dMinY, c.minY) : y2 + dMinY; - c.maxY = c.maxY !== null ? Math.min(y2 + dMaxY, c.maxY) : y2 + dMaxY; - if (c.startX === null) { - c.startX = Math.abs(dMaxY + dMinY) > 0 ? x2 : (Math.abs(dMinX) === 1 ? 'minX' : 'maxX'); - c.startY = Math.abs(dMaxX + dMinX) > 0 ? y2 : (Math.abs(dMinY) === 1 ? 'minY' : 'maxY'); - } - c.free = false; - } - }; - - const area = options['max-link-length']; - const sideArea = diagonals ? area : 0; - - node.const.beforeX.forEach(apply(1, 1 + area, -sideArea, sideArea)); - node.const.beforeY.forEach(apply(-sideArea, sideArea, 1, 1 + area)); - node.const.afterX.forEach(apply(-1 - area, -1, -sideArea, sideArea)); - node.const.afterY.forEach(apply(-sideArea, sideArea, -1 - area, -1)); - - if (typeof c.startX === 'string') - c.startX = c[c.startX]; - if (typeof c.startY === 'string') - c.startY = c[c.startY]; - - return (c.minX > c.maxX || c.minY > c.maxY) ? null : {x: c.startX, y: c.startY, free: c.free}; - }, - - /** - * Test if the links are respected by the currently placed nodes - * @param {Object} nodes - * @param {Link1[]} links - * @returns {boolean} - */ - isValid: (nodes, links) => { - let link, src, dst; - - //check overlapping - const list = Object.values(nodes).filter(n => n.x !== undefined); - for (let n1 = 0; n1 < list.length - 1; n1++) - for (let n2 = n1 + 1; n2 < list.length; n2++) { - if (list[n1].x === list[n2].x && list[n1].y === list[n2].y) - return false; - } - - - for (let li = 0; li < links.length; li++) { - link = links[li]; - src = nodes[link.from]; - dst = nodes[link.to]; - if (src.x !== undefined && dst.x !== undefined) { - if (self.nodeBetween(nodes, link.from, link.to)) - return false; - if (Math.pow(dst.x - src.x, 2) + Math.pow(dst.y - src.y, 2) > Math.pow(options['max-link-length'], 2)) - return false; - switch (link.direction) { - case 'up': - case 'top': - if (dst.y - src.y >= 0) return false; - break; - case 'down': - case 'bottom': - if (dst.y - src.y <= 0) return false; - break; - case 'left': - if (dst.x - src.x >= 0) return false; - break; - case 'right': - if (dst.x - src.x <= 0) return false; - break; - } - if (!options['diagonals'] && src.x !== dst.x && src.y !== dst.y) - return false; - } - } - return true; - }, - - - /** - * Assure that all nodes coordinates are starting at 0,0 - * @param {Object} nodes - */ - correctPlacing: (nodes) => { - const b = self.getBounds(nodes); - Object.values(nodes).forEach(node => { - node.x -= b.x; - node.y -= b.y; - }); - }, - - /** - * Core function that do the placing recursively until one combination works - * @param {Object} nodes - * @param {Link1[]} links - * @param {number} depth - * @returns {null|Object} - */ - applyLinks: (nodes, links, depth = 0) => { - if (!self.isValid(nodes, links)) { - return null; - } - - const keys = Object.keys(nodes).filter(k => nodes[k].x === undefined); //not placed - - if (keys.length === 0) - return nodes; - - const free = []; - - const tryPos = (key, x, y) => { - const nodes2 = utils.ezClone(nodes); - nodes2[key].x = x; - nodes2[key].y = y; - return self.applyLinks(nodes2, links, depth + 1); - }; - - let key; - let nodes2; - let p; - - // prefer no diagonals - for (let ln = 0; ln < keys.length; ln++) { - key = keys[ln]; - p = self.getPosition(nodes, key, false); - if (!p && !options['diagonals']) { - return null; - } else if (p && p.free) { - free.push(keys[ln]); - } else if (p) { - nodes2 = tryPos(key, p.x, p.y); - if (nodes2) - return nodes2; - } - } - - // allow diagonals - for (let ln = 0; ln < keys.length; ln++) { - key = keys[ln]; - p = self.getPosition(nodes, key, true); - if (!p) { - return null; - } else if (p.free) { - free.push(keys[ln]); - } else { - nodes2 = tryPos(key, p.x, p.y); - if (nodes2) - return nodes2; - } - } - - for (let ln = 0; ln < free.length; ln++) { - key = free[ln]; - p = self.getNewPos(nodes); - nodes2 = tryPos(key, p.x, p.y); - if (nodes2) - return nodes2; - } - return null; - }, - - /** - * Compute x and y coordinates of the nodes with the given links between them - * @param {Object} nodes - * @param {Link1[]} links - * @returns {Object|null} - */ - compute: (nodes, links) => { - - Object.keys(nodes).forEach(key => { - const res = utils.isValid(nodes[key], NODE_DEF); - if (res) - throw `Node '${key}' is invalid at key '${res}'`; - }); - - links.forEach((link, i) => { - const res = utils.isValid(link, LINK_DEF); - if (res) - throw `Link ${i} (${link.from}->${link.to}) is invalid at key '${res}'`; - }); - - Object.values(nodes).forEach(node => { - node.const = { - beforeX: [], - afterX: [], - beforeY: [], - afterY: [] - }; - }); - - links.forEach(link => { - if (link.direction) { - switch (link.direction) { - case 'up': - case 'top': - nodes[link.from].const.beforeY.push(link.to); - nodes[link.to].const.afterY.push(link.from); - break; - case 'down': - case 'bottom': - nodes[link.from].const.afterY.push(link.to); - nodes[link.to].const.beforeY.push(link.from); - break; - case 'left': - nodes[link.from].const.beforeX.push(link.to); - nodes[link.to].const.afterX.push(link.from); - break; - case 'right': - nodes[link.from].const.afterX.push(link.to); - nodes[link.to].const.beforeX.push(link.from); - break; - } - } - }); - - nodes = self.applyLinks(nodes, links); - - if (nodes) { - self.correctPlacing(nodes); - - Object.values(nodes).forEach(node => { - delete node.const; - }); - } - - return nodes; - }, - - }; - return self; +const utils = require('./utils'); + +/** + * @typedef Node1 + * @property {string} name + * @property {undefined|number} x + * @property {undefined|number} y + * @property {undefined|{beforeX: string[], afterX: string[], beforeY: string[], afterY: string[]}} const + */ + +/** + * @typedef Link1 + * @property {string} from + * @property {string} to + * @property {string|undefined} direction + */ + +const NODE_DEF = { + 'name': '!string', + 'x': 'number', + 'y': 'number' +}; + +const LINK_DEF = { + 'from': '!string', + 'to': '!string', + 'direction': 'string' +}; + +const DEFAULT_OPTIONS = { + 'max-link-length': 3, + 'diagonals': true, +}; + +module.exports = (options) => { + + options = utils.merge(DEFAULT_OPTIONS, options); + + const self = { + + /** + * Get the current bounds of the graph of nodes + * @param {Object} nodes + * @returns {{w: number, x: number, h: number, y: number}} + */ + getBounds: (nodes) => { + const list = Object.values(nodes).filter(n => n.x !== undefined); + if (list.length === 0) + return {x: 0, y: 0, w: 0, h: 0}; //empty + let minX = null; + let minY = null; + let maxX = null; + let maxY = null; + list.forEach(n => { + minX = minX !== null ? Math.min(n.x, minX) : n.x; + minY = minY !== null ? Math.min(n.y, minY) : n.y; + maxX = maxX !== null ? Math.max(n.x, maxX) : n.x; + maxY = maxY !== null ? Math.max(n.y, maxY) : n.y; + }); + return {x: minX, y: minY, w: maxX - minX + 1, h: maxY - minY + 1}; + }, + + /** + * Get a new available position around the existing nodes + * @param {Object} nodes + * @returns {{x: number, y: number}} + */ + getNewPos: (nodes) => { + const b = self.getBounds(nodes); + const map = utils.newMap(b.w, b.h, false); + const list = Object.values(nodes).filter(n => n.x !== undefined); + list.forEach(n => { + map[n.x - b.x][n.y - b.y] = true; + }); + for (let y = 0; y < b.h; y++) { + for (let x = 0; x < b.w; x++) { + if (!map[x][y]) + return {x: x + b.x, y: y + b.y}; + } + } + if (b.w <= b.h) + return {x: b.x + b.w, y: b.y}; //expand horizontally + else + return {x: b.x, y: b.y + b.h}; //expand vertically + }, + + /** + * Check if no other nodes are located in the path of n1 <-> n2 + * @param {Object} nodes + * @param {string} n1 + * @param {string} n2 + * @returns {boolean} + */ + nodeBetween: (nodes, n1, n2) => { + let x1 = nodes[n1].x; + let y1 = nodes[n1].y; + let x2 = nodes[n2].x; + let y2 = nodes[n2].y; + + const dx = x2 - x1; + const dy = y2 - y1; + + const samePos = (x, y) => n => n.x === x && n.y === y && n.name !== n1 && n.name !== n2; + + if (Math.abs(dx) >= Math.abs(dy)) { + if (x1 > x2) { + let tmp = x1; + x1 = x2; + x2 = tmp; + } + for (let x = x1; x <= x2; x++) { + let y = Math.round(y1 + dy * (x - x1) / dx); + if (Object.values(nodes).find(samePos(x, y))) + return true; + } + } else { + if (y1 > y2) { + let tmp = y1; + y1 = y2; + y2 = tmp; + } + for (let y = y1; y <= y2; y++) { + let x = Math.round(x1 + dx * (y - y1) / dy); + if (Object.values(nodes).find(samePos(x, y))) + return true; + } + } + return false; + }, + + /** + * Compute the area of possibility for the node placement and return the node calculated position or if it is unconstrained + * @param {Object} nodes + * @param {string} n - node key + * @param {boolean} diagonals + * @returns {null|{x: number, y: number, free: boolean}} null if not possible + */ + getPosition: (nodes, n, diagonals) => { + const node = nodes[n]; + const c = { + maxX: null, + maxY: null, + minX: null, + minY: null, + startX: null, + startY: null, + free: true, + }; + + const apply = (dMinX, dMaxX, dMinY, dMaxY) => n2 => { + if (nodes[n2].x !== undefined) { + const x2 = nodes[n2].x; + const y2 = nodes[n2].y; + c.minX = c.minX !== null ? Math.max(x2 + dMinX, c.minX) : x2 + dMinX; + c.maxX = c.maxX !== null ? Math.min(x2 + dMaxX, c.maxX) : x2 + dMaxX; + c.minY = c.minY !== null ? Math.max(y2 + dMinY, c.minY) : y2 + dMinY; + c.maxY = c.maxY !== null ? Math.min(y2 + dMaxY, c.maxY) : y2 + dMaxY; + if (c.startX === null) { + c.startX = Math.abs(dMaxY + dMinY) > 0 ? x2 : (Math.abs(dMinX) === 1 ? 'minX' : 'maxX'); + c.startY = Math.abs(dMaxX + dMinX) > 0 ? y2 : (Math.abs(dMinY) === 1 ? 'minY' : 'maxY'); + } + c.free = false; + } + }; + + const area = options['max-link-length']; + const sideArea = diagonals ? area : 0; + + node.const.beforeX.forEach(apply(1, 1 + area, -sideArea, sideArea)); + node.const.beforeY.forEach(apply(-sideArea, sideArea, 1, 1 + area)); + node.const.afterX.forEach(apply(-1 - area, -1, -sideArea, sideArea)); + node.const.afterY.forEach(apply(-sideArea, sideArea, -1 - area, -1)); + + if (typeof c.startX === 'string') + c.startX = c[c.startX]; + if (typeof c.startY === 'string') + c.startY = c[c.startY]; + + return (c.minX > c.maxX || c.minY > c.maxY) ? null : {x: c.startX, y: c.startY, free: c.free}; + }, + + /** + * Test if the links are respected by the currently placed nodes + * @param {Object} nodes + * @param {Link1[]} links + * @returns {boolean} + */ + isValid: (nodes, links) => { + let link, src, dst; + + //check overlapping + const list = Object.values(nodes).filter(n => n.x !== undefined); + for (let n1 = 0; n1 < list.length - 1; n1++) + for (let n2 = n1 + 1; n2 < list.length; n2++) { + if (list[n1].x === list[n2].x && list[n1].y === list[n2].y) + return false; + } + + + for (let li = 0; li < links.length; li++) { + link = links[li]; + src = nodes[link.from]; + dst = nodes[link.to]; + if (src.x !== undefined && dst.x !== undefined) { + if (self.nodeBetween(nodes, link.from, link.to)) + return false; + if (Math.pow(dst.x - src.x, 2) + Math.pow(dst.y - src.y, 2) > Math.pow(options['max-link-length'], 2)) + return false; + switch (link.direction) { + case 'up': + case 'top': + if (dst.y - src.y >= 0) return false; + break; + case 'down': + case 'bottom': + if (dst.y - src.y <= 0) return false; + break; + case 'left': + if (dst.x - src.x >= 0) return false; + break; + case 'right': + if (dst.x - src.x <= 0) return false; + break; + } + if (!options['diagonals'] && src.x !== dst.x && src.y !== dst.y) + return false; + } + } + return true; + }, + + + /** + * Assure that all nodes coordinates are starting at 0,0 + * @param {Object} nodes + */ + correctPlacing: (nodes) => { + const b = self.getBounds(nodes); + Object.values(nodes).forEach(node => { + node.x -= b.x; + node.y -= b.y; + }); + }, + + /** + * Core function that do the placing recursively until one combination works + * @param {Object} nodes + * @param {Link1[]} links + * @param {number} depth + * @returns {null|Object} + */ + applyLinks: (nodes, links, depth = 0) => { + if (!self.isValid(nodes, links)) { + return null; + } + + const keys = Object.keys(nodes).filter(k => nodes[k].x === undefined); //not placed + + if (keys.length === 0) + return nodes; + + const free = []; + + const tryPos = (key, x, y) => { + const nodes2 = utils.ezClone(nodes); + nodes2[key].x = x; + nodes2[key].y = y; + return self.applyLinks(nodes2, links, depth + 1); + }; + + let key; + let nodes2; + let p; + + // prefer no diagonals + for (let ln = 0; ln < keys.length; ln++) { + key = keys[ln]; + p = self.getPosition(nodes, key, false); + if (!p && !options['diagonals']) { + return null; + } else if (p && p.free) { + free.push(keys[ln]); + } else if (p) { + nodes2 = tryPos(key, p.x, p.y); + if (nodes2) + return nodes2; + } + } + + // allow diagonals + for (let ln = 0; ln < keys.length; ln++) { + key = keys[ln]; + p = self.getPosition(nodes, key, true); + if (!p) { + return null; + } else if (p.free) { + free.push(keys[ln]); + } else { + nodes2 = tryPos(key, p.x, p.y); + if (nodes2) + return nodes2; + } + } + + for (let ln = 0; ln < free.length; ln++) { + key = free[ln]; + p = self.getNewPos(nodes); + nodes2 = tryPos(key, p.x, p.y); + if (nodes2) + return nodes2; + } + return null; + }, + + /** + * Compute x and y coordinates of the nodes with the given links between them + * @param {Object} nodes + * @param {Link1[]} links + * @returns {Object|null} + */ + compute: (nodes, links) => { + + Object.keys(nodes).forEach(key => { + const res = utils.isValid(nodes[key], NODE_DEF); + if (res) + throw `Node '${key}' is invalid at key '${res}'`; + }); + + links.forEach((link, i) => { + const res = utils.isValid(link, LINK_DEF); + if (res) + throw `Link ${i} (${link.from}->${link.to}) is invalid at key '${res}'`; + }); + + Object.values(nodes).forEach(node => { + node.const = { + beforeX: [], + afterX: [], + beforeY: [], + afterY: [] + }; + }); + + links.forEach(link => { + if (link.direction) { + switch (link.direction) { + case 'up': + case 'top': + nodes[link.from].const.beforeY.push(link.to); + nodes[link.to].const.afterY.push(link.from); + break; + case 'down': + case 'bottom': + nodes[link.from].const.afterY.push(link.to); + nodes[link.to].const.beforeY.push(link.from); + break; + case 'left': + nodes[link.from].const.beforeX.push(link.to); + nodes[link.to].const.afterX.push(link.from); + break; + case 'right': + nodes[link.from].const.afterX.push(link.to); + nodes[link.to].const.beforeX.push(link.from); + break; + } + } + }); + + nodes = self.applyLinks(nodes, links); + + if (nodes) { + self.correctPlacing(nodes); + + Object.values(nodes).forEach(node => { + delete node.const; + }); + } + + return nodes; + }, + + }; + return self; }; },{"./utils":41}],40:[function(require,module,exports){ -const convert = require('xml-js'); -const utils = require('./utils'); - -let resources = { - name: 'error', - height: 512, - index: [], - links: { - 'arrow-head': {}, - 'arrow-head-reverse': {}, - 'line-start': {}, - 'line-end': {}, - 'dashed-step': {} - }, - icons: {} -}; -try { - resources = require('../resources.json'); -} catch (err) { - console.error('fa-diagrams: SVG resources could not be loaded: ' + err); -} - -/** - * @typedef Node2 - * @property {string} name - * @property {number} x - * @property {number} y - * @property {string|{path:string,width:number:height:number}} icon - */ - -/** - * @typedef Link2 - * @property {string} from - * @property {string} to - * @property {string|undefined} type - */ - -const SUB_DEF = { - '_': 'string', - 'text': 'string', - 'icon': { - '_': 'string', - 'path': 'string', - 'width': 'number', - 'height': 'number' - }, - 'color': 'string', - 'font': 'string', - 'font-size': 'number', - 'font-style': 'string', - 'scale': 'number', -}; - -const NODE_DEF = { - 'name': '!string', - 'icon': { - '_': 'string', - 'path': 'string', - 'width': 'number', - 'height': 'number' - }, - 'x': '!number', - 'y': '!number', - 'color': 'string', - 'scale': 'number', - 'top': SUB_DEF, - 'bottom': SUB_DEF, - 'left': SUB_DEF, - 'right': SUB_DEF -}; - -const LINK_DEF = { - 'from': '!string', - 'to': '!string', - 'type': 'string', - 'color': 'string', - 'scale': 'number', - 'size': 'number', - 'top': SUB_DEF, - 'bottom': SUB_DEF, -}; - -const DEFAULT_OPTIONS = { - 'beautify': false, - 'scale': 128, - 'h-spacing': 1.3, - 'color': 'black', - 'icons': { - 'scale': 1, - 'color': '' - }, - 'links': { - 'scale': 1, - 'color': '', - 'size': 0 - }, - 'texts': { - 'font': 'sans-serif', - 'font-size': '20', - 'font-style': 'normal', - 'color': '' - } -}; - -const SUBSTITUTES = { - 'font-awesome': { - 'fas': 'solid', - 'far': 'regular', - 'fab': 'brands' - } -}; - -const DEFAULT_SCALE = 0.4; -const LINK_MARGIN = (1 - DEFAULT_SCALE) / 2; - -module.exports = (options) => { - - options = utils.merge(DEFAULT_OPTIONS, options); - - const self = { - - /** - * Find icon data from given name or data - * @param {string|{path: string, width: number, height: number}} icon - * @returns {null|{path: string, width: number, height: number}} - */ - getIcon: (icon) => { - if (!icon) - return null; - - if (typeof icon === 'object') { - if (!icon.path || !icon.path.trim()) - return null; - - icon.height = icon.height || icon.width || resources.height; - icon.width = icon.width || icon.height; - return icon; - } - - if (!icon.trim()) - return null; - - let search = utils.ezClone(resources.index); - const spl = icon.trim().split(' ').map(t => t.indexOf('fa-') === 0 ? t.substr(3) : t); - - for (let i = 0; i < spl.length; i++) { - //replace fas by regular for example - if (Object.keys(SUBSTITUTES[resources.name] || {}).includes(spl[i])) { - spl[i] = SUBSTITUTES[resources.name][spl[i]]; - } - if (resources.index.includes(spl[i])) { - search = [spl.splice(i, 1)]; - } - } - - icon = spl[0]; - - for (let i = 0; i < search.length; i++) { - if (resources.icons[search[i]] && resources.icons[search[i]][icon]) { - resources.icons[search[i]][icon].height = resources.height; - return resources.icons[search[i]][icon]; - } - } - - return null; - }, - - /** - * Create the correct path from the type and width - * @param {string} type - * @param {number} width - * @return {string|null} - */ - getLinkPath: (type, width) => { - const arrowHead = 'v46.059c0 21.382 25.851 32.09 40.971 16.971 l86.059 -86.059c9.373-9.373 9.373-24.569 0-33.941l-86.059-86.059c-15.119-15.119-40.971-4.411-40.971 16.971v46.059'; //134.059 - const arrowHeadR = 'v-46.059c0-21.382-25.851-32.09-40.971-16.971l-86.059 86.059c-9.373 9.373-9.373 24.568 0 33.941l86.059 86.059c15.119 15.119 40.971 4.411 40.971-16.971v-46.059'; //134.059 - const lineEnd = 'c6.627 0 12 -5.373 12 -12v-56c0 -6.627 -5.373 -12 -12 -12'; // 12 - const lineStart = 'c-6.627 0-12 5.373-12 12v56c0 6.627 5.373 12 12 12'; // 12 - const dashedStep = `${lineStart}h56${lineEnd}`; // 80 - switch (type) { - case 'none': - return null; - default: - return `M12 216${lineStart}h${width * 512 - 146.059}${arrowHead}z`; - case 'line': - return `M12 216${lineStart}h${width * 512 - 24}${lineEnd}z`; - case 'double': - return `M134.059 216${arrowHeadR}h${width * 512 - 268.06}${arrowHead}z`; - case 'split-double': - return `M12 126${lineStart}h${width * 512 - 146.059}${arrowHead}M134.059 306${arrowHeadR}h${width * 512 - 146.059}${lineEnd}z`; - case 'dashed': - const n1 = Math.floor((width * 512 - 134.059) / (80 * 2.1)); - const space1 = ((width * 512 - 134.059) - n1 * 56 - 24) / (n1); - return `M12 216${new Array(n1).fill(`${dashedStep}m${space1} 0`).join('')}v80${arrowHead}z`; - case 'dashed-line': - const n2 = Math.floor(width * 512 / (80 * 2.1)); - const space2 = (width * 512 - n2 * 56 - 24) / (n2 - 1); - return `M12 216${new Array(n2).fill(dashedStep).join(`m${space2} 0`)}z`; - case 'dashed-double': - const n3 = Math.floor((width * 512 - 134.059 * 2) / (80 * 2.1)); - const space3 = ((width * 512 - 134.059 * 2) - n3 * 56 - 24) / (n3 + 1); - return `M134.059 216${arrowHeadR}m${space3}-80${new Array(n3).fill(`${dashedStep}m${space3} 0`).join('')}v80${arrowHead}z`; - case 'dashed-split-double': - const n4 = Math.floor((width * 512 - 134.059) / (80 * 2.1)); - const space4 = ((width * 512 - 134.059) - n4 * 56 - 24) / (n4); - return `M12 126${new Array(n4).fill(`${dashedStep}m${space4} 0`).join('')}v80${arrowHead}M134.059 306${arrowHeadR}m${space4} -80${new Array(n4).fill(`${dashedStep}`).join(`m${space4} 0`)}z`; - } - }, - - /** - * Get the width and height of the graph of nodes - * @param {Object} nodes - * @returns {{w: number, h: number}} - */ - getBounds: (nodes) => { - const list = Object.values(nodes); - if (list.length === 0) - return {w: 0, h: 0}; //empty - let maxX = 0; - let maxY = 0; - list.forEach(n => { - maxX = Math.max(n.x, maxX); - maxY = Math.max(n.y, maxY); - }); - return {w: maxX + 1, h: maxY + 1}; - }, - - /** - * @param {Node2} node - */ - renderNode: (node) => { - const icon = self.getIcon(node.icon); - if (!icon) - return null; - const scale = (node['scale'] || options['icons']['scale']) * DEFAULT_SCALE; - return { - '_attributes': { - 'transform': `translate(${(node.x + 0.5) * options['h-spacing']} ${node.y + 0.5})`, - }, - 'g': { - '_attributes': { - 'transform': `scale(${scale / icon.height} ${scale / icon.height}) translate(${-icon.width / 2} ${-icon.height / 2})`, - 'stroke': (node['color'] || options['icons']['color'] || undefined), - 'fill': (node['color'] || options['icons']['color'] || undefined) - }, - 'path': { - '_attributes': { - 'd': icon.path, - } - } - } - }; - }, - - /** - * @param {Object} nodes - * @param {Link2} link - */ - renderLink: (nodes, link) => { - const src = nodes[link.from]; - const dst = nodes[link.to]; - - const posX = ((src.x + dst.x) / 2 + 0.5) * options['h-spacing']; - const posY = (src.y + dst.y) / 2 + 0.5; - - const angle = Math.atan2(dst.y - src.y, (dst.x - src.x) * options['h-spacing']) * 180 / Math.PI; - const scale = (link['scale'] || options['links']['scale']) * DEFAULT_SCALE; - - let size = link['size'] || options['links']['size']; - - if (!size) { - let dx = Math.abs(dst.x - src.x) * options['h-spacing']; - if (dx > 0) - dx -= LINK_MARGIN * 2; - let dy = Math.abs(dst.y - src.y); - if (dy > 0) - dy -= LINK_MARGIN * 2; - - size = Math.sqrt(Math.pow(dx, 2) + Math.pow(dy, 2)) / scale; - } - - const path = self.getLinkPath(link.type, size); - - if (!path) - return null; - - return { - '_attributes': { - 'transform': `translate(${posX} ${posY}) rotate(${angle})` - }, - 'g': { - '_attributes': { - 'transform': `scale(${scale / 512} ${scale / 512}) translate(${(-256 * size)} ${-256})`, - 'stroke': (link['color'] || options['links']['color'] || undefined), - 'fill': (link['color'] || options['links']['color'] || undefined) - }, - 'path': { - '_attributes': { - 'd': path - } - } - } - }; - }, - - /** - * Convert xml-js data into correct svg xml string - * @param {Object} data - * @param {{w:number, h:number}} bounds - * @returns {string} - */ - toXML: (data, bounds) => { - const xml = { - 'svg': { - '_attributes': { - 'xmlns': 'http://www.w3.org/2000/svg', - 'viewBox': `0 0 ${bounds.w * options['h-spacing']} ${bounds.h}`, - 'width': bounds.w * options['h-spacing'] * options['scale'] / DEFAULT_SCALE, - 'height': bounds.h * options['scale'] / DEFAULT_SCALE, - 'stroke': options['color'], - 'fill': options['color'] - } - } - }; - Object.keys(data).forEach(key => { - xml['svg'][key] = data[key]; - }); - return convert.js2xml(xml, { - compact: true, - spaces: options['beautify'] ? '\t' : 0 - }); - }, - - /** - * @param {Object} nodes - * @param {Link2[]} links - */ - compute: (nodes, links) => { - - const data = {'g': []}; - - Object.keys(nodes).forEach(key => { - const res = utils.isValid(nodes[key], NODE_DEF); - if (res) - throw `Node '${key}' is invalid at key '${res}'`; - const group = self.renderNode(nodes[key]); - if (group) - data['g'].push(group); - }); - - links.forEach((link, i) => { - const res = utils.isValid(link, LINK_DEF); - if (res) - throw `Link ${i} (${link.from}->${link.to}) is invalid at key '${res}'`; - const group = self.renderLink(nodes, link); - if (group) - data['g'].push(group); - }); - - const bounds = self.getBounds(nodes); - - return self.toXML(data, bounds); - } - }; - - return self; +const convert = require('xml-js'); +const utils = require('./utils'); + +let resources = { + name: 'error', + height: 512, + index: [], + links: { + 'arrow-head': {}, + 'arrow-head-reverse': {}, + 'line-start': {}, + 'line-end': {}, + 'dashed-step': {} + }, + icons: {} +}; +try { + resources = require('../resources.json'); +} catch (err) { + console.error('fa-diagrams: SVG resources could not be loaded: ' + err); +} + +/** + * @typedef Node2 + * @property {string} name + * @property {number} x + * @property {number} y + * @property {string|{path:string,width:number:height:number}} icon + * @property {Object|undefined} bottom + * @property {Object|undefined} top + * @property {Object|undefined} left + * @property {Object|undefined} right + */ + +/** + * @typedef Link2 + * @property {string} from + * @property {string} to + * @property {string|undefined} type + * @property {Object|undefined} bottom + * @property {Object|undefined} top + */ + +const SUB_DEF = { + '_': 'string', + 'text': 'string', + 'icon': { + '_': 'string', + 'path': 'string', + 'width': 'number', + 'height': 'number' + }, + 'color': 'string', + 'font': 'string', + 'font-size': 'number', + 'font-style': 'string', + 'margin': 'number', + 'line-height': 'number', + 'scale': 'number' +}; + +const NODE_DEF = { + 'name': '!string', + 'icon': { + '_': 'string', + 'path': 'string', + 'width': 'number', + 'height': 'number' + }, + 'x': '!number', + 'y': '!number', + 'color': 'string', + 'scale': 'number', + 'top': SUB_DEF, + 'bottom': SUB_DEF, + 'left': SUB_DEF, + 'right': SUB_DEF +}; + +const LINK_DEF = { + 'from': '!string', + 'to': '!string', + 'type': 'string', + 'color': 'string', + 'scale': 'number', + 'size': 'number', + 'top': SUB_DEF, + 'bottom': SUB_DEF, +}; + +const DEFAULT_OPTIONS = { + 'beautify': false, + 'scale': 128, + 'h-spacing': 1.3, + 'color': 'black', + 'icons': { + 'scale': 1, + 'color': '' + }, + 'links': { + 'scale': 1, + 'color': '', + 'size': 0 + }, + 'texts': { + 'font': 'Arial', + 'font-size': 15, + 'font-style': 'normal', + 'color': '', + 'margin': 0.2, + 'line-height': 1.2 + } +}; + +const SUBSTITUTES = { + 'font-awesome': { + 'fas': 'solid', + 'far': 'regular', + 'fab': 'brands' + } +}; + +const DEFAULT_SCALE = 0.4; +const LINK_MARGIN = (1 - DEFAULT_SCALE) / 2; + +module.exports = (options) => { + + options = utils.merge(DEFAULT_OPTIONS, options); + + const self = { + + /** + * Find icon data from given name or data + * @param {string|{path: string, width: number, height: number}} icon + * @returns {null|{path: string, width: number, height: number}} + */ + getIcon: (icon) => { + if (!icon) + return null; + + if (typeof icon === 'object') { + if (!icon.path || !icon.path.trim()) + return null; + + icon.height = icon.height || icon.width || resources.height; + icon.width = icon.width || icon.height; + return icon; + } + + if (!icon.trim()) + return null; + + let search = utils.ezClone(resources.index); + const spl = icon.trim().split(' ').map(t => t.indexOf('fa-') === 0 ? t.substr(3) : t); + + for (let i = 0; i < spl.length; i++) { + //replace fas by regular for example + if (Object.keys(SUBSTITUTES[resources.name] || {}).includes(spl[i])) { + spl[i] = SUBSTITUTES[resources.name][spl[i]]; + } + if (resources.index.includes(spl[i])) { + search = [spl.splice(i, 1)]; + } + } + + icon = spl[0]; + + for (let i = 0; i < search.length; i++) { + if (resources.icons[search[i]] && resources.icons[search[i]][icon]) { + resources.icons[search[i]][icon].height = resources.height; + return resources.icons[search[i]][icon]; + } + } + + return null; + }, + + /** + * Create the correct path from the type and width + * @param {string} type + * @param {number} width + * @return {string|null} + */ + getLinkPath: (type, width) => { + const arrowHead = 'v46.059c0 21.382 25.851 32.09 40.971 16.971 l86.059 -86.059c9.373-9.373 9.373-24.569 0-33.941l-86.059-86.059c-15.119-15.119-40.971-4.411-40.971 16.971v46.059'; //134.059 + const arrowHeadR = 'v-46.059c0-21.382-25.851-32.09-40.971-16.971l-86.059 86.059c-9.373 9.373-9.373 24.568 0 33.941l86.059 86.059c15.119 15.119 40.971 4.411 40.971-16.971v-46.059'; //134.059 + const lineEnd = 'c6.627 0 12 -5.373 12 -12v-56c0 -6.627 -5.373 -12 -12 -12'; // 12 + const lineStart = 'c-6.627 0-12 5.373-12 12v56c0 6.627 5.373 12 12 12'; // 12 + const dashedStep = `${lineStart}h56${lineEnd}`; // 80 + switch (type) { + case 'none': + return null; + default: + return `M12 216${lineStart}h${width * 512 - 146.059}${arrowHead}z`; + case 'line': + return `M12 216${lineStart}h${width * 512 - 24}${lineEnd}z`; + case 'double': + return `M134.059 216${arrowHeadR}h${width * 512 - 268.06}${arrowHead}z`; + case 'split-double': + return `M12 126${lineStart}h${width * 512 - 146.059}${arrowHead}M134.059 306${arrowHeadR}h${width * 512 - 146.059}${lineEnd}z`; + case 'dashed': + const n1 = Math.floor((width * 512 - 134.059) / (80 * 2.1)); + const space1 = ((width * 512 - 134.059) - n1 * 56 - 24) / (n1); + return `M12 216${new Array(n1).fill(`${dashedStep}m${space1} 0`).join('')}v80${arrowHead}z`; + case 'dashed-line': + const n2 = Math.floor(width * 512 / (80 * 2.1)); + const space2 = (width * 512 - n2 * 56 - 24) / (n2 - 1); + return `M12 216${new Array(n2).fill(dashedStep).join(`m${space2} 0`)}z`; + case 'dashed-double': + const n3 = Math.floor((width * 512 - 134.059 * 2) / (80 * 2.1)); + const space3 = ((width * 512 - 134.059 * 2) - n3 * 56 - 24) / (n3 + 1); + return `M134.059 216${arrowHeadR}m${space3}-80${new Array(n3).fill(`${dashedStep}m${space3} 0`).join('')}v80${arrowHead}z`; + case 'dashed-split-double': + const n4 = Math.floor((width * 512 - 134.059) / (80 * 2.1)); + const space4 = ((width * 512 - 134.059) - n4 * 56 - 24) / (n4); + return `M12 126${new Array(n4).fill(`${dashedStep}m${space4} 0`).join('')}v80${arrowHead}M134.059 306${arrowHeadR}m${space4} -80${new Array(n4).fill(`${dashedStep}`).join(`m${space4} 0`)}z`; + } + }, + + /** + * Get the width and height of the graph of nodes + * @param {Object} nodes + * @returns {{w: number, h: number}} + */ + getBounds: (nodes) => { + const list = Object.values(nodes); + if (list.length === 0) + return {w: 0, h: 0}; //empty + let maxX = 0; + let maxY = 0; + list.forEach(n => { + maxX = Math.max(n.x, maxX); + maxY = Math.max(n.y, maxY); + }); + return {w: maxX + 1, h: maxY + 1}; + }, + + /** + * @param {string} text + * @param {number} lineHeight + * @param {number} x + * @param {string} anchor + * @return {Object} + */ + getSvgText: (text, lineHeight, x, anchor) => { + text = text.trim(); + if (!text.includes('\n')) + return {'_text': text}; + const list = []; + text.split('\n').map(t => t.trim()).forEach((line, i) => { + list.push({ + '_attributes': { + 'x': x, + 'dy': i === 0 ? '0' : `${lineHeight}em`, + 'text-anchor': anchor + }, + '_text': line + }); + }); + return {'tspan': list}; + }, + + /** + * @param {Node2} node + */ + renderNode: (node) => { + const icon = self.getIcon(node.icon); + if (!icon) + return null; + const scale = (node['scale'] || options['icons']['scale']) * DEFAULT_SCALE; + const g = { + '_attributes': { + 'transform': `translate(${(node.x + 0.5) * options['h-spacing']} ${node.y + 0.5})`, + }, + 'g': [{ + '_attributes': { + 'transform': `scale(${scale / icon.height} ${scale / icon.height}) translate(${-icon.width / 2} ${-icon.height / 2})`, + 'stroke': (node['color'] || options['icons']['color'] || undefined), + 'fill': (node['color'] || options['icons']['color'] || undefined) + }, + 'path': { + '_attributes': { + 'd': icon.path, + } + } + }] + }; + + ['bottom', 'top', 'left', 'right'].forEach(side => { + const subE = node[side]; + if (subE && subE.text) { + const fontSize = subE['font-size'] || options['texts']['font-size']; + const margin = subE['margin'] || options['texts']['margin']; + let pos; + let anchor; + switch (side) { + case 'bottom': + pos = {x: 0, y: 1}; + anchor = 'middle'; + break; + case 'top': + pos = {x: 0, y: -1}; + anchor = 'middle'; + break; + case 'left': + pos = {x: -1, y: 0}; + anchor = 'end'; + break; + case 'right': + pos = {x: 1, y: 0}; + anchor = 'start'; + break; + } + + const lineHeight = subE['line-height'] || options['texts']['line-height']; + const text = self.getSvgText(subE.text, lineHeight, pos.x * fontSize / 2, anchor); + const textHeight = text['tspan'] ? text['tspan'].length - 1 : 0; + + text['_attributes'] = { + 'font-family': subE['font'] || options['texts']['font'], + 'font-size': fontSize, + 'text-anchor': anchor, + 'x': pos.x * fontSize / 2, + 'y': (pos.y + 0.25) * fontSize - (1 - pos.y) * textHeight * fontSize * lineHeight / 2 + }; + + g['g'].push({ + '_attributes': { + 'transform': `translate(${pos.x * margin} ${pos.y * margin}) scale(${1 / options['scale']} ${1 / options['scale']})`, + 'stroke': (subE['color'] || node['color'] || options['texts']['color'] || options['icons']['color'] || undefined), + 'fill': (subE['color'] || node['color'] || options['texts']['color'] || options['icons']['color'] || undefined) + }, + 'text': text + }); + } + }); + + return g; + }, + + /** + * @param {Object} nodes + * @param {Link2} link + */ + renderLink: (nodes, link) => { + const src = nodes[link.from]; + const dst = nodes[link.to]; + + const posX = ((src.x + dst.x) / 2 + 0.5) * options['h-spacing']; + const posY = (src.y + dst.y) / 2 + 0.5; + + const angle = Math.atan2(dst.y - src.y, (dst.x - src.x) * options['h-spacing']) * 180 / Math.PI; + const scale = (link['scale'] || options['links']['scale']) * DEFAULT_SCALE; + + let size = link['size'] || options['links']['size']; + + if (!size) { + let dx = Math.abs(dst.x - src.x) * options['h-spacing']; + if (dx > 0) + dx -= LINK_MARGIN * 2; + let dy = Math.abs(dst.y - src.y); + if (dy > 0) + dy -= LINK_MARGIN * 2; + + size = Math.sqrt(Math.pow(dx, 2) + Math.pow(dy, 2)) / scale; + } + + const path = self.getLinkPath(link.type, size); + + if (!path) + return null; + + return { + '_attributes': { + 'transform': `translate(${posX} ${posY}) rotate(${angle})` + }, + 'g': { + '_attributes': { + 'transform': `scale(${scale / 512} ${scale / 512}) translate(${(-256 * size)} ${-256})`, + 'stroke': (link['color'] || options['links']['color'] || undefined), + 'fill': (link['color'] || options['links']['color'] || undefined) + }, + 'path': { + '_attributes': { + 'd': path + } + } + } + }; + }, + + /** + * Convert xml-js data into correct svg xml string + * @param {Object} data + * @param {{w:number, h:number}} bounds + * @returns {string} + */ + toXML: (data, bounds) => { + const xml = { + 'svg': { + '_attributes': { + 'xmlns': 'http://www.w3.org/2000/svg', + 'viewBox': `0 0 ${bounds.w * options['h-spacing']} ${bounds.h}`, + 'width': bounds.w * options['h-spacing'] * options['scale'] / DEFAULT_SCALE, + 'height': bounds.h * options['scale'] / DEFAULT_SCALE, + 'stroke': options['color'], + 'fill': options['color'] + } + } + }; + Object.keys(data).forEach(key => { + xml['svg'][key] = data[key]; + }); + return convert.js2xml(xml, { + compact: true, + spaces: options['beautify'] ? 4 : 0 + }).replace(/<\/tspan>(\s*)} nodes + * @param {Link2[]} links + */ + compute: (nodes, links) => { + + const data = {'g': []}; + + Object.keys(nodes).forEach(key => { + const res = utils.isValid(nodes[key], NODE_DEF); + if (res) + throw `Node '${key}' is invalid at key '${res}'`; + + ['bottom', 'top', 'left', 'right'].forEach(sub => { + if (typeof nodes[key][sub] === 'string') + nodes[key][sub] = {text: nodes[key][sub]}; + }); + + const group = self.renderNode(nodes[key]); + if (group) + data['g'].push(group); + }); + + links.forEach((link, i) => { + const res = utils.isValid(link, LINK_DEF); + if (res) + throw `Link ${i} (${link.from}->${link.to}) is invalid at key '${res}'`; + + ['bottom', 'top'].forEach(sub => { + if (typeof link[sub] === 'string') + link[sub] = {text: link[sub]}; + }); + + const group = self.renderLink(nodes, link); + if (group) + data['g'].push(group); + }); + + const bounds = self.getBounds(nodes); + + return self.toXML(data, bounds); + } + }; + + return self; }; },{"../resources.json":undefined,"./utils":41,"xml-js":32}],41:[function(require,module,exports){ -const self = { - /** - * Merge resources by reading object keys and keeping reference value only if it's type is different from the source - * @param ref - reference object/value - * @param src - source object/value - * @returns {*} - */ - merge: (ref, src) => { - if (typeof ref !== typeof src) { - return ref; - } else if (ref.length && !src.length) { - return ref; - } else if (ref.length && src.length) { - return src; - } else if (typeof ref === 'object') { - const out = {}; - Object.keys(ref).forEach((key) => out[key] = self.merge(ref[key], src[key])); - return out; - } else { - return src; - } - }, - - /** - * Verify if an object respect it's definition - * @param obj - * @param def - * @returns {null|string} - */ - isValid: (obj, def) => { - const keys = Object.keys(def).filter(k => k !== '_'); - let key; - let type; - for (let i = 0; i < keys.length; i++) { - key = keys[i]; - type = (typeof obj !== 'object' || obj[key] === undefined || obj[key] === null) ? null : typeof obj[key]; - if (type === 'object' && obj[key].length > 0) - type = 'array'; - if (typeof def[key] === 'object') { - if (type && type !== 'object' && type !== def[key]['_']) - return key; - const res = self.isValid(type ? obj[key] : undefined, def[key]); - if (res) - return key + '.' + res; - } else { - if (def[key][0] === '!') { - def[key] = def[key].substr(1); - if (!type) - return key; - } - if (type && type !== def[key]) - return key; - } - } - return null; - }, - - /** - * Clone any JS variable or object - * @param {*} arg - * @returns {any} - */ - ezClone: (arg) => JSON.parse(JSON.stringify(arg)), - - /** - * Create a new map of the defined bounds and filling - * @param {number} w - * @param {number} h - * @param {*} fill - * @returns {any[][]} - */ - newMap: (w, h, fill) => new Array(w).fill(0).map(() => new Array(h).fill(fill)) -}; - +const self = { + /** + * Merge resources by reading object keys and keeping reference value only if it's type is different from the source + * @param ref - reference object/value + * @param src - source object/value + * @returns {*} + */ + merge: (ref, src) => { + if (typeof ref !== typeof src) { + return ref; + } else if (ref.length && !src.length) { + return ref; + } else if (ref.length && src.length) { + return src; + } else if (typeof ref === 'object') { + const out = {}; + Object.keys(ref).forEach((key) => out[key] = self.merge(ref[key], src[key])); + return out; + } else { + return src; + } + }, + + /** + * Verify if an object respect it's definition + * @param obj + * @param def + * @returns {null|string} + */ + isValid: (obj, def) => { + const keys = Object.keys(def).filter(k => k !== '_'); + let key; + let type; + for (let i = 0; i < keys.length; i++) { + key = keys[i]; + type = (typeof obj !== 'object' || obj[key] === undefined || obj[key] === null) ? null : typeof obj[key]; + if (type === 'object' && obj[key].length > 0) + type = 'array'; + if (typeof def[key] === 'object') { + if (type && type !== 'object' && type !== def[key]['_']) + return key; + const res = self.isValid(type ? obj[key] : undefined, def[key]); + if (res) + return key + '.' + res; + } else { + if (def[key][0] === '!') { + def[key] = def[key].substr(1); + if (!type) + return key; + } + if (type && type !== def[key]) + return key; + } + } + return null; + }, + + /** + * Clone any JS variable or object + * @param {*} arg + * @returns {any} + */ + ezClone: (arg) => JSON.parse(JSON.stringify(arg)), + + /** + * Create a new map of the defined bounds and filling + * @param {number} w + * @param {number} h + * @param {*} fill + * @returns {any[][]} + */ + newMap: (w, h, fill) => new Array(w).fill(0).map(() => new Array(h).fill(fill)) +}; + module.exports = self; },{}]},{},[38]); diff --git a/dist/fa-diagrams.min.js b/dist/fa-diagrams.min.js index f8eb775..74b4fde 100644 --- a/dist/fa-diagrams.min.js +++ b/dist/fa-diagrams.min.js @@ -1 +1 @@ -!function(){return function t(e,r,n){function i(o,a){if(!r[o]){if(!e[o]){var u="function"==typeof require&&require;if(!a&&u)return u(o,!0);if(s)return s(o,!0);var l=new Error("Cannot find module '"+o+"'");throw l.code="MODULE_NOT_FOUND",l}var c=r[o]={exports:{}};e[o][0].call(c.exports,function(t){return i(e[o][1][t]||t)},c,c.exports,t,e,r,n)}return r[o].exports}for(var s="function"==typeof require&&require,o=0;o0?n-4:n,f=0;f>16&255,a[u++]=e>>8&255,a[u++]=255&e;2===o&&(e=i[t.charCodeAt(f)]<<2|i[t.charCodeAt(f+1)]>>4,a[u++]=255&e);1===o&&(e=i[t.charCodeAt(f)]<<10|i[t.charCodeAt(f+1)]<<4|i[t.charCodeAt(f+2)]>>2,a[u++]=e>>8&255,a[u++]=255&e);return a},r.fromByteArray=function(t){for(var e,r=t.length,i=r%3,s=[],o=0,a=r-i;oa?a:o+16383));1===i?(e=t[r-1],s.push(n[e>>2]+n[e<<4&63]+"==")):2===i&&(e=(t[r-2]<<8)+t[r-1],s.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"="));return s.join("")};for(var n=[],i=[],s="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,u=o.length;a0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function c(t,e,r){for(var i,s,o=[],a=e;a>18&63]+n[s>>12&63]+n[s>>6&63]+n[63&s]);return o.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},{}],2:[function(t,e,r){},{}],3:[function(t,e,r){(function(e){"use strict";var n=t("base64-js"),i=t("ieee754");r.Buffer=e,r.SlowBuffer=function(t){+t!=t&&(t=0);return e.alloc(+t)},r.INSPECT_MAX_BYTES=50;var s=2147483647;function o(t){if(t>s)throw new RangeError('The value "'+t+'" is invalid for option "size"');var r=new Uint8Array(t);return r.__proto__=e.prototype,r}function e(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return l(t)}return a(t,e,r)}function a(t,r,n){if("string"==typeof t)return function(t,r){"string"==typeof r&&""!==r||(r="utf8");if(!e.isEncoding(r))throw new TypeError("Unknown encoding: "+r);var n=0|h(t,r),i=o(n),s=i.write(t,r);s!==n&&(i=i.slice(0,s));return i}(t,r);if(ArrayBuffer.isView(t))return c(t);if(null==t)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(P(t,ArrayBuffer)||t&&P(t.buffer,ArrayBuffer))return function(t,r,n){if(r<0||t.byteLength=s)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s.toString(16)+" bytes");return 0|t}function h(t,r){if(e.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||P(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);var n=t.length,i=arguments.length>2&&!0===arguments[2];if(!i&&0===n)return 0;for(var s=!1;;)switch(r){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return j(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return B(t).length;default:if(s)return i?-1:j(t).length;r=(""+r).toLowerCase(),s=!0}}function p(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function d(t,r,n,i,s){if(0===t.length)return-1;if("string"==typeof n?(i=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),U(n=+n)&&(n=s?0:t.length-1),n<0&&(n=t.length+n),n>=t.length){if(s)return-1;n=t.length-1}else if(n<0){if(!s)return-1;n=0}if("string"==typeof r&&(r=e.from(r,i)),e.isBuffer(r))return 0===r.length?-1:g(t,r,n,i,s);if("number"==typeof r)return r&=255,"function"==typeof Uint8Array.prototype.indexOf?s?Uint8Array.prototype.indexOf.call(t,r,n):Uint8Array.prototype.lastIndexOf.call(t,r,n):g(t,[r],n,i,s);throw new TypeError("val must be string, number or Buffer")}function g(t,e,r,n,i){var s,o=1,a=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;o=2,a/=2,u/=2,r/=2}function l(t,e){return 1===o?t[e]:t.readUInt16BE(e*o)}if(i){var c=-1;for(s=r;sa&&(r=a-u),s=r;s>=0;s--){for(var f=!0,h=0;hi&&(n=i):n=i;var s=e.length;n>s/2&&(n=s/2);for(var o=0;o>8,i=r%256,s.push(i),s.push(n);return s}(e,t.length-r),t,r,n)}function _(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function T(t,e,r){r=Math.min(t.length,r);for(var n=[],i=e;i239?4:l>223?3:l>191?2:1;if(i+f<=r)switch(f){case 1:l<128&&(c=l);break;case 2:128==(192&(s=t[i+1]))&&(u=(31&l)<<6|63&s)>127&&(c=u);break;case 3:s=t[i+1],o=t[i+2],128==(192&s)&&128==(192&o)&&(u=(15&l)<<12|(63&s)<<6|63&o)>2047&&(u<55296||u>57343)&&(c=u);break;case 4:s=t[i+1],o=t[i+2],a=t[i+3],128==(192&s)&&128==(192&o)&&128==(192&a)&&(u=(15&l)<<18|(63&s)<<12|(63&o)<<6|63&a)>65535&&u<1114112&&(c=u)}null===c?(c=65533,f=1):c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|1023&c),n.push(c),i+=f}return function(t){var e=t.length;if(e<=x)return String.fromCharCode.apply(String,t);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return S(this,e,r);case"utf8":case"utf-8":return T(this,e,r);case"ascii":return A(this,e,r);case"latin1":case"binary":return N(this,e,r);case"base64":return _(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},e.prototype.toLocaleString=e.prototype.toString,e.prototype.equals=function(t){if(!e.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===e.compare(this,t)},e.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),""},e.prototype.compare=function(t,r,n,i,s){if(P(t,Uint8Array)&&(t=e.from(t,t.offset,t.byteLength)),!e.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===r&&(r=0),void 0===n&&(n=t?t.length:0),void 0===i&&(i=0),void 0===s&&(s=this.length),r<0||n>t.length||i<0||s>this.length)throw new RangeError("out of range index");if(i>=s&&r>=n)return 0;if(i>=s)return-1;if(r>=n)return 1;if(r>>>=0,n>>>=0,i>>>=0,s>>>=0,this===t)return 0;for(var o=s-i,a=n-r,u=Math.min(o,a),l=this.slice(i,s),c=t.slice(r,n),f=0;f>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-e;if((void 0===r||r>i)&&(r=i),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var s=!1;;)switch(n){case"hex":return m(this,t,e,r);case"utf8":case"utf-8":return y(this,t,e,r);case"ascii":return b(this,t,e,r);case"latin1":case"binary":return w(this,t,e,r);case"base64":return v(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return E(this,t,e,r);default:if(s)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),s=!0}},e.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var x=4096;function A(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;in)&&(r=n);for(var i="",s=e;sr)throw new RangeError("Trying to access beyond buffer length")}function F(t,r,n,i,s,o){if(!e.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(r>s||rt.length)throw new RangeError("Index out of range")}function I(t,e,r,n,i,s){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function O(t,e,r,n,s){return e=+e,r>>>=0,s||I(t,0,r,4),i.write(t,e,r,n,23,4),r+4}function L(t,e,r,n,s){return e=+e,r>>>=0,s||I(t,0,r,8),i.write(t,e,r,n,52,8),r+8}e.prototype.slice=function(t,r){var n=this.length;t=~~t,r=void 0===r?n:~~r,t<0?(t+=n)<0&&(t=0):t>n&&(t=n),r<0?(r+=n)<0&&(r=0):r>n&&(r=n),r>>=0,e>>>=0,r||k(t,e,this.length);for(var n=this[t],i=1,s=0;++s>>=0,e>>>=0,r||k(t,e,this.length);for(var n=this[t+--e],i=1;e>0&&(i*=256);)n+=this[t+--e]*i;return n},e.prototype.readUInt8=function(t,e){return t>>>=0,e||k(t,1,this.length),this[t]},e.prototype.readUInt16LE=function(t,e){return t>>>=0,e||k(t,2,this.length),this[t]|this[t+1]<<8},e.prototype.readUInt16BE=function(t,e){return t>>>=0,e||k(t,2,this.length),this[t]<<8|this[t+1]},e.prototype.readUInt32LE=function(t,e){return t>>>=0,e||k(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},e.prototype.readUInt32BE=function(t,e){return t>>>=0,e||k(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},e.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||k(t,e,this.length);for(var n=this[t],i=1,s=0;++s=(i*=128)&&(n-=Math.pow(2,8*e)),n},e.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||k(t,e,this.length);for(var n=e,i=1,s=this[t+--n];n>0&&(i*=256);)s+=this[t+--n]*i;return s>=(i*=128)&&(s-=Math.pow(2,8*e)),s},e.prototype.readInt8=function(t,e){return t>>>=0,e||k(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},e.prototype.readInt16LE=function(t,e){t>>>=0,e||k(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},e.prototype.readInt16BE=function(t,e){t>>>=0,e||k(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},e.prototype.readInt32LE=function(t,e){return t>>>=0,e||k(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},e.prototype.readInt32BE=function(t,e){return t>>>=0,e||k(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},e.prototype.readFloatLE=function(t,e){return t>>>=0,e||k(t,4,this.length),i.read(this,t,!0,23,4)},e.prototype.readFloatBE=function(t,e){return t>>>=0,e||k(t,4,this.length),i.read(this,t,!1,23,4)},e.prototype.readDoubleLE=function(t,e){return t>>>=0,e||k(t,8,this.length),i.read(this,t,!0,52,8)},e.prototype.readDoubleBE=function(t,e){return t>>>=0,e||k(t,8,this.length),i.read(this,t,!1,52,8)},e.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e>>>=0,r>>>=0,n)||F(this,t,e,r,Math.pow(2,8*r)-1,0);var i=1,s=0;for(this[e]=255&t;++s>>=0,r>>>=0,n)||F(this,t,e,r,Math.pow(2,8*r)-1,0);var i=r-1,s=1;for(this[e+i]=255&t;--i>=0&&(s*=256);)this[e+i]=t/s&255;return e+r},e.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||F(this,t,e,1,255,0),this[e]=255&t,e+1},e.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||F(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},e.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||F(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},e.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||F(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},e.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||F(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},e.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);F(this,t,e,r,i-1,-i)}var s=0,o=1,a=0;for(this[e]=255&t;++s>0)-a&255;return e+r},e.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);F(this,t,e,r,i-1,-i)}var s=r-1,o=1,a=0;for(this[e+s]=255&t;--s>=0&&(o*=256);)t<0&&0===a&&0!==this[e+s+1]&&(a=1),this[e+s]=(t/o>>0)-a&255;return e+r},e.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||F(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},e.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||F(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},e.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||F(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},e.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||F(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},e.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||F(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},e.prototype.writeFloatLE=function(t,e,r){return O(this,t,e,!0,r)},e.prototype.writeFloatBE=function(t,e,r){return O(this,t,e,!1,r)},e.prototype.writeDoubleLE=function(t,e,r){return L(this,t,e,!0,r)},e.prototype.writeDoubleBE=function(t,e,r){return L(this,t,e,!1,r)},e.prototype.copy=function(t,r,n,i){if(!e.isBuffer(t))throw new TypeError("argument should be a Buffer");if(n||(n=0),i||0===i||(i=this.length),r>=t.length&&(r=t.length),r||(r=0),i>0&&i=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),t.length-r=0;--o)t[o+r]=this[o+n];else Uint8Array.prototype.set.call(t,this.subarray(n,i),r);return s},e.prototype.fill=function(t,r,n,i){if("string"==typeof t){if("string"==typeof r?(i=r,r=0,n=this.length):"string"==typeof n&&(i=n,n=this.length),void 0!==i&&"string"!=typeof i)throw new TypeError("encoding must be a string");if("string"==typeof i&&!e.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(1===t.length){var s=t.charCodeAt(0);("utf8"===i&&s<128||"latin1"===i)&&(t=s)}}else"number"==typeof t&&(t&=255);if(r<0||this.length>>=0,n=void 0===n?this.length:n>>>0,t||(t=0),"number"==typeof t)for(o=r;o55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&s.push(239,191,189);continue}if(o+1===n){(e-=3)>-1&&s.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&s.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(e-=3)>-1&&s.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;s.push(r)}else if(r<2048){if((e-=2)<0)break;s.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;s.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;s.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return s}function B(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(M,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function R(t,e,r,n){for(var i=0;i=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function P(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function U(t){return t!=t}}).call(this,t("buffer").Buffer)},{"base64-js":1,buffer:3,ieee754:6}],4:[function(t,e,r){(function(t){function e(t){return Object.prototype.toString.call(t)}r.isArray=function(t){return Array.isArray?Array.isArray(t):"[object Array]"===e(t)},r.isBoolean=function(t){return"boolean"==typeof t},r.isNull=function(t){return null===t},r.isNullOrUndefined=function(t){return null==t},r.isNumber=function(t){return"number"==typeof t},r.isString=function(t){return"string"==typeof t},r.isSymbol=function(t){return"symbol"==typeof t},r.isUndefined=function(t){return void 0===t},r.isRegExp=function(t){return"[object RegExp]"===e(t)},r.isObject=function(t){return"object"==typeof t&&null!==t},r.isDate=function(t){return"[object Date]"===e(t)},r.isError=function(t){return"[object Error]"===e(t)||t instanceof Error},r.isFunction=function(t){return"function"==typeof t},r.isPrimitive=function(t){return null===t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||"symbol"==typeof t||void 0===t},r.isBuffer=t.isBuffer}).call(this,{isBuffer:t("../../is-buffer/index.js")})},{"../../is-buffer/index.js":8}],5:[function(t,e,r){var n=Object.create||function(t){var e=function(){};return e.prototype=t,new e},i=Object.keys||function(t){var e=[];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.push(r);return r},s=Function.prototype.bind||function(t){var e=this;return function(){return e.apply(t,arguments)}};function o(){this._events&&Object.prototype.hasOwnProperty.call(this,"_events")||(this._events=n(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0}e.exports=o,o.EventEmitter=o,o.prototype._events=void 0,o.prototype._maxListeners=void 0;var a,u=10;try{var l={};Object.defineProperty&&Object.defineProperty(l,"x",{value:0}),a=0===l.x}catch(t){a=!1}function c(t){return void 0===t._maxListeners?o.defaultMaxListeners:t._maxListeners}function f(t,e,r,i){var s,o,a;if("function"!=typeof r)throw new TypeError('"listener" argument must be a function');if((o=t._events)?(o.newListener&&(t.emit("newListener",e,r.listener?r.listener:r),o=t._events),a=o[e]):(o=t._events=n(null),t._eventsCount=0),a){if("function"==typeof a?a=o[e]=i?[r,a]:[a,r]:i?a.unshift(r):a.push(r),!a.warned&&(s=c(t))&&s>0&&a.length>s){a.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+a.length+' "'+String(e)+'" listeners added. Use emitter.setMaxListeners() to increase limit.');u.name="MaxListenersExceededWarning",u.emitter=t,u.type=e,u.count=a.length,"object"==typeof console&&console.warn&&console.warn("%s: %s",u.name,u.message)}}else a=o[e]=r,++t._eventsCount;return t}function h(){if(!this.fired)switch(this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length){case 0:return this.listener.call(this.target);case 1:return this.listener.call(this.target,arguments[0]);case 2:return this.listener.call(this.target,arguments[0],arguments[1]);case 3:return this.listener.call(this.target,arguments[0],arguments[1],arguments[2]);default:for(var t=new Array(arguments.length),e=0;e1&&(e=arguments[1]),e instanceof Error)throw e;var u=new Error('Unhandled "error" event. ('+e+")");throw u.context=e,u}if(!(r=o[t]))return!1;var l="function"==typeof r;switch(n=arguments.length){case 1:!function(t,e,r){if(e)t.call(r);else for(var n=t.length,i=m(t,n),s=0;s=0;o--)if(r[o]===e||r[o].listener===e){a=r[o].listener,s=o;break}if(s<0)return this;0===s?r.shift():function(t,e){for(var r=e,n=r+1,i=t.length;n=0;s--)this.removeListener(t,e[s]);return this},o.prototype.listeners=function(t){return d(this,t,!0)},o.prototype.rawListeners=function(t){return d(this,t,!1)},o.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):g.call(t,e)},o.prototype.listenerCount=g,o.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]}},{}],6:[function(t,e,r){r.read=function(t,e,r,n,i){var s,o,a=8*i-n-1,u=(1<>1,c=-7,f=r?i-1:0,h=r?-1:1,p=t[e+f];for(f+=h,s=p&(1<<-c)-1,p>>=-c,c+=a;c>0;s=256*s+t[e+f],f+=h,c-=8);for(o=s&(1<<-c)-1,s>>=-c,c+=n;c>0;o=256*o+t[e+f],f+=h,c-=8);if(0===s)s=1-l;else{if(s===u)return o?NaN:1/0*(p?-1:1);o+=Math.pow(2,n),s-=l}return(p?-1:1)*o*Math.pow(2,s-n)},r.write=function(t,e,r,n,i,s){var o,a,u,l=8*s-i-1,c=(1<>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:s-1,d=n?1:-1,g=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,o=c):(o=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-o))<1&&(o--,u*=2),(e+=o+f>=1?h/u:h*Math.pow(2,1-f))*u>=2&&(o++,u/=2),o+f>=c?(a=0,o=c):o+f>=1?(a=(e*u-1)*Math.pow(2,i),o+=f):(a=e*Math.pow(2,f-1)*Math.pow(2,i),o=0));i>=8;t[r+p]=255&a,p+=d,a/=256,i-=8);for(o=o<0;t[r+p]=255&o,p+=d,o/=256,l-=8);t[r+p-d]|=128*g}},{}],7:[function(t,e,r){"function"==typeof Object.create?e.exports=function(t,e){e&&(t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:e.exports=function(t,e){if(e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}}},{}],8:[function(t,e,r){function n(t){return!!t.constructor&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t)}e.exports=function(t){return null!=t&&(n(t)||function(t){return"function"==typeof t.readFloatLE&&"function"==typeof t.slice&&n(t.slice(0,0))}(t)||!!t._isBuffer)}},{}],9:[function(t,e,r){var n={}.toString;e.exports=Array.isArray||function(t){return"[object Array]"==n.call(t)}},{}],10:[function(t,e,r){(function(t){"use strict";void 0===t||!t.version||0===t.version.indexOf("v0.")||0===t.version.indexOf("v1.")&&0!==t.version.indexOf("v1.8.")?e.exports={nextTick:function(e,r,n,i){if("function"!=typeof e)throw new TypeError('"callback" argument must be a function');var s,o,a=arguments.length;switch(a){case 0:case 1:return t.nextTick(e);case 2:return t.nextTick(function(){e.call(null,r)});case 3:return t.nextTick(function(){e.call(null,r,n)});case 4:return t.nextTick(function(){e.call(null,r,n,i)});default:for(s=new Array(a-1),o=0;o1)for(var r=1;r0?("string"==typeof e||o.objectMode||Object.getPrototypeOf(e)===l.prototype||(e=function(t){return l.from(t)}(e)),n?o.endEmitted?t.emit("error",new Error("stream.unshift() after end event")):E(t,o,e,!0):o.ended?t.emit("error",new Error("stream.push() after EOF")):(o.reading=!1,o.decoder&&!r?(e=o.decoder.write(e),o.objectMode||0!==e.length?E(t,o,e,!1):N(t,o)):E(t,o,e,!1))):n||(o.reading=!1));return function(t){return!t.ended&&(t.needReadable||t.lengthe.highWaterMark&&(e.highWaterMark=function(t){return t>=_?t=_:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}function x(t){var e=t._readableState;e.needReadable=!1,e.emittedReadable||(p("emitReadable",e.flowing),e.emittedReadable=!0,e.sync?i.nextTick(A,t):A(t))}function A(t){p("emit readable"),t.emit("readable"),F(t)}function N(t,e){e.readingMore||(e.readingMore=!0,i.nextTick(S,t,e))}function S(t,e){for(var r=e.length;!e.reading&&!e.flowing&&!e.ended&&e.length=e.length?(r=e.decoder?e.buffer.join(""):1===e.buffer.length?e.buffer.head.data:e.buffer.concat(e.length),e.buffer.clear()):r=function(t,e,r){var n;ts.length?s.length:t;if(o===s.length?i+=s:i+=s.slice(0,t),0===(t-=o)){o===s.length?(++n,r.next?e.head=r.next:e.head=e.tail=null):(e.head=r,r.data=s.slice(o));break}++n}return e.length-=n,i}(t,e):function(t,e){var r=l.allocUnsafe(t),n=e.head,i=1;n.data.copy(r),t-=n.data.length;for(;n=n.next;){var s=n.data,o=t>s.length?s.length:t;if(s.copy(r,r.length-t,0,o),0===(t-=o)){o===s.length?(++i,n.next?e.head=n.next:e.head=e.tail=null):(e.head=n,n.data=s.slice(o));break}++i}return e.length-=i,r}(t,e);return n}(t,e.buffer,e.decoder),r);var r}function O(t){var e=t._readableState;if(e.length>0)throw new Error('"endReadable()" called on non-empty stream');e.endEmitted||(e.ended=!0,i.nextTick(L,e,t))}function L(t,e){t.endEmitted||0!==t.length||(t.endEmitted=!0,e.readable=!1,e.emit("end"))}function M(t,e){for(var r=0,n=t.length;r=e.highWaterMark||e.ended))return p("read: emitReadable",e.length,e.ended),0===e.length&&e.ended?O(this):x(this),null;if(0===(t=T(t,e))&&e.ended)return 0===e.length&&O(this),null;var n,i=e.needReadable;return p("need readable",i),(0===e.length||e.length-t0?I(t,e):null)?(e.needReadable=!0,t=0):e.length-=t,0===e.length&&(e.ended||(e.needReadable=!0),r!==t&&e.ended&&O(this)),null!==n&&this.emit("data",n),n},w.prototype._read=function(t){this.emit("error",new Error("_read() is not implemented"))},w.prototype.pipe=function(t,e){var n=this,s=this._readableState;switch(s.pipesCount){case 0:s.pipes=t;break;case 1:s.pipes=[s.pipes,t];break;default:s.pipes.push(t)}s.pipesCount+=1,p("pipe count=%d opts=%j",s.pipesCount,e);var u=(!e||!1!==e.end)&&t!==r.stdout&&t!==r.stderr?c:w;function l(e,r){p("onunpipe"),e===n&&r&&!1===r.hasUnpiped&&(r.hasUnpiped=!0,p("cleanup"),t.removeListener("close",y),t.removeListener("finish",b),t.removeListener("drain",f),t.removeListener("error",m),t.removeListener("unpipe",l),n.removeListener("end",c),n.removeListener("end",w),n.removeListener("data",g),h=!0,!s.awaitDrain||t._writableState&&!t._writableState.needDrain||f())}function c(){p("onend"),t.end()}s.endEmitted?i.nextTick(u):n.once("end",u),t.on("unpipe",l);var f=function(t){return function(){var e=t._readableState;p("pipeOnDrain",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&a(t,"data")&&(e.flowing=!0,F(t))}}(n);t.on("drain",f);var h=!1;var d=!1;function g(e){p("ondata"),d=!1,!1!==t.write(e)||d||((1===s.pipesCount&&s.pipes===t||s.pipesCount>1&&-1!==M(s.pipes,t))&&!h&&(p("false write response, pause",n._readableState.awaitDrain),n._readableState.awaitDrain++,d=!0),n.pause())}function m(e){p("onerror",e),w(),t.removeListener("error",m),0===a(t,"error")&&t.emit("error",e)}function y(){t.removeListener("finish",b),w()}function b(){p("onfinish"),t.removeListener("close",y),w()}function w(){p("unpipe"),n.unpipe(t)}return n.on("data",g),function(t,e,r){if("function"==typeof t.prependListener)return t.prependListener(e,r);t._events&&t._events[e]?o(t._events[e])?t._events[e].unshift(r):t._events[e]=[r,t._events[e]]:t.on(e,r)}(t,"error",m),t.once("close",y),t.once("finish",b),t.emit("pipe",n),s.flowing||(p("pipe resume"),n.resume()),t},w.prototype.unpipe=function(t){var e=this._readableState,r={hasUnpiped:!1};if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes?this:(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit("unpipe",this,r),this);if(!t){var n=e.pipes,i=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var s=0;s-1?i:s.nextTick;b.WritableState=y;var l=t("core-util-is");l.inherits=t("inherits");var c={deprecate:t("util-deprecate")},f=t("./internal/streams/stream"),h=t("safe-buffer").Buffer,p=n.Uint8Array||function(){};var d,g=t("./internal/streams/destroy");function m(){}function y(e,r){a=a||t("./_stream_duplex"),e=e||{};var n=r instanceof a;this.objectMode=!!e.objectMode,n&&(this.objectMode=this.objectMode||!!e.writableObjectMode);var i=e.highWaterMark,l=e.writableHighWaterMark,c=this.objectMode?16:16384;this.highWaterMark=i||0===i?i:n&&(l||0===l)?l:c,this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var f=!1===e.decodeStrings;this.decodeStrings=!f,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(t){!function(t,e){var r=t._writableState,n=r.sync,i=r.writecb;if(function(t){t.writing=!1,t.writecb=null,t.length-=t.writelen,t.writelen=0}(r),e)!function(t,e,r,n,i){--e.pendingcb,r?(s.nextTick(i,n),s.nextTick(x,t,e),t._writableState.errorEmitted=!0,t.emit("error",n)):(i(n),t._writableState.errorEmitted=!0,t.emit("error",n),x(t,e))}(t,r,n,e,i);else{var o=_(r);o||r.corked||r.bufferProcessing||!r.bufferedRequest||E(t,r),n?u(v,t,r,o,i):v(t,r,o,i)}}(r,t)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new o(this)}function b(e){if(a=a||t("./_stream_duplex"),!(d.call(b,this)||this instanceof a))return new b(e);this._writableState=new y(e,this),this.writable=!0,e&&("function"==typeof e.write&&(this._write=e.write),"function"==typeof e.writev&&(this._writev=e.writev),"function"==typeof e.destroy&&(this._destroy=e.destroy),"function"==typeof e.final&&(this._final=e.final)),f.call(this)}function w(t,e,r,n,i,s,o){e.writelen=n,e.writecb=o,e.writing=!0,e.sync=!0,r?t._writev(i,e.onwrite):t._write(i,s,e.onwrite),e.sync=!1}function v(t,e,r,n){r||function(t,e){0===e.length&&e.needDrain&&(e.needDrain=!1,t.emit("drain"))}(t,e),e.pendingcb--,n(),x(t,e)}function E(t,e){e.bufferProcessing=!0;var r=e.bufferedRequest;if(t._writev&&r&&r.next){var n=e.bufferedRequestCount,i=new Array(n),s=e.corkedRequestsFree;s.entry=r;for(var a=0,u=!0;r;)i[a]=r,r.isBuf||(u=!1),r=r.next,a+=1;i.allBuffers=u,w(t,e,!0,e.length,i,"",s.finish),e.pendingcb++,e.lastBufferedRequest=null,s.next?(e.corkedRequestsFree=s.next,s.next=null):e.corkedRequestsFree=new o(e),e.bufferedRequestCount=0}else{for(;r;){var l=r.chunk,c=r.encoding,f=r.callback;if(w(t,e,!1,e.objectMode?1:l.length,l,c,f),r=r.next,e.bufferedRequestCount--,e.writing)break}null===r&&(e.lastBufferedRequest=null)}e.bufferedRequest=r,e.bufferProcessing=!1}function _(t){return t.ending&&0===t.length&&null===t.bufferedRequest&&!t.finished&&!t.writing}function T(t,e){t._final(function(r){e.pendingcb--,r&&t.emit("error",r),e.prefinished=!0,t.emit("prefinish"),x(t,e)})}function x(t,e){var r=_(e);return r&&(!function(t,e){e.prefinished||e.finalCalled||("function"==typeof t._final?(e.pendingcb++,e.finalCalled=!0,s.nextTick(T,t,e)):(e.prefinished=!0,t.emit("prefinish")))}(t,e),0===e.pendingcb&&(e.finished=!0,t.emit("finish"))),r}l.inherits(b,f),y.prototype.getBuffer=function(){for(var t=this.bufferedRequest,e=[];t;)e.push(t),t=t.next;return e},function(){try{Object.defineProperty(y.prototype,"buffer",{get:c.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(t){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(d=Function.prototype[Symbol.hasInstance],Object.defineProperty(b,Symbol.hasInstance,{value:function(t){return!!d.call(this,t)||this===b&&(t&&t._writableState instanceof y)}})):d=function(t){return t instanceof this},b.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},b.prototype.write=function(t,e,r){var n,i=this._writableState,o=!1,a=!i.objectMode&&(n=t,h.isBuffer(n)||n instanceof p);return a&&!h.isBuffer(t)&&(t=function(t){return h.from(t)}(t)),"function"==typeof e&&(r=e,e=null),a?e="buffer":e||(e=i.defaultEncoding),"function"!=typeof r&&(r=m),i.ended?function(t,e){var r=new Error("write after end");t.emit("error",r),s.nextTick(e,r)}(this,r):(a||function(t,e,r,n){var i=!0,o=!1;return null===r?o=new TypeError("May not write null values to stream"):"string"==typeof r||void 0===r||e.objectMode||(o=new TypeError("Invalid non-string/buffer chunk")),o&&(t.emit("error",o),s.nextTick(n,o),i=!1),i}(this,i,t,r))&&(i.pendingcb++,o=function(t,e,r,n,i,s){if(!r){var o=function(t,e,r){t.objectMode||!1===t.decodeStrings||"string"!=typeof e||(e=h.from(e,r));return e}(e,n,i);n!==o&&(r=!0,i="buffer",n=o)}var a=e.objectMode?1:n.length;e.length+=a;var u=e.length-1))throw new TypeError("Unknown encoding: "+t);return this._writableState.defaultEncoding=t,this},Object.defineProperty(b.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),b.prototype._write=function(t,e,r){r(new Error("_write() is not implemented"))},b.prototype._writev=null,b.prototype.end=function(t,e,r){var n=this._writableState;"function"==typeof t?(r=t,t=null,e=null):"function"==typeof e&&(r=e,e=null),null!==t&&void 0!==t&&this.write(t,e),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(t,e,r){e.ending=!0,x(t,e),r&&(e.finished?s.nextTick(r):t.once("finish",r));e.ended=!0,t.writable=!1}(this,n,r)},Object.defineProperty(b.prototype,"destroyed",{get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}}),b.prototype.destroy=g.destroy,b.prototype._undestroy=g.undestroy,b.prototype._destroy=function(t,e){this.end(),e(t)}}).call(this,t("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},t("timers").setImmediate)},{"./_stream_duplex":13,"./internal/streams/destroy":19,"./internal/streams/stream":20,_process:11,"core-util-is":4,inherits:7,"process-nextick-args":10,"safe-buffer":25,timers:29,"util-deprecate":30}],18:[function(t,e,r){"use strict";var n=t("safe-buffer").Buffer,i=t("util");e.exports=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.head=null,this.tail=null,this.length=0}return t.prototype.push=function(t){var e={data:t,next:null};this.length>0?this.tail.next=e:this.head=e,this.tail=e,++this.length},t.prototype.unshift=function(t){var e={data:t,next:this.head};0===this.length&&(this.tail=e),this.head=e,++this.length},t.prototype.shift=function(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}},t.prototype.clear=function(){this.head=this.tail=null,this.length=0},t.prototype.join=function(t){if(0===this.length)return"";for(var e=this.head,r=""+e.data;e=e.next;)r+=t+e.data;return r},t.prototype.concat=function(t){if(0===this.length)return n.alloc(0);if(1===this.length)return this.head.data;for(var e,r,i,s=n.allocUnsafe(t>>>0),o=this.head,a=0;o;)e=o.data,r=s,i=a,e.copy(r,i),a+=o.data.length,o=o.next;return s},t}(),i&&i.inspect&&i.inspect.custom&&(e.exports.prototype[i.inspect.custom]=function(){var t=i.inspect({length:this.length});return this.constructor.name+" "+t})},{"safe-buffer":25,util:2}],19:[function(t,e,r){"use strict";var n=t("process-nextick-args");function i(t,e){t.emit("error",e)}e.exports={destroy:function(t,e){var r=this,s=this._readableState&&this._readableState.destroyed,o=this._writableState&&this._writableState.destroyed;return s||o?(e?e(t):!t||this._writableState&&this._writableState.errorEmitted||n.nextTick(i,this,t),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(t||null,function(t){!e&&t?(n.nextTick(i,r,t),r._writableState&&(r._writableState.errorEmitted=!0)):e&&e(t)}),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}}},{"process-nextick-args":10}],20:[function(t,e,r){e.exports=t("events").EventEmitter},{events:5}],21:[function(t,e,r){e.exports=t("./readable").PassThrough},{"./readable":22}],22:[function(t,e,r){(r=e.exports=t("./lib/_stream_readable.js")).Stream=r,r.Readable=r,r.Writable=t("./lib/_stream_writable.js"),r.Duplex=t("./lib/_stream_duplex.js"),r.Transform=t("./lib/_stream_transform.js"),r.PassThrough=t("./lib/_stream_passthrough.js")},{"./lib/_stream_duplex.js":13,"./lib/_stream_passthrough.js":14,"./lib/_stream_readable.js":15,"./lib/_stream_transform.js":16,"./lib/_stream_writable.js":17}],23:[function(t,e,r){e.exports=t("./readable").Transform},{"./readable":22}],24:[function(t,e,r){e.exports=t("./lib/_stream_writable.js")},{"./lib/_stream_writable.js":17}],25:[function(t,e,r){var n=t("buffer"),i=n.Buffer;function s(t,e){for(var r in t)e[r]=t[r]}function o(t,e,r){return i(t,e,r)}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?e.exports=n:(s(n,r),r.Buffer=o),s(i,o),o.from=function(t,e,r){if("number"==typeof t)throw new TypeError("Argument must not be a number");return i(t,e,r)},o.alloc=function(t,e,r){if("number"!=typeof t)throw new TypeError("Argument must be a number");var n=i(t);return void 0!==e?"string"==typeof r?n.fill(e,r):n.fill(e):n.fill(0),n},o.allocUnsafe=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return i(t)},o.allocUnsafeSlow=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return n.SlowBuffer(t)}},{buffer:3}],26:[function(t,e,r){(function(e){!function(r){r.parser=function(t,e){return new s(t,e)},r.SAXParser=s,r.SAXStream=a,r.createStream=function(t,e){return new a(t,e)},r.MAX_BUFFER_LENGTH=65536;var n,i=["comment","sgmlDecl","textNode","tagName","doctype","procInstName","procInstBody","entity","attribName","attribValue","cdata","script"];function s(t,e){if(!(this instanceof s))return new s(t,e);!function(t){for(var e=0,r=i.length;e"===n?(C(this,"onsgmldeclaration",this.sgmlDecl),this.sgmlDecl="",this.state=A.TEXT):b(n)?(this.state=A.SGML_DECL_QUOTED,this.sgmlDecl+=n):this.sgmlDecl+=n;continue;case A.SGML_DECL_QUOTED:n===this.q&&(this.state=A.SGML_DECL,this.q=""),this.sgmlDecl+=n;continue;case A.DOCTYPE:">"===n?(this.state=A.TEXT,C(this,"ondoctype",this.doctype),this.doctype=!0):(this.doctype+=n,"["===n?this.state=A.DOCTYPE_DTD:b(n)&&(this.state=A.DOCTYPE_QUOTED,this.q=n));continue;case A.DOCTYPE_QUOTED:this.doctype+=n,n===this.q&&(this.q="",this.state=A.DOCTYPE);continue;case A.DOCTYPE_DTD:this.doctype+=n,"]"===n?this.state=A.DOCTYPE:b(n)&&(this.state=A.DOCTYPE_DTD_QUOTED,this.q=n);continue;case A.DOCTYPE_DTD_QUOTED:this.doctype+=n,n===this.q&&(this.state=A.DOCTYPE_DTD,this.q="");continue;case A.COMMENT:"-"===n?this.state=A.COMMENT_ENDING:this.comment+=n;continue;case A.COMMENT_ENDING:"-"===n?(this.state=A.COMMENT_ENDED,this.comment=F(this.opt,this.comment),this.comment&&C(this,"oncomment",this.comment),this.comment=""):(this.comment+="-"+n,this.state=A.COMMENT);continue;case A.COMMENT_ENDED:">"!==n?(L(this,"Malformed comment"),this.comment+="--"+n,this.state=A.COMMENT):this.state=A.TEXT;continue;case A.CDATA:"]"===n?this.state=A.CDATA_ENDING:this.cdata+=n;continue;case A.CDATA_ENDING:"]"===n?this.state=A.CDATA_ENDING_2:(this.cdata+="]"+n,this.state=A.CDATA);continue;case A.CDATA_ENDING_2:">"===n?(this.cdata&&C(this,"oncdata",this.cdata),C(this,"onclosecdata"),this.cdata="",this.state=A.TEXT):"]"===n?this.cdata+="]":(this.cdata+="]]"+n,this.state=A.CDATA);continue;case A.PROC_INST:"?"===n?this.state=A.PROC_INST_ENDING:y(n)?this.state=A.PROC_INST_BODY:this.procInstName+=n;continue;case A.PROC_INST_BODY:if(!this.procInstBody&&y(n))continue;"?"===n?this.state=A.PROC_INST_ENDING:this.procInstBody+=n;continue;case A.PROC_INST_ENDING:">"===n?(C(this,"onprocessinginstruction",{name:this.procInstName,body:this.procInstBody}),this.procInstName=this.procInstBody="",this.state=A.TEXT):(this.procInstBody+="?"+n,this.state=A.PROC_INST_BODY);continue;case A.OPEN_TAG:v(d,n)?this.tagName+=n:(M(this),">"===n?B(this):"/"===n?this.state=A.OPEN_TAG_SLASH:(y(n)||L(this,"Invalid character in tag name"),this.state=A.ATTRIB));continue;case A.OPEN_TAG_SLASH:">"===n?(B(this,!0),R(this)):(L(this,"Forward-slash in opening tag not followed by >"),this.state=A.ATTRIB);continue;case A.ATTRIB:if(y(n))continue;">"===n?B(this):"/"===n?this.state=A.OPEN_TAG_SLASH:v(p,n)?(this.attribName=n,this.attribValue="",this.state=A.ATTRIB_NAME):L(this,"Invalid attribute name");continue;case A.ATTRIB_NAME:"="===n?this.state=A.ATTRIB_VALUE:">"===n?(L(this,"Attribute without value"),this.attribValue=this.attribName,j(this),B(this)):y(n)?this.state=A.ATTRIB_NAME_SAW_WHITE:v(d,n)?this.attribName+=n:L(this,"Invalid attribute name");continue;case A.ATTRIB_NAME_SAW_WHITE:if("="===n)this.state=A.ATTRIB_VALUE;else{if(y(n))continue;L(this,"Attribute without value"),this.tag.attributes[this.attribName]="",this.attribValue="",C(this,"onattribute",{name:this.attribName,value:""}),this.attribName="",">"===n?B(this):v(p,n)?(this.attribName=n,this.state=A.ATTRIB_NAME):(L(this,"Invalid attribute name"),this.state=A.ATTRIB)}continue;case A.ATTRIB_VALUE:if(y(n))continue;b(n)?(this.q=n,this.state=A.ATTRIB_VALUE_QUOTED):(L(this,"Unquoted attribute value"),this.state=A.ATTRIB_VALUE_UNQUOTED,this.attribValue=n);continue;case A.ATTRIB_VALUE_QUOTED:if(n!==this.q){"&"===n?this.state=A.ATTRIB_VALUE_ENTITY_Q:this.attribValue+=n;continue}j(this),this.q="",this.state=A.ATTRIB_VALUE_CLOSED;continue;case A.ATTRIB_VALUE_CLOSED:y(n)?this.state=A.ATTRIB:">"===n?B(this):"/"===n?this.state=A.OPEN_TAG_SLASH:v(p,n)?(L(this,"No whitespace between attributes"),this.attribName=n,this.attribValue="",this.state=A.ATTRIB_NAME):L(this,"Invalid attribute name");continue;case A.ATTRIB_VALUE_UNQUOTED:if(!w(n)){"&"===n?this.state=A.ATTRIB_VALUE_ENTITY_U:this.attribValue+=n;continue}j(this),">"===n?B(this):this.state=A.ATTRIB;continue;case A.CLOSE_TAG:if(this.tagName)">"===n?R(this):v(d,n)?this.tagName+=n:this.script?(this.script+=""===n?R(this):L(this,"Invalid characters in closing tag");continue;case A.TEXT_ENTITY:case A.ATTRIB_VALUE_ENTITY_Q:case A.ATTRIB_VALUE_ENTITY_U:var a,c;switch(this.state){case A.TEXT_ENTITY:a=A.TEXT,c="textNode";break;case A.ATTRIB_VALUE_ENTITY_Q:a=A.ATTRIB_VALUE_QUOTED,c="attribValue";break;case A.ATTRIB_VALUE_ENTITY_U:a=A.ATTRIB_VALUE_UNQUOTED,c="attribValue"}";"===n?(this[c]+=P(this),this.entity="",this.state=a):v(this.entity.length?m:g,n)?this.entity+=n:(L(this,"Invalid character in entity name"),this[c]+="&"+this.entity+n,this.entity="",this.state=a);continue;default:throw new Error(this,"Unknown state: "+this.state)}this.position>=this.bufferCheckPosition&&function(t){for(var e=Math.max(r.MAX_BUFFER_LENGTH,10),n=0,s=0,o=i.length;se)switch(i[s]){case"textNode":k(t);break;case"cdata":C(t,"oncdata",t.cdata),t.cdata="";break;case"script":C(t,"onscript",t.script),t.script="";break;default:I(t,"Max buffer length exceeded: "+i[s])}n=Math.max(n,a)}var u=r.MAX_BUFFER_LENGTH-n;t.bufferCheckPosition=u+t.position}(this);return this},resume:function(){return this.error=null,this},close:function(){return this.write(null)},flush:function(){var t;k(t=this),""!==t.cdata&&(C(t,"oncdata",t.cdata),t.cdata=""),""!==t.script&&(C(t,"onscript",t.script),t.script="")}};try{n=t("stream").Stream}catch(t){n=function(){}}var o=r.EVENTS.filter(function(t){return"error"!==t&&"end"!==t});function a(t,e){if(!(this instanceof a))return new a(t,e);n.apply(this),this._parser=new s(t,e),this.writable=!0,this.readable=!0;var r=this;this._parser.onend=function(){r.emit("end")},this._parser.onerror=function(t){r.emit("error",t),r._parser.error=null},this._decoder=null,o.forEach(function(t){Object.defineProperty(r,"on"+t,{get:function(){return r._parser["on"+t]},set:function(e){if(!e)return r.removeAllListeners(t),r._parser["on"+t]=e,e;r.on(t,e)},enumerable:!0,configurable:!1})})}a.prototype=Object.create(n.prototype,{constructor:{value:a}}),a.prototype.write=function(r){if("function"==typeof e&&"function"==typeof e.isBuffer&&e.isBuffer(r)){if(!this._decoder){var n=t("string_decoder").StringDecoder;this._decoder=new n("utf8")}r=this._decoder.write(r)}return this._parser.write(r.toString()),this.emit("data",r),!0},a.prototype.end=function(t){return t&&t.length&&this.write(t),this._parser.end(),!0},a.prototype.on=function(t,e){var r=this;return r._parser["on"+t]||-1===o.indexOf(t)||(r._parser["on"+t]=function(){var e=1===arguments.length?[arguments[0]]:Array.apply(null,arguments);e.splice(0,0,t),r.emit.apply(r,e)}),n.prototype.on.call(r,t,e)};var u="[CDATA[",l="DOCTYPE",c="http://www.w3.org/XML/1998/namespace",f="http://www.w3.org/2000/xmlns/",h={xml:c,xmlns:f},p=/[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,d=/[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/,g=/[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,m=/[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/;function y(t){return" "===t||"\n"===t||"\r"===t||"\t"===t}function b(t){return'"'===t||"'"===t}function w(t){return">"===t||y(t)}function v(t,e){return t.test(e)}function E(t,e){return!v(t,e)}var _,T,x,A=0;for(var N in r.STATE={BEGIN:A++,BEGIN_WHITESPACE:A++,TEXT:A++,TEXT_ENTITY:A++,OPEN_WAKA:A++,SGML_DECL:A++,SGML_DECL_QUOTED:A++,DOCTYPE:A++,DOCTYPE_QUOTED:A++,DOCTYPE_DTD:A++,DOCTYPE_DTD_QUOTED:A++,COMMENT_STARTING:A++,COMMENT:A++,COMMENT_ENDING:A++,COMMENT_ENDED:A++,CDATA:A++,CDATA_ENDING:A++,CDATA_ENDING_2:A++,PROC_INST:A++,PROC_INST_BODY:A++,PROC_INST_ENDING:A++,OPEN_TAG:A++,OPEN_TAG_SLASH:A++,ATTRIB:A++,ATTRIB_NAME:A++,ATTRIB_NAME_SAW_WHITE:A++,ATTRIB_VALUE:A++,ATTRIB_VALUE_QUOTED:A++,ATTRIB_VALUE_CLOSED:A++,ATTRIB_VALUE_UNQUOTED:A++,ATTRIB_VALUE_ENTITY_Q:A++,ATTRIB_VALUE_ENTITY_U:A++,CLOSE_TAG:A++,CLOSE_TAG_SAW_WHITE:A++,SCRIPT:A++,SCRIPT_ENDING:A++},r.XML_ENTITIES={amp:"&",gt:">",lt:"<",quot:'"',apos:"'"},r.ENTITIES={amp:"&",gt:">",lt:"<",quot:'"',apos:"'",AElig:198,Aacute:193,Acirc:194,Agrave:192,Aring:197,Atilde:195,Auml:196,Ccedil:199,ETH:208,Eacute:201,Ecirc:202,Egrave:200,Euml:203,Iacute:205,Icirc:206,Igrave:204,Iuml:207,Ntilde:209,Oacute:211,Ocirc:212,Ograve:210,Oslash:216,Otilde:213,Ouml:214,THORN:222,Uacute:218,Ucirc:219,Ugrave:217,Uuml:220,Yacute:221,aacute:225,acirc:226,aelig:230,agrave:224,aring:229,atilde:227,auml:228,ccedil:231,eacute:233,ecirc:234,egrave:232,eth:240,euml:235,iacute:237,icirc:238,igrave:236,iuml:239,ntilde:241,oacute:243,ocirc:244,ograve:242,oslash:248,otilde:245,ouml:246,szlig:223,thorn:254,uacute:250,ucirc:251,ugrave:249,uuml:252,yacute:253,yuml:255,copy:169,reg:174,nbsp:160,iexcl:161,cent:162,pound:163,curren:164,yen:165,brvbar:166,sect:167,uml:168,ordf:170,laquo:171,not:172,shy:173,macr:175,deg:176,plusmn:177,sup1:185,sup2:178,sup3:179,acute:180,micro:181,para:182,middot:183,cedil:184,ordm:186,raquo:187,frac14:188,frac12:189,frac34:190,iquest:191,times:215,divide:247,OElig:338,oelig:339,Scaron:352,scaron:353,Yuml:376,fnof:402,circ:710,tilde:732,Alpha:913,Beta:914,Gamma:915,Delta:916,Epsilon:917,Zeta:918,Eta:919,Theta:920,Iota:921,Kappa:922,Lambda:923,Mu:924,Nu:925,Xi:926,Omicron:927,Pi:928,Rho:929,Sigma:931,Tau:932,Upsilon:933,Phi:934,Chi:935,Psi:936,Omega:937,alpha:945,beta:946,gamma:947,delta:948,epsilon:949,zeta:950,eta:951,theta:952,iota:953,kappa:954,lambda:955,mu:956,nu:957,xi:958,omicron:959,pi:960,rho:961,sigmaf:962,sigma:963,tau:964,upsilon:965,phi:966,chi:967,psi:968,omega:969,thetasym:977,upsih:978,piv:982,ensp:8194,emsp:8195,thinsp:8201,zwnj:8204,zwj:8205,lrm:8206,rlm:8207,ndash:8211,mdash:8212,lsquo:8216,rsquo:8217,sbquo:8218,ldquo:8220,rdquo:8221,bdquo:8222,dagger:8224,Dagger:8225,bull:8226,hellip:8230,permil:8240,prime:8242,Prime:8243,lsaquo:8249,rsaquo:8250,oline:8254,frasl:8260,euro:8364,image:8465,weierp:8472,real:8476,trade:8482,alefsym:8501,larr:8592,uarr:8593,rarr:8594,darr:8595,harr:8596,crarr:8629,lArr:8656,uArr:8657,rArr:8658,dArr:8659,hArr:8660,forall:8704,part:8706,exist:8707,empty:8709,nabla:8711,isin:8712,notin:8713,ni:8715,prod:8719,sum:8721,minus:8722,lowast:8727,radic:8730,prop:8733,infin:8734,ang:8736,and:8743,or:8744,cap:8745,cup:8746,int:8747,there4:8756,sim:8764,cong:8773,asymp:8776,ne:8800,equiv:8801,le:8804,ge:8805,sub:8834,sup:8835,nsub:8836,sube:8838,supe:8839,oplus:8853,otimes:8855,perp:8869,sdot:8901,lceil:8968,rceil:8969,lfloor:8970,rfloor:8971,lang:9001,rang:9002,loz:9674,spades:9824,clubs:9827,hearts:9829,diams:9830},Object.keys(r.ENTITIES).forEach(function(t){var e=r.ENTITIES[t],n="number"==typeof e?String.fromCharCode(e):e;r.ENTITIES[t]=n}),r.STATE)r.STATE[r.STATE[N]]=N;function S(t,e,r){t[e]&&t[e](r)}function C(t,e,r){t.textNode&&k(t),S(t,e,r)}function k(t){t.textNode=F(t.opt,t.textNode),t.textNode&&S(t,"ontext",t.textNode),t.textNode=""}function F(t,e){return t.trim&&(e=e.trim()),t.normalize&&(e=e.replace(/\s+/g," ")),e}function I(t,e){return k(t),t.trackPosition&&(e+="\nLine: "+t.line+"\nColumn: "+t.column+"\nChar: "+t.c),e=new Error(e),t.error=e,S(t,"onerror",e),t}function O(t){return t.sawRoot&&!t.closedRoot&&L(t,"Unclosed root tag"),t.state!==A.BEGIN&&t.state!==A.BEGIN_WHITESPACE&&t.state!==A.TEXT&&I(t,"Unexpected end"),k(t),t.c="",t.closed=!0,S(t,"onend"),s.call(t,t.strict,t.opt),t}function L(t,e){if("object"!=typeof t||!(t instanceof s))throw new Error("bad call to strictFail");t.strict&&I(t,e)}function M(t){t.strict||(t.tagName=t.tagName[t.looseCase]());var e=t.tags[t.tags.length-1]||t,r=t.tag={name:t.tagName,attributes:{}};t.opt.xmlns&&(r.ns=e.ns),t.attribList.length=0,C(t,"onopentagstart",r)}function D(t,e){var r=t.indexOf(":")<0?["",t]:t.split(":"),n=r[0],i=r[1];return e&&"xmlns"===t&&(n="xmlns",i=""),{prefix:n,local:i}}function j(t){if(t.strict||(t.attribName=t.attribName[t.looseCase]()),-1!==t.attribList.indexOf(t.attribName)||t.tag.attributes.hasOwnProperty(t.attribName))t.attribName=t.attribValue="";else{if(t.opt.xmlns){var e=D(t.attribName,!0),r=e.prefix,n=e.local;if("xmlns"===r)if("xml"===n&&t.attribValue!==c)L(t,"xml: prefix must be bound to "+c+"\nActual: "+t.attribValue);else if("xmlns"===n&&t.attribValue!==f)L(t,"xmlns: prefix must be bound to "+f+"\nActual: "+t.attribValue);else{var i=t.tag,s=t.tags[t.tags.length-1]||t;i.ns===s.ns&&(i.ns=Object.create(s.ns)),i.ns[n]=t.attribValue}t.attribList.push([t.attribName,t.attribValue])}else t.tag.attributes[t.attribName]=t.attribValue,C(t,"onattribute",{name:t.attribName,value:t.attribValue});t.attribName=t.attribValue=""}}function B(t,e){if(t.opt.xmlns){var r=t.tag,n=D(t.tagName);r.prefix=n.prefix,r.local=n.local,r.uri=r.ns[n.prefix]||"",r.prefix&&!r.uri&&(L(t,"Unbound namespace prefix: "+JSON.stringify(t.tagName)),r.uri=n.prefix);var i=t.tags[t.tags.length-1]||t;r.ns&&i.ns!==r.ns&&Object.keys(r.ns).forEach(function(e){C(t,"onopennamespace",{prefix:e,uri:r.ns[e]})});for(var s=0,o=t.attribList.length;s",t.tagName="",void(t.state=A.SCRIPT);C(t,"onscript",t.script),t.script=""}var e=t.tags.length,r=t.tagName;t.strict||(r=r[t.looseCase]());for(var n=r;e--;){if(t.tags[e].name===n)break;L(t,"Unexpected close tag")}if(e<0)return L(t,"Unmatched closing tag: "+t.tagName),t.textNode+="",void(t.state=A.TEXT);t.tagName=r;for(var i=t.tags.length;i-- >e;){var s=t.tag=t.tags.pop();t.tagName=t.tag.name,C(t,"onclosetag",t.tagName);var o={};for(var a in s.ns)o[a]=s.ns[a];var u=t.tags[t.tags.length-1]||t;t.opt.xmlns&&s.ns!==u.ns&&Object.keys(s.ns).forEach(function(e){var r=s.ns[e];C(t,"onclosenamespace",{prefix:e,uri:r})})}0===e&&(t.closedRoot=!0),t.tagName=t.attribValue=t.attribName="",t.attribList.length=0,t.state=A.TEXT}function P(t){var e,r=t.entity,n=r.toLowerCase(),i="";return t.ENTITIES[r]?t.ENTITIES[r]:t.ENTITIES[n]?t.ENTITIES[n]:("#"===(r=n).charAt(0)&&("x"===r.charAt(1)?(r=r.slice(2),i=(e=parseInt(r,16)).toString(16)):(r=r.slice(1),i=(e=parseInt(r,10)).toString(10))),r=r.replace(/^0+/,""),isNaN(e)||i.toLowerCase()!==r?(L(t,"Invalid character entity"),"&"+t.entity+";"):String.fromCodePoint(e))}function U(t,e){"<"===e?(t.state=A.OPEN_WAKA,t.startTagPosition=t.position):y(e)||(L(t,"Non-whitespace before first tag."),t.textNode=e,t.state=A.TEXT)}function K(t,e){var r="";return e1114111||T(o)!==o)throw RangeError("Invalid code point: "+o);o<=65535?r.push(o):(t=55296+((o-=65536)>>10),e=o%1024+56320,r.push(t,e)),(n+1===i||r.length>16384)&&(s+=_.apply(null,r),r.length=0)}return s},Object.defineProperty?Object.defineProperty(String,"fromCodePoint",{value:x,configurable:!0,writable:!0}):String.fromCodePoint=x)}(void 0===r?this.sax={}:r)}).call(this,t("buffer").Buffer)},{buffer:3,stream:27,string_decoder:28}],27:[function(t,e,r){e.exports=i;var n=t("events").EventEmitter;function i(){n.call(this)}t("inherits")(i,n),i.Readable=t("readable-stream/readable.js"),i.Writable=t("readable-stream/writable.js"),i.Duplex=t("readable-stream/duplex.js"),i.Transform=t("readable-stream/transform.js"),i.PassThrough=t("readable-stream/passthrough.js"),i.Stream=i,i.prototype.pipe=function(t,e){var r=this;function i(e){t.writable&&!1===t.write(e)&&r.pause&&r.pause()}function s(){r.readable&&r.resume&&r.resume()}r.on("data",i),t.on("drain",s),t._isStdio||e&&!1===e.end||(r.on("end",a),r.on("close",u));var o=!1;function a(){o||(o=!0,t.end())}function u(){o||(o=!0,"function"==typeof t.destroy&&t.destroy())}function l(t){if(c(),0===n.listenerCount(this,"error"))throw t}function c(){r.removeListener("data",i),t.removeListener("drain",s),r.removeListener("end",a),r.removeListener("close",u),r.removeListener("error",l),t.removeListener("error",l),r.removeListener("end",c),r.removeListener("close",c),t.removeListener("close",c)}return r.on("error",l),t.on("error",l),r.on("end",c),r.on("close",c),t.on("close",c),t.emit("pipe",r),t}},{events:5,inherits:7,"readable-stream/duplex.js":12,"readable-stream/passthrough.js":21,"readable-stream/readable.js":22,"readable-stream/transform.js":23,"readable-stream/writable.js":24}],28:[function(t,e,r){"use strict";var n=t("safe-buffer").Buffer,i=n.isEncoding||function(t){switch((t=""+t)&&t.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function s(t){var e;switch(this.encoding=function(t){var e=function(t){if(!t)return"utf8";for(var e;;)switch(t){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return t;default:if(e)return;t=(""+t).toLowerCase(),e=!0}}(t);if("string"!=typeof e&&(n.isEncoding===i||!i(t)))throw new Error("Unknown encoding: "+t);return e||t}(t),this.encoding){case"utf16le":this.text=u,this.end=l,e=4;break;case"utf8":this.fillLast=a,e=4;break;case"base64":this.text=c,this.end=f,e=3;break;default:return this.write=h,void(this.end=p)}this.lastNeed=0,this.lastTotal=0,this.lastChar=n.allocUnsafe(e)}function o(t){return t<=127?0:t>>5==6?2:t>>4==14?3:t>>3==30?4:t>>6==2?-1:-2}function a(t){var e=this.lastTotal-this.lastNeed,r=function(t,e,r){if(128!=(192&e[0]))return t.lastNeed=0,"�";if(t.lastNeed>1&&e.length>1){if(128!=(192&e[1]))return t.lastNeed=1,"�";if(t.lastNeed>2&&e.length>2&&128!=(192&e[2]))return t.lastNeed=2,"�"}}(this,t);return void 0!==r?r:this.lastNeed<=t.length?(t.copy(this.lastChar,e,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(t.copy(this.lastChar,e,0,t.length),void(this.lastNeed-=t.length))}function u(t,e){if((t.length-e)%2==0){var r=t.toString("utf16le",e);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=t[t.length-1],t.toString("utf16le",e,t.length-1)}function l(t){var e=t&&t.length?this.write(t):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return e+this.lastChar.toString("utf16le",0,r)}return e}function c(t,e){var r=(t.length-e)%3;return 0===r?t.toString("base64",e):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=t[t.length-1]:(this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1]),t.toString("base64",e,t.length-r))}function f(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+this.lastChar.toString("base64",0,3-this.lastNeed):e}function h(t){return t.toString(this.encoding)}function p(t){return t&&t.length?this.write(t):""}r.StringDecoder=s,s.prototype.write=function(t){if(0===t.length)return"";var e,r;if(this.lastNeed){if(void 0===(e=this.fillLast(t)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r=0)return i>0&&(t.lastNeed=i-1),i;if(--n=0)return i>0&&(t.lastNeed=i-2),i;if(--n=0)return i>0&&(2===i?i=0:t.lastNeed=i-3),i;return 0}(this,t,e);if(!this.lastNeed)return t.toString("utf8",e);this.lastTotal=r;var n=t.length-(r-this.lastNeed);return t.copy(this.lastChar,0,n),t.toString("utf8",e,n)},s.prototype.fillLast=function(t){if(this.lastNeed<=t.length)return t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,t.length),this.lastNeed-=t.length}},{"safe-buffer":25}],29:[function(t,e,r){(function(e,n){var i=t("process/browser.js").nextTick,s=Function.prototype.apply,o=Array.prototype.slice,a={},u=0;function l(t,e){this._id=t,this._clearFn=e}r.setTimeout=function(){return new l(s.call(setTimeout,window,arguments),clearTimeout)},r.setInterval=function(){return new l(s.call(setInterval,window,arguments),clearInterval)},r.clearTimeout=r.clearInterval=function(t){t.close()},l.prototype.unref=l.prototype.ref=function(){},l.prototype.close=function(){this._clearFn.call(window,this._id)},r.enroll=function(t,e){clearTimeout(t._idleTimeoutId),t._idleTimeout=e},r.unenroll=function(t){clearTimeout(t._idleTimeoutId),t._idleTimeout=-1},r._unrefActive=r.active=function(t){clearTimeout(t._idleTimeoutId);var e=t._idleTimeout;e>=0&&(t._idleTimeoutId=setTimeout(function(){t._onTimeout&&t._onTimeout()},e))},r.setImmediate="function"==typeof e?e:function(t){var e=u++,n=!(arguments.length<2)&&o.call(arguments,1);return a[e]=!0,i(function(){a[e]&&(n?t.apply(null,n):t.call(null),r.clearImmediate(e))}),e},r.clearImmediate="function"==typeof n?n:function(t){delete a[t]}}).call(this,t("timers").setImmediate,t("timers").clearImmediate)},{"process/browser.js":11,timers:29}],30:[function(t,e,r){(function(t){function r(e){try{if(!t.localStorage)return!1}catch(t){return!1}var r=t.localStorage[e];return null!=r&&"true"===String(r).toLowerCase()}e.exports=function(t,e){if(r("noDeprecation"))return t;var n=!1;return function(){if(!n){if(r("throwDeprecation"))throw new Error(e);r("traceDeprecation")?console.trace(e):console.warn(e),n=!0}return t.apply(this,arguments)}}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],31:[function(t,e,r){e.exports={isArray:function(t){return Array.isArray?Array.isArray(t):"[object Array]"===Object.prototype.toString.call(t)}}},{}],32:[function(t,e,r){var n=t("./xml2js"),i=t("./xml2json"),s=t("./js2xml"),o=t("./json2xml");e.exports={xml2js:n,xml2json:i,js2xml:s,json2xml:o}},{"./js2xml":33,"./json2xml":34,"./xml2js":36,"./xml2json":37}],33:[function(t,e,r){var n,i,s=t("./options-helper"),o=t("./array-helper").isArray;function a(t,e,r){return(!r&&t.spaces?"\n":"")+Array(e+1).join(t.spaces)}function u(t,e,r){if(e.ignoreAttributes)return"";"attributesFn"in e&&(t=e.attributesFn(t,i,n));var s,o,u,l,c=[];for(s in t)t.hasOwnProperty(s)&&null!==t[s]&&void 0!==t[s]&&(l=e.noQuotesForNativeAttributes&&"string"!=typeof t[s]?"":'"',o=(o=""+t[s]).replace(/"/g,"""),u="attributeNameFn"in e?e.attributeNameFn(s,o,i,n):s,c.push(e.spaces&&e.indentAttributes?a(e,r+1,!1):" "),c.push(u+"="+l+("attributeValueFn"in e?e.attributeValueFn(o,s,i,n):o)+l));return t&&Object.keys(t).length&&e.spaces&&e.indentAttributes&&c.push(a(e,r,!1)),c.join("")}function l(t,e,r){return n=t,i="xml",e.ignoreDeclaration?"":""}function c(t,e,r){if(e.ignoreInstruction)return"";var s;for(s in t)if(t.hasOwnProperty(s))break;var o="instructionNameFn"in e?e.instructionNameFn(s,t[s],i,n):s;if("object"==typeof t[s])return n=t,i=o,"";var a=t[s]?t[s]:"";return"instructionFn"in e&&(a=e.instructionFn(a,s,i,n)),""}function f(t,e){return e.ignoreComment?"":"\x3c!--"+("commentFn"in e?e.commentFn(t,i,n):t)+"--\x3e"}function h(t,e){return e.ignoreCdata?"":"","]]]]>"))+"]]>"}function p(t,e){return e.ignoreDoctype?"":""}function d(t,e){return e.ignoreText?"":(t=(t=(t=""+t).replace(/&/g,"&")).replace(/&/g,"&").replace(//g,">"),"textFn"in e?e.textFn(t,i,n):t)}function g(t,e,r,s){return t.reduce(function(t,o){var l=a(e,r,s&&!t);switch(o.type){case"element":return t+l+function(t,e,r){n=t,i=t.name;var s=[],o="elementNameFn"in e?e.elementNameFn(t.name,t):t.name;s.push("<"+o),t[e.attributesKey]&&s.push(u(t[e.attributesKey],e,r));var a=t[e.elementsKey]&&t[e.elementsKey].length||t[e.attributesKey]&&"preserve"===t[e.attributesKey]["xml:space"];return a||(a="fullTagEmptyElementFn"in e?e.fullTagEmptyElementFn(t.name,t):e.fullTagEmptyElement),a?(s.push(">"),t[e.elementsKey]&&t[e.elementsKey].length&&(s.push(g(t[e.elementsKey],e,r+1)),n=t,i=t.name),s.push(e.spaces&&function(t,e){var r;if(t.elements&&t.elements.length)for(r=0;r")):s.push("/>"),s.join("")}(o,e,r);case"comment":return t+l+f(o[e.commentKey],e);case"doctype":return t+l+p(o[e.doctypeKey],e);case"cdata":return t+(e.indentCdata?l:"")+h(o[e.cdataKey],e);case"text":return t+(e.indentText?l:"")+d(o[e.textKey],e);case"instruction":var m={};return m[o[e.nameKey]]=o[e.attributesKey]?o:o[e.instructionKey],t+(e.indentInstruction?l:"")+c(m,e,r)}},"")}function m(t,e,r){var n;for(n in t)if(t.hasOwnProperty(n))switch(n){case e.parentKey:case e.attributesKey:break;case e.textKey:if(e.indentText||r)return!0;break;case e.cdataKey:if(e.indentCdata||r)return!0;break;case e.instructionKey:if(e.indentInstruction||r)return!0;break;case e.doctypeKey:case e.commentKey:default:return!0}return!1}function y(t,e,r,s,o){n=t,i=e;var l="elementNameFn"in r?r.elementNameFn(e,t):e;if(void 0===t||null===t||""===t)return"fullTagEmptyElementFn"in r&&r.fullTagEmptyElementFn(e,t)||r.fullTagEmptyElement?"<"+l+">":"<"+l+"/>";var c=[];if(e){if(c.push("<"+l),"object"!=typeof t)return c.push(">"+d(t,r)+""),c.join("");t[r.attributesKey]&&c.push(u(t[r.attributesKey],r,s));var f=m(t,r,!0)||t[r.attributesKey]&&"preserve"===t[r.attributesKey]["xml:space"];if(f||(f="fullTagEmptyElementFn"in r?r.fullTagEmptyElementFn(e,t):r.fullTagEmptyElement),!f)return c.push("/>"),c.join("");c.push(">")}return c.push(b(t,r,s+1,!1)),n=t,i=e,e&&c.push((o?a(r,s,!1):"")+""),c.join("")}function b(t,e,r,n){var i,s,u,g=[];for(s in t)if(t.hasOwnProperty(s))for(u=o(t[s])?t[s]:[t[s]],i=0;i/g,">")),l("text",t))}function d(t){n.ignoreComment||(n.trim&&(t=t.trim()),l("comment",t))}function g(t){var e=i[n.parentKey];n.addParent||delete i[n.parentKey],i=e}function m(t){n.ignoreCdata||(n.trim&&(t=t.trim()),l("cdata",t))}function y(t){n.ignoreDoctype||(t=t.replace(/^ /,""),n.trim&&(t=t.trim()),l("doctype",t))}function b(t){t.note=t}e.exports=function(t,e){var r=s.parser(!0,{}),a={};if(i=a,n=function(t){return n=o.copyOptions(t),o.ensureFlagExists("ignoreDeclaration",n),o.ensureFlagExists("ignoreInstruction",n),o.ensureFlagExists("ignoreAttributes",n),o.ensureFlagExists("ignoreText",n),o.ensureFlagExists("ignoreComment",n),o.ensureFlagExists("ignoreCdata",n),o.ensureFlagExists("ignoreDoctype",n),o.ensureFlagExists("compact",n),o.ensureFlagExists("alwaysChildren",n),o.ensureFlagExists("addParent",n),o.ensureFlagExists("trim",n),o.ensureFlagExists("nativeType",n),o.ensureFlagExists("nativeTypeAttributes",n),o.ensureFlagExists("sanitize",n),o.ensureFlagExists("instructionHasAttributes",n),o.ensureFlagExists("captureSpacesBetweenElements",n),o.ensureAlwaysArrayExists(n),o.ensureKeyExists("declaration",n),o.ensureKeyExists("instruction",n),o.ensureKeyExists("attributes",n),o.ensureKeyExists("text",n),o.ensureKeyExists("comment",n),o.ensureKeyExists("cdata",n),o.ensureKeyExists("doctype",n),o.ensureKeyExists("type",n),o.ensureKeyExists("name",n),o.ensureKeyExists("elements",n),o.ensureKeyExists("parent",n),o.checkFnExists("doctype",n),o.checkFnExists("instruction",n),o.checkFnExists("cdata",n),o.checkFnExists("comment",n),o.checkFnExists("text",n),o.checkFnExists("instructionName",n),o.checkFnExists("elementName",n),o.checkFnExists("attributeName",n),o.checkFnExists("attributeValue",n),o.checkFnExists("attributes",n),n}(e),r.opt={strictEntities:!0},r.onopentag=h,r.ontext=p,r.oncomment=d,r.onclosetag=g,r.onerror=b,r.oncdata=m,r.ondoctype=y,r.onprocessinginstruction=f,r.write(t).close(),a[n.elementsKey]){var u=a[n.elementsKey];delete a[n.elementsKey],a[n.elementsKey]=u,delete a.text}return a}},{"./array-helper":31,"./options-helper":35,sax:26}],37:[function(t,e,r){var n=t("./options-helper"),i=t("./xml2js");e.exports=function(t,e){var r,s,o;return r=function(t){var e=n.copyOptions(t);return n.ensureSpacesExists(e),e}(e),s=i(t,r),o="compact"in r&&r.compact?"_parent":"parent",("addParent"in r&&r.addParent?JSON.stringify(s,function(t,e){return t===o?"_":e},r.spaces):JSON.stringify(s,null,r.spaces)).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}},{"./options-helper":35,"./xml2js":36}],38:[function(t,e,r){(function(r){const n=t("./placing"),i=t("./rendering"),s={compute:t=>{const e=t.options||{};let r={};(t.nodes||[]).filter(t=>"string"==typeof t.name).forEach(t=>r[t.name]=t);let s=(t.links||[]).filter(t=>t.from&&t.to);if(s.filter(t=>!r[t.from]).forEach(t=>console.warn(`unknown source node "${t.from}"`)),s.filter(t=>!r[t.to]).forEach(t=>console.warn(`unknown destination node "${t.to}"`)),s=s.filter(t=>r[t.from]&&r[t.to]),!(r=n(e.placing).compute(r,s)))throw"Failed to place nodes";return i(e.rendering).compute(r,s)}};e.exports=s,r.faDiagrams=s}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./placing":39,"./rendering":40}],39:[function(t,e,r){const n=t("./utils"),i={name:"!string",x:"number",y:"number"},s={from:"!string",to:"!string",direction:"string"},o={"max-link-length":3,diagonals:!0};e.exports=(t=>{t=n.merge(o,t);const e={getBounds:t=>{const e=Object.values(t).filter(t=>void 0!==t.x);if(0===e.length)return{x:0,y:0,w:0,h:0};let r=null,n=null,i=null,s=null;return e.forEach(t=>{r=null!==r?Math.min(t.x,r):t.x,n=null!==n?Math.min(t.y,n):t.y,i=null!==i?Math.max(t.x,i):t.x,s=null!==s?Math.max(t.y,s):t.y}),{x:r,y:n,w:i-r+1,h:s-n+1}},getNewPos:t=>{const r=e.getBounds(t),i=n.newMap(r.w,r.h,!1);Object.values(t).filter(t=>void 0!==t.x).forEach(t=>{i[t.x-r.x][t.y-r.y]=!0});for(let t=0;t{let n=t[e].x,i=t[e].y,s=t[r].x,o=t[r].y;const a=s-n,u=o-i,l=(t,n)=>i=>i.x===t&&i.y===n&&i.name!==e&&i.name!==r;if(Math.abs(a)>=Math.abs(u)){if(n>s){let t=n;n=s,s=t}for(let e=n;e<=s;e++){let r=Math.round(i+u*(e-n)/a);if(Object.values(t).find(l(e,r)))return!0}}else{if(i>o){let t=i;i=o,o=t}for(let e=i;e<=o;e++){let r=Math.round(n+a*(e-i)/u);if(Object.values(t).find(l(r,e)))return!0}}return!1},getPosition:(e,r,n)=>{const i=e[r],s={maxX:null,maxY:null,minX:null,minY:null,startX:null,startY:null,free:!0},o=(t,r,n,i)=>o=>{if(void 0!==e[o].x){const a=e[o].x,u=e[o].y;s.minX=null!==s.minX?Math.max(a+t,s.minX):a+t,s.maxX=null!==s.maxX?Math.min(a+r,s.maxX):a+r,s.minY=null!==s.minY?Math.max(u+n,s.minY):u+n,s.maxY=null!==s.maxY?Math.min(u+i,s.maxY):u+i,null===s.startX&&(s.startX=Math.abs(i+n)>0?a:1===Math.abs(t)?"minX":"maxX",s.startY=Math.abs(r+t)>0?u:1===Math.abs(n)?"minY":"maxY"),s.free=!1}},a=t["max-link-length"],u=n?a:0;return i.const.beforeX.forEach(o(1,1+a,-u,u)),i.const.beforeY.forEach(o(-u,u,1,1+a)),i.const.afterX.forEach(o(-1-a,-1,-u,u)),i.const.afterY.forEach(o(-u,u,-1-a,-1)),"string"==typeof s.startX&&(s.startX=s[s.startX]),"string"==typeof s.startY&&(s.startY=s[s.startY]),s.minX>s.maxX||s.minY>s.maxY?null:{x:s.startX,y:s.startY,free:s.free}},isValid:(r,n)=>{let i,s,o;const a=Object.values(r).filter(t=>void 0!==t.x);for(let t=0;tMath.pow(t["max-link-length"],2))return!1;switch(i.direction){case"up":case"top":if(o.y-s.y>=0)return!1;break;case"down":case"bottom":if(o.y-s.y<=0)return!1;break;case"left":if(o.x-s.x>=0)return!1;break;case"right":if(o.x-s.x<=0)return!1}if(!t.diagonals&&s.x!==o.x&&s.y!==o.y)return!1}return!0},correctPlacing:t=>{const r=e.getBounds(t);Object.values(t).forEach(t=>{t.x-=r.x,t.y-=r.y})},applyLinks:(r,i,s=0)=>{if(!e.isValid(r,i))return null;const o=Object.keys(r).filter(t=>void 0===r[t].x);if(0===o.length)return r;const a=[],u=(t,o,a)=>{const u=n.ezClone(r);return u[t].x=o,u[t].y=a,e.applyLinks(u,i,s+1)};let l,c,f;for(let n=0;n(Object.keys(t).forEach(e=>{const r=n.isValid(t[e],i);if(r)throw`Node '${e}' is invalid at key '${r}'`}),r.forEach((t,e)=>{const r=n.isValid(t,s);if(r)throw`Link ${e} (${t.from}->${t.to}) is invalid at key '${r}'`}),Object.values(t).forEach(t=>{t.const={beforeX:[],afterX:[],beforeY:[],afterY:[]}}),r.forEach(e=>{if(e.direction)switch(e.direction){case"up":case"top":t[e.from].const.beforeY.push(e.to),t[e.to].const.afterY.push(e.from);break;case"down":case"bottom":t[e.from].const.afterY.push(e.to),t[e.to].const.beforeY.push(e.from);break;case"left":t[e.from].const.beforeX.push(e.to),t[e.to].const.afterX.push(e.from);break;case"right":t[e.from].const.afterX.push(e.to),t[e.to].const.beforeX.push(e.from)}}),(t=e.applyLinks(t,r))&&(e.correctPlacing(t),Object.values(t).forEach(t=>{delete t.const})),t)};return e})},{"./utils":41}],40:[function(t,e,r){const n=t("xml-js"),i=t("./utils");let s={name:"error",height:512,index:[],links:{"arrow-head":{},"arrow-head-reverse":{},"line-start":{},"line-end":{},"dashed-step":{}},icons:{}};try{s=t("../resources.json")}catch(t){console.error("fa-diagrams: SVG resources could not be loaded: "+t)}const o={_:"string",text:"string",icon:{_:"string",path:"string",width:"number",height:"number"},color:"string",font:"string","font-size":"number","font-style":"string",scale:"number"},a={name:"!string",icon:{_:"string",path:"string",width:"number",height:"number"},x:"!number",y:"!number",color:"string",scale:"number",top:o,bottom:o,left:o,right:o},u={from:"!string",to:"!string",type:"string",color:"string",scale:"number",size:"number",top:o,bottom:o},l={beautify:!1,scale:128,"h-spacing":1.3,color:"black",icons:{scale:1,color:""},links:{scale:1,color:"",size:0},texts:{font:"sans-serif","font-size":"20","font-style":"normal",color:""}},c={"font-awesome":{fas:"solid",far:"regular",fab:"brands"}};e.exports=(t=>{t=i.merge(l,t);const e={getIcon:t=>{if(!t)return null;if("object"==typeof t)return t.path&&t.path.trim()?(t.height=t.height||t.width||s.height,t.width=t.width||t.height,t):null;if(!t.trim())return null;let e=i.ezClone(s.index);const r=t.trim().split(" ").map(t=>0===t.indexOf("fa-")?t.substr(3):t);for(let t=0;t{const r="v46.059c0 21.382 25.851 32.09 40.971 16.971 l86.059 -86.059c9.373-9.373 9.373-24.569 0-33.941l-86.059-86.059c-15.119-15.119-40.971-4.411-40.971 16.971v46.059",n="v-46.059c0-21.382-25.851-32.09-40.971-16.971l-86.059 86.059c-9.373 9.373-9.373 24.568 0 33.941l86.059 86.059c15.119 15.119 40.971 4.411 40.971-16.971v-46.059",i="c6.627 0 12 -5.373 12 -12v-56c0 -6.627 -5.373 -12 -12 -12",s="c-6.627 0-12 5.373-12 12v56c0 6.627 5.373 12 12 12",o=`${s}h56${i}`;switch(t){case"none":return null;default:return`M12 216${s}h${512*e-146.059}${r}z`;case"line":return`M12 216${s}h${512*e-24}${i}z`;case"double":return`M134.059 216${n}h${512*e-268.06}${r}z`;case"split-double":return`M12 126${s}h${512*e-146.059}${r}M134.059 306${n}h${512*e-146.059}${i}z`;case"dashed":const a=Math.floor((512*e-134.059)/168),u=(512*e-134.059-56*a-24)/a;return`M12 216${new Array(a).fill(`${o}m${u} 0`).join("")}v80${r}z`;case"dashed-line":const l=Math.floor(512*e/168),c=(512*e-56*l-24)/(l-1);return`M12 216${new Array(l).fill(o).join(`m${c} 0`)}z`;case"dashed-double":const f=Math.floor((512*e-268.118)/168),h=(512*e-268.118-56*f-24)/(f+1);return`M134.059 216${n}m${h}-80${new Array(f).fill(`${o}m${h} 0`).join("")}v80${r}z`;case"dashed-split-double":const p=Math.floor((512*e-134.059)/168),d=(512*e-134.059-56*p-24)/p;return`M12 126${new Array(p).fill(`${o}m${d} 0`).join("")}v80${r}M134.059 306${n}m${d} -80${new Array(p).fill(`${o}`).join(`m${d} 0`)}z`}},getBounds:t=>{const e=Object.values(t);if(0===e.length)return{w:0,h:0};let r=0,n=0;return e.forEach(t=>{r=Math.max(t.x,r),n=Math.max(t.y,n)}),{w:r+1,h:n+1}},renderNode:r=>{const n=e.getIcon(r.icon);if(!n)return null;const i=.4*(r.scale||t.icons.scale);return{_attributes:{transform:`translate(${(r.x+.5)*t["h-spacing"]} ${r.y+.5})`},g:{_attributes:{transform:`scale(${i/n.height} ${i/n.height}) translate(${-n.width/2} ${-n.height/2})`,stroke:r.color||t.icons.color||void 0,fill:r.color||t.icons.color||void 0},path:{_attributes:{d:n.path}}}}},renderLink:(r,n)=>{const i=r[n.from],s=r[n.to],o=((i.x+s.x)/2+.5)*t["h-spacing"],a=(i.y+s.y)/2+.5,u=180*Math.atan2(s.y-i.y,(s.x-i.x)*t["h-spacing"])/Math.PI,l=.4*(n.scale||t.links.scale);let c=n.size||t.links.size;if(!c){let e=Math.abs(s.x-i.x)*t["h-spacing"];e>0&&(e-=.6);let r=Math.abs(s.y-i.y);r>0&&(r-=.6),c=Math.sqrt(Math.pow(e,2)+Math.pow(r,2))/l}const f=e.getLinkPath(n.type,c);return f?{_attributes:{transform:`translate(${o} ${a}) rotate(${u})`},g:{_attributes:{transform:`scale(${l/512} ${l/512}) translate(${-256*c} -256)`,stroke:n.color||t.links.color||void 0,fill:n.color||t.links.color||void 0},path:{_attributes:{d:f}}}}:null},toXML:(e,r)=>{const i={svg:{_attributes:{xmlns:"http://www.w3.org/2000/svg",viewBox:`0 0 ${r.w*t["h-spacing"]} ${r.h}`,width:r.w*t["h-spacing"]*t.scale/.4,height:r.h*t.scale/.4,stroke:t.color,fill:t.color}}};return Object.keys(e).forEach(t=>{i.svg[t]=e[t]}),n.js2xml(i,{compact:!0,spaces:t.beautify?"\t":0})},compute:(t,r)=>{const n={g:[]};Object.keys(t).forEach(r=>{const s=i.isValid(t[r],a);if(s)throw`Node '${r}' is invalid at key '${s}'`;const o=e.renderNode(t[r]);o&&n.g.push(o)}),r.forEach((r,s)=>{const o=i.isValid(r,u);if(o)throw`Link ${s} (${r.from}->${r.to}) is invalid at key '${o}'`;const a=e.renderLink(t,r);a&&n.g.push(a)});const s=e.getBounds(t);return e.toXML(n,s)}};return e})},{"../resources.json":void 0,"./utils":41,"xml-js":32}],41:[function(t,e,r){const n={merge:(t,e)=>{if(typeof t!=typeof e)return t;if(t.length&&!e.length)return t;if(t.length&&e.length)return e;if("object"==typeof t){const r={};return Object.keys(t).forEach(i=>r[i]=n.merge(t[i],e[i])),r}return e},isValid:(t,e)=>{const r=Object.keys(e).filter(t=>"_"!==t);let i,s;for(let o=0;o0&&(s="array"),"object"==typeof e[i]){if(s&&"object"!==s&&s!==e[i]._)return i;const r=n.isValid(s?t[i]:void 0,e[i]);if(r)return i+"."+r}else{if("!"===e[i][0]&&(e[i]=e[i].substr(1),!s))return i;if(s&&s!==e[i])return i}return null},ezClone:t=>JSON.parse(JSON.stringify(t)),newMap:(t,e,r)=>new Array(t).fill(0).map(()=>new Array(e).fill(r))};e.exports=n},{}]},{},[38]); \ No newline at end of file +!function(){return function t(e,r,n){function i(o,a){if(!r[o]){if(!e[o]){var u="function"==typeof require&&require;if(!a&&u)return u(o,!0);if(s)return s(o,!0);var l=new Error("Cannot find module '"+o+"'");throw l.code="MODULE_NOT_FOUND",l}var c=r[o]={exports:{}};e[o][0].call(c.exports,function(t){return i(e[o][1][t]||t)},c,c.exports,t,e,r,n)}return r[o].exports}for(var s="function"==typeof require&&require,o=0;o0?n-4:n,f=0;f>16&255,a[u++]=e>>8&255,a[u++]=255&e;2===o&&(e=i[t.charCodeAt(f)]<<2|i[t.charCodeAt(f+1)]>>4,a[u++]=255&e);1===o&&(e=i[t.charCodeAt(f)]<<10|i[t.charCodeAt(f+1)]<<4|i[t.charCodeAt(f+2)]>>2,a[u++]=e>>8&255,a[u++]=255&e);return a},r.fromByteArray=function(t){for(var e,r=t.length,i=r%3,s=[],o=0,a=r-i;oa?a:o+16383));1===i?(e=t[r-1],s.push(n[e>>2]+n[e<<4&63]+"==")):2===i&&(e=(t[r-2]<<8)+t[r-1],s.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"="));return s.join("")};for(var n=[],i=[],s="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,u=o.length;a0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function c(t,e,r){for(var i,s,o=[],a=e;a>18&63]+n[s>>12&63]+n[s>>6&63]+n[63&s]);return o.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},{}],2:[function(t,e,r){},{}],3:[function(t,e,r){(function(e){"use strict";var n=t("base64-js"),i=t("ieee754");r.Buffer=e,r.SlowBuffer=function(t){+t!=t&&(t=0);return e.alloc(+t)},r.INSPECT_MAX_BYTES=50;var s=2147483647;function o(t){if(t>s)throw new RangeError('The value "'+t+'" is invalid for option "size"');var r=new Uint8Array(t);return r.__proto__=e.prototype,r}function e(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return l(t)}return a(t,e,r)}function a(t,r,n){if("string"==typeof t)return function(t,r){"string"==typeof r&&""!==r||(r="utf8");if(!e.isEncoding(r))throw new TypeError("Unknown encoding: "+r);var n=0|h(t,r),i=o(n),s=i.write(t,r);s!==n&&(i=i.slice(0,s));return i}(t,r);if(ArrayBuffer.isView(t))return c(t);if(null==t)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(P(t,ArrayBuffer)||t&&P(t.buffer,ArrayBuffer))return function(t,r,n){if(r<0||t.byteLength=s)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s.toString(16)+" bytes");return 0|t}function h(t,r){if(e.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||P(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);var n=t.length,i=arguments.length>2&&!0===arguments[2];if(!i&&0===n)return 0;for(var s=!1;;)switch(r){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return j(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return B(t).length;default:if(s)return i?-1:j(t).length;r=(""+r).toLowerCase(),s=!0}}function p(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function d(t,r,n,i,s){if(0===t.length)return-1;if("string"==typeof n?(i=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),U(n=+n)&&(n=s?0:t.length-1),n<0&&(n=t.length+n),n>=t.length){if(s)return-1;n=t.length-1}else if(n<0){if(!s)return-1;n=0}if("string"==typeof r&&(r=e.from(r,i)),e.isBuffer(r))return 0===r.length?-1:g(t,r,n,i,s);if("number"==typeof r)return r&=255,"function"==typeof Uint8Array.prototype.indexOf?s?Uint8Array.prototype.indexOf.call(t,r,n):Uint8Array.prototype.lastIndexOf.call(t,r,n):g(t,[r],n,i,s);throw new TypeError("val must be string, number or Buffer")}function g(t,e,r,n,i){var s,o=1,a=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;o=2,a/=2,u/=2,r/=2}function l(t,e){return 1===o?t[e]:t.readUInt16BE(e*o)}if(i){var c=-1;for(s=r;sa&&(r=a-u),s=r;s>=0;s--){for(var f=!0,h=0;hi&&(n=i):n=i;var s=e.length;n>s/2&&(n=s/2);for(var o=0;o>8,i=r%256,s.push(i),s.push(n);return s}(e,t.length-r),t,r,n)}function _(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function x(t,e,r){r=Math.min(t.length,r);for(var n=[],i=e;i239?4:l>223?3:l>191?2:1;if(i+f<=r)switch(f){case 1:l<128&&(c=l);break;case 2:128==(192&(s=t[i+1]))&&(u=(31&l)<<6|63&s)>127&&(c=u);break;case 3:s=t[i+1],o=t[i+2],128==(192&s)&&128==(192&o)&&(u=(15&l)<<12|(63&s)<<6|63&o)>2047&&(u<55296||u>57343)&&(c=u);break;case 4:s=t[i+1],o=t[i+2],a=t[i+3],128==(192&s)&&128==(192&o)&&128==(192&a)&&(u=(15&l)<<18|(63&s)<<12|(63&o)<<6|63&a)>65535&&u<1114112&&(c=u)}null===c?(c=65533,f=1):c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|1023&c),n.push(c),i+=f}return function(t){var e=t.length;if(e<=T)return String.fromCharCode.apply(String,t);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return S(this,e,r);case"utf8":case"utf-8":return x(this,e,r);case"ascii":return A(this,e,r);case"latin1":case"binary":return N(this,e,r);case"base64":return _(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},e.prototype.toLocaleString=e.prototype.toString,e.prototype.equals=function(t){if(!e.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===e.compare(this,t)},e.prototype.inspect=function(){var t="",e=r.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),""},e.prototype.compare=function(t,r,n,i,s){if(P(t,Uint8Array)&&(t=e.from(t,t.offset,t.byteLength)),!e.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===r&&(r=0),void 0===n&&(n=t?t.length:0),void 0===i&&(i=0),void 0===s&&(s=this.length),r<0||n>t.length||i<0||s>this.length)throw new RangeError("out of range index");if(i>=s&&r>=n)return 0;if(i>=s)return-1;if(r>=n)return 1;if(r>>>=0,n>>>=0,i>>>=0,s>>>=0,this===t)return 0;for(var o=s-i,a=n-r,u=Math.min(o,a),l=this.slice(i,s),c=t.slice(r,n),f=0;f>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-e;if((void 0===r||r>i)&&(r=i),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var s=!1;;)switch(n){case"hex":return m(this,t,e,r);case"utf8":case"utf-8":return y(this,t,e,r);case"ascii":return b(this,t,e,r);case"latin1":case"binary":return w(this,t,e,r);case"base64":return v(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return E(this,t,e,r);default:if(s)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),s=!0}},e.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var T=4096;function A(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;in)&&(r=n);for(var i="",s=e;sr)throw new RangeError("Trying to access beyond buffer length")}function F(t,r,n,i,s,o){if(!e.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(r>s||rt.length)throw new RangeError("Index out of range")}function I(t,e,r,n,i,s){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function O(t,e,r,n,s){return e=+e,r>>>=0,s||I(t,0,r,4),i.write(t,e,r,n,23,4),r+4}function L(t,e,r,n,s){return e=+e,r>>>=0,s||I(t,0,r,8),i.write(t,e,r,n,52,8),r+8}e.prototype.slice=function(t,r){var n=this.length;t=~~t,r=void 0===r?n:~~r,t<0?(t+=n)<0&&(t=0):t>n&&(t=n),r<0?(r+=n)<0&&(r=0):r>n&&(r=n),r>>=0,e>>>=0,r||k(t,e,this.length);for(var n=this[t],i=1,s=0;++s>>=0,e>>>=0,r||k(t,e,this.length);for(var n=this[t+--e],i=1;e>0&&(i*=256);)n+=this[t+--e]*i;return n},e.prototype.readUInt8=function(t,e){return t>>>=0,e||k(t,1,this.length),this[t]},e.prototype.readUInt16LE=function(t,e){return t>>>=0,e||k(t,2,this.length),this[t]|this[t+1]<<8},e.prototype.readUInt16BE=function(t,e){return t>>>=0,e||k(t,2,this.length),this[t]<<8|this[t+1]},e.prototype.readUInt32LE=function(t,e){return t>>>=0,e||k(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},e.prototype.readUInt32BE=function(t,e){return t>>>=0,e||k(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},e.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||k(t,e,this.length);for(var n=this[t],i=1,s=0;++s=(i*=128)&&(n-=Math.pow(2,8*e)),n},e.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||k(t,e,this.length);for(var n=e,i=1,s=this[t+--n];n>0&&(i*=256);)s+=this[t+--n]*i;return s>=(i*=128)&&(s-=Math.pow(2,8*e)),s},e.prototype.readInt8=function(t,e){return t>>>=0,e||k(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},e.prototype.readInt16LE=function(t,e){t>>>=0,e||k(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},e.prototype.readInt16BE=function(t,e){t>>>=0,e||k(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},e.prototype.readInt32LE=function(t,e){return t>>>=0,e||k(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},e.prototype.readInt32BE=function(t,e){return t>>>=0,e||k(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},e.prototype.readFloatLE=function(t,e){return t>>>=0,e||k(t,4,this.length),i.read(this,t,!0,23,4)},e.prototype.readFloatBE=function(t,e){return t>>>=0,e||k(t,4,this.length),i.read(this,t,!1,23,4)},e.prototype.readDoubleLE=function(t,e){return t>>>=0,e||k(t,8,this.length),i.read(this,t,!0,52,8)},e.prototype.readDoubleBE=function(t,e){return t>>>=0,e||k(t,8,this.length),i.read(this,t,!1,52,8)},e.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e>>>=0,r>>>=0,n)||F(this,t,e,r,Math.pow(2,8*r)-1,0);var i=1,s=0;for(this[e]=255&t;++s>>=0,r>>>=0,n)||F(this,t,e,r,Math.pow(2,8*r)-1,0);var i=r-1,s=1;for(this[e+i]=255&t;--i>=0&&(s*=256);)this[e+i]=t/s&255;return e+r},e.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||F(this,t,e,1,255,0),this[e]=255&t,e+1},e.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||F(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},e.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||F(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},e.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||F(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},e.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||F(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},e.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);F(this,t,e,r,i-1,-i)}var s=0,o=1,a=0;for(this[e]=255&t;++s>0)-a&255;return e+r},e.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);F(this,t,e,r,i-1,-i)}var s=r-1,o=1,a=0;for(this[e+s]=255&t;--s>=0&&(o*=256);)t<0&&0===a&&0!==this[e+s+1]&&(a=1),this[e+s]=(t/o>>0)-a&255;return e+r},e.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||F(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},e.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||F(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},e.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||F(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},e.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||F(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},e.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||F(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},e.prototype.writeFloatLE=function(t,e,r){return O(this,t,e,!0,r)},e.prototype.writeFloatBE=function(t,e,r){return O(this,t,e,!1,r)},e.prototype.writeDoubleLE=function(t,e,r){return L(this,t,e,!0,r)},e.prototype.writeDoubleBE=function(t,e,r){return L(this,t,e,!1,r)},e.prototype.copy=function(t,r,n,i){if(!e.isBuffer(t))throw new TypeError("argument should be a Buffer");if(n||(n=0),i||0===i||(i=this.length),r>=t.length&&(r=t.length),r||(r=0),i>0&&i=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),t.length-r=0;--o)t[o+r]=this[o+n];else Uint8Array.prototype.set.call(t,this.subarray(n,i),r);return s},e.prototype.fill=function(t,r,n,i){if("string"==typeof t){if("string"==typeof r?(i=r,r=0,n=this.length):"string"==typeof n&&(i=n,n=this.length),void 0!==i&&"string"!=typeof i)throw new TypeError("encoding must be a string");if("string"==typeof i&&!e.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(1===t.length){var s=t.charCodeAt(0);("utf8"===i&&s<128||"latin1"===i)&&(t=s)}}else"number"==typeof t&&(t&=255);if(r<0||this.length>>=0,n=void 0===n?this.length:n>>>0,t||(t=0),"number"==typeof t)for(o=r;o55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&s.push(239,191,189);continue}if(o+1===n){(e-=3)>-1&&s.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&s.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(e-=3)>-1&&s.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;s.push(r)}else if(r<2048){if((e-=2)<0)break;s.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;s.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;s.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return s}function B(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(M,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function R(t,e,r,n){for(var i=0;i=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function P(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function U(t){return t!=t}}).call(this,t("buffer").Buffer)},{"base64-js":1,buffer:3,ieee754:6}],4:[function(t,e,r){(function(t){function e(t){return Object.prototype.toString.call(t)}r.isArray=function(t){return Array.isArray?Array.isArray(t):"[object Array]"===e(t)},r.isBoolean=function(t){return"boolean"==typeof t},r.isNull=function(t){return null===t},r.isNullOrUndefined=function(t){return null==t},r.isNumber=function(t){return"number"==typeof t},r.isString=function(t){return"string"==typeof t},r.isSymbol=function(t){return"symbol"==typeof t},r.isUndefined=function(t){return void 0===t},r.isRegExp=function(t){return"[object RegExp]"===e(t)},r.isObject=function(t){return"object"==typeof t&&null!==t},r.isDate=function(t){return"[object Date]"===e(t)},r.isError=function(t){return"[object Error]"===e(t)||t instanceof Error},r.isFunction=function(t){return"function"==typeof t},r.isPrimitive=function(t){return null===t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||"symbol"==typeof t||void 0===t},r.isBuffer=t.isBuffer}).call(this,{isBuffer:t("../../is-buffer/index.js")})},{"../../is-buffer/index.js":8}],5:[function(t,e,r){var n=Object.create||function(t){var e=function(){};return e.prototype=t,new e},i=Object.keys||function(t){var e=[];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.push(r);return r},s=Function.prototype.bind||function(t){var e=this;return function(){return e.apply(t,arguments)}};function o(){this._events&&Object.prototype.hasOwnProperty.call(this,"_events")||(this._events=n(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0}e.exports=o,o.EventEmitter=o,o.prototype._events=void 0,o.prototype._maxListeners=void 0;var a,u=10;try{var l={};Object.defineProperty&&Object.defineProperty(l,"x",{value:0}),a=0===l.x}catch(t){a=!1}function c(t){return void 0===t._maxListeners?o.defaultMaxListeners:t._maxListeners}function f(t,e,r,i){var s,o,a;if("function"!=typeof r)throw new TypeError('"listener" argument must be a function');if((o=t._events)?(o.newListener&&(t.emit("newListener",e,r.listener?r.listener:r),o=t._events),a=o[e]):(o=t._events=n(null),t._eventsCount=0),a){if("function"==typeof a?a=o[e]=i?[r,a]:[a,r]:i?a.unshift(r):a.push(r),!a.warned&&(s=c(t))&&s>0&&a.length>s){a.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+a.length+' "'+String(e)+'" listeners added. Use emitter.setMaxListeners() to increase limit.');u.name="MaxListenersExceededWarning",u.emitter=t,u.type=e,u.count=a.length,"object"==typeof console&&console.warn&&console.warn("%s: %s",u.name,u.message)}}else a=o[e]=r,++t._eventsCount;return t}function h(){if(!this.fired)switch(this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length){case 0:return this.listener.call(this.target);case 1:return this.listener.call(this.target,arguments[0]);case 2:return this.listener.call(this.target,arguments[0],arguments[1]);case 3:return this.listener.call(this.target,arguments[0],arguments[1],arguments[2]);default:for(var t=new Array(arguments.length),e=0;e1&&(e=arguments[1]),e instanceof Error)throw e;var u=new Error('Unhandled "error" event. ('+e+")");throw u.context=e,u}if(!(r=o[t]))return!1;var l="function"==typeof r;switch(n=arguments.length){case 1:!function(t,e,r){if(e)t.call(r);else for(var n=t.length,i=m(t,n),s=0;s=0;o--)if(r[o]===e||r[o].listener===e){a=r[o].listener,s=o;break}if(s<0)return this;0===s?r.shift():function(t,e){for(var r=e,n=r+1,i=t.length;n=0;s--)this.removeListener(t,e[s]);return this},o.prototype.listeners=function(t){return d(this,t,!0)},o.prototype.rawListeners=function(t){return d(this,t,!1)},o.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):g.call(t,e)},o.prototype.listenerCount=g,o.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]}},{}],6:[function(t,e,r){r.read=function(t,e,r,n,i){var s,o,a=8*i-n-1,u=(1<>1,c=-7,f=r?i-1:0,h=r?-1:1,p=t[e+f];for(f+=h,s=p&(1<<-c)-1,p>>=-c,c+=a;c>0;s=256*s+t[e+f],f+=h,c-=8);for(o=s&(1<<-c)-1,s>>=-c,c+=n;c>0;o=256*o+t[e+f],f+=h,c-=8);if(0===s)s=1-l;else{if(s===u)return o?NaN:1/0*(p?-1:1);o+=Math.pow(2,n),s-=l}return(p?-1:1)*o*Math.pow(2,s-n)},r.write=function(t,e,r,n,i,s){var o,a,u,l=8*s-i-1,c=(1<>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:s-1,d=n?1:-1,g=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,o=c):(o=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-o))<1&&(o--,u*=2),(e+=o+f>=1?h/u:h*Math.pow(2,1-f))*u>=2&&(o++,u/=2),o+f>=c?(a=0,o=c):o+f>=1?(a=(e*u-1)*Math.pow(2,i),o+=f):(a=e*Math.pow(2,f-1)*Math.pow(2,i),o=0));i>=8;t[r+p]=255&a,p+=d,a/=256,i-=8);for(o=o<0;t[r+p]=255&o,p+=d,o/=256,l-=8);t[r+p-d]|=128*g}},{}],7:[function(t,e,r){"function"==typeof Object.create?e.exports=function(t,e){e&&(t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:e.exports=function(t,e){if(e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}}},{}],8:[function(t,e,r){function n(t){return!!t.constructor&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t)}e.exports=function(t){return null!=t&&(n(t)||function(t){return"function"==typeof t.readFloatLE&&"function"==typeof t.slice&&n(t.slice(0,0))}(t)||!!t._isBuffer)}},{}],9:[function(t,e,r){var n={}.toString;e.exports=Array.isArray||function(t){return"[object Array]"==n.call(t)}},{}],10:[function(t,e,r){(function(t){"use strict";void 0===t||!t.version||0===t.version.indexOf("v0.")||0===t.version.indexOf("v1.")&&0!==t.version.indexOf("v1.8.")?e.exports={nextTick:function(e,r,n,i){if("function"!=typeof e)throw new TypeError('"callback" argument must be a function');var s,o,a=arguments.length;switch(a){case 0:case 1:return t.nextTick(e);case 2:return t.nextTick(function(){e.call(null,r)});case 3:return t.nextTick(function(){e.call(null,r,n)});case 4:return t.nextTick(function(){e.call(null,r,n,i)});default:for(s=new Array(a-1),o=0;o1)for(var r=1;r0?("string"==typeof e||o.objectMode||Object.getPrototypeOf(e)===l.prototype||(e=function(t){return l.from(t)}(e)),n?o.endEmitted?t.emit("error",new Error("stream.unshift() after end event")):E(t,o,e,!0):o.ended?t.emit("error",new Error("stream.push() after EOF")):(o.reading=!1,o.decoder&&!r?(e=o.decoder.write(e),o.objectMode||0!==e.length?E(t,o,e,!1):N(t,o)):E(t,o,e,!1))):n||(o.reading=!1));return function(t){return!t.ended&&(t.needReadable||t.lengthe.highWaterMark&&(e.highWaterMark=function(t){return t>=_?t=_:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}function T(t){var e=t._readableState;e.needReadable=!1,e.emittedReadable||(p("emitReadable",e.flowing),e.emittedReadable=!0,e.sync?i.nextTick(A,t):A(t))}function A(t){p("emit readable"),t.emit("readable"),F(t)}function N(t,e){e.readingMore||(e.readingMore=!0,i.nextTick(S,t,e))}function S(t,e){for(var r=e.length;!e.reading&&!e.flowing&&!e.ended&&e.length=e.length?(r=e.decoder?e.buffer.join(""):1===e.buffer.length?e.buffer.head.data:e.buffer.concat(e.length),e.buffer.clear()):r=function(t,e,r){var n;ts.length?s.length:t;if(o===s.length?i+=s:i+=s.slice(0,t),0===(t-=o)){o===s.length?(++n,r.next?e.head=r.next:e.head=e.tail=null):(e.head=r,r.data=s.slice(o));break}++n}return e.length-=n,i}(t,e):function(t,e){var r=l.allocUnsafe(t),n=e.head,i=1;n.data.copy(r),t-=n.data.length;for(;n=n.next;){var s=n.data,o=t>s.length?s.length:t;if(s.copy(r,r.length-t,0,o),0===(t-=o)){o===s.length?(++i,n.next?e.head=n.next:e.head=e.tail=null):(e.head=n,n.data=s.slice(o));break}++i}return e.length-=i,r}(t,e);return n}(t,e.buffer,e.decoder),r);var r}function O(t){var e=t._readableState;if(e.length>0)throw new Error('"endReadable()" called on non-empty stream');e.endEmitted||(e.ended=!0,i.nextTick(L,e,t))}function L(t,e){t.endEmitted||0!==t.length||(t.endEmitted=!0,e.readable=!1,e.emit("end"))}function M(t,e){for(var r=0,n=t.length;r=e.highWaterMark||e.ended))return p("read: emitReadable",e.length,e.ended),0===e.length&&e.ended?O(this):T(this),null;if(0===(t=x(t,e))&&e.ended)return 0===e.length&&O(this),null;var n,i=e.needReadable;return p("need readable",i),(0===e.length||e.length-t0?I(t,e):null)?(e.needReadable=!0,t=0):e.length-=t,0===e.length&&(e.ended||(e.needReadable=!0),r!==t&&e.ended&&O(this)),null!==n&&this.emit("data",n),n},w.prototype._read=function(t){this.emit("error",new Error("_read() is not implemented"))},w.prototype.pipe=function(t,e){var n=this,s=this._readableState;switch(s.pipesCount){case 0:s.pipes=t;break;case 1:s.pipes=[s.pipes,t];break;default:s.pipes.push(t)}s.pipesCount+=1,p("pipe count=%d opts=%j",s.pipesCount,e);var u=(!e||!1!==e.end)&&t!==r.stdout&&t!==r.stderr?c:w;function l(e,r){p("onunpipe"),e===n&&r&&!1===r.hasUnpiped&&(r.hasUnpiped=!0,p("cleanup"),t.removeListener("close",y),t.removeListener("finish",b),t.removeListener("drain",f),t.removeListener("error",m),t.removeListener("unpipe",l),n.removeListener("end",c),n.removeListener("end",w),n.removeListener("data",g),h=!0,!s.awaitDrain||t._writableState&&!t._writableState.needDrain||f())}function c(){p("onend"),t.end()}s.endEmitted?i.nextTick(u):n.once("end",u),t.on("unpipe",l);var f=function(t){return function(){var e=t._readableState;p("pipeOnDrain",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&a(t,"data")&&(e.flowing=!0,F(t))}}(n);t.on("drain",f);var h=!1;var d=!1;function g(e){p("ondata"),d=!1,!1!==t.write(e)||d||((1===s.pipesCount&&s.pipes===t||s.pipesCount>1&&-1!==M(s.pipes,t))&&!h&&(p("false write response, pause",n._readableState.awaitDrain),n._readableState.awaitDrain++,d=!0),n.pause())}function m(e){p("onerror",e),w(),t.removeListener("error",m),0===a(t,"error")&&t.emit("error",e)}function y(){t.removeListener("finish",b),w()}function b(){p("onfinish"),t.removeListener("close",y),w()}function w(){p("unpipe"),n.unpipe(t)}return n.on("data",g),function(t,e,r){if("function"==typeof t.prependListener)return t.prependListener(e,r);t._events&&t._events[e]?o(t._events[e])?t._events[e].unshift(r):t._events[e]=[r,t._events[e]]:t.on(e,r)}(t,"error",m),t.once("close",y),t.once("finish",b),t.emit("pipe",n),s.flowing||(p("pipe resume"),n.resume()),t},w.prototype.unpipe=function(t){var e=this._readableState,r={hasUnpiped:!1};if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes?this:(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit("unpipe",this,r),this);if(!t){var n=e.pipes,i=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var s=0;s-1?i:s.nextTick;b.WritableState=y;var l=t("core-util-is");l.inherits=t("inherits");var c={deprecate:t("util-deprecate")},f=t("./internal/streams/stream"),h=t("safe-buffer").Buffer,p=n.Uint8Array||function(){};var d,g=t("./internal/streams/destroy");function m(){}function y(e,r){a=a||t("./_stream_duplex"),e=e||{};var n=r instanceof a;this.objectMode=!!e.objectMode,n&&(this.objectMode=this.objectMode||!!e.writableObjectMode);var i=e.highWaterMark,l=e.writableHighWaterMark,c=this.objectMode?16:16384;this.highWaterMark=i||0===i?i:n&&(l||0===l)?l:c,this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var f=!1===e.decodeStrings;this.decodeStrings=!f,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(t){!function(t,e){var r=t._writableState,n=r.sync,i=r.writecb;if(function(t){t.writing=!1,t.writecb=null,t.length-=t.writelen,t.writelen=0}(r),e)!function(t,e,r,n,i){--e.pendingcb,r?(s.nextTick(i,n),s.nextTick(T,t,e),t._writableState.errorEmitted=!0,t.emit("error",n)):(i(n),t._writableState.errorEmitted=!0,t.emit("error",n),T(t,e))}(t,r,n,e,i);else{var o=_(r);o||r.corked||r.bufferProcessing||!r.bufferedRequest||E(t,r),n?u(v,t,r,o,i):v(t,r,o,i)}}(r,t)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new o(this)}function b(e){if(a=a||t("./_stream_duplex"),!(d.call(b,this)||this instanceof a))return new b(e);this._writableState=new y(e,this),this.writable=!0,e&&("function"==typeof e.write&&(this._write=e.write),"function"==typeof e.writev&&(this._writev=e.writev),"function"==typeof e.destroy&&(this._destroy=e.destroy),"function"==typeof e.final&&(this._final=e.final)),f.call(this)}function w(t,e,r,n,i,s,o){e.writelen=n,e.writecb=o,e.writing=!0,e.sync=!0,r?t._writev(i,e.onwrite):t._write(i,s,e.onwrite),e.sync=!1}function v(t,e,r,n){r||function(t,e){0===e.length&&e.needDrain&&(e.needDrain=!1,t.emit("drain"))}(t,e),e.pendingcb--,n(),T(t,e)}function E(t,e){e.bufferProcessing=!0;var r=e.bufferedRequest;if(t._writev&&r&&r.next){var n=e.bufferedRequestCount,i=new Array(n),s=e.corkedRequestsFree;s.entry=r;for(var a=0,u=!0;r;)i[a]=r,r.isBuf||(u=!1),r=r.next,a+=1;i.allBuffers=u,w(t,e,!0,e.length,i,"",s.finish),e.pendingcb++,e.lastBufferedRequest=null,s.next?(e.corkedRequestsFree=s.next,s.next=null):e.corkedRequestsFree=new o(e),e.bufferedRequestCount=0}else{for(;r;){var l=r.chunk,c=r.encoding,f=r.callback;if(w(t,e,!1,e.objectMode?1:l.length,l,c,f),r=r.next,e.bufferedRequestCount--,e.writing)break}null===r&&(e.lastBufferedRequest=null)}e.bufferedRequest=r,e.bufferProcessing=!1}function _(t){return t.ending&&0===t.length&&null===t.bufferedRequest&&!t.finished&&!t.writing}function x(t,e){t._final(function(r){e.pendingcb--,r&&t.emit("error",r),e.prefinished=!0,t.emit("prefinish"),T(t,e)})}function T(t,e){var r=_(e);return r&&(!function(t,e){e.prefinished||e.finalCalled||("function"==typeof t._final?(e.pendingcb++,e.finalCalled=!0,s.nextTick(x,t,e)):(e.prefinished=!0,t.emit("prefinish")))}(t,e),0===e.pendingcb&&(e.finished=!0,t.emit("finish"))),r}l.inherits(b,f),y.prototype.getBuffer=function(){for(var t=this.bufferedRequest,e=[];t;)e.push(t),t=t.next;return e},function(){try{Object.defineProperty(y.prototype,"buffer",{get:c.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(t){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(d=Function.prototype[Symbol.hasInstance],Object.defineProperty(b,Symbol.hasInstance,{value:function(t){return!!d.call(this,t)||this===b&&(t&&t._writableState instanceof y)}})):d=function(t){return t instanceof this},b.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},b.prototype.write=function(t,e,r){var n,i=this._writableState,o=!1,a=!i.objectMode&&(n=t,h.isBuffer(n)||n instanceof p);return a&&!h.isBuffer(t)&&(t=function(t){return h.from(t)}(t)),"function"==typeof e&&(r=e,e=null),a?e="buffer":e||(e=i.defaultEncoding),"function"!=typeof r&&(r=m),i.ended?function(t,e){var r=new Error("write after end");t.emit("error",r),s.nextTick(e,r)}(this,r):(a||function(t,e,r,n){var i=!0,o=!1;return null===r?o=new TypeError("May not write null values to stream"):"string"==typeof r||void 0===r||e.objectMode||(o=new TypeError("Invalid non-string/buffer chunk")),o&&(t.emit("error",o),s.nextTick(n,o),i=!1),i}(this,i,t,r))&&(i.pendingcb++,o=function(t,e,r,n,i,s){if(!r){var o=function(t,e,r){t.objectMode||!1===t.decodeStrings||"string"!=typeof e||(e=h.from(e,r));return e}(e,n,i);n!==o&&(r=!0,i="buffer",n=o)}var a=e.objectMode?1:n.length;e.length+=a;var u=e.length-1))throw new TypeError("Unknown encoding: "+t);return this._writableState.defaultEncoding=t,this},Object.defineProperty(b.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),b.prototype._write=function(t,e,r){r(new Error("_write() is not implemented"))},b.prototype._writev=null,b.prototype.end=function(t,e,r){var n=this._writableState;"function"==typeof t?(r=t,t=null,e=null):"function"==typeof e&&(r=e,e=null),null!==t&&void 0!==t&&this.write(t,e),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(t,e,r){e.ending=!0,T(t,e),r&&(e.finished?s.nextTick(r):t.once("finish",r));e.ended=!0,t.writable=!1}(this,n,r)},Object.defineProperty(b.prototype,"destroyed",{get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}}),b.prototype.destroy=g.destroy,b.prototype._undestroy=g.undestroy,b.prototype._destroy=function(t,e){this.end(),e(t)}}).call(this,t("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},t("timers").setImmediate)},{"./_stream_duplex":13,"./internal/streams/destroy":19,"./internal/streams/stream":20,_process:11,"core-util-is":4,inherits:7,"process-nextick-args":10,"safe-buffer":25,timers:29,"util-deprecate":30}],18:[function(t,e,r){"use strict";var n=t("safe-buffer").Buffer,i=t("util");e.exports=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.head=null,this.tail=null,this.length=0}return t.prototype.push=function(t){var e={data:t,next:null};this.length>0?this.tail.next=e:this.head=e,this.tail=e,++this.length},t.prototype.unshift=function(t){var e={data:t,next:this.head};0===this.length&&(this.tail=e),this.head=e,++this.length},t.prototype.shift=function(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}},t.prototype.clear=function(){this.head=this.tail=null,this.length=0},t.prototype.join=function(t){if(0===this.length)return"";for(var e=this.head,r=""+e.data;e=e.next;)r+=t+e.data;return r},t.prototype.concat=function(t){if(0===this.length)return n.alloc(0);if(1===this.length)return this.head.data;for(var e,r,i,s=n.allocUnsafe(t>>>0),o=this.head,a=0;o;)e=o.data,r=s,i=a,e.copy(r,i),a+=o.data.length,o=o.next;return s},t}(),i&&i.inspect&&i.inspect.custom&&(e.exports.prototype[i.inspect.custom]=function(){var t=i.inspect({length:this.length});return this.constructor.name+" "+t})},{"safe-buffer":25,util:2}],19:[function(t,e,r){"use strict";var n=t("process-nextick-args");function i(t,e){t.emit("error",e)}e.exports={destroy:function(t,e){var r=this,s=this._readableState&&this._readableState.destroyed,o=this._writableState&&this._writableState.destroyed;return s||o?(e?e(t):!t||this._writableState&&this._writableState.errorEmitted||n.nextTick(i,this,t),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(t||null,function(t){!e&&t?(n.nextTick(i,r,t),r._writableState&&(r._writableState.errorEmitted=!0)):e&&e(t)}),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}}},{"process-nextick-args":10}],20:[function(t,e,r){e.exports=t("events").EventEmitter},{events:5}],21:[function(t,e,r){e.exports=t("./readable").PassThrough},{"./readable":22}],22:[function(t,e,r){(r=e.exports=t("./lib/_stream_readable.js")).Stream=r,r.Readable=r,r.Writable=t("./lib/_stream_writable.js"),r.Duplex=t("./lib/_stream_duplex.js"),r.Transform=t("./lib/_stream_transform.js"),r.PassThrough=t("./lib/_stream_passthrough.js")},{"./lib/_stream_duplex.js":13,"./lib/_stream_passthrough.js":14,"./lib/_stream_readable.js":15,"./lib/_stream_transform.js":16,"./lib/_stream_writable.js":17}],23:[function(t,e,r){e.exports=t("./readable").Transform},{"./readable":22}],24:[function(t,e,r){e.exports=t("./lib/_stream_writable.js")},{"./lib/_stream_writable.js":17}],25:[function(t,e,r){var n=t("buffer"),i=n.Buffer;function s(t,e){for(var r in t)e[r]=t[r]}function o(t,e,r){return i(t,e,r)}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?e.exports=n:(s(n,r),r.Buffer=o),s(i,o),o.from=function(t,e,r){if("number"==typeof t)throw new TypeError("Argument must not be a number");return i(t,e,r)},o.alloc=function(t,e,r){if("number"!=typeof t)throw new TypeError("Argument must be a number");var n=i(t);return void 0!==e?"string"==typeof r?n.fill(e,r):n.fill(e):n.fill(0),n},o.allocUnsafe=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return i(t)},o.allocUnsafeSlow=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return n.SlowBuffer(t)}},{buffer:3}],26:[function(t,e,r){(function(e){!function(r){r.parser=function(t,e){return new s(t,e)},r.SAXParser=s,r.SAXStream=a,r.createStream=function(t,e){return new a(t,e)},r.MAX_BUFFER_LENGTH=65536;var n,i=["comment","sgmlDecl","textNode","tagName","doctype","procInstName","procInstBody","entity","attribName","attribValue","cdata","script"];function s(t,e){if(!(this instanceof s))return new s(t,e);!function(t){for(var e=0,r=i.length;e"===n?(C(this,"onsgmldeclaration",this.sgmlDecl),this.sgmlDecl="",this.state=A.TEXT):b(n)?(this.state=A.SGML_DECL_QUOTED,this.sgmlDecl+=n):this.sgmlDecl+=n;continue;case A.SGML_DECL_QUOTED:n===this.q&&(this.state=A.SGML_DECL,this.q=""),this.sgmlDecl+=n;continue;case A.DOCTYPE:">"===n?(this.state=A.TEXT,C(this,"ondoctype",this.doctype),this.doctype=!0):(this.doctype+=n,"["===n?this.state=A.DOCTYPE_DTD:b(n)&&(this.state=A.DOCTYPE_QUOTED,this.q=n));continue;case A.DOCTYPE_QUOTED:this.doctype+=n,n===this.q&&(this.q="",this.state=A.DOCTYPE);continue;case A.DOCTYPE_DTD:this.doctype+=n,"]"===n?this.state=A.DOCTYPE:b(n)&&(this.state=A.DOCTYPE_DTD_QUOTED,this.q=n);continue;case A.DOCTYPE_DTD_QUOTED:this.doctype+=n,n===this.q&&(this.state=A.DOCTYPE_DTD,this.q="");continue;case A.COMMENT:"-"===n?this.state=A.COMMENT_ENDING:this.comment+=n;continue;case A.COMMENT_ENDING:"-"===n?(this.state=A.COMMENT_ENDED,this.comment=F(this.opt,this.comment),this.comment&&C(this,"oncomment",this.comment),this.comment=""):(this.comment+="-"+n,this.state=A.COMMENT);continue;case A.COMMENT_ENDED:">"!==n?(L(this,"Malformed comment"),this.comment+="--"+n,this.state=A.COMMENT):this.state=A.TEXT;continue;case A.CDATA:"]"===n?this.state=A.CDATA_ENDING:this.cdata+=n;continue;case A.CDATA_ENDING:"]"===n?this.state=A.CDATA_ENDING_2:(this.cdata+="]"+n,this.state=A.CDATA);continue;case A.CDATA_ENDING_2:">"===n?(this.cdata&&C(this,"oncdata",this.cdata),C(this,"onclosecdata"),this.cdata="",this.state=A.TEXT):"]"===n?this.cdata+="]":(this.cdata+="]]"+n,this.state=A.CDATA);continue;case A.PROC_INST:"?"===n?this.state=A.PROC_INST_ENDING:y(n)?this.state=A.PROC_INST_BODY:this.procInstName+=n;continue;case A.PROC_INST_BODY:if(!this.procInstBody&&y(n))continue;"?"===n?this.state=A.PROC_INST_ENDING:this.procInstBody+=n;continue;case A.PROC_INST_ENDING:">"===n?(C(this,"onprocessinginstruction",{name:this.procInstName,body:this.procInstBody}),this.procInstName=this.procInstBody="",this.state=A.TEXT):(this.procInstBody+="?"+n,this.state=A.PROC_INST_BODY);continue;case A.OPEN_TAG:v(d,n)?this.tagName+=n:(M(this),">"===n?B(this):"/"===n?this.state=A.OPEN_TAG_SLASH:(y(n)||L(this,"Invalid character in tag name"),this.state=A.ATTRIB));continue;case A.OPEN_TAG_SLASH:">"===n?(B(this,!0),R(this)):(L(this,"Forward-slash in opening tag not followed by >"),this.state=A.ATTRIB);continue;case A.ATTRIB:if(y(n))continue;">"===n?B(this):"/"===n?this.state=A.OPEN_TAG_SLASH:v(p,n)?(this.attribName=n,this.attribValue="",this.state=A.ATTRIB_NAME):L(this,"Invalid attribute name");continue;case A.ATTRIB_NAME:"="===n?this.state=A.ATTRIB_VALUE:">"===n?(L(this,"Attribute without value"),this.attribValue=this.attribName,j(this),B(this)):y(n)?this.state=A.ATTRIB_NAME_SAW_WHITE:v(d,n)?this.attribName+=n:L(this,"Invalid attribute name");continue;case A.ATTRIB_NAME_SAW_WHITE:if("="===n)this.state=A.ATTRIB_VALUE;else{if(y(n))continue;L(this,"Attribute without value"),this.tag.attributes[this.attribName]="",this.attribValue="",C(this,"onattribute",{name:this.attribName,value:""}),this.attribName="",">"===n?B(this):v(p,n)?(this.attribName=n,this.state=A.ATTRIB_NAME):(L(this,"Invalid attribute name"),this.state=A.ATTRIB)}continue;case A.ATTRIB_VALUE:if(y(n))continue;b(n)?(this.q=n,this.state=A.ATTRIB_VALUE_QUOTED):(L(this,"Unquoted attribute value"),this.state=A.ATTRIB_VALUE_UNQUOTED,this.attribValue=n);continue;case A.ATTRIB_VALUE_QUOTED:if(n!==this.q){"&"===n?this.state=A.ATTRIB_VALUE_ENTITY_Q:this.attribValue+=n;continue}j(this),this.q="",this.state=A.ATTRIB_VALUE_CLOSED;continue;case A.ATTRIB_VALUE_CLOSED:y(n)?this.state=A.ATTRIB:">"===n?B(this):"/"===n?this.state=A.OPEN_TAG_SLASH:v(p,n)?(L(this,"No whitespace between attributes"),this.attribName=n,this.attribValue="",this.state=A.ATTRIB_NAME):L(this,"Invalid attribute name");continue;case A.ATTRIB_VALUE_UNQUOTED:if(!w(n)){"&"===n?this.state=A.ATTRIB_VALUE_ENTITY_U:this.attribValue+=n;continue}j(this),">"===n?B(this):this.state=A.ATTRIB;continue;case A.CLOSE_TAG:if(this.tagName)">"===n?R(this):v(d,n)?this.tagName+=n:this.script?(this.script+=""===n?R(this):L(this,"Invalid characters in closing tag");continue;case A.TEXT_ENTITY:case A.ATTRIB_VALUE_ENTITY_Q:case A.ATTRIB_VALUE_ENTITY_U:var a,c;switch(this.state){case A.TEXT_ENTITY:a=A.TEXT,c="textNode";break;case A.ATTRIB_VALUE_ENTITY_Q:a=A.ATTRIB_VALUE_QUOTED,c="attribValue";break;case A.ATTRIB_VALUE_ENTITY_U:a=A.ATTRIB_VALUE_UNQUOTED,c="attribValue"}";"===n?(this[c]+=P(this),this.entity="",this.state=a):v(this.entity.length?m:g,n)?this.entity+=n:(L(this,"Invalid character in entity name"),this[c]+="&"+this.entity+n,this.entity="",this.state=a);continue;default:throw new Error(this,"Unknown state: "+this.state)}this.position>=this.bufferCheckPosition&&function(t){for(var e=Math.max(r.MAX_BUFFER_LENGTH,10),n=0,s=0,o=i.length;se)switch(i[s]){case"textNode":k(t);break;case"cdata":C(t,"oncdata",t.cdata),t.cdata="";break;case"script":C(t,"onscript",t.script),t.script="";break;default:I(t,"Max buffer length exceeded: "+i[s])}n=Math.max(n,a)}var u=r.MAX_BUFFER_LENGTH-n;t.bufferCheckPosition=u+t.position}(this);return this},resume:function(){return this.error=null,this},close:function(){return this.write(null)},flush:function(){var t;k(t=this),""!==t.cdata&&(C(t,"oncdata",t.cdata),t.cdata=""),""!==t.script&&(C(t,"onscript",t.script),t.script="")}};try{n=t("stream").Stream}catch(t){n=function(){}}var o=r.EVENTS.filter(function(t){return"error"!==t&&"end"!==t});function a(t,e){if(!(this instanceof a))return new a(t,e);n.apply(this),this._parser=new s(t,e),this.writable=!0,this.readable=!0;var r=this;this._parser.onend=function(){r.emit("end")},this._parser.onerror=function(t){r.emit("error",t),r._parser.error=null},this._decoder=null,o.forEach(function(t){Object.defineProperty(r,"on"+t,{get:function(){return r._parser["on"+t]},set:function(e){if(!e)return r.removeAllListeners(t),r._parser["on"+t]=e,e;r.on(t,e)},enumerable:!0,configurable:!1})})}a.prototype=Object.create(n.prototype,{constructor:{value:a}}),a.prototype.write=function(r){if("function"==typeof e&&"function"==typeof e.isBuffer&&e.isBuffer(r)){if(!this._decoder){var n=t("string_decoder").StringDecoder;this._decoder=new n("utf8")}r=this._decoder.write(r)}return this._parser.write(r.toString()),this.emit("data",r),!0},a.prototype.end=function(t){return t&&t.length&&this.write(t),this._parser.end(),!0},a.prototype.on=function(t,e){var r=this;return r._parser["on"+t]||-1===o.indexOf(t)||(r._parser["on"+t]=function(){var e=1===arguments.length?[arguments[0]]:Array.apply(null,arguments);e.splice(0,0,t),r.emit.apply(r,e)}),n.prototype.on.call(r,t,e)};var u="[CDATA[",l="DOCTYPE",c="http://www.w3.org/XML/1998/namespace",f="http://www.w3.org/2000/xmlns/",h={xml:c,xmlns:f},p=/[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,d=/[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/,g=/[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,m=/[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/;function y(t){return" "===t||"\n"===t||"\r"===t||"\t"===t}function b(t){return'"'===t||"'"===t}function w(t){return">"===t||y(t)}function v(t,e){return t.test(e)}function E(t,e){return!v(t,e)}var _,x,T,A=0;for(var N in r.STATE={BEGIN:A++,BEGIN_WHITESPACE:A++,TEXT:A++,TEXT_ENTITY:A++,OPEN_WAKA:A++,SGML_DECL:A++,SGML_DECL_QUOTED:A++,DOCTYPE:A++,DOCTYPE_QUOTED:A++,DOCTYPE_DTD:A++,DOCTYPE_DTD_QUOTED:A++,COMMENT_STARTING:A++,COMMENT:A++,COMMENT_ENDING:A++,COMMENT_ENDED:A++,CDATA:A++,CDATA_ENDING:A++,CDATA_ENDING_2:A++,PROC_INST:A++,PROC_INST_BODY:A++,PROC_INST_ENDING:A++,OPEN_TAG:A++,OPEN_TAG_SLASH:A++,ATTRIB:A++,ATTRIB_NAME:A++,ATTRIB_NAME_SAW_WHITE:A++,ATTRIB_VALUE:A++,ATTRIB_VALUE_QUOTED:A++,ATTRIB_VALUE_CLOSED:A++,ATTRIB_VALUE_UNQUOTED:A++,ATTRIB_VALUE_ENTITY_Q:A++,ATTRIB_VALUE_ENTITY_U:A++,CLOSE_TAG:A++,CLOSE_TAG_SAW_WHITE:A++,SCRIPT:A++,SCRIPT_ENDING:A++},r.XML_ENTITIES={amp:"&",gt:">",lt:"<",quot:'"',apos:"'"},r.ENTITIES={amp:"&",gt:">",lt:"<",quot:'"',apos:"'",AElig:198,Aacute:193,Acirc:194,Agrave:192,Aring:197,Atilde:195,Auml:196,Ccedil:199,ETH:208,Eacute:201,Ecirc:202,Egrave:200,Euml:203,Iacute:205,Icirc:206,Igrave:204,Iuml:207,Ntilde:209,Oacute:211,Ocirc:212,Ograve:210,Oslash:216,Otilde:213,Ouml:214,THORN:222,Uacute:218,Ucirc:219,Ugrave:217,Uuml:220,Yacute:221,aacute:225,acirc:226,aelig:230,agrave:224,aring:229,atilde:227,auml:228,ccedil:231,eacute:233,ecirc:234,egrave:232,eth:240,euml:235,iacute:237,icirc:238,igrave:236,iuml:239,ntilde:241,oacute:243,ocirc:244,ograve:242,oslash:248,otilde:245,ouml:246,szlig:223,thorn:254,uacute:250,ucirc:251,ugrave:249,uuml:252,yacute:253,yuml:255,copy:169,reg:174,nbsp:160,iexcl:161,cent:162,pound:163,curren:164,yen:165,brvbar:166,sect:167,uml:168,ordf:170,laquo:171,not:172,shy:173,macr:175,deg:176,plusmn:177,sup1:185,sup2:178,sup3:179,acute:180,micro:181,para:182,middot:183,cedil:184,ordm:186,raquo:187,frac14:188,frac12:189,frac34:190,iquest:191,times:215,divide:247,OElig:338,oelig:339,Scaron:352,scaron:353,Yuml:376,fnof:402,circ:710,tilde:732,Alpha:913,Beta:914,Gamma:915,Delta:916,Epsilon:917,Zeta:918,Eta:919,Theta:920,Iota:921,Kappa:922,Lambda:923,Mu:924,Nu:925,Xi:926,Omicron:927,Pi:928,Rho:929,Sigma:931,Tau:932,Upsilon:933,Phi:934,Chi:935,Psi:936,Omega:937,alpha:945,beta:946,gamma:947,delta:948,epsilon:949,zeta:950,eta:951,theta:952,iota:953,kappa:954,lambda:955,mu:956,nu:957,xi:958,omicron:959,pi:960,rho:961,sigmaf:962,sigma:963,tau:964,upsilon:965,phi:966,chi:967,psi:968,omega:969,thetasym:977,upsih:978,piv:982,ensp:8194,emsp:8195,thinsp:8201,zwnj:8204,zwj:8205,lrm:8206,rlm:8207,ndash:8211,mdash:8212,lsquo:8216,rsquo:8217,sbquo:8218,ldquo:8220,rdquo:8221,bdquo:8222,dagger:8224,Dagger:8225,bull:8226,hellip:8230,permil:8240,prime:8242,Prime:8243,lsaquo:8249,rsaquo:8250,oline:8254,frasl:8260,euro:8364,image:8465,weierp:8472,real:8476,trade:8482,alefsym:8501,larr:8592,uarr:8593,rarr:8594,darr:8595,harr:8596,crarr:8629,lArr:8656,uArr:8657,rArr:8658,dArr:8659,hArr:8660,forall:8704,part:8706,exist:8707,empty:8709,nabla:8711,isin:8712,notin:8713,ni:8715,prod:8719,sum:8721,minus:8722,lowast:8727,radic:8730,prop:8733,infin:8734,ang:8736,and:8743,or:8744,cap:8745,cup:8746,int:8747,there4:8756,sim:8764,cong:8773,asymp:8776,ne:8800,equiv:8801,le:8804,ge:8805,sub:8834,sup:8835,nsub:8836,sube:8838,supe:8839,oplus:8853,otimes:8855,perp:8869,sdot:8901,lceil:8968,rceil:8969,lfloor:8970,rfloor:8971,lang:9001,rang:9002,loz:9674,spades:9824,clubs:9827,hearts:9829,diams:9830},Object.keys(r.ENTITIES).forEach(function(t){var e=r.ENTITIES[t],n="number"==typeof e?String.fromCharCode(e):e;r.ENTITIES[t]=n}),r.STATE)r.STATE[r.STATE[N]]=N;function S(t,e,r){t[e]&&t[e](r)}function C(t,e,r){t.textNode&&k(t),S(t,e,r)}function k(t){t.textNode=F(t.opt,t.textNode),t.textNode&&S(t,"ontext",t.textNode),t.textNode=""}function F(t,e){return t.trim&&(e=e.trim()),t.normalize&&(e=e.replace(/\s+/g," ")),e}function I(t,e){return k(t),t.trackPosition&&(e+="\nLine: "+t.line+"\nColumn: "+t.column+"\nChar: "+t.c),e=new Error(e),t.error=e,S(t,"onerror",e),t}function O(t){return t.sawRoot&&!t.closedRoot&&L(t,"Unclosed root tag"),t.state!==A.BEGIN&&t.state!==A.BEGIN_WHITESPACE&&t.state!==A.TEXT&&I(t,"Unexpected end"),k(t),t.c="",t.closed=!0,S(t,"onend"),s.call(t,t.strict,t.opt),t}function L(t,e){if("object"!=typeof t||!(t instanceof s))throw new Error("bad call to strictFail");t.strict&&I(t,e)}function M(t){t.strict||(t.tagName=t.tagName[t.looseCase]());var e=t.tags[t.tags.length-1]||t,r=t.tag={name:t.tagName,attributes:{}};t.opt.xmlns&&(r.ns=e.ns),t.attribList.length=0,C(t,"onopentagstart",r)}function D(t,e){var r=t.indexOf(":")<0?["",t]:t.split(":"),n=r[0],i=r[1];return e&&"xmlns"===t&&(n="xmlns",i=""),{prefix:n,local:i}}function j(t){if(t.strict||(t.attribName=t.attribName[t.looseCase]()),-1!==t.attribList.indexOf(t.attribName)||t.tag.attributes.hasOwnProperty(t.attribName))t.attribName=t.attribValue="";else{if(t.opt.xmlns){var e=D(t.attribName,!0),r=e.prefix,n=e.local;if("xmlns"===r)if("xml"===n&&t.attribValue!==c)L(t,"xml: prefix must be bound to "+c+"\nActual: "+t.attribValue);else if("xmlns"===n&&t.attribValue!==f)L(t,"xmlns: prefix must be bound to "+f+"\nActual: "+t.attribValue);else{var i=t.tag,s=t.tags[t.tags.length-1]||t;i.ns===s.ns&&(i.ns=Object.create(s.ns)),i.ns[n]=t.attribValue}t.attribList.push([t.attribName,t.attribValue])}else t.tag.attributes[t.attribName]=t.attribValue,C(t,"onattribute",{name:t.attribName,value:t.attribValue});t.attribName=t.attribValue=""}}function B(t,e){if(t.opt.xmlns){var r=t.tag,n=D(t.tagName);r.prefix=n.prefix,r.local=n.local,r.uri=r.ns[n.prefix]||"",r.prefix&&!r.uri&&(L(t,"Unbound namespace prefix: "+JSON.stringify(t.tagName)),r.uri=n.prefix);var i=t.tags[t.tags.length-1]||t;r.ns&&i.ns!==r.ns&&Object.keys(r.ns).forEach(function(e){C(t,"onopennamespace",{prefix:e,uri:r.ns[e]})});for(var s=0,o=t.attribList.length;s",t.tagName="",void(t.state=A.SCRIPT);C(t,"onscript",t.script),t.script=""}var e=t.tags.length,r=t.tagName;t.strict||(r=r[t.looseCase]());for(var n=r;e--;){if(t.tags[e].name===n)break;L(t,"Unexpected close tag")}if(e<0)return L(t,"Unmatched closing tag: "+t.tagName),t.textNode+="",void(t.state=A.TEXT);t.tagName=r;for(var i=t.tags.length;i-- >e;){var s=t.tag=t.tags.pop();t.tagName=t.tag.name,C(t,"onclosetag",t.tagName);var o={};for(var a in s.ns)o[a]=s.ns[a];var u=t.tags[t.tags.length-1]||t;t.opt.xmlns&&s.ns!==u.ns&&Object.keys(s.ns).forEach(function(e){var r=s.ns[e];C(t,"onclosenamespace",{prefix:e,uri:r})})}0===e&&(t.closedRoot=!0),t.tagName=t.attribValue=t.attribName="",t.attribList.length=0,t.state=A.TEXT}function P(t){var e,r=t.entity,n=r.toLowerCase(),i="";return t.ENTITIES[r]?t.ENTITIES[r]:t.ENTITIES[n]?t.ENTITIES[n]:("#"===(r=n).charAt(0)&&("x"===r.charAt(1)?(r=r.slice(2),i=(e=parseInt(r,16)).toString(16)):(r=r.slice(1),i=(e=parseInt(r,10)).toString(10))),r=r.replace(/^0+/,""),isNaN(e)||i.toLowerCase()!==r?(L(t,"Invalid character entity"),"&"+t.entity+";"):String.fromCodePoint(e))}function U(t,e){"<"===e?(t.state=A.OPEN_WAKA,t.startTagPosition=t.position):y(e)||(L(t,"Non-whitespace before first tag."),t.textNode=e,t.state=A.TEXT)}function K(t,e){var r="";return e1114111||x(o)!==o)throw RangeError("Invalid code point: "+o);o<=65535?r.push(o):(t=55296+((o-=65536)>>10),e=o%1024+56320,r.push(t,e)),(n+1===i||r.length>16384)&&(s+=_.apply(null,r),r.length=0)}return s},Object.defineProperty?Object.defineProperty(String,"fromCodePoint",{value:T,configurable:!0,writable:!0}):String.fromCodePoint=T)}(void 0===r?this.sax={}:r)}).call(this,t("buffer").Buffer)},{buffer:3,stream:27,string_decoder:28}],27:[function(t,e,r){e.exports=i;var n=t("events").EventEmitter;function i(){n.call(this)}t("inherits")(i,n),i.Readable=t("readable-stream/readable.js"),i.Writable=t("readable-stream/writable.js"),i.Duplex=t("readable-stream/duplex.js"),i.Transform=t("readable-stream/transform.js"),i.PassThrough=t("readable-stream/passthrough.js"),i.Stream=i,i.prototype.pipe=function(t,e){var r=this;function i(e){t.writable&&!1===t.write(e)&&r.pause&&r.pause()}function s(){r.readable&&r.resume&&r.resume()}r.on("data",i),t.on("drain",s),t._isStdio||e&&!1===e.end||(r.on("end",a),r.on("close",u));var o=!1;function a(){o||(o=!0,t.end())}function u(){o||(o=!0,"function"==typeof t.destroy&&t.destroy())}function l(t){if(c(),0===n.listenerCount(this,"error"))throw t}function c(){r.removeListener("data",i),t.removeListener("drain",s),r.removeListener("end",a),r.removeListener("close",u),r.removeListener("error",l),t.removeListener("error",l),r.removeListener("end",c),r.removeListener("close",c),t.removeListener("close",c)}return r.on("error",l),t.on("error",l),r.on("end",c),r.on("close",c),t.on("close",c),t.emit("pipe",r),t}},{events:5,inherits:7,"readable-stream/duplex.js":12,"readable-stream/passthrough.js":21,"readable-stream/readable.js":22,"readable-stream/transform.js":23,"readable-stream/writable.js":24}],28:[function(t,e,r){"use strict";var n=t("safe-buffer").Buffer,i=n.isEncoding||function(t){switch((t=""+t)&&t.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function s(t){var e;switch(this.encoding=function(t){var e=function(t){if(!t)return"utf8";for(var e;;)switch(t){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return t;default:if(e)return;t=(""+t).toLowerCase(),e=!0}}(t);if("string"!=typeof e&&(n.isEncoding===i||!i(t)))throw new Error("Unknown encoding: "+t);return e||t}(t),this.encoding){case"utf16le":this.text=u,this.end=l,e=4;break;case"utf8":this.fillLast=a,e=4;break;case"base64":this.text=c,this.end=f,e=3;break;default:return this.write=h,void(this.end=p)}this.lastNeed=0,this.lastTotal=0,this.lastChar=n.allocUnsafe(e)}function o(t){return t<=127?0:t>>5==6?2:t>>4==14?3:t>>3==30?4:t>>6==2?-1:-2}function a(t){var e=this.lastTotal-this.lastNeed,r=function(t,e,r){if(128!=(192&e[0]))return t.lastNeed=0,"�";if(t.lastNeed>1&&e.length>1){if(128!=(192&e[1]))return t.lastNeed=1,"�";if(t.lastNeed>2&&e.length>2&&128!=(192&e[2]))return t.lastNeed=2,"�"}}(this,t);return void 0!==r?r:this.lastNeed<=t.length?(t.copy(this.lastChar,e,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(t.copy(this.lastChar,e,0,t.length),void(this.lastNeed-=t.length))}function u(t,e){if((t.length-e)%2==0){var r=t.toString("utf16le",e);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=t[t.length-1],t.toString("utf16le",e,t.length-1)}function l(t){var e=t&&t.length?this.write(t):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return e+this.lastChar.toString("utf16le",0,r)}return e}function c(t,e){var r=(t.length-e)%3;return 0===r?t.toString("base64",e):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=t[t.length-1]:(this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1]),t.toString("base64",e,t.length-r))}function f(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+this.lastChar.toString("base64",0,3-this.lastNeed):e}function h(t){return t.toString(this.encoding)}function p(t){return t&&t.length?this.write(t):""}r.StringDecoder=s,s.prototype.write=function(t){if(0===t.length)return"";var e,r;if(this.lastNeed){if(void 0===(e=this.fillLast(t)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r=0)return i>0&&(t.lastNeed=i-1),i;if(--n=0)return i>0&&(t.lastNeed=i-2),i;if(--n=0)return i>0&&(2===i?i=0:t.lastNeed=i-3),i;return 0}(this,t,e);if(!this.lastNeed)return t.toString("utf8",e);this.lastTotal=r;var n=t.length-(r-this.lastNeed);return t.copy(this.lastChar,0,n),t.toString("utf8",e,n)},s.prototype.fillLast=function(t){if(this.lastNeed<=t.length)return t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,t.length),this.lastNeed-=t.length}},{"safe-buffer":25}],29:[function(t,e,r){(function(e,n){var i=t("process/browser.js").nextTick,s=Function.prototype.apply,o=Array.prototype.slice,a={},u=0;function l(t,e){this._id=t,this._clearFn=e}r.setTimeout=function(){return new l(s.call(setTimeout,window,arguments),clearTimeout)},r.setInterval=function(){return new l(s.call(setInterval,window,arguments),clearInterval)},r.clearTimeout=r.clearInterval=function(t){t.close()},l.prototype.unref=l.prototype.ref=function(){},l.prototype.close=function(){this._clearFn.call(window,this._id)},r.enroll=function(t,e){clearTimeout(t._idleTimeoutId),t._idleTimeout=e},r.unenroll=function(t){clearTimeout(t._idleTimeoutId),t._idleTimeout=-1},r._unrefActive=r.active=function(t){clearTimeout(t._idleTimeoutId);var e=t._idleTimeout;e>=0&&(t._idleTimeoutId=setTimeout(function(){t._onTimeout&&t._onTimeout()},e))},r.setImmediate="function"==typeof e?e:function(t){var e=u++,n=!(arguments.length<2)&&o.call(arguments,1);return a[e]=!0,i(function(){a[e]&&(n?t.apply(null,n):t.call(null),r.clearImmediate(e))}),e},r.clearImmediate="function"==typeof n?n:function(t){delete a[t]}}).call(this,t("timers").setImmediate,t("timers").clearImmediate)},{"process/browser.js":11,timers:29}],30:[function(t,e,r){(function(t){function r(e){try{if(!t.localStorage)return!1}catch(t){return!1}var r=t.localStorage[e];return null!=r&&"true"===String(r).toLowerCase()}e.exports=function(t,e){if(r("noDeprecation"))return t;var n=!1;return function(){if(!n){if(r("throwDeprecation"))throw new Error(e);r("traceDeprecation")?console.trace(e):console.warn(e),n=!0}return t.apply(this,arguments)}}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],31:[function(t,e,r){e.exports={isArray:function(t){return Array.isArray?Array.isArray(t):"[object Array]"===Object.prototype.toString.call(t)}}},{}],32:[function(t,e,r){var n=t("./xml2js"),i=t("./xml2json"),s=t("./js2xml"),o=t("./json2xml");e.exports={xml2js:n,xml2json:i,js2xml:s,json2xml:o}},{"./js2xml":33,"./json2xml":34,"./xml2js":36,"./xml2json":37}],33:[function(t,e,r){var n,i,s=t("./options-helper"),o=t("./array-helper").isArray;function a(t,e,r){return(!r&&t.spaces?"\n":"")+Array(e+1).join(t.spaces)}function u(t,e,r){if(e.ignoreAttributes)return"";"attributesFn"in e&&(t=e.attributesFn(t,i,n));var s,o,u,l,c=[];for(s in t)t.hasOwnProperty(s)&&null!==t[s]&&void 0!==t[s]&&(l=e.noQuotesForNativeAttributes&&"string"!=typeof t[s]?"":'"',o=(o=""+t[s]).replace(/"/g,"""),u="attributeNameFn"in e?e.attributeNameFn(s,o,i,n):s,c.push(e.spaces&&e.indentAttributes?a(e,r+1,!1):" "),c.push(u+"="+l+("attributeValueFn"in e?e.attributeValueFn(o,s,i,n):o)+l));return t&&Object.keys(t).length&&e.spaces&&e.indentAttributes&&c.push(a(e,r,!1)),c.join("")}function l(t,e,r){return n=t,i="xml",e.ignoreDeclaration?"":""}function c(t,e,r){if(e.ignoreInstruction)return"";var s;for(s in t)if(t.hasOwnProperty(s))break;var o="instructionNameFn"in e?e.instructionNameFn(s,t[s],i,n):s;if("object"==typeof t[s])return n=t,i=o,"";var a=t[s]?t[s]:"";return"instructionFn"in e&&(a=e.instructionFn(a,s,i,n)),""}function f(t,e){return e.ignoreComment?"":"\x3c!--"+("commentFn"in e?e.commentFn(t,i,n):t)+"--\x3e"}function h(t,e){return e.ignoreCdata?"":"","]]]]>"))+"]]>"}function p(t,e){return e.ignoreDoctype?"":""}function d(t,e){return e.ignoreText?"":(t=(t=(t=""+t).replace(/&/g,"&")).replace(/&/g,"&").replace(//g,">"),"textFn"in e?e.textFn(t,i,n):t)}function g(t,e,r,s){return t.reduce(function(t,o){var l=a(e,r,s&&!t);switch(o.type){case"element":return t+l+function(t,e,r){n=t,i=t.name;var s=[],o="elementNameFn"in e?e.elementNameFn(t.name,t):t.name;s.push("<"+o),t[e.attributesKey]&&s.push(u(t[e.attributesKey],e,r));var a=t[e.elementsKey]&&t[e.elementsKey].length||t[e.attributesKey]&&"preserve"===t[e.attributesKey]["xml:space"];return a||(a="fullTagEmptyElementFn"in e?e.fullTagEmptyElementFn(t.name,t):e.fullTagEmptyElement),a?(s.push(">"),t[e.elementsKey]&&t[e.elementsKey].length&&(s.push(g(t[e.elementsKey],e,r+1)),n=t,i=t.name),s.push(e.spaces&&function(t,e){var r;if(t.elements&&t.elements.length)for(r=0;r")):s.push("/>"),s.join("")}(o,e,r);case"comment":return t+l+f(o[e.commentKey],e);case"doctype":return t+l+p(o[e.doctypeKey],e);case"cdata":return t+(e.indentCdata?l:"")+h(o[e.cdataKey],e);case"text":return t+(e.indentText?l:"")+d(o[e.textKey],e);case"instruction":var m={};return m[o[e.nameKey]]=o[e.attributesKey]?o:o[e.instructionKey],t+(e.indentInstruction?l:"")+c(m,e,r)}},"")}function m(t,e,r){var n;for(n in t)if(t.hasOwnProperty(n))switch(n){case e.parentKey:case e.attributesKey:break;case e.textKey:if(e.indentText||r)return!0;break;case e.cdataKey:if(e.indentCdata||r)return!0;break;case e.instructionKey:if(e.indentInstruction||r)return!0;break;case e.doctypeKey:case e.commentKey:default:return!0}return!1}function y(t,e,r,s,o){n=t,i=e;var l="elementNameFn"in r?r.elementNameFn(e,t):e;if(void 0===t||null===t||""===t)return"fullTagEmptyElementFn"in r&&r.fullTagEmptyElementFn(e,t)||r.fullTagEmptyElement?"<"+l+">":"<"+l+"/>";var c=[];if(e){if(c.push("<"+l),"object"!=typeof t)return c.push(">"+d(t,r)+""),c.join("");t[r.attributesKey]&&c.push(u(t[r.attributesKey],r,s));var f=m(t,r,!0)||t[r.attributesKey]&&"preserve"===t[r.attributesKey]["xml:space"];if(f||(f="fullTagEmptyElementFn"in r?r.fullTagEmptyElementFn(e,t):r.fullTagEmptyElement),!f)return c.push("/>"),c.join("");c.push(">")}return c.push(b(t,r,s+1,!1)),n=t,i=e,e&&c.push((o?a(r,s,!1):"")+""),c.join("")}function b(t,e,r,n){var i,s,u,g=[];for(s in t)if(t.hasOwnProperty(s))for(u=o(t[s])?t[s]:[t[s]],i=0;i/g,">")),l("text",t))}function d(t){n.ignoreComment||(n.trim&&(t=t.trim()),l("comment",t))}function g(t){var e=i[n.parentKey];n.addParent||delete i[n.parentKey],i=e}function m(t){n.ignoreCdata||(n.trim&&(t=t.trim()),l("cdata",t))}function y(t){n.ignoreDoctype||(t=t.replace(/^ /,""),n.trim&&(t=t.trim()),l("doctype",t))}function b(t){t.note=t}e.exports=function(t,e){var r=s.parser(!0,{}),a={};if(i=a,n=function(t){return n=o.copyOptions(t),o.ensureFlagExists("ignoreDeclaration",n),o.ensureFlagExists("ignoreInstruction",n),o.ensureFlagExists("ignoreAttributes",n),o.ensureFlagExists("ignoreText",n),o.ensureFlagExists("ignoreComment",n),o.ensureFlagExists("ignoreCdata",n),o.ensureFlagExists("ignoreDoctype",n),o.ensureFlagExists("compact",n),o.ensureFlagExists("alwaysChildren",n),o.ensureFlagExists("addParent",n),o.ensureFlagExists("trim",n),o.ensureFlagExists("nativeType",n),o.ensureFlagExists("nativeTypeAttributes",n),o.ensureFlagExists("sanitize",n),o.ensureFlagExists("instructionHasAttributes",n),o.ensureFlagExists("captureSpacesBetweenElements",n),o.ensureAlwaysArrayExists(n),o.ensureKeyExists("declaration",n),o.ensureKeyExists("instruction",n),o.ensureKeyExists("attributes",n),o.ensureKeyExists("text",n),o.ensureKeyExists("comment",n),o.ensureKeyExists("cdata",n),o.ensureKeyExists("doctype",n),o.ensureKeyExists("type",n),o.ensureKeyExists("name",n),o.ensureKeyExists("elements",n),o.ensureKeyExists("parent",n),o.checkFnExists("doctype",n),o.checkFnExists("instruction",n),o.checkFnExists("cdata",n),o.checkFnExists("comment",n),o.checkFnExists("text",n),o.checkFnExists("instructionName",n),o.checkFnExists("elementName",n),o.checkFnExists("attributeName",n),o.checkFnExists("attributeValue",n),o.checkFnExists("attributes",n),n}(e),r.opt={strictEntities:!0},r.onopentag=h,r.ontext=p,r.oncomment=d,r.onclosetag=g,r.onerror=b,r.oncdata=m,r.ondoctype=y,r.onprocessinginstruction=f,r.write(t).close(),a[n.elementsKey]){var u=a[n.elementsKey];delete a[n.elementsKey],a[n.elementsKey]=u,delete a.text}return a}},{"./array-helper":31,"./options-helper":35,sax:26}],37:[function(t,e,r){var n=t("./options-helper"),i=t("./xml2js");e.exports=function(t,e){var r,s,o;return r=function(t){var e=n.copyOptions(t);return n.ensureSpacesExists(e),e}(e),s=i(t,r),o="compact"in r&&r.compact?"_parent":"parent",("addParent"in r&&r.addParent?JSON.stringify(s,function(t,e){return t===o?"_":e},r.spaces):JSON.stringify(s,null,r.spaces)).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}},{"./options-helper":35,"./xml2js":36}],38:[function(t,e,r){(function(r){const n=t("./placing"),i=t("./rendering"),s={compute:t=>{const e=t.options||{};let r={};(t.nodes||[]).filter(t=>"string"==typeof t.name).forEach(t=>r[t.name]=t);let s=(t.links||[]).filter(t=>t.from&&t.to);if(s.filter(t=>!r[t.from]).forEach(t=>console.warn(`unknown source node "${t.from}"`)),s.filter(t=>!r[t.to]).forEach(t=>console.warn(`unknown destination node "${t.to}"`)),s=s.filter(t=>r[t.from]&&r[t.to]),!(r=n(e.placing).compute(r,s)))throw"Failed to place nodes";return i(e.rendering).compute(r,s)}};e.exports=s,r.faDiagrams=s}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./placing":39,"./rendering":40}],39:[function(t,e,r){const n=t("./utils"),i={name:"!string",x:"number",y:"number"},s={from:"!string",to:"!string",direction:"string"},o={"max-link-length":3,diagonals:!0};e.exports=(t=>{t=n.merge(o,t);const e={getBounds:t=>{const e=Object.values(t).filter(t=>void 0!==t.x);if(0===e.length)return{x:0,y:0,w:0,h:0};let r=null,n=null,i=null,s=null;return e.forEach(t=>{r=null!==r?Math.min(t.x,r):t.x,n=null!==n?Math.min(t.y,n):t.y,i=null!==i?Math.max(t.x,i):t.x,s=null!==s?Math.max(t.y,s):t.y}),{x:r,y:n,w:i-r+1,h:s-n+1}},getNewPos:t=>{const r=e.getBounds(t),i=n.newMap(r.w,r.h,!1);Object.values(t).filter(t=>void 0!==t.x).forEach(t=>{i[t.x-r.x][t.y-r.y]=!0});for(let t=0;t{let n=t[e].x,i=t[e].y,s=t[r].x,o=t[r].y;const a=s-n,u=o-i,l=(t,n)=>i=>i.x===t&&i.y===n&&i.name!==e&&i.name!==r;if(Math.abs(a)>=Math.abs(u)){if(n>s){let t=n;n=s,s=t}for(let e=n;e<=s;e++){let r=Math.round(i+u*(e-n)/a);if(Object.values(t).find(l(e,r)))return!0}}else{if(i>o){let t=i;i=o,o=t}for(let e=i;e<=o;e++){let r=Math.round(n+a*(e-i)/u);if(Object.values(t).find(l(r,e)))return!0}}return!1},getPosition:(e,r,n)=>{const i=e[r],s={maxX:null,maxY:null,minX:null,minY:null,startX:null,startY:null,free:!0},o=(t,r,n,i)=>o=>{if(void 0!==e[o].x){const a=e[o].x,u=e[o].y;s.minX=null!==s.minX?Math.max(a+t,s.minX):a+t,s.maxX=null!==s.maxX?Math.min(a+r,s.maxX):a+r,s.minY=null!==s.minY?Math.max(u+n,s.minY):u+n,s.maxY=null!==s.maxY?Math.min(u+i,s.maxY):u+i,null===s.startX&&(s.startX=Math.abs(i+n)>0?a:1===Math.abs(t)?"minX":"maxX",s.startY=Math.abs(r+t)>0?u:1===Math.abs(n)?"minY":"maxY"),s.free=!1}},a=t["max-link-length"],u=n?a:0;return i.const.beforeX.forEach(o(1,1+a,-u,u)),i.const.beforeY.forEach(o(-u,u,1,1+a)),i.const.afterX.forEach(o(-1-a,-1,-u,u)),i.const.afterY.forEach(o(-u,u,-1-a,-1)),"string"==typeof s.startX&&(s.startX=s[s.startX]),"string"==typeof s.startY&&(s.startY=s[s.startY]),s.minX>s.maxX||s.minY>s.maxY?null:{x:s.startX,y:s.startY,free:s.free}},isValid:(r,n)=>{let i,s,o;const a=Object.values(r).filter(t=>void 0!==t.x);for(let t=0;tMath.pow(t["max-link-length"],2))return!1;switch(i.direction){case"up":case"top":if(o.y-s.y>=0)return!1;break;case"down":case"bottom":if(o.y-s.y<=0)return!1;break;case"left":if(o.x-s.x>=0)return!1;break;case"right":if(o.x-s.x<=0)return!1}if(!t.diagonals&&s.x!==o.x&&s.y!==o.y)return!1}return!0},correctPlacing:t=>{const r=e.getBounds(t);Object.values(t).forEach(t=>{t.x-=r.x,t.y-=r.y})},applyLinks:(r,i,s=0)=>{if(!e.isValid(r,i))return null;const o=Object.keys(r).filter(t=>void 0===r[t].x);if(0===o.length)return r;const a=[],u=(t,o,a)=>{const u=n.ezClone(r);return u[t].x=o,u[t].y=a,e.applyLinks(u,i,s+1)};let l,c,f;for(let n=0;n(Object.keys(t).forEach(e=>{const r=n.isValid(t[e],i);if(r)throw`Node '${e}' is invalid at key '${r}'`}),r.forEach((t,e)=>{const r=n.isValid(t,s);if(r)throw`Link ${e} (${t.from}->${t.to}) is invalid at key '${r}'`}),Object.values(t).forEach(t=>{t.const={beforeX:[],afterX:[],beforeY:[],afterY:[]}}),r.forEach(e=>{if(e.direction)switch(e.direction){case"up":case"top":t[e.from].const.beforeY.push(e.to),t[e.to].const.afterY.push(e.from);break;case"down":case"bottom":t[e.from].const.afterY.push(e.to),t[e.to].const.beforeY.push(e.from);break;case"left":t[e.from].const.beforeX.push(e.to),t[e.to].const.afterX.push(e.from);break;case"right":t[e.from].const.afterX.push(e.to),t[e.to].const.beforeX.push(e.from)}}),(t=e.applyLinks(t,r))&&(e.correctPlacing(t),Object.values(t).forEach(t=>{delete t.const})),t)};return e})},{"./utils":41}],40:[function(t,e,r){const n=t("xml-js"),i=t("./utils");let s={name:"error",height:512,index:[],links:{"arrow-head":{},"arrow-head-reverse":{},"line-start":{},"line-end":{},"dashed-step":{}},icons:{}};try{s=t("../resources.json")}catch(t){console.error("fa-diagrams: SVG resources could not be loaded: "+t)}const o={_:"string",text:"string",icon:{_:"string",path:"string",width:"number",height:"number"},color:"string",font:"string","font-size":"number","font-style":"string",margin:"number","line-height":"number",scale:"number"},a={name:"!string",icon:{_:"string",path:"string",width:"number",height:"number"},x:"!number",y:"!number",color:"string",scale:"number",top:o,bottom:o,left:o,right:o},u={from:"!string",to:"!string",type:"string",color:"string",scale:"number",size:"number",top:o,bottom:o},l={beautify:!1,scale:128,"h-spacing":1.3,color:"black",icons:{scale:1,color:""},links:{scale:1,color:"",size:0},texts:{font:"Arial","font-size":15,"font-style":"normal",color:"",margin:.2,"line-height":1.2}},c={"font-awesome":{fas:"solid",far:"regular",fab:"brands"}};e.exports=(t=>{t=i.merge(l,t);const e={getIcon:t=>{if(!t)return null;if("object"==typeof t)return t.path&&t.path.trim()?(t.height=t.height||t.width||s.height,t.width=t.width||t.height,t):null;if(!t.trim())return null;let e=i.ezClone(s.index);const r=t.trim().split(" ").map(t=>0===t.indexOf("fa-")?t.substr(3):t);for(let t=0;t{const r="v46.059c0 21.382 25.851 32.09 40.971 16.971 l86.059 -86.059c9.373-9.373 9.373-24.569 0-33.941l-86.059-86.059c-15.119-15.119-40.971-4.411-40.971 16.971v46.059",n="v-46.059c0-21.382-25.851-32.09-40.971-16.971l-86.059 86.059c-9.373 9.373-9.373 24.568 0 33.941l86.059 86.059c15.119 15.119 40.971 4.411 40.971-16.971v-46.059",i="c6.627 0 12 -5.373 12 -12v-56c0 -6.627 -5.373 -12 -12 -12",s="c-6.627 0-12 5.373-12 12v56c0 6.627 5.373 12 12 12",o=`${s}h56${i}`;switch(t){case"none":return null;default:return`M12 216${s}h${512*e-146.059}${r}z`;case"line":return`M12 216${s}h${512*e-24}${i}z`;case"double":return`M134.059 216${n}h${512*e-268.06}${r}z`;case"split-double":return`M12 126${s}h${512*e-146.059}${r}M134.059 306${n}h${512*e-146.059}${i}z`;case"dashed":const a=Math.floor((512*e-134.059)/168),u=(512*e-134.059-56*a-24)/a;return`M12 216${new Array(a).fill(`${o}m${u} 0`).join("")}v80${r}z`;case"dashed-line":const l=Math.floor(512*e/168),c=(512*e-56*l-24)/(l-1);return`M12 216${new Array(l).fill(o).join(`m${c} 0`)}z`;case"dashed-double":const f=Math.floor((512*e-268.118)/168),h=(512*e-268.118-56*f-24)/(f+1);return`M134.059 216${n}m${h}-80${new Array(f).fill(`${o}m${h} 0`).join("")}v80${r}z`;case"dashed-split-double":const p=Math.floor((512*e-134.059)/168),d=(512*e-134.059-56*p-24)/p;return`M12 126${new Array(p).fill(`${o}m${d} 0`).join("")}v80${r}M134.059 306${n}m${d} -80${new Array(p).fill(`${o}`).join(`m${d} 0`)}z`}},getBounds:t=>{const e=Object.values(t);if(0===e.length)return{w:0,h:0};let r=0,n=0;return e.forEach(t=>{r=Math.max(t.x,r),n=Math.max(t.y,n)}),{w:r+1,h:n+1}},getSvgText:(t,e,r,n)=>{if(!(t=t.trim()).includes("\n"))return{_text:t};const i=[];return t.split("\n").map(t=>t.trim()).forEach((t,s)=>{i.push({_attributes:{x:r,dy:0===s?"0":`${e}em`,"text-anchor":n},_text:t})}),{tspan:i}},renderNode:r=>{const n=e.getIcon(r.icon);if(!n)return null;const i=.4*(r.scale||t.icons.scale),s={_attributes:{transform:`translate(${(r.x+.5)*t["h-spacing"]} ${r.y+.5})`},g:[{_attributes:{transform:`scale(${i/n.height} ${i/n.height}) translate(${-n.width/2} ${-n.height/2})`,stroke:r.color||t.icons.color||void 0,fill:r.color||t.icons.color||void 0},path:{_attributes:{d:n.path}}}]};return["bottom","top","left","right"].forEach(n=>{const i=r[n];if(i&&i.text){const o=i["font-size"]||t.texts["font-size"],a=i.margin||t.texts.margin;let u,l;switch(n){case"bottom":u={x:0,y:1},l="middle";break;case"top":u={x:0,y:-1},l="middle";break;case"left":u={x:-1,y:0},l="end";break;case"right":u={x:1,y:0},l="start"}const c=i["line-height"]||t.texts["line-height"],f=e.getSvgText(i.text,c,u.x*o/2,l),h=f.tspan?f.tspan.length-1:0;f._attributes={"font-family":i.font||t.texts.font,"font-size":o,"text-anchor":l,x:u.x*o/2,y:(u.y+.25)*o-(1-u.y)*h*o*c/2},s.g.push({_attributes:{transform:`translate(${u.x*a} ${u.y*a}) scale(${1/t.scale} ${1/t.scale})`,stroke:i.color||r.color||t.texts.color||t.icons.color||void 0,fill:i.color||r.color||t.texts.color||t.icons.color||void 0},text:f})}}),s},renderLink:(r,n)=>{const i=r[n.from],s=r[n.to],o=((i.x+s.x)/2+.5)*t["h-spacing"],a=(i.y+s.y)/2+.5,u=180*Math.atan2(s.y-i.y,(s.x-i.x)*t["h-spacing"])/Math.PI,l=.4*(n.scale||t.links.scale);let c=n.size||t.links.size;if(!c){let e=Math.abs(s.x-i.x)*t["h-spacing"];e>0&&(e-=.6);let r=Math.abs(s.y-i.y);r>0&&(r-=.6),c=Math.sqrt(Math.pow(e,2)+Math.pow(r,2))/l}const f=e.getLinkPath(n.type,c);return f?{_attributes:{transform:`translate(${o} ${a}) rotate(${u})`},g:{_attributes:{transform:`scale(${l/512} ${l/512}) translate(${-256*c} -256)`,stroke:n.color||t.links.color||void 0,fill:n.color||t.links.color||void 0},path:{_attributes:{d:f}}}}:null},toXML:(e,r)=>{const i={svg:{_attributes:{xmlns:"http://www.w3.org/2000/svg",viewBox:`0 0 ${r.w*t["h-spacing"]} ${r.h}`,width:r.w*t["h-spacing"]*t.scale/.4,height:r.h*t.scale/.4,stroke:t.color,fill:t.color}}};return Object.keys(e).forEach(t=>{i.svg[t]=e[t]}),n.js2xml(i,{compact:!0,spaces:t.beautify?4:0}).replace(/<\/tspan>(\s*){const n={g:[]};Object.keys(t).forEach(r=>{const s=i.isValid(t[r],a);if(s)throw`Node '${r}' is invalid at key '${s}'`;["bottom","top","left","right"].forEach(e=>{"string"==typeof t[r][e]&&(t[r][e]={text:t[r][e]})});const o=e.renderNode(t[r]);o&&n.g.push(o)}),r.forEach((r,s)=>{const o=i.isValid(r,u);if(o)throw`Link ${s} (${r.from}->${r.to}) is invalid at key '${o}'`;["bottom","top"].forEach(t=>{"string"==typeof r[t]&&(r[t]={text:r[t]})});const a=e.renderLink(t,r);a&&n.g.push(a)});const s=e.getBounds(t);return e.toXML(n,s)}};return e})},{"../resources.json":void 0,"./utils":41,"xml-js":32}],41:[function(t,e,r){const n={merge:(t,e)=>{if(typeof t!=typeof e)return t;if(t.length&&!e.length)return t;if(t.length&&e.length)return e;if("object"==typeof t){const r={};return Object.keys(t).forEach(i=>r[i]=n.merge(t[i],e[i])),r}return e},isValid:(t,e)=>{const r=Object.keys(e).filter(t=>"_"!==t);let i,s;for(let o=0;o0&&(s="array"),"object"==typeof e[i]){if(s&&"object"!==s&&s!==e[i]._)return i;const r=n.isValid(s?t[i]:void 0,e[i]);if(r)return i+"."+r}else{if("!"===e[i][0]&&(e[i]=e[i].substr(1),!s))return i;if(s&&s!==e[i])return i}return null},ezClone:t=>JSON.parse(JSON.stringify(t)),newMap:(t,e,r)=>new Array(t).fill(0).map(()=>new Array(e).fill(r))};e.exports=n},{}]},{},[38]); \ No newline at end of file diff --git a/docs/index.html b/docs/index.html index 1219830..0f63ef1 100644 --- a/docs/index.html +++ b/docs/index.html @@ -4,6 +4,7 @@ fa-diagrams example +