@lichess-org/chessground 9.8.5 → 9.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/chessground.min.js +1 -1
- package/dist/config.d.ts +0 -1
- package/dist/config.js.map +1 -1
- package/dist/premove.js +12 -139
- package/dist/premove.js.map +1 -1
- package/dist/render.js +22 -25
- package/dist/render.js.map +1 -1
- package/dist/state.d.ts +0 -1
- package/dist/state.js.map +1 -1
- package/dist/types.d.ts +0 -2
- package/package.json +1 -1
- package/src/config.ts +0 -1
- package/src/premove.ts +13 -185
- package/src/render.ts +23 -28
- package/src/state.ts +1 -2
- package/src/types.ts +0 -2
package/README.md
CHANGED
|
@@ -76,7 +76,7 @@ const ground = Chessground(document.body, config);
|
|
|
76
76
|
- React: [react-chess/chessground](https://github.com/react-chess/chessground), [ruilisi/react-chessground](https://github.com/ruilisi/react-chessground)
|
|
77
77
|
- Vue.js: [vitogit/vue-chessboard](https://github.com/vitogit/vue-chessboard), [qwerty084/vue3-chessboard](https://github.com/qwerty084/vue3-chessboard)
|
|
78
78
|
- Angular: [topce/ngx-chessground](https://github.com/topce/ngx-chessground)
|
|
79
|
-
- Svelte: [
|
|
79
|
+
- Svelte: [Janldeboer/svelte5-chessground](https://github.com/Janldeboer/svelte5-chessground), [agelas/svelte-chessground-ui (Svelte 4)](https://github.com/agelas/svelte-chessground-ui), [gtim/svelte-chessground (Svelte3)](https://github.com/gtim/svelte-chessground),
|
|
80
80
|
|
|
81
81
|
More? Please make a pull request to include it here.
|
|
82
82
|
|
package/dist/chessground.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var eo=["white","black"];var z=["a","b","c","d","e","f","g","h"],j=["1","2","3","4","5","6","7","8"];var no=[...j].reverse(),Q=z.flatMap(e=>j.map(o=>e+o)),M=e=>e.every(o=>o>=0&&o<=7)?Q[8*e[0]+e[1]]:void 0,F=e=>M(e),f=e=>[e.charCodeAt(0)-97,e.charCodeAt(1)-49];var De=Q.map(f),ro=Q.map((e,o)=>({key:e,pos:De[o]}));function Ke(e){let o,n=()=>(o===void 0&&(o=e()),o);return n.clear=()=>{o=void 0},n}var to=()=>{let e;return{start(){e=performance.now()},cancel(){e=void 0},stop(){if(!e)return 0;let o=performance.now()-e;return e=void 0,o}}},U=e=>e==="white"?"black":"white",G=(e,o)=>(e[0]-o[0])**2+(e[1]-o[1])**2,$=(e,o)=>e.role===o.role&&e.color===o.color,io=(e,o)=>e[0]===o[0]&&e[1]===o[1],W=e=>(o,n)=>[(n?o[0]:7-o[0])*e.width/8,(n?7-o[1]:o[1])*e.height/8],k=(e,o)=>{e.style.transform=`translate(${o[0]}px,${o[1]}px)`},xe=(e,o,n=1)=>{e.style.transform=`translate(${o[0]}px,${o[1]}px) scale(${n})`},Y=(e,o)=>{e.style.visibility=o?"visible":"hidden"},B=e=>{if(e.clientX||e.clientX===0)return[e.clientX,e.clientY];if(e.targetTouches?.[0])return[e.targetTouches[0].clientX,e.targetTouches[0].clientY]},ln=Ke(()=>!("ontouchstart"in window)&&["macintosh","firefox"].every(e=>navigator.userAgent.toLowerCase().includes(e))),le=e=>e.button===2&&!(e.ctrlKey&&ln()),C=(e,o)=>{let n=document.createElement(e);return o&&(n.className=o),n};function de(e,o,n){let r=f(e);return o||(r[0]=7-r[0],r[1]=7-r[1]),[n.left+n.width*r[0]/8+n.width/16,n.top+n.height*(7-r[1])/8+n.height/16]}var x=(e,o)=>Math.abs(e-o),J=(e,o,n,r)=>x(e,n)*x(o,r)===2,ue=(e,o,n,r)=>e===n!=(o===r),pe=(e,o,n,r)=>x(e,n)===x(o,r)&&e!==n,fe=(e,o,n,r)=>ue(e,o,n,r)||pe(e,o,n,r),Ee=(e,o,n,r)=>Math.max(x(e,n),x(o,r))===1,Ae=(e,o,n,r,t)=>x(e,n)===1&&r===o+(t?1:-1),Ne=(e,o,n,r,t)=>{let i=t?1:-1;return e===n&&(r===o+i||r===o+2*i&&(t?o<=1:o>=6))},ee=(e,o,n,r)=>{let t=n-e,i=r-o;if(t&&i&&Math.abs(t)!==Math.abs(i))return[];let a=Math.sign(t),u=Math.sign(i),d=[],s=e+a,c=o+u;for(;s!==n||c!==r;)d.push([s,c]),s+=a,c+=u;return d.map(M).filter(l=>l!==void 0)},ao=e=>{let o=f(e),n=[];return o[0]>0&&n.push([o[0]-1,o[1]]),o[0]<7&&n.push([o[0]+1,o[1]]),n.map(M).filter(r=>r!==void 0)},oe=(e,o)=>{let n=f(e);return n[1]+=o,M(n)};var Z=e=>e.friendlies.has(e.dest.key),dn=e=>e.enemies.has(e.dest.key),so=(e,o,n)=>ee(...e,...o).some(r=>n.has(r)),co=(e,o,n)=>{let r=n.enemies.get(e);if(r?.role!=="pawn")return!1;let t=r.color==="white"?1:-1,i=f(e),a=f(o);return Ne(...i,...a,r.color==="white")&&!so(i,[a[0],a[1]+t],n.allPieces)},un=(e,o,n)=>{let r=n.enemies.get(e);return r?.role==="pawn"&&Ae(...f(e),...f(o),r.color==="white")&&(n.friendlies.has(o)||me(oe(o,r.color==="white"?-1:1),n.friendlies,n.enemies,n.lastMove))},pn=e=>[...e.enemies.keys()].some(o=>co(o,e.dest.key,e)),He=(e,o)=>{let n=e.dest.pos;return[...e.enemies].some(([r,t])=>{let i=f(r);return!o?.includes(t.role)&&(t.role==="pawn"&&Ae(...i,...n,t.color==="white")||t.role==="knight"&&J(...i,...n)||t.role==="bishop"&&pe(...i,...n)||t.role==="rook"&&ue(...i,...n)||t.role==="queen"&&fe(...i,...n)||t.role==="king"&&Ee(...i,...n))&&(!["bishop","rook","queen"].includes(t.role)||!so(i,n,e.allPieces))})},ge=e=>Z(e)&&(me(e.dest.key,e.friendlies,e.enemies,e.lastMove)||He(e)),me=(e,o,n,r)=>{if(!e||r&&e!==r[1])return!1;let t=f(e),i=o.get(e);return i?.role==="pawn"&&t[1]===(i.color==="white"?3:4)&&(!r||x(f(r[0])[1],t[1])===2)&&[1,-1].some(a=>{let u=M([t[0]+a,t[1]]);return!!u&&n.get(u)?.role==="pawn"})},fn=(e,o)=>{if(e.unrestrictedPremoves)return!0;let n=ee(...e.orig.pos,...e.dest.pos);o&&n.push(e.dest.key);let r=n.filter(a=>e.friendlies.has(a));if(!r.length)return!0;let t=r[0],i=oe(t,e.color==="white"?-1:1);return r.length===1&&me(t,e.friendlies,e.enemies,e.lastMove)&&!!i&&!n.includes(i)},gn=(e,o)=>{if(e.unrestrictedPremoves)return!0;let n=ee(...e.orig.pos,...e.dest.pos);o&&n.push(e.dest.key);let r=n.filter(c=>e.enemies.has(c));if(r.length>1)return!1;if(!r.length)return!0;let t=r[0],i=e.enemies.get(t);if(!i||i.role!=="pawn")return!0;let a=i.color==="white"?1:-1,u=oe(t,a),d=u?[...ao(u).filter(c=>un(t,c,e)),...[u,oe(u,a)].filter(c=>!!c).filter(c=>co(t,c,e))]:[],s=[...n,e.orig.key];return d.some(c=>!s.includes(c))},qe=(e,o)=>fn(e,o)&&gn(e,o),mn=e=>{let o=e.color==="white"?1:-1;return x(e.orig.pos[0],e.dest.pos[0])>1?!1:x(e.orig.pos[0],e.dest.pos[0])?e.dest.pos[1]!==e.orig.pos[1]+o?!1:e.unrestrictedPremoves||dn(e)?!0:Z(e)?He(e):pn(e)||me(M([e.dest.pos[0],e.dest.pos[1]+o]),e.friendlies,e.enemies,e.lastMove)||He(e,["pawn"]):Ne(...e.orig.pos,...e.dest.pos,e.color==="white")&&qe(e,!0)},bn=e=>J(...e.orig.pos,...e.dest.pos)&&(e.unrestrictedPremoves||!Z(e)||ge(e)),lo=e=>pe(...e.orig.pos,...e.dest.pos)&&qe(e,!1)&&(e.unrestrictedPremoves||!Z(e)||ge(e)),uo=e=>ue(...e.orig.pos,...e.dest.pos)&&qe(e,!1)&&(e.unrestrictedPremoves||!Z(e)||ge(e)),hn=e=>lo(e)||uo(e),vn=e=>Ee(...e.orig.pos,...e.dest.pos)&&(e.unrestrictedPremoves||!Z(e)||ge(e))||e.canCastle&&e.orig.pos[1]===e.dest.pos[1]&&e.orig.pos[1]===(e.color==="white"?0:7)&&(e.orig.pos[0]===4&&(e.dest.pos[0]===2&&e.rookFilesFriendlies.includes(0)||e.dest.pos[0]===6&&e.rookFilesFriendlies.includes(7))||e.rookFilesFriendlies.includes(e.dest.pos[0]))&&(e.unrestrictedPremoves||ee(...e.orig.pos,e.dest.pos[0]>e.orig.pos[0]?7:1,e.dest.pos[1]).map(o=>e.allPieces.get(o)).every(o=>!o||$(o,{role:"rook",color:e.color}))),yn={pawn:mn,knight:bn,bishop:lo,rook:uo,queen:hn,king:vn};function Te(e,o){let n=e.pieces,r=e.premovable.castle,t=!!e.premovable.unrestrictedPremoves,i=n.get(o);if(!i||i.color===e.turnColor)return[];let a=i.color,u=new Map([...n].filter(([p,m])=>m.color===a)),d=new Map([...n].filter(([p,m])=>m.color===U(a))),s={key:o,pos:f(o)},c=p=>yn[i.role](p)&&e.premovable.additionalPremoveRequirements(p),l={orig:s,role:i.role,allPieces:n,friendlies:u,enemies:d,unrestrictedPremoves:t,color:a,canCastle:r,rookFilesFriendlies:Array.from(n).filter(([p,m])=>p[1]===(a==="white"?"1":"8")&&m.color===a&&m.role==="rook").map(([p])=>f(p)[0]),lastMove:e.lastMove};return ro.filter(p=>c({...l,dest:p})).map(p=>p.key)}function S(e,...o){e&&setTimeout(()=>e(...o),1)}function po(e){e.orientation=U(e.orientation),e.animation.current=e.draggable.current=e.selected=void 0}function fo(e,o){for(let[n,r]of o)r?e.pieces.set(n,r):e.pieces.delete(n)}function go(e,o){if(e.check=void 0,o===!0&&(o=e.turnColor),o)for(let[n,r]of e.pieces)r.role==="king"&&r.color===o&&(e.check=n)}function wn(e,o,n,r){A(e),e.premovable.current=[o,n],S(e.premovable.events.set,o,n,r)}function E(e){e.premovable.current&&(e.premovable.current=void 0,S(e.premovable.events.unset))}function Pn(e,o,n){E(e),e.predroppable.current={role:o,key:n},S(e.predroppable.events.set,o,n)}function A(e){let o=e.predroppable;o.current&&(o.current=void 0,S(o.events.unset))}function Sn(e,o,n){if(!e.autoCastle)return!1;let r=e.pieces.get(o);if(!r||r.role!=="king")return!1;let t=f(o),i=f(n);if(t[1]!==0&&t[1]!==7||t[1]!==i[1])return!1;t[0]===4&&!e.pieces.has(n)&&(i[0]===6?n=F([7,i[1]]):i[0]===2&&(n=F([0,i[1]])));let a=e.pieces.get(n);return!a||a.color!==r.color||a.role!=="rook"?!1:(e.pieces.delete(o),e.pieces.delete(n),t[0]<i[0]?(e.pieces.set(F([6,i[1]]),r),e.pieces.set(F([5,i[1]]),a)):(e.pieces.set(F([2,i[1]]),r),e.pieces.set(F([3,i[1]]),a)),!0)}function Be(e,o,n){let r=e.pieces.get(o),t=e.pieces.get(n);if(o===n||!r)return!1;let i=t&&t.color!==r.color?t:void 0;return n===e.selected&&P(e),S(e.events.move,o,n,i),Sn(e,o,n)||(e.pieces.set(n,r),e.pieces.delete(o)),e.lastMove=[o,n],e.check=void 0,S(e.events.change),i||!0}function be(e,o,n,r){if(e.pieces.has(n))if(r)e.pieces.delete(n);else return!1;return S(e.events.dropNewPiece,o,n),e.pieces.set(n,o),e.lastMove=[n],e.check=void 0,S(e.events.change),e.movable.dests=void 0,e.turnColor=U(e.turnColor),!0}function mo(e,o,n){let r=Be(e,o,n);return r&&(e.movable.dests=void 0,e.turnColor=U(e.turnColor),e.animation.current=void 0),r}function Re(e,o,n){if(ve(e,o,n)){let r=mo(e,o,n);if(r){let t=e.hold.stop();P(e);let i={premove:!1,ctrlKey:e.stats.ctrlKey,holdTime:t};return r!==!0&&(i.captured=r),S(e.movable.events.after,o,n,i),!0}}else if(kn(e,o,n))return wn(e,o,n,{ctrlKey:e.stats.ctrlKey}),P(e),!0;return P(e),!1}function he(e,o,n,r){let t=e.pieces.get(o);t&&(Mn(e,o,n)||r)?(e.pieces.delete(o),be(e,t,n,r),S(e.movable.events.afterNewPiece,t.role,n,{premove:!1,predrop:!1})):t&&Cn(e,o,n)?Pn(e,t.role,n):(E(e),A(e)),e.pieces.delete(o),P(e)}function re(e,o,n){if(S(e.events.select,o),e.selected){if(e.selected===o&&!e.draggable.enabled){P(e),e.hold.cancel();return}else if((e.selectable.enabled||n)&&e.selected!==o&&Re(e,e.selected,o)){e.stats.dragged=!1;return}}(e.selectable.enabled||e.draggable.enabled)&&(bo(e,o)||Ve(e,o))&&(Oe(e,o),e.hold.start())}function Oe(e,o){e.selected=o,Ve(e,o)?e.premovable.customDests||(e.premovable.dests=Te(e,o)):e.premovable.dests=void 0}function P(e){e.selected=void 0,e.premovable.dests=void 0,e.hold.cancel()}function bo(e,o){let n=e.pieces.get(o);return!!n&&(e.movable.color==="both"||e.movable.color===n.color&&e.turnColor===n.color)}var ve=(e,o,n)=>o!==n&&bo(e,o)&&(e.movable.free||!!e.movable.dests?.get(o)?.includes(n));function Mn(e,o,n){let r=e.pieces.get(o);return!!r&&(o===n||!e.pieces.has(n))&&(e.movable.color==="both"||e.movable.color===r.color&&e.turnColor===r.color)}function Ve(e,o){let n=e.pieces.get(o);return!!n&&e.premovable.enabled&&e.movable.color===n.color&&e.turnColor!==n.color}var kn=(e,o,n)=>o!==n&&Ve(e,o)&&(e.premovable.customDests?.get(o)??Te(e,o)).includes(n);function Cn(e,o,n){let r=e.pieces.get(o),t=e.pieces.get(n);return!!r&&(!t||t.color!==e.movable.color)&&e.predroppable.enabled&&(r.role!=="pawn"||n[1]!=="1"&&n[1]!=="8")&&e.movable.color===r.color&&e.turnColor!==r.color}function ho(e,o){let n=e.pieces.get(o);return!!n&&e.draggable.enabled&&(e.movable.color==="both"||e.movable.color===n.color&&(e.turnColor===n.color||e.premovable.enabled))}function vo(e){let o=e.premovable.current;if(!o)return!1;let n=o[0],r=o[1],t=!1;if(ve(e,n,r)){let i=mo(e,n,r);if(i){let a={premove:!0};i!==!0&&(a.captured=i),S(e.movable.events.after,n,r,a),t=!0}}return E(e),t}function yo(e,o){let n=e.predroppable.current,r=!1;if(!n)return!1;if(o(n)){let t={role:n.role,color:e.movable.color};be(e,t,n.key)&&(S(e.movable.events.afterNewPiece,n.role,n.key,{premove:!1,predrop:!0}),r=!0)}return A(e),r}function te(e){E(e),A(e),P(e)}function Le(e){e.movable.color=e.movable.dests=e.animation.current=void 0,te(e)}function N(e,o,n){let r=Math.floor(8*(e[0]-n.left)/n.width);o||(r=7-r);let t=7-Math.floor(8*(e[1]-n.top)/n.height);return o||(t=7-t),r>=0&&r<8&&t>=0&&t<8?M([r,t]):void 0}function wo(e,o,n,r){let t=f(e),i=De.filter(s=>io(t,s)||fe(t[0],t[1],s[0],s[1])||J(t[0],t[1],s[0],s[1])),u=i.map(s=>de(F(s),n,r)).map(s=>G(o,s)),[,d]=u.reduce((s,c,l)=>s[0]<c?s:[c,l],[u[0],0]);return M(i[d])}var v=e=>e.orientation==="white";var Ge="rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR",Dn={p:"pawn",r:"rook",n:"knight",b:"bishop",q:"queen",k:"king"},Kn={pawn:"p",rook:"r",knight:"n",bishop:"b",queen:"q",king:"k"};function ye(e){e==="start"&&(e=Ge);let o=new Map,n=7,r=0;for(let t of e)switch(t){case" ":case"[":return o;case"/":if(--n,n<0)return o;r=0;break;case"~":{let i=M([r-1,n]),a=i&&o.get(i);a&&(a.promoted=!0);break}default:{let i=t.charCodeAt(0);if(i<57)r+=i-48;else{let a=t.toLowerCase(),u=M([r,n]);u&&o.set(u,{role:Dn[a],color:t===a?"black":"white"}),++r}}}return o}function Po(e){return no.map(o=>z.map(n=>{let r=e.get(n+o);if(r){let t=Kn[r.role];return r.color==="white"&&(t=t.toUpperCase()),r.promoted&&(t+="~"),t}else return"1"}).join("")).join("/").replace(/1{2,}/g,o=>o.length.toString())}function We(e,o){o.animation&&(ze(e.animation,o.animation),(e.animation.duration||0)<70&&(e.animation.enabled=!1))}function we(e,o){if(o.movable?.dests&&(e.movable.dests=void 0),o.drawable?.autoShapes&&(e.drawable.autoShapes=[]),ze(e,o),o.fen&&(e.pieces=ye(o.fen),e.drawable.shapes=o.drawable?.shapes||[]),"check"in o&&go(e,o.check||!1),"lastMove"in o&&!o.lastMove?e.lastMove=void 0:o.lastMove&&(e.lastMove=o.lastMove),e.selected&&Oe(e,e.selected),We(e,o),!e.movable.rookCastle&&e.movable.dests){let n=e.movable.color==="white"?"1":"8",r="e"+n,t=e.movable.dests.get(r),i=e.pieces.get(r);if(!t||!i||i.role!=="king")return;e.movable.dests.set(r,t.filter(a=>!(a==="a"+n&&t.includes("c"+n))&&!(a==="h"+n&&t.includes("g"+n))))}}function ze(e,o){for(let n in o)n==="__proto__"||n==="constructor"||!Object.prototype.hasOwnProperty.call(o,n)||(Object.prototype.hasOwnProperty.call(e,n)&&So(e[n])&&So(o[n])?ze(e[n],o[n]):e[n]=o[n])}function So(e){if(typeof e!="object"||e===null)return!1;let o=Object.getPrototypeOf(e);return o===Object.prototype||o===null}var O=(e,o)=>o.animation.enabled?Nn(e,o):V(e,o);function V(e,o){let n=e(o);return o.dom.redraw(),n}var $e=(e,o)=>({key:e,pos:f(e),piece:o}),En=(e,o)=>o.sort((n,r)=>G(e.pos,n.pos)-G(e.pos,r.pos))[0];function An(e,o){let n=new Map,r=[],t=new Map,i=[],a=[],u=new Map,d,s,c;for(let[l,p]of e)u.set(l,$e(l,p));for(let l of Q)d=o.pieces.get(l),s=u.get(l),d?s?$(d,s.piece)||(i.push(s),a.push($e(l,d))):a.push($e(l,d)):s&&i.push(s);for(let l of a)s=En(l,i.filter(p=>$(l.piece,p.piece))),s&&(c=[s.pos[0]-l.pos[0],s.pos[1]-l.pos[1]],n.set(l.key,c.concat(c)),r.push(s.key));for(let l of i)r.includes(l.key)||t.set(l.key,l.piece);return{anims:n,fadings:t}}function Mo(e,o){let n=e.animation.current;if(n===void 0){e.dom.destroyed||e.dom.redrawNow();return}let r=1-(o-n.start)*n.frequency;if(r<=0)e.animation.current=void 0,e.dom.redrawNow();else{let t=Hn(r);for(let i of n.plan.anims.values())i[2]=i[0]*t,i[3]=i[1]*t;e.dom.redrawNow(!0),requestAnimationFrame((i=performance.now())=>Mo(e,i))}}function Nn(e,o){let n=new Map(o.pieces),r=e(o),t=An(n,o);if(t.anims.size||t.fadings.size){let i=o.animation.current&&o.animation.current.start;o.animation.current={start:performance.now(),frequency:1/o.animation.duration,plan:t},i||Mo(o,performance.now())}else o.dom.redraw();return r}var Hn=e=>e<.5?4*e*e*e:(e-1)*(2*e-2)*(2*e-2)+1;var qn=["green","red","blue","yellow"];function ko(e,o){if(o.touches&&o.touches.length>1)return;o.stopPropagation(),o.preventDefault(),o.ctrlKey?P(e):te(e);let n=B(o),r=N(n,v(e),e.dom.bounds());r&&(e.drawable.current={orig:r,pos:n,brush:Tn(o),snapToValidMove:e.drawable.defaultSnapToValidMove},Co(e))}function Co(e){requestAnimationFrame(()=>{let o=e.drawable.current;if(o){let n=N(o.pos,v(e),e.dom.bounds());n||(o.snapToValidMove=!1);let r=o.snapToValidMove?wo(o.orig,o.pos,v(e),e.dom.bounds()):n;r!==o.mouseSq&&(o.mouseSq=r,o.dest=r!==o.orig?r:void 0,e.dom.redrawNow()),Co(e)}})}function Do(e,o){e.drawable.current&&(e.drawable.current.pos=B(o))}function Ko(e){let o=e.drawable.current;o&&(o.mouseSq&&Bn(e.drawable,o),Ie(e))}function Ie(e){e.drawable.current&&(e.drawable.current=void 0,e.dom.redraw())}function xo(e){e.drawable.shapes.length&&(e.drawable.shapes=[],e.dom.redraw(),Eo(e.drawable))}var Pe=(e,o)=>e.orig===o.orig&&e.dest===o.dest,je=(e,o)=>e.brush===o.brush;function Tn(e){let o=(e.shiftKey||e.ctrlKey)&&le(e),n=e.altKey||e.metaKey||e.getModifierState?.("AltGraph");return qn[(o?1:0)+(n?2:0)]}function Bn(e,o){let n=e.shapes.find(r=>Pe(r,o));n&&(e.shapes=e.shapes.filter(r=>!Pe(r,o))),(!n||!je(n,o))&&e.shapes.push({orig:o.orig,dest:o.dest,brush:o.brush}),Eo(e)}function Eo(e){e.onChange&&e.onChange(e.shapes)}function Ao(e,o){if(!(e.trustAllEvents||o.isTrusted)||o.buttons!==void 0&&o.buttons>1||o.touches&&o.touches.length>1)return;let n=e.dom.bounds(),r=B(o),t=N(r,v(e),n);if(!t)return;let i=e.pieces.get(t),a=e.selected;if(!a&&e.drawable.enabled&&(e.drawable.eraseOnMovablePieceClick||!i||i.color!==e.turnColor)&&xo(e),o.cancelable!==!1&&(!o.touches||e.blockTouchScroll||i||a||On(e,r)))o.preventDefault();else if(o.touches)return;let u=!!e.premovable.current,d=!!e.predroppable.current;e.stats.ctrlKey=o.ctrlKey,e.selected&&ve(e,e.selected,t)?O(l=>re(l,t),e):re(e,t);let s=e.selected===t,c=Bo(e,t);if(i&&c&&s&&ho(e,t)){e.draggable.current={orig:t,piece:i,origPos:r,pos:r,started:e.draggable.autoDistance&&e.stats.dragged,element:c,previouslySelected:a,originTarget:o.target,keyHasChanged:!1},c.cgDragging=!0,c.classList.add("dragging");let l=e.dom.elements.ghost;l&&(l.className=`ghost ${i.color} ${i.role}`,k(l,W(n)(f(t),v(e))),Y(l,!0)),Ue(e)}else u&&E(e),d&&A(e);e.dom.redraw()}function On(e,o){let n=v(e),r=e.dom.bounds(),t=Math.pow(e.touchIgnoreRadius*r.width/16,2)*2;for(let i of e.pieces.keys()){let a=de(i,n,r);if(G(a,o)<=t)return!0}return!1}function No(e,o,n,r){let t="a0";e.pieces.set(t,o),e.dom.redraw();let i=B(n);e.draggable.current={orig:t,piece:o,origPos:i,pos:i,started:!0,element:()=>Bo(e,t),originTarget:n.target,newPiece:!0,force:!!r,keyHasChanged:!1},Ue(e)}function Ue(e){requestAnimationFrame(()=>{let o=e.draggable.current;if(!o)return;e.animation.current?.plan.anims.has(o.orig)&&(e.animation.current=void 0);let n=e.pieces.get(o.orig);if(!n||!$(n,o.piece))I(e);else if(!o.started&&G(o.pos,o.origPos)>=Math.pow(e.draggable.distance,2)&&(o.started=!0),o.started){if(typeof o.element=="function"){let t=o.element();if(!t)return;t.cgDragging=!0,t.classList.add("dragging"),o.element=t}let r=e.dom.bounds();k(o.element,[o.pos[0]-r.left-r.width/16,o.pos[1]-r.top-r.height/16]),o.keyHasChanged||=o.orig!==N(o.pos,v(e),r)}Ue(e)})}function Ho(e,o){e.draggable.current&&(!o.touches||o.touches.length<2)&&(e.draggable.current.pos=B(o))}function qo(e,o){let n=e.draggable.current;if(!n)return;if(o.type==="touchend"&&o.cancelable!==!1&&o.preventDefault(),o.type==="touchend"&&n.originTarget!==o.target&&!n.newPiece){e.draggable.current=void 0;return}E(e),A(e);let r=B(o)||n.pos,t=N(r,v(e),e.dom.bounds());t&&n.started&&n.orig!==t?n.newPiece?he(e,n.orig,t,n.force):(e.stats.ctrlKey=o.ctrlKey,Re(e,n.orig,t)&&(e.stats.dragged=!0)):n.newPiece?e.pieces.delete(n.orig):e.draggable.deleteOnDropOff&&!t&&(e.pieces.delete(n.orig),S(e.events.change)),(n.orig===n.previouslySelected||n.keyHasChanged)&&(n.orig===t||!t)?P(e):e.selectable.enabled||P(e),To(e),e.draggable.current=void 0,e.dom.redraw()}function I(e){let o=e.draggable.current;o&&(o.newPiece&&e.pieces.delete(o.orig),e.draggable.current=void 0,P(e),To(e),e.dom.redraw())}function To(e){let o=e.dom.elements;o.ghost&&Y(o.ghost,!1)}function Bo(e,o){let n=e.dom.elements.board.firstChild;for(;n;){if(n.cgKey===o&&n.tagName==="PIECE")return n;n=n.nextSibling}}function Oo(e,o){e.exploding={stage:1,keys:o},e.dom.redraw(),setTimeout(()=>{Ro(e,2),setTimeout(()=>Ro(e,void 0),120)},120)}function Ro(e,o){e.exploding&&(o?e.exploding.stage=o:e.exploding=void 0,e.dom.redraw())}function Vo(e,o){function n(){po(e),o()}return{set(r){r.orientation&&r.orientation!==e.orientation&&n(),We(e,r),(r.fen?O:V)(t=>we(t,r),e)},state:e,getFen:()=>Po(e.pieces),toggleOrientation:n,setPieces(r){O(t=>fo(t,r),e)},selectSquare(r,t){r?O(i=>re(i,r,t),e):e.selected&&(P(e),e.dom.redraw())},move(r,t){O(i=>Be(i,r,t),e)},newPiece(r,t){O(i=>be(i,r,t),e)},playPremove(){if(e.premovable.current){if(O(vo,e))return!0;e.dom.redraw()}return!1},playPredrop(r){if(e.predroppable.current){let t=yo(e,r);return e.dom.redraw(),t}return!1},cancelPremove(){V(E,e)},cancelPredrop(){V(A,e)},cancelMove(){V(r=>{te(r),I(r)},e)},stop(){V(r=>{Le(r),I(r)},e)},explode(r){Oo(e,r)},setAutoShapes(r){V(t=>t.drawable.autoShapes=r,e)},setShapes(r){V(t=>t.drawable.shapes=r.slice(),e)},getKeyAtDomPos(r){return N(r,v(e),e.dom.bounds())},redrawAll:o,dragNewPiece(r,t,i){No(e,r,t,i)},destroy(){Le(e),e.dom.unbind&&e.dom.unbind(),e.dom.destroyed=!0}}}function Lo(){return{pieces:ye(Ge),orientation:"white",turnColor:"white",coordinates:!0,coordinatesOnSquares:!1,ranksPosition:"right",autoCastle:!0,viewOnly:!1,disableContextMenu:!1,addPieceZIndex:!1,blockTouchScroll:!1,touchIgnoreRadius:1,pieceKey:!1,trustAllEvents:!1,highlight:{lastMove:!0,check:!0},animation:{enabled:!0,duration:200},movable:{free:!0,color:"both",showDests:!0,events:{},rookCastle:!0},premovable:{enabled:!0,showDests:!0,castle:!0,additionalPremoveRequirements:e=>!0,events:{}},predroppable:{enabled:!1,events:{}},draggable:{enabled:!0,distance:3,autoDistance:!0,showGhost:!0,deleteOnDropOff:!1},dropmode:{active:!1},selectable:{enabled:!0},stats:{dragged:!("ontouchstart"in window)},events:{},drawable:{enabled:!0,visible:!0,defaultSnapToValidMove:!0,eraseOnMovablePieceClick:!0,shapes:[],autoShapes:[],brushes:{green:{key:"g",color:"#15781B",opacity:1,lineWidth:10},red:{key:"r",color:"#882020",opacity:1,lineWidth:10},blue:{key:"b",color:"#003088",opacity:1,lineWidth:10},yellow:{key:"y",color:"#e68f00",opacity:1,lineWidth:10},paleBlue:{key:"pb",color:"#003088",opacity:.4,lineWidth:15},paleGreen:{key:"pg",color:"#15781B",opacity:.4,lineWidth:15},paleRed:{key:"pr",color:"#882020",opacity:.4,lineWidth:15},paleGrey:{key:"pgr",color:"#4a4a4a",opacity:.35,lineWidth:15},purple:{key:"purple",color:"#68217a",opacity:.65,lineWidth:10},pink:{key:"pink",color:"#ee2080",opacity:.5,lineWidth:10},white:{key:"white",color:"white",opacity:1,lineWidth:10},paleWhite:{key:"pwhite",color:"white",opacity:.6,lineWidth:10}},prevSvgHash:""},hold:to()}}function Wo(){let e=y("defs"),o=w(y("filter"),{id:"cg-filter-blur"});return o.appendChild(w(y("feGaussianBlur"),{stdDeviation:"0.013"})),e.appendChild(o),e}function zo(e,o){let n=e.drawable,r=n.current,t=r&&r.mouseSq?r:void 0,i=new Map,a=e.dom.bounds(),u=n.autoShapes.filter(l=>!l.piece);for(let l of n.shapes.concat(u).concat(t?[t]:[])){if(!l.dest)continue;let p=i.get(l.dest)??new Set,m=Me(Se(f(l.orig),e.orientation),a),b=Me(Se(f(l.dest),e.orientation),a);p.add(_e(m,b)),i.set(l.dest,p)}let d=[],s=t?n.shapes.findIndex(l=>Pe(l,t)&&je(l,t)):-1;for(let[l,p]of n.shapes.concat(u).entries()){let m=s!==-1&&s===l;d.push({shape:p,current:!1,pendingErase:m,hash:Fo(p,Ze(p.dest,i),!1,a,m)})}t&&s===-1&&d.push({shape:t,current:!0,hash:Fo(t,Ze(t.dest,i),!0,a,!1),pendingErase:!1});let c=d.map(l=>l.hash).join(";");c!==e.drawable.prevSvgHash&&(e.drawable.prevSvgHash=c,Ln(n,d,o),Fn(d,o,l=>zn(e,l,n.brushes,i,a)))}function Ln(e,o,n){for(let r of[n.shapes,n.shapesBelow]){let t=r.querySelector("defs"),i=o.filter(s=>r===n.shapesBelow==!!s.shape.below),a=new Map;for(let s of i.filter(c=>c.shape.dest&&c.shape.brush)){let c=$o(e.brushes[s.shape.brush],s.shape.modifiers),{key:l,color:p}=Io(s.shape);l&&p&&a.set(l,{key:l,color:p,opacity:1,lineWidth:1}),a.set(c.key,c)}let u=new Set,d=t.firstElementChild;for(;d;)u.add(d.getAttribute("cgKey")),d=d.nextElementSibling;for(let[s,c]of a.entries())u.has(s)||t.appendChild(jn(c))}}function Fn(e,o,n){for(let[r,t]of[[o.shapes,o.custom],[o.shapesBelow,o.customBelow]]){let[i,a]=[r,t].map(s=>s.querySelector("g")),u=e.filter(s=>r===o.shapesBelow==!!s.shape.below),d=new Map;for(let s of u)d.set(s.hash,!1);for(let s of[i,a]){let c=[],l=s.firstElementChild,p;for(;l;)p=l.getAttribute("cgHash"),d.has(p)?d.set(p,!0):c.push(l),l=l.nextElementSibling;for(let m of c)s.removeChild(m)}for(let s of u.filter(c=>!d.get(c.hash)))for(let c of n(s))c.isCustom?a.appendChild(c.el):i.appendChild(c.el)}}function Fo({orig:e,dest:o,brush:n,piece:r,modifiers:t,customSvg:i,label:a,below:u},d,s,c,l){return[c.width,c.height,s,l&&"pendingErase",e,o,n,d&&"-",r&&Gn(r),t&&Wn(t),i&&`custom-${Go(i.html)},${i.center?.[0]??"o"}`,a&&`label-${Go(a.text)}`,u&&"below"].filter(p=>p).join(",")}function Gn(e){return[e.color,e.role,e.scale].filter(o=>o).join(",")}function Wn(e){return[e.lineWidth,e.hilite].filter(o=>o).join(",")}function Go(e){let o=0;for(let n=0;n<e.length;n++)o=(o<<5)-o+e.charCodeAt(n)>>>0;return o.toString()}function zn(e,{shape:o,current:n,pendingErase:r,hash:t},i,a,u){let d=Me(Se(f(o.orig),e.orientation),u),s=o.dest?Me(Se(f(o.dest),e.orientation),u):d,c=o.brush&&$o(i[o.brush],o.modifiers),l=a.get(o.dest),p=[];if(c){let m=w(y("g"),{cgHash:t});p.push({el:m}),d[0]!==s[0]||d[1]!==s[1]?m.appendChild(In(o,c,d,s,n,Ze(o.dest,a),r)):m.appendChild($n(i[o.brush],d,n,u,r))}if(o.label){let m=o.label;m.fill??=o.brush&&i[o.brush].color;let b=o.brush?void 0:"tr";p.push({el:Un(m,t,d,s,l,b),isCustom:!0})}if(o.customSvg){let m=o.customSvg.center??"orig",[b,g]=m==="label"?Uo(d,s,l).map(D=>D-.5):m==="dest"?s:d,R=w(y("g"),{transform:`translate(${b},${g})`,cgHash:t});R.innerHTML=`<svg width="1" height="1" viewBox="0 0 100 100">${o.customSvg.html}</svg>`,p.push({el:R,isCustom:!0})}return p}function $n(e,o,n,r,t){let i=Zn(),a=(r.width+r.height)/(4*Math.max(r.width,r.height));return w(y("circle"),{stroke:e.color,"stroke-width":i[n?0:1],fill:"none",opacity:jo(e,n,t),cx:o[0],cy:o[1],r:a-i[1]/2})}function In(e,o,n,r,t,i,a){function u(c){let l=Xn(i&&!t),p=r[0]-n[0],m=r[1]-n[1],b=Math.atan2(m,p),g=Math.cos(b)*l,R=Math.sin(b)*l,D=Io(e);return w(y("line"),{stroke:c?D.color:o.color,"stroke-width":_n(o,t)*(c?1.14:1),"stroke-linecap":"round","marker-end":`url(#arrowhead-${c?D.key:o.key})`,opacity:e.modifiers?.hilite&&!a?1:jo(o,t,a),x1:n[0],y1:n[1],x2:r[0]-g,y2:r[1]-R})}if(!e.modifiers?.hilite)return u(!1);let d=w(y("g"),{opacity:o.opacity}),s=w(y("g"),{filter:"url(#cg-filter-blur)"});return s.appendChild(Qn(n,r)),s.appendChild(u(!0)),d.appendChild(s),d.appendChild(u(!1)),d}function jn(e){let o=w(y("marker"),{id:"arrowhead-"+e.key,orient:"auto",overflow:"visible",markerWidth:4,markerHeight:4,refX:e.key.startsWith("hilite")?1.86:2.05,refY:2});return o.appendChild(w(y("path"),{d:"M0,0 V4 L3,2 Z",fill:e.color})),o.setAttribute("cgKey",e.key),o}function Un(e,o,n,r,t,i){let u=.4*.75**e.text.length,d=Uo(n,r,t),s=i==="tr"?.4:0,c=w(y("g"),{transform:`translate(${d[0]+s},${d[1]-s})`,cgHash:o});c.appendChild(w(y("circle"),{r:.4/2,"fill-opacity":i?1:.8,"stroke-opacity":i?1:.7,"stroke-width":.03,fill:e.fill??"#666",stroke:"white"}));let l=w(y("text"),{"font-size":u,"font-family":"Noto Sans","text-anchor":"middle",fill:"white",y:.13*.75**e.text.length});return l.innerHTML=e.text,c.appendChild(l),c}function Se(e,o){return o==="white"?e:[7-e[0],7-e[1]]}function Ze(e,o){return(e&&o.has(e)&&o.get(e).size>1)===!0}function y(e){return document.createElementNS("http://www.w3.org/2000/svg",e)}function w(e,o){for(let n in o)Object.prototype.hasOwnProperty.call(o,n)&&e.setAttribute(n,o[n]);return e}function $o(e,o){return o?{color:e.color,opacity:Math.round(e.opacity*10)/10,lineWidth:Math.round(o.lineWidth||e.lineWidth),key:[e.key,o.lineWidth].filter(n=>n).join("")}:e}function Zn(){return[3/64,4/64]}function _n(e,o){return(e.lineWidth||10)*(o?.85:1)/64}function Io(e){let o=e.modifiers?.hilite;return{key:o&&`hilite-${o.replace("#","")}`,color:o}}function jo(e,o,n){return(e.opacity||1)*(n?.6:o?.9:1)}function Xn(e){return(e?20:10)/64}function Me(e,o){let n=Math.min(1,o.width/o.height),r=Math.min(1,o.height/o.width);return[(e[0]-3.5)*n,(3.5-e[1])*r]}function Qn(e,o){let n={from:[Math.floor(Math.min(e[0],o[0])),Math.floor(Math.min(e[1],o[1]))],to:[Math.ceil(Math.max(e[0],o[0])),Math.ceil(Math.max(e[1],o[1]))]};return w(y("rect"),{x:n.from[0],y:n.from[1],width:n.to[0]-n.from[0],height:n.to[1]-n.from[1],fill:"none",stroke:"none"})}function _e(e,o,n=!0){let r=Math.atan2(o[1]-e[1],o[0]-e[0])+Math.PI;return n?(Math.round(r*8/Math.PI)+16)%16:r}function Yn(e,o){return Math.sqrt([e[0]-o[0],e[1]-o[1]].reduce((n,r)=>n+r*r,0))}function Uo(e,o,n){let r=Yn(e,o),t=_e(e,o,!1);if(n&&(r-=33/64,n.size>1)){r-=10/64;let i=_e(e,o);(n.has((i+1)%16)||n.has((i+15)%16))&&i&1&&(r-=.4)}return[e[0]-Math.cos(t)*r,e[1]-Math.sin(t)*r].map(i=>i+.5)}function _o(e,o){e.innerHTML="",e.classList.add("cg-wrap");for(let c of eo)e.classList.toggle("orientation-"+c,o.orientation===c);e.classList.toggle("manipulable",!o.viewOnly);let n=C("cg-container");e.appendChild(n);let r=C("cg-board");n.appendChild(r);let t,i,a,u,d;if(o.drawable.visible&&([t,i]=["cg-shapes-below","cg-shapes"].map(c=>Zo(c,!0)),[a,u]=["cg-custom-below","cg-custom-svgs"].map(c=>Zo(c,!1)),d=C("cg-auto-pieces"),n.appendChild(t),n.appendChild(a),n.appendChild(i),n.appendChild(u),n.appendChild(d)),o.coordinates){let c=o.orientation==="black"?" black":"",l=o.ranksPosition==="left"?" left":"";if(o.coordinatesOnSquares){let p=o.orientation==="white"?m=>m+1:m=>8-m;z.forEach((m,b)=>n.appendChild(Xe(j.map(g=>m+g),"squares rank"+p(b)+c+l)))}else n.appendChild(Xe(j,"ranks"+c+l)),n.appendChild(Xe(z,"files"+c))}let s;return o.draggable.enabled&&o.draggable.showGhost&&(s=C("piece","ghost"),Y(s,!1),n.appendChild(s)),{board:r,container:n,wrap:e,ghost:s,shapes:i,shapesBelow:t,custom:u,customBelow:a,autoPieces:d}}function Zo(e,o){let n=w(y("svg"),{class:e,viewBox:o?"-4 -4 8 8":"-3.5 -3.5 8 8",preserveAspectRatio:"xMidYMid slice"});return o&&n.appendChild(Wo()),n.appendChild(y("g")),n}function Xe(e,o){let n=C("coords",o),r;for(let t of e)r=C("coord"),r.textContent=t,n.appendChild(r);return n}function Xo(e,o){if(!e.dropmode.active)return;E(e),A(e);let n=e.dropmode.piece;if(n){e.pieces.set("a0",n);let r=B(o),t=r&&N(r,v(e),e.dom.bounds());t&&he(e,"a0",t)}e.dom.redraw()}function Yo(e,o){let n=e.dom.elements.board;if("ResizeObserver"in window&&new ResizeObserver(o).observe(e.dom.elements.wrap),(e.disableContextMenu||e.drawable.enabled)&&n.addEventListener("contextmenu",t=>t.preventDefault()),e.viewOnly)return;let r=er(e);n.addEventListener("touchstart",r,{passive:!1}),n.addEventListener("mousedown",r,{passive:!1})}function Jo(e,o){let n=[];if("ResizeObserver"in window||n.push(ie(document.body,"chessground.resize",o)),!e.viewOnly){let r=Qo(e,Ho,Do),t=Qo(e,qo,Ko);for(let a of["touchmove","mousemove"])n.push(ie(document,a,r));for(let a of["touchend","mouseup"])n.push(ie(document,a,t));let i=()=>e.dom.bounds.clear();n.push(ie(document,"scroll",i,{capture:!0,passive:!0})),n.push(ie(window,"resize",i,{passive:!0}))}return()=>n.forEach(r=>r())}function ie(e,o,n,r){return e.addEventListener(o,n,r),()=>e.removeEventListener(o,n,r)}var er=e=>o=>{e.draggable.current?I(e):e.drawable.current?Ie(e):o.shiftKey||le(o)?e.drawable.enabled&&ko(e,o):e.viewOnly||(e.dropmode.active?Xo(e,o):Ao(e,o))},Qo=(e,o,n)=>r=>{e.drawable.current?e.drawable.enabled&&n(e,r):e.viewOnly||o(e,r)};function on(e){let o=v(e),n=W(e.dom.bounds()),r=e.dom.elements.board,t=e.pieces,i=e.animation.current,a=i?i.plan.anims:new Map,u=i?i.plan.fadings:new Map,d=e.draggable.current,s=nr(e),c=new Set,l=new Set,p=new Map,m=new Map,b,g,R,D,K,_,ke,H,Ce,se;for(g=r.firstChild;g;){if(b=g.cgKey,rn(g))if(R=t.get(b),K=a.get(b),_=u.get(b),D=g.cgPiece,g.cgDragging&&(!d||d.orig!==b)&&(g.classList.remove("dragging"),k(g,n(f(b),o)),g.cgDragging=!1),!_&&g.cgFading&&(g.cgFading=!1,g.classList.remove("fading")),R){if(K&&g.cgAnimating&&D===ae(R)){let h=f(b);h[0]+=K[2],h[1]+=K[3],g.classList.add("anim"),k(g,n(h,o))}else g.cgAnimating&&(g.cgAnimating=!1,g.classList.remove("anim"),k(g,n(f(b),o)),e.addPieceZIndex&&(g.style.zIndex=Qe(f(b),o)));D===ae(R)&&(!_||!g.cgFading)?c.add(b):_&&D===ae(_)?(g.classList.add("fading"),g.cgFading=!0):Ye(p,D,g)}else Ye(p,D,g);else if(tn(g)){let h=g.className;s.get(b)===h?l.add(b):Ye(m,h,g)}g=g.nextSibling}for(let[h,X]of s)if(!l.has(h)){Ce=m.get(X),se=Ce&&Ce.pop();let q=n(f(h),o);if(se)se.cgKey=h,k(se,q);else{let T=C("square",X);T.cgKey=h,k(T,q),r.insertBefore(T,r.firstChild)}}for(let[h,X]of t)if(K=a.get(h),!c.has(h))if(ke=p.get(ae(X)),H=ke&&ke.pop(),H){H.cgKey=h,H.cgFading&&(H.classList.remove("fading"),H.cgFading=!1);let q=f(h);e.addPieceZIndex&&(H.style.zIndex=Qe(q,o)),K&&(H.cgAnimating=!0,H.classList.add("anim"),q[0]+=K[2],q[1]+=K[3]),k(H,n(q,o))}else{let q=ae(X),T=C("piece",q),ce=f(h);T.cgPiece=q,T.cgKey=h,K&&(T.cgAnimating=!0,ce[0]+=K[2],ce[1]+=K[3]),k(T,n(ce,o)),e.addPieceZIndex&&(T.style.zIndex=Qe(ce,o)),r.appendChild(T)}for(let h of p.values())en(e,h);for(let h of m.values())en(e,h)}function nn(e){let o=v(e),n=W(e.dom.bounds()),r=e.dom.elements.board.firstChild;for(;r;)(rn(r)&&!r.cgAnimating||tn(r))&&k(r,n(f(r.cgKey),o)),r=r.nextSibling}function Je(e){let o=e.dom.elements.wrap.getBoundingClientRect(),n=e.dom.elements.container,r=o.height/o.width,t=Math.floor(o.width*window.devicePixelRatio/8)*8/window.devicePixelRatio,i=t*r;n.style.width=t+"px",n.style.height=i+"px",e.dom.bounds.clear(),e.addDimensionsCssVarsTo?.style.setProperty("---cg-width",t+"px"),e.addDimensionsCssVarsTo?.style.setProperty("---cg-height",i+"px")}var rn=e=>e.tagName==="PIECE",tn=e=>e.tagName==="SQUARE";function en(e,o){for(let n of o)e.dom.elements.board.removeChild(n)}function Qe(e,o){let r=e[1];return`${o?10-r:3+r}`}var ae=e=>`${e.color} ${e.role}`;function nr(e){let o=new Map;if(e.lastMove&&e.highlight.lastMove)for(let t of e.lastMove)L(o,t,"last-move");if(e.check&&e.highlight.check&&L(o,e.check,"check"),e.selected&&(L(o,e.selected,"selected"),e.movable.showDests)){let t=e.movable.dests?.get(e.selected);if(t)for(let a of t)L(o,a,"move-dest"+(e.pieces.has(a)?" oc":""));let i=e.premovable.customDests?.get(e.selected)??e.premovable.dests;if(i)for(let a of i)L(o,a,"premove-dest"+(e.pieces.has(a)?" oc":""))}let n=e.premovable.current;if(n)for(let t of n)L(o,t,"current-premove");else e.predroppable.current&&L(o,e.predroppable.current.key,"current-premove");let r=e.exploding;if(r)for(let t of r.keys)L(o,t,"exploding"+r.stage);return e.highlight.custom&&e.highlight.custom.forEach((t,i)=>{L(o,i,t)}),o}function L(e,o,n){let r=e.get(o);r?e.set(o,`${r} ${n}`):e.set(o,n)}function Ye(e,o,n){let r=e.get(o);r?r.push(n):e.set(o,[n])}function an(e,o,n){let r=new Map,t=[];for(let u of e)r.set(u.hash,!1);let i=o.firstElementChild,a;for(;i;)a=i.getAttribute("cgHash"),r.has(a)?r.set(a,!0):t.push(i),i=i.nextElementSibling;for(let u of t)o.removeChild(u);for(let u of e)r.get(u.hash)||o.appendChild(n(u))}function sn(e,o){let r=e.drawable.autoShapes.filter(t=>t.piece).map(t=>({shape:t,hash:tr(t),current:!1,pendingErase:!1}));an(r,o,t=>rr(e,t,e.dom.bounds()))}function cn(e){let o=v(e),n=W(e.dom.bounds()),r=e.dom.elements.autoPieces?.firstChild;for(;r;)xe(r,n(f(r.cgKey),o),r.cgScale),r=r.nextSibling}function rr(e,{shape:o,hash:n},r){let t=o.orig,i=o.piece?.role,a=o.piece?.color,u=o.piece?.scale,d=C("piece",`${i} ${a}`);return d.setAttribute("cgHash",n),d.cgKey=t,d.cgScale=u,xe(d,W(r)(f(t),v(e)),u),d}var tr=e=>[e.orig,e.piece?.role,e.piece?.color,e.piece?.scale].join(",");function ut({el:e,config:o}){return ar(e,o)}function ar(e,o){let n=Lo();we(n,o||{});function r(){let t="dom"in n?n.dom.unbind:void 0,i=_o(e,n),a=Ke(()=>i.board.getBoundingClientRect()),u=c=>{on(s),i.autoPieces&&sn(s,i.autoPieces),!c&&i.shapes&&zo(s,i)},d=()=>{Je(s),nn(s),i.autoPieces&&cn(s)},s=n;return s.dom={elements:i,bounds:a,redraw:sr(u),redrawNow:u,unbind:t},s.drawable.prevSvgHash="",Je(s),u(!1),Yo(s,d),t||(s.dom.unbind=Jo(s,d)),s.events.insert&&s.events.insert(i),s}return Vo(r(),r)}function sr(e){let o=!1;return()=>{o||(o=!0,requestAnimationFrame(()=>{e(),o=!1}))}}export{ar as Chessground,ut as initModule};
|
|
1
|
+
var ze=["white","black"];var z=["a","b","c","d","e","f","g","h"],I=["1","2","3","4","5","6","7","8"];var Ie=[...I].reverse(),X=z.flatMap(e=>I.map(o=>e+o)),L=e=>e.every(o=>o>=0&&o<=7)?X[8*e[0]+e[1]]:void 0,G=e=>L(e),f=e=>[e.charCodeAt(0)-97,e.charCodeAt(1)-49];var ve=X.map(f),je=X.map((e,o)=>({key:e,pos:ve[o]}));function ye(e){let o,t=()=>(o===void 0&&(o=e()),o);return t.clear=()=>{o=void 0},t}var Ue=()=>{let e;return{start(){e=performance.now()},cancel(){e=void 0},stop(){if(!e)return 0;let o=performance.now()-e;return e=void 0,o}}},j=e=>e==="white"?"black":"white",F=(e,o)=>(e[0]-o[0])**2+(e[1]-o[1])**2,Q=(e,o)=>e.role===o.role&&e.color===o.color,Ze=(e,o)=>e[0]===o[0]&&e[1]===o[1],W=e=>(o,t)=>[(t?o[0]:7-o[0])*e.width/8,(t?7-o[1]:o[1])*e.height/8],M=(e,o)=>{e.style.transform=`translate(${o[0]}px,${o[1]}px)`},Se=(e,o,t=1)=>{e.style.transform=`translate(${o[0]}px,${o[1]}px) scale(${t})`},Y=(e,o)=>{e.style.visibility=o?"visible":"hidden"},T=e=>{if(e.clientX||e.clientX===0)return[e.clientX,e.clientY];if(e.targetTouches?.[0])return[e.targetTouches[0].clientX,e.targetTouches[0].clientY]},Yo=ye(()=>!("ontouchstart"in window)&&["macintosh","firefox"].every(e=>navigator.userAgent.toLowerCase().includes(e))),ie=e=>e.button===2&&!(e.ctrlKey&&Yo()),x=(e,o)=>{let t=document.createElement(e);return o&&(t.className=o),t};function ae(e,o,t){let n=f(e);return o||(n[0]=7-n[0],n[1]=7-n[1]),[t.left+t.width*n[0]/8+t.width/16,t.top+t.height*(7-n[1])/8+t.height/16]}var R=(e,o)=>Math.abs(e-o),ce=(e,o,t,n)=>R(e,t)*R(o,n)===2,we=(e,o,t,n)=>e===t!=(o===n),Pe=(e,o,t,n)=>R(e,t)===R(o,n)&&e!==t,_e=(e,o,t,n)=>we(e,o,t,n)||Pe(e,o,t,n),Xe=(e,o,t,n)=>Math.max(R(e,t),R(o,n))===1;var Qe=(e,o,t,n,r)=>{let i=r?1:-1;return e===t&&(n===o+i||n===o+2*i&&(r?o<=1:o>=6))},Ye=(e,o,t,n)=>{let r=t-e,i=n-o;if(r&&i&&Math.abs(r)!==Math.abs(i))return[];let l=Math.sign(r),u=Math.sign(i),d=[],a=e+l,s=o+u;for(;a!==t||s!==n;)d.push([a,s]),a+=l,s+=u;return d.map(L).filter(c=>c!==void 0)};var Jo=e=>R(e.orig.pos[0],e.dest.pos[0])<=1&&(R(e.orig.pos[0],e.dest.pos[0])===1?e.dest.pos[1]===e.orig.pos[1]+(e.color==="white"?1:-1):Qe(...e.orig.pos,...e.dest.pos,e.color==="white")),et=e=>ce(...e.orig.pos,...e.dest.pos),Je=e=>Pe(...e.orig.pos,...e.dest.pos),eo=e=>we(...e.orig.pos,...e.dest.pos),ot=e=>Je(e)||eo(e),tt=e=>Xe(...e.orig.pos,...e.dest.pos)||e.orig.pos[1]===e.dest.pos[1]&&e.orig.pos[1]===(e.color==="white"?0:7)&&(e.orig.pos[0]===4&&(e.dest.pos[0]===2&&e.rookFilesFriendlies.includes(0)||e.dest.pos[0]===6&&e.rookFilesFriendlies.includes(7))||e.rookFilesFriendlies.includes(e.dest.pos[0])),nt={pawn:Jo,knight:et,bishop:Je,rook:eo,queen:ot,king:tt};function Me(e,o){let t=e.pieces,n=t.get(o);if(!n||n.color===e.turnColor)return[];let r=n.color,i=new Map([...t].filter(([s,c])=>c.color===r)),l=new Map([...t].filter(([s,c])=>c.color===j(r))),u={key:o,pos:f(o)},d=s=>nt[n.role](s)&&e.premovable.additionalPremoveRequirements(s),a={orig:u,role:n.role,allPieces:t,friendlies:i,enemies:l,color:r,rookFilesFriendlies:Array.from(t).filter(([s,c])=>s[1]===(r==="white"?"1":"8")&&c.color===r&&c.role==="rook").map(([s])=>f(s)[0]),lastMove:e.lastMove};return je.filter(s=>d({...a,dest:s})).map(s=>s.key)}function P(e,...o){e&&setTimeout(()=>e(...o),1)}function oo(e){e.orientation=j(e.orientation),e.animation.current=e.draggable.current=e.selected=void 0}function to(e,o){for(let[t,n]of o)n?e.pieces.set(t,n):e.pieces.delete(t)}function no(e,o){if(e.check=void 0,o===!0&&(o=e.turnColor),o)for(let[t,n]of e.pieces)n.role==="king"&&n.color===o&&(e.check=t)}function rt(e,o,t,n){D(e),e.premovable.current=[o,t],P(e.premovable.events.set,o,t,n)}function k(e){e.premovable.current&&(e.premovable.current=void 0,P(e.premovable.events.unset))}function it(e,o,t){k(e),e.predroppable.current={role:o,key:t},P(e.predroppable.events.set,o,t)}function D(e){let o=e.predroppable;o.current&&(o.current=void 0,P(o.events.unset))}function at(e,o,t){if(!e.autoCastle)return!1;let n=e.pieces.get(o);if(!n||n.role!=="king")return!1;let r=f(o),i=f(t);if(r[1]!==0&&r[1]!==7||r[1]!==i[1])return!1;r[0]===4&&!e.pieces.has(t)&&(i[0]===6?t=G([7,i[1]]):i[0]===2&&(t=G([0,i[1]])));let l=e.pieces.get(t);return!l||l.color!==n.color||l.role!=="rook"?!1:(e.pieces.delete(o),e.pieces.delete(t),r[0]<i[0]?(e.pieces.set(G([6,i[1]]),n),e.pieces.set(G([5,i[1]]),l)):(e.pieces.set(G([2,i[1]]),n),e.pieces.set(G([3,i[1]]),l)),!0)}function xe(e,o,t){let n=e.pieces.get(o),r=e.pieces.get(t);if(o===t||!n)return!1;let i=r&&r.color!==n.color?r:void 0;return t===e.selected&&w(e),P(e.events.move,o,t,i),at(e,o,t)||(e.pieces.set(t,n),e.pieces.delete(o)),e.lastMove=[o,t],e.check=void 0,P(e.events.change),i||!0}function se(e,o,t,n){if(e.pieces.has(t))if(n)e.pieces.delete(t);else return!1;return P(e.events.dropNewPiece,o,t),e.pieces.set(t,o),e.lastMove=[t],e.check=void 0,P(e.events.change),e.movable.dests=void 0,e.turnColor=j(e.turnColor),!0}function ro(e,o,t){let n=xe(e,o,t);return n&&(e.movable.dests=void 0,e.turnColor=j(e.turnColor),e.animation.current=void 0),n}function Ce(e,o,t){if(de(e,o,t)){let n=ro(e,o,t);if(n){let r=e.hold.stop();w(e);let i={premove:!1,ctrlKey:e.stats.ctrlKey,holdTime:r};return n!==!0&&(i.captured=n),P(e.movable.events.after,o,t,i),!0}}else if(st(e,o,t))return rt(e,o,t,{ctrlKey:e.stats.ctrlKey}),w(e),!0;return w(e),!1}function le(e,o,t,n){let r=e.pieces.get(o);r&&(ct(e,o,t)||n)?(e.pieces.delete(o),se(e,r,t,n),P(e.movable.events.afterNewPiece,r.role,t,{premove:!1,predrop:!1})):r&<(e,o,t)?it(e,r.role,t):(k(e),D(e)),e.pieces.delete(o),w(e)}function J(e,o,t){if(P(e.events.select,o),e.selected){if(e.selected===o&&!e.draggable.enabled){w(e),e.hold.cancel();return}else if((e.selectable.enabled||t)&&e.selected!==o&&Ce(e,e.selected,o)){e.stats.dragged=!1;return}}(e.selectable.enabled||e.draggable.enabled)&&(io(e,o)||ke(e,o))&&(Ke(e,o),e.hold.start())}function Ke(e,o){e.selected=o,ke(e,o)?e.premovable.customDests||(e.premovable.dests=Me(e,o)):e.premovable.dests=void 0}function w(e){e.selected=void 0,e.premovable.dests=void 0,e.hold.cancel()}function io(e,o){let t=e.pieces.get(o);return!!t&&(e.movable.color==="both"||e.movable.color===t.color&&e.turnColor===t.color)}var de=(e,o,t)=>o!==t&&io(e,o)&&(e.movable.free||!!e.movable.dests?.get(o)?.includes(t));function ct(e,o,t){let n=e.pieces.get(o);return!!n&&(o===t||!e.pieces.has(t))&&(e.movable.color==="both"||e.movable.color===n.color&&e.turnColor===n.color)}function ke(e,o){let t=e.pieces.get(o);return!!t&&e.premovable.enabled&&e.movable.color===t.color&&e.turnColor!==t.color}var st=(e,o,t)=>o!==t&&ke(e,o)&&(e.premovable.customDests?.get(o)??Me(e,o)).includes(t);function lt(e,o,t){let n=e.pieces.get(o),r=e.pieces.get(t);return!!n&&(!r||r.color!==e.movable.color)&&e.predroppable.enabled&&(n.role!=="pawn"||t[1]!=="1"&&t[1]!=="8")&&e.movable.color===n.color&&e.turnColor!==n.color}function ao(e,o){let t=e.pieces.get(o);return!!t&&e.draggable.enabled&&(e.movable.color==="both"||e.movable.color===t.color&&(e.turnColor===t.color||e.premovable.enabled))}function co(e){let o=e.premovable.current;if(!o)return!1;let t=o[0],n=o[1],r=!1;if(de(e,t,n)){let i=ro(e,t,n);if(i){let l={premove:!0};i!==!0&&(l.captured=i),P(e.movable.events.after,t,n,l),r=!0}}return k(e),r}function so(e,o){let t=e.predroppable.current,n=!1;if(!t)return!1;if(o(t)){let r={role:t.role,color:e.movable.color};se(e,r,t.key)&&(P(e.movable.events.afterNewPiece,t.role,t.key,{premove:!1,predrop:!0}),n=!0)}return D(e),n}function ee(e){k(e),D(e),w(e)}function De(e){e.movable.color=e.movable.dests=e.animation.current=void 0,ee(e)}function E(e,o,t){let n=Math.floor(8*(e[0]-t.left)/t.width);o||(n=7-n);let r=7-Math.floor(8*(e[1]-t.top)/t.height);return o||(r=7-r),n>=0&&n<8&&r>=0&&r<8?L([n,r]):void 0}function lo(e,o,t,n){let r=f(e),i=ve.filter(a=>Ze(r,a)||_e(r[0],r[1],a[0],a[1])||ce(r[0],r[1],a[0],a[1])),u=i.map(a=>ae(G(a),t,n)).map(a=>F(o,a)),[,d]=u.reduce((a,s,c)=>a[0]<s?a:[s,c],[u[0],0]);return L(i[d])}var v=e=>e.orientation==="white";var Ae="rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR",dt={p:"pawn",r:"rook",n:"knight",b:"bishop",q:"queen",k:"king"},ut={pawn:"p",rook:"r",knight:"n",bishop:"b",queen:"q",king:"k"};function ue(e){e==="start"&&(e=Ae);let o=new Map,t=7,n=0;for(let r of e)switch(r){case" ":case"[":return o;case"/":if(--t,t<0)return o;n=0;break;case"~":{let i=L([n-1,t]),l=i&&o.get(i);l&&(l.promoted=!0);break}default:{let i=r.charCodeAt(0);if(i<57)n+=i-48;else{let l=r.toLowerCase(),u=L([n,t]);u&&o.set(u,{role:dt[l],color:r===l?"black":"white"}),++n}}}return o}function uo(e){return Ie.map(o=>z.map(t=>{let n=e.get(t+o);if(n){let r=ut[n.role];return n.color==="white"&&(r=r.toUpperCase()),n.promoted&&(r+="~"),r}else return"1"}).join("")).join("/").replace(/1{2,}/g,o=>o.length.toString())}function Ne(e,o){o.animation&&(He(e.animation,o.animation),(e.animation.duration||0)<70&&(e.animation.enabled=!1))}function pe(e,o){if(o.movable?.dests&&(e.movable.dests=void 0),o.drawable?.autoShapes&&(e.drawable.autoShapes=[]),He(e,o),o.fen&&(e.pieces=ue(o.fen),e.drawable.shapes=o.drawable?.shapes||[]),"check"in o&&no(e,o.check||!1),"lastMove"in o&&!o.lastMove?e.lastMove=void 0:o.lastMove&&(e.lastMove=o.lastMove),e.selected&&Ke(e,e.selected),Ne(e,o),!e.movable.rookCastle&&e.movable.dests){let t=e.movable.color==="white"?"1":"8",n="e"+t,r=e.movable.dests.get(n),i=e.pieces.get(n);if(!r||!i||i.role!=="king")return;e.movable.dests.set(n,r.filter(l=>!(l==="a"+t&&r.includes("c"+t))&&!(l==="h"+t&&r.includes("g"+t))))}}function He(e,o){for(let t in o)t==="__proto__"||t==="constructor"||!Object.prototype.hasOwnProperty.call(o,t)||(Object.prototype.hasOwnProperty.call(e,t)&&po(e[t])&&po(o[t])?He(e[t],o[t]):e[t]=o[t])}function po(e){if(typeof e!="object"||e===null)return!1;let o=Object.getPrototypeOf(e);return o===Object.prototype||o===null}var B=(e,o)=>o.animation.enabled?mt(e,o):O(e,o);function O(e,o){let t=e(o);return o.dom.redraw(),t}var Te=(e,o)=>({key:e,pos:f(e),piece:o}),gt=(e,o)=>o.sort((t,n)=>F(e.pos,t.pos)-F(e.pos,n.pos))[0];function ft(e,o){let t=new Map,n=[],r=new Map,i=[],l=[],u=new Map,d,a,s;for(let[c,g]of e)u.set(c,Te(c,g));for(let c of X)d=o.pieces.get(c),a=u.get(c),d?a?Q(d,a.piece)||(i.push(a),l.push(Te(c,d))):l.push(Te(c,d)):a&&i.push(a);for(let c of l)a=gt(c,i.filter(g=>Q(c.piece,g.piece))),a&&(s=[a.pos[0]-c.pos[0],a.pos[1]-c.pos[1]],t.set(c.key,s.concat(s)),n.push(a.key));for(let c of i)n.includes(c.key)||r.set(c.key,c.piece);return{anims:t,fadings:r}}function go(e,o){let t=e.animation.current;if(t===void 0){e.dom.destroyed||e.dom.redrawNow();return}let n=1-(o-t.start)*t.frequency;if(n<=0)e.animation.current=void 0,e.dom.redrawNow();else{let r=bt(n);for(let i of t.plan.anims.values())i[2]=i[0]*r,i[3]=i[1]*r;e.dom.redrawNow(!0),requestAnimationFrame((i=performance.now())=>go(e,i))}}function mt(e,o){let t=new Map(o.pieces),n=e(o),r=ft(t,o);if(r.anims.size||r.fadings.size){let i=o.animation.current&&o.animation.current.start;o.animation.current={start:performance.now(),frequency:1/o.animation.duration,plan:r},i||go(o,performance.now())}else o.dom.redraw();return n}var bt=e=>e<.5?4*e*e*e:(e-1)*(2*e-2)*(2*e-2)+1;var ht=["green","red","blue","yellow"];function fo(e,o){if(o.touches&&o.touches.length>1)return;o.stopPropagation(),o.preventDefault(),o.ctrlKey?w(e):ee(e);let t=T(o),n=E(t,v(e),e.dom.bounds());n&&(e.drawable.current={orig:n,pos:t,brush:vt(o),snapToValidMove:e.drawable.defaultSnapToValidMove},mo(e))}function mo(e){requestAnimationFrame(()=>{let o=e.drawable.current;if(o){let t=E(o.pos,v(e),e.dom.bounds());t||(o.snapToValidMove=!1);let n=o.snapToValidMove?lo(o.orig,o.pos,v(e),e.dom.bounds()):t;n!==o.mouseSq&&(o.mouseSq=n,o.dest=n!==o.orig?n:void 0,e.dom.redrawNow()),mo(e)}})}function bo(e,o){e.drawable.current&&(e.drawable.current.pos=T(o))}function ho(e){let o=e.drawable.current;o&&(o.mouseSq&&yt(e.drawable,o),qe(e))}function qe(e){e.drawable.current&&(e.drawable.current=void 0,e.dom.redraw())}function vo(e){e.drawable.shapes.length&&(e.drawable.shapes=[],e.dom.redraw(),yo(e.drawable))}var ge=(e,o)=>e.orig===o.orig&&e.dest===o.dest,Re=(e,o)=>e.brush===o.brush;function vt(e){let o=(e.shiftKey||e.ctrlKey)&&ie(e),t=e.altKey||e.metaKey||e.getModifierState?.("AltGraph");return ht[(o?1:0)+(t?2:0)]}function yt(e,o){let t=e.shapes.find(n=>ge(n,o));t&&(e.shapes=e.shapes.filter(n=>!ge(n,o))),(!t||!Re(t,o))&&e.shapes.push({orig:o.orig,dest:o.dest,brush:o.brush}),yo(e)}function yo(e){e.onChange&&e.onChange(e.shapes)}function So(e,o){if(!(e.trustAllEvents||o.isTrusted)||o.buttons!==void 0&&o.buttons>1||o.touches&&o.touches.length>1)return;let t=e.dom.bounds(),n=T(o),r=E(n,v(e),t);if(!r)return;let i=e.pieces.get(r),l=e.selected;if(!l&&e.drawable.enabled&&(e.drawable.eraseOnMovablePieceClick||!i||i.color!==e.turnColor)&&vo(e),o.cancelable!==!1&&(!o.touches||e.blockTouchScroll||i||l||wt(e,n)))o.preventDefault();else if(o.touches)return;let u=!!e.premovable.current,d=!!e.predroppable.current;e.stats.ctrlKey=o.ctrlKey,e.selected&&de(e,e.selected,r)?B(c=>J(c,r),e):J(e,r);let a=e.selected===r,s=Co(e,r);if(i&&s&&a&&ao(e,r)){e.draggable.current={orig:r,piece:i,origPos:n,pos:n,started:e.draggable.autoDistance&&e.stats.dragged,element:s,previouslySelected:l,originTarget:o.target,keyHasChanged:!1},s.cgDragging=!0,s.classList.add("dragging");let c=e.dom.elements.ghost;c&&(c.className=`ghost ${i.color} ${i.role}`,M(c,W(t)(f(r),v(e))),Y(c,!0)),Be(e)}else u&&k(e),d&&D(e);e.dom.redraw()}function wt(e,o){let t=v(e),n=e.dom.bounds(),r=Math.pow(e.touchIgnoreRadius*n.width/16,2)*2;for(let i of e.pieces.keys()){let l=ae(i,t,n);if(F(l,o)<=r)return!0}return!1}function wo(e,o,t,n){let r="a0";e.pieces.set(r,o),e.dom.redraw();let i=T(t);e.draggable.current={orig:r,piece:o,origPos:i,pos:i,started:!0,element:()=>Co(e,r),originTarget:t.target,newPiece:!0,force:!!n,keyHasChanged:!1},Be(e)}function Be(e){requestAnimationFrame(()=>{let o=e.draggable.current;if(!o)return;e.animation.current?.plan.anims.has(o.orig)&&(e.animation.current=void 0);let t=e.pieces.get(o.orig);if(!t||!Q(t,o.piece))$(e);else if(!o.started&&F(o.pos,o.origPos)>=Math.pow(e.draggable.distance,2)&&(o.started=!0),o.started){if(typeof o.element=="function"){let r=o.element();if(!r)return;r.cgDragging=!0,r.classList.add("dragging"),o.element=r}let n=e.dom.bounds();M(o.element,[o.pos[0]-n.left-n.width/16,o.pos[1]-n.top-n.height/16]),o.keyHasChanged||=o.orig!==E(o.pos,v(e),n)}Be(e)})}function Po(e,o){e.draggable.current&&(!o.touches||o.touches.length<2)&&(e.draggable.current.pos=T(o))}function Mo(e,o){let t=e.draggable.current;if(!t)return;if(o.type==="touchend"&&o.cancelable!==!1&&o.preventDefault(),o.type==="touchend"&&t.originTarget!==o.target&&!t.newPiece){e.draggable.current=void 0;return}k(e),D(e);let n=T(o)||t.pos,r=E(n,v(e),e.dom.bounds());r&&t.started&&t.orig!==r?t.newPiece?le(e,t.orig,r,t.force):(e.stats.ctrlKey=o.ctrlKey,Ce(e,t.orig,r)&&(e.stats.dragged=!0)):t.newPiece?e.pieces.delete(t.orig):e.draggable.deleteOnDropOff&&!r&&(e.pieces.delete(t.orig),P(e.events.change)),(t.orig===t.previouslySelected||t.keyHasChanged)&&(t.orig===r||!r)?w(e):e.selectable.enabled||w(e),xo(e),e.draggable.current=void 0,e.dom.redraw()}function $(e){let o=e.draggable.current;o&&(o.newPiece&&e.pieces.delete(o.orig),e.draggable.current=void 0,w(e),xo(e),e.dom.redraw())}function xo(e){let o=e.dom.elements;o.ghost&&Y(o.ghost,!1)}function Co(e,o){let t=e.dom.elements.board.firstChild;for(;t;){if(t.cgKey===o&&t.tagName==="PIECE")return t;t=t.nextSibling}}function ko(e,o){e.exploding={stage:1,keys:o},e.dom.redraw(),setTimeout(()=>{Ko(e,2),setTimeout(()=>Ko(e,void 0),120)},120)}function Ko(e,o){e.exploding&&(o?e.exploding.stage=o:e.exploding=void 0,e.dom.redraw())}function Do(e,o){function t(){oo(e),o()}return{set(n){n.orientation&&n.orientation!==e.orientation&&t(),Ne(e,n),(n.fen?B:O)(r=>pe(r,n),e)},state:e,getFen:()=>uo(e.pieces),toggleOrientation:t,setPieces(n){B(r=>to(r,n),e)},selectSquare(n,r){n?B(i=>J(i,n,r),e):e.selected&&(w(e),e.dom.redraw())},move(n,r){B(i=>xe(i,n,r),e)},newPiece(n,r){B(i=>se(i,n,r),e)},playPremove(){if(e.premovable.current){if(B(co,e))return!0;e.dom.redraw()}return!1},playPredrop(n){if(e.predroppable.current){let r=so(e,n);return e.dom.redraw(),r}return!1},cancelPremove(){O(k,e)},cancelPredrop(){O(D,e)},cancelMove(){O(n=>{ee(n),$(n)},e)},stop(){O(n=>{De(n),$(n)},e)},explode(n){ko(e,n)},setAutoShapes(n){O(r=>r.drawable.autoShapes=n,e)},setShapes(n){O(r=>r.drawable.shapes=n.slice(),e)},getKeyAtDomPos(n){return E(n,v(e),e.dom.bounds())},redrawAll:o,dragNewPiece(n,r,i){wo(e,n,r,i)},destroy(){De(e),e.dom.unbind&&e.dom.unbind(),e.dom.destroyed=!0}}}function Eo(){return{pieces:ue(Ae),orientation:"white",turnColor:"white",coordinates:!0,coordinatesOnSquares:!1,ranksPosition:"right",autoCastle:!0,viewOnly:!1,disableContextMenu:!1,addPieceZIndex:!1,blockTouchScroll:!1,touchIgnoreRadius:1,pieceKey:!1,trustAllEvents:!1,highlight:{lastMove:!0,check:!0},animation:{enabled:!0,duration:200},movable:{free:!0,color:"both",showDests:!0,events:{},rookCastle:!0},premovable:{enabled:!0,showDests:!0,castle:!0,additionalPremoveRequirements:e=>!0,events:{}},predroppable:{enabled:!1,events:{}},draggable:{enabled:!0,distance:3,autoDistance:!0,showGhost:!0,deleteOnDropOff:!1},dropmode:{active:!1},selectable:{enabled:!0},stats:{dragged:!("ontouchstart"in window)},events:{},drawable:{enabled:!0,visible:!0,defaultSnapToValidMove:!0,eraseOnMovablePieceClick:!0,shapes:[],autoShapes:[],brushes:{green:{key:"g",color:"#15781B",opacity:1,lineWidth:10},red:{key:"r",color:"#882020",opacity:1,lineWidth:10},blue:{key:"b",color:"#003088",opacity:1,lineWidth:10},yellow:{key:"y",color:"#e68f00",opacity:1,lineWidth:10},paleBlue:{key:"pb",color:"#003088",opacity:.4,lineWidth:15},paleGreen:{key:"pg",color:"#15781B",opacity:.4,lineWidth:15},paleRed:{key:"pr",color:"#882020",opacity:.4,lineWidth:15},paleGrey:{key:"pgr",color:"#4a4a4a",opacity:.35,lineWidth:15},purple:{key:"purple",color:"#68217a",opacity:.65,lineWidth:10},pink:{key:"pink",color:"#ee2080",opacity:.5,lineWidth:10},white:{key:"white",color:"white",opacity:1,lineWidth:10},paleWhite:{key:"pwhite",color:"white",opacity:.6,lineWidth:10}},prevSvgHash:""},hold:Ue()}}function Ho(){let e=y("defs"),o=S(y("filter"),{id:"cg-filter-blur"});return o.appendChild(S(y("feGaussianBlur"),{stdDeviation:"0.013"})),e.appendChild(o),e}function To(e,o){let t=e.drawable,n=t.current,r=n&&n.mouseSq?n:void 0,i=new Map,l=e.dom.bounds(),u=t.autoShapes.filter(c=>!c.piece);for(let c of t.shapes.concat(u).concat(r?[r]:[])){if(!c.dest)continue;let g=i.get(c.dest)??new Set,m=me(fe(f(c.orig),e.orientation),l),b=me(fe(f(c.dest),e.orientation),l);g.add(Ve(m,b)),i.set(c.dest,g)}let d=[],a=r?t.shapes.findIndex(c=>ge(c,r)&&Re(c,r)):-1;for(let[c,g]of t.shapes.concat(u).entries()){let m=a!==-1&&a===c;d.push({shape:g,current:!1,pendingErase:m,hash:Ao(g,Oe(g.dest,i),!1,l,m)})}r&&a===-1&&d.push({shape:r,current:!0,hash:Ao(r,Oe(r.dest,i),!0,l,!1),pendingErase:!1});let s=d.map(c=>c.hash).join(";");s!==e.drawable.prevSvgHash&&(e.drawable.prevSvgHash=s,Mt(t,d,o),xt(d,o,c=>kt(e,c,t.brushes,i,l)))}function Mt(e,o,t){for(let n of[t.shapes,t.shapesBelow]){let r=n.querySelector("defs"),i=o.filter(a=>n===t.shapesBelow==!!a.shape.below),l=new Map;for(let a of i.filter(s=>s.shape.dest&&s.shape.brush)){let s=qo(e.brushes[a.shape.brush],a.shape.modifiers),{key:c,color:g}=Ro(a.shape);c&&g&&l.set(c,{key:c,color:g,opacity:1,lineWidth:1}),l.set(s.key,s)}let u=new Set,d=r.firstElementChild;for(;d;)u.add(d.getAttribute("cgKey")),d=d.nextElementSibling;for(let[a,s]of l.entries())u.has(a)||r.appendChild(At(s))}}function xt(e,o,t){for(let[n,r]of[[o.shapes,o.custom],[o.shapesBelow,o.customBelow]]){let[i,l]=[n,r].map(a=>a.querySelector("g")),u=e.filter(a=>n===o.shapesBelow==!!a.shape.below),d=new Map;for(let a of u)d.set(a.hash,!1);for(let a of[i,l]){let s=[],c=a.firstElementChild,g;for(;c;)g=c.getAttribute("cgHash"),d.has(g)?d.set(g,!0):s.push(c),c=c.nextElementSibling;for(let m of s)a.removeChild(m)}for(let a of u.filter(s=>!d.get(s.hash)))for(let s of t(a))s.isCustom?l.appendChild(s.el):i.appendChild(s.el)}}function Ao({orig:e,dest:o,brush:t,piece:n,modifiers:r,customSvg:i,label:l,below:u},d,a,s,c){return[s.width,s.height,a,c&&"pendingErase",e,o,t,d&&"-",n&&Ct(n),r&&Kt(r),i&&`custom-${No(i.html)},${i.center?.[0]??"o"}`,l&&`label-${No(l.text)}`,u&&"below"].filter(g=>g).join(",")}function Ct(e){return[e.color,e.role,e.scale].filter(o=>o).join(",")}function Kt(e){return[e.lineWidth,e.hilite].filter(o=>o).join(",")}function No(e){let o=0;for(let t=0;t<e.length;t++)o=(o<<5)-o+e.charCodeAt(t)>>>0;return o.toString()}function kt(e,{shape:o,current:t,pendingErase:n,hash:r},i,l,u){let d=me(fe(f(o.orig),e.orientation),u),a=o.dest?me(fe(f(o.dest),e.orientation),u):d,s=o.brush&&qo(i[o.brush],o.modifiers),c=l.get(o.dest),g=[];if(s){let m=S(y("g"),{cgHash:r});g.push({el:m}),d[0]!==a[0]||d[1]!==a[1]?m.appendChild(Et(o,s,d,a,t,Oe(o.dest,l),n)):m.appendChild(Dt(i[o.brush],d,t,u,n))}if(o.label){let m=o.label;m.fill??=o.brush&&i[o.brush].color;let b=o.brush?void 0:"tr";g.push({el:Nt(m,r,d,a,c,b),isCustom:!0})}if(o.customSvg){let m=o.customSvg.center??"orig",[b,p]=m==="label"?Oo(d,a,c).map(C=>C-.5):m==="dest"?a:d,q=S(y("g"),{transform:`translate(${b},${p})`,cgHash:r});q.innerHTML=`<svg width="1" height="1" viewBox="0 0 100 100">${o.customSvg.html}</svg>`,g.push({el:q,isCustom:!0})}return g}function Dt(e,o,t,n,r){let i=Ht(),l=(n.width+n.height)/(4*Math.max(n.width,n.height));return S(y("circle"),{stroke:e.color,"stroke-width":i[t?0:1],fill:"none",opacity:Bo(e,t,r),cx:o[0],cy:o[1],r:l-i[1]/2})}function Et(e,o,t,n,r,i,l){function u(s){let c=qt(i&&!r),g=n[0]-t[0],m=n[1]-t[1],b=Math.atan2(m,g),p=Math.cos(b)*c,q=Math.sin(b)*c,C=Ro(e);return S(y("line"),{stroke:s?C.color:o.color,"stroke-width":Tt(o,r)*(s?1.14:1),"stroke-linecap":"round","marker-end":`url(#arrowhead-${s?C.key:o.key})`,opacity:e.modifiers?.hilite&&!l?1:Bo(o,r,l),x1:t[0],y1:t[1],x2:n[0]-p,y2:n[1]-q})}if(!e.modifiers?.hilite)return u(!1);let d=S(y("g"),{opacity:o.opacity}),a=S(y("g"),{filter:"url(#cg-filter-blur)"});return a.appendChild(Rt(t,n)),a.appendChild(u(!0)),d.appendChild(a),d.appendChild(u(!1)),d}function At(e){let o=S(y("marker"),{id:"arrowhead-"+e.key,orient:"auto",overflow:"visible",markerWidth:4,markerHeight:4,refX:e.key.startsWith("hilite")?1.86:2.05,refY:2});return o.appendChild(S(y("path"),{d:"M0,0 V4 L3,2 Z",fill:e.color})),o.setAttribute("cgKey",e.key),o}function Nt(e,o,t,n,r,i){let u=.4*.75**e.text.length,d=Oo(t,n,r),a=i==="tr"?.4:0,s=S(y("g"),{transform:`translate(${d[0]+a},${d[1]-a})`,cgHash:o});s.appendChild(S(y("circle"),{r:.4/2,"fill-opacity":i?1:.8,"stroke-opacity":i?1:.7,"stroke-width":.03,fill:e.fill??"#666",stroke:"white"}));let c=S(y("text"),{"font-size":u,"font-family":"Noto Sans","text-anchor":"middle",fill:"white",y:.13*.75**e.text.length});return c.innerHTML=e.text,s.appendChild(c),s}function fe(e,o){return o==="white"?e:[7-e[0],7-e[1]]}function Oe(e,o){return(e&&o.has(e)&&o.get(e).size>1)===!0}function y(e){return document.createElementNS("http://www.w3.org/2000/svg",e)}function S(e,o){for(let t in o)Object.prototype.hasOwnProperty.call(o,t)&&e.setAttribute(t,o[t]);return e}function qo(e,o){return o?{color:e.color,opacity:Math.round(e.opacity*10)/10,lineWidth:Math.round(o.lineWidth||e.lineWidth),key:[e.key,o.lineWidth].filter(t=>t).join("")}:e}function Ht(){return[3/64,4/64]}function Tt(e,o){return(e.lineWidth||10)*(o?.85:1)/64}function Ro(e){let o=e.modifiers?.hilite;return{key:o&&`hilite-${o.replace("#","")}`,color:o}}function Bo(e,o,t){return(e.opacity||1)*(t?.6:o?.9:1)}function qt(e){return(e?20:10)/64}function me(e,o){let t=Math.min(1,o.width/o.height),n=Math.min(1,o.height/o.width);return[(e[0]-3.5)*t,(3.5-e[1])*n]}function Rt(e,o){let t={from:[Math.floor(Math.min(e[0],o[0])),Math.floor(Math.min(e[1],o[1]))],to:[Math.ceil(Math.max(e[0],o[0])),Math.ceil(Math.max(e[1],o[1]))]};return S(y("rect"),{x:t.from[0],y:t.from[1],width:t.to[0]-t.from[0],height:t.to[1]-t.from[1],fill:"none",stroke:"none"})}function Ve(e,o,t=!0){let n=Math.atan2(o[1]-e[1],o[0]-e[0])+Math.PI;return t?(Math.round(n*8/Math.PI)+16)%16:n}function Bt(e,o){return Math.sqrt([e[0]-o[0],e[1]-o[1]].reduce((t,n)=>t+n*n,0))}function Oo(e,o,t){let n=Bt(e,o),r=Ve(e,o,!1);if(t&&(n-=33/64,t.size>1)){n-=10/64;let i=Ve(e,o);(t.has((i+1)%16)||t.has((i+15)%16))&&i&1&&(n-=.4)}return[e[0]-Math.cos(r)*n,e[1]-Math.sin(r)*n].map(i=>i+.5)}function Lo(e,o){e.innerHTML="",e.classList.add("cg-wrap");for(let s of ze)e.classList.toggle("orientation-"+s,o.orientation===s);e.classList.toggle("manipulable",!o.viewOnly);let t=x("cg-container");e.appendChild(t);let n=x("cg-board");t.appendChild(n);let r,i,l,u,d;if(o.drawable.visible&&([r,i]=["cg-shapes-below","cg-shapes"].map(s=>Vo(s,!0)),[l,u]=["cg-custom-below","cg-custom-svgs"].map(s=>Vo(s,!1)),d=x("cg-auto-pieces"),t.appendChild(r),t.appendChild(l),t.appendChild(i),t.appendChild(u),t.appendChild(d)),o.coordinates){let s=o.orientation==="black"?" black":"",c=o.ranksPosition==="left"?" left":"";if(o.coordinatesOnSquares){let g=o.orientation==="white"?m=>m+1:m=>8-m;z.forEach((m,b)=>t.appendChild(Le(I.map(p=>m+p),"squares rank"+g(b)+s+c)))}else t.appendChild(Le(I,"ranks"+s+c)),t.appendChild(Le(z,"files"+s))}let a;return o.draggable.enabled&&o.draggable.showGhost&&(a=x("piece","ghost"),Y(a,!1),t.appendChild(a)),{board:n,container:t,wrap:e,ghost:a,shapes:i,shapesBelow:r,custom:u,customBelow:l,autoPieces:d}}function Vo(e,o){let t=S(y("svg"),{class:e,viewBox:o?"-4 -4 8 8":"-3.5 -3.5 8 8",preserveAspectRatio:"xMidYMid slice"});return o&&t.appendChild(Ho()),t.appendChild(y("g")),t}function Le(e,o){let t=x("coords",o),n;for(let r of e)n=x("coord"),n.textContent=r,t.appendChild(n);return t}function Go(e,o){if(!e.dropmode.active)return;k(e),D(e);let t=e.dropmode.piece;if(t){e.pieces.set("a0",t);let n=T(o),r=n&&E(n,v(e),e.dom.bounds());r&&le(e,"a0",r)}e.dom.redraw()}function Wo(e,o){let t=e.dom.elements.board;if("ResizeObserver"in window&&new ResizeObserver(o).observe(e.dom.elements.wrap),(e.disableContextMenu||e.drawable.enabled)&&t.addEventListener("contextmenu",r=>r.preventDefault()),e.viewOnly)return;let n=Vt(e);t.addEventListener("touchstart",n,{passive:!1}),t.addEventListener("mousedown",n,{passive:!1})}function zo(e,o){let t=[];if("ResizeObserver"in window||t.push(oe(document.body,"chessground.resize",o)),!e.viewOnly){let n=Fo(e,Po,bo),r=Fo(e,Mo,ho);for(let l of["touchmove","mousemove"])t.push(oe(document,l,n));for(let l of["touchend","mouseup"])t.push(oe(document,l,r));let i=()=>e.dom.bounds.clear();t.push(oe(document,"scroll",i,{capture:!0,passive:!0})),t.push(oe(window,"resize",i,{passive:!0}))}return()=>t.forEach(n=>n())}function oe(e,o,t,n){return e.addEventListener(o,t,n),()=>e.removeEventListener(o,t,n)}var Vt=e=>o=>{e.draggable.current?$(e):e.drawable.current?qe(e):o.shiftKey||ie(o)?e.drawable.enabled&&fo(e,o):e.viewOnly||(e.dropmode.active?Go(e,o):So(e,o))},Fo=(e,o,t)=>n=>{e.drawable.current?e.drawable.enabled&&t(e,n):e.viewOnly||o(e,n)};function Io(e){let o=v(e),t=W(e.dom.bounds()),n=e.dom.elements.board,r=e.pieces,i=e.animation.current,l=i?i.plan.anims:new Map,u=i?i.plan.fadings:new Map,d=e.draggable.current,a=Ft(e),s=new Set,c=new Set,g=new Map,m=new Map,b,p,q,C,K,Z,be,A,he,ne;for(p=n.firstChild;p;){if(b=p.cgKey,Uo(p))if(q=r.get(b),K=l.get(b),Z=u.get(b),C=p.cgPiece,p.cgDragging&&(!d||d.orig!==b)&&(p.classList.remove("dragging"),M(p,t(f(b),o)),p.cgDragging=!1),!Z&&p.cgFading&&(p.cgFading=!1,p.classList.remove("fading")),q){if(K&&p.cgAnimating&&C===te(q)){let h=f(b);h[0]+=K[2],h[1]+=K[3],p.classList.add("anim"),M(p,t(h,o))}else p.cgAnimating&&(p.cgAnimating=!1,p.classList.remove("anim"),M(p,t(f(b),o)),e.addPieceZIndex&&(p.style.zIndex=Ge(f(b),o)));C===te(q)&&(!Z||!p.cgFading)?s.add(b):Z&&C===te(Z)?(p.classList.add("fading"),p.cgFading=!0):Fe(g,C,p)}else Fe(g,C,p);else if(Zo(p)){let h=p.className;a.get(b)===h?c.add(b):Fe(m,h,p)}p=p.nextSibling}for(let[h,_]of a)if(!c.has(h)){he=m.get(_),ne=he&&he.pop();let N=t(f(h),o);if(ne)ne.cgKey=h,M(ne,N);else{let H=x("square",_);H.cgKey=h,M(H,N),n.insertBefore(H,n.firstChild)}}for(let[h,_]of r)if(K=l.get(h),!s.has(h))if(be=g.get(te(_)),A=be&&be.pop(),A){A.cgKey=h,A.cgFading&&(A.classList.remove("fading"),A.cgFading=!1);let N=f(h);e.addPieceZIndex&&(A.style.zIndex=Ge(N,o)),K&&(A.cgAnimating=!0,A.classList.add("anim"),N[0]+=K[2],N[1]+=K[3]),M(A,t(N,o))}else{let N=te(_),H=x("piece",N),re=f(h);H.cgPiece=N,H.cgKey=h,K&&(H.cgAnimating=!0,re[0]+=K[2],re[1]+=K[3]),M(H,t(re,o)),e.addPieceZIndex&&(H.style.zIndex=Ge(re,o)),n.appendChild(H)}for(let h of g.values())$o(e,h);for(let h of m.values())$o(e,h)}function jo(e){let o=v(e),t=W(e.dom.bounds()),n=e.dom.elements.board.firstChild;for(;n;)(Uo(n)&&!n.cgAnimating||Zo(n))&&M(n,t(f(n.cgKey),o)),n=n.nextSibling}function We(e){let o=e.dom.elements.wrap.getBoundingClientRect(),t=e.dom.elements.container,n=o.height/o.width,r=Math.floor(o.width*window.devicePixelRatio/8)*8/window.devicePixelRatio,i=r*n;t.style.width=r+"px",t.style.height=i+"px",e.dom.bounds.clear(),e.addDimensionsCssVarsTo?.style.setProperty("---cg-width",r+"px"),e.addDimensionsCssVarsTo?.style.setProperty("---cg-height",i+"px")}var Uo=e=>e.tagName==="PIECE",Zo=e=>e.tagName==="SQUARE";function $o(e,o){for(let t of o)e.dom.elements.board.removeChild(t)}function Ge(e,o){let n=e[1];return`${o?10-n:3+n}`}var te=e=>`${e.color} ${e.role}`,Gt=(e,o)=>e.lastMove?.[1]&&!e.pieces.has(e.lastMove[1])&&e.lastMove[0][0]==="e"&&["h","a"].includes(e.lastMove[1][0])&&e.lastMove[0][1]===e.lastMove[1][1]&&Ye(...f(e.lastMove[0]),...f(e.lastMove[1])).some(t=>e.pieces.has(t))?(o>e.lastMove[0]?"g":"c")+o[1]:o;function Ft(e){let o=new Map;if(e.lastMove&&e.highlight.lastMove)for(let[r,i]of e.lastMove.entries())V(o,r===1?Gt(e,i):i,"last-move");if(e.check&&e.highlight.check&&V(o,e.check,"check"),e.selected&&(V(o,e.selected,"selected"),e.movable.showDests)){for(let r of e.movable.dests?.get(e.selected)??[])V(o,r,"move-dest"+(e.pieces.has(r)?" oc":""));for(let r of e.premovable.customDests?.get(e.selected)??e.premovable.dests??[])V(o,r,"premove-dest"+(e.pieces.has(r)?" oc":""))}let t=e.premovable.current;if(t)for(let r of t)V(o,r,"current-premove");else e.predroppable.current&&V(o,e.predroppable.current.key,"current-premove");let n=e.exploding;if(n)for(let r of n.keys)V(o,r,"exploding"+n.stage);return e.highlight.custom&&e.highlight.custom.forEach((r,i)=>{V(o,i,r)}),o}function V(e,o,t){let n=e.get(o);n?e.set(o,`${n} ${t}`):e.set(o,t)}function Fe(e,o,t){let n=e.get(o);n?n.push(t):e.set(o,[t])}function _o(e,o,t){let n=new Map,r=[];for(let u of e)n.set(u.hash,!1);let i=o.firstElementChild,l;for(;i;)l=i.getAttribute("cgHash"),n.has(l)?n.set(l,!0):r.push(i),i=i.nextElementSibling;for(let u of r)o.removeChild(u);for(let u of e)n.get(u.hash)||o.appendChild(t(u))}function Xo(e,o){let n=e.drawable.autoShapes.filter(r=>r.piece).map(r=>({shape:r,hash:zt(r),current:!1,pendingErase:!1}));_o(n,o,r=>Wt(e,r,e.dom.bounds()))}function Qo(e){let o=v(e),t=W(e.dom.bounds()),n=e.dom.elements.autoPieces?.firstChild;for(;n;)Se(n,t(f(n.cgKey),o),n.cgScale),n=n.nextSibling}function Wt(e,{shape:o,hash:t},n){let r=o.orig,i=o.piece?.role,l=o.piece?.color,u=o.piece?.scale,d=x("piece",`${i} ${l}`);return d.setAttribute("cgHash",t),d.cgKey=r,d.cgScale=u,Se(d,W(n)(f(r),v(e)),u),d}var zt=e=>[e.orig,e.piece?.role,e.piece?.color,e.piece?.scale].join(",");function Qn({el:e,config:o}){return It(e,o)}function It(e,o){let t=Eo();pe(t,o||{});function n(){let r="dom"in t?t.dom.unbind:void 0,i=Lo(e,t),l=ye(()=>i.board.getBoundingClientRect()),u=s=>{Io(a),i.autoPieces&&Xo(a,i.autoPieces),!s&&i.shapes&&To(a,i)},d=()=>{We(a),jo(a),i.autoPieces&&Qo(a)},a=t;return a.dom={elements:i,bounds:l,redraw:jt(u),redrawNow:u,unbind:r},a.drawable.prevSvgHash="",We(a),u(!1),Wo(a,d),r||(a.dom.unbind=zo(a,d)),a.events.insert&&a.events.insert(i),a}return Do(n(),n)}function jt(e){let o=!1;return()=>{o||(o=!0,requestAnimationFrame(()=>{e(),o=!1}))}}export{It as Chessground,Qn as initModule};
|
package/dist/config.d.ts
CHANGED
|
@@ -44,7 +44,6 @@ export interface Config {
|
|
|
44
44
|
castle?: boolean;
|
|
45
45
|
dests?: cg.Key[];
|
|
46
46
|
customDests?: cg.Dests;
|
|
47
|
-
unrestrictedPremoves?: boolean;
|
|
48
47
|
additionalPremoveRequirements?: cg.Mobility;
|
|
49
48
|
events?: {
|
|
50
49
|
set?: (orig: cg.Key, dest: cg.Key, metadata?: cg.SetPremoveMetadata) => void;
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,EAAE,IAAI,IAAI,OAAO,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,EAAE,IAAI,IAAI,OAAO,EAAE,MAAM,UAAU,CAAC;AA8F3C,MAAM,UAAU,cAAc,CAAC,KAAoB,EAAE,MAAc;IACjE,IAAI,MAAM,CAAC,SAAS,EAAE,CAAC;QACrB,SAAS,CAAC,KAAK,CAAC,SAAS,EAAE,MAAM,CAAC,SAAS,CAAC,CAAC;QAC7C,oCAAoC;QACpC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,QAAQ,IAAI,CAAC,CAAC,GAAG,EAAE;YAAE,KAAK,CAAC,SAAS,CAAC,OAAO,GAAG,KAAK,CAAC;IAC5E,CAAC;AACH,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,KAAoB,EAAE,MAAc;IAC5D,0DAA0D;IAC1D,IAAI,MAAM,CAAC,OAAO,EAAE,KAA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C,CAAU;IAC/B,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,IAAI;QAAE,OAAO,KAAK,CAAC;IACtD,MAAM,KAAK,GAAG,MAAM,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC;IACvC,OAAO,KAAK,KAAK,MAAM,CAAC,SAAS,IAAI,KAAK,KAAK,IAAI,CAAC;AACtD,CAAC"}
|
package/dist/premove.js
CHANGED
|
@@ -1,148 +1,22 @@
|
|
|
1
1
|
import * as util from './util.js';
|
|
2
|
-
const
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const step = piece.color === 'white' ? 1 : -1;
|
|
10
|
-
const startPos = util.key2pos(pawnStart);
|
|
11
|
-
const destPos = util.key2pos(dest);
|
|
12
|
-
return (util.pawnDirAdvance(...startPos, ...destPos, piece.color === 'white') &&
|
|
13
|
-
!anyPieceBetween(startPos, [destPos[0], destPos[1] + step], ctx.allPieces));
|
|
14
|
-
};
|
|
15
|
-
const canEnemyPawnCaptureOnSquare = (pawnStart, dest, ctx) => {
|
|
16
|
-
const enemyPawn = ctx.enemies.get(pawnStart);
|
|
17
|
-
return (enemyPawn?.role === 'pawn' &&
|
|
18
|
-
util.pawnDirCapture(...util.key2pos(pawnStart), ...util.key2pos(dest), enemyPawn.color === 'white') &&
|
|
19
|
-
(ctx.friendlies.has(dest) ||
|
|
20
|
-
canBeCapturedBySomeEnemyEnPassant(util.squareShiftedVertically(dest, enemyPawn.color === 'white' ? -1 : 1), ctx.friendlies, ctx.enemies, ctx.lastMove)));
|
|
21
|
-
};
|
|
22
|
-
const canSomeEnemyPawnAdvanceToDest = (ctx) => [...ctx.enemies.keys()].some(key => canEnemyPawnAdvanceToSquare(key, ctx.dest.key, ctx));
|
|
23
|
-
const isDestControlledByEnemy = (ctx, pieceRolesExclude) => {
|
|
24
|
-
const square = ctx.dest.pos;
|
|
25
|
-
return [...ctx.enemies].some(([key, piece]) => {
|
|
26
|
-
const piecePos = util.key2pos(key);
|
|
27
|
-
return (!pieceRolesExclude?.includes(piece.role) &&
|
|
28
|
-
((piece.role === 'pawn' && util.pawnDirCapture(...piecePos, ...square, piece.color === 'white')) ||
|
|
29
|
-
(piece.role === 'knight' && util.knightDir(...piecePos, ...square)) ||
|
|
30
|
-
(piece.role === 'bishop' && util.bishopDir(...piecePos, ...square)) ||
|
|
31
|
-
(piece.role === 'rook' && util.rookDir(...piecePos, ...square)) ||
|
|
32
|
-
(piece.role === 'queen' && util.queenDir(...piecePos, ...square)) ||
|
|
33
|
-
(piece.role === 'king' && util.kingDirNonCastling(...piecePos, ...square))) &&
|
|
34
|
-
(!['bishop', 'rook', 'queen'].includes(piece.role) || !anyPieceBetween(piecePos, square, ctx.allPieces)));
|
|
35
|
-
});
|
|
36
|
-
};
|
|
37
|
-
const isFriendlyOnDestAndAttacked = (ctx) => isDestOccupiedByFriendly(ctx) &&
|
|
38
|
-
(canBeCapturedBySomeEnemyEnPassant(ctx.dest.key, ctx.friendlies, ctx.enemies, ctx.lastMove) ||
|
|
39
|
-
isDestControlledByEnemy(ctx));
|
|
40
|
-
const canBeCapturedBySomeEnemyEnPassant = (potentialSquareOfFriendlyPawn, friendlies, enemies, lastMove) => {
|
|
41
|
-
if (!potentialSquareOfFriendlyPawn || (lastMove && potentialSquareOfFriendlyPawn !== lastMove[1]))
|
|
42
|
-
return false;
|
|
43
|
-
const pos = util.key2pos(potentialSquareOfFriendlyPawn);
|
|
44
|
-
const friendly = friendlies.get(potentialSquareOfFriendlyPawn);
|
|
45
|
-
return (friendly?.role === 'pawn' &&
|
|
46
|
-
pos[1] === (friendly.color === 'white' ? 3 : 4) &&
|
|
47
|
-
(!lastMove || util.diff(util.key2pos(lastMove[0])[1], pos[1]) === 2) &&
|
|
48
|
-
[1, -1].some(delta => {
|
|
49
|
-
const k = util.pos2key([pos[0] + delta, pos[1]]);
|
|
50
|
-
return !!k && enemies.get(k)?.role === 'pawn';
|
|
51
|
-
}));
|
|
52
|
-
};
|
|
53
|
-
const isPathClearEnoughOfFriendliesForPremove = (ctx, isPawnAdvance) => {
|
|
54
|
-
if (ctx.unrestrictedPremoves)
|
|
55
|
-
return true;
|
|
56
|
-
const squaresBetween = util.squaresBetween(...ctx.orig.pos, ...ctx.dest.pos);
|
|
57
|
-
if (isPawnAdvance)
|
|
58
|
-
squaresBetween.push(ctx.dest.key);
|
|
59
|
-
const squaresOfFriendliesBetween = squaresBetween.filter(s => ctx.friendlies.has(s));
|
|
60
|
-
if (!squaresOfFriendliesBetween.length)
|
|
61
|
-
return true;
|
|
62
|
-
const firstSquareOfFriendliesBetween = squaresOfFriendliesBetween[0];
|
|
63
|
-
const nextSquare = util.squareShiftedVertically(firstSquareOfFriendliesBetween, ctx.color === 'white' ? -1 : 1);
|
|
64
|
-
return (squaresOfFriendliesBetween.length === 1 &&
|
|
65
|
-
canBeCapturedBySomeEnemyEnPassant(firstSquareOfFriendliesBetween, ctx.friendlies, ctx.enemies, ctx.lastMove) &&
|
|
66
|
-
!!nextSquare &&
|
|
67
|
-
!squaresBetween.includes(nextSquare));
|
|
68
|
-
};
|
|
69
|
-
const isPathClearEnoughOfEnemiesForPremove = (ctx, isPawnAdvance) => {
|
|
70
|
-
if (ctx.unrestrictedPremoves)
|
|
71
|
-
return true;
|
|
72
|
-
const squaresBetween = util.squaresBetween(...ctx.orig.pos, ...ctx.dest.pos);
|
|
73
|
-
if (isPawnAdvance)
|
|
74
|
-
squaresBetween.push(ctx.dest.key);
|
|
75
|
-
const squaresOfEnemiesBetween = squaresBetween.filter(s => ctx.enemies.has(s));
|
|
76
|
-
if (squaresOfEnemiesBetween.length > 1)
|
|
77
|
-
return false;
|
|
78
|
-
if (!squaresOfEnemiesBetween.length)
|
|
79
|
-
return true;
|
|
80
|
-
const enemySquare = squaresOfEnemiesBetween[0];
|
|
81
|
-
const enemy = ctx.enemies.get(enemySquare);
|
|
82
|
-
if (!enemy || enemy.role !== 'pawn')
|
|
83
|
-
return true;
|
|
84
|
-
const enemyStep = enemy.color === 'white' ? 1 : -1;
|
|
85
|
-
const squareAbove = util.squareShiftedVertically(enemySquare, enemyStep);
|
|
86
|
-
const enemyPawnDests = squareAbove
|
|
87
|
-
? [
|
|
88
|
-
...util.adjacentSquares(squareAbove).filter(s => canEnemyPawnCaptureOnSquare(enemySquare, s, ctx)),
|
|
89
|
-
...[squareAbove, util.squareShiftedVertically(squareAbove, enemyStep)]
|
|
90
|
-
.filter(s => !!s)
|
|
91
|
-
.filter(s => canEnemyPawnAdvanceToSquare(enemySquare, s, ctx)),
|
|
92
|
-
]
|
|
93
|
-
: [];
|
|
94
|
-
const badSquares = [...squaresBetween, ctx.orig.key];
|
|
95
|
-
return enemyPawnDests.some(square => !badSquares.includes(square));
|
|
96
|
-
};
|
|
97
|
-
const isPathClearEnoughForPremove = (ctx, isPawnAdvance) => isPathClearEnoughOfFriendliesForPremove(ctx, isPawnAdvance) &&
|
|
98
|
-
isPathClearEnoughOfEnemiesForPremove(ctx, isPawnAdvance);
|
|
99
|
-
const pawn = (ctx) => {
|
|
100
|
-
const step = ctx.color === 'white' ? 1 : -1;
|
|
101
|
-
if (util.diff(ctx.orig.pos[0], ctx.dest.pos[0]) > 1)
|
|
102
|
-
return false;
|
|
103
|
-
if (!util.diff(ctx.orig.pos[0], ctx.dest.pos[0]))
|
|
104
|
-
return (util.pawnDirAdvance(...ctx.orig.pos, ...ctx.dest.pos, ctx.color === 'white') &&
|
|
105
|
-
isPathClearEnoughForPremove(ctx, true));
|
|
106
|
-
if (ctx.dest.pos[1] !== ctx.orig.pos[1] + step)
|
|
107
|
-
return false;
|
|
108
|
-
if (ctx.unrestrictedPremoves || isDestOccupiedByEnemy(ctx))
|
|
109
|
-
return true;
|
|
110
|
-
if (isDestOccupiedByFriendly(ctx))
|
|
111
|
-
return isDestControlledByEnemy(ctx);
|
|
112
|
-
else
|
|
113
|
-
return (canSomeEnemyPawnAdvanceToDest(ctx) ||
|
|
114
|
-
canBeCapturedBySomeEnemyEnPassant(util.pos2key([ctx.dest.pos[0], ctx.dest.pos[1] + step]), ctx.friendlies, ctx.enemies, ctx.lastMove) ||
|
|
115
|
-
isDestControlledByEnemy(ctx, ['pawn']));
|
|
116
|
-
};
|
|
117
|
-
const knight = (ctx) => util.knightDir(...ctx.orig.pos, ...ctx.dest.pos) &&
|
|
118
|
-
(ctx.unrestrictedPremoves || !isDestOccupiedByFriendly(ctx) || isFriendlyOnDestAndAttacked(ctx));
|
|
119
|
-
const bishop = (ctx) => util.bishopDir(...ctx.orig.pos, ...ctx.dest.pos) &&
|
|
120
|
-
isPathClearEnoughForPremove(ctx, false) &&
|
|
121
|
-
(ctx.unrestrictedPremoves || !isDestOccupiedByFriendly(ctx) || isFriendlyOnDestAndAttacked(ctx));
|
|
122
|
-
const rook = (ctx) => util.rookDir(...ctx.orig.pos, ...ctx.dest.pos) &&
|
|
123
|
-
isPathClearEnoughForPremove(ctx, false) &&
|
|
124
|
-
(ctx.unrestrictedPremoves || !isDestOccupiedByFriendly(ctx) || isFriendlyOnDestAndAttacked(ctx));
|
|
2
|
+
const pawn = (ctx) => util.diff(ctx.orig.pos[0], ctx.dest.pos[0]) <= 1 &&
|
|
3
|
+
(util.diff(ctx.orig.pos[0], ctx.dest.pos[0]) === 1
|
|
4
|
+
? ctx.dest.pos[1] === ctx.orig.pos[1] + (ctx.color === 'white' ? 1 : -1)
|
|
5
|
+
: util.pawnDirAdvance(...ctx.orig.pos, ...ctx.dest.pos, ctx.color === 'white'));
|
|
6
|
+
const knight = (ctx) => util.knightDir(...ctx.orig.pos, ...ctx.dest.pos);
|
|
7
|
+
const bishop = (ctx) => util.bishopDir(...ctx.orig.pos, ...ctx.dest.pos);
|
|
8
|
+
const rook = (ctx) => util.rookDir(...ctx.orig.pos, ...ctx.dest.pos);
|
|
125
9
|
const queen = (ctx) => bishop(ctx) || rook(ctx);
|
|
126
|
-
const king = (ctx) =>
|
|
127
|
-
(ctx.
|
|
128
|
-
(ctx.canCastle &&
|
|
129
|
-
ctx.orig.pos[1] === ctx.dest.pos[1] &&
|
|
10
|
+
const king = (ctx) => util.kingDirNonCastling(...ctx.orig.pos, ...ctx.dest.pos) ||
|
|
11
|
+
(ctx.orig.pos[1] === ctx.dest.pos[1] &&
|
|
130
12
|
ctx.orig.pos[1] === (ctx.color === 'white' ? 0 : 7) &&
|
|
131
13
|
((ctx.orig.pos[0] === 4 &&
|
|
132
14
|
((ctx.dest.pos[0] === 2 && ctx.rookFilesFriendlies.includes(0)) ||
|
|
133
15
|
(ctx.dest.pos[0] === 6 && ctx.rookFilesFriendlies.includes(7)))) ||
|
|
134
|
-
ctx.rookFilesFriendlies.includes(ctx.dest.pos[0]))
|
|
135
|
-
(ctx.unrestrictedPremoves ||
|
|
136
|
-
/* The following checks if no non-rook friendly piece is in the way between the king and its castling destination.
|
|
137
|
-
Note that for the Chess960 edge case of Kb1 "long castling", the check passes even if there is a piece in the way
|
|
138
|
-
on c1. But this is fine, since premoving from b1 to a1 as a normal move would have already returned true. */
|
|
139
|
-
util
|
|
140
|
-
.squaresBetween(...ctx.orig.pos, ctx.dest.pos[0] > ctx.orig.pos[0] ? 7 : 1, ctx.dest.pos[1])
|
|
141
|
-
.map(s => ctx.allPieces.get(s))
|
|
142
|
-
.every(p => !p || util.samePiece(p, { role: 'rook', color: ctx.color }))));
|
|
16
|
+
ctx.rookFilesFriendlies.includes(ctx.dest.pos[0])));
|
|
143
17
|
const mobilityByRole = { pawn, knight, bishop, rook, queen, king };
|
|
144
18
|
export function premove(state, key) {
|
|
145
|
-
const pieces = state.pieces
|
|
19
|
+
const pieces = state.pieces;
|
|
146
20
|
const piece = pieces.get(key);
|
|
147
21
|
if (!piece || piece.color === state.turnColor)
|
|
148
22
|
return [];
|
|
@@ -152,14 +26,13 @@ export function premove(state, key) {
|
|
|
152
26
|
allPieces: pieces,
|
|
153
27
|
friendlies: friendlies,
|
|
154
28
|
enemies: enemies,
|
|
155
|
-
unrestrictedPremoves: unrestrictedPremoves,
|
|
156
29
|
color: color,
|
|
157
|
-
canCastle: canCastle,
|
|
158
30
|
rookFilesFriendlies: Array.from(pieces)
|
|
159
31
|
.filter(([k, p]) => k[1] === (color === 'white' ? '1' : '8') && p.color === color && p.role === 'rook')
|
|
160
32
|
.map(([k]) => util.key2pos(k)[0]),
|
|
161
33
|
lastMove: state.lastMove,
|
|
162
34
|
};
|
|
35
|
+
// todo - remove more properties from MobilityContext that aren't used in this file, and adjust as needed in lila.
|
|
163
36
|
return util.allPosAndKey.filter(dest => mobility({ ...partialCtx, dest })).map(pk => pk.key);
|
|
164
37
|
}
|
|
165
38
|
//# sourceMappingURL=premove.js.map
|
package/dist/premove.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"premove.js","sourceRoot":"","sources":["../src/premove.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAKlC,MAAM,wBAAwB,GAAG,CAAC,GAAoB,EAAW,EAAE,CAAC,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAErG,MAAM,qBAAqB,GAAG,CAAC,GAAoB,EAAW,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAE/F,MAAM,eAAe,GAAG,CAAC,IAAY,EAAE,IAAY,EAAE,MAAiB,EAAW,EAAE,CACjF,IAAI,CAAC,cAAc,CAAC,GAAG,IAAI,EAAE,GAAG,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AAEjE,MAAM,2BAA2B,GAAG,CAAC,SAAiB,EAAE,IAAY,EAAE,GAAoB,EAAW,EAAE;IACrG,MAAM,KAAK,GAAG,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;I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C,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,KAAK,KAAK,KAAK,IAAI,CAAC,CAAC,IAAI,KAAK,MAAM,CAC/F;aACA,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACnC,QAAQ,EAAE,KAAK,CAAC,QAAQ;KACzB,CAAC;IACJ,kHAAkH;IAClH,OAAO,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,QAAQ,CAAC,EAAE,GAAG,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;AAC/F,CAAC"}
|
package/dist/render.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { key2pos, createEl, posToTranslate as posToTranslateFromBounds, translate } from './util.js';
|
|
2
|
+
import * as util from './util.js';
|
|
2
3
|
import { whitePov } from './board.js';
|
|
3
4
|
// ported from https://github.com/lichess-org/lichobile/blob/master/src/chessground/render.ts
|
|
4
5
|
// in case of bugs, blame @veloce
|
|
@@ -44,24 +45,19 @@ export function render(s) {
|
|
|
44
45
|
el.style.zIndex = posZIndex(key2pos(k), asWhite);
|
|
45
46
|
}
|
|
46
47
|
// same piece: flag as same
|
|
47
|
-
if (elPieceName === pieceNameOf(pieceAtKey) && (!fading || !el.cgFading))
|
|
48
|
+
if (elPieceName === pieceNameOf(pieceAtKey) && (!fading || !el.cgFading))
|
|
48
49
|
samePieces.add(k);
|
|
49
|
-
}
|
|
50
50
|
// different piece: flag as moved unless it is a fading piece
|
|
51
|
-
else {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
el.cgFading = true;
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
57
|
-
appendValue(movedPieces, elPieceName, el);
|
|
58
|
-
}
|
|
51
|
+
else if (fading && elPieceName === pieceNameOf(fading)) {
|
|
52
|
+
el.classList.add('fading');
|
|
53
|
+
el.cgFading = true;
|
|
59
54
|
}
|
|
55
|
+
else
|
|
56
|
+
appendValue(movedPieces, elPieceName, el);
|
|
60
57
|
}
|
|
61
58
|
// no piece: flag as moved
|
|
62
|
-
else
|
|
59
|
+
else
|
|
63
60
|
appendValue(movedPieces, elPieceName, el);
|
|
64
|
-
}
|
|
65
61
|
}
|
|
66
62
|
else if (isSquareNode(el)) {
|
|
67
63
|
const cn = el.className;
|
|
@@ -176,27 +172,28 @@ function posZIndex(pos, asWhite) {
|
|
|
176
172
|
return `${z}`;
|
|
177
173
|
}
|
|
178
174
|
const pieceNameOf = (piece) => `${piece.color} ${piece.role}`;
|
|
175
|
+
const normalizeLastMoveStandardRookCastle = (s, k) => !!s.lastMove?.[1] &&
|
|
176
|
+
!s.pieces.has(s.lastMove[1]) &&
|
|
177
|
+
s.lastMove[0][0] === 'e' &&
|
|
178
|
+
['h', 'a'].includes(s.lastMove[1][0]) &&
|
|
179
|
+
s.lastMove[0][1] === s.lastMove[1][1] &&
|
|
180
|
+
util.squaresBetween(...key2pos(s.lastMove[0]), ...key2pos(s.lastMove[1])).some(sq => s.pieces.has(sq))
|
|
181
|
+
? ((k > s.lastMove[0] ? 'g' : 'c') + k[1])
|
|
182
|
+
: k;
|
|
179
183
|
function computeSquareClasses(s) {
|
|
180
184
|
const squares = new Map();
|
|
181
185
|
if (s.lastMove && s.highlight.lastMove)
|
|
182
|
-
for (const k of s.lastMove)
|
|
183
|
-
addSquare(squares, k, 'last-move');
|
|
184
|
-
}
|
|
186
|
+
for (const [i, k] of s.lastMove.entries())
|
|
187
|
+
addSquare(squares, i === 1 ? normalizeLastMoveStandardRookCastle(s, k) : k, 'last-move');
|
|
185
188
|
if (s.check && s.highlight.check)
|
|
186
189
|
addSquare(squares, s.check, 'check');
|
|
187
190
|
if (s.selected) {
|
|
188
191
|
addSquare(squares, s.selected, 'selected');
|
|
189
192
|
if (s.movable.showDests) {
|
|
190
|
-
const
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
}
|
|
195
|
-
const pDests = s.premovable.customDests?.get(s.selected) ?? s.premovable.dests;
|
|
196
|
-
if (pDests)
|
|
197
|
-
for (const k of pDests) {
|
|
198
|
-
addSquare(squares, k, 'premove-dest' + (s.pieces.has(k) ? ' oc' : ''));
|
|
199
|
-
}
|
|
193
|
+
for (const k of s.movable.dests?.get(s.selected) ?? [])
|
|
194
|
+
addSquare(squares, k, 'move-dest' + (s.pieces.has(k) ? ' oc' : ''));
|
|
195
|
+
for (const k of s.premovable.customDests?.get(s.selected) ?? s.premovable.dests ?? [])
|
|
196
|
+
addSquare(squares, k, 'premove-dest' + (s.pieces.has(k) ? ' oc' : ''));
|
|
200
197
|
}
|
|
201
198
|
}
|
|
202
199
|
const premove = s.premovable.current;
|
package/dist/render.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render.js","sourceRoot":"","sources":["../src/render.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,cAAc,IAAI,wBAAwB,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACrG,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAOtC,6FAA6F;AAC7F,iCAAiC;AACjC,MAAM,UAAU,MAAM,CAAC,CAAQ;IAC7B,MAAM,OAAO,GAAY,QAAQ,CAAC,CAAC,CAAC,EAClC,cAAc,GAAG,wBAAwB,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC,EACzD,OAAO,GAAgB,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,EAC3C,MAAM,GAAc,CAAC,CAAC,MAAM,EAC5B,OAAO,GAA4B,CAAC,CAAC,SAAS,CAAC,OAAO,EACtD,KAAK,GAAgB,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,KA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AAE,SAAS,CAAC,OAAO,EAAE,CAAC,EAAE,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC;IAE5E,IAAI,CAAC,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC;QACvB,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAS,EAAE,CAAS,EAAE,EAAE;YAClD,SAAS,CAAC,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QAC3B,CAAC,CAAC,CAAC;IACL,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,SAAS,SAAS,CAAC,OAAyB,EAAE,GAAW,EAAE,KAAa;IACtE,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACjC,IAAI,OAAO;QAAE,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,OAAO,IAAI,KAAK,EAAE,CAAC,CAAC;;QAChD,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;AAC/B,CAAC;AAED,SAAS,WAAW,CAAO,GAAgB,EAAE,GAAM,EAAE,KAAQ;IAC3D,MAAM,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACzB,IAAI,GAAG;QAAE,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;;QACpB,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;AAC7B,CAAC"}
|
package/dist/state.d.ts
CHANGED
|
@@ -49,7 +49,6 @@ export interface HeadlessState {
|
|
|
49
49
|
dests?: cg.Key[];
|
|
50
50
|
customDests?: cg.Dests;
|
|
51
51
|
current?: cg.KeyPair;
|
|
52
|
-
unrestrictedPremoves?: boolean;
|
|
53
52
|
additionalPremoveRequirements: cg.Mobility;
|
|
54
53
|
events: {
|
|
55
54
|
set?: (orig: cg.Key, dest: cg.Key, metadata?: cg.SetPremoveMetadata) => void;
|
package/dist/state.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state.js","sourceRoot":"","sources":["../src/state.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC;AAIhC,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"state.js","sourceRoot":"","sources":["../src/state.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC;AAIhC,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AA4GlC,MAAM,UAAU,QAAQ;IACtB,OAAO;QACL,MAAM,EAAE,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC;QAC7B,WAAW,EAAE,OAAO;QACpB,SAAS,EAAE,OAAO;QAClB,WAAW,EAAE,IAAI;QACjB,oBAAoB,EAAE,KAAK;QAC3B,aAAa,EAAE,OAAO;QACtB,UAAU,EAAE,IAAI;QAChB,QAAQ,EAAE,KAAK;QACf,kBAAkB,EAAE,KAAK;QACzB,cAAc,EAAE,KAAK;QACrB,gBAAgB,EAAE,KAAK;QACvB,iBAAiB,EAAE,CAAC;QACpB,QAAQ,EAAE,KAAK;QACf,cAAc,EAAE,KAAK;QACrB,SAAS,EAAE;YACT,QAAQ,EAAE,IAAI;YACd,KAAK,EAAE,IAAI;SACZ;QACD,SAAS,EAAE;YACT,OAAO,EAAE,IAAI;YACb,QAAQ,EAAE,GAAG;SACd;QACD,OAAO,EAAE;YACP,IAAI,EAAE,IAAI;YACV,KAAK,EAAE,MAAM;YACb,SAAS,EAAE,IAAI;YACf,MAAM,EAAE,EAAE;YACV,UAAU,EAAE,IAAI;SACjB;QACD,UAAU,EAAE;YACV,OAAO,EAAE,IAAI;YACb,SAAS,EAAE,IAAI;YACf,MAAM,EAAE,IAAI;YACZ,6BAA6B,EAAE,CAAC,CAAC,EAAE,CAAC,IAAI;YACxC,MAAM,EAAE,EAAE;SACX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AAE,EAAE,EAAE;gBACtE,SAAS,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,EAAE,EAAE;gBACvE,OAAO,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,EAAE,EAAE;gBACrE,QAAQ,EAAE;oBACR,GAAG,EAAE,KAAK;oBACV,KAAK,EAAE,SAAS;oBAChB,OAAO,EAAE,IAAI;oBACb,SAAS,EAAE,EAAE;iBACd;gBACD,MAAM,EAAE,EAAE,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE;gBACzE,IAAI,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,EAAE,EAAE;gBACpE,KAAK,EAAE,EAAE,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE;gBAClE,SAAS,EAAE,EAAE,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,EAAE,EAAE;aAC1E;YACD,WAAW,EAAE,EAAE;SAChB;QACD,IAAI,EAAE,KAAK,EAAE;KACd,CAAC;AACJ,CAAC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -106,9 +106,7 @@ export type MobilityContext = {
|
|
|
106
106
|
allPieces: Pieces;
|
|
107
107
|
friendlies: Pieces;
|
|
108
108
|
enemies: Pieces;
|
|
109
|
-
unrestrictedPremoves: boolean;
|
|
110
109
|
color: Color;
|
|
111
|
-
canCastle: boolean;
|
|
112
110
|
rookFilesFriendlies: number[];
|
|
113
111
|
lastMove: Key[] | undefined;
|
|
114
112
|
};
|
package/package.json
CHANGED
package/src/config.ts
CHANGED
|
@@ -47,7 +47,6 @@ export interface Config {
|
|
|
47
47
|
castle?: boolean; // whether to allow king castle premoves
|
|
48
48
|
dests?: cg.Key[]; // premove destinations for the current selection
|
|
49
49
|
customDests?: cg.Dests; // use custom valid premoves. {"a2" ["a3" "a4"] "b1" ["a3" "c3"]}
|
|
50
|
-
unrestrictedPremoves?: boolean; // if falsy, the positions of friendly pieces will be used to trim premove options
|
|
51
50
|
additionalPremoveRequirements?: cg.Mobility;
|
|
52
51
|
events?: {
|
|
53
52
|
set?: (orig: cg.Key, dest: cg.Key, metadata?: cg.SetPremoveMetadata) => void; // called after the premove has been set
|
package/src/premove.ts
CHANGED
|
@@ -3,204 +3,33 @@ import * as cg from './types.js';
|
|
|
3
3
|
import { HeadlessState } from './state.js';
|
|
4
4
|
import { Mobility, MobilityContext } from './types.js';
|
|
5
5
|
|
|
6
|
-
const
|
|
6
|
+
const pawn: Mobility = (ctx: MobilityContext) =>
|
|
7
|
+
util.diff(ctx.orig.pos[0], ctx.dest.pos[0]) <= 1 &&
|
|
8
|
+
(util.diff(ctx.orig.pos[0], ctx.dest.pos[0]) === 1
|
|
9
|
+
? ctx.dest.pos[1] === ctx.orig.pos[1] + (ctx.color === 'white' ? 1 : -1)
|
|
10
|
+
: util.pawnDirAdvance(...ctx.orig.pos, ...ctx.dest.pos, ctx.color === 'white'));
|
|
7
11
|
|
|
8
|
-
const
|
|
12
|
+
const knight: Mobility = (ctx: MobilityContext) => util.knightDir(...ctx.orig.pos, ...ctx.dest.pos);
|
|
9
13
|
|
|
10
|
-
const
|
|
11
|
-
util.squaresBetween(...orig, ...dest).some(s => pieces.has(s));
|
|
14
|
+
const bishop: Mobility = (ctx: MobilityContext) => util.bishopDir(...ctx.orig.pos, ...ctx.dest.pos);
|
|
12
15
|
|
|
13
|
-
const
|
|
14
|
-
const piece = ctx.enemies.get(pawnStart);
|
|
15
|
-
if (piece?.role !== 'pawn') return false;
|
|
16
|
-
const step = piece.color === 'white' ? 1 : -1;
|
|
17
|
-
const startPos = util.key2pos(pawnStart);
|
|
18
|
-
const destPos = util.key2pos(dest);
|
|
19
|
-
return (
|
|
20
|
-
util.pawnDirAdvance(...startPos, ...destPos, piece.color === 'white') &&
|
|
21
|
-
!anyPieceBetween(startPos, [destPos[0], destPos[1] + step], ctx.allPieces)
|
|
22
|
-
);
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
const canEnemyPawnCaptureOnSquare = (pawnStart: cg.Key, dest: cg.Key, ctx: MobilityContext): boolean => {
|
|
26
|
-
const enemyPawn = ctx.enemies.get(pawnStart);
|
|
27
|
-
return (
|
|
28
|
-
enemyPawn?.role === 'pawn' &&
|
|
29
|
-
util.pawnDirCapture(...util.key2pos(pawnStart), ...util.key2pos(dest), enemyPawn.color === 'white') &&
|
|
30
|
-
(ctx.friendlies.has(dest) ||
|
|
31
|
-
canBeCapturedBySomeEnemyEnPassant(
|
|
32
|
-
util.squareShiftedVertically(dest, enemyPawn.color === 'white' ? -1 : 1),
|
|
33
|
-
ctx.friendlies,
|
|
34
|
-
ctx.enemies,
|
|
35
|
-
ctx.lastMove,
|
|
36
|
-
))
|
|
37
|
-
);
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
const canSomeEnemyPawnAdvanceToDest = (ctx: MobilityContext): boolean =>
|
|
41
|
-
[...ctx.enemies.keys()].some(key => canEnemyPawnAdvanceToSquare(key, ctx.dest.key, ctx));
|
|
42
|
-
|
|
43
|
-
const isDestControlledByEnemy = (ctx: MobilityContext, pieceRolesExclude?: cg.Role[]): boolean => {
|
|
44
|
-
const square: cg.Pos = ctx.dest.pos;
|
|
45
|
-
return [...ctx.enemies].some(([key, piece]) => {
|
|
46
|
-
const piecePos = util.key2pos(key);
|
|
47
|
-
return (
|
|
48
|
-
!pieceRolesExclude?.includes(piece.role) &&
|
|
49
|
-
((piece.role === 'pawn' && util.pawnDirCapture(...piecePos, ...square, piece.color === 'white')) ||
|
|
50
|
-
(piece.role === 'knight' && util.knightDir(...piecePos, ...square)) ||
|
|
51
|
-
(piece.role === 'bishop' && util.bishopDir(...piecePos, ...square)) ||
|
|
52
|
-
(piece.role === 'rook' && util.rookDir(...piecePos, ...square)) ||
|
|
53
|
-
(piece.role === 'queen' && util.queenDir(...piecePos, ...square)) ||
|
|
54
|
-
(piece.role === 'king' && util.kingDirNonCastling(...piecePos, ...square))) &&
|
|
55
|
-
(!['bishop', 'rook', 'queen'].includes(piece.role) || !anyPieceBetween(piecePos, square, ctx.allPieces))
|
|
56
|
-
);
|
|
57
|
-
});
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
const isFriendlyOnDestAndAttacked = (ctx: MobilityContext): boolean =>
|
|
61
|
-
isDestOccupiedByFriendly(ctx) &&
|
|
62
|
-
(canBeCapturedBySomeEnemyEnPassant(ctx.dest.key, ctx.friendlies, ctx.enemies, ctx.lastMove) ||
|
|
63
|
-
isDestControlledByEnemy(ctx));
|
|
64
|
-
|
|
65
|
-
const canBeCapturedBySomeEnemyEnPassant = (
|
|
66
|
-
potentialSquareOfFriendlyPawn: cg.Key | undefined,
|
|
67
|
-
friendlies: cg.Pieces,
|
|
68
|
-
enemies: cg.Pieces,
|
|
69
|
-
lastMove?: cg.Key[],
|
|
70
|
-
): boolean => {
|
|
71
|
-
if (!potentialSquareOfFriendlyPawn || (lastMove && potentialSquareOfFriendlyPawn !== lastMove[1]))
|
|
72
|
-
return false;
|
|
73
|
-
const pos = util.key2pos(potentialSquareOfFriendlyPawn);
|
|
74
|
-
const friendly = friendlies.get(potentialSquareOfFriendlyPawn);
|
|
75
|
-
return (
|
|
76
|
-
friendly?.role === 'pawn' &&
|
|
77
|
-
pos[1] === (friendly.color === 'white' ? 3 : 4) &&
|
|
78
|
-
(!lastMove || util.diff(util.key2pos(lastMove[0])[1], pos[1]) === 2) &&
|
|
79
|
-
[1, -1].some(delta => {
|
|
80
|
-
const k = util.pos2key([pos[0] + delta, pos[1]]);
|
|
81
|
-
return !!k && enemies.get(k)?.role === 'pawn';
|
|
82
|
-
})
|
|
83
|
-
);
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
const isPathClearEnoughOfFriendliesForPremove = (ctx: MobilityContext, isPawnAdvance: boolean): boolean => {
|
|
87
|
-
if (ctx.unrestrictedPremoves) return true;
|
|
88
|
-
const squaresBetween = util.squaresBetween(...ctx.orig.pos, ...ctx.dest.pos);
|
|
89
|
-
if (isPawnAdvance) squaresBetween.push(ctx.dest.key);
|
|
90
|
-
const squaresOfFriendliesBetween = squaresBetween.filter(s => ctx.friendlies.has(s));
|
|
91
|
-
if (!squaresOfFriendliesBetween.length) return true;
|
|
92
|
-
const firstSquareOfFriendliesBetween = squaresOfFriendliesBetween[0];
|
|
93
|
-
const nextSquare = util.squareShiftedVertically(
|
|
94
|
-
firstSquareOfFriendliesBetween,
|
|
95
|
-
ctx.color === 'white' ? -1 : 1,
|
|
96
|
-
);
|
|
97
|
-
return (
|
|
98
|
-
squaresOfFriendliesBetween.length === 1 &&
|
|
99
|
-
canBeCapturedBySomeEnemyEnPassant(
|
|
100
|
-
firstSquareOfFriendliesBetween,
|
|
101
|
-
ctx.friendlies,
|
|
102
|
-
ctx.enemies,
|
|
103
|
-
ctx.lastMove,
|
|
104
|
-
) &&
|
|
105
|
-
!!nextSquare &&
|
|
106
|
-
!squaresBetween.includes(nextSquare)
|
|
107
|
-
);
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
const isPathClearEnoughOfEnemiesForPremove = (ctx: MobilityContext, isPawnAdvance: boolean): boolean => {
|
|
111
|
-
if (ctx.unrestrictedPremoves) return true;
|
|
112
|
-
const squaresBetween = util.squaresBetween(...ctx.orig.pos, ...ctx.dest.pos);
|
|
113
|
-
if (isPawnAdvance) squaresBetween.push(ctx.dest.key);
|
|
114
|
-
const squaresOfEnemiesBetween = squaresBetween.filter(s => ctx.enemies.has(s));
|
|
115
|
-
if (squaresOfEnemiesBetween.length > 1) return false;
|
|
116
|
-
if (!squaresOfEnemiesBetween.length) return true;
|
|
117
|
-
const enemySquare = squaresOfEnemiesBetween[0];
|
|
118
|
-
const enemy = ctx.enemies.get(enemySquare);
|
|
119
|
-
if (!enemy || enemy.role !== 'pawn') return true;
|
|
120
|
-
|
|
121
|
-
const enemyStep = enemy.color === 'white' ? 1 : -1;
|
|
122
|
-
const squareAbove = util.squareShiftedVertically(enemySquare, enemyStep);
|
|
123
|
-
const enemyPawnDests: cg.Key[] = squareAbove
|
|
124
|
-
? [
|
|
125
|
-
...util.adjacentSquares(squareAbove).filter(s => canEnemyPawnCaptureOnSquare(enemySquare, s, ctx)),
|
|
126
|
-
...[squareAbove, util.squareShiftedVertically(squareAbove, enemyStep)]
|
|
127
|
-
.filter(s => !!s)
|
|
128
|
-
.filter(s => canEnemyPawnAdvanceToSquare(enemySquare, s, ctx)),
|
|
129
|
-
]
|
|
130
|
-
: [];
|
|
131
|
-
const badSquares = [...squaresBetween, ctx.orig.key];
|
|
132
|
-
return enemyPawnDests.some(square => !badSquares.includes(square));
|
|
133
|
-
};
|
|
134
|
-
|
|
135
|
-
const isPathClearEnoughForPremove = (ctx: MobilityContext, isPawnAdvance: boolean): boolean =>
|
|
136
|
-
isPathClearEnoughOfFriendliesForPremove(ctx, isPawnAdvance) &&
|
|
137
|
-
isPathClearEnoughOfEnemiesForPremove(ctx, isPawnAdvance);
|
|
138
|
-
|
|
139
|
-
const pawn: Mobility = (ctx: MobilityContext) => {
|
|
140
|
-
const step = ctx.color === 'white' ? 1 : -1;
|
|
141
|
-
if (util.diff(ctx.orig.pos[0], ctx.dest.pos[0]) > 1) return false;
|
|
142
|
-
if (!util.diff(ctx.orig.pos[0], ctx.dest.pos[0]))
|
|
143
|
-
return (
|
|
144
|
-
util.pawnDirAdvance(...ctx.orig.pos, ...ctx.dest.pos, ctx.color === 'white') &&
|
|
145
|
-
isPathClearEnoughForPremove(ctx, true)
|
|
146
|
-
);
|
|
147
|
-
if (ctx.dest.pos[1] !== ctx.orig.pos[1] + step) return false;
|
|
148
|
-
if (ctx.unrestrictedPremoves || isDestOccupiedByEnemy(ctx)) return true;
|
|
149
|
-
if (isDestOccupiedByFriendly(ctx)) return isDestControlledByEnemy(ctx);
|
|
150
|
-
else
|
|
151
|
-
return (
|
|
152
|
-
canSomeEnemyPawnAdvanceToDest(ctx) ||
|
|
153
|
-
canBeCapturedBySomeEnemyEnPassant(
|
|
154
|
-
util.pos2key([ctx.dest.pos[0], ctx.dest.pos[1] + step]),
|
|
155
|
-
ctx.friendlies,
|
|
156
|
-
ctx.enemies,
|
|
157
|
-
ctx.lastMove,
|
|
158
|
-
) ||
|
|
159
|
-
isDestControlledByEnemy(ctx, ['pawn'])
|
|
160
|
-
);
|
|
161
|
-
};
|
|
162
|
-
|
|
163
|
-
const knight: Mobility = (ctx: MobilityContext) =>
|
|
164
|
-
util.knightDir(...ctx.orig.pos, ...ctx.dest.pos) &&
|
|
165
|
-
(ctx.unrestrictedPremoves || !isDestOccupiedByFriendly(ctx) || isFriendlyOnDestAndAttacked(ctx));
|
|
166
|
-
|
|
167
|
-
const bishop: Mobility = (ctx: MobilityContext) =>
|
|
168
|
-
util.bishopDir(...ctx.orig.pos, ...ctx.dest.pos) &&
|
|
169
|
-
isPathClearEnoughForPremove(ctx, false) &&
|
|
170
|
-
(ctx.unrestrictedPremoves || !isDestOccupiedByFriendly(ctx) || isFriendlyOnDestAndAttacked(ctx));
|
|
171
|
-
|
|
172
|
-
const rook: Mobility = (ctx: MobilityContext) =>
|
|
173
|
-
util.rookDir(...ctx.orig.pos, ...ctx.dest.pos) &&
|
|
174
|
-
isPathClearEnoughForPremove(ctx, false) &&
|
|
175
|
-
(ctx.unrestrictedPremoves || !isDestOccupiedByFriendly(ctx) || isFriendlyOnDestAndAttacked(ctx));
|
|
16
|
+
const rook: Mobility = (ctx: MobilityContext) => util.rookDir(...ctx.orig.pos, ...ctx.dest.pos);
|
|
176
17
|
|
|
177
18
|
const queen: Mobility = (ctx: MobilityContext) => bishop(ctx) || rook(ctx);
|
|
178
19
|
|
|
179
20
|
const king: Mobility = (ctx: MobilityContext) =>
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
(ctx.canCastle &&
|
|
183
|
-
ctx.orig.pos[1] === ctx.dest.pos[1] &&
|
|
21
|
+
util.kingDirNonCastling(...ctx.orig.pos, ...ctx.dest.pos) ||
|
|
22
|
+
(ctx.orig.pos[1] === ctx.dest.pos[1] &&
|
|
184
23
|
ctx.orig.pos[1] === (ctx.color === 'white' ? 0 : 7) &&
|
|
185
24
|
((ctx.orig.pos[0] === 4 &&
|
|
186
25
|
((ctx.dest.pos[0] === 2 && ctx.rookFilesFriendlies.includes(0)) ||
|
|
187
26
|
(ctx.dest.pos[0] === 6 && ctx.rookFilesFriendlies.includes(7)))) ||
|
|
188
|
-
ctx.rookFilesFriendlies.includes(ctx.dest.pos[0]))
|
|
189
|
-
(ctx.unrestrictedPremoves ||
|
|
190
|
-
/* The following checks if no non-rook friendly piece is in the way between the king and its castling destination.
|
|
191
|
-
Note that for the Chess960 edge case of Kb1 "long castling", the check passes even if there is a piece in the way
|
|
192
|
-
on c1. But this is fine, since premoving from b1 to a1 as a normal move would have already returned true. */
|
|
193
|
-
util
|
|
194
|
-
.squaresBetween(...ctx.orig.pos, ctx.dest.pos[0] > ctx.orig.pos[0] ? 7 : 1, ctx.dest.pos[1])
|
|
195
|
-
.map(s => ctx.allPieces.get(s))
|
|
196
|
-
.every(p => !p || util.samePiece(p, { role: 'rook', color: ctx.color }))));
|
|
27
|
+
ctx.rookFilesFriendlies.includes(ctx.dest.pos[0])));
|
|
197
28
|
|
|
198
29
|
const mobilityByRole = { pawn, knight, bishop, rook, queen, king };
|
|
199
30
|
|
|
200
31
|
export function premove(state: HeadlessState, key: cg.Key): cg.Key[] {
|
|
201
|
-
const pieces = state.pieces
|
|
202
|
-
canCastle = state.premovable.castle,
|
|
203
|
-
unrestrictedPremoves = !!state.premovable.unrestrictedPremoves;
|
|
32
|
+
const pieces = state.pieces;
|
|
204
33
|
const piece = pieces.get(key);
|
|
205
34
|
if (!piece || piece.color === state.turnColor) return [];
|
|
206
35
|
const color = piece.color,
|
|
@@ -215,9 +44,7 @@ export function premove(state: HeadlessState, key: cg.Key): cg.Key[] {
|
|
|
215
44
|
allPieces: pieces,
|
|
216
45
|
friendlies: friendlies,
|
|
217
46
|
enemies: enemies,
|
|
218
|
-
unrestrictedPremoves: unrestrictedPremoves,
|
|
219
47
|
color: color,
|
|
220
|
-
canCastle: canCastle,
|
|
221
48
|
rookFilesFriendlies: Array.from(pieces)
|
|
222
49
|
.filter(
|
|
223
50
|
([k, p]) => k[1] === (color === 'white' ? '1' : '8') && p.color === color && p.role === 'rook',
|
|
@@ -225,5 +52,6 @@ export function premove(state: HeadlessState, key: cg.Key): cg.Key[] {
|
|
|
225
52
|
.map(([k]) => util.key2pos(k)[0]),
|
|
226
53
|
lastMove: state.lastMove,
|
|
227
54
|
};
|
|
55
|
+
// todo - remove more properties from MobilityContext that aren't used in this file, and adjust as needed in lila.
|
|
228
56
|
return util.allPosAndKey.filter(dest => mobility({ ...partialCtx, dest })).map(pk => pk.key);
|
|
229
57
|
}
|
package/src/render.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { State } from './state.js';
|
|
2
2
|
import { key2pos, createEl, posToTranslate as posToTranslateFromBounds, translate } from './util.js';
|
|
3
|
+
import * as util from './util.js';
|
|
3
4
|
import { whitePov } from './board.js';
|
|
4
5
|
import { AnimCurrent, AnimVectors, AnimVector, AnimFadings } from './anim.js';
|
|
5
6
|
import { DragCurrent } from './drag.js';
|
|
@@ -71,23 +72,15 @@ export function render(s: State): void {
|
|
|
71
72
|
if (s.addPieceZIndex) el.style.zIndex = posZIndex(key2pos(k), asWhite);
|
|
72
73
|
}
|
|
73
74
|
// same piece: flag as same
|
|
74
|
-
if (elPieceName === pieceNameOf(pieceAtKey) && (!fading || !el.cgFading))
|
|
75
|
-
samePieces.add(k);
|
|
76
|
-
}
|
|
75
|
+
if (elPieceName === pieceNameOf(pieceAtKey) && (!fading || !el.cgFading)) samePieces.add(k);
|
|
77
76
|
// different piece: flag as moved unless it is a fading piece
|
|
78
|
-
else {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
} else {
|
|
83
|
-
appendValue(movedPieces, elPieceName, el);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
77
|
+
else if (fading && elPieceName === pieceNameOf(fading)) {
|
|
78
|
+
el.classList.add('fading');
|
|
79
|
+
el.cgFading = true;
|
|
80
|
+
} else appendValue(movedPieces, elPieceName, el);
|
|
86
81
|
}
|
|
87
82
|
// no piece: flag as moved
|
|
88
|
-
else
|
|
89
|
-
appendValue(movedPieces, elPieceName, el);
|
|
90
|
-
}
|
|
83
|
+
else appendValue(movedPieces, elPieceName, el);
|
|
91
84
|
} else if (isSquareNode(el)) {
|
|
92
85
|
const cn = el.className;
|
|
93
86
|
if (squares.get(k) === cn) sameSquares.add(k);
|
|
@@ -205,32 +198,34 @@ function posZIndex(pos: cg.Pos, asWhite: boolean): string {
|
|
|
205
198
|
const minZ = 3;
|
|
206
199
|
const rank = pos[1];
|
|
207
200
|
const z = asWhite ? minZ + 7 - rank : minZ + rank;
|
|
208
|
-
|
|
209
201
|
return `${z}`;
|
|
210
202
|
}
|
|
211
203
|
|
|
212
204
|
const pieceNameOf = (piece: cg.Piece): string => `${piece.color} ${piece.role}`;
|
|
213
205
|
|
|
206
|
+
const normalizeLastMoveStandardRookCastle = (s: State, k: cg.Key): cg.Key =>
|
|
207
|
+
!!s.lastMove?.[1] &&
|
|
208
|
+
!s.pieces.has(s.lastMove[1]) &&
|
|
209
|
+
s.lastMove[0][0] === 'e' &&
|
|
210
|
+
['h', 'a'].includes(s.lastMove[1][0]) &&
|
|
211
|
+
s.lastMove[0][1] === s.lastMove[1][1] &&
|
|
212
|
+
util.squaresBetween(...key2pos(s.lastMove[0]), ...key2pos(s.lastMove[1])).some(sq => s.pieces.has(sq))
|
|
213
|
+
? (((k > s.lastMove[0] ? 'g' : 'c') + k[1]) as cg.Key)
|
|
214
|
+
: k;
|
|
215
|
+
|
|
214
216
|
function computeSquareClasses(s: State): cg.SquareClasses {
|
|
215
217
|
const squares: cg.SquareClasses = new Map();
|
|
216
218
|
if (s.lastMove && s.highlight.lastMove)
|
|
217
|
-
for (const k of s.lastMove)
|
|
218
|
-
addSquare(squares, k, 'last-move');
|
|
219
|
-
}
|
|
219
|
+
for (const [i, k] of s.lastMove.entries())
|
|
220
|
+
addSquare(squares, i === 1 ? normalizeLastMoveStandardRookCastle(s, k) : k, 'last-move');
|
|
220
221
|
if (s.check && s.highlight.check) addSquare(squares, s.check, 'check');
|
|
221
222
|
if (s.selected) {
|
|
222
223
|
addSquare(squares, s.selected, 'selected');
|
|
223
224
|
if (s.movable.showDests) {
|
|
224
|
-
const
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
}
|
|
229
|
-
const pDests = s.premovable.customDests?.get(s.selected) ?? s.premovable.dests;
|
|
230
|
-
if (pDests)
|
|
231
|
-
for (const k of pDests) {
|
|
232
|
-
addSquare(squares, k, 'premove-dest' + (s.pieces.has(k) ? ' oc' : ''));
|
|
233
|
-
}
|
|
225
|
+
for (const k of s.movable.dests?.get(s.selected) ?? [])
|
|
226
|
+
addSquare(squares, k, 'move-dest' + (s.pieces.has(k) ? ' oc' : ''));
|
|
227
|
+
for (const k of s.premovable.customDests?.get(s.selected) ?? s.premovable.dests ?? [])
|
|
228
|
+
addSquare(squares, k, 'premove-dest' + (s.pieces.has(k) ? ' oc' : ''));
|
|
234
229
|
}
|
|
235
230
|
}
|
|
236
231
|
const premove = s.premovable.current;
|
package/src/state.ts
CHANGED
|
@@ -10,7 +10,7 @@ export interface HeadlessState {
|
|
|
10
10
|
orientation: cg.Color; // board orientation. white | black
|
|
11
11
|
turnColor: cg.Color; // turn to play. white | black
|
|
12
12
|
check?: cg.Key; // square currently in check "a2"
|
|
13
|
-
lastMove?: cg.Key[]; // squares part of the last move ["c3"
|
|
13
|
+
lastMove?: cg.Key[]; // squares part of the last move ["c3", "c4"]
|
|
14
14
|
selected?: cg.Key; // square currently selected "a1"
|
|
15
15
|
coordinates: boolean; // include coords attributes
|
|
16
16
|
coordinatesOnSquares: boolean; // include coords attributes on every square
|
|
@@ -52,7 +52,6 @@ export interface HeadlessState {
|
|
|
52
52
|
dests?: cg.Key[]; // premove destinations for the current selection
|
|
53
53
|
customDests?: cg.Dests; // use custom valid premoves. {"a2" ["a3" "a4"] "b1" ["a3" "c3"]}
|
|
54
54
|
current?: cg.KeyPair; // keys of the current saved premove ["e2" "e4"]
|
|
55
|
-
unrestrictedPremoves?: boolean; // if falsy, the positions of friendly pieces will be used to trim premove options
|
|
56
55
|
additionalPremoveRequirements: cg.Mobility;
|
|
57
56
|
events: {
|
|
58
57
|
set?: (orig: cg.Key, dest: cg.Key, metadata?: cg.SetPremoveMetadata) => void; // called after the premove has been set
|
package/src/types.ts
CHANGED
|
@@ -124,9 +124,7 @@ export type MobilityContext = {
|
|
|
124
124
|
allPieces: Pieces;
|
|
125
125
|
friendlies: Pieces;
|
|
126
126
|
enemies: Pieces;
|
|
127
|
-
unrestrictedPremoves: boolean;
|
|
128
127
|
color: Color;
|
|
129
|
-
canCastle: boolean;
|
|
130
128
|
rookFilesFriendlies: number[];
|
|
131
129
|
lastMove: Key[] | undefined;
|
|
132
130
|
};
|