"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("../machine.js"),s=require("../utils/default-map.js"),c=require("../utils/match.js"),i=Object.defineProperty,r=(e,t,s)=>(((e,t,s)=>{t in e?i(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s})(e,"symbol"!=typeof t?t+"":t,s),s),a=((e=a||{})[e.Push=0]="Push",e[e.Pop=1]="Pop",e);let n={0(e,t){let s=t.id,c=e.stack,i=e.stack.indexOf(s);if(-1!==i){let t=e.stack.slice();return t.splice(i,1),t.push(s),c=t,{...e,stack:c}}return{...e,stack:[...e.stack,s]}},1(e,t){let s=t.id,c=e.stack.indexOf(s);if(-1===c)return e;let i=e.stack.slice();return i.splice(c,1),{...e,stack:i}}};class u extends t.Machine{constructor(){super(...arguments),r(this,"actions",{push:e=>this.send({type:0,id:e}),pop:e=>this.send({type:1,id:e})}),r(this,"selectors",{isTop:(e,t)=>e.stack[e.stack.length-1]===t,inStack:(e,t)=>e.stack.includes(t)})}static new(){return new u({stack:[]})}reduce(e,t){return c.match(t.type,n,e,t)}}const l=new s.DefaultMap((()=>u.new()));exports.ActionTypes=a,exports.stackMachines=l;
//# sourceMappingURL=stack-machine.js.map
