/*! For license information please see arcs.min.js.LICENSE.txt */
vart={d:(n,e)=>{for(varoine)t.o(e,o)&&!t.o(n,o)&&Object.defineProperty(n,o,{enumerable:!0,get:e[o]})},o:(t,n)=>Object.prototype.hasOwnProperty.call(t,n)},n={};t.d(n,{Z:()=>y});vare={SourceIsNotComponent:{message:"Source is not a component"},UndefinedSignal:{message:"Signal is not defined"},UndefinedSlot:{message:"Slot is not defined"},create:function(t,n,e){returnvoid0===t.prototype?(console.error("Cannot create such a component"),0):(t.prototype.slots=[],t.prototype.signals={},t.slotList=function(){returnt.prototype.slots},t.prototype.slotList=function(){returnt.prototype.slots},t.prototype.signalList=function(){varn,e=[];for(nint.prototype.signals)e.push(n);returne},t.signalList=function(){returnt.prototype.signalList()},t.prototype.emit=function(t){varn,e,o,i=Array.prototype.slice.call(arguments,1);for(ninthis.signals[t])e=this.signals[t][n].func,o=this.signals[t][n].obj,e.apply(o,i)},t.slot=function(n,e){varo;if(ninstanceofArray)for(o=0;o<n.length;o++)t.prototype.slots.push(n[o]);elset.prototype.slots.push(n),void0!==e&&(t.prototype[n]=e)},t.signal=function(n){vare;if(ninstanceofArray)for(e=0;e<n.length;e++)t.prototype.signals[n[e]]=1;elset.prototype.signals[n]=1},void0!==n&&t.slot(n),void0!==e&&t.signal(e),t)},check:function(t){returnvoid0!==t.prototype&&void0!==t.prototype.signals&&void0!==t.prototype.slots},connect:function(t,n,o,i){varr,s;if(void0===t.signals)throwe.SourceIsNotComponent;if(void0===t.signals[n])throwe.UndefinedSignal;if(void0===o[i])throwe.UndefinedSlot;if(!t.hasOwnProperty("signals"))for(sinr=t.signals,t.signals={},r)t.signals[s]=[];t.signals[n].push({obj:o,func:o[i]})},disconnect:function(t,n,e,o){vari;for(i=0;i<t.signals[n].length;i++)t.signals[n][i].obj===e&&t.signals[n][i].func===e[o]&&(t.signals[n].splice(i,1),i--)},invoke:function(t,n,o){if(void0===t[n])throwe.UndefinedSlot;t[n].apply(t,o)},config:function(t,n){"function"==typeoft.config&&t.config(n)}};consto=e,i=function(){vart,n;this.promise=newPromise((function(e,o){t=e,n=o})),this.accept=function(){t()},this.abort=function(){n()}};letr=function(){this.promise={},this.and=function(t){returnthis.promise=Promise.all([this.promise,t.promise]),this},this.or=function(t){returnthis.promise=Promise.race([this.promise,t.promise]),this}};r.build=function(t,n){vare,o,s,c;if("string"==typeoft){vara;n.hasOwnProperty(t)?a=n[t]:n[t]=a=newi;varu=newr;returnu.promise=a.promise,u}for(e=r.build(t[0],n),c=1;c<t.length;c++)t[c].hasOwnProperty("and")?(s=r.build(t[c].and,n),o=e.and(s)):t[c].hasOwnProperty("or")?(s=r.build(t[c].or,n),o=e.or(s)):console.warn("[ARCS] Illegal tree"),e=o;returne};consts=r,c=function(){functiont(t,n,e,o,i,r){this.message=t,this.expected=n,this.found=e,this.offset=o,this.line=i,this.column=r,this.name="SyntaxError"}returnfunction(t,n){functione(){this.constructor=t}e.prototype=n.prototype,t.prototype=newe}(t,Error),{SyntaxError:t,parse:function(n){vare,o=arguments.length>1?arguments[1]:{},i={},r={start:D},s=D,c=i,a=function(t,n){return[t].concat(n)},u=function(t){return{and:t}},f=function(t){return{or:t}},l=function(t){returnt},h="(",p={type:"literal",value:"(",description:'"("'},d=")",v={type:"literal",value:")",description:'")"'},g=function(t){return[t]},y={type:"other",description:"id"},m=function(t){returnt.trim()},C=/^[_a-zA-Z]/,w={type:"class",value:"[_a-zA-Z]",description:"[_a-zA-Z]"},S=/^[_a-zA-Z0-9]/,P={type:"class",value:"[_a-zA-Z0-9]",description:"[_a-zA-Z0-9]"},A="&",O={type:"literal",value:"&",description:'"&"'},x="|",b={type:"literal",value:"|",description:'"|"'},R=/^[\r\n\t]/,F={type:"class",value:"[ \\r\\n\\t]",description:"[ \\r\\n\\t]"},N=0,T=0,j={line:1,column:1,seenCR:!1},k=0,L=[],E=0;if("startRule"ino){if(!(o.startRuleinr))thrownewError("Can't start parsing from rule \""+o.startRule+'".');s=r[o.startRule]}function_(t){returnT!==t&&(T>t&&(T=0,j={line:1,column:1,seenCR:!1}),function(t,e,o){vari,r;for(i=e;i<o;i++)"\n"===(r=n.charAt(i))?(t.seenCR||t.line++,t.column=1,t.seenCR=!1):"\r"===r||"\u2028"===r||"\u2029"===r?(t.line++,t.column=1,t.seenCR=!0):(t.column++,t.seenCR=!1)}(j,T,t),T=t),j}functionU(t){N<k||(N>k&&(k=N,L=[]),L.push(t))}functionZ(e,o,i){varr=_(i),s=i<n.length?n.charAt(i):null;returnnull!==o&&function(t){varn=1;for(t.sort((function(t,n){returnt.description<n.description?-1:t.description>n.description?1:0}));n<t.length;)t[n-1]===t[n]?t.splice(n,1):n++}(o),newt(null!==e?e:function(t,n){vare,o=newArray(t.length);for(e=0;e<t.length;e++)o[e]=t[e].description;return"Expected "+(t.length>1?o.slice(0,-1).join(", ")+" or "+o[t.length-1]:o[0])+" but "+(n?'"'+function(t){functionn(t){returnt.charCodeAt(0).toString(16).toUpperCase()}returnt.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\x08/g,"\\b").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\f/g,"\\f").replace(/\r/g,"\\r").replace(/[\x00-\x07\x0B\x0E\x0F]/g,(function(t){return"\\x0"+n(t)})).replace(/[\x10-\x1F\x80-\xFF]/g,(function(t){return"\\x"+n(t)})).replace(/[\u0180-\u0FFF]/g,(function(t){return"\\u0"+n(t)})).replace(/[\u1080-\uFFFF]/g,(function(t){return"\\u"+n(t)}))}(n)+'"':"end of input")+" found."}(o,s),o,s,i,r.line,r.column)}functionD(){returnI()}functionI(){vart,n,e,o;if(t=N,(n=z())!==i){if(e=[],(o=q())!==i)for(;o!==i;)e.push(o),o=q();elsee=c;e!==i?t=n=a(n,e):(N=t,t=c)}elseN=t,t=c;returnt===i&&(t=z()),t}functionq(){vart,n;returnt=N,M()!==i&&(n=z())!==i?t=u(n):(N=t,t=c),t===i&&(t=N,B()!==i&&(n=z())!==i?t=f(n):(N=t,t=c)),t}functionz(){vart,e,o,r;returnt=N,(e=V())!==i&&(e=l(e)),(t=e)===i&&(t=N,40===n.charCodeAt(N)?(e=h,N++):(e=i,0===E&&U(p)),e!==i&&(o=I())!==i?(41===n.charCodeAt(N)?(r=d,N++):(r=i,0===E&&U(v)),r!==i?t=e=g(o):(N=t,t=c)):(N=t,t=c)),t}functionV(){vart,e,o;returnE++,t=N,e=N,(o=J())!==i&&(o=n.substring(e,N)),(e=o)!==i&&(e=m(e)),E--,(t=e)===i&&(e=i,0===E&&U(y)),t}functionJ(){vart,e,o,r,s;if(t=N,(e=G())!==i)if(C.test(n.charAt(N))?(o=n.charAt(N),N++):(o=i,0===E&&U(w)),o!==i){for(r=[],S.test(n.charAt(N))?(s=n.charAt(N),N++):(s=i,0===E&&U(P));s!==i;)r.push(s),S.test(n.charAt(N))?(s=n.charAt(N),N++):(s=i,0===E&&U(P));r!==i&&(s=G())!==i?t=e=[e,o,r,s]:(N=t,t=c)}elseN=t,t=c;elseN=t,t=c;returnt}functionM(){vart,e,o,r;returnt=N,(e=G())!==i?(38===n.charCodeAt(N)?(o=A,N++):(o=i,0===E&&U(O)),o!==i&&(r=G())!==i?t=e=[e,o,r]:(N=t,t=c)):(N=t,t=c),t}functionB(){vart,e,o,r;returnt=N,(e=G())!==i?(124===n.charCodeAt(N)?(o=x,N++):(o=i,0===E&&U(b)),o!==i&&(r=G())!==i?t=e=[e,o,r]:(N=t,t=c)):(N=t,t=c),t}functionG(){vart,e;for(t=[],R.test(n.charAt(N))?(e=n.charAt(N),N++):(e=i,0===E&&U(F));e!==i;)t.push(e),R.test(n.charAt(N))?(e=n.charAt(N),N++):(e=i,0===E&&U(F));returnt}if((e=s())!==i&&N===n.length)returne;throwe!==i&&N<n.length&&U({type:"end",description:"end of input"}),Z(null,L,k)}}}(),a=o.create((function(t){varn="",e="",o={},i="",r=this,a={},u={},f=function(t){varn;r.slots.indexOf(t)<0&&(r.slots.push(t),r[t]=(n=t,function(){r.setToken(n)}))},l=function(t){varn;if(o.hasOwnProperty(t))for(ninu={},o[t])o[t].hasOwnProperty(n)&&s.build(a[n],u).promise.then((function(){vare;for(einu)u.hasOwnProperty(e)&&u[e].abort();l(o[t][n])}));i=t,r.emit("requestSheet",i),i===e&&r.emit("requestTermination")};this.setInitialState=function(t){i=n=t},this.setFinalState=function(t){e=t},this.addTransition=function(t,n,e){vari,r=/([A-Za-z_]\w*)/g;try{vars;if("string"==typeof(s=c.parse(n)))f(s);elsefor(;null!==(i=r.exec(n));)f(i[0]);a[n]=s,void0===o[t]&&(o[t]={}),o[t][n]=e}catch(t){}},this.setToken=function(t){u.hasOwnProperty(t)&&u[t].accept()},this.setTransitions=function(t){varn,e;for(nint)if(t.hasOwnProperty(n))for(eint[n])t[n].hasOwnProperty(e)&&this.addTransition(n,e,t[n][e])},this.start=function(){l(n)},void0!==t&&(n=t.initial,e=t.final,this.setTransitions(t.transitions),i="")}),["setToken"],["requestSheet","requestTermination"]);letu=function(t){varn={},e={},o={},i=[],r=this;if(o.StateMachine=a,void0!==t){vars;for(sini=t.libraries,t.components)t.components.hasOwnProperty(s)&&(n[s]=t.components[s]);if(void0!==t.constants)for(sint.constants)t.constants.hasOwnProperty(s)&&(e[s]=t.constants[s])}varc=asyncfunction(t){returny()?newPromise((function(n,e){varo=require(t);void0!==o?n(o):e("[ARCS] File not found")})):(awaitfetch(t)).json()},f=function(){vart,r=[];for(tinn)if(n.hasOwnProperty(t)){if(void0===o[n[t].type])returnconsole.error("[ARCS] Factory "+n[t].type+" not found."),voidconsole.error("[ARCS] Context dump follows: ",i,n,e);vars=o[n[t].type];try{void0!==n[t].value||void0!==n[t].url||void0!==n[t].ref?(void0!==n[t].value&&(n[t].instance=news(n[t].value)),void0!==n[t].url&&(console.log("loading data file",n[t].url),r.push(c(n[t].url).then(function(t,e){returnfunction(o){returnconsole.log("instanciating from data file"),n[t].instance=newe(o),Promise.resolve()}}(t,s)))),void0!==n[t].ref&&void0!==e[n[t].ref]&&(n[t].instance=news(e[n[t].ref]))):n[t].instance=news}catch(n){console.error("[ARCS] Component of type ",t," not instanciated.",n)}}returnPromise.all(r)};this.loadLibrary=function(t,n){vare=t,o=t;returnu.currentContext=r,"string"!=typeoft&&(o=t.name,e=t.url),i.indexOf(o)<0&&i.push(o),import(e).then((function(t){for(sint.default)t.default.hasOwnProperty(s)&&u.currentContext.setFactory(s,t.default[s]);void0!==n&&n()})).catch((function(t){console.error("[ARCS] Trouble loading '",e,"' with reason -",{msg:t})}))},this.getComponentList=function(){vart,e=Object.keys(n);for(t=0;t<e.length;t++)n.hasOwnProperty(e[t])||e.splice(t--,1);returne},this.getConstant=function(t){returne[t]},this.getComponentType=function(t){if(void0!==n[t])returnn[t].type},this.getComponentValue=function(t){if(void0!==n[t])returnn[t].value},this.getComponent=function(t){if(void0!==n[t])returnn[t].instance},this.getComponentName=function(t){vare,o;for(o=n.getComponentList(),e=0;e<o.length;e++)if(n[o[e]].instance===t)returno[e]},this.setFactory=function(t,n){o[t]=n},this.toJSON=function(){vart,e={};for(tinn)n.hasOwnProperty(t)&&(e[t]={type:n[t].type,value:n[t].value});returne},this.setComponentValue=function(t,e){n[t].value=e},this.addComponent=function(t,e,i){varr;n[t]={},n[t].type=e,n[t].value=i;vars=o[e];void0!==s&&(r=news(i)),n[t].instance=r},this.removeComponent=function(t){deleten[t]},this.getFactory=function(t){returno[t]},this.getFactoryList=function(){returnObject.keys(o)},this.instanciate=function(){returnfunction(){vart;u.currentContext=r;varn=[];for(t=0;t<i.length;t++)n.push(r.loadLibrary(i[t]));returnPromise.all(n)}().then(f).catch((function(t){console.error("[ARCS] Trouble instanciating context",t)}))};varl=function(t,n){vare,o=Object.create(n);for(eint)t.hasOwnProperty(e)&&(o[e]=t[e]);returno};this.chain=function(t,i,r){return[l(t,n),l(i,e),l(r,o)]},this.setParent=function(t){if(void0!==t){vari=t.chain(n,e,o);n=i[0],e=i[1],o=i[2]}}};u.currentContext=null;constf=u;letl=function(t,n,e){this.getDestination=function(){returnt},this.getSlot=function(){returnn},this.getValue=function(){returne},this.invoke=function(){varo=t[n];void0!==o?o.apply(t,e):console.error("Undefined slot %s of component %s",n,t)}};l.cast=function(t,n){if(void0!==t.value){vare=n.getComponent(t.destination);returnvoid0===e&&console.error("[ARCS] Destination ",t.destination," is undefined"),newl(e,t.slot,t.value)}if(void0!==t.ref)returnnewl(n.getComponent(t.destination),t.slot,n.getConstant(t.ref))},l.PRE_CONNECTION=0,l.POST_CONNECTION=1,l.CLEAN_UP=2;consth=l;letp=function(t,n,e,i){this.connect=function(){try{o.connect(t,n,e,i)}catch(o){console.log(o,t,n,e,i)}},this.disconnect=function(){o.disconnect(t,n,e,i)},this.getSource=function(){returnt},this.getDestination=function(){returne},this.getSlot=function(){returni},this.getSignal=function(){returnn}};p.cast=function(t,n){returnnewp(n.getComponent(t.source),t.signal,n.getComponent(t.destination),t.slot)};constd=p,v=function(t){varn,e,o,i,r,s=newf,c=[],a=[],u=[],l=[],p=0,v=0,g=0,y=0;n=function(){vart;for(t=0;t<c.length;t++)c[t].invoke()},e=function(){vart;for(t=0;t<a.length;t++)a[t].invoke()},o=function(){vart;for(t=0;t<u.length;t++)u[t].invoke()},i=function(){vart;for(t=0;t<l.length;t++)l[t].connect()},r=function(){vart;for(t=0;t<l.length;t++)l[t].disconnect()},this.setContext=function(t){s=t},this.activate=function(){s.instanciate().then((function(){n(),i(),e()}))},this.deactivate=function(){r(),o()},this.addPreConnection=function(t){varn=h.cast(t,s);returnn.id=p++,c.push(n),n.id},this.addPostConnection=function(t){varn=h.cast(t,s);returnn.id=v++,a.push(n),n.id},this.addCleanup=function(t){varn=h.cast(t,s);returnn.id=g++,u.push(n),n.id},this.addConnection=function(t){varn=d.cast(t,s);returnn.id=y++,l.push(n),n.id};varm=function(t,n){for(vare=n.length;e--&&n[e].id!==t;);e>=0?n.splice(e,1):console.warn("Could not remove data with id",t)};this.removePreConnection=function(t){m(t,c)},this.removePostConnection=function(t){m(t,a)},this.removeCleanup=function(t){m(t,u)};varC=function(t,n,e){for(varo=e.length;o--&&e[o].id!==t;);o>=0&&(e[o].value=n)};this.changePreConnection=function(t,n){C(t,n,c)},this.changePostConnection=function(t,n){C(t,n,a)},this.changeCleanup=function(t,n){C(t,n,u)},this.removeConnection=function(t){m(t,l)};varw=function(t,n,e){for(varo,i=e.length,r=e.length;i--&&e[i].id!==t;);for(;r--&&e[r].id!==n;);i>=0&&r>=0&&(o=e[i],e[i]=e[r],e[r]=o,e[i].id=t,e[r].id=n)};this.swapConnections=function(t,n){w(t,n,l)},this.swapCleanups=function(t,n){w(t,n,u)},this.swapPreConnections=function(t,n){w(t,n,c)},this.swapPostConnections=function(t,n){w(t,n,a)},this.import=function(n){n.hasOwnProperty("context")&&(s=newf(n.context)).setParent(t),s.instanciate().then((function(){!function(t){varn=0,e=h.cast,o=d.cast;for(n=0;n<t.preconnections.length;n++)c.push(e(t.preconnections[n],s));for(n=0;n<t.postconnections.length;n++)a.push(e(t.postconnections[n],s));for(n=0;n<t.cleanups.length;n++)u.push(e(t.cleanups[n],s));for(n=0;n<t.connections.length;n++)l.push(o(t.connections[n],s))}(n)}))};varS=function(t){return{destination:s.getComponentName(t.getDestination()),slot:t.getSlot(),value:t.getValue()}};this.toJSON=function(){vart,n,e=[],o=[],i=[],r=[];for(t=0;t<l.length;t++)i.push((n=l[t],{source:s.getComponentName(n.getSource()),signal:n.getSignal(),destination:s.getComponentName(n.getDestination()),slot:n.getSlot()}));for(t=0;t<c.length;t++)e.push(S(c[t]));for(t=0;t<a.length;t++)o.push(S(a[t]));for(t=0;t<u.length;t++)r.push(S(u[t]));return{preconnections:e,postconnections:o,connections:i,cleanups:r}},s.setParent(t)};letg=function(){vart,n=newf,e={},i={},r=[],s=this,c="";this.export=function(){return{context:n,controller:n.getComponentName(i),sheets:e}},this.getContext=function(){returnn},this.getSheetList=function(){returnObject.keys(e)},this.getSheet=function(t){returne[t]},this.addSheet=function(t,o){e[t]=o,o.setContext(n)},this.removeSheet=function(t){deletee[t]},t=function(){vart,r,c;for(r=n.getComponent(i),i=r,c=Object.keys(e),t=0;t<c.length;t++)(r=newv(n)).import(e[c[t]],n),e[c[t]]=r;o.connect(i,"requestSheet",s,"setSheet"),o.connect(i,"requestTermination",s,"finish"),i.start()},this.setController=function(t){i=n.getComponent(t)},this.setSheet=function(t){e.hasOwnProperty(t)?(c&&e[c].deactivate(),e[c=t].activate()):console.warn("[ARCS] Tried to activate hollow sheet named: "+t)},this.finish=function(){c&&e[c].deactivate()},this.import=function(t){n=newf(t.context),e=t.sheets,void0===(i=t.controller)&&console.error("[ARCS] Undefined controller. Cannot start application.")},this.setFactory=function(t,n){factories[t]=n},this.setDependency=function(t){r[t]={}},this.start=function(){console.log("[ARCS] Starting application..."),n.instanciate().then(t)}};g.setDependency=function(t,n){t.setDependency(n)},o.create(g),g.slot("setSheet"),g.slot("finish");consty={Component:o,isInNode:function(){return"undefined"!=typeofprocess&&-1!==process.release.name.search(/node|io.js/)},StateMachine:a,Context:f,Invocation:h,Connection:d,Sheet:v,Application:g};varm=n.Z;export{masdefault};
\ No newline at end of file
varn={d:(t,e)=>{for(varoine)n.o(e,o)&&!n.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:e[o]})},o:(n,t)=>Object.prototype.hasOwnProperty.call(n,t)},t={};n.d(t,{Z:()=>y});vare={SourceIsNotComponent:{message:"Source is not a component"},UndefinedSignal:{message:"Signal is not defined"},UndefinedSlot:{message:"Slot is not defined"},create:function(n,t,e){returnvoid0===n.prototype?(console.error("Cannot create such a component"),0):(n.prototype.slots=[],n.prototype.signals={},n.slotList=function(){returnn.prototype.slots},n.prototype.slotList=function(){returnn.prototype.slots},n.prototype.signalList=function(){vart,e=[];for(tinn.prototype.signals)e.push(t);returne},n.signalList=function(){returnn.prototype.signalList()},n.prototype.emit=function(n){vart,e,o,i=Array.prototype.slice.call(arguments,1);for(tinthis.signals[n])e=this.signals[n][t].func,o=this.signals[n][t].obj,e.apply(o,i)},n.slot=function(t,e){varo;if(tinstanceofArray)for(o=0;o<t.length;o++)n.prototype.slots.push(t[o]);elsen.prototype.slots.push(t),void0!==e&&(n.prototype[t]=e)},n.signal=function(t){vare;if(tinstanceofArray)for(e=0;e<t.length;e++)n.prototype.signals[t[e]]=1;elsen.prototype.signals[t]=1},void0!==t&&n.slot(t),void0!==e&&n.signal(e),n)},check:function(n){returnvoid0!==n.prototype&&void0!==n.prototype.signals&&void0!==n.prototype.slots},connect:function(n,t,o,i){varr,s;if(void0===n.signals)throwe.SourceIsNotComponent;if(void0===n.signals[t])throwe.UndefinedSignal;if(void0===o[i])throwe.UndefinedSlot;if(!n.hasOwnProperty("signals"))for(sinr=n.signals,n.signals={},r)n.signals[s]=[];n.signals[t].push({obj:o,func:o[i]})},disconnect:function(n,t,e,o){vari;for(i=0;i<n.signals[t].length;i++)n.signals[t][i].obj===e&&n.signals[t][i].func===e[o]&&(n.signals[t].splice(i,1),i--)},invoke:function(n,t,o){if(void0===n[t])throwe.UndefinedSlot;n[t].apply(n,o)},config:function(n,t){"function"==typeofn.config&&n.config(t)}};consto=e,i=function(){varn,t;this.promise=newPromise((function(e,o){n=e,t=o})),this.accept=function(){n()},this.abort=function(){t()}};letr=function(){this.promise={},this.and=function(n){returnthis.promise=Promise.all([this.promise,n.promise]),this},this.or=function(n){returnthis.promise=Promise.race([this.promise,n.promise]),this}};r.build=function(n,t){vare,o,s,c;if("string"==typeofn){vara;t.hasOwnProperty(n)?a=t[n]:t[n]=a=newi;varu=newr;returnu.promise=a.promise,u}for(e=r.build(n[0],t),c=1;c<n.length;c++)n[c].hasOwnProperty("and")?(s=r.build(n[c].and,t),o=e.and(s)):n[c].hasOwnProperty("or")?(s=r.build(n[c].or,t),o=e.or(s)):console.warn("[ARCS] Illegal tree"),e=o;returne};consts=r,c=function(){functionn(n,t,e,o,i,r){this.message=n,this.expected=t,this.found=e,this.offset=o,this.line=i,this.column=r,this.name="SyntaxError"}returnfunction(n,t){functione(){this.constructor=n}e.prototype=t.prototype,n.prototype=newe}(n,Error),{SyntaxError:n,parse:function(t){vare,o=arguments.length>1?arguments[1]:{},i={},r={start:Z},s=Z,c=i,a=function(n,t){return[n].concat(t)},u=function(n){return{and:n}},f=function(n){return{or:n}},l=function(n){returnn},h="(",p={type:"literal",value:"(",description:'"("'},d=")",v={type:"literal",value:")",description:'")"'},g=function(n){return[n]},y={type:"other",description:"id"},m=function(n){returnn.trim()},C=/^[_a-zA-Z]/,w={type:"class",value:"[_a-zA-Z]",description:"[_a-zA-Z]"},S=/^[_a-zA-Z0-9]/,A={type:"class",value:"[_a-zA-Z0-9]",description:"[_a-zA-Z0-9]"},P="&",O={type:"literal",value:"&",description:'"&"'},x="|",R={type:"literal",value:"|",description:'"|"'},b=/^[\r\n\t]/,F={type:"class",value:"[ \\r\\n\\t]",description:"[ \\r\\n\\t]"},N=0,T=0,j={line:1,column:1,seenCR:!1},k=0,L=[],E=0;if("startRule"ino){if(!(o.startRuleinr))thrownewError("Can't start parsing from rule \""+o.startRule+'".');s=r[o.startRule]}function_(n){returnT!==n&&(T>n&&(T=0,j={line:1,column:1,seenCR:!1}),function(n,e,o){vari,r;for(i=e;i<o;i++)"\n"===(r=t.charAt(i))?(n.seenCR||n.line++,n.column=1,n.seenCR=!1):"\r"===r||"\u2028"===r||"\u2029"===r?(n.line++,n.column=1,n.seenCR=!0):(n.column++,n.seenCR=!1)}(j,T,n),T=n),j}functionI(n){N<k||(N>k&&(k=N,L=[]),L.push(n))}functionU(e,o,i){varr=_(i),s=i<t.length?t.charAt(i):null;returnnull!==o&&function(n){vart=1;for(n.sort((function(n,t){returnn.description<t.description?-1:n.description>t.description?1:0}));t<n.length;)n[t-1]===n[t]?n.splice(t,1):t++}(o),newn(null!==e?e:function(n,t){vare,o=newArray(n.length);for(e=0;e<n.length;e++)o[e]=n[e].description;return"Expected "+(n.length>1?o.slice(0,-1).join(", ")+" or "+o[n.length-1]:o[0])+" but "+(t?'"'+function(n){functiont(n){returnn.charCodeAt(0).toString(16).toUpperCase()}returnn.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\x08/g,"\\b").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\f/g,"\\f").replace(/\r/g,"\\r").replace(/[\x00-\x07\x0B\x0E\x0F]/g,(function(n){return"\\x0"+t(n)})).replace(/[\x10-\x1F\x80-\xFF]/g,(function(n){return"\\x"+t(n)})).replace(/[\u0180-\u0FFF]/g,(function(n){return"\\u0"+t(n)})).replace(/[\u1080-\uFFFF]/g,(function(n){return"\\u"+t(n)}))}(t)+'"':"end of input")+" found."}(o,s),o,s,i,r.line,r.column)}functionZ(){returnD()}functionD(){varn,t,e,o;if(n=N,(t=z())!==i){if(e=[],(o=q())!==i)for(;o!==i;)e.push(o),o=q();elsee=c;e!==i?n=t=a(t,e):(N=n,n=c)}elseN=n,n=c;returnn===i&&(n=z()),n}functionq(){varn,t;returnn=N,M()!==i&&(t=z())!==i?n=u(t):(N=n,n=c),n===i&&(n=N,B()!==i&&(t=z())!==i?n=f(t):(N=n,n=c)),n}functionz(){varn,e,o,r;returnn=N,(e=V())!==i&&(e=l(e)),(n=e)===i&&(n=N,40===t.charCodeAt(N)?(e=h,N++):(e=i,0===E&&I(p)),e!==i&&(o=D())!==i?(41===t.charCodeAt(N)?(r=d,N++):(r=i,0===E&&I(v)),r!==i?n=e=g(o):(N=n,n=c)):(N=n,n=c)),n}functionV(){varn,e,o;returnE++,n=N,e=N,(o=J())!==i&&(o=t.substring(e,N)),(e=o)!==i&&(e=m(e)),E--,(n=e)===i&&(e=i,0===E&&I(y)),n}functionJ(){varn,e,o,r,s;if(n=N,(e=G())!==i)if(C.test(t.charAt(N))?(o=t.charAt(N),N++):(o=i,0===E&&I(w)),o!==i){for(r=[],S.test(t.charAt(N))?(s=t.charAt(N),N++):(s=i,0===E&&I(A));s!==i;)r.push(s),S.test(t.charAt(N))?(s=t.charAt(N),N++):(s=i,0===E&&I(A));r!==i&&(s=G())!==i?n=e=[e,o,r,s]:(N=n,n=c)}elseN=n,n=c;elseN=n,n=c;returnn}functionM(){varn,e,o,r;returnn=N,(e=G())!==i?(38===t.charCodeAt(N)?(o=P,N++):(o=i,0===E&&I(O)),o!==i&&(r=G())!==i?n=e=[e,o,r]:(N=n,n=c)):(N=n,n=c),n}functionB(){varn,e,o,r;returnn=N,(e=G())!==i?(124===t.charCodeAt(N)?(o=x,N++):(o=i,0===E&&I(R)),o!==i&&(r=G())!==i?n=e=[e,o,r]:(N=n,n=c)):(N=n,n=c),n}functionG(){varn,e;for(n=[],b.test(t.charAt(N))?(e=t.charAt(N),N++):(e=i,0===E&&I(F));e!==i;)n.push(e),b.test(t.charAt(N))?(e=t.charAt(N),N++):(e=i,0===E&&I(F));returnn}if((e=s())!==i&&N===t.length)returne;throwe!==i&&N<t.length&&I({type:"end",description:"end of input"}),U(null,L,k)}}}(),a=o.create((function(n){vart="",e="",o={},i="",r=this,a={},u={},f=function(n){vart;r.slots.indexOf(n)<0&&(r.slots.push(n),r[n]=(t=n,function(){r.setToken(t)}))},l=function(n){vart;if(o.hasOwnProperty(n))for(tinu={},o[n])o[n].hasOwnProperty(t)&&s.build(a[t],u).promise.then((function(){vare;for(einu)u.hasOwnProperty(e)&&u[e].abort();l(o[n][t])}));i=n,r.emit("requestSheet",i),i===e&&r.emit("requestTermination")};this.setInitialState=function(n){i=t=n},this.setFinalState=function(n){e=n},this.addTransition=function(n,t,e){vari,r=/([A-Za-z_]\w*)/g;try{vars;if("string"==typeof(s=c.parse(t)))f(s);elsefor(;null!==(i=r.exec(t));)f(i[0]);a[t]=s,void0===o[n]&&(o[n]={}),o[n][t]=e}catch(n){}},this.setToken=function(n){u.hasOwnProperty(n)&&u[n].accept()},this.setTransitions=function(n){vart,e;for(tinn)if(n.hasOwnProperty(t))for(einn[t])n[t].hasOwnProperty(e)&&this.addTransition(t,e,n[t][e])},this.start=function(){l(t)},void0!==n&&(t=n.initial,e=n.final,this.setTransitions(n.transitions),i="")}),["setToken"],["requestSheet","requestTermination"]);letu=function(n){lett={},e={},o={},i=[],r=this,s=!1;if(o.StateMachine=a,void0!==n){varc;for(cini=n.libraries,n.components)n.components.hasOwnProperty(c)&&(t[c]=n.components[c]);if(void0!==n.constants)for(cinn.constants)n.constants.hasOwnProperty(c)&&(e[c]=n.constants[c])}varf=asyncfunction(n){returny()?newPromise((function(t,e){varo=require(n);void0!==o?t(o):e("[ARCS] File not found")})):(awaitfetch(n)).json()};this.loadLibrary=function(n,t){vare=n,o=n;returnu.currentContext=r,"string"!=typeofn&&(o=n.name,e=n.url),i.indexOf(o)<0&&i.push(o),import(e).then((function(n){for(cinn.default)n.default.hasOwnProperty(c)&&u.currentContext.setFactory(c,n.default[c]);void0!==t&&t()})).catch((function(n){console.error("[ARCS] Trouble loading '",e,"' with reason -",{msg:n})}))},this.getComponentList=function(){varn,e=Object.keys(t);for(n=0;n<e.length;n++)t.hasOwnProperty(e[n])||e.splice(n--,1);returne},this.getConstant=function(n){returne[n]},this.getComponentType=function(n){if(void0!==t[n])returnt[n].type},this.getComponentValue=function(n){if(void0!==t[n])returnt[n].value},this.getComponent=function(n){if(void0!==t[n])returnt[n].instance},this.getComponentName=function(n){vare,o;for(o=t.getComponentList(),e=0;e<o.length;e++)if(t[o[e]].instance===n)returno[e]},this.addFactories=function(n){for(cins=!0,n)n.hasOwnProperty(c)&&(o[c]=n[c])},this.setFactory=function(n,t){o[n]=t},this.toJSON=function(){varn,e={};for(nint)t.hasOwnProperty(n)&&(e[n]={type:t[n].type,value:t[n].value});returne},this.setComponentValue=function(n,e){t[n].value=e},this.addComponent=function(n,e,i){varr;t[n]={},t[n].type=e,t[n].value=i;vars=o[e];void0!==s&&(r=news(i)),t[n].instance=r},this.removeComponent=function(n){deletet[n]},this.getFactory=function(n){returno[n]},this.getFactoryList=function(){returnObject.keys(o)},this.instanciate=asyncfunction(){try{s&&awaitfunction(){varn;u.currentContext=r;vart=[];for(n=0;n<i.length;n++)t.push(r.loadLibrary(i[n]));returnPromise.all(t)}(),console.log("[ARCS] toto"),awaitasyncfunction(){varn,r=[];for(ninconsole.log("[ARCS] Components:",t),t)if(t.hasOwnProperty(n)){if(void0===o[t[n].type])returnconsole.error("[ARCS] Factory "+t[n].type+" not found."),voidconsole.error("[ARCS] Context dump follows: ",i,t,e);vars=o[t[n].type];try{void0!==t[n].value||void0!==t[n].url||void0!==t[n].ref?(void0!==t[n].value&&(t[n].instance=news(t[n].value)),void0!==t[n].url&&(console.log("loading data file",t[n].url),r.push(f(t[n].url).then(function(n,e){returnfunction(o){returnconsole.log("instanciating from data file"),t[n].instance=newe(o),Promise.resolve()}}(n,s)))),void0!==t[n].ref&&void0!==e[t[n].ref]&&(t[n].instance=news(e[t[n].ref]))):t[n].instance=news}catch(t){console.error("[ARCS] Component of type ",n," not instanciated.",t)}}returnPromise.all(r)}(),console.log("[ARCS] tutu")}catch(n){console.error("[ARCS] Trouble instanciating context",n)}};varl=function(n,t){vare,o=Object.create(t);for(einn)n.hasOwnProperty(e)&&(o[e]=n[e]);returno};this.chain=function(n,i,r){return[l(n,t),l(i,e),l(r,o)]},this.setParent=function(n){if(void0!==n){vari=n.chain(t,e,o);t=i[0],e=i[1],o=i[2]}}};u.currentContext=null;constf=u;letl=function(n,t,e){this.getDestination=function(){returnn},this.getSlot=function(){returnt},this.getValue=function(){returne},this.invoke=function(){varo=n[t];void0!==o?o.apply(n,e):console.error("Undefined slot %s of component %s",t,n)}};l.cast=function(n,t){if(void0!==n.value){vare=t.getComponent(n.destination);returnvoid0===e&&console.error("[ARCS] Destination ",n.destination," is undefined"),newl(e,n.slot,n.value)}if(void0!==n.ref)returnnewl(t.getComponent(n.destination),n.slot,t.getConstant(n.ref))},l.PRE_CONNECTION=0,l.POST_CONNECTION=1,l.CLEAN_UP=2;consth=l;letp=function(n,t,e,i){this.connect=function(){try{o.connect(n,t,e,i)}catch(o){console.log(o,n,t,e,i)}},this.disconnect=function(){o.disconnect(n,t,e,i)},this.getSource=function(){returnn},this.getDestination=function(){returne},this.getSlot=function(){returni},this.getSignal=function(){returnt}};p.cast=function(n,t){returnnewp(t.getComponent(n.source),n.signal,t.getComponent(n.destination),n.slot)};constd=p,v=function(n){vart,e,o,i,r,s=newf,c=[],a=[],u=[],l=[],p=0,v=0,g=0,y=0;t=function(){varn;for(n=0;n<c.length;n++)c[n].invoke()},e=function(){varn;for(n=0;n<a.length;n++)a[n].invoke()},o=function(){varn;for(n=0;n<u.length;n++)u[n].invoke()},i=function(){varn;for(n=0;n<l.length;n++)l[n].connect()},r=function(){varn;for(n=0;n<l.length;n++)l[n].disconnect()},this.setContext=function(n){s=n},this.activate=function(){s.instanciate().then((function(){t(),i(),e()}))},this.deactivate=function(){r(),o()},this.addPreConnection=function(n){vart=h.cast(n,s);returnt.id=p++,c.push(t),t.id},this.addPostConnection=function(n){vart=h.cast(n,s);returnt.id=v++,a.push(t),t.id},this.addCleanup=function(n){vart=h.cast(n,s);returnt.id=g++,u.push(t),t.id},this.addConnection=function(n){vart=d.cast(n,s);returnt.id=y++,l.push(t),t.id};varm=function(n,t){for(vare=t.length;e--&&t[e].id!==n;);e>=0?t.splice(e,1):console.warn("Could not remove data with id",n)};this.removePreConnection=function(n){m(n,c)},this.removePostConnection=function(n){m(n,a)},this.removeCleanup=function(n){m(n,u)};varC=function(n,t,e){for(varo=e.length;o--&&e[o].id!==n;);o>=0&&(e[o].value=t)};this.changePreConnection=function(n,t){C(n,t,c)},this.changePostConnection=function(n,t){C(n,t,a)},this.changeCleanup=function(n,t){C(n,t,u)},this.removeConnection=function(n){m(n,l)};varw=function(n,t,e){for(varo,i=e.length,r=e.length;i--&&e[i].id!==n;);for(;r--&&e[r].id!==t;);i>=0&&r>=0&&(o=e[i],e[i]=e[r],e[r]=o,e[i].id=n,e[r].id=t)};this.swapConnections=function(n,t){w(n,t,l)},this.swapCleanups=function(n,t){w(n,t,u)},this.swapPreConnections=function(n,t){w(n,t,c)},this.swapPostConnections=function(n,t){w(n,t,a)},this.import=function(t){t.hasOwnProperty("context")&&(s=newf(t.context)).setParent(n),s.instanciate().then((function(){!function(n){vart=0,e=h.cast,o=d.cast;for(t=0;t<n.preconnections.length;t++)c.push(e(n.preconnections[t],s));for(t=0;t<n.postconnections.length;t++)a.push(e(n.postconnections[t],s));for(t=0;t<n.cleanups.length;t++)u.push(e(n.cleanups[t],s));for(t=0;t<n.connections.length;t++)l.push(o(n.connections[t],s))}(t)}))};varS=function(n){return{destination:s.getComponentName(n.getDestination()),slot:n.getSlot(),value:n.getValue()}};this.toJSON=function(){varn,t,e=[],o=[],i=[],r=[];for(n=0;n<l.length;n++)i.push((t=l[n],{source:s.getComponentName(t.getSource()),signal:t.getSignal(),destination:s.getComponentName(t.getDestination()),slot:t.getSlot()}));for(n=0;n<c.length;n++)e.push(S(c[n]));for(n=0;n<a.length;n++)o.push(S(a[n]));for(n=0;n<u.length;n++)r.push(S(u[n]));return{preconnections:e,postconnections:o,connections:i,cleanups:r}},s.setParent(n)};letg=function(){varn=newf,t={},e={},i=[],r=this,s="";this.export=function(){return{context:n,controller:n.getComponentName(e),sheets:t}},this.getContext=function(){returnn},this.getSheetList=function(){returnObject.keys(t)},this.getSheet=function(n){returnt[n]},this.addSheet=function(e,o){t[e]=o,o.setContext(n)},this.removeSheet=function(n){deletet[n]},this.launch=function(){vari,s,c;if(console.log("[ARCS] Starting application..."),s=n.getComponent(e),void0!==(e=s)){for(c=Object.keys(t),i=0;i<c.length;i++)(s=newv(n)).import(t[c[i]],n),t[c[i]]=s;o.connect(e,"requestSheet",r,"setSheet"),o.connect(e,"requestTermination",r,"finish"),e.start()}elseconsole.error("[ARCS] undefined controller")},this.setController=function(t){e=n.getComponent(t)},this.setSheet=function(n){t.hasOwnProperty(n)?(s&&t[s].deactivate(),t[s=n].activate()):console.warn("[ARCS] Tried to activate hollow sheet named: "+n)},this.finish=function(){s&&t[s].deactivate()},this.import=function(o){n=newf(o.context),t=o.sheets,void0===(e=o.controller)&&console.error("[ARCS] Undefined controller. Cannot start application.")},this.setFactory=function(n,t){factories[n]=t},this.setDependency=function(n){i[n]={}},this.start=asyncfunction(){console.log("[ARCS] Instanciating components..."),awaitn.instanciate(),this.launch()}};g.setDependency=function(n,t){n.setDependency(t)},o.create(g),g.slot("setSheet"),g.slot("finish");consty={Component:o,isInNode:function(){return"undefined"!=typeofprocess&&-1!==process.release.name.search(/node|io.js/)},StateMachine:a,Context:f,Invocation:h,Connection:d,Sheet:v,Application:g};varm=t.Z;export{masdefault};