board-game-engine 1.0.4 → 1.0.5

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.
@@ -27071,7 +27071,7 @@ function createPayload(bgioState, moveRule, targets, context) {
27071
27071
  var Client2 = class {
27072
27072
  constructor(options) {
27073
27073
  this.options = options;
27074
- this.game = options.boardgameIOGame || gameFactory(JSON.parse(options.gameRules));
27074
+ this.game = options.boardgameIOGame || gameFactory(JSON.parse(options.gameRules), options.gameName);
27075
27075
  if (!options.boardgameIOGame) {
27076
27076
  this.moveBuilder = { targets: [], stepIndex: 0, eliminatedMoves: [] };
27077
27077
  this.optimisticWinner = null;
@@ -27071,7 +27071,7 @@ ${message}`);
27071
27071
  var Client2 = class {
27072
27072
  constructor(options) {
27073
27073
  this.options = options;
27074
- this.game = options.boardgameIOGame || gameFactory(JSON.parse(options.gameRules));
27074
+ this.game = options.boardgameIOGame || gameFactory(JSON.parse(options.gameRules), options.gameName);
27075
27075
  if (!options.boardgameIOGame) {
27076
27076
  this.moveBuilder = { targets: [], stepIndex: 0, eliminatedMoves: [] };
27077
27077
  this.optimisticWinner = null;
@@ -29,7 +29,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
29
29
  <th class="svelte-ztcwsu">Action</th>`,r=q(),i=A("tbody");for(let c=0;c<a.length;c+=1)a[c].c();k(t,"class","svelte-ztcwsu")},m(c,l){M(c,t,l),w(t,n),w(t,r),w(t,i);for(let f=0;f<a.length;f+=1)a[f].m(i,null);s=!0},p(c,[l]){if(l&15){o=c[1];let f;for(f=0;f<o.length;f+=1){let p=Wb(c,o,f);a[f]?(a[f].p(p,l),P(a[f],1)):(a[f]=Jb(p),a[f].c(),P(a[f],1),a[f].m(i,null))}for(ce(),f=o.length;f<a.length;f+=1)u(f);le()}},i(c){if(!s){for(let l=0;l<o.length;l+=1)P(a[l]);s=!0}},o(c){a=a.filter(Boolean);for(let l=0;l<a.length;l+=1)x(a[l]);s=!1},d(c){c&&S(t),$e(a,c)}}}function B3(e,t,n){let{root:r}=t,{selectedIndex:i=null}=t,s=Ji(),o=[],a=[];function u(h,d){s("select",{node:h,selectedIndex:d})}function c(h,d){i===null&&s("preview",{node:h})}let l=(h,d)=>u(h,d),f=h=>c(null),p=(h,d)=>c(h);return e.$$set=h=>{"root"in h&&n(4,r=h.root),"selectedIndex"in h&&n(0,i=h.selectedIndex)},e.$$.update=()=>{if(e.$$.dirty&48){let h=r;for(n(5,o=[]);h.parent;){let d=h.parent,{type:y,args:m}=h.parentAction.payload,b=(m||[]).join(","),g=`${y}(${b})`;o.push({parent:d,arrowText:g}),h=d}o.reverse(),n(1,a=[...r.children].sort((d,y)=>d.visits<y.visits?1:-1).slice(0,50))}},[i,a,u,c,r,o,l,f,p]}var Vi=class extends Z{constructor(t){super(),te(this,t,B3,R3,ee,{root:4,selectedIndex:0},D3)}};function L3(e){de(e,"svelte-1f0amz4",".visualizer.svelte-1f0amz4{display:flex;flex-direction:column;align-items:center;padding:50px}.preview.svelte-1f0amz4{opacity:0.5}.icon.svelte-1f0amz4{color:#777;width:32px;height:32px;margin-bottom:20px}")}function Yb(e,t,n){let r=e.slice();return r[9]=t[n].node,r[10]=t[n].selectedIndex,r[12]=n,r}function G3(e){let t,n,r;return n=new Oo({}),{c(){t=A("div"),L(n.$$.fragment),k(t,"class","icon svelte-1f0amz4")},m(i,s){M(i,t,s),R(n,t,null),r=!0},i(i){r||(P(n.$$.fragment,i),r=!0)},o(i){x(n.$$.fragment,i),r=!1},d(i){i&&S(t),B(n)}}}function F3(e){let t,n;function r(...i){return e[7](e[12],...i)}return t=new Vi({props:{root:e[9],selectedIndex:e[10]}}),t.$on("select",r),{c(){L(t.$$.fragment)},m(i,s){R(t,i,s),n=!0},p(i,s){e=i;let o={};s&1&&(o.root=e[9]),s&1&&(o.selectedIndex=e[10]),t.$set(o)},i(i){n||(P(t.$$.fragment,i),n=!0)},o(i){x(t.$$.fragment,i),n=!1},d(i){B(t,i)}}}function U3(e){let t,n;function r(...s){return e[5](e[12],...s)}function i(...s){return e[6](e[12],...s)}return t=new Vi({props:{root:e[9]}}),t.$on("select",r),t.$on("preview",i),{c(){L(t.$$.fragment)},m(s,o){R(t,s,o),n=!0},p(s,o){e=s;let a={};o&1&&(a.root=e[9]),t.$set(a)},i(s){n||(P(t.$$.fragment,s),n=!0)},o(s){x(t.$$.fragment,s),n=!1},d(s){B(t,s)}}}function $b(e){let t,n,r,i,s,o=e[12]!==0&&G3(),a=[U3,F3],u=[];function c(l,f){return l[12]===l[0].length-1?0:1}return r=c(e),i=u[r]=a[r](e),{c(){o&&o.c(),t=q(),n=A("section"),i.c()},m(l,f){o&&o.m(l,f),M(l,t,f),M(l,n,f),u[r].m(n,null),s=!0},p(l,f){let p=r;r=c(l),r===p?u[r].p(l,f):(ce(),x(u[p],1,1,()=>{u[p]=null}),le(),i=u[r],i?i.p(l,f):(i=u[r]=a[r](l),i.c()),P(i,1),i.m(n,null))},i(l){s||(P(o),P(i),s=!0)},o(l){x(o),x(i),s=!1},d(l){o&&o.d(l),l&&S(t),l&&S(n),u[r].d()}}}function Xb(e){let t,n,r,i,s,o;return n=new Oo({}),s=new Vi({props:{root:e[1]}}),{c(){t=A("div"),L(n.$$.fragment),r=q(),i=A("section"),L(s.$$.fragment),k(t,"class","icon svelte-1f0amz4"),k(i,"class","preview svelte-1f0amz4")},m(a,u){M(a,t,u),R(n,t,null),M(a,r,u),M(a,i,u),R(s,i,null),o=!0},p(a,u){let c={};u&2&&(c.root=a[1]),s.$set(c)},i(a){o||(P(n.$$.fragment,a),P(s.$$.fragment,a),o=!0)},o(a){x(n.$$.fragment,a),x(s.$$.fragment,a),o=!1},d(a){a&&S(t),B(n),a&&S(r),a&&S(i),B(s)}}}function V3(e){let t,n,r,i=e[0],s=[];for(let u=0;u<i.length;u+=1)s[u]=$b(Yb(e,i,u));let o=u=>x(s[u],1,1,()=>{s[u]=null}),a=e[1]&&Xb(e);return{c(){t=A("div");for(let u=0;u<s.length;u+=1)s[u].c();n=q(),a&&a.c(),k(t,"class","visualizer svelte-1f0amz4")},m(u,c){M(u,t,c);for(let l=0;l<s.length;l+=1)s[l].m(t,null);w(t,n),a&&a.m(t,null),r=!0},p(u,[c]){if(c&13){i=u[0];let l;for(l=0;l<i.length;l+=1){let f=Yb(u,i,l);s[l]?(s[l].p(f,c),P(s[l],1)):(s[l]=$b(f),s[l].c(),P(s[l],1),s[l].m(t,n))}for(ce(),l=i.length;l<s.length;l+=1)o(l);le()}u[1]?a?(a.p(u,c),c&2&&P(a,1)):(a=Xb(u),a.c(),P(a,1),a.m(t,null)):a&&(ce(),x(a,1,1,()=>{a=null}),le())},i(u){if(!r){for(let c=0;c<i.length;c+=1)P(s[c]);P(a),r=!0}},o(u){s=s.filter(Boolean);for(let c=0;c<s.length;c+=1)x(s[c]);x(a),r=!1},d(u){u&&S(t),$e(s,u),a&&a.d()}}}function z3(e,t,n){let{metadata:r}=t,i=[],s=null;function o({node:f,selectedIndex:p},h){n(1,s=null),n(0,i[h].selectedIndex=p,i),n(0,i=[...i.slice(0,h+1),{node:f}])}function a({node:f},p){n(1,s=f)}let u=(f,p)=>o(p.detail,f),c=(f,p)=>a(p.detail),l=(f,p)=>o(p.detail,f);return e.$$set=f=>{"metadata"in f&&n(4,r=f.metadata)},e.$$.update=()=>{e.$$.dirty&16&&n(0,i=[{node:r}])},[i,s,o,a,r,u,c,l]}var zi=class extends Z{constructor(t){super(),te(this,t,z3,V3,ee,{metadata:4},L3)}};function K3(e){de(e,"svelte-1pq5e4b",".gamelog.svelte-1pq5e4b{display:grid;grid-template-columns:30px 1fr 30px;grid-auto-rows:auto;grid-auto-flow:column}")}function Qb(e,t,n){let r=e.slice();return r[16]=t[n].phase,r[18]=n,r}function Zb(e,t,n){let r=e.slice();return r[19]=t[n].action,r[20]=t[n].metadata,r[18]=n,r}function e1(e,t,n){let r=e.slice();return r[22]=t[n].turn,r[18]=n,r}function t1(e){let t,n;return t=new _c({props:{turn:e[22],numEvents:e[3][e[18]]}}),{c(){L(t.$$.fragment)},m(r,i){R(t,r,i),n=!0},p(r,i){let s={};i&2&&(s.turn=r[22]),i&8&&(s.numEvents=r[3][r[18]]),t.$set(s)},i(r){n||(P(t.$$.fragment,r),n=!0)},o(r){x(t.$$.fragment,r),n=!1},d(r){B(t,r)}}}function n1(e){let t,n,r=e[18]in e[3]&&t1(e);return{c(){r&&r.c(),t=at()},m(i,s){r&&r.m(i,s),M(i,t,s),n=!0},p(i,s){i[18]in i[3]?r?(r.p(i,s),s&8&&P(r,1)):(r=t1(i),r.c(),P(r,1),r.m(t.parentNode,t)):r&&(ce(),x(r,1,1,()=>{r=null}),le())},i(i){n||(P(r),n=!0)},o(i){x(r),n=!1},d(i){r&&r.d(i),i&&S(t)}}}function r1(e){let t,n;return t=new Pc({props:{pinned:e[18]===e[2],logIndex:e[18],action:e[19],metadata:e[20]}}),t.$on("click",e[5]),t.$on("mouseenter",e[6]),t.$on("mouseleave",e[7]),{c(){L(t.$$.fragment)},m(r,i){R(t,r,i),n=!0},p(r,i){let s={};i&4&&(s.pinned=r[18]===r[2]),i&2&&(s.action=r[19]),i&2&&(s.metadata=r[20]),t.$set(s)},i(r){n||(P(t.$$.fragment,r),n=!0)},o(r){x(t.$$.fragment,r),n=!1},d(r){B(t,r)}}}function i1(e){let t,n;return t=new wc({props:{phase:e[16],numEvents:e[4][e[18]]}}),{c(){L(t.$$.fragment)},m(r,i){R(t,r,i),n=!0},p(r,i){let s={};i&2&&(s.phase=r[16]),i&16&&(s.numEvents=r[4][r[18]]),t.$set(s)},i(r){n||(P(t.$$.fragment,r),n=!0)},o(r){x(t.$$.fragment,r),n=!1},d(r){B(t,r)}}}function s1(e){let t,n,r=e[18]in e[4]&&i1(e);return{c(){r&&r.c(),t=at()},m(i,s){r&&r.m(i,s),M(i,t,s),n=!0},p(i,s){i[18]in i[4]?r?(r.p(i,s),s&16&&P(r,1)):(r=i1(i),r.c(),P(r,1),r.m(t.parentNode,t)):r&&(ce(),x(r,1,1,()=>{r=null}),le())},i(i){n||(P(r),n=!0)},o(i){x(r),n=!1},d(i){r&&r.d(i),i&&S(t)}}}function H3(e){let t,n,r,i,s,o,a=e[1],u=[];for(let m=0;m<a.length;m+=1)u[m]=n1(e1(e,a,m));let c=m=>x(u[m],1,1,()=>{u[m]=null}),l=e[1],f=[];for(let m=0;m<l.length;m+=1)f[m]=r1(Zb(e,l,m));let p=m=>x(f[m],1,1,()=>{f[m]=null}),h=e[1],d=[];for(let m=0;m<h.length;m+=1)d[m]=s1(Qb(e,h,m));let y=m=>x(d[m],1,1,()=>{d[m]=null});return{c(){t=A("div");for(let m=0;m<u.length;m+=1)u[m].c();n=q();for(let m=0;m<f.length;m+=1)f[m].c();r=q();for(let m=0;m<d.length;m+=1)d[m].c();k(t,"class","gamelog svelte-1pq5e4b"),ie(t,"pinned",e[2])},m(m,b){M(m,t,b);for(let g=0;g<u.length;g+=1)u[g].m(t,null);w(t,n);for(let g=0;g<f.length;g+=1)f[g].m(t,null);w(t,r);for(let g=0;g<d.length;g+=1)d[g].m(t,null);i=!0,s||(o=Q(window,"keydown",e[8]),s=!0)},p(m,[b]){if(b&10){a=m[1];let g;for(g=0;g<a.length;g+=1){let O=e1(m,a,g);u[g]?(u[g].p(O,b),P(u[g],1)):(u[g]=n1(O),u[g].c(),P(u[g],1),u[g].m(t,n))}for(ce(),g=a.length;g<u.length;g+=1)c(g);le()}if(b&230){l=m[1];let g;for(g=0;g<l.length;g+=1){let O=Zb(m,l,g);f[g]?(f[g].p(O,b),P(f[g],1)):(f[g]=r1(O),f[g].c(),P(f[g],1),f[g].m(t,r))}for(ce(),g=l.length;g<f.length;g+=1)p(g);le()}if(b&18){h=m[1];let g;for(g=0;g<h.length;g+=1){let O=Qb(m,h,g);d[g]?(d[g].p(O,b),P(d[g],1)):(d[g]=s1(O),d[g].c(),P(d[g],1),d[g].m(t,null))}for(ce(),g=h.length;g<d.length;g+=1)y(g);le()}b&4&&ie(t,"pinned",m[2])},i(m){if(!i){for(let b=0;b<a.length;b+=1)P(u[b]);for(let b=0;b<l.length;b+=1)P(f[b]);for(let b=0;b<h.length;b+=1)P(d[b]);i=!0}},o(m){u=u.filter(Boolean);for(let b=0;b<u.length;b+=1)x(u[b]);f=f.filter(Boolean);for(let b=0;b<f.length;b+=1)x(f[b]);d=d.filter(Boolean);for(let b=0;b<d.length;b+=1)x(d[b]);i=!1},d(m){m&&S(t),$e(u,m),$e(f,m),$e(d,m),s=!1,o()}}}function W3(e,t,n){let r,i=U,s=()=>(i(),i=Hi(o,j=>n(10,r=j)),o);e.$$.on_destroy.push(()=>i());let{client:o}=t;s();let{secondaryPane:a}=wn("secondaryPane"),u=Xn({game:o.game}),c=o.getInitialState(),{log:l}=r,f=null;function p(j){let N=c;for(let D=0;D<l.length;D++){let{action:J,automatic:fe}=l[D];if(!fe){if(N=u(N,J),j==0)break;j--}}return{G:N.G,ctx:N.ctx,plugins:N.plugins}}function h(j){let{logIndex:N}=j.detail,D=p(N),J=l.filter(fe=>!fe.automatic);if(o.overrideGameState(D),f==N)n(2,f=null),a.set(null);else{n(2,f=N);let{metadata:fe}=J[N].action.payload;fe&&a.set({component:zi,metadata:fe})}}function d(j){let{logIndex:N}=j.detail;if(f===null){let D=p(N);o.overrideGameState(D)}}function y(){f===null&&o.overrideGameState(null)}function m(){n(2,f=null),o.overrideGameState(null),a.set(null)}Cc(m);function b(j){j.keyCode==27&&m()}let g,O={},I={};return e.$$set=j=>{"client"in j&&s(n(0,o=j.client))},e.$$.update=()=>{if(e.$$.dirty&1538){n(9,l=r.log),n(1,g=l.filter(D=>!D.automatic));let j=0,N=0;n(3,O={}),n(4,I={});for(let D=0;D<g.length;D++){let{action:J,payload:fe,turn:V,phase:se}=g[D];N++,j++,(D==g.length-1||g[D+1].turn!=V)&&(n(3,O[D]=N,O),N=0),(D==g.length-1||g[D+1].phase!=se)&&(n(4,I[D]=j,I),j=0)}}},[o,g,f,O,I,h,d,y,b,l,r]}var kc=class extends Z{constructor(t){super(),te(this,t,W3,H3,ee,{client:0},K3)}};function J3(e){de(e,"svelte-1fu900w","label.svelte-1fu900w{color:#666}.option.svelte-1fu900w{margin-bottom:20px}.value.svelte-1fu900w{font-weight:bold;color:#000}input[type='checkbox'].svelte-1fu900w{vertical-align:middle}")}function o1(e,t,n){let r=e.slice();return r[6]=t[n][0],r[7]=t[n][1],r[8]=t,r[9]=n,r}function Y3(e){let t,n,r,i;function s(){e[5].call(t,e[6])}return{c(){t=A("input"),k(t,"id",n=e[3](e[6])),k(t,"type","checkbox"),k(t,"class","svelte-1fu900w")},m(o,a){M(o,t,a),t.checked=e[1][e[6]],r||(i=[Q(t,"change",s),Q(t,"change",e[2])],r=!0)},p(o,a){e=o,a&1&&n!==(n=e[3](e[6]))&&k(t,"id",n),a&3&&(t.checked=e[1][e[6]])},d(o){o&&S(t),r=!1,Le(i)}}}function $3(e){let t,n=e[1][e[6]]+"",r,i,s,o,a,u,c,l;function f(){e[4].call(s,e[6])}return{c(){t=A("span"),r=Y(n),i=q(),s=A("input"),k(t,"class","value svelte-1fu900w"),k(s,"id",o=e[3](e[6])),k(s,"type","range"),k(s,"min",a=e[7].range.min),k(s,"max",u=e[7].range.max)},m(p,h){M(p,t,h),w(t,r),M(p,i,h),M(p,s,h),hb(s,e[1][e[6]]),c||(l=[Q(s,"change",f),Q(s,"input",f),Q(s,"change",e[2])],c=!0)},p(p,h){e=p,h&3&&n!==(n=e[1][e[6]]+"")&&ae(r,n),h&1&&o!==(o=e[3](e[6]))&&k(s,"id",o),h&1&&a!==(a=e[7].range.min)&&k(s,"min",a),h&1&&u!==(u=e[7].range.max)&&k(s,"max",u),h&3&&hb(s,e[1][e[6]])},d(p){p&&S(t),p&&S(i),p&&S(s),c=!1,Le(l)}}}function a1(e){let t,n,r=e[6]+"",i,s,o,a;function u(f,p){if(f[7].range)return $3;if(typeof f[7].value=="boolean")return Y3}let c=u(e),l=c&&c(e);return{c(){t=A("div"),n=A("label"),i=Y(r),o=q(),l&&l.c(),a=q(),k(n,"for",s=e[3](e[6])),k(n,"class","svelte-1fu900w"),k(t,"class","option svelte-1fu900w")},m(f,p){M(f,t,p),w(t,n),w(n,i),w(t,o),l&&l.m(t,null),w(t,a)},p(f,p){p&1&&r!==(r=f[6]+"")&&ae(i,r),p&1&&s!==(s=f[3](f[6]))&&k(n,"for",s),c===(c=u(f))&&l?l.p(f,p):(l&&l.d(1),l=c&&c(f),l&&(l.c(),l.m(t,a)))},d(f){f&&S(t),l&&l.d()}}}function X3(e){let t,n=Object.entries(e[0].opts()),r=[];for(let i=0;i<n.length;i+=1)r[i]=a1(o1(e,n,i));return{c(){for(let i=0;i<r.length;i+=1)r[i].c();t=at()},m(i,s){for(let o=0;o<r.length;o+=1)r[o].m(i,s);M(i,t,s)},p(i,[s]){if(s&15){n=Object.entries(i[0].opts());let o;for(o=0;o<n.length;o+=1){let a=o1(i,n,o);r[o]?r[o].p(a,s):(r[o]=a1(a),r[o].c(),r[o].m(t.parentNode,t))}for(;o<r.length;o+=1)r[o].d(1);r.length=n.length}},i:U,o:U,d(i){$e(r,i),i&&S(t)}}}function Q3(e,t,n){let{bot:r}=t,i={};for(let[c,l]of Object.entries(r.opts()))i[c]=l.value;function s(){for(let[c,l]of Object.entries(i))r.setOpt(c,l)}let o=c=>"ai-option-"+c;function a(c){i[c]=DC(this.value),n(1,i)}function u(c){i[c]=this.checked,n(1,i)}return e.$$set=c=>{"bot"in c&&n(0,r=c.bot)},[r,i,s,o,a,u]}var Ac=class extends Z{constructor(t){super(),te(this,t,Q3,X3,ee,{bot:0},J3)}};function Z3(e){de(e,"svelte-fn09gm","ul.svelte-fn09gm{padding-left:0}li.svelte-fn09gm{list-style:none;margin:0;margin-bottom:5px}h3.svelte-fn09gm{text-transform:uppercase}label.svelte-fn09gm{color:#666}input[type='checkbox'].svelte-fn09gm{vertical-align:middle}")}function u1(e,t,n){let r=e.slice();return r[7]=t[n],r}function ej(e){let t,n,r;return{c(){t=A("p"),t.textContent="No bots available.",n=q(),r=A("p"),r.innerHTML=`Follow the instructions
30
30
  <a href="https://boardgame.io/documentation/#/tutorial?id=bots" target="_blank">here</a>
31
31
  to set up bots.`},m(i,s){M(i,t,s),M(i,n,s),M(i,r,s)},p:U,i:U,o:U,d(i){i&&S(t),i&&S(n),i&&S(r)}}}function tj(e){let t;return{c(){t=A("p"),t.textContent="The bot debugger is only available in singleplayer mode."},m(n,r){M(n,t,r)},p:U,i:U,o:U,d(n){n&&S(t)}}}function nj(e){let t,n,r,i,s,o,a,u,c,l,f,p,h,d,y,m,b,g,O=Object.keys(e[7].opts()).length,I,j,N,D,J;o=new vt({props:{value:"1",onPress:e[13],label:"reset"}}),c=new vt({props:{value:"2",onPress:e[11],label:"play"}}),p=new vt({props:{value:"3",onPress:e[12],label:"simulate"}});let fe=Object.keys(e[8]),V=[];for(let G=0;G<fe.length;G+=1)V[G]=c1(u1(e,fe,G));let se=O&&l1(e),ne=(e[5]||e[3])&&f1(e);return{c(){t=A("section"),n=A("h3"),n.textContent="Controls",r=q(),i=A("ul"),s=A("li"),L(o.$$.fragment),a=q(),u=A("li"),L(c.$$.fragment),l=q(),f=A("li"),L(p.$$.fragment),h=q(),d=A("section"),y=A("h3"),y.textContent="Bot",m=q(),b=A("select");for(let G=0;G<V.length;G+=1)V[G].c();g=q(),se&&se.c(),I=q(),ne&&ne.c(),j=at(),k(n,"class","svelte-fn09gm"),k(s,"class","svelte-fn09gm"),k(u,"class","svelte-fn09gm"),k(f,"class","svelte-fn09gm"),k(i,"class","svelte-fn09gm"),k(y,"class","svelte-fn09gm"),e[4]===void 0&&ot(()=>e[17].call(b))},m(G,Pe){M(G,t,Pe),w(t,n),w(t,r),w(t,i),w(i,s),R(o,s,null),w(i,a),w(i,u),R(c,u,null),w(i,l),w(i,f),R(p,f,null),M(G,h,Pe),M(G,d,Pe),w(d,y),w(d,m),w(d,b);for(let ue=0;ue<V.length;ue+=1)V[ue].m(b,null);fo(b,e[4]),M(G,g,Pe),se&&se.m(G,Pe),M(G,I,Pe),ne&&ne.m(G,Pe),M(G,j,Pe),N=!0,D||(J=[Q(b,"change",e[17]),Q(b,"change",e[10])],D=!0)},p(G,Pe){if(Pe&256){fe=Object.keys(G[8]);let ue;for(ue=0;ue<fe.length;ue+=1){let Lt=u1(G,fe,ue);V[ue]?V[ue].p(Lt,Pe):(V[ue]=c1(Lt),V[ue].c(),V[ue].m(b,null))}for(;ue<V.length;ue+=1)V[ue].d(1);V.length=fe.length}Pe&272&&fo(b,G[4]),Pe&128&&(O=Object.keys(G[7].opts()).length),O?se?(se.p(G,Pe),Pe&128&&P(se,1)):(se=l1(G),se.c(),P(se,1),se.m(I.parentNode,I)):se&&(ce(),x(se,1,1,()=>{se=null}),le()),G[5]||G[3]?ne?ne.p(G,Pe):(ne=f1(G),ne.c(),ne.m(j.parentNode,j)):ne&&(ne.d(1),ne=null)},i(G){N||(P(o.$$.fragment,G),P(c.$$.fragment,G),P(p.$$.fragment,G),P(se),N=!0)},o(G){x(o.$$.fragment,G),x(c.$$.fragment,G),x(p.$$.fragment,G),x(se),N=!1},d(G){G&&S(t),B(o),B(c),B(p),G&&S(h),G&&S(d),$e(V,G),G&&S(g),se&&se.d(G),G&&S(I),ne&&ne.d(G),G&&S(j),D=!1,Le(J)}}}function c1(e){let t,n=e[7]+"",r;return{c(){t=A("option"),r=Y(n),t.__value=e[7],t.value=t.__value},m(i,s){M(i,t,s),w(t,r)},p:U,d(i){i&&S(t)}}}function l1(e){let t,n,r,i,s,o,a,u,c,l,f;return u=new Ac({props:{bot:e[7]}}),{c(){t=A("section"),n=A("h3"),n.textContent="Options",r=q(),i=A("label"),i.textContent="debug",s=q(),o=A("input"),a=q(),L(u.$$.fragment),k(n,"class","svelte-fn09gm"),k(i,"for","ai-option-debug"),k(i,"class","svelte-fn09gm"),k(o,"id","ai-option-debug"),k(o,"type","checkbox"),k(o,"class","svelte-fn09gm")},m(p,h){M(p,t,h),w(t,n),w(t,r),w(t,i),w(t,s),w(t,o),o.checked=e[1],w(t,a),R(u,t,null),c=!0,l||(f=[Q(o,"change",e[18]),Q(o,"change",e[9])],l=!0)},p(p,h){h&2&&(o.checked=p[1]);let d={};h&128&&(d.bot=p[7]),u.$set(d)},i(p){c||(P(u.$$.fragment,p),c=!0)},o(p){x(u.$$.fragment,p),c=!1},d(p){p&&S(t),B(u),l=!1,Le(f)}}}function f1(e){let t,n,r,i,s=e[2]&&e[2]<1&&p1(e),o=e[5]&&h1(e);return{c(){t=A("section"),n=A("h3"),n.textContent="Result",r=q(),s&&s.c(),i=q(),o&&o.c(),k(n,"class","svelte-fn09gm")},m(a,u){M(a,t,u),w(t,n),w(t,r),s&&s.m(t,null),w(t,i),o&&o.m(t,null)},p(a,u){a[2]&&a[2]<1?s?s.p(a,u):(s=p1(a),s.c(),s.m(t,i)):s&&(s.d(1),s=null),a[5]?o?o.p(a,u):(o=h1(a),o.c(),o.m(t,null)):o&&(o.d(1),o=null)},d(a){a&&S(t),s&&s.d(),o&&o.d()}}}function p1(e){let t;return{c(){t=A("progress"),t.value=e[2]},m(n,r){M(n,t,r)},p(n,r){r&4&&(t.value=n[2])},d(n){n&&S(t)}}}function h1(e){let t,n,r,i,s,o,a,u=JSON.stringify(e[6])+"",c;return{c(){t=A("ul"),n=A("li"),r=Y("Action: "),i=Y(e[5]),s=q(),o=A("li"),a=Y("Args: "),c=Y(u),k(n,"class","svelte-fn09gm"),k(o,"class","svelte-fn09gm"),k(t,"class","svelte-fn09gm")},m(l,f){M(l,t,f),w(t,n),w(n,r),w(n,i),w(t,s),w(t,o),w(o,a),w(o,c)},p(l,f){f&32&&ae(i,l[5]),f&64&&u!==(u=JSON.stringify(l[6])+"")&&ae(c,u)},d(l){l&&S(t)}}}function rj(e){let t,n,r,i,s,o,a=[nj,tj,ej],u=[];function c(l,f){return l[0].game.ai&&!l[0].multiplayer?0:l[0].multiplayer?1:2}return n=c(e),r=u[n]=a[n](e),{c(){t=A("section"),r.c()},m(l,f){M(l,t,f),u[n].m(t,null),i=!0,s||(o=Q(window,"keydown",e[14]),s=!0)},p(l,[f]){let p=n;n=c(l),n===p?u[n].p(l,f):(ce(),x(u[p],1,1,()=>{u[p]=null}),le(),r=u[n],r?r.p(l,f):(r=u[n]=a[n](l),r.c()),P(r,1),r.m(t,null))},i(l){i||(P(r),i=!0)},o(l){x(r),i=!1},d(l){l&&S(t),u[n].d(),s=!1,o()}}}function ij(e,t,n){let{client:r}=t,{clientManager:i}=t,{ToggleVisibility:s}=t,{secondaryPane:o}=wn("secondaryPane"),a={MCTS:Di,Random:oo},u=!1,c=null,l=0,f=null,p=({iterationCounter:V,numIterations:se,metadata:ne})=>{n(3,l=V),n(2,c=V/se),f=ne,u&&f&&o.set({component:zi,metadata:f})};function h(){u&&f?o.set({component:zi,metadata:f}):o.set(null)}let d;r.game.ai&&(d=new Di({game:r.game,enumerate:r.game.ai.enumerate,iterationCallback:p}),d.setOpt("async",!0));let y,m,b;function g(){let V=a[y];n(7,d=new V({game:r.game,enumerate:r.game.ai.enumerate,iterationCallback:p})),d.setOpt("async",!0),n(5,m=null),f=null,o.set(null),n(3,l=0)}async function O(){n(5,m=null),f=null,n(3,l=0);let V=await nc(r,d);V&&(n(5,m=V.payload.type),n(6,b=V.payload.args))}function I(V=1e4,se=100){return n(5,m=null),f=null,n(3,l=0),(async()=>{for(let G=0;G<V&&await nc(r,d);G++)await new Promise(ue=>setTimeout(ue,se))})()}function j(){r.overrideGameState(null),o.set(null),n(1,u=!1)}function N(){r.reset(),n(5,m=null),f=null,n(3,l=0),j()}function D(V){V.keyCode==27&&j()}Cc(j);function J(){y=w1(this),n(4,y),n(8,a)}function fe(){u=this.checked,n(1,u)}return e.$$set=V=>{"client"in V&&n(0,r=V.client),"clientManager"in V&&n(15,i=V.clientManager),"ToggleVisibility"in V&&n(16,s=V.ToggleVisibility)},[r,u,c,l,y,m,b,d,a,h,g,O,I,N,D,i,s,J,fe]}var xc=class extends Z{constructor(t){super(),te(this,t,ij,rj,ee,{client:0,clientManager:15,ToggleVisibility:16},Z3)}};function sj(e){de(e,"svelte-8ymctk",`.debug-panel.svelte-8ymctk.svelte-8ymctk{position:fixed;color:#555;font-family:monospace;right:0;top:0;height:100%;font-size:14px;opacity:0.9;z-index:99999}.panel.svelte-8ymctk.svelte-8ymctk{display:flex;position:relative;flex-direction:row;height:100%}.visibility-toggle.svelte-8ymctk.svelte-8ymctk{position:absolute;box-sizing:border-box;top:7px;border:1px solid #ccc;border-radius:5px;width:48px;height:48px;padding:8px;background:white;color:#555;box-shadow:0 0 5px rgba(0, 0, 0, 0.2)}.visibility-toggle.svelte-8ymctk.svelte-8ymctk:hover,.visibility-toggle.svelte-8ymctk.svelte-8ymctk:focus{background:#eee}.opener.svelte-8ymctk.svelte-8ymctk{right:10px}.closer.svelte-8ymctk.svelte-8ymctk{left:-326px}@keyframes svelte-8ymctk-rotateFromZero{from{transform:rotateZ(0deg)}to{transform:rotateZ(180deg)}}.icon.svelte-8ymctk.svelte-8ymctk{display:flex;height:100%;animation:svelte-8ymctk-rotateFromZero 0.4s cubic-bezier(0.68, -0.55, 0.27, 1.55) 0s 1
32
- normal forwards}.closer.svelte-8ymctk .icon.svelte-8ymctk{animation-direction:reverse}.pane.svelte-8ymctk.svelte-8ymctk{flex-grow:2;overflow-x:hidden;overflow-y:scroll;background:#fefefe;padding:20px;border-left:1px solid #ccc;box-shadow:-1px 0 5px rgba(0, 0, 0, 0.2);box-sizing:border-box;width:280px}.secondary-pane.svelte-8ymctk.svelte-8ymctk{background:#fefefe;overflow-y:scroll}.debug-panel.svelte-8ymctk button,.debug-panel.svelte-8ymctk select{cursor:pointer;font-size:14px;font-family:monospace}.debug-panel.svelte-8ymctk select{background:#eee;border:1px solid #bbb;color:#555;padding:3px;border-radius:3px}.debug-panel.svelte-8ymctk section{margin-bottom:20px}.debug-panel.svelte-8ymctk .screen-reader-only{clip:rect(0 0 0 0);clip-path:inset(50%);height:1px;overflow:hidden;position:absolute;white-space:nowrap;width:1px}`)}function oj(e){let t,n,r,i,s,o,a,u,c,l=e[10]&&uj(e);r=new sc({props:{panes:e[6],pane:e[2]}}),r.$on("change",e[8]);var f=e[6][e[2]].component;function p(d){return{props:{client:d[4],clientManager:d[0],ToggleVisibility:d[9]}}}f&&(o=new f(p(e)));let h=e[5]&&d1(e);return{c(){t=A("div"),l&&l.c(),n=q(),L(r.$$.fragment),i=q(),s=A("div"),o&&L(o.$$.fragment),a=q(),h&&h.c(),k(s,"class","pane svelte-8ymctk"),k(s,"role","region"),k(s,"aria-label",e[2]),k(s,"tabindex","-1"),k(t,"class","panel svelte-8ymctk")},m(d,y){M(d,t,y),l&&l.m(t,null),w(t,n),R(r,t,null),w(t,i),w(t,s),o&&R(o,s,null),e[16](s),w(t,a),h&&h.m(t,null),c=!0},p(d,y){e=d,e[10]&&l.p(e,y);let m={};y&4&&(m.pane=e[2]),r.$set(m);let b={};if(y&16&&(b.client=e[4]),y&1&&(b.clientManager=e[0]),f!==(f=e[6][e[2]].component)){if(o){ce();let g=o;x(g.$$.fragment,1,0,()=>{B(g,1)}),le()}f?(o=new f(p(e)),L(o.$$.fragment),P(o.$$.fragment,1),R(o,s,null)):o=null}else f&&o.$set(b);(!c||y&4)&&k(s,"aria-label",e[2]),e[5]?h?(h.p(e,y),y&32&&P(h,1)):(h=d1(e),h.c(),P(h,1),h.m(t,null)):h&&(ce(),x(h,1,1,()=>{h=null}),le())},i(d){c||(P(l),P(r.$$.fragment,d),o&&P(o.$$.fragment,d),P(h),ot(()=>{u||(u=mb(t,yb,{x:400,...e[12]},!0)),u.run(1)}),c=!0)},o(d){x(l),x(r.$$.fragment,d),o&&x(o.$$.fragment,d),x(h),u||(u=mb(t,yb,{x:400,...e[12]},!1)),u.run(0),c=!1},d(d){d&&S(t),l&&l.d(),B(r),o&&B(o),e[16](null),h&&h.d(),d&&u&&u.end()}}}function aj(e){let t,n,r=e[10]&&cj(e);return{c(){r&&r.c(),t=at()},m(i,s){r&&r.m(i,s),M(i,t,s),n=!0},p(i,s){i[10]&&r.p(i,s)},i(i){n||(P(r),n=!0)},o(i){x(r),n=!1},d(i){r&&r.d(i),i&&S(t)}}}function uj(e){let t,n,r,i,s,o,a,u;return r=new bo({}),{c(){t=A("button"),n=A("span"),L(r.$$.fragment),k(n,"class","icon svelte-8ymctk"),k(n,"aria-hidden","true"),k(t,"class","visibility-toggle closer svelte-8ymctk"),k(t,"title","Hide Debug Panel")},m(c,l){M(c,t,l),w(t,n),R(r,n,null),o=!0,a||(u=Q(t,"click",e[9]),a=!0)},p:U,i(c){o||(P(r.$$.fragment,c),ot(()=>{s&&s.end(1),i=k1(t,e[14],{key:"toggle"}),i.start()}),o=!0)},o(c){x(r.$$.fragment,c),i&&i.invalidate(),s=A1(t,e[13],{key:"toggle"}),o=!1},d(c){c&&S(t),B(r),c&&s&&s.end(),a=!1,u()}}}function d1(e){let t,n,r;var i=e[5].component;function s(o){return{props:{metadata:o[5].metadata}}}return i&&(n=new i(s(e))),{c(){t=A("div"),n&&L(n.$$.fragment),k(t,"class","secondary-pane svelte-8ymctk")},m(o,a){M(o,t,a),n&&R(n,t,null),r=!0},p(o,a){let u={};if(a&32&&(u.metadata=o[5].metadata),i!==(i=o[5].component)){if(n){ce();let c=n;x(c.$$.fragment,1,0,()=>{B(c,1)}),le()}i?(n=new i(s(o)),L(n.$$.fragment),P(n.$$.fragment,1),R(n,t,null)):n=null}else i&&n.$set(u)},i(o){r||(n&&P(n.$$.fragment,o),r=!0)},o(o){n&&x(n.$$.fragment,o),r=!1},d(o){o&&S(t),n&&B(n)}}}function cj(e){let t,n,r,i,s,o,a,u;return r=new bo({}),{c(){t=A("button"),n=A("span"),L(r.$$.fragment),k(n,"class","icon svelte-8ymctk"),k(n,"aria-hidden","true"),k(t,"class","visibility-toggle opener svelte-8ymctk"),k(t,"title","Show Debug Panel")},m(c,l){M(c,t,l),w(t,n),R(r,n,null),o=!0,a||(u=Q(t,"click",e[9]),a=!0)},p:U,i(c){o||(P(r.$$.fragment,c),ot(()=>{s&&s.end(1),i=k1(t,e[14],{key:"toggle"}),i.start()}),o=!0)},o(c){x(r.$$.fragment,c),i&&i.invalidate(),s=A1(t,e[13],{key:"toggle"}),o=!1},d(c){c&&S(t),B(r),c&&s&&s.end(),a=!1,u()}}}function lj(e){let t,n,r,i,s,o,a=[aj,oj],u=[];function c(l,f){return l[3]?1:0}return n=c(e),r=u[n]=a[n](e),{c(){t=A("section"),r.c(),k(t,"aria-label","boardgame.io Debug Panel"),k(t,"class","debug-panel svelte-8ymctk")},m(l,f){M(l,t,f),u[n].m(t,null),i=!0,s||(o=Q(window,"keypress",e[11]),s=!0)},p(l,[f]){let p=n;n=c(l),n===p?u[n].p(l,f):(ce(),x(u[p],1,1,()=>{u[p]=null}),le(),r=u[n],r?r.p(l,f):(r=u[n]=a[n](l),r.c()),P(r,1),r.m(t,null))},i(l){i||(P(r),i=!0)},o(l){x(r),i=!1},d(l){l&&S(t),u[n].d(),s=!1,o()}}}function fj(e,t,n){let r,i,s=U,o=()=>(s(),s=Hi(u,J=>n(15,i=J)),u),a;e.$$.on_destroy.push(()=>s());let{clientManager:u}=t;o();let c={main:{label:"Main",shortcut:"m",component:vc},log:{label:"Log",shortcut:"l",component:kc},info:{label:"Info",shortcut:"i",component:bc},ai:{label:"AI",shortcut:"a",component:xc}},l=gb(!1),f=gb(null);g1(e,f,J=>n(5,a=J)),Fi("hotkeys",{disableHotkeys:l}),Fi("secondaryPane",{secondaryPane:f});let p,h="main";function d(J){n(2,h=J.detail),p.focus()}function y(){n(3,b=!b)}let m=i.client.debugOpt,b=!m||!m.collapseOnLoad,g=!m||!m.hideToggleButton;function O(J){if(J.key=="."){y();return}b&&Object.entries(c).forEach(([fe,{shortcut:V}])=>{J.key==V&&n(2,h=fe)})}let I={duration:150,easing:Dc},[j,N]=WC(I);function D(J){yo[J?"unshift":"push"](()=>{p=J,n(1,p)})}return e.$$set=J=>{"clientManager"in J&&o(n(0,u=J.clientManager))},e.$$.update=()=>{e.$$.dirty&32768&&n(4,r=i.client)},[u,p,h,b,r,a,c,f,d,y,g,O,I,j,N,i,D]}var Ki=class extends Z{constructor(t){super(),te(this,t,fj,lj,ee,{clientManager:0},sj)}};function On(e){"@babel/helpers - typeof";return On=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},On(e)}function M1(e,t){if(On(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(On(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function I1(e){var t=M1(e,"string");return On(t)=="symbol"?t:t+""}function N1(e,t,n){return(t=I1(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function C1(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function Rc(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?C1(Object(n),!0).forEach(function(r){N1(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):C1(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function Xe(e){return"Minified Redux error #"+e+"; visit https://redux.js.org/Errors?code="+e+" for the full message or use the non-minified dev environment for full errors. "}var q1=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}(),Bc=function(){return Math.random().toString(36).substring(7).split("").join(".")},j1={INIT:"@@redux/INIT"+Bc(),REPLACE:"@@redux/REPLACE"+Bc(),PROBE_UNKNOWN_ACTION:function(){return"@@redux/PROBE_UNKNOWN_ACTION"+Bc()}};function pj(e){if(typeof e!="object"||e===null)return!1;for(var t=e;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function Lc(e,t,n){var r;if(typeof t=="function"&&typeof n=="function"||typeof n=="function"&&typeof arguments[3]=="function")throw new Error(Xe(0));if(typeof t=="function"&&typeof n>"u"&&(n=t,t=void 0),typeof n<"u"){if(typeof n!="function")throw new Error(Xe(1));return n(Lc)(e,t)}if(typeof e!="function")throw new Error(Xe(2));var i=e,s=t,o=[],a=o,u=!1;function c(){a===o&&(a=o.slice())}function l(){if(u)throw new Error(Xe(3));return s}function f(y){if(typeof y!="function")throw new Error(Xe(4));if(u)throw new Error(Xe(5));var m=!0;return c(),a.push(y),function(){if(m){if(u)throw new Error(Xe(6));m=!1,c();var g=a.indexOf(y);a.splice(g,1),o=null}}}function p(y){if(!pj(y))throw new Error(Xe(7));if(typeof y.type>"u")throw new Error(Xe(8));if(u)throw new Error(Xe(9));try{u=!0,s=i(s,y)}finally{u=!1}for(var m=o=a,b=0;b<m.length;b++){var g=m[b];g()}return y}function h(y){if(typeof y!="function")throw new Error(Xe(10));i=y,p({type:j1.REPLACE})}function d(){var y,m=f;return y={subscribe:function(g){if(typeof g!="object"||g===null)throw new Error(Xe(11));function O(){g.next&&g.next(l())}O();var I=m(O);return{unsubscribe:I}}},y[q1]=function(){return this},y}return p({type:j1.INIT}),r={dispatch:p,subscribe:f,getState:l,replaceReducer:h},r[q1]=d,r}function Gc(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return t.length===0?function(r){return r}:t.length===1?t[0]:t.reduce(function(r,i){return function(){return r(i.apply(void 0,arguments))}})}function D1(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(r){return function(){var i=r.apply(void 0,arguments),s=function(){throw new Error(Xe(15))},o={getState:i.getState,dispatch:function(){return s.apply(void 0,arguments)}},a=t.map(function(u){return u(o)});return s=Gc.apply(void 0,a)(i.dispatch),Rc(Rc({},i),{},{dispatch:s})}}}function R1({game:e,numPlayers:t,setupData:n}){e=ji(e),t||(t=2);let r=e.flow.ctx(t),i={G:{},ctx:r,plugins:{}};i=Nv(i,{game:e}),i=Ti(i,{game:e,playerID:void 0});let s=Wt(i);i.G=e.setup({...s,ctx:i.ctx},n);let o={...i,_undo:[],_redo:[],_stateID:0};return o=e.flow.init(o),[o]=eo(o,{game:e}),e.disableUndo||(o._undo=[{G:o.G,ctx:o.ctx,plugins:o.plugins}]),o}var ir=class{constructor({transportDataCallback:t,gameName:n,playerID:r,matchID:i,credentials:s,numPlayers:o}){this.connectionStatusCallback=()=>{},this.isConnected=!1,this.transportDataCallback=t,this.gameName=n||"default",this.playerID=r||null,this.matchID=i||"default",this.credentials=s,this.numPlayers=o||2}subscribeToConnectionStatus(t){this.connectionStatusCallback=t}setConnectionStatus(t){this.isConnected=t,this.connectionStatusCallback()}notifyClient(t){this.transportDataCallback(t)}};var Fc=class extends ir{connect(){}disconnect(){}sendAction(){}sendChatMessage(){}requestSync(){}updateCredentials(){}updateMatchID(){}updatePlayerID(){}},hj=e=>new Fc(e),Uc=class{constructor(){this.debugPanel=null,this.currentClient=null,this.clients=new Map,this.subscribers=new Map}register(t){this.clients.set(t,t),this.mountDebug(t),this.notifySubscribers()}unregister(t){if(this.clients.delete(t),this.currentClient===t){this.unmountDebug();for(let[n]of this.clients){if(this.debugPanel)break;this.mountDebug(n)}}this.notifySubscribers()}subscribe(t){let n=Symbol();return this.subscribers.set(n,t),t(this.getState()),()=>{this.subscribers.delete(n)}}switchPlayerID(t){if(this.currentClient.multiplayer){for(let[n]of this.clients)if(n.playerID===t&&n.debugOpt!==!1&&n.multiplayer===this.currentClient.multiplayer){this.switchToClient(n);return}}this.currentClient.updatePlayerID(t),this.notifySubscribers()}switchToClient(t){t!==this.currentClient&&(this.unmountDebug(),this.mountDebug(t),this.notifySubscribers())}notifySubscribers(){let t=this.getState();this.subscribers.forEach(n=>{n(t)})}getState(){return{client:this.currentClient,debuggableClients:this.getDebuggableClients()}}getDebuggableClients(){return[...this.clients.values()].filter(t=>t.debugOpt!==!1)}mountDebug(t){if(t.debugOpt===!1||this.debugPanel!==null||typeof document>"u")return;let n,r=document.body;t.debugOpt&&t.debugOpt!==!0&&(n=t.debugOpt.impl||n,r=t.debugOpt.target||r),n&&(this.currentClient=t,this.debugPanel=new n({target:r,props:{clientManager:this}}))}unmountDebug(){this.debugPanel.$destroy(),this.debugPanel=null,this.currentClient=null}},dj=new Uc;function Vc(e,t,n){return!n&&e==null&&(e=t.getState().ctx.currentPlayer),e}function Kc(e,t,n,r,i,s){let o={};for(let a of t)o[a]=(...u)=>{let c=Mv[e](a,u,Vc(r,n,s),i);n.dispatch(c)};return o}var mj=Kc.bind(null,"makeMove"),gj=Kc.bind(null,"gameEvent"),yj=Kc.bind(null,"plugin"),zc=class{constructor({game:t,debug:n,numPlayers:r,multiplayer:i,matchID:s,playerID:o,credentials:a,enhancer:u}){this.game=ji(t),this.playerID=o,this.matchID=s||"default",this.credentials=a,this.multiplayer=i,this.debugOpt=n,this.manager=dj,this.gameStateOverride=null,this.subscribers={},this._running=!1,this.reducer=Xn({game:this.game,isClient:i!==void 0}),this.initialState=null,i||(this.initialState=R1({game:this.game,numPlayers:r})),this.reset=()=>{this.store.dispatch(Nu(this.initialState))},this.undo=()=>{let h=Cu(Vc(this.playerID,this.store,this.multiplayer),this.credentials);this.store.dispatch(h)},this.redo=()=>{let h=qu(Vc(this.playerID,this.store,this.multiplayer),this.credentials);this.store.dispatch(h)},this.log=[];let p=D1(cb,()=>h=>d=>{let y=h(d);return this.notifySubscribers(),y},h=>d=>y=>{let m=h.getState(),b=d(y);return!("clientOnly"in y)&&y.type!==$n&&this.transport.sendAction(m,y),b},h=>d=>y=>{let m=d(y),b=h.getState();switch(y.type){case _i:case Yn:case Ei:case wi:{let g=b.deltalog;this.log=[...this.log,...g];break}case Oi:{this.log=[];break}case Ai:case ki:{let g=-1;this.log.length>0&&(g=this.log[this.log.length-1]._stateID);let O=y.deltalog||[];O=O.filter(I=>I._stateID>g),this.log=[...this.log,...O];break}case Pi:{this.initialState=y.initialState,this.log=y.log||[];break}}return m});u=u!==void 0?Gc(p,u):p,this.store=Lc(this.reducer,this.initialState,u),i||(i=hj),this.transport=i({transportDataCallback:h=>this.receiveTransportData(h),gameKey:t,game:this.game,matchID:s,playerID:o,credentials:a,gameName:this.game.name,numPlayers:r}),this.createDispatchers(),this.chatMessages=[],this.sendChatMessage=h=>{this.transport.sendChatMessage(this.matchID,{id:mv(7),sender:this.playerID,payload:h})}}receiveMatchData(t){this.matchData=t,this.notifySubscribers()}receiveChatMessage(t){this.chatMessages=[...this.chatMessages,t],this.notifySubscribers()}receiveTransportData(t){let[n]=t.args;if(n===this.matchID)switch(t.type){case"sync":{let[,r]=t.args,i=xi(r);this.receiveMatchData(r.filteredMetadata),this.store.dispatch(i);break}case"update":{let[,r,i]=t.args,s=this.store.getState();if(r._stateID>=s._stateID){let o=Iu(r,i);this.store.dispatch(o)}break}case"patch":{let[,r,i,s,o]=t.args,a=this.store.getState()._stateID;if(r!==a)break;let u=Mu(r,i,s,o);this.store.dispatch(u),this.store.getState()._stateID===a&&this.transport.requestSync();break}case"matchData":{let[,r]=t.args;this.receiveMatchData(r);break}case"chat":{let[,r]=t.args;this.receiveChatMessage(r);break}}}notifySubscribers(){Object.values(this.subscribers).forEach(t=>t(this.getState()))}overrideGameState(t){this.gameStateOverride=t,this.notifySubscribers()}start(){this.transport.connect(),this._running=!0,this.manager.register(this)}stop(){this.transport.disconnect(),this._running=!1,this.manager.unregister(this)}subscribe(t){let n=Object.keys(this.subscribers).length;return this.subscribers[n]=t,this.transport.subscribeToConnectionStatus(()=>this.notifySubscribers()),(this._running||!this.multiplayer)&&t(this.getState()),()=>{delete this.subscribers[n]}}getInitialState(){return this.initialState}getState(){let t=this.store.getState();if(this.gameStateOverride!==null&&(t=this.gameStateOverride),t===null)return t;let n=!0,r=this.game.flow.isPlayerActive(t.G,t.ctx,this.playerID);return this.multiplayer&&!r&&(n=!1),!this.multiplayer&&this.playerID!==null&&this.playerID!==void 0&&!r&&(n=!1),t.ctx.gameover!==void 0&&(n=!1),this.multiplayer||(t={...t,G:this.game.playerView({G:t.G,ctx:t.ctx,playerID:this.playerID}),plugins:qv(t,this)}),{...t,log:this.log,isActive:n,isConnected:this.transport.isConnected}}createDispatchers(){this.moves=mj(this.game.moveNames,this.store,this.playerID,this.credentials,this.multiplayer),this.events=gj(this.game.flow.enabledEventNames,this.store,this.playerID,this.credentials,this.multiplayer),this.plugins=yj(this.game.pluginNames,this.store,this.playerID,this.credentials,this.multiplayer)}updatePlayerID(t){this.playerID=t,this.createDispatchers(),this.transport.updatePlayerID(t),this.notifySubscribers()}updateMatchID(t){this.matchID=t,this.createDispatchers(),this.transport.updateMatchID(t),this.notifySubscribers()}updateCredentials(t){this.credentials=t,this.createDispatchers(),this.transport.updateCredentials(t),this.notifySubscribers()}};function Hc(e){return new zc(e)}var DL=he(tn());var BL=he(qi());var LL=he(io());var UL=he(tn());var zL=he(qi());var KL=he(io());var ut=Object.create(null);ut.open="0";ut.close="1";ut.ping="2";ut.pong="3";ut.message="4";ut.upgrade="5";ut.noop="6";var Yi=Object.create(null);Object.keys(ut).forEach(e=>{Yi[ut[e]]=e});var $i={type:"error",data:"parser error"};var G1=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",F1=typeof ArrayBuffer=="function",U1=e=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,Xi=({type:e,data:t},n,r)=>G1&&t instanceof Blob?n?r(t):B1(t,r):F1&&(t instanceof ArrayBuffer||U1(t))?n?r(t):B1(new Blob([t]),r):r(ut[e]+(t||"")),B1=(e,t)=>{let n=new FileReader;return n.onload=function(){let r=n.result.split(",")[1];t("b"+(r||""))},n.readAsDataURL(e)};function L1(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}var Wc;function V1(e,t){if(G1&&e.data instanceof Blob)return e.data.arrayBuffer().then(L1).then(t);if(F1&&(e.data instanceof ArrayBuffer||U1(e.data)))return t(L1(e.data));Xi(e,!1,n=>{Wc||(Wc=new TextEncoder),t(Wc.encode(n))})}var z1="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Qi=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let e=0;e<z1.length;e++)Qi[z1.charCodeAt(e)]=e;var K1=e=>{let t=e.length*.75,n=e.length,r,i=0,s,o,a,u;e[e.length-1]==="="&&(t--,e[e.length-2]==="="&&t--);let c=new ArrayBuffer(t),l=new Uint8Array(c);for(r=0;r<n;r+=4)s=Qi[e.charCodeAt(r)],o=Qi[e.charCodeAt(r+1)],a=Qi[e.charCodeAt(r+2)],u=Qi[e.charCodeAt(r+3)],l[i++]=s<<2|o>>4,l[i++]=(o&15)<<4|a>>2,l[i++]=(a&3)<<6|u&63;return c};var vj=typeof ArrayBuffer=="function",Zi=(e,t)=>{if(typeof e!="string")return{type:"message",data:H1(e,t)};let n=e.charAt(0);return n==="b"?{type:"message",data:bj(e.substring(1),t)}:Yi[n]?e.length>1?{type:Yi[n],data:e.substring(1)}:{type:Yi[n]}:$i},bj=(e,t)=>{if(vj){let n=K1(e);return H1(n,t)}else return{base64:!0,data:e}},H1=(e,t)=>{switch(t){case"blob":return e instanceof Blob?e:new Blob([e]);case"arraybuffer":default:return e instanceof ArrayBuffer?e:e.buffer}};var W1="",J1=(e,t)=>{let n=e.length,r=new Array(n),i=0;e.forEach((s,o)=>{Xi(s,!1,a=>{r[o]=a,++i===n&&t(r.join(W1))})})},Y1=(e,t)=>{let n=e.split(W1),r=[];for(let i=0;i<n.length;i++){let s=Zi(n[i],t);if(r.push(s),s.type==="error")break}return r};function $1(){return new TransformStream({transform(e,t){V1(e,n=>{let r=n.length,i;if(r<126)i=new Uint8Array(1),new DataView(i.buffer).setUint8(0,r);else if(r<65536){i=new Uint8Array(3);let s=new DataView(i.buffer);s.setUint8(0,126),s.setUint16(1,r)}else{i=new Uint8Array(9);let s=new DataView(i.buffer);s.setUint8(0,127),s.setBigUint64(1,BigInt(r))}e.data&&typeof e.data!="string"&&(i[0]|=128),t.enqueue(i),t.enqueue(n)})}})}var Jc;function Eo(e){return e.reduce((t,n)=>t+n.length,0)}function ko(e,t){if(e[0].length===t)return e.shift();let n=new Uint8Array(t),r=0;for(let i=0;i<t;i++)n[i]=e[0][r++],r===e[0].length&&(e.shift(),r=0);return e.length&&r<e[0].length&&(e[0]=e[0].slice(r)),n}function X1(e,t){Jc||(Jc=new TextDecoder);let n=[],r=0,i=-1,s=!1;return new TransformStream({transform(o,a){for(n.push(o);;){if(r===0){if(Eo(n)<1)break;let u=ko(n,1);s=(u[0]&128)===128,i=u[0]&127,i<126?r=3:i===126?r=1:r=2}else if(r===1){if(Eo(n)<2)break;let u=ko(n,2);i=new DataView(u.buffer,u.byteOffset,u.length).getUint16(0),r=3}else if(r===2){if(Eo(n)<8)break;let u=ko(n,8),c=new DataView(u.buffer,u.byteOffset,u.length),l=c.getUint32(0);if(l>Math.pow(2,21)-1){a.enqueue($i);break}i=l*Math.pow(2,32)+c.getUint32(4),r=3}else{if(Eo(n)<i)break;let u=ko(n,i);a.enqueue(Zi(s?u:Jc.decode(u),t)),r=0}if(i===0||i>e){a.enqueue($i);break}}}})}var Yc=4;function ye(e){if(e)return _j(e)}function _j(e){for(var t in ye.prototype)e[t]=ye.prototype[t];return e}ye.prototype.on=ye.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this};ye.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this};ye.prototype.off=ye.prototype.removeListener=ye.prototype.removeAllListeners=ye.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var n=this._callbacks["$"+e];if(!n)return this;if(arguments.length==1)return delete this._callbacks["$"+e],this;for(var r,i=0;i<n.length;i++)if(r=n[i],r===t||r.fn===t){n.splice(i,1);break}return n.length===0&&delete this._callbacks["$"+e],this};ye.prototype.emit=function(e){this._callbacks=this._callbacks||{};for(var t=new Array(arguments.length-1),n=this._callbacks["$"+e],r=1;r<arguments.length;r++)t[r-1]=arguments[r];if(n){n=n.slice(0);for(var r=0,i=n.length;r<i;++r)n[r].apply(this,t)}return this};ye.prototype.emitReserved=ye.prototype.emit;ye.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]};ye.prototype.hasListeners=function(e){return!!this.listeners(e).length};var Dt=typeof Promise=="function"&&typeof Promise.resolve=="function"?t=>Promise.resolve().then(t):(t,n)=>n(t,0),Ue=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),Q1="arraybuffer";function Ao(e,...t){return t.reduce((n,r)=>(e.hasOwnProperty(r)&&(n[r]=e[r]),n),{})}var wj=Ue.setTimeout,Oj=Ue.clearTimeout;function Rt(e,t){t.useNativeTimers?(e.setTimeoutFn=wj.bind(Ue),e.clearTimeoutFn=Oj.bind(Ue)):(e.setTimeoutFn=Ue.setTimeout.bind(Ue),e.clearTimeoutFn=Ue.clearTimeout.bind(Ue))}var Pj=1.33;function Z1(e){return typeof e=="string"?Ej(e):Math.ceil((e.byteLength||e.size)*Pj)}function Ej(e){let t=0,n=0;for(let r=0,i=e.length;r<i;r++)t=e.charCodeAt(r),t<128?n+=1:t<2048?n+=2:t<55296||t>=57344?n+=3:(r++,n+=4);return n}function xo(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function e_(e){let t="";for(let n in e)e.hasOwnProperty(n)&&(t.length&&(t+="&"),t+=encodeURIComponent(n)+"="+encodeURIComponent(e[n]));return t}function t_(e){let t={},n=e.split("&");for(let r=0,i=n.length;r<i;r++){let s=n[r].split("=");t[decodeURIComponent(s[0])]=decodeURIComponent(s[1])}return t}var So=class extends Error{constructor(t,n,r){super(t),this.description=n,this.context=r,this.type="TransportError"}},Bt=class extends ye{constructor(t){super(),this.writable=!1,Rt(this,t),this.opts=t,this.query=t.query,this.socket=t.socket,this.supportsBinary=!t.forceBase64}onError(t,n,r){return super.emitReserved("error",new So(t,n,r)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(t){this.readyState==="open"&&this.write(t)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(t){let n=Zi(t,this.socket.binaryType);this.onPacket(n)}onPacket(t){super.emitReserved("packet",t)}onClose(t){this.readyState="closed",super.emitReserved("close",t)}pause(t){}createUri(t,n={}){return t+"://"+this._hostname()+this._port()+this.opts.path+this._query(n)}_hostname(){let t=this.opts.hostname;return t.indexOf(":")===-1?t:"["+t+"]"}_port(){return this.opts.port&&(this.opts.secure&&Number(this.opts.port)!==443||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(t){let n=e_(t);return n.length?"?"+n:""}};var es=class extends Bt{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(t){this.readyState="pausing";let n=()=>{this.readyState="paused",t()};if(this._polling||!this.writable){let r=0;this._polling&&(r++,this.once("pollComplete",function(){--r||n()})),this.writable||(r++,this.once("drain",function(){--r||n()}))}else n()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(t){let n=r=>{if(this.readyState==="opening"&&r.type==="open"&&this.onOpen(),r.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(r)};Y1(t,this.socket.binaryType).forEach(n),this.readyState!=="closed"&&(this._polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this._poll())}doClose(){let t=()=>{this.write([{type:"close"}])};this.readyState==="open"?t():this.once("open",t)}write(t){this.writable=!1,J1(t,n=>{this.doWrite(n,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){let t=this.opts.secure?"https":"http",n=this.query||{};return this.opts.timestampRequests!==!1&&(n[this.opts.timestampParam]=xo()),!this.supportsBinary&&!n.sid&&(n.b64=1),this.createUri(t,n)}};var n_=!1;try{n_=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}var r_=n_;function kj(){}var $c=class extends es{constructor(t){if(super(t),typeof location<"u"){let n=location.protocol==="https:",r=location.port;r||(r=n?"443":"80"),this.xd=typeof location<"u"&&t.hostname!==location.hostname||r!==t.port}}doWrite(t,n){let r=this.request({method:"POST",data:t});r.on("success",n),r.on("error",(i,s)=>{this.onError("xhr post error",i,s)})}doPoll(){let t=this.request();t.on("data",this.onData.bind(this)),t.on("error",(n,r)=>{this.onError("xhr poll error",n,r)}),this.pollXhr=t}},$t=class e extends ye{constructor(t,n,r){super(),this.createRequest=t,Rt(this,r),this._opts=r,this._method=r.method||"GET",this._uri=n,this._data=r.data!==void 0?r.data:null,this._create()}_create(){var t;let n=Ao(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");n.xdomain=!!this._opts.xd;let r=this._xhr=this.createRequest(n);try{r.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){r.setDisableHeaderCheck&&r.setDisableHeaderCheck(!0);for(let i in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(i)&&r.setRequestHeader(i,this._opts.extraHeaders[i])}}catch{}if(this._method==="POST")try{r.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{r.setRequestHeader("Accept","*/*")}catch{}(t=this._opts.cookieJar)===null||t===void 0||t.addCookies(r),"withCredentials"in r&&(r.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(r.timeout=this._opts.requestTimeout),r.onreadystatechange=()=>{var i;r.readyState===3&&((i=this._opts.cookieJar)===null||i===void 0||i.parseCookies(r.getResponseHeader("set-cookie"))),r.readyState===4&&(r.status===200||r.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof r.status=="number"?r.status:0)},0))},r.send(this._data)}catch(i){this.setTimeoutFn(()=>{this._onError(i)},0);return}typeof document<"u"&&(this._index=e.requestsCount++,e.requests[this._index]=this)}_onError(t){this.emitReserved("error",t,this._xhr),this._cleanup(!0)}_cleanup(t){if(!(typeof this._xhr>"u"||this._xhr===null)){if(this._xhr.onreadystatechange=kj,t)try{this._xhr.abort()}catch{}typeof document<"u"&&delete e.requests[this._index],this._xhr=null}}_onLoad(){let t=this._xhr.responseText;t!==null&&(this.emitReserved("data",t),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}};$t.requestsCount=0;$t.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",i_);else if(typeof addEventListener=="function"){let e="onpagehide"in Ue?"pagehide":"unload";addEventListener(e,i_,!1)}}function i_(){for(let e in $t.requests)$t.requests.hasOwnProperty(e)&&$t.requests[e].abort()}var Aj=function(){let e=s_({xdomain:!1});return e&&e.responseType!==null}(),Xt=class extends $c{constructor(t){super(t);let n=t&&t.forceBase64;this.supportsBinary=Aj&&!n}request(t={}){return Object.assign(t,{xd:this.xd},this.opts),new $t(s_,this.uri(),t)}};function s_(e){let t=e.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!t||r_))return new XMLHttpRequest}catch{}if(!t)try{return new Ue[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}var o_=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative",Qc=class extends Bt{get name(){return"websocket"}doOpen(){let t=this.uri(),n=this.opts.protocols,r=o_?{}:Ao(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(r.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(t,n,r)}catch(i){return this.emitReserved("error",i)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=t=>this.onClose({description:"websocket connection closed",context:t}),this.ws.onmessage=t=>this.onData(t.data),this.ws.onerror=t=>this.onError("websocket error",t)}write(t){this.writable=!1;for(let n=0;n<t.length;n++){let r=t[n],i=n===t.length-1;Xi(r,this.supportsBinary,s=>{try{this.doWrite(r,s)}catch{}i&&Dt(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){let t=this.opts.secure?"wss":"ws",n=this.query||{};return this.opts.timestampRequests&&(n[this.opts.timestampParam]=xo()),this.supportsBinary||(n.b64=1),this.createUri(t,n)}},Xc=Ue.WebSocket||Ue.MozWebSocket,Qt=class extends Qc{createSocket(t,n,r){return o_?new Xc(t,n,r):n?new Xc(t,n):new Xc(t)}doWrite(t,n){this.ws.send(n)}};var sr=class extends Bt{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(t){return this.emitReserved("error",t)}this._transport.closed.then(()=>{this.onClose()}).catch(t=>{this.onError("webtransport error",t)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(t=>{let n=X1(Number.MAX_SAFE_INTEGER,this.socket.binaryType),r=t.readable.pipeThrough(n).getReader(),i=$1();i.readable.pipeTo(t.writable),this._writer=i.writable.getWriter();let s=()=>{r.read().then(({done:a,value:u})=>{a||(this.onPacket(u),s())}).catch(a=>{})};s();let o={type:"open"};this.query.sid&&(o.data=`{"sid":"${this.query.sid}"}`),this._writer.write(o).then(()=>this.onOpen())})})}write(t){this.writable=!1;for(let n=0;n<t.length;n++){let r=t[n],i=n===t.length-1;this._writer.write(r).then(()=>{i&&Dt(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var t;(t=this._transport)===null||t===void 0||t.close()}};var Zc={websocket:Qt,webtransport:sr,polling:Xt};var xj=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,Sj=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function or(e){if(e.length>8e3)throw"URI too long";let t=e,n=e.indexOf("["),r=e.indexOf("]");n!=-1&&r!=-1&&(e=e.substring(0,n)+e.substring(n,r).replace(/:/g,";")+e.substring(r,e.length));let i=xj.exec(e||""),s={},o=14;for(;o--;)s[Sj[o]]=i[o]||"";return n!=-1&&r!=-1&&(s.source=t,s.host=s.host.substring(1,s.host.length-1).replace(/;/g,":"),s.authority=s.authority.replace("[","").replace("]","").replace(/;/g,":"),s.ipv6uri=!0),s.pathNames=Tj(s,s.path),s.queryKey=Mj(s,s.query),s}function Tj(e,t){let n=/\/{2,9}/g,r=t.replace(n,"/").split("/");return(t.slice(0,1)=="/"||t.length===0)&&r.splice(0,1),t.slice(-1)=="/"&&r.splice(r.length-1,1),r}function Mj(e,t){let n={};return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(r,i,s){i&&(n[i]=s)}),n}var el=typeof addEventListener=="function"&&typeof removeEventListener=="function",To=[];el&&addEventListener("offline",()=>{To.forEach(e=>e())},!1);var Pn=class e extends ye{constructor(t,n){if(super(),this.binaryType=Q1,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,t&&typeof t=="object"&&(n=t,t=null),t){let r=or(t);n.hostname=r.host,n.secure=r.protocol==="https"||r.protocol==="wss",n.port=r.port,r.query&&(n.query=r.query)}else n.host&&(n.hostname=or(n.host).host);Rt(this,n),this.secure=n.secure!=null?n.secure:typeof location<"u"&&location.protocol==="https:",n.hostname&&!n.port&&(n.port=this.secure?"443":"80"),this.hostname=n.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=n.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},n.transports.forEach(r=>{let i=r.prototype.name;this.transports.push(i),this._transportsByName[i]=r}),this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},n),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=t_(this.opts.query)),el&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this._beforeunloadEventListener,!1)),this.hostname!=="localhost"&&(this._offlineEventListener=()=>{this._onClose("transport close",{description:"network connection lost"})},To.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(t){let n=Object.assign({},this.opts.query);n.EIO=Yc,n.transport=t,this.id&&(n.sid=this.id);let r=Object.assign({},this.opts,{query:n,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[t]);return new this._transportsByName[t](r)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}let t=this.opts.rememberUpgrade&&e.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports[0];this.readyState="opening";let n=this.createTransport(t);n.open(),this.setTransport(n)}setTransport(t){this.transport&&this.transport.removeAllListeners(),this.transport=t,t.on("drain",this._onDrain.bind(this)).on("packet",this._onPacket.bind(this)).on("error",this._onError.bind(this)).on("close",n=>this._onClose("transport close",n))}onOpen(){this.readyState="open",e.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush()}_onPacket(t){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",t),this.emitReserved("heartbeat"),t.type){case"open":this.onHandshake(JSON.parse(t.data));break;case"ping":this._sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this._resetPingTimeout();break;case"error":let n=new Error("server error");n.code=t.data,this._onError(n);break;case"message":this.emitReserved("data",t.data),this.emitReserved("message",t.data);break}}onHandshake(t){this.emitReserved("handshake",t),this.id=t.sid,this.transport.query.sid=t.sid,this._pingInterval=t.pingInterval,this._pingTimeout=t.pingTimeout,this._maxPayload=t.maxPayload,this.onOpen(),this.readyState!=="closed"&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);let t=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+t,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},t),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){let t=this._getWritablePackets();this.transport.send(t),this._prevBufferLen=t.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let n=1;for(let r=0;r<this.writeBuffer.length;r++){let i=this.writeBuffer[r].data;if(i&&(n+=Z1(i)),r>0&&n>this._maxPayload)return this.writeBuffer.slice(0,r);n+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;let t=Date.now()>this._pingTimeoutTime;return t&&(this._pingTimeoutTime=0,Dt(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),t}write(t,n,r){return this._sendPacket("message",t,n,r),this}send(t,n,r){return this._sendPacket("message",t,n,r),this}_sendPacket(t,n,r,i){if(typeof n=="function"&&(i=n,n=void 0),typeof r=="function"&&(i=r,r=null),this.readyState==="closing"||this.readyState==="closed")return;r=r||{},r.compress=r.compress!==!1;let s={type:t,data:n,options:r};this.emitReserved("packetCreate",s),this.writeBuffer.push(s),i&&this.once("flush",i),this.flush()}close(){let t=()=>{this._onClose("forced close"),this.transport.close()},n=()=>{this.off("upgrade",n),this.off("upgradeError",n),t()},r=()=>{this.once("upgrade",n),this.once("upgradeError",n)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?r():t()}):this.upgrading?r():t()),this}_onError(t){if(e.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState==="opening")return this.transports.shift(),this._open();this.emitReserved("error",t),this._onClose("transport error",t)}_onClose(t,n){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing"){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),el&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){let r=To.indexOf(this._offlineEventListener);r!==-1&&To.splice(r,1)}this.readyState="closed",this.id=null,this.emitReserved("close",t,n),this.writeBuffer=[],this._prevBufferLen=0}}};Pn.protocol=Yc;var Mo=class extends Pn{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState==="open"&&this.opts.upgrade)for(let t=0;t<this._upgrades.length;t++)this._probe(this._upgrades[t])}_probe(t){let n=this.createTransport(t),r=!1;Pn.priorWebsocketSuccess=!1;let i=()=>{r||(n.send([{type:"ping",data:"probe"}]),n.once("packet",f=>{if(!r)if(f.type==="pong"&&f.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",n),!n)return;Pn.priorWebsocketSuccess=n.name==="websocket",this.transport.pause(()=>{r||this.readyState!=="closed"&&(l(),this.setTransport(n),n.send([{type:"upgrade"}]),this.emitReserved("upgrade",n),n=null,this.upgrading=!1,this.flush())})}else{let p=new Error("probe error");p.transport=n.name,this.emitReserved("upgradeError",p)}}))};function s(){r||(r=!0,l(),n.close(),n=null)}let o=f=>{let p=new Error("probe error: "+f);p.transport=n.name,s(),this.emitReserved("upgradeError",p)};function a(){o("transport closed")}function u(){o("socket closed")}function c(f){n&&f.name!==n.name&&s()}let l=()=>{n.removeListener("open",i),n.removeListener("error",o),n.removeListener("close",a),this.off("close",u),this.off("upgrading",c)};n.once("open",i),n.once("error",o),n.once("close",a),this.once("close",u),this.once("upgrading",c),this._upgrades.indexOf("webtransport")!==-1&&t!=="webtransport"?this.setTimeoutFn(()=>{r||n.open()},200):n.open()}onHandshake(t){this._upgrades=this._filterUpgrades(t.upgrades),super.onHandshake(t)}_filterUpgrades(t){let n=[];for(let r=0;r<t.length;r++)~this.transports.indexOf(t[r])&&n.push(t[r]);return n}},ar=class extends Mo{constructor(t,n={}){let r=typeof t=="object"?t:n;(!r.transports||r.transports&&typeof r.transports[0]=="string")&&(r.transports=(r.transports||["polling","websocket","webtransport"]).map(i=>Zc[i]).filter(i=>!!i)),super(t,r)}};var QG=ar.protocol;function a_(e,t="",n){let r=e;n=n||typeof location<"u"&&location,e==null&&(e=n.protocol+"//"+n.host),typeof e=="string"&&(e.charAt(0)==="/"&&(e.charAt(1)==="/"?e=n.protocol+e:e=n.host+e),/^(https?|wss?):\/\//.test(e)||(typeof n<"u"?e=n.protocol+"//"+e:e="https://"+e),r=or(e)),r.port||(/^(http|ws)$/.test(r.protocol)?r.port="80":/^(http|ws)s$/.test(r.protocol)&&(r.port="443")),r.path=r.path||"/";let s=r.host.indexOf(":")!==-1?"["+r.host+"]":r.host;return r.id=r.protocol+"://"+s+":"+r.port+t,r.href=r.protocol+"://"+s+(n&&n.port===r.port?"":":"+r.port),r}var ol={};ll(ol,{Decoder:()=>il,Encoder:()=>rl,PacketType:()=>X,isPacketValid:()=>Gj,protocol:()=>p_});var Nj=typeof ArrayBuffer=="function",Cj=e=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer,u_=Object.prototype.toString,qj=typeof Blob=="function"||typeof Blob<"u"&&u_.call(Blob)==="[object BlobConstructor]",jj=typeof File=="function"||typeof File<"u"&&u_.call(File)==="[object FileConstructor]";function ns(e){return Nj&&(e instanceof ArrayBuffer||Cj(e))||qj&&e instanceof Blob||jj&&e instanceof File}function ts(e,t){if(!e||typeof e!="object")return!1;if(Array.isArray(e)){for(let n=0,r=e.length;n<r;n++)if(ts(e[n]))return!0;return!1}if(ns(e))return!0;if(e.toJSON&&typeof e.toJSON=="function"&&arguments.length===1)return ts(e.toJSON(),!0);for(let n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&ts(e[n]))return!0;return!1}function c_(e){let t=[],n=e.data,r=e;return r.data=tl(n,t),r.attachments=t.length,{packet:r,buffers:t}}function tl(e,t){if(!e)return e;if(ns(e)){let n={_placeholder:!0,num:t.length};return t.push(e),n}else if(Array.isArray(e)){let n=new Array(e.length);for(let r=0;r<e.length;r++)n[r]=tl(e[r],t);return n}else if(typeof e=="object"&&!(e instanceof Date)){let n={};for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=tl(e[r],t));return n}return e}function l_(e,t){return e.data=nl(e.data,t),delete e.attachments,e}function nl(e,t){if(!e)return e;if(e&&e._placeholder===!0){if(typeof e.num=="number"&&e.num>=0&&e.num<t.length)return t[e.num];throw new Error("illegal attachments")}else if(Array.isArray(e))for(let n=0;n<e.length;n++)e[n]=nl(e[n],t);else if(typeof e=="object")for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&(e[n]=nl(e[n],t));return e}var f_=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],p_=5,X;(function(e){e[e.CONNECT=0]="CONNECT",e[e.DISCONNECT=1]="DISCONNECT",e[e.EVENT=2]="EVENT",e[e.ACK=3]="ACK",e[e.CONNECT_ERROR=4]="CONNECT_ERROR",e[e.BINARY_EVENT=5]="BINARY_EVENT",e[e.BINARY_ACK=6]="BINARY_ACK"})(X||(X={}));var rl=class{constructor(t){this.replacer=t}encode(t){return(t.type===X.EVENT||t.type===X.ACK)&&ts(t)?this.encodeAsBinary({type:t.type===X.EVENT?X.BINARY_EVENT:X.BINARY_ACK,nsp:t.nsp,data:t.data,id:t.id}):[this.encodeAsString(t)]}encodeAsString(t){let n=""+t.type;return(t.type===X.BINARY_EVENT||t.type===X.BINARY_ACK)&&(n+=t.attachments+"-"),t.nsp&&t.nsp!=="/"&&(n+=t.nsp+","),t.id!=null&&(n+=t.id),t.data!=null&&(n+=JSON.stringify(t.data,this.replacer)),n}encodeAsBinary(t){let n=c_(t),r=this.encodeAsString(n.packet),i=n.buffers;return i.unshift(r),i}},il=class e extends ye{constructor(t){super(),this.reviver=t}add(t){let n;if(typeof t=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");n=this.decodeString(t);let r=n.type===X.BINARY_EVENT;r||n.type===X.BINARY_ACK?(n.type=r?X.EVENT:X.ACK,this.reconstructor=new sl(n),n.attachments===0&&super.emitReserved("decoded",n)):super.emitReserved("decoded",n)}else if(ns(t)||t.base64)if(this.reconstructor)n=this.reconstructor.takeBinaryData(t),n&&(this.reconstructor=null,super.emitReserved("decoded",n));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+t)}decodeString(t){let n=0,r={type:Number(t.charAt(0))};if(X[r.type]===void 0)throw new Error("unknown packet type "+r.type);if(r.type===X.BINARY_EVENT||r.type===X.BINARY_ACK){let s=n+1;for(;t.charAt(++n)!=="-"&&n!=t.length;);let o=t.substring(s,n);if(o!=Number(o)||t.charAt(n)!=="-")throw new Error("Illegal attachments");r.attachments=Number(o)}if(t.charAt(n+1)==="/"){let s=n+1;for(;++n&&!(t.charAt(n)===","||n===t.length););r.nsp=t.substring(s,n)}else r.nsp="/";let i=t.charAt(n+1);if(i!==""&&Number(i)==i){let s=n+1;for(;++n;){let o=t.charAt(n);if(o==null||Number(o)!=o){--n;break}if(n===t.length)break}r.id=Number(t.substring(s,n+1))}if(t.charAt(++n)){let s=this.tryParse(t.substr(n));if(e.isPayloadValid(r.type,s))r.data=s;else throw new Error("invalid payload")}return r}tryParse(t){try{return JSON.parse(t,this.reviver)}catch{return!1}}static isPayloadValid(t,n){switch(t){case X.CONNECT:return Io(n);case X.DISCONNECT:return n===void 0;case X.CONNECT_ERROR:return typeof n=="string"||Io(n);case X.EVENT:case X.BINARY_EVENT:return Array.isArray(n)&&(typeof n[0]=="number"||typeof n[0]=="string"&&f_.indexOf(n[0])===-1);case X.ACK:case X.BINARY_ACK:return Array.isArray(n)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}},sl=class{constructor(t){this.packet=t,this.buffers=[],this.reconPack=t}takeBinaryData(t){if(this.buffers.push(t),this.buffers.length===this.reconPack.attachments){let n=l_(this.reconPack,this.buffers);return this.finishedReconstruction(),n}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}};function Dj(e){return typeof e=="string"}var Rj=Number.isInteger||function(e){return typeof e=="number"&&isFinite(e)&&Math.floor(e)===e};function Bj(e){return e===void 0||Rj(e)}function Io(e){return Object.prototype.toString.call(e)==="[object Object]"}function Lj(e,t){switch(e){case X.CONNECT:return t===void 0||Io(t);case X.DISCONNECT:return t===void 0;case X.EVENT:return Array.isArray(t)&&(typeof t[0]=="number"||typeof t[0]=="string"&&f_.indexOf(t[0])===-1);case X.ACK:return Array.isArray(t);case X.CONNECT_ERROR:return typeof t=="string"||Io(t);default:return!1}}function Gj(e){return Dj(e.nsp)&&Bj(e.id)&&Lj(e.type,e.data)}function Qe(e,t,n){return e.on(t,n),function(){e.off(t,n)}}var Fj=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1}),ur=class extends ye{constructor(t,n,r){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=t,this.nsp=n,r&&r.auth&&(this.auth=r.auth),this._opts=Object.assign({},r),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;let t=this.io;this.subs=[Qe(t,"open",this.onopen.bind(this)),Qe(t,"packet",this.onpacket.bind(this)),Qe(t,"error",this.onerror.bind(this)),Qe(t,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen(),this)}open(){return this.connect()}send(...t){return t.unshift("message"),this.emit.apply(this,t),this}emit(t,...n){var r,i,s;if(Fj.hasOwnProperty(t))throw new Error('"'+t.toString()+'" is a reserved event name');if(n.unshift(t),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(n),this;let o={type:X.EVENT,data:n};if(o.options={},o.options.compress=this.flags.compress!==!1,typeof n[n.length-1]=="function"){let l=this.ids++,f=n.pop();this._registerAckCallback(l,f),o.id=l}let a=(i=(r=this.io.engine)===null||r===void 0?void 0:r.transport)===null||i===void 0?void 0:i.writable,u=this.connected&&!(!((s=this.io.engine)===null||s===void 0)&&s._hasPingExpired());return this.flags.volatile&&!a||(u?(this.notifyOutgoingListeners(o),this.packet(o)):this.sendBuffer.push(o)),this.flags={},this}_registerAckCallback(t,n){var r;let i=(r=this.flags.timeout)!==null&&r!==void 0?r:this._opts.ackTimeout;if(i===void 0){this.acks[t]=n;return}let s=this.io.setTimeoutFn(()=>{delete this.acks[t];for(let a=0;a<this.sendBuffer.length;a++)this.sendBuffer[a].id===t&&this.sendBuffer.splice(a,1);n.call(this,new Error("operation has timed out"))},i),o=(...a)=>{this.io.clearTimeoutFn(s),n.apply(this,a)};o.withError=!0,this.acks[t]=o}emitWithAck(t,...n){return new Promise((r,i)=>{let s=(o,a)=>o?i(o):r(a);s.withError=!0,n.push(s),this.emit(t,...n)})}_addToQueue(t){let n;typeof t[t.length-1]=="function"&&(n=t.pop());let r={id:this._queueSeq++,tryCount:0,pending:!1,args:t,flags:Object.assign({fromQueue:!0},this.flags)};t.push((i,...s)=>(this._queue[0],i!==null?r.tryCount>this._opts.retries&&(this._queue.shift(),n&&n(i)):(this._queue.shift(),n&&n(null,...s)),r.pending=!1,this._drainQueue())),this._queue.push(r),this._drainQueue()}_drainQueue(t=!1){if(!this.connected||this._queue.length===0)return;let n=this._queue[0];n.pending&&!t||(n.pending=!0,n.tryCount++,this.flags=n.flags,this.emit.apply(this,n.args))}packet(t){t.nsp=this.nsp,this.io._packet(t)}onopen(){typeof this.auth=="function"?this.auth(t=>{this._sendConnectPacket(t)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(t){this.packet({type:X.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},t):t})}onerror(t){this.connected||this.emitReserved("connect_error",t)}onclose(t,n){this.connected=!1,delete this.id,this.emitReserved("disconnect",t,n),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(t=>{if(!this.sendBuffer.some(r=>String(r.id)===t)){let r=this.acks[t];delete this.acks[t],r.withError&&r.call(this,new Error("socket has been disconnected"))}})}onpacket(t){if(t.nsp===this.nsp)switch(t.type){case X.CONNECT:t.data&&t.data.sid?this.onconnect(t.data.sid,t.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case X.EVENT:case X.BINARY_EVENT:this.onevent(t);break;case X.ACK:case X.BINARY_ACK:this.onack(t);break;case X.DISCONNECT:this.ondisconnect();break;case X.CONNECT_ERROR:this.destroy();let r=new Error(t.data.message);r.data=t.data.data,this.emitReserved("connect_error",r);break}}onevent(t){let n=t.data||[];t.id!=null&&n.push(this.ack(t.id)),this.connected?this.emitEvent(n):this.receiveBuffer.push(Object.freeze(n))}emitEvent(t){if(this._anyListeners&&this._anyListeners.length){let n=this._anyListeners.slice();for(let r of n)r.apply(this,t)}super.emit.apply(this,t),this._pid&&t.length&&typeof t[t.length-1]=="string"&&(this._lastOffset=t[t.length-1])}ack(t){let n=this,r=!1;return function(...i){r||(r=!0,n.packet({type:X.ACK,id:t,data:i}))}}onack(t){let n=this.acks[t.id];typeof n=="function"&&(delete this.acks[t.id],n.withError&&t.data.unshift(null),n.apply(this,t.data))}onconnect(t,n){this.id=t,this.recovered=n&&this._pid===n,this._pid=n,this.connected=!0,this.emitBuffered(),this._drainQueue(!0),this.emitReserved("connect")}emitBuffered(){this.receiveBuffer.forEach(t=>this.emitEvent(t)),this.receiveBuffer=[],this.sendBuffer.forEach(t=>{this.notifyOutgoingListeners(t),this.packet(t)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(t=>t()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:X.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(t){return this.flags.compress=t,this}get volatile(){return this.flags.volatile=!0,this}timeout(t){return this.flags.timeout=t,this}onAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(t),this}prependAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(t),this}offAny(t){if(!this._anyListeners)return this;if(t){let n=this._anyListeners;for(let r=0;r<n.length;r++)if(t===n[r])return n.splice(r,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(t){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(t),this}prependAnyOutgoing(t){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(t),this}offAnyOutgoing(t){if(!this._anyOutgoingListeners)return this;if(t){let n=this._anyOutgoingListeners;for(let r=0;r<n.length;r++)if(t===n[r])return n.splice(r,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(t){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){let n=this._anyOutgoingListeners.slice();for(let r of n)r.apply(this,t.data)}}};function En(e){e=e||{},this.ms=e.min||100,this.max=e.max||1e4,this.factor=e.factor||2,this.jitter=e.jitter>0&&e.jitter<=1?e.jitter:0,this.attempts=0}En.prototype.duration=function(){var e=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var t=Math.random(),n=Math.floor(t*this.jitter*e);e=Math.floor(t*10)&1?e+n:e-n}return Math.min(e,this.max)|0};En.prototype.reset=function(){this.attempts=0};En.prototype.setMin=function(e){this.ms=e};En.prototype.setMax=function(e){this.max=e};En.prototype.setJitter=function(e){this.jitter=e};var cr=class extends ye{constructor(t,n){var r;super(),this.nsps={},this.subs=[],t&&typeof t=="object"&&(n=t,t=void 0),n=n||{},n.path=n.path||"/socket.io",this.opts=n,Rt(this,n),this.reconnection(n.reconnection!==!1),this.reconnectionAttempts(n.reconnectionAttempts||1/0),this.reconnectionDelay(n.reconnectionDelay||1e3),this.reconnectionDelayMax(n.reconnectionDelayMax||5e3),this.randomizationFactor((r=n.randomizationFactor)!==null&&r!==void 0?r:.5),this.backoff=new En({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(n.timeout==null?2e4:n.timeout),this._readyState="closed",this.uri=t;let i=n.parser||ol;this.encoder=new i.Encoder,this.decoder=new i.Decoder,this._autoConnect=n.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(t){return arguments.length?(this._reconnection=!!t,t||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(t){return t===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=t,this)}reconnectionDelay(t){var n;return t===void 0?this._reconnectionDelay:(this._reconnectionDelay=t,(n=this.backoff)===null||n===void 0||n.setMin(t),this)}randomizationFactor(t){var n;return t===void 0?this._randomizationFactor:(this._randomizationFactor=t,(n=this.backoff)===null||n===void 0||n.setJitter(t),this)}reconnectionDelayMax(t){var n;return t===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=t,(n=this.backoff)===null||n===void 0||n.setMax(t),this)}timeout(t){return arguments.length?(this._timeout=t,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(t){if(~this._readyState.indexOf("open"))return this;this.engine=new ar(this.uri,this.opts);let n=this.engine,r=this;this._readyState="opening",this.skipReconnect=!1;let i=Qe(n,"open",function(){r.onopen(),t&&t()}),s=a=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",a),t?t(a):this.maybeReconnectOnOpen()},o=Qe(n,"error",s);if(this._timeout!==!1){let a=this._timeout,u=this.setTimeoutFn(()=>{i(),s(new Error("timeout")),n.close()},a);this.opts.autoUnref&&u.unref(),this.subs.push(()=>{this.clearTimeoutFn(u)})}return this.subs.push(i),this.subs.push(o),this}connect(t){return this.open(t)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");let t=this.engine;this.subs.push(Qe(t,"ping",this.onping.bind(this)),Qe(t,"data",this.ondata.bind(this)),Qe(t,"error",this.onerror.bind(this)),Qe(t,"close",this.onclose.bind(this)),Qe(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(t){try{this.decoder.add(t)}catch(n){this.onclose("parse error",n)}}ondecoded(t){Dt(()=>{this.emitReserved("packet",t)},this.setTimeoutFn)}onerror(t){this.emitReserved("error",t)}socket(t,n){let r=this.nsps[t];return r?this._autoConnect&&!r.active&&r.connect():(r=new ur(this,t,n),this.nsps[t]=r),r}_destroy(t){let n=Object.keys(this.nsps);for(let r of n)if(this.nsps[r].active)return;this._close()}_packet(t){let n=this.encoder.encode(t);for(let r=0;r<n.length;r++)this.engine.write(n[r],t.options)}cleanup(){this.subs.forEach(t=>t()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(t,n){var r;this.cleanup(),(r=this.engine)===null||r===void 0||r.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",t,n),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;let t=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{let n=this.backoff.duration();this._reconnecting=!0;let r=this.setTimeoutFn(()=>{t.skipReconnect||(this.emitReserved("reconnect_attempt",t.backoff.attempts),!t.skipReconnect&&t.open(i=>{i?(t._reconnecting=!1,t.reconnect(),this.emitReserved("reconnect_error",i)):t.onreconnect()}))},n);this.opts.autoUnref&&r.unref(),this.subs.push(()=>{this.clearTimeoutFn(r)})}}onreconnect(){let t=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",t)}};var rs={};function is(e,t){typeof e=="object"&&(t=e,e=void 0),t=t||{};let n=a_(e,t.path||"/socket.io"),r=n.source,i=n.id,s=n.path,o=rs[i]&&s in rs[i].nsps,a=t.forceNew||t["force new connection"]||t.multiplex===!1||o,u;return a?u=new cr(r,t):(rs[i]||(rs[i]=new cr(r,t)),u=rs[i]),n.query&&!t.query&&(t.query=n.queryKey),u.socket(n.path,t)}Object.assign(is,{Manager:cr,Socket:ur,io:is,connect:is});var h_=is,al=class extends ir{constructor({socket:t,socketOpts:n,server:r,...i}){super(i),this.server=r,this.socket=t,this.socketOpts=n}sendAction(t,n){let r=[n,t._stateID,this.matchID,this.playerID];this.socket.emit("update",...r)}sendChatMessage(t,n){let r=[t,n,this.credentials];this.socket.emit("chat",...r)}connect(){if(!this.socket)if(this.server){let t=this.server;t.search(/^https?:\/\//)==-1&&(t="http://"+this.server),t.slice(-1)!="/"&&(t=t+"/"),this.socket=h_(t+this.gameName,this.socketOpts)}else this.socket=h_("/"+this.gameName,this.socketOpts);this.socket.on("patch",(t,n,r,i,s)=>{this.notifyClient({type:"patch",args:[t,n,r,i,s]})}),this.socket.on("update",(t,n,r)=>{this.notifyClient({type:"update",args:[t,n,r]})}),this.socket.on("sync",(t,n)=>{this.notifyClient({type:"sync",args:[t,n]})}),this.socket.on("matchData",(t,n)=>{this.notifyClient({type:"matchData",args:[t,n]})}),this.socket.on("chat",(t,n)=>{this.notifyClient({type:"chat",args:[t,n]})}),this.socket.on("connect",()=>{this.requestSync(),this.setConnectionStatus(!0)}),this.socket.on("disconnect",()=>{this.setConnectionStatus(!1)})}disconnect(){this.socket.close(),this.socket=null,this.setConnectionStatus(!1)}requestSync(){if(this.socket){let t=[this.matchID,this.playerID,this.credentials,this.numPlayers];this.socket.emit("sync",...t)}}updateMatchID(t){this.matchID=t,this.requestSync()}updatePlayerID(t){this.playerID=t,this.requestSync()}updateCredentials(t){this.credentials=t,this.requestSync()}};function ul({server:e,socketOpts:t}={}){return n=>new al({server:e,socketOpts:t,...n})}var G9=he(tn()),F9=he(qi());function No(e){if(e?.arguments){let t={...e};return t.arguments=Object.entries(t.arguments).reduce((n,[r,i])=>({...n,[r]:i.abstract?i:i.entityId}),{}),JSON.parse(He(t,{deduplicateInstances:!1}))}else return e}var Vj={PlaceNew:["destination"],RemoveEntity:["entity"],MoveEntity:["entity","destination"],TakeFrom:["source","destination"],SetState:["entity","state"]};function lr(e,t){return Vj[t.moveType].filter(n=>t.arguments[n].playerChoice).map(n=>({argName:n,getClickable:n==="state"?()=>t.arguments[n].possibleValues.map(r=>({abstract:!0,...t.arguments[n],value:r})):r=>e.G.bank.findAll(e,t.arguments[n],r)}))}function Co(e,t,n,r){let i=lr(e,t,r).map(s=>s.argName);return{arguments:n.reduce((s,o,a)=>({...s,[i[a]]:o}),{})}}var qo=class{constructor(t){this.options=t,this.game=t.boardgameIOGame||gi(JSON.parse(t.gameRules)),t.boardgameIOGame||(this.moveBuilder={targets:[],stepIndex:0,eliminatedMoves:[]},this.optimisticWinner=null)}connect(){let{server:t,numPlayers:n,debug:r={collapseOnLoad:!0,impl:Ki},matchID:i,playerID:s,credentials:o,multiplayer:a=ul({server:t,socketOpts:{transports:["websocket","polling"]}})}=this.options;try{let u=o?{game:this.game,multiplayer:a,matchID:i,playerID:s,credentials:o,numPlayers:n,debug:r}:{game:this.game,numPlayers:n,debug:r};return this.client=Hc(u),this.client.subscribe(()=>this.update()),this.client.start(),this}catch(u){console.error("Failed to join game:",u?.message??u),u?.stack&&console.error(u.stack)}}update(){this.options.onClientUpdate?.()}getState(){let t=this.client?.getState();if(!t)return{};let n=this.options.boardgameIOGame?t:{...t,G:Ft(JSON.stringify(t.G),ht)},r=this.optimisticWinner??n?.ctx?.gameover,i=r?[]:ti(n,this.client);if(this.options.boardgameIOGame)return{state:n,gameover:r,moves:this.client.moves,currentMoves:i};let s=Object.entries(i).reduce((u,[c,l])=>{let f=p=>{this.client.moves[c](No(p))};return f.moveInstance=l.moveInstance,{...u,[c]:f}},{}),{allClickable:o,_possibleMoveMeta:a}=Kj(n,s,this.moveBuilder);return{state:n,gameover:r,allClickable:o,_wrappedMoves:s,_possibleMoveMeta:a}}doStep(t){if(this.options.boardgameIOGame)return;let{state:n,_wrappedMoves:r,_possibleMoveMeta:i}=this.getState(),s=t.abstract?t:n.G.bank.locate(t.entityId),o=Object.entries(i).filter(([u,c])=>!zj(c.clickableForMove,s)).map(([u])=>u).concat(this.moveBuilder.eliminatedMoves);if(o.length===Object.keys(r).length){console.error("invalid move with target:",s?.rule);return}let a=Object.entries(i).filter(([u])=>!o.includes(u));if(Hj(n,r,a,this.moveBuilder.stepIndex)){let[u]=a[0],c=r[u],l=Co(n,c.moveInstance.rule,[...this.moveBuilder.targets,s],{moveInstance:c.moveInstance});this.optimisticWinner=Wj(n,this.game,c.moveInstance,l),c(l),this.moveBuilder={targets:[],stepIndex:0,eliminatedMoves:[]}}else this.moveBuilder={eliminatedMoves:o,stepIndex:this.moveBuilder.stepIndex+1,targets:[...this.moveBuilder.targets,s]};this.update()}reset(){this.options.boardgameIOGame||(this.moveBuilder={targets:[],stepIndex:0,eliminatedMoves:[]},this.optimisticWinner=null,this.update())}undoStep(){this.options.boardgameIOGame||(this.moveBuilder.targets.length&&(this.moveBuilder={targets:this.moveBuilder.targets.slice(0,-1),stepIndex:Math.max(0,this.moveBuilder.stepIndex-1),eliminatedMoves:[]}),this.update())}};function zj(e,t){return t.abstract?[...e].some(n=>n.abstract&&n.value===t.value):e.has(t)}function Kj(e,t,n){let{eliminatedMoves:r,stepIndex:i}=n,s={},o=new Set;return Object.entries(t).filter(([a])=>!r.includes(a)).forEach(([a,u])=>{let c=pe(e,{...u.moveInstance.rule,moveName:a}),l={moveInstance:u.moveInstance,moveArguments:c.arguments},f=n.targets.map(m=>m.abstract?m:e.G.bank.locate(m.entityId)),p=Co(e,c,f,l);l.moveArguments={...l.moveArguments,...p.arguments};let h=ke(e,c,{},l).conditionsAreMet,d=lr(e,c),y=new Set(h&&d?.[i]?.getClickable(l)||[]);s[a]={clickableForMove:y},y.forEach(m=>o.add(m))}),{_possibleMoveMeta:s,allClickable:o}}function Hj(e,t,n,r){return n.length===1&&lr(e,t[n[0][0]].moveInstance.rule).length===r+1}function Wj(e,t,n,r){let i=Zr(e,No(r),{moveInstance:n});return t.endIf?.({...e,G:JSON.parse(He(i))})}return w_(Jj);})();
32
+ normal forwards}.closer.svelte-8ymctk .icon.svelte-8ymctk{animation-direction:reverse}.pane.svelte-8ymctk.svelte-8ymctk{flex-grow:2;overflow-x:hidden;overflow-y:scroll;background:#fefefe;padding:20px;border-left:1px solid #ccc;box-shadow:-1px 0 5px rgba(0, 0, 0, 0.2);box-sizing:border-box;width:280px}.secondary-pane.svelte-8ymctk.svelte-8ymctk{background:#fefefe;overflow-y:scroll}.debug-panel.svelte-8ymctk button,.debug-panel.svelte-8ymctk select{cursor:pointer;font-size:14px;font-family:monospace}.debug-panel.svelte-8ymctk select{background:#eee;border:1px solid #bbb;color:#555;padding:3px;border-radius:3px}.debug-panel.svelte-8ymctk section{margin-bottom:20px}.debug-panel.svelte-8ymctk .screen-reader-only{clip:rect(0 0 0 0);clip-path:inset(50%);height:1px;overflow:hidden;position:absolute;white-space:nowrap;width:1px}`)}function oj(e){let t,n,r,i,s,o,a,u,c,l=e[10]&&uj(e);r=new sc({props:{panes:e[6],pane:e[2]}}),r.$on("change",e[8]);var f=e[6][e[2]].component;function p(d){return{props:{client:d[4],clientManager:d[0],ToggleVisibility:d[9]}}}f&&(o=new f(p(e)));let h=e[5]&&d1(e);return{c(){t=A("div"),l&&l.c(),n=q(),L(r.$$.fragment),i=q(),s=A("div"),o&&L(o.$$.fragment),a=q(),h&&h.c(),k(s,"class","pane svelte-8ymctk"),k(s,"role","region"),k(s,"aria-label",e[2]),k(s,"tabindex","-1"),k(t,"class","panel svelte-8ymctk")},m(d,y){M(d,t,y),l&&l.m(t,null),w(t,n),R(r,t,null),w(t,i),w(t,s),o&&R(o,s,null),e[16](s),w(t,a),h&&h.m(t,null),c=!0},p(d,y){e=d,e[10]&&l.p(e,y);let m={};y&4&&(m.pane=e[2]),r.$set(m);let b={};if(y&16&&(b.client=e[4]),y&1&&(b.clientManager=e[0]),f!==(f=e[6][e[2]].component)){if(o){ce();let g=o;x(g.$$.fragment,1,0,()=>{B(g,1)}),le()}f?(o=new f(p(e)),L(o.$$.fragment),P(o.$$.fragment,1),R(o,s,null)):o=null}else f&&o.$set(b);(!c||y&4)&&k(s,"aria-label",e[2]),e[5]?h?(h.p(e,y),y&32&&P(h,1)):(h=d1(e),h.c(),P(h,1),h.m(t,null)):h&&(ce(),x(h,1,1,()=>{h=null}),le())},i(d){c||(P(l),P(r.$$.fragment,d),o&&P(o.$$.fragment,d),P(h),ot(()=>{u||(u=mb(t,yb,{x:400,...e[12]},!0)),u.run(1)}),c=!0)},o(d){x(l),x(r.$$.fragment,d),o&&x(o.$$.fragment,d),x(h),u||(u=mb(t,yb,{x:400,...e[12]},!1)),u.run(0),c=!1},d(d){d&&S(t),l&&l.d(),B(r),o&&B(o),e[16](null),h&&h.d(),d&&u&&u.end()}}}function aj(e){let t,n,r=e[10]&&cj(e);return{c(){r&&r.c(),t=at()},m(i,s){r&&r.m(i,s),M(i,t,s),n=!0},p(i,s){i[10]&&r.p(i,s)},i(i){n||(P(r),n=!0)},o(i){x(r),n=!1},d(i){r&&r.d(i),i&&S(t)}}}function uj(e){let t,n,r,i,s,o,a,u;return r=new bo({}),{c(){t=A("button"),n=A("span"),L(r.$$.fragment),k(n,"class","icon svelte-8ymctk"),k(n,"aria-hidden","true"),k(t,"class","visibility-toggle closer svelte-8ymctk"),k(t,"title","Hide Debug Panel")},m(c,l){M(c,t,l),w(t,n),R(r,n,null),o=!0,a||(u=Q(t,"click",e[9]),a=!0)},p:U,i(c){o||(P(r.$$.fragment,c),ot(()=>{s&&s.end(1),i=k1(t,e[14],{key:"toggle"}),i.start()}),o=!0)},o(c){x(r.$$.fragment,c),i&&i.invalidate(),s=A1(t,e[13],{key:"toggle"}),o=!1},d(c){c&&S(t),B(r),c&&s&&s.end(),a=!1,u()}}}function d1(e){let t,n,r;var i=e[5].component;function s(o){return{props:{metadata:o[5].metadata}}}return i&&(n=new i(s(e))),{c(){t=A("div"),n&&L(n.$$.fragment),k(t,"class","secondary-pane svelte-8ymctk")},m(o,a){M(o,t,a),n&&R(n,t,null),r=!0},p(o,a){let u={};if(a&32&&(u.metadata=o[5].metadata),i!==(i=o[5].component)){if(n){ce();let c=n;x(c.$$.fragment,1,0,()=>{B(c,1)}),le()}i?(n=new i(s(o)),L(n.$$.fragment),P(n.$$.fragment,1),R(n,t,null)):n=null}else i&&n.$set(u)},i(o){r||(n&&P(n.$$.fragment,o),r=!0)},o(o){n&&x(n.$$.fragment,o),r=!1},d(o){o&&S(t),n&&B(n)}}}function cj(e){let t,n,r,i,s,o,a,u;return r=new bo({}),{c(){t=A("button"),n=A("span"),L(r.$$.fragment),k(n,"class","icon svelte-8ymctk"),k(n,"aria-hidden","true"),k(t,"class","visibility-toggle opener svelte-8ymctk"),k(t,"title","Show Debug Panel")},m(c,l){M(c,t,l),w(t,n),R(r,n,null),o=!0,a||(u=Q(t,"click",e[9]),a=!0)},p:U,i(c){o||(P(r.$$.fragment,c),ot(()=>{s&&s.end(1),i=k1(t,e[14],{key:"toggle"}),i.start()}),o=!0)},o(c){x(r.$$.fragment,c),i&&i.invalidate(),s=A1(t,e[13],{key:"toggle"}),o=!1},d(c){c&&S(t),B(r),c&&s&&s.end(),a=!1,u()}}}function lj(e){let t,n,r,i,s,o,a=[aj,oj],u=[];function c(l,f){return l[3]?1:0}return n=c(e),r=u[n]=a[n](e),{c(){t=A("section"),r.c(),k(t,"aria-label","boardgame.io Debug Panel"),k(t,"class","debug-panel svelte-8ymctk")},m(l,f){M(l,t,f),u[n].m(t,null),i=!0,s||(o=Q(window,"keypress",e[11]),s=!0)},p(l,[f]){let p=n;n=c(l),n===p?u[n].p(l,f):(ce(),x(u[p],1,1,()=>{u[p]=null}),le(),r=u[n],r?r.p(l,f):(r=u[n]=a[n](l),r.c()),P(r,1),r.m(t,null))},i(l){i||(P(r),i=!0)},o(l){x(r),i=!1},d(l){l&&S(t),u[n].d(),s=!1,o()}}}function fj(e,t,n){let r,i,s=U,o=()=>(s(),s=Hi(u,J=>n(15,i=J)),u),a;e.$$.on_destroy.push(()=>s());let{clientManager:u}=t;o();let c={main:{label:"Main",shortcut:"m",component:vc},log:{label:"Log",shortcut:"l",component:kc},info:{label:"Info",shortcut:"i",component:bc},ai:{label:"AI",shortcut:"a",component:xc}},l=gb(!1),f=gb(null);g1(e,f,J=>n(5,a=J)),Fi("hotkeys",{disableHotkeys:l}),Fi("secondaryPane",{secondaryPane:f});let p,h="main";function d(J){n(2,h=J.detail),p.focus()}function y(){n(3,b=!b)}let m=i.client.debugOpt,b=!m||!m.collapseOnLoad,g=!m||!m.hideToggleButton;function O(J){if(J.key=="."){y();return}b&&Object.entries(c).forEach(([fe,{shortcut:V}])=>{J.key==V&&n(2,h=fe)})}let I={duration:150,easing:Dc},[j,N]=WC(I);function D(J){yo[J?"unshift":"push"](()=>{p=J,n(1,p)})}return e.$$set=J=>{"clientManager"in J&&o(n(0,u=J.clientManager))},e.$$.update=()=>{e.$$.dirty&32768&&n(4,r=i.client)},[u,p,h,b,r,a,c,f,d,y,g,O,I,j,N,i,D]}var Ki=class extends Z{constructor(t){super(),te(this,t,fj,lj,ee,{clientManager:0},sj)}};function On(e){"@babel/helpers - typeof";return On=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},On(e)}function M1(e,t){if(On(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(On(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function I1(e){var t=M1(e,"string");return On(t)=="symbol"?t:t+""}function N1(e,t,n){return(t=I1(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function C1(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function Rc(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?C1(Object(n),!0).forEach(function(r){N1(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):C1(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function Xe(e){return"Minified Redux error #"+e+"; visit https://redux.js.org/Errors?code="+e+" for the full message or use the non-minified dev environment for full errors. "}var q1=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}(),Bc=function(){return Math.random().toString(36).substring(7).split("").join(".")},j1={INIT:"@@redux/INIT"+Bc(),REPLACE:"@@redux/REPLACE"+Bc(),PROBE_UNKNOWN_ACTION:function(){return"@@redux/PROBE_UNKNOWN_ACTION"+Bc()}};function pj(e){if(typeof e!="object"||e===null)return!1;for(var t=e;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function Lc(e,t,n){var r;if(typeof t=="function"&&typeof n=="function"||typeof n=="function"&&typeof arguments[3]=="function")throw new Error(Xe(0));if(typeof t=="function"&&typeof n>"u"&&(n=t,t=void 0),typeof n<"u"){if(typeof n!="function")throw new Error(Xe(1));return n(Lc)(e,t)}if(typeof e!="function")throw new Error(Xe(2));var i=e,s=t,o=[],a=o,u=!1;function c(){a===o&&(a=o.slice())}function l(){if(u)throw new Error(Xe(3));return s}function f(y){if(typeof y!="function")throw new Error(Xe(4));if(u)throw new Error(Xe(5));var m=!0;return c(),a.push(y),function(){if(m){if(u)throw new Error(Xe(6));m=!1,c();var g=a.indexOf(y);a.splice(g,1),o=null}}}function p(y){if(!pj(y))throw new Error(Xe(7));if(typeof y.type>"u")throw new Error(Xe(8));if(u)throw new Error(Xe(9));try{u=!0,s=i(s,y)}finally{u=!1}for(var m=o=a,b=0;b<m.length;b++){var g=m[b];g()}return y}function h(y){if(typeof y!="function")throw new Error(Xe(10));i=y,p({type:j1.REPLACE})}function d(){var y,m=f;return y={subscribe:function(g){if(typeof g!="object"||g===null)throw new Error(Xe(11));function O(){g.next&&g.next(l())}O();var I=m(O);return{unsubscribe:I}}},y[q1]=function(){return this},y}return p({type:j1.INIT}),r={dispatch:p,subscribe:f,getState:l,replaceReducer:h},r[q1]=d,r}function Gc(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return t.length===0?function(r){return r}:t.length===1?t[0]:t.reduce(function(r,i){return function(){return r(i.apply(void 0,arguments))}})}function D1(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(r){return function(){var i=r.apply(void 0,arguments),s=function(){throw new Error(Xe(15))},o={getState:i.getState,dispatch:function(){return s.apply(void 0,arguments)}},a=t.map(function(u){return u(o)});return s=Gc.apply(void 0,a)(i.dispatch),Rc(Rc({},i),{},{dispatch:s})}}}function R1({game:e,numPlayers:t,setupData:n}){e=ji(e),t||(t=2);let r=e.flow.ctx(t),i={G:{},ctx:r,plugins:{}};i=Nv(i,{game:e}),i=Ti(i,{game:e,playerID:void 0});let s=Wt(i);i.G=e.setup({...s,ctx:i.ctx},n);let o={...i,_undo:[],_redo:[],_stateID:0};return o=e.flow.init(o),[o]=eo(o,{game:e}),e.disableUndo||(o._undo=[{G:o.G,ctx:o.ctx,plugins:o.plugins}]),o}var ir=class{constructor({transportDataCallback:t,gameName:n,playerID:r,matchID:i,credentials:s,numPlayers:o}){this.connectionStatusCallback=()=>{},this.isConnected=!1,this.transportDataCallback=t,this.gameName=n||"default",this.playerID=r||null,this.matchID=i||"default",this.credentials=s,this.numPlayers=o||2}subscribeToConnectionStatus(t){this.connectionStatusCallback=t}setConnectionStatus(t){this.isConnected=t,this.connectionStatusCallback()}notifyClient(t){this.transportDataCallback(t)}};var Fc=class extends ir{connect(){}disconnect(){}sendAction(){}sendChatMessage(){}requestSync(){}updateCredentials(){}updateMatchID(){}updatePlayerID(){}},hj=e=>new Fc(e),Uc=class{constructor(){this.debugPanel=null,this.currentClient=null,this.clients=new Map,this.subscribers=new Map}register(t){this.clients.set(t,t),this.mountDebug(t),this.notifySubscribers()}unregister(t){if(this.clients.delete(t),this.currentClient===t){this.unmountDebug();for(let[n]of this.clients){if(this.debugPanel)break;this.mountDebug(n)}}this.notifySubscribers()}subscribe(t){let n=Symbol();return this.subscribers.set(n,t),t(this.getState()),()=>{this.subscribers.delete(n)}}switchPlayerID(t){if(this.currentClient.multiplayer){for(let[n]of this.clients)if(n.playerID===t&&n.debugOpt!==!1&&n.multiplayer===this.currentClient.multiplayer){this.switchToClient(n);return}}this.currentClient.updatePlayerID(t),this.notifySubscribers()}switchToClient(t){t!==this.currentClient&&(this.unmountDebug(),this.mountDebug(t),this.notifySubscribers())}notifySubscribers(){let t=this.getState();this.subscribers.forEach(n=>{n(t)})}getState(){return{client:this.currentClient,debuggableClients:this.getDebuggableClients()}}getDebuggableClients(){return[...this.clients.values()].filter(t=>t.debugOpt!==!1)}mountDebug(t){if(t.debugOpt===!1||this.debugPanel!==null||typeof document>"u")return;let n,r=document.body;t.debugOpt&&t.debugOpt!==!0&&(n=t.debugOpt.impl||n,r=t.debugOpt.target||r),n&&(this.currentClient=t,this.debugPanel=new n({target:r,props:{clientManager:this}}))}unmountDebug(){this.debugPanel.$destroy(),this.debugPanel=null,this.currentClient=null}},dj=new Uc;function Vc(e,t,n){return!n&&e==null&&(e=t.getState().ctx.currentPlayer),e}function Kc(e,t,n,r,i,s){let o={};for(let a of t)o[a]=(...u)=>{let c=Mv[e](a,u,Vc(r,n,s),i);n.dispatch(c)};return o}var mj=Kc.bind(null,"makeMove"),gj=Kc.bind(null,"gameEvent"),yj=Kc.bind(null,"plugin"),zc=class{constructor({game:t,debug:n,numPlayers:r,multiplayer:i,matchID:s,playerID:o,credentials:a,enhancer:u}){this.game=ji(t),this.playerID=o,this.matchID=s||"default",this.credentials=a,this.multiplayer=i,this.debugOpt=n,this.manager=dj,this.gameStateOverride=null,this.subscribers={},this._running=!1,this.reducer=Xn({game:this.game,isClient:i!==void 0}),this.initialState=null,i||(this.initialState=R1({game:this.game,numPlayers:r})),this.reset=()=>{this.store.dispatch(Nu(this.initialState))},this.undo=()=>{let h=Cu(Vc(this.playerID,this.store,this.multiplayer),this.credentials);this.store.dispatch(h)},this.redo=()=>{let h=qu(Vc(this.playerID,this.store,this.multiplayer),this.credentials);this.store.dispatch(h)},this.log=[];let p=D1(cb,()=>h=>d=>{let y=h(d);return this.notifySubscribers(),y},h=>d=>y=>{let m=h.getState(),b=d(y);return!("clientOnly"in y)&&y.type!==$n&&this.transport.sendAction(m,y),b},h=>d=>y=>{let m=d(y),b=h.getState();switch(y.type){case _i:case Yn:case Ei:case wi:{let g=b.deltalog;this.log=[...this.log,...g];break}case Oi:{this.log=[];break}case Ai:case ki:{let g=-1;this.log.length>0&&(g=this.log[this.log.length-1]._stateID);let O=y.deltalog||[];O=O.filter(I=>I._stateID>g),this.log=[...this.log,...O];break}case Pi:{this.initialState=y.initialState,this.log=y.log||[];break}}return m});u=u!==void 0?Gc(p,u):p,this.store=Lc(this.reducer,this.initialState,u),i||(i=hj),this.transport=i({transportDataCallback:h=>this.receiveTransportData(h),gameKey:t,game:this.game,matchID:s,playerID:o,credentials:a,gameName:this.game.name,numPlayers:r}),this.createDispatchers(),this.chatMessages=[],this.sendChatMessage=h=>{this.transport.sendChatMessage(this.matchID,{id:mv(7),sender:this.playerID,payload:h})}}receiveMatchData(t){this.matchData=t,this.notifySubscribers()}receiveChatMessage(t){this.chatMessages=[...this.chatMessages,t],this.notifySubscribers()}receiveTransportData(t){let[n]=t.args;if(n===this.matchID)switch(t.type){case"sync":{let[,r]=t.args,i=xi(r);this.receiveMatchData(r.filteredMetadata),this.store.dispatch(i);break}case"update":{let[,r,i]=t.args,s=this.store.getState();if(r._stateID>=s._stateID){let o=Iu(r,i);this.store.dispatch(o)}break}case"patch":{let[,r,i,s,o]=t.args,a=this.store.getState()._stateID;if(r!==a)break;let u=Mu(r,i,s,o);this.store.dispatch(u),this.store.getState()._stateID===a&&this.transport.requestSync();break}case"matchData":{let[,r]=t.args;this.receiveMatchData(r);break}case"chat":{let[,r]=t.args;this.receiveChatMessage(r);break}}}notifySubscribers(){Object.values(this.subscribers).forEach(t=>t(this.getState()))}overrideGameState(t){this.gameStateOverride=t,this.notifySubscribers()}start(){this.transport.connect(),this._running=!0,this.manager.register(this)}stop(){this.transport.disconnect(),this._running=!1,this.manager.unregister(this)}subscribe(t){let n=Object.keys(this.subscribers).length;return this.subscribers[n]=t,this.transport.subscribeToConnectionStatus(()=>this.notifySubscribers()),(this._running||!this.multiplayer)&&t(this.getState()),()=>{delete this.subscribers[n]}}getInitialState(){return this.initialState}getState(){let t=this.store.getState();if(this.gameStateOverride!==null&&(t=this.gameStateOverride),t===null)return t;let n=!0,r=this.game.flow.isPlayerActive(t.G,t.ctx,this.playerID);return this.multiplayer&&!r&&(n=!1),!this.multiplayer&&this.playerID!==null&&this.playerID!==void 0&&!r&&(n=!1),t.ctx.gameover!==void 0&&(n=!1),this.multiplayer||(t={...t,G:this.game.playerView({G:t.G,ctx:t.ctx,playerID:this.playerID}),plugins:qv(t,this)}),{...t,log:this.log,isActive:n,isConnected:this.transport.isConnected}}createDispatchers(){this.moves=mj(this.game.moveNames,this.store,this.playerID,this.credentials,this.multiplayer),this.events=gj(this.game.flow.enabledEventNames,this.store,this.playerID,this.credentials,this.multiplayer),this.plugins=yj(this.game.pluginNames,this.store,this.playerID,this.credentials,this.multiplayer)}updatePlayerID(t){this.playerID=t,this.createDispatchers(),this.transport.updatePlayerID(t),this.notifySubscribers()}updateMatchID(t){this.matchID=t,this.createDispatchers(),this.transport.updateMatchID(t),this.notifySubscribers()}updateCredentials(t){this.credentials=t,this.createDispatchers(),this.transport.updateCredentials(t),this.notifySubscribers()}};function Hc(e){return new zc(e)}var DL=he(tn());var BL=he(qi());var LL=he(io());var UL=he(tn());var zL=he(qi());var KL=he(io());var ut=Object.create(null);ut.open="0";ut.close="1";ut.ping="2";ut.pong="3";ut.message="4";ut.upgrade="5";ut.noop="6";var Yi=Object.create(null);Object.keys(ut).forEach(e=>{Yi[ut[e]]=e});var $i={type:"error",data:"parser error"};var G1=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",F1=typeof ArrayBuffer=="function",U1=e=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,Xi=({type:e,data:t},n,r)=>G1&&t instanceof Blob?n?r(t):B1(t,r):F1&&(t instanceof ArrayBuffer||U1(t))?n?r(t):B1(new Blob([t]),r):r(ut[e]+(t||"")),B1=(e,t)=>{let n=new FileReader;return n.onload=function(){let r=n.result.split(",")[1];t("b"+(r||""))},n.readAsDataURL(e)};function L1(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}var Wc;function V1(e,t){if(G1&&e.data instanceof Blob)return e.data.arrayBuffer().then(L1).then(t);if(F1&&(e.data instanceof ArrayBuffer||U1(e.data)))return t(L1(e.data));Xi(e,!1,n=>{Wc||(Wc=new TextEncoder),t(Wc.encode(n))})}var z1="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Qi=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let e=0;e<z1.length;e++)Qi[z1.charCodeAt(e)]=e;var K1=e=>{let t=e.length*.75,n=e.length,r,i=0,s,o,a,u;e[e.length-1]==="="&&(t--,e[e.length-2]==="="&&t--);let c=new ArrayBuffer(t),l=new Uint8Array(c);for(r=0;r<n;r+=4)s=Qi[e.charCodeAt(r)],o=Qi[e.charCodeAt(r+1)],a=Qi[e.charCodeAt(r+2)],u=Qi[e.charCodeAt(r+3)],l[i++]=s<<2|o>>4,l[i++]=(o&15)<<4|a>>2,l[i++]=(a&3)<<6|u&63;return c};var vj=typeof ArrayBuffer=="function",Zi=(e,t)=>{if(typeof e!="string")return{type:"message",data:H1(e,t)};let n=e.charAt(0);return n==="b"?{type:"message",data:bj(e.substring(1),t)}:Yi[n]?e.length>1?{type:Yi[n],data:e.substring(1)}:{type:Yi[n]}:$i},bj=(e,t)=>{if(vj){let n=K1(e);return H1(n,t)}else return{base64:!0,data:e}},H1=(e,t)=>{switch(t){case"blob":return e instanceof Blob?e:new Blob([e]);case"arraybuffer":default:return e instanceof ArrayBuffer?e:e.buffer}};var W1="",J1=(e,t)=>{let n=e.length,r=new Array(n),i=0;e.forEach((s,o)=>{Xi(s,!1,a=>{r[o]=a,++i===n&&t(r.join(W1))})})},Y1=(e,t)=>{let n=e.split(W1),r=[];for(let i=0;i<n.length;i++){let s=Zi(n[i],t);if(r.push(s),s.type==="error")break}return r};function $1(){return new TransformStream({transform(e,t){V1(e,n=>{let r=n.length,i;if(r<126)i=new Uint8Array(1),new DataView(i.buffer).setUint8(0,r);else if(r<65536){i=new Uint8Array(3);let s=new DataView(i.buffer);s.setUint8(0,126),s.setUint16(1,r)}else{i=new Uint8Array(9);let s=new DataView(i.buffer);s.setUint8(0,127),s.setBigUint64(1,BigInt(r))}e.data&&typeof e.data!="string"&&(i[0]|=128),t.enqueue(i),t.enqueue(n)})}})}var Jc;function Eo(e){return e.reduce((t,n)=>t+n.length,0)}function ko(e,t){if(e[0].length===t)return e.shift();let n=new Uint8Array(t),r=0;for(let i=0;i<t;i++)n[i]=e[0][r++],r===e[0].length&&(e.shift(),r=0);return e.length&&r<e[0].length&&(e[0]=e[0].slice(r)),n}function X1(e,t){Jc||(Jc=new TextDecoder);let n=[],r=0,i=-1,s=!1;return new TransformStream({transform(o,a){for(n.push(o);;){if(r===0){if(Eo(n)<1)break;let u=ko(n,1);s=(u[0]&128)===128,i=u[0]&127,i<126?r=3:i===126?r=1:r=2}else if(r===1){if(Eo(n)<2)break;let u=ko(n,2);i=new DataView(u.buffer,u.byteOffset,u.length).getUint16(0),r=3}else if(r===2){if(Eo(n)<8)break;let u=ko(n,8),c=new DataView(u.buffer,u.byteOffset,u.length),l=c.getUint32(0);if(l>Math.pow(2,21)-1){a.enqueue($i);break}i=l*Math.pow(2,32)+c.getUint32(4),r=3}else{if(Eo(n)<i)break;let u=ko(n,i);a.enqueue(Zi(s?u:Jc.decode(u),t)),r=0}if(i===0||i>e){a.enqueue($i);break}}}})}var Yc=4;function ye(e){if(e)return _j(e)}function _j(e){for(var t in ye.prototype)e[t]=ye.prototype[t];return e}ye.prototype.on=ye.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this};ye.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this};ye.prototype.off=ye.prototype.removeListener=ye.prototype.removeAllListeners=ye.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var n=this._callbacks["$"+e];if(!n)return this;if(arguments.length==1)return delete this._callbacks["$"+e],this;for(var r,i=0;i<n.length;i++)if(r=n[i],r===t||r.fn===t){n.splice(i,1);break}return n.length===0&&delete this._callbacks["$"+e],this};ye.prototype.emit=function(e){this._callbacks=this._callbacks||{};for(var t=new Array(arguments.length-1),n=this._callbacks["$"+e],r=1;r<arguments.length;r++)t[r-1]=arguments[r];if(n){n=n.slice(0);for(var r=0,i=n.length;r<i;++r)n[r].apply(this,t)}return this};ye.prototype.emitReserved=ye.prototype.emit;ye.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]};ye.prototype.hasListeners=function(e){return!!this.listeners(e).length};var Dt=typeof Promise=="function"&&typeof Promise.resolve=="function"?t=>Promise.resolve().then(t):(t,n)=>n(t,0),Ue=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),Q1="arraybuffer";function Ao(e,...t){return t.reduce((n,r)=>(e.hasOwnProperty(r)&&(n[r]=e[r]),n),{})}var wj=Ue.setTimeout,Oj=Ue.clearTimeout;function Rt(e,t){t.useNativeTimers?(e.setTimeoutFn=wj.bind(Ue),e.clearTimeoutFn=Oj.bind(Ue)):(e.setTimeoutFn=Ue.setTimeout.bind(Ue),e.clearTimeoutFn=Ue.clearTimeout.bind(Ue))}var Pj=1.33;function Z1(e){return typeof e=="string"?Ej(e):Math.ceil((e.byteLength||e.size)*Pj)}function Ej(e){let t=0,n=0;for(let r=0,i=e.length;r<i;r++)t=e.charCodeAt(r),t<128?n+=1:t<2048?n+=2:t<55296||t>=57344?n+=3:(r++,n+=4);return n}function xo(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function e_(e){let t="";for(let n in e)e.hasOwnProperty(n)&&(t.length&&(t+="&"),t+=encodeURIComponent(n)+"="+encodeURIComponent(e[n]));return t}function t_(e){let t={},n=e.split("&");for(let r=0,i=n.length;r<i;r++){let s=n[r].split("=");t[decodeURIComponent(s[0])]=decodeURIComponent(s[1])}return t}var So=class extends Error{constructor(t,n,r){super(t),this.description=n,this.context=r,this.type="TransportError"}},Bt=class extends ye{constructor(t){super(),this.writable=!1,Rt(this,t),this.opts=t,this.query=t.query,this.socket=t.socket,this.supportsBinary=!t.forceBase64}onError(t,n,r){return super.emitReserved("error",new So(t,n,r)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(t){this.readyState==="open"&&this.write(t)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(t){let n=Zi(t,this.socket.binaryType);this.onPacket(n)}onPacket(t){super.emitReserved("packet",t)}onClose(t){this.readyState="closed",super.emitReserved("close",t)}pause(t){}createUri(t,n={}){return t+"://"+this._hostname()+this._port()+this.opts.path+this._query(n)}_hostname(){let t=this.opts.hostname;return t.indexOf(":")===-1?t:"["+t+"]"}_port(){return this.opts.port&&(this.opts.secure&&Number(this.opts.port)!==443||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(t){let n=e_(t);return n.length?"?"+n:""}};var es=class extends Bt{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(t){this.readyState="pausing";let n=()=>{this.readyState="paused",t()};if(this._polling||!this.writable){let r=0;this._polling&&(r++,this.once("pollComplete",function(){--r||n()})),this.writable||(r++,this.once("drain",function(){--r||n()}))}else n()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(t){let n=r=>{if(this.readyState==="opening"&&r.type==="open"&&this.onOpen(),r.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(r)};Y1(t,this.socket.binaryType).forEach(n),this.readyState!=="closed"&&(this._polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this._poll())}doClose(){let t=()=>{this.write([{type:"close"}])};this.readyState==="open"?t():this.once("open",t)}write(t){this.writable=!1,J1(t,n=>{this.doWrite(n,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){let t=this.opts.secure?"https":"http",n=this.query||{};return this.opts.timestampRequests!==!1&&(n[this.opts.timestampParam]=xo()),!this.supportsBinary&&!n.sid&&(n.b64=1),this.createUri(t,n)}};var n_=!1;try{n_=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}var r_=n_;function kj(){}var $c=class extends es{constructor(t){if(super(t),typeof location<"u"){let n=location.protocol==="https:",r=location.port;r||(r=n?"443":"80"),this.xd=typeof location<"u"&&t.hostname!==location.hostname||r!==t.port}}doWrite(t,n){let r=this.request({method:"POST",data:t});r.on("success",n),r.on("error",(i,s)=>{this.onError("xhr post error",i,s)})}doPoll(){let t=this.request();t.on("data",this.onData.bind(this)),t.on("error",(n,r)=>{this.onError("xhr poll error",n,r)}),this.pollXhr=t}},$t=class e extends ye{constructor(t,n,r){super(),this.createRequest=t,Rt(this,r),this._opts=r,this._method=r.method||"GET",this._uri=n,this._data=r.data!==void 0?r.data:null,this._create()}_create(){var t;let n=Ao(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");n.xdomain=!!this._opts.xd;let r=this._xhr=this.createRequest(n);try{r.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){r.setDisableHeaderCheck&&r.setDisableHeaderCheck(!0);for(let i in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(i)&&r.setRequestHeader(i,this._opts.extraHeaders[i])}}catch{}if(this._method==="POST")try{r.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{r.setRequestHeader("Accept","*/*")}catch{}(t=this._opts.cookieJar)===null||t===void 0||t.addCookies(r),"withCredentials"in r&&(r.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(r.timeout=this._opts.requestTimeout),r.onreadystatechange=()=>{var i;r.readyState===3&&((i=this._opts.cookieJar)===null||i===void 0||i.parseCookies(r.getResponseHeader("set-cookie"))),r.readyState===4&&(r.status===200||r.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof r.status=="number"?r.status:0)},0))},r.send(this._data)}catch(i){this.setTimeoutFn(()=>{this._onError(i)},0);return}typeof document<"u"&&(this._index=e.requestsCount++,e.requests[this._index]=this)}_onError(t){this.emitReserved("error",t,this._xhr),this._cleanup(!0)}_cleanup(t){if(!(typeof this._xhr>"u"||this._xhr===null)){if(this._xhr.onreadystatechange=kj,t)try{this._xhr.abort()}catch{}typeof document<"u"&&delete e.requests[this._index],this._xhr=null}}_onLoad(){let t=this._xhr.responseText;t!==null&&(this.emitReserved("data",t),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}};$t.requestsCount=0;$t.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",i_);else if(typeof addEventListener=="function"){let e="onpagehide"in Ue?"pagehide":"unload";addEventListener(e,i_,!1)}}function i_(){for(let e in $t.requests)$t.requests.hasOwnProperty(e)&&$t.requests[e].abort()}var Aj=function(){let e=s_({xdomain:!1});return e&&e.responseType!==null}(),Xt=class extends $c{constructor(t){super(t);let n=t&&t.forceBase64;this.supportsBinary=Aj&&!n}request(t={}){return Object.assign(t,{xd:this.xd},this.opts),new $t(s_,this.uri(),t)}};function s_(e){let t=e.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!t||r_))return new XMLHttpRequest}catch{}if(!t)try{return new Ue[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}var o_=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative",Qc=class extends Bt{get name(){return"websocket"}doOpen(){let t=this.uri(),n=this.opts.protocols,r=o_?{}:Ao(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(r.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(t,n,r)}catch(i){return this.emitReserved("error",i)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=t=>this.onClose({description:"websocket connection closed",context:t}),this.ws.onmessage=t=>this.onData(t.data),this.ws.onerror=t=>this.onError("websocket error",t)}write(t){this.writable=!1;for(let n=0;n<t.length;n++){let r=t[n],i=n===t.length-1;Xi(r,this.supportsBinary,s=>{try{this.doWrite(r,s)}catch{}i&&Dt(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){let t=this.opts.secure?"wss":"ws",n=this.query||{};return this.opts.timestampRequests&&(n[this.opts.timestampParam]=xo()),this.supportsBinary||(n.b64=1),this.createUri(t,n)}},Xc=Ue.WebSocket||Ue.MozWebSocket,Qt=class extends Qc{createSocket(t,n,r){return o_?new Xc(t,n,r):n?new Xc(t,n):new Xc(t)}doWrite(t,n){this.ws.send(n)}};var sr=class extends Bt{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(t){return this.emitReserved("error",t)}this._transport.closed.then(()=>{this.onClose()}).catch(t=>{this.onError("webtransport error",t)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(t=>{let n=X1(Number.MAX_SAFE_INTEGER,this.socket.binaryType),r=t.readable.pipeThrough(n).getReader(),i=$1();i.readable.pipeTo(t.writable),this._writer=i.writable.getWriter();let s=()=>{r.read().then(({done:a,value:u})=>{a||(this.onPacket(u),s())}).catch(a=>{})};s();let o={type:"open"};this.query.sid&&(o.data=`{"sid":"${this.query.sid}"}`),this._writer.write(o).then(()=>this.onOpen())})})}write(t){this.writable=!1;for(let n=0;n<t.length;n++){let r=t[n],i=n===t.length-1;this._writer.write(r).then(()=>{i&&Dt(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var t;(t=this._transport)===null||t===void 0||t.close()}};var Zc={websocket:Qt,webtransport:sr,polling:Xt};var xj=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,Sj=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function or(e){if(e.length>8e3)throw"URI too long";let t=e,n=e.indexOf("["),r=e.indexOf("]");n!=-1&&r!=-1&&(e=e.substring(0,n)+e.substring(n,r).replace(/:/g,";")+e.substring(r,e.length));let i=xj.exec(e||""),s={},o=14;for(;o--;)s[Sj[o]]=i[o]||"";return n!=-1&&r!=-1&&(s.source=t,s.host=s.host.substring(1,s.host.length-1).replace(/;/g,":"),s.authority=s.authority.replace("[","").replace("]","").replace(/;/g,":"),s.ipv6uri=!0),s.pathNames=Tj(s,s.path),s.queryKey=Mj(s,s.query),s}function Tj(e,t){let n=/\/{2,9}/g,r=t.replace(n,"/").split("/");return(t.slice(0,1)=="/"||t.length===0)&&r.splice(0,1),t.slice(-1)=="/"&&r.splice(r.length-1,1),r}function Mj(e,t){let n={};return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(r,i,s){i&&(n[i]=s)}),n}var el=typeof addEventListener=="function"&&typeof removeEventListener=="function",To=[];el&&addEventListener("offline",()=>{To.forEach(e=>e())},!1);var Pn=class e extends ye{constructor(t,n){if(super(),this.binaryType=Q1,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,t&&typeof t=="object"&&(n=t,t=null),t){let r=or(t);n.hostname=r.host,n.secure=r.protocol==="https"||r.protocol==="wss",n.port=r.port,r.query&&(n.query=r.query)}else n.host&&(n.hostname=or(n.host).host);Rt(this,n),this.secure=n.secure!=null?n.secure:typeof location<"u"&&location.protocol==="https:",n.hostname&&!n.port&&(n.port=this.secure?"443":"80"),this.hostname=n.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=n.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},n.transports.forEach(r=>{let i=r.prototype.name;this.transports.push(i),this._transportsByName[i]=r}),this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},n),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=t_(this.opts.query)),el&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this._beforeunloadEventListener,!1)),this.hostname!=="localhost"&&(this._offlineEventListener=()=>{this._onClose("transport close",{description:"network connection lost"})},To.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(t){let n=Object.assign({},this.opts.query);n.EIO=Yc,n.transport=t,this.id&&(n.sid=this.id);let r=Object.assign({},this.opts,{query:n,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[t]);return new this._transportsByName[t](r)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}let t=this.opts.rememberUpgrade&&e.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports[0];this.readyState="opening";let n=this.createTransport(t);n.open(),this.setTransport(n)}setTransport(t){this.transport&&this.transport.removeAllListeners(),this.transport=t,t.on("drain",this._onDrain.bind(this)).on("packet",this._onPacket.bind(this)).on("error",this._onError.bind(this)).on("close",n=>this._onClose("transport close",n))}onOpen(){this.readyState="open",e.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush()}_onPacket(t){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",t),this.emitReserved("heartbeat"),t.type){case"open":this.onHandshake(JSON.parse(t.data));break;case"ping":this._sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this._resetPingTimeout();break;case"error":let n=new Error("server error");n.code=t.data,this._onError(n);break;case"message":this.emitReserved("data",t.data),this.emitReserved("message",t.data);break}}onHandshake(t){this.emitReserved("handshake",t),this.id=t.sid,this.transport.query.sid=t.sid,this._pingInterval=t.pingInterval,this._pingTimeout=t.pingTimeout,this._maxPayload=t.maxPayload,this.onOpen(),this.readyState!=="closed"&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);let t=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+t,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},t),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){let t=this._getWritablePackets();this.transport.send(t),this._prevBufferLen=t.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let n=1;for(let r=0;r<this.writeBuffer.length;r++){let i=this.writeBuffer[r].data;if(i&&(n+=Z1(i)),r>0&&n>this._maxPayload)return this.writeBuffer.slice(0,r);n+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;let t=Date.now()>this._pingTimeoutTime;return t&&(this._pingTimeoutTime=0,Dt(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),t}write(t,n,r){return this._sendPacket("message",t,n,r),this}send(t,n,r){return this._sendPacket("message",t,n,r),this}_sendPacket(t,n,r,i){if(typeof n=="function"&&(i=n,n=void 0),typeof r=="function"&&(i=r,r=null),this.readyState==="closing"||this.readyState==="closed")return;r=r||{},r.compress=r.compress!==!1;let s={type:t,data:n,options:r};this.emitReserved("packetCreate",s),this.writeBuffer.push(s),i&&this.once("flush",i),this.flush()}close(){let t=()=>{this._onClose("forced close"),this.transport.close()},n=()=>{this.off("upgrade",n),this.off("upgradeError",n),t()},r=()=>{this.once("upgrade",n),this.once("upgradeError",n)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?r():t()}):this.upgrading?r():t()),this}_onError(t){if(e.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState==="opening")return this.transports.shift(),this._open();this.emitReserved("error",t),this._onClose("transport error",t)}_onClose(t,n){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing"){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),el&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){let r=To.indexOf(this._offlineEventListener);r!==-1&&To.splice(r,1)}this.readyState="closed",this.id=null,this.emitReserved("close",t,n),this.writeBuffer=[],this._prevBufferLen=0}}};Pn.protocol=Yc;var Mo=class extends Pn{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState==="open"&&this.opts.upgrade)for(let t=0;t<this._upgrades.length;t++)this._probe(this._upgrades[t])}_probe(t){let n=this.createTransport(t),r=!1;Pn.priorWebsocketSuccess=!1;let i=()=>{r||(n.send([{type:"ping",data:"probe"}]),n.once("packet",f=>{if(!r)if(f.type==="pong"&&f.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",n),!n)return;Pn.priorWebsocketSuccess=n.name==="websocket",this.transport.pause(()=>{r||this.readyState!=="closed"&&(l(),this.setTransport(n),n.send([{type:"upgrade"}]),this.emitReserved("upgrade",n),n=null,this.upgrading=!1,this.flush())})}else{let p=new Error("probe error");p.transport=n.name,this.emitReserved("upgradeError",p)}}))};function s(){r||(r=!0,l(),n.close(),n=null)}let o=f=>{let p=new Error("probe error: "+f);p.transport=n.name,s(),this.emitReserved("upgradeError",p)};function a(){o("transport closed")}function u(){o("socket closed")}function c(f){n&&f.name!==n.name&&s()}let l=()=>{n.removeListener("open",i),n.removeListener("error",o),n.removeListener("close",a),this.off("close",u),this.off("upgrading",c)};n.once("open",i),n.once("error",o),n.once("close",a),this.once("close",u),this.once("upgrading",c),this._upgrades.indexOf("webtransport")!==-1&&t!=="webtransport"?this.setTimeoutFn(()=>{r||n.open()},200):n.open()}onHandshake(t){this._upgrades=this._filterUpgrades(t.upgrades),super.onHandshake(t)}_filterUpgrades(t){let n=[];for(let r=0;r<t.length;r++)~this.transports.indexOf(t[r])&&n.push(t[r]);return n}},ar=class extends Mo{constructor(t,n={}){let r=typeof t=="object"?t:n;(!r.transports||r.transports&&typeof r.transports[0]=="string")&&(r.transports=(r.transports||["polling","websocket","webtransport"]).map(i=>Zc[i]).filter(i=>!!i)),super(t,r)}};var QG=ar.protocol;function a_(e,t="",n){let r=e;n=n||typeof location<"u"&&location,e==null&&(e=n.protocol+"//"+n.host),typeof e=="string"&&(e.charAt(0)==="/"&&(e.charAt(1)==="/"?e=n.protocol+e:e=n.host+e),/^(https?|wss?):\/\//.test(e)||(typeof n<"u"?e=n.protocol+"//"+e:e="https://"+e),r=or(e)),r.port||(/^(http|ws)$/.test(r.protocol)?r.port="80":/^(http|ws)s$/.test(r.protocol)&&(r.port="443")),r.path=r.path||"/";let s=r.host.indexOf(":")!==-1?"["+r.host+"]":r.host;return r.id=r.protocol+"://"+s+":"+r.port+t,r.href=r.protocol+"://"+s+(n&&n.port===r.port?"":":"+r.port),r}var ol={};ll(ol,{Decoder:()=>il,Encoder:()=>rl,PacketType:()=>X,isPacketValid:()=>Gj,protocol:()=>p_});var Nj=typeof ArrayBuffer=="function",Cj=e=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer,u_=Object.prototype.toString,qj=typeof Blob=="function"||typeof Blob<"u"&&u_.call(Blob)==="[object BlobConstructor]",jj=typeof File=="function"||typeof File<"u"&&u_.call(File)==="[object FileConstructor]";function ns(e){return Nj&&(e instanceof ArrayBuffer||Cj(e))||qj&&e instanceof Blob||jj&&e instanceof File}function ts(e,t){if(!e||typeof e!="object")return!1;if(Array.isArray(e)){for(let n=0,r=e.length;n<r;n++)if(ts(e[n]))return!0;return!1}if(ns(e))return!0;if(e.toJSON&&typeof e.toJSON=="function"&&arguments.length===1)return ts(e.toJSON(),!0);for(let n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&ts(e[n]))return!0;return!1}function c_(e){let t=[],n=e.data,r=e;return r.data=tl(n,t),r.attachments=t.length,{packet:r,buffers:t}}function tl(e,t){if(!e)return e;if(ns(e)){let n={_placeholder:!0,num:t.length};return t.push(e),n}else if(Array.isArray(e)){let n=new Array(e.length);for(let r=0;r<e.length;r++)n[r]=tl(e[r],t);return n}else if(typeof e=="object"&&!(e instanceof Date)){let n={};for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=tl(e[r],t));return n}return e}function l_(e,t){return e.data=nl(e.data,t),delete e.attachments,e}function nl(e,t){if(!e)return e;if(e&&e._placeholder===!0){if(typeof e.num=="number"&&e.num>=0&&e.num<t.length)return t[e.num];throw new Error("illegal attachments")}else if(Array.isArray(e))for(let n=0;n<e.length;n++)e[n]=nl(e[n],t);else if(typeof e=="object")for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&(e[n]=nl(e[n],t));return e}var f_=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],p_=5,X;(function(e){e[e.CONNECT=0]="CONNECT",e[e.DISCONNECT=1]="DISCONNECT",e[e.EVENT=2]="EVENT",e[e.ACK=3]="ACK",e[e.CONNECT_ERROR=4]="CONNECT_ERROR",e[e.BINARY_EVENT=5]="BINARY_EVENT",e[e.BINARY_ACK=6]="BINARY_ACK"})(X||(X={}));var rl=class{constructor(t){this.replacer=t}encode(t){return(t.type===X.EVENT||t.type===X.ACK)&&ts(t)?this.encodeAsBinary({type:t.type===X.EVENT?X.BINARY_EVENT:X.BINARY_ACK,nsp:t.nsp,data:t.data,id:t.id}):[this.encodeAsString(t)]}encodeAsString(t){let n=""+t.type;return(t.type===X.BINARY_EVENT||t.type===X.BINARY_ACK)&&(n+=t.attachments+"-"),t.nsp&&t.nsp!=="/"&&(n+=t.nsp+","),t.id!=null&&(n+=t.id),t.data!=null&&(n+=JSON.stringify(t.data,this.replacer)),n}encodeAsBinary(t){let n=c_(t),r=this.encodeAsString(n.packet),i=n.buffers;return i.unshift(r),i}},il=class e extends ye{constructor(t){super(),this.reviver=t}add(t){let n;if(typeof t=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");n=this.decodeString(t);let r=n.type===X.BINARY_EVENT;r||n.type===X.BINARY_ACK?(n.type=r?X.EVENT:X.ACK,this.reconstructor=new sl(n),n.attachments===0&&super.emitReserved("decoded",n)):super.emitReserved("decoded",n)}else if(ns(t)||t.base64)if(this.reconstructor)n=this.reconstructor.takeBinaryData(t),n&&(this.reconstructor=null,super.emitReserved("decoded",n));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+t)}decodeString(t){let n=0,r={type:Number(t.charAt(0))};if(X[r.type]===void 0)throw new Error("unknown packet type "+r.type);if(r.type===X.BINARY_EVENT||r.type===X.BINARY_ACK){let s=n+1;for(;t.charAt(++n)!=="-"&&n!=t.length;);let o=t.substring(s,n);if(o!=Number(o)||t.charAt(n)!=="-")throw new Error("Illegal attachments");r.attachments=Number(o)}if(t.charAt(n+1)==="/"){let s=n+1;for(;++n&&!(t.charAt(n)===","||n===t.length););r.nsp=t.substring(s,n)}else r.nsp="/";let i=t.charAt(n+1);if(i!==""&&Number(i)==i){let s=n+1;for(;++n;){let o=t.charAt(n);if(o==null||Number(o)!=o){--n;break}if(n===t.length)break}r.id=Number(t.substring(s,n+1))}if(t.charAt(++n)){let s=this.tryParse(t.substr(n));if(e.isPayloadValid(r.type,s))r.data=s;else throw new Error("invalid payload")}return r}tryParse(t){try{return JSON.parse(t,this.reviver)}catch{return!1}}static isPayloadValid(t,n){switch(t){case X.CONNECT:return Io(n);case X.DISCONNECT:return n===void 0;case X.CONNECT_ERROR:return typeof n=="string"||Io(n);case X.EVENT:case X.BINARY_EVENT:return Array.isArray(n)&&(typeof n[0]=="number"||typeof n[0]=="string"&&f_.indexOf(n[0])===-1);case X.ACK:case X.BINARY_ACK:return Array.isArray(n)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}},sl=class{constructor(t){this.packet=t,this.buffers=[],this.reconPack=t}takeBinaryData(t){if(this.buffers.push(t),this.buffers.length===this.reconPack.attachments){let n=l_(this.reconPack,this.buffers);return this.finishedReconstruction(),n}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}};function Dj(e){return typeof e=="string"}var Rj=Number.isInteger||function(e){return typeof e=="number"&&isFinite(e)&&Math.floor(e)===e};function Bj(e){return e===void 0||Rj(e)}function Io(e){return Object.prototype.toString.call(e)==="[object Object]"}function Lj(e,t){switch(e){case X.CONNECT:return t===void 0||Io(t);case X.DISCONNECT:return t===void 0;case X.EVENT:return Array.isArray(t)&&(typeof t[0]=="number"||typeof t[0]=="string"&&f_.indexOf(t[0])===-1);case X.ACK:return Array.isArray(t);case X.CONNECT_ERROR:return typeof t=="string"||Io(t);default:return!1}}function Gj(e){return Dj(e.nsp)&&Bj(e.id)&&Lj(e.type,e.data)}function Qe(e,t,n){return e.on(t,n),function(){e.off(t,n)}}var Fj=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1}),ur=class extends ye{constructor(t,n,r){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=t,this.nsp=n,r&&r.auth&&(this.auth=r.auth),this._opts=Object.assign({},r),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;let t=this.io;this.subs=[Qe(t,"open",this.onopen.bind(this)),Qe(t,"packet",this.onpacket.bind(this)),Qe(t,"error",this.onerror.bind(this)),Qe(t,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen(),this)}open(){return this.connect()}send(...t){return t.unshift("message"),this.emit.apply(this,t),this}emit(t,...n){var r,i,s;if(Fj.hasOwnProperty(t))throw new Error('"'+t.toString()+'" is a reserved event name');if(n.unshift(t),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(n),this;let o={type:X.EVENT,data:n};if(o.options={},o.options.compress=this.flags.compress!==!1,typeof n[n.length-1]=="function"){let l=this.ids++,f=n.pop();this._registerAckCallback(l,f),o.id=l}let a=(i=(r=this.io.engine)===null||r===void 0?void 0:r.transport)===null||i===void 0?void 0:i.writable,u=this.connected&&!(!((s=this.io.engine)===null||s===void 0)&&s._hasPingExpired());return this.flags.volatile&&!a||(u?(this.notifyOutgoingListeners(o),this.packet(o)):this.sendBuffer.push(o)),this.flags={},this}_registerAckCallback(t,n){var r;let i=(r=this.flags.timeout)!==null&&r!==void 0?r:this._opts.ackTimeout;if(i===void 0){this.acks[t]=n;return}let s=this.io.setTimeoutFn(()=>{delete this.acks[t];for(let a=0;a<this.sendBuffer.length;a++)this.sendBuffer[a].id===t&&this.sendBuffer.splice(a,1);n.call(this,new Error("operation has timed out"))},i),o=(...a)=>{this.io.clearTimeoutFn(s),n.apply(this,a)};o.withError=!0,this.acks[t]=o}emitWithAck(t,...n){return new Promise((r,i)=>{let s=(o,a)=>o?i(o):r(a);s.withError=!0,n.push(s),this.emit(t,...n)})}_addToQueue(t){let n;typeof t[t.length-1]=="function"&&(n=t.pop());let r={id:this._queueSeq++,tryCount:0,pending:!1,args:t,flags:Object.assign({fromQueue:!0},this.flags)};t.push((i,...s)=>(this._queue[0],i!==null?r.tryCount>this._opts.retries&&(this._queue.shift(),n&&n(i)):(this._queue.shift(),n&&n(null,...s)),r.pending=!1,this._drainQueue())),this._queue.push(r),this._drainQueue()}_drainQueue(t=!1){if(!this.connected||this._queue.length===0)return;let n=this._queue[0];n.pending&&!t||(n.pending=!0,n.tryCount++,this.flags=n.flags,this.emit.apply(this,n.args))}packet(t){t.nsp=this.nsp,this.io._packet(t)}onopen(){typeof this.auth=="function"?this.auth(t=>{this._sendConnectPacket(t)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(t){this.packet({type:X.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},t):t})}onerror(t){this.connected||this.emitReserved("connect_error",t)}onclose(t,n){this.connected=!1,delete this.id,this.emitReserved("disconnect",t,n),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(t=>{if(!this.sendBuffer.some(r=>String(r.id)===t)){let r=this.acks[t];delete this.acks[t],r.withError&&r.call(this,new Error("socket has been disconnected"))}})}onpacket(t){if(t.nsp===this.nsp)switch(t.type){case X.CONNECT:t.data&&t.data.sid?this.onconnect(t.data.sid,t.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case X.EVENT:case X.BINARY_EVENT:this.onevent(t);break;case X.ACK:case X.BINARY_ACK:this.onack(t);break;case X.DISCONNECT:this.ondisconnect();break;case X.CONNECT_ERROR:this.destroy();let r=new Error(t.data.message);r.data=t.data.data,this.emitReserved("connect_error",r);break}}onevent(t){let n=t.data||[];t.id!=null&&n.push(this.ack(t.id)),this.connected?this.emitEvent(n):this.receiveBuffer.push(Object.freeze(n))}emitEvent(t){if(this._anyListeners&&this._anyListeners.length){let n=this._anyListeners.slice();for(let r of n)r.apply(this,t)}super.emit.apply(this,t),this._pid&&t.length&&typeof t[t.length-1]=="string"&&(this._lastOffset=t[t.length-1])}ack(t){let n=this,r=!1;return function(...i){r||(r=!0,n.packet({type:X.ACK,id:t,data:i}))}}onack(t){let n=this.acks[t.id];typeof n=="function"&&(delete this.acks[t.id],n.withError&&t.data.unshift(null),n.apply(this,t.data))}onconnect(t,n){this.id=t,this.recovered=n&&this._pid===n,this._pid=n,this.connected=!0,this.emitBuffered(),this._drainQueue(!0),this.emitReserved("connect")}emitBuffered(){this.receiveBuffer.forEach(t=>this.emitEvent(t)),this.receiveBuffer=[],this.sendBuffer.forEach(t=>{this.notifyOutgoingListeners(t),this.packet(t)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(t=>t()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:X.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(t){return this.flags.compress=t,this}get volatile(){return this.flags.volatile=!0,this}timeout(t){return this.flags.timeout=t,this}onAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(t),this}prependAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(t),this}offAny(t){if(!this._anyListeners)return this;if(t){let n=this._anyListeners;for(let r=0;r<n.length;r++)if(t===n[r])return n.splice(r,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(t){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(t),this}prependAnyOutgoing(t){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(t),this}offAnyOutgoing(t){if(!this._anyOutgoingListeners)return this;if(t){let n=this._anyOutgoingListeners;for(let r=0;r<n.length;r++)if(t===n[r])return n.splice(r,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(t){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){let n=this._anyOutgoingListeners.slice();for(let r of n)r.apply(this,t.data)}}};function En(e){e=e||{},this.ms=e.min||100,this.max=e.max||1e4,this.factor=e.factor||2,this.jitter=e.jitter>0&&e.jitter<=1?e.jitter:0,this.attempts=0}En.prototype.duration=function(){var e=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var t=Math.random(),n=Math.floor(t*this.jitter*e);e=Math.floor(t*10)&1?e+n:e-n}return Math.min(e,this.max)|0};En.prototype.reset=function(){this.attempts=0};En.prototype.setMin=function(e){this.ms=e};En.prototype.setMax=function(e){this.max=e};En.prototype.setJitter=function(e){this.jitter=e};var cr=class extends ye{constructor(t,n){var r;super(),this.nsps={},this.subs=[],t&&typeof t=="object"&&(n=t,t=void 0),n=n||{},n.path=n.path||"/socket.io",this.opts=n,Rt(this,n),this.reconnection(n.reconnection!==!1),this.reconnectionAttempts(n.reconnectionAttempts||1/0),this.reconnectionDelay(n.reconnectionDelay||1e3),this.reconnectionDelayMax(n.reconnectionDelayMax||5e3),this.randomizationFactor((r=n.randomizationFactor)!==null&&r!==void 0?r:.5),this.backoff=new En({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(n.timeout==null?2e4:n.timeout),this._readyState="closed",this.uri=t;let i=n.parser||ol;this.encoder=new i.Encoder,this.decoder=new i.Decoder,this._autoConnect=n.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(t){return arguments.length?(this._reconnection=!!t,t||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(t){return t===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=t,this)}reconnectionDelay(t){var n;return t===void 0?this._reconnectionDelay:(this._reconnectionDelay=t,(n=this.backoff)===null||n===void 0||n.setMin(t),this)}randomizationFactor(t){var n;return t===void 0?this._randomizationFactor:(this._randomizationFactor=t,(n=this.backoff)===null||n===void 0||n.setJitter(t),this)}reconnectionDelayMax(t){var n;return t===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=t,(n=this.backoff)===null||n===void 0||n.setMax(t),this)}timeout(t){return arguments.length?(this._timeout=t,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(t){if(~this._readyState.indexOf("open"))return this;this.engine=new ar(this.uri,this.opts);let n=this.engine,r=this;this._readyState="opening",this.skipReconnect=!1;let i=Qe(n,"open",function(){r.onopen(),t&&t()}),s=a=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",a),t?t(a):this.maybeReconnectOnOpen()},o=Qe(n,"error",s);if(this._timeout!==!1){let a=this._timeout,u=this.setTimeoutFn(()=>{i(),s(new Error("timeout")),n.close()},a);this.opts.autoUnref&&u.unref(),this.subs.push(()=>{this.clearTimeoutFn(u)})}return this.subs.push(i),this.subs.push(o),this}connect(t){return this.open(t)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");let t=this.engine;this.subs.push(Qe(t,"ping",this.onping.bind(this)),Qe(t,"data",this.ondata.bind(this)),Qe(t,"error",this.onerror.bind(this)),Qe(t,"close",this.onclose.bind(this)),Qe(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(t){try{this.decoder.add(t)}catch(n){this.onclose("parse error",n)}}ondecoded(t){Dt(()=>{this.emitReserved("packet",t)},this.setTimeoutFn)}onerror(t){this.emitReserved("error",t)}socket(t,n){let r=this.nsps[t];return r?this._autoConnect&&!r.active&&r.connect():(r=new ur(this,t,n),this.nsps[t]=r),r}_destroy(t){let n=Object.keys(this.nsps);for(let r of n)if(this.nsps[r].active)return;this._close()}_packet(t){let n=this.encoder.encode(t);for(let r=0;r<n.length;r++)this.engine.write(n[r],t.options)}cleanup(){this.subs.forEach(t=>t()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(t,n){var r;this.cleanup(),(r=this.engine)===null||r===void 0||r.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",t,n),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;let t=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{let n=this.backoff.duration();this._reconnecting=!0;let r=this.setTimeoutFn(()=>{t.skipReconnect||(this.emitReserved("reconnect_attempt",t.backoff.attempts),!t.skipReconnect&&t.open(i=>{i?(t._reconnecting=!1,t.reconnect(),this.emitReserved("reconnect_error",i)):t.onreconnect()}))},n);this.opts.autoUnref&&r.unref(),this.subs.push(()=>{this.clearTimeoutFn(r)})}}onreconnect(){let t=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",t)}};var rs={};function is(e,t){typeof e=="object"&&(t=e,e=void 0),t=t||{};let n=a_(e,t.path||"/socket.io"),r=n.source,i=n.id,s=n.path,o=rs[i]&&s in rs[i].nsps,a=t.forceNew||t["force new connection"]||t.multiplex===!1||o,u;return a?u=new cr(r,t):(rs[i]||(rs[i]=new cr(r,t)),u=rs[i]),n.query&&!t.query&&(t.query=n.queryKey),u.socket(n.path,t)}Object.assign(is,{Manager:cr,Socket:ur,io:is,connect:is});var h_=is,al=class extends ir{constructor({socket:t,socketOpts:n,server:r,...i}){super(i),this.server=r,this.socket=t,this.socketOpts=n}sendAction(t,n){let r=[n,t._stateID,this.matchID,this.playerID];this.socket.emit("update",...r)}sendChatMessage(t,n){let r=[t,n,this.credentials];this.socket.emit("chat",...r)}connect(){if(!this.socket)if(this.server){let t=this.server;t.search(/^https?:\/\//)==-1&&(t="http://"+this.server),t.slice(-1)!="/"&&(t=t+"/"),this.socket=h_(t+this.gameName,this.socketOpts)}else this.socket=h_("/"+this.gameName,this.socketOpts);this.socket.on("patch",(t,n,r,i,s)=>{this.notifyClient({type:"patch",args:[t,n,r,i,s]})}),this.socket.on("update",(t,n,r)=>{this.notifyClient({type:"update",args:[t,n,r]})}),this.socket.on("sync",(t,n)=>{this.notifyClient({type:"sync",args:[t,n]})}),this.socket.on("matchData",(t,n)=>{this.notifyClient({type:"matchData",args:[t,n]})}),this.socket.on("chat",(t,n)=>{this.notifyClient({type:"chat",args:[t,n]})}),this.socket.on("connect",()=>{this.requestSync(),this.setConnectionStatus(!0)}),this.socket.on("disconnect",()=>{this.setConnectionStatus(!1)})}disconnect(){this.socket.close(),this.socket=null,this.setConnectionStatus(!1)}requestSync(){if(this.socket){let t=[this.matchID,this.playerID,this.credentials,this.numPlayers];this.socket.emit("sync",...t)}}updateMatchID(t){this.matchID=t,this.requestSync()}updatePlayerID(t){this.playerID=t,this.requestSync()}updateCredentials(t){this.credentials=t,this.requestSync()}};function ul({server:e,socketOpts:t}={}){return n=>new al({server:e,socketOpts:t,...n})}var G9=he(tn()),F9=he(qi());function No(e){if(e?.arguments){let t={...e};return t.arguments=Object.entries(t.arguments).reduce((n,[r,i])=>({...n,[r]:i.abstract?i:i.entityId}),{}),JSON.parse(He(t,{deduplicateInstances:!1}))}else return e}var Vj={PlaceNew:["destination"],RemoveEntity:["entity"],MoveEntity:["entity","destination"],TakeFrom:["source","destination"],SetState:["entity","state"]};function lr(e,t){return Vj[t.moveType].filter(n=>t.arguments[n].playerChoice).map(n=>({argName:n,getClickable:n==="state"?()=>t.arguments[n].possibleValues.map(r=>({abstract:!0,...t.arguments[n],value:r})):r=>e.G.bank.findAll(e,t.arguments[n],r)}))}function Co(e,t,n,r){let i=lr(e,t,r).map(s=>s.argName);return{arguments:n.reduce((s,o,a)=>({...s,[i[a]]:o}),{})}}var qo=class{constructor(t){this.options=t,this.game=t.boardgameIOGame||gi(JSON.parse(t.gameRules),t.gameName),t.boardgameIOGame||(this.moveBuilder={targets:[],stepIndex:0,eliminatedMoves:[]},this.optimisticWinner=null)}connect(){let{server:t,numPlayers:n,debug:r={collapseOnLoad:!0,impl:Ki},matchID:i,playerID:s,credentials:o,multiplayer:a=ul({server:t,socketOpts:{transports:["websocket","polling"]}})}=this.options;try{let u=o?{game:this.game,multiplayer:a,matchID:i,playerID:s,credentials:o,numPlayers:n,debug:r}:{game:this.game,numPlayers:n,debug:r};return this.client=Hc(u),this.client.subscribe(()=>this.update()),this.client.start(),this}catch(u){console.error("Failed to join game:",u?.message??u),u?.stack&&console.error(u.stack)}}update(){this.options.onClientUpdate?.()}getState(){let t=this.client?.getState();if(!t)return{};let n=this.options.boardgameIOGame?t:{...t,G:Ft(JSON.stringify(t.G),ht)},r=this.optimisticWinner??n?.ctx?.gameover,i=r?[]:ti(n,this.client);if(this.options.boardgameIOGame)return{state:n,gameover:r,moves:this.client.moves,currentMoves:i};let s=Object.entries(i).reduce((u,[c,l])=>{let f=p=>{this.client.moves[c](No(p))};return f.moveInstance=l.moveInstance,{...u,[c]:f}},{}),{allClickable:o,_possibleMoveMeta:a}=Kj(n,s,this.moveBuilder);return{state:n,gameover:r,allClickable:o,_wrappedMoves:s,_possibleMoveMeta:a}}doStep(t){if(this.options.boardgameIOGame)return;let{state:n,_wrappedMoves:r,_possibleMoveMeta:i}=this.getState(),s=t.abstract?t:n.G.bank.locate(t.entityId),o=Object.entries(i).filter(([u,c])=>!zj(c.clickableForMove,s)).map(([u])=>u).concat(this.moveBuilder.eliminatedMoves);if(o.length===Object.keys(r).length){console.error("invalid move with target:",s?.rule);return}let a=Object.entries(i).filter(([u])=>!o.includes(u));if(Hj(n,r,a,this.moveBuilder.stepIndex)){let[u]=a[0],c=r[u],l=Co(n,c.moveInstance.rule,[...this.moveBuilder.targets,s],{moveInstance:c.moveInstance});this.optimisticWinner=Wj(n,this.game,c.moveInstance,l),c(l),this.moveBuilder={targets:[],stepIndex:0,eliminatedMoves:[]}}else this.moveBuilder={eliminatedMoves:o,stepIndex:this.moveBuilder.stepIndex+1,targets:[...this.moveBuilder.targets,s]};this.update()}reset(){this.options.boardgameIOGame||(this.moveBuilder={targets:[],stepIndex:0,eliminatedMoves:[]},this.optimisticWinner=null,this.update())}undoStep(){this.options.boardgameIOGame||(this.moveBuilder.targets.length&&(this.moveBuilder={targets:this.moveBuilder.targets.slice(0,-1),stepIndex:Math.max(0,this.moveBuilder.stepIndex-1),eliminatedMoves:[]}),this.update())}};function zj(e,t){return t.abstract?[...e].some(n=>n.abstract&&n.value===t.value):e.has(t)}function Kj(e,t,n){let{eliminatedMoves:r,stepIndex:i}=n,s={},o=new Set;return Object.entries(t).filter(([a])=>!r.includes(a)).forEach(([a,u])=>{let c=pe(e,{...u.moveInstance.rule,moveName:a}),l={moveInstance:u.moveInstance,moveArguments:c.arguments},f=n.targets.map(m=>m.abstract?m:e.G.bank.locate(m.entityId)),p=Co(e,c,f,l);l.moveArguments={...l.moveArguments,...p.arguments};let h=ke(e,c,{},l).conditionsAreMet,d=lr(e,c),y=new Set(h&&d?.[i]?.getClickable(l)||[]);s[a]={clickableForMove:y},y.forEach(m=>o.add(m))}),{_possibleMoveMeta:s,allClickable:o}}function Hj(e,t,n,r){return n.length===1&&lr(e,t[n[0][0]].moveInstance.rule).length===r+1}function Wj(e,t,n,r){let i=Zr(e,No(r),{moveInstance:n});return t.endIf?.({...e,G:JSON.parse(He(i))})}return w_(Jj);})();
33
33
  /*! Bundled license information:
34
34
 
35
35
  expr-eval/dist/index.mjs:
@@ -27062,7 +27062,7 @@ function createPayload(bgioState, moveRule, targets, context) {
27062
27062
  var Client2 = class {
27063
27063
  constructor(options) {
27064
27064
  this.options = options;
27065
- this.game = options.boardgameIOGame || gameFactory(JSON.parse(options.gameRules));
27065
+ this.game = options.boardgameIOGame || gameFactory(JSON.parse(options.gameRules), options.gameName);
27066
27066
  if (!options.boardgameIOGame) {
27067
27067
  this.moveBuilder = { targets: [], stepIndex: 0, eliminatedMoves: [] };
27068
27068
  this.optimisticWinner = null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "board-game-engine",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "wip board game engine",
5
5
  "main": "dist/board-game-engine.cjs",
6
6
  "module": "dist/board-game-engine.mjs",
@@ -16,7 +16,7 @@ export class Client {
16
16
  constructor (options) {
17
17
  this.options = options
18
18
  this.game = options.boardgameIOGame
19
- || gameFactory(JSON.parse(options.gameRules))
19
+ || gameFactory(JSON.parse(options.gameRules), options.gameName)
20
20
 
21
21
  if (!options.boardgameIOGame) {
22
22
  this.moveBuilder = { targets: [], stepIndex: 0, eliminatedMoves: [] }