@lichess-org/chessground 9.8.5 → 9.10.1

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