@lichess-org/chessground 9.9.0 → 9.10.2

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.
@@ -1 +1 @@
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&&lt(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};
1
+ var We=["white","black"];var $=["a","b","c","d","e","f","g","h"],I=["1","2","3","4","5","6","7","8"];var ze=[...I].reverse(),X=$.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),Ie=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 je=()=>{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,Ue=(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]},nt=ye(()=>!("ontouchstart"in window)&&["macintosh","firefox"].every(e=>navigator.userAgent.toLowerCase().includes(e))),ie=e=>e.button===2&&!(e.ctrlKey&&nt()),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,Ze=(e,o,t,n)=>we(e,o,t,n)||Pe(e,o,t,n),_e=(e,o,t,n)=>Math.max(R(e,t),R(o,n))===1;var Xe=(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))},Qe=(e,o,t,n)=>{let r=t-e,i=n-o;if(r&&i&&Math.abs(r)!==Math.abs(i))return[];let c=Math.sign(r),p=Math.sign(i),d=[],a=e+c,l=o+p;for(;a!==t||l!==n;)d.push([a,l]),a+=c,l+=p;return d.map(L).filter(s=>s!==void 0)};var rt=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):Xe(...e.orig.pos,...e.dest.pos,e.color==="white")),it=e=>ce(...e.orig.pos,...e.dest.pos),Ye=e=>Pe(...e.orig.pos,...e.dest.pos),Je=e=>we(...e.orig.pos,...e.dest.pos),at=e=>Ye(e)||Je(e),ct=e=>_e(...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])),st={pawn:rt,knight:it,bishop:Ye,rook:Je,queen:at,king:ct};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(([l,s])=>s.color===r)),c=new Map([...t].filter(([l,s])=>s.color===j(r))),p={key:o,pos:f(o)},d=l=>st[n.role](l)&&e.premovable.additionalPremoveRequirements(l),a={orig:p,role:n.role,allPieces:t,friendlies:i,enemies:c,color:r,rookFilesFriendlies:Array.from(t).filter(([l,s])=>l[1]===(r==="white"?"1":"8")&&s.color===r&&s.role==="rook").map(([l])=>f(l)[0]),lastMove:e.lastMove};return Ie.filter(l=>d({...a,dest:l})).map(l=>l.key)}function P(e,...o){e&&setTimeout(()=>e(...o),1)}function eo(e){e.orientation=j(e.orientation),e.animation.current=e.draggable.current=e.selected=void 0}function oo(e,o){for(let[t,n]of o)n?e.pieces.set(t,n):e.pieces.delete(t)}function to(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 lt(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 dt(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 pt(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 c=e.pieces.get(t);return!c||c.color!==n.color||c.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]]),c)):(e.pieces.set(G([2,i[1]]),n),e.pieces.set(G([3,i[1]]),c)),!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),pt(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 no(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=no(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(gt(e,o,t))return lt(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&&(ut(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&&ft(e,o,t)?dt(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)&&(ro(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 ro(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&&ro(e,o)&&(e.movable.free||!!e.movable.dests?.get(o)?.includes(t));function ut(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 gt=(e,o,t)=>o!==t&&Ke(e,o)&&(e.premovable.customDests?.get(o)??Me(e,o)).includes(t);function ft(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 io(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 ao(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=no(e,t,n);if(i){let c={premove:!0};i!==!0&&(c.captured=i),P(e.movable.events.after,t,n,c),r=!0}}return K(e),r}function co(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 so(e,o,t,n){let r=f(e),i=ve.filter(a=>Ue(r,a)||Ze(r[0],r[1],a[0],a[1])||ce(r[0],r[1],a[0],a[1])),p=i.map(a=>ae(G(a),t,n)).map(a=>F(o,a)),[,d]=p.reduce((a,l,s)=>a[0]<l?a:[l,s],[p[0],0]);return L(i[d])}var v=e=>e.orientation==="white";var Ae="rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR",mt={p:"pawn",r:"rook",n:"knight",b:"bishop",q:"queen",k:"king"},bt={pawn:"p",rook:"r",knight:"n",bishop:"b",queen:"q",king:"k"};function pe(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]),c=i&&o.get(i);c&&(c.promoted=!0);break}default:{let i=r.charCodeAt(0);if(i<57)n+=i-48;else{let c=r.toLowerCase(),p=L([n,t]);p&&o.set(p,{role:mt[c],color:r===c?"black":"white"}),++n}}}return o}function lo(e){return ze.map(o=>$.map(t=>{let n=e.get(t+o);if(n){let r=bt[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 ue(e,o){if(o.movable?.dests&&(e.movable.dests=void 0),o.drawable?.autoShapes&&(e.drawable.autoShapes=[]),He(e,o),o.fen&&(e.pieces=pe(o.fen),e.drawable.shapes=o.drawable?.shapes||[]),"check"in o&&to(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(c=>!(c==="a"+t&&r.includes("c"+t))&&!(c==="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?St(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}),vt=(e,o)=>o.sort((t,n)=>F(e.pos,t.pos)-F(e.pos,n.pos))[0];function yt(e,o){let t=new Map,n=[],r=new Map,i=[],c=[],p=new Map,d,a,l;for(let[s,g]of e)p.set(s,Te(s,g));for(let s of X)d=o.pieces.get(s),a=p.get(s),d?a?Q(d,a.piece)||(i.push(a),c.push(Te(s,d))):c.push(Te(s,d)):a&&i.push(a);for(let s of c)a=vt(s,i.filter(g=>Q(s.piece,g.piece))),a&&(l=[a.pos[0]-s.pos[0],a.pos[1]-s.pos[1]],t.set(s.key,l.concat(l)),n.push(a.key));for(let s of i)n.includes(s.key)||r.set(s.key,s.piece);return{anims:t,fadings:r}}function uo(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=wt(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())=>uo(e,i))}}function St(e,o){let t=new Map(o.pieces),n=e(o),r=yt(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||uo(o,performance.now())}else o.dom.redraw();return n}var wt=e=>e<.5?4*e*e*e:(e-1)*(2*e-2)*(2*e-2)+1;var Pt=["green","red","blue","yellow"];function go(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:Mt(o),snapToValidMove:e.drawable.defaultSnapToValidMove},fo(e))}function fo(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?so(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()),fo(e)}})}function mo(e,o){e.drawable.current&&(e.drawable.current.pos=T(o))}function bo(e){let o=e.drawable.current;o&&(o.mouseSq&&xt(e.drawable,o),qe(e))}function qe(e){e.drawable.current&&(e.drawable.current=void 0,e.dom.redraw())}function ho(e){e.drawable.shapes.length&&(e.drawable.shapes=[],e.dom.redraw(),vo(e.drawable))}var ge=(e,o)=>e.orig===o.orig&&e.dest===o.dest,Re=(e,o)=>e.brush===o.brush;function Mt(e){let o=(e.shiftKey||e.ctrlKey)&&ie(e),t=e.altKey||e.metaKey||e.getModifierState?.("AltGraph");return Pt[(o?1:0)+(t?2:0)]}function xt(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}),vo(e)}function vo(e){e.onChange&&e.onChange(e.shapes)}function yo(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),c=e.selected;if(!c&&e.drawable.enabled&&(e.drawable.eraseOnMovablePieceClick||!i||i.color!==e.turnColor)&&ho(e),o.cancelable!==!1&&(!o.touches||e.blockTouchScroll||i||c||kt(e,n)))o.preventDefault();else if(o.touches)return;let p=!!e.premovable.current,d=!!e.predroppable.current;e.stats.ctrlKey=o.ctrlKey,e.selected&&de(e,e.selected,r)?B(s=>J(s,r),e):J(e,r);let a=e.selected===r,l=xo(e,r);if(i&&l&&a&&io(e,r)){e.draggable.current={orig:r,piece:i,origPos:n,pos:n,started:e.draggable.autoDistance&&e.stats.dragged,element:l,previouslySelected:c,originTarget:o.target,keyHasChanged:!1},l.cgDragging=!0,l.classList.add("dragging");let s=e.dom.elements.ghost;s&&(s.className=`ghost ${i.color} ${i.role}`,M(s,W(t)(f(r),v(e))),Y(s,!0)),Be(e)}else p&&K(e),d&&D(e);e.dom.redraw()}function kt(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 c=ae(i,t,n);if(F(c,o)<=r)return!0}return!1}function So(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:()=>xo(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))z(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 wo(e,o){e.draggable.current&&(!o.touches||o.touches.length<2)&&(e.draggable.current.pos=T(o))}function Po(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),Mo(e),e.draggable.current=void 0,e.dom.redraw()}function z(e){let o=e.draggable.current;o&&(o.newPiece&&e.pieces.delete(o.orig),e.draggable.current=void 0,w(e),Mo(e),e.dom.redraw())}function Mo(e){let o=e.dom.elements;o.ghost&&Y(o.ghost,!1)}function xo(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(()=>{Co(e,2),setTimeout(()=>Co(e,void 0),120)},120)}function Co(e,o){e.exploding&&(o?e.exploding.stage=o:e.exploding=void 0,e.dom.redraw())}function Ko(e,o){function t(){eo(e),o()}return{set(n){n.orientation&&n.orientation!==e.orientation&&t(),Ne(e,n),(n.fen?B:O)(r=>ue(r,n),e)},state:e,getFen:()=>lo(e.pieces),toggleOrientation:t,setPieces(n){B(r=>oo(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(ao,e))return!0;e.dom.redraw()}return!1},playPredrop(n){if(e.predroppable.current){let r=co(e,n);return e.dom.redraw(),r}return!1},cancelPremove(){O(K,e)},cancelPredrop(){O(D,e)},cancelMove(){O(n=>{ee(n),z(n)},e)},stop(){O(n=>{De(n),z(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){So(e,n,r,i)},destroy(){De(e),e.dom.unbind&&e.dom.unbind(),e.dom.destroyed=!0}}}function Do(){return{pieces:pe(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:je()}}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,c=e.dom.bounds(),p=t.autoShapes.filter(s=>!s.piece);for(let s of t.shapes.concat(p).concat(r?[r]:[])){if(!s.dest)continue;let g=i.get(s.dest)??new Set,m=me(fe(f(s.orig),e.orientation),c),b=me(fe(f(s.dest),e.orientation),c);g.add(Go(Fo(m,b))),i.set(s.dest,g)}let d=[],a=r?t.shapes.findIndex(s=>ge(s,r)&&Re(s,r)):-1;for(let[s,g]of t.shapes.concat(p).entries()){let m=a!==-1&&a===s;d.push({shape:g,current:!1,pendingErase:m,hash:Eo(g,Oe(g.dest,i),!1,c,m,No(g.dest,i))})}r&&a===-1&&d.push({shape:r,current:!0,hash:Eo(r,Oe(r.dest,i),!0,c,!1,No(r.dest,i)),pendingErase:!1});let l=d.map(s=>s.hash).join(";");l!==e.drawable.prevSvgHash&&(e.drawable.prevSvgHash=l,Dt(t,d,o),Et(d,o,s=>Ht(e,s,t.brushes,i,c)))}function Dt(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),c=new Map;for(let a of i.filter(l=>l.shape.dest&&l.shape.brush)){let l=Oo(e.brushes[a.shape.brush],a.shape.modifiers),{key:s,color:g}=Vo(a.shape);s&&g&&c.set(s,{key:s,color:g,opacity:1,lineWidth:1}),c.set(l.key,l)}let p=new Set,d=r.firstElementChild;for(;d;)p.add(d.getAttribute("cgKey")),d=d.nextElementSibling;for(let[a,l]of c.entries())p.has(a)||r.appendChild(Rt(l))}}function Et(e,o,t){for(let[n,r]of[[o.shapes,o.custom],[o.shapesBelow,o.customBelow]]){let[i,c]=[n,r].map(a=>a.querySelector("g")),p=e.filter(a=>n===o.shapesBelow==!!a.shape.below),d=new Map;for(let a of p)d.set(a.hash,!1);for(let a of[i,c]){let l=[],s=a.firstElementChild,g;for(;s;)g=s.getAttribute("cgHash"),d.has(g)?d.set(g,!0):l.push(s),s=s.nextElementSibling;for(let m of l)a.removeChild(m)}for(let a of p.filter(l=>!d.get(l.hash)))for(let l of t(a))l.isCustom?c.appendChild(l.el):i.appendChild(l.el)}}function Eo({orig:e,dest:o,brush:t,piece:n,modifiers:r,customSvg:i,label:c,below:p},d,a,l,s,g){return[l.width,l.height,a,s&&"pendingErase",g,e,o,t,d&&"-",n&&At(n),r&&Nt(r),i&&`custom-${Ao(i.html)},${i.center?.[0]??"o"}`,c&&`label-${Ao(c.text)}`,p&&"below"].filter(m=>m).join(",")}var At=e=>[e.color,e.role,e.scale].filter(o=>o).join(","),Nt=e=>[e.lineWidth,e.hilite].filter(o=>o).join(",");function Ao(e){let o=0;for(let t=0;t<e.length;t++)o=(o<<5)-o+e.charCodeAt(t)>>>0;return o.toString()}function Ht(e,{shape:o,current:t,pendingErase:n,hash:r},i,c,p){let d=me(fe(f(o.orig),e.orientation),p),a=o.dest?me(fe(f(o.dest),e.orientation),p):d,l=o.brush&&Oo(i[o.brush],o.modifiers),s=c.get(o.dest),g=[];if(l){let m=S(y("g"),{cgHash:r});g.push({el:m}),d[0]!==a[0]||d[1]!==a[1]?m.appendChild(qt(o,l,d,a,t,Oe(o.dest,c),n)):m.appendChild(Tt(i[o.brush],d,t,p,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:Bt(m,r,d,a,s,b),isCustom:!0})}if(o.customSvg){let m=o.customSvg.center??"orig",[b,u]=m==="label"?Wo(d,a,s).map(C=>C-.5):m==="dest"?a:d,q=S(y("g"),{transform:`translate(${b},${u})`,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 Tt(e,o,t,n,r){let i=Ot(),c=(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:Lo(e,t,r),cx:o[0],cy:o[1],r:c-i[1]/2})}function qt(e,o,t,n,r,i,c){function p(l){let s=Lt(i&&!r),g=n[0]-t[0],m=n[1]-t[1],b=Math.atan2(m,g),u=Math.cos(b)*s,q=Math.sin(b)*s,C=Vo(e);return S(y("line"),{stroke:l?C.color:o.color,"stroke-width":Vt(o,r)*(l?1.14:1),"stroke-linecap":"round","marker-end":`url(#arrowhead-${l?C.key:o.key})`,opacity:e.modifiers?.hilite&&!c?1:Lo(o,r,c),x1:t[0],y1:t[1],x2:n[0]-u,y2:n[1]-q})}if(!e.modifiers?.hilite)return p(!1);let d=S(y("g"),{opacity:o.opacity}),a=S(y("g"),{filter:"url(#cg-filter-blur)"});return a.appendChild(Gt(t,n)),a.appendChild(p(!0)),d.appendChild(a),d.appendChild(p(!1)),d}function Rt(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 Bt(e,o,t,n,r,i){let p=.4*.75**e.text.length,d=Wo(t,n,r),a=i==="tr"?.4:0,l=S(y("g"),{transform:`translate(${d[0]+a},${d[1]-a})`,cgHash:o});l.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 s=S(y("text"),{"font-size":p,"font-family":"Noto Sans","text-anchor":"middle",fill:"white",y:.13*.75**e.text.length});return s.innerHTML=e.text,l.appendChild(s),l}var fe=(e,o)=>o==="white"?e:[7-e[0],7-e[1]],qo=(e,o)=>(e%o+o)%o,Ro=(e,o)=>qo(e+o,16),Bo=e=>[...e].some(o=>[-3,-2,-1,1,2,3].some(t=>e.has(Ro(o,t)))),Oe=(e,o)=>!!e&&o.has(e)&&Bo(o.get(e)),y=e=>document.createElementNS("http://www.w3.org/2000/svg",e),No=(e,o)=>e&&o.has(e)?o.get(e).size:0;function S(e,o){for(let t in o)Object.prototype.hasOwnProperty.call(o,t)&&e.setAttribute(t,o[t]);return e}var Oo=(e,o)=>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,Ot=()=>[3/64,4/64],Vt=(e,o)=>(e.lineWidth||10)*(o?.85:1)/64;function Vo(e){let o=e.modifiers?.hilite;return{key:o&&`hilite-${o.replace("#","")}`,color:o}}var Lo=(e,o,t)=>(e.opacity||1)*(t?.6:o?.9:1),Lt=e=>(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 Gt(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"})}var Go=e=>qo(Math.round(e*8/Math.PI),16),Fo=(e,o)=>Math.atan2(o[1]-e[1],o[0]-e[0])+Math.PI,Ft=(e,o)=>Math.sqrt([e[0]-o[0],e[1]-o[1]].reduce((t,n)=>t+n*n,0));function Wo(e,o,t){let n=Ft(e,o),r=Fo(e,o);if(t&&(n-=33/64,Bo(t))){n-=10/64;let i=Go(r);i&1&&[-1,1].some(c=>t.has(Ro(i,c)))&&(n-=.4)}return[e[0]-Math.cos(r)*n,e[1]-Math.sin(r)*n].map(i=>i+.5)}function zo(e,o){e.innerHTML="",e.classList.add("cg-wrap");for(let l of We)e.classList.toggle("orientation-"+l,o.orientation===l);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,c,p,d;if(o.drawable.visible&&([r,i]=["cg-shapes-below","cg-shapes"].map(l=>$o(l,!0)),[c,p]=["cg-custom-below","cg-custom-svgs"].map(l=>$o(l,!1)),d=x("cg-auto-pieces"),t.appendChild(r),t.appendChild(c),t.appendChild(i),t.appendChild(p),t.appendChild(d)),o.coordinates){let l=o.orientation==="black"?" black":"",s=o.ranksPosition==="left"?" left":"";if(o.coordinatesOnSquares){let g=o.orientation==="white"?m=>m+1:m=>8-m;$.forEach((m,b)=>t.appendChild(Ve(I.map(u=>m+u),"squares rank"+g(b)+l+s,b%2===0?"black":"white")))}else t.appendChild(Ve(I,"ranks"+l+s,o.ranksPosition==="right"?"white":"black")),t.appendChild(Ve($,"files"+l,"black"))}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:p,customBelow:c,autoPieces:d}}function $o(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 Ve(e,o,t){let n=x("coords",o),r;return e.forEach((i,c)=>{let p=c%2===(t==="white"?0:1);r=x("coord",`coord-${p?"light":"dark"}`),r.textContent=i,n.appendChild(r)}),n}function Io(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 Uo(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=$t(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=jo(e,wo,mo),r=jo(e,Po,bo);for(let c of["touchmove","mousemove"])t.push(oe(document,c,n));for(let c of["touchend","mouseup"])t.push(oe(document,c,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 $t=e=>o=>{e.draggable.current?z(e):e.drawable.current?qe(e):o.shiftKey||ie(o)?e.drawable.enabled&&go(e,o):e.viewOnly||(e.dropmode.active?Io(e,o):yo(e,o))},jo=(e,o,t)=>n=>{e.drawable.current?e.drawable.enabled&&t(e,n):e.viewOnly||o(e,n)};function Xo(e){let o=v(e),t=W(e.dom.bounds()),n=e.dom.elements.board,r=e.pieces,i=e.animation.current,c=i?i.plan.anims:new Map,p=i?i.plan.fadings:new Map,d=e.draggable.current,a=jt(e),l=new Set,s=new Set,g=new Map,m=new Map,b,u,q,C,k,Z,be,A,he,ne;for(u=n.firstChild;u;){if(b=u.cgKey,Yo(u))if(q=r.get(b),k=c.get(b),Z=p.get(b),C=u.cgPiece,u.cgDragging&&(!d||d.orig!==b)&&(u.classList.remove("dragging"),M(u,t(f(b),o)),u.cgDragging=!1),!Z&&u.cgFading&&(u.cgFading=!1,u.classList.remove("fading")),q){if(k&&u.cgAnimating&&C===te(q)){let h=f(b);h[0]+=k[2],h[1]+=k[3],u.classList.add("anim"),M(u,t(h,o))}else u.cgAnimating&&(u.cgAnimating=!1,u.classList.remove("anim"),M(u,t(f(b),o)),e.addPieceZIndex&&(u.style.zIndex=Le(f(b),o)));C===te(q)&&(!Z||!u.cgFading)?l.add(b):Z&&C===te(Z)?(u.classList.add("fading"),u.cgFading=!0):Ge(g,C,u)}else Ge(g,C,u);else if(Jo(u)){let h=u.className;a.get(b)===h?s.add(b):Ge(m,h,u)}u=u.nextSibling}for(let[h,_]of a)if(!s.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=c.get(h),!l.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=Le(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=Le(re,o)),n.appendChild(H)}for(let h of g.values())_o(e,h);for(let h of m.values())_o(e,h)}function Qo(e){let o=v(e),t=W(e.dom.bounds()),n=e.dom.elements.board.firstChild;for(;n;)(Yo(n)&&!n.cgAnimating||Jo(n))&&M(n,t(f(n.cgKey),o)),n=n.nextSibling}function Fe(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 Yo=e=>e.tagName==="PIECE",Jo=e=>e.tagName==="SQUARE";function _o(e,o){for(let t of o)e.dom.elements.board.removeChild(t)}function Le(e,o){let n=e[1];return`${o?10-n:3+n}`}var te=e=>`${e.color} ${e.role}`,It=(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]&&Qe(...f(e.lastMove[0]),...f(e.lastMove[1])).some(t=>e.pieces.has(t))?(o>e.lastMove[0]?"g":"c")+o[1]:o;function jt(e){let o=new Map;if(e.lastMove&&e.highlight.lastMove)for(let[r,i]of e.lastMove.entries())V(o,r===1?It(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 Ge(e,o,t){let n=e.get(o);n?n.push(t):e.set(o,[t])}function et(e,o,t){let n=new Map,r=[];for(let p of e)n.set(p.hash,!1);let i=o.firstElementChild,c;for(;i;)c=i.getAttribute("cgHash"),n.has(c)?n.set(c,!0):r.push(i),i=i.nextElementSibling;for(let p of r)o.removeChild(p);for(let p of e)n.get(p.hash)||o.appendChild(t(p))}function ot(e,o){let n=e.drawable.autoShapes.filter(r=>r.piece).map(r=>({shape:r,hash:Zt(r),current:!1,pendingErase:!1}));et(n,o,r=>Ut(e,r,e.dom.bounds()))}function tt(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 Ut(e,{shape:o,hash:t},n){let r=o.orig,i=o.piece?.role,c=o.piece?.color,p=o.piece?.scale,d=x("piece",`${i} ${c}`);return d.setAttribute("cgHash",t),d.cgKey=r,d.cgScale=p,Se(d,W(n)(f(r),v(e)),p),d}var Zt=e=>[e.orig,e.piece?.role,e.piece?.color,e.piece?.scale].join(",");function nr({el:e,config:o}){return Xt(e,o)}function Xt(e,o){let t=Do();ue(t,o||{});function n(){let r="dom"in t?t.dom.unbind:void 0,i=zo(e,t),c=ye(()=>i.board.getBoundingClientRect()),p=l=>{Xo(a),i.autoPieces&&ot(a,i.autoPieces),!l&&i.shapes&&To(a,i)},d=()=>{Fe(a),Qo(a),i.autoPieces&&tt(a)},a=t;return a.dom={elements:i,bounds:c,redraw:Qt(p),redrawNow:p,unbind:r},a.drawable.prevSvgHash="",Fe(a),p(!1),Uo(a,d),r||(a.dom.unbind=Zo(a,d)),a.events.insert&&a.events.insert(i),a}return Ko(n(),n)}function Qt(e){let o=!1;return()=>{o||(o=!0,requestAnimationFrame(()=>{e(),o=!1}))}}export{Xt as Chessground,nr as initModule};
package/dist/config.d.ts CHANGED
@@ -10,6 +10,7 @@ export interface Config {
10
10
  selected?: cg.Key;
11
11
  coordinates?: boolean;
12
12
  coordinatesOnSquares?: boolean;
13
+ ranksPosition?: cg.RanksPosition;
13
14
  autoCastle?: boolean;
14
15
  viewOnly?: boolean;
15
16
  disableContextMenu?: boolean;
@@ -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;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,KAAK;QAAE,KAAK,CAAC,OAAO,CAAC,KAAK,GAAG,SAAS,CAAC;IAC3D,IAAI,MAAM,CAAC,QAAQ,EAAE,UAAU;QAAE,KAAK,CAAC,QAAQ,CAAC,UAAU,GAAG,EAAE,CAAC;IAEhE,SAAS,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IAEzB,4CAA4C;IAC5C,IAAI,MAAM,CAAC,GAAG,EAAE,CAAC;QACf,KAAK,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACnC,KAAK,CAAC,QAAQ,CAAC,MAAM,GAAG,MAAM,CAAC,QAAQ,EAAE,MAAM,IAAI,EAAE,CAAC;IACxD,CAAC;IAED,6DAA6D;IAC7D,IAAI,OAAO,IAAI,MAAM;QAAE,QAAQ,CAAC,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,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC;YAC/C,aAAa,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YACxB,aAAa,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YAE1B,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;;YAC/B,IAAI,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;IAC/B,CAAC;AACH,CAAC;AAED,SAAS,aAAa,CAAC,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/svg.d.ts CHANGED
@@ -3,7 +3,7 @@ import * as cg from './types.js';
3
3
  export { createElement, setAttributes };
4
4
  export declare function createDefs(): Element;
5
5
  export declare function renderSvg(state: State, els: cg.Elements): void;
6
- declare function createElement(tagName: string): SVGElement;
6
+ declare const createElement: (tagName: string) => SVGElement;
7
7
  declare function setAttributes(el: SVGElement, attrs: {
8
8
  [key: string]: any;
9
9
  }): SVGElement;
package/dist/svg.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { key2pos } from './util.js';
2
2
  import { sameEndpoints, sameColor, } from './draw.js';
3
+ const angleSlotVals = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15];
3
4
  export { createElement, setAttributes };
4
5
  export function createDefs() {
5
6
  const defs = createElement('defs');
@@ -14,7 +15,7 @@ export function renderSvg(state, els) {
14
15
  if (!s.dest)
15
16
  continue;
16
17
  const sources = dests.get(s.dest) ?? new Set(), from = pos2user(orient(key2pos(s.orig), state.orientation), bounds), to = pos2user(orient(key2pos(s.dest), state.orientation), bounds);
17
- sources.add(moveAngle(from, to));
18
+ sources.add(angleToSlot(moveAngle(from, to)));
18
19
  dests.set(s.dest, sources);
19
20
  }
20
21
  const shapes = [];
@@ -25,14 +26,14 @@ export function renderSvg(state, els) {
25
26
  shape: s,
26
27
  current: false,
27
28
  pendingErase: isPendingErase,
28
- hash: shapeHash(s, isShort(s.dest, dests), false, bounds, isPendingErase),
29
+ hash: shapeHash(s, isShort(s.dest, dests), false, bounds, isPendingErase, angleCount(s.dest, dests)),
29
30
  });
30
31
  }
31
32
  if (cur && pendingEraseIdx === -1)
32
33
  shapes.push({
33
34
  shape: cur,
34
35
  current: true,
35
- hash: shapeHash(cur, isShort(cur.dest, dests), true, bounds, false),
36
+ hash: shapeHash(cur, isShort(cur.dest, dests), true, bounds, false, angleCount(cur.dest, dests)),
36
37
  pendingErase: false,
37
38
  });
38
39
  const fullHash = shapes.map(sc => sc.hash).join(';');
@@ -102,13 +103,14 @@ function syncShapes(shapes, els, renderShape) {
102
103
  }
103
104
  }
104
105
  }
105
- function shapeHash({ orig, dest, brush, piece, modifiers, customSvg, label, below }, shorten, current, bounds, pendingErase) {
106
+ function shapeHash({ orig, dest, brush, piece, modifiers, customSvg, label, below }, shorten, current, bounds, pendingErase, angleCountOfDest) {
106
107
  // a shape and an overlay svg share a lifetime and have the same cgHash attribute
107
108
  return [
108
109
  bounds.width,
109
110
  bounds.height,
110
111
  current,
111
112
  pendingErase && 'pendingErase',
113
+ angleCountOfDest,
112
114
  orig,
113
115
  dest,
114
116
  brush,
@@ -122,12 +124,8 @@ function shapeHash({ orig, dest, brush, piece, modifiers, customSvg, label, belo
122
124
  .filter(x => x)
123
125
  .join(',');
124
126
  }
125
- function pieceHash(piece) {
126
- return [piece.color, piece.role, piece.scale].filter(x => x).join(',');
127
- }
128
- function modifiersHash(m) {
129
- return [m.lineWidth, m.hilite].filter(x => x).join(',');
130
- }
127
+ const pieceHash = (piece) => [piece.color, piece.role, piece.scale].filter(x => x).join(',');
128
+ const modifiersHash = (m) => [m.lineWidth, m.hilite].filter(x => x).join(',');
131
129
  function textHash(s) {
132
130
  // Rolling hash with base 31 (cf. https://stackoverflow.com/questions/7616461/generate-a-hash-from-string-in-javascript)
133
131
  let h = 0;
@@ -240,15 +238,13 @@ function renderLabel(label, hash, from, to, slots, corner) {
240
238
  g.appendChild(labelEl);
241
239
  return g;
242
240
  }
243
- function orient(pos, color) {
244
- return color === 'white' ? pos : [7 - pos[0], 7 - pos[1]];
245
- }
246
- function isShort(dest, dests) {
247
- return true === (dest && dests.has(dest) && dests.get(dest).size > 1);
248
- }
249
- function createElement(tagName) {
250
- return document.createElementNS('http://www.w3.org/2000/svg', tagName);
251
- }
241
+ const orient = (pos, color) => (color === 'white' ? pos : [7 - pos[0], 7 - pos[1]]);
242
+ const mod = (n, m) => ((n % m) + m) % m;
243
+ const rotateAngleSlot = (slot, steps) => mod(slot + steps, 16);
244
+ const anyTwoCloserThan90Degrees = (slots) => [...slots].some(slot => [-3, -2, -1, 1, 2, 3].some(i => slots.has(rotateAngleSlot(slot, i))));
245
+ const isShort = (dest, dests) => !!dest && dests.has(dest) && anyTwoCloserThan90Degrees(dests.get(dest));
246
+ const createElement = (tagName) => document.createElementNS('http://www.w3.org/2000/svg', tagName);
247
+ const angleCount = (dest, dests) => dest && dests.has(dest) ? dests.get(dest).size : 0;
252
248
  function setAttributes(el, attrs) {
253
249
  for (const key in attrs) {
254
250
  if (Object.prototype.hasOwnProperty.call(attrs, key))
@@ -256,32 +252,22 @@ function setAttributes(el, attrs) {
256
252
  }
257
253
  return el;
258
254
  }
259
- function makeCustomBrush(base, modifiers) {
260
- return !modifiers
261
- ? base
262
- : {
263
- color: base.color,
264
- opacity: Math.round(base.opacity * 10) / 10,
265
- lineWidth: Math.round(modifiers.lineWidth || base.lineWidth),
266
- key: [base.key, modifiers.lineWidth].filter(x => x).join(''),
267
- };
268
- }
269
- function circleWidth() {
270
- return [3 / 64, 4 / 64];
271
- }
272
- function lineWidth(brush, current) {
273
- return ((brush.lineWidth || 10) * (current ? 0.85 : 1)) / 64;
274
- }
255
+ const makeCustomBrush = (base, modifiers) => !modifiers
256
+ ? base
257
+ : {
258
+ color: base.color,
259
+ opacity: Math.round(base.opacity * 10) / 10,
260
+ lineWidth: Math.round(modifiers.lineWidth || base.lineWidth),
261
+ key: [base.key, modifiers.lineWidth].filter(x => x).join(''),
262
+ };
263
+ const circleWidth = () => [3 / 64, 4 / 64];
264
+ const lineWidth = (brush, current) => ((brush.lineWidth || 10) * (current ? 0.85 : 1)) / 64;
275
265
  function hiliteOf(shape) {
276
266
  const hilite = shape.modifiers?.hilite;
277
267
  return { key: hilite && `hilite-${hilite.replace('#', '')}`, color: hilite };
278
268
  }
279
- function opacity(brush, current, pendingErase) {
280
- return (brush.opacity || 1) * (pendingErase ? 0.6 : current ? 0.9 : 1);
281
- }
282
- function arrowMargin(shorten) {
283
- return (shorten ? 20 : 10) / 64;
284
- }
269
+ const opacity = (brush, current, pendingErase) => (brush.opacity || 1) * (pendingErase ? 0.6 : current ? 0.9 : 1);
270
+ const arrowMargin = (shorten) => (shorten ? 20 : 10) / 64;
285
271
  function pos2user(pos, bounds) {
286
272
  const xScale = Math.min(1, bounds.width / bounds.height);
287
273
  const yScale = Math.min(1, bounds.height / bounds.width);
@@ -303,13 +289,9 @@ function filterBox(from, to) {
303
289
  stroke: 'none',
304
290
  });
305
291
  }
306
- function moveAngle(from, to, asSlot = true) {
307
- const angle = Math.atan2(to[1] - from[1], to[0] - from[0]) + Math.PI;
308
- return asSlot ? (Math.round((angle * 8) / Math.PI) + 16) % 16 : angle;
309
- }
310
- function dist(from, to) {
311
- return Math.sqrt([from[0] - to[0], from[1] - to[1]].reduce((acc, x) => acc + x * x, 0));
312
- }
292
+ const angleToSlot = (angle) => mod(Math.round((angle * 8) / Math.PI), 16);
293
+ const moveAngle = (from, to) => Math.atan2(to[1] - from[1], to[0] - from[0]) + Math.PI;
294
+ const dist = (from, to) => Math.sqrt([from[0] - to[0], from[1] - to[1]].reduce((acc, x) => acc + x * x, 0));
313
295
  /*
314
296
  try to place label at the junction of the destination shaft and arrowhead. if there's more than
315
297
  1 arrow pointing to a square, the arrow shortens by 10 / 64 units so the label must move as well.
@@ -321,17 +303,15 @@ function dist(from, to) {
321
303
  function labelCoords(from, to, slots) {
322
304
  let mag = dist(from, to);
323
305
  //if (mag === 0) return [from[0], from[1]];
324
- const angle = moveAngle(from, to, false);
306
+ const angle = moveAngle(from, to);
325
307
  if (slots) {
326
308
  mag -= 33 / 64; // reduce by arrowhead length
327
- if (slots.size > 1) {
309
+ if (anyTwoCloserThan90Degrees(slots)) {
328
310
  mag -= 10 / 64; // reduce by shortening factor
329
- const slot = moveAngle(from, to);
330
- if (slots.has((slot + 1) % 16) || slots.has((slot + 15) % 16)) {
331
- if (slot & 1)
332
- mag -= 0.4;
333
- // and by label size for the knight if another arrow is within pi / 8.
334
- }
311
+ const slot = angleToSlot(angle);
312
+ // reduce by label size for the knight if another arrow is within pi / 8:
313
+ if (slot & 1 && [-1, 1].some(s => slots.has(rotateAngleSlot(slot, s))))
314
+ mag -= 0.4;
335
315
  }
336
316
  }
337
317
  return [from[0] - Math.cos(angle) * mag, from[1] - Math.sin(angle) * mag].map(c => c + 0.5);
package/dist/svg.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"svg.js","sourceRoot":"","sources":["../src/svg.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAOL,aAAa,EACb,SAAS,GACV,MAAM,WAAW,CAAC;AA0BnB,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,CAAC;AAExC,MAAM,UAAU,UAAU;IACxB,MAAM,IAAI,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC;IACnC,MAAM,MAAM,GAAG,aAAa,CAAC,aAAa,CAAC,QAAQ,CAAC,EAAE,EAAE,EAAE,EAAE,gBAAgB,E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AC;IACH,CAAC;IACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,CAC3E,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,GAAG,CACI,CAAC;AACrB,CAAC"}
package/dist/wrap.js CHANGED
@@ -47,11 +47,11 @@ export function renderWrap(element, s) {
47
47
  const ranksPositionClass = s.ranksPosition === 'left' ? ' left' : '';
48
48
  if (s.coordinatesOnSquares) {
49
49
  const rankN = s.orientation === 'white' ? i => i + 1 : i => 8 - i;
50
- files.forEach((f, i) => container.appendChild(renderCoords(ranks.map(r => f + r), 'squares rank' + rankN(i) + orientClass + ranksPositionClass)));
50
+ files.forEach((f, i) => container.appendChild(renderCoords(ranks.map(r => f + r), 'squares rank' + rankN(i) + orientClass + ranksPositionClass, i % 2 === 0 ? 'black' : 'white')));
51
51
  }
52
52
  else {
53
- container.appendChild(renderCoords(ranks, 'ranks' + orientClass + ranksPositionClass));
54
- container.appendChild(renderCoords(files, 'files' + orientClass));
53
+ container.appendChild(renderCoords(ranks, 'ranks' + orientClass + ranksPositionClass, s.ranksPosition === 'right' ? 'white' : 'black'));
54
+ container.appendChild(renderCoords(files, 'files' + orientClass, 'black'));
55
55
  }
56
56
  }
57
57
  let ghost;
@@ -73,14 +73,15 @@ function svgContainer(cls, isShapes) {
73
73
  svg.appendChild(createSVG('g'));
74
74
  return svg;
75
75
  }
76
- function renderCoords(elems, className) {
76
+ function renderCoords(elems, className, firstColor) {
77
77
  const el = createEl('coords', className);
78
78
  let f;
79
- for (const elem of elems) {
80
- f = createEl('coord');
79
+ elems.forEach((elem, i) => {
80
+ const light = i % 2 === (firstColor === 'white' ? 0 : 1);
81
+ f = createEl('coord', `coord-${light ? 'light' : 'dark'}`);
81
82
  f.textContent = elem;
82
83
  el.appendChild(f);
83
- }
84
+ });
84
85
  return el;
85
86
  }
86
87
  //# sourceMappingURL=wrap.js.map
package/dist/wrap.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"wrap.js","sourceRoot":"","sources":["../src/wrap.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAY,MAAM,YAAY,CAAC;AAC5D,OAAO,EAAE,aAAa,IAAI,SAAS,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAEjF,MAAM,UAAU,UAAU,CAAC,OAAoB,EAAE,CAAgB;IAC/D,2CAA2C;IAC3C,iBAAiB;IACjB,eAAe;IACf,oBAAoB;IACpB,aAAa;IACb,UAAU;IACV,yBAAyB;IACzB,UAAU;IACV,qBAAqB;IACrB,mBAAmB;IACnB,mBAAmB;IACnB,kBAAkB;IAElB,OAAO,CAAC,SAAS,GAAG,EAAE,CAAC;IAEvB,kCAAkC;IAClC,4DAA4D;IAC5D,oEAAoE;IACpE,mEAAmE;IACnE,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IAEjC,KAAK,MAAM,CAAC,IAAI,MAAM;QAAE,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,cAAc,GAAG,CAAC,EAAE,CAAC,CAAC,WAAW,KAAK,CAAC,CAAC,CAAC;IAC1F,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,aAAa,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;IAErD,MAAM,SAAS,GAAG,QAAQ,CAAC,cAAc,CAAC,CAAC;IAC3C,OAAO,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;IAE/B,MAAM,KAAK,GAAG,QAAQ,CAAC,UAAU,CAAC,CAAC;IACnC,SAAS,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;IAE7B,I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CAAC,GAAG,QAAQ,CAAC,OAAO,EAAE,SAAS,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;QAC3D,CAAC,CAAC,WAAW,GAAG,IAAI,CAAC;QACrB,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;IACpB,CAAC,CAAC,CAAC;IACH,OAAO,EAAE,CAAC;AACZ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lichess-org/chessground",
3
- "version": "9.9.0",
3
+ "version": "9.10.2",
4
4
  "//": "version is managed by the build system",
5
5
  "description": "lichess.org chess ui",
6
6
  "type": "module",
package/src/config.ts CHANGED
@@ -13,6 +13,7 @@ export interface Config {
13
13
  selected?: cg.Key; // square currently selected "a1"
14
14
  coordinates?: boolean; // include coords attributes
15
15
  coordinatesOnSquares?: boolean; // include coords attributes on every square
16
+ ranksPosition?: cg.RanksPosition; // render rank coords on the right (default) or the left
16
17
  autoCastle?: boolean; // immediately complete the castle by moving the rook after king move
17
18
  viewOnly?: boolean; // don't bind events: the user will never be able to move pieces around
18
19
  disableContextMenu?: boolean; // because who needs a context menu on a chessboard
package/src/svg.ts CHANGED
@@ -32,7 +32,9 @@ import * as cg from './types.js';
32
32
 
33
33
  type CustomBrushes = Map<string, DrawBrush>; // by hash
34
34
  type Svg = { el: SVGElement; isCustom?: boolean };
35
- type AngleSlots = Set<number>; // arrow angle slots for label positioning
35
+ const angleSlotVals = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15] as const;
36
+ type AngleSlot = (typeof angleSlotVals)[number];
37
+ type AngleSlots = Set<AngleSlot>; // arrow angle slots for label positioning
36
38
  type ArrowDests = Map<cg.Key | undefined, AngleSlots>; // angle slots per dest
37
39
 
38
40
  export { createElement, setAttributes };
@@ -58,7 +60,7 @@ export function renderSvg(state: State, els: cg.Elements): void {
58
60
  const sources = dests.get(s.dest) ?? new Set(),
59
61
  from = pos2user(orient(key2pos(s.orig), state.orientation), bounds),
60
62
  to = pos2user(orient(key2pos(s.dest), state.orientation), bounds);
61
- sources.add(moveAngle(from, to));
63
+ sources.add(angleToSlot(moveAngle(from, to)));
62
64
  dests.set(s.dest, sources);
63
65
  }
64
66
  const shapes: SyncableShape[] = [];
@@ -71,14 +73,14 @@ export function renderSvg(state: State, els: cg.Elements): void {
71
73
  shape: s,
72
74
  current: false,
73
75
  pendingErase: isPendingErase,
74
- hash: shapeHash(s, isShort(s.dest, dests), false, bounds, isPendingErase),
76
+ hash: shapeHash(s, isShort(s.dest, dests), false, bounds, isPendingErase, angleCount(s.dest, dests)),
75
77
  });
76
78
  }
77
79
  if (cur && pendingEraseIdx === -1)
78
80
  shapes.push({
79
81
  shape: cur,
80
82
  current: true,
81
- hash: shapeHash(cur, isShort(cur.dest, dests), true, bounds, false),
83
+ hash: shapeHash(cur, isShort(cur.dest, dests), true, bounds, false, angleCount(cur.dest, dests)),
82
84
  pendingErase: false,
83
85
  });
84
86
 
@@ -156,6 +158,7 @@ function shapeHash(
156
158
  current: boolean,
157
159
  bounds: DOMRectReadOnly,
158
160
  pendingErase: boolean,
161
+ angleCountOfDest: number,
159
162
  ): Hash {
160
163
  // a shape and an overlay svg share a lifetime and have the same cgHash attribute
161
164
  return [
@@ -163,6 +166,7 @@ function shapeHash(
163
166
  bounds.height,
164
167
  current,
165
168
  pendingErase && 'pendingErase',
169
+ angleCountOfDest,
166
170
  orig,
167
171
  dest,
168
172
  brush,
@@ -177,13 +181,10 @@ function shapeHash(
177
181
  .join(',');
178
182
  }
179
183
 
180
- function pieceHash(piece: DrawShapePiece): Hash {
181
- return [piece.color, piece.role, piece.scale].filter(x => x).join(',');
182
- }
184
+ const pieceHash = (piece: DrawShapePiece): Hash =>
185
+ [piece.color, piece.role, piece.scale].filter(x => x).join(',');
183
186
 
184
- function modifiersHash(m: DrawModifiers): Hash {
185
- return [m.lineWidth, m.hilite].filter(x => x).join(',');
186
- }
187
+ const modifiersHash = (m: DrawModifiers): Hash => [m.lineWidth, m.hilite].filter(x => x).join(',');
187
188
 
188
189
  function textHash(s: string): Hash {
189
190
  // Rolling hash with base 31 (cf. https://stackoverflow.com/questions/7616461/generate-a-hash-from-string-in-javascript)
@@ -350,17 +351,23 @@ function renderLabel(
350
351
  return g;
351
352
  }
352
353
 
353
- function orient(pos: cg.Pos, color: cg.Color): cg.Pos {
354
- return color === 'white' ? pos : [7 - pos[0], 7 - pos[1]];
355
- }
354
+ const orient = (pos: cg.Pos, color: cg.Color): cg.Pos => (color === 'white' ? pos : [7 - pos[0], 7 - pos[1]]);
356
355
 
357
- function isShort(dest: cg.Key | undefined, dests: ArrowDests) {
358
- return true === (dest && dests.has(dest) && dests.get(dest)!.size > 1);
359
- }
356
+ const mod = (n: number, m: number): number => ((n % m) + m) % m;
360
357
 
361
- function createElement(tagName: string): SVGElement {
362
- return document.createElementNS('http://www.w3.org/2000/svg', tagName);
363
- }
358
+ const rotateAngleSlot = (slot: AngleSlot, steps: number): AngleSlot => mod(slot + steps, 16) as AngleSlot;
359
+
360
+ const anyTwoCloserThan90Degrees = (slots: AngleSlots): boolean =>
361
+ [...slots].some(slot => [-3, -2, -1, 1, 2, 3].some(i => slots.has(rotateAngleSlot(slot, i))));
362
+
363
+ const isShort = (dest: cg.Key | undefined, dests: ArrowDests): boolean =>
364
+ !!dest && dests.has(dest) && anyTwoCloserThan90Degrees(dests.get(dest)!);
365
+
366
+ const createElement = (tagName: string): SVGElement =>
367
+ document.createElementNS('http://www.w3.org/2000/svg', tagName);
368
+
369
+ const angleCount = (dest: cg.Key | undefined, dests: ArrowDests): number =>
370
+ dest && dests.has(dest) ? dests.get(dest)!.size : 0;
364
371
 
365
372
  function setAttributes(el: SVGElement, attrs: { [key: string]: any }): SVGElement {
366
373
  for (const key in attrs) {
@@ -369,8 +376,8 @@ function setAttributes(el: SVGElement, attrs: { [key: string]: any }): SVGElemen
369
376
  return el;
370
377
  }
371
378
 
372
- function makeCustomBrush(base: DrawBrush, modifiers: DrawModifiers | undefined): DrawBrush {
373
- return !modifiers
379
+ const makeCustomBrush = (base: DrawBrush, modifiers: DrawModifiers | undefined): DrawBrush =>
380
+ !modifiers
374
381
  ? base
375
382
  : {
376
383
  color: base.color,
@@ -378,28 +385,21 @@ function makeCustomBrush(base: DrawBrush, modifiers: DrawModifiers | undefined):
378
385
  lineWidth: Math.round(modifiers.lineWidth || base.lineWidth),
379
386
  key: [base.key, modifiers.lineWidth].filter(x => x).join(''),
380
387
  };
381
- }
382
388
 
383
- function circleWidth(): [number, number] {
384
- return [3 / 64, 4 / 64];
385
- }
389
+ const circleWidth = (): [number, number] => [3 / 64, 4 / 64];
386
390
 
387
- function lineWidth(brush: DrawBrush, current: boolean): number {
388
- return ((brush.lineWidth || 10) * (current ? 0.85 : 1)) / 64;
389
- }
391
+ const lineWidth = (brush: DrawBrush, current: boolean): number =>
392
+ ((brush.lineWidth || 10) * (current ? 0.85 : 1)) / 64;
390
393
 
391
394
  function hiliteOf(shape: DrawShape): { key?: string; color?: string } {
392
395
  const hilite = shape.modifiers?.hilite;
393
396
  return { key: hilite && `hilite-${hilite.replace('#', '')}`, color: hilite };
394
397
  }
395
398
 
396
- function opacity(brush: DrawBrush, current: boolean, pendingErase: boolean): number {
397
- return (brush.opacity || 1) * (pendingErase ? 0.6 : current ? 0.9 : 1);
398
- }
399
+ const opacity = (brush: DrawBrush, current: boolean, pendingErase: boolean): number =>
400
+ (brush.opacity || 1) * (pendingErase ? 0.6 : current ? 0.9 : 1);
399
401
 
400
- function arrowMargin(shorten: boolean): number {
401
- return (shorten ? 20 : 10) / 64;
402
- }
402
+ const arrowMargin = (shorten: boolean): number => (shorten ? 20 : 10) / 64;
403
403
 
404
404
  function pos2user(pos: cg.Pos, bounds: DOMRectReadOnly): cg.NumberPair {
405
405
  const xScale = Math.min(1, bounds.width / bounds.height);
@@ -424,14 +424,13 @@ function filterBox(from: cg.NumberPair, to: cg.NumberPair): SVGElement {
424
424
  });
425
425
  }
426
426
 
427
- function moveAngle(from: cg.NumberPair, to: cg.NumberPair, asSlot = true) {
428
- const angle = Math.atan2(to[1] - from[1], to[0] - from[0]) + Math.PI;
429
- return asSlot ? (Math.round((angle * 8) / Math.PI) + 16) % 16 : angle;
430
- }
427
+ const angleToSlot = (angle: number): AngleSlot => mod(Math.round((angle * 8) / Math.PI), 16) as AngleSlot;
431
428
 
432
- function dist(from: cg.NumberPair, to: cg.NumberPair): number {
433
- return Math.sqrt([from[0] - to[0], from[1] - to[1]].reduce((acc, x) => acc + x * x, 0));
434
- }
429
+ const moveAngle = (from: cg.NumberPair, to: cg.NumberPair): number =>
430
+ Math.atan2(to[1] - from[1], to[0] - from[0]) + Math.PI;
431
+
432
+ const dist = (from: cg.NumberPair, to: cg.NumberPair): number =>
433
+ Math.sqrt([from[0] - to[0], from[1] - to[1]].reduce((acc, x) => acc + x * x, 0));
435
434
 
436
435
  /*
437
436
  try to place label at the junction of the destination shaft and arrowhead. if there's more than
@@ -445,16 +444,14 @@ function dist(from: cg.NumberPair, to: cg.NumberPair): number {
445
444
  function labelCoords(from: cg.NumberPair, to: cg.NumberPair, slots?: AngleSlots): cg.NumberPair {
446
445
  let mag = dist(from, to);
447
446
  //if (mag === 0) return [from[0], from[1]];
448
- const angle = moveAngle(from, to, false);
447
+ const angle = moveAngle(from, to);
449
448
  if (slots) {
450
449
  mag -= 33 / 64; // reduce by arrowhead length
451
- if (slots.size > 1) {
450
+ if (anyTwoCloserThan90Degrees(slots)) {
452
451
  mag -= 10 / 64; // reduce by shortening factor
453
- const slot = moveAngle(from, to);
454
- if (slots.has((slot + 1) % 16) || slots.has((slot + 15) % 16)) {
455
- if (slot & 1) mag -= 0.4;
456
- // and by label size for the knight if another arrow is within pi / 8.
457
- }
452
+ const slot = angleToSlot(angle);
453
+ // reduce by label size for the knight if another arrow is within pi / 8:
454
+ if (slot & 1 && [-1, 1].some(s => slots.has(rotateAngleSlot(slot, s)))) mag -= 0.4;
458
455
  }
459
456
  }
460
457
  return [from[0] - Math.cos(angle) * mag, from[1] - Math.sin(angle) * mag].map(
package/src/wrap.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { HeadlessState } from './state.js';
2
2
  import { setVisible, createEl } from './util.js';
3
- import { colors, files, ranks, Elements } from './types.js';
3
+ import { colors, files, ranks, Elements, Color } from './types.js';
4
4
  import { createElement as createSVG, setAttributes, createDefs } from './svg.js';
5
5
 
6
6
  export function renderWrap(element: HTMLElement, s: HeadlessState): Elements {
@@ -64,12 +64,19 @@ export function renderWrap(element: HTMLElement, s: HeadlessState): Elements {
64
64
  renderCoords(
65
65
  ranks.map(r => f + r),
66
66
  'squares rank' + rankN(i) + orientClass + ranksPositionClass,
67
+ i % 2 === 0 ? 'black' : 'white',
67
68
  ),
68
69
  ),
69
70
  );
70
71
  } else {
71
- container.appendChild(renderCoords(ranks, 'ranks' + orientClass + ranksPositionClass));
72
- container.appendChild(renderCoords(files, 'files' + orientClass));
72
+ container.appendChild(
73
+ renderCoords(
74
+ ranks,
75
+ 'ranks' + orientClass + ranksPositionClass,
76
+ s.ranksPosition === 'right' ? 'white' : 'black',
77
+ ),
78
+ );
79
+ container.appendChild(renderCoords(files, 'files' + orientClass, 'black'));
73
80
  }
74
81
  }
75
82
 
@@ -94,13 +101,14 @@ function svgContainer(cls: string, isShapes: boolean) {
94
101
  return svg;
95
102
  }
96
103
 
97
- function renderCoords(elems: readonly string[], className: string): HTMLElement {
104
+ function renderCoords(elems: readonly string[], className: string, firstColor: Color): HTMLElement {
98
105
  const el = createEl('coords', className);
99
106
  let f: HTMLElement;
100
- for (const elem of elems) {
101
- f = createEl('coord');
107
+ elems.forEach((elem, i) => {
108
+ const light = i % 2 === (firstColor === 'white' ? 0 : 1);
109
+ f = createEl('coord', `coord-${light ? 'light' : 'dark'}`);
102
110
  f.textContent = elem;
103
111
  el.appendChild(f);
104
- }
112
+ });
105
113
  return el;
106
114
  }