board-game-engine 1.0.5 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/board-game-engine.cjs +4 -4
- package/dist/board-game-engine.js +4 -4
- package/dist/board-game-engine.min.js +1 -1
- package/dist/board-game-engine.mjs +4 -4
- package/examples/checkers.json +2 -2
- package/examples/connect-four.json +1 -1
- package/examples/eights.json +15 -15
- package/package.json +1 -1
- package/src/game-factory/condition/condition.js +1 -1
- package/src/utils/resolve-properties.js +9 -9
|
@@ -8425,10 +8425,10 @@ function resolveProperty(bgioArguments, value2, context) {
|
|
|
8425
8425
|
return get(bgioArguments.ctx, value2.path);
|
|
8426
8426
|
} else if (value2?.type === "gamePath") {
|
|
8427
8427
|
return get(bgioArguments.G, value2.path);
|
|
8428
|
-
} else if (value2?.type === "RelativePath") {
|
|
8428
|
+
} else if (value2?.type === "relativePath" || value2?.type === "RelativePath") {
|
|
8429
8429
|
const target = resolveProperties(bgioArguments, value2.target, context, "target");
|
|
8430
8430
|
return get(target.attributes, value2.path) ?? null;
|
|
8431
|
-
} else if (value2?.type === "Parent") {
|
|
8431
|
+
} else if (value2?.type === "parent" || value2?.type === "Parent") {
|
|
8432
8432
|
const originalTarget = value2.target ? resolveProperties(bgioArguments, value2.target, context, "target") : context.originalTarget;
|
|
8433
8433
|
return bgioArguments.G.bank.findParent(originalTarget) ?? null;
|
|
8434
8434
|
} else if (value2?.type === "map") {
|
|
@@ -8458,7 +8458,7 @@ function resolveProperty(bgioArguments, value2, context) {
|
|
|
8458
8458
|
}
|
|
8459
8459
|
}
|
|
8460
8460
|
return maxTargets;
|
|
8461
|
-
} else if (value2?.type === "Pick") {
|
|
8461
|
+
} else if (value2?.type === "pick" || value2?.type === "Pick") {
|
|
8462
8462
|
const target = resolveProperties(bgioArguments, value2.target, context, "target");
|
|
8463
8463
|
return (0, import_pick.default)(
|
|
8464
8464
|
resolveProperties(
|
|
@@ -8469,7 +8469,7 @@ function resolveProperty(bgioArguments, value2, context) {
|
|
|
8469
8469
|
),
|
|
8470
8470
|
value2.properties
|
|
8471
8471
|
);
|
|
8472
|
-
} else if (value2?.type === "Coordinates") {
|
|
8472
|
+
} else if (value2?.type === "coordinates" || value2?.type === "Coordinates") {
|
|
8473
8473
|
const originalTarget = value2.target ? resolveProperties(bgioArguments, value2.target, context, "target") : context.originalTarget;
|
|
8474
8474
|
const parent = bgioArguments.G.bank.findParent(originalTarget);
|
|
8475
8475
|
return parent.getCoordinates(originalTarget.rule.index);
|
|
@@ -8425,10 +8425,10 @@ ${message}`);
|
|
|
8425
8425
|
return get(bgioArguments.ctx, value2.path);
|
|
8426
8426
|
} else if (value2?.type === "gamePath") {
|
|
8427
8427
|
return get(bgioArguments.G, value2.path);
|
|
8428
|
-
} else if (value2?.type === "RelativePath") {
|
|
8428
|
+
} else if (value2?.type === "relativePath" || value2?.type === "RelativePath") {
|
|
8429
8429
|
const target = resolveProperties(bgioArguments, value2.target, context, "target");
|
|
8430
8430
|
return get(target.attributes, value2.path) ?? null;
|
|
8431
|
-
} else if (value2?.type === "Parent") {
|
|
8431
|
+
} else if (value2?.type === "parent" || value2?.type === "Parent") {
|
|
8432
8432
|
const originalTarget = value2.target ? resolveProperties(bgioArguments, value2.target, context, "target") : context.originalTarget;
|
|
8433
8433
|
return bgioArguments.G.bank.findParent(originalTarget) ?? null;
|
|
8434
8434
|
} else if (value2?.type === "map") {
|
|
@@ -8458,7 +8458,7 @@ ${message}`);
|
|
|
8458
8458
|
}
|
|
8459
8459
|
}
|
|
8460
8460
|
return maxTargets;
|
|
8461
|
-
} else if (value2?.type === "Pick") {
|
|
8461
|
+
} else if (value2?.type === "pick" || value2?.type === "Pick") {
|
|
8462
8462
|
const target = resolveProperties(bgioArguments, value2.target, context, "target");
|
|
8463
8463
|
return (0, import_pick.default)(
|
|
8464
8464
|
resolveProperties(
|
|
@@ -8469,7 +8469,7 @@ ${message}`);
|
|
|
8469
8469
|
),
|
|
8470
8470
|
value2.properties
|
|
8471
8471
|
);
|
|
8472
|
-
} else if (value2?.type === "Coordinates") {
|
|
8472
|
+
} else if (value2?.type === "coordinates" || value2?.type === "Coordinates") {
|
|
8473
8473
|
const originalTarget = value2.target ? resolveProperties(bgioArguments, value2.target, context, "target") : context.originalTarget;
|
|
8474
8474
|
const parent = bgioArguments.G.bank.findParent(originalTarget);
|
|
8475
8475
|
return parent.getCoordinates(originalTarget.rule.index);
|
|
@@ -4,7 +4,7 @@ This likely means game code is triggering an infinite loop.`,e.PhaseEventInOnEnd
|
|
|
4
4
|
${s}`),[e,r]},p0=({G:e,ctx:t,plugins:n={}},{game:r,playerID:i})=>([...br,...r.plugins].forEach(({name:s,playerView:o})=>{if(!o)return;let{data:a}=n[s]||{data:{}},u=o({G:e,ctx:t,game:r,data:a,playerID:i});n={...n,[s]:{data:u}}}),n);function sa(e,t=!1){e.moveLimit&&(t&&(e.minMoves=e.moveLimit),e.maxMoves=e.moveLimit,delete e.moveLimit)}function oa(e,t){let n={},r=[],i=null,s={},o={};if(Array.isArray(t)){let u={};t.forEach(c=>u[c]=nn.NULL),n=u}else{if(sa(t),t.next&&(i=t.next),t.revert&&(r=[...e._prevActivePlayers,{activePlayers:e.activePlayers,_activePlayersMinMoves:e._activePlayersMinMoves,_activePlayersMaxMoves:e._activePlayersMaxMoves,_activePlayersNumMoves:e._activePlayersNumMoves}]),t.currentPlayer!==void 0&&gs(n,s,o,e.currentPlayer,t.currentPlayer),t.others!==void 0)for(let u=0;u<e.playOrder.length;u++){let c=e.playOrder[u];c!==e.currentPlayer&&gs(n,s,o,c,t.others)}if(t.all!==void 0)for(let u=0;u<e.playOrder.length;u++){let c=e.playOrder[u];gs(n,s,o,c,t.all)}if(t.value)for(let u in t.value)gs(n,s,o,u,t.value[u]);if(t.minMoves)for(let u in n)s[u]===void 0&&(s[u]=t.minMoves);if(t.maxMoves)for(let u in n)o[u]===void 0&&(o[u]=t.maxMoves)}Object.keys(n).length===0&&(n=null),Object.keys(s).length===0&&(s=null),Object.keys(o).length===0&&(o=null);let a={};for(let u in n)a[u]=0;return{...e,activePlayers:n,_activePlayersMinMoves:s,_activePlayersMaxMoves:o,_activePlayersNumMoves:a,_prevActivePlayers:r,_nextActivePlayers:i}}function h0(e){let{activePlayers:t,_activePlayersMinMoves:n,_activePlayersMaxMoves:r,_activePlayersNumMoves:i,_prevActivePlayers:s,_nextActivePlayers:o}=e;if(t&&Object.keys(t).length===0)if(o)e=oa(e,o),{activePlayers:t,_activePlayersMinMoves:n,_activePlayersMaxMoves:r,_activePlayersNumMoves:i,_prevActivePlayers:s}=e;else if(s.length>0){let a=s.length-1;({activePlayers:t,_activePlayersMinMoves:n,_activePlayersMaxMoves:r,_activePlayersNumMoves:i}=s[a]),s=s.slice(0,a)}else t=null,n=null,r=null;return{...e,activePlayers:t,_activePlayersMinMoves:n,_activePlayersMaxMoves:r,_activePlayersNumMoves:i,_prevActivePlayers:s}}function gs(e,t,n,r,i){(typeof i!="object"||i===nn.NULL)&&(i={stage:i}),i.stage!==void 0&&(sa(i),e[r]=i.stage,i.minMoves&&(t[r]=i.minMoves),i.maxMoves&&(n[r]=i.maxMoves))}function ea(e,t){return e[t]+""}function d0(e,t){let{G:n,ctx:r}=e,{numPlayers:i}=r,o={...ia(e),G:n,ctx:r},a=t.order,u=[...Array.from({length:i})].map((p,h)=>h+"");a.playOrder!==void 0&&(u=a.playOrder(o));let c=a.first(o),l=typeof c;l!=="number"&&Sn(`invalid value returned by turn.order.first \u2014 expected number got ${l} \u201C${c}\u201D.`);let f=ea(u,c);return r={...r,currentPlayer:f,playOrderPos:c,playOrder:u},r=oa(r,t.activePlayers||{}),r}function m0(e,t,n,r){let i=n.order,{G:s,ctx:o}=e,a=o.playOrderPos,u=!1;if(r&&r!==!0)typeof r!="object"&&Sn(`invalid argument to endTurn: ${r}`),Object.keys(r).forEach(c=>{switch(c){case"remove":t=ea(o.playOrder,a);break;case"next":a=o.playOrder.indexOf(r.next),t=r.next;break;default:Sn(`invalid argument to endTurn: ${c}`)}});else{let l={...ia(e),G:s,ctx:o},f=i.next(l),p=typeof f;f!==void 0&&p!=="number"&&Sn(`invalid value returned by turn.order.next \u2014 expected number or undefined got ${p} \u201C${f}\u201D.`),f===void 0?u=!0:(a=f,t=ea(o.playOrder,a))}return o={...o,playOrderPos:a,currentPlayer:t},{endPhase:u,ctx:o}}var g0={DEFAULT:{first:({ctx:e})=>e.turn===0?e.playOrderPos:(e.playOrderPos+1)%e.playOrder.length,next:({ctx:e})=>(e.playOrderPos+1)%e.playOrder.length},RESET:{first:()=>0,next:({ctx:e})=>(e.playOrderPos+1)%e.playOrder.length},CONTINUE:{first:({ctx:e})=>e.playOrderPos,next:({ctx:e})=>(e.playOrderPos+1)%e.playOrder.length},ONCE:{first:()=>0,next:({ctx:e})=>{if(e.playOrderPos<e.playOrder.length-1)return e.playOrderPos+1}},CUSTOM:e=>({playOrder:()=>e,first:()=>0,next:({ctx:t})=>(t.playOrderPos+1)%t.playOrder.length}),CUSTOM_FROM:e=>({playOrder:({G:t})=>t[e],first:()=>0,next:({ctx:t})=>(t.playOrderPos+1)%t.playOrder.length})},nn={NULL:null},y0={ALL:{all:nn.NULL},ALL_ONCE:{all:nn.NULL,minMoves:1,maxMoves:1},OTHERS:{others:nn.NULL},OTHERS_ONCE:{others:nn.NULL,minMoves:1,maxMoves:1}};K.ActionCreators=$_;K.ActivePlayers=y0;K.Enhance=a0;K.FlushAndValidate=f0;K.FnWrap=s0;K.GAME_EVENT=ta;K.GetAPIs=ia;K.INVALID_MOVE=Qo;K.InitTurnOrderState=d0;K.MAKE_MOVE=ql;K.NoClient=c0;K.PATCH=Gl;K.PLUGIN=Fl;K.PlayerView=p0;K.ProcessAction=i0;K.REDO=jl;K.RESET=Dl;K.STRIP_TRANSIENTS=Ul;K.SYNC=Rl;K.SetActivePlayers=oa;K.Setup=o0;K.Stage=nn;K.TurnOrder=g0;K.UNDO=Bl;K.UPDATE=Ll;K.UpdateActivePlayersOnceEmpty=h0;K.UpdateTurnOrderState=m0;K.error=Sn;K.gameEvent=zl;K.info=r0;K.makeMove=Vl;K.patch=Wl;K.redo=Xl;K.reset=Yl;K.stripTransients=Ql;K.supportDeprecatedMoveLimit=sa;K.sync=Hl;K.undo=$l;K.update=Jl});var aa=v(zt=>{"use strict";Object.defineProperty(zt,"__esModule",{value:!0});var _r=Zl();Jo();Xo();tn();var v0={STRIP_SECRETS:({G:e,playerID:t})=>{let n={...e};return n.secret!==void 0&&delete n.secret,n.players&&(n.players=t?{[t]:n.players[t]}:{}),n}};zt.ActivePlayers=_r.ActivePlayers;Object.defineProperty(zt,"GameMethod",{enumerable:!0,get:function(){return _r.GameMethod}});zt.INVALID_MOVE=_r.INVALID_MOVE;zt.Stage=_r.Stage;zt.TurnOrder=_r.TurnOrder;zt.PlayerView=v0});var tf=v((fD,ef)=>{function b0(e,t,n){var r=-1,i=e.length;t<0&&(t=-t>i?0:i+t),n=n>i?i:n,n<0&&(n+=i),i=t>n?0:n-t>>>0,t>>>=0;for(var s=Array(i);++r<i;)s[r]=e[r+t];return s}ef.exports=b0});var Or=v((pD,nf)=>{function _0(e,t){return e===t||e!==e&&t!==t}nf.exports=_0});var ua=v((hD,rf)=>{var w0=typeof global=="object"&&global&&global.Object===Object&&global;rf.exports=w0});var rt=v((dD,sf)=>{var O0=ua(),P0=typeof self=="object"&&self&&self.Object===Object&&self,E0=O0||P0||Function("return this")();sf.exports=E0});var on=v((mD,of)=>{var k0=rt(),A0=k0.Symbol;of.exports=A0});var lf=v((gD,cf)=>{var af=on(),uf=Object.prototype,x0=uf.hasOwnProperty,S0=uf.toString,Pr=af?af.toStringTag:void 0;function T0(e){var t=x0.call(e,Pr),n=e[Pr];try{e[Pr]=void 0;var r=!0}catch{}var i=S0.call(e);return r&&(t?e[Pr]=n:delete e[Pr]),i}cf.exports=T0});var pf=v((yD,ff)=>{var M0=Object.prototype,I0=M0.toString;function N0(e){return I0.call(e)}ff.exports=N0});var an=v((vD,mf)=>{var hf=on(),C0=lf(),q0=pf(),j0="[object Null]",D0="[object Undefined]",df=hf?hf.toStringTag:void 0;function R0(e){return e==null?e===void 0?D0:j0:df&&df in Object(e)?C0(e):q0(e)}mf.exports=R0});var pt=v((bD,gf)=>{function B0(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}gf.exports=B0});var ca=v((_D,yf)=>{var L0=an(),G0=pt(),F0="[object AsyncFunction]",U0="[object Function]",V0="[object GeneratorFunction]",z0="[object Proxy]";function K0(e){if(!G0(e))return!1;var t=L0(e);return t==U0||t==V0||t==F0||t==z0}yf.exports=K0});var ys=v((wD,vf)=>{var H0=9007199254740991;function W0(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=H0}vf.exports=W0});var Tn=v((OD,bf)=>{var J0=ca(),Y0=ys();function $0(e){return e!=null&&Y0(e.length)&&!J0(e)}bf.exports=$0});var Er=v((PD,_f)=>{var X0=9007199254740991,Q0=/^(?:0|[1-9]\d*)$/;function Z0(e,t){var n=typeof e;return t=t??X0,!!t&&(n=="number"||n!="symbol"&&Q0.test(e))&&e>-1&&e%1==0&&e<t}_f.exports=Z0});var Of=v((ED,wf)=>{var ew=Or(),tw=Tn(),nw=Er(),rw=pt();function iw(e,t,n){if(!rw(n))return!1;var r=typeof t;return(r=="number"?tw(n)&&nw(t,n.length):r=="string"&&t in n)?ew(n[t],e):!1}wf.exports=iw});var Ef=v((kD,Pf)=>{var sw=/\s/;function ow(e){for(var t=e.length;t--&&sw.test(e.charAt(t)););return t}Pf.exports=ow});var Af=v((AD,kf)=>{var aw=Ef(),uw=/^\s+/;function cw(e){return e&&e.slice(0,aw(e)+1).replace(uw,"")}kf.exports=cw});var kt=v((xD,xf)=>{function lw(e){return e!=null&&typeof e=="object"}xf.exports=lw});var kr=v((SD,Sf)=>{var fw=an(),pw=kt(),hw="[object Symbol]";function dw(e){return typeof e=="symbol"||pw(e)&&fw(e)==hw}Sf.exports=dw});var Nf=v((TD,If)=>{var mw=Af(),Tf=pt(),gw=kr(),Mf=NaN,yw=/^[-+]0x[0-9a-f]+$/i,vw=/^0b[01]+$/i,bw=/^0o[0-7]+$/i,_w=parseInt;function ww(e){if(typeof e=="number")return e;if(gw(e))return Mf;if(Tf(e)){var t=typeof e.valueOf=="function"?e.valueOf():e;e=Tf(t)?t+"":t}if(typeof e!="string")return e===0?e:+e;e=mw(e);var n=vw.test(e);return n||bw.test(e)?_w(e.slice(2),n?2:8):yw.test(e)?Mf:+e}If.exports=ww});var jf=v((MD,qf)=>{var Ow=Nf(),Cf=1/0,Pw=17976931348623157e292;function Ew(e){if(!e)return e===0?e:0;if(e=Ow(e),e===Cf||e===-Cf){var t=e<0?-1:1;return t*Pw}return e===e?e:0}qf.exports=Ew});var la=v((ID,Df)=>{var kw=jf();function Aw(e){var t=kw(e),n=t%1;return t===t?n?t-n:t:0}Df.exports=Aw});var Bf=v((ND,Rf)=>{var xw=tf(),Sw=Of(),Tw=la(),Mw=Math.ceil,Iw=Math.max;function Nw(e,t,n){(n?Sw(e,t,n):t===void 0)?t=1:t=Iw(Tw(t),0);var r=e==null?0:e.length;if(!r||t<1)return[];for(var i=0,s=0,o=Array(Mw(r/t));i<r;)o[s++]=xw(e,i,i+=t);return o}Rf.exports=Nw});var Ff=v((jD,Gf)=>{function Cw(){this.__data__=[],this.size=0}Gf.exports=Cw});var xr=v((DD,Uf)=>{var qw=Or();function jw(e,t){for(var n=e.length;n--;)if(qw(e[n][0],t))return n;return-1}Uf.exports=jw});var zf=v((RD,Vf)=>{var Dw=xr(),Rw=Array.prototype,Bw=Rw.splice;function Lw(e){var t=this.__data__,n=Dw(t,e);if(n<0)return!1;var r=t.length-1;return n==r?t.pop():Bw.call(t,n,1),--this.size,!0}Vf.exports=Lw});var Hf=v((BD,Kf)=>{var Gw=xr();function Fw(e){var t=this.__data__,n=Gw(t,e);return n<0?void 0:t[n][1]}Kf.exports=Fw});var Jf=v((LD,Wf)=>{var Uw=xr();function Vw(e){return Uw(this.__data__,e)>-1}Wf.exports=Vw});var $f=v((GD,Yf)=>{var zw=xr();function Kw(e,t){var n=this.__data__,r=zw(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this}Yf.exports=Kw});var Sr=v((FD,Xf)=>{var Hw=Ff(),Ww=zf(),Jw=Hf(),Yw=Jf(),$w=$f();function Mn(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}Mn.prototype.clear=Hw;Mn.prototype.delete=Ww;Mn.prototype.get=Jw;Mn.prototype.has=Yw;Mn.prototype.set=$w;Xf.exports=Mn});var Zf=v((UD,Qf)=>{var Xw=Sr();function Qw(){this.__data__=new Xw,this.size=0}Qf.exports=Qw});var tp=v((VD,ep)=>{function Zw(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n}ep.exports=Zw});var rp=v((zD,np)=>{function eO(e){return this.__data__.get(e)}np.exports=eO});var sp=v((KD,ip)=>{function tO(e){return this.__data__.has(e)}ip.exports=tO});var ap=v((HD,op)=>{var nO=rt(),rO=nO["__core-js_shared__"];op.exports=rO});var lp=v((WD,cp)=>{var fa=ap(),up=function(){var e=/[^.]+$/.exec(fa&&fa.keys&&fa.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function iO(e){return!!up&&up in e}cp.exports=iO});var pa=v((JD,fp)=>{var sO=Function.prototype,oO=sO.toString;function aO(e){if(e!=null){try{return oO.call(e)}catch{}try{return e+""}catch{}}return""}fp.exports=aO});var hp=v((YD,pp)=>{var uO=ca(),cO=lp(),lO=pt(),fO=pa(),pO=/[\\^$.*+?()[\]{}|]/g,hO=/^\[object .+?Constructor\]$/,dO=Function.prototype,mO=Object.prototype,gO=dO.toString,yO=mO.hasOwnProperty,vO=RegExp("^"+gO.call(yO).replace(pO,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function bO(e){if(!lO(e)||cO(e))return!1;var t=uO(e)?vO:hO;return t.test(fO(e))}pp.exports=bO});var mp=v(($D,dp)=>{function _O(e,t){return e?.[t]}dp.exports=_O});var Kt=v((XD,gp)=>{var wO=hp(),OO=mp();function PO(e,t){var n=OO(e,t);return wO(n)?n:void 0}gp.exports=PO});var vs=v((QD,yp)=>{var EO=Kt(),kO=rt(),AO=EO(kO,"Map");yp.exports=AO});var Tr=v((ZD,vp)=>{var xO=Kt(),SO=xO(Object,"create");vp.exports=SO});var wp=v((eR,_p)=>{var bp=Tr();function TO(){this.__data__=bp?bp(null):{},this.size=0}_p.exports=TO});var Pp=v((tR,Op)=>{function MO(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}Op.exports=MO});var kp=v((nR,Ep)=>{var IO=Tr(),NO="__lodash_hash_undefined__",CO=Object.prototype,qO=CO.hasOwnProperty;function jO(e){var t=this.__data__;if(IO){var n=t[e];return n===NO?void 0:n}return qO.call(t,e)?t[e]:void 0}Ep.exports=jO});var xp=v((rR,Ap)=>{var DO=Tr(),RO=Object.prototype,BO=RO.hasOwnProperty;function LO(e){var t=this.__data__;return DO?t[e]!==void 0:BO.call(t,e)}Ap.exports=LO});var Tp=v((iR,Sp)=>{var GO=Tr(),FO="__lodash_hash_undefined__";function UO(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=GO&&t===void 0?FO:t,this}Sp.exports=UO});var Ip=v((sR,Mp)=>{var VO=wp(),zO=Pp(),KO=kp(),HO=xp(),WO=Tp();function In(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}In.prototype.clear=VO;In.prototype.delete=zO;In.prototype.get=KO;In.prototype.has=HO;In.prototype.set=WO;Mp.exports=In});var qp=v((oR,Cp)=>{var Np=Ip(),JO=Sr(),YO=vs();function $O(){this.size=0,this.__data__={hash:new Np,map:new(YO||JO),string:new Np}}Cp.exports=$O});var Dp=v((aR,jp)=>{function XO(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}jp.exports=XO});var Mr=v((uR,Rp)=>{var QO=Dp();function ZO(e,t){var n=e.__data__;return QO(t)?n[typeof t=="string"?"string":"hash"]:n.map}Rp.exports=ZO});var Lp=v((cR,Bp)=>{var eP=Mr();function tP(e){var t=eP(this,e).delete(e);return this.size-=t?1:0,t}Bp.exports=tP});var Fp=v((lR,Gp)=>{var nP=Mr();function rP(e){return nP(this,e).get(e)}Gp.exports=rP});var Vp=v((fR,Up)=>{var iP=Mr();function sP(e){return iP(this,e).has(e)}Up.exports=sP});var Kp=v((pR,zp)=>{var oP=Mr();function aP(e,t){var n=oP(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this}zp.exports=aP});var bs=v((hR,Hp)=>{var uP=qp(),cP=Lp(),lP=Fp(),fP=Vp(),pP=Kp();function Nn(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}Nn.prototype.clear=uP;Nn.prototype.delete=cP;Nn.prototype.get=lP;Nn.prototype.has=fP;Nn.prototype.set=pP;Hp.exports=Nn});var Jp=v((dR,Wp)=>{var hP=Sr(),dP=vs(),mP=bs(),gP=200;function yP(e,t){var n=this.__data__;if(n instanceof hP){var r=n.__data__;if(!dP||r.length<gP-1)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new mP(r)}return n.set(e,t),this.size=n.size,this}Wp.exports=yP});var _s=v((mR,Yp)=>{var vP=Sr(),bP=Zf(),_P=tp(),wP=rp(),OP=sp(),PP=Jp();function Cn(e){var t=this.__data__=new vP(e);this.size=t.size}Cn.prototype.clear=bP;Cn.prototype.delete=_P;Cn.prototype.get=wP;Cn.prototype.has=OP;Cn.prototype.set=PP;Yp.exports=Cn});var Xp=v((gR,$p)=>{var EP="__lodash_hash_undefined__";function kP(e){return this.__data__.set(e,EP),this}$p.exports=kP});var Zp=v((yR,Qp)=>{function AP(e){return this.__data__.has(e)}Qp.exports=AP});var th=v((vR,eh)=>{var xP=bs(),SP=Xp(),TP=Zp();function ws(e){var t=-1,n=e==null?0:e.length;for(this.__data__=new xP;++t<n;)this.add(e[t])}ws.prototype.add=ws.prototype.push=SP;ws.prototype.has=TP;eh.exports=ws});var rh=v((bR,nh)=>{function MP(e,t){for(var n=-1,r=e==null?0:e.length;++n<r;)if(t(e[n],n,e))return!0;return!1}nh.exports=MP});var sh=v((_R,ih)=>{function IP(e,t){return e.has(t)}ih.exports=IP});var ha=v((wR,oh)=>{var NP=th(),CP=rh(),qP=sh(),jP=1,DP=2;function RP(e,t,n,r,i,s){var o=n&jP,a=e.length,u=t.length;if(a!=u&&!(o&&u>a))return!1;var c=s.get(e),l=s.get(t);if(c&&l)return c==t&&l==e;var f=-1,p=!0,h=n&DP?new NP:void 0;for(s.set(e,t),s.set(t,e);++f<a;){var d=e[f],y=t[f];if(r)var m=o?r(y,d,f,t,e,s):r(d,y,f,e,t,s);if(m!==void 0){if(m)continue;p=!1;break}if(h){if(!CP(t,function(b,g){if(!qP(h,g)&&(d===b||i(d,b,n,r,s)))return h.push(g)})){p=!1;break}}else if(!(d===y||i(d,y,n,r,s))){p=!1;break}}return s.delete(e),s.delete(t),p}oh.exports=RP});var da=v((OR,ah)=>{var BP=rt(),LP=BP.Uint8Array;ah.exports=LP});var ch=v((PR,uh)=>{function GP(e){var t=-1,n=Array(e.size);return e.forEach(function(r,i){n[++t]=[i,r]}),n}uh.exports=GP});var fh=v((ER,lh)=>{function FP(e){var t=-1,n=Array(e.size);return e.forEach(function(r){n[++t]=r}),n}lh.exports=FP});var gh=v((kR,mh)=>{var ph=on(),hh=da(),UP=Or(),VP=ha(),zP=ch(),KP=fh(),HP=1,WP=2,JP="[object Boolean]",YP="[object Date]",$P="[object Error]",XP="[object Map]",QP="[object Number]",ZP="[object RegExp]",eE="[object Set]",tE="[object String]",nE="[object Symbol]",rE="[object ArrayBuffer]",iE="[object DataView]",dh=ph?ph.prototype:void 0,ma=dh?dh.valueOf:void 0;function sE(e,t,n,r,i,s,o){switch(n){case iE:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case rE:return!(e.byteLength!=t.byteLength||!s(new hh(e),new hh(t)));case JP:case YP:case QP:return UP(+e,+t);case $P:return e.name==t.name&&e.message==t.message;case ZP:case tE:return e==t+"";case XP:var a=zP;case eE:var u=r&HP;if(a||(a=KP),e.size!=t.size&&!u)return!1;var c=o.get(e);if(c)return c==t;r|=WP,o.set(e,t);var l=VP(a(e),a(t),r,i,s,o);return o.delete(e),l;case nE:if(ma)return ma.call(e)==ma.call(t)}return!1}mh.exports=sE});var Os=v((AR,yh)=>{function oE(e,t){for(var n=-1,r=t.length,i=e.length;++n<r;)e[i+n]=t[n];return e}yh.exports=oE});var et=v((xR,vh)=>{var aE=Array.isArray;vh.exports=aE});var ga=v((SR,bh)=>{var uE=Os(),cE=et();function lE(e,t,n){var r=t(e);return cE(e)?r:uE(r,n(e))}bh.exports=lE});var ya=v((TR,_h)=>{function fE(e,t){for(var n=-1,r=e==null?0:e.length,i=0,s=[];++n<r;){var o=e[n];t(o,n,e)&&(s[i++]=o)}return s}_h.exports=fE});var va=v((MR,wh)=>{function pE(){return[]}wh.exports=pE});var Ps=v((IR,Ph)=>{var hE=ya(),dE=va(),mE=Object.prototype,gE=mE.propertyIsEnumerable,Oh=Object.getOwnPropertySymbols,yE=Oh?function(e){return e==null?[]:(e=Object(e),hE(Oh(e),function(t){return gE.call(e,t)}))}:dE;Ph.exports=yE});var kh=v((NR,Eh)=>{function vE(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}Eh.exports=vE});var xh=v((CR,Ah)=>{var bE=an(),_E=kt(),wE="[object Arguments]";function OE(e){return _E(e)&&bE(e)==wE}Ah.exports=OE});var Es=v((qR,Mh)=>{var Sh=xh(),PE=kt(),Th=Object.prototype,EE=Th.hasOwnProperty,kE=Th.propertyIsEnumerable,AE=Sh(function(){return arguments}())?Sh:function(e){return PE(e)&&EE.call(e,"callee")&&!kE.call(e,"callee")};Mh.exports=AE});var Nh=v((jR,Ih)=>{function xE(){return!1}Ih.exports=xE});var ks=v((Ir,qn)=>{var SE=rt(),TE=Nh(),jh=typeof Ir=="object"&&Ir&&!Ir.nodeType&&Ir,Ch=jh&&typeof qn=="object"&&qn&&!qn.nodeType&&qn,ME=Ch&&Ch.exports===jh,qh=ME?SE.Buffer:void 0,IE=qh?qh.isBuffer:void 0,NE=IE||TE;qn.exports=NE});var Rh=v((DR,Dh)=>{var CE=an(),qE=ys(),jE=kt(),DE="[object Arguments]",RE="[object Array]",BE="[object Boolean]",LE="[object Date]",GE="[object Error]",FE="[object Function]",UE="[object Map]",VE="[object Number]",zE="[object Object]",KE="[object RegExp]",HE="[object Set]",WE="[object String]",JE="[object WeakMap]",YE="[object ArrayBuffer]",$E="[object DataView]",XE="[object Float32Array]",QE="[object Float64Array]",ZE="[object Int8Array]",ek="[object Int16Array]",tk="[object Int32Array]",nk="[object Uint8Array]",rk="[object Uint8ClampedArray]",ik="[object Uint16Array]",sk="[object Uint32Array]",be={};be[XE]=be[QE]=be[ZE]=be[ek]=be[tk]=be[nk]=be[rk]=be[ik]=be[sk]=!0;be[DE]=be[RE]=be[YE]=be[BE]=be[$E]=be[LE]=be[GE]=be[FE]=be[UE]=be[VE]=be[zE]=be[KE]=be[HE]=be[WE]=be[JE]=!1;function ok(e){return jE(e)&&qE(e.length)&&!!be[CE(e)]}Dh.exports=ok});var As=v((RR,Bh)=>{function ak(e){return function(t){return e(t)}}Bh.exports=ak});var xs=v((Nr,jn)=>{var uk=ua(),Lh=typeof Nr=="object"&&Nr&&!Nr.nodeType&&Nr,Cr=Lh&&typeof jn=="object"&&jn&&!jn.nodeType&&jn,ck=Cr&&Cr.exports===Lh,ba=ck&&uk.process,lk=function(){try{var e=Cr&&Cr.require&&Cr.require("util").types;return e||ba&&ba.binding&&ba.binding("util")}catch{}}();jn.exports=lk});var _a=v((BR,Uh)=>{var fk=Rh(),pk=As(),Gh=xs(),Fh=Gh&&Gh.isTypedArray,hk=Fh?pk(Fh):fk;Uh.exports=hk});var wa=v((LR,Vh)=>{var dk=kh(),mk=Es(),gk=et(),yk=ks(),vk=Er(),bk=_a(),_k=Object.prototype,wk=_k.hasOwnProperty;function Ok(e,t){var n=gk(e),r=!n&&mk(e),i=!n&&!r&&yk(e),s=!n&&!r&&!i&&bk(e),o=n||r||i||s,a=o?dk(e.length,String):[],u=a.length;for(var c in e)(t||wk.call(e,c))&&!(o&&(c=="length"||i&&(c=="offset"||c=="parent")||s&&(c=="buffer"||c=="byteLength"||c=="byteOffset")||vk(c,u)))&&a.push(c);return a}Vh.exports=Ok});var Ss=v((GR,zh)=>{var Pk=Object.prototype;function Ek(e){var t=e&&e.constructor,n=typeof t=="function"&&t.prototype||Pk;return e===n}zh.exports=Ek});var Oa=v((FR,Kh)=>{function kk(e,t){return function(n){return e(t(n))}}Kh.exports=kk});var Wh=v((UR,Hh)=>{var Ak=Oa(),xk=Ak(Object.keys,Object);Hh.exports=xk});var Yh=v((VR,Jh)=>{var Sk=Ss(),Tk=Wh(),Mk=Object.prototype,Ik=Mk.hasOwnProperty;function Nk(e){if(!Sk(e))return Tk(e);var t=[];for(var n in Object(e))Ik.call(e,n)&&n!="constructor"&&t.push(n);return t}Jh.exports=Nk});var un=v((zR,$h)=>{var Ck=wa(),qk=Yh(),jk=Tn();function Dk(e){return jk(e)?Ck(e):qk(e)}$h.exports=Dk});var Pa=v((KR,Xh)=>{var Rk=ga(),Bk=Ps(),Lk=un();function Gk(e){return Rk(e,Lk,Bk)}Xh.exports=Gk});var ed=v((HR,Zh)=>{var Qh=Pa(),Fk=1,Uk=Object.prototype,Vk=Uk.hasOwnProperty;function zk(e,t,n,r,i,s){var o=n&Fk,a=Qh(e),u=a.length,c=Qh(t),l=c.length;if(u!=l&&!o)return!1;for(var f=u;f--;){var p=a[f];if(!(o?p in t:Vk.call(t,p)))return!1}var h=s.get(e),d=s.get(t);if(h&&d)return h==t&&d==e;var y=!0;s.set(e,t),s.set(t,e);for(var m=o;++f<u;){p=a[f];var b=e[p],g=t[p];if(r)var O=o?r(g,b,p,t,e,s):r(b,g,p,e,t,s);if(!(O===void 0?b===g||i(b,g,n,r,s):O)){y=!1;break}m||(m=p=="constructor")}if(y&&!m){var I=e.constructor,j=t.constructor;I!=j&&"constructor"in e&&"constructor"in t&&!(typeof I=="function"&&I instanceof I&&typeof j=="function"&&j instanceof j)&&(y=!1)}return s.delete(e),s.delete(t),y}Zh.exports=zk});var nd=v((WR,td)=>{var Kk=Kt(),Hk=rt(),Wk=Kk(Hk,"DataView");td.exports=Wk});var id=v((JR,rd)=>{var Jk=Kt(),Yk=rt(),$k=Jk(Yk,"Promise");rd.exports=$k});var od=v((YR,sd)=>{var Xk=Kt(),Qk=rt(),Zk=Xk(Qk,"Set");sd.exports=Zk});var ud=v(($R,ad)=>{var eA=Kt(),tA=rt(),nA=eA(tA,"WeakMap");ad.exports=nA});var qr=v((XR,md)=>{var Ea=nd(),ka=vs(),Aa=id(),xa=od(),Sa=ud(),dd=an(),Dn=pa(),cd="[object Map]",rA="[object Object]",ld="[object Promise]",fd="[object Set]",pd="[object WeakMap]",hd="[object DataView]",iA=Dn(Ea),sA=Dn(ka),oA=Dn(Aa),aA=Dn(xa),uA=Dn(Sa),cn=dd;(Ea&&cn(new Ea(new ArrayBuffer(1)))!=hd||ka&&cn(new ka)!=cd||Aa&&cn(Aa.resolve())!=ld||xa&&cn(new xa)!=fd||Sa&&cn(new Sa)!=pd)&&(cn=function(e){var t=dd(e),n=t==rA?e.constructor:void 0,r=n?Dn(n):"";if(r)switch(r){case iA:return hd;case sA:return cd;case oA:return ld;case aA:return fd;case uA:return pd}return t});md.exports=cn});var Pd=v((QR,Od)=>{var Ta=_s(),cA=ha(),lA=gh(),fA=ed(),gd=qr(),yd=et(),vd=ks(),pA=_a(),hA=1,bd="[object Arguments]",_d="[object Array]",Ts="[object Object]",dA=Object.prototype,wd=dA.hasOwnProperty;function mA(e,t,n,r,i,s){var o=yd(e),a=yd(t),u=o?_d:gd(e),c=a?_d:gd(t);u=u==bd?Ts:u,c=c==bd?Ts:c;var l=u==Ts,f=c==Ts,p=u==c;if(p&&vd(e)){if(!vd(t))return!1;o=!0,l=!1}if(p&&!l)return s||(s=new Ta),o||pA(e)?cA(e,t,n,r,i,s):lA(e,t,u,n,r,i,s);if(!(n&hA)){var h=l&&wd.call(e,"__wrapped__"),d=f&&wd.call(t,"__wrapped__");if(h||d){var y=h?e.value():e,m=d?t.value():t;return s||(s=new Ta),i(y,m,n,r,s)}}return p?(s||(s=new Ta),fA(e,t,n,r,i,s)):!1}Od.exports=mA});var Ma=v((ZR,Ad)=>{var gA=Pd(),Ed=kt();function kd(e,t,n,r,i){return e===t?!0:e==null||t==null||!Ed(e)&&!Ed(t)?e!==e&&t!==t:gA(e,t,n,r,kd,i)}Ad.exports=kd});var Sd=v((e4,xd)=>{var yA=_s(),vA=Ma(),bA=1,_A=2;function wA(e,t,n,r){var i=n.length,s=i,o=!r;if(e==null)return!s;for(e=Object(e);i--;){var a=n[i];if(o&&a[2]?a[1]!==e[a[0]]:!(a[0]in e))return!1}for(;++i<s;){a=n[i];var u=a[0],c=e[u],l=a[1];if(o&&a[2]){if(c===void 0&&!(u in e))return!1}else{var f=new yA;if(r)var p=r(c,l,u,e,t,f);if(!(p===void 0?vA(l,c,bA|_A,r,f):p))return!1}}return!0}xd.exports=wA});var Ia=v((t4,Td)=>{var OA=pt();function PA(e){return e===e&&!OA(e)}Td.exports=PA});var Id=v((n4,Md)=>{var EA=Ia(),kA=un();function AA(e){for(var t=kA(e),n=t.length;n--;){var r=t[n],i=e[r];t[n]=[r,i,EA(i)]}return t}Md.exports=AA});var Na=v((r4,Nd)=>{function xA(e,t){return function(n){return n==null?!1:n[e]===t&&(t!==void 0||e in Object(n))}}Nd.exports=xA});var Ca=v((i4,Cd)=>{var SA=Sd(),TA=Id(),MA=Na();function IA(e){var t=TA(e);return t.length==1&&t[0][2]?MA(t[0][0],t[0][1]):function(n){return n===e||SA(n,e,t)}}Cd.exports=IA});var Ms=v((s4,qd)=>{var NA=et(),CA=kr(),qA=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,jA=/^\w*$/;function DA(e,t){if(NA(e))return!1;var n=typeof e;return n=="number"||n=="symbol"||n=="boolean"||e==null||CA(e)?!0:jA.test(e)||!qA.test(e)||t!=null&&e in Object(t)}qd.exports=DA});var Rd=v((o4,Dd)=>{var jd=bs(),RA="Expected a function";function qa(e,t){if(typeof e!="function"||t!=null&&typeof t!="function")throw new TypeError(RA);var n=function(){var r=arguments,i=t?t.apply(this,r):r[0],s=n.cache;if(s.has(i))return s.get(i);var o=e.apply(this,r);return n.cache=s.set(i,o)||s,o};return n.cache=new(qa.Cache||jd),n}qa.Cache=jd;Dd.exports=qa});var Ld=v((a4,Bd)=>{var BA=Rd(),LA=500;function GA(e){var t=BA(e,function(r){return n.size===LA&&n.clear(),r}),n=t.cache;return t}Bd.exports=GA});var Fd=v((u4,Gd)=>{var FA=Ld(),UA=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,VA=/\\(\\)?/g,zA=FA(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(""),e.replace(UA,function(n,r,i,s){t.push(i?s.replace(VA,"$1"):r||n)}),t});Gd.exports=zA});var Vd=v((c4,Ud)=>{function KA(e,t){for(var n=-1,r=e==null?0:e.length,i=Array(r);++n<r;)i[n]=t(e[n],n,e);return i}Ud.exports=KA});var Yd=v((l4,Jd)=>{var zd=on(),HA=Vd(),WA=et(),JA=kr(),YA=1/0,Kd=zd?zd.prototype:void 0,Hd=Kd?Kd.toString:void 0;function Wd(e){if(typeof e=="string")return e;if(WA(e))return HA(e,Wd)+"";if(JA(e))return Hd?Hd.call(e):"";var t=e+"";return t=="0"&&1/e==-YA?"-0":t}Jd.exports=Wd});var Xd=v((f4,$d)=>{var $A=Yd();function XA(e){return e==null?"":$A(e)}$d.exports=XA});var jr=v((p4,Qd)=>{var QA=et(),ZA=Ms(),ex=Fd(),tx=Xd();function nx(e,t){return QA(e)?e:ZA(e,t)?[e]:ex(tx(e))}Qd.exports=nx});var Rn=v((h4,Zd)=>{var rx=kr(),ix=1/0;function sx(e){if(typeof e=="string"||rx(e))return e;var t=e+"";return t=="0"&&1/e==-ix?"-0":t}Zd.exports=sx});var Is=v((d4,em)=>{var ox=jr(),ax=Rn();function ux(e,t){t=ox(t,e);for(var n=0,r=t.length;e!=null&&n<r;)e=e[ax(t[n++])];return n&&n==r?e:void 0}em.exports=ux});var nm=v((m4,tm)=>{var cx=Is();function lx(e,t,n){var r=e==null?void 0:cx(e,t);return r===void 0?n:r}tm.exports=lx});var im=v((g4,rm)=>{function fx(e,t){return e!=null&&t in Object(e)}rm.exports=fx});var om=v((y4,sm)=>{var px=jr(),hx=Es(),dx=et(),mx=Er(),gx=ys(),yx=Rn();function vx(e,t,n){t=px(t,e);for(var r=-1,i=t.length,s=!1;++r<i;){var o=yx(t[r]);if(!(s=e!=null&&n(e,o)))break;e=e[o]}return s||++r!=i?s:(i=e==null?0:e.length,!!i&&gx(i)&&mx(o,i)&&(dx(e)||hx(e)))}sm.exports=vx});var ja=v((v4,am)=>{var bx=im(),_x=om();function wx(e,t){return e!=null&&_x(e,t,bx)}am.exports=wx});var cm=v((b4,um)=>{var Ox=Ma(),Px=nm(),Ex=ja(),kx=Ms(),Ax=Ia(),xx=Na(),Sx=Rn(),Tx=1,Mx=2;function Ix(e,t){return kx(e)&&Ax(t)?xx(Sx(e),t):function(n){var r=Px(n,e);return r===void 0&&r===t?Ex(n,e):Ox(t,r,Tx|Mx)}}um.exports=Ix});var Da=v((_4,lm)=>{function Nx(e){return e}lm.exports=Nx});var pm=v((w4,fm)=>{function Cx(e){return function(t){return t?.[e]}}fm.exports=Cx});var dm=v((O4,hm)=>{var qx=Is();function jx(e){return function(t){return qx(t,e)}}hm.exports=jx});var gm=v((P4,mm)=>{var Dx=pm(),Rx=dm(),Bx=Ms(),Lx=Rn();function Gx(e){return Bx(e)?Dx(Lx(e)):Rx(e)}mm.exports=Gx});var Ns=v((E4,ym)=>{var Fx=Ca(),Ux=cm(),Vx=Da(),zx=et(),Kx=gm();function Hx(e){return typeof e=="function"?e:e==null?Vx:typeof e=="object"?zx(e)?Ux(e[0],e[1]):Fx(e):Kx(e)}ym.exports=Hx});var bm=v((k4,vm)=>{var Wx=Ns(),Jx=Tn(),Yx=un();function $x(e){return function(t,n,r){var i=Object(t);if(!Jx(t)){var s=Wx(n,3);t=Yx(t),n=function(a){return s(i[a],a,i)}}var o=e(t,n,r);return o>-1?i[s?t[o]:o]:void 0}}vm.exports=$x});var wm=v((A4,_m)=>{function Xx(e,t,n,r){for(var i=e.length,s=n+(r?1:-1);r?s--:++s<i;)if(t(e[s],s,e))return s;return-1}_m.exports=Xx});var Pm=v((x4,Om)=>{var Qx=wm(),Zx=Ns(),eS=la(),tS=Math.max;function nS(e,t,n){var r=e==null?0:e.length;if(!r)return-1;var i=n==null?0:eS(n);return i<0&&(i=tS(r+i,0)),Qx(e,Zx(t,3),i)}Om.exports=nS});var Ra=v((S4,Em)=>{var rS=bm(),iS=Pm(),sS=rS(iS);Em.exports=sS});var Am=v((T4,km)=>{function oS(e){return function(t,n,r){for(var i=-1,s=Object(t),o=r(t),a=o.length;a--;){var u=o[e?a:++i];if(n(s[u],u,s)===!1)break}return t}}km.exports=oS});var Sm=v((M4,xm)=>{var aS=Am(),uS=aS();xm.exports=uS});var Mm=v((I4,Tm)=>{var cS=Sm(),lS=un();function fS(e,t){return e&&cS(e,t,lS)}Tm.exports=fS});var Nm=v((N4,Im)=>{var pS=Tn();function hS(e,t){return function(n,r){if(n==null)return n;if(!pS(n))return e(n,r);for(var i=n.length,s=t?i:-1,o=Object(n);(t?s--:++s<i)&&r(o[s],s,o)!==!1;);return n}}Im.exports=hS});var qm=v((C4,Cm)=>{var dS=Mm(),mS=Nm(),gS=mS(dS);Cm.exports=gS});var Dm=v((q4,jm)=>{var yS=qm();function vS(e,t){var n=[];return yS(e,function(r,i,s){t(r,i,s)&&n.push(r)}),n}jm.exports=vS});var Bm=v((j4,Rm)=>{var bS=ya(),_S=Dm(),wS=Ns(),OS=et();function PS(e,t){var n=OS(e)?bS:_S;return n(e,wS(t,3))}Rm.exports=PS});var Cs=v((D4,Lm)=>{var ES=Oa(),kS=ES(Object.getPrototypeOf,Object);Lm.exports=kS});var qs=v((R4,Fm)=>{var AS=an(),xS=Cs(),SS=kt(),TS="[object Object]",MS=Function.prototype,IS=Object.prototype,Gm=MS.toString,NS=IS.hasOwnProperty,CS=Gm.call(Object);function qS(e){if(!SS(e)||AS(e)!=TS)return!1;var t=xS(e);if(t===null)return!0;var n=NS.call(t,"constructor")&&t.constructor;return typeof n=="function"&&n instanceof n&&Gm.call(n)==CS}Fm.exports=qS});var Ba=v((B4,Um)=>{var jS=Kt(),DS=function(){try{var e=jS(Object,"defineProperty");return e({},"",{}),e}catch{}}();Um.exports=DS});var La=v((L4,zm)=>{var Vm=Ba();function RS(e,t,n){t=="__proto__"&&Vm?Vm(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[t]=n}zm.exports=RS});var js=v((G4,Km)=>{var BS=La(),LS=Or(),GS=Object.prototype,FS=GS.hasOwnProperty;function US(e,t,n){var r=e[t];(!(FS.call(e,t)&&LS(r,n))||n===void 0&&!(t in e))&&BS(e,t,n)}Km.exports=US});var Jm=v((F4,Wm)=>{var VS=js(),zS=jr(),KS=Er(),Hm=pt(),HS=Rn();function WS(e,t,n,r){if(!Hm(e))return e;t=zS(t,e);for(var i=-1,s=t.length,o=s-1,a=e;a!=null&&++i<s;){var u=HS(t[i]),c=n;if(u==="__proto__"||u==="constructor"||u==="prototype")return e;if(i!=o){var l=a[u];c=r?r(l,u,a):void 0,c===void 0&&(c=Hm(l)?l:KS(t[i+1])?[]:{})}VS(a,u,c),a=a[u]}return e}Wm.exports=WS});var $m=v((U4,Ym)=>{var JS=Is(),YS=Jm(),$S=jr();function XS(e,t,n){for(var r=-1,i=t.length,s={};++r<i;){var o=t[r],a=JS(e,o);n(a,o)&&YS(s,$S(o,e),a)}return s}Ym.exports=XS});var Qm=v((V4,Xm)=>{var QS=$m(),ZS=ja();function eT(e,t){return QS(e,t,function(n,r){return ZS(e,r)})}Xm.exports=eT});var ng=v((z4,tg)=>{var Zm=on(),tT=Es(),nT=et(),eg=Zm?Zm.isConcatSpreadable:void 0;function rT(e){return nT(e)||tT(e)||!!(eg&&e&&e[eg])}tg.exports=rT});var sg=v((K4,ig)=>{var iT=Os(),sT=ng();function rg(e,t,n,r,i){var s=-1,o=e.length;for(n||(n=sT),i||(i=[]);++s<o;){var a=e[s];t>0&&n(a)?t>1?rg(a,t-1,n,r,i):iT(i,a):r||(i[i.length]=a)}return i}ig.exports=rg});var ag=v((H4,og)=>{var oT=sg();function aT(e){var t=e==null?0:e.length;return t?oT(e,1):[]}og.exports=aT});var cg=v((W4,ug)=>{function uT(e,t,n){switch(n.length){case 0:return e.call(t);case 1:return e.call(t,n[0]);case 2:return e.call(t,n[0],n[1]);case 3:return e.call(t,n[0],n[1],n[2])}return e.apply(t,n)}ug.exports=uT});var pg=v((J4,fg)=>{var cT=cg(),lg=Math.max;function lT(e,t,n){return t=lg(t===void 0?e.length-1:t,0),function(){for(var r=arguments,i=-1,s=lg(r.length-t,0),o=Array(s);++i<s;)o[i]=r[t+i];i=-1;for(var a=Array(t+1);++i<t;)a[i]=r[i];return a[t]=n(o),cT(e,this,a)}}fg.exports=lT});var dg=v((Y4,hg)=>{function fT(e){return function(){return e}}hg.exports=fT});var yg=v(($4,gg)=>{var pT=dg(),mg=Ba(),hT=Da(),dT=mg?function(e,t){return mg(e,"toString",{configurable:!0,enumerable:!1,value:pT(t),writable:!0})}:hT;gg.exports=dT});var bg=v((X4,vg)=>{var mT=800,gT=16,yT=Date.now;function vT(e){var t=0,n=0;return function(){var r=yT(),i=gT-(r-n);if(n=r,i>0){if(++t>=mT)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}vg.exports=vT});var wg=v((Q4,_g)=>{var bT=yg(),_T=bg(),wT=_T(bT);_g.exports=wT});var Pg=v((Z4,Og)=>{var OT=ag(),PT=pg(),ET=wg();function kT(e){return ET(PT(e,void 0,OT),e+"")}Og.exports=kT});var Ga=v((e5,Eg)=>{var AT=Qm(),xT=Pg(),ST=xT(function(e,t){return e==null?{}:AT(e,t)});Eg.exports=ST});var Vg=v((h5,Ug)=>{function xM(e,t){for(var n=-1,r=e==null?0:e.length;++n<r&&t(e[n],n,e)!==!1;);return e}Ug.exports=xM});var Lr=v((d5,zg)=>{var SM=js(),TM=La();function MM(e,t,n,r){var i=!n;n||(n={});for(var s=-1,o=t.length;++s<o;){var a=t[s],u=r?r(n[a],e[a],a,n,e):void 0;u===void 0&&(u=e[a]),i?TM(n,a,u):SM(n,a,u)}return n}zg.exports=MM});var Hg=v((m5,Kg)=>{var IM=Lr(),NM=un();function CM(e,t){return e&&IM(t,NM(t),e)}Kg.exports=CM});var Jg=v((g5,Wg)=>{function qM(e){var t=[];if(e!=null)for(var n in Object(e))t.push(n);return t}Wg.exports=qM});var $g=v((y5,Yg)=>{var jM=pt(),DM=Ss(),RM=Jg(),BM=Object.prototype,LM=BM.hasOwnProperty;function GM(e){if(!jM(e))return RM(e);var t=DM(e),n=[];for(var r in e)r=="constructor"&&(t||!LM.call(e,r))||n.push(r);return n}Yg.exports=GM});var Fs=v((v5,Xg)=>{var FM=wa(),UM=$g(),VM=Tn();function zM(e){return VM(e)?FM(e,!0):UM(e)}Xg.exports=zM});var Zg=v((b5,Qg)=>{var KM=Lr(),HM=Fs();function WM(e,t){return e&&KM(t,HM(t),e)}Qg.exports=WM});var iy=v((Gr,Kn)=>{var JM=rt(),ry=typeof Gr=="object"&&Gr&&!Gr.nodeType&&Gr,ey=ry&&typeof Kn=="object"&&Kn&&!Kn.nodeType&&Kn,YM=ey&&ey.exports===ry,ty=YM?JM.Buffer:void 0,ny=ty?ty.allocUnsafe:void 0;function $M(e,t){if(t)return e.slice();var n=e.length,r=ny?ny(n):new e.constructor(n);return e.copy(r),r}Kn.exports=$M});var oy=v((_5,sy)=>{function XM(e,t){var n=-1,r=e.length;for(t||(t=Array(r));++n<r;)t[n]=e[n];return t}sy.exports=XM});var uy=v((w5,ay)=>{var QM=Lr(),ZM=Ps();function eI(e,t){return QM(e,ZM(e),t)}ay.exports=eI});var $a=v((O5,cy)=>{var tI=Os(),nI=Cs(),rI=Ps(),iI=va(),sI=Object.getOwnPropertySymbols,oI=sI?function(e){for(var t=[];e;)tI(t,rI(e)),e=nI(e);return t}:iI;cy.exports=oI});var fy=v((P5,ly)=>{var aI=Lr(),uI=$a();function cI(e,t){return aI(e,uI(e),t)}ly.exports=cI});var hy=v((E5,py)=>{var lI=ga(),fI=$a(),pI=Fs();function hI(e){return lI(e,pI,fI)}py.exports=hI});var my=v((k5,dy)=>{var dI=Object.prototype,mI=dI.hasOwnProperty;function gI(e){var t=e.length,n=new e.constructor(t);return t&&typeof e[0]=="string"&&mI.call(e,"index")&&(n.index=e.index,n.input=e.input),n}dy.exports=gI});var Us=v((A5,yy)=>{var gy=da();function yI(e){var t=new e.constructor(e.byteLength);return new gy(t).set(new gy(e)),t}yy.exports=yI});var by=v((x5,vy)=>{var vI=Us();function bI(e,t){var n=t?vI(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.byteLength)}vy.exports=bI});var wy=v((S5,_y)=>{var _I=/\w*$/;function wI(e){var t=new e.constructor(e.source,_I.exec(e));return t.lastIndex=e.lastIndex,t}_y.exports=wI});var Ay=v((T5,ky)=>{var Oy=on(),Py=Oy?Oy.prototype:void 0,Ey=Py?Py.valueOf:void 0;function OI(e){return Ey?Object(Ey.call(e)):{}}ky.exports=OI});var Sy=v((M5,xy)=>{var PI=Us();function EI(e,t){var n=t?PI(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}xy.exports=EI});var My=v((I5,Ty)=>{var kI=Us(),AI=by(),xI=wy(),SI=Ay(),TI=Sy(),MI="[object Boolean]",II="[object Date]",NI="[object Map]",CI="[object Number]",qI="[object RegExp]",jI="[object Set]",DI="[object String]",RI="[object Symbol]",BI="[object ArrayBuffer]",LI="[object DataView]",GI="[object Float32Array]",FI="[object Float64Array]",UI="[object Int8Array]",VI="[object Int16Array]",zI="[object Int32Array]",KI="[object Uint8Array]",HI="[object Uint8ClampedArray]",WI="[object Uint16Array]",JI="[object Uint32Array]";function YI(e,t,n){var r=e.constructor;switch(t){case BI:return kI(e);case MI:case II:return new r(+e);case LI:return AI(e,n);case GI:case FI:case UI:case VI:case zI:case KI:case HI:case WI:case JI:return TI(e,n);case NI:return new r;case CI:case DI:return new r(e);case qI:return xI(e);case jI:return new r;case RI:return SI(e)}}Ty.exports=YI});var Cy=v((N5,Ny)=>{var $I=pt(),Iy=Object.create,XI=function(){function e(){}return function(t){if(!$I(t))return{};if(Iy)return Iy(t);e.prototype=t;var n=new e;return e.prototype=void 0,n}}();Ny.exports=XI});var jy=v((C5,qy)=>{var QI=Cy(),ZI=Cs(),eN=Ss();function tN(e){return typeof e.constructor=="function"&&!eN(e)?QI(ZI(e)):{}}qy.exports=tN});var Ry=v((q5,Dy)=>{var nN=qr(),rN=kt(),iN="[object Map]";function sN(e){return rN(e)&&nN(e)==iN}Dy.exports=sN});var Fy=v((j5,Gy)=>{var oN=Ry(),aN=As(),By=xs(),Ly=By&&By.isMap,uN=Ly?aN(Ly):oN;Gy.exports=uN});var Vy=v((D5,Uy)=>{var cN=qr(),lN=kt(),fN="[object Set]";function pN(e){return lN(e)&&cN(e)==fN}Uy.exports=pN});var Wy=v((R5,Hy)=>{var hN=Vy(),dN=As(),zy=xs(),Ky=zy&&zy.isSet,mN=Ky?dN(Ky):hN;Hy.exports=mN});var Xa=v((B5,Xy)=>{var gN=_s(),yN=Vg(),vN=js(),bN=Hg(),_N=Zg(),wN=iy(),ON=oy(),PN=uy(),EN=fy(),kN=Pa(),AN=hy(),xN=qr(),SN=my(),TN=My(),MN=jy(),IN=et(),NN=ks(),CN=Fy(),qN=pt(),jN=Wy(),DN=un(),RN=Fs(),BN=1,LN=2,GN=4,Jy="[object Arguments]",FN="[object Array]",UN="[object Boolean]",VN="[object Date]",zN="[object Error]",Yy="[object Function]",KN="[object GeneratorFunction]",HN="[object Map]",WN="[object Number]",$y="[object Object]",JN="[object RegExp]",YN="[object Set]",$N="[object String]",XN="[object Symbol]",QN="[object WeakMap]",ZN="[object ArrayBuffer]",e2="[object DataView]",t2="[object Float32Array]",n2="[object Float64Array]",r2="[object Int8Array]",i2="[object Int16Array]",s2="[object Int32Array]",o2="[object Uint8Array]",a2="[object Uint8ClampedArray]",u2="[object Uint16Array]",c2="[object Uint32Array]",ge={};ge[Jy]=ge[FN]=ge[ZN]=ge[e2]=ge[UN]=ge[VN]=ge[t2]=ge[n2]=ge[r2]=ge[i2]=ge[s2]=ge[HN]=ge[WN]=ge[$y]=ge[JN]=ge[YN]=ge[$N]=ge[XN]=ge[o2]=ge[a2]=ge[u2]=ge[c2]=!0;ge[zN]=ge[Yy]=ge[QN]=!1;function Vs(e,t,n,r,i,s){var o,a=t&BN,u=t&LN,c=t&GN;if(n&&(o=i?n(e,r,i,s):n(e)),o!==void 0)return o;if(!qN(e))return e;var l=IN(e);if(l){if(o=SN(e),!a)return ON(e,o)}else{var f=xN(e),p=f==Yy||f==KN;if(NN(e))return wN(e,a);if(f==$y||f==Jy||p&&!i){if(o=u||p?{}:MN(e),!a)return u?EN(e,_N(o,e)):PN(e,bN(o,e))}else{if(!ge[f])return i?e:{};o=TN(e,f,a)}}s||(s=new gN);var h=s.get(e);if(h)return h;s.set(e,o),jN(e)?e.forEach(function(m){o.add(Vs(m,t,n,m,e,s))}):CN(e)&&e.forEach(function(m,b){o.set(b,Vs(m,t,n,b,e,s))});var d=c?u?AN:kN:u?RN:DN,y=l?void 0:d(e);return yN(y||e,function(m,b){y&&(b=m,m=e[b]),vN(o,b,Vs(m,t,n,b,e,s))}),o}Xy.exports=Vs});var Fr=v((L5,Qy)=>{var l2=Xa(),f2=Ca(),p2=1;function h2(e){return f2(l2(e,p2))}Qy.exports=h2});var fv=v((y6,lv)=>{var A2=Xa(),x2=1,S2=4;function T2(e){return A2(e,x2|S2)}lv.exports=T2});var Uu=v(Jt=>{"use strict";Object.defineProperty(Jt,"__esModule",{value:!0});Jt.Pointer=Jt.escapeToken=Jt.unescapeToken=void 0;function zv(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}Jt.unescapeToken=zv;function Kv(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}Jt.escapeToken=Kv;var fC=function(){function e(t){t===void 0&&(t=[""]),this.tokens=t}return e.fromJSON=function(t){var n=t.split("/").map(zv);if(n[0]!=="")throw new Error("Invalid JSON Pointer: ".concat(t));return new e(n)},e.prototype.toString=function(){return this.tokens.map(Kv).join("/")},e.prototype.evaluate=function(t){for(var n=null,r="",i=t,s=1,o=this.tokens.length;s<o;s++)n=i,r=this.tokens[s],!(r=="__proto__"||r=="constructor"||r=="prototype")&&(i=(n||{})[r]);return{parent:n,key:r,value:i}},e.prototype.get=function(t){return this.evaluate(t).value},e.prototype.set=function(t,n){var r=this.evaluate(t);r.parent&&(r.parent[r.key]=n)},e.prototype.push=function(t){this.tokens.push(t)},e.prototype.add=function(t){var n=this.tokens.concat(String(t));return new e(n)},e}();Jt.Pointer=fC});var zu=v(Ct=>{"use strict";Object.defineProperty(Ct,"__esModule",{value:!0});Ct.clone=Ct.objectType=Ct.hasOwnProperty=void 0;Ct.hasOwnProperty=Object.prototype.hasOwnProperty;function pC(e){return e===void 0?"undefined":e===null?"null":Array.isArray(e)?"array":typeof e}Ct.objectType=pC;function hC(e){return e!=null&&typeof e=="object"}function Vu(e){if(!hC(e))return e;if(e.constructor==Array){for(var t=e.length,n=new Array(t),r=0;r<t;r++)n[r]=Vu(e[r]);return n}if(e.constructor==Date){var i=new Date(+e);return i}var s={};for(var o in e)Ct.hasOwnProperty.call(e,o)&&(s[o]=Vu(e[o]));return s}Ct.clone=Vu});var Wu=v(Ke=>{"use strict";Object.defineProperty(Ke,"__esModule",{value:!0});Ke.diffAny=Ke.diffObjects=Ke.diffArrays=Ke.intersection=Ke.subtract=Ke.isDestructive=void 0;var Ci=zu();function dC(e){var t=e.op;return t==="remove"||t==="replace"||t==="copy"||t==="move"}Ke.isDestructive=dC;function Hu(e,t){var n={};for(var r in e)Ci.hasOwnProperty.call(e,r)&&e[r]!==void 0&&(n[r]=1);for(var i in t)Ci.hasOwnProperty.call(t,i)&&t[i]!==void 0&&delete n[i];return Object.keys(n)}Ke.subtract=Hu;function Hv(e){for(var t=e.length,n={},r=0;r<t;r++){var i=e[r];for(var s in i)Ci.hasOwnProperty.call(i,s)&&i[s]!==void 0&&(n[s]=(n[s]||0)+1)}for(var s in n)n[s]<t&&delete n[s];return Object.keys(n)}Ke.intersection=Hv;function mC(e){return e.op==="add"}function gC(e){return e.op==="remove"}function Ku(e,t){return{operations:e.operations.concat(t),cost:e.cost+1}}function Wv(e,t,n,r){r===void 0&&(r=no);var i={"0,0":{operations:[],cost:0}};function s(l,f){var p="".concat(l,",").concat(f),h=i[p];if(h===void 0){if(l>0&&f>0&&!r(e[l-1],t[f-1],n.add(String(l-1))).length)h=s(l-1,f-1);else{var d=[];if(l>0){var y=s(l-1,f),m={op:"remove",index:l-1};d.push(Ku(y,m))}if(f>0){var b=s(l,f-1),g={op:"add",index:l-1,value:t[f-1]};d.push(Ku(b,g))}if(l>0&&f>0){var O=s(l-1,f-1),I={op:"replace",index:l-1,original:e[l-1],value:t[f-1]};d.push(Ku(O,I))}var j=d.sort(function(N,D){return N.cost-D.cost})[0];h=j}i[p]=h}return h}var o=isNaN(e.length)||e.length<=0?0:e.length,a=isNaN(t.length)||t.length<=0?0:t.length,u=s(o,a).operations,c=u.reduce(function(l,f){var p=l[0],h=l[1];if(mC(f)){var d=f.index+1+h,y=d<o+h?String(d):"-",m={op:f.op,path:n.add(y).toString(),value:f.value};return[p.concat(m),h+1]}else if(gC(f)){var m={op:f.op,path:n.add(String(f.index+h)).toString()};return[p.concat(m),h-1]}else{var b=n.add(String(f.index+h)),g=r(f.original,f.value,b);return[p.concat.apply(p,g),h]}},[[],0])[0];return c}Ke.diffArrays=Wv;function Jv(e,t,n,r){r===void 0&&(r=no);var i=[];return Hu(e,t).forEach(function(s){i.push({op:"remove",path:n.add(s).toString()})}),Hu(t,e).forEach(function(s){i.push({op:"add",path:n.add(s).toString(),value:t[s]})}),Hv([e,t]).forEach(function(s){i.push.apply(i,r(e[s],t[s],n.add(s)))}),i}Ke.diffObjects=Jv;function no(e,t,n,r){if(r===void 0&&(r=no),e===t)return[];var i=(0,Ci.objectType)(e),s=(0,Ci.objectType)(t);return i=="array"&&s=="array"?Wv(e,t,n,r):i=="object"&&s=="object"?Jv(e,t,n,r):[{op:"replace",path:n.toString(),value:t}]}Ke.diffAny=no});var ib=v(Ae=>{"use strict";var Ju=Ae&&Ae.__extends||function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var s in i)Object.prototype.hasOwnProperty.call(i,s)&&(r[s]=i[s])},e(t,n)};return function(t,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}();Object.defineProperty(Ae,"__esModule",{value:!0});Ae.apply=Ae.InvalidOperationError=Ae.test=Ae.copy=Ae.move=Ae.replace=Ae.remove=Ae.add=Ae.TestError=Ae.MissingError=void 0;var qt=Uu(),Yu=zu(),yC=Wu(),mt=function(e){Ju(t,e);function t(n){var r=e.call(this,"Value required at path: ".concat(n))||this;return r.path=n,r.name="MissingError",r}return t}(Error);Ae.MissingError=mt;var Yv=function(e){Ju(t,e);function t(n,r){var i=e.call(this,"Test failed: ".concat(n," != ").concat(r))||this;return i.actual=n,i.expected=r,i.name="TestError",i}return t}(Error);Ae.TestError=Yv;function $u(e,t,n){if(Array.isArray(e))if(t=="-")e.push(n);else{var r=parseInt(t,10);e.splice(r,0,n)}else e[t]=n}function $v(e,t){if(Array.isArray(e)){var n=parseInt(t,10);e.splice(n,1)}else delete e[t]}function Xv(e,t){var n=qt.Pointer.fromJSON(t.path).evaluate(e);return n.parent===void 0?new mt(t.path):($u(n.parent,n.key,(0,Yu.clone)(t.value)),null)}Ae.add=Xv;function Qv(e,t){var n=qt.Pointer.fromJSON(t.path).evaluate(e);return n.value===void 0?new mt(t.path):($v(n.parent,n.key),null)}Ae.remove=Qv;function Zv(e,t){var n=qt.Pointer.fromJSON(t.path).evaluate(e);if(n.parent===null)return new mt(t.path);if(Array.isArray(n.parent)){if(parseInt(n.key,10)>=n.parent.length)return new mt(t.path)}else if(n.value===void 0)return new mt(t.path);return n.parent[n.key]=(0,Yu.clone)(t.value),null}Ae.replace=Zv;function eb(e,t){var n=qt.Pointer.fromJSON(t.from).evaluate(e);if(n.value===void 0)return new mt(t.from);var r=qt.Pointer.fromJSON(t.path).evaluate(e);return r.parent===void 0?new mt(t.path):($v(n.parent,n.key),$u(r.parent,r.key,n.value),null)}Ae.move=eb;function tb(e,t){var n=qt.Pointer.fromJSON(t.from).evaluate(e);if(n.value===void 0)return new mt(t.from);var r=qt.Pointer.fromJSON(t.path).evaluate(e);return r.parent===void 0?new mt(t.path):($u(r.parent,r.key,(0,Yu.clone)(n.value)),null)}Ae.copy=tb;function nb(e,t){var n=qt.Pointer.fromJSON(t.path).evaluate(e);return(0,yC.diffAny)(n.value,t.value,new qt.Pointer).length?new Yv(n.value,t.value):null}Ae.test=nb;var rb=function(e){Ju(t,e);function t(n){var r=e.call(this,"Invalid operation: ".concat(n.op))||this;return r.operation=n,r.name="InvalidOperationError",r}return t}(Error);Ae.InvalidOperationError=rb;function vC(e,t){switch(t.op){case"add":return Xv(e,t);case"remove":return Qv(e,t);case"replace":return Zv(e,t);case"move":return eb(e,t);case"copy":return tb(e,t);case"test":return nb(e,t)}return new rb(t)}Ae.apply=vC});var qi=v(gt=>{"use strict";Object.defineProperty(gt,"__esModule",{value:!0});gt.createTests=gt.createPatch=gt.applyPatch=gt.Pointer=void 0;var Xu=Uu();Object.defineProperty(gt,"Pointer",{enumerable:!0,get:function(){return Xu.Pointer}});var bC=ib(),Qu=Wu();function _C(e,t){return t.map(function(n){return(0,bC.apply)(e,n)})}gt.applyPatch=_C;function wC(e){function t(n,r,i){var s=e(n,r,i);return Array.isArray(s)?s:(0,Qu.diffAny)(n,r,i,t)}return t}function OC(e,t,n){var r=new Xu.Pointer;return(n?wC(n):Qu.diffAny)(e,t,r)}gt.createPatch=OC;function sb(e,t){var n=Xu.Pointer.fromJSON(t).evaluate(e);if(n!==void 0)return{op:"test",path:t,value:n.value}}function PC(e,t){var n=new Array;return t.filter(Qu.isDestructive).forEach(function(r){var i=sb(e,r.path);if(i&&n.push(i),"from"in r){var s=sb(e,r.from);s&&n.push(s)}}),n}gt.createTests=PC});var io=v(lb=>{(function(e,t){"use strict";if(e.setImmediate)return;var n=1,r={},i=!1,s=e.document,o;function a(g){typeof g!="function"&&(g=new Function(""+g));for(var O=new Array(arguments.length-1),I=0;I<O.length;I++)O[I]=arguments[I+1];var j={callback:g,args:O};return r[n]=j,o(n),n++}function u(g){delete r[g]}function c(g){var O=g.callback,I=g.args;switch(I.length){case 0:O();break;case 1:O(I[0]);break;case 2:O(I[0],I[1]);break;case 3:O(I[0],I[1],I[2]);break;default:O.apply(t,I);break}}function l(g){if(i)setTimeout(l,0,g);else{var O=r[g];if(O){i=!0;try{c(O)}finally{u(g),i=!1}}}}function f(){o=function(g){process.nextTick(function(){l(g)})}}function p(){if(e.postMessage&&!e.importScripts){var g=!0,O=e.onmessage;return e.onmessage=function(){g=!1},e.postMessage("","*"),e.onmessage=O,g}}function h(){var g="setImmediate$"+Math.random()+"$",O=function(I){I.source===e&&typeof I.data=="string"&&I.data.indexOf(g)===0&&l(+I.data.slice(g.length))};e.addEventListener?e.addEventListener("message",O,!1):e.attachEvent("onmessage",O),o=function(I){e.postMessage(g+I,"*")}}function d(){var g=new MessageChannel;g.port1.onmessage=function(O){var I=O.data;l(I)},o=function(O){g.port2.postMessage(O)}}function y(){var g=s.documentElement;o=function(O){var I=s.createElement("script");I.onreadystatechange=function(){l(O),I.onreadystatechange=null,g.removeChild(I),I=null},g.appendChild(I)}}function m(){o=function(g){setTimeout(l,0,g)}}var b=Object.getPrototypeOf&&Object.getPrototypeOf(e);b=b&&b.setTimeout?b:e,{}.toString.call(e.process)==="[object process]"?f():p()?h():e.MessageChannel?d():s&&"onreadystatechange"in s.createElement("script")?y():m(),b.setImmediate=a,b.clearImmediate=u})(typeof self>"u"?typeof global>"u"?lb:global:self)});var Jj={};ll(Jj,{Client:()=>qo,gameFactory:()=>gi});function He(e,t){let{duplicates:n,circular:r}=hr(e),i=[...n],s=new Map(i.map(a=>[a,null])),o=t?.deduplicateInstances!==!1;return JSON.stringify(e,(a,u)=>{if(typeof u=="object"&&u!==null&&!Array.isArray(u)){let c=s.get(u),l=r.has(u);if(typeof c=="number"&&l)return{_instanceReference:c};if(o&&typeof c=="number")return{_instanceReference:c};let f={...u};if(c===null){let p=i.indexOf(u);s.set(u,p),f._instanceReferenceId=p}else!o&&typeof c=="number"&&(f._instanceReference=c);return u.constructor&&u.constructor!==Object&&u.constructor!==Array&&(f._constructorName=u.constructor.name),f}else{if(Number.isNaN(u))return"Wacksonan";if(Object.is(u,-0))return"Wacksonegativezero";switch(u){case 1/0:return"Wacksonfinity";case-1/0:return"Wacksonegativinfinity";case void 0:return"Wacksondefined";default:return u}}},t?.space)}function Ft(e,t){let n=JSON.parse(e,(i,s)=>{switch(s){case"Wacksonfinity":return 1/0;case"Wacksonegativinfinity":return-1/0;case"Wacksondefined":return;case"Wacksonan":return NaN;case"Wacksonegativezero":return-0;default:return s}}),r=new Map;return hr(n,i=>{if(i._instanceReferenceId!=null){let s=i._instanceReferenceId;delete i._instanceReferenceId,r.set(s,i)}if(t&&i._constructorName){let s=t[i._constructorName];if(!s)throw new Error(`Constructor ${i._constructorName} is not in registry`);Object.setPrototypeOf(i,s.prototype),delete i._constructorName}}),hr(n,(i,s,o)=>{if(i?._instanceReference!=null){let a=r.get(i._instanceReference);if(!a)throw new Error(`Unknown _instanceReference: ${i._instanceReference}`);s[o]=a}}),n}function hr(e,t,n=new WeakSet,r=null,i=null,s=new Set,o=new Set,a=new WeakSet){if(typeof e!="object"||e===null)return{duplicates:s,circular:o};if(n.has(e)){s.add(e),a.has(e)&&o.add(e);return}if(n.add(e),a.add(e),t?.(e,r,i),Array.isArray(e))for(let u=0;u<e.length;u++)hr(e[u],t,n,e,u,s,o,a);else for(let u of Object.keys(e))hr(e[u],t,n,e,u,s,o,a);return a.delete(e),{duplicates:s,circular:o}}var cv=he(aa());var Et=class{constructor(t,n,r){if(!t?.fromBank)throw new Error(`Do not create entities directly. Go through the Bank. rule: ${JSON.stringify(n)}`);this.rule=n,this.entityId=r,this.state={},this.rule.stateGroups&&Object.entries(this.rule.stateGroups).forEach(([i,s])=>{let o=t?.initialStateGroups?.[i]??Object.keys(s)[0];Object.assign(this.state,s[o])}),this.rule.state&&Object.assign(this.state,this.rule.state)}get attributes(){return{...this.rule,...this,...this.state}}};var rn=class extends Et{constructor(...t){super(...t),this.entities=[]}placeEntity(t,n="Last"){n==="Last"?this.entities.push(t):n==="First"&&this.entities.unshift(t)}remove(t){this.entities.splice(this.entities.indexOf(t),1)}takeOne(t="First"){if(t==="First")return this.entities.splice(0,1)[0]}isEmpty(){return this.entities.length===0}};var wr=class extends rn{};var sn=class extends Et{constructor(t,...n){super(t,...n),this.spaces=this.makeSpaces(t.bank)}makeSpaces(t){return Array(this.getSpacesCount()).fill().map((n,r)=>t.createEntity({entityType:"Space",index:r}))}getEmptySpaces(){return this.spaces.filter(t=>t.isEmpty())}getSpace(t){return this.spaces[t]}getEntities(t){return this.getSpace(t).entities}placeEntity(t,n){this.getSpace(t).placeEntity(n)}};var Lf=he(Bf());var Ar=class extends sn{getSpacesCount(){return this.rule.width*this.rule.height}getRows(){return(0,Lf.default)(this.spaces,this.rule.width)}getCoordinates(t){let{width:n}=this.rule;return[t%n,Math.floor(t/n)]}getIndex([t,n]){let{width:r}=this.rule;return n*r+t}getSpace(t){return this.spaces[this.getIndex(t)]}getRelativeCoordinates([t,n],[r,i]){let s=[t+r,n+i];return this.areCoordinatesValid(s)?s:null}areCoordinatesValid([t,n]){return t>=0&&n>=0&&t<this.rule.width&&n<this.rule.height}};var ov=he(Ra()),av=he(Bm());var Gg=he(qs()),Fg=he(Ga());function ln(e,t){let n=e;for(let r of t){if(n===void 0)return n;if(r?.flatten){if(!Array.isArray(n))return;n=n.flat(),r.map&&(n=n.map(i=>ln(i,r.map)))}else n=n[r]}return n}var tt="INUMBER",Un="IOP1",Vn="IOP2",zn="IOP3",xt="IVAR",pn="IVARNAME",Ln="IFUNCALL",Ds="IFUNDEF",ze="IEXPR",Va="IEXPREVAL",hn="IMEMBER",Rs="IENDSTATEMENT",Gn="IARRAY";function re(e,t){this.type=e,this.value=t??0}re.prototype.toString=function(){switch(this.type){case tt:case Un:case Vn:case zn:case xt:case pn:case Rs:return this.value;case Ln:return"CALL "+this.value;case Ds:return"DEF "+this.value;case Gn:return"ARRAY "+this.value;case hn:return"."+this.value;default:return"Invalid Instruction"}};function Bs(e){return new re(Un,e)}function Tt(e){return new re(Vn,e)}function Ng(e){return new re(zn,e)}function Ua(e,t,n,r,i){for(var s=[],o=[],a,u,c,l,f=0;f<e.length;f++){var p=e[f],h=p.type;if(h===tt||h===pn)Array.isArray(p.value)?s.push.apply(s,Ua(p.value.map(function(d){return new re(tt,d)}).concat(new re(Gn,p.value.length)),t,n,r,i)):s.push(p);else if(h===xt&&i.hasOwnProperty(p.value))p=new re(tt,i[p.value]),s.push(p);else if(h===Vn&&s.length>1)u=s.pop(),a=s.pop(),l=n[p.value],p=new re(tt,l(a.value,u.value)),s.push(p);else if(h===zn&&s.length>2)c=s.pop(),u=s.pop(),a=s.pop(),p.value==="?"?s.push(a.value?u.value:c.value):(l=r[p.value],p=new re(tt,l(a.value,u.value,c.value)),s.push(p));else if(h===Un&&s.length>0)a=s.pop(),l=t[p.value],p=new re(tt,l(a.value)),s.push(p);else if(h===ze){for(;s.length>0;)o.push(s.shift());o.push(new re(ze,Ua(p.value,t,n,r,i)))}else if(h===hn&&s.length>0)a=s.pop(),s.push(new re(tt,a.value[p.value]));else{for(;s.length>0;)o.push(s.shift());o.push(p)}}for(;s.length>0;)o.push(s.shift());return o}function Cg(e,t,n){for(var r=[],i=0;i<e.length;i++){var s=e[i],o=s.type;if(o===xt&&s.value===t)for(var a=0;a<n.tokens.length;a++){var u=n.tokens[a],c;u.type===Un?c=Bs(u.value):u.type===Vn?c=Tt(u.value):u.type===zn?c=Ng(u.value):c=new re(u.type,u.value),r.push(c)}else o===ze?r.push(new re(ze,Cg(s.value,t,n))):r.push(s)}return r}function fn(e,t,n){var r=[],i,s,o,a,u,c;if(za(e))return At(e,n);for(var l=e.length,f=0;f<l;f++){var p=e[f],h=p.type;if(h===tt||h===pn)r.push(p.value);else if(h===Vn)s=r.pop(),i=r.pop(),p.value==="and"?r.push(i?!!fn(s,t,n):!1):p.value==="or"?r.push(i?!0:!!fn(s,t,n)):p.value==="="?(a=t.binaryOps[p.value],r.push(a(i,fn(s,t,n),n))):(a=t.binaryOps[p.value],r.push(a(At(i,n),At(s,n))));else if(h===zn)o=r.pop(),s=r.pop(),i=r.pop(),p.value==="?"?r.push(fn(i?s:o,t,n)):(a=t.ternaryOps[p.value],r.push(a(At(i,n),At(s,n),At(o,n))));else if(h===xt)if(p.value in t.functions)r.push(t.functions[p.value]);else if(p.value in t.unaryOps&&t.parser.isOperatorEnabled(p.value))r.push(t.unaryOps[p.value]);else{var d=n[p.value];if(d!==void 0)r.push(d);else throw new Error("undefined variable: "+p.value)}else if(h===Un)i=r.pop(),a=t.unaryOps[p.value],r.push(a(At(i,n)));else if(h===Ln){for(c=p.value,u=[];c-- >0;)u.unshift(At(r.pop(),n));if(a=r.pop(),a.apply&&a.call)r.push(a.apply(void 0,u));else throw new Error(a+" is not a function")}else if(h===Ds)r.push(function(){for(var y=r.pop(),m=[],b=p.value;b-- >0;)m.unshift(r.pop());var g=r.pop(),O=function(){for(var I=Object.assign({},n),j=0,N=m.length;j<N;j++)I[m[j]]=arguments[j];return fn(y,t,I)};return Object.defineProperty(O,"name",{value:g,writable:!1}),n[g]=O,O}());else if(h===ze)r.push(TT(p,t));else if(h===Va)r.push(p);else if(h===hn)i=r.pop(),r.push(i[p.value]);else if(h===Rs)r.pop();else if(h===Gn){for(c=p.value,u=[];c-- >0;)u.unshift(r.pop());r.push(u)}else throw new Error("invalid Expression")}if(r.length>1)throw new Error("invalid Expression (parity)");return r[0]===0?0:At(r[0],n)}function TT(e,t,n){return za(e)?e:{type:Va,value:function(r){return fn(e.value,t,r)}}}function za(e){return e&&e.type===Va}function At(e,t){return za(e)?e.value(t):e}function Ka(e,t){for(var n=[],r,i,s,o,a,u,c=0;c<e.length;c++){var l=e[c],f=l.type;if(f===tt)typeof l.value=="number"&&l.value<0?n.push("("+l.value+")"):Array.isArray(l.value)?n.push("["+l.value.map(kg).join(", ")+"]"):n.push(kg(l.value));else if(f===Vn)i=n.pop(),r=n.pop(),o=l.value,t?o==="^"?n.push("Math.pow("+r+", "+i+")"):o==="and"?n.push("(!!"+r+" && !!"+i+")"):o==="or"?n.push("(!!"+r+" || !!"+i+")"):o==="||"?n.push("(function(a,b){ return Array.isArray(a) && Array.isArray(b) ? a.concat(b) : String(a) + String(b); }(("+r+"),("+i+")))"):o==="=="?n.push("("+r+" === "+i+")"):o==="!="?n.push("("+r+" !== "+i+")"):o==="["?n.push(r+"[("+i+") | 0]"):n.push("("+r+" "+o+" "+i+")"):o==="["?n.push(r+"["+i+"]"):n.push("("+r+" "+o+" "+i+")");else if(f===zn)if(s=n.pop(),i=n.pop(),r=n.pop(),o=l.value,o==="?")n.push("("+r+" ? "+i+" : "+s+")");else throw new Error("invalid Expression");else if(f===xt||f===pn)n.push(l.value);else if(f===Un)r=n.pop(),o=l.value,o==="-"||o==="+"?n.push("("+o+r+")"):t?o==="not"?n.push("(!"+r+")"):o==="!"?n.push("fac("+r+")"):n.push(o+"("+r+")"):o==="!"?n.push("("+r+"!)"):n.push("("+o+" "+r+")");else if(f===Ln){for(u=l.value,a=[];u-- >0;)a.unshift(n.pop());o=n.pop(),n.push(o+"("+a.join(", ")+")")}else if(f===Ds){for(i=n.pop(),u=l.value,a=[];u-- >0;)a.unshift(n.pop());r=n.pop(),t?n.push("("+r+" = function("+a.join(", ")+") { return "+i+" })"):n.push("("+r+"("+a.join(", ")+") = "+i+")")}else if(f===hn)r=n.pop(),n.push(r+"."+l.value);else if(f===Gn){for(u=l.value,a=[];u-- >0;)a.unshift(n.pop());n.push("["+a.join(", ")+"]")}else if(f===ze)n.push("("+Ka(l.value,t)+")");else if(f!==Rs)throw new Error("invalid Expression")}return n.length>1&&(t?n=[n.join(",")]:n=[n.join(";")]),String(n[0])}function kg(e){return typeof e=="string"?JSON.stringify(e).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029"):e}function Bn(e,t){for(var n=0;n<e.length;n++)if(e[n]===t)return!0;return!1}function Ha(e,t,n){n=n||{};for(var r=!!n.withMembers,i=null,s=0;s<e.length;s++){var o=e[s];o.type===xt||o.type===pn?!r&&!Bn(t,o.value)?t.push(o.value):(i!==null&&(Bn(t,i)||t.push(i)),i=o.value):o.type===hn&&r&&i!==null?i+="."+o.value:o.type===ze?Ha(o.value,t,n):i!==null&&(Bn(t,i)||t.push(i),i=null)}i!==null&&!Bn(t,i)&&t.push(i)}function it(e,t){this.tokens=e,this.parser=t,this.unaryOps=t.unaryOps,this.binaryOps=t.binaryOps,this.ternaryOps=t.ternaryOps,this.functions=t.functions}it.prototype.simplify=function(e){return e=e||{},new it(Ua(this.tokens,this.unaryOps,this.binaryOps,this.ternaryOps,e),this.parser)};it.prototype.substitute=function(e,t){return t instanceof it||(t=this.parser.parse(String(t))),new it(Cg(this.tokens,e,t),this.parser)};it.prototype.evaluate=function(e){return e=e||{},fn(this.tokens,this,e)};it.prototype.toString=function(){return Ka(this.tokens,!1)};it.prototype.symbols=function(e){e=e||{};var t=[];return Ha(this.tokens,t,e),t};it.prototype.variables=function(e){e=e||{};var t=[];Ha(this.tokens,t,e);var n=this.functions;return t.filter(function(r){return!(r in n)})};it.prototype.toJSFunction=function(e,t){var n=this,r=new Function(e,"with(this.functions) with (this.ternaryOps) with (this.binaryOps) with (this.unaryOps) { return "+Ka(this.simplify(t).tokens,!0)+"; }");return function(){return r.apply(n,arguments)}};var Dr="TEOF",me="TOP",Ls="TNUMBER",qg="TSTRING",St="TPAREN",Fn="TBRACKET",Gs="TCOMMA",Wa="TNAME",Ja="TSEMICOLON";function jg(e,t,n){this.type=e,this.value=t,this.index=n}jg.prototype.toString=function(){return this.type+": "+this.value};function Te(e,t){this.pos=0,this.current=null,this.unaryOps=e.unaryOps,this.binaryOps=e.binaryOps,this.ternaryOps=e.ternaryOps,this.consts=e.consts,this.expression=t,this.savedPosition=0,this.savedCurrent=null,this.options=e.options,this.parser=e}Te.prototype.newToken=function(e,t,n){return new jg(e,t,n??this.pos)};Te.prototype.save=function(){this.savedPosition=this.pos,this.savedCurrent=this.current};Te.prototype.restore=function(){this.pos=this.savedPosition,this.current=this.savedCurrent};Te.prototype.next=function(){if(this.pos>=this.expression.length)return this.newToken(Dr,"EOF");if(this.isWhitespace()||this.isComment())return this.next();if(this.isRadixInteger()||this.isNumber()||this.isOperator()||this.isString()||this.isParen()||this.isBracket()||this.isComma()||this.isSemicolon()||this.isNamedOp()||this.isConst()||this.isName())return this.current;this.parseError('Unknown character "'+this.expression.charAt(this.pos)+'"')};Te.prototype.isString=function(){var e=!1,t=this.pos,n=this.expression.charAt(t);if(n==="'"||n==='"')for(var r=this.expression.indexOf(n,t+1);r>=0&&this.pos<this.expression.length;){if(this.pos=r+1,this.expression.charAt(r-1)!=="\\"){var i=this.expression.substring(t+1,r);this.current=this.newToken(qg,this.unescape(i),t),e=!0;break}r=this.expression.indexOf(n,r+1)}return e};Te.prototype.isParen=function(){var e=this.expression.charAt(this.pos);return e==="("||e===")"?(this.current=this.newToken(St,e),this.pos++,!0):!1};Te.prototype.isBracket=function(){var e=this.expression.charAt(this.pos);return(e==="["||e==="]")&&this.isOperatorEnabled("[")?(this.current=this.newToken(Fn,e),this.pos++,!0):!1};Te.prototype.isComma=function(){var e=this.expression.charAt(this.pos);return e===","?(this.current=this.newToken(Gs,","),this.pos++,!0):!1};Te.prototype.isSemicolon=function(){var e=this.expression.charAt(this.pos);return e===";"?(this.current=this.newToken(Ja,";"),this.pos++,!0):!1};Te.prototype.isConst=function(){for(var e=this.pos,t=e;t<this.expression.length;t++){var n=this.expression.charAt(t);if(n.toUpperCase()===n.toLowerCase()&&(t===this.pos||n!=="_"&&n!=="."&&(n<"0"||n>"9")))break}if(t>e){var r=this.expression.substring(e,t);if(r in this.consts)return this.current=this.newToken(Ls,this.consts[r]),this.pos+=r.length,!0}return!1};Te.prototype.isNamedOp=function(){for(var e=this.pos,t=e;t<this.expression.length;t++){var n=this.expression.charAt(t);if(n.toUpperCase()===n.toLowerCase()&&(t===this.pos||n!=="_"&&(n<"0"||n>"9")))break}if(t>e){var r=this.expression.substring(e,t);if(this.isOperatorEnabled(r)&&(r in this.binaryOps||r in this.unaryOps||r in this.ternaryOps))return this.current=this.newToken(me,r),this.pos+=r.length,!0}return!1};Te.prototype.isName=function(){for(var e=this.pos,t=e,n=!1;t<this.expression.length;t++){var r=this.expression.charAt(t);if(r.toUpperCase()===r.toLowerCase()){if(t===this.pos&&(r==="$"||r==="_")){r==="_"&&(n=!0);continue}else if(t===this.pos||!n||r!=="_"&&(r<"0"||r>"9"))break}else n=!0}if(n){var i=this.expression.substring(e,t);return this.current=this.newToken(Wa,i),this.pos+=i.length,!0}return!1};Te.prototype.isWhitespace=function(){for(var e=!1,t=this.expression.charAt(this.pos);(t===" "||t===" "||t===`
|
|
5
5
|
`||t==="\r")&&(e=!0,this.pos++,!(this.pos>=this.expression.length));)t=this.expression.charAt(this.pos);return e};var MT=/^[0-9a-f]{4}$/i;Te.prototype.unescape=function(e){var t=e.indexOf("\\");if(t<0)return e;for(var n=e.substring(0,t);t>=0;){var r=e.charAt(++t);switch(r){case"'":n+="'";break;case'"':n+='"';break;case"\\":n+="\\";break;case"/":n+="/";break;case"b":n+="\b";break;case"f":n+="\f";break;case"n":n+=`
|
|
6
6
|
`;break;case"r":n+="\r";break;case"t":n+=" ";break;case"u":var i=e.substring(t+1,t+5);MT.test(i)||this.parseError("Illegal escape sequence: \\u"+i),n+=String.fromCharCode(parseInt(i,16)),t+=4;break;default:throw this.parseError('Illegal escape sequence: "\\'+r+'"')}++t;var s=e.indexOf("\\",t);n+=e.substring(t,s<0?e.length:s),t=s}return n};Te.prototype.isComment=function(){var e=this.expression.charAt(this.pos);return e==="/"&&this.expression.charAt(this.pos+1)==="*"?(this.pos=this.expression.indexOf("*/",this.pos)+2,this.pos===1&&(this.pos=this.expression.length),!0):!1};Te.prototype.isRadixInteger=function(){var e=this.pos;if(e>=this.expression.length-2||this.expression.charAt(e)!=="0")return!1;++e;var t,n;if(this.expression.charAt(e)==="x")t=16,n=/^[0-9a-f]$/i,++e;else if(this.expression.charAt(e)==="b")t=2,n=/^[01]$/i,++e;else return!1;for(var r=!1,i=e;e<this.expression.length;){var s=this.expression.charAt(e);if(n.test(s))e++,r=!0;else break}return r&&(this.current=this.newToken(Ls,parseInt(this.expression.substring(i,e),t)),this.pos=e),r};Te.prototype.isNumber=function(){for(var e=!1,t=this.pos,n=t,r=t,i=!1,s=!1,o;t<this.expression.length&&(o=this.expression.charAt(t),o>="0"&&o<="9"||!i&&o===".");)o==="."?i=!0:s=!0,t++,e=s;if(e&&(r=t),o==="e"||o==="E"){t++;for(var a=!0,u=!1;t<this.expression.length;){if(o=this.expression.charAt(t),a&&(o==="+"||o==="-"))a=!1;else if(o>="0"&&o<="9")u=!0,a=!1;else break;t++}u||(t=r)}return e?(this.current=this.newToken(Ls,parseFloat(this.expression.substring(n,t))),this.pos=t):this.pos=r,e};Te.prototype.isOperator=function(){var e=this.pos,t=this.expression.charAt(this.pos);if(t==="+"||t==="-"||t==="*"||t==="/"||t==="%"||t==="^"||t==="?"||t===":"||t===".")this.current=this.newToken(me,t);else if(t==="\u2219"||t==="\u2022")this.current=this.newToken(me,"*");else if(t===">")this.expression.charAt(this.pos+1)==="="?(this.current=this.newToken(me,">="),this.pos++):this.current=this.newToken(me,">");else if(t==="<")this.expression.charAt(this.pos+1)==="="?(this.current=this.newToken(me,"<="),this.pos++):this.current=this.newToken(me,"<");else if(t==="|")if(this.expression.charAt(this.pos+1)==="|")this.current=this.newToken(me,"||"),this.pos++;else return!1;else if(t==="=")this.expression.charAt(this.pos+1)==="="?(this.current=this.newToken(me,"=="),this.pos++):this.current=this.newToken(me,t);else if(t==="!")this.expression.charAt(this.pos+1)==="="?(this.current=this.newToken(me,"!="),this.pos++):this.current=this.newToken(me,t);else return!1;return this.pos++,this.isOperatorEnabled(this.current.value)?!0:(this.pos=e,!1)};Te.prototype.isOperatorEnabled=function(e){return this.parser.isOperatorEnabled(e)};Te.prototype.getCoordinates=function(){var e=0,t,n=-1;do e++,t=this.pos-n,n=this.expression.indexOf(`
|
|
7
|
-
`,n+1);while(n>=0&&n<this.pos);return{line:e,column:t}};Te.prototype.parseError=function(e){var t=this.getCoordinates();throw new Error("parse error ["+t.line+":"+t.column+"]: "+e)};function _e(e,t,n){this.parser=e,this.tokens=t,this.current=null,this.nextToken=null,this.next(),this.savedCurrent=null,this.savedNextToken=null,this.allowMemberAccess=n.allowMemberAccess!==!1}_e.prototype.next=function(){return this.current=this.nextToken,this.nextToken=this.tokens.next()};_e.prototype.tokenMatches=function(e,t){return typeof t>"u"?!0:Array.isArray(t)?Bn(t,e.value):typeof t=="function"?t(e):e.value===t};_e.prototype.save=function(){this.savedCurrent=this.current,this.savedNextToken=this.nextToken,this.tokens.save()};_e.prototype.restore=function(){this.tokens.restore(),this.current=this.savedCurrent,this.nextToken=this.savedNextToken};_e.prototype.accept=function(e,t){return this.nextToken.type===e&&this.tokenMatches(this.nextToken,t)?(this.next(),!0):!1};_e.prototype.expect=function(e,t){if(!this.accept(e,t)){var n=this.tokens.getCoordinates();throw new Error("parse error ["+n.line+":"+n.column+"]: Expected "+(t||e))}};_e.prototype.parseAtom=function(e){var t=this.tokens.unaryOps;function n(i){return i.value in t}if(this.accept(Wa)||this.accept(me,n))e.push(new re(xt,this.current.value));else if(this.accept(Ls))e.push(new re(tt,this.current.value));else if(this.accept(qg))e.push(new re(tt,this.current.value));else if(this.accept(St,"("))this.parseExpression(e),this.expect(St,")");else if(this.accept(Fn,"["))if(this.accept(Fn,"]"))e.push(new re(Gn,0));else{var r=this.parseArrayList(e);e.push(new re(Gn,r))}else throw new Error("unexpected "+this.nextToken)};_e.prototype.parseExpression=function(e){var t=[];this.parseUntilEndStatement(e,t)||(this.parseVariableAssignmentExpression(t),!this.parseUntilEndStatement(e,t)&&this.pushExpression(e,t))};_e.prototype.pushExpression=function(e,t){for(var n=0,r=t.length;n<r;n++)e.push(t[n])};_e.prototype.parseUntilEndStatement=function(e,t){return this.accept(Ja)?(this.nextToken&&this.nextToken.type!==Dr&&!(this.nextToken.type===St&&this.nextToken.value===")")&&t.push(new re(Rs)),this.nextToken.type!==Dr&&this.parseExpression(t),e.push(new re(ze,t)),!0):!1};_e.prototype.parseArrayList=function(e){for(var t=0;!this.accept(Fn,"]");)for(this.parseExpression(e),++t;this.accept(Gs);)this.parseExpression(e),++t;return t};_e.prototype.parseVariableAssignmentExpression=function(e){for(this.parseConditionalExpression(e);this.accept(me,"=");){var t=e.pop(),n=[],r=e.length-1;if(t.type===Ln){if(!this.tokens.isOperatorEnabled("()="))throw new Error("function definition is not permitted");for(var i=0,s=t.value+1;i<s;i++){var o=r-i;e[o].type===xt&&(e[o]=new re(pn,e[o].value))}this.parseVariableAssignmentExpression(n),e.push(new re(ze,n)),e.push(new re(Ds,t.value));continue}if(t.type!==xt&&t.type!==hn)throw new Error("expected variable for assignment");this.parseVariableAssignmentExpression(n),e.push(new re(pn,t.value)),e.push(new re(ze,n)),e.push(Tt("="))}};_e.prototype.parseConditionalExpression=function(e){for(this.parseOrExpression(e);this.accept(me,"?");){var t=[],n=[];this.parseConditionalExpression(t),this.expect(me,":"),this.parseConditionalExpression(n),e.push(new re(ze,t)),e.push(new re(ze,n)),e.push(Ng("?"))}};_e.prototype.parseOrExpression=function(e){for(this.parseAndExpression(e);this.accept(me,"or");){var t=[];this.parseAndExpression(t),e.push(new re(ze,t)),e.push(Tt("or"))}};_e.prototype.parseAndExpression=function(e){for(this.parseComparison(e);this.accept(me,"and");){var t=[];this.parseComparison(t),e.push(new re(ze,t)),e.push(Tt("and"))}};var IT=["==","!=","<","<=",">=",">","in"];_e.prototype.parseComparison=function(e){for(this.parseAddSub(e);this.accept(me,IT);){var t=this.current;this.parseAddSub(e),e.push(Tt(t.value))}};var NT=["+","-","||"];_e.prototype.parseAddSub=function(e){for(this.parseTerm(e);this.accept(me,NT);){var t=this.current;this.parseTerm(e),e.push(Tt(t.value))}};var CT=["*","/","%"];_e.prototype.parseTerm=function(e){for(this.parseFactor(e);this.accept(me,CT);){var t=this.current;this.parseFactor(e),e.push(Tt(t.value))}};_e.prototype.parseFactor=function(e){var t=this.tokens.unaryOps;function n(i){return i.value in t}if(this.save(),this.accept(me,n)){if(this.current.value!=="-"&&this.current.value!=="+"){if(this.nextToken.type===St&&this.nextToken.value==="("){this.restore(),this.parseExponential(e);return}else if(this.nextToken.type===Ja||this.nextToken.type===Gs||this.nextToken.type===Dr||this.nextToken.type===St&&this.nextToken.value===")"){this.restore(),this.parseAtom(e);return}}var r=this.current;this.parseFactor(e),e.push(Bs(r.value))}else this.parseExponential(e)};_e.prototype.parseExponential=function(e){for(this.parsePostfixExpression(e);this.accept(me,"^");)this.parseFactor(e),e.push(Tt("^"))};_e.prototype.parsePostfixExpression=function(e){for(this.parseFunctionCall(e);this.accept(me,"!");)e.push(Bs("!"))};_e.prototype.parseFunctionCall=function(e){var t=this.tokens.unaryOps;function n(s){return s.value in t}if(this.accept(me,n)){var r=this.current;this.parseAtom(e),e.push(Bs(r.value))}else for(this.parseMemberExpression(e);this.accept(St,"(");)if(this.accept(St,")"))e.push(new re(Ln,0));else{var i=this.parseArgumentList(e);e.push(new re(Ln,i))}};_e.prototype.parseArgumentList=function(e){for(var t=0;!this.accept(St,")");)for(this.parseExpression(e),++t;this.accept(Gs);)this.parseExpression(e),++t;return t};_e.prototype.parseMemberExpression=function(e){for(this.parseAtom(e);this.accept(me,".")||this.accept(Fn,"[");){var t=this.current;if(t.value==="."){if(!this.allowMemberAccess)throw new Error('unexpected ".", member access is not permitted');this.expect(Wa),e.push(new re(hn,this.current.value))}else if(t.value==="["){if(!this.tokens.isOperatorEnabled("["))throw new Error('unexpected "[]", arrays are disabled');this.parseExpression(e),this.expect(Fn,"]"),e.push(Tt("["))}else throw new Error("unexpected symbol: "+t.value)}};function qT(e,t){return Number(e)+Number(t)}function jT(e,t){return e-t}function DT(e,t){return e*t}function RT(e,t){return e/t}function BT(e,t){return e%t}function LT(e,t){return Array.isArray(e)&&Array.isArray(t)?e.concat(t):""+e+t}function GT(e,t){return e===t}function FT(e,t){return e!==t}function UT(e,t){return e>t}function VT(e,t){return e<t}function zT(e,t){return e>=t}function KT(e,t){return e<=t}function HT(e,t){return!!(e&&t)}function WT(e,t){return!!(e||t)}function JT(e,t){return Bn(t,e)}function YT(e){return(Math.exp(e)-Math.exp(-e))/2}function $T(e){return(Math.exp(e)+Math.exp(-e))/2}function XT(e){return e===1/0?1:e===-1/0?-1:(Math.exp(e)-Math.exp(-e))/(Math.exp(e)+Math.exp(-e))}function QT(e){return e===-1/0?e:Math.log(e+Math.sqrt(e*e+1))}function ZT(e){return Math.log(e+Math.sqrt(e*e-1))}function eM(e){return Math.log((1+e)/(1-e))/2}function Ag(e){return Math.log(e)*Math.LOG10E}function tM(e){return-e}function nM(e){return!e}function rM(e){return e<0?Math.ceil(e):Math.floor(e)}function iM(e){return Math.random()*(e||1)}function xg(e){return Ya(e+1)}function sM(e){return isFinite(e)&&e===Math.round(e)}var oM=4.7421875,Fa=[.9999999999999971,57.15623566586292,-59.59796035547549,14.136097974741746,-.4919138160976202,3399464998481189e-20,4652362892704858e-20,-9837447530487956e-20,.0001580887032249125,-.00021026444172410488,.00021743961811521265,-.0001643181065367639,8441822398385275e-20,-26190838401581408e-21,36899182659531625e-22];function Ya(e){var t,n;if(sM(e)){if(e<=0)return isFinite(e)?1/0:NaN;if(e>171)return 1/0;for(var r=e-2,i=e-1;r>1;)i*=r,r--;return i===0&&(i=1),i}if(e<.5)return Math.PI/(Math.sin(Math.PI*e)*Ya(1-e));if(e>=171.35)return 1/0;if(e>85){var s=e*e,o=s*e,a=o*e,u=a*e;return Math.sqrt(2*Math.PI/e)*Math.pow(e/Math.E,e)*(1+1/(12*e)+1/(288*s)-139/(51840*o)-571/(2488320*a)+163879/(209018880*u)+5246819/(75246796800*u*e))}--e,n=Fa[0];for(var c=1;c<Fa.length;++c)n+=Fa[c]/(e+c);return t=e+oM+.5,Math.sqrt(2*Math.PI)*Math.pow(t,e+.5)*Math.exp(-t)*n}function aM(e){return Array.isArray(e)?e.length:String(e).length}function Sg(){for(var e=0,t=0,n=0;n<arguments.length;n++){var r=Math.abs(arguments[n]),i;t<r?(i=t/r,e=e*i*i+1,t=r):r>0?(i=r/t,e+=i*i):e+=r}return t===1/0?1/0:t*Math.sqrt(e)}function Tg(e,t,n){return e?t:n}function uM(e,t){return typeof t>"u"||+t==0?Math.round(e):(e=+e,t=-+t,isNaN(e)||!(typeof t=="number"&&t%1===0)?NaN:(e=e.toString().split("e"),e=Math.round(+(e[0]+"e"+(e[1]?+e[1]-t:-t))),e=e.toString().split("e"),+(e[0]+"e"+(e[1]?+e[1]+t:t))))}function cM(e,t,n){return n&&(n[e]=t),t}function lM(e,t){return e[t|0]}function fM(e){return arguments.length===1&&Array.isArray(e)?Math.max.apply(Math,e):Math.max.apply(Math,arguments)}function pM(e){return arguments.length===1&&Array.isArray(e)?Math.min.apply(Math,e):Math.min.apply(Math,arguments)}function hM(e,t){if(typeof e!="function")throw new Error("First argument to map is not a function");if(!Array.isArray(t))throw new Error("Second argument to map is not an array");return t.map(function(n,r){return e(n,r)})}function dM(e,t,n){if(typeof e!="function")throw new Error("First argument to fold is not a function");if(!Array.isArray(n))throw new Error("Second argument to fold is not an array");return n.reduce(function(r,i,s){return e(r,i,s)},t)}function mM(e,t){if(typeof e!="function")throw new Error("First argument to filter is not a function");if(!Array.isArray(t))throw new Error("Second argument to filter is not an array");return t.filter(function(n,r){return e(n,r)})}function gM(e,t){if(!(Array.isArray(t)||typeof t=="string"))throw new Error("Second argument to indexOf is not a string or array");return t.indexOf(e)}function yM(e,t){if(!Array.isArray(t))throw new Error("Second argument to join is not an array");return t.join(e)}function vM(e){return(e>0)-(e<0)||+e}var Mg=1/3;function bM(e){return e<0?-Math.pow(-e,Mg):Math.pow(e,Mg)}function _M(e){return Math.exp(e)-1}function wM(e){return Math.log(1+e)}function OM(e){return Math.log(e)/Math.LN2}function Ht(e){this.options=e||{},this.unaryOps={sin:Math.sin,cos:Math.cos,tan:Math.tan,asin:Math.asin,acos:Math.acos,atan:Math.atan,sinh:Math.sinh||YT,cosh:Math.cosh||$T,tanh:Math.tanh||XT,asinh:Math.asinh||QT,acosh:Math.acosh||ZT,atanh:Math.atanh||eM,sqrt:Math.sqrt,cbrt:Math.cbrt||bM,log:Math.log,log2:Math.log2||OM,ln:Math.log,lg:Math.log10||Ag,log10:Math.log10||Ag,expm1:Math.expm1||_M,log1p:Math.log1p||wM,abs:Math.abs,ceil:Math.ceil,floor:Math.floor,round:Math.round,trunc:Math.trunc||rM,"-":tM,"+":Number,exp:Math.exp,not:nM,length:aM,"!":xg,sign:Math.sign||vM},this.binaryOps={"+":qT,"-":jT,"*":DT,"/":RT,"%":BT,"^":Math.pow,"||":LT,"==":GT,"!=":FT,">":UT,"<":VT,">=":zT,"<=":KT,and:HT,or:WT,in:JT,"=":cM,"[":lM},this.ternaryOps={"?":Tg},this.functions={random:iM,fac:xg,min:pM,max:fM,hypot:Math.hypot||Sg,pyt:Math.hypot||Sg,pow:Math.pow,atan2:Math.atan2,if:Tg,gamma:Ya,roundTo:uM,map:hM,fold:dM,filter:mM,indexOf:gM,join:yM},this.consts={E:Math.E,PI:Math.PI,true:!0,false:!1}}Ht.prototype.parse=function(e){var t=[],n=new _e(this,new Te(this,e),{allowMemberAccess:this.options.allowMemberAccess});return n.parseExpression(t),n.expect(Dr,"EOF"),new it(t,this)};Ht.prototype.evaluate=function(e,t){return this.parse(e).evaluate(t)};var Dg=new Ht;Ht.parse=function(e){return Dg.parse(e)};Ht.evaluate=function(e,t){return Dg.parse(e).evaluate(t)};var Ig={"+":"add","-":"subtract","*":"multiply","/":"divide","%":"remainder","^":"power","!":"factorial","<":"comparison",">":"comparison","<=":"comparison",">=":"comparison","==":"comparison","!=":"comparison","||":"concatenate",and:"logical",or:"logical",not:"logical","?":"conditional",":":"conditional","=":"assignment","[":"array","()=":"fndef"};function PM(e){return Ig.hasOwnProperty(e)?Ig[e]:e}Ht.prototype.isOperatorEnabled=function(e){var t=PM(e),n=this.options.operators||{};return!(t in n)||!!n[t]};var Rg=new Ht;Rg.functions.sum=e=>e.reduce((t,n)=>t+n,0);function Rr(e,t,n){let r=pe(e,t.arguments,n);return Rg.evaluate(t.expression,r)}var Bg=he(qs()),EM=["state"];function Br(e,t,n,r){return!EM.includes(r)&&(0,Bg.default)(t)?e.G.bank.find(e,t,n):t}var kM=["conditions","move","then","mapping"];function pe(e,t,n,r){if(!(0,Gg.default)(t)&&!Array.isArray(t))return t;let i=Array.isArray(t)?[...t]:{...t};Object.entries(t).forEach(([a,u])=>{kM.includes(a)||(i[a]=pe(e,u,n,a))});let s=AM(e,i,n);return s?.resolveAsEntity||r==="target"||r==="targets"?Br(e,s,n,r):s}function AM(e,t,n){if(t?.type==="expression")return Rr(e,{...t,arguments:pe(e,t.arguments,n,"arguments")},n);if(t?.type==="count")return e.G.bank.findAll(e,t,n).length;if(t?.type==="contextPath")return ln(n,t.path);if(t?.type==="ctxPath")return ln(e.ctx,t.path);if(t?.type==="gamePath")return ln(e.G,t.path);if(t?.type==="RelativePath"){let r=pe(e,t.target,n,"target");return ln(r.attributes,t.path)??null}else if(t?.type==="Parent"){let r=t.target?pe(e,t.target,n,"target"):n.originalTarget;return e.G.bank.findParent(r)??null}else{if(t?.type==="map")return Lg(e,t.targets,t.mapping,n).map(r=>r.value);if(t?.type==="mapMax"){let r=Lg(e,t.targets,t.mapping,n),i,s=[];for(let o=0,a=r.length;o<a;o++){let{target:u,value:c}=r[o];i===void 0||c>i?(i=c,s.length=0,s.push(u)):c===i&&s.push(u)}return s}else if(t?.type==="Pick"){let r=pe(e,t.target,n,"target");return(0,Fg.default)(pe(e,r.attributes,n,"attributes"),t.properties)}else if(t?.type==="Coordinates"){let r=t.target?pe(e,t.target,n,"target"):n.originalTarget;return e.G.bank.findParent(r).getCoordinates(r.rule.index)}else if(t?.type==="relativeCoordinates"){let r=t.target?pe(e,t.target,n,"target"):n.originalTarget,i=e.G.bank.findParent(r),s=i.getCoordinates(r.rule.index),o=i.getRelativeCoordinates(s,pe(e,t.location,n,"location"));return(o&&i.spaces[i.getIndex(o)])??null}else return t}}function Lg(e,t,n,r){return t.resolveAsEntity=!0,pe(e,t,r)?.map(i=>({target:i,value:pe(e,n,{...r,loopTarget:i})}))??[]}var oe=class{constructor(t){this.rule=t}check(t,n,r){let i={...n},s={...r};i.target&&(s.originalTarget=i.target);let o=pe(t,this.rule,s);return o.target!==void 0&&(i.target=o.target),this.rule.target!==void 0&&!i.target?{conditionIsMet:!1}:this.checkCondition(t,o,i,s)}isMet(...t){return this.check(...t).conditionIsMet}};var Zy=he(Fr());function d2(e,t,n){let r={...t};return delete r.state,delete r.stateGroups,pe(e,r,n)}function m2(e){return{...e.rule,...e.state}}function Qa(e,t,n,r){return(0,Zy.default)(d2(e,t,r))(m2(n))}var Ur=class extends oe{checkCondition(t,n,{target:r},i){return this.rule.entity&&r!==n.entity?{target:r,conditionIsMet:!1}:{target:r,conditionIsMet:Qa(t,n.matcher,r,i)}}};var Vr=class extends oe{checkCondition(t,n,r,i){return{conditionIsMet:!ke(t,n,r,i).conditionsAreMet}}};function Za(e,{conditions:t=[]},n,r){let i;for(let s of t){let o=dn(s).check(e,n,r);if(o.conditionIsMet){i={...o,conditionRule:s};break}}return i}var zr=class extends oe{checkCondition(t,n,r,i){return{conditionIsMet:!!Za(t,n,r,i)}}};var Kr=class extends oe{checkCondition(t,n,{target:r},i){let s=r.find(o=>{let a={...i,loopTarget:o};return ke(t,n,void 0,a).conditionsAreMet});return{conditionIsMet:!!s,result:s}}};var Hr=class extends oe{checkCondition(t,n,{target:r},i){let s=r.map(o=>{let a={...i,loopTarget:o};return ke(t,n,void 0,a)});return{conditionIsMet:s.every(o=>o.conditionsAreMet),results:s}}};var s8=he(Fr());var Wr=class extends oe{checkCondition(t,n,r,i){let{target:s}=r;if(s){let a=(s.entities??s.spaces)?.filter(u=>ke(t,n,{target:u},i).conditionsAreMet)??[];return{matches:a,conditionIsMet:!!a.length}}else return{matches:[],conditionIsMet:!1}}};var ev=he(Ga());var Jr=class extends oe{checkCondition(t,n,{targets:r}){if(r.length===1&&r[0].entities?.length)return{conditionIsMet:!0};let[i,...s]=r;return{conditionIsMet:i.entities.some(a=>{let u=dn({conditionType:"Contains",conditions:[{conditionType:"Is",matcher:(0,ev.default)(a.rule,n.properties)}]});return s.every(c=>u.isMet(t,{target:c}))})}}};var h8=he(Fr());var g2=[[1,0],[0,1],[1,1],[-1,1]],tv=new WeakMap;function y2(e,t){let n={moveInstance:t.moveInstance?.id,moveArguments:t.moveArguments};return JSON.stringify({pattern:e,context:n})}function v2(e){return(e.entities||[]).map(n=>{let r=n.entities||[];return r.length===0?"empty":r.map(i=>{let s=Object.keys(i).sort(),o={};return s.forEach(a=>{o[a]=i[a]}),JSON.stringify(o)}).sort().join("|")}).join(",")}function nv(e,t,n,r,i,s=!1){let o=[],a=t.length,u=0;for(;u<=a-r;){let c=w2(e,t,u,n,i,s);c&&o.push(c),u++}return o}function b2(e,t,n){let{width:r,height:i}=e.attributes,s=[];if(t===1&&n===0)for(let o=0;o<i;o++)s.push([0,o]);else if(t===0&&n===1)for(let o=0;o<r;o++)s.push([o,0]);else if(t===1&&n===1){for(let o=0;o<r;o++)s.push([o,0]);for(let o=1;o<i;o++)s.push([0,o])}else if(t===-1&&n===1){for(let o=0;o<r;o++)s.push([o,0]);for(let o=1;o<i;o++)s.push([r-1,o])}return s}function _2(e,t,n,r,i){let s=[],[o,a]=[t,n];for(;e.areCoordinatesValid([o,a]);)s.push(e.getSpace([o,a])),o+=r,a+=i;return s}function w2(e,t,n,r,i,s=!1){let o=n,a=[],u=t.length;for(let c of r){let{count:l,minCount:f,maxCount:p,conditions:h}=c,d,y;l!==void 0?d=y=l:f!==void 0||p!==void 0?(d=f||0,y=p||1/0):d=y=1;let m=0,b=[];for(;m<y&&o<u;){let g=s?t[u-1-o]:t[o];if(O2(e,g,h,b,i))b.push(g),m++,o++;else break}if(m<d)return null;a.push(...b)}return a.length>0?a:null}function O2(e,t,n,r=[],i){return!n||n.length===0?!0:ke(e,{conditions:n},{target:t,targets:[t,...r]},i).conditionsAreMet}function Yr(e,t,n,r){let i=y2(n,r),s=tv.get(t);s||(s=new Map,tv.set(t,s));let o=v2(t),a=s.get(i);if(a&&a.stateKey===o)return a.result;let u=[],c=n.reduce((f,p)=>f+(p.minCount||p.count||1),0);for(let[f,p]of g2){let h=b2(t,f,p);for(let[d,y]of h){let m=_2(t,d,y,f,p);if(m.length<c)continue;let b=nv(e,m,n,c,r);if(u.push(...b),b.length===0||n.length>1){let g=nv(e,m,n,c,r,!0);u.push(...g)}}}let l={matches:u,conditionIsMet:!!u.length};return s.set(i,{stateKey:o,result:l}),l}var $r=class extends oe{checkCondition(t,n,r,i){let{G:s}=t,{target:o}=r,a=s.bank.findParent(r.target),{matches:u}=Yr(t,a,n.sequence,i),c=u.filter(l=>l.some(f=>f===o));return{matches:c,conditionIsMet:!!c.length}}};var Xr=class extends oe{checkCondition(t,n,r,i){let{matches:s}=Yr(t,r.target,n.sequence,i);return{matches:s,conditionIsMet:!!s.length}}};var Qr=class extends oe{checkCondition(t,n,r,i){return{conditionIsMet:r.target.spaces.every(s=>s?.entities.length)}}};function Zr(e,t,n){let r=Ft(He(e.G),ht),i={...e,G:r},s={...t,arguments:{}};return Object.entries(t.arguments).forEach(([o,a])=>{s.arguments[o]=a.abstract?a:r.bank.locate(typeof a=="number"?a:a.entityId)}),n.moveInstance.doMove(i,s,n,{skipCheck:!0}),r}var P2={PlaceNew:["destination"],RemoveEntity:["entity"],MoveEntity:["entity","destination"],TakeFrom:["source","destination"],SetState:["entity","state"]},ei=class extends oe{checkCondition(t,n,{target:r,targets:i=[r]},s){let o={arguments:i.reduce((p,h,d)=>({...p,[P2[s.moveInstance.rule.moveType][d]]:h}),{})},a=Zr(t,o,s),u={};r?u={target:a.bank.locate(r.entityId)}:i&&(u={targets:i.map(p=>a.bank.locate(p.entityId))});let c=ke({...t,G:a},n,u,s),l=c.conditionsAreMet;return{results:l?eu(c.results,p=>t.G.bank.locate(p)):c.results,conditionIsMet:l}}};function eu(e,t,n=new WeakSet){if(typeof e!="object"||e===null||n.has(e))return e;if(n.add(e),e.entityId!==void 0)return t(e.entityId);if(Array.isArray(e))return e.map(r=>eu(r,t,n));{let r={};for(let i in e)e.hasOwnProperty(i)&&(r[i]=eu(e[i],t,n));return r}}var rv=he(qs());function iv(e,t=new Set){if(!e||typeof e!="object")return t;e.type==="contextPath"&&Array.isArray(e.path)&&e.path[0]==="moveArguments"&&e.path[1]&&t.add(e.path[1]);for(let n of Object.values(e))iv(n,t);return t}function E2(e){let t=Object.keys(e),n={},r={};t.forEach(o=>{n[o]=[],r[o]=0}),t.forEach(o=>{let a=e[o];iv(a).forEach(c=>{t.includes(c)&&c!==o&&(n[c].push(o),r[o]++)})});let i=t.filter(o=>r[o]===0),s=[];for(;i.length>0;){let o=i.shift();s.push(o),n[o].forEach(a=>{r[a]--,r[a]===0&&i.push(a)})}return s.length===t.length?s:t}function sv(e,t,n,r,i,s=0,o={}){if(s===r.length){let p={arguments:o};return t.isValid(e,p,i)}let a=r[s],u=n[a],c={...i,moveArguments:o},l=(0,rv.default)(u)?Br(e,{...u,matchMultiple:!0},c,a):u,f=Array.isArray(l)?l:l!==void 0?[l]:[];return f.length===0?!1:f.some(p=>sv(e,t,n,r,i,s+1,{...o,[a]:p}))}function tu(e,t){return Object.values(t).some(n=>{let{moveInstance:r}=n,i={moveInstance:r},o=pe(e,r.rule,i).arguments??{};if(Object.keys(o).length===0)return r.isValid(e,{arguments:{}},i);let a=E2(o);return sv(e,r,o,a,i)})}function ti(e,{game:t,playerID:n,stageName:r}){let i=e.ctx.phase,s=r??e.ctx.activePlayers?.[n??e.ctx.currentPlayer],o=t.phases?.[i]??t;return(o.turn?.stages?.[s]??o).moves??{}}var ni=class extends oe{checkCondition(t,n,r,i){return{conditionIsMet:!tu(t,ti(t,i))}}};var G8=he(Fr());var ri=class extends oe{checkCondition(t,n,r,i){let s={...i};r?.target&&(s.target=r.target);let o=Rr(t,n,s);return{result:o,conditionIsMet:!!o}}};var ii=class extends oe{checkCondition(t,n,{target:r}){let i=t.G.bank.findParent(r),s;return n.position==="First"&&(s=i.entities.indexOf(r)===0),{conditionIsMet:s}}};function dn(e){if(e.conditionType==="Is")return new Ur(e);if(e.conditionType==="Not")return new Vr(e);if(e.conditionType==="Or")return new zr(e);if(e.conditionType==="Some")return new Kr(e);if(e.conditionType==="Contains")return new Wr(e);if(e.conditionType==="ContainsSame")return new Jr(e);if(e.conditionType==="Every")return new Hr(e);if(e.conditionType==="InLine")return new $r(e);if(e.conditionType==="HasLine")return new Xr(e);if(e.conditionType==="IsFull")return new Qr(e);if(e.conditionType==="Would")return new ei(e);if(e.conditionType==="NoPossibleMoves")return new ni(e);if(e.conditionType==="Evaluate")return new ri(e);if(e.conditionType==="Position")return new ii(e)}function ke(e,t,n,r){let{conditions:i=[]}=t,s=[],o;for(let a of i){let u=dn(a).check(e,n,r);if(u.conditionIsMet)s.push(u);else{o=a;break}}return{results:s,failedAt:o,conditionsAreMet:s.length===i.length}}var nu=class{constructor(t,n){this.bank=n,this.rule=t,this.pool=[],this.remaining=+t.count||1}getOne(t,n,r){return this.getMultiple(t,1,n,r)[0]}getMultiple(t,n=1/0,r={},i){let s=[];if(this.remaining===1/0&&n===1/0)throw new Error(`Cannot get infinite pieces from slot with infinite remaining: ${this.rule.name}`);if(n!==1/0&&n>this.remaining)throw new Error(`Requested ${n} pieces but only ${this.remaining} available in slot: ${this.rule.name}`);let o=n===1/0?this.remaining:n;this.remaining!==1/0&&(this.remaining-=o);let a=Math.min(o,this.pool.length);s.push(...this.pool.splice(0,a));let u=o-a;if(u>0&&s.push(...Array.from(new Array(u)).map(()=>this.bank.createEntity(this.rule))),r.state){let c=pe(t,r.state,i);s.forEach(l=>{l.state={...l.state,...c}})}return s}returnToBank(t){t.rule.state?t.state=t.rule.state:delete t.state,this.remaining!==void 0&&(this.remaining+=1),this.pool.push(t)}},zs=nu;var ru=class{constructor(t){this.currentEntityId=0,this.tracker={},this.slots=t.map(n=>new zs(n,this))}createEntity(t={},n){let r=new ht[t.entityType||"Entity"]({bank:this,fromBank:!0,...n},t,this.currentEntityId++);return this.track(r),r}track(t){this.tracker[t.entityId]=t}locate(t){return this.tracker[t]}findAll(t,n,r){if(!n.conditions)throw new Error(`Cannot find entity with no conditions. Rule: ${JSON.stringify(n)}`);return(0,av.default)(Object.values(this.tracker),i=>ke(t,n,{target:i},r).conditionsAreMet)}findOne(t,n,r){return this.findAll(t,n,r)[0]}find(t,n,r){return n.matchMultiple?this.findAll(t,n,r):this.findOne(t,n,r)}findParent(t){return(0,ov.default)(this.tracker,n=>n.entities?.includes(t)||n.spaces?.includes(t))}getOne(t,n,r){let i=this.getSlot(t,n,r);return i||console.error(`No matching slot for ${JSON.stringify(n)}`),i.getOne(t,{state:n.state},r)}getMultiple(t,n,r,i){let s=this.getSlots(t,n,i);return s.length||console.error(`No matching slots for ${JSON.stringify(n)}`),s.reduce((o,a)=>[...o,...a.getMultiple(t,r,{state:n.state})],[])}getSlot(t,n,r){return this.slots.find(i=>ke(t,n,{target:i},r).conditionsAreMet)}getSlots(t,n,r){return this.slots.filter(i=>ke(t,n,{target:i},r).conditionsAreMet)}returnToBank(t,n){this.findParent(n).remove(n),this.getSlot(t,n.rule).returnToBank(n),delete this.tracker[n.entityId]}},Ks=ru;var ht={Board:wr,SpaceGroup:sn,Space:rn,Grid:Ar,Bank:Ks,BankSlot:zs,Entity:Et};function Mt(e){return{...e,G:Ft(JSON.stringify(e.G),ht)}}var uv=he(aa());var we=class{constructor(t){this.rule=this.transformRule(t)}checkValidity(t,n,r){let i=Object.entries(this.rule.arguments??{});if(!i.every(([a])=>{let u=n.arguments[a];return u!==void 0&&(!Array.isArray(u)||u.length)}))return!1;let s={};for(let a=0,u=i.length;a<u;a++){let[c,l]=i[a],f=n.arguments[c],p=Array.isArray(f)?f:[f],h=[];for(let y=0,m=p.length;y<m;y++){let b=p[y],g=ke(t,l,{target:b},{...r,moveArguments:n.arguments});if(h.push(g),!g.conditionsAreMet)break}let d=h.at(-1).conditionsAreMet;if(s[c]={results:h,conditionsAreMet:d},!d)break}let o=ke(t,{conditions:this.rule.conditions},void 0,{...r,moveArguments:n.arguments});return{argumentResults:s,moveResults:o,conditionsAreMet:o.conditionsAreMet&&Object.values(s).every(a=>a.conditionsAreMet)}}isValid(t,n,r){return this.checkValidity(t,n,r).conditionsAreMet}doMove(t,n,r,{skipCheck:i=!1}={}){let s=pe(t,this.rule,r),o={...n,arguments:Object.entries(s.arguments??{}).reduce((u,[c,l])=>({...u,[c]:n?.arguments?.[c]??l}),{})};s.name&&(t.G._meta.previousPayloads[s.name]=o);let a;return i||(a=this.checkValidity(t,o,r)),!i&&!a.conditionsAreMet?uv.INVALID_MOVE:(this.do(t,s,o,r),r&&(r.previousArguments=o.arguments),{conditionResults:a})}transformRule(t){let n=t.arguments;for(let r in n){let i=n[r];i.playerChoice||(i.resolveAsEntity=!0)}return t}};var si=class extends we{do(t,n,{arguments:{entity:r,destination:i}}){Array.isArray(r)?r.forEach(s=>{t.G.bank.findParent(s)?.remove(s),i.placeEntity(s,n.position)}):(t.G.bank.findParent(r)?.remove(r),i.placeEntity(r,n.position))}};var oi=class extends we{do(t,n,{arguments:{entity:r}}){t.G.bank.returnToBank(t,r)}};var ai=class extends we{do(t,n,{arguments:{destination:r}},i){(n.matchMultiple?t.G.bank.getMultiple(t,{...n.entity,conditions:[...n.entity?.conditions||[],...n.conditions||[]]},n.count,i):[t.G.bank.getOne(t,{...n.entity,conditions:[...n.entity?.conditions||[],...n.conditions||[]]},i)]).forEach(o=>{r.placeEntity(o,n.position)})}};var ui=class extends we{do(t,n,{arguments:{source:r,destination:i}}){i.placeEntity(r.takeOne(n.arguments.source.position))}};var ci=class extends we{do(t,n,{arguments:{entity:r,state:i}}){r.state={...r.state,[i.property]:i.value}}};function mn(e,t=[],n){return t?.length&&t.forEach(r=>{Hn(r,n.game).moveInstance.doMove(e,void 0,n)}),e.G}var li=class extends we{do(t,n,r,i){t.events.setActivePlayers(n.options);let s=t.ctx.phase,o=n.options.currentPlayer?.stage,u=(i.game.phases?.[s]??i.game)?.turn?.stages?.[o];mn(t,u?.initialMoves,{...i,stageName:o})}};var fi=class extends we{do(t){t.events.endTurn()}};var pi=class extends we{do(t){t.G._meta.passedPlayers.length<t.ctx.numPlayers&&(t.G._meta.passedPlayers.push(t.ctx.currentPlayer),t.events.pass())}};var hi=class extends we{do(t,n,{arguments:{targets:r}},i){r.forEach(s=>{let o={...i,loopTarget:s};Hs(n.move).doMove(t,void 0,o)})}};var di=class extends we{do(t){t.events.endTurn()}};var mi=class extends we{do(t,n,{arguments:{target:r}}){r.entities=t.random.Shuffle(r.entities)}};function Hn(e,t){let n=Hs(e),r=function(i,s){let o=Mt(i),{G:a}=o,u=k2(s,a),c={moveInstance:n,game:t},l=n.doMove(o,u,c);if(c.moveConditionResults=[l],l!==cv.INVALID_MOVE&&e.then)for(let f of e.then){let p=Hs(f).doMove(o,{},{...c});c.moveConditionResults.push(p)}return JSON.parse(He(a))};return r.moveInstance=n,r}function k2(e,t){if(e){let n=Ft(JSON.stringify(e),ht);return n.arguments=Object.entries(n.arguments).reduce((r,[i,s])=>({...r,[i]:typeof s=="number"?t.bank.locate(s):s}),{}),n}else return e}function Hs(e){switch(e.moveType){case"MoveEntity":return new si(e);case"PlaceNew":return new ai(e);case"RemoveEntity":return new oi(e);case"TakeFrom":return new ui(e);case"SetState":return new ci(e);case"ForEach":return new hi(e);case"Pass":return new di(e);case"Shuffle":return new mi(e);case"SetActivePlayers":return new li(e);case"EndTurn":return new fi(e);case"PassTurn":return new pi(e)}}var b6=he(fv()),hv=he(Ra());function iu(e,t){return JSON.parse(JSON.stringify(e),(n,r)=>{let i=r;for(let s of t)s.test(i)&&(i=s.replace(i));return i})}var M2=[{entityType:"Space",count:"Infinity"},{entityType:"Board",name:"sharedBoard"},{name:"playerMarker",perPlayer:!0,count:"Infinity"}];function I2(e){e.entities=[...M2,...e.entities||[]]}function pv(e,t){if(e.sharedBoard){let n=e.sharedBoard.map(r=>({entity:r,destination:{name:"sharedBoard"}}));e.initialPlacements||(e.initialPlacements=[]),e.initialPlacements.unshift(...n)}if(e.personalBoard){t.push({entityType:"Board",name:"personalBoard",perPlayer:!0});let n=e.personalBoard.map(r=>({entity:r,destination:{name:"personalBoard"}}));e.initialPlacements||(e.initialPlacements=[]),e.initialPlacements.unshift(...n)}if(e.initialPlacements){let n=e.initialPlacements.map(r=>{let{state:i,...s}=r.entity,o=(0,hv.default)(t,s);return r.destination.name==="personalBoard"?{moveType:"ForEach",arguments:{targets:{type:"ctxPath",path:["playOrder"]}},move:{moveType:"PlaceNew",entity:{state:i,conditions:[{conditionType:"Is",matcher:{...s,...o.perPlayer?{player:{type:"contextPath",path:["loopTarget"]}}:{}}}]},arguments:{destination:{conditions:[{conditionType:"Is",matcher:{...r.destination,player:{type:"contextPath",path:["loopTarget"]}}}]}}}}:{moveType:"PlaceNew",entity:{state:i,conditions:[{conditionType:"Is",matcher:s}]},arguments:{destination:{conditions:[{conditionType:"Is",matcher:r.destination}]}}}});e.initialMoves||(e.initialMoves=[]),e.initialMoves.unshift(...n),delete e.initialPlacements}}var N2=[],su=[["isCurrentPlayer",{conditionType:"Is",matcher:{player:{type:"ctxPath",path:["currentPlayer"]}}}],["isEmpty",{conditionType:"Not",conditions:[{conditionType:"Contains"}]}],["ownerOfFirstResultEntity",{type:"contextPath",path:["results",0,"matches",0,0,"entities",0,"attributes","player"]}]],C2=[{test:e=>e&&typeof e=="object",replace:e=>(N2.forEach(([t,n])=>{e.hasOwnProperty(t)&&(e[n]=e[t],delete e[t])}),e)},{test:e=>typeof e=="string",replace:e=>{for(let t=0,n=su.length;t<n;t++)if(e===su[t][0])return su[t][1];return e}},{test:e=>e?.conditions,replace:e=>(Array.isArray(e.conditions)||(e.conditions=[e.conditions]),e)},{test:e=>e?.conditions,replace:e=>{for(let t=0,n=e.conditions.length;t<n;t++)e.conditions[t].conditionType||(e.conditions[t]={conditionType:"Is",matcher:e.conditions[t]});return e}},{test:e=>typeof e?.target=="string",replace:e=>({...e,target:{conditions:[{conditionType:"Is",matcher:{name:e.target}}]}})}];function ou(e){let t=iu(e,C2);return t.sharedBoard||(t.sharedBoard=t.entities),t.turn||(t.turn={minMoves:1,maxMoves:1}),I2(t),pv(t,t.entities),t.phases&&Object.entries(t.phases).forEach(n=>{pv(n,t.entities)}),e.numPlayers&&(e.minPlayers=e.maxPlayers=e.numPlayers),t}function Ws(e,t,n){let r;for(let i of t){let s=ke(e,i);if(s.conditionsAreMet){r={scenario:i,conditionResults:s};break}}return r?.scenario?.result?pe(e,r.scenario.result,{results:r.conditionResults.results}):r}function gi(e,t){let n={name:t},r=ou(e);return n.setup=i=>{let{ctx:s}=i,o={_meta:{passedPlayers:[],previousPayloads:{}}},a=q2(r.entities,s);return o.bank=new Ks(a),o.sharedBoard=o.bank.getOne(i,{conditions:[{conditionType:"Is",matcher:{name:"sharedBoard"}}]}),r.personalBoard&&(o.personalBoards=i.ctx.playOrder.map(u=>o.bank.getOne(i,{conditions:[{conditionType:"Is",matcher:{name:"personalBoard",player:u}}]}))),r.initialMoves?.forEach(u=>{Hn(u,n).moveInstance.doMove({...i,G:o})}),JSON.parse(He(o))},r.moves&&(n.moves=au(r.moves,n)),r.turn&&(n.turn=dv(r.turn,n)),r.phases&&(n.phases=Object.entries(r.phases).reduce((i,[s,o])=>({...i,[s]:j2(o,n)}),{})),r.endIf&&(n.endIf=i=>{let s=Mt(i);return Ws(s,r.endIf)}),e.DEBUG_DISABLE_SECRET_STATE||(n.playerView=i=>{let{G:s,playerID:o}=Mt(i);return Object.values(s.bank.tracker).forEach(a=>{(a.rule.contentsHiddenFrom==="All"||a.rule.contentsHiddenFrom==="Others"&&(o!==a.rule.player||o==null))&&(a.spaces&&(a.spaces=a.rule.hideLength?[]:a.spaces.map(()=>s.bank.createEntity())),a.entities&&(a.entities=a.rule.hideLength?[]:a.entities.map(()=>s.bank.createEntity())))}),JSON.parse(He(s))}),n}function q2(e,t){return e.reduce((n,r)=>{let i={...r};if(i.perPlayer&&(delete i.perPlayer,i.variants?i.variants=new Array(t.numPlayers).fill().reduce((s,o,a)=>[...s,...i.variants.map(u=>({...u,player:`${a}`}))],[]):i.variants=new Array(t.numPlayers).fill().map((s,o)=>({player:`${o}`}))),i.variants){let s=i.variants;return delete i.variants,[...n,...s.map(o=>({...i,...o}))]}else return[...n,i]},[])}function dv(e,t){let n={...e};return n.onBegin=r=>{let i=Mt(r),s=e.stages?.[i.ctx.activePlayers?.[i.ctx.currentPlayer]];return i.G._meta.passedPlayers=i.G._meta.passedPlayers.filter(o=>o!==i.ctx.currentPlayer),mn(i,e.initialMoves,{game:t}),mn(i,s?.initialMoves,{game:t}),JSON.parse(He(i.G))},e.stages&&Object.entries(e.stages).forEach(([r,i])=>{i.moves&&(n.stages[r].moves=au(i.moves,t))}),e.order?.playOrder==="RotateFirst"&&(e.order.first=()=>0,e.order.next=({ctx:r})=>(r.playOrderPos+1)%r.numPlayers,n.order.playOrder=({ctx:r,G:i})=>i._meta.isAfterFirstPhase?[...r.playOrder.slice(1),r.playOrder[0]]:r.playOrder),n}function j2(e,t){let n={...e};return e.turn&&(n.turn=dv(e.turn,t)),e.moves&&(n.moves=au(e.moves,t)),n.onBegin=r=>{let i=Mt(r);return mn(i,e.initialMoves,{game:t}),i.G._meta.currentPhaseHasBeenSetUp=!0,i.G._meta.nextPhase=e.next,JSON.parse(He(i.G))},e.endIf&&(n.endIf=r=>{let i=Mt(r);if(i.G._meta.currentPhaseHasBeenSetUp){let s=Ws(i,e.endIf);if(s)return s}}),n.onEnd=({G:r})=>{r._meta.currentPhaseHasBeenSetUp=!1,r._meta.isAfterFirstPhase=!0},n}function au(e,t){return Object.entries(e).reduce((n,[r,i])=>({...n,[r]:Hn({...i,name:r},t)}),{})}var D2="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";var mv=(e=21)=>{let t="",n=e|0;for(;n--;)t+=D2[Math.random()*64|0];return t};function st(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];if(0)var i,s;throw Error("[Immer] minified error nr: "+e+(n.length?" "+n.map(function(o){return"'"+o+"'"}).join(","):"")+". Find the full error at: https://bit.ly/3cXEKWf")}function Wn(e){return!!e&&!!e[Je]}function yn(e){var t;return!!e&&(function(n){if(!n||typeof n!="object")return!1;var r=Object.getPrototypeOf(n);if(r===null)return!0;var i=Object.hasOwnProperty.call(r,"constructor")&&r.constructor;return i===Object||typeof i=="function"&&Function.toString.call(i)===z2}(e)||Array.isArray(e)||!!e[Pv]||!!(!((t=e.constructor)===null||t===void 0)&&t[Pv])||yu(e)||vu(e))}function vi(e,t,n){n===void 0&&(n=!1),Jn(e)===0?(n?Object.keys:Pu)(e).forEach(function(r){n&&typeof r=="symbol"||t(r,e[r],e)}):e.forEach(function(r,i){return t(i,r,e)})}function Jn(e){var t=e[Je];return t?t.i>3?t.i-4:t.i:Array.isArray(e)?1:yu(e)?2:vu(e)?3:0}function pu(e,t){return Jn(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function R2(e,t){return Jn(e)===2?e.get(t):e[t]}function Ev(e,t,n){var r=Jn(e);r===2?e.set(t,n):r===3?e.add(n):e[t]=n}function B2(e,t){return e===t?e!==0||1/e==1/t:e!=e&&t!=t}function yu(e){return U2&&e instanceof Map}function vu(e){return V2&&e instanceof Set}function gn(e){return e.o||e.t}function bu(e){if(Array.isArray(e))return Array.prototype.slice.call(e);var t=K2(e);delete t[Je];for(var n=Pu(t),r=0;r<n.length;r++){var i=n[r],s=t[i];s.writable===!1&&(s.writable=!0,s.configurable=!0),(s.get||s.set)&&(t[i]={configurable:!0,writable:!0,enumerable:s.enumerable,value:e[i]})}return Object.create(Object.getPrototypeOf(e),t)}function _u(e,t){return t===void 0&&(t=!1),wu(e)||Wn(e)||!yn(e)||(Jn(e)>1&&(e.set=e.add=e.clear=e.delete=L2),Object.freeze(e),t&&vi(e,function(n,r){return _u(r,!0)},!0)),e}function L2(){st(2)}function wu(e){return e==null||typeof e!="object"||Object.isFrozen(e)}function dt(e){var t=H2[e];return t||st(18,e),t}function gv(){return bi}function uu(e,t){t&&(dt("Patches"),e.u=[],e.s=[],e.v=t)}function Js(e){hu(e),e.p.forEach(G2),e.p=null}function hu(e){e===bi&&(bi=e.l)}function yv(e){return bi={p:[],l:bi,h:e,m:!0,_:0}}function G2(e){var t=e[Je];t.i===0||t.i===1?t.j():t.g=!0}function cu(e,t){t._=t.p.length;var n=t.p[0],r=e!==void 0&&e!==n;return t.h.O||dt("ES5").S(t,e,r),r?(n[Je].P&&(Js(t),st(4)),yn(e)&&(e=Ys(t,e),t.l||$s(t,e)),t.u&&dt("Patches").M(n[Je].t,e,t.u,t.s)):e=Ys(t,n,[]),Js(t),t.u&&t.v(t.u,t.s),e!==kv?e:void 0}function Ys(e,t,n){if(wu(t))return t;var r=t[Je];if(!r)return vi(t,function(a,u){return vv(e,r,t,a,u,n)},!0),t;if(r.A!==e)return t;if(!r.P)return $s(e,r.t,!0),r.t;if(!r.I){r.I=!0,r.A._--;var i=r.i===4||r.i===5?r.o=bu(r.k):r.o,s=i,o=!1;r.i===3&&(s=new Set(i),i.clear(),o=!0),vi(s,function(a,u){return vv(e,r,i,a,u,n,o)}),$s(e,i,!1),n&&e.u&&dt("Patches").N(r,n,e.u,e.s)}return r.o}function vv(e,t,n,r,i,s,o){if(Wn(i)){var a=Ys(e,i,s&&t&&t.i!==3&&!pu(t.R,r)?s.concat(r):void 0);if(Ev(n,r,a),!Wn(a))return;e.m=!1}else o&&n.add(i);if(yn(i)&&!wu(i)){if(!e.h.D&&e._<1)return;Ys(e,i),t&&t.A.l||$s(e,i)}}function $s(e,t,n){n===void 0&&(n=!1),!e.l&&e.h.D&&e.m&&_u(t,n)}function lu(e,t){var n=e[Je];return(n?gn(n):e)[t]}function bv(e,t){if(t in e)for(var n=Object.getPrototypeOf(e);n;){var r=Object.getOwnPropertyDescriptor(n,t);if(r)return r;n=Object.getPrototypeOf(n)}}function du(e){e.P||(e.P=!0,e.l&&du(e.l))}function fu(e){e.o||(e.o=bu(e.t))}function mu(e,t,n){var r=yu(t)?dt("MapSet").F(t,n):vu(t)?dt("MapSet").T(t,n):e.O?function(i,s){var o=Array.isArray(i),a={i:o?1:0,A:s?s.A:gv(),P:!1,I:!1,R:{},l:s,t:i,k:null,o:null,j:null,C:!1},u=a,c=gu;o&&(u=[a],c=yi);var l=Proxy.revocable(u,c),f=l.revoke,p=l.proxy;return a.k=p,a.j=f,p}(t,n):dt("ES5").J(t,n);return(n?n.A:gv()).p.push(r),r}function F2(e){return Wn(e)||st(22,e),function t(n){if(!yn(n))return n;var r,i=n[Je],s=Jn(n);if(i){if(!i.P&&(i.i<4||!dt("ES5").K(i)))return i.t;i.I=!0,r=_v(n,s),i.I=!1}else r=_v(n,s);return vi(r,function(o,a){i&&R2(i.t,o)===a||Ev(r,o,t(a))}),s===3?new Set(r):r}(e)}function _v(e,t){switch(t){case 2:return new Map(e);case 3:return Array.from(e)}return bu(e)}var wv,bi,Ou=typeof Symbol<"u"&&typeof Symbol("x")=="symbol",U2=typeof Map<"u",V2=typeof Set<"u",Ov=typeof Proxy<"u"&&Proxy.revocable!==void 0&&typeof Reflect<"u",kv=Ou?Symbol.for("immer-nothing"):((wv={})["immer-nothing"]=!0,wv),Pv=Ou?Symbol.for("immer-draftable"):"__$immer_draftable",Je=Ou?Symbol.for("immer-state"):"__$immer_state";var z2=""+Object.prototype.constructor,Pu=typeof Reflect<"u"&&Reflect.ownKeys?Reflect.ownKeys:Object.getOwnPropertySymbols!==void 0?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Object.getOwnPropertyNames,K2=Object.getOwnPropertyDescriptors||function(e){var t={};return Pu(e).forEach(function(n){t[n]=Object.getOwnPropertyDescriptor(e,n)}),t},H2={},gu={get:function(e,t){if(t===Je)return e;var n=gn(e);if(!pu(n,t))return function(i,s,o){var a,u=bv(s,o);return u?"value"in u?u.value:(a=u.get)===null||a===void 0?void 0:a.call(i.k):void 0}(e,n,t);var r=n[t];return e.I||!yn(r)?r:r===lu(e.t,t)?(fu(e),e.o[t]=mu(e.A.h,r,e)):r},has:function(e,t){return t in gn(e)},ownKeys:function(e){return Reflect.ownKeys(gn(e))},set:function(e,t,n){var r=bv(gn(e),t);if(r?.set)return r.set.call(e.k,n),!0;if(!e.P){var i=lu(gn(e),t),s=i?.[Je];if(s&&s.t===n)return e.o[t]=n,e.R[t]=!1,!0;if(B2(n,i)&&(n!==void 0||pu(e.t,t)))return!0;fu(e),du(e)}return e.o[t]===n&&(n!==void 0||t in e.o)||Number.isNaN(n)&&Number.isNaN(e.o[t])||(e.o[t]=n,e.R[t]=!0),!0},deleteProperty:function(e,t){return lu(e.t,t)!==void 0||t in e.t?(e.R[t]=!1,fu(e),du(e)):delete e.R[t],e.o&&delete e.o[t],!0},getOwnPropertyDescriptor:function(e,t){var n=gn(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r&&{writable:!0,configurable:e.i!==1||t!=="length",enumerable:r.enumerable,value:n[t]}},defineProperty:function(){st(11)},getPrototypeOf:function(e){return Object.getPrototypeOf(e.t)},setPrototypeOf:function(){st(12)}},yi={};vi(gu,function(e,t){yi[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}}),yi.deleteProperty=function(e,t){return yi.set.call(this,e,t,void 0)},yi.set=function(e,t,n){return gu.set.call(this,e[0],t,n,e[0])};var W2=function(){function e(n){var r=this;this.O=Ov,this.D=!0,this.produce=function(i,s,o){if(typeof i=="function"&&typeof s!="function"){var a=s;s=i;var u=r;return function(y){var m=this;y===void 0&&(y=a);for(var b=arguments.length,g=Array(b>1?b-1:0),O=1;O<b;O++)g[O-1]=arguments[O];return u.produce(y,function(I){var j;return(j=s).call.apply(j,[m,I].concat(g))})}}var c;if(typeof s!="function"&&st(6),o!==void 0&&typeof o!="function"&&st(7),yn(i)){var l=yv(r),f=mu(r,i,void 0),p=!0;try{c=s(f),p=!1}finally{p?Js(l):hu(l)}return typeof Promise<"u"&&c instanceof Promise?c.then(function(y){return uu(l,o),cu(y,l)},function(y){throw Js(l),y}):(uu(l,o),cu(c,l))}if(!i||typeof i!="object"){if((c=s(i))===void 0&&(c=i),c===kv&&(c=void 0),r.D&&_u(c,!0),o){var h=[],d=[];dt("Patches").M(i,c,h,d),o(h,d)}return c}st(21,i)},this.produceWithPatches=function(i,s){if(typeof i=="function")return function(c){for(var l=arguments.length,f=Array(l>1?l-1:0),p=1;p<l;p++)f[p-1]=arguments[p];return r.produceWithPatches(c,function(h){return i.apply(void 0,[h].concat(f))})};var o,a,u=r.produce(i,s,function(c,l){o=c,a=l});return typeof Promise<"u"&&u instanceof Promise?u.then(function(c){return[c,o,a]}):[u,o,a]},typeof n?.useProxies=="boolean"&&this.setUseProxies(n.useProxies),typeof n?.autoFreeze=="boolean"&&this.setAutoFreeze(n.autoFreeze)}var t=e.prototype;return t.createDraft=function(n){yn(n)||st(8),Wn(n)&&(n=F2(n));var r=yv(this),i=mu(this,n,void 0);return i[Je].C=!0,hu(r),i},t.finishDraft=function(n,r){var i=n&&n[Je],s=i.A;return uu(s,r),cu(void 0,s)},t.setAutoFreeze=function(n){this.D=n},t.setUseProxies=function(n){n&&!Ov&&st(20),this.O=n},t.applyPatches=function(n,r){var i;for(i=r.length-1;i>=0;i--){var s=r[i];if(s.path.length===0&&s.op==="replace"){n=s.value;break}}i>-1&&(r=r.slice(i+1));var o=dt("Patches").$;return Wn(n)?o(n,r):this.produce(n,function(a){return o(a,r)})},e}(),Ye=new W2,J2=Ye.produce,j6=Ye.produceWithPatches.bind(Ye),D6=Ye.setAutoFreeze.bind(Ye),R6=Ye.setUseProxies.bind(Ye),B6=Ye.applyPatches.bind(Ye),L6=Ye.createDraft.bind(Ye),G6=Ye.finishDraft.bind(Ye),Av=J2;var Eu=class{constructor(t){let n=Y2();this.c=1,this.s0=n(" "),this.s1=n(" "),this.s2=n(" "),this.s0-=n(t),this.s0<0&&(this.s0+=1),this.s1-=n(t),this.s1<0&&(this.s1+=1),this.s2-=n(t),this.s2<0&&(this.s2+=1)}next(){let t=2091639*this.s0+this.c*23283064365386963e-26;return this.s0=this.s1,this.s1=this.s2,this.s2=t-(this.c=Math.trunc(t))}};function Y2(){let e=4022871197;return function(n){let r=n.toString();for(let i=0;i<r.length;i++){e+=r.charCodeAt(i);let s=.02519603282416938*e;e=s>>>0,s-=e,s*=e,e=s>>>0,s-=e,e+=s*4294967296}return(e>>>0)*23283064365386963e-26}}function xv(e,t){return t.c=e.c,t.s0=e.s0,t.s1=e.s1,t.s2=e.s2,t}function ku(e,t){let n=new Eu(e),r=n.next.bind(n);return t&&xv(t,n),r.state=()=>xv(n,{}),r}var Xs=class{constructor(t){this.state=t||{seed:"0"},this.used=!1}static seed(){return Date.now().toString(36).slice(-10)}isUsed(){return this.used}getState(){return this.state}_random(){this.used=!0;let t=this.state,n=t.prngstate?"":t.seed,r=ku(n,t.prngstate),i=r();return this.state={...t,prngstate:r.state()},i}api(){let t=this._random.bind(this),n={D4:4,D6:6,D8:8,D10:10,D12:12,D20:20},r={};for(let s in n){let o=n[s];r[s]=a=>a===void 0?Math.floor(t()*o)+1:Array.from({length:a}).map(()=>Math.floor(t()*o)+1)}function i(s=6,o){return o===void 0?Math.floor(t()*s)+1:Array.from({length:o}).map(()=>Math.floor(t()*s)+1)}return{...r,Die:i,Number:()=>t(),Shuffle:s=>{let o=[...s],a=s.length,u=0,c=Array.from({length:a});for(;a;){let l=Math.trunc(a*t());c[u++]=o[l],o[l]=o[--a]}return c},_private:this}}},Sv={name:"random",noClient:({api:e})=>e._private.isUsed(),flush:({api:e})=>e._private.getState(),api:({data:e})=>new Xs(e).api(),setup:({game:e})=>{let{seed:t}=e;return t===void 0&&(t=Xs.seed()),{seed:t}},playerView:()=>{}};var $2=he(tn()),_i="MAKE_MOVE",Yn="GAME_EVENT",wi="REDO",Oi="RESET",Pi="SYNC",Ei="UNDO",ki="UPDATE",Ai="PATCH",Su="PLUGIN",$n="STRIP_TRANSIENTS",Tu=(e,t,n,r)=>({type:_i,payload:{type:e,args:t,playerID:n,credentials:r}}),vn=(e,t,n,r)=>({type:Yn,payload:{type:e,args:t,playerID:n,credentials:r}}),Tv=(e,t,n,r)=>({type:Yn,payload:{type:e,args:t,playerID:n,credentials:r},automatic:!0}),xi=e=>({type:Pi,state:e.state,log:e.log,initialState:e.initialState,clientOnly:!0}),Mu=(e,t,n,r)=>({type:Ai,prevStateID:e,stateID:t,patch:n,deltalog:r,clientOnly:!0}),Iu=(e,t)=>({type:ki,state:e,deltalog:t,clientOnly:!0}),Nu=e=>({type:Oi,state:e,clientOnly:!0}),Cu=(e,t)=>({type:Ei,payload:{type:null,args:null,playerID:e,credentials:t}}),qu=(e,t)=>({type:wi,payload:{type:null,args:null,playerID:e,credentials:t}}),X2=(e,t,n,r)=>({type:Su,payload:{type:e,args:t,playerID:n,credentials:r}}),ju=()=>({type:$n}),Mv=Object.freeze({__proto__:null,makeMove:Tu,gameEvent:vn,automaticGameEvent:Tv,sync:xi,patch:Mu,update:Iu,reset:Nu,undo:Cu,redo:qu,plugin:X2,stripTransients:ju}),Zs="INVALID_MOVE",Q2={name:"plugin-immer",fnWrap:e=>(t,...n)=>{let r=!1,i=Av(t.G,s=>{let o=e({...t,G:s},...n);if(o===Zs){r=!0;return}return o});return r?Zs:i}},Re;(function(e){e.MOVE="MOVE",e.GAME_ON_END="GAME_ON_END",e.PHASE_ON_BEGIN="PHASE_ON_BEGIN",e.PHASE_ON_END="PHASE_ON_END",e.TURN_ON_BEGIN="TURN_ON_BEGIN",e.TURN_ON_MOVE="TURN_ON_MOVE",e.TURN_ON_END="TURN_ON_END"})(Re||(Re={}));var It;(function(e){e.CalledOutsideHook="Events must be called from moves or the `onBegin`, `onEnd`, and `onMove` hooks.\nThis error probably means you called an event from other game code, like an `endIf` trigger or one of the `turn.order` methods.",e.EndTurnInOnEnd="`endTurn` is disallowed in `onEnd` hooks \u2014 the turn is already ending.",e.MaxTurnEndings=`Maximum number of turn endings exceeded for this update.
|
|
7
|
+
`,n+1);while(n>=0&&n<this.pos);return{line:e,column:t}};Te.prototype.parseError=function(e){var t=this.getCoordinates();throw new Error("parse error ["+t.line+":"+t.column+"]: "+e)};function _e(e,t,n){this.parser=e,this.tokens=t,this.current=null,this.nextToken=null,this.next(),this.savedCurrent=null,this.savedNextToken=null,this.allowMemberAccess=n.allowMemberAccess!==!1}_e.prototype.next=function(){return this.current=this.nextToken,this.nextToken=this.tokens.next()};_e.prototype.tokenMatches=function(e,t){return typeof t>"u"?!0:Array.isArray(t)?Bn(t,e.value):typeof t=="function"?t(e):e.value===t};_e.prototype.save=function(){this.savedCurrent=this.current,this.savedNextToken=this.nextToken,this.tokens.save()};_e.prototype.restore=function(){this.tokens.restore(),this.current=this.savedCurrent,this.nextToken=this.savedNextToken};_e.prototype.accept=function(e,t){return this.nextToken.type===e&&this.tokenMatches(this.nextToken,t)?(this.next(),!0):!1};_e.prototype.expect=function(e,t){if(!this.accept(e,t)){var n=this.tokens.getCoordinates();throw new Error("parse error ["+n.line+":"+n.column+"]: Expected "+(t||e))}};_e.prototype.parseAtom=function(e){var t=this.tokens.unaryOps;function n(i){return i.value in t}if(this.accept(Wa)||this.accept(me,n))e.push(new re(xt,this.current.value));else if(this.accept(Ls))e.push(new re(tt,this.current.value));else if(this.accept(qg))e.push(new re(tt,this.current.value));else if(this.accept(St,"("))this.parseExpression(e),this.expect(St,")");else if(this.accept(Fn,"["))if(this.accept(Fn,"]"))e.push(new re(Gn,0));else{var r=this.parseArrayList(e);e.push(new re(Gn,r))}else throw new Error("unexpected "+this.nextToken)};_e.prototype.parseExpression=function(e){var t=[];this.parseUntilEndStatement(e,t)||(this.parseVariableAssignmentExpression(t),!this.parseUntilEndStatement(e,t)&&this.pushExpression(e,t))};_e.prototype.pushExpression=function(e,t){for(var n=0,r=t.length;n<r;n++)e.push(t[n])};_e.prototype.parseUntilEndStatement=function(e,t){return this.accept(Ja)?(this.nextToken&&this.nextToken.type!==Dr&&!(this.nextToken.type===St&&this.nextToken.value===")")&&t.push(new re(Rs)),this.nextToken.type!==Dr&&this.parseExpression(t),e.push(new re(ze,t)),!0):!1};_e.prototype.parseArrayList=function(e){for(var t=0;!this.accept(Fn,"]");)for(this.parseExpression(e),++t;this.accept(Gs);)this.parseExpression(e),++t;return t};_e.prototype.parseVariableAssignmentExpression=function(e){for(this.parseConditionalExpression(e);this.accept(me,"=");){var t=e.pop(),n=[],r=e.length-1;if(t.type===Ln){if(!this.tokens.isOperatorEnabled("()="))throw new Error("function definition is not permitted");for(var i=0,s=t.value+1;i<s;i++){var o=r-i;e[o].type===xt&&(e[o]=new re(pn,e[o].value))}this.parseVariableAssignmentExpression(n),e.push(new re(ze,n)),e.push(new re(Ds,t.value));continue}if(t.type!==xt&&t.type!==hn)throw new Error("expected variable for assignment");this.parseVariableAssignmentExpression(n),e.push(new re(pn,t.value)),e.push(new re(ze,n)),e.push(Tt("="))}};_e.prototype.parseConditionalExpression=function(e){for(this.parseOrExpression(e);this.accept(me,"?");){var t=[],n=[];this.parseConditionalExpression(t),this.expect(me,":"),this.parseConditionalExpression(n),e.push(new re(ze,t)),e.push(new re(ze,n)),e.push(Ng("?"))}};_e.prototype.parseOrExpression=function(e){for(this.parseAndExpression(e);this.accept(me,"or");){var t=[];this.parseAndExpression(t),e.push(new re(ze,t)),e.push(Tt("or"))}};_e.prototype.parseAndExpression=function(e){for(this.parseComparison(e);this.accept(me,"and");){var t=[];this.parseComparison(t),e.push(new re(ze,t)),e.push(Tt("and"))}};var IT=["==","!=","<","<=",">=",">","in"];_e.prototype.parseComparison=function(e){for(this.parseAddSub(e);this.accept(me,IT);){var t=this.current;this.parseAddSub(e),e.push(Tt(t.value))}};var NT=["+","-","||"];_e.prototype.parseAddSub=function(e){for(this.parseTerm(e);this.accept(me,NT);){var t=this.current;this.parseTerm(e),e.push(Tt(t.value))}};var CT=["*","/","%"];_e.prototype.parseTerm=function(e){for(this.parseFactor(e);this.accept(me,CT);){var t=this.current;this.parseFactor(e),e.push(Tt(t.value))}};_e.prototype.parseFactor=function(e){var t=this.tokens.unaryOps;function n(i){return i.value in t}if(this.save(),this.accept(me,n)){if(this.current.value!=="-"&&this.current.value!=="+"){if(this.nextToken.type===St&&this.nextToken.value==="("){this.restore(),this.parseExponential(e);return}else if(this.nextToken.type===Ja||this.nextToken.type===Gs||this.nextToken.type===Dr||this.nextToken.type===St&&this.nextToken.value===")"){this.restore(),this.parseAtom(e);return}}var r=this.current;this.parseFactor(e),e.push(Bs(r.value))}else this.parseExponential(e)};_e.prototype.parseExponential=function(e){for(this.parsePostfixExpression(e);this.accept(me,"^");)this.parseFactor(e),e.push(Tt("^"))};_e.prototype.parsePostfixExpression=function(e){for(this.parseFunctionCall(e);this.accept(me,"!");)e.push(Bs("!"))};_e.prototype.parseFunctionCall=function(e){var t=this.tokens.unaryOps;function n(s){return s.value in t}if(this.accept(me,n)){var r=this.current;this.parseAtom(e),e.push(Bs(r.value))}else for(this.parseMemberExpression(e);this.accept(St,"(");)if(this.accept(St,")"))e.push(new re(Ln,0));else{var i=this.parseArgumentList(e);e.push(new re(Ln,i))}};_e.prototype.parseArgumentList=function(e){for(var t=0;!this.accept(St,")");)for(this.parseExpression(e),++t;this.accept(Gs);)this.parseExpression(e),++t;return t};_e.prototype.parseMemberExpression=function(e){for(this.parseAtom(e);this.accept(me,".")||this.accept(Fn,"[");){var t=this.current;if(t.value==="."){if(!this.allowMemberAccess)throw new Error('unexpected ".", member access is not permitted');this.expect(Wa),e.push(new re(hn,this.current.value))}else if(t.value==="["){if(!this.tokens.isOperatorEnabled("["))throw new Error('unexpected "[]", arrays are disabled');this.parseExpression(e),this.expect(Fn,"]"),e.push(Tt("["))}else throw new Error("unexpected symbol: "+t.value)}};function qT(e,t){return Number(e)+Number(t)}function jT(e,t){return e-t}function DT(e,t){return e*t}function RT(e,t){return e/t}function BT(e,t){return e%t}function LT(e,t){return Array.isArray(e)&&Array.isArray(t)?e.concat(t):""+e+t}function GT(e,t){return e===t}function FT(e,t){return e!==t}function UT(e,t){return e>t}function VT(e,t){return e<t}function zT(e,t){return e>=t}function KT(e,t){return e<=t}function HT(e,t){return!!(e&&t)}function WT(e,t){return!!(e||t)}function JT(e,t){return Bn(t,e)}function YT(e){return(Math.exp(e)-Math.exp(-e))/2}function $T(e){return(Math.exp(e)+Math.exp(-e))/2}function XT(e){return e===1/0?1:e===-1/0?-1:(Math.exp(e)-Math.exp(-e))/(Math.exp(e)+Math.exp(-e))}function QT(e){return e===-1/0?e:Math.log(e+Math.sqrt(e*e+1))}function ZT(e){return Math.log(e+Math.sqrt(e*e-1))}function eM(e){return Math.log((1+e)/(1-e))/2}function Ag(e){return Math.log(e)*Math.LOG10E}function tM(e){return-e}function nM(e){return!e}function rM(e){return e<0?Math.ceil(e):Math.floor(e)}function iM(e){return Math.random()*(e||1)}function xg(e){return Ya(e+1)}function sM(e){return isFinite(e)&&e===Math.round(e)}var oM=4.7421875,Fa=[.9999999999999971,57.15623566586292,-59.59796035547549,14.136097974741746,-.4919138160976202,3399464998481189e-20,4652362892704858e-20,-9837447530487956e-20,.0001580887032249125,-.00021026444172410488,.00021743961811521265,-.0001643181065367639,8441822398385275e-20,-26190838401581408e-21,36899182659531625e-22];function Ya(e){var t,n;if(sM(e)){if(e<=0)return isFinite(e)?1/0:NaN;if(e>171)return 1/0;for(var r=e-2,i=e-1;r>1;)i*=r,r--;return i===0&&(i=1),i}if(e<.5)return Math.PI/(Math.sin(Math.PI*e)*Ya(1-e));if(e>=171.35)return 1/0;if(e>85){var s=e*e,o=s*e,a=o*e,u=a*e;return Math.sqrt(2*Math.PI/e)*Math.pow(e/Math.E,e)*(1+1/(12*e)+1/(288*s)-139/(51840*o)-571/(2488320*a)+163879/(209018880*u)+5246819/(75246796800*u*e))}--e,n=Fa[0];for(var c=1;c<Fa.length;++c)n+=Fa[c]/(e+c);return t=e+oM+.5,Math.sqrt(2*Math.PI)*Math.pow(t,e+.5)*Math.exp(-t)*n}function aM(e){return Array.isArray(e)?e.length:String(e).length}function Sg(){for(var e=0,t=0,n=0;n<arguments.length;n++){var r=Math.abs(arguments[n]),i;t<r?(i=t/r,e=e*i*i+1,t=r):r>0?(i=r/t,e+=i*i):e+=r}return t===1/0?1/0:t*Math.sqrt(e)}function Tg(e,t,n){return e?t:n}function uM(e,t){return typeof t>"u"||+t==0?Math.round(e):(e=+e,t=-+t,isNaN(e)||!(typeof t=="number"&&t%1===0)?NaN:(e=e.toString().split("e"),e=Math.round(+(e[0]+"e"+(e[1]?+e[1]-t:-t))),e=e.toString().split("e"),+(e[0]+"e"+(e[1]?+e[1]+t:t))))}function cM(e,t,n){return n&&(n[e]=t),t}function lM(e,t){return e[t|0]}function fM(e){return arguments.length===1&&Array.isArray(e)?Math.max.apply(Math,e):Math.max.apply(Math,arguments)}function pM(e){return arguments.length===1&&Array.isArray(e)?Math.min.apply(Math,e):Math.min.apply(Math,arguments)}function hM(e,t){if(typeof e!="function")throw new Error("First argument to map is not a function");if(!Array.isArray(t))throw new Error("Second argument to map is not an array");return t.map(function(n,r){return e(n,r)})}function dM(e,t,n){if(typeof e!="function")throw new Error("First argument to fold is not a function");if(!Array.isArray(n))throw new Error("Second argument to fold is not an array");return n.reduce(function(r,i,s){return e(r,i,s)},t)}function mM(e,t){if(typeof e!="function")throw new Error("First argument to filter is not a function");if(!Array.isArray(t))throw new Error("Second argument to filter is not an array");return t.filter(function(n,r){return e(n,r)})}function gM(e,t){if(!(Array.isArray(t)||typeof t=="string"))throw new Error("Second argument to indexOf is not a string or array");return t.indexOf(e)}function yM(e,t){if(!Array.isArray(t))throw new Error("Second argument to join is not an array");return t.join(e)}function vM(e){return(e>0)-(e<0)||+e}var Mg=1/3;function bM(e){return e<0?-Math.pow(-e,Mg):Math.pow(e,Mg)}function _M(e){return Math.exp(e)-1}function wM(e){return Math.log(1+e)}function OM(e){return Math.log(e)/Math.LN2}function Ht(e){this.options=e||{},this.unaryOps={sin:Math.sin,cos:Math.cos,tan:Math.tan,asin:Math.asin,acos:Math.acos,atan:Math.atan,sinh:Math.sinh||YT,cosh:Math.cosh||$T,tanh:Math.tanh||XT,asinh:Math.asinh||QT,acosh:Math.acosh||ZT,atanh:Math.atanh||eM,sqrt:Math.sqrt,cbrt:Math.cbrt||bM,log:Math.log,log2:Math.log2||OM,ln:Math.log,lg:Math.log10||Ag,log10:Math.log10||Ag,expm1:Math.expm1||_M,log1p:Math.log1p||wM,abs:Math.abs,ceil:Math.ceil,floor:Math.floor,round:Math.round,trunc:Math.trunc||rM,"-":tM,"+":Number,exp:Math.exp,not:nM,length:aM,"!":xg,sign:Math.sign||vM},this.binaryOps={"+":qT,"-":jT,"*":DT,"/":RT,"%":BT,"^":Math.pow,"||":LT,"==":GT,"!=":FT,">":UT,"<":VT,">=":zT,"<=":KT,and:HT,or:WT,in:JT,"=":cM,"[":lM},this.ternaryOps={"?":Tg},this.functions={random:iM,fac:xg,min:pM,max:fM,hypot:Math.hypot||Sg,pyt:Math.hypot||Sg,pow:Math.pow,atan2:Math.atan2,if:Tg,gamma:Ya,roundTo:uM,map:hM,fold:dM,filter:mM,indexOf:gM,join:yM},this.consts={E:Math.E,PI:Math.PI,true:!0,false:!1}}Ht.prototype.parse=function(e){var t=[],n=new _e(this,new Te(this,e),{allowMemberAccess:this.options.allowMemberAccess});return n.parseExpression(t),n.expect(Dr,"EOF"),new it(t,this)};Ht.prototype.evaluate=function(e,t){return this.parse(e).evaluate(t)};var Dg=new Ht;Ht.parse=function(e){return Dg.parse(e)};Ht.evaluate=function(e,t){return Dg.parse(e).evaluate(t)};var Ig={"+":"add","-":"subtract","*":"multiply","/":"divide","%":"remainder","^":"power","!":"factorial","<":"comparison",">":"comparison","<=":"comparison",">=":"comparison","==":"comparison","!=":"comparison","||":"concatenate",and:"logical",or:"logical",not:"logical","?":"conditional",":":"conditional","=":"assignment","[":"array","()=":"fndef"};function PM(e){return Ig.hasOwnProperty(e)?Ig[e]:e}Ht.prototype.isOperatorEnabled=function(e){var t=PM(e),n=this.options.operators||{};return!(t in n)||!!n[t]};var Rg=new Ht;Rg.functions.sum=e=>e.reduce((t,n)=>t+n,0);function Rr(e,t,n){let r=pe(e,t.arguments,n);return Rg.evaluate(t.expression,r)}var Bg=he(qs()),EM=["state"];function Br(e,t,n,r){return!EM.includes(r)&&(0,Bg.default)(t)?e.G.bank.find(e,t,n):t}var kM=["conditions","move","then","mapping"];function pe(e,t,n,r){if(!(0,Gg.default)(t)&&!Array.isArray(t))return t;let i=Array.isArray(t)?[...t]:{...t};Object.entries(t).forEach(([a,u])=>{kM.includes(a)||(i[a]=pe(e,u,n,a))});let s=AM(e,i,n);return s?.resolveAsEntity||r==="target"||r==="targets"?Br(e,s,n,r):s}function AM(e,t,n){if(t?.type==="expression")return Rr(e,{...t,arguments:pe(e,t.arguments,n,"arguments")},n);if(t?.type==="count")return e.G.bank.findAll(e,t,n).length;if(t?.type==="contextPath")return ln(n,t.path);if(t?.type==="ctxPath")return ln(e.ctx,t.path);if(t?.type==="gamePath")return ln(e.G,t.path);if(t?.type==="relativePath"||t?.type==="RelativePath"){let r=pe(e,t.target,n,"target");return ln(r.attributes,t.path)??null}else if(t?.type==="parent"||t?.type==="Parent"){let r=t.target?pe(e,t.target,n,"target"):n.originalTarget;return e.G.bank.findParent(r)??null}else{if(t?.type==="map")return Lg(e,t.targets,t.mapping,n).map(r=>r.value);if(t?.type==="mapMax"){let r=Lg(e,t.targets,t.mapping,n),i,s=[];for(let o=0,a=r.length;o<a;o++){let{target:u,value:c}=r[o];i===void 0||c>i?(i=c,s.length=0,s.push(u)):c===i&&s.push(u)}return s}else if(t?.type==="pick"||t?.type==="Pick"){let r=pe(e,t.target,n,"target");return(0,Fg.default)(pe(e,r.attributes,n,"attributes"),t.properties)}else if(t?.type==="coordinates"||t?.type==="Coordinates"){let r=t.target?pe(e,t.target,n,"target"):n.originalTarget;return e.G.bank.findParent(r).getCoordinates(r.rule.index)}else if(t?.type==="relativeCoordinates"){let r=t.target?pe(e,t.target,n,"target"):n.originalTarget,i=e.G.bank.findParent(r),s=i.getCoordinates(r.rule.index),o=i.getRelativeCoordinates(s,pe(e,t.location,n,"location"));return(o&&i.spaces[i.getIndex(o)])??null}else return t}}function Lg(e,t,n,r){return t.resolveAsEntity=!0,pe(e,t,r)?.map(i=>({target:i,value:pe(e,n,{...r,loopTarget:i})}))??[]}var oe=class{constructor(t){this.rule=t}check(t,n,r){let i={...n},s={...r};i.target&&(s.originalTarget=i.target);let o=pe(t,this.rule,s);return o.target!==void 0&&(i.target=o.target),this.rule.target!==void 0&&!i.target?{conditionIsMet:!1}:this.checkCondition(t,o,i,s)}isMet(...t){return this.check(...t).conditionIsMet}};var Zy=he(Fr());function d2(e,t,n){let r={...t};return delete r.state,delete r.stateGroups,pe(e,r,n)}function m2(e){return{...e.rule,...e.state}}function Qa(e,t,n,r){return(0,Zy.default)(d2(e,t,r))(m2(n))}var Ur=class extends oe{checkCondition(t,n,{target:r},i){return this.rule.entity&&r!==n.entity?{target:r,conditionIsMet:!1}:{target:r,conditionIsMet:Qa(t,n.matcher,r,i)}}};var Vr=class extends oe{checkCondition(t,n,r,i){return{conditionIsMet:!ke(t,n,r,i).conditionsAreMet}}};function Za(e,{conditions:t=[]},n,r){let i;for(let s of t){let o=dn(s).check(e,n,r);if(o.conditionIsMet){i={...o,conditionRule:s};break}}return i}var zr=class extends oe{checkCondition(t,n,r,i){return{conditionIsMet:!!Za(t,n,r,i)}}};var Kr=class extends oe{checkCondition(t,n,{target:r},i){let s=r.find(o=>{let a={...i,loopTarget:o};return ke(t,n,void 0,a).conditionsAreMet});return{conditionIsMet:!!s,result:s}}};var Hr=class extends oe{checkCondition(t,n,{target:r},i){let s=r.map(o=>{let a={...i,loopTarget:o};return ke(t,n,void 0,a)});return{conditionIsMet:s.every(o=>o.conditionsAreMet),results:s}}};var s8=he(Fr());var Wr=class extends oe{checkCondition(t,n,r,i){let{target:s}=r;if(s){let a=(s.entities??s.spaces)?.filter(u=>ke(t,n,{target:u},i).conditionsAreMet)??[];return{matches:a,conditionIsMet:!!a.length}}else return{matches:[],conditionIsMet:!1}}};var ev=he(Ga());var Jr=class extends oe{checkCondition(t,n,{targets:r}){if(r.length===1&&r[0].entities?.length)return{conditionIsMet:!0};let[i,...s]=r;return{conditionIsMet:i.entities.some(a=>{let u=dn({conditionType:"Contains",conditions:[{conditionType:"Is",matcher:(0,ev.default)(a.rule,n.properties)}]});return s.every(c=>u.isMet(t,{target:c}))})}}};var h8=he(Fr());var g2=[[1,0],[0,1],[1,1],[-1,1]],tv=new WeakMap;function y2(e,t){let n={moveInstance:t.moveInstance?.id,moveArguments:t.moveArguments};return JSON.stringify({pattern:e,context:n})}function v2(e){return(e.entities||[]).map(n=>{let r=n.entities||[];return r.length===0?"empty":r.map(i=>{let s=Object.keys(i).sort(),o={};return s.forEach(a=>{o[a]=i[a]}),JSON.stringify(o)}).sort().join("|")}).join(",")}function nv(e,t,n,r,i,s=!1){let o=[],a=t.length,u=0;for(;u<=a-r;){let c=w2(e,t,u,n,i,s);c&&o.push(c),u++}return o}function b2(e,t,n){let{width:r,height:i}=e.attributes,s=[];if(t===1&&n===0)for(let o=0;o<i;o++)s.push([0,o]);else if(t===0&&n===1)for(let o=0;o<r;o++)s.push([o,0]);else if(t===1&&n===1){for(let o=0;o<r;o++)s.push([o,0]);for(let o=1;o<i;o++)s.push([0,o])}else if(t===-1&&n===1){for(let o=0;o<r;o++)s.push([o,0]);for(let o=1;o<i;o++)s.push([r-1,o])}return s}function _2(e,t,n,r,i){let s=[],[o,a]=[t,n];for(;e.areCoordinatesValid([o,a]);)s.push(e.getSpace([o,a])),o+=r,a+=i;return s}function w2(e,t,n,r,i,s=!1){let o=n,a=[],u=t.length;for(let c of r){let{count:l,minCount:f,maxCount:p,conditions:h}=c,d,y;l!==void 0?d=y=l:f!==void 0||p!==void 0?(d=f||0,y=p||1/0):d=y=1;let m=0,b=[];for(;m<y&&o<u;){let g=s?t[u-1-o]:t[o];if(O2(e,g,h,b,i))b.push(g),m++,o++;else break}if(m<d)return null;a.push(...b)}return a.length>0?a:null}function O2(e,t,n,r=[],i){return!n||n.length===0?!0:ke(e,{conditions:n},{target:t,targets:[t,...r]},i).conditionsAreMet}function Yr(e,t,n,r){let i=y2(n,r),s=tv.get(t);s||(s=new Map,tv.set(t,s));let o=v2(t),a=s.get(i);if(a&&a.stateKey===o)return a.result;let u=[],c=n.reduce((f,p)=>f+(p.minCount||p.count||1),0);for(let[f,p]of g2){let h=b2(t,f,p);for(let[d,y]of h){let m=_2(t,d,y,f,p);if(m.length<c)continue;let b=nv(e,m,n,c,r);if(u.push(...b),b.length===0||n.length>1){let g=nv(e,m,n,c,r,!0);u.push(...g)}}}let l={matches:u,conditionIsMet:!!u.length};return s.set(i,{stateKey:o,result:l}),l}var $r=class extends oe{checkCondition(t,n,r,i){let{G:s}=t,{target:o}=r,a=s.bank.findParent(r.target),{matches:u}=Yr(t,a,n.sequence,i),c=u.filter(l=>l.some(f=>f===o));return{matches:c,conditionIsMet:!!c.length}}};var Xr=class extends oe{checkCondition(t,n,r,i){let{matches:s}=Yr(t,r.target,n.sequence,i);return{matches:s,conditionIsMet:!!s.length}}};var Qr=class extends oe{checkCondition(t,n,r,i){return{conditionIsMet:r.target.spaces.every(s=>s?.entities.length)}}};function Zr(e,t,n){let r=Ft(He(e.G),ht),i={...e,G:r},s={...t,arguments:{}};return Object.entries(t.arguments).forEach(([o,a])=>{s.arguments[o]=a.abstract?a:r.bank.locate(typeof a=="number"?a:a.entityId)}),n.moveInstance.doMove(i,s,n,{skipCheck:!0}),r}var P2={PlaceNew:["destination"],RemoveEntity:["entity"],MoveEntity:["entity","destination"],TakeFrom:["source","destination"],SetState:["entity","state"]},ei=class extends oe{checkCondition(t,n,{target:r,targets:i=[r]},s){let o={arguments:i.reduce((p,h,d)=>({...p,[P2[s.moveInstance.rule.moveType][d]]:h}),{})},a=Zr(t,o,s),u={};r?u={target:a.bank.locate(r.entityId)}:i&&(u={targets:i.map(p=>a.bank.locate(p.entityId))});let c=ke({...t,G:a},n,u,s),l=c.conditionsAreMet;return{results:l?eu(c.results,p=>t.G.bank.locate(p)):c.results,conditionIsMet:l}}};function eu(e,t,n=new WeakSet){if(typeof e!="object"||e===null||n.has(e))return e;if(n.add(e),e.entityId!==void 0)return t(e.entityId);if(Array.isArray(e))return e.map(r=>eu(r,t,n));{let r={};for(let i in e)e.hasOwnProperty(i)&&(r[i]=eu(e[i],t,n));return r}}var rv=he(qs());function iv(e,t=new Set){if(!e||typeof e!="object")return t;e.type==="contextPath"&&Array.isArray(e.path)&&e.path[0]==="moveArguments"&&e.path[1]&&t.add(e.path[1]);for(let n of Object.values(e))iv(n,t);return t}function E2(e){let t=Object.keys(e),n={},r={};t.forEach(o=>{n[o]=[],r[o]=0}),t.forEach(o=>{let a=e[o];iv(a).forEach(c=>{t.includes(c)&&c!==o&&(n[c].push(o),r[o]++)})});let i=t.filter(o=>r[o]===0),s=[];for(;i.length>0;){let o=i.shift();s.push(o),n[o].forEach(a=>{r[a]--,r[a]===0&&i.push(a)})}return s.length===t.length?s:t}function sv(e,t,n,r,i,s=0,o={}){if(s===r.length){let p={arguments:o};return t.isValid(e,p,i)}let a=r[s],u=n[a],c={...i,moveArguments:o},l=(0,rv.default)(u)?Br(e,{...u,matchMultiple:!0},c,a):u,f=Array.isArray(l)?l:l!==void 0?[l]:[];return f.length===0?!1:f.some(p=>sv(e,t,n,r,i,s+1,{...o,[a]:p}))}function tu(e,t){return Object.values(t).some(n=>{let{moveInstance:r}=n,i={moveInstance:r},o=pe(e,r.rule,i).arguments??{};if(Object.keys(o).length===0)return r.isValid(e,{arguments:{}},i);let a=E2(o);return sv(e,r,o,a,i)})}function ti(e,{game:t,playerID:n,stageName:r}){let i=e.ctx.phase,s=r??e.ctx.activePlayers?.[n??e.ctx.currentPlayer],o=t.phases?.[i]??t;return(o.turn?.stages?.[s]??o).moves??{}}var ni=class extends oe{checkCondition(t,n,r,i){return{conditionIsMet:!tu(t,ti(t,i))}}};var G8=he(Fr());var ri=class extends oe{checkCondition(t,n,r,i){let s={...i};r?.target&&(s.target=r.target);let o=Rr(t,n,s);return{result:o,conditionIsMet:!!o}}};var ii=class extends oe{checkCondition(t,n,{target:r}){let i=t.G.bank.findParent(r),s;return n.position==="First"&&(s=i.entities.indexOf(r)===0),{conditionIsMet:s}}};function dn(e){if(e.conditionType==="Is")return new Ur(e);if(e.conditionType==="Not")return new Vr(e);if(e.conditionType==="Or")return new zr(e);if(e.conditionType==="Some")return new Kr(e);if(e.conditionType==="Contains")return new Wr(e);if(e.conditionType==="ContainsSame")return new Jr(e);if(e.conditionType==="Every")return new Hr(e);if(e.conditionType==="InLine")return new $r(e);if(e.conditionType==="HasLine")return new Xr(e);if(e.conditionType==="IsFull")return new Qr(e);if(e.conditionType==="Would")return new ei(e);if(e.conditionType==="NoPossibleMoves")return new ni(e);if(e.conditionType==="Evaluate")return new ri(e);if(e.conditionType==="Position")return new ii(e)}function ke(e,t,n,r){let{conditions:i=[]}=t,s=[],o;for(let a of i){let u=dn(a).check(e,n,r);if(u.conditionIsMet)s.push(u);else{o=a;break}}return{results:s,failedAt:o,conditionsAreMet:s.length===i.length}}var nu=class{constructor(t,n){this.bank=n,this.rule=t,this.pool=[],this.remaining=+t.count||1}getOne(t,n,r){return this.getMultiple(t,1,n,r)[0]}getMultiple(t,n=1/0,r={},i){let s=[];if(this.remaining===1/0&&n===1/0)throw new Error(`Cannot get infinite pieces from slot with infinite remaining: ${this.rule.name}`);if(n!==1/0&&n>this.remaining)throw new Error(`Requested ${n} pieces but only ${this.remaining} available in slot: ${this.rule.name}`);let o=n===1/0?this.remaining:n;this.remaining!==1/0&&(this.remaining-=o);let a=Math.min(o,this.pool.length);s.push(...this.pool.splice(0,a));let u=o-a;if(u>0&&s.push(...Array.from(new Array(u)).map(()=>this.bank.createEntity(this.rule))),r.state){let c=pe(t,r.state,i);s.forEach(l=>{l.state={...l.state,...c}})}return s}returnToBank(t){t.rule.state?t.state=t.rule.state:delete t.state,this.remaining!==void 0&&(this.remaining+=1),this.pool.push(t)}},zs=nu;var ru=class{constructor(t){this.currentEntityId=0,this.tracker={},this.slots=t.map(n=>new zs(n,this))}createEntity(t={},n){let r=new ht[t.entityType||"Entity"]({bank:this,fromBank:!0,...n},t,this.currentEntityId++);return this.track(r),r}track(t){this.tracker[t.entityId]=t}locate(t){return this.tracker[t]}findAll(t,n,r){if(!n.conditions)throw new Error(`Cannot find entity with no conditions. Rule: ${JSON.stringify(n)}`);return(0,av.default)(Object.values(this.tracker),i=>ke(t,n,{target:i},r).conditionsAreMet)}findOne(t,n,r){return this.findAll(t,n,r)[0]}find(t,n,r){return n.matchMultiple?this.findAll(t,n,r):this.findOne(t,n,r)}findParent(t){return(0,ov.default)(this.tracker,n=>n.entities?.includes(t)||n.spaces?.includes(t))}getOne(t,n,r){let i=this.getSlot(t,n,r);return i||console.error(`No matching slot for ${JSON.stringify(n)}`),i.getOne(t,{state:n.state},r)}getMultiple(t,n,r,i){let s=this.getSlots(t,n,i);return s.length||console.error(`No matching slots for ${JSON.stringify(n)}`),s.reduce((o,a)=>[...o,...a.getMultiple(t,r,{state:n.state})],[])}getSlot(t,n,r){return this.slots.find(i=>ke(t,n,{target:i},r).conditionsAreMet)}getSlots(t,n,r){return this.slots.filter(i=>ke(t,n,{target:i},r).conditionsAreMet)}returnToBank(t,n){this.findParent(n).remove(n),this.getSlot(t,n.rule).returnToBank(n),delete this.tracker[n.entityId]}},Ks=ru;var ht={Board:wr,SpaceGroup:sn,Space:rn,Grid:Ar,Bank:Ks,BankSlot:zs,Entity:Et};function Mt(e){return{...e,G:Ft(JSON.stringify(e.G),ht)}}var uv=he(aa());var we=class{constructor(t){this.rule=this.transformRule(t)}checkValidity(t,n,r){let i=Object.entries(this.rule.arguments??{});if(!i.every(([a])=>{let u=n.arguments[a];return u!==void 0&&(!Array.isArray(u)||u.length)}))return!1;let s={};for(let a=0,u=i.length;a<u;a++){let[c,l]=i[a],f=n.arguments[c],p=Array.isArray(f)?f:[f],h=[];for(let y=0,m=p.length;y<m;y++){let b=p[y],g=ke(t,l,{target:b},{...r,moveArguments:n.arguments});if(h.push(g),!g.conditionsAreMet)break}let d=h.at(-1).conditionsAreMet;if(s[c]={results:h,conditionsAreMet:d},!d)break}let o=ke(t,{conditions:this.rule.conditions},void 0,{...r,moveArguments:n.arguments});return{argumentResults:s,moveResults:o,conditionsAreMet:o.conditionsAreMet&&Object.values(s).every(a=>a.conditionsAreMet)}}isValid(t,n,r){return this.checkValidity(t,n,r).conditionsAreMet}doMove(t,n,r,{skipCheck:i=!1}={}){let s=pe(t,this.rule,r),o={...n,arguments:Object.entries(s.arguments??{}).reduce((u,[c,l])=>({...u,[c]:n?.arguments?.[c]??l}),{})};s.name&&(t.G._meta.previousPayloads[s.name]=o);let a;return i||(a=this.checkValidity(t,o,r)),!i&&!a.conditionsAreMet?uv.INVALID_MOVE:(this.do(t,s,o,r),r&&(r.previousArguments=o.arguments),{conditionResults:a})}transformRule(t){let n=t.arguments;for(let r in n){let i=n[r];i.playerChoice||(i.resolveAsEntity=!0)}return t}};var si=class extends we{do(t,n,{arguments:{entity:r,destination:i}}){Array.isArray(r)?r.forEach(s=>{t.G.bank.findParent(s)?.remove(s),i.placeEntity(s,n.position)}):(t.G.bank.findParent(r)?.remove(r),i.placeEntity(r,n.position))}};var oi=class extends we{do(t,n,{arguments:{entity:r}}){t.G.bank.returnToBank(t,r)}};var ai=class extends we{do(t,n,{arguments:{destination:r}},i){(n.matchMultiple?t.G.bank.getMultiple(t,{...n.entity,conditions:[...n.entity?.conditions||[],...n.conditions||[]]},n.count,i):[t.G.bank.getOne(t,{...n.entity,conditions:[...n.entity?.conditions||[],...n.conditions||[]]},i)]).forEach(o=>{r.placeEntity(o,n.position)})}};var ui=class extends we{do(t,n,{arguments:{source:r,destination:i}}){i.placeEntity(r.takeOne(n.arguments.source.position))}};var ci=class extends we{do(t,n,{arguments:{entity:r,state:i}}){r.state={...r.state,[i.property]:i.value}}};function mn(e,t=[],n){return t?.length&&t.forEach(r=>{Hn(r,n.game).moveInstance.doMove(e,void 0,n)}),e.G}var li=class extends we{do(t,n,r,i){t.events.setActivePlayers(n.options);let s=t.ctx.phase,o=n.options.currentPlayer?.stage,u=(i.game.phases?.[s]??i.game)?.turn?.stages?.[o];mn(t,u?.initialMoves,{...i,stageName:o})}};var fi=class extends we{do(t){t.events.endTurn()}};var pi=class extends we{do(t){t.G._meta.passedPlayers.length<t.ctx.numPlayers&&(t.G._meta.passedPlayers.push(t.ctx.currentPlayer),t.events.pass())}};var hi=class extends we{do(t,n,{arguments:{targets:r}},i){r.forEach(s=>{let o={...i,loopTarget:s};Hs(n.move).doMove(t,void 0,o)})}};var di=class extends we{do(t){t.events.endTurn()}};var mi=class extends we{do(t,n,{arguments:{target:r}}){r.entities=t.random.Shuffle(r.entities)}};function Hn(e,t){let n=Hs(e),r=function(i,s){let o=Mt(i),{G:a}=o,u=k2(s,a),c={moveInstance:n,game:t},l=n.doMove(o,u,c);if(c.moveConditionResults=[l],l!==cv.INVALID_MOVE&&e.then)for(let f of e.then){let p=Hs(f).doMove(o,{},{...c});c.moveConditionResults.push(p)}return JSON.parse(He(a))};return r.moveInstance=n,r}function k2(e,t){if(e){let n=Ft(JSON.stringify(e),ht);return n.arguments=Object.entries(n.arguments).reduce((r,[i,s])=>({...r,[i]:typeof s=="number"?t.bank.locate(s):s}),{}),n}else return e}function Hs(e){switch(e.moveType){case"MoveEntity":return new si(e);case"PlaceNew":return new ai(e);case"RemoveEntity":return new oi(e);case"TakeFrom":return new ui(e);case"SetState":return new ci(e);case"ForEach":return new hi(e);case"Pass":return new di(e);case"Shuffle":return new mi(e);case"SetActivePlayers":return new li(e);case"EndTurn":return new fi(e);case"PassTurn":return new pi(e)}}var b6=he(fv()),hv=he(Ra());function iu(e,t){return JSON.parse(JSON.stringify(e),(n,r)=>{let i=r;for(let s of t)s.test(i)&&(i=s.replace(i));return i})}var M2=[{entityType:"Space",count:"Infinity"},{entityType:"Board",name:"sharedBoard"},{name:"playerMarker",perPlayer:!0,count:"Infinity"}];function I2(e){e.entities=[...M2,...e.entities||[]]}function pv(e,t){if(e.sharedBoard){let n=e.sharedBoard.map(r=>({entity:r,destination:{name:"sharedBoard"}}));e.initialPlacements||(e.initialPlacements=[]),e.initialPlacements.unshift(...n)}if(e.personalBoard){t.push({entityType:"Board",name:"personalBoard",perPlayer:!0});let n=e.personalBoard.map(r=>({entity:r,destination:{name:"personalBoard"}}));e.initialPlacements||(e.initialPlacements=[]),e.initialPlacements.unshift(...n)}if(e.initialPlacements){let n=e.initialPlacements.map(r=>{let{state:i,...s}=r.entity,o=(0,hv.default)(t,s);return r.destination.name==="personalBoard"?{moveType:"ForEach",arguments:{targets:{type:"ctxPath",path:["playOrder"]}},move:{moveType:"PlaceNew",entity:{state:i,conditions:[{conditionType:"Is",matcher:{...s,...o.perPlayer?{player:{type:"contextPath",path:["loopTarget"]}}:{}}}]},arguments:{destination:{conditions:[{conditionType:"Is",matcher:{...r.destination,player:{type:"contextPath",path:["loopTarget"]}}}]}}}}:{moveType:"PlaceNew",entity:{state:i,conditions:[{conditionType:"Is",matcher:s}]},arguments:{destination:{conditions:[{conditionType:"Is",matcher:r.destination}]}}}});e.initialMoves||(e.initialMoves=[]),e.initialMoves.unshift(...n),delete e.initialPlacements}}var N2=[],su=[["isCurrentPlayer",{conditionType:"Is",matcher:{player:{type:"ctxPath",path:["currentPlayer"]}}}],["isEmpty",{conditionType:"Not",conditions:[{conditionType:"Contains"}]}],["ownerOfFirstResultEntity",{type:"contextPath",path:["results",0,"matches",0,0,"entities",0,"attributes","player"]}]],C2=[{test:e=>e&&typeof e=="object",replace:e=>(N2.forEach(([t,n])=>{e.hasOwnProperty(t)&&(e[n]=e[t],delete e[t])}),e)},{test:e=>typeof e=="string",replace:e=>{for(let t=0,n=su.length;t<n;t++)if(e===su[t][0])return su[t][1];return e}},{test:e=>e?.conditions,replace:e=>(Array.isArray(e.conditions)||(e.conditions=[e.conditions]),e)},{test:e=>e?.conditions,replace:e=>{for(let t=0,n=e.conditions.length;t<n;t++)e.conditions[t].conditionType||(e.conditions[t]={conditionType:"Is",matcher:e.conditions[t]});return e}},{test:e=>typeof e?.target=="string",replace:e=>({...e,target:{conditions:[{conditionType:"Is",matcher:{name:e.target}}]}})}];function ou(e){let t=iu(e,C2);return t.sharedBoard||(t.sharedBoard=t.entities),t.turn||(t.turn={minMoves:1,maxMoves:1}),I2(t),pv(t,t.entities),t.phases&&Object.entries(t.phases).forEach(n=>{pv(n,t.entities)}),e.numPlayers&&(e.minPlayers=e.maxPlayers=e.numPlayers),t}function Ws(e,t,n){let r;for(let i of t){let s=ke(e,i);if(s.conditionsAreMet){r={scenario:i,conditionResults:s};break}}return r?.scenario?.result?pe(e,r.scenario.result,{results:r.conditionResults.results}):r}function gi(e,t){let n={name:t},r=ou(e);return n.setup=i=>{let{ctx:s}=i,o={_meta:{passedPlayers:[],previousPayloads:{}}},a=q2(r.entities,s);return o.bank=new Ks(a),o.sharedBoard=o.bank.getOne(i,{conditions:[{conditionType:"Is",matcher:{name:"sharedBoard"}}]}),r.personalBoard&&(o.personalBoards=i.ctx.playOrder.map(u=>o.bank.getOne(i,{conditions:[{conditionType:"Is",matcher:{name:"personalBoard",player:u}}]}))),r.initialMoves?.forEach(u=>{Hn(u,n).moveInstance.doMove({...i,G:o})}),JSON.parse(He(o))},r.moves&&(n.moves=au(r.moves,n)),r.turn&&(n.turn=dv(r.turn,n)),r.phases&&(n.phases=Object.entries(r.phases).reduce((i,[s,o])=>({...i,[s]:j2(o,n)}),{})),r.endIf&&(n.endIf=i=>{let s=Mt(i);return Ws(s,r.endIf)}),e.DEBUG_DISABLE_SECRET_STATE||(n.playerView=i=>{let{G:s,playerID:o}=Mt(i);return Object.values(s.bank.tracker).forEach(a=>{(a.rule.contentsHiddenFrom==="All"||a.rule.contentsHiddenFrom==="Others"&&(o!==a.rule.player||o==null))&&(a.spaces&&(a.spaces=a.rule.hideLength?[]:a.spaces.map(()=>s.bank.createEntity())),a.entities&&(a.entities=a.rule.hideLength?[]:a.entities.map(()=>s.bank.createEntity())))}),JSON.parse(He(s))}),n}function q2(e,t){return e.reduce((n,r)=>{let i={...r};if(i.perPlayer&&(delete i.perPlayer,i.variants?i.variants=new Array(t.numPlayers).fill().reduce((s,o,a)=>[...s,...i.variants.map(u=>({...u,player:`${a}`}))],[]):i.variants=new Array(t.numPlayers).fill().map((s,o)=>({player:`${o}`}))),i.variants){let s=i.variants;return delete i.variants,[...n,...s.map(o=>({...i,...o}))]}else return[...n,i]},[])}function dv(e,t){let n={...e};return n.onBegin=r=>{let i=Mt(r),s=e.stages?.[i.ctx.activePlayers?.[i.ctx.currentPlayer]];return i.G._meta.passedPlayers=i.G._meta.passedPlayers.filter(o=>o!==i.ctx.currentPlayer),mn(i,e.initialMoves,{game:t}),mn(i,s?.initialMoves,{game:t}),JSON.parse(He(i.G))},e.stages&&Object.entries(e.stages).forEach(([r,i])=>{i.moves&&(n.stages[r].moves=au(i.moves,t))}),e.order?.playOrder==="RotateFirst"&&(e.order.first=()=>0,e.order.next=({ctx:r})=>(r.playOrderPos+1)%r.numPlayers,n.order.playOrder=({ctx:r,G:i})=>i._meta.isAfterFirstPhase?[...r.playOrder.slice(1),r.playOrder[0]]:r.playOrder),n}function j2(e,t){let n={...e};return e.turn&&(n.turn=dv(e.turn,t)),e.moves&&(n.moves=au(e.moves,t)),n.onBegin=r=>{let i=Mt(r);return mn(i,e.initialMoves,{game:t}),i.G._meta.currentPhaseHasBeenSetUp=!0,i.G._meta.nextPhase=e.next,JSON.parse(He(i.G))},e.endIf&&(n.endIf=r=>{let i=Mt(r);if(i.G._meta.currentPhaseHasBeenSetUp){let s=Ws(i,e.endIf);if(s)return s}}),n.onEnd=({G:r})=>{r._meta.currentPhaseHasBeenSetUp=!1,r._meta.isAfterFirstPhase=!0},n}function au(e,t){return Object.entries(e).reduce((n,[r,i])=>({...n,[r]:Hn({...i,name:r},t)}),{})}var D2="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";var mv=(e=21)=>{let t="",n=e|0;for(;n--;)t+=D2[Math.random()*64|0];return t};function st(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];if(0)var i,s;throw Error("[Immer] minified error nr: "+e+(n.length?" "+n.map(function(o){return"'"+o+"'"}).join(","):"")+". Find the full error at: https://bit.ly/3cXEKWf")}function Wn(e){return!!e&&!!e[Je]}function yn(e){var t;return!!e&&(function(n){if(!n||typeof n!="object")return!1;var r=Object.getPrototypeOf(n);if(r===null)return!0;var i=Object.hasOwnProperty.call(r,"constructor")&&r.constructor;return i===Object||typeof i=="function"&&Function.toString.call(i)===z2}(e)||Array.isArray(e)||!!e[Pv]||!!(!((t=e.constructor)===null||t===void 0)&&t[Pv])||yu(e)||vu(e))}function vi(e,t,n){n===void 0&&(n=!1),Jn(e)===0?(n?Object.keys:Pu)(e).forEach(function(r){n&&typeof r=="symbol"||t(r,e[r],e)}):e.forEach(function(r,i){return t(i,r,e)})}function Jn(e){var t=e[Je];return t?t.i>3?t.i-4:t.i:Array.isArray(e)?1:yu(e)?2:vu(e)?3:0}function pu(e,t){return Jn(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function R2(e,t){return Jn(e)===2?e.get(t):e[t]}function Ev(e,t,n){var r=Jn(e);r===2?e.set(t,n):r===3?e.add(n):e[t]=n}function B2(e,t){return e===t?e!==0||1/e==1/t:e!=e&&t!=t}function yu(e){return U2&&e instanceof Map}function vu(e){return V2&&e instanceof Set}function gn(e){return e.o||e.t}function bu(e){if(Array.isArray(e))return Array.prototype.slice.call(e);var t=K2(e);delete t[Je];for(var n=Pu(t),r=0;r<n.length;r++){var i=n[r],s=t[i];s.writable===!1&&(s.writable=!0,s.configurable=!0),(s.get||s.set)&&(t[i]={configurable:!0,writable:!0,enumerable:s.enumerable,value:e[i]})}return Object.create(Object.getPrototypeOf(e),t)}function _u(e,t){return t===void 0&&(t=!1),wu(e)||Wn(e)||!yn(e)||(Jn(e)>1&&(e.set=e.add=e.clear=e.delete=L2),Object.freeze(e),t&&vi(e,function(n,r){return _u(r,!0)},!0)),e}function L2(){st(2)}function wu(e){return e==null||typeof e!="object"||Object.isFrozen(e)}function dt(e){var t=H2[e];return t||st(18,e),t}function gv(){return bi}function uu(e,t){t&&(dt("Patches"),e.u=[],e.s=[],e.v=t)}function Js(e){hu(e),e.p.forEach(G2),e.p=null}function hu(e){e===bi&&(bi=e.l)}function yv(e){return bi={p:[],l:bi,h:e,m:!0,_:0}}function G2(e){var t=e[Je];t.i===0||t.i===1?t.j():t.g=!0}function cu(e,t){t._=t.p.length;var n=t.p[0],r=e!==void 0&&e!==n;return t.h.O||dt("ES5").S(t,e,r),r?(n[Je].P&&(Js(t),st(4)),yn(e)&&(e=Ys(t,e),t.l||$s(t,e)),t.u&&dt("Patches").M(n[Je].t,e,t.u,t.s)):e=Ys(t,n,[]),Js(t),t.u&&t.v(t.u,t.s),e!==kv?e:void 0}function Ys(e,t,n){if(wu(t))return t;var r=t[Je];if(!r)return vi(t,function(a,u){return vv(e,r,t,a,u,n)},!0),t;if(r.A!==e)return t;if(!r.P)return $s(e,r.t,!0),r.t;if(!r.I){r.I=!0,r.A._--;var i=r.i===4||r.i===5?r.o=bu(r.k):r.o,s=i,o=!1;r.i===3&&(s=new Set(i),i.clear(),o=!0),vi(s,function(a,u){return vv(e,r,i,a,u,n,o)}),$s(e,i,!1),n&&e.u&&dt("Patches").N(r,n,e.u,e.s)}return r.o}function vv(e,t,n,r,i,s,o){if(Wn(i)){var a=Ys(e,i,s&&t&&t.i!==3&&!pu(t.R,r)?s.concat(r):void 0);if(Ev(n,r,a),!Wn(a))return;e.m=!1}else o&&n.add(i);if(yn(i)&&!wu(i)){if(!e.h.D&&e._<1)return;Ys(e,i),t&&t.A.l||$s(e,i)}}function $s(e,t,n){n===void 0&&(n=!1),!e.l&&e.h.D&&e.m&&_u(t,n)}function lu(e,t){var n=e[Je];return(n?gn(n):e)[t]}function bv(e,t){if(t in e)for(var n=Object.getPrototypeOf(e);n;){var r=Object.getOwnPropertyDescriptor(n,t);if(r)return r;n=Object.getPrototypeOf(n)}}function du(e){e.P||(e.P=!0,e.l&&du(e.l))}function fu(e){e.o||(e.o=bu(e.t))}function mu(e,t,n){var r=yu(t)?dt("MapSet").F(t,n):vu(t)?dt("MapSet").T(t,n):e.O?function(i,s){var o=Array.isArray(i),a={i:o?1:0,A:s?s.A:gv(),P:!1,I:!1,R:{},l:s,t:i,k:null,o:null,j:null,C:!1},u=a,c=gu;o&&(u=[a],c=yi);var l=Proxy.revocable(u,c),f=l.revoke,p=l.proxy;return a.k=p,a.j=f,p}(t,n):dt("ES5").J(t,n);return(n?n.A:gv()).p.push(r),r}function F2(e){return Wn(e)||st(22,e),function t(n){if(!yn(n))return n;var r,i=n[Je],s=Jn(n);if(i){if(!i.P&&(i.i<4||!dt("ES5").K(i)))return i.t;i.I=!0,r=_v(n,s),i.I=!1}else r=_v(n,s);return vi(r,function(o,a){i&&R2(i.t,o)===a||Ev(r,o,t(a))}),s===3?new Set(r):r}(e)}function _v(e,t){switch(t){case 2:return new Map(e);case 3:return Array.from(e)}return bu(e)}var wv,bi,Ou=typeof Symbol<"u"&&typeof Symbol("x")=="symbol",U2=typeof Map<"u",V2=typeof Set<"u",Ov=typeof Proxy<"u"&&Proxy.revocable!==void 0&&typeof Reflect<"u",kv=Ou?Symbol.for("immer-nothing"):((wv={})["immer-nothing"]=!0,wv),Pv=Ou?Symbol.for("immer-draftable"):"__$immer_draftable",Je=Ou?Symbol.for("immer-state"):"__$immer_state";var z2=""+Object.prototype.constructor,Pu=typeof Reflect<"u"&&Reflect.ownKeys?Reflect.ownKeys:Object.getOwnPropertySymbols!==void 0?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Object.getOwnPropertyNames,K2=Object.getOwnPropertyDescriptors||function(e){var t={};return Pu(e).forEach(function(n){t[n]=Object.getOwnPropertyDescriptor(e,n)}),t},H2={},gu={get:function(e,t){if(t===Je)return e;var n=gn(e);if(!pu(n,t))return function(i,s,o){var a,u=bv(s,o);return u?"value"in u?u.value:(a=u.get)===null||a===void 0?void 0:a.call(i.k):void 0}(e,n,t);var r=n[t];return e.I||!yn(r)?r:r===lu(e.t,t)?(fu(e),e.o[t]=mu(e.A.h,r,e)):r},has:function(e,t){return t in gn(e)},ownKeys:function(e){return Reflect.ownKeys(gn(e))},set:function(e,t,n){var r=bv(gn(e),t);if(r?.set)return r.set.call(e.k,n),!0;if(!e.P){var i=lu(gn(e),t),s=i?.[Je];if(s&&s.t===n)return e.o[t]=n,e.R[t]=!1,!0;if(B2(n,i)&&(n!==void 0||pu(e.t,t)))return!0;fu(e),du(e)}return e.o[t]===n&&(n!==void 0||t in e.o)||Number.isNaN(n)&&Number.isNaN(e.o[t])||(e.o[t]=n,e.R[t]=!0),!0},deleteProperty:function(e,t){return lu(e.t,t)!==void 0||t in e.t?(e.R[t]=!1,fu(e),du(e)):delete e.R[t],e.o&&delete e.o[t],!0},getOwnPropertyDescriptor:function(e,t){var n=gn(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r&&{writable:!0,configurable:e.i!==1||t!=="length",enumerable:r.enumerable,value:n[t]}},defineProperty:function(){st(11)},getPrototypeOf:function(e){return Object.getPrototypeOf(e.t)},setPrototypeOf:function(){st(12)}},yi={};vi(gu,function(e,t){yi[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}}),yi.deleteProperty=function(e,t){return yi.set.call(this,e,t,void 0)},yi.set=function(e,t,n){return gu.set.call(this,e[0],t,n,e[0])};var W2=function(){function e(n){var r=this;this.O=Ov,this.D=!0,this.produce=function(i,s,o){if(typeof i=="function"&&typeof s!="function"){var a=s;s=i;var u=r;return function(y){var m=this;y===void 0&&(y=a);for(var b=arguments.length,g=Array(b>1?b-1:0),O=1;O<b;O++)g[O-1]=arguments[O];return u.produce(y,function(I){var j;return(j=s).call.apply(j,[m,I].concat(g))})}}var c;if(typeof s!="function"&&st(6),o!==void 0&&typeof o!="function"&&st(7),yn(i)){var l=yv(r),f=mu(r,i,void 0),p=!0;try{c=s(f),p=!1}finally{p?Js(l):hu(l)}return typeof Promise<"u"&&c instanceof Promise?c.then(function(y){return uu(l,o),cu(y,l)},function(y){throw Js(l),y}):(uu(l,o),cu(c,l))}if(!i||typeof i!="object"){if((c=s(i))===void 0&&(c=i),c===kv&&(c=void 0),r.D&&_u(c,!0),o){var h=[],d=[];dt("Patches").M(i,c,h,d),o(h,d)}return c}st(21,i)},this.produceWithPatches=function(i,s){if(typeof i=="function")return function(c){for(var l=arguments.length,f=Array(l>1?l-1:0),p=1;p<l;p++)f[p-1]=arguments[p];return r.produceWithPatches(c,function(h){return i.apply(void 0,[h].concat(f))})};var o,a,u=r.produce(i,s,function(c,l){o=c,a=l});return typeof Promise<"u"&&u instanceof Promise?u.then(function(c){return[c,o,a]}):[u,o,a]},typeof n?.useProxies=="boolean"&&this.setUseProxies(n.useProxies),typeof n?.autoFreeze=="boolean"&&this.setAutoFreeze(n.autoFreeze)}var t=e.prototype;return t.createDraft=function(n){yn(n)||st(8),Wn(n)&&(n=F2(n));var r=yv(this),i=mu(this,n,void 0);return i[Je].C=!0,hu(r),i},t.finishDraft=function(n,r){var i=n&&n[Je],s=i.A;return uu(s,r),cu(void 0,s)},t.setAutoFreeze=function(n){this.D=n},t.setUseProxies=function(n){n&&!Ov&&st(20),this.O=n},t.applyPatches=function(n,r){var i;for(i=r.length-1;i>=0;i--){var s=r[i];if(s.path.length===0&&s.op==="replace"){n=s.value;break}}i>-1&&(r=r.slice(i+1));var o=dt("Patches").$;return Wn(n)?o(n,r):this.produce(n,function(a){return o(a,r)})},e}(),Ye=new W2,J2=Ye.produce,j6=Ye.produceWithPatches.bind(Ye),D6=Ye.setAutoFreeze.bind(Ye),R6=Ye.setUseProxies.bind(Ye),B6=Ye.applyPatches.bind(Ye),L6=Ye.createDraft.bind(Ye),G6=Ye.finishDraft.bind(Ye),Av=J2;var Eu=class{constructor(t){let n=Y2();this.c=1,this.s0=n(" "),this.s1=n(" "),this.s2=n(" "),this.s0-=n(t),this.s0<0&&(this.s0+=1),this.s1-=n(t),this.s1<0&&(this.s1+=1),this.s2-=n(t),this.s2<0&&(this.s2+=1)}next(){let t=2091639*this.s0+this.c*23283064365386963e-26;return this.s0=this.s1,this.s1=this.s2,this.s2=t-(this.c=Math.trunc(t))}};function Y2(){let e=4022871197;return function(n){let r=n.toString();for(let i=0;i<r.length;i++){e+=r.charCodeAt(i);let s=.02519603282416938*e;e=s>>>0,s-=e,s*=e,e=s>>>0,s-=e,e+=s*4294967296}return(e>>>0)*23283064365386963e-26}}function xv(e,t){return t.c=e.c,t.s0=e.s0,t.s1=e.s1,t.s2=e.s2,t}function ku(e,t){let n=new Eu(e),r=n.next.bind(n);return t&&xv(t,n),r.state=()=>xv(n,{}),r}var Xs=class{constructor(t){this.state=t||{seed:"0"},this.used=!1}static seed(){return Date.now().toString(36).slice(-10)}isUsed(){return this.used}getState(){return this.state}_random(){this.used=!0;let t=this.state,n=t.prngstate?"":t.seed,r=ku(n,t.prngstate),i=r();return this.state={...t,prngstate:r.state()},i}api(){let t=this._random.bind(this),n={D4:4,D6:6,D8:8,D10:10,D12:12,D20:20},r={};for(let s in n){let o=n[s];r[s]=a=>a===void 0?Math.floor(t()*o)+1:Array.from({length:a}).map(()=>Math.floor(t()*o)+1)}function i(s=6,o){return o===void 0?Math.floor(t()*s)+1:Array.from({length:o}).map(()=>Math.floor(t()*s)+1)}return{...r,Die:i,Number:()=>t(),Shuffle:s=>{let o=[...s],a=s.length,u=0,c=Array.from({length:a});for(;a;){let l=Math.trunc(a*t());c[u++]=o[l],o[l]=o[--a]}return c},_private:this}}},Sv={name:"random",noClient:({api:e})=>e._private.isUsed(),flush:({api:e})=>e._private.getState(),api:({data:e})=>new Xs(e).api(),setup:({game:e})=>{let{seed:t}=e;return t===void 0&&(t=Xs.seed()),{seed:t}},playerView:()=>{}};var $2=he(tn()),_i="MAKE_MOVE",Yn="GAME_EVENT",wi="REDO",Oi="RESET",Pi="SYNC",Ei="UNDO",ki="UPDATE",Ai="PATCH",Su="PLUGIN",$n="STRIP_TRANSIENTS",Tu=(e,t,n,r)=>({type:_i,payload:{type:e,args:t,playerID:n,credentials:r}}),vn=(e,t,n,r)=>({type:Yn,payload:{type:e,args:t,playerID:n,credentials:r}}),Tv=(e,t,n,r)=>({type:Yn,payload:{type:e,args:t,playerID:n,credentials:r},automatic:!0}),xi=e=>({type:Pi,state:e.state,log:e.log,initialState:e.initialState,clientOnly:!0}),Mu=(e,t,n,r)=>({type:Ai,prevStateID:e,stateID:t,patch:n,deltalog:r,clientOnly:!0}),Iu=(e,t)=>({type:ki,state:e,deltalog:t,clientOnly:!0}),Nu=e=>({type:Oi,state:e,clientOnly:!0}),Cu=(e,t)=>({type:Ei,payload:{type:null,args:null,playerID:e,credentials:t}}),qu=(e,t)=>({type:wi,payload:{type:null,args:null,playerID:e,credentials:t}}),X2=(e,t,n,r)=>({type:Su,payload:{type:e,args:t,playerID:n,credentials:r}}),ju=()=>({type:$n}),Mv=Object.freeze({__proto__:null,makeMove:Tu,gameEvent:vn,automaticGameEvent:Tv,sync:xi,patch:Mu,update:Iu,reset:Nu,undo:Cu,redo:qu,plugin:X2,stripTransients:ju}),Zs="INVALID_MOVE",Q2={name:"plugin-immer",fnWrap:e=>(t,...n)=>{let r=!1,i=Av(t.G,s=>{let o=e({...t,G:s},...n);if(o===Zs){r=!0;return}return o});return r?Zs:i}},Re;(function(e){e.MOVE="MOVE",e.GAME_ON_END="GAME_ON_END",e.PHASE_ON_BEGIN="PHASE_ON_BEGIN",e.PHASE_ON_END="PHASE_ON_END",e.TURN_ON_BEGIN="TURN_ON_BEGIN",e.TURN_ON_MOVE="TURN_ON_MOVE",e.TURN_ON_END="TURN_ON_END"})(Re||(Re={}));var It;(function(e){e.CalledOutsideHook="Events must be called from moves or the `onBegin`, `onEnd`, and `onMove` hooks.\nThis error probably means you called an event from other game code, like an `endIf` trigger or one of the `turn.order` methods.",e.EndTurnInOnEnd="`endTurn` is disallowed in `onEnd` hooks \u2014 the turn is already ending.",e.MaxTurnEndings=`Maximum number of turn endings exceeded for this update.
|
|
8
8
|
This likely means game code is triggering an infinite loop.`,e.PhaseEventInOnEnd="`setPhase` & `endPhase` are disallowed in a phase\u2019s `onEnd` hook \u2014 the phase is already ending.\nIf you\u2019re trying to dynamically choose the next phase when a phase ends, use the phase\u2019s `next` trigger.",e.StageEventInOnEnd="`setStage`, `endStage` & `setActivePlayers` are disallowed in `onEnd` hooks.",e.StageEventInPhaseBegin="`setStage`, `endStage` & `setActivePlayers` are disallowed in a phase\u2019s `onBegin` hook.\nUse `setActivePlayers` in a `turn.onBegin` hook or declare stages with `turn.activePlayers` instead.",e.StageEventInTurnBegin="`setStage` & `endStage` are disallowed in `turn.onBegin`.\nUse `setActivePlayers` or declare stages with `turn.activePlayers` instead."})(It||(It={}));var Au=class{constructor(t,n,r){this.flow=t,this.playerID=r,this.dispatch=[],this.initialTurn=n.turn,this.updateTurnContext(n,void 0),this.maxEndedTurnsPerAction=n.numPlayers*100}api(){let t={_private:this};for(let n of this.flow.eventNames)t[n]=(...r)=>{this.dispatch.push({type:n,args:r,phase:this.currentPhase,turn:this.currentTurn,calledFrom:this.currentMethod,error:new Error("Events Plugin Error")})};return t}isUsed(){return this.dispatch.length>0}updateTurnContext(t,n){this.currentPhase=t.phase,this.currentTurn=t.turn,this.currentMethod=n}unsetCurrentMethod(){this.currentMethod=void 0}update(t){let n=t,r=({stack:i},s)=>({...n,plugins:{...n.plugins,events:{...n.plugins.events,data:{error:s+`
|
|
9
9
|
`+i}}}});e:for(let i=0;i<this.dispatch.length;i++){let s=this.dispatch[i],o=s.turn!==t.ctx.turn;if(this.currentTurn-this.initialTurn>=this.maxEndedTurnsPerAction)return r(s.error,It.MaxTurnEndings);if(s.calledFrom===void 0)return r(s.error,It.CalledOutsideHook);if(t.ctx.gameover)break e;switch(s.type){case"endStage":case"setStage":case"setActivePlayers":{switch(s.calledFrom){case Re.TURN_ON_END:case Re.PHASE_ON_END:return r(s.error,It.StageEventInOnEnd);case Re.PHASE_ON_BEGIN:return r(s.error,It.StageEventInPhaseBegin);case Re.TURN_ON_BEGIN:if(s.type==="setActivePlayers")break;return r(s.error,It.StageEventInTurnBegin)}if(o)continue e;break}case"endTurn":{if(s.calledFrom===Re.TURN_ON_END||s.calledFrom===Re.PHASE_ON_END)return r(s.error,It.EndTurnInOnEnd);if(o)continue e;break}case"endPhase":case"setPhase":{if(s.calledFrom===Re.PHASE_ON_END)return r(s.error,It.PhaseEventInOnEnd);if(s.phase!==t.ctx.phase)continue e;break}}let u=Tv(s.type,s.args,this.playerID);t=this.flow.processEvent(t,u)}return t}},Du={name:"events",noClient:({api:e})=>e._private.isUsed(),isInvalid:({data:e})=>e.error||!1,fnWrap:(e,t)=>(n,...r)=>{let i=n.events;i&&i._private.updateTurnContext(n.ctx,t);let s=e(n,...r);return i&&i._private.unsetCurrentMethod(),s},dangerouslyFlushRawState:({state:e,api:t})=>t._private.update(e),api:({game:e,ctx:t,playerID:n})=>new Au(e.flow,t,n).api()},Z2={name:"log",flush:()=>({}),api:({data:e})=>({setMetadata:t=>{e.metadata=t}}),setup:()=>({})};var eC={name:"plugin-serializable",fnWrap:e=>(t,...n)=>e(t,...n)},tC=!0,nC=tC?()=>{}:(...e)=>console.log(...e),rC=(...e)=>console.error(...e);function Ru(e){nC(`INFO: ${e}`)}function Oe(e){rC("ERROR:",e)}var Bu=[Q2,Sv,Z2,eC],Si=[...Bu,Du],Iv=(e,t,n)=>(n.game.plugins.filter(r=>r.action!==void 0).filter(r=>r.name===t.payload.type).forEach(r=>{let i=r.name,s=e.plugins[i]||{data:{}},o=r.action(s.data,t.payload);e={...e,plugins:{...e.plugins,[i]:{...s,data:o}}}}),e),Wt=({plugins:e})=>Object.entries(e||{}).reduce((t,[n,{api:r}])=>(t[n]=r,t),{}),Lu=(e,t,n)=>[...Bu,...n,Du].filter(r=>r.fnWrap!==void 0).reduce((r,{fnWrap:i})=>i(r,t),e),Nv=(e,t)=>([...Si,...t.game.plugins].filter(n=>n.setup!==void 0).forEach(n=>{let r=n.name,i=n.setup({G:e.G,ctx:e.ctx,game:t.game});e={...e,plugins:{...e.plugins,[r]:{data:i}}}}),e),Ti=(e,t)=>([...Si,...t.game.plugins].filter(n=>n.api!==void 0).forEach(n=>{let r=n.name,i=e.plugins[r]||{data:{}},s=n.api({G:e.G,ctx:e.ctx,data:i.data,game:t.game,playerID:t.playerID});e={...e,plugins:{...e.plugins,[r]:{...i,api:s}}}}),e),iC=(e,t)=>([...Bu,...t.game.plugins,Du].reverse().forEach(n=>{let r=n.name,i=e.plugins[r]||{data:{}};if(n.flush){let s=n.flush({G:e.G,ctx:e.ctx,game:t.game,api:i.api,data:i.data});e={...e,plugins:{...e.plugins,[n.name]:{data:s}}}}else if(n.dangerouslyFlushRawState){e=n.dangerouslyFlushRawState({state:e,game:t.game,api:i.api,data:i.data});let s=e.plugins[r].data;e={...e,plugins:{...e.plugins,[n.name]:{data:s}}}}}),e),Cv=(e,t)=>[...Si,...t.game.plugins].filter(n=>n.noClient!==void 0).map(n=>{let r=n.name,i=e.plugins[r];return i?n.noClient({G:e.G,ctx:e.ctx,game:t.game,api:i.api,data:i.data}):!1}).includes(!0),sC=(e,t)=>[...Si,...t.game.plugins].filter(r=>r.isInvalid!==void 0).map(r=>{let{name:i}=r,s=e.plugins[i],o=r.isInvalid({G:e.G,ctx:e.ctx,game:t.game,data:s&&s.data});return o?{plugin:i,message:o}:!1}).find(r=>r)||!1,eo=(e,t)=>{let n=iC(e,t),r=sC(n,t);if(!r)return[n];let{plugin:i,message:s}=r;return Oe(`${i} plugin declared action invalid:
|
|
10
10
|
${s}`),[e,r]},qv=({G:e,ctx:t,plugins:n={}},{game:r,playerID:i})=>([...Si,...r.plugins].forEach(({name:s,playerView:o})=>{if(!o)return;let{data:a}=n[s]||{data:{}},u=o({G:e,ctx:t,game:r,data:a,playerID:i});n={...n,[s]:{data:u}}}),n);function Mi(e,t=!1){e.moveLimit&&(t&&(e.minMoves=e.moveLimit),e.maxMoves=e.moveLimit,delete e.moveLimit)}function Ii(e,t){let n={},r=[],i=null,s={},o={};if(Array.isArray(t)){let u={};t.forEach(c=>u[c]=Nt.NULL),n=u}else{if(Mi(t),t.next&&(i=t.next),t.revert&&(r=[...e._prevActivePlayers,{activePlayers:e.activePlayers,_activePlayersMinMoves:e._activePlayersMinMoves,_activePlayersMaxMoves:e._activePlayersMaxMoves,_activePlayersNumMoves:e._activePlayersNumMoves}]),t.currentPlayer!==void 0&&Qs(n,s,o,e.currentPlayer,t.currentPlayer),t.others!==void 0)for(let u=0;u<e.playOrder.length;u++){let c=e.playOrder[u];c!==e.currentPlayer&&Qs(n,s,o,c,t.others)}if(t.all!==void 0)for(let u=0;u<e.playOrder.length;u++){let c=e.playOrder[u];Qs(n,s,o,c,t.all)}if(t.value)for(let u in t.value)Qs(n,s,o,u,t.value[u]);if(t.minMoves)for(let u in n)s[u]===void 0&&(s[u]=t.minMoves);if(t.maxMoves)for(let u in n)o[u]===void 0&&(o[u]=t.maxMoves)}Object.keys(n).length===0&&(n=null),Object.keys(s).length===0&&(s=null),Object.keys(o).length===0&&(o=null);let a={};for(let u in n)a[u]=0;return{...e,activePlayers:n,_activePlayersMinMoves:s,_activePlayersMaxMoves:o,_activePlayersNumMoves:a,_prevActivePlayers:r,_nextActivePlayers:i}}function jv(e){let{activePlayers:t,_activePlayersMinMoves:n,_activePlayersMaxMoves:r,_activePlayersNumMoves:i,_prevActivePlayers:s,_nextActivePlayers:o}=e;if(t&&Object.keys(t).length===0)if(o)e=Ii(e,o),{activePlayers:t,_activePlayersMinMoves:n,_activePlayersMaxMoves:r,_activePlayersNumMoves:i,_prevActivePlayers:s}=e;else if(s.length>0){let a=s.length-1;({activePlayers:t,_activePlayersMinMoves:n,_activePlayersMaxMoves:r,_activePlayersNumMoves:i}=s[a]),s=s.slice(0,a)}else t=null,n=null,r=null;return{...e,activePlayers:t,_activePlayersMinMoves:n,_activePlayersMaxMoves:r,_activePlayersNumMoves:i,_prevActivePlayers:s}}function Qs(e,t,n,r,i){(typeof i!="object"||i===Nt.NULL)&&(i={stage:i}),i.stage!==void 0&&(Mi(i),e[r]=i.stage,i.minMoves&&(t[r]=i.minMoves),i.maxMoves&&(n[r]=i.maxMoves))}function xu(e,t){return e[t]+""}function Dv(e,t){let{G:n,ctx:r}=e,{numPlayers:i}=r,o={...Wt(e),G:n,ctx:r},a=t.order,u=[...Array.from({length:i})].map((p,h)=>h+"");a.playOrder!==void 0&&(u=a.playOrder(o));let c=a.first(o),l=typeof c;l!=="number"&&Oe(`invalid value returned by turn.order.first \u2014 expected number got ${l} \u201C${c}\u201D.`);let f=xu(u,c);return r={...r,currentPlayer:f,playOrderPos:c,playOrder:u},r=Ii(r,t.activePlayers||{}),r}function Rv(e,t,n,r){let i=n.order,{G:s,ctx:o}=e,a=o.playOrderPos,u=!1;if(r&&r!==!0)typeof r!="object"&&Oe(`invalid argument to endTurn: ${r}`),Object.keys(r).forEach(c=>{switch(c){case"remove":t=xu(o.playOrder,a);break;case"next":a=o.playOrder.indexOf(r.next),t=r.next;break;default:Oe(`invalid argument to endTurn: ${c}`)}});else{let l={...Wt(e),G:s,ctx:o},f=i.next(l),p=typeof f;f!==void 0&&p!=="number"&&Oe(`invalid value returned by turn.order.next \u2014 expected number or undefined got ${p} \u201C${f}\u201D.`),f===void 0?u=!0:(a=f,t=xu(o.playOrder,a))}return o={...o,playOrderPos:a,currentPlayer:t},{endPhase:u,ctx:o}}var Bv={DEFAULT:{first:({ctx:e})=>e.turn===0?e.playOrderPos:(e.playOrderPos+1)%e.playOrder.length,next:({ctx:e})=>(e.playOrderPos+1)%e.playOrder.length},RESET:{first:()=>0,next:({ctx:e})=>(e.playOrderPos+1)%e.playOrder.length},CONTINUE:{first:({ctx:e})=>e.playOrderPos,next:({ctx:e})=>(e.playOrderPos+1)%e.playOrder.length},ONCE:{first:()=>0,next:({ctx:e})=>{if(e.playOrderPos<e.playOrder.length-1)return e.playOrderPos+1}},CUSTOM:e=>({playOrder:()=>e,first:()=>0,next:({ctx:t})=>(t.playOrderPos+1)%t.playOrder.length}),CUSTOM_FROM:e=>({playOrder:({G:t})=>t[e],first:()=>0,next:({ctx:t})=>(t.playOrderPos+1)%t.playOrder.length})},Nt={NULL:null},K6={ALL:{all:Nt.NULL},ALL_ONCE:{all:Nt.NULL,minMoves:1,maxMoves:1},OTHERS:{others:Nt.NULL},OTHERS_ONCE:{others:Nt.NULL,minMoves:1,maxMoves:1}};var{parse:oC,stringify:aC}=JSON,{keys:uC}=Object,Ni=String,Fv="string",Lv={},to="object",Uv=(e,t)=>t,cC=e=>e instanceof Ni?Ni(e):e,lC=(e,t)=>typeof t===Fv?new Ni(t):t,Vv=(e,t,n,r)=>{let i=[];for(let s=uC(n),{length:o}=s,a=0;a<o;a++){let u=s[a],c=n[u];if(c instanceof Ni){let l=e[c];typeof l===to&&!t.has(l)?(t.add(l),n[u]=Lv,i.push({k:u,a:[e,t,l,r]})):n[u]=r.call(n,u,l)}else n[u]!==Lv&&(n[u]=r.call(n,u,c))}for(let{length:s}=i,o=0;o<s;o++){let{k:a,a:u}=i[o];n[a]=r.call(n,a,Vv.apply(null,u))}return n},Gv=(e,t,n)=>{let r=Ni(t.push(n)-1);return e.set(n,r),r},Gu=(e,t)=>{let n=oC(e,lC).map(cC),r=n[0],i=t||Uv,s=typeof r===to&&r?Vv(n,new Set,r,i):r;return i.call({"":s},"",s)},Fu=(e,t,n)=>{let r=t&&typeof t===to?(l,f)=>l===""||-1<t.indexOf(l)?f:void 0:t||Uv,i=new Map,s=[],o=[],a=+Gv(i,s,r.call({"":e},"",e)),u=!a;for(;a<s.length;)u=!0,o[a]=aC(s[a++],c,n);return"["+o.join(",")+"]";function c(l,f){if(u)return u=!u,f;let p=r.call(this,l,f);switch(typeof p){case to:if(p===null)return p;case Fv:return i.get(p)||Gv(i,s,p)}return p}};var ab=he(qi());function EC({moves:e,phases:t,endIf:n,onEnd:r,turn:i,events:s,plugins:o}){e===void 0&&(e={}),s===void 0&&(s={}),o===void 0&&(o=[]),t===void 0&&(t={}),n||(n=()=>{}),r||(r=({G:_})=>_),i||(i={});let a={...t};""in a&&Oe("cannot specify phase with empty name"),a[""]={};let u={},c=new Set,l=null;Object.keys(e).forEach(_=>c.add(_));let f=(_,E)=>{let T=Lu(_,E,o);return F=>{let z=Wt(F);return T({...z,G:F.G,ctx:F.ctx,playerID:F.playerID})}},p=_=>E=>{let T=Wt(E);return _({...T,G:E.G,ctx:E.ctx})},h={onEnd:f(r,Re.GAME_ON_END),endIf:p(n)};for(let _ in a){let E=a[_];if(E.start===!0&&(l=_),E.moves!==void 0)for(let T of Object.keys(E.moves))u[_+"."+T]=E.moves[T],c.add(T);E.endIf===void 0&&(E.endIf=()=>{}),E.onBegin===void 0&&(E.onBegin=({G:T})=>T),E.onEnd===void 0&&(E.onEnd=({G:T})=>T),E.turn===void 0&&(E.turn=i),E.turn.order===void 0&&(E.turn.order=Bv.DEFAULT),E.turn.onBegin===void 0&&(E.turn.onBegin=({G:T})=>T),E.turn.onEnd===void 0&&(E.turn.onEnd=({G:T})=>T),E.turn.endIf===void 0&&(E.turn.endIf=()=>!1),E.turn.onMove===void 0&&(E.turn.onMove=({G:T})=>T),E.turn.stages===void 0&&(E.turn.stages={}),Mi(E.turn,!0);for(let T in E.turn.stages){let z=E.turn.stages[T].moves||{};for(let H of Object.keys(z)){let Se=_+"."+T+"."+H;u[Se]=z[H],c.add(H)}}if(E.wrapped={onBegin:f(E.onBegin,Re.PHASE_ON_BEGIN),onEnd:f(E.onEnd,Re.PHASE_ON_END),endIf:p(E.endIf)},E.turn.wrapped={onMove:f(E.turn.onMove,Re.TURN_ON_MOVE),onBegin:f(E.turn.onBegin,Re.TURN_ON_BEGIN),onEnd:f(E.turn.onEnd,Re.TURN_ON_END),endIf:p(E.turn.endIf)},typeof E.next!="function"){let{next:T}=E;E.next=()=>T||null}E.wrapped.next=p(E.next)}function d(_){return _.phase?a[_.phase]:a[""]}function y(_){return _}function m(_,E){let T=new Set,F=new Set;for(let z=0;z<E.length;z++){let{fn:H,arg:Se,...ve}=E[z];if(H===ne){F.clear();let Ge=_.ctx.phase;if(T.has(Ge)){let ct={..._.ctx,phase:null};return{..._,ctx:ct}}T.add(Ge)}let Ze=[];if(_=H(_,{...ve,arg:Se,next:Ze}),H===se)break;let Ce=J(_);if(Ce){E.push({fn:se,arg:Ce,turn:_.ctx.turn,phase:_.ctx.phase,automatic:!0});continue}let De=fe(_);if(De){E.push({fn:ne,arg:De,turn:_.ctx.turn,phase:_.ctx.phase,automatic:!0});continue}if([y,N,D].includes(H)){let Ge=V(_);if(Ge){E.push({fn:G,arg:Ge,turn:_.ctx.turn,phase:_.ctx.phase,automatic:!0});continue}}E.push(...Ze)}return _}function b(_,{next:E}){return E.push({fn:g}),_}function g(_,{next:E}){let{G:T,ctx:F}=_;return T=d(F).wrapped.onBegin(_),E.push({fn:O}),{..._,G:T,ctx:F}}function O(_,{currentPlayer:E}){let{ctx:T}=_,F=d(T);E?(T={...T,currentPlayer:E},F.turn.activePlayers&&(T=Ii(T,F.turn.activePlayers))):T=Dv(_,F.turn);let z=T.turn+1;T={...T,turn:z,numMoves:0,_prevActivePlayers:[]};let H=F.turn.wrapped.onBegin({..._,ctx:T});return{..._,G:H,ctx:T,_undo:[],_redo:[]}}function I(_,{arg:E,next:T,phase:F}){let z=d({phase:F}),{ctx:H}=_;if(E&&E.next)if(E.next in a)H={...H,phase:E.next};else return Oe("invalid phase: "+E.next),_;else H={...H,phase:z.wrapped.next(_)||null};return _={..._,ctx:H},T.push({fn:g}),_}function j(_,{arg:E,currentPlayer:T,next:F}){let{G:z,ctx:H}=_,Se=d(H),{endPhase:ve,ctx:Ze}=Rv(_,T,Se.turn,E);return H=Ze,_={..._,G:z,ctx:H},ve?F.push({fn:ne,turn:H.turn,phase:H.phase}):F.push({fn:O,currentPlayer:H.currentPlayer}),_}function N(_,{arg:E,playerID:T}){if((typeof E=="string"||E===Nt.NULL)&&(E={stage:E}),typeof E!="object")return _;Mi(E);let{ctx:F}=_,{activePlayers:z,_activePlayersMinMoves:H,_activePlayersMaxMoves:Se,_activePlayersNumMoves:ve}=F;return E.stage!==void 0&&(z===null&&(z={}),z[T]=E.stage,ve[T]=0,E.minMoves&&(H===null&&(H={}),H[T]=E.minMoves),E.maxMoves&&(Se===null&&(Se={}),Se[T]=E.maxMoves)),F={...F,activePlayers:z,_activePlayersMinMoves:H,_activePlayersMaxMoves:Se,_activePlayersNumMoves:ve},{..._,ctx:F}}function D(_,{arg:E}){return{..._,ctx:Ii(_.ctx,E)}}function J(_){return h.endIf(_)}function fe(_){return d(_.ctx).wrapped.endIf(_)}function V(_){let E=d(_.ctx),T=_.ctx.numMoves||0;return E.turn.maxMoves&&T>=E.turn.maxMoves?!0:E.turn.wrapped.endIf(_)}function se(_,{arg:E,phase:T}){_=ne(_,{phase:T}),E===void 0&&(E=!0),_={..._,ctx:{..._.ctx,gameover:E}};let F=h.onEnd(_);return{..._,G:F}}function ne(_,{arg:E,next:T,turn:F,automatic:z}){_=G(_,{turn:F,force:!0,automatic:!0});let{phase:H,turn:Se}=_.ctx;if(T&&T.push({fn:I,arg:E,phase:H}),H===null)return _;let Ze=d(_.ctx).wrapped.onEnd(_),Ce={..._.ctx,phase:null},De=vn("endPhase",E),{_stateID:Ge}=_,ct={action:De,_stateID:Ge,turn:Se,phase:H};z&&(ct.automatic=!0);let Zt=[..._.deltalog||[],ct];return{..._,G:Ze,ctx:Ce,deltalog:Zt}}function G(_,{arg:E,next:T,turn:F,force:z,automatic:H,playerID:Se}){if(F!==_.ctx.turn)return _;let{currentPlayer:ve,numMoves:Ze,phase:Ce,turn:De}=_.ctx,Ge=d(_.ctx),ct=Ze||0;if(!z&&Ge.turn.minMoves&&ct<Ge.turn.minMoves)return Ru(`cannot end turn before making ${Ge.turn.minMoves} moves`),_;let Zt=Ge.turn.wrapped.onEnd(_);T&&T.push({fn:j,arg:E,currentPlayer:ve});let Gt={..._.ctx,activePlayers:null};if(E&&E.remove){Se=Se||ve;let en=Gt.playOrder.filter(m_=>m_!=Se),d_=Gt.playOrderPos>en.length-1?0:Gt.playOrderPos;if(Gt={...Gt,playOrder:en,playOrderPos:d_},en.length===0)return T.push({fn:ne,turn:De,phase:Ce}),_}let Do=vn("endTurn",E),{_stateID:cl}=_,pr={action:Do,_stateID:cl,turn:De,phase:Ce};H&&(pr.automatic=!0);let Ro=[..._.deltalog||[],pr];return{..._,G:Zt,ctx:Gt,deltalog:Ro,_undo:[],_redo:[]}}function Pe(_,{arg:E,next:T,automatic:F,playerID:z}){z=z||_.ctx.currentPlayer;let{ctx:H,_stateID:Se}=_,{activePlayers:ve,_activePlayersNumMoves:Ze,_activePlayersMinMoves:Ce,_activePlayersMaxMoves:De,phase:Ge,turn:ct}=H,Zt=ve!==null&&z in ve,Gt=d(H);if(!E&&Zt){let en=Gt.turn.stages[ve[z]];en&&en.next&&(E=en.next)}if(T&&T.push({fn:N,arg:E,playerID:z}),!Zt)return _;let Do=Ze[z]||0;if(Ce&&Ce[z]&&Do<Ce[z])return Ru(`cannot end stage before making ${Ce[z]} moves`),_;ve={...ve},delete ve[z],Ce&&(Ce={...Ce},delete Ce[z]),De&&(De={...De},delete De[z]),H=jv({...H,activePlayers:ve,_activePlayersMinMoves:Ce,_activePlayersMaxMoves:De});let pr={action:vn("endStage",E),_stateID:Se,turn:ct,phase:Ge};F&&(pr.automatic=!0);let Ro=[..._.deltalog||[],pr];return{..._,ctx:H,deltalog:Ro}}function ue(_,E,T){let F=d(_),z=F.turn.stages,{activePlayers:H}=_;if(H&&H[T]!==void 0&&H[T]!==Nt.NULL&&z[H[T]]!==void 0&&z[H[T]].moves!==void 0){let ve=z[H[T]].moves;if(E in ve)return ve[E]}else if(F.moves){if(E in F.moves)return F.moves[E]}else if(E in e)return e[E];return null}function Lt(_,E){let{playerID:T,type:F}=E,{currentPlayer:z,activePlayers:H,_activePlayersMaxMoves:Se}=_.ctx,ve=ue(_.ctx,F,T),Ze=!ve||typeof ve=="function"||ve.noLimit!==!0,{numMoves:Ce,_activePlayersNumMoves:De}=_.ctx;Ze&&(T===z&&Ce++,H&&De[T]++),_={..._,ctx:{..._.ctx,numMoves:Ce,_activePlayersNumMoves:De}},Se&&De[T]>=Se[T]&&(_=Pe(_,{playerID:T,automatic:!0}));let ct=d(_.ctx).turn.wrapped.onMove({..._,playerID:T});return _={..._,G:ct},m(_,[{fn:y}])}function bt(_,E,T){return m(_,[{fn:Pe,arg:T,playerID:E}])}function kn(_,E){return m(_,[{fn:Pe,playerID:E}])}function _t(_,E,T){return m(_,[{fn:D,arg:T}])}function xe(_,E,T){return m(_,[{fn:ne,phase:_.ctx.phase,turn:_.ctx.turn,arg:{next:T}}])}function jo(_){return m(_,[{fn:ne,phase:_.ctx.phase,turn:_.ctx.turn}])}function Me(_,E,T){return m(_,[{fn:G,turn:_.ctx.turn,phase:_.ctx.phase,arg:T}])}function Ie(_,E,T){return m(_,[{fn:G,turn:_.ctx.turn,phase:_.ctx.phase,force:!0,arg:T}])}function Ne(_,E,T){return m(_,[{fn:se,turn:_.ctx.turn,phase:_.ctx.phase,arg:T}])}let C={endStage:kn,setStage:bt,endTurn:Me,pass:Ie,endPhase:jo,setPhase:xe,endGame:Ne,setActivePlayers:_t},W=[];s.endTurn!==!1&&W.push("endTurn"),s.pass!==!1&&W.push("pass"),s.endPhase!==!1&&W.push("endPhase"),s.setPhase!==!1&&W.push("setPhase"),s.endGame!==!1&&W.push("endGame"),s.setActivePlayers!==!1&&W.push("setActivePlayers"),s.endStage!==!1&&W.push("endStage"),s.setStage!==!1&&W.push("setStage");function wt(_,E){let{type:T,playerID:F,args:z}=E.payload;return typeof C[T]!="function"?_:C[T](_,F,...Array.isArray(z)?z:[z])}function fr(_,E,T){return E.activePlayers?T in E.activePlayers:E.currentPlayer===T}return{ctx:_=>({numPlayers:_,turn:0,currentPlayer:"0",playOrder:[...Array.from({length:_})].map((E,T)=>T+""),playOrderPos:0,phase:l,activePlayers:null}),init:_=>m(_,[{fn:b}]),isPlayerActive:fr,eventHandlers:C,eventNames:Object.keys(C),enabledEventNames:W,moveMap:u,moveNames:[...c.values()],processMove:Lt,processEvent:wt,getMove:ue}}function kC(e){return e.processMove!==void 0}function ji(e){if(kC(e))return e;if(e.name===void 0&&(e.name="default"),e.deltaState===void 0&&(e.deltaState=!1),e.disableUndo===void 0&&(e.disableUndo=!1),e.setup===void 0&&(e.setup=()=>({})),e.moves===void 0&&(e.moves={}),e.playerView===void 0&&(e.playerView=({G:n})=>n),e.plugins===void 0&&(e.plugins=[]),e.plugins.forEach(n=>{if(n.name===void 0)throw new Error("Plugin missing name attribute");if(n.name.includes(" "))throw new Error(n.name+": Plugin name must not include spaces")}),e.name.includes(" "))throw new Error(e.name+": Game name must not include spaces");let t=EC(e);return{...e,flow:t,moveNames:t.moveNames,pluginNames:e.plugins.map(n=>n.name),processMove:(n,r)=>{let i=t.getMove(n.ctx,r.type,r.playerID);if(AC(i)&&(i=i.move),i instanceof Function){let s=Lu(i,Re.MOVE,e.plugins),o=[];r.args!==void 0&&(o=Array.isArray(r.args)?r.args:[r.args]);let a={...Wt(n),G:n.G,ctx:n.ctx,playerID:r.playerID};return s(a,...o)}return Oe(`invalid move object: ${r.type}`),n.G}}}function AC(e){return e instanceof Object&&e.move!==void 0}var tc;(function(e){e.UnauthorizedAction="update/unauthorized_action",e.MatchNotFound="update/match_not_found",e.PatchFailed="update/patch_failed"})(tc||(tc={}));var Be;(function(e){e.StaleStateId="action/stale_state_id",e.UnavailableMove="action/unavailable_move",e.InvalidMove="action/invalid_move",e.InactivePlayer="action/inactive_player",e.GameOver="action/gameover",e.ActionDisabled="action/action_disabled",e.ActionInvalid="action/action_invalid",e.PluginActionInvalid="action/plugin_invalid"})(Be||(Be={}));var ro=e=>e.payload.playerID!==null&&e.payload.playerID!==void 0,xC=(e,t,n)=>{function r(s){return s.undoable!==void 0}function i(s){return s instanceof Function}return r(n)?i(n.undoable)?n.undoable({G:e,ctx:t}):n.undoable:!0};function ob(e,t){if(t.game.disableUndo)return e;let n={G:e.G,ctx:e.ctx,plugins:e.plugins,playerID:t.action.payload.playerID||e.ctx.currentPlayer};return t.action.type==="MAKE_MOVE"&&(n.moveType=t.action.payload.type),{...e,_undo:[...e._undo,n],_redo:[]}}function Zu(e,t,n){let r={action:t,_stateID:e._stateID,turn:e.ctx.turn,phase:e.ctx.phase},i=e.plugins.log.data.metadata;return i!==void 0&&(r.metadata=i),typeof n=="object"&&n.redact===!0?r.redact=!0:typeof n=="object"&&n.redact instanceof Function&&(r.redact=n.redact({G:e.G,ctx:e.ctx})),{...e,deltalog:[r]}}function ec(e,t,n){let[r,i]=eo(e,n);return i?[r,Fe(t,Be.PluginActionInvalid,i)]:[r]}function ub(e){if(!e)return[null,void 0];let{transients:t,...n}=e;return[n,t]}function Fe(e,t,n){return{...e,transients:{error:{type:t,payload:n}}}}var cb=e=>t=>n=>{let r=t(n);switch(n.type){case $n:return r;default:{let[,i]=ub(e.getState());return typeof i<"u"?(e.dispatch(ju()),{...r,transients:i}):r}}};function Xn({game:e,isClient:t}){return e=ji(e),(n=null,r)=>{let[i]=ub(n);switch(r.type){case $n:return i;case Yn:{if(i={...i,deltalog:[]},t)return i;if(i.ctx.gameover!==void 0)return Oe("cannot call event after game end"),Fe(i,Be.GameOver);if(ro(r)&&!e.flow.isPlayerActive(i.G,i.ctx,r.payload.playerID))return Oe(`disallowed event: ${r.payload.type}`),Fe(i,Be.InactivePlayer);i=Ti(i,{game:e,isClient:!1,playerID:r.payload.playerID});let s=e.flow.processEvent(i,r),o;return[s,o]=ec(s,i,{game:e,isClient:!1}),o||(s=ob(s,{game:e,action:r}),{...s,_stateID:i._stateID+1})}case _i:{let s=i={...i,deltalog:[]},o=e.flow.getMove(i.ctx,r.payload.type,r.payload.playerID||i.ctx.currentPlayer);if(o===null)return Oe(`disallowed move: ${r.payload.type}`),Fe(i,Be.UnavailableMove);if(t&&o.client===!1)return i;if(i.ctx.gameover!==void 0)return Oe("cannot make move after game end"),Fe(i,Be.GameOver);if(ro(r)&&!e.flow.isPlayerActive(i.G,i.ctx,r.payload.playerID))return Oe(`disallowed move: ${r.payload.type}`),Fe(i,Be.InactivePlayer);i=Ti(i,{game:e,isClient:t,playerID:r.payload.playerID});let a=e.processMove(i,r.payload);if(a===Zs)return Oe(`invalid move: ${r.payload.type} args: ${r.payload.args}`),Fe(i,Be.InvalidMove);let u={...i,G:a};if(t&&Cv(u,{game:e}))return i;if(i=u,t){let l;return[i,l]=ec(i,s,{game:e,isClient:!0}),l||{...i,_stateID:i._stateID+1}}i=Zu(i,r,o),i=e.flow.processMove(i,r.payload);let c;return[i,c]=ec(i,s,{game:e}),c||(i=ob(i,{game:e,action:r}),{...i,_stateID:i._stateID+1})}case Oi:case ki:case Pi:return r.state;case Ei:{if(i={...i,deltalog:[]},e.disableUndo)return Oe("Undo is not enabled"),Fe(i,Be.ActionDisabled);let{G:s,ctx:o,_undo:a,_redo:u,_stateID:c}=i;if(a.length<2)return Oe("No moves to undo"),Fe(i,Be.ActionInvalid);let l=a[a.length-1],f=a[a.length-2];if(ro(r)&&r.payload.playerID!==l.playerID)return Oe("Cannot undo other players' moves"),Fe(i,Be.ActionInvalid);if(l.moveType){let p=e.flow.getMove(f.ctx,l.moveType,l.playerID);if(!xC(s,o,p))return Oe("Move cannot be undone"),Fe(i,Be.ActionInvalid)}return i=Zu(i,r),{...i,G:f.G,ctx:f.ctx,plugins:f.plugins,_stateID:c+1,_undo:a.slice(0,-1),_redo:[l,...u]}}case wi:{if(i={...i,deltalog:[]},e.disableUndo)return Oe("Redo is not enabled"),Fe(i,Be.ActionDisabled);let{_undo:s,_redo:o,_stateID:a}=i;if(o.length===0)return Oe("No moves to redo"),Fe(i,Be.ActionInvalid);let u=o[0];return ro(r)&&r.payload.playerID!==u.playerID?(Oe("Cannot redo other players' moves"),Fe(i,Be.ActionInvalid)):(i=Zu(i,r),{...i,G:u.G,ctx:u.ctx,plugins:u.plugins,_stateID:a+1,_undo:[...s,u],_redo:o.slice(1)})}case Su:return Iv(i,r,{game:e});case Ai:{let s=i,o=JSON.parse(JSON.stringify(s)),a=(0,ab.applyPatch)(o,r.patch);return a.some(c=>c!==null)?(Oe(`Patch ${JSON.stringify(r.patch)} apply failed`),Fe(s,tc.PatchFailed,a)):o}default:return i}}}var nL=he(io());var so=class{constructor({enumerate:t,seed:n}){this.enumerateFn=t,this.seed=n,this.iterationCounter=0,this._opts={}}addOpt({key:t,range:n,initial:r}){this._opts[t]={range:n,value:r}}getOpt(t){return this._opts[t].value}setOpt(t,n){t in this._opts&&(this._opts[t].value=n)}opts(){return this._opts}enumerate(t,n,r){return this.enumerateFn(t,n,r).map(s=>{if("payload"in s)return s;if("move"in s)return Tu(s.move,s.args,r);if("event"in s)return vn(s.event,s.args,r)})}random(t){let n;if(this.seed!==void 0){let r=this.prngstate?"":this.seed,i=ku(r,this.prngstate);n=i(),this.prngstate=i.state()}else n=Math.random();if(t)if(Array.isArray(t)){let r=Math.floor(n*t.length);return t[r]}else return Math.floor(n*t);return n}},SC=25,Di=class extends so{constructor({enumerate:t,seed:n,objectives:r,game:i,iterations:s,playoutDepth:o,iterationCallback:a}){super({enumerate:t,seed:n}),r===void 0&&(r=()=>({})),this.objectives=r,this.iterationCallback=a||(()=>{}),this.reducer=Xn({game:i}),this.iterations=s,this.playoutDepth=o,this.addOpt({key:"async",initial:!1}),this.addOpt({key:"iterations",initial:typeof s=="number"?s:1e3,range:{min:1,max:2e3}}),this.addOpt({key:"playoutDepth",initial:typeof o=="number"?o:50,range:{min:1,max:100}})}createNode({state:t,parentAction:n,parent:r,playerID:i}){let{G:s,ctx:o}=t,a=[],u=[];if(i!==void 0)a=this.enumerate(s,o,i),u=this.objectives(s,o,i);else if(o.activePlayers)for(let c in o.activePlayers)a.push(...this.enumerate(s,o,c)),u.push(this.objectives(s,o,c));else a=this.enumerate(s,o,o.currentPlayer),u=this.objectives(s,o,o.currentPlayer);return{state:t,parent:r,parentAction:n,actions:a,objectives:u,children:[],visits:0,value:0}}select(t){if(t.actions.length>0||t.children.length===0)return t;let n=null,r=0;for(let i of t.children){let s=i.visits+Number.EPSILON,o=i.value/s+Math.sqrt(2*Math.log(t.visits)/s);(n==null||o>r)&&(r=o,n=i)}return this.select(n)}expand(t){let n=t.actions;if(n.length===0||t.state.ctx.gameover!==void 0)return t;let r=this.random(n.length),i=n[r];t.actions.splice(r,1);let s=this.reducer(t.state,i),o=this.createNode({state:s,parentAction:i,parent:t});return t.children.push(o),o}playout({state:t}){let n=this.getOpt("playoutDepth");typeof this.playoutDepth=="function"&&(n=this.playoutDepth(t.G,t.ctx));for(let r=0;r<n&&t.ctx.gameover===void 0;r++){let{G:i,ctx:s}=t,o=s.currentPlayer;s.activePlayers&&(o=Object.keys(s.activePlayers)[0]);let a=this.enumerate(i,s,o),u=this.objectives(i,s,o),c=Object.keys(u).reduce((p,h)=>{let d=u[h];return d.checker(i,s)?p+d.weight:p},0);if(c>0)return{score:c};if(!a||a.length===0)return;let l=this.random(a.length);t=this.reducer(t,a[l])}return t.ctx.gameover}backpropagate(t,n={}){t.visits++,n.score!==void 0&&(t.value+=n.score),n.draw===!0&&(t.value+=.5),t.parentAction&&n.winner===t.parentAction.payload.playerID&&t.value++,t.parent&&this.backpropagate(t.parent,n)}play(t,n){let r=this.createNode({state:t,playerID:n}),i=this.getOpt("iterations");typeof this.iterations=="function"&&(i=this.iterations(t.G,t.ctx));let s=()=>{let o=null;for(let c of r.children)(o==null||c.visits>o.visits)&&(o=c);return{action:o&&o.parentAction,metadata:r}};return new Promise(o=>{let a=()=>{for(let u=0;u<SC&&this.iterationCounter<i;u++){let c=this.select(r),l=this.expand(c),f=this.playout(l);this.backpropagate(l,f),this.iterationCounter++}this.iterationCallback({iterationCounter:this.iterationCounter,numIterations:i,metadata:r})};if(this.iterationCounter=0,this.getOpt("async")){let u=()=>{this.iterationCounter<i?(a(),setImmediate(u)):o(s())};u()}else{for(;this.iterationCounter<i;)a();o(s())}})}},oo=class extends so{play({G:t,ctx:n},r){let i=this.enumerate(t,n,r);return Promise.resolve({action:this.random(i)})}};async function nc(e,t){let n=e.store.getState(),r=n.ctx.currentPlayer;n.ctx.activePlayers&&(r=Object.keys(n.ctx.activePlayers)[0]);let{action:i,metadata:s}=await t.play(n,r);if(i){let o={...i,payload:{...i.payload,metadata:s}};return e.store.dispatch(o),o}}function U(){}var Sc=e=>e;function jt(e,t){for(let n in t)e[n]=t[n];return e}function m1(e){return e()}function fb(){return Object.create(null)}function Le(e){e.forEach(m1)}function Yt(e){return typeof e=="function"}function ee(e,t){return e!=e?t==t:e!==t||e&&typeof e=="object"||typeof e=="function"}function TC(e){return Object.keys(e).length===0}function Hi(e,...t){if(e==null)return U;let n=e.subscribe(...t);return n.unsubscribe?()=>n.unsubscribe():n}function g1(e,t,n){e.$$.on_destroy.push(Hi(t,n))}function MC(e,t,n,r){if(e){let i=y1(e,t,n,r);return e[0](i)}}function y1(e,t,n,r){return e[1]&&r?jt(n.ctx.slice(),e[1](r(t))):n.ctx}function IC(e,t,n,r){if(e[2]&&r){let i=e[2](r(n));if(t.dirty===void 0)return i;if(typeof i=="object"){let s=[],o=Math.max(t.dirty.length,i.length);for(let a=0;a<o;a+=1)s[a]=t.dirty[a]|i[a];return s}return t.dirty|i}return t.dirty}function NC(e,t,n,r,i,s){if(i){let o=y1(t,n,r,s);e.p(o,i)}}function CC(e){if(e.ctx.length>32){let t=[],n=e.ctx.length/32;for(let r=0;r<n;r++)t[r]=-1;return t}return-1}function lo(e){let t={};for(let n in e)n[0]!=="$"&&(t[n]=e[n]);return t}function pb(e){return e??""}var v1=typeof window<"u",Tc=v1?()=>window.performance.now():()=>Date.now(),Mc=v1?e=>requestAnimationFrame(e):U,Zn=new Set;function b1(e){Zn.forEach(t=>{t.c(e)||(Zn.delete(t),t.f())}),Zn.size!==0&&Mc(b1)}function Ic(e){let t;return Zn.size===0&&Mc(b1),{promise:new Promise(n=>{Zn.add(t={c:e,f:n})}),abort(){Zn.delete(t)}}}function w(e,t){e.appendChild(t)}function de(e,t,n){let r=Nc(e);if(!r.getElementById(t)){let i=A("style");i.id=t,i.textContent=n,_1(r,i)}}function Nc(e){if(!e)return document;let t=e.getRootNode?e.getRootNode():e.ownerDocument;return t&&t.host?t:e.ownerDocument}function qC(e){let t=A("style");return _1(Nc(e),t),t.sheet}function _1(e,t){w(e.head||e,t)}function M(e,t,n){e.insertBefore(t,n||null)}function S(e){e.parentNode.removeChild(e)}function $e(e,t){for(let n=0;n<e.length;n+=1)e[n]&&e[n].d(t)}function A(e){return document.createElement(e)}function Po(e){return document.createElementNS("http://www.w3.org/2000/svg",e)}function Y(e){return document.createTextNode(e)}function q(){return Y(" ")}function at(){return Y("")}function Q(e,t,n,r){return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n,r)}function jC(e){return function(t){return t.stopPropagation(),e.call(this,t)}}function k(e,t,n){n==null?e.removeAttribute(t):e.getAttribute(t)!==n&&e.setAttribute(t,n)}function DC(e){return e===""?null:+e}function RC(e){return Array.from(e.childNodes)}function ae(e,t){t=""+t,e.wholeText!==t&&(e.data=t)}function hb(e,t){e.value=t??""}function fo(e,t){for(let n=0;n<e.options.length;n+=1){let r=e.options[n];if(r.__value===t){r.selected=!0;return}}e.selectedIndex=-1}function w1(e){let t=e.querySelector(":checked")||e.options[0];return t&&t.__value}function ie(e,t,n){e.classList[n?"add":"remove"](t)}function O1(e,t,{bubbles:n=!1,cancelable:r=!1}={}){let i=document.createEvent("CustomEvent");return i.initCustomEvent(e,n,r,t),i}var po=new Map,ho=0;function BC(e){let t=5381,n=e.length;for(;n--;)t=(t<<5)-t^e.charCodeAt(n);return t>>>0}function LC(e,t){let n={stylesheet:qC(t),rules:{}};return po.set(e,n),n}function mo(e,t,n,r,i,s,o,a=0){let u=16.666/r,c=`{
|
|
@@ -8416,10 +8416,10 @@ function resolveProperty(bgioArguments, value2, context) {
|
|
|
8416
8416
|
return get(bgioArguments.ctx, value2.path);
|
|
8417
8417
|
} else if (value2?.type === "gamePath") {
|
|
8418
8418
|
return get(bgioArguments.G, value2.path);
|
|
8419
|
-
} else if (value2?.type === "RelativePath") {
|
|
8419
|
+
} else if (value2?.type === "relativePath" || value2?.type === "RelativePath") {
|
|
8420
8420
|
const target = resolveProperties(bgioArguments, value2.target, context, "target");
|
|
8421
8421
|
return get(target.attributes, value2.path) ?? null;
|
|
8422
|
-
} else if (value2?.type === "Parent") {
|
|
8422
|
+
} else if (value2?.type === "parent" || value2?.type === "Parent") {
|
|
8423
8423
|
const originalTarget = value2.target ? resolveProperties(bgioArguments, value2.target, context, "target") : context.originalTarget;
|
|
8424
8424
|
return bgioArguments.G.bank.findParent(originalTarget) ?? null;
|
|
8425
8425
|
} else if (value2?.type === "map") {
|
|
@@ -8449,7 +8449,7 @@ function resolveProperty(bgioArguments, value2, context) {
|
|
|
8449
8449
|
}
|
|
8450
8450
|
}
|
|
8451
8451
|
return maxTargets;
|
|
8452
|
-
} else if (value2?.type === "Pick") {
|
|
8452
|
+
} else if (value2?.type === "pick" || value2?.type === "Pick") {
|
|
8453
8453
|
const target = resolveProperties(bgioArguments, value2.target, context, "target");
|
|
8454
8454
|
return (0, import_pick.default)(
|
|
8455
8455
|
resolveProperties(
|
|
@@ -8460,7 +8460,7 @@ function resolveProperty(bgioArguments, value2, context) {
|
|
|
8460
8460
|
),
|
|
8461
8461
|
value2.properties
|
|
8462
8462
|
);
|
|
8463
|
-
} else if (value2?.type === "Coordinates") {
|
|
8463
|
+
} else if (value2?.type === "coordinates" || value2?.type === "Coordinates") {
|
|
8464
8464
|
const originalTarget = value2.target ? resolveProperties(bgioArguments, value2.target, context, "target") : context.originalTarget;
|
|
8465
8465
|
const parent = bgioArguments.G.bank.findParent(originalTarget);
|
|
8466
8466
|
return parent.getCoordinates(originalTarget.rule.index);
|
package/examples/checkers.json
CHANGED
|
@@ -719,7 +719,7 @@
|
|
|
719
719
|
"expression": "(player == '0' and destinationCoordinates[1] == 0) or (player == '1' and destinationCoordinates[1] == 7)",
|
|
720
720
|
"arguments": {
|
|
721
721
|
"player": {
|
|
722
|
-
"type": "
|
|
722
|
+
"type": "relativePath",
|
|
723
723
|
"target": {
|
|
724
724
|
"type": "contextPath",
|
|
725
725
|
"path": ["originalTarget"]
|
|
@@ -727,7 +727,7 @@
|
|
|
727
727
|
"path": ["entities", 0, "rule", "player"]
|
|
728
728
|
},
|
|
729
729
|
"destinationCoordinates": {
|
|
730
|
-
"type": "
|
|
730
|
+
"type": "coordinates",
|
|
731
731
|
"target": {
|
|
732
732
|
"type": "contextPath",
|
|
733
733
|
"path": ["target"]
|
package/examples/eights.json
CHANGED
|
@@ -161,7 +161,7 @@
|
|
|
161
161
|
"conditions": [
|
|
162
162
|
{
|
|
163
163
|
"conditionType": "Is",
|
|
164
|
-
"target": { "type": "
|
|
164
|
+
"target": { "type": "parent" },
|
|
165
165
|
"matcher": { "name": "stock" }
|
|
166
166
|
},
|
|
167
167
|
{
|
|
@@ -195,7 +195,7 @@
|
|
|
195
195
|
"conditions": [
|
|
196
196
|
{
|
|
197
197
|
"conditionType": "Is",
|
|
198
|
-
"target": { "type": "
|
|
198
|
+
"target": { "type": "parent" },
|
|
199
199
|
"matcher": { "name": "stock" }
|
|
200
200
|
},
|
|
201
201
|
{
|
|
@@ -231,7 +231,7 @@
|
|
|
231
231
|
"conditions": [
|
|
232
232
|
{
|
|
233
233
|
"conditionType": "Is",
|
|
234
|
-
"target": { "type": "
|
|
234
|
+
"target": { "type": "parent" },
|
|
235
235
|
"matcher": { "name": "discard" }
|
|
236
236
|
},
|
|
237
237
|
{
|
|
@@ -298,7 +298,7 @@
|
|
|
298
298
|
"conditions": [
|
|
299
299
|
{
|
|
300
300
|
"conditionType": "Is",
|
|
301
|
-
"target": { "type": "
|
|
301
|
+
"target": { "type": "parent" },
|
|
302
302
|
"matcher": {
|
|
303
303
|
"name": "hand",
|
|
304
304
|
"player": {
|
|
@@ -319,13 +319,13 @@
|
|
|
319
319
|
{
|
|
320
320
|
"conditionType": "Is",
|
|
321
321
|
"matcher": {
|
|
322
|
-
"type": "
|
|
322
|
+
"type": "pick",
|
|
323
323
|
"properties": ["suit"],
|
|
324
324
|
"target": {
|
|
325
325
|
"conditions": [
|
|
326
326
|
{
|
|
327
327
|
"conditionType": "Is",
|
|
328
|
-
"target": { "type": "
|
|
328
|
+
"target": { "type": "parent" },
|
|
329
329
|
"matcher": { "name": "discard" }
|
|
330
330
|
},
|
|
331
331
|
{
|
|
@@ -339,13 +339,13 @@
|
|
|
339
339
|
{
|
|
340
340
|
"conditionType": "Is",
|
|
341
341
|
"matcher": {
|
|
342
|
-
"type": "
|
|
342
|
+
"type": "pick",
|
|
343
343
|
"properties": ["value"],
|
|
344
344
|
"target": {
|
|
345
345
|
"conditions": [
|
|
346
346
|
{
|
|
347
347
|
"conditionType": "Is",
|
|
348
|
-
"target": { "type": "
|
|
348
|
+
"target": { "type": "parent" },
|
|
349
349
|
"matcher": { "name": "discard" }
|
|
350
350
|
},
|
|
351
351
|
{
|
|
@@ -452,7 +452,7 @@
|
|
|
452
452
|
"conditions": [
|
|
453
453
|
{
|
|
454
454
|
"conditionType": "Is",
|
|
455
|
-
"target": { "type": "
|
|
455
|
+
"target": { "type": "parent" },
|
|
456
456
|
"matcher": { "name": "discard" }
|
|
457
457
|
},
|
|
458
458
|
{
|
|
@@ -512,7 +512,7 @@
|
|
|
512
512
|
"matcher": {
|
|
513
513
|
"name": "score",
|
|
514
514
|
"player": {
|
|
515
|
-
"type": "
|
|
515
|
+
"type": "relativePath",
|
|
516
516
|
"target": {
|
|
517
517
|
"conditions": [
|
|
518
518
|
{
|
|
@@ -538,7 +538,7 @@
|
|
|
538
538
|
"expression": "existingScore + sum(faceValues)",
|
|
539
539
|
"arguments": {
|
|
540
540
|
"existingScore": {
|
|
541
|
-
"type": "
|
|
541
|
+
"type": "relativePath",
|
|
542
542
|
"target": {
|
|
543
543
|
"conditions": [
|
|
544
544
|
{
|
|
@@ -546,7 +546,7 @@
|
|
|
546
546
|
"matcher": {
|
|
547
547
|
"name": "score",
|
|
548
548
|
"player": {
|
|
549
|
-
"type": "
|
|
549
|
+
"type": "relativePath",
|
|
550
550
|
"target": {
|
|
551
551
|
"conditions": [
|
|
552
552
|
{
|
|
@@ -574,7 +574,7 @@
|
|
|
574
574
|
"conditions": [
|
|
575
575
|
{
|
|
576
576
|
"conditionType": "Is",
|
|
577
|
-
"target": { "type": "
|
|
577
|
+
"target": { "type": "parent" },
|
|
578
578
|
"matcher": {
|
|
579
579
|
"name": "hand",
|
|
580
580
|
"player": {
|
|
@@ -590,7 +590,7 @@
|
|
|
590
590
|
"expression": "cardValue == 8 ? 50 : (cardValue >= 10 and cardValue <= 13) ? 10 : cardValue",
|
|
591
591
|
"arguments": {
|
|
592
592
|
"cardValue": {
|
|
593
|
-
"
|
|
593
|
+
"type": "relativePath",
|
|
594
594
|
"target": {
|
|
595
595
|
|
|
596
596
|
"type": "contextPath",
|
|
@@ -627,7 +627,7 @@
|
|
|
627
627
|
"expression": "score >= numPlayers * 50",
|
|
628
628
|
"arguments": {
|
|
629
629
|
"score": {
|
|
630
|
-
"type": "
|
|
630
|
+
"type": "relativePath",
|
|
631
631
|
"target": {
|
|
632
632
|
"type": "contextPath",
|
|
633
633
|
"path": ["loopTarget"]
|
package/package.json
CHANGED
|
@@ -19,7 +19,7 @@ export default class Condition {
|
|
|
19
19
|
newContext
|
|
20
20
|
)
|
|
21
21
|
|
|
22
|
-
// We don't simply defer to payload target because of
|
|
22
|
+
// We don't simply defer to payload target because of parent and relativePath
|
|
23
23
|
// target types, for instance, which retarget to another entity
|
|
24
24
|
if (rule.target !== undefined) {
|
|
25
25
|
conditionPayload.target = rule.target
|
|
@@ -65,10 +65,10 @@ function resolveProperty (bgioArguments, value, context) {
|
|
|
65
65
|
return get(bgioArguments.ctx, value.path)
|
|
66
66
|
} else if (value?.type === 'gamePath') {
|
|
67
67
|
return get(bgioArguments.G, value.path)
|
|
68
|
-
} else if (value?.type === 'RelativePath') {
|
|
68
|
+
} else if (value?.type === 'relativePath' || value?.type === 'RelativePath') {
|
|
69
69
|
const target = resolveProperties(bgioArguments, value.target, context, 'target')
|
|
70
70
|
return get(target.attributes, value.path) ?? null
|
|
71
|
-
} else if (value?.type === 'Parent') {
|
|
71
|
+
} else if (value?.type === 'parent' || value?.type === 'Parent') {
|
|
72
72
|
const originalTarget = value.target
|
|
73
73
|
? resolveProperties(bgioArguments, value.target, context, 'target')
|
|
74
74
|
: context.originalTarget
|
|
@@ -100,7 +100,7 @@ function resolveProperty (bgioArguments, value, context) {
|
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
102
|
return maxTargets
|
|
103
|
-
} else if (value?.type === 'Pick') {
|
|
103
|
+
} else if (value?.type === 'pick' || value?.type === 'Pick') {
|
|
104
104
|
const target = resolveProperties(bgioArguments, value.target, context, 'target')
|
|
105
105
|
return pick(
|
|
106
106
|
resolveProperties(
|
|
@@ -111,12 +111,12 @@ function resolveProperty (bgioArguments, value, context) {
|
|
|
111
111
|
),
|
|
112
112
|
value.properties
|
|
113
113
|
)
|
|
114
|
-
} else if (value?.type === 'Coordinates') {
|
|
114
|
+
} else if (value?.type === 'coordinates' || value?.type === 'Coordinates') {
|
|
115
115
|
const originalTarget = value.target
|
|
116
116
|
? resolveProperties(bgioArguments, value.target, context, 'target')
|
|
117
117
|
: context.originalTarget
|
|
118
|
-
|
|
119
|
-
|
|
118
|
+
const parent = bgioArguments.G.bank.findParent(originalTarget)
|
|
119
|
+
return parent.getCoordinates(originalTarget.rule.index)
|
|
120
120
|
} else if (value?.type === 'relativeCoordinates') {
|
|
121
121
|
const originalTarget = value.target
|
|
122
122
|
? resolveProperties(bgioArguments, value.target, context, 'target')
|
|
@@ -126,9 +126,9 @@ function resolveProperty (bgioArguments, value, context) {
|
|
|
126
126
|
parent.getCoordinates(originalTarget.rule.index)
|
|
127
127
|
const newCoordinates =
|
|
128
128
|
parent.getRelativeCoordinates(
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
129
|
+
oldCoordinates,
|
|
130
|
+
resolveProperties(bgioArguments, value.location, context, 'location')
|
|
131
|
+
)
|
|
132
132
|
return (newCoordinates && parent.spaces[parent.getIndex(newCoordinates)]) ?? null
|
|
133
133
|
} else {
|
|
134
134
|
return value
|