From f9ae3d6b96aa79fb6e4f9498f052aad6f6b0d436 Mon Sep 17 00:00:00 2001 From: Erik Date: Sun, 12 Apr 2026 22:23:38 +0200 Subject: [PATCH] debug(v2): log WindowRenderer to check if windows mount Co-Authored-By: Claude Opus 4.6 (1M context) --- frontend/src/components/windows/WindowRenderer.tsx | 3 +++ static/v2/assets/{index-Belkz_Ci.js => index-CvsOrcq1.js} | 2 +- static/v2/index.html | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) rename static/v2/assets/{index-Belkz_Ci.js => index-CvsOrcq1.js} (99%) diff --git a/frontend/src/components/windows/WindowRenderer.tsx b/frontend/src/components/windows/WindowRenderer.tsx index 19974d0e..39762f10 100644 --- a/frontend/src/components/windows/WindowRenderer.tsx +++ b/frontend/src/components/windows/WindowRenderer.tsx @@ -20,11 +20,14 @@ interface Props { export const WindowRenderer: React.FC = ({ characters, chatMessages, nearbyObjects, socket }) => { const { windows } = useWindowManager(); + console.log('[WR] Rendering', windows.length, 'windows:', windows.map(w => w.id)); + return ( <> {windows.map(w => { const charName = w.charName ?? ''; const prefix = w.id.split('-')[0]; + console.log('[WR] Window:', w.id, 'prefix:', prefix, 'charName:', charName); switch (prefix) { case 'chat': diff --git a/static/v2/assets/index-Belkz_Ci.js b/static/v2/assets/index-CvsOrcq1.js similarity index 99% rename from static/v2/assets/index-Belkz_Ci.js rename to static/v2/assets/index-CvsOrcq1.js index 09a8ac06..d54310a2 100644 --- a/static/v2/assets/index-Belkz_Ci.js +++ b/static/v2/assets/index-CvsOrcq1.js @@ -117,4 +117,4 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function NH(e,t){if(e){if(typeof e=="string")return K2(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return K2(e,t)}}function K2(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);ne*l)return!1;var u=n();return e*(t-e*u/2-r)>=0&&e*(t+e*u/2-l)<=0}function rG(e,t){return _R(e,t+1)}function aG(e,t,n,r,l){for(var u=(r||[]).slice(),c=t.start,f=t.end,d=0,h=1,y=c,v=function(){var j=r==null?void 0:r[d];if(j===void 0)return{v:_R(r,h)};var S=d,_,E=function(){return _===void 0&&(_=n(j,S)),_},w=j.coordinate,M=d===0||Af(e,w,E,y,f);M||(d=0,y=c,h+=1),M&&(y=w+e*(E()/2+l),d+=h)},g;h<=u.length;)if(g=v(),g)return g.v;return[]}function zu(e){"@babel/helpers - typeof";return zu=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},zu(e)}function Q2(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(l){return Object.getOwnPropertyDescriptor(e,l).enumerable})),n.push.apply(n,r)}return n}function Lt(e){for(var t=1;t0?x.coordinate-_*e:x.coordinate})}else u[g]=x=Lt(Lt({},x),{},{tickCoord:x.coordinate});var E=Af(e,x.tickCoord,S,f,d);E&&(d=x.tickCoord-e*(S()/2+l),u[g]=Lt(Lt({},x),{},{isShow:!0}))},y=c-1;y>=0;y--)h(y);return u}function cG(e,t,n,r,l,u){var c=(r||[]).slice(),f=c.length,d=t.start,h=t.end;if(u){var y=r[f-1],v=n(y,f-1),g=e*(y.coordinate+e*v/2-h);c[f-1]=y=Lt(Lt({},y),{},{tickCoord:g>0?y.coordinate-g*e:y.coordinate});var x=Af(e,y.tickCoord,function(){return v},d,h);x&&(h=y.tickCoord-e*(v/2+l),c[f-1]=Lt(Lt({},y),{},{isShow:!0}))}for(var j=u?f-1:f,S=function(w){var M=c[w],N,A=function(){return N===void 0&&(N=n(M,w)),N};if(w===0){var T=e*(M.coordinate-e*A()/2-d);c[w]=M=Lt(Lt({},M),{},{tickCoord:T<0?M.coordinate-T*e:M.coordinate})}else c[w]=M=Lt(Lt({},M),{},{tickCoord:M.coordinate});var C=Af(e,M.tickCoord,A,d,h);C&&(d=M.tickCoord+e*(A()/2+l),c[w]=Lt(Lt({},M),{},{isShow:!0}))},_=0;_=2?Yt(l[1].coordinate-l[0].coordinate):1,E=nG(u,_,x);return d==="equidistantPreserveStart"?aG(_,E,S,l,c):(d==="preserveStart"||d==="preserveStartEnd"?g=cG(_,E,S,l,c,d==="preserveStartEnd"):g=uG(_,E,S,l,c),g.filter(function(w){return w.isShow}))}var sG=["viewBox"],fG=["viewBox"],dG=["ticks"];function Ml(e){"@babel/helpers - typeof";return Ml=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Ml(e)}function il(){return il=Object.assign?Object.assign.bind():function(e){for(var t=1;t=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function hG(e,t){if(e==null)return{};var n={};for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){if(t.indexOf(r)>=0)continue;n[r]=e[r]}return n}function pG(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function eM(e,t){for(var n=0;n0?d(this.props):d(x)),c<=0||f<=0||!j||!j.length?null:I.createElement(Ye,{className:Me("recharts-cartesian-axis",h),ref:function(_){r.layerReference=_}},u&&this.renderAxisLine(),this.renderTicks(j,this.state.fontSize,this.state.letterSpacing),Mt.renderCallByParent(this.props))}}],[{key:"renderTickItem",value:function(r,l,u){var c,f=Me(l.className,"recharts-cartesian-axis-tick-value");return I.isValidElement(r)?c=I.cloneElement(r,St(St({},l),{},{className:f})):Se(r)?c=r(St(St({},l),{},{className:f})):c=I.createElement(ri,il({},l,{className:"recharts-cartesian-axis-tick-value"}),u),c}}])})(B.Component);fx(Hl,"displayName","CartesianAxis");fx(Hl,"defaultProps",{x:0,y:0,width:0,height:0,viewBox:{x:0,y:0,width:0,height:0},orientation:"bottom",ticks:[],stroke:"#666",tickLine:!0,axisLine:!0,tick:!0,mirror:!1,minTickGap:5,tickSize:6,tickMargin:2,interval:"preserveEnd"});var _G=["x1","y1","x2","y2","key"],SG=["offset"];function li(e){"@babel/helpers - typeof";return li=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},li(e)}function tM(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(l){return Object.getOwnPropertyDescriptor(e,l).enumerable})),n.push.apply(n,r)}return n}function It(e){for(var t=1;t=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function jG(e,t){if(e==null)return{};var n={};for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){if(t.indexOf(r)>=0)continue;n[r]=e[r]}return n}var TG=function(t){var n=t.fill;if(!n||n==="none")return null;var r=t.fillOpacity,l=t.x,u=t.y,c=t.width,f=t.height,d=t.ry;return I.createElement("rect",{x:l,y:u,ry:d,width:c,height:f,stroke:"none",fill:n,fillOpacity:r,className:"recharts-cartesian-grid-bg"})};function AR(e,t){var n;if(I.isValidElement(e))n=I.cloneElement(e,t);else if(Se(e))n=e(t);else{var r=t.x1,l=t.y1,u=t.x2,c=t.y2,f=t.key,d=nM(t,_G),h=_e(d,!1);h.offset;var y=nM(h,SG);n=I.createElement("line",Za({},y,{x1:r,y1:l,x2:u,y2:c,fill:"none",key:f}))}return n}function EG(e){var t=e.x,n=e.width,r=e.horizontal,l=r===void 0?!0:r,u=e.horizontalPoints;if(!l||!u||!u.length)return null;var c=u.map(function(f,d){var h=It(It({},e),{},{x1:t,y1:f,x2:t+n,y2:f,key:"line-".concat(d),index:d});return AR(l,h)});return I.createElement("g",{className:"recharts-cartesian-grid-horizontal"},c)}function MG(e){var t=e.y,n=e.height,r=e.vertical,l=r===void 0?!0:r,u=e.verticalPoints;if(!l||!u||!u.length)return null;var c=u.map(function(f,d){var h=It(It({},e),{},{x1:f,y1:t,x2:f,y2:t+n,key:"line-".concat(d),index:d});return AR(l,h)});return I.createElement("g",{className:"recharts-cartesian-grid-vertical"},c)}function CG(e){var t=e.horizontalFill,n=e.fillOpacity,r=e.x,l=e.y,u=e.width,c=e.height,f=e.horizontalPoints,d=e.horizontal,h=d===void 0?!0:d;if(!h||!t||!t.length)return null;var y=f.map(function(g){return Math.round(g+l-l)}).sort(function(g,x){return g-x});l!==y[0]&&y.unshift(0);var v=y.map(function(g,x){var j=!y[x+1],S=j?l+c-g:y[x+1]-g;if(S<=0)return null;var _=x%t.length;return I.createElement("rect",{key:"react-".concat(x),y:g,x:r,height:S,width:u,stroke:"none",fill:t[_],fillOpacity:n,className:"recharts-cartesian-grid-bg"})});return I.createElement("g",{className:"recharts-cartesian-gridstripes-horizontal"},v)}function NG(e){var t=e.vertical,n=t===void 0?!0:t,r=e.verticalFill,l=e.fillOpacity,u=e.x,c=e.y,f=e.width,d=e.height,h=e.verticalPoints;if(!n||!r||!r.length)return null;var y=h.map(function(g){return Math.round(g+u-u)}).sort(function(g,x){return g-x});u!==y[0]&&y.unshift(0);var v=y.map(function(g,x){var j=!y[x+1],S=j?u+f-g:y[x+1]-g;if(S<=0)return null;var _=x%r.length;return I.createElement("rect",{key:"react-".concat(x),x:g,y:c,width:S,height:d,stroke:"none",fill:r[_],fillOpacity:l,className:"recharts-cartesian-grid-bg"})});return I.createElement("g",{className:"recharts-cartesian-gridstripes-vertical"},v)}var RG=function(t,n){var r=t.xAxis,l=t.width,u=t.height,c=t.offset;return wN(sx(It(It(It({},Hl.defaultProps),r),{},{ticks:Er(r,!0),viewBox:{x:0,y:0,width:l,height:u}})),c.left,c.left+c.width,n)},PG=function(t,n){var r=t.yAxis,l=t.width,u=t.height,c=t.offset;return wN(sx(It(It(It({},Hl.defaultProps),r),{},{ticks:Er(r,!0),viewBox:{x:0,y:0,width:l,height:u}})),c.top,c.top+c.height,n)},Zi={horizontal:!0,vertical:!0,stroke:"#ccc",fill:"none",verticalFill:[],horizontalFill:[]};function jf(e){var t,n,r,l,u,c,f=lx(),d=ox(),h=xH(),y=It(It({},e),{},{stroke:(t=e.stroke)!==null&&t!==void 0?t:Zi.stroke,fill:(n=e.fill)!==null&&n!==void 0?n:Zi.fill,horizontal:(r=e.horizontal)!==null&&r!==void 0?r:Zi.horizontal,horizontalFill:(l=e.horizontalFill)!==null&&l!==void 0?l:Zi.horizontalFill,vertical:(u=e.vertical)!==null&&u!==void 0?u:Zi.vertical,verticalFill:(c=e.verticalFill)!==null&&c!==void 0?c:Zi.verticalFill,x:fe(e.x)?e.x:h.left,y:fe(e.y)?e.y:h.top,width:fe(e.width)?e.width:h.width,height:fe(e.height)?e.height:h.height}),v=y.x,g=y.y,x=y.width,j=y.height,S=y.syncWithTicks,_=y.horizontalValues,E=y.verticalValues,w=mH(),M=gH();if(!fe(x)||x<=0||!fe(j)||j<=0||!fe(v)||v!==+v||!fe(g)||g!==+g)return null;var N=y.verticalCoordinatesGenerator||RG,A=y.horizontalCoordinatesGenerator||PG,T=y.horizontalPoints,C=y.verticalPoints;if((!T||!T.length)&&Se(A)){var D=_&&_.length,z=A({yAxis:M?It(It({},M),{},{ticks:D?_:M.ticks}):void 0,width:f,height:d,offset:h},D?!0:S);Xn(Array.isArray(z),"horizontalCoordinatesGenerator should return Array but instead it returned [".concat(li(z),"]")),Array.isArray(z)&&(T=z)}if((!C||!C.length)&&Se(N)){var F=E&&E.length,X=N({xAxis:w?It(It({},w),{},{ticks:F?E:w.ticks}):void 0,width:f,height:d,offset:h},F?!0:S);Xn(Array.isArray(X),"verticalCoordinatesGenerator should return Array but instead it returned [".concat(li(X),"]")),Array.isArray(X)&&(C=X)}return I.createElement("g",{className:"recharts-cartesian-grid"},I.createElement(TG,{fill:y.fill,fillOpacity:y.fillOpacity,x:y.x,y:y.y,width:y.width,height:y.height,ry:y.ry}),I.createElement(EG,Za({},y,{offset:h,horizontalPoints:T,xAxis:w,yAxis:M})),I.createElement(MG,Za({},y,{offset:h,verticalPoints:C,xAxis:w,yAxis:M})),I.createElement(CG,Za({},y,{horizontalPoints:T})),I.createElement(NG,Za({},y,{verticalPoints:C})))}jf.displayName="CartesianGrid";function Cl(e){"@babel/helpers - typeof";return Cl=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Cl(e)}function DG(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function kG(e,t){for(var n=0;ne.length)&&(t=e.length);for(var n=0,r=new Array(t);n=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function SY(e,t){if(e==null)return{};var n={};for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){if(t.indexOf(r)>=0)continue;n[r]=e[r]}return n}function OY(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function AY(e,t){for(var n=0;ne.length)&&(t=e.length);for(var n=0,r=new Array(t);n0?c:t&&t.length&&fe(l)&&fe(u)?t.slice(l,u+1):[]};function zR(e){return e==="number"?[0,"auto"]:void 0}var ab=function(t,n,r,l){var u=t.graphicalItems,c=t.tooltipAxis,f=pd(n,t);return r<0||!u||!u.length||r>=f.length?null:u.reduce(function(d,h){var y,v=(y=h.props.data)!==null&&y!==void 0?y:n;v&&t.dataStartIndex+t.dataEndIndex!==0&&t.dataEndIndex-t.dataStartIndex>=r&&(v=v.slice(t.dataStartIndex,t.dataEndIndex+1));var g;if(c.dataKey&&!c.allowDuplicatedCategory){var x=v===void 0?f:v;g=Bg(x,c.dataKey,l)}else g=v&&v[r]||f[r];return g?[].concat(kl(d),[CN(h,g)]):d},[])},cM=function(t,n,r,l){var u=l||{x:t.chartX,y:t.chartY},c=$Y(u,r),f=t.orderedTooltipTicks,d=t.tooltipAxis,h=t.tooltipTicks,y=gB(c,f,h,d);if(y>=0&&h){var v=h[y]&&h[y].value,g=ab(t,n,y,v),x=zY(r,f,y,u);return{activeTooltipIndex:y,activeLabel:v,activePayload:g,activeCoordinate:x}}return null},qY=function(t,n){var r=n.axes,l=n.graphicalItems,u=n.axisType,c=n.axisIdKey,f=n.stackGroups,d=n.dataStartIndex,h=n.dataEndIndex,y=t.layout,v=t.children,g=t.stackOffset,x=AN(y,u);return r.reduce(function(j,S){var _,E=S.type.defaultProps!==void 0?ae(ae({},S.type.defaultProps),S.props):S.props,w=E.type,M=E.dataKey,N=E.allowDataOverflow,A=E.allowDuplicatedCategory,T=E.scale,C=E.ticks,D=E.includeHidden,z=E[c];if(j[z])return j;var F=pd(t.data,{graphicalItems:l.filter(function(Y){var ne,ue=c in Y.props?Y.props[c]:(ne=Y.type.defaultProps)===null||ne===void 0?void 0:ne[c];return ue===z}),dataStartIndex:d,dataEndIndex:h}),X=F.length,U,V,L;sY(E.domain,N,w)&&(U=b0(E.domain,null,N),x&&(w==="number"||T!=="auto")&&(L=tu(F,M,"category")));var G=zR(w);if(!U||U.length===0){var P,$=(P=E.domain)!==null&&P!==void 0?P:G;if(M){if(U=tu(F,M,w),w==="category"&&x){var W=d6(U);A&&W?(V=U,U=yf(0,X)):A||(U=pE($,U,S).reduce(function(Y,ne){return Y.indexOf(ne)>=0?Y:[].concat(kl(Y),[ne])},[]))}else if(w==="category")A?U=U.filter(function(Y){return Y!==""&&!Ce(Y)}):U=pE($,U,S).reduce(function(Y,ne){return Y.indexOf(ne)>=0||ne===""||Ce(ne)?Y:[].concat(kl(Y),[ne])},[]);else if(w==="number"){var ee=OB(F,l.filter(function(Y){var ne,ue,de=c in Y.props?Y.props[c]:(ne=Y.type.defaultProps)===null||ne===void 0?void 0:ne[c],me="hide"in Y.props?Y.props.hide:(ue=Y.type.defaultProps)===null||ue===void 0?void 0:ue.hide;return de===z&&(D||!me)}),M,u,y);ee&&(U=ee)}x&&(w==="number"||T!=="auto")&&(L=tu(F,M,"category"))}else x?U=yf(0,X):f&&f[z]&&f[z].hasStack&&w==="number"?U=g==="expand"?[0,1]:MN(f[z].stackGroups,d,h):U=ON(F,l.filter(function(Y){var ne=c in Y.props?Y.props[c]:Y.type.defaultProps[c],ue="hide"in Y.props?Y.props.hide:Y.type.defaultProps.hide;return ne===z&&(D||!ue)}),w,y,!0);if(w==="number")U=tb(v,U,z,u,C),$&&(U=b0($,U,N));else if(w==="category"&&$){var le=$,k=U.every(function(Y){return le.indexOf(Y)>=0});k&&(U=le)}}return ae(ae({},j),{},xe({},z,ae(ae({},E),{},{axisType:u,domain:U,categoricalDomain:L,duplicateDomain:V,originalDomain:(_=E.domain)!==null&&_!==void 0?_:G,isCategorical:x,layout:y})))},{})},BY=function(t,n){var r=n.graphicalItems,l=n.Axis,u=n.axisType,c=n.axisIdKey,f=n.stackGroups,d=n.dataStartIndex,h=n.dataEndIndex,y=t.layout,v=t.children,g=pd(t.data,{graphicalItems:r,dataStartIndex:d,dataEndIndex:h}),x=g.length,j=AN(y,u),S=-1;return r.reduce(function(_,E){var w=E.type.defaultProps!==void 0?ae(ae({},E.type.defaultProps),E.props):E.props,M=w[c],N=zR("number");if(!_[M]){S++;var A;return j?A=yf(0,x):f&&f[M]&&f[M].hasStack?(A=MN(f[M].stackGroups,d,h),A=tb(v,A,M,u)):(A=b0(N,ON(g,r.filter(function(T){var C,D,z=c in T.props?T.props[c]:(C=T.type.defaultProps)===null||C===void 0?void 0:C[c],F="hide"in T.props?T.props.hide:(D=T.type.defaultProps)===null||D===void 0?void 0:D.hide;return z===M&&!F}),"number",y),l.defaultProps.allowDataOverflow),A=tb(v,A,M,u)),ae(ae({},_),{},xe({},M,ae(ae({axisType:u},l.defaultProps),{},{hide:!0,orientation:mn(DY,"".concat(u,".").concat(S%2),null),domain:A,originalDomain:N,isCategorical:j,layout:y})))}return _},{})},LY=function(t,n){var r=n.axisType,l=r===void 0?"xAxis":r,u=n.AxisComp,c=n.graphicalItems,f=n.stackGroups,d=n.dataStartIndex,h=n.dataEndIndex,y=t.children,v="".concat(l,"Id"),g=Dn(y,u),x={};return g&&g.length?x=qY(t,{axes:g,graphicalItems:c,axisType:l,axisIdKey:v,stackGroups:f,dataStartIndex:d,dataEndIndex:h}):c&&c.length&&(x=BY(t,{Axis:u,graphicalItems:c,axisType:l,axisIdKey:v,stackGroups:f,dataStartIndex:d,dataEndIndex:h})),x},IY=function(t){var n=ya(t),r=Er(n,!1,!0);return{tooltipTicks:r,orderedTooltipTicks:Eb(r,function(l){return l.coordinate}),tooltipAxis:n,tooltipAxisBandSize:nf(n,r)}},sM=function(t){var n=t.children,r=t.defaultShowTooltip,l=pn(n,Al),u=0,c=0;return t.data&&t.data.length!==0&&(c=t.data.length-1),l&&l.props&&(l.props.startIndex>=0&&(u=l.props.startIndex),l.props.endIndex>=0&&(c=l.props.endIndex)),{chartX:0,chartY:0,dataStartIndex:u,dataEndIndex:c,activeTooltipIndex:-1,isTooltipActive:!!r}},UY=function(t){return!t||!t.length?!1:t.some(function(n){var r=Mr(n&&n.type);return r&&r.indexOf("Bar")>=0})},fM=function(t){return t==="horizontal"?{numericAxisName:"yAxis",cateAxisName:"xAxis"}:t==="vertical"?{numericAxisName:"xAxis",cateAxisName:"yAxis"}:t==="centric"?{numericAxisName:"radiusAxis",cateAxisName:"angleAxis"}:{numericAxisName:"angleAxis",cateAxisName:"radiusAxis"}},HY=function(t,n){var r=t.props,l=t.graphicalItems,u=t.xAxisMap,c=u===void 0?{}:u,f=t.yAxisMap,d=f===void 0?{}:f,h=r.width,y=r.height,v=r.children,g=r.margin||{},x=pn(v,Al),j=pn(v,Qa),S=Object.keys(d).reduce(function(A,T){var C=d[T],D=C.orientation;return!C.mirror&&!C.hide?ae(ae({},A),{},xe({},D,A[D]+C.width)):A},{left:g.left||0,right:g.right||0}),_=Object.keys(c).reduce(function(A,T){var C=c[T],D=C.orientation;return!C.mirror&&!C.hide?ae(ae({},A),{},xe({},D,mn(A,"".concat(D))+C.height)):A},{top:g.top||0,bottom:g.bottom||0}),E=ae(ae({},_),S),w=E.bottom;x&&(E.bottom+=x.props.height||Al.defaultProps.height),j&&n&&(E=_B(E,l,r,n));var M=h-E.left-E.right,N=y-E.top-E.bottom;return ae(ae({brushBottom:w},E),{},{width:Math.max(M,0),height:Math.max(N,0)})},GY=function(t,n){if(n==="xAxis")return t[n].width;if(n==="yAxis")return t[n].height},qR=function(t){var n=t.chartName,r=t.GraphicalChild,l=t.defaultTooltipEventType,u=l===void 0?"axis":l,c=t.validateTooltipEventTypes,f=c===void 0?["axis"]:c,d=t.axisComponents,h=t.legendContent,y=t.formatAxisMap,v=t.defaultProps,g=function(E,w){var M=w.graphicalItems,N=w.stackGroups,A=w.offset,T=w.updateId,C=w.dataStartIndex,D=w.dataEndIndex,z=E.barSize,F=E.layout,X=E.barGap,U=E.barCategoryGap,V=E.maxBarSize,L=fM(F),G=L.numericAxisName,P=L.cateAxisName,$=UY(M),W=[];return M.forEach(function(ee,le){var k=pd(E.data,{graphicalItems:[ee],dataStartIndex:C,dataEndIndex:D}),Y=ee.type.defaultProps!==void 0?ae(ae({},ee.type.defaultProps),ee.props):ee.props,ne=Y.dataKey,ue=Y.maxBarSize,de=Y["".concat(G,"Id")],me=Y["".concat(P,"Id")],Oe={},$e=d.reduce(function(qn,ir){var Gl=w["".concat(ir.axisType,"Map")],qt=Y["".concat(ir.axisType,"Id")];Gl&&Gl[qt]||ir.axisType==="zAxis"||ii();var Vu=Gl[qt];return ae(ae({},qn),{},xe(xe({},ir.axisType,Vu),"".concat(ir.axisType,"Ticks"),Er(Vu)))},Oe),se=$e[P],be=$e["".concat(P,"Ticks")],Ae=N&&N[de]&&N[de].hasStack&&RB(ee,N[de].stackGroups),ce=Mr(ee.type).indexOf("Bar")>=0,nt=nf(se,be),Te=[],ut=$&&bB({barSize:z,stackGroups:N,totalSize:GY($e,P)});if(ce){var ct,zt,zn=Ce(ue)?V:ue,Vn=(ct=(zt=nf(se,be,!0))!==null&&zt!==void 0?zt:zn)!==null&&ct!==void 0?ct:0;Te=xB({barGap:X,barCategoryGap:U,bandSize:Vn!==nt?Vn:nt,sizeList:ut[me],maxBarSize:zn}),Vn!==nt&&(Te=Te.map(function(qn){return ae(ae({},qn),{},{position:ae(ae({},qn.position),{},{offset:qn.position.offset-Vn/2})})}))}var Ir=ee&&ee.type&&ee.type.getComposedData;Ir&&W.push({props:ae(ae({},Ir(ae(ae({},$e),{},{displayedData:k,props:E,dataKey:ne,item:ee,bandSize:nt,barPosition:Te,offset:A,stackedData:Ae,layout:F,dataStartIndex:C,dataEndIndex:D}))),{},xe(xe(xe({key:ee.key||"item-".concat(le)},G,$e[G]),P,$e[P]),"animationId",T)),childIndex:A6(ee,E.children),item:ee})}),W},x=function(E,w){var M=E.props,N=E.dataStartIndex,A=E.dataEndIndex,T=E.updateId;if(!MA({props:M}))return null;var C=M.children,D=M.layout,z=M.stackOffset,F=M.data,X=M.reverseStackOrder,U=fM(D),V=U.numericAxisName,L=U.cateAxisName,G=Dn(C,r),P=CB(F,G,"".concat(V,"Id"),"".concat(L,"Id"),z,X),$=d.reduce(function(Y,ne){var ue="".concat(ne.axisType,"Map");return ae(ae({},Y),{},xe({},ue,LY(M,ae(ae({},ne),{},{graphicalItems:G,stackGroups:ne.axisType===V&&P,dataStartIndex:N,dataEndIndex:A}))))},{}),W=HY(ae(ae({},$),{},{props:M,graphicalItems:G}),w==null?void 0:w.legendBBox);Object.keys($).forEach(function(Y){$[Y]=y(M,$[Y],W,Y.replace("Map",""),n)});var ee=$["".concat(L,"Map")],le=IY(ee),k=g(M,ae(ae({},$),{},{dataStartIndex:N,dataEndIndex:A,updateId:T,graphicalItems:G,stackGroups:P,offset:W}));return ae(ae({formattedGraphicalItems:k,graphicalItems:G,offset:W,stackGroups:P},le),$)},j=(function(_){function E(w){var M,N,A;return OY(this,E),A=jY(this,E,[w]),xe(A,"eventEmitterSymbol",Symbol("rechartsEventEmitter")),xe(A,"accessibilityManager",new cY),xe(A,"handleLegendBBoxUpdate",function(T){if(T){var C=A.state,D=C.dataStartIndex,z=C.dataEndIndex,F=C.updateId;A.setState(ae({legendBBox:T},x({props:A.props,dataStartIndex:D,dataEndIndex:z,updateId:F},ae(ae({},A.state),{},{legendBBox:T}))))}}),xe(A,"handleReceiveSyncEvent",function(T,C,D){if(A.props.syncId===T){if(D===A.eventEmitterSymbol&&typeof A.props.syncMethod!="function")return;A.applySyncEvent(C)}}),xe(A,"handleBrushChange",function(T){var C=T.startIndex,D=T.endIndex;if(C!==A.state.dataStartIndex||D!==A.state.dataEndIndex){var z=A.state.updateId;A.setState(function(){return ae({dataStartIndex:C,dataEndIndex:D},x({props:A.props,dataStartIndex:C,dataEndIndex:D,updateId:z},A.state))}),A.triggerSyncEvent({dataStartIndex:C,dataEndIndex:D})}}),xe(A,"handleMouseEnter",function(T){var C=A.getMouseInfo(T);if(C){var D=ae(ae({},C),{},{isTooltipActive:!0});A.setState(D),A.triggerSyncEvent(D);var z=A.props.onMouseEnter;Se(z)&&z(D,T)}}),xe(A,"triggeredAfterMouseMove",function(T){var C=A.getMouseInfo(T),D=C?ae(ae({},C),{},{isTooltipActive:!0}):{isTooltipActive:!1};A.setState(D),A.triggerSyncEvent(D);var z=A.props.onMouseMove;Se(z)&&z(D,T)}),xe(A,"handleItemMouseEnter",function(T){A.setState(function(){return{isTooltipActive:!0,activeItem:T,activePayload:T.tooltipPayload,activeCoordinate:T.tooltipPosition||{x:T.cx,y:T.cy}}})}),xe(A,"handleItemMouseLeave",function(){A.setState(function(){return{isTooltipActive:!1}})}),xe(A,"handleMouseMove",function(T){T.persist(),A.throttleTriggeredAfterMouseMove(T)}),xe(A,"handleMouseLeave",function(T){A.throttleTriggeredAfterMouseMove.cancel();var C={isTooltipActive:!1};A.setState(C),A.triggerSyncEvent(C);var D=A.props.onMouseLeave;Se(D)&&D(C,T)}),xe(A,"handleOuterEvent",function(T){var C=O6(T),D=mn(A.props,"".concat(C));if(C&&Se(D)){var z,F;/.*touch.*/i.test(C)?F=A.getMouseInfo(T.changedTouches[0]):F=A.getMouseInfo(T),D((z=F)!==null&&z!==void 0?z:{},T)}}),xe(A,"handleClick",function(T){var C=A.getMouseInfo(T);if(C){var D=ae(ae({},C),{},{isTooltipActive:!0});A.setState(D),A.triggerSyncEvent(D);var z=A.props.onClick;Se(z)&&z(D,T)}}),xe(A,"handleMouseDown",function(T){var C=A.props.onMouseDown;if(Se(C)){var D=A.getMouseInfo(T);C(D,T)}}),xe(A,"handleMouseUp",function(T){var C=A.props.onMouseUp;if(Se(C)){var D=A.getMouseInfo(T);C(D,T)}}),xe(A,"handleTouchMove",function(T){T.changedTouches!=null&&T.changedTouches.length>0&&A.throttleTriggeredAfterMouseMove(T.changedTouches[0])}),xe(A,"handleTouchStart",function(T){T.changedTouches!=null&&T.changedTouches.length>0&&A.handleMouseDown(T.changedTouches[0])}),xe(A,"handleTouchEnd",function(T){T.changedTouches!=null&&T.changedTouches.length>0&&A.handleMouseUp(T.changedTouches[0])}),xe(A,"handleDoubleClick",function(T){var C=A.props.onDoubleClick;if(Se(C)){var D=A.getMouseInfo(T);C(D,T)}}),xe(A,"handleContextMenu",function(T){var C=A.props.onContextMenu;if(Se(C)){var D=A.getMouseInfo(T);C(D,T)}}),xe(A,"triggerSyncEvent",function(T){A.props.syncId!==void 0&&Dg.emit(kg,A.props.syncId,T,A.eventEmitterSymbol)}),xe(A,"applySyncEvent",function(T){var C=A.props,D=C.layout,z=C.syncMethod,F=A.state.updateId,X=T.dataStartIndex,U=T.dataEndIndex;if(T.dataStartIndex!==void 0||T.dataEndIndex!==void 0)A.setState(ae({dataStartIndex:X,dataEndIndex:U},x({props:A.props,dataStartIndex:X,dataEndIndex:U,updateId:F},A.state)));else if(T.activeTooltipIndex!==void 0){var V=T.chartX,L=T.chartY,G=T.activeTooltipIndex,P=A.state,$=P.offset,W=P.tooltipTicks;if(!$)return;if(typeof z=="function")G=z(W,T);else if(z==="value"){G=-1;for(var ee=0;ee=0){var Ae,ce;if(V.dataKey&&!V.allowDuplicatedCategory){var nt=typeof V.dataKey=="function"?be:"payload.".concat(V.dataKey.toString());Ae=Bg(ee,nt,G),ce=le&&k&&Bg(k,nt,G)}else Ae=ee==null?void 0:ee[L],ce=le&&k&&k[L];if(me||de){var Te=T.props.activeIndex!==void 0?T.props.activeIndex:L;return[B.cloneElement(T,ae(ae(ae({},z.props),$e),{},{activeIndex:Te})),null,null]}if(!Ce(Ae))return[se].concat(kl(A.renderActivePoints({item:z,activePoint:Ae,basePoint:ce,childIndex:L,isRange:le})))}else{var ut,ct=(ut=A.getItemByXY(A.state.activeCoordinate))!==null&&ut!==void 0?ut:{graphicalItem:se},zt=ct.graphicalItem,zn=zt.item,Vn=zn===void 0?T:zn,Ir=zt.childIndex,qn=ae(ae(ae({},z.props),$e),{},{activeIndex:Ir});return[B.cloneElement(Vn,qn),null,null]}return le?[se,null,null]:[se,null]}),xe(A,"renderCustomized",function(T,C,D){return B.cloneElement(T,ae(ae({key:"recharts-customized-".concat(D)},A.props),A.state))}),xe(A,"renderMap",{CartesianGrid:{handler:ws,once:!0},ReferenceArea:{handler:A.renderReferenceElement},ReferenceLine:{handler:ws},ReferenceDot:{handler:A.renderReferenceElement},XAxis:{handler:ws},YAxis:{handler:ws},Brush:{handler:A.renderBrush,once:!0},Bar:{handler:A.renderGraphicChild},Line:{handler:A.renderGraphicChild},Area:{handler:A.renderGraphicChild},Radar:{handler:A.renderGraphicChild},RadialBar:{handler:A.renderGraphicChild},Scatter:{handler:A.renderGraphicChild},Pie:{handler:A.renderGraphicChild},Funnel:{handler:A.renderGraphicChild},Tooltip:{handler:A.renderCursor,once:!0},PolarGrid:{handler:A.renderPolarGrid,once:!0},PolarAngleAxis:{handler:A.renderPolarAxis},PolarRadiusAxis:{handler:A.renderPolarAxis},Customized:{handler:A.renderCustomized}}),A.clipPathId="".concat((M=w.id)!==null&&M!==void 0?M:Uu("recharts"),"-clip"),A.throttleTriggeredAfterMouseMove=_C(A.triggeredAfterMouseMove,(N=w.throttleDelay)!==null&&N!==void 0?N:1e3/60),A.state={},A}return MY(E,_),wY(E,[{key:"componentDidMount",value:function(){var M,N;this.addListener(),this.accessibilityManager.setDetails({container:this.container,offset:{left:(M=this.props.margin.left)!==null&&M!==void 0?M:0,top:(N=this.props.margin.top)!==null&&N!==void 0?N:0},coordinateList:this.state.tooltipTicks,mouseHandlerCallback:this.triggeredAfterMouseMove,layout:this.props.layout}),this.displayDefaultTooltip()}},{key:"displayDefaultTooltip",value:function(){var M=this.props,N=M.children,A=M.data,T=M.height,C=M.layout,D=pn(N,vn);if(D){var z=D.props.defaultIndex;if(!(typeof z!="number"||z<0||z>this.state.tooltipTicks.length-1)){var F=this.state.tooltipTicks[z]&&this.state.tooltipTicks[z].value,X=ab(this.state,A,z,F),U=this.state.tooltipTicks[z].coordinate,V=(this.state.offset.top+T)/2,L=C==="horizontal",G=L?{x:U,y:V}:{y:U,x:V},P=this.state.formattedGraphicalItems.find(function(W){var ee=W.item;return ee.type.name==="Scatter"});P&&(G=ae(ae({},G),P.props.points[z].tooltipPosition),X=P.props.points[z].tooltipPayload);var $={activeTooltipIndex:z,isTooltipActive:!0,activeLabel:F,activePayload:X,activeCoordinate:G};this.setState($),this.renderCursor(D),this.accessibilityManager.setIndex(z)}}}},{key:"getSnapshotBeforeUpdate",value:function(M,N){if(!this.props.accessibilityLayer)return null;if(this.state.tooltipTicks!==N.tooltipTicks&&this.accessibilityManager.setDetails({coordinateList:this.state.tooltipTicks}),this.props.layout!==M.layout&&this.accessibilityManager.setDetails({layout:this.props.layout}),this.props.margin!==M.margin){var A,T;this.accessibilityManager.setDetails({offset:{left:(A=this.props.margin.left)!==null&&A!==void 0?A:0,top:(T=this.props.margin.top)!==null&&T!==void 0?T:0}})}return null}},{key:"componentDidUpdate",value:function(M){Ig([pn(M.children,vn)],[pn(this.props.children,vn)])||this.displayDefaultTooltip()}},{key:"componentWillUnmount",value:function(){this.removeListener(),this.throttleTriggeredAfterMouseMove.cancel()}},{key:"getTooltipEventType",value:function(){var M=pn(this.props.children,vn);if(M&&typeof M.props.shared=="boolean"){var N=M.props.shared?"axis":"item";return f.indexOf(N)>=0?N:u}return u}},{key:"getMouseInfo",value:function(M){if(!this.container)return null;var N=this.container,A=N.getBoundingClientRect(),T=s$(A),C={chartX:Math.round(M.pageX-T.left),chartY:Math.round(M.pageY-T.top)},D=A.width/N.offsetWidth||1,z=this.inRange(C.chartX,C.chartY,D);if(!z)return null;var F=this.state,X=F.xAxisMap,U=F.yAxisMap,V=this.getTooltipEventType(),L=cM(this.state,this.props.data,this.props.layout,z);if(V!=="axis"&&X&&U){var G=ya(X).scale,P=ya(U).scale,$=G&&G.invert?G.invert(C.chartX):null,W=P&&P.invert?P.invert(C.chartY):null;return ae(ae({},C),{},{xValue:$,yValue:W},L)}return L?ae(ae({},C),L):null}},{key:"inRange",value:function(M,N){var A=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,T=this.props.layout,C=M/A,D=N/A;if(T==="horizontal"||T==="vertical"){var z=this.state.offset,F=C>=z.left&&C<=z.left+z.width&&D>=z.top&&D<=z.top+z.height;return F?{x:C,y:D}:null}var X=this.state,U=X.angleAxisMap,V=X.radiusAxisMap;if(U&&V){var L=ya(U);return mE({x:C,y:D},L)}return null}},{key:"parseEventsOfWrapper",value:function(){var M=this.props.children,N=this.getTooltipEventType(),A=pn(M,vn),T={};A&&N==="axis"&&(A.props.trigger==="click"?T={onClick:this.handleClick}:T={onMouseEnter:this.handleMouseEnter,onDoubleClick:this.handleDoubleClick,onMouseMove:this.handleMouseMove,onMouseLeave:this.handleMouseLeave,onTouchMove:this.handleTouchMove,onTouchStart:this.handleTouchStart,onTouchEnd:this.handleTouchEnd,onContextMenu:this.handleContextMenu});var C=Ns(this.props,this.handleOuterEvent);return ae(ae({},C),T)}},{key:"addListener",value:function(){Dg.on(kg,this.handleReceiveSyncEvent)}},{key:"removeListener",value:function(){Dg.removeListener(kg,this.handleReceiveSyncEvent)}},{key:"filterFormatItem",value:function(M,N,A){for(var T=this.state.formattedGraphicalItems,C=0,D=T.length;C{const t=B.useMemo(()=>Array.from(e.values()).filter(l=>l.telemetry).map(l=>({name:l.name.length>18?l.name.slice(0,16)+"..":l.name,fullName:l.name,killsPerHour:parseInt(l.telemetry.kills_per_hour)||0,totalKills:l.telemetry.kills||0})).sort((l,u)=>u.killsPerHour-l.killsPerHour).slice(0,30),[e]),n=B.useMemo(()=>Array.from(e.values()).filter(l=>{var u;return(u=l.combat)==null?void 0:u.session}).map(l=>({name:l.name.length>18?l.name.slice(0,16)+"..":l.name,fullName:l.name,damage:l.combat.session.total_damage_given})).sort((l,u)=>u.damage-l.damage).slice(0,30),[e]),r=B.useMemo(()=>{var u;const l={};for(const c of e.values()){const f=(u=c.combat)==null?void 0:u.session;if(f!=null&&f.monsters){for(const d of Object.values(f.monsters))if(d.offense)for(const h of Object.values(d.offense))for(const[y,v]of Object.entries(h))y==="None"||y==="Unknown"||(l[y]=(l[y]||0)+(v.damage||0))}}return Object.entries(l).map(([c,f])=>({name:c,value:f})).filter(c=>c.value>0).sort((c,f)=>f.value-c.value)},[e]);return b.jsxs("div",{className:"combat-tab",children:[b.jsxs("div",{className:"chart-section",children:[b.jsx("h3",{className:"chart-title",children:"Kills per Hour"}),b.jsx(Es,{width:"100%",height:Math.max(200,t.length*28),children:b.jsxs(ib,{data:t,layout:"vertical",margin:{left:10,right:20,top:5,bottom:5},children:[b.jsx(jf,{strokeDasharray:"3 3",stroke:"#333"}),b.jsx(Nl,{type:"number",stroke:"#888",fontSize:11}),b.jsx(Pl,{type:"category",dataKey:"name",width:130,stroke:"#888",fontSize:11}),b.jsx(vn,{contentStyle:{background:"#1a1a1a",border:"1px solid #444",fontSize:12},formatter:l=>[l.toLocaleString(),"Kills/hr"],labelFormatter:(l,u)=>{var c,f;return((f=(c=u==null?void 0:u[0])==null?void 0:c.payload)==null?void 0:f.fullName)||l}}),b.jsx(kr,{dataKey:"killsPerHour",fill:"#44cc44",radius:[0,3,3,0]})]})})]}),n.length>0&&b.jsxs("div",{className:"chart-section",children:[b.jsx("h3",{className:"chart-title",children:"Total Damage (Session)"}),b.jsx(Es,{width:"100%",height:Math.max(200,n.length*28),children:b.jsxs(ib,{data:n,layout:"vertical",margin:{left:10,right:20,top:5,bottom:5},children:[b.jsx(jf,{strokeDasharray:"3 3",stroke:"#333"}),b.jsx(Nl,{type:"number",stroke:"#888",fontSize:11}),b.jsx(Pl,{type:"category",dataKey:"name",width:130,stroke:"#888",fontSize:11}),b.jsx(vn,{contentStyle:{background:"#1a1a1a",border:"1px solid #444",fontSize:12},formatter:l=>[l.toLocaleString(),"Damage"],labelFormatter:(l,u)=>{var c,f;return((f=(c=u==null?void 0:u[0])==null?void 0:c.payload)==null?void 0:f.fullName)||l}}),b.jsx(kr,{dataKey:"damage",fill:"#ff6644",radius:[0,3,3,0]})]})})]}),r.length>0&&b.jsxs("div",{className:"chart-section",children:[b.jsx("h3",{className:"chart-title",children:"Damage by Element (All Characters)"}),b.jsx(Es,{width:"100%",height:300,children:b.jsxs(YY,{children:[b.jsx(Lr,{data:r,dataKey:"value",nameKey:"name",cx:"50%",cy:"50%",outerRadius:100,label:({name:l,percent:u})=>`${l} ${(u*100).toFixed(0)}%`,labelLine:!0,fontSize:12,children:r.map(l=>b.jsx(Hf,{fill:XY[l.name]||"#888"},l.name))}),b.jsx(vn,{contentStyle:{background:"#1a1a1a",border:"1px solid #444",fontSize:12},formatter:l=>l.toLocaleString()}),b.jsx(Qa,{wrapperStyle:{fontSize:12,color:"#aaa"}})]})})]})]})},VY=({characters:e,totalRares:t,totalKills:n,recentRares:r})=>{const l=B.useMemo(()=>Array.from(e.values()).filter(c=>c.telemetry&&(c.telemetry.total_rares??0)>0).map(c=>({name:c.name.length>18?c.name.slice(0,16)+"..":c.name,fullName:c.name,rares:c.telemetry.total_rares??0})).sort((c,f)=>f.rares-c.rares),[e]),u=t>0?Math.round(n/t):0;return b.jsxs("div",{className:"rares-tab",children:[b.jsxs("div",{className:"rares-summary",children:[b.jsxs("div",{className:"rare-stat-card",children:[b.jsx("span",{className:"rare-stat-value",children:t}),b.jsx("span",{className:"rare-stat-label",children:"Total Rares Found"})]}),b.jsxs("div",{className:"rare-stat-card",children:[b.jsx("span",{className:"rare-stat-value",children:n.toLocaleString()}),b.jsx("span",{className:"rare-stat-label",children:"Total Kills"})]}),b.jsxs("div",{className:"rare-stat-card",children:[b.jsx("span",{className:"rare-stat-value",children:u>0?`1 in ${u.toLocaleString()}`:"--"}),b.jsx("span",{className:"rare-stat-label",children:"Drop Rate"})]})]}),r.length>0&&b.jsxs("div",{className:"chart-section",children:[b.jsx("h3",{className:"chart-title",children:"Recent Rare Drops (This Session)"}),b.jsx("div",{className:"rare-timeline",children:r.map((c,f)=>b.jsxs("div",{className:"rare-event",children:[b.jsx("span",{className:"rare-time",children:new Date(c.timestamp).toLocaleTimeString()}),b.jsx("span",{className:"rare-char",children:c.character_name}),b.jsx("span",{className:"rare-name",children:c.name})]},f))})]}),l.length>0&&b.jsxs("div",{className:"chart-section",children:[b.jsx("h3",{className:"chart-title",children:"Rares per Character (Lifetime)"}),b.jsx(Es,{width:"100%",height:Math.max(200,l.length*28),children:b.jsxs(ib,{data:l,layout:"vertical",margin:{left:10,right:20,top:5,bottom:5},children:[b.jsx(jf,{strokeDasharray:"3 3",stroke:"#333"}),b.jsx(Nl,{type:"number",stroke:"#888",fontSize:11}),b.jsx(Pl,{type:"category",dataKey:"name",width:130,stroke:"#888",fontSize:11}),b.jsx(vn,{contentStyle:{background:"#1a1a1a",border:"1px solid #444",fontSize:12},formatter:c=>[c,"Rares"],labelFormatter:(c,f)=>{var d,h;return((h=(d=f==null?void 0:f[0])==null?void 0:d.payload)==null?void 0:h.fullName)||c}}),b.jsx(kr,{dataKey:"rares",fill:"#ffcc00",radius:[0,3,3,0]})]})})]})]})},Qi={west:-102.1,east:102.1,north:102.1,south:-102.1},Cf=800;function FY(e,t){const n=(e-Qi.west)/(Qi.east-Qi.west)*Cf,r=(Qi.north-t)/(Qi.north-Qi.south)*Cf;return{x:n,y:r}}const WY=({characters:e})=>{const t=B.useRef(null),[n,r]=B.useState(null),l=B.useMemo(()=>Array.from(e.values()).filter(c=>c.telemetry&&c.telemetry.ew!==void 0).map(c=>{const f=c.telemetry,{x:d,y:h}=FY(f.ew,f.ns),y=(f.vt_state||"").toLowerCase()==="combat"||(f.vt_state||"").toLowerCase()==="hunt";return{name:c.name,x:d,y:h,isHunting:y,ns:f.ns,ew:f.ew}}),[e]),u=B.useCallback(c=>r(c),[]);return b.jsxs("div",{className:"map-tab",children:[b.jsxs("div",{className:"map-container",ref:t,children:[b.jsx("img",{src:"/dereth_highres.png",alt:"Dereth Map",className:"map-image",draggable:!1}),b.jsx("svg",{className:"map-overlay",viewBox:`0 0 ${Cf} ${Cf}`,children:l.map(c=>{var f,d;return b.jsxs("g",{children:[b.jsx("circle",{cx:c.x,cy:c.y,r:n===c.name?6:4,fill:c.isHunting?"#44cc44":"#ffaa00",stroke:"#000",strokeWidth:1,opacity:.9,onMouseEnter:()=>u(c.name),onMouseLeave:()=>u(null),style:{cursor:"pointer"}}),n===c.name&&b.jsxs("text",{x:c.x+8,y:c.y+4,fill:"#fff",fontSize:11,stroke:"#000",strokeWidth:.3,paintOrder:"stroke",children:[c.name," (",(f=c.ns)==null?void 0:f.toFixed(1),"N, ",(d=c.ew)==null?void 0:d.toFixed(1),"E)"]})]},c.name)})})]}),b.jsxs("div",{className:"map-legend",children:[b.jsxs("span",{children:[b.jsx("span",{className:"legend-dot hunting"})," Hunting/Combat"]}),b.jsxs("span",{children:[b.jsx("span",{className:"legend-dot other"})," Other state"]}),b.jsxs("span",{className:"map-count",children:[l.length," characters on map"]})]})]})},ZY="/api";async function Ht(e){const t=await fetch(`${ZY}${e}`,{credentials:"include"});if(!t.ok)throw new Error(`API ${e}: ${t.status}`);return t.json()}function QY(){return`${location.protocol==="https:"?"wss:":"ws:"}//${location.host}/api/ws/live`}const JY=()=>{const[e,t]=B.useState(""),[n,r]=B.useState([]),[l,u]=B.useState(0),[c,f]=B.useState(!1),d=B.useRef(0),h=B.useCallback(async v=>{if(v.length<2){r([]),u(0);return}f(!0);try{const g=await Ht(`/search/items?q=${encodeURIComponent(v)}&limit=100`);r(g.results??[]),u(g.total??0)}catch{r([])}f(!1)},[]),y=B.useCallback(v=>{const g=v.target.value;t(g),clearTimeout(d.current),d.current=window.setTimeout(()=>h(g),400)},[h]);return b.jsxs("div",{className:"inventory-tab",children:[b.jsxs("div",{className:"search-bar",children:[b.jsx("input",{type:"text",value:e,onChange:y,placeholder:"Search items across all characters...",className:"search-input"}),c&&b.jsx("span",{className:"search-spinner",children:"Searching..."})]}),l>0&&b.jsxs("div",{className:"search-count",children:[l.toLocaleString()," results"]}),b.jsxs("div",{className:"search-results",children:[n.length===0&&e.length>=2&&!c&&b.jsx("div",{className:"search-empty",children:"No items found"}),b.jsxs("table",{className:"results-table",children:[b.jsx("thead",{children:b.jsxs("tr",{children:[b.jsx("th",{children:"Character"}),b.jsx("th",{children:"Item"}),b.jsx("th",{children:"Type"}),b.jsx("th",{children:"Material"}),b.jsx("th",{children:"Set"}),b.jsx("th",{children:"Work"})]})}),b.jsx("tbody",{children:n.map((v,g)=>b.jsxs("tr",{children:[b.jsx("td",{children:v.character_name}),b.jsx("td",{className:"item-name",children:v.item_name}),b.jsx("td",{children:v.type||""}),b.jsx("td",{children:v.material||""}),b.jsx("td",{children:v.set_name||""}),b.jsx("td",{children:v.workmanship||""})]},g))})]})]})]})},eX=20,tX=.3;function nX(e,t){switch(t.type){case"SET":return{scale:t.scale,offX:t.offX,offY:t.offY};case"ZOOM":{const n=Math.min(eX,Math.max(tX,e.scale*t.factor)),r=n/e.scale;return{scale:n,offX:t.cx-(t.cx-e.offX)*r,offY:t.cy-(t.cy-e.offY)*r}}case"PAN":return{...e,offX:e.offX+t.dx,offY:e.offY+t.dy};default:return e}}const BR=B.createContext({transform:{scale:1,offX:0,offY:0},dispatch:()=>{}}),rX=({children:e})=>{const[t,n]=B.useReducer(nX,{scale:1,offX:0,offY:0});return b.jsx(BR.Provider,{value:{transform:t,dispatch:n},children:e})},aX=()=>B.useContext(BR),LR=B.createContext({windows:[],openWindow:()=>{},closeWindow:()=>{},bringToFront:()=>{}}),iX=({children:e})=>{const[t,n]=B.useState([]),r=B.useRef(1e4),l=B.useCallback((f,d,h)=>{n(y=>y.find(g=>g.id===f)?y.map(g=>g.id===f?{...g,zIndex:++r.current}:g):[...y,{id:f,title:d,charName:h,zIndex:++r.current}])},[]),u=B.useCallback(f=>{n(d=>d.filter(h=>h.id!==f))},[]),c=B.useCallback(f=>{n(d=>d.map(h=>h.id===f?{...h,zIndex:++r.current}:h))},[]);return b.jsx(LR.Provider,{value:{windows:t,openWindow:l,closeWindow:u,bringToFront:c},children:e})},vd=()=>B.useContext(LR),Nn={west:-102.1,east:102.1,north:102.1,south:-102.1};function yd(e,t,n,r){const l=(e-Nn.west)/(Nn.east-Nn.west)*n,u=(Nn.north-t)/(Nn.north-Nn.south)*r;return{x:l,y:u}}function lX(e,t,n,r,l,u,c){const f=(e-r)/n,d=(t-l)/n,h=Nn.west+f/u*(Nn.east-Nn.west),y=Nn.north-d/c*(Nn.north-Nn.south);return{ew:h,ns:y}}function lb(e,t){const n=e>=0?"N":"S",r=t>=0?"E":"W";return`${Math.abs(e).toFixed(1)}${n}, ${Math.abs(t).toFixed(1)}${r}`}const IR=I.memo(({players:e,imgW:t,imgH:n,getColor:r,onHover:l,onSelect:u})=>{const c=B.useMemo(()=>e.filter(f=>f.ew!==void 0&&f.ns!==void 0).map(f=>({...f,pos:yd(f.ew,f.ns,t,n),color:r(f.character_name)})),[e,t,n,r]);return b.jsx("div",{className:"ml-dots-layer",children:c.map(f=>b.jsx("div",{className:"ml-dot",style:{left:f.pos.x,top:f.pos.y,backgroundColor:f.color},onMouseEnter:d=>{var y;const h=(y=d.currentTarget.closest(".ml-map-container"))==null?void 0:y.getBoundingClientRect();h&&l(f,d.clientX-h.left,d.clientY-h.top)},onMouseLeave:()=>l(null,0,0),onClick:()=>u(f.character_name)},f.character_name))})});IR.displayName="PlayerDots";const UR=I.memo(({imgW:e,imgH:t,getColor:n})=>{const[r,l]=B.useState([]);B.useEffect(()=>{const c=async()=>{try{const d=await Ht("/trails/?seconds=600");l(d.trails??[])}catch{}};c();const f=setInterval(c,2e3);return()=>clearInterval(f)},[]);const u=B.useMemo(()=>{const c={};for(const f of r){const{x:d,y:h}=yd(f.ew,f.ns,e,t);c[f.character_name]||(c[f.character_name]=[]),c[f.character_name].push(`${d},${h}`)}return Object.entries(c).filter(([,f])=>f.length>=2).map(([f,d])=>({name:f,points:d.join(" ")}))},[r,e,t]);return b.jsx("svg",{className:"ml-trails-svg",viewBox:`0 0 ${e} ${t}`,preserveAspectRatio:"none",children:u.map(c=>b.jsx("polyline",{points:c.points,stroke:n(c.name),fill:"none",strokeWidth:2,strokeOpacity:.7,strokeLinecap:"round",strokeLinejoin:"round"},c.name))})});UR.displayName="TrailsSVG";const oX=({imgW:e,imgH:t,enabled:n})=>{const r=B.useRef(null),[l,u]=B.useState([]);return B.useEffect(()=>{if(!n)return;(async()=>{try{const f=await Ht("/spawns/heatmap?hours=24&limit=50000");u(f.spawn_points??[])}catch{}})()},[n]),B.useEffect(()=>{const c=r.current;if(!c||!n||l.length===0||e===0)return;c.width=e,c.height=t;const f=c.getContext("2d");if(f){f.clearRect(0,0,e,t);for(const d of l){const{x:h,y}=yd(d.ew,d.ns,e,t),v=Math.max(5,Math.min(12,5+Math.sqrt(d.intensity*.5))),g=f.createRadialGradient(h,y,0,h,y,v);g.addColorStop(0,`rgba(255, 0, 0, ${Math.min(.9,d.intensity/40)})`),g.addColorStop(.6,`rgba(255, 100, 0, ${Math.min(.4,d.intensity/120)})`),g.addColorStop(1,"rgba(255, 150, 0, 0)"),f.fillStyle=g,f.fillRect(h-v,y-v,v*2,v*2)}}},[l,e,t,n]),n?b.jsx("canvas",{ref:r,className:"ml-heatmap-canvas"}):null},uX=({imgW:e,imgH:t,enabled:n})=>{const[r,l]=B.useState([]);B.useEffect(()=>{if(!n)return;const c=async()=>{try{const d=await Ht("/portals");l(d.portals??[])}catch{}};c();const f=setInterval(c,6e4);return()=>clearInterval(f)},[n]);const u=B.useMemo(()=>r.map(c=>({...c,pos:yd(c.coordinates.ew,c.coordinates.ns,e,t)})),[r,e,t]);return!n||u.length===0?null:b.jsx("div",{className:"ml-portals-layer",children:u.map((c,f)=>b.jsx("div",{className:"ml-portal-icon",style:{left:c.pos.x,top:c.pos.y},title:`${c.portal_name} (by ${c.discovered_by})`},f))})},cX=({players:e,getColor:t,onSelectPlayer:n,showHeatmap:r,showPortals:l})=>{var M;const u=B.useRef(null),{transform:c,dispatch:f}=aX(),[d,h]=B.useState({w:0,h:0}),[y,v]=B.useState(null),[g,x]=B.useState(null),j=B.useRef({dragging:!1,sx:0,sy:0,startOffX:0,startOffY:0}),S=B.useCallback(N=>{const A=N.currentTarget;if(h({w:A.naturalWidth,h:A.naturalHeight}),u.current){const T=u.current.clientWidth,C=u.current.clientHeight,D=Math.min(T/A.naturalWidth,C/A.naturalHeight);f({type:"SET",scale:D,offX:(T-A.naturalWidth*D)/2,offY:(C-A.naturalHeight*D)/2})}},[f]),_=B.useCallback(N=>{var C;N.preventDefault();const A=(C=u.current)==null?void 0:C.getBoundingClientRect();if(!A)return;const T=N.deltaY<0?1.1:.9;f({type:"ZOOM",factor:T,cx:N.clientX-A.left,cy:N.clientY-A.top})},[f]),E=B.useCallback(N=>{N.button===0&&(j.current={dragging:!0,sx:N.clientX,sy:N.clientY,startOffX:c.offX,startOffY:c.offY})},[c.offX,c.offY]);B.useEffect(()=>{const N=T=>{const C=j.current;if(C.dragging&&f({type:"SET",scale:c.scale,offX:C.startOffX+(T.clientX-C.sx),offY:C.startOffY+(T.clientY-C.sy)}),u.current&&d.w>0){const D=u.current.getBoundingClientRect(),z=lX(T.clientX-D.left,T.clientY-D.top,c.scale,c.offX,c.offY,d.w,d.h);x(z)}},A=()=>{j.current.dragging=!1};return window.addEventListener("mousemove",N),window.addEventListener("mouseup",A),()=>{window.removeEventListener("mousemove",N),window.removeEventListener("mouseup",A)}},[f,c.scale,c.offX,c.offY,d.w,d.h]);const w=B.useCallback((N,A,T)=>{v(N?{x:A,y:T,player:N}:null)},[]);return b.jsxs("div",{className:"ml-map-container",ref:u,onWheel:_,onMouseDown:E,children:[b.jsxs("div",{className:"ml-map-group",style:{transform:`translate(${c.offX}px, ${c.offY}px) scale(${c.scale})`},children:[b.jsx("img",{src:"/dereth.png",alt:"Dereth",className:"ml-map-img",onLoad:S,draggable:!1}),d.w>0&&b.jsxs(b.Fragment,{children:[b.jsx(oX,{imgW:d.w,imgH:d.h,enabled:r}),b.jsx(UR,{imgW:d.w,imgH:d.h,getColor:t}),b.jsx(IR,{players:e,imgW:d.w,imgH:d.h,getColor:t,onHover:w,onSelect:n}),b.jsx(uX,{imgW:d.w,imgH:d.h,enabled:l})]})]}),y&&b.jsxs("div",{className:"ml-tooltip",style:{left:y.x+12,top:y.y-10},children:[b.jsx("strong",{children:y.player.character_name}),b.jsx("br",{}),lb(y.player.ns,y.player.ew),b.jsx("br",{}),y.player.kills_per_hour," kph ยท ",(M=y.player.kills)==null?void 0:M.toLocaleString()," kills"]}),g&&b.jsx("div",{className:"ml-coords",children:lb(g.ns,g.ew)})]})},HR=I.memo(({player:e,vitals:t,color:n,onSelect:r})=>{var h,y;const{openWindow:l}=vd(),u=(e.vt_state||"idle").toLowerCase(),c=u==="combat"||u==="hunt",f=(e.total_rares??0)>0?Math.round((e.total_kills??0)/(e.total_rares??1)).toLocaleString():null,d=e.character_name;return b.jsxs("li",{className:"ml-player-row",style:{borderLeftColor:n},children:[b.jsxs("div",{className:"ml-pr-header",onClick:r,children:[b.jsx("span",{className:"ml-pr-name",children:d}),b.jsx("span",{className:"ml-pr-coords",children:lb(e.ns,e.ew)})]}),b.jsxs("div",{className:"ml-pr-vitals",children:[b.jsx("div",{className:"ml-vital-bar hp",children:b.jsx("div",{className:"ml-vital-fill",style:{width:`${(t==null?void 0:t.health_percentage)??0}%`}})}),b.jsx("div",{className:"ml-vital-bar sta",children:b.jsx("div",{className:"ml-vital-fill",style:{width:`${(t==null?void 0:t.stamina_percentage)??0}%`}})}),b.jsx("div",{className:"ml-vital-bar mana",children:b.jsx("div",{className:"ml-vital-fill",style:{width:`${(t==null?void 0:t.mana_percentage)??0}%`}})})]}),b.jsxs("div",{className:"ml-pr-grid",children:[b.jsxs("span",{className:"ml-gs",title:"Session kills",children:["โš”๏ธ ",((h=e.kills)==null?void 0:h.toLocaleString())??0]}),b.jsxs("span",{className:"ml-gs",title:"Total kills",children:["๐Ÿ† ",(e.total_kills??0).toLocaleString()]}),b.jsxs("span",{className:"ml-gs",title:"Kills per hour",children:[e.kills_per_hour??"0"," ",b.jsx("span",{className:"ml-suffix",children:"KPH"})]}),b.jsxs("span",{className:"ml-gs",title:"Rares (session / total)",children:["๐Ÿ’Ž ",e.session_rares??0," / ",e.total_rares??0]}),b.jsx("span",{className:"ml-gs",title:"Kills per rare",children:f?b.jsxs(b.Fragment,{children:["๐Ÿ“Š ",f," ",b.jsx("span",{className:"ml-suffix",children:"KPR"})]}):""}),b.jsx("span",{className:`ml-meta-pill ${c?"active":""}`,children:e.vt_state||"idle"}),b.jsxs("span",{className:"ml-gs",title:"Online time",children:["๐Ÿ• ",((y=e.onlinetime)==null?void 0:y.replace(/^00\./,""))??"--"]}),b.jsxs("span",{className:"ml-gs",title:"Deaths",children:["โ˜ ๏ธ ",e.deaths??"0"]}),b.jsxs("span",{className:"ml-gs",title:"Prismatic tapers",children:[b.jsx("img",{src:"/prismatic-taper-icon.png",className:"ml-taper-icon",alt:""}),e.prismatic_taper_count??"0"]})]}),b.jsxs("div",{className:"ml-pr-buttons",children:[b.jsx("button",{className:"ml-btn accent",onClick:()=>l(`chat-${d}`,`Chat: ${d}`,d),children:"Chat"}),b.jsx("button",{className:"ml-btn accent",onClick:()=>l(`stats-${d}`,`Stats: ${d}`,d),children:"Stats"}),b.jsx("button",{className:"ml-btn accent",onClick:()=>l(`inv-${d}`,`Inventory: ${d}`,d),children:"Inv"}),b.jsx("button",{className:"ml-btn",onClick:()=>l(`char-${d}`,`Character: ${d}`,d),children:"Char"}),b.jsx("button",{className:"ml-btn",onClick:()=>l(`combat-${d}`,`Combat: ${d}`,d),children:"Combat"}),b.jsx("button",{className:"ml-btn",onClick:()=>l(`radar-${d}`,`Radar: ${d}`,d),children:"Radar"})]})]})});HR.displayName="PlayerRow";const sX=({players:e,vitals:t,getColor:n,onSelect:r})=>b.jsx("ul",{className:"ml-player-list",children:e.map(l=>b.jsx(HR,{player:l,vitals:t.get(l.character_name)??null,color:n(l.character_name),onSelect:()=>r(l.character_name)},l.character_name))}),fX=[{key:"name",label:"Name"},{key:"kph",label:"KPH"},{key:"skills",label:"S.Kills"},{key:"srares",label:"S.Rares"},{key:"tkills",label:"T.Kills"},{key:"kpr",label:"KPR"}],dX=({value:e,onChange:t})=>b.jsx("div",{className:"ml-sort-buttons",children:fX.map(n=>b.jsx("button",{className:`ml-sort-btn ${e===n.key?"active":""}`,onClick:()=>t(n.key),children:n.label},n.key))}),hX=()=>{const{openWindow:e}=vd();return b.jsxs("div",{className:"ml-tool-links",children:[b.jsx("span",{className:"ml-tool-link",style:{cursor:"pointer"},onClick:()=>e("issues","Issues Board"),children:"๐Ÿ“‹ Issues"}),b.jsx("span",{className:"ml-tool-link",style:{cursor:"pointer"},onClick:()=>e("vitalsharing","Vital Sharing"),children:"๐Ÿค Vitals"})]})},pX=({players:e,vitals:t,serverHealth:n,totalRares:r,totalKills:l,getColor:u,onSelectPlayer:c,onViewToggle:f,showHeatmap:d,showPortals:h,onToggleHeatmap:y,onTogglePortals:v})=>{var M,N;const[g,x]=B.useState("name"),[j,S]=B.useState(""),_=B.useMemo(()=>e.reduce((A,T)=>A+(parseInt(T.kills_per_hour)||0),0),[e]),E=((M=n==null?void 0:n.status)==null?void 0:M.toLowerCase())==="online"||((N=n==null?void 0:n.status)==null?void 0:N.toLowerCase())==="up",w=B.useMemo(()=>{let A=[...e];switch(j&&(A=A.filter(T=>T.character_name.toLowerCase().startsWith(j.toLowerCase()))),g){case"kph":A.sort((T,C)=>(parseInt(C.kills_per_hour)||0)-(parseInt(T.kills_per_hour)||0));break;case"skills":A.sort((T,C)=>(C.kills||0)-(T.kills||0));break;case"srares":A.sort((T,C)=>(C.session_rares??0)-(T.session_rares??0));break;case"tkills":A.sort((T,C)=>(C.total_kills??0)-(T.total_kills??0));break;case"kpr":A.sort((T,C)=>{const D=(T.total_kills??0)/Math.max(1,T.total_rares??1),z=(C.total_kills??0)/Math.max(1,C.total_rares??1);return D-z});break;default:A.sort((T,C)=>T.character_name.localeCompare(C.character_name))}return A},[e,g,j]);return b.jsxs("div",{className:"ml-sidebar",children:[b.jsxs("div",{className:"ml-sidebar-header",children:[b.jsxs("span",{className:"ml-sidebar-title",children:["Active Mosswart Enjoyers (",e.length,")"]}),b.jsx("button",{className:"ml-view-toggle",onClick:f,children:"Dashboard"})]}),b.jsxs("div",{className:"ml-server-status",children:[b.jsx("span",{className:`ml-status-dot ${E?"online":"offline"}`}),b.jsxs("span",{className:"ml-status-text",children:["Coldeve ",E?"Online":"Offline"]}),(n==null?void 0:n.player_count)!=null&&b.jsxs("span",{className:"ml-status-detail",children:["๐Ÿ‘ฅ ",n.player_count]}),(n==null?void 0:n.latency_ms)!=null&&b.jsxs("span",{className:"ml-status-detail",children:[Math.round(n.latency_ms),"ms"]}),(n==null?void 0:n.uptime_seconds)!=null&&b.jsxs("span",{className:"ml-status-detail",children:["Up: ",Math.floor(n.uptime_seconds/3600),"h"]})]}),b.jsxs("div",{className:"ml-counters",children:[b.jsxs("div",{className:"ml-counter rares",children:[b.jsx("span",{className:"ml-counter-val",children:r}),b.jsx("span",{className:"ml-counter-lbl",children:"Rares"})]}),b.jsxs("div",{className:`ml-counter kph ${_>5e3?"ultra":""}`,children:[b.jsx("span",{className:"ml-counter-val",children:_.toLocaleString()}),b.jsx("span",{className:"ml-counter-lbl",children:"Server KPH"})]}),b.jsxs("div",{className:"ml-counter kills",children:[b.jsx("span",{className:"ml-counter-val",children:l.toLocaleString()}),b.jsx("span",{className:"ml-counter-lbl",children:"Kills"})]})]}),b.jsxs("div",{className:"ml-tool-links",children:[b.jsx("a",{href:"/inventory.html",className:"ml-tool-link",children:"๐Ÿ” Inv Search"}),b.jsx("a",{href:"/suitbuilder.html",className:"ml-tool-link",children:"๐Ÿ›ก๏ธ Suitbuilder"}),b.jsx("a",{href:"/debug.html",className:"ml-tool-link",children:"๐Ÿ› Debug"}),b.jsx("a",{href:"/quest-status.html",target:"_blank",className:"ml-tool-link",children:"๐Ÿ“œ Quests"})]}),b.jsx(hX,{}),b.jsxs("div",{className:"ml-toggles",children:[b.jsxs("label",{className:"ml-toggle-label",children:[b.jsx("input",{type:"checkbox",checked:d,onChange:A=>y(A.target.checked)}),b.jsx("span",{children:"Spawn Heatmap"})]}),b.jsxs("label",{className:"ml-toggle-label",children:[b.jsx("input",{type:"checkbox",checked:h,onChange:A=>v(A.target.checked)}),b.jsx("span",{children:"Portals"})]})]}),b.jsx(dX,{value:g,onChange:x}),b.jsx("input",{className:"ml-filter",type:"text",placeholder:"Filter players...",value:j,onChange:A=>S(A.target.value)}),b.jsx(sX,{players:w,vitals:t,getColor:u,onSelect:c})]})},$r=({id:e,title:t,zIndex:n,width:r=700,height:l=340,children:u})=>{const{closeWindow:c,bringToFront:f}=vd(),d=B.useRef(null),h=B.useRef({dragging:!1,sx:0,sy:0,ox:0,oy:0}),y=B.useRef({x:420,y:10+Math.random()*40}),v=B.useCallback(g=>{var j;g.preventDefault(),f(e);const x=(j=d.current)==null?void 0:j.getBoundingClientRect();x&&(h.current={dragging:!0,sx:g.clientX,sy:g.clientY,ox:x.left,oy:x.top})},[e,f]);return B.useEffect(()=>{const g=j=>{const S=h.current;!S.dragging||!d.current||(y.current.x=S.ox+(j.clientX-S.sx),y.current.y=S.oy+(j.clientY-S.sy),d.current.style.left=`${y.current.x}px`,d.current.style.top=`${y.current.y}px`)},x=()=>{h.current.dragging=!1};return window.addEventListener("mousemove",g),window.addEventListener("mouseup",x),()=>{window.removeEventListener("mousemove",g),window.removeEventListener("mouseup",x)}},[]),b.jsxs("div",{ref:d,className:"ml-window",style:{zIndex:n,width:r,height:l,left:y.current.x,top:y.current.y},onMouseDown:()=>f(e),children:[b.jsxs("div",{className:"ml-window-header",onMouseDown:v,children:[b.jsx("span",{className:"ml-window-title",children:t}),b.jsx("button",{className:"ml-window-close",onClick:()=>c(e),children:"ร—"})]}),b.jsx("div",{className:"ml-window-content",children:u})]})},vX={0:"#00FF00",2:"#FFFFFF",3:"#FF0000",4:"#FFFFFF",5:"#33CCFF",6:"#CCFF99",7:"#00FFFF",14:"#FFD700",15:"#FF69B4",17:"#AAAAFF",18:"#88FF88",21:"#FF8888",22:"#FFAA66"},yX=({id:e,charName:t,zIndex:n,messages:r,socket:l})=>{const u=B.useRef(null),[c,f]=B.useState("");B.useEffect(()=>{u.current&&(u.current.scrollTop=u.current.scrollHeight)},[r.length]);const d=h=>{h.preventDefault();const y=c.trim();!y||!l||l.readyState!==WebSocket.OPEN||(l.send(JSON.stringify({player_name:t,command:y})),f(""))};return b.jsxs($r,{id:e,title:`Chat: ${t}`,zIndex:n,width:600,height:300,children:[b.jsx("div",{className:"ml-chat-messages",ref:u,children:r.map((h,y)=>b.jsx("div",{className:"ml-chat-line",style:{color:vX[h.color??2]??"#ddd"},children:h.text},y))}),b.jsx("form",{className:"ml-chat-form",onSubmit:d,children:b.jsx("input",{className:"ml-chat-input",value:c,onChange:h=>f(h.target.value),placeholder:"Enter chat..."})})]})},mX=[{title:"Kills per Hour",id:1},{title:"Memory (MB)",id:2},{title:"CPU (%)",id:3},{title:"Mem Handles",id:4}],gX=[{label:"1H",value:"now-1h"},{label:"6H",value:"now-6h"},{label:"24H",value:"now-24h"},{label:"7D",value:"now-7d"}],bX=({id:e,charName:t,zIndex:n})=>{const[r,l]=B.useState("now-24h"),u=c=>`/grafana/d-solo/dereth-tracker/dereth-tracker-dashboard?panelId=${c}&var-character=${encodeURIComponent(t)}&from=${r}&to=now&theme=light`;return b.jsxs($r,{id:e,title:`Stats: ${t}`,zIndex:n,width:750,height:480,children:[b.jsx("div",{className:"ml-stats-controls",children:gX.map(c=>b.jsx("button",{className:`ml-stats-range-btn ${r===c.value?"active":""}`,onClick:()=>l(c.value),children:c.label},c.value))}),b.jsx("div",{className:"ml-stats-grid",children:mX.map(c=>b.jsx("div",{className:"ml-stats-panel",children:b.jsx("iframe",{src:u(c.id),width:"100%",height:"100%",frameBorder:"0",title:c.title})},c.id))})]})},dM={369:"Blade Turner",370:"Arrow Turner",371:"Mace Turner",372:"Caustic Enhancement",373:"Fiery Enhancement",374:"Icy Enhancement",375:"Lightning Enhancement",376:"Critical Protection",377:"Frenzy",362:"Iron Skin",363:"Eye of the Remorseless",364:"Hand of the Remorseless",365:"Ciandra's Essence",366:"Yoshi's Essence",367:"Jibril's Essence",368:"Celdiseth's Essence"},hM={378:"Valor",379:"Protection",380:"Glory",381:"Temperance",382:"Aetheric Vision",383:"Mana Flow",384:"Mana Infusion",385:"Purity",386:"Craftsman",387:"Specialization",388:"World"},pM={354:"Damage Rating",355:"Damage Resist Rating",356:"Crit Rating",357:"Crit Resist Rating",358:"Crit Damage Rating",359:"Crit Damage Resist Rating",360:"Heal Boost Rating",361:"Vitality Rating"},Hn="#af7a30",js="#000022",xX=({id:e,charName:t,zIndex:n,vitals:r})=>{var U,V,L,G;const[l,u]=B.useState(null),[c,f]=B.useState(0),[d,h]=B.useState(0);B.useEffect(()=>{Ht(`/character-stats/${encodeURIComponent(t)}`).then(u).catch(()=>{})},[t]);const y=P=>P!=null?Number(P).toLocaleString():"โ€”",v=(l==null?void 0:l.stats_data)||l||{},g=v.attributes||{},x=v.skills||{},j=v.vitals||{},S=v.titles||[],_=v.properties||{},E=Object.entries(x).filter(([,P])=>(P==null?void 0:P.training)==="Specialized").sort(([P],[$])=>P.localeCompare($)),w=Object.entries(x).filter(([,P])=>(P==null?void 0:P.training)==="Trained").sort(([P],[$])=>P.localeCompare($)),M=Object.entries(_).filter(([P,$])=>dM[parseInt(P)]&&Number($)>0).map(([P,$])=>({name:dM[parseInt(P)],uses:Number($)})),N=Object.entries(_).filter(([P,$])=>hM[parseInt(P)]&&Number($)>0).map(([P,$])=>({name:hM[parseInt(P)],uses:Number($)})),A=Object.entries(_).filter(([P,$])=>pM[parseInt(P)]&&Number($)>0).map(([P,$])=>({name:pM[parseInt(P)],value:Number($)})),T=P=>({padding:"5px 8px",fontSize:12,fontWeight:"bold",color:"#fff",cursor:"pointer",userSelect:"none",borderTop:`2px solid ${P?Hn:js}`,borderLeft:`2px solid ${P?Hn:js}`,borderRight:`2px solid ${P?Hn:js}`,background:P?"rgba(0,100,0,0.4)":"transparent"}),C={background:"#000",border:`2px solid ${Hn}`,maxHeight:400,overflowY:"auto",overflowX:"hidden"},D={background:"#222",fontWeight:"bold",fontSize:12,padding:"2px 6px"},z={padding:"2px 6px",background:"rgba(0,100,0,0.4)",whiteSpace:"nowrap"},F={padding:"2px 6px",background:"rgba(0,0,100,0.4)",textAlign:"right",whiteSpace:"nowrap"},X={padding:"2px 6px",color:"#ccc"};return b.jsx($r,{id:e,title:`Character: ${t}`,zIndex:n,width:740,height:600,children:b.jsxs("div",{style:{background:js,color:"#fff",font:'14px/1.5 -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif',overflowY:"auto",padding:"10px 15px 15px",flex:1},children:[b.jsxs("div",{style:{marginBottom:10},children:[b.jsxs("h1",{style:{margin:"0 0 2px",fontSize:28,fontWeight:"bold"},children:[t,b.jsx("span",{style:{fontSize:"200%",color:"#fff27f",float:"right"},children:(l==null?void 0:l.level)||""})]}),b.jsx("div",{style:{fontSize:"85%",color:"gold"},children:[l==null?void 0:l.gender,l==null?void 0:l.race].filter(Boolean).join(" ")||"Awaiting character data..."})]}),b.jsxs("div",{style:{fontSize:"85%",margin:"6px 0 10px",display:"grid",gridTemplateColumns:"1fr 1fr",gap:"0 20px"},children:[b.jsxs("div",{children:["Total XP: ",y(l==null?void 0:l.total_xp)]}),b.jsxs("div",{style:{textAlign:"right"},children:["Unassigned XP: ",y(l==null?void 0:l.unassigned_xp)]}),b.jsxs("div",{children:["Luminance: ",(l==null?void 0:l.luminance_earned)!=null?`${y(l.luminance_earned)} / ${y(l.luminance_total)}`:"โ€”"]}),b.jsxs("div",{style:{textAlign:"right"},children:["Deaths: ",y(l==null?void 0:l.deaths)]})]}),b.jsxs("div",{style:{display:"flex",gap:13,flexWrap:"wrap"},children:[b.jsxs("div",{style:{width:320},children:[b.jsx("div",{style:{height:30,display:"flex"},children:["Attributes","Skills","Titles"].map((P,$)=>b.jsx("div",{style:T(c===$),onClick:()=>f($),children:P},P))}),b.jsxs("div",{style:C,children:[c===0&&b.jsxs(b.Fragment,{children:[b.jsx("div",{style:{padding:"6px 8px",display:"flex",flexDirection:"column",gap:8,borderBottom:`2px solid ${Hn}`},children:[{label:"Health",pct:(r==null?void 0:r.health_percentage)??0,cur:r==null?void 0:r.health_current,max:r==null?void 0:r.health_max,bg:"#cc3333"},{label:"Stamina",pct:(r==null?void 0:r.stamina_percentage)??0,cur:r==null?void 0:r.stamina_current,max:r==null?void 0:r.stamina_max,bg:"#ccaa33"},{label:"Mana",pct:(r==null?void 0:r.mana_percentage)??0,cur:r==null?void 0:r.mana_current,max:r==null?void 0:r.mana_max,bg:"#3366cc"}].map(P=>b.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[b.jsx("span",{style:{width:55,fontSize:12,color:"#ccc"},children:P.label}),b.jsx("div",{style:{flex:1,height:14,overflow:"hidden",position:"relative",border:`1px solid ${Hn}`},children:b.jsx("div",{style:{height:"100%",width:`${P.pct}%`,background:P.bg,transition:"width 0.5s ease"}})}),b.jsxs("span",{style:{width:80,textAlign:"right",fontSize:12,color:"#ccc"},children:[P.cur??"โ€”"," / ",P.max??"โ€”"]})]},P.label))}),b.jsxs("table",{style:{width:"100%",fontSize:13,borderCollapse:"collapse"},children:[b.jsx("thead",{children:b.jsxs("tr",{children:[b.jsx("td",{style:D,children:"Attribute"}),b.jsx("td",{style:D,children:"Creation"}),b.jsx("td",{style:D,children:"Base"})]})}),b.jsx("tbody",{children:["strength","endurance","coordination","quickness","focus","self"].map(P=>{var $,W;return b.jsxs("tr",{children:[b.jsx("td",{style:z,children:P.charAt(0).toUpperCase()+P.slice(1)}),b.jsx("td",{style:X,children:(($=g[P])==null?void 0:$.creation)??"โ€”"}),b.jsx("td",{style:F,children:((W=g[P])==null?void 0:W.base)??"โ€”"})]},P)})})]}),b.jsxs("table",{style:{width:"100%",fontSize:13,borderCollapse:"collapse"},children:[b.jsx("thead",{children:b.jsxs("tr",{children:[b.jsx("td",{style:D,children:"Vital"}),b.jsx("td",{style:D,children:"Base"})]})}),b.jsx("tbody",{children:["health","stamina","mana"].map(P=>{var $;return b.jsxs("tr",{children:[b.jsx("td",{style:z,children:P.charAt(0).toUpperCase()+P.slice(1)}),b.jsx("td",{style:F,children:(($=j[P])==null?void 0:$.base)??"โ€”"})]},P)})})]}),b.jsx("table",{style:{width:"100%",fontSize:13,borderCollapse:"collapse"},children:b.jsx("tbody",{children:b.jsxs("tr",{children:[b.jsx("td",{style:z,children:"Skill Credits"}),b.jsx("td",{style:F,children:y(v.skill_credits)})]})})})]}),c===1&&b.jsxs("table",{style:{width:"100%",fontSize:13,borderCollapse:"collapse"},children:[b.jsx("thead",{children:b.jsxs("tr",{children:[b.jsx("td",{style:D,children:"Skill"}),b.jsx("td",{style:D,children:"Level"})]})}),b.jsxs("tbody",{children:[E.map(([P,$])=>b.jsxs("tr",{children:[b.jsx("td",{style:{padding:"2px 6px",background:"linear-gradient(to right, #392067, #392067, black)"},children:P.replace(/_/g," ").replace(/\b\w/g,W=>W.toUpperCase())}),b.jsx("td",{style:{...F,background:"linear-gradient(to right, #392067, #392067, black)"},children:$.base})]},P)),w.map(([P,$])=>b.jsxs("tr",{children:[b.jsx("td",{style:{padding:"2px 6px",background:"linear-gradient(to right, #0f3c3e, #0f3c3e, black)"},children:P.replace(/_/g," ").replace(/\b\w/g,W=>W.toUpperCase())}),b.jsx("td",{style:{...F,background:"linear-gradient(to right, #0f3c3e, #0f3c3e, black)"},children:$.base})]},P)),E.length===0&&w.length===0&&b.jsx("tr",{children:b.jsx("td",{colSpan:2,style:{padding:10,color:"#666",fontStyle:"italic",textAlign:"center"},children:"No skill data"})})]})]}),c===2&&b.jsx("div",{style:{padding:"6px 10px",fontSize:13},children:S.length>0?S.map((P,$)=>b.jsx("div",{style:{padding:"1px 0"},children:P},$)):b.jsx("div",{style:{color:"#666",fontStyle:"italic",textAlign:"center",padding:10},children:"No titles"})})]})]}),b.jsxs("div",{style:{width:320},children:[b.jsx("div",{style:{height:30,display:"flex"},children:["Augmentations","Ratings","Other"].map((P,$)=>b.jsx("div",{style:T(d===$),onClick:()=>h($),children:P},P))}),b.jsxs("div",{style:C,children:[d===0&&(M.length||N.length?b.jsxs(b.Fragment,{children:[M.length>0&&b.jsxs(b.Fragment,{children:[b.jsx("div",{style:{background:"#222",padding:"4px 8px",fontWeight:"bold",fontSize:13,borderBottom:`1px solid ${Hn}`},children:"Augmentations"}),b.jsxs("table",{style:{width:"100%",fontSize:13,borderCollapse:"collapse"},children:[b.jsx("thead",{children:b.jsxs("tr",{children:[b.jsx("td",{style:D,children:"Name"}),b.jsx("td",{style:D,children:"Uses"})]})}),b.jsx("tbody",{children:M.map(P=>b.jsxs("tr",{children:[b.jsx("td",{style:{padding:"2px 6px"},children:P.name}),b.jsx("td",{style:{padding:"2px 6px",textAlign:"right"},children:P.uses})]},P.name))})]})]}),N.length>0&&b.jsxs(b.Fragment,{children:[b.jsx("div",{style:{background:"#222",padding:"4px 8px",fontWeight:"bold",fontSize:13,borderBottom:`1px solid ${Hn}`},children:"Auras"}),b.jsxs("table",{style:{width:"100%",fontSize:13,borderCollapse:"collapse"},children:[b.jsx("thead",{children:b.jsxs("tr",{children:[b.jsx("td",{style:D,children:"Name"}),b.jsx("td",{style:D,children:"Uses"})]})}),b.jsx("tbody",{children:N.map(P=>b.jsxs("tr",{children:[b.jsx("td",{style:{padding:"2px 6px"},children:P.name}),b.jsx("td",{style:{padding:"2px 6px",textAlign:"right"},children:P.uses})]},P.name))})]})]})]}):b.jsx("div",{style:{color:"#666",fontStyle:"italic",textAlign:"center",padding:10},children:"No augmentation data"})),d===1&&(A.length>0?b.jsxs("table",{style:{width:"100%",fontSize:13,borderCollapse:"collapse"},children:[b.jsx("thead",{children:b.jsxs("tr",{children:[b.jsx("td",{style:D,children:"Rating"}),b.jsx("td",{style:D,children:"Value"})]})}),b.jsx("tbody",{children:A.map(P=>b.jsxs("tr",{children:[b.jsx("td",{style:{padding:"2px 6px"},children:P.name}),b.jsx("td",{style:{padding:"2px 6px",textAlign:"right"},children:P.value})]},P.name))})]}):b.jsx("div",{style:{color:"#666",fontStyle:"italic",textAlign:"center",padding:10},children:"No rating data"})),d===2&&b.jsx("div",{style:{padding:6},children:l!=null&&l.allegiance?b.jsxs(b.Fragment,{children:[b.jsx("div",{style:{background:"#222",padding:"4px 8px",fontWeight:"bold",fontSize:13,borderBottom:`1px solid ${Hn}`},children:"Allegiance"}),b.jsx("table",{style:{width:"100%",fontSize:13,borderCollapse:"collapse"},children:b.jsxs("tbody",{children:[l.allegiance.name&&b.jsxs("tr",{children:[b.jsx("td",{style:{padding:"2px 6px",color:"#ccc",width:100},children:"Name"}),b.jsx("td",{style:{padding:"2px 6px"},children:l.allegiance.name})]}),((U=l.allegiance.monarch)==null?void 0:U.name)&&b.jsxs("tr",{children:[b.jsx("td",{style:{padding:"2px 6px",color:"#ccc"},children:"Monarch"}),b.jsx("td",{style:{padding:"2px 6px"},children:l.allegiance.monarch.name})]}),((V=l.allegiance.patron)==null?void 0:V.name)&&b.jsxs("tr",{children:[b.jsx("td",{style:{padding:"2px 6px",color:"#ccc"},children:"Patron"}),b.jsx("td",{style:{padding:"2px 6px"},children:l.allegiance.patron.name})]}),l.allegiance.rank!=null&&b.jsxs("tr",{children:[b.jsx("td",{style:{padding:"2px 6px",color:"#ccc"},children:"Rank"}),b.jsx("td",{style:{padding:"2px 6px"},children:l.allegiance.rank})]})]})})]}):b.jsx("div",{style:{color:"#666",fontStyle:"italic",textAlign:"center",padding:10},children:"No additional data"})})]})]})]}),(l==null?void 0:l.allegiance)&&b.jsxs("div",{style:{marginTop:5,border:`2px solid ${Hn}`,background:"#000"},children:[b.jsx("div",{style:{background:"#222",padding:"4px 8px",fontWeight:"bold",fontSize:13,borderBottom:`1px solid ${Hn}`},children:"Allegiance"}),b.jsx("table",{style:{width:"100%",fontSize:13,borderCollapse:"collapse"},children:b.jsxs("tbody",{children:[l.allegiance.name&&b.jsxs("tr",{children:[b.jsx("td",{style:{padding:"2px 6px",color:"#ccc",width:100},children:"Name"}),b.jsx("td",{style:{padding:"2px 6px"},children:l.allegiance.name})]}),((L=l.allegiance.monarch)==null?void 0:L.name)&&b.jsxs("tr",{children:[b.jsx("td",{style:{padding:"2px 6px",color:"#ccc"},children:"Monarch"}),b.jsx("td",{style:{padding:"2px 6px"},children:l.allegiance.monarch.name})]}),((G=l.allegiance.patron)==null?void 0:G.name)&&b.jsxs("tr",{children:[b.jsx("td",{style:{padding:"2px 6px",color:"#ccc"},children:"Patron"}),b.jsx("td",{style:{padding:"2px 6px"},children:l.allegiance.patron.name})]}),l.allegiance.rank!=null&&b.jsxs("tr",{children:[b.jsx("td",{style:{padding:"2px 6px",color:"#ccc"},children:"Rank"}),b.jsx("td",{style:{padding:"2px 6px"},children:l.allegiance.rank})]}),l.allegiance.followers!=null&&b.jsxs("tr",{children:[b.jsx("td",{style:{padding:"2px 6px",color:"#ccc"},children:"Followers"}),b.jsx("td",{style:{padding:"2px 6px"},children:l.allegiance.followers})]})]})})]})]})})};function _X(e){var r;if(!e)return e;const t=l=>l!=null&&l!==-1&&l!==-1?l:void 0,n=e.IntValues||{};return{item_id:e.item_id??e.Id??0,name:e.name??e.Name??((r=e.StringValues)==null?void 0:r["1"])??"Unknown",icon:e.icon??e.Icon??0,object_class:e.object_class??e.ObjectClass??0,current_wielded_location:e.current_wielded_location??t(e.CurrentWieldedLocation)??t(Number(n[10]))??0,container_id:e.container_id??e.ContainerId??0,items_capacity:e.items_capacity??t(e.ItemsCapacity)??t(Number(n[6]))??void 0,value:e.value??t(e.Value)??t(Number(n[19]))??0,burden:e.burden??t(e.Burden)??t(Number(n[5]))??0,armor_level:e.armor_level??t(e.ArmorLevel),max_damage:e.max_damage??t(e.MaxDamage),material:e.material??e.material_name??e.Material??void 0,item_set:e.item_set??e.ItemSet??void 0,imbue:e.imbue??e.Imbue??void 0,tinks:e.tinks??t(e.Tinks),workmanship:e.workmanship??t(e.Workmanship),equip_skill:e.equip_skill??e.equip_skill_name??e.EquipSkill??void 0,wield_level:e.wield_level??t(e.WieldLevel),skill_level:e.skill_level??t(e.SkillLevel),lore_requirement:e.lore_requirement??t(e.LoreRequirement),attack_bonus:e.attack_bonus??t(e.AttackBonus),melee_defense_bonus:e.melee_defense_bonus??t(e.MeleeDefenseBonus),magic_defense_bonus:e.magic_defense_bonus??t(e.MagicDBonus),damage_bonus:e.damage_bonus??t(e.DamageBonus),damage_rating:e.damage_rating??t(e.DamRating),crit_rating:e.crit_rating??t(e.CritRating),heal_boost_rating:e.heal_boost_rating??t(e.HealBoostRating),current_mana:e.current_mana??t(Number(n[218103815]))??void 0,max_mana:e.max_mana??t(Number(n[218103814]))??void 0,spellcraft:e.spellcraft??void 0,damage_range:e.damage_range??void 0,damage_type:e.damage_type??void 0,speed_text:e.speed_text??void 0,mana_display:e.mana_display??void 0,spells:e.spells??void 0,icon_overlay_id:e.icon_overlay_id??t(Number(n[218103849]))??void 0,icon_underlay_id:e.icon_underlay_id??t(Number(n[218103850]))??void 0,_raw:e}}function Cs(e){return!e||e<=0?"06000133":(e+100663296).toString(16).toUpperCase().padStart(8,"0")}const Ji={32768:{name:"Neck",row:1,col:1},1:{name:"Head",row:1,col:3},268435456:{name:"Sigil",row:1,col:5},536870912:{name:"Sigil",row:1,col:6},1073741824:{name:"Sigil",row:1,col:7},67108864:{name:"Trinket",row:2,col:1},2048:{name:"U.Arm",row:2,col:2},512:{name:"Chest",row:2,col:3},134217728:{name:"Cloak",row:2,col:7},65536:{name:"Brace L",row:3,col:1},4096:{name:"L.Arm",row:3,col:2},1024:{name:"Abdomen",row:3,col:3},8192:{name:"U.Leg",row:3,col:4},131072:{name:"Brace R",row:3,col:5},2:{name:"Shirt",row:3,col:7},262144:{name:"Ring L",row:4,col:1},32:{name:"Hands",row:4,col:2},16384:{name:"L.Leg",row:4,col:4},524288:{name:"Ring R",row:4,col:5},4:{name:"Pants",row:4,col:7},256:{name:"Feet",row:5,col:4},2097152:{name:"Shield",row:6,col:1},1048576:{name:"Melee",row:6,col:3},4194304:{name:"Missile",row:6,col:3},16777216:{name:"Held",row:6,col:3},33554432:{name:"2H",row:6,col:3},8388608:{name:"Ammo",row:6,col:7}},el={},SX=[32768,67108864,65536,131072,262144,524288],OX=[1,512,2048,1024,4096,8192,16384,32,256],AX=[2,4,134217728,268435456,536870912,1073741824],wX=[2097152,1048576,4194304,16777216,33554432,8388608];(()=>{const e=new Set;Object.entries(Ji).forEach(([t,n])=>{const r=`${n.row}-${n.col}`,l=parseInt(t);e.has(r)||(e.add(r),SX.includes(l)?el[r]="#3a2555":OX.includes(l)?el[r]="#1e2e55":AX.includes(l)?el[r]="#1e3e3e":wX.includes(l)?el[r]="#142040":el[r]="#2a2a2a")})})();const tl="#af7a30";function zg({item:e,size:t=36}){const n={position:"absolute",top:0,left:0,width:t,height:t,border:"none",background:"transparent",imageRendering:"pixelated"},r=e.icon_underlay_id&&e.icon_underlay_id>100?`/icons/${Cs(e.icon_underlay_id)}.png`:null,l=e.icon_overlay_id&&e.icon_overlay_id>100?`/icons/${Cs(e.icon_overlay_id)}.png`:null;return b.jsxs("div",{style:{width:t,height:t,position:"relative"},children:[r&&b.jsx("img",{src:r,alt:"",style:{...n,zIndex:1},onError:u=>{u.target.style.display="none"}}),b.jsx("img",{src:`/icons/${Cs(e.icon)}.png`,alt:e.name,style:{...n,zIndex:2},onError:u=>{u.target.src="/icons/06000133.png"}}),l&&b.jsx("img",{src:l,alt:"",style:{...n,zIndex:3},onError:u=>{u.target.style.display="none"}})]})}function jX({item:e,x:t,y:n}){var c,f;const r=d=>d!=null&&d!==-1&&d!==-1,l=d=>d.toLocaleString(),u=d=>`${((d-1)*100).toFixed(1)}%`;return b.jsxs("div",{style:{position:"fixed",left:t+14,top:n+14,background:"rgba(0,0,0,0.96)",border:"1px solid #555",borderRadius:4,padding:"8px 12px",zIndex:99999,minWidth:200,maxWidth:340,fontSize:13,color:"#ddd",pointerEvents:"none",lineHeight:1.6,fontFamily:'-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif'},children:[b.jsx("div",{style:{color:"#ffcc00",fontWeight:"bold",fontSize:14,marginBottom:4},children:e.name}),b.jsxs("div",{style:{color:"#aaa"},children:["Value: ",l(e.value)," ยท Burden: ",e.burden]}),e.workmanship&&b.jsxs("div",{style:{color:"#aaa"},children:["Workmanship: ",e.workmanship]}),e.material&&b.jsxs("div",{style:{color:"#88ff88"},children:["Material: ",e.material]}),r(e.armor_level)&&b.jsxs("div",{style:{color:"#88ff88"},children:["Armor Level: ",e.armor_level]}),r(e.max_damage)&&b.jsxs("div",{style:{color:"#88ff88"},children:["Max Damage: ",e.max_damage]}),e.damage_range&&b.jsxs("div",{style:{color:"#88ff88"},children:["Damage: ",e.damage_range,e.damage_type?`, ${e.damage_type}`:""]}),r(e.attack_bonus)&&e.attack_bonus!==1&&b.jsxs("div",{style:{color:"#88ff88"},children:["Attack: +",u(e.attack_bonus)]}),r(e.melee_defense_bonus)&&e.melee_defense_bonus!==1&&b.jsxs("div",{style:{color:"#88ff88"},children:["Melee Def: +",u(e.melee_defense_bonus)]}),r(e.magic_defense_bonus)&&e.magic_defense_bonus!==1&&b.jsxs("div",{style:{color:"#88ff88"},children:["Magic Def: +",u(e.magic_defense_bonus)]}),e.equip_skill&&b.jsxs("div",{style:{color:"#ddd"},children:["Skill: ",e.equip_skill]}),r(e.wield_level)&&b.jsxs("div",{style:{color:"#ffaa00"},children:["Wield Level: ",e.wield_level]}),r(e.lore_requirement)&&b.jsxs("div",{style:{color:"#ffaa00"},children:["Lore: ",e.lore_requirement]}),e.imbue&&b.jsxs("div",{style:{color:"#88ff88"},children:["Imbue: ",e.imbue]}),e.item_set&&b.jsxs("div",{style:{color:"#88ff88"},children:["Set: ",e.item_set]}),r(e.tinks)&&b.jsxs("div",{style:{color:"#88ff88"},children:["Tinks: ",e.tinks]}),r(e.damage_rating)&&b.jsxs("div",{children:["Damage Rating: ",e.damage_rating]}),r(e.crit_rating)&&b.jsxs("div",{children:["Crit Rating: ",e.crit_rating]}),r(e.heal_boost_rating)&&b.jsxs("div",{children:["Heal Boost: ",e.heal_boost_rating]}),e.spellcraft&&b.jsxs("div",{style:{color:"#dda0dd"},children:["Spellcraft: ",e.spellcraft]}),r(e.current_mana)&&r(e.max_mana)&&b.jsxs("div",{style:{color:"#98d7ff"},children:["Mana: ",e.current_mana," / ",e.max_mana]}),((f=(c=e.spells)==null?void 0:c.spells)==null?void 0:f.length)>0&&b.jsxs("div",{style:{color:"#4a90e2",marginTop:4,fontSize:12},children:["Spells: ",e.spells.spells.map(d=>d.name).join(", ")]})]})}function vM({iconSrc:e,isActive:t,fillPct:n,label:r,onClick:l}){const u=n>90?"#b7432c":n>70?"#d8a431":"#00ff00";return b.jsxs("div",{onClick:l,title:r,style:{display:"flex",alignItems:"flex-start",gap:2,cursor:"pointer",flexShrink:0,marginTop:3,position:"relative"},children:[t&&b.jsx("span",{style:{position:"absolute",left:-11,top:8,color:tl,fontSize:10},children:"โ–ถ"}),b.jsx("div",{style:{width:30,height:30,border:t?"1px solid #00ff00":"1px solid #333",boxShadow:t?"0 0 4px #00ff00":"none",background:"#000",display:"flex",alignItems:"center",justifyContent:"center"},children:b.jsx("img",{src:e,alt:"",style:{width:26,height:26,objectFit:"contain",imageRendering:"pixelated"},onError:c=>{c.target.src="/icons/06001080.png"}})}),b.jsx("div",{style:{width:7,height:30,background:"#222",border:"1px solid #666",position:"relative",overflow:"hidden",borderRadius:2},title:`${Math.round(n)}% full`,children:b.jsx("div",{style:{position:"absolute",bottom:0,left:0,right:0,height:`${n}%`,background:u,minHeight:n>0?2:0}})})]})}const TX=({id:e,charName:t,zIndex:n})=>{var X,U,V;const[r,l]=B.useState([]),[u,c]=B.useState(!0),[f,d]=B.useState(null),[h,y]=B.useState(null),[v,g]=B.useState(null),[x,j]=B.useState(null);B.useEffect(()=>{console.log("[INV] Loading inventory for",t),c(!0),Promise.all([Ht(`/inventory/${encodeURIComponent(t)}?limit=1000`).catch(L=>(console.error("[INV] fetch error:",L),{items:[]})),Ht(`/character-stats/${encodeURIComponent(t)}`).catch(()=>null)]).then(([L,G])=>{const P=L.items??[];console.log("[INV] Got",P.length,"raw items, first:",P[0]);const $=P.map(_X);console.log("[INV] Normalized",$.length,"items, sample container_ids:",$.slice(0,5).map(W=>W.container_id)),l($),g(G)}).finally(()=>c(!1))},[t]);const S=B.useCallback((L,G)=>{y(L&&G?{item:L,x:G.clientX,y:G.clientY}:null)},[]),_=B.useMemo(()=>{const L=new Set,G=[];return Object.entries(Ji).forEach(([P,$])=>{const W=`${$.row}-${$.col}`;L.has(W)||(L.add(W),G.push({key:W,...$,mask:parseInt(P)}))}),G},[]),{equippedMap:E,containers:w,packItems:M}=B.useMemo(()=>{const L=new Map,G=[],P=new Set,$=new Map;r.forEach(ee=>{ee.object_class===10&&(G.push(ee),P.add(ee.item_id))}),G.sort((ee,le)=>(ee.item_id>>>0)-(le.item_id>>>0));let W=null;return r.forEach(ee=>{ee.current_wielded_location>0&&ee.container_id&&!P.has(ee.container_id)&&(W=ee.container_id)}),r.forEach(ee=>{if(P.has(ee.item_id))return;const le=ee.current_wielded_location;if(le>0)if(ee.object_class===2)Object.entries(Ji).forEach(([Y,ne])=>{if((le&parseInt(Y))===parseInt(Y)){const ue=`${ne.row}-${ne.col}`;L.has(ue)||L.set(ue,ee)}});else{let Y=!1;if(Ji[le]){const ne=Ji[le],ue=`${ne.row}-${ne.col}`;L.has(ue)||(L.set(ue,ee),Y=!0)}if(!Y){for(const[ne,ue]of Object.entries(Ji))if((le&parseInt(ne))===parseInt(ne)){const de=`${ue.row}-${ue.col}`;if(!L.has(de)){L.set(de,ee),Y=!0;break}}}}else{let k=ee.container_id||0;W&&k===W&&(k=0),$.has(k)||$.set(k,[]),$.get(k).push(ee)}}),console.log("[INV DEBUG] containers:",G.map(ee=>({id:ee.item_id,name:ee.name}))),console.log("[INV DEBUG] packItems keys:",[...$.keys()]),console.log("[INV DEBUG] packItems sizes:",[...$.entries()].map(([ee,le])=>`${ee}: ${le.length}`)),{equippedMap:L,containers:G,packItems:$}},[r]);let N=M.get(0)??[],A=0;if(N.length===0){let L=0;for(const[G,P]of M.entries())!w.some($=>$.item_id===G)&&P.length>L&&(L=P.length,A=G);N=M.get(A)??[]}const T=f!==null?M.get(f)??[]:N,C=(v==null?void 0:v.burden_units)??((X=v==null?void 0:v.stats_data)==null?void 0:X.burden_units)??0,D=(v==null?void 0:v.encumbrance_capacity)??((U=v==null?void 0:v.stats_data)==null?void 0:U.encumbrance_capacity)??0,z=D>0?Math.min(200,C/D*100):0,F=z>150?"#b7432c":z>100?"#d8a431":"#2e8b57";return u?b.jsx($r,{id:e,title:`Inventory: ${t}`,zIndex:n,width:572,height:720,children:b.jsx("div",{style:{padding:20,color:"#666",fontStyle:"italic"},children:"Loading inventory..."})}):b.jsxs($r,{id:e,title:`Inventory: ${t}`,zIndex:n,width:572,height:720,children:[b.jsxs("div",{style:{display:"flex",flex:1,overflow:"hidden",background:"rgba(14,14,14,0.96)",fontFamily:'-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif',fontSize:13},children:[b.jsxs("div",{style:{width:316,display:"flex",flexDirection:"column",overflow:"hidden"},children:[b.jsx("div",{style:{position:"relative",height:270,minHeight:270,background:"#0a0a0a",borderBottom:`1px solid ${tl}`},children:_.map(L=>{const G=E.get(L.key),P=el[L.key]??"#2a2a2a";return b.jsx("div",{style:{position:"absolute",left:(L.col-1)*44+4,top:(L.row-1)*44+4,width:36,height:36,background:G?"#5a5a62":P,border:G?"2px solid #00ffff":"2px outset #6a6a72",boxShadow:G?"0 0 5px #00ffff, inset 0 0 5px rgba(0,255,255,0.2)":"none",display:"flex",alignItems:"center",justifyContent:"center",cursor:G?"pointer":"default"},onMouseEnter:$=>G&&S(G,$),onMouseMove:$=>G&&S(G,$),onMouseLeave:()=>S(null),children:G?b.jsx(zg,{item:G,size:32}):b.jsx("img",{src:"/icons/06000133.png",alt:"",style:{width:28,height:28,opacity:.15,filter:"grayscale(100%)",imageRendering:"pixelated"}})},L.key)})}),b.jsxs("div",{style:{padding:"3px 6px",fontSize:11,color:"#ccc",background:"#111",borderBottom:`1px solid ${tl}`},children:["Contents of ",f!==null?((V=w.find(L=>L.item_id===f))==null?void 0:V.name)??"Pack":"Backpack"]}),b.jsxs("div",{style:{flex:1,overflowY:"auto",display:"grid",gridTemplateColumns:"repeat(6, 36px)",gridAutoRows:36,gap:2,padding:4,alignContent:"start"},children:[T.map((L,G)=>b.jsx("div",{style:{width:36,height:36,background:"linear-gradient(135deg, #3d007a 0%, #1a0033 100%)",border:"1px solid #4a148c",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer"},onMouseEnter:P=>S(L,P),onMouseMove:P=>S(L,P),onMouseLeave:()=>S(null),children:b.jsx(zg,{item:L,size:32})},L.item_id??G)),Array.from({length:Math.max(0,24-T.length)}).map((L,G)=>b.jsx("div",{style:{width:36,height:36,background:"#0a0a0a",border:"1px solid #1a1a1a"}},`e${G}`))]})]}),b.jsxs("div",{style:{width:42,display:"flex",flexDirection:"column",alignItems:"center",padding:"4px 2px",borderLeft:`1px solid ${tl}`,borderRight:`1px solid ${tl}`},children:[b.jsx("div",{style:{textAlign:"center",fontSize:8,color:"#ccc",marginBottom:2},children:D>0?`${Math.floor(z)}%`:"Burden"}),b.jsx("div",{style:{width:14,height:40,background:"#111",border:"1px solid #555",position:"relative",overflow:"hidden",marginBottom:6,flexShrink:0},title:D>0?`${C.toLocaleString()} / ${D.toLocaleString()}`:`Burden: ${r.reduce((L,G)=>L+(G.burden??0),0).toLocaleString()}`,children:b.jsx("div",{style:{position:"absolute",bottom:0,left:0,right:0,height:`${z/2}%`,background:F,transition:"height 0.3s"}})}),b.jsx(vM,{iconSrc:"/icons/0600127E.png",isActive:f===null,fillPct:N.length>0?Math.min(100,N.length/102*100):0,label:`Backpack (${N.length}/102)`,onClick:()=>d(null)}),w.map(L=>{const G=L.item_id,P=M.get(G)??[],$=L.items_capacity??24;return b.jsx(vM,{iconSrc:`/icons/${Cs(L.icon)}.png`,isActive:f===G,fillPct:Math.min(100,P.length/$*100),label:`${L.name} (${P.length}/${$})`,onClick:()=>d(G)},G)})]}),b.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden",minWidth:160},children:[b.jsx("div",{style:{padding:"4px 8px",fontSize:"0.72rem",fontWeight:600,color:"#aaa",background:"#111",borderBottom:`1px solid ${tl}`},children:"Mana"}),b.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"2px 0"},children:[Array.from(E.values()).filter(L=>L.current_mana>0||L.max_mana>0).sort((L,G)=>(L.current_mana??999999)-(G.current_mana??999999)).map((L,G)=>b.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4,padding:"2px 4px",borderBottom:"1px solid #1a1a1a",cursor:"pointer"},onMouseEnter:P=>S(L,P),onMouseMove:P=>S(L,P),onMouseLeave:()=>S(null),children:[b.jsx("div",{style:{width:20,height:20,flexShrink:0},children:b.jsx(zg,{item:L,size:20})}),b.jsx("div",{style:{width:8,height:8,borderRadius:"50%",background:L.current_mana>0?"#4c4":"#c44",flexShrink:0}}),b.jsx("div",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:"0.68rem",color:"#ccc"},children:L.name}),b.jsxs("div",{style:{fontSize:"0.65rem",color:"#88bbff",whiteSpace:"nowrap",fontVariantNumeric:"tabular-nums"},children:[L.current_mana??0,"/",L.max_mana??0]}),b.jsx("div",{style:{fontSize:"0.63rem",color:"#9c9",whiteSpace:"nowrap",fontVariantNumeric:"tabular-nums",minWidth:42,textAlign:"right"},children:L.max_mana>0?EX(L.current_mana??0,L.max_mana??0):""})]},G)),Array.from(E.values()).filter(L=>L.current_mana>0||L.max_mana>0).length===0&&b.jsx("div",{style:{padding:12,color:"#555",textAlign:"center",fontSize:"0.7rem"},children:"No mana items equipped"})]})]})]}),h&&b.jsx(jX,{item:h.item,x:h.x,y:h.y})]})};function EX(e,t){if(t<=0||e<=0)return"0h00m";const n=e*20,r=Math.floor(n/3600),l=Math.floor(n%3600/60);return`~${r}h${String(l).padStart(2,"0")}m`}const qg=300,yM=.5,mM={Monster:"#ff4444",Player:"#4488ff",NPC:"#44cc44",Vendor:"#44cc44",Portal:"#aa44ff",Corpse:"#ff8800",Container:"#cccc44",Door:"#888888"};function MX(e){const t=(e%360+360)%360;return["N","NE","E","SE","S","SW","W","NW"][Math.round(t/45)%8]}const CX=({id:e,charName:t,zIndex:n,socket:r,radarData:l})=>{const u=B.useRef(null),c=B.useRef(yM),[f,d]=B.useState(yM),[h,y]=B.useState(null),v=B.useRef(null),g=B.useRef([]);B.useEffect(()=>{const E=new Image;E.src="/dereth.png",E.onload=()=>{v.current=E}},[]),B.useEffect(()=>((r==null?void 0:r.readyState)===WebSocket.OPEN&&r.send(JSON.stringify({player_name:t,command:"start_radar"})),()=>{(r==null?void 0:r.readyState)===WebSocket.OPEN&&r.send(JSON.stringify({player_name:t,command:"stop_radar"}))}),[t,r]);const x=B.useCallback(E=>{E.preventDefault();const w=E.deltaY>0?1.25:.8;c.current=Math.max(.02,Math.min(5,c.current*w)),d(c.current)},[]),j=B.useCallback(E=>{const w=u.current;if(!w)return;const M=w.getBoundingClientRect(),N=(E.clientX-M.left)*(w.width/M.width),A=(E.clientY-M.top)*(w.height/M.height);let T=null,C=20;g.current.forEach(D=>{if(D._px===void 0)return;const z=Math.sqrt((N-D._px)**2+(A-D._py)**2);z{const E=u.current;if(!E||!l)return;const w=E.getContext("2d");if(!w)return;const M=qg,N=M/2,A=M/2,T=l.objects??[],C=l.player_ew??0,D=l.player_ns??0,z=l.player_heading??0,F=l.is_dungeon??!1,X=l.player_x??0,U=l.player_y??0,V=c.current,L=F?M/2/(V*240):M/2/V,G=z*Math.PI/180;if(w.clearRect(0,0,M,M),w.fillStyle="#111",w.beginPath(),w.arc(N,A,N,0,Math.PI*2),w.fill(),w.save(),w.beginPath(),w.arc(N,A,N-1,0,Math.PI*2),w.clip(),!F&&v.current){const ee=v.current,le=ee.naturalWidth/204.2,k=(C+102.1)*le,Y=(102.1-D)*le;w.globalAlpha=.4,w.save(),w.translate(N,A),w.rotate(-G),w.drawImage(ee,k-N/L*le,Y-A/L*le,M/L*le,M/L*le,-N,-A,M,M),w.restore(),w.globalAlpha=1}w.restore(),w.strokeStyle="#333",w.lineWidth=1;for(let ee=1;ee<=4;ee++)w.beginPath(),w.arc(N,A,N/4*ee,0,Math.PI*2),w.stroke();w.beginPath(),w.moveTo(N,0),w.lineTo(N,M),w.moveTo(0,A),w.lineTo(M,A),w.stroke(),w.font="bold 12px monospace",w.textAlign="center",w.textBaseline="middle",[{l:"N",a:0},{l:"E",a:Math.PI/2},{l:"S",a:Math.PI},{l:"W",a:-Math.PI/2}].forEach(({l:ee,a:le})=>{const k=le-G;w.fillStyle=ee==="N"?"#cc4444":"#888",w.fillText(ee,N+Math.sin(k)*(N-12),A-Math.cos(k)*(N-12))}),w.strokeStyle="#666",w.lineWidth=1,w.beginPath(),w.moveTo(N,A),w.lineTo(N,A-N*.85),w.stroke();const P=F?Math.PI-G:G,$=Math.cos(P),W=Math.sin(P);T.forEach(ee=>{let le,k;F&&ee.raw_x!==void 0?(le=-(ee.raw_x-X),k=ee.raw_y-U):(le=(ee.ew??0)-C,k=(ee.ns??0)-D);const Y=le*$-k*W,ne=F?le*W+k*$:-(le*W+k*$),ue=N+Y*L,de=A+ne*L;if(Math.sqrt((ue-N)**2+(de-A)**2)>N-4)return;ee._px=ue,ee._py=de;const Oe=ee.object_class??ee.type??"",$e=mM[Oe]??"#888",se=ee.id===h,be=se?6:Oe==="Monster"||Oe==="Player"?4:3;se&&(w.strokeStyle="#fff",w.lineWidth=2,w.beginPath(),w.arc(ue,de,be+3,0,Math.PI*2),w.stroke()),w.fillStyle=$e,w.beginPath(),w.arc(ue,de,be,0,Math.PI*2),w.fill(),(Oe==="Player"||Oe==="Portal"||se)&&(w.fillStyle=se?"#fff":$e,w.font="9px monospace",w.textAlign="left",w.fillText(ee.name,ue+6,de+3))}),g.current=T,w.fillStyle="#ffcc00",w.beginPath(),w.arc(N,A,5,0,Math.PI*2),w.fill(),w.strokeStyle="#fff",w.lineWidth=1,w.stroke()},[l,f,h]);const S=((l==null?void 0:l.objects)??[]).map(E=>{const w=(l==null?void 0:l.player_ew)??0,M=(l==null?void 0:l.player_ns)??0,N=(l==null?void 0:l.is_dungeon)??!1,A=(l==null?void 0:l.player_x)??0,T=(l==null?void 0:l.player_y)??0;let C,D,z;N&&E.raw_x!==void 0?(C=-(E.raw_x-A),D=E.raw_y-T,z=Math.sqrt(C*C+D*D)):(C=(E.ew??0)-w,D=(E.ns??0)-M,z=Math.sqrt(C*C+D*D)*240);const F=Math.atan2(C,D)*180/Math.PI;return{...E,dist:z,dir:MX(F)}}).sort((E,w)=>E.dist-w.dist),_=Math.round(f*240);return b.jsxs($r,{id:e,title:`Radar: ${t}`,zIndex:n,width:360,height:560,children:[b.jsxs("div",{style:{padding:"4px 8px",display:"flex",justifyContent:"space-between",fontSize:"0.75rem",color:"#888",borderBottom:"1px solid #333",background:"#1a1a1a"},children:[b.jsxs("span",{children:["Range: ~",_,"m"]}),b.jsx("span",{style:{fontSize:"0.65rem",color:"#555"},children:"Scroll to zoom"})]}),b.jsx("canvas",{ref:u,width:qg,height:qg,style:{display:"block",margin:"0 auto",borderBottom:"1px solid #333",cursor:"crosshair",flexShrink:0},onWheel:x,onClick:j}),b.jsxs("div",{style:{flex:1,overflowY:"auto",fontSize:"0.72rem",minHeight:0},children:[b.jsxs("div",{style:{display:"flex",padding:"3px 6px",borderBottom:"1px solid #333",color:"#666",fontSize:"0.65rem",fontWeight:600},children:[b.jsx("span",{style:{width:8}}),b.jsx("span",{style:{flex:1,marginLeft:6},children:"Name"}),b.jsx("span",{style:{width:55,textAlign:"left"},children:"Type"}),b.jsx("span",{style:{width:40,textAlign:"right"},children:"Dist"}),b.jsx("span",{style:{width:24,textAlign:"center"},children:"Dir"})]}),S.length===0&&b.jsx("div",{style:{padding:12,color:"#555",textAlign:"center",fontSize:"0.7rem"},children:"Waiting for radar data..."}),S.map(E=>{const w=E.object_class??E.type??"",M=mM[w]??"#888",N=E.id===h;return b.jsxs("div",{onClick:()=>y(N?null:E.id),style:{display:"flex",alignItems:"center",padding:"2px 6px",borderBottom:"1px solid #1a1a1a",cursor:"pointer",color:"#ccc",background:N?"#1a2a3a":"",borderLeft:N?"2px solid #4488ff":"2px solid transparent"},children:[b.jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:M,flexShrink:0}}),b.jsx("span",{style:{flex:1,marginLeft:6,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:E.name}),b.jsx("span",{style:{width:55,color:"#888",fontSize:"0.65rem"},children:w}),b.jsx("span",{style:{width:40,textAlign:"right",fontVariantNumeric:"tabular-nums"},children:E.dist<1e3?`${Math.round(E.dist)}m`:`${(E.dist/1e3).toFixed(1)}km`}),b.jsx("span",{style:{width:24,textAlign:"center",color:"#666"},children:E.dir})]},E.id)})]})]})},Fo=["Typeless","Slash","Pierce","Bludgeon","Fire","Cold","Acid","Electric"];function ha(e,t,n){var r,l,u,c;return(((l=(r=e==null?void 0:e[t])==null?void 0:r[n])==null?void 0:l.total_normal_damage)??0)+(((c=(u=e==null?void 0:e[t])==null?void 0:u[n])==null?void 0:c.total_crit_damage)??0)}function NX(e){let t={attacks:0,failed:0,crits:0,normalDmg:0,maxNormal:0,critDmg:0,maxCrit:0};if(!e)return t;for(const n of Object.values(e))for(const r of Object.values(n))t.attacks+=r.total_attacks??0,t.failed+=r.failed_attacks??0,t.crits+=r.crits??0,t.normalDmg+=r.total_normal_damage??0,t.maxNormal=Math.max(t.maxNormal,r.max_normal_damage??0),t.critDmg+=r.total_crit_damage??0,t.maxCrit=Math.max(t.maxCrit,r.max_crit_damage??0);return t}function gM(e,t){let n={attacks:0,failed:0};const r=e==null?void 0:e[t];if(!r)return n;for(const l of Object.values(r))n.attacks+=l.total_attacks??0,n.failed+=l.failed_attacks??0;return n}const RX=({id:e,charName:t,zIndex:n})=>{const[r,l]=B.useState(null),[u,c]=B.useState("session"),[f,d]=B.useState(null);B.useEffect(()=>{Ht(`/combat-stats/${encodeURIComponent(t)}`).then(l).catch(()=>{});const C=setInterval(()=>{Ht(`/combat-stats/${encodeURIComponent(t)}`).then(l).catch(()=>{})},1e4);return()=>clearInterval(C)},[t]);const h=r==null?void 0:r[u],y=(h==null?void 0:h.monsters)??{},v=Object.keys(y).filter(C=>C!=="__cloak_surges__").sort(),g=B.useMemo(()=>{let C={},D={},z=0,F=0;const X=f?[y[f]].filter(Boolean):v.map(U=>y[U]);for(const U of X)if(U){for(const[V,L]of Object.entries(U.offense??{})){C[V]||(C[V]={});for(const[G,P]of Object.entries(L)){C[V][G]||(C[V][G]={total_attacks:0,failed_attacks:0,crits:0,total_normal_damage:0,max_normal_damage:0,total_crit_damage:0,max_crit_damage:0});const $=C[V][G],W=P;$.total_attacks+=W.total_attacks??0,$.failed_attacks+=W.failed_attacks??0,$.crits+=W.crits??0,$.total_normal_damage+=W.total_normal_damage??0,$.max_normal_damage=Math.max($.max_normal_damage,W.max_normal_damage??0),$.total_crit_damage+=W.total_crit_damage??0,$.max_crit_damage=Math.max($.max_crit_damage,W.max_crit_damage??0)}}for(const[V,L]of Object.entries(U.defense??{})){D[V]||(D[V]={});for(const[G,P]of Object.entries(L)){D[V][G]||(D[V][G]={total_attacks:0,failed_attacks:0,crits:0,total_normal_damage:0,max_normal_damage:0,total_crit_damage:0,max_crit_damage:0});const $=D[V][G],W=P;$.total_attacks+=W.total_attacks??0,$.failed_attacks+=W.failed_attacks??0,$.total_normal_damage+=W.total_normal_damage??0,$.max_normal_damage=Math.max($.max_normal_damage,W.max_normal_damage??0),$.total_crit_damage+=W.total_crit_damage??0,$.max_crit_damage=Math.max($.max_crit_damage,W.max_crit_damage??0)}}z+=U.aetheria_surges??0,F+=U.cloak_surges??0}return y.__cloak_surges__&&!f&&(F+=y.__cloak_surges__.cloak_surges??0),{offense:C,defense:D,aeth:z,cloak:F}},[y,v,f]),x=NX(g.offense),j=gM(g.defense,"MeleeMissile"),S=gM(g.defense,"Magic");x.attacks>0&&((x.attacks-x.failed)/x.attacks*100).toFixed(0);const _=j.attacks>0?(j.failed/j.attacks*100).toFixed(0):"0",E=S.attacks>0?(S.failed/S.attacks*100).toFixed(0):"0",w=x.attacks-x.failed,M=w-x.crits,N=M>0?Math.round(x.normalDmg/M):0;x.crits>0&&Math.round(x.critDmg/x.crits);const A=w>0?(x.crits/w*100).toFixed(1):"0",T=C=>C===0?"":C.toLocaleString();return b.jsxs($r,{id:e,title:`Combat: ${t}`,zIndex:n,width:640,height:520,children:[b.jsxs("div",{style:{display:"flex",gap:4,padding:"4px 8px",borderBottom:"1px solid #333"},children:[b.jsx("button",{className:`ml-stats-range-btn ${u==="session"?"active":""}`,onClick:()=>c("session"),children:"Session"}),b.jsx("button",{className:`ml-stats-range-btn ${u==="lifetime"?"active":""}`,onClick:()=>c("lifetime"),children:"Lifetime"})]}),b.jsxs("div",{style:{display:"flex",flex:1,overflow:"hidden"},children:[b.jsxs("div",{style:{width:240,borderRight:"1px solid #333",overflowY:"auto",fontSize:"0.72rem"},children:[b.jsxs("div",{style:{display:"flex",padding:"3px 6px",borderBottom:"1px solid #333",color:"#777",fontSize:"0.65rem",fontWeight:600},children:[b.jsx("span",{style:{width:14}}),b.jsx("span",{style:{flex:1},children:"Monster"}),b.jsx("span",{style:{width:40,textAlign:"right"},children:"Kills"}),b.jsx("span",{style:{width:55,textAlign:"right"},children:"Dmg"})]}),b.jsxs("div",{style:{display:"flex",padding:"3px 6px",cursor:"pointer",background:f===null?"#2a3a4a":"",borderBottom:"1px solid #222",color:"#ddd"},onClick:()=>d(null),children:[b.jsx("span",{style:{width:14,color:"#888"},children:f===null?"*":""}),b.jsx("span",{style:{flex:1},children:"All"}),b.jsx("span",{style:{width:40,textAlign:"right"},children:T((h==null?void 0:h.total_kills)??0)}),b.jsx("span",{style:{width:55,textAlign:"right"},children:T((h==null?void 0:h.total_damage_given)??0)})]}),v.map(C=>{const D=y[C];return b.jsxs("div",{style:{display:"flex",padding:"2px 6px",cursor:"pointer",background:f===C?"#2a3a4a":"",borderBottom:"1px solid #1a1a1a",color:"#ccc"},onClick:()=>d(C),children:[b.jsx("span",{style:{width:14,color:"#888"},children:f===C?"*":""}),b.jsx("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:C}),b.jsx("span",{style:{width:40,textAlign:"right"},children:T(D.kill_count)}),b.jsx("span",{style:{width:55,textAlign:"right"},children:T(D.damage_given)})]},C)})]}),b.jsx("div",{style:{flex:1,overflowY:"auto",padding:6,fontSize:"0.72rem"},children:b.jsxs("table",{style:{width:"100%",borderCollapse:"collapse"},children:[b.jsx("thead",{children:b.jsxs("tr",{style:{color:"#777",fontSize:"0.65rem"},children:[b.jsx("th",{style:{textAlign:"left",padding:"1px 4px"}}),b.jsx("th",{style:{textAlign:"right",padding:"1px 3px"},children:"Given M/M"}),b.jsx("th",{style:{textAlign:"right",padding:"1px 3px"},children:"Given Mag"}),b.jsx("th",{style:{width:4}}),b.jsx("th",{style:{textAlign:"right",padding:"1px 3px"},children:"Recv M/M"}),b.jsx("th",{style:{textAlign:"right",padding:"1px 3px"},children:"Recv Mag"}),b.jsx("th",{style:{width:4}}),b.jsx("th",{style:{textAlign:"left",padding:"1px 3px"},children:"Stats"}),b.jsx("th",{style:{textAlign:"right",padding:"1px 3px"}})]})}),b.jsxs("tbody",{children:[Fo.map((C,D)=>{const z=[["Evades",j.attacks>0?`${T(j.attacks)} (${_}%)`:""],["Resists",S.attacks>0?`${T(S.attacks)} (${E}%)`:""],["A.Surges",g.aeth>0?`${T(g.aeth)}`:""],["C.Surges",g.cloak>0?`${T(g.cloak)}`:""],["",""],["",""],["Av/Mx",N>0?`${T(N)} / ${T(x.maxNormal)}`:""],["Crits",x.crits>0?`${T(x.crits)} (${A}%)`:""]][D]??["",""];return b.jsxs("tr",{children:[b.jsx("td",{style:{padding:"1px 4px",color:"#888"},children:C}),b.jsx("td",{style:{textAlign:"right",padding:"1px 3px",color:"#ccc"},children:T(ha(g.offense,"MeleeMissile",C))}),b.jsx("td",{style:{textAlign:"right",padding:"1px 3px",color:"#ccc"},children:T(ha(g.offense,"Magic",C))}),b.jsx("td",{}),b.jsx("td",{style:{textAlign:"right",padding:"1px 3px",color:"#ccc"},children:T(ha(g.defense,"MeleeMissile",C))}),b.jsx("td",{style:{textAlign:"right",padding:"1px 3px",color:"#ccc"},children:T(ha(g.defense,"Magic",C))}),b.jsx("td",{}),b.jsx("td",{style:{padding:"1px 3px",color:"#777",fontWeight:600,fontSize:"0.65rem"},children:z[0]}),b.jsx("td",{style:{textAlign:"right",padding:"1px 3px",color:"#ccc"},children:z[1]})]},C)}),b.jsx("tr",{children:b.jsx("td",{colSpan:9,style:{height:4}})}),b.jsxs("tr",{children:[b.jsx("td",{style:{padding:"1px 4px",color:"#888",fontWeight:600},children:"Total"}),b.jsx("td",{style:{textAlign:"right",padding:"1px 3px",color:"#ccc"},children:T(Fo.reduce((C,D)=>C+ha(g.offense,"MeleeMissile",D),0))}),b.jsx("td",{style:{textAlign:"right",padding:"1px 3px",color:"#ccc"},children:T(Fo.reduce((C,D)=>C+ha(g.offense,"Magic",D),0))}),b.jsx("td",{}),b.jsx("td",{style:{textAlign:"right",padding:"1px 3px",color:"#ccc"},children:T(Fo.reduce((C,D)=>C+ha(g.defense,"MeleeMissile",D),0))}),b.jsx("td",{style:{textAlign:"right",padding:"1px 3px",color:"#ccc"},children:T(Fo.reduce((C,D)=>C+ha(g.defense,"Magic",D),0))}),b.jsx("td",{}),b.jsx("td",{style:{padding:"1px 3px",color:"#777",fontWeight:600,fontSize:"0.65rem"},children:"Total"}),b.jsx("td",{style:{textAlign:"right",padding:"1px 3px",color:"#ccc"},children:T(x.normalDmg+x.critDmg)})]})]})]})})]})]})},PX={plugin:"#4488ff",overlord:"#44cc44",nav:"#ffaa00",macro:"#cc44cc",other:"#888"},DX=({id:e,zIndex:t})=>{const[n,r]=B.useState([]),[l,u]=B.useState(""),[c,f]=B.useState(""),[d,h]=B.useState("plugin"),y=B.useCallback(async()=>{try{const x=await Ht("/issues");r((x.issues??[]).sort((j,S)=>(j.resolved?1:0)-(S.resolved?1:0)))}catch{}},[]);B.useEffect(()=>{y()},[y]);const v=async()=>{l.trim()&&(await fetch("/api/issues",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({title:l.trim(),description:c.trim(),category:d})}),u(""),f(""),y())},g=async x=>{await fetch(`/api/issues/${x.id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({resolved:!x.resolved})}),y()};return b.jsxs($r,{id:e,title:"Issues Board",zIndex:t,width:540,height:520,children:[b.jsx("div",{style:{flex:1,overflowY:"auto",padding:6,fontSize:"0.75rem"},children:n.length===0?b.jsx("div",{style:{padding:12,color:"#666",textAlign:"center"},children:"No issues"}):n.map(x=>b.jsxs("div",{style:{padding:"6px 8px",marginBottom:4,background:"#1f1f1f",borderRadius:3,border:"1px solid #333",opacity:x.resolved?.5:1},children:[b.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[b.jsx("span",{style:{fontSize:"0.6rem",padding:"1px 6px",borderRadius:3,background:PX[x.category]??"#888",color:"#111",fontWeight:600},children:x.category}),b.jsx("span",{style:{flex:1,fontWeight:500},children:x.title}),b.jsx("button",{onClick:()=>g(x),style:{fontSize:"0.65rem",padding:"1px 6px",background:x.resolved?"#333":"rgba(68,204,68,0.15)",color:x.resolved?"#888":"#4c4",border:"1px solid #444",borderRadius:3,cursor:"pointer"},children:x.resolved?"โ†ป Reopen":"โœ“ Resolve"})]}),x.description&&b.jsx("div",{style:{color:"#888",marginTop:3,fontSize:"0.7rem"},children:x.description}),b.jsxs("div",{style:{color:"#555",fontSize:"0.6rem",marginTop:2},children:["by ",x.author," ยท ",new Date(x.created).toLocaleDateString()]})]},x.id))}),b.jsxs("div",{style:{padding:6,borderTop:"1px solid #333",display:"flex",flexDirection:"column",gap:3},children:[b.jsxs("div",{style:{display:"flex",gap:4},children:[b.jsx("input",{value:l,onChange:x=>u(x.target.value),placeholder:"Issue title...",style:{flex:1,padding:"3px 6px",fontSize:"0.75rem",background:"#222",color:"#eee",border:"1px solid #444",borderRadius:3}}),b.jsxs("select",{value:d,onChange:x=>h(x.target.value),style:{padding:"3px 4px",fontSize:"0.7rem",background:"#222",color:"#eee",border:"1px solid #444",borderRadius:3},children:[b.jsx("option",{value:"plugin",children:"Plugin"}),b.jsx("option",{value:"overlord",children:"Overlord"}),b.jsx("option",{value:"nav",children:"Nav"}),b.jsx("option",{value:"macro",children:"Macro"}),b.jsx("option",{value:"other",children:"Other"})]})]}),b.jsxs("div",{style:{display:"flex",gap:4},children:[b.jsx("textarea",{value:c,onChange:x=>f(x.target.value),placeholder:"Description...",rows:2,style:{flex:1,padding:"3px 6px",fontSize:"0.7rem",background:"#222",color:"#eee",border:"1px solid #444",borderRadius:3,resize:"vertical"}}),b.jsx("button",{onClick:v,style:{padding:"4px 12px",background:"rgba(68,136,255,0.15)",color:"#6aadff",border:"1px solid rgba(68,136,255,0.3)",borderRadius:3,cursor:"pointer",alignSelf:"flex-end",fontSize:"0.7rem"},children:"Add"})]})]})]})},kX=({id:e,zIndex:t})=>{const[n,r]=B.useState([]);B.useEffect(()=>{const u=async()=>{try{const f=await Ht("/vital-sharing/peers");r(f.peers??[])}catch{}};u();const c=setInterval(u,5e3);return()=>clearInterval(c)},[]);const l=(u,c)=>c>0?Math.min(100,u/c*100):0;return b.jsx($r,{id:e,title:"Vital Sharing Network",zIndex:t,width:520,height:450,children:b.jsx("div",{style:{flex:1,overflowY:"auto",padding:6,fontSize:"0.75rem"},children:n.length===0?b.jsx("div",{style:{padding:16,color:"#666",textAlign:"center"},children:"No vital-sharing peers connected"}):n.map(u=>{var c,f,d;return b.jsxs("div",{style:{padding:"6px 8px",marginBottom:4,background:"#1f1f1f",borderRadius:3,border:"1px solid #333"},children:[b.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:3},children:[b.jsx("span",{style:{color:u.plugin_connected?"#4c4":"#a33",fontSize:"0.8rem"},children:"โ—"}),b.jsx("strong",{style:{flex:1},children:u.character_name}),u.subscribed&&b.jsx("span",{style:{color:"#6bf",fontSize:"0.65rem"},children:"[subscribed]"})]}),b.jsxs("div",{style:{color:"#666",fontSize:"0.68rem",marginBottom:3},children:["tags: ",((c=u.tags)==null?void 0:c.join(", "))||"none"]}),u.vitals&&u.vitals.max_health>0&&b.jsx("div",{style:{display:"flex",flexDirection:"column",gap:2},children:[{label:"HP",cur:u.vitals.current_health,max:u.vitals.max_health,bg:"#330000",fill:"#c44"},{label:"STA",cur:u.vitals.current_stamina,max:u.vitals.max_stamina,bg:"#331a00",fill:"#ca0"},{label:"MANA",cur:u.vitals.current_mana,max:u.vitals.max_mana,bg:"#001433",fill:"#48f"}].map(h=>b.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4},children:[b.jsx("span",{style:{width:32,color:"#888",fontSize:"0.65rem"},children:h.label}),b.jsx("div",{style:{flex:1,height:6,background:h.bg,borderRadius:3,overflow:"hidden"},children:b.jsx("div",{style:{width:`${l(h.cur,h.max)}%`,height:"100%",background:h.fill,borderRadius:3}})}),b.jsxs("span",{style:{width:60,textAlign:"right",fontSize:"0.65rem",color:"#888"},children:[h.cur,"/",h.max]})]},h.label))}),u.position&&b.jsxs("div",{style:{color:"#555",fontSize:"0.65rem",marginTop:2},children:[(f=u.position.ns)==null?void 0:f.toFixed(1),"N, ",(d=u.position.ew)==null?void 0:d.toFixed(1),"E"]})]},u.character_name)})})})},$X=({characters:e,chatMessages:t,nearbyObjects:n,socket:r})=>{const{windows:l}=vd();return b.jsx(b.Fragment,{children:l.map(u=>{var d;const c=u.charName??"";switch(u.id.split("-")[0]){case"chat":return b.jsx(yX,{id:u.id,charName:c,zIndex:u.zIndex,messages:t.get(c)??[],socket:r},u.id);case"stats":return b.jsx(bX,{id:u.id,charName:c,zIndex:u.zIndex},u.id);case"char":return b.jsx(xX,{id:u.id,charName:c,zIndex:u.zIndex,vitals:((d=e.get(c))==null?void 0:d.vitals)??void 0},u.id);case"inv":return b.jsx(TX,{id:u.id,charName:c,zIndex:u.zIndex},u.id);case"radar":return b.jsx(CX,{id:u.id,charName:c,zIndex:u.zIndex,socket:r,radarData:n.get(c)??null},u.id);case"combat":return b.jsx(RX,{id:u.id,charName:c,zIndex:u.zIndex},u.id);case"issues":return b.jsx(DX,{id:u.id,zIndex:u.zIndex},u.id);case"vitalsharing":return b.jsx(kX,{id:u.id,zIndex:u.zIndex},u.id);default:return null}})})};let zX=0;const qX=({recentRares:e})=>{const[t,n]=B.useState([]),[r,l]=B.useState(0),[u,c]=B.useState([]);B.useEffect(()=>{if(e.length>r&&r>0){const d=e.slice(0,e.length-r);for(const h of d){const y=++zX;n(v=>[...v,{key:y,charName:h.character_name,rareName:h.name,exiting:!1}]),f(),setTimeout(()=>{n(v=>v.map(g=>g.key===y?{...g,exiting:!0}:g)),setTimeout(()=>{n(v=>v.filter(g=>g.key!==y))},500)},6e3)}}l(e.length)},[e.length]);const f=B.useCallback(()=>{const d=Date.now(),h=["#FFD700","#FF4444","#FF8800","#AA44FF","#4488FF"],y=Array.from({length:30},(v,g)=>{const x=Math.PI*2*g/30+(Math.random()-.5)*.5,j=100+Math.random()*200;return{dx:Math.cos(x)*j,dy:Math.sin(x)*j-50,color:h[Math.floor(Math.random()*h.length)]}});c(v=>[...v,{id:d,particles:y}]),setTimeout(()=>c(v=>v.filter(g=>g.id!==d)),2200)},[]);return b.jsxs(b.Fragment,{children:[b.jsx("div",{className:"ml-rare-notifications",children:t.map(d=>b.jsxs("div",{className:`ml-rare-notif ${d.exiting?"exiting":""}`,children:[b.jsx("div",{className:"ml-rare-notif-title",children:"LEGENDARY RARE!"}),b.jsx("div",{className:"ml-rare-notif-name",children:d.rareName}),b.jsx("div",{className:"ml-rare-notif-by",children:"found by"}),b.jsx("div",{className:"ml-rare-notif-char",children:d.charName})]},d.key))}),b.jsx("div",{className:"ml-fireworks",children:u.map(d=>b.jsx(I.Fragment,{children:d.particles.map((h,y)=>b.jsx("div",{className:"ml-firework-particle",style:{left:"50%",top:"30%",backgroundColor:h.color,"--dx":`${h.dx}px`,"--dy":`${h.dy+200}px`}},y))},d.id))})]})},bM=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf","#ff4444","#44ff44","#4444ff","#ffff44","#ff44ff","#44ffff","#ff8844","#88ff44","#4488ff","#ff4488","#cc3333","#33cc33","#3333cc","#cccc33","#cc33cc","#33cccc","#cc6633","#66cc33","#3366cc","#cc3366","#ff6666","#66ff66","#6666ff","#ffff66","#ff66ff","#66ffff","#ffaa66","#aaff66","#66aaff","#ff66aa","#990099","#009900","#000099","#990000","#009999","#999900","#aa5500","#55aa00","#0055aa","#aa0055","#ffaaaa","#aaffaa","#aaaaff","#ffffaa","#ffaaff","#aaffff","#ffccaa","#ccffaa","#aaccff","#ffaacc"];function BX(e){let t=0;for(let n=0;n{let l=e.current.get(r);return l||(l=t.current{const n=LX(),[r,l]=B.useState(!1),[u,c]=B.useState(!1),f=Array.from(e.characters.values()).filter(y=>y.telemetry).map(y=>y.telemetry),d=new Map(Array.from(e.characters.values()).filter(y=>y.vitals).map(y=>[y.name,y.vitals])),h=B.useCallback(y=>{},[]);return b.jsx(rX,{children:b.jsx(iX,{children:b.jsxs("div",{className:"ml-layout",children:[b.jsx(pX,{players:f,vitals:d,serverHealth:e.serverHealth,totalRares:e.totalRares,totalKills:e.totalKills,getColor:n,onSelectPlayer:h,onViewToggle:t,showHeatmap:r,showPortals:u,onToggleHeatmap:l,onTogglePortals:c}),b.jsx(cX,{players:f,getColor:n,onSelectPlayer:h,showHeatmap:r,showPortals:u}),b.jsx($X,{characters:e.characters,chatMessages:e.chatMessages,nearbyObjects:e.nearbyObjects,socket:e.socketRef.current}),b.jsx(qX,{recentRares:e.recentRares})]})})})};function UX(e){const t=B.useRef(null),n=B.useRef(0),r=B.useRef(e);r.current=e;const l=B.useCallback(()=>{var c;if(((c=t.current)==null?void 0:c.readyState)===WebSocket.OPEN)return;const u=new WebSocket(QY());t.current=u,u.addEventListener("message",f=>{try{const d=JSON.parse(f.data);r.current(d)}catch{}}),u.addEventListener("close",()=>{t.current=null,n.current=window.setTimeout(l,2e3)}),u.addEventListener("error",()=>{u.close()})},[]);return B.useEffect(()=>(l(),()=>{var u;clearTimeout(n.current),(u=t.current)==null||u.close(),t.current=null}),[l]),t}const HX=()=>Ht("/live"),GX=()=>Ht("/combat-stats"),YX=()=>Ht("/server-health"),XX=()=>Ht("/total-rares"),KX=()=>Ht("/total-kills");function VX(){const[e,t]=B.useState(new Map),[n,r]=B.useState(null),[l,u]=B.useState(0),[c,f]=B.useState(0),[d,h]=B.useState([]),[y,v]=B.useState(new Map),[g,x]=B.useState(new Map),j=B.useRef(e);j.current=e;const S=B.useCallback((w,M)=>{t(N=>{const A=new Map(N),T=A.get(w)??{name:w,telemetry:null,vitals:null,combat:null,lastUpdate:0};return A.set(w,M(T)),A})},[]),_=B.useCallback(w=>{if(w.type){if(w.type==="telemetry"){const M=w;S(M.character_name,N=>({...N,telemetry:M,lastUpdate:Date.now()}))}else if(w.type==="vitals"){const M=w;S(M.character_name,N=>({...N,vitals:M,lastUpdate:Date.now()}))}else if(w.type==="combat_stats"){const M=w;S(M.character_name,N=>({...N,combat:M,lastUpdate:Date.now()}))}else if(w.type==="rare"){const M=w;h(N=>[M,...N].slice(0,50))}else if(w.type==="nearby_objects"){const M=w;x(N=>{const A=new Map(N);return A.set(M.character_name,M),A})}else if(w.type==="chat"){const M=w;v(N=>{const A=new Map(N),T=[...A.get(M.character_name)??[],{text:M.text,color:M.color,timestamp:M.timestamp}];return T.length>1e3&&T.splice(0,T.length-1e3),A.set(M.character_name,T),A})}}},[S]),E=UX(_);return B.useEffect(()=>{const w=async()=>{try{const N=await HX();t(A=>{var C;const T=new Map(A);for(const D of N.players??[]){const z=T.get(D.character_name);T.set(D.character_name,{name:D.character_name,telemetry:D,vitals:(z==null?void 0:z.vitals)??null,combat:(z==null?void 0:z.combat)??null,lastUpdate:Date.now()})}for(const D of T.keys())(C=N.players)!=null&&C.some(z=>z.character_name===D)||T.delete(D);return T})}catch{}};w();const M=setInterval(w,5e3);return()=>clearInterval(M)},[]),B.useEffect(()=>{const w=async()=>{try{const N=await GX();for(const A of N.stats??[])S(A.character_name,T=>({...T,combat:{...A,type:"combat_stats"}}))}catch{}};w();const M=setInterval(w,3e4);return()=>clearInterval(M)},[S]),B.useEffect(()=>{const w=async()=>{try{r(await YX())}catch{}};w();const M=setInterval(w,3e4);return()=>clearInterval(M)},[]),B.useEffect(()=>{const w=async()=>{try{const[N,A]=await Promise.all([XX(),KX()]);u(N.all_time??0),f(A.total??0)}catch{}};w();const M=setInterval(w,3e5);return()=>clearInterval(M)},[]),{characters:e,serverHealth:n,totalRares:l,totalKills:c,recentRares:d,chatMessages:y,nearbyObjects:g,socketRef:E}}function FX(){const[e,t]=B.useState(()=>localStorage.getItem("v2-view")||"map"),n=VX(),r=()=>{const u=e==="map"?"dashboard":"map";t(u),localStorage.setItem("v2-view",u)};if(e==="map")return b.jsx(IX,{data:n,onViewToggle:r});const l=[{id:"combat",label:"Combat",content:b.jsx(KY,{characters:n.characters})},{id:"rares",label:"Rares",content:b.jsx(VY,{characters:n.characters,totalRares:n.totalRares,totalKills:n.totalKills,recentRares:n.recentRares})},{id:"map",label:"Map",content:b.jsx(WY,{characters:n.characters})},{id:"inventory",label:"Inventory",content:b.jsx(JY,{})}];return b.jsxs(bD,{children:[b.jsx("div",{style:{display:"flex",justifyContent:"flex-end",marginBottom:8},children:b.jsx("button",{onClick:r,className:"tab-btn",children:"Map View"})}),b.jsx(xD,{activeChars:n.characters.size,totalKills:n.totalKills,totalRares:n.totalRares,serverHealth:n.serverHealth}),b.jsx(SD,{characters:n.characters}),b.jsx(OD,{tabs:l})]})}gD.createRoot(document.getElementById("root")).render(b.jsx(B.StrictMode,{children:b.jsx(FX,{})})); +In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function DR(e,t){if(e){if(typeof e=="string")return rb(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return rb(e,t)}}function NY(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function RY(e){if(Array.isArray(e))return rb(e)}function rb(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n0?c:t&&t.length&&fe(l)&&fe(u)?t.slice(l,u+1):[]};function zR(e){return e==="number"?[0,"auto"]:void 0}var ab=function(t,n,r,l){var u=t.graphicalItems,c=t.tooltipAxis,f=pd(n,t);return r<0||!u||!u.length||r>=f.length?null:u.reduce(function(d,h){var y,v=(y=h.props.data)!==null&&y!==void 0?y:n;v&&t.dataStartIndex+t.dataEndIndex!==0&&t.dataEndIndex-t.dataStartIndex>=r&&(v=v.slice(t.dataStartIndex,t.dataEndIndex+1));var g;if(c.dataKey&&!c.allowDuplicatedCategory){var x=v===void 0?f:v;g=Bg(x,c.dataKey,l)}else g=v&&v[r]||f[r];return g?[].concat(kl(d),[CN(h,g)]):d},[])},cM=function(t,n,r,l){var u=l||{x:t.chartX,y:t.chartY},c=$Y(u,r),f=t.orderedTooltipTicks,d=t.tooltipAxis,h=t.tooltipTicks,y=gB(c,f,h,d);if(y>=0&&h){var v=h[y]&&h[y].value,g=ab(t,n,y,v),x=zY(r,f,y,u);return{activeTooltipIndex:y,activeLabel:v,activePayload:g,activeCoordinate:x}}return null},qY=function(t,n){var r=n.axes,l=n.graphicalItems,u=n.axisType,c=n.axisIdKey,f=n.stackGroups,d=n.dataStartIndex,h=n.dataEndIndex,y=t.layout,v=t.children,g=t.stackOffset,x=AN(y,u);return r.reduce(function(j,S){var _,E=S.type.defaultProps!==void 0?ae(ae({},S.type.defaultProps),S.props):S.props,w=E.type,M=E.dataKey,N=E.allowDataOverflow,A=E.allowDuplicatedCategory,T=E.scale,C=E.ticks,D=E.includeHidden,z=E[c];if(j[z])return j;var F=pd(t.data,{graphicalItems:l.filter(function(Y){var ne,ue=c in Y.props?Y.props[c]:(ne=Y.type.defaultProps)===null||ne===void 0?void 0:ne[c];return ue===z}),dataStartIndex:d,dataEndIndex:h}),X=F.length,U,V,L;sY(E.domain,N,w)&&(U=b0(E.domain,null,N),x&&(w==="number"||T!=="auto")&&(L=tu(F,M,"category")));var G=zR(w);if(!U||U.length===0){var P,$=(P=E.domain)!==null&&P!==void 0?P:G;if(M){if(U=tu(F,M,w),w==="category"&&x){var W=d6(U);A&&W?(V=U,U=yf(0,X)):A||(U=pE($,U,S).reduce(function(Y,ne){return Y.indexOf(ne)>=0?Y:[].concat(kl(Y),[ne])},[]))}else if(w==="category")A?U=U.filter(function(Y){return Y!==""&&!Ce(Y)}):U=pE($,U,S).reduce(function(Y,ne){return Y.indexOf(ne)>=0||ne===""||Ce(ne)?Y:[].concat(kl(Y),[ne])},[]);else if(w==="number"){var ee=OB(F,l.filter(function(Y){var ne,ue,de=c in Y.props?Y.props[c]:(ne=Y.type.defaultProps)===null||ne===void 0?void 0:ne[c],me="hide"in Y.props?Y.props.hide:(ue=Y.type.defaultProps)===null||ue===void 0?void 0:ue.hide;return de===z&&(D||!me)}),M,u,y);ee&&(U=ee)}x&&(w==="number"||T!=="auto")&&(L=tu(F,M,"category"))}else x?U=yf(0,X):f&&f[z]&&f[z].hasStack&&w==="number"?U=g==="expand"?[0,1]:MN(f[z].stackGroups,d,h):U=ON(F,l.filter(function(Y){var ne=c in Y.props?Y.props[c]:Y.type.defaultProps[c],ue="hide"in Y.props?Y.props.hide:Y.type.defaultProps.hide;return ne===z&&(D||!ue)}),w,y,!0);if(w==="number")U=tb(v,U,z,u,C),$&&(U=b0($,U,N));else if(w==="category"&&$){var le=$,k=U.every(function(Y){return le.indexOf(Y)>=0});k&&(U=le)}}return ae(ae({},j),{},xe({},z,ae(ae({},E),{},{axisType:u,domain:U,categoricalDomain:L,duplicateDomain:V,originalDomain:(_=E.domain)!==null&&_!==void 0?_:G,isCategorical:x,layout:y})))},{})},BY=function(t,n){var r=n.graphicalItems,l=n.Axis,u=n.axisType,c=n.axisIdKey,f=n.stackGroups,d=n.dataStartIndex,h=n.dataEndIndex,y=t.layout,v=t.children,g=pd(t.data,{graphicalItems:r,dataStartIndex:d,dataEndIndex:h}),x=g.length,j=AN(y,u),S=-1;return r.reduce(function(_,E){var w=E.type.defaultProps!==void 0?ae(ae({},E.type.defaultProps),E.props):E.props,M=w[c],N=zR("number");if(!_[M]){S++;var A;return j?A=yf(0,x):f&&f[M]&&f[M].hasStack?(A=MN(f[M].stackGroups,d,h),A=tb(v,A,M,u)):(A=b0(N,ON(g,r.filter(function(T){var C,D,z=c in T.props?T.props[c]:(C=T.type.defaultProps)===null||C===void 0?void 0:C[c],F="hide"in T.props?T.props.hide:(D=T.type.defaultProps)===null||D===void 0?void 0:D.hide;return z===M&&!F}),"number",y),l.defaultProps.allowDataOverflow),A=tb(v,A,M,u)),ae(ae({},_),{},xe({},M,ae(ae({axisType:u},l.defaultProps),{},{hide:!0,orientation:mn(DY,"".concat(u,".").concat(S%2),null),domain:A,originalDomain:N,isCategorical:j,layout:y})))}return _},{})},LY=function(t,n){var r=n.axisType,l=r===void 0?"xAxis":r,u=n.AxisComp,c=n.graphicalItems,f=n.stackGroups,d=n.dataStartIndex,h=n.dataEndIndex,y=t.children,v="".concat(l,"Id"),g=Dn(y,u),x={};return g&&g.length?x=qY(t,{axes:g,graphicalItems:c,axisType:l,axisIdKey:v,stackGroups:f,dataStartIndex:d,dataEndIndex:h}):c&&c.length&&(x=BY(t,{Axis:u,graphicalItems:c,axisType:l,axisIdKey:v,stackGroups:f,dataStartIndex:d,dataEndIndex:h})),x},IY=function(t){var n=ya(t),r=Er(n,!1,!0);return{tooltipTicks:r,orderedTooltipTicks:Eb(r,function(l){return l.coordinate}),tooltipAxis:n,tooltipAxisBandSize:nf(n,r)}},sM=function(t){var n=t.children,r=t.defaultShowTooltip,l=pn(n,Al),u=0,c=0;return t.data&&t.data.length!==0&&(c=t.data.length-1),l&&l.props&&(l.props.startIndex>=0&&(u=l.props.startIndex),l.props.endIndex>=0&&(c=l.props.endIndex)),{chartX:0,chartY:0,dataStartIndex:u,dataEndIndex:c,activeTooltipIndex:-1,isTooltipActive:!!r}},UY=function(t){return!t||!t.length?!1:t.some(function(n){var r=Mr(n&&n.type);return r&&r.indexOf("Bar")>=0})},fM=function(t){return t==="horizontal"?{numericAxisName:"yAxis",cateAxisName:"xAxis"}:t==="vertical"?{numericAxisName:"xAxis",cateAxisName:"yAxis"}:t==="centric"?{numericAxisName:"radiusAxis",cateAxisName:"angleAxis"}:{numericAxisName:"angleAxis",cateAxisName:"radiusAxis"}},HY=function(t,n){var r=t.props,l=t.graphicalItems,u=t.xAxisMap,c=u===void 0?{}:u,f=t.yAxisMap,d=f===void 0?{}:f,h=r.width,y=r.height,v=r.children,g=r.margin||{},x=pn(v,Al),j=pn(v,Qa),S=Object.keys(d).reduce(function(A,T){var C=d[T],D=C.orientation;return!C.mirror&&!C.hide?ae(ae({},A),{},xe({},D,A[D]+C.width)):A},{left:g.left||0,right:g.right||0}),_=Object.keys(c).reduce(function(A,T){var C=c[T],D=C.orientation;return!C.mirror&&!C.hide?ae(ae({},A),{},xe({},D,mn(A,"".concat(D))+C.height)):A},{top:g.top||0,bottom:g.bottom||0}),E=ae(ae({},_),S),w=E.bottom;x&&(E.bottom+=x.props.height||Al.defaultProps.height),j&&n&&(E=_B(E,l,r,n));var M=h-E.left-E.right,N=y-E.top-E.bottom;return ae(ae({brushBottom:w},E),{},{width:Math.max(M,0),height:Math.max(N,0)})},GY=function(t,n){if(n==="xAxis")return t[n].width;if(n==="yAxis")return t[n].height},qR=function(t){var n=t.chartName,r=t.GraphicalChild,l=t.defaultTooltipEventType,u=l===void 0?"axis":l,c=t.validateTooltipEventTypes,f=c===void 0?["axis"]:c,d=t.axisComponents,h=t.legendContent,y=t.formatAxisMap,v=t.defaultProps,g=function(E,w){var M=w.graphicalItems,N=w.stackGroups,A=w.offset,T=w.updateId,C=w.dataStartIndex,D=w.dataEndIndex,z=E.barSize,F=E.layout,X=E.barGap,U=E.barCategoryGap,V=E.maxBarSize,L=fM(F),G=L.numericAxisName,P=L.cateAxisName,$=UY(M),W=[];return M.forEach(function(ee,le){var k=pd(E.data,{graphicalItems:[ee],dataStartIndex:C,dataEndIndex:D}),Y=ee.type.defaultProps!==void 0?ae(ae({},ee.type.defaultProps),ee.props):ee.props,ne=Y.dataKey,ue=Y.maxBarSize,de=Y["".concat(G,"Id")],me=Y["".concat(P,"Id")],Oe={},$e=d.reduce(function(qn,ir){var Gl=w["".concat(ir.axisType,"Map")],qt=Y["".concat(ir.axisType,"Id")];Gl&&Gl[qt]||ir.axisType==="zAxis"||ii();var Vu=Gl[qt];return ae(ae({},qn),{},xe(xe({},ir.axisType,Vu),"".concat(ir.axisType,"Ticks"),Er(Vu)))},Oe),se=$e[P],be=$e["".concat(P,"Ticks")],Ae=N&&N[de]&&N[de].hasStack&&RB(ee,N[de].stackGroups),ce=Mr(ee.type).indexOf("Bar")>=0,nt=nf(se,be),Te=[],ut=$&&bB({barSize:z,stackGroups:N,totalSize:GY($e,P)});if(ce){var ct,zt,zn=Ce(ue)?V:ue,Vn=(ct=(zt=nf(se,be,!0))!==null&&zt!==void 0?zt:zn)!==null&&ct!==void 0?ct:0;Te=xB({barGap:X,barCategoryGap:U,bandSize:Vn!==nt?Vn:nt,sizeList:ut[me],maxBarSize:zn}),Vn!==nt&&(Te=Te.map(function(qn){return ae(ae({},qn),{},{position:ae(ae({},qn.position),{},{offset:qn.position.offset-Vn/2})})}))}var Ir=ee&&ee.type&&ee.type.getComposedData;Ir&&W.push({props:ae(ae({},Ir(ae(ae({},$e),{},{displayedData:k,props:E,dataKey:ne,item:ee,bandSize:nt,barPosition:Te,offset:A,stackedData:Ae,layout:F,dataStartIndex:C,dataEndIndex:D}))),{},xe(xe(xe({key:ee.key||"item-".concat(le)},G,$e[G]),P,$e[P]),"animationId",T)),childIndex:A6(ee,E.children),item:ee})}),W},x=function(E,w){var M=E.props,N=E.dataStartIndex,A=E.dataEndIndex,T=E.updateId;if(!MA({props:M}))return null;var C=M.children,D=M.layout,z=M.stackOffset,F=M.data,X=M.reverseStackOrder,U=fM(D),V=U.numericAxisName,L=U.cateAxisName,G=Dn(C,r),P=CB(F,G,"".concat(V,"Id"),"".concat(L,"Id"),z,X),$=d.reduce(function(Y,ne){var ue="".concat(ne.axisType,"Map");return ae(ae({},Y),{},xe({},ue,LY(M,ae(ae({},ne),{},{graphicalItems:G,stackGroups:ne.axisType===V&&P,dataStartIndex:N,dataEndIndex:A}))))},{}),W=HY(ae(ae({},$),{},{props:M,graphicalItems:G}),w==null?void 0:w.legendBBox);Object.keys($).forEach(function(Y){$[Y]=y(M,$[Y],W,Y.replace("Map",""),n)});var ee=$["".concat(L,"Map")],le=IY(ee),k=g(M,ae(ae({},$),{},{dataStartIndex:N,dataEndIndex:A,updateId:T,graphicalItems:G,stackGroups:P,offset:W}));return ae(ae({formattedGraphicalItems:k,graphicalItems:G,offset:W,stackGroups:P},le),$)},j=(function(_){function E(w){var M,N,A;return OY(this,E),A=jY(this,E,[w]),xe(A,"eventEmitterSymbol",Symbol("rechartsEventEmitter")),xe(A,"accessibilityManager",new cY),xe(A,"handleLegendBBoxUpdate",function(T){if(T){var C=A.state,D=C.dataStartIndex,z=C.dataEndIndex,F=C.updateId;A.setState(ae({legendBBox:T},x({props:A.props,dataStartIndex:D,dataEndIndex:z,updateId:F},ae(ae({},A.state),{},{legendBBox:T}))))}}),xe(A,"handleReceiveSyncEvent",function(T,C,D){if(A.props.syncId===T){if(D===A.eventEmitterSymbol&&typeof A.props.syncMethod!="function")return;A.applySyncEvent(C)}}),xe(A,"handleBrushChange",function(T){var C=T.startIndex,D=T.endIndex;if(C!==A.state.dataStartIndex||D!==A.state.dataEndIndex){var z=A.state.updateId;A.setState(function(){return ae({dataStartIndex:C,dataEndIndex:D},x({props:A.props,dataStartIndex:C,dataEndIndex:D,updateId:z},A.state))}),A.triggerSyncEvent({dataStartIndex:C,dataEndIndex:D})}}),xe(A,"handleMouseEnter",function(T){var C=A.getMouseInfo(T);if(C){var D=ae(ae({},C),{},{isTooltipActive:!0});A.setState(D),A.triggerSyncEvent(D);var z=A.props.onMouseEnter;Se(z)&&z(D,T)}}),xe(A,"triggeredAfterMouseMove",function(T){var C=A.getMouseInfo(T),D=C?ae(ae({},C),{},{isTooltipActive:!0}):{isTooltipActive:!1};A.setState(D),A.triggerSyncEvent(D);var z=A.props.onMouseMove;Se(z)&&z(D,T)}),xe(A,"handleItemMouseEnter",function(T){A.setState(function(){return{isTooltipActive:!0,activeItem:T,activePayload:T.tooltipPayload,activeCoordinate:T.tooltipPosition||{x:T.cx,y:T.cy}}})}),xe(A,"handleItemMouseLeave",function(){A.setState(function(){return{isTooltipActive:!1}})}),xe(A,"handleMouseMove",function(T){T.persist(),A.throttleTriggeredAfterMouseMove(T)}),xe(A,"handleMouseLeave",function(T){A.throttleTriggeredAfterMouseMove.cancel();var C={isTooltipActive:!1};A.setState(C),A.triggerSyncEvent(C);var D=A.props.onMouseLeave;Se(D)&&D(C,T)}),xe(A,"handleOuterEvent",function(T){var C=O6(T),D=mn(A.props,"".concat(C));if(C&&Se(D)){var z,F;/.*touch.*/i.test(C)?F=A.getMouseInfo(T.changedTouches[0]):F=A.getMouseInfo(T),D((z=F)!==null&&z!==void 0?z:{},T)}}),xe(A,"handleClick",function(T){var C=A.getMouseInfo(T);if(C){var D=ae(ae({},C),{},{isTooltipActive:!0});A.setState(D),A.triggerSyncEvent(D);var z=A.props.onClick;Se(z)&&z(D,T)}}),xe(A,"handleMouseDown",function(T){var C=A.props.onMouseDown;if(Se(C)){var D=A.getMouseInfo(T);C(D,T)}}),xe(A,"handleMouseUp",function(T){var C=A.props.onMouseUp;if(Se(C)){var D=A.getMouseInfo(T);C(D,T)}}),xe(A,"handleTouchMove",function(T){T.changedTouches!=null&&T.changedTouches.length>0&&A.throttleTriggeredAfterMouseMove(T.changedTouches[0])}),xe(A,"handleTouchStart",function(T){T.changedTouches!=null&&T.changedTouches.length>0&&A.handleMouseDown(T.changedTouches[0])}),xe(A,"handleTouchEnd",function(T){T.changedTouches!=null&&T.changedTouches.length>0&&A.handleMouseUp(T.changedTouches[0])}),xe(A,"handleDoubleClick",function(T){var C=A.props.onDoubleClick;if(Se(C)){var D=A.getMouseInfo(T);C(D,T)}}),xe(A,"handleContextMenu",function(T){var C=A.props.onContextMenu;if(Se(C)){var D=A.getMouseInfo(T);C(D,T)}}),xe(A,"triggerSyncEvent",function(T){A.props.syncId!==void 0&&Dg.emit(kg,A.props.syncId,T,A.eventEmitterSymbol)}),xe(A,"applySyncEvent",function(T){var C=A.props,D=C.layout,z=C.syncMethod,F=A.state.updateId,X=T.dataStartIndex,U=T.dataEndIndex;if(T.dataStartIndex!==void 0||T.dataEndIndex!==void 0)A.setState(ae({dataStartIndex:X,dataEndIndex:U},x({props:A.props,dataStartIndex:X,dataEndIndex:U,updateId:F},A.state)));else if(T.activeTooltipIndex!==void 0){var V=T.chartX,L=T.chartY,G=T.activeTooltipIndex,P=A.state,$=P.offset,W=P.tooltipTicks;if(!$)return;if(typeof z=="function")G=z(W,T);else if(z==="value"){G=-1;for(var ee=0;ee=0){var Ae,ce;if(V.dataKey&&!V.allowDuplicatedCategory){var nt=typeof V.dataKey=="function"?be:"payload.".concat(V.dataKey.toString());Ae=Bg(ee,nt,G),ce=le&&k&&Bg(k,nt,G)}else Ae=ee==null?void 0:ee[L],ce=le&&k&&k[L];if(me||de){var Te=T.props.activeIndex!==void 0?T.props.activeIndex:L;return[B.cloneElement(T,ae(ae(ae({},z.props),$e),{},{activeIndex:Te})),null,null]}if(!Ce(Ae))return[se].concat(kl(A.renderActivePoints({item:z,activePoint:Ae,basePoint:ce,childIndex:L,isRange:le})))}else{var ut,ct=(ut=A.getItemByXY(A.state.activeCoordinate))!==null&&ut!==void 0?ut:{graphicalItem:se},zt=ct.graphicalItem,zn=zt.item,Vn=zn===void 0?T:zn,Ir=zt.childIndex,qn=ae(ae(ae({},z.props),$e),{},{activeIndex:Ir});return[B.cloneElement(Vn,qn),null,null]}return le?[se,null,null]:[se,null]}),xe(A,"renderCustomized",function(T,C,D){return B.cloneElement(T,ae(ae({key:"recharts-customized-".concat(D)},A.props),A.state))}),xe(A,"renderMap",{CartesianGrid:{handler:ws,once:!0},ReferenceArea:{handler:A.renderReferenceElement},ReferenceLine:{handler:ws},ReferenceDot:{handler:A.renderReferenceElement},XAxis:{handler:ws},YAxis:{handler:ws},Brush:{handler:A.renderBrush,once:!0},Bar:{handler:A.renderGraphicChild},Line:{handler:A.renderGraphicChild},Area:{handler:A.renderGraphicChild},Radar:{handler:A.renderGraphicChild},RadialBar:{handler:A.renderGraphicChild},Scatter:{handler:A.renderGraphicChild},Pie:{handler:A.renderGraphicChild},Funnel:{handler:A.renderGraphicChild},Tooltip:{handler:A.renderCursor,once:!0},PolarGrid:{handler:A.renderPolarGrid,once:!0},PolarAngleAxis:{handler:A.renderPolarAxis},PolarRadiusAxis:{handler:A.renderPolarAxis},Customized:{handler:A.renderCustomized}}),A.clipPathId="".concat((M=w.id)!==null&&M!==void 0?M:Uu("recharts"),"-clip"),A.throttleTriggeredAfterMouseMove=_C(A.triggeredAfterMouseMove,(N=w.throttleDelay)!==null&&N!==void 0?N:1e3/60),A.state={},A}return MY(E,_),wY(E,[{key:"componentDidMount",value:function(){var M,N;this.addListener(),this.accessibilityManager.setDetails({container:this.container,offset:{left:(M=this.props.margin.left)!==null&&M!==void 0?M:0,top:(N=this.props.margin.top)!==null&&N!==void 0?N:0},coordinateList:this.state.tooltipTicks,mouseHandlerCallback:this.triggeredAfterMouseMove,layout:this.props.layout}),this.displayDefaultTooltip()}},{key:"displayDefaultTooltip",value:function(){var M=this.props,N=M.children,A=M.data,T=M.height,C=M.layout,D=pn(N,vn);if(D){var z=D.props.defaultIndex;if(!(typeof z!="number"||z<0||z>this.state.tooltipTicks.length-1)){var F=this.state.tooltipTicks[z]&&this.state.tooltipTicks[z].value,X=ab(this.state,A,z,F),U=this.state.tooltipTicks[z].coordinate,V=(this.state.offset.top+T)/2,L=C==="horizontal",G=L?{x:U,y:V}:{y:U,x:V},P=this.state.formattedGraphicalItems.find(function(W){var ee=W.item;return ee.type.name==="Scatter"});P&&(G=ae(ae({},G),P.props.points[z].tooltipPosition),X=P.props.points[z].tooltipPayload);var $={activeTooltipIndex:z,isTooltipActive:!0,activeLabel:F,activePayload:X,activeCoordinate:G};this.setState($),this.renderCursor(D),this.accessibilityManager.setIndex(z)}}}},{key:"getSnapshotBeforeUpdate",value:function(M,N){if(!this.props.accessibilityLayer)return null;if(this.state.tooltipTicks!==N.tooltipTicks&&this.accessibilityManager.setDetails({coordinateList:this.state.tooltipTicks}),this.props.layout!==M.layout&&this.accessibilityManager.setDetails({layout:this.props.layout}),this.props.margin!==M.margin){var A,T;this.accessibilityManager.setDetails({offset:{left:(A=this.props.margin.left)!==null&&A!==void 0?A:0,top:(T=this.props.margin.top)!==null&&T!==void 0?T:0}})}return null}},{key:"componentDidUpdate",value:function(M){Ig([pn(M.children,vn)],[pn(this.props.children,vn)])||this.displayDefaultTooltip()}},{key:"componentWillUnmount",value:function(){this.removeListener(),this.throttleTriggeredAfterMouseMove.cancel()}},{key:"getTooltipEventType",value:function(){var M=pn(this.props.children,vn);if(M&&typeof M.props.shared=="boolean"){var N=M.props.shared?"axis":"item";return f.indexOf(N)>=0?N:u}return u}},{key:"getMouseInfo",value:function(M){if(!this.container)return null;var N=this.container,A=N.getBoundingClientRect(),T=s$(A),C={chartX:Math.round(M.pageX-T.left),chartY:Math.round(M.pageY-T.top)},D=A.width/N.offsetWidth||1,z=this.inRange(C.chartX,C.chartY,D);if(!z)return null;var F=this.state,X=F.xAxisMap,U=F.yAxisMap,V=this.getTooltipEventType(),L=cM(this.state,this.props.data,this.props.layout,z);if(V!=="axis"&&X&&U){var G=ya(X).scale,P=ya(U).scale,$=G&&G.invert?G.invert(C.chartX):null,W=P&&P.invert?P.invert(C.chartY):null;return ae(ae({},C),{},{xValue:$,yValue:W},L)}return L?ae(ae({},C),L):null}},{key:"inRange",value:function(M,N){var A=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,T=this.props.layout,C=M/A,D=N/A;if(T==="horizontal"||T==="vertical"){var z=this.state.offset,F=C>=z.left&&C<=z.left+z.width&&D>=z.top&&D<=z.top+z.height;return F?{x:C,y:D}:null}var X=this.state,U=X.angleAxisMap,V=X.radiusAxisMap;if(U&&V){var L=ya(U);return mE({x:C,y:D},L)}return null}},{key:"parseEventsOfWrapper",value:function(){var M=this.props.children,N=this.getTooltipEventType(),A=pn(M,vn),T={};A&&N==="axis"&&(A.props.trigger==="click"?T={onClick:this.handleClick}:T={onMouseEnter:this.handleMouseEnter,onDoubleClick:this.handleDoubleClick,onMouseMove:this.handleMouseMove,onMouseLeave:this.handleMouseLeave,onTouchMove:this.handleTouchMove,onTouchStart:this.handleTouchStart,onTouchEnd:this.handleTouchEnd,onContextMenu:this.handleContextMenu});var C=Ns(this.props,this.handleOuterEvent);return ae(ae({},C),T)}},{key:"addListener",value:function(){Dg.on(kg,this.handleReceiveSyncEvent)}},{key:"removeListener",value:function(){Dg.removeListener(kg,this.handleReceiveSyncEvent)}},{key:"filterFormatItem",value:function(M,N,A){for(var T=this.state.formattedGraphicalItems,C=0,D=T.length;C{const t=B.useMemo(()=>Array.from(e.values()).filter(l=>l.telemetry).map(l=>({name:l.name.length>18?l.name.slice(0,16)+"..":l.name,fullName:l.name,killsPerHour:parseInt(l.telemetry.kills_per_hour)||0,totalKills:l.telemetry.kills||0})).sort((l,u)=>u.killsPerHour-l.killsPerHour).slice(0,30),[e]),n=B.useMemo(()=>Array.from(e.values()).filter(l=>{var u;return(u=l.combat)==null?void 0:u.session}).map(l=>({name:l.name.length>18?l.name.slice(0,16)+"..":l.name,fullName:l.name,damage:l.combat.session.total_damage_given})).sort((l,u)=>u.damage-l.damage).slice(0,30),[e]),r=B.useMemo(()=>{var u;const l={};for(const c of e.values()){const f=(u=c.combat)==null?void 0:u.session;if(f!=null&&f.monsters){for(const d of Object.values(f.monsters))if(d.offense)for(const h of Object.values(d.offense))for(const[y,v]of Object.entries(h))y==="None"||y==="Unknown"||(l[y]=(l[y]||0)+(v.damage||0))}}return Object.entries(l).map(([c,f])=>({name:c,value:f})).filter(c=>c.value>0).sort((c,f)=>f.value-c.value)},[e]);return b.jsxs("div",{className:"combat-tab",children:[b.jsxs("div",{className:"chart-section",children:[b.jsx("h3",{className:"chart-title",children:"Kills per Hour"}),b.jsx(Es,{width:"100%",height:Math.max(200,t.length*28),children:b.jsxs(ib,{data:t,layout:"vertical",margin:{left:10,right:20,top:5,bottom:5},children:[b.jsx(jf,{strokeDasharray:"3 3",stroke:"#333"}),b.jsx(Nl,{type:"number",stroke:"#888",fontSize:11}),b.jsx(Pl,{type:"category",dataKey:"name",width:130,stroke:"#888",fontSize:11}),b.jsx(vn,{contentStyle:{background:"#1a1a1a",border:"1px solid #444",fontSize:12},formatter:l=>[l.toLocaleString(),"Kills/hr"],labelFormatter:(l,u)=>{var c,f;return((f=(c=u==null?void 0:u[0])==null?void 0:c.payload)==null?void 0:f.fullName)||l}}),b.jsx(kr,{dataKey:"killsPerHour",fill:"#44cc44",radius:[0,3,3,0]})]})})]}),n.length>0&&b.jsxs("div",{className:"chart-section",children:[b.jsx("h3",{className:"chart-title",children:"Total Damage (Session)"}),b.jsx(Es,{width:"100%",height:Math.max(200,n.length*28),children:b.jsxs(ib,{data:n,layout:"vertical",margin:{left:10,right:20,top:5,bottom:5},children:[b.jsx(jf,{strokeDasharray:"3 3",stroke:"#333"}),b.jsx(Nl,{type:"number",stroke:"#888",fontSize:11}),b.jsx(Pl,{type:"category",dataKey:"name",width:130,stroke:"#888",fontSize:11}),b.jsx(vn,{contentStyle:{background:"#1a1a1a",border:"1px solid #444",fontSize:12},formatter:l=>[l.toLocaleString(),"Damage"],labelFormatter:(l,u)=>{var c,f;return((f=(c=u==null?void 0:u[0])==null?void 0:c.payload)==null?void 0:f.fullName)||l}}),b.jsx(kr,{dataKey:"damage",fill:"#ff6644",radius:[0,3,3,0]})]})})]}),r.length>0&&b.jsxs("div",{className:"chart-section",children:[b.jsx("h3",{className:"chart-title",children:"Damage by Element (All Characters)"}),b.jsx(Es,{width:"100%",height:300,children:b.jsxs(YY,{children:[b.jsx(Lr,{data:r,dataKey:"value",nameKey:"name",cx:"50%",cy:"50%",outerRadius:100,label:({name:l,percent:u})=>`${l} ${(u*100).toFixed(0)}%`,labelLine:!0,fontSize:12,children:r.map(l=>b.jsx(Hf,{fill:XY[l.name]||"#888"},l.name))}),b.jsx(vn,{contentStyle:{background:"#1a1a1a",border:"1px solid #444",fontSize:12},formatter:l=>l.toLocaleString()}),b.jsx(Qa,{wrapperStyle:{fontSize:12,color:"#aaa"}})]})})]})]})},VY=({characters:e,totalRares:t,totalKills:n,recentRares:r})=>{const l=B.useMemo(()=>Array.from(e.values()).filter(c=>c.telemetry&&(c.telemetry.total_rares??0)>0).map(c=>({name:c.name.length>18?c.name.slice(0,16)+"..":c.name,fullName:c.name,rares:c.telemetry.total_rares??0})).sort((c,f)=>f.rares-c.rares),[e]),u=t>0?Math.round(n/t):0;return b.jsxs("div",{className:"rares-tab",children:[b.jsxs("div",{className:"rares-summary",children:[b.jsxs("div",{className:"rare-stat-card",children:[b.jsx("span",{className:"rare-stat-value",children:t}),b.jsx("span",{className:"rare-stat-label",children:"Total Rares Found"})]}),b.jsxs("div",{className:"rare-stat-card",children:[b.jsx("span",{className:"rare-stat-value",children:n.toLocaleString()}),b.jsx("span",{className:"rare-stat-label",children:"Total Kills"})]}),b.jsxs("div",{className:"rare-stat-card",children:[b.jsx("span",{className:"rare-stat-value",children:u>0?`1 in ${u.toLocaleString()}`:"--"}),b.jsx("span",{className:"rare-stat-label",children:"Drop Rate"})]})]}),r.length>0&&b.jsxs("div",{className:"chart-section",children:[b.jsx("h3",{className:"chart-title",children:"Recent Rare Drops (This Session)"}),b.jsx("div",{className:"rare-timeline",children:r.map((c,f)=>b.jsxs("div",{className:"rare-event",children:[b.jsx("span",{className:"rare-time",children:new Date(c.timestamp).toLocaleTimeString()}),b.jsx("span",{className:"rare-char",children:c.character_name}),b.jsx("span",{className:"rare-name",children:c.name})]},f))})]}),l.length>0&&b.jsxs("div",{className:"chart-section",children:[b.jsx("h3",{className:"chart-title",children:"Rares per Character (Lifetime)"}),b.jsx(Es,{width:"100%",height:Math.max(200,l.length*28),children:b.jsxs(ib,{data:l,layout:"vertical",margin:{left:10,right:20,top:5,bottom:5},children:[b.jsx(jf,{strokeDasharray:"3 3",stroke:"#333"}),b.jsx(Nl,{type:"number",stroke:"#888",fontSize:11}),b.jsx(Pl,{type:"category",dataKey:"name",width:130,stroke:"#888",fontSize:11}),b.jsx(vn,{contentStyle:{background:"#1a1a1a",border:"1px solid #444",fontSize:12},formatter:c=>[c,"Rares"],labelFormatter:(c,f)=>{var d,h;return((h=(d=f==null?void 0:f[0])==null?void 0:d.payload)==null?void 0:h.fullName)||c}}),b.jsx(kr,{dataKey:"rares",fill:"#ffcc00",radius:[0,3,3,0]})]})})]})]})},Qi={west:-102.1,east:102.1,north:102.1,south:-102.1},Cf=800;function FY(e,t){const n=(e-Qi.west)/(Qi.east-Qi.west)*Cf,r=(Qi.north-t)/(Qi.north-Qi.south)*Cf;return{x:n,y:r}}const WY=({characters:e})=>{const t=B.useRef(null),[n,r]=B.useState(null),l=B.useMemo(()=>Array.from(e.values()).filter(c=>c.telemetry&&c.telemetry.ew!==void 0).map(c=>{const f=c.telemetry,{x:d,y:h}=FY(f.ew,f.ns),y=(f.vt_state||"").toLowerCase()==="combat"||(f.vt_state||"").toLowerCase()==="hunt";return{name:c.name,x:d,y:h,isHunting:y,ns:f.ns,ew:f.ew}}),[e]),u=B.useCallback(c=>r(c),[]);return b.jsxs("div",{className:"map-tab",children:[b.jsxs("div",{className:"map-container",ref:t,children:[b.jsx("img",{src:"/dereth_highres.png",alt:"Dereth Map",className:"map-image",draggable:!1}),b.jsx("svg",{className:"map-overlay",viewBox:`0 0 ${Cf} ${Cf}`,children:l.map(c=>{var f,d;return b.jsxs("g",{children:[b.jsx("circle",{cx:c.x,cy:c.y,r:n===c.name?6:4,fill:c.isHunting?"#44cc44":"#ffaa00",stroke:"#000",strokeWidth:1,opacity:.9,onMouseEnter:()=>u(c.name),onMouseLeave:()=>u(null),style:{cursor:"pointer"}}),n===c.name&&b.jsxs("text",{x:c.x+8,y:c.y+4,fill:"#fff",fontSize:11,stroke:"#000",strokeWidth:.3,paintOrder:"stroke",children:[c.name," (",(f=c.ns)==null?void 0:f.toFixed(1),"N, ",(d=c.ew)==null?void 0:d.toFixed(1),"E)"]})]},c.name)})})]}),b.jsxs("div",{className:"map-legend",children:[b.jsxs("span",{children:[b.jsx("span",{className:"legend-dot hunting"})," Hunting/Combat"]}),b.jsxs("span",{children:[b.jsx("span",{className:"legend-dot other"})," Other state"]}),b.jsxs("span",{className:"map-count",children:[l.length," characters on map"]})]})]})},ZY="/api";async function Ht(e){const t=await fetch(`${ZY}${e}`,{credentials:"include"});if(!t.ok)throw new Error(`API ${e}: ${t.status}`);return t.json()}function QY(){return`${location.protocol==="https:"?"wss:":"ws:"}//${location.host}/api/ws/live`}const JY=()=>{const[e,t]=B.useState(""),[n,r]=B.useState([]),[l,u]=B.useState(0),[c,f]=B.useState(!1),d=B.useRef(0),h=B.useCallback(async v=>{if(v.length<2){r([]),u(0);return}f(!0);try{const g=await Ht(`/search/items?q=${encodeURIComponent(v)}&limit=100`);r(g.results??[]),u(g.total??0)}catch{r([])}f(!1)},[]),y=B.useCallback(v=>{const g=v.target.value;t(g),clearTimeout(d.current),d.current=window.setTimeout(()=>h(g),400)},[h]);return b.jsxs("div",{className:"inventory-tab",children:[b.jsxs("div",{className:"search-bar",children:[b.jsx("input",{type:"text",value:e,onChange:y,placeholder:"Search items across all characters...",className:"search-input"}),c&&b.jsx("span",{className:"search-spinner",children:"Searching..."})]}),l>0&&b.jsxs("div",{className:"search-count",children:[l.toLocaleString()," results"]}),b.jsxs("div",{className:"search-results",children:[n.length===0&&e.length>=2&&!c&&b.jsx("div",{className:"search-empty",children:"No items found"}),b.jsxs("table",{className:"results-table",children:[b.jsx("thead",{children:b.jsxs("tr",{children:[b.jsx("th",{children:"Character"}),b.jsx("th",{children:"Item"}),b.jsx("th",{children:"Type"}),b.jsx("th",{children:"Material"}),b.jsx("th",{children:"Set"}),b.jsx("th",{children:"Work"})]})}),b.jsx("tbody",{children:n.map((v,g)=>b.jsxs("tr",{children:[b.jsx("td",{children:v.character_name}),b.jsx("td",{className:"item-name",children:v.item_name}),b.jsx("td",{children:v.type||""}),b.jsx("td",{children:v.material||""}),b.jsx("td",{children:v.set_name||""}),b.jsx("td",{children:v.workmanship||""})]},g))})]})]})]})},eX=20,tX=.3;function nX(e,t){switch(t.type){case"SET":return{scale:t.scale,offX:t.offX,offY:t.offY};case"ZOOM":{const n=Math.min(eX,Math.max(tX,e.scale*t.factor)),r=n/e.scale;return{scale:n,offX:t.cx-(t.cx-e.offX)*r,offY:t.cy-(t.cy-e.offY)*r}}case"PAN":return{...e,offX:e.offX+t.dx,offY:e.offY+t.dy};default:return e}}const BR=B.createContext({transform:{scale:1,offX:0,offY:0},dispatch:()=>{}}),rX=({children:e})=>{const[t,n]=B.useReducer(nX,{scale:1,offX:0,offY:0});return b.jsx(BR.Provider,{value:{transform:t,dispatch:n},children:e})},aX=()=>B.useContext(BR),LR=B.createContext({windows:[],openWindow:()=>{},closeWindow:()=>{},bringToFront:()=>{}}),iX=({children:e})=>{const[t,n]=B.useState([]),r=B.useRef(1e4),l=B.useCallback((f,d,h)=>{n(y=>y.find(g=>g.id===f)?y.map(g=>g.id===f?{...g,zIndex:++r.current}:g):[...y,{id:f,title:d,charName:h,zIndex:++r.current}])},[]),u=B.useCallback(f=>{n(d=>d.filter(h=>h.id!==f))},[]),c=B.useCallback(f=>{n(d=>d.map(h=>h.id===f?{...h,zIndex:++r.current}:h))},[]);return b.jsx(LR.Provider,{value:{windows:t,openWindow:l,closeWindow:u,bringToFront:c},children:e})},vd=()=>B.useContext(LR),Nn={west:-102.1,east:102.1,north:102.1,south:-102.1};function yd(e,t,n,r){const l=(e-Nn.west)/(Nn.east-Nn.west)*n,u=(Nn.north-t)/(Nn.north-Nn.south)*r;return{x:l,y:u}}function lX(e,t,n,r,l,u,c){const f=(e-r)/n,d=(t-l)/n,h=Nn.west+f/u*(Nn.east-Nn.west),y=Nn.north-d/c*(Nn.north-Nn.south);return{ew:h,ns:y}}function lb(e,t){const n=e>=0?"N":"S",r=t>=0?"E":"W";return`${Math.abs(e).toFixed(1)}${n}, ${Math.abs(t).toFixed(1)}${r}`}const IR=I.memo(({players:e,imgW:t,imgH:n,getColor:r,onHover:l,onSelect:u})=>{const c=B.useMemo(()=>e.filter(f=>f.ew!==void 0&&f.ns!==void 0).map(f=>({...f,pos:yd(f.ew,f.ns,t,n),color:r(f.character_name)})),[e,t,n,r]);return b.jsx("div",{className:"ml-dots-layer",children:c.map(f=>b.jsx("div",{className:"ml-dot",style:{left:f.pos.x,top:f.pos.y,backgroundColor:f.color},onMouseEnter:d=>{var y;const h=(y=d.currentTarget.closest(".ml-map-container"))==null?void 0:y.getBoundingClientRect();h&&l(f,d.clientX-h.left,d.clientY-h.top)},onMouseLeave:()=>l(null,0,0),onClick:()=>u(f.character_name)},f.character_name))})});IR.displayName="PlayerDots";const UR=I.memo(({imgW:e,imgH:t,getColor:n})=>{const[r,l]=B.useState([]);B.useEffect(()=>{const c=async()=>{try{const d=await Ht("/trails/?seconds=600");l(d.trails??[])}catch{}};c();const f=setInterval(c,2e3);return()=>clearInterval(f)},[]);const u=B.useMemo(()=>{const c={};for(const f of r){const{x:d,y:h}=yd(f.ew,f.ns,e,t);c[f.character_name]||(c[f.character_name]=[]),c[f.character_name].push(`${d},${h}`)}return Object.entries(c).filter(([,f])=>f.length>=2).map(([f,d])=>({name:f,points:d.join(" ")}))},[r,e,t]);return b.jsx("svg",{className:"ml-trails-svg",viewBox:`0 0 ${e} ${t}`,preserveAspectRatio:"none",children:u.map(c=>b.jsx("polyline",{points:c.points,stroke:n(c.name),fill:"none",strokeWidth:2,strokeOpacity:.7,strokeLinecap:"round",strokeLinejoin:"round"},c.name))})});UR.displayName="TrailsSVG";const oX=({imgW:e,imgH:t,enabled:n})=>{const r=B.useRef(null),[l,u]=B.useState([]);return B.useEffect(()=>{if(!n)return;(async()=>{try{const f=await Ht("/spawns/heatmap?hours=24&limit=50000");u(f.spawn_points??[])}catch{}})()},[n]),B.useEffect(()=>{const c=r.current;if(!c||!n||l.length===0||e===0)return;c.width=e,c.height=t;const f=c.getContext("2d");if(f){f.clearRect(0,0,e,t);for(const d of l){const{x:h,y}=yd(d.ew,d.ns,e,t),v=Math.max(5,Math.min(12,5+Math.sqrt(d.intensity*.5))),g=f.createRadialGradient(h,y,0,h,y,v);g.addColorStop(0,`rgba(255, 0, 0, ${Math.min(.9,d.intensity/40)})`),g.addColorStop(.6,`rgba(255, 100, 0, ${Math.min(.4,d.intensity/120)})`),g.addColorStop(1,"rgba(255, 150, 0, 0)"),f.fillStyle=g,f.fillRect(h-v,y-v,v*2,v*2)}}},[l,e,t,n]),n?b.jsx("canvas",{ref:r,className:"ml-heatmap-canvas"}):null},uX=({imgW:e,imgH:t,enabled:n})=>{const[r,l]=B.useState([]);B.useEffect(()=>{if(!n)return;const c=async()=>{try{const d=await Ht("/portals");l(d.portals??[])}catch{}};c();const f=setInterval(c,6e4);return()=>clearInterval(f)},[n]);const u=B.useMemo(()=>r.map(c=>({...c,pos:yd(c.coordinates.ew,c.coordinates.ns,e,t)})),[r,e,t]);return!n||u.length===0?null:b.jsx("div",{className:"ml-portals-layer",children:u.map((c,f)=>b.jsx("div",{className:"ml-portal-icon",style:{left:c.pos.x,top:c.pos.y},title:`${c.portal_name} (by ${c.discovered_by})`},f))})},cX=({players:e,getColor:t,onSelectPlayer:n,showHeatmap:r,showPortals:l})=>{var M;const u=B.useRef(null),{transform:c,dispatch:f}=aX(),[d,h]=B.useState({w:0,h:0}),[y,v]=B.useState(null),[g,x]=B.useState(null),j=B.useRef({dragging:!1,sx:0,sy:0,startOffX:0,startOffY:0}),S=B.useCallback(N=>{const A=N.currentTarget;if(h({w:A.naturalWidth,h:A.naturalHeight}),u.current){const T=u.current.clientWidth,C=u.current.clientHeight,D=Math.min(T/A.naturalWidth,C/A.naturalHeight);f({type:"SET",scale:D,offX:(T-A.naturalWidth*D)/2,offY:(C-A.naturalHeight*D)/2})}},[f]),_=B.useCallback(N=>{var C;N.preventDefault();const A=(C=u.current)==null?void 0:C.getBoundingClientRect();if(!A)return;const T=N.deltaY<0?1.1:.9;f({type:"ZOOM",factor:T,cx:N.clientX-A.left,cy:N.clientY-A.top})},[f]),E=B.useCallback(N=>{N.button===0&&(j.current={dragging:!0,sx:N.clientX,sy:N.clientY,startOffX:c.offX,startOffY:c.offY})},[c.offX,c.offY]);B.useEffect(()=>{const N=T=>{const C=j.current;if(C.dragging&&f({type:"SET",scale:c.scale,offX:C.startOffX+(T.clientX-C.sx),offY:C.startOffY+(T.clientY-C.sy)}),u.current&&d.w>0){const D=u.current.getBoundingClientRect(),z=lX(T.clientX-D.left,T.clientY-D.top,c.scale,c.offX,c.offY,d.w,d.h);x(z)}},A=()=>{j.current.dragging=!1};return window.addEventListener("mousemove",N),window.addEventListener("mouseup",A),()=>{window.removeEventListener("mousemove",N),window.removeEventListener("mouseup",A)}},[f,c.scale,c.offX,c.offY,d.w,d.h]);const w=B.useCallback((N,A,T)=>{v(N?{x:A,y:T,player:N}:null)},[]);return b.jsxs("div",{className:"ml-map-container",ref:u,onWheel:_,onMouseDown:E,children:[b.jsxs("div",{className:"ml-map-group",style:{transform:`translate(${c.offX}px, ${c.offY}px) scale(${c.scale})`},children:[b.jsx("img",{src:"/dereth.png",alt:"Dereth",className:"ml-map-img",onLoad:S,draggable:!1}),d.w>0&&b.jsxs(b.Fragment,{children:[b.jsx(oX,{imgW:d.w,imgH:d.h,enabled:r}),b.jsx(UR,{imgW:d.w,imgH:d.h,getColor:t}),b.jsx(IR,{players:e,imgW:d.w,imgH:d.h,getColor:t,onHover:w,onSelect:n}),b.jsx(uX,{imgW:d.w,imgH:d.h,enabled:l})]})]}),y&&b.jsxs("div",{className:"ml-tooltip",style:{left:y.x+12,top:y.y-10},children:[b.jsx("strong",{children:y.player.character_name}),b.jsx("br",{}),lb(y.player.ns,y.player.ew),b.jsx("br",{}),y.player.kills_per_hour," kph ยท ",(M=y.player.kills)==null?void 0:M.toLocaleString()," kills"]}),g&&b.jsx("div",{className:"ml-coords",children:lb(g.ns,g.ew)})]})},HR=I.memo(({player:e,vitals:t,color:n,onSelect:r})=>{var h,y;const{openWindow:l}=vd(),u=(e.vt_state||"idle").toLowerCase(),c=u==="combat"||u==="hunt",f=(e.total_rares??0)>0?Math.round((e.total_kills??0)/(e.total_rares??1)).toLocaleString():null,d=e.character_name;return b.jsxs("li",{className:"ml-player-row",style:{borderLeftColor:n},children:[b.jsxs("div",{className:"ml-pr-header",onClick:r,children:[b.jsx("span",{className:"ml-pr-name",children:d}),b.jsx("span",{className:"ml-pr-coords",children:lb(e.ns,e.ew)})]}),b.jsxs("div",{className:"ml-pr-vitals",children:[b.jsx("div",{className:"ml-vital-bar hp",children:b.jsx("div",{className:"ml-vital-fill",style:{width:`${(t==null?void 0:t.health_percentage)??0}%`}})}),b.jsx("div",{className:"ml-vital-bar sta",children:b.jsx("div",{className:"ml-vital-fill",style:{width:`${(t==null?void 0:t.stamina_percentage)??0}%`}})}),b.jsx("div",{className:"ml-vital-bar mana",children:b.jsx("div",{className:"ml-vital-fill",style:{width:`${(t==null?void 0:t.mana_percentage)??0}%`}})})]}),b.jsxs("div",{className:"ml-pr-grid",children:[b.jsxs("span",{className:"ml-gs",title:"Session kills",children:["โš”๏ธ ",((h=e.kills)==null?void 0:h.toLocaleString())??0]}),b.jsxs("span",{className:"ml-gs",title:"Total kills",children:["๐Ÿ† ",(e.total_kills??0).toLocaleString()]}),b.jsxs("span",{className:"ml-gs",title:"Kills per hour",children:[e.kills_per_hour??"0"," ",b.jsx("span",{className:"ml-suffix",children:"KPH"})]}),b.jsxs("span",{className:"ml-gs",title:"Rares (session / total)",children:["๐Ÿ’Ž ",e.session_rares??0," / ",e.total_rares??0]}),b.jsx("span",{className:"ml-gs",title:"Kills per rare",children:f?b.jsxs(b.Fragment,{children:["๐Ÿ“Š ",f," ",b.jsx("span",{className:"ml-suffix",children:"KPR"})]}):""}),b.jsx("span",{className:`ml-meta-pill ${c?"active":""}`,children:e.vt_state||"idle"}),b.jsxs("span",{className:"ml-gs",title:"Online time",children:["๐Ÿ• ",((y=e.onlinetime)==null?void 0:y.replace(/^00\./,""))??"--"]}),b.jsxs("span",{className:"ml-gs",title:"Deaths",children:["โ˜ ๏ธ ",e.deaths??"0"]}),b.jsxs("span",{className:"ml-gs",title:"Prismatic tapers",children:[b.jsx("img",{src:"/prismatic-taper-icon.png",className:"ml-taper-icon",alt:""}),e.prismatic_taper_count??"0"]})]}),b.jsxs("div",{className:"ml-pr-buttons",children:[b.jsx("button",{className:"ml-btn accent",onClick:()=>l(`chat-${d}`,`Chat: ${d}`,d),children:"Chat"}),b.jsx("button",{className:"ml-btn accent",onClick:()=>l(`stats-${d}`,`Stats: ${d}`,d),children:"Stats"}),b.jsx("button",{className:"ml-btn accent",onClick:()=>l(`inv-${d}`,`Inventory: ${d}`,d),children:"Inv"}),b.jsx("button",{className:"ml-btn",onClick:()=>l(`char-${d}`,`Character: ${d}`,d),children:"Char"}),b.jsx("button",{className:"ml-btn",onClick:()=>l(`combat-${d}`,`Combat: ${d}`,d),children:"Combat"}),b.jsx("button",{className:"ml-btn",onClick:()=>l(`radar-${d}`,`Radar: ${d}`,d),children:"Radar"})]})]})});HR.displayName="PlayerRow";const sX=({players:e,vitals:t,getColor:n,onSelect:r})=>b.jsx("ul",{className:"ml-player-list",children:e.map(l=>b.jsx(HR,{player:l,vitals:t.get(l.character_name)??null,color:n(l.character_name),onSelect:()=>r(l.character_name)},l.character_name))}),fX=[{key:"name",label:"Name"},{key:"kph",label:"KPH"},{key:"skills",label:"S.Kills"},{key:"srares",label:"S.Rares"},{key:"tkills",label:"T.Kills"},{key:"kpr",label:"KPR"}],dX=({value:e,onChange:t})=>b.jsx("div",{className:"ml-sort-buttons",children:fX.map(n=>b.jsx("button",{className:`ml-sort-btn ${e===n.key?"active":""}`,onClick:()=>t(n.key),children:n.label},n.key))}),hX=()=>{const{openWindow:e}=vd();return b.jsxs("div",{className:"ml-tool-links",children:[b.jsx("span",{className:"ml-tool-link",style:{cursor:"pointer"},onClick:()=>e("issues","Issues Board"),children:"๐Ÿ“‹ Issues"}),b.jsx("span",{className:"ml-tool-link",style:{cursor:"pointer"},onClick:()=>e("vitalsharing","Vital Sharing"),children:"๐Ÿค Vitals"})]})},pX=({players:e,vitals:t,serverHealth:n,totalRares:r,totalKills:l,getColor:u,onSelectPlayer:c,onViewToggle:f,showHeatmap:d,showPortals:h,onToggleHeatmap:y,onTogglePortals:v})=>{var M,N;const[g,x]=B.useState("name"),[j,S]=B.useState(""),_=B.useMemo(()=>e.reduce((A,T)=>A+(parseInt(T.kills_per_hour)||0),0),[e]),E=((M=n==null?void 0:n.status)==null?void 0:M.toLowerCase())==="online"||((N=n==null?void 0:n.status)==null?void 0:N.toLowerCase())==="up",w=B.useMemo(()=>{let A=[...e];switch(j&&(A=A.filter(T=>T.character_name.toLowerCase().startsWith(j.toLowerCase()))),g){case"kph":A.sort((T,C)=>(parseInt(C.kills_per_hour)||0)-(parseInt(T.kills_per_hour)||0));break;case"skills":A.sort((T,C)=>(C.kills||0)-(T.kills||0));break;case"srares":A.sort((T,C)=>(C.session_rares??0)-(T.session_rares??0));break;case"tkills":A.sort((T,C)=>(C.total_kills??0)-(T.total_kills??0));break;case"kpr":A.sort((T,C)=>{const D=(T.total_kills??0)/Math.max(1,T.total_rares??1),z=(C.total_kills??0)/Math.max(1,C.total_rares??1);return D-z});break;default:A.sort((T,C)=>T.character_name.localeCompare(C.character_name))}return A},[e,g,j]);return b.jsxs("div",{className:"ml-sidebar",children:[b.jsxs("div",{className:"ml-sidebar-header",children:[b.jsxs("span",{className:"ml-sidebar-title",children:["Active Mosswart Enjoyers (",e.length,")"]}),b.jsx("button",{className:"ml-view-toggle",onClick:f,children:"Dashboard"})]}),b.jsxs("div",{className:"ml-server-status",children:[b.jsx("span",{className:`ml-status-dot ${E?"online":"offline"}`}),b.jsxs("span",{className:"ml-status-text",children:["Coldeve ",E?"Online":"Offline"]}),(n==null?void 0:n.player_count)!=null&&b.jsxs("span",{className:"ml-status-detail",children:["๐Ÿ‘ฅ ",n.player_count]}),(n==null?void 0:n.latency_ms)!=null&&b.jsxs("span",{className:"ml-status-detail",children:[Math.round(n.latency_ms),"ms"]}),(n==null?void 0:n.uptime_seconds)!=null&&b.jsxs("span",{className:"ml-status-detail",children:["Up: ",Math.floor(n.uptime_seconds/3600),"h"]})]}),b.jsxs("div",{className:"ml-counters",children:[b.jsxs("div",{className:"ml-counter rares",children:[b.jsx("span",{className:"ml-counter-val",children:r}),b.jsx("span",{className:"ml-counter-lbl",children:"Rares"})]}),b.jsxs("div",{className:`ml-counter kph ${_>5e3?"ultra":""}`,children:[b.jsx("span",{className:"ml-counter-val",children:_.toLocaleString()}),b.jsx("span",{className:"ml-counter-lbl",children:"Server KPH"})]}),b.jsxs("div",{className:"ml-counter kills",children:[b.jsx("span",{className:"ml-counter-val",children:l.toLocaleString()}),b.jsx("span",{className:"ml-counter-lbl",children:"Kills"})]})]}),b.jsxs("div",{className:"ml-tool-links",children:[b.jsx("a",{href:"/inventory.html",className:"ml-tool-link",children:"๐Ÿ” Inv Search"}),b.jsx("a",{href:"/suitbuilder.html",className:"ml-tool-link",children:"๐Ÿ›ก๏ธ Suitbuilder"}),b.jsx("a",{href:"/debug.html",className:"ml-tool-link",children:"๐Ÿ› Debug"}),b.jsx("a",{href:"/quest-status.html",target:"_blank",className:"ml-tool-link",children:"๐Ÿ“œ Quests"})]}),b.jsx(hX,{}),b.jsxs("div",{className:"ml-toggles",children:[b.jsxs("label",{className:"ml-toggle-label",children:[b.jsx("input",{type:"checkbox",checked:d,onChange:A=>y(A.target.checked)}),b.jsx("span",{children:"Spawn Heatmap"})]}),b.jsxs("label",{className:"ml-toggle-label",children:[b.jsx("input",{type:"checkbox",checked:h,onChange:A=>v(A.target.checked)}),b.jsx("span",{children:"Portals"})]})]}),b.jsx(dX,{value:g,onChange:x}),b.jsx("input",{className:"ml-filter",type:"text",placeholder:"Filter players...",value:j,onChange:A=>S(A.target.value)}),b.jsx(sX,{players:w,vitals:t,getColor:u,onSelect:c})]})},$r=({id:e,title:t,zIndex:n,width:r=700,height:l=340,children:u})=>{const{closeWindow:c,bringToFront:f}=vd(),d=B.useRef(null),h=B.useRef({dragging:!1,sx:0,sy:0,ox:0,oy:0}),y=B.useRef({x:420,y:10+Math.random()*40}),v=B.useCallback(g=>{var j;g.preventDefault(),f(e);const x=(j=d.current)==null?void 0:j.getBoundingClientRect();x&&(h.current={dragging:!0,sx:g.clientX,sy:g.clientY,ox:x.left,oy:x.top})},[e,f]);return B.useEffect(()=>{const g=j=>{const S=h.current;!S.dragging||!d.current||(y.current.x=S.ox+(j.clientX-S.sx),y.current.y=S.oy+(j.clientY-S.sy),d.current.style.left=`${y.current.x}px`,d.current.style.top=`${y.current.y}px`)},x=()=>{h.current.dragging=!1};return window.addEventListener("mousemove",g),window.addEventListener("mouseup",x),()=>{window.removeEventListener("mousemove",g),window.removeEventListener("mouseup",x)}},[]),b.jsxs("div",{ref:d,className:"ml-window",style:{zIndex:n,width:r,height:l,left:y.current.x,top:y.current.y},onMouseDown:()=>f(e),children:[b.jsxs("div",{className:"ml-window-header",onMouseDown:v,children:[b.jsx("span",{className:"ml-window-title",children:t}),b.jsx("button",{className:"ml-window-close",onClick:()=>c(e),children:"ร—"})]}),b.jsx("div",{className:"ml-window-content",children:u})]})},vX={0:"#00FF00",2:"#FFFFFF",3:"#FF0000",4:"#FFFFFF",5:"#33CCFF",6:"#CCFF99",7:"#00FFFF",14:"#FFD700",15:"#FF69B4",17:"#AAAAFF",18:"#88FF88",21:"#FF8888",22:"#FFAA66"},yX=({id:e,charName:t,zIndex:n,messages:r,socket:l})=>{const u=B.useRef(null),[c,f]=B.useState("");B.useEffect(()=>{u.current&&(u.current.scrollTop=u.current.scrollHeight)},[r.length]);const d=h=>{h.preventDefault();const y=c.trim();!y||!l||l.readyState!==WebSocket.OPEN||(l.send(JSON.stringify({player_name:t,command:y})),f(""))};return b.jsxs($r,{id:e,title:`Chat: ${t}`,zIndex:n,width:600,height:300,children:[b.jsx("div",{className:"ml-chat-messages",ref:u,children:r.map((h,y)=>b.jsx("div",{className:"ml-chat-line",style:{color:vX[h.color??2]??"#ddd"},children:h.text},y))}),b.jsx("form",{className:"ml-chat-form",onSubmit:d,children:b.jsx("input",{className:"ml-chat-input",value:c,onChange:h=>f(h.target.value),placeholder:"Enter chat..."})})]})},mX=[{title:"Kills per Hour",id:1},{title:"Memory (MB)",id:2},{title:"CPU (%)",id:3},{title:"Mem Handles",id:4}],gX=[{label:"1H",value:"now-1h"},{label:"6H",value:"now-6h"},{label:"24H",value:"now-24h"},{label:"7D",value:"now-7d"}],bX=({id:e,charName:t,zIndex:n})=>{const[r,l]=B.useState("now-24h"),u=c=>`/grafana/d-solo/dereth-tracker/dereth-tracker-dashboard?panelId=${c}&var-character=${encodeURIComponent(t)}&from=${r}&to=now&theme=light`;return b.jsxs($r,{id:e,title:`Stats: ${t}`,zIndex:n,width:750,height:480,children:[b.jsx("div",{className:"ml-stats-controls",children:gX.map(c=>b.jsx("button",{className:`ml-stats-range-btn ${r===c.value?"active":""}`,onClick:()=>l(c.value),children:c.label},c.value))}),b.jsx("div",{className:"ml-stats-grid",children:mX.map(c=>b.jsx("div",{className:"ml-stats-panel",children:b.jsx("iframe",{src:u(c.id),width:"100%",height:"100%",frameBorder:"0",title:c.title})},c.id))})]})},dM={369:"Blade Turner",370:"Arrow Turner",371:"Mace Turner",372:"Caustic Enhancement",373:"Fiery Enhancement",374:"Icy Enhancement",375:"Lightning Enhancement",376:"Critical Protection",377:"Frenzy",362:"Iron Skin",363:"Eye of the Remorseless",364:"Hand of the Remorseless",365:"Ciandra's Essence",366:"Yoshi's Essence",367:"Jibril's Essence",368:"Celdiseth's Essence"},hM={378:"Valor",379:"Protection",380:"Glory",381:"Temperance",382:"Aetheric Vision",383:"Mana Flow",384:"Mana Infusion",385:"Purity",386:"Craftsman",387:"Specialization",388:"World"},pM={354:"Damage Rating",355:"Damage Resist Rating",356:"Crit Rating",357:"Crit Resist Rating",358:"Crit Damage Rating",359:"Crit Damage Resist Rating",360:"Heal Boost Rating",361:"Vitality Rating"},Hn="#af7a30",js="#000022",xX=({id:e,charName:t,zIndex:n,vitals:r})=>{var U,V,L,G;const[l,u]=B.useState(null),[c,f]=B.useState(0),[d,h]=B.useState(0);B.useEffect(()=>{Ht(`/character-stats/${encodeURIComponent(t)}`).then(u).catch(()=>{})},[t]);const y=P=>P!=null?Number(P).toLocaleString():"โ€”",v=(l==null?void 0:l.stats_data)||l||{},g=v.attributes||{},x=v.skills||{},j=v.vitals||{},S=v.titles||[],_=v.properties||{},E=Object.entries(x).filter(([,P])=>(P==null?void 0:P.training)==="Specialized").sort(([P],[$])=>P.localeCompare($)),w=Object.entries(x).filter(([,P])=>(P==null?void 0:P.training)==="Trained").sort(([P],[$])=>P.localeCompare($)),M=Object.entries(_).filter(([P,$])=>dM[parseInt(P)]&&Number($)>0).map(([P,$])=>({name:dM[parseInt(P)],uses:Number($)})),N=Object.entries(_).filter(([P,$])=>hM[parseInt(P)]&&Number($)>0).map(([P,$])=>({name:hM[parseInt(P)],uses:Number($)})),A=Object.entries(_).filter(([P,$])=>pM[parseInt(P)]&&Number($)>0).map(([P,$])=>({name:pM[parseInt(P)],value:Number($)})),T=P=>({padding:"5px 8px",fontSize:12,fontWeight:"bold",color:"#fff",cursor:"pointer",userSelect:"none",borderTop:`2px solid ${P?Hn:js}`,borderLeft:`2px solid ${P?Hn:js}`,borderRight:`2px solid ${P?Hn:js}`,background:P?"rgba(0,100,0,0.4)":"transparent"}),C={background:"#000",border:`2px solid ${Hn}`,maxHeight:400,overflowY:"auto",overflowX:"hidden"},D={background:"#222",fontWeight:"bold",fontSize:12,padding:"2px 6px"},z={padding:"2px 6px",background:"rgba(0,100,0,0.4)",whiteSpace:"nowrap"},F={padding:"2px 6px",background:"rgba(0,0,100,0.4)",textAlign:"right",whiteSpace:"nowrap"},X={padding:"2px 6px",color:"#ccc"};return b.jsx($r,{id:e,title:`Character: ${t}`,zIndex:n,width:740,height:600,children:b.jsxs("div",{style:{background:js,color:"#fff",font:'14px/1.5 -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif',overflowY:"auto",padding:"10px 15px 15px",flex:1},children:[b.jsxs("div",{style:{marginBottom:10},children:[b.jsxs("h1",{style:{margin:"0 0 2px",fontSize:28,fontWeight:"bold"},children:[t,b.jsx("span",{style:{fontSize:"200%",color:"#fff27f",float:"right"},children:(l==null?void 0:l.level)||""})]}),b.jsx("div",{style:{fontSize:"85%",color:"gold"},children:[l==null?void 0:l.gender,l==null?void 0:l.race].filter(Boolean).join(" ")||"Awaiting character data..."})]}),b.jsxs("div",{style:{fontSize:"85%",margin:"6px 0 10px",display:"grid",gridTemplateColumns:"1fr 1fr",gap:"0 20px"},children:[b.jsxs("div",{children:["Total XP: ",y(l==null?void 0:l.total_xp)]}),b.jsxs("div",{style:{textAlign:"right"},children:["Unassigned XP: ",y(l==null?void 0:l.unassigned_xp)]}),b.jsxs("div",{children:["Luminance: ",(l==null?void 0:l.luminance_earned)!=null?`${y(l.luminance_earned)} / ${y(l.luminance_total)}`:"โ€”"]}),b.jsxs("div",{style:{textAlign:"right"},children:["Deaths: ",y(l==null?void 0:l.deaths)]})]}),b.jsxs("div",{style:{display:"flex",gap:13,flexWrap:"wrap"},children:[b.jsxs("div",{style:{width:320},children:[b.jsx("div",{style:{height:30,display:"flex"},children:["Attributes","Skills","Titles"].map((P,$)=>b.jsx("div",{style:T(c===$),onClick:()=>f($),children:P},P))}),b.jsxs("div",{style:C,children:[c===0&&b.jsxs(b.Fragment,{children:[b.jsx("div",{style:{padding:"6px 8px",display:"flex",flexDirection:"column",gap:8,borderBottom:`2px solid ${Hn}`},children:[{label:"Health",pct:(r==null?void 0:r.health_percentage)??0,cur:r==null?void 0:r.health_current,max:r==null?void 0:r.health_max,bg:"#cc3333"},{label:"Stamina",pct:(r==null?void 0:r.stamina_percentage)??0,cur:r==null?void 0:r.stamina_current,max:r==null?void 0:r.stamina_max,bg:"#ccaa33"},{label:"Mana",pct:(r==null?void 0:r.mana_percentage)??0,cur:r==null?void 0:r.mana_current,max:r==null?void 0:r.mana_max,bg:"#3366cc"}].map(P=>b.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[b.jsx("span",{style:{width:55,fontSize:12,color:"#ccc"},children:P.label}),b.jsx("div",{style:{flex:1,height:14,overflow:"hidden",position:"relative",border:`1px solid ${Hn}`},children:b.jsx("div",{style:{height:"100%",width:`${P.pct}%`,background:P.bg,transition:"width 0.5s ease"}})}),b.jsxs("span",{style:{width:80,textAlign:"right",fontSize:12,color:"#ccc"},children:[P.cur??"โ€”"," / ",P.max??"โ€”"]})]},P.label))}),b.jsxs("table",{style:{width:"100%",fontSize:13,borderCollapse:"collapse"},children:[b.jsx("thead",{children:b.jsxs("tr",{children:[b.jsx("td",{style:D,children:"Attribute"}),b.jsx("td",{style:D,children:"Creation"}),b.jsx("td",{style:D,children:"Base"})]})}),b.jsx("tbody",{children:["strength","endurance","coordination","quickness","focus","self"].map(P=>{var $,W;return b.jsxs("tr",{children:[b.jsx("td",{style:z,children:P.charAt(0).toUpperCase()+P.slice(1)}),b.jsx("td",{style:X,children:(($=g[P])==null?void 0:$.creation)??"โ€”"}),b.jsx("td",{style:F,children:((W=g[P])==null?void 0:W.base)??"โ€”"})]},P)})})]}),b.jsxs("table",{style:{width:"100%",fontSize:13,borderCollapse:"collapse"},children:[b.jsx("thead",{children:b.jsxs("tr",{children:[b.jsx("td",{style:D,children:"Vital"}),b.jsx("td",{style:D,children:"Base"})]})}),b.jsx("tbody",{children:["health","stamina","mana"].map(P=>{var $;return b.jsxs("tr",{children:[b.jsx("td",{style:z,children:P.charAt(0).toUpperCase()+P.slice(1)}),b.jsx("td",{style:F,children:(($=j[P])==null?void 0:$.base)??"โ€”"})]},P)})})]}),b.jsx("table",{style:{width:"100%",fontSize:13,borderCollapse:"collapse"},children:b.jsx("tbody",{children:b.jsxs("tr",{children:[b.jsx("td",{style:z,children:"Skill Credits"}),b.jsx("td",{style:F,children:y(v.skill_credits)})]})})})]}),c===1&&b.jsxs("table",{style:{width:"100%",fontSize:13,borderCollapse:"collapse"},children:[b.jsx("thead",{children:b.jsxs("tr",{children:[b.jsx("td",{style:D,children:"Skill"}),b.jsx("td",{style:D,children:"Level"})]})}),b.jsxs("tbody",{children:[E.map(([P,$])=>b.jsxs("tr",{children:[b.jsx("td",{style:{padding:"2px 6px",background:"linear-gradient(to right, #392067, #392067, black)"},children:P.replace(/_/g," ").replace(/\b\w/g,W=>W.toUpperCase())}),b.jsx("td",{style:{...F,background:"linear-gradient(to right, #392067, #392067, black)"},children:$.base})]},P)),w.map(([P,$])=>b.jsxs("tr",{children:[b.jsx("td",{style:{padding:"2px 6px",background:"linear-gradient(to right, #0f3c3e, #0f3c3e, black)"},children:P.replace(/_/g," ").replace(/\b\w/g,W=>W.toUpperCase())}),b.jsx("td",{style:{...F,background:"linear-gradient(to right, #0f3c3e, #0f3c3e, black)"},children:$.base})]},P)),E.length===0&&w.length===0&&b.jsx("tr",{children:b.jsx("td",{colSpan:2,style:{padding:10,color:"#666",fontStyle:"italic",textAlign:"center"},children:"No skill data"})})]})]}),c===2&&b.jsx("div",{style:{padding:"6px 10px",fontSize:13},children:S.length>0?S.map((P,$)=>b.jsx("div",{style:{padding:"1px 0"},children:P},$)):b.jsx("div",{style:{color:"#666",fontStyle:"italic",textAlign:"center",padding:10},children:"No titles"})})]})]}),b.jsxs("div",{style:{width:320},children:[b.jsx("div",{style:{height:30,display:"flex"},children:["Augmentations","Ratings","Other"].map((P,$)=>b.jsx("div",{style:T(d===$),onClick:()=>h($),children:P},P))}),b.jsxs("div",{style:C,children:[d===0&&(M.length||N.length?b.jsxs(b.Fragment,{children:[M.length>0&&b.jsxs(b.Fragment,{children:[b.jsx("div",{style:{background:"#222",padding:"4px 8px",fontWeight:"bold",fontSize:13,borderBottom:`1px solid ${Hn}`},children:"Augmentations"}),b.jsxs("table",{style:{width:"100%",fontSize:13,borderCollapse:"collapse"},children:[b.jsx("thead",{children:b.jsxs("tr",{children:[b.jsx("td",{style:D,children:"Name"}),b.jsx("td",{style:D,children:"Uses"})]})}),b.jsx("tbody",{children:M.map(P=>b.jsxs("tr",{children:[b.jsx("td",{style:{padding:"2px 6px"},children:P.name}),b.jsx("td",{style:{padding:"2px 6px",textAlign:"right"},children:P.uses})]},P.name))})]})]}),N.length>0&&b.jsxs(b.Fragment,{children:[b.jsx("div",{style:{background:"#222",padding:"4px 8px",fontWeight:"bold",fontSize:13,borderBottom:`1px solid ${Hn}`},children:"Auras"}),b.jsxs("table",{style:{width:"100%",fontSize:13,borderCollapse:"collapse"},children:[b.jsx("thead",{children:b.jsxs("tr",{children:[b.jsx("td",{style:D,children:"Name"}),b.jsx("td",{style:D,children:"Uses"})]})}),b.jsx("tbody",{children:N.map(P=>b.jsxs("tr",{children:[b.jsx("td",{style:{padding:"2px 6px"},children:P.name}),b.jsx("td",{style:{padding:"2px 6px",textAlign:"right"},children:P.uses})]},P.name))})]})]})]}):b.jsx("div",{style:{color:"#666",fontStyle:"italic",textAlign:"center",padding:10},children:"No augmentation data"})),d===1&&(A.length>0?b.jsxs("table",{style:{width:"100%",fontSize:13,borderCollapse:"collapse"},children:[b.jsx("thead",{children:b.jsxs("tr",{children:[b.jsx("td",{style:D,children:"Rating"}),b.jsx("td",{style:D,children:"Value"})]})}),b.jsx("tbody",{children:A.map(P=>b.jsxs("tr",{children:[b.jsx("td",{style:{padding:"2px 6px"},children:P.name}),b.jsx("td",{style:{padding:"2px 6px",textAlign:"right"},children:P.value})]},P.name))})]}):b.jsx("div",{style:{color:"#666",fontStyle:"italic",textAlign:"center",padding:10},children:"No rating data"})),d===2&&b.jsx("div",{style:{padding:6},children:l!=null&&l.allegiance?b.jsxs(b.Fragment,{children:[b.jsx("div",{style:{background:"#222",padding:"4px 8px",fontWeight:"bold",fontSize:13,borderBottom:`1px solid ${Hn}`},children:"Allegiance"}),b.jsx("table",{style:{width:"100%",fontSize:13,borderCollapse:"collapse"},children:b.jsxs("tbody",{children:[l.allegiance.name&&b.jsxs("tr",{children:[b.jsx("td",{style:{padding:"2px 6px",color:"#ccc",width:100},children:"Name"}),b.jsx("td",{style:{padding:"2px 6px"},children:l.allegiance.name})]}),((U=l.allegiance.monarch)==null?void 0:U.name)&&b.jsxs("tr",{children:[b.jsx("td",{style:{padding:"2px 6px",color:"#ccc"},children:"Monarch"}),b.jsx("td",{style:{padding:"2px 6px"},children:l.allegiance.monarch.name})]}),((V=l.allegiance.patron)==null?void 0:V.name)&&b.jsxs("tr",{children:[b.jsx("td",{style:{padding:"2px 6px",color:"#ccc"},children:"Patron"}),b.jsx("td",{style:{padding:"2px 6px"},children:l.allegiance.patron.name})]}),l.allegiance.rank!=null&&b.jsxs("tr",{children:[b.jsx("td",{style:{padding:"2px 6px",color:"#ccc"},children:"Rank"}),b.jsx("td",{style:{padding:"2px 6px"},children:l.allegiance.rank})]})]})})]}):b.jsx("div",{style:{color:"#666",fontStyle:"italic",textAlign:"center",padding:10},children:"No additional data"})})]})]})]}),(l==null?void 0:l.allegiance)&&b.jsxs("div",{style:{marginTop:5,border:`2px solid ${Hn}`,background:"#000"},children:[b.jsx("div",{style:{background:"#222",padding:"4px 8px",fontWeight:"bold",fontSize:13,borderBottom:`1px solid ${Hn}`},children:"Allegiance"}),b.jsx("table",{style:{width:"100%",fontSize:13,borderCollapse:"collapse"},children:b.jsxs("tbody",{children:[l.allegiance.name&&b.jsxs("tr",{children:[b.jsx("td",{style:{padding:"2px 6px",color:"#ccc",width:100},children:"Name"}),b.jsx("td",{style:{padding:"2px 6px"},children:l.allegiance.name})]}),((L=l.allegiance.monarch)==null?void 0:L.name)&&b.jsxs("tr",{children:[b.jsx("td",{style:{padding:"2px 6px",color:"#ccc"},children:"Monarch"}),b.jsx("td",{style:{padding:"2px 6px"},children:l.allegiance.monarch.name})]}),((G=l.allegiance.patron)==null?void 0:G.name)&&b.jsxs("tr",{children:[b.jsx("td",{style:{padding:"2px 6px",color:"#ccc"},children:"Patron"}),b.jsx("td",{style:{padding:"2px 6px"},children:l.allegiance.patron.name})]}),l.allegiance.rank!=null&&b.jsxs("tr",{children:[b.jsx("td",{style:{padding:"2px 6px",color:"#ccc"},children:"Rank"}),b.jsx("td",{style:{padding:"2px 6px"},children:l.allegiance.rank})]}),l.allegiance.followers!=null&&b.jsxs("tr",{children:[b.jsx("td",{style:{padding:"2px 6px",color:"#ccc"},children:"Followers"}),b.jsx("td",{style:{padding:"2px 6px"},children:l.allegiance.followers})]})]})})]})]})})};function _X(e){var r;if(!e)return e;const t=l=>l!=null&&l!==-1&&l!==-1?l:void 0,n=e.IntValues||{};return{item_id:e.item_id??e.Id??0,name:e.name??e.Name??((r=e.StringValues)==null?void 0:r["1"])??"Unknown",icon:e.icon??e.Icon??0,object_class:e.object_class??e.ObjectClass??0,current_wielded_location:e.current_wielded_location??t(e.CurrentWieldedLocation)??t(Number(n[10]))??0,container_id:e.container_id??e.ContainerId??0,items_capacity:e.items_capacity??t(e.ItemsCapacity)??t(Number(n[6]))??void 0,value:e.value??t(e.Value)??t(Number(n[19]))??0,burden:e.burden??t(e.Burden)??t(Number(n[5]))??0,armor_level:e.armor_level??t(e.ArmorLevel),max_damage:e.max_damage??t(e.MaxDamage),material:e.material??e.material_name??e.Material??void 0,item_set:e.item_set??e.ItemSet??void 0,imbue:e.imbue??e.Imbue??void 0,tinks:e.tinks??t(e.Tinks),workmanship:e.workmanship??t(e.Workmanship),equip_skill:e.equip_skill??e.equip_skill_name??e.EquipSkill??void 0,wield_level:e.wield_level??t(e.WieldLevel),skill_level:e.skill_level??t(e.SkillLevel),lore_requirement:e.lore_requirement??t(e.LoreRequirement),attack_bonus:e.attack_bonus??t(e.AttackBonus),melee_defense_bonus:e.melee_defense_bonus??t(e.MeleeDefenseBonus),magic_defense_bonus:e.magic_defense_bonus??t(e.MagicDBonus),damage_bonus:e.damage_bonus??t(e.DamageBonus),damage_rating:e.damage_rating??t(e.DamRating),crit_rating:e.crit_rating??t(e.CritRating),heal_boost_rating:e.heal_boost_rating??t(e.HealBoostRating),current_mana:e.current_mana??t(Number(n[218103815]))??void 0,max_mana:e.max_mana??t(Number(n[218103814]))??void 0,spellcraft:e.spellcraft??void 0,damage_range:e.damage_range??void 0,damage_type:e.damage_type??void 0,speed_text:e.speed_text??void 0,mana_display:e.mana_display??void 0,spells:e.spells??void 0,icon_overlay_id:e.icon_overlay_id??t(Number(n[218103849]))??void 0,icon_underlay_id:e.icon_underlay_id??t(Number(n[218103850]))??void 0,_raw:e}}function Cs(e){return!e||e<=0?"06000133":(e+100663296).toString(16).toUpperCase().padStart(8,"0")}const Ji={32768:{name:"Neck",row:1,col:1},1:{name:"Head",row:1,col:3},268435456:{name:"Sigil",row:1,col:5},536870912:{name:"Sigil",row:1,col:6},1073741824:{name:"Sigil",row:1,col:7},67108864:{name:"Trinket",row:2,col:1},2048:{name:"U.Arm",row:2,col:2},512:{name:"Chest",row:2,col:3},134217728:{name:"Cloak",row:2,col:7},65536:{name:"Brace L",row:3,col:1},4096:{name:"L.Arm",row:3,col:2},1024:{name:"Abdomen",row:3,col:3},8192:{name:"U.Leg",row:3,col:4},131072:{name:"Brace R",row:3,col:5},2:{name:"Shirt",row:3,col:7},262144:{name:"Ring L",row:4,col:1},32:{name:"Hands",row:4,col:2},16384:{name:"L.Leg",row:4,col:4},524288:{name:"Ring R",row:4,col:5},4:{name:"Pants",row:4,col:7},256:{name:"Feet",row:5,col:4},2097152:{name:"Shield",row:6,col:1},1048576:{name:"Melee",row:6,col:3},4194304:{name:"Missile",row:6,col:3},16777216:{name:"Held",row:6,col:3},33554432:{name:"2H",row:6,col:3},8388608:{name:"Ammo",row:6,col:7}},el={},SX=[32768,67108864,65536,131072,262144,524288],OX=[1,512,2048,1024,4096,8192,16384,32,256],AX=[2,4,134217728,268435456,536870912,1073741824],wX=[2097152,1048576,4194304,16777216,33554432,8388608];(()=>{const e=new Set;Object.entries(Ji).forEach(([t,n])=>{const r=`${n.row}-${n.col}`,l=parseInt(t);e.has(r)||(e.add(r),SX.includes(l)?el[r]="#3a2555":OX.includes(l)?el[r]="#1e2e55":AX.includes(l)?el[r]="#1e3e3e":wX.includes(l)?el[r]="#142040":el[r]="#2a2a2a")})})();const tl="#af7a30";function zg({item:e,size:t=36}){const n={position:"absolute",top:0,left:0,width:t,height:t,border:"none",background:"transparent",imageRendering:"pixelated"},r=e.icon_underlay_id&&e.icon_underlay_id>100?`/icons/${Cs(e.icon_underlay_id)}.png`:null,l=e.icon_overlay_id&&e.icon_overlay_id>100?`/icons/${Cs(e.icon_overlay_id)}.png`:null;return b.jsxs("div",{style:{width:t,height:t,position:"relative"},children:[r&&b.jsx("img",{src:r,alt:"",style:{...n,zIndex:1},onError:u=>{u.target.style.display="none"}}),b.jsx("img",{src:`/icons/${Cs(e.icon)}.png`,alt:e.name,style:{...n,zIndex:2},onError:u=>{u.target.src="/icons/06000133.png"}}),l&&b.jsx("img",{src:l,alt:"",style:{...n,zIndex:3},onError:u=>{u.target.style.display="none"}})]})}function jX({item:e,x:t,y:n}){var c,f;const r=d=>d!=null&&d!==-1&&d!==-1,l=d=>d.toLocaleString(),u=d=>`${((d-1)*100).toFixed(1)}%`;return b.jsxs("div",{style:{position:"fixed",left:t+14,top:n+14,background:"rgba(0,0,0,0.96)",border:"1px solid #555",borderRadius:4,padding:"8px 12px",zIndex:99999,minWidth:200,maxWidth:340,fontSize:13,color:"#ddd",pointerEvents:"none",lineHeight:1.6,fontFamily:'-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif'},children:[b.jsx("div",{style:{color:"#ffcc00",fontWeight:"bold",fontSize:14,marginBottom:4},children:e.name}),b.jsxs("div",{style:{color:"#aaa"},children:["Value: ",l(e.value)," ยท Burden: ",e.burden]}),e.workmanship&&b.jsxs("div",{style:{color:"#aaa"},children:["Workmanship: ",e.workmanship]}),e.material&&b.jsxs("div",{style:{color:"#88ff88"},children:["Material: ",e.material]}),r(e.armor_level)&&b.jsxs("div",{style:{color:"#88ff88"},children:["Armor Level: ",e.armor_level]}),r(e.max_damage)&&b.jsxs("div",{style:{color:"#88ff88"},children:["Max Damage: ",e.max_damage]}),e.damage_range&&b.jsxs("div",{style:{color:"#88ff88"},children:["Damage: ",e.damage_range,e.damage_type?`, ${e.damage_type}`:""]}),r(e.attack_bonus)&&e.attack_bonus!==1&&b.jsxs("div",{style:{color:"#88ff88"},children:["Attack: +",u(e.attack_bonus)]}),r(e.melee_defense_bonus)&&e.melee_defense_bonus!==1&&b.jsxs("div",{style:{color:"#88ff88"},children:["Melee Def: +",u(e.melee_defense_bonus)]}),r(e.magic_defense_bonus)&&e.magic_defense_bonus!==1&&b.jsxs("div",{style:{color:"#88ff88"},children:["Magic Def: +",u(e.magic_defense_bonus)]}),e.equip_skill&&b.jsxs("div",{style:{color:"#ddd"},children:["Skill: ",e.equip_skill]}),r(e.wield_level)&&b.jsxs("div",{style:{color:"#ffaa00"},children:["Wield Level: ",e.wield_level]}),r(e.lore_requirement)&&b.jsxs("div",{style:{color:"#ffaa00"},children:["Lore: ",e.lore_requirement]}),e.imbue&&b.jsxs("div",{style:{color:"#88ff88"},children:["Imbue: ",e.imbue]}),e.item_set&&b.jsxs("div",{style:{color:"#88ff88"},children:["Set: ",e.item_set]}),r(e.tinks)&&b.jsxs("div",{style:{color:"#88ff88"},children:["Tinks: ",e.tinks]}),r(e.damage_rating)&&b.jsxs("div",{children:["Damage Rating: ",e.damage_rating]}),r(e.crit_rating)&&b.jsxs("div",{children:["Crit Rating: ",e.crit_rating]}),r(e.heal_boost_rating)&&b.jsxs("div",{children:["Heal Boost: ",e.heal_boost_rating]}),e.spellcraft&&b.jsxs("div",{style:{color:"#dda0dd"},children:["Spellcraft: ",e.spellcraft]}),r(e.current_mana)&&r(e.max_mana)&&b.jsxs("div",{style:{color:"#98d7ff"},children:["Mana: ",e.current_mana," / ",e.max_mana]}),((f=(c=e.spells)==null?void 0:c.spells)==null?void 0:f.length)>0&&b.jsxs("div",{style:{color:"#4a90e2",marginTop:4,fontSize:12},children:["Spells: ",e.spells.spells.map(d=>d.name).join(", ")]})]})}function vM({iconSrc:e,isActive:t,fillPct:n,label:r,onClick:l}){const u=n>90?"#b7432c":n>70?"#d8a431":"#00ff00";return b.jsxs("div",{onClick:l,title:r,style:{display:"flex",alignItems:"flex-start",gap:2,cursor:"pointer",flexShrink:0,marginTop:3,position:"relative"},children:[t&&b.jsx("span",{style:{position:"absolute",left:-11,top:8,color:tl,fontSize:10},children:"โ–ถ"}),b.jsx("div",{style:{width:30,height:30,border:t?"1px solid #00ff00":"1px solid #333",boxShadow:t?"0 0 4px #00ff00":"none",background:"#000",display:"flex",alignItems:"center",justifyContent:"center"},children:b.jsx("img",{src:e,alt:"",style:{width:26,height:26,objectFit:"contain",imageRendering:"pixelated"},onError:c=>{c.target.src="/icons/06001080.png"}})}),b.jsx("div",{style:{width:7,height:30,background:"#222",border:"1px solid #666",position:"relative",overflow:"hidden",borderRadius:2},title:`${Math.round(n)}% full`,children:b.jsx("div",{style:{position:"absolute",bottom:0,left:0,right:0,height:`${n}%`,background:u,minHeight:n>0?2:0}})})]})}const TX=({id:e,charName:t,zIndex:n})=>{var X,U,V;const[r,l]=B.useState([]),[u,c]=B.useState(!0),[f,d]=B.useState(null),[h,y]=B.useState(null),[v,g]=B.useState(null),[x,j]=B.useState(null);B.useEffect(()=>{console.log("[INV] Loading inventory for",t),c(!0),Promise.all([Ht(`/inventory/${encodeURIComponent(t)}?limit=1000`).catch(L=>(console.error("[INV] fetch error:",L),{items:[]})),Ht(`/character-stats/${encodeURIComponent(t)}`).catch(()=>null)]).then(([L,G])=>{const P=L.items??[];console.log("[INV] Got",P.length,"raw items, first:",P[0]);const $=P.map(_X);console.log("[INV] Normalized",$.length,"items, sample container_ids:",$.slice(0,5).map(W=>W.container_id)),l($),g(G)}).finally(()=>c(!1))},[t]);const S=B.useCallback((L,G)=>{y(L&&G?{item:L,x:G.clientX,y:G.clientY}:null)},[]),_=B.useMemo(()=>{const L=new Set,G=[];return Object.entries(Ji).forEach(([P,$])=>{const W=`${$.row}-${$.col}`;L.has(W)||(L.add(W),G.push({key:W,...$,mask:parseInt(P)}))}),G},[]),{equippedMap:E,containers:w,packItems:M}=B.useMemo(()=>{const L=new Map,G=[],P=new Set,$=new Map;r.forEach(ee=>{ee.object_class===10&&(G.push(ee),P.add(ee.item_id))}),G.sort((ee,le)=>(ee.item_id>>>0)-(le.item_id>>>0));let W=null;return r.forEach(ee=>{ee.current_wielded_location>0&&ee.container_id&&!P.has(ee.container_id)&&(W=ee.container_id)}),r.forEach(ee=>{if(P.has(ee.item_id))return;const le=ee.current_wielded_location;if(le>0)if(ee.object_class===2)Object.entries(Ji).forEach(([Y,ne])=>{if((le&parseInt(Y))===parseInt(Y)){const ue=`${ne.row}-${ne.col}`;L.has(ue)||L.set(ue,ee)}});else{let Y=!1;if(Ji[le]){const ne=Ji[le],ue=`${ne.row}-${ne.col}`;L.has(ue)||(L.set(ue,ee),Y=!0)}if(!Y){for(const[ne,ue]of Object.entries(Ji))if((le&parseInt(ne))===parseInt(ne)){const de=`${ue.row}-${ue.col}`;if(!L.has(de)){L.set(de,ee),Y=!0;break}}}}else{let k=ee.container_id||0;W&&k===W&&(k=0),$.has(k)||$.set(k,[]),$.get(k).push(ee)}}),console.log("[INV DEBUG] containers:",G.map(ee=>({id:ee.item_id,name:ee.name}))),console.log("[INV DEBUG] packItems keys:",[...$.keys()]),console.log("[INV DEBUG] packItems sizes:",[...$.entries()].map(([ee,le])=>`${ee}: ${le.length}`)),{equippedMap:L,containers:G,packItems:$}},[r]);let N=M.get(0)??[],A=0;if(N.length===0){let L=0;for(const[G,P]of M.entries())!w.some($=>$.item_id===G)&&P.length>L&&(L=P.length,A=G);N=M.get(A)??[]}const T=f!==null?M.get(f)??[]:N,C=(v==null?void 0:v.burden_units)??((X=v==null?void 0:v.stats_data)==null?void 0:X.burden_units)??0,D=(v==null?void 0:v.encumbrance_capacity)??((U=v==null?void 0:v.stats_data)==null?void 0:U.encumbrance_capacity)??0,z=D>0?Math.min(200,C/D*100):0,F=z>150?"#b7432c":z>100?"#d8a431":"#2e8b57";return u?b.jsx($r,{id:e,title:`Inventory: ${t}`,zIndex:n,width:572,height:720,children:b.jsx("div",{style:{padding:20,color:"#666",fontStyle:"italic"},children:"Loading inventory..."})}):b.jsxs($r,{id:e,title:`Inventory: ${t}`,zIndex:n,width:572,height:720,children:[b.jsxs("div",{style:{display:"flex",flex:1,overflow:"hidden",background:"rgba(14,14,14,0.96)",fontFamily:'-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif',fontSize:13},children:[b.jsxs("div",{style:{width:316,display:"flex",flexDirection:"column",overflow:"hidden"},children:[b.jsx("div",{style:{position:"relative",height:270,minHeight:270,background:"#0a0a0a",borderBottom:`1px solid ${tl}`},children:_.map(L=>{const G=E.get(L.key),P=el[L.key]??"#2a2a2a";return b.jsx("div",{style:{position:"absolute",left:(L.col-1)*44+4,top:(L.row-1)*44+4,width:36,height:36,background:G?"#5a5a62":P,border:G?"2px solid #00ffff":"2px outset #6a6a72",boxShadow:G?"0 0 5px #00ffff, inset 0 0 5px rgba(0,255,255,0.2)":"none",display:"flex",alignItems:"center",justifyContent:"center",cursor:G?"pointer":"default"},onMouseEnter:$=>G&&S(G,$),onMouseMove:$=>G&&S(G,$),onMouseLeave:()=>S(null),children:G?b.jsx(zg,{item:G,size:32}):b.jsx("img",{src:"/icons/06000133.png",alt:"",style:{width:28,height:28,opacity:.15,filter:"grayscale(100%)",imageRendering:"pixelated"}})},L.key)})}),b.jsxs("div",{style:{padding:"3px 6px",fontSize:11,color:"#ccc",background:"#111",borderBottom:`1px solid ${tl}`},children:["Contents of ",f!==null?((V=w.find(L=>L.item_id===f))==null?void 0:V.name)??"Pack":"Backpack"]}),b.jsxs("div",{style:{flex:1,overflowY:"auto",display:"grid",gridTemplateColumns:"repeat(6, 36px)",gridAutoRows:36,gap:2,padding:4,alignContent:"start"},children:[T.map((L,G)=>b.jsx("div",{style:{width:36,height:36,background:"linear-gradient(135deg, #3d007a 0%, #1a0033 100%)",border:"1px solid #4a148c",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer"},onMouseEnter:P=>S(L,P),onMouseMove:P=>S(L,P),onMouseLeave:()=>S(null),children:b.jsx(zg,{item:L,size:32})},L.item_id??G)),Array.from({length:Math.max(0,24-T.length)}).map((L,G)=>b.jsx("div",{style:{width:36,height:36,background:"#0a0a0a",border:"1px solid #1a1a1a"}},`e${G}`))]})]}),b.jsxs("div",{style:{width:42,display:"flex",flexDirection:"column",alignItems:"center",padding:"4px 2px",borderLeft:`1px solid ${tl}`,borderRight:`1px solid ${tl}`},children:[b.jsx("div",{style:{textAlign:"center",fontSize:8,color:"#ccc",marginBottom:2},children:D>0?`${Math.floor(z)}%`:"Burden"}),b.jsx("div",{style:{width:14,height:40,background:"#111",border:"1px solid #555",position:"relative",overflow:"hidden",marginBottom:6,flexShrink:0},title:D>0?`${C.toLocaleString()} / ${D.toLocaleString()}`:`Burden: ${r.reduce((L,G)=>L+(G.burden??0),0).toLocaleString()}`,children:b.jsx("div",{style:{position:"absolute",bottom:0,left:0,right:0,height:`${z/2}%`,background:F,transition:"height 0.3s"}})}),b.jsx(vM,{iconSrc:"/icons/0600127E.png",isActive:f===null,fillPct:N.length>0?Math.min(100,N.length/102*100):0,label:`Backpack (${N.length}/102)`,onClick:()=>d(null)}),w.map(L=>{const G=L.item_id,P=M.get(G)??[],$=L.items_capacity??24;return b.jsx(vM,{iconSrc:`/icons/${Cs(L.icon)}.png`,isActive:f===G,fillPct:Math.min(100,P.length/$*100),label:`${L.name} (${P.length}/${$})`,onClick:()=>d(G)},G)})]}),b.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden",minWidth:160},children:[b.jsx("div",{style:{padding:"4px 8px",fontSize:"0.72rem",fontWeight:600,color:"#aaa",background:"#111",borderBottom:`1px solid ${tl}`},children:"Mana"}),b.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"2px 0"},children:[Array.from(E.values()).filter(L=>L.current_mana>0||L.max_mana>0).sort((L,G)=>(L.current_mana??999999)-(G.current_mana??999999)).map((L,G)=>b.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4,padding:"2px 4px",borderBottom:"1px solid #1a1a1a",cursor:"pointer"},onMouseEnter:P=>S(L,P),onMouseMove:P=>S(L,P),onMouseLeave:()=>S(null),children:[b.jsx("div",{style:{width:20,height:20,flexShrink:0},children:b.jsx(zg,{item:L,size:20})}),b.jsx("div",{style:{width:8,height:8,borderRadius:"50%",background:L.current_mana>0?"#4c4":"#c44",flexShrink:0}}),b.jsx("div",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:"0.68rem",color:"#ccc"},children:L.name}),b.jsxs("div",{style:{fontSize:"0.65rem",color:"#88bbff",whiteSpace:"nowrap",fontVariantNumeric:"tabular-nums"},children:[L.current_mana??0,"/",L.max_mana??0]}),b.jsx("div",{style:{fontSize:"0.63rem",color:"#9c9",whiteSpace:"nowrap",fontVariantNumeric:"tabular-nums",minWidth:42,textAlign:"right"},children:L.max_mana>0?EX(L.current_mana??0,L.max_mana??0):""})]},G)),Array.from(E.values()).filter(L=>L.current_mana>0||L.max_mana>0).length===0&&b.jsx("div",{style:{padding:12,color:"#555",textAlign:"center",fontSize:"0.7rem"},children:"No mana items equipped"})]})]})]}),h&&b.jsx(jX,{item:h.item,x:h.x,y:h.y})]})};function EX(e,t){if(t<=0||e<=0)return"0h00m";const n=e*20,r=Math.floor(n/3600),l=Math.floor(n%3600/60);return`~${r}h${String(l).padStart(2,"0")}m`}const qg=300,yM=.5,mM={Monster:"#ff4444",Player:"#4488ff",NPC:"#44cc44",Vendor:"#44cc44",Portal:"#aa44ff",Corpse:"#ff8800",Container:"#cccc44",Door:"#888888"};function MX(e){const t=(e%360+360)%360;return["N","NE","E","SE","S","SW","W","NW"][Math.round(t/45)%8]}const CX=({id:e,charName:t,zIndex:n,socket:r,radarData:l})=>{const u=B.useRef(null),c=B.useRef(yM),[f,d]=B.useState(yM),[h,y]=B.useState(null),v=B.useRef(null),g=B.useRef([]);B.useEffect(()=>{const E=new Image;E.src="/dereth.png",E.onload=()=>{v.current=E}},[]),B.useEffect(()=>((r==null?void 0:r.readyState)===WebSocket.OPEN&&r.send(JSON.stringify({player_name:t,command:"start_radar"})),()=>{(r==null?void 0:r.readyState)===WebSocket.OPEN&&r.send(JSON.stringify({player_name:t,command:"stop_radar"}))}),[t,r]);const x=B.useCallback(E=>{E.preventDefault();const w=E.deltaY>0?1.25:.8;c.current=Math.max(.02,Math.min(5,c.current*w)),d(c.current)},[]),j=B.useCallback(E=>{const w=u.current;if(!w)return;const M=w.getBoundingClientRect(),N=(E.clientX-M.left)*(w.width/M.width),A=(E.clientY-M.top)*(w.height/M.height);let T=null,C=20;g.current.forEach(D=>{if(D._px===void 0)return;const z=Math.sqrt((N-D._px)**2+(A-D._py)**2);z{const E=u.current;if(!E||!l)return;const w=E.getContext("2d");if(!w)return;const M=qg,N=M/2,A=M/2,T=l.objects??[],C=l.player_ew??0,D=l.player_ns??0,z=l.player_heading??0,F=l.is_dungeon??!1,X=l.player_x??0,U=l.player_y??0,V=c.current,L=F?M/2/(V*240):M/2/V,G=z*Math.PI/180;if(w.clearRect(0,0,M,M),w.fillStyle="#111",w.beginPath(),w.arc(N,A,N,0,Math.PI*2),w.fill(),w.save(),w.beginPath(),w.arc(N,A,N-1,0,Math.PI*2),w.clip(),!F&&v.current){const ee=v.current,le=ee.naturalWidth/204.2,k=(C+102.1)*le,Y=(102.1-D)*le;w.globalAlpha=.4,w.save(),w.translate(N,A),w.rotate(-G),w.drawImage(ee,k-N/L*le,Y-A/L*le,M/L*le,M/L*le,-N,-A,M,M),w.restore(),w.globalAlpha=1}w.restore(),w.strokeStyle="#333",w.lineWidth=1;for(let ee=1;ee<=4;ee++)w.beginPath(),w.arc(N,A,N/4*ee,0,Math.PI*2),w.stroke();w.beginPath(),w.moveTo(N,0),w.lineTo(N,M),w.moveTo(0,A),w.lineTo(M,A),w.stroke(),w.font="bold 12px monospace",w.textAlign="center",w.textBaseline="middle",[{l:"N",a:0},{l:"E",a:Math.PI/2},{l:"S",a:Math.PI},{l:"W",a:-Math.PI/2}].forEach(({l:ee,a:le})=>{const k=le-G;w.fillStyle=ee==="N"?"#cc4444":"#888",w.fillText(ee,N+Math.sin(k)*(N-12),A-Math.cos(k)*(N-12))}),w.strokeStyle="#666",w.lineWidth=1,w.beginPath(),w.moveTo(N,A),w.lineTo(N,A-N*.85),w.stroke();const P=F?Math.PI-G:G,$=Math.cos(P),W=Math.sin(P);T.forEach(ee=>{let le,k;F&&ee.raw_x!==void 0?(le=-(ee.raw_x-X),k=ee.raw_y-U):(le=(ee.ew??0)-C,k=(ee.ns??0)-D);const Y=le*$-k*W,ne=F?le*W+k*$:-(le*W+k*$),ue=N+Y*L,de=A+ne*L;if(Math.sqrt((ue-N)**2+(de-A)**2)>N-4)return;ee._px=ue,ee._py=de;const Oe=ee.object_class??ee.type??"",$e=mM[Oe]??"#888",se=ee.id===h,be=se?6:Oe==="Monster"||Oe==="Player"?4:3;se&&(w.strokeStyle="#fff",w.lineWidth=2,w.beginPath(),w.arc(ue,de,be+3,0,Math.PI*2),w.stroke()),w.fillStyle=$e,w.beginPath(),w.arc(ue,de,be,0,Math.PI*2),w.fill(),(Oe==="Player"||Oe==="Portal"||se)&&(w.fillStyle=se?"#fff":$e,w.font="9px monospace",w.textAlign="left",w.fillText(ee.name,ue+6,de+3))}),g.current=T,w.fillStyle="#ffcc00",w.beginPath(),w.arc(N,A,5,0,Math.PI*2),w.fill(),w.strokeStyle="#fff",w.lineWidth=1,w.stroke()},[l,f,h]);const S=((l==null?void 0:l.objects)??[]).map(E=>{const w=(l==null?void 0:l.player_ew)??0,M=(l==null?void 0:l.player_ns)??0,N=(l==null?void 0:l.is_dungeon)??!1,A=(l==null?void 0:l.player_x)??0,T=(l==null?void 0:l.player_y)??0;let C,D,z;N&&E.raw_x!==void 0?(C=-(E.raw_x-A),D=E.raw_y-T,z=Math.sqrt(C*C+D*D)):(C=(E.ew??0)-w,D=(E.ns??0)-M,z=Math.sqrt(C*C+D*D)*240);const F=Math.atan2(C,D)*180/Math.PI;return{...E,dist:z,dir:MX(F)}}).sort((E,w)=>E.dist-w.dist),_=Math.round(f*240);return b.jsxs($r,{id:e,title:`Radar: ${t}`,zIndex:n,width:360,height:560,children:[b.jsxs("div",{style:{padding:"4px 8px",display:"flex",justifyContent:"space-between",fontSize:"0.75rem",color:"#888",borderBottom:"1px solid #333",background:"#1a1a1a"},children:[b.jsxs("span",{children:["Range: ~",_,"m"]}),b.jsx("span",{style:{fontSize:"0.65rem",color:"#555"},children:"Scroll to zoom"})]}),b.jsx("canvas",{ref:u,width:qg,height:qg,style:{display:"block",margin:"0 auto",borderBottom:"1px solid #333",cursor:"crosshair",flexShrink:0},onWheel:x,onClick:j}),b.jsxs("div",{style:{flex:1,overflowY:"auto",fontSize:"0.72rem",minHeight:0},children:[b.jsxs("div",{style:{display:"flex",padding:"3px 6px",borderBottom:"1px solid #333",color:"#666",fontSize:"0.65rem",fontWeight:600},children:[b.jsx("span",{style:{width:8}}),b.jsx("span",{style:{flex:1,marginLeft:6},children:"Name"}),b.jsx("span",{style:{width:55,textAlign:"left"},children:"Type"}),b.jsx("span",{style:{width:40,textAlign:"right"},children:"Dist"}),b.jsx("span",{style:{width:24,textAlign:"center"},children:"Dir"})]}),S.length===0&&b.jsx("div",{style:{padding:12,color:"#555",textAlign:"center",fontSize:"0.7rem"},children:"Waiting for radar data..."}),S.map(E=>{const w=E.object_class??E.type??"",M=mM[w]??"#888",N=E.id===h;return b.jsxs("div",{onClick:()=>y(N?null:E.id),style:{display:"flex",alignItems:"center",padding:"2px 6px",borderBottom:"1px solid #1a1a1a",cursor:"pointer",color:"#ccc",background:N?"#1a2a3a":"",borderLeft:N?"2px solid #4488ff":"2px solid transparent"},children:[b.jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:M,flexShrink:0}}),b.jsx("span",{style:{flex:1,marginLeft:6,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:E.name}),b.jsx("span",{style:{width:55,color:"#888",fontSize:"0.65rem"},children:w}),b.jsx("span",{style:{width:40,textAlign:"right",fontVariantNumeric:"tabular-nums"},children:E.dist<1e3?`${Math.round(E.dist)}m`:`${(E.dist/1e3).toFixed(1)}km`}),b.jsx("span",{style:{width:24,textAlign:"center",color:"#666"},children:E.dir})]},E.id)})]})]})},Fo=["Typeless","Slash","Pierce","Bludgeon","Fire","Cold","Acid","Electric"];function ha(e,t,n){var r,l,u,c;return(((l=(r=e==null?void 0:e[t])==null?void 0:r[n])==null?void 0:l.total_normal_damage)??0)+(((c=(u=e==null?void 0:e[t])==null?void 0:u[n])==null?void 0:c.total_crit_damage)??0)}function NX(e){let t={attacks:0,failed:0,crits:0,normalDmg:0,maxNormal:0,critDmg:0,maxCrit:0};if(!e)return t;for(const n of Object.values(e))for(const r of Object.values(n))t.attacks+=r.total_attacks??0,t.failed+=r.failed_attacks??0,t.crits+=r.crits??0,t.normalDmg+=r.total_normal_damage??0,t.maxNormal=Math.max(t.maxNormal,r.max_normal_damage??0),t.critDmg+=r.total_crit_damage??0,t.maxCrit=Math.max(t.maxCrit,r.max_crit_damage??0);return t}function gM(e,t){let n={attacks:0,failed:0};const r=e==null?void 0:e[t];if(!r)return n;for(const l of Object.values(r))n.attacks+=l.total_attacks??0,n.failed+=l.failed_attacks??0;return n}const RX=({id:e,charName:t,zIndex:n})=>{const[r,l]=B.useState(null),[u,c]=B.useState("session"),[f,d]=B.useState(null);B.useEffect(()=>{Ht(`/combat-stats/${encodeURIComponent(t)}`).then(l).catch(()=>{});const C=setInterval(()=>{Ht(`/combat-stats/${encodeURIComponent(t)}`).then(l).catch(()=>{})},1e4);return()=>clearInterval(C)},[t]);const h=r==null?void 0:r[u],y=(h==null?void 0:h.monsters)??{},v=Object.keys(y).filter(C=>C!=="__cloak_surges__").sort(),g=B.useMemo(()=>{let C={},D={},z=0,F=0;const X=f?[y[f]].filter(Boolean):v.map(U=>y[U]);for(const U of X)if(U){for(const[V,L]of Object.entries(U.offense??{})){C[V]||(C[V]={});for(const[G,P]of Object.entries(L)){C[V][G]||(C[V][G]={total_attacks:0,failed_attacks:0,crits:0,total_normal_damage:0,max_normal_damage:0,total_crit_damage:0,max_crit_damage:0});const $=C[V][G],W=P;$.total_attacks+=W.total_attacks??0,$.failed_attacks+=W.failed_attacks??0,$.crits+=W.crits??0,$.total_normal_damage+=W.total_normal_damage??0,$.max_normal_damage=Math.max($.max_normal_damage,W.max_normal_damage??0),$.total_crit_damage+=W.total_crit_damage??0,$.max_crit_damage=Math.max($.max_crit_damage,W.max_crit_damage??0)}}for(const[V,L]of Object.entries(U.defense??{})){D[V]||(D[V]={});for(const[G,P]of Object.entries(L)){D[V][G]||(D[V][G]={total_attacks:0,failed_attacks:0,crits:0,total_normal_damage:0,max_normal_damage:0,total_crit_damage:0,max_crit_damage:0});const $=D[V][G],W=P;$.total_attacks+=W.total_attacks??0,$.failed_attacks+=W.failed_attacks??0,$.total_normal_damage+=W.total_normal_damage??0,$.max_normal_damage=Math.max($.max_normal_damage,W.max_normal_damage??0),$.total_crit_damage+=W.total_crit_damage??0,$.max_crit_damage=Math.max($.max_crit_damage,W.max_crit_damage??0)}}z+=U.aetheria_surges??0,F+=U.cloak_surges??0}return y.__cloak_surges__&&!f&&(F+=y.__cloak_surges__.cloak_surges??0),{offense:C,defense:D,aeth:z,cloak:F}},[y,v,f]),x=NX(g.offense),j=gM(g.defense,"MeleeMissile"),S=gM(g.defense,"Magic");x.attacks>0&&((x.attacks-x.failed)/x.attacks*100).toFixed(0);const _=j.attacks>0?(j.failed/j.attacks*100).toFixed(0):"0",E=S.attacks>0?(S.failed/S.attacks*100).toFixed(0):"0",w=x.attacks-x.failed,M=w-x.crits,N=M>0?Math.round(x.normalDmg/M):0;x.crits>0&&Math.round(x.critDmg/x.crits);const A=w>0?(x.crits/w*100).toFixed(1):"0",T=C=>C===0?"":C.toLocaleString();return b.jsxs($r,{id:e,title:`Combat: ${t}`,zIndex:n,width:640,height:520,children:[b.jsxs("div",{style:{display:"flex",gap:4,padding:"4px 8px",borderBottom:"1px solid #333"},children:[b.jsx("button",{className:`ml-stats-range-btn ${u==="session"?"active":""}`,onClick:()=>c("session"),children:"Session"}),b.jsx("button",{className:`ml-stats-range-btn ${u==="lifetime"?"active":""}`,onClick:()=>c("lifetime"),children:"Lifetime"})]}),b.jsxs("div",{style:{display:"flex",flex:1,overflow:"hidden"},children:[b.jsxs("div",{style:{width:240,borderRight:"1px solid #333",overflowY:"auto",fontSize:"0.72rem"},children:[b.jsxs("div",{style:{display:"flex",padding:"3px 6px",borderBottom:"1px solid #333",color:"#777",fontSize:"0.65rem",fontWeight:600},children:[b.jsx("span",{style:{width:14}}),b.jsx("span",{style:{flex:1},children:"Monster"}),b.jsx("span",{style:{width:40,textAlign:"right"},children:"Kills"}),b.jsx("span",{style:{width:55,textAlign:"right"},children:"Dmg"})]}),b.jsxs("div",{style:{display:"flex",padding:"3px 6px",cursor:"pointer",background:f===null?"#2a3a4a":"",borderBottom:"1px solid #222",color:"#ddd"},onClick:()=>d(null),children:[b.jsx("span",{style:{width:14,color:"#888"},children:f===null?"*":""}),b.jsx("span",{style:{flex:1},children:"All"}),b.jsx("span",{style:{width:40,textAlign:"right"},children:T((h==null?void 0:h.total_kills)??0)}),b.jsx("span",{style:{width:55,textAlign:"right"},children:T((h==null?void 0:h.total_damage_given)??0)})]}),v.map(C=>{const D=y[C];return b.jsxs("div",{style:{display:"flex",padding:"2px 6px",cursor:"pointer",background:f===C?"#2a3a4a":"",borderBottom:"1px solid #1a1a1a",color:"#ccc"},onClick:()=>d(C),children:[b.jsx("span",{style:{width:14,color:"#888"},children:f===C?"*":""}),b.jsx("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:C}),b.jsx("span",{style:{width:40,textAlign:"right"},children:T(D.kill_count)}),b.jsx("span",{style:{width:55,textAlign:"right"},children:T(D.damage_given)})]},C)})]}),b.jsx("div",{style:{flex:1,overflowY:"auto",padding:6,fontSize:"0.72rem"},children:b.jsxs("table",{style:{width:"100%",borderCollapse:"collapse"},children:[b.jsx("thead",{children:b.jsxs("tr",{style:{color:"#777",fontSize:"0.65rem"},children:[b.jsx("th",{style:{textAlign:"left",padding:"1px 4px"}}),b.jsx("th",{style:{textAlign:"right",padding:"1px 3px"},children:"Given M/M"}),b.jsx("th",{style:{textAlign:"right",padding:"1px 3px"},children:"Given Mag"}),b.jsx("th",{style:{width:4}}),b.jsx("th",{style:{textAlign:"right",padding:"1px 3px"},children:"Recv M/M"}),b.jsx("th",{style:{textAlign:"right",padding:"1px 3px"},children:"Recv Mag"}),b.jsx("th",{style:{width:4}}),b.jsx("th",{style:{textAlign:"left",padding:"1px 3px"},children:"Stats"}),b.jsx("th",{style:{textAlign:"right",padding:"1px 3px"}})]})}),b.jsxs("tbody",{children:[Fo.map((C,D)=>{const z=[["Evades",j.attacks>0?`${T(j.attacks)} (${_}%)`:""],["Resists",S.attacks>0?`${T(S.attacks)} (${E}%)`:""],["A.Surges",g.aeth>0?`${T(g.aeth)}`:""],["C.Surges",g.cloak>0?`${T(g.cloak)}`:""],["",""],["",""],["Av/Mx",N>0?`${T(N)} / ${T(x.maxNormal)}`:""],["Crits",x.crits>0?`${T(x.crits)} (${A}%)`:""]][D]??["",""];return b.jsxs("tr",{children:[b.jsx("td",{style:{padding:"1px 4px",color:"#888"},children:C}),b.jsx("td",{style:{textAlign:"right",padding:"1px 3px",color:"#ccc"},children:T(ha(g.offense,"MeleeMissile",C))}),b.jsx("td",{style:{textAlign:"right",padding:"1px 3px",color:"#ccc"},children:T(ha(g.offense,"Magic",C))}),b.jsx("td",{}),b.jsx("td",{style:{textAlign:"right",padding:"1px 3px",color:"#ccc"},children:T(ha(g.defense,"MeleeMissile",C))}),b.jsx("td",{style:{textAlign:"right",padding:"1px 3px",color:"#ccc"},children:T(ha(g.defense,"Magic",C))}),b.jsx("td",{}),b.jsx("td",{style:{padding:"1px 3px",color:"#777",fontWeight:600,fontSize:"0.65rem"},children:z[0]}),b.jsx("td",{style:{textAlign:"right",padding:"1px 3px",color:"#ccc"},children:z[1]})]},C)}),b.jsx("tr",{children:b.jsx("td",{colSpan:9,style:{height:4}})}),b.jsxs("tr",{children:[b.jsx("td",{style:{padding:"1px 4px",color:"#888",fontWeight:600},children:"Total"}),b.jsx("td",{style:{textAlign:"right",padding:"1px 3px",color:"#ccc"},children:T(Fo.reduce((C,D)=>C+ha(g.offense,"MeleeMissile",D),0))}),b.jsx("td",{style:{textAlign:"right",padding:"1px 3px",color:"#ccc"},children:T(Fo.reduce((C,D)=>C+ha(g.offense,"Magic",D),0))}),b.jsx("td",{}),b.jsx("td",{style:{textAlign:"right",padding:"1px 3px",color:"#ccc"},children:T(Fo.reduce((C,D)=>C+ha(g.defense,"MeleeMissile",D),0))}),b.jsx("td",{style:{textAlign:"right",padding:"1px 3px",color:"#ccc"},children:T(Fo.reduce((C,D)=>C+ha(g.defense,"Magic",D),0))}),b.jsx("td",{}),b.jsx("td",{style:{padding:"1px 3px",color:"#777",fontWeight:600,fontSize:"0.65rem"},children:"Total"}),b.jsx("td",{style:{textAlign:"right",padding:"1px 3px",color:"#ccc"},children:T(x.normalDmg+x.critDmg)})]})]})]})})]})]})},PX={plugin:"#4488ff",overlord:"#44cc44",nav:"#ffaa00",macro:"#cc44cc",other:"#888"},DX=({id:e,zIndex:t})=>{const[n,r]=B.useState([]),[l,u]=B.useState(""),[c,f]=B.useState(""),[d,h]=B.useState("plugin"),y=B.useCallback(async()=>{try{const x=await Ht("/issues");r((x.issues??[]).sort((j,S)=>(j.resolved?1:0)-(S.resolved?1:0)))}catch{}},[]);B.useEffect(()=>{y()},[y]);const v=async()=>{l.trim()&&(await fetch("/api/issues",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({title:l.trim(),description:c.trim(),category:d})}),u(""),f(""),y())},g=async x=>{await fetch(`/api/issues/${x.id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({resolved:!x.resolved})}),y()};return b.jsxs($r,{id:e,title:"Issues Board",zIndex:t,width:540,height:520,children:[b.jsx("div",{style:{flex:1,overflowY:"auto",padding:6,fontSize:"0.75rem"},children:n.length===0?b.jsx("div",{style:{padding:12,color:"#666",textAlign:"center"},children:"No issues"}):n.map(x=>b.jsxs("div",{style:{padding:"6px 8px",marginBottom:4,background:"#1f1f1f",borderRadius:3,border:"1px solid #333",opacity:x.resolved?.5:1},children:[b.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[b.jsx("span",{style:{fontSize:"0.6rem",padding:"1px 6px",borderRadius:3,background:PX[x.category]??"#888",color:"#111",fontWeight:600},children:x.category}),b.jsx("span",{style:{flex:1,fontWeight:500},children:x.title}),b.jsx("button",{onClick:()=>g(x),style:{fontSize:"0.65rem",padding:"1px 6px",background:x.resolved?"#333":"rgba(68,204,68,0.15)",color:x.resolved?"#888":"#4c4",border:"1px solid #444",borderRadius:3,cursor:"pointer"},children:x.resolved?"โ†ป Reopen":"โœ“ Resolve"})]}),x.description&&b.jsx("div",{style:{color:"#888",marginTop:3,fontSize:"0.7rem"},children:x.description}),b.jsxs("div",{style:{color:"#555",fontSize:"0.6rem",marginTop:2},children:["by ",x.author," ยท ",new Date(x.created).toLocaleDateString()]})]},x.id))}),b.jsxs("div",{style:{padding:6,borderTop:"1px solid #333",display:"flex",flexDirection:"column",gap:3},children:[b.jsxs("div",{style:{display:"flex",gap:4},children:[b.jsx("input",{value:l,onChange:x=>u(x.target.value),placeholder:"Issue title...",style:{flex:1,padding:"3px 6px",fontSize:"0.75rem",background:"#222",color:"#eee",border:"1px solid #444",borderRadius:3}}),b.jsxs("select",{value:d,onChange:x=>h(x.target.value),style:{padding:"3px 4px",fontSize:"0.7rem",background:"#222",color:"#eee",border:"1px solid #444",borderRadius:3},children:[b.jsx("option",{value:"plugin",children:"Plugin"}),b.jsx("option",{value:"overlord",children:"Overlord"}),b.jsx("option",{value:"nav",children:"Nav"}),b.jsx("option",{value:"macro",children:"Macro"}),b.jsx("option",{value:"other",children:"Other"})]})]}),b.jsxs("div",{style:{display:"flex",gap:4},children:[b.jsx("textarea",{value:c,onChange:x=>f(x.target.value),placeholder:"Description...",rows:2,style:{flex:1,padding:"3px 6px",fontSize:"0.7rem",background:"#222",color:"#eee",border:"1px solid #444",borderRadius:3,resize:"vertical"}}),b.jsx("button",{onClick:v,style:{padding:"4px 12px",background:"rgba(68,136,255,0.15)",color:"#6aadff",border:"1px solid rgba(68,136,255,0.3)",borderRadius:3,cursor:"pointer",alignSelf:"flex-end",fontSize:"0.7rem"},children:"Add"})]})]})]})},kX=({id:e,zIndex:t})=>{const[n,r]=B.useState([]);B.useEffect(()=>{const u=async()=>{try{const f=await Ht("/vital-sharing/peers");r(f.peers??[])}catch{}};u();const c=setInterval(u,5e3);return()=>clearInterval(c)},[]);const l=(u,c)=>c>0?Math.min(100,u/c*100):0;return b.jsx($r,{id:e,title:"Vital Sharing Network",zIndex:t,width:520,height:450,children:b.jsx("div",{style:{flex:1,overflowY:"auto",padding:6,fontSize:"0.75rem"},children:n.length===0?b.jsx("div",{style:{padding:16,color:"#666",textAlign:"center"},children:"No vital-sharing peers connected"}):n.map(u=>{var c,f,d;return b.jsxs("div",{style:{padding:"6px 8px",marginBottom:4,background:"#1f1f1f",borderRadius:3,border:"1px solid #333"},children:[b.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:3},children:[b.jsx("span",{style:{color:u.plugin_connected?"#4c4":"#a33",fontSize:"0.8rem"},children:"โ—"}),b.jsx("strong",{style:{flex:1},children:u.character_name}),u.subscribed&&b.jsx("span",{style:{color:"#6bf",fontSize:"0.65rem"},children:"[subscribed]"})]}),b.jsxs("div",{style:{color:"#666",fontSize:"0.68rem",marginBottom:3},children:["tags: ",((c=u.tags)==null?void 0:c.join(", "))||"none"]}),u.vitals&&u.vitals.max_health>0&&b.jsx("div",{style:{display:"flex",flexDirection:"column",gap:2},children:[{label:"HP",cur:u.vitals.current_health,max:u.vitals.max_health,bg:"#330000",fill:"#c44"},{label:"STA",cur:u.vitals.current_stamina,max:u.vitals.max_stamina,bg:"#331a00",fill:"#ca0"},{label:"MANA",cur:u.vitals.current_mana,max:u.vitals.max_mana,bg:"#001433",fill:"#48f"}].map(h=>b.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4},children:[b.jsx("span",{style:{width:32,color:"#888",fontSize:"0.65rem"},children:h.label}),b.jsx("div",{style:{flex:1,height:6,background:h.bg,borderRadius:3,overflow:"hidden"},children:b.jsx("div",{style:{width:`${l(h.cur,h.max)}%`,height:"100%",background:h.fill,borderRadius:3}})}),b.jsxs("span",{style:{width:60,textAlign:"right",fontSize:"0.65rem",color:"#888"},children:[h.cur,"/",h.max]})]},h.label))}),u.position&&b.jsxs("div",{style:{color:"#555",fontSize:"0.65rem",marginTop:2},children:[(f=u.position.ns)==null?void 0:f.toFixed(1),"N, ",(d=u.position.ew)==null?void 0:d.toFixed(1),"E"]})]},u.character_name)})})})},$X=({characters:e,chatMessages:t,nearbyObjects:n,socket:r})=>{const{windows:l}=vd();return console.log("[WR] Rendering",l.length,"windows:",l.map(u=>u.id)),b.jsx(b.Fragment,{children:l.map(u=>{var d;const c=u.charName??"",f=u.id.split("-")[0];switch(console.log("[WR] Window:",u.id,"prefix:",f,"charName:",c),f){case"chat":return b.jsx(yX,{id:u.id,charName:c,zIndex:u.zIndex,messages:t.get(c)??[],socket:r},u.id);case"stats":return b.jsx(bX,{id:u.id,charName:c,zIndex:u.zIndex},u.id);case"char":return b.jsx(xX,{id:u.id,charName:c,zIndex:u.zIndex,vitals:((d=e.get(c))==null?void 0:d.vitals)??void 0},u.id);case"inv":return b.jsx(TX,{id:u.id,charName:c,zIndex:u.zIndex},u.id);case"radar":return b.jsx(CX,{id:u.id,charName:c,zIndex:u.zIndex,socket:r,radarData:n.get(c)??null},u.id);case"combat":return b.jsx(RX,{id:u.id,charName:c,zIndex:u.zIndex},u.id);case"issues":return b.jsx(DX,{id:u.id,zIndex:u.zIndex},u.id);case"vitalsharing":return b.jsx(kX,{id:u.id,zIndex:u.zIndex},u.id);default:return null}})})};let zX=0;const qX=({recentRares:e})=>{const[t,n]=B.useState([]),[r,l]=B.useState(0),[u,c]=B.useState([]);B.useEffect(()=>{if(e.length>r&&r>0){const d=e.slice(0,e.length-r);for(const h of d){const y=++zX;n(v=>[...v,{key:y,charName:h.character_name,rareName:h.name,exiting:!1}]),f(),setTimeout(()=>{n(v=>v.map(g=>g.key===y?{...g,exiting:!0}:g)),setTimeout(()=>{n(v=>v.filter(g=>g.key!==y))},500)},6e3)}}l(e.length)},[e.length]);const f=B.useCallback(()=>{const d=Date.now(),h=["#FFD700","#FF4444","#FF8800","#AA44FF","#4488FF"],y=Array.from({length:30},(v,g)=>{const x=Math.PI*2*g/30+(Math.random()-.5)*.5,j=100+Math.random()*200;return{dx:Math.cos(x)*j,dy:Math.sin(x)*j-50,color:h[Math.floor(Math.random()*h.length)]}});c(v=>[...v,{id:d,particles:y}]),setTimeout(()=>c(v=>v.filter(g=>g.id!==d)),2200)},[]);return b.jsxs(b.Fragment,{children:[b.jsx("div",{className:"ml-rare-notifications",children:t.map(d=>b.jsxs("div",{className:`ml-rare-notif ${d.exiting?"exiting":""}`,children:[b.jsx("div",{className:"ml-rare-notif-title",children:"LEGENDARY RARE!"}),b.jsx("div",{className:"ml-rare-notif-name",children:d.rareName}),b.jsx("div",{className:"ml-rare-notif-by",children:"found by"}),b.jsx("div",{className:"ml-rare-notif-char",children:d.charName})]},d.key))}),b.jsx("div",{className:"ml-fireworks",children:u.map(d=>b.jsx(I.Fragment,{children:d.particles.map((h,y)=>b.jsx("div",{className:"ml-firework-particle",style:{left:"50%",top:"30%",backgroundColor:h.color,"--dx":`${h.dx}px`,"--dy":`${h.dy+200}px`}},y))},d.id))})]})},bM=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf","#ff4444","#44ff44","#4444ff","#ffff44","#ff44ff","#44ffff","#ff8844","#88ff44","#4488ff","#ff4488","#cc3333","#33cc33","#3333cc","#cccc33","#cc33cc","#33cccc","#cc6633","#66cc33","#3366cc","#cc3366","#ff6666","#66ff66","#6666ff","#ffff66","#ff66ff","#66ffff","#ffaa66","#aaff66","#66aaff","#ff66aa","#990099","#009900","#000099","#990000","#009999","#999900","#aa5500","#55aa00","#0055aa","#aa0055","#ffaaaa","#aaffaa","#aaaaff","#ffffaa","#ffaaff","#aaffff","#ffccaa","#ccffaa","#aaccff","#ffaacc"];function BX(e){let t=0;for(let n=0;n{let l=e.current.get(r);return l||(l=t.current{const n=LX(),[r,l]=B.useState(!1),[u,c]=B.useState(!1),f=Array.from(e.characters.values()).filter(y=>y.telemetry).map(y=>y.telemetry),d=new Map(Array.from(e.characters.values()).filter(y=>y.vitals).map(y=>[y.name,y.vitals])),h=B.useCallback(y=>{},[]);return b.jsx(rX,{children:b.jsx(iX,{children:b.jsxs("div",{className:"ml-layout",children:[b.jsx(pX,{players:f,vitals:d,serverHealth:e.serverHealth,totalRares:e.totalRares,totalKills:e.totalKills,getColor:n,onSelectPlayer:h,onViewToggle:t,showHeatmap:r,showPortals:u,onToggleHeatmap:l,onTogglePortals:c}),b.jsx(cX,{players:f,getColor:n,onSelectPlayer:h,showHeatmap:r,showPortals:u}),b.jsx($X,{characters:e.characters,chatMessages:e.chatMessages,nearbyObjects:e.nearbyObjects,socket:e.socketRef.current}),b.jsx(qX,{recentRares:e.recentRares})]})})})};function UX(e){const t=B.useRef(null),n=B.useRef(0),r=B.useRef(e);r.current=e;const l=B.useCallback(()=>{var c;if(((c=t.current)==null?void 0:c.readyState)===WebSocket.OPEN)return;const u=new WebSocket(QY());t.current=u,u.addEventListener("message",f=>{try{const d=JSON.parse(f.data);r.current(d)}catch{}}),u.addEventListener("close",()=>{t.current=null,n.current=window.setTimeout(l,2e3)}),u.addEventListener("error",()=>{u.close()})},[]);return B.useEffect(()=>(l(),()=>{var u;clearTimeout(n.current),(u=t.current)==null||u.close(),t.current=null}),[l]),t}const HX=()=>Ht("/live"),GX=()=>Ht("/combat-stats"),YX=()=>Ht("/server-health"),XX=()=>Ht("/total-rares"),KX=()=>Ht("/total-kills");function VX(){const[e,t]=B.useState(new Map),[n,r]=B.useState(null),[l,u]=B.useState(0),[c,f]=B.useState(0),[d,h]=B.useState([]),[y,v]=B.useState(new Map),[g,x]=B.useState(new Map),j=B.useRef(e);j.current=e;const S=B.useCallback((w,M)=>{t(N=>{const A=new Map(N),T=A.get(w)??{name:w,telemetry:null,vitals:null,combat:null,lastUpdate:0};return A.set(w,M(T)),A})},[]),_=B.useCallback(w=>{if(w.type){if(w.type==="telemetry"){const M=w;S(M.character_name,N=>({...N,telemetry:M,lastUpdate:Date.now()}))}else if(w.type==="vitals"){const M=w;S(M.character_name,N=>({...N,vitals:M,lastUpdate:Date.now()}))}else if(w.type==="combat_stats"){const M=w;S(M.character_name,N=>({...N,combat:M,lastUpdate:Date.now()}))}else if(w.type==="rare"){const M=w;h(N=>[M,...N].slice(0,50))}else if(w.type==="nearby_objects"){const M=w;x(N=>{const A=new Map(N);return A.set(M.character_name,M),A})}else if(w.type==="chat"){const M=w;v(N=>{const A=new Map(N),T=[...A.get(M.character_name)??[],{text:M.text,color:M.color,timestamp:M.timestamp}];return T.length>1e3&&T.splice(0,T.length-1e3),A.set(M.character_name,T),A})}}},[S]),E=UX(_);return B.useEffect(()=>{const w=async()=>{try{const N=await HX();t(A=>{var C;const T=new Map(A);for(const D of N.players??[]){const z=T.get(D.character_name);T.set(D.character_name,{name:D.character_name,telemetry:D,vitals:(z==null?void 0:z.vitals)??null,combat:(z==null?void 0:z.combat)??null,lastUpdate:Date.now()})}for(const D of T.keys())(C=N.players)!=null&&C.some(z=>z.character_name===D)||T.delete(D);return T})}catch{}};w();const M=setInterval(w,5e3);return()=>clearInterval(M)},[]),B.useEffect(()=>{const w=async()=>{try{const N=await GX();for(const A of N.stats??[])S(A.character_name,T=>({...T,combat:{...A,type:"combat_stats"}}))}catch{}};w();const M=setInterval(w,3e4);return()=>clearInterval(M)},[S]),B.useEffect(()=>{const w=async()=>{try{r(await YX())}catch{}};w();const M=setInterval(w,3e4);return()=>clearInterval(M)},[]),B.useEffect(()=>{const w=async()=>{try{const[N,A]=await Promise.all([XX(),KX()]);u(N.all_time??0),f(A.total??0)}catch{}};w();const M=setInterval(w,3e5);return()=>clearInterval(M)},[]),{characters:e,serverHealth:n,totalRares:l,totalKills:c,recentRares:d,chatMessages:y,nearbyObjects:g,socketRef:E}}function FX(){const[e,t]=B.useState(()=>localStorage.getItem("v2-view")||"map"),n=VX(),r=()=>{const u=e==="map"?"dashboard":"map";t(u),localStorage.setItem("v2-view",u)};if(e==="map")return b.jsx(IX,{data:n,onViewToggle:r});const l=[{id:"combat",label:"Combat",content:b.jsx(KY,{characters:n.characters})},{id:"rares",label:"Rares",content:b.jsx(VY,{characters:n.characters,totalRares:n.totalRares,totalKills:n.totalKills,recentRares:n.recentRares})},{id:"map",label:"Map",content:b.jsx(WY,{characters:n.characters})},{id:"inventory",label:"Inventory",content:b.jsx(JY,{})}];return b.jsxs(bD,{children:[b.jsx("div",{style:{display:"flex",justifyContent:"flex-end",marginBottom:8},children:b.jsx("button",{onClick:r,className:"tab-btn",children:"Map View"})}),b.jsx(xD,{activeChars:n.characters.size,totalKills:n.totalKills,totalRares:n.totalRares,serverHealth:n.serverHealth}),b.jsx(SD,{characters:n.characters}),b.jsx(OD,{tabs:l})]})}gD.createRoot(document.getElementById("root")).render(b.jsx(B.StrictMode,{children:b.jsx(FX,{})})); diff --git a/static/v2/index.html b/static/v2/index.html index 299d4efe..a2fff7ef 100644 --- a/static/v2/index.html +++ b/static/v2/index.html @@ -5,7 +5,7 @@ Mosswart Overlord v2 - +