(()=>{var Ud=Object.create;var $s=Object.defineProperty;var Hd=Object.getOwnPropertyDescriptor;var Vd=Object.getOwnPropertyNames;var Kd=Object.getPrototypeOf,Qd=Object.prototype.hasOwnProperty;var lt=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(n){throw t=0,n}};var Gd=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Vd(t))!Qd.call(e,i)&&i!==n&&$s(e,i,{get:()=>t[i],enumerable:!(r=Hd(t,i))||r.enumerable});return e};var Lr=(e,t,n)=>(n=e!=null?Ud(Kd(e)):{},Gd(t||!e||!e.__esModule?$s(n,"default",{value:e,enumerable:!0}):n,e));var qs=lt(U=>{"use strict";var Wn=Symbol.for("react.element"),Xd=Symbol.for("react.portal"),Zd=Symbol.for("react.fragment"),Yd=Symbol.for("react.strict_mode"),Jd=Symbol.for("react.profiler"),qd=Symbol.for("react.provider"),ep=Symbol.for("react.context"),tp=Symbol.for("react.forward_ref"),np=Symbol.for("react.suspense"),rp=Symbol.for("react.memo"),ip=Symbol.for("react.lazy"),js=Symbol.iterator;function op(e){return e===null||typeof e!="object"?null:(e=js&&e[js]||e["@@iterator"],typeof e=="function"?e:null)}var Vs={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},Ks=Object.assign,Qs={};function sn(e,t,n){this.props=e,this.context=t,this.refs=Qs,this.updater=n||Vs}sn.prototype.isReactComponent={};sn.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")};sn.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function Gs(){}Gs.prototype=sn.prototype;function ho(e,t,n){this.props=e,this.context=t,this.refs=Qs,this.updater=n||Vs}var mo=ho.prototype=new Gs;mo.constructor=ho;Ks(mo,sn.prototype);mo.isPureReactComponent=!0;var Us=Array.isArray,Xs=Object.prototype.hasOwnProperty,yo={current:null},Zs={key:!0,ref:!0,__self:!0,__source:!0};function Ys(e,t,n){var r,i={},o=null,l=null;if(t!=null)for(r in t.ref!==void 0&&(l=t.ref),t.key!==void 0&&(o=""+t.key),t)Xs.call(t,r)&&!Zs.hasOwnProperty(r)&&(i[r]=t[r]);var a=arguments.length-2;if(a===1)i.children=n;else if(1{"use strict";ea.exports=qs()});var ca=lt(Z=>{"use strict";function wo(e,t){var n=e.length;e.push(t);e:for(;0>>1,i=e[r];if(0>>1;rOr(a,n))uOr(c,a)?(e[r]=c,e[u]=n,r=u):(e[r]=a,e[l]=n,r=l);else if(uOr(c,n))e[r]=c,e[u]=n,r=u;else break e}}return t}function Or(e,t){var n=e.sortIndex-t.sortIndex;return n!==0?n:e.id-t.id}typeof performance=="object"&&typeof performance.now=="function"?(ta=performance,Z.unstable_now=function(){return ta.now()}):(xo=Date,na=xo.now(),Z.unstable_now=function(){return xo.now()-na});var ta,xo,na,st=[],bt=[],cp=1,$e=null,ke=3,Ur=!1,Vt=!1,$n=!1,oa=typeof setTimeout=="function"?setTimeout:null,la=typeof clearTimeout=="function"?clearTimeout:null,ra=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function Eo(e){for(var t=Ye(bt);t!==null;){if(t.callback===null)jr(bt);else if(t.startTime<=e)jr(bt),t.sortIndex=t.expirationTime,wo(st,t);else break;t=Ye(bt)}}function bo(e){if($n=!1,Eo(e),!Vt)if(Ye(st)!==null)Vt=!0,zo(Co);else{var t=Ye(bt);t!==null&&_o(bo,t.startTime-e)}}function Co(e,t){Vt=!1,$n&&($n=!1,la(jn),jn=-1),Ur=!0;var n=ke;try{for(Eo(t),$e=Ye(st);$e!==null&&(!($e.expirationTime>t)||e&&!ua());){var r=$e.callback;if(typeof r=="function"){$e.callback=null,ke=$e.priorityLevel;var i=r($e.expirationTime<=t);t=Z.unstable_now(),typeof i=="function"?$e.callback=i:$e===Ye(st)&&jr(st),Eo(t)}else jr(st);$e=Ye(st)}if($e!==null)var o=!0;else{var l=Ye(bt);l!==null&&_o(bo,l.startTime-t),o=!1}return o}finally{$e=null,ke=n,Ur=!1}}var Hr=!1,$r=null,jn=-1,sa=5,aa=-1;function ua(){return!(Z.unstable_now()-aae||125r?(e.sortIndex=n,wo(bt,e),Ye(st)===null&&e===Ye(bt)&&($n?(la(jn),jn=-1):$n=!0,_o(bo,n-r))):(e.sortIndex=i,wo(st,e),Vt||Ur||(Vt=!0,zo(Co))),e};Z.unstable_shouldYield=ua;Z.unstable_wrapCallback=function(e){var t=ke;return function(){var n=ke;ke=t;try{return e.apply(this,arguments)}finally{ke=n}}}});var pa=lt((J0,da)=>{"use strict";da.exports=ca()});var md=lt(Oe=>{"use strict";var dp=Wr(),Me=pa();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"),Zo=Object.prototype.hasOwnProperty,pp=/^[: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]*$/,fa={},ga={};function fp(e){return Zo.call(ga,e)?!0:Zo.call(fa,e)?!1:pp.test(e)?ga[e]=!0:(fa[e]=!0,!1)}function gp(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 hp(e,t,n,r){if(t===null||typeof t>"u"||gp(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 Fe(e,t,n,r,i,o,l){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=l}var ye={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){ye[e]=new Fe(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];ye[t]=new Fe(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){ye[e]=new Fe(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){ye[e]=new Fe(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){ye[e]=new Fe(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){ye[e]=new Fe(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){ye[e]=new Fe(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){ye[e]=new Fe(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){ye[e]=new Fe(e,5,!1,e.toLowerCase(),null,!1,!1)});var jl=/[\-:]([a-z])/g;function Ul(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(jl,Ul);ye[t]=new Fe(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(jl,Ul);ye[t]=new Fe(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(jl,Ul);ye[t]=new Fe(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){ye[e]=new Fe(e,1,!1,e.toLowerCase(),null,!1,!1)});ye.xlinkHref=new Fe("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){ye[e]=new Fe(e,1,!1,e.toLowerCase(),null,!0,!0)});function Hl(e,t,n,r){var i=ye.hasOwnProperty(t)?ye[t]:null;(i!==null?i.type!==0:r||!(2a||i[l]!==o[a]){var u=` `+i[l].replace(" at new "," at ");return e.displayName&&u.includes("")&&(u=u.replace("",e.displayName)),u}while(1<=l&&0<=a);break}}}finally{To=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?Yn(e):""}function mp(e){switch(e.tag){case 5:return Yn(e.type);case 16:return Yn("Lazy");case 13:return Yn("Suspense");case 19:return Yn("SuspenseList");case 0:case 2:case 15:return e=Po(e.type,!1),e;case 11:return e=Po(e.type.render,!1),e;case 1:return e=Po(e.type,!0),e;default:return""}}function el(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 dn:return"Fragment";case cn:return"Portal";case Yo:return"Profiler";case Vl:return"StrictMode";case Jo:return"Suspense";case qo:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case Su:return(e.displayName||"Context")+".Consumer";case ku:return(e._context.displayName||"Context")+".Provider";case Kl:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case Ql:return t=e.displayName||null,t!==null?t:el(e.type)||"Memo";case zt:t=e._payload,e=e._init;try{return el(e(t))}catch{}}return null}function yp(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 el(t);case 8:return t===Vl?"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 Ot(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function Eu(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function vp(e){var t=Eu(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(l){r=""+l,o.call(this,l)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(l){r=""+l},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function Kr(e){e._valueTracker||(e._valueTracker=vp(e))}function bu(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=Eu(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function ki(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 tl(e,t){var n=t.checked;return ie({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function ma(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=Ot(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 Cu(e,t){t=t.checked,t!=null&&Hl(e,"checked",t,!1)}function nl(e,t){Cu(e,t);var n=Ot(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")?rl(e,t.type,n):t.hasOwnProperty("defaultValue")&&rl(e,t.type,Ot(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function ya(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 rl(e,t,n){(t!=="number"||ki(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var Jn=Array.isArray;function wn(e,t,n,r){if(e=e.options,t){t={};for(var i=0;i"+t.valueOf().toString()+"",t=Qr.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function dr(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var tr={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},xp=["Webkit","ms","Moz","O"];Object.keys(tr).forEach(function(e){xp.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),tr[t]=tr[e]})});function Tu(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||tr.hasOwnProperty(e)&&tr[e]?(""+t).trim():t+"px"}function Pu(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,i=Tu(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,i):e[n]=i}}var kp=ie({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 ll(e,t){if(t){if(kp[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 sl(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 al=null;function Gl(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var ul=null,En=null,bn=null;function ka(e){if(e=Tr(e)){if(typeof ul!="function")throw Error(_(280));var t=e.stateNode;t&&(t=Gi(t),ul(e.stateNode,e.type,t))}}function Nu(e){En?bn?bn.push(e):bn=[e]:En=e}function Ru(){if(En){var e=En,t=bn;if(bn=En=null,ka(e),t)for(e=0;e>>=0,e===0?32:31-(Np(e)/Rp|0)|0}var Gr=64,Xr=4194304;function qn(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 bi(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,i=e.suspendedLanes,o=e.pingedLanes,l=n&268435455;if(l!==0){var a=l&~i;a!==0?r=qn(a):(o&=l,o!==0&&(r=qn(o)))}else l=n&~i,l!==0?r=qn(l):o!==0&&(r=qn(o));if(r===0)return 0;if(t!==0&&t!==r&&(t&i)===0&&(i=r&-r,o=t&-t,i>=o||i===16&&(o&4194240)!==0))return t;if((r&4)!==0&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0n;n++)t.push(e);return t}function _r(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 Dp(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=rr),Ta=" ",Pa=!1;function Ju(e,t){switch(e){case"keyup":return df.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function qu(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var pn=!1;function ff(e,t){switch(e){case"compositionend":return qu(t);case"keypress":return t.which!==32?null:(Pa=!0,Ta);case"textInput":return e=t.data,e===Ta&&Pa?null:e;default:return null}}function gf(e,t){if(pn)return e==="compositionend"||!ns&&Ju(e,t)?(e=Zu(),di=ql=Pt=null,pn=!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=Ia(n)}}function rc(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?rc(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function ic(){for(var e=window,t=ki();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=ki(e.document)}return t}function rs(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 Ef(e){var t=ic(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&rc(n.ownerDocument.documentElement,n)){if(r!==null&&rs(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=Ba(n,o);var l=Ba(n,r);i&&l&&(e.rangeCount!==1||e.anchorNode!==i.node||e.anchorOffset!==i.offset||e.focusNode!==l.node||e.focusOffset!==l.offset)&&(t=t.createRange(),t.setStart(i.node,i.offset),e.removeAllRanges(),o>r?(e.addRange(t),e.extend(l.node,l.offset)):(t.setEnd(l.node,l.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,fn=null,hl=null,or=null,ml=!1;function La(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;ml||fn==null||fn!==ki(r)||(r=fn,"selectionStart"in r&&rs(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}),or&&yr(or,r)||(or=r,r=_i(hl,"onSelect"),0mn||(e.current=wl[mn],wl[mn]=null,mn--)}function Y(e,t){mn++,wl[mn]=e.current,e.current=t}var $t={},be=Ut($t),Ne=Ut(!1),qt=$t;function Tn(e,t){var n=e.type.contextTypes;if(!n)return $t;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 Re(e){return e=e.childContextTypes,e!=null}function Ti(){q(Ne),q(be)}function Ha(e,t,n){if(be.current!==$t)throw Error(_(168));Y(be,t),Y(Ne,n)}function fc(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,yp(e)||"Unknown",i));return ie({},n,r)}function Pi(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||$t,qt=be.current,Y(be,e),Y(Ne,Ne.current),!0}function Va(e,t,n){var r=e.stateNode;if(!r)throw Error(_(169));n?(e=fc(e,t,qt),r.__reactInternalMemoizedMergedChildContext=e,q(Ne),q(be),Y(be,e)):q(Ne),Y(Ne,n)}var gt=null,Xi=!1,$o=!1;function gc(e){gt===null?gt=[e]:gt.push(e)}function If(e){Xi=!0,gc(e)}function Ht(){if(!$o&>!==null){$o=!0;var e=0,t=Q;try{var n=gt;for(Q=1;e>=l,i-=l,ht=1<<32-nt(t)+i|n<F?(D=S,S=null):D=S.sibling;var I=m(f,S,g[F],y);if(I===null){S===null&&(S=D);break}e&&S&&I.alternate===null&&t(f,S),p=o(I,p,F),b===null?x=I:b.sibling=I,b=I,S=D}if(F===g.length)return n(f,S),ee&&Kt(f,F),x;if(S===null){for(;FF?(D=S,S=null):D=S.sibling;var R=m(f,S,I.value,y);if(R===null){S===null&&(S=D);break}e&&S&&R.alternate===null&&t(f,S),p=o(R,p,F),b===null?x=R:b.sibling=R,b=R,S=D}if(I.done)return n(f,S),ee&&Kt(f,F),x;if(S===null){for(;!I.done;F++,I=g.next())I=h(f,I.value,y),I!==null&&(p=o(I,p,F),b===null?x=I:b.sibling=I,b=I);return ee&&Kt(f,F),x}for(S=r(f,S);!I.done;F++,I=g.next())I=v(S,f,F,I.value,y),I!==null&&(e&&I.alternate!==null&&S.delete(I.key===null?F:I.key),p=o(I,p,F),b===null?x=I:b.sibling=I,b=I);return e&&S.forEach(function(z){return t(f,z)}),ee&&Kt(f,F),x}function L(f,p,g,y){if(typeof g=="object"&&g!==null&&g.type===dn&&g.key===null&&(g=g.props.children),typeof g=="object"&&g!==null){switch(g.$$typeof){case Vr:e:{for(var x=g.key,b=p;b!==null;){if(b.key===x){if(x=g.type,x===dn){if(b.tag===7){n(f,b.sibling),p=i(b,g.props.children),p.return=f,f=p;break e}}else if(b.elementType===x||typeof x=="object"&&x!==null&&x.$$typeof===zt&&Ga(x)===b.type){n(f,b.sibling),p=i(b,g.props),p.ref=Qn(f,b,g),p.return=f,f=p;break e}n(f,b);break}else t(f,b);b=b.sibling}g.type===dn?(p=Jt(g.props.children,f.mode,y,g.key),p.return=f,f=p):(y=xi(g.type,g.key,g.props,null,f.mode,y),y.ref=Qn(f,p,g),y.return=f,f=y)}return l(f);case cn:e:{for(b=g.key;p!==null;){if(p.key===b)if(p.tag===4&&p.stateNode.containerInfo===g.containerInfo&&p.stateNode.implementation===g.implementation){n(f,p.sibling),p=i(p,g.children||[]),p.return=f,f=p;break e}else{n(f,p);break}else t(f,p);p=p.sibling}p=Xo(g,f.mode,y),p.return=f,f=p}return l(f);case zt:return b=g._init,L(f,p,b(g._payload),y)}if(Jn(g))return C(f,p,g,y);if(Un(g))return k(f,p,g,y);li(f,g)}return typeof g=="string"&&g!==""||typeof g=="number"?(g=""+g,p!==null&&p.tag===6?(n(f,p.sibling),p=i(p,g),p.return=f,f=p):(n(f,p),p=Go(g,f.mode,y),p.return=f,f=p),l(f)):n(f,p)}return L}var Nn=vc(!0),xc=vc(!1),Ii=Ut(null),Bi=null,xn=null,ss=null;function as(){ss=xn=Bi=null}function us(e){var t=Ii.current;q(Ii),e._currentValue=t}function Cl(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,r!==null&&(r.childLanes|=t)):r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===n)break;e=e.return}}function zn(e,t){Bi=e,ss=xn=null,e=e.dependencies,e!==null&&e.firstContext!==null&&((e.lanes&t)!==0&&(Pe=!0),e.firstContext=null)}function Ke(e){var t=e._currentValue;if(ss!==e)if(e={context:e,memoizedValue:t,next:null},xn===null){if(Bi===null)throw Error(_(308));xn=e,Bi.dependencies={lanes:0,firstContext:e}}else xn=xn.next=e;return t}var Xt=null;function cs(e){Xt===null?Xt=[e]:Xt.push(e)}function kc(e,t,n,r){var i=t.interleaved;return i===null?(n.next=n,cs(t)):(n.next=i.next,i.next=n),t.interleaved=n,kt(e,r)}function kt(e,t){e.lanes|=t;var n=e.alternate;for(n!==null&&(n.lanes|=t),n=e,e=e.return;e!==null;)e.childLanes|=t,n=e.alternate,n!==null&&(n.childLanes|=t),n=e,e=e.return;return n.tag===3?n.stateNode:null}var _t=!1;function ds(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Sc(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function yt(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function Dt(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,(V&2)!==0){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,kt(e,n)}return i=r.interleaved,i===null?(t.next=t,cs(r)):(t.next=i.next,i.next=t),r.interleaved=t,kt(e,n)}function fi(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194240)!==0)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Zl(e,n)}}function Xa(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,o=null;if(n=n.firstBaseUpdate,n!==null){do{var l={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};o===null?i=o=l:o=o.next=l,n=n.next}while(n!==null);o===null?i=o=t:o=o.next=t}else i=o=t;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:o,shared:r.shared,effects:r.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function Li(e,t,n,r){var i=e.updateQueue;_t=!1;var o=i.firstBaseUpdate,l=i.lastBaseUpdate,a=i.shared.pending;if(a!==null){i.shared.pending=null;var u=a,c=u.next;u.next=null,l===null?o=c:l.next=c,l=u;var d=e.alternate;d!==null&&(d=d.updateQueue,a=d.lastBaseUpdate,a!==l&&(a===null?d.firstBaseUpdate=c:a.next=c,d.lastBaseUpdate=u))}if(o!==null){var h=i.baseState;l=0,d=c=u=null,a=o;do{var m=a.lane,v=a.eventTime;if((r&m)===m){d!==null&&(d=d.next={eventTime:v,lane:0,tag:a.tag,payload:a.payload,callback:a.callback,next:null});e:{var C=e,k=a;switch(m=t,v=n,k.tag){case 1:if(C=k.payload,typeof C=="function"){h=C.call(v,h,m);break e}h=C;break e;case 3:C.flags=C.flags&-65537|128;case 0:if(C=k.payload,m=typeof C=="function"?C.call(v,h,m):C,m==null)break e;h=ie({},h,m);break e;case 2:_t=!0}}a.callback!==null&&a.lane!==0&&(e.flags|=64,m=i.effects,m===null?i.effects=[a]:m.push(a))}else v={eventTime:v,lane:m,tag:a.tag,payload:a.payload,callback:a.callback,next:null},d===null?(c=d=v,u=h):d=d.next=v,l|=m;if(a=a.next,a===null){if(a=i.shared.pending,a===null)break;m=a,a=m.next,m.next=null,i.lastBaseUpdate=m,i.shared.pending=null}}while(!0);if(d===null&&(u=h),i.baseState=u,i.firstBaseUpdate=c,i.lastBaseUpdate=d,t=i.shared.interleaved,t!==null){i=t;do l|=i.lane,i=i.next;while(i!==t)}else o===null&&(i.shared.lanes=0);nn|=l,e.lanes=l,e.memoizedState=h}}function Za(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;tn?n:4,e(!0);var r=Uo.transition;Uo.transition={};try{e(!1),t()}finally{Q=n,Uo.transition=r}}function Mc(){return Qe().memoizedState}function Af(e,t,n){var r=Mt(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},Wc(e))Oc(t,n);else if(n=kc(e,t,n,r),n!==null){var i=_e();rt(n,e,r,i),$c(n,t,r)}}function Mf(e,t,n){var r=Mt(e),i={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(Wc(e))Oc(t,i);else{var o=e.alternate;if(e.lanes===0&&(o===null||o.lanes===0)&&(o=t.lastRenderedReducer,o!==null))try{var l=t.lastRenderedState,a=o(l,n);if(i.hasEagerState=!0,i.eagerState=a,it(a,l)){var u=t.interleaved;u===null?(i.next=i,cs(t)):(i.next=u.next,u.next=i),t.interleaved=i;return}}catch{}n=kc(e,t,i,r),n!==null&&(i=_e(),rt(n,e,r,i),$c(n,t,r))}}function Wc(e){var t=e.alternate;return e===re||t!==null&&t===re}function Oc(e,t){lr=Ai=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function $c(e,t,n){if((n&4194240)!==0){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Zl(e,n)}}var Mi={readContext:Ke,useCallback:Se,useContext:Se,useEffect:Se,useImperativeHandle:Se,useInsertionEffect:Se,useLayoutEffect:Se,useMemo:Se,useReducer:Se,useRef:Se,useState:Se,useDebugValue:Se,useDeferredValue:Se,useTransition:Se,useMutableSource:Se,useSyncExternalStore:Se,useId:Se,unstable_isNewReconciler:!1},Wf={readContext:Ke,useCallback:function(e,t){return ut().memoizedState=[e,t===void 0?null:t],e},useContext:Ke,useEffect:Ja,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,hi(4194308,4,Ic.bind(null,t,e),n)},useLayoutEffect:function(e,t){return hi(4194308,4,e,t)},useInsertionEffect:function(e,t){return hi(4,2,e,t)},useMemo:function(e,t){var n=ut();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=ut();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=Af.bind(null,re,e),[r.memoizedState,e]},useRef:function(e){var t=ut();return e={current:e},t.memoizedState=e},useState:Ya,useDebugValue:xs,useDeferredValue:function(e){return ut().memoizedState=e},useTransition:function(){var e=Ya(!1),t=e[0];return e=Df.bind(null,e[1]),ut().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=re,i=ut();if(ee){if(n===void 0)throw Error(_(407));n=n()}else{if(n=t(),ge===null)throw Error(_(349));(tn&30)!==0||Cc(r,t,n)}i.memoizedState=n;var o={value:n,getSnapshot:t};return i.queue=o,Ja(_c.bind(null,r,o,e),[e]),r.flags|=2048,Cr(9,zc.bind(null,r,o,n,t),void 0,null),n},useId:function(){var e=ut(),t=ge.identifierPrefix;if(ee){var n=mt,r=ht;n=(r&~(1<<32-nt(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=Er++,0<\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=l.createElement(n,{is:r.is}):(e=l.createElement(n),n==="select"&&(l=e,r.multiple?l.multiple=!0:r.size&&(l.size=r.size))):e=l.createElementNS(e,n),e[ct]=t,e[kr]=r,Yc(e,t,!1,!1),t.stateNode=e;e:{switch(l=sl(n,r),n){case"dialog":J("cancel",e),J("close",e),i=r;break;case"iframe":case"object":case"embed":J("load",e),i=r;break;case"video":case"audio":for(i=0;iBn&&(t.flags|=128,r=!0,Gn(o,!1),t.lanes=4194304)}else{if(!r)if(e=Di(l),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),Gn(o,!0),o.tail===null&&o.tailMode==="hidden"&&!l.alternate&&!ee)return we(t),null}else 2*le()-o.renderingStartTime>Bn&&n!==1073741824&&(t.flags|=128,r=!0,Gn(o,!1),t.lanes=4194304);o.isBackwards?(l.sibling=t.child,t.child=l):(n=o.last,n!==null?n.sibling=l:t.child=l,o.last=l)}return o.tail!==null?(t=o.tail,o.rendering=t,o.tail=t.sibling,o.renderingStartTime=le(),t.sibling=null,n=ne.current,Y(ne,r?n&1|2:n&1),t):(we(t),null);case 22:case 23:return Cs(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&(t.mode&1)!==0?(Le&1073741824)!==0&&(we(t),t.subtreeFlags&6&&(t.flags|=8192)):we(t),null;case 24:return null;case 25:return null}throw Error(_(156,t.tag))}function Qf(e,t){switch(os(t),t.tag){case 1:return Re(t.type)&&Ti(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Rn(),q(Ne),q(be),gs(),e=t.flags,(e&65536)!==0&&(e&128)===0?(t.flags=e&-65537|128,t):null;case 5:return fs(t),null;case 13:if(q(ne),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(_(340));Pn()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return q(ne),null;case 4:return Rn(),null;case 10:return us(t.type._context),null;case 22:case 23:return Cs(),null;case 24:return null;default:return null}}var ai=!1,Ee=!1,Gf=typeof WeakSet=="function"?WeakSet:Set,N=null;function kn(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){oe(e,t,r)}else n.current=null}function Bl(e,t,n){try{n()}catch(r){oe(e,t,r)}}var uu=!1;function Xf(e,t){if(yl=Ci,e=ic(),rs(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 l=0,a=-1,u=-1,c=0,d=0,h=e,m=null;t:for(;;){for(var v;h!==n||i!==0&&h.nodeType!==3||(a=l+i),h!==o||r!==0&&h.nodeType!==3||(u=l+r),h.nodeType===3&&(l+=h.nodeValue.length),(v=h.firstChild)!==null;)m=h,h=v;for(;;){if(h===e)break t;if(m===n&&++c===i&&(a=l),m===o&&++d===r&&(u=l),(v=h.nextSibling)!==null)break;h=m,m=h.parentNode}h=v}n=a===-1||u===-1?null:{start:a,end:u}}else n=null}n=n||{start:0,end:0}}else n=null;for(vl={focusedElem:e,selectionRange:n},Ci=!1,N=t;N!==null;)if(t=N,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,N=e;else for(;N!==null;){t=N;try{var C=t.alternate;if((t.flags&1024)!==0)switch(t.tag){case 0:case 11:case 15:break;case 1:if(C!==null){var k=C.memoizedProps,L=C.memoizedState,f=t.stateNode,p=f.getSnapshotBeforeUpdate(t.elementType===t.type?k:qe(t.type,k),L);f.__reactInternalSnapshotBeforeUpdate=p}break;case 3:var g=t.stateNode.containerInfo;g.nodeType===1?g.textContent="":g.nodeType===9&&g.documentElement&&g.removeChild(g.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(_(163))}}catch(y){oe(t,t.return,y)}if(e=t.sibling,e!==null){e.return=t.return,N=e;break}N=t.return}return C=uu,uu=!1,C}function sr(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&&Bl(t,n,o)}i=i.next}while(i!==r)}}function Ji(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;e.tag,e=n,typeof t=="function"?t(e):t.current=e}}function ed(e){var t=e.alternate;t!==null&&(e.alternate=null,ed(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[ct],delete t[kr],delete t[Sl],delete t[Nf],delete t[Rf])),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 td(e){return e.tag===5||e.tag===3||e.tag===4}function cu(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||td(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 Dl(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=Fi));else if(r!==4&&(e=e.child,e!==null))for(Dl(e,t,n),e=e.sibling;e!==null;)Dl(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 he=null,et=!1;function Ct(e,t,n){for(n=n.child;n!==null;)nd(e,t,n),n=n.sibling}function nd(e,t,n){if(dt&&typeof dt.onCommitFiberUnmount=="function")try{dt.onCommitFiberUnmount(Hi,n)}catch{}switch(n.tag){case 5:Ee||kn(n,t);case 6:var r=he,i=et;he=null,Ct(e,t,n),he=r,et=i,he!==null&&(et?(e=he,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):he.removeChild(n.stateNode));break;case 18:he!==null&&(et?(e=he,n=n.stateNode,e.nodeType===8?Oo(e.parentNode,n):e.nodeType===1&&Oo(e,n),hr(e)):Oo(he,n.stateNode));break;case 4:r=he,i=et,he=n.stateNode.containerInfo,et=!0,Ct(e,t,n),he=r,et=i;break;case 0:case 11:case 14:case 15:if(!Ee&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){i=r=r.next;do{var o=i,l=o.destroy;o=o.tag,l!==void 0&&((o&2)!==0||(o&4)!==0)&&Bl(n,t,l),i=i.next}while(i!==r)}Ct(e,t,n);break;case 1:if(!Ee&&(kn(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(a){oe(n,t,a)}Ct(e,t,n);break;case 21:Ct(e,t,n);break;case 22:n.mode&1?(Ee=(r=Ee)||n.memoizedState!==null,Ct(e,t,n),Ee=r):Ct(e,t,n);break;default:Ct(e,t,n)}}function du(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new Gf),t.forEach(function(r){var i=i0.bind(null,e,r);n.has(r)||(n.add(r),r.then(i,i))})}}function Je(e,t){var n=t.deletions;if(n!==null)for(var r=0;ri&&(i=l),r&=~o}if(r=i,r=le()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*Yf(r/1960))-r,10e?16:e,Nt===null)var r=!1;else{if(e=Nt,Nt=null,$i=0,(V&6)!==0)throw Error(_(331));var i=V;for(V|=4,N=e.current;N!==null;){var o=N,l=o.child;if((N.flags&16)!==0){var a=o.deletions;if(a!==null){for(var u=0;ule()-Es?Yt(e,0):ws|=n),Ie(e,t)}function cd(e,t){t===0&&((e.mode&1)===0?t=1:(t=Xr,Xr<<=1,(Xr&130023424)===0&&(Xr=4194304)));var n=_e();e=kt(e,t),e!==null&&(_r(e,t,n),Ie(e,n))}function r0(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),cd(e,n)}function i0(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),cd(e,n)}var dd;dd=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||Ne.current)Pe=!0;else{if((e.lanes&n)===0&&(t.flags&128)===0)return Pe=!1,Vf(e,t,n);Pe=(e.flags&131072)!==0}else Pe=!1,ee&&(t.flags&1048576)!==0&&hc(t,Ri,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;mi(e,t),e=t.pendingProps;var i=Tn(t,be.current);zn(t,n),i=ms(null,t,r,e,i,n);var o=ys();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,Re(r)?(o=!0,Pi(t)):o=!1,t.memoizedState=i.state!==null&&i.state!==void 0?i.state:null,ds(t),i.updater=Yi,t.stateNode=i,i._reactInternals=t,_l(t,r,e,n),t=Pl(null,t,r,!0,o,n)):(t.tag=0,ee&&o&&is(t),ze(null,t,i,n),t=t.child),t;case 16:r=t.elementType;e:{switch(mi(e,t),e=t.pendingProps,i=r._init,r=i(r._payload),t.type=r,i=t.tag=l0(r),e=qe(r,e),i){case 0:t=Tl(null,t,r,e,n);break e;case 1:t=lu(null,t,r,e,n);break e;case 11:t=iu(null,t,r,e,n);break e;case 14:t=ou(null,t,r,qe(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:qe(r,i),Tl(e,t,r,i,n);case 1:return r=t.type,i=t.pendingProps,i=t.elementType===r?i:qe(r,i),lu(e,t,r,i,n);case 3:e:{if(Gc(t),e===null)throw Error(_(387));r=t.pendingProps,o=t.memoizedState,i=o.element,Sc(e,t),Li(t,r,null,n);var l=t.memoizedState;if(r=l.element,o.isDehydrated)if(o={element:r,isDehydrated:!1,cache:l.cache,pendingSuspenseBoundaries:l.pendingSuspenseBoundaries,transitions:l.transitions},t.updateQueue.baseState=o,t.memoizedState=o,t.flags&256){i=In(Error(_(423)),t),t=su(e,t,r,n,i);break e}else if(r!==i){i=In(Error(_(424)),t),t=su(e,t,r,n,i);break e}else for(De=Lt(t.stateNode.containerInfo.firstChild),Ae=t,ee=!0,tt=null,n=xc(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(Pn(),r===i){t=St(e,t,n);break e}ze(e,t,r,n)}t=t.child}return t;case 5:return wc(t),e===null&&bl(t),r=t.type,i=t.pendingProps,o=e!==null?e.memoizedProps:null,l=i.children,xl(r,i)?l=null:o!==null&&xl(r,o)&&(t.flags|=32),Qc(e,t),ze(e,t,l,n),t.child;case 6:return e===null&&bl(t),null;case 13:return Xc(e,t,n);case 4:return ps(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=Nn(t,null,r,n):ze(e,t,r,n),t.child;case 11:return r=t.type,i=t.pendingProps,i=t.elementType===r?i:qe(r,i),iu(e,t,r,i,n);case 7:return ze(e,t,t.pendingProps,n),t.child;case 8:return ze(e,t,t.pendingProps.children,n),t.child;case 12:return ze(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,i=t.pendingProps,o=t.memoizedProps,l=i.value,Y(Ii,r._currentValue),r._currentValue=l,o!==null)if(it(o.value,l)){if(o.children===i.children&&!Ne.current){t=St(e,t,n);break e}}else for(o=t.child,o!==null&&(o.return=t);o!==null;){var a=o.dependencies;if(a!==null){l=o.child;for(var u=a.firstContext;u!==null;){if(u.context===r){if(o.tag===1){u=yt(-1,n&-n),u.tag=2;var c=o.updateQueue;if(c!==null){c=c.shared;var d=c.pending;d===null?u.next=u:(u.next=d.next,d.next=u),c.pending=u}}o.lanes|=n,u=o.alternate,u!==null&&(u.lanes|=n),Cl(o.return,n,t),a.lanes|=n;break}u=u.next}}else if(o.tag===10)l=o.type===t.type?null:o.child;else if(o.tag===18){if(l=o.return,l===null)throw Error(_(341));l.lanes|=n,a=l.alternate,a!==null&&(a.lanes|=n),Cl(l,n,t),l=o.sibling}else l=o.child;if(l!==null)l.return=o;else for(l=o;l!==null;){if(l===t){l=null;break}if(o=l.sibling,o!==null){o.return=l.return,l=o;break}l=l.return}o=l}ze(e,t,i.children,n),t=t.child}return t;case 9:return i=t.type,r=t.pendingProps.children,zn(t,n),i=Ke(i),r=r(i),t.flags|=1,ze(e,t,r,n),t.child;case 14:return r=t.type,i=qe(r,t.pendingProps),i=qe(r.type,i),ou(e,t,r,i,n);case 15:return Vc(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,i=t.pendingProps,i=t.elementType===r?i:qe(r,i),mi(e,t),t.tag=1,Re(r)?(e=!0,Pi(t)):e=!1,zn(t,n),jc(t,r,i),_l(t,r,i,n),Pl(null,t,r,!0,e,n);case 19:return Zc(e,t,n);case 22:return Kc(e,t,n)}throw Error(_(156,t.tag))};function pd(e,t){return Wu(e,t)}function o0(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 He(e,t,n,r){return new o0(e,t,n,r)}function _s(e){return e=e.prototype,!(!e||!e.isReactComponent)}function l0(e){if(typeof e=="function")return _s(e)?1:0;if(e!=null){if(e=e.$$typeof,e===Kl)return 11;if(e===Ql)return 14}return 2}function Wt(e,t){var n=e.alternate;return n===null?(n=He(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 xi(e,t,n,r,i,o){var l=2;if(r=e,typeof e=="function")_s(e)&&(l=1);else if(typeof e=="string")l=5;else e:switch(e){case dn:return Jt(n.children,i,o,t);case Vl:l=8,i|=8;break;case Yo:return e=He(12,n,t,i|2),e.elementType=Yo,e.lanes=o,e;case Jo:return e=He(13,n,t,i),e.elementType=Jo,e.lanes=o,e;case qo:return e=He(19,n,t,i),e.elementType=qo,e.lanes=o,e;case wu:return eo(n,i,o,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case ku:l=10;break e;case Su:l=9;break e;case Kl:l=11;break e;case Ql:l=14;break e;case zt:l=16,r=null;break e}throw Error(_(130,e==null?e:typeof e,""))}return t=He(l,n,t,i),t.elementType=e,t.type=r,t.lanes=o,t}function Jt(e,t,n,r){return e=He(7,e,r,t),e.lanes=n,e}function eo(e,t,n,r){return e=He(22,e,r,t),e.elementType=wu,e.lanes=n,e.stateNode={isHidden:!1},e}function Go(e,t,n){return e=He(6,e,null,t),e.lanes=n,e}function Xo(e,t,n){return t=He(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function s0(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=Ro(0),this.expirationTimes=Ro(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ro(0),this.identifierPrefix=r,this.onRecoverableError=i,this.mutableSourceEagerHydrationData=null}function Fs(e,t,n,r,i,o,l,a,u){return e=new s0(e,t,n,a,u),t===1?(t=1,o===!0&&(t|=8)):t=0,o=He(3,null,null,t),e.current=o,o.stateNode=e,o.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},ds(o),e}function a0(e,t,n){var r=3{"use strict";function yd(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(yd)}catch(e){console.error(e)}}yd(),vd.exports=md()});var Sd=lt(Rs=>{"use strict";var kd=xd();Rs.createRoot=kd.createRoot,Rs.hydrateRoot=kd.hydrateRoot;var tg});var Ed=lt(oo=>{"use strict";var f0=Wr(),g0=Symbol.for("react.element"),h0=Symbol.for("react.fragment"),m0=Object.prototype.hasOwnProperty,y0=f0.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,v0={key:!0,ref:!0,__self:!0,__source:!0};function wd(e,t,n){var r,i={},o=null,l=null;n!==void 0&&(o=""+n),t.key!==void 0&&(o=""+t.key),t.ref!==void 0&&(l=t.ref);for(r in t)m0.call(t,r)&&!v0.hasOwnProperty(r)&&(i[r]=t[r]);if(e&&e.defaultProps)for(r in t=e.defaultProps,t)i[r]===void 0&&(i[r]=t[r]);return{$$typeof:g0,type:e,key:o,ref:l,props:i,_owner:y0.current}}oo.Fragment=h0;oo.jsx=wd;oo.jsxs=wd});var Is=lt((ig,bd)=>{"use strict";bd.exports=Ed()});var K0=lt(()=>{var w=Lr(Wr()),Ds=Lr(Sd()),s=Lr(Is());function Bs(e,t=1568,n=.8){return new Promise((r,i)=>{let o=new Image;o.onload=()=>{let{width:l,height:a}=o;if(l>t||a>t){let d=t/Math.max(l,a);l=Math.round(l*d),a=Math.round(a*d)}let u=document.createElement("canvas");u.width=l,u.height=a,u.getContext("2d").drawImage(o,0,0,l,a);let c=u.toDataURL("image/jpeg",n);r({type:"image/jpeg",data:c.split(",")[1]}),URL.revokeObjectURL(o.src)},o.onerror=()=>{URL.revokeObjectURL(o.src),i(new Error("Bild konnte nicht geladen werden"))},o.src=URL.createObjectURL(e)})}var $={token:localStorage.getItem("vangii_token")||null,setToken(e){this.token=e,e?localStorage.setItem("vangii_token",e):localStorage.removeItem("vangii_token")},async post(e,t){if(typeof window<"u"&&window.__MOCK_API__)return window.__MOCK_API__(e,t);let n={"Content-Type":"application/json"};this.token&&(n["X-Auth-Token"]=this.token);let r=await fetch(e,{method:"POST",headers:n,body:JSON.stringify(t)}),i=await r.json();if(r.status===401)throw this.setToken(null),new Error("AUTH");if(!r.ok)throw new Error(i.error||"Fehler");return i},async get(e){let t={};this.token&&(t["X-Auth-Token"]=this.token);let n=await fetch(e,{headers:t}),r=await n.json();if(n.status===401)throw this.setToken(null),new Error("AUTH");if(!n.ok)throw new Error(r.error||"Fehler");return r}};if(typeof document<"u"&&!document.getElementById("vg-anim")){let e=document.createElement("style");e.id="vg-anim",e.textContent="@keyframes vgPop{0%{transform:scale(1)}40%{transform:scale(1.07)}100%{transform:scale(1)}}@keyframes vgShake{0%,100%{transform:translateX(0)}20%{transform:translateX(-7px)}40%{transform:translateX(7px)}60%{transform:translateX(-4px)}80%{transform:translateX(4px)}}@keyframes vgUp{from{opacity:0;transform:translateY(12px)}to{opacity:1;transform:translateY(0)}}@keyframes vgPulse{0%,100%{transform:scale(1)}50%{transform:scale(1.15)}}",document.head.appendChild(e)}var Ls=[{name:"🌱 Anfänger",min:0},{name:"🔍 Entdecker",min:31},{name:"⚡ Profi",min:81},{name:"🏆 Champion",min:151},{name:"🚀 Superstar",min:301}],x0=e=>[...Ls].reverse().find(t=>e>=t.min)||Ls[0],k0=e=>Ls.find(t=>t.min>e),Et=[{key:"englisch",label:"Englisch",icon:"🇬🇧",persona:"Miss Poppy",personaEmoji:"👩‍🏫",gradient:"linear-gradient(135deg, #6366f1, #4f46e5)",accent:"#a5b4fc",bgTint:"rgba(99,102,241,0.15)",exerciseLabels:{vocab:"Vokabeln",grammar:"Grammatik"},quickActions:["Vokabeln üben 📝","Grammatik üben 📐","Klausur üben 📋","Neues Kapitel 📸"]},{key:"deutsch",label:"Deutsch",icon:"📖",persona:"Frau Lotte",personaEmoji:"👩‍🏫",gradient:"linear-gradient(135deg, #ec4899, #be185d)",accent:"#fbcfe8",bgTint:"rgba(236,72,153,0.15)",exerciseLabels:{vocab:"Rechtschreibung",grammar:"Grammatik"},quickActions:["Rechtschreibung ✏️","Grammatik üben 📐","Klausur üben 📋","Neues Kapitel 📸"]},{key:"mathe",label:"Mathe",icon:"🔢",persona:"Professor Pi",personaEmoji:"🧑‍🏫",gradient:"linear-gradient(135deg, #10b981, #047857)",accent:"#a7f3d0",bgTint:"rgba(16,185,129,0.15)",exerciseLabels:{vocab:"Rechnen",grammar:"Textaufgaben"},quickActions:["Kopfrechnen 🧠","Textaufgaben 📝","Klausur üben 📋","Neues Kapitel 📸"]}],Ge=e=>Et.find(t=>t.key===e)||Et[0];function As(e,t){return`=== LEHRMETHODE - hat IMMER Vorrang vor den Detail-Regeln weiter unten === Du bist eine Weltklasse-Lehrkraft mit begrenzter Zeit. Ziel: ${e} im aktuellen Thema WIRKLICH handlungsfähig machen - nicht Stoff abspulen. Keine Theorie ohne sofortigen Praxisbezug. (A) NEUES THEMA - zuerst die 3 Strategie-Fragen (kurz, zusammen 3-5 Sätze): - Was lernen wir ZUERST - und warum genau das? (das Fundament, ohne das nichts geht) - Was lassen wir bewusst WEG - und warum ist das schlau? (nimmt Druck raus) - Welche EINE Übung bringt ${e} sofort weiter als die meisten? (der Hebel) Danach sofort loslegen. (B) EIN KONZEPT ERKLÄREN - die einfachste Logik: - Nenne den EINEN Satz, den ${e} verstehen muss, damit der Rest von selbst Sinn ergibt. - Erkläre NUR diesen Satz - mit einer alltagsnahen Analogie. Kein Fachbegriff ohne sofortige Erklärung. - Stelle dann GENAU 3 Verständnisfragen, die nur jemand richtig beantwortet, der es wirklich durchdrungen hat. - Mach erst weiter, wenn ${e} alle 3 richtig hat. Bei Fehler: zurück zur Analogie, neue Frage. (C) ÜBEN - Situation statt Vortrag, Fehler als Werkzeug: - Erkläre nicht lang vorweg. Bring ${e} direkt in eine realistische Situation, in der das Konzept angewendet werden muss - eine, in der Anfänger typischerweise einen bestimmten Fehler machen. - Bei einem Fehler: gib NICHT die Lösung. Stelle eine gezielte Rückfrage, die ${e} zwingt, den eigenen Denkfehler selbst zu finden. - Die Lösung gibt es erst nach MINDESTENS 2 eigenen Versuchen. Wiederhole, bis ${e} das Konzept ohne Zögern korrekt anwendet. - Echtes, konkretes Lob bei Fortschritt - nie Punkte abziehen. (D) WENN ${e} TROTZDEM HÄNGT - geprüftes Erklärvideo: Kommt ${e} nach 2-3 Versuchen nicht weiter, biete ein Video an. Schreibe dann eine eigene Zeile im Format: [YOUTUBE:suchbegriff|Kanal] Beispiel: [YOUTUBE:das aktuelle Thema einfach erklärt|${t.split(",")[0].trim()}] Geprüfte Kanäle für dieses Fach: ${t}. Behalte dabei das Punkte-System (+X ⭐), die Zwischenrunden und das Session-Ende-JSON wie unten beschrieben bei.`}function S0({term:e,channel:t}){let r="https://www.youtube.com/results?search_query="+encodeURIComponent([t,e].filter(Boolean).join(" ")),i=t?t+": "+e:e||"Erklärvideo";return(0,s.jsx)("a",{href:r,target:"_blank",rel:"noopener noreferrer",style:{display:"inline-flex",alignItems:"center",gap:"6px",textDecoration:"none",padding:"6px 10px",margin:"4px 0",borderRadius:"8px",background:"rgba(239,68,68,0.12)",border:"1px solid rgba(239,68,68,0.35)",color:"#fca5a5",fontSize:"12px",fontWeight:600},children:"▶️ "+i})}function w0(e,t,n,r){let i;return e==="deutsch"?i=b0(t,n):e==="mathe"?i=C0(t,n):i=E0(t,n),r>0&&(i+=` BUCHSEITEN-REFERENZ: Es gibt ${r} Buchseiten als Bilder. Wenn du auf eine Buchseite verweisen willst (z.B. Grafik, Tabelle, Beispiel im Buch), schreibe [SEITE:X] wobei X die Seitennummer (1-${r}) ist. Die Schülerin sieht dann die Buchseite direkt im Chat als Bild. Nutze das aktiv! Verweise auf Buchseiten wenn es zum Thema passt, z.B.: - "Schau dir die Hieroglyphen auf [SEITE:2] an" - "Die Grammatik-Tabelle findest du auf [SEITE:3]" - "Vergleiche mit dem Beispiel auf [SEITE:1]"`),i}function E0(e,t){return`Du bist Miss Poppy — ${e}s persönliche Englisch-Lernbegleiterin. ${e} ist Schüler/in, 6. Klasse Gymnasium. ${As(e,"musstewissen Englisch, Sofatutor")} REGELN: - Freundlich, geduldig, enthusiastisch — nenne sie/ihn IMMER "${e}" - EINE Aufgabe auf einmal, keine Textwände - Erkläre auf Deutsch, übe auf Englisch - Viel echtes, konkretes Lob (nicht nur "Gut gemacht") - Fehler: nie Punkte abziehen, erst ermutigen, dann erklären, Eselsbrücken anbieten - Nach jeweils 5 Aufgaben: automatisch Pause anbieten - Insgesamt ca. 10-15 Aufgaben pro Session PUNKTE — KRITISCH, bei JEDER richtigen Antwort MUSST du EXAKT dieses Format schreiben: +2 ⭐ (einfache Vokabel) | +3 ⭐ (schwere Vokabel) | +3 ⭐ (Grammatik) | +4 ⭐ (kreativer Satz) | +1 ⭐ (beim 2. Versuch) IMMER das Pluszeichen, die Zahl und den Stern schreiben, z.B.: "Super! +2 ⭐" oder "Perfekt, ${e}! +3 ⭐" NIEMALS die Punkte weglassen oder anders formatieren! Die App zählt sie automatisch. ÜBUNGSTYPEN — PFLICHT: Nie 2x denselben Typ hintereinander! Wechsle IMMER ab zwischen: 1. Deutsch→Englisch 2. Englisch→Deutsch 3. Lückentext 4. Multiple Choice 5. Satz bilden 6. Fehler finden 7. Satz umformen 8. Welches Wort passt nicht? 9. Speed-Übersetzen 10. Kreativ-Satz ZWISCHENRUNDEN (PFLICHT!): - Nach jeder 5. Vokabel: Blitz-Runde → Alle 5 schnell nochmal abfragen - Nach jeder 10. Vokabel: Power-Check → Liste mit ✅/🔄, dann schwache nochmal SESSION-ENDE (PFLICHT!): Übersicht ALLER gelernten Vokabeln mit ✅/❌ + motivierender Abschluss ${t||""} KLAUSUR-MODUS (bei "Klausur üben"): Simuliere eine realistische Klassenarbeit über ALLE Sessions. Gemischte Aufgabentypen, ca. 15-20 Aufgaben, kein sofortiges Feedback, Auswertung mit Note am Ende. Punkte: +2 ⭐ pro richtig, +1 ⭐ bei teilweise richtig. topic="Klausur-Simulation" SESSION-ABLAUF: 1. Begrüße ${e}, sage Session-Nr und Thema 2. Starte mit 2-3 leichten Aufwärm-Vokabeln 3. Wechsle JEDEN Übungstyp — NIE 2x dasselbe hintereinander! 4. Nach 5 Vokabeln: PFLICHT Blitz-Runde 5. Nach 5 Aufgaben: Pause anbieten 6. Nach 10 Vokabeln: PFLICHT Power-Check 7. Am Ende: PFLICHT Komplett-Übersicht mit ✅/❌ WENN "Session beenden"/"fertig"/"Schluss"/"genug jetzt": Zusammenfassung + am Ende JSON: \`\`\`json {"pointsEarned":X,"vocabCorrect":X,"vocabTotal":X,"grammarCorrect":X,"grammarTotal":X,"weakItems":["..."],"strongItems":["..."],"teacherNote":"...","recommendation":"...","topic":"Session X — Thema"} \`\`\``}function b0(e,t){return`Du bist Frau Lotte — ${e}s persönliche Deutsch-Lernbegleiterin. ${e} ist Schüler/in, 6. Klasse Gymnasium. PERSÖNLICHKEIT: Warmherzig, klassisch, geduldig. Liebt Sprache und gute Geschichten. ${As(e,"musstewissen Deutsch, Die Merkhilfe")} REGELN: - Freundlich, ermutigend — nenne sie/ihn IMMER "${e}" - EINE Aufgabe auf einmal, keine Textwände - Arbeite komplett auf Deutsch - Viel echtes, konkretes Lob - Fehler: nie Punkte abziehen, erst ermutigen, dann erklären, Eselsbrücken anbieten - Nach jeweils 5 Aufgaben: Pause anbieten - Insgesamt ca. 10-15 Aufgaben pro Session PUNKTE — KRITISCH, bei JEDER richtigen Antwort MUSST du EXAKT dieses Format schreiben: +2 ⭐ (einfache Aufgabe) | +3 ⭐ (schwieriger) | +3 ⭐ (Grammatik/Rechtschreibregel) | +4 ⭐ (Kreativaufgabe) | +1 ⭐ (beim 2. Versuch) IMMER das Pluszeichen, die Zahl und den Stern schreiben, z.B.: "Super! +2 ⭐" oder "Wunderschön, ${e}! +3 ⭐" NIEMALS die Punkte weglassen oder anders formatieren! Die App zählt sie automatisch. ÜBUNGSTYPEN — PFLICHT: Nie 2x denselben Typ hintereinander! Wechsle zwischen: 1. Rechtschreibung (Wort richtig schreiben, z.B. das/dass, ie/ih, Groß/Klein) 2. Wortarten bestimmen (Nomen, Verb, Adjektiv, Pronomen, Artikel, Präposition...) 3. Lückentext (Regel anwenden) 4. Satzglieder bestimmen (Subjekt, Prädikat, Objekt, Adverbiale) 5. Zeitformen bilden (Präsens → Präteritum → Perfekt) 6. Synonyme/Antonyme finden 7. Satz umformen (aktiv↔passiv, direkte↔indirekte Rede) 8. Zeichensetzung (Komma, Anführungszeichen) 9. Fehler im Satz finden 10. Kreativ-Satz mit Vorgabe ZWISCHENRUNDEN (PFLICHT!): - Nach jeder 5. Aufgabe: Blitz-Runde → 5 kurze Wiederholungen - Nach jeder 10. Aufgabe: Power-Check → Liste mit ✅/🔄, dann schwache nochmal SESSION-ENDE (PFLICHT!): Übersicht ALLER geübten Inhalte mit ✅/❌ + motivierender Abschluss ${t||""} KLAUSUR-MODUS (bei "Klausur üben"): Realistische Klassenarbeit über ALLE Sessions, gemischte Aufgaben, ca. 15-20, kein sofortiges Feedback, Auswertung mit Note am Ende. Punkte: +2 ⭐ richtig, +1 ⭐ teilweise richtig. topic="Klausur-Simulation" SESSION-ABLAUF: 1. Begrüße ${e}, sage Session-Nr und Thema 2. Starte mit 2-3 leichten Aufgaben 3. Wechsle JEDEN Übungstyp — NIE 2x dasselbe hintereinander! 4. Nach 5 Aufgaben: PFLICHT Blitz-Runde + Pause anbieten 5. Nach 10 Aufgaben: PFLICHT Power-Check 6. Am Ende: PFLICHT Komplett-Übersicht mit ✅/❌ WENN "Session beenden"/"fertig"/"Schluss"/"genug jetzt": Zusammenfassung + am Ende JSON: \`\`\`json {"pointsEarned":X,"vocabCorrect":X,"vocabTotal":X,"grammarCorrect":X,"grammarTotal":X,"weakItems":["..."],"strongItems":["..."],"teacherNote":"...","recommendation":"...","topic":"Session X — Thema"} \`\`\` HINWEIS: vocabCorrect/Total = Rechtschreibung/Wortschatz-Aufgaben, grammarCorrect/Total = Grammatik/Satzbau-Aufgaben.`}function C0(e,t){return`Du bist Professor Pi — ${e}s persönlicher Mathe-Lernbegleiter. ${e} ist Schüler/in, 6. Klasse Gymnasium. PERSÖNLICHKEIT: Verspielt, neugierig, zahlen-verliebt. Bringe Mathe zum Leben mit kleinen "Mathe-Aha-Momenten"! ${As(e,"Lehrerschmidt, Mathe by Daniel Jung")} REGELN: - Freundlich, geduldig, enthusiastisch — nenne sie/ihn IMMER "${e}" - EINE Aufgabe auf einmal, keine Textwände - Arbeite auf Deutsch - Zeige Rechenwege und erkläre Zwischenschritte - Fehler: nie Punkte abziehen, erst ermutigen, dann den Denkfehler zeigen - Nach jeweils 5 Aufgaben: Pause anbieten - Insgesamt ca. 10-15 Aufgaben pro Session PUNKTE — KRITISCH, bei JEDER richtigen Antwort MUSST du EXAKT dieses Format schreiben: +2 ⭐ (einfache Rechnung) | +3 ⭐ (schwieriger) | +3 ⭐ (Regel/Formel richtig angewendet) | +4 ⭐ (Textaufgabe/Knobelei) | +1 ⭐ (beim 2. Versuch) IMMER das Pluszeichen, die Zahl und den Stern schreiben, z.B.: "Klasse! +2 ⭐" oder "Mathe-Magie, ${e}! +4 ⭐" NIEMALS die Punkte weglassen oder anders formatieren! Die App zählt sie automatisch. ÜBUNGSTYPEN — PFLICHT: Nie 2x denselben Typ hintereinander! Wechsle zwischen: 1. Kopfrechnen (schnelle Rechnung) 2. Textaufgabe (Wort-Problem aus dem Alltag) 3. Regel/Formel anwenden 4. Ergebnis schätzen (grob überschlagen) 5. Umkehraufgabe (aus Ergebnis auf Rechnung schließen) 6. Fehler finden (falsche Rechnung korrigieren) 7. Logik/Knobelaufgabe 8. Geometrie in Worten (Figur beschreiben, Umfang/Fläche) 9. Muster fortsetzen (Zahlenfolge) 10. Sachrechnung (Einheiten, Umrechnen) FORMATIERUNG — KRITISCH: - Verwende LaTeX-Notation für Brüche und Formeln, eingeschlossen in $...$ - Brüche IMMER als $\\frac{Zähler}{Nenner}$ schreiben, z.B.: $\\frac{3}{4} \\cdot \\frac{5}{7} = \\frac{3 \\cdot 5}{4 \\cdot 7} = \\frac{15}{28}$ - Multiplikation: $\\cdot$ statt * oder x - Potenzen: $2^3 = 8$ - Wurzeln: $\\sqrt{16} = 4$ - Einfache Rechnungen ohne Brüche: "3 + 4 = 7" (kein LaTeX nötig) - Einheiten IMMER dabei: "5 cm", "10 €", "2,5 kg" - Geometrie: in Worten beschreiben, Formeln in LaTeX ZWISCHENRUNDEN (PFLICHT!): - Nach jeder 5. Aufgabe: Blitz-Runde → 5 schnelle Kopfrechnungen - Nach jeder 10. Aufgabe: Power-Check → Übersicht mit ✅/🔄 SESSION-ENDE (PFLICHT!): Übersicht ALLER Aufgaben mit ✅/❌ + motivierender Abschluss ${t||""} KLAUSUR-MODUS (bei "Klausur üben"): Realistische Klassenarbeit, gemischte Aufgaben inklusive Textaufgaben, ca. 15-20 Aufgaben, kein sofortiges Feedback, Auswertung mit Note am Ende. Punkte: +2 ⭐ pro richtig, +1 ⭐ bei Rechenweg richtig aber Ergebnis falsch. topic="Klausur-Simulation" SESSION-ABLAUF: 1. Begrüße ${e}, sage Session-Nr und Thema 2. Starte mit 2-3 leichten Aufwärm-Aufgaben 3. Wechsle JEDEN Übungstyp — NIE 2x dasselbe hintereinander! 4. Nach 5 Aufgaben: PFLICHT Blitz-Runde + Pause anbieten 5. Nach 10 Aufgaben: PFLICHT Power-Check 6. Am Ende: PFLICHT Komplett-Übersicht mit ✅/❌ WENN "Session beenden"/"fertig"/"Schluss"/"genug jetzt": Zusammenfassung + am Ende JSON: \`\`\`json {"pointsEarned":X,"vocabCorrect":X,"vocabTotal":X,"grammarCorrect":X,"grammarTotal":X,"weakItems":["..."],"strongItems":["..."],"teacherNote":"...","recommendation":"...","topic":"Session X — Thema"} \`\`\` HINWEIS: vocabCorrect/Total = einfache Rechnungen/Regeln, grammarCorrect/Total = Textaufgaben/komplexe Aufgaben.`}function so(e){return!window.katex||!e.includes("$")?e:e.split(/(\$[^$]+\$)/g).map((n,r)=>{if(n.startsWith("$")&&n.endsWith("$")&&n.length>2){let i=n.slice(1,-1);try{let o=window.katex.renderToString(i,{throwOnError:!1,displayMode:!1});return w.default.createElement("span",{key:r,dangerouslySetInnerHTML:{__html:o},style:{fontSize:"1.1em"}})}catch{return n}}return n})}function z0(e,t){let n=t?.length&&e.includes("[SEITE:"),r=window.katex&&e.includes("$"),i=e.includes("[YOUTUBE:");return!n&&!r&&!i?e:e.split(/(\[SEITE:\d+\]|\[YOUTUBE:[^\]]+\]|\$[^$]+\$)/g).map((l,a)=>{let u=l.match(/\[SEITE:(\d+)\]/);if(u){let d=parseInt(u[1])-1,h=t?.[d];return h?w.default.createElement(_0,{key:a,src:h,page:parseInt(u[1])}):l}let c=l.match(/^\[YOUTUBE:([^\]]+)\]$/);if(c){let d=c[1].split("|").map(h=>h.trim());return w.default.createElement(S0,{key:a,term:d[0]||"",channel:d[1]||""})}if(l.startsWith("$")&&l.endsWith("$")&&l.length>2&&window.katex){let d=l.slice(1,-1);try{let h=window.katex.renderToString(d,{throwOnError:!1,displayMode:!1});return w.default.createElement("span",{key:a,dangerouslySetInnerHTML:{__html:h},style:{fontSize:"1.1em"}})}catch{return l}}return l})}function _0({src:e,page:t}){let[n,r]=(0,w.useState)(!1);return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("span",{onClick:i=>{i.stopPropagation(),r(!0)},style:{display:"inline-flex",alignItems:"center",gap:"4px",cursor:"pointer",padding:"4px 8px",margin:"2px 0",borderRadius:"6px",background:"rgba(99,102,241,0.15)",border:"1px solid rgba(99,102,241,0.3)"},children:[(0,s.jsx)("img",{src:e,alt:`S.${t}`,style:{width:"32px",height:"40px",objectFit:"cover",borderRadius:"3px"}}),(0,s.jsx)("span",{style:{fontSize:"11px",color:"#a5b4fc",fontWeight:600},children:`S.${t}`})]}),n&&(0,s.jsx)(Id,{images:[e],onClose:()=>r(!1)})]})}function F0(e){let t=e.match(/\+\s*(\d+)\s*\u2B50/g),n=t?t.reduce((r,i)=>r+parseInt(i.match(/\d+/)[0]),0):0;if(n===0){let r=e.match(/(\d+)\s*\u2B50/g);n=r?r.reduce((i,o)=>i+parseInt(o.match(/\d+/)[0]),0):0}return n}function T0(e){let t=e.match(/```json\s*(\{[\s\S]*?\})\s*```/);if(!t)return null;try{return JSON.parse(t[1])}catch{return null}}function P0({onLogin:e}){let[t,n]=(0,w.useState)("login"),[r,i]=(0,w.useState)({first_name:"",last_name:"",nickname:"",email:"",password:""}),[o,l]=(0,w.useState)(""),[a,u]=(0,w.useState)(!1),c=(m,v)=>i(C=>({...C,[m]:v}));async function d(){l(""),u(!0);try{let m=await $.post("/api/auth.php",{action:t,...r});$.setToken(m.token),e(m.user)}catch(m){l(m.message)}u(!1)}let h=(m,v,C="text")=>(0,s.jsx)("input",{value:r[m],onChange:k=>c(m,k.target.value),placeholder:v,type:C,style:{width:"100%",padding:"12px 14px",borderRadius:"12px",border:"1px solid rgba(255,255,255,0.15)",background:"rgba(255,255,255,0.06)",color:"#fff",fontSize:"14px",outline:"none",marginBottom:"10px"}});return(0,s.jsx)("div",{style:{height:"100%",display:"flex",alignItems:"center",justifyContent:"center",background:"linear-gradient(135deg, #0f172a 0%, #1e1b4b 100%)"},children:(0,s.jsxs)("div",{style:{width:"320px",padding:"30px"},children:[(0,s.jsxs)("div",{style:{textAlign:"center",marginBottom:"24px"},children:[(0,s.jsx)("div",{style:{fontSize:"48px",marginBottom:"8px"},children:"📚"}),(0,s.jsx)("div",{style:{fontSize:"20px",fontWeight:800,color:"#fff"},children:"Vangii Adventure"}),(0,s.jsx)("div",{style:{fontSize:"13px",color:"#94a3b8",marginTop:"4px"},children:"Englisch, Deutsch & Mathe mit KI"})]}),(0,s.jsx)("div",{style:{display:"flex",gap:"8px",marginBottom:"20px"},children:["login","register"].map(m=>(0,s.jsx)("button",{onClick:()=>{n(m),l("")},style:{flex:1,padding:"8px",borderRadius:"10px",border:"1px solid rgba(255,255,255,0.15)",background:t===m?"rgba(99,102,241,0.2)":"transparent",color:t===m?"#a5b4fc":"#94a3b8",fontWeight:t===m?700:400,cursor:"pointer",fontSize:"13px"},children:m==="login"?"Anmelden":"Registrieren"},m))}),t==="register"&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{style:{display:"flex",gap:"8px"},children:[(0,s.jsx)("div",{style:{flex:1},children:h("first_name","Vorname")}),(0,s.jsx)("div",{style:{flex:1},children:h("last_name","Nachname")})]}),h("nickname","Spitzname")]}),h("email","Email","email"),h("password","Passwort","password"),o&&(0,s.jsx)("div",{style:{color:"#ef4444",fontSize:"13px",marginBottom:"10px",textAlign:"center"},children:o}),(0,s.jsx)("button",{onClick:d,disabled:a,style:{width:"100%",padding:"12px",borderRadius:"12px",border:"none",background:a?"rgba(99,102,241,0.3)":"linear-gradient(135deg, #6366f1, #4f46e5)",color:"#fff",fontSize:"15px",fontWeight:700,cursor:a?"default":"pointer"},children:a?"...":t==="login"?"Anmelden":"Registrieren"})]})})}function N0({user:e}){let[t,n]=(0,w.useState)(e),r=t?.nickname||"Schüler",[i,o]=(0,w.useState)([]),[l,a]=(0,w.useState)(()=>{let E=localStorage.getItem("vangii_subject");return Et.some(B=>B.key===E)?E:"englisch"}),[u,c]=(0,w.useState)(()=>{try{return JSON.parse(localStorage.getItem("vangii_unit_by_subject")||"{}")}catch{return{}}}),d=Ge(l),h=(0,w.useMemo)(()=>i.filter(E=>(E.subject||"englisch")===l&&E.is_active),[i,l]),m=u[l]||h[0]?.unit_key||null,v=h.find(E=>E.unit_key===m)||h[0]||null,C=v?.sessions||[],k=v?.unit_key||"none",L=v?.title||"Keine Unit aktiv",f=w0(l,r,v?.prompt_content,v?.images?.length||0);function p(E){E!==l&&(a(E),localStorage.setItem("vangii_subject",E),D([]),R([]),P(0),Nr(null),Rr(!1))}function g(){S("chat"),Mn("genug jetzt")}function y(E){if(E===m)return;let B={...u,[l]:E};c(B),localStorage.setItem("vangii_unit_by_subject",JSON.stringify(B)),D([]),R([]),P(0),Nr(null),Rr(!1)}async function x(E,B){let j=B?` AKTUELLE SESSION: Session ${B.id} — "${B.title}". Fokus: ${B.desc}. Halte dich an die Inhalte und Regeln dieser Session.`:"";return(await $.post("/api/chat.php",{system:f+j,messages:E})).content?.map(ve=>ve.text||"").join(` `)||"Ups, Verbindungsfehler..."}let[b,S]=(0,w.useState)("dashboard"),[F,D]=(0,w.useState)([]),[I,R]=(0,w.useState)([]),[z,A]=(0,w.useState)(""),[O,T]=(0,w.useState)(!1),[W,P]=(0,w.useState)(0),[M,H]=(0,w.useState)(null),[se,ot]=(0,w.useState)(null),[Ze,Nr]=(0,w.useState)(null),[uo,Rr]=(0,w.useState)(!1),[Ir,co]=(0,w.useState)(!1),Q0=(0,w.useRef)(null),Br=(0,w.useRef)(null),po=(0,w.useRef)(null),Ms=(0,w.useRef)(null);async function Bd(){try{let E=await $.get("/api/units.php");E.units&&o(E.units)}catch{}}(0,w.useEffect)(()=>{(async()=>{try{let[E,B]=await Promise.all([$.get("/api/progress.php"),$.get("/api/units.php")]);E.progress&&H(E.progress),E.admin_usage&&ot(E.admin_usage),B.units&&o(B.units)}catch{}})()},[]),(0,w.useEffect)(()=>{Br.current&&(Br.current.scrollTop=Br.current.scrollHeight)},[F,O]);async function fo(E){H(E);try{await $.post("/api/progress.php",{data:E})}catch(B){console.error(B)}}async function Mn(E,B=[]){if(!E.trim()&&!B.length)return;if(!v){D(G=>[...G,{role:"assistant",display:`⚠️ Keine ${d.label}-Unit aktiv. Der Admin muss erst eine Unit aktivieren.`}]);return}let j=[...B.map(G=>({type:"image",source:{type:"base64",media_type:G.type,data:G.data}}))];E.trim()&&j.push({type:"text",text:E.trim()});let X=E.trim()+(B.length?` 📷 ${B.length}`:"");D(G=>[...G,{role:"user",display:X}]);let ve=[...I,{role:"user",content:j}];R(ve),A(""),T(!0);try{let G=await x(ve,Ze),K=F0(G);K>0&&P(pe=>{let te=pe+K;return Ad(K,te),te});let ue=T0(G);ue&&await Md(ue),R(pe=>[...pe,{role:"assistant",content:[{type:"text",text:G}]}]),D(pe=>[...pe,{role:"assistant",display:G.replace(/```json[\s\S]*?```/g,"").trim()}])}catch(G){let K=G.message==="AUTH"?"⚠️ Bitte neu einloggen!":"⚠️ Verbindungsfehler!";D(ue=>[...ue,{role:"assistant",display:K}])}T(!1)}function Ld(E){let B=Array.from(E.target.files);B.length&&(Promise.all(B.map(j=>Bs(j))).then(j=>Mn(z||"Hier sind meine Buchseiten!",j)),E.target.value="")}function Dd(E,B){let j=(M?.sessionHistory||[]).filter(te=>te.unit===E&&typeof te.topic=="string"&&te.topic.includes(`Session ${B}`));if(j.length===0)return"";let X={},ve={};j.forEach(te=>{(te.strongItems||[]).forEach(xe=>{X[xe]=(X[xe]||0)+1}),(te.weakItems||[]).forEach(xe=>{ve[xe]=(ve[xe]||0)+1})});let G=te=>Object.entries(te).sort((xe,Be)=>Be[1]-xe[1]).map(([xe,Be])=>Be>1?`${xe} (${Be}x)`:xe).join(", "),K=G(X),ue=G(ve),pe=` LERNHISTORIE (aus früheren Durchläufen dieser Session, bereits ${j.length}x gestartet):`;return K&&(pe+=` - Schon sicher beherrscht: ${K}`),ue&&(pe+=` - Noch unsicher: ${ue}`),pe+=` WICHTIG: - NICHT mit den sicher beherrschten Items anfangen! - Priorisiere unsichere Items + neue, die noch nie drankamen - Randomisiere die Reihenfolge (nicht jedes Mal gleich starten) - Die "sicher beherrschten" höchstens am Ende kurz checken, nicht vorne breittreten`,pe}async function Ws(E,B=!1){Nr(E),Rr(!0),D([]),R([]),P(0),S("chat");let j=Dd(k,E.id),X=E.pages?.length?` Relevante Buchseiten fuer diese Session: ${E.pages.map(K=>`[SEITE:${K}]`).join(", ")}. Verweise aktiv darauf!`:"",G={role:"user",content:[{type:"text",text:B?`${r} hat Session ${E.id}: "${E.title}" schon mal gemacht. Starte einen REVIEW-QUIZ: Begrüße kurz, sag dass ihr checkt ob alles noch sitzt, und starte direkt mit einer Quizfrage. Kein langes Erklären — direkt abfragen! Spielerisch: "Mal sehen ob du das noch weißt..."${j}${X}`:`Starte Session ${E.id}: "${E.title}". Begrüße ${r} und leg los!${j}${X}`}]};R([G]),T(!0);try{let K=await x([G],E);R([G,{role:"assistant",content:[{type:"text",text:K}]}]),D([{role:"assistant",display:K.replace(/```json[\s\S]*?```/g,"").trim()}])}catch{D([{role:"assistant",display:"⚠️ Verbindungsfehler!"}])}T(!1)}async function Ad(E,B){try{let j=new Date,X=j.toISOString().split("T")[0],ve=j.toLocaleTimeString("de-DE",{hour:"2-digit",minute:"2-digit"}),G=Ze?`Session ${Ze.id} — ${Ze.title}`:"Freies Üben",K=M||{},ue=K.currentStreak||0,pe=K.lastSessionDate;if(pe){let Be=Math.floor((new Date(X)-new Date(pe))/864e5);Be===1?ue++:Be>1&&(ue=1)}else ue=1;let te={...K.unitPoints||{}};te[k]=(te[k]||0)+E;let xe={...K,totalPoints:(K.totalPoints||0)+E,unitPoints:te,currentStreak:ue,lastSessionDate:X,sessionsCompleted:K.sessionsCompleted||0,sessionHistory:K.sessionHistory||[],lastActivity:{date:X,time:ve,topic:G,pointsThisSession:B,subject:l}};await fo(xe)}catch(j){console.error(j)}}async function Md(E){try{let B=M||{},j=new Date().toISOString().split("T")[0],X=B.currentStreak||0,ve=B.lastSessionDate;if(ve){let Be=Math.floor((new Date(j)-new Date(ve))/864e5);Be===1?X++:Be>1&&(X=1)}else X=1;let G=X===3?5:X===7?15:0,K=(B.totalPoints||0)+(E.pointsEarned||0)+G,ue=E.topic||(Ze?`Session ${Ze.id} — ${Ze.title}`:"Übung"),pe=[{...E,date:j,topic:ue,unit:k,subject:l,bonusPoints:G},...B.sessionHistory||[]].slice(0,30),te={...B.unitPoints||{}};te[k]=(te[k]||0)+(E.pointsEarned||0)+G;let xe={totalPoints:K,unitPoints:te,currentStreak:X,lastSessionDate:j,sessionsCompleted:(B.sessionsCompleted||0)+1,sessionHistory:pe,lastActivity:B.lastActivity};await fo(xe)}catch(B){console.error(B)}}async function Wd(E,B){try{let j=new Date,X=j.toISOString().split("T")[0],ve=j.toLocaleTimeString("de-DE",{hour:"2-digit",minute:"2-digit"}),G=B==="quiz"?"Blitz-Quiz":"Hangman",K=M||{},ue=K.currentStreak||0,pe=K.lastSessionDate;if(pe){let Be=Math.floor((new Date(X)-new Date(pe))/864e5);Be===1?ue++:Be>1&&(ue=1)}else ue=1;let te={...K.unitPoints||{}};te[k]=(te[k]||0)+E;let xe={...K,totalPoints:(K.totalPoints||0)+E,unitPoints:te,currentStreak:ue,lastSessionDate:X,sessionHistory:K.sessionHistory||[],lastActivity:{date:X,time:ve,topic:G,pointsThisSession:E,subject:l}};await fo(xe)}catch(j){console.error(j)}}function Od(){$.setToken(null),window.location.reload()}(0,w.useEffect)(()=>{if(!Ir)return;let E=()=>{document.fullscreenElement||co(!1)};return document.addEventListener("fullscreenchange",E),()=>document.removeEventListener("fullscreenchange",E)},[Ir]);let $d=()=>{Ir?document.exitFullscreen?.().then(()=>co(!1)).catch(()=>{}):(Ms.current||document.documentElement).requestFullscreen?.().then(()=>co(!0)).catch(()=>{})},Os=b==="chat",jd=b==="sessions";return(0,s.jsxs)("div",{ref:Ms,style:{height:"100%",display:"flex",flexDirection:"column",background:"linear-gradient(180deg, #0f172a 0%, #1e1b4b 100%)",color:"#fff",maxWidth:"500px",margin:"0 auto",position:"relative"},children:[(0,s.jsxs)("div",{style:{padding:"10px 16px",display:"flex",alignItems:"center",justifyContent:"space-between",borderBottom:"1px solid rgba(255,255,255,0.08)"},children:[(0,s.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"10px"},children:[(0,s.jsx)("span",{style:{fontSize:"22px"},children:"📚"}),(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{style:{fontSize:"15px",fontWeight:800},children:"Vangii Adventure"}),(0,s.jsxs)("div",{style:{fontSize:"11px",color:"#94a3b8"},children:["Hey ",r,"! ",W>0&&`· +${W} ⭐`]})]})]}),(0,s.jsxs)("div",{style:{display:"flex",gap:"8px",alignItems:"center"},children:[(0,s.jsx)("button",{onClick:$d,style:{background:"none",border:"none",color:"#94a3b8",cursor:"pointer",fontSize:"16px"},children:Ir?"✕":"⛶"}),(0,s.jsx)("button",{onClick:Od,style:{background:"rgba(255,255,255,0.06)",border:"1px solid rgba(255,255,255,0.12)",borderRadius:"8px",color:"#94a3b8",cursor:"pointer",fontSize:"11px",padding:"4px 10px"},children:"Logout"})]})]}),(0,s.jsx)("div",{style:{display:"flex",borderBottom:"1px solid rgba(255,255,255,0.08)",background:"rgba(0,0,0,0.2)"},children:Et.map(E=>{let B=E.key===l;return(0,s.jsxs)("button",{onClick:()=>p(E.key),style:{flex:1,padding:"10px 4px",border:"none",cursor:"pointer",background:B?E.bgTint:"transparent",color:B?E.accent:"rgba(255,255,255,0.55)",fontWeight:B?700:500,fontSize:"13px",borderBottom:B?`2px solid ${E.accent}`:"2px solid transparent",display:"flex",alignItems:"center",justifyContent:"center",gap:"6px"},children:[(0,s.jsx)("span",{style:{fontSize:"15px"},children:E.icon}),E.label]},E.key)})}),h.length>1&&(0,s.jsx)("div",{style:{padding:"8px 12px",borderBottom:"1px solid rgba(255,255,255,0.06)",display:"flex",gap:"6px",overflowX:"auto",flexShrink:0},children:h.map(E=>{let B=E.unit_key===v?.unit_key;return(0,s.jsx)("button",{onClick:()=>y(E.unit_key),style:{padding:"5px 11px",borderRadius:"99px",border:`1px solid ${B?d.accent:"rgba(255,255,255,0.15)"}`,background:B?d.bgTint:"rgba(255,255,255,0.04)",color:B?d.accent:"#cbd5e1",fontSize:"11px",fontWeight:B?700:500,cursor:"pointer",whiteSpace:"nowrap",flexShrink:0},children:E.title},E.unit_key)})}),(0,s.jsxs)("div",{style:{flex:1,overflow:"hidden",display:"flex",flexDirection:"column",minHeight:0},children:[(0,s.jsx)("div",{style:{display:jd?"block":"none",flex:1,overflow:"auto"},children:(0,s.jsxs)("div",{style:{padding:"16px"},children:[uo&&Ze&&(0,s.jsxs)("div",{style:{background:d.bgTint,border:`1px solid ${d.accent}55`,borderRadius:"12px",padding:"10px 12px",marginBottom:"14px",display:"flex",alignItems:"center",gap:"8px",flexWrap:"wrap"},children:[(0,s.jsx)("div",{style:{fontSize:"22px"},children:"💬"}),(0,s.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,s.jsx)("div",{style:{fontSize:"11px",color:d.accent,fontWeight:700},children:"Laufender Chat"}),(0,s.jsxs)("div",{style:{fontSize:"13px",color:"#fff",fontWeight:600,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:["Session ",Ze.id," ","—"," ",Ze.title]})]}),(0,s.jsxs)("button",{onClick:()=>S("chat"),style:{padding:"7px 12px",borderRadius:"8px",border:"none",background:d.gradient,color:"#fff",fontWeight:700,fontSize:"12px",cursor:"pointer",flexShrink:0},children:["Weiter ","▶"]}),(0,s.jsxs)("button",{onClick:g,style:{padding:"7px 12px",borderRadius:"8px",border:`1px solid ${d.accent}44`,background:"rgba(255,255,255,0.06)",color:d.accent,fontWeight:700,fontSize:"12px",cursor:"pointer",flexShrink:0},children:["Genug jetzt ","✓"]})]}),(0,s.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"12px"},children:[(0,s.jsx)("div",{style:{fontSize:"11px",fontWeight:700,color:"#94a3b8",textTransform:"uppercase",letterSpacing:"1px"},children:L}),(0,s.jsx)(_d,{images:v?.images,accent:d.accent})]}),!v&&(0,s.jsxs)("div",{style:{fontSize:"13px",color:"rgba(255,255,255,0.5)",padding:"20px 0",textAlign:"center"},children:["Noch keine ",d.label,"-Unit aktiv.",(0,s.jsx)("br",{}),"Der Admin muss erst eine Unit aktivieren."]}),C.map(E=>{let B=M?.sessionHistory?.some(X=>X.topic?.includes(`Session ${E.id}`)&&X.unit===k),j=uo&&Ze?.id===E.id;return(0,s.jsxs)("div",{style:{background:j?d.bgTint:"rgba(255,255,255,0.05)",border:`1px solid ${j?d.accent+"66":"rgba(255,255,255,0.08)"}`,borderRadius:"14px",padding:"14px",marginBottom:"10px",display:"flex",alignItems:"center",gap:"14px"},children:[(0,s.jsx)("div",{style:{fontSize:"28px",width:"44px",textAlign:"center"},children:E.icon}),(0,s.jsxs)("div",{style:{flex:1},children:[(0,s.jsx)("div",{style:{fontWeight:700,fontSize:"14px"},children:E.title}),(0,s.jsx)("div",{style:{fontSize:"12px",color:"#94a3b8",marginTop:"2px"},children:E.desc}),E.pages?.length>0&&v?.images?.length>0&&(0,s.jsxs)("span",{style:{fontSize:"10px",color:"#60a5fa"},children:["📖"," S. ",E.pages.join(", ")]}),j?(0,s.jsxs)("span",{style:{fontSize:"10px",color:d.accent,fontWeight:700},children:[" ","💬"," L\\u00E4uft gerade"]}):B&&(0,s.jsxs)("span",{style:{fontSize:"10px",color:"#34d399",fontWeight:700},children:[" ","✅"," Gemacht"]})]}),(0,s.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:[j?(0,s.jsxs)("button",{onClick:()=>S("chat"),style:{padding:"6px 14px",borderRadius:"8px",border:"none",background:d.gradient,color:"#fff",fontWeight:700,cursor:"pointer",fontSize:"12px"},children:["Weiter ","▶"]}):(0,s.jsx)("button",{onClick:()=>Ws(E),style:{padding:"6px 14px",borderRadius:"8px",border:"none",background:d.gradient,color:"#fff",fontWeight:700,cursor:"pointer",fontSize:"12px"},children:B?"Nochmal":"Start"}),!j&&B&&(0,s.jsx)("button",{onClick:()=>Ws(E,!0),style:{padding:"4px 10px",borderRadius:"6px",border:`1px solid ${d.accent}44`,background:"transparent",color:d.accent,fontWeight:600,cursor:"pointer",fontSize:"10px"},children:"Quiz"})]})]},E.id)})]})}),(0,s.jsxs)("div",{style:{display:Os?"flex":"none",flex:1,flexDirection:"column",overflow:"hidden",minHeight:0},children:[(0,s.jsxs)("div",{ref:Br,style:{flex:1,overflow:"auto",padding:"16px",display:"flex",flexDirection:"column",gap:"12px",minHeight:0},children:[F.length===0&&!O&&(0,s.jsxs)("div",{style:{textAlign:"center",padding:"40px 20px",color:"rgba(255,255,255,0.4)"},children:[(0,s.jsx)("div",{style:{fontSize:"48px",marginBottom:"12px"},children:d.personaEmoji}),(0,s.jsxs)("div",{style:{fontSize:"16px",fontWeight:700,marginBottom:"8px",color:"rgba(255,255,255,0.6)"},children:["Hey ",r,"!"]}),(0,s.jsxs)("div",{style:{fontSize:"14px",lineHeight:1.6},children:["Ich bin ",d.persona,", deine ",d.label,"-Tutorin.",(0,s.jsx)("br",{}),"Schick mir Fotos aus deinem Buch ","📸"," oder leg direkt los!"]}),(0,s.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px",justifyContent:"center",marginTop:"20px"},children:d.quickActions.map(E=>(0,s.jsx)("button",{onClick:()=>E.includes("📸")?po.current?.click():Mn(E),style:{padding:"8px 16px",borderRadius:"99px",border:"1px solid rgba(255,255,255,0.15)",background:"rgba(255,255,255,0.06)",color:"#fff",cursor:"pointer",fontSize:"13px"},children:E},E))})]}),F.map((E,B)=>(0,s.jsx)("div",{style:{display:"flex",justifyContent:E.role==="user"?"flex-end":"flex-start"},children:(0,s.jsx)("div",{style:{maxWidth:"85%",padding:"10px 14px",borderRadius:E.role==="user"?"18px 18px 4px 18px":"18px 18px 18px 4px",background:E.role==="user"?d.gradient:"rgba(255,255,255,0.08)",border:E.role==="user"?"none":"1px solid rgba(255,255,255,0.08)",fontSize:"14px",lineHeight:1.6,whiteSpace:"pre-wrap",wordBreak:"break-word"},children:E.role==="assistant"?z0(E.display,v?.images):E.display})},B)),O&&(0,s.jsx)("div",{style:{display:"flex",justifyContent:"flex-start"},children:(0,s.jsx)("div",{style:{padding:"12px 18px",borderRadius:"18px 18px 18px 4px",background:"rgba(255,255,255,0.08)",border:"1px solid rgba(255,255,255,0.08)"},children:(0,s.jsxs)("span",{style:{animation:"pulse 1.5s infinite",fontSize:"14px",color:"rgba(255,255,255,0.5)"},children:[d.persona," tippt..."]})})})]}),Os&&uo&&(0,s.jsxs)("button",{onClick:()=>{confirm(`Session wirklich beenden? Dein Chat mit ${d.persona} geht verloren.`)&&(Rr(!1),Nr(null),D([]),R([]),P(0),S("dashboard"))},style:{position:"absolute",top:"14px",right:"100px",padding:"4px 12px",borderRadius:"8px",border:"1px solid rgba(255,255,255,0.15)",background:"rgba(239,68,68,0.15)",color:"#fca5a5",fontSize:"11px",fontWeight:600,cursor:"pointer",zIndex:10},children:["✕"," Session beenden"]}),(0,s.jsx)("input",{type:"file",ref:po,accept:"image/*",multiple:!0,style:{display:"none"},onChange:Ld}),(0,s.jsxs)("div",{style:{padding:"10px 12px",borderTop:"1px solid rgba(255,255,255,0.08)",display:"flex",gap:"6px",alignItems:"center"},children:[v?.images?.length>0&&(0,s.jsx)(_d,{images:v.images,accent:d.accent}),(0,s.jsx)("button",{onClick:()=>po.current?.click(),style:{width:"42px",height:"42px",borderRadius:"50%",border:"1px solid rgba(255,255,255,0.15)",background:"rgba(255,255,255,0.06)",color:"#fff",cursor:"pointer",fontSize:"18px",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:"📷"}),(0,s.jsx)("input",{value:z,onChange:E=>A(E.target.value),onKeyDown:E=>{E.key==="Enter"&&!E.shiftKey&&(E.preventDefault(),Mn(z))},placeholder:`Schreib ${d.persona}...`,style:{flex:1,padding:"10px 14px",borderRadius:"21px",border:"1px solid rgba(255,255,255,0.15)",background:"rgba(255,255,255,0.06)",color:"#fff",fontSize:"14px",outline:"none"}}),(0,s.jsx)("button",{onClick:()=>Mn(z),disabled:O||!z.trim(),style:{width:"42px",height:"42px",borderRadius:"50%",border:"none",background:O||!z.trim()?"rgba(99,102,241,0.3)":d.gradient,color:"#fff",cursor:O?"default":"pointer",fontSize:"16px",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:"▲"})]})]}),(0,s.jsx)("div",{style:{display:b==="games"?"block":"none",flex:1,overflow:"auto"},children:(0,s.jsx)(A0,{selectedUnit:v,subject:d,weakItems:D0(k,M?.sessionHistory),onPointsEarned:(E,B)=>Wd(E,B)})}),(0,s.jsx)("div",{style:{display:b==="ranking"?"block":"none",flex:1,overflow:"auto"},children:(0,s.jsx)(I0,{unitKey:k,unitLabel:L})}),(0,s.jsx)("div",{style:{display:b==="dashboard"?"block":"none",flex:1,overflow:"auto"},children:(0,s.jsx)(j0,{data:M,pts:W,user:t,adminUsage:se,unitKey:k,unitLabel:L,allUnits:i,onUnitsChanged:Bd,currentSubject:l})})]}),(0,s.jsx)("div",{style:{display:"flex",borderTop:"1px solid rgba(255,255,255,0.08)",background:"rgba(0,0,0,0.3)"},children:[["dashboard","📊","Dashboard"],["chat","💬","Chat"],["games","🎮","Spiele"],["sessions","📚","Sessions"],["ranking","🏆","Rangliste"]].map(([E,B,j])=>(0,s.jsxs)("button",{onClick:()=>S(E),style:{flex:1,padding:"10px 0 8px",border:"none",background:"transparent",color:b===E?d.accent:"rgba(255,255,255,0.35)",cursor:"pointer",display:"flex",flexDirection:"column",alignItems:"center",gap:"2px",position:"relative"},children:[(0,s.jsx)("span",{style:{fontSize:"20px"},children:B}),(0,s.jsx)("span",{style:{fontSize:"11px",fontWeight:b===E?700:500},children:j}),E==="chat"&&F.length>0&&b!=="chat"&&(0,s.jsx)("span",{style:{position:"absolute",top:"6px",right:"calc(50% - 16px)",width:"8px",height:"8px",borderRadius:"50%",background:d.accent}})]},E))}),(0,s.jsx)("style",{children:"@keyframes pulse{0%,100%{opacity:.4}50%{opacity:1}}input::placeholder{color:rgba(255,255,255,.3)}"})]})}var R0=[{key:"unit",label:"Unit",icon:"📚"},{key:"monthly",label:"Monat",icon:"📅"},{key:"alltime",label:"All Time",icon:"🏆"}];function I0({unitKey:e,unitLabel:t}){let[n,r]=(0,w.useState)("unit"),[i,o]=(0,w.useState)(null),[l,a]=(0,w.useState)(!0);(0,w.useEffect)(()=>{a(!0),(async()=>{try{let d=await $.get(`/api/leaderboard.php?unit=${e}&mode=${n}`);o(d)}catch(d){console.error(d)}a(!1)})()},[e,n]);let u=n==="unit"?t:n==="monthly"?i?.month||"Monat":"All Time",c=d=>({flex:1,padding:"6px 4px",borderRadius:"8px",border:"none",cursor:"pointer",background:n===d.key?"rgba(255,255,255,0.12)":"transparent",color:n===d.key?"#fff":"rgba(255,255,255,0.5)",fontWeight:n===d.key?700:500,fontSize:"11px"});return(0,s.jsxs)("div",{style:{padding:"16px"},children:[(0,s.jsx)("div",{style:{textAlign:"center",marginBottom:"12px"},children:(0,s.jsxs)("div",{style:{fontSize:"13px",fontWeight:700,color:"#94a3b8",textTransform:"uppercase",letterSpacing:"1px"},children:["🏆"," Rangliste"]})}),(0,s.jsx)("div",{style:{display:"flex",gap:"4px",marginBottom:"14px",padding:"3px",background:"rgba(255,255,255,0.04)",borderRadius:"10px"},children:R0.map(d=>(0,s.jsxs)("button",{onClick:()=>r(d.key),style:c(d),children:[d.icon," ",d.label]},d.key))}),(0,s.jsx)("div",{style:{textAlign:"center",marginBottom:"14px"},children:(0,s.jsx)("div",{style:{fontSize:"14px",fontWeight:800,color:"#a5b4fc"},children:u})}),l?(0,s.jsx)("div",{style:{padding:"30px",textAlign:"center",color:"#94a3b8"},children:"Laden..."}):i?.leaderboard?.length?(0,s.jsx)(B0,{data:i}):(0,s.jsxs)("div",{style:{padding:"30px 20px",textAlign:"center",color:"rgba(255,255,255,0.4)"},children:[(0,s.jsx)("div",{style:{fontSize:"40px",marginBottom:"10px"},children:"🏆"}),(0,s.jsx)("div",{style:{fontSize:"14px",fontWeight:700,color:"rgba(255,255,255,0.6)",marginBottom:"6px"},children:"Noch keine Einträge!"}),(0,s.jsx)("div",{style:{fontSize:"12px",lineHeight:1.5},children:n==="monthly"?"Sammle diesen Monat Punkte!":n==="alltime"?"Sammle Punkte um hier zu erscheinen.":(0,s.jsxs)(s.Fragment,{children:["Sammle Punkte in ",t,(0,s.jsx)("br",{}),"um auf der Rangliste zu erscheinen."]})})]})]})}function B0({data:e}){let t=["🥇","🥈","🥉"];return(0,s.jsxs)("div",{children:[e.leaderboard.length>=3&&(0,s.jsx)("div",{style:{display:"flex",justifyContent:"center",alignItems:"flex-end",gap:"8px",marginBottom:"20px",padding:"0 10px"},children:[1,0,2].map(n=>{let r=e.leaderboard[n];if(!r)return null;let i=n===0;return(0,s.jsxs)("div",{style:{flex:1,textAlign:"center"},children:[(0,s.jsx)("div",{style:{fontSize:i?"36px":"28px",marginBottom:"4px"},children:t[n]}),(0,s.jsxs)("div",{style:{background:r.isMe?"linear-gradient(135deg, rgba(99,102,241,0.2), rgba(139,92,246,0.15))":"rgba(255,255,255,0.05)",border:r.isMe?"2px solid rgba(99,102,241,0.4)":"1px solid rgba(255,255,255,0.08)",borderRadius:"14px",padding:i?"16px 8px":"12px 8px"},children:[(0,s.jsx)("div",{style:{fontSize:i?"15px":"13px",fontWeight:800,color:"#fff"},children:r.nickname}),(0,s.jsxs)("div",{style:{fontSize:i?"20px":"16px",fontWeight:900,color:"#fbbf24",marginTop:"4px"},children:[r.points," ","⭐"]})]})]},n)})}),e.leaderboard.map((n,r)=>(0,s.jsxs)("div",{style:{background:n.isMe?"linear-gradient(135deg, rgba(99,102,241,0.12), rgba(139,92,246,0.08))":"rgba(255,255,255,0.03)",border:n.isMe?"1px solid rgba(99,102,241,0.3)":"1px solid rgba(255,255,255,0.06)",borderRadius:"12px",padding:"12px 14px",marginBottom:"6px",display:"flex",alignItems:"center",gap:"12px"},children:[(0,s.jsx)("div",{style:{width:"28px",textAlign:"center",fontSize:r<3?"20px":"14px",fontWeight:800,color:r<3?"#fbbf24":"#94a3b8"},children:r<3?t[r]:`${n.rank}.`}),(0,s.jsx)("div",{style:{flex:1},children:(0,s.jsxs)("div",{style:{fontSize:"14px",fontWeight:n.isMe?800:600,color:n.isMe?"#a5b4fc":"#fff"},children:[n.nickname," ",n.isMe&&"👈"]})}),(0,s.jsx)("div",{style:{textAlign:"right"},children:(0,s.jsxs)("div",{style:{fontSize:"16px",fontWeight:800,color:"#fbbf24"},children:[n.points," ","⭐"]})})]},r))]})}function L0({unitKey:e,unitLabel:t}){let[n,r]=(0,w.useState)(null);if((0,w.useEffect)(()=>{!e||e==="none"||$.get(`/api/leaderboard.php?unit=${e}`).then(r).catch(()=>{})},[e]),!n?.leaderboard?.length)return null;let i=n.leaderboard.slice(0,5),o=["🥇","🥈","🥉"];return(0,s.jsxs)("div",{style:{marginBottom:"16px"},children:[(0,s.jsxs)("div",{style:{fontSize:"11px",fontWeight:700,color:"#94a3b8",marginBottom:"10px",textTransform:"uppercase",letterSpacing:"1px"},children:["🏆"," Top 5 ","—"," ",t]}),i.map((l,a)=>(0,s.jsxs)("div",{style:{background:l.isMe?"rgba(99,102,241,0.1)":"rgba(255,255,255,0.03)",border:l.isMe?"1px solid rgba(99,102,241,0.25)":"1px solid rgba(255,255,255,0.05)",borderRadius:"10px",padding:"8px 12px",marginBottom:"4px",display:"flex",alignItems:"center",gap:"10px"},children:[(0,s.jsx)("span",{style:{fontSize:a<3?"16px":"12px",width:"24px",textAlign:"center",fontWeight:800,color:"#94a3b8"},children:a<3?o[a]:`${l.rank}.`}),(0,s.jsxs)("span",{style:{flex:1,fontSize:"13px",fontWeight:l.isMe?700:500,color:l.isMe?"#a5b4fc":"#fff"},children:[l.nickname,l.isMe&&" 👈"]}),(0,s.jsxs)("span",{style:{fontSize:"13px",fontWeight:700,color:"#fbbf24"},children:[l.points," ","⭐"]})]},a))]})}function D0(e,t){return Array.from(new Set((t||[]).filter(n=>n.unit===e).flatMap(n=>n.weakItems||[]).filter(n=>typeof n=="string"))).slice(0,20)}function A0({selectedUnit:e,subject:t,weakItems:n,onPointsEarned:r}){let[i,o]=(0,w.useState)("menu");return e?i==="quiz"?(0,s.jsx)(ao,{selectedUnit:e,subject:t,weakItems:n,onExit:()=>o("menu"),onPointsEarned:l=>r(l,"quiz")}):i==="hangman"?(0,s.jsx)(Td,{selectedUnit:e,subject:t,weakItems:n,onExit:()=>o("menu"),onPointsEarned:l=>r(l,"hangman")}):i==="wordsearch"?(0,s.jsx)(Pd,{selectedUnit:e,subject:t,weakItems:n,onExit:()=>o("menu"),onPointsEarned:l=>r(l,"wordsearch")}):i==="memory"?(0,s.jsx)(Nd,{selectedUnit:e,subject:t,weakItems:n,onExit:()=>o("menu"),onPointsEarned:l=>r(l,"memory")}):i==="challenge"?(0,s.jsx)(Rd,{selectedUnit:e,subject:t,weakItems:n,onExit:()=>o("menu"),onPointsEarned:r}):(0,s.jsxs)("div",{style:{padding:"20px"},children:[(0,s.jsxs)("div",{style:{textAlign:"center",marginBottom:"20px"},children:[(0,s.jsx)("div",{style:{fontSize:"48px",marginBottom:"8px"},children:"🎮"}),(0,s.jsx)("div",{style:{fontSize:"18px",fontWeight:800,color:"#fff"},children:"Spiele"}),(0,s.jsxs)("div",{style:{fontSize:"12px",color:t.accent,marginTop:"4px"},children:[t.icon," ",e.title]})]}),(0,s.jsxs)("button",{onClick:()=>o("challenge"),style:{width:"100%",padding:"18px",marginBottom:"12px",borderRadius:"14px",border:"none",background:t.gradient,color:"#fff",cursor:"pointer",textAlign:"left",display:"flex",alignItems:"center",gap:"14px",boxShadow:`0 6px 20px ${t.accent}33`},children:[(0,s.jsx)("div",{style:{fontSize:"32px"},children:"🆚"}),(0,s.jsxs)("div",{style:{flex:1},children:[(0,s.jsx)("div",{style:{fontSize:"15px",fontWeight:800},children:"Duell"}),(0,s.jsx)("div",{style:{fontSize:"12px",color:"rgba(255,255,255,0.85)",marginTop:"2px"},children:"Fordere einen Freund heraus - gleiches Quiz, wer gewinnt?"})]}),(0,s.jsx)("div",{style:{fontSize:"20px"},children:"▶"})]}),(0,s.jsxs)("button",{onClick:()=>o("quiz"),style:{width:"100%",padding:"18px",marginBottom:"12px",borderRadius:"14px",border:`1px solid ${t.accent}44`,background:t.bgTint,color:"#fff",cursor:"pointer",textAlign:"left",display:"flex",alignItems:"center",gap:"14px"},children:[(0,s.jsx)("div",{style:{fontSize:"32px"},children:"⚡"}),(0,s.jsxs)("div",{style:{flex:1},children:[(0,s.jsx)("div",{style:{fontSize:"15px",fontWeight:800},children:"Blitz-Quiz"}),(0,s.jsxs)("div",{style:{fontSize:"12px",color:"#cbd5e1",marginTop:"2px"},children:["10 schnelle Fragen, 4 Optionen pro Frage. Bis zu +25 ","⭐"]})]}),(0,s.jsx)("div",{style:{fontSize:"20px",color:t.accent},children:"▶"})]}),(0,s.jsxs)("button",{onClick:()=>o("hangman"),style:{width:"100%",padding:"18px",marginBottom:"12px",borderRadius:"14px",border:`1px solid ${t.accent}44`,background:t.bgTint,color:"#fff",cursor:"pointer",textAlign:"left",display:"flex",alignItems:"center",gap:"14px"},children:[(0,s.jsx)("div",{style:{fontSize:"32px"},children:"🪢"}),(0,s.jsxs)("div",{style:{flex:1},children:[(0,s.jsx)("div",{style:{fontSize:"15px",fontWeight:800},children:"Hangman"}),(0,s.jsxs)("div",{style:{fontSize:"12px",color:"#cbd5e1",marginTop:"2px"},children:["Wort erraten Buchstabe für Buchstabe. 8 Runden, bis zu +40 ","⭐"]})]}),(0,s.jsx)("div",{style:{fontSize:"20px",color:t.accent},children:"▶"})]}),(0,s.jsxs)("button",{onClick:()=>o("wordsearch"),style:{width:"100%",padding:"18px",marginBottom:"12px",borderRadius:"14px",border:`1px solid ${t.accent}44`,background:t.bgTint,color:"#fff",cursor:"pointer",textAlign:"left",display:"flex",alignItems:"center",gap:"14px"},children:[(0,s.jsx)("div",{style:{fontSize:"32px"},children:"🔍"}),(0,s.jsxs)("div",{style:{flex:1},children:[(0,s.jsx)("div",{style:{fontSize:"15px",fontWeight:800},children:"Wortsuche"}),(0,s.jsxs)("div",{style:{fontSize:"12px",color:"#cbd5e1",marginTop:"2px"},children:["Versteckte Wörter im Buchstabengitter finden. +3 ","⭐"," pro Wort"]})]}),(0,s.jsx)("div",{style:{fontSize:"20px",color:t.accent},children:"▶"})]}),(0,s.jsxs)("button",{onClick:()=>o("memory"),style:{width:"100%",padding:"18px",marginBottom:"12px",borderRadius:"14px",border:`1px solid ${t.accent}44`,background:t.bgTint,color:"#fff",cursor:"pointer",textAlign:"left",display:"flex",alignItems:"center",gap:"14px"},children:[(0,s.jsx)("div",{style:{fontSize:"32px"},children:"🃏"}),(0,s.jsxs)("div",{style:{flex:1},children:[(0,s.jsx)("div",{style:{fontSize:"15px",fontWeight:800},children:"Paare"}),(0,s.jsxs)("div",{style:{fontSize:"12px",color:"#cbd5e1",marginTop:"2px"},children:["Memory: passende Paare aufdecken. +2 ","⭐"," pro Paar"]})]}),(0,s.jsx)("div",{style:{fontSize:"20px",color:t.accent},children:"▶"})]}),n.length>0&&(0,s.jsxs)("div",{style:{marginTop:"14px",padding:"10px 12px",borderRadius:"10px",background:"rgba(252,211,77,0.08)",border:"1px solid rgba(252,211,77,0.25)",fontSize:"11px",color:"#fde68a"},children:["💡"," Die Spiele fokussieren auf ",n.length," Items, die dir beim Chat schwer fielen."]})]}):(0,s.jsxs)("div",{style:{padding:"40px 20px",textAlign:"center",color:"rgba(255,255,255,0.5)"},children:[(0,s.jsx)("div",{style:{fontSize:"48px",marginBottom:"12px"},children:"🎮"}),(0,s.jsxs)("div",{style:{fontSize:"14px"},children:["Keine ",t.label,"-Unit ausgewählt.",(0,s.jsx)("br",{}),"Wähle erst eine Unit, dann geht’s los!"]})]})}function ao({selectedUnit:e,subject:t,weakItems:n,onExit:r,onPointsEarned:i,presetGame:o,onScore:l}){let[a,u]=(0,w.useState)("loading"),[c,d]=(0,w.useState)(null),[h,m]=(0,w.useState)(0),[v,C]=(0,w.useState)(0),[k,L]=(0,w.useState)(null),[f,p]=(0,w.useState)(""),[g,y]=(0,w.useState)(0),[x,b]=(0,w.useState)(0),S=(0,w.useRef)(!1),F=z=>{try{navigator.vibrate&&navigator.vibrate(z)}catch{}};if((0,w.useEffect)(()=>{if(o){d(o),u("playing");return}$.post("/api/game.php",{action:"generate",unit_key:e.unit_key,game_type:"quiz",weak_items:n}).then(z=>{d(z.game),u("playing")}).catch(z=>{p(z.message),u("error")})},[e.unit_key]),a==="loading")return(0,s.jsx)(Xe,{emoji:"🎲",text:`${t.persona} bastelt ein Blitz-Quiz...`});if(a==="error")return(0,s.jsx)(Xe,{emoji:"⚠️",text:`Fehler: ${f}`,action:{label:"Zurück",onClick:r}});let D=c?.questions?.[h];if(!D)return(0,s.jsx)(Xe,{emoji:"⚠️",text:"Fragen fehlen",action:{label:"Zurück",onClick:r}});if(a==="done"){if(!S.current){S.current=!0;let O=v===c.questions.length?5:0,T=v*2+O;T>0&&i(T),l&&l(v,c)}if(l)return(0,s.jsx)(Xe,{emoji:"⏳",text:"Ergebnis wird gewertet..."});let z=v===c.questions.length?5:0,A=v*2+z;return(0,s.jsxs)("div",{style:{padding:"30px 20px",textAlign:"center",animation:"vgUp .4s ease"},children:[(0,s.jsx)("div",{style:{fontSize:"56px",marginBottom:"12px",animation:"vgPop .5s ease"},children:v>=8?"🏆":v>=5?"👏":"💪"}),(0,s.jsxs)("div",{style:{fontSize:"22px",fontWeight:800,color:"#fff"},children:[v," / ",c.questions.length]}),(0,s.jsx)("div",{style:{fontSize:"15px",color:t.accent,marginTop:"4px"},children:v>=8?"Super!":v>=5?"Gut gemacht!":"Nochmal versuchen!"}),(0,s.jsxs)("div",{style:{fontSize:"34px",color:"#fbbf24",fontWeight:900,margin:"16px 0",animation:"vgPop .5s ease"},children:["+",A," ","⭐"]}),x>=3&&(0,s.jsxs)("div",{style:{fontSize:"13px",color:"#fdba74",marginBottom:"4px"},children:["🔥"," Beste Serie: ",x," richtig in Folge"]}),z>0&&(0,s.jsxs)("div",{style:{fontSize:"12px",color:"#fbbf24"},children:["🎉"," Perfekt-Bonus: +5 ","⭐"]}),(0,s.jsxs)("div",{style:{display:"flex",gap:"10px",marginTop:"24px",justifyContent:"center"},children:[(0,s.jsx)("button",{onClick:r,style:{padding:"10px 20px",borderRadius:"10px",border:"1px solid rgba(255,255,255,0.2)",background:"transparent",color:"#fff",cursor:"pointer",fontSize:"13px"},children:"Zurück"}),(0,s.jsx)("button",{onClick:()=>{S.current=!1,m(0),C(0),L(null),y(0),b(0),u("loading"),$.post("/api/game.php",{action:"generate",unit_key:e.unit_key,game_type:"quiz",weak_items:n}).then(O=>{d(O.game),u("playing")}).catch(O=>{p(O.message),u("error")})},style:{padding:"10px 20px",borderRadius:"10px",border:"none",background:t.gradient,color:"#fff",fontWeight:700,cursor:"pointer",fontSize:"13px"},children:"Nochmal"})]})]})}function I(z){if(k!==null)return;L(z);let A=z===D.a;A?(C(O=>O+1),y(O=>{let T=O+1;return b(W=>Math.max(W,T)),T}),F(15)):(y(0),F([12,50,12])),setTimeout(()=>{L(null),h+1>=c.questions.length?u("done"):m(O=>O+1)},A?650:1300)}let R=(h+(k!==null?1:0))/c.questions.length*100;return(0,s.jsxs)("div",{style:{padding:"16px",display:"flex",flexDirection:"column",height:"100%"},children:[(0,s.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"8px",fontSize:"12px"},children:[(0,s.jsx)("button",{onClick:r,style:{background:"none",border:"none",color:"#94a3b8",cursor:"pointer",fontSize:"13px"},children:"← Zurück"}),(0,s.jsxs)("div",{style:{color:"#94a3b8"},children:["Runde ",h+1," / ",c.questions.length]}),(0,s.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[g>=2&&(0,s.jsxs)("span",{style:{display:"inline-flex",alignItems:"center",gap:"2px",padding:"2px 8px",borderRadius:"99px",background:"rgba(251,146,60,0.18)",border:"1px solid rgba(251,146,60,0.4)",color:"#fdba74",fontWeight:800,animation:"vgPop .35s ease"},children:["🔥"," x",g]},g),(0,s.jsxs)("span",{style:{color:"#fbbf24",fontWeight:700},children:[v*2," ","⭐"]})]})]}),(0,s.jsx)("div",{style:{height:"4px",background:"rgba(255,255,255,0.08)",borderRadius:"99px",marginBottom:"20px"},children:(0,s.jsx)("div",{style:{height:"100%",background:t.gradient,borderRadius:"99px",width:`${R}%`,transition:"width 0.3s"}})}),(0,s.jsxs)("div",{style:{flex:1,display:"flex",flexDirection:"column",justifyContent:"center",animation:"vgUp .35s ease"},children:[(0,s.jsx)("div",{style:{background:"linear-gradient(180deg, rgba(255,255,255,0.07), rgba(255,255,255,0.03))",border:"1px solid rgba(255,255,255,0.12)",borderRadius:"18px",padding:"30px 22px",textAlign:"center",marginBottom:"18px",boxShadow:"0 10px 30px rgba(0,0,0,0.25)"},children:(0,s.jsx)("div",{style:{fontSize:"22px",fontWeight:700,color:"#fff",lineHeight:1.35},children:so(D.q)})}),(0,s.jsx)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"10px"},children:D.opts.map((z,A)=>{let O=k===z,T=z===D.a,W="rgba(255,255,255,0.06)",P="rgba(255,255,255,0.12)",M="#fff",H="none",se="none";return k!==null&&(T?(W="rgba(52,211,153,0.22)",P="#34d399",M="#bbf7d0",H="vgPop .4s ease",se="0 0 22px rgba(52,211,153,0.35)"):O?(W="rgba(239,68,68,0.2)",P="#ef4444",M="#fecaca",H="vgShake .4s ease"):M="rgba(255,255,255,0.35)"),(0,s.jsxs)("button",{onClick:()=>I(z),disabled:k!==null,style:{position:"relative",padding:"16px 10px",borderRadius:"14px",border:`2px solid ${P}`,background:W,color:M,fontSize:"14px",fontWeight:600,cursor:k!==null?"default":"pointer",minHeight:"62px",transition:"all 0.2s",animation:H,boxShadow:se},children:[so(z),k!==null&&T&&(0,s.jsx)("span",{style:{position:"absolute",top:"6px",right:"8px",fontSize:"13px"},children:"✅"})]},A)})})]},h)]})}var lo=6;function M0({wrong:e,color:t}){let n={stroke:t,strokeWidth:2.5,fill:"none",strokeLinecap:"round"};return(0,s.jsxs)("svg",{viewBox:"0 0 100 120",width:"100",height:"120",style:{display:"block",margin:"0 auto"},children:[(0,s.jsx)("line",{x1:"5",y1:"115",x2:"55",y2:"115",...n}),(0,s.jsx)("line",{x1:"20",y1:"115",x2:"20",y2:"10",...n}),(0,s.jsx)("line",{x1:"20",y1:"10",x2:"55",y2:"10",...n}),(0,s.jsx)("line",{x1:"55",y1:"10",x2:"55",y2:"22",...n}),e>=1&&(0,s.jsx)("circle",{cx:"55",cy:"30",r:"8",...n}),e>=2&&(0,s.jsx)("line",{x1:"55",y1:"38",x2:"55",y2:"70",...n}),e>=3&&(0,s.jsx)("line",{x1:"55",y1:"48",x2:"42",y2:"60",...n}),e>=4&&(0,s.jsx)("line",{x1:"55",y1:"48",x2:"68",y2:"60",...n}),e>=5&&(0,s.jsx)("line",{x1:"55",y1:"70",x2:"44",y2:"88",...n}),e>=6&&(0,s.jsx)("line",{x1:"55",y1:"70",x2:"66",y2:"88",...n})]})}function Td({selectedUnit:e,subject:t,weakItems:n,onExit:r,onPointsEarned:i}){let[o,l]=(0,w.useState)("loading"),[a,u]=(0,w.useState)(null),[c,d]=(0,w.useState)(0),[h,m]=(0,w.useState)(new Set),[v,C]=(0,w.useState)(0),[k,L]=(0,w.useState)(0),[f,p]=(0,w.useState)(0),[g,y]=(0,w.useState)(""),x=(0,w.useRef)(!1),b=P=>{try{navigator.vibrate&&navigator.vibrate(P)}catch{}};if((0,w.useEffect)(()=>{$.post("/api/game.php",{action:"generate",unit_key:e.unit_key,game_type:"hangman",weak_items:n}).then(P=>{u(P.game),l("playing")}).catch(P=>{y(P.message),l("error")})},[e.unit_key]),o==="loading")return(0,s.jsx)(Xe,{emoji:"🪢",text:`${t.persona} waehlt Wörter aus...`});if(o==="error")return(0,s.jsx)(Xe,{emoji:"⚠️",text:`Fehler: ${g}`,action:{label:"Zurück",onClick:r}});let S=a?.rounds?.[c];if(!S)return(0,s.jsx)(Xe,{emoji:"⚠️",text:"Keine W\\u00F6rter",action:{label:"Zurück",onClick:r}});let F=S.word,D=[...F],I=D.every(P=>h.has(P)),R=v>=lo,z=I||R;if(o==="done")return x.current||(x.current=!0,f>0&&i(f)),(0,s.jsxs)("div",{style:{padding:"30px 20px",textAlign:"center",animation:"vgUp .4s ease"},children:[(0,s.jsx)("div",{style:{fontSize:"56px",marginBottom:"12px",animation:"vgPop .5s ease"},children:k>=6?"🏆":k>=4?"👏":"💪"}),(0,s.jsxs)("div",{style:{fontSize:"22px",fontWeight:800,color:"#fff"},children:[k," / ",a.rounds.length," ","Wörter"]}),(0,s.jsxs)("div",{style:{fontSize:"34px",color:"#fbbf24",fontWeight:900,margin:"16px 0",animation:"vgPop .5s ease"},children:["+",f," ","⭐"]}),(0,s.jsxs)("div",{style:{display:"flex",gap:"10px",marginTop:"24px",justifyContent:"center"},children:[(0,s.jsx)("button",{onClick:r,style:{padding:"10px 20px",borderRadius:"10px",border:"1px solid rgba(255,255,255,0.2)",background:"transparent",color:"#fff",cursor:"pointer",fontSize:"13px"},children:"Zurück"}),(0,s.jsx)("button",{onClick:()=>{x.current=!1,d(0),m(new Set),C(0),L(0),p(0),l("loading"),$.post("/api/game.php",{action:"generate",unit_key:e.unit_key,game_type:"hangman",weak_items:n}).then(P=>{u(P.game),l("playing")}).catch(P=>{y(P.message),l("error")})},style:{padding:"10px 20px",borderRadius:"10px",border:"none",background:t.gradient,color:"#fff",fontWeight:700,cursor:"pointer",fontSize:"13px"},children:"Nochmal"})]})]});function O(P){if(z||h.has(P))return;let M=new Set(h);M.add(P),m(M),F.includes(P)?b(15):(C(H=>H+1),b([12,50,12]))}function T(){if(I){let P=Math.max(1,lo-v+1);L(M=>M+1),p(M=>M+P)}c+1>=a.rounds.length?l("done"):(d(P=>P+1),m(new Set),C(0))}return(0,s.jsxs)("div",{style:{padding:"14px",display:"flex",flexDirection:"column",height:"100%"},children:[(0,s.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"8px",fontSize:"12px"},children:[(0,s.jsx)("button",{onClick:r,style:{background:"none",border:"none",color:"#94a3b8",cursor:"pointer",fontSize:"13px"},children:"← Zurück"}),(0,s.jsxs)("div",{style:{color:"#94a3b8"},children:["Wort ",c+1," / ",a.rounds.length]}),(0,s.jsxs)("div",{style:{color:"#fbbf24",fontWeight:700},children:[f," ","⭐"]})]}),(0,s.jsxs)("div",{style:{display:"flex",gap:"12px",alignItems:"center",marginBottom:"10px"},children:[(0,s.jsx)(M0,{wrong:v,color:t.accent}),(0,s.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,s.jsx)("div",{style:{fontSize:"11px",color:"#94a3b8",fontWeight:700,textTransform:"uppercase",letterSpacing:"0.5px"},children:"Hinweis"}),(0,s.jsx)("div",{style:{fontSize:"13px",color:"#fff",marginTop:"4px"},children:S.hint}),(0,s.jsxs)("div",{style:{fontSize:"11px",color:v>=4?"#fca5a5":"#94a3b8",marginTop:"6px"},children:["Fehler: ",v," / ",lo]})]})]}),(0,s.jsx)("div",{style:{display:"flex",justifyContent:"center",gap:"6px",flexWrap:"wrap",margin:"14px 0 18px"},children:D.map((P,M)=>{let H=h.has(P)||R;return(0,s.jsx)("div",{style:{width:"24px",borderBottom:`2px solid ${t.accent}`,textAlign:"center",fontSize:"20px",fontWeight:800,color:H?R&&!h.has(P)?"#fca5a5":"#fff":"transparent",minHeight:"28px",animation:h.has(P)&&!R?"vgPop .3s ease":"none"},children:H?P:"_"},M)})}),z?(0,s.jsxs)("div",{style:{textAlign:"center",marginBottom:"14px",animation:"vgUp .35s ease"},children:[(0,s.jsx)("div",{style:{fontSize:"18px",fontWeight:800,color:I?"#34d399":"#fca5a5",animation:I?"vgPop .5s ease":"none"},children:I?`🎉 Richtig! +${Math.max(1,lo-v+1)} ⭐`:`😕 Verloren — Wort war: ${F}`}),(0,s.jsx)("button",{onClick:T,style:{marginTop:"12px",padding:"10px 24px",borderRadius:"10px",border:"none",background:t.gradient,color:"#fff",fontWeight:700,cursor:"pointer",fontSize:"14px"},children:c+1>=a.rounds.length?"Ergebnis ▶":"Nächstes Wort ▶"})]}):(0,s.jsx)("div",{style:{display:"grid",gridTemplateColumns:"repeat(7, 1fr)",gap:"4px"},children:"ABCDEFGHIJKLMNOPQRSTUVWXYZ".split("").map(P=>{let M=h.has(P),H=M&&!F.includes(P),se=M&&F.includes(P);return(0,s.jsx)("button",{onClick:()=>O(P),disabled:M,style:{padding:"8px 0",borderRadius:"8px",border:`1px solid ${se?"#34d399":H?"#ef4444":"rgba(255,255,255,0.15)"}`,background:se?"rgba(52,211,153,0.2)":H?"rgba(239,68,68,0.15)":"rgba(255,255,255,0.05)",color:M?se?"#bbf7d0":"#fca5a5":"#fff",fontSize:"13px",fontWeight:700,transition:"all 0.15s",animation:se?"vgPop .35s ease":H?"vgShake .35s ease":"none",cursor:M?"default":"pointer",minHeight:"34px"},children:P},P)})})]})}function Cd(e,t=10){let n=Array.from({length:t},()=>Array(t).fill("")),r=[],i=[[0,1],[1,0],[1,1],[0,-1],[-1,0],[-1,-1],[1,-1],[-1,1]],o=[...e].sort((a,u)=>u.length-a.length);for(let a of o){let u=!1;for(let c=0;c<150&&!u;c++){let[d,h]=i[Math.floor(Math.random()*i.length)],m=Math.floor(Math.random()*t),v=Math.floor(Math.random()*t),C=m+d*(a.length-1),k=v+h*(a.length-1);if(C<0||C>=t||k<0||k>=t)continue;let L=!0;for(let f=0;f{try{navigator.vibrate&&navigator.vibrate(T)}catch{}};if((0,w.useEffect)(()=>{$.post("/api/game.php",{action:"generate",unit_key:e.unit_key,game_type:"wordsearch",weak_items:n}).then(T=>{u(T.game);let W=(T.game.words||[]).map(H=>H.word).filter(H=>H&&H.length>=3),P=Math.max(...W.map(H=>H.length),8),M=Math.max(10,P+2);d(Cd(W,M)),l("playing")}).catch(T=>{p(T.message),l("error")})},[e.unit_key]),o==="loading")return(0,s.jsx)(Xe,{emoji:"🔍",text:`${t.persona} versteckt Wörter...`});if(o==="error")return(0,s.jsx)(Xe,{emoji:"⚠️",text:`Fehler: ${f}`,action:{label:"Zurück",onClick:r}});if(!c||!a)return null;let b=c.placed.length>0&&h.size>=c.placed.length;if(b&&!y.current){y.current=!0;let T=h.size*3;T>0&&i(T)}function S(T,W){if(!g.current)return null;let P=g.current.getBoundingClientRect(),M=P.width/c.size,H=P.height/c.size,se=Math.floor((T-P.left)/M),ot=Math.floor((W-P.top)/H);return ot<0||ot>=c.size||se<0||se>=c.size?null:{r:ot,c:se}}function F(T){T.preventDefault();let W=T.touches?T.touches[0]:T,P=S(W.clientX,W.clientY);P&&(C(P),L(P))}function D(T){if(!v)return;T.preventDefault();let W=T.touches?T.touches[0]:T,P=S(W.clientX,W.clientY);P&&L(P)}function I(){if(!v||!k){C(null),L(null);return}let T=zd(v.r,v.c,k.r,k.c);if(T.length>=2){let W=T.map(H=>c.grid[H.r][H.c]).join(""),P=[...W].reverse().join(""),M=c.placed.find(H=>H.word===W||H.word===P);M&&!h.has(M.word)&&(m(H=>{let se=new Set(H);return se.add(M.word),se}),x([15,30,15]))}C(null),L(null)}let R=v&&k?zd(v.r,v.c,k.r,k.c):[],z=new Set(R.map(T=>`${T.r},${T.c}`)),A=new Set;c.placed.forEach(T=>{if(h.has(T.word))for(let W=0;W{let P=h.has(T.word);return(0,s.jsx)("div",{style:{padding:"3px 8px",borderRadius:"6px",fontSize:"10px",fontWeight:700,background:P?"rgba(52,211,153,0.15)":"rgba(255,255,255,0.05)",border:`1px solid ${P?"#34d399":"rgba(255,255,255,0.1)"}`,color:P?"#34d399":"#cbd5e1",transition:"all 0.2s",animation:P?"vgPop .4s ease":"none"},children:P?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{style:{textDecoration:"line-through"},children:T.word})," ",(0,s.jsx)("span",{style:{fontWeight:400,color:"#94a3b8"},children:T.hint})]}):(0,s.jsxs)(s.Fragment,{children:[T.hint," ",(0,s.jsxs)("span",{style:{fontWeight:400,color:"#94a3b8"},children:["(",T.word.length,")"]})]})},W)})}),b?(0,s.jsxs)("div",{style:{textAlign:"center",padding:"20px 0",animation:"vgUp .4s ease"},children:[(0,s.jsx)("div",{style:{fontSize:"48px",marginBottom:"10px",animation:"vgPop .5s ease"},children:"🎉"}),(0,s.jsx)("div",{style:{fontSize:"18px",fontWeight:800,color:"#fff"},children:"Alle gefunden!"}),(0,s.jsxs)("div",{style:{fontSize:"30px",color:"#fbbf24",fontWeight:900,margin:"12px 0",animation:"vgPop .5s ease"},children:["+",h.size*3," ","⭐"]}),(0,s.jsxs)("div",{style:{display:"flex",gap:"10px",marginTop:"16px",justifyContent:"center"},children:[(0,s.jsx)("button",{onClick:r,style:{padding:"10px 20px",borderRadius:"10px",border:"1px solid rgba(255,255,255,0.2)",background:"transparent",color:"#fff",cursor:"pointer",fontSize:"13px"},children:"Zurück"}),(0,s.jsx)("button",{onClick:()=>{y.current=!1,m(new Set),l("loading"),$.post("/api/game.php",{action:"generate",unit_key:e.unit_key,game_type:"wordsearch",weak_items:n}).then(T=>{u(T.game);let W=(T.game.words||[]).map(M=>M.word).filter(M=>M&&M.length>=3),P=Math.max(...W.map(M=>M.length),8);d(Cd(W,Math.max(10,P+2))),l("playing")}).catch(T=>{p(T.message),l("error")})},style:{padding:"10px 20px",borderRadius:"10px",border:"none",background:t.gradient,color:"#fff",fontWeight:700,cursor:"pointer",fontSize:"13px"},children:"Nochmal"})]})]}):(0,s.jsx)("div",{ref:g,onMouseDown:F,onMouseMove:D,onMouseUp:I,onTouchStart:F,onTouchMove:D,onTouchEnd:I,style:{display:"grid",gridTemplateColumns:`repeat(${c.size}, ${O}px)`,gap:"1px",justifyContent:"center",touchAction:"none",userSelect:"none"},children:c.grid.map((T,W)=>T.map((P,M)=>{let H=`${W},${M}`,se=z.has(H),ot=A.has(H);return(0,s.jsx)("div",{style:{width:O,height:O,display:"flex",alignItems:"center",justifyContent:"center",fontSize:O>28?"14px":"11px",fontWeight:700,borderRadius:"3px",background:se?t.bgTint:ot?"rgba(52,211,153,0.2)":"rgba(255,255,255,0.04)",border:`1px solid ${se?t.accent:ot?"#34d39944":"rgba(255,255,255,0.06)"}`,color:se?t.accent:ot?"#34d399":"rgba(255,255,255,0.7)",transition:"background 0.15s",animation:ot?"vgPop .4s ease":"none"},children:P},H)}))})]})}function Nd({selectedUnit:e,subject:t,weakItems:n,onExit:r,onPointsEarned:i}){let[o,l]=(0,w.useState)("loading"),[a,u]=(0,w.useState)([]),[c,d]=(0,w.useState)([]),[h,m]=(0,w.useState)(new Set),[v,C]=(0,w.useState)([]),[k,L]=(0,w.useState)(0),[f,p]=(0,w.useState)(""),g=(0,w.useRef)(!1),y=(0,w.useRef)(!1),x=R=>{try{navigator.vibrate&&navigator.vibrate(R)}catch{}};function b(R){let z=[];(R||[]).forEach((A,O)=>{z.push({id:O*2,pair:O,text:A.a}),z.push({id:O*2+1,pair:O,text:A.b})});for(let A=z.length-1;A>0;A--){let O=Math.floor(Math.random()*(A+1));[z[A],z[O]]=[z[O],z[A]]}return z}function S(){l("loading"),$.post("/api/game.php",{action:"generate",unit_key:e.unit_key,game_type:"memory",weak_items:n}).then(R=>{u(b(R.game.pairs)),l("playing")}).catch(R=>{p(R.message),l("error")})}if((0,w.useEffect)(()=>{S()},[e.unit_key]),o==="loading")return(0,s.jsx)(Xe,{emoji:"🃏",text:`${t.persona} mischt die Karten...`});if(o==="error")return(0,s.jsx)(Xe,{emoji:"⚠️",text:`Fehler: ${f}`,action:{label:"Zurück",onClick:r}});let F=a.length/2;if(F>0&&h.size>=F){let R=F*2;return g.current||(g.current=!0,R>0&&i(R)),(0,s.jsxs)("div",{style:{padding:"30px 20px",textAlign:"center",animation:"vgUp .4s ease"},children:[(0,s.jsx)("div",{style:{fontSize:"56px",marginBottom:"12px",animation:"vgPop .5s ease"},children:"🎉"}),(0,s.jsx)("div",{style:{fontSize:"22px",fontWeight:800,color:"#fff"},children:"Alle Paare gefunden!"}),(0,s.jsxs)("div",{style:{fontSize:"13px",color:t.accent,marginTop:"4px"},children:["in ",k," Zügen"]}),(0,s.jsxs)("div",{style:{fontSize:"34px",color:"#fbbf24",fontWeight:900,margin:"16px 0",animation:"vgPop .5s ease"},children:["+",R," ","⭐"]}),(0,s.jsxs)("div",{style:{display:"flex",gap:"10px",marginTop:"16px",justifyContent:"center"},children:[(0,s.jsx)("button",{onClick:r,style:{padding:"10px 20px",borderRadius:"10px",border:"1px solid rgba(255,255,255,0.2)",background:"transparent",color:"#fff",cursor:"pointer",fontSize:"13px"},children:"Zurück"}),(0,s.jsx)("button",{onClick:()=>{g.current=!1,m(new Set),d([]),C([]),L(0),S()},style:{padding:"10px 20px",borderRadius:"10px",border:"none",background:t.gradient,color:"#fff",fontWeight:700,cursor:"pointer",fontSize:"13px"},children:"Nochmal"})]})]})}function I(R){if(y.current||h.has(R.pair)||c.includes(R.id))return;let z=[...c,R.id];if(d(z),z.length===2){L(T=>T+1);let[A,O]=z.map(T=>a.find(W=>W.id===T));A.pair===O.pair?(x(15),y.current=!0,setTimeout(()=>{m(T=>{let W=new Set(T);return W.add(A.pair),W}),d([]),y.current=!1},420)):(x([12,50,12]),y.current=!0,C(z),setTimeout(()=>{d([]),C([]),y.current=!1},820))}}return(0,s.jsxs)("div",{style:{padding:"16px",display:"flex",flexDirection:"column",height:"100%"},children:[(0,s.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"10px",fontSize:"12px"},children:[(0,s.jsx)("button",{onClick:r,style:{background:"none",border:"none",color:"#94a3b8",cursor:"pointer",fontSize:"13px"},children:"← Zurück"}),(0,s.jsxs)("div",{style:{color:"#94a3b8"},children:[h.size," / ",F," Paare"]}),(0,s.jsxs)("div",{style:{color:"#cbd5e1",fontWeight:700},children:[k," Züge"]})]}),(0,s.jsx)("div",{style:{flex:1,display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:"8px",alignContent:"center"},children:a.map(R=>{let z=h.has(R.pair),A=c.includes(R.id)||z,O=v.includes(R.id),T="rgba(255,255,255,0.05)",W="rgba(255,255,255,0.12)",P="none",M="none";return z?(T="rgba(52,211,153,0.18)",W="#34d399",P="vgPop .4s ease"):O?(T="rgba(239,68,68,0.18)",W="#ef4444",P="vgShake .4s ease"):A&&(T=t.bgTint,W=t.accent,M=`0 0 16px ${t.accent}33`),(0,s.jsx)("button",{onClick:()=>I(R),disabled:A,style:{minHeight:"66px",borderRadius:"12px",border:`2px solid ${W}`,background:T,color:z?"#bbf7d0":A?"#fff":"transparent",fontSize:"13px",fontWeight:700,padding:"6px",cursor:A?"default":"pointer",transition:"all 0.18s",animation:P,boxShadow:M,lineHeight:1.2,display:"flex",alignItems:"center",justifyContent:"center",textAlign:"center"},children:A?so(R.text):(0,s.jsx)("span",{style:{color:t.accent,fontSize:"20px",opacity:.5},children:"?"})},R.id)})})]})}function Rd({selectedUnit:e,subject:t,weakItems:n,onExit:r,onPointsEarned:i}){let[o,l]=(0,w.useState)("hub"),[a,u]=(0,w.useState)(null),[c,d]=(0,w.useState)([]),[h,m]=(0,w.useState)(null),[v,C]=(0,w.useState)(null),[k,L]=(0,w.useState)(null),[f,p]=(0,w.useState)(!1),[g,y]=(0,w.useState)("");function x(){$.post("/api/challenge.php",{action:"inbox"}).then(u).catch(z=>y(z.message))}(0,w.useEffect)(()=>{x()},[]);function b(){p(!0),$.post("/api/challenge.php",{action:"opponents"}).then(z=>{d(z.opponents||[]),l("pick")}).catch(z=>y(z.message)).finally(()=>p(!1))}function S(z,A){$.post("/api/challenge.php",{action:"create",opponent_id:h.id,game_type:"quiz",unit_key:e.unit_key,unit_title:e.title,game_json:A,challenger_score:z}).then(()=>{L({created:!0,opponent:h.nickname,score:z}),l("created")}).catch(O=>{y(O.message),l("hub")})}function F(z){p(!0),$.post("/api/challenge.php",{action:"get",id:z}).then(A=>{C({id:z,game:A.game,challenger:A.challenger,beat:A.challenger_score}),l("playOpp")}).catch(A=>y(A.message)).finally(()=>p(!1))}function D(z){$.post("/api/challenge.php",{action:"submit",id:v.id,opponent_score:z}).then(A=>{L(A),l("result"),x()}).catch(A=>{y(A.message),l("hub")})}let I={background:"rgba(255,255,255,0.05)",border:"1px solid rgba(255,255,255,0.1)",borderRadius:"14px",padding:"14px",marginBottom:"10px"},R=(0,s.jsx)("button",{onClick:r,style:{background:"none",border:"none",color:"#94a3b8",cursor:"pointer",fontSize:"13px",marginBottom:"10px"},children:"← Zurück"});if(o==="playChal")return(0,s.jsx)(ao,{selectedUnit:e,subject:t,weakItems:n,onExit:()=>l("hub"),onPointsEarned:z=>i(z,"quiz"),onScore:S});if(o==="playOpp"&&v)return(0,s.jsx)(ao,{selectedUnit:e,subject:t,weakItems:n,presetGame:v.game,onExit:()=>l("hub"),onPointsEarned:z=>i(z,"quiz"),onScore:D});if(o==="pick")return(0,s.jsxs)("div",{style:{padding:"16px",animation:"vgUp .3s ease"},children:[R,(0,s.jsx)("div",{style:{fontSize:"16px",fontWeight:800,color:"#fff",marginBottom:"4px"},children:"Wen fordest du heraus?"}),(0,s.jsx)("div",{style:{fontSize:"12px",color:"#94a3b8",marginBottom:"14px"},children:"Du spielst zuerst ein Blitz-Quiz, dann muss dein Gegner dieselben Fragen schlagen."}),c.length===0&&(0,s.jsx)("div",{style:{fontSize:"13px",color:"#94a3b8"},children:"Noch keine anderen Spieler:innen da."}),c.map(z=>(0,s.jsxs)("button",{onClick:()=>{m(z),l("playChal")},style:{...I,width:"100%",textAlign:"left",color:"#fff",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[(0,s.jsxs)("span",{style:{fontWeight:700},children:["👤"," ",z.nickname]}),(0,s.jsxs)("span",{style:{color:t.accent,fontSize:"13px"},children:["Herausfordern ","▶"]})]},z.id))]});if(o==="created"&&k)return(0,s.jsxs)("div",{style:{padding:"30px 20px",textAlign:"center",animation:"vgUp .4s ease"},children:[(0,s.jsx)("div",{style:{fontSize:"52px",marginBottom:"10px",animation:"vgPop .5s ease"},children:"📤"}),(0,s.jsx)("div",{style:{fontSize:"18px",fontWeight:800,color:"#fff"},children:"Duell gesendet!"}),(0,s.jsxs)("div",{style:{fontSize:"14px",color:"#cbd5e1",margin:"8px 0 4px"},children:["Dein Ergebnis: ",(0,s.jsxs)("b",{style:{color:"#fbbf24"},children:[k.score," / 10"]})]}),(0,s.jsxs)("div",{style:{fontSize:"12px",color:"#94a3b8",maxWidth:"260px",margin:"0 auto"},children:[k.opponent," muss jetzt dieselben Fragen schlagen. Du wirst benachrichtigt!"]}),(0,s.jsx)("button",{onClick:()=>{x(),l("hub")},style:{marginTop:"20px",padding:"10px 22px",borderRadius:"10px",border:"none",background:t.gradient,color:"#fff",fontWeight:700,cursor:"pointer",fontSize:"13px"},children:"Weiter"})]});if(o==="result"&&k){let z=k.outcome==="win",A=k.outcome==="tie";return(0,s.jsxs)("div",{style:{padding:"30px 20px",textAlign:"center",animation:"vgUp .4s ease"},children:[(0,s.jsx)("div",{style:{fontSize:"56px",marginBottom:"10px",animation:"vgPop .5s ease"},children:z?"🏆":A?"🤝":"💪"}),(0,s.jsx)("div",{style:{fontSize:"22px",fontWeight:800,color:z?"#34d399":A?"#fbbf24":"#fca5a5"},children:z?"Gewonnen!":A?"Unentschieden!":"Knapp verloren"}),(0,s.jsxs)("div",{style:{fontSize:"18px",color:"#fff",margin:"14px 0",fontWeight:700},children:["Du ",k.my_score," : ",k.challenger_score," ",k.challenger]}),(0,s.jsx)("button",{onClick:()=>l("hub"),style:{marginTop:"12px",padding:"10px 22px",borderRadius:"10px",border:"none",background:t.gradient,color:"#fff",fontWeight:700,cursor:"pointer",fontSize:"13px"},children:"Weiter"})]})}return(0,s.jsxs)("div",{style:{padding:"16px",animation:"vgUp .3s ease"},children:[R,(0,s.jsxs)("div",{style:{textAlign:"center",marginBottom:"16px"},children:[(0,s.jsx)("div",{style:{fontSize:"40px"},children:"🆚"}),(0,s.jsx)("div",{style:{fontSize:"18px",fontWeight:800,color:"#fff"},children:"Duelle"}),(0,s.jsxs)("div",{style:{fontSize:"12px",color:t.accent},children:[t.icon," ",e.title]})]}),(0,s.jsx)("button",{onClick:b,disabled:f,style:{width:"100%",padding:"16px",borderRadius:"14px",border:"none",background:t.gradient,color:"#fff",fontWeight:800,fontSize:"15px",cursor:"pointer",marginBottom:"18px",boxShadow:`0 6px 20px ${t.accent}44`},children:f?"...":"⚔️ Freund herausfordern"}),g&&(0,s.jsx)("div",{style:{fontSize:"12px",color:"#fca5a5",marginBottom:"10px"},children:g}),a?.incoming?.length>0&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{style:{fontSize:"11px",fontWeight:800,color:"#94a3b8",textTransform:"uppercase",letterSpacing:"0.5px",margin:"0 0 8px"},children:"Dich erwartet ein Duell"}),a.incoming.map(z=>(0,s.jsxs)("div",{style:{...I,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{style:{fontWeight:700,color:"#fff",fontSize:"14px"},children:z.from}),(0,s.jsxs)("div",{style:{fontSize:"11px",color:"#94a3b8"},children:[z.unit_title," · schlag ",z.challenger_score," / 10"]})]}),(0,s.jsx)("button",{onClick:()=>F(z.id),disabled:f,style:{padding:"8px 14px",borderRadius:"10px",border:"none",background:t.gradient,color:"#fff",fontWeight:700,cursor:"pointer",fontSize:"12px"},children:"Annehmen"})]},z.id))]}),a?.outgoing?.length>0&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{style:{fontSize:"11px",fontWeight:800,color:"#94a3b8",textTransform:"uppercase",letterSpacing:"0.5px",margin:"14px 0 8px"},children:"Warten auf Antwort"}),a.outgoing.map(z=>(0,s.jsxs)("div",{style:{...I,fontSize:"13px",color:"#cbd5e1"},children:["⏳"," ",z.to," muss noch spielen ",(0,s.jsxs)("span",{style:{color:"#94a3b8"},children:["(dein Score: ",z.challenger_score,")"]})]},z.id))]}),a?.results?.length>0&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{style:{fontSize:"11px",fontWeight:800,color:"#94a3b8",textTransform:"uppercase",letterSpacing:"0.5px",margin:"14px 0 8px"},children:"Letzte Duelle"}),a.results.map(z=>(0,s.jsxs)("div",{style:{...I,display:"flex",alignItems:"center",justifyContent:"space-between",fontSize:"13px"},children:[(0,s.jsxs)("span",{style:{color:"#fff"},children:["vs ",z.opponent]}),(0,s.jsxs)("span",{style:{fontWeight:800,color:z.outcome==="win"?"#34d399":z.outcome==="tie"?"#fbbf24":"#fca5a5"},children:[z.my_score," : ",z.opp_score," ",z.outcome==="win"?"🏆":(z.outcome==="tie","")]})]},z.id))]}),a&&!a.incoming?.length&&!a.outgoing?.length&&!a.results?.length&&(0,s.jsx)("div",{style:{fontSize:"12px",color:"#94a3b8",textAlign:"center",marginTop:"10px"},children:"Noch keine Duelle. Fordere jemanden heraus!"})]})}function Id({images:e,onClose:t}){let[n,r]=(0,w.useState)(0),[i,o]=(0,w.useState)(1),l=[1,1.25,1.5,1.75,2];if(!e?.length)return null;let a=()=>o(d=>{let h=l.indexOf(d);return l[(h+1)%l.length]}),u=d=>{r(d),o(1)},c=i>1;return(0,s.jsxs)("div",{style:{position:"fixed",inset:0,zIndex:1e3,background:"rgba(0,0,0,0.95)",display:"flex",flexDirection:"column"},onClick:t,children:[(0,s.jsxs)("div",{style:{padding:"10px 16px",display:"flex",justifyContent:"space-between",alignItems:"center",flexShrink:0},onClick:d=>d.stopPropagation(),children:[(0,s.jsxs)("span",{style:{color:"#fff",fontSize:"13px",fontWeight:700},children:["📸"," Seite ",n+1,"/",e.length]}),(0,s.jsxs)("div",{style:{display:"flex",gap:"8px",alignItems:"center"},children:[(0,s.jsxs)("button",{onClick:a,style:{background:"rgba(255,255,255,0.15)",border:"none",color:"#fff",fontSize:"13px",fontWeight:700,padding:"4px 10px",borderRadius:"6px",cursor:"pointer"},children:["🔍"," ",i,"x"]}),(0,s.jsx)("button",{onClick:t,style:{background:"none",border:"none",color:"#fff",fontSize:"22px",cursor:"pointer"},children:"✕"})]})]}),(0,s.jsxs)("div",{style:{flex:1,overflow:c?"auto":"hidden",display:c?"block":"flex",alignItems:"center",justifyContent:"center",position:"relative",WebkitOverflowScrolling:"touch"},onClick:d=>d.stopPropagation(),children:[(0,s.jsx)("img",{src:e[n],alt:`Seite ${n+1}`,onClick:a,style:c?{width:`${i*100}%`,height:"auto",cursor:"zoom-out",display:"block"}:{maxWidth:"100%",maxHeight:"100%",objectFit:"contain",cursor:"zoom-in"}}),!c&&e.length>1&&n>0&&(0,s.jsx)("button",{onClick:()=>u(n-1),style:{position:"absolute",left:"8px",top:"50%",transform:"translateY(-50%)",width:"36px",height:"36px",borderRadius:"50%",border:"none",background:"rgba(255,255,255,0.2)",color:"#fff",fontSize:"18px",cursor:"pointer"},children:"‹"}),!c&&e.length>1&&nu(n+1),style:{position:"absolute",right:"8px",top:"50%",transform:"translateY(-50%)",width:"36px",height:"36px",borderRadius:"50%",border:"none",background:"rgba(255,255,255,0.2)",color:"#fff",fontSize:"18px",cursor:"pointer"},children:"›"})]}),!c&&e.length>1&&(0,s.jsx)("div",{style:{padding:"10px",display:"flex",justifyContent:"center",gap:"6px",flexShrink:0},children:e.map((d,h)=>(0,s.jsx)("div",{onClick:m=>{m.stopPropagation(),u(h)},style:{width:"8px",height:"8px",borderRadius:"50%",cursor:"pointer",background:h===n?"#fff":"rgba(255,255,255,0.3)"}},h))})]})}function _d({images:e,accent:t}){let[n,r]=(0,w.useState)(!1);return e?.length?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("button",{onClick:()=>r(!0),style:{padding:"6px 12px",borderRadius:"8px",border:`1px solid ${t}44`,background:"rgba(255,255,255,0.06)",color:t,fontSize:"11px",fontWeight:700,cursor:"pointer",display:"inline-flex",alignItems:"center",gap:"4px"},children:["📸"," Buchseiten (",e.length,")"]}),n&&(0,s.jsx)(Id,{images:e,onClose:()=>r(!1)})]}):null}function Xe({emoji:e,text:t,action:n}){return(0,s.jsxs)("div",{style:{padding:"40px 20px",textAlign:"center",color:"rgba(255,255,255,0.6)"},children:[(0,s.jsx)("div",{style:{fontSize:"48px",marginBottom:"12px"},children:e}),(0,s.jsx)("div",{style:{fontSize:"14px",marginBottom:"16px"},children:t}),n&&(0,s.jsx)("button",{onClick:n.onClick,style:{padding:"8px 20px",borderRadius:"10px",border:"1px solid rgba(255,255,255,0.2)",background:"transparent",color:"#fff",cursor:"pointer",fontSize:"13px"},children:n.label})]})}function W0({onDone:e}){let[t,n]=(0,w.useState)(!1),[r,i]=(0,w.useState)(null);async function o(){n(!0),i(null);try{let l=await $.get("/api/migrate.php");i(l),e?.()}catch(l){i({error:l.message})}n(!1)}return(0,s.jsxs)("div",{style:{marginBottom:"16px",padding:"10px 12px",background:"rgba(255,255,255,0.04)",border:"1px solid rgba(255,255,255,0.1)",borderRadius:"10px"},children:[(0,s.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",gap:"8px"},children:[(0,s.jsxs)("div",{style:{fontSize:"12px",fontWeight:700,color:"#cbd5e1"},children:["🔧"," DB-Migrationen"]}),(0,s.jsx)("button",{onClick:o,disabled:t,style:{padding:"5px 12px",borderRadius:"8px",border:"1px solid rgba(99,102,241,0.4)",background:"rgba(99,102,241,0.15)",color:"#a5b4fc",fontSize:"11px",fontWeight:700,cursor:t?"default":"pointer"},children:t?"Laeuft...":"Ausfuehren"})]}),r&&(0,s.jsx)("div",{style:{marginTop:"8px",fontSize:"11px",color:r.error?"#fca5a5":"#34d399"},children:r.error?`Fehler: ${r.error}`:(0,s.jsxs)(s.Fragment,{children:[r.applied?.length?(0,s.jsxs)("div",{children:["✅"," ",r.applied.join(", ")]}):null,r.skipped?.length?(0,s.jsxs)("div",{style:{color:"#94a3b8"},children:["ℹ️"," ",r.skipped.join(", ")]}):null,!r.applied?.length&&!r.skipped?.length&&(0,s.jsx)("div",{children:"OK"})]})})]})}function O0({allUnits:e,onUnitsChanged:t}){let[n,r]=(0,w.useState)(null),[i,o]=(0,w.useState)(null),[l,a]=(0,w.useState)("englisch"),[u,c]=(0,w.useState)(""),d=(0,w.useRef)(null),h=(0,w.useRef)(null),[m,v]=(0,w.useState)(null);async function C(x){let b=Array.from(x.target.files||[]).sort((S,F)=>S.name.localeCompare(F.name,void 0,{numeric:!0}));if(!(!b.length||!m)){r(m);try{let S=await Promise.all(b.map(I=>Bs(I))),F=10,D=0;for(let I=0;IS.name.localeCompare(F.name,void 0,{numeric:!0}));if(b.length){r("upload");try{c(`Komprimiere ${b.length} Bilder...`);let S=await Promise.all(b.map(R=>Bs(R))),F="temp_"+Date.now(),D=10;for(let R=0;R({subject:x,units:(e||[]).filter(b=>(b.subject||"englisch")===x.key)}));return(0,s.jsxs)("div",{style:{marginBottom:"16px"},children:[(0,s.jsx)("input",{type:"file",ref:h,accept:"image/*",multiple:!0,style:{display:"none"},onChange:C}),(0,s.jsxs)("div",{style:{fontSize:"11px",fontWeight:700,color:"#94a3b8",marginBottom:"10px",textTransform:"uppercase",letterSpacing:"1px"},children:["📖"," Units verwalten"]}),y.map(({subject:x,units:b})=>(0,s.jsxs)("div",{style:{marginBottom:"14px"},children:[(0,s.jsxs)("div",{style:{fontSize:"12px",fontWeight:700,color:x.accent,marginBottom:"6px",display:"flex",alignItems:"center",gap:"6px"},children:[(0,s.jsx)("span",{children:x.icon}),x.label," ",(0,s.jsxs)("span",{style:{color:"#94a3b8",fontWeight:500},children:["(",b.length,")"]})]}),b.length===0&&(0,s.jsx)("div",{style:{fontSize:"11px",color:"#94a3b8",padding:"4px 0 8px",fontStyle:"italic"},children:"Noch keine Units"}),b.map(S=>(0,s.jsxs)("div",{style:{background:"rgba(255,255,255,0.05)",border:"1px solid rgba(255,255,255,0.08)",borderRadius:"12px",padding:"10px 12px",marginBottom:"6px"},children:[(0,s.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"4px"},children:[(0,s.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"8px",flex:1,minWidth:0},children:[(0,s.jsx)("span",{style:{fontWeight:700,fontSize:"13px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:S.title}),!!S.is_active&&(0,s.jsxs)("span",{style:{fontSize:"9px",fontWeight:700,color:"#34d399",background:"rgba(52,211,153,0.15)",padding:"2px 7px",borderRadius:"99px",flexShrink:0},children:["✅"," Aktiv"]})]}),(0,s.jsxs)("div",{style:{display:"flex",gap:"4px",flexShrink:0},children:[!S.is_active&&(0,s.jsx)("button",{disabled:n===S.unit_key,onClick:()=>k(S.unit_key),style:{padding:"3px 8px",borderRadius:"6px",border:"1px solid rgba(99,102,241,0.4)",background:"rgba(99,102,241,0.15)",color:"#a5b4fc",fontSize:"10px",cursor:"pointer",fontWeight:700},children:"Aktivieren"}),S.is_active&&(0,s.jsx)("button",{disabled:n===S.unit_key,onClick:()=>L(S.unit_key),style:{padding:"3px 8px",borderRadius:"6px",border:"1px solid rgba(251,191,36,0.4)",background:"rgba(251,191,36,0.12)",color:"#fcd34d",fontSize:"10px",cursor:"pointer",fontWeight:700},children:"Verstecken"}),!S.is_active&&(0,s.jsx)("button",{disabled:n===S.unit_key,onClick:()=>f(S.unit_key),style:{padding:"3px 8px",borderRadius:"6px",border:"1px solid rgba(239,68,68,0.3)",background:"transparent",color:"#fca5a5",fontSize:"10px",cursor:"pointer"},children:"Loeschen"})]})]}),(0,s.jsxs)("div",{style:{fontSize:"10px",color:"#94a3b8",display:"flex",alignItems:"center",gap:"6px",flexWrap:"wrap"},children:[(0,s.jsxs)("span",{children:[S.unit_key," ","·"," ",S.sessions?.length||0," Sessions",S.description?` — ${S.description}`:""]}),S.images?.length>0&&(0,s.jsxs)("span",{style:{color:"#60a5fa"},children:["📸"," ",S.images.length," Bilder"]}),(0,s.jsx)("button",{onClick:()=>{v(S.unit_key),setTimeout(()=>h.current?.click(),50)},disabled:n===S.unit_key,style:{padding:"1px 6px",borderRadius:"4px",border:"1px solid rgba(99,102,241,0.3)",background:"transparent",color:"#a5b4fc",fontSize:"9px",cursor:"pointer"},children:"📸+"})]})]},S.unit_key))]},x.key)),(0,s.jsxs)("div",{style:{marginTop:"8px",padding:"10px",borderRadius:"10px",background:"rgba(255,255,255,0.04)",border:"1px solid rgba(255,255,255,0.08)"},children:[(0,s.jsx)("div",{style:{fontSize:"11px",fontWeight:700,color:"#cbd5e1",marginBottom:"8px"},children:"Neue Unit aus Fotos"}),(0,s.jsx)("div",{style:{display:"flex",gap:"6px",marginBottom:"8px"},children:Et.map(x=>(0,s.jsxs)("button",{onClick:()=>a(x.key),style:{flex:1,padding:"6px",borderRadius:"8px",border:l===x.key?`1px solid ${x.accent}`:"1px solid rgba(255,255,255,0.12)",background:l===x.key?x.bgTint:"transparent",color:l===x.key?x.accent:"#cbd5e1",fontSize:"11px",fontWeight:l===x.key?700:500,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",gap:"4px"},children:[x.icon," ",x.label]},x.key))}),(0,s.jsx)("input",{type:"file",ref:d,accept:"image/*",multiple:!0,style:{display:"none"},onChange:p}),(0,s.jsx)("button",{disabled:n==="upload",onClick:()=>d.current?.click(),style:{width:"100%",padding:"10px",borderRadius:"10px",border:`1px dashed ${Ge(l).accent}66`,background:Ge(l).bgTint,color:Ge(l).accent,fontSize:"13px",fontWeight:700,cursor:"pointer"},children:n==="upload"?u||"Analysiere...":`📷 Fotos fuer ${Ge(l).label} hochladen`})]}),i&&(0,s.jsxs)("div",{style:{marginTop:"10px",background:"rgba(99,102,241,0.08)",border:"1px solid rgba(99,102,241,0.3)",borderRadius:"12px",padding:"12px"},children:[(0,s.jsxs)("div",{style:{fontSize:"11px",color:Ge(i.subject).accent,marginBottom:"4px",fontWeight:700},children:[Ge(i.subject).icon," ",Ge(i.subject).label]}),(0,s.jsxs)("div",{style:{fontSize:"12px",fontWeight:700,color:"#a5b4fc",marginBottom:"6px"},children:["Vorschau: ",i.title]}),(0,s.jsxs)("div",{style:{fontSize:"11px",color:"#94a3b8",marginBottom:"8px"},children:[i.unit_key," ","·"," ",i.sessions?.length||0," Sessions"]}),(0,s.jsx)("ul",{style:{fontSize:"12px",color:"#cbd5e1",margin:"0 0 10px 18px",padding:0},children:i.sessions?.map(x=>(0,s.jsxs)("li",{children:[x.icon," ",x.title," ","—"," ",(0,s.jsx)("span",{style:{color:"#94a3b8"},children:x.desc})]},x.id))}),(0,s.jsxs)("div",{style:{display:"flex",gap:"6px"},children:[(0,s.jsx)("button",{onClick:()=>g(!1),disabled:n==="upload",style:{padding:"6px 12px",borderRadius:"8px",border:"1px solid rgba(255,255,255,0.15)",background:"transparent",color:"#fff",fontSize:"12px",cursor:"pointer"},children:"Speichern"}),(0,s.jsx)("button",{onClick:()=>g(!0),disabled:n==="upload",style:{padding:"6px 12px",borderRadius:"8px",border:"none",background:"#6366f1",color:"#fff",fontSize:"12px",fontWeight:700,cursor:"pointer"},children:"Speichern + Aktivieren"}),(0,s.jsx)("button",{onClick:()=>o(null),style:{marginLeft:"auto",padding:"6px 12px",borderRadius:"8px",border:"1px solid rgba(239,68,68,0.3)",background:"transparent",color:"#fca5a5",fontSize:"12px",cursor:"pointer"},children:"Verwerfen"})]})]})]})}function $0(){let[e,t]=(0,w.useState)([]),[n,r]=(0,w.useState)(!0),[i,o]=(0,w.useState)(null),[l,a]=(0,w.useState)({});(0,w.useEffect)(()=>{$.get("/api/telegram.php").then(d=>{t(d.users||[]),r(!1)}).catch(()=>r(!1))},[]);async function u(){try{await $.post("/api/telegram.php",{action:"save",...l});let d=await $.get("/api/telegram.php");t(d.users||[]),o(null)}catch(d){alert(d.message)}}async function c(d){try{await $.post("/api/telegram.php",{action:"test",user_id:d}),alert("Test gesendet!")}catch(h){alert(h.message)}}return n?(0,s.jsx)("div",{style:{color:"#94a3b8",fontSize:"13px"},children:"Laden..."}):(0,s.jsxs)("div",{children:[(0,s.jsxs)("div",{style:{fontSize:"11px",fontWeight:700,color:"#94a3b8",marginBottom:"10px",textTransform:"uppercase",letterSpacing:"1px"},children:["📨"," Telegram-Benachrichtigungen"]}),e.map(d=>{let h=!!d.bot_token,m=i===d.id;return(0,s.jsxs)("div",{style:{background:"rgba(255,255,255,0.05)",border:"1px solid rgba(255,255,255,0.08)",borderRadius:"12px",padding:"12px 14px",marginBottom:"8px"},children:[(0,s.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"6px"},children:[(0,s.jsx)("span",{style:{fontWeight:700,fontSize:"14px"},children:d.nickname}),(0,s.jsxs)("div",{style:{display:"flex",gap:"6px"},children:[h&&(0,s.jsx)("button",{onClick:()=>c(d.id),style:{padding:"3px 8px",borderRadius:"6px",border:"1px solid rgba(52,211,153,0.3)",background:"transparent",color:"#34d399",fontSize:"10px",cursor:"pointer"},children:"Test"}),(0,s.jsx)("button",{onClick:()=>{o(m?null:d.id),a({user_id:d.id,bot_token:d.bot_token||"",chat_id:d.chat_id||"",worker_url:d.worker_url||"",active:d.active??1})},style:{padding:"3px 8px",borderRadius:"6px",border:"1px solid rgba(255,255,255,0.15)",background:"transparent",color:"#94a3b8",fontSize:"10px",cursor:"pointer"},children:m?"Abbrechen":h?"Bearbeiten":"Einrichten"})]})]}),h&&!m&&(0,s.jsxs)("div",{style:{fontSize:"11px",color:d.active?"#34d399":"#ef4444"},children:[d.active?"✅ Aktiv":"❌ Deaktiviert"," ","—"," Auto-Push bei Session-Ende"]}),m&&(0,s.jsxs)("div",{style:{marginTop:"8px",display:"flex",flexDirection:"column",gap:"6px"},children:[[["bot_token","Bot Token"],["chat_id","Chat ID"],["worker_url","Worker URL (optional)"]].map(([v,C])=>(0,s.jsx)("input",{value:l[v]||"",onChange:k=>a(L=>({...L,[v]:k.target.value})),placeholder:C,style:{padding:"8px 10px",borderRadius:"8px",border:"1px solid rgba(255,255,255,0.12)",background:"rgba(255,255,255,0.04)",color:"#fff",fontSize:"12px",outline:"none"}},v)),(0,s.jsxs)("div",{style:{display:"flex",gap:"8px"},children:[(0,s.jsxs)("label",{style:{fontSize:"12px",color:"#94a3b8",display:"flex",alignItems:"center",gap:"6px"},children:[(0,s.jsx)("input",{type:"checkbox",checked:!!l.active,onChange:v=>a(C=>({...C,active:v.target.checked?1:0}))})," Aktiv"]}),(0,s.jsx)("button",{onClick:u,style:{marginLeft:"auto",padding:"6px 14px",borderRadius:"8px",border:"none",background:"#6366f1",color:"#fff",fontSize:"12px",fontWeight:700,cursor:"pointer"},children:"Speichern"})]})]})]},d.id)})]})}function j0({data:e,pts:t,user:n,adminUsage:r,unitKey:i,unitLabel:o,allUnits:l,onUnitsChanged:a,currentSubject:u}){let[c,d]=(0,w.useState)("student"),[h,m]=(0,w.useState)(0),v=n?.role==="admin",C=Ge(u),k=e?.lastActivity,L=e?x0(e.totalPoints):null,f=e?k0(e.totalPoints):null,p=f&&L?Math.min(100,Math.round((e.totalPoints-L.min)/(f.min-L.min)*100)):100,g=e?Et.reduce((y,x)=>(y[x.key]=(l||[]).filter(b=>(b.subject||"englisch")===x.key).reduce((b,S)=>b+(e.unitPoints?.[S.unit_key]||0),0),y),{}):{};return(0,s.jsxs)("div",{style:{padding:"16px"},children:[k&&(0,s.jsxs)("div",{style:{background:"linear-gradient(135deg, rgba(99,102,241,0.15), rgba(139,92,246,0.1))",border:"1px solid rgba(99,102,241,0.25)",borderRadius:"12px",padding:"12px 14px",marginBottom:"16px",display:"flex",alignItems:"center",gap:"12px"},children:[(0,s.jsx)("div",{style:{fontSize:"28px"},children:"📍"}),(0,s.jsxs)("div",{style:{flex:1},children:[(0,s.jsxs)("div",{style:{fontSize:"13px",fontWeight:700,color:"#a5b4fc"},children:["Zuletzt aktiv ",k.subject&&`· ${Ge(k.subject).icon} ${Ge(k.subject).label}`]}),(0,s.jsx)("div",{style:{fontSize:"14px",color:"#fff",fontWeight:600,marginTop:"2px"},children:k.topic}),(0,s.jsxs)("div",{style:{fontSize:"12px",color:"#94a3b8",marginTop:"2px"},children:[k.date," um ",k.time," ","—"," ",k.pointsThisSession," ","⭐"," gesammelt"]})]})]}),v&&(0,s.jsx)("div",{style:{display:"flex",gap:"8px",marginBottom:"16px"},children:["student","admin"].map(y=>(0,s.jsx)("button",{onClick:()=>d(y),style:{flex:1,padding:"8px",borderRadius:"10px",border:"1px solid rgba(255,255,255,0.15)",background:c===y?"rgba(255,255,255,0.12)":"transparent",color:"#fff",fontWeight:c===y?700:400,cursor:"pointer",fontSize:"13px"},children:y==="student"?"🎮 Fortschritt":"👩‍🏫 Admin"},y))}),c==="student"?e?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{style:{background:"rgba(255,255,255,0.06)",borderRadius:"16px",padding:"20px",marginBottom:"16px",textAlign:"center"},children:[(0,s.jsx)("div",{style:{fontSize:"44px",marginBottom:"4px"},children:L.name.split(" ")[0]}),(0,s.jsx)("div",{style:{fontSize:"20px",fontWeight:800,color:"#fbbf24"},children:L.name}),(0,s.jsxs)("div",{style:{fontSize:"36px",fontWeight:900,color:"#34d399",margin:"8px 0"},children:[e.totalPoints," ","⭐"]}),(0,s.jsx)("div",{style:{display:"flex",justifyContent:"center",gap:"8px",marginTop:"8px",flexWrap:"wrap"},children:Et.map(y=>(0,s.jsxs)("div",{style:{fontSize:"11px",padding:"3px 10px",borderRadius:"99px",background:y.key===u?y.bgTint:"rgba(255,255,255,0.04)",border:`1px solid ${y.key===u?y.accent+"55":"rgba(255,255,255,0.08)"}`,color:y.key===u?y.accent:"#cbd5e1"},children:[y.icon," ",g[y.key]||0," ","⭐"]},y.key))})]}),(0,s.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"10px",marginBottom:"16px"},children:[(0,s.jsx)(Fd,{icon:"🔥",label:"Streak",value:`${e.currentStreak} Tage`,color:"#f97316"}),(0,s.jsx)(Fd,{icon:"📚",label:"Sessions",value:e.sessionsCompleted||0,color:"#60a5fa"})]}),f&&(0,s.jsxs)("div",{style:{background:"rgba(255,255,255,0.06)",borderRadius:"12px",padding:"14px",marginBottom:"16px"},children:[(0,s.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",fontSize:"12px",color:"#94a3b8",marginBottom:"8px"},children:[(0,s.jsx)("span",{children:L.name}),(0,s.jsxs)("span",{children:[f.name," (",f.min-e.totalPoints," Pkt.)"]})]}),(0,s.jsx)("div",{style:{background:"rgba(255,255,255,0.1)",borderRadius:"99px",height:"10px"},children:(0,s.jsx)("div",{style:{height:"10px",borderRadius:"99px",width:`${p}%`,background:"linear-gradient(90deg,#34d399,#059669)"}})})]}),(0,s.jsx)(L0,{unitKey:i,unitLabel:o}),e.sessionHistory?.length>0&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{style:{fontSize:"11px",fontWeight:700,color:"#94a3b8",marginBottom:"10px",textTransform:"uppercase",letterSpacing:"1px"},children:"Session-Berichte"}),e.sessionHistory.map((y,x)=>{let b=Ge(y.subject||"englisch"),S=b.exerciseLabels;return(0,s.jsxs)("div",{style:{background:"rgba(255,255,255,0.05)",border:"1px solid rgba(255,255,255,0.08)",borderRadius:"12px",marginBottom:"8px"},children:[(0,s.jsxs)("div",{onClick:()=>m(h===x?-1:x),style:{padding:"12px 14px",cursor:"pointer",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("span",{style:{fontWeight:700,fontSize:"13px"},children:y.date}),(0,s.jsx)("span",{style:{color:b.accent,marginLeft:"6px",fontSize:"11px"},children:b.icon}),(0,s.jsx)("span",{style:{color:"#94a3b8",marginLeft:"8px",fontSize:"12px"},children:y.topic})]}),(0,s.jsxs)("span",{style:{color:"#fbbf24",fontWeight:700,fontSize:"13px"},children:["+",y.pointsEarned," ","⭐"]})]}),h===x&&(0,s.jsxs)("div",{style:{padding:"0 14px 12px",borderTop:"1px solid rgba(255,255,255,0.06)",paddingTop:"10px",fontSize:"12px"},children:[(0,s.jsx)(An,{l:S.vocab,v:`${y.vocabCorrect}/${y.vocabTotal}`}),(0,s.jsx)(An,{l:S.grammar,v:`${y.grammarCorrect}/${y.grammarTotal}`}),y.strongItems?.length>0&&(0,s.jsx)(An,{l:"💪 Stark",v:y.strongItems.join(", "),c:"#34d399"}),y.weakItems?.length>0&&(0,s.jsx)(An,{l:"🔄 Üben",v:y.weakItems.join(", "),c:"#fcd34d"}),y.teacherNote&&(0,s.jsx)(An,{l:"📝",v:y.teacherNote}),y.recommendation&&(0,s.jsx)(An,{l:"➡️",v:y.recommendation,c:"#60a5fa"})]})]},x)})]})]}):(0,s.jsxs)("div",{style:{padding:"30px 20px",textAlign:"center",color:"rgba(255,255,255,0.4)"},children:[(0,s.jsx)("div",{style:{fontSize:"48px",marginBottom:"12px"},children:"🌱"}),(0,s.jsx)("div",{style:{fontSize:"16px",fontWeight:700,color:"rgba(255,255,255,0.6)",marginBottom:"8px"},children:"Noch keine Daten!"}),(0,s.jsxs)("div",{style:{fontSize:"13px",lineHeight:1.6},children:["Starte eine Session oder chatte mit ",C.persona,",",(0,s.jsx)("br",{}),"dann siehst du hier deinen Fortschritt."]})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(W0,{onDone:a}),(0,s.jsx)(O0,{allUnits:l,onUnitsChanged:a}),(0,s.jsx)(H0,{adminUsage:r}),(0,s.jsx)("div",{style:{marginTop:"16px"},children:(0,s.jsx)($0,{})})]})]})}var U0=[{key:"today",label:"Heute"},{key:"month",label:"Monat"},{key:"total",label:"Gesamt"}];function H0({adminUsage:e}){let[t,n]=(0,w.useState)("total"),r=l=>(l=parseInt(l||0),l>=1e6?`${(l/1e6).toFixed(1)}M`:l>=1e3?`${(l/1e3).toFixed(0)}K`:`${l}`);function i(l){return t==="today"?{calls:l.today_calls,tokIn:l.today_tokens_in,tokOut:l.today_tokens_out,cost:l.today_cost}:t==="month"?{calls:l.month_calls,tokIn:l.month_tokens_in,tokOut:l.month_tokens_out,cost:l.month_cost}:{calls:l.total_calls,tokIn:l.total_tokens_in,tokOut:l.total_tokens_out,cost:l.total_cost}}let o=(e||[]).reduce((l,a)=>l+parseFloat(i(a).cost||0),0);return(0,s.jsxs)("div",{style:{marginBottom:"16px"},children:[(0,s.jsxs)("div",{style:{fontSize:"11px",fontWeight:700,color:"#94a3b8",marginBottom:"10px",textTransform:"uppercase",letterSpacing:"1px"},children:["📊"," User & Verbrauch"]}),(0,s.jsx)("div",{style:{display:"flex",gap:"4px",marginBottom:"10px",padding:"3px",background:"rgba(255,255,255,0.04)",borderRadius:"10px"},children:U0.map(l=>(0,s.jsx)("button",{onClick:()=>n(l.key),style:{flex:1,padding:"5px 4px",borderRadius:"8px",border:"none",cursor:"pointer",background:t===l.key?"rgba(255,255,255,0.12)":"transparent",color:t===l.key?"#fff":"rgba(255,255,255,0.5)",fontWeight:t===l.key?700:500,fontSize:"11px"},children:l.label},l.key))}),(0,s.jsxs)("div",{style:{textAlign:"right",fontSize:"11px",color:"#fbbf24",fontWeight:700,marginBottom:"2px"},children:["∑ ≈ $",o.toFixed(2)," ",(0,s.jsxs)("span",{style:{color:"#94a3b8",fontWeight:500},children:["(ca. ",(o*.92).toFixed(2)," ","€",")"]})]}),(0,s.jsx)("div",{style:{textAlign:"right",fontSize:"9px",color:"#64748b",marginBottom:"8px"},children:"≈ geschätzt · echte Kosten: Anthropic Console"}),(e||[]).map((l,a)=>{let u=i(l),c=parseInt(u.tokIn||0),d=parseInt(u.tokOut||0),h=parseInt(u.calls||0),m=parseFloat(u.cost||0),v=parseInt(l.total_cached||0),C=parseInt(l.total_tokens_in||0);return(0,s.jsxs)("div",{style:{background:"rgba(255,255,255,0.05)",border:"1px solid rgba(255,255,255,0.08)",borderRadius:"12px",padding:"10px 12px",marginBottom:"6px"},children:[(0,s.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"4px"},children:[(0,s.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"6px"},children:[(0,s.jsx)("span",{style:{fontWeight:700,fontSize:"13px"},children:l.nickname}),(0,s.jsx)("span",{style:{fontSize:"9px",padding:"1px 6px",borderRadius:"99px",background:l.role==="admin"?"rgba(139,92,246,0.2)":"rgba(99,102,241,0.15)",color:l.role==="admin"?"#c4b5fd":"#a5b4fc"},children:l.role})]}),(0,s.jsxs)("span",{style:{fontSize:"14px",fontWeight:800,color:"#fbbf24"},children:["≈ $",m.toFixed(2)]})]}),(0,s.jsx)("div",{style:{fontSize:"10px",color:"#94a3b8",marginBottom:"4px"},children:l.email}),(0,s.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",gap:"4px 12px",fontSize:"10px",color:"#cbd5e1"},children:[(0,s.jsxs)("span",{children:[h," Calls"]}),(0,s.jsxs)("span",{children:["⬆️"," ",r(c)," In"]}),(0,s.jsxs)("span",{children:["⬇️"," ",r(d)," Out"]}),t==="total"&&v>0&&(0,s.jsxs)("span",{style:{color:"#34d399"},children:["💾"," ",r(v)," Cached (",Math.round(v/Math.max(C,1)*100),"%)"]})]}),(0,s.jsxs)("div",{style:{fontSize:"9px",color:"#64748b",marginTop:"3px"},children:["Registriert: ",l.created_at?.split(" ")[0]]})]},a)})]})}function Fd({icon:e,label:t,value:n,color:r}){return(0,s.jsxs)("div",{style:{background:"rgba(255,255,255,0.05)",borderRadius:"12px",padding:"12px",textAlign:"center"},children:[(0,s.jsx)("div",{style:{fontSize:"18px"},children:e}),(0,s.jsx)("div",{style:{fontSize:"16px",fontWeight:800,color:r},children:n}),(0,s.jsx)("div",{style:{fontSize:"10px",color:"#94a3b8",marginTop:"2px"},children:t})]})}function An({l:e,v:t,c:n}){return(0,s.jsxs)("div",{style:{display:"flex",gap:"8px",marginBottom:"4px"},children:[(0,s.jsxs)("span",{style:{color:"#94a3b8",minWidth:"90px",fontSize:"12px"},children:[e,":"]}),(0,s.jsx)("span",{style:{color:n||"#fff",fontSize:"12px"},children:t})]})}function V0(){let[e,t]=(0,w.useState)(null),[n,r]=(0,w.useState)(!0);return(0,w.useEffect)(()=>{if(!$.token){r(!1);return}$.get("/api/progress.php").then(i=>{t(i.user),r(!1)}).catch(()=>{$.setToken(null),r(!1)})},[]),n?(0,s.jsx)("div",{style:{height:"100%",display:"flex",alignItems:"center",justifyContent:"center",background:"#0f172a",color:"#94a3b8"},children:"Laden..."}):e?(0,s.jsx)(N0,{user:e}):(0,s.jsx)(P0,{onLogin:t})}typeof window<"u"&&(location.hostname==="localhost"||location.search.includes("dev=1"))&&(window.__VANGII__={React:w.default,createRoot:Ds.createRoot,SUBJECTS:Et,renderMath:so,CenterMsg:Xe,BlitzQuiz:ao,Hangman:Td,WordSearch:Pd,Memory:Nd,ChallengeHub:Rd});(typeof window>"u"||!window.__VANGII_NO_MOUNT__)&&(0,Ds.createRoot)(document.getElementById("root")).render((0,s.jsx)(V0,{}))});K0();})(); /*! Bundled license information: react/cjs/react.production.min.js: (** * @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. *) scheduler/cjs/scheduler.production.min.js: (** * @license React * scheduler.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. *) react-dom/cjs/react-dom.production.min.js: (** * @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. *) react/cjs/react-jsx-runtime.production.min.js: (** * @license React * react-jsx-runtime.production.min.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. *) */