/
state.js
1 lines (1 loc) · 20.7 KB
/
state.js
1
var state=function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(r,o,function(e){return t[e]}.bind(null,o));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=0)}([function(t,e,n){"use strict";e.__esModule=!0;var r=n(3);e.log=r.log;var o=n(1);e.random=o.random;var i=n(4);e.PseudoStateKind=i.PseudoStateKind;var a=n(2);e.TransitionKind=a.TransitionKind;var s=n(5);e.NamedElement=s.NamedElement;var u=n(6);e.Vertex=u.Vertex;var c=n(7);e.Region=c.Region;var l=n(8);e.State=l.State;var f=n(9);e.PseudoState=f.PseudoState;var h=n(10);e.Transition=h.Transition;var p=n(14);e.Instance=p.Instance;var d=n(16);e.Visitor=d.Visitor;var v=n(17);e.JSONSerializer=v.JSONSerializer},function(t,e,n){"use strict";e.__esModule=!0,function(t){var e=function(t){return Math.floor(Math.random()*t)};t.get=function(t){return t[e(t.length)]},t.set=function(t){var n=e;return e=t,n}}(e.random||(e.random={}))},function(t,e,n){"use strict";e.__esModule=!0,function(t){t[t.External=0]="External",t[t.Internal=1]="Internal",t[t.Local=2]="Local"}(e.TransitionKind||(e.TransitionKind={}))},function(t,e,n){"use strict";var r=this&&this.__values||function(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};e.__esModule=!0,function(t){var e=[];t.Create=1,t.Entry=2,t.Exit=4,t.Evaluate=8,t.Transition=16,t.User=128,t.add=function(t){for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];return e.push({consumer:t,category:n.reduce((function(t,e){return t|e}))})},t.remove=function(t){delete e[t]},t.write=function(t,n){var o,i,a;try{for(var s=r(e),u=s.next();!u.done;u=s.next()){var c=u.value;c&&n&c.category&&c.consumer(a||(a=t()))}}catch(t){o={error:t}}finally{try{u&&!u.done&&(i=s.return)&&i.call(s)}finally{if(o)throw o.error}}}}(e.log||(e.log={}))},function(t,e,n){"use strict";e.__esModule=!0,function(t){t[t.Choice=0]="Choice",t[t.DeepHistory=1]="DeepHistory",t[t.Initial=2]="Initial",t[t.Junction=3]="Junction",t[t.ShallowHistory=4]="ShallowHistory"}(e.PseudoStateKind||(e.PseudoStateKind={}))},function(t,e,n){"use strict";var r=this&&this.__generator||function(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=e.call(t,a)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}},o=this&&this.__values||function(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};e.__esModule=!0;var i=n(0),a=function(){function t(t,e){var n=this;this.name=t,this.qualifiedName=e?e+"."+t:t,i.log.write((function(){return"Created "+n}),i.log.Create)}return t.prototype.getAncestors=function(){var t;return r(this,(function(e){switch(e.label){case 0:return(t=this.getParent())?[5,o(t.getAncestors())]:[3,2];case 1:e.sent(),e.label=2;case 2:return[4,this];case 3:return e.sent(),[2]}}))},t.prototype.doEnter=function(t,e,n){this.doEnterHead(t,e,n,void 0),this.doEnterTail(t,e,n)},t.prototype.doEnterHead=function(t,e,n,r){var o=this;i.log.write((function(){return t.instance+" enter "+o}),i.log.Entry)},t.prototype.doExit=function(t,e,n){var r=this;i.log.write((function(){return t.instance+" leave "+r}),i.log.Exit)},t.prototype.toString=function(){return this.qualifiedName},t}();e.NamedElement=a},function(t,e,n){"use strict";var r,o=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});e.__esModule=!0;var i=n(0),a=function(t){function e(e,n){var r=t.call(this,e,n)||this;return r.parent=n,r.outgoing=[],r.parent&&r.parent.children.push(r),r}return o(e,t),e.prototype.getParent=function(){return this.parent},e.prototype.on=function(t){return new i.Transition(this).on(t)},e.prototype.when=function(t){return new i.Transition(this).when(t)},e.prototype.to=function(t,e){if(void 0===e&&(e=i.TransitionKind.External),e===i.TransitionKind.Internal&&t!==this)throw new Error("Internal transitions must have the same source and target states.");return new i.Transition(this).to(t,e)},e.prototype.isActive=function(t){return void 0===this.parent||t.getVertex(this.parent)===this},e.prototype.evaluate=function(t,e,n){var r=this.getTransition(n);return!!r&&(r.traverse(t,e,n),!0)},e.prototype.getTransition=function(t){return this.outgoing.find((function(e){return e.evaluate(t)}))},e.prototype.doEnterHead=function(e,n,r,o){t.prototype.doEnterHead.call(this,e,n,r,o),e.setVertex(this)},e}(i.NamedElement);e.Vertex=a},function(t,e,n){"use strict";var r,o=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),i=this&&this.__values||function(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};e.__esModule=!0;var a=n(0),s=function(t){function e(e,n){var r=t.call(this,e,n)||this;return r.parent=n,r.children=[],n.children.push(r),r}return o(e,t),e.prototype.getParent=function(){return this.parent},e.prototype.isComplete=function(t){var e=t.getState(this);return e&&e.isFinal()},e.prototype.doEnterTail=function(t,e,n){var r=t.getState(this),o=(e||this.initial&&this.initial.isHistory)&&r?r:this.initial,i=e||void 0!==this.initial&&this.initial.kind===a.PseudoStateKind.DeepHistory;o.doEnter(t,i,n)},e.prototype.doExit=function(e,n,r){e.getVertex(this).doExit(e,n,r),t.prototype.doExit.call(this,e,n,r)},e.prototype.accept=function(t){var e,n;t.visitRegion(this);try{for(var r=i(this.children),o=r.next();!o.done;o=r.next()){o.value.accept(t)}}catch(t){e={error:t}}finally{try{o&&!o.done&&(n=r.return)&&n.call(r)}finally{if(e)throw e.error}}t.visitRegionTail(this)},e}(a.NamedElement);e.Region=s},function(t,e,n){"use strict";var r,o=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),i=this&&this.__read||function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return a},a=this&&this.__spread||function(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(i(arguments[e]));return t},s=this&&this.__values||function(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};e.__esModule=!0;var u=n(0),c=function(t){function e(n,r){void 0===r&&(r=void 0);var o=t.call(this,n,r instanceof e?r.getDefaultRegion():r)||this;return o.children=[],o.deferrableTriggers=[],o.entryActions=[],o.exitActions=[],o}return o(e,t),e.prototype.entry=function(){for(var t,e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return(t=this.entryActions).push.apply(t,a(e)),this},e.prototype.exit=function(){for(var t,e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return(t=this.exitActions).push.apply(t,a(e)),this},e.prototype.defer=function(){for(var t,e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return(t=this.deferrableTriggers).push.apply(t,a(e)),this},e.prototype.getDefaultRegion=function(){return this.defaultRegion||(this.defaultRegion=new u.Region("default",this))},e.prototype.isSimple=function(){return 0===this.children.length},e.prototype.isComposite=function(){return this.children.length>0},e.prototype.isOrthogonal=function(){return this.children.length>1},e.prototype.isFinal=function(){return 0===this.outgoing.length},e.prototype.isComplete=function(t){return!this.children.some((function(e){return!e.isComplete(t)}))},e.prototype.evaluate=function(e,n,r){var o=this.delegate(e,n,r)||t.prototype.evaluate.call(this,e,n,r)||this.deferrable(e,r);return o&&this.completion(e,n),o},e.prototype.delegate=function(t,e,n){for(var r=!1,o=0,i=this.children.length;o<i&&this.isActive(t);++o)r=t.getState(this.children[o]).evaluate(t,e,n)||r;return r},e.prototype.deferrable=function(t,e){return-1!==this.deferrableTriggers.indexOf(e.constructor)&&(t.instance.defer(e),!0)},e.prototype.getDeferrableTriggers=function(t){return this.children.reduce((function(e,n){return e.concat(t.getState(n).getDeferrableTriggers(t))}),this.deferrableTriggers)},e.prototype.doEnterHead=function(e,n,r,o){o&&this.children.forEach((function(t){t!==o&&t.doEnter(e,n,r)})),t.prototype.doEnterHead.call(this,e,n,r,o),e.setState(this),this.entryActions.forEach((function(t){return t(r,e.instance)}))},e.prototype.doEnterTail=function(t,e,n){this.children.forEach((function(r){return r.doEnter(t,e,n)})),this.completion(t,e)},e.prototype.doExit=function(e,n,r){this.children.forEach((function(t){return t.doExit(e,n,r)})),t.prototype.doExit.call(this,e,n,r),this.exitActions.forEach((function(t){return t(r,e.instance)}))},e.prototype.completion=function(e,n){this.isComplete(e)&&t.prototype.evaluate.call(this,e,n,this)},e.prototype.accept=function(t){var e,n;t.visitState(this);try{for(var r=s(this.children),o=r.next();!o.done;o=r.next()){o.value.accept(t)}}catch(t){e={error:t}}finally{try{o&&!o.done&&(n=r.return)&&n.call(r)}finally{if(e)throw e.error}}t.visitStateTail(this)},e}(u.Vertex);e.State=c},function(t,e,n){"use strict";var r,o=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});e.__esModule=!0;var i=n(1),a=n(0),s=n(2),u=function(t){function e(e,n,r){void 0===r&&(r=a.PseudoStateKind.Initial);var o=t.call(this,e,n instanceof a.State?n.getDefaultRegion():n)||this;return o.kind=r,o.isHistory=o.kind===a.PseudoStateKind.DeepHistory||o.kind===a.PseudoStateKind.ShallowHistory,(o.kind===a.PseudoStateKind.Initial||o.isHistory)&&(o.parent.initial=o),o}return o(e,t),e.prototype.else=function(t,e){return void 0===e&&(e=s.TransitionKind.External),this.elseTransition=new a.Transition(this).to(t,e).when((function(){return!1}))},e.prototype.getTransition=function(e){return(this.kind===a.PseudoStateKind.Choice?i.random.get(this.outgoing.filter((function(t){return t.evaluate(e)}))):t.prototype.getTransition.call(this,e))||this.elseTransition},e.prototype.doEnterTail=function(t,e,n){this.kind!==a.PseudoStateKind.Junction&&this.evaluate(t,e,n)},e.prototype.accept=function(t){t.visitPseudoState(this),t.visitPseudoStateTail(this)},e}(a.Vertex);e.PseudoState=u},function(t,e,n){"use strict";var r=this&&this.__read||function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return a},o=this&&this.__spread||function(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(r(arguments[e]));return t};e.__esModule=!0;var i=n(0),a=n(11),s=n(12),u=n(13),c=[];c[i.TransitionKind.External]=a.ExternalTransitionStrategy,c[i.TransitionKind.Internal]=s.InternalTransitionStrategy,c[i.TransitionKind.Local]=u.LocalTransitionStrategy;var l=function(){function t(t){this.source=t,this.guard=function(){return!0},this.traverseActions=[],this.target=t,this.strategy=new c[i.TransitionKind.Internal](this.source,this.target),this.source.outgoing.push(this)}return t.prototype.on=function(t){return this.eventType=t,this},t.prototype.when=function(t){return this.guard=t,this},t.prototype.to=function(t,e){return void 0===e&&(e=i.TransitionKind.External),this.target=t,this.strategy=new c[e](this.source,this.target),this},t.prototype.effect=function(){for(var t,e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return(t=this.traverseActions).push.apply(t,o(e)),this},t.prototype.evaluate=function(t){return(void 0===this.eventType||t.constructor===this.eventType)&&this.guard(t)},t.prototype.traverse=function(t,e,n){for(var r=this,o=[r];r.target instanceof i.PseudoState&&r.target.kind===i.PseudoStateKind.Junction;)o.push(r=r.target.getTransition(n));o.forEach((function(r){return r.execute(t,e,n)}))},t.prototype.execute=function(t,e,n){var r=this;i.log.write((function(){return t.instance+" traverse "+r}),i.log.Transition),this.strategy.doExitSource(t,e,n),this.traverseActions.forEach((function(e){return e(n,t.instance)})),this.strategy.doEnterTarget(t,e,n)},t.prototype.toString=function(){return this.strategy+" transition from "+this.source+" to "+this.target},t}();e.Transition=l},function(t,e,n){"use strict";e.__esModule=!0;var r=n(0),o=function(){function t(t,e){for(var n=t.getAncestors(),o=e.getAncestors(),i=n.next(),a=o.next(),s=n.next(),u=o.next();i.value===a.value&&!s.done&&!u.done;)i=s,a=u,s=n.next(),u=o.next();for(this.toExit=i.value,this.toEnter=[a.value];!u.done;)this.toEnter.push(u.value),u=o.next();e instanceof r.PseudoState&&e.isHistory&&this.toEnter.pop()}return t.prototype.doExitSource=function(t,e,n){this.toExit.doExit(t,e,n)},t.prototype.doEnterTarget=function(t,e,n){var r=this;this.toEnter.forEach((function(o,i){return o.doEnterHead(t,e,n,r.toEnter[i+1])})),this.toEnter[this.toEnter.length-1].doEnterTail(t,e,n)},t.prototype.toString=function(){return"external"},t}();e.ExternalTransitionStrategy=o},function(t,e,n){"use strict";e.__esModule=!0;var r=n(0),o=function(){function t(t,e){this.target=e}return t.prototype.doEnterTarget=function(t,e,n){this.target instanceof r.State&&this.target.completion(t,e)},t.prototype.doExitSource=function(t,e,n){},t.prototype.toString=function(){return"internal"},t}();e.InternalTransitionStrategy=o},function(t,e,n){"use strict";e.__esModule=!0;var r=function(){function t(t,e){this.source=t,this.target=e}return t.prototype.doExitSource=function(t,e,n){for(this.vertexToEnter=this.target;this.vertexToEnter.parent&&this.vertexToEnter.parent.parent&&!this.vertexToEnter.parent.parent.isActive(t);)this.vertexToEnter=this.vertexToEnter.parent.parent;!this.vertexToEnter.isActive(t)&&this.vertexToEnter.parent&&t.getVertex(this.vertexToEnter.parent).doExit(t,e,n)},t.prototype.doEnterTarget=function(t,e,n){this.vertexToEnter&&!this.vertexToEnter.isActive(t)&&this.vertexToEnter.doEnter(t,e,n)},t.prototype.toString=function(){return"local"},t}();e.LocalTransitionStrategy=r},function(t,e,n){"use strict";e.__esModule=!0;var r=n(0),o=n(15),i=function(){function t(t,e){var n=this;this.name=t,this.root=e,this.activeStateConfiguration={},this.deferredEventPool=[],this.transactional((function(t){n.root.doEnter(t,!1,n.root),0!==n.deferredEventPool.length&&(n.evaluateDeferred(t),n.deferredEventPool=n.deferredEventPool.filter((function(t){return t})))}))}return t.prototype.evaluate=function(t){var e=this;return r.log.write((function(){return e+" evaluate "+t}),r.log.Evaluate),this.transaction?(this.defer(t),!1):this.transactional((function(n){var r=e.root.evaluate(n,!1,t);return r&&0!==e.deferredEventPool.length&&(e.evaluateDeferred(n),e.deferredEventPool=e.deferredEventPool.filter((function(t){return t}))),r}))},t.prototype.transactional=function(t){try{this.transaction=new o.Transaction(this);var e=t(this.transaction);return Object.assign(this.activeStateConfiguration,this.transaction.activeStateConfiguration),e}finally{this.transaction=void 0}},t.prototype.defer=function(t){var e=this;r.log.write((function(){return e+" deferring "+t}),r.log.Evaluate),this.deferredEventPool.push(t)},t.prototype.evaluateDeferred=function(t){var e=this;this.deferredEventPool.forEach((function(n,o){n&&-1===e.root.getDeferrableTriggers(t).indexOf(n.constructor)&&(delete e.deferredEventPool[o],r.log.write((function(){return e+" evaluate deferred "+n}),r.log.Evaluate),e.root.evaluate(t,!1,n))&&e.evaluateDeferred(t)}))},t.prototype.getState=function(t){return this.activeStateConfiguration[t.qualifiedName]},t.prototype.toString=function(){return this.name},t}();e.Instance=i},function(t,e,n){"use strict";e.__esModule=!0;var r=function(){function t(t){this.instance=t,this.activeStateConfiguration={},this.lastKnownVertex={}}return t.prototype.setState=function(t){t.parent&&(this.activeStateConfiguration[t.parent.qualifiedName]=t)},t.prototype.getState=function(t){return this.activeStateConfiguration[t.qualifiedName]||this.instance.getState(t)},t.prototype.setVertex=function(t){t.parent&&(this.lastKnownVertex[t.parent.qualifiedName]=t)},t.prototype.getVertex=function(t){return this.lastKnownVertex[t.qualifiedName]||this.instance.getState(t)},t}();e.Transaction=r},function(t,e,n){"use strict";e.__esModule=!0;var r=function(){function t(){}return t.prototype.visitState=function(t){},t.prototype.visitStateTail=function(t){},t.prototype.visitPseudoState=function(t){},t.prototype.visitPseudoStateTail=function(t){},t.prototype.visitRegion=function(t){},t.prototype.visitRegionTail=function(t){},t}();e.Visitor=r},function(t,e,n){"use strict";var r,o=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});e.__esModule=!0;var i=n(0),a=function(t){this.name=t.name},s=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.children=[],e}return o(e,t),e}(a),u=function(t){function e(e,n){var r=t.call(this,e)||this;return r.activeState=n,r.children=[],r}return o(e,t),e}(a),c=function(t){function e(e,n){void 0===n&&(n=void 0);var r=t.call(this)||this;return r.instance=e,r.deferedEventSerializer=n,r.stateMap={},r.regionMap={},r}return o(e,t),e.prototype.visitState=function(t){var e=new s(t);this.stateMap[t.qualifiedName]=e,void 0!==t.parent?this.regionMap[t.parent.qualifiedName].children.push(e):this.root=e},e.prototype.visitRegion=function(t){var e=this.instance.getState(t),n=new u(t,e?e.name:void 0);this.regionMap[t.qualifiedName]=n,this.stateMap[t.parent.qualifiedName].children.push(n)},e.prototype.toString=function(){return 0!==this.instance.deferredEventPool.length&&this.deferedEventSerializer&&this.root&&(this.root.deferredEventPool=this.instance.deferredEventPool.map(this.deferedEventSerializer)),JSON.stringify(this.root)},e}(i.Visitor);e.JSONSerializer=c}]);