@lichess-org/chessground 9.4.0 → 9.4.1
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 +2 -0
- package/dist/chessground.min.js +1 -1
- package/dist/premove.js +8 -6
- package/dist/premove.js.map +1 -1
- package/package.json +3 -2
- package/src/premove.ts +8 -8
package/README.md
CHANGED
package/dist/chessground.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var _e=["white","black"];var F=["a","b","c","d","e","f","g","h"],I=["1","2","3","4","5","6","7","8"];var Je=[...I].reverse(),se=F.flatMap(e=>I.map(o=>e+o)),m=e=>se[8*e[0]+e[1]],f=e=>[e.charCodeAt(0)-97,e.charCodeAt(1)-49];var ce=se.map(f);function eo(e){let o,r=()=>(o===void 0&&(o=e()),o);return r.clear=()=>{o=void 0},r}var oo=()=>{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",V=(e,o)=>(e[0]-o[0])**2+(e[1]-o[1])**2,G=(e,o)=>e.role===o.role&&e.color===o.color,ro=(e,o)=>e[0]===o[0]&&e[1]===o[1],L=e=>(o,r)=>[(r?o[0]:7-o[0])*e.width/8,(r?7-o[1]:o[1])*e.height/8],k=(e,o)=>{e.style.transform=`translate(${o[0]}px,${o[1]}px)`},De=(e,o,r=1)=>{e.style.transform=`translate(${o[0]}px,${o[1]}px) scale(${r})`},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]},le=e=>e.button===2,C=(e,o)=>{let r=document.createElement(e);return o&&(r.className=o),r};function de(e,o,r){let n=f(e);return o||(n[0]=7-n[0],n[1]=7-n[1]),[r.left+r.width*n[0]/8+r.width/16,r.top+r.height*(7-n[1])/8+r.height/16]}var K=(e,o)=>Math.abs(e-o),_=(e,o,r,n)=>K(e,r)*K(o,n)===2,ue=(e,o,r,n)=>e===r!=(o===n),pe=(e,o,r,n)=>K(e,r)===K(o,n)&&e!==r,fe=(e,o,r,n)=>ue(e,o,r,n)||pe(e,o,r,n),Ke=(e,o,r,n)=>Math.max(K(e,r),K(o,n))===1,xe=(e,o,r,n,t)=>K(e,r)===1&&n===o+(t?1:-1),Ee=(e,o,r,n,t)=>{let i=t?1:-1;return e===r&&(n===o+i||n===o+2*i&&(t?o<=1:o>=6))},Q=(e,o,r,n)=>{let t=r-e,i=n-o;if(t&&i&&Math.abs(t)!==Math.abs(i))return[];let a=Math.sign(t),c=Math.sign(i),l=[],s=e+a,p=o+c;for(;s!==r||p!==n;)l.push([s,p]),s+=a,p+=c;return l.map(d=>m(d))},no=e=>{let o=f(e),r=[];return o[0]>0&&r.push([o[0]-1,o[1]]),o[0]<7&&r.push([o[0]+1,o[1]]),r.map(m)},J=(e,o)=>{let r=f(e);return r[1]+=o,m(r)};var U=e=>e.friendlies.has(m(e.pos2)),tr=e=>e.enemies.has(m(e.pos2)),to=(e,o,r)=>Q(...e,...o).some(n=>r.has(n)),io=(e,o,r)=>{let n=r.enemies.get(e);if(n?.role!=="pawn")return!1;let t=n.color==="white"?1:-1,i=f(e),a=f(o);return Ee(...i,...a,n.color==="white")&&!to(i,[a[0],a[1]+t],r.allPieces)},ir=(e,o,r)=>{let n=r.enemies.get(e);return n?.role==="pawn"&&xe(...f(e),...f(o),n.color==="white")&&(r.friendlies.has(o)||me(J(o,n.color==="white"?-1:1),r.friendlies,r.enemies,r.lastMove))},ar=e=>[...e.enemies.keys()].some(o=>io(o,m(e.pos2),e)),Ae=(e,o)=>{let r=e.pos2;return[...e.enemies].some(([n,t])=>{let i=f(n);return!o?.includes(t.role)&&(t.role==="pawn"&&xe(...i,...r,t.color==="white")||t.role==="knight"&&_(...i,...r)||t.role==="bishop"&&pe(...i,...r)||t.role==="rook"&&ue(...i,...r)||t.role==="queen"&&fe(...i,...r)||t.role==="king"&&Ke(...i,...r))&&(!["bishop","rook","queen"].includes(t.role)||!to(i,r,e.allPieces))})},ge=e=>U(e)&&(me(m(e.pos2),e.friendlies,e.enemies,e.lastMove)||Ae(e)),me=(e,o,r,n)=>{if(!n||e!==n[1])return!1;let t=f(n[0]),i=f(n[1]);return o.get(n[1]).role==="pawn"&&K(t[1],i[1])===2&&[1,-1].some(c=>r.get(m([i[0]+c,i[1]]))?.role==="pawn")},sr=e=>{if(e.unrestrictedPremoves)return!0;let o=Q(...e.pos1,...e.pos2),r=o.filter(n=>e.friendlies.has(n));return!r.length||r.length===1&&me(r[0],e.friendlies,e.enemies,e.lastMove)&&!o.includes(J(r[0],e.color==="white"?-1:1))},cr=e=>{if(e.unrestrictedPremoves)return!0;let o=Q(...e.pos1,...e.pos2),r=o.filter(s=>e.enemies.has(s));if(r.length>1)return!1;if(!r.length)return!0;let n=r[0],t=e.enemies.get(n);if(!t||t.role!=="pawn")return!0;let i=t.color==="white"?1:-1,a=J(n,i),c=[...no(a).filter(s=>ir(n,s,e)),...[a,J(a,i)].filter(s=>io(n,s,e))],l=[...o,m(e.pos1)];return c.some(s=>!l.includes(s))},Ne=e=>sr(e)&&cr(e),lr=e=>{let o=e.color==="white"?1:-1;return K(e.pos1[0],e.pos2[0])>1?!1:K(e.pos1[0],e.pos2[0])?e.pos2[1]!==e.pos1[1]+o?!1:e.unrestrictedPremoves||tr(e)?!0:U(e)?Ae(e):ar(e)||me(m([e.pos2[0],e.pos2[1]+o]),e.friendlies,e.enemies,e.lastMove)||Ae(e,["pawn"]):Ee(...e.pos1,...e.pos2,e.color==="white")&&Ne({...e,pos2:[e.pos2[0],e.pos2[1]+o]})},dr=e=>_(...e.pos1,...e.pos2)&&(e.unrestrictedPremoves||!U(e)||ge(e)),ao=e=>pe(...e.pos1,...e.pos2)&&Ne(e)&&(e.unrestrictedPremoves||!U(e)||ge(e)),so=e=>ue(...e.pos1,...e.pos2)&&Ne(e)&&(e.unrestrictedPremoves||!U(e)||ge(e)),ur=e=>ao(e)||so(e),pr=e=>Ke(...e.pos1,...e.pos2)&&(e.unrestrictedPremoves||!U(e)||ge(e))||e.canCastle&&e.pos1[1]===e.pos2[1]&&e.pos1[1]===(e.color==="white"?0:7)&&(e.pos1[0]===4&&(e.pos2[0]===2&&e.rookFilesFriendlies.includes(0)||e.pos2[0]===6&&e.rookFilesFriendlies.includes(7))||e.rookFilesFriendlies.includes(e.pos2[0]))&&(e.unrestrictedPremoves||Q(...e.pos1,e.pos2[0]>e.pos1[0]?7:1,e.pos2[1]).map(o=>e.allPieces.get(o)).every(o=>!o||G(o,{role:"rook",color:e.color}))),fr={pawn:lr,knight:dr,bishop:ao,rook:so,queen:ur,king:pr};function He(e,o){let r=e.pieces,n=e.premovable.castle,t=!!e.premovable.unrestrictedPremoves,i=r.get(o);if(!i||i.color===e.turnColor)return[];let a=i.color,c=new Map([...r].filter(([u,b])=>b.color===a)),l=new Map([...r].filter(([u,b])=>b.color===j(a))),s=f(o),p=fr[i.role],d={pos1:s,allPieces:r,friendlies:c,enemies:l,unrestrictedPremoves:t,color:a,canCastle:n,rookFilesFriendlies:Array.from(r).filter(([u,b])=>u[1]===(a==="white"?"1":"8")&&b.color===a&&b.role==="rook").map(([u])=>f(u)[0]),lastMove:e.lastMove};return ce.filter(u=>p({...d,pos2:u})).map(m)}function M(e,...o){e&&setTimeout(()=>e(...o),1)}function co(e){e.orientation=j(e.orientation),e.animation.current=e.draggable.current=e.selected=void 0}function lo(e,o){for(let[r,n]of o)n?e.pieces.set(r,n):e.pieces.delete(r)}function uo(e,o){if(e.check=void 0,o===!0&&(o=e.turnColor),o)for(let[r,n]of e.pieces)n.role==="king"&&n.color===o&&(e.check=r)}function gr(e,o,r,n){E(e),e.premovable.current=[o,r],M(e.premovable.events.set,o,r,n)}function x(e){e.premovable.current&&(e.premovable.current=void 0,M(e.premovable.events.unset))}function mr(e,o,r){x(e),e.predroppable.current={role:o,key:r},M(e.predroppable.events.set,o,r)}function E(e){let o=e.predroppable;o.current&&(o.current=void 0,M(o.events.unset))}function br(e,o,r){if(!e.autoCastle)return!1;let n=e.pieces.get(o);if(!n||n.role!=="king")return!1;let t=f(o),i=f(r);if(t[1]!==0&&t[1]!==7||t[1]!==i[1])return!1;t[0]===4&&!e.pieces.has(r)&&(i[0]===6?r=m([7,i[1]]):i[0]===2&&(r=m([0,i[1]])));let a=e.pieces.get(r);return!a||a.color!==n.color||a.role!=="rook"?!1:(e.pieces.delete(o),e.pieces.delete(r),t[0]<i[0]?(e.pieces.set(m([6,i[1]]),n),e.pieces.set(m([5,i[1]]),a)):(e.pieces.set(m([2,i[1]]),n),e.pieces.set(m([3,i[1]]),a)),!0)}function qe(e,o,r){let n=e.pieces.get(o),t=e.pieces.get(r);if(o===r||!n)return!1;let i=t&&t.color!==n.color?t:void 0;return r===e.selected&&P(e),M(e.events.move,o,r,i),br(e,o,r)||(e.pieces.set(r,n),e.pieces.delete(o)),e.lastMove=[o,r],e.check=void 0,M(e.events.change),i||!0}function be(e,o,r,n){if(e.pieces.has(r))if(n)e.pieces.delete(r);else return!1;return M(e.events.dropNewPiece,o,r),e.pieces.set(r,o),e.lastMove=[r],e.check=void 0,M(e.events.change),e.movable.dests=void 0,e.turnColor=j(e.turnColor),!0}function po(e,o,r){let n=qe(e,o,r);return n&&(e.movable.dests=void 0,e.turnColor=j(e.turnColor),e.animation.current=void 0),n}function Te(e,o,r){if(ve(e,o,r)){let n=po(e,o,r);if(n){let t=e.hold.stop();P(e);let i={premove:!1,ctrlKey:e.stats.ctrlKey,holdTime:t};return n!==!0&&(i.captured=n),M(e.movable.events.after,o,r,i),!0}}else if(vr(e,o,r))return gr(e,o,r,{ctrlKey:e.stats.ctrlKey}),P(e),!0;return P(e),!1}function he(e,o,r,n){let t=e.pieces.get(o);t&&(hr(e,o,r)||n)?(e.pieces.delete(o),be(e,t,r,n),M(e.movable.events.afterNewPiece,t.role,r,{premove:!1,predrop:!1})):t&&yr(e,o,r)?mr(e,t.role,r):(x(e),E(e)),e.pieces.delete(o),P(e)}function oe(e,o,r){if(M(e.events.select,o),e.selected){if(e.selected===o&&!e.draggable.enabled){P(e),e.hold.cancel();return}else if((e.selectable.enabled||r)&&e.selected!==o&&Te(e,e.selected,o)){e.stats.dragged=!1;return}}(e.selectable.enabled||e.draggable.enabled)&&(fo(e,o)||Oe(e,o))&&(Be(e,o),e.hold.start())}function Be(e,o){e.selected=o,Oe(e,o)?e.premovable.customDests||(e.premovable.dests=He(e,o)):e.premovable.dests=void 0}function P(e){e.selected=void 0,e.premovable.dests=void 0,e.hold.cancel()}function fo(e,o){let r=e.pieces.get(o);return!!r&&(e.movable.color==="both"||e.movable.color===r.color&&e.turnColor===r.color)}var ve=(e,o,r)=>o!==r&&fo(e,o)&&(e.movable.free||!!e.movable.dests?.get(o)?.includes(r));function hr(e,o,r){let n=e.pieces.get(o);return!!n&&(o===r||!e.pieces.has(r))&&(e.movable.color==="both"||e.movable.color===n.color&&e.turnColor===n.color)}function Oe(e,o){let r=e.pieces.get(o);return!!r&&e.premovable.enabled&&e.movable.color===r.color&&e.turnColor!==r.color}var vr=(e,o,r)=>o!==r&&Oe(e,o)&&(e.premovable.customDests?.get(o)??He(e,o)).includes(r);function yr(e,o,r){let n=e.pieces.get(o),t=e.pieces.get(r);return!!n&&(!t||t.color!==e.movable.color)&&e.predroppable.enabled&&(n.role!=="pawn"||r[1]!=="1"&&r[1]!=="8")&&e.movable.color===n.color&&e.turnColor!==n.color}function go(e,o){let r=e.pieces.get(o);return!!r&&e.draggable.enabled&&(e.movable.color==="both"||e.movable.color===r.color&&(e.turnColor===r.color||e.premovable.enabled))}function mo(e){let o=e.premovable.current;if(!o)return!1;let r=o[0],n=o[1],t=!1;if(ve(e,r,n)){let i=po(e,r,n);if(i){let a={premove:!0};i!==!0&&(a.captured=i),M(e.movable.events.after,r,n,a),t=!0}}return x(e),t}function bo(e,o){let r=e.predroppable.current,n=!1;if(!r)return!1;if(o(r)){let t={role:r.role,color:e.movable.color};be(e,t,r.key)&&(M(e.movable.events.afterNewPiece,r.role,r.key,{premove:!1,predrop:!0}),n=!0)}return E(e),n}function re(e){x(e),E(e),P(e)}function Re(e){e.movable.color=e.movable.dests=e.animation.current=void 0,re(e)}function A(e,o,r){let n=Math.floor(8*(e[0]-r.left)/r.width);o||(n=7-n);let t=7-Math.floor(8*(e[1]-r.top)/r.height);return o||(t=7-t),n>=0&&n<8&&t>=0&&t<8?m([n,t]):void 0}function ho(e,o,r,n){let t=f(e),i=ce.filter(s=>ro(t,s)||fe(t[0],t[1],s[0],s[1])||_(t[0],t[1],s[0],s[1])),c=i.map(s=>de(m(s),r,n)).map(s=>V(o,s)),[,l]=c.reduce((s,p,d)=>s[0]<p?s:[p,d],[c[0],0]);return m(i[l])}var v=e=>e.orientation==="white";var Le="rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR",Sr={p:"pawn",r:"rook",n:"knight",b:"bishop",q:"queen",k:"king"},wr={pawn:"p",rook:"r",knight:"n",bishop:"b",queen:"q",king:"k"};function ye(e){e==="start"&&(e=Le);let o=new Map,r=7,n=0;for(let t of e)switch(t){case" ":case"[":return o;case"/":if(--r,r<0)return o;n=0;break;case"~":{let i=o.get(m([n-1,r]));i&&(i.promoted=!0);break}default:{let i=t.charCodeAt(0);if(i<57)n+=i-48;else{let a=t.toLowerCase();o.set(m([n,r]),{role:Sr[a],color:t===a?"black":"white"}),++n}}}return o}function vo(e){return Je.map(o=>F.map(r=>{let n=e.get(r+o);if(n){let t=wr[n.role];return n.color==="white"&&(t=t.toUpperCase()),n.promoted&&(t+="~"),t}else return"1"}).join("")).join("/").replace(/1{2,}/g,o=>o.length.toString())}function Fe(e,o){o.animation&&(Ge(e.animation,o.animation),(e.animation.duration||0)<70&&(e.animation.enabled=!1))}function Se(e,o){if(o.movable?.dests&&(e.movable.dests=void 0),o.drawable?.autoShapes&&(e.drawable.autoShapes=[]),Ge(e,o),o.fen&&(e.pieces=ye(o.fen),e.drawable.shapes=o.drawable?.shapes||[]),"check"in o&&uo(e,o.check||!1),"lastMove"in o&&!o.lastMove?e.lastMove=void 0:o.lastMove&&(e.lastMove=o.lastMove),e.selected&&Be(e,e.selected),Fe(e,o),!e.movable.rookCastle&&e.movable.dests){let r=e.movable.color==="white"?"1":"8",n="e"+r,t=e.movable.dests.get(n),i=e.pieces.get(n);if(!t||!i||i.role!=="king")return;e.movable.dests.set(n,t.filter(a=>!(a==="a"+r&&t.includes("c"+r))&&!(a==="h"+r&&t.includes("g"+r))))}}function Ge(e,o){for(let r in o)r==="__proto__"||r==="constructor"||!Object.prototype.hasOwnProperty.call(o,r)||(Object.prototype.hasOwnProperty.call(e,r)&&yo(e[r])&&yo(o[r])?Ge(e[r],o[r]):e[r]=o[r])}function yo(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?Cr(e,o):O(e,o);function O(e,o){let r=e(o);return o.dom.redraw(),r}var We=(e,o)=>({key:e,pos:f(e),piece:o}),Mr=(e,o)=>o.sort((r,n)=>V(e.pos,r.pos)-V(e.pos,n.pos))[0];function kr(e,o){let r=new Map,n=[],t=new Map,i=[],a=[],c=new Map,l,s,p;for(let[d,u]of e)c.set(d,We(d,u));for(let d of se)l=o.pieces.get(d),s=c.get(d),l?s?G(l,s.piece)||(i.push(s),a.push(We(d,l))):a.push(We(d,l)):s&&i.push(s);for(let d of a)s=Mr(d,i.filter(u=>G(d.piece,u.piece))),s&&(p=[s.pos[0]-d.pos[0],s.pos[1]-d.pos[1]],r.set(d.key,p.concat(p)),n.push(s.key));for(let d of i)n.includes(d.key)||t.set(d.key,d.piece);return{anims:r,fadings:t}}function So(e,o){let r=e.animation.current;if(r===void 0){e.dom.destroyed||e.dom.redrawNow();return}let n=1-(o-r.start)*r.frequency;if(n<=0)e.animation.current=void 0,e.dom.redrawNow();else{let t=Dr(n);for(let i of r.plan.anims.values())i[2]=i[0]*t,i[3]=i[1]*t;e.dom.redrawNow(!0),requestAnimationFrame((i=performance.now())=>So(e,i))}}function Cr(e,o){let r=new Map(o.pieces),n=e(o),t=kr(r,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||So(o,performance.now())}else o.dom.redraw();return n}var Dr=e=>e<.5?4*e*e*e:(e-1)*(2*e-2)*(2*e-2)+1;var Kr=["green","red","blue","yellow"];function wo(e,o){if(o.touches&&o.touches.length>1)return;o.stopPropagation(),o.preventDefault(),o.ctrlKey?P(e):re(e);let r=T(o),n=A(r,v(e),e.dom.bounds());n&&(e.drawable.current={orig:n,pos:r,brush:xr(o),snapToValidMove:e.drawable.defaultSnapToValidMove},Po(e))}function Po(e){requestAnimationFrame(()=>{let o=e.drawable.current;if(o){let r=A(o.pos,v(e),e.dom.bounds());r||(o.snapToValidMove=!1);let n=o.snapToValidMove?ho(o.orig,o.pos,v(e),e.dom.bounds()):r;n!==o.mouseSq&&(o.mouseSq=n,o.dest=n!==o.orig?n:void 0,e.dom.redrawNow()),Po(e)}})}function Mo(e,o){e.drawable.current&&(e.drawable.current.pos=T(o))}function ko(e){let o=e.drawable.current;o&&(o.mouseSq&&Er(e.drawable,o),ze(e))}function ze(e){e.drawable.current&&(e.drawable.current=void 0,e.dom.redraw())}function Co(e){e.drawable.shapes.length&&(e.drawable.shapes=[],e.dom.redraw(),Do(e.drawable))}function xr(e){let o=(e.shiftKey||e.ctrlKey)&&le(e),r=e.altKey||e.metaKey||e.getModifierState?.("AltGraph");return Kr[(o?1:0)+(r?2:0)]}function Er(e,o){let r=t=>t.orig===o.orig&&t.dest===o.dest,n=e.shapes.find(r);n&&(e.shapes=e.shapes.filter(t=>!r(t))),(!n||n.brush!==o.brush)&&e.shapes.push({orig:o.orig,dest:o.dest,brush:o.brush}),Do(e)}function Do(e){e.onChange&&e.onChange(e.shapes)}function Ko(e,o){if(!(e.trustAllEvents||o.isTrusted)||o.buttons!==void 0&&o.buttons>1||o.touches&&o.touches.length>1)return;let r=e.dom.bounds(),n=T(o),t=A(n,v(e),r);if(!t)return;let i=e.pieces.get(t),a=e.selected;if(!a&&e.drawable.enabled&&(e.drawable.eraseOnClick||!i||i.color!==e.turnColor)&&Co(e),o.cancelable!==!1&&(!o.touches||e.blockTouchScroll||i||a||Nr(e,n)))o.preventDefault();else if(o.touches)return;let c=!!e.premovable.current,l=!!e.predroppable.current;e.stats.ctrlKey=o.ctrlKey,e.selected&&ve(e,e.selected,t)?B(d=>oe(d,t),e):oe(e,t);let s=e.selected===t,p=Ho(e,t);if(i&&p&&s&&go(e,t)){e.draggable.current={orig:t,piece:i,origPos:n,pos:n,started:e.draggable.autoDistance&&e.stats.dragged,element:p,previouslySelected:a,originTarget:o.target,keyHasChanged:!1},p.cgDragging=!0,p.classList.add("dragging");let d=e.dom.elements.ghost;d&&(d.className=`ghost ${i.color} ${i.role}`,k(d,L(r)(f(t),v(e))),Y(d,!0)),$e(e)}else c&&x(e),l&&E(e);e.dom.redraw()}function Nr(e,o){let r=v(e),n=e.dom.bounds(),t=Math.pow(n.width/8,2);for(let i of e.pieces.keys()){let a=de(i,r,n);if(V(a,o)<=t)return!0}return!1}function xo(e,o,r,n){let t="a0";e.pieces.set(t,o),e.dom.redraw();let i=T(r);e.draggable.current={orig:t,piece:o,origPos:i,pos:i,started:!0,element:()=>Ho(e,t),originTarget:r.target,newPiece:!0,force:!!n,keyHasChanged:!1},$e(e)}function $e(e){requestAnimationFrame(()=>{let o=e.draggable.current;if(!o)return;e.animation.current?.plan.anims.has(o.orig)&&(e.animation.current=void 0);let r=e.pieces.get(o.orig);if(!r||!G(r,o.piece))W(e);else if(!o.started&&V(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 n=e.dom.bounds();k(o.element,[o.pos[0]-n.left-n.width/16,o.pos[1]-n.top-n.height/16]),o.keyHasChanged||=o.orig!==A(o.pos,v(e),n)}$e(e)})}function Eo(e,o){e.draggable.current&&(!o.touches||o.touches.length<2)&&(e.draggable.current.pos=T(o))}function Ao(e,o){let r=e.draggable.current;if(!r)return;if(o.type==="touchend"&&o.cancelable!==!1&&o.preventDefault(),o.type==="touchend"&&r.originTarget!==o.target&&!r.newPiece){e.draggable.current=void 0;return}x(e),E(e);let n=T(o)||r.pos,t=A(n,v(e),e.dom.bounds());t&&r.started&&r.orig!==t?r.newPiece?he(e,r.orig,t,r.force):(e.stats.ctrlKey=o.ctrlKey,Te(e,r.orig,t)&&(e.stats.dragged=!0)):r.newPiece?e.pieces.delete(r.orig):e.draggable.deleteOnDropOff&&!t&&(e.pieces.delete(r.orig),M(e.events.change)),(r.orig===r.previouslySelected||r.keyHasChanged)&&(r.orig===t||!t)?P(e):e.selectable.enabled||P(e),No(e),e.draggable.current=void 0,e.dom.redraw()}function W(e){let o=e.draggable.current;o&&(o.newPiece&&e.pieces.delete(o.orig),e.draggable.current=void 0,P(e),No(e),e.dom.redraw())}function No(e){let o=e.dom.elements;o.ghost&&Y(o.ghost,!1)}function Ho(e,o){let r=e.dom.elements.board.firstChild;for(;r;){if(r.cgKey===o&&r.tagName==="PIECE")return r;r=r.nextSibling}}function To(e,o){e.exploding={stage:1,keys:o},e.dom.redraw(),setTimeout(()=>{qo(e,2),setTimeout(()=>qo(e,void 0),120)},120)}function qo(e,o){e.exploding&&(o?e.exploding.stage=o:e.exploding=void 0,e.dom.redraw())}function Bo(e,o){function r(){co(e),o()}return{set(n){n.orientation&&n.orientation!==e.orientation&&r(),Fe(e,n),(n.fen?B:O)(t=>Se(t,n),e)},state:e,getFen:()=>vo(e.pieces),toggleOrientation:r,setPieces(n){B(t=>lo(t,n),e)},selectSquare(n,t){n?B(i=>oe(i,n,t),e):e.selected&&(P(e),e.dom.redraw())},move(n,t){B(i=>qe(i,n,t),e)},newPiece(n,t){B(i=>be(i,n,t),e)},playPremove(){if(e.premovable.current){if(B(mo,e))return!0;e.dom.redraw()}return!1},playPredrop(n){if(e.predroppable.current){let t=bo(e,n);return e.dom.redraw(),t}return!1},cancelPremove(){O(x,e)},cancelPredrop(){O(E,e)},cancelMove(){O(n=>{re(n),W(n)},e)},stop(){O(n=>{Re(n),W(n)},e)},explode(n){To(e,n)},setAutoShapes(n){O(t=>t.drawable.autoShapes=n,e)},setShapes(n){O(t=>t.drawable.shapes=n.slice(),e)},getKeyAtDomPos(n){return A(n,v(e),e.dom.bounds())},redrawAll:o,dragNewPiece(n,t,i){xo(e,n,t,i)},destroy(){Re(e),e.dom.unbind&&e.dom.unbind(),e.dom.destroyed=!0}}}function Oo(){return{pieces:ye(Le),orientation:"white",turnColor:"white",coordinates:!0,coordinatesOnSquares:!1,ranksPosition:"right",autoCastle:!0,viewOnly:!1,disableContextMenu:!1,addPieceZIndex:!1,blockTouchScroll:!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,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,eraseOnClick:!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}},prevSvgHash:""},hold:oo()}}var Ro={hilitePrimary:{key:"hilitePrimary",color:"#3291ff",opacity:1,lineWidth:1},hiliteWhite:{key:"hiliteWhite",color:"#ffffff",opacity:1,lineWidth:1}};function Fo(){let e=y("defs"),o=w(y("filter"),{id:"cg-filter-blur"});return o.appendChild(w(y("feGaussianBlur"),{stdDeviation:"0.019"})),e.appendChild(o),e}function Go(e,o,r){let n=e.drawable,t=n.current,i=t&&t.mouseSq?t:void 0,a=new Map,c=e.dom.bounds(),l=n.autoShapes.filter(u=>!u.piece);for(let u of n.shapes.concat(l).concat(i?[i]:[])){if(!u.dest)continue;let b=a.get(u.dest)??new Set,S=Me(Pe(f(u.orig),e.orientation),c),g=Me(Pe(f(u.dest),e.orientation),c);b.add(je(S,g)),a.set(u.dest,b)}let s=n.shapes.concat(l).map(u=>({shape:u,current:!1,hash:Vo(u,Ie(u.dest,a),!1,c)}));i&&s.push({shape:i,current:!0,hash:Vo(i,Ie(i.dest,a),!0,c)});let p=s.map(u=>u.hash).join(";");if(p===e.drawable.prevSvgHash)return;e.drawable.prevSvgHash=p;let d=o.querySelector("defs");qr(n,s,d),Tr(s,o.querySelector("g"),r.querySelector("g"),u=>Rr(e,u,n.brushes,a,c))}function qr(e,o,r){let n=new Map,t;for(let c of o.filter(l=>l.shape.dest&&l.shape.brush))t=Wo(e.brushes[c.shape.brush],c.shape.modifiers),c.shape.modifiers?.hilite&&n.set(we(t).key,we(t)),n.set(t.key,t);let i=new Set,a=r.firstElementChild;for(;a;)i.add(a.getAttribute("cgKey")),a=a.nextElementSibling;for(let[c,l]of n.entries())i.has(c)||r.appendChild(Fr(l))}function Tr(e,o,r,n){let t=new Map;for(let i of e)t.set(i.hash,!1);for(let i of[o,r]){let a=[],c=i.firstElementChild,l;for(;c;)l=c.getAttribute("cgHash"),t.has(l)?t.set(l,!0):a.push(c),c=c.nextElementSibling;for(let s of a)i.removeChild(s)}for(let i of e.filter(a=>!t.get(a.hash)))for(let a of n(i))a.isCustom?r.appendChild(a.el):o.appendChild(a.el)}function Vo({orig:e,dest:o,brush:r,piece:n,modifiers:t,customSvg:i,label:a},c,l,s){return[s.width,s.height,l,e,o,r,c&&"-",n&&Br(n),t&&Or(t),i&&`custom-${Lo(i.html)},${i.center?.[0]??"o"}`,a&&`label-${Lo(a.text)}`].filter(p=>p).join(",")}function Br(e){return[e.color,e.role,e.scale].filter(o=>o).join(",")}function Or(e){return[e.lineWidth,e.hilite&&"*"].filter(o=>o).join(",")}function Lo(e){let o=0;for(let r=0;r<e.length;r++)o=(o<<5)-o+e.charCodeAt(r)>>>0;return o.toString()}function Rr(e,{shape:o,current:r,hash:n},t,i,a){let c=Me(Pe(f(o.orig),e.orientation),a),l=o.dest?Me(Pe(f(o.dest),e.orientation),a):c,s=o.brush&&Wo(t[o.brush],o.modifiers),p=i.get(o.dest),d=[];if(s){let u=w(y("g"),{cgHash:n});d.push({el:u}),c[0]!==l[0]||c[1]!==l[1]?u.appendChild(Lr(o,s,c,l,r,Ie(o.dest,i))):u.appendChild(Vr(t[o.brush],c,r,a))}if(o.label){let u=o.label;u.fill??=o.brush&&t[o.brush].color;let b=o.brush?void 0:"tr";d.push({el:Gr(u,n,c,l,p,b),isCustom:!0})}if(o.customSvg){let u=o.customSvg.center??"orig",[b,S]=u==="label"?$o(c,l,p).map(z=>z-.5):u==="dest"?l:c,g=w(y("g"),{transform:`translate(${b},${S})`,cgHash:n});g.innerHTML=`<svg width="1" height="1" viewBox="0 0 100 100">${o.customSvg.html}</svg>`,d.push({el:g,isCustom:!0})}return d}function Vr(e,o,r,n){let t=Wr(),i=(n.width+n.height)/(4*Math.max(n.width,n.height));return w(y("circle"),{stroke:e.color,"stroke-width":t[r?0:1],fill:"none",opacity:zo(e,r),cx:o[0],cy:o[1],r:i-t[1]/2})}function we(e){return["#ffffff","#fff","white"].includes(e.color)?Ro.hilitePrimary:Ro.hiliteWhite}function Lr(e,o,r,n,t,i){function a(s){let p=$r(i&&!t),d=n[0]-r[0],u=n[1]-r[1],b=Math.atan2(u,d),S=Math.cos(b)*p,g=Math.sin(b)*p;return w(y("line"),{stroke:s?we(o).color:o.color,"stroke-width":zr(o,t)+(s?.04:0),"stroke-linecap":"round","marker-end":`url(#arrowhead-${s?we(o).key:o.key})`,opacity:e.modifiers?.hilite?1:zo(o,t),x1:r[0],y1:r[1],x2:n[0]-S,y2:n[1]-g})}if(!e.modifiers?.hilite)return a(!1);let c=y("g"),l=w(y("g"),{filter:"url(#cg-filter-blur)"});return l.appendChild(Ir(r,n)),l.appendChild(a(!0)),c.appendChild(l),c.appendChild(a(!1)),c}function Fr(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 Gr(e,o,r,n,t,i){let c=.4*.75**e.text.length,l=$o(r,n,t),s=i==="tr"?.4:0,p=w(y("g"),{transform:`translate(${l[0]+s},${l[1]-s})`,cgHash:o});p.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 d=w(y("text"),{"font-size":c,"font-family":"Noto Sans","text-anchor":"middle",fill:"white",y:.13*.75**e.text.length});return d.innerHTML=e.text,p.appendChild(d),p}function Pe(e,o){return o==="white"?e:[7-e[0],7-e[1]]}function Ie(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 r in o)Object.prototype.hasOwnProperty.call(o,r)&&e.setAttribute(r,o[r]);return e}function Wo(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(r=>r).join("")}:e}function Wr(){return[3/64,4/64]}function zr(e,o){return(e.lineWidth||10)*(o?.85:1)/64}function zo(e,o){return(e.opacity||1)*(o?.9:1)}function $r(e){return(e?20:10)/64}function Me(e,o){let r=Math.min(1,o.width/o.height),n=Math.min(1,o.height/o.width);return[(e[0]-3.5)*r,(3.5-e[1])*n]}function Ir(e,o){let r={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:r.from[0],y:r.from[1],width:r.to[0]-r.from[0],height:r.to[1]-r.from[1],fill:"none",stroke:"none"})}function je(e,o,r=!0){let n=Math.atan2(o[1]-e[1],o[0]-e[0])+Math.PI;return r?(Math.round(n*8/Math.PI)+16)%16:n}function jr(e,o){return Math.sqrt([e[0]-o[0],e[1]-o[1]].reduce((r,n)=>r+n*n,0))}function $o(e,o,r){let n=jr(e,o),t=je(e,o,!1);if(r&&(n-=33/64,r.size>1)){n-=10/64;let i=je(e,o);(r.has((i+1)%16)||r.has((i+15)%16))&&i&1&&(n-=.4)}return[e[0]-Math.cos(t)*n,e[1]-Math.sin(t)*n].map(i=>i+.5)}function Io(e,o){e.innerHTML="",e.classList.add("cg-wrap");for(let l of _e)e.classList.toggle("orientation-"+l,o.orientation===l);e.classList.toggle("manipulable",!o.viewOnly);let r=C("cg-container");e.appendChild(r);let n=C("cg-board");r.appendChild(n);let t,i,a;if(o.drawable.visible&&(t=w(y("svg"),{class:"cg-shapes",viewBox:"-4 -4 8 8",preserveAspectRatio:"xMidYMid slice"}),t.appendChild(Fo()),t.appendChild(y("g")),i=w(y("svg"),{class:"cg-custom-svgs",viewBox:"-3.5 -3.5 8 8",preserveAspectRatio:"xMidYMid slice"}),i.appendChild(y("g")),a=C("cg-auto-pieces"),r.appendChild(t),r.appendChild(i),r.appendChild(a)),o.coordinates){let l=o.orientation==="black"?" black":"",s=o.ranksPosition==="left"?" left":"";if(o.coordinatesOnSquares){let p=o.orientation==="white"?d=>d+1:d=>8-d;F.forEach((d,u)=>r.appendChild(Ue(I.map(b=>d+b),"squares rank"+p(u)+l+s)))}else r.appendChild(Ue(I,"ranks"+l+s)),r.appendChild(Ue(F,"files"+l))}let c;return o.draggable.enabled&&o.draggable.showGhost&&(c=C("piece","ghost"),Y(c,!1),r.appendChild(c)),{board:n,container:r,wrap:e,ghost:c,svg:t,customSvg:i,autoPieces:a}}function Ue(e,o){let r=C("coords",o),n;for(let t of e)n=C("coord"),n.textContent=t,r.appendChild(n);return r}function jo(e,o){if(!e.dropmode.active)return;x(e),E(e);let r=e.dropmode.piece;if(r){e.pieces.set("a0",r);let n=T(o),t=n&&A(n,v(e),e.dom.bounds());t&&he(e,"a0",t)}e.dom.redraw()}function Zo(e,o){let r=e.dom.elements.board;if("ResizeObserver"in window&&new ResizeObserver(o).observe(e.dom.elements.wrap),(e.disableContextMenu||e.drawable.enabled)&&r.addEventListener("contextmenu",t=>t.preventDefault()),e.viewOnly)return;let n=Zr(e);r.addEventListener("touchstart",n,{passive:!1}),r.addEventListener("mousedown",n,{passive:!1})}function Xo(e,o){let r=[];if("ResizeObserver"in window||r.push(ne(document.body,"chessground.resize",o)),!e.viewOnly){let n=Uo(e,Eo,Mo),t=Uo(e,Ao,ko);for(let a of["touchmove","mousemove"])r.push(ne(document,a,n));for(let a of["touchend","mouseup"])r.push(ne(document,a,t));let i=()=>e.dom.bounds.clear();r.push(ne(document,"scroll",i,{capture:!0,passive:!0})),r.push(ne(window,"resize",i,{passive:!0}))}return()=>r.forEach(n=>n())}function ne(e,o,r,n){return e.addEventListener(o,r,n),()=>e.removeEventListener(o,r,n)}var Zr=e=>o=>{e.draggable.current?W(e):e.drawable.current?ze(e):o.shiftKey||le(o)?e.drawable.enabled&&wo(e,o):e.viewOnly||(e.dropmode.active?jo(e,o):Ko(e,o))},Uo=(e,o,r)=>n=>{e.drawable.current?e.drawable.enabled&&r(e,n):e.viewOnly||o(e,n)};function _o(e){let o=v(e),r=L(e.dom.bounds()),n=e.dom.elements.board,t=e.pieces,i=e.animation.current,a=i?i.plan.anims:new Map,c=i?i.plan.fadings:new Map,l=e.draggable.current,s=Yr(e),p=new Set,d=new Set,u=new Map,b=new Map,S,g,z,$,D,Z,ke,N,Ce,ie;for(g=n.firstChild;g;){if(S=g.cgKey,Jo(g))if(z=t.get(S),D=a.get(S),Z=c.get(S),$=g.cgPiece,g.cgDragging&&(!l||l.orig!==S)&&(g.classList.remove("dragging"),k(g,r(f(S),o)),g.cgDragging=!1),!Z&&g.cgFading&&(g.cgFading=!1,g.classList.remove("fading")),z){if(D&&g.cgAnimating&&$===te(z)){let h=f(S);h[0]+=D[2],h[1]+=D[3],g.classList.add("anim"),k(g,r(h,o))}else g.cgAnimating&&(g.cgAnimating=!1,g.classList.remove("anim"),k(g,r(f(S),o)),e.addPieceZIndex&&(g.style.zIndex=Ze(f(S),o)));$===te(z)&&(!Z||!g.cgFading)?p.add(S):Z&&$===te(Z)?(g.classList.add("fading"),g.cgFading=!0):Xe(u,$,g)}else Xe(u,$,g);else if(er(g)){let h=g.className;s.get(S)===h?d.add(S):Xe(b,h,g)}g=g.nextSibling}for(let[h,X]of s)if(!d.has(h)){Ce=b.get(X),ie=Ce&&Ce.pop();let H=r(f(h),o);if(ie)ie.cgKey=h,k(ie,H);else{let q=C("square",X);q.cgKey=h,k(q,H),n.insertBefore(q,n.firstChild)}}for(let[h,X]of t)if(D=a.get(h),!p.has(h))if(ke=u.get(te(X)),N=ke&&ke.pop(),N){N.cgKey=h,N.cgFading&&(N.classList.remove("fading"),N.cgFading=!1);let H=f(h);e.addPieceZIndex&&(N.style.zIndex=Ze(H,o)),D&&(N.cgAnimating=!0,N.classList.add("anim"),H[0]+=D[2],H[1]+=D[3]),k(N,r(H,o))}else{let H=te(X),q=C("piece",H),ae=f(h);q.cgPiece=H,q.cgKey=h,D&&(q.cgAnimating=!0,ae[0]+=D[2],ae[1]+=D[3]),k(q,r(ae,o)),e.addPieceZIndex&&(q.style.zIndex=Ze(ae,o)),n.appendChild(q)}for(let h of u.values())Yo(e,h);for(let h of b.values())Yo(e,h)}function Qo(e){let o=v(e),r=L(e.dom.bounds()),n=e.dom.elements.board.firstChild;for(;n;)(Jo(n)&&!n.cgAnimating||er(n))&&k(n,r(f(n.cgKey),o)),n=n.nextSibling}function Ye(e){let o=e.dom.elements.wrap.getBoundingClientRect(),r=e.dom.elements.container,n=o.height/o.width,t=Math.floor(o.width*window.devicePixelRatio/8)*8/window.devicePixelRatio,i=t*n;r.style.width=t+"px",r.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 Jo=e=>e.tagName==="PIECE",er=e=>e.tagName==="SQUARE";function Yo(e,o){for(let r of o)e.dom.elements.board.removeChild(r)}function Ze(e,o){let n=e[1];return`${o?10-n:3+n}`}var te=e=>`${e.color} ${e.role}`;function Yr(e){let o=new Map;if(e.lastMove&&e.highlight.lastMove)for(let t of e.lastMove)R(o,t,"last-move");if(e.check&&e.highlight.check&&R(o,e.check,"check"),e.selected&&(R(o,e.selected,"selected"),e.movable.showDests)){let t=e.movable.dests?.get(e.selected);if(t)for(let a of t)R(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)R(o,a,"premove-dest"+(e.pieces.has(a)?" oc":""))}let r=e.premovable.current;if(r)for(let t of r)R(o,t,"current-premove");else e.predroppable.current&&R(o,e.predroppable.current.key,"current-premove");let n=e.exploding;if(n)for(let t of n.keys)R(o,t,"exploding"+n.stage);return e.highlight.custom&&e.highlight.custom.forEach((t,i)=>{R(o,i,t)}),o}function R(e,o,r){let n=e.get(o);n?e.set(o,`${n} ${r}`):e.set(o,r)}function Xe(e,o,r){let n=e.get(o);n?n.push(r):e.set(o,[r])}function or(e,o,r){let n=new Map,t=[];for(let c of e)n.set(c.hash,!1);let i=o.firstElementChild,a;for(;i;)a=i.getAttribute("cgHash"),n.has(a)?n.set(a,!0):t.push(i),i=i.nextElementSibling;for(let c of t)o.removeChild(c);for(let c of e)n.get(c.hash)||o.appendChild(r(c))}function rr(e,o){let n=e.drawable.autoShapes.filter(t=>t.piece).map(t=>({shape:t,hash:Qr(t),current:!1}));or(n,o,t=>_r(e,t,e.dom.bounds()))}function nr(e){let o=v(e),r=L(e.dom.bounds()),n=e.dom.elements.autoPieces?.firstChild;for(;n;)De(n,r(f(n.cgKey),o),n.cgScale),n=n.nextSibling}function _r(e,{shape:o,hash:r},n){let t=o.orig,i=o.piece?.role,a=o.piece?.color,c=o.piece?.scale,l=C("piece",`${i} ${a}`);return l.setAttribute("cgHash",r),l.cgKey=t,l.cgScale=c,De(l,L(n)(f(t),v(e)),c),l}var Qr=e=>[e.orig,e.piece?.role,e.piece?.color,e.piece?.scale].join(",");function Jn({el:e,config:o}){return en(e,o)}function en(e,o){let r=Oo();Se(r,o||{});function n(){let t="dom"in r?r.dom.unbind:void 0,i=Io(e,r),a=eo(()=>i.board.getBoundingClientRect()),c=p=>{_o(s),i.autoPieces&&rr(s,i.autoPieces),!p&&i.svg&&Go(s,i.svg,i.customSvg)},l=()=>{Ye(s),Qo(s),i.autoPieces&&nr(s)},s=r;return s.dom={elements:i,bounds:a,redraw:on(c),redrawNow:c,unbind:t},s.drawable.prevSvgHash="",Ye(s),c(!1),Zo(s,l),t||(s.dom.unbind=Xo(s,l)),s.events.insert&&s.events.insert(i),s}return Bo(n(),n)}function on(e){let o=!1;return()=>{o||(o=!0,requestAnimationFrame(()=>{e(),o=!1}))}}export{en as Chessground,Jn as initModule};
|
|
1
|
+
var _e=["white","black"];var F=["a","b","c","d","e","f","g","h"],I=["1","2","3","4","5","6","7","8"];var Je=[...I].reverse(),se=F.flatMap(e=>I.map(o=>e+o)),m=e=>se[8*e[0]+e[1]],f=e=>[e.charCodeAt(0)-97,e.charCodeAt(1)-49];var ce=se.map(f);function eo(e){let o,r=()=>(o===void 0&&(o=e()),o);return r.clear=()=>{o=void 0},r}var oo=()=>{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",V=(e,o)=>(e[0]-o[0])**2+(e[1]-o[1])**2,G=(e,o)=>e.role===o.role&&e.color===o.color,ro=(e,o)=>e[0]===o[0]&&e[1]===o[1],L=e=>(o,r)=>[(r?o[0]:7-o[0])*e.width/8,(r?7-o[1]:o[1])*e.height/8],k=(e,o)=>{e.style.transform=`translate(${o[0]}px,${o[1]}px)`},De=(e,o,r=1)=>{e.style.transform=`translate(${o[0]}px,${o[1]}px) scale(${r})`},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]},le=e=>e.button===2,C=(e,o)=>{let r=document.createElement(e);return o&&(r.className=o),r};function de(e,o,r){let n=f(e);return o||(n[0]=7-n[0],n[1]=7-n[1]),[r.left+r.width*n[0]/8+r.width/16,r.top+r.height*(7-n[1])/8+r.height/16]}var K=(e,o)=>Math.abs(e-o),_=(e,o,r,n)=>K(e,r)*K(o,n)===2,ue=(e,o,r,n)=>e===r!=(o===n),pe=(e,o,r,n)=>K(e,r)===K(o,n)&&e!==r,fe=(e,o,r,n)=>ue(e,o,r,n)||pe(e,o,r,n),Ke=(e,o,r,n)=>Math.max(K(e,r),K(o,n))===1,xe=(e,o,r,n,t)=>K(e,r)===1&&n===o+(t?1:-1),Ee=(e,o,r,n,t)=>{let i=t?1:-1;return e===r&&(n===o+i||n===o+2*i&&(t?o<=1:o>=6))},Q=(e,o,r,n)=>{let t=r-e,i=n-o;if(t&&i&&Math.abs(t)!==Math.abs(i))return[];let a=Math.sign(t),c=Math.sign(i),l=[],s=e+a,p=o+c;for(;s!==r||p!==n;)l.push([s,p]),s+=a,p+=c;return l.map(d=>m(d))},no=e=>{let o=f(e),r=[];return o[0]>0&&r.push([o[0]-1,o[1]]),o[0]<7&&r.push([o[0]+1,o[1]]),r.map(m)},J=(e,o)=>{let r=f(e);return r[1]+=o,m(r)};var U=e=>e.friendlies.has(m(e.pos2)),tr=e=>e.enemies.has(m(e.pos2)),to=(e,o,r)=>Q(...e,...o).some(n=>r.has(n)),io=(e,o,r)=>{let n=r.enemies.get(e);if(n?.role!=="pawn")return!1;let t=n.color==="white"?1:-1,i=f(e),a=f(o);return Ee(...i,...a,n.color==="white")&&!to(i,[a[0],a[1]+t],r.allPieces)},ir=(e,o,r)=>{let n=r.enemies.get(e);return n?.role==="pawn"&&xe(...f(e),...f(o),n.color==="white")&&(r.friendlies.has(o)||me(J(o,n.color==="white"?-1:1),r.friendlies,r.enemies,r.lastMove))},ar=e=>[...e.enemies.keys()].some(o=>io(o,m(e.pos2),e)),Ae=(e,o)=>{let r=e.pos2;return[...e.enemies].some(([n,t])=>{let i=f(n);return!o?.includes(t.role)&&(t.role==="pawn"&&xe(...i,...r,t.color==="white")||t.role==="knight"&&_(...i,...r)||t.role==="bishop"&&pe(...i,...r)||t.role==="rook"&&ue(...i,...r)||t.role==="queen"&&fe(...i,...r)||t.role==="king"&&Ke(...i,...r))&&(!["bishop","rook","queen"].includes(t.role)||!to(i,r,e.allPieces))})},ge=e=>U(e)&&(me(m(e.pos2),e.friendlies,e.enemies,e.lastMove)||Ae(e)),me=(e,o,r,n)=>{if(n&&e!==n[1])return!1;let t=f(e),i=o.get(e);return i?.role==="pawn"&&t[1]===(i.color==="white"?3:4)&&(!n||K(f(n[0])[1],t[1])===2)&&[1,-1].some(a=>r.get(m([t[0]+a,t[1]]))?.role==="pawn")},sr=e=>{if(e.unrestrictedPremoves)return!0;let o=Q(...e.pos1,...e.pos2),r=o.filter(n=>e.friendlies.has(n));return!r.length||r.length===1&&me(r[0],e.friendlies,e.enemies,e.lastMove)&&!o.includes(J(r[0],e.color==="white"?-1:1))},cr=e=>{if(e.unrestrictedPremoves)return!0;let o=Q(...e.pos1,...e.pos2),r=o.filter(s=>e.enemies.has(s));if(r.length>1)return!1;if(!r.length)return!0;let n=r[0],t=e.enemies.get(n);if(!t||t.role!=="pawn")return!0;let i=t.color==="white"?1:-1,a=J(n,i),c=[...no(a).filter(s=>ir(n,s,e)),...[a,J(a,i)].filter(s=>io(n,s,e))],l=[...o,m(e.pos1)];return c.some(s=>!l.includes(s))},Ne=e=>sr(e)&&cr(e),lr=e=>{let o=e.color==="white"?1:-1;return K(e.pos1[0],e.pos2[0])>1?!1:K(e.pos1[0],e.pos2[0])?e.pos2[1]!==e.pos1[1]+o?!1:e.unrestrictedPremoves||tr(e)?!0:U(e)?Ae(e):ar(e)||me(m([e.pos2[0],e.pos2[1]+o]),e.friendlies,e.enemies,e.lastMove)||Ae(e,["pawn"]):Ee(...e.pos1,...e.pos2,e.color==="white")&&Ne({...e,pos2:[e.pos2[0],e.pos2[1]+o]})},dr=e=>_(...e.pos1,...e.pos2)&&(e.unrestrictedPremoves||!U(e)||ge(e)),ao=e=>pe(...e.pos1,...e.pos2)&&Ne(e)&&(e.unrestrictedPremoves||!U(e)||ge(e)),so=e=>ue(...e.pos1,...e.pos2)&&Ne(e)&&(e.unrestrictedPremoves||!U(e)||ge(e)),ur=e=>ao(e)||so(e),pr=e=>Ke(...e.pos1,...e.pos2)&&(e.unrestrictedPremoves||!U(e)||ge(e))||e.canCastle&&e.pos1[1]===e.pos2[1]&&e.pos1[1]===(e.color==="white"?0:7)&&(e.pos1[0]===4&&(e.pos2[0]===2&&e.rookFilesFriendlies.includes(0)||e.pos2[0]===6&&e.rookFilesFriendlies.includes(7))||e.rookFilesFriendlies.includes(e.pos2[0]))&&(e.unrestrictedPremoves||Q(...e.pos1,e.pos2[0]>e.pos1[0]?7:1,e.pos2[1]).map(o=>e.allPieces.get(o)).every(o=>!o||G(o,{role:"rook",color:e.color}))),fr={pawn:lr,knight:dr,bishop:ao,rook:so,queen:ur,king:pr};function He(e,o){let r=e.pieces,n=e.premovable.castle,t=!!e.premovable.unrestrictedPremoves,i=r.get(o);if(!i||i.color===e.turnColor)return[];let a=i.color,c=new Map([...r].filter(([u,b])=>b.color===a)),l=new Map([...r].filter(([u,b])=>b.color===j(a))),s=f(o),p=fr[i.role],d={pos1:s,allPieces:r,friendlies:c,enemies:l,unrestrictedPremoves:t,color:a,canCastle:n,rookFilesFriendlies:Array.from(r).filter(([u,b])=>u[1]===(a==="white"?"1":"8")&&b.color===a&&b.role==="rook").map(([u])=>f(u)[0]),lastMove:e.lastMove};return ce.filter(u=>p({...d,pos2:u})).map(m)}function M(e,...o){e&&setTimeout(()=>e(...o),1)}function co(e){e.orientation=j(e.orientation),e.animation.current=e.draggable.current=e.selected=void 0}function lo(e,o){for(let[r,n]of o)n?e.pieces.set(r,n):e.pieces.delete(r)}function uo(e,o){if(e.check=void 0,o===!0&&(o=e.turnColor),o)for(let[r,n]of e.pieces)n.role==="king"&&n.color===o&&(e.check=r)}function gr(e,o,r,n){E(e),e.premovable.current=[o,r],M(e.premovable.events.set,o,r,n)}function x(e){e.premovable.current&&(e.premovable.current=void 0,M(e.premovable.events.unset))}function mr(e,o,r){x(e),e.predroppable.current={role:o,key:r},M(e.predroppable.events.set,o,r)}function E(e){let o=e.predroppable;o.current&&(o.current=void 0,M(o.events.unset))}function br(e,o,r){if(!e.autoCastle)return!1;let n=e.pieces.get(o);if(!n||n.role!=="king")return!1;let t=f(o),i=f(r);if(t[1]!==0&&t[1]!==7||t[1]!==i[1])return!1;t[0]===4&&!e.pieces.has(r)&&(i[0]===6?r=m([7,i[1]]):i[0]===2&&(r=m([0,i[1]])));let a=e.pieces.get(r);return!a||a.color!==n.color||a.role!=="rook"?!1:(e.pieces.delete(o),e.pieces.delete(r),t[0]<i[0]?(e.pieces.set(m([6,i[1]]),n),e.pieces.set(m([5,i[1]]),a)):(e.pieces.set(m([2,i[1]]),n),e.pieces.set(m([3,i[1]]),a)),!0)}function qe(e,o,r){let n=e.pieces.get(o),t=e.pieces.get(r);if(o===r||!n)return!1;let i=t&&t.color!==n.color?t:void 0;return r===e.selected&&P(e),M(e.events.move,o,r,i),br(e,o,r)||(e.pieces.set(r,n),e.pieces.delete(o)),e.lastMove=[o,r],e.check=void 0,M(e.events.change),i||!0}function be(e,o,r,n){if(e.pieces.has(r))if(n)e.pieces.delete(r);else return!1;return M(e.events.dropNewPiece,o,r),e.pieces.set(r,o),e.lastMove=[r],e.check=void 0,M(e.events.change),e.movable.dests=void 0,e.turnColor=j(e.turnColor),!0}function po(e,o,r){let n=qe(e,o,r);return n&&(e.movable.dests=void 0,e.turnColor=j(e.turnColor),e.animation.current=void 0),n}function Te(e,o,r){if(ve(e,o,r)){let n=po(e,o,r);if(n){let t=e.hold.stop();P(e);let i={premove:!1,ctrlKey:e.stats.ctrlKey,holdTime:t};return n!==!0&&(i.captured=n),M(e.movable.events.after,o,r,i),!0}}else if(vr(e,o,r))return gr(e,o,r,{ctrlKey:e.stats.ctrlKey}),P(e),!0;return P(e),!1}function he(e,o,r,n){let t=e.pieces.get(o);t&&(hr(e,o,r)||n)?(e.pieces.delete(o),be(e,t,r,n),M(e.movable.events.afterNewPiece,t.role,r,{premove:!1,predrop:!1})):t&&yr(e,o,r)?mr(e,t.role,r):(x(e),E(e)),e.pieces.delete(o),P(e)}function oe(e,o,r){if(M(e.events.select,o),e.selected){if(e.selected===o&&!e.draggable.enabled){P(e),e.hold.cancel();return}else if((e.selectable.enabled||r)&&e.selected!==o&&Te(e,e.selected,o)){e.stats.dragged=!1;return}}(e.selectable.enabled||e.draggable.enabled)&&(fo(e,o)||Oe(e,o))&&(Be(e,o),e.hold.start())}function Be(e,o){e.selected=o,Oe(e,o)?e.premovable.customDests||(e.premovable.dests=He(e,o)):e.premovable.dests=void 0}function P(e){e.selected=void 0,e.premovable.dests=void 0,e.hold.cancel()}function fo(e,o){let r=e.pieces.get(o);return!!r&&(e.movable.color==="both"||e.movable.color===r.color&&e.turnColor===r.color)}var ve=(e,o,r)=>o!==r&&fo(e,o)&&(e.movable.free||!!e.movable.dests?.get(o)?.includes(r));function hr(e,o,r){let n=e.pieces.get(o);return!!n&&(o===r||!e.pieces.has(r))&&(e.movable.color==="both"||e.movable.color===n.color&&e.turnColor===n.color)}function Oe(e,o){let r=e.pieces.get(o);return!!r&&e.premovable.enabled&&e.movable.color===r.color&&e.turnColor!==r.color}var vr=(e,o,r)=>o!==r&&Oe(e,o)&&(e.premovable.customDests?.get(o)??He(e,o)).includes(r);function yr(e,o,r){let n=e.pieces.get(o),t=e.pieces.get(r);return!!n&&(!t||t.color!==e.movable.color)&&e.predroppable.enabled&&(n.role!=="pawn"||r[1]!=="1"&&r[1]!=="8")&&e.movable.color===n.color&&e.turnColor!==n.color}function go(e,o){let r=e.pieces.get(o);return!!r&&e.draggable.enabled&&(e.movable.color==="both"||e.movable.color===r.color&&(e.turnColor===r.color||e.premovable.enabled))}function mo(e){let o=e.premovable.current;if(!o)return!1;let r=o[0],n=o[1],t=!1;if(ve(e,r,n)){let i=po(e,r,n);if(i){let a={premove:!0};i!==!0&&(a.captured=i),M(e.movable.events.after,r,n,a),t=!0}}return x(e),t}function bo(e,o){let r=e.predroppable.current,n=!1;if(!r)return!1;if(o(r)){let t={role:r.role,color:e.movable.color};be(e,t,r.key)&&(M(e.movable.events.afterNewPiece,r.role,r.key,{premove:!1,predrop:!0}),n=!0)}return E(e),n}function re(e){x(e),E(e),P(e)}function Re(e){e.movable.color=e.movable.dests=e.animation.current=void 0,re(e)}function A(e,o,r){let n=Math.floor(8*(e[0]-r.left)/r.width);o||(n=7-n);let t=7-Math.floor(8*(e[1]-r.top)/r.height);return o||(t=7-t),n>=0&&n<8&&t>=0&&t<8?m([n,t]):void 0}function ho(e,o,r,n){let t=f(e),i=ce.filter(s=>ro(t,s)||fe(t[0],t[1],s[0],s[1])||_(t[0],t[1],s[0],s[1])),c=i.map(s=>de(m(s),r,n)).map(s=>V(o,s)),[,l]=c.reduce((s,p,d)=>s[0]<p?s:[p,d],[c[0],0]);return m(i[l])}var v=e=>e.orientation==="white";var Le="rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR",wr={p:"pawn",r:"rook",n:"knight",b:"bishop",q:"queen",k:"king"},Sr={pawn:"p",rook:"r",knight:"n",bishop:"b",queen:"q",king:"k"};function ye(e){e==="start"&&(e=Le);let o=new Map,r=7,n=0;for(let t of e)switch(t){case" ":case"[":return o;case"/":if(--r,r<0)return o;n=0;break;case"~":{let i=o.get(m([n-1,r]));i&&(i.promoted=!0);break}default:{let i=t.charCodeAt(0);if(i<57)n+=i-48;else{let a=t.toLowerCase();o.set(m([n,r]),{role:wr[a],color:t===a?"black":"white"}),++n}}}return o}function vo(e){return Je.map(o=>F.map(r=>{let n=e.get(r+o);if(n){let t=Sr[n.role];return n.color==="white"&&(t=t.toUpperCase()),n.promoted&&(t+="~"),t}else return"1"}).join("")).join("/").replace(/1{2,}/g,o=>o.length.toString())}function Fe(e,o){o.animation&&(Ge(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=[]),Ge(e,o),o.fen&&(e.pieces=ye(o.fen),e.drawable.shapes=o.drawable?.shapes||[]),"check"in o&&uo(e,o.check||!1),"lastMove"in o&&!o.lastMove?e.lastMove=void 0:o.lastMove&&(e.lastMove=o.lastMove),e.selected&&Be(e,e.selected),Fe(e,o),!e.movable.rookCastle&&e.movable.dests){let r=e.movable.color==="white"?"1":"8",n="e"+r,t=e.movable.dests.get(n),i=e.pieces.get(n);if(!t||!i||i.role!=="king")return;e.movable.dests.set(n,t.filter(a=>!(a==="a"+r&&t.includes("c"+r))&&!(a==="h"+r&&t.includes("g"+r))))}}function Ge(e,o){for(let r in o)r==="__proto__"||r==="constructor"||!Object.prototype.hasOwnProperty.call(o,r)||(Object.prototype.hasOwnProperty.call(e,r)&&yo(e[r])&&yo(o[r])?Ge(e[r],o[r]):e[r]=o[r])}function yo(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?Cr(e,o):O(e,o);function O(e,o){let r=e(o);return o.dom.redraw(),r}var We=(e,o)=>({key:e,pos:f(e),piece:o}),Mr=(e,o)=>o.sort((r,n)=>V(e.pos,r.pos)-V(e.pos,n.pos))[0];function kr(e,o){let r=new Map,n=[],t=new Map,i=[],a=[],c=new Map,l,s,p;for(let[d,u]of e)c.set(d,We(d,u));for(let d of se)l=o.pieces.get(d),s=c.get(d),l?s?G(l,s.piece)||(i.push(s),a.push(We(d,l))):a.push(We(d,l)):s&&i.push(s);for(let d of a)s=Mr(d,i.filter(u=>G(d.piece,u.piece))),s&&(p=[s.pos[0]-d.pos[0],s.pos[1]-d.pos[1]],r.set(d.key,p.concat(p)),n.push(s.key));for(let d of i)n.includes(d.key)||t.set(d.key,d.piece);return{anims:r,fadings:t}}function wo(e,o){let r=e.animation.current;if(r===void 0){e.dom.destroyed||e.dom.redrawNow();return}let n=1-(o-r.start)*r.frequency;if(n<=0)e.animation.current=void 0,e.dom.redrawNow();else{let t=Dr(n);for(let i of r.plan.anims.values())i[2]=i[0]*t,i[3]=i[1]*t;e.dom.redrawNow(!0),requestAnimationFrame((i=performance.now())=>wo(e,i))}}function Cr(e,o){let r=new Map(o.pieces),n=e(o),t=kr(r,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||wo(o,performance.now())}else o.dom.redraw();return n}var Dr=e=>e<.5?4*e*e*e:(e-1)*(2*e-2)*(2*e-2)+1;var Kr=["green","red","blue","yellow"];function So(e,o){if(o.touches&&o.touches.length>1)return;o.stopPropagation(),o.preventDefault(),o.ctrlKey?P(e):re(e);let r=T(o),n=A(r,v(e),e.dom.bounds());n&&(e.drawable.current={orig:n,pos:r,brush:xr(o),snapToValidMove:e.drawable.defaultSnapToValidMove},Po(e))}function Po(e){requestAnimationFrame(()=>{let o=e.drawable.current;if(o){let r=A(o.pos,v(e),e.dom.bounds());r||(o.snapToValidMove=!1);let n=o.snapToValidMove?ho(o.orig,o.pos,v(e),e.dom.bounds()):r;n!==o.mouseSq&&(o.mouseSq=n,o.dest=n!==o.orig?n:void 0,e.dom.redrawNow()),Po(e)}})}function Mo(e,o){e.drawable.current&&(e.drawable.current.pos=T(o))}function ko(e){let o=e.drawable.current;o&&(o.mouseSq&&Er(e.drawable,o),ze(e))}function ze(e){e.drawable.current&&(e.drawable.current=void 0,e.dom.redraw())}function Co(e){e.drawable.shapes.length&&(e.drawable.shapes=[],e.dom.redraw(),Do(e.drawable))}function xr(e){let o=(e.shiftKey||e.ctrlKey)&&le(e),r=e.altKey||e.metaKey||e.getModifierState?.("AltGraph");return Kr[(o?1:0)+(r?2:0)]}function Er(e,o){let r=t=>t.orig===o.orig&&t.dest===o.dest,n=e.shapes.find(r);n&&(e.shapes=e.shapes.filter(t=>!r(t))),(!n||n.brush!==o.brush)&&e.shapes.push({orig:o.orig,dest:o.dest,brush:o.brush}),Do(e)}function Do(e){e.onChange&&e.onChange(e.shapes)}function Ko(e,o){if(!(e.trustAllEvents||o.isTrusted)||o.buttons!==void 0&&o.buttons>1||o.touches&&o.touches.length>1)return;let r=e.dom.bounds(),n=T(o),t=A(n,v(e),r);if(!t)return;let i=e.pieces.get(t),a=e.selected;if(!a&&e.drawable.enabled&&(e.drawable.eraseOnClick||!i||i.color!==e.turnColor)&&Co(e),o.cancelable!==!1&&(!o.touches||e.blockTouchScroll||i||a||Nr(e,n)))o.preventDefault();else if(o.touches)return;let c=!!e.premovable.current,l=!!e.predroppable.current;e.stats.ctrlKey=o.ctrlKey,e.selected&&ve(e,e.selected,t)?B(d=>oe(d,t),e):oe(e,t);let s=e.selected===t,p=Ho(e,t);if(i&&p&&s&&go(e,t)){e.draggable.current={orig:t,piece:i,origPos:n,pos:n,started:e.draggable.autoDistance&&e.stats.dragged,element:p,previouslySelected:a,originTarget:o.target,keyHasChanged:!1},p.cgDragging=!0,p.classList.add("dragging");let d=e.dom.elements.ghost;d&&(d.className=`ghost ${i.color} ${i.role}`,k(d,L(r)(f(t),v(e))),Y(d,!0)),$e(e)}else c&&x(e),l&&E(e);e.dom.redraw()}function Nr(e,o){let r=v(e),n=e.dom.bounds(),t=Math.pow(n.width/8,2);for(let i of e.pieces.keys()){let a=de(i,r,n);if(V(a,o)<=t)return!0}return!1}function xo(e,o,r,n){let t="a0";e.pieces.set(t,o),e.dom.redraw();let i=T(r);e.draggable.current={orig:t,piece:o,origPos:i,pos:i,started:!0,element:()=>Ho(e,t),originTarget:r.target,newPiece:!0,force:!!n,keyHasChanged:!1},$e(e)}function $e(e){requestAnimationFrame(()=>{let o=e.draggable.current;if(!o)return;e.animation.current?.plan.anims.has(o.orig)&&(e.animation.current=void 0);let r=e.pieces.get(o.orig);if(!r||!G(r,o.piece))W(e);else if(!o.started&&V(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 n=e.dom.bounds();k(o.element,[o.pos[0]-n.left-n.width/16,o.pos[1]-n.top-n.height/16]),o.keyHasChanged||=o.orig!==A(o.pos,v(e),n)}$e(e)})}function Eo(e,o){e.draggable.current&&(!o.touches||o.touches.length<2)&&(e.draggable.current.pos=T(o))}function Ao(e,o){let r=e.draggable.current;if(!r)return;if(o.type==="touchend"&&o.cancelable!==!1&&o.preventDefault(),o.type==="touchend"&&r.originTarget!==o.target&&!r.newPiece){e.draggable.current=void 0;return}x(e),E(e);let n=T(o)||r.pos,t=A(n,v(e),e.dom.bounds());t&&r.started&&r.orig!==t?r.newPiece?he(e,r.orig,t,r.force):(e.stats.ctrlKey=o.ctrlKey,Te(e,r.orig,t)&&(e.stats.dragged=!0)):r.newPiece?e.pieces.delete(r.orig):e.draggable.deleteOnDropOff&&!t&&(e.pieces.delete(r.orig),M(e.events.change)),(r.orig===r.previouslySelected||r.keyHasChanged)&&(r.orig===t||!t)?P(e):e.selectable.enabled||P(e),No(e),e.draggable.current=void 0,e.dom.redraw()}function W(e){let o=e.draggable.current;o&&(o.newPiece&&e.pieces.delete(o.orig),e.draggable.current=void 0,P(e),No(e),e.dom.redraw())}function No(e){let o=e.dom.elements;o.ghost&&Y(o.ghost,!1)}function Ho(e,o){let r=e.dom.elements.board.firstChild;for(;r;){if(r.cgKey===o&&r.tagName==="PIECE")return r;r=r.nextSibling}}function To(e,o){e.exploding={stage:1,keys:o},e.dom.redraw(),setTimeout(()=>{qo(e,2),setTimeout(()=>qo(e,void 0),120)},120)}function qo(e,o){e.exploding&&(o?e.exploding.stage=o:e.exploding=void 0,e.dom.redraw())}function Bo(e,o){function r(){co(e),o()}return{set(n){n.orientation&&n.orientation!==e.orientation&&r(),Fe(e,n),(n.fen?B:O)(t=>we(t,n),e)},state:e,getFen:()=>vo(e.pieces),toggleOrientation:r,setPieces(n){B(t=>lo(t,n),e)},selectSquare(n,t){n?B(i=>oe(i,n,t),e):e.selected&&(P(e),e.dom.redraw())},move(n,t){B(i=>qe(i,n,t),e)},newPiece(n,t){B(i=>be(i,n,t),e)},playPremove(){if(e.premovable.current){if(B(mo,e))return!0;e.dom.redraw()}return!1},playPredrop(n){if(e.predroppable.current){let t=bo(e,n);return e.dom.redraw(),t}return!1},cancelPremove(){O(x,e)},cancelPredrop(){O(E,e)},cancelMove(){O(n=>{re(n),W(n)},e)},stop(){O(n=>{Re(n),W(n)},e)},explode(n){To(e,n)},setAutoShapes(n){O(t=>t.drawable.autoShapes=n,e)},setShapes(n){O(t=>t.drawable.shapes=n.slice(),e)},getKeyAtDomPos(n){return A(n,v(e),e.dom.bounds())},redrawAll:o,dragNewPiece(n,t,i){xo(e,n,t,i)},destroy(){Re(e),e.dom.unbind&&e.dom.unbind(),e.dom.destroyed=!0}}}function Oo(){return{pieces:ye(Le),orientation:"white",turnColor:"white",coordinates:!0,coordinatesOnSquares:!1,ranksPosition:"right",autoCastle:!0,viewOnly:!1,disableContextMenu:!1,addPieceZIndex:!1,blockTouchScroll:!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,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,eraseOnClick:!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}},prevSvgHash:""},hold:oo()}}var Ro={hilitePrimary:{key:"hilitePrimary",color:"#3291ff",opacity:1,lineWidth:1},hiliteWhite:{key:"hiliteWhite",color:"#ffffff",opacity:1,lineWidth:1}};function Fo(){let e=y("defs"),o=S(y("filter"),{id:"cg-filter-blur"});return o.appendChild(S(y("feGaussianBlur"),{stdDeviation:"0.019"})),e.appendChild(o),e}function Go(e,o,r){let n=e.drawable,t=n.current,i=t&&t.mouseSq?t:void 0,a=new Map,c=e.dom.bounds(),l=n.autoShapes.filter(u=>!u.piece);for(let u of n.shapes.concat(l).concat(i?[i]:[])){if(!u.dest)continue;let b=a.get(u.dest)??new Set,w=Me(Pe(f(u.orig),e.orientation),c),g=Me(Pe(f(u.dest),e.orientation),c);b.add(je(w,g)),a.set(u.dest,b)}let s=n.shapes.concat(l).map(u=>({shape:u,current:!1,hash:Vo(u,Ie(u.dest,a),!1,c)}));i&&s.push({shape:i,current:!0,hash:Vo(i,Ie(i.dest,a),!0,c)});let p=s.map(u=>u.hash).join(";");if(p===e.drawable.prevSvgHash)return;e.drawable.prevSvgHash=p;let d=o.querySelector("defs");qr(n,s,d),Tr(s,o.querySelector("g"),r.querySelector("g"),u=>Rr(e,u,n.brushes,a,c))}function qr(e,o,r){let n=new Map,t;for(let c of o.filter(l=>l.shape.dest&&l.shape.brush))t=Wo(e.brushes[c.shape.brush],c.shape.modifiers),c.shape.modifiers?.hilite&&n.set(Se(t).key,Se(t)),n.set(t.key,t);let i=new Set,a=r.firstElementChild;for(;a;)i.add(a.getAttribute("cgKey")),a=a.nextElementSibling;for(let[c,l]of n.entries())i.has(c)||r.appendChild(Fr(l))}function Tr(e,o,r,n){let t=new Map;for(let i of e)t.set(i.hash,!1);for(let i of[o,r]){let a=[],c=i.firstElementChild,l;for(;c;)l=c.getAttribute("cgHash"),t.has(l)?t.set(l,!0):a.push(c),c=c.nextElementSibling;for(let s of a)i.removeChild(s)}for(let i of e.filter(a=>!t.get(a.hash)))for(let a of n(i))a.isCustom?r.appendChild(a.el):o.appendChild(a.el)}function Vo({orig:e,dest:o,brush:r,piece:n,modifiers:t,customSvg:i,label:a},c,l,s){return[s.width,s.height,l,e,o,r,c&&"-",n&&Br(n),t&&Or(t),i&&`custom-${Lo(i.html)},${i.center?.[0]??"o"}`,a&&`label-${Lo(a.text)}`].filter(p=>p).join(",")}function Br(e){return[e.color,e.role,e.scale].filter(o=>o).join(",")}function Or(e){return[e.lineWidth,e.hilite&&"*"].filter(o=>o).join(",")}function Lo(e){let o=0;for(let r=0;r<e.length;r++)o=(o<<5)-o+e.charCodeAt(r)>>>0;return o.toString()}function Rr(e,{shape:o,current:r,hash:n},t,i,a){let c=Me(Pe(f(o.orig),e.orientation),a),l=o.dest?Me(Pe(f(o.dest),e.orientation),a):c,s=o.brush&&Wo(t[o.brush],o.modifiers),p=i.get(o.dest),d=[];if(s){let u=S(y("g"),{cgHash:n});d.push({el:u}),c[0]!==l[0]||c[1]!==l[1]?u.appendChild(Lr(o,s,c,l,r,Ie(o.dest,i))):u.appendChild(Vr(t[o.brush],c,r,a))}if(o.label){let u=o.label;u.fill??=o.brush&&t[o.brush].color;let b=o.brush?void 0:"tr";d.push({el:Gr(u,n,c,l,p,b),isCustom:!0})}if(o.customSvg){let u=o.customSvg.center??"orig",[b,w]=u==="label"?$o(c,l,p).map(z=>z-.5):u==="dest"?l:c,g=S(y("g"),{transform:`translate(${b},${w})`,cgHash:n});g.innerHTML=`<svg width="1" height="1" viewBox="0 0 100 100">${o.customSvg.html}</svg>`,d.push({el:g,isCustom:!0})}return d}function Vr(e,o,r,n){let t=Wr(),i=(n.width+n.height)/(4*Math.max(n.width,n.height));return S(y("circle"),{stroke:e.color,"stroke-width":t[r?0:1],fill:"none",opacity:zo(e,r),cx:o[0],cy:o[1],r:i-t[1]/2})}function Se(e){return["#ffffff","#fff","white"].includes(e.color)?Ro.hilitePrimary:Ro.hiliteWhite}function Lr(e,o,r,n,t,i){function a(s){let p=$r(i&&!t),d=n[0]-r[0],u=n[1]-r[1],b=Math.atan2(u,d),w=Math.cos(b)*p,g=Math.sin(b)*p;return S(y("line"),{stroke:s?Se(o).color:o.color,"stroke-width":zr(o,t)+(s?.04:0),"stroke-linecap":"round","marker-end":`url(#arrowhead-${s?Se(o).key:o.key})`,opacity:e.modifiers?.hilite?1:zo(o,t),x1:r[0],y1:r[1],x2:n[0]-w,y2:n[1]-g})}if(!e.modifiers?.hilite)return a(!1);let c=y("g"),l=S(y("g"),{filter:"url(#cg-filter-blur)"});return l.appendChild(Ir(r,n)),l.appendChild(a(!0)),c.appendChild(l),c.appendChild(a(!1)),c}function Fr(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 Gr(e,o,r,n,t,i){let c=.4*.75**e.text.length,l=$o(r,n,t),s=i==="tr"?.4:0,p=S(y("g"),{transform:`translate(${l[0]+s},${l[1]-s})`,cgHash:o});p.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 d=S(y("text"),{"font-size":c,"font-family":"Noto Sans","text-anchor":"middle",fill:"white",y:.13*.75**e.text.length});return d.innerHTML=e.text,p.appendChild(d),p}function Pe(e,o){return o==="white"?e:[7-e[0],7-e[1]]}function Ie(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 r in o)Object.prototype.hasOwnProperty.call(o,r)&&e.setAttribute(r,o[r]);return e}function Wo(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(r=>r).join("")}:e}function Wr(){return[3/64,4/64]}function zr(e,o){return(e.lineWidth||10)*(o?.85:1)/64}function zo(e,o){return(e.opacity||1)*(o?.9:1)}function $r(e){return(e?20:10)/64}function Me(e,o){let r=Math.min(1,o.width/o.height),n=Math.min(1,o.height/o.width);return[(e[0]-3.5)*r,(3.5-e[1])*n]}function Ir(e,o){let r={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:r.from[0],y:r.from[1],width:r.to[0]-r.from[0],height:r.to[1]-r.from[1],fill:"none",stroke:"none"})}function je(e,o,r=!0){let n=Math.atan2(o[1]-e[1],o[0]-e[0])+Math.PI;return r?(Math.round(n*8/Math.PI)+16)%16:n}function jr(e,o){return Math.sqrt([e[0]-o[0],e[1]-o[1]].reduce((r,n)=>r+n*n,0))}function $o(e,o,r){let n=jr(e,o),t=je(e,o,!1);if(r&&(n-=33/64,r.size>1)){n-=10/64;let i=je(e,o);(r.has((i+1)%16)||r.has((i+15)%16))&&i&1&&(n-=.4)}return[e[0]-Math.cos(t)*n,e[1]-Math.sin(t)*n].map(i=>i+.5)}function Io(e,o){e.innerHTML="",e.classList.add("cg-wrap");for(let l of _e)e.classList.toggle("orientation-"+l,o.orientation===l);e.classList.toggle("manipulable",!o.viewOnly);let r=C("cg-container");e.appendChild(r);let n=C("cg-board");r.appendChild(n);let t,i,a;if(o.drawable.visible&&(t=S(y("svg"),{class:"cg-shapes",viewBox:"-4 -4 8 8",preserveAspectRatio:"xMidYMid slice"}),t.appendChild(Fo()),t.appendChild(y("g")),i=S(y("svg"),{class:"cg-custom-svgs",viewBox:"-3.5 -3.5 8 8",preserveAspectRatio:"xMidYMid slice"}),i.appendChild(y("g")),a=C("cg-auto-pieces"),r.appendChild(t),r.appendChild(i),r.appendChild(a)),o.coordinates){let l=o.orientation==="black"?" black":"",s=o.ranksPosition==="left"?" left":"";if(o.coordinatesOnSquares){let p=o.orientation==="white"?d=>d+1:d=>8-d;F.forEach((d,u)=>r.appendChild(Ue(I.map(b=>d+b),"squares rank"+p(u)+l+s)))}else r.appendChild(Ue(I,"ranks"+l+s)),r.appendChild(Ue(F,"files"+l))}let c;return o.draggable.enabled&&o.draggable.showGhost&&(c=C("piece","ghost"),Y(c,!1),r.appendChild(c)),{board:n,container:r,wrap:e,ghost:c,svg:t,customSvg:i,autoPieces:a}}function Ue(e,o){let r=C("coords",o),n;for(let t of e)n=C("coord"),n.textContent=t,r.appendChild(n);return r}function jo(e,o){if(!e.dropmode.active)return;x(e),E(e);let r=e.dropmode.piece;if(r){e.pieces.set("a0",r);let n=T(o),t=n&&A(n,v(e),e.dom.bounds());t&&he(e,"a0",t)}e.dom.redraw()}function Zo(e,o){let r=e.dom.elements.board;if("ResizeObserver"in window&&new ResizeObserver(o).observe(e.dom.elements.wrap),(e.disableContextMenu||e.drawable.enabled)&&r.addEventListener("contextmenu",t=>t.preventDefault()),e.viewOnly)return;let n=Zr(e);r.addEventListener("touchstart",n,{passive:!1}),r.addEventListener("mousedown",n,{passive:!1})}function Xo(e,o){let r=[];if("ResizeObserver"in window||r.push(ne(document.body,"chessground.resize",o)),!e.viewOnly){let n=Uo(e,Eo,Mo),t=Uo(e,Ao,ko);for(let a of["touchmove","mousemove"])r.push(ne(document,a,n));for(let a of["touchend","mouseup"])r.push(ne(document,a,t));let i=()=>e.dom.bounds.clear();r.push(ne(document,"scroll",i,{capture:!0,passive:!0})),r.push(ne(window,"resize",i,{passive:!0}))}return()=>r.forEach(n=>n())}function ne(e,o,r,n){return e.addEventListener(o,r,n),()=>e.removeEventListener(o,r,n)}var Zr=e=>o=>{e.draggable.current?W(e):e.drawable.current?ze(e):o.shiftKey||le(o)?e.drawable.enabled&&So(e,o):e.viewOnly||(e.dropmode.active?jo(e,o):Ko(e,o))},Uo=(e,o,r)=>n=>{e.drawable.current?e.drawable.enabled&&r(e,n):e.viewOnly||o(e,n)};function _o(e){let o=v(e),r=L(e.dom.bounds()),n=e.dom.elements.board,t=e.pieces,i=e.animation.current,a=i?i.plan.anims:new Map,c=i?i.plan.fadings:new Map,l=e.draggable.current,s=Yr(e),p=new Set,d=new Set,u=new Map,b=new Map,w,g,z,$,D,Z,ke,N,Ce,ie;for(g=n.firstChild;g;){if(w=g.cgKey,Jo(g))if(z=t.get(w),D=a.get(w),Z=c.get(w),$=g.cgPiece,g.cgDragging&&(!l||l.orig!==w)&&(g.classList.remove("dragging"),k(g,r(f(w),o)),g.cgDragging=!1),!Z&&g.cgFading&&(g.cgFading=!1,g.classList.remove("fading")),z){if(D&&g.cgAnimating&&$===te(z)){let h=f(w);h[0]+=D[2],h[1]+=D[3],g.classList.add("anim"),k(g,r(h,o))}else g.cgAnimating&&(g.cgAnimating=!1,g.classList.remove("anim"),k(g,r(f(w),o)),e.addPieceZIndex&&(g.style.zIndex=Ze(f(w),o)));$===te(z)&&(!Z||!g.cgFading)?p.add(w):Z&&$===te(Z)?(g.classList.add("fading"),g.cgFading=!0):Xe(u,$,g)}else Xe(u,$,g);else if(er(g)){let h=g.className;s.get(w)===h?d.add(w):Xe(b,h,g)}g=g.nextSibling}for(let[h,X]of s)if(!d.has(h)){Ce=b.get(X),ie=Ce&&Ce.pop();let H=r(f(h),o);if(ie)ie.cgKey=h,k(ie,H);else{let q=C("square",X);q.cgKey=h,k(q,H),n.insertBefore(q,n.firstChild)}}for(let[h,X]of t)if(D=a.get(h),!p.has(h))if(ke=u.get(te(X)),N=ke&&ke.pop(),N){N.cgKey=h,N.cgFading&&(N.classList.remove("fading"),N.cgFading=!1);let H=f(h);e.addPieceZIndex&&(N.style.zIndex=Ze(H,o)),D&&(N.cgAnimating=!0,N.classList.add("anim"),H[0]+=D[2],H[1]+=D[3]),k(N,r(H,o))}else{let H=te(X),q=C("piece",H),ae=f(h);q.cgPiece=H,q.cgKey=h,D&&(q.cgAnimating=!0,ae[0]+=D[2],ae[1]+=D[3]),k(q,r(ae,o)),e.addPieceZIndex&&(q.style.zIndex=Ze(ae,o)),n.appendChild(q)}for(let h of u.values())Yo(e,h);for(let h of b.values())Yo(e,h)}function Qo(e){let o=v(e),r=L(e.dom.bounds()),n=e.dom.elements.board.firstChild;for(;n;)(Jo(n)&&!n.cgAnimating||er(n))&&k(n,r(f(n.cgKey),o)),n=n.nextSibling}function Ye(e){let o=e.dom.elements.wrap.getBoundingClientRect(),r=e.dom.elements.container,n=o.height/o.width,t=Math.floor(o.width*window.devicePixelRatio/8)*8/window.devicePixelRatio,i=t*n;r.style.width=t+"px",r.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 Jo=e=>e.tagName==="PIECE",er=e=>e.tagName==="SQUARE";function Yo(e,o){for(let r of o)e.dom.elements.board.removeChild(r)}function Ze(e,o){let n=e[1];return`${o?10-n:3+n}`}var te=e=>`${e.color} ${e.role}`;function Yr(e){let o=new Map;if(e.lastMove&&e.highlight.lastMove)for(let t of e.lastMove)R(o,t,"last-move");if(e.check&&e.highlight.check&&R(o,e.check,"check"),e.selected&&(R(o,e.selected,"selected"),e.movable.showDests)){let t=e.movable.dests?.get(e.selected);if(t)for(let a of t)R(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)R(o,a,"premove-dest"+(e.pieces.has(a)?" oc":""))}let r=e.premovable.current;if(r)for(let t of r)R(o,t,"current-premove");else e.predroppable.current&&R(o,e.predroppable.current.key,"current-premove");let n=e.exploding;if(n)for(let t of n.keys)R(o,t,"exploding"+n.stage);return e.highlight.custom&&e.highlight.custom.forEach((t,i)=>{R(o,i,t)}),o}function R(e,o,r){let n=e.get(o);n?e.set(o,`${n} ${r}`):e.set(o,r)}function Xe(e,o,r){let n=e.get(o);n?n.push(r):e.set(o,[r])}function or(e,o,r){let n=new Map,t=[];for(let c of e)n.set(c.hash,!1);let i=o.firstElementChild,a;for(;i;)a=i.getAttribute("cgHash"),n.has(a)?n.set(a,!0):t.push(i),i=i.nextElementSibling;for(let c of t)o.removeChild(c);for(let c of e)n.get(c.hash)||o.appendChild(r(c))}function rr(e,o){let n=e.drawable.autoShapes.filter(t=>t.piece).map(t=>({shape:t,hash:Qr(t),current:!1}));or(n,o,t=>_r(e,t,e.dom.bounds()))}function nr(e){let o=v(e),r=L(e.dom.bounds()),n=e.dom.elements.autoPieces?.firstChild;for(;n;)De(n,r(f(n.cgKey),o),n.cgScale),n=n.nextSibling}function _r(e,{shape:o,hash:r},n){let t=o.orig,i=o.piece?.role,a=o.piece?.color,c=o.piece?.scale,l=C("piece",`${i} ${a}`);return l.setAttribute("cgHash",r),l.cgKey=t,l.cgScale=c,De(l,L(n)(f(t),v(e)),c),l}var Qr=e=>[e.orig,e.piece?.role,e.piece?.color,e.piece?.scale].join(",");function Jn({el:e,config:o}){return en(e,o)}function en(e,o){let r=Oo();we(r,o||{});function n(){let t="dom"in r?r.dom.unbind:void 0,i=Io(e,r),a=eo(()=>i.board.getBoundingClientRect()),c=p=>{_o(s),i.autoPieces&&rr(s,i.autoPieces),!p&&i.svg&&Go(s,i.svg,i.customSvg)},l=()=>{Ye(s),Qo(s),i.autoPieces&&nr(s)},s=r;return s.dom={elements:i,bounds:a,redraw:on(c),redrawNow:c,unbind:t},s.drawable.prevSvgHash="",Ye(s),c(!1),Zo(s,l),t||(s.dom.unbind=Xo(s,l)),s.events.insert&&s.events.insert(i),s}return Bo(n(),n)}function on(e){let o=!1;return()=>{o||(o=!0,requestAnimationFrame(()=>{e(),o=!1}))}}export{en as Chessground,Jn as initModule};
|
package/dist/premove.js
CHANGED
|
@@ -37,13 +37,15 @@ const isDestControlledByEnemy = (ctx, pieceRolesExclude) => {
|
|
|
37
37
|
const isFriendlyOnDestAndAttacked = (ctx) => isDestOccupiedByFriendly(ctx) &&
|
|
38
38
|
(canBeCapturedBySomeEnemyEnPassant(util.pos2key(ctx.pos2), ctx.friendlies, ctx.enemies, ctx.lastMove) ||
|
|
39
39
|
isDestControlledByEnemy(ctx));
|
|
40
|
-
const canBeCapturedBySomeEnemyEnPassant = (
|
|
41
|
-
if (
|
|
40
|
+
const canBeCapturedBySomeEnemyEnPassant = (potentialSquareOfFriendlyPawn, friendlies, enemies, lastMove) => {
|
|
41
|
+
if (lastMove && potentialSquareOfFriendlyPawn !== lastMove[1])
|
|
42
42
|
return false;
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
[1
|
|
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 => enemies.get(util.pos2key([pos[0] + delta, pos[1]]))?.role === 'pawn'));
|
|
47
49
|
};
|
|
48
50
|
const isPathClearEnoughOfFriendliesForPremove = (ctx) => {
|
|
49
51
|
if (ctx.unrestrictedPremoves)
|
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;AAmBlC,MAAM,wBAAwB,GAAG,CAAC,GAAoB,EAAW,EAAE,CACjE,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;AAE7C,MAAM,qBAAqB,GAAG,CAAC,GAAoB,EAAW,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;AAEzG,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,OA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C,OAAO,CAAC,GAAG,CAAC,EACvB,QAAQ,GAAa,cAAc,CAAC,KAAK,CAAC,IAAI,CAAC,EAC/C,GAAG,GAAG;QACJ,IAAI,EAAE,GAAG;QACT,SAAS,EAAE,MAAM;QACjB,UAAU,EAAE,UAAU;QACtB,OAAO,EAAE,OAAO;QAChB,oBAAoB,EAAE,oBAAoB;QAC1C,KAAK,EAAE,KAAK;QACZ,SAAS,EAAE,SAAS;QACpB,mBAAmB,EAAE,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC;aACpC,MAAM,CACL,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,KAAK,OAAO,CAAC,CAAC,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,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,QAAQ,CAAC,EAAE,GAAG,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AAClF,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lichess-org/chessground",
|
|
3
|
-
"version": "9.4.
|
|
3
|
+
"version": "9.4.1",
|
|
4
4
|
"//": "version is managed by the build system",
|
|
5
5
|
"description": "lichess.org chess ui",
|
|
6
6
|
"type": "module",
|
|
@@ -36,7 +36,8 @@
|
|
|
36
36
|
"check-format": "prettier --check .",
|
|
37
37
|
"bundle": "esbuild src/chessground.ts --bundle --format=esm --outfile=dist/chessground.min.js --minify",
|
|
38
38
|
"dist": "$npm_execpath run compile && $npm_execpath run bundle",
|
|
39
|
-
"test": "vitest"
|
|
39
|
+
"test": "vitest run",
|
|
40
|
+
"test:watch": "vitest"
|
|
40
41
|
},
|
|
41
42
|
"files": [
|
|
42
43
|
"/dist/*.js",
|
package/src/premove.ts
CHANGED
|
@@ -78,19 +78,19 @@ const isFriendlyOnDestAndAttacked = (ctx: MobilityContext): boolean =>
|
|
|
78
78
|
isDestControlledByEnemy(ctx));
|
|
79
79
|
|
|
80
80
|
const canBeCapturedBySomeEnemyEnPassant = (
|
|
81
|
-
|
|
81
|
+
potentialSquareOfFriendlyPawn: cg.Key,
|
|
82
82
|
friendlies: cg.Pieces,
|
|
83
83
|
enemies: cg.Pieces,
|
|
84
84
|
lastMove?: cg.Key[],
|
|
85
85
|
): boolean => {
|
|
86
|
-
if (
|
|
87
|
-
const
|
|
88
|
-
|
|
89
|
-
piece = friendlies.get(lastMove[1])!;
|
|
86
|
+
if (lastMove && potentialSquareOfFriendlyPawn !== lastMove[1]) return false;
|
|
87
|
+
const pos = util.key2pos(potentialSquareOfFriendlyPawn);
|
|
88
|
+
const friendly = friendlies.get(potentialSquareOfFriendlyPawn);
|
|
90
89
|
return (
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
90
|
+
friendly?.role === 'pawn' &&
|
|
91
|
+
pos[1] === (friendly.color === 'white' ? 3 : 4) &&
|
|
92
|
+
(!lastMove || util.diff(util.key2pos(lastMove[0])[1], pos[1]) === 2) &&
|
|
93
|
+
[1, -1].some(delta => enemies.get(util.pos2key([pos[0] + delta, pos[1]]))?.role === 'pawn')
|
|
94
94
|
);
|
|
95
95
|
};
|
|
96
96
|
|