@reactchessts/chess-ts
Version:
A modern React TypeScript chess development toolkit
176 lines (154 loc) • 43.9 kB
JavaScript
(function(A,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("react"),require("react-dom"),require("chess.js")):typeof define=="function"&&define.amd?define(["exports","react","react-dom","chess.js"],o):(A=typeof globalThis<"u"?globalThis:A||self,o(A.ChessTs={},A.React,A.ReactDOM,A.Chess))})(this,function(A,o,r0,n0){"use strict";var se={exports:{}},Z={};/**
* @license React
* react-jsx-runtime.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var ve;function o0(){if(ve)return Z;ve=1;var p=o,n=Symbol.for("react.element"),v=Symbol.for("react.fragment"),R=Object.prototype.hasOwnProperty,M=p.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,C={key:!0,ref:!0,__self:!0,__source:!0};function E(x,a,f){var g,F={},D=null,U=null;f!==void 0&&(D=""+f),a.key!==void 0&&(D=""+a.key),a.ref!==void 0&&(U=a.ref);for(g in a)R.call(a,g)&&!C.hasOwnProperty(g)&&(F[g]=a[g]);if(x&&x.defaultProps)for(g in a=x.defaultProps,a)F[g]===void 0&&(F[g]=a[g]);return{$$typeof:n,type:x,key:D,ref:U,props:F,_owner:M.current}}return Z.Fragment=v,Z.jsx=E,Z.jsxs=E,Z}var Q={};/**
* @license React
* react-jsx-runtime.development.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var ge;function s0(){return ge||(ge=1,process.env.NODE_ENV!=="production"&&function(){var p=o,n=Symbol.for("react.element"),v=Symbol.for("react.portal"),R=Symbol.for("react.fragment"),M=Symbol.for("react.strict_mode"),C=Symbol.for("react.profiler"),E=Symbol.for("react.provider"),x=Symbol.for("react.context"),a=Symbol.for("react.forward_ref"),f=Symbol.for("react.suspense"),g=Symbol.for("react.suspense_list"),F=Symbol.for("react.memo"),D=Symbol.for("react.lazy"),U=Symbol.for("react.offscreen"),I=Symbol.iterator,z="@@iterator";function m(e){if(e===null||typeof e!="object")return null;var t=I&&e[I]||e[z];return typeof t=="function"?t:null}var l=p.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function i(e){{for(var t=arguments.length,r=new Array(t>1?t-1:0),s=1;s<t;s++)r[s-1]=arguments[s];P("error",e,r)}}function P(e,t,r){{var s=l.ReactDebugCurrentFrame,h=s.getStackAddendum();h!==""&&(t+="%s",r=r.concat([h]));var y=r.map(function(u){return String(u)});y.unshift("Warning: "+t),Function.prototype.apply.call(console[e],console,y)}}var N=!1,q=!1,k=!1,d=!1,w=!1,_;_=Symbol.for("react.module.reference");function G(e){return!!(typeof e=="string"||typeof e=="function"||e===R||e===C||w||e===M||e===f||e===g||d||e===U||N||q||k||typeof e=="object"&&e!==null&&(e.$$typeof===D||e.$$typeof===F||e.$$typeof===E||e.$$typeof===x||e.$$typeof===a||e.$$typeof===_||e.getModuleId!==void 0))}function L(e,t,r){var s=e.displayName;if(s)return s;var h=t.displayName||t.name||"";return h!==""?r+"("+h+")":r}function O(e){return e.displayName||"Context"}function b(e){if(e==null)return null;if(typeof e.tag=="number"&&i("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case R:return"Fragment";case v:return"Portal";case C:return"Profiler";case M:return"StrictMode";case f:return"Suspense";case g:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case x:var t=e;return O(t)+".Consumer";case E:var r=e;return O(r._context)+".Provider";case a:return L(e,e.render,"ForwardRef");case F:var s=e.displayName||null;return s!==null?s:b(e.type)||"Memo";case D:{var h=e,y=h._payload,u=h._init;try{return b(u(y))}catch{return null}}}return null}var S=Object.assign,X=0,ee,Oe,Ae,Fe,Ie,Ue,Ge;function Ve(){}Ve.__reactDisabledLog=!0;function h0(){{if(X===0){ee=console.log,Oe=console.info,Ae=console.warn,Fe=console.error,Ie=console.group,Ue=console.groupCollapsed,Ge=console.groupEnd;var e={configurable:!0,enumerable:!0,value:Ve,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}X++}}function v0(){{if(X--,X===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:S({},e,{value:ee}),info:S({},e,{value:Oe}),warn:S({},e,{value:Ae}),error:S({},e,{value:Fe}),group:S({},e,{value:Ie}),groupCollapsed:S({},e,{value:Ue}),groupEnd:S({},e,{value:Ge})})}X<0&&i("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var ie=l.ReactCurrentDispatcher,le;function te(e,t,r){{if(le===void 0)try{throw Error()}catch(h){var s=h.stack.trim().match(/\n( *(at )?)/);le=s&&s[1]||""}return`
`+le+e}}var ce=!1,re;{var g0=typeof WeakMap=="function"?WeakMap:Map;re=new g0}function Ye(e,t){if(!e||ce)return"";{var r=re.get(e);if(r!==void 0)return r}var s;ce=!0;var h=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var y;y=ie.current,ie.current=null,h0();try{if(t){var u=function(){throw Error()};if(Object.defineProperty(u.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(u,[])}catch(W){s=W}Reflect.construct(e,[],u)}else{try{u.call()}catch(W){s=W}e.call(u.prototype)}}else{try{throw Error()}catch(W){s=W}e()}}catch(W){if(W&&s&&typeof W.stack=="string"){for(var c=W.stack.split(`
`),V=s.stack.split(`
`),T=c.length-1,j=V.length-1;T>=1&&j>=0&&c[T]!==V[j];)j--;for(;T>=1&&j>=0;T--,j--)if(c[T]!==V[j]){if(T!==1||j!==1)do if(T--,j--,j<0||c[T]!==V[j]){var B=`
`+c[T].replace(" at new "," at ");return e.displayName&&B.includes("<anonymous>")&&(B=B.replace("<anonymous>",e.displayName)),typeof e=="function"&&re.set(e,B),B}while(T>=1&&j>=0);break}}}finally{ce=!1,ie.current=y,v0(),Error.prepareStackTrace=h}var K=e?e.displayName||e.name:"",H=K?te(K):"";return typeof e=="function"&&re.set(e,H),H}function m0(e,t,r){return Ye(e,!1)}function w0(e){var t=e.prototype;return!!(t&&t.isReactComponent)}function ne(e,t,r){if(e==null)return"";if(typeof e=="function")return Ye(e,w0(e));if(typeof e=="string")return te(e);switch(e){case f:return te("Suspense");case g:return te("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case a:return m0(e.render);case F:return ne(e.type,t,r);case D:{var s=e,h=s._payload,y=s._init;try{return ne(y(h),t,r)}catch{}}}return""}var $=Object.prototype.hasOwnProperty,ze={},We=l.ReactDebugCurrentFrame;function oe(e){if(e){var t=e._owner,r=ne(e.type,e._source,t?t.type:null);We.setExtraStackFrame(r)}else We.setExtraStackFrame(null)}function y0(e,t,r,s,h){{var y=Function.call.bind($);for(var u in e)if(y(e,u)){var c=void 0;try{if(typeof e[u]!="function"){var V=Error((s||"React class")+": "+r+" type `"+u+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[u]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw V.name="Invariant Violation",V}c=e[u](t,u,s,r,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(T){c=T}c&&!(c instanceof Error)&&(oe(h),i("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",s||"React class",r,u,typeof c),oe(null)),c instanceof Error&&!(c.message in ze)&&(ze[c.message]=!0,oe(h),i("Failed %s type: %s",r,c.message),oe(null))}}}var C0=Array.isArray;function ue(e){return C0(e)}function k0(e){{var t=typeof Symbol=="function"&&Symbol.toStringTag,r=t&&e[Symbol.toStringTag]||e.constructor.name||"Object";return r}}function b0(e){try{return Ne(e),!1}catch{return!0}}function Ne(e){return""+e}function Be(e){if(b0(e))return i("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",k0(e)),Ne(e)}var Xe=l.ReactCurrentOwner,E0={key:!0,ref:!0,__self:!0,__source:!0},He,Je;function L0(e){if($.call(e,"ref")){var t=Object.getOwnPropertyDescriptor(e,"ref").get;if(t&&t.isReactWarning)return!1}return e.ref!==void 0}function x0(e){if($.call(e,"key")){var t=Object.getOwnPropertyDescriptor(e,"key").get;if(t&&t.isReactWarning)return!1}return e.key!==void 0}function S0(e,t){typeof e.ref=="string"&&Xe.current}function T0(e,t){{var r=function(){He||(He=!0,i("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",t))};r.isReactWarning=!0,Object.defineProperty(e,"key",{get:r,configurable:!0})}}function R0(e,t){{var r=function(){Je||(Je=!0,i("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",t))};r.isReactWarning=!0,Object.defineProperty(e,"ref",{get:r,configurable:!0})}}var M0=function(e,t,r,s,h,y,u){var c={$$typeof:n,type:e,key:t,ref:r,props:u,_owner:y};return c._store={},Object.defineProperty(c._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(c,"_self",{configurable:!1,enumerable:!1,writable:!1,value:s}),Object.defineProperty(c,"_source",{configurable:!1,enumerable:!1,writable:!1,value:h}),Object.freeze&&(Object.freeze(c.props),Object.freeze(c)),c};function P0(e,t,r,s,h){{var y,u={},c=null,V=null;r!==void 0&&(Be(r),c=""+r),x0(t)&&(Be(t.key),c=""+t.key),L0(t)&&(V=t.ref,S0(t,h));for(y in t)$.call(t,y)&&!E0.hasOwnProperty(y)&&(u[y]=t[y]);if(e&&e.defaultProps){var T=e.defaultProps;for(y in T)u[y]===void 0&&(u[y]=T[y])}if(c||V){var j=typeof e=="function"?e.displayName||e.name||"Unknown":e;c&&T0(u,j),V&&R0(u,j)}return M0(e,c,V,h,s,Xe.current,u)}}var fe=l.ReactCurrentOwner,Ke=l.ReactDebugCurrentFrame;function J(e){if(e){var t=e._owner,r=ne(e.type,e._source,t?t.type:null);Ke.setExtraStackFrame(r)}else Ke.setExtraStackFrame(null)}var de;de=!1;function pe(e){return typeof e=="object"&&e!==null&&e.$$typeof===n}function Ze(){{if(fe.current){var e=b(fe.current.type);if(e)return`
Check the render method of \``+e+"`."}return""}}function _0(e){return""}var Qe={};function j0(e){{var t=Ze();if(!t){var r=typeof e=="string"?e:e.displayName||e.name;r&&(t=`
Check the top-level render call using <`+r+">.")}return t}}function qe(e,t){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var r=j0(t);if(Qe[r])return;Qe[r]=!0;var s="";e&&e._owner&&e._owner!==fe.current&&(s=" It was passed a child from "+b(e._owner.type)+"."),J(e),i('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',r,s),J(null)}}function $e(e,t){{if(typeof e!="object")return;if(ue(e))for(var r=0;r<e.length;r++){var s=e[r];pe(s)&&qe(s,t)}else if(pe(e))e._store&&(e._store.validated=!0);else if(e){var h=m(e);if(typeof h=="function"&&h!==e.entries)for(var y=h.call(e),u;!(u=y.next()).done;)pe(u.value)&&qe(u.value,t)}}}function D0(e){{var t=e.type;if(t==null||typeof t=="string")return;var r;if(typeof t=="function")r=t.propTypes;else if(typeof t=="object"&&(t.$$typeof===a||t.$$typeof===F))r=t.propTypes;else return;if(r){var s=b(t);y0(r,e.props,"prop",s,e)}else if(t.PropTypes!==void 0&&!de){de=!0;var h=b(t);i("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",h||"Unknown")}typeof t.getDefaultProps=="function"&&!t.getDefaultProps.isReactClassApproved&&i("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function O0(e){{for(var t=Object.keys(e.props),r=0;r<t.length;r++){var s=t[r];if(s!=="children"&&s!=="key"){J(e),i("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",s),J(null);break}}e.ref!==null&&(J(e),i("Invalid attribute `ref` supplied to `React.Fragment`."),J(null))}}var e0={};function t0(e,t,r,s,h,y){{var u=G(e);if(!u){var c="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(c+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var V=_0();V?c+=V:c+=Ze();var T;e===null?T="null":ue(e)?T="array":e!==void 0&&e.$$typeof===n?(T="<"+(b(e.type)||"Unknown")+" />",c=" Did you accidentally export a JSX literal instead of a component?"):T=typeof e,i("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",T,c)}var j=P0(e,t,r,h,y);if(j==null)return j;if(u){var B=t.children;if(B!==void 0)if(s)if(ue(B)){for(var K=0;K<B.length;K++)$e(B[K],e);Object.freeze&&Object.freeze(B)}else i("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else $e(B,e)}if($.call(t,"key")){var H=b(e),W=Object.keys(t).filter(function(V0){return V0!=="key"}),he=W.length>0?"{key: someKey, "+W.join(": ..., ")+": ...}":"{key: someKey}";if(!e0[H+he]){var G0=W.length>0?"{"+W.join(": ..., ")+": ...}":"{}";i(`A props object containing a "key" prop is being spread into JSX:
let props = %s;
<%s {...props} />
React keys must be passed directly to JSX without using spread:
let props = %s;
<%s key={someKey} {...props} />`,he,H,G0,H),e0[H+he]=!0}}return e===R?O0(j):D0(j),j}}function A0(e,t,r){return t0(e,t,r,!0)}function F0(e,t,r){return t0(e,t,r,!1)}var I0=F0,U0=A0;Q.Fragment=R,Q.jsx=I0,Q.jsxs=U0}()),Q}process.env.NODE_ENV==="production"?se.exports=o0():se.exports=s0();var Y=se.exports;const a0={p:"pawn",n:"knight",b:"bishop",r:"rook",q:"queen",k:"king"},me="data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='UTF-8'%20standalone='no'?%3e%3c!DOCTYPE%20svg%20PUBLIC%20'-//W3C//DTD%20SVG%201.1//EN'%20'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg%20xmlns='http://www.w3.org/2000/svg'%20version='1.1'%20width='45'%20height='45'%3e%3cpath%20d='m%2022.5,9%20c%20-2.21,0%20-4,1.79%20-4,4%200,0.89%200.29,1.71%200.78,2.38%20C%2017.33,16.5%2016,18.59%2016,21%20c%200,2.03%200.94,3.84%202.41,5.03%20C%2015.41,27.09%2011,31.58%2011,39.5%20H%2034%20C%2034,31.58%2029.59,27.09%2026.59,26.03%2028.06,24.84%2029,23.03%2029,21%2029,18.59%2027.67,16.5%2025.72,15.38%2026.21,14.71%2026.5,13.89%2026.5,13%20c%200,-2.21%20-1.79,-4%20-4,-4%20z'%20style='opacity:1;%20fill:%23ffffff;%20fill-opacity:1;%20fill-rule:nonzero;%20stroke:%23000000;%20stroke-width:1.5;%20stroke-linecap:round;%20stroke-linejoin:miter;%20stroke-miterlimit:4;%20stroke-dasharray:none;%20stroke-opacity:1;'/%3e%3c/svg%3e",we="data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='UTF-8'%20standalone='no'?%3e%3c!DOCTYPE%20svg%20PUBLIC%20'-//W3C//DTD%20SVG%201.1//EN'%20'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg%20xmlns='http://www.w3.org/2000/svg'%20version='1.1'%20width='45'%20height='45'%3e%3cg%20style='opacity:1;%20fill:none;%20fill-opacity:1;%20fill-rule:evenodd;%20stroke:%23000000;%20stroke-width:1.5;%20stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;%20stroke-dasharray:none;%20stroke-opacity:1;'%20transform='translate(0,0.3)'%3e%3cpath%20d='M%2022,10%20C%2032.5,11%2038.5,18%2038,39%20L%2015,39%20C%2015,30%2025,32.5%2023,18'%20style='fill:%23ffffff;%20stroke:%23000000;'%20/%3e%3cpath%20d='M%2024,18%20C%2024.38,20.91%2018.45,25.37%2016,27%20C%2013,29%2013.18,31.34%2011,31%20C%209.958,30.06%2012.41,27.96%2011,28%20C%2010,28%2011.19,29.23%2010,30%20C%209,30%205.997,31%206,26%20C%206,24%2012,14%2012,14%20C%2012,14%2013.89,12.1%2014,10.5%20C%2013.27,9.506%2013.5,8.5%2013.5,7.5%20C%2014.5,6.5%2016.5,10%2016.5,10%20L%2018.5,10%20C%2018.5,10%2019.28,8.008%2021,7%20C%2022,7%2022,10%2022,10'%20style='fill:%23ffffff;%20stroke:%23000000;'%20/%3e%3cpath%20d='M%209.5%2025.5%20A%200.5%200.5%200%201%201%208.5,25.5%20A%200.5%200.5%200%201%201%209.5%2025.5%20z'%20style='fill:%23000000;%20stroke:%23000000;'%20/%3e%3cpath%20d='M%2015%2015.5%20A%200.5%201.5%200%201%201%2014,15.5%20A%200.5%201.5%200%201%201%2015%2015.5%20z'%20transform='matrix(0.866,0.5,-0.5,0.866,9.693,-5.173)'%20style='fill:%23000000;%20stroke:%23000000;'%20/%3e%3c/g%3e%3c/svg%3e",ye="data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='UTF-8'%20standalone='no'?%3e%3c!DOCTYPE%20svg%20PUBLIC%20'-//W3C//DTD%20SVG%201.1//EN'%20'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg%20xmlns='http://www.w3.org/2000/svg'%20version='1.1'%20width='45'%20height='45'%3e%3cg%20style='opacity:1;%20fill:none;%20fill-rule:evenodd;%20fill-opacity:1;%20stroke:%23000000;%20stroke-width:1.5;%20stroke-linecap:round;%20stroke-linejoin:round;%20stroke-miterlimit:4;%20stroke-dasharray:none;%20stroke-opacity:1;'%20transform='translate(0,0.6)'%3e%3cg%20style='fill:%23ffffff;%20stroke:%23000000;%20stroke-linecap:butt;'%3e%3cpath%20d='M%209,36%20C%2012.39,35.03%2019.11,36.43%2022.5,34%20C%2025.89,36.43%2032.61,35.03%2036,36%20C%2036,36%2037.65,36.54%2039,38%20C%2038.32,38.97%2037.35,38.99%2036,38.5%20C%2032.61,37.53%2025.89,38.96%2022.5,37.5%20C%2019.11,38.96%2012.39,37.53%209,38.5%20C%207.65,38.99%206.68,38.97%206,38%20C%207.35,36.54%209,36%209,36%20z'/%3e%3cpath%20d='M%2015,32%20C%2017.5,34.5%2027.5,34.5%2030,32%20C%2030.5,30.5%2030,30%2030,30%20C%2030,27.5%2027.5,26%2027.5,26%20C%2033,24.5%2033.5,14.5%2022.5,10.5%20C%2011.5,14.5%2012,24.5%2017.5,26%20C%2017.5,26%2015,27.5%2015,30%20C%2015,30%2014.5,30.5%2015,32%20z'/%3e%3cpath%20d='M%2025%208%20A%202.5%202.5%200%201%201%2020,8%20A%202.5%202.5%200%201%201%2025%208%20z'/%3e%3c/g%3e%3cpath%20d='M%2017.5,26%20L%2027.5,26%20M%2015,30%20L%2030,30%20M%2022.5,15.5%20L%2022.5,20.5%20M%2020,18%20L%2025,18'%20style='fill:none;%20stroke:%23000000;%20stroke-linejoin:miter;'/%3e%3c/g%3e%3c/svg%3e",Ce="data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='UTF-8'%20standalone='no'?%3e%3c!DOCTYPE%20svg%20PUBLIC%20'-//W3C//DTD%20SVG%201.1//EN'%20'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg%20xmlns='http://www.w3.org/2000/svg'%20version='1.1'%20width='45'%20height='45'%3e%3cg%20style='opacity:1;%20fill:%23ffffff;%20fill-opacity:1;%20fill-rule:evenodd;%20stroke:%23000000;%20stroke-width:1.5;%20stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;%20stroke-dasharray:none;%20stroke-opacity:1;'%20transform='translate(0,0.3)'%3e%3cpath%20d='M%209,39%20L%2036,39%20L%2036,36%20L%209,36%20L%209,39%20z%20'%20style='stroke-linecap:butt;'%20/%3e%3cpath%20d='M%2012,36%20L%2012,32%20L%2033,32%20L%2033,36%20L%2012,36%20z%20'%20style='stroke-linecap:butt;'%20/%3e%3cpath%20d='M%2011,14%20L%2011,9%20L%2015,9%20L%2015,11%20L%2020,11%20L%2020,9%20L%2025,9%20L%2025,11%20L%2030,11%20L%2030,9%20L%2034,9%20L%2034,14'%20style='stroke-linecap:butt;'%20/%3e%3cpath%20d='M%2034,14%20L%2031,17%20L%2014,17%20L%2011,14'%20/%3e%3cpath%20d='M%2031,17%20L%2031,29.5%20L%2014,29.5%20L%2014,17'%20style='stroke-linecap:butt;%20stroke-linejoin:miter;'%20/%3e%3cpath%20d='M%2031,29.5%20L%2032.5,32%20L%2012.5,32%20L%2014,29.5'%20/%3e%3cpath%20d='M%2011,14%20L%2034,14'%20style='fill:none;%20stroke:%23000000;%20stroke-linejoin:miter;'%20/%3e%3c/g%3e%3c/svg%3e",ke="data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='UTF-8'%20standalone='no'?%3e%3c!DOCTYPE%20svg%20PUBLIC%20'-//W3C//DTD%20SVG%201.1//EN'%20'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg%20xmlns='http://www.w3.org/2000/svg'%20version='1.1'%20width='45'%20height='45'%3e%3cg%20style='fill:%23ffffff;stroke:%23000000;stroke-width:1.5;stroke-linejoin:round'%3e%3cpath%20d='M%209,26%20C%2017.5,24.5%2030,24.5%2036,26%20L%2038.5,13.5%20L%2031,25%20L%2030.7,10.9%20L%2025.5,24.5%20L%2022.5,10%20L%2019.5,24.5%20L%2014.3,10.9%20L%2014,25%20L%206.5,13.5%20L%209,26%20z'/%3e%3cpath%20d='M%209,26%20C%209,28%2010.5,28%2011.5,30%20C%2012.5,31.5%2012.5,31%2012,33.5%20C%2010.5,34.5%2011,36%2011,36%20C%209.5,37.5%2011,38.5%2011,38.5%20C%2017.5,39.5%2027.5,39.5%2034,38.5%20C%2034,38.5%2035.5,37.5%2034,36%20C%2034,36%2034.5,34.5%2033,33.5%20C%2032.5,31%2032.5,31.5%2033.5,30%20C%2034.5,28%2036,28%2036,26%20C%2027.5,24.5%2017.5,24.5%209,26%20z'/%3e%3cpath%20d='M%2011.5,30%20C%2015,29%2030,29%2033.5,30'%20style='fill:none'/%3e%3cpath%20d='M%2012,33.5%20C%2018,32.5%2027,32.5%2033,33.5'%20style='fill:none'/%3e%3ccircle%20cx='6'%20cy='12'%20r='2'%20/%3e%3ccircle%20cx='14'%20cy='9'%20r='2'%20/%3e%3ccircle%20cx='22.5'%20cy='8'%20r='2'%20/%3e%3ccircle%20cx='31'%20cy='9'%20r='2'%20/%3e%3ccircle%20cx='39'%20cy='12'%20r='2'%20/%3e%3c/g%3e%3c/svg%3e",be="data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='UTF-8'%20standalone='no'?%3e%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='45'%20height='45'%3e%3cg%20fill='none'%20fill-rule='evenodd'%20stroke='%23000'%20stroke-linecap='round'%20stroke-linejoin='round'%20stroke-width='1.5'%3e%3cpath%20stroke-linejoin='miter'%20d='M22.5%2011.63V6M20%208h5'/%3e%3cpath%20fill='%23fff'%20stroke-linecap='butt'%20stroke-linejoin='miter'%20d='M22.5%2025s4.5-7.5%203-10.5c0%200-1-2.5-3-2.5s-3%202.5-3%202.5c-1.5%203%203%2010.5%203%2010.5'/%3e%3cpath%20fill='%23fff'%20d='M12.5%2037c5.5%203.5%2014.5%203.5%2020%200v-7s9-4.5%206-10.5c-4-6.5-13.5-3.5-16%204V27v-3.5c-2.5-7.5-12-10.5-16-4-3%206%206%2010.5%206%2010.5v7'/%3e%3cpath%20d='M12.5%2030c5.5-3%2014.5-3%2020%200m-20%203.5c5.5-3%2014.5-3%2020%200m-20%203.5c5.5-3%2014.5-3%2020%200'/%3e%3c/g%3e%3c/svg%3e",Ee="data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='UTF-8'%20standalone='no'?%3e%3c!DOCTYPE%20svg%20PUBLIC%20'-//W3C//DTD%20SVG%201.1//EN'%20'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg%20xmlns='http://www.w3.org/2000/svg'%20version='1.1'%20width='45'%20height='45'%3e%3cpath%20d='m%2022.5,9%20c%20-2.21,0%20-4,1.79%20-4,4%200,0.89%200.29,1.71%200.78,2.38%20C%2017.33,16.5%2016,18.59%2016,21%20c%200,2.03%200.94,3.84%202.41,5.03%20C%2015.41,27.09%2011,31.58%2011,39.5%20H%2034%20C%2034,31.58%2029.59,27.09%2026.59,26.03%2028.06,24.84%2029,23.03%2029,21%2029,18.59%2027.67,16.5%2025.72,15.38%2026.21,14.71%2026.5,13.89%2026.5,13%20c%200,-2.21%20-1.79,-4%20-4,-4%20z'%20style='opacity:1;%20fill:%23000000;%20fill-opacity:1;%20fill-rule:nonzero;%20stroke:%23000000;%20stroke-width:1.5;%20stroke-linecap:round;%20stroke-linejoin:miter;%20stroke-miterlimit:4;%20stroke-dasharray:none;%20stroke-opacity:1;'/%3e%3c/svg%3e",Le="data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='UTF-8'%20standalone='no'?%3e%3c!DOCTYPE%20svg%20PUBLIC%20'-//W3C//DTD%20SVG%201.1//EN'%20'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg%20xmlns='http://www.w3.org/2000/svg'%20version='1.1'%20width='45'%20height='45'%3e%3cg%20style='opacity:1;%20fill:none;%20fill-opacity:1;%20fill-rule:evenodd;%20stroke:%23000000;%20stroke-width:1.5;%20stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;%20stroke-dasharray:none;%20stroke-opacity:1;'%20transform='translate(0,0.3)'%3e%3cpath%20d='M%2022,10%20C%2032.5,11%2038.5,18%2038,39%20L%2015,39%20C%2015,30%2025,32.5%2023,18'%20style='fill:%23000000;%20stroke:%23000000;'%20/%3e%3cpath%20d='M%2024,18%20C%2024.38,20.91%2018.45,25.37%2016,27%20C%2013,29%2013.18,31.34%2011,31%20C%209.958,30.06%2012.41,27.96%2011,28%20C%2010,28%2011.19,29.23%2010,30%20C%209,30%205.997,31%206,26%20C%206,24%2012,14%2012,14%20C%2012,14%2013.89,12.1%2014,10.5%20C%2013.27,9.506%2013.5,8.5%2013.5,7.5%20C%2014.5,6.5%2016.5,10%2016.5,10%20L%2018.5,10%20C%2018.5,10%2019.28,8.008%2021,7%20C%2022,7%2022,10%2022,10'%20style='fill:%23000000;%20stroke:%23000000;'%20/%3e%3cpath%20d='M%209.5%2025.5%20A%200.5%200.5%200%201%201%208.5,25.5%20A%200.5%200.5%200%201%201%209.5%2025.5%20z'%20style='fill:%23ffffff;%20stroke:%23ffffff;'%20/%3e%3cpath%20d='M%2015%2015.5%20A%200.5%201.5%200%201%201%2014,15.5%20A%200.5%201.5%200%201%201%2015%2015.5%20z'%20transform='matrix(0.866,0.5,-0.5,0.866,9.693,-5.173)'%20style='fill:%23ffffff;%20stroke:%23ffffff;'%20/%3e%3cpath%20d='M%2024.55,10.4%20L%2024.1,11.85%20L%2024.6,12%20C%2027.75,13%2030.25,14.49%2032.5,18.75%20C%2034.75,23.01%2035.75,29.06%2035.25,39%20L%2035.2,39.5%20L%2037.45,39.5%20L%2037.5,39%20C%2038,28.94%2036.62,22.15%2034.25,17.66%20C%2031.88,13.17%2028.46,11.02%2025.06,10.5%20L%2024.55,10.4%20z%20'%20style='fill:%23ffffff;%20stroke:none;'%20/%3e%3c/g%3e%3c/svg%3e",xe="data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='UTF-8'%20standalone='no'?%3e%3c!DOCTYPE%20svg%20PUBLIC%20'-//W3C//DTD%20SVG%201.1//EN'%20'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg%20xmlns='http://www.w3.org/2000/svg'%20version='1.1'%20width='45'%20height='45'%3e%3cg%20style='opacity:1;%20fill:none;%20fill-rule:evenodd;%20fill-opacity:1;%20stroke:%23000000;%20stroke-width:1.5;%20stroke-linecap:round;%20stroke-linejoin:round;%20stroke-miterlimit:4;%20stroke-dasharray:none;%20stroke-opacity:1;'%20transform='translate(0,0.6)'%3e%3cg%20style='fill:%23000000;%20stroke:%23000000;%20stroke-linecap:butt;'%3e%3cpath%20d='M%209,36%20C%2012.39,35.03%2019.11,36.43%2022.5,34%20C%2025.89,36.43%2032.61,35.03%2036,36%20C%2036,36%2037.65,36.54%2039,38%20C%2038.32,38.97%2037.35,38.99%2036,38.5%20C%2032.61,37.53%2025.89,38.96%2022.5,37.5%20C%2019.11,38.96%2012.39,37.53%209,38.5%20C%207.65,38.99%206.68,38.97%206,38%20C%207.35,36.54%209,36%209,36%20z'/%3e%3cpath%20d='M%2015,32%20C%2017.5,34.5%2027.5,34.5%2030,32%20C%2030.5,30.5%2030,30%2030,30%20C%2030,27.5%2027.5,26%2027.5,26%20C%2033,24.5%2033.5,14.5%2022.5,10.5%20C%2011.5,14.5%2012,24.5%2017.5,26%20C%2017.5,26%2015,27.5%2015,30%20C%2015,30%2014.5,30.5%2015,32%20z'/%3e%3cpath%20d='M%2025%208%20A%202.5%202.5%200%201%201%2020,8%20A%202.5%202.5%200%201%201%2025%208%20z'/%3e%3c/g%3e%3cpath%20d='M%2017.5,26%20L%2027.5,26%20M%2015,30%20L%2030,30%20M%2022.5,15.5%20L%2022.5,20.5%20M%2020,18%20L%2025,18'%20style='fill:none;%20stroke:%23ffffff;%20stroke-linejoin:miter;'/%3e%3c/g%3e%3c/svg%3e",Se="data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='UTF-8'%20standalone='no'?%3e%3c!DOCTYPE%20svg%20PUBLIC%20'-//W3C//DTD%20SVG%201.1//EN'%20'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg%20xmlns='http://www.w3.org/2000/svg'%20version='1.1'%20width='45'%20height='45'%3e%3cg%20style='opacity:1;%20fill:%23000000;%20fill-opacity:1;%20fill-rule:evenodd;%20stroke:%23000000;%20stroke-width:1.5;%20stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;%20stroke-dasharray:none;%20stroke-opacity:1;'%20transform='translate(0,0.3)'%3e%3cpath%20d='M%209,39%20L%2036,39%20L%2036,36%20L%209,36%20L%209,39%20z%20'%20style='stroke-linecap:butt;'%20/%3e%3cpath%20d='M%2012.5,32%20L%2014,29.5%20L%2031,29.5%20L%2032.5,32%20L%2012.5,32%20z%20'%20style='stroke-linecap:butt;'%20/%3e%3cpath%20d='M%2012,36%20L%2012,32%20L%2033,32%20L%2033,36%20L%2012,36%20z%20'%20style='stroke-linecap:butt;'%20/%3e%3cpath%20d='M%2014,29.5%20L%2014,16.5%20L%2031,16.5%20L%2031,29.5%20L%2014,29.5%20z%20'%20style='stroke-linecap:butt;stroke-linejoin:miter;'%20/%3e%3cpath%20d='M%2014,16.5%20L%2011,14%20L%2034,14%20L%2031,16.5%20L%2014,16.5%20z%20'%20style='stroke-linecap:butt;'%20/%3e%3cpath%20d='M%2011,14%20L%2011,9%20L%2015,9%20L%2015,11%20L%2020,11%20L%2020,9%20L%2025,9%20L%2025,11%20L%2030,11%20L%2030,9%20L%2034,9%20L%2034,14%20L%2011,14%20z%20'%20style='stroke-linecap:butt;'%20/%3e%3cpath%20d='M%2012,35.5%20L%2033,35.5%20L%2033,35.5'%20style='fill:none;%20stroke:%23ffffff;%20stroke-width:1;%20stroke-linejoin:miter;'%20/%3e%3cpath%20d='M%2013,31.5%20L%2032,31.5'%20style='fill:none;%20stroke:%23ffffff;%20stroke-width:1;%20stroke-linejoin:miter;'%20/%3e%3cpath%20d='M%2014,29.5%20L%2031,29.5'%20style='fill:none;%20stroke:%23ffffff;%20stroke-width:1;%20stroke-linejoin:miter;'%20/%3e%3cpath%20d='M%2014,16.5%20L%2031,16.5'%20style='fill:none;%20stroke:%23ffffff;%20stroke-width:1;%20stroke-linejoin:miter;'%20/%3e%3cpath%20d='M%2011,14%20L%2034,14'%20style='fill:none;%20stroke:%23ffffff;%20stroke-width:1;%20stroke-linejoin:miter;'%20/%3e%3c/g%3e%3c/svg%3e",Te="data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='UTF-8'%20standalone='no'?%3e%3c!DOCTYPE%20svg%20PUBLIC%20'-//W3C//DTD%20SVG%201.1//EN'%20'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg%20xmlns='http://www.w3.org/2000/svg'%20version='1.1'%20width='45'%20height='45'%3e%3cg%20style='fill:%23000000;stroke:%23000000;stroke-width:1.5;stroke-linejoin:round'%3e%3cpath%20d='M%209,26%20C%2017.5,24.5%2030,24.5%2036,26%20L%2038.5,13.5%20L%2031,25%20L%2030.7,10.9%20L%2025.5,24.5%20L%2022.5,10%20L%2019.5,24.5%20L%2014.3,10.9%20L%2014,25%20L%206.5,13.5%20L%209,26%20z'/%3e%3cpath%20d='m%209,26%20c%200,2%201.5,2%202.5,4%201,1.5%201,1%200.5,3.5%20-1.5,1%20-1,2.5%20-1,2.5%20-1.5,1.5%200,2.5%200,2.5%206.5,1%2016.5,1%2023,0%200,0%201.5,-1%200,-2.5%200,0%200.5,-1.5%20-1,-2.5%20-0.5,-2.5%20-0.5,-2%200.5,-3.5%201,-2%202.5,-2%202.5,-4%20-8.5,-1.5%20-18.5,-1.5%20-27,0%20z'/%3e%3cpath%20d='M%2011.5,30%20C%2015,29%2030,29%2033.5,30'%20style='fill:none'/%3e%3cpath%20d='m%2012,33.5%20c%206,-1%2015,-1%2021,0'%20style='fill:none'/%3e%3ccircle%20cx='6'%20cy='12'%20r='2'/%3e%3ccircle%20cx='14'%20cy='9'%20r='2'/%3e%3ccircle%20cx='22.5'%20cy='8'%20r='2'/%3e%3ccircle%20cx='31'%20cy='9'%20r='2'/%3e%3ccircle%20cx='39'%20cy='12'%20r='2'/%3e%3cpath%20d='M%2011,38.5%20A%2035,35%201%200%200%2034,38.5'%20style='fill:none'/%3e%3cg%20style='fill:none;stroke:%23ffffff'%3e%3cpath%20d='M%2011,29%20A%2035,35%201%200%201%2034,29'/%3e%3cpath%20d='M%2012.5,31.5%20L%2032.5,31.5'/%3e%3cpath%20d='M%2011.5,34.5%20A%2035,35%201%200%200%2033.5,34.5'/%3e%3cpath%20d='M%2010.5,37.5%20A%2035,35%201%200%200%2034.5,37.5'/%3e%3c/g%3e%3c/g%3e%3c/svg%3e",Re="data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='UTF-8'%20standalone='no'?%3e%3c!DOCTYPE%20svg%20PUBLIC%20'-//W3C//DTD%20SVG%201.1//EN'%20'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg%20xmlns='http://www.w3.org/2000/svg'%20version='1.1'%20width='45'%20height='45'%3e%3cg%20style='fill:none;%20fill-opacity:1;%20fill-rule:evenodd;%20stroke:%23000000;%20stroke-width:1.5;%20stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;%20stroke-dasharray:none;%20stroke-opacity:1;'%3e%3cpath%20d='M%2022.5,11.63%20L%2022.5,6'%20style='fill:none;%20stroke:%23000000;%20stroke-linejoin:miter;'%20id='path6570'/%3e%3cpath%20d='M%2022.5,25%20C%2022.5,25%2027,17.5%2025.5,14.5%20C%2025.5,14.5%2024.5,12%2022.5,12%20C%2020.5,12%2019.5,14.5%2019.5,14.5%20C%2018,17.5%2022.5,25%2022.5,25'%20style='fill:%23000000;fill-opacity:1;%20stroke-linecap:butt;%20stroke-linejoin:miter;'/%3e%3cpath%20d='M%2012.5,37%20C%2018,40.5%2027,40.5%2032.5,37%20L%2032.5,30%20C%2032.5,30%2041.5,25.5%2038.5,19.5%20C%2034.5,13%2025,16%2022.5,23.5%20L%2022.5,27%20L%2022.5,23.5%20C%2020,16%2010.5,13%206.5,19.5%20C%203.5,25.5%2012.5,30%2012.5,30%20L%2012.5,37'%20style='fill:%23000000;%20stroke:%23000000;'/%3e%3cpath%20d='M%2020,8%20L%2025,8'%20style='fill:none;%20stroke:%23000000;%20stroke-linejoin:miter;'/%3e%3cpath%20d='M%2032,29.5%20C%2032,29.5%2040.5,25.5%2038.03,19.85%20C%2034.15,14%2025,18%2022.5,24.5%20L%2022.5,26.6%20L%2022.5,24.5%20C%2020,18%2010.85,14%206.97,19.85%20C%204.5,25.5%2013,29.5%2013,29.5'%20style='fill:none;%20stroke:%23ffffff;'/%3e%3cpath%20d='M%2012.5,30%20C%2018,27%2027,27%2032.5,30%20M%2012.5,33.5%20C%2018,30.5%2027,30.5%2032.5,33.5%20M%2012.5,37%20C%2018,34%2027,34%2032.5,37'%20style='fill:none;%20stroke:%23ffffff;'/%3e%3c/g%3e%3c/svg%3e",Me={wp:me,wn:we,wb:ye,wr:Ce,wq:ke,wk:be,bp:Ee,bn:Le,bb:xe,br:Se,bq:Te,bk:Re},Pe=o.createContext({currentTheme:"default",themes:{},loadTheme:async()=>{},getPieceSvg:()=>null}),_e=()=>o.useContext(Pe),i0=({children:p,defaultTheme:n="default"})=>{const[v,R]=o.useState({}),[M,C]=o.useState(n),E=async a=>{if(!v[a])try{console.log("Loading theme:",a),console.log("SVG imports:",{wp:me,wn:we,wb:ye,wr:Ce,wq:ke,wk:be,bp:Ee,bn:Le,bb:xe,br:Se,bq:Te,bk:Re});const f={name:a,pieces:Me};console.log("Theme loaded:",f),R(g=>({...g,[a]:f})),C(a)}catch(f){console.error(`Failed to load theme: ${a}`,f)}},x=a=>Me[a]||null;return o.useEffect(()=>{E(n)},[n]),Y.jsx(Pe.Provider,{value:{currentTheme:M,themes:v,loadTheme:E,getPieceSvg:x},children:p})},ae=o.memo(({piece:p,square:n,isDragging:v,_theme:R="default"})=>{var z,m;const{getPieceSvg:M}=_e(),C=M(p),E=o.useRef(null),[x,a]=o.useState(null),f=o.useRef(null),g=a0[p[1]],F=p[0]==="w"?"white":"black",D=`${F} ${g} on ${n}`,U=o.useCallback(l=>{if(!v||!f.current)return;const{x:i,y:P,rect:N}=f.current,q=l.pageX-i,k=l.pageY-P;a({x:N.left+window.scrollX+q,y:N.top+window.scrollY+k})},[v]);o.useEffect(()=>{if(v&&E.current){const l=E.current.getBoundingClientRect();f.current={x:window.scrollX+l.left,y:window.scrollY+l.top,rect:l},a({x:window.scrollX+l.left,y:window.scrollY+l.top});const i=P=>{f.current&&(f.current.x=P.pageX,f.current.y=P.pageY,window.removeEventListener("mousemove",i))};window.addEventListener("mousemove",i,{once:!0}),window.addEventListener("mousemove",U)}else a(null);return()=>{window.removeEventListener("mousemove",U),f.current=null}},[v,U]);const I=o.useCallback(()=>C?Y.jsx("img",{src:C,alt:`${F} ${g}`,className:"piece-svg no-drag",style:{position:"absolute",inset:0,width:"100%",height:"100%",pointerEvents:"none",opacity:v?.8:1,filter:p.startsWith("b")?"brightness(0.2)":"none",userSelect:"none"}}):null,[C,v,p,F,g]);return Y.jsxs(Y.Fragment,{children:[Y.jsxs("div",{ref:E,className:`piece ${v?"dragging":""}`,"data-piece":p,"data-square":n,role:"piece","aria-label":D,style:{position:"absolute",inset:0,width:"100%",height:"100%",cursor:v?"grabbing":"grab",transition:v?"none":"transform 0.2s ease",pointerEvents:v?"none":"auto",touchAction:"none",willChange:"transform",transformOrigin:"center",zIndex:v?9999:1,opacity:v?0:1,backgroundColor:"transparent"},children:[!v&&I(),Y.jsx("span",{className:"visually-hidden",children:D})]}),v&&x&&r0.createPortal(Y.jsx("div",{className:"dragged-piece",style:{position:"fixed",left:0,top:0,width:(z=f.current)==null?void 0:z.rect.width,height:(m=f.current)==null?void 0:m.rect.height,transform:`translate(${x.x}px, ${x.y}px)`,zIndex:9999,pointerEvents:"none",willChange:"transform",backgroundColor:"transparent"},children:I()}),document.body),Y.jsx("style",{children:`
.piece-svg {
user-select: none;
-webkit-user-drag: none;
}
.chess-board {
position: relative;
}
.chess-board .square {
position: relative;
z-index: 1;
}
.piece {
position: absolute;
z-index: 2;
transform-origin: center;
background-color: transparent !important;
}
.piece.dragging {
z-index: 9999;
pointer-events: none;
}
.dragged-piece {
pointer-events: none;
transform-origin: center;
background-color: transparent !important;
}
.visually-hidden {
position: absolute;
width: 1px;
height: 1px;
padding: 0;
margin: -1px;
overflow: hidden;
clip: rect(0, 0, 0, 0);
white-space: nowrap;
border: 0;
}
.no-drag {
-webkit-user-drag: none;
-khtml-user-drag: none;
-moz-user-drag: none;
-o-user-drag: none;
user-drag: none;
}
`})]})});ae.displayName="Piece";const je=o.createContext(null),De=()=>{const p=o.useContext(je);if(!p)throw new Error("useChess must be used within a ChessProvider");return p},l0=({children:p})=>{const[n]=o.useState(()=>new n0.Chess),[v,R]=o.useState(n.fen()),[M,C]=o.useState([]),[E,x]=o.useState(new Map),a=o.useCallback(()=>{const m=n.fen();R(m),C(n.history({verbose:!0}).map(i=>i.san));const l=m.split(" ").slice(0,4).join(" ");x(i=>{const P=new Map(i);return P.set(l,(P.get(l)||0)+1),P})},[n]),f=o.useCallback(()=>{const m=n.fen().split(" ").slice(0,4).join(" ");return(E.get(m)||0)>=3},[n,E]),g=o.useCallback(()=>{const[,,,,m]=n.fen().split(" ");return parseInt(m)>=100},[n]),F=o.useCallback(()=>{const m=n.board().flat().filter(l=>l!==null);if(m.length<=3){if(m.length===2)return!0;if(m.length===3){const l=m.find(i=>(i==null?void 0:i.type)!=="k");return(l==null?void 0:l.type)==="b"||(l==null?void 0:l.type)==="n"}}return!1},[n]),D=o.useCallback(m=>{try{return n.moves({square:m,verbose:!1}).map(i=>{if(typeof i=="string"){if(i==="O-O"||i==="O-O-O"){const N=n.turn()==="w"?"1":"8";return i==="O-O"?`g${N}`:`c${N}`}const P=i.match(/[a-h][1-8]/);return P?P[0]:""}return""}).filter(Boolean)}catch(l){return console.error("Error getting possible moves:",l),[]}},[n]),U=o.useCallback((m,l)=>{try{const P=n.moves({square:m,verbose:!0}).find(N=>N.to===l);return P&&n.move(P)?(a(),!0):!1}catch(i){return console.error("Invalid move:",i),!1}},[n,a]),I=o.useCallback(()=>{const m=n.undo()!==null;return m&&a(),m},[n,a]),z=o.useCallback(()=>{n.reset(),x(new Map),a()},[n,a]);return o.useEffect(()=>{a()},[a]),Y.jsx(je.Provider,{value:{game:n,position:v,isCheck:n.isCheck(),isCheckmate:n.isCheckmate(),isStalemate:n.isStalemate(),isDraw:n.isDraw(),isThreefoldRepetition:f(),isFiftyMoveRule:g(),isInsufficientMaterial:F(),turn:n.turn(),history:M,makeMove:U,undo:I,reset:z,getPossibleMoves:D},children:p})},c0=(p,n)=>{const v=p.charCodeAt(0)-97,R=8-parseInt(p[1]);let M=v,C=R;switch(n){case"up":C--;break;case"down":C++;break;case"left":M--;break;case"right":M++;break}return M<0||M>7||C<0||C>7?null:`${String.fromCharCode(97+M)}${8-C}`},u0=({onPieceDrop:p,orientation:n="white",customSquareStyles:v={}})=>{const{position:R,makeMove:M,getPossibleMoves:C,turn:E}=De(),[x,a]=o.useState({piece:null,from:null,isDragging:!1}),[f,g]=o.useState(null),[F,D]=o.useState([]),U=o.useRef(null),I=o.useRef({handleMove:null,handleUp:null}),z=o.useMemo(()=>{console.log("Parsing position:",R);const[k]=R.split(" "),d=k.split("/"),w={};return d.forEach((_,G)=>{let L=0;for(let O=0;O<_.length;O++){const b=_[O];if(/\d/.test(b))L+=parseInt(b);else{const S=`${String.fromCharCode(97+L)}${8-G}`,X=b===b.toUpperCase()?"w":"b",ee=b.toLowerCase();w[S]=`${X}${ee}`,L++}}}),console.log("Parsed position map:",w),w},[R]),m=o.useCallback(k=>{if(!U.current)return null;const d=U.current.getBoundingClientRect(),w=k.clientX-d.left,_=k.clientY-d.top;if(w<0||w>d.width||_<0||_>d.height)return null;const G=Math.floor(w/d.width*8),L=Math.floor(_/d.height*8);return`${String.fromCharCode(97+(n==="white"?G:7-G))}${8-L}`},[n]),l=o.useCallback(()=>{I.current.handleMove&&window.removeEventListener("mousemove",I.current.handleMove),I.current.handleUp&&window.removeEventListener("mouseup",I.current.handleUp),I.current.handleMove=null,I.current.handleUp=null},[]);o.useEffect(()=>()=>l(),[l]);const i=o.useCallback((k,d)=>{const w=z[d];if(!w||E==="w"&&w.startsWith("b")||E==="b"&&w.startsWith("w"))return;k.preventDefault(),a({piece:w,from:d,isDragging:!0});const _=C(d);D(_);const G=O=>{if(O.preventDefault(),!U.current)return;document.querySelectorAll(".drop-target, .dragging-over").forEach(S=>{S.classList.remove("drop-target","dragging-over")});const b=m(O);if(b&&_.includes(b)){const S=document.querySelector(`[data-square="${b}"]`);S&&S.classList.add("drop-target","dragging-over")}},L=O=>{O.preventDefault(),document.querySelectorAll(".drop-target").forEach(S=>{S.classList.remove("drop-target")});const b=m(O);b&&b!==d&&_.includes(b)&&p&&p(d,b,w),a({piece:null,from:null,isDragging:!1}),D([]),l()};I.current.handleMove=G,I.current.handleUp=L,window.addEventListener("mousemove",G),window.addEventListener("mouseup",L)},[z,C,E,m,p,l]),P=o.useCallback((k,d)=>{if(k.stopPropagation(),!x.isDragging)if(f){if(d===f){g(null),D([]);return}C(f).includes(d)&&M(f,d)&&p&&p(f,d,z[f]),g(null),D([])}else if(z[d]){const w=z[d];(E==="w"&&w.startsWith("w")||E==="b"&&w.startsWith("b"))&&(g(d),D(C(d)))}else g(null),D([])},[f,M,p,z,C,E,x.isDragging]),N=o.useCallback(k=>{k.target===k.currentTarget&&g(null)},[]),q=o.useCallback((k,d)=>{if(k.key==="Enter"||k.key===" "){k.preventDefault();const w={stopPropagation:()=>{},target:k.target,currentTarget:k.currentTarget};P(w,d)}else if(k.key==="Escape")g(null);else{const w={ArrowUp:"up",ArrowDown:"down",ArrowLeft:"left",ArrowRight:"right"}[k.key];if(w){k.preventDefault();const _=c0(d,w);if(_){const G=document.querySelector(`[data-square="${_}"]`);G instanceof HTMLElement&&G.focus()}}}},[P]);return Y.jsxs("div",{ref:U,className:"chess-board",role:"grid","aria-label":"Chess board",onClick:N,children:[Array.from({length:64},(k,d)=>{const w=Math.floor(d/8),_=n==="white"?d%8:7-d%8,G=(w+_)%2===0,L=`${String.fromCharCode(97+_)}${8-w}`,O=z[L],b=F.includes(L);return Y.jsx("div",{className:`square ${G?"light":"dark"} ${f===L?"selected":""} ${b?"highlighted":""}`,"data-square":L,style:v[L],onMouseDown:S=>O&&i(S,L),onClick:S=>P(S,L),role:"gridcell","aria-label":`${G?"light":"dark"} square ${L}${O?` with ${O[0]==="w"?"white":"black"} piece`:""}`,tabIndex:0,onKeyDown:S=>q(S,L),children:Y.jsx("div",{className:"square-content",children:O&&Y.jsx(ae,{piece:O,square:L,isDragging:x.from===L})})},L)}),Y.jsx("style",{children:`
.chess-board {
display: grid;
grid-template-columns: repeat(8, 1fr);
aspect-ratio: 1;
background: #312E2B;
position: relative;
user-select: none;
width: 100%;
border: 4px solid #312E2B;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
touch-action: none;
}
.square {
position: relative;
width: 100%;
padding-top: 100%;
background-color: #EEEED2;
transition: background-color 0.2s ease;
cursor: pointer;
}
.square.dark {
background-color: #769656;
}
.square-content {
position: absolute;
inset: 0;
display: flex;
align-items: center;
justify-content: center;
background-color: inherit;
}
.square.selected {
box-shadow: inset 0 0 0 3px rgba(255, 255, 0, 0.5);
}
.square.drop-target {
box-shadow: inset 0 0 0 3px rgba(0, 255, 0, 0.5);
}
.square.drop-target.selected {
box-shadow: inset 0 0 0 3px rgba(255, 255, 0, 0.5),
inset 0 0 0 6px rgba(0, 255, 0, 0.5);
}
.square:focus {
outline: none;
box-shadow: inset 0 0 0 3px rgba(0, 128, 255, 0.5);
}
.square.selected:focus {
box-shadow: inset 0 0 0 3px rgba(255, 255, 0, 0.5),
0 0 0 3px rgba(0, 128, 255, 0.5);
}
.square::before {
content: attr(data-square);
position: absolute;
bottom: 2px;
left: 2px;
font-size: 8px;
opacity: 0.5;
color: ${n==="white"?"#769656":"#EEEED2"};
pointer-events: none;
z-index: 1;
}
.square:hover .square-content::after {
content: '';
position: absolute;
inset: 0;
background: rgba(255, 255, 255, 0.1);
pointer-events: none;
}
@media (hover: none) {
.square:hover .square-content::after {
display: none;
}
}
.square.highlighted::after {
content: '';
position: absolute;
inset: 0;
background: rgba(0, 255, 0, 0.2);
pointer-events: none;
z-index: 1;
}
`})]})},f0=(p="start")=>{const[n,v]=o.useState(p),[R,M]=o.useState({isCheck:!1,isCheckmate:!1,isStalemate:!1,turn:"white"});return{position:n,gameState:R,makeMove:(E,x)=>(console.log(`Moving from ${E} to ${x}`),!0)}},d0=(p,n,v,R)=>!0,p0=p=>"";A.ChessBoard=u0,A.ChessProvider=l0,A.Piece=ae,A.PieceProvider=i0,A.generateFEN=p0,A.isValidMove=d0,A.useChess=De,A.useChessGame=f0,A.usePieces=_e,Object.defineProperty(A,Symbol.toStringTag,{value:"Module"})});