var mh=Object.defineProperty;var vh=(e,t,n)=>t in e?mh(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var ze=(e,t,n)=>(vh(e,typeof t!="symbol"?t+"":t,n),n);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const o of i)if(o.type==="childList")for(const s of o.addedNodes)s.tagName==="LINK"&&s.rel==="modulepreload"&&r(s)}).observe(document,{childList:!0,subtree:!0});function n(i){const o={};return i.integrity&&(o.integrity=i.integrity),i.referrerPolicy&&(o.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?o.credentials="include":i.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function r(i){if(i.ep)return;i.ep=!0;const o=n(i);fetch(i.href,o)}})();function uc(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var ac={exports:{}},so={},cc={exports:{}},b={};/** * @license React * react.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 Wr=Symbol.for("react.element"),yh=Symbol.for("react.portal"),Sh=Symbol.for("react.fragment"),wh=Symbol.for("react.strict_mode"),Ch=Symbol.for("react.profiler"),Eh=Symbol.for("react.provider"),kh=Symbol.for("react.context"),_h=Symbol.for("react.forward_ref"),xh=Symbol.for("react.suspense"),Oh=Symbol.for("react.memo"),Th=Symbol.for("react.lazy"),ku=Symbol.iterator;function Dh(e){return e===null||typeof e!="object"?null:(e=ku&&e[ku]||e["@@iterator"],typeof e=="function"?e:null)}var dc={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},fc=Object.assign,hc={};function Kn(e,t,n){this.props=e,this.context=t,this.refs=hc,this.updater=n||dc}Kn.prototype.isReactComponent={};Kn.prototype.setState=function(e,t){if(typeof e!="object"&&typeof e!="function"&&e!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")};Kn.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function pc(){}pc.prototype=Kn.prototype;function Cl(e,t,n){this.props=e,this.context=t,this.refs=hc,this.updater=n||dc}var El=Cl.prototype=new pc;El.constructor=Cl;fc(El,Kn.prototype);El.isPureReactComponent=!0;var _u=Array.isArray,gc=Object.prototype.hasOwnProperty,kl={current:null},mc={key:!0,ref:!0,__self:!0,__source:!0};function vc(e,t,n){var r,i={},o=null,s=null;if(t!=null)for(r in t.ref!==void 0&&(s=t.ref),t.key!==void 0&&(o=""+t.key),t)gc.call(t,r)&&!mc.hasOwnProperty(r)&&(i[r]=t[r]);var l=arguments.length-2;if(l===1)i.children=n;else if(1>>1,X=D[H];if(0>>1;Hi(ft,j))Gei(vn,ft)?(D[H]=vn,D[Ge]=j,H=Ge):(D[H]=ft,D[A]=j,H=A);else if(Gei(vn,j))D[H]=vn,D[Ge]=j,H=Ge;else break e}}return L}function i(D,L){var j=D.sortIndex-L.sortIndex;return j!==0?j:D.id-L.id}if(typeof performance=="object"&&typeof performance.now=="function"){var o=performance;e.unstable_now=function(){return o.now()}}else{var s=Date,l=s.now();e.unstable_now=function(){return s.now()-l}}var u=[],a=[],g=1,p=null,f=3,S=!1,m=!1,y=!1,C=typeof setTimeout=="function"?setTimeout:null,d=typeof clearTimeout=="function"?clearTimeout:null,c=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function h(D){for(var L=n(a);L!==null;){if(L.callback===null)r(a);else if(L.startTime<=D)r(a),L.sortIndex=L.expirationTime,t(u,L);else break;L=n(a)}}function w(D){if(y=!1,h(D),!m)if(n(u)!==null)m=!0,Ce(k);else{var L=n(a);L!==null&&dt(w,L.startTime-D)}}function k(D,L){m=!1,y&&(y=!1,d(T),T=-1),S=!0;var j=f;try{for(h(L),p=n(u);p!==null&&(!(p.expirationTime>L)||D&&!$());){var H=p.callback;if(typeof H=="function"){p.callback=null,f=p.priorityLevel;var X=H(p.expirationTime<=L);L=e.unstable_now(),typeof X=="function"?p.callback=X:p===n(u)&&r(u),h(L)}else r(u);p=n(u)}if(p!==null)var ot=!0;else{var A=n(a);A!==null&&dt(w,A.startTime-L),ot=!1}return ot}finally{p=null,f=j,S=!1}}var O=!1,x=null,T=-1,z=5,M=-1;function $(){return!(e.unstable_now()-MD||125H?(D.sortIndex=j,t(a,D),n(u)===null&&D===n(a)&&(y?(d(T),T=-1):y=!0,dt(w,j-H))):(D.sortIndex=X,t(u,D),m||S||(m=!0,Ce(k))),D},e.unstable_shouldYield=$,e.unstable_wrapCallback=function(D){var L=f;return function(){var j=f;f=L;try{return D.apply(this,arguments)}finally{f=j}}}})(Ec);Cc.exports=Ec;var Fh=Cc.exports;/** * @license React * react-dom.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 kc=E,je=Fh;function _(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Es=Object.prototype.hasOwnProperty,$h=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,Ou={},Tu={};function Uh(e){return Es.call(Tu,e)?!0:Es.call(Ou,e)?!1:$h.test(e)?Tu[e]=!0:(Ou[e]=!0,!1)}function Hh(e,t,n,r){if(n!==null&&n.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function Wh(e,t,n,r){if(t===null||typeof t>"u"||Hh(e,t,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!t;case 4:return t===!1;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function we(e,t,n,r,i,o,s){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=i,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=o,this.removeEmptyString=s}var ce={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){ce[e]=new we(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];ce[t]=new we(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){ce[e]=new we(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){ce[e]=new we(e,2,!1,e,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){ce[e]=new we(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){ce[e]=new we(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){ce[e]=new we(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){ce[e]=new we(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){ce[e]=new we(e,5,!1,e.toLowerCase(),null,!1,!1)});var xl=/[\-:]([a-z])/g;function Ol(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var t=e.replace(xl,Ol);ce[t]=new we(t,1,!1,e,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(xl,Ol);ce[t]=new we(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(xl,Ol);ce[t]=new we(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){ce[e]=new we(e,1,!1,e.toLowerCase(),null,!1,!1)});ce.xlinkHref=new we("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){ce[e]=new we(e,1,!1,e.toLowerCase(),null,!0,!0)});function Tl(e,t,n,r){var i=ce.hasOwnProperty(t)?ce[t]:null;(i!==null?i.type!==0:r||!(2l||i[s]!==o[l]){var u=` `+i[s].replace(" at new "," at ");return e.displayName&&u.includes("")&&(u=u.replace("",e.displayName)),u}while(1<=s&&0<=l);break}}}finally{$o=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?lr(e):""}function Bh(e){switch(e.tag){case 5:return lr(e.type);case 16:return lr("Lazy");case 13:return lr("Suspense");case 19:return lr("SuspenseList");case 0:case 2:case 15:return e=Uo(e.type,!1),e;case 11:return e=Uo(e.type.render,!1),e;case 1:return e=Uo(e.type,!0),e;default:return""}}function Os(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case En:return"Fragment";case Cn:return"Portal";case ks:return"Profiler";case Dl:return"StrictMode";case _s:return"Suspense";case xs:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case Oc:return(e.displayName||"Context")+".Consumer";case xc:return(e._context.displayName||"Context")+".Provider";case Pl:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case Ll:return t=e.displayName||null,t!==null?t:Os(e.type)||"Memo";case Lt:t=e._payload,e=e._init;try{return Os(e(t))}catch{}}return null}function Vh(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=t.render,e=e.displayName||e.name||"",t.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Os(t);case 8:return t===Dl?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t}return null}function Kt(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function Dc(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function Qh(e){var t=Dc(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var i=n.get,o=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return i.call(this)},set:function(s){r=""+s,o.call(this,s)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(s){r=""+s},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function ni(e){e._valueTracker||(e._valueTracker=Qh(e))}function Pc(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=Dc(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function Mi(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function Ts(e,t){var n=t.checked;return Y({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function Pu(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=Kt(t.value!=null?t.value:n),e._wrapperState={initialChecked:r,initialValue:n,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function Lc(e,t){t=t.checked,t!=null&&Tl(e,"checked",t,!1)}function Ds(e,t){Lc(e,t);var n=Kt(t.value),r=t.type;if(n!=null)r==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if(r==="submit"||r==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?Ps(e,t.type,n):t.hasOwnProperty("defaultValue")&&Ps(e,t.type,Kt(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function Lu(e,t,n){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var r=t.type;if(!(r!=="submit"&&r!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}n=e.name,n!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,n!==""&&(e.name=n)}function Ps(e,t,n){(t!=="number"||Mi(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var ur=Array.isArray;function jn(e,t,n,r){if(e=e.options,t){t={};for(var i=0;i"+t.valueOf().toString()+"",t=ri.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function _r(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var fr={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},Kh=["Webkit","ms","Moz","O"];Object.keys(fr).forEach(function(e){Kh.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),fr[t]=fr[e]})});function Rc(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||fr.hasOwnProperty(e)&&fr[e]?(""+t).trim():t+"px"}function Mc(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,i=Rc(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,i):e[n]=i}}var qh=Y({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function Ns(e,t){if(t){if(qh[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(_(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(_(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(_(61))}if(t.style!=null&&typeof t.style!="object")throw Error(_(62))}}function js(e,t){if(e.indexOf("-")===-1)return typeof t.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Rs=null;function Il(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Ms=null,Rn=null,Mn=null;function ju(e){if(e=Qr(e)){if(typeof Ms!="function")throw Error(_(280));var t=e.stateNode;t&&(t=fo(t),Ms(e.stateNode,e.type,t))}}function Ac(e){Rn?Mn?Mn.push(e):Mn=[e]:Rn=e}function bc(){if(Rn){var e=Rn,t=Mn;if(Mn=Rn=null,ju(e),t)for(e=0;e>>=0,e===0?32:31-(op(e)/sp|0)|0}var ii=64,oi=4194304;function ar(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function Fi(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,i=e.suspendedLanes,o=e.pingedLanes,s=n&268435455;if(s!==0){var l=s&~i;l!==0?r=ar(l):(o&=s,o!==0&&(r=ar(o)))}else s=n&~i,s!==0?r=ar(s):o!==0&&(r=ar(o));if(r===0)return 0;if(t!==0&&t!==r&&!(t&i)&&(i=r&-r,o=t&-t,i>=o||i===16&&(o&4194240)!==0))return t;if(r&4&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0n;n++)t.push(e);return t}function Br(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-nt(t),e[t]=n}function cp(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0=pr),Hu=String.fromCharCode(32),Wu=!1;function rd(e,t){switch(e){case"keyup":return zp.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function id(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var kn=!1;function $p(e,t){switch(e){case"compositionend":return id(t);case"keypress":return t.which!==32?null:(Wu=!0,Hu);case"textInput":return e=t.data,e===Hu&&Wu?null:e;default:return null}}function Up(e,t){if(kn)return e==="compositionend"||!Fl&&rd(e,t)?(e=td(),ki=Al=At=null,kn=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1=t)return{node:n,offset:t-e};e=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=Ku(n)}}function ud(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?ud(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function ad(){for(var e=window,t=Mi();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=Mi(e.document)}return t}function $l(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}function Yp(e){var t=ad(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&ud(n.ownerDocument.documentElement,n)){if(r!==null&&$l(n)){if(t=r.start,e=r.end,e===void 0&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var i=n.textContent.length,o=Math.min(r.start,i);r=r.end===void 0?o:Math.min(r.end,i),!e.extend&&o>r&&(i=r,r=o,o=i),i=qu(n,o);var s=qu(n,r);i&&s&&(e.rangeCount!==1||e.anchorNode!==i.node||e.anchorOffset!==i.offset||e.focusNode!==s.node||e.focusOffset!==s.offset)&&(t=t.createRange(),t.setStart(i.node,i.offset),e.removeAllRanges(),o>r?(e.addRange(t),e.extend(s.node,s.offset)):(t.setEnd(s.node,s.offset),e.addRange(t)))}}for(t=[],e=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n=document.documentMode,_n=null,Us=null,mr=null,Hs=!1;function Gu(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Hs||_n==null||_n!==Mi(r)||(r=_n,"selectionStart"in r&&$l(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),mr&&Lr(mr,r)||(mr=r,r=Hi(Us,"onSelect"),0Tn||(e.current=qs[Tn],qs[Tn]=null,Tn--)}function W(e,t){Tn++,qs[Tn]=e.current,e.current=t}var qt={},me=Yt(qt),xe=Yt(!1),un=qt;function $n(e,t){var n=e.type.contextTypes;if(!n)return qt;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var i={},o;for(o in n)i[o]=t[o];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=i),i}function Oe(e){return e=e.childContextTypes,e!=null}function Bi(){V(xe),V(me)}function na(e,t,n){if(me.current!==qt)throw Error(_(168));W(me,t),W(xe,n)}function yd(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var i in r)if(!(i in t))throw Error(_(108,Vh(e)||"Unknown",i));return Y({},n,r)}function Vi(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||qt,un=me.current,W(me,e),W(xe,xe.current),!0}function ra(e,t,n){var r=e.stateNode;if(!r)throw Error(_(169));n?(e=yd(e,t,un),r.__reactInternalMemoizedMergedChildContext=e,V(xe),V(me),W(me,e)):V(xe),W(xe,n)}var gt=null,ho=!1,ts=!1;function Sd(e){gt===null?gt=[e]:gt.push(e)}function u0(e){ho=!0,Sd(e)}function Xt(){if(!ts&>!==null){ts=!0;var e=0,t=U;try{var n=gt;for(U=1;e>=s,i-=s,mt=1<<32-nt(t)+i|n<T?(z=x,x=null):z=x.sibling;var M=f(d,x,h[T],w);if(M===null){x===null&&(x=z);break}e&&x&&M.alternate===null&&t(d,x),c=o(M,c,T),O===null?k=M:O.sibling=M,O=M,x=z}if(T===h.length)return n(d,x),Q&&Jt(d,T),k;if(x===null){for(;TT?(z=x,x=null):z=x.sibling;var $=f(d,x,M.value,w);if($===null){x===null&&(x=z);break}e&&x&&$.alternate===null&&t(d,x),c=o($,c,T),O===null?k=$:O.sibling=$,O=$,x=z}if(M.done)return n(d,x),Q&&Jt(d,T),k;if(x===null){for(;!M.done;T++,M=h.next())M=p(d,M.value,w),M!==null&&(c=o(M,c,T),O===null?k=M:O.sibling=M,O=M);return Q&&Jt(d,T),k}for(x=r(d,x);!M.done;T++,M=h.next())M=S(x,d,T,M.value,w),M!==null&&(e&&M.alternate!==null&&x.delete(M.key===null?T:M.key),c=o(M,c,T),O===null?k=M:O.sibling=M,O=M);return e&&x.forEach(function(K){return t(d,K)}),Q&&Jt(d,T),k}function C(d,c,h,w){if(typeof h=="object"&&h!==null&&h.type===En&&h.key===null&&(h=h.props.children),typeof h=="object"&&h!==null){switch(h.$$typeof){case ti:e:{for(var k=h.key,O=c;O!==null;){if(O.key===k){if(k=h.type,k===En){if(O.tag===7){n(d,O.sibling),c=i(O,h.props.children),c.return=d,d=c;break e}}else if(O.elementType===k||typeof k=="object"&&k!==null&&k.$$typeof===Lt&&ca(k)===O.type){n(d,O.sibling),c=i(O,h.props),c.ref=tr(d,O,h),c.return=d,d=c;break e}n(d,O);break}else t(d,O);O=O.sibling}h.type===En?(c=sn(h.props.children,d.mode,w,h.key),c.return=d,d=c):(w=Ii(h.type,h.key,h.props,null,d.mode,w),w.ref=tr(d,c,h),w.return=d,d=w)}return s(d);case Cn:e:{for(O=h.key;c!==null;){if(c.key===O)if(c.tag===4&&c.stateNode.containerInfo===h.containerInfo&&c.stateNode.implementation===h.implementation){n(d,c.sibling),c=i(c,h.children||[]),c.return=d,d=c;break e}else{n(d,c);break}else t(d,c);c=c.sibling}c=as(h,d.mode,w),c.return=d,d=c}return s(d);case Lt:return O=h._init,C(d,c,O(h._payload),w)}if(ur(h))return m(d,c,h,w);if(Yn(h))return y(d,c,h,w);fi(d,h)}return typeof h=="string"&&h!==""||typeof h=="number"?(h=""+h,c!==null&&c.tag===6?(n(d,c.sibling),c=i(c,h),c.return=d,d=c):(n(d,c),c=us(h,d.mode,w),c.return=d,d=c),s(d)):n(d,c)}return C}var Hn=Td(!0),Dd=Td(!1),Kr={},ct=Yt(Kr),Rr=Yt(Kr),Mr=Yt(Kr);function rn(e){if(e===Kr)throw Error(_(174));return e}function Gl(e,t){switch(W(Mr,t),W(Rr,e),W(ct,Kr),e=t.nodeType,e){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:Is(null,"");break;default:e=e===8?t.parentNode:t,t=e.namespaceURI||null,e=e.tagName,t=Is(t,e)}V(ct),W(ct,t)}function Wn(){V(ct),V(Rr),V(Mr)}function Pd(e){rn(Mr.current);var t=rn(ct.current),n=Is(t,e.type);t!==n&&(W(Rr,e),W(ct,n))}function Yl(e){Rr.current===e&&(V(ct),V(Rr))}var q=Yt(0);function Xi(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||n.data==="$?"||n.data==="$!"))return t}else if(t.tag===19&&t.memoizedProps.revealOrder!==void 0){if(t.flags&128)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var ns=[];function Xl(){for(var e=0;en?n:4,e(!0);var r=rs.transition;rs.transition={};try{e(!1),t()}finally{U=n,rs.transition=r}}function Vd(){return Ke().memoizedState}function f0(e,t,n){var r=Bt(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},Qd(e))Kd(t,n);else if(n=kd(e,t,n,r),n!==null){var i=ye();rt(n,e,r,i),qd(n,t,r)}}function h0(e,t,n){var r=Bt(e),i={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(Qd(e))Kd(t,i);else{var o=e.alternate;if(e.lanes===0&&(o===null||o.lanes===0)&&(o=t.lastRenderedReducer,o!==null))try{var s=t.lastRenderedState,l=o(s,n);if(i.hasEagerState=!0,i.eagerState=l,it(l,s)){var u=t.interleaved;u===null?(i.next=i,Kl(t)):(i.next=u.next,u.next=i),t.interleaved=i;return}}catch{}finally{}n=kd(e,t,i,r),n!==null&&(i=ye(),rt(n,e,r,i),qd(n,t,r))}}function Qd(e){var t=e.alternate;return e===G||t!==null&&t===G}function Kd(e,t){vr=Zi=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function qd(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,jl(e,n)}}var Ji={readContext:Qe,useCallback:fe,useContext:fe,useEffect:fe,useImperativeHandle:fe,useInsertionEffect:fe,useLayoutEffect:fe,useMemo:fe,useReducer:fe,useRef:fe,useState:fe,useDebugValue:fe,useDeferredValue:fe,useTransition:fe,useMutableSource:fe,useSyncExternalStore:fe,useId:fe,unstable_isNewReconciler:!1},p0={readContext:Qe,useCallback:function(e,t){return lt().memoizedState=[e,t===void 0?null:t],e},useContext:Qe,useEffect:fa,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,Ti(4194308,4,$d.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Ti(4194308,4,e,t)},useInsertionEffect:function(e,t){return Ti(4,2,e,t)},useMemo:function(e,t){var n=lt();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=lt();return t=n!==void 0?n(t):t,r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=f0.bind(null,G,e),[r.memoizedState,e]},useRef:function(e){var t=lt();return e={current:e},t.memoizedState=e},useState:da,useDebugValue:nu,useDeferredValue:function(e){return lt().memoizedState=e},useTransition:function(){var e=da(!1),t=e[0];return e=d0.bind(null,e[1]),lt().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=G,i=lt();if(Q){if(n===void 0)throw Error(_(407));n=n()}else{if(n=t(),le===null)throw Error(_(349));cn&30||Nd(r,t,n)}i.memoizedState=n;var o={value:n,getSnapshot:t};return i.queue=o,fa(Rd.bind(null,r,o,e),[e]),r.flags|=2048,zr(9,jd.bind(null,r,o,n,t),void 0,null),n},useId:function(){var e=lt(),t=le.identifierPrefix;if(Q){var n=vt,r=mt;n=(r&~(1<<32-nt(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=Ar++,0<\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=s.createElement(n,{is:r.is}):(e=s.createElement(n),n==="select"&&(s=e,r.multiple?s.multiple=!0:r.size&&(s.size=r.size))):e=s.createElementNS(e,n),e[ut]=t,e[jr]=r,rf(e,t,!1,!1),t.stateNode=e;e:{switch(s=js(n,r),n){case"dialog":B("cancel",e),B("close",e),i=r;break;case"iframe":case"object":case"embed":B("load",e),i=r;break;case"video":case"audio":for(i=0;iVn&&(t.flags|=128,r=!0,nr(o,!1),t.lanes=4194304)}else{if(!r)if(e=Xi(s),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),nr(o,!0),o.tail===null&&o.tailMode==="hidden"&&!s.alternate&&!Q)return he(t),null}else 2*J()-o.renderingStartTime>Vn&&n!==1073741824&&(t.flags|=128,r=!0,nr(o,!1),t.lanes=4194304);o.isBackwards?(s.sibling=t.child,t.child=s):(n=o.last,n!==null?n.sibling=s:t.child=s,o.last=s)}return o.tail!==null?(t=o.tail,o.rendering=t,o.tail=t.sibling,o.renderingStartTime=J(),t.sibling=null,n=q.current,W(q,r?n&1|2:n&1),t):(he(t),null);case 22:case 23:return uu(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?Le&1073741824&&(he(t),t.subtreeFlags&6&&(t.flags|=8192)):he(t),null;case 24:return null;case 25:return null}throw Error(_(156,t.tag))}function E0(e,t){switch(Hl(t),t.tag){case 1:return Oe(t.type)&&Bi(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Wn(),V(xe),V(me),Xl(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return Yl(t),null;case 13:if(V(q),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(_(340));Un()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return V(q),null;case 4:return Wn(),null;case 10:return Ql(t.type._context),null;case 22:case 23:return uu(),null;case 24:return null;default:return null}}var pi=!1,ge=!1,k0=typeof WeakSet=="function"?WeakSet:Set,P=null;function In(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){Z(e,t,r)}else n.current=null}function sl(e,t,n){try{n()}catch(r){Z(e,t,r)}}var Ca=!1;function _0(e,t){if(Ws=$i,e=ad(),$l(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var i=r.anchorOffset,o=r.focusNode;r=r.focusOffset;try{n.nodeType,o.nodeType}catch{n=null;break e}var s=0,l=-1,u=-1,a=0,g=0,p=e,f=null;t:for(;;){for(var S;p!==n||i!==0&&p.nodeType!==3||(l=s+i),p!==o||r!==0&&p.nodeType!==3||(u=s+r),p.nodeType===3&&(s+=p.nodeValue.length),(S=p.firstChild)!==null;)f=p,p=S;for(;;){if(p===e)break t;if(f===n&&++a===i&&(l=s),f===o&&++g===r&&(u=s),(S=p.nextSibling)!==null)break;p=f,f=p.parentNode}p=S}n=l===-1||u===-1?null:{start:l,end:u}}else n=null}n=n||{start:0,end:0}}else n=null;for(Bs={focusedElem:e,selectionRange:n},$i=!1,P=t;P!==null;)if(t=P,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,P=e;else for(;P!==null;){t=P;try{var m=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(m!==null){var y=m.memoizedProps,C=m.memoizedState,d=t.stateNode,c=d.getSnapshotBeforeUpdate(t.elementType===t.type?y:Je(t.type,y),C);d.__reactInternalSnapshotBeforeUpdate=c}break;case 3:var h=t.stateNode.containerInfo;h.nodeType===1?h.textContent="":h.nodeType===9&&h.documentElement&&h.removeChild(h.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(_(163))}}catch(w){Z(t,t.return,w)}if(e=t.sibling,e!==null){e.return=t.return,P=e;break}P=t.return}return m=Ca,Ca=!1,m}function yr(e,t,n){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var i=r=r.next;do{if((i.tag&e)===e){var o=i.destroy;i.destroy=void 0,o!==void 0&&sl(t,n,o)}i=i.next}while(i!==r)}}function mo(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function ll(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t=="function"?t(e):t.current=e}}function lf(e){var t=e.alternate;t!==null&&(e.alternate=null,lf(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[ut],delete t[jr],delete t[Ks],delete t[s0],delete t[l0])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function uf(e){return e.tag===5||e.tag===3||e.tag===4}function Ea(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||uf(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function ul(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=Wi));else if(r!==4&&(e=e.child,e!==null))for(ul(e,t,n),e=e.sibling;e!==null;)ul(e,t,n),e=e.sibling}function al(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(al(e,t,n),e=e.sibling;e!==null;)al(e,t,n),e=e.sibling}var ue=null,et=!1;function Tt(e,t,n){for(n=n.child;n!==null;)af(e,t,n),n=n.sibling}function af(e,t,n){if(at&&typeof at.onCommitFiberUnmount=="function")try{at.onCommitFiberUnmount(lo,n)}catch{}switch(n.tag){case 5:ge||In(n,t);case 6:var r=ue,i=et;ue=null,Tt(e,t,n),ue=r,et=i,ue!==null&&(et?(e=ue,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):ue.removeChild(n.stateNode));break;case 18:ue!==null&&(et?(e=ue,n=n.stateNode,e.nodeType===8?es(e.parentNode,n):e.nodeType===1&&es(e,n),Dr(e)):es(ue,n.stateNode));break;case 4:r=ue,i=et,ue=n.stateNode.containerInfo,et=!0,Tt(e,t,n),ue=r,et=i;break;case 0:case 11:case 14:case 15:if(!ge&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){i=r=r.next;do{var o=i,s=o.destroy;o=o.tag,s!==void 0&&(o&2||o&4)&&sl(n,t,s),i=i.next}while(i!==r)}Tt(e,t,n);break;case 1:if(!ge&&(In(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(l){Z(n,t,l)}Tt(e,t,n);break;case 21:Tt(e,t,n);break;case 22:n.mode&1?(ge=(r=ge)||n.memoizedState!==null,Tt(e,t,n),ge=r):Tt(e,t,n);break;default:Tt(e,t,n)}}function ka(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new k0),t.forEach(function(r){var i=j0.bind(null,e,r);n.has(r)||(n.add(r),r.then(i,i))})}}function Ze(e,t){var n=t.deletions;if(n!==null)for(var r=0;ri&&(i=s),r&=~o}if(r=i,r=J()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*O0(r/1960))-r,10e?16:e,bt===null)var r=!1;else{if(e=bt,bt=null,no=0,F&6)throw Error(_(331));var i=F;for(F|=4,P=e.current;P!==null;){var o=P,s=o.child;if(P.flags&16){var l=o.deletions;if(l!==null){for(var u=0;uJ()-su?on(e,0):ou|=n),Te(e,t)}function vf(e,t){t===0&&(e.mode&1?(t=oi,oi<<=1,!(oi&130023424)&&(oi=4194304)):t=1);var n=ye();e=Ct(e,t),e!==null&&(Br(e,t,n),Te(e,n))}function N0(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),vf(e,n)}function j0(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,i=e.memoizedState;i!==null&&(n=i.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(_(314))}r!==null&&r.delete(t),vf(e,n)}var yf;yf=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||xe.current)_e=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return _e=!1,w0(e,t,n);_e=!!(e.flags&131072)}else _e=!1,Q&&t.flags&1048576&&wd(t,Ki,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;Di(e,t),e=t.pendingProps;var i=$n(t,me.current);bn(t,n),i=Jl(null,t,r,e,i,n);var o=eu();return t.flags|=1,typeof i=="object"&&i!==null&&typeof i.render=="function"&&i.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,Oe(r)?(o=!0,Vi(t)):o=!1,t.memoizedState=i.state!==null&&i.state!==void 0?i.state:null,ql(t),i.updater=po,t.stateNode=i,i._reactInternals=t,Js(t,r,e,n),t=nl(null,t,r,!0,o,n)):(t.tag=0,Q&&o&&Ul(t),ve(null,t,i,n),t=t.child),t;case 16:r=t.elementType;e:{switch(Di(e,t),e=t.pendingProps,i=r._init,r=i(r._payload),t.type=r,i=t.tag=M0(r),e=Je(r,e),i){case 0:t=tl(null,t,r,e,n);break e;case 1:t=ya(null,t,r,e,n);break e;case 11:t=ma(null,t,r,e,n);break e;case 14:t=va(null,t,r,Je(r.type,e),n);break e}throw Error(_(306,r,""))}return t;case 0:return r=t.type,i=t.pendingProps,i=t.elementType===r?i:Je(r,i),tl(e,t,r,i,n);case 1:return r=t.type,i=t.pendingProps,i=t.elementType===r?i:Je(r,i),ya(e,t,r,i,n);case 3:e:{if(ef(t),e===null)throw Error(_(387));r=t.pendingProps,o=t.memoizedState,i=o.element,_d(e,t),Yi(t,r,null,n);var s=t.memoizedState;if(r=s.element,o.isDehydrated)if(o={element:r,isDehydrated:!1,cache:s.cache,pendingSuspenseBoundaries:s.pendingSuspenseBoundaries,transitions:s.transitions},t.updateQueue.baseState=o,t.memoizedState=o,t.flags&256){i=Bn(Error(_(423)),t),t=Sa(e,t,r,n,i);break e}else if(r!==i){i=Bn(Error(_(424)),t),t=Sa(e,t,r,n,i);break e}else for(Ie=Ut(t.stateNode.containerInfo.firstChild),Ne=t,Q=!0,tt=null,n=Dd(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(Un(),r===i){t=Et(e,t,n);break e}ve(e,t,r,n)}t=t.child}return t;case 5:return Pd(t),e===null&&Ys(t),r=t.type,i=t.pendingProps,o=e!==null?e.memoizedProps:null,s=i.children,Vs(r,i)?s=null:o!==null&&Vs(r,o)&&(t.flags|=32),Jd(e,t),ve(e,t,s,n),t.child;case 6:return e===null&&Ys(t),null;case 13:return tf(e,t,n);case 4:return Gl(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=Hn(t,null,r,n):ve(e,t,r,n),t.child;case 11:return r=t.type,i=t.pendingProps,i=t.elementType===r?i:Je(r,i),ma(e,t,r,i,n);case 7:return ve(e,t,t.pendingProps,n),t.child;case 8:return ve(e,t,t.pendingProps.children,n),t.child;case 12:return ve(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,i=t.pendingProps,o=t.memoizedProps,s=i.value,W(qi,r._currentValue),r._currentValue=s,o!==null)if(it(o.value,s)){if(o.children===i.children&&!xe.current){t=Et(e,t,n);break e}}else for(o=t.child,o!==null&&(o.return=t);o!==null;){var l=o.dependencies;if(l!==null){s=o.child;for(var u=l.firstContext;u!==null;){if(u.context===r){if(o.tag===1){u=yt(-1,n&-n),u.tag=2;var a=o.updateQueue;if(a!==null){a=a.shared;var g=a.pending;g===null?u.next=u:(u.next=g.next,g.next=u),a.pending=u}}o.lanes|=n,u=o.alternate,u!==null&&(u.lanes|=n),Xs(o.return,n,t),l.lanes|=n;break}u=u.next}}else if(o.tag===10)s=o.type===t.type?null:o.child;else if(o.tag===18){if(s=o.return,s===null)throw Error(_(341));s.lanes|=n,l=s.alternate,l!==null&&(l.lanes|=n),Xs(s,n,t),s=o.sibling}else s=o.child;if(s!==null)s.return=o;else for(s=o;s!==null;){if(s===t){s=null;break}if(o=s.sibling,o!==null){o.return=s.return,s=o;break}s=s.return}o=s}ve(e,t,i.children,n),t=t.child}return t;case 9:return i=t.type,r=t.pendingProps.children,bn(t,n),i=Qe(i),r=r(i),t.flags|=1,ve(e,t,r,n),t.child;case 14:return r=t.type,i=Je(r,t.pendingProps),i=Je(r.type,i),va(e,t,r,i,n);case 15:return Xd(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,i=t.pendingProps,i=t.elementType===r?i:Je(r,i),Di(e,t),t.tag=1,Oe(r)?(e=!0,Vi(t)):e=!1,bn(t,n),Od(t,r,i),Js(t,r,i,n),nl(null,t,r,!0,e,n);case 19:return nf(e,t,n);case 22:return Zd(e,t,n)}throw Error(_(156,t.tag))};function Sf(e,t){return Bc(e,t)}function R0(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Be(e,t,n,r){return new R0(e,t,n,r)}function cu(e){return e=e.prototype,!(!e||!e.isReactComponent)}function M0(e){if(typeof e=="function")return cu(e)?1:0;if(e!=null){if(e=e.$$typeof,e===Pl)return 11;if(e===Ll)return 14}return 2}function Vt(e,t){var n=e.alternate;return n===null?(n=Be(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function Ii(e,t,n,r,i,o){var s=2;if(r=e,typeof e=="function")cu(e)&&(s=1);else if(typeof e=="string")s=5;else e:switch(e){case En:return sn(n.children,i,o,t);case Dl:s=8,i|=8;break;case ks:return e=Be(12,n,t,i|2),e.elementType=ks,e.lanes=o,e;case _s:return e=Be(13,n,t,i),e.elementType=_s,e.lanes=o,e;case xs:return e=Be(19,n,t,i),e.elementType=xs,e.lanes=o,e;case Tc:return yo(n,i,o,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case xc:s=10;break e;case Oc:s=9;break e;case Pl:s=11;break e;case Ll:s=14;break e;case Lt:s=16,r=null;break e}throw Error(_(130,e==null?e:typeof e,""))}return t=Be(s,n,t,i),t.elementType=e,t.type=r,t.lanes=o,t}function sn(e,t,n,r){return e=Be(7,e,r,t),e.lanes=n,e}function yo(e,t,n,r){return e=Be(22,e,r,t),e.elementType=Tc,e.lanes=n,e.stateNode={isHidden:!1},e}function us(e,t,n){return e=Be(6,e,null,t),e.lanes=n,e}function as(e,t,n){return t=Be(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function A0(e,t,n,r,i){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Wo(0),this.expirationTimes=Wo(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Wo(0),this.identifierPrefix=r,this.onRecoverableError=i,this.mutableSourceEagerHydrationData=null}function du(e,t,n,r,i,o,s,l,u){return e=new A0(e,t,n,l,u),t===1?(t=1,o===!0&&(t|=8)):t=0,o=Be(3,null,null,t),e.current=o,o.stateNode=e,o.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},ql(o),e}function b0(e,t,n){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(kf)}catch(e){console.error(e)}}kf(),wc.exports=Re;var H0=wc.exports,Ia=H0;Cs.createRoot=Ia.createRoot,Cs.hydrateRoot=Ia.hydrateRoot;/** * @license * Copyright (c) 2023, Jeff Hlywa (jhlywa@gmail.com) * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */const pe="w",$e="b",oe="p",pl="n",Ni="b",dr="r",Nt="q",ne="k",cs="rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1",Ee=-1,W0={NORMAL:"n",CAPTURE:"c",BIG_PAWN:"b",EP_CAPTURE:"e",PROMOTION:"p",KSIDE_CASTLE:"k",QSIDE_CASTLE:"q"},I={NORMAL:1,CAPTURE:2,BIG_PAWN:4,EP_CAPTURE:8,PROMOTION:16,KSIDE_CASTLE:32,QSIDE_CASTLE:64},R={a8:0,b8:1,c8:2,d8:3,e8:4,f8:5,g8:6,h8:7,a7:16,b7:17,c7:18,d7:19,e7:20,f7:21,g7:22,h7:23,a6:32,b6:33,c6:34,d6:35,e6:36,f6:37,g6:38,h6:39,a5:48,b5:49,c5:50,d5:51,e5:52,f5:53,g5:54,h5:55,a4:64,b4:65,c4:66,d4:67,e4:68,f4:69,g4:70,h4:71,a3:80,b3:81,c3:82,d3:83,e3:84,f3:85,g3:86,h3:87,a2:96,b2:97,c2:98,d2:99,e2:100,f2:101,g2:102,h2:103,a1:112,b1:113,c1:114,d1:115,e1:116,f1:117,g1:118,h1:119},ds={b:[16,32,17,15],w:[-16,-32,-17,-15]},Na={n:[-18,-33,-31,-14,18,33,31,14],b:[-17,-15,17,15],r:[-16,1,16,-1],q:[-17,-16,-15,1,17,16,15,-1],k:[-17,-16,-15,1,17,16,15,-1]},B0=[20,0,0,0,0,0,0,24,0,0,0,0,0,0,20,0,0,20,0,0,0,0,0,24,0,0,0,0,0,20,0,0,0,0,20,0,0,0,0,24,0,0,0,0,20,0,0,0,0,0,0,20,0,0,0,24,0,0,0,20,0,0,0,0,0,0,0,0,20,0,0,24,0,0,20,0,0,0,0,0,0,0,0,0,0,20,2,24,2,20,0,0,0,0,0,0,0,0,0,0,0,2,53,56,53,2,0,0,0,0,0,0,24,24,24,24,24,24,56,0,56,24,24,24,24,24,24,0,0,0,0,0,0,2,53,56,53,2,0,0,0,0,0,0,0,0,0,0,0,20,2,24,2,20,0,0,0,0,0,0,0,0,0,0,20,0,0,24,0,0,20,0,0,0,0,0,0,0,0,20,0,0,0,24,0,0,0,20,0,0,0,0,0,0,20,0,0,0,0,24,0,0,0,0,20,0,0,0,0,20,0,0,0,0,0,24,0,0,0,0,0,20,0,0,20,0,0,0,0,0,0,24,0,0,0,0,0,0,20],V0=[17,0,0,0,0,0,0,16,0,0,0,0,0,0,15,0,0,17,0,0,0,0,0,16,0,0,0,0,0,15,0,0,0,0,17,0,0,0,0,16,0,0,0,0,15,0,0,0,0,0,0,17,0,0,0,16,0,0,0,15,0,0,0,0,0,0,0,0,17,0,0,16,0,0,15,0,0,0,0,0,0,0,0,0,0,17,0,16,0,15,0,0,0,0,0,0,0,0,0,0,0,0,17,16,15,0,0,0,0,0,0,0,1,1,1,1,1,1,1,0,-1,-1,-1,-1,-1,-1,-1,0,0,0,0,0,0,0,-15,-16,-17,0,0,0,0,0,0,0,0,0,0,0,0,-15,0,-16,0,-17,0,0,0,0,0,0,0,0,0,0,-15,0,0,-16,0,0,-17,0,0,0,0,0,0,0,0,-15,0,0,0,-16,0,0,0,-17,0,0,0,0,0,0,-15,0,0,0,0,-16,0,0,0,0,-17,0,0,0,0,-15,0,0,0,0,0,-16,0,0,0,0,0,-17,0,0,-15,0,0,0,0,0,0,-16,0,0,0,0,0,0,-17],Q0={p:1,n:2,b:4,r:8,q:16,k:32},K0="pnbrqkPNBRQK",ja=[pl,Ni,dr,Nt],q0=7,G0=6,Y0=1,X0=0,vi={[ne]:I.KSIDE_CASTLE,[Nt]:I.QSIDE_CASTLE},Dt={w:[{square:R.a1,flag:I.QSIDE_CASTLE},{square:R.h1,flag:I.KSIDE_CASTLE}],b:[{square:R.a8,flag:I.QSIDE_CASTLE},{square:R.h8,flag:I.KSIDE_CASTLE}]},Z0={b:Y0,w:G0},J0=["1-0","0-1","1/2-1/2","*"];function ln(e){return e>>4}function $r(e){return e&15}function _f(e){return"0123456789".indexOf(e)!==-1}function Pe(e){const t=$r(e),n=ln(e);return"abcdefgh".substring(t,t+1)+"87654321".substring(n,n+1)}function ir(e){return e===pe?$e:pe}function eg(e){const t=e.split(/\s+/);if(t.length!==6)return{ok:!1,error:"Invalid FEN: must contain six space-delimited fields"};const n=parseInt(t[5],10);if(isNaN(n)||n<=0)return{ok:!1,error:"Invalid FEN: move number must be a positive integer"};const r=parseInt(t[4],10);if(isNaN(r)||r<0)return{ok:!1,error:"Invalid FEN: half move counter number must be a non-negative integer"};if(!/^(-|[abcdefgh][36])$/.test(t[3]))return{ok:!1,error:"Invalid FEN: en-passant square is invalid"};if(/[^kKqQ-]/.test(t[2]))return{ok:!1,error:"Invalid FEN: castling availability is invalid"};if(!/^(w|b)$/.test(t[1]))return{ok:!1,error:"Invalid FEN: side-to-move is invalid"};const i=t[0].split("/");if(i.length!==8)return{ok:!1,error:"Invalid FEN: piece data does not contain 8 '/'-delimited rows"};for(let s=0;s1)return{ok:!1,error:`Invalid FEN: too many ${s} kings`}}return Array.from(i[0]+i[7]).some(s=>s.toUpperCase()==="P")?{ok:!1,error:"Invalid FEN: some pawns are on the edge rows"}:{ok:!0}}function tg(e,t){const n=e.from,r=e.to,i=e.piece;let o=0,s=0,l=0;for(let u=0,a=t.length;u0?s>0&&l>0?Pe(n):l>0?Pe(n).charAt(1):Pe(n).charAt(0):""}function Pt(e,t,n,r,i,o=void 0,s=I.NORMAL){const l=ln(r);if(i===oe&&(l===q0||l===X0))for(let u=0;u="a"&&t<="h"?e.match(/[a-h]\d.*[a-h]\d/)?void 0:oe:(t=t.toLowerCase(),t==="o"?ne:t)}function fs(e){return e.replace(/=/,"").replace(/[+#]?[?!]*$/,"")}function Ma(e){return e.split(" ").slice(0,4).join(" ")}class ng{constructor(t=cs){ze(this,"_board",new Array(128));ze(this,"_turn",pe);ze(this,"_header",{});ze(this,"_kings",{w:Ee,b:Ee});ze(this,"_epSquare",-1);ze(this,"_halfMoves",0);ze(this,"_moveNumber",0);ze(this,"_history",[]);ze(this,"_comments",{});ze(this,"_castling",{w:0,b:0});ze(this,"_positionCounts",{});this.load(t)}clear({preserveHeaders:t=!1}={}){this._board=new Array(128),this._kings={w:Ee,b:Ee},this._turn=pe,this._castling={w:0,b:0},this._epSquare=Ee,this._halfMoves=0,this._moveNumber=1,this._history=[],this._comments={},this._header=t?this._header:{},delete this._header.SetUp,delete this._header.FEN,this._positionCounts=new Proxy({},{get:(n,r)=>r==="length"?Object.keys(n).length:(n==null?void 0:n[Ma(r)])||0,set:(n,r,i)=>{const o=Ma(r);return i===0?delete n[o]:n[o]=i,!0}})}removeHeader(t){t in this._header&&delete this._header[t]}load(t,{skipValidation:n=!1,preserveHeaders:r=!1}={}){let i=t.split(/\s+/);if(i.length>=2&&i.length<6){const l=["-","-","0","1"];t=i.concat(l.slice(-(6-i.length))).join(" ")}if(i=t.split(/\s+/),!n){const{ok:l,error:u}=eg(t);if(!l)throw new Error(u)}const o=i[0];let s=0;this.clear({preserveHeaders:r});for(let l=0;l-1&&(this._castling.w|=I.KSIDE_CASTLE),i[2].indexOf("Q")>-1&&(this._castling.w|=I.QSIDE_CASTLE),i[2].indexOf("k")>-1&&(this._castling.b|=I.KSIDE_CASTLE),i[2].indexOf("q")>-1&&(this._castling.b|=I.QSIDE_CASTLE),this._epSquare=i[3]==="-"?Ee:R[i[3]],this._halfMoves=parseInt(i[4],10),this._moveNumber=parseInt(i[5],10),this._updateSetup(t),this._positionCounts[t]++}fen(){var o,s;let t=0,n="";for(let l=R.a8;l<=R.h1;l++){if(this._board[l]){t>0&&(n+=t,t=0);const{color:u,type:a}=this._board[l];n+=u===pe?a.toUpperCase():a.toLowerCase()}else t++;l+1&136&&(t>0&&(n+=t),l!==R.h1&&(n+="/"),t=0,l+=8)}let r="";this._castling[pe]&I.KSIDE_CASTLE&&(r+="K"),this._castling[pe]&I.QSIDE_CASTLE&&(r+="Q"),this._castling[$e]&I.KSIDE_CASTLE&&(r+="k"),this._castling[$e]&I.QSIDE_CASTLE&&(r+="q"),r=r||"-";let i="-";if(this._epSquare!==Ee){const l=this._epSquare+(this._turn===pe?16:-16),u=[l+1,l-1];for(const a of u){if(a&136)continue;const g=this._turn;if(((o=this._board[a])==null?void 0:o.color)===g&&((s=this._board[a])==null?void 0:s.type)===oe){this._makeMove({color:g,from:a,to:this._epSquare,piece:oe,captured:oe,flags:I.EP_CAPTURE});const p=!this._isKingAttacked(g);if(this._undoMove(),p){i=Pe(this._epSquare);break}}}}return[n,this._turn,r,i,this._halfMoves,this._moveNumber].join(" ")}_updateSetup(t){this._history.length>0||(t!==cs?(this._header.SetUp="1",this._header.FEN=t):(delete this._header.SetUp,delete this._header.FEN))}reset(){this.load(cs)}get(t){return this._board[R[t]]||!1}put({type:t,color:n},r){return this._put({type:t,color:n},r)?(this._updateCastlingRights(),this._updateEnPassantSquare(),this._updateSetup(this.fen()),!0):!1}_put({type:t,color:n},r){if(K0.indexOf(t.toLowerCase())===-1||!(r in R))return!1;const i=R[r];if(t==ne&&!(this._kings[n]==Ee||this._kings[n]==i))return!1;const o=this._board[i];return o&&o.type===ne&&(this._kings[o.color]=Ee),this._board[i]={type:t,color:n},t===ne&&(this._kings[n]=i),!0}remove(t){const n=this.get(t);return delete this._board[R[t]],n&&n.type===ne&&(this._kings[n.color]=Ee),this._updateCastlingRights(),this._updateEnPassantSquare(),this._updateSetup(this.fen()),n}_updateCastlingRights(){var r,i,o,s,l,u,a,g,p,f,S,m;const t=((r=this._board[R.e1])==null?void 0:r.type)===ne&&((i=this._board[R.e1])==null?void 0:i.color)===pe,n=((o=this._board[R.e8])==null?void 0:o.type)===ne&&((s=this._board[R.e8])==null?void 0:s.color)===$e;(!t||((l=this._board[R.a1])==null?void 0:l.type)!==dr||((u=this._board[R.a1])==null?void 0:u.color)!==pe)&&(this._castling.w&=~I.QSIDE_CASTLE),(!t||((a=this._board[R.h1])==null?void 0:a.type)!==dr||((g=this._board[R.h1])==null?void 0:g.color)!==pe)&&(this._castling.w&=~I.KSIDE_CASTLE),(!n||((p=this._board[R.a8])==null?void 0:p.type)!==dr||((f=this._board[R.a8])==null?void 0:f.color)!==$e)&&(this._castling.b&=~I.QSIDE_CASTLE),(!n||((S=this._board[R.h8])==null?void 0:S.type)!==dr||((m=this._board[R.h8])==null?void 0:m.color)!==$e)&&(this._castling.b&=~I.KSIDE_CASTLE)}_updateEnPassantSquare(){var o,s;if(this._epSquare===Ee)return;const t=this._epSquare+(this._turn===pe?-16:16),n=this._epSquare+(this._turn===pe?16:-16),r=[n+1,n-1];if(this._board[t]!==null||this._board[this._epSquare]!==null||((o=this._board[n])==null?void 0:o.color)!==ir(this._turn)||((s=this._board[n])==null?void 0:s.type)!==oe){this._epSquare=Ee;return}const i=l=>{var u,a;return!(l&136)&&((u=this._board[l])==null?void 0:u.color)===this._turn&&((a=this._board[l])==null?void 0:a.type)===oe};r.some(i)||(this._epSquare=Ee)}_attacked(t,n){for(let r=R.a8;r<=R.h1;r++){if(r&136){r+=7;continue}if(this._board[r]===void 0||this._board[r].color!==t)continue;const i=this._board[r],o=r-n;if(o===0)continue;const s=o+119;if(B0[s]&Q0[i.type]){if(i.type===oe){if(o>0){if(i.color===pe)return!0}else if(i.color===$e)return!0;continue}if(i.type==="n"||i.type==="k")return!0;const l=V0[s];let u=r+l,a=!1;for(;u!==n;){if(this._board[u]!=null){a=!0;break}u+=l}if(!a)return!0}}return!1}_isKingAttacked(t){const n=this._kings[t];return n===-1?!1:this._attacked(ir(t),n)}isAttacked(t,n){return this._attacked(n,R[t])}isCheck(){return this._isKingAttacked(this._turn)}inCheck(){return this.isCheck()}isCheckmate(){return this.isCheck()&&this._moves().length===0}isStalemate(){return!this.isCheck()&&this._moves().length===0}isInsufficientMaterial(){const t={b:0,n:0,r:0,q:0,k:0,p:0},n=[];let r=0,i=0;for(let o=R.a8;o<=R.h1;o++){if(i=(i+1)%2,o&136){o+=7;continue}const s=this._board[o];s&&(t[s.type]=s.type in t?t[s.type]+1:1,s.type===Ni&&n.push(i),r++)}if(r===2)return!0;if(r===3&&(t[Ni]===1||t[pl]===1))return!0;if(r===t[Ni]+2){let o=0;const s=n.length;for(let l=0;l=3}isDraw(){return this._halfMoves>=100||this.isStalemate()||this.isInsufficientMaterial()||this.isThreefoldRepetition()}isGameOver(){return this.isCheckmate()||this.isStalemate()||this.isDraw()}moves({verbose:t=!1,square:n=void 0,piece:r=void 0}={}){const i=this._moves({square:n,piece:r});return t?i.map(o=>this._makePretty(o)):i.map(o=>this._moveToSan(o,i))}_moves({legal:t=!0,piece:n=void 0,square:r=void 0}={}){var S;const i=r?r.toLowerCase():void 0,o=n==null?void 0:n.toLowerCase(),s=[],l=this._turn,u=ir(l);let a=R.a8,g=R.h1,p=!1;if(i)if(i in R)a=g=R[i],p=!0;else return[];for(let m=a;m<=g;m++){if(m&136){m+=7;continue}if(!this._board[m]||this._board[m].color===u)continue;const{type:y}=this._board[m];let C;if(y===oe){if(o&&o!==y)continue;C=m+ds[l][0],this._board[C]||(Pt(s,l,m,C,oe),C=m+ds[l][1],Z0[l]===ln(m)&&!this._board[C]&&Pt(s,l,m,C,oe,void 0,I.BIG_PAWN));for(let d=2;d<4;d++)C=m+ds[l][d],!(C&136)&&(((S=this._board[C])==null?void 0:S.color)===u?Pt(s,l,m,C,oe,this._board[C].type,I.CAPTURE):C===this._epSquare&&Pt(s,l,m,C,oe,oe,I.EP_CAPTURE))}else{if(o&&o!==y)continue;for(let d=0,c=Na[y].length;d{const S=this._comments[this.fen()];if(typeof S<"u"){const m=f.length>0?" ":"";f=`${f}${m}{${S}}`}return f},s=[];for(;this._history.length>0;)s.push(this._undoMove());const l=[];let u="";for(s.length===0&&l.push(o(""));s.length>0;){u=o(u);const f=s.pop();if(!f)break;if(!this._history.length&&f.color==="b"){const S=`${this._moveNumber}. ...`;u=u?`${u} ${S}`:S}else f.color==="w"&&(u.length&&l.push(u),u=this._moveNumber+".");u=u+" "+this._moveToSan(f,this._moves({legal:!0})),this._makeMove(f)}if(u.length&&l.push(o(u)),typeof this._header.Result<"u"&&l.push(this._header.Result),n===0)return r.join("")+l.join(" ");const a=function(){return r.length>0&&r[r.length-1]===" "?(r.pop(),!0):!1},g=function(f,S){for(const m of S.split(" "))if(m){if(f+m.length>n){for(;a();)f--;r.push(t),f=0}r.push(m),f+=m.length,r.push(" "),f++}return a()&&f--,f};let p=0;for(let f=0;fn&&l[f].includes("{")){p=g(p,l[f]);continue}p+l[f].length>n&&f!==0?(r[r.length-1]===" "&&r.pop(),r.push(t),p=0):f!==0&&(r.push(" "),p++),r.push(l[f]),p+=l[f].length}return r.join("")}header(...t){for(let n=0;n0&&(w[O]=x)}return w}t=t.trim();const l=new RegExp("^(\\[((?:"+i(r)+")|.)*\\])((?:\\s*"+i(r)+"){2}|(?:\\s*"+i(r)+")*$)").exec(t),u=l&&l.length>=2?l[1]:"";this.reset();const a=o(u);let g="";for(const h in a)h.toLowerCase()==="fen"&&(g=a[h]),this.header(h,a[h]);if(!n)g&&this.load(g,{preserveHeaders:!0});else if(a.SetUp==="1"){if(!("FEN"in a))throw new Error("Invalid PGN: FEN tag must be supplied with SetUp tag");this.load(a.FEN,{preserveHeaders:!0})}function p(h){return Array.from(h).map(function(w){return w.charCodeAt(0)<128?w.charCodeAt(0).toString(16):encodeURIComponent(w).replace(/%/g,"").toLowerCase()}).join("")}function f(h){return h.length==0?"":decodeURIComponent("%"+(h.match(/.{1,2}/g)||[]).join("%"))}const S=function(h){return h=h.replace(new RegExp(i(r),"g")," "),`{${p(h.slice(1,h.length-1))}}`},m=function(h){if(h.startsWith("{")&&h.endsWith("}"))return f(h.slice(1,h.length-1))};let y=t.replace(u,"").replace(new RegExp(`({[^}]*})+?|;([^${i(r)}]*)`,"g"),function(h,w,k){return w!==void 0?S(w):" "+S(`{${k.slice(1)}}`)}).replace(new RegExp(i(r),"g")," ");const C=/(\([^()]+\))+?/g;for(;C.test(y);)y=y.replace(C,"");y=y.replace(/\d+\.(\.\.)?/g,""),y=y.replace(/\.\.\./g,""),y=y.replace(/\$\d+/g,"");let d=y.trim().split(new RegExp(/\s+/));d=d.filter(h=>h!=="");let c="";for(let h=0;h-1)c=d[h];else throw new Error(`Invalid move in PGN: ${d[h]}`);else c="",this._makeMove(k),this._positionCounts[this.fen()]++}c&&Object.keys(this._header).length&&!this._header.Result&&this.header("Result",c)}_moveToSan(t,n){let r="";if(t.flags&I.KSIDE_CASTLE)r="O-O";else if(t.flags&I.QSIDE_CASTLE)r="O-O-O";else{if(t.piece!==oe){const i=tg(t,n);r+=t.piece.toUpperCase()+i}t.flags&(I.CAPTURE|I.EP_CAPTURE)&&(t.piece===oe&&(r+=Pe(t.from)[0]),r+="x"),r+=Pe(t.to),t.promotion&&(r+="="+t.promotion.toUpperCase())}return this._makeMove(t),this.isCheck()&&(this.isCheckmate()?r+="#":r+="+"),this._undoMove(),r}_moveFromSan(t,n=!1){const r=fs(t);let i=Ra(r),o=this._moves({legal:!0,piece:i});for(let f=0,S=o.length;f0?r+=this.perft(t-1):r++),this._undoMove();return r}_makePretty(t){const{color:n,piece:r,from:i,to:o,flags:s,captured:l,promotion:u}=t;let a="";for(const S in I)I[S]&s&&(a+=W0[S]);const g=Pe(i),p=Pe(o),f={color:n,piece:r,from:g,to:p,san:this._moveToSan(t,this._moves({legal:!0})),flags:a,lan:g+p,before:this.fen(),after:""};return this._makeMove(t),f.after=this.fen(),this._undoMove(),l&&(f.captured=l),u&&(f.promotion=u,f.lan+=u),f}turn(){return this._turn}board(){const t=[];let n=[];for(let r=R.a8;r<=R.h1;r++)this._board[r]==null?n.push(null):n.push({square:Pe(r),type:this._board[r].type,color:this._board[r].color}),r+1&136&&(t.push(n),n=[],r+=8);return t}squareColor(t){if(t in R){const n=R[t];return(ln(n)+$r(n))%2===0?"light":"dark"}return null}history({verbose:t=!1}={}){const n=[],r=[];for(;this._history.length>0;)n.push(this._undoMove());for(;;){const i=n.pop();if(!i)break;t?r.push(this._makePretty(i)):r.push(this._moveToSan(i,this._moves())),this._makeMove(i)}return r}_pruneComments(){const t=[],n={},r=i=>{i in this._comments&&(n[i]=this._comments[i])};for(;this._history.length>0;)t.push(this._undoMove());for(r(this.fen());;){const i=t.pop();if(!i)break;this._makeMove(i),r(this.fen())}this._comments=n}getComment(){return this._comments[this.fen()]}setComment(t){this._comments[this.fen()]=t.replace("{","[").replace("}","]")}deleteComment(){const t=this._comments[this.fen()];return delete this._comments[this.fen()],t}getComments(){return this._pruneComments(),Object.keys(this._comments).map(t=>({fen:t,comment:this._comments[t]}))}deleteComments(){return this._pruneComments(),Object.keys(this._comments).map(t=>{const n=this._comments[t];return delete this._comments[t],{fen:t,comment:n}})}setCastlingRights(t,n){for(const i of[ne,Nt])n[i]!==void 0&&(n[i]?this._castling[t]|=vi[i]:this._castling[t]&=~vi[i]);this._updateCastlingRights();const r=this.getCastlingRights(t);return(n[ne]===void 0||n[ne]===r[ne])&&(n[Nt]===void 0||n[Nt]===r[Nt])}getCastlingRights(t){return{[ne]:(this._castling[t]&vi[ne])!==0,[Nt]:(this._castling[t]&vi[Nt])!==0}}moveNumber(){return this._moveNumber}}function rg(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(e);i"u"&&(n=t,t=void 0),typeof n<"u"){if(typeof n!="function")throw new Error(Fe(1));return n(Of)(e,t)}if(typeof e!="function")throw new Error(Fe(2));var i=e,o=t,s=[],l=s,u=!1;function a(){l===s&&(l=s.slice())}function g(){if(u)throw new Error(Fe(3));return o}function p(y){if(typeof y!="function")throw new Error(Fe(4));if(u)throw new Error(Fe(5));var C=!0;return a(),l.push(y),function(){if(C){if(u)throw new Error(Fe(6));C=!1,a();var c=l.indexOf(y);l.splice(c,1),s=null}}}function f(y){if(!ig(y))throw new Error(Fe(7));if(typeof y.type>"u")throw new Error(Fe(8));if(u)throw new Error(Fe(9));try{u=!0,o=i(o,y)}finally{u=!1}for(var C=s=l,d=0;dr&&r[i]?r[i]:n||null,e)}function lg(e,t){return e.filter(n=>n!==t)}function Tf(e){return typeof e=="object"}function ug(e,t){const n=new Map,r=o=>{n.set(o,n.has(o)?n.get(o)+1:1)};e.forEach(r),t.forEach(r);const i=[];return n.forEach((o,s)=>{o===1&&i.push(s)}),i}function ag(e,t){return e.filter(n=>t.indexOf(n)>-1)}const gu="dnd-core/INIT_COORDS",ko="dnd-core/BEGIN_DRAG",mu="dnd-core/PUBLISH_DRAG_SOURCE",_o="dnd-core/HOVER",xo="dnd-core/DROP",Oo="dnd-core/END_DRAG";function za(e,t){return{type:gu,payload:{sourceClientOffset:t||null,clientOffset:e||null}}}const cg={type:gu,payload:{clientOffset:null,sourceClientOffset:null}};function dg(e){return function(n=[],r={publishSource:!0}){const{publishSource:i=!0,clientOffset:o,getSourceClientOffset:s}=r,l=e.getMonitor(),u=e.getRegistry();e.dispatch(za(o)),fg(n,l,u);const a=gg(n,l);if(a==null){e.dispatch(cg);return}let g=null;if(o){if(!s)throw new Error("getSourceClientOffset must be defined");hg(s),g=s(a)}e.dispatch(za(o,g));const f=u.getSource(a).beginDrag(l,a);if(f==null)return;pg(f),u.pinSource(a);const S=u.getSourceType(a);return{type:ko,payload:{itemType:S,item:f,sourceId:a,clientOffset:o||null,sourceClientOffset:g||null,isSourcePublic:!!i}}}}function fg(e,t,n){N(!t.isDragging(),"Cannot call beginDrag while dragging."),e.forEach(function(r){N(n.getSource(r),"Expected sourceIds to be registered.")})}function hg(e){N(typeof e=="function","When clientOffset is provided, getSourceClientOffset must be a function.")}function pg(e){N(Tf(e),"Item must be an object.")}function gg(e,t){let n=null;for(let r=e.length-1;r>=0;r--)if(t.canDragSource(e[r])){n=e[r];break}return n}function mg(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function vg(e){for(var t=1;t{const u=wg(s,l,i,r),a={type:xo,payload:{dropResult:vg({},n,u)}};e.dispatch(a)})}}function Sg(e){N(e.isDragging(),"Cannot call drop while not dragging."),N(!e.didDrop(),"Cannot call drop twice during one drag operation.")}function wg(e,t,n,r){const i=n.getTarget(e);let o=i?i.drop(r,e):void 0;return Cg(o),typeof o>"u"&&(o=t===0?{}:r.getDropResult()),o}function Cg(e){N(typeof e>"u"||Tf(e),"Drop result must either be an object or undefined.")}function Eg(e){const t=e.getTargetIds().filter(e.canDropOnTarget,e);return t.reverse(),t}function kg(e){return function(){const n=e.getMonitor(),r=e.getRegistry();_g(n);const i=n.getSourceId();return i!=null&&(r.getSource(i,!0).endDrag(n,i),r.unpinSource()),{type:Oo}}}function _g(e){N(e.isDragging(),"Cannot call endDrag while not dragging.")}function gl(e,t){return t===null?e===null:Array.isArray(e)?e.some(n=>n===t):e===t}function xg(e){return function(n,{clientOffset:r}={}){Og(n);const i=n.slice(0),o=e.getMonitor(),s=e.getRegistry(),l=o.getItemType();return Dg(i,s,l),Tg(i,o,s),Pg(i,o,s),{type:_o,payload:{targetIds:i,clientOffset:r||null}}}}function Og(e){N(Array.isArray(e),"Expected targetIds to be an array.")}function Tg(e,t,n){N(t.isDragging(),"Cannot call hover while not dragging."),N(!t.didDrop(),"Cannot call hover after drop.");for(let r=0;r=0;r--){const i=e[r],o=t.getTargetType(i);gl(o,n)||e.splice(r,1)}}function Pg(e,t,n){e.forEach(function(r){n.getTarget(r).hover(t,r)})}function Lg(e){return function(){if(e.getMonitor().isDragging())return{type:mu}}}function Ig(e){return{beginDrag:dg(e),publishDragSource:Lg(e),hover:xg(e),drop:yg(e),endDrag:kg(e)}}class Ng{receiveBackend(t){this.backend=t}getMonitor(){return this.monitor}getBackend(){return this.backend}getRegistry(){return this.monitor.registry}getActions(){const t=this,{dispatch:n}=this.store;function r(o){return(...s)=>{const l=o.apply(t,s);typeof l<"u"&&n(l)}}const i=Ig(this);return Object.keys(i).reduce((o,s)=>{const l=i[s];return o[s]=r(l),o},{})}dispatch(t){this.store.dispatch(t)}constructor(t,n){this.isSetUp=!1,this.handleRefCountChange=()=>{const r=this.store.getState().refCount>0;this.backend&&(r&&!this.isSetUp?(this.backend.setup(),this.isSetUp=!0):!r&&this.isSetUp&&(this.backend.teardown(),this.isSetUp=!1))},this.store=t,this.monitor=n,t.subscribe(this.handleRefCountChange)}}function jg(e,t){return{x:e.x+t.x,y:e.y+t.y}}function Df(e,t){return{x:e.x-t.x,y:e.y-t.y}}function Rg(e){const{clientOffset:t,initialClientOffset:n,initialSourceClientOffset:r}=e;return!t||!n||!r?null:Df(jg(t,r),n)}function Mg(e){const{clientOffset:t,initialClientOffset:n}=e;return!t||!n?null:Df(t,n)}const Cr=[],vu=[];Cr.__IS_NONE__=!0;vu.__IS_ALL__=!0;function Ag(e,t){return e===Cr?!1:e===vu||typeof t>"u"?!0:ag(t,e).length>0}class bg{subscribeToStateChange(t,n={}){const{handlerIds:r}=n;N(typeof t=="function","listener must be a function."),N(typeof r>"u"||Array.isArray(r),"handlerIds, when specified, must be an array of strings.");let i=this.store.getState().stateId;const o=()=>{const s=this.store.getState(),l=s.stateId;try{l===i||l===i+1&&!Ag(s.dirtyHandlerIds,r)||t()}finally{i=l}};return this.store.subscribe(o)}subscribeToOffsetChange(t){N(typeof t=="function","listener must be a function.");let n=this.store.getState().dragOffset;const r=()=>{const i=this.store.getState().dragOffset;i!==n&&(n=i,t())};return this.store.subscribe(r)}canDragSource(t){if(!t)return!1;const n=this.registry.getSource(t);return N(n,`Expected to find a valid source. sourceId=${t}`),this.isDragging()?!1:n.canDrag(this,t)}canDropOnTarget(t){if(!t)return!1;const n=this.registry.getTarget(t);if(N(n,`Expected to find a valid target. targetId=${t}`),!this.isDragging()||this.didDrop())return!1;const r=this.registry.getTargetType(t),i=this.getItemType();return gl(r,i)&&n.canDrop(this,t)}isDragging(){return!!this.getItemType()}isDraggingSource(t){if(!t)return!1;const n=this.registry.getSource(t,!0);if(N(n,`Expected to find a valid source. sourceId=${t}`),!this.isDragging()||!this.isSourcePublic())return!1;const r=this.registry.getSourceType(t),i=this.getItemType();return r!==i?!1:n.isDragging(this,t)}isOverTarget(t,n={shallow:!1}){if(!t)return!1;const{shallow:r}=n;if(!this.isDragging())return!1;const i=this.registry.getTargetType(t),o=this.getItemType();if(o&&!gl(i,o))return!1;const s=this.getTargetIds();if(!s.length)return!1;const l=s.indexOf(t);return r?l===s.length-1:l>-1}getItemType(){return this.store.getState().dragOperation.itemType}getItem(){return this.store.getState().dragOperation.item}getSourceId(){return this.store.getState().dragOperation.sourceId}getTargetIds(){return this.store.getState().dragOperation.targetIds}getDropResult(){return this.store.getState().dragOperation.dropResult}didDrop(){return this.store.getState().dragOperation.didDrop}isSourcePublic(){return!!this.store.getState().dragOperation.isSourcePublic}getInitialClientOffset(){return this.store.getState().dragOffset.initialClientOffset}getInitialSourceClientOffset(){return this.store.getState().dragOffset.initialSourceClientOffset}getClientOffset(){return this.store.getState().dragOffset.clientOffset}getSourceClientOffset(){return Rg(this.store.getState().dragOffset)}getDifferenceFromInitialOffset(){return Mg(this.store.getState().dragOffset)}constructor(t,n){this.store=t,this.registry=n}}const Fa=typeof global<"u"?global:self,Pf=Fa.MutationObserver||Fa.WebKitMutationObserver;function Lf(e){return function(){const n=setTimeout(i,0),r=setInterval(i,50);function i(){clearTimeout(n),clearInterval(r),e()}}}function zg(e){let t=1;const n=new Pf(e),r=document.createTextNode("");return n.observe(r,{characterData:!0}),function(){t=-t,r.data=t}}const Fg=typeof Pf=="function"?zg:Lf;class $g{enqueueTask(t){const{queue:n,requestFlush:r}=this;n.length||(r(),this.flushing=!0),n[n.length]=t}constructor(){this.queue=[],this.pendingErrors=[],this.flushing=!1,this.index=0,this.capacity=1024,this.flush=()=>{const{queue:t}=this;for(;this.indexthis.capacity){for(let r=0,i=t.length-this.index;r{this.pendingErrors.push(t),this.requestErrorThrow()},this.requestFlush=Fg(this.flush),this.requestErrorThrow=Lf(()=>{if(this.pendingErrors.length)throw this.pendingErrors.shift()})}}class Ug{call(){try{this.task&&this.task()}catch(t){this.onError(t)}finally{this.task=null,this.release(this)}}constructor(t,n){this.onError=t,this.release=n,this.task=null}}class Hg{create(t){const n=this.freeTasks,r=n.length?n.pop():new Ug(this.onError,i=>n[n.length]=i);return r.task=t,r}constructor(t){this.onError=t,this.freeTasks=[]}}const If=new $g,Wg=new Hg(If.registerPendingError);function Bg(e){If.enqueueTask(Wg.create(e))}const yu="dnd-core/ADD_SOURCE",Su="dnd-core/ADD_TARGET",wu="dnd-core/REMOVE_SOURCE",To="dnd-core/REMOVE_TARGET";function Vg(e){return{type:yu,payload:{sourceId:e}}}function Qg(e){return{type:Su,payload:{targetId:e}}}function Kg(e){return{type:wu,payload:{sourceId:e}}}function qg(e){return{type:To,payload:{targetId:e}}}function Gg(e){N(typeof e.canDrag=="function","Expected canDrag to be a function."),N(typeof e.beginDrag=="function","Expected beginDrag to be a function."),N(typeof e.endDrag=="function","Expected endDrag to be a function.")}function Yg(e){N(typeof e.canDrop=="function","Expected canDrop to be a function."),N(typeof e.hover=="function","Expected hover to be a function."),N(typeof e.drop=="function","Expected beginDrag to be a function.")}function ml(e,t){if(t&&Array.isArray(e)){e.forEach(n=>ml(n,!1));return}N(typeof e=="string"||typeof e=="symbol",t?"Type can only be a string, a symbol, or an array of either.":"Type can only be a string or a symbol.")}var We;(function(e){e.SOURCE="SOURCE",e.TARGET="TARGET"})(We||(We={}));let Xg=0;function Zg(){return Xg++}function Jg(e){const t=Zg().toString();switch(e){case We.SOURCE:return`S${t}`;case We.TARGET:return`T${t}`;default:throw new Error(`Unknown Handler Role: ${e}`)}}function $a(e){switch(e[0]){case"S":return We.SOURCE;case"T":return We.TARGET;default:throw new Error(`Cannot parse handler ID: ${e}`)}}function Ua(e,t){const n=e.entries();let r=!1;do{const{done:i,value:[,o]}=n.next();if(o===t)return!0;r=!!i}while(!r);return!1}class e1{addSource(t,n){ml(t),Gg(n);const r=this.addHandler(We.SOURCE,t,n);return this.store.dispatch(Vg(r)),r}addTarget(t,n){ml(t,!0),Yg(n);const r=this.addHandler(We.TARGET,t,n);return this.store.dispatch(Qg(r)),r}containsHandler(t){return Ua(this.dragSources,t)||Ua(this.dropTargets,t)}getSource(t,n=!1){return N(this.isSourceId(t),"Expected a valid source ID."),n&&t===this.pinnedSourceId?this.pinnedSource:this.dragSources.get(t)}getTarget(t){return N(this.isTargetId(t),"Expected a valid target ID."),this.dropTargets.get(t)}getSourceType(t){return N(this.isSourceId(t),"Expected a valid source ID."),this.types.get(t)}getTargetType(t){return N(this.isTargetId(t),"Expected a valid target ID."),this.types.get(t)}isSourceId(t){return $a(t)===We.SOURCE}isTargetId(t){return $a(t)===We.TARGET}removeSource(t){N(this.getSource(t),"Expected an existing source."),this.store.dispatch(Kg(t)),Bg(()=>{this.dragSources.delete(t),this.types.delete(t)})}removeTarget(t){N(this.getTarget(t),"Expected an existing target."),this.store.dispatch(qg(t)),this.dropTargets.delete(t),this.types.delete(t)}pinSource(t){const n=this.getSource(t);N(n,"Expected an existing source."),this.pinnedSourceId=t,this.pinnedSource=n}unpinSource(){N(this.pinnedSource,"No source is pinned at the time."),this.pinnedSourceId=null,this.pinnedSource=null}addHandler(t,n,r){const i=Jg(t);return this.types.set(i,n),t===We.SOURCE?this.dragSources.set(i,r):t===We.TARGET&&this.dropTargets.set(i,r),i}constructor(t){this.types=new Map,this.dragSources=new Map,this.dropTargets=new Map,this.pinnedSourceId=null,this.pinnedSource=null,this.store=t}}const t1=(e,t)=>e===t;function n1(e,t){return!e&&!t?!0:!e||!t?!1:e.x===t.x&&e.y===t.y}function r1(e,t,n=t1){if(e.length!==t.length)return!1;for(let r=0;r0||!r1(n,r)))return Cr;const s=r[r.length-1],l=n[n.length-1];return s!==l&&(s&&i.push(s),l&&i.push(l)),i}function o1(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function s1(e){for(var t=1;t=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function S1(e,t){if(e==null)return{};var n={},r=Object.keys(e),i,o;for(o=0;o=0)&&(n[i]=e[i]);return n}let Wa=0;const ji=Symbol.for("__REACT_DND_CONTEXT_INSTANCE__");var w1=E.memo(function(t){var{children:n}=t,r=y1(t,["children"]);const[i,o]=C1(r);return E.useEffect(()=>{if(o){const s=Nf();return++Wa,()=>{--Wa===0&&(s[ji]=null)}}},[]),v.jsx(xf.Provider,{value:i,children:n})});function C1(e){if("manager"in e)return[{dragDropManager:e.manager},!1];const t=E1(e.backend,e.context,e.options,e.debugMode),n=!e.context;return[t,n]}function E1(e,t=Nf(),n,r){const i=t;return i[ji]||(i[ji]={dragDropManager:m1(e,t,n,r)}),i[ji]}function Nf(){return typeof global<"u"?global:window}var k1=function e(t,n){if(t===n)return!0;if(t&&n&&typeof t=="object"&&typeof n=="object"){if(t.constructor!==n.constructor)return!1;var r,i,o;if(Array.isArray(t)){if(r=t.length,r!=n.length)return!1;for(i=r;i--!==0;)if(!e(t[i],n[i]))return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if(o=Object.keys(t),r=o.length,r!==Object.keys(n).length)return!1;for(i=r;i--!==0;)if(!Object.prototype.hasOwnProperty.call(n,o[i]))return!1;for(i=r;i--!==0;){var s=o[i];if(!e(t[s],n[s]))return!1}return!0}return t!==t&&n!==n};const hn=typeof window<"u"?E.useLayoutEffect:E.useEffect;function jf(e,t,n){const[r,i]=E.useState(()=>t(e)),o=E.useCallback(()=>{const s=t(e);k1(r,s)||(i(s),n&&n())},[r,e,n]);return hn(o),[r,o]}function _1(e,t,n){const[r,i]=jf(e,t,n);return hn(function(){const s=e.getHandlerId();if(s!=null)return e.subscribeToStateChange(i,{handlerIds:[s]})},[e,i]),r}function Rf(e,t,n){return _1(t,e||(()=>({})),()=>n.reconnect())}function Mf(e,t){const n=[...t||[]];return t==null&&typeof e!="function"&&n.push(e),E.useMemo(()=>typeof e=="function"?e():e,n)}function x1(e){return E.useMemo(()=>e.hooks.dragSource(),[e])}function O1(e){return E.useMemo(()=>e.hooks.dragPreview(),[e])}let ps=!1,gs=!1;class T1{receiveHandlerId(t){this.sourceId=t}getHandlerId(){return this.sourceId}canDrag(){N(!ps,"You may not call monitor.canDrag() inside your canDrag() implementation. Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-source-monitor");try{return ps=!0,this.internalMonitor.canDragSource(this.sourceId)}finally{ps=!1}}isDragging(){if(!this.sourceId)return!1;N(!gs,"You may not call monitor.isDragging() inside your isDragging() implementation. Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-source-monitor");try{return gs=!0,this.internalMonitor.isDraggingSource(this.sourceId)}finally{gs=!1}}subscribeToStateChange(t,n){return this.internalMonitor.subscribeToStateChange(t,n)}isDraggingSource(t){return this.internalMonitor.isDraggingSource(t)}isOverTarget(t,n){return this.internalMonitor.isOverTarget(t,n)}getTargetIds(){return this.internalMonitor.getTargetIds()}isSourcePublic(){return this.internalMonitor.isSourcePublic()}getSourceId(){return this.internalMonitor.getSourceId()}subscribeToOffsetChange(t){return this.internalMonitor.subscribeToOffsetChange(t)}canDragSource(t){return this.internalMonitor.canDragSource(t)}canDropOnTarget(t){return this.internalMonitor.canDropOnTarget(t)}getItemType(){return this.internalMonitor.getItemType()}getItem(){return this.internalMonitor.getItem()}getDropResult(){return this.internalMonitor.getDropResult()}didDrop(){return this.internalMonitor.didDrop()}getInitialClientOffset(){return this.internalMonitor.getInitialClientOffset()}getInitialSourceClientOffset(){return this.internalMonitor.getInitialSourceClientOffset()}getSourceClientOffset(){return this.internalMonitor.getSourceClientOffset()}getClientOffset(){return this.internalMonitor.getClientOffset()}getDifferenceFromInitialOffset(){return this.internalMonitor.getDifferenceFromInitialOffset()}constructor(t){this.sourceId=null,this.internalMonitor=t.getMonitor()}}let ms=!1;class D1{receiveHandlerId(t){this.targetId=t}getHandlerId(){return this.targetId}subscribeToStateChange(t,n){return this.internalMonitor.subscribeToStateChange(t,n)}canDrop(){if(!this.targetId)return!1;N(!ms,"You may not call monitor.canDrop() inside your canDrop() implementation. Read more: http://react-dnd.github.io/react-dnd/docs/api/drop-target-monitor");try{return ms=!0,this.internalMonitor.canDropOnTarget(this.targetId)}finally{ms=!1}}isOver(t){return this.targetId?this.internalMonitor.isOverTarget(this.targetId,t):!1}getItemType(){return this.internalMonitor.getItemType()}getItem(){return this.internalMonitor.getItem()}getDropResult(){return this.internalMonitor.getDropResult()}didDrop(){return this.internalMonitor.didDrop()}getInitialClientOffset(){return this.internalMonitor.getInitialClientOffset()}getInitialSourceClientOffset(){return this.internalMonitor.getInitialSourceClientOffset()}getSourceClientOffset(){return this.internalMonitor.getSourceClientOffset()}getClientOffset(){return this.internalMonitor.getClientOffset()}getDifferenceFromInitialOffset(){return this.internalMonitor.getDifferenceFromInitialOffset()}constructor(t){this.targetId=null,this.internalMonitor=t.getMonitor()}}function P1(e,t,n){const r=n.getRegistry(),i=r.addTarget(e,t);return[i,()=>r.removeTarget(i)]}function L1(e,t,n){const r=n.getRegistry(),i=r.addSource(e,t);return[i,()=>r.removeSource(i)]}function vl(e,t,n,r){let i=n?n.call(r,e,t):void 0;if(i!==void 0)return!!i;if(e===t)return!0;if(typeof e!="object"||!e||typeof t!="object"||!t)return!1;const o=Object.keys(e),s=Object.keys(t);if(o.length!==s.length)return!1;const l=Object.prototype.hasOwnProperty.bind(t);for(let u=0;u, or turn it into a drag source or a drop target itself.`)}function N1(e){return(t=null,n=null)=>{if(!E.isValidElement(t)){const o=t;return e(o,n),o}const r=t;return I1(r),j1(r,n?o=>e(o,n):e)}}function Af(e){const t={};return Object.keys(e).forEach(n=>{const r=e[n];if(n.endsWith("Ref"))t[n]=e[n];else{const i=N1(r);t[n]=()=>i}}),t}function Ba(e,t){typeof e=="function"?e(t):e.current=t}function j1(e,t){const n=e.ref;return N(typeof n!="string","Cannot connect React DnD to an element with an existing string ref. Please convert it to use a callback ref instead, or wrap it into a or
. Read more: https://reactjs.org/docs/refs-and-the-dom.html#callback-refs"),n?E.cloneElement(e,{ref:r=>{Ba(n,r),Ba(t,r)}}):E.cloneElement(e,{ref:t})}class R1{receiveHandlerId(t){this.handlerId!==t&&(this.handlerId=t,this.reconnect())}get connectTarget(){return this.dragSource}get dragSourceOptions(){return this.dragSourceOptionsInternal}set dragSourceOptions(t){this.dragSourceOptionsInternal=t}get dragPreviewOptions(){return this.dragPreviewOptionsInternal}set dragPreviewOptions(t){this.dragPreviewOptionsInternal=t}reconnect(){const t=this.reconnectDragSource();this.reconnectDragPreview(t)}reconnectDragSource(){const t=this.dragSource,n=this.didHandlerIdChange()||this.didConnectedDragSourceChange()||this.didDragSourceOptionsChange();return n&&this.disconnectDragSource(),this.handlerId?t?(n&&(this.lastConnectedHandlerId=this.handlerId,this.lastConnectedDragSource=t,this.lastConnectedDragSourceOptions=this.dragSourceOptions,this.dragSourceUnsubscribe=this.backend.connectDragSource(this.handlerId,t,this.dragSourceOptions)),n):(this.lastConnectedDragSource=t,n):n}reconnectDragPreview(t=!1){const n=this.dragPreview,r=t||this.didHandlerIdChange()||this.didConnectedDragPreviewChange()||this.didDragPreviewOptionsChange();if(r&&this.disconnectDragPreview(),!!this.handlerId){if(!n){this.lastConnectedDragPreview=n;return}r&&(this.lastConnectedHandlerId=this.handlerId,this.lastConnectedDragPreview=n,this.lastConnectedDragPreviewOptions=this.dragPreviewOptions,this.dragPreviewUnsubscribe=this.backend.connectDragPreview(this.handlerId,n,this.dragPreviewOptions))}}didHandlerIdChange(){return this.lastConnectedHandlerId!==this.handlerId}didConnectedDragSourceChange(){return this.lastConnectedDragSource!==this.dragSource}didConnectedDragPreviewChange(){return this.lastConnectedDragPreview!==this.dragPreview}didDragSourceOptionsChange(){return!vl(this.lastConnectedDragSourceOptions,this.dragSourceOptions)}didDragPreviewOptionsChange(){return!vl(this.lastConnectedDragPreviewOptions,this.dragPreviewOptions)}disconnectDragSource(){this.dragSourceUnsubscribe&&(this.dragSourceUnsubscribe(),this.dragSourceUnsubscribe=void 0)}disconnectDragPreview(){this.dragPreviewUnsubscribe&&(this.dragPreviewUnsubscribe(),this.dragPreviewUnsubscribe=void 0,this.dragPreviewNode=null,this.dragPreviewRef=null)}get dragSource(){return this.dragSourceNode||this.dragSourceRef&&this.dragSourceRef.current}get dragPreview(){return this.dragPreviewNode||this.dragPreviewRef&&this.dragPreviewRef.current}clearDragSource(){this.dragSourceNode=null,this.dragSourceRef=null}clearDragPreview(){this.dragPreviewNode=null,this.dragPreviewRef=null}constructor(t){this.hooks=Af({dragSource:(n,r)=>{this.clearDragSource(),this.dragSourceOptions=r||null,yl(n)?this.dragSourceRef=n:this.dragSourceNode=n,this.reconnectDragSource()},dragPreview:(n,r)=>{this.clearDragPreview(),this.dragPreviewOptions=r||null,yl(n)?this.dragPreviewRef=n:this.dragPreviewNode=n,this.reconnectDragPreview()}}),this.handlerId=null,this.dragSourceRef=null,this.dragSourceOptionsInternal=null,this.dragPreviewRef=null,this.dragPreviewOptionsInternal=null,this.lastConnectedHandlerId=null,this.lastConnectedDragSource=null,this.lastConnectedDragSourceOptions=null,this.lastConnectedDragPreview=null,this.lastConnectedDragPreviewOptions=null,this.backend=t}}class M1{get connectTarget(){return this.dropTarget}reconnect(){const t=this.didHandlerIdChange()||this.didDropTargetChange()||this.didOptionsChange();t&&this.disconnectDropTarget();const n=this.dropTarget;if(this.handlerId){if(!n){this.lastConnectedDropTarget=n;return}t&&(this.lastConnectedHandlerId=this.handlerId,this.lastConnectedDropTarget=n,this.lastConnectedDropTargetOptions=this.dropTargetOptions,this.unsubscribeDropTarget=this.backend.connectDropTarget(this.handlerId,n,this.dropTargetOptions))}}receiveHandlerId(t){t!==this.handlerId&&(this.handlerId=t,this.reconnect())}get dropTargetOptions(){return this.dropTargetOptionsInternal}set dropTargetOptions(t){this.dropTargetOptionsInternal=t}didHandlerIdChange(){return this.lastConnectedHandlerId!==this.handlerId}didDropTargetChange(){return this.lastConnectedDropTarget!==this.dropTarget}didOptionsChange(){return!vl(this.lastConnectedDropTargetOptions,this.dropTargetOptions)}disconnectDropTarget(){this.unsubscribeDropTarget&&(this.unsubscribeDropTarget(),this.unsubscribeDropTarget=void 0)}get dropTarget(){return this.dropTargetNode||this.dropTargetRef&&this.dropTargetRef.current}clearDropTarget(){this.dropTargetRef=null,this.dropTargetNode=null}constructor(t){this.hooks=Af({dropTarget:(n,r)=>{this.clearDropTarget(),this.dropTargetOptions=r,yl(n)?this.dropTargetRef=n:this.dropTargetNode=n,this.reconnect()}}),this.handlerId=null,this.dropTargetRef=null,this.dropTargetOptionsInternal=null,this.lastConnectedHandlerId=null,this.lastConnectedDropTarget=null,this.lastConnectedDropTargetOptions=null,this.backend=t}}function mn(){const{dragDropManager:e}=E.useContext(xf);return N(e!=null,"Expected drag drop context"),e}function A1(e,t){const n=mn(),r=E.useMemo(()=>new R1(n.getBackend()),[n]);return hn(()=>(r.dragSourceOptions=e||null,r.reconnect(),()=>r.disconnectDragSource()),[r,e]),hn(()=>(r.dragPreviewOptions=t||null,r.reconnect(),()=>r.disconnectDragPreview()),[r,t]),r}function b1(){const e=mn();return E.useMemo(()=>new T1(e),[e])}class z1{beginDrag(){const t=this.spec,n=this.monitor;let r=null;return typeof t.item=="object"?r=t.item:typeof t.item=="function"?r=t.item(n):r={},r??null}canDrag(){const t=this.spec,n=this.monitor;return typeof t.canDrag=="boolean"?t.canDrag:typeof t.canDrag=="function"?t.canDrag(n):!0}isDragging(t,n){const r=this.spec,i=this.monitor,{isDragging:o}=r;return o?o(i):n===t.getSourceId()}endDrag(){const t=this.spec,n=this.monitor,r=this.connector,{end:i}=t;i&&i(n.getItem(),n),r.reconnect()}constructor(t,n,r){this.spec=t,this.monitor=n,this.connector=r}}function F1(e,t,n){const r=E.useMemo(()=>new z1(e,t,n),[t,n]);return E.useEffect(()=>{r.spec=e},[e]),r}function $1(e){return E.useMemo(()=>{const t=e.type;return N(t!=null,"spec.type must be defined"),t},[e])}function U1(e,t,n){const r=mn(),i=F1(e,t,n),o=$1(e);hn(function(){if(o!=null){const[l,u]=L1(o,i,r);return t.receiveHandlerId(l),n.receiveHandlerId(l),u}},[r,t,n,i,o])}function H1(e,t){const n=Mf(e,t);N(!n.begin,"useDrag::spec.begin was deprecated in v14. Replace spec.begin() with spec.item(). (see more here - https://react-dnd.github.io/react-dnd/docs/api/use-drag)");const r=b1(),i=A1(n.options,n.previewOptions);return U1(n,r,i),[Rf(n.collect,r,i),x1(i),O1(i)]}function W1(e){const n=mn().getMonitor(),[r,i]=jf(n,e);return E.useEffect(()=>n.subscribeToOffsetChange(i)),E.useEffect(()=>n.subscribeToStateChange(i)),r}function B1(e){return E.useMemo(()=>e.hooks.dropTarget(),[e])}function V1(e){const t=mn(),n=E.useMemo(()=>new M1(t.getBackend()),[t]);return hn(()=>(n.dropTargetOptions=e||null,n.reconnect(),()=>n.disconnectDropTarget()),[e]),n}function Q1(){const e=mn();return E.useMemo(()=>new D1(e),[e])}function K1(e){const{accept:t}=e;return E.useMemo(()=>(N(e.accept!=null,"accept must be defined"),Array.isArray(t)?t:[t]),[t])}class q1{canDrop(){const t=this.spec,n=this.monitor;return t.canDrop?t.canDrop(n.getItem(),n):!0}hover(){const t=this.spec,n=this.monitor;t.hover&&t.hover(n.getItem(),n)}drop(){const t=this.spec,n=this.monitor;if(t.drop)return t.drop(n.getItem(),n)}constructor(t,n){this.spec=t,this.monitor=n}}function G1(e,t){const n=E.useMemo(()=>new q1(e,t),[t]);return E.useEffect(()=>{n.spec=e},[e]),n}function Y1(e,t,n){const r=mn(),i=G1(e,t),o=K1(e);hn(function(){const[l,u]=P1(o,i,r);return t.receiveHandlerId(l),n.receiveHandlerId(l),u},[r,t,i,n,o.map(s=>s.toString()).join("|")])}function X1(e,t){const n=Mf(e,t),r=Q1(),i=V1(n.options);return Y1(n,r,i),[Rf(n.collect,r,i),B1(i)]}function bf(e){let t=null;return()=>(t==null&&(t=e()),t)}function Z1(e,t){return e.filter(n=>n!==t)}function J1(e,t){const n=new Set,r=o=>n.add(o);e.forEach(r),t.forEach(r);const i=[];return n.forEach(o=>i.push(o)),i}class em{enter(t){const n=this.entered.length,r=i=>this.isNodeInDocument(i)&&(!i.contains||i.contains(t));return this.entered=J1(this.entered.filter(r),[t]),n===0&&this.entered.length>0}leave(t){const n=this.entered.length;return this.entered=Z1(this.entered.filter(this.isNodeInDocument),t),n>0&&this.entered.length===0}reset(){this.entered=[]}constructor(t){this.entered=[],this.isNodeInDocument=t}}class tm{initializeExposedProperties(){Object.keys(this.config.exposeProperties).forEach(t=>{Object.defineProperty(this.item,t,{configurable:!0,enumerable:!0,get(){return console.warn(`Browser doesn't allow reading "${t}" until the drop event.`),null}})})}loadDataTransfer(t){if(t){const n={};Object.keys(this.config.exposeProperties).forEach(r=>{const i=this.config.exposeProperties[r];i!=null&&(n[r]={value:i(t,this.config.matchesTypes),configurable:!0,enumerable:!0})}),Object.defineProperties(this.item,n)}}canDrag(){return!0}beginDrag(){return this.item}isDragging(t,n){return n===t.getSourceId()}endDrag(){}constructor(t){this.config=t,this.item={},this.initializeExposedProperties()}}const zf="__NATIVE_FILE__",Ff="__NATIVE_URL__",$f="__NATIVE_TEXT__",Uf="__NATIVE_HTML__";var Va=Object.freeze({__proto__:null,FILE:zf,HTML:Uf,TEXT:$f,URL:Ff});function vs(e,t,n){const r=t.reduce((i,o)=>i||e.getData(o),"");return r??n}const Sl={[zf]:{exposeProperties:{files:e=>Array.prototype.slice.call(e.files),items:e=>e.items,dataTransfer:e=>e},matchesTypes:["Files"]},[Uf]:{exposeProperties:{html:(e,t)=>vs(e,t,""),dataTransfer:e=>e},matchesTypes:["Html","text/html"]},[Ff]:{exposeProperties:{urls:(e,t)=>vs(e,t,"").split(` `),dataTransfer:e=>e},matchesTypes:["Url","text/uri-list"]},[$f]:{exposeProperties:{text:(e,t)=>vs(e,t,""),dataTransfer:e=>e},matchesTypes:["Text","text/plain"]}};function nm(e,t){const n=Sl[e];if(!n)throw new Error(`native type ${e} has no configuration`);const r=new tm(n);return r.loadDataTransfer(t),r}function ys(e){if(!e)return null;const t=Array.prototype.slice.call(e.types||[]);return Object.keys(Sl).filter(n=>{const r=Sl[n];return r!=null&&r.matchesTypes?r.matchesTypes.some(i=>t.indexOf(i)>-1):!1})[0]||null}const rm=bf(()=>/firefox/i.test(navigator.userAgent)),Hf=bf(()=>!!window.safari);class Qa{interpolate(t){const{xs:n,ys:r,c1s:i,c2s:o,c3s:s}=this;let l=n.length-1;if(t===n[l])return r[l];let u=0,a=s.length-1,g;for(;u<=a;){g=Math.floor(.5*(u+a));const S=n[g];if(St)a=g-1;else return r[g]}l=Math.max(0,a);const p=t-n[l],f=p*p;return r[l]+i[l]*p+o[l]*f+s[l]*p*f}constructor(t,n){const{length:r}=t,i=[];for(let S=0;St[S]{let O=new Qa([0,.5,1],[u.y,u.y/g*m,u.y+m-g]).interpolate(f);return Hf()&&o&&(O+=(window.devicePixelRatio-1)*m),O},C=()=>new Qa([0,.5,1],[u.x,u.x/a*S,u.x+S-a]).interpolate(p),{offsetX:d,offsetY:c}=i,h=d===0||d,w=c===0||c;return{x:h?d:C(),y:w?c:y()}}let um=class{get window(){if(this.globalContext)return this.globalContext;if(typeof window<"u")return window}get document(){var t;return!((t=this.globalContext)===null||t===void 0)&&t.document?this.globalContext.document:this.window?this.window.document:void 0}get rootElement(){var t;return((t=this.optionsArgs)===null||t===void 0?void 0:t.rootElement)||this.window}constructor(t,n){this.ownerDocument=null,this.globalContext=t,this.optionsArgs=n}};function am(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Ka(e){for(var t=1;t{this.sourcePreviewNodes.delete(t),this.sourcePreviewNodeOptions.delete(t)}}connectDragSource(t,n,r){this.sourceNodes.set(t,n),this.sourceNodeOptions.set(t,r);const i=s=>this.handleDragStart(s,t),o=s=>this.handleSelectStart(s);return n.setAttribute("draggable","true"),n.addEventListener("dragstart",i),n.addEventListener("selectstart",o),()=>{this.sourceNodes.delete(t),this.sourceNodeOptions.delete(t),n.removeEventListener("dragstart",i),n.removeEventListener("selectstart",o),n.setAttribute("draggable","false")}}connectDropTarget(t,n){const r=s=>this.handleDragEnter(s,t),i=s=>this.handleDragOver(s,t),o=s=>this.handleDrop(s,t);return n.addEventListener("dragenter",r),n.addEventListener("dragover",i),n.addEventListener("drop",o),()=>{n.removeEventListener("dragenter",r),n.removeEventListener("dragover",i),n.removeEventListener("drop",o)}}addEventListeners(t){t.addEventListener&&(t.addEventListener("dragstart",this.handleTopDragStart),t.addEventListener("dragstart",this.handleTopDragStartCapture,!0),t.addEventListener("dragend",this.handleTopDragEndCapture,!0),t.addEventListener("dragenter",this.handleTopDragEnter),t.addEventListener("dragenter",this.handleTopDragEnterCapture,!0),t.addEventListener("dragleave",this.handleTopDragLeaveCapture,!0),t.addEventListener("dragover",this.handleTopDragOver),t.addEventListener("dragover",this.handleTopDragOverCapture,!0),t.addEventListener("drop",this.handleTopDrop),t.addEventListener("drop",this.handleTopDropCapture,!0))}removeEventListeners(t){t.removeEventListener&&(t.removeEventListener("dragstart",this.handleTopDragStart),t.removeEventListener("dragstart",this.handleTopDragStartCapture,!0),t.removeEventListener("dragend",this.handleTopDragEndCapture,!0),t.removeEventListener("dragenter",this.handleTopDragEnter),t.removeEventListener("dragenter",this.handleTopDragEnterCapture,!0),t.removeEventListener("dragleave",this.handleTopDragLeaveCapture,!0),t.removeEventListener("dragover",this.handleTopDragOver),t.removeEventListener("dragover",this.handleTopDragOverCapture,!0),t.removeEventListener("drop",this.handleTopDrop),t.removeEventListener("drop",this.handleTopDropCapture,!0))}getCurrentSourceNodeOptions(){const t=this.monitor.getSourceId(),n=this.sourceNodeOptions.get(t);return Ka({dropEffect:this.altKeyPressed?"copy":"move"},n||{})}getCurrentDropEffect(){return this.isDraggingNativeItem()?"copy":this.getCurrentSourceNodeOptions().dropEffect}getCurrentSourcePreviewNodeOptions(){const t=this.monitor.getSourceId(),n=this.sourcePreviewNodeOptions.get(t);return Ka({anchorX:.5,anchorY:.5,captureDraggingState:!1},n||{})}isDraggingNativeItem(){const t=this.monitor.getItemType();return Object.keys(Va).some(n=>Va[n]===t)}beginDragNativeItem(t,n){this.clearCurrentDragSourceNode(),this.currentNativeSource=nm(t,n),this.currentNativeHandle=this.registry.addSource(t,this.currentNativeSource),this.actions.beginDrag([this.currentNativeHandle])}setCurrentDragSourceNode(t){this.clearCurrentDragSourceNode(),this.currentDragSourceNode=t;const n=1e3;this.mouseMoveTimeoutTimer=setTimeout(()=>{var r;return(r=this.rootElement)===null||r===void 0?void 0:r.addEventListener("mousemove",this.endDragIfSourceWasRemovedFromDOM,!0)},n)}clearCurrentDragSourceNode(){if(this.currentDragSourceNode){if(this.currentDragSourceNode=null,this.rootElement){var t;(t=this.window)===null||t===void 0||t.clearTimeout(this.mouseMoveTimeoutTimer||void 0),this.rootElement.removeEventListener("mousemove",this.endDragIfSourceWasRemovedFromDOM,!0)}return this.mouseMoveTimeoutTimer=null,!0}return!1}handleDragStart(t,n){t.defaultPrevented||(this.dragStartSourceIds||(this.dragStartSourceIds=[]),this.dragStartSourceIds.unshift(n))}handleDragEnter(t,n){this.dragEnterTargetIds.unshift(n)}handleDragOver(t,n){this.dragOverTargetIds===null&&(this.dragOverTargetIds=[]),this.dragOverTargetIds.unshift(n)}handleDrop(t,n){this.dropTargetIds.unshift(n)}constructor(t,n,r){this.sourcePreviewNodes=new Map,this.sourcePreviewNodeOptions=new Map,this.sourceNodes=new Map,this.sourceNodeOptions=new Map,this.dragStartSourceIds=null,this.dropTargetIds=[],this.dragEnterTargetIds=[],this.currentNativeSource=null,this.currentNativeHandle=null,this.currentDragSourceNode=null,this.altKeyPressed=!1,this.mouseMoveTimeoutTimer=null,this.asyncEndDragFrameId=null,this.dragOverTargetIds=null,this.lastClientOffset=null,this.hoverRafId=null,this.getSourceClientOffset=i=>{const o=this.sourceNodes.get(i);return o&&Wf(o)||null},this.endDragNativeItem=()=>{this.isDraggingNativeItem()&&(this.actions.endDrag(),this.currentNativeHandle&&this.registry.removeSource(this.currentNativeHandle),this.currentNativeHandle=null,this.currentNativeSource=null)},this.isNodeInDocument=i=>!!(i&&this.document&&this.document.body&&this.document.body.contains(i)),this.endDragIfSourceWasRemovedFromDOM=()=>{const i=this.currentDragSourceNode;i==null||this.isNodeInDocument(i)||(this.clearCurrentDragSourceNode()&&this.monitor.isDragging()&&this.actions.endDrag(),this.cancelHover())},this.scheduleHover=i=>{this.hoverRafId===null&&typeof requestAnimationFrame<"u"&&(this.hoverRafId=requestAnimationFrame(()=>{this.monitor.isDragging()&&this.actions.hover(i||[],{clientOffset:this.lastClientOffset}),this.hoverRafId=null}))},this.cancelHover=()=>{this.hoverRafId!==null&&typeof cancelAnimationFrame<"u"&&(cancelAnimationFrame(this.hoverRafId),this.hoverRafId=null)},this.handleTopDragStartCapture=()=>{this.clearCurrentDragSourceNode(),this.dragStartSourceIds=[]},this.handleTopDragStart=i=>{if(i.defaultPrevented)return;const{dragStartSourceIds:o}=this;this.dragStartSourceIds=null;const s=yi(i);this.monitor.isDragging()&&(this.actions.endDrag(),this.cancelHover()),this.actions.beginDrag(o||[],{publishSource:!1,getSourceClientOffset:this.getSourceClientOffset,clientOffset:s});const{dataTransfer:l}=i,u=ys(l);if(this.monitor.isDragging()){if(l&&typeof l.setDragImage=="function"){const g=this.monitor.getSourceId(),p=this.sourceNodes.get(g),f=this.sourcePreviewNodes.get(g)||p;if(f){const{anchorX:S,anchorY:m,offsetX:y,offsetY:C}=this.getCurrentSourcePreviewNodeOptions(),h=lm(p,f,s,{anchorX:S,anchorY:m},{offsetX:y,offsetY:C});l.setDragImage(f,h.x,h.y)}}try{l==null||l.setData("application/json",{})}catch{}this.setCurrentDragSourceNode(i.target);const{captureDraggingState:a}=this.getCurrentSourcePreviewNodeOptions();a?this.actions.publishDragSource():setTimeout(()=>this.actions.publishDragSource(),0)}else if(u)this.beginDragNativeItem(u);else{if(l&&!l.types&&(i.target&&!i.target.hasAttribute||!i.target.hasAttribute("draggable")))return;i.preventDefault()}},this.handleTopDragEndCapture=()=>{this.clearCurrentDragSourceNode()&&this.monitor.isDragging()&&this.actions.endDrag(),this.cancelHover()},this.handleTopDragEnterCapture=i=>{if(this.dragEnterTargetIds=[],this.isDraggingNativeItem()){var o;(o=this.currentNativeSource)===null||o===void 0||o.loadDataTransfer(i.dataTransfer)}if(!this.enterLeaveCounter.enter(i.target)||this.monitor.isDragging())return;const{dataTransfer:l}=i,u=ys(l);u&&this.beginDragNativeItem(u,l)},this.handleTopDragEnter=i=>{const{dragEnterTargetIds:o}=this;if(this.dragEnterTargetIds=[],!this.monitor.isDragging())return;this.altKeyPressed=i.altKey,o.length>0&&this.actions.hover(o,{clientOffset:yi(i)}),o.some(l=>this.monitor.canDropOnTarget(l))&&(i.preventDefault(),i.dataTransfer&&(i.dataTransfer.dropEffect=this.getCurrentDropEffect()))},this.handleTopDragOverCapture=i=>{if(this.dragOverTargetIds=[],this.isDraggingNativeItem()){var o;(o=this.currentNativeSource)===null||o===void 0||o.loadDataTransfer(i.dataTransfer)}},this.handleTopDragOver=i=>{const{dragOverTargetIds:o}=this;if(this.dragOverTargetIds=[],!this.monitor.isDragging()){i.preventDefault(),i.dataTransfer&&(i.dataTransfer.dropEffect="none");return}this.altKeyPressed=i.altKey,this.lastClientOffset=yi(i),this.scheduleHover(o),(o||[]).some(l=>this.monitor.canDropOnTarget(l))?(i.preventDefault(),i.dataTransfer&&(i.dataTransfer.dropEffect=this.getCurrentDropEffect())):this.isDraggingNativeItem()?i.preventDefault():(i.preventDefault(),i.dataTransfer&&(i.dataTransfer.dropEffect="none"))},this.handleTopDragLeaveCapture=i=>{this.isDraggingNativeItem()&&i.preventDefault(),this.enterLeaveCounter.leave(i.target)&&(this.isDraggingNativeItem()&&setTimeout(()=>this.endDragNativeItem(),0),this.cancelHover())},this.handleTopDropCapture=i=>{if(this.dropTargetIds=[],this.isDraggingNativeItem()){var o;i.preventDefault(),(o=this.currentNativeSource)===null||o===void 0||o.loadDataTransfer(i.dataTransfer)}else ys(i.dataTransfer)&&i.preventDefault();this.enterLeaveCounter.reset()},this.handleTopDrop=i=>{const{dropTargetIds:o}=this;this.dropTargetIds=[],this.actions.hover(o,{clientOffset:yi(i)}),this.actions.drop({dropEffect:this.getCurrentDropEffect()}),this.isDraggingNativeItem()?this.endDragNativeItem():this.monitor.isDragging()&&this.actions.endDrag(),this.cancelHover()},this.handleSelectStart=i=>{const o=i.target;typeof o.dragDrop=="function"&&(o.tagName==="INPUT"||o.tagName==="SELECT"||o.tagName==="TEXTAREA"||o.isContentEditable||(i.preventDefault(),o.dragDrop()))},this.options=new um(n,r),this.actions=t.getActions(),this.monitor=t.getMonitor(),this.registry=t.getRegistry(),this.enterLeaveCounter=new em(this.isNodeInDocument)}}let Si;function dm(){return Si||(Si=new Image,Si.src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="),Si}const fm=function(t,n,r){return new cm(t,n,r)};var Qt;(function(e){e.mouse="mouse",e.touch="touch",e.keyboard="keyboard"})(Qt||(Qt={}));class hm{get delay(){var t;return(t=this.args.delay)!==null&&t!==void 0?t:0}get scrollAngleRanges(){return this.args.scrollAngleRanges}get getDropTargetElementsAtPoint(){return this.args.getDropTargetElementsAtPoint}get ignoreContextMenu(){var t;return(t=this.args.ignoreContextMenu)!==null&&t!==void 0?t:!1}get enableHoverOutsideTarget(){var t;return(t=this.args.enableHoverOutsideTarget)!==null&&t!==void 0?t:!1}get enableKeyboardEvents(){var t;return(t=this.args.enableKeyboardEvents)!==null&&t!==void 0?t:!1}get enableMouseEvents(){var t;return(t=this.args.enableMouseEvents)!==null&&t!==void 0?t:!1}get enableTouchEvents(){var t;return(t=this.args.enableTouchEvents)!==null&&t!==void 0?t:!0}get touchSlop(){return this.args.touchSlop||0}get delayTouchStart(){var t,n,r,i;return(i=(r=(t=this.args)===null||t===void 0?void 0:t.delayTouchStart)!==null&&r!==void 0?r:(n=this.args)===null||n===void 0?void 0:n.delay)!==null&&i!==void 0?i:0}get delayMouseStart(){var t,n,r,i;return(i=(r=(t=this.args)===null||t===void 0?void 0:t.delayMouseStart)!==null&&r!==void 0?r:(n=this.args)===null||n===void 0?void 0:n.delay)!==null&&i!==void 0?i:0}get window(){if(this.context&&this.context.window)return this.context.window;if(typeof window<"u")return window}get document(){var t;if(!((t=this.context)===null||t===void 0)&&t.document)return this.context.document;if(this.window)return this.window.document}get rootElement(){var t;return((t=this.args)===null||t===void 0?void 0:t.rootElement)||this.document}constructor(t,n){this.args=t,this.context=n}}function pm(e,t,n,r){return Math.sqrt(Math.pow(Math.abs(n-e),2)+Math.pow(Math.abs(r-t),2))}function gm(e,t,n,r,i){if(!i)return!1;const o=Math.atan2(r-t,n-e)*180/Math.PI+180;for(let s=0;s=l.start)&&(l.end==null||o<=l.end))return!0}return!1}const mm={Left:1,Right:2,Center:4},vm={Left:0,Center:1,Right:2};function Ss(e){return e.button===void 0||e.button===vm.Left}function ym(e){return e.buttons===void 0||(e.buttons&mm.Left)===0}function Bf(e){return!!e.targetTouches}const Sm=1;function wm(e){const t=e.nodeType===Sm?e:e.parentElement;if(!t)return;const{top:n,left:r}=t.getBoundingClientRect();return{x:r,y:n}}function Cm(e,t){if(e.targetTouches.length===1)return oo(e.targetTouches[0]);if(t&&e.touches.length===1&&e.touches[0].target===t.target)return oo(e.touches[0])}function oo(e,t){return Bf(e)?Cm(e,t):{x:e.clientX,y:e.clientY}}const qa=(()=>{let e=!1;try{addEventListener("test",()=>{},Object.defineProperty({},"passive",{get(){return e=!0,!0}}))}catch{}return e})(),or={[Qt.mouse]:{start:"mousedown",move:"mousemove",end:"mouseup",contextmenu:"contextmenu"},[Qt.touch]:{start:"touchstart",move:"touchmove",end:"touchend"},[Qt.keyboard]:{keydown:"keydown"}};class Er{profile(){var t;return{sourceNodes:this.sourceNodes.size,sourcePreviewNodes:this.sourcePreviewNodes.size,sourcePreviewNodeOptions:this.sourcePreviewNodeOptions.size,targetNodes:this.targetNodes.size,dragOverTargetIds:((t=this.dragOverTargetIds)===null||t===void 0?void 0:t.length)||0}}get document(){return this.options.document}setup(){const t=this.options.rootElement;t&&(N(!Er.isSetUp,"Cannot have two Touch backends at the same time."),Er.isSetUp=!0,this.addEventListener(t,"start",this.getTopMoveStartHandler()),this.addEventListener(t,"start",this.handleTopMoveStartCapture,!0),this.addEventListener(t,"move",this.handleTopMove),this.addEventListener(t,"move",this.handleTopMoveCapture,!0),this.addEventListener(t,"end",this.handleTopMoveEndCapture,!0),this.options.enableMouseEvents&&!this.options.ignoreContextMenu&&this.addEventListener(t,"contextmenu",this.handleTopMoveEndCapture),this.options.enableKeyboardEvents&&this.addEventListener(t,"keydown",this.handleCancelOnEscape,!0))}teardown(){const t=this.options.rootElement;t&&(Er.isSetUp=!1,this._mouseClientOffset={},this.removeEventListener(t,"start",this.handleTopMoveStartCapture,!0),this.removeEventListener(t,"start",this.handleTopMoveStart),this.removeEventListener(t,"move",this.handleTopMoveCapture,!0),this.removeEventListener(t,"move",this.handleTopMove),this.removeEventListener(t,"end",this.handleTopMoveEndCapture,!0),this.options.enableMouseEvents&&!this.options.ignoreContextMenu&&this.removeEventListener(t,"contextmenu",this.handleTopMoveEndCapture),this.options.enableKeyboardEvents&&this.removeEventListener(t,"keydown",this.handleCancelOnEscape,!0),this.uninstallSourceNodeRemovalObserver())}addEventListener(t,n,r,i=!1){const o=qa?{capture:i,passive:!1}:i;this.listenerTypes.forEach(function(s){const l=or[s][n];l&&t.addEventListener(l,r,o)})}removeEventListener(t,n,r,i=!1){const o=qa?{capture:i,passive:!1}:i;this.listenerTypes.forEach(function(s){const l=or[s][n];l&&t.removeEventListener(l,r,o)})}connectDragSource(t,n){const r=this.handleMoveStart.bind(this,t);return this.sourceNodes.set(t,n),this.addEventListener(n,"start",r),()=>{this.sourceNodes.delete(t),this.removeEventListener(n,"start",r)}}connectDragPreview(t,n,r){return this.sourcePreviewNodeOptions.set(t,r),this.sourcePreviewNodes.set(t,n),()=>{this.sourcePreviewNodes.delete(t),this.sourcePreviewNodeOptions.delete(t)}}connectDropTarget(t,n){const r=this.options.rootElement;if(!this.document||!r)return()=>{};const i=o=>{if(!this.document||!r||!this.monitor.isDragging())return;let s;switch(o.type){case or.mouse.move:s={x:o.clientX,y:o.clientY};break;case or.touch.move:var l,u;s={x:((l=o.touches[0])===null||l===void 0?void 0:l.clientX)||0,y:((u=o.touches[0])===null||u===void 0?void 0:u.clientY)||0};break}const a=s!=null?this.document.elementFromPoint(s.x,s.y):void 0,g=a&&n.contains(a);if(a===n||g)return this.handleMove(o,t)};return this.addEventListener(this.document.body,"move",i),this.targetNodes.set(t,n),()=>{this.document&&(this.targetNodes.delete(t),this.removeEventListener(this.document.body,"move",i))}}getTopMoveStartHandler(){return!this.options.delayTouchStart&&!this.options.delayMouseStart?this.handleTopMoveStart:this.handleTopMoveStartDelay}installSourceNodeRemovalObserver(t){this.uninstallSourceNodeRemovalObserver(),this.draggedSourceNode=t,this.draggedSourceNodeRemovalObserver=new MutationObserver(()=>{t&&!t.parentElement&&(this.resurrectSourceNode(),this.uninstallSourceNodeRemovalObserver())}),!(!t||!t.parentElement)&&this.draggedSourceNodeRemovalObserver.observe(t.parentElement,{childList:!0})}resurrectSourceNode(){this.document&&this.draggedSourceNode&&(this.draggedSourceNode.style.display="none",this.draggedSourceNode.removeAttribute("data-reactid"),this.document.body.appendChild(this.draggedSourceNode))}uninstallSourceNodeRemovalObserver(){this.draggedSourceNodeRemovalObserver&&this.draggedSourceNodeRemovalObserver.disconnect(),this.draggedSourceNodeRemovalObserver=void 0,this.draggedSourceNode=void 0}constructor(t,n,r){this.getSourceClientOffset=i=>{const o=this.sourceNodes.get(i);return o&&wm(o)},this.handleTopMoveStartCapture=i=>{Ss(i)&&(this.moveStartSourceIds=[])},this.handleMoveStart=i=>{Array.isArray(this.moveStartSourceIds)&&this.moveStartSourceIds.unshift(i)},this.handleTopMoveStart=i=>{if(!Ss(i))return;const o=oo(i);o&&(Bf(i)&&(this.lastTargetTouchFallback=i.targetTouches[0]),this._mouseClientOffset=o),this.waitingForDelay=!1},this.handleTopMoveStartDelay=i=>{if(!Ss(i))return;const o=i.type===or.touch.start?this.options.delayTouchStart:this.options.delayMouseStart;this.timeout=setTimeout(this.handleTopMoveStart.bind(this,i),o),this.waitingForDelay=!0},this.handleTopMoveCapture=()=>{this.dragOverTargetIds=[]},this.handleMove=(i,o)=>{this.dragOverTargetIds&&this.dragOverTargetIds.unshift(o)},this.handleTopMove=i=>{if(this.timeout&&clearTimeout(this.timeout),!this.document||this.waitingForDelay)return;const{moveStartSourceIds:o,dragOverTargetIds:s}=this,l=this.options.enableHoverOutsideTarget,u=oo(i,this.lastTargetTouchFallback);if(!u)return;if(this._isScrolling||!this.monitor.isDragging()&&gm(this._mouseClientOffset.x||0,this._mouseClientOffset.y||0,u.x,u.y,this.options.scrollAngleRanges)){this._isScrolling=!0;return}if(!this.monitor.isDragging()&&this._mouseClientOffset.hasOwnProperty("x")&&o&&pm(this._mouseClientOffset.x||0,this._mouseClientOffset.y||0,u.x,u.y)>(this.options.touchSlop?this.options.touchSlop:0)&&(this.moveStartSourceIds=void 0,this.actions.beginDrag(o,{clientOffset:this._mouseClientOffset,getSourceClientOffset:this.getSourceClientOffset,publishSource:!1})),!this.monitor.isDragging())return;const a=this.sourceNodes.get(this.monitor.getSourceId());this.installSourceNodeRemovalObserver(a),this.actions.publishDragSource(),i.cancelable&&i.preventDefault();const g=(s||[]).map(m=>this.targetNodes.get(m)).filter(m=>!!m),p=this.options.getDropTargetElementsAtPoint?this.options.getDropTargetElementsAtPoint(u.x,u.y,g):this.document.elementsFromPoint(u.x,u.y),f=[];for(const m in p){if(!p.hasOwnProperty(m))continue;let y=p[m];for(y!=null&&f.push(y);y;)y=y.parentElement,y&&f.indexOf(y)===-1&&f.push(y)}const S=f.filter(m=>g.indexOf(m)>-1).map(m=>this._getDropTargetId(m)).filter(m=>!!m).filter((m,y,C)=>C.indexOf(m)===y);if(l)for(const m in this.targetNodes){const y=this.targetNodes.get(m);if(a&&y&&y.contains(a)&&S.indexOf(m)===-1){S.unshift(m);break}}S.reverse(),this.actions.hover(S,{clientOffset:u})},this._getDropTargetId=i=>{const o=this.targetNodes.keys();let s=o.next();for(;s.done===!1;){const l=s.value;if(i===this.targetNodes.get(l))return l;s=o.next()}},this.handleTopMoveEndCapture=i=>{if(this._isScrolling=!1,this.lastTargetTouchFallback=void 0,!!ym(i)){if(!this.monitor.isDragging()||this.monitor.didDrop()){this.moveStartSourceIds=void 0;return}i.cancelable&&i.preventDefault(),this._mouseClientOffset={},this.uninstallSourceNodeRemovalObserver(),this.actions.drop(),this.actions.endDrag()}},this.handleCancelOnEscape=i=>{i.key==="Escape"&&this.monitor.isDragging()&&(this._mouseClientOffset={},this.uninstallSourceNodeRemovalObserver(),this.actions.endDrag())},this.options=new hm(r,n),this.actions=t.getActions(),this.monitor=t.getMonitor(),this.sourceNodes=new Map,this.sourcePreviewNodes=new Map,this.sourcePreviewNodeOptions=new Map,this.targetNodes=new Map,this.listenerTypes=[],this._mouseClientOffset={},this._isScrolling=!1,this.options.enableMouseEvents&&this.listenerTypes.push(Qt.mouse),this.options.enableTouchEvents&&this.listenerTypes.push(Qt.touch),this.options.enableKeyboardEvents&&this.listenerTypes.push(Qt.keyboard)}}const Em=function(t,n={},r={}){return new Er(t,n,r)},Ur="abcdefgh".split(""),Ri={a8:"bR",b8:"bN",c8:"bB",d8:"bQ",e8:"bK",f8:"bB",g8:"bN",h8:"bR",a7:"bP",b7:"bP",c7:"bP",d7:"bP",e7:"bP",f7:"bP",g7:"bP",h7:"bP",a2:"wP",b2:"wP",c2:"wP",d2:"wP",e2:"wP",f2:"wP",g2:"wP",h2:"wP",a1:"wR",b1:"wN",c1:"wB",d1:"wQ",e1:"wK",f1:"wB",g1:"wN",h1:"wR"},km={a:0,b:1,c:2,d:3,e:4,f:5,g:6,h:7},_m={a:7,b:6,c:5,d:4,e:3,f:2,g:1,h:0},xm=[7,6,5,4,3,2,1,0],Om=[0,1,2,3,4,5,6,7],Ga={wP:v.jsx("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",version:"1.1",width:"45",height:"45"},{children:v.jsx("path",{d:"m 22.5,9 c -2.21,0 -4,1.79 -4,4 0,0.89 0.29,1.71 0.78,2.38 C 17.33,16.5 16,18.59 16,21 c 0,2.03 0.94,3.84 2.41,5.03 C 15.41,27.09 11,31.58 11,39.5 H 34 C 34,31.58 29.59,27.09 26.59,26.03 28.06,24.84 29,23.03 29,21 29,18.59 27.67,16.5 25.72,15.38 26.21,14.71 26.5,13.89 26.5,13 c 0,-2.21 -1.79,-4 -4,-4 z",style:{opacity:"1",fill:"#ffffff",fillOpacity:"1",fillRule:"nonzero",stroke:"#000000",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"miter",strokeMiterlimit:"4",strokeDasharray:"none",strokeOpacity:"1"}})})),wR:v.jsx("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",version:"1.1",width:"45",height:"45"},{children:v.jsxs("g",Object.assign({style:{opacity:"1",fill:"#ffffff",fillOpacity:"1",fillRule:"evenodd",stroke:"#000000",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",strokeMiterlimit:"4",strokeDasharray:"none",strokeOpacity:"1"}},{children:[v.jsx("path",{d:"M 9,39 L 36,39 L 36,36 L 9,36 L 9,39 z ",style:{strokeLinecap:"butt"}}),v.jsx("path",{d:"M 12,36 L 12,32 L 33,32 L 33,36 L 12,36 z ",style:{strokeLinecap:"butt"}}),v.jsx("path",{d:"M 11,14 L 11,9 L 15,9 L 15,11 L 20,11 L 20,9 L 25,9 L 25,11 L 30,11 L 30,9 L 34,9 L 34,14",style:{strokeLinecap:"butt"}}),v.jsx("path",{d:"M 34,14 L 31,17 L 14,17 L 11,14"}),v.jsx("path",{d:"M 31,17 L 31,29.5 L 14,29.5 L 14,17",style:{strokeLinecap:"butt",strokeLinejoin:"miter"}}),v.jsx("path",{d:"M 31,29.5 L 32.5,32 L 12.5,32 L 14,29.5"}),v.jsx("path",{d:"M 11,14 L 34,14",style:{fill:"none",stroke:"#000000",strokeLinejoin:"miter"}})]}))})),wN:v.jsx("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",version:"1.1",width:"45",height:"45"},{children:v.jsxs("g",Object.assign({style:{opacity:"1",fill:"none",fillOpacity:"1",fillRule:"evenodd",stroke:"#000000",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",strokeMiterlimit:"4",strokeDasharray:"none",strokeOpacity:"1"}},{children:[v.jsx("path",{d:"M 22,10 C 32.5,11 38.5,18 38,39 L 15,39 C 15,30 25,32.5 23,18",style:{fill:"#ffffff",stroke:"#000000"}}),v.jsx("path",{d:"M 24,18 C 24.38,20.91 18.45,25.37 16,27 C 13,29 13.18,31.34 11,31 C 9.958,30.06 12.41,27.96 11,28 C 10,28 11.19,29.23 10,30 C 9,30 5.997,31 6,26 C 6,24 12,14 12,14 C 12,14 13.89,12.1 14,10.5 C 13.27,9.506 13.5,8.5 13.5,7.5 C 14.5,6.5 16.5,10 16.5,10 L 18.5,10 C 18.5,10 19.28,8.008 21,7 C 22,7 22,10 22,10",style:{fill:"#ffffff",stroke:"#000000"}}),v.jsx("path",{d:"M 9.5 25.5 A 0.5 0.5 0 1 1 8.5,25.5 A 0.5 0.5 0 1 1 9.5 25.5 z",style:{fill:"#000000",stroke:"#000000"}}),v.jsx("path",{d:"M 15 15.5 A 0.5 1.5 0 1 1 14,15.5 A 0.5 1.5 0 1 1 15 15.5 z",transform:"matrix(0.866,0.5,-0.5,0.866,9.693,-5.173)",style:{fill:"#000000",stroke:"#000000"}})]}))})),wB:v.jsx("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",version:"1.1",width:"45",height:"45"},{children:v.jsxs("g",Object.assign({style:{opacity:"1",fill:"none",fillRule:"evenodd",fillOpacity:"1",stroke:"#000000",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",strokeMiterlimit:"4",strokeDasharray:"none",strokeOpacity:"1"}},{children:[v.jsxs("g",Object.assign({style:{fill:"#ffffff",stroke:"#000000",strokeLinecap:"butt"}},{children:[v.jsx("path",{d:"M 9,36 C 12.39,35.03 19.11,36.43 22.5,34 C 25.89,36.43 32.61,35.03 36,36 C 36,36 37.65,36.54 39,38 C 38.32,38.97 37.35,38.99 36,38.5 C 32.61,37.53 25.89,38.96 22.5,37.5 C 19.11,38.96 12.39,37.53 9,38.5 C 7.65,38.99 6.68,38.97 6,38 C 7.35,36.54 9,36 9,36 z"}),v.jsx("path",{d:"M 15,32 C 17.5,34.5 27.5,34.5 30,32 C 30.5,30.5 30,30 30,30 C 30,27.5 27.5,26 27.5,26 C 33,24.5 33.5,14.5 22.5,10.5 C 11.5,14.5 12,24.5 17.5,26 C 17.5,26 15,27.5 15,30 C 15,30 14.5,30.5 15,32 z"}),v.jsx("path",{d:"M 25 8 A 2.5 2.5 0 1 1 20,8 A 2.5 2.5 0 1 1 25 8 z"})]})),v.jsx("path",{d:"M 17.5,26 L 27.5,26 M 15,30 L 30,30 M 22.5,15.5 L 22.5,20.5 M 20,18 L 25,18",style:{fill:"none",stroke:"#000000",strokeLinejoin:"miter"}})]}))})),wQ:v.jsx("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",version:"1.1",width:"45",height:"45"},{children:v.jsxs("g",Object.assign({style:{fill:"#ffffff",stroke:"#000000",strokeWidth:"1.5",strokeLinejoin:"round"}},{children:[v.jsx("path",{d:"M 9,26 C 17.5,24.5 30,24.5 36,26 L 38.5,13.5 L 31,25 L 30.7,10.9 L 25.5,24.5 L 22.5,10 L 19.5,24.5 L 14.3,10.9 L 14,25 L 6.5,13.5 L 9,26 z"}),v.jsx("path",{d:"M 9,26 C 9,28 10.5,28 11.5,30 C 12.5,31.5 12.5,31 12,33.5 C 10.5,34.5 11,36 11,36 C 9.5,37.5 11,38.5 11,38.5 C 17.5,39.5 27.5,39.5 34,38.5 C 34,38.5 35.5,37.5 34,36 C 34,36 34.5,34.5 33,33.5 C 32.5,31 32.5,31.5 33.5,30 C 34.5,28 36,28 36,26 C 27.5,24.5 17.5,24.5 9,26 z"}),v.jsx("path",{d:"M 11.5,30 C 15,29 30,29 33.5,30",style:{fill:"none"}}),v.jsx("path",{d:"M 12,33.5 C 18,32.5 27,32.5 33,33.5",style:{fill:"none"}}),v.jsx("circle",{cx:"6",cy:"12",r:"2"}),v.jsx("circle",{cx:"14",cy:"9",r:"2"}),v.jsx("circle",{cx:"22.5",cy:"8",r:"2"}),v.jsx("circle",{cx:"31",cy:"9",r:"2"}),v.jsx("circle",{cx:"39",cy:"12",r:"2"})]}))})),wK:v.jsx("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",version:"1.1",width:"45",height:"45"},{children:v.jsxs("g",Object.assign({style:{fill:"none",fillOpacity:"1",fillRule:"evenodd",stroke:"#000000",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",strokeMiterlimit:"4",strokeDasharray:"none",strokeOpacity:"1"}},{children:[v.jsx("path",{d:"M 22.5,11.63 L 22.5,6",style:{fill:"none",stroke:"#000000",strokeLinejoin:"miter"}}),v.jsx("path",{d:"M 20,8 L 25,8",style:{fill:"none",stroke:"#000000",strokeLinejoin:"miter"}}),v.jsx("path",{d:"M 22.5,25 C 22.5,25 27,17.5 25.5,14.5 C 25.5,14.5 24.5,12 22.5,12 C 20.5,12 19.5,14.5 19.5,14.5 C 18,17.5 22.5,25 22.5,25",style:{fill:"#ffffff",stroke:"#000000",strokeLinecap:"butt",strokeLinejoin:"miter"}}),v.jsx("path",{d:"M 12.5,37 C 18,40.5 27,40.5 32.5,37 L 32.5,30 C 32.5,30 41.5,25.5 38.5,19.5 C 34.5,13 25,16 22.5,23.5 L 22.5,27 L 22.5,23.5 C 20,16 10.5,13 6.5,19.5 C 3.5,25.5 12.5,30 12.5,30 L 12.5,37",style:{fill:"#ffffff",stroke:"#000000"}}),v.jsx("path",{d:"M 12.5,30 C 18,27 27,27 32.5,30",style:{fill:"none",stroke:"#000000"}}),v.jsx("path",{d:"M 12.5,33.5 C 18,30.5 27,30.5 32.5,33.5",style:{fill:"none",stroke:"#000000"}}),v.jsx("path",{d:"M 12.5,37 C 18,34 27,34 32.5,37",style:{fill:"none",stroke:"#000000"}})]}))})),bP:v.jsx("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",version:"1.1",width:"45",height:"45"},{children:v.jsx("path",{d:"m 22.5,9 c -2.21,0 -4,1.79 -4,4 0,0.89 0.29,1.71 0.78,2.38 C 17.33,16.5 16,18.59 16,21 c 0,2.03 0.94,3.84 2.41,5.03 C 15.41,27.09 11,31.58 11,39.5 H 34 C 34,31.58 29.59,27.09 26.59,26.03 28.06,24.84 29,23.03 29,21 29,18.59 27.67,16.5 25.72,15.38 26.21,14.71 26.5,13.89 26.5,13 c 0,-2.21 -1.79,-4 -4,-4 z",style:{opacity:"1",fill:"#000000",fillOpacity:"1",fillRule:"nonzero",stroke:"#000000",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"miter",strokeMiterlimit:"4",strokeDasharray:"none",strokeOpacity:"1"}})})),bR:v.jsx("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",version:"1.1",width:"45",height:"45"},{children:v.jsxs("g",Object.assign({style:{opacity:"1",fill:"#000000",fillOpacity:"1",fillRule:"evenodd",stroke:"#000000",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",strokeMiterlimit:"4",strokeDasharray:"none",strokeOpacity:"1"}},{children:[v.jsx("path",{d:"M 9,39 L 36,39 L 36,36 L 9,36 L 9,39 z ",style:{strokeLinecap:"butt"}}),v.jsx("path",{d:"M 12.5,32 L 14,29.5 L 31,29.5 L 32.5,32 L 12.5,32 z ",style:{strokeLinecap:"butt"}}),v.jsx("path",{d:"M 12,36 L 12,32 L 33,32 L 33,36 L 12,36 z ",style:{strokeLinecap:"butt"}}),v.jsx("path",{d:"M 14,29.5 L 14,16.5 L 31,16.5 L 31,29.5 L 14,29.5 z ",style:{strokeLinecap:"butt",strokeLinejoin:"miter"}}),v.jsx("path",{d:"M 14,16.5 L 11,14 L 34,14 L 31,16.5 L 14,16.5 z ",style:{strokeLinecap:"butt"}}),v.jsx("path",{d:"M 11,14 L 11,9 L 15,9 L 15,11 L 20,11 L 20,9 L 25,9 L 25,11 L 30,11 L 30,9 L 34,9 L 34,14 L 11,14 z ",style:{strokeLinecap:"butt"}}),v.jsx("path",{d:"M 12,35.5 L 33,35.5 L 33,35.5",style:{fill:"none",stroke:"#ffffff",strokeWidth:"1",strokeLinejoin:"miter"}}),v.jsx("path",{d:"M 13,31.5 L 32,31.5",style:{fill:"none",stroke:"#ffffff",strokeWidth:"1",strokeLinejoin:"miter"}}),v.jsx("path",{d:"M 14,29.5 L 31,29.5",style:{fill:"none",stroke:"#ffffff",strokeWidth:"1",strokeLinejoin:"miter"}}),v.jsx("path",{d:"M 14,16.5 L 31,16.5",style:{fill:"none",stroke:"#ffffff",strokeWidth:"1",strokeLinejoin:"miter"}}),v.jsx("path",{d:"M 11,14 L 34,14",style:{fill:"none",stroke:"#ffffff",strokeWidth:"1",strokeLinejoin:"miter"}})]}))})),bN:v.jsx("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",version:"1.1",width:"45",height:"45"},{children:v.jsxs("g",Object.assign({style:{opacity:"1",fill:"none",fillOpacity:"1",fillRule:"evenodd",stroke:"#000000",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",strokeMiterlimit:"4",strokeDasharray:"none",strokeOpacity:"1"}},{children:[v.jsx("path",{d:"M 22,10 C 32.5,11 38.5,18 38,39 L 15,39 C 15,30 25,32.5 23,18",style:{fill:"#000000",stroke:"#000000"}}),v.jsx("path",{d:"M 24,18 C 24.38,20.91 18.45,25.37 16,27 C 13,29 13.18,31.34 11,31 C 9.958,30.06 12.41,27.96 11,28 C 10,28 11.19,29.23 10,30 C 9,30 5.997,31 6,26 C 6,24 12,14 12,14 C 12,14 13.89,12.1 14,10.5 C 13.27,9.506 13.5,8.5 13.5,7.5 C 14.5,6.5 16.5,10 16.5,10 L 18.5,10 C 18.5,10 19.28,8.008 21,7 C 22,7 22,10 22,10",style:{fill:"#000000",stroke:"#000000"}}),v.jsx("path",{d:"M 9.5 25.5 A 0.5 0.5 0 1 1 8.5,25.5 A 0.5 0.5 0 1 1 9.5 25.5 z",style:{fill:"#ffffff",stroke:"#ffffff"}}),v.jsx("path",{d:"M 15 15.5 A 0.5 1.5 0 1 1 14,15.5 A 0.5 1.5 0 1 1 15 15.5 z",transform:"matrix(0.866,0.5,-0.5,0.866,9.693,-5.173)",style:{fill:"#ffffff",stroke:"#ffffff"}}),v.jsx("path",{d:"M 24.55,10.4 L 24.1,11.85 L 24.6,12 C 27.75,13 30.25,14.49 32.5,18.75 C 34.75,23.01 35.75,29.06 35.25,39 L 35.2,39.5 L 37.45,39.5 L 37.5,39 C 38,28.94 36.62,22.15 34.25,17.66 C 31.88,13.17 28.46,11.02 25.06,10.5 L 24.55,10.4 z ",style:{fill:"#ffffff",stroke:"none"}})]}))})),bB:v.jsx("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",version:"1.1",width:"45",height:"45"},{children:v.jsxs("g",Object.assign({style:{opacity:"1",fill:"none",fillRule:"evenodd",fillOpacity:"1",stroke:"#000000",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",strokeMiterlimit:"4",strokeDasharray:"none",strokeOpacity:"1"}},{children:[v.jsxs("g",Object.assign({style:{fill:"#000000",stroke:"#000000",strokeLinecap:"butt"}},{children:[v.jsx("path",{d:"M 9,36 C 12.39,35.03 19.11,36.43 22.5,34 C 25.89,36.43 32.61,35.03 36,36 C 36,36 37.65,36.54 39,38 C 38.32,38.97 37.35,38.99 36,38.5 C 32.61,37.53 25.89,38.96 22.5,37.5 C 19.11,38.96 12.39,37.53 9,38.5 C 7.65,38.99 6.68,38.97 6,38 C 7.35,36.54 9,36 9,36 z"}),v.jsx("path",{d:"M 15,32 C 17.5,34.5 27.5,34.5 30,32 C 30.5,30.5 30,30 30,30 C 30,27.5 27.5,26 27.5,26 C 33,24.5 33.5,14.5 22.5,10.5 C 11.5,14.5 12,24.5 17.5,26 C 17.5,26 15,27.5 15,30 C 15,30 14.5,30.5 15,32 z"}),v.jsx("path",{d:"M 25 8 A 2.5 2.5 0 1 1 20,8 A 2.5 2.5 0 1 1 25 8 z"})]})),v.jsx("path",{d:"M 17.5,26 L 27.5,26 M 15,30 L 30,30 M 22.5,15.5 L 22.5,20.5 M 20,18 L 25,18",style:{fill:"none",stroke:"#ffffff",strokeLinejoin:"miter"}})]}))})),bQ:v.jsx("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",version:"1.1",width:"45",height:"45"},{children:v.jsxs("g",Object.assign({style:{fill:"#000000",stroke:"#000000",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}},{children:[v.jsx("path",{d:"M 9,26 C 17.5,24.5 30,24.5 36,26 L 38.5,13.5 L 31,25 L 30.7,10.9 L 25.5,24.5 L 22.5,10 L 19.5,24.5 L 14.3,10.9 L 14,25 L 6.5,13.5 L 9,26 z",style:{strokeLinecap:"butt",fill:"#000000"}}),v.jsx("path",{d:"m 9,26 c 0,2 1.5,2 2.5,4 1,1.5 1,1 0.5,3.5 -1.5,1 -1,2.5 -1,2.5 -1.5,1.5 0,2.5 0,2.5 6.5,1 16.5,1 23,0 0,0 1.5,-1 0,-2.5 0,0 0.5,-1.5 -1,-2.5 -0.5,-2.5 -0.5,-2 0.5,-3.5 1,-2 2.5,-2 2.5,-4 -8.5,-1.5 -18.5,-1.5 -27,0 z"}),v.jsx("path",{d:"M 11.5,30 C 15,29 30,29 33.5,30"}),v.jsx("path",{d:"m 12,33.5 c 6,-1 15,-1 21,0"}),v.jsx("circle",{cx:"6",cy:"12",r:"2"}),v.jsx("circle",{cx:"14",cy:"9",r:"2"}),v.jsx("circle",{cx:"22.5",cy:"8",r:"2"}),v.jsx("circle",{cx:"31",cy:"9",r:"2"}),v.jsx("circle",{cx:"39",cy:"12",r:"2"}),v.jsx("path",{d:"M 11,38.5 A 35,35 1 0 0 34,38.5",style:{fill:"none",stroke:"#000000",strokeLinecap:"butt"}}),v.jsxs("g",Object.assign({style:{fill:"none",stroke:"#ffffff"}},{children:[v.jsx("path",{d:"M 11,29 A 35,35 1 0 1 34,29"}),v.jsx("path",{d:"M 12.5,31.5 L 32.5,31.5"}),v.jsx("path",{d:"M 11.5,34.5 A 35,35 1 0 0 33.5,34.5"}),v.jsx("path",{d:"M 10.5,37.5 A 35,35 1 0 0 34.5,37.5"})]}))]}))})),bK:v.jsx("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",version:"1.1",width:"45",height:"45"},{children:v.jsxs("g",Object.assign({style:{fill:"none",fillOpacity:"1",fillRule:"evenodd",stroke:"#000000",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",strokeMiterlimit:"4",strokeDasharray:"none",strokeOpacity:"1"}},{children:[v.jsx("path",{d:"M 22.5,11.63 L 22.5,6",style:{fill:"none",stroke:"#000000",strokeLinejoin:"miter"},id:"path6570"}),v.jsx("path",{d:"M 22.5,25 C 22.5,25 27,17.5 25.5,14.5 C 25.5,14.5 24.5,12 22.5,12 C 20.5,12 19.5,14.5 19.5,14.5 C 18,17.5 22.5,25 22.5,25",style:{fill:"#000000",fillOpacity:"1",strokeLinecap:"butt",strokeLinejoin:"miter"}}),v.jsx("path",{d:"M 12.5,37 C 18,40.5 27,40.5 32.5,37 L 32.5,30 C 32.5,30 41.5,25.5 38.5,19.5 C 34.5,13 25,16 22.5,23.5 L 22.5,27 L 22.5,23.5 C 20,16 10.5,13 6.5,19.5 C 3.5,25.5 12.5,30 12.5,30 L 12.5,37",style:{fill:"#000000",stroke:"#000000"}}),v.jsx("path",{d:"M 20,8 L 25,8",style:{fill:"none",stroke:"#000000",strokeLinejoin:"miter"}}),v.jsx("path",{d:"M 32,29.5 C 32,29.5 40.5,25.5 38.03,19.85 C 34.15,14 25,18 22.5,24.5 L 22.5,26.6 L 22.5,24.5 C 20,18 10.85,14 6.97,19.85 C 4.5,25.5 13,29.5 13,29.5",style:{fill:"none",stroke:"#ffffff"}}),v.jsx("path",{d:"M 12.5,30 C 18,27 27,27 32.5,30 M 12.5,33.5 C 18,30.5 27,30.5 32.5,33.5 M 12.5,37 C 18,34 27,34 32.5,37",style:{fill:"none",stroke:"#ffffff"}})]}))}))};function wl(e,t,n){const r=t/8,i=e==="white"?km:_m,o=e==="white"?xm:Om,s=i[n[0]]*r+r/2,l=o[parseInt(n[1],10)-1]*r+r/2;return{x:s,y:l}}function Ya(e){let t=!1;return Object.keys(Ri).forEach(n=>{e[n]!==Ri[n]&&(t=!0)}),Object.keys(e).forEach(n=>{Ri[n]!==e[n]&&(t=!0)}),t}function Tm(e,t){const n={removed:{},added:{}};return Object.keys(e).forEach(r=>{t[r]!==e[r]&&(n.removed[r]=e[r])}),Object.keys(t).forEach(r=>{e[r]!==t[r]&&(n.added[r]=t[r])}),n}function Xa(e){return e==="start"?Ri:typeof e=="string"?Dm(e):e}function Dm(e){if(!Pm(e))return{};e=e.replace(/ .+$/,"");const t=e.split("/"),n={};let r=8;for(let i=0;i<8;i++){const o=t[i].split("");let s=0;for(let l=0;l{const[i,o]=E.useState([]),[s,l]=E.useState([]),[u,a]=E.useState();E.useEffect(()=>{Array.isArray(e)&&o(e==null?void 0:e.filter(m=>m[0]!==m[1]))},[e]),E.useEffect(()=>{n==null||n(s)},[s]);function g(){l([]),a(void 0)}const p=(m,y)=>{t&&a([m,y,r])},f=[...s,...i];return{arrows:f,newArrow:u,clearArrows:g,drawNewArrow:p,setArrows:l,onArrowDrawEnd:(m,y)=>{if(m===y||!t)return;let C;const d=[m,y,r];f.every(([h,w])=>!(h===m&&w===y))?C=[...s,d]:C=s.filter(([h,w])=>!(h===m&&w===y)),a(void 0),l(C)}}},Vf=E.createContext({}),_t=()=>E.useContext(Vf),jm=E.forwardRef(({allowDragOutsideBoard:e=!0,animationDuration:t=300,areArrowsAllowed:n=!0,arePiecesDraggable:r=!0,arePremovesAllowed:i=!1,autoPromoteToQueen:o=!1,boardOrientation:s="white",boardWidth:l,children:u,clearPremovesOnRightClick:a=!0,customArrows:g,customArrowColor:p="rgb(255,170,0)",customBoardStyle:f,customDarkSquareStyle:S={backgroundColor:"#B58863"},customDropSquareStyle:m={boxShadow:"inset 0 0 1px 6px rgba(255,255,255,0.75)"},customLightSquareStyle:y={backgroundColor:"#F0D9B5"},customPieces:C,customPremoveDarkSquareStyle:d={backgroundColor:"#A42323"},customPremoveLightSquareStyle:c={backgroundColor:"#BD2828"},customSquare:h="div",customSquareStyles:w,dropOffBoardAction:k="snapback",id:O=0,isDraggablePiece:x=()=>!0,getPositionObject:T=()=>{},onArrowsChange:z=()=>{},onDragOverSquare:M=()=>{},onMouseOutSquare:$=()=>{},onMouseOverSquare:K=()=>{},onPieceClick:Ae=()=>{},onPieceDragBegin:be=()=>{},onPieceDragEnd:qe=()=>{},onPieceDrop:Ce=()=>!0,onPromotionCheck:dt=(Zt,xt,qr)=>(qr==="wP"&&Zt[1]==="7"&&xt[1]==="8"||qr==="bP"&&Zt[1]==="2"&&xt[1]==="1")&&Math.abs(Zt.charCodeAt(0)-xt.charCodeAt(0))<=1,onPromotionPieceSelect:D,onSquareClick:L=()=>{},onSquareRightClick:j=()=>{},position:H="start",promotionDialogVariant:X="default",promotionToSquare:ot=null,showBoardNotation:A=!0,showPromotionDialog:ft=!1,snapToCursor:Ge=!0},vn)=>{const[Zt,xt]=E.useState(Xa(H)),[qr,Zf]=E.useState({removed:{},added:{}}),[Po,yn]=E.useState(void 0),[Jf,Lo]=E.useState(ft&&!o),[eh,Cu]=E.useState(null),[th,Io]=E.useState(ot),[Eu,No]=E.useState([]),Ot=E.useRef(Eu),[jo,Gr]=E.useState(),[nh,rh]=E.useState(Object.assign(Object.assign({},Ga),C)),[ih,Yr]=E.useState(!1),[Ro,oh]=E.useState(),[Xr,Zr]=E.useState(!1);E.useImperativeHandle(vn,()=>({clearPremoves(ee=!0){Jr(ee)}})),E.useEffect(()=>{rh(Object.assign(Object.assign({},Ga),C))},[C]),E.useEffect(()=>{Lo(ft),Io(ot)},[ot,ft]),E.useEffect(()=>{var ee,de,Ye;bo();const De=Xa(H),ht=Tm(Zt,De),Xe=((ee=Object.keys(ht.added))===null||ee===void 0?void 0:ee.length)<=2?(Ye=(de=Object.entries(ht.added))===null||de===void 0?void 0:de[0])===null||Ye===void 0?void 0:Ye[1][0]:void 0;if(Xr)xt(De),Zr(!1),i&&Ao(Xe),Ro&&clearTimeout(Ro);else if(ih)xt(De),Zr(!1),i&&Ao(Xe);else{Ya(De)&&Po!==void 0?yn(Xe):Ya(De)?yn(void 0):yn("b"),Zf(ht),Zr(!0);const gh=setTimeout(()=>{xt(De),Zr(!1),i&&Ao(Xe)},t);oh(gh)}return Yr(!1),T(De),Mo(),()=>{clearTimeout(Ro)}},[H]);const{arrows:sh,newArrow:lh,clearArrows:Mo,drawNewArrow:uh,onArrowDrawEnd:ah}=Nm(g,n,z,p);function ch(ee,de,Ye,De){if(ee===de)return;if(Mo(),i&&Xr||i&&(Po===Ye[0]||Ot.current.filter(Xe=>Xe.piece[0]===Ye[0]).length>0)){const Xe=[...Ot.current];Xe.push({sourceSq:ee,targetSq:de,piece:Ye}),Ot.current=Xe,No([...Xe]),bo();return}if(!i&&Xr)return;const ht=Object.assign({},Zt);Yr(!!De),yn(Ye[0]),Ce.length?Ce(ee,de,Ye)||(Jr(),Yr(!1)):(k==="trash"&&!de&&delete ht[ee],delete ht[ee],ht[de]=Ye,xt(ht)),bo(),T(ht)}function Ao(ee){if(Ot.current.length===0)return;const de=Ot.current[0];if(de.piece[0]!==void 0&&de.piece[0]!==ee&&Ce.length)if(yn(de.piece[0]),Yr(!0),Ce(de.sourceSq,de.targetSq,de.piece)){const De=[...Ot.current];De.shift(),Ot.current=De,No([...De])}else Jr()}function Jr(ee=!0){ee&&yn(void 0),Ot.current=[],No([])}function bo(){Cu(null),Io(null),Lo(!1)}function dh(ee){Gr(ee)}function fh(ee){if(jo){if(jo===ee){Gr(void 0),a&&Jr(!1),j(ee);return}}else Gr(void 0)}function hh(){Gr(void 0)}const ph={animationDuration:t,arePiecesDraggable:r,arePremovesAllowed:i,boardOrientation:s,boardWidth:l,customArrowColor:p,customBoardStyle:f,customDarkSquareStyle:S,customDropSquareStyle:m,customLightSquareStyle:y,customPremoveDarkSquareStyle:d,customPremoveLightSquareStyle:c,customSquare:h,customSquareStyles:w,id:O,isDraggablePiece:x,onDragOverSquare:M,onMouseOutSquare:$,onMouseOverSquare:K,onPieceClick:Ae,onPieceDragBegin:be,onPieceDragEnd:qe,onPieceDrop:Ce,onPromotionCheck:dt,onPromotionPieceSelect:D,onSquareClick:L,showBoardNotation:A,snapToCursor:Ge,promotionDialogVariant:X,allowDragOutsideBoard:e,arrows:sh,newArrow:lh,onArrowDrawEnd:ah,chessPieces:nh,clearArrows:Mo,drawNewArrow:uh,clearCurrentRightClickDown:hh,currentPosition:Zt,handleSetPosition:ch,isWaitingForAnimation:Xr,lastPieceColour:Po,onRightClickDown:dh,onRightClickUp:fh,positionDifferences:qr,promoteFromSquare:eh,promoteToSquare:th,premoves:Eu,setPromoteFromSquare:Cu,setPromoteToSquare:Io,setShowPromoteDialog:Lo,showPromoteDialog:Jf,autoPromoteToQueen:o,currentRightClickDown:jo};return v.jsx(Vf.Provider,Object.assign({value:ph},{children:u}))});function Rm({row:e,col:t}){const{boardOrientation:n,boardWidth:r,customDarkSquareStyle:i,customLightSquareStyle:o}=_t(),s=o.backgroundColor,l=i.backgroundColor,u=t===0,a=e===7,g=u&&a;function p(){return n==="white"?8-e:e+1}function f(){return n==="black"?Ur[7-t]:Ur[t]}function S(){return v.jsxs(v.Fragment,{children:[v.jsx("div",Object.assign({style:Object.assign(Object.assign({zIndex:3,position:"absolute"},{color:s}),Ja(r))},{children:p()})),v.jsx("div",Object.assign({style:Object.assign(Object.assign({zIndex:3,position:"absolute"},{color:s}),Za(r))},{children:f()}))]})}function m(){return v.jsx("div",Object.assign({style:Object.assign(Object.assign({userSelect:"none",zIndex:3,position:"absolute"},{color:t%2!==0?l:s}),Za(r))},{children:f()}))}function y(){return v.jsx("div",Object.assign({style:Object.assign(Object.assign({userSelect:"none",zIndex:3,position:"absolute"},n==="black"?{color:e%2===0?l:s}:{color:e%2===0?l:s}),Ja(r))},{children:p()}))}return g?S():a?m():u?y():null}const Za=e=>({alignSelf:"flex-end",paddingLeft:e/8-e/48,fontSize:e/48}),Ja=e=>({alignSelf:"flex-start",paddingRight:e/8-e/48,fontSize:e/48});function ec({isPremovedPiece:e=!1,piece:t,square:n,squares:r}){const{animationDuration:i,arePiecesDraggable:o,arePremovesAllowed:s,boardWidth:l,boardOrientation:u,chessPieces:a,currentPosition:g,id:p,isDraggablePiece:f,isWaitingForAnimation:S,onPieceClick:m,onPieceDragBegin:y,onPieceDragEnd:C,positionDifferences:d,premoves:c,onPromotionCheck:h}=_t(),[w,k]=E.useState({opacity:1,zIndex:5,touchAction:"none",cursor:o&&f({piece:t,sourceSquare:n})?"-webkit-grab":"default"}),[{canDrag:O,isDragging:x},T,z]=H1(()=>({type:"piece",item:()=>(y(t,n),{piece:t,square:n,id:p}),end:()=>C(t,n),collect:$=>({canDrag:f({piece:t,sourceSquare:n}),isDragging:!!$.isDragging()})}),[t,n,g,p]);z(dm(),{captureDraggingState:!0}),E.useEffect(()=>{k($=>Object.assign(Object.assign({},$),{opacity:x?0:1}))},[x]),E.useEffect(()=>{if(!s)return;let $=!1;!e&&c.find(K=>K.targetSq===n)&&($=!0),c.find(K=>K.sourceSq===n&&K.piece===t)&&($=!0),k(K=>Object.assign(Object.assign({},K),{display:$?"none":"unset"}))},[g,c]),E.useEffect(()=>{var $;const K=($=d.removed)===null||$===void 0?void 0:$[n];if(!d.added||!K)return;const Ae=Object.entries(d.added).find(([be,qe])=>qe===K||h(n,be,K));if(S&&K&&Ae&&!e){const be=n,qe=Ae[0];if(be&&qe){const Ce=l/8;k(dt=>Object.assign(Object.assign({},dt),{transform:`translate(${(u==="black"?-1:1)*(qe.charCodeAt(0)-be.charCodeAt(0))*Ce}px, ${(u==="black"?-1:1)*(Number(be[1])-Number(qe[1]))*Ce}px)`,transition:`transform ${i}ms`,zIndex:6}))}}},[d]),E.useEffect(()=>{const{sourceSq:$}=M();$&&k(K=>Object.assign(Object.assign({},K),{transform:"translate(0px, 0px)",transition:"transform 0ms"}))},[g]),E.useEffect(()=>{k($=>Object.assign(Object.assign({},$),{cursor:o&&f({piece:t,sourceSquare:n})?"-webkit-grab":"default"}))},[n,g,o]);function M(){return{sourceSq:r[n]}}return v.jsx("div",Object.assign({ref:o&&O?T:null,onClick:()=>m(t),"data-piece":t,style:w},{children:typeof a[t]=="function"?a[t]({squareWidth:l/8,isDragging:x,square:n}):v.jsx("svg",Object.assign({viewBox:"1 1 43 43",width:l/8,height:l/8},{children:v.jsx("g",{children:a[t]})}))}))}function Mm({square:e,squareColor:t,setSquares:n,squareHasPremove:r,children:i}){const o=E.useRef(null),{autoPromoteToQueen:s,boardWidth:l,boardOrientation:u,clearArrows:a,currentPosition:g,currentRightClickDown:p,customBoardStyle:f,customDarkSquareStyle:S,customDropSquareStyle:m,customLightSquareStyle:y,customPremoveDarkSquareStyle:C,customPremoveLightSquareStyle:d,customSquare:c,customSquareStyles:h,drawNewArrow:w,handleSetPosition:k,isWaitingForAnimation:O,lastPieceColour:x,onArrowDrawEnd:T,onDragOverSquare:z,onMouseOutSquare:M,onMouseOverSquare:$,onPieceDrop:K,onPromotionCheck:Ae,onRightClickDown:be,onRightClickUp:qe,onSquareClick:Ce,setPromoteFromSquare:dt,setPromoteToSquare:D,setShowPromoteDialog:L}=_t(),[{isOver:j},H]=X1(()=>({accept:"piece",drop:X,collect:A=>({isOver:!!A.isOver()})}),[e,g,K,O,x]);function X(A){Ae(A.square,e,A.piece)?s?k(A.square,e,A.piece[0]==="w"?"wQ":"bQ"):(dt(A.square),D(e),L(!0)):k(A.square,e,A.piece,!0)}E.useEffect(()=>{if(o.current){const{x:A,y:ft}=o.current.getBoundingClientRect();n(Ge=>Object.assign(Object.assign({},Ge),{[e]:{x:A,y:ft}}))}},[l,u]);const ot=Object.assign(Object.assign(Object.assign(Object.assign({},Am(e,u,f)),t==="black"?S:y),r&&(t==="black"?C:d)),j&&m);return v.jsx("div",Object.assign({ref:H,style:ot,"data-square-color":t,"data-square":e,onMouseOver:A=>{A.buttons===2&&p&&w(p,e),!(A.relatedTarget&&A.currentTarget.contains(A.relatedTarget))&&$(e)},onMouseOut:A=>{A.relatedTarget&&A.currentTarget.contains(A.relatedTarget)||M(e)},onMouseDown:A=>{A.button===2&&be(e)},onMouseUp:A=>{A.button===2&&(p&&T(p,e),qe(e))},onDragEnter:()=>z(e),onClick:()=>{Ce(e),a()},onContextMenu:A=>{A.preventDefault()}},{children:typeof c=="string"?v.jsx(c,Object.assign({ref:o,style:Object.assign(Object.assign(Object.assign({},nc(l)),tc),!r&&(h==null?void 0:h[e]))},{children:i})):v.jsx(c,Object.assign({ref:o,square:e,squareColor:t,style:Object.assign(Object.assign(Object.assign({},nc(l)),tc),!r&&(h==null?void 0:h[e]))},{children:i}))}))}const tc={display:"flex",justifyContent:"center"},nc=e=>({width:e/8,height:e/8}),Am=(e,t,n)=>n!=null&&n.borderRadius?e==="a1"?t==="white"?{borderBottomLeftRadius:n.borderRadius}:{borderTopRightRadius:n.borderRadius}:e==="a8"?t==="white"?{borderTopLeftRadius:n.borderRadius}:{borderBottomRightRadius:n.borderRadius}:e==="h1"?t==="white"?{borderBottomRightRadius:n.borderRadius}:{borderTopLeftRadius:n.borderRadius}:e==="h8"?t==="white"?{borderTopRightRadius:n.borderRadius}:{borderBottomLeftRadius:n.borderRadius}:{}:{};function bm(){const[e,t]=E.useState({}),{boardOrientation:n,boardWidth:r,currentPosition:i,id:o,premoves:s,showBoardNotation:l}=_t();return v.jsx("div",Object.assign({"data-boardid":o},{children:[...Array(8)].map((u,a)=>v.jsx("div",Object.assign({style:{display:"flex",flexWrap:"nowrap",width:r}},{children:[...Array(8)].map((g,p)=>{const f=n==="black"?Ur[7-p]+(a+1):Ur[p]+(8-a),S=p%2===a%2?"white":"black",m=s.find(C=>C.sourceSq===f||C.targetSq===f),y=s.find(C=>C.targetSq===f);return v.jsxs(Mm,Object.assign({square:f,squareColor:S,setSquares:t,squareHasPremove:!!m},{children:[i[f]&&v.jsx(ec,{piece:i[f],square:f,squares:e}),y&&v.jsx(ec,{isPremovedPiece:!0,piece:y.piece,square:f,squares:e}),l&&v.jsx(Rm,{row:a,col:p})]}),`${p}${a}`)})}),a.toString()))}))}const zm=()=>{const{arrows:e,newArrow:t,boardOrientation:n,boardWidth:r,customArrowColor:i}=_t(),o=[...e,t].filter(Boolean);return v.jsx("svg",Object.assign({width:r,height:r,style:{position:"absolute",top:"0",left:"0",pointerEvents:"none",zIndex:"10"}},{children:o.map((s,l)=>{const[u,a,g]=s;if(u===a)return null;const p=wl(n,r,u),f=wl(n,r,a);let S=r/32;const m=l===e.length;e.some(h=>h[0]!==u&&h[1]===a)&&!m&&(S=r/16);const y=f.x-p.x,C=f.y-p.y,d=Math.hypot(C,y),c={x:p.x+y*(d-S)/d,y:p.y+C*(d-S)/d};return v.jsxs(E.Fragment,{children:[v.jsx("marker",Object.assign({id:`arrowhead-${l}`,markerWidth:"2",markerHeight:"2.5",refX:"1.25",refY:"1.25",orient:"auto"},{children:v.jsx("polygon",{points:"0.3 0, 2 1.25, 0.3 2.5",fill:g??i})})),v.jsx("line",{x1:p.x,y1:p.y,x2:c.x,y2:c.y,opacity:m?"0.5":"0.65",stroke:g??i,strokeWidth:m?.9*r/40:r/40,markerEnd:`url(#arrowhead-${l})`})]},`${u}-${a}${m?"-active":""}`)})}))};function Fm({option:e}){const[t,n]=E.useState(!1),{boardWidth:r,chessPieces:i,customDarkSquareStyle:o,customLightSquareStyle:s,handleSetPosition:l,onPromotionPieceSelect:u,promoteFromSquare:a,promoteToSquare:g,promotionDialogVariant:p}=_t(),f=()=>{switch(e[1]){case"Q":return o.backgroundColor;case"R":return s.backgroundColor;case"N":return p==="default"?s.backgroundColor:o.backgroundColor;case"B":return p==="default"?o.backgroundColor:s.backgroundColor}};return v.jsx("div",Object.assign({onClick:()=>{u!=null&&u.length?u(e):l(a,g,e,!0)},onMouseOver:()=>n(!0),onMouseOut:()=>n(!1),"data-piece":e,style:{cursor:"pointer",backgroundColor:t?f():`${f()}aa`,borderRadius:"4px",transition:"all 0.1s ease-out"}},{children:typeof i[e]=="function"?v.jsx("div",Object.assign({style:{transition:"all 0.1s ease-out",transform:t?"scale(1)":"scale(0.85)"}},{children:i[e]({squareWidth:r/8,isDragging:!1})})):v.jsx("svg",Object.assign({viewBox:"1 1 43 43",width:r/8,height:r/8,style:{transition:"all 0.1s ease-out",transform:t?"scale(1)":"scale(0.85)"}},{children:v.jsx("g",{children:i[e]})}))}))}function $m(){const{boardOrientation:e,boardWidth:t,promotionDialogVariant:n,promoteToSquare:r}=_t(),i=(r==null?void 0:r[1])==="1"?"b":"w",o=[`${i??"w"}Q`,`${i??"w"}R`,`${i??"w"}N`,`${i??"w"}B`],s={default:{display:"grid",gridTemplateColumns:"1fr 1fr",transform:`translate(${-t/8}px, ${-t/8}px)`},vertical:{transform:`translate(${-t/16}px, ${-t/16}px)`},modal:{display:"flex",justifyContent:"center",alignItems:"center",transform:`translate(0px, ${3*t/8}px)`,width:"100%",height:`${t/4}px`,top:0,backgroundColor:"white",left:0}},l=wl(e,t,r||"a8");return v.jsx("div",Object.assign({style:Object.assign({position:"absolute",top:`${l==null?void 0:l.y}px`,left:`${l==null?void 0:l.x}px`,zIndex:1e3},s[n]),title:"Choose promotion piece"},{children:o.map(u=>v.jsx(Fm,{option:u},u))}))}const Um={whiteKing:v.jsx("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",version:"1.1",style:{shapeRendering:"geometricPrecision",textRendering:"geometricPrecision",imageRendering:"crisp-edges"},viewBox:"0 0 4210 12970",x:"0px",y:"0px",fillRule:"evenodd",clipRule:"evenodd",width:"250",height:"250"},{children:v.jsx("g",{children:v.jsx("path",{style:{fill:"black",fillRule:"nonzero"},d:"M2105 0c169,0 286,160 249,315l200 0c-172,266 -231,479 -256,792 315,-24 530,-86 792,-255l0 897c-265,-171 -479,-231 -792,-256 18,234 75,495 185,682l339 0c233,0 369,269 225,456l545 0 -595 1916c130,94 158,275 59,402 465,0 416,568 51,568l-334 0 465 2867 332 0c250,0 381,306 199,485 162,63 273,220 273,399l0 633 168 0 0 475c-1403,0 -2807,0 -4210,0l0 -475 167 0 0 -633c0,-179 112,-336 274,-399 -181,-178 -52,-485 199,-485l332 0 465 -2867 -335 0c-353,0 -418,-568 51,-568 -98,-127 -70,-308 59,-402l-594 -1916c181,0 363,0 545,0 -144,-187 -9,-456 225,-456l339 0c110,-187 167,-448 185,-682 -315,25 -530,87 -793,256l0 -897c266,171 480,231 793,255 -25,-315 -87,-529 -256,-792l199 0c-36,-155 81,-315 250,-315zm-1994 10012l0 253 3988 0 0 -253c-1330,0 -2659,0 -3988,0zm484 -1060c-174,0 -316,142 -316,316l0 633 3652 0 0 -633c0,-174 -142,-316 -316,-316 -1007,0 -2013,0 -3020,0zm45 -457c-230,0 -225,345 0,345l2930 0c230,0 225,-345 0,-345 -977,0 -1953,0 -2930,0zm2020 -2978l-1111 0 -465 2867 2041 0 -465 -2867zm-1558 -456c-229,0 -224,345 0,345 669,0 1337,0 2005,0 230,0 225,-345 0,-345 -668,0 -1336,0 -2005,0zm1730 -457l-1454 0c-229,0 -224,345 0,345l1454 0c229,0 224,-345 0,-345zm-2064 -1862l544 1751c529,0 1057,0 1586,0l544 -1751c-892,0 -1783,0 -2674,0zm1085 -567l504 0c-126,-247 -163,-526 -177,-800 273,15 553,52 800,177l0 -504c-247,126 -527,163 -800,177 14,-273 51,-552 177,-799 -168,0 -336,0 -504,0 125,247 162,526 177,799 -274,-14 -553,-51 -800,-177l0 504c247,-125 527,-162 800,-177 -15,274 -52,553 -177,800zm969 111l-1434 0c-230,0 -225,345 0,345l1434 0c230,0 225,-345 0,-345zm-717 -2175c-105,0 -175,109 -133,204l266 0c42,-96 -30,-205 -133,-204z"})})}))};function Hm({children:e}){try{return v.jsx(v.Fragment,{children:e})}catch(t){return console.log(t),v.jsx(Qf,{showError:!0})}}function Qf({showError:e=!1}){return v.jsxs("div",Object.assign({style:{display:"flex",justifyContent:"center",alignItems:"center",flexDirection:"column"}},{children:[v.jsx("div",Object.assign({style:{width:250,height:250,transform:"rotate(90deg)"}},{children:Um.whiteKing})),e&&v.jsx("h1",{children:"Something went wrong"})]}))}function Wm(){const e=E.useRef(null),{boardWidth:t,clearCurrentRightClickDown:n,onPromotionPieceSelect:r,setShowPromoteDialog:i,showPromoteDialog:o,customBoardStyle:s}=_t();return E.useEffect(()=>{function l(u){e.current&&!e.current.contains(u.target)&&n()}return document.addEventListener("mouseup",l),()=>{document.removeEventListener("mouseup",l)}},[]),t?v.jsx("div",Object.assign({style:{perspective:"1000px"}},{children:v.jsxs("div",Object.assign({ref:e,style:Object.assign(Object.assign({position:"relative"},Bm(t)),s)},{children:[v.jsx(bm,{}),v.jsx(zm,{}),o&&v.jsxs(v.Fragment,{children:[v.jsx("div",{onClick:()=>{i(!1),r==null||r()},style:{position:"absolute",top:"0",left:"0",zIndex:"100",backgroundColor:"rgba(22,21,18,.7)",width:t,height:t}}),v.jsx($m,{})]})]}))})):v.jsx(Qf,{})}const Bm=e=>({cursor:"default",height:e,width:e});function Vm({boardContainer:e}){const{boardWidth:t,chessPieces:n,id:r,snapToCursor:i,allowDragOutsideBoard:o}=_t(),s=W1(f=>({item:f.getItem(),clientOffset:f.getClientOffset(),sourceClientOffset:f.getSourceClientOffset(),isDragging:f.isDragging()})),{isDragging:l,item:u,clientOffset:a,sourceClientOffset:g}=s,p=E.useCallback((f,S)=>{if(!f||!S)return{display:"none"};let{x:m,y}=i?f:S;const C=t/8/2;if(i&&(m-=C,y-=C),!o){const{left:c,top:h}=e,w=c-C,k=h-C,O=c+t-C,x=h+t-C;m=Math.max(w,Math.min(m,O)),y=Math.max(k,Math.min(y,x))}const d=`translate(${m}px, ${y}px)`;return{transform:d,WebkitTransform:d,touchAction:"none"}},[t,o,i,e]);return l&&u.id===r?v.jsx("div",Object.assign({style:{position:"fixed",pointerEvents:"none",zIndex:10,left:0,top:0}},{children:v.jsx("div",Object.assign({style:p(a,g)},{children:typeof n[u.piece]=="function"?n[u.piece]({squareWidth:t/8,isDragging:!0}):v.jsx("svg",Object.assign({viewBox:"1 1 43 43",width:t/8,height:t/8},{children:v.jsx("g",{children:n[u.piece]})}))}))})):null}const Qm=E.forwardRef((e,t)=>{const{customDndBackend:n,customDndBackendOptions:r}=e,i=rg(e,["customDndBackend","customDndBackendOptions"]),[o,s]=E.useState(),[l,u]=E.useState(!1),[a,g]=E.useState(!1),[p,f]=E.useState(e.boardWidth),S=E.useRef(null),m=E.useRef(null),[y,C]=E.useState({left:0,top:0}),d=E.useMemo(()=>{var h;return(h=S.current)===null||h===void 0?void 0:h.getBoundingClientRect()},[S.current]);E.useEffect(()=>{C({left:d!=null&&d.left?d==null?void 0:d.left:0,top:d!=null&&d.top?d==null?void 0:d.top:0})},[d]),E.useEffect(()=>{g("ontouchstart"in window),u(!0),s(window)},[]),E.useEffect(()=>{var h;if(e.boardWidth===void 0&&(!((h=S.current)===null||h===void 0)&&h.offsetWidth)){const w=new ResizeObserver(()=>{var k;f((k=S.current)===null||k===void 0?void 0:k.offsetWidth)});return w.observe(S.current),()=>{w.disconnect()}}},[S.current,o]);const c=n||(a?Em:fm);return l&&o?v.jsx(Hm,{children:v.jsxs("div",Object.assign({ref:m,style:{display:"flex",flexDirection:"column",width:"100%"}},{children:[v.jsx("div",{ref:S,style:{width:"100%"}}),v.jsx(w1,Object.assign({backend:c,context:o,options:n?r:void 0},{children:p&&v.jsxs(jm,Object.assign({boardWidth:p},i,{ref:t},{children:[v.jsx(Vm,{boardContainer:y}),v.jsx(Wm,{})]}))}))]}))}):null});var rc=globalThis&&globalThis.__awaiter||function(e,t,n,r){function i(o){return o instanceof n?o:new n(function(s){s(o)})}return new(n||(n=Promise))(function(o,s){function l(g){try{a(r.next(g))}catch(p){s(p)}}function u(g){try{a(r.throw(g))}catch(p){s(p)}}function a(g){g.done?o(g.value):i(g.value).then(l,u)}a((r=r.apply(e,t||[])).next())})};const Km=e=>{const[t,n,r]=e.split(":");return{process_name:t,package_name:n,publisher_node:r}};function sr(e){const t=document.cookie.split(";");for(let n=0;nnull,onOpen:s=()=>null,onClose:l=()=>null,onError:u=()=>null}){this._encrypt=a=>null,this._decrypt=a=>{},this.send=({data:a})=>{sr(`kinode-auth_${this.nodeId}`),sr(`kinode-ws-auth_${this.nodeId}`),this._ws.send(ic(a))},this.fetchJson=(a,g)=>rc(this,void 0,void 0,function*(){return console.log("Fetching JSON:",a),yield(yield fetch(a,g)).json()}),this._secret=void 0,this.processId=Km(n),this.channelId=r,this.nodeId=t,this._ws=new WebSocket(i),this._ws.onmessage=a=>rc(this,void 0,void 0,function*(){o(a.data,this)}),this._ws.onopen=a=>{console.log(`${t}`,sr(`kinode-auth_${t}`),sr(`kinode-ws-auth_${t}`)),this._ws.send(ic({auth_token:sr(`kinode-auth_${t}`),target_process:n,encrypted:!1})),s(a,this)},this._ws.onclose=l,this._ws.onerror=u}}const oc=e=>{let t;const n=new Set,r=(u,a)=>{const g=typeof u=="function"?u(t):u;if(!Object.is(g,t)){const p=t;t=a??(typeof g!="object"||g===null)?g:Object.assign({},t,g),n.forEach(f=>f(t,p))}},i=()=>t,l={setState:r,getState:i,subscribe:u=>(n.add(u),()=>n.delete(u)),destroy:()=>{n.clear()}};return t=e(r,i,l),l},Gm=e=>e?oc(e):oc;var Kf={exports:{}},qf={},Gf={exports:{}},Yf={};/** * @license React * use-sync-external-store-shim.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 Qn=E;function Ym(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var Xm=typeof Object.is=="function"?Object.is:Ym,Zm=Qn.useState,Jm=Qn.useEffect,ev=Qn.useLayoutEffect,tv=Qn.useDebugValue;function nv(e,t){var n=t(),r=Zm({inst:{value:n,getSnapshot:t}}),i=r[0].inst,o=r[1];return ev(function(){i.value=n,i.getSnapshot=t,ws(i)&&o({inst:i})},[e,n,t]),Jm(function(){return ws(i)&&o({inst:i}),e(function(){ws(i)&&o({inst:i})})},[e]),tv(n),n}function ws(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!Xm(e,n)}catch{return!0}}function rv(e,t){return t()}var iv=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?rv:nv;Yf.useSyncExternalStore=Qn.useSyncExternalStore!==void 0?Qn.useSyncExternalStore:iv;Gf.exports=Yf;var ov=Gf.exports;/** * @license React * use-sync-external-store-shim/with-selector.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 Do=E,sv=ov;function lv(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var uv=typeof Object.is=="function"?Object.is:lv,av=sv.useSyncExternalStore,cv=Do.useRef,dv=Do.useEffect,fv=Do.useMemo,hv=Do.useDebugValue;qf.useSyncExternalStoreWithSelector=function(e,t,n,r,i){var o=cv(null);if(o.current===null){var s={hasValue:!1,value:null};o.current=s}else s=o.current;o=fv(function(){function u(S){if(!a){if(a=!0,g=S,S=r(S),i!==void 0&&s.hasValue){var m=s.value;if(i(m,S))return p=m}return p=S}if(m=p,uv(g,S))return m;var y=r(S);return i!==void 0&&i(m,y)?m:(g=S,p=y)}var a=!1,g,p,f=n===void 0?null:n;return[function(){return u(t())},f===null?void 0:function(){return u(f())}]},[t,n,r,i]);var l=av(e,o[0],o[1]);return dv(function(){s.hasValue=!0,s.value=l},[l]),hv(l),l};Kf.exports=qf;var pv=Kf.exports;const gv=uc(pv),{useDebugValue:mv}=yc,{useSyncExternalStoreWithSelector:vv}=gv;function yv(e,t=e.getState,n){const r=vv(e.subscribe,e.getState,e.getServerState||e.getState,t,n);return mv(r),r}const sc=e=>{const t=typeof e=="function"?Gm(e):e,n=(r,i)=>yv(t,r,i);return Object.assign(n,t),n},Sv=e=>e?sc(e):sc;function Xf(e,t){let n;try{n=e()}catch{return}return{getItem:i=>{var o;const s=u=>u===null?null:JSON.parse(u,t==null?void 0:t.reviver),l=(o=n.getItem(i))!=null?o:null;return l instanceof Promise?l.then(s):s(l)},setItem:(i,o)=>n.setItem(i,JSON.stringify(o,t==null?void 0:t.replacer)),removeItem:i=>n.removeItem(i)}}const Hr=e=>t=>{try{const n=e(t);return n instanceof Promise?n:{then(r){return Hr(r)(n)},catch(r){return this}}}catch(n){return{then(r){return this},catch(r){return Hr(r)(n)}}}},wv=(e,t)=>(n,r,i)=>{let o={getStorage:()=>localStorage,serialize:JSON.stringify,deserialize:JSON.parse,partialize:C=>C,version:0,merge:(C,d)=>({...d,...C}),...t},s=!1;const l=new Set,u=new Set;let a;try{a=o.getStorage()}catch{}if(!a)return e((...C)=>{console.warn(`[zustand persist middleware] Unable to update item '${o.name}', the given storage is currently unavailable.`),n(...C)},r,i);const g=Hr(o.serialize),p=()=>{const C=o.partialize({...r()});let d;const c=g({state:C,version:o.version}).then(h=>a.setItem(o.name,h)).catch(h=>{d=h});if(d)throw d;return c},f=i.setState;i.setState=(C,d)=>{f(C,d),p()};const S=e((...C)=>{n(...C),p()},r,i);let m;const y=()=>{var C;if(!a)return;s=!1,l.forEach(c=>c(r()));const d=((C=o.onRehydrateStorage)==null?void 0:C.call(o,r()))||void 0;return Hr(a.getItem.bind(a))(o.name).then(c=>{if(c)return o.deserialize(c)}).then(c=>{if(c)if(typeof c.version=="number"&&c.version!==o.version){if(o.migrate)return o.migrate(c.state,c.version);console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return c.state}).then(c=>{var h;return m=o.merge(c,(h=r())!=null?h:S),n(m,!0),p()}).then(()=>{d==null||d(m,void 0),s=!0,u.forEach(c=>c(m))}).catch(c=>{d==null||d(void 0,c)})};return i.persist={setOptions:C=>{o={...o,...C},C.getStorage&&(a=C.getStorage())},clearStorage:()=>{a==null||a.removeItem(o.name)},getOptions:()=>o,rehydrate:()=>y(),hasHydrated:()=>s,onHydrate:C=>(l.add(C),()=>{l.delete(C)}),onFinishHydration:C=>(u.add(C),()=>{u.delete(C)})},y(),m||S},Cv=(e,t)=>(n,r,i)=>{let o={storage:Xf(()=>localStorage),partialize:y=>y,version:0,merge:(y,C)=>({...C,...y}),...t},s=!1;const l=new Set,u=new Set;let a=o.storage;if(!a)return e((...y)=>{console.warn(`[zustand persist middleware] Unable to update item '${o.name}', the given storage is currently unavailable.`),n(...y)},r,i);const g=()=>{const y=o.partialize({...r()});return a.setItem(o.name,{state:y,version:o.version})},p=i.setState;i.setState=(y,C)=>{p(y,C),g()};const f=e((...y)=>{n(...y),g()},r,i);let S;const m=()=>{var y,C;if(!a)return;s=!1,l.forEach(c=>{var h;return c((h=r())!=null?h:f)});const d=((C=o.onRehydrateStorage)==null?void 0:C.call(o,(y=r())!=null?y:f))||void 0;return Hr(a.getItem.bind(a))(o.name).then(c=>{if(c)if(typeof c.version=="number"&&c.version!==o.version){if(o.migrate)return o.migrate(c.state,c.version);console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return c.state}).then(c=>{var h;return S=o.merge(c,(h=r())!=null?h:f),n(S,!0),g()}).then(()=>{d==null||d(S,void 0),S=r(),s=!0,u.forEach(c=>c(S))}).catch(c=>{d==null||d(void 0,c)})};return i.persist={setOptions:y=>{o={...o,...y},y.storage&&(a=y.storage)},clearStorage:()=>{a==null||a.removeItem(o.name)},getOptions:()=>o,rehydrate:()=>m(),hasHydrated:()=>s,onHydrate:y=>(l.add(y),()=>{l.delete(y)}),onFinishHydration:y=>(u.add(y),()=>{u.delete(y)})},o.skipHydration||m(),S||f},Ev=(e,t)=>"getStorage"in t||"serialize"in t||"deserialize"in t?wv(e,t):Cv(e,t),kv=Ev,_v=Sv()(kv((e,t)=>({games:{},handleWsMessage:n=>{if(typeof n=="string")try{const{kind:r,data:i}=JSON.parse(n);r==="game_update"&&e({games:{...t().games,[i.id]:i}})}catch(r){console.error("Error parsing WebSocket message",r)}else{const r=new FileReader;r.onload=function(i){var o;if(typeof((o=i==null?void 0:i.target)==null?void 0:o.result)=="string")try{const{kind:s,data:l}=JSON.parse(i.target.result);s==="game_update"&&e({games:{...t().games,[l.id]:l}})}catch(s){console.error("Error parsing WebSocket message",s)}},r.readAsText(n)}},set:e}),{name:"chess",storage:Xf(()=>localStorage)}));const Mt="/chess:chess:sys";window.our&&(window.our.process=Mt==null?void 0:Mt.replace("/",""));const lc=(e,t)=>(e.turns||0)%2===0?t===e.white:t===e.black,xv=void 0;function Ov(){const{games:e,handleWsMessage:t,set:n}=_v(),[r,i]=E.useState("new"),[o,s]=E.useState(""),l=E.useRef(null),[u,a]=E.useState(560-20),g=new ResizeObserver(d=>{for(let c of d)a(Math.min(c.contentRect.width,c.contentRect.height)-16)});l.current&&g.observe(l.current);const p=E.useMemo(()=>e[r]?{...e[r],game:new ng(e[r].board)}:void 0,[e,r]),f=E.useMemo(()=>((p==null?void 0:p.turns)||0)%2===0?`${p==null?void 0:p.white} (white)`:`${p==null?void 0:p.black} (black)`,[p]);E.useEffect(()=>{new qm({uri:xv,nodeId:window.our.node,processId:window.our.process,onMessage:t}),fetch(`${Mt}/games`).then(d=>d.json()).then(d=>{n({games:d})}).catch(console.error)},[]);const S=E.useCallback(async d=>{d.preventDefault();try{const c=await fetch(`${Mt}/games`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:o})}).then(w=>{if(w.status===409)throw e[o]?i(o):alert("Game already exists, please refresh the page and select it."),new Error("Game already exists");if(w.status===503)throw alert(`${o} may be offline, please confirm it is online and try again.`),new Error("Player offline");if(w.status===400)throw alert("Please enter a valid player ID"),new Error("Invalid player ID");if(w.status>399)throw alert("There was an error creating the game. Please try again."),new Error("Error creating game");return w.json()}),h={...e};h[c.id]=c,n({games:h}),i(o),s("")}catch(c){console.error(c)}},[e,o,s,n]),m=E.useCallback((d,c)=>{if(!p||!lc(p,window.our.node))return!1;const h={from:d,to:c,promotion:"q"},w={...p};if(w.game.move(h)===null)return!1;w.board=w.game.fen();const O={...e};return O[p.id]=w,n({games:O}),fetch(`${Mt}/games`,{method:"PUT",body:JSON.stringify({id:p.id,move:d+c})}).then(x=>x.json()).then(x=>{const T={...e};T[p.id]=x,n({games:T})}).catch(x=>{console.error(x),alert("There was an error making your move. Please try again");const T={...e},z={...p};z.game.undo(),T[p.id]=z,n({games:T})}),!0},[p,e,n]),y=E.useCallback(d=>{d.preventDefault(),d.stopPropagation(),p&&window.confirm("Are you sure you want to resign this game?")&&fetch(`${Mt}/games?id=${p.id}`,{method:"DELETE"}).then(c=>c.json()).then(c=>{const h={...e};h[p.id]=c,n({games:h})}).catch(c=>{console.error(c),alert("There was an error resigning the game. Please try again")})},[p]),C=E.useCallback(async d=>{if(d.preventDefault(),d.stopPropagation(),!!p)try{const c=await fetch(`${Mt}/games`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:p.id})}).then(w=>w.json()),h={...e};h[c.id]=c,n({games:h})}catch(c){console.error(c),alert("You could not create the game. Please make sure your current game with this player (if any) has ended and try again.")}},[p]);return v.jsx("div",{className:"flex flex-col justify-center items-center",style:{height:"100%"},children:v.jsxs("div",{className:"flex flex-col justify-center",style:{maxHeight:"100vh",maxWidth:"800px",height:"100%",width:"100%",position:"relative"},children:[v.jsxs("a",{href:"/",className:"absolute top-6 left-0 ml-2",style:{fontSize:24},onClick:d=>{d.preventDefault(),window.history.back()},children:[v.jsx("span",{style:{fontSize:18,marginBottom:4},children:"◀"})," Back"]}),v.jsxs("h4",{className:"m-4 row justify-center",children:["Chess by",v.jsxs("svg",{width:"180",height:"20",viewBox:"0 0 580 72",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[v.jsxs("g",{"clip-path":"url(#clip0_6_641)",children:[v.jsx("path",{d:"M0.824922 1.07031L0.794922 70.0703H14.7949L14.8049 1.07031H0.824922Z",fill:"#FFF5D9"}),v.jsx("path",{d:"M16.5947 36.8803L41.2547 1.07031H58.2447L33.1647 36.8803L61.2447 70.0703H42.9947L16.5947 36.8803Z",fill:"#FFF5D9"}),v.jsx("path",{d:"M119.885 1.07031H105.765V70.0703H119.885V1.07031Z",fill:"#FFF5D9"}),v.jsx("path",{d:"M173.185 1.07031V70.0703H186.775V26.8303L224.045 70.0703H234.825V1.07031H221.325V45.6803L183.445 1.07031H173.185Z",fill:"#FFF5D9"}),v.jsx("path",{d:"M342.465 8.86C333.025 0.15 321.645 0 318.535 0C315.475 0 303.575 0.22 294.005 9.52C283.845 19.4 283.805 32.24 283.795 35.66C283.785 39.3 283.895 49.03 290.805 57.99C300.855 71.02 316.695 71.31 318.535 71.32C321.375 71.32 334.185 71 343.965 60.66C353.065 51.04 353.265 39.4 353.275 35.66C353.275 32.49 353.305 18.86 342.455 8.86H342.465ZM318.435 58.01C307.095 58.01 297.895 47.95 297.895 35.54C297.895 23.13 307.085 13.07 318.435 13.07C329.785 13.07 338.975 23.13 338.975 35.54C338.975 47.95 329.785 58.01 318.435 58.01Z",fill:"#FFF5D9"}),v.jsx("path",{d:"M450.495 12.0802C444.975 5.46023 437.135 0.990234 427.955 0.990234C417.555 0.990234 405.295 1.07023 402.295 1.07023V69.9802C405.285 69.9802 417.555 70.0602 427.955 70.0602C445.525 70.0602 458.445 53.4102 459.065 36.8602C459.395 28.0102 456.185 18.9002 450.495 12.0802ZM440.085 49.9502C436.895 53.8702 432.705 56.6902 427.665 57.5602C424.025 58.1902 420.095 57.8302 416.405 57.8302C416.405 50.4002 416.405 42.9802 416.405 35.5502V13.2202C423.795 13.2202 430.525 12.7002 436.605 17.6002C440.275 20.5602 442.925 24.7102 444.165 29.2402C444.525 30.5402 444.765 31.8802 444.875 33.2302C445.395 39.3702 443.995 45.1402 440.085 49.9502Z",fill:"#FFF5D9"}),v.jsx("path",{d:"M508.135 0.990234V70.0602H552.715V57.9302H522.035V40.4202H547.125V28.0702H521.995V13.3202H552.715V0.990234H508.135Z",fill:"#FFF5D9"}),v.jsx("path",{d:"M574.835 66.0398H572.745L571.015 63.0698H569.845V66.0398H567.805V57.5498H571.765C572.845 57.5498 573.865 57.9298 574.425 58.9398C575.205 60.3698 574.665 62.3798 573.105 63.0298C573.725 64.1198 574.225 64.9498 574.845 66.0398H574.835ZM570.375 61.0798H570.845C571.335 61.0798 572.365 61.0798 572.365 60.2898C572.365 59.5598 571.335 59.5598 570.845 59.5598H570.375V61.0798Z",fill:"#FFF5D9"}),v.jsx("path",{d:"M570.964 69.0002C574.913 69.0002 578.114 65.799 578.114 61.8502C578.114 57.9014 574.913 54.7002 570.964 54.7002C567.016 54.7002 563.814 57.9014 563.814 61.8502C563.814 65.799 567.016 69.0002 570.964 69.0002Z",stroke:"#FFF5D9","stroke-width":"2.2",strokeMiterlimit:"10"})]}),v.jsx("defs",{children:v.jsx("clipPath",{id:"clip0_6_641",children:v.jsx("rect",{width:"578.41",height:"71.32",fill:"white",transform:"translate(0.794922)"})})})]})]}),v.jsxs("div",{className:"flex flex-row justify-between items-center",style:{height:"100%"},children:[Object.keys(e).length>0&&v.jsxs("div",{className:"flex flex-col games items-center",style:{width:"25%",height:"100%",gap:"1em",padding:"1em"},children:[v.jsx("h4",{className:"m-2",children:"Games"}),v.jsx("button",{className:"small",style:{width:"100%"},onClick:()=>i("new"),children:"New"}),v.jsx("div",{className:"flex flex-col overflow-scroll",style:{width:"100%"},children:Object.values(e).map(d=>v.jsx("div",{onClick:()=>i(d==null?void 0:d.id),className:`game-entry ${r!==(d==null?void 0:d.id)&&lc(d,window.our.node)?"is-turn":""} ${r===(d==null?void 0:d.id)?"selected":""} ${d!=null&&d.ended?"ended":""}`,children:d==null?void 0:d.id},d==null?void 0:d.id))})]}),v.jsx("div",{className:"flex flex-col justify-center items-center game",style:{width:Object.keys(e).length>0?"calc(75% - 16px)":"100%",height:"100%"},ref:l,children:r==="new"||!p?v.jsxs(v.Fragment,{children:[v.jsx("h3",{children:"Start New Game"}),v.jsx("h5",{className:"mb-8 orange-text",children:"(game creator will be white)"}),v.jsxs("form",{onSubmit:S,className:"flex flex-col justify-center mb-40",style:{maxWidth:400},children:[v.jsx("label",{className:"mb-2",style:{alignSelf:"flex-start",fontWeight:"600"},children:"Player ID"}),v.jsx("input",{className:"border rounded p-2 mb-2",style:{minWidth:300},type:"text",placeholder:"Player ID",value:o,onChange:d=>s(d.target.value)}),v.jsx("button",{type:"submit",children:"Start Game"})]})]}):v.jsxs(v.Fragment,{children:[v.jsxs("div",{className:"flex flex-row justify-between items-center w-full px-4 pb-2 gap-4",children:[v.jsx("h4",{children:r}),v.jsx("h5",{children:p!=null&&p.ended?"Game Ended":`Turn: ${f}`}),p!=null&&p.ended?v.jsx("button",{className:"small mt-2",onClick:C,children:"Rematch"}):v.jsx("button",{className:"small mt-2",onClick:y,children:"Resign"})]}),v.jsx("div",{children:v.jsx(Qm,{boardWidth:u-16,position:p==null?void 0:p.game.fen(),onPieceDrop:m,boardOrientation:(p==null?void 0:p.white)===window.our.node?"white":"black"})})]})})]})]})})}Cs.createRoot(document.getElementById("root")).render(v.jsx(yc.StrictMode,{children:v.jsx(Ov,{})}));