>)/i,/^(?:.*\[\[fork\]\])/i,/^(?:.*\[\[join\]\])/i,/^(?:["])/i,/^(?:\s*as\s+)/i,/^(?:[^\n\{]*)/i,/^(?:["])/i,/^(?:[^"]*)/i,/^(?:[^\n\s\{]+)/i,/^(?:\n)/i,/^(?:\{)/i,/^(?:\})/i,/^(?:[\n])/i,/^(?:note\s+)/i,/^(?:left of\b)/i,/^(?:right of\b)/i,/^(?:")/i,/^(?:\s*as\s*)/i,/^(?:["])/i,/^(?:[^"]*)/i,/^(?:[^\n]*)/i,/^(?:\s*[^:\n\s\-]+)/i,/^(?:\s*:[^:\n;]+)/i,/^(?:\s*[^:;]+end note\b)/i,/^(?:stateDiagram\s+)/i,/^(?:stateDiagram-v2\s+)/i,/^(?:hide empty description\b)/i,/^(?:\[\*\])/i,/^(?:[^:\n\s\-\{]+)/i,/^(?:\s*:[^:\n;]+)/i,/^(?:-->)/i,/^(?:--)/i,/^(?:$)/i,/^(?:.)/i],
conditions: {"LINE":{"rules":[2,3],"inclusive":false},"struct":{"rules":[2,3,8,21,22,23,37,38,39,40,41],"inclusive":false},"FLOATING_NOTE_ID":{"rules":[30],"inclusive":false},"FLOATING_NOTE":{"rules":[27,28,29],"inclusive":false},"NOTE_TEXT":{"rules":[32,33],"inclusive":false},"NOTE_ID":{"rules":[31],"inclusive":false},"NOTE":{"rules":[24,25,26],"inclusive":false},"SCALE":{"rules":[6,7],"inclusive":false},"ALIAS":{"rules":[],"inclusive":false},"STATE_ID":{"rules":[15],"inclusive":false},"STATE_STRING":{"rules":[16,17],"inclusive":false},"FORK_STATE":{"rules":[],"inclusive":false},"STATE":{"rules":[2,3,9,10,11,12,13,14,18,19,20],"inclusive":false},"ID":{"rules":[2,3],"inclusive":false},"INITIAL":{"rules":[0,1,3,4,5,8,20,23,34,35,36,37,38,39,40,42,43],"inclusive":true}}
});
return lexer;
})();
parser.lexer = lexer;
function Parser () {
this.yy = {};
}
Parser.prototype = parser;parser.Parser = Parser;
return new Parser;
})();
if (true) {
exports.parser = parser;
exports.Parser = parser.Parser;
exports.parse = function () { return parser.parse.apply(parser, arguments); };
exports.main = function commonjsMain (args) {
if (!args[1]) {
console.log('Usage: '+args[0]+' FILE');
process.exit(1);
}
var source = __webpack_require__(/*! fs */ "./node_modules/node-libs-browser/mock/empty.js").readFileSync(__webpack_require__(/*! path */ "./node_modules/path-browserify/index.js").normalize(args[1]), "utf8");
return exports.parser.parse(source);
};
if ( true && __webpack_require__.c[__webpack_require__.s] === module) {
exports.main(process.argv.slice(1));
}
}
/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../../node_modules/process/browser.js */ "./node_modules/process/browser.js"), __webpack_require__(/*! ./../../../../node_modules/webpack/buildin/module.js */ "./node_modules/webpack/buildin/module.js")(module)))
/***/ }),
/***/ "./src/diagrams/state/shapes.js":
/*!**************************************!*\
!*** ./src/diagrams/state/shapes.js ***!
\**************************************/
/*! exports provided: drawStartState, drawDivider, drawSimpleState, drawDescrState, addTitleAndBox, drawText, drawNote, drawState, drawEdge */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "drawStartState", function() { return drawStartState; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "drawDivider", function() { return drawDivider; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "drawSimpleState", function() { return drawSimpleState; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "drawDescrState", function() { return drawDescrState; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "addTitleAndBox", function() { return addTitleAndBox; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "drawText", function() { return drawText; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "drawNote", function() { return drawNote; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "drawState", function() { return drawState; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "drawEdge", function() { return drawEdge; });
/* harmony import */ var d3__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! d3 */ "d3");
/* harmony import */ var d3__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(d3__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _id_cache_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./id-cache.js */ "./src/diagrams/state/id-cache.js");
/* harmony import */ var _stateDb__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stateDb */ "./src/diagrams/state/stateDb.js");
/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../utils */ "./src/utils.js");
/* harmony import */ var _common_common__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../common/common */ "./src/diagrams/common/common.js");
/* harmony import */ var _config__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../config */ "./src/config.js");
/* harmony import */ var _logger__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../logger */ "./src/logger.js");
// let conf;
/**
* Draws a start state as a black circle
*/
var drawStartState = function drawStartState(g) {
return g.append('circle').style('stroke', 'black').style('fill', 'black').attr('r', Object(_config__WEBPACK_IMPORTED_MODULE_5__["getConfig"])().state.sizeUnit).attr('cx', Object(_config__WEBPACK_IMPORTED_MODULE_5__["getConfig"])().state.padding + Object(_config__WEBPACK_IMPORTED_MODULE_5__["getConfig"])().state.sizeUnit).attr('cy', Object(_config__WEBPACK_IMPORTED_MODULE_5__["getConfig"])().state.padding + Object(_config__WEBPACK_IMPORTED_MODULE_5__["getConfig"])().state.sizeUnit);
};
/**
* Draws a start state as a black circle
*/
var drawDivider = function drawDivider(g) {
return g.append('line').style('stroke', 'grey').style('stroke-dasharray', '3').attr('x1', Object(_config__WEBPACK_IMPORTED_MODULE_5__["getConfig"])().state.textHeight).attr('class', 'divider').attr('x2', Object(_config__WEBPACK_IMPORTED_MODULE_5__["getConfig"])().state.textHeight * 2).attr('y1', 0).attr('y2', 0);
};
/**
* Draws a an end state as a black circle
*/
var drawSimpleState = function drawSimpleState(g, stateDef) {
var state = g.append('text').attr('x', 2 * Object(_config__WEBPACK_IMPORTED_MODULE_5__["getConfig"])().state.padding).attr('y', Object(_config__WEBPACK_IMPORTED_MODULE_5__["getConfig"])().state.textHeight + 2 * Object(_config__WEBPACK_IMPORTED_MODULE_5__["getConfig"])().state.padding).attr('font-size', Object(_config__WEBPACK_IMPORTED_MODULE_5__["getConfig"])().state.fontSize).attr('class', 'state-title').text(stateDef.id);
var classBox = state.node().getBBox();
g.insert('rect', ':first-child').attr('x', Object(_config__WEBPACK_IMPORTED_MODULE_5__["getConfig"])().state.padding).attr('y', Object(_config__WEBPACK_IMPORTED_MODULE_5__["getConfig"])().state.padding).attr('width', classBox.width + 2 * Object(_config__WEBPACK_IMPORTED_MODULE_5__["getConfig"])().state.padding).attr('height', classBox.height + 2 * Object(_config__WEBPACK_IMPORTED_MODULE_5__["getConfig"])().state.padding).attr('rx', Object(_config__WEBPACK_IMPORTED_MODULE_5__["getConfig"])().state.radius);
return state;
};
/**
* Draws a state with descriptions
* @param {*} g
* @param {*} stateDef
*/
var drawDescrState = function drawDescrState(g, stateDef) {
var addTspan = function addTspan(textEl, txt, isFirst) {
var tSpan = textEl.append('tspan').attr('x', 2 * Object(_config__WEBPACK_IMPORTED_MODULE_5__["getConfig"])().state.padding).text(txt);
if (!isFirst) {
tSpan.attr('dy', Object(_config__WEBPACK_IMPORTED_MODULE_5__["getConfig"])().state.textHeight);
}
};
var title = g.append('text').attr('x', 2 * Object(_config__WEBPACK_IMPORTED_MODULE_5__["getConfig"])().state.padding).attr('y', Object(_config__WEBPACK_IMPORTED_MODULE_5__["getConfig"])().state.textHeight + 1.3 * Object(_config__WEBPACK_IMPORTED_MODULE_5__["getConfig"])().state.padding).attr('font-size', Object(_config__WEBPACK_IMPORTED_MODULE_5__["getConfig"])().state.fontSize).attr('class', 'state-title').text(stateDef.descriptions[0]);
var titleBox = title.node().getBBox();
var titleHeight = titleBox.height;
var description = g.append('text') // text label for the x axis
.attr('x', Object(_config__WEBPACK_IMPORTED_MODULE_5__["getConfig"])().state.padding).attr('y', titleHeight + Object(_config__WEBPACK_IMPORTED_MODULE_5__["getConfig"])().state.padding * 0.4 + Object(_config__WEBPACK_IMPORTED_MODULE_5__["getConfig"])().state.dividerMargin + Object(_config__WEBPACK_IMPORTED_MODULE_5__["getConfig"])().state.textHeight).attr('class', 'state-description');
var isFirst = true;
var isSecond = true;
stateDef.descriptions.forEach(function (descr) {
if (!isFirst) {
addTspan(description, descr, isSecond);
isSecond = false;
}
isFirst = false;
});
var descrLine = g.append('line') // text label for the x axis
.attr('x1', Object(_config__WEBPACK_IMPORTED_MODULE_5__["getConfig"])().state.padding).attr('y1', Object(_config__WEBPACK_IMPORTED_MODULE_5__["getConfig"])().state.padding + titleHeight + Object(_config__WEBPACK_IMPORTED_MODULE_5__["getConfig"])().state.dividerMargin / 2).attr('y2', Object(_config__WEBPACK_IMPORTED_MODULE_5__["getConfig"])().state.padding + titleHeight + Object(_config__WEBPACK_IMPORTED_MODULE_5__["getConfig"])().state.dividerMargin / 2).attr('class', 'descr-divider');
var descrBox = description.node().getBBox();
var width = Math.max(descrBox.width, titleBox.width);
descrLine.attr('x2', width + 3 * Object(_config__WEBPACK_IMPORTED_MODULE_5__["getConfig"])().state.padding); // const classBox = title.node().getBBox();
g.insert('rect', ':first-child').attr('x', Object(_config__WEBPACK_IMPORTED_MODULE_5__["getConfig"])().state.padding).attr('y', Object(_config__WEBPACK_IMPORTED_MODULE_5__["getConfig"])().state.padding).attr('width', width + 2 * Object(_config__WEBPACK_IMPORTED_MODULE_5__["getConfig"])().state.padding).attr('height', descrBox.height + titleHeight + 2 * Object(_config__WEBPACK_IMPORTED_MODULE_5__["getConfig"])().state.padding).attr('rx', Object(_config__WEBPACK_IMPORTED_MODULE_5__["getConfig"])().state.radius);
return g;
};
/**
* Adds the creates a box around the existing content and adds a
* panel for the id on top of the content.
*/
/**
* Function that creates an title row and a frame around a substate for a composit state diagram.
* The function returns a new d3 svg object with updated width and height properties;
* @param {*} g The d3 svg object for the substate to framed
* @param {*} stateDef The info about the
*/
var addTitleAndBox = function addTitleAndBox(g, stateDef, altBkg) {
var pad = Object(_config__WEBPACK_IMPORTED_MODULE_5__["getConfig"])().state.padding;
var dblPad = 2 * Object(_config__WEBPACK_IMPORTED_MODULE_5__["getConfig"])().state.padding;
var orgBox = g.node().getBBox();
var orgWidth = orgBox.width;
var orgX = orgBox.x;
var title = g.append('text').attr('x', 0).attr('y', Object(_config__WEBPACK_IMPORTED_MODULE_5__["getConfig"])().state.titleShift).attr('font-size', Object(_config__WEBPACK_IMPORTED_MODULE_5__["getConfig"])().state.fontSize).attr('class', 'state-title').text(stateDef.id);
var titleBox = title.node().getBBox();
var titleWidth = titleBox.width + dblPad;
var width = Math.max(titleWidth, orgWidth); // + dblPad;
if (width === orgWidth) {
width = width + dblPad;
}
var startX; // const lineY = 1 - getConfig().state.textHeight;
// const descrLine = g
// .append('line') // text label for the x axis
// .attr('x1', 0)
// .attr('y1', lineY)
// .attr('y2', lineY)
// .attr('class', 'descr-divider');
var graphBox = g.node().getBBox(); // console.warn(width / 2, titleWidth / 2, getConfig().state.padding, orgBox);
// descrLine.attr('x2', graphBox.width + getConfig().state.padding);
if (stateDef.doc) {// cnsole.warn(
// stateDef.id,
// 'orgX: ',
// orgX,
// 'width: ',
// width,
// 'titleWidth: ',
// titleWidth,
// 'orgWidth: ',
// orgWidth,
// 'width',
// width
// );
}
startX = orgX - pad;
if (titleWidth > orgWidth) {
startX = (orgWidth - width) / 2 + pad;
}
if (Math.abs(orgX - graphBox.x) < pad) {
if (titleWidth > orgWidth) {
startX = orgX - (titleWidth - orgWidth) / 2;
}
}
var lineY = 1 - Object(_config__WEBPACK_IMPORTED_MODULE_5__["getConfig"])().state.textHeight; // White color
g.insert('rect', ':first-child').attr('x', startX).attr('y', lineY).attr('class', altBkg ? 'alt-composit' : 'composit').attr('width', width).attr('height', graphBox.height + Object(_config__WEBPACK_IMPORTED_MODULE_5__["getConfig"])().state.textHeight + Object(_config__WEBPACK_IMPORTED_MODULE_5__["getConfig"])().state.titleShift + 1).attr('rx', '0');
title.attr('x', startX + pad);
if (titleWidth <= orgWidth) title.attr('x', orgX + (width - dblPad) / 2 - titleWidth / 2 + pad); // Title background
g.insert('rect', ':first-child').attr('x', startX).attr('y', Object(_config__WEBPACK_IMPORTED_MODULE_5__["getConfig"])().state.titleShift - Object(_config__WEBPACK_IMPORTED_MODULE_5__["getConfig"])().state.textHeight - Object(_config__WEBPACK_IMPORTED_MODULE_5__["getConfig"])().state.padding).attr('width', width) // Just needs to be higher then the descr line, will be clipped by the white color box
.attr('height', Object(_config__WEBPACK_IMPORTED_MODULE_5__["getConfig"])().state.textHeight * 3).attr('rx', Object(_config__WEBPACK_IMPORTED_MODULE_5__["getConfig"])().state.radius); // Full background
g.insert('rect', ':first-child').attr('x', startX).attr('y', Object(_config__WEBPACK_IMPORTED_MODULE_5__["getConfig"])().state.titleShift - Object(_config__WEBPACK_IMPORTED_MODULE_5__["getConfig"])().state.textHeight - Object(_config__WEBPACK_IMPORTED_MODULE_5__["getConfig"])().state.padding).attr('width', width).attr('height', graphBox.height + 3 + 2 * Object(_config__WEBPACK_IMPORTED_MODULE_5__["getConfig"])().state.textHeight).attr('rx', Object(_config__WEBPACK_IMPORTED_MODULE_5__["getConfig"])().state.radius);
return g;
};
var drawEndState = function drawEndState(g) {
g.append('circle').style('stroke', 'black').style('fill', 'white').attr('r', Object(_config__WEBPACK_IMPORTED_MODULE_5__["getConfig"])().state.sizeUnit + Object(_config__WEBPACK_IMPORTED_MODULE_5__["getConfig"])().state.miniPadding).attr('cx', Object(_config__WEBPACK_IMPORTED_MODULE_5__["getConfig"])().state.padding + Object(_config__WEBPACK_IMPORTED_MODULE_5__["getConfig"])().state.sizeUnit + Object(_config__WEBPACK_IMPORTED_MODULE_5__["getConfig"])().state.miniPadding).attr('cy', Object(_config__WEBPACK_IMPORTED_MODULE_5__["getConfig"])().state.padding + Object(_config__WEBPACK_IMPORTED_MODULE_5__["getConfig"])().state.sizeUnit + Object(_config__WEBPACK_IMPORTED_MODULE_5__["getConfig"])().state.miniPadding);
return g.append('circle').style('stroke', 'black').style('fill', 'black').attr('r', Object(_config__WEBPACK_IMPORTED_MODULE_5__["getConfig"])().state.sizeUnit).attr('cx', Object(_config__WEBPACK_IMPORTED_MODULE_5__["getConfig"])().state.padding + Object(_config__WEBPACK_IMPORTED_MODULE_5__["getConfig"])().state.sizeUnit + 2).attr('cy', Object(_config__WEBPACK_IMPORTED_MODULE_5__["getConfig"])().state.padding + Object(_config__WEBPACK_IMPORTED_MODULE_5__["getConfig"])().state.sizeUnit + 2);
};
var drawForkJoinState = function drawForkJoinState(g, stateDef) {
var width = Object(_config__WEBPACK_IMPORTED_MODULE_5__["getConfig"])().state.forkWidth;
var height = Object(_config__WEBPACK_IMPORTED_MODULE_5__["getConfig"])().state.forkHeight;
if (stateDef.parentId) {
var tmp = width;
width = height;
height = tmp;
}
return g.append('rect').style('stroke', 'black').style('fill', 'black').attr('width', width).attr('height', height).attr('x', Object(_config__WEBPACK_IMPORTED_MODULE_5__["getConfig"])().state.padding).attr('y', Object(_config__WEBPACK_IMPORTED_MODULE_5__["getConfig"])().state.padding);
};
var drawText = function drawText(elem, textData) {
// Remove and ignore br:s
var nText = textData.text.replace(_common_common__WEBPACK_IMPORTED_MODULE_4__["default"].lineBreakRegex, ' ');
var textElem = elem.append('text');
textElem.attr('x', textData.x);
textElem.attr('y', textData.y);
textElem.style('text-anchor', textData.anchor);
textElem.attr('fill', textData.fill);
if (typeof textData.class !== 'undefined') {
textElem.attr('class', textData.class);
}
var span = textElem.append('tspan');
span.attr('x', textData.x + textData.textMargin * 2);
span.attr('fill', textData.fill);
span.text(nText);
return textElem;
};
var _drawLongText = function _drawLongText(_text, x, y, g) {
var textHeight = 0;
var textElem = g.append('text');
textElem.style('text-anchor', 'start');
textElem.attr('class', 'noteText');
var text = _text.replace(/\r\n/g, '
');
text = text.replace(/\n/g, '
');
var lines = text.split(_common_common__WEBPACK_IMPORTED_MODULE_4__["default"].lineBreakRegex);
var tHeight = 1.25 * Object(_config__WEBPACK_IMPORTED_MODULE_5__["getConfig"])().state.noteMargin;
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = lines[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var _line = _step.value;
var txt = _line.trim();
if (txt.length > 0) {
var span = textElem.append('tspan');
span.text(txt);
if (tHeight === 0) {
var textBounds = span.node().getBBox();
tHeight += textBounds.height;
} // console.warn('textBounds', textBounds);
textHeight += tHeight;
span.attr('x', x + Object(_config__WEBPACK_IMPORTED_MODULE_5__["getConfig"])().state.noteMargin);
span.attr('y', y + textHeight + 1.25 * Object(_config__WEBPACK_IMPORTED_MODULE_5__["getConfig"])().state.noteMargin);
}
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return != null) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
return {
textWidth: textElem.node().getBBox().width,
textHeight: textHeight
};
};
/**
* Draws a note to the diagram
* @param text - The text of the given note.
* @param g - The element the note is attached to.
*/
var drawNote = function drawNote(text, g) {
g.attr('class', 'state-note');
var note = g.append('rect').attr('x', 0).attr('y', Object(_config__WEBPACK_IMPORTED_MODULE_5__["getConfig"])().state.padding);
var rectElem = g.append('g');
var _drawLongText2 = _drawLongText(text, 0, 0, rectElem),
textWidth = _drawLongText2.textWidth,
textHeight = _drawLongText2.textHeight;
note.attr('height', textHeight + 2 * Object(_config__WEBPACK_IMPORTED_MODULE_5__["getConfig"])().state.noteMargin);
note.attr('width', textWidth + Object(_config__WEBPACK_IMPORTED_MODULE_5__["getConfig"])().state.noteMargin * 2);
return note;
};
/**
* Starting point for drawing a state. The function finds out the specifics
* about the state and renders with approprtiate function.
* @param {*} elem
* @param {*} stateDef
*/
var drawState = function drawState(elem, stateDef) {
var id = stateDef.id;
var stateInfo = {
id: id,
label: stateDef.id,
width: 0,
height: 0
};
var g = elem.append('g').attr('id', id).attr('class', 'stateGroup');
if (stateDef.type === 'start') drawStartState(g);
if (stateDef.type === 'end') drawEndState(g);
if (stateDef.type === 'fork' || stateDef.type === 'join') drawForkJoinState(g, stateDef);
if (stateDef.type === 'note') drawNote(stateDef.note.text, g);
if (stateDef.type === 'divider') drawDivider(g);
if (stateDef.type === 'default' && stateDef.descriptions.length === 0) drawSimpleState(g, stateDef);
if (stateDef.type === 'default' && stateDef.descriptions.length > 0) drawDescrState(g, stateDef);
var stateBox = g.node().getBBox();
stateInfo.width = stateBox.width + 2 * Object(_config__WEBPACK_IMPORTED_MODULE_5__["getConfig"])().state.padding;
stateInfo.height = stateBox.height + 2 * Object(_config__WEBPACK_IMPORTED_MODULE_5__["getConfig"])().state.padding;
_id_cache_js__WEBPACK_IMPORTED_MODULE_1__["default"].set(id, stateInfo); // stateCnt++;
return stateInfo;
};
var edgeCount = 0;
var drawEdge = function drawEdge(elem, path, relation) {
var getRelationType = function getRelationType(type) {
switch (type) {
case _stateDb__WEBPACK_IMPORTED_MODULE_2__["default"].relationType.AGGREGATION:
return 'aggregation';
case _stateDb__WEBPACK_IMPORTED_MODULE_2__["default"].relationType.EXTENSION:
return 'extension';
case _stateDb__WEBPACK_IMPORTED_MODULE_2__["default"].relationType.COMPOSITION:
return 'composition';
case _stateDb__WEBPACK_IMPORTED_MODULE_2__["default"].relationType.DEPENDENCY:
return 'dependency';
}
};
path.points = path.points.filter(function (p) {
return !Number.isNaN(p.y);
}); // The data for our line
var lineData = path.points; // This is the accessor function we talked about above
var lineFunction = Object(d3__WEBPACK_IMPORTED_MODULE_0__["line"])().x(function (d) {
return d.x;
}).y(function (d) {
return d.y;
}).curve(d3__WEBPACK_IMPORTED_MODULE_0__["curveBasis"]);
var svgPath = elem.append('path').attr('d', lineFunction(lineData)).attr('id', 'edge' + edgeCount).attr('class', 'transition');
var url = '';
if (Object(_config__WEBPACK_IMPORTED_MODULE_5__["getConfig"])().state.arrowMarkerAbsolute) {
url = window.location.protocol + '//' + window.location.host + window.location.pathname + window.location.search;
url = url.replace(/\(/g, '\\(');
url = url.replace(/\)/g, '\\)');
}
svgPath.attr('marker-end', 'url(' + url + '#' + getRelationType(_stateDb__WEBPACK_IMPORTED_MODULE_2__["default"].relationType.DEPENDENCY) + 'End' + ')');
if (typeof relation.title !== 'undefined') {
var label = elem.append('g').attr('class', 'stateLabel');
var _utils$calcLabelPosit = _utils__WEBPACK_IMPORTED_MODULE_3__["default"].calcLabelPosition(path.points),
x = _utils$calcLabelPosit.x,
y = _utils$calcLabelPosit.y;
var rows = _common_common__WEBPACK_IMPORTED_MODULE_4__["default"].getRows(relation.title); // console.warn(rows);
var titleHeight = 0;
var titleRows = [];
var maxWidth = 0;
var minX = 0;
for (var i = 0; i <= rows.length; i++) {
var title = label.append('text').attr('text-anchor', 'middle').text(rows[i]).attr('x', x).attr('y', y + titleHeight);
var boundstmp = title.node().getBBox();
maxWidth = Math.max(maxWidth, boundstmp.width);
minX = Math.min(minX, boundstmp.x);
_logger__WEBPACK_IMPORTED_MODULE_6__["logger"].info(boundstmp.x, x, y + titleHeight);
if (titleHeight === 0) {
var titleBox = title.node().getBBox();
titleHeight = titleBox.height;
_logger__WEBPACK_IMPORTED_MODULE_6__["logger"].info('Title height', titleHeight, y);
}
titleRows.push(title);
}
var boxHeight = titleHeight * rows.length;
if (rows.length > 1) {
var heightAdj = (rows.length - 1) * titleHeight * 0.5;
titleRows.forEach(function (title, i) {
return title.attr('y', y + i * titleHeight - heightAdj);
});
boxHeight = titleHeight * rows.length;
}
var bounds = label.node().getBBox();
label.insert('rect', ':first-child').attr('class', 'box').attr('x', x - maxWidth / 2 - Object(_config__WEBPACK_IMPORTED_MODULE_5__["getConfig"])().state.padding / 2).attr('y', y - boxHeight / 2 - Object(_config__WEBPACK_IMPORTED_MODULE_5__["getConfig"])().state.padding / 2 - 3.5).attr('width', maxWidth + Object(_config__WEBPACK_IMPORTED_MODULE_5__["getConfig"])().state.padding).attr('height', boxHeight + Object(_config__WEBPACK_IMPORTED_MODULE_5__["getConfig"])().state.padding);
_logger__WEBPACK_IMPORTED_MODULE_6__["logger"].info(bounds); //label.attr('transform', '0 -' + (bounds.y / 2));
// Debug points
// path.points.forEach(point => {
// g.append('circle')
// .style('stroke', 'red')
// .style('fill', 'red')
// .attr('r', 1)
// .attr('cx', point.x)
// .attr('cy', point.y);
// });
// g.append('circle')
// .style('stroke', 'blue')
// .style('fill', 'blue')
// .attr('r', 1)
// .attr('cx', x)
// .attr('cy', y);
}
edgeCount++;
};
/***/ }),
/***/ "./src/diagrams/state/stateDb.js":
/*!***************************************!*\
!*** ./src/diagrams/state/stateDb.js ***!
\***************************************/
/*! exports provided: addState, clear, getState, getStates, logDocuments, getRelations, addRelation, cleanupLabel, lineType, relationType, default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "addState", function() { return addState; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clear", function() { return clear; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getState", function() { return getState; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getStates", function() { return getStates; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "logDocuments", function() { return logDocuments; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getRelations", function() { return getRelations; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "addRelation", function() { return addRelation; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "cleanupLabel", function() { return cleanupLabel; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lineType", function() { return lineType; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "relationType", function() { return relationType; });
/* harmony import */ var _logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../logger */ "./src/logger.js");
/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../utils */ "./src/utils.js");
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
var clone = function clone(o) {
return JSON.parse(JSON.stringify(o));
};
var rootDoc = [];
var setRootDoc = function setRootDoc(o) {
_logger__WEBPACK_IMPORTED_MODULE_0__["logger"].info('Setting root doc', o); // rootDoc = { id: 'root', doc: o };
rootDoc = o;
};
var getRootDoc = function getRootDoc() {
return rootDoc;
};
var docTranslator = function docTranslator(parent, node, first) {
if (node.stmt === 'relation') {
docTranslator(parent, node.state1, true);
docTranslator(parent, node.state2, false);
} else {
if (node.stmt === 'state') {
if (node.id === '[*]') {
node.id = first ? parent.id + '_start' : parent.id + '_end';
node.start = first;
}
}
if (node.doc) {
var doc = []; // Check for concurrency
var i = 0;
var currentDoc = [];
for (i = 0; i < node.doc.length; i++) {
if (node.doc[i].type === 'divider') {
// debugger;
var newNode = clone(node.doc[i]);
newNode.doc = clone(currentDoc);
doc.push(newNode);
currentDoc = [];
} else {
currentDoc.push(node.doc[i]);
}
} // If any divider was encountered
if (doc.length > 0 && currentDoc.length > 0) {
var _newNode = {
stmt: 'state',
id: Object(_utils__WEBPACK_IMPORTED_MODULE_1__["generateId"])(),
type: 'divider',
doc: clone(currentDoc)
};
doc.push(clone(_newNode));
node.doc = doc;
}
node.doc.forEach(function (docNode) {
return docTranslator(node, docNode, true);
});
}
}
};
var getRootDocV2 = function getRootDocV2() {
docTranslator({
id: 'root'
}, {
id: 'root',
doc: rootDoc
}, true);
return {
id: 'root',
doc: rootDoc
};
};
var extract = function extract(_doc) {
// const res = { states: [], relations: [] };
var doc;
if (_doc.doc) {
doc = _doc.doc;
} else {
doc = _doc;
} // let doc = root.doc;
// if (!doc) {
// doc = root;
// }
_logger__WEBPACK_IMPORTED_MODULE_0__["logger"].info(doc);
clear();
_logger__WEBPACK_IMPORTED_MODULE_0__["logger"].info('Extract', doc);
doc.forEach(function (item) {
if (item.stmt === 'state') {
addState(item.id, item.type, item.doc, item.description, item.note);
}
if (item.stmt === 'relation') {
addRelation(item.state1.id, item.state2.id, item.description);
}
});
};
var newDoc = function newDoc() {
return {
relations: [],
states: {},
documents: {}
};
};
var documents = {
root: newDoc()
};
var currentDocument = documents.root;
var startCnt = 0;
var endCnt = 0; // eslint-disable-line
// let stateCnt = 0;
/**
* Function called by parser when a node definition has been found.
* @param id
* @param text
* @param type
* @param style
*/
var addState = function addState(id, type, doc, descr, note) {
if (typeof currentDocument.states[id] === 'undefined') {
currentDocument.states[id] = {
id: id,
descriptions: [],
type: type,
doc: doc,
note: note
};
} else {
if (!currentDocument.states[id].doc) {
currentDocument.states[id].doc = doc;
}
if (!currentDocument.states[id].type) {
currentDocument.states[id].type = type;
}
}
if (descr) {
_logger__WEBPACK_IMPORTED_MODULE_0__["logger"].info('Adding state ', id, descr);
if (typeof descr === 'string') addDescription(id, descr.trim());
if (_typeof(descr) === 'object') {
descr.forEach(function (des) {
return addDescription(id, des.trim());
});
}
}
if (note) currentDocument.states[id].note = note;
};
var clear = function clear() {
documents = {
root: newDoc()
};
currentDocument = documents.root;
currentDocument = documents.root;
startCnt = 0;
endCnt = 0; // eslint-disable-line
classes = [];
};
var getState = function getState(id) {
return currentDocument.states[id];
};
var getStates = function getStates() {
return currentDocument.states;
};
var logDocuments = function logDocuments() {
_logger__WEBPACK_IMPORTED_MODULE_0__["logger"].info('Documents = ', documents);
};
var getRelations = function getRelations() {
return currentDocument.relations;
};
var addRelation = function addRelation(_id1, _id2, title) {
var id1 = _id1;
var id2 = _id2;
var type1 = 'default';
var type2 = 'default';
if (_id1 === '[*]') {
startCnt++;
id1 = 'start' + startCnt;
type1 = 'start';
}
if (_id2 === '[*]') {
endCnt++;
id2 = 'end' + startCnt;
type2 = 'end';
}
addState(id1, type1);
addState(id2, type2);
currentDocument.relations.push({
id1: id1,
id2: id2,
title: title
});
};
var addDescription = function addDescription(id, _descr) {
var theState = currentDocument.states[id];
var descr = _descr;
if (descr[0] === ':') {
descr = descr.substr(1).trim();
}
theState.descriptions.push(descr);
};
var cleanupLabel = function cleanupLabel(label) {
if (label.substring(0, 1) === ':') {
return label.substr(2).trim();
} else {
return label.trim();
}
};
var lineType = {
LINE: 0,
DOTTED_LINE: 1
};
var dividerCnt = 0;
var getDividerId = function getDividerId() {
dividerCnt++;
return 'divider-id-' + dividerCnt;
};
var classes = [];
var getClasses = function getClasses() {
return classes;
};
var getDirection = function getDirection() {
return 'TB';
};
var relationType = {
AGGREGATION: 0,
EXTENSION: 1,
COMPOSITION: 2,
DEPENDENCY: 3
};
var trimColon = function trimColon(str) {
return str && str[0] === ':' ? str.substr(1).trim() : str.trim();
};
/* harmony default export */ __webpack_exports__["default"] = ({
addState: addState,
clear: clear,
getState: getState,
getStates: getStates,
getRelations: getRelations,
getClasses: getClasses,
getDirection: getDirection,
addRelation: addRelation,
getDividerId: getDividerId,
// addDescription,
cleanupLabel: cleanupLabel,
lineType: lineType,
relationType: relationType,
logDocuments: logDocuments,
getRootDoc: getRootDoc,
setRootDoc: setRootDoc,
getRootDocV2: getRootDocV2,
extract: extract,
trimColon: trimColon
});
/***/ }),
/***/ "./src/diagrams/state/stateRenderer-v2.js":
/*!************************************************!*\
!*** ./src/diagrams/state/stateRenderer-v2.js ***!
\************************************************/
/*! exports provided: setConf, getClasses, draw, default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "setConf", function() { return setConf; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getClasses", function() { return getClasses; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "draw", function() { return draw; });
/* harmony import */ var graphlib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! graphlib */ "graphlib");
/* harmony import */ var graphlib__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(graphlib__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var d3__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! d3 */ "d3");
/* harmony import */ var d3__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(d3__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var _stateDb__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stateDb */ "./src/diagrams/state/stateDb.js");
/* harmony import */ var _parser_stateDiagram__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./parser/stateDiagram */ "./src/diagrams/state/parser/stateDiagram.jison");
/* harmony import */ var _parser_stateDiagram__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_parser_stateDiagram__WEBPACK_IMPORTED_MODULE_3__);
/* harmony import */ var _config__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../config */ "./src/config.js");
/* harmony import */ var _dagre_wrapper_index_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../dagre-wrapper/index.js */ "./src/dagre-wrapper/index.js");
/* harmony import */ var _logger__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../logger */ "./src/logger.js");
var conf = {};
var setConf = function setConf(cnf) {
var keys = Object.keys(cnf);
for (var i = 0; i < keys.length; i++) {
conf[keys[i]] = cnf[keys[i]];
}
};
var nodeDb = {};
/**
* Returns the all the styles from classDef statements in the graph definition.
* @returns {object} classDef styles
*/
var getClasses = function getClasses(text) {
_logger__WEBPACK_IMPORTED_MODULE_6__["logger"].trace('Extracting classes');
_stateDb__WEBPACK_IMPORTED_MODULE_2__["default"].clear();
var parser = _parser_stateDiagram__WEBPACK_IMPORTED_MODULE_3___default.a.parser;
parser.yy = _stateDb__WEBPACK_IMPORTED_MODULE_2__["default"]; // Parse the graph definition
parser.parse(text);
return _stateDb__WEBPACK_IMPORTED_MODULE_2__["default"].getClasses();
};
var setupNode = function setupNode(g, parent, node, altFlag) {
// Add the node
if (node.id !== 'root') {
var shape = 'rect';
if (node.start === true) {
shape = 'start';
}
if (node.start === false) {
shape = 'end';
}
if (node.type !== 'default') {
shape = node.type;
}
if (!nodeDb[node.id]) {
nodeDb[node.id] = {
id: node.id,
shape: shape,
description: node.id,
classes: 'statediagram-state'
};
} // Build of the array of description strings accordinging
if (node.description) {
if (Array.isArray(nodeDb[node.id].description)) {
// There already is an array of strings,add to it
nodeDb[node.id].shape = 'rectWithTitle';
nodeDb[node.id].description.push(node.description);
} else {
if (nodeDb[node.id].description.length > 0) {
// if there is a description already transformit to an array
nodeDb[node.id].shape = 'rectWithTitle';
if (nodeDb[node.id].description === node.id) {
// If the previous description was the is, remove it
nodeDb[node.id].description = [node.description];
} else {
nodeDb[node.id].description = [nodeDb[node.id].description, node.description];
}
} else {
nodeDb[node.id].shape = 'rect';
nodeDb[node.id].description = node.description;
}
}
} // Save data for description and group so that for instance a statement without description overwrites
// one with description
// group
if (!nodeDb[node.id].type && node.doc) {
_logger__WEBPACK_IMPORTED_MODULE_6__["logger"].info('Setting cluser for ', node.id);
nodeDb[node.id].type = 'group';
nodeDb[node.id].shape = node.type === 'divider' ? 'divider' : 'roundedWithTitle';
nodeDb[node.id].classes = nodeDb[node.id].classes + ' ' + (altFlag ? 'statediagram-cluster statediagram-cluster-alt' : 'statediagram-cluster');
}
var nodeData = {
labelStyle: '',
shape: nodeDb[node.id].shape,
labelText: nodeDb[node.id].description,
classes: nodeDb[node.id].classes,
//classStr,
style: '',
//styles.style,
id: node.id,
type: nodeDb[node.id].type,
padding: 15 //getConfig().flowchart.padding
};
if (node.note) {
// Todo: set random id
var noteData = {
labelStyle: '',
shape: 'note',
labelText: node.note.text,
classes: 'statediagram-note',
//classStr,
style: '',
//styles.style,
id: node.id + '----note',
type: nodeDb[node.id].type,
padding: 15 //getConfig().flowchart.padding
};
var groupData = {
labelStyle: '',
shape: 'noteGroup',
labelText: node.note.text,
classes: nodeDb[node.id].classes,
//classStr,
style: '',
//styles.style,
id: node.id + '----parent',
type: 'group',
padding: 0 //getConfig().flowchart.padding
};
g.setNode(node.id + '----parent', groupData);
g.setNode(noteData.id, noteData);
g.setNode(node.id, nodeData);
g.setParent(node.id, node.id + '----parent');
g.setParent(noteData.id, node.id + '----parent');
var from = node.id;
var to = noteData.id;
if (node.note.position === 'left of') {
from = noteData.id;
to = node.id;
}
g.setEdge(from, to, {
arrowhead: 'none',
arrowType: '',
style: 'fill:none',
labelStyle: '',
classes: 'note-edge',
arrowheadStyle: 'fill: #333',
labelpos: 'c',
labelType: 'text'
});
} else {
g.setNode(node.id, nodeData);
}
}
if (parent) {
if (parent.id !== 'root') {
_logger__WEBPACK_IMPORTED_MODULE_6__["logger"].info('Setting node ', node.id, ' to be child of its parent ', parent.id);
g.setParent(node.id, parent.id);
}
}
if (node.doc) {
_logger__WEBPACK_IMPORTED_MODULE_6__["logger"].info('Adding nodes children ');
setupDoc(g, node, node.doc, !altFlag);
}
};
var cnt = 0;
var setupDoc = function setupDoc(g, parent, doc, altFlag) {
_logger__WEBPACK_IMPORTED_MODULE_6__["logger"].trace('items', doc);
doc.forEach(function (item) {
if (item.stmt === 'state' || item.stmt === 'default') {
setupNode(g, parent, item, altFlag);
} else if (item.stmt === 'relation') {
setupNode(g, parent, item.state1, altFlag);
setupNode(g, parent, item.state2, altFlag);
var edgeData = {
id: 'edge' + cnt,
arrowhead: 'normal',
arrowType: 'arrow_barb',
style: 'fill:none',
labelStyle: '',
label: item.description,
arrowheadStyle: 'fill: #333',
labelpos: 'c',
labelType: 'text'
};
var startId = item.state1.id;
var endId = item.state2.id;
g.setEdge(startId, endId, edgeData, cnt);
cnt++;
}
});
};
/**
* Draws a flowchart in the tag with id: id based on the graph definition in text.
* @param text
* @param id
*/
var draw = function draw(text, id) {
_logger__WEBPACK_IMPORTED_MODULE_6__["logger"].info('Drawing state diagram (v2)', id);
_stateDb__WEBPACK_IMPORTED_MODULE_2__["default"].clear();
nodeDb = {};
var parser = _parser_stateDiagram__WEBPACK_IMPORTED_MODULE_3___default.a.parser;
parser.yy = _stateDb__WEBPACK_IMPORTED_MODULE_2__["default"]; // Parse the graph definition
try {
parser.parse(text);
} catch (err) {
_logger__WEBPACK_IMPORTED_MODULE_6__["logger"].debug('Parsing failed');
} // Fetch the default direction, use TD if none was found
var dir = _stateDb__WEBPACK_IMPORTED_MODULE_2__["default"].getDirection();
if (typeof dir === 'undefined') {
dir = 'LR';
}
var conf = Object(_config__WEBPACK_IMPORTED_MODULE_4__["getConfig"])().state;
var nodeSpacing = conf.nodeSpacing || 50;
var rankSpacing = conf.rankSpacing || 50; // Create the input mermaid.graph
var g = new graphlib__WEBPACK_IMPORTED_MODULE_0___default.a.Graph({
multigraph: true,
compound: true
}).setGraph({
rankdir: 'TB',
nodesep: nodeSpacing,
ranksep: rankSpacing,
marginx: 8,
marginy: 8
}).setDefaultEdgeLabel(function () {
return {};
});
_logger__WEBPACK_IMPORTED_MODULE_6__["logger"].info(_stateDb__WEBPACK_IMPORTED_MODULE_2__["default"].getRootDocV2());
_stateDb__WEBPACK_IMPORTED_MODULE_2__["default"].extract(_stateDb__WEBPACK_IMPORTED_MODULE_2__["default"].getRootDocV2());
_logger__WEBPACK_IMPORTED_MODULE_6__["logger"].info(_stateDb__WEBPACK_IMPORTED_MODULE_2__["default"].getRootDocV2());
setupNode(g, undefined, _stateDb__WEBPACK_IMPORTED_MODULE_2__["default"].getRootDocV2(), true); // Set up an SVG group so that we can translate the final graph.
var svg = Object(d3__WEBPACK_IMPORTED_MODULE_1__["select"])("[id=\"".concat(id, "\"]")); // Run the renderer. This is what draws the final graph.
var element = Object(d3__WEBPACK_IMPORTED_MODULE_1__["select"])('#' + id + ' g');
Object(_dagre_wrapper_index_js__WEBPACK_IMPORTED_MODULE_5__["render"])(element, g, ['barb'], 'statediagram', id);
var padding = 8; // const svgBounds = svg.node().getBBox();
// const width = svgBounds.width + padding * 2;
// const height = svgBounds.height + padding * 2;
// logger.debug(
// `new ViewBox 0 0 ${width} ${height}`,
// `translate(${padding + g._label.marginx}, ${padding + g._label.marginy})`
// );
// if (conf.useMaxWidth) {
// svg.attr('width', '100%');
// svg.attr('style', `max-width: ${width}px;`);
// } else {
// svg.attr('height', height);
// svg.attr('width', width);
// }
// svg.attr('viewBox', `0 0 ${width} ${height}`);
// svg
// .select('g')
// .attr('transform', `translate(${padding - g._label.marginx}, ${padding - svgBounds.y})`);
var bounds = svg.node().getBBox();
var width = bounds.width + padding * 2;
var height = bounds.height + padding * 2; // diagram.attr('height', '100%');
// diagram.attr('style', `width: ${bounds.width * 3 + conf.padding * 2};`);
// diagram.attr('height', height);
// Zoom in a bit
svg.attr('width', width * 1.75);
svg.attr('class', 'statediagram'); // diagram.attr('height', bounds.height * 3 + conf.padding * 2);
// svg.attr(
// 'viewBox',
// `${bounds.x - conf.padding} ${bounds.y - conf.padding} ` + width + ' ' + height
// );
var svgBounds = svg.node().getBBox();
if (conf.useMaxWidth) {
svg.attr('width', '100%');
svg.attr('style', "max-width: ".concat(width, "px;"));
} else {
svg.attr('height', height);
svg.attr('width', width);
} // Ensure the viewBox includes the whole svgBounds area with extra space for padding
var vBox = "".concat(svgBounds.x - padding, " ").concat(svgBounds.y - padding, " ").concat(width, " ").concat(height);
_logger__WEBPACK_IMPORTED_MODULE_6__["logger"].debug("viewBox ".concat(vBox));
svg.attr('viewBox', vBox); // Add label rects for non html labels
if (!conf.htmlLabels) {
var labels = document.querySelectorAll('[id="' + id + '"] .edgeLabel .label');
for (var k = 0; k < labels.length; k++) {
var label = labels[k]; // Get dimensions of label
var dim = label.getBBox();
var rect = document.createElementNS('http://www.w3.org/2000/svg', 'rect');
rect.setAttribute('rx', 0);
rect.setAttribute('ry', 0);
rect.setAttribute('width', dim.width);
rect.setAttribute('height', dim.height);
rect.setAttribute('style', 'fill:#e8e8e8;');
label.insertBefore(rect, label.firstChild);
}
}
};
/* harmony default export */ __webpack_exports__["default"] = ({
setConf: setConf,
getClasses: getClasses,
draw: draw
});
/***/ }),
/***/ "./src/diagrams/state/stateRenderer.js":
/*!*********************************************!*\
!*** ./src/diagrams/state/stateRenderer.js ***!
\*********************************************/
/*! exports provided: setConf, draw, default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "setConf", function() { return setConf; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "draw", function() { return draw; });
/* harmony import */ var d3__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! d3 */ "d3");
/* harmony import */ var d3__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(d3__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var dagre__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! dagre */ "dagre");
/* harmony import */ var dagre__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(dagre__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var graphlib__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! graphlib */ "graphlib");
/* harmony import */ var graphlib__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(graphlib__WEBPACK_IMPORTED_MODULE_2__);
/* harmony import */ var _logger__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../logger */ "./src/logger.js");
/* harmony import */ var _stateDb__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./stateDb */ "./src/diagrams/state/stateDb.js");
/* harmony import */ var _common_common__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../common/common */ "./src/diagrams/common/common.js");
/* harmony import */ var _parser_stateDiagram__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./parser/stateDiagram */ "./src/diagrams/state/parser/stateDiagram.jison");
/* harmony import */ var _parser_stateDiagram__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(_parser_stateDiagram__WEBPACK_IMPORTED_MODULE_6__);
/* harmony import */ var _shapes__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./shapes */ "./src/diagrams/state/shapes.js");
/* harmony import */ var _config__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../config */ "./src/config.js");
// import idCache from './id-cache';
_parser_stateDiagram__WEBPACK_IMPORTED_MODULE_6__["parser"].yy = _stateDb__WEBPACK_IMPORTED_MODULE_4__["default"]; // TODO Move conf object to main conf in mermaidAPI
var conf;
var transformationLog = {};
var setConf = function setConf() {}; // Todo optimize
/**
* Setup arrow head and define the marker. The result is appended to the svg.
*/
var insertMarkers = function insertMarkers(elem) {
elem.append('defs').append('marker').attr('id', 'dependencyEnd').attr('refX', 19).attr('refY', 7).attr('markerWidth', 20).attr('markerHeight', 28).attr('orient', 'auto').append('path').attr('d', 'M 19,7 L9,13 L14,7 L9,1 Z');
};
/**
* Draws a flowchart in the tag with id: id based on the graph definition in text.
* @param text
* @param id
*/
var draw = function draw(text, id) {
conf = Object(_config__WEBPACK_IMPORTED_MODULE_8__["getConfig"])().state;
_parser_stateDiagram__WEBPACK_IMPORTED_MODULE_6__["parser"].yy.clear();
_parser_stateDiagram__WEBPACK_IMPORTED_MODULE_6__["parser"].parse(text);
_logger__WEBPACK_IMPORTED_MODULE_3__["logger"].debug('Rendering diagram ' + text); // Fetch the default direction, use TD if none was found
var diagram = Object(d3__WEBPACK_IMPORTED_MODULE_0__["select"])("[id='".concat(id, "']"));
insertMarkers(diagram); // Layout graph, Create a new directed graph
var graph = new graphlib__WEBPACK_IMPORTED_MODULE_2___default.a.Graph({
multigraph: true,
compound: true,
// acyclicer: 'greedy',
rankdir: 'RL' // ranksep: '20'
}); // Default to assigning a new object as a label for each new edge.
graph.setDefaultEdgeLabel(function () {
return {};
});
var rootDoc = _stateDb__WEBPACK_IMPORTED_MODULE_4__["default"].getRootDoc();
renderDoc(rootDoc, diagram, undefined, false);
var padding = conf.padding;
var bounds = diagram.node().getBBox();
var width = bounds.width + padding * 2;
var height = bounds.height + padding * 2;
if (conf.useMaxWidth) {
diagram.attr('width', '100%');
diagram.attr('style', "max-width: ".concat(width * 1.75, "px;"));
} else {
// Zoom in a bit
diagram.attr('width', width * 1.75);
} // diagram.attr('height', bounds.height * 3 + conf.padding * 2);
diagram.attr('viewBox', "".concat(bounds.x - conf.padding, " ").concat(bounds.y - conf.padding, " ") + width + ' ' + height);
};
var getLabelWidth = function getLabelWidth(text) {
return text ? text.length * conf.fontSizeFactor : 1;
};
var renderDoc = function renderDoc(doc, diagram, parentId, altBkg) {
// // Layout graph, Create a new directed graph
var graph = new graphlib__WEBPACK_IMPORTED_MODULE_2___default.a.Graph({
compound: true,
multigraph: true
});
var i;
var edgeFreeDoc = true;
for (i = 0; i < doc.length; i++) {
if (doc[i].stmt === 'relation') {
edgeFreeDoc = false;
break;
}
} // Set an object for the graph label
if (parentId) graph.setGraph({
rankdir: 'LR',
multigraph: true,
compound: true,
// acyclicer: 'greedy',
ranker: 'tight-tree',
ranksep: edgeFreeDoc ? 1 : conf.edgeLengthFactor,
nodeSep: edgeFreeDoc ? 1 : 50,
isMultiGraph: true // ranksep: 5,
// nodesep: 1
});else {
graph.setGraph({
rankdir: 'TB',
multigraph: true,
compound: true,
// isCompound: true,
// acyclicer: 'greedy',
// ranker: 'longest-path'
ranksep: edgeFreeDoc ? 1 : conf.edgeLengthFactor,
nodeSep: edgeFreeDoc ? 1 : 50,
ranker: 'tight-tree',
// ranker: 'network-simplex'
isMultiGraph: true
});
} // Default to assigning a new object as a label for each new edge.
graph.setDefaultEdgeLabel(function () {
return {};
});
_stateDb__WEBPACK_IMPORTED_MODULE_4__["default"].extract(doc);
var states = _stateDb__WEBPACK_IMPORTED_MODULE_4__["default"].getStates();
var relations = _stateDb__WEBPACK_IMPORTED_MODULE_4__["default"].getRelations();
var keys = Object.keys(states);
var first = true;
for (var _i = 0; _i < keys.length; _i++) {
var stateDef = states[keys[_i]];
if (parentId) {
stateDef.parentId = parentId;
}
var node = void 0;
if (stateDef.doc) {
var sub = diagram.append('g').attr('id', stateDef.id).attr('class', 'stateGroup');
node = renderDoc(stateDef.doc, sub, stateDef.id, !altBkg);
if (first) {
// first = false;
sub = Object(_shapes__WEBPACK_IMPORTED_MODULE_7__["addTitleAndBox"])(sub, stateDef, altBkg);
var boxBounds = sub.node().getBBox();
node.width = boxBounds.width;
node.height = boxBounds.height + conf.padding / 2;
transformationLog[stateDef.id] = {
y: conf.compositTitleSize
};
} else {
// sub = addIdAndBox(sub, stateDef);
var _boxBounds = sub.node().getBBox();
node.width = _boxBounds.width;
node.height = _boxBounds.height; // transformationLog[stateDef.id] = { y: conf.compositTitleSize };
}
} else {
node = Object(_shapes__WEBPACK_IMPORTED_MODULE_7__["drawState"])(diagram, stateDef, graph);
}
if (stateDef.note) {
// Draw note note
var noteDef = {
descriptions: [],
id: stateDef.id + '-note',
note: stateDef.note,
type: 'note'
};
var note = Object(_shapes__WEBPACK_IMPORTED_MODULE_7__["drawState"])(diagram, noteDef, graph); // graph.setNode(node.id, node);
if (stateDef.note.position === 'left of') {
graph.setNode(node.id + '-note', note);
graph.setNode(node.id, node);
} else {
graph.setNode(node.id, node);
graph.setNode(node.id + '-note', note);
} // graph.setNode(node.id);
graph.setParent(node.id, node.id + '-group');
graph.setParent(node.id + '-note', node.id + '-group');
} else {
// Add nodes to the graph. The first argument is the node id. The second is
// metadata about the node. In this case we're going to add labels to each of
// our nodes.
graph.setNode(node.id, node);
}
}
_logger__WEBPACK_IMPORTED_MODULE_3__["logger"].debug('Count=', graph.nodeCount(), graph);
var cnt = 0;
relations.forEach(function (relation) {
cnt++;
_logger__WEBPACK_IMPORTED_MODULE_3__["logger"].debug('Setting edge', relation);
graph.setEdge(relation.id1, relation.id2, {
relation: relation,
width: getLabelWidth(relation.title),
height: conf.labelHeight * _common_common__WEBPACK_IMPORTED_MODULE_5__["default"].getRows(relation.title).length,
labelpos: 'c'
}, 'id' + cnt);
});
dagre__WEBPACK_IMPORTED_MODULE_1___default.a.layout(graph);
_logger__WEBPACK_IMPORTED_MODULE_3__["logger"].debug('Graph after layout', graph.nodes());
var svgElem = diagram.node();
graph.nodes().forEach(function (v) {
if (typeof v !== 'undefined' && typeof graph.node(v) !== 'undefined') {
_logger__WEBPACK_IMPORTED_MODULE_3__["logger"].warn('Node ' + v + ': ' + JSON.stringify(graph.node(v)));
Object(d3__WEBPACK_IMPORTED_MODULE_0__["select"])('#' + svgElem.id + ' #' + v).attr('transform', 'translate(' + (graph.node(v).x - graph.node(v).width / 2) + ',' + (graph.node(v).y + (transformationLog[v] ? transformationLog[v].y : 0) - graph.node(v).height / 2) + ' )');
Object(d3__WEBPACK_IMPORTED_MODULE_0__["select"])('#' + svgElem.id + ' #' + v).attr('data-x-shift', graph.node(v).x - graph.node(v).width / 2);
var dividers = document.querySelectorAll('#' + svgElem.id + ' #' + v + ' .divider');
dividers.forEach(function (divider) {
var parent = divider.parentElement;
var pWidth = 0;
var pShift = 0;
if (parent) {
if (parent.parentElement) pWidth = parent.parentElement.getBBox().width;
pShift = parseInt(parent.getAttribute('data-x-shift'), 10);
if (Number.isNaN(pShift)) {
pShift = 0;
}
}
divider.setAttribute('x1', 0 - pShift + 8);
divider.setAttribute('x2', pWidth - pShift - 8);
});
} else {
_logger__WEBPACK_IMPORTED_MODULE_3__["logger"].debug('No Node ' + v + ': ' + JSON.stringify(graph.node(v)));
}
});
var stateBox = svgElem.getBBox();
graph.edges().forEach(function (e) {
if (typeof e !== 'undefined' && typeof graph.edge(e) !== 'undefined') {
_logger__WEBPACK_IMPORTED_MODULE_3__["logger"].debug('Edge ' + e.v + ' -> ' + e.w + ': ' + JSON.stringify(graph.edge(e)));
Object(_shapes__WEBPACK_IMPORTED_MODULE_7__["drawEdge"])(diagram, graph.edge(e), graph.edge(e).relation);
}
});
stateBox = svgElem.getBBox();
var stateInfo = {
id: parentId ? parentId : 'root',
label: parentId ? parentId : 'root',
width: 0,
height: 0
};
stateInfo.width = stateBox.width + 2 * conf.padding;
stateInfo.height = stateBox.height + 2 * conf.padding;
_logger__WEBPACK_IMPORTED_MODULE_3__["logger"].debug('Doc rendered', stateInfo, graph);
return stateInfo;
};
/* harmony default export */ __webpack_exports__["default"] = ({
setConf: setConf,
draw: draw
});
/***/ }),
/***/ "./src/diagrams/user-journey/journeyDb.js":
/*!************************************************!*\
!*** ./src/diagrams/user-journey/journeyDb.js ***!
\************************************************/
/*! exports provided: clear, setTitle, getTitle, addSection, getSections, getTasks, addTask, addTaskOrg, default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clear", function() { return clear; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "setTitle", function() { return setTitle; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getTitle", function() { return getTitle; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "addSection", function() { return addSection; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getSections", function() { return getSections; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getTasks", function() { return getTasks; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "addTask", function() { return addTask; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "addTaskOrg", function() { return addTaskOrg; });
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
var title = '';
var currentSection = '';
var sections = [];
var tasks = [];
var rawTasks = [];
var clear = function clear() {
sections.length = 0;
tasks.length = 0;
currentSection = '';
title = '';
rawTasks.length = 0;
};
var setTitle = function setTitle(txt) {
title = txt;
};
var getTitle = function getTitle() {
return title;
};
var addSection = function addSection(txt) {
currentSection = txt;
sections.push(txt);
};
var getSections = function getSections() {
return sections;
};
var getTasks = function getTasks() {
var allItemsProcessed = compileTasks();
var maxDepth = 100;
var iterationCount = 0;
while (!allItemsProcessed && iterationCount < maxDepth) {
allItemsProcessed = compileTasks();
iterationCount++;
}
tasks.push.apply(tasks, rawTasks);
return tasks;
};
var updateActors = function updateActors() {
var tempActors = [];
tasks.forEach(function (task) {
if (task.people) {
tempActors.push.apply(tempActors, _toConsumableArray(task.people));
}
});
var unique = new Set(tempActors);
return _toConsumableArray(unique).sort();
};
var addTask = function addTask(descr, taskData) {
var pieces = taskData.substr(1).split(':');
var score = 0;
var peeps = [];
if (pieces.length === 1) {
score = Number(pieces[0]);
peeps = [];
} else {
score = Number(pieces[0]);
peeps = pieces[1].split(',');
}
var peopleList = peeps.map(function (s) {
return s.trim();
});
var rawTask = {
section: currentSection,
type: currentSection,
people: peopleList,
task: descr,
score: score
};
rawTasks.push(rawTask);
};
var addTaskOrg = function addTaskOrg(descr) {
var newTask = {
section: currentSection,
type: currentSection,
description: descr,
task: descr,
classes: []
};
tasks.push(newTask);
};
var compileTasks = function compileTasks() {
var compileTask = function compileTask(pos) {
return rawTasks[pos].processed;
};
var allProcessed = true;
for (var i = 0; i < rawTasks.length; i++) {
compileTask(i);
allProcessed = allProcessed && rawTasks[i].processed;
}
return allProcessed;
};
var getActors = function getActors() {
return updateActors();
};
/* harmony default export */ __webpack_exports__["default"] = ({
clear: clear,
setTitle: setTitle,
getTitle: getTitle,
addSection: addSection,
getSections: getSections,
getTasks: getTasks,
addTask: addTask,
addTaskOrg: addTaskOrg,
getActors: getActors
});
/***/ }),
/***/ "./src/diagrams/user-journey/journeyRenderer.js":
/*!******************************************************!*\
!*** ./src/diagrams/user-journey/journeyRenderer.js ***!
\******************************************************/
/*! exports provided: setConf, draw, bounds, drawTasks, default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "setConf", function() { return setConf; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "draw", function() { return draw; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bounds", function() { return bounds; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "drawTasks", function() { return drawTasks; });
/* harmony import */ var d3__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! d3 */ "d3");
/* harmony import */ var d3__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(d3__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _parser_journey__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./parser/journey */ "./src/diagrams/user-journey/parser/journey.jison");
/* harmony import */ var _parser_journey__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_parser_journey__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var _journeyDb__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./journeyDb */ "./src/diagrams/user-journey/journeyDb.js");
/* harmony import */ var _svgDraw__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./svgDraw */ "./src/diagrams/user-journey/svgDraw.js");
_parser_journey__WEBPACK_IMPORTED_MODULE_1__["parser"].yy = _journeyDb__WEBPACK_IMPORTED_MODULE_2__["default"];
var conf = {
leftMargin: 150,
diagramMarginX: 50,
diagramMarginY: 20,
// Margin between tasks
taskMargin: 50,
// Width of task boxes
width: 150,
// Height of task boxes
height: 50,
taskFontSize: 14,
taskFontFamily: '"Open-Sans", "sans-serif"',
// Margin around loop boxes
boxMargin: 10,
boxTextMargin: 5,
noteMargin: 10,
// Space between messages
messageMargin: 35,
// Multiline message alignment
messageAlign: 'center',
// Depending on css styling this might need adjustment
// Projects the edge of the diagram downwards
bottomMarginAdj: 1,
// width of activation box
activationWidth: 10,
// text placement as: tspan | fo | old only text as before
textPlacement: 'fo',
actorColours: ['#8FBC8F', '#7CFC00', '#00FFFF', '#20B2AA', '#B0E0E6', '#FFFFE0'],
sectionFills: ['#191970', '#8B008B', '#4B0082', '#2F4F4F', '#800000', '#8B4513', '#00008B'],
sectionColours: ['#fff']
};
var setConf = function setConf(cnf) {
var keys = Object.keys(cnf);
keys.forEach(function (key) {
conf[key] = cnf[key];
});
};
var actors = {};
function drawActorLegend(diagram) {
// Draw the actors
var yPos = 60;
Object.keys(actors).forEach(function (person) {
var colour = actors[person];
var circleData = {
cx: 20,
cy: yPos,
r: 7,
fill: colour,
stroke: '#000'
};
_svgDraw__WEBPACK_IMPORTED_MODULE_3__["default"].drawCircle(diagram, circleData);
var labelData = {
x: 40,
y: yPos + 7,
fill: '#666',
text: person
};
_svgDraw__WEBPACK_IMPORTED_MODULE_3__["default"].drawText(diagram, labelData);
yPos += 20;
});
}
var LEFT_MARGIN = conf.leftMargin;
var draw = function draw(text, id) {
_parser_journey__WEBPACK_IMPORTED_MODULE_1__["parser"].yy.clear();
_parser_journey__WEBPACK_IMPORTED_MODULE_1__["parser"].parse(text + '\n');
bounds.init();
var diagram = Object(d3__WEBPACK_IMPORTED_MODULE_0__["select"])('#' + id);
diagram.attr('xmlns:xlink', 'http://www.w3.org/1999/xlink');
_svgDraw__WEBPACK_IMPORTED_MODULE_3__["default"].initGraphics(diagram);
var tasks = _parser_journey__WEBPACK_IMPORTED_MODULE_1__["parser"].yy.getTasks();
var title = _parser_journey__WEBPACK_IMPORTED_MODULE_1__["parser"].yy.getTitle();
var actorNames = _parser_journey__WEBPACK_IMPORTED_MODULE_1__["parser"].yy.getActors();
for (var member in actors) {
delete actors[member];
}
var actorPos = 0;
actorNames.forEach(function (actorName) {
actors[actorName] = conf.actorColours[actorPos % conf.actorColours.length];
actorPos++;
});
drawActorLegend(diagram);
bounds.insert(0, 0, LEFT_MARGIN, Object.keys(actors).length * 50);
drawTasks(diagram, tasks, 0);
var box = bounds.getBounds();
if (title) {
diagram.append('text').text(title).attr('x', LEFT_MARGIN).attr('font-size', '4ex').attr('font-weight', 'bold').attr('y', 25);
}
var height = box.stopy - box.starty + 2 * conf.diagramMarginY;
var width = LEFT_MARGIN + box.stopx + 2 * conf.diagramMarginX;
if (conf.useMaxWidth) {
diagram.attr('height', '100%');
diagram.attr('width', '100%');
diagram.attr('style', 'max-width:' + width + 'px;');
} else {
diagram.attr('height', height);
diagram.attr('width', width);
} // Draw activity line
diagram.append('line').attr('x1', LEFT_MARGIN).attr('y1', conf.height * 4) // One section head + one task + margins
.attr('x2', width - LEFT_MARGIN - 4) // Subtract stroke width so arrow point is retained
.attr('y2', conf.height * 4).attr('stroke-width', 4).attr('stroke', 'black').attr('marker-end', 'url(#arrowhead)');
var extraVertForTitle = title ? 70 : 0;
diagram.attr('viewBox', "".concat(box.startx, " -25 ").concat(width, " ").concat(height + extraVertForTitle));
diagram.attr('preserveAspectRatio', 'xMinYMin meet');
};
var bounds = {
data: {
startx: undefined,
stopx: undefined,
starty: undefined,
stopy: undefined
},
verticalPos: 0,
sequenceItems: [],
init: function init() {
this.sequenceItems = [];
this.data = {
startx: undefined,
stopx: undefined,
starty: undefined,
stopy: undefined
};
this.verticalPos = 0;
},
updateVal: function updateVal(obj, key, val, fun) {
if (typeof obj[key] === 'undefined') {
obj[key] = val;
} else {
obj[key] = fun(val, obj[key]);
}
},
updateBounds: function updateBounds(startx, starty, stopx, stopy) {
var _self = this;
var cnt = 0;
function updateFn(type) {
return function updateItemBounds(item) {
cnt++; // The loop sequenceItems is a stack so the biggest margins in the beginning of the sequenceItems
var n = _self.sequenceItems.length - cnt + 1;
_self.updateVal(item, 'starty', starty - n * conf.boxMargin, Math.min);
_self.updateVal(item, 'stopy', stopy + n * conf.boxMargin, Math.max);
_self.updateVal(bounds.data, 'startx', startx - n * conf.boxMargin, Math.min);
_self.updateVal(bounds.data, 'stopx', stopx + n * conf.boxMargin, Math.max);
if (!(type === 'activation')) {
_self.updateVal(item, 'startx', startx - n * conf.boxMargin, Math.min);
_self.updateVal(item, 'stopx', stopx + n * conf.boxMargin, Math.max);
_self.updateVal(bounds.data, 'starty', starty - n * conf.boxMargin, Math.min);
_self.updateVal(bounds.data, 'stopy', stopy + n * conf.boxMargin, Math.max);
}
};
}
this.sequenceItems.forEach(updateFn());
},
insert: function insert(startx, starty, stopx, stopy) {
var _startx = Math.min(startx, stopx);
var _stopx = Math.max(startx, stopx);
var _starty = Math.min(starty, stopy);
var _stopy = Math.max(starty, stopy);
this.updateVal(bounds.data, 'startx', _startx, Math.min);
this.updateVal(bounds.data, 'starty', _starty, Math.min);
this.updateVal(bounds.data, 'stopx', _stopx, Math.max);
this.updateVal(bounds.data, 'stopy', _stopy, Math.max);
this.updateBounds(_startx, _starty, _stopx, _stopy);
},
bumpVerticalPos: function bumpVerticalPos(bump) {
this.verticalPos = this.verticalPos + bump;
this.data.stopy = this.verticalPos;
},
getVerticalPos: function getVerticalPos() {
return this.verticalPos;
},
getBounds: function getBounds() {
return this.data;
}
};
var fills = conf.sectionFills;
var textColours = conf.sectionColours;
var drawTasks = function drawTasks(diagram, tasks, verticalPos) {
var lastSection = '';
var sectionVHeight = conf.height * 2 + conf.diagramMarginY;
var taskPos = verticalPos + sectionVHeight;
var sectionNumber = 0;
var fill = '#CCC';
var colour = 'black'; // Draw the tasks
for (var i = 0; i < tasks.length; i++) {
var task = tasks[i];
if (lastSection !== task.section) {
fill = fills[sectionNumber % fills.length];
colour = textColours[sectionNumber % textColours.length];
var section = {
x: i * conf.taskMargin + i * conf.width + LEFT_MARGIN,
y: 50,
text: task.section,
fill: fill,
colour: colour
};
_svgDraw__WEBPACK_IMPORTED_MODULE_3__["default"].drawSection(diagram, section, conf);
lastSection = task.section;
sectionNumber++;
} // Collect the actors involved in the task
var taskActors = task.people.reduce(function (acc, actorName) {
if (actors[actorName]) {
acc[actorName] = actors[actorName];
}
return acc;
}, {}); // Add some rendering data to the object
task.x = i * conf.taskMargin + i * conf.width + LEFT_MARGIN;
task.y = taskPos;
task.width = conf.diagramMarginX;
task.height = conf.diagramMarginY;
task.colour = colour;
task.fill = fill;
task.actors = taskActors; // Draw the box with the attached line
_svgDraw__WEBPACK_IMPORTED_MODULE_3__["default"].drawTask(diagram, task, conf);
bounds.insert(task.x, task.y, task.x + task.width + conf.taskMargin, 300 + 5 * 30); // stopy is the length of the descenders.
}
};
/* harmony default export */ __webpack_exports__["default"] = ({
setConf: setConf,
draw: draw
});
/***/ }),
/***/ "./src/diagrams/user-journey/parser/journey.jison":
/*!********************************************************!*\
!*** ./src/diagrams/user-journey/parser/journey.jison ***!
\********************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
/* WEBPACK VAR INJECTION */(function(process, module) {/* parser generated by jison 0.4.18 */
/*
Returns a Parser object of the following structure:
Parser: {
yy: {}
}
Parser.prototype: {
yy: {},
trace: function(),
symbols_: {associative list: name ==> number},
terminals_: {associative list: number ==> name},
productions_: [...],
performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$),
table: [...],
defaultActions: {...},
parseError: function(str, hash),
parse: function(input),
lexer: {
EOF: 1,
parseError: function(str, hash),
setInput: function(input),
input: function(),
unput: function(str),
more: function(),
less: function(n),
pastInput: function(),
upcomingInput: function(),
showPosition: function(),
test_match: function(regex_match_array, rule_index),
next: function(),
lex: function(),
begin: function(condition),
popState: function(),
_currentRules: function(),
topState: function(),
pushState: function(condition),
options: {
ranges: boolean (optional: true ==> token location info will include a .range[] member)
flex: boolean (optional: true ==> flex-like lexing behaviour where the rules are tested exhaustively to find the longest match)
backtrack_lexer: boolean (optional: true ==> lexer regexes are tested in order and for each matching regex the action code is invoked; the lexer terminates the scan when a token is returned by the action code)
},
performAction: function(yy, yy_, $avoiding_name_collisions, YY_START),
rules: [...],
conditions: {associative list: name ==> set},
}
}
token location info (@$, _$, etc.): {
first_line: n,
last_line: n,
first_column: n,
last_column: n,
range: [start_number, end_number] (where the numbers are indexes into the input string, regular zero-based)
}
the parseError function receives a 'hash' object with these members for lexer and parser errors: {
text: (matched text)
token: (the produced terminal token, if any)
line: (yylineno)
}
while parser (grammar) errors will also provide these members, i.e. parser errors deliver a superset of attributes: {
loc: (yylloc)
expected: (string describing the set of expected tokens)
recoverable: (boolean: TRUE when the parser has a error recovery rule available for this particular error)
}
*/
var parser = (function(){
var o=function(k,v,o,l){for(o=o||{},l=k.length;l--;o[k[l]]=v);return o},$V0=[6,8,10,11,12,13],$V1=[1,9],$V2=[1,10],$V3=[1,11];
var parser = {trace: function trace () { },
yy: {},
symbols_: {"error":2,"start":3,"journey":4,"document":5,"EOF":6,"line":7,"SPACE":8,"statement":9,"NL":10,"title":11,"section":12,"taskName":13,"taskData":14,"$accept":0,"$end":1},
terminals_: {2:"error",4:"journey",6:"EOF",8:"SPACE",10:"NL",11:"title",12:"section",13:"taskName",14:"taskData"},
productions_: [0,[3,3],[5,0],[5,2],[7,2],[7,1],[7,1],[7,1],[9,1],[9,1],[9,2]],
performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate /* action[1] */, $$ /* vstack */, _$ /* lstack */) {
/* this == yyval */
var $0 = $$.length - 1;
switch (yystate) {
case 1:
return $$[$0-1];
break;
case 2:
this.$ = []
break;
case 3:
$$[$0-1].push($$[$0]);this.$ = $$[$0-1]
break;
case 4: case 5:
this.$ = $$[$0]
break;
case 6: case 7:
this.$=[];
break;
case 8:
yy.setTitle($$[$0].substr(6));this.$=$$[$0].substr(6);
break;
case 9:
yy.addSection($$[$0].substr(8));this.$=$$[$0].substr(8);
break;
case 10:
yy.addTask($$[$0-1], $$[$0]);this.$='task';
break;
}
},
table: [{3:1,4:[1,2]},{1:[3]},o($V0,[2,2],{5:3}),{6:[1,4],7:5,8:[1,6],9:7,10:[1,8],11:$V1,12:$V2,13:$V3},o($V0,[2,7],{1:[2,1]}),o($V0,[2,3]),{9:12,11:$V1,12:$V2,13:$V3},o($V0,[2,5]),o($V0,[2,6]),o($V0,[2,8]),o($V0,[2,9]),{14:[1,13]},o($V0,[2,4]),o($V0,[2,10])],
defaultActions: {},
parseError: function parseError (str, hash) {
if (hash.recoverable) {
this.trace(str);
} else {
var error = new Error(str);
error.hash = hash;
throw error;
}
},
parse: function parse(input) {
var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = '', yylineno = 0, yyleng = 0, recovering = 0, TERROR = 2, EOF = 1;
var args = lstack.slice.call(arguments, 1);
var lexer = Object.create(this.lexer);
var sharedState = { yy: {} };
for (var k in this.yy) {
if (Object.prototype.hasOwnProperty.call(this.yy, k)) {
sharedState.yy[k] = this.yy[k];
}
}
lexer.setInput(input, sharedState.yy);
sharedState.yy.lexer = lexer;
sharedState.yy.parser = this;
if (typeof lexer.yylloc == 'undefined') {
lexer.yylloc = {};
}
var yyloc = lexer.yylloc;
lstack.push(yyloc);
var ranges = lexer.options && lexer.options.ranges;
if (typeof sharedState.yy.parseError === 'function') {
this.parseError = sharedState.yy.parseError;
} else {
this.parseError = Object.getPrototypeOf(this).parseError;
}
function popStack(n) {
stack.length = stack.length - 2 * n;
vstack.length = vstack.length - n;
lstack.length = lstack.length - n;
}
function lex() {
var token;
token = tstack.pop() || lexer.lex() || EOF;
if (typeof token !== 'number') {
if (token instanceof Array) {
tstack = token;
token = tstack.pop();
}
token = self.symbols_[token] || token;
}
return token;
}
var symbol, preErrorSymbol, state, action, a, r, yyval = {}, p, len, newState, expected;
while (true) {
state = stack[stack.length - 1];
if (this.defaultActions[state]) {
action = this.defaultActions[state];
} else {
if (symbol === null || typeof symbol == 'undefined') {
symbol = lex();
}
action = table[state] && table[state][symbol];
}
if (typeof action === 'undefined' || !action.length || !action[0]) {
var errStr = '';
expected = [];
for (p in table[state]) {
if (this.terminals_[p] && p > TERROR) {
expected.push('\'' + this.terminals_[p] + '\'');
}
}
if (lexer.showPosition) {
errStr = 'Parse error on line ' + (yylineno + 1) + ':\n' + lexer.showPosition() + '\nExpecting ' + expected.join(', ') + ', got \'' + (this.terminals_[symbol] || symbol) + '\'';
} else {
errStr = 'Parse error on line ' + (yylineno + 1) + ': Unexpected ' + (symbol == EOF ? 'end of input' : '\'' + (this.terminals_[symbol] || symbol) + '\'');
}
this.parseError(errStr, {
text: lexer.match,
token: this.terminals_[symbol] || symbol,
line: lexer.yylineno,
loc: yyloc,
expected: expected
});
}
if (action[0] instanceof Array && action.length > 1) {
throw new Error('Parse Error: multiple actions possible at state: ' + state + ', token: ' + symbol);
}
switch (action[0]) {
case 1:
stack.push(symbol);
vstack.push(lexer.yytext);
lstack.push(lexer.yylloc);
stack.push(action[1]);
symbol = null;
if (!preErrorSymbol) {
yyleng = lexer.yyleng;
yytext = lexer.yytext;
yylineno = lexer.yylineno;
yyloc = lexer.yylloc;
if (recovering > 0) {
recovering--;
}
} else {
symbol = preErrorSymbol;
preErrorSymbol = null;
}
break;
case 2:
len = this.productions_[action[1]][1];
yyval.$ = vstack[vstack.length - len];
yyval._$ = {
first_line: lstack[lstack.length - (len || 1)].first_line,
last_line: lstack[lstack.length - 1].last_line,
first_column: lstack[lstack.length - (len || 1)].first_column,
last_column: lstack[lstack.length - 1].last_column
};
if (ranges) {
yyval._$.range = [
lstack[lstack.length - (len || 1)].range[0],
lstack[lstack.length - 1].range[1]
];
}
r = this.performAction.apply(yyval, [
yytext,
yyleng,
yylineno,
sharedState.yy,
action[1],
vstack,
lstack
].concat(args));
if (typeof r !== 'undefined') {
return r;
}
if (len) {
stack = stack.slice(0, -1 * len * 2);
vstack = vstack.slice(0, -1 * len);
lstack = lstack.slice(0, -1 * len);
}
stack.push(this.productions_[action[1]][0]);
vstack.push(yyval.$);
lstack.push(yyval._$);
newState = table[stack[stack.length - 2]][stack[stack.length - 1]];
stack.push(newState);
break;
case 3:
return true;
}
}
return true;
}};
/* generated by jison-lex 0.3.4 */
var lexer = (function(){
var lexer = ({
EOF:1,
parseError:function parseError(str, hash) {
if (this.yy.parser) {
this.yy.parser.parseError(str, hash);
} else {
throw new Error(str);
}
},
// resets the lexer, sets new input
setInput:function (input, yy) {
this.yy = yy || this.yy || {};
this._input = input;
this._more = this._backtrack = this.done = false;
this.yylineno = this.yyleng = 0;
this.yytext = this.matched = this.match = '';
this.conditionStack = ['INITIAL'];
this.yylloc = {
first_line: 1,
first_column: 0,
last_line: 1,
last_column: 0
};
if (this.options.ranges) {
this.yylloc.range = [0,0];
}
this.offset = 0;
return this;
},
// consumes and returns one char from the input
input:function () {
var ch = this._input[0];
this.yytext += ch;
this.yyleng++;
this.offset++;
this.match += ch;
this.matched += ch;
var lines = ch.match(/(?:\r\n?|\n).*/g);
if (lines) {
this.yylineno++;
this.yylloc.last_line++;
} else {
this.yylloc.last_column++;
}
if (this.options.ranges) {
this.yylloc.range[1]++;
}
this._input = this._input.slice(1);
return ch;
},
// unshifts one char (or a string) into the input
unput:function (ch) {
var len = ch.length;
var lines = ch.split(/(?:\r\n?|\n)/g);
this._input = ch + this._input;
this.yytext = this.yytext.substr(0, this.yytext.length - len);
//this.yyleng -= len;
this.offset -= len;
var oldLines = this.match.split(/(?:\r\n?|\n)/g);
this.match = this.match.substr(0, this.match.length - 1);
this.matched = this.matched.substr(0, this.matched.length - 1);
if (lines.length - 1) {
this.yylineno -= lines.length - 1;
}
var r = this.yylloc.range;
this.yylloc = {
first_line: this.yylloc.first_line,
last_line: this.yylineno + 1,
first_column: this.yylloc.first_column,
last_column: lines ?
(lines.length === oldLines.length ? this.yylloc.first_column : 0)
+ oldLines[oldLines.length - lines.length].length - lines[0].length :
this.yylloc.first_column - len
};
if (this.options.ranges) {
this.yylloc.range = [r[0], r[0] + this.yyleng - len];
}
this.yyleng = this.yytext.length;
return this;
},
// When called from action, caches matched text and appends it on next action
more:function () {
this._more = true;
return this;
},
// When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead.
reject:function () {
if (this.options.backtrack_lexer) {
this._backtrack = true;
} else {
return this.parseError('Lexical error on line ' + (this.yylineno + 1) + '. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n' + this.showPosition(), {
text: "",
token: null,
line: this.yylineno
});
}
return this;
},
// retain first n characters of the match
less:function (n) {
this.unput(this.match.slice(n));
},
// displays already matched input, i.e. for error messages
pastInput:function () {
var past = this.matched.substr(0, this.matched.length - this.match.length);
return (past.length > 20 ? '...':'') + past.substr(-20).replace(/\n/g, "");
},
// displays upcoming input, i.e. for error messages
upcomingInput:function () {
var next = this.match;
if (next.length < 20) {
next += this._input.substr(0, 20-next.length);
}
return (next.substr(0,20) + (next.length > 20 ? '...' : '')).replace(/\n/g, "");
},
// displays the character position where the lexing error occurred, i.e. for error messages
showPosition:function () {
var pre = this.pastInput();
var c = new Array(pre.length + 1).join("-");
return pre + this.upcomingInput() + "\n" + c + "^";
},
// test the lexed token: return FALSE when not a match, otherwise return token
test_match:function(match, indexed_rule) {
var token,
lines,
backup;
if (this.options.backtrack_lexer) {
// save context
backup = {
yylineno: this.yylineno,
yylloc: {
first_line: this.yylloc.first_line,
last_line: this.last_line,
first_column: this.yylloc.first_column,
last_column: this.yylloc.last_column
},
yytext: this.yytext,
match: this.match,
matches: this.matches,
matched: this.matched,
yyleng: this.yyleng,
offset: this.offset,
_more: this._more,
_input: this._input,
yy: this.yy,
conditionStack: this.conditionStack.slice(0),
done: this.done
};
if (this.options.ranges) {
backup.yylloc.range = this.yylloc.range.slice(0);
}
}
lines = match[0].match(/(?:\r\n?|\n).*/g);
if (lines) {
this.yylineno += lines.length;
}
this.yylloc = {
first_line: this.yylloc.last_line,
last_line: this.yylineno + 1,
first_column: this.yylloc.last_column,
last_column: lines ?
lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length :
this.yylloc.last_column + match[0].length
};
this.yytext += match[0];
this.match += match[0];
this.matches = match;
this.yyleng = this.yytext.length;
if (this.options.ranges) {
this.yylloc.range = [this.offset, this.offset += this.yyleng];
}
this._more = false;
this._backtrack = false;
this._input = this._input.slice(match[0].length);
this.matched += match[0];
token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]);
if (this.done && this._input) {
this.done = false;
}
if (token) {
return token;
} else if (this._backtrack) {
// recover context
for (var k in backup) {
this[k] = backup[k];
}
return false; // rule action called reject() implying the next rule should be tested instead.
}
return false;
},
// return next match in input
next:function () {
if (this.done) {
return this.EOF;
}
if (!this._input) {
this.done = true;
}
var token,
match,
tempMatch,
index;
if (!this._more) {
this.yytext = '';
this.match = '';
}
var rules = this._currentRules();
for (var i = 0; i < rules.length; i++) {
tempMatch = this._input.match(this.rules[rules[i]]);
if (tempMatch && (!match || tempMatch[0].length > match[0].length)) {
match = tempMatch;
index = i;
if (this.options.backtrack_lexer) {
token = this.test_match(tempMatch, rules[i]);
if (token !== false) {
return token;
} else if (this._backtrack) {
match = false;
continue; // rule action called reject() implying a rule MISmatch.
} else {
// else: this is a lexer rule which consumes input without producing a token (e.g. whitespace)
return false;
}
} else if (!this.options.flex) {
break;
}
}
}
if (match) {
token = this.test_match(match, rules[index]);
if (token !== false) {
return token;
}
// else: this is a lexer rule which consumes input without producing a token (e.g. whitespace)
return false;
}
if (this._input === "") {
return this.EOF;
} else {
return this.parseError('Lexical error on line ' + (this.yylineno + 1) + '. Unrecognized text.\n' + this.showPosition(), {
text: "",
token: null,
line: this.yylineno
});
}
},
// return next match that has a token
lex:function lex () {
var r = this.next();
if (r) {
return r;
} else {
return this.lex();
}
},
// activates a new lexer condition state (pushes the new lexer condition state onto the condition stack)
begin:function begin (condition) {
this.conditionStack.push(condition);
},
// pop the previously active lexer condition state off the condition stack
popState:function popState () {
var n = this.conditionStack.length - 1;
if (n > 0) {
return this.conditionStack.pop();
} else {
return this.conditionStack[0];
}
},
// produce the lexer rule set which is active for the currently active lexer condition state
_currentRules:function _currentRules () {
if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) {
return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules;
} else {
return this.conditions["INITIAL"].rules;
}
},
// return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available
topState:function topState (n) {
n = this.conditionStack.length - 1 - Math.abs(n || 0);
if (n >= 0) {
return this.conditionStack[n];
} else {
return "INITIAL";
}
},
// alias for begin(condition)
pushState:function pushState (condition) {
this.begin(condition);
},
// return the number of states currently on the stack
stateStackSize:function stateStackSize() {
return this.conditionStack.length;
},
options: {"case-insensitive":true},
performAction: function anonymous(yy,yy_,$avoiding_name_collisions,YY_START) {
var YYSTATE=YY_START;
switch($avoiding_name_collisions) {
case 0:return 10;
break;
case 1:/* skip whitespace */
break;
case 2:/* skip comments */
break;
case 3:/* skip comments */
break;
case 4:return 4;
break;
case 5:return 11;
break;
case 6:return 12;
break;
case 7:return 13;
break;
case 8:return 14;
break;
case 9:return ':';
break;
case 10:return 6;
break;
case 11:return 'INVALID';
break;
}
},
rules: [/^(?:[\n]+)/i,/^(?:\s+)/i,/^(?:#[^\n]*)/i,/^(?:%[^\n]*)/i,/^(?:journey\b)/i,/^(?:title\s[^#\n;]+)/i,/^(?:section\s[^#:\n;]+)/i,/^(?:[^#:\n;]+)/i,/^(?::[^#\n;]+)/i,/^(?::)/i,/^(?:$)/i,/^(?:.)/i],
conditions: {"INITIAL":{"rules":[0,1,2,3,4,5,6,7,8,9,10,11],"inclusive":true}}
});
return lexer;
})();
parser.lexer = lexer;
function Parser () {
this.yy = {};
}
Parser.prototype = parser;parser.Parser = Parser;
return new Parser;
})();
if (true) {
exports.parser = parser;
exports.Parser = parser.Parser;
exports.parse = function () { return parser.parse.apply(parser, arguments); };
exports.main = function commonjsMain (args) {
if (!args[1]) {
console.log('Usage: '+args[0]+' FILE');
process.exit(1);
}
var source = __webpack_require__(/*! fs */ "./node_modules/node-libs-browser/mock/empty.js").readFileSync(__webpack_require__(/*! path */ "./node_modules/path-browserify/index.js").normalize(args[1]), "utf8");
return exports.parser.parse(source);
};
if ( true && __webpack_require__.c[__webpack_require__.s] === module) {
exports.main(process.argv.slice(1));
}
}
/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../../node_modules/process/browser.js */ "./node_modules/process/browser.js"), __webpack_require__(/*! ./../../../../node_modules/webpack/buildin/module.js */ "./node_modules/webpack/buildin/module.js")(module)))
/***/ }),
/***/ "./src/diagrams/user-journey/svgDraw.js":
/*!**********************************************!*\
!*** ./src/diagrams/user-journey/svgDraw.js ***!
\**********************************************/
/*! exports provided: drawRect, drawFace, drawCircle, drawText, drawLabel, drawSection, drawTask, drawBackgroundRect, getTextObj, getNoteRect, default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "drawRect", function() { return drawRect; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "drawFace", function() { return drawFace; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "drawCircle", function() { return drawCircle; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "drawText", function() { return drawText; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "drawLabel", function() { return drawLabel; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "drawSection", function() { return drawSection; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "drawTask", function() { return drawTask; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "drawBackgroundRect", function() { return drawBackgroundRect; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getTextObj", function() { return getTextObj; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getNoteRect", function() { return getNoteRect; });
/* harmony import */ var d3__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! d3 */ "d3");
/* harmony import */ var d3__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(d3__WEBPACK_IMPORTED_MODULE_0__);
var drawRect = function drawRect(elem, rectData) {
var rectElem = elem.append('rect');
rectElem.attr('x', rectData.x);
rectElem.attr('y', rectData.y);
rectElem.attr('fill', rectData.fill);
rectElem.attr('stroke', rectData.stroke);
rectElem.attr('width', rectData.width);
rectElem.attr('height', rectData.height);
rectElem.attr('rx', rectData.rx);
rectElem.attr('ry', rectData.ry);
if (typeof rectData.class !== 'undefined') {
rectElem.attr('class', rectData.class);
}
return rectElem;
};
var drawFace = function drawFace(element, faceData) {
var radius = 15;
var circleElement = element.append('circle').attr('cx', faceData.cx).attr('cy', faceData.cy).attr('fill', '#FFF8DC').attr('stroke', '#999').attr('r', radius).attr('stroke-width', 2).attr('overflow', 'visible');
var face = element.append('g'); //left eye
face.append('circle').attr('cx', faceData.cx - radius / 3).attr('cy', faceData.cy - radius / 3).attr('r', 1.5).attr('stroke-width', 2).attr('fill', '#666').attr('stroke', '#666'); //right eye
face.append('circle').attr('cx', faceData.cx + radius / 3).attr('cy', faceData.cy - radius / 3).attr('r', 1.5).attr('stroke-width', 2).attr('fill', '#666').attr('stroke', '#666');
function smile(face) {
var arc = Object(d3__WEBPACK_IMPORTED_MODULE_0__["arc"])().startAngle(Math.PI / 2).endAngle(3 * (Math.PI / 2)).innerRadius(radius / 2).outerRadius(radius / 2.2); //mouth
face.append('path').attr('d', arc).attr('transform', 'translate(' + faceData.cx + ',' + (faceData.cy + 2) + ')');
}
function sad(face) {
var arc = Object(d3__WEBPACK_IMPORTED_MODULE_0__["arc"])().startAngle(3 * Math.PI / 2).endAngle(5 * (Math.PI / 2)).innerRadius(radius / 2).outerRadius(radius / 2.2); //mouth
face.append('path').attr('d', arc).attr('transform', 'translate(' + faceData.cx + ',' + (faceData.cy + 7) + ')');
}
function ambivalent(face) {
face.append('line').attr('stroke', 2).attr('x1', faceData.cx - 5).attr('y1', faceData.cy + 7).attr('x2', faceData.cx + 5).attr('y2', faceData.cy + 7).attr('class', 'task-line').attr('stroke-width', '1px').attr('stroke', '#666');
}
if (faceData.score > 3) {
smile(face);
} else if (faceData.score < 3) {
sad(face);
} else {
ambivalent(face);
}
return circleElement;
};
var drawCircle = function drawCircle(element, circleData) {
var circleElement = element.append('circle');
circleElement.attr('cx', circleData.cx);
circleElement.attr('cy', circleData.cy);
circleElement.attr('fill', circleData.fill);
circleElement.attr('stroke', circleData.stroke);
circleElement.attr('r', circleData.r);
if (typeof circleElement.class !== 'undefined') {
circleElement.attr('class', circleElement.class);
}
if (typeof circleData.title !== 'undefined') {
circleElement.append('title').text(circleData.title);
}
return circleElement;
};
var drawText = function drawText(elem, textData) {
// Remove and ignore br:s
var nText = textData.text.replace(/
/gi, ' ');
var textElem = elem.append('text');
textElem.attr('x', textData.x);
textElem.attr('y', textData.y);
textElem.attr('fill', textData.fill);
textElem.style('text-anchor', textData.anchor);
if (typeof textData.class !== 'undefined') {
textElem.attr('class', textData.class);
}
var span = textElem.append('tspan');
span.attr('x', textData.x + textData.textMargin * 2);
span.text(nText);
return textElem;
};
var drawLabel = function drawLabel(elem, txtObject) {
function genPoints(x, y, width, height, cut) {
return x + ',' + y + ' ' + (x + width) + ',' + y + ' ' + (x + width) + ',' + (y + height - cut) + ' ' + (x + width - cut * 1.2) + ',' + (y + height) + ' ' + x + ',' + (y + height);
}
var polygon = elem.append('polygon');
polygon.attr('points', genPoints(txtObject.x, txtObject.y, 50, 20, 7));
polygon.attr('class', 'labelBox');
txtObject.y = txtObject.y + txtObject.labelMargin;
txtObject.x = txtObject.x + 0.5 * txtObject.labelMargin;
drawText(elem, txtObject);
};
var drawSection = function drawSection(elem, section, conf) {
var g = elem.append('g');
var rect = getNoteRect();
rect.x = section.x;
rect.y = section.y;
rect.fill = section.fill;
rect.width = conf.width;
rect.height = conf.height;
rect.class = 'journey-section';
rect.rx = 3;
rect.ry = 3;
drawRect(g, rect);
_drawTextCandidateFunc(conf)(section.text, g, rect.x, rect.y, rect.width, rect.height, {
class: 'journey-section'
}, conf, section.colour);
};
var taskCount = -1;
/**
* Draws an actor in the diagram with the attaced line
* @param elem The HTML element
* @param task The task to render
* @param conf The global configuration
*/
var drawTask = function drawTask(elem, task, conf) {
var center = task.x + conf.width / 2;
var g = elem.append('g');
taskCount++;
var maxHeight = 300 + 5 * 30;
g.append('line').attr('id', 'task' + taskCount).attr('x1', center).attr('y1', task.y).attr('x2', center).attr('y2', maxHeight).attr('class', 'task-line').attr('stroke-width', '1px').attr('stroke-dasharray', '4 2').attr('stroke', '#666');
drawFace(g, {
cx: center,
cy: 300 + (5 - task.score) * 30,
score: task.score
});
var rect = getNoteRect();
rect.x = task.x;
rect.y = task.y;
rect.fill = task.fill;
rect.width = conf.width;
rect.height = conf.height;
rect.class = 'task';
rect.rx = 3;
rect.ry = 3;
drawRect(g, rect);
var xPos = task.x + 14;
task.people.forEach(function (person) {
var colour = task.actors[person];
var circle = {
cx: xPos,
cy: task.y,
r: 7,
fill: colour,
stroke: '#000',
title: person
};
drawCircle(g, circle);
xPos += 10;
});
_drawTextCandidateFunc(conf)(task.task, g, rect.x, rect.y, rect.width, rect.height, {
class: 'task'
}, conf, task.colour);
};
/**
* Draws a background rectangle
* @param elem The html element
* @param bounds The bounds of the drawing
*/
var drawBackgroundRect = function drawBackgroundRect(elem, bounds) {
var rectElem = drawRect(elem, {
x: bounds.startx,
y: bounds.starty,
width: bounds.stopx - bounds.startx,
height: bounds.stopy - bounds.starty,
fill: bounds.fill,
class: 'rect'
});
rectElem.lower();
};
var getTextObj = function getTextObj() {
return {
x: 0,
y: 0,
fill: undefined,
'text-anchor': 'start',
width: 100,
height: 100,
textMargin: 0,
rx: 0,
ry: 0
};
};
var getNoteRect = function getNoteRect() {
return {
x: 0,
y: 0,
width: 100,
anchor: 'start',
height: 100,
rx: 0,
ry: 0
};
};
var _drawTextCandidateFunc = function () {
function byText(content, g, x, y, width, height, textAttrs, colour) {
var text = g.append('text').attr('x', x + width / 2).attr('y', y + height / 2 + 5).style('font-color', colour).style('text-anchor', 'middle').text(content);
_setTextAttrs(text, textAttrs);
}
function byTspan(content, g, x, y, width, height, textAttrs, conf, colour) {
var taskFontSize = conf.taskFontSize,
taskFontFamily = conf.taskFontFamily;
var lines = content.split(/
/gi);
for (var i = 0; i < lines.length; i++) {
var dy = i * taskFontSize - taskFontSize * (lines.length - 1) / 2;
var text = g.append('text').attr('x', x + width / 2).attr('y', y).attr('fill', colour).style('text-anchor', 'middle').style('font-size', taskFontSize).style('font-family', taskFontFamily);
text.append('tspan').attr('x', x + width / 2).attr('dy', dy).text(lines[i]);
text.attr('y', y + height / 2.0).attr('dominant-baseline', 'central').attr('alignment-baseline', 'central');
_setTextAttrs(text, textAttrs);
}
}
function byFo(content, g, x, y, width, height, textAttrs, conf, colour) {
var body = g.append('switch');
var f = body.append('foreignObject').attr('x', x).attr('y', y).attr('width', width).attr('height', height).attr('position', 'fixed');
var text = f.append('div').style('display', 'table').style('height', '100%').style('width', '100%');
text.append('div').style('display', 'table-cell').style('text-align', 'center').style('vertical-align', 'middle').style('color', colour).text(content);
byTspan(content, body, x, y, width, height, textAttrs, conf);
_setTextAttrs(text, textAttrs);
}
function _setTextAttrs(toText, fromTextAttrsDict) {
for (var key in fromTextAttrsDict) {
if (key in fromTextAttrsDict) {
// eslint-disable-line
// noinspection JSUnfilteredForInLoop
toText.attr(key, fromTextAttrsDict[key]);
}
}
}
return function (conf) {
return conf.textPlacement === 'fo' ? byFo : conf.textPlacement === 'old' ? byText : byTspan;
};
}();
var initGraphics = function initGraphics(graphics) {
graphics.append('defs').append('marker').attr('id', 'arrowhead').attr('refX', 5).attr('refY', 2).attr('markerWidth', 6).attr('markerHeight', 4).attr('orient', 'auto').append('path').attr('d', 'M 0,0 V 4 L6,2 Z'); // this is actual shape for arrowhead
};
/* harmony default export */ __webpack_exports__["default"] = ({
drawRect: drawRect,
drawCircle: drawCircle,
drawSection: drawSection,
drawText: drawText,
drawLabel: drawLabel,
drawTask: drawTask,
drawBackgroundRect: drawBackgroundRect,
getTextObj: getTextObj,
getNoteRect: getNoteRect,
initGraphics: initGraphics
});
/***/ }),
/***/ "./src/errorRenderer.js":
/*!******************************!*\
!*** ./src/errorRenderer.js ***!
\******************************/
/*! exports provided: setConf, draw, default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "setConf", function() { return setConf; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "draw", function() { return draw; });
/* harmony import */ var d3__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! d3 */ "d3");
/* harmony import */ var d3__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(d3__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./logger */ "./src/logger.js");
/**
* Created by knut on 14-12-11.
*/
var conf = {};
var setConf = function setConf(cnf) {
var keys = Object.keys(cnf);
keys.forEach(function (key) {
conf[key] = cnf[key];
});
};
/**
* Draws a an info picture in the tag with id: id based on the graph definition in text.
* @param text
* @param id
*/
var draw = function draw(id, ver) {
try {
_logger__WEBPACK_IMPORTED_MODULE_1__["logger"].debug('Renering svg for syntax error\n');
var svg = Object(d3__WEBPACK_IMPORTED_MODULE_0__["select"])('#' + id);
var g = svg.append('g');
g.append('path').attr('class', 'error-icon').attr('d', 'm411.313,123.313c6.25-6.25 6.25-16.375 0-22.625s-16.375-6.25-22.625,0l-32,32-9.375,9.375-20.688-20.688c-12.484-12.5-32.766-12.5-45.25,0l-16,16c-1.261,1.261-2.304,2.648-3.31,4.051-21.739-8.561-45.324-13.426-70.065-13.426-105.867,0-192,86.133-192,192s86.133,192 192,192 192-86.133 192-192c0-24.741-4.864-48.327-13.426-70.065 1.402-1.007 2.79-2.049 4.051-3.31l16-16c12.5-12.492 12.5-32.758 0-45.25l-20.688-20.688 9.375-9.375 32.001-31.999zm-219.313,100.687c-52.938,0-96,43.063-96,96 0,8.836-7.164,16-16,16s-16-7.164-16-16c0-70.578 57.422-128 128-128 8.836,0 16,7.164 16,16s-7.164,16-16,16z');
g.append('path').attr('class', 'error-icon').attr('d', 'm459.02,148.98c-6.25-6.25-16.375-6.25-22.625,0s-6.25,16.375 0,22.625l16,16c3.125,3.125 7.219,4.688 11.313,4.688 4.094,0 8.188-1.563 11.313-4.688 6.25-6.25 6.25-16.375 0-22.625l-16.001-16z');
g.append('path').attr('class', 'error-icon').attr('d', 'm340.395,75.605c3.125,3.125 7.219,4.688 11.313,4.688 4.094,0 8.188-1.563 11.313-4.688 6.25-6.25 6.25-16.375 0-22.625l-16-16c-6.25-6.25-16.375-6.25-22.625,0s-6.25,16.375 0,22.625l15.999,16z');
g.append('path').attr('class', 'error-icon').attr('d', 'm400,64c8.844,0 16-7.164 16-16v-32c0-8.836-7.156-16-16-16-8.844,0-16,7.164-16,16v32c0,8.836 7.156,16 16,16z');
g.append('path').attr('class', 'error-icon').attr('d', 'm496,96.586h-32c-8.844,0-16,7.164-16,16 0,8.836 7.156,16 16,16h32c8.844,0 16-7.164 16-16 0-8.836-7.156-16-16-16z');
g.append('path').attr('class', 'error-icon').attr('d', 'm436.98,75.605c3.125,3.125 7.219,4.688 11.313,4.688 4.094,0 8.188-1.563 11.313-4.688l32-32c6.25-6.25 6.25-16.375 0-22.625s-16.375-6.25-22.625,0l-32,32c-6.251,6.25-6.251,16.375-0.001,22.625z');
g.append('text') // text label for the x axis
.attr('class', 'error-text').attr('x', 1240).attr('y', 250).attr('font-size', '150px').style('text-anchor', 'middle').text('Syntax error in graph');
g.append('text') // text label for the x axis
.attr('class', 'error-text').attr('x', 1050).attr('y', 400).attr('font-size', '100px').style('text-anchor', 'middle').text('mermaid version ' + ver);
svg.attr('height', 100);
svg.attr('width', 400);
svg.attr('viewBox', '768 0 512 512');
} catch (e) {
_logger__WEBPACK_IMPORTED_MODULE_1__["logger"].error('Error while rendering info diagram');
_logger__WEBPACK_IMPORTED_MODULE_1__["logger"].error(e.message);
}
};
/* harmony default export */ __webpack_exports__["default"] = ({
setConf: setConf,
draw: draw
});
/***/ }),
/***/ "./src/logger.js":
/*!***********************!*\
!*** ./src/logger.js ***!
\***********************/
/*! exports provided: LEVELS, logger, setLogLevel */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LEVELS", function() { return LEVELS; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "logger", function() { return logger; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "setLogLevel", function() { return setLogLevel; });
/* harmony import */ var moment_mini__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! moment-mini */ "moment-mini");
/* harmony import */ var moment_mini__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(moment_mini__WEBPACK_IMPORTED_MODULE_0__);
//
var LEVELS = {
debug: 1,
info: 2,
warn: 3,
error: 4,
fatal: 5
};
var logger = {
debug: function debug() {},
info: function info() {},
warn: function warn() {},
error: function error() {},
fatal: function fatal() {}
};
var setLogLevel = function setLogLevel(level) {
logger.trace = function () {};
logger.debug = function () {};
logger.info = function () {};
logger.warn = function () {};
logger.error = function () {};
logger.fatal = function () {};
if (level <= LEVELS.fatal) {
logger.fatal = console.error ? console.error.bind(console, format('FATAL'), 'color: orange') : console.log.bind(console, '\x1b[35m', format('FATAL'));
}
if (level <= LEVELS.error) {
logger.error = console.error ? console.error.bind(console, format('ERROR'), 'color: orange') : console.log.bind(console, '\x1b[31m', format('ERROR'));
}
if (level <= LEVELS.warn) {
logger.warn = console.warn ? console.warn.bind(console, format('WARN'), 'color: orange') : console.log.bind(console, "\x1B[33m", format('WARN'));
}
if (level <= LEVELS.info) {
logger.info = console.info ? // ? console.info.bind(console, '\x1b[34m', format('INFO'), 'color: blue')
console.info.bind(console, format('INFO'), 'color: lightblue') : console.log.bind(console, '\x1b[34m', format('INFO'));
}
if (level <= LEVELS.debug) {
logger.debug = console.debug ? console.debug.bind(console, format('DEBUG'), 'color: lightgreen') : console.log.bind(console, '\x1b[32m', format('DEBUG'));
}
};
var format = function format(level) {
var time = moment_mini__WEBPACK_IMPORTED_MODULE_0___default()().format('ss.SSS');
return "%c".concat(time, " : ").concat(level, " : ");
};
/***/ }),
/***/ "./src/mermaid.js":
/*!************************!*\
!*** ./src/mermaid.js ***!
\************************/
/*! exports provided: default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony import */ var entity_decode_browser__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! entity-decode/browser */ "entity-decode/browser");
/* harmony import */ var entity_decode_browser__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(entity_decode_browser__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _mermaidAPI__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./mermaidAPI */ "./src/mermaidAPI.js");
/* harmony import */ var _logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./logger */ "./src/logger.js");
/**
* Web page integration module for the mermaid framework. It uses the mermaidAPI for mermaid functionality and to render
* the diagrams to svg code.
*/
// import { decode } from 'he';
/**
* ## init
* Function that goes through the document to find the chart definitions in there and render them.
*
* The function tags the processed attributes with the attribute data-processed and ignores found elements with the
* attribute already set. This way the init function can be triggered several times.
*
* Optionally, `init` can accept in the second argument one of the following:
* - a DOM Node
* - an array of DOM nodes (as would come from a jQuery selector)
* - a W3C selector, a la `.mermaid`
*
* ```mermaid
* graph LR;
* a(Find elements)-->b{Processed}
* b-->|Yes|c(Leave element)
* b-->|No |d(Transform)
* ```
* Renders the mermaid diagrams
* @param nodes a css selector or an array of nodes
*/
var init = function init() {
var _this = this;
var conf = _mermaidAPI__WEBPACK_IMPORTED_MODULE_1__["default"].getConfig();
_logger__WEBPACK_IMPORTED_MODULE_2__["logger"].debug('Starting rendering diagrams');
var nodes;
if (arguments.length >= 2) {
/*! sequence config was passed as #1 */
if (typeof arguments[0] !== 'undefined') {
mermaid.sequenceConfig = arguments[0];
}
nodes = arguments[1];
} else {
nodes = arguments[0];
} // if last argument is a function this is the callback function
var callback;
if (typeof arguments[arguments.length - 1] === 'function') {
callback = arguments[arguments.length - 1];
_logger__WEBPACK_IMPORTED_MODULE_2__["logger"].debug('Callback function found');
} else {
if (typeof conf.mermaid !== 'undefined') {
if (typeof conf.mermaid.callback === 'function') {
callback = conf.mermaid.callback;
_logger__WEBPACK_IMPORTED_MODULE_2__["logger"].debug('Callback function found');
} else {
_logger__WEBPACK_IMPORTED_MODULE_2__["logger"].debug('No Callback function found');
}
}
}
nodes = nodes === undefined ? document.querySelectorAll('.mermaid') : typeof nodes === 'string' ? document.querySelectorAll(nodes) : nodes instanceof window.Node ? [nodes] : nodes; // Last case - sequence config was passed pick next
_logger__WEBPACK_IMPORTED_MODULE_2__["logger"].debug('Start On Load before: ' + mermaid.startOnLoad);
if (typeof mermaid.startOnLoad !== 'undefined') {
_logger__WEBPACK_IMPORTED_MODULE_2__["logger"].debug('Start On Load inner: ' + mermaid.startOnLoad);
_mermaidAPI__WEBPACK_IMPORTED_MODULE_1__["default"].initialize({
startOnLoad: mermaid.startOnLoad
});
}
if (typeof mermaid.ganttConfig !== 'undefined') {
_mermaidAPI__WEBPACK_IMPORTED_MODULE_1__["default"].initialize({
gantt: mermaid.ganttConfig
});
}
var txt;
var _loop = function _loop(i) {
var element = nodes[i];
/*! Check if previously processed */
if (!element.getAttribute('data-processed')) {
element.setAttribute('data-processed', true);
} else {
return "continue";
}
var id = "mermaid-".concat(Date.now()); // Fetch the graph definition including tags
txt = element.innerHTML; // transforms the html to pure text
txt = entity_decode_browser__WEBPACK_IMPORTED_MODULE_0___default()(txt).trim().replace(/
/gi, '
');
try {
_mermaidAPI__WEBPACK_IMPORTED_MODULE_1__["default"].render(id, txt, function (svgCode, bindFunctions) {
element.innerHTML = svgCode;
if (typeof callback !== 'undefined') {
callback(id);
}
if (bindFunctions) bindFunctions(element);
}, element);
} catch (e) {
_logger__WEBPACK_IMPORTED_MODULE_2__["logger"].warn('Syntax Error rendering');
_logger__WEBPACK_IMPORTED_MODULE_2__["logger"].warn(e);
if (_this.parseError) {
_this.parseError(e);
}
}
};
for (var i = 0; i < nodes.length; i++) {
var _ret = _loop(i);
if (_ret === "continue") continue;
}
};
var initialize = function initialize(config) {
if (typeof config.mermaid !== 'undefined') {
if (typeof config.mermaid.startOnLoad !== 'undefined') {
mermaid.startOnLoad = config.mermaid.startOnLoad;
}
if (typeof config.mermaid.htmlLabels !== 'undefined') {
mermaid.htmlLabels = config.mermaid.htmlLabels;
}
}
_mermaidAPI__WEBPACK_IMPORTED_MODULE_1__["default"].initialize(config);
_logger__WEBPACK_IMPORTED_MODULE_2__["logger"].debug('Initializing mermaid ');
};
/**
* ##contentLoaded
* Callback function that is called when page is loaded. This functions fetches configuration for mermaid rendering and
* calls init for rendering the mermaid diagrams on the page.
*/
var contentLoaded = function contentLoaded() {
var config;
if (mermaid.startOnLoad) {
// No config found, do check API config
config = _mermaidAPI__WEBPACK_IMPORTED_MODULE_1__["default"].getConfig();
if (config.startOnLoad) {
mermaid.init();
}
} else {
if (typeof mermaid.startOnLoad === 'undefined') {
_logger__WEBPACK_IMPORTED_MODULE_2__["logger"].debug('In start, no config');
config = _mermaidAPI__WEBPACK_IMPORTED_MODULE_1__["default"].getConfig();
if (config.startOnLoad) {
mermaid.init();
}
}
}
};
if (typeof document !== 'undefined') {
/*!
* Wait for document loaded before starting the execution
*/
window.addEventListener('load', function () {
contentLoaded();
}, false);
}
var mermaid = {
startOnLoad: true,
htmlLabels: true,
mermaidAPI: _mermaidAPI__WEBPACK_IMPORTED_MODULE_1__["default"],
parse: _mermaidAPI__WEBPACK_IMPORTED_MODULE_1__["default"].parse,
render: _mermaidAPI__WEBPACK_IMPORTED_MODULE_1__["default"].render,
init: init,
initialize: initialize,
contentLoaded: contentLoaded
};
/* harmony default export */ __webpack_exports__["default"] = (mermaid);
/***/ }),
/***/ "./src/mermaidAPI.js":
/*!***************************!*\
!*** ./src/mermaidAPI.js ***!
\***************************/
/*! exports provided: encodeEntities, decodeEntities, default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "encodeEntities", function() { return encodeEntities; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "decodeEntities", function() { return decodeEntities; });
/* harmony import */ var d3__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! d3 */ "d3");
/* harmony import */ var d3__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(d3__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var scope_css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! scope-css */ "scope-css");
/* harmony import */ var scope_css__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(scope_css__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var _package_json__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../package.json */ "./package.json");
var _package_json__WEBPACK_IMPORTED_MODULE_2___namespace = /*#__PURE__*/__webpack_require__.t(/*! ../package.json */ "./package.json", 1);
/* harmony import */ var _config__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./config */ "./src/config.js");
/* harmony import */ var _logger__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./logger */ "./src/logger.js");
/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./utils */ "./src/utils.js");
/* harmony import */ var _diagrams_flowchart_flowRenderer__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./diagrams/flowchart/flowRenderer */ "./src/diagrams/flowchart/flowRenderer.js");
/* harmony import */ var _diagrams_flowchart_flowRenderer_v2__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./diagrams/flowchart/flowRenderer-v2 */ "./src/diagrams/flowchart/flowRenderer-v2.js");
/* harmony import */ var _diagrams_flowchart_parser_flow__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./diagrams/flowchart/parser/flow */ "./src/diagrams/flowchart/parser/flow.jison");
/* harmony import */ var _diagrams_flowchart_parser_flow__WEBPACK_IMPORTED_MODULE_8___default = /*#__PURE__*/__webpack_require__.n(_diagrams_flowchart_parser_flow__WEBPACK_IMPORTED_MODULE_8__);
/* harmony import */ var _diagrams_flowchart_flowDb__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./diagrams/flowchart/flowDb */ "./src/diagrams/flowchart/flowDb.js");
/* harmony import */ var _diagrams_sequence_sequenceRenderer__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./diagrams/sequence/sequenceRenderer */ "./src/diagrams/sequence/sequenceRenderer.js");
/* harmony import */ var _diagrams_sequence_parser_sequenceDiagram__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./diagrams/sequence/parser/sequenceDiagram */ "./src/diagrams/sequence/parser/sequenceDiagram.jison");
/* harmony import */ var _diagrams_sequence_parser_sequenceDiagram__WEBPACK_IMPORTED_MODULE_11___default = /*#__PURE__*/__webpack_require__.n(_diagrams_sequence_parser_sequenceDiagram__WEBPACK_IMPORTED_MODULE_11__);
/* harmony import */ var _diagrams_sequence_sequenceDb__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./diagrams/sequence/sequenceDb */ "./src/diagrams/sequence/sequenceDb.js");
/* harmony import */ var _diagrams_gantt_ganttRenderer__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./diagrams/gantt/ganttRenderer */ "./src/diagrams/gantt/ganttRenderer.js");
/* harmony import */ var _diagrams_gantt_parser_gantt__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./diagrams/gantt/parser/gantt */ "./src/diagrams/gantt/parser/gantt.jison");
/* harmony import */ var _diagrams_gantt_parser_gantt__WEBPACK_IMPORTED_MODULE_14___default = /*#__PURE__*/__webpack_require__.n(_diagrams_gantt_parser_gantt__WEBPACK_IMPORTED_MODULE_14__);
/* harmony import */ var _diagrams_gantt_ganttDb__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./diagrams/gantt/ganttDb */ "./src/diagrams/gantt/ganttDb.js");
/* harmony import */ var _diagrams_class_classRenderer__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./diagrams/class/classRenderer */ "./src/diagrams/class/classRenderer.js");
/* harmony import */ var _diagrams_class_parser_classDiagram__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./diagrams/class/parser/classDiagram */ "./src/diagrams/class/parser/classDiagram.jison");
/* harmony import */ var _diagrams_class_parser_classDiagram__WEBPACK_IMPORTED_MODULE_17___default = /*#__PURE__*/__webpack_require__.n(_diagrams_class_parser_classDiagram__WEBPACK_IMPORTED_MODULE_17__);
/* harmony import */ var _diagrams_class_classDb__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./diagrams/class/classDb */ "./src/diagrams/class/classDb.js");
/* harmony import */ var _diagrams_state_stateRenderer__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./diagrams/state/stateRenderer */ "./src/diagrams/state/stateRenderer.js");
/* harmony import */ var _diagrams_state_stateRenderer_v2__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./diagrams/state/stateRenderer-v2 */ "./src/diagrams/state/stateRenderer-v2.js");
/* harmony import */ var _diagrams_state_parser_stateDiagram__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./diagrams/state/parser/stateDiagram */ "./src/diagrams/state/parser/stateDiagram.jison");
/* harmony import */ var _diagrams_state_parser_stateDiagram__WEBPACK_IMPORTED_MODULE_21___default = /*#__PURE__*/__webpack_require__.n(_diagrams_state_parser_stateDiagram__WEBPACK_IMPORTED_MODULE_21__);
/* harmony import */ var _diagrams_state_stateDb__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./diagrams/state/stateDb */ "./src/diagrams/state/stateDb.js");
/* harmony import */ var _diagrams_git_gitGraphRenderer__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./diagrams/git/gitGraphRenderer */ "./src/diagrams/git/gitGraphRenderer.js");
/* harmony import */ var _diagrams_git_parser_gitGraph__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./diagrams/git/parser/gitGraph */ "./src/diagrams/git/parser/gitGraph.jison");
/* harmony import */ var _diagrams_git_parser_gitGraph__WEBPACK_IMPORTED_MODULE_24___default = /*#__PURE__*/__webpack_require__.n(_diagrams_git_parser_gitGraph__WEBPACK_IMPORTED_MODULE_24__);
/* harmony import */ var _diagrams_git_gitGraphAst__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./diagrams/git/gitGraphAst */ "./src/diagrams/git/gitGraphAst.js");
/* harmony import */ var _diagrams_info_infoRenderer__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./diagrams/info/infoRenderer */ "./src/diagrams/info/infoRenderer.js");
/* harmony import */ var _errorRenderer__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ./errorRenderer */ "./src/errorRenderer.js");
/* harmony import */ var _diagrams_info_parser_info__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! ./diagrams/info/parser/info */ "./src/diagrams/info/parser/info.jison");
/* harmony import */ var _diagrams_info_parser_info__WEBPACK_IMPORTED_MODULE_28___default = /*#__PURE__*/__webpack_require__.n(_diagrams_info_parser_info__WEBPACK_IMPORTED_MODULE_28__);
/* harmony import */ var _diagrams_info_infoDb__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(/*! ./diagrams/info/infoDb */ "./src/diagrams/info/infoDb.js");
/* harmony import */ var _diagrams_pie_pieRenderer__WEBPACK_IMPORTED_MODULE_30__ = __webpack_require__(/*! ./diagrams/pie/pieRenderer */ "./src/diagrams/pie/pieRenderer.js");
/* harmony import */ var _diagrams_pie_parser_pie__WEBPACK_IMPORTED_MODULE_31__ = __webpack_require__(/*! ./diagrams/pie/parser/pie */ "./src/diagrams/pie/parser/pie.jison");
/* harmony import */ var _diagrams_pie_parser_pie__WEBPACK_IMPORTED_MODULE_31___default = /*#__PURE__*/__webpack_require__.n(_diagrams_pie_parser_pie__WEBPACK_IMPORTED_MODULE_31__);
/* harmony import */ var _diagrams_pie_pieDb__WEBPACK_IMPORTED_MODULE_32__ = __webpack_require__(/*! ./diagrams/pie/pieDb */ "./src/diagrams/pie/pieDb.js");
/* harmony import */ var _diagrams_er_erDb__WEBPACK_IMPORTED_MODULE_33__ = __webpack_require__(/*! ./diagrams/er/erDb */ "./src/diagrams/er/erDb.js");
/* harmony import */ var _diagrams_er_parser_erDiagram__WEBPACK_IMPORTED_MODULE_34__ = __webpack_require__(/*! ./diagrams/er/parser/erDiagram */ "./src/diagrams/er/parser/erDiagram.jison");
/* harmony import */ var _diagrams_er_parser_erDiagram__WEBPACK_IMPORTED_MODULE_34___default = /*#__PURE__*/__webpack_require__.n(_diagrams_er_parser_erDiagram__WEBPACK_IMPORTED_MODULE_34__);
/* harmony import */ var _diagrams_er_erRenderer__WEBPACK_IMPORTED_MODULE_35__ = __webpack_require__(/*! ./diagrams/er/erRenderer */ "./src/diagrams/er/erRenderer.js");
/* harmony import */ var _diagrams_user_journey_parser_journey__WEBPACK_IMPORTED_MODULE_36__ = __webpack_require__(/*! ./diagrams/user-journey/parser/journey */ "./src/diagrams/user-journey/parser/journey.jison");
/* harmony import */ var _diagrams_user_journey_parser_journey__WEBPACK_IMPORTED_MODULE_36___default = /*#__PURE__*/__webpack_require__.n(_diagrams_user_journey_parser_journey__WEBPACK_IMPORTED_MODULE_36__);
/* harmony import */ var _diagrams_user_journey_journeyDb__WEBPACK_IMPORTED_MODULE_37__ = __webpack_require__(/*! ./diagrams/user-journey/journeyDb */ "./src/diagrams/user-journey/journeyDb.js");
/* harmony import */ var _diagrams_user_journey_journeyRenderer__WEBPACK_IMPORTED_MODULE_38__ = __webpack_require__(/*! ./diagrams/user-journey/journeyRenderer */ "./src/diagrams/user-journey/journeyRenderer.js");
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
/**
* This is the api to be used when optionally handling the integration with the web page, instead of using the default integration provided by mermaid.js.
*
* The core of this api is the [**render**](https://github.com/knsv/mermaid/blob/master/docs/mermaidAPI.md#render) function which, given a graph
* definition as text, renders the graph/diagram and returns an svg element for the graph.
*
* It is is then up to the user of the API to make use of the svg, either insert it somewhere in the page or do something completely different.
*
* In addition to the render function, a number of behavioral configuration options are available.
*
* @name mermaidAPI
*/
var themes = {};
for (var _i = 0, _arr = ['default', 'forest', 'dark', 'neutral']; _i < _arr.length; _i++) {
var themeName = _arr[_i];
themes[themeName] = __webpack_require__("./src/themes sync recursive ^\\.\\/.*\\/index\\.scss$")("./".concat(themeName, "/index.scss"));
}
/**
* These are the default options which can be overridden with the initialization call like so:
* **Example 1:**
*
* mermaid.initialize({
* flowchart:{
* htmlLabels: false
* }
* });
*
*
* **Example 2:**
*
* <script>
* var config = {
* startOnLoad:true,
* flowchart:{
* useMaxWidth:true,
* htmlLabels:true,
* curve:'cardinal',
* },
*
* securityLevel:'loose',
* };
* mermaid.initialize(config);
* </script>
*
* A summary of all options and their defaults is found [here](https://github.com/knsv/mermaid/blob/master/docs/mermaidAPI.md#mermaidapi-configuration-defaults). A description of each option follows below.
*
* @name Configuration
*/
var config = {
/** theme , the CSS style sheet
*
* **theme** - Choose one of the built-in themes:
* * default
* * forest
* * dark
* * neutral.
* To disable any pre-defined mermaid theme, use "null".
*
* **themeCSS** - Use your own CSS. This overrides **theme**.
*
* "theme": "forest",
* "themeCSS": ".node rect { fill: red; }"
*
*/
theme: 'default',
themeCSS: undefined,
/* **maxTextSize** - The maximum allowed size of the users text diamgram */
maxTextSize: 50000,
/**
* **fontFamily** The font to be used for the rendered diagrams. Default value is \"trebuchet ms\", verdana, arial;
*/
fontFamily: '"trebuchet ms", verdana, arial;',
/**
* This option decides the amount of logging to be used.
* * debug: 1
* * info: 2
* * warn: 3
* * error: 4
* * fatal: (**default**) 5
*/
logLevel: 5,
/**
* Sets the level of trust to be used on the parsed diagrams.
* * **strict**: (**default**) tags in text are encoded, click functionality is disabeled
* * **loose**: tags in text are allowed, click functionality is enabled
*/
securityLevel: 'strict',
/**
* This options controls whether or mermaid starts when the page loads
* **Default value true**.
*/
startOnLoad: true,
/**
* This options controls whether or arrow markers in html code will be absolute paths or
* an anchor, #. This matters if you are using base tag settings.
* **Default value false**.
*/
arrowMarkerAbsolute: false,
/**
* The object containing configurations specific for flowcharts
*/
flowchart: {
/**
* Flag for setting whether or not a html tag should be used for rendering labels
* on the edges.
* **Default value true**.
*/
htmlLabels: true,
/**
* Defines the spacing between nodes on the same level (meaning horizontal spacing for
* TB or BT graphs, and the vertical spacing for LR as well as RL graphs).
* **Default value 50**.
*/
nodeSpacing: 50,
/**
* Defines the spacing between nodes on different levels (meaning vertical spacing for
* TB or BT graphs, and the horizontal spacing for LR as well as RL graphs).
* **Default value 50**.
*/
rankSpacing: 50,
/**
* How mermaid renders curves for flowcharts. Possible values are
* * basis
* * linear **default**
* * cardinal
*/
curve: 'linear',
// Only used in new experimental rendering
// repreesents the padding between the labels and the shape
padding: 15
},
/**
* The object containing configurations specific for sequence diagrams
*/
sequence: {
/**
* margin to the right and left of the sequence diagram.
* **Default value 50**.
*/
diagramMarginX: 50,
/**
* margin to the over and under the sequence diagram.
* **Default value 10**.
*/
diagramMarginY: 10,
/**
* Margin between actors.
* **Default value 50**.
*/
actorMargin: 50,
/**
* Width of actor boxes
* **Default value 150**.
*/
width: 150,
/**
* Height of actor boxes
* **Default value 65**.
*/
height: 65,
/**
* Margin around loop boxes
* **Default value 10**.
*/
boxMargin: 10,
/**
* margin around the text in loop/alt/opt boxes
* **Default value 5**.
*/
boxTextMargin: 5,
/**
* margin around notes.
* **Default value 10**.
*/
noteMargin: 10,
/**
* Space between messages.
* **Default value 35**.
*/
messageMargin: 35,
/**
* Multiline message alignment. Possible values are:
* * left
* * center **default**
* * right
*/
messageAlign: 'center',
/**
* mirror actors under diagram.
* **Default value true**.
*/
mirrorActors: true,
/**
* Depending on css styling this might need adjustment.
* Prolongs the edge of the diagram downwards.
* **Default value 1**.
*/
bottomMarginAdj: 1,
/**
* when this flag is set the height and width is set to 100% and is then scaling with the
* available space if not the absolute space required is used.
* **Default value true**.
*/
useMaxWidth: true,
/**
* This will display arrows that start and begin at the same node as right angles, rather than a curve
* **Default value false**.
*/
rightAngles: false,
/**
* This will show the node numbers
* **Default value false**.
*/
showSequenceNumbers: false,
/**
* This sets the font size of the actor's description
* **Default value 14**.
*/
actorFontSize: 14,
/**
* This sets the font family of the actor's description
* **Default value "Open-Sans", "sans-serif"**.
*/
actorFontFamily: '"Open-Sans", "sans-serif"',
/**
* This sets the font size of actor-attached notes.
* **Default value 14**.
*/
noteFontSize: 14,
/**
* This sets the font family of actor-attached notes.
* **Default value "trebuchet ms", verdana, arial**.
*/
noteFontFamily: '"trebuchet ms", verdana, arial',
/**
* This sets the text alignment of actor-attached notes.
* **Default value center**.
*/
noteAlign: 'center',
/**
* This sets the font size of actor messages.
* **Default value 16**.
*/
messageFontSize: 16,
/**
* This sets the font family of actor messages.
* **Default value "trebuchet ms", verdana, arial**.
*/
messageFontFamily: '"trebuchet ms", verdana, arial'
},
/**
* The object containing configurations specific for gantt diagrams*
*/
gantt: {
/**
* Margin top for the text over the gantt diagram
* **Default value 25**.
*/
titleTopMargin: 25,
/**
* The height of the bars in the graph
* **Default value 20**.
*/
barHeight: 20,
/**
* The margin between the different activities in the gantt diagram.
* **Default value 4**.
*/
barGap: 4,
/**
* Margin between title and gantt diagram and between axis and gantt diagram.
* **Default value 50**.
*/
topPadding: 50,
/**
* The space allocated for the section name to the left of the activities.
* **Default value 75**.
*/
leftPadding: 75,
/**
* Vertical starting position of the grid lines.
* **Default value 35**.
*/
gridLineStartPadding: 35,
/**
* Font size ...
* **Default value 11**.
*/
fontSize: 11,
/**
* font family ...
* **Default value '"Open-Sans", "sans-serif"'**.
*/
fontFamily: '"Open-Sans", "sans-serif"',
/**
* The number of alternating section styles.
* **Default value 4**.
*/
numberSectionStyles: 4,
/**
* Datetime format of the axis. This might need adjustment to match your locale and preferences
* **Default value '%Y-%m-%d'**.
*/
axisFormat: '%Y-%m-%d'
},
/**
* The object containing configurations specific for sequence diagrams
*/
journey: {
/**
* margin to the right and left of the sequence diagram.
* **Default value 50**.
*/
diagramMarginX: 50,
/**
* margin to the over and under the sequence diagram.
* **Default value 10**.
*/
diagramMarginY: 10,
/**
* Margin between actors.
* **Default value 50**.
*/
actorMargin: 50,
/**
* Width of actor boxes
* **Default value 150**.
*/
width: 150,
/**
* Height of actor boxes
* **Default value 65**.
*/
height: 65,
/**
* Margin around loop boxes
* **Default value 10**.
*/
boxMargin: 10,
/**
* margin around the text in loop/alt/opt boxes
* **Default value 5**.
*/
boxTextMargin: 5,
/**
* margin around notes.
* **Default value 10**.
*/
noteMargin: 10,
/**
* Space between messages.
* **Default value 35**.
*/
messageMargin: 35,
/**
* Multiline message alignment. Possible values are:
* * left
* * center **default**
* * right
*/
messageAlign: 'center',
/**
* Depending on css styling this might need adjustment.
* Prolongs the edge of the diagram downwards.
* **Default value 1**.
*/
bottomMarginAdj: 1,
/**
* when this flag is set the height and width is set to 100% and is then scaling with the
* available space if not the absolute space required is used.
* **Default value true**.
*/
useMaxWidth: true,
/**
* This will display arrows that start and begin at the same node as right angles, rather than a curve
* **Default value false**.
*/
rightAngles: false
},
class: {},
git: {},
state: {
dividerMargin: 10,
sizeUnit: 5,
padding: 8,
textHeight: 10,
titleShift: -15,
noteMargin: 10,
forkWidth: 70,
forkHeight: 7,
// Used
miniPadding: 2,
// Font size factor, this is used to guess the width of the edges labels before rendering by dagre
// layout. This might need updating if/when switching font
fontSizeFactor: 5.02,
fontSize: 24,
labelHeight: 16,
edgeLengthFactor: '20',
compositTitleSize: 35,
radius: 5
},
/**
* The object containing configurations specific for entity relationship diagrams
*/
er: {
/**
* The amount of padding around the diagram as a whole so that embedded diagrams have margins, expressed in pixels
*/
diagramPadding: 20,
/**
* Directional bias for layout of entities. Can be either 'TB', 'BT', 'LR', or 'RL',
* where T = top, B = bottom, L = left, and R = right.
*/
layoutDirection: 'TB',
/**
* The mimimum width of an entity box, expressed in pixels
*/
minEntityWidth: 100,
/**
* The minimum height of an entity box, expressed in pixels
*/
minEntityHeight: 75,
/**
* The minimum internal padding between the text in an entity box and the enclosing box borders, expressed in pixels
*/
entityPadding: 15,
/**
* Stroke color of box edges and lines
*/
stroke: 'gray',
/**
* Fill color of entity boxes
*/
fill: 'honeydew',
/**
* Font size (expressed as an integer representing a number of pixels)
*/
fontSize: 12
}
};
Object(_logger__WEBPACK_IMPORTED_MODULE_4__["setLogLevel"])(config.logLevel);
Object(_config__WEBPACK_IMPORTED_MODULE_3__["setConfig"])(config);
function parse(text) {
var graphType = _utils__WEBPACK_IMPORTED_MODULE_5__["default"].detectType(text);
var parser;
_logger__WEBPACK_IMPORTED_MODULE_4__["logger"].debug('Type ' + graphType);
switch (graphType) {
case 'git':
parser = _diagrams_git_parser_gitGraph__WEBPACK_IMPORTED_MODULE_24___default.a;
parser.parser.yy = _diagrams_git_gitGraphAst__WEBPACK_IMPORTED_MODULE_25__["default"];
break;
case 'flowchart':
_diagrams_flowchart_flowDb__WEBPACK_IMPORTED_MODULE_9__["default"].clear();
parser = _diagrams_flowchart_parser_flow__WEBPACK_IMPORTED_MODULE_8___default.a;
parser.parser.yy = _diagrams_flowchart_flowDb__WEBPACK_IMPORTED_MODULE_9__["default"];
break;
case 'flowchart-v2':
_diagrams_flowchart_flowDb__WEBPACK_IMPORTED_MODULE_9__["default"].clear();
parser = _diagrams_flowchart_parser_flow__WEBPACK_IMPORTED_MODULE_8___default.a;
parser.parser.yy = _diagrams_flowchart_flowDb__WEBPACK_IMPORTED_MODULE_9__["default"];
break;
case 'sequence':
parser = _diagrams_sequence_parser_sequenceDiagram__WEBPACK_IMPORTED_MODULE_11___default.a;
parser.parser.yy = _diagrams_sequence_sequenceDb__WEBPACK_IMPORTED_MODULE_12__["default"];
break;
case 'gantt':
parser = _diagrams_gantt_parser_gantt__WEBPACK_IMPORTED_MODULE_14___default.a;
parser.parser.yy = _diagrams_gantt_ganttDb__WEBPACK_IMPORTED_MODULE_15__["default"];
break;
case 'class':
parser = _diagrams_class_parser_classDiagram__WEBPACK_IMPORTED_MODULE_17___default.a;
parser.parser.yy = _diagrams_class_classDb__WEBPACK_IMPORTED_MODULE_18__["default"];
break;
case 'state':
parser = _diagrams_state_parser_stateDiagram__WEBPACK_IMPORTED_MODULE_21___default.a;
parser.parser.yy = _diagrams_state_stateDb__WEBPACK_IMPORTED_MODULE_22__["default"];
break;
case 'stateDiagram':
parser = _diagrams_state_parser_stateDiagram__WEBPACK_IMPORTED_MODULE_21___default.a;
parser.parser.yy = _diagrams_state_stateDb__WEBPACK_IMPORTED_MODULE_22__["default"];
break;
case 'info':
_logger__WEBPACK_IMPORTED_MODULE_4__["logger"].debug('info info info');
parser = _diagrams_info_parser_info__WEBPACK_IMPORTED_MODULE_28___default.a;
parser.parser.yy = _diagrams_info_infoDb__WEBPACK_IMPORTED_MODULE_29__["default"];
break;
case 'pie':
_logger__WEBPACK_IMPORTED_MODULE_4__["logger"].debug('pie');
parser = _diagrams_pie_parser_pie__WEBPACK_IMPORTED_MODULE_31___default.a;
parser.parser.yy = _diagrams_pie_pieDb__WEBPACK_IMPORTED_MODULE_32__["default"];
break;
case 'er':
_logger__WEBPACK_IMPORTED_MODULE_4__["logger"].debug('er');
parser = _diagrams_er_parser_erDiagram__WEBPACK_IMPORTED_MODULE_34___default.a;
parser.parser.yy = _diagrams_er_erDb__WEBPACK_IMPORTED_MODULE_33__["default"];
break;
case 'journey':
_logger__WEBPACK_IMPORTED_MODULE_4__["logger"].debug('Journey');
parser = _diagrams_user_journey_parser_journey__WEBPACK_IMPORTED_MODULE_36___default.a;
parser.parser.yy = _diagrams_user_journey_journeyDb__WEBPACK_IMPORTED_MODULE_37__["default"];
break;
}
parser.parser.yy.parseError = function (str, hash) {
var error = {
str: str,
hash: hash
};
throw error;
};
parser.parse(text);
}
var encodeEntities = function encodeEntities(text) {
var txt = text;
txt = txt.replace(/style.*:\S*#.*;/g, function (s) {
var innerTxt = s.substring(0, s.length - 1);
return innerTxt;
});
txt = txt.replace(/classDef.*:\S*#.*;/g, function (s) {
var innerTxt = s.substring(0, s.length - 1);
return innerTxt;
});
txt = txt.replace(/#\w+;/g, function (s) {
var innerTxt = s.substring(1, s.length - 1);
var isInt = /^\+?\d+$/.test(innerTxt);
if (isInt) {
return 'fl°°' + innerTxt + '¶ß';
} else {
return 'fl°' + innerTxt + '¶ß';
}
});
return txt;
};
var decodeEntities = function decodeEntities(text) {
var txt = text;
txt = txt.replace(/fl°°/g, function () {
return '';
});
txt = txt.replace(/fl°/g, function () {
return '&';
});
txt = txt.replace(/¶ß/g, function () {
return ';';
});
return txt;
};
/**
* Function that renders an svg with a graph from a chart definition. Usage example below.
*
* ```js
* mermaidAPI.initialize({
* startOnLoad:true
* });
* $(function(){
* const graphDefinition = 'graph TB\na-->b';
* const cb = function(svgGraph){
* console.log(svgGraph);
* };
* mermaidAPI.render('id1',graphDefinition,cb);
* });
*```
* @param id the id of the element to be rendered
* @param txt the graph definition
* @param cb callback which is called after rendering is finished with the svg code as inparam.
* @param container selector to element in which a div with the graph temporarily will be inserted. In one is
* provided a hidden div will be inserted in the body of the page instead. The element will be removed when rendering is
* completed.
*/
var render = function render(id, _txt, cb, container) {
// Check the maximum allowed text size
var txt = _txt;
if (_txt.length > config.maxTextSize) {
txt = 'graph TB;a[Maximum text size in diagram exceeded];style a fill:#faa';
}
if (typeof container !== 'undefined') {
container.innerHTML = '';
Object(d3__WEBPACK_IMPORTED_MODULE_0__["select"])(container).append('div').attr('id', 'd' + id).attr('style', 'font-family: ' + config.fontFamily).append('svg').attr('id', id).attr('width', '100%').attr('xmlns', 'http://www.w3.org/2000/svg').append('g');
} else {
var existingSvg = document.getElementById(id);
if (existingSvg) {
existingSvg.remove();
}
var _element = document.querySelector('#' + 'd' + id);
if (_element) {
_element.innerHTML = '';
}
Object(d3__WEBPACK_IMPORTED_MODULE_0__["select"])('body').append('div').attr('id', 'd' + id).append('svg').attr('id', id).attr('width', '100%').attr('xmlns', 'http://www.w3.org/2000/svg').append('g');
}
window.txt = txt;
txt = encodeEntities(txt);
var element = Object(d3__WEBPACK_IMPORTED_MODULE_0__["select"])('#d' + id).node();
var graphType = _utils__WEBPACK_IMPORTED_MODULE_5__["default"].detectType(txt); // insert inline style into svg
var svg = element.firstChild;
var firstChild = svg.firstChild; // pre-defined theme
var style = themes[config.theme];
if (style === undefined) {
style = '';
} // user provided theme CSS
if (config.themeCSS !== undefined) {
style += "\n".concat(config.themeCSS);
} // user provided theme CSS
if (config.fontFamily !== undefined) {
style += "\n:root { --mermaid-font-family: ".concat(config.fontFamily, "}");
} // user provided theme CSS
if (config.altFontFamily !== undefined) {
style += "\n:root { --mermaid-alt-font-family: ".concat(config.altFontFamily, "}");
} // classDef
if (graphType === 'flowchart' || graphType === 'flowchart-v2') {
var classes = _diagrams_flowchart_flowRenderer__WEBPACK_IMPORTED_MODULE_6__["default"].getClasses(txt);
for (var className in classes) {
style += "\n.".concat(className, " > * { ").concat(classes[className].styles.join(' !important; '), " !important; }");
if (classes[className].textStyles) {
style += "\n.".concat(className, " tspan { ").concat(classes[className].textStyles.join(' !important; '), " !important; }");
}
}
}
var style1 = document.createElement('style');
style1.innerHTML = scope_css__WEBPACK_IMPORTED_MODULE_1___default()(style, "#".concat(id));
svg.insertBefore(style1, firstChild);
var style2 = document.createElement('style');
var cs = window.getComputedStyle(svg);
style2.innerHTML = "#".concat(id, " {\n color: ").concat(cs.color, ";\n font: ").concat(cs.font, ";\n }");
svg.insertBefore(style2, firstChild);
try {
switch (graphType) {
case 'git':
config.flowchart.arrowMarkerAbsolute = config.arrowMarkerAbsolute;
_diagrams_git_gitGraphRenderer__WEBPACK_IMPORTED_MODULE_23__["default"].setConf(config.git);
_diagrams_git_gitGraphRenderer__WEBPACK_IMPORTED_MODULE_23__["default"].draw(txt, id, false);
break;
case 'flowchart':
config.flowchart.arrowMarkerAbsolute = config.arrowMarkerAbsolute;
_diagrams_flowchart_flowRenderer__WEBPACK_IMPORTED_MODULE_6__["default"].setConf(config.flowchart);
_diagrams_flowchart_flowRenderer__WEBPACK_IMPORTED_MODULE_6__["default"].draw(txt, id, false);
break;
case 'flowchart-v2':
config.flowchart.arrowMarkerAbsolute = config.arrowMarkerAbsolute;
_diagrams_flowchart_flowRenderer_v2__WEBPACK_IMPORTED_MODULE_7__["default"].setConf(config.flowchart);
_diagrams_flowchart_flowRenderer_v2__WEBPACK_IMPORTED_MODULE_7__["default"].draw(txt, id, false);
break;
case 'sequence':
config.sequence.arrowMarkerAbsolute = config.arrowMarkerAbsolute;
if (config.sequenceDiagram) {
// backwards compatibility
_diagrams_sequence_sequenceRenderer__WEBPACK_IMPORTED_MODULE_10__["default"].setConf(Object.assign(config.sequence, config.sequenceDiagram));
console.error('`mermaid config.sequenceDiagram` has been renamed to `config.sequence`. Please update your mermaid config.');
} else {
_diagrams_sequence_sequenceRenderer__WEBPACK_IMPORTED_MODULE_10__["default"].setConf(config.sequence);
}
_diagrams_sequence_sequenceRenderer__WEBPACK_IMPORTED_MODULE_10__["default"].draw(txt, id);
break;
case 'gantt':
config.gantt.arrowMarkerAbsolute = config.arrowMarkerAbsolute;
_diagrams_gantt_ganttRenderer__WEBPACK_IMPORTED_MODULE_13__["default"].setConf(config.gantt);
_diagrams_gantt_ganttRenderer__WEBPACK_IMPORTED_MODULE_13__["default"].draw(txt, id);
break;
case 'class':
config.class.arrowMarkerAbsolute = config.arrowMarkerAbsolute;
_diagrams_class_classRenderer__WEBPACK_IMPORTED_MODULE_16__["default"].setConf(config.class);
_diagrams_class_classRenderer__WEBPACK_IMPORTED_MODULE_16__["default"].draw(txt, id);
break;
case 'state':
// config.class.arrowMarkerAbsolute = config.arrowMarkerAbsolute;
_diagrams_state_stateRenderer__WEBPACK_IMPORTED_MODULE_19__["default"].setConf(config.state);
_diagrams_state_stateRenderer__WEBPACK_IMPORTED_MODULE_19__["default"].draw(txt, id);
break;
case 'stateDiagram':
// config.class.arrowMarkerAbsolute = config.arrowMarkerAbsolute;
_diagrams_state_stateRenderer_v2__WEBPACK_IMPORTED_MODULE_20__["default"].setConf(config.state);
_diagrams_state_stateRenderer_v2__WEBPACK_IMPORTED_MODULE_20__["default"].draw(txt, id);
break;
case 'info':
config.class.arrowMarkerAbsolute = config.arrowMarkerAbsolute;
_diagrams_info_infoRenderer__WEBPACK_IMPORTED_MODULE_26__["default"].setConf(config.class);
_diagrams_info_infoRenderer__WEBPACK_IMPORTED_MODULE_26__["default"].draw(txt, id, _package_json__WEBPACK_IMPORTED_MODULE_2__.version);
break;
case 'pie':
config.class.arrowMarkerAbsolute = config.arrowMarkerAbsolute;
_diagrams_pie_pieRenderer__WEBPACK_IMPORTED_MODULE_30__["default"].setConf(config.class);
_diagrams_pie_pieRenderer__WEBPACK_IMPORTED_MODULE_30__["default"].draw(txt, id, _package_json__WEBPACK_IMPORTED_MODULE_2__.version);
break;
case 'er':
_diagrams_er_erRenderer__WEBPACK_IMPORTED_MODULE_35__["default"].setConf(config.er);
_diagrams_er_erRenderer__WEBPACK_IMPORTED_MODULE_35__["default"].draw(txt, id, _package_json__WEBPACK_IMPORTED_MODULE_2__.version);
break;
case 'journey':
_diagrams_user_journey_journeyRenderer__WEBPACK_IMPORTED_MODULE_38__["default"].setConf(config.journey);
_diagrams_user_journey_journeyRenderer__WEBPACK_IMPORTED_MODULE_38__["default"].draw(txt, id, _package_json__WEBPACK_IMPORTED_MODULE_2__.version);
break;
}
} catch (e) {
_errorRenderer__WEBPACK_IMPORTED_MODULE_27__["default"].setConf(config.class);
_errorRenderer__WEBPACK_IMPORTED_MODULE_27__["default"].draw(id, _package_json__WEBPACK_IMPORTED_MODULE_2__.version);
throw e;
}
Object(d3__WEBPACK_IMPORTED_MODULE_0__["select"])("[id=\"".concat(id, "\"]")).selectAll('foreignobject > *').attr('xmlns', 'http://www.w3.org/1999/xhtml'); // if (config.arrowMarkerAbsolute) {
// url =
// window.location.protocol +
// '//' +
// window.location.host +
// window.location.pathname +
// window.location.search;
// url = url.replace(/\(/g, '\\(');
// url = url.replace(/\)/g, '\\)');
// }
// Fix for when the base tag is used
var svgCode = Object(d3__WEBPACK_IMPORTED_MODULE_0__["select"])('#d' + id).node().innerHTML;
if (!config.arrowMarkerAbsolute || config.arrowMarkerAbsolute === 'false') {
svgCode = svgCode.replace(/marker-end="url\(.*?#/g, 'marker-end="url(#', 'g');
}
svgCode = decodeEntities(svgCode);
if (typeof cb !== 'undefined') {
switch (graphType) {
case 'flowchart':
case 'flowchart-v2':
cb(svgCode, _diagrams_flowchart_flowDb__WEBPACK_IMPORTED_MODULE_9__["default"].bindFunctions);
break;
case 'gantt':
cb(svgCode, _diagrams_gantt_ganttDb__WEBPACK_IMPORTED_MODULE_15__["default"].bindFunctions);
break;
case 'class':
cb(svgCode, _diagrams_class_classDb__WEBPACK_IMPORTED_MODULE_18__["default"].bindFunctions);
break;
default:
cb(svgCode);
}
} else {
_logger__WEBPACK_IMPORTED_MODULE_4__["logger"].debug('CB = undefined!');
}
var node = Object(d3__WEBPACK_IMPORTED_MODULE_0__["select"])('#d' + id).node();
if (node !== null && typeof node.remove === 'function') {
Object(d3__WEBPACK_IMPORTED_MODULE_0__["select"])('#d' + id).node().remove();
}
return svgCode;
};
var setConf = function setConf(cnf) {
// Top level initially mermaid, gflow, sequenceDiagram and gantt
var lvl1Keys = Object.keys(cnf);
for (var i = 0; i < lvl1Keys.length; i++) {
if (_typeof(cnf[lvl1Keys[i]]) === 'object' && cnf[lvl1Keys[i]] != null) {
var lvl2Keys = Object.keys(cnf[lvl1Keys[i]]);
for (var j = 0; j < lvl2Keys.length; j++) {
_logger__WEBPACK_IMPORTED_MODULE_4__["logger"].debug('Setting conf ', lvl1Keys[i], '-', lvl2Keys[j]);
if (typeof config[lvl1Keys[i]] === 'undefined') {
config[lvl1Keys[i]] = {};
}
_logger__WEBPACK_IMPORTED_MODULE_4__["logger"].debug('Setting config: ' + lvl1Keys[i] + ' ' + lvl2Keys[j] + ' to ' + cnf[lvl1Keys[i]][lvl2Keys[j]]);
config[lvl1Keys[i]][lvl2Keys[j]] = cnf[lvl1Keys[i]][lvl2Keys[j]];
}
} else {
config[lvl1Keys[i]] = cnf[lvl1Keys[i]];
}
}
};
function initialize(options) {
_logger__WEBPACK_IMPORTED_MODULE_4__["logger"].debug('Initializing mermaidAPI ', _package_json__WEBPACK_IMPORTED_MODULE_2__.version); // Update default config with options supplied at initialization
if (_typeof(options) === 'object') {
setConf(options);
}
Object(_config__WEBPACK_IMPORTED_MODULE_3__["setConfig"])(config);
Object(_logger__WEBPACK_IMPORTED_MODULE_4__["setLogLevel"])(config.logLevel);
} // function getConfig () {
// console.warn('get config')
// return config
// }
var mermaidAPI = {
render: render,
parse: parse,
initialize: initialize,
getConfig: _config__WEBPACK_IMPORTED_MODULE_3__["getConfig"]
};
/* harmony default export */ __webpack_exports__["default"] = (mermaidAPI);
/**
* ## mermaidAPI configuration defaults
*
*
* <script>
* var config = {
* theme:'default',
* logLevel:'fatal',
* securityLevel:'strict',
* startOnLoad:true,
* arrowMarkerAbsolute:false,
*
* flowchart:{
* htmlLabels:true,
* curve:'linear',
* },
* sequence:{
* diagramMarginX:50,
* diagramMarginY:10,
* actorMargin:50,
* width:150,
* height:65,
* boxMargin:10,
* boxTextMargin:5,
* noteMargin:10,
* messageMargin:35,
* messageAlign:'center',
* mirrorActors:true,
* bottomMarginAdj:1,
* useMaxWidth:true,
* rightAngles:false,
* showSequenceNumbers:false,
* },
* gantt:{
* titleTopMargin:25,
* barHeight:20,
* barGap:4,
* topPadding:50,
* leftPadding:75,
* gridLineStartPadding:35,
* fontSize:11,
* fontFamily:'"Open-Sans", "sans-serif"',
* numberSectionStyles:4,
* axisFormat:'%Y-%m-%d',
* }
* };
* mermaid.initialize(config);
* </script>
*
*/
/***/ }),
/***/ "./src/themes sync recursive ^\\.\\/.*\\/index\\.scss$":
/*!***********************************************!*\
!*** ./src/themes sync ^\.\/.*\/index\.scss$ ***!
\***********************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
var map = {
"./dark/index.scss": "./src/themes/dark/index.scss",
"./default/index.scss": "./src/themes/default/index.scss",
"./forest/index.scss": "./src/themes/forest/index.scss",
"./neutral/index.scss": "./src/themes/neutral/index.scss"
};
function webpackContext(req) {
var id = webpackContextResolve(req);
return __webpack_require__(id);
}
function webpackContextResolve(req) {
if(!__webpack_require__.o(map, req)) {
var e = new Error("Cannot find module '" + req + "'");
e.code = 'MODULE_NOT_FOUND';
throw e;
}
return map[req];
}
webpackContext.keys = function webpackContextKeys() {
return Object.keys(map);
};
webpackContext.resolve = webpackContextResolve;
module.exports = webpackContext;
webpackContext.id = "./src/themes sync recursive ^\\.\\/.*\\/index\\.scss$";
/***/ }),
/***/ "./src/themes/dark/index.scss":
/*!************************************!*\
!*** ./src/themes/dark/index.scss ***!
\************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
// css-to-string-loader: transforms styles from css-loader to a string output
// Get the styles
var styles = __webpack_require__(/*! !../../../node_modules/css-loader/dist/cjs.js!../../../node_modules/sass-loader/dist/cjs.js!./index.scss */ "./node_modules/css-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js!./src/themes/dark/index.scss");
if (typeof styles === 'string') {
// Return an existing string
module.exports = styles;
} else {
// Call the custom toString method from css-loader module
module.exports = styles.toString();
}
/***/ }),
/***/ "./src/themes/default/index.scss":
/*!***************************************!*\
!*** ./src/themes/default/index.scss ***!
\***************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
// css-to-string-loader: transforms styles from css-loader to a string output
// Get the styles
var styles = __webpack_require__(/*! !../../../node_modules/css-loader/dist/cjs.js!../../../node_modules/sass-loader/dist/cjs.js!./index.scss */ "./node_modules/css-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js!./src/themes/default/index.scss");
if (typeof styles === 'string') {
// Return an existing string
module.exports = styles;
} else {
// Call the custom toString method from css-loader module
module.exports = styles.toString();
}
/***/ }),
/***/ "./src/themes/forest/index.scss":
/*!**************************************!*\
!*** ./src/themes/forest/index.scss ***!
\**************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
// css-to-string-loader: transforms styles from css-loader to a string output
// Get the styles
var styles = __webpack_require__(/*! !../../../node_modules/css-loader/dist/cjs.js!../../../node_modules/sass-loader/dist/cjs.js!./index.scss */ "./node_modules/css-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js!./src/themes/forest/index.scss");
if (typeof styles === 'string') {
// Return an existing string
module.exports = styles;
} else {
// Call the custom toString method from css-loader module
module.exports = styles.toString();
}
/***/ }),
/***/ "./src/themes/neutral/index.scss":
/*!***************************************!*\
!*** ./src/themes/neutral/index.scss ***!
\***************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
// css-to-string-loader: transforms styles from css-loader to a string output
// Get the styles
var styles = __webpack_require__(/*! !../../../node_modules/css-loader/dist/cjs.js!../../../node_modules/sass-loader/dist/cjs.js!./index.scss */ "./node_modules/css-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js!./src/themes/neutral/index.scss");
if (typeof styles === 'string') {
// Return an existing string
module.exports = styles;
} else {
// Call the custom toString method from css-loader module
module.exports = styles.toString();
}
/***/ }),
/***/ "./src/utils.js":
/*!**********************!*\
!*** ./src/utils.js ***!
\**********************/
/*! exports provided: detectType, isSubstringInArray, interpolateToCurve, formatUrl, getStylesFromArray, generateId, default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "detectType", function() { return detectType; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isSubstringInArray", function() { return isSubstringInArray; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "interpolateToCurve", function() { return interpolateToCurve; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "formatUrl", function() { return formatUrl; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getStylesFromArray", function() { return getStylesFromArray; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "generateId", function() { return generateId; });
/* harmony import */ var d3__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! d3 */ "d3");
/* harmony import */ var d3__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(d3__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./logger */ "./src/logger.js");
/* harmony import */ var _braintree_sanitize_url__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @braintree/sanitize-url */ "@braintree/sanitize-url");
/* harmony import */ var _braintree_sanitize_url__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_braintree_sanitize_url__WEBPACK_IMPORTED_MODULE_2__);
// Effectively an enum of the supported curve types, accessible by name
var d3CurveTypes = {
curveBasis: d3__WEBPACK_IMPORTED_MODULE_0__["curveBasis"],
curveBasisClosed: d3__WEBPACK_IMPORTED_MODULE_0__["curveBasisClosed"],
curveBasisOpen: d3__WEBPACK_IMPORTED_MODULE_0__["curveBasisOpen"],
curveLinear: d3__WEBPACK_IMPORTED_MODULE_0__["curveLinear"],
curveLinearClosed: d3__WEBPACK_IMPORTED_MODULE_0__["curveLinearClosed"],
curveMonotoneX: d3__WEBPACK_IMPORTED_MODULE_0__["curveMonotoneX"],
curveMonotoneY: d3__WEBPACK_IMPORTED_MODULE_0__["curveMonotoneY"],
curveNatural: d3__WEBPACK_IMPORTED_MODULE_0__["curveNatural"],
curveStep: d3__WEBPACK_IMPORTED_MODULE_0__["curveStep"],
curveStepAfter: d3__WEBPACK_IMPORTED_MODULE_0__["curveStepAfter"],
curveStepBefore: d3__WEBPACK_IMPORTED_MODULE_0__["curveStepBefore"]
};
/**
* @function detectType
* Detects the type of the graph text.
* ```mermaid
* graph LR
* a-->b
* b-->c
* c-->d
* d-->e
* e-->f
* f-->g
* g-->h
* ```
*
* @param {string} text The text defining the graph
* @returns {string} A graph definition key
*/
var detectType = function detectType(text) {
text = text.replace(/^\s*%%.*\n/g, '\n');
_logger__WEBPACK_IMPORTED_MODULE_1__["logger"].debug('Detecting diagram type based on the text ' + text);
if (text.match(/^\s*sequenceDiagram/)) {
return 'sequence';
}
if (text.match(/^\s*gantt/)) {
return 'gantt';
}
if (text.match(/^\s*classDiagram/)) {
return 'class';
}
if (text.match(/^\s*stateDiagram-v2/)) {
return 'stateDiagram';
}
if (text.match(/^\s*stateDiagram/)) {
return 'state';
}
if (text.match(/^\s*gitGraph/)) {
return 'git';
}
if (text.match(/^\s*flowchart/)) {
return 'flowchart-v2';
}
if (text.match(/^\s*info/)) {
return 'info';
}
if (text.match(/^\s*pie/)) {
return 'pie';
}
if (text.match(/^\s*erDiagram/)) {
return 'er';
}
if (text.match(/^\s*journey/)) {
return 'journey';
}
return 'flowchart';
};
/**
* @function isSubstringInArray
* Detects whether a substring in present in a given array
* @param {string} str The substring to detect
* @param {array} arr The array to search
* @returns {number} the array index containing the substring or -1 if not present
**/
var isSubstringInArray = function isSubstringInArray(str, arr) {
for (var i = 0; i < arr.length; i++) {
if (arr[i].match(str)) return i;
}
return -1;
};
var interpolateToCurve = function interpolateToCurve(interpolate, defaultCurve) {
if (!interpolate) {
return defaultCurve;
}
var curveName = "curve".concat(interpolate.charAt(0).toUpperCase() + interpolate.slice(1));
return d3CurveTypes[curveName] || defaultCurve;
};
var formatUrl = function formatUrl(linkStr, config) {
var url = linkStr.trim();
if (url) {
if (config.securityLevel !== 'loose') {
return Object(_braintree_sanitize_url__WEBPACK_IMPORTED_MODULE_2__["sanitizeUrl"])(url);
}
return url;
}
};
var distance = function distance(p1, p2) {
return p1 && p2 ? Math.sqrt(Math.pow(p2.x - p1.x, 2) + Math.pow(p2.y - p1.y, 2)) : 0;
};
var traverseEdge = function traverseEdge(points) {
var prevPoint;
var totalDistance = 0;
points.forEach(function (point) {
totalDistance += distance(point, prevPoint);
prevPoint = point;
}); // Traverse half of total distance along points
var distanceToLabel = totalDistance / 2;
var remainingDistance = distanceToLabel;
var center;
prevPoint = undefined;
points.forEach(function (point) {
if (prevPoint && !center) {
var vectorDistance = distance(point, prevPoint);
if (vectorDistance < remainingDistance) {
remainingDistance -= vectorDistance;
} else {
// The point is remainingDistance from prevPoint in the vector between prevPoint and point
// Calculate the coordinates
var distanceRatio = remainingDistance / vectorDistance;
if (distanceRatio <= 0) center = prevPoint;
if (distanceRatio >= 1) center = {
x: point.x,
y: point.y
};
if (distanceRatio > 0 && distanceRatio < 1) {
center = {
x: (1 - distanceRatio) * prevPoint.x + distanceRatio * point.x,
y: (1 - distanceRatio) * prevPoint.y + distanceRatio * point.y
};
}
}
}
prevPoint = point;
});
return center;
};
var calcLabelPosition = function calcLabelPosition(points) {
var p = traverseEdge(points);
return p;
};
var calcCardinalityPosition = function calcCardinalityPosition(isRelationTypePresent, points, initialPosition) {
var prevPoint;
var totalDistance = 0; // eslint-disable-line
if (points[0] !== initialPosition) {
points = points.reverse();
}
points.forEach(function (point) {
totalDistance += distance(point, prevPoint);
prevPoint = point;
}); // Traverse only 25 total distance along points to find cardinality point
var distanceToCardinalityPoint = 25;
var remainingDistance = distanceToCardinalityPoint;
var center;
prevPoint = undefined;
points.forEach(function (point) {
if (prevPoint && !center) {
var vectorDistance = distance(point, prevPoint);
if (vectorDistance < remainingDistance) {
remainingDistance -= vectorDistance;
} else {
// The point is remainingDistance from prevPoint in the vector between prevPoint and point
// Calculate the coordinates
var distanceRatio = remainingDistance / vectorDistance;
if (distanceRatio <= 0) center = prevPoint;
if (distanceRatio >= 1) center = {
x: point.x,
y: point.y
};
if (distanceRatio > 0 && distanceRatio < 1) {
center = {
x: (1 - distanceRatio) * prevPoint.x + distanceRatio * point.x,
y: (1 - distanceRatio) * prevPoint.y + distanceRatio * point.y
};
}
}
}
prevPoint = point;
}); // if relation is present (Arrows will be added), change cardinality point off-set distance (d)
var d = isRelationTypePresent ? 10 : 5; //Calculate Angle for x and y axis
var angle = Math.atan2(points[0].y - center.y, points[0].x - center.x);
var cardinalityPosition = {
x: 0,
y: 0
}; //Calculation cardinality position using angle, center point on the line/curve but pendicular and with offset-distance
cardinalityPosition.x = Math.sin(angle) * d + (points[0].x + center.x) / 2;
cardinalityPosition.y = -Math.cos(angle) * d + (points[0].y + center.y) / 2;
return cardinalityPosition;
};
var getStylesFromArray = function getStylesFromArray(arr) {
var style = '';
var labelStyle = '';
for (var i = 0; i < arr.length; i++) {
if (typeof arr[i] !== 'undefined') {
// add text properties to label style definition
if (arr[i].startsWith('color:') || arr[i].startsWith('text-align:')) {
labelStyle = labelStyle + arr[i] + ';';
} else {
style = style + arr[i] + ';';
}
}
}
return {
style: style,
labelStyle: labelStyle
};
};
var cnt = 0;
var generateId = function generateId() {
cnt++;
return 'id-' + Math.random().toString(36).substr(2, 12) + '-' + cnt;
};
/* harmony default export */ __webpack_exports__["default"] = ({
detectType: detectType,
isSubstringInArray: isSubstringInArray,
interpolateToCurve: interpolateToCurve,
calcLabelPosition: calcLabelPosition,
calcCardinalityPosition: calcCardinalityPosition,
formatUrl: formatUrl,
getStylesFromArray: getStylesFromArray,
generateId: generateId
});
/***/ }),
/***/ "@braintree/sanitize-url":
/*!******************************************!*\
!*** external "@braintree/sanitize-url" ***!
\******************************************/
/*! no static exports found */
/***/ (function(module, exports) {
module.exports = require("@braintree/sanitize-url");
/***/ }),
/***/ "d3":
/*!*********************!*\
!*** external "d3" ***!
\*********************/
/*! no static exports found */
/***/ (function(module, exports) {
module.exports = require("d3");
/***/ }),
/***/ "dagre":
/*!************************!*\
!*** external "dagre" ***!
\************************/
/*! no static exports found */
/***/ (function(module, exports) {
module.exports = require("dagre");
/***/ }),
/***/ "dagre-d3":
/*!***************************!*\
!*** external "dagre-d3" ***!
\***************************/
/*! no static exports found */
/***/ (function(module, exports) {
module.exports = require("dagre-d3");
/***/ }),
/***/ "dagre-d3/lib/label/add-html-label.js":
/*!*******************************************************!*\
!*** external "dagre-d3/lib/label/add-html-label.js" ***!
\*******************************************************/
/*! no static exports found */
/***/ (function(module, exports) {
module.exports = require("dagre-d3/lib/label/add-html-label.js");
/***/ }),
/***/ "entity-decode/browser":
/*!****************************************!*\
!*** external "entity-decode/browser" ***!
\****************************************/
/*! no static exports found */
/***/ (function(module, exports) {
module.exports = require("entity-decode/browser");
/***/ }),
/***/ "graphlib":
/*!***************************!*\
!*** external "graphlib" ***!
\***************************/
/*! no static exports found */
/***/ (function(module, exports) {
module.exports = require("graphlib");
/***/ }),
/***/ "moment-mini":
/*!******************************!*\
!*** external "moment-mini" ***!
\******************************/
/*! no static exports found */
/***/ (function(module, exports) {
module.exports = require("moment-mini");
/***/ }),
/***/ "scope-css":
/*!****************************!*\
!*** external "scope-css" ***!
\****************************/
/*! no static exports found */
/***/ (function(module, exports) {
module.exports = require("scope-css");
/***/ })
/******/ })["default"];
});
//# sourceMappingURL=mermaid.core.js.map