Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

jssm

Package Overview
Dependencies
Maintainers
1
Versions
324
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jssm - npm Package Compare versions

Comparing version 2.2.0 to 2.3.0

src/js/tests/general.js

360

dist/jssm.es5.cjs.js

@@ -141,77 +141,100 @@ require=(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){

peg$c6 = peg$literalExpectation("<->", false),
peg$c7 = peg$otherExpectation("string"),
peg$c8 = function peg$c8(chars) {
return chars.join("");
},
peg$c9 = /^[0-9a-fA-F]/,
peg$c10 = peg$classExpectation([["0", "9"], ["a", "f"], ["A", "F"]], false, false),
peg$c11 = "\"",
peg$c12 = peg$literalExpectation("\"", false),
peg$c13 = "\\",
peg$c14 = peg$literalExpectation("\\", false),
peg$c15 = "/",
peg$c16 = peg$literalExpectation("/", false),
peg$c17 = "b",
peg$c18 = peg$literalExpectation("b", false),
peg$c19 = function peg$c19() {
peg$c7 = /^[0-9a-fA-F]/,
peg$c8 = peg$classExpectation([["0", "9"], ["a", "f"], ["A", "F"]], false, false),
peg$c9 = "\"",
peg$c10 = peg$literalExpectation("\"", false),
peg$c11 = "\\",
peg$c12 = peg$literalExpectation("\\", false),
peg$c13 = "/",
peg$c14 = peg$literalExpectation("/", false),
peg$c15 = "b",
peg$c16 = peg$literalExpectation("b", false),
peg$c17 = function peg$c17() {
return "\b";
},
peg$c20 = "f",
peg$c21 = peg$literalExpectation("f", false),
peg$c22 = function peg$c22() {
peg$c18 = "f",
peg$c19 = peg$literalExpectation("f", false),
peg$c20 = function peg$c20() {
return "\f";
},
peg$c23 = "n",
peg$c24 = peg$literalExpectation("n", false),
peg$c25 = function peg$c25() {
peg$c21 = "n",
peg$c22 = peg$literalExpectation("n", false),
peg$c23 = function peg$c23() {
return "\n";
},
peg$c26 = "r",
peg$c27 = peg$literalExpectation("r", false),
peg$c28 = function peg$c28() {
peg$c24 = "r",
peg$c25 = peg$literalExpectation("r", false),
peg$c26 = function peg$c26() {
return "\r";
},
peg$c29 = "t",
peg$c30 = peg$literalExpectation("t", false),
peg$c31 = function peg$c31() {
peg$c27 = "t",
peg$c28 = peg$literalExpectation("t", false),
peg$c29 = function peg$c29() {
return "\t";
},
peg$c32 = "v",
peg$c33 = peg$literalExpectation("v", false),
peg$c34 = function peg$c34() {
peg$c30 = "v",
peg$c31 = peg$literalExpectation("v", false),
peg$c32 = function peg$c32() {
return "\v";
},
peg$c35 = "u",
peg$c36 = peg$literalExpectation("u", false),
peg$c37 = function peg$c37(digits) {
peg$c33 = "u",
peg$c34 = peg$literalExpectation("u", false),
peg$c35 = function peg$c35(digits) {
return String.fromCharCode(parseInt(digits, 16));
},
peg$c38 = function peg$c38(Sequence) {
peg$c36 = function peg$c36(Sequence) {
return Sequence;
},
peg$c39 = /^[ -!#-[\]-\u10FFFF]/,
peg$c40 = peg$classExpectation([[" ", "!"], ["#", "["], ["]", "\u10FF"], "F", "F"], false, false),
peg$c41 = peg$otherExpectation("label"),
peg$c42 = /^[0-9a-zA-Z.+\-_&()%$#@!?<>,:;']/,
peg$c43 = peg$classExpectation([["0", "9"], ["a", "z"], ["A", "Z"], ".", "+", "-", "_", "&", "(", ")", "%", "$", "#", "@", "!", "?", "<", ">", ",", ":", ";", "'"], false, false),
peg$c37 = /^[ -!#-[\]-\u10FFFF]/,
peg$c38 = peg$classExpectation([[" ", "!"], ["#", "["], ["]", "\u10FF"], "F", "F"], false, false),
peg$c39 = peg$otherExpectation("string"),
peg$c40 = function peg$c40(chars) {
return chars.join("");
},
peg$c41 = peg$otherExpectation("atom"),
peg$c42 = /^[0-9a-zA-Z.+_&()%$#@!?,']/,
peg$c43 = peg$classExpectation([["0", "9"], ["a", "z"], ["A", "Z"], ".", "+", "_", "&", "(", ")", "%", "$", "#", "@", "!", "?", ",", "'"], false, false),
peg$c44 = function peg$c44(text) {
return text.join('');
},
peg$c45 = ":",
peg$c46 = peg$literalExpectation(":", false),
peg$c47 = ";",
peg$c48 = peg$literalExpectation(";", false),
peg$c49 = "{",
peg$c50 = peg$literalExpectation("{", false),
peg$c51 = "}",
peg$c52 = peg$literalExpectation("}", false),
peg$c53 = function peg$c53(ldesc, arrow, rdesc, label, tail) {
return { kind: arrow, to: label, se: tail === [] ? undefined : tail };
peg$c45 = peg$otherExpectation("label"),
peg$c46 = ":",
peg$c47 = peg$literalExpectation(":", false),
peg$c48 = ";",
peg$c49 = peg$literalExpectation(";", false),
peg$c50 = function peg$c50(text, value) {
return { text: text, value: value };
},
peg$c54 = function peg$c54(label, se) {
return { from: label, se: se === [] ? undefined : se };
peg$c51 = "{",
peg$c52 = peg$literalExpectation("{", false),
peg$c53 = "}",
peg$c54 = peg$literalExpectation("}", false),
peg$c55 = function peg$c55(descitems) {
return descitems;
},
peg$c55 = peg$otherExpectation("whitespace"),
peg$c56 = /^[ \t\n\r\x0B]/,
peg$c57 = peg$classExpectation([" ", "\t", "\n", "\r", "\x0B"], false, false),
peg$c56 = function peg$c56(ldesc, arrow, rdesc, label, tail) {
var base = { kind: arrow, to: label };
if (tail && tail !== []) {
base.se = tail;
}
if (ldesc) {
base.ldesc = ldesc;
}
if (rdesc) {
base.rdesc = rdesc;
}
return base;
},
peg$c57 = function peg$c57(label, se) {
var base = { from: label };
if (se && se !== []) {
base.se = se;
}
return base;
},
peg$c58 = peg$otherExpectation("whitespace"),
peg$c59 = /^[ \t\n\r\x0B]/,
peg$c60 = peg$classExpectation([" ", "\t", "\n", "\r", "\x0B"], false, false),
peg$currPos = 0,

@@ -434,48 +457,6 @@ peg$savedPos = 0,

function peg$parseString() {
var s0, s1, s2, s3;
peg$silentFails++;
s0 = peg$currPos;
s1 = peg$parseQuoteMark();
if (s1 !== peg$FAILED) {
s2 = [];
s3 = peg$parseChar();
while (s3 !== peg$FAILED) {
s2.push(s3);
s3 = peg$parseChar();
}
if (s2 !== peg$FAILED) {
s3 = peg$parseQuoteMark();
if (s3 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c8(s2);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
peg$silentFails--;
if (s0 === peg$FAILED) {
s1 = peg$FAILED;
if (peg$silentFails === 0) {
peg$fail(peg$c7);
}
}
return s0;
}
function peg$parseHexDigit() {
var s0;
if (peg$c9.test(input.charAt(peg$currPos))) {
if (peg$c7.test(input.charAt(peg$currPos))) {
s0 = input.charAt(peg$currPos);

@@ -486,3 +467,3 @@ peg$currPos++;

if (peg$silentFails === 0) {
peg$fail(peg$c10);
peg$fail(peg$c8);
}

@@ -503,3 +484,3 @@ }

if (input.charCodeAt(peg$currPos) === 34) {
s2 = peg$c11;
s2 = peg$c9;
peg$currPos++;

@@ -509,3 +490,3 @@ } else {

if (peg$silentFails === 0) {
peg$fail(peg$c12);
peg$fail(peg$c10);
}

@@ -515,3 +496,3 @@ }

if (input.charCodeAt(peg$currPos) === 92) {
s2 = peg$c13;
s2 = peg$c11;
peg$currPos++;

@@ -521,3 +502,3 @@ } else {

if (peg$silentFails === 0) {
peg$fail(peg$c14);
peg$fail(peg$c12);
}

@@ -527,3 +508,3 @@ }

if (input.charCodeAt(peg$currPos) === 47) {
s2 = peg$c15;
s2 = peg$c13;
peg$currPos++;

@@ -533,3 +514,3 @@ } else {

if (peg$silentFails === 0) {
peg$fail(peg$c16);
peg$fail(peg$c14);
}

@@ -540,3 +521,3 @@ }

if (input.charCodeAt(peg$currPos) === 98) {
s3 = peg$c17;
s3 = peg$c15;
peg$currPos++;

@@ -546,3 +527,3 @@ } else {

if (peg$silentFails === 0) {
peg$fail(peg$c18);
peg$fail(peg$c16);
}

@@ -552,3 +533,3 @@ }

peg$savedPos = s2;
s3 = peg$c19();
s3 = peg$c17();
}

@@ -559,3 +540,3 @@ s2 = s3;

if (input.charCodeAt(peg$currPos) === 102) {
s3 = peg$c20;
s3 = peg$c18;
peg$currPos++;

@@ -565,3 +546,3 @@ } else {

if (peg$silentFails === 0) {
peg$fail(peg$c21);
peg$fail(peg$c19);
}

@@ -571,3 +552,3 @@ }

peg$savedPos = s2;
s3 = peg$c22();
s3 = peg$c20();
}

@@ -578,3 +559,3 @@ s2 = s3;

if (input.charCodeAt(peg$currPos) === 110) {
s3 = peg$c23;
s3 = peg$c21;
peg$currPos++;

@@ -584,3 +565,3 @@ } else {

if (peg$silentFails === 0) {
peg$fail(peg$c24);
peg$fail(peg$c22);
}

@@ -590,3 +571,3 @@ }

peg$savedPos = s2;
s3 = peg$c25();
s3 = peg$c23();
}

@@ -597,3 +578,3 @@ s2 = s3;

if (input.charCodeAt(peg$currPos) === 114) {
s3 = peg$c26;
s3 = peg$c24;
peg$currPos++;

@@ -603,3 +584,3 @@ } else {

if (peg$silentFails === 0) {
peg$fail(peg$c27);
peg$fail(peg$c25);
}

@@ -609,3 +590,3 @@ }

peg$savedPos = s2;
s3 = peg$c28();
s3 = peg$c26();
}

@@ -616,3 +597,3 @@ s2 = s3;

if (input.charCodeAt(peg$currPos) === 116) {
s3 = peg$c29;
s3 = peg$c27;
peg$currPos++;

@@ -622,3 +603,3 @@ } else {

if (peg$silentFails === 0) {
peg$fail(peg$c30);
peg$fail(peg$c28);
}

@@ -628,3 +609,3 @@ }

peg$savedPos = s2;
s3 = peg$c31();
s3 = peg$c29();
}

@@ -635,3 +616,3 @@ s2 = s3;

if (input.charCodeAt(peg$currPos) === 118) {
s3 = peg$c32;
s3 = peg$c30;
peg$currPos++;

@@ -641,3 +622,3 @@ } else {

if (peg$silentFails === 0) {
peg$fail(peg$c33);
peg$fail(peg$c31);
}

@@ -647,3 +628,3 @@ }

peg$savedPos = s2;
s3 = peg$c34();
s3 = peg$c32();
}

@@ -654,3 +635,3 @@ s2 = s3;

if (input.charCodeAt(peg$currPos) === 117) {
s3 = peg$c35;
s3 = peg$c33;
peg$currPos++;

@@ -660,3 +641,3 @@ } else {

if (peg$silentFails === 0) {
peg$fail(peg$c36);
peg$fail(peg$c34);
}

@@ -700,3 +681,3 @@ }

peg$savedPos = s2;
s3 = peg$c37(s4);
s3 = peg$c35(s4);
s2 = s3;

@@ -722,3 +703,3 @@ } else {

peg$savedPos = s0;
s1 = peg$c38(s2);
s1 = peg$c36(s2);
s0 = s1;

@@ -742,3 +723,3 @@ } else {

if (input.charCodeAt(peg$currPos) === 92) {
s0 = peg$c13;
s0 = peg$c11;
peg$currPos++;

@@ -748,3 +729,3 @@ } else {

if (peg$silentFails === 0) {
peg$fail(peg$c14);
peg$fail(peg$c12);
}

@@ -760,3 +741,3 @@ }

if (input.charCodeAt(peg$currPos) === 34) {
s0 = peg$c11;
s0 = peg$c9;
peg$currPos++;

@@ -766,3 +747,3 @@ } else {

if (peg$silentFails === 0) {
peg$fail(peg$c12);
peg$fail(peg$c10);
}

@@ -777,3 +758,3 @@ }

if (peg$c39.test(input.charAt(peg$currPos))) {
if (peg$c37.test(input.charAt(peg$currPos))) {
s0 = input.charAt(peg$currPos);

@@ -784,3 +765,3 @@ peg$currPos++;

if (peg$silentFails === 0) {
peg$fail(peg$c40);
peg$fail(peg$c38);
}

@@ -792,3 +773,45 @@ }

function peg$parseLabel() {
function peg$parseString() {
var s0, s1, s2, s3;
peg$silentFails++;
s0 = peg$currPos;
s1 = peg$parseQuoteMark();
if (s1 !== peg$FAILED) {
s2 = [];
s3 = peg$parseChar();
while (s3 !== peg$FAILED) {
s2.push(s3);
s3 = peg$parseChar();
}
if (s2 !== peg$FAILED) {
s3 = peg$parseQuoteMark();
if (s3 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c40(s2);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
peg$silentFails--;
if (s0 === peg$FAILED) {
s1 = peg$FAILED;
if (peg$silentFails === 0) {
peg$fail(peg$c39);
}
}
return s0;
}
function peg$parseAtom() {
var s0, s1, s2;

@@ -829,11 +852,21 @@

s0 = s1;
peg$silentFails--;
if (s0 === peg$FAILED) {
s0 = peg$currPos;
s1 = peg$parseString();
if (s1 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c44(s1);
s1 = peg$FAILED;
if (peg$silentFails === 0) {
peg$fail(peg$c41);
}
s0 = s1;
}
return s0;
}
function peg$parseLabel() {
var s0, s1;
peg$silentFails++;
s0 = peg$parseAtom();
if (s0 === peg$FAILED) {
s0 = peg$parseString();
}
peg$silentFails--;

@@ -843,3 +876,3 @@ if (s0 === peg$FAILED) {

if (peg$silentFails === 0) {
peg$fail(peg$c41);
peg$fail(peg$c45);
}

@@ -854,3 +887,3 @@ }

s0 = peg$parseString();
s0 = peg$parseLabel();

@@ -867,3 +900,3 @@ return s0;

if (input.charCodeAt(peg$currPos) === 58) {
s2 = peg$c45;
s2 = peg$c46;
peg$currPos++;

@@ -873,3 +906,3 @@ } else {

if (peg$silentFails === 0) {
peg$fail(peg$c46);
peg$fail(peg$c47);
}

@@ -881,3 +914,3 @@ }

if (input.charCodeAt(peg$currPos) === 59) {
s4 = peg$c47;
s4 = peg$c48;
peg$currPos++;

@@ -887,7 +920,8 @@ } else {

if (peg$silentFails === 0) {
peg$fail(peg$c48);
peg$fail(peg$c49);
}
}
if (s4 !== peg$FAILED) {
s1 = [s1, s2, s3, s4];
peg$savedPos = s0;
s1 = peg$c50(s1, s3);
s0 = s1;

@@ -936,3 +970,3 @@ } else {

if (input.charCodeAt(peg$currPos) === 123) {
s1 = peg$c49;
s1 = peg$c51;
peg$currPos++;

@@ -942,3 +976,3 @@ } else {

if (peg$silentFails === 0) {
peg$fail(peg$c50);
peg$fail(peg$c52);
}

@@ -953,3 +987,3 @@ }

if (input.charCodeAt(peg$currPos) === 125) {
s3 = peg$c51;
s3 = peg$c53;
peg$currPos++;

@@ -959,7 +993,8 @@ } else {

if (peg$silentFails === 0) {
peg$fail(peg$c52);
peg$fail(peg$c54);
}
}
if (s3 !== peg$FAILED) {
s1 = [s1, s2, s3];
peg$savedPos = s0;
s1 = peg$c55(s2);
s0 = s1;

@@ -1016,3 +1051,3 @@ } else {

peg$savedPos = s0;
s1 = peg$c53(s2, s4, s6, s8, s10);
s1 = peg$c56(s2, s4, s6, s8, s10);
s0 = s1;

@@ -1074,3 +1109,3 @@ } else {

if (input.charCodeAt(peg$currPos) === 59) {
s4 = peg$c47;
s4 = peg$c48;
peg$currPos++;

@@ -1080,3 +1115,3 @@ } else {

if (peg$silentFails === 0) {
peg$fail(peg$c48);
peg$fail(peg$c49);
}

@@ -1088,3 +1123,3 @@ }

peg$savedPos = s0;
s1 = peg$c54(s1, s2);
s1 = peg$c57(s1, s2);
s0 = s1;

@@ -1133,3 +1168,3 @@ } else {

s0 = [];
if (peg$c56.test(input.charAt(peg$currPos))) {
if (peg$c59.test(input.charAt(peg$currPos))) {
s1 = input.charAt(peg$currPos);

@@ -1140,3 +1175,3 @@ peg$currPos++;

if (peg$silentFails === 0) {
peg$fail(peg$c57);
peg$fail(peg$c60);
}

@@ -1146,3 +1181,3 @@ }

s0.push(s1);
if (peg$c56.test(input.charAt(peg$currPos))) {
if (peg$c59.test(input.charAt(peg$currPos))) {
s1 = input.charAt(peg$currPos);

@@ -1153,3 +1188,3 @@ peg$currPos++;

if (peg$silentFails === 0) {
peg$fail(peg$c57);
peg$fail(peg$c60);
}

@@ -1162,3 +1197,3 @@ }

if (peg$silentFails === 0) {
peg$fail(peg$c55);
peg$fail(peg$c58);
}

@@ -1363,3 +1398,3 @@ }

});
exports.histograph = exports.rand_select = exports.seq = exports.machine = exports.version = undefined;
exports.histograph = exports.rand_select = exports.seq = exports.parse = exports.machine = exports.version = undefined;

@@ -1376,3 +1411,3 @@ var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

var version = '2.2.0'; // replaced from package.js in build
var version = '2.3.0'; // replaced from package.js in build

@@ -1920,2 +1955,3 @@

exports.machine = machine;
exports.parse = parse;
exports.seq = _jssmUtil.seq;

@@ -1922,0 +1958,0 @@ exports.rand_select = _jssmUtil.rand_select;

@@ -1,1 +0,1 @@

require=function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a="function"==typeof require&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n||e)},l,l.exports,e,t,n,r)}return n[o].exports}for(var i="function"==typeof require&&require,o=0;o<r.length;o++)s(r[o]);return s}({1:[function(require,module,exports){"use strict";function peg$SyntaxError(message,expected,found,location){this.message=message,this.expected=expected,this.found=found,this.location=location,this.name="SyntaxError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,peg$SyntaxError)}function peg$parse(input,options){function peg$literalExpectation(text,ignoreCase){return{type:"literal",text:text,ignoreCase:ignoreCase}}function peg$classExpectation(parts,inverted,ignoreCase){return{type:"class",parts:parts,inverted:inverted,ignoreCase:ignoreCase}}function peg$otherExpectation(description){return{type:"other",description:description}}function peg$computePosDetails(pos){var p,details=peg$posDetailsCache[pos];if(details)return details;for(p=pos-1;!peg$posDetailsCache[p];)p--;for(details={line:(details=peg$posDetailsCache[p]).line,column:details.column};p<pos;)10===input.charCodeAt(p)?(details.line++,details.column=1):details.column++,p++;return peg$posDetailsCache[pos]=details,details}function peg$computeLocation(startPos,endPos){var startPosDetails=peg$computePosDetails(startPos),endPosDetails=peg$computePosDetails(endPos);return{start:{offset:startPos,line:startPosDetails.line,column:startPosDetails.column},end:{offset:endPos,line:endPosDetails.line,column:endPosDetails.column}}}function peg$fail(expected){peg$currPos<peg$maxFailPos||(peg$currPos>peg$maxFailPos&&(peg$maxFailPos=peg$currPos,peg$maxFailExpected=[]),peg$maxFailExpected.push(expected))}function peg$buildStructuredError(expected,found,location){return new peg$SyntaxError(peg$SyntaxError.buildMessage(expected,found),expected,found,location)}function peg$parseExpression(){var s0,s1,s2;return s0=peg$currPos,s1=peg$parseWhitespace(),s1!==peg$FAILED&&(s2=peg$parseExpList())!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(peg$savedPos=s0,s0=s1=peg$c0(s2)):(peg$currPos=s0,s0=peg$FAILED),s0}function peg$parseForwardArrow(){var s0;return peg$silentFails++,input.substr(peg$currPos,2)===peg$c2?(s0=peg$c2,peg$currPos+=2):(s0=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c3)),peg$silentFails--,s0===peg$FAILED&&(peg$FAILED,0===peg$silentFails&&peg$fail(peg$c1)),s0}function peg$parseTwoWayArrow(){var s0;return peg$silentFails++,input.substr(peg$currPos,3)===peg$c5?(s0=peg$c5,peg$currPos+=3):(s0=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c6)),peg$silentFails--,s0===peg$FAILED&&(peg$FAILED,0===peg$silentFails&&peg$fail(peg$c4)),s0}function peg$parseArrow(){var s0;return(s0=peg$parseForwardArrow())===peg$FAILED&&(s0=peg$parseTwoWayArrow()),s0}function peg$parseString(){var s0,s2,s3;if(peg$silentFails++,s0=peg$currPos,peg$parseQuoteMark()!==peg$FAILED){for(s2=[],s3=peg$parseChar();s3!==peg$FAILED;)s2.push(s3),s3=peg$parseChar();s2!==peg$FAILED&&(s3=peg$parseQuoteMark())!==peg$FAILED?(peg$savedPos=s0,s0=peg$c8(s2)):(peg$currPos=s0,s0=peg$FAILED)}else peg$currPos=s0,s0=peg$FAILED;return peg$silentFails--,s0===peg$FAILED&&(peg$FAILED,0===peg$silentFails&&peg$fail(peg$c7)),s0}function peg$parseHexDigit(){var s0;return peg$c9.test(input.charAt(peg$currPos))?(s0=input.charAt(peg$currPos),peg$currPos++):(s0=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c10)),s0}function peg$parseChar(){var s0,s2,s3,s4,s5,s6,s7,s8,s9;return(s0=peg$parseUnescaped())===peg$FAILED&&(s0=peg$currPos,peg$parseEscape()!==peg$FAILED?(34===input.charCodeAt(peg$currPos)?(s2=peg$c11,peg$currPos++):(s2=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c12)),s2===peg$FAILED&&(92===input.charCodeAt(peg$currPos)?(s2=peg$c13,peg$currPos++):(s2=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c14)),s2===peg$FAILED&&(47===input.charCodeAt(peg$currPos)?(s2=peg$c15,peg$currPos++):(s2=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c16)),s2===peg$FAILED&&(s2=peg$currPos,98===input.charCodeAt(peg$currPos)?(s3=peg$c17,peg$currPos++):(s3=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c18)),s3!==peg$FAILED&&(peg$savedPos=s2,s3=peg$c19()),(s2=s3)===peg$FAILED&&(s2=peg$currPos,102===input.charCodeAt(peg$currPos)?(s3=peg$c20,peg$currPos++):(s3=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c21)),s3!==peg$FAILED&&(peg$savedPos=s2,s3=peg$c22()),(s2=s3)===peg$FAILED&&(s2=peg$currPos,110===input.charCodeAt(peg$currPos)?(s3=peg$c23,peg$currPos++):(s3=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c24)),s3!==peg$FAILED&&(peg$savedPos=s2,s3=peg$c25()),(s2=s3)===peg$FAILED&&(s2=peg$currPos,114===input.charCodeAt(peg$currPos)?(s3=peg$c26,peg$currPos++):(s3=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c27)),s3!==peg$FAILED&&(peg$savedPos=s2,s3=peg$c28()),(s2=s3)===peg$FAILED&&(s2=peg$currPos,116===input.charCodeAt(peg$currPos)?(s3=peg$c29,peg$currPos++):(s3=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c30)),s3!==peg$FAILED&&(peg$savedPos=s2,s3=peg$c31()),(s2=s3)===peg$FAILED&&(s2=peg$currPos,118===input.charCodeAt(peg$currPos)?(s3=peg$c32,peg$currPos++):(s3=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c33)),s3!==peg$FAILED&&(peg$savedPos=s2,s3=peg$c34()),(s2=s3)===peg$FAILED&&(s2=peg$currPos,117===input.charCodeAt(peg$currPos)?(s3=peg$c35,peg$currPos++):(s3=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c36)),s3!==peg$FAILED?(s4=peg$currPos,s5=peg$currPos,(s6=peg$parseHexDigit())!==peg$FAILED&&(s7=peg$parseHexDigit())!==peg$FAILED&&(s8=peg$parseHexDigit())!==peg$FAILED&&(s9=peg$parseHexDigit())!==peg$FAILED?s5=s6=[s6,s7,s8,s9]:(peg$currPos=s5,s5=peg$FAILED),(s4=s5!==peg$FAILED?input.substring(s4,peg$currPos):s5)!==peg$FAILED?(peg$savedPos=s2,s2=s3=peg$c37(s4)):(peg$currPos=s2,s2=peg$FAILED)):(peg$currPos=s2,s2=peg$FAILED)))))))))),s2!==peg$FAILED?(peg$savedPos=s0,s0=peg$c38(s2)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)),s0}function peg$parseEscape(){var s0;return 92===input.charCodeAt(peg$currPos)?(s0=peg$c13,peg$currPos++):(s0=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c14)),s0}function peg$parseQuoteMark(){var s0;return 34===input.charCodeAt(peg$currPos)?(s0=peg$c11,peg$currPos++):(s0=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c12)),s0}function peg$parseUnescaped(){var s0;return peg$c39.test(input.charAt(peg$currPos))?(s0=input.charAt(peg$currPos),peg$currPos++):(s0=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c40)),s0}function peg$parseLabel(){var s0,s1,s2;if(peg$silentFails++,s0=peg$currPos,s1=[],peg$c42.test(input.charAt(peg$currPos))?(s2=input.charAt(peg$currPos),peg$currPos++):(s2=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c43)),s2!==peg$FAILED)for(;s2!==peg$FAILED;)s1.push(s2),peg$c42.test(input.charAt(peg$currPos))?(s2=input.charAt(peg$currPos),peg$currPos++):(s2=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c43));else s1=peg$FAILED;return s1!==peg$FAILED&&(peg$savedPos=s0,s1=peg$c44(s1)),(s0=s1)===peg$FAILED&&(s0=peg$currPos,(s1=peg$parseString())!==peg$FAILED&&(peg$savedPos=s0,s1=peg$c44(s1)),s0=s1),peg$silentFails--,s0===peg$FAILED&&(s1=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c41)),s0}function peg$parseDescValue(){return peg$parseString()}function peg$parseDescItem(){var s0,s1,s2,s3,s4;return s0=peg$currPos,s1=peg$parseLabel(),s1!==peg$FAILED?(58===input.charCodeAt(peg$currPos)?(s2=peg$c45,peg$currPos++):(s2=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c46)),s2!==peg$FAILED&&(s3=peg$parseDescValue())!==peg$FAILED?(59===input.charCodeAt(peg$currPos)?(s4=peg$c47,peg$currPos++):(s4=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c48)),s4!==peg$FAILED?s0=s1=[s1,s2,s3,s4]:(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED),s0}function peg$parseDescItems(){var s0,s1;if(s0=[],(s1=peg$parseDescItem())!==peg$FAILED)for(;s1!==peg$FAILED;)s0.push(s1),s1=peg$parseDescItem();else s0=peg$FAILED;return s0}function peg$parseArrowDesc(){var s0,s1,s2,s3;return s0=peg$currPos,123===input.charCodeAt(peg$currPos)?(s1=peg$c49,peg$currPos++):(s1=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c50)),s1!==peg$FAILED?((s2=peg$parseDescItems())===peg$FAILED&&(s2=null),s2!==peg$FAILED?(125===input.charCodeAt(peg$currPos)?(s3=peg$c51,peg$currPos++):(s3=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c52)),s3!==peg$FAILED?s0=s1=[s1,s2,s3]:(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED),s0}function peg$parseSubexp(){var s0,s1,s2,s4,s6,s8,s10;return s0=peg$currPos,s1=peg$parseWhitespace(),s1!==peg$FAILED?((s2=peg$parseArrowDesc())===peg$FAILED&&(s2=null),s2!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED&&(s4=peg$parseArrow())!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?((s6=peg$parseArrowDesc())===peg$FAILED&&(s6=null),s6!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED&&(s8=peg$parseLabel())!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?((s10=peg$parseSubexp())===peg$FAILED&&(s10=null),s10!==peg$FAILED?(peg$savedPos=s0,s0=s1=peg$c53(s2,s4,s6,s8,s10)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED),s0}function peg$parseExp(){var s0,s1,s2,s4;return s0=peg$currPos,s1=peg$parseLabel(),s1!==peg$FAILED&&(s2=peg$parseSubexp())!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(59===input.charCodeAt(peg$currPos)?(s4=peg$c47,peg$currPos++):(s4=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c48)),s4!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(peg$savedPos=s0,s0=s1=peg$c54(s1,s2)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED),s0}function peg$parseExpList(){var s0,s1;for(s0=[],s1=peg$parseExp();s1!==peg$FAILED;)s0.push(s1),s1=peg$parseExp();return s0}function peg$parseWhitespace(){var s0,s1;for(peg$silentFails++,s0=[],peg$c56.test(input.charAt(peg$currPos))?(s1=input.charAt(peg$currPos),peg$currPos++):(s1=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c57));s1!==peg$FAILED;)s0.push(s1),peg$c56.test(input.charAt(peg$currPos))?(s1=input.charAt(peg$currPos),peg$currPos++):(s1=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c57));return peg$silentFails--,s0===peg$FAILED&&(s1=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c55)),s0}options=void 0!==options?options:{};var peg$result,peg$FAILED={},peg$startRuleFunctions={Expression:peg$parseExpression},peg$startRuleFunction=peg$parseExpression,peg$c0=function(e){return e},peg$c1=peg$otherExpectation("forward arrow"),peg$c2="->",peg$c3=peg$literalExpectation("->",!1),peg$c4=peg$otherExpectation("two way arrow"),peg$c5="<->",peg$c6=peg$literalExpectation("<->",!1),peg$c7=peg$otherExpectation("string"),peg$c8=function(chars){return chars.join("")},peg$c9=/^[0-9a-fA-F]/,peg$c10=peg$classExpectation([["0","9"],["a","f"],["A","F"]],!1,!1),peg$c11='"',peg$c12=peg$literalExpectation('"',!1),peg$c13="\\",peg$c14=peg$literalExpectation("\\",!1),peg$c15="/",peg$c16=peg$literalExpectation("/",!1),peg$c17="b",peg$c18=peg$literalExpectation("b",!1),peg$c19=function(){return"\b"},peg$c20="f",peg$c21=peg$literalExpectation("f",!1),peg$c22=function(){return"\f"},peg$c23="n",peg$c24=peg$literalExpectation("n",!1),peg$c25=function(){return"\n"},peg$c26="r",peg$c27=peg$literalExpectation("r",!1),peg$c28=function(){return"\r"},peg$c29="t",peg$c30=peg$literalExpectation("t",!1),peg$c31=function(){return"\t"},peg$c32="v",peg$c33=peg$literalExpectation("v",!1),peg$c34=function(){return"\v"},peg$c35="u",peg$c36=peg$literalExpectation("u",!1),peg$c37=function(digits){return String.fromCharCode(parseInt(digits,16))},peg$c38=function(Sequence){return Sequence},peg$c39=/^[ -!#-[\]-\u10FFFF]/,peg$c40=peg$classExpectation([[" ","!"],["#","["],["]","ჿ"],"F","F"],!1,!1),peg$c41=peg$otherExpectation("label"),peg$c42=/^[0-9a-zA-Z.+\-_&()%$#@!?<>,:;']/,peg$c43=peg$classExpectation([["0","9"],["a","z"],["A","Z"],".","+","-","_","&","(",")","%","$","#","@","!","?","<",">",",",":",";","'"],!1,!1),peg$c44=function(text){return text.join("")},peg$c45=":",peg$c46=peg$literalExpectation(":",!1),peg$c47=";",peg$c48=peg$literalExpectation(";",!1),peg$c49="{",peg$c50=peg$literalExpectation("{",!1),peg$c51="}",peg$c52=peg$literalExpectation("}",!1),peg$c53=function(ldesc,arrow,rdesc,label,tail){return{kind:arrow,to:label,se:tail===[]?void 0:tail}},peg$c54=function(label,se){return{from:label,se:se===[]?void 0:se}},peg$c55=peg$otherExpectation("whitespace"),peg$c56=/^[ \t\n\r\x0B]/,peg$c57=peg$classExpectation([" ","\t","\n","\r","\v"],!1,!1),peg$currPos=0,peg$savedPos=0,peg$posDetailsCache=[{line:1,column:1}],peg$maxFailPos=0,peg$maxFailExpected=[],peg$silentFails=0;if("startRule"in options){if(!(options.startRule in peg$startRuleFunctions))throw new Error("Can't start parsing from rule \""+options.startRule+'".');peg$startRuleFunction=peg$startRuleFunctions[options.startRule]}if((peg$result=peg$startRuleFunction())!==peg$FAILED&&peg$currPos===input.length)return peg$result;throw peg$result!==peg$FAILED&&peg$currPos<input.length&&peg$fail({type:"end"}),peg$buildStructuredError(peg$maxFailExpected,peg$maxFailPos<input.length?input.charAt(peg$maxFailPos):null,peg$maxFailPos<input.length?peg$computeLocation(peg$maxFailPos,peg$maxFailPos+1):peg$computeLocation(peg$maxFailPos,peg$maxFailPos))}!function(child,parent){function ctor(){this.constructor=child}ctor.prototype=parent.prototype,child.prototype=new ctor}(peg$SyntaxError,Error),peg$SyntaxError.buildMessage=function(expected,found){function hex(ch){return ch.charCodeAt(0).toString(16).toUpperCase()}function literalEscape(s){return s.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(ch){return"\\x0"+hex(ch)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(ch){return"\\x"+hex(ch)})}function classEscape(s){return s.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(ch){return"\\x0"+hex(ch)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(ch){return"\\x"+hex(ch)})}function describeExpectation(expectation){return DESCRIBE_EXPECTATION_FNS[expectation.type](expectation)}var DESCRIBE_EXPECTATION_FNS={literal:function(expectation){return'"'+literalEscape(expectation.text)+'"'},class:function(expectation){var i,escapedParts="";for(i=0;i<expectation.parts.length;i++)escapedParts+=expectation.parts[i]instanceof Array?classEscape(expectation.parts[i][0])+"-"+classEscape(expectation.parts[i][1]):classEscape(expectation.parts[i]);return"["+(expectation.inverted?"^":"")+escapedParts+"]"},any:function(expectation){return"any character"},end:function(expectation){return"end of input"},other:function(expectation){return expectation.description}};return"Expected "+function(expected){var i,j,descriptions=new Array(expected.length);for(i=0;i<expected.length;i++)descriptions[i]=describeExpectation(expected[i]);if(descriptions.sort(),descriptions.length>0){for(i=1,j=1;i<descriptions.length;i++)descriptions[i-1]!==descriptions[i]&&(descriptions[j]=descriptions[i],j++);descriptions.length=j}switch(descriptions.length){case 1:return descriptions[0];case 2:return descriptions[0]+" or "+descriptions[1];default:return descriptions.slice(0,-1).join(", ")+", or "+descriptions[descriptions.length-1]}}(expected)+" but "+function(found){return found?'"'+literalEscape(found)+'"':"end of input"}(found)+" found."},module.exports={SyntaxError:peg$SyntaxError,parse:peg$parse}},{}],2:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(obj){return typeof obj}:function(obj){return obj&&"function"==typeof Symbol&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj},rand_select=function(options){var probability_property=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"probability";if(!Array.isArray(options))throw new TypeError("options must be a non-empty array of objects");if("object"!==_typeof(options[0]))throw new TypeError("options must be a non-empty array of objects");for(var rnd=function(cap){return Math.random()*cap}(options.reduce(function(acc,val){return acc+val[probability_property]},0)),cursor=0,cursor_sum=0;(cursor_sum+=options[cursor++][probability_property])<=rnd;);return options[cursor-1]},seq=function(n){return new Array(n).fill(!0).map(function(_,i){return i})},histograph=function(a){return a.sort().reduce(function(m,v){return m.set(v,m.has(v)?m.get(v)+1:1),m},new Map)},sample_select=function(n,options,probability_property){return seq(n).map(function(i){return rand_select(options,probability_property)})},histo_key=function(n,options,probability_property,extract){return histograph(sample_select(n,options,probability_property).map(function(s){return s[extract]}))};exports.seq=seq,exports.histograph=histograph,exports.histo_key=histo_key,exports.rand_select=rand_select,exports.sample_select=sample_select},{}],3:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var viz=function(jssm){var l_states=jssm.states(),node_of=function(state){return"n"+l_states.indexOf(state)},vc=function(col){return jssm._viz_colors[col]||""},strike=[];return'digraph G {\n fontname="helvetica neue";\n style=filled;\n bgcolor=lightgrey;\n node [fontsize=14; shape=box; style=filled; fillcolor=white; fontname="helvetica neue"];\n edge [fontsize=6;fontname="helvetica neue"];\n\n '+l_states.map(function(s){jssm.state_for(s);var terminal=jssm.state_is_terminal(s),final=jssm.state_is_final(s),complete=jssm.state_is_complete(s),features=[["label",s],["peripheries",complete?2:1],["fillcolor",final?vc("fill_final"):complete?vc("fill_complete"):terminal?vc("fill_terminal"):""]].filter(function(r){return r[1]}).map(function(r){return r[0]+'="'+r[1]+'"'}).join(" ");return node_of(s)+" ["+features+"];"}).join(" ")+"\n\n "+jssm.states().map(function(s){return jssm.list_exits(s).map(function(ex){if(strike.find(function(row){return row[0]===s&&row[1]==ex}))return"";var edge=jssm.list_transitions(s,ex),pair=jssm.list_transitions(ex,s),double=pair&&s!==ex,if_obj_field=(jssm.state_for(s),jssm.state_for(ex),function(obj,field){return obj?obj[field]||"":""}),h_final=jssm.state_is_final(s),h_complete=jssm.state_is_complete(s),h_terminal=jssm.state_is_terminal(s),t_final=jssm.state_is_final(ex),t_complete=jssm.state_is_complete(ex),t_terminal=jssm.state_is_terminal(ex),lineColor=function(final,complete,terminal){var _solo_1_2=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"_solo";return vc(final?"line_final"+_solo_1_2:complete?"line_complete"+_solo_1_2:terminal?"line_terminal"+_solo_1_2:"normal_line"+_solo_1_2)},textColor=function(final,complete,terminal){var _solo_1_2=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"_solo";return final?vc("text_final"+_solo_1_2):complete?vc("text_complete"+_solo_1_2):terminal?vc("text_terminal"+_solo_1_2):""},labelInline=[[pair,"probability","headlabel","name","action",double,textColor(h_final,h_complete,h_terminal,double?"_1":"_solo")],[edge,"probability","taillabel","name","action",!0,textColor(t_final,t_complete,t_terminal,double?"_2":"_solo")]].map(function(r){return{which:r[2],whether:r[5]?[if_obj_field(r[0],r[5]),if_obj_field(r[0],r[1]),if_obj_field(r[0],r[3])].filter(function(q){return q}).join("<br/>")||"":"",color:r[6]}}).filter(function(present){return present.whether}).map(function(r){return r.which+"="+(r.color?'<<font color="'+r.color+'">'+r.whether+"</font>>":'"'+r.whether+'"')+";"}).join(" "),tc1=lineColor(t_final,t_complete,t_terminal,"_1"),tc2=lineColor(h_final,h_complete,h_terminal,"_2"),tcd=lineColor(t_final,t_complete,t_terminal,"_solo"),edgeInline=edge?double?'dir=both;color="'+tc1+":"+tc2+'"':'color="'+tcd+'"':"";return pair&&strike.push([ex,s]),node_of(s)+"->"+node_of(ex)+" ["+labelInline+edgeInline+"];"}).join(" ")}).join(" ")+"\n}"};exports.viz=viz},{}],jssm:[function(require,module,exports){"use strict";function _toConsumableArray(arr){if(Array.isArray(arr)){for(var i=0,arr2=Array(arr.length);i<arr.length;i++)arr2[i]=arr[i];return arr2}return Array.from(arr)}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(exports,"__esModule",{value:!0}),exports.histograph=exports.rand_select=exports.seq=exports.machine=exports.version=void 0;var _createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||!1,descriptor.configurable=!0,"value"in descriptor&&(descriptor.writable=!0),Object.defineProperty(target,descriptor.key,descriptor)}}return function(Constructor,protoProps,staticProps){return protoProps&&defineProperties(Constructor.prototype,protoProps),staticProps&&defineProperties(Constructor,staticProps),Constructor}}(),_jssmUtil=require("./jssm-util.js"),_jssmViz=require("./jssm-viz.js"),machine=(require("./jssm-dot.js").parse,function(){function machine(_ref){var _this=this,initial_state=_ref.initial_state,_ref$complete=_ref.complete,complete=void 0===_ref$complete?[]:_ref$complete,transitions=_ref.transitions;_classCallCheck(this,machine),this.set_viz_colors(),this._state=initial_state,this._states=new Map,this._edges=[],this._edge_map=new Map,this._named_transitions=new Map,this._actions=new Map,this._reverse_actions=new Map,this._reverse_action_targets=new Map,transitions.map(function(tr){if(void 0===tr.from)throw new Error("transition must define 'from': "+JSON.stringify(tr));if(void 0===tr.to)throw new Error("transition must define 'to': "+JSON.stringify(tr));var cursor_from=_this._states.get(tr.from);void 0===cursor_from&&(_this._new_state({name:tr.from,from:[],to:[],complete:complete.includes(tr.from)}),cursor_from=_this._states.get(tr.from));var cursor_to=_this._states.get(tr.to);if(void 0===cursor_to&&(_this._new_state({name:tr.to,from:[],to:[],complete:complete.includes(tr.to)}),cursor_to=_this._states.get(tr.to)),cursor_from.to.includes(tr.to))throw new Error("already has "+tr.from+" to "+tr.to);if(cursor_from.to.push(tr.to),cursor_to.from.includes(tr.from))throw new Error("already has "+tr.to+" from "+tr.from);cursor_to.from.push(tr.from),_this._edges.push(tr);var thisEdgeId=_this._edges.length-1;if(tr.name){if(_this._named_transitions.has(tr.name))throw new Error('named transition "'+tr.name+'" already created');_this._named_transitions.set(tr.name,thisEdgeId)}var from_mapping=_this._edge_map.get(tr.from);if(void 0===from_mapping&&(_this._edge_map.set(tr.from,new Map),from_mapping=_this._edge_map.get(tr.from)),from_mapping.get(tr.to))throw new Error("from -> to already exists "+tr.from+" "+tr.to);if(from_mapping.set(tr.to,thisEdgeId),tr.action){_this._actions.has(tr.action)||_this._actions.set(tr.action,new Map);var actionMap=_this._actions.get(tr.action);if(!actionMap)throw new Error("should be impossible, satisfying type checker that doesn't know .set precedes .get. severe error?");if(actionMap.has(tr.from))throw new Error("action "+tr.action+" already attached to origin "+tr.from);actionMap.set(tr.from,thisEdgeId),_this._reverse_actions.has(tr.from)||_this._reverse_actions.set(tr.from,new Map);var rActionMap=_this._reverse_actions.get(tr.from);if(!rActionMap)throw new Error("should be impossible, satisfying type checker that doesn't know .set precedes .get again. severe error?");if(rActionMap.has(tr.action))throw new Error("r-action "+tr.from+" already attached to action "+tr.action);rActionMap.set(tr.action,thisEdgeId),_this._reverse_action_targets.has(tr.to)||_this._reverse_action_targets.set(tr.to,new Map)}})}return _createClass(machine,[{key:"_new_state",value:function(state_config){if(this._states.has(state_config.name))throw new Error("state "+state_config.name+" already exists");return this._states.set(state_config.name,state_config),state_config.name}},{key:"state",value:function(){return this._state}},{key:"is_changing",value:function(){return!0}},{key:"state_is_final",value:function(whichState){return this.state_is_terminal(whichState)&&this.state_is_complete(whichState)}},{key:"is_final",value:function(){return!this.is_changing()&&this.state_is_final(this.state())}},{key:"machine_state",value:function(){return{internal_state_impl_version:1,actions:this._actions,edge_map:this._edge_map,edges:this._edges,named_transitions:this._named_transitions,reverse_actions:this._reverse_actions,state:this._state,states:this._states}}},{key:"load_machine_state",value:function(){return!1}},{key:"states",value:function(){return[].concat(_toConsumableArray(this._states.keys()))}},{key:"state_for",value:function(whichState){var state=this._states.get(whichState);if(state)return state;throw new Error("no such state "+JSON.stringify(state))}},{key:"list_transitions",value:function(){return this._edges}},{key:"list_named_transitions",value:function(){return this._named_transitions}},{key:"list_actions",value:function(){return[].concat(_toConsumableArray(this._actions.keys()))}},{key:"get_transition_by_id",value:function(from,to){return this._edge_map.has(from)?this._edge_map.get(from).get(to):void 0}},{key:"lookup_transition_for",value:function(from,to){var id=this.get_transition_by_id(from,to);return void 0===id?void 0:this._edges[id]}},{key:"list_transitions",value:function(){var whichState=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.state();return{entrances:this.list_entrances(whichState),exits:this.list_exits(whichState)}}},{key:"list_entrances",value:function(){var whichState=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.state();return(this._states.get(whichState)||{}).from}},{key:"list_exits",value:function(){var whichState=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.state();return(this._states.get(whichState)||{}).to}},{key:"probable_exits_for",value:function(whichState){var _this2=this;return(this._states.get(whichState)||{to:[]}).to.map(function(ws){return _this2.lookup_transition_for(_this2.state(),ws)}).filter(function(defined){return defined})||[]}},{key:"probabilistic_transition",value:function(){var selected=(0,_jssmUtil.rand_select)(this.probable_exits_for(this.state()));return this.transition(selected.to)}},{key:"probabilistic_walk",value:function(n){var _this3=this;return(0,_jssmUtil.seq)(n-1).map(function(i){var state_was=_this3.state();return _this3.probabilistic_transition(),state_was}).concat([this.state()])}},{key:"probabilistic_histo_walk",value:function(n){return(0,_jssmUtil.histograph)(this.probabilistic_walk(n))}},{key:"actions",value:function(){var whichState=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.state(),wstate=this._reverse_actions.get(whichState);if(wstate)return[].concat(_toConsumableArray(wstate.keys()));throw new Error("No such state "+JSON.stringify(whichState))}},{key:"list_states_having_action",value:function(whichState){var wstate=this._actions.get(whichState);if(wstate)return[].concat(_toConsumableArray(wstate.keys()));throw new Error("No such state "+JSON.stringify(whichState))}},{key:"list_exit_actions",value:function(){var _this4=this,whichState=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.state();return[].concat(_toConsumableArray((this._reverse_actions.get(whichState)||new Map).values())).map(function(edgeId){return _this4._edges[edgeId]}).filter(function(o){return o.from===whichState}).map(function(filtered){return filtered.action})}},{key:"probable_action_exits",value:function(){var _this5=this,whichState=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.state();return[].concat(_toConsumableArray((this._reverse_actions.get(whichState)||new Map).values())).map(function(edgeId){return _this5._edges[edgeId]}).filter(function(o){return o.from===whichState}).map(function(filtered){return{action:filtered.action,probability:filtered.probability}})}},{key:"is_unenterable",value:function(whichState){return 0===this.list_entrances(whichState).length}},{key:"has_unenterables",value:function(){return this.states.some(this.is_unenterable)}},{key:"is_terminal",value:function(){return this.state_is_terminal(this.state())}},{key:"state_is_terminal",value:function(whichState){return 0===this.list_exits(whichState).length}},{key:"has_terminals",value:function(){return this.states.some(this.state_is_terminal)}},{key:"is_complete",value:function(){return this.state_is_complete(this.state())}},{key:"state_is_complete",value:function(whichState){var wstate=this._states.get(whichState);if(wstate)return wstate.complete;throw new Error("No such state "+JSON.stringify(whichState))}},{key:"has_completes",value:function(){return this.states.some(this.state_is_complete)}},{key:"action",value:function(name,newData){if(this.valid_action(name,newData)){var edge=this.current_action_edge_for(name);if(!edge)throw new Error("Should be impossible - valid_action true, no edge in current_action_edge_for, in action("+JSON.stringify(name)+"...)");return this._state=edge.to,!0}return!1}},{key:"transition",value:function(newState,newData){return!!this.valid_transition(newState,newData)&&(this._state=newState,!0)}},{key:"force_transition",value:function(newState,newData){return!!this.valid_force_transition(newState,newData)&&(this._state=newState,!0)}},{key:"current_action_for",value:function(action){var action_base=this._actions.get(action);return action_base?action_base.get(this.state()):void 0}},{key:"current_action_edge_for",value:function(action){var idx=this.current_action_for(action);return void 0!==idx?this._edges[idx]:void 0}},{key:"valid_action",value:function(action,newData){return void 0!==this.current_action_for(action)}},{key:"valid_transition",value:function(newState,newData){return void 0!==this.lookup_transition_for(this.state(),newState)}},{key:"valid_force_transition",value:function(newState,newData){return!1}},{key:"viz",value:function(){return(0,_jssmViz.viz)(this)}},{key:"set_viz_colors",value:function(){this._viz_colors={fill_final:"#eeeeff",fill_terminal:"#ffeeee",fill_complete:"#eeffee",normal_line_1:"#999999",normal_line_2:"#888888",normal_line_solo:"#888888",line_final_1:"#8888bb",line_final_2:"#7777aa",line_final_solo:"#7777aa",line_terminal_1:"#bb8888",line_terminal_2:"#aa7777",line_terminal_solo:"#aa7777",line_complete_1:"#88bb88",line_complete_2:"#77aa77",line_complete_solo:"#77aa77",text_final_1:"#000088",text_final_2:"#000088",text_final_solo:"#000088",text_terminal_1:"#880000",text_terminal_2:"#880000",text_terminal_solo:"#880000",text_complete_1:"#007700",text_complete_2:"#007700",text_complete_solo:"#007700"}}}]),machine}());exports.version="2.2.0",exports.machine=machine,exports.seq=_jssmUtil.seq,exports.rand_select=_jssmUtil.rand_select,exports.histograph=_jssmUtil.histograph},{"./jssm-dot.js":1,"./jssm-util.js":2,"./jssm-viz.js":3}]},{},[]);
require=function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a="function"==typeof require&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n||e)},l,l.exports,e,t,n,r)}return n[o].exports}for(var i="function"==typeof require&&require,o=0;o<r.length;o++)s(r[o]);return s}({1:[function(require,module,exports){"use strict";function peg$SyntaxError(message,expected,found,location){this.message=message,this.expected=expected,this.found=found,this.location=location,this.name="SyntaxError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,peg$SyntaxError)}function peg$parse(input,options){function peg$literalExpectation(text,ignoreCase){return{type:"literal",text:text,ignoreCase:ignoreCase}}function peg$classExpectation(parts,inverted,ignoreCase){return{type:"class",parts:parts,inverted:inverted,ignoreCase:ignoreCase}}function peg$otherExpectation(description){return{type:"other",description:description}}function peg$computePosDetails(pos){var p,details=peg$posDetailsCache[pos];if(details)return details;for(p=pos-1;!peg$posDetailsCache[p];)p--;for(details={line:(details=peg$posDetailsCache[p]).line,column:details.column};p<pos;)10===input.charCodeAt(p)?(details.line++,details.column=1):details.column++,p++;return peg$posDetailsCache[pos]=details,details}function peg$computeLocation(startPos,endPos){var startPosDetails=peg$computePosDetails(startPos),endPosDetails=peg$computePosDetails(endPos);return{start:{offset:startPos,line:startPosDetails.line,column:startPosDetails.column},end:{offset:endPos,line:endPosDetails.line,column:endPosDetails.column}}}function peg$fail(expected){peg$currPos<peg$maxFailPos||(peg$currPos>peg$maxFailPos&&(peg$maxFailPos=peg$currPos,peg$maxFailExpected=[]),peg$maxFailExpected.push(expected))}function peg$buildStructuredError(expected,found,location){return new peg$SyntaxError(peg$SyntaxError.buildMessage(expected,found),expected,found,location)}function peg$parseExpression(){var s0,s1,s2;return s0=peg$currPos,s1=peg$parseWhitespace(),s1!==peg$FAILED&&(s2=peg$parseExpList())!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(peg$savedPos=s0,s0=s1=peg$c0(s2)):(peg$currPos=s0,s0=peg$FAILED),s0}function peg$parseForwardArrow(){var s0;return peg$silentFails++,input.substr(peg$currPos,2)===peg$c2?(s0=peg$c2,peg$currPos+=2):(s0=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c3)),peg$silentFails--,s0===peg$FAILED&&(peg$FAILED,0===peg$silentFails&&peg$fail(peg$c1)),s0}function peg$parseTwoWayArrow(){var s0;return peg$silentFails++,input.substr(peg$currPos,3)===peg$c5?(s0=peg$c5,peg$currPos+=3):(s0=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c6)),peg$silentFails--,s0===peg$FAILED&&(peg$FAILED,0===peg$silentFails&&peg$fail(peg$c4)),s0}function peg$parseArrow(){var s0;return(s0=peg$parseForwardArrow())===peg$FAILED&&(s0=peg$parseTwoWayArrow()),s0}function peg$parseHexDigit(){var s0;return peg$c7.test(input.charAt(peg$currPos))?(s0=input.charAt(peg$currPos),peg$currPos++):(s0=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c8)),s0}function peg$parseChar(){var s0,s2,s3,s4,s5,s6,s7,s8,s9;return(s0=peg$parseUnescaped())===peg$FAILED&&(s0=peg$currPos,peg$parseEscape()!==peg$FAILED?(34===input.charCodeAt(peg$currPos)?(s2=peg$c9,peg$currPos++):(s2=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c10)),s2===peg$FAILED&&(92===input.charCodeAt(peg$currPos)?(s2=peg$c11,peg$currPos++):(s2=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c12)),s2===peg$FAILED&&(47===input.charCodeAt(peg$currPos)?(s2=peg$c13,peg$currPos++):(s2=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c14)),s2===peg$FAILED&&(s2=peg$currPos,98===input.charCodeAt(peg$currPos)?(s3=peg$c15,peg$currPos++):(s3=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c16)),s3!==peg$FAILED&&(peg$savedPos=s2,s3=peg$c17()),(s2=s3)===peg$FAILED&&(s2=peg$currPos,102===input.charCodeAt(peg$currPos)?(s3=peg$c18,peg$currPos++):(s3=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c19)),s3!==peg$FAILED&&(peg$savedPos=s2,s3=peg$c20()),(s2=s3)===peg$FAILED&&(s2=peg$currPos,110===input.charCodeAt(peg$currPos)?(s3=peg$c21,peg$currPos++):(s3=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c22)),s3!==peg$FAILED&&(peg$savedPos=s2,s3=peg$c23()),(s2=s3)===peg$FAILED&&(s2=peg$currPos,114===input.charCodeAt(peg$currPos)?(s3=peg$c24,peg$currPos++):(s3=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c25)),s3!==peg$FAILED&&(peg$savedPos=s2,s3=peg$c26()),(s2=s3)===peg$FAILED&&(s2=peg$currPos,116===input.charCodeAt(peg$currPos)?(s3=peg$c27,peg$currPos++):(s3=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c28)),s3!==peg$FAILED&&(peg$savedPos=s2,s3=peg$c29()),(s2=s3)===peg$FAILED&&(s2=peg$currPos,118===input.charCodeAt(peg$currPos)?(s3=peg$c30,peg$currPos++):(s3=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c31)),s3!==peg$FAILED&&(peg$savedPos=s2,s3=peg$c32()),(s2=s3)===peg$FAILED&&(s2=peg$currPos,117===input.charCodeAt(peg$currPos)?(s3=peg$c33,peg$currPos++):(s3=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c34)),s3!==peg$FAILED?(s4=peg$currPos,s5=peg$currPos,(s6=peg$parseHexDigit())!==peg$FAILED&&(s7=peg$parseHexDigit())!==peg$FAILED&&(s8=peg$parseHexDigit())!==peg$FAILED&&(s9=peg$parseHexDigit())!==peg$FAILED?s5=s6=[s6,s7,s8,s9]:(peg$currPos=s5,s5=peg$FAILED),(s4=s5!==peg$FAILED?input.substring(s4,peg$currPos):s5)!==peg$FAILED?(peg$savedPos=s2,s2=s3=peg$c35(s4)):(peg$currPos=s2,s2=peg$FAILED)):(peg$currPos=s2,s2=peg$FAILED)))))))))),s2!==peg$FAILED?(peg$savedPos=s0,s0=peg$c36(s2)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)),s0}function peg$parseEscape(){var s0;return 92===input.charCodeAt(peg$currPos)?(s0=peg$c11,peg$currPos++):(s0=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c12)),s0}function peg$parseQuoteMark(){var s0;return 34===input.charCodeAt(peg$currPos)?(s0=peg$c9,peg$currPos++):(s0=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c10)),s0}function peg$parseUnescaped(){var s0;return peg$c37.test(input.charAt(peg$currPos))?(s0=input.charAt(peg$currPos),peg$currPos++):(s0=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c38)),s0}function peg$parseString(){var s0,s2,s3;if(peg$silentFails++,s0=peg$currPos,peg$parseQuoteMark()!==peg$FAILED){for(s2=[],s3=peg$parseChar();s3!==peg$FAILED;)s2.push(s3),s3=peg$parseChar();s2!==peg$FAILED&&(s3=peg$parseQuoteMark())!==peg$FAILED?(peg$savedPos=s0,s0=peg$c40(s2)):(peg$currPos=s0,s0=peg$FAILED)}else peg$currPos=s0,s0=peg$FAILED;return peg$silentFails--,s0===peg$FAILED&&(peg$FAILED,0===peg$silentFails&&peg$fail(peg$c39)),s0}function peg$parseAtom(){var s0,s1,s2;if(peg$silentFails++,s0=peg$currPos,s1=[],peg$c42.test(input.charAt(peg$currPos))?(s2=input.charAt(peg$currPos),peg$currPos++):(s2=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c43)),s2!==peg$FAILED)for(;s2!==peg$FAILED;)s1.push(s2),peg$c42.test(input.charAt(peg$currPos))?(s2=input.charAt(peg$currPos),peg$currPos++):(s2=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c43));else s1=peg$FAILED;return s1!==peg$FAILED&&(peg$savedPos=s0,s1=peg$c44(s1)),s0=s1,peg$silentFails--,s0===peg$FAILED&&(s1=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c41)),s0}function peg$parseLabel(){var s0;return peg$silentFails++,(s0=peg$parseAtom())===peg$FAILED&&(s0=peg$parseString()),peg$silentFails--,s0===peg$FAILED&&(peg$FAILED,0===peg$silentFails&&peg$fail(peg$c45)),s0}function peg$parseDescValue(){return peg$parseLabel()}function peg$parseDescItem(){var s0,s1,s2,s3,s4;return s0=peg$currPos,s1=peg$parseLabel(),s1!==peg$FAILED?(58===input.charCodeAt(peg$currPos)?(s2=peg$c46,peg$currPos++):(s2=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c47)),s2!==peg$FAILED&&(s3=peg$parseDescValue())!==peg$FAILED?(59===input.charCodeAt(peg$currPos)?(s4=peg$c48,peg$currPos++):(s4=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c49)),s4!==peg$FAILED?(peg$savedPos=s0,s0=s1=peg$c50(s1,s3)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED),s0}function peg$parseDescItems(){var s0,s1;if(s0=[],(s1=peg$parseDescItem())!==peg$FAILED)for(;s1!==peg$FAILED;)s0.push(s1),s1=peg$parseDescItem();else s0=peg$FAILED;return s0}function peg$parseArrowDesc(){var s0,s1,s2,s3;return s0=peg$currPos,123===input.charCodeAt(peg$currPos)?(s1=peg$c51,peg$currPos++):(s1=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c52)),s1!==peg$FAILED?((s2=peg$parseDescItems())===peg$FAILED&&(s2=null),s2!==peg$FAILED?(125===input.charCodeAt(peg$currPos)?(s3=peg$c53,peg$currPos++):(s3=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c54)),s3!==peg$FAILED?(peg$savedPos=s0,s0=s1=peg$c55(s2)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED),s0}function peg$parseSubexp(){var s0,s1,s2,s4,s6,s8,s10;return s0=peg$currPos,s1=peg$parseWhitespace(),s1!==peg$FAILED?((s2=peg$parseArrowDesc())===peg$FAILED&&(s2=null),s2!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED&&(s4=peg$parseArrow())!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?((s6=peg$parseArrowDesc())===peg$FAILED&&(s6=null),s6!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED&&(s8=peg$parseLabel())!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?((s10=peg$parseSubexp())===peg$FAILED&&(s10=null),s10!==peg$FAILED?(peg$savedPos=s0,s0=s1=peg$c56(s2,s4,s6,s8,s10)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED),s0}function peg$parseExp(){var s0,s1,s2,s4;return s0=peg$currPos,s1=peg$parseLabel(),s1!==peg$FAILED&&(s2=peg$parseSubexp())!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(59===input.charCodeAt(peg$currPos)?(s4=peg$c48,peg$currPos++):(s4=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c49)),s4!==peg$FAILED&&peg$parseWhitespace()!==peg$FAILED?(peg$savedPos=s0,s0=s1=peg$c57(s1,s2)):(peg$currPos=s0,s0=peg$FAILED)):(peg$currPos=s0,s0=peg$FAILED),s0}function peg$parseExpList(){var s0,s1;for(s0=[],s1=peg$parseExp();s1!==peg$FAILED;)s0.push(s1),s1=peg$parseExp();return s0}function peg$parseWhitespace(){var s0,s1;for(peg$silentFails++,s0=[],peg$c59.test(input.charAt(peg$currPos))?(s1=input.charAt(peg$currPos),peg$currPos++):(s1=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c60));s1!==peg$FAILED;)s0.push(s1),peg$c59.test(input.charAt(peg$currPos))?(s1=input.charAt(peg$currPos),peg$currPos++):(s1=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c60));return peg$silentFails--,s0===peg$FAILED&&(s1=peg$FAILED,0===peg$silentFails&&peg$fail(peg$c58)),s0}options=void 0!==options?options:{};var peg$result,peg$FAILED={},peg$startRuleFunctions={Expression:peg$parseExpression},peg$startRuleFunction=peg$parseExpression,peg$c0=function(e){return e},peg$c1=peg$otherExpectation("forward arrow"),peg$c2="->",peg$c3=peg$literalExpectation("->",!1),peg$c4=peg$otherExpectation("two way arrow"),peg$c5="<->",peg$c6=peg$literalExpectation("<->",!1),peg$c7=/^[0-9a-fA-F]/,peg$c8=peg$classExpectation([["0","9"],["a","f"],["A","F"]],!1,!1),peg$c9='"',peg$c10=peg$literalExpectation('"',!1),peg$c11="\\",peg$c12=peg$literalExpectation("\\",!1),peg$c13="/",peg$c14=peg$literalExpectation("/",!1),peg$c15="b",peg$c16=peg$literalExpectation("b",!1),peg$c17=function(){return"\b"},peg$c18="f",peg$c19=peg$literalExpectation("f",!1),peg$c20=function(){return"\f"},peg$c21="n",peg$c22=peg$literalExpectation("n",!1),peg$c23=function(){return"\n"},peg$c24="r",peg$c25=peg$literalExpectation("r",!1),peg$c26=function(){return"\r"},peg$c27="t",peg$c28=peg$literalExpectation("t",!1),peg$c29=function(){return"\t"},peg$c30="v",peg$c31=peg$literalExpectation("v",!1),peg$c32=function(){return"\v"},peg$c33="u",peg$c34=peg$literalExpectation("u",!1),peg$c35=function(digits){return String.fromCharCode(parseInt(digits,16))},peg$c36=function(Sequence){return Sequence},peg$c37=/^[ -!#-[\]-\u10FFFF]/,peg$c38=peg$classExpectation([[" ","!"],["#","["],["]","ჿ"],"F","F"],!1,!1),peg$c39=peg$otherExpectation("string"),peg$c40=function(chars){return chars.join("")},peg$c41=peg$otherExpectation("atom"),peg$c42=/^[0-9a-zA-Z.+_&()%$#@!?,']/,peg$c43=peg$classExpectation([["0","9"],["a","z"],["A","Z"],".","+","_","&","(",")","%","$","#","@","!","?",",","'"],!1,!1),peg$c44=function(text){return text.join("")},peg$c45=peg$otherExpectation("label"),peg$c46=":",peg$c47=peg$literalExpectation(":",!1),peg$c48=";",peg$c49=peg$literalExpectation(";",!1),peg$c50=function(text,value){return{text:text,value:value}},peg$c51="{",peg$c52=peg$literalExpectation("{",!1),peg$c53="}",peg$c54=peg$literalExpectation("}",!1),peg$c55=function(descitems){return descitems},peg$c56=function(ldesc,arrow,rdesc,label,tail){var base={kind:arrow,to:label};return tail&&tail!==[]&&(base.se=tail),ldesc&&(base.ldesc=ldesc),rdesc&&(base.rdesc=rdesc),base},peg$c57=function(label,se){var base={from:label};return se&&se!==[]&&(base.se=se),base},peg$c58=peg$otherExpectation("whitespace"),peg$c59=/^[ \t\n\r\x0B]/,peg$c60=peg$classExpectation([" ","\t","\n","\r","\v"],!1,!1),peg$currPos=0,peg$savedPos=0,peg$posDetailsCache=[{line:1,column:1}],peg$maxFailPos=0,peg$maxFailExpected=[],peg$silentFails=0;if("startRule"in options){if(!(options.startRule in peg$startRuleFunctions))throw new Error("Can't start parsing from rule \""+options.startRule+'".');peg$startRuleFunction=peg$startRuleFunctions[options.startRule]}if((peg$result=peg$startRuleFunction())!==peg$FAILED&&peg$currPos===input.length)return peg$result;throw peg$result!==peg$FAILED&&peg$currPos<input.length&&peg$fail({type:"end"}),peg$buildStructuredError(peg$maxFailExpected,peg$maxFailPos<input.length?input.charAt(peg$maxFailPos):null,peg$maxFailPos<input.length?peg$computeLocation(peg$maxFailPos,peg$maxFailPos+1):peg$computeLocation(peg$maxFailPos,peg$maxFailPos))}!function(child,parent){function ctor(){this.constructor=child}ctor.prototype=parent.prototype,child.prototype=new ctor}(peg$SyntaxError,Error),peg$SyntaxError.buildMessage=function(expected,found){function hex(ch){return ch.charCodeAt(0).toString(16).toUpperCase()}function literalEscape(s){return s.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(ch){return"\\x0"+hex(ch)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(ch){return"\\x"+hex(ch)})}function classEscape(s){return s.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(ch){return"\\x0"+hex(ch)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(ch){return"\\x"+hex(ch)})}function describeExpectation(expectation){return DESCRIBE_EXPECTATION_FNS[expectation.type](expectation)}var DESCRIBE_EXPECTATION_FNS={literal:function(expectation){return'"'+literalEscape(expectation.text)+'"'},class:function(expectation){var i,escapedParts="";for(i=0;i<expectation.parts.length;i++)escapedParts+=expectation.parts[i]instanceof Array?classEscape(expectation.parts[i][0])+"-"+classEscape(expectation.parts[i][1]):classEscape(expectation.parts[i]);return"["+(expectation.inverted?"^":"")+escapedParts+"]"},any:function(expectation){return"any character"},end:function(expectation){return"end of input"},other:function(expectation){return expectation.description}};return"Expected "+function(expected){var i,j,descriptions=new Array(expected.length);for(i=0;i<expected.length;i++)descriptions[i]=describeExpectation(expected[i]);if(descriptions.sort(),descriptions.length>0){for(i=1,j=1;i<descriptions.length;i++)descriptions[i-1]!==descriptions[i]&&(descriptions[j]=descriptions[i],j++);descriptions.length=j}switch(descriptions.length){case 1:return descriptions[0];case 2:return descriptions[0]+" or "+descriptions[1];default:return descriptions.slice(0,-1).join(", ")+", or "+descriptions[descriptions.length-1]}}(expected)+" but "+function(found){return found?'"'+literalEscape(found)+'"':"end of input"}(found)+" found."},module.exports={SyntaxError:peg$SyntaxError,parse:peg$parse}},{}],2:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(obj){return typeof obj}:function(obj){return obj&&"function"==typeof Symbol&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj},rand_select=function(options){var probability_property=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"probability";if(!Array.isArray(options))throw new TypeError("options must be a non-empty array of objects");if("object"!==_typeof(options[0]))throw new TypeError("options must be a non-empty array of objects");for(var rnd=function(cap){return Math.random()*cap}(options.reduce(function(acc,val){return acc+val[probability_property]},0)),cursor=0,cursor_sum=0;(cursor_sum+=options[cursor++][probability_property])<=rnd;);return options[cursor-1]},seq=function(n){return new Array(n).fill(!0).map(function(_,i){return i})},histograph=function(a){return a.sort().reduce(function(m,v){return m.set(v,m.has(v)?m.get(v)+1:1),m},new Map)},sample_select=function(n,options,probability_property){return seq(n).map(function(i){return rand_select(options,probability_property)})},histo_key=function(n,options,probability_property,extract){return histograph(sample_select(n,options,probability_property).map(function(s){return s[extract]}))};exports.seq=seq,exports.histograph=histograph,exports.histo_key=histo_key,exports.rand_select=rand_select,exports.sample_select=sample_select},{}],3:[function(require,module,exports){"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var viz=function(jssm){var l_states=jssm.states(),node_of=function(state){return"n"+l_states.indexOf(state)},vc=function(col){return jssm._viz_colors[col]||""},strike=[];return'digraph G {\n fontname="helvetica neue";\n style=filled;\n bgcolor=lightgrey;\n node [fontsize=14; shape=box; style=filled; fillcolor=white; fontname="helvetica neue"];\n edge [fontsize=6;fontname="helvetica neue"];\n\n '+l_states.map(function(s){jssm.state_for(s);var terminal=jssm.state_is_terminal(s),final=jssm.state_is_final(s),complete=jssm.state_is_complete(s),features=[["label",s],["peripheries",complete?2:1],["fillcolor",final?vc("fill_final"):complete?vc("fill_complete"):terminal?vc("fill_terminal"):""]].filter(function(r){return r[1]}).map(function(r){return r[0]+'="'+r[1]+'"'}).join(" ");return node_of(s)+" ["+features+"];"}).join(" ")+"\n\n "+jssm.states().map(function(s){return jssm.list_exits(s).map(function(ex){if(strike.find(function(row){return row[0]===s&&row[1]==ex}))return"";var edge=jssm.list_transitions(s,ex),pair=jssm.list_transitions(ex,s),double=pair&&s!==ex,if_obj_field=(jssm.state_for(s),jssm.state_for(ex),function(obj,field){return obj?obj[field]||"":""}),h_final=jssm.state_is_final(s),h_complete=jssm.state_is_complete(s),h_terminal=jssm.state_is_terminal(s),t_final=jssm.state_is_final(ex),t_complete=jssm.state_is_complete(ex),t_terminal=jssm.state_is_terminal(ex),lineColor=function(final,complete,terminal){var _solo_1_2=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"_solo";return vc(final?"line_final"+_solo_1_2:complete?"line_complete"+_solo_1_2:terminal?"line_terminal"+_solo_1_2:"normal_line"+_solo_1_2)},textColor=function(final,complete,terminal){var _solo_1_2=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"_solo";return final?vc("text_final"+_solo_1_2):complete?vc("text_complete"+_solo_1_2):terminal?vc("text_terminal"+_solo_1_2):""},labelInline=[[pair,"probability","headlabel","name","action",double,textColor(h_final,h_complete,h_terminal,double?"_1":"_solo")],[edge,"probability","taillabel","name","action",!0,textColor(t_final,t_complete,t_terminal,double?"_2":"_solo")]].map(function(r){return{which:r[2],whether:r[5]?[if_obj_field(r[0],r[5]),if_obj_field(r[0],r[1]),if_obj_field(r[0],r[3])].filter(function(q){return q}).join("<br/>")||"":"",color:r[6]}}).filter(function(present){return present.whether}).map(function(r){return r.which+"="+(r.color?'<<font color="'+r.color+'">'+r.whether+"</font>>":'"'+r.whether+'"')+";"}).join(" "),tc1=lineColor(t_final,t_complete,t_terminal,"_1"),tc2=lineColor(h_final,h_complete,h_terminal,"_2"),tcd=lineColor(t_final,t_complete,t_terminal,"_solo"),edgeInline=edge?double?'dir=both;color="'+tc1+":"+tc2+'"':'color="'+tcd+'"':"";return pair&&strike.push([ex,s]),node_of(s)+"->"+node_of(ex)+" ["+labelInline+edgeInline+"];"}).join(" ")}).join(" ")+"\n}"};exports.viz=viz},{}],jssm:[function(require,module,exports){"use strict";function _toConsumableArray(arr){if(Array.isArray(arr)){for(var i=0,arr2=Array(arr.length);i<arr.length;i++)arr2[i]=arr[i];return arr2}return Array.from(arr)}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(exports,"__esModule",{value:!0}),exports.histograph=exports.rand_select=exports.seq=exports.parse=exports.machine=exports.version=void 0;var _createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||!1,descriptor.configurable=!0,"value"in descriptor&&(descriptor.writable=!0),Object.defineProperty(target,descriptor.key,descriptor)}}return function(Constructor,protoProps,staticProps){return protoProps&&defineProperties(Constructor.prototype,protoProps),staticProps&&defineProperties(Constructor,staticProps),Constructor}}(),_jssmUtil=require("./jssm-util.js"),_jssmViz=require("./jssm-viz.js"),parse=require("./jssm-dot.js").parse,machine=function(){function machine(_ref){var _this=this,initial_state=_ref.initial_state,_ref$complete=_ref.complete,complete=void 0===_ref$complete?[]:_ref$complete,transitions=_ref.transitions;_classCallCheck(this,machine),this.set_viz_colors(),this._state=initial_state,this._states=new Map,this._edges=[],this._edge_map=new Map,this._named_transitions=new Map,this._actions=new Map,this._reverse_actions=new Map,this._reverse_action_targets=new Map,transitions.map(function(tr){if(void 0===tr.from)throw new Error("transition must define 'from': "+JSON.stringify(tr));if(void 0===tr.to)throw new Error("transition must define 'to': "+JSON.stringify(tr));var cursor_from=_this._states.get(tr.from);void 0===cursor_from&&(_this._new_state({name:tr.from,from:[],to:[],complete:complete.includes(tr.from)}),cursor_from=_this._states.get(tr.from));var cursor_to=_this._states.get(tr.to);if(void 0===cursor_to&&(_this._new_state({name:tr.to,from:[],to:[],complete:complete.includes(tr.to)}),cursor_to=_this._states.get(tr.to)),cursor_from.to.includes(tr.to))throw new Error("already has "+tr.from+" to "+tr.to);if(cursor_from.to.push(tr.to),cursor_to.from.includes(tr.from))throw new Error("already has "+tr.to+" from "+tr.from);cursor_to.from.push(tr.from),_this._edges.push(tr);var thisEdgeId=_this._edges.length-1;if(tr.name){if(_this._named_transitions.has(tr.name))throw new Error('named transition "'+tr.name+'" already created');_this._named_transitions.set(tr.name,thisEdgeId)}var from_mapping=_this._edge_map.get(tr.from);if(void 0===from_mapping&&(_this._edge_map.set(tr.from,new Map),from_mapping=_this._edge_map.get(tr.from)),from_mapping.get(tr.to))throw new Error("from -> to already exists "+tr.from+" "+tr.to);if(from_mapping.set(tr.to,thisEdgeId),tr.action){_this._actions.has(tr.action)||_this._actions.set(tr.action,new Map);var actionMap=_this._actions.get(tr.action);if(!actionMap)throw new Error("should be impossible, satisfying type checker that doesn't know .set precedes .get. severe error?");if(actionMap.has(tr.from))throw new Error("action "+tr.action+" already attached to origin "+tr.from);actionMap.set(tr.from,thisEdgeId),_this._reverse_actions.has(tr.from)||_this._reverse_actions.set(tr.from,new Map);var rActionMap=_this._reverse_actions.get(tr.from);if(!rActionMap)throw new Error("should be impossible, satisfying type checker that doesn't know .set precedes .get again. severe error?");if(rActionMap.has(tr.action))throw new Error("r-action "+tr.from+" already attached to action "+tr.action);rActionMap.set(tr.action,thisEdgeId),_this._reverse_action_targets.has(tr.to)||_this._reverse_action_targets.set(tr.to,new Map)}})}return _createClass(machine,[{key:"_new_state",value:function(state_config){if(this._states.has(state_config.name))throw new Error("state "+state_config.name+" already exists");return this._states.set(state_config.name,state_config),state_config.name}},{key:"state",value:function(){return this._state}},{key:"is_changing",value:function(){return!0}},{key:"state_is_final",value:function(whichState){return this.state_is_terminal(whichState)&&this.state_is_complete(whichState)}},{key:"is_final",value:function(){return!this.is_changing()&&this.state_is_final(this.state())}},{key:"machine_state",value:function(){return{internal_state_impl_version:1,actions:this._actions,edge_map:this._edge_map,edges:this._edges,named_transitions:this._named_transitions,reverse_actions:this._reverse_actions,state:this._state,states:this._states}}},{key:"load_machine_state",value:function(){return!1}},{key:"states",value:function(){return[].concat(_toConsumableArray(this._states.keys()))}},{key:"state_for",value:function(whichState){var state=this._states.get(whichState);if(state)return state;throw new Error("no such state "+JSON.stringify(state))}},{key:"list_transitions",value:function(){return this._edges}},{key:"list_named_transitions",value:function(){return this._named_transitions}},{key:"list_actions",value:function(){return[].concat(_toConsumableArray(this._actions.keys()))}},{key:"get_transition_by_id",value:function(from,to){return this._edge_map.has(from)?this._edge_map.get(from).get(to):void 0}},{key:"lookup_transition_for",value:function(from,to){var id=this.get_transition_by_id(from,to);return void 0===id?void 0:this._edges[id]}},{key:"list_transitions",value:function(){var whichState=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.state();return{entrances:this.list_entrances(whichState),exits:this.list_exits(whichState)}}},{key:"list_entrances",value:function(){var whichState=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.state();return(this._states.get(whichState)||{}).from}},{key:"list_exits",value:function(){var whichState=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.state();return(this._states.get(whichState)||{}).to}},{key:"probable_exits_for",value:function(whichState){var _this2=this;return(this._states.get(whichState)||{to:[]}).to.map(function(ws){return _this2.lookup_transition_for(_this2.state(),ws)}).filter(function(defined){return defined})||[]}},{key:"probabilistic_transition",value:function(){var selected=(0,_jssmUtil.rand_select)(this.probable_exits_for(this.state()));return this.transition(selected.to)}},{key:"probabilistic_walk",value:function(n){var _this3=this;return(0,_jssmUtil.seq)(n-1).map(function(i){var state_was=_this3.state();return _this3.probabilistic_transition(),state_was}).concat([this.state()])}},{key:"probabilistic_histo_walk",value:function(n){return(0,_jssmUtil.histograph)(this.probabilistic_walk(n))}},{key:"actions",value:function(){var whichState=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.state(),wstate=this._reverse_actions.get(whichState);if(wstate)return[].concat(_toConsumableArray(wstate.keys()));throw new Error("No such state "+JSON.stringify(whichState))}},{key:"list_states_having_action",value:function(whichState){var wstate=this._actions.get(whichState);if(wstate)return[].concat(_toConsumableArray(wstate.keys()));throw new Error("No such state "+JSON.stringify(whichState))}},{key:"list_exit_actions",value:function(){var _this4=this,whichState=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.state();return[].concat(_toConsumableArray((this._reverse_actions.get(whichState)||new Map).values())).map(function(edgeId){return _this4._edges[edgeId]}).filter(function(o){return o.from===whichState}).map(function(filtered){return filtered.action})}},{key:"probable_action_exits",value:function(){var _this5=this,whichState=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.state();return[].concat(_toConsumableArray((this._reverse_actions.get(whichState)||new Map).values())).map(function(edgeId){return _this5._edges[edgeId]}).filter(function(o){return o.from===whichState}).map(function(filtered){return{action:filtered.action,probability:filtered.probability}})}},{key:"is_unenterable",value:function(whichState){return 0===this.list_entrances(whichState).length}},{key:"has_unenterables",value:function(){return this.states.some(this.is_unenterable)}},{key:"is_terminal",value:function(){return this.state_is_terminal(this.state())}},{key:"state_is_terminal",value:function(whichState){return 0===this.list_exits(whichState).length}},{key:"has_terminals",value:function(){return this.states.some(this.state_is_terminal)}},{key:"is_complete",value:function(){return this.state_is_complete(this.state())}},{key:"state_is_complete",value:function(whichState){var wstate=this._states.get(whichState);if(wstate)return wstate.complete;throw new Error("No such state "+JSON.stringify(whichState))}},{key:"has_completes",value:function(){return this.states.some(this.state_is_complete)}},{key:"action",value:function(name,newData){if(this.valid_action(name,newData)){var edge=this.current_action_edge_for(name);if(!edge)throw new Error("Should be impossible - valid_action true, no edge in current_action_edge_for, in action("+JSON.stringify(name)+"...)");return this._state=edge.to,!0}return!1}},{key:"transition",value:function(newState,newData){return!!this.valid_transition(newState,newData)&&(this._state=newState,!0)}},{key:"force_transition",value:function(newState,newData){return!!this.valid_force_transition(newState,newData)&&(this._state=newState,!0)}},{key:"current_action_for",value:function(action){var action_base=this._actions.get(action);return action_base?action_base.get(this.state()):void 0}},{key:"current_action_edge_for",value:function(action){var idx=this.current_action_for(action);return void 0!==idx?this._edges[idx]:void 0}},{key:"valid_action",value:function(action,newData){return void 0!==this.current_action_for(action)}},{key:"valid_transition",value:function(newState,newData){return void 0!==this.lookup_transition_for(this.state(),newState)}},{key:"valid_force_transition",value:function(newState,newData){return!1}},{key:"viz",value:function(){return(0,_jssmViz.viz)(this)}},{key:"set_viz_colors",value:function(){this._viz_colors={fill_final:"#eeeeff",fill_terminal:"#ffeeee",fill_complete:"#eeffee",normal_line_1:"#999999",normal_line_2:"#888888",normal_line_solo:"#888888",line_final_1:"#8888bb",line_final_2:"#7777aa",line_final_solo:"#7777aa",line_terminal_1:"#bb8888",line_terminal_2:"#aa7777",line_terminal_solo:"#aa7777",line_complete_1:"#88bb88",line_complete_2:"#77aa77",line_complete_solo:"#77aa77",text_final_1:"#000088",text_final_2:"#000088",text_final_solo:"#000088",text_terminal_1:"#880000",text_terminal_2:"#880000",text_terminal_solo:"#880000",text_complete_1:"#007700",text_complete_2:"#007700",text_complete_solo:"#007700"}}}]),machine}();exports.version="2.3.0",exports.machine=machine,exports.parse=parse,exports.seq=_jssmUtil.seq,exports.rand_select=_jssmUtil.rand_select,exports.histograph=_jssmUtil.histograph},{"./jssm-dot.js":1,"./jssm-util.js":2,"./jssm-viz.js":3}]},{},[]);
{
"name": "jssm",
"version": "2.2.0",
"version": "2.3.0",
"engines": {

@@ -10,5 +10,5 @@ "node": ">=6.0.0"

"scripts": {
"nyc-test": "nyc ava src/js/jssm*-tests.js",
"test": "ava src/js/jssm*-tests.js",
"test-verbose": "ava src/js/jssm*-tests.js -v",
"nyc-test": "nyc ava src/js/tests/*.js",
"test": "ava src/js/tests/*.js",
"test-verbose": "ava src/js/tests/*.js -v",
"removedir": "rimraf build -f && rimraf dist -f && rimraf docs -f",

@@ -15,0 +15,0 @@ "createdir": "mkdir build && mkdir dist && mkdir docs && cd docs && mkdir docs && cd ..",

@@ -497,2 +497,3 @@

machine,
parse,

@@ -499,0 +500,0 @@ seq, rand_select, histograph

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc