@lichess-org/chessground 9.4.0 → 9.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/chessground.js +2 -2
- package/dist/chessground.js.map +1 -1
- package/dist/chessground.min.js +1 -1
- package/dist/draw.d.ts +2 -1
- package/dist/draw.js.map +1 -1
- package/dist/premove.js +8 -6
- package/dist/premove.js.map +1 -1
- package/dist/state.js +1 -0
- package/dist/state.js.map +1 -1
- package/dist/svg.d.ts +2 -1
- package/dist/svg.js +73 -81
- package/dist/svg.js.map +1 -1
- package/dist/types.d.ts +4 -2
- package/dist/types.js.map +1 -1
- package/dist/wrap.js +22 -26
- package/dist/wrap.js.map +1 -1
- package/package.json +12 -13
- package/src/chessground.ts +1 -1
- package/src/draw.ts +4 -3
- package/src/premove.ts +8 -8
- package/src/state.ts +1 -0
- package/src/svg.ts +89 -85
- package/src/types.ts +4 -2
- package/src/wrap.ts +22 -27
package/README.md
CHANGED
package/dist/chessground.js
CHANGED
|
@@ -21,8 +21,8 @@ export function Chessground(element, config) {
|
|
|
21
21
|
render(state);
|
|
22
22
|
if (elements.autoPieces)
|
|
23
23
|
autoPieces.render(state, elements.autoPieces);
|
|
24
|
-
if (!skipSvg && elements.
|
|
25
|
-
svg.renderSvg(state, elements
|
|
24
|
+
if (!skipSvg && elements.shapes)
|
|
25
|
+
svg.renderSvg(state, elements);
|
|
26
26
|
}, onResize = () => {
|
|
27
27
|
updateBounds(state);
|
|
28
28
|
renderResized(state);
|
package/dist/chessground.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chessground.js","sourceRoot":"","sources":["../src/chessground.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,KAAK,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAU,SAAS,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAwB,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE5D,O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,KAAK,CAAC;QACpB,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC"}
|
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 G=["a","b","c","d","e","f","g","h"],I=["1","2","3","4","5","6","7","8"];var Ye=[...I].reverse(),se=G.flatMap(e=>I.map(o=>e+o)),h=e=>se[8*e[0]+e[1]],f=e=>[e.charCodeAt(0)-97,e.charCodeAt(1)-49];var ce=se.map(f);function Je(e){let o,n=()=>(o===void 0&&(o=e()),o);return n.clear=()=>{o=void 0},n}var eo=()=>{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",L=(e,o)=>(e[0]-o[0])**2+(e[1]-o[1])**2,W=(e,o)=>e.role===o.role&&e.color===o.color,oo=(e,o)=>e[0]===o[0]&&e[1]===o[1],F=e=>(o,n)=>[(n?o[0]:7-o[0])*e.width/8,(n?7-o[1]:o[1])*e.height/8],C=(e,o)=>{e.style.transform=`translate(${o[0]}px,${o[1]}px)`},ke=(e,o,n=1)=>{e.style.transform=`translate(${o[0]}px,${o[1]}px) scale(${n})`},_=(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,k=(e,o)=>{let n=document.createElement(e);return o&&(n.className=o),n};function de(e,o,n){let r=f(e);return o||(r[0]=7-r[0],r[1]=7-r[1]),[n.left+n.width*r[0]/8+n.width/16,n.top+n.height*(7-r[1])/8+n.height/16]}var K=(e,o)=>Math.abs(e-o),Q=(e,o,n,r)=>K(e,n)*K(o,r)===2,ue=(e,o,n,r)=>e===n!=(o===r),pe=(e,o,n,r)=>K(e,n)===K(o,r)&&e!==n,fe=(e,o,n,r)=>ue(e,o,n,r)||pe(e,o,n,r),De=(e,o,n,r)=>Math.max(K(e,n),K(o,r))===1,Ke=(e,o,n,r,t)=>K(e,n)===1&&r===o+(t?1:-1),Ee=(e,o,n,r,t)=>{let i=t?1:-1;return e===n&&(r===o+i||r===o+2*i&&(t?o<=1:o>=6))},Y=(e,o,n,r)=>{let t=n-e,i=r-o;if(t&&i&&Math.abs(t)!==Math.abs(i))return[];let s=Math.sign(t),u=Math.sign(i),l=[],a=e+s,c=o+u;for(;a!==n||c!==r;)l.push([a,c]),a+=s,c+=u;return l.map(d=>h(d))},no=e=>{let o=f(e),n=[];return o[0]>0&&n.push([o[0]-1,o[1]]),o[0]<7&&n.push([o[0]+1,o[1]]),n.map(h)},J=(e,o)=>{let n=f(e);return n[1]+=o,h(n)};var U=e=>e.friendlies.has(h(e.pos2)),tn=e=>e.enemies.has(h(e.pos2)),ro=(e,o,n)=>Y(...e,...o).some(r=>n.has(r)),to=(e,o,n)=>{let r=n.enemies.get(e);if(r?.role!=="pawn")return!1;let t=r.color==="white"?1:-1,i=f(e),s=f(o);return Ee(...i,...s,r.color==="white")&&!ro(i,[s[0],s[1]+t],n.allPieces)},an=(e,o,n)=>{let r=n.enemies.get(e);return r?.role==="pawn"&&Ke(...f(e),...f(o),r.color==="white")&&(n.friendlies.has(o)||me(J(o,r.color==="white"?-1:1),n.friendlies,n.enemies,n.lastMove))},sn=e=>[...e.enemies.keys()].some(o=>to(o,h(e.pos2),e)),xe=(e,o)=>{let n=e.pos2;return[...e.enemies].some(([r,t])=>{let i=f(r);return!o?.includes(t.role)&&(t.role==="pawn"&&Ke(...i,...n,t.color==="white")||t.role==="knight"&&Q(...i,...n)||t.role==="bishop"&&pe(...i,...n)||t.role==="rook"&&ue(...i,...n)||t.role==="queen"&&fe(...i,...n)||t.role==="king"&&De(...i,...n))&&(!["bishop","rook","queen"].includes(t.role)||!ro(i,n,e.allPieces))})},ge=e=>U(e)&&(me(h(e.pos2),e.friendlies,e.enemies,e.lastMove)||xe(e)),me=(e,o,n,r)=>{if(r&&e!==r[1])return!1;let t=f(e),i=o.get(e);return i?.role==="pawn"&&t[1]===(i.color==="white"?3:4)&&(!r||K(f(r[0])[1],t[1])===2)&&[1,-1].some(s=>n.get(h([t[0]+s,t[1]]))?.role==="pawn")},cn=e=>{if(e.unrestrictedPremoves)return!0;let o=Y(...e.pos1,...e.pos2),n=o.filter(r=>e.friendlies.has(r));return!n.length||n.length===1&&me(n[0],e.friendlies,e.enemies,e.lastMove)&&!o.includes(J(n[0],e.color==="white"?-1:1))},ln=e=>{if(e.unrestrictedPremoves)return!0;let o=Y(...e.pos1,...e.pos2),n=o.filter(a=>e.enemies.has(a));if(n.length>1)return!1;if(!n.length)return!0;let r=n[0],t=e.enemies.get(r);if(!t||t.role!=="pawn")return!0;let i=t.color==="white"?1:-1,s=J(r,i),u=[...no(s).filter(a=>an(r,a,e)),...[s,J(s,i)].filter(a=>to(r,a,e))],l=[...o,h(e.pos1)];return u.some(a=>!l.includes(a))},Ae=e=>cn(e)&&ln(e),dn=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||tn(e)?!0:U(e)?xe(e):sn(e)||me(h([e.pos2[0],e.pos2[1]+o]),e.friendlies,e.enemies,e.lastMove)||xe(e,["pawn"]):Ee(...e.pos1,...e.pos2,e.color==="white")&&Ae({...e,pos2:[e.pos2[0],e.pos2[1]+o]})},un=e=>Q(...e.pos1,...e.pos2)&&(e.unrestrictedPremoves||!U(e)||ge(e)),io=e=>pe(...e.pos1,...e.pos2)&&Ae(e)&&(e.unrestrictedPremoves||!U(e)||ge(e)),ao=e=>ue(...e.pos1,...e.pos2)&&Ae(e)&&(e.unrestrictedPremoves||!U(e)||ge(e)),pn=e=>io(e)||ao(e),fn=e=>De(...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||Y(...e.pos1,e.pos2[0]>e.pos1[0]?7:1,e.pos2[1]).map(o=>e.allPieces.get(o)).every(o=>!o||W(o,{role:"rook",color:e.color}))),gn={pawn:dn,knight:un,bishop:io,rook:ao,queen:pn,king:fn};function Ne(e,o){let n=e.pieces,r=e.premovable.castle,t=!!e.premovable.unrestrictedPremoves,i=n.get(o);if(!i||i.color===e.turnColor)return[];let s=i.color,u=new Map([...n].filter(([p,m])=>m.color===s)),l=new Map([...n].filter(([p,m])=>m.color===j(s))),a=f(o),c=gn[i.role],d={pos1:a,allPieces:n,friendlies:u,enemies:l,unrestrictedPremoves:t,color:s,canCastle:r,rookFilesFriendlies:Array.from(n).filter(([p,m])=>p[1]===(s==="white"?"1":"8")&&m.color===s&&m.role==="rook").map(([p])=>f(p)[0]),lastMove:e.lastMove};return ce.filter(p=>c({...d,pos2:p})).map(h)}function M(e,...o){e&&setTimeout(()=>e(...o),1)}function so(e){e.orientation=j(e.orientation),e.animation.current=e.draggable.current=e.selected=void 0}function co(e,o){for(let[n,r]of o)r?e.pieces.set(n,r):e.pieces.delete(n)}function lo(e,o){if(e.check=void 0,o===!0&&(o=e.turnColor),o)for(let[n,r]of e.pieces)r.role==="king"&&r.color===o&&(e.check=n)}function mn(e,o,n,r){x(e),e.premovable.current=[o,n],M(e.premovable.events.set,o,n,r)}function E(e){e.premovable.current&&(e.premovable.current=void 0,M(e.premovable.events.unset))}function hn(e,o,n){E(e),e.predroppable.current={role:o,key:n},M(e.predroppable.events.set,o,n)}function x(e){let o=e.predroppable;o.current&&(o.current=void 0,M(o.events.unset))}function bn(e,o,n){if(!e.autoCastle)return!1;let r=e.pieces.get(o);if(!r||r.role!=="king")return!1;let t=f(o),i=f(n);if(t[1]!==0&&t[1]!==7||t[1]!==i[1])return!1;t[0]===4&&!e.pieces.has(n)&&(i[0]===6?n=h([7,i[1]]):i[0]===2&&(n=h([0,i[1]])));let s=e.pieces.get(n);return!s||s.color!==r.color||s.role!=="rook"?!1:(e.pieces.delete(o),e.pieces.delete(n),t[0]<i[0]?(e.pieces.set(h([6,i[1]]),r),e.pieces.set(h([5,i[1]]),s)):(e.pieces.set(h([2,i[1]]),r),e.pieces.set(h([3,i[1]]),s)),!0)}function He(e,o,n){let r=e.pieces.get(o),t=e.pieces.get(n);if(o===n||!r)return!1;let i=t&&t.color!==r.color?t:void 0;return n===e.selected&&P(e),M(e.events.move,o,n,i),bn(e,o,n)||(e.pieces.set(n,r),e.pieces.delete(o)),e.lastMove=[o,n],e.check=void 0,M(e.events.change),i||!0}function he(e,o,n,r){if(e.pieces.has(n))if(r)e.pieces.delete(n);else return!1;return M(e.events.dropNewPiece,o,n),e.pieces.set(n,o),e.lastMove=[n],e.check=void 0,M(e.events.change),e.movable.dests=void 0,e.turnColor=j(e.turnColor),!0}function uo(e,o,n){let r=He(e,o,n);return r&&(e.movable.dests=void 0,e.turnColor=j(e.turnColor),e.animation.current=void 0),r}function qe(e,o,n){if(ve(e,o,n)){let r=uo(e,o,n);if(r){let t=e.hold.stop();P(e);let i={premove:!1,ctrlKey:e.stats.ctrlKey,holdTime:t};return r!==!0&&(i.captured=r),M(e.movable.events.after,o,n,i),!0}}else if(yn(e,o,n))return mn(e,o,n,{ctrlKey:e.stats.ctrlKey}),P(e),!0;return P(e),!1}function be(e,o,n,r){let t=e.pieces.get(o);t&&(vn(e,o,n)||r)?(e.pieces.delete(o),he(e,t,n,r),M(e.movable.events.afterNewPiece,t.role,n,{premove:!1,predrop:!1})):t&&wn(e,o,n)?hn(e,t.role,n):(E(e),x(e)),e.pieces.delete(o),P(e)}function oe(e,o,n){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||n)&&e.selected!==o&&qe(e,e.selected,o)){e.stats.dragged=!1;return}}(e.selectable.enabled||e.draggable.enabled)&&(po(e,o)||Be(e,o))&&(Te(e,o),e.hold.start())}function Te(e,o){e.selected=o,Be(e,o)?e.premovable.customDests||(e.premovable.dests=Ne(e,o)):e.premovable.dests=void 0}function P(e){e.selected=void 0,e.premovable.dests=void 0,e.hold.cancel()}function po(e,o){let n=e.pieces.get(o);return!!n&&(e.movable.color==="both"||e.movable.color===n.color&&e.turnColor===n.color)}var ve=(e,o,n)=>o!==n&&po(e,o)&&(e.movable.free||!!e.movable.dests?.get(o)?.includes(n));function vn(e,o,n){let r=e.pieces.get(o);return!!r&&(o===n||!e.pieces.has(n))&&(e.movable.color==="both"||e.movable.color===r.color&&e.turnColor===r.color)}function Be(e,o){let n=e.pieces.get(o);return!!n&&e.premovable.enabled&&e.movable.color===n.color&&e.turnColor!==n.color}var yn=(e,o,n)=>o!==n&&Be(e,o)&&(e.premovable.customDests?.get(o)??Ne(e,o)).includes(n);function wn(e,o,n){let r=e.pieces.get(o),t=e.pieces.get(n);return!!r&&(!t||t.color!==e.movable.color)&&e.predroppable.enabled&&(r.role!=="pawn"||n[1]!=="1"&&n[1]!=="8")&&e.movable.color===r.color&&e.turnColor!==r.color}function fo(e,o){let n=e.pieces.get(o);return!!n&&e.draggable.enabled&&(e.movable.color==="both"||e.movable.color===n.color&&(e.turnColor===n.color||e.premovable.enabled))}function go(e){let o=e.premovable.current;if(!o)return!1;let n=o[0],r=o[1],t=!1;if(ve(e,n,r)){let i=uo(e,n,r);if(i){let s={premove:!0};i!==!0&&(s.captured=i),M(e.movable.events.after,n,r,s),t=!0}}return E(e),t}function mo(e,o){let n=e.predroppable.current,r=!1;if(!n)return!1;if(o(n)){let t={role:n.role,color:e.movable.color};he(e,t,n.key)&&(M(e.movable.events.afterNewPiece,n.role,n.key,{premove:!1,predrop:!0}),r=!0)}return x(e),r}function ne(e){E(e),x(e),P(e)}function Oe(e){e.movable.color=e.movable.dests=e.animation.current=void 0,ne(e)}function A(e,o,n){let r=Math.floor(8*(e[0]-n.left)/n.width);o||(r=7-r);let t=7-Math.floor(8*(e[1]-n.top)/n.height);return o||(t=7-t),r>=0&&r<8&&t>=0&&t<8?h([r,t]):void 0}function ho(e,o,n,r){let t=f(e),i=ce.filter(a=>oo(t,a)||fe(t[0],t[1],a[0],a[1])||Q(t[0],t[1],a[0],a[1])),u=i.map(a=>de(h(a),n,r)).map(a=>L(o,a)),[,l]=u.reduce((a,c,d)=>a[0]<c?a:[c,d],[u[0],0]);return h(i[l])}var v=e=>e.orientation==="white";var Ve="rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR",Sn={p:"pawn",r:"rook",n:"knight",b:"bishop",q:"queen",k:"king"},Pn={pawn:"p",rook:"r",knight:"n",bishop:"b",queen:"q",king:"k"};function ye(e){e==="start"&&(e=Ve);let o=new Map,n=7,r=0;for(let t of e)switch(t){case" ":case"[":return o;case"/":if(--n,n<0)return o;r=0;break;case"~":{let i=o.get(h([r-1,n]));i&&(i.promoted=!0);break}default:{let i=t.charCodeAt(0);if(i<57)r+=i-48;else{let s=t.toLowerCase();o.set(h([r,n]),{role:Sn[s],color:t===s?"black":"white"}),++r}}}return o}function bo(e){return Ye.map(o=>G.map(n=>{let r=e.get(n+o);if(r){let t=Pn[r.role];return r.color==="white"&&(t=t.toUpperCase()),r.promoted&&(t+="~"),t}else return"1"}).join("")).join("/").replace(/1{2,}/g,o=>o.length.toString())}function Le(e,o){o.animation&&(Fe(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=[]),Fe(e,o),o.fen&&(e.pieces=ye(o.fen),e.drawable.shapes=o.drawable?.shapes||[]),"check"in o&&lo(e,o.check||!1),"lastMove"in o&&!o.lastMove?e.lastMove=void 0:o.lastMove&&(e.lastMove=o.lastMove),e.selected&&Te(e,e.selected),Le(e,o),!e.movable.rookCastle&&e.movable.dests){let n=e.movable.color==="white"?"1":"8",r="e"+n,t=e.movable.dests.get(r),i=e.pieces.get(r);if(!t||!i||i.role!=="king")return;e.movable.dests.set(r,t.filter(s=>!(s==="a"+n&&t.includes("c"+n))&&!(s==="h"+n&&t.includes("g"+n))))}}function Fe(e,o){for(let n in o)n==="__proto__"||n==="constructor"||!Object.prototype.hasOwnProperty.call(o,n)||(Object.prototype.hasOwnProperty.call(e,n)&&vo(e[n])&&vo(o[n])?Fe(e[n],o[n]):e[n]=o[n])}function vo(e){if(typeof e!="object"||e===null)return!1;let o=Object.getPrototypeOf(e);return o===Object.prototype||o===null}var O=(e,o)=>o.animation.enabled?Dn(e,o):R(e,o);function R(e,o){let n=e(o);return o.dom.redraw(),n}var Ge=(e,o)=>({key:e,pos:f(e),piece:o}),Cn=(e,o)=>o.sort((n,r)=>L(e.pos,n.pos)-L(e.pos,r.pos))[0];function kn(e,o){let n=new Map,r=[],t=new Map,i=[],s=[],u=new Map,l,a,c;for(let[d,p]of e)u.set(d,Ge(d,p));for(let d of se)l=o.pieces.get(d),a=u.get(d),l?a?W(l,a.piece)||(i.push(a),s.push(Ge(d,l))):s.push(Ge(d,l)):a&&i.push(a);for(let d of s)a=Cn(d,i.filter(p=>W(d.piece,p.piece))),a&&(c=[a.pos[0]-d.pos[0],a.pos[1]-d.pos[1]],n.set(d.key,c.concat(c)),r.push(a.key));for(let d of i)r.includes(d.key)||t.set(d.key,d.piece);return{anims:n,fadings:t}}function yo(e,o){let n=e.animation.current;if(n===void 0){e.dom.destroyed||e.dom.redrawNow();return}let r=1-(o-n.start)*n.frequency;if(r<=0)e.animation.current=void 0,e.dom.redrawNow();else{let t=Kn(r);for(let i of n.plan.anims.values())i[2]=i[0]*t,i[3]=i[1]*t;e.dom.redrawNow(!0),requestAnimationFrame((i=performance.now())=>yo(e,i))}}function Dn(e,o){let n=new Map(o.pieces),r=e(o),t=kn(n,o);if(t.anims.size||t.fadings.size){let i=o.animation.current&&o.animation.current.start;o.animation.current={start:performance.now(),frequency:1/o.animation.duration,plan:t},i||yo(o,performance.now())}else o.dom.redraw();return r}var Kn=e=>e<.5?4*e*e*e:(e-1)*(2*e-2)*(2*e-2)+1;var En=["green","red","blue","yellow"];function wo(e,o){if(o.touches&&o.touches.length>1)return;o.stopPropagation(),o.preventDefault(),o.ctrlKey?P(e):ne(e);let n=T(o),r=A(n,v(e),e.dom.bounds());r&&(e.drawable.current={orig:r,pos:n,brush:xn(o),snapToValidMove:e.drawable.defaultSnapToValidMove},So(e))}function So(e){requestAnimationFrame(()=>{let o=e.drawable.current;if(o){let n=A(o.pos,v(e),e.dom.bounds());n||(o.snapToValidMove=!1);let r=o.snapToValidMove?ho(o.orig,o.pos,v(e),e.dom.bounds()):n;r!==o.mouseSq&&(o.mouseSq=r,o.dest=r!==o.orig?r:void 0,e.dom.redrawNow()),So(e)}})}function Po(e,o){e.drawable.current&&(e.drawable.current.pos=T(o))}function Mo(e){let o=e.drawable.current;o&&(o.mouseSq&&An(e.drawable,o),We(e))}function We(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(),ko(e.drawable))}function xn(e){let o=(e.shiftKey||e.ctrlKey)&&le(e),n=e.altKey||e.metaKey||e.getModifierState?.("AltGraph");return En[(o?1:0)+(n?2:0)]}function An(e,o){let n=t=>t.orig===o.orig&&t.dest===o.dest,r=e.shapes.find(n);r&&(e.shapes=e.shapes.filter(t=>!n(t))),(!r||r.brush!==o.brush)&&e.shapes.push({orig:o.orig,dest:o.dest,brush:o.brush}),ko(e)}function ko(e){e.onChange&&e.onChange(e.shapes)}function Do(e,o){if(!(e.trustAllEvents||o.isTrusted)||o.buttons!==void 0&&o.buttons>1||o.touches&&o.touches.length>1)return;let n=e.dom.bounds(),r=T(o),t=A(r,v(e),n);if(!t)return;let i=e.pieces.get(t),s=e.selected;if(!s&&e.drawable.enabled&&(e.drawable.eraseOnClick||!i||i.color!==e.turnColor)&&Co(e),o.cancelable!==!1&&(!o.touches||e.blockTouchScroll||i||s||Hn(e,r)))o.preventDefault();else if(o.touches)return;let u=!!e.premovable.current,l=!!e.predroppable.current;e.stats.ctrlKey=o.ctrlKey,e.selected&&ve(e,e.selected,t)?O(d=>oe(d,t),e):oe(e,t);let a=e.selected===t,c=No(e,t);if(i&&c&&a&&fo(e,t)){e.draggable.current={orig:t,piece:i,origPos:r,pos:r,started:e.draggable.autoDistance&&e.stats.dragged,element:c,previouslySelected:s,originTarget:o.target,keyHasChanged:!1},c.cgDragging=!0,c.classList.add("dragging");let d=e.dom.elements.ghost;d&&(d.className=`ghost ${i.color} ${i.role}`,C(d,F(n)(f(t),v(e))),_(d,!0)),ze(e)}else u&&E(e),l&&x(e);e.dom.redraw()}function Hn(e,o){let n=v(e),r=e.dom.bounds(),t=Math.pow(r.width/8,2);for(let i of e.pieces.keys()){let s=de(i,n,r);if(L(s,o)<=t)return!0}return!1}function Ko(e,o,n,r){let t="a0";e.pieces.set(t,o),e.dom.redraw();let i=T(n);e.draggable.current={orig:t,piece:o,origPos:i,pos:i,started:!0,element:()=>No(e,t),originTarget:n.target,newPiece:!0,force:!!r,keyHasChanged:!1},ze(e)}function ze(e){requestAnimationFrame(()=>{let o=e.draggable.current;if(!o)return;e.animation.current?.plan.anims.has(o.orig)&&(e.animation.current=void 0);let n=e.pieces.get(o.orig);if(!n||!W(n,o.piece))z(e);else if(!o.started&&L(o.pos,o.origPos)>=Math.pow(e.draggable.distance,2)&&(o.started=!0),o.started){if(typeof o.element=="function"){let t=o.element();if(!t)return;t.cgDragging=!0,t.classList.add("dragging"),o.element=t}let r=e.dom.bounds();C(o.element,[o.pos[0]-r.left-r.width/16,o.pos[1]-r.top-r.height/16]),o.keyHasChanged||=o.orig!==A(o.pos,v(e),r)}ze(e)})}function Eo(e,o){e.draggable.current&&(!o.touches||o.touches.length<2)&&(e.draggable.current.pos=T(o))}function xo(e,o){let n=e.draggable.current;if(!n)return;if(o.type==="touchend"&&o.cancelable!==!1&&o.preventDefault(),o.type==="touchend"&&n.originTarget!==o.target&&!n.newPiece){e.draggable.current=void 0;return}E(e),x(e);let r=T(o)||n.pos,t=A(r,v(e),e.dom.bounds());t&&n.started&&n.orig!==t?n.newPiece?be(e,n.orig,t,n.force):(e.stats.ctrlKey=o.ctrlKey,qe(e,n.orig,t)&&(e.stats.dragged=!0)):n.newPiece?e.pieces.delete(n.orig):e.draggable.deleteOnDropOff&&!t&&(e.pieces.delete(n.orig),M(e.events.change)),(n.orig===n.previouslySelected||n.keyHasChanged)&&(n.orig===t||!t)?P(e):e.selectable.enabled||P(e),Ao(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,P(e),Ao(e),e.dom.redraw())}function Ao(e){let o=e.dom.elements;o.ghost&&_(o.ghost,!1)}function No(e,o){let n=e.dom.elements.board.firstChild;for(;n;){if(n.cgKey===o&&n.tagName==="PIECE")return n;n=n.nextSibling}}function qo(e,o){e.exploding={stage:1,keys:o},e.dom.redraw(),setTimeout(()=>{Ho(e,2),setTimeout(()=>Ho(e,void 0),120)},120)}function Ho(e,o){e.exploding&&(o?e.exploding.stage=o:e.exploding=void 0,e.dom.redraw())}function To(e,o){function n(){so(e),o()}return{set(r){r.orientation&&r.orientation!==e.orientation&&n(),Le(e,r),(r.fen?O:R)(t=>we(t,r),e)},state:e,getFen:()=>bo(e.pieces),toggleOrientation:n,setPieces(r){O(t=>co(t,r),e)},selectSquare(r,t){r?O(i=>oe(i,r,t),e):e.selected&&(P(e),e.dom.redraw())},move(r,t){O(i=>He(i,r,t),e)},newPiece(r,t){O(i=>he(i,r,t),e)},playPremove(){if(e.premovable.current){if(O(go,e))return!0;e.dom.redraw()}return!1},playPredrop(r){if(e.predroppable.current){let t=mo(e,r);return e.dom.redraw(),t}return!1},cancelPremove(){R(E,e)},cancelPredrop(){R(x,e)},cancelMove(){R(r=>{ne(r),z(r)},e)},stop(){R(r=>{Oe(r),z(r)},e)},explode(r){qo(e,r)},setAutoShapes(r){R(t=>t.drawable.autoShapes=r,e)},setShapes(r){R(t=>t.drawable.shapes=r.slice(),e)},getKeyAtDomPos(r){return A(r,v(e),e.dom.bounds())},redrawAll:o,dragNewPiece(r,t,i){Ko(e,r,t,i)},destroy(){Oe(e),e.dom.unbind&&e.dom.unbind(),e.dom.destroyed=!0}}}function Bo(){return{pieces:ye(Ve),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},paleWhite:{key:"pwhite",color:"white",opacity:.6,lineWidth:10}},prevSvgHash:""},hold:eo()}}function Vo(){let e=w("defs"),o=S(w("filter"),{id:"cg-filter-blur"});return o.appendChild(S(w("feGaussianBlur"),{stdDeviation:"0.013"})),e.appendChild(o),e}function Lo(e,o){let n=e.drawable,r=n.current,t=r&&r.mouseSq?r:void 0,i=new Map,s=e.dom.bounds(),u=n.autoShapes.filter(c=>!c.piece);for(let c of n.shapes.concat(u).concat(t?[t]:[])){if(!c.dest)continue;let d=i.get(c.dest)??new Set,p=Pe(Se(f(c.orig),e.orientation),s),m=Pe(Se(f(c.dest),e.orientation),s);d.add(Ie(p,m)),i.set(c.dest,d)}let l=[];for(let c of n.shapes.concat(u))l.push({shape:c,current:!1,hash:Oo(c,$e(c.dest,i),!1,s)});t&&l.push({shape:t,current:!0,hash:Oo(t,$e(t.dest,i),!0,s)});let a=l.map(c=>c.hash).join(";");a!==e.drawable.prevSvgHash&&(e.drawable.prevSvgHash=a,Tn(n,l,o),Bn(l,o,c=>Vn(e,c,n.brushes,i,s)))}function Tn(e,o,n){for(let r of[n.shapes,n.shapesBelow]){let t=r.querySelector("defs"),i=o.filter(a=>r===n.shapesBelow==!!a.shape.below),s=new Map;for(let a of i.filter(c=>c.shape.dest&&c.shape.brush)){let c=Fo(e.brushes[a.shape.brush],a.shape.modifiers),{key:d,color:p}=Go(a.shape);d&&p&&s.set(d,{key:d,color:p,opacity:1,lineWidth:1}),s.set(c.key,c)}let u=new Set,l=t.firstElementChild;for(;l;)u.add(l.getAttribute("cgKey")),l=l.nextElementSibling;for(let[a,c]of s.entries())u.has(a)||t.appendChild(Gn(c))}}function Bn(e,o,n){for(let[r,t]of[[o.shapes,o.custom],[o.shapesBelow,o.customBelow]]){let[i,s]=[r,t].map(a=>a.querySelector("g")),u=e.filter(a=>r===o.shapesBelow==!!a.shape.below),l=new Map;for(let a of u)l.set(a.hash,!1);for(let a of[i,s]){let c=[],d=a.firstElementChild,p;for(;d;)p=d.getAttribute("cgHash"),l.has(p)?l.set(p,!0):c.push(d),d=d.nextElementSibling;for(let m of c)a.removeChild(m)}for(let a of u.filter(c=>!l.get(c.hash)))for(let c of n(a))c.isCustom?s.appendChild(c.el):i.appendChild(c.el)}}function Oo({orig:e,dest:o,brush:n,piece:r,modifiers:t,customSvg:i,label:s,below:u},l,a,c){return[c.width,c.height,a,e,o,n,l&&"-",r&&On(r),t&&Rn(t),i&&`custom-${Ro(i.html)},${i.center?.[0]??"o"}`,s&&`label-${Ro(s.text)}`,u&&"below"].filter(d=>d).join(",")}function On(e){return[e.color,e.role,e.scale].filter(o=>o).join(",")}function Rn(e){return[e.lineWidth,e.hilite].filter(o=>o).join(",")}function Ro(e){let o=0;for(let n=0;n<e.length;n++)o=(o<<5)-o+e.charCodeAt(n)>>>0;return o.toString()}function Vn(e,{shape:o,current:n,hash:r},t,i,s){let u=Pe(Se(f(o.orig),e.orientation),s),l=o.dest?Pe(Se(f(o.dest),e.orientation),s):u,a=o.brush&&Fo(t[o.brush],o.modifiers),c=i.get(o.dest),d=[];if(a){let p=S(w("g"),{cgHash:r});d.push({el:p}),u[0]!==l[0]||u[1]!==l[1]?p.appendChild(Fn(o,a,u,l,n,$e(o.dest,i))):p.appendChild(Ln(t[o.brush],u,n,s))}if(o.label){let p=o.label;p.fill??=o.brush&&t[o.brush].color;let m=o.brush?void 0:"tr";d.push({el:Wn(p,r,u,l,c,m),isCustom:!0})}if(o.customSvg){let p=o.customSvg.center??"orig",[m,y]=p==="label"?zo(u,l,c).map(B=>B-.5):p==="dest"?l:u,g=S(w("g"),{transform:`translate(${m},${y})`,cgHash:r});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 Ln(e,o,n,r){let t=zn(),i=(r.width+r.height)/(4*Math.max(r.width,r.height));return S(w("circle"),{stroke:e.color,"stroke-width":t[n?0:1],fill:"none",opacity:Wo(e,n),cx:o[0],cy:o[1],r:i-t[1]/2})}function Fn(e,o,n,r,t,i){function s(a){let c=In(i&&!t),d=r[0]-n[0],p=r[1]-n[1],m=Math.atan2(p,d),y=Math.cos(m)*c,g=Math.sin(m)*c,B=Go(e);return S(w("line"),{stroke:a?B.color:o.color,"stroke-width":$n(o,t)*(a?1.14:1),"stroke-linecap":"round","marker-end":`url(#arrowhead-${a?B.key:o.key})`,opacity:e.modifiers?.hilite?1:Wo(o,t),x1:n[0],y1:n[1],x2:r[0]-y,y2:r[1]-g})}if(!e.modifiers?.hilite)return s(!1);let u=S(w("g"),{opacity:o.opacity}),l=S(w("g"),{filter:"url(#cg-filter-blur)"});return l.appendChild(jn(n,r)),l.appendChild(s(!0)),u.appendChild(l),u.appendChild(s(!1)),u}function Gn(e){let o=S(w("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(w("path"),{d:"M0,0 V4 L3,2 Z",fill:e.color})),o.setAttribute("cgKey",e.key),o}function Wn(e,o,n,r,t,i){let u=.4*.75**e.text.length,l=zo(n,r,t),a=i==="tr"?.4:0,c=S(w("g"),{transform:`translate(${l[0]+a},${l[1]-a})`,cgHash:o});c.appendChild(S(w("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(w("text"),{"font-size":u,"font-family":"Noto Sans","text-anchor":"middle",fill:"white",y:.13*.75**e.text.length});return d.innerHTML=e.text,c.appendChild(d),c}function Se(e,o){return o==="white"?e:[7-e[0],7-e[1]]}function $e(e,o){return(e&&o.has(e)&&o.get(e).size>1)===!0}function w(e){return document.createElementNS("http://www.w3.org/2000/svg",e)}function S(e,o){for(let n in o)Object.prototype.hasOwnProperty.call(o,n)&&e.setAttribute(n,o[n]);return e}function Fo(e,o){return o?{color:e.color,opacity:Math.round(e.opacity*10)/10,lineWidth:Math.round(o.lineWidth||e.lineWidth),key:[e.key,o.lineWidth].filter(n=>n).join("")}:e}function zn(){return[3/64,4/64]}function $n(e,o){return(e.lineWidth||10)*(o?.85:1)/64}function Go(e){let o=e.modifiers?.hilite;return{key:o&&`hilite-${o.replace("#","")}`,color:o}}function Wo(e,o){return(e.opacity||1)*(o?.9:1)}function In(e){return(e?20:10)/64}function Pe(e,o){let n=Math.min(1,o.width/o.height),r=Math.min(1,o.height/o.width);return[(e[0]-3.5)*n,(3.5-e[1])*r]}function jn(e,o){let n={from:[Math.floor(Math.min(e[0],o[0])),Math.floor(Math.min(e[1],o[1]))],to:[Math.ceil(Math.max(e[0],o[0])),Math.ceil(Math.max(e[1],o[1]))]};return S(w("rect"),{x:n.from[0],y:n.from[1],width:n.to[0]-n.from[0],height:n.to[1]-n.from[1],fill:"none",stroke:"none"})}function Ie(e,o,n=!0){let r=Math.atan2(o[1]-e[1],o[0]-e[0])+Math.PI;return n?(Math.round(r*8/Math.PI)+16)%16:r}function Un(e,o){return Math.sqrt([e[0]-o[0],e[1]-o[1]].reduce((n,r)=>n+r*r,0))}function zo(e,o,n){let r=Un(e,o),t=Ie(e,o,!1);if(n&&(r-=33/64,n.size>1)){r-=10/64;let i=Ie(e,o);(n.has((i+1)%16)||n.has((i+15)%16))&&i&1&&(r-=.4)}return[e[0]-Math.cos(t)*r,e[1]-Math.sin(t)*r].map(i=>i+.5)}function Io(e,o){e.innerHTML="",e.classList.add("cg-wrap");for(let c of _e)e.classList.toggle("orientation-"+c,o.orientation===c);e.classList.toggle("manipulable",!o.viewOnly);let n=k("cg-container");e.appendChild(n);let r=k("cg-board");n.appendChild(r);let t,i,s,u,l;if(o.drawable.visible&&([t,i]=["cg-shapes-below","cg-shapes"].map(c=>$o(c,!0)),[s,u]=["cg-custom-below","cg-custom-svgs"].map(c=>$o(c,!1)),l=k("cg-auto-pieces"),n.appendChild(t),n.appendChild(s),n.appendChild(i),n.appendChild(u),n.appendChild(l)),o.coordinates){let c=o.orientation==="black"?" black":"",d=o.ranksPosition==="left"?" left":"";if(o.coordinatesOnSquares){let p=o.orientation==="white"?m=>m+1:m=>8-m;G.forEach((m,y)=>n.appendChild(je(I.map(g=>m+g),"squares rank"+p(y)+c+d)))}else n.appendChild(je(I,"ranks"+c+d)),n.appendChild(je(G,"files"+c))}let a;return o.draggable.enabled&&o.draggable.showGhost&&(a=k("piece","ghost"),_(a,!1),n.appendChild(a)),{board:r,container:n,wrap:e,ghost:a,shapes:i,shapesBelow:t,custom:u,customBelow:s,autoPieces:l}}function $o(e,o){let n=S(w("svg"),{class:e,viewBox:o?"-4 -4 8 8":"-3.5 -3.5 8 8",preserveAspectRatio:"xMidYMid slice"});return n.appendChild(w("g")),o&&n.appendChild(Vo()),n}function je(e,o){let n=k("coords",o),r;for(let t of e)r=k("coord"),r.textContent=t,n.appendChild(r);return n}function jo(e,o){if(!e.dropmode.active)return;E(e),x(e);let n=e.dropmode.piece;if(n){e.pieces.set("a0",n);let r=T(o),t=r&&A(r,v(e),e.dom.bounds());t&&be(e,"a0",t)}e.dom.redraw()}function Zo(e,o){let n=e.dom.elements.board;if("ResizeObserver"in window&&new ResizeObserver(o).observe(e.dom.elements.wrap),(e.disableContextMenu||e.drawable.enabled)&&n.addEventListener("contextmenu",t=>t.preventDefault()),e.viewOnly)return;let r=Xn(e);n.addEventListener("touchstart",r,{passive:!1}),n.addEventListener("mousedown",r,{passive:!1})}function Xo(e,o){let n=[];if("ResizeObserver"in window||n.push(re(document.body,"chessground.resize",o)),!e.viewOnly){let r=Uo(e,Eo,Po),t=Uo(e,xo,Mo);for(let s of["touchmove","mousemove"])n.push(re(document,s,r));for(let s of["touchend","mouseup"])n.push(re(document,s,t));let i=()=>e.dom.bounds.clear();n.push(re(document,"scroll",i,{capture:!0,passive:!0})),n.push(re(window,"resize",i,{passive:!0}))}return()=>n.forEach(r=>r())}function re(e,o,n,r){return e.addEventListener(o,n,r),()=>e.removeEventListener(o,n,r)}var Xn=e=>o=>{e.draggable.current?z(e):e.drawable.current?We(e):o.shiftKey||le(o)?e.drawable.enabled&&wo(e,o):e.viewOnly||(e.dropmode.active?jo(e,o):Do(e,o))},Uo=(e,o,n)=>r=>{e.drawable.current?e.drawable.enabled&&n(e,r):e.viewOnly||o(e,r)};function Qo(e){let o=v(e),n=F(e.dom.bounds()),r=e.dom.elements.board,t=e.pieces,i=e.animation.current,s=i?i.plan.anims:new Map,u=i?i.plan.fadings:new Map,l=e.draggable.current,a=Qn(e),c=new Set,d=new Set,p=new Map,m=new Map,y,g,B,$,D,Z,Me,N,Ce,ie;for(g=r.firstChild;g;){if(y=g.cgKey,Jo(g))if(B=t.get(y),D=s.get(y),Z=u.get(y),$=g.cgPiece,g.cgDragging&&(!l||l.orig!==y)&&(g.classList.remove("dragging"),C(g,n(f(y),o)),g.cgDragging=!1),!Z&&g.cgFading&&(g.cgFading=!1,g.classList.remove("fading")),B){if(D&&g.cgAnimating&&$===te(B)){let b=f(y);b[0]+=D[2],b[1]+=D[3],g.classList.add("anim"),C(g,n(b,o))}else g.cgAnimating&&(g.cgAnimating=!1,g.classList.remove("anim"),C(g,n(f(y),o)),e.addPieceZIndex&&(g.style.zIndex=Ue(f(y),o)));$===te(B)&&(!Z||!g.cgFading)?c.add(y):Z&&$===te(Z)?(g.classList.add("fading"),g.cgFading=!0):Ze(p,$,g)}else Ze(p,$,g);else if(en(g)){let b=g.className;a.get(y)===b?d.add(y):Ze(m,b,g)}g=g.nextSibling}for(let[b,X]of a)if(!d.has(b)){Ce=m.get(X),ie=Ce&&Ce.pop();let H=n(f(b),o);if(ie)ie.cgKey=b,C(ie,H);else{let q=k("square",X);q.cgKey=b,C(q,H),r.insertBefore(q,r.firstChild)}}for(let[b,X]of t)if(D=s.get(b),!c.has(b))if(Me=p.get(te(X)),N=Me&&Me.pop(),N){N.cgKey=b,N.cgFading&&(N.classList.remove("fading"),N.cgFading=!1);let H=f(b);e.addPieceZIndex&&(N.style.zIndex=Ue(H,o)),D&&(N.cgAnimating=!0,N.classList.add("anim"),H[0]+=D[2],H[1]+=D[3]),C(N,n(H,o))}else{let H=te(X),q=k("piece",H),ae=f(b);q.cgPiece=H,q.cgKey=b,D&&(q.cgAnimating=!0,ae[0]+=D[2],ae[1]+=D[3]),C(q,n(ae,o)),e.addPieceZIndex&&(q.style.zIndex=Ue(ae,o)),r.appendChild(q)}for(let b of p.values())_o(e,b);for(let b of m.values())_o(e,b)}function Yo(e){let o=v(e),n=F(e.dom.bounds()),r=e.dom.elements.board.firstChild;for(;r;)(Jo(r)&&!r.cgAnimating||en(r))&&C(r,n(f(r.cgKey),o)),r=r.nextSibling}function Xe(e){let o=e.dom.elements.wrap.getBoundingClientRect(),n=e.dom.elements.container,r=o.height/o.width,t=Math.floor(o.width*window.devicePixelRatio/8)*8/window.devicePixelRatio,i=t*r;n.style.width=t+"px",n.style.height=i+"px",e.dom.bounds.clear(),e.addDimensionsCssVarsTo?.style.setProperty("---cg-width",t+"px"),e.addDimensionsCssVarsTo?.style.setProperty("---cg-height",i+"px")}var Jo=e=>e.tagName==="PIECE",en=e=>e.tagName==="SQUARE";function _o(e,o){for(let n of o)e.dom.elements.board.removeChild(n)}function Ue(e,o){let r=e[1];return`${o?10-r:3+r}`}var te=e=>`${e.color} ${e.role}`;function Qn(e){let o=new Map;if(e.lastMove&&e.highlight.lastMove)for(let t of e.lastMove)V(o,t,"last-move");if(e.check&&e.highlight.check&&V(o,e.check,"check"),e.selected&&(V(o,e.selected,"selected"),e.movable.showDests)){let t=e.movable.dests?.get(e.selected);if(t)for(let s of t)V(o,s,"move-dest"+(e.pieces.has(s)?" oc":""));let i=e.premovable.customDests?.get(e.selected)??e.premovable.dests;if(i)for(let s of i)V(o,s,"premove-dest"+(e.pieces.has(s)?" oc":""))}let n=e.premovable.current;if(n)for(let t of n)V(o,t,"current-premove");else e.predroppable.current&&V(o,e.predroppable.current.key,"current-premove");let r=e.exploding;if(r)for(let t of r.keys)V(o,t,"exploding"+r.stage);return e.highlight.custom&&e.highlight.custom.forEach((t,i)=>{V(o,i,t)}),o}function V(e,o,n){let r=e.get(o);r?e.set(o,`${r} ${n}`):e.set(o,n)}function Ze(e,o,n){let r=e.get(o);r?r.push(n):e.set(o,[n])}function on(e,o,n){let r=new Map,t=[];for(let u of e)r.set(u.hash,!1);let i=o.firstElementChild,s;for(;i;)s=i.getAttribute("cgHash"),r.has(s)?r.set(s,!0):t.push(i),i=i.nextElementSibling;for(let u of t)o.removeChild(u);for(let u of e)r.get(u.hash)||o.appendChild(n(u))}function nn(e,o){let r=e.drawable.autoShapes.filter(t=>t.piece).map(t=>({shape:t,hash:Jn(t),current:!1}));on(r,o,t=>Yn(e,t,e.dom.bounds()))}function rn(e){let o=v(e),n=F(e.dom.bounds()),r=e.dom.elements.autoPieces?.firstChild;for(;r;)ke(r,n(f(r.cgKey),o),r.cgScale),r=r.nextSibling}function Yn(e,{shape:o,hash:n},r){let t=o.orig,i=o.piece?.role,s=o.piece?.color,u=o.piece?.scale,l=k("piece",`${i} ${s}`);return l.setAttribute("cgHash",n),l.cgKey=t,l.cgScale=u,ke(l,F(r)(f(t),v(e)),u),l}var Jn=e=>[e.orig,e.piece?.role,e.piece?.color,e.piece?.scale].join(",");function Jr({el:e,config:o}){return or(e,o)}function or(e,o){let n=Bo();we(n,o||{});function r(){let t="dom"in n?n.dom.unbind:void 0,i=Io(e,n),s=Je(()=>i.board.getBoundingClientRect()),u=c=>{Qo(a),i.autoPieces&&nn(a,i.autoPieces),!c&&i.shapes&&Lo(a,i)},l=()=>{Xe(a),Yo(a),i.autoPieces&&rn(a)},a=n;return a.dom={elements:i,bounds:s,redraw:nr(u),redrawNow:u,unbind:t},a.drawable.prevSvgHash="",Xe(a),u(!1),Zo(a,l),t||(a.dom.unbind=Xo(a,l)),a.events.insert&&a.events.insert(i),a}return To(r(),r)}function nr(e){let o=!1;return()=>{o||(o=!0,requestAnimationFrame(()=>{e(),o=!1}))}}export{or as Chessground,Jr as initModule};
|
package/dist/draw.d.ts
CHANGED
|
@@ -14,10 +14,11 @@ export interface DrawShape {
|
|
|
14
14
|
text: string;
|
|
15
15
|
fill?: string;
|
|
16
16
|
};
|
|
17
|
+
below?: boolean;
|
|
17
18
|
}
|
|
18
19
|
export interface DrawModifiers {
|
|
19
20
|
lineWidth?: number;
|
|
20
|
-
hilite?:
|
|
21
|
+
hilite?: string;
|
|
21
22
|
}
|
|
22
23
|
export interface DrawShapePiece {
|
|
23
24
|
role: cg.Role;
|
package/dist/draw.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"draw.js","sourceRoot":"","sources":["../src/draw.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,cAAc,EAAE,qBAAqB,EAAE,QAAQ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AK,GAAG,CAAC,IAAI,IAAI,CAAC,CAAC,IAAI,KAAK,GAAG,CAAC,IAAI,CAAC;IAC/E,MAAM,OAAO,GAAG,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAChD,IAAI,OAAO;QAAE,QAAQ,CAAC,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;IAC1E,IAAI,CAAC,OAAO,IAAI,OAAO,CAAC,KAAK,KAAK,GAAG,CAAC,KAAK;QACzC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC;YACnB,IAAI,EAAE,GAAG,CAAC,IAAI;YACd,IAAI,EAAE,GAAG,CAAC,IAAI;YACd,KAAK,EAAE,GAAG,CAAC,KAAK;SACjB,CAAC,CAAC;IACL,QAAQ,CAAC,QAAQ,CAAC,CAAC;AACrB,CAAC;AAED,SAAS,QAAQ,CAAC,QAAkB;IAClC,IAAI,QAAQ,CAAC,QAAQ;QAAE,QAAQ,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;AAC5D,CAAC"}
|
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;IAC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C,CAAC,EACnF,GAAG,GAAG,IAAI,CAAC,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/dist/state.js
CHANGED
|
@@ -83,6 +83,7 @@ export function defaults() {
|
|
|
83
83
|
purple: { key: 'purple', color: '#68217a', opacity: 0.65, lineWidth: 10 },
|
|
84
84
|
pink: { key: 'pink', color: '#ee2080', opacity: 0.5, lineWidth: 10 },
|
|
85
85
|
white: { key: 'white', color: 'white', opacity: 1, lineWidth: 10 },
|
|
86
|
+
paleWhite: { key: 'pwhite', color: 'white', opacity: 0.6, lineWidth: 10 },
|
|
86
87
|
},
|
|
87
88
|
prevSvgHash: '',
|
|
88
89
|
},
|
package/dist/state.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state.js","sourceRoot":"","sources":["../src/state.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC;AAIhC,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AA2GlC,MAAM,UAAU,QAAQ;IACtB,OAAO;QACL,MAAM,EAAE,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC;QAC7B,WAAW,EAAE,OAAO;QACpB,SAAS,EAAE,OAAO;QAClB,WAAW,EAAE,IAAI;QACjB,oBAAoB,EAAE,KAAK;QAC3B,aAAa,EAAE,OAAO;QACtB,UAAU,EAAE,IAAI;QAChB,QAAQ,EAAE,KAAK;QACf,kBAAkB,EAAE,KAAK;QACzB,cAAc,EAAE,KAAK;QACrB,gBAAgB,EAAE,KAAK;QACvB,QAAQ,EAAE,KAAK;QACf,cAAc,EAAE,KAAK;QACrB,SAAS,EAAE;YACT,QAAQ,EAAE,IAAI;YACd,KAAK,EAAE,IAAI;SACZ;QACD,SAAS,EAAE;YACT,OAAO,EAAE,IAAI;YACb,QAAQ,EAAE,GAAG;SACd;QACD,OAAO,EAAE;YACP,IAAI,EAAE,IAAI;YACV,KAAK,EAAE,MAAM;YACb,SAAS,EAAE,IAAI;YACf,MAAM,EAAE,EAAE;YACV,UAAU,EAAE,IAAI;SACjB;QACD,UAAU,EAAE;YACV,OAAO,EAAE,IAAI;YACb,SAAS,EAAE,IAAI;YACf,MAAM,EAAE,IAAI;YACZ,MAAM,EAAE,EAAE;SACX;QACD,YAAY,EAAE;YACZ,OAAO,EAAE,KAAK;YACd,MAAM,EAAE,EAAE;SACX;QACD,SAAS,EAAE;YACT,OAAO,EAAE,IAAI;YACb,QAAQ,EAAE,CAAC;YAC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B;QACD,IAAI,EAAE,KAAK,EAAE;KACd,CAAC;AACJ,CAAC"}
|
package/dist/svg.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { State } from './state.js';
|
|
2
|
+
import * as cg from './types.js';
|
|
2
3
|
export { createElement, setAttributes };
|
|
3
4
|
export declare function createDefs(): Element;
|
|
4
|
-
export declare function renderSvg(state: State,
|
|
5
|
+
export declare function renderSvg(state: State, els: cg.Elements): void;
|
|
5
6
|
declare function createElement(tagName: string): SVGElement;
|
|
6
7
|
declare function setAttributes(el: SVGElement, attrs: {
|
|
7
8
|
[key: string]: any;
|
package/dist/svg.js
CHANGED
|
@@ -1,17 +1,13 @@
|
|
|
1
1
|
import { key2pos } from './util.js';
|
|
2
|
-
const hilites = {
|
|
3
|
-
hilitePrimary: { key: 'hilitePrimary', color: '#3291ff', opacity: 1, lineWidth: 1 },
|
|
4
|
-
hiliteWhite: { key: 'hiliteWhite', color: '#ffffff', opacity: 1, lineWidth: 1 },
|
|
5
|
-
};
|
|
6
2
|
export { createElement, setAttributes };
|
|
7
3
|
export function createDefs() {
|
|
8
4
|
const defs = createElement('defs');
|
|
9
5
|
const filter = setAttributes(createElement('filter'), { id: 'cg-filter-blur' });
|
|
10
|
-
filter.appendChild(setAttributes(createElement('feGaussianBlur'), { stdDeviation: '0.
|
|
6
|
+
filter.appendChild(setAttributes(createElement('feGaussianBlur'), { stdDeviation: '0.013' }));
|
|
11
7
|
defs.appendChild(filter);
|
|
12
8
|
return defs;
|
|
13
9
|
}
|
|
14
|
-
export function renderSvg(state,
|
|
10
|
+
export function renderSvg(state, els) {
|
|
15
11
|
const d = state.drawable, curD = d.current, cur = curD && curD.mouseSq ? curD : undefined, dests = new Map(), bounds = state.dom.bounds(), nonPieceAutoShapes = d.autoShapes.filter(autoShape => !autoShape.piece);
|
|
16
12
|
for (const s of d.shapes.concat(nonPieceAutoShapes).concat(cur ? [cur] : [])) {
|
|
17
13
|
if (!s.dest)
|
|
@@ -20,13 +16,14 @@ export function renderSvg(state, shapesEl, customsEl) {
|
|
|
20
16
|
sources.add(moveAngle(from, to));
|
|
21
17
|
dests.set(s.dest, sources);
|
|
22
18
|
}
|
|
23
|
-
const shapes =
|
|
24
|
-
|
|
19
|
+
const shapes = [];
|
|
20
|
+
for (const s of d.shapes.concat(nonPieceAutoShapes)) {
|
|
21
|
+
shapes.push({
|
|
25
22
|
shape: s,
|
|
26
23
|
current: false,
|
|
27
24
|
hash: shapeHash(s, isShort(s.dest, dests), false, bounds),
|
|
28
|
-
};
|
|
29
|
-
}
|
|
25
|
+
});
|
|
26
|
+
}
|
|
30
27
|
if (cur)
|
|
31
28
|
shapes.push({
|
|
32
29
|
shape: cur,
|
|
@@ -37,76 +34,70 @@ export function renderSvg(state, shapesEl, customsEl) {
|
|
|
37
34
|
if (fullHash === state.drawable.prevSvgHash)
|
|
38
35
|
return;
|
|
39
36
|
state.drawable.prevSvgHash = fullHash;
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
<svg class="cg-shapes"> (<= svg)
|
|
43
|
-
<defs>
|
|
44
|
-
...(for brushes)...
|
|
45
|
-
</defs>
|
|
46
|
-
<g>
|
|
47
|
-
...(for arrows and circles)...
|
|
48
|
-
</g>
|
|
49
|
-
</svg>
|
|
50
|
-
<svg class="cg-custom-svgs"> (<= customSvg)
|
|
51
|
-
<g>
|
|
52
|
-
...(for custom svgs)...
|
|
53
|
-
</g>
|
|
54
|
-
</svg>
|
|
55
|
-
*/
|
|
56
|
-
const defsEl = shapesEl.querySelector('defs');
|
|
57
|
-
syncDefs(d, shapes, defsEl);
|
|
58
|
-
syncShapes(shapes, shapesEl.querySelector('g'), customsEl.querySelector('g'), s => renderShape(state, s, d.brushes, dests, bounds));
|
|
37
|
+
syncDefs(d, shapes, els);
|
|
38
|
+
syncShapes(shapes, els, s => renderShape(state, s, d.brushes, dests, bounds));
|
|
59
39
|
}
|
|
60
40
|
// append only. Don't try to update/remove.
|
|
61
|
-
function syncDefs(d, shapes,
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
brushes.
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
keysInDom
|
|
74
|
-
el =
|
|
75
|
-
}
|
|
76
|
-
for (const [key, brush] of brushes.entries()) {
|
|
77
|
-
if (!keysInDom.has(key))
|
|
78
|
-
defsEl.appendChild(renderMarker(brush));
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
function syncShapes(syncables, shapes, customs, renderShape) {
|
|
82
|
-
const hashesInDom = new Map();
|
|
83
|
-
for (const sc of syncables)
|
|
84
|
-
hashesInDom.set(sc.hash, false);
|
|
85
|
-
for (const root of [shapes, customs]) {
|
|
86
|
-
const toRemove = [];
|
|
87
|
-
let el = root.firstElementChild, elHash;
|
|
41
|
+
function syncDefs(d, shapes, els) {
|
|
42
|
+
for (const shapesEl of [els.shapes, els.shapesBelow]) {
|
|
43
|
+
const defsEl = shapesEl.querySelector('defs');
|
|
44
|
+
const thisPlane = shapes.filter(s => (shapesEl === els.shapesBelow) === !!s.shape.below);
|
|
45
|
+
const brushes = new Map();
|
|
46
|
+
for (const s of thisPlane.filter(s => s.shape.dest && s.shape.brush)) {
|
|
47
|
+
const brush = makeCustomBrush(d.brushes[s.shape.brush], s.shape.modifiers);
|
|
48
|
+
const { key, color } = hiliteOf(s.shape);
|
|
49
|
+
if (key && color)
|
|
50
|
+
brushes.set(key, { key, color, opacity: 1, lineWidth: 1 });
|
|
51
|
+
brushes.set(brush.key, brush);
|
|
52
|
+
}
|
|
53
|
+
const keysInDom = new Set();
|
|
54
|
+
let el = defsEl.firstElementChild;
|
|
88
55
|
while (el) {
|
|
89
|
-
|
|
90
|
-
if (hashesInDom.has(elHash))
|
|
91
|
-
hashesInDom.set(elHash, true);
|
|
92
|
-
else
|
|
93
|
-
toRemove.push(el);
|
|
56
|
+
keysInDom.add(el.getAttribute('cgKey'));
|
|
94
57
|
el = el.nextElementSibling;
|
|
95
58
|
}
|
|
96
|
-
for (const
|
|
97
|
-
|
|
59
|
+
for (const [key, brush] of brushes.entries()) {
|
|
60
|
+
if (!keysInDom.has(key))
|
|
61
|
+
defsEl.appendChild(renderMarker(brush));
|
|
62
|
+
}
|
|
98
63
|
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
64
|
+
}
|
|
65
|
+
function syncShapes(shapes, els, renderShape) {
|
|
66
|
+
for (const [shapesEl, customEl] of [
|
|
67
|
+
[els.shapes, els.custom],
|
|
68
|
+
[els.shapesBelow, els.customBelow],
|
|
69
|
+
]) {
|
|
70
|
+
const [shapesG, customG] = [shapesEl, customEl].map(el => el.querySelector('g'));
|
|
71
|
+
const thisPlane = shapes.filter(s => (shapesEl === els.shapesBelow) === !!s.shape.below);
|
|
72
|
+
const hashesInDom = new Map();
|
|
73
|
+
for (const sc of thisPlane)
|
|
74
|
+
hashesInDom.set(sc.hash, false);
|
|
75
|
+
for (const root of [shapesG, customG]) {
|
|
76
|
+
const toRemove = [];
|
|
77
|
+
let el = root.firstElementChild, elHash;
|
|
78
|
+
while (el) {
|
|
79
|
+
elHash = el.getAttribute('cgHash');
|
|
80
|
+
if (hashesInDom.has(elHash))
|
|
81
|
+
hashesInDom.set(elHash, true);
|
|
82
|
+
else
|
|
83
|
+
toRemove.push(el);
|
|
84
|
+
el = el.nextElementSibling;
|
|
85
|
+
}
|
|
86
|
+
for (const el of toRemove)
|
|
87
|
+
root.removeChild(el);
|
|
88
|
+
}
|
|
89
|
+
// insert shapes that are not yet in dom
|
|
90
|
+
for (const sc of thisPlane.filter(s => !hashesInDom.get(s.hash))) {
|
|
91
|
+
for (const svg of renderShape(sc)) {
|
|
92
|
+
if (svg.isCustom)
|
|
93
|
+
customG.appendChild(svg.el);
|
|
94
|
+
else
|
|
95
|
+
shapesG.appendChild(svg.el);
|
|
96
|
+
}
|
|
106
97
|
}
|
|
107
98
|
}
|
|
108
99
|
}
|
|
109
|
-
function shapeHash({ orig, dest, brush, piece, modifiers, customSvg, label }, shorten, current, bounds) {
|
|
100
|
+
function shapeHash({ orig, dest, brush, piece, modifiers, customSvg, label, below }, shorten, current, bounds) {
|
|
110
101
|
// a shape and an overlay svg share a lifetime and have the same cgHash attribute
|
|
111
102
|
return [
|
|
112
103
|
bounds.width,
|
|
@@ -120,6 +111,7 @@ function shapeHash({ orig, dest, brush, piece, modifiers, customSvg, label }, sh
|
|
|
120
111
|
modifiers && modifiersHash(modifiers),
|
|
121
112
|
customSvg && `custom-${textHash(customSvg.html)},${customSvg.center?.[0] ?? 'o'}`,
|
|
122
113
|
label && `label-${textHash(label.text)}`,
|
|
114
|
+
below && 'below',
|
|
123
115
|
]
|
|
124
116
|
.filter(x => x)
|
|
125
117
|
.join(',');
|
|
@@ -128,7 +120,7 @@ function pieceHash(piece) {
|
|
|
128
120
|
return [piece.color, piece.role, piece.scale].filter(x => x).join(',');
|
|
129
121
|
}
|
|
130
122
|
function modifiersHash(m) {
|
|
131
|
-
return [m.lineWidth, m.hilite
|
|
123
|
+
return [m.lineWidth, m.hilite].filter(x => x).join(',');
|
|
132
124
|
}
|
|
133
125
|
function textHash(s) {
|
|
134
126
|
// Rolling hash with base 31 (cf. https://stackoverflow.com/questions/7616461/generate-a-hash-from-string-in-javascript)
|
|
@@ -175,19 +167,15 @@ function renderCircle(brush, at, current, bounds) {
|
|
|
175
167
|
r: radius - widths[1] / 2,
|
|
176
168
|
});
|
|
177
169
|
}
|
|
178
|
-
function hilite(brush) {
|
|
179
|
-
return ['#ffffff', '#fff', 'white'].includes(brush.color)
|
|
180
|
-
? hilites['hilitePrimary']
|
|
181
|
-
: hilites['hiliteWhite'];
|
|
182
|
-
}
|
|
183
170
|
function renderArrow(s, brush, from, to, current, shorten) {
|
|
184
171
|
function renderLine(isHilite) {
|
|
185
172
|
const m = arrowMargin(shorten && !current), dx = to[0] - from[0], dy = to[1] - from[1], angle = Math.atan2(dy, dx), xo = Math.cos(angle) * m, yo = Math.sin(angle) * m;
|
|
173
|
+
const hilite = hiliteOf(s);
|
|
186
174
|
return setAttributes(createElement('line'), {
|
|
187
|
-
stroke: isHilite ? hilite
|
|
188
|
-
'stroke-width': lineWidth(brush, current)
|
|
175
|
+
stroke: isHilite ? hilite.color : brush.color,
|
|
176
|
+
'stroke-width': lineWidth(brush, current) * (isHilite ? 1.14 : 1),
|
|
189
177
|
'stroke-linecap': 'round',
|
|
190
|
-
'marker-end': `url(#arrowhead-${isHilite ? hilite
|
|
178
|
+
'marker-end': `url(#arrowhead-${isHilite ? hilite.key : brush.key})`,
|
|
191
179
|
opacity: s.modifiers?.hilite ? 1 : opacity(brush, current),
|
|
192
180
|
x1: from[0],
|
|
193
181
|
y1: from[1],
|
|
@@ -197,7 +185,7 @@ function renderArrow(s, brush, from, to, current, shorten) {
|
|
|
197
185
|
}
|
|
198
186
|
if (!s.modifiers?.hilite)
|
|
199
187
|
return renderLine(false);
|
|
200
|
-
const g = createElement('g');
|
|
188
|
+
const g = setAttributes(createElement('g'), { opacity: brush.opacity });
|
|
201
189
|
const blurred = setAttributes(createElement('g'), { filter: 'url(#cg-filter-blur)' });
|
|
202
190
|
blurred.appendChild(filterBox(from, to));
|
|
203
191
|
blurred.appendChild(renderLine(true));
|
|
@@ -278,6 +266,10 @@ function circleWidth() {
|
|
|
278
266
|
function lineWidth(brush, current) {
|
|
279
267
|
return ((brush.lineWidth || 10) * (current ? 0.85 : 1)) / 64;
|
|
280
268
|
}
|
|
269
|
+
function hiliteOf(shape) {
|
|
270
|
+
const hilite = shape.modifiers?.hilite;
|
|
271
|
+
return { key: hilite && `hilite-${hilite.replace('#', '')}`, color: hilite };
|
|
272
|
+
}
|
|
281
273
|
function opacity(brush, current) {
|
|
282
274
|
return (brush.opacity || 1) * (current ? 0.9 : 1);
|
|
283
275
|
}
|